@exodus/ethereum-lib 1.2.1 → 2.0.0

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@exodus/ethereum-lib",
3
- "version": "1.2.1",
3
+ "version": "2.0.0",
4
4
  "description": "Ethereum Library",
5
5
  "main": "src/index.js",
6
6
  "author": "Exodus Movement, Inc.",
@@ -21,5 +21,5 @@
21
21
  "peerDependencies": {
22
22
  "@exodus/assets": "8.0.x"
23
23
  },
24
- "gitHead": "80487ac0f84b65961f7603bceb1bfa0ff07cc6fa"
24
+ "gitHead": "cc2ade686dff7693c028ca9d6796ada2a0eed6f1"
25
25
  }
package/src/abi/gnt.js ADDED
@@ -0,0 +1,200 @@
1
+ // https://etherscan.io/address/0xa74476443119A942dE498590Fe1f2454d7D4aC0d#code
2
+
3
+ export default [
4
+ {
5
+ constant: true,
6
+ inputs: [],
7
+ name: 'name',
8
+ outputs: [{ name: '', type: 'string' }],
9
+ payable: false,
10
+ type: 'function',
11
+ },
12
+ {
13
+ constant: true,
14
+ inputs: [],
15
+ name: 'golemFactory',
16
+ outputs: [{ name: '', type: 'address' }],
17
+ payable: false,
18
+ type: 'function',
19
+ },
20
+ {
21
+ constant: true,
22
+ inputs: [],
23
+ name: 'totalSupply',
24
+ outputs: [{ name: '', type: 'uint256' }],
25
+ payable: false,
26
+ type: 'function',
27
+ },
28
+ {
29
+ constant: false,
30
+ inputs: [{ name: '_master', type: 'address' }],
31
+ name: 'setMigrationMaster',
32
+ outputs: [],
33
+ payable: false,
34
+ type: 'function',
35
+ },
36
+ {
37
+ constant: true,
38
+ inputs: [],
39
+ name: 'decimals',
40
+ outputs: [{ name: '', type: 'uint8' }],
41
+ payable: false,
42
+ type: 'function',
43
+ },
44
+ {
45
+ constant: false,
46
+ inputs: [{ name: '_value', type: 'uint256' }],
47
+ name: 'migrate',
48
+ outputs: [],
49
+ payable: false,
50
+ type: 'function',
51
+ },
52
+ { constant: false, inputs: [], name: 'finalize', outputs: [], payable: false, type: 'function' },
53
+ { constant: false, inputs: [], name: 'refund', outputs: [], payable: false, type: 'function' },
54
+ {
55
+ constant: true,
56
+ inputs: [],
57
+ name: 'migrationMaster',
58
+ outputs: [{ name: '', type: 'address' }],
59
+ payable: false,
60
+ type: 'function',
61
+ },
62
+ {
63
+ constant: true,
64
+ inputs: [],
65
+ name: 'tokenCreationCap',
66
+ outputs: [{ name: '', type: 'uint256' }],
67
+ payable: false,
68
+ type: 'function',
69
+ },
70
+ {
71
+ constant: true,
72
+ inputs: [{ name: '_owner', type: 'address' }],
73
+ name: 'balanceOf',
74
+ outputs: [{ name: '', type: 'uint256' }],
75
+ payable: false,
76
+ type: 'function',
77
+ },
78
+ {
79
+ constant: false,
80
+ inputs: [{ name: '_agent', type: 'address' }],
81
+ name: 'setMigrationAgent',
82
+ outputs: [],
83
+ payable: false,
84
+ type: 'function',
85
+ },
86
+ {
87
+ constant: true,
88
+ inputs: [],
89
+ name: 'migrationAgent',
90
+ outputs: [{ name: '', type: 'address' }],
91
+ payable: false,
92
+ type: 'function',
93
+ },
94
+ {
95
+ constant: true,
96
+ inputs: [],
97
+ name: 'fundingEndBlock',
98
+ outputs: [{ name: '', type: 'uint256' }],
99
+ payable: false,
100
+ type: 'function',
101
+ },
102
+ {
103
+ constant: true,
104
+ inputs: [],
105
+ name: 'totalMigrated',
106
+ outputs: [{ name: '', type: 'uint256' }],
107
+ payable: false,
108
+ type: 'function',
109
+ },
110
+ {
111
+ constant: true,
112
+ inputs: [],
113
+ name: 'symbol',
114
+ outputs: [{ name: '', type: 'string' }],
115
+ payable: false,
116
+ type: 'function',
117
+ },
118
+ {
119
+ constant: false,
120
+ inputs: [
121
+ { name: '_to', type: 'address' },
122
+ { name: '_value', type: 'uint256' },
123
+ ],
124
+ name: 'transfer',
125
+ outputs: [{ name: '', type: 'bool' }],
126
+ payable: false,
127
+ type: 'function',
128
+ },
129
+ {
130
+ constant: true,
131
+ inputs: [],
132
+ name: 'tokenCreationMin',
133
+ outputs: [{ name: '', type: 'uint256' }],
134
+ payable: false,
135
+ type: 'function',
136
+ },
137
+ {
138
+ constant: true,
139
+ inputs: [],
140
+ name: 'funding',
141
+ outputs: [{ name: '', type: 'bool' }],
142
+ payable: false,
143
+ type: 'function',
144
+ },
145
+ {
146
+ constant: true,
147
+ inputs: [],
148
+ name: 'tokenCreationRate',
149
+ outputs: [{ name: '', type: 'uint256' }],
150
+ payable: false,
151
+ type: 'function',
152
+ },
153
+ {
154
+ constant: true,
155
+ inputs: [],
156
+ name: 'fundingStartBlock',
157
+ outputs: [{ name: '', type: 'uint256' }],
158
+ payable: false,
159
+ type: 'function',
160
+ },
161
+ { constant: false, inputs: [], name: 'create', outputs: [], payable: true, type: 'function' },
162
+ {
163
+ inputs: [
164
+ { name: '_golemFactory', type: 'address' },
165
+ { name: '_migrationMaster', type: 'address' },
166
+ { name: '_fundingStartBlock', type: 'uint256' },
167
+ { name: '_fundingEndBlock', type: 'uint256' },
168
+ ],
169
+ type: 'constructor',
170
+ },
171
+ {
172
+ anonymous: false,
173
+ inputs: [
174
+ { indexed: true, name: '_from', type: 'address' },
175
+ { indexed: true, name: '_to', type: 'address' },
176
+ { indexed: false, name: '_value', type: 'uint256' },
177
+ ],
178
+ name: 'Transfer',
179
+ type: 'event',
180
+ },
181
+ {
182
+ anonymous: false,
183
+ inputs: [
184
+ { indexed: true, name: '_from', type: 'address' },
185
+ { indexed: true, name: '_to', type: 'address' },
186
+ { indexed: false, name: '_value', type: 'uint256' },
187
+ ],
188
+ name: 'Migrate',
189
+ type: 'event',
190
+ },
191
+ {
192
+ anonymous: false,
193
+ inputs: [
194
+ { indexed: true, name: '_from', type: 'address' },
195
+ { indexed: false, name: '_value', type: 'uint256' },
196
+ ],
197
+ name: 'Refund',
198
+ type: 'event',
199
+ },
200
+ ]
package/src/abi/index.js CHANGED
@@ -1,6 +1,7 @@
1
1
  import ant from './ant'
