-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathexecute-txs.ts
68 lines (47 loc) · 2.2 KB
/
execute-txs.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
import { providers, Wallet } from "ethers";
import {
registerCustomArbitrumNetwork,
ChildTransactionReceipt,
ChildToParentMessageStatus,
} from "@arbitrum/sdk";
import dotenv from "dotenv";
import {fluenceNetwork as childNetwork} from "../helpers/custom-network-fluence";
dotenv.config();
//requireEnvVariables(["DEVNET_PRIVKEY", "ParentRPC", "ChildRPC", "TOKEN_ADDRESS"]);
console.log("Environment Variables Loaded");
/**
* Set up: instantiate Parent / Child wallets connected to providers
*/
const walletPrivateKey: string = process.env.DEVNET_PRIVKEY as string;
const parentProvider = new providers.JsonRpcProvider(process.env.ParentRPC);
const childProvider = new providers.JsonRpcProvider(process.env.ChildRPC);
const parentWallet = new Wallet(walletPrivateKey, parentProvider);
const childWallet = new Wallet(walletPrivateKey, childProvider);
const main = async () => {
// await arbLog("Deposit token using Arbitrum SDK");
// register - needed for retryables
registerCustomArbitrumNetwork(childNetwork);
let txnHash= "0x99334e3f5c081b335ece35c8aac61972afab18c5a6fca2a9f9218cc7b3695192"//"0x86cc4b3157dd5fba34dd8f50008f18b9ba54b432cc002797a724cb42dcfaac49"
const receipt = await childProvider.getTransactionReceipt(txnHash)
const childReceipt = new ChildTransactionReceipt(receipt)
const messages = await childReceipt.getChildToParentMessages(parentWallet)
const childToParentMsg = messages[0]
if ((await childToParentMsg.status(childProvider)) == ChildToParentMessageStatus.EXECUTED) {
console.log(`Message already executed! Nothing else to do here`)
process.exit(1)
}
//console.log(await childToParentMsg.status(hre.ethers.provider))
const timeToWaitMs = 1000 * 60
console.log(
"Waiting for the outbox entry to be created. This only happens when the Child block is confirmed on Parent, ~1 week after it's creation on Mainnet."
)
await childToParentMsg.waitUntilReadyToExecute(childProvider, timeToWaitMs)
console.log('Outbox entry exists! Trying to execute now')
const res = await childToParentMsg.execute(childProvider)
const rec = await res.wait()
console.log('Done! Your transaction is executed', rec)
};
main().catch((err) => {
console.error(err);
process.exit(1);
});