@instadapp/interop-x 0.0.0-dev.dc4f10a → 0.0.0-dev.e69b5e8
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/package.json +5 -5
- package/dist/src/api/index.js +3 -3
- package/dist/src/config/index.js +1 -0
- package/dist/src/index.js +44 -5
- package/dist/src/net/peer/index.js +2 -1
- package/dist/src/net/pool/index.js +18 -2
- package/dist/src/net/protocol/dial/SignatureDialProtocol.1.js +28 -0
- package/dist/src/net/protocol/index.js +41 -1
- package/dist/src/tasks/AutoUpdateTask.js +67 -0
- package/dist/src/tasks/BaseTask.js +7 -3
- package/dist/src/tasks/InteropBridge/ProcessWithdrawEvents.js +2 -3
- package/dist/src/tasks/InteropBridge/SyncWithdrawEvents.js +0 -1
- package/dist/src/tasks/InteropXGateway/ProcessDepositEvents.js +3 -1
- package/dist/src/tasks/InteropXGateway/SyncDepositEvents.js +0 -1
- package/dist/src/tasks/Transactions/SyncTransactionStatusTask.js +53 -0
- package/dist/src/tasks/index.js +4 -0
- package/dist/src/utils/index.js +21 -6
- package/package.json +5 -5
- package/src/api/index.ts +2 -2
- package/src/config/index.ts +2 -0
- package/src/index.ts +56 -7
- package/src/net/peer/index.ts +2 -1
- package/src/net/pool/index.ts +25 -5
- package/src/net/protocol/dial/SignatureDialProtocol.1.ts +31 -0
- package/src/net/protocol/index.ts +57 -1
- package/src/tasks/AutoUpdateTask.ts +81 -0
- package/src/tasks/BaseTask.ts +8 -3
- package/src/tasks/InteropBridge/ProcessWithdrawEvents.ts +2 -12
- package/src/tasks/InteropBridge/SyncWithdrawEvents.ts +0 -2
- package/src/tasks/InteropXGateway/ProcessDepositEvents.ts +4 -2
- package/src/tasks/InteropXGateway/SyncDepositEvents.ts +0 -2
- package/src/tasks/Transactions/SyncTransactionStatusTask.ts +65 -0
- package/src/tasks/index.ts +5 -0
- package/src/utils/index.ts +23 -5
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,7 +222,7 @@ 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, itokenAddress } = transaction.submitEvent;
|
225
|
+
const { to, amount, chainId, itoken: itokenAddress } = transaction.submitEvent;
|
214
226
|
|
215
227
|
const itoken = itokens[transaction.sourceChainId].find(token => token.address.toLowerCase() === itokenAddress.toLowerCase());
|
216
228
|
|
@@ -233,7 +245,7 @@ export const buildWithdrawDataForTransaction = async (transaction: Transaction,
|
|
233
245
|
ethers.BigNumber.from(amount.toString()),
|
234
246
|
to,
|
235
247
|
token.address,
|
236
|
-
ethers.BigNumber.from(transaction.
|
248
|
+
ethers.BigNumber.from(transaction.sourceChainId.toString()),
|
237
249
|
transaction.submitTransactionHash,
|
238
250
|
);
|
239
251
|
|
@@ -259,6 +271,12 @@ export function getContract<TContract extends ethers.Contract>(address: string,
|
|
259
271
|
signerOrProvider
|
260
272
|
) as TContract
|
261
273
|
|
274
|
+
// Make sure the contract properties is writable
|
275
|
+
const desc = Object.getOwnPropertyDescriptor(contract, 'functions');
|
276
|
+
|
277
|
+
if (!desc || desc.writable !== true) {
|
278
|
+
return contract
|
279
|
+
}
|
262
280
|
|
263
281
|
return new Proxy(contract, {
|
264
282
|
get(target, prop, receiver) {
|