2
2
  import cdai from './cdai'
3
3
  import dai from './dai'
4
+ import gnt from './gnt'
4
5
  import repv2 from './repv2'
5
6
  import scdMcdMigration from './scd-mcd-migration'
6
7
 
@@ -8,6 +9,7 @@ export default {
8
9
  ant,
9
10
  cdai,
10
11
  dai,
12
+ gnt,
11
13
  repv2,
12
14
  scdMcdMigration,
13
15
  }
@@ -11,6 +11,8 @@ export default function createContract(address, assetName) {
11
11
  return new SolidityContract(ABI.repv2, address)
12
12
  case 'aragon':
13
13
  return new SolidityContract(ABI.ant, address)
14
+ case 'golem':
15
+ return new SolidityContract(ABI.gnt, address)
14
16
  default:
15
17
  return SolidityContract.erc20(address)
16
18
  }
@@ -6,6 +6,13 @@ const BumpType = {
6
6
  RBF: 2,
7
7
  }
8
8
 
9
+ export const calculateBumpedGasPrice = (tx, currentGasPrice) => {
10
+ const usedGasPrice = tx.feeAmount.div(tx.data.gasLimit)
11
+ const bumpedGasPrice = usedGasPrice.mul(12).div(10)
12
+
13
+ return currentGasPrice.gt(bumpedGasPrice) ? currentGasPrice : bumpedGasPrice
14
+ }
15
+
9
16
  export default (
10
17
  getFeeDataSelector,
11
18
  getFeeSelector,
@@ -31,10 +38,7 @@ export default (
31
38
 
32
39
  const walletAccountBalances = getWalletAccountBalances(activeWalletAccount)
33
40
  const { gasPrice: currentGasPrice } = getFeeData(assetName)
34
- const usedGasPrice = tx.feeAmount.div(tx.data.gasLimit)
35
- // new gas price should be at least 20% higher and not less than the current gas price
36
- const bumpedGasPrice = usedGasPrice.mul(12).div(10)
37
- const gasPriceToUse = currentGasPrice.gt(bumpedGasPrice) ? currentGasPrice : bumpedGasPrice
41
+ const gasPriceToUse = calculateBumpedGasPrice(tx, currentGasPrice)
38
42
  const replacementFee = gasPriceToUse.mul(tx.data.gasLimit)
39
43
  const extraEthNeeded = replacementFee.sub(tx.feeAmount)
40
44
  if (walletAccountBalances[asset.baseAsset.name].lt(extraEthNeeded)) return BumpType.NONE
@@ -1 +1,4 @@
1
- export { default as getCanAccelerateTxFactory } from './get-can-accelerate-tx-factory'
1
+ export {
2
+ default as getCanAccelerateTxFactory,
3
+ calculateBumpedGasPrice,
4
+ } from './get-can-accelerate-tx-factory'