diff --git a/CLAUDE.md b/CLAUDE.md index a21d5d7..ded2d53 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -25,7 +25,7 @@ npm run test:watch # Watch mode The SDK exports three entry points (see `package.json` exports): - `genlayer-js` - Main: client, accounts, transaction decoders, staking utils -- `genlayer-js/chains` - Chain configs: `localnet`, `studionet`, `testnetAsimov` +- `genlayer-js/chains` - Chain configs: `localnet`, `studionet`, `testnetAsimov`, `testnetBradbury` - `genlayer-js/types` - TypeScript types for all SDK entities ### Client Factory Pattern @@ -45,7 +45,7 @@ Each action module (`src//actions.ts`) returns an object of methods that `GenLayerChain` extends viem's `Chain` with GenLayer-specific properties: - `isStudio` - Whether using studio-based localnet - `consensusMainContract` / `consensusDataContract` - On-chain consensus contracts -- `stakingContract` - Staking contract (testnet-asimov only) +- `stakingContract` - Staking contract (testnet-bradbury and testnet-asimov) - `defaultNumberOfInitialValidators` / `defaultConsensusMaxRotations` ### Calldata Encoding diff --git a/README.md b/README.md index 89d8ce0..55e8a1c 100644 --- a/README.md +++ b/README.md @@ -108,15 +108,15 @@ const receipt = await client.waitForTransactionReceipt({ ``` ### Staking Operations -The SDK provides staking functionality for validators and delegators on testnet-asimov. +The SDK provides staking functionality for validators and delegators on testnet-bradbury (and testnet-asimov). ```typescript -import { testnetAsimov } from 'genlayer-js/chains'; +import { testnetBradbury } from 'genlayer-js/chains'; import { createClient, createAccount } from "genlayer-js"; const account = createAccount(); const client = createClient({ - chain: testnetAsimov, + chain: testnetBradbury, account, }); @@ -160,7 +160,7 @@ const delegateResult = await client.delegatorJoin({ * **Client Creation**: Easily create and configure a client to connect to GenLayer's network. * **Transaction Handling**: Send and manage transactions on the GenLayer network. -* **Staking**: Full staking support for validators and delegators on testnet-asimov. +* **Staking**: Full staking support for validators and delegators on testnet-bradbury and testnet-asimov. * **Wallet Integration***: Seamless integration with MetaMask for managing user accounts. * **Gas Estimation***: Estimate gas fees for executing transactions on GenLayer. diff --git a/src/chains/index.ts b/src/chains/index.ts index 3423f3d..6979228 100644 --- a/src/chains/index.ts +++ b/src/chains/index.ts @@ -2,3 +2,4 @@ export {localnet} from "./localnet"; export {studionet} from "./studionet"; export {testnetAsimov} from "./testnetAsimov"; +export {testnetBradbury} from "./testnetBradbury"; diff --git a/src/chains/testnetBradbury.ts b/src/chains/testnetBradbury.ts new file mode 100644 index 0000000..5614944 --- /dev/null +++ b/src/chains/testnetBradbury.ts @@ -0,0 +1,3358 @@ +import {Address, defineChain} from "viem"; +import {GenLayerChain} from "@/types"; +import {STAKING_ABI} from "@/abi/staking"; + +const TESTNET_JSON_RPC_URL = "https://zksync-os-testnet-genlayer.zksync.dev"; +const TESTNET_WS_URL = "wss://zksync-os-testnet-genlayer.zksync.dev/ws"; + +const STAKING_CONTRACT = { + address: "0x4A4449E617F8D10FDeD0b461CadEf83939E821A5" as Address, + abi: STAKING_ABI, +}; +const EXPLORER_URL = "https://explorer-bradbury.genlayer.com/"; +const CONSENSUS_MAIN_CONTRACT = { + address: "0x0112Bf6e83497965A5fdD6Dad1E447a6E004271D" as Address, + abi: [ + { + "inputs": [], + "stateMutability": "nonpayable", + "type": "constructor" + }, + { + "inputs": [], + "name": "CallerNotMessages", + "type": "error" + }, + { + "inputs": [], + "name": "CanNotAppeal", + "type": "error" + }, + { + "inputs": [], + "name": "InvalidDeploymentWithSalt", + "type": "error" + }, + { + "inputs": [], + "name": "InvalidGhostContract", + "type": "error" + }, + { + "inputs": [], + "name": "InvalidInitialization", + "type": "error" + }, + { + "inputs": [], + "name": "InvalidRevealLeaderData", + "type": "error" + }, + { + "inputs": [], + "name": "InvalidVote", + "type": "error" + }, + { + "inputs": [], + "name": "NotInitializing", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "owner", + "type": "address" + } + ], + "name": "OwnableInvalidOwner", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "account", + "type": "address" + } + ], + "name": "OwnableUnauthorizedAccount", + "type": "error" + }, + { + "inputs": [], + "name": "ReentrancyGuardReentrantCall", + "type": "error" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "bytes32", + "name": "txId", + "type": "bytes32" + }, + { + "indexed": true, + "internalType": "address", + "name": "oldActivator", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "newActivator", + "type": "address" + } + ], + "name": "ActivatorReplaced", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "addressManager", + "type": "address" + } + ], + "name": "AddressManagerSet", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "bytes32", + "name": "txId", + "type": "bytes32" + }, + { + "indexed": false, + "internalType": "enum ITransactions.TransactionStatus", + "name": "newStatus", + "type": "uint8" + } + ], + "name": "AllVotesCommitted", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "bytes32", + "name": "txId", + "type": "bytes32" + }, + { + "indexed": true, + "internalType": "address", + "name": "appellant", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "bond", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "address[]", + "name": "validators", + "type": "address[]" + } + ], + "name": "AppealStarted", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint256", + "name": "attempted", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "succeeded", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "failed", + "type": "uint256" + } + ], + "name": "BatchFinalizationCompleted", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "bytes32", + "name": "txId", + "type": "bytes32" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "txSlot", + "type": "uint256" + } + ], + "name": "CreatedTransaction", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint64", + "name": "version", + "type": "uint64" + } + ], + "name": "Initialized", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "bytes32", + "name": "txId", + "type": "bytes32" + }, + { + "indexed": true, + "internalType": "address", + "name": "recipient", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "activator", + "type": "address" + } + ], + "name": "InternalMessageProcessed", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "bytes32", + "name": "txId", + "type": "bytes32" + }, + { + "indexed": true, + "internalType": "address", + "name": "oldLeader", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "newLeader", + "type": "address" + } + ], + "name": "LeaderIdlenessProcessed", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "bytes32", + "name": "txId", + "type": "bytes32" + }, + { + "indexed": true, + "internalType": "address", + "name": "recipient", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "activator", + "type": "address" + } + ], + "name": "NewTransaction", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "previousOwner", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "newOwner", + "type": "address" + } + ], + "name": "OwnershipTransferStarted", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "previousOwner", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "newOwner", + "type": "address" + } + ], + "name": "OwnershipTransferred", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "bytes32", + "name": "txId", + "type": "bytes32" + } + ], + "name": "ProcessIdlenessAccepted", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "bytes32", + "name": "txId", + "type": "bytes32" + } + ], + "name": "TransactionAccepted", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "bytes32", + "name": "txId", + "type": "bytes32" + }, + { + "indexed": true, + "internalType": "address", + "name": "leader", + "type": "address" + } + ], + "name": "TransactionActivated", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "bytes32", + "name": "txId", + "type": "bytes32" + }, + { + "indexed": true, + "internalType": "address", + "name": "cancelledBy", + "type": "address" + } + ], + "name": "TransactionCancelled", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "bytes32", + "name": "txId", + "type": "bytes32" + } + ], + "name": "TransactionFinalizationFailed", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "bytes32", + "name": "txId", + "type": "bytes32" + } + ], + "name": "TransactionFinalized", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "bytes32", + "name": "txId", + "type": "bytes32" + } + ], + "name": "TransactionLeaderRevealed", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "bytes32", + "name": "txId", + "type": "bytes32" + }, + { + "indexed": true, + "internalType": "address", + "name": "newLeader", + "type": "address" + } + ], + "name": "TransactionLeaderRotated", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "bytes32", + "name": "txId", + "type": "bytes32" + } + ], + "name": "TransactionLeaderTimeout", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "bytes32[]", + "name": "txIds", + "type": "bytes32[]" + } + ], + "name": "TransactionNeedsRecomputation", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "bytes32", + "name": "txId", + "type": "bytes32" + }, + { + "indexed": false, + "internalType": "address[]", + "name": "validators", + "type": "address[]" + } + ], + "name": "TransactionReceiptProposed", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "bytes32", + "name": "txId", + "type": "bytes32" + } + ], + "name": "TransactionUndetermined", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "bytes32", + "name": "txId", + "type": "bytes32" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "tribunalIndex", + "type": "uint256" + }, + { + "indexed": true, + "internalType": "address", + "name": "validator", + "type": "address" + } + ], + "name": "TribunalAppealVoteCommitted", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "bytes32", + "name": "txId", + "type": "bytes32" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "tribunalIndex", + "type": "uint256" + }, + { + "indexed": true, + "internalType": "address", + "name": "validator", + "type": "address" + }, + { + "indexed": false, + "internalType": "enum ITransactions.VoteType", + "name": "voteType", + "type": "uint8" + } + ], + "name": "TribunalAppealVoteRevealed", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "bytes32", + "name": "txId", + "type": "bytes32" + }, + { + "indexed": true, + "internalType": "address", + "name": "oldValidator", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "newValidator", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "validatorIndex", + "type": "uint256" + } + ], + "name": "ValidatorReplaced", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "bytes32", + "name": "txId", + "type": "bytes32" + }, + { + "indexed": true, + "internalType": "address", + "name": "recipient", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "value", + "type": "uint256" + } + ], + "name": "ValueWithdrawalFailed", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "bytes32", + "name": "txId", + "type": "bytes32" + }, + { + "indexed": true, + "internalType": "address", + "name": "validator", + "type": "address" + }, + { + "indexed": false, + "internalType": "bool", + "name": "isLastVote", + "type": "bool" + } + ], + "name": "VoteCommitted", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "bytes32", + "name": "txId", + "type": "bytes32" + }, + { + "indexed": true, + "internalType": "address", + "name": "validator", + "type": "address" + }, + { + "indexed": false, + "internalType": "enum ITransactions.VoteType", + "name": "voteType", + "type": "uint8" + }, + { + "indexed": false, + "internalType": "bool", + "name": "isLastVote", + "type": "bool" + }, + { + "indexed": false, + "internalType": "enum ITransactions.ResultType", + "name": "result", + "type": "uint8" + } + ], + "name": "VoteRevealed", + "type": "event" + }, + { + "inputs": [], + "name": "EVENTS_BATCH_SIZE", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "VERSION", + "outputs": [ + { + "internalType": "string", + "name": "", + "type": "string" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "acceptOwnership", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes32", + "name": "_txId", + "type": "bytes32" + }, + { + "internalType": "address", + "name": "_operator", + "type": "address" + }, + { + "internalType": "bytes", + "name": "_vrfProof", + "type": "bytes" + } + ], + "name": "activateTransaction", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_sender", + "type": "address" + }, + { + "internalType": "address", + "name": "_recipient", + "type": "address" + }, + { + "internalType": "uint256", + "name": "_numOfInitialValidators", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "_maxRotations", + "type": "uint256" + }, + { + "internalType": "bytes", + "name": "_calldata", + "type": "bytes" + }, + { + "internalType": "uint256", + "name": "_validUntil", + "type": "uint256" + } + ], + "name": "addTransaction", + "outputs": [], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [], + "name": "addressManager", + "outputs": [ + { + "internalType": "contract IAddressManager", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes32", + "name": "_txId", + "type": "bytes32" + } + ], + "name": "cancelTransaction", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes32", + "name": "_txId", + "type": "bytes32" + }, + { + "internalType": "uint256", + "name": "_tribunalIndex", + "type": "uint256" + }, + { + "internalType": "bytes32", + "name": "_commitHash", + "type": "bytes32" + } + ], + "name": "commitTribunalAppealVote", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes32", + "name": "_txId", + "type": "bytes32" + }, + { + "internalType": "bytes32", + "name": "_commitHash", + "type": "bytes32" + }, + { + "internalType": "uint256", + "name": "_validatorIndex", + "type": "uint256" + } + ], + "name": "commitVote", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_sender", + "type": "address" + }, + { + "internalType": "uint256", + "name": "_numOfInitialValidators", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "_maxRotations", + "type": "uint256" + }, + { + "internalType": "bytes", + "name": "_calldata", + "type": "bytes" + }, + { + "internalType": "uint256", + "name": "_saltNonce", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "_validUntil", + "type": "uint256" + } + ], + "name": "deploySalted", + "outputs": [], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_recipient", + "type": "address" + }, + { + "internalType": "uint256", + "name": "_value", + "type": "uint256" + }, + { + "internalType": "bytes", + "name": "_data", + "type": "bytes" + } + ], + "name": "executeMessage", + "outputs": [ + { + "internalType": "bool", + "name": "success", + "type": "bool" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes32[]", + "name": "_txIds", + "type": "bytes32[]" + } + ], + "name": "finalizeIdlenessTxs", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes32", + "name": "_txId", + "type": "bytes32" + } + ], + "name": "finalizeTransaction", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes32", + "name": "_txId", + "type": "bytes32" + } + ], + "name": "flushExternalMessages", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "getAddressManager", + "outputs": [ + { + "internalType": "contract IAddressManager", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes32", + "name": "txId", + "type": "bytes32" + } + ], + "name": "getPendingTransactionValue", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_addressManager", + "type": "address" + } + ], + "name": "initialize", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "addr", + "type": "address" + } + ], + "name": "isGhostContract", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes32", + "name": "_txId", + "type": "bytes32" + } + ], + "name": "leaderIdleness", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "components": [ + { + "internalType": "bytes32", + "name": "txId", + "type": "bytes32" + }, + { + "internalType": "uint256", + "name": "saltAsAValidator", + "type": "uint256" + }, + { + "internalType": "bytes32", + "name": "txExecutionHash", + "type": "bytes32" + }, + { + "internalType": "bytes32", + "name": "messagesAndOtherFieldsHash", + "type": "bytes32" + }, + { + "internalType": "bytes32", + "name": "otherExecutionFieldsHash", + "type": "bytes32" + }, + { + "internalType": "enum ITransactions.VoteType", + "name": "resultValue", + "type": "uint8" + }, + { + "components": [ + { + "internalType": "enum IMessages.MessageType", + "name": "messageType", + "type": "uint8" + }, + { + "internalType": "address", + "name": "recipient", + "type": "address" + }, + { + "internalType": "uint256", + "name": "value", + "type": "uint256" + }, + { + "internalType": "bytes", + "name": "data", + "type": "bytes" + }, + { + "internalType": "bool", + "name": "onAcceptance", + "type": "bool" + }, + { + "internalType": "uint256", + "name": "saltNonce", + "type": "uint256" + } + ], + "internalType": "struct IMessages.SubmittedMessage[]", + "name": "messages", + "type": "tuple[]" + } + ], + "internalType": "struct IConsensusMain.LeaderRevealVoteParams", + "name": "leaderRevealVoteParams", + "type": "tuple" + } + ], + "name": "leaderRevealVote", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "owner", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "pendingOwner", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes32", + "name": "_txId", + "type": "bytes32" + } + ], + "name": "processIdleness", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes32", + "name": "_txId", + "type": "bytes32" + }, + { + "internalType": "bytes32", + "name": "_txExecutionHash", + "type": "bytes32" + }, + { + "internalType": "uint256", + "name": "_processingBlock", + "type": "uint256" + }, + { + "internalType": "address", + "name": "_operator", + "type": "address" + }, + { + "internalType": "bytes", + "name": "_eqBlocksOutputs", + "type": "bytes" + }, + { + "internalType": "bytes", + "name": "_vrfProof", + "type": "bytes" + } + ], + "name": "proposeReceipt", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes32[]", + "name": "_txIds", + "type": "bytes32[]" + } + ], + "name": "redButtonFinalize", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "ghost", + "type": "address" + } + ], + "name": "registerGhostContract", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "renounceOwnership", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes32", + "name": "_txId", + "type": "bytes32" + }, + { + "internalType": "uint256", + "name": "_tribunalIndex", + "type": "uint256" + }, + { + "internalType": "bytes32", + "name": "_voteHash", + "type": "bytes32" + }, + { + "internalType": "enum ITransactions.VoteType", + "name": "_voteType", + "type": "uint8" + }, + { + "internalType": "bytes32", + "name": "_otherExecutionFieldsHash", + "type": "bytes32" + }, + { + "internalType": "uint256", + "name": "_nonce", + "type": "uint256" + } + ], + "name": "revealTribunalAppealVote", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes32", + "name": "_txId", + "type": "bytes32" + }, + { + "internalType": "bytes32", + "name": "_voteHash", + "type": "bytes32" + }, + { + "internalType": "enum ITransactions.VoteType", + "name": "_voteType", + "type": "uint8" + }, + { + "internalType": "bytes32", + "name": "_otherExecutionFieldsHash", + "type": "bytes32" + }, + { + "internalType": "uint256", + "name": "_nonce", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "_validatorIndex", + "type": "uint256" + } + ], + "name": "revealVote", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_addressManager", + "type": "address" + } + ], + "name": "setAddressManager", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes32", + "name": "_txId", + "type": "bytes32" + } + ], + "name": "submitAppeal", + "outputs": [], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "newOwner", + "type": "address" + } + ], + "name": "transferOwnership", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "stateMutability": "payable", + "type": "receive" + } +], + bytecode: "", +}; + +const CONSENSUS_DATA_CONTRACT = { + address: "0x85D7bf947A512Fc640C75327A780c90847267697" as Address, + abi: [ + { + "inputs": [], + "name": "AccessControlBadConfirmation", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "account", + "type": "address" + }, + { + "internalType": "bytes32", + "name": "neededRole", + "type": "bytes32" + } + ], + "name": "AccessControlUnauthorizedAccount", + "type": "error" + }, + { + "inputs": [], + "name": "InvalidInitialization", + "type": "error" + }, + { + "inputs": [], + "name": "NotInitializing", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "owner", + "type": "address" + } + ], + "name": "OwnableInvalidOwner", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "account", + "type": "address" + } + ], + "name": "OwnableUnauthorizedAccount", + "type": "error" + }, + { + "inputs": [], + "name": "ReentrancyGuardReentrantCall", + "type": "error" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint64", + "name": "version", + "type": "uint64" + } + ], + "name": "Initialized", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "previousOwner", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "newOwner", + "type": "address" + } + ], + "name": "OwnershipTransferStarted", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "previousOwner", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "newOwner", + "type": "address" + } + ], + "name": "OwnershipTransferred", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "bytes32", + "name": "role", + "type": "bytes32" + }, + { + "indexed": true, + "internalType": "bytes32", + "name": "previousAdminRole", + "type": "bytes32" + }, + { + "indexed": true, + "internalType": "bytes32", + "name": "newAdminRole", + "type": "bytes32" + } + ], + "name": "RoleAdminChanged", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "bytes32", + "name": "role", + "type": "bytes32" + }, + { + "indexed": true, + "internalType": "address", + "name": "account", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "sender", + "type": "address" + } + ], + "name": "RoleGranted", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "bytes32", + "name": "role", + "type": "bytes32" + }, + { + "indexed": true, + "internalType": "address", + "name": "account", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "sender", + "type": "address" + } + ], + "name": "RoleRevoked", + "type": "event" + }, + { + "inputs": [], + "name": "DEFAULT_ADMIN_ROLE", + "outputs": [ + { + "internalType": "bytes32", + "name": "", + "type": "bytes32" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "acceptOwnership", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "addressManager", + "outputs": [ + { + "internalType": "contract IAddressManager", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes32", + "name": "_txId", + "type": "bytes32" + }, + { + "internalType": "uint256", + "name": "_currentTimestamp", + "type": "uint256" + } + ], + "name": "canFinalize", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + }, + { + "internalType": "uint256", + "name": "", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "recipient", + "type": "address" + } + ], + "name": "getLatestAcceptedTransaction", + "outputs": [ + { + "components": [ + { + "internalType": "uint256", + "name": "currentTimestamp", + "type": "uint256" + }, + { + "internalType": "address", + "name": "sender", + "type": "address" + }, + { + "internalType": "address", + "name": "recipient", + "type": "address" + }, + { + "internalType": "uint256", + "name": "initialRotations", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "txSlot", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "createdTimestamp", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "lastVoteTimestamp", + "type": "uint256" + }, + { + "internalType": "bytes32", + "name": "randomSeed", + "type": "bytes32" + }, + { + "internalType": "enum ITransactions.ResultType", + "name": "result", + "type": "uint8" + }, + { + "internalType": "bytes32", + "name": "txExecutionHash", + "type": "bytes32" + }, + { + "internalType": "bytes", + "name": "txCalldata", + "type": "bytes" + }, + { + "internalType": "bytes", + "name": "eqBlocksOutputs", + "type": "bytes" + }, + { + "components": [ + { + "internalType": "enum IMessages.MessageType", + "name": "messageType", + "type": "uint8" + }, + { + "internalType": "address", + "name": "recipient", + "type": "address" + }, + { + "internalType": "uint256", + "name": "value", + "type": "uint256" + }, + { + "internalType": "bytes", + "name": "data", + "type": "bytes" + }, + { + "internalType": "bool", + "name": "onAcceptance", + "type": "bool" + }, + { + "internalType": "uint256", + "name": "saltNonce", + "type": "uint256" + } + ], + "internalType": "struct IMessages.SubmittedMessage[]", + "name": "messages", + "type": "tuple[]" + }, + { + "internalType": "enum IQueues.QueueType", + "name": "queueType", + "type": "uint8" + }, + { + "internalType": "uint256", + "name": "queuePosition", + "type": "uint256" + }, + { + "internalType": "address", + "name": "activator", + "type": "address" + }, + { + "internalType": "address", + "name": "lastLeader", + "type": "address" + }, + { + "internalType": "enum ITransactions.TransactionStatus", + "name": "status", + "type": "uint8" + }, + { + "internalType": "bytes32", + "name": "txId", + "type": "bytes32" + }, + { + "components": [ + { + "internalType": "uint256", + "name": "activationBlock", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "processingBlock", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "proposalBlock", + "type": "uint256" + } + ], + "internalType": "struct ITransactions.ReadStateBlockRange", + "name": "readStateBlockRange", + "type": "tuple" + }, + { + "internalType": "uint256", + "name": "numOfRounds", + "type": "uint256" + }, + { + "components": [ + { + "internalType": "uint256", + "name": "round", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "leaderIndex", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "votesCommitted", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "votesRevealed", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "appealBond", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "rotationsLeft", + "type": "uint256" + }, + { + "internalType": "enum ITransactions.ResultType", + "name": "result", + "type": "uint8" + }, + { + "internalType": "address[]", + "name": "roundValidators", + "type": "address[]" + }, + { + "internalType": "enum ITransactions.VoteType[]", + "name": "validatorVotes", + "type": "uint8[]" + }, + { + "internalType": "bytes32[]", + "name": "validatorVotesHash", + "type": "bytes32[]" + }, + { + "internalType": "bytes32[]", + "name": "validatorResultHash", + "type": "bytes32[]" + } + ], + "internalType": "struct ITransactions.RoundData", + "name": "lastRound", + "type": "tuple" + }, + { + "internalType": "address[]", + "name": "consumedValidators", + "type": "address[]" + } + ], + "internalType": "struct ConsensusData.TransactionData", + "name": "inputData", + "type": "tuple" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "recipient", + "type": "address" + }, + { + "internalType": "uint256", + "name": "startIndex", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "pageSize", + "type": "uint256" + } + ], + "name": "getLatestAcceptedTransactions", + "outputs": [ + { + "components": [ + { + "internalType": "uint256", + "name": "currentTimestamp", + "type": "uint256" + }, + { + "internalType": "address", + "name": "sender", + "type": "address" + }, + { + "internalType": "address", + "name": "recipient", + "type": "address" + }, + { + "internalType": "uint256", + "name": "initialRotations", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "txSlot", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "createdTimestamp", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "lastVoteTimestamp", + "type": "uint256" + }, + { + "internalType": "bytes32", + "name": "randomSeed", + "type": "bytes32" + }, + { + "internalType": "enum ITransactions.ResultType", + "name": "result", + "type": "uint8" + }, + { + "internalType": "bytes32", + "name": "txExecutionHash", + "type": "bytes32" + }, + { + "internalType": "bytes", + "name": "txCalldata", + "type": "bytes" + }, + { + "internalType": "bytes", + "name": "eqBlocksOutputs", + "type": "bytes" + }, + { + "components": [ + { + "internalType": "enum IMessages.MessageType", + "name": "messageType", + "type": "uint8" + }, + { + "internalType": "address", + "name": "recipient", + "type": "address" + }, + { + "internalType": "uint256", + "name": "value", + "type": "uint256" + }, + { + "internalType": "bytes", + "name": "data", + "type": "bytes" + }, + { + "internalType": "bool", + "name": "onAcceptance", + "type": "bool" + }, + { + "internalType": "uint256", + "name": "saltNonce", + "type": "uint256" + } + ], + "internalType": "struct IMessages.SubmittedMessage[]", + "name": "messages", + "type": "tuple[]" + }, + { + "internalType": "enum IQueues.QueueType", + "name": "queueType", + "type": "uint8" + }, + { + "internalType": "uint256", + "name": "queuePosition", + "type": "uint256" + }, + { + "internalType": "address", + "name": "activator", + "type": "address" + }, + { + "internalType": "address", + "name": "lastLeader", + "type": "address" + }, + { + "internalType": "enum ITransactions.TransactionStatus", + "name": "status", + "type": "uint8" + }, + { + "internalType": "bytes32", + "name": "txId", + "type": "bytes32" + }, + { + "components": [ + { + "internalType": "uint256", + "name": "activationBlock", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "processingBlock", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "proposalBlock", + "type": "uint256" + } + ], + "internalType": "struct ITransactions.ReadStateBlockRange", + "name": "readStateBlockRange", + "type": "tuple" + }, + { + "internalType": "uint256", + "name": "numOfRounds", + "type": "uint256" + }, + { + "components": [ + { + "internalType": "uint256", + "name": "round", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "leaderIndex", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "votesCommitted", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "votesRevealed", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "appealBond", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "rotationsLeft", + "type": "uint256" + }, + { + "internalType": "enum ITransactions.ResultType", + "name": "result", + "type": "uint8" + }, + { + "internalType": "address[]", + "name": "roundValidators", + "type": "address[]" + }, + { + "internalType": "enum ITransactions.VoteType[]", + "name": "validatorVotes", + "type": "uint8[]" + }, + { + "internalType": "bytes32[]", + "name": "validatorVotesHash", + "type": "bytes32[]" + }, + { + "internalType": "bytes32[]", + "name": "validatorResultHash", + "type": "bytes32[]" + } + ], + "internalType": "struct ITransactions.RoundData", + "name": "lastRound", + "type": "tuple" + }, + { + "internalType": "address[]", + "name": "consumedValidators", + "type": "address[]" + } + ], + "internalType": "struct ConsensusData.TransactionData[]", + "name": "", + "type": "tuple[]" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "recipient", + "type": "address" + } + ], + "name": "getLatestAcceptedTxCount", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "recipient", + "type": "address" + } + ], + "name": "getLatestFinalizedTransaction", + "outputs": [ + { + "components": [ + { + "internalType": "uint256", + "name": "currentTimestamp", + "type": "uint256" + }, + { + "internalType": "address", + "name": "sender", + "type": "address" + }, + { + "internalType": "address", + "name": "recipient", + "type": "address" + }, + { + "internalType": "uint256", + "name": "initialRotations", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "txSlot", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "createdTimestamp", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "lastVoteTimestamp", + "type": "uint256" + }, + { + "internalType": "bytes32", + "name": "randomSeed", + "type": "bytes32" + }, + { + "internalType": "enum ITransactions.ResultType", + "name": "result", + "type": "uint8" + }, + { + "internalType": "bytes32", + "name": "txExecutionHash", + "type": "bytes32" + }, + { + "internalType": "bytes", + "name": "txCalldata", + "type": "bytes" + }, + { + "internalType": "bytes", + "name": "eqBlocksOutputs", + "type": "bytes" + }, + { + "components": [ + { + "internalType": "enum IMessages.MessageType", + "name": "messageType", + "type": "uint8" + }, + { + "internalType": "address", + "name": "recipient", + "type": "address" + }, + { + "internalType": "uint256", + "name": "value", + "type": "uint256" + }, + { + "internalType": "bytes", + "name": "data", + "type": "bytes" + }, + { + "internalType": "bool", + "name": "onAcceptance", + "type": "bool" + }, + { + "internalType": "uint256", + "name": "saltNonce", + "type": "uint256" + } + ], + "internalType": "struct IMessages.SubmittedMessage[]", + "name": "messages", + "type": "tuple[]" + }, + { + "internalType": "enum IQueues.QueueType", + "name": "queueType", + "type": "uint8" + }, + { + "internalType": "uint256", + "name": "queuePosition", + "type": "uint256" + }, + { + "internalType": "address", + "name": "activator", + "type": "address" + }, + { + "internalType": "address", + "name": "lastLeader", + "type": "address" + }, + { + "internalType": "enum ITransactions.TransactionStatus", + "name": "status", + "type": "uint8" + }, + { + "internalType": "bytes32", + "name": "txId", + "type": "bytes32" + }, + { + "components": [ + { + "internalType": "uint256", + "name": "activationBlock", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "processingBlock", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "proposalBlock", + "type": "uint256" + } + ], + "internalType": "struct ITransactions.ReadStateBlockRange", + "name": "readStateBlockRange", + "type": "tuple" + }, + { + "internalType": "uint256", + "name": "numOfRounds", + "type": "uint256" + }, + { + "components": [ + { + "internalType": "uint256", + "name": "round", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "leaderIndex", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "votesCommitted", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "votesRevealed", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "appealBond", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "rotationsLeft", + "type": "uint256" + }, + { + "internalType": "enum ITransactions.ResultType", + "name": "result", + "type": "uint8" + }, + { + "internalType": "address[]", + "name": "roundValidators", + "type": "address[]" + }, + { + "internalType": "enum ITransactions.VoteType[]", + "name": "validatorVotes", + "type": "uint8[]" + }, + { + "internalType": "bytes32[]", + "name": "validatorVotesHash", + "type": "bytes32[]" + }, + { + "internalType": "bytes32[]", + "name": "validatorResultHash", + "type": "bytes32[]" + } + ], + "internalType": "struct ITransactions.RoundData", + "name": "lastRound", + "type": "tuple" + }, + { + "internalType": "address[]", + "name": "consumedValidators", + "type": "address[]" + } + ], + "internalType": "struct ConsensusData.TransactionData", + "name": "inputData", + "type": "tuple" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "recipient", + "type": "address" + }, + { + "internalType": "uint256", + "name": "startIndex", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "pageSize", + "type": "uint256" + } + ], + "name": "getLatestFinalizedTransactions", + "outputs": [ + { + "components": [ + { + "internalType": "uint256", + "name": "currentTimestamp", + "type": "uint256" + }, + { + "internalType": "address", + "name": "sender", + "type": "address" + }, + { + "internalType": "address", + "name": "recipient", + "type": "address" + }, + { + "internalType": "uint256", + "name": "initialRotations", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "txSlot", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "createdTimestamp", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "lastVoteTimestamp", + "type": "uint256" + }, + { + "internalType": "bytes32", + "name": "randomSeed", + "type": "bytes32" + }, + { + "internalType": "enum ITransactions.ResultType", + "name": "result", + "type": "uint8" + }, + { + "internalType": "bytes32", + "name": "txExecutionHash", + "type": "bytes32" + }, + { + "internalType": "bytes", + "name": "txCalldata", + "type": "bytes" + }, + { + "internalType": "bytes", + "name": "eqBlocksOutputs", + "type": "bytes" + }, + { + "components": [ + { + "internalType": "enum IMessages.MessageType", + "name": "messageType", + "type": "uint8" + }, + { + "internalType": "address", + "name": "recipient", + "type": "address" + }, + { + "internalType": "uint256", + "name": "value", + "type": "uint256" + }, + { + "internalType": "bytes", + "name": "data", + "type": "bytes" + }, + { + "internalType": "bool", + "name": "onAcceptance", + "type": "bool" + }, + { + "internalType": "uint256", + "name": "saltNonce", + "type": "uint256" + } + ], + "internalType": "struct IMessages.SubmittedMessage[]", + "name": "messages", + "type": "tuple[]" + }, + { + "internalType": "enum IQueues.QueueType", + "name": "queueType", + "type": "uint8" + }, + { + "internalType": "uint256", + "name": "queuePosition", + "type": "uint256" + }, + { + "internalType": "address", + "name": "activator", + "type": "address" + }, + { + "internalType": "address", + "name": "lastLeader", + "type": "address" + }, + { + "internalType": "enum ITransactions.TransactionStatus", + "name": "status", + "type": "uint8" + }, + { + "internalType": "bytes32", + "name": "txId", + "type": "bytes32" + }, + { + "components": [ + { + "internalType": "uint256", + "name": "activationBlock", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "processingBlock", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "proposalBlock", + "type": "uint256" + } + ], + "internalType": "struct ITransactions.ReadStateBlockRange", + "name": "readStateBlockRange", + "type": "tuple" + }, + { + "internalType": "uint256", + "name": "numOfRounds", + "type": "uint256" + }, + { + "components": [ + { + "internalType": "uint256", + "name": "round", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "leaderIndex", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "votesCommitted", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "votesRevealed", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "appealBond", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "rotationsLeft", + "type": "uint256" + }, + { + "internalType": "enum ITransactions.ResultType", + "name": "result", + "type": "uint8" + }, + { + "internalType": "address[]", + "name": "roundValidators", + "type": "address[]" + }, + { + "internalType": "enum ITransactions.VoteType[]", + "name": "validatorVotes", + "type": "uint8[]" + }, + { + "internalType": "bytes32[]", + "name": "validatorVotesHash", + "type": "bytes32[]" + }, + { + "internalType": "bytes32[]", + "name": "validatorResultHash", + "type": "bytes32[]" + } + ], + "internalType": "struct ITransactions.RoundData", + "name": "lastRound", + "type": "tuple" + }, + { + "internalType": "address[]", + "name": "consumedValidators", + "type": "address[]" + } + ], + "internalType": "struct ConsensusData.TransactionData[]", + "name": "", + "type": "tuple[]" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "recipient", + "type": "address" + } + ], + "name": "getLatestFinalizedTxCount", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes32", + "name": "role", + "type": "bytes32" + } + ], + "name": "getRoleAdmin", + "outputs": [ + { + "internalType": "bytes32", + "name": "", + "type": "bytes32" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes32", + "name": "_txId", + "type": "bytes32" + } + ], + "name": "getTransactionAllData", + "outputs": [ + { + "components": [ + { + "internalType": "enum ITransactions.ResultType", + "name": "result", + "type": "uint8" + }, + { + "internalType": "enum ITransactions.VoteType", + "name": "txExecutionResult", + "type": "uint8" + }, + { + "internalType": "enum ITransactions.TransactionStatus", + "name": "previousStatus", + "type": "uint8" + }, + { + "internalType": "enum ITransactions.TransactionStatus", + "name": "status", + "type": "uint8" + }, + { + "internalType": "address", + "name": "txOrigin", + "type": "address" + }, + { + "internalType": "address", + "name": "sender", + "type": "address" + }, + { + "internalType": "address", + "name": "recipient", + "type": "address" + }, + { + "internalType": "address", + "name": "activator", + "type": "address" + }, + { + "internalType": "uint256", + "name": "txSlot", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "initialRotations", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "numOfInitialValidators", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "epoch", + "type": "uint256" + }, + { + "internalType": "bytes32", + "name": "id", + "type": "bytes32" + }, + { + "internalType": "bytes32", + "name": "randomSeed", + "type": "bytes32" + }, + { + "internalType": "bytes32", + "name": "txExecutionHash", + "type": "bytes32" + }, + { + "internalType": "bytes32", + "name": "resultHash", + "type": "bytes32" + }, + { + "internalType": "bytes", + "name": "txCalldata", + "type": "bytes" + }, + { + "internalType": "bytes", + "name": "eqBlocksOutputs", + "type": "bytes" + }, + { + "components": [ + { + "internalType": "uint256", + "name": "activationBlock", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "processingBlock", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "proposalBlock", + "type": "uint256" + } + ], + "internalType": "struct ITransactions.ReadStateBlockRange[]", + "name": "readStateBlockRanges", + "type": "tuple[]" + }, + { + "internalType": "uint256", + "name": "validUntil", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "value", + "type": "uint256" + } + ], + "internalType": "struct ITransactions.Transaction", + "name": "transaction", + "type": "tuple" + }, + { + "components": [ + { + "internalType": "uint256", + "name": "round", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "leaderIndex", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "votesCommitted", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "votesRevealed", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "appealBond", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "rotationsLeft", + "type": "uint256" + }, + { + "internalType": "enum ITransactions.ResultType", + "name": "result", + "type": "uint8" + }, + { + "internalType": "address[]", + "name": "roundValidators", + "type": "address[]" + }, + { + "internalType": "enum ITransactions.VoteType[]", + "name": "validatorVotes", + "type": "uint8[]" + }, + { + "internalType": "bytes32[]", + "name": "validatorVotesHash", + "type": "bytes32[]" + }, + { + "internalType": "bytes32[]", + "name": "validatorResultHash", + "type": "bytes32[]" + } + ], + "internalType": "struct ITransactions.RoundData[]", + "name": "roundsData", + "type": "tuple[]" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes32", + "name": "_txId", + "type": "bytes32" + }, + { + "internalType": "uint256", + "name": "_timestamp", + "type": "uint256" + } + ], + "name": "getTransactionData", + "outputs": [ + { + "components": [ + { + "internalType": "uint256", + "name": "currentTimestamp", + "type": "uint256" + }, + { + "internalType": "address", + "name": "sender", + "type": "address" + }, + { + "internalType": "address", + "name": "recipient", + "type": "address" + }, + { + "internalType": "uint256", + "name": "initialRotations", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "txSlot", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "createdTimestamp", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "lastVoteTimestamp", + "type": "uint256" + }, + { + "internalType": "bytes32", + "name": "randomSeed", + "type": "bytes32" + }, + { + "internalType": "enum ITransactions.ResultType", + "name": "result", + "type": "uint8" + }, + { + "internalType": "bytes32", + "name": "txExecutionHash", + "type": "bytes32" + }, + { + "internalType": "bytes", + "name": "txCalldata", + "type": "bytes" + }, + { + "internalType": "bytes", + "name": "eqBlocksOutputs", + "type": "bytes" + }, + { + "components": [ + { + "internalType": "enum IMessages.MessageType", + "name": "messageType", + "type": "uint8" + }, + { + "internalType": "address", + "name": "recipient", + "type": "address" + }, + { + "internalType": "uint256", + "name": "value", + "type": "uint256" + }, + { + "internalType": "bytes", + "name": "data", + "type": "bytes" + }, + { + "internalType": "bool", + "name": "onAcceptance", + "type": "bool" + }, + { + "internalType": "uint256", + "name": "saltNonce", + "type": "uint256" + } + ], + "internalType": "struct IMessages.SubmittedMessage[]", + "name": "messages", + "type": "tuple[]" + }, + { + "internalType": "enum IQueues.QueueType", + "name": "queueType", + "type": "uint8" + }, + { + "internalType": "uint256", + "name": "queuePosition", + "type": "uint256" + }, + { + "internalType": "address", + "name": "activator", + "type": "address" + }, + { + "internalType": "address", + "name": "lastLeader", + "type": "address" + }, + { + "internalType": "enum ITransactions.TransactionStatus", + "name": "status", + "type": "uint8" + }, + { + "internalType": "bytes32", + "name": "txId", + "type": "bytes32" + }, + { + "components": [ + { + "internalType": "uint256", + "name": "activationBlock", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "processingBlock", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "proposalBlock", + "type": "uint256" + } + ], + "internalType": "struct ITransactions.ReadStateBlockRange", + "name": "readStateBlockRange", + "type": "tuple" + }, + { + "internalType": "uint256", + "name": "numOfRounds", + "type": "uint256" + }, + { + "components": [ + { + "internalType": "uint256", + "name": "round", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "leaderIndex", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "votesCommitted", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "votesRevealed", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "appealBond", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "rotationsLeft", + "type": "uint256" + }, + { + "internalType": "enum ITransactions.ResultType", + "name": "result", + "type": "uint8" + }, + { + "internalType": "address[]", + "name": "roundValidators", + "type": "address[]" + }, + { + "internalType": "enum ITransactions.VoteType[]", + "name": "validatorVotes", + "type": "uint8[]" + }, + { + "internalType": "bytes32[]", + "name": "validatorVotesHash", + "type": "bytes32[]" + }, + { + "internalType": "bytes32[]", + "name": "validatorResultHash", + "type": "bytes32[]" + } + ], + "internalType": "struct ITransactions.RoundData", + "name": "lastRound", + "type": "tuple" + }, + { + "internalType": "address[]", + "name": "consumedValidators", + "type": "address[]" + } + ], + "internalType": "struct ConsensusData.TransactionData", + "name": "", + "type": "tuple" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes32", + "name": "_txId", + "type": "bytes32" + }, + { + "internalType": "uint256", + "name": "_timestamp", + "type": "uint256" + } + ], + "name": "getTransactionStatus", + "outputs": [ + { + "internalType": "enum ITransactions.TransactionStatus", + "name": "", + "type": "uint8" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes32", + "name": "_txId", + "type": "bytes32" + } + ], + "name": "getValidatorsForLastRound", + "outputs": [ + { + "internalType": "address[]", + "name": "validators", + "type": "address[]" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes32", + "name": "role", + "type": "bytes32" + }, + { + "internalType": "address", + "name": "account", + "type": "address" + } + ], + "name": "grantRole", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes32", + "name": "role", + "type": "bytes32" + }, + { + "internalType": "address", + "name": "account", + "type": "address" + } + ], + "name": "hasRole", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_addressManager", + "type": "address" + } + ], + "name": "initialize", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "owner", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "pendingOwner", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "renounceOwnership", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes32", + "name": "role", + "type": "bytes32" + }, + { + "internalType": "address", + "name": "callerConfirmation", + "type": "address" + } + ], + "name": "renounceRole", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes32", + "name": "role", + "type": "bytes32" + }, + { + "internalType": "address", + "name": "account", + "type": "address" + } + ], + "name": "revokeRole", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_addressManager", + "type": "address" + } + ], + "name": "setAddressManager", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes4", + "name": "interfaceId", + "type": "bytes4" + } + ], + "name": "supportsInterface", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "newOwner", + "type": "address" + } + ], + "name": "transferOwnership", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + } +], + bytecode: "", +}; + +export const testnetBradbury: GenLayerChain = defineChain({ + id: 0x107d, + isStudio: false, + name: "Genlayer Bradbury Testnet", + rpcUrls: { + default: { + http: [TESTNET_JSON_RPC_URL], + webSocket: [TESTNET_WS_URL], + }, + }, + nativeCurrency: { + name: "GEN Token", + symbol: "GEN", + decimals: 18, + }, + blockExplorers: { + default: { + name: "GenLayer Bradbury Explorer", + url: EXPLORER_URL, + }, + }, + testnet: true, + consensusMainContract: CONSENSUS_MAIN_CONTRACT, + consensusDataContract: CONSENSUS_DATA_CONTRACT, + stakingContract: STAKING_CONTRACT, + defaultNumberOfInitialValidators: 5, + defaultConsensusMaxRotations: 3, +}); diff --git a/src/types/network.ts b/src/types/network.ts index 5dd6b1d..8eaee39 100644 --- a/src/types/network.ts +++ b/src/types/network.ts @@ -1 +1 @@ -export type Network = "localnet" | "studionet" | "testnetAsimov" | "mainnet"; +export type Network = "localnet" | "studionet" | "testnetAsimov" | "testnetBradbury" | "mainnet"; diff --git a/src/wallet/connect.ts b/src/wallet/connect.ts index d4d4313..3985dd9 100644 --- a/src/wallet/connect.ts +++ b/src/wallet/connect.ts @@ -1,6 +1,7 @@ import {localnet} from "@/chains/localnet"; import {studionet} from "@/chains/studionet"; import {testnetAsimov} from "@/chains/testnetAsimov"; +import {testnetBradbury} from "@/chains/testnetBradbury"; import {GenLayerClient, GenLayerChain} from "@/types"; import {Network} from "@/types/network"; import {SnapSource} from "@/types/snapSource"; @@ -10,6 +11,7 @@ const networks = { localnet, studionet, testnetAsimov, + testnetBradbury, }; export const connect = async ( diff --git a/tests/smoke.test.ts b/tests/smoke.test.ts index a5e63a9..00c43aa 100644 --- a/tests/smoke.test.ts +++ b/tests/smoke.test.ts @@ -1,33 +1,42 @@ // tests/smoke.test.ts -// Smoke tests against live testnet-asimov to verify ABI compatibility and connectivity. +// Smoke tests against live testnets to verify ABI compatibility and connectivity. // Run with: npm run test:smoke // These are excluded from regular `npm test` to avoid CI dependence on testnet availability. import {describe, it, expect, beforeAll} from "vitest"; import {createPublicClient, http, webSocket, getContract, Address as ViemAddress} from "viem"; import {testnetAsimov} from "@/chains/testnetAsimov"; +import {testnetBradbury} from "@/chains/testnetBradbury"; import {createClient} from "@/client/client"; import {STAKING_ABI} from "@/abi/staking"; import {Address} from "@/types/accounts"; +import {GenLayerChain} from "@/types"; const TIMEOUT = 30_000; +const testnets: {name: string; chain: GenLayerChain}[] = [ + {name: "Asimov", chain: testnetAsimov}, + {name: "Bradbury", chain: testnetBradbury}, +]; + +for (const {name, chain} of testnets) { + // ─── HTTP RPC Connectivity ─────────────────────────────────────────────────── -describe("Testnet Asimov - HTTP RPC", () => { +describe(`Testnet ${name} - HTTP RPC`, () => { it("should fetch chain ID", async () => { const client = createPublicClient({ - chain: testnetAsimov, - transport: http(testnetAsimov.rpcUrls.default.http[0]), + chain, + transport: http(chain.rpcUrls.default.http[0]), }); const chainId = await client.getChainId(); - expect(chainId).toBe(testnetAsimov.id); + expect(chainId).toBe(chain.id); }, TIMEOUT); it("should fetch latest block number", async () => { const client = createPublicClient({ - chain: testnetAsimov, - transport: http(testnetAsimov.rpcUrls.default.http[0]), + chain, + transport: http(chain.rpcUrls.default.http[0]), }); const blockNumber = await client.getBlockNumber(); expect(blockNumber).toBeGreaterThan(0n); @@ -36,8 +45,8 @@ describe("Testnet Asimov - HTTP RPC", () => { // ─── WebSocket RPC Connectivity ────────────────────────────────────────────── -describe("Testnet Asimov - WebSocket RPC", () => { - const wsUrl = testnetAsimov.rpcUrls.default.webSocket?.[0]; +describe(`Testnet ${name} - WebSocket RPC`, () => { + const wsUrl = chain.rpcUrls.default.webSocket?.[0]; it("should have a WS URL configured", () => { expect(wsUrl).toBeDefined(); @@ -47,7 +56,7 @@ describe("Testnet Asimov - WebSocket RPC", () => { it("should connect and fetch chain ID over WebSocket", async () => { if (!wsUrl) return; const client = createPublicClient({ - chain: testnetAsimov, + chain, transport: webSocket(wsUrl), }); const chainId = await client.getChainId(); @@ -55,9 +64,9 @@ describe("Testnet Asimov - WebSocket RPC", () => { // The key assertion is that the connection works and returns a valid number expect(chainId).toBeTypeOf("number"); expect(chainId).toBeGreaterThan(0); - if (chainId !== testnetAsimov.id) { + if (chainId !== chain.id) { console.warn( - `WS chain ID (${chainId}) differs from HTTP chain ID (${testnetAsimov.id}). ` + + `WS chain ID (${chainId}) differs from HTTP chain ID (${chain.id}). ` + `WS URL may point to the underlying L1/L2 chain.` ); } @@ -66,7 +75,7 @@ describe("Testnet Asimov - WebSocket RPC", () => { it("should fetch latest block number over WebSocket", async () => { if (!wsUrl) return; const client = createPublicClient({ - chain: testnetAsimov, + chain, transport: webSocket(wsUrl), }); const blockNumber = await client.getBlockNumber(); @@ -76,9 +85,9 @@ describe("Testnet Asimov - WebSocket RPC", () => { // ─── Staking Read-Only via WebSocket ───────────────────────────────────────── -describe("Testnet Asimov - Staking over WebSocket", () => { - const wsUrl = testnetAsimov.rpcUrls.default.webSocket?.[0]; - const stakingAddress = testnetAsimov.stakingContract?.address as ViemAddress; +describe(`Testnet ${name} - Staking over WebSocket`, () => { + const wsUrl = chain.rpcUrls.default.webSocket?.[0]; + const stakingAddress = chain.stakingContract?.address as ViemAddress; // First check if WS points to the same chain — if not, skip staking tests let wsMatchesChain = false; @@ -86,13 +95,13 @@ describe("Testnet Asimov - Staking over WebSocket", () => { beforeAll(async () => { if (!wsUrl) return; - wsPub = createPublicClient({chain: testnetAsimov, transport: webSocket(wsUrl)}); + wsPub = createPublicClient({chain, transport: webSocket(wsUrl)}); try { const chainId = await wsPub.getChainId(); - wsMatchesChain = chainId === testnetAsimov.id; + wsMatchesChain = chainId === chain.id; if (!wsMatchesChain) { console.warn( - `WS chain ID (${chainId}) differs from testnet (${testnetAsimov.id}). ` + + `WS chain ID (${chainId}) differs from testnet (${chain.id}). ` + `Staking contract calls will be skipped — WS endpoint serves a different chain.` ); } @@ -142,9 +151,6 @@ describe("Testnet Asimov - Staking over WebSocket", () => { if (nonZero.length === 0) return; const view = await contract.read.validatorView([nonZero[0]]) as unknown; - // Depending on ABI/runtime decoding, viem may return either: - // - positional tuple array (length 12), or - // - named tuple object ({ left, right, ..., live }) if (Array.isArray(view)) { expect(view.length).toBe(12); return; @@ -188,11 +194,11 @@ describe("Testnet Asimov - Staking over WebSocket", () => { // ─── Staking Read-Only Methods ─────────────────────────────────────────────── -describe("Testnet Asimov - Staking (read-only)", () => { +describe(`Testnet ${name} - Staking (read-only)`, () => { let client: ReturnType; beforeAll(() => { - client = createClient({chain: testnetAsimov}); + client = createClient({chain}); }); it("getEpochInfo", async () => { @@ -309,3 +315,5 @@ describe("Testnet Asimov - Staking (read-only)", () => { expect(client.formatStakingAmount(weiAmount)).toBe("42 GEN"); }); }); + +} // end for loop over testnets