@instadapp/interop-x 0.0.0-dev.d4e8223 → 0.0.0-dev.d71f27e
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 +2 -2
- 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/constants/addresses.js +3 -3
- package/dist/src/constants/index.js +0 -1
- package/dist/src/db/models/transaction.js +27 -9
- package/dist/src/gnosis/actions/index.js +9 -0
- package/dist/src/gnosis/actions/withdraw/index.js +41 -0
- package/dist/src/gnosis/index.js +20 -0
- package/dist/src/index.js +7 -18
- package/dist/src/net/protocol/dial/SignatureDialProtocol.js +9 -10
- package/dist/src/net/protocol/dial/TransactionStatusDialProtocol.js +2 -0
- package/dist/src/net/protocol/index.js +11 -1
- package/dist/src/tasks/{InteropXGateway/ProcessDepositEvents.js → InteropXContract/ProcessBridgeRequestEvents.js} +43 -53
- package/dist/src/tasks/InteropXContract/SyncBridgeRequestEvents.js +78 -0
- package/dist/src/tasks/InteropXContract/SyncBridgeRequestSentEvents.js +89 -0
- package/dist/src/tasks/Transactions/SyncTransactionStatusTask.js +2 -0
- package/dist/src/tasks/index.js +13 -30
- 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 +14 -84
- package/package.json +2 -2
- package/src/abi/index.ts +2 -4
- package/src/abi/interopXContract.json +391 -0
- package/src/alias.ts +6 -0
- package/src/constants/addresses.ts +3 -3
- package/src/constants/index.ts +0 -1
- package/src/db/models/transaction.ts +66 -21
- package/src/gnosis/actions/index.ts +5 -0
- package/src/gnosis/actions/withdraw/index.ts +56 -0
- package/src/gnosis/index.ts +19 -0
- package/src/index.ts +6 -17
- package/src/net/protocol/dial/SignatureDialProtocol.ts +11 -13
- package/src/net/protocol/dial/TransactionStatusDialProtocol.ts +3 -1
- package/src/net/protocol/index.ts +13 -3
- package/src/tasks/{InteropXGateway/ProcessDepositEvents.ts → InteropXContract/ProcessBridgeRequestEvents.ts} +62 -103
- package/src/tasks/InteropXContract/SyncBridgeRequestEvents.ts +116 -0
- package/src/tasks/InteropXContract/SyncBridgeRequestSentEvents.ts +120 -0
- package/src/tasks/Transactions/SyncTransactionStatusTask.ts +2 -0
- package/src/tasks/index.ts +15 -37
- 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 +46 -125
- 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/tasks/InteropBridge/ProcessWithdrawEvents.js +0 -146
- package/dist/src/tasks/InteropBridge/SyncBurnEvents.js +0 -71
- package/dist/src/tasks/InteropBridge/SyncMintEvents.js +0 -67
- 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/tasks/InteropBridge/ProcessWithdrawEvents.ts +0 -231
- package/src/tasks/InteropBridge/SyncBurnEvents.ts +0 -121
- package/src/tasks/InteropBridge/SyncMintEvents.ts +0 -99
- 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,124 +0,0 @@
|
|
1
|
-
import { BaseTask } from "../BaseTask";
|
2
|
-
import Logger from '@/logger';
|
3
|
-
import { ethers } from "ethers";
|
4
|
-
import abi from "@/abi";
|
5
|
-
import { Transaction } from "@/db";
|
6
|
-
import { generateInteropTransactionHash, getContract, getRpcProviderUrl } from "@/utils";
|
7
|
-
import { addresses } from "@/constants";
|
8
|
-
import { ChainId } from "@/types";
|
9
|
-
import config from "@/config";
|
10
|
-
import { InteropXGateway } from "@/typechain";
|
11
|
-
|
12
|
-
class SyncDepositEvents extends BaseTask {
|
13
|
-
contractAddress: string;
|
14
|
-
provider: ethers.providers.JsonRpcProvider;
|
15
|
-
contract: InteropXGateway;
|
16
|
-
chainId: ChainId;
|
17
|
-
|
18
|
-
constructor({ chainId }: { chainId: ChainId }) {
|
19
|
-
super({
|
20
|
-
logger: new Logger("InteropXGateway::SyncDepositEvents"),
|
21
|
-
})
|
22
|
-
this.chainId = chainId;
|
23
|
-
}
|
24
|
-
|
25
|
-
async pollHandler() {
|
26
|
-
const currentBlock = await this.provider.getBlockNumber();
|
27
|
-
|
28
|
-
const events = await this.contract.queryFilter(
|
29
|
-
this.contract.filters.LogGatewayDeposit(),
|
30
|
-
currentBlock - 2000,
|
31
|
-
currentBlock,
|
32
|
-
);
|
33
|
-
|
34
|
-
let processedEvents = 0;
|
35
|
-
|
36
|
-
for (const event of events) {
|
37
|
-
|
38
|
-
try {
|
39
|
-
if (!event.args) {
|
40
|
-
continue;
|
41
|
-
}
|
42
|
-
|
43
|
-
const { sourceChainId, targetChainId, user, vnonce, amount, token } = event.args;
|
44
|
-
|
45
|
-
const uniqueIdentifier = {
|
46
|
-
action: 'deposit',
|
47
|
-
submitTransactionHash: event.transactionHash,
|
48
|
-
sourceChainId: sourceChainId,
|
49
|
-
targetChainId: targetChainId,
|
50
|
-
}
|
51
|
-
|
52
|
-
if (await Transaction.findOne({ where: uniqueIdentifier })) {
|
53
|
-
continue;
|
54
|
-
}
|
55
|
-
|
56
|
-
const tx = await event.getTransaction()
|
57
|
-
|
58
|
-
await Transaction.create({
|
59
|
-
...uniqueIdentifier,
|
60
|
-
transactionHash: generateInteropTransactionHash(uniqueIdentifier),
|
61
|
-
from: tx.from,
|
62
|
-
to: user,
|
63
|
-
|
64
|
-
|
65
|
-
submitTransactionHash: event.transactionHash,
|
66
|
-
submitBlockNumber: event.blockNumber,
|
67
|
-
|
68
|
-
// submit & source are the same
|
69
|
-
sourceTransactionHash: event.transactionHash,
|
70
|
-
sourceBlockNumber: event.blockNumber,
|
71
|
-
sourceStatus: "success",
|
72
|
-
|
73
|
-
targetStatus: "uninitialised",
|
74
|
-
|
75
|
-
submitEvent: {
|
76
|
-
user,
|
77
|
-
sourceChainId: sourceChainId.toString(),
|
78
|
-
targetChainId: targetChainId.toString(),
|
79
|
-
token: token,
|
80
|
-
amount: amount.toString(),
|
81
|
-
vnonce: vnonce.toString(),
|
82
|
-
},
|
83
|
-
|
84
|
-
sourceEvent: {
|
85
|
-
user,
|
86
|
-
sourceChainId: sourceChainId.toString(),
|
87
|
-
targetChainId: targetChainId.toString(),
|
88
|
-
token: token,
|
89
|
-
amount: amount.toString(),
|
90
|
-
vnonce: vnonce.toString(),
|
91
|
-
},
|
92
|
-
status: "pending",
|
93
|
-
})
|
94
|
-
|
95
|
-
this.logger.info(
|
96
|
-
`Deposit queued: ${event.transactionHash} ${event.blockNumber}`
|
97
|
-
);
|
98
|
-
} catch (error) {
|
99
|
-
this.logger.error(error);
|
100
|
-
}
|
101
|
-
}
|
102
|
-
|
103
|
-
if (processedEvents > 0)
|
104
|
-
this.logger.info(`${processedEvents} events processed`);
|
105
|
-
}
|
106
|
-
|
107
|
-
async start(): Promise<void> {
|
108
|
-
this.contractAddress = addresses[this.chainId].interopXGateway;
|
109
|
-
|
110
|
-
this.provider = new ethers.providers.JsonRpcProvider(
|
111
|
-
getRpcProviderUrl(this.chainId)
|
112
|
-
);
|
113
|
-
|
114
|
-
this.contract = getContract<InteropXGateway>(
|
115
|
-
this.contractAddress,
|
116
|
-
abi.interopXGateway,
|
117
|
-
new ethers.Wallet(config.privateKey!, this.provider)
|
118
|
-
);
|
119
|
-
|
120
|
-
await super.start()
|
121
|
-
}
|
122
|
-
}
|
123
|
-
|
124
|
-
export default SyncDepositEvents;
|
@@ -1,105 +0,0 @@
|
|
1
|
-
import { BaseTask } from "../BaseTask";
|
2
|
-
import Logger from '@/logger';
|
3
|
-
import { ethers } from "ethers";
|
4
|
-
import abi from "@/abi";
|
5
|
-
import { Transaction } from "@/db";
|
6
|
-
import { getContract, getRpcProviderUrl } from "@/utils";
|
7
|
-
import { addresses } from "@/constants";
|
8
|
-
import { ChainId } from "@/types";
|
9
|
-
import config from "@/config";
|
10
|
-
import { InteropXGateway } from "@/typechain";
|
11
|
-
|
12
|
-
class SyncWithdrawEvents extends BaseTask {
|
13
|
-
contractAddress: string;
|
14
|
-
provider: ethers.providers.JsonRpcProvider;
|
15
|
-
contract: InteropXGateway;
|
16
|
-
chainId: ChainId;
|
17
|
-
|
18
|
-
constructor({ chainId }: { chainId: ChainId }) {
|
19
|
-
super({
|
20
|
-
logger: new Logger("InteropXGateway::SyncWithdrawEvents"),
|
21
|
-
})
|
22
|
-
this.chainId = chainId;
|
23
|
-
}
|
24
|
-
|
25
|
-
async pollHandler() {
|
26
|
-
const currentBlock = await this.provider.getBlockNumber();
|
27
|
-
|
28
|
-
const events = await this.contract.queryFilter(
|
29
|
-
this.contract.filters.LogGatewayWithdraw(),
|
30
|
-
currentBlock - 500,
|
31
|
-
currentBlock,
|
32
|
-
);
|
33
|
-
|
34
|
-
let processedEvents = 0;
|
35
|
-
|
36
|
-
for (const event of events) {
|
37
|
-
|
38
|
-
try {
|
39
|
-
if (!event.args) {
|
40
|
-
continue;
|
41
|
-
}
|
42
|
-
|
43
|
-
const { user, token, amount, sourceChainId, targetChainId, transactionHash } = event.args;
|
44
|
-
|
45
|
-
const uniqueIdentifier = {
|
46
|
-
action: 'withdraw',
|
47
|
-
submitTransactionHash: transactionHash,
|
48
|
-
sourceChainId: sourceChainId,
|
49
|
-
targetChainId: targetChainId,
|
50
|
-
|
51
|
-
targetEvent: null
|
52
|
-
}
|
53
|
-
const transaction = await Transaction.findOne({ where: uniqueIdentifier });
|
54
|
-
|
55
|
-
if (!transaction) {
|
56
|
-
return;
|
57
|
-
}
|
58
|
-
|
59
|
-
const tx = await event.getTransaction()
|
60
|
-
|
61
|
-
transaction.targetStatus = 'success'
|
62
|
-
transaction.targetErrors = []
|
63
|
-
transaction.targetTransactionHash = tx.hash
|
64
|
-
transaction.targetEvent = {
|
65
|
-
user,
|
66
|
-
token,
|
67
|
-
amount: amount.toString(),
|
68
|
-
sourceChainId,
|
69
|
-
targetChainId,
|
70
|
-
transactionHash,
|
71
|
-
}
|
72
|
-
transaction.status = 'success'
|
73
|
-
|
74
|
-
await transaction.save()
|
75
|
-
|
76
|
-
this.logger.info(
|
77
|
-
`Witdraw confirmation received: ${transaction.transactionHash} `
|
78
|
-
);
|
79
|
-
} catch (error) {
|
80
|
-
this.logger.error(error);
|
81
|
-
}
|
82
|
-
}
|
83
|
-
|
84
|
-
if (processedEvents > 0)
|
85
|
-
this.logger.info(`${processedEvents} events processed`);
|
86
|
-
}
|
87
|
-
|
88
|
-
async start(): Promise<void> {
|
89
|
-
this.contractAddress = addresses[this.chainId].interopXGateway;
|
90
|
-
|
91
|
-
this.provider = new ethers.providers.JsonRpcProvider(
|
92
|
-
getRpcProviderUrl(this.chainId)
|
93
|
-
);
|
94
|
-
|
95
|
-
this.contract = getContract<InteropXGateway>(
|
96
|
-
this.contractAddress,
|
97
|
-
abi.interopXGateway,
|
98
|
-
new ethers.Wallet(config.privateKey!, this.provider)
|
99
|
-
);
|
100
|
-
|
101
|
-
await super.start()
|
102
|
-
}
|
103
|
-
}
|
104
|
-
|
105
|
-
export default SyncWithdrawEvents;
|