Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: transaction info #5

Open
wants to merge 32 commits into
base: nmlinaric/pausing-command
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
6368c41
Initial setup with pausing-unpausing command
nmlinaric Jul 10, 2023
c927387
early draft of pause functionality
matejdrazic Jul 11, 2023
7ec9441
key fix
matejdrazic Jul 11, 2023
d415d4c
adding some typescript types
matejdrazic Jul 11, 2023
8df9c46
fixing some bugs
matejdrazic Jul 11, 2023
0a8b2a0
added bridge abi
matejdrazic Jul 11, 2023
795fc79
comments regarding typescript types
matejdrazic Jul 12, 2023
e7e03ad
adding more types
matejdrazic Jul 12, 2023
9b28408
changing types to reflect update
matejdrazic Jul 12, 2023
615f4fb
moving constants to a separate folder
matejdrazic Jul 12, 2023
0c57136
added desc to readme file
matejdrazic Jul 13, 2023
3686be7
Added basic skeleton for debugging cli command
Jul 13, 2023
8dac703
Created program action
Jul 13, 2023
6b54c51
getTranscationInfo function created
Jul 13, 2023
0124a49
Added new option for specifying chainId
Jul 13, 2023
2d6d5fe
Added getting transaction by hash
Jul 13, 2023
f8de08e
Only chainId is required for transaction info
Jul 13, 2023
8336a3c
Added status checking of transactions
Jul 14, 2023
8f92057
Transfer from ethers v6 to v5
Jul 14, 2023
d18e42f
Added getEvents function
Jul 14, 2023
7a91808
Added printing data on the console
Jul 14, 2023
3fc9d01
Added correct printing of FailedHandlerExecution event
Jul 14, 2023
e929d97
Added function for printing event data
Jul 14, 2023
b6a9eed
Added constant possibleEvents
Jul 17, 2023
a2b57ba
Added export in index.ts
Jul 17, 2023
1c20ce0
Minor code changes
Jul 17, 2023
e108d19
Changed getEvent function
Jul 17, 2023
8c6ca94
added yarn.lock
Jul 17, 2023
412676c
Added README.md
Jul 17, 2023
a346838
Corrected cli flag name and README
Jul 17, 2023
d4819bf
Error handling corrected
Jul 17, 2023
47d2c28
Minor changes
Jul 17, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
GOERLI_RPC_URL=
40 changes: 40 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.

# dependencies
/node_modules
**/*/node_modules
/.pnp
.pnp.*

# testing
/coverage

# production
/build
/dist-cjs

# misc
.DS_Store
.env
.env.local
.env.development.local
.env.test.local
.env.production.local

npm-debug.log*
yarn-debug.log*
yarn-error.log*

.env
.vscode
.history

# IDE
.idea/

.yarn/*
!.yarn/patches
!.yarn/plugins
!.yarn/releases
!.yarn/sdks
!.yarn/versions
874 changes: 874 additions & 0 deletions .yarn/releases/yarn-3.6.1.cjs

Large diffs are not rendered by default.

9 changes: 9 additions & 0 deletions .yarnrc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
compressionLevel: 0

enableGlobalCache: true

nmMode: hardlinks-local

nodeLinker: node-modules

yarnPath: .yarn/releases/yarn-3.6.1.cjs
18 changes: 17 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,17 @@
# maintenance-utils
# maintenance-utils
NodeCLI for various purposes

## Commands

```pause``` - Pause all transfers across all bridges on selected enviroment (devnet, testnet or mainnet)

```debug``` - Provide information about transactions for a specific Sygma message

Run with:

```
node pause -pk "private-key" -m "mnemonic words" -e "environment"
```
```
node debug -e "environment" -txn "transaction hash" -cid "chain id"
```
6 changes: 6 additions & 0 deletions eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
require("@rushstack/eslint-patch/modern-module-resolution");

module.exports = {
root: true,
extends: "@chainsafe",
}
41 changes: 41 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
{
"name": "@buildwithsygma/sygma-sdk",
"description": "Sygma Maintenance",
"main": "index.js",
"private": true,
"type": "commonjs",
"repository": {
"type": "git",
"url": "https://github.com/sygmaprotocol/maintenance-utils"
},
"packageManager": "[email protected]",
"engines": {
"node": ">=16.0.0"
},
"scripts": {
"build:cjs": "tsc -p tsconfig.cjs.json && echo '{\"type\": \"commonjs\"}' > ./dist-cjs/package.json",
"build:types": "tsc -p tsconfig.types.json",
"build:all": "yarn run clean && yarn build:cjs && yarn build:types",
"lint": "eslint 'src/**/*.ts'",
"lint:fix": "yarn run lint --fix",
"clean": "rm -rf ./dist ./dist-cjs ./dist-esm ./types"
},
"keywords": [],
"author": "Sygma Protocol Product Team",
"license": "LGPL-3.0-or-later",
"dependencies": {
"axios": "^1.4.0",
"commander": "^11.0.0"
},
"devDependencies": {
"@buildwithsygma/sygma-contracts": "^2.3.0",
"@buildwithsygma/sygma-sdk-core": "^2.1.0",
"dotenv": "^16.3.1",
"ethers": "5",
"ts-node": "^10.9.1",
"typescript": "^5.1.6"
},
"resolutions": {
"typescript": "^5.0.4"
}
}
7 changes: 7 additions & 0 deletions prettierrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"printWidth": 100,
"singleQuote": true,
"trailingComma": "all",
"useTabs": false,
"arrowParens": "avoid"
}
47 changes: 47 additions & 0 deletions src/bridgeDebugging.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,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)
63 changes: 63 additions & 0 deletions src/bridgePausing.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
import 'dotenv/config';
import axios from 'axios';
import { Command, Option } from 'commander';
import { Wallet } from 'ethers';
import { SharedConfig } from "./constants";
import { getWalletsForDifferentProviders, deriveWalletsFromMnemonic, sendPauseTransactions } from "./utils";
import { RawConfig, Domain } from '@buildwithsygma/sygma-sdk-core';

