@instadapp/interop-x 0.0.0-dev.eb2b141 → 0.0.0-dev.f0a6281

Sign up to get free protection for your applications and to get access to all the features.
Files changed (48) hide show
  1. package/dist/package.json +4 -3
  2. package/dist/src/abi/interopBridgeToken.json +21 -9
  3. package/dist/src/abi/interopXGateway.json +11 -11
  4. package/dist/src/api/index.js +3 -3
  5. package/dist/src/config/index.js +11 -1
  6. package/dist/src/constants/addresses.js +1 -1
  7. package/dist/src/constants/itokens.js +1 -1
  8. package/dist/src/index.js +39 -6
  9. package/dist/src/net/peer/index.js +2 -1
  10. package/dist/src/net/pool/index.js +7 -2
  11. package/dist/src/net/protocol/dial/TransactionStatusDialProtocol.js +28 -0
  12. package/dist/src/net/protocol/index.js +11 -0
  13. package/dist/src/tasks/AutoUpdateTask.js +70 -0
  14. package/dist/src/tasks/BaseTask.js +11 -3
  15. package/dist/src/tasks/InteropBridge/ProcessWithdrawEvents.js +0 -1
  16. package/dist/src/tasks/InteropBridge/SyncWithdrawEvents.js +7 -6
  17. package/dist/src/tasks/InteropXGateway/ProcessDepositEvents.js +13 -2
  18. package/dist/src/tasks/InteropXGateway/SyncDepositEvents.js +2 -3
  19. package/dist/src/tasks/Transactions/SyncTransactionStatusTask.js +53 -0
  20. package/dist/src/tasks/index.js +4 -0
  21. package/dist/src/typechain/factories/InteropBridgeToken__factory.js +23 -11
  22. package/dist/src/typechain/factories/InteropXGateway__factory.js +14 -14
  23. package/dist/src/utils/index.js +20 -10
  24. package/package.json +4 -3
  25. package/src/abi/interopBridgeToken.json +21 -9
  26. package/src/abi/interopXGateway.json +11 -11
  27. package/src/api/index.ts +2 -2
  28. package/src/config/index.ts +11 -1
  29. package/src/constants/addresses.ts +1 -1
  30. package/src/constants/itokens.ts +1 -1
  31. package/src/index.ts +53 -8
  32. package/src/net/peer/index.ts +2 -1
  33. package/src/net/pool/index.ts +7 -3
  34. package/src/net/protocol/dial/TransactionStatusDialProtocol.ts +31 -0
  35. package/src/net/protocol/index.ts +12 -0
  36. package/src/tasks/AutoUpdateTask.ts +82 -0
  37. package/src/tasks/BaseTask.ts +13 -3
  38. package/src/tasks/InteropBridge/ProcessWithdrawEvents.ts +0 -2
  39. package/src/tasks/InteropBridge/SyncWithdrawEvents.ts +7 -7
  40. package/src/tasks/InteropXGateway/ProcessDepositEvents.ts +17 -6
  41. package/src/tasks/InteropXGateway/SyncDepositEvents.ts +2 -4
  42. package/src/tasks/Transactions/SyncTransactionStatusTask.ts +65 -0
  43. package/src/tasks/index.ts +5 -0
  44. package/src/typechain/InteropBridgeToken.ts +23 -17
  45. package/src/typechain/InteropXGateway.ts +13 -13
  46. package/src/typechain/factories/InteropBridgeToken__factory.ts +23 -11
  47. package/src/typechain/factories/InteropXGateway__factory.ts +14 -14
  48. package/src/utils/index.ts +21 -9
@@ -61,11 +61,17 @@ const _abi = [
61
61
  name: "amount",
62
62
  type: "uint256",
63
63
  },
