@instadapp/interop-x 0.0.0-dev.1abc1ca → 0.0.0-dev.1dc43c9
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/.github/workflows/ci.yml +19 -0
- package/bin/interop-x +1 -1
- package/dist/package.json +21 -16
- package/dist/src/abi/index.js +2 -4
- package/dist/src/abi/interopX.json +1436 -0
- package/dist/src/alias.js +10 -0
- package/dist/src/api/index.js +6 -3
- package/dist/src/config/index.js +11 -1
- package/dist/src/constants/addresses.js +2 -7
- package/dist/src/constants/index.js +0 -1
- package/dist/src/constants/tokens.js +62 -39
- package/dist/src/db/models/transaction.js +29 -11
- package/dist/src/gnosis/actions/index.js +9 -0
- package/dist/src/gnosis/actions/withdraw/index.js +114 -0
- package/dist/src/gnosis/index.js +20 -0
- package/dist/src/index.js +75 -24
- package/dist/src/net/peer/index.js +8 -3
- package/dist/src/net/pool/index.js +32 -9
- package/dist/src/net/protocol/dial/SignatureDialProtocol.js +8 -2
- package/dist/src/net/protocol/dial/TransactionStatusDialProtocol.js +30 -0
- package/dist/src/net/protocol/index.js +51 -1
- package/dist/src/tasks/AutoUpdateTask.js +70 -0
- package/dist/src/tasks/BaseTask.js +12 -4
- package/dist/src/tasks/InteropX/SyncLogSubmitEvents.js +84 -0
- package/dist/src/tasks/Transactions/SyncTransactionStatusTask.js +57 -0
- package/dist/src/tasks/index.js +11 -4
- package/dist/src/typechain/{InteropBridgeToken.js → InteropX.js} +0 -0
- package/dist/src/typechain/factories/InteropX__factory.js +1928 -0
- package/dist/src/typechain/factories/index.js +3 -5
- package/dist/src/typechain/index.js +3 -5
- package/dist/src/utils/index.js +97 -39
- package/package.json +21 -16
- package/patches/@ethersproject+properties+5.6.0.patch +13 -0
- package/src/abi/index.ts +2 -4
- package/src/abi/interopX.json +1436 -0
- package/src/alias.ts +6 -0
- package/src/api/index.ts +5 -2
- package/src/config/index.ts +11 -1
- package/src/constants/addresses.ts +3 -8
- package/src/constants/index.ts +0 -1
- package/src/constants/tokens.ts +63 -40
- package/src/db/models/transaction.ts +65 -25
- package/src/gnosis/actions/index.ts +5 -0
- package/src/gnosis/actions/withdraw/index.ts +155 -0
- package/src/gnosis/index.ts +19 -0
- package/src/index.ts +96 -26
- package/src/net/peer/index.ts +9 -7
- package/src/net/pool/index.ts +41 -11
- package/src/net/protocol/dial/SignatureDialProtocol.ts +10 -4
- package/src/net/protocol/dial/TransactionStatusDialProtocol.ts +33 -0
- package/src/net/protocol/index.ts +67 -1
- package/src/tasks/AutoUpdateTask.ts +82 -0
- package/src/tasks/BaseTask.ts +14 -4
- package/src/tasks/InteropX/SyncLogSubmitEvents.ts +136 -0
- package/src/tasks/Transactions/SyncTransactionStatusTask.ts +69 -0
- package/src/tasks/index.ts +17 -5
- package/src/typechain/InteropX.ts +1216 -0
- package/src/typechain/factories/InteropX__factory.ts +1932 -0
- package/src/typechain/factories/index.ts +1 -2
- package/src/typechain/index.ts +2 -4
- package/src/utils/index.ts +153 -49
- package/tsconfig.json +7 -2
- package/dist/src/abi/interopBridgeToken.json +0 -286
- package/dist/src/abi/interopXGateway.json +0 -184
- package/dist/src/constants/itokens.js +0 -13
- package/dist/src/tasks/InteropXGateway/ProcessDepositEvents.js +0 -140
- package/dist/src/tasks/InteropXGateway/SyncDepositEvents.js +0 -75
- package/dist/src/typechain/InteropXGateway.js +0 -2
- package/dist/src/typechain/factories/InteropBridgeToken__factory.js +0 -459
- package/dist/src/typechain/factories/InteropXGateway__factory.js +0 -265
- package/src/abi/interopBridgeToken.json +0 -286
- package/src/abi/interopXGateway.json +0 -184
- package/src/constants/itokens.ts +0 -10
- package/src/tasks/InteropXGateway/ProcessDepositEvents.ts +0 -232
- package/src/tasks/InteropXGateway/SyncDepositEvents.ts +0 -126
- package/src/typechain/InteropBridgeToken.ts +0 -686
- package/src/typechain/InteropXGateway.ts +0 -407
- package/src/typechain/factories/InteropBridgeToken__factory.ts +0 -466
- package/src/typechain/factories/InteropXGateway__factory.ts +0 -272
@@ -1,6 +1,6 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.
|
3
|
+
exports.InteropX__factory = exports.GnosisSafe__factory = exports.Erc20__factory = void 0;
|
4
4
|
/* Autogenerated file. Do not edit manually. */
|
5
5
|
/* tslint:disable */
|
6
6
|
/* eslint-disable */
|
@@ -8,7 +8,5 @@ var Erc20__factory_1 = require("./Erc20__factory");
|
|
8
8
|
Object.defineProperty(exports, "Erc20__factory", { enumerable: true, get: function () { return Erc20__factory_1.Erc20__factory; } });
|
9
9
|
var GnosisSafe__factory_1 = require("./GnosisSafe__factory");
|
10
10
|
Object.defineProperty(exports, "GnosisSafe__factory", { enumerable: true, get: function () { return GnosisSafe__factory_1.GnosisSafe__factory; } });
|
11
|
-
var
|
12
|
-
Object.defineProperty(exports, "
|
13
|
-
var InteropXGateway__factory_1 = require("./InteropXGateway__factory");
|
14
|
-
Object.defineProperty(exports, "InteropXGateway__factory", { enumerable: true, get: function () { return InteropXGateway__factory_1.InteropXGateway__factory; } });
|
11
|
+
var InteropX__factory_1 = require("./InteropX__factory");
|
12
|
+
Object.defineProperty(exports, "InteropX__factory", { enumerable: true, get: function () { return InteropX__factory_1.InteropX__factory; } });
|
@@ -23,13 +23,11 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
23
23
|
return result;
|
24
24
|
};
|
25
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
26
|
-
exports.
|
26
|
+
exports.InteropX__factory = exports.GnosisSafe__factory = exports.Erc20__factory = exports.factories = void 0;
|
27
27
|
exports.factories = __importStar(require("./factories"));
|
28
28
|
var Erc20__factory_1 = require("./factories/Erc20__factory");
|
29
29
|
Object.defineProperty(exports, "Erc20__factory", { enumerable: true, get: function () { return Erc20__factory_1.Erc20__factory; } });
|
30
30
|
var GnosisSafe__factory_1 = require("./factories/GnosisSafe__factory");
|
31
31
|
Object.defineProperty(exports, "GnosisSafe__factory", { enumerable: true, get: function () { return GnosisSafe__factory_1.GnosisSafe__factory; } });
|
32
|
-
var
|
33
|
-
Object.defineProperty(exports, "
|
34
|
-
var InteropXGateway__factory_1 = require("./factories/InteropXGateway__factory");
|
35
|
-
Object.defineProperty(exports, "InteropXGateway__factory", { enumerable: true, get: function () { return InteropXGateway__factory_1.InteropXGateway__factory; } });
|
32
|
+
var InteropX__factory_1 = require("./factories/InteropX__factory");
|
33
|
+
Object.defineProperty(exports, "InteropX__factory", { enumerable: true, get: function () { return InteropX__factory_1.InteropX__factory; } });
|
package/dist/src/utils/index.js
CHANGED
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
4
4
|
};
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
6
|
-
exports.
|
6
|
+
exports.LiquidityError = exports.generateGnosisTransaction = exports.getContract = exports.ContractError = exports.generateInteropTransactionHash = exports.asyncCallWithTimeout = exports.buildSignatureBytes = exports.getRpcProviderUrl = exports.signGnosisSafeTx = exports.short = exports.shortenHash = exports.http = void 0;
|
7
7
|
/**
|
8
8
|
* @module util
|
9
9
|
*/
|
@@ -11,11 +11,19 @@ const axios_1 = __importDefault(require("axios"));
|
|
11
11
|
const axios_retry_1 = __importDefault(require("axios-retry"));
|
12
12
|
const constants_1 = require("@/constants");
|
13
13
|
const ethers_1 = require("ethers");
|
14
|
-
const
|
15
|
-
const config_1 = __importDefault(require("@/config"));
|
16
|
-
const abi_1 = __importDefault(require("@/abi"));
|
14
|
+
const async_retry_1 = __importDefault(require("async-retry"));
|
17
15
|
exports.http = axios_1.default.create();
|
18
16
|
(0, axios_retry_1.default)(exports.http, { retries: 3, retryDelay: axios_retry_1.default.exponentialDelay });
|
17
|
+
function shortenHash(hash, length = 4) {
|
18
|
+
if (!hash)
|
19
|
+
return;
|
20
|
+
if (hash.length < 12)
|
21
|
+
return hash;
|
22
|
+
const beginningChars = hash.startsWith("0x") ? length + 2 : length;
|
23
|
+
const shortened = hash.substr(0, beginningChars) + "…" + hash.substr(-length);
|
24
|
+
return shortened;
|
25
|
+
}
|
26
|
+
exports.shortenHash = shortenHash;
|
19
27
|
function short(buffer) {
|
20
28
|
return buffer.toString('hex').slice(0, 8) + '...';
|
21
29
|
}
|
@@ -59,11 +67,11 @@ exports.signGnosisSafeTx = signGnosisSafeTx;
|
|
59
67
|
const getRpcProviderUrl = (chainId) => {
|
60
68
|
switch (chainId) {
|
61
69
|
case 1:
|
62
|
-
return 'https://rpc.
|
70
|
+
return 'https://rpc.ankr.com/eth';
|
63
71
|
case 137:
|
64
|
-
return 'https://rpc.
|
72
|
+
return 'https://rpc.ankr.com/polygon';
|
65
73
|
case 43114:
|
66
|
-
return 'https://rpc.
|
74
|
+
return 'https://rpc.ankr.com/avalanche';
|
67
75
|
default:
|
68
76
|
throw new Error(`Unknown chainId: ${chainId}`);
|
69
77
|
}
|
@@ -94,44 +102,94 @@ const asyncCallWithTimeout = async (asyncPromise, timeout) => {
|
|
94
102
|
};
|
95
103
|
exports.asyncCallWithTimeout = asyncCallWithTimeout;
|
96
104
|
const generateInteropTransactionHash = (data) => {
|
97
|
-
return ethers_1.ethers.utils.solidityKeccak256(
|
98
|
-
String(data.
|
99
|
-
String(data.
|
105
|
+
return ethers_1.ethers.utils.solidityKeccak256(Array.from({ length: 7 }, () => 'string'), [
|
106
|
+
String(data.actionId),
|
107
|
+
String(data.vnonce),
|
108
|
+
String(data.sourceSender),
|
100
109
|
String(data.sourceChainId),
|
110
|
+
String(data.sourceDsaId),
|
101
111
|
String(data.targetChainId),
|
112
|
+
String(data.targetDsaId),
|
102
113
|
]);
|
103
114
|
};
|
104
115
|
exports.generateInteropTransactionHash = generateInteropTransactionHash;
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
if (transaction.action === 'deposit' && transaction.sourceStatus === 'pending') {
|
112
|
-
throw Error('Cannot build data for pending deposit transaction');
|
113
|
-
}
|
114
|
-
if (!transaction.submitEvent) {
|
115
|
-
throw Error('Cannot build data for transaction without submitEvent');
|
116
|
-
}
|
117
|
-
const token = constants_1.tokens[transaction.sourceChainId].find(token => token.address.toLowerCase() === transaction.submitEvent.token.toLowerCase());
|
118
|
-
if (!token) {
|
119
|
-
throw Error('Cannot build data for transaction without token');
|
116
|
+
class ContractError extends Error {
|
117
|
+
}
|
118
|
+
exports.ContractError = ContractError;
|
119
|
+
function getContract(address, contractInterface, signerOrProvider) {
|
120
|
+
if (!ethers_1.ethers.utils.getAddress(address) || address === ethers_1.ethers.constants.AddressZero) {
|
121
|
+
throw Error(`Invalid 'address' parameter '${address}'.`);
|
120
122
|
}
|
121
|
-
const
|
122
|
-
|
123
|
-
|
123
|
+
const contract = new ethers_1.ethers.Contract(address, contractInterface, signerOrProvider);
|
124
|
+
// Make sure the contract properties is writable
|
125
|
+
const desc = Object.getOwnPropertyDescriptor(contract, 'functions');
|
126
|
+
if (!desc || desc.writable !== true) {
|
127
|
+
return contract;
|
124
128
|
}
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
129
|
+
return new Proxy(contract, {
|
130
|
+
get(target, prop, receiver) {
|
131
|
+
const value = Reflect.get(target, prop, receiver);
|
132
|
+
if (typeof value === 'function' && (contract.functions.hasOwnProperty(prop) || ['queryFilter'].includes(String(prop)))) {
|
133
|
+
let isConstant = false;
|
134
|
+
try {
|
135
|
+
isConstant = contract.interface.getFunction(String(prop)).constant;
|
136
|
+
}
|
137
|
+
catch (error) {
|
138
|
+
}
|
139
|
+
return async (...args) => {
|
140
|
+
try {
|
141
|
+
return await (0, async_retry_1.default)(async () => await value.bind(contract)(...args), { retries: isConstant ? 1 : 3 });
|
142
|
+
}
|
143
|
+
catch (error) {
|
144
|
+
const err = new ContractError(`Error calling "${String(prop)}" on "${address}": ${error.reason || error.message}`);
|
145
|
+
err.method = String(prop);
|
146
|
+
err.address = address;
|
147
|
+
err.args = [...args];
|
148
|
+
throw err;
|
149
|
+
}
|
150
|
+
};
|
151
|
+
}
|
152
|
+
if (typeof value === 'object' && ['populateTransaction', 'estimateGas', 'functions', 'callStatic'].includes(String(prop))) {
|
153
|
+
const parentProp = String(prop);
|
154
|
+
return new Proxy(value, {
|
155
|
+
get(target, prop, receiver) {
|
156
|
+
const value = Reflect.get(target, prop, receiver);
|
157
|
+
if (typeof value === 'function') {
|
158
|
+
return async (...args) => {
|
159
|
+
try {
|
160
|
+
return await (0, async_retry_1.default)(async () => await value.bind(contract)(...args), { retries: parentProp === 'callStatic' ? 3 : 1 });
|
161
|
+
}
|
162
|
+
catch (error) {
|
163
|
+
const err = new ContractError(`Error calling "${String(prop)}" using "${parentProp}" on "${address}": ${error.reason || error.message}`);
|
164
|
+
err.method = String(prop);
|
165
|
+
err.address = address;
|
166
|
+
err.args = [...args];
|
167
|
+
throw err;
|
168
|
+
}
|
169
|
+
};
|
170
|
+
}
|
171
|
+
}
|
172
|
+
});
|
173
|
+
}
|
174
|
+
return value;
|
175
|
+
},
|
134
176
|
});
|
135
|
-
|
177
|
+
}
|
178
|
+
exports.getContract = getContract;
|
179
|
+
const generateGnosisTransaction = async (transactionData, safeContract) => {
|
180
|
+
console.log(transactionData);
|
181
|
+
let isExecuted = await safeContract.dataHashes(await safeContract.getTransactionHash(transactionData.to, transactionData.value, transactionData.data, transactionData.operation, transactionData.safeTxGas, transactionData.baseGas, transactionData.gasPrice, transactionData.gasToken, transactionData.refundReceiver, transactionData.nonce));
|
182
|
+
while (isExecuted == 1) {
|
183
|
+
transactionData.safeTxGas = ethers_1.ethers.BigNumber.from(String(transactionData.safeTxGas)).add(1).toString();
|
184
|
+
isExecuted = await safeContract.dataHashes(await safeContract.getTransactionHash(transactionData.to, transactionData.value, transactionData.data, transactionData.operation, transactionData.safeTxGas, transactionData.baseGas, transactionData.gasPrice, transactionData.gasToken, transactionData.refundReceiver, transactionData.nonce));
|
185
|
+
}
|
186
|
+
return transactionData;
|
136
187
|
};
|
137
|
-
exports.
|
188
|
+
exports.generateGnosisTransaction = generateGnosisTransaction;
|
189
|
+
class LiquidityError extends Error {
|
190
|
+
constructor(message) {
|
191
|
+
super(message || 'Not enough liquidity');
|
192
|
+
Object.setPrototypeOf(this, new.target.prototype);
|
193
|
+
}
|
194
|
+
}
|
195
|
+
exports.LiquidityError = LiquidityError;
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@instadapp/interop-x",
|
3
|
-
"version": "0.0.0-dev.
|
3
|
+
"version": "0.0.0-dev.1dc43c9",
|
4
4
|
"license": "MIT",
|
5
5
|
"main": "dist/index.js",
|
6
6
|
"engines": {
|
@@ -11,8 +11,9 @@
|
|
11
11
|
"start": "yarn build && node bin/interop-x",
|
12
12
|
"build": "yarn generate-abi-types && export GIT_REF=$(git rev-parse --short HEAD) && rimraf ./dist && tsc -p tsconfig.json && replace-in-file '@GIT_SHORT_HASH@' $GIT_REF ./dist/**/*.js",
|
13
13
|
"dev": "yarn generate-abi-types && NODE_ENV=development nodemon",
|
14
|
-
"generate-abi-types": "typechain --target=ethers-v5 'src/abi/*.json' --out-dir 'src/typechain'",
|
15
|
-
"prepublishOnly": "yarn build"
|
14
|
+
"generate-abi-types": "rimraf src/typechain && typechain --target=ethers-v5 'src/abi/*.json' --out-dir 'src/typechain'",
|
15
|
+
"prepublishOnly": "yarn build",
|
16
|
+
"postinstall": "patch-package"
|
16
17
|
},
|
17
18
|
"nodemonConfig": {
|
18
19
|
"watch": [
|
@@ -23,17 +24,19 @@
|
|
23
24
|
},
|
24
25
|
"dependencies": {
|
25
26
|
"@achingbrain/libp2p-gossipsub": "^0.12.2",
|
26
|
-
"
|
27
|
-
"
|
28
|
-
"
|
27
|
+
"@fastify/cors": "^7.0.0",
|
28
|
+
"async-retry": "^1.3.3",
|
29
|
+
"await-spawn": "^4.0.2",
|
30
|
+
"axios": "^0.27.2",
|
31
|
+
"axios-retry": "^3.2.5",
|
29
32
|
"chalk": "4.1.2",
|
30
|
-
"dotenv": "^16.0.
|
33
|
+
"dotenv": "^16.0.1",
|
31
34
|
"ethereumjs-util": "^7.1.4",
|
32
|
-
"ethers": "^5.6.
|
35
|
+
"ethers": "^5.6.5",
|
33
36
|
"ethers-multisend": "^2.1.1",
|
34
37
|
"expand-home-dir": "^0.0.3",
|
35
|
-
"fastify": "^3.
|
36
|
-
"
|
38
|
+
"fastify": "^3.29.0",
|
39
|
+
"fs-extra": "^10.1.0",
|
37
40
|
"libp2p": "^0.36.2",
|
38
41
|
"libp2p-bootstrap": "^0.14.0",
|
39
42
|
"libp2p-kad-dht": "^0.28.6",
|
@@ -43,10 +46,12 @@
|
|
43
46
|
"libp2p-pubsub-peer-discovery": "^4.0.0",
|
44
47
|
"libp2p-tcp": "^0.17.2",
|
45
48
|
"libp2p-websockets": "^0.16.2",
|
46
|
-
"luxon": "^2.
|
49
|
+
"luxon": "^2.4.0",
|
47
50
|
"module-alias": "^2.2.2",
|
48
|
-
"
|
49
|
-
"
|
51
|
+
"patch-package": "^6.4.7",
|
52
|
+
"postinstall-postinstall": "^2.1.0",
|
53
|
+
"sequelize": "6.18.0",
|
54
|
+
"sqlite3": "^5.0.8",
|
50
55
|
"waait": "^1.0.5"
|
51
56
|
},
|
52
57
|
"bin": {
|
@@ -57,13 +62,13 @@
|
|
57
62
|
"@typechain/ethers-v5": "^10.0.0",
|
58
63
|
"@types/bn.js": "^5.1.0",
|
59
64
|
"@types/fs-extra": "^9.0.13",
|
60
|
-
"@types/node": "^17.0.
|
61
|
-
"nodemon": "^2.0.
|
65
|
+
"@types/node": "^17.0.33",
|
66
|
+
"nodemon": "^2.0.16",
|
62
67
|
"replace-in-file": "^6.3.2",
|
63
68
|
"rimraf": "^3.0.2",
|
64
69
|
"ts-node": "^10.5.0",
|
65
70
|
"tsconfig-paths": "^3.12.0",
|
66
71
|
"typechain": "^8.0.0",
|
67
|
-
"typescript": "^4.
|
72
|
+
"typescript": "^4.6.4"
|
68
73
|
}
|
69
74
|
}
|
@@ -0,0 +1,13 @@
|
|
1
|
+
diff --git a/node_modules/@ethersproject/properties/lib/index.js b/node_modules/@ethersproject/properties/lib/index.js
|
2
|
+
index 41e0b52..4c7a9e3 100644
|
3
|
+
--- a/node_modules/@ethersproject/properties/lib/index.js
|
4
|
+
+++ b/node_modules/@ethersproject/properties/lib/index.js
|
5
|
+
@@ -44,7 +44,7 @@ function defineReadOnly(object, name, value) {
|
6
|
+
Object.defineProperty(object, name, {
|
7
|
+
enumerable: true,
|
8
|
+
value: value,
|
9
|
+
- writable: false,
|
10
|
+
+ writable: true,
|
11
|
+
});
|
12
|
+
}
|
13
|
+
exports.defineReadOnly = defineReadOnly;
|
package/src/abi/index.ts
CHANGED
@@ -1,11 +1,9 @@
|
|
1
1
|
import gnosisSafe from "./gnosisSafe.json";
|
2
2
|
import erc20 from "./erc20.json";
|
3
|
-
import
|
4
|
-
import interopBridgeToken from "./interopBridgeToken.json";
|
3
|
+
import interopX from "./interopX.json";
|
5
4
|
|
6
5
|
export default {
|
7
6
|
gnosisSafe,
|
8
7
|
erc20,
|
9
|
-
|
10
|
-
interopBridgeToken,
|
8
|
+
interopX,
|
11
9
|
}
|