UNPKG

@flaunch/sdk

Version:

Flaunch SDK to easily interact with the Flaunch protocol

1 lines 716 kB
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("@delvtech/drift"),require("viem"),require("axios"),require("@delvtech/drift-viem")):"function"==typeof define&&define.amd?define(["exports","@delvtech/drift","viem","axios","@delvtech/drift-viem"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self)["@flaunch_sdk"]={},e.drift,e.viem,e.axios,e.driftViem)}(this,function(e,t,n,a,i){"use strict";function r(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var s=r(a);function o(e){const t={formatters:void 0,fees:void 0,serializers:void 0,...e};return Object.assign(t,{extend:function e(t){return n=>{const a="function"==typeof n?n(t):n,i={...t,...a};return Object.assign(i,{extend:e(i)})}}(t)})}const p="2.55.4";let u=({docsBaseUrl:e,docsPath:t="",docsSlug:n})=>t?`${e??"https://viem.sh"}${t}${n?`#${n}`:""}`:void 0,y=`viem@${p}`;class d extends Error{constructor(e,t={}){const n=t.cause instanceof d?t.cause.details:t.cause?.message?t.cause.message:t.details,a=t.cause instanceof d&&t.cause.docsPath||t.docsPath,i=u?.({...t,docsPath:a});super([e||"An error occurred.","",...t.metaMessages?[...t.metaMessages,""]:[],...i?[`Docs: ${i}`]:[],...n?[`Details: ${n}`]:[],...y?[`Version: ${y}`]:[]].join("\n"),t.cause?{cause:t.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=n,this.docsPath=a,this.metaMessages=t.metaMessages,this.name=t.name??this.name,this.shortMessage=e,this.version=p}walk(e){return l(this,e)}}function l(e,t){return t?.(e)?e:e&&"object"==typeof e&&"cause"in e&&void 0!==e.cause?l(e.cause,t):t?null:e}class c extends d{constructor({max:e,min:t,signed:n,size:a,value:i}){super(`Number "${i}" is not in safe ${a?`${8*a}-bit ${n?"signed":"unsigned"} `:""}integer range ${e?`(${t} to ${e})`:`(above ${t})`}`,{name:"IntegerOutOfRangeError"})}}class m extends d{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 f extends d{constructor({givenSize:e,maxSize:t}){super(`Size cannot exceed ${t} bytes. Given size: ${e} bytes.`,{name:"SizeOverflowError"})}}function b(e,{strict:t=!0}={}){return!!e&&("string"==typeof e&&(t?/^0x[0-9a-fA-F]*$/.test(e):e.startsWith("0x")))}function h(e){return b(e,{strict:!1})?Math.ceil((e.length-2)/2):e.length}function T(e,{dir:t="left"}={}){let n="string"==typeof e?e.replace("0x",""):e,a=0;for(let e=0;e<n.length-1&&"0"===n["left"===t?e:n.length-e-1].toString();e++)a++;return n="left"===t?n.slice(a):n.slice(0,n.length-a),"string"==typeof e?(1===n.length&&"right"===t&&(n=`${n}0`),`0x${n.length%2==1?`0${n}`:n}`):n}class g extends d{constructor({offset:e,position:t,size:n}){super(`Slice ${"start"===t?"starting":"ending"} at offset "${e}" is out-of-bounds (size: ${n}).`,{name:"SliceOffsetOutOfBoundsError"})}}class w extends d{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 v extends d{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 x(e,{dir:t,size:n=32}={}){return"string"==typeof e?I(e,{dir:t,size:n}):function(e,{dir:t,size:n=32}={}){if(null===n)return e;if(e.length>n)throw new w({size:e.length,targetSize:n,type:"bytes"});const a=new Uint8Array(n);for(let i=0;i<n;i++){const r="right"===t;a[r?i:n-i-1]=e[r?i:e.length-i-1]}return a}(e,{dir:t,size:n})}function I(e,{dir:t,size:n=32}={}){if(null===n)return e;const a=e.replace("0x","");if(a.length>2*n)throw new w({size:Math.ceil(a.length/2),targetSize:n,type:"hex"});return`0x${a["right"===t?"padEnd":"padStart"](2*n,"0")}`}const P=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,"0"));function k(e,t={}){return"number"==typeof e||"bigint"==typeof e?F(e,t):"string"==typeof e?C(e,t):"boolean"==typeof e?M(e,t):A(e,t)}function M(e,t={}){const n=`0x${Number(e)}`;return"number"==typeof t.size?(R(n,{size:t.size}),x(n,{size:t.size})):n}function A(e,t={}){let n="";for(let t=0;t<e.length;t++)n+=P[e[t]];const a=`0x${n}`;return"number"==typeof t.size?(R(a,{size:t.size}),x(a,{dir:"right",size:t.size})):a}function F(e,t={}){const{signed:n,size:a}=t,i=BigInt(e);let r;a?r=n?(1n<<8n*BigInt(a)-1n)-1n:2n**(8n*BigInt(a))-1n:"number"==typeof e&&(r=BigInt(Number.MAX_SAFE_INTEGER));const s="bigint"==typeof r&&n?-r-1n:0;if(r&&i>r||i<s){const t="bigint"==typeof e?"n":"";throw new c({max:r?`${r}${t}`:void 0,min:`${s}${t}`,signed:n,size:a,value:`${e}${t}`})}const o=`0x${(n&&i<0?(1n<<BigInt(8*a))+BigInt(i):i).toString(16)}`;return a?x(o,{size:a}):o}const _=new TextEncoder;function C(e,t={}){return A(_.encode(e),t)}const S=new TextEncoder;function E(e,t={}){return"number"==typeof e||"bigint"==typeof e?function(e,t){const n=F(e,t);return D(n)}(e,t):"boolean"==typeof e?function(e,t={}){const n=new Uint8Array(1);if(n[0]=Number(e),"number"==typeof t.size)return R(n,{size:t.size}),x(n,{size:t.size});return n}(e,t):b(e)?D(e,t):U(e,t)}const B={zero:48,nine:57,A:65,F:70,a:97,f:102};function O(e){return e>=B.zero&&e<=B.nine?e-B.zero:e>=B.A&&e<=B.F?e-(B.A-10):e>=B.a&&e<=B.f?e-(B.a-10):void 0}function D(e,t={}){let n=e;t.size&&(R(n,{size:t.size}),n=x(n,{dir:"right",size:t.size}));let a=n.slice(2);a.length%2&&(a=`0${a}`);const i=a.length/2,r=new Uint8Array(i);for(let e=0,t=0;e<i;e++){const n=O(a.charCodeAt(t++)),i=O(a.charCodeAt(t++));if(void 0===n||void 0===i)throw new d(`Invalid byte sequence ("${a[t-2]}${a[t-1]}" in "${a}").`);r[e]=16*n+i}return r}function U(e,t={}){const n=S.encode(e);return"number"==typeof t.size?(R(n,{size:t.size}),x(n,{dir:"right",size:t.size})):n}function R(e,{size:t}){if(h(e)>t)throw new f({givenSize:h(e),maxSize:t})}function N(e,t={}){const{signed:n}=t;t.size&&R(e,{size:t.size});const a=BigInt(e);if(!n)return a;const i=(e.length-2)/2;return a<=(1n<<8n*BigInt(i)-1n)-1n?a:a-BigInt(`0x${"f".padStart(2*i,"f")}`)-1n}function L(e,t={}){const n=N(e,t),a=Number(n);if(!Number.isSafeInteger(a))throw new c({max:`${Number.MAX_SAFE_INTEGER}`,min:`${Number.MIN_SAFE_INTEGER}`,signed:t.signed,size:t.size,value:`${n}n`});return a}function z(e,t){return({exclude:n,format:a})=>({exclude:n,format:(e,i)=>{const r=t(e,i);if(n)for(const e of n)delete r[e];return{...r,...a(e,i)}},type:e})}const $={"0x0":"legacy","0x1":"eip2930","0x2":"eip1559","0x3":"eip4844","0x4":"eip7702"};function H(e,t){const n={...e,blockHash:e.blockHash?e.blockHash:null,blockNumber:e.blockNumber?BigInt(e.blockNumber):null,...null!=e.blockTimestamp&&{blockTimestamp:BigInt(e.blockTimestamp)},chainId:e.chainId?L(e.chainId):void 0,gas:e.gas?BigInt(e.gas):void 0,gasPrice:e.gasPrice?BigInt(e.gasPrice):void 0,maxFeePerBlobGas:e.maxFeePerBlobGas?BigInt(e.maxFeePerBlobGas):void 0,maxFeePerGas:e.maxFeePerGas?BigInt(e.maxFeePerGas):void 0,maxPriorityFeePerGas:e.maxPriorityFeePerGas?BigInt(e.maxPriorityFeePerGas):void 0,nonce:e.nonce?L(e.nonce):void 0,to:e.to?e.to:null,transactionIndex:e.transactionIndex?Number(e.transactionIndex):null,type:e.type?$[e.type]:void 0,typeHex:e.type?e.type:void 0,value:e.value?BigInt(e.value):void 0,v:e.v?BigInt(e.v):void 0};return e.authorizationList&&(n.authorizationList=e.authorizationList.map(e=>({address:e.address,chainId:Number(e.chainId),nonce:Number(e.nonce),r:e.r,s:e.s,yParity:Number(e.yParity)}))),n.yParity=(()=>{if(e.yParity)return Number(e.yParity);if("bigint"==typeof n.v){if(0n===n.v||27n===n.v)return 0;if(1n===n.v||28n===n.v)return 1;if(n.v>=35n)return n.v%2n==0n?1:0}})(),"legacy"===n.type&&(delete n.accessList,delete n.maxFeePerBlobGas,delete n.maxFeePerGas,delete n.maxPriorityFeePerGas,delete n.yParity),"eip2930"===n.type&&(delete n.maxFeePerBlobGas,delete n.maxFeePerGas,delete n.maxPriorityFeePerGas),"eip1559"===n.type&&delete n.maxFeePerBlobGas,n}const q=z("transaction",H);function V(e,t){const n=(e.transactions??[]).map(e=>"string"==typeof e?e:H(e));return{...e,baseFeePerGas:e.baseFeePerGas?BigInt(e.baseFeePerGas):null,blobGasUsed:e.blobGasUsed?BigInt(e.blobGasUsed):void 0,difficulty:e.difficulty?BigInt(e.difficulty):void 0,excessBlobGas:e.excessBlobGas?BigInt(e.excessBlobGas):void 0,gasLimit:e.gasLimit?BigInt(e.gasLimit):void 0,gasUsed:e.gasUsed?BigInt(e.gasUsed):void 0,hash:e.hash?e.hash:null,logsBloom:e.logsBloom?e.logsBloom:null,nonce:e.nonce?e.nonce:null,number:e.number?BigInt(e.number):null,size:e.size?BigInt(e.size):void 0,timestamp:e.timestamp?BigInt(e.timestamp):void 0,transactions:n,totalDifficulty:e.totalDifficulty?BigInt(e.totalDifficulty):null}}const K=z("block",V);function G(e,{args:t,eventName:n}={}){return{...e,blockHash:e.blockHash?e.blockHash:null,blockNumber:e.blockNumber?BigInt(e.blockNumber):null,blockTimestamp:e.blockTimestamp?BigInt(e.blockTimestamp):null===e.blockTimestamp?null:void 0,logIndex:e.logIndex?Number(e.logIndex):null,transactionHash:e.transactionHash?e.transactionHash:null,transactionIndex:e.transactionIndex?Number(e.transactionIndex):null,...n?{args:t,eventName:n}:{}}}const W={"0x0":"reverted","0x1":"success"};function j(e,t){const n={...e,blockNumber:e.blockNumber?BigInt(e.blockNumber):null,contractAddress:e.contractAddress?e.contractAddress:null,cumulativeGasUsed:e.cumulativeGasUsed?BigInt(e.cumulativeGasUsed):null,effectiveGasPrice:e.effectiveGasPrice?BigInt(e.effectiveGasPrice):null,gasUsed:e.gasUsed?BigInt(e.gasUsed):null,logs:e.logs?e.logs.map(e=>G(e)):null,to:e.to?e.to:null,transactionIndex:e.transactionIndex?L(e.transactionIndex):null,status:e.status?W[e.status]:null,type:e.type?$[e.type]||e.type:null};return e.blobGasPrice&&(n.blobGasPrice=BigInt(e.blobGasPrice)),e.blobGasUsed&&(n.blobGasUsed=BigInt(e.blobGasUsed)),n}const Z=z("transactionReceipt",j),X={legacy:"0x0",eip2930:"0x1",eip1559:"0x2",eip4844:"0x3",eip7702:"0x4"};function Y(e,t){const n={};return void 0!==e.authorizationList&&(n.authorizationList=e.authorizationList.map(e=>({address:e.address,r:e.r?F(BigInt(e.r)):e.r,s:e.s?F(BigInt(e.s)):e.s,chainId:F(e.chainId),nonce:F(e.nonce),...void 0!==e.yParity?{yParity:F(e.yParity)}:{},...void 0!==e.v&&void 0===e.yParity?{v:F(e.v)}:{}}))),void 0!==e.accessList&&(n.accessList=e.accessList),void 0!==e.blobVersionedHashes&&(n.blobVersionedHashes=e.blobVersionedHashes),void 0!==e.blobs&&("string"!=typeof e.blobs[0]?n.blobs=e.blobs.map(e=>A(e)):n.blobs=e.blobs),void 0!==e.data&&(n.data=e.data),e.account&&(n.from=e.account.address),void 0!==e.from&&(n.from=e.from),void 0!==e.gas&&(n.gas=F(e.gas)),void 0!==e.gasPrice&&(n.gasPrice=F(e.gasPrice)),void 0!==e.maxFeePerBlobGas&&(n.maxFeePerBlobGas=F(e.maxFeePerBlobGas)),void 0!==e.maxFeePerGas&&(n.maxFeePerGas=F(e.maxFeePerGas)),void 0!==e.maxPriorityFeePerGas&&(n.maxPriorityFeePerGas=F(e.maxPriorityFeePerGas)),void 0!==e.nonce&&(n.nonce=F(e.nonce)),void 0!==e.to&&(n.to=e.to),void 0!==e.type&&(n.type=X[e.type]),void 0!==e.value&&(n.value=F(e.value)),n}const Q=2n**256n-1n;function J(e){return"string"==typeof e[0]?ee(e):function(e){let t=0;for(const n of e)t+=n.length;const n=new Uint8Array(t);let a=0;for(const t of e)n.set(t,a),a+=t.length;return n}(e)}function ee(e){return`0x${e.reduce((e,t)=>e+t.replace("0x",""),"")}`}class te extends d{constructor({offset:e}){super(`Offset \`${e}\` cannot be negative.`,{name:"NegativeOffsetError"})}}class ne extends d{constructor({length:e,position:t}){super(`Position \`${t}\` is out of bounds (\`0 < position < ${e}\`).`,{name:"PositionOutOfBoundsError"})}}class ae extends d{constructor({count:e,limit:t}){super(`Recursive read limit of \`${t}\` exceeded (recursive read count: \`${e}\`).`,{name:"RecursiveReadLimitExceededError"})}}const ie={bytes:new Uint8Array,dataView:new DataView(new ArrayBuffer(0)),position:0,positionReadCount:new Map,recursiveReadCount:0,recursiveReadLimit:Number.POSITIVE_INFINITY,assertReadLimit(){if(this.recursiveReadCount>=this.recursiveReadLimit)throw new ae({count:this.recursiveReadCount+1,limit:this.recursiveReadLimit})},assertPosition(e){if(e<0||e>this.bytes.length-1)throw new ne({length:this.bytes.length,position:e})},decrementPosition(e){if(e<0)throw new te({offset:e});const t=this.position-e;this.assertPosition(t),this.position=t},getReadCount(e){return this.positionReadCount.get(e||this.position)||0},incrementPosition(e){if(e<0)throw new te({offset:e});const t=this.position+e;this.assertPosition(t),this.position=t},inspectByte(e){const t=e??this.position;return this.assertPosition(t),this.bytes[t]},inspectBytes(e,t){const n=t??this.position;return this.assertPosition(n+e-1),this.bytes.subarray(n,n+e)},inspectUint8(e){const t=e??this.position;return this.assertPosition(t),this.bytes[t]},inspectUint16(e){const t=e??this.position;return this.assertPosition(t+1),this.dataView.getUint16(t)},inspectUint24(e){const t=e??this.position;return this.assertPosition(t+2),(this.dataView.getUint16(t)<<8)+this.dataView.getUint8(t+2)},inspectUint32(e){const t=e??this.position;return this.assertPosition(t+3),this.dataView.getUint32(t)},pushByte(e){this.assertPosition(this.position),this.bytes[this.position]=e,this.position++},pushBytes(e){this.assertPosition(this.position+e.length-1),this.bytes.set(e,this.position),this.position+=e.length},pushUint8(e){this.assertPosition(this.position),this.bytes[this.position]=e,this.position++},pushUint16(e){this.assertPosition(this.position+1),this.dataView.setUint16(this.position,e),this.position+=2},pushUint24(e){this.assertPosition(this.position+2),this.dataView.setUint16(this.position,e>>8),this.dataView.setUint8(this.position+2,255&e),this.position+=3},pushUint32(e){this.assertPosition(this.position+3),this.dataView.setUint32(this.position,e),this.position+=4},readByte(){this.assertReadLimit(),this._touch();const e=this.inspectByte();return this.position++,e},readBytes(e,t){this.assertReadLimit(),this._touch();const n=this.inspectBytes(e);return this.position+=t??e,n},readUint8(){this.assertReadLimit(),this._touch();const e=this.inspectUint8();return this.position+=1,e},readUint16(){this.assertReadLimit(),this._touch();const e=this.inspectUint16();return this.position+=2,e},readUint24(){this.assertReadLimit(),this._touch();const e=this.inspectUint24();return this.position+=3,e},readUint32(){this.assertReadLimit(),this._touch();const e=this.inspectUint32();return this.position+=4,e},get remaining(){return this.bytes.length-this.position},setPosition(e){const t=this.position;return this.assertPosition(e),this.position=e,()=>this.position=t},_touch(){if(this.recursiveReadLimit===Number.POSITIVE_INFINITY)return;const e=this.getReadCount();this.positionReadCount.set(this.position,e+1),e>0&&this.recursiveReadCount++}};function re(e,{recursiveReadLimit:t=8192}={}){const n=Object.create(ie);return n.bytes=e,n.dataView=new DataView(e.buffer??e,e.byteOffset,e.byteLength),n.positionReadCount=new Map,n.recursiveReadLimit=t,n}function se(e,t="hex"){const n=oe(e),a=re(new Uint8Array(n.length));return n.encode(a),"hex"===t?A(a.bytes):a.bytes}function oe(e){return Array.isArray(e)?function(e){const t=e.reduce((e,t)=>e+t.length,0),n=pe(t);return{length:t<=55?1+t:1+n+t,encode(a){t<=55?a.pushByte(192+t):(a.pushByte(247+n),1===n?a.pushUint8(t):2===n?a.pushUint16(t):3===n?a.pushUint24(t):a.pushUint32(t));for(const{encode:t}of e)t(a)}}}(e.map(e=>oe(e))):function(e){const t="string"==typeof e?D(e):e,n=pe(t.length),a=1===t.length&&t[0]<128?1:t.length<=55?1+t.length:1+n+t.length;return{length:a,encode(e){1===t.length&&t[0]<128?e.pushBytes(t):t.length<=55?(e.pushByte(128+t.length),e.pushBytes(t)):(e.pushByte(183+n),1===n?e.pushUint8(t.length):2===n?e.pushUint16(t.length):3===n?e.pushUint24(t.length):e.pushUint32(t.length),e.pushBytes(t))}}}(e)}function pe(e){if(e<256)return 1;if(e<65536)return 2;if(e<2**24)return 3;if(e<2**32)return 4;throw new d("Length is too large.")}const ue={wei:0,gwei:9,szabo:12,finney:15,ether:18};function ye(e,t=0){if(!Number.isInteger(t)||t<0)throw new de({decimals:t});let n=e.toString();const a=n.startsWith("-");a&&(n=n.slice(1)),n=n.padStart(t,"0");let[i,r]=[n.slice(0,n.length-t),n.slice(n.length-t)];return r=r.replace(/(0+)$/,""),`${a?"-":""}${i||"0"}${r?`.${r}`:""}`}class de extends Error{constructor({decimals:e}){super(`\`decimals\` must be a non-negative integer. Got \`${e}\`.`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Value.InvalidDecimalsError"})}}function le(e,t="wei"){return function(e,t="wei"){return ye(e,ue.ether-ue[t])}(e,t)}function ce(e,t="wei"){return function(e,t="wei"){return ye(e,ue.gwei-ue[t])}(e,t)}function me(e){const t=Object.entries(e).map(([e,t])=>void 0===t||!1===t?null:[e,t]).filter(Boolean),n=t.reduce((e,[t])=>Math.max(e,t.length),0);return t.map(([e,t])=>` ${`${e}:`.padEnd(n+1)} ${t}`).join("\n")}class fe extends d{constructor({v:e}){super(`Invalid \`v\` value "${e}". Expected 27 or 28.`,{name:"InvalidLegacyVError"})}}class be extends d{constructor({transaction:e}){super("Cannot infer a transaction type from provided transaction.",{metaMessages:["Provided Transaction:","{",me(e),"}","","To infer the type, either provide:","- a `type` to the Transaction, or","- an EIP-1559 Transaction with `maxFeePerGas`, or","- an EIP-2930 Transaction with `gasPrice` & `accessList`, or","- an EIP-4844 Transaction with `blobs`, `blobVersionedHashes`, `sidecars`, or","- an EIP-7702 Transaction with `authorizationList`, or","- a Legacy Transaction with `gasPrice`"],name:"InvalidSerializableTransactionError"})}}class he extends d{constructor({storageKey:e}){super(`Size for storage key "${e}" is invalid. Expected 32 bytes. Got ${Math.floor((e.length-2)/2)} bytes.`,{name:"InvalidStorageKeySizeError"})}}class Te extends d{constructor(e,{account:t,docsPath:n,chain:a,data:i,gas:r,gasPrice:s,maxFeePerGas:o,maxPriorityFeePerGas:p,nonce:u,to:y,value:d}){const l=me({chain:a&&`${a?.name} (id: ${a?.id})`,from:t?.address,to:y,value:void 0!==d&&`${le(d)} ${a?.nativeCurrency?.symbol||"ETH"}`,data:i,gas:r,gasPrice:void 0!==s&&`${ce(s)} gwei`,maxFeePerGas:void 0!==o&&`${ce(o)} gwei`,maxPriorityFeePerGas:void 0!==p&&`${ce(p)} gwei`,nonce:u});super(e.shortMessage,{cause:e,docsPath:n,metaMessages:[...e.metaMessages?[...e.metaMessages," "]:[],"Request Arguments:",l].filter(Boolean),name:"TransactionExecutionError"}),Object.defineProperty(this,"cause",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.cause=e}}function ge(e){const{kzg:t}=e,n=e.to??("string"==typeof e.blobs[0]?"hex":"bytes"),a="string"==typeof e.blobs[0]?e.blobs.map(e=>D(e)):e.blobs,i=[];for(const e of a)i.push(Uint8Array.from(t.blobToKzgCommitment(e)));return"bytes"===n?i:i.map(e=>A(e))}function we(e){const{kzg:t}=e,n=e.to??("string"==typeof e.blobs[0]?"hex":"bytes"),a="string"==typeof e.blobs[0]?e.blobs.map(e=>D(e)):e.blobs,i="string"==typeof e.commitments[0]?e.commitments.map(e=>D(e)):e.commitments,r=[];for(let e=0;e<a.length;e++){const n=a[e],s=i[e];r.push(Uint8Array.from(t.computeBlobKzgProof(n,s)))}return"bytes"===n?r:r.map(e=>A(e))}const ve="object"==typeof globalThis&&"crypto"in globalThis?globalThis.crypto:void 0;function xe(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&"Uint8Array"===e.constructor.name}function Ie(e){if(!Number.isSafeInteger(e)||e<0)throw new Error("positive integer expected, got "+e)}function Pe(e,...t){if(!xe(e))throw new Error("Uint8Array expected");if(t.length>0&&!t.includes(e.length))throw new Error("Uint8Array expected of length "+t+", got length="+e.length)}function ke(e){if("function"!=typeof e||"function"!=typeof e.create)throw new Error("Hash should be wrapped by utils.createHasher");Ie(e.outputLen),Ie(e.blockLen)}function Me(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 Ae(e,t){Pe(e);const n=t.outputLen;if(e.length<n)throw new Error("digestInto() expects output buffer of length at least "+n)}function Fe(...e){for(let t=0;t<e.length;t++)e[t].fill(0)}function _e(e){return new DataView(e.buffer,e.byteOffset,e.byteLength)}function Ce(e,t){return e<<32-t|e>>>t}function Se(e){return e<<24&4278190080|e<<8&16711680|e>>>8&65280|e>>>24&255}const Ee=(()=>68===new Uint8Array(new Uint32Array([287454020]).buffer)[0])()?e=>e:function(e){for(let t=0;t<e.length;t++)e[t]=Se(e[t]);return e},Be=(()=>"function"==typeof Uint8Array.from([]).toHex&&"function"==typeof Uint8Array.fromHex)(),Oe=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,"0"));function De(e){if(Pe(e),Be)return e.toHex();let t="";for(let n=0;n<e.length;n++)t+=Oe[e[n]];return t}const Ue=48,Re=57,Ne=65,Le=70,ze=97,$e=102;function He(e){return e>=Ue&&e<=Re?e-Ue:e>=Ne&&e<=Le?e-(Ne-10):e>=ze&&e<=$e?e-(ze-10):void 0}function qe(e){if("string"!=typeof e)throw new Error("hex string expected, got "+typeof e);if(Be)return Uint8Array.fromHex(e);const t=e.length,n=t/2;if(t%2)throw new Error("hex string expected, got unpadded hex of length "+t);const a=new Uint8Array(n);for(let t=0,i=0;t<n;t++,i+=2){const n=He(e.charCodeAt(i)),r=He(e.charCodeAt(i+1));if(void 0===n||void 0===r){const t=e[i]+e[i+1];throw new Error('hex string expected, got non-hex character "'+t+'" at index '+i)}a[t]=16*n+r}return a}function Ve(e){if("string"!=typeof e)throw new Error("string expected");return new Uint8Array((new TextEncoder).encode(e))}function Ke(e){return"string"==typeof e&&(e=Ve(e)),Pe(e),e}function Ge(...e){let t=0;for(let n=0;n<e.length;n++){const a=e[n];Pe(a),t+=a.length}const n=new Uint8Array(t);for(let t=0,a=0;t<e.length;t++){const i=e[t];n.set(i,a),a+=i.length}return n}class We{}function je(e){const t=t=>e().update(Ke(t)).digest(),n=e();return t.outputLen=n.outputLen,t.blockLen=n.blockLen,t.create=()=>e(),t}function Ze(e=32){if(ve&&"function"==typeof ve.getRandomValues)return ve.getRandomValues(new Uint8Array(e));if(ve&&"function"==typeof ve.randomBytes)return Uint8Array.from(ve.randomBytes(e));throw new Error("crypto.getRandomValues must be defined")}function Xe(e,t,n){return e&t^~e&n}function Ye(e,t,n){return e&t^e&n^t&n}class Qe extends We{constructor(e,t,n,a){super(),this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.blockLen=e,this.outputLen=t,this.padOffset=n,this.isLE=a,this.buffer=new Uint8Array(e),this.view=_e(this.buffer)}update(e){Me(this),Pe(e=Ke(e));const{view:t,buffer:n,blockLen:a}=this,i=e.length;for(let r=0;r<i;){const s=Math.min(a-this.pos,i-r);if(s===a){const t=_e(e);for(;a<=i-r;r+=a)this.process(t,r);continue}n.set(e.subarray(r,r+s),this.pos),this.pos+=s,r+=s,this.pos===a&&(this.process(t,0),this.pos=0)}return this.length+=e.length,this.roundClean(),this}digestInto(e){Me(this),Ae(e,this),this.finished=!0;const{buffer:t,view:n,blockLen:a,isLE:i}=this;let{pos:r}=this;t[r++]=128,Fe(this.buffer.subarray(r)),this.padOffset>a-r&&(this.process(n,0),r=0);for(let e=r;e<a;e++)t[e]=0;!function(e,t,n,a){if("function"==typeof e.setBigUint64)return e.setBigUint64(t,n,a);const i=BigInt(32),r=BigInt(4294967295),s=Number(n>>i&r),o=Number(n&r),p=a?4:0,u=a?0:4;e.setUint32(t+p,s,a),e.setUint32(t+u,o,a)}(n,a-8,BigInt(8*this.length),i),this.process(n,0);const s=_e(e),o=this.outputLen;if(o%4)throw new Error("_sha2: outputLen should be aligned to 32bit");const p=o/4,u=this.get();if(p>u.length)throw new Error("_sha2: outputLen bigger than state");for(let e=0;e<p;e++)s.setUint32(4*e,u[e],i)}digest(){const{buffer:e,outputLen:t}=this;this.digestInto(e);const n=e.slice(0,t);return this.destroy(),n}_cloneInto(e){e||(e=new this.constructor),e.set(...this.get());const{blockLen:t,buffer:n,length:a,finished:i,destroyed:r,pos:s}=this;return e.destroyed=r,e.finished=i,e.length=a,e.pos=s,a%t&&e.buffer.set(n),e}clone(){return this._cloneInto()}}const Je=Uint32Array.from([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),et=Uint32Array.from([3418070365,3238371032,1654270250,914150663,2438529370,812702999,355462360,4144912697,1731405415,4290775857,2394180231,1750603025,3675008525,1694076839,1203062813,3204075428]),tt=Uint32Array.from([1779033703,4089235720,3144134277,2227873595,1013904242,4271175723,2773480762,1595750129,1359893119,2917565137,2600822924,725511199,528734635,4215389547,1541459225,327033209]),nt=BigInt(2**32-1),at=BigInt(32);function it(e,t=!1){return t?{h:Number(e&nt),l:Number(e>>at&nt)}:{h:0|Number(e>>at&nt),l:0|Number(e&nt)}}function rt(e,t=!1){const n=e.length;let a=new Uint32Array(n),i=new Uint32Array(n);for(let r=0;r<n;r++){const{h:n,l:s}=it(e[r],t);[a[r],i[r]]=[n,s]}return[a,i]}const st=(e,t,n)=>e>>>n,ot=(e,t,n)=>e<<32-n|t>>>n,pt=(e,t,n)=>e>>>n|t<<32-n,ut=(e,t,n)=>e<<32-n|t>>>n,yt=(e,t,n)=>e<<64-n|t>>>n-32,dt=(e,t,n)=>e>>>n-32|t<<64-n;function lt(e,t,n,a){const i=(t>>>0)+(a>>>0);return{h:e+n+(i/2**32|0)|0,l:0|i}}const ct=(e,t,n)=>(e>>>0)+(t>>>0)+(n>>>0),mt=(e,t,n,a)=>t+n+a+(e/2**32|0)|0,ft=(e,t,n,a)=>(e>>>0)+(t>>>0)+(n>>>0)+(a>>>0),bt=(e,t,n,a,i)=>t+n+a+i+(e/2**32|0)|0,ht=(e,t,n,a,i)=>(e>>>0)+(t>>>0)+(n>>>0)+(a>>>0)+(i>>>0),Tt=(e,t,n,a,i,r)=>t+n+a+i+r+(e/2**32|0)|0,gt=Uint32Array.from([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),wt=new Uint32Array(64);class vt extends Qe{constructor(e=32){super(64,e,8,!1),this.A=0|Je[0],this.B=0|Je[1],this.C=0|Je[2],this.D=0|Je[3],this.E=0|Je[4],this.F=0|Je[5],this.G=0|Je[6],this.H=0|Je[7]}get(){const{A:e,B:t,C:n,D:a,E:i,F:r,G:s,H:o}=this;return[e,t,n,a,i,r,s,o]}set(e,t,n,a,i,r,s,o){this.A=0|e,this.B=0|t,this.C=0|n,this.D=0|a,this.E=0|i,this.F=0|r,this.G=0|s,this.H=0|o}process(e,t){for(let n=0;n<16;n++,t+=4)wt[n]=e.getUint32(t,!1);for(let e=16;e<64;e++){const t=wt[e-15],n=wt[e-2],a=Ce(t,7)^Ce(t,18)^t>>>3,i=Ce(n,17)^Ce(n,19)^n>>>10;wt[e]=i+wt[e-7]+a+wt[e-16]|0}let{A:n,B:a,C:i,D:r,E:s,F:o,G:p,H:u}=this;for(let e=0;e<64;e++){const t=u+(Ce(s,6)^Ce(s,11)^Ce(s,25))+Xe(s,o,p)+gt[e]+wt[e]|0,y=(Ce(n,2)^Ce(n,13)^Ce(n,22))+Ye(n,a,i)|0;u=p,p=o,o=s,s=r+t|0,r=i,i=a,a=n,n=t+y|0}n=n+this.A|0,a=a+this.B|0,i=i+this.C|0,r=r+this.D|0,s=s+this.E|0,o=o+this.F|0,p=p+this.G|0,u=u+this.H|0,this.set(n,a,i,r,s,o,p,u)}roundClean(){Fe(wt)}destroy(){this.set(0,0,0,0,0,0,0,0),Fe(this.buffer)}}const xt=(()=>rt(["0x428a2f98d728ae22","0x7137449123ef65cd","0xb5c0fbcfec4d3b2f","0xe9b5dba58189dbbc","0x3956c25bf348b538","0x59f111f1b605d019","0x923f82a4af194f9b","0xab1c5ed5da6d8118","0xd807aa98a3030242","0x12835b0145706fbe","0x243185be4ee4b28c","0x550c7dc3d5ffb4e2","0x72be5d74f27b896f","0x80deb1fe3b1696b1","0x9bdc06a725c71235","0xc19bf174cf692694","0xe49b69c19ef14ad2","0xefbe4786384f25e3","0x0fc19dc68b8cd5b5","0x240ca1cc77ac9c65","0x2de92c6f592b0275","0x4a7484aa6ea6e483","0x5cb0a9dcbd41fbd4","0x76f988da831153b5","0x983e5152ee66dfab","0xa831c66d2db43210","0xb00327c898fb213f","0xbf597fc7beef0ee4","0xc6e00bf33da88fc2","0xd5a79147930aa725","0x06ca6351e003826f","0x142929670a0e6e70","0x27b70a8546d22ffc","0x2e1b21385c26c926","0x4d2c6dfc5ac42aed","0x53380d139d95b3df","0x650a73548baf63de","0x766a0abb3c77b2a8","0x81c2c92e47edaee6","0x92722c851482353b","0xa2bfe8a14cf10364","0xa81a664bbc423001","0xc24b8b70d0f89791","0xc76c51a30654be30","0xd192e819d6ef5218","0xd69906245565a910","0xf40e35855771202a","0x106aa07032bbd1b8","0x19a4c116b8d2d0c8","0x1e376c085141ab53","0x2748774cdf8eeb99","0x34b0bcb5e19b48a8","0x391c0cb3c5c95a63","0x4ed8aa4ae3418acb","0x5b9cca4f7763e373","0x682e6ff3d6b2b8a3","0x748f82ee5defb2fc","0x78a5636f43172f60","0x84c87814a1f0ab72","0x8cc702081a6439ec","0x90befffa23631e28","0xa4506cebde82bde9","0xbef9a3f7b2c67915","0xc67178f2e372532b","0xca273eceea26619c","0xd186b8c721c0c207","0xeada7dd6cde0eb1e","0xf57d4f7fee6ed178","0x06f067aa72176fba","0x0a637dc5a2c898a6","0x113f9804bef90dae","0x1b710b35131c471b","0x28db77f523047d84","0x32caab7b40c72493","0x3c9ebe0a15c9bebc","0x431d67c49c100d4c","0x4cc5d4becb3e42b6","0x597f299cfc657e2a","0x5fcb6fab3ad6faec","0x6c44198c4a475817"].map(e=>BigInt(e))))(),It=(()=>xt[0])(),Pt=(()=>xt[1])(),kt=new Uint32Array(80),Mt=new Uint32Array(80);class At extends Qe{constructor(e=64){super(128,e,16,!1),this.Ah=0|tt[0],this.Al=0|tt[1],this.Bh=0|tt[2],this.Bl=0|tt[3],this.Ch=0|tt[4],this.Cl=0|tt[5],this.Dh=0|tt[6],this.Dl=0|tt[7],this.Eh=0|tt[8],this.El=0|tt[9],this.Fh=0|tt[10],this.Fl=0|tt[11],this.Gh=0|tt[12],this.Gl=0|tt[13],this.Hh=0|tt[14],this.Hl=0|tt[15]}get(){const{Ah:e,Al:t,Bh:n,Bl:a,Ch:i,Cl:r,Dh:s,Dl:o,Eh:p,El:u,Fh:y,Fl:d,Gh:l,Gl:c,Hh:m,Hl:f}=this;return[e,t,n,a,i,r,s,o,p,u,y,d,l,c,m,f]}set(e,t,n,a,i,r,s,o,p,u,y,d,l,c,m,f){this.Ah=0|e,this.Al=0|t,this.Bh=0|n,this.Bl=0|a,this.Ch=0|i,this.Cl=0|r,this.Dh=0|s,this.Dl=0|o,this.Eh=0|p,this.El=0|u,this.Fh=0|y,this.Fl=0|d,this.Gh=0|l,this.Gl=0|c,this.Hh=0|m,this.Hl=0|f}process(e,t){for(let n=0;n<16;n++,t+=4)kt[n]=e.getUint32(t),Mt[n]=e.getUint32(t+=4);for(let e=16;e<80;e++){const t=0|kt[e-15],n=0|Mt[e-15],a=pt(t,n,1)^pt(t,n,8)^st(t,0,7),i=ut(t,n,1)^ut(t,n,8)^ot(t,n,7),r=0|kt[e-2],s=0|Mt[e-2],o=pt(r,s,19)^yt(r,s,61)^st(r,0,6),p=ut(r,s,19)^dt(r,s,61)^ot(r,s,6),u=ft(i,p,Mt[e-7],Mt[e-16]),y=bt(u,a,o,kt[e-7],kt[e-16]);kt[e]=0|y,Mt[e]=0|u}let{Ah:n,Al:a,Bh:i,Bl:r,Ch:s,Cl:o,Dh:p,Dl:u,Eh:y,El:d,Fh:l,Fl:c,Gh:m,Gl:f,Hh:b,Hl:h}=this;for(let e=0;e<80;e++){const t=pt(y,d,14)^pt(y,d,18)^yt(y,d,41),T=ut(y,d,14)^ut(y,d,18)^dt(y,d,41),g=y&l^~y&m,w=ht(h,T,d&c^~d&f,Pt[e],Mt[e]),v=Tt(w,b,t,g,It[e],kt[e]),x=0|w,I=pt(n,a,28)^yt(n,a,34)^yt(n,a,39),P=ut(n,a,28)^dt(n,a,34)^dt(n,a,39),k=n&i^n&s^i&s,M=a&r^a&o^r&o;b=0|m,h=0|f,m=0|l,f=0|c,l=0|y,c=0|d,({h:y,l:d}=lt(0|p,0|u,0|v,0|x)),p=0|s,u=0|o,s=0|i,o=0|r,i=0|n,r=0|a;const A=ct(x,P,M);n=mt(A,v,I,k),a=0|A}({h:n,l:a}=lt(0|this.Ah,0|this.Al,0|n,0|a)),({h:i,l:r}=lt(0|this.Bh,0|this.Bl,0|i,0|r)),({h:s,l:o}=lt(0|this.Ch,0|this.Cl,0|s,0|o)),({h:p,l:u}=lt(0|this.Dh,0|this.Dl,0|p,0|u)),({h:y,l:d}=lt(0|this.Eh,0|this.El,0|y,0|d)),({h:l,l:c}=lt(0|this.Fh,0|this.Fl,0|l,0|c)),({h:m,l:f}=lt(0|this.Gh,0|this.Gl,0|m,0|f)),({h:b,l:h}=lt(0|this.Hh,0|this.Hl,0|b,0|h)),this.set(n,a,i,r,s,o,p,u,y,d,l,c,m,f,b,h)}roundClean(){Fe(kt,Mt)}destroy(){Fe(this.buffer),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}}class Ft extends At{constructor(){super(48),this.Ah=0|et[0],this.Al=0|et[1],this.Bh=0|et[2],this.Bl=0|et[3],this.Ch=0|et[4],this.Cl=0|et[5],this.Dh=0|et[6],this.Dl=0|et[7],this.Eh=0|et[8],this.El=0|et[9],this.Fh=0|et[10],this.Fl=0|et[11],this.Gh=0|et[12],this.Gl=0|et[13],this.Hh=0|et[14],this.Hl=0|et[15]}}const _t=je(()=>new vt),Ct=je(()=>new At),St=je(()=>new Ft),Et=_t;function Bt(e){const{commitment:t,version:n=1}=e,a=e.to??("string"==typeof t?"hex":"bytes"),i=function(e,t){const n=t||"hex",a=Et(b(e,{strict:!1})?E(e):e);return"bytes"===n?a:k(a)}(t,"bytes");return i.set([n],0),"bytes"===a?i:A(i)}function Ot(e){const{commitments:t,version:n}=e,a=e.to??("string"==typeof t[0]?"hex":"bytes"),i=[];for(const e of t)i.push(Bt({commitment:e,to:a,version:n}));return i}const Dt=4096,Ut=131072,Rt=761855;class Nt extends d{constructor({maxSize:e,size:t}){super("Blob size is too large.",{metaMessages:[`Max: ${e} bytes`,`Given: ${t} bytes`],name:"BlobSizeTooLargeError"})}}class Lt extends d{constructor(){super("Blob data must not be empty.",{name:"EmptyBlobError"})}}class zt extends d{constructor({hash:e,size:t}){super(`Versioned hash "${e}" size is invalid.`,{metaMessages:["Expected: 32",`Received: ${t}`],name:"InvalidVersionedHashSizeError"})}}class $t extends d{constructor({hash:e,version:t}){super(`Versioned hash "${e}" version is invalid.`,{metaMessages:["Expected: 1",`Received: ${t}`],name:"InvalidVersionedHashVersionError"})}}function Ht(e){const{data:t,kzg:n,to:a}=e,i=e.blobs??function(e){const t=e.to??("string"==typeof e.data?"hex":"bytes"),n="string"==typeof e.data?D(e.data):e.data,a=h(n);if(!a)throw new Lt;if(a>Rt)throw new Nt({maxSize:Rt,size:a});const i=[];let r=!0,s=0;for(;r;){const e=re(new Uint8Array(Ut));let t=0;for(;t<Dt;){const a=n.slice(s,s+31);if(e.pushByte(0),e.pushBytes(a),a.length<31){e.pushByte(128),r=!1;break}t++,s+=31}i.push(e)}return"bytes"===t?i.map(e=>e.bytes):i.map(e=>A(e.bytes))}({data:t,to:a}),r=e.commitments??ge({blobs:i,kzg:n,to:a}),s=e.proofs??we({blobs:i,commitments:r,kzg:n,to:a}),o=[];for(let e=0;e<i.length;e++)o.push({blob:i[e],commitment:r[e],proof:s[e]});return o}class qt extends d{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"})}}class Vt extends d{constructor({blockNumber:e,chain:t,contract:n}){super(`Chain "${t.name}" does not support contract "${n.name}".`,{metaMessages:["This could be due to any of the following:",...e&&n.blockCreated&&n.blockCreated>e?[`- The contract "${n.name}" was not deployed until block ${n.blockCreated} (current block ${e}).`]:[`- The chain does not have the contract "${n.name}" configured.`]],name:"ChainDoesNotSupportContract"})}}class Kt extends d{constructor({chain:e,currentChainId:t}){super(`The current chain of the wallet (id: ${t}) does not match the target chain for the transaction (id: ${e.id} – ${e.name}).`,{metaMessages:[`Current Chain ID: ${t}`,`Expected Chain ID: ${e.id} – ${e.name}`],name:"ChainMismatchError"})}}class Gt extends d{constructor(){super(["No chain was provided to the request.","Please provide a chain with the `chain` argument on the Action, or by supplying a `chain` to WalletClient."].join("\n"),{name:"ChainNotFoundError"})}}class Wt extends d{constructor(){super("No chain was provided to the Client.",{name:"ClientChainNotConfiguredError"})}}class jt extends d{constructor({chainId:e}){super("number"==typeof e?`Chain ID "${e}" is invalid.`:"Chain ID is invalid.",{name:"InvalidChainIdError"})}}class Zt extends d{constructor({cause:e,message:t}={}){const n=t?.replace("execution reverted: ","")?.replace("execution reverted","");super(`Execution reverted ${n?`with reason: ${n}`:"for an unknown reason"}.`,{cause:e,name:"ExecutionRevertedError"})}}Object.defineProperty(Zt,"code",{enumerable:!0,configurable:!0,writable:!0,value:3}),Object.defineProperty(Zt,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/execution reverted|gas required exceeds allowance/});class Xt extends d{constructor({cause:e,maxFeePerGas:t}={}){super(`The fee cap (\`maxFeePerGas\`${t?` = ${ce(t)} gwei`:""}) cannot be higher than the maximum allowed value (2^256-1).`,{cause:e,name:"FeeCapTooHighError"})}}Object.defineProperty(Xt,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/max fee per gas higher than 2\^256-1|fee cap higher than 2\^256-1/});class Yt extends d{constructor({cause:e,maxFeePerGas:t}={}){super(`The fee cap (\`maxFeePerGas\`${t?` = ${ce(t)}`:""} gwei) cannot be lower than the block base fee.`,{cause:e,name:"FeeCapTooLowError"})}}Object.defineProperty(Yt,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/max fee per gas less than block base fee|fee cap less than block base fee|transaction is outdated/});class Qt extends d{constructor({cause:e,nonce:t}={}){super(`Nonce provided for the transaction ${t?`(${t}) `:""}is higher than the next one expected.`,{cause:e,name:"NonceTooHighError"})}}Object.defineProperty(Qt,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/nonce too high/});class Jt extends d{constructor({cause:e,nonce:t}={}){super([`Nonce provided for the transaction ${t?`(${t}) `:""}is lower than the current nonce of the account.`,"Try increasing the nonce or find the latest nonce with `getTransactionCount`."].join("\n"),{cause:e,name:"NonceTooLowError"})}}Object.defineProperty(Jt,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/nonce too low|transaction already imported|already known/});class en extends d{constructor({cause:e,nonce:t}={}){super(`Nonce provided for the transaction ${t?`(${t}) `:""}exceeds the maximum allowed nonce.`,{cause:e,name:"NonceMaxValueError"})}}Object.defineProperty(en,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/nonce has max value/});class tn extends d{constructor({cause:e}={}){super(["The total cost (gas * gas fee + value) of executing this transaction exceeds the balance of the account."].join("\n"),{cause:e,metaMessages:["This error could arise when the account does not have enough funds to:"," - pay for the total gas fee,"," - pay for the value to send."," ","The cost of the transaction is calculated as `gas * gas fee + value`, where:"," - `gas` is the amount of gas needed for transaction to execute,"," - `gas fee` is the gas fee,"," - `value` is the amount of ether to send to the recipient."],name:"InsufficientFundsError"})}}Object.defineProperty(tn,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/insufficient funds|exceeds transaction sender account balance/});class nn extends d{constructor({cause:e,gas:t}={}){super(`The amount of gas ${t?`(${t}) `:""}provided for the transaction exceeds the limit allowed for the block.`,{cause:e,name:"IntrinsicGasTooHighError"})}}Object.defineProperty(nn,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/intrinsic gas too high|gas limit reached/});class an extends d{constructor({cause:e,gas:t}={}){super(`The amount of gas ${t?`(${t}) `:""}provided for the transaction is too low.`,{cause:e,name:"IntrinsicGasTooLowError"})}}Object.defineProperty(an,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/intrinsic gas too low/});class rn extends d{constructor({cause:e}){super("The transaction type is not supported for this chain.",{cause:e,name:"TransactionTypeNotSupportedError"})}}Object.defineProperty(rn,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/transaction type not valid/});class sn extends d{constructor({cause:e,maxPriorityFeePerGas:t,maxFeePerGas:n}={}){super([`The provided tip (\`maxPriorityFeePerGas\`${t?` = ${ce(t)} gwei`:""}) cannot be higher than the fee cap (\`maxFeePerGas\`${n?` = ${ce(n)} gwei`:""}).`].join("\n"),{cause:e,name:"TipAboveFeeCapError"})}}Object.defineProperty(sn,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/max priority fee per gas higher than max fee per gas|tip higher than fee cap/});class on extends d{constructor({cause:e}){super(`An error occurred while executing: ${e?.shortMessage}`,{cause:e,name:"UnknownNodeError"})}}class pn 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)&&(super.delete(e),super.set(e,t)),t}set(e,t){if(super.has(e)&&super.delete(e),super.set(e,t),this.maxSize&&this.size>this.maxSize){const e=super.keys().next().value;void 0!==e&&super.delete(e)}return this}}const un=BigInt(0),yn=BigInt(1),dn=BigInt(2),ln=BigInt(7),cn=BigInt(256),mn=BigInt(113),fn=[],bn=[],hn=[];for(let e=0,t=yn,n=1,a=0;e<24;e++){[n,a]=[a,(2*n+3*a)%5],fn.push(2*(5*a+n)),bn.push((e+1)*(e+2)/2%64);let i=un;for(let e=0;e<7;e++)t=(t<<yn^(t>>ln)*mn)%cn,t&dn&&(i^=yn<<(yn<<BigInt(e))-yn);hn.push(i)}const Tn=rt(hn,!0),gn=Tn[0],wn=Tn[1],vn=(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),xn=(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 In extends We{constructor(e,t,n,a=!1,i=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=a,this.rounds=i,Ie(n),!(0<e&&e<200))throw new Error("only keccak-f1600 function is supported");var r;this.state=new Uint8Array(200),this.state32=(r=this.state,new Uint32Array(r.buffer,r.byteOffset,Math.floor(r.byteLength/4)))}clone(){return this._cloneInto()}keccak(){Ee(this.state32),function(e,t=24){const n=new Uint32Array(10);for(let a=24-t;a<24;a++){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 a=(t+8)%10,i=(t+2)%10,r=n[i],s=n[i+1],o=vn(r,s,1)^n[a],p=xn(r,s,1)^n[a+1];for(let n=0;n<50;n+=10)e[t+n]^=o,e[t+n+1]^=p}let t=e[2],i=e[3];for(let n=0;n<24;n++){const a=bn[n],r=vn(t,i,a),s=xn(t,i,a),o=fn[n];t=e[o],i=e[o+1],e[o]=r,e[o+1]=s}for(let t=0;t<50;t+=10){for(let a=0;a<10;a++)n[a]=e[t+a];for(let a=0;a<10;a++)e[t+a]^=~n[(a+2)%10]&n[(a+4)%10]}e[0]^=gn[a],e[1]^=wn[a]}Fe(n)}(this.state32,this.rounds),Ee(this.state32),this.posOut=0,this.pos=0}update(e){Me(this),Pe(e=Ke(e));const{blockLen:t,state:n}=this,a=e.length;for(let i=0;i<a;){const r=Math.min(t-this.pos,a-i);for(let t=0;t<r;t++)n[this.pos++]^=e[i++];this.pos===t&&this.keccak()}return this}finish(){if(this.finished)return;this.finished=!0;const{state:e,suffix:t,pos:n,blockLen:a}=this;e[n]^=t,128&t&&n===a-1&&this.keccak(),e[a-1]^=128,this.keccak()}writeInto(e){Me(this,!1),Pe(e),this.finish();const t=this.state,{blockLen:n}=this;for(let a=0,i=e.length;a<i;){this.posOut>=n&&this.keccak();const r=Math.min(n-this.posOut,i-a);e.set(t.subarray(this.posOut,this.posOut+r),a),this.posOut+=r,a+=r}return e}xofInto(e){if(!this.enableXOF)throw new Error("XOF is not possible for this instance");return this.writeInto(e)}xof(e){return Ie(e),this.xofInto(new Uint8Array(e))}digestInto(e){if(Ae(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,Fe(this.state)}_cloneInto(e){const{blockLen:t,suffix:n,outputLen:a,rounds:i,enableXOF:r}=this;return e||(e=new In(t,n,a,r,i)),e.state32.set(this.state32),e.pos=this.pos,e.posOut=this.posOut,e.finished=this.finished,e.rounds=i,e.suffix=n,e.outputLen=a,e.enableXOF=r,e.destroyed=this.destroyed,e}}const Pn=(()=>{return e=1,t=136,n=32,je(()=>new In(t,e,n));var e,t,n})();function kn(e,t){const n=t||"hex",a=Pn(b(e,{strict:!1})?E(e):e);return"bytes"===n?a:k(a)}const Mn=new pn(8192);function An(e,t){if(Mn.has(`${e}.${t}`))return Mn.get(`${e}.${t}`);const n=t?`${t}${e.toLowerCase()}`:e.substring(2).toLowerCase(),a=kn(U(n),"bytes"),i=(t?n.substring(`${t}0x`.length):n).split("");for(let e=0;e<40;e+=2)a[e>>1]>>4>=8&&i[e]&&(i[e]=i[e].toUpperCase()),(15&a[e>>1])>=8&&i[e+1]&&(i[e+1]=i[e+1].toUpperCase());const r=`0x${i.join("")}`;return Mn.set(`${e}.${t}`,r),r}const Fn=/^0x[a-fA-F0-9]{40}$/,_n=new pn(8192);function Cn(e,t){const{strict:n=!0}=t??{},a=`${e}.${n}`;if(_n.has(a))return _n.get(a);const i=!(!Fn.test(e)||e.toLowerCase()!==e&&n&&An(e)!==e);return _n.set(a,i),i}function Sn(e,t,n,{strict:a}={}){return b(e,{strict:!1})?function(e,t,n,{strict:a}={}){En(e,t);const i=`0x${e.replace("0x","").slice(2*(t??0),2*(n??e.length))}`;a&&Bn(i,t,n);return i}(e,t,n,{strict:a}):On(e,t,n,{strict:a})}function En(e,t){if("number"==typeof t&&t>0&&t>h(e)-1)throw new g({offset:t,position:"start",size:h(e)})}function Bn(e,t,n){if("number"==typeof t&&"number"==typeof n&&h(e)!==n-t)throw new g({offset:n,position:"end",size:h(e)})}function On(e,t,n,{strict:a}={}){En(e,t);const i=e.slice(t,n);return a&&Bn(i,t,n),i}function Dn(e){const{chainId:t,maxPriorityFeePerGas:n,maxFeePerGas:a,to:i}=e;if(t<=0)throw new jt({chainId:t});if(i&&!Cn(i))throw new qt({address:i});if(a&&a>Q)throw new Xt({maxFeePerGas:a});if(n&&a&&n>a)throw new sn({maxFeePerGas:a,maxPriorityFeePerGas:n})}function Un(e){if(e.type)return e.type;if(void 0!==e.authorizationList)return"eip7702";if(void 0!==e.blobs||void 0!==e.blobVersionedHashes||void 0!==e.maxFeePerBlobGas||void 0!==e.sidecars)return"eip4844";if(void 0!==e.maxFeePerGas||void 0!==e.maxPriorityFeePerGas)return"eip1559";if(void 0!==e.gasPrice)return void 0!==e.accessList?"eip2930":"legacy";throw new be({transaction:e})}function Rn(e){if(!e||0===e.length)return[];const t=[];for(let n=0;n<e.length;n++){const{address:a,storageKeys:i}=e[n];for(let e=0;e<i.length;e++)if(i[e].length-2!=64)throw new he({storageKey:i[e]});if(!Cn(a,{strict:!1}))throw new qt({address:a});t.push([a,i])}return t}function Nn(e,t){const n=Un(e);return"eip1559"===n?function(e,t){const{chainId:n,gas:a,nonce:i,to:r,value:s,maxFeePerGas:o,maxPriorityFeePerGas:p,accessList:u,data:y}=e;Dn(e);const d=Rn(u),l=[F(n),i?F(i):"0x",p?F(p):"0x",o?F(o):"0x",a?F(a):"0x",r??"0x",s?F(s):"0x",y??"0x",d,...Ln(e,t)];return ee(["0x02",se(l)])}(e,t):"eip2930"===n?function(e,t){const{chainId:n,gas:a,data:i,nonce:r,to:s,value:o,accessList:p,gasPrice:u}=e;!function(e){const{chainId:t,maxPriorityFeePerGas:n,gasPrice:a,maxFeePerGas:i,to:r}=e;if(t<=0)throw new jt({chainId:t});if(r&&!Cn(r))throw new qt({address:r});if(n||i)throw new d("`maxFeePerGas`/`maxPriorityFeePerGas` is not a valid EIP-2930 Transaction attribute.");if(a&&a>Q)throw new Xt({maxFeePerGas:a})}(e);const y=Rn(p),l=[F(n),r?F(r):"0x",u?F(u):"0x",a?F(a):"0x",s??"0x",o?F(o):"0x",i??"0x",y,...Ln(e,t)];return ee(["0x01",se(l)])}(e,t):"eip4844"===n?function(e,t){const{chainId:n,gas:a,nonce:i,to:r,value:s,maxFeePerBlobGas:o,maxFeePerGas:p,maxPriorityFeePerGas:u,accessList:y,data:d}=e;!function(e){const{blobVersionedHashes:t}=e;if(t){if(0===t.length)throw new Lt;for(const e of t){const t=h(e),n=L(Sn(e,0,1));if(32!==t)throw new zt({hash:e,size:t});if(1!==n)throw new $t({hash:e,version:n})}}Dn(e)}(e);let l=e.blobVersionedHashes,c=e.sidecars;if(e.blobs&&(void 0===l||void 0===c)){const t="string"==typeof e.blobs[0]?e.blobs:e.blobs.map(e=>A(e)),n=e.kzg,a=ge({blobs:t,kzg:n});if(void 0===l&&(l=Ot({commitments:a})),void 0===c){c=Ht({blobs:t,commitments:a,proofs:we({blobs:t,commitments:a,kzg:n})})}}const m=Rn(y),f=[F(n),i?F(i):"0x",u?F(u):"0x",p?F(p):"0x",a?F(a):"0x",r??"0x",s?F(s):"0x",d??"0x",m,o?F(o):"0x",l??[],...Ln(e,t)],b=[],T=[],g=[];if(c)for(let e=0;e<c.length;e++){const{blob:t,commitment:n,proof:a}=c[e];b.push(t),T.push(n),g.push(a)}return ee(["0x03",se(c?[f,b,T,g]:f)])}(e,t):"eip7702"===n?function(e,t){const{authorizationList:n,chainId:a,gas:i,nonce:r,to:s,value:o,maxFeePerGas:p,maxPriorityFeePerGas:u,accessList:y,data:d}=e;!function(e){const{authorizationList:t}=e;if(t)for(const e of t){const{chainId:t}=e,n=e.address;if(!Cn(n))throw new qt({address:n});if(t<0)throw new jt({chainId:t})}Dn(e)}(e);const l=Rn(y),c=function(e){if(!e||0===e.length)return[];const t=[];for(const n of e){const{chainId:e,nonce:a,...i}=n,r=n.address;t.push([e?k(e):"0x",r,a?k(a):"0x",...Ln({},i)])}return t}(n);return ee(["0x04",se([F(a),r?F(r):"0x",u?F(u):"0x",p?F(p):"0x",i?F(i):"0x",s??"0x",o?F(o):"0x",d??"0x",l,c,...Ln(e,t)])])}(e,t):function(e,t){const{chainId:n=0,gas:a,data:i,nonce:r,to:s,value:o,gasPrice:p}=e;!function(e){const{chainId:t,maxPriorityFeePerGas:n,gasPrice:a,maxFeePerGas:i,to:r}=e;if(r&&!Cn(r))throw new qt({address:r});if(void 0!==t&&t<=0)throw new jt({chainId:t});if(n||i)throw new d("`maxFeePerGas`/`maxPriorityFeePerGas` is not a valid Legacy Transaction attribute.");if(a&&a>Q)throw new Xt({maxFeePerGas:a})}(e);let u=[r?F(r):"0x",p?F(p):"0x",a?F(a):"0x",s??"0x",o?F(o):"0x",i??"0x"];if(t){const e=(()=>{if(t.v>=35n){return(t.v-35n)/2n>0?t.v:27n+(35n===t.v?0n:1n)}if(n>0)return BigInt(2*n)+BigInt(35n+t.v-27n);const e=27n+(27n===t.v?0n:1n);if(t.v!==e)throw new fe({v:t.v});return e})(),a=T(t.r),i=T(t.s);u=[...u,F(e),"0x00"===a?"0x":a,"0x00"===i?"0x":i]}else n>0&&(u=[...u,F(n),"0x","0x"]);return se(u)}(e,t)}function Ln(e,t){const n=t??e,{v:a,yParity:i}=n;if(void 0===n.r)return[];if(void 0===n.s)return[];if(void 0===a&&void 0===i)return[];const r=T(n.r),s=T(n.s);return["number"==typeof i?i?F(1):"0x":0n===a?"0x":1n===a?F(1):27n===a?"0x":F(1),"0x00"===r?"0x":r,"0x00"===s?"0x":s]}const zn={gasPriceOracle:{address:"0x420000000000000000000000000000000000000F"},l1Block:{address:"0x4200000000000000000000000000000000000015"},l2CrossDomainMessenger:{address:"0x4200000000000000000000000000000000000007"},l2Erc721Bridge:{address:"0x4200000000000000000000000000000000000014"},l2StandardBridge:{address:"0x4200000000000000000000000000000000000010"},l2ToL1MessagePasser:{address:"0x4200000000000000000000000000000000000016"}};function $n(e,t){return function(e){return"deposit"===e.type||void 0!==e.sourceHash}(e)?function(e){!function(e){const{from:t,to:n}=e;if(t&&!Cn(t))throw new qt({address:t});if(n&&!Cn(n))throw new qt({address:n})}(e);const{sourceHash:t,data:n,from:a,gas:i,isSystemTx:r,mint:s,to:o,value:p}=e,u=[t,a,o??"0x",s?k(s):"0x",p?k(p):"0x",i?k(i):"0x",r?"0x1":"0x",n??"0x"];return ee(["0x7e",se(u)])}(e):Nn(e,t)}const Hn={blockTime:2e3,contracts:zn,formatters:{block:K({format(e){const t=e.transactions?.map(e=>{if("string"==typeof e)return e;const t=H(e);return"0x7e"===t.typeHex&&(t.isSystemTx=e.isSystemTx,t.mint=e.mint?N(e.mint):void 0,t.sourceHash=e.sourceHash,t.type="deposit"),t});return{transactions:t,stateRoot:e.stateRoot}}}),transaction:q({format(e){const t={};return"0x7e"===e.type&&(t.isSystemTx=e.isSystemTx,t.mint=e.mint?N(e.mint):void 0,t.sourceHash=e.sourceHash,t.type="deposit"),t}}),transactionReceipt:Z({format:e=>({...e.depositNonce?{depositNonce:N(e.depositNonce)}:{},...e.depositReceiptVersion?{depositReceiptVersion:L(e.depositReceiptVersion)}:{},l1GasPrice:e.l1GasPrice?N(e.l1GasPrice):null,l1GasUsed:e.l1GasUsed?N(e.l1GasUsed):null,l1Fee:e.l1Fee?N(e.l1Fee):null,l1FeeScalar:e.l1FeeScalar?Number(e.l1FeeScalar):null})})},serializers