@instadapp/interop-x 0.0.0-dev.6ea4ee5 → 0.0.0-dev.79c1ae5
Sign up to get free protection for your applications and to get access to all the features.
- package/bin/interop-x +1 -1
- package/dist/package.json +73 -0
- package/dist/{abi → src/abi}/erc20.json +0 -0
- package/dist/{abi → src/abi}/gnosisSafe.json +0 -0
- package/dist/{abi → src/abi}/index.js +0 -0
- package/dist/{abi → src/abi}/interopBridgeToken.json +0 -0
- package/dist/{abi → src/abi}/interopXGateway.json +0 -0
- package/dist/src/api/index.js +33 -0
- package/dist/{config → src/config}/index.js +1 -0
- package/dist/{constants → src/constants}/addresses.js +0 -8
- package/dist/{constants → src/constants}/index.js +1 -0
- package/dist/src/constants/itokens.js +13 -0
- package/dist/{constants → src/constants}/tokens.js +0 -0
- package/dist/{db → src/db}/index.js +0 -0
- package/dist/{db → src/db}/models/index.js +0 -0
- package/dist/{db → src/db}/models/transaction.js +3 -1
- package/dist/{db → src/db}/sequelize.js +1 -1
- package/dist/src/index.js +103 -0
- package/dist/{logger → src/logger}/index.js +0 -0
- package/dist/{net → src/net}/index.js +0 -0
- package/dist/{net → src/net}/peer/index.js +6 -2
- package/dist/{net → src/net}/pool/index.js +27 -9
- package/dist/{net → src/net}/protocol/dial/BaseDialProtocol.js +0 -0
- package/dist/{net → src/net}/protocol/dial/SignatureDialProtocol.js +22 -12
- package/dist/{net → src/net}/protocol/index.js +30 -1
- package/dist/src/tasks/AutoUpdateTask.js +43 -0
- package/dist/{tasks → src/tasks}/BaseTask.js +1 -1
- package/dist/src/tasks/InteropBridge/ProcessWithdrawEvents.js +147 -0
- package/dist/src/tasks/InteropBridge/SyncWithdrawEvents.js +70 -0
- package/dist/src/tasks/InteropXGateway/ProcessDepositEvents.js +150 -0
- package/dist/{tasks → src/tasks}/InteropXGateway/SyncDepositEvents.js +16 -20
- package/dist/{tasks → src/tasks}/index.js +15 -0
- package/dist/{typechain → src/typechain}/Erc20.js +0 -0
- package/dist/{typechain → src/typechain}/GnosisSafe.js +0 -0
- package/dist/{typechain → src/typechain}/InteropBridgeToken.js +0 -0
- package/dist/{typechain → src/typechain}/InteropXGateway.js +0 -0
- package/dist/{typechain → src/typechain}/common.js +0 -0
- package/dist/{typechain → src/typechain}/factories/Erc20__factory.js +0 -0
- package/dist/{typechain → src/typechain}/factories/GnosisSafe__factory.js +0 -0
- package/dist/{typechain → src/typechain}/factories/InteropBridgeToken__factory.js +0 -0
- package/dist/{typechain → src/typechain}/factories/InteropXGateway__factory.js +0 -0
- package/dist/{typechain → src/typechain}/factories/index.js +0 -0
- package/dist/{typechain → src/typechain}/index.js +0 -0
- package/dist/{types.js → src/types.js} +0 -0
- package/dist/src/utils/index.js +228 -0
- package/package.json +11 -4
- package/patches/@ethersproject+properties+5.6.0.patch +13 -0
- package/src/api/index.ts +33 -0
- package/src/config/index.ts +2 -0
- package/src/constants/addresses.ts +0 -8
- package/src/constants/index.ts +1 -0
- package/src/constants/itokens.ts +10 -0
- package/src/db/models/transaction.ts +8 -4
- package/src/db/sequelize.ts +1 -1
- package/src/index.ts +56 -6
- package/src/net/peer/index.ts +7 -6
- package/src/net/pool/index.ts +37 -11
- package/src/net/protocol/dial/SignatureDialProtocol.ts +25 -13
- package/src/net/protocol/index.ts +45 -1
- package/src/tasks/AutoUpdateTask.ts +55 -0
- package/src/tasks/BaseTask.ts +1 -1
- package/src/tasks/InteropBridge/ProcessWithdrawEvents.ts +233 -0
- package/src/tasks/InteropBridge/SyncWithdrawEvents.ts +121 -0
- package/src/tasks/InteropXGateway/ProcessDepositEvents.ts +245 -0
- package/src/tasks/InteropXGateway/SyncDepositEvents.ts +23 -11
- package/src/tasks/index.ts +22 -2
- package/src/utils/index.ts +182 -4
- package/dist/index.js +0 -63
- package/dist/utils/index.js +0 -101
package/dist/utils/index.js
DELETED
@@ -1,101 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
4
|
-
};
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
6
|
-
exports.generateInteropTransactionHash = exports.asyncCallWithTimeout = exports.buildSignatureBytes = exports.getRpcProviderUrl = exports.signGnosisSafeTx = exports.short = exports.http = void 0;
|
7
|
-
/**
|
8
|
-
* @module util
|
9
|
-
*/
|
10
|
-
const axios_1 = __importDefault(require("axios"));
|
11
|
-
const axios_retry_1 = __importDefault(require("axios-retry"));
|
12
|
-
const constants_1 = require("@/constants");
|
13
|
-
const ethers_1 = require("ethers");
|
14
|
-
exports.http = axios_1.default.create();
|
15
|
-
(0, axios_retry_1.default)(exports.http, { retries: 3, retryDelay: axios_retry_1.default.exponentialDelay });
|
16
|
-
function short(buffer) {
|
17
|
-
return buffer.toString('hex').slice(0, 8) + '...';
|
18
|
-
}
|
19
|
-
exports.short = short;
|
20
|
-
const signGnosisSafeTx = async ({ to, data = null, value = '0', operation = '1', baseGas = '0', gasPrice = "0", gasToken = "0x0000000000000000000000000000000000000000", refundReceiver = "0x0000000000000000000000000000000000000000", safeTxGas = "79668", nonce = "0", chainId = 137, }, { signer }) => {
|
21
|
-
const gnosisSafe = constants_1.addresses[chainId].gnosisSafe;
|
22
|
-
const domain = {
|
23
|
-
verifyingContract: gnosisSafe,
|
24
|
-
chainId,
|
25
|
-
};
|
26
|
-
const types = {
|
27
|
-
SafeTx: [
|
28
|
-
{ type: 'address', name: 'to' },
|
29
|
-
{ type: 'uint256', name: 'value' },
|
30
|
-
{ type: 'bytes', name: 'data' },
|
31
|
-
{ type: 'uint8', name: 'operation' },
|
32
|
-
{ type: 'uint256', name: 'safeTxGas' },
|
33
|
-
{ type: 'uint256', name: 'baseGas' },
|
34
|
-
{ type: 'uint256', name: 'gasPrice' },
|
35
|
-
{ type: 'address', name: 'gasToken' },
|
36
|
-
{ type: 'address', name: 'refundReceiver' },
|
37
|
-
{ type: 'uint256', name: 'nonce' },
|
38
|
-
],
|
39
|
-
};
|
40
|
-
const message = {
|
41
|
-
baseGas,
|
42
|
-
data,
|
43
|
-
gasPrice,
|
44
|
-
gasToken,
|
45
|
-
nonce: Number(nonce),
|
46
|
-
operation,
|
47
|
-
refundReceiver,
|
48
|
-
safeAddress: gnosisSafe,
|
49
|
-
safeTxGas: String(safeTxGas),
|
50
|
-
to,
|
51
|
-
value,
|
52
|
-
};
|
53
|
-
return await signer._signTypedData(domain, types, message);
|
54
|
-
};
|
55
|
-
exports.signGnosisSafeTx = signGnosisSafeTx;
|
56
|
-
const getRpcProviderUrl = (chainId) => {
|
57
|
-
switch (chainId) {
|
58
|
-
case 1:
|
59
|
-
return 'https://rpc.instadapp.io/mainnet';
|
60
|
-
case 137:
|
61
|
-
return 'https://rpc.instadapp.io/polygon';
|
62
|
-
case 43114:
|
63
|
-
return 'https://rpc.instadapp.io/avalanche';
|
64
|
-
default:
|
65
|
-
throw new Error(`Unknown chainId: ${chainId}`);
|
66
|
-
}
|
67
|
-
};
|
68
|
-
exports.getRpcProviderUrl = getRpcProviderUrl;
|
69
|
-
const buildSignatureBytes = (signatures) => {
|
70
|
-
signatures.sort((left, right) => left.signer.toLowerCase().localeCompare(right.signer.toLowerCase()));
|
71
|
-
let signatureBytes = "0x";
|
72
|
-
for (const sig of signatures) {
|
73
|
-
signatureBytes += sig.data.slice(2);
|
74
|
-
}
|
75
|
-
return signatureBytes;
|
76
|
-
};
|
77
|
-
exports.buildSignatureBytes = buildSignatureBytes;
|
78
|
-
/**
|
79
|
-
* Call an async function with a maximum time limit (in milliseconds) for the timeout
|
80
|
-
* Resolved promise for async function call, or an error if time limit reached
|
81
|
-
*/
|
82
|
-
const asyncCallWithTimeout = async (asyncPromise, timeout) => {
|
83
|
-
let timeoutHandle;
|
84
|
-
const timeoutPromise = new Promise((_resolve, reject) => {
|
85
|
-
timeoutHandle = setTimeout(() => reject(new Error('Async call timeout limit reached')), timeout);
|
86
|
-
});
|
87
|
-
return Promise.race([asyncPromise, timeoutPromise]).then(result => {
|
88
|
-
clearTimeout(timeoutHandle);
|
89
|
-
return result;
|
90
|
-
});
|
91
|
-
};
|
92
|
-
exports.asyncCallWithTimeout = asyncCallWithTimeout;
|
93
|
-
const generateInteropTransactionHash = (data) => {
|
94
|
-
return ethers_1.ethers.utils.solidityKeccak256(['string', 'string', 'string', 'string'], [
|
95
|
-
String(data.type),
|
96
|
-
String(data.sourceTransactionHash),
|
97
|
-
String(data.sourceChainId),
|
98
|
-
String(data.targetChainId),
|
99
|
-
]);
|
100
|
-
};
|
101
|
-
exports.generateInteropTransactionHash = generateInteropTransactionHash;
|