-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathbridgeDebugging.ts
More file actions
47 lines (41 loc) · 1.59 KB
/
Copy pathbridgeDebugging.ts
File metadata and controls
47 lines (41 loc) · 1.59 KB
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
import 'dotenv/config';
import axios from 'axios';
import { Command } from 'commander';
import { SharedConfig } from "./constants";
import { RawConfig, Domain } from '@buildwithsygma/sygma-sdk-core';
import { getTransactionInfo } from './utils';
const program = new Command();
program
.name("debug")
.description("Enables quick debugging of specific Sygma messages (bridging request)")
.requiredOption(
"-e, --environment <environment>", "Environment on which to debug"
)
.requiredOption(
"-txn, --transaction-hash <transactionHash>", "Transaction on which to provide information"
)
.requiredOption(
"-cid, --chain-id <chainId>", "Chain on which the transaction happened"
)
.action(async(configs: any) => {
try {
const network: keyof typeof SharedConfig = configs.environment;
const {
data
} = await axios.get(SharedConfig[network]) as unknown as { data: RawConfig };
const networks = data.domains.filter((domain: Domain) =>
domain.name === "ethereum"
&& domain.chainId == configs.chainId)
if (!networks){
throw new Error("Chain doesn't exist")
}
await getTransactionInfo(networks[0], configs.transactionHash)
} catch (err) {
if (err instanceof Error) {
throw new Error(`Failed to execute because of: ${err.message}`);
} else {
throw new Error('Something went wrong');
}
}
})
program.parse(process.argv)