@instadapp/interop-x 0.0.0-dev.adea608 → 0.0.0-dev.b0d4a8f
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 +2 -2
- package/dist/src/net/protocol/index.js +4 -4
- package/dist/src/utils/index.js +5 -0
- package/package.json +3 -3
- package/src/index.ts +1 -1
- package/src/net/protocol/index.ts +6 -6
- package/src/utils/index.ts +6 -0
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.b0d4a8f",
|
4
4
|
"license": "MIT",
|
5
5
|
"main": "dist/index.js",
|
6
6
|
"engines": {
|
@@ -46,6 +46,8 @@
|
|
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",
|
49
51
|
"sequelize": "6.18.0",
|
50
52
|
"sqlite3": "^5.0.5",
|
51
53
|
"waait": "^1.0.5"
|
@@ -60,8 +62,6 @@
|
|
60
62
|
"@types/fs-extra": "^9.0.13",
|
61
63
|
"@types/node": "^17.0.17",
|
62
64
|
"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
@@ -40,7 +40,7 @@ catch (e) {
|
|
40
40
|
logger.error('Invalid private key');
|
41
41
|
process.exit(1);
|
42
42
|
}
|
43
|
-
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.b0d4a8f)`);
|
44
44
|
const tasks_1 = require("@/tasks");
|
45
45
|
const net_1 = require("@/net");
|
46
46
|
const api_1 = require("@/api");
|
@@ -50,7 +50,7 @@ async function main() {
|
|
50
50
|
const tasks = new tasks_1.Tasks();
|
51
51
|
tasks.start();
|
52
52
|
(0, api_1.startApiServer)();
|
53
|
-
net_1.protocol.on('
|
53
|
+
net_1.protocol.on('TransactionStatus', async (payload) => {
|
54
54
|
if (!net_1.peerPool.isLeadNode(payload.peerId)) {
|
55
55
|
return;
|
56
56
|
}
|
@@ -25,16 +25,16 @@ class Protocol extends stream_1.EventEmitter {
|
|
25
25
|
}),
|
26
26
|
},
|
27
27
|
{
|
28
|
-
name: '
|
28
|
+
name: 'TransactionStatus',
|
29
29
|
code: 0x02,
|
30
30
|
encode: (transaction) => [
|
31
31
|
Buffer.from(transaction.transactionHash),
|
32
32
|
Buffer.from(transaction.sourceStatus),
|
33
33
|
Buffer.from(transaction.sourceTransactionHash),
|
34
|
-
transaction.sourceErrors.map((e) => Buffer.from(e)),
|
34
|
+
transaction.sourceErrors ? transaction.sourceErrors.map((e) => Buffer.from(e)) : [],
|
35
35
|
Buffer.from(transaction.targetStatus),
|
36
36
|
Buffer.from(transaction.targetTransactionHash),
|
37
|
-
transaction.targetErrors.map((e) => Buffer.from(e)),
|
37
|
+
transaction.targetErrors ? transaction.targetErrors.map((e) => Buffer.from(e)) : [],
|
38
38
|
Buffer.from(transaction.status),
|
39
39
|
],
|
40
40
|
decode: ([transactionHash, sourceStatus, sourceTransactionHash, sourceErrors, targetStatus, targetTransactionHash, targetErrors, status]) => ({
|
@@ -100,7 +100,7 @@ class Protocol extends stream_1.EventEmitter {
|
|
100
100
|
this.libp2p.pubsub.publish(this.topic, encoded);
|
101
101
|
}
|
102
102
|
sendTransaction(transaction) {
|
103
|
-
const message = this.protocolMessages.find((m) => m.name === '
|
103
|
+
const message = this.protocolMessages.find((m) => m.name === 'TransactionStatus');
|
104
104
|
const encoded = ethereumjs_util_1.rlp.encode([message.code, message.encode(transaction)]);
|
105
105
|
this.libp2p.pubsub.publish(this.topic, encoded);
|
106
106
|
}
|
package/dist/src/utils/index.js
CHANGED
@@ -185,6 +185,11 @@ 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
|
+
}
|
188
193
|
return new Proxy(contract, {
|
189
194
|
get(target, prop, receiver) {
|
190
195
|
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.b0d4a8f",
|
4
4
|
"license": "MIT",
|
5
5
|
"main": "dist/index.js",
|
6
6
|
"engines": {
|
@@ -46,6 +46,8 @@
|
|
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",
|
49
51
|
"sequelize": "6.18.0",
|
50
52
|
"sqlite3": "^5.0.5",
|
51
53
|
"waait": "^1.0.5"
|
@@ -60,8 +62,6 @@
|
|
60
62
|
"@types/fs-extra": "^9.0.13",
|
61
63
|
"@types/node": "^17.0.17",
|
62
64
|
"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
@@ -34,12 +34,12 @@ interface PeerInfoEvent extends BaseMessageEvent {
|
|
34
34
|
data: Omit<IPeerInfo, 'id' | 'updated' | 'idle' | 'pooled'>
|
35
35
|
}
|
36
36
|
|
37
|
-
interface
|
37
|
+
interface TransactionStatusEvent extends BaseMessageEvent {
|
38
38
|
data: Pick<Transaction, 'transactionHash' | 'sourceStatus' | 'sourceTransactionHash' | 'sourceErrors' | 'targetStatus' | 'targetTransactionHash' | 'targetErrors' | 'status'>
|
39
39
|
}
|
40
40
|
|
41
41
|
declare interface Protocol {
|
42
|
-
on(event: '
|
42
|
+
on(event: 'TransactionStatus', listener: (payload: TransactionStatusEvent) => void): this;
|
43
43
|
on(event: 'PeerInfo', listener: (payload: PeerInfoEvent) => void): this;
|
44
44
|
on(event: string, listener: (payload: BaseMessageEvent) => void): this;
|
45
45
|
}
|
@@ -59,18 +59,18 @@ class Protocol extends EventEmitter {
|
|
59
59
|
}),
|
60
60
|
},
|
61
61
|
{
|
62
|
-
name: '
|
62
|
+
name: 'TransactionStatus',
|
63
63
|
code: 0x02,
|
64
64
|
encode: (transaction: Transaction) => [
|
65
65
|
Buffer.from(transaction.transactionHash),
|
66
66
|
|
67
67
|
Buffer.from(transaction.sourceStatus),
|
68
68
|
Buffer.from(transaction.sourceTransactionHash),
|
69
|
-
transaction.sourceErrors.map((e) => Buffer.from(e)),
|
69
|
+
transaction.sourceErrors ? transaction.sourceErrors.map((e) => Buffer.from(e)) : [],
|
70
70
|
|
71
71
|
Buffer.from(transaction.targetStatus),
|
72
72
|
Buffer.from(transaction.targetTransactionHash),
|
73
|
-
transaction.targetErrors.map((e) => Buffer.from(e)),
|
73
|
+
transaction.targetErrors ? transaction.targetErrors.map((e) => Buffer.from(e)) : [],
|
74
74
|
|
75
75
|
Buffer.from(transaction.status),
|
76
76
|
],
|
@@ -158,7 +158,7 @@ class Protocol extends EventEmitter {
|
|
158
158
|
}
|
159
159
|
|
160
160
|
public sendTransaction(transaction: Transaction) {
|
161
|
-
const message = this.protocolMessages.find((m) => m.name === '
|
161
|
+
const message = this.protocolMessages.find((m) => m.name === 'TransactionStatus')!
|
162
162
|
|
163
163
|
const encoded = rlp.encode([message.code, message.encode(transaction)]);
|
164
164
|
|
package/src/utils/index.ts
CHANGED
@@ -259,6 +259,12 @@ 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
|
+
}
|
262
268
|
|
263
269
|
return new Proxy(contract, {
|
264
270
|
get(target, prop, receiver) {
|