@instadapp/interop-x 0.0.0-dev.8f86e9f → 0.0.0-dev.99c56eb
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/dist/package.json +8 -6
- package/dist/src/abi/index.js +2 -4
- package/dist/src/abi/interopXContract.json +391 -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 +3 -3
- package/dist/src/constants/index.js +0 -1
- package/dist/src/constants/tokens.js +31 -1
- package/dist/src/db/models/transaction.js +26 -10
- package/dist/src/gnosis/actions/index.js +9 -0
- package/dist/src/gnosis/actions/withdraw/index.js +55 -0
- package/dist/src/gnosis/index.js +20 -0
- package/dist/src/index.js +75 -24
- package/dist/src/net/peer/index.js +2 -1
- package/dist/src/net/pool/index.js +18 -2
- 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 +11 -3
- package/dist/src/tasks/InteropXContract/ProcessBridgeRequestEvents.js +152 -0
- package/dist/src/tasks/InteropXContract/SyncBridgeRequestEvents.js +77 -0
- package/dist/src/tasks/InteropXContract/SyncBridgeRequestSentEvents.js +89 -0
- package/dist/src/tasks/Transactions/SyncTransactionStatusTask.js +55 -0
- package/dist/src/tasks/index.js +15 -8
- package/dist/src/typechain/{InteropBridgeToken.js → InteropXContract.js} +0 -0
- package/dist/src/typechain/factories/InteropXContract__factory.js +526 -0
- package/dist/src/typechain/factories/index.js +3 -5
- package/dist/src/typechain/index.js +3 -5
- package/dist/src/utils/index.js +54 -46
- package/package.json +8 -6
- package/src/abi/index.ts +2 -4
- package/src/abi/interopXContract.json +391 -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 -3
- package/src/constants/index.ts +0 -1
- package/src/constants/tokens.ts +32 -2
- package/src/db/models/transaction.ts +64 -25
- package/src/gnosis/actions/index.ts +5 -0
- package/src/gnosis/actions/withdraw/index.ts +76 -0
- package/src/gnosis/index.ts +19 -0
- package/src/index.ts +96 -26
- package/src/net/peer/index.ts +2 -1
- package/src/net/pool/index.ts +25 -5
- 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 +13 -3
- package/src/tasks/InteropXContract/ProcessBridgeRequestEvents.ts +216 -0
- package/src/tasks/InteropXContract/SyncBridgeRequestEvents.ts +114 -0
- package/src/tasks/InteropXContract/SyncBridgeRequestSentEvents.ts +120 -0
- package/src/tasks/Transactions/SyncTransactionStatusTask.ts +67 -0
- package/src/tasks/index.ts +23 -9
- package/src/typechain/InteropXContract.ts +524 -0
- package/src/typechain/factories/InteropXContract__factory.ts +533 -0
- package/src/typechain/factories/index.ts +1 -2
- package/src/typechain/index.ts +2 -4
- package/src/utils/index.ts +95 -65
- 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 -158
- 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 -253
- 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
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.
|
|
6
|
+
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,62 +102,48 @@ const asyncCallWithTimeout = async (asyncPromise, timeout) => {
|
|
|
94
102
|
};
|
|
95
103
|
exports.asyncCallWithTimeout = asyncCallWithTimeout;
|
|
96
104
|
const generateInteropTransactionHash = (data) => {
|
|
97
|
-
return ethers_1.ethers.utils.solidityKeccak256(['string', 'string', 'string', 'string'], [
|
|
105
|
+
return ethers_1.ethers.utils.solidityKeccak256(['string', 'string', 'string', 'string', 'string'], [
|
|
98
106
|
String(data.action),
|
|
99
|
-
String(data.
|
|
107
|
+
String(data.bridger),
|
|
108
|
+
String(data.requestTransactionHash),
|
|
100
109
|
String(data.sourceChainId),
|
|
101
110
|
String(data.targetChainId),
|
|
102
111
|
]);
|
|
103
112
|
};
|
|
104
113
|
exports.generateInteropTransactionHash = generateInteropTransactionHash;
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
if (transaction.action != 'deposit') {
|
|
109
|
-
throw new Error('Invalid action');
|
|
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');
|
|
120
|
-
}
|
|
121
|
-
const itoken = constants_1.itokens[transaction.targetChainId].find(itoken => itoken.symbol.toLowerCase() === token.symbol.toLowerCase());
|
|
122
|
-
if (!itoken) {
|
|
123
|
-
throw Error('Cannot build data for transaction without itoken');
|
|
124
|
-
}
|
|
125
|
-
const targetChainProvider = new ethers_1.ethers.providers.JsonRpcProvider((0, exports.getRpcProviderUrl)(transaction.targetChainId));
|
|
126
|
-
const targetWallet = new ethers_1.ethers.Wallet(config_1.default.privateKey, targetChainProvider);
|
|
127
|
-
const interopBridgeContract = getContract(itoken.address, abi_1.default.interopBridgeToken, targetWallet);
|
|
128
|
-
const { data } = await interopBridgeContract.populateTransaction.mint(transaction.submitEvent.user, ethers_1.ethers.BigNumber.from(transaction.submitEvent.amount.toString()), ethers_1.ethers.BigNumber.from(transaction.submitEvent.sourceChainId.toString()), transaction.sourceTransactionHash);
|
|
129
|
-
transactions.push({
|
|
130
|
-
to: itoken.address,
|
|
131
|
-
data: data,
|
|
132
|
-
value: '0',
|
|
133
|
-
operation: ethers_multisend_1.OperationType.Call,
|
|
134
|
-
});
|
|
135
|
-
return (0, ethers_multisend_1.encodeMulti)(transactions).data;
|
|
136
|
-
};
|
|
137
|
-
exports.buildDataForTransaction = buildDataForTransaction;
|
|
114
|
+
class ContractError extends Error {
|
|
115
|
+
}
|
|
116
|
+
exports.ContractError = ContractError;
|
|
138
117
|
function getContract(address, contractInterface, signerOrProvider) {
|
|
139
118
|
if (!ethers_1.ethers.utils.getAddress(address) || address === ethers_1.ethers.constants.AddressZero) {
|
|
140
119
|
throw Error(`Invalid 'address' parameter '${address}'.`);
|
|
141
120
|
}
|
|
142
121
|
const contract = new ethers_1.ethers.Contract(address, contractInterface, signerOrProvider);
|
|
122
|
+
// Make sure the contract properties is writable
|
|
123
|
+
const desc = Object.getOwnPropertyDescriptor(contract, 'functions');
|
|
124
|
+
if (!desc || desc.writable !== true) {
|
|
125
|
+
return contract;
|
|
126
|
+
}
|
|
143
127
|
return new Proxy(contract, {
|
|
144
128
|
get(target, prop, receiver) {
|
|
145
129
|
const value = Reflect.get(target, prop, receiver);
|
|
146
130
|
if (typeof value === 'function' && (contract.functions.hasOwnProperty(prop) || ['queryFilter'].includes(String(prop)))) {
|
|
131
|
+
let isConstant = false;
|
|
132
|
+
try {
|
|
133
|
+
isConstant = contract.interface.getFunction(String(prop)).constant;
|
|
134
|
+
}
|
|
135
|
+
catch (error) {
|
|
136
|
+
}
|
|
147
137
|
return async (...args) => {
|
|
148
138
|
try {
|
|
149
|
-
return await value.bind(contract)(...args);
|
|
139
|
+
return await (0, async_retry_1.default)(async () => await value.bind(contract)(...args), { retries: isConstant ? 1 : 3 });
|
|
150
140
|
}
|
|
151
141
|
catch (error) {
|
|
152
|
-
|
|
142
|
+
const err = new ContractError(`Error calling "${String(prop)}" on "${address}": ${error.reason || error.message}`);
|
|
143
|
+
err.method = String(prop);
|
|
144
|
+
err.address = address;
|
|
145
|
+
err.args = [...args];
|
|
146
|
+
throw err;
|
|
153
147
|
}
|
|
154
148
|
};
|
|
155
149
|
}
|
|
@@ -161,10 +155,14 @@ function getContract(address, contractInterface, signerOrProvider) {
|
|
|
161
155
|
if (typeof value === 'function') {
|
|
162
156
|
return async (...args) => {
|
|
163
157
|
try {
|
|
164
|
-
return await value.bind(contract)(...args);
|
|
158
|
+
return await (0, async_retry_1.default)(async () => await value.bind(contract)(...args), { retries: parentProp === 'callStatic' ? 3 : 1 });
|
|
165
159
|
}
|
|
166
160
|
catch (error) {
|
|
167
|
-
|
|
161
|
+
const err = new ContractError(`Error calling "${String(prop)}" using "${parentProp}" on "${address}": ${error.reason || error.message}`);
|
|
162
|
+
err.method = String(prop);
|
|
163
|
+
err.address = address;
|
|
164
|
+
err.args = [...args];
|
|
165
|
+
throw err;
|
|
168
166
|
}
|
|
169
167
|
};
|
|
170
168
|
}
|
|
@@ -176,3 +174,13 @@ function getContract(address, contractInterface, signerOrProvider) {
|
|
|
176
174
|
});
|
|
177
175
|
}
|
|
178
176
|
exports.getContract = getContract;
|
|
177
|
+
const generateGnosisTransaction = async (transactionData, safeContract) => {
|
|
178
|
+
console.log(transactionData);
|
|
179
|
+
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));
|
|
180
|
+
while (isExecuted == 1) {
|
|
181
|
+
transactionData.safeTxGas = ethers_1.ethers.BigNumber.from(String(transactionData.safeTxGas)).add(1).toString();
|
|
182
|
+
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));
|
|
183
|
+
}
|
|
184
|
+
return transactionData;
|
|
185
|
+
};
|
|
186
|
+
exports.generateGnosisTransaction = generateGnosisTransaction;
|
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.99c56eb",
|
|
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
|
},
|
|
@@ -24,9 +24,11 @@
|
|
|
24
24
|
},
|
|
25
25
|
"dependencies": {
|
|
26
26
|
"@achingbrain/libp2p-gossipsub": "^0.12.2",
|
|
27
|
+
"@fastify/cors": "^7.0.0",
|
|
28
|
+
"async-retry": "^1.3.3",
|
|
29
|
+
"await-spawn": "^4.0.2",
|
|
27
30
|
"axios": "^0.27.1",
|
|
28
31
|
"axios-retry": "^3.2.4",
|
|
29
|
-
"bignumber.js": "^9.0.2",
|
|
30
32
|
"chalk": "4.1.2",
|
|
31
33
|
"dotenv": "^16.0.0",
|
|
32
34
|
"ethereumjs-util": "^7.1.4",
|
|
@@ -34,7 +36,7 @@
|
|
|
34
36
|
"ethers-multisend": "^2.1.1",
|
|
35
37
|
"expand-home-dir": "^0.0.3",
|
|
36
38
|
"fastify": "^3.28.0",
|
|
37
|
-
"
|
|
39
|
+
"fs-extra": "^10.1.0",
|
|
38
40
|
"libp2p": "^0.36.2",
|
|
39
41
|
"libp2p-bootstrap": "^0.14.0",
|
|
40
42
|
"libp2p-kad-dht": "^0.28.6",
|
|
@@ -46,6 +48,8 @@
|
|
|
46
48
|
"libp2p-websockets": "^0.16.2",
|
|
47
49
|
"luxon": "^2.3.2",
|
|
48
50
|
"module-alias": "^2.2.2",
|
|
51
|
+
"patch-package": "^6.4.7",
|
|
52
|
+
"postinstall-postinstall": "^2.1.0",
|
|
49
53
|
"sequelize": "6.18.0",
|
|
50
54
|
"sqlite3": "^5.0.5",
|
|
51
55
|
"waait": "^1.0.5"
|
|
@@ -60,8 +64,6 @@
|
|
|
60
64
|
"@types/fs-extra": "^9.0.13",
|
|
61
65
|
"@types/node": "^17.0.17",
|
|
62
66
|
"nodemon": "^2.0.15",
|
|
63
|
-
"patch-package": "^6.4.7",
|
|
64
|
-
"postinstall-postinstall": "^2.1.0",
|
|
65
67
|
"replace-in-file": "^6.3.2",
|
|
66
68
|
"rimraf": "^3.0.2",
|
|
67
69
|
"ts-node": "^10.5.0",
|
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 interopXContract from "./interopXContract.json";
|
|
5
4
|
|
|
6
5
|
export default {
|
|
7
6
|
gnosisSafe,
|
|
8
7
|
erc20,
|
|
9
|
-
|
|
10
|
-
interopBridgeToken,
|
|
8
|
+
interopXContract,
|
|
11
9
|
}
|
|
@@ -0,0 +1,391 @@
|
|
|
1
|
+
[
|
|
2
|
+
{
|
|
3
|
+
"anonymous": false,
|
|
4
|
+
"inputs": [
|
|
5
|
+
{
|
|
6
|
+
"indexed": true,
|
|
7
|
+
"internalType": "address",
|
|
8
|
+
"name": "bridger",
|
|
9
|
+
"type": "address"
|
|
10
|
+
},
|
|
11
|
+
{
|
|
12
|
+
"components": [
|
|
13
|
+
{
|
|
14
|
+
"components": [
|
|
15
|
+
{
|
|
16
|
+
"internalType": "address",
|
|
17
|
+
"name": "sourceToken",
|
|
18
|
+
"type": "address"
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
"internalType": "address",
|
|
22
|
+
"name": "targetToken",
|
|
23
|
+
"type": "address"
|
|
24
|
+
},
|
|
25
|
+
{ "internalType": "uint256", "name": "amount", "type": "uint256" }
|
|
26
|
+
],
|
|
27
|
+
"internalType": "struct InteropXContractBeta.TokenInfo[]",
|
|
28
|
+
"name": "supply",
|
|
29
|
+
"type": "tuple[]"
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
"components": [
|
|
33
|
+
{
|
|
34
|
+
"internalType": "address",
|
|
35
|
+
"name": "sourceToken",
|
|
36
|
+
"type": "address"
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
"internalType": "address",
|
|
40
|
+
"name": "targetToken",
|
|
41
|
+
"type": "address"
|
|
42
|
+
},
|
|
43
|
+
{ "internalType": "uint256", "name": "amount", "type": "uint256" }
|
|
44
|
+
],
|
|
45
|
+
"internalType": "struct InteropXContractBeta.TokenInfo[]",
|
|
46
|
+
"name": "withdraw",
|
|
47
|
+
"type": "tuple[]"
|
|
48
|
+
}
|
|
49
|
+
],
|
|
50
|
+
"indexed": false,
|
|
51
|
+
"internalType": "struct InteropXContractBeta.Position",
|
|
52
|
+
"name": "position",
|
|
53
|
+
"type": "tuple"
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
"indexed": true,
|
|
57
|
+
"internalType": "uint32",
|
|
58
|
+
"name": "sourceChainId",
|
|
59
|
+
"type": "uint32"
|
|
60
|
+
},
|
|
61
|
+
{
|
|
62
|
+
"indexed": false,
|
|
63
|
+
"internalType": "uint32",
|
|
64
|
+
"name": "targetChainId",
|
|
65
|
+
"type": "uint32"
|
|
66
|
+
},
|
|
67
|
+
{
|
|
68
|
+
"indexed": true,
|
|
69
|
+
"internalType": "bytes32",
|
|
70
|
+
"name": "requestTransactionHash",
|
|
71
|
+
"type": "bytes32"
|
|
72
|
+
},
|
|
73
|
+
{
|
|
74
|
+
"indexed": false,
|
|
75
|
+
"internalType": "bytes",
|
|
76
|
+
"name": "metadata",
|
|
77
|
+
"type": "bytes"
|
|
78
|
+
}
|
|
79
|
+
],
|
|
80
|
+
"name": "LogBridgeCommitted",
|
|
81
|
+
"type": "event"
|
|
82
|
+
},
|
|
83
|
+
{
|
|
84
|
+
"anonymous": false,
|
|
85
|
+
"inputs": [
|
|
86
|
+
{
|
|
87
|
+
"indexed": true,
|
|
88
|
+
"internalType": "address",
|
|
89
|
+
"name": "bridger",
|
|
90
|
+
"type": "address"
|
|
91
|
+
},
|
|
92
|
+
{
|
|
93
|
+
"components": [
|
|
94
|
+
{
|
|
95
|
+
"components": [
|
|
96
|
+
{
|
|
97
|
+
"internalType": "address",
|
|
98
|
+
"name": "sourceToken",
|
|
99
|
+
"type": "address"
|
|
100
|
+
},
|
|
101
|
+
{
|
|
102
|
+
"internalType": "address",
|
|
103
|
+
"name": "targetToken",
|
|
104
|
+
"type": "address"
|
|
105
|
+
},
|
|
106
|
+
{ "internalType": "uint256", "name": "amount", "type": "uint256" }
|
|
107
|
+
],
|
|
108
|
+
"internalType": "struct InteropXContractBeta.TokenInfo[]",
|
|
109
|
+
"name": "supply",
|
|
110
|
+
"type": "tuple[]"
|
|
111
|
+
},
|
|
112
|
+
{
|
|
113
|
+
"components": [
|
|
114
|
+
{
|
|
115
|
+
"internalType": "address",
|
|
116
|
+
"name": "sourceToken",
|
|
117
|
+
"type": "address"
|
|
118
|
+
},
|
|
119
|
+
{
|
|
120
|
+
"internalType": "address",
|
|
121
|
+
"name": "targetToken",
|
|
122
|
+
"type": "address"
|
|
123
|
+
},
|
|
124
|
+
{ "internalType": "uint256", "name": "amount", "type": "uint256" }
|
|
125
|
+
],
|
|
126
|
+
"internalType": "struct InteropXContractBeta.TokenInfo[]",
|
|
127
|
+
"name": "withdraw",
|
|
128
|
+
"type": "tuple[]"
|
|
129
|
+
}
|
|
130
|
+
],
|
|
131
|
+
"indexed": false,
|
|
132
|
+
"internalType": "struct InteropXContractBeta.Position",
|
|
133
|
+
"name": "position",
|
|
134
|
+
"type": "tuple"
|
|
135
|
+
},
|
|
136
|
+
{
|
|
137
|
+
"indexed": false,
|
|
138
|
+
"internalType": "uint256",
|
|
139
|
+
"name": "sourceChainId",
|
|
140
|
+
"type": "uint256"
|
|
141
|
+
},
|
|
142
|
+
{
|
|
143
|
+
"indexed": true,
|
|
144
|
+
"internalType": "uint256",
|
|
145
|
+
"name": "targetChainId",
|
|
146
|
+
"type": "uint256"
|
|
147
|
+
},
|
|
148
|
+
{
|
|
149
|
+
"indexed": true,
|
|
150
|
+
"internalType": "bytes32",
|
|
151
|
+
"name": "requestTransactionHash",
|
|
152
|
+
"type": "bytes32"
|
|
153
|
+
},
|
|
154
|
+
{
|
|
155
|
+
"indexed": false,
|
|
156
|
+
"internalType": "bytes32",
|
|
157
|
+
"name": "targetCommittedTransactionHash",
|
|
158
|
+
"type": "bytes32"
|
|
159
|
+
},
|
|
160
|
+
{
|
|
161
|
+
"indexed": false,
|
|
162
|
+
"internalType": "bytes",
|
|
163
|
+
"name": "metadata",
|
|
164
|
+
"type": "bytes"
|
|
165
|
+
}
|
|
166
|
+
],
|
|
167
|
+
"name": "LogBridgeCompleted",
|
|
168
|
+
"type": "event"
|
|
169
|
+
},
|
|
170
|
+
{
|
|
171
|
+
"anonymous": false,
|
|
172
|
+
"inputs": [
|
|
173
|
+
{
|
|
174
|
+
"indexed": true,
|
|
175
|
+
"internalType": "address",
|
|
176
|
+
"name": "bridger",
|
|
177
|
+
"type": "address"
|
|
178
|
+
},
|
|
179
|
+
{
|
|
180
|
+
"components": [
|
|
181
|
+
{
|
|
182
|
+
"components": [
|
|
183
|
+
{
|
|
184
|
+
"internalType": "address",
|
|
185
|
+
"name": "sourceToken",
|
|
186
|
+
"type": "address"
|
|
187
|
+
},
|
|
188
|
+
{
|
|
189
|
+
"internalType": "address",
|
|
190
|
+
"name": "targetToken",
|
|
191
|
+
"type": "address"
|
|
192
|
+
},
|
|
193
|
+
{ "internalType": "uint256", "name": "amount", "type": "uint256" }
|
|
194
|
+
],
|
|
195
|
+
"internalType": "struct InteropXContractBeta.TokenInfo[]",
|
|
196
|
+
"name": "supply",
|
|
197
|
+
"type": "tuple[]"
|
|
198
|
+
},
|
|
199
|
+
{
|
|
200
|
+
"components": [
|
|
201
|
+
{
|
|
202
|
+
"internalType": "address",
|
|
203
|
+
"name": "sourceToken",
|
|
204
|
+
"type": "address"
|
|
205
|
+
},
|
|
206
|
+
{
|
|
207
|
+
"internalType": "address",
|
|
208
|
+
"name": "targetToken",
|
|
209
|
+
"type": "address"
|
|
210
|
+
},
|
|
211
|
+
{ "internalType": "uint256", "name": "amount", "type": "uint256" }
|
|
212
|
+
],
|
|
213
|
+
"internalType": "struct InteropXContractBeta.TokenInfo[]",
|
|
214
|
+
"name": "withdraw",
|
|
215
|
+
"type": "tuple[]"
|
|
216
|
+
}
|
|
217
|
+
],
|
|
218
|
+
"indexed": false,
|
|
219
|
+
"internalType": "struct InteropXContractBeta.Position",
|
|
220
|
+
"name": "position",
|
|
221
|
+
"type": "tuple"
|
|
222
|
+
},
|
|
223
|
+
{
|
|
224
|
+
"indexed": false,
|
|
225
|
+
"internalType": "uint256",
|
|
226
|
+
"name": "sourceChainId",
|
|
227
|
+
"type": "uint256"
|
|
228
|
+
},
|
|
229
|
+
{
|
|
230
|
+
"indexed": true,
|
|
231
|
+
"internalType": "uint256",
|
|
232
|
+
"name": "targetChainId",
|
|
233
|
+
"type": "uint256"
|
|
234
|
+
},
|
|
235
|
+
{
|
|
236
|
+
"indexed": false,
|
|
237
|
+
"internalType": "bytes",
|
|
238
|
+
"name": "metadata",
|
|
239
|
+
"type": "bytes"
|
|
240
|
+
}
|
|
241
|
+
],
|
|
242
|
+
"name": "LogBridgeRequest",
|
|
243
|
+
"type": "event"
|
|
244
|
+
},
|
|
245
|
+
{
|
|
246
|
+
"anonymous": false,
|
|
247
|
+
"inputs": [
|
|
248
|
+
{
|
|
249
|
+
"indexed": true,
|
|
250
|
+
"internalType": "address",
|
|
251
|
+
"name": "bridger",
|
|
252
|
+
"type": "address"
|
|
253
|
+
},
|
|
254
|
+
{
|
|
255
|
+
"components": [
|
|
256
|
+
{
|
|
257
|
+
"components": [
|
|
258
|
+
{
|
|
259
|
+
"internalType": "address",
|
|
260
|
+
"name": "sourceToken",
|
|
261
|
+
"type": "address"
|
|
262
|
+
},
|
|
263
|
+
{
|
|
264
|
+
"internalType": "address",
|
|
265
|
+
"name": "targetToken",
|
|
266
|
+
"type": "address"
|
|
267
|
+
},
|
|
268
|
+
{ "internalType": "uint256", "name": "amount", "type": "uint256" }
|
|
269
|
+
],
|
|
270
|
+
"internalType": "struct InteropXContractBeta.TokenInfo[]",
|
|
271
|
+
"name": "supply",
|
|
272
|
+
"type": "tuple[]"
|
|
273
|
+
},
|
|
274
|
+
{
|
|
275
|
+
"components": [
|
|
276
|
+
{
|
|
277
|
+
"internalType": "address",
|
|
278
|
+
"name": "sourceToken",
|
|
279
|
+
"type": "address"
|
|
280
|
+
},
|
|
281
|
+
{
|
|
282
|
+
"internalType": "address",
|
|
283
|
+
"name": "targetToken",
|
|
284
|
+
"type": "address"
|
|
285
|
+
},
|
|
286
|
+
{ "internalType": "uint256", "name": "amount", "type": "uint256" }
|
|
287
|
+
],
|
|
288
|
+
"internalType": "struct InteropXContractBeta.TokenInfo[]",
|
|
289
|
+
"name": "withdraw",
|
|
290
|
+
"type": "tuple[]"
|
|
291
|
+
}
|
|
292
|
+
],
|
|
293
|
+
"indexed": false,
|
|
294
|
+
"internalType": "struct InteropXContractBeta.Position",
|
|
295
|
+
"name": "position",
|
|
296
|
+
"type": "tuple"
|
|
297
|
+
},
|
|
298
|
+
{
|
|
299
|
+
"indexed": false,
|
|
300
|
+
"internalType": "uint32",
|
|
301
|
+
"name": "sourceChainId",
|
|
302
|
+
"type": "uint32"
|
|
303
|
+
},
|
|
304
|
+
{
|
|
305
|
+
"indexed": true,
|
|
306
|
+
"internalType": "uint32",
|
|
307
|
+
"name": "targetChainId",
|
|
308
|
+
"type": "uint32"
|
|
309
|
+
},
|
|
310
|
+
{
|
|
311
|
+
"indexed": true,
|
|
312
|
+
"internalType": "bytes32",
|
|
313
|
+
"name": "requestTransactionHash",
|
|
314
|
+
"type": "bytes32"
|
|
315
|
+
},
|
|
316
|
+
{
|
|
317
|
+
"indexed": false,
|
|
318
|
+
"internalType": "bytes",
|
|
319
|
+
"name": "metadata",
|
|
320
|
+
"type": "bytes"
|
|
321
|
+
}
|
|
322
|
+
],
|
|
323
|
+
"name": "LogBridgeRequestSent",
|
|
324
|
+
"type": "event"
|
|
325
|
+
},
|
|
326
|
+
{
|
|
327
|
+
"inputs": [],
|
|
328
|
+
"name": "_vnonce",
|
|
329
|
+
"outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }],
|
|
330
|
+
"stateMutability": "view",
|
|
331
|
+
"type": "function"
|
|
332
|
+
},
|
|
333
|
+
{
|
|
334
|
+
"inputs": [
|
|
335
|
+
{ "internalType": "address", "name": "to_", "type": "address" },
|
|
336
|
+
{ "internalType": "address", "name": "sourceToken_", "type": "address" },
|
|
337
|
+
{ "internalType": "address", "name": "targetToken_", "type": "address" },
|
|
338
|
+
{ "internalType": "uint256", "name": "amount_", "type": "uint256" },
|
|
339
|
+
{ "internalType": "uint32", "name": "targetChainId_", "type": "uint32" },
|
|
340
|
+
{
|
|
341
|
+
"internalType": "bytes32",
|
|
342
|
+
"name": "transactionHash_",
|
|
343
|
+
"type": "bytes32"
|
|
344
|
+
},
|
|
345
|
+
{ "internalType": "bytes", "name": "metadata_", "type": "bytes" }
|
|
346
|
+
],
|
|
347
|
+
"name": "completeBridge",
|
|
348
|
+
"outputs": [],
|
|
349
|
+
"stateMutability": "nonpayable",
|
|
350
|
+
"type": "function"
|
|
351
|
+
},
|
|
352
|
+
{
|
|
353
|
+
"inputs": [
|
|
354
|
+
{ "internalType": "address", "name": "sourceToken_", "type": "address" },
|
|
355
|
+
{ "internalType": "address", "name": "targetToken_", "type": "address" },
|
|
356
|
+
{ "internalType": "uint256", "name": "amount_", "type": "uint256" },
|
|
357
|
+
{ "internalType": "uint32", "name": "targetChainId_", "type": "uint32" },
|
|
358
|
+
{ "internalType": "bytes", "name": "metadata_", "type": "bytes" }
|
|
359
|
+
],
|
|
360
|
+
"name": "requestWithdraw",
|
|
361
|
+
"outputs": [],
|
|
362
|
+
"stateMutability": "nonpayable",
|
|
363
|
+
"type": "function"
|
|
364
|
+
},
|
|
365
|
+
{
|
|
366
|
+
"inputs": [{ "internalType": "address", "name": "", "type": "address" }],
|
|
367
|
+
"name": "whitelistedMapping",
|
|
368
|
+
"outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }],
|
|
369
|
+
"stateMutability": "view",
|
|
370
|
+
"type": "function"
|
|
371
|
+
},
|
|
372
|
+
{
|
|
373
|
+
"inputs": [
|
|
374
|
+
{ "internalType": "address", "name": "user_", "type": "address" },
|
|
375
|
+
{ "internalType": "address", "name": "sourceToken_", "type": "address" },
|
|
376
|
+
{ "internalType": "address", "name": "targetToken_", "type": "address" },
|
|
377
|
+
{ "internalType": "uint256", "name": "amount_", "type": "uint256" },
|
|
378
|
+
{ "internalType": "uint32", "name": "chainId_", "type": "uint32" },
|
|
379
|
+
{
|
|
380
|
+
"internalType": "bytes32",
|
|
381
|
+
"name": "transactionHash_",
|
|
382
|
+
"type": "bytes32"
|
|
383
|
+
},
|
|
384
|
+
{ "internalType": "bytes", "name": "metadata_", "type": "bytes" }
|
|
385
|
+
],
|
|
386
|
+
"name": "withdrawRequested",
|
|
387
|
+
"outputs": [],
|
|
388
|
+
"stateMutability": "nonpayable",
|
|
389
|
+
"type": "function"
|
|
390
|
+
}
|
|
391
|
+
]
|
package/src/alias.ts
ADDED
package/src/api/index.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import fastify from "fastify"
|
|
2
|
-
import cors from 'fastify
|
|
2
|
+
import cors from '@fastify/cors'
|
|
3
3
|
import Logger from "@/logger"
|
|
4
4
|
import { Transaction } from "@/db";
|
|
5
5
|
|
|
@@ -20,6 +20,9 @@ export const startApiServer = async () => {
|
|
|
20
20
|
return await Transaction.findAndCountAll({
|
|
21
21
|
limit: 20,
|
|
22
22
|
offset: 0,
|
|
23
|
+
order: [
|
|
24
|
+
['createdAt', 'DESC']
|
|
25
|
+
]
|
|
23
26
|
})
|
|
24
27
|
})
|
|
25
28
|
|
|
@@ -27,7 +30,7 @@ export const startApiServer = async () => {
|
|
|
27
30
|
|
|
28
31
|
logger.log(`RPC Server listening at http://${HOST}:${PORT}`)
|
|
29
32
|
} catch (err) {
|
|
30
|
-
logger.error(err)
|
|
33
|
+
logger.error(err.message)
|
|
31
34
|
process.exit(1)
|
|
32
35
|
}
|
|
33
36
|
}
|