@exodus/ethereum-lib 2.3.0 → 2.3.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +2 -2
- package/src/abi/index.js +2 -0
- package/src/abi/loomv2-swap.js +176 -0
- package/src/constants.js +2 -1
- package/src/create-contract/index.js +2 -0
- package/src/fee-data/index.js +1 -0
- package/src/fee-data/quorum.js +11 -0
- package/src/unsigned-tx/create-unsigned-tx.js +2 -2
- package/src/unsigned-tx/parse-unsigned-tx.js +2 -2
- package/src/utils.js +2 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@exodus/ethereum-lib",
|
|
3
|
-
"version": "2.3.
|
|
3
|
+
"version": "2.3.2",
|
|
4
4
|
"description": "Ethereum Library",
|
|
5
5
|
"main": "src/index.js",
|
|
6
6
|
"author": "Exodus Movement, Inc.",
|
|
@@ -25,5 +25,5 @@
|
|
|
25
25
|
"devDependencies": {
|
|
26
26
|
"@exodus/models": "^8.5.1"
|
|
27
27
|
},
|
|
28
|
-
"gitHead": "
|
|
28
|
+
"gitHead": "52593609ee44ae7f3113482ee84c68646e7bf6ed"
|
|
29
29
|
}
|
package/src/abi/index.js
CHANGED
|
@@ -2,6 +2,7 @@ import ant from './ant'
|
|
|
2
2
|
import cdai from './cdai'
|
|
3
3
|
import dai from './dai'
|
|
4
4
|
import gnt from './gnt'
|
|
5
|
+
import loomv2Swap from './loomv2-swap'
|
|
5
6
|
import repv2 from './repv2'
|
|
6
7
|
import scdMcdMigration from './scd-mcd-migration'
|
|
7
8
|
|
|
@@ -10,6 +11,7 @@ export default {
|
|
|
10
11
|
cdai,
|
|
11
12
|
dai,
|
|
12
13
|
gnt,
|
|
14
|
+
loomv2Swap,
|
|
13
15
|
repv2,
|
|
14
16
|
scdMcdMigration,
|
|
15
17
|
}
|
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
// https://github.com/loomnetwork/loom-token/blob/main/contracts/TokenSwap.sol
|
|
2
|
+
|
|
3
|
+
export default [
|
|
4
|
+
{
|
|
5
|
+
inputs: [
|
|
6
|
+
{
|
|
7
|
+
internalType: 'address',
|
|
8
|
+
name: '_oldToken',
|
|
9
|
+
type: 'address',
|
|
10
|
+
},
|
|
11
|
+
],
|
|
12
|
+
stateMutability: 'nonpayable',
|
|
13
|
+
type: 'constructor',
|
|
14
|
+
},
|
|
15
|
+
{
|
|
16
|
+
anonymous: false,
|
|
17
|
+
inputs: [
|
|
18
|
+
{
|
|
19
|
+
indexed: true,
|
|
20
|
+
internalType: 'address',
|
|
21
|
+
name: 'previousOwner',
|
|
22
|
+
type: 'address',
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
indexed: true,
|
|
26
|
+
internalType: 'address',
|
|
27
|
+
name: 'newOwner',
|
|
28
|
+
type: 'address',
|
|
29
|
+
},
|
|
30
|
+
],
|
|
31
|
+
name: 'OwnershipTransferred',
|
|
32
|
+
type: 'event',
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
inputs: [],
|
|
36
|
+
name: 'newToken',
|
|
37
|
+
outputs: [
|
|
38
|
+
{
|
|
39
|
+
internalType: 'contract IERC20',
|
|
40
|
+
name: '',
|
|
41
|
+
type: 'address',
|
|
42
|
+
},
|
|
43
|
+
],
|
|
44
|
+
stateMutability: 'view',
|
|
45
|
+
type: 'function',
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
inputs: [],
|
|
49
|
+
name: 'oldToken',
|
|
50
|
+
outputs: [
|
|
51
|
+
{
|
|
52
|
+
internalType: 'contract IERC20',
|
|
53
|
+
name: '',
|
|
54
|
+
type: 'address',
|
|
55
|
+
},
|
|
56
|
+
],
|
|
57
|
+
stateMutability: 'view',
|
|
58
|
+
type: 'function',
|
|
59
|
+
},
|
|
60
|
+
{
|
|
61
|
+
inputs: [],
|
|
62
|
+
name: 'owner',
|
|
63
|
+
outputs: [
|
|
64
|
+
{
|
|
65
|
+
internalType: 'address',
|
|
66
|
+
name: '',
|
|
67
|
+
type: 'address',
|
|
68
|
+
},
|
|
69
|
+
],
|
|
70
|
+
stateMutability: 'view',
|
|
71
|
+
type: 'function',
|
|
72
|
+
},
|
|
73
|
+
{
|
|
74
|
+
inputs: [],
|
|
75
|
+
name: 'pause',
|
|
76
|
+
outputs: [],
|
|
77
|
+
stateMutability: 'nonpayable',
|
|
78
|
+
type: 'function',
|
|
79
|
+
},
|
|
80
|
+
{
|
|
81
|
+
inputs: [],
|
|
82
|
+
name: 'paused',
|
|
83
|
+
outputs: [
|
|
84
|
+
{
|
|
85
|
+
internalType: 'bool',
|
|
86
|
+
name: '',
|
|
87
|
+
type: 'bool',
|
|
88
|
+
},
|
|
89
|
+
],
|
|
90
|
+
stateMutability: 'view',
|
|
91
|
+
type: 'function',
|
|
92
|
+
},
|
|
93
|
+
{
|
|
94
|
+
inputs: [],
|
|
95
|
+
name: 'renounceOwnership',
|
|
96
|
+
outputs: [],
|
|
97
|
+
stateMutability: 'nonpayable',
|
|
98
|
+
type: 'function',
|
|
99
|
+
},
|
|
100
|
+
{
|
|
101
|
+
inputs: [
|
|
102
|
+
{
|
|
103
|
+
internalType: 'address',
|
|
104
|
+
name: '_newToken',
|
|
105
|
+
type: 'address',
|
|
106
|
+
},
|
|
107
|
+
],
|
|
108
|
+
name: 'setNewLoomToken',
|
|
109
|
+
outputs: [],
|
|
110
|
+
stateMutability: 'nonpayable',
|
|
111
|
+
type: 'function',
|
|
112
|
+
},
|
|
113
|
+
{
|
|
114
|
+
inputs: [],
|
|
115
|
+
name: 'swap',
|
|
116
|
+
outputs: [],
|
|
117
|
+
stateMutability: 'nonpayable',
|
|
118
|
+
type: 'function',
|
|
119
|
+
},
|
|
120
|
+
{
|
|
121
|
+
inputs: [
|
|
122
|
+
{
|
|
123
|
+
internalType: 'address',
|
|
124
|
+
name: '_recipient',
|
|
125
|
+
type: 'address',
|
|
126
|
+
},
|
|
127
|
+
{
|
|
128
|
+
internalType: 'uint256',
|
|
129
|
+
name: '_amount',
|
|
130
|
+
type: 'uint256',
|
|
131
|
+
},
|
|
132
|
+
],
|
|
133
|
+
name: 'swapFor',
|
|
134
|
+
outputs: [],
|
|
135
|
+
stateMutability: 'nonpayable',
|
|
136
|
+
type: 'function',
|
|
137
|
+
},
|
|
138
|
+
{
|
|
139
|
+
inputs: [
|
|
140
|
+
{
|
|
141
|
+
internalType: 'address',
|
|
142
|
+
name: 'newOwner',
|
|
143
|
+
type: 'address',
|
|
144
|
+
},
|
|
145
|
+
],
|
|
146
|
+
name: 'transferOwnership',
|
|
147
|
+
outputs: [],
|
|
148
|
+
stateMutability: 'nonpayable',
|
|
149
|
+
type: 'function',
|
|
150
|
+
},
|
|
151
|
+
{
|
|
152
|
+
inputs: [],
|
|
153
|
+
name: 'unpause',
|
|
154
|
+
outputs: [],
|
|
155
|
+
stateMutability: 'nonpayable',
|
|
156
|
+
type: 'function',
|
|
157
|
+
},
|
|
158
|
+
{
|
|
159
|
+
inputs: [
|
|
160
|
+
{
|
|
161
|
+
internalType: 'address',
|
|
162
|
+
name: '_recipient',
|
|
163
|
+
type: 'address',
|
|
164
|
+
},
|
|
165
|
+
{
|
|
166
|
+
internalType: 'uint256',
|
|
167
|
+
name: '_amount',
|
|
168
|
+
type: 'uint256',
|
|
169
|
+
},
|
|
170
|
+
],
|
|
171
|
+
name: 'withdrawTo',
|
|
172
|
+
outputs: [],
|
|
173
|
+
stateMutability: 'nonpayable',
|
|
174
|
+
type: 'function',
|
|
175
|
+
},
|
|
176
|
+
]
|
package/src/constants.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
export const CHAIN_IDS = { ethereum: 1, ethereumclassic: 61 }
|
|
1
|
+
export const CHAIN_IDS = { ethereum: 1, ethereumclassic: 61, quorum: 10 }
|
|
2
2
|
export const MIN_GASPRICE = 1e9 // 1 gwei
|
|
3
3
|
export const DEFAULT_FEE_MONITOR_INTERVAL = '1m'
|
|
4
4
|
export const CONFIRMATIONS_NUMBER = {
|
|
5
5
|
ethereum: 30,
|
|
6
6
|
ethereumclassic: 5000,
|
|
7
|
+
quorum: 4,
|
|
7
8
|
}
|
|
@@ -13,6 +13,8 @@ export default function createContract(address, assetName) {
|
|
|
13
13
|
return new SolidityContract(ABI.ant, address)
|
|
14
14
|
case 'golem':
|
|
15
15
|
return new SolidityContract(ABI.gnt, address)
|
|
16
|
+
case 'loomv2Swap':
|
|
17
|
+
return new SolidityContract(ABI.loomv2Swap, address)
|
|
16
18
|
default:
|
|
17
19
|
return SolidityContract.erc20(address)
|
|
18
20
|
}
|
package/src/fee-data/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import ethUtil from 'ethereumjs-util'
|
|
2
|
-
import { isEthereumToken, currency2buffer, getBaseAsset } from '../utils'
|
|
2
|
+
import { isEthereumToken, isQuorumToken, currency2buffer, getBaseAsset } from '../utils'
|
|
3
3
|
import { CHAIN_IDS } from '../constants'
|
|
4
4
|
|
|
5
5
|
import type { UnsignedTransaction } from '#/app-models'
|
|
@@ -25,7 +25,7 @@ export default function createUnsignedTx({
|
|
|
25
25
|
const baseAsset = getBaseAsset(asset)
|
|
26
26
|
if (!chainId) chainId = CHAIN_IDS[baseAsset.name] // mainnet
|
|
27
27
|
|
|
28
|
-
const isToken = isEthereumToken(asset)
|
|
28
|
+
const isToken = isEthereumToken(asset) || isQuorumToken(asset)
|
|
29
29
|
const to = isToken ? asset.contract.address : address
|
|
30
30
|
let value = currency2buffer(isToken ? baseAsset.currency.ZERO : amount)
|
|
31
31
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/* @flow */
|
|
2
2
|
import * as ethUtil from 'ethereumjs-util'
|
|
3
|
-
import { isEthereumToken, buffer2currency, getBaseAsset } from '../utils'
|
|
3
|
+
import { isEthereumToken, isQuorumToken, buffer2currency, getBaseAsset } from '../utils'
|
|
4
4
|
import { CHAIN_IDS } from '../constants'
|
|
5
5
|
|
|
6
6
|
import type { UnsignedTransaction, ParsedTransaction } from '@exodus/models/lib/types'
|
|
@@ -10,7 +10,7 @@ export default function parseUnsignedTx(
|
|
|
10
10
|
unsignedTx: UnsignedTransaction
|
|
11
11
|
): ParsedTransaction {
|
|
12
12
|
const { txData } = unsignedTx
|
|
13
|
-
const isToken = isEthereumToken(asset)
|
|
13
|
+
const isToken = isEthereumToken(asset) || isQuorumToken(asset)
|
|
14
14
|
const baseAsset = getBaseAsset(asset)
|
|
15
15
|
const gasPrice = buffer2currency({ asset: baseAsset, value: txData.gasPrice })
|
|
16
16
|
const gasLimit = ethUtil.bufferToInt(txData.gasLimit)
|
package/src/utils.js
CHANGED
|
@@ -6,6 +6,7 @@ const base10 = baseX('0123456789')
|
|
|
6
6
|
const base16 = baseX('0123456789abcdef')
|
|
7
7
|
|
|
8
8
|
export const isEthereumToken = (asset) => asset.assetType === 'ETHEREUM_ERC20'
|
|
9
|
+
export const isQuorumToken = (asset) => asset.assetType === 'QUORUM_ERC20'
|
|
9
10
|
|
|
10
11
|
export function buffer2currency({ asset, value }) {
|
|
11
12
|
return asset.currency.baseUnit(base10.encode(value)).toDefault()
|
|
@@ -34,5 +35,5 @@ export function normalizeTxId(txId: string): string {
|
|
|
34
35
|
}
|
|
35
36
|
|
|
36
37
|
export function getBaseAsset(asset) {
|
|
37
|
-
return isEthereumToken(asset) ? assets.ethereum : asset
|
|
38
|
+
return isEthereumToken(asset) ? assets.ethereum : isQuorumToken(asset) ? assets.quorum : asset
|
|
38
39
|
}
|