64
+ {
65
+ indexed: false,
66
+ internalType: "uint32",
67
+ name: "sourceChainId",
68
+ type: "uint32",
69
+ },
64
70
  {
65
71
  indexed: true,
66
- internalType: "uint256",
67
- name: "chainId",
68
- type: "uint256",
72
+ internalType: "uint32",
73
+ name: "targetChainId",
74
+ type: "uint32",
69
75
  },
70
76
  ],
71
77
  name: "Burn",
@@ -88,14 +94,20 @@ const _abi = [
88
94
  },
89
95
  {
90
96
  indexed: true,
91
- internalType: "uint256",
92
- name: "chainId",
93
- type: "uint256",
97
+ internalType: "uint32",
98
+ name: "sourceChainId",
99
+ type: "uint32",
100
+ },
101
+ {
102
+ indexed: false,
103
+ internalType: "uint32",
104
+ name: "targetChainId",
105
+ type: "uint32",
94
106
  },
95
107
  {
96
108
  indexed: true,
97
109
  internalType: "bytes32",
98
- name: "transactionHash",
110
+ name: "submitTransactionHash",
99
111
  type: "bytes32",
100
112
  },
101
113
  ],
@@ -226,9 +238,9 @@ const _abi = [
226
238
  type: "uint256",
227
239
  },
228
240
  {
229
- internalType: "uint256",
241
+ internalType: "uint32",
230
242
  name: "chainId",
231
- type: "uint256",
243
+ type: "uint32",
232
244
  },
233
245
  ],
234
246
  name: "burn",
@@ -310,9 +322,9 @@ const _abi = [
310
322
  type: "uint256",
311
323
  },
312
324
  {
313
- internalType: "uint256",
325
+ internalType: "uint32",
314
326
  name: "chainId",
315
- type: "uint256",
327
+ type: "uint32",
316
328
  },
317
329
  {
318
330
  internalType: "bytes32",
@@ -50,15 +50,15 @@ const _abi = [
50
50
  },
51
51
  {
52
52
  indexed: false,
53
- internalType: "uint256",
53
+ internalType: "uint32",
54
54
  name: "sourceChainId",
55
- type: "uint256",
55
+ type: "uint32",
56
56
  },
57
57
  {
58
58
  indexed: true,
59
- internalType: "uint256",
59
+ internalType: "uint32",
60
60
  name: "targetChainId",
61
- type: "uint256",
61
+ type: "uint32",
62
62
  },
63
63
  ],
64
64
  name: "LogGatewayDeposit",
@@ -87,15 +87,15 @@ const _abi = [
87
87
  },
88
88
  {
89
89
  indexed: true,
90
- internalType: "uint256",
90
+ internalType: "uint32",
91
91
  name: "sourceChainId",
92
- type: "uint256",
92
+ type: "uint32",
93
93
  },
94
94
  {
95
95
  indexed: false,
96
- internalType: "uint256",
96
+ internalType: "uint32",
97
97
  name: "targetChainId",
98
- type: "uint256",
98
+ type: "uint32",
99
99
  },
100
100
  {
101
101
  indexed: true,
@@ -152,9 +152,9 @@ const _abi = [
152
152
  type: "uint256",
153
153
  },
154
154
  {
155
- internalType: "uint256",
155
+ internalType: "uint32",
156
156
  name: "chainId_",
157
- type: "uint256",
157
+ type: "uint32",
158
158
  },
159
159
  ],
160
160
  name: "deposit",
@@ -180,9 +180,9 @@ const _abi = [
180
180
  type: "uint256",
181
181
  },
182
182
  {
183
- internalType: "uint256",
183
+ internalType: "uint32",
184
184
  name: "chainId_",
185
- type: "uint256",
185
+ type: "uint32",
186
186
  },
187
187
  ],
188
188
  name: "depositFor",
@@ -228,9 +228,9 @@ const _abi = [
228
228
  type: "address",
229
229
  },
230
230
  {
231
- internalType: "uint256",
231
+ internalType: "uint32",
232
232
  name: "chainId_",
233
- type: "uint256",
233
+ type: "uint32",
234
234
  },
