diff --git a/contracts/foundry.toml b/contracts/foundry.toml index 2bc70ba5..047810a7 100644 --- a/contracts/foundry.toml +++ b/contracts/foundry.toml @@ -2,3 +2,4 @@ src = "src" out = "out" libs = ["lib"] +via_ir = true diff --git a/contracts/src/DepositContract.sol b/contracts/src/DepositContract.sol new file mode 100644 index 00000000..a66f9048 --- /dev/null +++ b/contracts/src/DepositContract.sol @@ -0,0 +1,193 @@ +// ┏━━━┓━┏┓━┏┓━━┏━━━┓━━┏━━━┓━━━━┏━━━┓━━━━━━━━━━━━━━━━━━━┏┓━━━━━┏━━━┓━━━━━━━━━┏┓━━━━━━━━━━━━━━┏┓━ +// ┃┏━━┛┏┛┗┓┃┃━━┃┏━┓┃━━┃┏━┓┃━━━━┗┓┏┓┃━━━━━━━━━━━━━━━━━━┏┛┗┓━━━━┃┏━┓┃━━━━━━━━┏┛┗┓━━━━━━━━━━━━┏┛┗┓ +// ┃┗━━┓┗┓┏┛┃┗━┓┗┛┏┛┃━━┃┃━┃┃━━━━━┃┃┃┃┏━━┓┏━━┓┏━━┓┏━━┓┏┓┗┓┏┛━━━━┃┃━┗┛┏━━┓┏━┓━┗┓┏┛┏━┓┏━━┓━┏━━┓┗┓┏┛ +// ┃┏━━┛━┃┃━┃┏┓┃┏━┛┏┛━━┃┃━┃┃━━━━━┃┃┃┃┃┏┓┃┃┏┓┃┃┏┓┃┃━━┫┣┫━┃┃━━━━━┃┃━┏┓┃┏┓┃┃┏┓┓━┃┃━┃┏┛┗━┓┃━┃┏━┛━┃┃━ +// ┃┗━━┓━┃┗┓┃┃┃┃┃┃┗━┓┏┓┃┗━┛┃━━━━┏┛┗┛┃┃┃━┫┃┗┛┃┃┗┛┃┣━━┃┃┃━┃┗┓━━━━┃┗━┛┃┃┗┛┃┃┃┃┃━┃┗┓┃┃━┃┗┛┗┓┃┗━┓━┃┗┓ +// ┗━━━┛━┗━┛┗┛┗┛┗━━━┛┗┛┗━━━┛━━━━┗━━━┛┗━━┛┃┏━┛┗━━┛┗━━┛┗┛━┗━┛━━━━┗━━━┛┗━━┛┗┛┗┛━┗━┛┗┛━┗━━━┛┗━━┛━┗━┛ +// ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┃┃━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +// ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┗┛━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + +// SPDX-License-Identifier: CC0-1.0 + +pragma solidity ^0.8.30; + +// This interface is designed to be compatible with the Vyper version. +/// @notice This is the Ethereum 2.0 deposit contract interface. +/// For more information see the Phase 0 specification under https://github.com/ethereum/eth2.0-specs +interface IDepositContract { + /// @notice A processed deposit event. + event DepositEvent( + bytes node_pubkey, + bytes consensus_pubkey, + bytes withdrawal_credentials, + bytes amount, + bytes node_signature, + bytes consensus_signature, + bytes index + ); + + /// @notice Submit a Phase 0 DepositData object. + /// @param node_pubkey An ED25519 public key. + /// @param consensus_pubkey A BLS12-381 public key. + /// @param withdrawal_credentials Commitment to a public key for withdrawals. + /// @param node_signature An ED25519 signature. + /// @param consensus_signature A BLS12-381 signature. + /// @param deposit_data_root The SHA-256 hash of the SSZ-encoded DepositData object. + /// Used as a protection against malformed input. + function deposit( + bytes calldata node_pubkey, + bytes calldata consensus_pubkey, + bytes calldata withdrawal_credentials, + bytes calldata node_signature, + bytes calldata consensus_signature, + bytes32 deposit_data_root + ) external payable; + + /// @notice Query the current deposit root hash. + /// @return The deposit root hash. + function get_deposit_root() external view returns (bytes32); + + /// @notice Query the current deposit count. + /// @return The deposit count encoded as a little endian 64-bit number. + function get_deposit_count() external view returns (bytes memory); +} + +// Based on official specification in https://eips.ethereum.org/EIPS/eip-165 +interface ERC165 { + /// @notice Query if a contract implements an interface + /// @param interfaceId The interface identifier, as specified in ERC-165 + /// @dev Interface identification is specified in ERC-165. This function + /// uses less than 30,000 gas. + /// @return `true` if the contract implements `interfaceId` and + /// `interfaceId` is not 0xffffffff, `false` otherwise + function supportsInterface(bytes4 interfaceId) external pure returns (bool); +} + +// This is a rewrite of the Vyper Eth2.0 deposit contract in Solidity. +// It tries to stay as close as possible to the original source code. +/// @notice This is the Ethereum 2.0 deposit contract interface. +/// For more information see the Phase 0 specification under https://github.com/ethereum/eth2.0-specs +contract DepositContract is IDepositContract, ERC165 { + uint constant DEPOSIT_CONTRACT_TREE_DEPTH = 32; + // NOTE: this also ensures `deposit_count` will fit into 64-bits + uint constant MAX_DEPOSIT_COUNT = 2**DEPOSIT_CONTRACT_TREE_DEPTH - 1; + + bytes32[DEPOSIT_CONTRACT_TREE_DEPTH] branch; + uint256 deposit_count; + + bytes32[DEPOSIT_CONTRACT_TREE_DEPTH] zero_hashes; + + constructor() { + // Compute hashes in empty sparse Merkle tree + for (uint height = 0; height < DEPOSIT_CONTRACT_TREE_DEPTH - 1; height++) + zero_hashes[height + 1] = sha256(abi.encodePacked(zero_hashes[height], zero_hashes[height])); + } + + function get_deposit_root() override external view returns (bytes32) { + bytes32 node; + uint size = deposit_count; + for (uint height = 0; height < DEPOSIT_CONTRACT_TREE_DEPTH; height++) { + if ((size & 1) == 1) + node = sha256(abi.encodePacked(branch[height], node)); + else + node = sha256(abi.encodePacked(node, zero_hashes[height])); + size /= 2; + } + return sha256(abi.encodePacked( + node, + to_little_endian_64(uint64(deposit_count)), + bytes24(0) + )); + } + + function get_deposit_count() override external view returns (bytes memory) { + return to_little_endian_64(uint64(deposit_count)); + } + + function deposit( + bytes calldata node_pubkey, + bytes calldata consensus_pubkey, + bytes calldata withdrawal_credentials, + bytes calldata node_signature, + bytes calldata consensus_signature, + bytes32 deposit_data_root + ) override external payable { + // Extended ABI length checks since dynamic types are used. + require(node_pubkey.length == 32, "DepositContract: invalid node_pubkey length"); + require(consensus_pubkey.length == 48, "DepositContract: invalid consensus_pubkey length"); + require(withdrawal_credentials.length == 32, "DepositContract: invalid withdrawal_credentials length"); + require(node_signature.length == 64, "DepositContract: invalid node_signature length"); + require(consensus_signature.length == 96, "DepositContract: invalid consensus_signature length"); + + // Check deposit amount + require(msg.value >= 1 ether, "DepositContract: deposit value too low"); + require(msg.value % 1 gwei == 0, "DepositContract: deposit value not multiple of gwei"); + uint deposit_amount = msg.value / 1 gwei; + require(deposit_amount <= type(uint64).max, "DepositContract: deposit value too high"); + + // Emit `DepositEvent` log + bytes memory amount = to_little_endian_64(uint64(deposit_amount)); + emit DepositEvent( + node_pubkey, + consensus_pubkey, + withdrawal_credentials, + amount, + node_signature, + consensus_signature, + to_little_endian_64(uint64(deposit_count)) + ); + + // Compute deposit data root (`DepositData` hash tree root) + bytes32 consensus_pubkey_hash = sha256(abi.encodePacked(consensus_pubkey, bytes16(0))); + bytes32 pubkey_root = sha256(abi.encodePacked(node_pubkey, consensus_pubkey_hash)); + bytes32 node_signature_hash = sha256(node_signature); + bytes32 consensus_signature_hash = sha256(abi.encodePacked( + sha256(abi.encodePacked(consensus_signature[:64])), + sha256(abi.encodePacked(consensus_signature[64:], bytes32(0))) + )); + bytes32 signature_root = sha256(abi.encodePacked(node_signature_hash, consensus_signature_hash)); + bytes32 node = sha256(abi.encodePacked( + sha256(abi.encodePacked(pubkey_root, withdrawal_credentials)), + sha256(abi.encodePacked(amount, bytes24(0), signature_root)) + )); + + // Verify computed and expected deposit data roots match + require(node == deposit_data_root, "DepositContract: reconstructed DepositData does not match supplied deposit_data_root"); + + // Avoid overflowing the Merkle tree (and prevent edge case in computing `branch`) + require(deposit_count < MAX_DEPOSIT_COUNT, "DepositContract: merkle tree full"); + + // Add deposit data root to Merkle tree (update a single `branch` node) + deposit_count += 1; + uint size = deposit_count; + for (uint height = 0; height < DEPOSIT_CONTRACT_TREE_DEPTH; height++) { + if ((size & 1) == 1) { + branch[height] = node; + return; + } + node = sha256(abi.encodePacked(branch[height], node)); + size /= 2; + } + // As the loop should always end prematurely with the `return` statement, + // this code should be unreachable. We assert `false` just to be safe. + assert(false); + } + + function supportsInterface(bytes4 interfaceId) override external pure returns (bool) { + return interfaceId == type(ERC165).interfaceId || interfaceId == type(IDepositContract).interfaceId; + } + + function to_little_endian_64(uint64 value) internal pure returns (bytes memory ret) { + ret = new bytes(8); + bytes8 bytesValue = bytes8(value); + // Byteswapping during copying to bytes. + ret[0] = bytesValue[7]; + ret[1] = bytesValue[6]; + ret[2] = bytesValue[5]; + ret[3] = bytesValue[4]; + ret[4] = bytesValue[3]; + ret[5] = bytesValue[2]; + ret[6] = bytesValue[1]; + ret[7] = bytesValue[0]; + } +} diff --git a/contracts/test/ShieldedDelegationAccount.t.sol b/contracts/test/ShieldedDelegationAccount.t.sol index 44ceed34..92ea5404 100644 --- a/contracts/test/ShieldedDelegationAccount.t.sol +++ b/contracts/test/ShieldedDelegationAccount.t.sol @@ -266,11 +266,12 @@ contract ShieldedDelegationAccountTest is Test, ShieldedDelegationAccount { /// @param keyIndex Index of the key to use /// @param cipher Encrypted data to be executed /// @return signature The signature bytes - function _signExecuteDigestWithKey(address payable account, uint32 keyIndex, bytes memory cipher, uint256 privateKey) - internal - view - returns (bytes memory signature) - { + function _signExecuteDigestWithKey( + address payable account, + uint32 keyIndex, + bytes memory cipher, + uint256 privateKey + ) internal view returns (bytes memory signature) { uint256 keyNonce = ShieldedDelegationAccount(account).getKeyNonce(keyIndex); Key memory key = ShieldedDelegationAccount(account).getKey(keyIndex); bytes32 domainSeparator = _getDomainSeparator(); @@ -299,7 +300,9 @@ contract ShieldedDelegationAccountTest is Test, ShieldedDelegationAccount { /// @param keyIndex The key index to use /// @param calls The encoded calls to execute /// @param privateKey The private key to sign with - function _executeViaKey(address payable account, uint32 keyIndex, bytes memory calls, uint256 privateKey) internal { + function _executeViaKey(address payable account, uint32 keyIndex, bytes memory calls, uint256 privateKey) + internal + { // Encrypt the calls (uint96 nonce, bytes memory cipher) = ShieldedDelegationAccount(account).encrypt(calls); diff --git a/packages/seismic-react/package.json b/packages/seismic-react/package.json index 7aefe07d..2a7728bc 100644 --- a/packages/seismic-react/package.json +++ b/packages/seismic-react/package.json @@ -1,6 +1,6 @@ { "name": "seismic-react", - "version": "1.0.50", + "version": "1.0.51", "description": "React components for Seismic.", "type": "module", "main": "./dist/_cjs/index.js", @@ -52,7 +52,7 @@ "typescript": ">=5.0.4", "viem": "2.x", "wagmi": "^2.0.0", - "seismic-viem": ">=1.0.50" + "seismic-viem": ">=1.0.51" }, "peerDependenciesMeta": { "typescript": { diff --git a/packages/seismic-viem-tests/src/index.ts b/packages/seismic-viem-tests/src/index.ts index 2ff913e4..30f82e99 100644 --- a/packages/seismic-viem-tests/src/index.ts +++ b/packages/seismic-viem-tests/src/index.ts @@ -7,6 +7,7 @@ export type { export { testSeismicTxEncoding } from '@sviem-tests/tests/encoding.ts' export { testSeismicTx } from '@sviem-tests/tests/contract/contract.ts' +export { testDepositContract } from '@sviem-tests/tests/contract/depositContract.ts' export { testContractTreadIsntSeismicTx, testShieldedWalletClientTreadIsntSeismicTx, diff --git a/packages/seismic-viem-tests/src/tests/contract/depositContract.ts b/packages/seismic-viem-tests/src/tests/contract/depositContract.ts new file mode 100644 index 00000000..b360517b --- /dev/null +++ b/packages/seismic-viem-tests/src/tests/contract/depositContract.ts @@ -0,0 +1,230 @@ +import { expect } from 'bun:test' +import { createHash } from 'crypto' +import { + createShieldedPublicClient, + createShieldedWalletClient, +} from 'seismic-viem' +import { Account, Chain, parseEther } from 'viem' +import { http } from 'viem' + +import { depositContractAbi } from '@sviem-tests/tests/contract/depositContractAbi.ts' +import { depositContractBytecode } from '@sviem-tests/tests/contract/depositContractBytecode.ts' + +export type ContractTestArgs = { + chain: Chain + url: string + account: Account +} + +const VALIDATOR_MINIMUM_STAKE = 32n +const WITHDRAWAL_ADDRESS = '0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266' + +function generateWithdrawalCredentials(address: `0x${string}`): `0x${string}` { + // Format: 0x01 || 0x00...00 (11 bytes) || execution_address (20 bytes) + const credentials = new Uint8Array(32) + credentials[0] = 0x01 // ETH1 withdrawal prefix + // Bytes 1-11 remain zero + // Set the last 20 bytes to the withdrawal address + const addressBytes = new Uint8Array(Buffer.from(address.slice(2), 'hex')) + credentials.set(addressBytes, 12) + + return `0x${Buffer.from(credentials).toString('hex')}` as `0x${string}` +} + +function generateValidatorData() { + const nodePubkey = `0x${'00'.repeat(32)}` as `0x${string}` + + const consensusPubkey = `0x${'11'.repeat(48)}` as `0x${string}` + + const withdrawalCredentials = + generateWithdrawalCredentials(WITHDRAWAL_ADDRESS) + + const nodeSignature = `0x${'33'.repeat(64)}` as `0x${string}` + + const consensusSignature = `0x${'44'.repeat(96)}` as `0x${string}` + + const depositDataRoot = computeDepositDataRoot( + nodePubkey, + consensusPubkey, + withdrawalCredentials, + nodeSignature, + consensusSignature, + parseEther(VALIDATOR_MINIMUM_STAKE.toString()) + ) + + return { + nodePubkey, + consensusPubkey, + withdrawalCredentials, + nodeSignature, + consensusSignature, + depositDataRoot, + } +} + +function computeDepositDataRoot( + nodePubkey: `0x${string}`, + consensusPubkey: `0x${string}`, + withdrawalCredentials: `0x${string}`, + nodeSignature: `0x${string}`, + consensusSignature: `0x${string}`, + amount: bigint +): `0x${string}` { + // Convert hex strings to buffers + const nodePubkeyBytes = Buffer.from(nodePubkey.slice(2), 'hex') + const consensusPubkeyBytes = Buffer.from(consensusPubkey.slice(2), 'hex') + const withdrawalCredentialsBytes = Buffer.from( + withdrawalCredentials.slice(2), + 'hex' + ) + const nodeSignatureBytes = Buffer.from(nodeSignature.slice(2), 'hex') + const consensusSignatureBytes = Buffer.from( + consensusSignature.slice(2), + 'hex' + ) + + // consensus_pubkey_hash = sha256(consensus_pubkey || bytes16(0)) + const consensusPubkeyHash = createHash('sha256') + .update(consensusPubkeyBytes) + .update(Buffer.alloc(16, 0)) // bytes16(0) + .digest() + + // pubkey_root = sha256(node_pubkey || consensus_pubkey_hash) + const pubkeyRoot = createHash('sha256') + .update(nodePubkeyBytes) + .update(consensusPubkeyHash) + .digest() + + // node_signature_hash = sha256(node_signature) + const nodeSignatureHash = createHash('sha256') + .update(nodeSignatureBytes) + .digest() + + // consensus_signature_hash = sha256(sha256(consensus_signature[0:64]) || sha256(consensus_signature[64:96] || bytes32(0))) + const consensusSigPart1 = createHash('sha256') + .update(consensusSignatureBytes.slice(0, 64)) + .digest() + + const consensusSigPart2 = createHash('sha256') + .update(consensusSignatureBytes.slice(64, 96)) + .update(Buffer.alloc(32, 0)) // bytes32(0) + .digest() + + const consensusSignatureHash = createHash('sha256') + .update(consensusSigPart1) + .update(consensusSigPart2) + .digest() + + // signature_root = sha256(node_signature_hash || consensus_signature_hash) + const signatureRoot = createHash('sha256') + .update(nodeSignatureHash) + .update(consensusSignatureHash) + .digest() + + // Convert amount to 8-byte little-endian (gwei) + const amountGwei = amount / BigInt(10 ** 9) // Convert wei to gwei + const amountBytes = Buffer.alloc(8) + amountBytes.writeBigUInt64LE(amountGwei, 0) + + // node = sha256(sha256(pubkey_root || withdrawal_credentials) || sha256(amount || bytes24(0) || signature_root)) + const leftNode = createHash('sha256') + .update(pubkeyRoot) + .update(withdrawalCredentialsBytes) + .digest() + + const rightNode = createHash('sha256') + .update(amountBytes) + .update(Buffer.alloc(24, 0)) // bytes24(0) + .update(signatureRoot) + .digest() + + const depositDataRoot = createHash('sha256') + .update(leftNode) + .update(rightNode) + .digest() + + return `0x${depositDataRoot.toString('hex')}` as `0x${string}` +} + +export const testDepositContract = async ({ + chain, + url, + account, +}: ContractTestArgs) => { + const publicClient = createShieldedPublicClient({ + chain, + transport: http(url), + }) + const walletClient = await createShieldedWalletClient({ + chain, + transport: http(url), + account, + }) + + const testContractBytecodeFormatted: `0x${string}` = `0x${depositContractBytecode.object.replace(/^0x/, '')}` + + const deployTx = await walletClient.deployContract({ + abi: depositContractAbi, + bytecode: testContractBytecodeFormatted, + chain: walletClient.chain, + }) + const deployReceipt = await publicClient.waitForTransactionReceipt({ + hash: deployTx, + }) + + const deployedContractAddress = deployReceipt.contractAddress! + + const initialDepositRoot = await publicClient.getDepositRoot({ + address: deployedContractAddress, + }) + expect(initialDepositRoot).toBeDefined() + expect(typeof initialDepositRoot).toBe('string') + + const initialDepositCount = await publicClient.getDepositCount({ + address: deployedContractAddress, + }) + expect(initialDepositCount).toBeDefined() + + const validatorData = generateValidatorData() + + const depositTx = await walletClient.deposit({ + address: deployedContractAddress, + nodePubkey: validatorData.nodePubkey, + consensusPubkey: validatorData.consensusPubkey, + withdrawalCredentials: validatorData.withdrawalCredentials, + nodeSignature: validatorData.nodeSignature, + consensusSignature: validatorData.consensusSignature, + depositDataRoot: validatorData.depositDataRoot, + value: parseEther(VALIDATOR_MINIMUM_STAKE.toString()), + }) + + expect(depositTx).toBeDefined() + const depositReceipt = await publicClient.waitForTransactionReceipt({ + hash: depositTx, + }) + expect(depositReceipt.status).toBe('success') + + expect(depositReceipt.logs.length).toBeGreaterThan(0) + + const newDepositCount = await publicClient.getDepositCount({ + address: deployedContractAddress, + }) + expect(newDepositCount).toBeDefined() + + const newDepositRoot = await publicClient.getDepositRoot({ + address: deployedContractAddress, + }) + expect(newDepositRoot).toBeDefined() + expect(typeof newDepositRoot).toBe('string') + + return { + deployedContractAddress, + initialDepositRoot, + initialDepositCount, + depositTx, + depositReceipt, + newDepositCount, + newDepositRoot, + validatorData, + } +} diff --git a/packages/seismic-viem-tests/src/tests/contract/depositContractAbi.ts b/packages/seismic-viem-tests/src/tests/contract/depositContractAbi.ts new file mode 100644 index 00000000..61d31417 --- /dev/null +++ b/packages/seismic-viem-tests/src/tests/contract/depositContractAbi.ts @@ -0,0 +1,83 @@ +import type { Abi } from 'abitype' + +export const depositContractAbi = [ + { + type: 'constructor', + inputs: [], + stateMutability: 'nonpayable', + }, + { + type: 'function', + name: 'deposit', + inputs: [ + { name: 'node_pubkey', type: 'bytes', internalType: 'bytes' }, + { name: 'consensus_pubkey', type: 'bytes', internalType: 'bytes' }, + { name: 'withdrawal_credentials', type: 'bytes', internalType: 'bytes' }, + { name: 'node_signature', type: 'bytes', internalType: 'bytes' }, + { name: 'consensus_signature', type: 'bytes', internalType: 'bytes' }, + { name: 'deposit_data_root', type: 'bytes32', internalType: 'bytes32' }, + ], + outputs: [], + stateMutability: 'payable', + }, + { + type: 'function', + name: 'get_deposit_count', + inputs: [], + outputs: [{ name: '', type: 'bytes', internalType: 'bytes' }], + stateMutability: 'view', + }, + { + type: 'function', + name: 'get_deposit_root', + inputs: [], + outputs: [{ name: '', type: 'bytes32', internalType: 'bytes32' }], + stateMutability: 'view', + }, + { + type: 'function', + name: 'supportsInterface', + inputs: [{ name: 'interfaceId', type: 'bytes4', internalType: 'bytes4' }], + outputs: [{ name: '', type: 'bool', internalType: 'bool' }], + stateMutability: 'pure', + }, + { + type: 'event', + name: 'DepositEvent', + inputs: [ + { + name: 'node_pubkey', + type: 'bytes', + indexed: false, + internalType: 'bytes', + }, + { + name: 'consensus_pubkey', + type: 'bytes', + indexed: false, + internalType: 'bytes', + }, + { + name: 'withdrawal_credentials', + type: 'bytes', + indexed: false, + internalType: 'bytes', + }, + { name: 'amount', type: 'bytes', indexed: false, internalType: 'bytes' }, + { + name: 'node_signature', + type: 'bytes', + indexed: false, + internalType: 'bytes', + }, + { + name: 'consensus_signature', + type: 'bytes', + indexed: false, + internalType: 'bytes', + }, + { name: 'index', type: 'bytes', indexed: false, internalType: 'bytes' }, + ], + anonymous: false, + }, +] as const satisfies Abi diff --git a/packages/seismic-viem-tests/src/tests/contract/depositContractBytecode.ts b/packages/seismic-viem-tests/src/tests/contract/depositContractBytecode.ts new file mode 100644 index 00000000..4a092c63 --- /dev/null +++ b/packages/seismic-viem-tests/src/tests/contract/depositContractBytecode.ts @@ -0,0 +1,7 @@ +export const depositContractBytecode = { + object: + '0x608060405234610027576100116102c9565b61001961002c565b611f686103c38239611f6890f35b610032565b60405190565b5f80fd5b90565b90565b90565b61005361004e61005892610036565b61003c565b610039565b90565b60016100679101610039565b90565b90565b61008161007c6100869261006a565b61003c565b610039565b90565b610093602061006d565b90565b90565b6100ad6100a86100b292610096565b61003c565b610039565b90565b634e487b7160e01b5f52601160045260245ffd5b6100d86100de91939293610039565b92610039565b82039182116100e957565b6100b5565b634e487b7160e01b5f52603260045260245ffd5b50602090565b90565b61011481610102565b82101561012e57610126600191610108565b910201905f90565b6100ee565b1c90565b90565b61014a90600861014f9302610133565b610137565b90565b9061015d915461013a565b90565b90565b90565b61017261017791610160565b610163565b9052565b60208161018d61019593839695610166565b018092610166565b0190565b601f801991011690565b634e487b7160e01b5f52604160045260245ffd5b906101c190610199565b810190811060018060401b038211176101d957604052565b6101a3565b5f1b90565b5190565b905090565b90825f9392825e0152565b61021c6102139260209261020a816101e3565b948580936101e7565b938491016101ec565b0190565b610229916101f7565b90565b61023461002c565b3d5f823e3d90fd5b61024b61025191939293610039565b92610039565b820180921161025c57565b6100b5565b1b90565b9190600861028091029161027a5f1984610261565b92610261565b9181191691161790565b61029390610160565b90565b5f1c90565b6102a490610296565b90565b91906102bd6102b86102c59361028a565b61029b565b908354610265565b9055565b6102d25f61003f565b5b806103006102fa6102f56102e5610089565b6102ef6001610099565b906100c9565b610039565b91610039565b10156103bf5760205f61036f61032161031b6021869061010b565b90610152565b61035e6103396103336021889061010b565b90610152565b9161035061034561002c565b93849288840161017b565b8682018103825203826101b7565b61036661002c565b91829182610220565b039060025afa156103ba576103b5906103b061038b5f516101de565b6103aa60216103a48561039e6001610099565b9061023c565b9061010b565b906102a7565b61005b565b6102d3565b61022c565b5056fe60806040526004361015610013575b6103b4565b61001d5f3561005c565b806301ffc9a714610057578063621fd1301461005257806379f6caf51461004d5763c5f2892f0361000e5761037f565b610327565b610197565b6100e8565b60e01c90565b60405190565b5f80fd5b5f80fd5b5f80fd5b63ffffffff60e01b1690565b61008981610074565b0361009057565b5f80fd5b905035906100a182610080565b565b906020828203126100bc576100b9915f01610094565b90565b61006c565b151590565b6100cf906100c1565b9052565b91906100e6905f602085019401906100c6565b565b34610118576101146101036100fe3660046100a3565b6103bc565b61010b610062565b918291826100d3565b0390f35b610068565b5f91031261012757565b61006c565b5190565b60209181520190565b90825f9392825e0152565b601f801991011690565b61016d61017660209361017b936101648161012c565b93848093610130565b95869101610139565b610144565b0190565b6101949160208201915f81840391015261014e565b90565b346101c7576101a736600461011d565b6101c36101b261046b565b6101ba610062565b9182918261017f565b0390f35b610068565b5f80fd5b5f80fd5b5f80fd5b909182601f830112156102125781359167ffffffffffffffff831161020d57602001926001830284011161020857565b6101d4565b6101d0565b6101cc565b90565b61022381610217565b0361022a57565b5f80fd5b9050359061023b8261021a565b565b9160c08383031261031d575f83013567ffffffffffffffff811161031857826102679185016101d8565b929093602081013567ffffffffffffffff8111610313578261028a9183016101d8565b929093604083013567ffffffffffffffff811161030e57826102ad9185016101d8565b929093606081013567ffffffffffffffff811161030957826102d09183016101d8565b929093608083013567ffffffffffffffff8111610304576102f6836103019286016101d8565b93909460a00161022e565b90565b610070565b610070565b610070565b610070565b610070565b61006c565b5f0190565b61034761033536600461023d565b99989098979197969296959395611213565b61034f610062565b8061035981610322565b0390f35b61036690610217565b9052565b919061037d905f6020850194019061035d565b565b346103af5761038f36600461011d565b6103ab61039a611975565b6103a2610062565b9182918261036a565b0390f35b610068565b5f80fd5b5f90565b6103c46103b8565b50806103df6103d96301ffc9a760e01b610074565b91610074565b149081156103ec575b5090565b9050610407610401636f0dc97560e11b610074565b91610074565b145f6103e8565b606090565b5f1c90565b90565b61042761042c91610413565b610418565b90565b610439905461041b565b90565b90565b67ffffffffffffffff1690565b90565b61046361045e6104689261043c565b61044c565b61043f565b90565b61047361040e565b5061048e610489610484602061042f565b61044f565b611cff565b90565b5090565b90565b6104ac6104a76104b192610495565b61044c565b61043c565b90565b60209181520190565b60207f626b6579206c656e677468000000000000000000000000000000000000000000917f4465706f736974436f6e74726163743a20696e76616c6964206e6f64655f70755f8201520152565b610517602b6040926104b4565b610520816104bd565b0190565b6105399060208101905f81830391015261050a565b90565b1561054357565b61054b610062565b62461bcd60e51b81528061056160048201610524565b0390fd5b90565b61057c61057761058192610565565b61044c565b61043c565b90565b60207f75735f7075626b6579206c656e67746800000000000000000000000000000000917f4465706f736974436f6e74726163743a20696e76616c696420636f6e73656e735f8201520152565b6105de60306040926104b4565b6105e781610584565b0190565b6106009060208101905f8183039101526105d1565b90565b1561060a57565b610612610062565b62461bcd60e51b815280610628600482016105eb565b0390fd5b60207f77616c5f63726564656e7469616c73206c656e67746800000000000000000000917f4465706f736974436f6e74726163743a20696e76616c696420776974686472615f8201520152565b61068660366040926104b4565b61068f8161062c565b0190565b6106a89060208101905f818303910152610679565b90565b156106b257565b6106ba610062565b62461bcd60e51b8152806106d060048201610693565b0390fd5b90565b6106eb6106e66106f0926106d4565b61044c565b61043c565b90565b60207f676e6174757265206c656e677468000000000000000000000000000000000000917f4465706f736974436f6e74726163743a20696e76616c6964206e6f64655f73695f8201520152565b61074d602e6040926104b4565b610756816106f3565b0190565b61076f9060208101905f818303910152610740565b90565b1561077957565b610781610062565b62461bcd60e51b8152806107976004820161075a565b0390fd5b90565b6107b26107ad6107b79261079b565b61044c565b61043c565b90565b60207f75735f7369676e6174757265206c656e67746800000000000000000000000000917f4465706f736974436f6e74726163743a20696e76616c696420636f6e73656e735f8201520152565b61081460336040926104b4565b61081d816107ba565b0190565b6108369060208101905f818303910152610807565b90565b1561084057565b610848610062565b62461bcd60e51b81528061085e60048201610821565b0390fd5b90565b61087961087461087e92610862565b61044c565b61043c565b90565b60207f6f6f206c6f770000000000000000000000000000000000000000000000000000917f4465706f736974436f6e74726163743a206465706f7369742076616c756520745f8201520152565b6108db60266040926104b4565b6108e481610881565b0190565b6108fd9060208101905f8183039101526108ce565b90565b1561090757565b61090f610062565b62461bcd60e51b815280610925600482016108e8565b0390fd5b90565b61094061093b61094592610929565b61044c565b61043c565b90565b634e487b7160e01b5f52601260045260245ffd5b61096861096e9161043c565b9161043c565b908115610979570690565b610948565b90565b61099561099061099a9261097e565b61044c565b61043c565b90565b60207f6f74206d756c7469706c65206f66206777656900000000000000000000000000917f4465706f736974436f6e74726163743a206465706f7369742076616c7565206e5f8201520152565b6109f760336040926104b4565b610a008161099d565b0190565b610a199060208101905f8183039101526109ea565b90565b15610a2357565b610a2b610062565b62461bcd60e51b815280610a4160048201610a04565b0390fd5b634e487b7160e01b5f52601160045260245ffd5b610a65610a6b9161043c565b9161043c565b908115610a76570490565b610948565b610a8f610a8a610a949261043f565b61044c565b61043c565b90565b60207f6f6f206869676800000000000000000000000000000000000000000000000000917f4465706f736974436f6e74726163743a206465706f7369742076616c756520745f8201520152565b610af160276040926104b4565b610afa81610a97565b0190565b610b139060208101905f818303910152610ae4565b90565b15610b1d57565b610b25610062565b62461bcd60e51b815280610b3b60048201610afe565b0390fd5b90825f939282370152565b9190610b6481610b5d81610b6995610130565b8095610b3f565b610144565b0190565b9a969194610bdc96610bb18d610bf89f9d9b9897610bce97610ba3610bea9f9a97610bc09860e08601918683035f880152610b4a565b926020818503910152610b4a565b918d6040818503910152610b4a565b908a820360608c015261014e565b9188830360808a0152610b4a565b9185830360a0870152610b4a565b9160c081840391015261014e565b90565b6fffffffffffffffffffffffffffffffff191690565b60801b90565b610c2b610c26610c309261097e565b610c11565b610bfb565b90565b905090565b909182610c4881610c4f93610c33565b8093610b3f565b0190565b90565b610c62610c6791610bfb565b610c53565b9052565b610c7c9060109493610c8393610c38565b8092610c56565b0190565b634e487b7160e01b5f52604160045260245ffd5b90610ca590610144565b810190811067ffffffffffffffff821117610cbf57604052565b610c87565b5f1b90565b610cee610ce592602092610cdc8161012c565b94858093610c33565b93849101610139565b0190565b610cfb91610cc9565b90565b610d06610062565b3d5f823e3d90fd5b90565b610d1d610d2291610217565b610d0e565b9052565b610d379060209493610d3e93610c38565b8092610d11565b0190565b9091610d4d92610c38565b90565b5f80fd5b5f80fd5b90939293848311610d78578411610d73576001820201920390565b610d54565b610d50565b9091610d8892610c38565b90565b610d9f610d9a610da49261097e565b610cc4565b610217565b90565b610db89060209493610dbf93610c38565b8092610d11565b0190565b602081610dd5610ddd93839695610d11565b018092610d11565b0190565b80610df2602092610df99694610d11565b0191610c38565b90565b67ffffffffffffffff191690565b60401b90565b610e24610e1f610e299261097e565b610e0a565b610dfc565b90565b90565b610e3b610e4091610dfc565b610e2c565b9052565b60209392610e61610e5a601893610e6995610cc9565b8092610e2f565b018092610d11565b0190565b60407f6564206465706f7369745f646174615f726f6f74000000000000000000000000917f4465706f736974436f6e74726163743a207265636f6e737472756374656420445f8201527f65706f7369744461746120646f6573206e6f74206d6174636820737570706c6960208201520152565b610eed60546060926104b4565b610ef681610e6d565b0190565b610f0f9060208101905f818303910152610ee0565b90565b15610f1957565b610f21610062565b62461bcd60e51b815280610f3760048201610efa565b0390fd5b610f456020610498565b90565b90565b610f5f610f5a610f6492610f48565b61044c565b61043c565b90565b610f709061043c565b60ff8111610f7e5760020a90565b610a45565b90565b610f9a610f95610f9f92610f83565b61044c565b61043c565b90565b610fb1610fb79193929361043c565b9261043c565b8203918211610fc257565b610a45565b610fea610fda610fd5610f3b565b610f67565b610fe46001610f86565b90610fa2565b90565b60207f6c00000000000000000000000000000000000000000000000000000000000000917f4465706f736974436f6e74726163743a206d65726b6c6520747265652066756c5f8201520152565b61104760216040926104b4565b61105081610fed565b0190565b6110699060208101905f81830391015261103a565b90565b1561107357565b61107b610062565b62461bcd60e51b81528061109160048201611054565b0390fd5b6110a46110aa9193929361043c565b9261043c565b82018092116110b557565b610a45565b906110c65f1991610cc4565b9181191691161790565b6110e46110df6110e99261043c565b61044c565b61043c565b90565b90565b906111046110ff61110b926110d0565b6110ec565b82546110ba565b9055565b600161111b910161043c565b90565b634e487b7160e01b5f52603260045260245ffd5b50602090565b90565b61114481611132565b82101561115e57611156600191611138565b910201905f90565b61111e565b1b90565b9190600861118291029161117c5f1984611163565b92611163565b9181191691161790565b61119590610217565b90565b6111a190610413565b90565b91906111ba6111b56111c29361118c565b611198565b908354611167565b9055565b1c90565b90565b6111dd9060086111e293026111c6565b6111ca565b90565b906111f091546111cd565b90565b634e487b7160e01b5f52600160045260245ffd5b1561120e57565b6111f3565b9091989495979396929a999a818361122a91610491565b602061123590610498565b9061123f9061043c565b146112499061053c565b898161125491610491565b603061125f90610568565b906112699061043c565b1461127390610603565b878761127e91610491565b602061128990610498565b906112939061043c565b1461129d906106ab565b88846112a891610491565b60406112b3906106d7565b906112bd9061043c565b146112c790610772565b84866112d291610491565b60606112dd9061079e565b906112e79061043c565b146112f190610839565b34670de0b6b3a764000061130490610865565b9061130e9061043c565b101561131990610900565b34633b9aca006113289061092c565b6113319161095c565b5f61133b90610981565b906113459061043c565b1461134f90610a1c565b34633b9aca0061135e9061092c565b61136791610a59565b8067ffffffffffffffff61137a90610a7b565b906113849061043c565b111561138f90610b16565b6113989061044f565b6113a190611cff565b99888a8c858b88928c8c8c89978b99959490919293946113c1602061042f565b6113ca9061044f565b6113d390611cff565b967f0cff1634a9a72df9d813ea7e3a3874a76086e081904ad3cf81e12e43f4d4c87a9b6113fe610062565b9b8c9b61140b9b8d610b6d565b0390a1905f61141990610c17565b91611422610062565b928392602084019261143393610c6b565b6020820181038252036114469082610c9b565b61144e610062565b611459819282610cf2565b03905a915f916002602094fa15611943576114b75f916114a66020946114986114828651610cc4565b93919361148d610062565b948593898501610d26565b868201810382520382610c9b565b6114ae610062565b91829182610cf2565b039060025afa1561193e575f6020916114d08251610cc4565b976114e56114dc610062565b92839283610d42565b039060025afa15611939576114fa5f51610cc4565b9160205f61155361154261151c868660409061151687926106d7565b92610d58565b9190611534611529610062565b938492888401610d7d565b868201810382520382610c9b565b61154a610062565b91829182610cf2565b039060025afa15611934575f6115c96115b86115896020946115758551610cc4565b969061158160406106d7565b908092610d58565b91906115aa61159786610d8b565b61159f610062565b948593898501610da7565b868201810382520382610c9b565b6115c0610062565b91829182610cf2565b039060025afa1561192f575f61161e60209261160d6115e88451610cc4565b916115ff6115f4610062565b938492888401610dc3565b868201810382520382610c9b565b611615610062565b91829182610cf2565b039060025afa1561192a575f61167360209261166261163d8451610cc4565b91611654611649610062565b938492888401610dc3565b868201810382520382610c9b565b61166a610062565b91829182610cf2565b039060025afa15611925576116cb5f916116ba6020946116ac6116968651610cc4565b9791936116a1610062565b948593898501610de1565b868201810382520382610c9b565b6116c2610062565b91829182610cf2565b039060025afa15611920575f61172a6020926117196116ea8451610cc4565b9561170b6116f786610e10565b93611700610062565b948593898501610e44565b868201810382520382610c9b565b611721610062565b91829182610cf2565b039060025afa1561191b575f61177f60209261176e6117498451610cc4565b91611760611755610062565b938492888401610dc3565b868201810382520382610c9b565b611776610062565b91829182610cf2565b039060025afa15611916576117b16117975f51610cc4565b926117ab6117a58592610217565b91610217565b14610f12565b6117dd6117be602061042f565b6117d76117d16117cc610fc7565b61043c565b9161043c565b1061106c565b6118036117fc6117ed6001610f86565b6117f7602061042f565b611095565b60206110ef565b61180d602061042f565b6118165f610981565b925b8361183261182c611827610f3b565b61043c565b9161043c565b101561190757816118436001610f86565b166118576118516001610f86565b9161043c565b146118ed575f6118af60209261189e61187a611874858a9061113b565b906111e5565b611890611885610062565b938492888401610dc3565b868201810382520382610c9b565b6118a6610062565b91829182610cf2565b039060025afa156118e8576118e16118db6118ca5f51610cc4565b926118d56002610f4b565b90610a59565b9361110f565b9290611818565b610cfe565b611905929391506118ff90915f61113b565b906111a4565b565b505090506119145f611207565b565b610cfe565b610cfe565b610cfe565b610cfe565b610cfe565b610cfe565b610cfe565b610cfe565b610cfe565b610cfe565b5f90565b6018939260208261196361196a9461197196610d11565b0190610cc9565b8092610e2f565b0190565b61197d611948565b50611986611948565b90611991602061042f565b61199a5f610981565b925b836119b66119b06119ab610f3b565b61043c565b9161043c565b1015611aed575f602091836119cb6001610f86565b166119df6119d96001610f86565b9161043c565b148214611a7557611a3690611a25611a016119fb858a9061113b565b906111e5565b611a17611a0c610062565b938492888401610dc3565b868201810382520382610c9b565b611a2d610062565b91829182610cf2565b039060025afa15611a7057611a69611a63611a515f51610cc4565b925b611a5d6002610f4b565b90610a59565b9361110f565b929061199c565b610cfe565b611ac790611ab6611a91611a8b60218a9061113b565b906111e5565b91611aa8611a9d610062565b938492888401610dc3565b868201810382520382610c9b565b611abe610062565b91829182610cf2565b039060025afa15611ae857611a69611a63611ae25f51610cc4565b92611a53565b610cfe565b60209293505f9150611b5490611b43611b15611b10611b0b8761042f565b61044f565b611cff565b91611b35611b2286610e10565b611b2a610062565b94859389850161194c565b868201810382520382610c9b565b611b4b610062565b91829182610cf2565b039060025afa15611b6c57611b695f51610cc4565b90565b610cfe565b90565b611b88611b83611b8d92611b71565b61044c565b61043c565b90565b90611ba3611b9c610062565b9283610c9b565b565b67ffffffffffffffff8111611bc357611bbf602091610144565b0190565b610c87565b90611bda611bd583611ba5565b611b90565b918252565b369037565b90611c09611bf183611bc8565b92602080611bff8693611ba5565b9201910390611bdf565b565b67ffffffffffffffff60c01b1690565b60c01b90565b611c35611c30611c3a9261043f565b611c1b565b611c0b565b90565b90565b611c54611c4f611c5992611c3d565b61044c565b61043c565b90565b60f81b90565b90611c6c8261012c565b811015611c7e57600160209102010190565b61111e565b90565b611c9a611c95611c9f92611c83565b61044c565b61043c565b90565b90565b611cb9611cb4611cbe92611ca2565b61044c565b61043c565b90565b90565b611cd8611cd3611cdd92611cc1565b61044c565b61043c565b90565b90565b611cf7611cf2611cfc92611ce0565b61044c565b61043c565b90565b90611d0861040e565b50611d24611d1e611d196008611b74565b611be4565b92611c21565b80611d2f6007611c40565b906008821015611f0657611d43911a611c5c565b611d5a84611d545f935f1a93610981565b90611c62565b5380611d666006611c86565b906008821015611f0157611d7a911a611c5c565b611d9284611d8c6001935f1a93610f86565b90611c62565b5380611d9e6005611ca5565b906008821015611efc57611db2911a611c5c565b611dca84611dc46002935f1a93610f4b565b90611c62565b5380611dd66004611cc4565b906008821015611ef757611dea911a611c5c565b611e0284611dfc6003935f1a93611ce3565b90611c62565b5380611e0e6003611ce3565b906008821015611ef257611e22911a611c5c565b611e3a84611e346004935f1a93611cc4565b90611c62565b5380611e466002610f4b565b906008821015611eed57611e5a911a611c5c565b611e7284611e6c6005935f1a93611ca5565b90611c62565b5380611e7e6001610f86565b906008821015611ee857611e92911a611c5c565b611eaa84611ea46006935f1a93611c86565b90611c62565b53611eb45f610981565b906008821015611ee357611ec8911a611c5c565b611ee083611eda6007935f1a93611c40565b90611c62565b53565b61111e565b61111e565b61111e565b61111e565b61111e565b61111e565b61111e565b61111e56fea2646970667358221220d795d2a8ef4f86bedb2c518bcd02cac4208692fa24afc784418c01911d2ede3364736f6c637829302e382e33312d646576656c6f702e323032352e31312e31322b636f6d6d69742e3637366264656363005a', + sourceMap: + '4879:5583:27:-:0;;;;;;;;;-1:-1:-1;4879:5583:27;:::i;:::-;;;;;:::i;:::-;;;;;;;;;;;;;;;;;;;;;:::i;:::-;;:::i;:::-;;:::i;:::-;;:::i;:::-;;;;:::o;:::-;;;;:::o;:::-;;;;;;;;;;;;;;;;;;:::o;:::-;;;;:::i;:::-;;;;:::o;:::-;;;;;;;;;;;;:::i;:::-;:::o;:::-;;;;;;;;;;;;;;:::i;:::-;;:::o;:::-;;:::i;:::-;;;;:::o;:::-;;;;:::i;:::-;;;:::o;:::-;;;;;;;;;;;;;:::i;:::-;:::o;:::-;;;;;;;;;;:::i;:::-;;:::i;:::-;;;:::i;:::-;;;;;;:::i;:::-;;;;;;:::i;:::-;;;;;;;:::o;:::-;;:::i;:::-;;;:::o;:::-;;;;;;;:::o;:::-;;;;;;;;;;:::o;:::-;;;;;;;;:::o;:::-;;;;;;;;;;:::i;:::-;;;;;;:::i;:::-;;;;;;:::i;:::-;;:::i;:::-;;;:::o;:::-;;;;;;;;;;;;;;;:::i;:::-;;:::o;:::-;;;;;;;;:::i;:::-;;;;:::i;:::-;;;:::i;:::-;;;;;;:::i;:::-;;;;;;:::i;:::-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::o;:::-;;:::i;:::-;;:::i;:::-;;:::i;:::-;;:::o;:::-;;;;:::i;:::-;;;;:::o;:::-;;;;;;;;;;;;:::i;:::-;:::o;:::-;;;;;;;;;;;;;;;;;;;;;;;;:::i;:::-;;;;;;;;;;;;;;;;;;;:::i;:::-;;;;;;;;;;;;;;;;;;;:::i;:::-;;;;;;;;;;;;;;;;;;;:::i;:::-;;;;;;;;;;;;;;;;;;;;:::i;:::-;;;;;;;:::i;:::-;;:::o;:::-;;:::i;:::-;;:::i;:::-;;:::i;:::-;;:::i;:::-;;:::i;:::-;;:::i;:::-;;;;:::o;:::-;;;;;;:::i;:::-;;;;;;;;;;;;;;;:::i;:::-;;;:::i;:::-;;;;;:::i;:::-;;;;;;;;:::i;:::-;;;:::o;:::-;;;;;;;;;;;;;:::i;:::-;:::o;:::-;;;;;;;;:::i;:::-;;;;:::i;:::-;;;:::i;:::-;;;;;;:::i;:::-;;;;;;:::i;:::-;;;;;;;:::o;9786:201::-;9865:4;;:::i;:::-;9888:11;;:39;;9903:24;;;9888:39;:::i;:::-;;;:::i;:::-;;:92;;;;;9786:201;9881:99;;:::o;9888:92::-;9931:11;;:49;;9946:34;;;9931:49;:::i;:::-;;;:::i;:::-;;9888:92;;;4879:5583;;;:::o;:::-;;;;:::o;:::-;;:::o;:::-;;;;;:::i;:::-;;:::i;:::-;;:::o;:::-;;;;;:::i;:::-;;:::o;:::-;;:::o;:::-;;;;:::o;:::-;;:::o;:::-;;;;;;:::i;:::-;;:::i;:::-;;:::i;:::-;;:::o;6133:141::-;6194:12;;:::i;:::-;6252:13;6225:42;6245:21;6252:13;;;:::i;:::-;6245:21;:::i;:::-;6225:42;:::i;:::-;6218:49;:::o;4879:5583::-;;;:::o;:::-;;:::o;:::-;;;;;;:::i;:::-;;:::i;:::-;;:::i;:::-;;:::o;:::-;;;;;;;:::o;:::-;;;;;;;;;;;:::o;:::-;;;;;;:::i;:::-;;;;:::i;:::-;;;:::o;:::-;;;;;;;;;;;;;;;:::i;:::-;;:::o;:::-;;;;:::o;:::-;;;:::i;:::-;;;;;;;;;;;;:::i;:::-;;;;;;:::o;:::-;;;;;;:::i;:::-;;:::i;:::-;;:::i;:::-;;:::o;:::-;;;;;;;;;;;:::o;:::-;;;;;;:::i;:::-;;;;:::i;:::-;;;:::o;:::-;;;;;;;;;;;;;;;:::i;:::-;;:::o;:::-;;;;:::o;:::-;;;:::i;:::-;;;;;;;;;;;;:::i;:::-;;;;;;;;;;;;;;;:::o;:::-;;;;;;:::i;:::-;;;;:::i;:::-;;;:::o;:::-;;;;;;;;;;;;;;;:::i;:::-;;:::o;:::-;;;;:::o;:::-;;;:::i;:::-;;;;;;;;;;;;:::i;:::-;;;;;;:::o;:::-;;;;;;:::i;:::-;;:::i;:::-;;:::i;:::-;;:::o;:::-;;;;;;;;;;;:::o;:::-;;;;;;:::i;:::-;;;;:::i;:::-;;;:::o;:::-;;;;;;;;;;;;;;;:::i;:::-;;:::o;:::-;;;;:::o;:::-;;;:::i;:::-;;;;;;;;;;;;:::i;:::-;;;;;;:::o;:::-;;;;;;:::i;:::-;;:::i;:::-;;:::i;:::-;;:::o;:::-;;;;;;;;;;;:::o;:::-;;;;;;:::i;:::-;;;;:::i;:::-;;;:::o;:::-;;;;;;;;;;;;;;;:::i;:::-;;:::o;:::-;;;;:::o;:::-;;;:::i;:::-;;;;;;;;;;;;:::i;:::-;;;;;;:::o;:::-;;;;;;:::i;:::-;;:::i;:::-;;:::i;:::-;;:::o;:::-;;;;;;;;;;;:::o;:::-;;;;;;:::i;:::-;;;;:::i;:::-;;;:::o;:::-;;;;;;;;;;;;;;;:::i;:::-;;:::o;:::-;;;;:::o;:::-;;;:::i;:::-;;;;;;;;;;;;:::i;:::-;;;;;;;;;;;;;;;;;;;;;:::i;:::-;;;:::i;:::-;;;;;;;;:::o;:::-;;:::i;:::-;;;;;;:::i;:::-;;:::i;:::-;;:::i;:::-;;:::o;:::-;;;;;;;;;;;:::o;:::-;;;;;;:::i;:::-;;;;:::i;:::-;;;:::o;:::-;;;;;;;;;;;;;;;:::i;:::-;;:::o;:::-;;;;:::o;:::-;;;:::i;:::-;;;;;;;;;;;;:::i;:::-;;;;;;;;;;;;;;:::o;:::-;;;;;;;;;;:::i;:::-;;;;:::i;:::-;;:::i;:::-;;;:::o;:::-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::i;:::-;;;;;;;;;;:::i;:::-;;;;;;;;;;;:::i;:::-;;;;;;;;;;:::i;:::-;;;;;;;;;;:::i;:::-;;;;;;;;;;:::i;:::-;;;;;;;;;;:::i;:::-;;:::o;:::-;;;;;:::o;:::-;;;;:::o;:::-;;;;;;:::i;:::-;;:::i;:::-;;:::i;:::-;;:::o;:::-;;;;:::o;:::-;;;;;;;;;:::i;:::-;;;;:::i;:::-;;;:::o;:::-;;:::o;:::-;;;;;:::i;:::-;;:::i;:::-;;;:::o;:::-;;;;;;;;;:::i;:::-;;;;:::i;:::-;;;:::o;:::-;;;;;;;;;;;;;;;;;:::i;:::-;;;;;;;;;;;;;;:::o;:::-;;:::i;:::-;;;;:::o;:::-;;;;;;;;;:::i;:::-;;;;;;:::i;:::-;;;;;;:::i;:::-;;;:::o;:::-;;;;:::i;:::-;;:::o;:::-;;;:::i;:::-;;;;;;;;;;:::o;:::-;;;;;:::i;:::-;;:::i;:::-;;;:::o;:::-;;;;;;;;;:::i;:::-;;;;:::i;:::-;;;:::o;:::-;;;;;;:::i;:::-;;:::o;:::-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::o;:::-;;:::i;:::-;;:::i;:::-;;;;;;:::i;:::-;;:::o;:::-;;;;;;:::i;:::-;;:::i;:::-;;:::i;:::-;;:::o;:::-;;;;;;;;;:::i;:::-;;;;:::i;:::-;;;:::o;:::-;;;;;;;;;;:::i;:::-;;;;;:::i;:::-;;;:::o;:::-;;;;;;;;;:::i;:::-;;;;:::i;:::-;;:::o;:::-;;;;;:::o;:::-;;;;:::o;:::-;;;;;;:::i;:::-;;:::i;:::-;;:::i;:::-;;:::o;:::-;;:::o;:::-;;;;;:::i;:::-;;:::i;:::-;;;:::o;:::-;;;;;;;;;;;:::i;:::-;;;;:::i;:::-;;;;;:::i;:::-;;;:::o;:::-;;;;;;;;;;;;;;;;:::o;:::-;;;;;;:::i;:::-;;;;:::i;:::-;;;:::o;:::-;;;;;;;;;;;;;;;:::i;:::-;;:::o;:::-;;;;:::o;:::-;;;:::i;:::-;;;;;;;;;;;;:::i;:::-;;;;4938:46;4982:2;;;:::i;:::-;4938:46;:::o;4982:2::-;;:::o;:::-;;;;;;:::i;:::-;;:::i;:::-;;:::i;:::-;;:::o;:::-;;;;:::i;:::-;;;;;;;;;:::o;:::-;;:::i;:::-;;:::o;:::-;;;;;;:::i;:::-;;:::i;:::-;;:::i;:::-;;:::o;:::-;;;;;;;;:::i;:::-;;;:::i;:::-;;;;;;;;:::o;:::-;;:::i;5059:68::-;5093:34;:30;5096:27;;:::i;:::-;5093:30;:::i;:::-;:34;5126:1;5093:34;:::i;:::-;;;:::i;:::-;5059:68;:::o;5093:34::-;;;;;;;;;;;:::o;:::-;;;;;;:::i;:::-;;;;:::i;:::-;;;:::o;:::-;;;;;;;;;;;;;;;:::i;:::-;;:::o;:::-;;;;:::o;:::-;;;:::i;:::-;4879:5583;;;5093:34;;;;;;;;:::i;:::-;;;;;;;;;;;;:::i;:::-;;;:::i;:::-;;;;;;;;:::o;:::-;;:::i;:::-;;;;;;;:::i;:::-;;;;;;;;;:::o;:::-;;;;;;:::i;:::-;;:::i;:::-;;:::i;:::-;;:::o;:::-;;:::o;:::-;;;;;;;:::i;:::-;;:::i;:::-;;;;:::i;:::-;;;:::o;:::-;;;;;;:::i;:::-;;:::o;:::-;4879:5583;;;5093:34;;;;;;;;;;;;:::o;:::-;;:::o;:::-;;;;:::i;:::-;;;;;;;;;;:::i;:::-;;;;;;;:::o;:::-;;:::i;:::-;;;:::o;:::-;;;;;;;;;;;;;:::i;:::-;;;:::i;:::-;;;;;;;;;:::o;:::-;;;;:::i;:::-;;:::o;:::-;;;;:::i;:::-;;:::o;:::-;;;;;;;;:::i;:::-;;:::i;:::-;;;;;:::i;:::-;;;:::o;:::-;;;:::o;:::-;;:::o;:::-;;;;;;;;:::i;:::-;;:::i;:::-;;:::o;:::-;;;;;;:::i;:::-;;:::o;:::-;4879:5583;;;5093:34;;;;;;;;;;;;:::o;:::-;;:::i;6280:3500::-;;;;;;;;;;;;;6657:11;;:18;;;:::i;:::-;6679:2;6657:24;;;:::i;:::-;;;;;:::i;:::-;;6649:80;;;:::i;:::-;6747:16;;:23;;;:::i;:::-;6774:2;6747:29;;;:::i;:::-;;;;;:::i;:::-;;6739:90;;;:::i;:::-;6847:22;;:29;;;:::i;:::-;6880:2;6847:35;;;:::i;:::-;;;;;:::i;:::-;;6839:102;;;:::i;:::-;6959:14;;:21;;;:::i;:::-;6984:2;6959:27;;;:::i;:::-;;;;;:::i;:::-;;6951:86;;;:::i;:::-;7055:19;;:26;;;:::i;:::-;7085:2;7055:32;;;:::i;:::-;;;;;:::i;:::-;;7047:96;;;:::i;:::-;7194:9;7207:7;7194:20;;;:::i;:::-;;;;;:::i;:::-;;;7186:71;;;:::i;:::-;7275:9;7287:6;7275:18;;;:::i;:::-;;;;:::i;:::-;7297:1;7275:23;;;:::i;:::-;;;;;:::i;:::-;;7267:87;;;:::i;:::-;7386:9;7398:6;7386:18;;;:::i;:::-;;;;:::i;:::-;7422:14;7440:16;7422:34;;;:::i;:::-;;;;;:::i;:::-;;;7414:86;;;:::i;:::-;7590:22;;;:::i;:::-;7570:43;;;:::i;:::-;7658:11;;;;;;;7685:16;;;;;;;7717:22;;7755:6;7777:14;;7807:19;;7869:13;;;;:::i;:::-;7862:21;;;:::i;:::-;7842:42;;;:::i;:::-;7630:266;;;;;:::i;:::-;;;;;;;;:::i;:::-;;;;8035:16;8061:1;8053:10;;;:::i;:::-;8018:46;;;:::i;:::-;;;;;;;;;;;:::i;:::-;;;;;;;;;;;;;:::i;:::-;8011:54;;:::i;:::-;;;;;;:::i;:::-;;;;;;;;;;;;;;8099:60;;8011:54;8106:52;8099:60;8011:54;8106:52;8011:54;;;;:::i;:::-;8123:11;;8136:21;8106:52;;:::i;:::-;;;;;;;;:::i;:::-;;;;;;;;;;;:::i;:::-;8099:60;;:::i;:::-;;;;;;:::i;:::-;;;;;;;;;8201:22;;8099:60;;;;;:::i;:::-;8208:14;8201:22;;;:::i;:::-;;;;;;:::i;:::-;;;;;;;;;;;;;:::i;:::-;8333:19;8309:50;;;8316:42;8333:24;:19;;8354:2;8333:24;;;;;:::i;:::-;;;:::i;:::-;8316:42;;;;;:::i;:::-;;;;;;;;:::i;:::-;;;;;;;;;;;:::i;:::-;8309:50;;:::i;:::-;;;;;;:::i;:::-;;;;;;;;;8375:62;;8382:54;8399:24;8375:62;8309:50;;;;;:::i;:::-;8399:19;;:24;8419:2;8399:24;:::i;:::-;;;;;:::i;:::-;8433:1;;8382:54;8425:10;8433:1;8425:10;:::i;:::-;8382:54;;:::i;:::-;;;;;;;;:::i;:::-;;;;;;;;;;;:::i;:::-;8375:62;;:::i;:::-;;;;;;:::i;:::-;;;;;;;;;8270:180;;;8375:62;8277:172;8375:62;;;;:::i;:::-;8277:172;;;;:::i;:::-;;;;;;;;:::i;:::-;;;;;;;;;;;:::i;:::-;8270:180;;:::i;:::-;;;;;;:::i;:::-;;;;;;;;;8487:71;;;8270:180;8494:63;8270:180;;;;:::i;:::-;8494:63;;;;:::i;:::-;;;;;;;;:::i;:::-;;;;;;;;;;;:::i;:::-;8487:71;;:::i;:::-;;;;;;:::i;:::-;;;;;;;;;8624:61;;8487:71;8631:53;8624:61;8487:71;8631:53;8487:71;;;;:::i;:::-;8648:11;8661:22;;8631:53;;:::i;:::-;;;;;;;;:::i;:::-;;;;;;;;;;;:::i;:::-;8624:61;;:::i;:::-;;;;;;:::i;:::-;;;;;;;;;8701:60;;;8624:61;8708:52;8624:61;;;;:::i;:::-;8725:6;8708:52;8733:10;8741:1;8733:10;:::i;:::-;8745:14;8708:52;;:::i;:::-;;;;;;;;:::i;:::-;;;;;;;;;;;:::i;:::-;8701:60;;:::i;:::-;;;;;;:::i;:::-;;;;;;;;;8585:189;;;8701:60;8592:181;8701:60;;;;:::i;:::-;8592:181;;;;:::i;:::-;;;;;;;;:::i;:::-;;;;;;;;;;;:::i;:::-;8585:189;;:::i;:::-;;;;;;:::i;:::-;;;;;;;;;8850:122;8585:189;;;;:::i;:::-;8858:4;:25;;:4;8866:17;8858:25;:::i;:::-;;;:::i;:::-;;8850:122;:::i;:::-;9074:79;9082:13;;;:::i;:::-;:33;;9098:17;;:::i;:::-;9082:33;:::i;:::-;;;:::i;:::-;;9074:79;:::i;:::-;9244:18;;;9261:1;9244:18;:::i;:::-;;;;:::i;:::-;;:::i;:::-;;;:::i;:::-;9284:13;;;:::i;:::-;9312:15;9326:1;9312:15;:::i;:::-;9307:283;9367:8;9329:6;:36;;9338:27;;:::i;:::-;9329:36;:::i;:::-;;;:::i;:::-;;;;;9396:4;:8;9403:1;9396:8;:::i;:::-;;9395:15;;9409:1;9395:15;:::i;:::-;;;:::i;:::-;;9391:99;;9510:46;;;9534:6;9517:38;9534:14;;:6;9541;9534:14;;:::i;:::-;;;:::i;:::-;9517:38;;;:::i;:::-;;;;;;;;:::i;:::-;;;;;;;;;;;:::i;:::-;9510:46;;:::i;:::-;;;;;;:::i;:::-;;;;;;;;;9367:8;9570:9;9510:46;;;;:::i;:::-;9578:1;9570:9;9578:1;9570:9;:::i;:::-;;;:::i;:::-;9367:8;;:::i;:::-;9312:15;;;;9510:46;;:::i;9391:99::-;9430:21;9447:4;;;;9430:14;9447:4;9430:6;;:14;:::i;:::-;:21;;:::i;:::-;9469:7::o;9329:36::-;;;;;9760:13;9767:5;9760:13;:::i;:::-;6280:3500::o;8585:189::-;;:::i;8701:60::-;;:::i;8624:61::-;;:::i;8487:71::-;;:::i;8270:180::-;;:::i;8375:62::-;;:::i;8309:50::-;;:::i;8201:22::-;;:::i;8099:60::-;;:::i;8011:54::-;;:::i;4879:5583::-;;;:::o;:::-;;;;;;;;;;;;:::i;:::-;;;;:::i;:::-;;;;:::i;:::-;;;:::o;5535:592::-;5595:7;;:::i;:::-;5614:12;;;:::i;:::-;5648:13;;;;:::i;:::-;5676:15;5690:1;5676:15;:::i;:::-;5671:301;5731:8;5693:6;:36;;5702:27;;:::i;:::-;5693:36;:::i;:::-;;;:::i;:::-;;;;;5799:46;;5760:4;;:8;5767:1;5760:8;:::i;:::-;;5759:15;;5773:1;5759:15;:::i;:::-;;;:::i;:::-;;5755:183;;;;5799:46;5823:6;5806:38;5823:14;;:6;5830;5823:14;;:::i;:::-;;;:::i;:::-;5806:38;;;:::i;:::-;;;;;;;;:::i;:::-;;;;;;;;;;;:::i;:::-;5799:46;;:::i;:::-;;;;;;:::i;:::-;;;;;;;;;5731:8;5952:9;5799:46;;;;:::i;:::-;5755:183;;5952:9;5960:1;5952:9;:::i;:::-;;;:::i;:::-;5731:8;;:::i;:::-;5676:15;;;;5799:46;;:::i;5755:183::-;5887:51;5911:4;5894:43;5917:19;;:11;5929:6;5917:19;;:::i;:::-;;;:::i;:::-;5894:43;;;;:::i;:::-;;;;;;;;:::i;:::-;;;;;;;;;;;:::i;:::-;5887:51;;:::i;:::-;;;;;;:::i;:::-;;;;;;;;;5731:8;5952:9;5887:51;;;;:::i;:::-;5755:183;;;5887:51;;:::i;5693:36::-;5988:132;5693:36;;;5988:132;5693:36;;5988:132;5693:36;5995:124;6043:42;6063:21;6070:13;;;:::i;:::-;6063:21;:::i;:::-;6043:42;:::i;:::-;6107:1;5995:124;6099:10;6107:1;6099:10;:::i;:::-;5995:124;;:::i;:::-;;;;;;;;:::i;:::-;;;;;;;;;;;:::i;:::-;5988:132;;:::i;:::-;;;;;;:::i;:::-;;;;;;;;;;;;;:::i;:::-;5981:139;:::o;5988:132::-;;:::i;4879:5583::-;;:::o;:::-;;;;;;:::i;:::-;;:::i;:::-;;:::i;:::-;;:::o;:::-;;;;;:::i;:::-;;;;:::i;:::-;:::o;:::-;;;;;;;;;;:::i;:::-;;;:::o;:::-;;:::i;:::-;;;;;;:::i;:::-;;:::i;:::-;;;;:::o;:::-;;;;:::o;:::-;;;;;;:::i;:::-;;;;;;;;:::i;:::-;;;;;;;:::i;:::-;:::o;:::-;;;;;;:::o;:::-;;;;:::o;:::-;;;;;;:::i;:::-;;:::i;:::-;;:::i;:::-;;:::o;:::-;;:::o;:::-;;;;;;:::i;:::-;;:::i;:::-;;:::i;:::-;;:::o;:::-;;;;:::o;:::-;;;;;:::i;:::-;;;;;;;;;;;;;:::o;:::-;;:::i;:::-;;:::o;:::-;;;;;;:::i;:::-;;:::i;:::-;;:::i;:::-;;:::o;:::-;;:::o;:::-;;;;;;:::i;:::-;;:::i;:::-;;:::i;:::-;;:::o;:::-;;:::o;:::-;;;;;;:::i;:::-;;:::i;:::-;;:::i;:::-;;:::o;:::-;;:::o;:::-;;;;;;:::i;:::-;;:::i;:::-;;:::i;:::-;;:::o;9993:467::-;;10059:16;;:::i;:::-;10103:1;10135:13;10093:12;;10103:1;10093:12;:::i;:::-;;:::i;:::-;10142:5;10135:13;:::i;:::-;10216:10;:13;10227:1;10216:13;:::i;:::-;;;;;;;;;;;;:::i;:::-;10207:22;:3;:22;10211:1;10207:22;;;;;:::i;:::-;;;:::i;:::-;;10248:10;:13;10259:1;10248:13;:::i;:::-;;;;;;;;;;;;:::i;:::-;10239:22;:3;:22;10243:1;10239:22;;;;;:::i;:::-;;;:::i;:::-;;10280:10;:13;10291:1;10280:13;:::i;:::-;;;;;;;;;;;;:::i;:::-;10271:22;:3;:22;10275:1;10271:22;;;;;:::i;:::-;;;:::i;:::-;;10312:10;:13;10323:1;10312:13;:::i;:::-;;;;;;;;;;;;:::i;:::-;10303:22;:3;:22;10307:1;10303:22;;;;;:::i;:::-;;;:::i;:::-;;10344:10;:13;10355:1;10344:13;:::i;:::-;;;;;;;;;;;;:::i;:::-;10335:22;:3;:22;10339:1;10335:22;;;;;:::i;:::-;;;:::i;:::-;;10376:10;:13;10387:1;10376:13;:::i;:::-;;;;;;;;;;;;:::i;:::-;10367:22;:3;:22;10371:1;10367:22;;;;;:::i;:::-;;;:::i;:::-;;10408:10;:13;10419:1;10408:13;:::i;:::-;;;;;;;;;;;;:::i;:::-;10399:22;:3;:22;10403:1;10399:22;;;;;:::i;:::-;;;:::i;:::-;;10440:13;10451:1;10440:13;:::i;:::-;;;;;;;;;;;;:::i;:::-;10431:22;:3;:22;10435:1;10431:22;;;;;:::i;:::-;;;:::i;:::-;;9993:467::o;10440:13::-;;:::i;10408:::-;;:::i;10376:::-;;:::i;10344:::-;;:::i;10312:::-;;:::i;10280:::-;;:::i;10248:::-;;:::i;10216:::-;;:::i', + linkReferences: {}, +} diff --git a/packages/seismic-viem/package.json b/packages/seismic-viem/package.json index 07c2a75c..1add35a6 100644 --- a/packages/seismic-viem/package.json +++ b/packages/seismic-viem/package.json @@ -1,6 +1,6 @@ { "name": "seismic-viem", - "version": "1.0.50", + "version": "1.0.51", "description": "Typescript interface for Seismic", "type": "module", "main": "./dist/_cjs/index.js", diff --git a/packages/seismic-viem/src/abis/depositContract.ts b/packages/seismic-viem/src/abis/depositContract.ts new file mode 100644 index 00000000..61d31417 --- /dev/null +++ b/packages/seismic-viem/src/abis/depositContract.ts @@ -0,0 +1,83 @@ +import type { Abi } from 'abitype' + +export const depositContractAbi = [ + { + type: 'constructor', + inputs: [], + stateMutability: 'nonpayable', + }, + { + type: 'function', + name: 'deposit', + inputs: [ + { name: 'node_pubkey', type: 'bytes', internalType: 'bytes' }, + { name: 'consensus_pubkey', type: 'bytes', internalType: 'bytes' }, + { name: 'withdrawal_credentials', type: 'bytes', internalType: 'bytes' }, + { name: 'node_signature', type: 'bytes', internalType: 'bytes' }, + { name: 'consensus_signature', type: 'bytes', internalType: 'bytes' }, + { name: 'deposit_data_root', type: 'bytes32', internalType: 'bytes32' }, + ], + outputs: [], + stateMutability: 'payable', + }, + { + type: 'function', + name: 'get_deposit_count', + inputs: [], + outputs: [{ name: '', type: 'bytes', internalType: 'bytes' }], + stateMutability: 'view', + }, + { + type: 'function', + name: 'get_deposit_root', + inputs: [], + outputs: [{ name: '', type: 'bytes32', internalType: 'bytes32' }], + stateMutability: 'view', + }, + { + type: 'function', + name: 'supportsInterface', + inputs: [{ name: 'interfaceId', type: 'bytes4', internalType: 'bytes4' }], + outputs: [{ name: '', type: 'bool', internalType: 'bool' }], + stateMutability: 'pure', + }, + { + type: 'event', + name: 'DepositEvent', + inputs: [ + { + name: 'node_pubkey', + type: 'bytes', + indexed: false, + internalType: 'bytes', + }, + { + name: 'consensus_pubkey', + type: 'bytes', + indexed: false, + internalType: 'bytes', + }, + { + name: 'withdrawal_credentials', + type: 'bytes', + indexed: false, + internalType: 'bytes', + }, + { name: 'amount', type: 'bytes', indexed: false, internalType: 'bytes' }, + { + name: 'node_signature', + type: 'bytes', + indexed: false, + internalType: 'bytes', + }, + { + name: 'consensus_signature', + type: 'bytes', + indexed: false, + internalType: 'bytes', + }, + { name: 'index', type: 'bytes', indexed: false, internalType: 'bytes' }, + ], + anonymous: false, + }, +] as const satisfies Abi diff --git a/packages/seismic-viem/src/actions/depositContract.ts b/packages/seismic-viem/src/actions/depositContract.ts new file mode 100644 index 00000000..190ba143 --- /dev/null +++ b/packages/seismic-viem/src/actions/depositContract.ts @@ -0,0 +1,107 @@ +import type { + Account, + Address, + Chain, + Hex, + PublicClient, + ReadContractParameters, + ReadContractReturnType, + Transport, + WalletClient, +} from 'viem' +import type { WriteContractReturnType } from 'viem' +import { readContract, writeContract } from 'viem/actions' + +import { depositContractAbi } from '@sviem/abis/depositContract.ts' + +export const DEPOSIT_CONTRACT_ADDRESS: Address = + '0x00000000219ab540356cBB839Cbe05303d7705Fa' + +export type DepositParameters = { + /** Deposit contract address */ + address?: Address + /** Validator public key*/ + nodePubkey: Hex + /** Consensus public key */ + consensusPubkey: Hex + /** Withdrawal credentials */ + withdrawalCredentials: Hex + /** Node signature */ + nodeSignature: Hex + /** Consensus signature */ + consensusSignature: Hex + /** Deposit data root */ + depositDataRoot: Hex + /** Amount of ETH to deposit */ + value: bigint +} + +/** Base parameters for deposit contract read operations */ +export type DepositContractBaseParameters = { + /** Deposit contract address */ + address?: Address +} + +export type GetDepositRootParameters = DepositContractBaseParameters +export type GetDepositCountParameters = DepositContractBaseParameters + +export type DepositContractPublicActions = { + getDepositRoot: ( + args: GetDepositRootParameters + ) => Promise + getDepositCount: ( + args: GetDepositCountParameters + ) => Promise +} + +export const depositContractPublicActions = < + TTransport extends Transport, + TChain extends Chain | undefined = Chain | undefined, +>( + client: PublicClient +): DepositContractPublicActions => ({ + getDepositRoot: async (args) => + readContract(client, { + abi: depositContractAbi, + address: args.address || DEPOSIT_CONTRACT_ADDRESS, + functionName: 'get_deposit_root', + } as ReadContractParameters), + + getDepositCount: async (args) => + readContract(client, { + abi: depositContractAbi, + address: args.address || DEPOSIT_CONTRACT_ADDRESS, + functionName: 'get_deposit_count', + } as ReadContractParameters< + typeof depositContractAbi, + 'get_deposit_count' + >), +}) + +export type DepositContractWalletActions = { + deposit: (args: DepositParameters) => Promise +} + +export const depositContractWalletActions = < + TTransport extends Transport, + TChain extends Chain | undefined = Chain | undefined, + TAccount extends Account | undefined = Account | undefined, +>( + client: WalletClient +): DepositContractWalletActions => ({ + deposit: async (args) => + writeContract(client, { + abi: depositContractAbi, + address: args.address || DEPOSIT_CONTRACT_ADDRESS, + functionName: 'deposit', + args: [ + args.nodePubkey, + args.consensusPubkey, + args.withdrawalCredentials, + args.nodeSignature, + args.consensusSignature, + args.depositDataRoot, + ], + value: args.value, + } as any), +}) diff --git a/packages/seismic-viem/src/client.ts b/packages/seismic-viem/src/client.ts index c98c08a2..a11e9de3 100644 --- a/packages/seismic-viem/src/client.ts +++ b/packages/seismic-viem/src/client.ts @@ -19,6 +19,14 @@ import { } from 'viem' import { generatePrivateKey, privateKeyToAccount } from 'viem/accounts' +import type { + DepositContractPublicActions, + DepositContractWalletActions, +} from '@sviem/actions/depositContract.ts' +import { + depositContractPublicActions, + depositContractWalletActions, +} from '@sviem/actions/depositContract.ts' import { EncryptionActions, encryptionActions, @@ -49,7 +57,9 @@ export type ShieldedPublicClient< rpcSchema extends RpcSchema ? [...PublicRpcSchema, ...rpcSchema] : PublicRpcSchema, - PublicActions & ShieldedPublicActions + PublicActions & + ShieldedPublicActions & + DepositContractPublicActions > > @@ -82,7 +92,9 @@ export type ShieldedWalletClient< WalletActions & EncryptionActions & ShieldedPublicActions & - ShieldedWalletActions + ShieldedWalletActions & + DepositContractPublicActions & + DepositContractWalletActions > type SeismicClients< @@ -169,7 +181,12 @@ export const createShieldedPublicClient = < undefined, rpcSchema >(parameters) as ShieldedPublicClient - return viemPublicClient.extend(shieldedPublicActions as any) + return ( + viemPublicClient + .extend(shieldedPublicActions as any) + // @ts-ignore + .extend(depositContractPublicActions as any) + ) } export const getSeismicClients = async < @@ -213,7 +230,8 @@ export const getSeismicClients = async < .extend(() => shieldedPublicActions(pubClient)) // @ts-ignore .extend(shieldedWalletActions) - + // @ts-ignore + .extend(depositContractWalletActions as any) return { public: pubClient, wallet, diff --git a/packages/seismic-viem/src/index.ts b/packages/seismic-viem/src/index.ts index 67675244..630e05e7 100644 --- a/packages/seismic-viem/src/index.ts +++ b/packages/seismic-viem/src/index.ts @@ -105,3 +105,4 @@ export { export type { Secp256K1SigParams } from '@sviem/precompiles/secp256k1.ts' export type { CallClient, Precompile } from '@sviem/precompiles/precompile.ts' +export { DEPOSIT_CONTRACT_ADDRESS } from '@sviem/actions/depositContract.ts' diff --git a/tests/seismic-viem/src/viem.test.ts b/tests/seismic-viem/src/viem.test.ts index 37a60b92..30fa7217 100644 --- a/tests/seismic-viem/src/viem.test.ts +++ b/tests/seismic-viem/src/viem.test.ts @@ -10,6 +10,7 @@ import { testSeismicTx, } from '@sviem-tests/index.ts' import { testAesKeygen } from '@sviem-tests/tests/aesKeygen.ts' +import { testDepositContract } from '@sviem-tests/tests/contract/depositContract.ts' import { testSeismicTxEncoding } from '@sviem-tests/tests/encoding.ts' import { testRng } from '@sviem-tests/tests/precompiles.ts' import { testHkdfHex } from '@sviem-tests/tests/precompiles.ts' @@ -100,6 +101,16 @@ describe('Seismic Contract', async () => { ) }) +describe('Deposit Contract', async () => { + test( + 'deploy & test deposit contract functionality', + async () => await testDepositContract({ chain, url, account }), + { + timeout: CONTRACT_TIMEOUT_MS, + } + ) +}) + describe('twrite should not use seismic tx', async () => { test( 'ShieldedContract.twrite should not use seismic tx',