Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

721 bridging #367

Closed
wants to merge 7 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ Note, you can observe the logs of the relays by running:
pm2 logs
```

### Transferring tokens
### Transferring ERC20 tokens

Finally, let's transfer some tokens

Expand All @@ -274,6 +274,12 @@ rainbow transfer-eth-erc20-from-near --amount 1 --near-sender-account rainbow_br

You should observe the change of the ERC20 balance as reported by the CLI.

### Transferring ERC721 tokens

```
rainbow transfer-example-nft-to-near --amount 1000 --eth-sender-sk 0x2bdd21761a483f71054e14f5b827213567971c676928d9a1808cbfa4b7501200 --near-receiver-account rainbow_bridge_eth_on_near_prover --near-master-account nearnonfuntoken
```

## Contract Development Workflow

Above steps are ways to run a local bridge and development workflows you need if make any changes to rainbow-bridge-cli. If you want to update any of solidity or rust contracts, they're not in this repo now and workflow is as following.
Expand Down
7 changes: 6 additions & 1 deletion config.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,10 @@
"ethLockerAbiPath": "~/.rainbow/bridge/node_modules/rainbow-token-connector/res/BridgeTokenFactory.full.abi",
"ethLockerBinPath": "~/.rainbow/bridge/node_modules/rainbow-token-connector/res/BridgeTokenFactory.full.bin",
"ethErc20AbiPath": "~/.rainbow/bridge/node_modules/rainbow-token-connector/res/TToken.full.abi",
"ethErc20BinPath": "~/.rainbow/bridge/node_modules/rainbow-token-connector/res/TToken.full.bin"
"ethErc20BinPath": "~/.rainbow/bridge/node_modules/rainbow-token-connector/res/TToken.full.bin",
"nearNonFunTokenContractPath": "./node_modules/rainbow-bridge-rs/res/mintable_non_fungible_token.wasm",
"ethErc721LockerAbiPath": "./node_modules/rainbow-bridge-sol/token-locker/dist/ERC721TokenLocker.full.abi",
"ethErc721LockerBinPath": "./node_modules/rainbow-bridge-sol/token-locker/dist/ERC721TokenLocker.full.bin",
"ethErc721AbiPath": "./node_modules/rainbow-bridge-sol/token-locker/dist/MockERC721.full.abi",
"ethErc721BinPath": "./node_modules/rainbow-bridge-sol/token-locker/dist/MockERC721.full.bin"
}
139 changes: 137 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ const {
TransferEthERC20FromNear,
DeployToken,
} = require('rainbow-bridge-lib/transfer-eth-erc20')
const {TransferExampleERC721ToNear} = require('rainbow-bridge-lib/transfer-erc721/to-near');
const { ETHDump } = require('./commands/eth-dump')
const { NearDump } = require('rainbow-bridge-lib/rainbow/near-dump')
const { RainbowConfig } = require('rainbow-bridge-lib/config')
Expand All @@ -34,6 +35,9 @@ const {
InitEthEd25519,
InitEthErc20,
InitEthLocker,
InitEthErc721,
InitEthERC721Locker,
InitNearNonFunToken,
InitEthClient,
InitEthProver,
} = require('rainbow-bridge-lib/init')
Expand All @@ -53,6 +57,29 @@ const LIBS_TC_SRC_DIR = path.join(
'node_modules/rainbow-token-connector'
)

RainbowConfig.declareOption(
'near-non-fun-token-contract-path',
'The path to the Wasm file containing the non fungible contract. Note, this version of fungible contract should support minting.',
path.join(LIBS_RS_SRC_DIR, 'res/mintable_non_fungible_token.wasm')
)
RainbowConfig.declareOption(
'eth-erc721Locker-address',
'Address of the locker contract on the Ethereum'
)
RainbowConfig.declareOption(
'near-non-fun-token-sk',
'The secret key of the non fungible token account. If not specified will use master SK.'
)
RainbowConfig.declareOption(
'near-non-fun-token-init-balance',
'The initial balance of fungible token contract in femtoNEAR.',
'100000000000000000000000000'
)
RainbowConfig.declareOption(
'near-non-fun-token-account',
'The account of the non-fungible token contract that will be used to mint tokens locked on Ethereum.',
'nearnonfuntoken'
)
RainbowConfig.declareOption(
'near-network-id',
'The identifier of the NEAR network that the given NEAR node is expected to represent.'
Expand Down Expand Up @@ -176,10 +203,24 @@ RainbowConfig.declareOption(
'Path to the .bin file defining Ethereum locker contract. This contract works in pair with mintable fungible token on NEAR blockchain.',
path.join(LIBS_TC_SRC_DIR, 'res/BridgeTokenFactory.full.bin')
)
RainbowConfig.declareOption(
'eth-erc721Locker-abi-path',
'Path to the .abi file defining Ethereum 721 locker contract. This contract works in pair with mintable non fungible token on NEAR blockchain.',
path.join(LIBS_SOL_SRC_DIR, 'token-locker/dist/ERC721TokenLocker.full.abi')
)
RainbowConfig.declareOption(
'eth-erc721Locker-bin-path',
'Path to the .bin file defining Ethereum 721 locker contract. This contract works in pair with mintable non fungible token on NEAR blockchain.',
path.join(LIBS_SOL_SRC_DIR, 'token-locker/dist/ERC721TokenLocker.full.bin')
)
RainbowConfig.declareOption(
'eth-erc20-address',
'ETH address of the ERC20 contract.'
)
RainbowConfig.declareOption(
'eth-erc721-address',
'ETH address of the ERC721 contract.'
)
RainbowConfig.declareOption(
'eth-erc20-abi-path',
'Path to the .abi file defining Ethereum ERC20 contract.',
Expand All @@ -204,6 +245,16 @@ RainbowConfig.declareOption(
'Path to the .bin file defining Ethereum ED25519 contract.',
path.join(LIBS_SOL_SRC_DIR, 'nearbridge/dist/Ed25519.full.bin')
)
RainbowConfig.declareOption(
'eth-erc721-abi-path',
'Path to the .abi file defining Mock Ethereum ERC721 contract.',
path.join(LIBS_SOL_SRC_DIR, 'token-locker/dist/MockERC721.full.abi')
)
RainbowConfig.declareOption(
'eth-erc721-bin-path',
'Path to the .bin file defining Mock Ethereum ERC721 contract.',
path.join(LIBS_SOL_SRC_DIR, 'token-locker/dist/MockERC721.full.bin')
)
RainbowConfig.declareOption(
'eth-client-lock-eth-amount',
'Amount of Ether that should be temporarily locked when submitting a new header to EthClient, in wei.',
Expand Down Expand Up @@ -272,6 +323,22 @@ RainbowConfig.addOptions(
['daemon']
)

RainbowConfig.addOptions(
program
.command('init-near-non-fun-token')
.description(
'Deploys and initializes mintable non fungible token to NEAR blockchain. Requires 721 locker on Ethereum side.'
)
.action(InitNearNonFunToken.execute),
[
'near-non-fun-token-account',
'near-non-fun-token-sk',
'near-non-fun-token-contract-path',
'near-non-fun-token-init-balance',
'eth-erc721Locker-address',
]
)

RainbowConfig.addOptions(
startCommand
.command('eth2near-relay')
Expand Down Expand Up @@ -432,8 +499,8 @@ RainbowConfig.addOptions(
[
'eth-node-url',
'eth-master-sk',
'eth-locker-abi-path',
'eth-locker-bin-path',
'eth-erc721Locker-abi-path',
'eth-erc721Locker-bin-path',
'eth-erc20-address',
'near-token-factory-account',
'eth-prover-address',
Expand All @@ -457,6 +524,41 @@ RainbowConfig.addOptions(
]
)

RainbowConfig.addOptions(
program
.command('init-eth-721-locker')
.description(
'Deploys and initializes locker contract on Ethereum blockchain for 721 tokens. Requires mintable non-fungible token on Near side.'
)
.action(InitEthERC721Locker.execute),
[
'eth-node-url',
'eth-master-sk',
'eth-erc721Locker-abi-path',
'eth-erc721Locker-bin-path',
'eth-erc721-address',
'near-non-fun-token-account',
'eth-prover-address',
'eth-gas-multiplier',
]
)

RainbowConfig.addOptions(
program
.command('init-eth-erc721')
.description(
'Deploys and initializes an example ERC721 contract on the Ethereum blockchain.'
)
.action(InitEthErc721.execute),
[
'eth-node-url',
'eth-master-sk',
'eth-erc721-abi-path',
'eth-erc721-bin-path',
'eth-gas-multiplier',
]
)

RainbowConfig.addOptions(
program
.command('transfer-eth-erc20-to-near')
Expand Down Expand Up @@ -490,6 +592,39 @@ RainbowConfig.addOptions(
]
)

RainbowConfig.addOptions(
program
.command('transfer-example-nft-to-near')
.action(TransferExampleERC721ToNear.execute)
.option('--amount <amount>', 'Token ID to transfer')
.option(
'--eth-sender-sk <eth_sender_sk>',
'The secret key of the Ethereum account that will be sending ERC721 token.'
)
.option(
'--near-receiver-account <near_receiver_account>',
'The account on NEAR blockchain that will be receiving the minted token.'
)
.option(
'--token-name <token_name>',
'Specific ERC721 token that is already bound by `deploy-token`.'
),
[
'eth-node-url',
'eth-erc721-address',
'eth-erc721-abi-path',
'eth-erc721Locker-address',
'eth-erc721Locker-abi-path',
'near-node-url',
'near-network-id',
'near-non-fun-token-account',
'near-client-account',
'near-master-account',
'near-master-sk',
'eth-gas-multiplier',
]
)

RainbowConfig.addOptions(
program
.command('transfer-eth-erc20-from-near')
Expand Down
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@
"node-fetch": "^2.6.0",
"pm2": "^4.4.0",
"pm2-promise": "^2.0.1",
"rainbow-bridge-lib": "1.0.6",
"rainbow-bridge-rs": "1.0.2",
"rainbow-bridge-sol": "1.1.1",
"rainbow-bridge-lib": "file:../rainbow-bridge-lib",
"rainbow-bridge-rs": "file:../rainbow-bridge-rs",
"rainbow-bridge-sol": "file:../rainbow-bridge-sol",
"request": "^2.88.2",
"web3": "=1.2.6",
"rainbow-token-connector": "near/rainbow-token-connector#87ba0a1a8268f26ff58b67a6139ddb74f8eecce6"
Expand Down
Loading