-
Notifications
You must be signed in to change notification settings - Fork 46
Bungee chains #422
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
Bungee chains #422
Changes from all commits
47eafc8
e00c928
45f7395
9ce502e
7e3704b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -139,3 +139,5 @@ HYPEREVM_RPC=' ' | |
| SEI_RPC=' ' | ||
|
|
||
| PLASMA_RPC=' ' | ||
|
|
||
| MONAD_RPC=' ' | ||
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,147 @@ | ||
| import { config as dotenvConfig } from "dotenv"; | ||
| import { | ||
| ChainSlug, | ||
| DeploymentAddresses, | ||
| IntegrationTypes, | ||
| getAllAddresses, | ||
| } from "../../src"; | ||
| import { mode } from "../deploy/config/config"; | ||
| import SingleCapacitorArtifact from "../../out/SingleCapacitor.sol/SingleCapacitor.json"; | ||
| import { getProviderFromChainSlug } from "../constants"; | ||
| import { ethers } from "ethers"; | ||
|
|
||
| dotenvConfig(); | ||
|
|
||
| /** | ||
| * Usage | ||
| * | ||
| * --source Specify the source chain slug. | ||
| * This flag is required. | ||
| * Eg. npx --source=1 --destination=10 --startblock=12345 --endblock=12456 ts-node scripts/admin/get-outbound-txs.ts | ||
| * | ||
| * --destination Specify the destination chain slug. | ||
| * This flag is required. | ||
| * | ||
| * --startblock Specify the start block number. | ||
| * This flag is required. | ||
| * | ||
| * --endblock Specify the end block number. | ||
| * This flag is required. | ||
| */ | ||
|
|
||
| const sourceChainSlug = process.env.npm_config_source; | ||
| if (!sourceChainSlug) { | ||
| console.error("Error: source flag is required"); | ||
| process.exit(1); | ||
| } | ||
|
|
||
| const destinationChainSlug = process.env.npm_config_destination; | ||
| if (!destinationChainSlug) { | ||
| console.error("Error: destination flag is required"); | ||
| process.exit(1); | ||
| } | ||
|
|
||
| const startBlock = process.env.npm_config_startblock; | ||
| if (!startBlock) { | ||
| console.error("Error: startblock flag is required"); | ||
| process.exit(1); | ||
| } | ||
|
|
||
| const endBlock = process.env.npm_config_endblock; | ||
| if (!endBlock) { | ||
| console.error("Error: endblock flag is required"); | ||
| process.exit(1); | ||
| } | ||
|
Comment on lines
+32
to
+54
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Validate and convert chain slugs to numbers immediately after extraction. The env vars are strings but need to be numeric ChainSlug values. Convert and validate them right after extraction to fail fast and ensure type safety throughout the script. Apply this diff: const sourceChainSlug = process.env.npm_config_source;
if (!sourceChainSlug) {
console.error("Error: source flag is required");
process.exit(1);
}
+const sourceChainSlugNum = parseInt(sourceChainSlug);
+if (isNaN(sourceChainSlugNum)) {
+ console.error(`Error: source must be a valid number, got: ${sourceChainSlug}`);
+ process.exit(1);
+}
const destinationChainSlug = process.env.npm_config_destination;
if (!destinationChainSlug) {
console.error("Error: destination flag is required");
process.exit(1);
}
+const destinationChainSlugNum = parseInt(destinationChainSlug);
+if (isNaN(destinationChainSlugNum)) {
+ console.error(`Error: destination must be a valid number, got: ${destinationChainSlug}`);
+ process.exit(1);
+}Then update lines 59-60 and 98 to use the numeric versions: - const sourceChain = sourceChainSlug;
- const destinationChain = destinationChainSlug;
+ const sourceChain = sourceChainSlugNum as ChainSlug;
+ const destinationChain = destinationChainSlugNum as ChainSlug;- const provider = getProviderFromChainSlug(parseInt(sourceChain) as ChainSlug);
+ const provider = getProviderFromChainSlug(sourceChain);
🤖 Prompt for AI Agents |
||
|
|
||
| const addresses: DeploymentAddresses = getAllAddresses(mode); | ||
|
|
||
| export const main = async () => { | ||
| const sourceChain = sourceChainSlug; | ||
| const destinationChain = destinationChainSlug; | ||
|
|
||
| console.log(`\nProcessing path: ${sourceChain} -> ${destinationChain}\n`); | ||
|
|
||
| // Get addresses from prod_addresses.json | ||
| const sourceAddresses = addresses[sourceChain]; | ||
| if (!sourceAddresses) { | ||
| console.error(`Error: No addresses found for source chain ${sourceChain}`); | ||
| process.exit(1); | ||
| } | ||
|
|
||
| const integration = sourceAddresses.integrations?.[destinationChain]; | ||
| if (!integration) { | ||
| console.error( | ||
| `Error: No integration found for ${sourceChain} -> ${destinationChain}` | ||
| ); | ||
| process.exit(1); | ||
| } | ||
|
|
||
| // Get FAST integration addresses (switchboard, socket, capacitor) | ||
| const fastIntegration = integration[IntegrationTypes.fast]; | ||
| if (!fastIntegration) { | ||
| console.error( | ||
| `Error: No FAST integration found for ${sourceChain} -> ${destinationChain}` | ||
| ); | ||
| process.exit(1); | ||
| } | ||
|
|
||
| const switchboardAddress = fastIntegration.switchboard; | ||
| const capacitorAddress = fastIntegration.capacitor; | ||
| const socketAddress = sourceAddresses.Socket; | ||
|
|
||
| console.log("Addresses:"); | ||
| console.log(` Switchboard: ${switchboardAddress}`); | ||
| console.log(` Socket: ${socketAddress}`); | ||
| console.log(` Capacitor: ${capacitorAddress}\n`); | ||
|
|
||
| // Get provider and query events | ||
| const provider = getProviderFromChainSlug(parseInt(sourceChain) as ChainSlug); | ||
|
|
||
| const capacitorContract = new ethers.Contract( | ||
| capacitorAddress, | ||
| SingleCapacitorArtifact.abi, | ||
| provider | ||
| ); | ||
|
|
||
| const fromBlock = parseInt(startBlock); | ||
| const toBlock = parseInt(endBlock); | ||
|
|
||
| console.log(`Querying events from block ${fromBlock} to ${toBlock}\n`); | ||
|
|
||
| // Query MessageAdded events in chunks of 5000 blocks | ||
| const CHUNK_SIZE = 5000; | ||
| const messageAddedEvents = []; | ||
|
|
||
| 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}`); | ||
|
|
||
| const events = await capacitorContract.queryFilter( | ||
| capacitorContract.filters.MessageAdded(), | ||
| currentBlock, | ||
| chunkEnd | ||
| ); | ||
|
|
||
| messageAddedEvents.push(...events); | ||
| } | ||
|
|
||
| console.log(`Found ${messageAddedEvents.length} outbound transactions:\n`); | ||
|
|
||
| for (const event of messageAddedEvents) { | ||
| console.log(`Block: ${event.blockNumber}`); | ||
| console.log(` Transaction Hash: ${event.transactionHash}`); | ||
| console.log(` Packed Message: ${event.args?.packedMessage}`); | ||
| console.log(` Packet Count: ${event.args?.packetCount?.toString()}`); | ||
| console.log(` Root Hash: ${event.args?.newRootHash}`); | ||
| console.log(""); | ||
| } | ||
|
|
||
| console.log("Script completed."); | ||
| }; | ||
|
|
||
| main() | ||
| .then(() => process.exit(0)) | ||
| .catch((error: Error) => { | ||
| console.error(error); | ||
| process.exit(1); | ||
| }); | ||
|
Comment on lines
+1
to
+147
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion | 🟠 Major Eliminate code duplication with get-seal-events.ts. This script shares ~95% identical code with Consider creating a shared helper like: // scripts/admin/utils/query-events.ts
export async function queryEventsForPath(
sourceChain: ChainSlug,
destinationChain: ChainSlug,
startBlock: number,
endBlock: number,
contractType: 'Socket' | 'SingleCapacitor',
eventName: string
) {
// Common logic here
}Then both scripts become simple wrappers: // get-outbound-txs.ts
const result = await queryEventsForPath(
sourceChain,
destinationChain,
startBlock,
endBlock,
'SingleCapacitor',
'MessageAdded'
);🤖 Prompt for AI Agents |
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧩 Analysis chain
Verify Etherscan API endpoint supports MONAD chain ID 143.
The
apiURLuseshttps://api.etherscan.io/v2/api?chainid=143, which routes through Etherscan's infrastructure. MONAD is a separate L1 blockchain - verify that Etherscan actually indexes MONAD (chain ID 143) before contracts can be verified on mainnet.If Etherscan doesn't support MONAD yet, this configuration will fail during contract verification with
hardhat verify.Alternatively, search for Etherscan's supported chains:
🏁 Script executed:
Length of output: 292
🌐 Web query:
💡 Result:
Short answer: No — Etherscan API v2 does not list Monad mainnet (chain ID 143) as a supported chain; it lists Monad testnet (chain ID 10143). [1][2][3]
Sources:
This configuration will fail contract verification—Etherscan API v2 doesn't support MONAD mainnet (chain ID 143).
Etherscan API v2 only supports Monad testnet (chain ID 10143), not mainnet (chain ID 143). The
apiURLpointing to Etherscan will return errors when users attempthardhat verifyfor MONAD mainnet contracts. Either:🤖 Prompt for AI Agents