@instadapp/interop-x 0.0.0-dev.14afa72 → 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/dist/package.json +13 -12
- 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 +1 -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 +21 -11
- package/dist/src/gnosis/actions/index.js +0 -2
- package/dist/src/gnosis/actions/withdraw/index.js +114 -0
- package/dist/src/gnosis/index.js +4 -4
- package/dist/src/index.js +7 -19
- package/dist/src/net/protocol/dial/SignatureDialProtocol.js +6 -2
- package/dist/src/net/protocol/dial/TransactionStatusDialProtocol.js +2 -0
- package/dist/src/net/protocol/index.js +11 -1
- package/dist/src/tasks/InteropX/SyncLogSubmitEvents.js +84 -0
- package/dist/src/tasks/Transactions/SyncTransactionStatusTask.js +6 -2
- package/dist/src/tasks/index.js +8 -29
- 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 +46 -8
- package/package.json +13 -12
- 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 +1 -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 +55 -25
- package/src/gnosis/actions/index.ts +0 -2
- package/src/gnosis/actions/withdraw/index.ts +155 -0
- package/src/gnosis/index.ts +5 -5
- package/src/index.ts +6 -18
- package/src/net/protocol/dial/SignatureDialProtocol.ts +6 -2
- package/src/net/protocol/dial/TransactionStatusDialProtocol.ts +3 -1
- package/src/net/protocol/index.ts +13 -3
- package/src/tasks/InteropX/SyncLogSubmitEvents.ts +136 -0
- package/src/tasks/Transactions/SyncTransactionStatusTask.ts +6 -2
- package/src/tasks/index.ts +10 -39
- 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 +102 -11
- package/tsconfig.json +7 -2
- package/dist/src/abi/interopBridgeToken.json +0 -298
- package/dist/src/abi/interopXGateway.json +0 -184
- package/dist/src/constants/itokens.js +0 -13
- package/dist/src/gnosis/actions/deposit.js +0 -48
- package/dist/src/gnosis/actions/withdraw.js +0 -50
- package/dist/src/tasks/InteropBridge/ProcessWithdrawEvents.js +0 -162
- package/dist/src/tasks/InteropBridge/SyncBurnEvents.js +0 -71
- package/dist/src/tasks/InteropBridge/SyncMintEvents.js +0 -67
- package/dist/src/tasks/InteropXGateway/ProcessDepositEvents.js +0 -164
- package/dist/src/tasks/InteropXGateway/SyncDepositEvents.js +0 -74
- package/dist/src/tasks/InteropXGateway/SyncWithdrawtEvents.js +0 -72
- package/dist/src/typechain/InteropXGateway.js +0 -2
- package/dist/src/typechain/factories/InteropBridgeToken__factory.js +0 -471
- package/dist/src/typechain/factories/InteropXGateway__factory.js +0 -265
- package/src/abi/interopBridgeToken.json +0 -298
- package/src/abi/interopXGateway.json +0 -184
- package/src/constants/itokens.ts +0 -10
- package/src/gnosis/actions/deposit.ts +0 -63
- package/src/gnosis/actions/withdraw.ts +0 -67
- package/src/tasks/InteropBridge/ProcessWithdrawEvents.ts +0 -249
- package/src/tasks/InteropBridge/SyncBurnEvents.ts +0 -119
- package/src/tasks/InteropBridge/SyncMintEvents.ts +0 -99
- package/src/tasks/InteropXGateway/ProcessDepositEvents.ts +0 -260
- package/src/tasks/InteropXGateway/SyncDepositEvents.ts +0 -124
- package/src/tasks/InteropXGateway/SyncWithdrawtEvents.ts +0 -105
- package/src/typechain/InteropBridgeToken.ts +0 -692
- package/src/typechain/InteropXGateway.ts +0 -407
- package/src/typechain/factories/InteropBridgeToken__factory.ts +0 -478
- 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.getContract = exports.generateInteropTransactionHash = exports.asyncCallWithTimeout = exports.buildSignatureBytes = exports.getRpcProviderUrl = exports.signGnosisSafeTx = exports.short = exports.shortenHash = exports.http = void 0;
|
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,6 +11,7 @@ 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 async_retry_1 = __importDefault(require("async-retry"));
|
14
15
|
exports.http = axios_1.default.create();
|
15
16
|
(0, axios_retry_1.default)(exports.http, { retries: 3, retryDelay: axios_retry_1.default.exponentialDelay });
|
16
17
|
function shortenHash(hash, length = 4) {
|
@@ -101,14 +102,20 @@ const asyncCallWithTimeout = async (asyncPromise, timeout) => {
|
|
101
102
|
};
|
102
103
|
exports.asyncCallWithTimeout = asyncCallWithTimeout;
|
103
104
|
const generateInteropTransactionHash = (data) => {
|
104
|
-
return ethers_1.ethers.utils.solidityKeccak256(
|
105
|
-
String(data.
|
106
|
-
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),
|
107
109
|
String(data.sourceChainId),
|
110
|
+
String(data.sourceDsaId),
|
108
111
|
String(data.targetChainId),
|
112
|
+
String(data.targetDsaId),
|
109
113
|
]);
|
110
114
|
};
|
111
115
|
exports.generateInteropTransactionHash = generateInteropTransactionHash;
|
116
|
+
class ContractError extends Error {
|
117
|
+
}
|
118
|
+
exports.ContractError = ContractError;
|
112
119
|
function getContract(address, contractInterface, signerOrProvider) {
|
113
120
|
if (!ethers_1.ethers.utils.getAddress(address) || address === ethers_1.ethers.constants.AddressZero) {
|
114
121
|
throw Error(`Invalid 'address' parameter '${address}'.`);
|
@@ -123,12 +130,22 @@ function getContract(address, contractInterface, signerOrProvider) {
|
|
123
130
|
get(target, prop, receiver) {
|
124
131
|
const value = Reflect.get(target, prop, receiver);
|
125
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
|
+
}
|
126
139
|
return async (...args) => {
|
127
140
|
try {
|
128
|
-
return await value.bind(contract)(...args);
|
141
|
+
return await (0, async_retry_1.default)(async () => await value.bind(contract)(...args), { retries: isConstant ? 1 : 3 });
|
129
142
|
}
|
130
143
|
catch (error) {
|
131
|
-
|
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;
|
132
149
|
}
|
133
150
|
};
|
134
151
|
}
|
@@ -140,10 +157,14 @@ function getContract(address, contractInterface, signerOrProvider) {
|
|
140
157
|
if (typeof value === 'function') {
|
141
158
|
return async (...args) => {
|
142
159
|
try {
|
143
|
-
return await value.bind(contract)(...args);
|
160
|
+
return await (0, async_retry_1.default)(async () => await value.bind(contract)(...args), { retries: parentProp === 'callStatic' ? 3 : 1 });
|
144
161
|
}
|
145
162
|
catch (error) {
|
146
|
-
|
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;
|
147
168
|
}
|
148
169
|
};
|
149
170
|
}
|
@@ -155,3 +176,20 @@ function getContract(address, contractInterface, signerOrProvider) {
|
|
155
176
|
});
|
156
177
|
}
|
157
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;
|
187
|
+
};
|
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,7 +11,7 @@
|
|
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'",
|
14
|
+
"generate-abi-types": "rimraf src/typechain && typechain --target=ethers-v5 'src/abi/*.json' --out-dir 'src/typechain'",
|
15
15
|
"prepublishOnly": "yarn build",
|
16
16
|
"postinstall": "patch-package"
|
17
17
|
},
|
@@ -25,16 +25,17 @@
|
|
25
25
|
"dependencies": {
|
26
26
|
"@achingbrain/libp2p-gossipsub": "^0.12.2",
|
27
27
|
"@fastify/cors": "^7.0.0",
|
28
|
+
"async-retry": "^1.3.3",
|
28
29
|
"await-spawn": "^4.0.2",
|
29
|
-
"axios": "^0.27.
|
30
|
-
"axios-retry": "^3.2.
|
30
|
+
"axios": "^0.27.2",
|
31
|
+
"axios-retry": "^3.2.5",
|
31
32
|
"chalk": "4.1.2",
|
32
|
-
"dotenv": "^16.0.
|
33
|
+
"dotenv": "^16.0.1",
|
33
34
|
"ethereumjs-util": "^7.1.4",
|
34
|
-
"ethers": "^5.6.
|
35
|
+
"ethers": "^5.6.5",
|
35
36
|
"ethers-multisend": "^2.1.1",
|
36
37
|
"expand-home-dir": "^0.0.3",
|
37
|
-
"fastify": "^3.
|
38
|
+
"fastify": "^3.29.0",
|
38
39
|
"fs-extra": "^10.1.0",
|
39
40
|
"libp2p": "^0.36.2",
|
40
41
|
"libp2p-bootstrap": "^0.14.0",
|
@@ -45,12 +46,12 @@
|
|
45
46
|
"libp2p-pubsub-peer-discovery": "^4.0.0",
|
46
47
|
"libp2p-tcp": "^0.17.2",
|
47
48
|
"libp2p-websockets": "^0.16.2",
|
48
|
-
"luxon": "^2.
|
49
|
+
"luxon": "^2.4.0",
|
49
50
|
"module-alias": "^2.2.2",
|
50
51
|
"patch-package": "^6.4.7",
|
51
52
|
"postinstall-postinstall": "^2.1.0",
|
52
53
|
"sequelize": "6.18.0",
|
53
|
-
"sqlite3": "^5.0.
|
54
|
+
"sqlite3": "^5.0.8",
|
54
55
|
"waait": "^1.0.5"
|
55
56
|
},
|
56
57
|
"bin": {
|
@@ -61,13 +62,13 @@
|
|
61
62
|
"@typechain/ethers-v5": "^10.0.0",
|
62
63
|
"@types/bn.js": "^5.1.0",
|
63
64
|
"@types/fs-extra": "^9.0.13",
|
64
|
-
"@types/node": "^17.0.
|
65
|
-
"nodemon": "^2.0.
|
65
|
+
"@types/node": "^17.0.33",
|
66
|
+
"nodemon": "^2.0.16",
|
66
67
|
"replace-in-file": "^6.3.2",
|
67
68
|
"rimraf": "^3.0.2",
|
68
69
|
"ts-node": "^10.5.0",
|
69
70
|
"tsconfig-paths": "^3.12.0",
|
70
71
|
"typechain": "^8.0.0",
|
71
|
-
"typescript": "^4.
|
72
|
+
"typescript": "^4.6.4"
|
72
73
|
}
|
73
74
|
}
|
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
|
}
|