@instadapp/interop-x 0.0.0-dev.fd7fd6f → 0.0.0-dev.fded533
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/package.json +4 -3
- package/dist/src/abi/interopBridgeToken.json +21 -9
- package/dist/src/abi/interopXGateway.json +11 -11
- package/dist/src/api/index.js +3 -3
- package/dist/src/config/index.js +10 -1
- package/dist/src/constants/addresses.js +1 -1
- package/dist/src/constants/itokens.js +1 -1
- package/dist/src/index.js +33 -6
- package/dist/src/net/peer/index.js +2 -1
- package/dist/src/net/pool/index.js +7 -2
- package/dist/src/net/protocol/dial/TransactionStatusDialProtocol.js +28 -0
- package/dist/src/net/protocol/index.js +15 -4
- package/dist/src/tasks/AutoUpdateTask.js +42 -16
- package/dist/src/tasks/BaseTask.js +11 -3
- package/dist/src/tasks/InteropBridge/ProcessWithdrawEvents.js +0 -1
- package/dist/src/tasks/InteropBridge/{SyncWithdrawEvents.js → SyncBurnEvents.js} +10 -9
- package/dist/src/tasks/InteropBridge/SyncMintEvents.js +67 -0
- package/dist/src/tasks/InteropXGateway/ProcessDepositEvents.js +14 -2
- package/dist/src/tasks/InteropXGateway/SyncDepositEvents.js +2 -3
- package/dist/src/tasks/InteropXGateway/SyncWithdrawtEvents.js +72 -0
- package/dist/src/tasks/Transactions/SyncTransactionStatusTask.js +53 -0
- package/dist/src/tasks/index.js +17 -4
- package/dist/src/typechain/factories/InteropBridgeToken__factory.js +23 -11
- package/dist/src/typechain/factories/InteropXGateway__factory.js +14 -14
- package/dist/src/utils/index.js +20 -10
- package/package.json +4 -3
- package/src/abi/interopBridgeToken.json +21 -9
- package/src/abi/interopXGateway.json +11 -11
- package/src/api/index.ts +2 -2
- package/src/config/index.ts +9 -1
- package/src/constants/addresses.ts +1 -1
- package/src/constants/itokens.ts +1 -1
- package/src/index.ts +46 -8
- package/src/net/peer/index.ts +2 -1
- package/src/net/pool/index.ts +7 -3
- package/src/net/protocol/dial/TransactionStatusDialProtocol.ts +31 -0
- package/src/net/protocol/index.ts +16 -4
- package/src/tasks/AutoUpdateTask.ts +48 -19
- package/src/tasks/BaseTask.ts +13 -3
- package/src/tasks/InteropBridge/ProcessWithdrawEvents.ts +0 -2
- package/src/tasks/InteropBridge/{SyncWithdrawEvents.ts → SyncBurnEvents.ts} +10 -10
- package/src/tasks/InteropBridge/SyncMintEvents.ts +99 -0
- package/src/tasks/InteropXGateway/ProcessDepositEvents.ts +18 -6
- package/src/tasks/InteropXGateway/SyncDepositEvents.ts +2 -4
- package/src/tasks/InteropXGateway/SyncWithdrawtEvents.ts +105 -0
- package/src/tasks/Transactions/SyncTransactionStatusTask.ts +65 -0
- package/src/tasks/index.ts +25 -4
- package/src/typechain/InteropBridgeToken.ts +23 -17
- package/src/typechain/InteropXGateway.ts +13 -13
- package/src/typechain/factories/InteropBridgeToken__factory.ts +23 -11
- package/src/typechain/factories/InteropXGateway__factory.ts +14 -14
- package/src/utils/index.ts +21 -9
package/src/utils/index.ts
CHANGED
@@ -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.
|
91
|
+
return 'https://rpc.ankr.com/eth';
|
80
92
|
case 137:
|
81
|
-
return 'https://rpc.
|
93
|
+
return 'https://rpc.ankr.com/polygon';
|
82
94
|
case 43114:
|
83
|
-
return 'https://rpc.
|
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,
|
225
|
+
const { to, amount, sourceChainId, targetChainId, itoken: itokenAddress } = transaction.submitEvent;
|
214
226
|
|
215
|
-
const itoken = itokens[
|
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[
|
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(
|
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[
|
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(
|
248
|
+
ethers.BigNumber.from(sourceChainId.toString()),
|
237
249
|
transaction.submitTransactionHash,
|
238
250
|
);
|
239
251
|
|