Skip to content

Commit

Permalink
fixup! Simplify our React Native integration
Browse files Browse the repository at this point in the history
  • Loading branch information
swansontec committed Oct 19, 2023
1 parent 75332e5 commit 75d2d0b
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 20 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

## Unreleased

- changed: Simplify our React Native integration.

## 0.21.10 (2023-10-09)

- changed: Restrict ChangeHero trading to whitelisted plugins
Expand Down
72 changes: 52 additions & 20 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,32 +2,63 @@

This library exports a collection of exchange-rate & swap plugins for use with [`edge-core-js`](https://github.com/EdgeApp/edge-core-js).

Use it like this:
Please see [index.js](./src/index.js) for the list of plugins in this repo. These are compatible with edge-core-js v0.19.31 or later.

## Installing

Fist, add this library to your project:

```sh
npm i -s edge-exchange-plugins
```

### Node.js

For Node.js, you should call `addEdgeCorePlugins` to register these plugins with edge-core-js:

```js
import {
addEdgeCorePlugins,
lockEdgeCorePlugins,
makeEdgeContext
} from 'edge-core-js'
import exchangePlugins from 'edge-exchange-plugins'

addEdgeCorePlugins(exchangePlugins)
const { addEdgeCorePlugins, lockEdgeCorePlugins } = require('edge-core-js')
const plugins = require('edge-exchange-plugins')

addEdgeCorePlugins(plugins)

// Once you are done adding plugins, call this:
lockEdgeCorePlugins()
```

makeEdgeContext({
apiKey: '',
appId: '',
plugins: {
// Plugin names from edge-exchange-plugins:
coinbase: true,
shapeshift: true
}
You can also add plugins individually if you want to be more picky:

```js
addEdgeCorePlugins({
thorchain: plugins.thorchain
})
```

### Browser

The bundle located in `dist/edge-exchange-plugins.js` will automatically register itself with edge-core-js. Just serve the entire `dist` directory along with your app, and then load the script:

```html
<script src='https://example.com/app/dist/edge-exchange-plugins.js'>
```
Please see [index.js](./src/index.js) for the list of plugins in this repo.
If you want to debug this project, run `yarn start` to start the a Webpack server,
and then adjust your script URL to http://localhost:8083/edge-exchange-plugins.js.
### React Native
This package will automatically install itself using React Native autolinking. To integrate the plugins with edge-core-js, add its URI to the context component:
```jsx
import { pluginUri } from 'edge-exchange-plugins'
<MakeEdgeContext
pluginUris={[pluginUri]}
// Plus other props as required...
/>
```
To debug this project, run `yarn start` to start the a Webpack server, and then use `debugUri` instead of `pluginUri`.
## edge-react-gui
Expand All @@ -39,16 +70,17 @@ To test your exchange plugin, build the full application at [`edge-react-gui`](h
Clone this repo as a peer in the same directory as `edge-react-gui`. Then run
```
```sh
yarn
yarn prepare
```
From within the `edge-react-gui`
```
```sh
yarn updot edge-exchange-plugins
yarn prepare
yarn prepare.ios # For iPhone development
```
Make appropriate changes to `edge-react-gui` to include your plugin. Search `edge-react-gui` for the string `changelly` and make similar changes for your plugin.
Expand Down

0 comments on commit 75d2d0b

Please sign in to comment.