UNPKG

@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 226 kB
import{createClient as e,fallback as t,http as n,custom as r,webSocket as a,createPublicClient as s,rpcSchema as o,formatEther as i,parseEther as f,isAddress as c,walletActions as u}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 d,secp256k1 as l,Credential as b,Utxo as h,TypeSymbols as p,Address as m,avaxSerial as g,pvmSerial as y,PChainOwner as w,Int as x,TransferableOutput as v,Id as P,evm as I,pvm as T,Signature as E,UnsignedTx as A,L1Validator as B,avm as C}from"@avalabs/avalanchejs";import*as k from"node:crypto";function $(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 S={"User-Agent":`${"@avalanche-sdk/client"} ${"0.0.4-alpha.16"}`,"Content-Type":"application/json"};function F(e,s,{apiKey:o,rlToken:i}={},f="public"){switch(e.type){case"http":return n(N(s,e.url,f,"http"),{...e.config,fetchOptions:{...e.config?.fetchOptions??{},...o?{headers:{"x-glacier-api-key":o,...S}}:i?{headers:{rlToken:i,...S}}:{}}});case"ws":return a(N(s,e.url,f,"webSocket"),e.config);case"custom":return"wallet"!==f?n(N(s,void 0,f,"http"),{...e.config,fetchOptions:{...o?{headers:{"x-glacier-api-key":o,...S}}:i?{headers:{rlToken:i,...S}}:{headers:S}}}):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 N(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`;default:throw new Error("Invalid client type"+n)}}function O(e){const{key:t="avalancheCore",name:n="Avalanche Core Client",transport:r,chain:a,apiKey:s,rlToken:o,clientType:i="public"}=e,f=F(r,a,{apiKey:s,rlToken:o},i);return $({...e,key:t,name:n,transport:f})}function z(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 R(e){const{key:t="admin",name:n="Admin API Client"}=e;return O({...e,key:t,name:n,clientType:"admin"}).extend(z)}async function M(e,t){return e.request({method:"avax.getAtomicTxStatus",params:t})}async function U(e,t){return e.request({method:"avax.getUTXOs",params:t})}async function q(e,t){return e.request({method:"avax.issueTx",params:t})}function L(e){return{getAtomicTx:t=>async function(e,t){return e.request({method:"avax.getAtomicTx",params:t})}(e,t),getAtomicTxStatus:t=>M(e,t),getUTXOs:t=>U(e,t),issueTx:t=>q(e,t)}}function j(e){const{key:t="cChain",name:n="C-Chain Client"}=e;return O({...e,key:t,name:n,clientType:"cChain"}).extend(L)}function D(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 G(e){const{key:t="health",name:n="Health API Client"}=e;return O({...e,key:t,name:n,clientType:"health"}).extend(D)}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 V(e){const{key:t="index",name:n="Index API Client",clientType:r}=e;return O({...e,key:t,name:n,clientType:r}).extend(H)}async function _(e,t){return e.request({method:"info.getBlockchainID",params:t})}async function X(e){return e.request({method:"info.getNetworkID",params:{}})}function W(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=>_(e,t),getNetworkID:()=>X(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 Z(e){const{key:t="info",name:n="Info API Client"}=e;return O({...e,key:t,name:n,clientType:"info"}).extend(W)}async function K(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 Y(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 J(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 Q(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 ee(e,t){return e.request({method:"platform.getTx",params:t})}async function te(e,t){return e.request({method:"platform.getTxStatus",params:t})}async function ne(e,t){return e.request({method:"platform.getUTXOs",params:t})}async function re(e,t){return e.request({method:"platform.issueTx",params:t})}function ae(e){return{getBalance:t=>K(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:()=>Y(e),getFeeState:()=>J(e),getHeight:()=>async function(e){return e.request({method:"platform.getHeight",params:{}})}(e),getL1Validator:t=>Q(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=>ee(e,t),getTxStatus:t=>te(e,t),getUTXOs:t=>ne(e,t),getValidatorsAt:t=>async function(e,t){return e.request({method:"platform.getValidatorsAt",params:t})}(e,t),issueTx:t=>re(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 se(e){const{key:t="pChain",name:n="P-Chain Client"}=e;return O({...e,key:t,name:n,clientType:"pChain"}).extend(ae)}async function oe(e,t){return e.request({method:"avm.getAssetDescription",params:t})}async function ie(e){return e.request({method:"avm.getTxFee",params:{}})}async function fe(e,t){return e.request({method:"avm.getTxStatus",params:t})}async function ce(e,t){return e.request({method:"avm.getUTXOs",params:t})}async function ue(e,t){return e.request({method:"avm.issueTx",params:t})}function de(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=>oe(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:()=>ie(e),getTxStatus:t=>fe(e,t),getUTXOs:t=>ce(e,t),issueTx:t=>ue(e,t)}}function le(e){const{key:t="xChain",name:n="X-Chain Client"}=e;return O({...e,key:t,name:n,clientType:"xChain"}).extend(de)}async function be(e){return e.request({method:"eth_baseFee",params:[]})}function he(e){return{baseFee:()=>be(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 pe(e){const{key:t="avalanche",name:n="Avalanche Client",transport:r,chain:a,apiKey:i="",rlToken:f=""}=e,c=F(r,a,{apiKey:i,rlToken:f}),u=s({...e,key:t,name:n,transport:c,rpcSchema:o()}).extend(he);return"Avalanche"!==a?.name&&"Avalanche Fuji"!==a?.name?{...u}:{...u,pChain:se({...e,key:"pChain",name:"P-Chain Client"}).extend(ae),cChain:j({...e,key:"cChain",name:"C-Chain Client"}).extend(L),xChain:le({...e,key:"xChain",name:"X-Chain Client"}).extend(de),admin:R({...e,key:"admin",name:"Admin Client"}).extend(z),info:Z({...e,key:"info",name:"Info Client"}).extend(W),health:G({...e,key:"health",name:"Health Client"}).extend(D),indexPChainBlock:V({...e,key:"indexPChainBlock",name:"Index P-Chain Block Client",clientType:"indexPChainBlock"}).extend(H),indexCChainBlock:V({...e,key:"indexCChainBlock",name:"Index C-Chain Block Client",clientType:"indexCChainBlock"}).extend(H),indexXChainBlock:V({...e,key:"indexXChainBlock",name:"Index X-Chain Block Client",clientType:"indexXChainBlock"}).extend(H),indexXChainTx:V({...e,key:"indexXChainTx",name:"Index X-Chain Tx Client",clientType:"indexXChainTx"}).extend(H)}}let me=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 ye=/^bytes([1-9]|1[0-9]|2[0-9]|3[0-2])?$/,we=/^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)?$/,xe=/^\(.+?\).*?$/,ve=/^tuple(?<array>(\[(\d*)\])*)$/;function Pe(e){let t=e.type;if(ve.test(e.type)&&"components"in e){t="(";const n=e.components.length;for(let r=0;r<n;r++){t+=Pe(e.components[r]),r<n-1&&(t+=", ")}const r=ge(ve,e.type);return t+=`)${r?.array??""}`,Pe({...e,type:t})}return"indexed"in e&&e.indexed&&(t=`${t} indexed`),e.name?`${t} ${e.name}`:t}function Ie(e){let t="";const n=e.length;for(let r=0;r<n;r++){t+=Pe(e[r]),r!==n-1&&(t+=", ")}return t}const Te=/^error (?<name>[a-zA-Z$_][a-zA-Z0-9$_]*)\((?<parameters>.*?)\)$/;const Ee=/^event (?<name>[a-zA-Z$_][a-zA-Z0-9$_]*)\((?<parameters>.*?)\)$/;const Ae=/^function (?<name>[a-zA-Z$_][a-zA-Z0-9$_]*)\((?<parameters>.*?)\)(?: (?<scope>external|public{1}))?(?: (?<stateMutability>pure|view|nonpayable|payable{1}))?(?: returns\s?\((?<returns>.*?)\))?$/;const Be=/^struct (?<name>[a-zA-Z$_][a-zA-Z0-9$_]*) \{(?<properties>.*?)\}$/;function Ce(e){return Be.test(e)}function ke(e){return ge(Be,e)}const $e=/^constructor\((?<parameters>.*?)\)(?:\s(?<stateMutability>payable{1}))?$/;const Se=/^fallback\(\) external(?:\s(?<stateMutability>payable{1}))?$/;const Fe=/^receive\(\) external payable$/;const Ne=new Set(["indexed"]),Oe=new Set(["calldata","memory","storage"]);class ze extends me{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 Re extends me{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 Me extends me{constructor({param:e}){super("Invalid ABI parameter.",{details:e}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"InvalidParameterError"})}}class Ue extends me{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 qe extends me{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 Le extends me{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 je extends me{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 De extends me{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 me{constructor({signature:e}){super("Unknown signature.",{details:e}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"UnknownSignatureError"})}}class He extends me{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 Ve extends me{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 _e extends me{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 Xe=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 We(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 De({signature:e,type:"function"});const r=Qe(n.parameters),a=[],s=r.length;for(let e=0;e<s;e++)a.push(Je(r[e],{modifiers:Oe,structs:t,type:"function"}));const o=[];if(n.returns){const e=Qe(n.returns),r=e.length;for(let n=0;n<r;n++)o.push(Je(e[n],{modifiers:Oe,structs:t,type:"function"}))}return{name:n.name,type:"function",stateMutability:n.stateMutability??"nonpayable",inputs:a,outputs:o}}(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 De({signature:e,type:"event"});const r=Qe(n.parameters),a=[],s=r.length;for(let e=0;e<s;e++)a.push(Je(r[e],{modifiers:Ne,structs:t,type:"event"}));return{name:n.name,type:"event",inputs:a}}(e,t);if(function(e){return Te.test(e)}(e))return function(e,t={}){const n=function(e){return ge(Te,e)}(e);if(!n)throw new De({signature:e,type:"error"});const r=Qe(n.parameters),a=[],s=r.length;for(let e=0;e<s;e++)a.push(Je(r[e],{structs:t,type:"error"}));return{name:n.name,type:"error",inputs:a}}(e,t);if(function(e){return $e.test(e)}(e))return function(e,t={}){const n=function(e){return ge($e,e)}(e);if(!n)throw new De({signature:e,type:"constructor"});const r=Qe(n.parameters),a=[],s=r.length;for(let e=0;e<s;e++)a.push(Je(r[e],{structs:t,type:"constructor"}));return{type:"constructor",stateMutability:n.stateMutability??"nonpayable",inputs:a}}(e,t);if(function(e){return Se.test(e)}(e))return function(e){const t=function(e){return ge(Se,e)}(e);if(!t)throw new De({signature:e,type:"fallback"});return{type:"fallback",stateMutability:t.stateMutability??"nonpayable"}}(e);if(function(e){return Fe.test(e)}(e))return{type:"receive",stateMutability:"payable"};throw new Ge({signature:e})}const Ze=/^(?<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$_]*))?$/,Ke=/^\((?<type>.+?)\)(?<array>(?:\[\d*?\])+?)?(?:\s(?<modifier>calldata|indexed|memory|storage{1}))?(?:\s(?<name>[a-zA-Z$_][a-zA-Z0-9$_]*))?$/,Ye=/^u?int$/;function Je(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(Xe.has(n))return Xe.get(n);const r=xe.test(e),a=ge(r?Ke:Ze,e);if(!a)throw new Me({param:e});if(a.name&&function(e){return"address"===e||"bool"===e||"function"===e||"string"===e||"tuple"===e||ye.test(e)||we.test(e)||tt.test(e)}(a.name))throw new Ue({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=Qe(a.type),t=[],n=e.length;for(let r=0;r<n;r++)t.push(Je(e[r],{structs:i}));c={components:t}}else if(a.type in i)f="tuple",c={components:i[a.type]};else if(Ye.test(a.type))f=`${a.type}256`;else if("address payable"===a.type)f="address";else if(f=a.type,"struct"!==t?.type&&!et(f))throw new Re({type:f});if(a.modifier){if(!t?.modifiers?.has?.(a.modifier))throw new qe({param:e,type:t?.type,modifier:a.modifier});if(Oe.has(a.modifier)&&!function(e,t){return t||"bytes"===e||"string"===e||"tuple"===e}(f,!!a.array))throw new Le({param:e,type:t?.type,modifier:a.modifier})}const u={type:`${f}${a.array??""}`,...s,...o,...c};return Xe.set(n,u),u}function Qe(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?Qe(o,[...t,n.trim()]):Qe(o,t,`${n}${a}`,r);case"(":return Qe(o,t,`${n}${a}`,r+1);case")":return Qe(o,t,`${n}${a}`,r-1);default:return Qe(o,t,`${n}${a}`,r)}}if(""===n)return t;if(0!==r)throw new _e({current:n,depth:r});return t.push(n.trim()),t}function et(e){return"address"===e||"bool"===e||"function"===e||"string"===e||ye.test(e)||we.test(e)}const tt=/^(?: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 nt=/^(?<type>[a-zA-Z$_][a-zA-Z0-9$_]*)(?<array>(?:\[\d*?\])+?)?$/;function rt(e,t,n=new Set){const r=[],a=e.length;for(let s=0;s<a;s++){const a=e[s];if(xe.test(a.type))r.push(a);else{const e=ge(nt,a.type);if(!e?.type)throw new je({abiParameter:a});const{array:s,type:o}=e;if(o in t){if(n.has(o))throw new Ve({type:o});r.push({...a,type:`tuple${s??""}`,components:rt(t[o]??[],t,new Set([...n,o]))})}else{if(!et(o))throw new ze({type:o});r.push(a)}}}return r}function at(e){const t=function(e){const t={},n=e.length;for(let r=0;r<n;r++){const n=e[r];if(!Ce(n))continue;const a=ke(n);if(!a)throw new De({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=Je(t,{type:"struct"});o.push(n)}if(!o.length)throw new He({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]=rt(s,t)}return r}(e),n=[],r=e.length;for(let a=0;a<r;a++){const r=e[a];Ce(r)||n.push(We(r,t))}return n}function st(e){return"string"==typeof e?{address:e,type:"json-rpc"}:e}const ot="2.38.2";let it=({docsBaseUrl:e,docsPath:t="",docsSlug:n})=>t?`${e??"https://viem.sh"}${t}${n?`#${n}`:""}`:void 0,ft=`viem@${ot}`,ct=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=it?.({...n,docsPath:a});super([t||"An error occurred.","",...n.metaMessages?[...n.metaMessages,""]:[],...s?[`Docs: ${s}`]:[],...r?[`Details: ${r}`]:[],...ft?[`Version: ${ft}`]:[]].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=ot}walk(e){return ut(this,e)}};function ut(e,t){return t?.(e)?e:e&&"object"==typeof e&&"cause"in e&&void 0!==e.cause?ut(e.cause,t):t?null:e}class dt extends ct{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 lt(e,{strict:t=!0}={}){return!!e&&("string"==typeof e&&(t?/^0x[0-9a-fA-F]*$/.test(e):e.startsWith("0x")))}class bt extends ct{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 ht=class extends ct{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 pt extends ct{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 mt(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 ht({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 ht({size:Math.ceil(r.length/2),targetSize:n,type:"hex"});return`0x${r["right"===t?"padEnd":"padStart"](2*n,"0")}`}let yt=class extends ct{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 wt extends ct{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 xt extends ct{constructor({givenSize:e,maxSize:t}){super(`Size cannot exceed ${t} bytes. Given size: ${e} bytes.`,{name:"SizeOverflowError"})}}function vt(e){return lt(e,{strict:!1})?Math.ceil((e.length-2)/2):e.length}function Pt(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 It(e,{size:t}){if(vt(e)>t)throw new xt({givenSize:vt(e),maxSize:t})}function Tt(e,t={}){const{signed:n}=t;t.size&&It(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 Et(e,t={}){return Number(Tt(e,t))}const At=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,"0"));function Bt(e,t={}){return"number"==typeof e||"bigint"==typeof e?$t(e,t):"string"==typeof e?Ft(e,t):"boolean"==typeof e?Ct(e,t):kt(e,t)}function Ct(e,t={}){const n=`0x${Number(e)}`;return"number"==typeof t.size?(It(n,{size:t.size}),mt(n,{size:t.size})):n}function kt(e,t={}){let n="";for(let t=0;t<e.length;t++)n+=At[e[t]];const r=`0x${n}`;return"number"==typeof t.size?(It(r,{size:t.size}),mt(r,{dir:"right",size:t.size})):r}function $t(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 yt({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?mt(i,{size:r}):i}const St=new TextEncoder;function Ft(e,t={}){return kt(St.encode(e),t)}const Nt=new TextEncoder;function Ot(e,t={}){return"number"==typeof e||"bigint"==typeof e?function(e,t){const n=$t(e,t);return Mt(n)}(e,t):"boolean"==typeof e?function(e,t={}){const n=new Uint8Array(1);if(n[0]=Number(e),"number"==typeof t.size)return It(n,{size:t.size}),mt(n,{size:t.size});return n}(e,t):lt(e)?Mt(e,t):Ut(e,t)}const zt={zero:48,nine:57,A:65,F:70,a:97,f:102};function Rt(e){return e>=zt.zero&&e<=zt.nine?e-zt.zero:e>=zt.A&&e<=zt.F?e-(zt.A-10):e>=zt.a&&e<=zt.f?e-(zt.a-10):void 0}function Mt(e,t={}){let n=e;t.size&&(It(n,{size:t.size}),n=mt(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=Rt(r.charCodeAt(t++)),a=Rt(r.charCodeAt(t++));if(void 0===n||void 0===a)throw new ct(`Invalid byte sequence ("${r[t-2]}${r[t-1]}" in "${r}").`);s[e]=16*n+a}return s}function Ut(e,t={}){const n=Nt.encode(e);return"number"==typeof t.size?(It(n,{size:t.size}),mt(n,{dir:"right",size:t.size})):n}const qt=BigInt(2**32-1),Lt=BigInt(32);function jt(e,t=!1){return t?{h:Number(e&qt),l:Number(e>>Lt&qt)}:{h:0|Number(e>>Lt&qt),l:0|Number(e&qt)}}const Dt=k&&"object"==typeof k&&"webcrypto"in k?k.webcrypto:k&&"object"==typeof k&&"randomBytes"in k?k:void 0;function Gt(e){if(!Number.isSafeInteger(e)||e<0)throw new Error("positive integer expected, got "+e)}function Ht(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 Vt(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 _t(e,t){Ht(e);const n=t.outputLen;if(e.length<n)throw new Error("digestInto() expects output buffer of length at least "+n)}function Xt(...e){for(let t=0;t<e.length;t++)e[t].fill(0)}function Wt(e){return new DataView(e.buffer,e.byteOffset,e.byteLength)}function Zt(e,t){return e<<32-t|e>>>t}function Kt(e){return e<<24&4278190080|e<<8&16711680|e>>>8&65280|e>>>24&255}const Yt=(()=>68===new Uint8Array(new Uint32Array([287454020]).buffer)[0])()?e=>e:function(e){for(let t=0;t<e.length;t++)e[t]=Kt(e[t]);return e};function Jt(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)),Ht(e),e}class Qt{}function en(e){const t=t=>e().update(Jt(t)).digest(),n=e();return t.outputLen=n.outputLen,t.blockLen=n.blockLen,t.create=()=>e(),t}function tn(e=32){if(Dt&&"function"==typeof Dt.getRandomValues)return Dt.getRandomValues(new Uint8Array(e));if(Dt&&"function"==typeof Dt.randomBytes)return Uint8Array.from(Dt.randomBytes(e));throw new Error("crypto.getRandomValues must be defined")}const nn=BigInt(0),rn=BigInt(1),an=BigInt(2),sn=BigInt(7),on=BigInt(256),fn=BigInt(113),cn=[],un=[],dn=[];for(let e=0,t=rn,n=1,r=0;e<24;e++){[n,r]=[r,(2*n+3*r)%5],cn.push(2*(5*r+n)),un.push((e+1)*(e+2)/2%64);let a=nn;for(let e=0;e<7;e++)t=(t<<rn^(t>>sn)*fn)%on,t&an&&(a^=rn<<(rn<<BigInt(e))-rn);dn.push(a)}const ln=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}=jt(e[s],t);[r[s],a[s]]=[n,o]}return[r,a]}(dn,!0),bn=ln[0],hn=ln[1],pn=(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),mn=(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 Qt{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(){Yt(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=pn(s,o,1)^n[r],f=mn(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=un[n],s=pn(t,a,r),o=mn(t,a,r),i=cn[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]^=bn[r],e[1]^=hn[r]}Xt(n)}(this.state32,this.rounds),Yt(this.state32),this.posOut=0,this.pos=0}update(e){Vt(this),Ht(e=Jt(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){Vt(this,!1),Ht(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(_t(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,Xt(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 yn=(()=>{return e=1,t=136,n=32,en(()=>new gn(t,e,n));var e,t,n})();function wn(e,t){const n=t||"hex",r=yn(lt(e,{strict:!1})?Ot(e):e);return"bytes"===n?r:Bt(r)}class xn 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 vn=/^0x[a-fA-F0-9]{40}$/,Pn=new xn(8192);function In(e,t){const{strict:n=!0}=t??{},r=`${e}.${n}`;if(Pn.has(r))return Pn.get(r);const a=!(!vn.test(e)||e.toLowerCase()!==e&&n&&En(e)!==e);return Pn.set(r,a),a}const Tn=new xn(8192);function En(e,t){if(Tn.has(`${e}.${t}`))return Tn.get(`${e}.${t}`);const n=e.substring(2).toLowerCase(),r=wn(Ut(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 Tn.set(`${e}.${t}`,s),s}function An(e,{includeName:t=!1}={}){if("function"!==e.type&&"event"!==e.type&&"error"!==e.type)throw new Vn(e.type);return`${e.name}(${Bn(e.inputs,{includeName:t})})`}function Bn(e,{includeName:t=!1}={}){return e?e.map(e=>function(e,{includeName:t}){if(e.type.startsWith("tuple"))return`(${Bn(e.components,{includeName:t})})${e.type.slice(5)}`;return e.type+(t&&e.name?` ${e.name}`:"")}(e,{includeName:t})).join(t?", ":","):""}class Cn extends ct{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 kn extends ct{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 $n extends ct{constructor({data:e,params:t,size:n}){super([`Data size of ${n} bytes is too small for given parameters.`].join("\n"),{metaMessages:[`Params: (${Bn(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 Sn extends ct{constructor(){super('Cannot decode zero data ("0x") with ABI parameters.',{name:"AbiDecodingZeroDataError"})}}class Fn extends ct{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 Nn extends ct{constructor({expectedSize:e,value:t}){super(`Size of bytes "${t}" (bytes${vt(t)}) does not match expected size (bytes${e}).`,{name:"AbiEncodingBytesSizeMismatchError"})}}class On extends ct{constructor({expectedLength:e,givenLength:t}){super(["ABI encoding params/values length mismatch.",`Expected length (params): ${e}`,`Given length (values): ${t}`].join("\n"),{name:"AbiEncodingLengthMismatchError"})}}class zn extends ct{constructor(e,{docsPath:t}){super([`Arguments (\`args\`) were provided to "${e}", but "${e}" on the ABI does not contain any parameters (\`inputs\`).`,"Cannot encode error result without knowing what the parameter types are.","Make sure you are using the correct ABI and that the inputs exist on it."].join("\n"),{docsPath:t,name:"AbiErrorInputsNotFoundError"})}}class Rn extends ct{constructor(e,{docsPath:t}={}){super([`Error ${e?`"${e}" `:""}not found on ABI.`,"Make sure you are using the correct ABI and that the error exists on it."].join("\n")