diff --git a/scripts/admin/get-outbound-txs.ts b/scripts/admin/get-outbound-txs.ts index b5426808..3febc662 100644 --- a/scripts/admin/get-outbound-txs.ts +++ b/scripts/admin/get-outbound-txs.ts @@ -112,7 +112,11 @@ export const main = async () => { const CHUNK_SIZE = 5000; const messageAddedEvents = []; - for (let currentBlock = fromBlock; currentBlock <= toBlock; currentBlock += CHUNK_SIZE) { + for ( + let currentBlock = fromBlock; + currentBlock <= toBlock; + currentBlock += CHUNK_SIZE + ) { const chunkEnd = Math.min(currentBlock + CHUNK_SIZE - 1, toBlock); console.log(`Querying chunk: ${currentBlock} to ${chunkEnd}`); diff --git a/scripts/admin/get-seal-events.ts b/scripts/admin/get-seal-events.ts index 4307cbab..0ea3609a 100644 --- a/scripts/admin/get-seal-events.ts +++ b/scripts/admin/get-seal-events.ts @@ -112,7 +112,11 @@ export const main = async () => { const CHUNK_SIZE = 5000; const sealedEvents = []; - for (let currentBlock = fromBlock; currentBlock <= toBlock; currentBlock += CHUNK_SIZE) { + for ( + let currentBlock = fromBlock; + currentBlock <= toBlock; + currentBlock += CHUNK_SIZE + ) { const chunkEnd = Math.min(currentBlock + CHUNK_SIZE - 1, toBlock); console.log(`Querying chunk: ${currentBlock} to ${chunkEnd}`); diff --git a/scripts/admin/send-attest.ts b/scripts/admin/send-attest.ts index d7a32f3b..cc5809e0 100644 --- a/scripts/admin/send-attest.ts +++ b/scripts/admin/send-attest.ts @@ -91,7 +91,9 @@ export const main = async () => { const sourceChain = sourceChainSlug; const destinationChain = destinationChainSlug; - console.log(`\nProcessing attest for path: ${sourceChain} -> ${destinationChain}\n`); + console.log( + `\nProcessing attest for path: ${sourceChain} -> ${destinationChain}\n` + ); // Get addresses from prod_addresses.json const destinationAddresses = addresses[destinationChain]; @@ -139,7 +141,13 @@ export const main = async () => { const messageHash = keccak256( defaultAbiCoder.encode( ["address", "uint32", "bytes32", "uint256", "bytes32"], - [switchboardAddress, parseInt(destinationChain), packetId, proposalCount, root] + [ + switchboardAddress, + parseInt(destinationChain), + packetId, + proposalCount, + root, + ] ) ); @@ -147,11 +155,15 @@ export const main = async () => { // Sign with KMS console.log("\nSigning with AWS KMS..."); - const signature = await kmsSigner.signMessage(ethers.utils.arrayify(messageHash)); + const signature = await kmsSigner.signMessage( + ethers.utils.arrayify(messageHash) + ); console.log("Signature:", signature); // Prepare transaction data - const switchboardInterface = new ethers.utils.Interface(FastSwitchboardArtifact.abi); + const switchboardInterface = new ethers.utils.Interface( + FastSwitchboardArtifact.abi + ); const calldata = switchboardInterface.encodeFunctionData("attest", [ packetId, proposalCount, @@ -193,7 +205,9 @@ export const main = async () => { console.log("Gas used:", receipt.gasUsed.toString()); } else { console.log("To send the attest transaction, add --sendtx flag"); - console.log("You can use the transaction details above to manually send, simulate, or audit the transaction."); + console.log( + "You can use the transaction details above to manually send, simulate, or audit the transaction." + ); } console.log("\nScript completed."); diff --git a/scripts/admin/send-execute.ts b/scripts/admin/send-execute.ts index a6c912e5..40698ea1 100644 --- a/scripts/admin/send-execute.ts +++ b/scripts/admin/send-execute.ts @@ -5,7 +5,7 @@ import { getAllAddresses, getOverrides, } from "../../src"; -import { mode, overrides } from "../deploy/config/config"; +import { mode } from "../deploy/config/config"; import SocketArtifact from "../../out/Socket.sol/Socket.json"; import { getProviderFromChainSlug } from "../constants"; import { ethers, Wallet } from "ethers"; @@ -31,7 +31,8 @@ dotenvConfig(); // Configuration object with execution and message details const EXECUTION_CONFIG = { executionDetails: { - packetId: "0x0000a4b129ebc834d24af22b9466a4150425354998c3e800000000000000cbe6", // Replace with actual packet ID + packetId: + "0x0000a4b129ebc834d24af22b9466a4150425354998c3e800000000000000cbe6", // Replace with actual packet ID proposalCount: "0", // Replace with actual proposal count executionGasLimit: "200000", // Replace with actual gas limit decapacitorProof: "0x", // Replace with actual proof @@ -40,8 +41,10 @@ const EXECUTION_CONFIG = { msgId: "0x0000a4b126e5ce884875ea3776a57f0b225b1ea8d2e9beeb00000000000608cb", // Replace with actual message ID executionFee: "0", // Replace with actual execution fee minMsgGasLimit: "100000", // Replace with actual min gas limit - executionParams: "0x0000000000000000000000000000000000000000000000000000000000000000", // Replace with actual execution params - payload: "0x0000000000000000000000008cb4c89cc297e07c7a309af8b16cc2f5f62a3b1300000000000000000000000000000000000000000000000000000000062ebe4d", // Replace with actual payload + executionParams: + "0x0000000000000000000000000000000000000000000000000000000000000000", // Replace with actual execution params + payload: + "0x0000000000000000000000008cb4c89cc297e07c7a309af8b16cc2f5f62a3b1300000000000000000000000000000000000000000000000000000000062ebe4d", // Replace with actual payload }, msgValue: "0", // ETH value to send with transaction (in wei) }; @@ -71,7 +74,9 @@ const addresses: DeploymentAddresses = getAllAddresses(mode); export const main = async () => { const destinationChain = parseInt(destinationChainSlug) as ChainSlug; - console.log(`\nProcessing execute transaction for chain: ${destinationChain}\n`); + console.log( + `\nProcessing execute transaction for chain: ${destinationChain}\n` + ); // Get addresses from prod_addresses.json const destinationAddresses = addresses[destinationChain]; @@ -90,21 +95,31 @@ export const main = async () => { console.log("Execution Configuration:"); console.log(" ExecutionDetails:"); console.log(` Packet ID: ${EXECUTION_CONFIG.executionDetails.packetId}`); - console.log(` Proposal Count: ${EXECUTION_CONFIG.executionDetails.proposalCount}`); - console.log(` Execution Gas Limit: ${EXECUTION_CONFIG.executionDetails.executionGasLimit}`); - console.log(` Decapacitor Proof: ${EXECUTION_CONFIG.executionDetails.decapacitorProof}`); + console.log( + ` Proposal Count: ${EXECUTION_CONFIG.executionDetails.proposalCount}` + ); + console.log( + ` Execution Gas Limit: ${EXECUTION_CONFIG.executionDetails.executionGasLimit}` + ); + console.log( + ` Decapacitor Proof: ${EXECUTION_CONFIG.executionDetails.decapacitorProof}` + ); console.log(" MessageDetails:"); console.log(` Message ID: ${EXECUTION_CONFIG.messageDetails.msgId}`); - console.log(` Execution Fee: ${EXECUTION_CONFIG.messageDetails.executionFee}`); - console.log(` Min Message Gas Limit: ${EXECUTION_CONFIG.messageDetails.minMsgGasLimit}`); - console.log(` Execution Params: ${EXECUTION_CONFIG.messageDetails.executionParams}`); + console.log( + ` Execution Fee: ${EXECUTION_CONFIG.messageDetails.executionFee}` + ); + console.log( + ` Min Message Gas Limit: ${EXECUTION_CONFIG.messageDetails.minMsgGasLimit}` + ); + console.log( + ` Execution Params: ${EXECUTION_CONFIG.messageDetails.executionParams}` + ); console.log(` Payload: ${EXECUTION_CONFIG.messageDetails.payload}`); console.log(` Message Value: ${EXECUTION_CONFIG.msgValue}\n`); // Get provider - const provider = getProviderFromChainSlug( - destinationChain - ); + const provider = getProviderFromChainSlug(destinationChain); // Get Socket contract to access hasher const socketContract = new ethers.Contract( @@ -119,15 +134,25 @@ export const main = async () => { // Get hasher contract const hasherAbi = [ - "function packMessage(uint32 srcChainSlug_, address srcPlug_, uint32 dstChainSlug_, address dstPlug_, tuple(bytes32 msgId, uint256 executionFee, uint256 minMsgGasLimit, bytes32 executionParams, bytes payload) messageDetails_) external pure returns (bytes32)" + "function packMessage(uint32 srcChainSlug_, address srcPlug_, uint32 dstChainSlug_, address dstPlug_, tuple(bytes32 msgId, uint256 executionFee, uint256 minMsgGasLimit, bytes32 executionParams, bytes payload) messageDetails_) external pure returns (bytes32)", ]; - const hasherContract = new ethers.Contract(hasherAddress, hasherAbi, provider); + const hasherContract = new ethers.Contract( + hasherAddress, + hasherAbi, + provider + ); // Extract chain slug and plug from msgId // msgId format: chainSlug (32 bits) | plug (160 bits) | messageCount (64 bits) const msgIdBigInt = BigInt(EXECUTION_CONFIG.messageDetails.msgId); - const srcChainSlug = Number((msgIdBigInt >> BigInt(224)) & BigInt(0xFFFFFFFF)); - const dstPlug = "0x" + ((msgIdBigInt >> BigInt(64)) & ((BigInt(1) << BigInt(160)) - BigInt(1))).toString(16).padStart(40, "0"); + const srcChainSlug = Number( + (msgIdBigInt >> BigInt(224)) & BigInt(0xffffffff) + ); + const dstPlug = + "0x" + + ((msgIdBigInt >> BigInt(64)) & ((BigInt(1) << BigInt(160)) - BigInt(1))) + .toString(16) + .padStart(40, "0"); console.log(`\nExtracted from msgId:`); console.log(` Source Chain Slug: ${srcChainSlug}`); @@ -164,7 +189,9 @@ export const main = async () => { // Sign with KMS console.log("\nSigning packed message with AWS KMS..."); - const signature = await kmsSigner.signMessage(ethers.utils.arrayify(packedMessage)); + const signature = await kmsSigner.signMessage( + ethers.utils.arrayify(packedMessage) + ); console.log("Signature:", signature); // Prepare transaction structs @@ -223,7 +250,9 @@ export const main = async () => { console.log("Gas used:", receipt.gasUsed.toString()); } else { console.log("To send the execute transaction, add --sendtx flag"); - console.log("You can use the transaction details above to manually send, simulate, or audit the transaction."); + console.log( + "You can use the transaction details above to manually send, simulate, or audit the transaction." + ); } console.log("\nScript completed."); diff --git a/scripts/constants/overrides.ts b/scripts/constants/overrides.ts index 46d2c73d..a96d2665 100644 --- a/scripts/constants/overrides.ts +++ b/scripts/constants/overrides.ts @@ -175,7 +175,7 @@ export const getOverrides = async ( const block = await provider.getBlock("latest"); const baseFee = block.baseFeePerGas?.toNumber() || 0; const maxPriorityFeePerGas = Math.max(maxFeePerGas - baseFee, 0); -console.log(chainSlug, gasLimit, maxFeePerGas, maxPriorityFeePerGas, type); + console.log(chainSlug, gasLimit, maxFeePerGas, maxPriorityFeePerGas, type); return { gasLimit, maxFeePerGas, maxPriorityFeePerGas, type }; } else { // Legacy transaction (type 0 or 1) diff --git a/scripts/deploy/helpers/send-msg/utils.ts b/scripts/deploy/helpers/send-msg/utils.ts index 34dd5331..364cdfd7 100644 --- a/scripts/deploy/helpers/send-msg/utils.ts +++ b/scripts/deploy/helpers/send-msg/utils.ts @@ -3,7 +3,7 @@ import { ethers } from "ethers"; import Counter from "../../../../out/Counter.sol/Counter.json"; import Socket from "../../../../out/Socket.sol/Socket.json"; import { ChainSlug } from "../../../../src"; -import { getAPIBaseURL, getAddresses, relayTx } from "../../utils"; +import { getAPIBaseURL, getAddresses, getStatus, relayTx } from "../../utils"; dotenvConfig(); import { formatEther } from "ethers/lib/utils"; @@ -129,15 +129,21 @@ export const sendCounterBridgeMsg = async ( let response = await relayTx({ to, data, - value, - gasLimit, - gasPrice, + value: value?.toString(), + gasLimit: gasLimit?.toString(), + gasPrice: gasPrice?.toString(), type, chainSlug, }); - console.log( - `Track message here: ${getAPIBaseURL( - mode - )}/messages-from-tx?srcChainSlug=${chainSlug}&srcTxHash=${response?.hash}` - ); + + console.log(`Tx Id: ${response?.txId}`); + const txHash = await getStatus(response?.txId); + + if (txHash) { + console.log( + `Track message here: ${getAPIBaseURL( + mode + )}/messages-from-tx?srcChainSlug=${chainSlug}&srcTxHash=${txHash}` + ); + } }; diff --git a/scripts/deploy/utils/relayer.ts b/scripts/deploy/utils/relayer.ts index 80a2abf1..b859b89d 100644 --- a/scripts/deploy/utils/relayer.ts +++ b/scripts/deploy/utils/relayer.ts @@ -1,6 +1,6 @@ import { BigNumber, BigNumberish } from "ethers"; import { getRelayAPIKEY, getRelayUrl } from "./utils"; -import { axiosPost } from "@socket.tech/dl-common"; +import { axiosGet, axiosPost } from "@socket.tech/dl-common"; import { mode } from "../config/config"; import { ChainSlugToId } from "../../../src"; @@ -17,7 +17,6 @@ interface RequestObj { export const relayTx = async (params: RequestObj) => { try { let { to, data, chainSlug, gasPrice, value, type, gasLimit } = params; - let url = await getRelayUrl(mode); let config = { headers: { "x-api-key": getRelayAPIKEY(mode), @@ -34,7 +33,26 @@ export const relayTx = async (params: RequestObj) => { sequential: false, source: "LoadTester", }; - let response = await axiosPost(url!, body, config); + let response = await axiosPost( + `${await getRelayUrl(mode)}/relay`, + body, + config + ); + if (response?.success) return response?.data; + else { + console.log("error in relaying tx", response); + return { hash: "" }; + } + } catch (error) { + console.log("uncaught error", error); + } +}; + +export const getStatus = async (txId: string) => { + try { + const response = await axiosGet( + `${await getRelayUrl(mode)}/status?txId=${txId}` + ); if (response?.success) return response?.data; else { console.log("error in relaying tx", response); diff --git a/scripts/deploy/utils/socket-signer.ts b/scripts/deploy/utils/socket-signer.ts index a62d9446..e728c364 100644 --- a/scripts/deploy/utils/socket-signer.ts +++ b/scripts/deploy/utils/socket-signer.ts @@ -34,7 +34,7 @@ export const getSocketSigner = async ( ChainSlugToId[chainSlug], safeAddress, safeWrapperAddress, - await getRelayUrl(mode), + `${await getRelayUrl(mode)}/relay`, getRelayAPIKEY(mode), wallet, useSafe, diff --git a/scripts/native-bridge-helpers/arbitrum/l1Tol2Relay.ts b/scripts/native-bridge-helpers/arbitrum/l1Tol2Relay.ts index 44e67aba..5705f1f6 100644 --- a/scripts/native-bridge-helpers/arbitrum/l1Tol2Relay.ts +++ b/scripts/native-bridge-helpers/arbitrum/l1Tol2Relay.ts @@ -19,16 +19,20 @@ import { L1ToL2MessageStatus, L1TransactionReceipt } from "@arbitrum/sdk"; // get providers for source and destination // replace following variables to initiate the txn -const l1Chain = HardhatChainName.GOERLI; -const l2Chain = HardhatChainName.ARBITRUM_GOERLI; +const l1Chain = HardhatChainName.SEPOLIA; +const l2Chain = HardhatChainName.ARBITRUM_SEPOLIA; const packetId = "0x00000005feb89935220606f3c3670ae510a74ab5750e810c0000000000000000"; const root = "0xc8111d45052c1df62037b92c1fab7c23bda80a0854b81432aee514aaf5f6c440"; const walletPrivateKey = process.env.SOCKET_SIGNER_KEY!; -const l1Provider = new providers.JsonRpcProvider(getJsonRpcUrl(l1Chain)); -const l2Provider = new providers.JsonRpcProvider(getJsonRpcUrl(l2Chain)); +const l1Provider = new providers.JsonRpcProvider( + getJsonRpcUrl(hardhatChainNameToSlug[l1Chain]) +); +const l2Provider = new providers.JsonRpcProvider( + getJsonRpcUrl(hardhatChainNameToSlug[l2Chain]) +); const l1Wallet = new Wallet(walletPrivateKey, l1Provider); const l2Wallet = new Wallet(walletPrivateKey, l2Provider); diff --git a/scripts/native-bridge-helpers/arbitrum/l2tol1Relay.ts b/scripts/native-bridge-helpers/arbitrum/l2tol1Relay.ts index aaa60a2b..e6fb5f6d 100644 --- a/scripts/native-bridge-helpers/arbitrum/l2tol1Relay.ts +++ b/scripts/native-bridge-helpers/arbitrum/l2tol1Relay.ts @@ -11,16 +11,20 @@ import { } from "../../../src"; // https://goerli.arbiscan.io/txsExit to check message status -const l1Chain = HardhatChainName.GOERLI; -const l2Chain = HardhatChainName.ARBITRUM_GOERLI; +const l1Chain = HardhatChainName.SEPOLIA; +const l2Chain = HardhatChainName.ARBITRUM_SEPOLIA; const sealTxHash = - "0x0113020a1e3b9f814a78791b9719bf583bb0f25075cde1e754af99f1dcf137a7"; + "0x4e8f4b180b2fbb5d06d637294776fda71025568bdb0cc31e2a430795e6481d54"; import { mode } from "../../deploy/config/config"; const walletPrivateKey = process.env.SOCKET_SIGNER_KEY!; -const l1Provider = new providers.JsonRpcProvider(getJsonRpcUrl(l1Chain)); -const l2Provider = new providers.JsonRpcProvider(getJsonRpcUrl(l2Chain)); +const l1Provider = new providers.JsonRpcProvider( + getJsonRpcUrl(hardhatChainNameToSlug[l1Chain]) +); +const l2Provider = new providers.JsonRpcProvider( + getJsonRpcUrl(hardhatChainNameToSlug[l2Chain]) +); const l1Wallet = new Wallet(walletPrivateKey, l1Provider); diff --git a/scripts/native-bridge-helpers/optimism/l1Tol2Relay.ts b/scripts/native-bridge-helpers/optimism/l1Tol2Relay.ts index 8dc236c6..478ff182 100644 --- a/scripts/native-bridge-helpers/optimism/l1Tol2Relay.ts +++ b/scripts/native-bridge-helpers/optimism/l1Tol2Relay.ts @@ -21,7 +21,9 @@ const ATTEST_GAS_LIMIT = 800000; const outboundTxHash = ""; const walletPrivateKey = process.env.SOCKET_SIGNER_KEY!; -const l1Provider = new providers.JsonRpcProvider(getJsonRpcUrl(localChain)); +const l1Provider = new providers.JsonRpcProvider( + getJsonRpcUrl(hardhatChainNameToSlug[localChain]) +); const l1Wallet = new Wallet(walletPrivateKey, l1Provider); export const main = async () => { @@ -45,7 +47,11 @@ export const main = async () => { // get socket contracts for both chains // counter l1, counter l2, seal, execute - const contracts = contractNames("", localChain, remoteChain); + const contracts = contractNames( + "", + hardhatChainNameToSlug[localChain], + hardhatChainNameToSlug[remoteChain] + ); const l1Capacitor: Contract = ( await getInstance( diff --git a/scripts/native-bridge-helpers/optimism/l2tol1Relay.ts b/scripts/native-bridge-helpers/optimism/l2tol1Relay.ts index dd348703..b4e52fa0 100644 --- a/scripts/native-bridge-helpers/optimism/l2tol1Relay.ts +++ b/scripts/native-bridge-helpers/optimism/l2tol1Relay.ts @@ -1,14 +1,20 @@ import { providers, Wallet } from "ethers"; import { CrossChainMessenger, MessageStatus } from "@eth-optimism/sdk"; import { getJsonRpcUrl } from "../../constants"; -import { HardhatChainName, ChainId } from "../../../src"; +import { + HardhatChainName, + ChainId, + hardhatChainNameToSlug, +} from "../../../src"; // get providers for source and destination const l1ChainId = ChainId.SEPOLIA; const l2ChainId = ChainId.OPTIMISM_SEPOLIA; const walletPrivateKey = process.env.SOCKET_SIGNER_KEY!; -const l1Provider = new providers.JsonRpcProvider(getJsonRpcUrl(l1ChainId)); +const l1Provider = new providers.JsonRpcProvider( + getJsonRpcUrl(hardhatChainNameToSlug[l1ChainId]) +); const l1Wallet = new Wallet(walletPrivateKey, l1Provider); const sealTxHash = ""; @@ -18,7 +24,9 @@ export const main = async () => { l1ChainId, l2ChainId, l1SignerOrProvider: l1Wallet, - l2SignerOrProvider: new providers.JsonRpcProvider(getJsonRpcUrl(l2ChainId)), + l2SignerOrProvider: new providers.JsonRpcProvider( + getJsonRpcUrl(hardhatChainNameToSlug[l2ChainId]) + ), }); const status = await crossChainMessenger.getMessageStatus(sealTxHash); diff --git a/scripts/native-bridge-helpers/optimism/op-stack-native-withdrawals.ts b/scripts/native-bridge-helpers/optimism/op-stack-native-withdrawals.ts index e177afb6..50e5136d 100644 --- a/scripts/native-bridge-helpers/optimism/op-stack-native-withdrawals.ts +++ b/scripts/native-bridge-helpers/optimism/op-stack-native-withdrawals.ts @@ -3,7 +3,7 @@ import { config as dotenvConfig } from "dotenv"; import { constants, providers, Wallet } from "ethers"; import { CrossChainMessenger, MessageStatus } from "@eth-optimism/sdk"; import { getJsonRpcUrl } from "../../constants"; -import { ChainId } from "../../../src"; +import { ChainId, hardhatChainNameToSlug } from "../../../src"; import { resolve } from "path"; import axios from "axios"; @@ -20,8 +20,12 @@ const initTxHash = "0x373611163c75ca063aae79fc7a8ef4a9d8e66603cc92997cbbcd2a18cbbcde37"; const walletPrivateKey = process.env.SOCKET_SIGNER_KEY!; -const l1Provider = new providers.JsonRpcProvider(getJsonRpcUrl(l1Chain)); -const l2Provider = new providers.JsonRpcProvider(getJsonRpcUrl(l2Chain)); +const l1Provider = new providers.JsonRpcProvider( + getJsonRpcUrl(hardhatChainNameToSlug[l1Chain]) +); +const l2Provider = new providers.JsonRpcProvider( + getJsonRpcUrl(hardhatChainNameToSlug[l2Chain]) +); const l1Wallet = new Wallet(walletPrivateKey, l1Provider); diff --git a/scripts/native-bridge-helpers/polygon/l2tol1Relay.ts b/scripts/native-bridge-helpers/polygon/l2tol1Relay.ts index 54c2a79b..851f3043 100644 --- a/scripts/native-bridge-helpers/polygon/l2tol1Relay.ts +++ b/scripts/native-bridge-helpers/polygon/l2tol1Relay.ts @@ -89,13 +89,14 @@ const remoteChain = HardhatChainName.MAINNET; const l2Provider = new providers.JsonRpcProvider(getJsonRpcUrl(localChain)); const l1Provider = new providers.JsonRpcProvider(getJsonRpcUrl(remoteChain)); + const l1Signer = new SocketRelaySigner( l1Provider, - process.env.RELAYER_URL_DEV! + `${process.env.RELAYER_URL_DEV!}/relay` ); const l2Signer = new SocketRelaySigner( l2Provider, - process.env.RELAYER_URL_DEV! + `${process.env.RELAYER_URL_DEV!}/relay` ); export const main = async () => { diff --git a/src/enums/native-tokens.ts b/src/enums/native-tokens.ts index ef5cd7f9..2901043e 100644 --- a/src/enums/native-tokens.ts +++ b/src/enums/native-tokens.ts @@ -21,4 +21,5 @@ export enum NativeTokens { "sei-network" = "sei-network", "dogwifcoin" = "dogwifcoin", "wormhole" = "wormhole", + "plasma" = "plasma", }