-
Notifications
You must be signed in to change notification settings - Fork 36
Home
Each Exchange plugin is different but there are some common structural threads.
A good way to get started is to copy either changenow.js
or changelly.js
in src/plugins
and create your own .js
file with the correct name
The main driver of your plugin is a central function makeYourPluginNamePlugin
. Obviously change the name of the function.
Import that function into ./index.js
by following the pattern already established in that file.
Key items to make sure you copy over and customize are
const swapInfo = {
pluginName: '',
displayName: '',
quoteUri: '',
supportEmail: ''
}
const dontUseLegacy = {
DGB: true
}
// returns addresses
async function getAddress (
wallet: EdgeCurrencyWallet,
currencyCode: string
): Promise<string> {
const addressInfo = await wallet.getReceiveAddress({ currencyCode })
return addressInfo.legacyAddress && !dontUseLegacy[currencyCode]
? addressInfo.legacyAddress
: addressInfo.publicAddress
}
This block of code is for if your plugin uses legacy address types.
This function will need to do the these basic processes. This may entail several calls to your api or just one.
- determine if your exchange supports the swap being requested.
- format the request in a way your API will understand and call to get quote
- Is the requested amount above or below any set limits you currently have on the api that does not make the swap feasible.
- If quote can be made, what are the miner fees etc.
- create a spend info
- call make
swapInfoQuote
When referencing ChangeNow and Changelly you will see a distinct difference. Change now supports both estimate and exact quotes while changelly is only one type. So there is a lot less logic.
In order to test your plugin and have it published you will need to follow the instructions in the project for edge-react-gui.
NOTE: clone this repository and the edge-react-gui repository into the same folder. Do not change the names of the folders from their defaults. This will be important for testing.
Follow instructions in Gui Wiki for integration into app instructions
Anytime you want to make changes to your plugin and test in the app, the easiest way to do this is to leverage updot.
- Save your changes in your local branch of this repository
- In terminal, in the top level director of edge-react-gui
npm run updot edge-exchange-plugins
This will update the dependency.
Once your plugin is tested. submit a PR. You will need to also submit a PR for changes in edge-react-gui