@instadapp/interop-x 0.0.0-dev.ef78459 → 0.0.0-dev.f0a6281
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/.env.example +2 -1
- package/bin/interop-x +1 -1
- package/dist/package.json +73 -0
- package/dist/src/abi/erc20.json +350 -0
- package/dist/src/abi/gnosisSafe.json +747 -0
- package/dist/src/abi/index.js +15 -0
- package/dist/src/abi/interopBridgeToken.json +298 -0
- package/dist/src/abi/interopXGateway.json +184 -0
- package/dist/src/api/index.js +33 -0
- package/dist/src/config/index.js +31 -0
- package/dist/src/constants/addresses.js +20 -0
- package/dist/{constants → src/constants}/index.js +2 -0
- package/dist/src/constants/itokens.js +13 -0
- package/dist/src/constants/tokens.js +107 -0
- package/dist/{db → src/db}/index.js +0 -0
- package/dist/{db → src/db}/models/index.js +1 -1
- package/dist/src/db/models/transaction.js +54 -0
- package/dist/{db → src/db}/sequelize.js +2 -1
- package/dist/src/index.js +130 -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 +8 -3
- package/dist/{net → src/net}/pool/index.js +32 -9
- package/dist/{net → src/net}/protocol/dial/BaseDialProtocol.js +0 -0
- package/dist/{net → src/net}/protocol/dial/SignatureDialProtocol.js +20 -12
- package/dist/src/net/protocol/dial/TransactionStatusDialProtocol.js +28 -0
- package/dist/{net → src/net}/protocol/index.js +44 -4
- package/dist/src/tasks/AutoUpdateTask.js +70 -0
- package/dist/{tasks → src/tasks}/BaseTask.js +13 -5
- package/dist/src/tasks/InteropBridge/ProcessWithdrawEvents.js +146 -0
- package/dist/src/tasks/InteropBridge/SyncWithdrawEvents.js +71 -0
- package/dist/src/tasks/InteropXGateway/ProcessDepositEvents.js +161 -0
- package/dist/src/tasks/InteropXGateway/SyncDepositEvents.js +74 -0
- package/dist/src/tasks/Transactions/SyncTransactionStatusTask.js +53 -0
- package/dist/src/tasks/index.js +44 -0
- package/dist/src/typechain/Erc20.js +2 -0
- package/dist/src/typechain/GnosisSafe.js +2 -0
- package/dist/src/typechain/InteropBridgeToken.js +2 -0
- package/dist/src/typechain/InteropXGateway.js +2 -0
- package/dist/src/typechain/common.js +2 -0
- package/dist/src/typechain/factories/Erc20__factory.js +367 -0
- package/dist/src/typechain/factories/GnosisSafe__factory.js +1174 -0
- package/dist/src/typechain/factories/InteropBridgeToken__factory.js +471 -0
- package/dist/src/typechain/factories/InteropXGateway__factory.js +265 -0
- package/dist/src/typechain/factories/index.js +14 -0
- package/dist/src/typechain/index.js +35 -0
- package/dist/{types.js → src/types.js} +0 -0
- package/dist/src/utils/index.js +238 -0
- package/package.json +18 -10
- package/patches/@ethersproject+properties+5.6.0.patch +13 -0
- package/src/abi/erc20.json +350 -0
- package/src/abi/gnosisSafe.json +747 -0
- package/src/abi/index.ts +11 -0
- package/src/abi/interopBridgeToken.json +298 -0
- package/src/abi/interopXGateway.json +184 -0
- package/src/api/index.ts +33 -0
- package/src/config/index.ts +17 -1
- package/src/constants/addresses.ts +9 -2
- package/src/constants/index.ts +2 -0
- package/src/constants/itokens.ts +10 -0
- package/src/constants/tokens.ts +104 -0
- package/src/db/models/index.ts +1 -1
- package/src/db/models/transaction.ts +96 -0
- package/src/db/sequelize.ts +2 -1
- package/src/index.ts +119 -7
- package/src/net/peer/index.ts +9 -7
- package/src/net/pool/index.ts +41 -11
- package/src/net/protocol/dial/SignatureDialProtocol.ts +24 -15
- package/src/net/protocol/dial/TransactionStatusDialProtocol.ts +31 -0
- package/src/net/protocol/index.ts +60 -4
- package/src/tasks/AutoUpdateTask.ts +82 -0
- package/src/tasks/BaseTask.ts +15 -6
- package/src/tasks/InteropBridge/ProcessWithdrawEvents.ts +231 -0
- package/src/tasks/InteropBridge/SyncWithdrawEvents.ts +121 -0
- package/src/tasks/InteropXGateway/ProcessDepositEvents.ts +256 -0
- package/src/tasks/InteropXGateway/SyncDepositEvents.ts +124 -0
- package/src/tasks/Transactions/SyncTransactionStatusTask.ts +65 -0
- package/src/tasks/index.ts +26 -1
- package/src/typechain/Erc20.ts +491 -0
- package/src/typechain/GnosisSafe.ts +1728 -0
- package/src/typechain/InteropBridgeToken.ts +692 -0
- package/src/typechain/InteropXGateway.ts +407 -0
- package/src/typechain/common.ts +44 -0
- package/src/typechain/factories/Erc20__factory.ts +368 -0
- package/src/typechain/factories/GnosisSafe__factory.ts +1178 -0
- package/src/typechain/factories/InteropBridgeToken__factory.ts +478 -0
- package/src/typechain/factories/InteropXGateway__factory.ts +272 -0
- package/src/typechain/factories/index.ts +7 -0
- package/src/typechain/index.ts +12 -0
- package/src/types.ts +1 -1
- package/src/utils/index.ts +206 -3
- package/dist/config/index.js +0 -17
- package/dist/constants/addresses.js +0 -13
- package/dist/db/models/execution.js +0 -38
- package/dist/index.js +0 -43
- package/dist/tasks/index.js +0 -19
- package/dist/utils/index.js +0 -89
- package/src/db/models/execution.ts +0 -57
package/dist/utils/index.js
DELETED
@@ -1,89 +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.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
|
-
exports.http = axios_1.default.create();
|
14
|
-
(0, axios_retry_1.default)(exports.http, { retries: 3, retryDelay: axios_retry_1.default.exponentialDelay });
|
15
|
-
function short(buffer) {
|
16
|
-
return buffer.toString('hex').slice(0, 8) + '...';
|
17
|
-
}
|
18
|
-
exports.short = short;
|
19
|
-
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 }) => {
|
20
|
-
const gnosisSafe = constants_1.addresses[chainId].gnosisSafe;
|
21
|
-
const domain = {
|
22
|
-
verifyingContract: gnosisSafe,
|
23
|
-
chainId,
|
24
|
-
};
|
25
|
-
const types = {
|
26
|
-
SafeTx: [
|
27
|
-
{ type: 'address', name: 'to' },
|
28
|
-
{ type: 'uint256', name: 'value' },
|
29
|
-
{ type: 'bytes', name: 'data' },
|
30
|
-
{ type: 'uint8', name: 'operation' },
|
31
|
-
{ type: 'uint256', name: 'safeTxGas' },
|
32
|
-
{ type: 'uint256', name: 'baseGas' },
|
33
|
-
{ type: 'uint256', name: 'gasPrice' },
|
34
|
-
{ type: 'address', name: 'gasToken' },
|
35
|
-
{ type: 'address', name: 'refundReceiver' },
|
36
|
-
{ type: 'uint256', name: 'nonce' },
|
37
|
-
],
|
38
|
-
};
|
39
|
-
const message = {
|
40
|
-
baseGas,
|
41
|
-
data,
|
42
|
-
gasPrice,
|
43
|
-
gasToken,
|
44
|
-
nonce: Number(nonce),
|
45
|
-
operation,
|
46
|
-
refundReceiver,
|
47
|
-
safeAddress: gnosisSafe,
|
48
|
-
safeTxGas: String(safeTxGas),
|
49
|
-
to,
|
50
|
-
value,
|
51
|
-
};
|
52
|
-
return await signer._signTypedData(domain, types, message);
|
53
|
-
};
|
54
|
-
exports.signGnosisSafeTx = signGnosisSafeTx;
|
55
|
-
const getRpcProviderUrl = (chainId) => {
|
56
|
-
switch (chainId) {
|
57
|
-
case 1:
|
58
|
-
return 'https://rpc.instadapp.io/mainnet';
|
59
|
-
case 137:
|
60
|
-
return 'https://rpc.instadapp.io/polygon';
|
61
|
-
default:
|
62
|
-
throw new Error(`Unknown chainId: ${chainId}`);
|
63
|
-
}
|
64
|
-
};
|
65
|
-
exports.getRpcProviderUrl = getRpcProviderUrl;
|
66
|
-
const buildSignatureBytes = (signatures) => {
|
67
|
-
signatures.sort((left, right) => left.signer.toLowerCase().localeCompare(right.signer.toLowerCase()));
|
68
|
-
let signatureBytes = "0x";
|
69
|
-
for (const sig of signatures) {
|
70
|
-
signatureBytes += sig.data.slice(2);
|
71
|
-
}
|
72
|
-
return signatureBytes;
|
73
|
-
};
|
74
|
-
exports.buildSignatureBytes = buildSignatureBytes;
|
75
|
-
/**
|
76
|
-
* Call an async function with a maximum time limit (in milliseconds) for the timeout
|
77
|
-
* Resolved promise for async function call, or an error if time limit reached
|
78
|
-
*/
|
79
|
-
const asyncCallWithTimeout = async (asyncPromise, timeout) => {
|
80
|
-
let timeoutHandle;
|
81
|
-
const timeoutPromise = new Promise((_resolve, reject) => {
|
82
|
-
timeoutHandle = setTimeout(() => reject(new Error('Async call timeout limit reached')), timeout);
|
83
|
-
});
|
84
|
-
return Promise.race([asyncPromise, timeoutPromise]).then(result => {
|
85
|
-
clearTimeout(timeoutHandle);
|
86
|
-
return result;
|
87
|
-
});
|
88
|
-
};
|
89
|
-
exports.asyncCallWithTimeout = asyncCallWithTimeout;
|
@@ -1,57 +0,0 @@
|
|
1
|
-
import { sequelize } from '@/db/sequelize'
|
2
|
-
import { CreationOptional, InferAttributes, InferCreationAttributes, Model, DataTypes } from 'sequelize';
|
3
|
-
|
4
|
-
export class Execution extends Model<InferAttributes<Execution>, InferCreationAttributes<Execution>> {
|
5
|
-
declare id: CreationOptional<number>;
|
6
|
-
|
7
|
-
declare transactionHash: string;
|
8
|
-
declare from: string;
|
9
|
-
declare executions: any[];
|
10
|
-
declare chainId: number;
|
11
|
-
declare gas: string;
|
12
|
-
declare maxGasPrice: string;
|
13
|
-
declare assets: any[];
|
14
|
-
declare metadata: string;
|
15
|
-
declare vnonce: string;
|
16
|
-
declare txHash: string;
|
17
|
-
|
18
|
-
declare blockNumber: string;
|
19
|
-
declare status: CreationOptional<string>;
|
20
|
-
declare delayUntil: CreationOptional<Date>;
|
21
|
-
declare delayedCount: CreationOptional<number>;
|
22
|
-
|
23
|
-
declare error: CreationOptional<string>;
|
24
|
-
declare createdAt: CreationOptional<Date>;
|
25
|
-
declare updatedAt: CreationOptional<Date>;
|
26
|
-
}
|
27
|
-
|
28
|
-
Execution.init({
|
29
|
-
id: {
|
30
|
-
type: DataTypes.INTEGER,
|
31
|
-
autoIncrement: true,
|
32
|
-
primaryKey: true
|
33
|
-
},
|
34
|
-
transactionHash: DataTypes.STRING,
|
35
|
-
from: DataTypes.STRING,
|
36
|
-
executions: DataTypes.JSON,
|
37
|
-
chainId: DataTypes.NUMBER,
|
38
|
-
gas: DataTypes.STRING,
|
39
|
-
maxGasPrice: DataTypes.STRING,
|
40
|
-
assets: DataTypes.JSON,
|
41
|
-
metadata: DataTypes.STRING,
|
42
|
-
vnonce: DataTypes.STRING,
|
43
|
-
txHash: DataTypes.STRING,
|
44
|
-
blockNumber: DataTypes.STRING,
|
45
|
-
status: {
|
46
|
-
type: DataTypes.STRING,
|
47
|
-
defaultValue: 'pending'
|
48
|
-
},
|
49
|
-
delayUntil: DataTypes.DATE,
|
50
|
-
delayedCount: {
|
51
|
-
type: DataTypes.INTEGER,
|
52
|
-
defaultValue: 0
|
53
|
-
},
|
54
|
-
error: DataTypes.STRING,
|
55
|
-
createdAt: DataTypes.DATE,
|
56
|
-
updatedAt: DataTypes.DATE,
|
57
|
-
}, { sequelize, tableName: 'executions' });
|