wowok_agent
Version:
Create, collaborate, and transact on your own terms with the AI-driven web3 collaboration protocol.
1 lines • 28.9 kB
JavaScript
"use strict";(this.webpackChunkwowok_agent=this.webpackChunkwowok_agent||[]).push([[706],{1075:(t,e,r)=>{r.d(e,{SB:()=>a,jh:()=>i});var s=r(4329),n=r(7059);function i(t){return!!new RegExp("^m\\/44'\\/784'\\/[0-9]+'\\/[0-9]+'\\/[0-9]+'+$").test(t)}function a(t){return(0,s.J)(function(t){return(0,n.kw)(t,"")}(t))}},1646:(t,e,r)=>{r.d(e,{Pz:()=>n,uD:()=>s,y3:()=>i});const s={ED25519:0,Secp256k1:1,Secp256r1:2,MultiSig:3,ZkLogin:5},n={ED25519:32,Secp256k1:33,Secp256r1:33},i={0:"ED25519",1:"Secp256k1",2:"Secp256r1",3:"MultiSig",5:"ZkLogin"}},1789:(t,e,r)=>{r.d(e,{AX:()=>h,At:()=>g,uS:()=>l,yk:()=>m});var s=r(9440),n=r(5412),i=r(5398),a=r(2343),o=r(5762),u=r(1646),c=r(6132);const l=32,d="suiprivkey";class p{async signWithIntent(t,e){const r=(0,o.i)(e,t),n=(0,i.S)(r,{dkLen:32});return{signature:(0,c.C)({signature:await this.sign(n),signatureScheme:this.getKeyScheme(),publicKey:this.getPublicKey()}),bytes:(0,s.o)(t)}}async signTransaction(t){return this.signWithIntent(t,"TransactionData")}async signPersonalMessage(t){const{signature:e}=await this.signWithIntent(n.j.vector(n.j.u8()).serialize(t).toBytes(),"PersonalMessage");return{bytes:(0,s.o)(t),signature:e}}toSuiAddress(){return this.getPublicKey().toSuiAddress()}}class h extends p{}function g(t){const{prefix:e,words:r}=a.I.decode(t);if(e!==d)throw new Error("invalid private key prefix");const s=new Uint8Array(a.I.fromWords(r)),n=s.slice(1);return{schema:u.y3[s[0]],secretKey:n}}function m(t,e){if(t.length!==l)throw new Error("Invalid bytes length");const r=u.uD[e],s=new Uint8Array(t.length+1);return s.set([r]),s.set(t,1),a.I.encode(d,a.I.toWords(s))}},3852:(t,e,r)=>{r.d(e,{r:()=>o});var s=r(7573),n=r(9298);const i=/^vector<(.+)>$/,a=/^([^:]+)::([^:]+)::([^<]+)(<(.+)>)?/;class o{static parseFromStr(t,e=!1){if("address"===t)return{address:null};if("bool"===t)return{bool:null};if("u8"===t)return{u8:null};if("u16"===t)return{u16:null};if("u32"===t)return{u32:null};if("u64"===t)return{u64:null};if("u128"===t)return{u128:null};if("u256"===t)return{u256:null};if("signer"===t)return{signer:null};const r=t.match(i);if(r)return{vector:o.parseFromStr(r[1],e)};const s=t.match(a);if(s)return{struct:{address:e?(0,n.t4)(s[1]):s[1],module:s[2],name:s[3],typeParams:void 0===s[5]?[]:o.parseStructTypeArgs(s[5],e)}};throw new Error(`Encountered unexpected token when parsing type args for ${t}`)}static parseStructTypeArgs(t,e=!1){return(0,s.sT)(t).map((t=>o.parseFromStr(t,e)))}static tagToString(t){if("bool"in t)return"bool";if("u8"in t)return"u8";if("u16"in t)return"u16";if("u32"in t)return"u32";if("u64"in t)return"u64";if("u128"in t)return"u128";if("u256"in t)return"u256";if("address"in t)return"address";if("signer"in t)return"signer";if("vector"in t)return`vector<${o.tagToString(t.vector)}>`;if("struct"in t){const e=t.struct,r=e.typeParams.map(o.tagToString).join(", ");return`${e.address}::${e.module}::${e.name}${r?`<${r}>`:""}`}throw new Error("Invalid TypeTag")}}},4278:(t,e,r)=>{r.d(e,{J:()=>l,O:()=>c});var s=r(9440),n=r(5398),i=r(4976),a=r(4364),o=r(9298),u=r(5762);function c(t,e){if(t===e)return!0;if(t.length!==e.length)return!1;for(let r=0;r<t.length;r++)if(t[r]!==e[r])return!1;return!0}class l{equals(t){return c(this.toRawBytes(),t.toRawBytes())}toBase64(){return(0,s.o)(this.toRawBytes())}toString(){throw new Error("`toString` is not implemented on public keys. Use `toBase64()` or `toRawBytes()` instead.")}toSuiPublicKey(){const t=this.toSuiBytes();return(0,s.o)(t)}verifyWithIntent(t,e,r){const s=(0,u.i)(r,t),i=(0,n.S)(s,{dkLen:32});return this.verify(i,e)}verifyPersonalMessage(t,e){return this.verifyWithIntent(a.jy.vector(a.jy.u8()).serialize(t).toBytes(),e,"PersonalMessage")}verifyTransaction(t,e){return this.verifyWithIntent(t,e,"TransactionData")}toSuiBytes(){const t=this.toRawBytes(),e=new Uint8Array(t.length+1);return e.set([this.flag()]),e.set(t,1),e}toSuiAddress(){return(0,o.t4)((0,i.My)((0,n.S)(this.toSuiBytes(),{dkLen:32})).slice(0,2*o.wn))}}},4364:(t,e,r)=>{r.d(e,{jy:()=>it});var s=r(5412),n=r(4329),i=r(9835),a=r(9440),o=r(9298),u=r(3852);const c=s.j.bytes(o.wn).transform({validate:t=>{const e="string"==typeof t?t:(0,n.J)(t);if(!e||!(0,o.AP)((0,o.t4)(e)))throw new Error(`Invalid Sui address ${e}`)},input:t=>"string"==typeof t?(0,n.i)((0,o.t4)(t)):t,output:t=>(0,o.t4)((0,n.J)(t))}),l=s.j.vector(s.j.u8()).transform({name:"ObjectDigest",input:t=>(0,i.Q)(t),output:t=>(0,i.x)(new Uint8Array(t)),validate:t=>{if(32!==(0,i.Q)(t).length)throw new Error("ObjectDigest must be 32 bytes")}}),d=s.j.struct("SuiObjectRef",{objectId:c,version:s.j.u64(),digest:l}),p=s.j.struct("SharedObjectRef",{objectId:c,initialSharedVersion:s.j.u64(),mutable:s.j.bool()}),h=s.j.enum("ObjectArg",{ImmOrOwnedObject:d,SharedObject:p,Receiving:d}),g=s.j.enum("CallArg",{Pure:s.j.struct("Pure",{bytes:s.j.vector(s.j.u8()).transform({input:t=>"string"==typeof t?(0,a.Z)(t):t,output:t=>(0,a.o)(new Uint8Array(t))})}),Object:h}),m=s.j.enum("TypeTag",{bool:null,u8:null,u64:null,u128:null,address:null,signer:null,vector:s.j.lazy((()=>m)),struct:s.j.lazy((()=>T)),u16:null,u32:null,u256:null}),j=m.transform({input:t=>"string"==typeof t?u.r.parseFromStr(t,!0):t,output:t=>u.r.tagToString(t)}),y=s.j.enum("Argument",{GasCoin:null,Input:s.j.u16(),Result:s.j.u16(),NestedResult:s.j.tuple([s.j.u16(),s.j.u16()])}),w=s.j.struct("ProgrammableMoveCall",{package:c,module:s.j.string(),function:s.j.string(),typeArguments:s.j.vector(j),arguments:s.j.vector(y)}),f=s.j.enum("Command",{MoveCall:w,TransferObjects:s.j.struct("TransferObjects",{objects:s.j.vector(y),address:y}),SplitCoins:s.j.struct("SplitCoins",{coin:y,amounts:s.j.vector(y)}),MergeCoins:s.j.struct("MergeCoins",{destination:y,sources:s.j.vector(y)}),Publish:s.j.struct("Publish",{modules:s.j.vector(s.j.vector(s.j.u8()).transform({input:t=>"string"==typeof t?(0,a.Z)(t):t,output:t=>(0,a.o)(new Uint8Array(t))})),dependencies:s.j.vector(c)}),MakeMoveVec:s.j.struct("MakeMoveVec",{type:(b=j,s.j.enum("Option",{None:null,Some:b})).transform({input:t=>null===t?{None:!0}:{Some:t},output:t=>t.Some??null}),elements:s.j.vector(y)}),Upgrade:s.j.struct("Upgrade",{modules:s.j.vector(s.j.vector(s.j.u8()).transform({input:t=>"string"==typeof t?(0,a.Z)(t):t,output:t=>(0,a.o)(new Uint8Array(t))})),dependencies:s.j.vector(c),package:c,ticket:y})});var b;const S=s.j.struct("ProgrammableTransaction",{inputs:s.j.vector(g),commands:s.j.vector(f)}),v=s.j.enum("TransactionKind",{ProgrammableTransaction:S,ChangeEpoch:null,Genesis:null,ConsensusCommitPrologue:null}),k=s.j.enum("TransactionExpiration",{None:null,Epoch:s.j.u64({name:"unsafe_u64"}).transform({input:t=>t,output:t=>Number(t)})});const T=s.j.struct("StructTag",{address:c,module:s.j.string(),name:s.j.string(),typeParams:s.j.vector(m)}),I=s.j.struct("GasData",{payment:s.j.vector(d),owner:c,price:s.j.u64(),budget:s.j.u64()}),E=s.j.struct("TransactionDataV1",{kind:v,sender:c,gasData:I,expiration:k}),M=s.j.enum("TransactionData",{V1:E}),x=s.j.enum("IntentScope",{TransactionData:null,TransactionEffects:null,CheckpointSummary:null,PersonalMessage:null}),O=s.j.enum("IntentVersion",{V0:null}),A=s.j.enum("AppId",{Sui:null}),C=s.j.struct("Intent",{scope:x,version:O,appId:A});function P(t){return s.j.struct(`IntentMessage<${t.name}>`,{intent:C,value:t})}const B=s.j.enum("CompressedSignature",{ED25519:s.j.fixedArray(64,s.j.u8()),Secp256k1:s.j.fixedArray(64,s.j.u8()),Secp256r1:s.j.fixedArray(64,s.j.u8()),ZkLogin:s.j.vector(s.j.u8())}),q=s.j.enum("PublicKey",{ED25519:s.j.fixedArray(32,s.j.u8()),Secp256k1:s.j.fixedArray(33,s.j.u8()),Secp256r1:s.j.fixedArray(33,s.j.u8()),ZkLogin:s.j.vector(s.j.u8())}),D=s.j.struct("MultiSigPkMap",{pubKey:q,weight:s.j.u8()}),_=s.j.struct("MultiSigPublicKey",{pk_map:s.j.vector(D),threshold:s.j.u16()}),N=s.j.struct("MultiSig",{sigs:s.j.vector(B),bitmap:s.j.u16(),multisig_pk:_}),U=s.j.vector(s.j.u8()).transform({input:t=>"string"==typeof t?(0,a.Z)(t):t,output:t=>(0,a.o)(new Uint8Array(t))}),R=s.j.struct("SenderSignedTransaction",{intentMessage:P(M),txSignatures:s.j.vector(U)}),W=s.j.vector(R,{name:"SenderSignedData"}),V=s.j.enum("PackageUpgradeError",{UnableToFetchPackage:s.j.struct("UnableToFetchPackage",{packageId:c}),NotAPackage:s.j.struct("NotAPackage",{objectId:c}),IncompatibleUpgrade:null,DigestDoesNotMatch:s.j.struct("DigestDoesNotMatch",{digest:s.j.vector(s.j.u8())}),UnknownUpgradePolicy:s.j.struct("UnknownUpgradePolicy",{policy:s.j.u8()}),PackageIDDoesNotMatch:s.j.struct("PackageIDDoesNotMatch",{packageId:c,ticketId:c})}),F=s.j.struct("ModuleId",{address:c,name:s.j.string()}),z=s.j.struct("MoveLocation",{module:F,function:s.j.u16(),instruction:s.j.u16(),functionName:s.j.option(s.j.string())}),L=s.j.enum("CommandArgumentError",{TypeMismatch:null,InvalidBCSBytes:null,InvalidUsageOfPureArg:null,InvalidArgumentToPrivateEntryFunction:null,IndexOutOfBounds:s.j.struct("IndexOutOfBounds",{idx:s.j.u16()}),SecondaryIndexOutOfBounds:s.j.struct("SecondaryIndexOutOfBounds",{resultIdx:s.j.u16(),secondaryIdx:s.j.u16()}),InvalidResultArity:s.j.struct("InvalidResultArity",{resultIdx:s.j.u16()}),InvalidGasCoinUsage:null,InvalidValueUsage:null,InvalidObjectByValue:null,InvalidObjectByMutRef:null,SharedObjectOperationNotAllowed:null}),$=s.j.enum("TypeArgumentError",{TypeNotFound:null,ConstraintNotSatisfied:null}),K=s.j.enum("ExecutionFailureStatus",{InsufficientGas:null,InvalidGasObject:null,InvariantViolation:null,FeatureNotYetSupported:null,MoveObjectTooBig:s.j.struct("MoveObjectTooBig",{objectSize:s.j.u64(),maxObjectSize:s.j.u64()}),MovePackageTooBig:s.j.struct("MovePackageTooBig",{objectSize:s.j.u64(),maxObjectSize:s.j.u64()}),CircularObjectOwnership:s.j.struct("CircularObjectOwnership",{object:c}),InsufficientCoinBalance:null,CoinBalanceOverflow:null,PublishErrorNonZeroAddress:null,SuiMoveVerificationError:null,MovePrimitiveRuntimeError:s.j.option(z),MoveAbort:s.j.tuple([z,s.j.u64()]),VMVerificationOrDeserializationError:null,VMInvariantViolation:null,FunctionNotFound:null,ArityMismatch:null,TypeArityMismatch:null,NonEntryFunctionInvoked:null,CommandArgumentError:s.j.struct("CommandArgumentError",{argIdx:s.j.u16(),kind:L}),TypeArgumentError:s.j.struct("TypeArgumentError",{argumentIdx:s.j.u16(),kind:$}),UnusedValueWithoutDrop:s.j.struct("UnusedValueWithoutDrop",{resultIdx:s.j.u16(),secondaryIdx:s.j.u16()}),InvalidPublicFunctionReturnType:s.j.struct("InvalidPublicFunctionReturnType",{idx:s.j.u16()}),InvalidTransferObject:null,EffectsTooLarge:s.j.struct("EffectsTooLarge",{currentSize:s.j.u64(),maxSize:s.j.u64()}),PublishUpgradeMissingDependency:null,PublishUpgradeDependencyDowngrade:null,PackageUpgradeError:s.j.struct("PackageUpgradeError",{upgradeError:V}),WrittenObjectsTooLarge:s.j.struct("WrittenObjectsTooLarge",{currentSize:s.j.u64(),maxSize:s.j.u64()}),CertificateDenied:null,SuiMoveVerificationTimedout:null,SharedObjectOperationNotAllowed:null,InputObjectDeleted:null}),G=s.j.enum("ExecutionStatus",{Success:null,Failed:s.j.struct("ExecutionFailed",{error:K,command:s.j.option(s.j.u64())})}),Z=s.j.struct("GasCostSummary",{computationCost:s.j.u64(),storageCost:s.j.u64(),storageRebate:s.j.u64(),nonRefundableStorageFee:s.j.u64()}),J=s.j.enum("Owner",{AddressOwner:c,ObjectOwner:c,Shared:s.j.struct("Shared",{initialSharedVersion:s.j.u64()}),Immutable:null}),Q=s.j.struct("TransactionEffectsV1",{status:G,executedEpoch:s.j.u64(),gasUsed:Z,modifiedAtVersions:s.j.vector(s.j.tuple([c,s.j.u64()])),sharedObjects:s.j.vector(d),transactionDigest:l,created:s.j.vector(s.j.tuple([d,J])),mutated:s.j.vector(s.j.tuple([d,J])),unwrapped:s.j.vector(s.j.tuple([d,J])),deleted:s.j.vector(d),unwrappedThenDeleted:s.j.vector(d),wrapped:s.j.vector(d),gasObject:s.j.tuple([d,J]),eventsDigest:s.j.option(l),dependencies:s.j.vector(l)}),H=s.j.tuple([s.j.u64(),l]),Y=s.j.enum("ObjectIn",{NotExist:null,Exist:s.j.tuple([H,J])}),X=s.j.enum("ObjectOut",{NotExist:null,ObjectWrite:s.j.tuple([l,J]),PackageWrite:H}),tt=s.j.enum("IDOperation",{None:null,Created:null,Deleted:null}),et=s.j.struct("EffectsObjectChange",{inputState:Y,outputState:X,idOperation:tt}),rt=s.j.enum("UnchangedSharedKind",{ReadOnlyRoot:H,MutateDeleted:s.j.u64(),ReadDeleted:s.j.u64(),Cancelled:s.j.u64(),PerEpochConfig:null}),st=s.j.struct("TransactionEffectsV2",{status:G,executedEpoch:s.j.u64(),gasUsed:Z,transactionDigest:l,gasObjectIndex:s.j.option(s.j.u32()),eventsDigest:s.j.option(l),dependencies:s.j.vector(l),lamportVersion:s.j.u64(),changedObjects:s.j.vector(s.j.tuple([c,et])),unchangedSharedObjects:s.j.vector(s.j.tuple([c,rt])),auxDataDigest:s.j.option(l)}),nt=s.j.enum("TransactionEffects",{V1:Q,V2:st}),it={...s.j,U8:s.j.u8(),U16:s.j.u16(),U32:s.j.u32(),U64:s.j.u64(),U128:s.j.u128(),U256:s.j.u256(),ULEB128:s.j.uleb128(),Bool:s.j.bool(),String:s.j.string(),Address:c,AppId:A,Argument:y,CallArg:g,CompressedSignature:B,GasData:I,Intent:C,IntentMessage:P,IntentScope:x,IntentVersion:O,MultiSig:N,MultiSigPkMap:D,MultiSigPublicKey:_,ObjectArg:h,ObjectDigest:l,ProgrammableMoveCall:w,ProgrammableTransaction:S,PublicKey:q,SenderSignedData:W,SenderSignedTransaction:R,SharedObjectRef:p,StructTag:T,SuiObjectRef:d,Command:f,TransactionData:M,TransactionDataV1:E,TransactionExpiration:k,TransactionKind:v,TypeTag:j,TransactionEffects:nt}},5762:(t,e,r)=>{r.d(e,{i:()=>n});var s=r(4364);function n(t,e){return s.jy.IntentMessage(s.jy.fixedArray(e.length,s.jy.u8())).serialize({intent:{scope:{[t]:!0},version:{V0:!0},appId:{Sui:!0}},value:e}).toBytes()}},6132:(t,e,r)=>{r.d(e,{C:()=>o,Y:()=>u});var s=r(9440),n=r(4364),i=r(6092),a=r(1646);function o({signature:t,signatureScheme:e,publicKey:r}){if(!r)throw new Error("`publicKey` is required");const n=r.toRawBytes(),i=new Uint8Array(1+t.length+n.length);return i.set([a.uD[e]]),i.set(t,1),i.set(n,1+t.length),(0,s.o)(i)}function u(t){const e=(0,s.Z)(t),r=a.y3[e[0]];switch(r){case"MultiSig":return{serializedSignature:t,signatureScheme:r,multisig:n.jy.MultiSig.parse(e.slice(1)),bytes:e};case"ZkLogin":return(0,i.eu)(t);case"ED25519":case"Secp256k1":case"Secp256r1":const s=a.Pz[r],o=e.slice(1,e.length-s);return{serializedSignature:t,signatureScheme:r,signature:o,publicKey:e.slice(1+o.length),bytes:e};default:throw new Error("Unsupported signature scheme")}}},9635:(t,e,r)=>{r.d(e,{x:()=>L});var s=r(9440),n=r(9835),i=r(4329),a=r(8278),o=r(9298),u=r(801),c=r(99);const l={"-32700":"ParseError","-32701":"OversizedRequest","-32702":"OversizedResponse","-32600":"InvalidRequest","-32601":"MethodNotFound","-32602":"InvalidParams","-32603":"InternalError","-32604":"ServerBusy","-32000":"CallExecutionFailed","-32001":"UnknownError","-32003":"SubscriptionClosed","-32004":"SubscriptionClosedWithError","-32005":"BatchesNotSupported","-32006":"TooManySubscriptions","-32050":"TransientError","-32002":"TransactionExecutionClientError"};class d extends Error{}class p extends d{constructor(t,e){super(t),this.code=e,this.type=l[e]??"ServerError"}}class h extends d{constructor(t,e,r){super(t),this.status=e,this.statusText=r}}var g,m,j,y,w,f,b,S,v,k=t=>{throw TypeError(t)},T=(t,e,r)=>e.has(t)||k("Cannot "+r),I=(t,e,r)=>(T(t,e,"read from private field"),r?r.call(t):e.get(t)),E=(t,e,r)=>e.has(t)?k("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(t):e.set(t,r),M=(t,e,r,s)=>(T(t,e,"write to private field"),s?s.call(t,r):e.set(t,r),r),x=(t,e,r)=>(T(t,e,"access private method"),r);const O={WebSocketConstructor:"undefined"!=typeof WebSocket?WebSocket:void 0,callTimeout:3e4,reconnectTimeout:3e3,maxReconnects:5};class A{constructor(t,e={}){if(E(this,b),E(this,g,0),E(this,m,0),E(this,j,null),E(this,y,null),E(this,w,new Set),E(this,f,new Map),this.endpoint=t,this.options={...O,...e},!this.options.WebSocketConstructor)throw new Error("Missing WebSocket constructor");this.endpoint.startsWith("http")&&(this.endpoint=function(t){const e=new URL(t);return e.protocol=e.protocol.replace("http","ws"),e.toString()}(this.endpoint))}async makeRequest(t,e){const r=await x(this,b,S).call(this);return new Promise(((s,n)=>{M(this,g,I(this,g)+1),I(this,f).set(I(this,g),{resolve:s,reject:n,timeout:setTimeout((()=>{I(this,f).delete(I(this,g)),n(new Error(`Request timeout: ${t}`))}),this.options.callTimeout)}),r.send(JSON.stringify({jsonrpc:"2.0",id:I(this,g),method:t,params:e}))})).then((({error:t,result:e})=>{if(t)throw new p(t.message,t.code);return e}))}async subscribe(t){const e=new C(t);return I(this,w).add(e),await e.subscribe(this),()=>e.unsubscribe(this)}}g=new WeakMap,m=new WeakMap,j=new WeakMap,y=new WeakMap,w=new WeakMap,f=new WeakMap,b=new WeakSet,S=function(){return I(this,y)||M(this,y,new Promise((t=>{I(this,j)?.close(),M(this,j,new this.options.WebSocketConstructor(this.endpoint)),I(this,j).addEventListener("open",(()=>{M(this,m,0),t(I(this,j))})),I(this,j).addEventListener("close",(()=>{var t,e;(t=this,e=m,{set _(r){M(t,e,r,undefined)},get _(){return I(t,e,undefined)}})._++,I(this,m)<=this.options.maxReconnects&&setTimeout((()=>{x(this,b,v).call(this)}),this.options.reconnectTimeout)})),I(this,j).addEventListener("message",(({data:t})=>{let e;try{e=JSON.parse(t)}catch(e){return void console.error(new Error(`Failed to parse RPC message: ${t}`,{cause:e}))}if("id"in e&&null!=e.id&&I(this,f).has(e.id)){const{resolve:t,timeout:r}=I(this,f).get(e.id);clearTimeout(r),t(e)}else if("params"in e){const{params:t}=e;I(this,w).forEach((e=>{e.subscriptionId===t.subscription&&t.subscription===e.subscriptionId&&e.onMessage(t.result)}))}}))}))),I(this,y)},v=async function(){return I(this,j)?.close(),M(this,y,null),Promise.allSettled([...I(this,w)].map((t=>t.subscribe(this))))};class C{constructor(t){this.subscriptionId=null,this.subscribed=!1,this.input=t}onMessage(t){this.subscribed&&this.input.onMessage(t)}async unsubscribe(t){const{subscriptionId:e}=this;return this.subscribed=!1,null!=e&&(this.subscriptionId=null,t.makeRequest(this.input.unsubscribe,[e]))}async subscribe(t){this.subscriptionId=null,this.subscribed=!0;const e=await t.makeRequest(this.input.method,this.input.params);this.subscribed&&(this.subscriptionId=e)}}var P,B,q,D,_,N=t=>{throw TypeError(t)},U=(t,e,r)=>e.has(t)||N("Cannot "+r),R=(t,e,r)=>(U(t,e,"read from private field"),r?r.call(t):e.get(t)),W=(t,e,r)=>e.has(t)?N("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(t):e.set(t,r),V=(t,e,r,s)=>(U(t,e,"write to private field"),s?s.call(t,r):e.set(t,r),r);class F{constructor(t){W(this,D),W(this,P,0),W(this,B),W(this,q),V(this,B,t)}fetch(t,e){const r=R(this,B).fetch??fetch;if(!r)throw new Error("The current environment does not support fetch, you can provide a fetch implementation in the options for SuiHTTPTransport.");return r(t,e)}async request(t){V(this,P,R(this,P)+1);const e=await this.fetch(R(this,B).rpc?.url??R(this,B).url,{method:"POST",headers:{"Content-Type":"application/json","Client-Sdk-Type":"typescript","Client-Sdk-Version":c.i,"Client-Target-Api-Version":c.c,...R(this,B).rpc?.headers},body:JSON.stringify({jsonrpc:"2.0",id:R(this,P),method:t.method,params:t.params})});if(!e.ok)throw new h(`Unexpected status code: ${e.status}`,e.status,e.statusText);const r=await e.json();if("error"in r&&null!=r.error)throw new p(r.error.message,r.error.code);return r.result}async subscribe(t){const e=await(r=D,s=_,U(this,r,"access private method"),s).call(this).subscribe(t);var r,s;return async()=>!!await e()}}P=new WeakMap,B=new WeakMap,q=new WeakMap,D=new WeakSet,_=function(){if(!R(this,q)){const t=R(this,B).WebSocketConstructor??WebSocket;if(!t)throw new Error("The current environment does not support WebSocket, you can provide a WebSocketConstructor in the options for SuiHTTPTransport.");V(this,q,new A(R(this,B).websocket?.url??R(this,B).url,{WebSocketConstructor:t,...R(this,B).websocket}))}return R(this,q)};const z=Symbol.for("@mysten/SuiClient");class L{get[z](){return!0}constructor(t){this.transport=t.transport??new F({url:t.url})}async getRpcApiVersion(){return(await this.transport.request({method:"rpc.discover",params:[]})).info.version}async getCoins(t){if(!t.owner||!(0,o.AP)((0,o.t4)(t.owner)))throw new Error("Invalid Sui address");return await this.transport.request({method:"suix_getCoins",params:[t.owner,t.coinType,t.cursor,t.limit]})}async getAllCoins(t){if(!t.owner||!(0,o.AP)((0,o.t4)(t.owner)))throw new Error("Invalid Sui address");return await this.transport.request({method:"suix_getAllCoins",params:[t.owner,t.cursor,t.limit]})}async getBalance(t){if(!t.owner||!(0,o.AP)((0,o.t4)(t.owner)))throw new Error("Invalid Sui address");return await this.transport.request({method:"suix_getBalance",params:[t.owner,t.coinType]})}async getAllBalances(t){if(!t.owner||!(0,o.AP)((0,o.t4)(t.owner)))throw new Error("Invalid Sui address");return await this.transport.request({method:"suix_getAllBalances",params:[t.owner]})}async getCoinMetadata(t){return await this.transport.request({method:"suix_getCoinMetadata",params:[t.coinType]})}async getTotalSupply(t){return await this.transport.request({method:"suix_getTotalSupply",params:[t.coinType]})}async call(t,e){return await this.transport.request({method:t,params:e})}async getMoveFunctionArgTypes(t){return await this.transport.request({method:"sui_getMoveFunctionArgTypes",params:[t.package,t.module,t.function]})}async getNormalizedMoveModulesByPackage(t){return await this.transport.request({method:"sui_getNormalizedMoveModulesByPackage",params:[t.package]})}async getNormalizedMoveModule(t){return await this.transport.request({method:"sui_getNormalizedMoveModule",params:[t.package,t.module]})}async getNormalizedMoveFunction(t){return await this.transport.request({method:"sui_getNormalizedMoveFunction",params:[t.package,t.module,t.function]})}async getNormalizedMoveStruct(t){return await this.transport.request({method:"sui_getNormalizedMoveStruct",params:[t.package,t.module,t.struct]})}async getOwnedObjects(t){if(!t.owner||!(0,o.AP)((0,o.t4)(t.owner)))throw new Error("Invalid Sui address");return await this.transport.request({method:"suix_getOwnedObjects",params:[t.owner,{filter:t.filter,options:t.options},t.cursor,t.limit]})}async getObject(t){if(!t.id||!(0,o.qD)((0,o.fN)(t.id)))throw new Error("Invalid Sui Object id");return await this.transport.request({method:"sui_getObject",params:[t.id,t.options]})}async tryGetPastObject(t){return await this.transport.request({method:"sui_tryGetPastObject",params:[t.id,t.version,t.options]})}async multiGetObjects(t){if(t.ids.forEach((t=>{if(!t||!(0,o.qD)((0,o.fN)(t)))throw new Error(`Invalid Sui Object id ${t}`)})),t.ids.length!==new Set(t.ids).size)throw new Error(`Duplicate object ids in batch call ${t.ids}`);return await this.transport.request({method:"sui_multiGetObjects",params:[t.ids,t.options]})}async queryTransactionBlocks(t){return await this.transport.request({method:"suix_queryTransactionBlocks",params:[{filter:t.filter,options:t.options},t.cursor,t.limit,"descending"===(t.order||"descending")]})}async getTransactionBlock(t){if(!(0,o.n4)(t.digest))throw new Error("Invalid Transaction digest");return await this.transport.request({method:"sui_getTransactionBlock",params:[t.digest,t.options]})}async multiGetTransactionBlocks(t){if(t.digests.forEach((t=>{if(!(0,o.n4)(t))throw new Error(`Invalid Transaction digest ${t}`)})),t.digests.length!==new Set(t.digests).size)throw new Error(`Duplicate digests in batch call ${t.digests}`);return await this.transport.request({method:"sui_multiGetTransactionBlocks",params:[t.digests,t.options]})}async executeTransactionBlock({transactionBlock:t,signature:e,options:r,requestType:n}){const i=await this.transport.request({method:"sui_executeTransactionBlock",params:["string"==typeof t?t:(0,s.o)(t),Array.isArray(e)?e:[e],r]});if("WaitForLocalExecution"===n)try{await this.waitForTransaction({digest:i.digest})}catch(t){}return i}async signAndExecuteTransaction({transaction:t,signer:e,...r}){let s;t instanceof Uint8Array?s=t:(t.setSenderIfNotSet(e.toSuiAddress()),s=await t.build({client:this}));const{signature:n,bytes:i}=await e.signTransaction(s);return this.executeTransactionBlock({transactionBlock:i,signature:n,...r})}async getTotalTransactionBlocks(){const t=await this.transport.request({method:"sui_getTotalTransactionBlocks",params:[]});return BigInt(t)}async getReferenceGasPrice(){const t=await this.transport.request({method:"suix_getReferenceGasPrice",params:[]});return BigInt(t)}async getStakes(t){if(!t.owner||!(0,o.AP)((0,o.t4)(t.owner)))throw new Error("Invalid Sui address");return await this.transport.request({method:"suix_getStakes",params:[t.owner]})}async getStakesByIds(t){return t.stakedSuiIds.forEach((t=>{if(!t||!(0,o.qD)((0,o.fN)(t)))throw new Error(`Invalid Sui Stake id ${t}`)})),await this.transport.request({method:"suix_getStakesByIds",params:[t.stakedSuiIds]})}async getLatestSuiSystemState(){return await this.transport.request({method:"suix_getLatestSuiSystemState",params:[]})}async queryEvents(t){return await this.transport.request({method:"suix_queryEvents",params:[t.query,t.cursor,t.limit,"descending"===(t.order||"descending")]})}async subscribeEvent(t){return this.transport.subscribe({method:"suix_subscribeEvent",unsubscribe:"suix_unsubscribeEvent",params:[t.filter],onMessage:t.onMessage})}async subscribeTransaction(t){return this.transport.subscribe({method:"suix_subscribeTransaction",unsubscribe:"suix_unsubscribeTransaction",params:[t.filter],onMessage:t.onMessage})}async devInspectTransactionBlock(t){let e;if((0,a.b)(t.transactionBlock))t.transactionBlock.setSenderIfNotSet(t.sender),e=(0,s.o)(await t.transactionBlock.build({client:this,onlyTransactionKind:!0}));else if("string"==typeof t.transactionBlock)e=t.transactionBlock;else{if(!(t.transactionBlock instanceof Uint8Array))throw new Error("Unknown transaction block format.");e=(0,s.o)(t.transactionBlock)}return await this.transport.request({method:"sui_devInspectTransactionBlock",params:[t.sender,e,t.gasPrice?.toString(),t.epoch]})}async dryRunTransactionBlock(t){return await this.transport.request({method:"sui_dryRunTransactionBlock",params:["string"==typeof t.transactionBlock?t.transactionBlock:(0,s.o)(t.transactionBlock)]})}async getDynamicFields(t){if(!t.parentId||!(0,o.qD)((0,o.fN)(t.parentId)))throw new Error("Invalid Sui Object id");return await this.transport.request({method:"suix_getDynamicFields",params:[t.parentId,t.cursor,t.limit]})}async getDynamicFieldObject(t){return await this.transport.request({method:"suix_getDynamicFieldObject",params:[t.parentId,t.name]})}async getLatestCheckpointSequenceNumber(){const t=await this.transport.request({method:"sui_getLatestCheckpointSequenceNumber",params:[]});return String(t)}async getCheckpoint(t){return await this.transport.request({method:"sui_getCheckpoint",params:[t.id]})}async getCheckpoints(t){return await this.transport.request({method:"sui_getCheckpoints",params:[t.cursor,t?.limit,t.descendingOrder]})}async getCommitteeInfo(t){return await this.transport.request({method:"suix_getCommitteeInfo",params:[t?.epoch]})}async getNetworkMetrics(){return await this.transport.request({method:"suix_getNetworkMetrics",params:[]})}async getAddressMetrics(){return await this.transport.request({method:"suix_getLatestAddressMetrics",params:[]})}async getEpochMetrics(t){return await this.transport.request({method:"suix_getEpochMetrics",params:[t?.cursor,t?.limit,t?.descendingOrder]})}async getAllEpochAddressMetrics(t){return await this.transport.request({method:"suix_getAllEpochAddressMetrics",params:[t?.descendingOrder]})}async getEpochs(t){return await this.transport.request({method:"suix_getEpochs",params:[t?.cursor,t?.limit,t?.descendingOrder]})}async getMoveCallMetrics(){return await this.transport.request({method:"suix_getMoveCallMetrics",params:[]})}async getCurrentEpoch(){return await this.transport.request({method:"suix_getCurrentEpoch",params:[]})}async getValidatorsApy(){return await this.transport.request({method:"suix_getValidatorsApy",params:[]})}async getChainIdentifier(){const t=await this.getCheckpoint({id:"0"}),e=(0,n.Q)(t.digest);return(0,i.J)(e.slice(0,4))}async resolveNameServiceAddress(t){return await this.transport.request({method:"suix_resolveNameServiceAddress",params:[t.name]})}async resolveNameServiceNames({format:t="dot",...e}){const{nextCursor:r,hasNextPage:s,data:n}=await this.transport.request({method:"suix_resolveNameServiceNames",params:[e.address,e.cursor,e.limit]});return{hasNextPage:s,nextCursor:r,data:n.map((e=>(0,u.n)(e,t)))}}async getProtocolConfig(t){return await this.transport.request({method:"sui_getProtocolConfig",params:[t?.version]})}async waitForTransaction({signal:t,timeout:e=6e4,pollInterval:r=2e3,...s}){const n=AbortSignal.timeout(e),i=new Promise(((t,e)=>{n.addEventListener("abort",(()=>e(n.reason)))}));for(i.catch((()=>{}));!n.aborted;){t?.throwIfAborted();try{return await this.getTransactionBlock(s)}catch(t){await Promise.race([new Promise((t=>setTimeout(t,r))),i])}}throw n.throwIfAborted(),new Error("Unexpected error while waiting for transaction block.")}}}}]);