@instadapp/interop-x 0.0.0-dev.f9253db → 0.0.0-dev.fabee70
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 +0 -0
- package/dist/src/index.js +107 -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/src/net/protocol/dial/SignatureDialProtocol.1.js +28 -0
- package/dist/{net → src/net}/protocol/dial/SignatureDialProtocol.js +22 -12
- package/dist/{net → src/net}/protocol/index.js +41 -1
- package/dist/src/tasks/AutoUpdateTask.js +57 -0
- package/dist/{tasks → src/tasks}/BaseTask.js +8 -4
- package/dist/src/tasks/InteropBridge/ProcessWithdrawEvents.js +146 -0
- package/dist/src/tasks/InteropBridge/SyncWithdrawEvents.js +69 -0
- package/dist/src/tasks/InteropXGateway/ProcessDepositEvents.js +149 -0
- package/dist/{tasks → src/tasks}/InteropXGateway/SyncDepositEvents.js +16 -21
- package/dist/src/tasks/Transactions/SyncTransactionStatusTask.js +53 -0
- package/dist/src/tasks/index.js +44 -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 +238 -0
- package/package.json +9 -3
- 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/index.ts +62 -6
- package/src/net/peer/index.ts +9 -7
- package/src/net/pool/index.ts +41 -11
- package/src/net/protocol/dial/SignatureDialProtocol.1.ts +31 -0
- package/src/net/protocol/dial/SignatureDialProtocol.ts +25 -13
- package/src/net/protocol/index.ts +57 -1
- package/src/tasks/AutoUpdateTask.ts +73 -0
- package/src/tasks/BaseTask.ts +9 -4
- package/src/tasks/InteropBridge/ProcessWithdrawEvents.ts +231 -0
- package/src/tasks/InteropBridge/SyncWithdrawEvents.ts +119 -0
- package/src/tasks/InteropXGateway/ProcessDepositEvents.ts +243 -0
- package/src/tasks/InteropXGateway/SyncDepositEvents.ts +23 -13
- package/src/tasks/Transactions/SyncTransactionStatusTask.ts +65 -0
- package/src/tasks/index.ts +24 -2
- package/src/utils/index.ts +197 -7
- package/dist/index.js +0 -63
- package/dist/tasks/index.js +0 -27
- package/dist/utils/index.js +0 -101
package/dist/index.js
DELETED
@@ -1,63 +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
|
-
const module_alias_1 = __importDefault(require("module-alias"));
|
7
|
-
module_alias_1.default.addAliases({
|
8
|
-
"@/": __dirname + "/",
|
9
|
-
"@/logger": __dirname + "/logger",
|
10
|
-
"@/tasks": __dirname + "/tasks",
|
11
|
-
"@/utils": __dirname + "/utils",
|
12
|
-
"@/net": __dirname + "/net",
|
13
|
-
"@/db": __dirname + "/db",
|
14
|
-
"@/config": __dirname + "/config",
|
15
|
-
"@/types": __dirname + "/types",
|
16
|
-
"@/abi": __dirname + "/abi",
|
17
|
-
"@/constants": __dirname + "/constants",
|
18
|
-
"@/typechain": __dirname + "/typechain"
|
19
|
-
});
|
20
|
-
(0, module_alias_1.default)();
|
21
|
-
const assert_1 = __importDefault(require("assert"));
|
22
|
-
const dotenv_1 = __importDefault(require("dotenv"));
|
23
|
-
const ethers_1 = require("ethers");
|
24
|
-
dotenv_1.default.config();
|
25
|
-
const logger_1 = __importDefault(require("@/logger"));
|
26
|
-
const logger = new logger_1.default('Process');
|
27
|
-
if (process.argv.at(-1) === 'help') {
|
28
|
-
console.log('Usage:');
|
29
|
-
console.log(' PRIVATE_KEY=abcd1234 interop-x');
|
30
|
-
console.log(' PRIVATE_KEY=abcd1234 STAGING=true interop-x');
|
31
|
-
process.exit(0);
|
32
|
-
}
|
33
|
-
(0, assert_1.default)(process.env.PRIVATE_KEY, "PRIVATE_KEY is not defined");
|
34
|
-
try {
|
35
|
-
new ethers_1.ethers.Wallet(process.env.PRIVATE_KEY);
|
36
|
-
}
|
37
|
-
catch (e) {
|
38
|
-
logger.error('Invalid private key');
|
39
|
-
process.exit(1);
|
40
|
-
}
|
41
|
-
const tasks_1 = require("@/tasks");
|
42
|
-
const net_1 = require("@/net");
|
43
|
-
async function main() {
|
44
|
-
(0, net_1.startPeer)({});
|
45
|
-
const tasks = new tasks_1.Tasks();
|
46
|
-
tasks.start();
|
47
|
-
}
|
48
|
-
main()
|
49
|
-
.then(() => {
|
50
|
-
}).catch(err => {
|
51
|
-
console.error(err);
|
52
|
-
});
|
53
|
-
process.on('SIGINT', () => {
|
54
|
-
logger.debug('received SIGINT signal. exiting.');
|
55
|
-
process.exit(0);
|
56
|
-
});
|
57
|
-
process.on('SIGTERM', () => {
|
58
|
-
logger.debug('received SIGTERM signal. exiting.');
|
59
|
-
process.exit(0);
|
60
|
-
});
|
61
|
-
process.on('unhandledRejection', (reason, p) => {
|
62
|
-
logger.error('unhandled rejection: promise:', p, 'reason:', reason);
|
63
|
-
});
|
package/dist/tasks/index.js
DELETED
@@ -1,27 +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.Tasks = void 0;
|
7
|
-
const SyncDepositEvents_1 = __importDefault(require("./InteropXGateway/SyncDepositEvents"));
|
8
|
-
class Tasks {
|
9
|
-
constructor() {
|
10
|
-
this.tasks = [
|
11
|
-
new SyncDepositEvents_1.default({
|
12
|
-
chainId: 43114
|
13
|
-
})
|
14
|
-
];
|
15
|
-
}
|
16
|
-
async start() {
|
17
|
-
for (const task of this.tasks) {
|
18
|
-
try {
|
19
|
-
task.start();
|
20
|
-
}
|
21
|
-
catch (error) {
|
22
|
-
console.error(`Error starting task: ${task.constructor.name}`);
|
23
|
-
}
|
24
|
-
}
|
25
|
-
}
|
26
|
-
}
|
27
|
-
exports.Tasks = Tasks;
|
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;
|