Skip to content

Commit

Permalink
refactor(svm): restructure utils into modular files under src folder (#…
Browse files Browse the repository at this point in the history
…793)

* refactor(svm): restructure utils into modular files under src folder for better organization

Signed-off-by: Pablo Maldonado <pablomaldonadoturci@gmail.com>

* fix: imports

Signed-off-by: Pablo Maldonado <pablomaldonadoturci@gmail.com>

* fix: anchor

Signed-off-by: Pablo Maldonado <pablomaldonadoturci@gmail.com>

* refactor: comments

Signed-off-by: Pablo Maldonado <pablomaldonadoturci@gmail.com>

* fix: test

Signed-off-by: Pablo Maldonado <pablomaldonadoturci@gmail.com>

* refactor: comments

Signed-off-by: Pablo Maldonado <pablomaldonadoturci@gmail.com>

* fixes

Signed-off-by: Pablo Maldonado <pablomaldonadoturci@gmail.com>

---------

Signed-off-by: Pablo Maldonado <pablomaldonadoturci@gmail.com>
  • Loading branch information
md0x authored Dec 16, 2024
1 parent 6260895 commit 42402b9
Show file tree
Hide file tree
Showing 36 changed files with 1,189 additions and 1,098 deletions.
2 changes: 1 addition & 1 deletion scripts/svm/addressToPublicKey.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { evmAddressToPublicKey } from "../../src/SvmUtils";
import { evmAddressToPublicKey } from "../../src/svm";
import yargs from "yargs";
import { hideBin } from "yargs/helpers";
const argv = yargs(hideBin(process.argv)).option("address", {
Expand Down
2 changes: 1 addition & 1 deletion scripts/svm/closeRelayerPdas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { PublicKey, SystemProgram } from "@solana/web3.js";
import { SvmSpoke } from "../../target/types/svm_spoke";
import yargs from "yargs";
import { hideBin } from "yargs/helpers";
import { calculateRelayEventHashUint8Array, readProgramEvents } from "../../src/SvmUtils";
import { calculateRelayEventHashUint8Array, readProgramEvents } from "../../src/svm";

// Set up the provider
const provider = AnchorProvider.env();
Expand Down
7 changes: 2 additions & 5 deletions scripts/svm/executeRebalanceToHubPool.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,11 +68,8 @@ import {

import { getNodeUrl, MerkleTree } from "@uma/common";
import { decodeMessageHeader, getMessages } from "../../test/svm/cctpHelpers";
import {
loadExecuteRelayerRefundLeafParams,
RelayerRefundLeafSolana,
RelayerRefundLeafType,
} from "../../test/svm/utils";
import { RelayerRefundLeafSolana, RelayerRefundLeafType } from "../../src/types/svm";
import { loadExecuteRelayerRefundLeafParams } from "../../src/svm";

// Set up Solana provider.
const provider = AnchorProvider.env();
Expand Down
2 changes: 1 addition & 1 deletion scripts/svm/executeRebalanceToSpokePool.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { CHAIN_IDs, TOKEN_SYMBOLS_MAP } from "../../utils/constants";
import { SvmSpoke } from "../../target/types/svm_spoke";
import yargs from "yargs";
import { hideBin } from "yargs/helpers";
import { evmAddressToPublicKey } from "../../src/SvmUtils";
import { evmAddressToPublicKey } from "../../src/svm";
import { MessageTransmitter } from "../../target/types/message_transmitter";
import { TokenMessengerMinter } from "../../target/types/token_messenger_minter";
import { ethers, BigNumber } from "ethers";
Expand Down
6 changes: 3 additions & 3 deletions scripts/svm/fakeFillWithRandomDistribution.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ import {
AcrossPlusMessageCoder,
MulticallHandlerCoder,
calculateRelayHashUint8Array,
loadFillV3RelayParams,
sendTransactionWithLookupTable,
} from "../../src/SvmUtils";
import { FillDataParams, FillDataValues } from "../../test/svm/SvmSpoke.common";
import { loadFillV3RelayParams } from "../../test/svm/utils";
} from "../../src/svm";
import { FillDataParams, FillDataValues } from "../../src/types/svm";

// Set up the provider and signer.
const provider = AnchorProvider.env();
Expand Down
2 changes: 1 addition & 1 deletion scripts/svm/initialize.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { PublicKey, SystemProgram } from "@solana/web3.js";
import { SvmSpoke } from "../../target/types/svm_spoke";
import yargs from "yargs";
import { hideBin } from "yargs/helpers";
import { evmAddressToPublicKey } from "../../src/SvmUtils";
import { evmAddressToPublicKey } from "../../src/svm";

// Set up the provider
const provider = AnchorProvider.env();
Expand Down
2 changes: 1 addition & 1 deletion scripts/svm/publicKeyToAddress.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { publicKeyToEvmAddress } from "../../src/SvmUtils";
import yargs from "yargs";
import { hideBin } from "yargs/helpers";
import { publicKeyToEvmAddress } from "../../src/svm";

const argv = yargs(hideBin(process.argv)).option("publicKey", {
type: "string",
Expand Down
2 changes: 1 addition & 1 deletion scripts/svm/queryDeposits.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { PublicKey } from "@solana/web3.js";
import { SvmSpoke } from "../../target/types/svm_spoke";
import yargs from "yargs";
import { hideBin } from "yargs/helpers";
import { readProgramEvents } from "../../src/SvmUtils";
import { readProgramEvents } from "../../src/svm";

// Set up the provider
const provider = AnchorProvider.env();
Expand Down
3 changes: 1 addition & 2 deletions scripts/svm/queryFills.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@ import { PublicKey } from "@solana/web3.js";
import { SvmSpoke } from "../../target/types/svm_spoke";
import yargs from "yargs";
import { hideBin } from "yargs/helpers";
import { readProgramEvents, strPublicKey } from "../../src/SvmUtils";
import { u8Array32ToInt } from "../../test/svm/utils";
import { readProgramEvents, strPublicKey, u8Array32ToInt } from "../../src/svm";

// Set up the provider
const provider = AnchorProvider.env();
Expand Down
8 changes: 2 additions & 6 deletions scripts/svm/simpleFakeRelayerRepayment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,8 @@ import { SvmSpoke } from "../../target/types/svm_spoke";
import yargs from "yargs";
import { hideBin } from "yargs/helpers";
import { MerkleTree } from "@uma/common/dist/MerkleTree";
import {
relayerRefundHashFn,
RelayerRefundLeafType,
RelayerRefundLeafSolana,
loadExecuteRelayerRefundLeafParams,
} from "../../test/svm/utils";
import { RelayerRefundLeafSolana, RelayerRefundLeafType } from "../../src/types/svm";
import { loadExecuteRelayerRefundLeafParams, relayerRefundHashFn } from "../../src/svm";

// Set up the provider
const provider = AnchorProvider.env();
Expand Down
3 changes: 1 addition & 2 deletions scripts/svm/simpleFill.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@ import {
import { SvmSpoke } from "../../target/types/svm_spoke";
import yargs from "yargs";
import { hideBin } from "yargs/helpers";
import { calculateRelayHashUint8Array } from "../../src/SvmUtils";
import { intToU8Array32 } from "../../test/svm/utils";
import { calculateRelayHashUint8Array, intToU8Array32 } from "../../src/svm";

// Set up the provider
const provider = AnchorProvider.env();
Expand Down
3 changes: 2 additions & 1 deletion scripts/svm/utils/helpers.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import { utils as anchorUtils, BN } from "@coral-xyz/anchor";
import { relayerRefundHashFn, RelayerRefundLeafSolana, RelayerRefundLeafType } from "../../../test/svm/utils";
import { BigNumber, ethers } from "ethers";
import { PublicKey } from "@solana/web3.js";
import { MerkleTree } from "@uma/common";
import { RelayerRefundLeafSolana, RelayerRefundLeafType } from "../../../src/types/svm";
import { relayerRefundHashFn } from "../../../src/svm";

export const requireEnv = (name: string): string => {
if (!process.env[name]) throw new Error(`Environment variable ${name} is not set`);
Expand Down
Loading

0 comments on commit 42402b9

Please sign in to comment.