UNPKG

wowok_agent

Version:

Create, collaborate, and transact on your own terms with the AI-driven web3 collaboration protocol.

1 lines 17 kB
"use strict";(this.webpackChunkwowok_agent=this.webpackChunkwowok_agent||[]).push([[658],{2748:(e,t,n)=>{n.d(t,{G:()=>i});var s=n(9440),r=n(9298);const i={Pure:function(e){return{$kind:"Pure",Pure:{bytes:e instanceof Uint8Array?(0,s.o)(e):e.toBase64()}}},ObjectRef:({objectId:e,digest:t,version:n})=>({$kind:"Object",Object:{$kind:"ImmOrOwnedObject",ImmOrOwnedObject:{digest:t,version:n,objectId:(0,r.t4)(e)}}}),SharedObjectRef:({objectId:e,mutable:t,initialSharedVersion:n})=>({$kind:"Object",Object:{$kind:"SharedObject",SharedObject:{mutable:t,initialSharedVersion:n,objectId:(0,r.t4)(e)}}}),ReceivingRef:({objectId:e,digest:t,version:n})=>({$kind:"Object",Object:{$kind:"Receiving",Receiving:{digest:t,version:n,objectId:(0,r.t4)(e)}}})}},3274:(e,t,n)=>{n.d(t,{A:()=>g});var s,r,i,a,o=n(9770),c=e=>{throw TypeError(e)},d=(e,t,n)=>t.has(e)||c("Cannot "+n),u=(e,t,n)=>(d(e,t,"read from private field"),n?n.call(e):t.get(e)),h=(e,t,n)=>t.has(e)?c("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),l=(e,t,n,s)=>(d(e,t,"write to private field"),s?s.call(e,n):t.set(e,n),n);class p extends Error{}class g{constructor({url:e,fetch:t=fetch,headers:n={},queries:o={}}){h(this,s),h(this,r),h(this,i),h(this,a),l(this,s,e),l(this,r,o),l(this,i,n),l(this,a,((...e)=>t(...e)))}async query(e){const t=await u(this,a).call(this,u(this,s),{method:"POST",headers:{"Content-Type":"application/json",...u(this,i)},body:JSON.stringify({query:"string"==typeof e.query?String(e.query):(0,o.y)(e.query),variables:e.variables,extensions:e.extensions,operationName:e.operationName})});if(!t.ok)throw new p(`GraphQL request failed: ${t.statusText} (${t.status})`);return await t.json()}async execute(e,t){return this.query({...t,query:u(this,r)[e]})}}s=new WeakMap,r=new WeakMap,i=new WeakMap,a=new WeakMap},7745:(e,t,n)=>{n.d(t,{UG:()=>s});const s=(0,n(2439).Se)()},8091:(e,t,n)=>{n.d(t,{h:()=>b});var s=n(8947),r=n(1789),i=n(1075),a=n(4329),o=n(1454),c=n(2341);const d=new RegExp("^m(\\/[0-9]+')+$"),u=e=>e.replace("'",""),h=(e,t,n=2147483648)=>{if(!(e=>!!d.test(e)&&!e.split("/").slice(1).map(u).some(isNaN))(e))throw new Error("Invalid derivation path");const{key:s,chainCode:r}=(e=>{const t=o.w.create(c.Zf,"ed25519 seed").update((0,a.i)(e)).digest();return{key:t.slice(0,32),chainCode:t.slice(32)}})(t);return e.split("/").slice(1).map(u).map((e=>parseInt(e,10))).reduce(((e,t)=>(({key:e,chainCode:t},n)=>{const s=new ArrayBuffer(4);new DataView(s).setUint32(0,n);const r=new Uint8Array(1+e.length+s.byteLength);r.set(new Uint8Array(1).fill(0)),r.set(e,1),r.set(new Uint8Array(s,0,s.byteLength),e.length+1);const i=o.w.create(c.Zf,t).update(r).digest();return{key:i.slice(0,32),chainCode:i.slice(32)}})(e,t+n)),{key:s,chainCode:r})};var l=n(9440),p=n(4278),g=n(1646),f=n(6132);class m extends p.J{constructor(e){if(super(),"string"==typeof e?this.data=(0,l.Z)(e):e instanceof Uint8Array?this.data=e:this.data=Uint8Array.from(e),32!==this.data.length)throw new Error(`Invalid public key input. Expected 32 bytes, got ${this.data.length}`)}equals(e){return super.equals(e)}toRawBytes(){return this.data}flag(){return g.uD.ED25519}async verify(e,t){let n;if("string"==typeof t){const e=(0,f.Y)(t);if("ED25519"!==e.signatureScheme)throw new Error("Invalid signature scheme");if(!(0,p.O)(this.toRawBytes(),e.publicKey))throw new Error("Signature does not match public key");n=e.signature}else n=t;return s.sign.detached.verify(e,n,this.toRawBytes())}}m.SIZE=32;const y="m/44'/784'/0'/0'/0'";class b extends r.AX{constructor(e){super(),this.keypair=e||s.sign.keyPair()}getKeyScheme(){return"ED25519"}static generate(){return new b(s.sign.keyPair())}static fromSecretKey(e,t){const n=e.length;if(n!==r.uS)throw new Error(`Wrong secretKey size. Expected ${r.uS} bytes, got ${n}.`);const i=s.sign.keyPair.fromSeed(e);if(!t||!t.skipValidation){const e=(new TextEncoder).encode("sui validation"),t=s.sign.detached(e,i.secretKey);if(!s.sign.detached.verify(e,t,i.publicKey))throw new Error("provided secretKey is invalid")}return new b(i)}getPublicKey(){return new m(this.keypair.publicKey)}getSecretKey(){return(0,r.yk)(this.keypair.secretKey.slice(0,r.uS),this.getKeyScheme())}async sign(e){return s.sign.detached(e,this.keypair.secretKey)}static deriveKeypair(e,t){if(null==t&&(t=y),!(0,i.jh)(t))throw new Error("Invalid derivation path");const{key:n}=h(t,(0,i.SB)(e));return b.fromSecretKey(n)}static deriveKeypairFromSeed(e,t){if(null==t&&(t=y),!(0,i.jh)(t))throw new Error("Invalid derivation path");const{key:n}=h(t,e);return b.fromSecretKey(n)}}},8278:(e,t,n)=>{n.d(t,{Z:()=>z,b:()=>U});var s=n(9440),r=n(621),i=n(8620),a=n(9298),o=n(1801);const c={MoveCall(e){const[t,n="",s=""]="target"in e?e.target.split("::"):[e.package,e.module,e.function];return{$kind:"MoveCall",MoveCall:{package:t,module:n,function:s,typeArguments:e.typeArguments??[],arguments:e.arguments??[]}}},TransferObjects:(e,t)=>({$kind:"TransferObjects",TransferObjects:{objects:e.map((e=>(0,i.qgA)(o.ef,e))),address:(0,i.qgA)(o.ef,t)}}),SplitCoins:(e,t)=>({$kind:"SplitCoins",SplitCoins:{coin:(0,i.qgA)(o.ef,e),amounts:t.map((e=>(0,i.qgA)(o.ef,e)))}}),MergeCoins:(e,t)=>({$kind:"MergeCoins",MergeCoins:{destination:(0,i.qgA)(o.ef,e),sources:t.map((e=>(0,i.qgA)(o.ef,e)))}}),Publish:({modules:e,dependencies:t})=>({$kind:"Publish",Publish:{modules:e.map((e=>"string"==typeof e?e:(0,s.o)(new Uint8Array(e)))),dependencies:t.map((e=>(0,a.fN)(e)))}}),Upgrade:({modules:e,dependencies:t,package:n,ticket:r})=>({$kind:"Upgrade",Upgrade:{modules:e.map((e=>"string"==typeof e?e:(0,s.o)(new Uint8Array(e)))),dependencies:t.map((e=>(0,a.fN)(e))),package:n,ticket:(0,i.qgA)(o.ef,r)}}),MakeMoveVec:({type:e,elements:t})=>({$kind:"MakeMoveVec",MakeMoveVec:{type:e??null,elements:t.map((e=>(0,i.qgA)(o.ef,e)))}}),Intent:({name:e,inputs:t={},data:n={}})=>({$kind:"$Intent",$Intent:{name:e,inputs:Object.fromEntries(Object.entries(t).map((([e,t])=>[e,Array.isArray(t)?t.map((e=>(0,i.qgA)(o.ef,e))):(0,i.qgA)(o.ef,t)]))),data:n}})};var d=n(9793),u=n(9800),h=n(2748),l=n(8116),p=n(8978),g=n(747),f=n(9835),m=n(4364),y=n(8377);function b(e){return(0,a.t4)(e).replace("0x","")}class w{constructor(e){this.version=2,this.sender=e?.sender??null,this.expiration=e?.expiration??null,this.inputs=e?.inputs??[],this.commands=e?.commands??[],this.gasData=e?.gasData??{budget:null,price:null,owner:null,payment:null}}static fromKindBytes(e){const t=m.jy.TransactionKind.parse(e).ProgrammableTransaction;if(!t)throw new Error("Unable to deserialize from bytes.");return w.restore({version:2,sender:null,expiration:null,gasData:{budget:null,owner:null,payment:null,price:null},inputs:t.inputs,commands:t.commands})}static fromBytes(e){const t=m.jy.TransactionData.parse(e),n=t?.V1,s=n.kind.ProgrammableTransaction;if(!n||!s)throw new Error("Unable to deserialize from bytes.");return w.restore({version:2,sender:n.sender,expiration:n.expiration,gasData:n.gasData,inputs:s.inputs,commands:s.commands})}static restore(e){return 2===e.version?new w((0,i.qgA)(o.pl,e)):new w((0,i.qgA)(o.pl,(0,d.ef)(e)))}static getDigestFromBytes(e){const t=(0,y.Z)("TransactionData",e);return(0,f.x)(t)}get gasConfig(){return this.gasData}set gasConfig(e){this.gasData=e}build({maxSizeBytes:e=1/0,overrides:t,onlyTransactionKind:n}={}){const s=this.inputs,r=this.commands,i={ProgrammableTransaction:{inputs:s,commands:r}};if(n)return m.jy.TransactionKind.serialize(i,{maxSize:e}).toBytes();const a=t?.expiration??this.expiration,o=t?.sender??this.sender,c={...this.gasData,...t?.gasConfig,...t?.gasData};if(!o)throw new Error("Missing transaction sender");if(!c.budget)throw new Error("Missing gas budget");if(!c.payment)throw new Error("Missing gas payment");if(!c.price)throw new Error("Missing gas price");const d={sender:b(o),expiration:a||{None:!0},gasData:{payment:c.payment,owner:b(this.gasData.owner??o),price:BigInt(c.price),budget:BigInt(c.budget)},kind:{ProgrammableTransaction:{inputs:s,commands:r}}};return m.jy.TransactionData.serialize({V1:d},{maxSize:e}).toBytes()}addInput(e,t){const n=this.inputs.length;return this.inputs.push(t),{Input:n,type:e,$kind:"Input"}}getInputUses(e,t){this.mapArguments(((n,s)=>("Input"===n.$kind&&n.Input===e&&t(n,s),n)))}mapArguments(e){for(const t of this.commands)switch(t.$kind){case"MoveCall":t.MoveCall.arguments=t.MoveCall.arguments.map((n=>e(n,t)));break;case"TransferObjects":t.TransferObjects.objects=t.TransferObjects.objects.map((n=>e(n,t))),t.TransferObjects.address=e(t.TransferObjects.address,t);break;case"SplitCoins":t.SplitCoins.coin=e(t.SplitCoins.coin,t),t.SplitCoins.amounts=t.SplitCoins.amounts.map((n=>e(n,t)));break;case"MergeCoins":t.MergeCoins.destination=e(t.MergeCoins.destination,t),t.MergeCoins.sources=t.MergeCoins.sources.map((n=>e(n,t)));break;case"MakeMoveVec":t.MakeMoveVec.elements=t.MakeMoveVec.elements.map((n=>e(n,t)));break;case"Upgrade":t.Upgrade.ticket=e(t.Upgrade.ticket,t);break;case"$Intent":const n=t.$Intent.inputs;t.$Intent.inputs={};for(const[s,r]of Object.entries(n))t.$Intent.inputs[s]=Array.isArray(r)?r.map((n=>e(n,t))):e(r,t);break;case"Publish":break;default:throw new Error(`Unexpected transaction kind: ${t.$kind}`)}}replaceCommand(e,t){if(!Array.isArray(t))return void(this.commands[e]=t);const n=t.length-1;this.commands.splice(e,1,...t),0!==n&&this.mapArguments((t=>{switch(t.$kind){case"Result":t.Result>e&&(t.Result+=n);break;case"NestedResult":t.NestedResult[0]>e&&(t.NestedResult[0]+=n)}return t}))}getDigest(){const e=this.build({onlyTransactionKind:!1});return w.getDigestFromBytes(e)}snapshot(){return(0,i.qgA)(o.pl,this)}}var k,j,v,S,O,C,$,M,A,I=n(7668),P=e=>{throw TypeError(e)},E=(e,t,n)=>t.has(e)||P("Cannot "+n),T=(e,t,n)=>(E(e,t,"read from private field"),n?n.call(e):t.get(e)),x=(e,t,n)=>t.has(e)?P("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),R=(e,t,n,s)=>(E(e,t,"write to private field"),s?s.call(e,n):t.set(e,n),n),q=(e,t,n)=>(E(e,t,"access private method"),n);const D=Symbol.for("@mysten/transaction");function U(e){return!!e&&"object"==typeof e&&!0===e[D]}const K={buildPlugins:[],serializationPlugins:[]},N=Symbol.for("@mysten/transaction/registry");function B(){try{const e=globalThis;return e[N]||(e[N]=K),e[N]}catch(e){return K}}k=new WeakMap,j=new WeakMap,v=new WeakMap,S=new WeakMap,O=new WeakSet,C=function(e){return(0,r.d_)(e)?this.pure(e):q(this,O,$).call(this,e)},$=function(e){return"function"==typeof e?(0,i.qgA)(o.ef,e(this)):(0,i.qgA)(o.ef,e)},M=async function(e){if(!e.onlyTransactionKind&&!T(this,S).sender)throw new Error("Missing transaction sender");await q(this,O,A).call(this,[...T(this,j),l.J],e)},A=async function(e,t){const n=s=>{if(s>=e.length)return()=>{};const r=e[s];return async()=>{const e=n(s+1);let i=!1,a=!1;if(await r(T(this,S),t,(async()=>{if(i)throw new Error(`next() was call multiple times in TransactionPlugin ${s}`);i=!0,await e(),a=!0})),!i)throw new Error(`next() was not called in TransactionPlugin ${s}`);if(!a)throw new Error(`next() was not awaited in TransactionPlugin ${s}`)}};await n(0)()};let z=class e{constructor(){x(this,O),x(this,k),x(this,j),x(this,v,new Map),x(this,S),this.object=(0,p.O)((e=>{if("function"==typeof e)return this.object(e(this));if("object"==typeof e&&(0,i.is)(o.ef,e))return e;const t=(0,I._t)(e),n=T(this,S).inputs.find((e=>t===(0,I._t)(e)));return n?.Object?.SharedObject&&"object"==typeof e&&e.Object?.SharedObject&&(n.Object.SharedObject.mutable=n.Object.SharedObject.mutable||e.Object.SharedObject.mutable),n?{$kind:"Input",Input:T(this,S).inputs.indexOf(n),type:"object"}:T(this,S).addInput("object","string"==typeof e?{$kind:"UnresolvedObject",UnresolvedObject:{objectId:(0,a.t4)(e)}}:e)}));const e=B();R(this,S,new w),R(this,j,[...e.buildPlugins]),R(this,k,[...e.serializationPlugins])}static fromKind(t){const n=new e;return R(n,S,w.fromKindBytes("string"==typeof t?(0,s.Z)(t):t)),n}static from(t){const n=new e;return U(t)?R(n,S,new w(t.getData())):"string"==typeof t&&t.startsWith("{")?R(n,S,w.restore(JSON.parse(t))):R(n,S,w.fromBytes("string"==typeof t?(0,s.Z)(t):t)),n}static registerGlobalSerializationPlugin(e){B().serializationPlugins.push(e)}static registerGlobalBuildPlugin(e){B().buildPlugins.push(e)}addSerializationPlugin(e){T(this,k).push(e)}addBuildPlugin(e){T(this,j).push(e)}addIntentResolver(e,t){if(T(this,v).has(e)&&T(this,v).get(e)!==t)throw new Error(`Intent resolver for ${e} already exists`);T(this,v).set(e,t)}setSender(e){T(this,S).sender=e}setSenderIfNotSet(e){T(this,S).sender||(T(this,S).sender=e)}setExpiration(e){T(this,S).expiration=e?(0,i.qgA)(o.ko,e):null}setGasPrice(e){T(this,S).gasConfig.price=String(e)}setGasBudget(e){T(this,S).gasConfig.budget=String(e)}setGasBudgetIfNotSet(e){null==T(this,S).gasData.budget&&(T(this,S).gasConfig.budget=String(e))}setGasOwner(e){T(this,S).gasConfig.owner=e}setGasPayment(e){T(this,S).gasConfig.payment=e.map((e=>(0,i.qgA)(o.xJ,e)))}get blockData(){return(0,d.Sm)(T(this,S).snapshot())}getData(){return T(this,S).snapshot()}get[D](){return!0}get pure(){return Object.defineProperty(this,"pure",{enumerable:!1,value:(0,g.N)((e=>(0,r.d_)(e)?T(this,S).addInput("pure",{$kind:"Pure",Pure:{bytes:e.toBase64()}}):T(this,S).addInput("pure",(0,i.is)(o.QR,e)?(0,i.qgA)(o.QR,e):e instanceof Uint8Array?h.G.Pure(e):{$kind:"UnresolvedPure",UnresolvedPure:{value:e}})))}),this.pure}get gas(){return{$kind:"GasCoin",GasCoin:!0}}objectRef(...e){return this.object(h.G.ObjectRef(...e))}receivingRef(...e){return this.object(h.G.ReceivingRef(...e))}sharedObjectRef(...e){return this.object(h.G.SharedObjectRef(...e))}add(e){return"function"==typeof e?e(this):function(e){const t=[],n=n=>t[n]??(t[n]={$kind:"NestedResult",NestedResult:[e,n]});return new Proxy({$kind:"Result",Result:e},{set(){throw new Error("The transaction result is a proxy, and does not support setting properties directly")},get(e,t){if(t in e)return Reflect.get(e,t);if(t===Symbol.iterator)return function*(){let e=0;for(;;)yield n(e),e++};if("symbol"==typeof t)return;const s=parseInt(t,10);return Number.isNaN(s)||s<0?void 0:n(s)}})}(T(this,S).commands.push(e)-1)}splitCoins(e,t){return this.add(c.SplitCoins("string"==typeof e?this.object(e):q(this,O,$).call(this,e),t.map((e=>"number"==typeof e||"bigint"==typeof e||"string"==typeof e?this.pure.u64(e):q(this,O,C).call(this,e)))))}mergeCoins(e,t){return this.add(c.MergeCoins(this.object(e),t.map((e=>this.object(e)))))}publish({modules:e,dependencies:t}){return this.add(c.Publish({modules:e,dependencies:t}))}upgrade({modules:e,dependencies:t,package:n,ticket:s}){return this.add(c.Upgrade({modules:e,dependencies:t,package:n,ticket:this.object(s)}))}moveCall({arguments:e,...t}){return this.add(c.MoveCall({...t,arguments:e?.map((e=>q(this,O,C).call(this,e)))}))}transferObjects(e,t){return this.add(c.TransferObjects(e.map((e=>this.object(e))),"string"==typeof t?this.pure.address(t):q(this,O,C).call(this,t)))}makeMoveVec({type:e,elements:t}){return this.add(c.MakeMoveVec({type:e,elements:t.map((e=>this.object(e)))}))}serialize(){return JSON.stringify((0,d.Sm)(T(this,S).snapshot()))}async toJSON(e={}){return await this.prepareForSerialization(e),JSON.stringify((0,i.qgA)(u.f,T(this,S).snapshot()),((e,t)=>"bigint"==typeof t?t.toString():t),2)}async sign(e){const{signer:t,...n}=e,s=await this.build(n);return t.signTransaction(s)}async build(e={}){return await this.prepareForSerialization(e),await q(this,O,M).call(this,e),T(this,S).build({onlyTransactionKind:e.onlyTransactionKind})}async getDigest(e={}){return await q(this,O,M).call(this,e),T(this,S).getDigest()}async prepareForSerialization(e){const t=new Set;for(const e of T(this,S).commands)e.$Intent&&t.add(e.$Intent.name);const n=[...T(this,k)];for(const s of t)if(!e.supportedIntents?.includes(s)){if(!T(this,v).has(s))throw new Error(`Missing intent resolver for ${s}`);n.push(T(this,v).get(s))}await q(this,O,A).call(this,n,e)}}},8338:(e,t,n)=>{n.d(t,{RJ:()=>i,Yl:()=>a,lG:()=>o});class s extends Error{}async function r({host:e,path:t,body:n,headers:r,method:i}){const a=new URL(t,e).toString(),o=await fetch(a,{method:i,body:n?JSON.stringify(n):void 0,headers:{"Content-Type":"application/json",...r||{}}});if(429===o.status)throw new s("Too many requests from this client have been sent to the faucet. Please retry later");try{const e=await o.json();if(e.error)throw new Error(`Faucet returns error: ${e.error}`);return e}catch(e){throw new Error(`Encountered error when parsing response from faucet, error: ${e}, status ${o.status}, response ${o}`)}}async function i(e){return r({host:e.host,path:"/gas",body:{FixedAmountRequest:{recipient:e.recipient}},headers:e.headers,method:"POST"})}async function a(e){return r({host:e.host,path:"/v1/gas",body:{FixedAmountRequest:{recipient:e.recipient}},headers:e.headers,method:"POST"})}function o(e){switch(e){case"testnet":return"https://faucet.testnet.sui.io";case"devnet":return"https://faucet.devnet.sui.io";case"localnet":return"http://127.0.0.1:9123";default:throw new Error(`Unknown network: ${e}`)}}}}]);