UNPKG

dev3-sdk

Version:

SDK for interacting with the 0xDev3 platform.

5 lines (4 loc) 411 kB
import { PriceFeedsETH, PriceFeedsAVAX, PriceFeedsBSC, PolycodeChainlinkSDK } from 'polycode-chainlink-feeds'; export { default as DkgClient } from 'dkg.js'; import o0, { AxiosError } from 'axios'; var Td=Object.defineProperty,km=Object.defineProperties;var Pm=Object.getOwnPropertyDescriptors;var Id=Object.getOwnPropertySymbols,vm=Object.getPrototypeOf,Sm=Object.prototype.hasOwnProperty,Nm=Object.prototype.propertyIsEnumerable,Im=Reflect.get;var i0=(n,e,t)=>e in n?Td(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t,Lo=(n,e)=>{for(var t in e||(e={}))Sm.call(e,t)&&i0(n,t,e[t]);if(Id)for(var t of Id(e))Nm.call(e,t)&&i0(n,t,e[t]);return n},Mo=(n,e)=>km(n,Pm(e));var Bd=(n,e)=>{for(var t in e)Td(n,t,{get:e[t],enumerable:!0});};var g=(n,e,t)=>(i0(n,typeof e!="symbol"?e+"":e,t),t),a0=(n,e,t)=>{if(!e.has(n))throw TypeError("Cannot "+t)};var u=(n,e,t)=>(a0(n,e,"read from private field"),t?t.call(n):e.get(n)),b=(n,e,t)=>{if(e.has(n))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(n):e.set(n,t);},p=(n,e,t,r)=>(a0(n,e,"write to private field"),r?r.call(n,t):e.set(n,t),t),Yr=(n,e,t,r)=>({set _(s){p(n,e,s,t);},get _(){return u(n,e,r)}}),k=(n,e,t)=>(a0(n,e,"access private method"),t),ve=(n,e,t)=>Im(vm(n),t,e);var l=(n,e,t)=>new Promise((r,s)=>{var i=c=>{try{o(t.next(c));}catch(f){s(f);}},a=c=>{try{o(t.throw(c));}catch(f){s(f);}},o=c=>c.done?r(c.value):Promise.resolve(c.value).then(i,a);o((t=t.apply(n,e)).next());});var yu=class extends Error{constructor(e,t){super(`${e}: ${t}`);}},Ce=class extends Error{constructor(e){super(e);}};var wu=class{constructor(e,t,r,s){this._initializeResponseInterceptor=()=>{this.instance.interceptors.response.use(this._handleResponse,this._handleError),this.protectedInstance.interceptors.response.use(this._handleResponse,this._handleError),this.identityServiceInstance.interceptors.response.use(this._handleResponse,this._handleError);};this._handleResponse=({data:e})=>e;this._handleError=e=>{var t,r,s,i;if(e instanceof AxiosError){let a=(r=(t=e.response)==null?void 0:t.data)==null?void 0:r.error_code,o=(i=(s=e.response)==null?void 0:s.data)==null?void 0:i.message;if(a!==void 0&&o!==void 0)return Promise.reject(new yu(a,o))}return Promise.reject(e)};this.instance=o0.create({baseURL:e}),this.protectedInstance=o0.create({baseURL:e,headers:{"X-API-KEY":r}}),this.identityServiceInstance=o0.create({baseURL:t}),this.projectId=s,this.apiKey=r,this._initializeResponseInterceptor();}};var B=class extends wu{constructor(e,t,r,s){super(e,t,r,s);}static init(e,t,r,s){this.classInstance||(this.classInstance=new B(e,t,r,s));}static instance(){if(this.classInstance===void 0)throw new Ce("API module not initialized.");return this.classInstance}createWalletAuthorizationRequest(e){return l(this,null,function*(){return yield this.protectedInstance.post("wallet-authorization",e)})}fetchProject(){return l(this,null,function*(){return yield this.protectedInstance.get("projects/by-api-key")})}fetchWalletAuthorizationRequestById(e){return l(this,null,function*(){return yield this.instance.get(`wallet-authorization/${e}`)})}fetchWalletAuthorizationRequests(){return l(this,null,function*(){return yield this.instance.get(`wallet-authorization/by-project/${this.projectId}`)})}createContractDeploymentRequest(e){return l(this,null,function*(){return yield this.protectedInstance.post("deploy",e)})}fetchContractDeploymentRequestById(e){return l(this,null,function*(){return yield this.instance.get(`deploy/${e}`)})}fetchContractDeploymentRequestByAlias(e){return l(this,null,function*(){return yield this.instance.get(`deploy/by-project/${this.projectId}/by-alias/${e}`)})}fetchContractDeploymentRequests(e,t,r,s){return l(this,null,function*(){return yield this.protectedInstance.get(`deploy/by-project/${this.projectId}`,{params:{contractIds:e.join(","),contracTags:r.join(","),contractImplements:s.join(","),deployedOnly:t}})})}deleteContractDeploymentRequestById(e){return l(this,null,function*(){return this.protectedInstance.delete(`deploy/${e}`)})}createFunctionCallRequest(e){return l(this,null,function*(){return yield this.protectedInstance.post("function-call",e)})}fetchFunctionCallRequestById(e){return l(this,null,function*(){return yield this.instance.get(`function-call/${e}`)})}fetchFunctionCallRequests(e,t){return l(this,null,function*(){let r=new Map;return e&&r.set("deployedContractId",e),t&&r.set("contractAddress",t),(yield this.instance.get(`function-call/by-project/${this.projectId}`,{params:r})).requests})}readContract(e){return l(this,null,function*(){return yield this.protectedInstance.post("readonly-function-call",e)})}attachTxHashForFunctionCall(e){return l(this,null,function*(){return yield this.instance.put(`function-call/${e.action_id}`,{tx_hash:e.tx_hash,caller_address:e.caller_address})})}fetchDeployableContracts(e){return l(this,null,function*(){return yield this.instance.get("deployable-contracts",{params:{tags:e.tags.join(","),implements:e.implements.join(","),projectId:this.projectId}})})}fetchDeployableContractById(e){return l(this,null,function*(){return yield this.instance.get(`deployable-contracts/${e}`)})}getPayload(e){return l(this,null,function*(){let t=e==null?void 0:e.address;return t?this.identityServiceInstance.post("authorize",{address:t}):this.identityServiceInstance.post("authorize/by-message")})}getJwt(e){return l(this,null,function*(){return this.identityServiceInstance.post("authorize/jwt",e)})}getJwtByMessage(e){return l(this,null,function*(){return this.identityServiceInstance.post("authorize/jwt/by-message",e)})}createAddressBookEntry(e,t){return l(this,null,function*(){return this.instance.post("address-book",e,{headers:{Authorization:`Bearer ${t.access_token}`}})})}updateAddressBookEntry(e,t){return l(this,null,function*(){return this.instance.patch(`address-book/${e.id}`,{alias:e.alias,address:e.address,phone_number:e.phone_number,email:e.email},{headers:{Authorization:`Bearer ${t.access_token}`}})})}deleteAddressBookEntry(e,t){return l(this,null,function*(){return this.instance.delete(`address-book/${e.id}`,{headers:{Authorization:`Bearer ${t.access_token}`}})})}fetchAddressBookEntryByAlias(e,t){return l(this,null,function*(){return this.instance.get(`address-book/by-alias/${e.alias}`,{headers:{Authorization:`Bearer ${t.access_token}`}})})}fetchAddressBookEntries(e,t){return l(this,null,function*(){return this.instance.get(`address-book/by-wallet-address/${e}`,{headers:{Authorization:`Bearer ${t.access_token}`}})})}createAssetSendRequest(e){return l(this,null,function*(){return this.protectedInstance.post("send",e)})}fetchAssetSendRequest(e){return l(this,null,function*(){return this.instance.get(`send/${e}`)})}fetchAllAssetSendRequests(){return l(this,null,function*(){return this.instance.get(`send/by-project/${this.projectId}`)})}fetchAssetSendRequestsBySender(e){return l(this,null,function*(){return this.instance.get(`send/by-sender/${e}`)})}fetchAssetSendRequestsByRecipient(e){return l(this,null,function*(){return this.instance.get(`send/by-recipient/${e}`)})}createContractArbitraryCallRequest(e){return l(this,null,function*(){return yield this.protectedInstance.post("arbitrary-call",e)})}estimateArbitraryCallGasCost(e){return l(this,null,function*(){return yield this.protectedInstance.post("gas/estimate/arbitrary-call",e)})}getGasPrice(){return l(this,null,function*(){return yield this.protectedInstance.get("gas/price")})}fetchContractArbitraryCallRequestById(e){return l(this,null,function*(){return yield this.instance.get(`arbitrary-call/${e}`)})}fetchContractArbitraryCallRequests(e,t){return l(this,null,function*(){let r=new Map;return e&&r.set("deployedContractId",e),t&&r.set("contractAddress",t),(yield this.instance.get(`arbitrary-call/by-project/${this.projectId}`,{params:r})).requests})}};var Ds=class{constructor(){this.deployableContracts=new Map;}static instance(){return this.classInstance||(this.classInstance=new Ds),this.classInstance}getManifest(e){return l(this,null,function*(){yield this.lazyInit();let t=this.deployableContracts.get(e);if(!t)throw new Ce(`DeployableContractsService:: Fatal error. No contract found with id ${e}`);return t})}lazyInit(){return l(this,null,function*(){if(this.deployableContracts.size===0){let e=yield B.instance().fetchDeployableContracts({tags:[],implements:[]});this.deployableContracts=e.deployable_contracts.reduce((t,r)=>(t.set(r.id,r),t),this.deployableContracts);}})}};var pt=class{static instance(){return pt._instance||(pt._instance=new pt),pt._instance}encodeConstructorInputs(e,t){if(e.length===0)return [];let s=this.getConstructorDecoratorFromManifest(t,e.length).inputs;return this.encodeInputsImpl(e,s)}encodeInputs(e,t,r){if(t.length===0)return [];let i=this.getFunctionDecoratorFromManifest(e,r).inputs;return this.encodeInputsImpl(t,i)}encodeOutputTypes(e,t){let s=this.getFunctionDecoratorFromManifest(e,t).outputs;return this.encodeOutputTypesImpl(s)}encodeInputsImpl(e,t){return t?t.map((r,s)=>{let i=r.solidity_type,a=this.encodeInputValue(e[s],r,i);return {type:i,value:a}}):[]}encodeOutputTypesImpl(e){return e?e.map(t=>{if(t.solidity_type.startsWith("tuple")){let r=this.encodeOutputTypesImpl(t.parameters);return {type:t.solidity_type,elems:r}}else return t.solidity_type}):[]}encodeInputValue(e,t,r){if(r.endsWith("]")){let s=r.substring(0,r.lastIndexOf("["));return (e!=null?e:[]).map(i=>this.encodeInputValue(i,t,s))}else if(r.startsWith("tuple")){let s=t.parameters;if(!s)throw new Ce(`Expected tuple definition but nothing found for decorator ${t.name} and function ${t.solidity_name}`);return (e!=null?e:[]).map((i,a)=>({type:s[a].solidity_type,value:this.encodeInputValue(i,s[a],s[a].solidity_type)}))}else {if(r==="bool")return !!e;if(r.startsWith("bytes"))return (e!=null?e:[]).map(s=>String(s));if(r.startsWith("uint")||r.startsWith("int")||r.startsWith("byte")||r.startsWith("address")||r.startsWith("string"))return String(e);throw new Ce(`Could not parse solidity type: ${r} for function ${t.name}`)}}getConstructorDecoratorFromManifest(e,t){let r=e.constructors.find(s=>s.inputs.length===t);if(!r)throw new Ce(`Can't deploy contract. Constructor with ${t} param(s) not found in contract descriptor.`);return r}getFunctionDecoratorFromManifest(e,t){let r=t.functions.find(s=>s.solidity_name===e);if(!r)throw new Ce(`Can't call execute on a contract . Function ${e} not found in contract descriptor.`);return r}};var Zr=class{constructor(e){this.defaultCaller="0x0000000000000000000000000000000000000000";this.defaultEthAmount="0";this.deploymentRequest=e;}buildAction(e,t,r){return l(this,null,function*(){var o;let s=yield Ds.instance().getManifest(this.deploymentRequest.contract_id),i=pt.instance().encodeInputs(e,t,s),a=yield B.instance().createFunctionCallRequest({deployed_contract_id:this.deploymentRequest.id,function_name:e,function_params:i,eth_amount:(o=r==null?void 0:r.ethAmount)!=null?o:this.defaultEthAmount,arbitrary_data:r==null?void 0:r.arbitraryData,screen_config:r==null?void 0:r.screenConfig,caller_address:r==null?void 0:r.callerAddress,redirect_url:r==null?void 0:r.redirectUrl});return new xt(a)})}read(e,t){return l(this,null,function*(){if(this.deploymentRequest.status!=="SUCCESS")return Promise.reject(new Ce(`Can't read state on a contract with deployment status: ${this.deploymentRequest.status}`));let r=yield Ds.instance().getManifest(this.deploymentRequest.contract_id),s=pt.instance().encodeInputs(e,t,r),i=pt.instance().encodeOutputTypes(e,r);return yield B.instance().readContract({deployed_contract_id:this.deploymentRequest.id,function_name:e,function_params:s,output_params:i,caller_address:this.defaultCaller})})}};var ue={};Bd(ue,{AbiCoder:()=>Mt,AbstractProvider:()=>Kt,AbstractSigner:()=>jt,AlchemyProvider:()=>Cr,AnkrProvider:()=>Mr,BaseContract:()=>Rn,BaseWallet:()=>Fn,Block:()=>fi,BrowserProvider:()=>su,CloudflareProvider:()=>Si,ConstructorFragment:()=>rt,Contract:()=>lt,ContractEventPayload:()=>di,ContractFactory:()=>xi,ContractTransactionReceipt:()=>Qa,ContractTransactionResponse:()=>En,ContractUnknownEventPayload:()=>as,EnsPlugin:()=>Ur,EnsResolver:()=>kn,ErrorDescription:()=>Ja,ErrorFragment:()=>Re,EtherSymbol:()=>H0,EtherscanPlugin:()=>Ni,EtherscanProvider:()=>Ii,EventFragment:()=>Ve,EventLog:()=>Cn,EventPayload:()=>tn,FallbackFragment:()=>ct,FallbackProvider:()=>Ui,FeeData:()=>ss,FeeDataNetworkPlugin:()=>_c,FetchCancelSignal:()=>aa,FetchRequest:()=>oe,FetchResponse:()=>nr,FetchUrlFeeDataNetworkPlugin:()=>us,FixedNumber:()=>Gn,Fragment:()=>Rt,FunctionFragment:()=>Ke,GasCostPlugin:()=>Fr,HDNodeVoidWallet:()=>Wr,HDNodeWallet:()=>Jr,Indexed:()=>li,InfuraProvider:()=>Rr,InfuraWebSocketProvider:()=>Co,Interface:()=>yn,IpcSocketProvider:()=>sd,JsonRpcApiProvider:()=>ws,JsonRpcProvider:()=>ke,JsonRpcSigner:()=>ys,LangEn:()=>Ye,Log:()=>kt,LogDescription:()=>Ka,MaxInt256:()=>q0,MaxUint256:()=>M0,MessagePrefix:()=>hc,MinInt256:()=>G0,Mnemonic:()=>It,MulticoinProviderPlugin:()=>Za,N:()=>D0,NamedFragment:()=>bn,Network:()=>Z,NetworkPlugin:()=>vt,NonceManager:()=>nu,ParamType:()=>we,PocketProvider:()=>Ps,QuickNodeProvider:()=>Gr,Result:()=>un,Signature:()=>Ue,SigningKey:()=>_e,SocketBlockSubscriber:()=>yo,SocketEventSubscriber:()=>Ao,SocketPendingSubscriber:()=>wo,SocketProvider:()=>Oi,SocketSubscriber:()=>Rs,StructFragment:()=>Lt,Transaction:()=>Et,TransactionDescription:()=>ja,TransactionReceipt:()=>An,TransactionResponse:()=>Br,Typed:()=>ie,TypedDataEncoder:()=>_t,UndecodedEventLog:()=>is,UnmanagedSubscriber:()=>wr,Utf8ErrorFuncs:()=>Eu,VoidSigner:()=>Ei,Wallet:()=>Uo,WebSocketProvider:()=>Bn,WeiPerEther:()=>L0,Wordlist:()=>Di,WordlistOwl:()=>Un,WordlistOwlA:()=>pu,ZeroAddress:()=>Zn,ZeroHash:()=>ya,accessListify:()=>Le,assert:()=>w,assertArgument:()=>h,assertArgumentCount:()=>Ms,assertNormalize:()=>Gs,assertPrivate:()=>Oe,checkResultErrors:()=>Ou,computeAddress:()=>mr,computeHmac:()=>yt,concat:()=>G,copyRequest:()=>Or,dataLength:()=>st,dataSlice:()=>j,decodeBase58:()=>qo,decodeBase64:()=>Ho,decodeBytes32String:()=>mf,decodeRlp:()=>Xs,decryptCrowdsaleJson:()=>Oo,decryptKeystoreJson:()=>lu,decryptKeystoreJsonSync:()=>uu,defaultPath:()=>To,defineProperties:()=>N,dnsEncode:()=>Ec,encodeBase58:()=>zs,encodeBase64:()=>zo,encodeBytes32String:()=>xf,encodeRlp:()=>vr,encryptKeystoreJson:()=>Vi,encryptKeystoreJsonSync:()=>zi,ensNormalize:()=>fl,formatEther:()=>y0,formatUnits:()=>vu,fromTwos:()=>$r,getAccountPath:()=>bd,getAddress:()=>L,getBigInt:()=>I,getBytes:()=>v,getBytesCopy:()=>de,getCreate2Address:()=>K0,getCreateAddress:()=>ai,getDefaultProvider:()=>nd,getIcapAddress:()=>V0,getIndexedAccountPath:()=>yd,getNumber:()=>_,getUint:()=>Hs,hashMessage:()=>La,hexlify:()=>P,id:()=>De,isAddress:()=>J0,isAddressable:()=>Ra,isBytesLike:()=>qs,isCallException:()=>Dn,isCrowdsaleJson:()=>Bo,isError:()=>me,isHexString:()=>V,isKeystoreJson:()=>Io,isValidName:()=>nf,keccak256:()=>z,lock:()=>bp,makeError:()=>te,mask:()=>mt,namehash:()=>$n,parseEther:()=>w0,parseUnits:()=>Su,pbkdf2:()=>$e,randomBytes:()=>ze,recoverAddress:()=>hn,resolveAddress:()=>xe,resolveProperties:()=>ae,ripemd160:()=>ur,scrypt:()=>lr,scryptSync:()=>fr,sha256:()=>Ne,sha512:()=>ri,showThrottleMessage:()=>nt,solidityPacked:()=>Rc,solidityPackedKeccak256:()=>cf,solidityPackedSha256:()=>uf,stripZerosLeft:()=>c0,toBeArray:()=>pe,toBeHex:()=>Ie,toBigInt:()=>Bt,toNumber:()=>Go,toQuantity:()=>it,toTwos:()=>en,toUtf8Bytes:()=>ee,toUtf8CodePoints:()=>f0,toUtf8String:()=>at,uuidV4:()=>$o,verifyMessage:()=>of,verifyTypedData:()=>df,version:()=>Zi,wordlists:()=>Ad,zeroPadBytes:()=>Xr,zeroPadValue:()=>Se});var Zi="6.7.1";function Bm(n,e,t){let r=e.split("|").map(i=>i.trim());for(let i=0;i<r.length;i++)switch(e){case"any":return;case"bigint":case"boolean":case"number":case"string":if(typeof n===e)return}let s=new Error(`invalid value for type ${e}`);throw s.code="INVALID_ARGUMENT",s.argument=`value.${t}`,s.value=n,s}function ae(n){return l(this,null,function*(){let e=Object.keys(n);return (yield Promise.all(e.map(r=>Promise.resolve(n[r])))).reduce((r,s,i)=>(r[e[i]]=s,r),{})})}function N(n,e,t){for(let r in e){let s=e[r],i=t?t[r]:null;i&&Bm(s,i,r),Object.defineProperty(n,r,{enumerable:!0,value:s,writable:!1});}}function Xi(n){if(n==null)return "null";if(Array.isArray(n))return "[ "+n.map(Xi).join(", ")+" ]";if(n instanceof Uint8Array){let e="0123456789abcdef",t="0x";for(let r=0;r<n.length;r++)t+=e[n[r]>>4],t+=e[n[r]&15];return t}if(typeof n=="object"&&typeof n.toJSON=="function")return Xi(n.toJSON());switch(typeof n){case"boolean":case"symbol":return n.toString();case"bigint":return BigInt(n).toString();case"number":return n.toString();case"string":return JSON.stringify(n);case"object":{let e=Object.keys(n);return e.sort(),"{ "+e.map(t=>`${Xi(t)}: ${Xi(n[t])}`).join(", ")+" }"}}return "[ COULD NOT SERIALIZE ]"}function me(n,e){return n&&n.code===e}function Dn(n){return me(n,"CALL_EXCEPTION")}function te(n,e,t){{let s=[];if(t){if("message"in t||"code"in t||"name"in t)throw new Error(`value will overwrite populated values: ${Xi(t)}`);for(let i in t){let a=t[i];s.push(i+"="+Xi(a));}}s.push(`code=${e}`),s.push(`version=${Zi}`),s.length&&(n+=" ("+s.join(", ")+")");}let r;switch(e){case"INVALID_ARGUMENT":r=new TypeError(n);break;case"NUMERIC_FAULT":case"BUFFER_OVERRUN":r=new RangeError(n);break;default:r=new Error(n);}return N(r,{code:e}),t&&Object.assign(r,t),r}function w(n,e,t,r){if(!n)throw te(e,t,r)}function h(n,e,t,r){w(n,e,"INVALID_ARGUMENT",{argument:t,value:r});}function Ms(n,e,t){t==null&&(t=""),t&&(t=": "+t),w(n>=e,"missing arguemnt"+t,"MISSING_ARGUMENT",{count:n,expectedCount:e}),w(n<=e,"too many arguemnts"+t,"UNEXPECTED_ARGUMENT",{count:n,expectedCount:e});}var Om=["NFD","NFC","NFKD","NFKC"].reduce((n,e)=>{try{if("test".normalize(e)!=="test")throw new Error("bad");if(e==="NFD"){let t=String.fromCharCode(233).normalize("NFD"),r=String.fromCharCode(101,769);if(t!==r)throw new Error("broken")}n.push(e);}catch(t){}return n},[]);function Gs(n){w(Om.indexOf(n)>=0,"platform missing String.prototype.normalize","UNSUPPORTED_OPERATION",{operation:"String.prototype.normalize",info:{form:n}});}function Oe(n,e,t){if(t==null&&(t=""),n!==e){let r=t,s="new";t&&(r+=".",s+=" "+t),w(!1,`private constructor; use ${r}from* methods`,"UNSUPPORTED_OPERATION",{operation:s});}}function Fd(n,e,t){if(n instanceof Uint8Array)return t?new Uint8Array(n):n;if(typeof n=="string"&&n.match(/^0x([0-9a-f][0-9a-f])*$/i)){let r=new Uint8Array((n.length-2)/2),s=2;for(let i=0;i<r.length;i++)r[i]=parseInt(n.substring(s,s+2),16),s+=2;return r}h(!1,"invalid BytesLike value",e||"value",n);}function v(n,e){return Fd(n,e,!1)}function de(n,e){return Fd(n,e,!0)}function V(n,e){return !(typeof n!="string"||!n.match(/^0x[0-9A-Fa-f]*$/)||typeof e=="number"&&n.length!==2+2*e||e===!0&&n.length%2!==0)}function qs(n){return V(n,!0)||n instanceof Uint8Array}var Od="0123456789abcdef";function P(n){let e=v(n),t="0x";for(let r=0;r<e.length;r++){let s=e[r];t+=Od[(s&240)>>4]+Od[s&15];}return t}function G(n){return "0x"+n.map(e=>P(e).substring(2)).join("")}function st(n){return V(n,!0)?(n.length-2)/2:v(n).length}function j(n,e,t){let r=v(n);return t!=null&&t>r.length&&w(!1,"cannot slice beyond data bounds","BUFFER_OVERRUN",{buffer:r,length:r.length,offset:t}),P(r.slice(e==null?0:e,t==null?r.length:t))}function c0(n){let e=P(n).substring(2);for(;e.startsWith("00");)e=e.substring(2);return "0x"+e}function Ud(n,e,t){let r=v(n);w(e>=r.length,"padding exceeds data length","BUFFER_OVERRUN",{buffer:new Uint8Array(r),length:e,offset:e+1});let s=new Uint8Array(e);return s.fill(0),t?s.set(r,e-r.length):s.set(r,0),P(s)}function Se(n,e){return Ud(n,e,!0)}function Xr(n,e){return Ud(n,e,!1)}var Au=BigInt(0),er=BigInt(1),$i=9007199254740991;function $r(n,e){let t=Hs(n,"value"),r=BigInt(_(e,"width"));if(w(t>>r===Au,"overflow","NUMERIC_FAULT",{operation:"fromTwos",fault:"overflow",value:n}),t>>r-er){let s=(er<<r)-er;return -((~t&s)+er)}return t}function en(n,e){let t=I(n,"value"),r=BigInt(_(e,"width")),s=er<<r-er;if(t<Au){t=-t,w(t<=s,"too low","NUMERIC_FAULT",{operation:"toTwos",fault:"overflow",value:n});let i=(er<<r)-er;return (~t&i)+er}else w(t<s,"too high","NUMERIC_FAULT",{operation:"toTwos",fault:"overflow",value:n});return t}function mt(n,e){let t=Hs(n,"value"),r=BigInt(_(e,"bits"));return t&(er<<r)-er}function I(n,e){switch(typeof n){case"bigint":return n;case"number":return h(Number.isInteger(n),"underflow",e||"value",n),h(n>=-$i&&n<=$i,"overflow",e||"value",n),BigInt(n);case"string":try{if(n==="")throw new Error("empty string");return n[0]==="-"&&n[1]!=="-"?-BigInt(n.substring(1)):BigInt(n)}catch(t){h(!1,`invalid BigNumberish string: ${t.message}`,e||"value",n);}}h(!1,"invalid BigNumberish value",e||"value",n);}function Hs(n,e){let t=I(n,e);return w(t>=Au,"unsigned value cannot be negative","NUMERIC_FAULT",{fault:"overflow",operation:"getUint",value:n}),t}var _d="0123456789abcdef";function Bt(n){if(n instanceof Uint8Array){let e="0x0";for(let t of n)e+=_d[t>>4],e+=_d[t&15];return BigInt(e)}return I(n)}function _(n,e){switch(typeof n){case"bigint":return h(n>=-$i&&n<=$i,"overflow",e||"value",n),Number(n);case"number":return h(Number.isInteger(n),"underflow",e||"value",n),h(n>=-$i&&n<=$i,"overflow",e||"value",n),n;case"string":try{if(n==="")throw new Error("empty string");return _(BigInt(n),e)}catch(t){h(!1,`invalid numeric string: ${t.message}`,e||"value",n);}}h(!1,"invalid numeric value",e||"value",n);}function Go(n){return _(Bt(n))}function Ie(n,e){let r=Hs(n,"value").toString(16);if(e==null)r.length%2&&(r="0"+r);else {let s=_(e,"width");for(w(s*2>=r.length,`value exceeds width (${s} bits)`,"NUMERIC_FAULT",{operation:"toBeHex",fault:"overflow",value:n});r.length<s*2;)r="0"+r;}return "0x"+r}function pe(n){let e=Hs(n,"value");if(e===Au)return new Uint8Array([]);let t=e.toString(16);t.length%2&&(t="0"+t);let r=new Uint8Array(t.length/2);for(let s=0;s<r.length;s++){let i=s*2;r[s]=parseInt(t.substring(i,i+2),16);}return r}function it(n){let e=P(qs(n)?n:pe(n)).substring(2);for(;e.startsWith("0");)e=e.substring(1);return e===""&&(e="0"),"0x"+e}var u0="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz",Cu=null;function Fm(n){if(Cu==null){Cu={};for(let t=0;t<u0.length;t++)Cu[u0[t]]=BigInt(t);}let e=Cu[n];return h(e!=null,"invalid base58 value","letter",n),e}var Um=BigInt(0),l0=BigInt(58);function zs(n){let e=Bt(v(n)),t="";for(;e;)t=u0[Number(e%l0)]+t,e/=l0;return t}function qo(n){let e=Um;for(let t=0;t<n.length;t++)e*=l0,e+=Fm(n[t]);return e}function Ho(n){n=atob(n);let e=new Uint8Array(n.length);for(let t=0;t<n.length;t++)e[t]=n.charCodeAt(t);return v(e)}function zo(n){let e=v(n),t="";for(let r=0;r<e.length;r++)t+=String.fromCharCode(e[r]);return btoa(t)}var ea,tn=class{constructor(e,t,r){g(this,"filter");g(this,"emitter");b(this,ea,void 0);p(this,ea,t),N(this,{emitter:e,filter:r});}removeListener(){return l(this,null,function*(){u(this,ea)!=null&&(yield this.emitter.off(this.filter,u(this,ea)));})}};ea=new WeakMap;function _m(n,e,t,r,s){h(!1,`invalid codepoint at offset ${e}; ${n}`,"bytes",t);}function Dd(n,e,t,r,s){if(n==="BAD_PREFIX"||n==="UNEXPECTED_CONTINUE"){let i=0;for(let a=e+1;a<t.length&&t[a]>>6===2;a++)i++;return i}return n==="OVERRUN"?t.length-e-1:0}function Dm(n,e,t,r,s){return n==="OVERLONG"?(h(typeof s=="number","invalid bad code point for replacement","badCodepoint",s),r.push(s),0):(r.push(65533),Dd(n,e,t))}var Eu=Object.freeze({error:_m,ignore:Dd,replace:Dm});function Ld(n,e){e==null&&(e=Eu.error);let t=v(n,"bytes"),r=[],s=0;for(;s<t.length;){let i=t[s++];if(!(i>>7)){r.push(i);continue}let a=null,o=null;if((i&224)===192)a=1,o=127;else if((i&240)===224)a=2,o=2047;else if((i&248)===240)a=3,o=65535;else {(i&192)===128?s+=e("UNEXPECTED_CONTINUE",s-1,t,r):s+=e("BAD_PREFIX",s-1,t,r);continue}if(s-1+a>=t.length){s+=e("OVERRUN",s-1,t,r);continue}let c=i&(1<<8-a-1)-1;for(let f=0;f<a;f++){let d=t[s];if((d&192)!=128){s+=e("MISSING_CONTINUE",s,t,r),c=null;break}c=c<<6|d&63,s++;}if(c!==null){if(c>1114111){s+=e("OUT_OF_RANGE",s-1-a,t,r,c);continue}if(c>=55296&&c<=57343){s+=e("UTF16_SURROGATE",s-1-a,t,r,c);continue}if(c<=o){s+=e("OVERLONG",s-1-a,t,r,c);continue}r.push(c);}}return r}function ee(n,e){e!=null&&(Gs(e),n=n.normalize(e));let t=[];for(let r=0;r<n.length;r++){let s=n.charCodeAt(r);if(s<128)t.push(s);else if(s<2048)t.push(s>>6|192),t.push(s&63|128);else if((s&64512)==55296){r++;let i=n.charCodeAt(r);h(r<n.length&&(i&64512)===56320,"invalid surrogate pair","str",n);let a=65536+((s&1023)<<10)+(i&1023);t.push(a>>18|240),t.push(a>>12&63|128),t.push(a>>6&63|128),t.push(a&63|128);}else t.push(s>>12|224),t.push(s>>6&63|128),t.push(s&63|128);}return new Uint8Array(t)}function Lm(n){return n.map(e=>e<=65535?String.fromCharCode(e):(e-=65536,String.fromCharCode((e>>10&1023)+55296,(e&1023)+56320))).join("")}function at(n,e){return Lm(Ld(n,e))}function f0(n,e){return Ld(ee(n,e))}function Md(n,e){return l(this,null,function*(){let t=n.url.split(":")[0].toLowerCase();w(t==="http"||t==="https",`unsupported protocol ${t}`,"UNSUPPORTED_OPERATION",{info:{protocol:t},operation:"request"}),w(t==="https"||!n.credentials||n.allowInsecureAuthentication,"insecure authorized connections unsupported","UNSUPPORTED_OPERATION",{operation:"request"});let r;if(e){let f=new AbortController;r=f.signal,e.addListener(()=>{f.abort();});}let s={method:n.method,headers:new Headers(Array.from(n)),body:n.body||void 0,signal:r},i=yield fetch(n.url,s),a={};i.headers.forEach((f,d)=>{a[d.toLowerCase()]=f;});let o=yield i.arrayBuffer(),c=o==null?null:new Uint8Array(o);return {statusCode:i.status,statusMessage:i.statusText,headers:a,body:c}})}var Mm=12,Gm=250,Gd=Md,qm=new RegExp("^data:([^;:]*)?(;base64)?,(.*)$","i"),Hm=new RegExp("^ipfs://(ipfs/)?(.*)$","i"),d0=!1;function Hd(n,e){return l(this,null,function*(){try{let t=n.match(qm);if(!t)throw new Error("invalid data");return new nr(200,"OK",{"content-type":t[1]||"text/plain"},t[2]?Ho(t[3]):zm(t[3]))}catch(t){return new nr(599,"BAD REQUEST (invalid data: URI)",{},null,new oe(n))}})}function zd(n){function e(t,r){return l(this,null,function*(){try{let s=t.match(Hm);if(!s)throw new Error("invalid link");return new oe(`${n}${s[2]}`)}catch(s){return new nr(599,"BAD REQUEST (invalid IPFS URI)",{},null,new oe(t))}})}return e}var Ru={data:Hd,ipfs:zd("https://gateway.ipfs.io/ipfs/")},Vd=new WeakMap,Vs,Ln,aa=class{constructor(e){b(this,Vs,void 0);b(this,Ln,void 0);p(this,Vs,[]),p(this,Ln,!1),Vd.set(e,()=>{if(!u(this,Ln)){p(this,Ln,!0);for(let t of u(this,Vs))setTimeout(()=>{t();},0);p(this,Vs,[]);}});}addListener(e){w(!u(this,Ln),"singal already cancelled","UNSUPPORTED_OPERATION",{operation:"fetchCancelSignal.addCancelListener"}),u(this,Vs).push(e);}get cancelled(){return u(this,Ln)}checkSignal(){w(!this.cancelled,"cancelled","CANCELLED",{});}};Vs=new WeakMap,Ln=new WeakMap;function ku(n){if(n==null)throw new Error("missing signal; should not happen");return n.checkSignal(),n}var ta,ra,tr,rn,na,sa,Te,gt,nn,Ks,js,Js,Pr,sn,Ws,Vo,Pu=class{constructor(e){b(this,Ws);b(this,ta,void 0);b(this,ra,void 0);b(this,tr,void 0);b(this,rn,void 0);b(this,na,void 0);b(this,sa,void 0);b(this,Te,void 0);b(this,gt,void 0);b(this,nn,void 0);b(this,Ks,void 0);b(this,js,void 0);b(this,Js,void 0);b(this,Pr,void 0);b(this,sn,void 0);p(this,sa,String(e)),p(this,ta,!1),p(this,ra,!0),p(this,tr,{}),p(this,rn,""),p(this,na,3e5),p(this,sn,{slotInterval:Gm,maxAttempts:Mm});}get url(){return u(this,sa)}set url(e){p(this,sa,String(e));}get body(){return u(this,Te)==null?null:new Uint8Array(u(this,Te))}set body(e){if(e==null)p(this,Te,void 0),p(this,gt,void 0);else if(typeof e=="string")p(this,Te,ee(e)),p(this,gt,"text/plain");else if(e instanceof Uint8Array)p(this,Te,e),p(this,gt,"application/octet-stream");else if(typeof e=="object")p(this,Te,ee(JSON.stringify(e))),p(this,gt,"application/json");else throw new Error("invalid body")}hasBody(){return u(this,Te)!=null}get method(){return u(this,rn)?u(this,rn):this.hasBody()?"POST":"GET"}set method(e){e==null&&(e=""),p(this,rn,String(e).toUpperCase());}get headers(){let e=Object.assign({},u(this,tr));return u(this,nn)&&(e.authorization=`Basic ${zo(ee(u(this,nn)))}`),this.allowGzip&&(e["accept-encoding"]="gzip"),e["content-type"]==null&&u(this,gt)&&(e["content-type"]=u(this,gt)),this.body&&(e["content-length"]=String(this.body.length)),e}getHeader(e){return this.headers[e.toLowerCase()]}setHeader(e,t){u(this,tr)[String(e).toLowerCase()]=String(t);}clearHeaders(){p(this,tr,{});}[Symbol.iterator](){let e=this.headers,t=Object.keys(e),r=0;return {next:()=>{if(r<t.length){let s=t[r++];return {value:[s,e[s]],done:!1}}return {value:void 0,done:!0}}}}get credentials(){return u(this,nn)||null}setCredentials(e,t){h(!e.match(/:/),"invalid basic authentication username","username","[REDACTED]"),p(this,nn,`${e}:${t}`);}get allowGzip(){return u(this,ra)}set allowGzip(e){p(this,ra,!!e);}get allowInsecureAuthentication(){return !!u(this,ta)}set allowInsecureAuthentication(e){p(this,ta,!!e);}get timeout(){return u(this,na)}set timeout(e){h(e>=0,"timeout must be non-zero","timeout",e),p(this,na,e);}get preflightFunc(){return u(this,Ks)||null}set preflightFunc(e){p(this,Ks,e);}get processFunc(){return u(this,js)||null}set processFunc(e){p(this,js,e);}get retryFunc(){return u(this,Js)||null}set retryFunc(e){p(this,Js,e);}toString(){return `<FetchRequest method=${JSON.stringify(this.method)} url=${JSON.stringify(this.url)} headers=${JSON.stringify(this.headers)} body=${u(this,Te)?P(u(this,Te)):"null"}>`}setThrottleParams(e){e.slotInterval!=null&&(u(this,sn).slotInterval=e.slotInterval),e.maxAttempts!=null&&(u(this,sn).maxAttempts=e.maxAttempts);}send(){return w(u(this,Pr)==null,"request already sent","UNSUPPORTED_OPERATION",{operation:"fetchRequest.send"}),p(this,Pr,new aa(this)),k(this,Ws,Vo).call(this,0,qd()+this.timeout,0,this,new nr(0,"",{},null,this))}cancel(){w(u(this,Pr)!=null,"request has not been sent","UNSUPPORTED_OPERATION",{operation:"fetchRequest.cancel"});let e=Vd.get(this);if(!e)throw new Error("missing signal; should not happen");e();}redirect(e){let t=this.url.split(":")[0].toLowerCase(),r=e.split(":")[0].toLowerCase();w(this.method==="GET"&&(t!=="https"||r!=="http")&&e.match(/^https?:/),"unsupported redirect","UNSUPPORTED_OPERATION",{operation:`redirect(${this.method} ${JSON.stringify(this.url)} => ${JSON.stringify(e)})`});let s=new Pu(e);return s.method="GET",s.allowGzip=this.allowGzip,s.timeout=this.timeout,p(s,tr,Object.assign({},u(this,tr))),u(this,Te)&&p(s,Te,new Uint8Array(u(this,Te))),p(s,gt,u(this,gt)),s}clone(){let e=new Pu(this.url);return p(e,rn,u(this,rn)),u(this,Te)&&p(e,Te,u(this,Te)),p(e,gt,u(this,gt)),p(e,tr,Object.assign({},u(this,tr))),p(e,nn,u(this,nn)),this.allowGzip&&(e.allowGzip=!0),e.timeout=this.timeout,this.allowInsecureAuthentication&&(e.allowInsecureAuthentication=!0),p(e,Ks,u(this,Ks)),p(e,js,u(this,js)),p(e,Js,u(this,Js)),e}static lockConfig(){d0=!0;}static getGateway(e){return Ru[e.toLowerCase()]||null}static registerGateway(e,t){if(e=e.toLowerCase(),e==="http"||e==="https")throw new Error(`cannot intercept ${e}; use registerGetUrl`);if(d0)throw new Error("gateways locked");Ru[e]=t;}static registerGetUrl(e){if(d0)throw new Error("gateways locked");Gd=e;}static createDataGateway(){return Hd}static createIpfsGatewayFunc(e){return zd(e)}},oe=Pu;ta=new WeakMap,ra=new WeakMap,tr=new WeakMap,rn=new WeakMap,na=new WeakMap,sa=new WeakMap,Te=new WeakMap,gt=new WeakMap,nn=new WeakMap,Ks=new WeakMap,js=new WeakMap,Js=new WeakMap,Pr=new WeakMap,sn=new WeakMap,Ws=new WeakSet,Vo=function(e,t,r,s,i){return l(this,null,function*(){var d,x,m;if(e>=u(this,sn).maxAttempts)return i.makeServerError("exceeded maximum retry limit");w(qd()<=t,"timeout","TIMEOUT",{operation:"request.send",reason:"timeout",request:s}),r>0&&(yield Vm(r));let a=this.clone(),o=(a.url.split(":")[0]||"").toLowerCase();if(o in Ru){let y=yield Ru[o](a.url,ku(u(s,Pr)));if(y instanceof nr){let R=y;if(this.processFunc){ku(u(s,Pr));try{R=yield this.processFunc(a,R);}catch(S){(S.throttle==null||typeof S.stall!="number")&&R.makeServerError("error in post-processing function",S).assertOk();}}return R}a=y;}this.preflightFunc&&(a=yield this.preflightFunc(a));let c=yield Gd(a,ku(u(s,Pr))),f=new nr(c.statusCode,c.statusMessage,c.headers,c.body,s);if(f.statusCode===301||f.statusCode===302){try{let y=f.headers.location||"";return k(d=a.redirect(y),Ws,Vo).call(d,e+1,t,0,s,f)}catch(y){}return f}else if(f.statusCode===429&&(this.retryFunc==null||(yield this.retryFunc(a,f,e)))){let y=f.headers["retry-after"],R=u(this,sn).slotInterval*Math.trunc(Math.random()*Math.pow(2,e));return typeof y=="string"&&y.match(/^[1-9][0-9]*$/)&&(R=parseInt(y)),k(x=a.clone(),Ws,Vo).call(x,e+1,t,R,s,f)}if(this.processFunc){ku(u(s,Pr));try{f=yield this.processFunc(a,f);}catch(y){(y.throttle==null||typeof y.stall!="number")&&f.makeServerError("error in post-processing function",y).assertOk();let R=u(this,sn).slotInterval*Math.trunc(Math.random()*Math.pow(2,e));return y.stall>=0&&(R=y.stall),k(m=a.clone(),Ws,Vo).call(m,e+1,t,R,s,f)}}return f})};var Ko,jo,Jo,rr,ia,Qs,h0=class{constructor(e,t,r,s,i){b(this,Ko,void 0);b(this,jo,void 0);b(this,Jo,void 0);b(this,rr,void 0);b(this,ia,void 0);b(this,Qs,void 0);p(this,Ko,e),p(this,jo,t),p(this,Jo,Object.keys(r).reduce((a,o)=>(a[o.toLowerCase()]=String(r[o]),a),{})),p(this,rr,s==null?null:new Uint8Array(s)),p(this,ia,i||null),p(this,Qs,{message:""});}toString(){return `<FetchResponse status=${this.statusCode} body=${u(this,rr)?P(u(this,rr)):"null"}>`}get statusCode(){return u(this,Ko)}get statusMessage(){return u(this,jo)}get headers(){return Object.assign({},u(this,Jo))}get body(){return u(this,rr)==null?null:new Uint8Array(u(this,rr))}get bodyText(){try{return u(this,rr)==null?"":at(u(this,rr))}catch(e){w(!1,"response body is not valid UTF-8 data","UNSUPPORTED_OPERATION",{operation:"bodyText",info:{response:this}});}}get bodyJson(){try{return JSON.parse(this.bodyText)}catch(e){w(!1,"response body is not valid JSON","UNSUPPORTED_OPERATION",{operation:"bodyJson",info:{response:this}});}}[Symbol.iterator](){let e=this.headers,t=Object.keys(e),r=0;return {next:()=>{if(r<t.length){let s=t[r++];return {value:[s,e[s]],done:!1}}return {value:void 0,done:!0}}}}makeServerError(e,t){let r;e?r=`CLIENT ESCALATED SERVER ERROR (${this.statusCode} ${this.statusMessage}; ${e})`:(e=`${this.statusCode} ${this.statusMessage}`,r=`CLIENT ESCALATED SERVER ERROR (${e})`);let s=new h0(599,r,this.headers,this.body,u(this,ia)||void 0);return p(s,Qs,{message:e,error:t}),s}throwThrottleError(e,t){t==null?t=-1:h(Number.isInteger(t)&&t>=0,"invalid stall timeout","stall",t);let r=new Error(e||"throttling requests");throw N(r,{stall:t,throttle:!0}),r}getHeader(e){return this.headers[e.toLowerCase()]}hasBody(){return u(this,rr)!=null}get request(){return u(this,ia)}ok(){return u(this,Qs).message===""&&this.statusCode>=200&&this.statusCode<300}assertOk(){if(this.ok())return;let{message:e,error:t}=u(this,Qs);e===""&&(e=`server response ${this.statusCode} ${this.statusMessage}`),w(!1,e,"SERVER_ERROR",{request:this.request||"unknown request",response:this,error:t});}},nr=h0;Ko=new WeakMap,jo=new WeakMap,Jo=new WeakMap,rr=new WeakMap,ia=new WeakMap,Qs=new WeakMap;function qd(){return new Date().getTime()}function zm(n){return ee(n.replace(/%([0-9a-f][0-9a-f])/gi,(e,t)=>String.fromCharCode(parseInt(t,16))))}function Vm(n){return new Promise(e=>setTimeout(e,n))}var Km=BigInt(-1),sr=BigInt(0),ca=BigInt(1),jm=BigInt(5),oa={},ua="0000";for(;ua.length<80;)ua+=ua;function Ys(n){let e=ua;for(;e.length<n;)e+=e;return BigInt("1"+e.substring(0,n))}function Wo(n,e,t){let r=BigInt(e.width);if(e.signed){let s=ca<<r-ca;w(t==null||n>=-s&&n<s,"overflow","NUMERIC_FAULT",{operation:t,fault:"overflow",value:n}),n>sr?n=$r(mt(n,r),r):n=-$r(mt(-n,r),r);}else {let s=ca<<r;w(t==null||n>=0&&n<s,"overflow","NUMERIC_FAULT",{operation:t,fault:"overflow",value:n}),n=(n%s+s)%s&s-ca;}return n}function p0(n){typeof n=="number"&&(n=`fixed128x${n}`);let e=!0,t=128,r=18;if(typeof n=="string"){if(n!=="fixed")if(n==="ufixed")e=!1;else {let i=n.match(/^(u?)fixed([0-9]+)x([0-9]+)$/);h(i,"invalid fixed format","format",n),e=i[1]!=="u",t=parseInt(i[2]),r=parseInt(i[3]);}}else if(n){let i=n,a=(o,c,f)=>i[o]==null?f:(h(typeof i[o]===c,"invalid fixed format ("+o+" not "+c+")","format."+o,i[o]),i[o]);e=a("signed","boolean",e),t=a("width","number",t),r=a("decimals","number",r);}h(t%8===0,"invalid FixedNumber width (not byte aligned)","format.width",t),h(r<=80,"invalid FixedNumber decimals (too large)","format.decimals",r);let s=(e?"":"u")+"fixed"+String(t)+"x"+String(r);return {signed:e,width:t,decimals:r,name:s}}function Jm(n,e){let t="";n<sr&&(t="-",n*=Km);let r=n.toString();if(e===0)return t+r;for(;r.length<=e;)r=ua+r;let s=r.length-e;for(r=r.substring(0,s)+"."+r.substring(s);r[0]==="0"&&r[1]!==".";)r=r.substring(1);for(;r[r.length-1]==="0"&&r[r.length-2]!==".";)r=r.substring(0,r.length-1);return t+r}var ir,ne,Xe,on,Zs,ar,an,Qo,x0,Yo,m0,Zo,g0,Xo,b0,Mn=class{constructor(e,t,r){b(this,on);b(this,ar);b(this,Qo);b(this,Yo);b(this,Zo);b(this,Xo);g(this,"format");b(this,ir,void 0);b(this,ne,void 0);b(this,Xe,void 0);g(this,"_value");Oe(e,oa,"FixedNumber"),p(this,ne,t),p(this,ir,r);let s=Jm(t,r.decimals);N(this,{format:r.name,_value:s}),p(this,Xe,Ys(r.decimals));}get signed(){return u(this,ir).signed}get width(){return u(this,ir).width}get decimals(){return u(this,ir).decimals}get value(){return u(this,ne)}addUnsafe(e){return k(this,Qo,x0).call(this,e)}add(e){return k(this,Qo,x0).call(this,e,"add")}subUnsafe(e){return k(this,Yo,m0).call(this,e)}sub(e){return k(this,Yo,m0).call(this,e,"sub")}mulUnsafe(e){return k(this,Zo,g0).call(this,e)}mul(e){return k(this,Zo,g0).call(this,e,"mul")}mulSignal(e){k(this,on,Zs).call(this,e);let t=u(this,ne)*u(e,ne);return w(t%u(this,Xe)===sr,"precision lost during signalling mul","NUMERIC_FAULT",{operation:"mulSignal",fault:"underflow",value:this}),k(this,ar,an).call(this,t/u(this,Xe),"mulSignal")}divUnsafe(e){return k(this,Xo,b0).call(this,e)}div(e){return k(this,Xo,b0).call(this,e,"div")}divSignal(e){w(u(e,ne)!==sr,"division by zero","NUMERIC_FAULT",{operation:"div",fault:"divide-by-zero",value:this}),k(this,on,Zs).call(this,e);let t=u(this,ne)*u(this,Xe);return w(t%u(e,ne)===sr,"precision lost during signalling div","NUMERIC_FAULT",{operation:"divSignal",fault:"underflow",value:this}),k(this,ar,an).call(this,t/u(e,ne),"divSignal")}cmp(e){let t=this.value,r=e.value,s=this.decimals-e.decimals;return s>0?r*=Ys(s):s<0&&(t*=Ys(-s)),t<r?-1:t>r?1:0}eq(e){return this.cmp(e)===0}lt(e){return this.cmp(e)<0}lte(e){return this.cmp(e)<=0}gt(e){return this.cmp(e)>0}gte(e){return this.cmp(e)>=0}floor(){let e=u(this,ne);return u(this,ne)<sr&&(e-=u(this,Xe)-ca),e=u(this,ne)/u(this,Xe)*u(this,Xe),k(this,ar,an).call(this,e,"floor")}ceiling(){let e=u(this,ne);return u(this,ne)>sr&&(e+=u(this,Xe)-ca),e=u(this,ne)/u(this,Xe)*u(this,Xe),k(this,ar,an).call(this,e,"ceiling")}round(e){if(e==null&&(e=0),e>=this.decimals)return this;let t=this.decimals-e,r=jm*Ys(t-1),s=this.value+r,i=Ys(t);return s=s/i*i,Wo(s,u(this,ir),"round"),new Mn(oa,s,u(this,ir))}isZero(){return u(this,ne)===sr}isNegative(){return u(this,ne)<sr}toString(){return this._value}toUnsafeFloat(){return parseFloat(this.toString())}toFormat(e){return Mn.fromString(this.toString(),e)}static fromValue(e,t,r){let s=t==null?0:_(t),i=p0(r),a=I(e,"value"),o=s-i.decimals;if(o>0){let c=Ys(o);w(a%c===sr,"value loses precision for format","NUMERIC_FAULT",{operation:"fromValue",fault:"underflow",value:e}),a/=c;}else o<0&&(a*=Ys(-o));return Wo(a,i,"fromValue"),new Mn(oa,a,i)}static fromString(e,t){let r=e.match(/^(-?)([0-9]*)\.?([0-9]*)$/);h(r&&r[2].length+r[3].length>0,"invalid FixedNumber string value","value",e);let s=p0(t),i=r[2]||"0",a=r[3]||"";for(;a.length<s.decimals;)a+=ua;w(a.substring(s.decimals).match(/^0*$/),"too many decimals for format","NUMERIC_FAULT",{operation:"fromString",fault:"underflow",value:e}),a=a.substring(0,s.decimals);let o=BigInt(r[1]+i+a);return Wo(o,s,"fromString"),new Mn(oa,o,s)}static fromBytes(e,t){let r=Bt(v(e,"value")),s=p0(t);return s.signed&&(r=$r(r,s.width)),Wo(r,s,"fromBytes"),new Mn(oa,r,s)}},Gn=Mn;ir=new WeakMap,ne=new WeakMap,Xe=new WeakMap,on=new WeakSet,Zs=function(e){h(this.format===e.format,"incompatible format; use fixedNumber.toFormat","other",e);},ar=new WeakSet,an=function(e,t){return e=Wo(e,u(this,ir),t),new Mn(oa,e,u(this,ir))},Qo=new WeakSet,x0=function(e,t){return k(this,on,Zs).call(this,e),k(this,ar,an).call(this,u(this,ne)+u(e,ne),t)},Yo=new WeakSet,m0=function(e,t){return k(this,on,Zs).call(this,e),k(this,ar,an).call(this,u(this,ne)-u(e,ne),t)},Zo=new WeakSet,g0=function(e,t){return k(this,on,Zs).call(this,e),k(this,ar,an).call(this,u(this,ne)*u(e,ne)/u(this,Xe),t)},Xo=new WeakSet,b0=function(e,t){return w(u(e,ne)!==sr,"division by zero","NUMERIC_FAULT",{operation:"div",fault:"divide-by-zero",value:this}),k(this,on,Zs).call(this,e),k(this,ar,an).call(this,u(this,ne)*u(this,Xe)/u(e,ne),t)};function Wm(n){let e=n.toString(16);for(;e.length<2;)e="0"+e;return "0x"+e}function Kd(n,e,t){let r=0;for(let s=0;s<t;s++)r=r*256+n[e+s];return r}function jd(n,e,t,r){let s=[];for(;t<e+1+r;){let i=Jd(n,t);s.push(i.result),t+=i.consumed,w(t<=e+1+r,"child data too short","BUFFER_OVERRUN",{buffer:n,length:r,offset:e});}return {consumed:1+r,result:s}}function Jd(n,e){w(n.length!==0,"data too short","BUFFER_OVERRUN",{buffer:n,length:0,offset:1});let t=r=>{w(r<=n.length,"data short segment too short","BUFFER_OVERRUN",{buffer:n,length:n.length,offset:r});};if(n[e]>=248){let r=n[e]-247;t(e+1+r);let s=Kd(n,e+1,r);return t(e+1+r+s),jd(n,e,e+1+r,r+s)}else if(n[e]>=192){let r=n[e]-192;return t(e+1+r),jd(n,e,e+1,r)}else if(n[e]>=184){let r=n[e]-183;t(e+1+r);let s=Kd(n,e+1,r);t(e+1+r+s);let i=P(n.slice(e+1+r,e+1+r+s));return {consumed:1+r+s,result:i}}else if(n[e]>=128){let r=n[e]-128;t(e+1+r);let s=P(n.slice(e+1,e+1+r));return {consumed:1+r,result:s}}return {consumed:1,result:Wm(n[e])}}function Xs(n){let e=v(n,"data"),t=Jd(e,0);return h(t.consumed===e.length,"unexpected junk after rlp payload","data",n),t.result}function Wd(n){let e=[];for(;n;)e.unshift(n&255),n>>=8;return e}function Yd(n){if(Array.isArray(n)){let r=[];if(n.forEach(function(i){r=r.concat(Yd(i));}),r.length<=55)return r.unshift(192+r.length),r;let s=Wd(r.length);return s.unshift(247+s.length),s.concat(r)}let e=Array.prototype.slice.call(v(n,"object"));if(e.length===1&&e[0]<=127)return e;if(e.length<=55)return e.unshift(128+e.length),e;let t=Wd(e.length);return t.unshift(183+t.length),t.concat(e)}var Qd="0123456789abcdef";function vr(n){let e="0x";for(let t of Yd(n))e+=Qd[t>>4],e+=Qd[t&15];return e}var Zd=["wei","kwei","mwei","gwei","szabo","finney","ether"];function vu(n,e){let t=18;if(typeof e=="string"){let r=Zd.indexOf(e);h(r>=0,"invalid unit","unit",e),t=3*r;}else e!=null&&(t=_(e,"unit"));return Gn.fromValue(n,t,{decimals:t,width:512}).toString()}function Su(n,e){h(typeof n=="string","value must be a string","value",n);let t=18;if(typeof e=="string"){let r=Zd.indexOf(e);h(r>=0,"invalid unit","unit",e),t=3*r;}else e!=null&&(t=_(e,"unit"));return Gn.fromString(n,{decimals:t,width:512}).value}function y0(n){return vu(n,18)}function w0(n){return Su(n,18)}function $o(n){let e=v(n,"randomBytes");e[6]=e[6]&15|64,e[8]=e[8]&63|128;let t=P(e);return [t.substring(2,10),t.substring(10,14),t.substring(14,18),t.substring(18,22),t.substring(22,34)].join("-")}var Fe=32,A0=new Uint8Array(Fe),Qm=["then"],Nu={};function ec(n,e){let t=new Error(`deferred error during ABI decoding triggered accessing ${n}`);throw t.error=e,t}var qn,tc=class extends Array{constructor(...t){let r=t[0],s=t[1],i=(t[2]||[]).slice(),a=!0;r!==Nu&&(s=t,i=[],a=!1);super(s.length);b(this,qn,void 0);s.forEach((c,f)=>{this[f]=c;});let o=i.reduce((c,f)=>(typeof f=="string"&&c.set(f,(c.get(f)||0)+1),c),new Map);if(p(this,qn,Object.freeze(s.map((c,f)=>{let d=i[f];return d!=null&&o.get(d)===1?d:null}))),!!a)return Object.freeze(this),new Proxy(this,{get:(c,f,d)=>{if(typeof f=="string"){if(f.match(/^[0-9]+$/)){let m=_(f,"%index");if(m<0||m>=this.length)throw new RangeError("out of result range");let y=c[m];return y instanceof Error&&ec(`index ${m}`,y),y}if(Qm.indexOf(f)>=0)return Reflect.get(c,f,d);let x=c[f];if(x instanceof Function)return function(...m){return x.apply(this===d?c:this,m)};if(!(f in c))return c.getValue.apply(this===d?c:this,[f])}return Reflect.get(c,f,d)}})}toArray(){let t=[];return this.forEach((r,s)=>{r instanceof Error&&ec(`index ${s}`,r),t.push(r);}),t}toObject(){return u(this,qn).reduce((t,r,s)=>(w(r!=null,"value at index ${ index } unnamed","UNSUPPORTED_OPERATION",{operation:"toObject()"}),r in t||(t[r]=this.getValue(r)),t),{})}slice(t,r){t==null&&(t=0),t<0&&(t+=this.length,t<0&&(t=0)),r==null&&(r=this.length),r<0&&(r+=this.length,r<0&&(r=0)),r>this.length&&(r=this.length);let s=[],i=[];for(let a=t;a<r;a++)s.push(this[a]),i.push(u(this,qn)[a]);return new tc(Nu,s,i)}filter(t,r){let s=[],i=[];for(let a=0;a<this.length;a++){let o=this[a];o instanceof Error&&ec(`index ${a}`,o),t.call(r,o,a,this)&&(s.push(o),i.push(u(this,qn)[a]));}return new tc(Nu,s,i)}map(t,r){let s=[];for(let i=0;i<this.length;i++){let a=this[i];a instanceof Error&&ec(`index ${i}`,a),s.push(t.call(r,a,i,this));}return s}getValue(t){let r=u(this,qn).indexOf(t);if(r===-1)return;let s=this[r];return s instanceof Error&&ec(`property ${JSON.stringify(t)}`,s.error),s}static fromItems(t,r){return new tc(Nu,t,r)}},un=tc;qn=new WeakMap;function Ou(n){let e=[],t=function(r,s){if(Array.isArray(s))for(let i in s){let a=r.slice();a.push(i);try{t(a,s[i]);}catch(o){e.push({path:a,error:o});}}};return t([],n),e}function Xd(n){let e=pe(n);return w(e.length<=Fe,"value out-of-bounds","BUFFER_OVERRUN",{buffer:e,length:Fe,offset:e.length}),e.length!==Fe&&(e=de(G([A0.slice(e.length%Fe),e]))),e}var Ee=class{constructor(e,t,r,s){g(this,"name");g(this,"type");g(this,"localName");g(this,"dynamic");N(this,{name:e,type:t,localName:r,dynamic:s},{name:"string",type:"string",localName:"string",dynamic:"boolean"});}_throwError(e,t){h(!1,e,this.localName,t);}},cn,$s,la,Iu,ei=class{constructor(){b(this,la);b(this,cn,void 0);b(this,$s,void 0);p(this,cn,[]),p(this,$s,0);}get data(){return G(u(this,cn))}get length(){return u(this,$s)}appendWriter(e){return k(this,la,Iu).call(this,de(e.data))}writeBytes(e){let t=de(e),r=t.length%Fe;return r&&(t=de(G([t,A0.slice(r)]))),k(this,la,Iu).call(this,t)}writeValue(e){return k(this,la,Iu).call(this,Xd(e))}writeUpdatableValue(){let e=u(this,cn).length;return u(this,cn).push(A0),p(this,$s,u(this,$s)+Fe),t=>{u(this,cn)[e]=Xd(t);}}};cn=new WeakMap,$s=new WeakMap,la=new WeakSet,Iu=function(e){return u(this,cn).push(e),p(this,$s,u(this,$s)+e.length),e.length};var bt,Ot,Bu,$d,C0=class{constructor(e,t){b(this,Bu);g(this,"allowLoose");b(this,bt,void 0);b(this,Ot,void 0);N(this,{allowLoose:!!t}),p(this,bt,de(e)),p(this,Ot,0);}get data(){return P(u(this,bt))}get dataLength(){return u(this,bt).length}get consumed(){return u(this,Ot)}get bytes(){return new Uint8Array(u(this,bt))}subReader(e){return new C0(u(this,bt).slice(u(this,Ot)+e),this.allowLoose)}readBytes(e,t){let r=k(this,Bu,$d).call(this,0,e,!!t);return p(this,Ot,u(this,Ot)+r.length),r.slice(0,e)}readValue(){return Bt(this.readBytes(Fe))}readIndex(){return Go(this.readBytes(Fe))}},Tu=C0;bt=new WeakMap,Ot=new WeakMap,Bu=new WeakSet,$d=function(e,t,r){let s=Math.ceil(t/Fe)*Fe;return u(this,Ot)+s>u(this,bt).length&&(this.allowLoose&&r&&u(this,Ot)+t<=u(this,bt).length?s=t:w(!1,"data out-of-bounds","BUFFER_OVERRUN",{buffer:de(u(this,bt)),length:u(this,bt).length,offset:u(this,Ot)+s})),u(this,bt).slice(u(this,Ot),u(this,Ot)+s)};function E0(n){if(!Number.isSafeInteger(n)||n<0)throw new Error(`Wrong positive integer: ${n}`)}function Ym(n){if(typeof n!="boolean")throw new Error(`Expected boolean, not ${n}`)}function eh(n,...e){if(!(n instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(e.length>0&&!e.includes(n.length))throw new TypeError(`Expected Uint8Array of length ${e}, not of length=${n.length}`)}function Zm(n){if(typeof n!="function"||typeof n.create!="function")throw new Error("Hash should be wrapped by utils.wrapConstructor");E0(n.outputLen),E0(n.blockLen);}function Xm(n,e=!0){if(n.destroyed)throw new Error("Hash instance has been destroyed");if(e&&n.finished)throw new Error("Hash#digest() has already been called")}function $m(n,e){eh(n);let t=e.outputLen;if(n.length<t)throw new Error(`digestInto() expects output buffer of length at least ${t}`)}var eg={number:E0,bool:Ym,bytes:eh,hash:Zm,exists:Xm,output:$m},se=eg;var fa=n=>new Uint32Array(n.buffer,n.byteOffset,Math.floor(n.byteLength/4)),da=n=>new DataView(n.buffer,n.byteOffset,n.byteLength),or=(n,e)=>n<<32-e|n>>>e,rg=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;if(!rg)throw new Error("Non little-endian hardware is not supported");Array.from({length:256},(n,e)=>e.toString(16).padStart(2,"0"));var ng=()=>l(void 0,null,function*(){});function Fu(n,e,t){return l(this,null,function*(){let r=Date.now();for(let s=0;s<n;s++){t(s);let i=Date.now()-r;i>=0&&i<e||(yield ng(),r+=i);}})}function sg(n){if(typeof n!="string")throw new TypeError(`utf8ToBytes expected string, got ${typeof n}`);return new TextEncoder().encode(n)}function cr(n){if(typeof n=="string"&&(n=sg(n)),!(n instanceof Uint8Array))throw new TypeError(`Expected input type is Uint8Array (got ${typeof n})`);return n}var ln=class{clone(){return this._cloneInto()}},ig=n=>Object.prototype.toString.call(n)==="[object Object]"&&n.constructor===Object;function Uu(n,e){if(e!==void 0&&(typeof e!="object"||!ig(e)))throw new TypeError("Options should be object or undefined");return Object.assign(n,e)}function Sr(n){let e=r=>n().update(cr(r)).digest(),t=n();return e.outputLen=t.outputLen,e.blockLen=t.blockLen,e.create=()=>n(),e}function th(n){let e=(r,s)=>n(s).update(cr(r)).digest(),t=n({});return e.outputLen=t.outputLen,e.blockLen=t.bloc