-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
early draft of pause functionality
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
GOERLI_RPC_URL= |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,12 @@ | ||
# maintenance-utils | ||
# maintenance-utils | ||
NodeCLI for various purposes | ||
|
||
## Commands | ||
|
||
```pause``` - Pause all transfers across all bridges on selected enviroment (devnet, testnet or mainnet) | ||
|
||
Run with: | ||
|
||
``` | ||
node pause -pk "private-key" -m "mnemonic words" -e "environment" | ||
``` |
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
export { chainIdToRpc } from "./rpc"; | ||
export { SharedConfig } from "./sharedConfig"; |
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, | ||
} | ||
|
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" | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import { ethers } from 'ethers'; | ||
import { chainIdToRpc } from "./constants"; | ||
import { Bridge__factory } from "@buildwithsygma/sygma-contracts"; | ||
import { Domain } from "@buildwithsygma/sygma-sdk-core"; | ||
|
||
export async function getWalletsForDifferentProviders(privateKey: string, networks: Array<Domain>) { | ||
const wallets = []; | ||
for (let i = 0; i < networks.length; i++) { | ||
const network = networks[i]; | ||
const chainId = network.chainId; | ||
const rpc = chainIdToRpc[chainId as keyof typeof chainIdToRpc]; | ||
if (rpc) { | ||
const provider = new ethers.JsonRpcProvider(rpc); | ||
const wallet = new ethers.Wallet(privateKey, provider); // add error handling for invalid private key | ||
wallets.push(wallet); | ||
} | ||
} | ||
return wallets; | ||
} | ||
|
||
export async function deriveWalletsFromMnemonic(mnemonic: string, networks: Array<Domain>) { | ||
const wallets = []; | ||
for (let i = 0; i < networks.length; i++) { | ||
const network = networks[i]; | ||
const chainId = network.chainId; | ||
const rpc = chainIdToRpc[chainId as keyof typeof chainIdToRpc]; | ||
if (rpc) { | ||
const provider = new ethers.JsonRpcProvider(rpc); | ||
const wallet = ethers.Wallet.fromPhrase(mnemonic, provider); | ||
wallets.push(wallet); | ||
} | ||
} | ||
return wallets; | ||
} | ||
|
||
export async function sendPauseTransactions(networks: Array<any>, wallets: Array<ethers.Wallet | ethers.HDNodeWallet>) { | ||
const receipts = []; | ||
for (let i = 0; i < networks.length; i++) { | ||
const network = networks[i]; | ||
const wallet = wallets[i]; | ||
const bridge = Bridge__factory.connect(network.bridge, wallet); | ||
const tx = await bridge.adminPauseTransfers(); | ||
console.log(`Transaction no. ${i + 1} completed, bridge on ${network.name} paused`); | ||
receipts.push(tx); | ||
} | ||
return receipts; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
export {}; | ||
import 'dotenv/config'; | ||
//# sourceMappingURL=bridgePausing.d.ts.map |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
This file was deleted.
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export { chainIdToRpc } from "./rpc"; | ||
export { SharedConfig } from "./sharedConfig"; | ||
//# sourceMappingURL=index.d.ts.map |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
export declare const chainIdToRpc: { | ||
5: string | undefined; | ||
}; | ||
//# sourceMappingURL=rpc.d.ts.map |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
export declare const SharedConfig: { | ||
devnet: string; | ||
testnet: string; | ||
mainnet: string; | ||
}; | ||
//# sourceMappingURL=sharedConfig.d.ts.map |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import { ethers } from 'ethers'; | ||
import { Domain } from "@buildwithsygma/sygma-sdk-core"; | ||
export declare function getWalletsForDifferentProviders(privateKey: string, networks: Array<Domain>): Promise<ethers.Wallet[]>; | ||
export declare function deriveWalletsFromMnemonic(mnemonic: string, networks: Array<Domain>): Promise<ethers.HDNodeWallet[]>; | ||
export declare function sendPauseTransactions(networks: Array<any>, wallets: Array<ethers.Wallet | ethers.HDNodeWallet>): Promise<ethers.ContractTransaction[]>; | ||
//# sourceMappingURL=utils.d.ts.map |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.