@avalanche-sdk/client
Version:
A TypeScript SDK for interacting with the Avalanche network through JSON-RPC APIs. This SDK provides a comprehensive set of tools to interact with all Avalanche chains (P-Chain, X-Chain, C-Chain) and various APIs, including wallet functionality for transa
3 lines • 227 kB
JavaScript
import{createClient as e,fallback as t,http as n,custom as r,webSocket as a,createPublicClient as s,rpcSchema as o,isAddress as i,walletActions as f,publicActions as c}from"viem";export{AbiConstructorNotFoundError,AbiConstructorParamsNotFoundError,AbiDecodingDataSizeInvalidError,AbiDecodingDataSizeTooSmallError,AbiDecodingZeroDataError,AbiEncodingArrayLengthMismatchError,AbiEncodingBytesSizeMismatchError,AbiEncodingLengthMismatchError,AbiErrorInputsNotFoundError,AbiErrorNotFoundError,AbiErrorSignatureNotFoundError,AbiEventNotFoundError,AbiEventSignatureEmptyTopicsError,AbiEventSignatureNotFoundError,AbiFunctionNotFoundError,AbiFunctionOutputsNotFoundError,AbiFunctionSignatureNotFoundError,AccountStateConflictError,AtomicReadyWalletRejectedUpgradeError,AtomicityNotSupportedError,BaseError,BaseFeeScalarError,BlockNotFoundError,BundleTooLargeError,BytesSizeMismatchError,CallExecutionError,ChainDisconnectedError,ChainDoesNotSupportContract,ChainMismatchError,ChainNotFoundError,CircularReferenceError,ClientChainNotConfiguredError,ContractFunctionExecutionError,ContractFunctionRevertedError,ContractFunctionZeroDataError,CounterfactualDeploymentFailedError,DecodeLogDataMismatch,DecodeLogTopicsMismatch,DuplicateIdError,ProviderRpcError as EIP1193ProviderRpcError,Eip1559FeesNotSupportedError,EnsAvatarInvalidNftUriError,EnsAvatarUnsupportedNamespaceError,EnsAvatarUriResolutionError,EstimateGasExecutionError,ExecutionRevertedError,FeeCapTooHighError,FeeCapTooLowError,FeeConflictError,FilterTypeNotSupportedError,HttpRequestError,InsufficientFundsError,IntegerOutOfRangeError,InternalRpcError,IntrinsicGasTooHighError,IntrinsicGasTooLowError,InvalidAbiDecodingTypeError,InvalidAbiEncodingTypeError,InvalidAbiItemError,InvalidAbiParameterError,InvalidAbiParametersError,InvalidAbiTypeParameterError,InvalidAddressError,InvalidArrayError,InvalidBytesBooleanError,InvalidChainIdError,InvalidDecimalNumberError,InvalidDefinitionTypeError,InvalidDomainError,InvalidFunctionModifierError,InvalidHexBooleanError,InvalidHexValueError,InvalidInputRpcError,InvalidLegacyVError,InvalidModifierError,InvalidParameterError,InvalidParamsRpcError,InvalidParenthesisError,InvalidPrimaryTypeError,InvalidRequestRpcError,InvalidSerializableTransactionError,InvalidSerializedTransactionError,InvalidSerializedTransactionTypeError,InvalidSignatureError,InvalidStorageKeySizeError,InvalidStructSignatureError,InvalidStructTypeError,JsonRpcVersionUnsupportedError,LimitExceededRpcError,MaxFeePerGasTooLowError,MethodNotFoundRpcError,MethodNotSupportedRpcError,NonceMaxValueError,NonceTooHighError,NonceTooLowError,ParseRpcError,ProviderDisconnectedError,ProviderRpcError,RawContractError,ResourceNotFoundRpcError,ResourceUnavailableRpcError,RpcError,RpcRequestError,SizeExceedsPaddingSizeError,SizeOverflowError,SliceOffsetOutOfBoundsError,SocketClosedError,SolidityProtectedKeywordError,StateAssignmentConflictError,SwitchChainError,TimeoutError,TipAboveFeeCapError,TransactionExecutionError,TransactionNotFoundError,TransactionReceiptNotFoundError,TransactionRejectedRpcError,TransactionTypeNotSupportedError,UnauthorizedProviderError,UnknownBundleIdError,UnknownNodeError,UnknownRpcError,UnknownSignatureError,UnknownTypeError,UnsupportedChainIdError,UnsupportedNonOptionalCapabilityError,UnsupportedPackedAbiType,UnsupportedProviderMethodError,UrlRequiredError,UserRejectedRequestError,WaitForCallsStatusTimeoutError,WaitForTransactionReceiptTimeoutError,WebSocketRequestError,assertCurrentChain,assertRequest,assertTransactionEIP1559,assertTransactionEIP2930,assertTransactionLegacy,blobsToCommitments,blobsToProofs,boolToBytes,boolToHex,bytesToBigInt,bytesToBool,bytesToHex,bytesToNumber,bytesToRlp,bytesToString,ccipRequest as ccipFetch,ccipRequest,checksumAddress,commitmentToVersionedHash,commitmentsToVersionedHashes,serializeCompactSignature as compactSignatureToHex,compactSignatureToSignature,concat,concatBytes,concatHex,createClient,createNonceManager,createPublicClient,createTestClient,createTransport,createWalletClient,custom,decodeAbiParameters,decodeDeployData,decodeErrorResult,decodeEventLog,decodeFunctionData,decodeFunctionResult,defineBlock,defineChain,defineKzg,defineTransaction,defineTransactionReceipt,defineTransactionRequest,deploylessCallViaBytecodeBytecode,deploylessCallViaFactoryBytecode,domainSeparator,encodeAbiParameters,encodeDeployData,encodeErrorResult,encodeEventTopics,encodeFunctionData,encodeFunctionResult,encodePacked,erc1155Abi,erc20Abi,erc20Abi_bytes32,erc4626Abi,erc721Abi,ethAddress,etherUnits,extractChain,fallback,formatBlock,formatEther,formatGwei,formatLog,formatTransaction,formatTransactionReceipt,formatTransactionRequest,formatUnits,fromBlobs,fromBytes,fromHex,fromRlp,getAbiItem,getAddress,getChainContractAddress,getContract,getContractAddress,getContractError,getCreate2Address,getCreateAddress,toEventSelector as getEventSelector,toEventSignature as getEventSignature,toFunctionSelector as getFunctionSelector,toFunctionSignature as getFunctionSignature,getSerializedTransactionType,getTransactionType,getTypesForEIP712Domain,gweiUnits,hashDomain,hashMessage,hashStruct,hashTypedData,hexToBigInt,hexToBool,hexToBytes,parseCompactSignature as hexToCompactSignature,hexToNumber,hexToRlp,parseSignature as hexToSignature,hexToString,http,isAddress,isAddressEqual,isBytes,isErc6492Signature,isHash,isHex,keccak256,labelhash,maxInt104,maxInt112,maxInt120,maxInt128,maxInt136,maxInt144,maxInt152,maxInt16,maxInt160,maxInt168,maxInt176,maxInt184,maxInt192,maxInt200,maxInt208,maxInt216,maxInt224,maxInt232,maxInt24,maxInt240,maxInt248,maxInt256,maxInt32,maxInt40,maxInt48,maxInt56,maxInt64,maxInt72,maxInt8,maxInt80,maxInt88,maxInt96,maxUint104,maxUint112,maxUint120,maxUint128,maxUint136,maxUint144,maxUint152,maxUint16,maxUint160,maxUint168,maxUint176,maxUint184,maxUint192,maxUint200,maxUint208,maxUint216,maxUint224,maxUint232,maxUint24,maxUint240,maxUint248,maxUint256,maxUint32,maxUint40,maxUint48,maxUint56,maxUint64,maxUint72,maxUint8,maxUint80,maxUint88,maxUint96,minInt104,minInt112,minInt120,minInt128,minInt136,minInt144,minInt152,minInt16,minInt160,minInt168,minInt176,minInt184,minInt192,minInt200,minInt208,minInt216,minInt224,minInt232,minInt24,minInt240,minInt248,minInt256,minInt32,minInt40,minInt48,minInt56,minInt64,minInt72,minInt8,minInt80,minInt88,minInt96,multicall3Abi,namehash,nonceManager,numberToBytes,numberToHex,offchainLookup,offchainLookupAbiItem,offchainLookupSignature,pad,padBytes,padHex,parseAbi,parseAbiItem,parseAbiParameter,parseAbiParameters,parseCompactSignature,parseErc6492Signature,parseEther,parseEventLogs,parseGwei,parseSignature,parseTransaction,parseUnits,prepareEncodeFunctionData,presignMessagePrefix,publicActions,recoverAddress,recoverMessageAddress,recoverPublicKey,recoverTransactionAddress,recoverTypedDataAddress,ripemd160,rpcSchema,rpcTransactionType,serializeAccessList,serializeCompactSignature,serializeErc6492Signature,serializeSignature,serializeTransaction,serializeTypedData,setErrorConfig,setupKzg,sha256,shouldThrow,sidecarsToVersionedHashes,signatureToCompactSignature,serializeSignature as signatureToHex,size,slice,sliceBytes,sliceHex,stringToBytes,stringToHex,stringify,testActions,toBlobSidecars,toBlobs,toBytes,toEventHash,toEventSelector,toEventSignature,toFunctionHash,toFunctionSelector,toFunctionSignature,toHex,toPrefixedMessage,toRlp,transactionType,trim,universalSignatureValidatorAbi,universalSignatureValidatorByteCode,validateTypedData,verifyHash,verifyMessage,verifyTypedData,walletActions,webSocket,weiUnits,withCache,withRetry,withTimeout,zeroAddress,zeroHash}from"viem";import{utils as u,secp256k1 as d,Credential as l,Utxo as b,TypeSymbols as h,Address as p,avaxSerial as m,pvmSerial as y,PChainOwner as g,Int as w,TransferableOutput as x,Id as v,evm as P,pvm as I,Signature as T,UnsignedTx as E,L1Validator as A,avm as B}from"@avalabs/avalanchejs";import*as C from"node:crypto";function k(t){const{key:n="avalancheBase",name:r="Avalanche Base Client"}=t,a=e({...t,key:n,name:r,type:"avalancheClient"});return Object.assign(a,{extend:function e(t){return n=>{const r=n(t);for(const e in a)delete r[e];const s={...t,...r};return Object.assign(s,{extend:e(s)})}}(a)})}const $={"User-Agent":`${"@avalanche-sdk/client"} ${"0.1.0-alpha.2"}`,"Content-Type":"application/json"};function S(e,s,{apiKey:o,rlToken:i}={},f="public"){switch(e.type){case"http":return n(F(s,e.url,f,"http"),{...e.config,fetchOptions:{...e.config?.fetchOptions??{},...o?{headers:{"x-glacier-api-key":o,...$}}:i?{headers:{rlToken:i,...$}}:{}}});case"ws":return a(F(s,e.url,f,"webSocket"),e.config);case"custom":return"wallet"!==f?n(F(s,void 0,f,"http"),{...e.config,fetchOptions:{...o?{headers:{"x-glacier-api-key":o,...$}}:i?{headers:{rlToken:i,...$}}:{headers:$}}}):r(e.provider,e.config);case"ipc":throw new Error("IPC transport is not available in browser environments. Use HTTP or WebSocket transport instead.");case"fallback":return t(e.transports,e.config);default:throw new Error("Invalid transport type")}}function F(e,t,n="public",r="http"){if("Avalanche Fuji"!==e?.name&&"Avalanche"!==e?.name)return t??e?.rpcUrls.default[r]?.[0];if(!t&&!e?.rpcUrls?.default?.[r]?.[0])throw new Error("URL is required");t=t??e.rpcUrls.default[r]?.[0];const a=new URL(t).origin;switch(n){case"public":case"wallet":return t;case"pChain":return`${a}/ext/bc/P`;case"xChain":return`${a}/ext/bc/X`;case"cChain":return`${a}/ext/bc/C/avax`;case"admin":return`${a}/ext/admin`;case"info":return`${a}/ext/info`;case"health":return`${a}/ext/health`;case"indexPChainBlock":return`${a}/ext/index/P/block`;case"indexCChainBlock":return`${a}/ext/index/C/block`;case"indexXChainBlock":return`${a}/ext/index/X/block`;case"indexXChainTx":return`${a}/ext/index/X/tx`;case"proposervmCChain":return`${a}/ext/bc/C/proposervm`;case"proposervmPChain":return`${a}/ext/bc/P/proposervm`;case"proposervmXChain":return`${a}/ext/bc/X/proposervm`;default:throw new Error("Invalid client type"+n)}}function N(e){const{key:t="avalancheCore",name:n="Avalanche Core Client",transport:r,chain:a,apiKey:s,rlToken:o,clientType:i="public"}=e,f=S(r,a,{apiKey:s,rlToken:o},i);return k({...e,key:t,name:n,transport:f})}function O(e){return{alias:t=>async function(e,t){return e.request({method:"admin.alias",params:t})}(e,t),aliasChain:t=>async function(e,t){return e.request({method:"admin.aliasChain",params:t})}(e,t),getChainAliases:t=>async function(e,t){return e.request({method:"admin.getChainAliases",params:t})}(e,t),getLoggerLevel:t=>async function(e,t){return e.request({method:"admin.getLoggerLevel",params:t})}(e,t),loadVMs:()=>async function(e){return e.request({method:"admin.loadVMs",params:{}})}(e),lockProfile:()=>async function(e){return e.request({method:"admin.lockProfile",params:{}})}(e),memoryProfile:()=>async function(e){return e.request({method:"admin.memoryProfile",params:{}})}(e),setLoggerLevel:t=>async function(e,t){return e.request({method:"admin.setLoggerLevel",params:t})}(e,t),startCPUProfiler:()=>async function(e){return e.request({method:"admin.startCPUProfiler",params:{}})}(e),stopCPUProfiler:()=>async function(e){return e.request({method:"admin.stopCPUProfiler",params:{}})}(e)}}function z(e){const{key:t="admin",name:n="Admin API Client"}=e;return N({...e,key:t,name:n,clientType:"admin"}).extend(O)}async function R(e,t){return e.request({method:"avax.getAtomicTxStatus",params:t})}async function M(e,t){return e.request({method:"avax.getUTXOs",params:t})}async function U(e,t){return e.request({method:"avax.issueTx",params:t})}function q(e){return{getAtomicTx:t=>async function(e,t){return e.request({method:"avax.getAtomicTx",params:t})}(e,t),getAtomicTxStatus:t=>R(e,t),getUTXOs:t=>M(e,t),issueTx:t=>U(e,t)}}function L(e){const{key:t="cChain",name:n="C-Chain Client"}=e;return N({...e,key:t,name:n,clientType:"cChain"}).extend(q)}function j(e){return{health:t=>async function(e,t){return e.request({method:"health.health",params:t})}(e,t),liveness:()=>async function(e){return e.request({method:"health.liveness",params:{}})}(e),readiness:t=>async function(e,t){return e.request({method:"health.readiness",params:t})}(e,t)}}function D(e){const{key:t="health",name:n="Health API Client"}=e;return N({...e,key:t,name:n,clientType:"health"}).extend(j)}function H(e){return{getContainerByID:t=>async function(e,t){return e.request({method:"index.getContainerByID",params:t})}(e,t),getContainerByIndex:t=>async function(e,t){return e.request({method:"index.getContainerByIndex",params:t})}(e,t),getContainerRange:t=>async function(e,t){return e.request({method:"index.getContainerRange",params:t})}(e,t),getIndex:t=>async function(e,t){return e.request({method:"index.getIndex",params:t})}(e,t),getLastAccepted:t=>async function(e,t){return e.request({method:"index.getLastAccepted",params:t})}(e,t),isAccepted:t=>async function(e,t){return e.request({method:"index.isAccepted",params:t})}(e,t)}}function G(e){const{key:t="index",name:n="Index API Client",clientType:r}=e;return N({...e,key:t,name:n,clientType:r}).extend(H)}async function V(e,t){return e.request({method:"info.getBlockchainID",params:t})}async function _(e){return e.request({method:"info.getNetworkID",params:{}})}function X(e){return{acps:()=>async function(e){const t=await e.request({method:"info.acps",params:{}});return Object.keys(t.acps).reduce((e,n)=>{const r=parseInt(n);return e.acps.set(r,{supportWeight:BigInt(t.acps?.[r]?.supportWeight||0n),supporters:new Set(t.acps?.[r]?.supporters||[]),objectWeight:BigInt(t.acps?.[r]?.objectWeight||0n),objectors:new Set(t.acps?.[r]?.objectors||[]),abstainWeight:BigInt(t.acps?.[r]?.abstainWeight||0n)}),e},{acps:new Map})}(e),getBlockchainID:t=>V(e,t),getNetworkID:()=>_(e),getNetworkName:()=>async function(e){return e.request({method:"info.getNetworkName",params:{}})}(e),getNodeID:()=>async function(e){return e.request({method:"info.getNodeID",params:{}})}(e),getNodeIP:()=>async function(e){return e.request({method:"info.getNodeIP",params:{}})}(e),getNodeVersion:()=>async function(e){return e.request({method:"info.getNodeVersion",params:{}})}(e),getTxFee:()=>async function(e){const t=await e.request({method:"info.getTxFee",params:{}});return{txFee:BigInt(t.txFee),createAssetTxFee:BigInt(t.createAssetTxFee),createSubnetTxFee:BigInt(t.createSubnetTxFee),transformSubnetTxFee:BigInt(t.transformSubnetTxFee),createBlockchainTxFee:BigInt(t.createBlockchainTxFee),addPrimaryNetworkValidatorFee:BigInt(t.addPrimaryNetworkValidatorFee),addPrimaryNetworkDelegatorFee:BigInt(t.addPrimaryNetworkDelegatorFee),addSubnetValidatorFee:BigInt(t.addSubnetValidatorFee),addSubnetDelegatorFee:BigInt(t.addSubnetDelegatorFee)}}(e),getVMs:()=>async function(e){return e.request({method:"info.getVMs",params:{}})}(e),isBootstrapped:t=>async function(e,t){return e.request({method:"info.isBootstrapped",params:t})}(e,t),peers:t=>async function(e,t){return e.request({method:"info.peers",params:t})}(e,t),upgrades:()=>async function(e){return e.request({method:"info.upgrades",params:{}})}(e),uptime:()=>async function(e){return e.request({method:"info.uptime",params:{}})}(e)}}function W(e){const{key:t="info",name:n="Info API Client"}=e;return N({...e,key:t,name:n,clientType:"info"}).extend(X)}async function Z(e,t){const n=await e.request({method:"platform.getBalance",params:t});return{...n,balance:BigInt(n.balance),unlocked:BigInt(n.unlocked),lockedNotStakeable:BigInt(n.lockedNotStakeable),lockedStakeable:BigInt(n.lockedStakeable)}}async function K(e){const t=await e.request({method:"platform.getFeeConfig",params:{}});return{...t,maxCapacity:BigInt(t.maxCapacity),maxPerSecond:BigInt(t.maxPerSecond),minPrice:BigInt(t.minPrice),targetPerSecond:BigInt(t.targetPerSecond),excessConversionConstant:BigInt(t.excessConversionConstant)}}async function Y(e){const t=await e.request({method:"platform.getFeeState",params:{}});return{...t,capacity:BigInt(t.capacity),excess:BigInt(t.excess),price:BigInt(t.price)}}async function J(e,t){const n=await e.request({method:"platform.getL1Validator",params:t});return{...n,startTime:BigInt(n.startTime),weight:BigInt(n.weight),...n.minNonce&&{minNonce:BigInt(n.minNonce)},...n.balance&&{balance:BigInt(n.balance)},...n.height&&{height:BigInt(n.height)}}}async function Q(e,t){return e.request({method:"platform.getTx",params:t})}async function ee(e,t){return e.request({method:"platform.getTxStatus",params:t})}async function te(e,t){return e.request({method:"platform.getUTXOs",params:t})}async function ne(e,t){return e.request({method:"platform.issueTx",params:t})}function re(e){return{getBalance:t=>Z(e,t),getBlock:t=>async function(e,t){return e.request({method:"platform.getBlock",params:t})}(e,t),getBlockByHeight:t=>async function(e,t){return e.request({method:"platform.getBlockByHeight",params:t})}(e,t),getBlockchains:()=>async function(e){return e.request({method:"platform.getBlockchains",params:{}})}(e),getBlockchainStatus:t=>async function(e,t){return e.request({method:"platform.getBlockchainStatus",params:t})}(e,t),getCurrentValidators:t=>async function(e,t){return e.request({method:"platform.getCurrentValidators",params:t})}(e,t),getCurrentSupply:t=>async function(e,t){const n=await e.request({method:"platform.getCurrentSupply",params:t});return{supply:BigInt(n.supply)}}(e,t),getFeeConfig:()=>K(e),getFeeState:()=>Y(e),getHeight:()=>async function(e){return e.request({method:"platform.getHeight",params:{}})}(e),getL1Validator:t=>J(e,t),getProposedHeight:()=>async function(e){return e.request({method:"platform.getProposedHeight",params:{}})}(e),getMinStake:t=>async function(e,t){const n=await e.request({method:"platform.getMinStake",params:t});return{minDelegatorStake:BigInt(n.minDelegatorStake),minValidatorStake:BigInt(n.minValidatorStake)}}(e,t),getRewardUTXOs:t=>async function(e,t){return e.request({method:"platform.getRewardUTXOs",params:t})}(e,t),getStake:t=>async function(e,t){return e.request({method:"platform.getStake",params:t})}(e,t),getStakingAssetID:t=>async function(e,t){return e.request({method:"platform.getStakingAssetID",params:t})}(e,t),getSubnet:t=>async function(e,t){return e.request({method:"platform.getSubnet",params:t})}(e,t),getSubnets:t=>async function(e,t){return e.request({method:"platform.getSubnets",params:t})}(e,t),getTimestamp:()=>async function(e){return e.request({method:"platform.getTimestamp",params:{}})}(e),getTotalStake:t=>async function(e,t){return e.request({method:"platform.getTotalStake",params:t})}(e,t),getTx:t=>Q(e,t),getTxStatus:t=>ee(e,t),getUTXOs:t=>te(e,t),getAllValidatorsAt:t=>async function(e,t){return e.request({method:"platform.getAllValidatorsAt",params:t})}(e,t),getValidatorsAt:t=>async function(e,t){return e.request({method:"platform.getValidatorsAt",params:t})}(e,t),issueTx:t=>ne(e,t),sampleValidators:t=>async function(e,t){return e.request({method:"platform.sampleValidators",params:t})}(e,t),validates:t=>async function(e,t){return e.request({method:"platform.validates",params:t})}(e,t),validatedBy:t=>async function(e,t){return e.request({method:"platform.validatedBy",params:t})}(e,t)}}function ae(e){const{key:t="pChain",name:n="P-Chain Client"}=e;return N({...e,key:t,name:n,clientType:"pChain"}).extend(re)}function se(e){return{getProposedHeight:()=>async function(e){return e.request({method:"proposervm.getProposedHeight",params:{}})}(e),getCurrentEpoch:()=>async function(e){return e.request({method:"proposervm.getCurrentEpoch",params:{}})}(e)}}function oe(e){const{key:t="proposervm",name:n="proposervm API Client",clientType:r}=e;return N({...e,key:t,name:n,clientType:r}).extend(se)}async function ie(e,t){return e.request({method:"avm.getAssetDescription",params:t})}async function fe(e){return e.request({method:"avm.getTxFee",params:{}})}async function ce(e,t){return e.request({method:"avm.getTxStatus",params:t})}async function ue(e,t){return e.request({method:"avm.getUTXOs",params:t})}async function de(e,t){return e.request({method:"avm.issueTx",params:t})}function le(e){return{buildGenesis:t=>async function(e,t){return e.request({method:"avm.buildGenesis",params:t})}(e,t),getAllBalances:t=>async function(e,t){return{balances:(await e.request({method:"avm.getAllBalances",params:t})).balances.map(e=>({...e,balance:BigInt(e.balance)}))}}(e,t),getAssetDescription:t=>ie(e,t),getBalance:t=>async function(e,t){const n=await e.request({method:"avm.getBalance",params:t});return{...n,balance:BigInt(n.balance)}}(e,t),getBlock:t=>async function(e,t){return e.request({method:"avm.getBlock",params:t})}(e,t),getBlockByHeight:t=>async function(e,t){return e.request({method:"avm.getBlockByHeight",params:t})}(e,t),getHeight:()=>async function(e){return e.request({method:"avm.getHeight",params:{}})}(e),getTx:t=>async function(e,t){return e.request({method:"avm.getTx",params:t})}(e,t),getTxFee:()=>fe(e),getTxStatus:t=>ce(e,t),getUTXOs:t=>ue(e,t),issueTx:t=>de(e,t)}}function be(e){const{key:t="xChain",name:n="X-Chain Client"}=e;return N({...e,key:t,name:n,clientType:"xChain"}).extend(le)}async function he(e){return e.request({method:"eth_baseFee",params:[]})}function pe(e){return{baseFee:()=>he(e),getChainConfig:()=>async function(e){return e.request({method:"eth_getChainConfig",params:[]})}(e),maxPriorityFeePerGas:()=>async function(e){return e.request({method:"eth_maxPriorityFeePerGas",params:[]})}(e),feeConfig:t=>async function(e,{blk:t}){return e.request({method:"eth_feeConfig",params:[t??"latest"]})}(e,t),getActiveRulesAt:t=>async function(e,{timestamp:t}){return e.request({method:"eth_getActiveRulesAt",params:[t??"latest"]})}(e,t)}}function me(e){const{key:t="avalanche",name:n="Avalanche Client",transport:r,chain:a,apiKey:i="",rlToken:f=""}=e,c=S(r,a,{apiKey:i,rlToken:f}),u=s({...e,key:t,name:n,transport:c,rpcSchema:o()}).extend(pe);return"Avalanche"!==a?.name&&"Avalanche Fuji"!==a?.name?{...u}:{...u,pChain:ae({...e,key:"pChain",name:"P-Chain Client"}),cChain:L({...e,key:"cChain",name:"C-Chain Client"}),xChain:be({...e,key:"xChain",name:"X-Chain Client"}),admin:z({...e,key:"admin",name:"Admin Client"}),info:W({...e,key:"info",name:"Info Client"}),health:D({...e,key:"health",name:"Health Client"}),proposervm:{cChain:oe({...e,key:"proposervm",name:"proposervm Client",clientType:"proposervmCChain"}),pChain:oe({...e,key:"proposervm",name:"proposervm Client",clientType:"proposervmPChain"}),xChain:oe({...e,key:"proposervm",name:"proposervm Client",clientType:"proposervmXChain"})},indexBlock:{pChain:G({...e,key:"indexPChainBlock",name:"Index P-Chain Block Client",clientType:"indexPChainBlock"}),cChain:G({...e,key:"indexCChainBlock",name:"Index C-Chain Block Client",clientType:"indexCChainBlock"}),xChain:G({...e,key:"indexXChainBlock",name:"Index X-Chain Block Client",clientType:"indexXChainBlock"})},indexTx:{xChain:G({...e,key:"indexXChainTx",name:"Index X-Chain Tx Client",clientType:"indexXChainTx"})}}}let ye=class e extends Error{constructor(t,n={}){const r=n.cause instanceof e?n.cause.details:n.cause?.message?n.cause.message:n.details,a=n.cause instanceof e&&n.cause.docsPath||n.docsPath;super([t||"An error occurred.","",...n.metaMessages?[...n.metaMessages,""]:[],...a?[`Docs: https://abitype.dev${a}`]:[],...r?[`Details: ${r}`]:[],"Version: abitype@1.1.0"].join("\n")),Object.defineProperty(this,"details",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"docsPath",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"metaMessages",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"shortMessage",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"AbiTypeError"}),n.cause&&(this.cause=n.cause),this.details=r,this.docsPath=a,this.metaMessages=n.metaMessages,this.shortMessage=t}};function ge(e,t){const n=e.exec(t);return n?.groups}const we=/^bytes([1-9]|1[0-9]|2[0-9]|3[0-2])?$/,xe=/^u?int(8|16|24|32|40|48|56|64|72|80|88|96|104|112|120|128|136|144|152|160|168|176|184|192|200|208|216|224|232|240|248|256)?$/,ve=/^\(.+?\).*?$/,Pe=/^tuple(?<array>(\[(\d*)\])*)$/;function Ie(e){let t=e.type;if(Pe.test(e.type)&&"components"in e){t="(";const n=e.components.length;for(let r=0;r<n;r++){t+=Ie(e.components[r]),r<n-1&&(t+=", ")}const r=ge(Pe,e.type);return t+=`)${r?.array??""}`,Ie({...e,type:t})}return"indexed"in e&&e.indexed&&(t=`${t} indexed`),e.name?`${t} ${e.name}`:t}function Te(e){let t="";const n=e.length;for(let r=0;r<n;r++){t+=Ie(e[r]),r!==n-1&&(t+=", ")}return t}const Ee=/^error (?<name>[a-zA-Z$_][a-zA-Z0-9$_]*)\((?<parameters>.*?)\)$/;const Ae=/^event (?<name>[a-zA-Z$_][a-zA-Z0-9$_]*)\((?<parameters>.*?)\)$/;const Be=/^function (?<name>[a-zA-Z$_][a-zA-Z0-9$_]*)\((?<parameters>.*?)\)(?: (?<scope>external|public{1}))?(?: (?<stateMutability>pure|view|nonpayable|payable{1}))?(?: returns\s?\((?<returns>.*?)\))?$/;const Ce=/^struct (?<name>[a-zA-Z$_][a-zA-Z0-9$_]*) \{(?<properties>.*?)\}$/;function ke(e){return Ce.test(e)}function $e(e){return ge(Ce,e)}const Se=/^constructor\((?<parameters>.*?)\)(?:\s(?<stateMutability>payable{1}))?$/;const Fe=/^fallback\(\) external(?:\s(?<stateMutability>payable{1}))?$/;const Ne=/^receive\(\) external payable$/;const Oe=new Set(["indexed"]),ze=new Set(["calldata","memory","storage"]);class Re extends ye{constructor({type:e}){super("Unknown type.",{metaMessages:[`Type "${e}" is not a valid ABI type. Perhaps you forgot to include a struct signature?`]}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"UnknownTypeError"})}}class Me extends ye{constructor({type:e}){super("Unknown type.",{metaMessages:[`Type "${e}" is not a valid ABI type.`]}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"UnknownSolidityTypeError"})}}class Ue extends ye{constructor({param:e}){super("Invalid ABI parameter.",{details:e}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"InvalidParameterError"})}}class qe extends ye{constructor({param:e,name:t}){super("Invalid ABI parameter.",{details:e,metaMessages:[`"${t}" is a protected Solidity keyword. More info: https://docs.soliditylang.org/en/latest/cheatsheet.html`]}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"SolidityProtectedKeywordError"})}}class Le extends ye{constructor({param:e,type:t,modifier:n}){super("Invalid ABI parameter.",{details:e,metaMessages:[`Modifier "${n}" not allowed${t?` in "${t}" type`:""}.`]}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"InvalidModifierError"})}}class je extends ye{constructor({param:e,type:t,modifier:n}){super("Invalid ABI parameter.",{details:e,metaMessages:[`Modifier "${n}" not allowed${t?` in "${t}" type`:""}.`,`Data location can only be specified for array, struct, or mapping types, but "${n}" was given.`]}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"InvalidFunctionModifierError"})}}class De extends ye{constructor({abiParameter:e}){super("Invalid ABI parameter.",{details:JSON.stringify(e,null,2),metaMessages:["ABI parameter type is invalid."]}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"InvalidAbiTypeParameterError"})}}class He extends ye{constructor({signature:e,type:t}){super(`Invalid ${t} signature.`,{details:e}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"InvalidSignatureError"})}}class Ge extends ye{constructor({signature:e}){super("Unknown signature.",{details:e}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"UnknownSignatureError"})}}class Ve extends ye{constructor({signature:e}){super("Invalid struct signature.",{details:e,metaMessages:["No properties exist."]}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"InvalidStructSignatureError"})}}class _e extends ye{constructor({type:e}){super("Circular reference detected.",{metaMessages:[`Struct "${e}" is a circular reference.`]}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"CircularReferenceError"})}}class Xe extends ye{constructor({current:e,depth:t}){super("Unbalanced parentheses.",{metaMessages:[`"${e.trim()}" has too many ${t>0?"opening":"closing"} parentheses.`],details:`Depth "${t}"`}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"InvalidParenthesisError"})}}const We=new Map([["address",{type:"address"}],["bool",{type:"bool"}],["bytes",{type:"bytes"}],["bytes32",{type:"bytes32"}],["int",{type:"int256"}],["int256",{type:"int256"}],["string",{type:"string"}],["uint",{type:"uint256"}],["uint8",{type:"uint8"}],["uint16",{type:"uint16"}],["uint24",{type:"uint24"}],["uint32",{type:"uint32"}],["uint64",{type:"uint64"}],["uint96",{type:"uint96"}],["uint112",{type:"uint112"}],["uint160",{type:"uint160"}],["uint192",{type:"uint192"}],["uint256",{type:"uint256"}],["address owner",{type:"address",name:"owner"}],["address to",{type:"address",name:"to"}],["bool approved",{type:"bool",name:"approved"}],["bytes _data",{type:"bytes",name:"_data"}],["bytes data",{type:"bytes",name:"data"}],["bytes signature",{type:"bytes",name:"signature"}],["bytes32 hash",{type:"bytes32",name:"hash"}],["bytes32 r",{type:"bytes32",name:"r"}],["bytes32 root",{type:"bytes32",name:"root"}],["bytes32 s",{type:"bytes32",name:"s"}],["string name",{type:"string",name:"name"}],["string symbol",{type:"string",name:"symbol"}],["string tokenURI",{type:"string",name:"tokenURI"}],["uint tokenId",{type:"uint256",name:"tokenId"}],["uint8 v",{type:"uint8",name:"v"}],["uint256 balance",{type:"uint256",name:"balance"}],["uint256 tokenId",{type:"uint256",name:"tokenId"}],["uint256 value",{type:"uint256",name:"value"}],["event:address indexed from",{type:"address",name:"from",indexed:!0}],["event:address indexed to",{type:"address",name:"to",indexed:!0}],["event:uint indexed tokenId",{type:"uint256",name:"tokenId",indexed:!0}],["event:uint256 indexed tokenId",{type:"uint256",name:"tokenId",indexed:!0}]]);function Ze(e,t={}){if(function(e){return Be.test(e)}(e))return function(e,t={}){const n=function(e){return ge(Be,e)}(e);if(!n)throw new He({signature:e,type:"function"});const r=et(n.parameters),a=[],s=r.length;for(let e=0;e<s;e++)a.push(Qe(r[e],{modifiers:ze,structs:t,type:"function"}));const o=[];if(n.returns){const e=et(n.returns),r=e.length;for(let n=0;n<r;n++)o.push(Qe(e[n],{modifiers:ze,structs:t,type:"function"}))}return{name:n.name,type:"function",stateMutability:n.stateMutability??"nonpayable",inputs:a,outputs:o}}(e,t);if(function(e){return Ae.test(e)}(e))return function(e,t={}){const n=function(e){return ge(Ae,e)}(e);if(!n)throw new He({signature:e,type:"event"});const r=et(n.parameters),a=[],s=r.length;for(let e=0;e<s;e++)a.push(Qe(r[e],{modifiers:Oe,structs:t,type:"event"}));return{name:n.name,type:"event",inputs:a}}(e,t);if(function(e){return Ee.test(e)}(e))return function(e,t={}){const n=function(e){return ge(Ee,e)}(e);if(!n)throw new He({signature:e,type:"error"});const r=et(n.parameters),a=[],s=r.length;for(let e=0;e<s;e++)a.push(Qe(r[e],{structs:t,type:"error"}));return{name:n.name,type:"error",inputs:a}}(e,t);if(function(e){return Se.test(e)}(e))return function(e,t={}){const n=function(e){return ge(Se,e)}(e);if(!n)throw new He({signature:e,type:"constructor"});const r=et(n.parameters),a=[],s=r.length;for(let e=0;e<s;e++)a.push(Qe(r[e],{structs:t,type:"constructor"}));return{type:"constructor",stateMutability:n.stateMutability??"nonpayable",inputs:a}}(e,t);if(function(e){return Fe.test(e)}(e))return function(e){const t=function(e){return ge(Fe,e)}(e);if(!t)throw new He({signature:e,type:"fallback"});return{type:"fallback",stateMutability:t.stateMutability??"nonpayable"}}(e);if(function(e){return Ne.test(e)}(e))return{type:"receive",stateMutability:"payable"};throw new Ge({signature:e})}const Ke=/^(?<type>[a-zA-Z$_][a-zA-Z0-9$_]*(?:\spayable)?)(?<array>(?:\[\d*?\])+?)?(?:\s(?<modifier>calldata|indexed|memory|storage{1}))?(?:\s(?<name>[a-zA-Z$_][a-zA-Z0-9$_]*))?$/,Ye=/^\((?<type>.+?)\)(?<array>(?:\[\d*?\])+?)?(?:\s(?<modifier>calldata|indexed|memory|storage{1}))?(?:\s(?<name>[a-zA-Z$_][a-zA-Z0-9$_]*))?$/,Je=/^u?int$/;function Qe(e,t){const n=function(e,t,n){let r="";if(n)for(const e of Object.entries(n)){if(!e)continue;let t="";for(const n of e[1])t+=`[${n.type}${n.name?`:${n.name}`:""}]`;r+=`(${e[0]}{${t}})`}return t?`${t}:${e}${r}`:e}(e,t?.type,t?.structs);if(We.has(n))return We.get(n);const r=ve.test(e),a=ge(r?Ye:Ke,e);if(!a)throw new Ue({param:e});if(a.name&&function(e){return"address"===e||"bool"===e||"function"===e||"string"===e||"tuple"===e||we.test(e)||xe.test(e)||nt.test(e)}(a.name))throw new qe({param:e,name:a.name});const s=a.name?{name:a.name}:{},o="indexed"===a.modifier?{indexed:!0}:{},i=t?.structs??{};let f,c={};if(r){f="tuple";const e=et(a.type),t=[],n=e.length;for(let r=0;r<n;r++)t.push(Qe(e[r],{structs:i}));c={components:t}}else if(a.type in i)f="tuple",c={components:i[a.type]};else if(Je.test(a.type))f=`${a.type}256`;else if("address payable"===a.type)f="address";else if(f=a.type,"struct"!==t?.type&&!tt(f))throw new Me({type:f});if(a.modifier){if(!t?.modifiers?.has?.(a.modifier))throw new Le({param:e,type:t?.type,modifier:a.modifier});if(ze.has(a.modifier)&&!function(e,t){return t||"bytes"===e||"string"===e||"tuple"===e}(f,!!a.array))throw new je({param:e,type:t?.type,modifier:a.modifier})}const u={type:`${f}${a.array??""}`,...s,...o,...c};return We.set(n,u),u}function et(e,t=[],n="",r=0){const a=e.trim().length;for(let s=0;s<a;s++){const a=e[s],o=e.slice(s+1);switch(a){case",":return 0===r?et(o,[...t,n.trim()]):et(o,t,`${n}${a}`,r);case"(":return et(o,t,`${n}${a}`,r+1);case")":return et(o,t,`${n}${a}`,r-1);default:return et(o,t,`${n}${a}`,r)}}if(""===n)return t;if(0!==r)throw new Xe({current:n,depth:r});return t.push(n.trim()),t}function tt(e){return"address"===e||"bool"===e||"function"===e||"string"===e||we.test(e)||xe.test(e)}const nt=/^(?:after|alias|anonymous|apply|auto|byte|calldata|case|catch|constant|copyof|default|defined|error|event|external|false|final|function|immutable|implements|in|indexed|inline|internal|let|mapping|match|memory|mutable|null|of|override|partial|private|promise|public|pure|reference|relocatable|return|returns|sizeof|static|storage|struct|super|supports|switch|this|true|try|typedef|typeof|var|view|virtual)$/;const rt=/^(?<type>[a-zA-Z$_][a-zA-Z0-9$_]*)(?<array>(?:\[\d*?\])+?)?$/;function at(e,t,n=new Set){const r=[],a=e.length;for(let s=0;s<a;s++){const a=e[s];if(ve.test(a.type))r.push(a);else{const e=ge(rt,a.type);if(!e?.type)throw new De({abiParameter:a});const{array:s,type:o}=e;if(o in t){if(n.has(o))throw new _e({type:o});r.push({...a,type:`tuple${s??""}`,components:at(t[o]??[],t,new Set([...n,o]))})}else{if(!tt(o))throw new Re({type:o});r.push(a)}}}return r}function st(e){const t=function(e){const t={},n=e.length;for(let r=0;r<n;r++){const n=e[r];if(!ke(n))continue;const a=$e(n);if(!a)throw new He({signature:n,type:"struct"});const s=a.properties.split(";"),o=[],i=s.length;for(let e=0;e<i;e++){const t=s[e].trim();if(!t)continue;const n=Qe(t,{type:"struct"});o.push(n)}if(!o.length)throw new Ve({signature:n});t[a.name]=o}const r={},a=Object.entries(t),s=a.length;for(let e=0;e<s;e++){const[n,s]=a[e];r[n]=at(s,t)}return r}(e),n=[],r=e.length;for(let a=0;a<r;a++){const r=e[a];ke(r)||n.push(Ze(r,t))}return n}function ot(e){return"string"==typeof e?{address:e,type:"json-rpc"}:e}const it="2.38.6";let ft=({docsBaseUrl:e,docsPath:t="",docsSlug:n})=>t?`${e??"https://viem.sh"}${t}${n?`#${n}`:""}`:void 0,ct=`viem@${it}`,ut=class e extends Error{constructor(t,n={}){const r=n.cause instanceof e?n.cause.details:n.cause?.message?n.cause.message:n.details,a=n.cause instanceof e&&n.cause.docsPath||n.docsPath,s=ft?.({...n,docsPath:a});super([t||"An error occurred.","",...n.metaMessages?[...n.metaMessages,""]:[],...s?[`Docs: ${s}`]:[],...r?[`Details: ${r}`]:[],...ct?[`Version: ${ct}`]:[]].join("\n"),n.cause?{cause:n.cause}:void 0),Object.defineProperty(this,"details",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"docsPath",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"metaMessages",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"shortMessage",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"version",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"BaseError"}),this.details=r,this.docsPath=a,this.metaMessages=n.metaMessages,this.name=n.name??this.name,this.shortMessage=t,this.version=it}walk(e){return dt(this,e)}};function dt(e,t){return t?.(e)?e:e&&"object"==typeof e&&"cause"in e&&void 0!==e.cause?dt(e.cause,t):t?null:e}class lt extends ut{constructor({address:e}){super(`Address "${e}" is invalid.`,{metaMessages:["- Address must be a hex value of 20 bytes (40 hex characters).","- Address must match its checksum counterpart."],name:"InvalidAddressError"})}}function bt(e,{strict:t=!0}={}){return!!e&&("string"==typeof e&&(t?/^0x[0-9a-fA-F]*$/.test(e):e.startsWith("0x")))}class ht extends ut{constructor({offset:e,position:t,size:n}){super(`Slice ${"start"===t?"starting":"ending"} at offset "${e}" is out-of-bounds (size: ${n}).`,{name:"SliceOffsetOutOfBoundsError"})}}let pt=class extends ut{constructor({size:e,targetSize:t,type:n}){super(`${n.charAt(0).toUpperCase()}${n.slice(1).toLowerCase()} size (${e}) exceeds padding size (${t}).`,{name:"SizeExceedsPaddingSizeError"})}};class mt extends ut{constructor({size:e,targetSize:t,type:n}){super(`${n.charAt(0).toUpperCase()}${n.slice(1).toLowerCase()} is expected to be ${t} ${n} long, but is ${e} ${n} long.`,{name:"InvalidBytesLengthError"})}}function yt(e,{dir:t,size:n=32}={}){return"string"==typeof e?gt(e,{dir:t,size:n}):function(e,{dir:t,size:n=32}={}){if(null===n)return e;if(e.length>n)throw new pt({size:e.length,targetSize:n,type:"bytes"});const r=new Uint8Array(n);for(let a=0;a<n;a++){const s="right"===t;r[s?a:n-a-1]=e[s?a:e.length-a-1]}return r}(e,{dir:t,size:n})}function gt(e,{dir:t,size:n=32}={}){if(null===n)return e;const r=e.replace("0x","");if(r.length>2*n)throw new pt({size:Math.ceil(r.length/2),targetSize:n,type:"hex"});return`0x${r["right"===t?"padEnd":"padStart"](2*n,"0")}`}let wt=class extends ut{constructor({max:e,min:t,signed:n,size:r,value:a}){super(`Number "${a}" is not in safe ${r?`${8*r}-bit ${n?"signed":"unsigned"} `:""}integer range ${e?`(${t} to ${e})`:`(above ${t})`}`,{name:"IntegerOutOfRangeError"})}};class xt extends ut{constructor(e){super(`Bytes value "${e}" is not a valid boolean. The bytes array must contain a single byte of either a 0 or 1 value.`,{name:"InvalidBytesBooleanError"})}}class vt extends ut{constructor({givenSize:e,maxSize:t}){super(`Size cannot exceed ${t} bytes. Given size: ${e} bytes.`,{name:"SizeOverflowError"})}}function Pt(e){return bt(e,{strict:!1})?Math.ceil((e.length-2)/2):e.length}function It(e,{dir:t="left"}={}){let n="string"==typeof e?e.replace("0x",""):e,r=0;for(let e=0;e<n.length-1&&"0"===n["left"===t?e:n.length-e-1].toString();e++)r++;return n="left"===t?n.slice(r):n.slice(0,n.length-r),"string"==typeof e?(1===n.length&&"right"===t&&(n=`${n}0`),`0x${n.length%2==1?`0${n}`:n}`):n}function Tt(e,{size:t}){if(Pt(e)>t)throw new vt({givenSize:Pt(e),maxSize:t})}function Et(e,t={}){const{signed:n}=t;t.size&&Tt(e,{size:t.size});const r=BigInt(e);if(!n)return r;const a=(e.length-2)/2;return r<=(1n<<8n*BigInt(a)-1n)-1n?r:r-BigInt(`0x${"f".padStart(2*a,"f")}`)-1n}function At(e,t={}){return Number(Et(e,t))}const Bt=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,"0"));function Ct(e,t={}){return"number"==typeof e||"bigint"==typeof e?St(e,t):"string"==typeof e?Nt(e,t):"boolean"==typeof e?kt(e,t):$t(e,t)}function kt(e,t={}){const n=`0x${Number(e)}`;return"number"==typeof t.size?(Tt(n,{size:t.size}),yt(n,{size:t.size})):n}function $t(e,t={}){let n="";for(let t=0;t<e.length;t++)n+=Bt[e[t]];const r=`0x${n}`;return"number"==typeof t.size?(Tt(r,{size:t.size}),yt(r,{dir:"right",size:t.size})):r}function St(e,t={}){const{signed:n,size:r}=t,a=BigInt(e);let s;r?s=n?(1n<<8n*BigInt(r)-1n)-1n:2n**(8n*BigInt(r))-1n:"number"==typeof e&&(s=BigInt(Number.MAX_SAFE_INTEGER));const o="bigint"==typeof s&&n?-s-1n:0;if(s&&a>s||a<o){const t="bigint"==typeof e?"n":"";throw new wt({max:s?`${s}${t}`:void 0,min:`${o}${t}`,signed:n,size:r,value:`${e}${t}`})}const i=`0x${(n&&a<0?(1n<<BigInt(8*r))+BigInt(a):a).toString(16)}`;return r?yt(i,{size:r}):i}const Ft=new TextEncoder;function Nt(e,t={}){return $t(Ft.encode(e),t)}const Ot=new TextEncoder;function zt(e,t={}){return"number"==typeof e||"bigint"==typeof e?function(e,t){const n=St(e,t);return Ut(n)}(e,t):"boolean"==typeof e?function(e,t={}){const n=new Uint8Array(1);if(n[0]=Number(e),"number"==typeof t.size)return Tt(n,{size:t.size}),yt(n,{size:t.size});return n}(e,t):bt(e)?Ut(e,t):qt(e,t)}const Rt={zero:48,nine:57,A:65,F:70,a:97,f:102};function Mt(e){return e>=Rt.zero&&e<=Rt.nine?e-Rt.zero:e>=Rt.A&&e<=Rt.F?e-(Rt.A-10):e>=Rt.a&&e<=Rt.f?e-(Rt.a-10):void 0}function Ut(e,t={}){let n=e;t.size&&(Tt(n,{size:t.size}),n=yt(n,{dir:"right",size:t.size}));let r=n.slice(2);r.length%2&&(r=`0${r}`);const a=r.length/2,s=new Uint8Array(a);for(let e=0,t=0;e<a;e++){const n=Mt(r.charCodeAt(t++)),a=Mt(r.charCodeAt(t++));if(void 0===n||void 0===a)throw new ut(`Invalid byte sequence ("${r[t-2]}${r[t-1]}" in "${r}").`);s[e]=16*n+a}return s}function qt(e,t={}){const n=Ot.encode(e);return"number"==typeof t.size?(Tt(n,{size:t.size}),yt(n,{dir:"right",size:t.size})):n}const Lt=BigInt(2**32-1),jt=BigInt(32);function Dt(e,t=!1){return t?{h:Number(e&Lt),l:Number(e>>jt&Lt)}:{h:0|Number(e>>jt&Lt),l:0|Number(e&Lt)}}const Ht=C&&"object"==typeof C&&"webcrypto"in C?C.webcrypto:C&&"object"==typeof C&&"randomBytes"in C?C:void 0;function Gt(e){if(!Number.isSafeInteger(e)||e<0)throw new Error("positive integer expected, got "+e)}function Vt(e,...t){if(!((n=e)instanceof Uint8Array||ArrayBuffer.isView(n)&&"Uint8Array"===n.constructor.name))throw new Error("Uint8Array expected");
/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */
var n;if(t.length>0&&!t.includes(e.length))throw new Error("Uint8Array expected of length "+t+", got length="+e.length)}function _t(e,t=!0){if(e.destroyed)throw new Error("Hash instance has been destroyed");if(t&&e.finished)throw new Error("Hash#digest() has already been called")}function Xt(e,t){Vt(e);const n=t.outputLen;if(e.length<n)throw new Error("digestInto() expects output buffer of length at least "+n)}function Wt(...e){for(let t=0;t<e.length;t++)e[t].fill(0)}function Zt(e){return new DataView(e.buffer,e.byteOffset,e.byteLength)}function Kt(e,t){return e<<32-t|e>>>t}function Yt(e){return e<<24&4278190080|e<<8&16711680|e>>>8&65280|e>>>24&255}const Jt=(()=>68===new Uint8Array(new Uint32Array([287454020]).buffer)[0])()?e=>e:function(e){for(let t=0;t<e.length;t++)e[t]=Yt(e[t]);return e};function Qt(e){return"string"==typeof e&&(e=function(e){if("string"!=typeof e)throw new Error("string expected");return new Uint8Array((new TextEncoder).encode(e))}(e)),Vt(e),e}class en{}function tn(e){const t=t=>e().update(Qt(t)).digest(),n=e();return t.outputLen=n.outputLen,t.blockLen=n.blockLen,t.create=()=>e(),t}function nn(e=32){if(Ht&&"function"==typeof Ht.getRandomValues)return Ht.getRandomValues(new Uint8Array(e));if(Ht&&"function"==typeof Ht.randomBytes)return Uint8Array.from(Ht.randomBytes(e));throw new Error("crypto.getRandomValues must be defined")}const rn=BigInt(0),an=BigInt(1),sn=BigInt(2),on=BigInt(7),fn=BigInt(256),cn=BigInt(113),un=[],dn=[],ln=[];for(let e=0,t=an,n=1,r=0;e<24;e++){[n,r]=[r,(2*n+3*r)%5],un.push(2*(5*r+n)),dn.push((e+1)*(e+2)/2%64);let a=rn;for(let e=0;e<7;e++)t=(t<<an^(t>>on)*cn)%fn,t&sn&&(a^=an<<(an<<BigInt(e))-an);ln.push(a)}const bn=function(e,t=!1){const n=e.length;let r=new Uint32Array(n),a=new Uint32Array(n);for(let s=0;s<n;s++){const{h:n,l:o}=Dt(e[s],t);[r[s],a[s]]=[n,o]}return[r,a]}(ln,!0),hn=bn[0],pn=bn[1],mn=(e,t,n)=>n>32?((e,t,n)=>t<<n-32|e>>>64-n)(e,t,n):((e,t,n)=>e<<n|t>>>32-n)(e,t,n),yn=(e,t,n)=>n>32?((e,t,n)=>e<<n-32|t>>>64-n)(e,t,n):((e,t,n)=>t<<n|e>>>32-n)(e,t,n);class gn extends en{constructor(e,t,n,r=!1,a=24){if(super(),this.pos=0,this.posOut=0,this.finished=!1,this.destroyed=!1,this.enableXOF=!1,this.blockLen=e,this.suffix=t,this.outputLen=n,this.enableXOF=r,this.rounds=a,Gt(n),!(0<e&&e<200))throw new Error("only keccak-f1600 function is supported");var s;this.state=new Uint8Array(200),this.state32=(s=this.state,new Uint32Array(s.buffer,s.byteOffset,Math.floor(s.byteLength/4)))}clone(){return this._cloneInto()}keccak(){Jt(this.state32),function(e,t=24){const n=new Uint32Array(10);for(let r=24-t;r<24;r++){for(let t=0;t<10;t++)n[t]=e[t]^e[t+10]^e[t+20]^e[t+30]^e[t+40];for(let t=0;t<10;t+=2){const r=(t+8)%10,a=(t+2)%10,s=n[a],o=n[a+1],i=mn(s,o,1)^n[r],f=yn(s,o,1)^n[r+1];for(let n=0;n<50;n+=10)e[t+n]^=i,e[t+n+1]^=f}let t=e[2],a=e[3];for(let n=0;n<24;n++){const r=dn[n],s=mn(t,a,r),o=yn(t,a,r),i=un[n];t=e[i],a=e[i+1],e[i]=s,e[i+1]=o}for(let t=0;t<50;t+=10){for(let r=0;r<10;r++)n[r]=e[t+r];for(let r=0;r<10;r++)e[t+r]^=~n[(r+2)%10]&n[(r+4)%10]}e[0]^=hn[r],e[1]^=pn[r]}Wt(n)}(this.state32,this.rounds),Jt(this.state32),this.posOut=0,this.pos=0}update(e){_t(this),Vt(e=Qt(e));const{blockLen:t,state:n}=this,r=e.length;for(let a=0;a<r;){const s=Math.min(t-this.pos,r-a);for(let t=0;t<s;t++)n[this.pos++]^=e[a++];this.pos===t&&this.keccak()}return this}finish(){if(this.finished)return;this.finished=!0;const{state:e,suffix:t,pos:n,blockLen:r}=this;e[n]^=t,128&t&&n===r-1&&this.keccak(),e[r-1]^=128,this.keccak()}writeInto(e){_t(this,!1),Vt(e),this.finish();const t=this.state,{blockLen:n}=this;for(let r=0,a=e.length;r<a;){this.posOut>=n&&this.keccak();const s=Math.min(n-this.posOut,a-r);e.set(t.subarray(this.posOut,this.posOut+s),r),this.posOut+=s,r+=s}return e}xofInto(e){if(!this.enableXOF)throw new Error("XOF is not possible for this instance");return this.writeInto(e)}xof(e){return Gt(e),this.xofInto(new Uint8Array(e))}digestInto(e){if(Xt(e,this),this.finished)throw new Error("digest() was already called");return this.writeInto(e),this.destroy(),e}digest(){return this.digestInto(new Uint8Array(this.outputLen))}destroy(){this.destroyed=!0,Wt(this.state)}_cloneInto(e){const{blockLen:t,suffix:n,outputLen:r,rounds:a,enableXOF:s}=this;return e||(e=new gn(t,n,r,s,a)),e.state32.set(this.state32),e.pos=this.pos,e.posOut=this.posOut,e.finished=this.finished,e.rounds=a,e.suffix=n,e.outputLen=r,e.enableXOF=s,e.destroyed=this.destroyed,e}}const wn=(()=>{return e=1,t=136,n=32,tn(()=>new gn(t,e,n));var e,t,n})();function xn(e,t){const n=t||"hex",r=wn(bt(e,{strict:!1})?zt(e):e);return"bytes"===n?r:Ct(r)}class vn extends Map{constructor(e){super(),Object.defineProperty(this,"maxSize",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.maxSize=e}get(e){const t=super.get(e);return super.has(e)&&void 0!==t&&(this.delete(e),super.set(e,t)),t}set(e,t){if(super.set(e,t),this.maxSize&&this.size>this.maxSize){const e=this.keys().next().value;e&&this.delete(e)}return this}}const Pn=/^0x[a-fA-F0-9]{40}$/,In=new vn(8192);function Tn(e,t){const{strict:n=!0}=t??{},r=`${e}.${n}`;if(In.has(r))return In.get(r);const a=!(!Pn.test(e)||e.toLowerCase()!==e&&n&&An(e)!==e);return In.set(r,a),a}const En=new vn(8192);function An(e,t){if(En.has(`${e}.${t}`))return En.get(`${e}.${t}`);const n=e.substring(2).toLowerCase(),r=xn(qt(n),"bytes"),a=n.split("");for(let e=0;e<40;e+=2)r[e>>1]>>4>=8&&a[e]&&(a[e]=a[e].toUpperCase()),(15&r[e>>1])>=8&&a[e+1]&&(a[e+1]=a[e+1].toUpperCase());const s=`0x${a.join("")}`;return En.set(`${e}.${t}`,s),s}function Bn(e,{includeName:t=!1}={}){if("function"!==e.type&&"event"!==e.type&&"error"!==e.type)throw new _n(e.type);return`${e.name}(${Cn(e.inputs,{includeName:t})})`}function Cn(e,{includeName:t=!1}={}){return e?e.map(e=>function(e,{includeName:t}){if(e.type.startsWith("tuple"))return`(${Cn(e.components,{includeName:t})})${e.type.slice(5)}`;return e.type+(t&&e.name?` ${e.name}`:"")}(e,{includeName:t})).join(t?", ":","):""}class kn extends ut{constructor({docsPath:e}){super(["A constructor was not found on the ABI.","Make sure you are using the correct ABI and that the constructor exists on it."].join("\n"),{docsPath:e,name:"AbiConstructorNotFoundError"})}}class $n extends ut{constructor({docsPath:e}){super(["Constructor arguments were provided (`args`), but a constructor parameters (`inputs`) were not found on the ABI.","Make sure you are using the correct ABI, and that the `inputs` attribute on the constructor exists."].join("\n"),{docsPath:e,name:"AbiConstructorParamsNotFoundError"})}}class Sn extends ut{constructor({data:e,params:t,size:n}){super([`Data size of ${n} bytes is too small for given parameters.`].join("\n"),{metaMessages:[`Params: (${Cn(t,{includeName:!0})})`,`Data: ${e} (${n} bytes)`],name:"AbiDecodingDataSizeTooSmallError"}),Object.defineProperty(this,"data",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"params",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"size",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.data=e,this.params=t,this.size=n}}class Fn extends ut{constructor(){super('Cannot decode zero data ("0x") with ABI parameters.',{name:"AbiDecodingZeroDataError"})}}class Nn extends ut{constructor({expectedLength:e,givenLength:t,type:n}){super([`ABI encoding array length mismatch for type ${n}.`,`Expected length: ${e}`,`Given length: ${t}`].join("\n"),{name:"AbiEncodingArrayLengthMismatchError"})}}class On extends ut{constructor({expectedSize:e,value:t}){super(`Size of bytes "${t}" (bytes${Pt(t)}) does not match expected size (bytes${e}).`,{name:"AbiEncodingBytesSizeMismatch