@instadapp/interop-x 0.0.0-dev.b660e0a → 0.0.0-dev.b8c571d
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/package.json +3 -3
- package/dist/src/index.js +4 -29
- package/dist/src/net/pool/index.js +0 -8
- package/dist/src/net/protocol/index.js +1 -30
- package/dist/src/tasks/InteropBridge/ProcessWithdrawEvents.js +0 -2
- package/dist/src/tasks/InteropXGateway/ProcessDepositEvents.js +0 -3
- package/dist/src/utils/index.js +1 -6
- package/package.json +3 -3
- package/src/index.ts +5 -37
- package/src/net/pool/index.ts +3 -15
- package/src/net/protocol/index.ts +1 -45
- package/src/tasks/InteropBridge/ProcessWithdrawEvents.ts +0 -2
- package/src/tasks/InteropXGateway/ProcessDepositEvents.ts +0 -4
- package/src/utils/index.ts +1 -7
package/dist/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.b8c571d",
|
4
4
|
"license": "MIT",
|
5
5
|
"main": "dist/index.js",
|
6
6
|
"engines": {
|
@@ -46,8 +46,6 @@
|
|
46
46
|
"libp2p-websockets": "^0.16.2",
|
47
47
|
"luxon": "^2.3.2",
|
48
48
|
"module-alias": "^2.2.2",
|
49
|
-
"patch-package": "^6.4.7",
|
50
|
-
"postinstall-postinstall": "^2.1.0",
|
51
49
|
"sequelize": "6.18.0",
|
52
50
|
"sqlite3": "^5.0.5",
|
53
51
|
"waait": "^1.0.5"
|
@@ -62,6 +60,8 @@
|
|
62
60
|
"@types/fs-extra": "^9.0.13",
|
63
61
|
"@types/node": "^17.0.17",
|
64
62
|
"nodemon": "^2.0.15",
|
63
|
+
"patch-package": "^6.4.7",
|
64
|
+
"postinstall-postinstall": "^2.1.0",
|
65
65
|
"replace-in-file": "^6.3.2",
|
66
66
|
"rimraf": "^3.0.2",
|
67
67
|
"ts-node": "^10.5.0",
|
package/dist/src/index.js
CHANGED
@@ -19,27 +19,20 @@ module_alias_1.default.addAliases({
|
|
19
19
|
"@/typechain": __dirname + "/typechain"
|
20
20
|
});
|
21
21
|
(0, module_alias_1.default)();
|
22
|
+
const assert_1 = __importDefault(require("assert"));
|
22
23
|
const dotenv_1 = __importDefault(require("dotenv"));
|
23
24
|
const ethers_1 = require("ethers");
|
24
25
|
const package_json_1 = __importDefault(require("../package.json"));
|
25
26
|
dotenv_1.default.config();
|
26
27
|
const logger_1 = __importDefault(require("@/logger"));
|
27
28
|
const logger = new logger_1.default('Process');
|
28
|
-
|
29
|
+
if (process.argv.at(-1) === 'help') {
|
29
30
|
console.log('Usage:');
|
30
31
|
console.log(' PRIVATE_KEY=abcd1234 interop-x');
|
31
32
|
console.log(' PRIVATE_KEY=abcd1234 STAGING=true interop-x');
|
32
|
-
console.log(' PRIVATE_KEY=abcd1234 API_HOST=0.0.0.0 API_PORT=8080 interop-x');
|
33
|
-
};
|
34
|
-
if (process.argv.at(-1) === 'help') {
|
35
|
-
printUsage();
|
36
33
|
process.exit(0);
|
37
34
|
}
|
38
|
-
|
39
|
-
console.error('Please provide a private key\n\n');
|
40
|
-
printUsage();
|
41
|
-
process.exit(1);
|
42
|
-
}
|
35
|
+
(0, assert_1.default)(process.env.PRIVATE_KEY, "PRIVATE_KEY is not defined");
|
43
36
|
try {
|
44
37
|
new ethers_1.ethers.Wallet(process.env.PRIVATE_KEY);
|
45
38
|
}
|
@@ -47,33 +40,15 @@ catch (e) {
|
|
47
40
|
logger.error('Invalid private key');
|
48
41
|
process.exit(1);
|
49
42
|
}
|
50
|
-
logger.debug(`Starting Interop X Node (v${package_json_1.default.version} - rev.
|
43
|
+
logger.debug(`Starting Interop X Node (v${package_json_1.default.version} - rev.b8c571d)`);
|
51
44
|
const tasks_1 = require("@/tasks");
|
52
45
|
const net_1 = require("@/net");
|
53
46
|
const api_1 = require("@/api");
|
54
|
-
const db_1 = require("./db");
|
55
47
|
async function main() {
|
56
48
|
(0, net_1.startPeer)({});
|
57
49
|
const tasks = new tasks_1.Tasks();
|
58
50
|
tasks.start();
|
59
51
|
(0, api_1.startApiServer)();
|
60
|
-
net_1.protocol.on('TransactionStatus', async (payload) => {
|
61
|
-
if (!net_1.peerPool.isLeadNode(payload.peerId)) {
|
62
|
-
return;
|
63
|
-
}
|
64
|
-
const transaction = await db_1.Transaction.findOne({ where: { transactionHash: payload.data.transactionHash } });
|
65
|
-
if (!transaction) {
|
66
|
-
return;
|
67
|
-
}
|
68
|
-
transaction.sourceStatus = payload.data.sourceStatus;
|
69
|
-
transaction.sourceTransactionHash = payload.data.sourceTransactionHash;
|
70
|
-
transaction.sourceErrors = payload.data.sourceErrors;
|
71
|
-
transaction.targetStatus = payload.data.targetStatus;
|
72
|
-
transaction.targetTransactionHash = payload.data.targetTransactionHash;
|
73
|
-
transaction.targetErrors = payload.data.targetErrors;
|
74
|
-
transaction.status = payload.data.status;
|
75
|
-
await transaction.save();
|
76
|
-
});
|
77
52
|
}
|
78
53
|
main()
|
79
54
|
.then(() => {
|
@@ -7,7 +7,6 @@ exports.peerPool = exports.PeerPool = void 0;
|
|
7
7
|
const types_1 = require("@/types");
|
8
8
|
const config_1 = __importDefault(require("@/config"));
|
9
9
|
const logger_1 = __importDefault(require("@/logger"));
|
10
|
-
const utils_1 = require("ethers/lib/utils");
|
11
10
|
const logger = new logger_1.default('PeerPool');
|
12
11
|
class PeerPool {
|
13
12
|
constructor() {
|
@@ -101,13 +100,6 @@ class PeerPool {
|
|
101
100
|
get activePeerIds() {
|
102
101
|
return this.activePeers.map((p) => p.id);
|
103
102
|
}
|
104
|
-
isLeadNode(id) {
|
105
|
-
const peer = this.pool.get(id);
|
106
|
-
if (!peer) {
|
107
|
-
return false;
|
108
|
-
}
|
109
|
-
return (0, utils_1.getAddress)(peer.publicAddress) === (0, utils_1.getAddress)(config_1.default.leadNodeAddress);
|
110
|
-
}
|
111
103
|
cleanup() {
|
112
104
|
// let compDate = Date.now() - this.PEERS_CLEANUP_TIME_LIMIT * 60
|
113
105
|
// this.peers.forEach((peerInfo) => {
|
@@ -16,7 +16,7 @@ class Protocol extends stream_1.EventEmitter {
|
|
16
16
|
this.protocolMessages = [
|
17
17
|
{
|
18
18
|
name: 'PeerInfo',
|
19
|
-
code:
|
19
|
+
code: 0x09,
|
20
20
|
encode: (info) => [
|
21
21
|
Buffer.from(info.publicAddress),
|
22
22
|
],
|
@@ -24,30 +24,6 @@ class Protocol extends stream_1.EventEmitter {
|
|
24
24
|
publicAddress: publicAddress.toString(),
|
25
25
|
}),
|
26
26
|
},
|
27
|
-
{
|
28
|
-
name: 'TransactionStatus',
|
29
|
-
code: 0x02,
|
30
|
-
encode: (transaction) => [
|
31
|
-
Buffer.from(transaction.transactionHash),
|
32
|
-
Buffer.from(transaction.sourceStatus),
|
33
|
-
Buffer.from(transaction.sourceTransactionHash),
|
34
|
-
transaction.sourceErrors ? transaction.sourceErrors.map((e) => Buffer.from(e)) : [],
|
35
|
-
Buffer.from(transaction.targetStatus),
|
36
|
-
Buffer.from(transaction.targetTransactionHash),
|
37
|
-
transaction.targetErrors ? transaction.targetErrors.map((e) => Buffer.from(e)) : [],
|
38
|
-
Buffer.from(transaction.status),
|
39
|
-
],
|
40
|
-
decode: ([transactionHash, sourceStatus, sourceTransactionHash, sourceErrors, targetStatus, targetTransactionHash, targetErrors, status]) => ({
|
41
|
-
transactionHash: transactionHash.toString(),
|
42
|
-
sourceStatus: sourceStatus.toString(),
|
43
|
-
sourceTransactionHash: sourceTransactionHash.toString(),
|
44
|
-
sourceErrors: sourceErrors.map((e) => e.toString()),
|
45
|
-
targetStatus: targetStatus.toString(),
|
46
|
-
targetTransactionHash: targetTransactionHash.toString(),
|
47
|
-
targetErrors: targetErrors.map((e) => e.toString()),
|
48
|
-
status: status.toString(),
|
49
|
-
}),
|
50
|
-
},
|
51
27
|
];
|
52
28
|
}
|
53
29
|
start({ libp2p, topic = null, }) {
|
@@ -99,11 +75,6 @@ class Protocol extends stream_1.EventEmitter {
|
|
99
75
|
const encoded = ethereumjs_util_1.rlp.encode([message.code, message.encode(data)]);
|
100
76
|
this.libp2p.pubsub.publish(this.topic, encoded);
|
101
77
|
}
|
102
|
-
sendTransaction(transaction) {
|
103
|
-
const message = this.protocolMessages.find((m) => m.name === 'TransactionStatus');
|
104
|
-
const encoded = ethereumjs_util_1.rlp.encode([message.code, message.encode(transaction)]);
|
105
|
-
this.libp2p.pubsub.publish(this.topic, encoded);
|
106
|
-
}
|
107
78
|
async requestSignatures(data, peerIds) {
|
108
79
|
try {
|
109
80
|
peerIds = peerIds || __1.peerPool.activePeerIds;
|
@@ -126,14 +126,12 @@ class ProcessWithdrawEvents extends BaseTask_1.BaseTask {
|
|
126
126
|
if (parsedLogs.find(e => e.name === 'ExecutionSuccess')) {
|
127
127
|
console.log('ExecutionSuccess');
|
128
128
|
transaction.targetStatus = 'success';
|
129
|
-
transaction.targetTransactionHash = txSent.hash;
|
130
129
|
transaction.status = 'success';
|
131
130
|
await transaction.save();
|
132
131
|
}
|
133
132
|
else {
|
134
133
|
console.log('ExecutionFailure');
|
135
134
|
transaction.targetStatus = 'failed';
|
136
|
-
transaction.targetTransactionHash = txSent.hash;
|
137
135
|
transaction.status = 'failed';
|
138
136
|
await transaction.save();
|
139
137
|
}
|
@@ -126,18 +126,15 @@ class ProcessDepositEvents extends BaseTask_1.BaseTask {
|
|
126
126
|
if (parsedLogs.find(e => e.name === 'ExecutionSuccess')) {
|
127
127
|
console.log('ExecutionSuccess');
|
128
128
|
transaction.targetStatus = 'success';
|
129
|
-
transaction.targetTransactionHash = txSent.hash;
|
130
129
|
transaction.status = 'success';
|
131
130
|
await transaction.save();
|
132
131
|
}
|
133
132
|
else {
|
134
133
|
console.log('ExecutionFailure');
|
135
134
|
transaction.targetStatus = 'failed';
|
136
|
-
transaction.targetTransactionHash = txSent.hash;
|
137
135
|
transaction.status = 'failed';
|
138
136
|
await transaction.save();
|
139
137
|
}
|
140
|
-
net_1.protocol.sendTransaction(transaction);
|
141
138
|
}
|
142
139
|
async start() {
|
143
140
|
this.logger.info(`Starting execution watcher on interop chain`);
|
package/dist/src/utils/index.js
CHANGED
@@ -170,7 +170,7 @@ const buildWithdrawDataForTransaction = async (transaction, type) => {
|
|
170
170
|
const targetWallet = new ethers_1.ethers.Wallet(config_1.default.privateKey, targetChainProvider);
|
171
171
|
const gatewayAddress = constants_1.addresses[chainId].interopXGateway;
|
172
172
|
const interopBridgeContract = getContract(gatewayAddress, abi_1.default.interopXGateway, targetWallet);
|
173
|
-
const { data } = await interopBridgeContract.populateTransaction.systemWithdraw(ethers_1.ethers.BigNumber.from(amount.toString()), to, token.address, ethers_1.ethers.BigNumber.from(transaction.sourceChainId.toString()), transaction.submitTransactionHash);
|
173
|
+
const { data } = await interopBridgeContract.populateTransaction.systemWithdraw(ethers_1.ethers.BigNumber.from(amount.toString()), to, token.address, ethers_1.ethers.BigNumber.from(transaction.submitEvent.sourceChainId.toString()), transaction.submitTransactionHash);
|
174
174
|
transactions.push({
|
175
175
|
to: gatewayAddress,
|
176
176
|
data: data,
|
@@ -185,11 +185,6 @@ function getContract(address, contractInterface, signerOrProvider) {
|
|
185
185
|
throw Error(`Invalid 'address' parameter '${address}'.`);
|
186
186
|
}
|
187
187
|
const contract = new ethers_1.ethers.Contract(address, contractInterface, signerOrProvider);
|
188
|
-
// Make sure the contract properties is writable
|
189
|
-
const desc = Object.getOwnPropertyDescriptor(contract, 'functions');
|
190
|
-
if (!desc || desc.writable !== true) {
|
191
|
-
return contract;
|
192
|
-
}
|
193
188
|
return new Proxy(contract, {
|
194
189
|
get(target, prop, receiver) {
|
195
190
|
const value = Reflect.get(target, prop, receiver);
|
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.b8c571d",
|
4
4
|
"license": "MIT",
|
5
5
|
"main": "dist/index.js",
|
6
6
|
"engines": {
|
@@ -46,8 +46,6 @@
|
|
46
46
|
"libp2p-websockets": "^0.16.2",
|
47
47
|
"luxon": "^2.3.2",
|
48
48
|
"module-alias": "^2.2.2",
|
49
|
-
"patch-package": "^6.4.7",
|
50
|
-
"postinstall-postinstall": "^2.1.0",
|
51
49
|
"sequelize": "6.18.0",
|
52
50
|
"sqlite3": "^5.0.5",
|
53
51
|
"waait": "^1.0.5"
|
@@ -62,6 +60,8 @@
|
|
62
60
|
"@types/fs-extra": "^9.0.13",
|
63
61
|
"@types/node": "^17.0.17",
|
64
62
|
"nodemon": "^2.0.15",
|
63
|
+
"patch-package": "^6.4.7",
|
64
|
+
"postinstall-postinstall": "^2.1.0",
|
65
65
|
"replace-in-file": "^6.3.2",
|
66
66
|
"rimraf": "^3.0.2",
|
67
67
|
"ts-node": "^10.5.0",
|
package/src/index.ts
CHANGED
@@ -16,6 +16,7 @@ moduleAlias.addAliases({
|
|
16
16
|
})
|
17
17
|
|
18
18
|
moduleAlias();
|
19
|
+
import assert from "assert";
|
19
20
|
import dotenv from "dotenv";
|
20
21
|
import { ethers } from "ethers";
|
21
22
|
import packageJson from '../package.json'
|
@@ -24,24 +25,16 @@ dotenv.config();
|
|
24
25
|
import Logger from "@/logger";
|
25
26
|
const logger = new Logger('Process')
|
26
27
|
|
27
|
-
|
28
|
+
|
29
|
+
if (process.argv.at(-1) === 'help') {
|
28
30
|
console.log('Usage:')
|
29
31
|
console.log(' PRIVATE_KEY=abcd1234 interop-x')
|
30
32
|
console.log(' PRIVATE_KEY=abcd1234 STAGING=true interop-x')
|
31
|
-
console.log(' PRIVATE_KEY=abcd1234 API_HOST=0.0.0.0 API_PORT=8080 interop-x')
|
32
|
-
}
|
33
|
-
|
34
|
-
if (process.argv.at(-1) === 'help') {
|
35
|
-
printUsage()
|
36
33
|
process.exit(0)
|
37
34
|
}
|
38
35
|
|
36
|
+
assert(process.env.PRIVATE_KEY, "PRIVATE_KEY is not defined");
|
39
37
|
|
40
|
-
if(! process.env.PRIVATE_KEY) {
|
41
|
-
console.error('Please provide a private key\n\n')
|
42
|
-
printUsage()
|
43
|
-
process.exit(1)
|
44
|
-
}
|
45
38
|
try {
|
46
39
|
new ethers.Wallet(process.env.PRIVATE_KEY!)
|
47
40
|
} catch (e) {
|
@@ -52,9 +45,8 @@ try {
|
|
52
45
|
logger.debug(`Starting Interop X Node (v${packageJson.version} - rev.@GIT_SHORT_HASH@)`)
|
53
46
|
|
54
47
|
import { Tasks } from "@/tasks";
|
55
|
-
import { startPeer
|
48
|
+
import { startPeer } from "@/net";
|
56
49
|
import { startApiServer } from '@/api';
|
57
|
-
import { Transaction } from './db';
|
58
50
|
|
59
51
|
async function main() {
|
60
52
|
|
@@ -65,30 +57,6 @@ async function main() {
|
|
65
57
|
tasks.start();
|
66
58
|
|
67
59
|
startApiServer()
|
68
|
-
|
69
|
-
protocol.on('TransactionStatus', async (payload) => {
|
70
|
-
if (!peerPool.isLeadNode(payload.peerId)) {
|
71
|
-
return;
|
72
|
-
}
|
73
|
-
|
74
|
-
const transaction = await Transaction.findOne({ where: { transactionHash: payload.data.transactionHash } })
|
75
|
-
|
76
|
-
if (!transaction) {
|
77
|
-
return;
|
78
|
-
}
|
79
|
-
|
80
|
-
transaction.sourceStatus = payload.data.sourceStatus
|
81
|
-
transaction.sourceTransactionHash = payload.data.sourceTransactionHash
|
82
|
-
transaction.sourceErrors = payload.data.sourceErrors
|
83
|
-
|
84
|
-
transaction.targetStatus = payload.data.targetStatus
|
85
|
-
transaction.targetTransactionHash = payload.data.targetTransactionHash
|
86
|
-
transaction.targetErrors = payload.data.targetErrors
|
87
|
-
|
88
|
-
transaction.status = payload.data.status
|
89
|
-
|
90
|
-
await transaction.save()
|
91
|
-
})
|
92
60
|
}
|
93
61
|
|
94
62
|
main()
|
package/src/net/pool/index.ts
CHANGED
@@ -1,7 +1,6 @@
|
|
1
1
|
import { Event } from "@/types";
|
2
2
|
import config from "@/config";
|
3
3
|
import Logger from "@/logger";
|
4
|
-
import { getAddress } from "ethers/lib/utils";
|
5
4
|
|
6
5
|
|
7
6
|
const logger = new Logger('PeerPool')
|
@@ -84,8 +83,8 @@ export class PeerPool {
|
|
84
83
|
const newPeer = !this.pool.get(peer.id);
|
85
84
|
this.pool.set(peer.id, peer)
|
86
85
|
peer.pooled = true
|
87
|
-
|
88
|
-
if
|
86
|
+
|
87
|
+
if(newPeer) {
|
89
88
|
config.events.emit(Event.POOL_PEER_ADDED, peer)
|
90
89
|
logger.info(`Peer ${peer.id} with address ${peer.publicAddress} added to pool`)
|
91
90
|
}
|
@@ -111,7 +110,7 @@ export class PeerPool {
|
|
111
110
|
this.cleanup()
|
112
111
|
|
113
112
|
return this.peers.filter((p) => {
|
114
|
-
if
|
113
|
+
if(!p.pooled) return false;
|
115
114
|
|
116
115
|
const now = new Date()
|
117
116
|
|
@@ -124,17 +123,6 @@ export class PeerPool {
|
|
124
123
|
}
|
125
124
|
|
126
125
|
|
127
|
-
isLeadNode(id: string) {
|
128
|
-
const peer = this.pool.get(id);
|
129
|
-
|
130
|
-
if (!peer) {
|
131
|
-
return false;
|
132
|
-
}
|
133
|
-
|
134
|
-
return getAddress(peer.publicAddress) === getAddress(config.leadNodeAddress)
|
135
|
-
}
|
136
|
-
|
137
|
-
|
138
126
|
cleanup() {
|
139
127
|
// let compDate = Date.now() - this.PEERS_CLEANUP_TIME_LIMIT * 60
|
140
128
|
|
@@ -5,7 +5,6 @@ import { SignatureDialProtocol, ISignatureRequest, ISignatureResponse } from "./
|
|
5
5
|
import { IPeerInfo, peerPool } from "..";
|
6
6
|
import config from "@/config";
|
7
7
|
import { Event } from "@/types";
|
8
|
-
import { Transaction } from "@/db";
|
9
8
|
|
10
9
|
export interface ProtocolOptions {
|
11
10
|
/* Handshake timeout in ms (default: 8000) */
|
@@ -34,12 +33,7 @@ interface PeerInfoEvent extends BaseMessageEvent {
|
|
34
33
|
data: Omit<IPeerInfo, 'id' | 'updated' | 'idle' | 'pooled'>
|
35
34
|
}
|
36
35
|
|
37
|
-
interface TransactionStatusEvent extends BaseMessageEvent {
|
38
|
-
data: Pick<Transaction, 'transactionHash' | 'sourceStatus' | 'sourceTransactionHash' | 'sourceErrors' | 'targetStatus' | 'targetTransactionHash' | 'targetErrors' | 'status'>
|
39
|
-
}
|
40
|
-
|
41
36
|
declare interface Protocol {
|
42
|
-
on(event: 'TransactionStatus', listener: (payload: TransactionStatusEvent) => void): this;
|
43
37
|
on(event: 'PeerInfo', listener: (payload: PeerInfoEvent) => void): this;
|
44
38
|
on(event: string, listener: (payload: BaseMessageEvent) => void): this;
|
45
39
|
}
|
@@ -50,7 +44,7 @@ class Protocol extends EventEmitter {
|
|
50
44
|
private protocolMessages: Message[] = [
|
51
45
|
{
|
52
46
|
name: 'PeerInfo',
|
53
|
-
code:
|
47
|
+
code: 0x09,
|
54
48
|
encode: (info: Pick<IPeerInfo, 'publicAddress'>) => [
|
55
49
|
Buffer.from(info.publicAddress),
|
56
50
|
],
|
@@ -58,36 +52,6 @@ class Protocol extends EventEmitter {
|
|
58
52
|
publicAddress: publicAddress.toString(),
|
59
53
|
}),
|
60
54
|
},
|
61
|
-
{
|
62
|
-
name: 'TransactionStatus',
|
63
|
-
code: 0x02,
|
64
|
-
encode: (transaction: Transaction) => [
|
65
|
-
Buffer.from(transaction.transactionHash),
|
66
|
-
|
67
|
-
Buffer.from(transaction.sourceStatus),
|
68
|
-
Buffer.from(transaction.sourceTransactionHash),
|
69
|
-
transaction.sourceErrors ? transaction.sourceErrors.map((e) => Buffer.from(e)) : [],
|
70
|
-
|
71
|
-
Buffer.from(transaction.targetStatus),
|
72
|
-
Buffer.from(transaction.targetTransactionHash),
|
73
|
-
transaction.targetErrors ? transaction.targetErrors.map((e) => Buffer.from(e)) : [],
|
74
|
-
|
75
|
-
Buffer.from(transaction.status),
|
76
|
-
],
|
77
|
-
decode: ([transactionHash, sourceStatus, sourceTransactionHash, sourceErrors, targetStatus, targetTransactionHash, targetErrors, status]: [Buffer, Buffer, Buffer, Buffer[], Buffer, Buffer, Buffer[], Buffer]) => ({
|
78
|
-
transactionHash: transactionHash.toString(),
|
79
|
-
|
80
|
-
sourceStatus: sourceStatus.toString(),
|
81
|
-
sourceTransactionHash: sourceTransactionHash.toString(),
|
82
|
-
sourceErrors: sourceErrors.map((e) => e.toString()),
|
83
|
-
|
84
|
-
targetStatus: targetStatus.toString(),
|
85
|
-
targetTransactionHash: targetTransactionHash.toString(),
|
86
|
-
targetErrors: targetErrors.map((e) => e.toString()),
|
87
|
-
|
88
|
-
status: status.toString(),
|
89
|
-
}),
|
90
|
-
},
|
91
55
|
];
|
92
56
|
private signature: SignatureDialProtocol;
|
93
57
|
|
@@ -157,14 +121,6 @@ class Protocol extends EventEmitter {
|
|
157
121
|
this.libp2p.pubsub.publish(this.topic, encoded)
|
158
122
|
}
|
159
123
|
|
160
|
-
public sendTransaction(transaction: Transaction) {
|
161
|
-
const message = this.protocolMessages.find((m) => m.name === 'TransactionStatus')!
|
162
|
-
|
163
|
-
const encoded = rlp.encode([message.code, message.encode(transaction)]);
|
164
|
-
|
165
|
-
this.libp2p.pubsub.publish(this.topic, encoded)
|
166
|
-
}
|
167
|
-
|
168
124
|
async requestSignatures(data: ISignatureRequest, peerIds?: string[]) {
|
169
125
|
try {
|
170
126
|
peerIds = peerIds || peerPool.activePeerIds;
|
@@ -207,13 +207,11 @@ class ProcessWithdrawEvents extends BaseTask {
|
|
207
207
|
if (parsedLogs.find(e => e.name === 'ExecutionSuccess')) {
|
208
208
|
console.log('ExecutionSuccess')
|
209
209
|
transaction.targetStatus = 'success'
|
210
|
-
transaction.targetTransactionHash = txSent.hash
|
211
210
|
transaction.status = 'success'
|
212
211
|
await transaction.save();
|
213
212
|
} else {
|
214
213
|
console.log('ExecutionFailure')
|
215
214
|
transaction.targetStatus = 'failed'
|
216
|
-
transaction.targetTransactionHash = txSent.hash
|
217
215
|
transaction.status = 'failed'
|
218
216
|
await transaction.save();
|
219
217
|
}
|
@@ -209,18 +209,14 @@ class ProcessDepositEvents extends BaseTask {
|
|
209
209
|
if (parsedLogs.find(e => e.name === 'ExecutionSuccess')) {
|
210
210
|
console.log('ExecutionSuccess')
|
211
211
|
transaction.targetStatus = 'success'
|
212
|
-
transaction.targetTransactionHash = txSent.hash
|
213
212
|
transaction.status = 'success'
|
214
213
|
await transaction.save();
|
215
214
|
} else {
|
216
215
|
console.log('ExecutionFailure')
|
217
216
|
transaction.targetStatus = 'failed'
|
218
|
-
transaction.targetTransactionHash = txSent.hash
|
219
217
|
transaction.status = 'failed'
|
220
218
|
await transaction.save();
|
221
219
|
}
|
222
|
-
|
223
|
-
protocol.sendTransaction(transaction)
|
224
220
|
}
|
225
221
|
|
226
222
|
async start(): Promise<void> {
|
package/src/utils/index.ts
CHANGED
@@ -233,7 +233,7 @@ export const buildWithdrawDataForTransaction = async (transaction: Transaction,
|
|
233
233
|
ethers.BigNumber.from(amount.toString()),
|
234
234
|
to,
|
235
235
|
token.address,
|
236
|
-
ethers.BigNumber.from(transaction.sourceChainId.toString()),
|
236
|
+
ethers.BigNumber.from(transaction.submitEvent.sourceChainId.toString()),
|
237
237
|
transaction.submitTransactionHash,
|
238
238
|
);
|
239
239
|
|
@@ -259,12 +259,6 @@ export function getContract<TContract extends ethers.Contract>(address: string,
|
|
259
259
|
signerOrProvider
|
260
260
|
) as TContract
|
261
261
|
|
262
|
-
// Make sure the contract properties is writable
|
263
|
-
const desc = Object.getOwnPropertyDescriptor(contract, 'functions');
|
264
|
-
|
265
|
-
if (!desc || desc.writable !== true) {
|
266
|
-
return contract
|
267
|
-
}
|
268
262
|
|
269
263
|
return new Proxy(contract, {
|
270
264
|
get(target, prop, receiver) {
|