const program = new Command();

program
.name("pause-bridge")
.description("Pauses all bridge instances across all networks")
.version("0.0.1")

program
.command("pause")
.addOption(
new Option('-e, --environment <environment>', 'Environment on which to pause bridge instances')
.choices(['devnet', 'testnet', 'mainnet'])
)
.addOption(
new Option('-pk, --private-key <privateKey>', 'Private key to use for signing transactions')
)
.addOption(
new Option('-m, --mnemonic <mnemonic>', 'Mnemonic to use for signing transactions').conflicts('private-key')
)
.action(async (configs: any) => {
try {
const network: keyof typeof SharedConfig = configs.environment;
const {
privateKey,
mnemonic
} = configs;

const {
data
} = await axios.get(SharedConfig[network]) as unknown as { data: RawConfig };

const networks: Array<Domain> = data.domains.filter((network: Domain) => network.name === "ethereum"); // just evms for now

let wallets: Array<Wallet | any> = [];

if (mnemonic) {
wallets = await deriveWalletsFromMnemonic(mnemonic, networks);
} else if (privateKey) {
wallets = await getWalletsForDifferentProviders(privateKey, networks);
} else {
throw new Error('Either mnemonic or private key must be provided');
}

await sendPauseTransactions(networks, wallets);

} catch (err) {
if (err instanceof Error) {
throw new Error(`Failed to fetch shared config because of: ${err.message}`);
} else {
throw new Error('Something went wrong while fetching config file');
}
}
})

program.parse(process.argv);
2 changes: 2 additions & 0 deletions src/constants/events.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export const possibleEvents: string[] =
["deposit", "proposalexecution", "failedhandlerexecution"]
3 changes: 3 additions & 0 deletions src/constants/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export { chainIdToRpc } from "./rpc";
export { SharedConfig } from "./sharedConfig";
export { possibleEvents } from "./events";
5 changes: 5 additions & 0 deletions src/constants/rpc.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
// chain id -> provider url
export const chainIdToRpc = {
5: process.env.GOERLI_RPC_URL,
}

5 changes: 5 additions & 0 deletions src/constants/sharedConfig.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
export const SharedConfig = {
devnet: "https://chainbridge-assets-stage.s3.us-east-2.amazonaws.com/shared-config-dev.json",
testnet: "https://chainbridge-assets-stage.s3.us-east-2.amazonaws.com/shared-config-test.json",
mainnet: "https://sygma-assets-mainnet.s3.us-east-2.amazonaws.com/shared-config-mainnet.json"
};
2 changes: 2 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export * from "bridgePausing"
export * from "bridgeDebugging"
Loading