Add @poanet/tokenbridge-bw-exchange

This commit is contained in:
Gerardo Nardelli 2020-04-27 16:57:32 -03:00
parent 729076f815
commit c7a1d69378
9 changed files with 28 additions and 335 deletions

View File

@ -13,6 +13,7 @@
"@burner-wallet/assets": "^1.1.10",
"@burner-wallet/exchange": "^1.1.2",
"@burner-wallet/types": "^1.0.8",
"@poanet/tokenbridge-bw-exchange": "^0.0.2",
"@types/react": "*"
},
"devDependencies": {

View File

@ -1,22 +0,0 @@
import { ERC20Asset } from '@burner-wallet/assets'
import IERC677abi from './abi/IERC677.json'
export default class ERC677Asset extends ERC20Asset {
constructor({ abi = IERC677abi, ...params }) {
// @ts-ignore
super({ abi, type: 'erc677', ...params })
}
// @ts-ignore
async _send({ from, to, value }) {
// @ts-ignore
const receipt = await this.getContract()
.methods.transferAndCall(to, value, '0x')
.send({ from })
return {
...receipt,
txHash: receipt.transactionHash,
id: `${receipt.transactionHash}-${receipt.events.Transfer.logIndex}`
}
}
}

View File

@ -1,249 +0,0 @@
[
{
"constant": true,
"inputs": [],
"name": "name",
"outputs": [
{
"name": "",
"type": "string"
}
],
"payable": false,
"stateMutability": "view",
"type": "function"
},
{
"constant": false,
"inputs": [
{
"name": "_spender",
"type": "address"
},
{
"name": "_value",
"type": "uint256"
}
],
"name": "approve",
"outputs": [
{
"name": "",
"type": "bool"
}
],
"payable": false,
"stateMutability": "nonpayable",
"type": "function"
},
{
"constant": true,
"inputs": [],
"name": "totalSupply",
"outputs": [
{
"name": "",
"type": "uint256"
}
],
"payable": false,
"stateMutability": "view",
"type": "function"
},
{
"constant": false,
"inputs": [
{
"name": "_from",
"type": "address"
},
{
"name": "_to",
"type": "address"
},
{
"name": "_value",
"type": "uint256"
}
],
"name": "transferFrom",
"outputs": [
{
"name": "",
"type": "bool"
}
],
"payable": false,
"stateMutability": "nonpayable",
"type": "function"
},
{
"constant": true,
"inputs": [],
"name": "decimals",
"outputs": [
{
"name": "",
"type": "uint8"
}
],
"payable": false,
"stateMutability": "view",
"type": "function"
},
{
"constant": true,
"inputs": [
{
"name": "_owner",
"type": "address"
}
],
"name": "balanceOf",
"outputs": [
{
"name": "balance",
"type": "uint256"
}
],
"payable": false,
"stateMutability": "view",
"type": "function"
},
{
"constant": true,
"inputs": [],
"name": "symbol",
"outputs": [
{
"name": "",
"type": "string"
}
],
"payable": false,
"stateMutability": "view",
"type": "function"
},
{
"constant": false,
"inputs": [
{
"name": "_to",
"type": "address"
},
{
"name": "_value",
"type": "uint256"
}
],
"name": "transfer",
"outputs": [
{
"name": "",
"type": "bool"
}
],
"payable": false,
"stateMutability": "nonpayable",
"type": "function"
},
{
"constant": true,
"inputs": [
{
"name": "_owner",
"type": "address"
},
{
"name": "_spender",
"type": "address"
}
],
"name": "allowance",
"outputs": [
{
"name": "",
"type": "uint256"
}
],
"payable": false,
"stateMutability": "view",
"type": "function"
},
{
"payable": true,
"stateMutability": "payable",
"type": "fallback"
},
{
"anonymous": false,
"inputs": [
{
"indexed": true,
"name": "owner",
"type": "address"
},
{
"indexed": true,
"name": "spender",
"type": "address"
},
{
"indexed": false,
"name": "value",
"type": "uint256"
}
],
"name": "Approval",
"type": "event"
},
{
"anonymous": false,
"inputs": [
{
"indexed": true,
"name": "from",
"type": "address"
},
{
"indexed": true,
"name": "to",
"type": "address"
},
{
"indexed": false,
"name": "value",
"type": "uint256"
}
],
"name": "Transfer",
"type": "event"
},
{
"constant": false,
"inputs": [
{
"name": "",
"type": "address"
},
{
"name": "",
"type": "uint256"
},
{
"name": "",
"type": "bytes"
}
],
"name": "transferAndCall",
"outputs": [
{
"name": "",
"type": "bool"
}
],
"payable": false,
"stateMutability": "nonpayable",
"type": "function"
}
]

View File

@ -1,6 +1,6 @@
import { default as ERC677Asset } from './ERC677Asset'
import { ERC20Asset } from '@burner-wallet/assets'
export default new ERC677Asset({
export default new ERC20Asset({
id: 'susd',
name: 'sUSD',
network: '1',

View File

@ -1,4 +1,4 @@
import { default as ERC677Asset } from './ERC677Asset'
import { ERC677Asset } from '@poanet/tokenbridge-bw-exchange'
export default new ERC677Asset({
id: 'xsusd',

View File

@ -1,57 +0,0 @@
import { Pair } from '@burner-wallet/exchange'
export interface ValueTypes {
value?: string
ether?: string
}
export interface ExchangeParams extends ValueTypes {
account: string
}
interface PairConstructor {
assetA: string
assetABridge: string
assetB: string
assetBBridge: string
}
export default class Bridge extends Pair {
private readonly assetABridge: string
private readonly assetBBridge: string
constructor({ assetA, assetABridge, assetB, assetBBridge }: PairConstructor) {
super({ assetA, assetB })
this.assetABridge = assetABridge
this.assetBBridge = assetBBridge
}
exchangeAtoB({ account, value, ether }: ExchangeParams) {
const _value = this._getValue({ value, ether })
const etc = this.getExchange().getAsset(this.assetA)
return etc.send({
from: account,
value: _value,
to: this.assetABridge
})
}
exchangeBtoA({ account, value, ether }: ExchangeParams) {
const _value = this._getValue({ value, ether })
const wetc = this.getExchange().getAsset(this.assetB)
return wetc.send({
from: account,
value: _value,
to: this.assetBBridge
})
}
async estimateAtoB(value: ValueTypes) {
return this._getValue(value)
}
async estimateBtoA(value: ValueTypes) {
return this._getValue(value)
}
}

View File

@ -1,7 +1,7 @@
import Bridge from './Bridge'
import { Mediator } from '@poanet/tokenbridge-bw-exchange'
import { sUSD, xsUSD } from '../index'
export default class SUSDBridge extends Bridge {
export default class SUSDBridge extends Mediator {
constructor() {
super({
assetA: xsUSD.id,

View File

@ -5,7 +5,7 @@
"dependencies": {
"@burner-wallet/assets": "^1.1.10",
"@burner-wallet/core": "^1.1.9",
"@burner-wallet/exchange": "^1.1.2",
"@burner-wallet/exchange": "^1.1.3",
"@burner-wallet/metamask-plugin": "^1.0.1",
"@burner-wallet/modern-ui": "^1.0.7",
"@types/node": "12.0.4",

View File

@ -1225,6 +1225,16 @@
"@types/styled-components" "4.1.8"
styled-components "^5.0.1"
"@burner-wallet/exchange@^1.1.3":
version "1.1.3"
resolved "https://registry.yarnpkg.com/@burner-wallet/exchange/-/exchange-1.1.3.tgz#18a3d6ad74e6b755318a390aa7936416aa614f05"
integrity sha512-8eWVhT5/Om0JmilsaaIRo4jDbsiTxMH+wwLOjJfZ868i0qIQmdwyvdKqk7PBNz+vwjt+tkpE5XTqRafGcZtyAg==
dependencies:
"@burner-wallet/types" "^1.0.0"
"@types/react" "*"
"@types/styled-components" "4.1.8"
styled-components "^5.0.1"
"@burner-wallet/metamask-plugin@^1.0.1":
version "1.0.1"
resolved "https://registry.yarnpkg.com/@burner-wallet/metamask-plugin/-/metamask-plugin-1.0.1.tgz#52f86b30b663641070110393b0cdfce739cedd1c"
@ -1279,7 +1289,7 @@
i18next "^19.0.2"
web3 "^1.2.2"
"@burner-wallet/types@^1.0.8":
"@burner-wallet/types@^1.0.6", "@burner-wallet/types@^1.0.8":
version "1.0.8"
resolved "https://registry.yarnpkg.com/@burner-wallet/types/-/types-1.0.8.tgz#cd37196cd5fa93ffd0d3714a3a3a4ef133221659"
integrity sha512-UwGLVIxdQCZz+Vy8XUKfsQfWmn/Z6cA9E08B+oF+v3U9Lqcgw005agbxGTUmw6X9kXgtDQRWde5R3fo2Ze4CsQ==
@ -2358,6 +2368,16 @@
dependencies:
"@types/node" "^12.11.1"
"@poanet/tokenbridge-bw-exchange@^0.0.2":
version "0.0.2"
resolved "https://registry.yarnpkg.com/@poanet/tokenbridge-bw-exchange/-/tokenbridge-bw-exchange-0.0.2.tgz#afe127138e500bb0590ab1cf38e2711c45424046"
integrity sha512-WzWgbjGU5Ya9MbPboMApR6TKRGPlFazer5r7pmKy2K9YW9H/njXTz1Kqc4pnHUNvnSgUFhXLkHjz9h4erYeSZw==
dependencies:
"@burner-wallet/assets" "^1.1.10"
"@burner-wallet/exchange" "^1.1.3"
"@burner-wallet/types" "^1.0.6"
"@types/react" "*"
"@sindresorhus/is@^0.14.0":
version "0.14.0"
resolved "https://registry.yarnpkg.com/@sindresorhus/is/-/is-0.14.0.tgz#9fb3a3cf3132328151f353de4632e01e52102bea"