235
235
  {
236
236
  internalType: "bytes32",
@@ -17,6 +17,18 @@ export const http = axios.create();
17
17
  axiosRetry(http, { retries: 3, retryDelay: axiosRetry.exponentialDelay });
18
18
 
19
19
 
20
+ export function shortenHash(hash: string, length: number = 4) {
21
+ if (!hash) return;
22
+
23
+ if (hash.length < 12) return hash;
24
+
25
+ const beginningChars = hash.startsWith("0x") ? length + 2 : length;
26
+
27
+ const shortened = hash.substr(0, beginningChars) + "…" + hash.substr(-length);
28
+
29
+ return shortened;
30
+ }
31
+
20
32
  export function short(buffer: Buffer): string {
21
33
  return buffer.toString('hex').slice(0, 8) + '...'
22
34
  }
@@ -76,11 +88,11 @@ export const signGnosisSafeTx = async ({
76
88
  export const getRpcProviderUrl = (chainId: ChainId) => {
77
89
  switch (chainId) {
78
90
  case 1:
79
- return 'https://rpc.instadapp.io/mainnet';
91
+ return 'https://rpc.ankr.com/eth';
80
92
  case 137:
81
- return 'https://rpc.instadapp.io/polygon';
93
+ return 'https://rpc.ankr.com/polygon';
82
94
  case 43114:
83
- return 'https://rpc.instadapp.io/avalanche';
95
+ return 'https://rpc.ankr.com/avalanche';
84
96
  default:
85
97
  throw new Error(`Unknown chainId: ${chainId}`);
86
98
  }
@@ -210,30 +222,30 @@ export const buildWithdrawDataForTransaction = async (transaction: Transaction,
210
222
  throw Error('Cannot build data for transaction without submitEvent');
211
223
  }
212
224
 
213
- const { to, amount, chainId, itoken: itokenAddress } = transaction.submitEvent;
225
+ const { to, amount, sourceChainId, targetChainId, itoken: itokenAddress } = transaction.submitEvent;
214
226
 
215
- const itoken = itokens[transaction.sourceChainId].find(token => token.address.toLowerCase() === itokenAddress.toLowerCase());
227
+ const itoken = itokens[sourceChainId].find(token => token.address.toLowerCase() === itokenAddress.toLowerCase());
216
228
 
217
229
  if (!itoken) {
218
230
  throw Error('Cannot build data for transaction without itoken');
219
231
  }
220
232
 
221
- const token = tokens[chainId].find(t => t.symbol.toLowerCase() === itoken.symbol.toLowerCase());
233
+ const token = tokens[targetChainId].find(t => t.symbol.toLowerCase() === itoken.symbol.toLowerCase());
222
234
 
223
235
  if (!token) {
224
236
  throw Error('Cannot build data for transaction without token');
225
237
  }
226
238
 
227
- const targetChainProvider = new ethers.providers.JsonRpcProvider(getRpcProviderUrl(transaction.targetChainId as ChainId));
239
+ const targetChainProvider = new ethers.providers.JsonRpcProvider(getRpcProviderUrl(targetChainId as ChainId));
228
240
  const targetWallet = new ethers.Wallet(config.privateKey, targetChainProvider);
229
- const gatewayAddress = addresses[chainId].interopXGateway;
241
+ const gatewayAddress = addresses[targetChainId].interopXGateway;
230
242
  const interopBridgeContract = getContract<InteropXGateway>(gatewayAddress, abi.interopXGateway, targetWallet);
231
243
 
232
244
  const { data } = await interopBridgeContract.populateTransaction.systemWithdraw(
233
245
  ethers.BigNumber.from(amount.toString()),
234
246
  to,
235
247
  token.address,
236
- ethers.BigNumber.from(transaction.sourceChainId.toString()),
248
+ ethers.BigNumber.from(sourceChainId.toString()),
237
249
  transaction.submitTransactionHash,
238
250
  );
239
251