Skip to content

Commit

Permalink
feat: fix and clean trip scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
arthcp committed Feb 23, 2024
1 parent c01f868 commit 0cdd79c
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 38 deletions.
8 changes: 5 additions & 3 deletions scripts/admin/tripCommon.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,11 @@ else
export const sendTx = process.env.npm_config_sendtx == "true";
export const trip = process.env.npm_config_trip == "true";
export const untrip = process.env.npm_config_untrip == "true";
export const integrationType = process.env.npm_config_integration
? process.env.npm_config_integration.toUpperCase()
: IntegrationTypes.fast;
export const integrationType = (
process.env.npm_config_integration
? process.env.npm_config_integration.toUpperCase()
: IntegrationTypes.fast
) as IntegrationTypes;
export let filterChains = process.env.npm_config_chains
? process.env.npm_config_chains.split(",").map((c) => Number(c))
: activeChainSlugs.map((c) => Number(c));
Expand Down
30 changes: 10 additions & 20 deletions scripts/admin/tripGlobal.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,4 @@
import {
IntegrationTypes,
ChainSlug,
DeploymentMode,
isTestnet,
isMainnet,
} from "../../src";
import { IntegrationTypes, ChainSlug } from "../../src";
import { mode, overrides } from "../deploy/config";
import { arrayify, defaultAbiCoder, keccak256 } from "ethers/lib/utils";
import {
Expand All @@ -17,7 +11,6 @@ import {
TRIP_NATIVE_SIG_IDENTIFIER,
} from "../common";
import { ROLES } from "@socket.tech/dl-core";
import dotenv from "dotenv";
import {
sendTx,
integrationType,
Expand All @@ -29,7 +22,7 @@ import {
deploymentMode,
formatMsg,
} from "./tripCommon";
import { BigNumberish, Contract } from "ethers";
import { Contract } from "ethers";

/**
* Usable flags
Expand Down Expand Up @@ -67,9 +60,7 @@ const main = async () => {

if (
integrationType &&
!Object.values(IntegrationTypes).includes(
integrationType as IntegrationTypes
)
!Object.values(IntegrationTypes).includes(integrationType)
) {
throw new Error(
"Invalid integration type. Can be FAST, NATIVE_BRIDGE or OPTIMISTIC"
Expand All @@ -89,14 +80,13 @@ const main = async () => {
continue;
}
console.log("\nChecking chain: ", chain);
let siblingChain = siblingChains[0];

const switchboard = getSwitchboardInstance(
chain,
siblingChain,
integrationType as IntegrationTypes,
mode
);
const switchboard = siblingChains
.map((siblingChain) =>
getSwitchboardInstance(chain, siblingChain, integrationType, mode)
)
.find((siblingChain) => !!siblingChain);

if (switchboard === undefined) {
console.log("Switchboard address not found for ", chain, "continuing...");
continue;
Expand Down Expand Up @@ -140,7 +130,7 @@ const main = async () => {
});

if (sendTx) {
sendTxn(chain, nonce, signature, switchboard, trip, untrip);
await sendTxn(chain, nonce, signature, switchboard, trip, untrip);
}
}
printSummary(summary);
Expand Down
19 changes: 4 additions & 15 deletions scripts/admin/untripPath.ts
Original file line number Diff line number Diff line change
@@ -1,20 +1,9 @@
import { Contract, Wallet, utils } from "ethers";
import {
IntegrationTypes,
ChainSlug,
DeploymentMode,
isTestnet,
isMainnet,
} from "../../src";
import { IntegrationTypes, ChainSlug } from "../../src";
import { mode, overrides } from "../deploy/config";
import { arrayify, defaultAbiCoder, keccak256 } from "ethers/lib/utils";
import { UN_TRIP_PATH_SIG_IDENTIFIER, checkRole, getSiblings } from "../common";
import {
getAllAddresses,
DeploymentAddresses,
ROLES,
} from "@socket.tech/dl-core";
import dotenv from "dotenv";
import { ROLES } from "@socket.tech/dl-core";
import { getSwitchboardInstance } from "../common";
import {
sendTx,
Expand Down Expand Up @@ -81,7 +70,7 @@ const main = async () => {
const switchboard = getSwitchboardInstance(
chain,
siblingChain,
integrationType as IntegrationTypes,
integrationType,
mode
);
if (switchboard === undefined) {
Expand Down Expand Up @@ -134,7 +123,7 @@ const main = async () => {
});

if (sendTx) {
sendTxn(chain, siblingChain, nonce, signature, switchboard);
await sendTxn(chain, siblingChain, nonce, signature, switchboard);
}
}
}
Expand Down

0 comments on commit 0cdd79c

Please sign in to comment.