@joai/warps-adapter-sui 1.3.0 → 1.3.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/index.mjs +1 -1
- package/package.json +2 -2
package/dist/index.d.cts
CHANGED
|
@@ -137,7 +137,7 @@ declare class WarpSuiOutput implements AdapterWarpOutput {
|
|
|
137
137
|
private readonly serializer;
|
|
138
138
|
private readonly client;
|
|
139
139
|
constructor(config: WarpClientConfig, chain: WarpChainInfo);
|
|
140
|
-
getActionExecution(warp: Warp, actionIndex: WarpActionIndex, tx: WarpAdapterGenericRemoteTransaction): Promise<WarpActionExecutionResult>;
|
|
140
|
+
getActionExecution(warp: Warp, actionIndex: WarpActionIndex, tx: WarpAdapterGenericRemoteTransaction, _resolvedInputs?: ResolvedInput[]): Promise<WarpActionExecutionResult>;
|
|
141
141
|
extractContractOutput(warp: Warp, actionIndex: WarpActionIndex, tx: any, inputs: ResolvedInput[]): Promise<{
|
|
142
142
|
values: {
|
|
143
143
|
string: string[];
|
package/dist/index.d.ts
CHANGED
|
@@ -137,7 +137,7 @@ declare class WarpSuiOutput implements AdapterWarpOutput {
|
|
|
137
137
|
private readonly serializer;
|
|
138
138
|
private readonly client;
|
|
139
139
|
constructor(config: WarpClientConfig, chain: WarpChainInfo);
|
|
140
|
-
getActionExecution(warp: Warp, actionIndex: WarpActionIndex, tx: WarpAdapterGenericRemoteTransaction): Promise<WarpActionExecutionResult>;
|
|
140
|
+
getActionExecution(warp: Warp, actionIndex: WarpActionIndex, tx: WarpAdapterGenericRemoteTransaction, _resolvedInputs?: ResolvedInput[]): Promise<WarpActionExecutionResult>;
|
|
141
141
|
extractContractOutput(warp: Warp, actionIndex: WarpActionIndex, tx: any, inputs: ResolvedInput[]): Promise<{
|
|
142
142
|
values: {
|
|
143
143
|
string: string[];
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var me=Object.create;var F=Object.defineProperty;var fe=Object.getOwnPropertyDescriptor;var ye=Object.getOwnPropertyNames;var We=Object.getPrototypeOf,ve=Object.prototype.hasOwnProperty;var we=(o,e)=>{for(var t in e)F(o,t,{get:e[t],enumerable:!0})},Q=(o,e,t,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of ye(e))!ve.call(o,i)&&i!==t&&F(o,i,{get:()=>e[i],enumerable:!(r=fe(e,i))||r.enumerable});return o};var Ce=(o,e,t)=>(t=o!=null?me(We(o)):{},Q(e||!o||!o.__esModule?F(t,"default",{value:o,enumerable:!0}):t,o)),be=o=>Q(F({},"__esModule",{value:!0}),o);var Ee={};we(Ee,{ExplorerUrls:()=>W,KnownTokens:()=>ne,NativeTokenSui:()=>j,SuiAdapter:()=>Pe,SuiExplorers:()=>L,SuiExplorersConfig:()=>R,WarpSuiAbiBuilder:()=>C,WarpSuiBrandBuilder:()=>K,WarpSuiBuilder:()=>B,WarpSuiConstants:()=>Ae,WarpSuiContractLoader:()=>_,WarpSuiDataLoader:()=>k,WarpSuiExecutor:()=>N,WarpSuiExplorer:()=>D,WarpSuiOutput:()=>b,WarpSuiSerializer:()=>y,WarpSuiWallet:()=>z,findKnownTokenById:()=>V,getConfiguredSuiClient:()=>M});module.exports=be(Ee);var Ae={Sui:{Identifier:"SUI",DisplayName:"Sui",Decimals:9}},L=(a=>(a.SuiVision="suivision",a.SuiVisionTestnet="suivision_testnet",a.SuiVisionDevnet="suivision_devnet",a.SuiScan="suiscan",a.SuiScanTestnet="suiscan_testnet",a.SuiScanDevnet="suiscan_devnet",a))(L||{}),R={sui:{mainnet:["suivision","suiscan"],testnet:["suivision_testnet","suiscan_testnet"],devnet:["suivision_devnet","suiscan_devnet"]}},W={suivision:"https://suivision.xyz",suivision_testnet:"https://testnet.suivision.xyz",suivision_devnet:"https://devnet.suivision.xyz",suiscan:"https://suiscan.xyz",suiscan_testnet:"https://testnet.suiscan.xyz",suiscan_devnet:"https://devnet.suiscan.xyz"};var J=require("@mysten/sui/client"),q=require("@joai/warps"),M=(o,e)=>{let t=(0,q.getProviderConfig)(o,e.name,o.env,e.defaultApiUrl);return new J.SuiClient({url:t.url})};var U=require("@joai/warps");var X=require("@mysten/sui/client"),Y=require("@joai/warps"),C=class{constructor(e,t){this.config=e;this.chain=t;let r=(0,Y.getProviderConfig)(this.config,this.chain.name,this.config.env,this.chain.defaultApiUrl);this.client=new X.SuiClient({url:r.url})}async createInscriptionTransaction(e){throw new Error("WarpSuiAbiBuilder: createInscriptionTransaction not implemented")}async createFromRaw(e){return JSON.parse(e)}async createFromTransaction(e){return this.createFromRaw(e.data||"{}")}async createFromTransactionHash(e,t){try{let r=await this.client.getTransactionBlock({digest:e});return r?this.createFromTransaction(r):null}catch{return null}}async getModuleAbi(e,t){return this.client.getNormalizedMoveModule({package:e,module:t})}async getFunctionAbi(e,t,r){return this.client.getNormalizedMoveFunction({package:e,module:t,function:r})}};var Z=require("@mysten/sui/client"),ee=require("@mysten/sui/transactions"),te=require("@joai/warps"),K=class{constructor(e,t){this.config=e;this.chain=t;let r=(0,te.getProviderConfig)(this.config,this.chain.name,this.config.env,this.chain.defaultApiUrl);this.client=new Z.SuiClient({url:r.url})}createInscriptionTransaction(e){return new ee.Transaction}async createFromRaw(e){return JSON.parse(e)}async createFromTransaction(e,t){return this.createFromRaw(e.data||"{}")}async createFromTransactionHash(e,t){try{let r=await this.client.getTransactionBlock({digest:e});return r?this.createFromTransaction(r,!1):null}catch{return null}}};var re=require("@mysten/sui/client"),E=require("@joai/warps"),B=class extends E.WarpBuilder{constructor(t,r){super(t);this.config=t;this.chain=r;this.cache=new E.WarpCache(t.env,t.cache);let i=(0,E.getProviderConfig)(this.config,this.chain.name,this.config.env,this.chain.defaultApiUrl);this.client=new re.SuiClient({url:i.url})}async createInscriptionTransaction(t){throw new Error("WarpSuiBuilder: on-chain inscription is not supported for Sui")}async createFromTransaction(t){return this.createFromRaw(t)}async createFromTransactionHash(t,r){return null}};var ae=require("@mysten/sui/client"),v=require("@joai/warps");var ie=require("@joai/warps"),f=ie.WarpChainName.Sui,ne=[{chain:f,identifier:"0x2::sui::SUI",name:"Sui",symbol:"SUI",decimals:9,logoUrl:"https://assets.coingecko.com/coins/images/26375/small/sui-logo.png"},{chain:f,identifier:"0xa198f3be41cda8c07c3bf1c4e0bb88b8e9827b7c063f36b1e6c3d6da1c4e8753::usdc::USDC",name:"USD Coin",symbol:"USDC",decimals:6,logoUrl:"https://assets.coingecko.com/coins/images/6319/small/USD_Coin_icon.png"},{chain:f,identifier:"0xc060006111016b8a020ad5b33834984a437aaa7d3c74c18e09a95d48ace0cdd97::usdt::USDT",name:"Tether USD",symbol:"USDT",decimals:6,logoUrl:"https://assets.coingecko.com/coins/images/325/small/Tether.png"},{chain:f,identifier:"0xaf8cd5edc19c4512f4259f0bee101a7c94d8a5c0e7c90c7a7c8c8c8c8c8c8c8c8::wbtc::WBTC",name:"Wrapped Bitcoin",symbol:"WBTC",decimals:8,logoUrl:"https://assets.coingecko.com/coins/images/7598/small/wrapped_bitcoin_wbtc.png"},{chain:f,identifier:"0xb8a6a9b7c7a6f4a3e2d1c0b9a8f7e6d5c4b3a2b1c0d9e8f7a6b5c4d3e2f1a0b::weth::WETH",name:"Wrapped Ether",symbol:"WETH",decimals:8,logoUrl:"https://assets.coingecko.com/coins/images/2518/small/weth.png"},{chain:f,identifier:"0x5d4b302506645c37ff133b98c4b50a5ae14841659738d6d733d59d0d217a15e0e9::ocean::OCEAN",name:"Ocean Protocol",symbol:"OCEAN",decimals:9,logoUrl:"https://assets.coingecko.com/coins/images/3687/small/ocean-protocol-logo.png"},{chain:f,identifier:"0x5d1f47ea69bb0de31c313d7acf89b890dbb8991ea8e03c6c35569693fd50fb8b7::deep::DEEP",name:"DeepBook",symbol:"DEEP",decimals:6,logoUrl:"https://assets.coingecko.com/coins/images/30169/small/deepbook.png"},{chain:f,identifier:"0xbde4ba4c2e274a60ce15c1cfff9e5c42e41654ac8b6d906a57efa4bd3c29f47ba3::hasui::HASUI",name:"Haedal Staked SUI",symbol:"HASUI",decimals:9,logoUrl:"https://assets.coingecko.com/coins/images/30027/small/haSUI.png"},{chain:f,identifier:"0xdba34672e30cb065b1f93e3ab55318768fd6fef66c15942c9f7cb846e2f900e935::usdc::USDC",name:"USD Coin (Wormhole)",symbol:"USDC",decimals:6,logoUrl:"https://assets.coingecko.com/coins/images/6319/small/USD_Coin_icon.png"}],V=o=>ne.find(e=>e.identifier===o)||null;var k=class{constructor(e,t){this.config=e;this.chain=t;let r=(0,v.getProviderConfig)(this.config,this.chain.name,this.config.env,this.chain.defaultApiUrl);this.client=new ae.SuiClient({url:r.url}),this.cache=new v.WarpCache(e.env,e.cache)}async getAccount(e){let t=await this.client.getBalance({owner:e,coinType:"0x2::sui::SUI"});return{chain:this.chain.name,address:e,balance:BigInt(t.totalBalance)}}async getAccountAssets(e){let t=await this.client.getAllBalances({owner:e});console.log("WarpSuiDataLoader.getAccountAssets",t);let r=t.find(a=>a.coinType==="0x2::sui::SUI"),i=t.filter(a=>a.coinType!=="0x2::sui::SUI"&&BigInt(a.totalBalance)>0n),n=[];if(r&&BigInt(r.totalBalance)>0n&&n.push({...this.chain.nativeToken,amount:BigInt(r.totalBalance)}),i.length>0){let a=await Promise.all(i.map(s=>this.getAsset(s.coinType)));n.push(...a.filter(s=>s!==null).map(s=>({...s,amount:BigInt(i.find(c=>c.coinType===s.identifier)?.totalBalance||0)})))}return n}async getAsset(e){let t=v.WarpCacheKey.Asset(this.config.env,this.chain.name,e),r=await this.cache.get(t);if(r)return r;let i=V(e);if(i)return{chain:this.chain.name,identifier:e,name:i.name,symbol:i.symbol,amount:0n,decimals:i.decimals,logoUrl:i.logoUrl};try{let n=await this.client.getCoinMetadata({coinType:e}),a={chain:this.chain.name,identifier:e,name:n?.name||e.split("::").pop()||e,symbol:n?.symbol||e.split("::").pop()||e,amount:0n,decimals:n?.decimals||9,logoUrl:n?.iconUrl||""};return await this.cache.set(t,a,v.CacheTtl.OneHour),a}catch{return null}}async getAccountNfts(e,t){try{let r=t?.size||25,i=t?.page||0,n;for(let c=0;c<i;c++){let l=await this.client.getOwnedObjects({owner:e,options:{showContent:!1,showDisplay:!1},limit:r,cursor:n});if(n=l.nextCursor,!l.hasNextPage)return[]}let a=await this.client.getOwnedObjects({owner:e,options:{showContent:!0,showDisplay:!0},limit:r,cursor:n}),s=[];for(let c of a.data){let l=c.data?.content,d=c.data?.display?.data,h=l?.type||"";if(h.startsWith("0x2::coin::Coin"))continue;let $=c.data?.objectId||"",he=d?.name||h.split("::").pop()||$.slice(0,8),ge=h.includes("::")?h.split("::").slice(0,2).join("::"):void 0,G=d?.image_url;s.push({chain:this.chain.name,identifier:$,name:he,symbol:"",amount:1n,decimals:0,type:"nft",nft:{collection:ge,mediaUrl:G,thumbnailUrl:G}})}return s}catch{return[]}}async getAction(e,t=!1){return null}async getAccountActions(e,t){return[]}};var le=require("@mysten/sui/client"),H=require("@mysten/sui/transactions"),g=require("@joai/warps");var ce=require("@mysten/sui/client"),u=require("@joai/warps");var se=require("@mysten/sui/transactions"),oe=require("@joai/warps"),y=class{constructor(){this.coreSerializer=new oe.WarpSerializer}typedToString(e){if(e==null)return"option:null";if(typeof e=="string")return`string:${e}`;if(typeof e=="boolean")return`bool:${e}`;if(typeof e=="number")return`uint64:${e.toString()}`;if(typeof e=="bigint")return`uint64:${e.toString()}`;if(e&&typeof e=="object"&&e.address)return`address:${e.address}`;if(Array.isArray(e)){if(e.length===0)return"vector:u8:";let t=this.typeToString(typeof e[0]),r=e.map(i=>this.typedToString(i).split(":")[1]);return`vector:${t}:${r.join(",")}`}if(e&&typeof e=="object"&&e.type&&e.value&&e.type==="option")return e.value===null||e.value===void 0?"option:null":`option:${this.typedToString(e.value)}`;throw new Error(`WarpSuiSerializer (typedToString): Unsupported input type: ${typeof e}`)}typedToNative(e){let t=this.typedToString(e);return this.coreSerializer.stringToNative(t)}nativeToTyped(e,t){let r=this.coreSerializer.nativeToString(e,t);return this.stringToTyped(r)}stringToTyped(e,t){let r=t||new se.Transaction,[i,n]=e.split(/:(.*)/,2);if(i==="object")return r.object(n);if(i==="string")return r.pure.string(n);if(i==="bool")return r.pure.bool(n==="true");if(i==="u8")return r.pure.u8(Number(n));if(i==="u16")return r.pure.u16(Number(n));if(i==="u32")return r.pure.u32(Number(n));if(i==="u64"||i==="uint64")return r.pure.u64(BigInt(n));if(i==="u128")return r.pure.u128(BigInt(n));if(i==="u256")return r.pure.u256(BigInt(n));if(i==="address")return r.pure.address(n);throw new Error(`WarpSuiSerializer (stringToTyped): Unsupported type: ${i}`)}typeToString(e){if(e==="string")return"string";if(e==="bool")return"bool";if(e==="u8")return"u8";if(e==="u16")return"u16";if(e==="u32")return"u32";if(e==="u64"||e==="bigint"||e==="number")return"u64";if(e==="u128")return"u128";if(e==="u256")return"u256";if(e==="address")return"address";if(e==="vector")return"vector";if(e==="option")return"option";throw new Error(`WarpSuiSerializer (typeToString): Unsupported input type: ${e}`)}nativeToType(e){throw new Error("Not implemented")}};var b=class{constructor(e,t){this.config=e;this.chain=t;this.serializer=new y;let r=(0,u.getProviderConfig)(this.config,this.chain.name,this.config.env,this.chain.defaultApiUrl);this.client=new ce.SuiClient({url:r.url})}async getActionExecution(e,t,r){let i=await this.extractContractOutput(e,t,r,[]),n=(0,u.getNextInfo)(this.config,[],e,t,i.output),a=(0,u.applyOutputToMessages)(e,i.output,this.config);return{status:r.effects?.status?.status==="success"?"success":"error",warp:e,action:t,user:(0,u.getWarpWalletAddressFromConfig)(this.config,this.chain.name),txHash:r.digest,tx:r,next:n,values:i.values,output:i.output,messages:a,destination:null,resolvedInputs:[]}}async extractContractOutput(e,t,r,i){let n=[],a=[],s={};if(!e.output)return{values:{string:n,native:a,mapped:{}},output:s};for(let[c,l]of Object.entries(e.output)){if(l.startsWith(u.WarpConstants.Transform.Prefix))continue;if(l.startsWith("input.")){s[c]=l;continue}let d=(0,u.parseOutputOutIndex)(l);if(d!==null&&d!==t){s[c]=null;continue}if(l.startsWith("out.")){let h=r.returnValues?r.returnValues[c]:null;s[c]=h,n.push(String(h)),a.push(h)}else s[c]=l}return{values:{string:n,native:a,mapped:{}},output:await(0,u.evaluateOutputCommon)(e,s,a,t,i,this.serializer.coreSerializer,this.config)}}async extractQueryOutput(e,t,r,i){let n=t.map(l=>String(l)),a=t,s={string:n,native:a,mapped:{}},c={};if(!e.output)return{values:s,output:c};for(let[l,d]of Object.entries(e.output)){if(d.startsWith(u.WarpConstants.Transform.Prefix))continue;let h=(0,u.parseOutputOutIndex)(d);if(h!==null&&h!==r){c[l]=null;continue}if(d.startsWith("out.")||d==="out")if(Array.isArray(t)&&t.length>0&&typeof t[0]=="object"&&t[0]!==null){let $=d.replace(/^out\./,"");c[l]=t[0][$]}else c[l]=t[0];else c[l]=d}return{values:s,output:await(0,u.evaluateOutputCommon)(e,c,a,r,i,this.serializer.coreSerializer,this.config)}}};var N=class{constructor(e,t){this.config=e;this.chain=t;this.serializer=new y,this.output=new b(this.config,this.chain);let r=(0,g.getProviderConfig)(this.config,this.chain.name,this.config.env,this.chain.defaultApiUrl);this.client=new le.SuiClient({url:r.url}),this.userWallet=(0,g.getWarpWalletAddressFromConfig)(this.config,this.chain.name)}async createTransaction(e){let t=(0,g.getWarpActionByIndex)(e.warp,e.action);if(t.type==="transfer")return this.createTransferTransaction(e);if(t.type==="contract")return this.createContractCallTransaction(e);throw t.type==="query"?new Error("WarpSuiExecutor: Invalid action type for createTransaction; Use executeQuery instead"):t.type==="collect"?new Error("WarpSuiExecutor: Invalid action type for createTransaction; Use executeCollect instead"):new Error(`WarpSuiExecutor: Invalid action type (${t.type})`)}async createTransferTransaction(e){if(!this.userWallet)throw new Error("WarpSuiExecutor: createTransfer - user address not set");if(!e.destination)throw new Error("WarpSuiExecutor: Invalid destination address");if(e.value<0)throw new Error(`WarpSuiExecutor: Transfer value cannot be negative: ${e.value}`);let t=new H.Transaction,r=[];if(e.value>0){let i=await this.handleCoinTransfer(t,"0x2::sui::SUI",e.value);r.push(i)}for(let i of e.transfers){let n=await this.handleCoinTransfer(t,i.identifier,i.amount);r.push(n)}return r.length>0&&t.transferObjects(r,t.pure.address(e.destination)),t}async createContractCallTransaction(e){if(!this.userWallet)throw new Error("WarpSuiExecutor: createContractCall - user address not set");if(!e.destination)throw new Error("WarpSuiExecutor: Invalid contract address");if(e.value<0)throw new Error(`WarpSuiExecutor: Contract call value cannot be negative: ${e.value}`);let t=(0,g.getWarpActionByIndex)(e.warp,e.action);if(!t.func)throw new Error("WarpSuiExecutor: createContractCall - function not set");let r=new H.Transaction;r.setSender(this.userWallet);let i=[];e.value>0&&i.push(await this.handleCoinTransfer(r,"0x2::sui::SUI",e.value));for(let c of e.transfers)i.push(await this.handleCoinTransfer(r,c.identifier,c.amount));let{target:n,typeArguments:a}=this.parseMoveCallTarget(t),s=e.args.map(c=>this.serializer.stringToTyped(c,r));return n==="0x2::transfer::public_transfer"?i.push(...await this.buildPublicTransferArgs(r,e,s)):i.push(...s),r.moveCall({target:n,arguments:i,typeArguments:a}),r.setGasBudget(1e8),r}async executeQuery(e){if(!e.destination)throw new Error("WarpSuiExecutor: executeQuery - destination not set");let t=(0,g.getWarpActionByIndex)(e.warp,e.action);if(t.type!=="query")throw new Error(`WarpSuiExecutor: Invalid action type for executeQuery: ${t.type}`);let r=await this.client.getObject({id:e.destination,options:{showContent:!0}}),i=[r],{values:n,output:a}=await this.output.extractQueryOutput(e.warp,i,e.action,e.resolvedInputs),s=(0,g.getNextInfo)(this.config,[],e.warp,e.action,a),l=e.resolvedInputs.find(h=>h.input.position==="receiver"||h.input.position==="destination")?.value||e.destination,d=(0,g.extractResolvedInputValues)(e.resolvedInputs);return{status:"success",warp:e.warp,action:e.action,user:this.userWallet,txHash:null,tx:null,next:s,values:n,output:{...a,_DATA:r},resolvedInputs:d,messages:(0,g.applyOutputToMessages)(e.warp,a,this.config),destination:l}}async signMessage(e,t){throw new Error("Not implemented")}parseMoveCallTarget(e){if(!e.func)throw new Error("WarpSuiExecutor: Function not set");let t=`${e.address}::${e.func}`,r=e.typeArguments;if(!r&&e.func.includes("<")&&e.func.includes(">")){let i=e.func.match(/<([^>]+)>/);i&&(r=[i[1]],t=`${e.address}::${e.func.replace(/<[^>]+>/,"")}`)}return{target:t,typeArguments:r}}async buildPublicTransferArgs(e,t,r){let i=t.resolvedInputs.find(s=>String(s.input.position)==="arg:0")?.value||t.args[0],n=t.resolvedInputs.find(s=>String(s.input.position)==="arg:1")?.value||t.resolvedInputs.find(s=>s.input.type==="address"&&String(s.input.position)!=="arg:0")?.value||t.args[1],a=this.extractObjectId(i);if(!a)return r;try{if(!(await this.client.getObject({id:a,options:{showType:!0,showContent:!0}})).data?.type?.startsWith("0x2::coin::Coin<"))return r;let c=n?this.serializer.stringToTyped(n.includes(":")?n:`address:${n}`,e):r[1]||e.pure.address(this.userWallet);return[e.object(a),c]}catch{return r}}extractObjectId(e){if(!e||typeof e!="string")return null;let t=e.startsWith("object:")?e.substring(7):e;return t.startsWith("0x")?t:null}async handleCoinTransfer(e,t,r){if(t==="0x2::sui::SUI")try{return e.splitCoins(e.gas,[r.toString()])[0]}catch{}return this.createCoinTransferFromObjects(e,t,r)}async createCoinTransferFromObjects(e,t,r){let i=await this.getCoinObjectsForTransfer(t,r);if(i.length===0)throw new Error(`No coin objects found for ${t}`);let n=e.object(i[0].coinObjectId);return i.length>1&&e.mergeCoins(n,i.slice(1).map(a=>e.object(a.coinObjectId))),e.splitCoins(n,[r.toString()])[0]}async getCoinObjectsForTransfer(e,t){if(!this.userWallet)throw new Error("User wallet not set");let{data:r}=await this.client.getCoins({owner:this.userWallet,coinType:e}),i=r.map(s=>({coinObjectId:s.coinObjectId,balance:s.balance})).sort((s,c)=>BigInt(c.balance)>BigInt(s.balance)?1:-1),n=BigInt(0),a=[];for(let s of i)if(a.push(s),n+=BigInt(s.balance),n>=t)return a;throw new Error(`Insufficient ${e} balance. Required: ${t}, Available: ${n}`)}};var D=class{constructor(e,t){this.config=e;this.chain=t}getExplorers(){let e=R[this.chain.name];if(!e)return["suivision"];let t=e[this.config.env];return t||["suivision"]}getPrimaryExplorer(){return this.getExplorers()[0]}getExplorerUrlByName(e){let t=this.config.preferences?.explorers?.[this.chain.name];if(t&&!e){let n=W[t];if(n)return n}if(e){let n=W[e];if(n)return n}let r=this.getPrimaryExplorer();return W[r]||W[r]}getAccountUrl(e,t){return`${this.getExplorerUrlByName(t)}/account/${e}`}getTransactionUrl(e,t){return`${this.getExplorerUrlByName(t)}/txblock/${e}`}getBlockUrl(e,t){return`${this.getExplorerUrlByName(t)}/block/${e}`}getAssetUrl(e,t){return`${this.getExplorerUrlByName(t)}/coin/${e}`}getContractUrl(e,t){return`${this.getExplorerUrlByName(t)}/object/${e}`}getAllExplorers(){return this.getExplorers()}getExplorerByName(e){return this.getExplorers().find(r=>r.toLowerCase()===e.toLowerCase())}getAccountUrls(e){let t=this.getAllExplorers(),r={};return t.forEach(i=>{let n=W[i];n&&(r[i]=`${n}/account/${e}`)}),r}getTransactionUrls(e){let t=this.getAllExplorers(),r={};return t.forEach(i=>{let n=W[i];n&&(r[i]=`${n}/txblock/${e}`)}),r}};var de=require("@joai/warps");var O=require("@mysten/sui/keypairs/ed25519"),pe=Ce(require("@scure/bip39"),1),ue=require("@scure/bip39/wordlists/english.js"),p=require("@joai/warps"),A=class A{constructor(e,t){this.config=e;this.chain=t;this.keypair=null}async getAddress(){return(0,p.getWarpWalletAddressFromConfig)(this.config,this.chain.name)}async getPublicKey(){try{let t=this.getKeypair().getPublicKey();return Buffer.from(t.toRawBytes()).toString("hex")}catch{return null}}async signTransaction(e){if(e&&typeof e=="object"&&"sign"in e&&typeof e.sign=="function")return e;let t=this.getKeypair(),r=new TextEncoder().encode(JSON.stringify(e)),i=await t.signPersonalMessage(r);return{...e,signature:i.signature}}async signMessage(e){let t=this.getKeypair(),r=new TextEncoder().encode(e);return(await t.signPersonalMessage(r)).signature}getKeypairInstance(){return this.getKeypair()}async importFromMnemonic(e){let t=(0,p.normalizeAndValidateMnemonic)(e),i=O.Ed25519Keypair.deriveKeypair(t).getPublicKey().toSuiAddress(),n={provider:A.PROVIDER_NAME,address:i,privateKey:null,mnemonic:t};return(0,p.setWarpWalletInConfig)(this.config,this.chain.name,n),n}async importFromPrivateKey(e){let t=Buffer.from(e,"hex"),r;if(t.length===70)r=new Uint8Array(t.subarray(1,33));else if(t.length===32)r=new Uint8Array(t);else throw new Error(`Unsupported private key length: ${t.length} bytes`);let n=O.Ed25519Keypair.fromSecretKey(r).getPublicKey().toSuiAddress(),a={provider:A.PROVIDER_NAME,address:n,privateKey:e,mnemonic:null};return(0,p.setWarpWalletInConfig)(this.config,this.chain.name,a),a}async export(){let e=this.getKeypair(),t=(0,p.getWarpWalletMnemonicFromConfig)(this.config,this.chain.name),r=(0,p.getWarpWalletPrivateKeyFromConfig)(this.config,this.chain.name);return{provider:A.PROVIDER_NAME,address:e.getPublicKey().toSuiAddress(),privateKey:r||null,mnemonic:t||null}}async generate(){let e=pe.generateMnemonic(ue.wordlist,256),t=(0,p.normalizeMnemonic)(e);(0,p.validateMnemonicLength)(t);let i=O.Ed25519Keypair.deriveKeypair(t).getPublicKey().toSuiAddress();return{provider:A.PROVIDER_NAME,address:i,privateKey:null,mnemonic:t}}async delete(e){(0,p.removeWarpWalletFromConfig)(this.config,this.chain.name)}getKeypair(){if(this.keypair)return this.keypair;let e=(0,p.getWarpWalletMnemonicFromConfig)(this.config,this.chain.name);if(!e)throw new Error("No mnemonic provided");return this.keypair=O.Ed25519Keypair.deriveKeypair(e.trim()),this.keypair}};A.PROVIDER_NAME="mnemonic";var T=A;var w=require("@joai/warps"),S=class{constructor(e,t){this.config=e;this.chain=t}async getAddress(){return(0,w.getWarpWalletAddressFromConfig)(this.config,this.chain.name)}async getPublicKey(){return null}async signTransaction(e){let t=await this.getAddress();throw new Error(`Wallet can not be used for signing: ${t}`)}async signMessage(e){let t=await this.getAddress();throw new Error(`Wallet can not be used for signing: ${t}`)}async importFromMnemonic(e){let t=(0,w.getWarpWalletAddressFromConfig)(this.config,this.chain.name);throw new Error(`Wallet can not be used for signing: ${t}`)}async importFromPrivateKey(e){let t=(0,w.getWarpWalletAddressFromConfig)(this.config,this.chain.name);throw new Error(`Wallet can not be used for signing: ${t}`)}async export(){let e=(0,w.getWarpWalletAddressFromConfig)(this.config,this.chain.name);throw new Error(`Wallet can not be used for signing: ${e}`)}async generate(){let e=(0,w.getWarpWalletAddressFromConfig)(this.config,this.chain.name);throw new Error(`Wallet can not be used for signing: ${e}`)}async delete(e){(0,w.removeWarpWalletFromConfig)(this.config,this.chain.name)}};var I=require("@mysten/sui/keypairs/ed25519"),m=require("@joai/warps"),P=class P{constructor(e,t){this.config=e;this.chain=t;this.keypair=null}async getAddress(){return(0,m.getWarpWalletAddressFromConfig)(this.config,this.chain.name)}async getPublicKey(){try{let t=this.getKeypair().getPublicKey();return Buffer.from(t.toRawBytes()).toString("hex")}catch{return null}}async signTransaction(e){if(e&&typeof e=="object"&&"sign"in e&&typeof e.sign=="function")return e;let t=this.getKeypair(),r=new TextEncoder().encode(JSON.stringify(e)),i=await t.signPersonalMessage(r);return{...e,signature:i.signature}}async signMessage(e){let t=this.getKeypair(),r=new TextEncoder().encode(e);return(await t.signPersonalMessage(r)).signature}getKeypairInstance(){return this.getKeypair()}async importFromMnemonic(e){let t=I.Ed25519Keypair.deriveKeypair(e.trim()),r=t.getPublicKey().toSuiAddress(),i=Buffer.from(t.getSecretKey()).toString("hex"),n={provider:P.PROVIDER_NAME,address:r,privateKey:i,mnemonic:e};return(0,m.setWarpWalletInConfig)(this.config,this.chain.name,n),n}async importFromPrivateKey(e){let t=Buffer.from(e,"hex"),r;if(t.length===70)r=new Uint8Array(t.subarray(1,33));else if(t.length===32)r=new Uint8Array(t);else throw new Error(`Unsupported private key length: ${t.length} bytes`);let n=I.Ed25519Keypair.fromSecretKey(r).getPublicKey().toSuiAddress(),a={provider:P.PROVIDER_NAME,address:n,privateKey:e,mnemonic:null};return(0,m.setWarpWalletInConfig)(this.config,this.chain.name,a),a}async export(){let e=this.getKeypair(),t=(0,m.getWarpWalletPrivateKeyFromConfig)(this.config,this.chain.name),r=(0,m.getWarpWalletMnemonicFromConfig)(this.config,this.chain.name);return{provider:P.PROVIDER_NAME,address:e.getPublicKey().toSuiAddress(),privateKey:t||null,mnemonic:r||null}}async generate(){let e=I.Ed25519Keypair.generate(),t=e.getPublicKey().toSuiAddress(),r=Buffer.from(e.getSecretKey()).toString("hex");return{provider:P.PROVIDER_NAME,address:t,privateKey:r,mnemonic:null}}async delete(e){(0,m.removeWarpWalletFromConfig)(this.config,this.chain.name)}getKeypair(){if(this.keypair)return this.keypair;let e=(0,m.getWarpWalletPrivateKeyFromConfig)(this.config,this.chain.name);if(!e)throw new Error("Wallet not initialized - no private key provided");try{let t=Buffer.from(e,"hex");if(t.length===70){let r=new Uint8Array(t.subarray(1,33));return this.keypair=I.Ed25519Keypair.fromSecretKey(r),this.keypair}else{if(t.length===32)return this.keypair=I.Ed25519Keypair.fromSecretKey(new Uint8Array(t)),this.keypair;throw new Error(`Unsupported private key length: ${t.length} bytes`)}}catch(t){throw t}}};P.PROVIDER_NAME="privateKey";var x=P;var z=class{constructor(e,t){this.config=e;this.chain=t;this.cachedAddress=null;this.cachedPublicKey=null;this.client=M(e,t),this.walletProvider=this.createProvider(),this.isInitializedPromise=new Promise(r=>{this.isInitializedResolve=r}),this.initializeCache()}async waitUntilInitialized(){await this.isInitializedPromise}async signTransaction(e){if(await this.waitUntilInitialized(),!e||typeof e!="object")throw new Error("Invalid transaction object");if(!this.walletProvider)throw new Error("No wallet provider available");if(this.walletProvider instanceof S)throw new Error(`Wallet (${this.chain.name}) is read-only`);return(this.walletProvider instanceof x||this.walletProvider instanceof T)&&e&&typeof e=="object"&&"sign"in e&&typeof e.sign=="function"?e:await this.walletProvider.signTransaction(e)}async signMessage(e){if(await this.waitUntilInitialized(),!this.walletProvider)throw new Error("No wallet provider available");if(this.walletProvider instanceof S)throw new Error(`Wallet (${this.chain.name}) is read-only`);return await this.walletProvider.signMessage(e)}async signTransactions(e){return await this.waitUntilInitialized(),e}async sendTransaction(e){if(await this.waitUntilInitialized(),!e||typeof e!="object")throw new Error("Invalid transaction object");if(e.transactionHash)return e.transactionHash;if(e&&typeof e=="object"&&"bytes"in e&&"signature"in e)return(await this.client.executeTransactionBlock({transactionBlock:e.bytes,signature:Array.isArray(e.signature)?e.signature:[e.signature],options:{showEffects:!0,showEvents:!0}})).digest;if(!this.walletProvider)throw new Error("No wallet provider available");if(this.walletProvider instanceof x||this.walletProvider instanceof T){let t=this.walletProvider.getKeypairInstance();if(e&&typeof e=="object"&&"sign"in e&&typeof e.sign=="function")return(await this.client.signAndExecuteTransaction({transaction:e,signer:t,options:{showEffects:!0,showEvents:!0}})).digest;throw new Error(`Transaction must be a Transaction object or have bytes and signature. Got: ${typeof e}, has sign: ${e&&typeof e=="object"&&"sign"in e}, has bytes: ${e&&typeof e=="object"&&"bytes"in e}, has signature: ${e&&typeof e=="object"&&"signature"in e}`)}throw new Error("Remote wallet provider must return signed payload (bytes + signature) or transactionHash for Sui transactions")}async sendTransactions(e){return await this.waitUntilInitialized(),Promise.all(e.map(async t=>this.sendTransaction(t)))}async importFromMnemonic(e){return await this.waitUntilInitialized(),await this.createProviderForOperation("mnemonic").importFromMnemonic(e)}async importFromPrivateKey(e){return await this.waitUntilInitialized(),await this.createProviderForOperation("privateKey").importFromPrivateKey(e)}async export(e){return await this.waitUntilInitialized(),await this.createProviderForOperation(e).export()}async generate(e){return await this.waitUntilInitialized(),await this.createProviderForOperation(e).generate()}async delete(e,t){await this.waitUntilInitialized(),await this.createProviderForOperation(e).delete(t)}getAddress(){return this.cachedAddress}getPublicKey(){return this.cachedPublicKey}createProvider(){let e=this.config.user?.wallets?.[this.chain.name];return e?typeof e=="string"?new S(this.config,this.chain):e.provider?this.createProviderForOperation(e.provider):new S(this.config,this.chain):null}async initializeCache(){let e=await(0,de.initializeWalletCache)(this.walletProvider);this.cachedAddress=e.address,this.cachedPublicKey=e.publicKey,this.isInitializedResolve()}createProviderForOperation(e){let r=this.config.walletProviders?.[this.chain.name]?.[e];if(r){let i=r(this.config,this.chain);if(!i)throw new Error(`Custom wallet provider factory returned null for ${e}`);return i}if(e==="privateKey")return new x(this.config,this.chain);if(e==="mnemonic")return new T(this.config,this.chain);throw new Error(`Unsupported wallet provider for ${this.chain.name}: ${e}`)}};var j={chain:U.WarpChainName.Sui,identifier:"0x2::sui::SUI",name:"SUI",symbol:"SUI",decimals:9,logoUrl:"https://assets.coingecko.com/coins/images/26375/standard/sui-ocean-square.png?1727791290"};function Se(o,e){return(t,r)=>{if(!r)throw new Error(`${o} adapter requires a fallback adapter`);let i=e[t.env];if(!i)throw new Error(`SuiAdapter: chain info not found for chain ${o}`);return{chainInfo:i,builder:()=>new B(t,i),executor:new N(t,i),output:new b(t,i),serializer:new y,registry:r.registry,explorer:new D(t,i),abiBuilder:()=>new C(t,i),brandBuilder:()=>new K(t,i),dataLoader:new k(t,i),wallet:new z(t,i)}}}var Pe=Se(U.WarpChainName.Sui,{mainnet:{name:U.WarpChainName.Sui,displayName:"Sui",chainId:"1",blockTime:3e3,addressHrp:"sui",defaultApiUrl:"https://fullnode.mainnet.sui.io",logoUrl:"https://raw.githubusercontent.com/JoAiHQ/assets/refs/heads/main/chains/logos/sui.svg",nativeToken:j},testnet:{name:U.WarpChainName.Sui,displayName:"Sui Testnet",chainId:"testnet",blockTime:3e3,addressHrp:"sui",defaultApiUrl:"https://fullnode.testnet.sui.io",logoUrl:"https://raw.githubusercontent.com/JoAiHQ/assets/refs/heads/main/chains/logos/sui.svg",nativeToken:j},devnet:{name:U.WarpChainName.Sui,displayName:"Sui Devnet",chainId:"devnet",blockTime:3e3,addressHrp:"sui",defaultApiUrl:"https://fullnode.devnet.sui.io",logoUrl:"https://raw.githubusercontent.com/JoAiHQ/assets/refs/heads/main/chains/logos/sui.svg",nativeToken:j}});var _=class{constructor(e,t){this.abi=new C(e,t)}async loadModuleAbi(e,t){return this.abi.getModuleAbi(e,t)}async loadFunctionAbi(e,t,r){return this.abi.getFunctionAbi(e,t,r)}};0&&(module.exports={ExplorerUrls,KnownTokens,NativeTokenSui,SuiAdapter,SuiExplorers,SuiExplorersConfig,WarpSuiAbiBuilder,WarpSuiBrandBuilder,WarpSuiBuilder,WarpSuiConstants,WarpSuiContractLoader,WarpSuiDataLoader,WarpSuiExecutor,WarpSuiExplorer,WarpSuiOutput,WarpSuiSerializer,WarpSuiWallet,findKnownTokenById,getConfiguredSuiClient});
|
|
1
|
+
"use strict";var me=Object.create;var F=Object.defineProperty;var fe=Object.getOwnPropertyDescriptor;var ye=Object.getOwnPropertyNames;var We=Object.getPrototypeOf,ve=Object.prototype.hasOwnProperty;var we=(o,e)=>{for(var t in e)F(o,t,{get:e[t],enumerable:!0})},Q=(o,e,t,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of ye(e))!ve.call(o,i)&&i!==t&&F(o,i,{get:()=>e[i],enumerable:!(r=fe(e,i))||r.enumerable});return o};var Ce=(o,e,t)=>(t=o!=null?me(We(o)):{},Q(e||!o||!o.__esModule?F(t,"default",{value:o,enumerable:!0}):t,o)),be=o=>Q(F({},"__esModule",{value:!0}),o);var Pe={};we(Pe,{ExplorerUrls:()=>W,KnownTokens:()=>ne,NativeTokenSui:()=>R,SuiAdapter:()=>Ee,SuiExplorers:()=>L,SuiExplorersConfig:()=>j,WarpSuiAbiBuilder:()=>C,WarpSuiBrandBuilder:()=>K,WarpSuiBuilder:()=>B,WarpSuiConstants:()=>Ae,WarpSuiContractLoader:()=>_,WarpSuiDataLoader:()=>k,WarpSuiExecutor:()=>N,WarpSuiExplorer:()=>D,WarpSuiOutput:()=>b,WarpSuiSerializer:()=>y,WarpSuiWallet:()=>z,findKnownTokenById:()=>V,getConfiguredSuiClient:()=>M});module.exports=be(Pe);var Ae={Sui:{Identifier:"SUI",DisplayName:"Sui",Decimals:9}},L=(a=>(a.SuiVision="suivision",a.SuiVisionTestnet="suivision_testnet",a.SuiVisionDevnet="suivision_devnet",a.SuiScan="suiscan",a.SuiScanTestnet="suiscan_testnet",a.SuiScanDevnet="suiscan_devnet",a))(L||{}),j={sui:{mainnet:["suivision","suiscan"],testnet:["suivision_testnet","suiscan_testnet"],devnet:["suivision_devnet","suiscan_devnet"]}},W={suivision:"https://suivision.xyz",suivision_testnet:"https://testnet.suivision.xyz",suivision_devnet:"https://devnet.suivision.xyz",suiscan:"https://suiscan.xyz",suiscan_testnet:"https://testnet.suiscan.xyz",suiscan_devnet:"https://devnet.suiscan.xyz"};var J=require("@mysten/sui/client"),q=require("@joai/warps"),M=(o,e)=>{let t=(0,q.getProviderConfig)(o,e.name,o.env,e.defaultApiUrl);return new J.SuiClient({url:t.url})};var U=require("@joai/warps");var X=require("@mysten/sui/client"),Y=require("@joai/warps"),C=class{constructor(e,t){this.config=e;this.chain=t;let r=(0,Y.getProviderConfig)(this.config,this.chain.name,this.config.env,this.chain.defaultApiUrl);this.client=new X.SuiClient({url:r.url})}async createInscriptionTransaction(e){throw new Error("WarpSuiAbiBuilder: createInscriptionTransaction not implemented")}async createFromRaw(e){return JSON.parse(e)}async createFromTransaction(e){return this.createFromRaw(e.data||"{}")}async createFromTransactionHash(e,t){try{let r=await this.client.getTransactionBlock({digest:e});return r?this.createFromTransaction(r):null}catch{return null}}async getModuleAbi(e,t){return this.client.getNormalizedMoveModule({package:e,module:t})}async getFunctionAbi(e,t,r){return this.client.getNormalizedMoveFunction({package:e,module:t,function:r})}};var Z=require("@mysten/sui/client"),ee=require("@mysten/sui/transactions"),te=require("@joai/warps"),K=class{constructor(e,t){this.config=e;this.chain=t;let r=(0,te.getProviderConfig)(this.config,this.chain.name,this.config.env,this.chain.defaultApiUrl);this.client=new Z.SuiClient({url:r.url})}createInscriptionTransaction(e){return new ee.Transaction}async createFromRaw(e){return JSON.parse(e)}async createFromTransaction(e,t){return this.createFromRaw(e.data||"{}")}async createFromTransactionHash(e,t){try{let r=await this.client.getTransactionBlock({digest:e});return r?this.createFromTransaction(r,!1):null}catch{return null}}};var re=require("@mysten/sui/client"),P=require("@joai/warps"),B=class extends P.WarpBuilder{constructor(t,r){super(t);this.config=t;this.chain=r;this.cache=new P.WarpCache(t.env,t.cache);let i=(0,P.getProviderConfig)(this.config,this.chain.name,this.config.env,this.chain.defaultApiUrl);this.client=new re.SuiClient({url:i.url})}async createInscriptionTransaction(t){throw new Error("WarpSuiBuilder: on-chain inscription is not supported for Sui")}async createFromTransaction(t){return this.createFromRaw(t)}async createFromTransactionHash(t,r){return null}};var ae=require("@mysten/sui/client"),v=require("@joai/warps");var ie=require("@joai/warps"),f=ie.WarpChainName.Sui,ne=[{chain:f,identifier:"0x2::sui::SUI",name:"Sui",symbol:"SUI",decimals:9,logoUrl:"https://assets.coingecko.com/coins/images/26375/small/sui-logo.png"},{chain:f,identifier:"0xa198f3be41cda8c07c3bf1c4e0bb88b8e9827b7c063f36b1e6c3d6da1c4e8753::usdc::USDC",name:"USD Coin",symbol:"USDC",decimals:6,logoUrl:"https://assets.coingecko.com/coins/images/6319/small/USD_Coin_icon.png"},{chain:f,identifier:"0xc060006111016b8a020ad5b33834984a437aaa7d3c74c18e09a95d48ace0cdd97::usdt::USDT",name:"Tether USD",symbol:"USDT",decimals:6,logoUrl:"https://assets.coingecko.com/coins/images/325/small/Tether.png"},{chain:f,identifier:"0xaf8cd5edc19c4512f4259f0bee101a7c94d8a5c0e7c90c7a7c8c8c8c8c8c8c8c8::wbtc::WBTC",name:"Wrapped Bitcoin",symbol:"WBTC",decimals:8,logoUrl:"https://assets.coingecko.com/coins/images/7598/small/wrapped_bitcoin_wbtc.png"},{chain:f,identifier:"0xb8a6a9b7c7a6f4a3e2d1c0b9a8f7e6d5c4b3a2b1c0d9e8f7a6b5c4d3e2f1a0b::weth::WETH",name:"Wrapped Ether",symbol:"WETH",decimals:8,logoUrl:"https://assets.coingecko.com/coins/images/2518/small/weth.png"},{chain:f,identifier:"0x5d4b302506645c37ff133b98c4b50a5ae14841659738d6d733d59d0d217a15e0e9::ocean::OCEAN",name:"Ocean Protocol",symbol:"OCEAN",decimals:9,logoUrl:"https://assets.coingecko.com/coins/images/3687/small/ocean-protocol-logo.png"},{chain:f,identifier:"0x5d1f47ea69bb0de31c313d7acf89b890dbb8991ea8e03c6c35569693fd50fb8b7::deep::DEEP",name:"DeepBook",symbol:"DEEP",decimals:6,logoUrl:"https://assets.coingecko.com/coins/images/30169/small/deepbook.png"},{chain:f,identifier:"0xbde4ba4c2e274a60ce15c1cfff9e5c42e41654ac8b6d906a57efa4bd3c29f47ba3::hasui::HASUI",name:"Haedal Staked SUI",symbol:"HASUI",decimals:9,logoUrl:"https://assets.coingecko.com/coins/images/30027/small/haSUI.png"},{chain:f,identifier:"0xdba34672e30cb065b1f93e3ab55318768fd6fef66c15942c9f7cb846e2f900e935::usdc::USDC",name:"USD Coin (Wormhole)",symbol:"USDC",decimals:6,logoUrl:"https://assets.coingecko.com/coins/images/6319/small/USD_Coin_icon.png"}],V=o=>ne.find(e=>e.identifier===o)||null;var k=class{constructor(e,t){this.config=e;this.chain=t;let r=(0,v.getProviderConfig)(this.config,this.chain.name,this.config.env,this.chain.defaultApiUrl);this.client=new ae.SuiClient({url:r.url}),this.cache=new v.WarpCache(e.env,e.cache)}async getAccount(e){let t=await this.client.getBalance({owner:e,coinType:"0x2::sui::SUI"});return{chain:this.chain.name,address:e,balance:BigInt(t.totalBalance)}}async getAccountAssets(e){let t=await this.client.getAllBalances({owner:e});console.log("WarpSuiDataLoader.getAccountAssets",t);let r=t.find(a=>a.coinType==="0x2::sui::SUI"),i=t.filter(a=>a.coinType!=="0x2::sui::SUI"&&BigInt(a.totalBalance)>0n),n=[];if(r&&BigInt(r.totalBalance)>0n&&n.push({...this.chain.nativeToken,amount:BigInt(r.totalBalance)}),i.length>0){let a=await Promise.all(i.map(s=>this.getAsset(s.coinType)));n.push(...a.filter(s=>s!==null).map(s=>({...s,amount:BigInt(i.find(c=>c.coinType===s.identifier)?.totalBalance||0)})))}return n}async getAsset(e){let t=v.WarpCacheKey.Asset(this.config.env,this.chain.name,e),r=await this.cache.get(t);if(r)return r;let i=V(e);if(i)return{chain:this.chain.name,identifier:e,name:i.name,symbol:i.symbol,amount:0n,decimals:i.decimals,logoUrl:i.logoUrl};try{let n=await this.client.getCoinMetadata({coinType:e}),a={chain:this.chain.name,identifier:e,name:n?.name||e.split("::").pop()||e,symbol:n?.symbol||e.split("::").pop()||e,amount:0n,decimals:n?.decimals||9,logoUrl:n?.iconUrl||""};return await this.cache.set(t,a,v.CacheTtl.OneHour),a}catch{return null}}async getAccountNfts(e,t){try{let r=t?.size||25,i=t?.page||0,n;for(let c=0;c<i;c++){let l=await this.client.getOwnedObjects({owner:e,options:{showContent:!1,showDisplay:!1},limit:r,cursor:n});if(n=l.nextCursor,!l.hasNextPage)return[]}let a=await this.client.getOwnedObjects({owner:e,options:{showContent:!0,showDisplay:!0},limit:r,cursor:n}),s=[];for(let c of a.data){let l=c.data?.content,p=c.data?.display?.data,h=l?.type||"";if(h.startsWith("0x2::coin::Coin"))continue;let $=c.data?.objectId||"",he=p?.name||h.split("::").pop()||$.slice(0,8),ge=h.includes("::")?h.split("::").slice(0,2).join("::"):void 0,G=p?.image_url;s.push({chain:this.chain.name,identifier:$,name:he,symbol:"",amount:1n,decimals:0,type:"nft",nft:{collection:ge,mediaUrl:G,thumbnailUrl:G}})}return s}catch{return[]}}async getAction(e,t=!1){return null}async getAccountActions(e,t){return[]}};var le=require("@mysten/sui/client"),H=require("@mysten/sui/transactions"),g=require("@joai/warps");var ce=require("@mysten/sui/client"),d=require("@joai/warps");var se=require("@mysten/sui/transactions"),oe=require("@joai/warps"),y=class{constructor(){this.coreSerializer=new oe.WarpSerializer}typedToString(e){if(e==null)return"option:null";if(typeof e=="string")return`string:${e}`;if(typeof e=="boolean")return`bool:${e}`;if(typeof e=="number")return`uint64:${e.toString()}`;if(typeof e=="bigint")return`uint64:${e.toString()}`;if(e&&typeof e=="object"&&e.address)return`address:${e.address}`;if(Array.isArray(e)){if(e.length===0)return"vector:u8:";let t=this.typeToString(typeof e[0]),r=e.map(i=>this.typedToString(i).split(":")[1]);return`vector:${t}:${r.join(",")}`}if(e&&typeof e=="object"&&e.type&&e.value&&e.type==="option")return e.value===null||e.value===void 0?"option:null":`option:${this.typedToString(e.value)}`;throw new Error(`WarpSuiSerializer (typedToString): Unsupported input type: ${typeof e}`)}typedToNative(e){let t=this.typedToString(e);return this.coreSerializer.stringToNative(t)}nativeToTyped(e,t){let r=this.coreSerializer.nativeToString(e,t);return this.stringToTyped(r)}stringToTyped(e,t){let r=t||new se.Transaction,[i,n]=e.split(/:(.*)/,2);if(i==="object")return r.object(n);if(i==="string")return r.pure.string(n);if(i==="bool")return r.pure.bool(n==="true");if(i==="u8")return r.pure.u8(Number(n));if(i==="u16")return r.pure.u16(Number(n));if(i==="u32")return r.pure.u32(Number(n));if(i==="u64"||i==="uint64")return r.pure.u64(BigInt(n));if(i==="u128")return r.pure.u128(BigInt(n));if(i==="u256")return r.pure.u256(BigInt(n));if(i==="address")return r.pure.address(n);throw new Error(`WarpSuiSerializer (stringToTyped): Unsupported type: ${i}`)}typeToString(e){if(e==="string")return"string";if(e==="bool")return"bool";if(e==="u8")return"u8";if(e==="u16")return"u16";if(e==="u32")return"u32";if(e==="u64"||e==="bigint"||e==="number")return"u64";if(e==="u128")return"u128";if(e==="u256")return"u256";if(e==="address")return"address";if(e==="vector")return"vector";if(e==="option")return"option";throw new Error(`WarpSuiSerializer (typeToString): Unsupported input type: ${e}`)}nativeToType(e){throw new Error("Not implemented")}};var b=class{constructor(e,t){this.config=e;this.chain=t;this.serializer=new y;let r=(0,d.getProviderConfig)(this.config,this.chain.name,this.config.env,this.chain.defaultApiUrl);this.client=new ce.SuiClient({url:r.url})}async getActionExecution(e,t,r,i){let n=i??[],a=await this.extractContractOutput(e,t,r,[]),s=(0,d.getNextInfo)(this.config,[],e,t,a.output),c=Object.fromEntries(n.map(p=>[p.input.as||p.input.name,p.value])),l=(0,d.applyOutputToMessages)(e,{...c,...a.output},this.config);return{status:r.effects?.status?.status==="success"?"success":"error",warp:e,action:t,user:(0,d.getWarpWalletAddressFromConfig)(this.config,this.chain.name),txHash:r.digest,tx:r,next:s,values:a.values,output:a.output,messages:l,destination:null,resolvedInputs:[]}}async extractContractOutput(e,t,r,i){let n=[],a=[],s={};if(!e.output)return{values:{string:n,native:a,mapped:{}},output:s};for(let[c,l]of Object.entries(e.output)){if(l.startsWith(d.WarpConstants.Transform.Prefix))continue;if(l.startsWith("input.")){s[c]=l;continue}let p=(0,d.parseOutputOutIndex)(l);if(p!==null&&p!==t){s[c]=null;continue}if(l.startsWith("out.")){let h=r.returnValues?r.returnValues[c]:null;s[c]=h,n.push(String(h)),a.push(h)}else s[c]=l}return{values:{string:n,native:a,mapped:{}},output:await(0,d.evaluateOutputCommon)(e,s,a,t,i,this.serializer.coreSerializer,this.config)}}async extractQueryOutput(e,t,r,i){let n=t.map(l=>String(l)),a=t,s={string:n,native:a,mapped:{}},c={};if(!e.output)return{values:s,output:c};for(let[l,p]of Object.entries(e.output)){if(p.startsWith(d.WarpConstants.Transform.Prefix))continue;let h=(0,d.parseOutputOutIndex)(p);if(h!==null&&h!==r){c[l]=null;continue}if(p.startsWith("out.")||p==="out")if(Array.isArray(t)&&t.length>0&&typeof t[0]=="object"&&t[0]!==null){let $=p.replace(/^out\./,"");c[l]=t[0][$]}else c[l]=t[0];else c[l]=p}return{values:s,output:await(0,d.evaluateOutputCommon)(e,c,a,r,i,this.serializer.coreSerializer,this.config)}}};var N=class{constructor(e,t){this.config=e;this.chain=t;this.serializer=new y,this.output=new b(this.config,this.chain);let r=(0,g.getProviderConfig)(this.config,this.chain.name,this.config.env,this.chain.defaultApiUrl);this.client=new le.SuiClient({url:r.url}),this.userWallet=(0,g.getWarpWalletAddressFromConfig)(this.config,this.chain.name)}async createTransaction(e){let t=(0,g.getWarpActionByIndex)(e.warp,e.action);if(t.type==="transfer")return this.createTransferTransaction(e);if(t.type==="contract")return this.createContractCallTransaction(e);throw t.type==="query"?new Error("WarpSuiExecutor: Invalid action type for createTransaction; Use executeQuery instead"):t.type==="collect"?new Error("WarpSuiExecutor: Invalid action type for createTransaction; Use executeCollect instead"):new Error(`WarpSuiExecutor: Invalid action type (${t.type})`)}async createTransferTransaction(e){if(!this.userWallet)throw new Error("WarpSuiExecutor: createTransfer - user address not set");if(!e.destination)throw new Error("WarpSuiExecutor: Invalid destination address");if(e.value<0)throw new Error(`WarpSuiExecutor: Transfer value cannot be negative: ${e.value}`);let t=new H.Transaction,r=[];if(e.value>0){let i=await this.handleCoinTransfer(t,"0x2::sui::SUI",e.value);r.push(i)}for(let i of e.transfers){let n=await this.handleCoinTransfer(t,i.identifier,i.amount);r.push(n)}return r.length>0&&t.transferObjects(r,t.pure.address(e.destination)),t}async createContractCallTransaction(e){if(!this.userWallet)throw new Error("WarpSuiExecutor: createContractCall - user address not set");if(!e.destination)throw new Error("WarpSuiExecutor: Invalid contract address");if(e.value<0)throw new Error(`WarpSuiExecutor: Contract call value cannot be negative: ${e.value}`);let t=(0,g.getWarpActionByIndex)(e.warp,e.action);if(!t.func)throw new Error("WarpSuiExecutor: createContractCall - function not set");let r=new H.Transaction;r.setSender(this.userWallet);let i=[];e.value>0&&i.push(await this.handleCoinTransfer(r,"0x2::sui::SUI",e.value));for(let c of e.transfers)i.push(await this.handleCoinTransfer(r,c.identifier,c.amount));let{target:n,typeArguments:a}=this.parseMoveCallTarget(t),s=e.args.map(c=>this.serializer.stringToTyped(c,r));return n==="0x2::transfer::public_transfer"?i.push(...await this.buildPublicTransferArgs(r,e,s)):i.push(...s),r.moveCall({target:n,arguments:i,typeArguments:a}),r.setGasBudget(1e8),r}async executeQuery(e){if(!e.destination)throw new Error("WarpSuiExecutor: executeQuery - destination not set");let t=(0,g.getWarpActionByIndex)(e.warp,e.action);if(t.type!=="query")throw new Error(`WarpSuiExecutor: Invalid action type for executeQuery: ${t.type}`);let r=await this.client.getObject({id:e.destination,options:{showContent:!0}}),i=[r],{values:n,output:a}=await this.output.extractQueryOutput(e.warp,i,e.action,e.resolvedInputs),s=(0,g.getNextInfo)(this.config,[],e.warp,e.action,a),l=e.resolvedInputs.find(h=>h.input.position==="receiver"||h.input.position==="destination")?.value||e.destination,p=(0,g.extractResolvedInputValues)(e.resolvedInputs);return{status:"success",warp:e.warp,action:e.action,user:this.userWallet,txHash:null,tx:null,next:s,values:n,output:{...a,_DATA:r},resolvedInputs:p,messages:(0,g.applyOutputToMessages)(e.warp,a,this.config),destination:l}}async signMessage(e,t){throw new Error("Not implemented")}parseMoveCallTarget(e){if(!e.func)throw new Error("WarpSuiExecutor: Function not set");let t=`${e.address}::${e.func}`,r=e.typeArguments;if(!r&&e.func.includes("<")&&e.func.includes(">")){let i=e.func.match(/<([^>]+)>/);i&&(r=[i[1]],t=`${e.address}::${e.func.replace(/<[^>]+>/,"")}`)}return{target:t,typeArguments:r}}async buildPublicTransferArgs(e,t,r){let i=t.resolvedInputs.find(s=>String(s.input.position)==="arg:0")?.value||t.args[0],n=t.resolvedInputs.find(s=>String(s.input.position)==="arg:1")?.value||t.resolvedInputs.find(s=>s.input.type==="address"&&String(s.input.position)!=="arg:0")?.value||t.args[1],a=this.extractObjectId(i);if(!a)return r;try{if(!(await this.client.getObject({id:a,options:{showType:!0,showContent:!0}})).data?.type?.startsWith("0x2::coin::Coin<"))return r;let c=n?this.serializer.stringToTyped(n.includes(":")?n:`address:${n}`,e):r[1]||e.pure.address(this.userWallet);return[e.object(a),c]}catch{return r}}extractObjectId(e){if(!e||typeof e!="string")return null;let t=e.startsWith("object:")?e.substring(7):e;return t.startsWith("0x")?t:null}async handleCoinTransfer(e,t,r){if(t==="0x2::sui::SUI")try{return e.splitCoins(e.gas,[r.toString()])[0]}catch{}return this.createCoinTransferFromObjects(e,t,r)}async createCoinTransferFromObjects(e,t,r){let i=await this.getCoinObjectsForTransfer(t,r);if(i.length===0)throw new Error(`No coin objects found for ${t}`);let n=e.object(i[0].coinObjectId);return i.length>1&&e.mergeCoins(n,i.slice(1).map(a=>e.object(a.coinObjectId))),e.splitCoins(n,[r.toString()])[0]}async getCoinObjectsForTransfer(e,t){if(!this.userWallet)throw new Error("User wallet not set");let{data:r}=await this.client.getCoins({owner:this.userWallet,coinType:e}),i=r.map(s=>({coinObjectId:s.coinObjectId,balance:s.balance})).sort((s,c)=>BigInt(c.balance)>BigInt(s.balance)?1:-1),n=BigInt(0),a=[];for(let s of i)if(a.push(s),n+=BigInt(s.balance),n>=t)return a;throw new Error(`Insufficient ${e} balance. Required: ${t}, Available: ${n}`)}};var D=class{constructor(e,t){this.config=e;this.chain=t}getExplorers(){let e=j[this.chain.name];if(!e)return["suivision"];let t=e[this.config.env];return t||["suivision"]}getPrimaryExplorer(){return this.getExplorers()[0]}getExplorerUrlByName(e){let t=this.config.preferences?.explorers?.[this.chain.name];if(t&&!e){let n=W[t];if(n)return n}if(e){let n=W[e];if(n)return n}let r=this.getPrimaryExplorer();return W[r]||W[r]}getAccountUrl(e,t){return`${this.getExplorerUrlByName(t)}/account/${e}`}getTransactionUrl(e,t){return`${this.getExplorerUrlByName(t)}/txblock/${e}`}getBlockUrl(e,t){return`${this.getExplorerUrlByName(t)}/block/${e}`}getAssetUrl(e,t){return`${this.getExplorerUrlByName(t)}/coin/${e}`}getContractUrl(e,t){return`${this.getExplorerUrlByName(t)}/object/${e}`}getAllExplorers(){return this.getExplorers()}getExplorerByName(e){return this.getExplorers().find(r=>r.toLowerCase()===e.toLowerCase())}getAccountUrls(e){let t=this.getAllExplorers(),r={};return t.forEach(i=>{let n=W[i];n&&(r[i]=`${n}/account/${e}`)}),r}getTransactionUrls(e){let t=this.getAllExplorers(),r={};return t.forEach(i=>{let n=W[i];n&&(r[i]=`${n}/txblock/${e}`)}),r}};var de=require("@joai/warps");var O=require("@mysten/sui/keypairs/ed25519"),pe=Ce(require("@scure/bip39"),1),ue=require("@scure/bip39/wordlists/english.js"),u=require("@joai/warps"),A=class A{constructor(e,t){this.config=e;this.chain=t;this.keypair=null}async getAddress(){return(0,u.getWarpWalletAddressFromConfig)(this.config,this.chain.name)}async getPublicKey(){try{let t=this.getKeypair().getPublicKey();return Buffer.from(t.toRawBytes()).toString("hex")}catch{return null}}async signTransaction(e){if(e&&typeof e=="object"&&"sign"in e&&typeof e.sign=="function")return e;let t=this.getKeypair(),r=new TextEncoder().encode(JSON.stringify(e)),i=await t.signPersonalMessage(r);return{...e,signature:i.signature}}async signMessage(e){let t=this.getKeypair(),r=new TextEncoder().encode(e);return(await t.signPersonalMessage(r)).signature}getKeypairInstance(){return this.getKeypair()}async importFromMnemonic(e){let t=(0,u.normalizeAndValidateMnemonic)(e),i=O.Ed25519Keypair.deriveKeypair(t).getPublicKey().toSuiAddress(),n={provider:A.PROVIDER_NAME,address:i,privateKey:null,mnemonic:t};return(0,u.setWarpWalletInConfig)(this.config,this.chain.name,n),n}async importFromPrivateKey(e){let t=Buffer.from(e,"hex"),r;if(t.length===70)r=new Uint8Array(t.subarray(1,33));else if(t.length===32)r=new Uint8Array(t);else throw new Error(`Unsupported private key length: ${t.length} bytes`);let n=O.Ed25519Keypair.fromSecretKey(r).getPublicKey().toSuiAddress(),a={provider:A.PROVIDER_NAME,address:n,privateKey:e,mnemonic:null};return(0,u.setWarpWalletInConfig)(this.config,this.chain.name,a),a}async export(){let e=this.getKeypair(),t=(0,u.getWarpWalletMnemonicFromConfig)(this.config,this.chain.name),r=(0,u.getWarpWalletPrivateKeyFromConfig)(this.config,this.chain.name);return{provider:A.PROVIDER_NAME,address:e.getPublicKey().toSuiAddress(),privateKey:r||null,mnemonic:t||null}}async generate(){let e=pe.generateMnemonic(ue.wordlist,256),t=(0,u.normalizeMnemonic)(e);(0,u.validateMnemonicLength)(t);let i=O.Ed25519Keypair.deriveKeypair(t).getPublicKey().toSuiAddress();return{provider:A.PROVIDER_NAME,address:i,privateKey:null,mnemonic:t}}async delete(e){(0,u.removeWarpWalletFromConfig)(this.config,this.chain.name)}getKeypair(){if(this.keypair)return this.keypair;let e=(0,u.getWarpWalletMnemonicFromConfig)(this.config,this.chain.name);if(!e)throw new Error("No mnemonic provided");return this.keypair=O.Ed25519Keypair.deriveKeypair(e.trim()),this.keypair}};A.PROVIDER_NAME="mnemonic";var T=A;var w=require("@joai/warps"),S=class{constructor(e,t){this.config=e;this.chain=t}async getAddress(){return(0,w.getWarpWalletAddressFromConfig)(this.config,this.chain.name)}async getPublicKey(){return null}async signTransaction(e){let t=await this.getAddress();throw new Error(`Wallet can not be used for signing: ${t}`)}async signMessage(e){let t=await this.getAddress();throw new Error(`Wallet can not be used for signing: ${t}`)}async importFromMnemonic(e){let t=(0,w.getWarpWalletAddressFromConfig)(this.config,this.chain.name);throw new Error(`Wallet can not be used for signing: ${t}`)}async importFromPrivateKey(e){let t=(0,w.getWarpWalletAddressFromConfig)(this.config,this.chain.name);throw new Error(`Wallet can not be used for signing: ${t}`)}async export(){let e=(0,w.getWarpWalletAddressFromConfig)(this.config,this.chain.name);throw new Error(`Wallet can not be used for signing: ${e}`)}async generate(){let e=(0,w.getWarpWalletAddressFromConfig)(this.config,this.chain.name);throw new Error(`Wallet can not be used for signing: ${e}`)}async delete(e){(0,w.removeWarpWalletFromConfig)(this.config,this.chain.name)}};var I=require("@mysten/sui/keypairs/ed25519"),m=require("@joai/warps"),E=class E{constructor(e,t){this.config=e;this.chain=t;this.keypair=null}async getAddress(){return(0,m.getWarpWalletAddressFromConfig)(this.config,this.chain.name)}async getPublicKey(){try{let t=this.getKeypair().getPublicKey();return Buffer.from(t.toRawBytes()).toString("hex")}catch{return null}}async signTransaction(e){if(e&&typeof e=="object"&&"sign"in e&&typeof e.sign=="function")return e;let t=this.getKeypair(),r=new TextEncoder().encode(JSON.stringify(e)),i=await t.signPersonalMessage(r);return{...e,signature:i.signature}}async signMessage(e){let t=this.getKeypair(),r=new TextEncoder().encode(e);return(await t.signPersonalMessage(r)).signature}getKeypairInstance(){return this.getKeypair()}async importFromMnemonic(e){let t=I.Ed25519Keypair.deriveKeypair(e.trim()),r=t.getPublicKey().toSuiAddress(),i=Buffer.from(t.getSecretKey()).toString("hex"),n={provider:E.PROVIDER_NAME,address:r,privateKey:i,mnemonic:e};return(0,m.setWarpWalletInConfig)(this.config,this.chain.name,n),n}async importFromPrivateKey(e){let t=Buffer.from(e,"hex"),r;if(t.length===70)r=new Uint8Array(t.subarray(1,33));else if(t.length===32)r=new Uint8Array(t);else throw new Error(`Unsupported private key length: ${t.length} bytes`);let n=I.Ed25519Keypair.fromSecretKey(r).getPublicKey().toSuiAddress(),a={provider:E.PROVIDER_NAME,address:n,privateKey:e,mnemonic:null};return(0,m.setWarpWalletInConfig)(this.config,this.chain.name,a),a}async export(){let e=this.getKeypair(),t=(0,m.getWarpWalletPrivateKeyFromConfig)(this.config,this.chain.name),r=(0,m.getWarpWalletMnemonicFromConfig)(this.config,this.chain.name);return{provider:E.PROVIDER_NAME,address:e.getPublicKey().toSuiAddress(),privateKey:t||null,mnemonic:r||null}}async generate(){let e=I.Ed25519Keypair.generate(),t=e.getPublicKey().toSuiAddress(),r=Buffer.from(e.getSecretKey()).toString("hex");return{provider:E.PROVIDER_NAME,address:t,privateKey:r,mnemonic:null}}async delete(e){(0,m.removeWarpWalletFromConfig)(this.config,this.chain.name)}getKeypair(){if(this.keypair)return this.keypair;let e=(0,m.getWarpWalletPrivateKeyFromConfig)(this.config,this.chain.name);if(!e)throw new Error("Wallet not initialized - no private key provided");try{let t=Buffer.from(e,"hex");if(t.length===70){let r=new Uint8Array(t.subarray(1,33));return this.keypair=I.Ed25519Keypair.fromSecretKey(r),this.keypair}else{if(t.length===32)return this.keypair=I.Ed25519Keypair.fromSecretKey(new Uint8Array(t)),this.keypair;throw new Error(`Unsupported private key length: ${t.length} bytes`)}}catch(t){throw t}}};E.PROVIDER_NAME="privateKey";var x=E;var z=class{constructor(e,t){this.config=e;this.chain=t;this.cachedAddress=null;this.cachedPublicKey=null;this.client=M(e,t),this.walletProvider=this.createProvider(),this.isInitializedPromise=new Promise(r=>{this.isInitializedResolve=r}),this.initializeCache()}async waitUntilInitialized(){await this.isInitializedPromise}async signTransaction(e){if(await this.waitUntilInitialized(),!e||typeof e!="object")throw new Error("Invalid transaction object");if(!this.walletProvider)throw new Error("No wallet provider available");if(this.walletProvider instanceof S)throw new Error(`Wallet (${this.chain.name}) is read-only`);return(this.walletProvider instanceof x||this.walletProvider instanceof T)&&e&&typeof e=="object"&&"sign"in e&&typeof e.sign=="function"?e:await this.walletProvider.signTransaction(e)}async signMessage(e){if(await this.waitUntilInitialized(),!this.walletProvider)throw new Error("No wallet provider available");if(this.walletProvider instanceof S)throw new Error(`Wallet (${this.chain.name}) is read-only`);return await this.walletProvider.signMessage(e)}async signTransactions(e){return await this.waitUntilInitialized(),e}async sendTransaction(e){if(await this.waitUntilInitialized(),!e||typeof e!="object")throw new Error("Invalid transaction object");if(e.transactionHash)return e.transactionHash;if(e&&typeof e=="object"&&"bytes"in e&&"signature"in e)return(await this.client.executeTransactionBlock({transactionBlock:e.bytes,signature:Array.isArray(e.signature)?e.signature:[e.signature],options:{showEffects:!0,showEvents:!0}})).digest;if(!this.walletProvider)throw new Error("No wallet provider available");if(this.walletProvider instanceof x||this.walletProvider instanceof T){let t=this.walletProvider.getKeypairInstance();if(e&&typeof e=="object"&&"sign"in e&&typeof e.sign=="function")return(await this.client.signAndExecuteTransaction({transaction:e,signer:t,options:{showEffects:!0,showEvents:!0}})).digest;throw new Error(`Transaction must be a Transaction object or have bytes and signature. Got: ${typeof e}, has sign: ${e&&typeof e=="object"&&"sign"in e}, has bytes: ${e&&typeof e=="object"&&"bytes"in e}, has signature: ${e&&typeof e=="object"&&"signature"in e}`)}throw new Error("Remote wallet provider must return signed payload (bytes + signature) or transactionHash for Sui transactions")}async sendTransactions(e){return await this.waitUntilInitialized(),Promise.all(e.map(async t=>this.sendTransaction(t)))}async importFromMnemonic(e){return await this.waitUntilInitialized(),await this.createProviderForOperation("mnemonic").importFromMnemonic(e)}async importFromPrivateKey(e){return await this.waitUntilInitialized(),await this.createProviderForOperation("privateKey").importFromPrivateKey(e)}async export(e){return await this.waitUntilInitialized(),await this.createProviderForOperation(e).export()}async generate(e){return await this.waitUntilInitialized(),await this.createProviderForOperation(e).generate()}async delete(e,t){await this.waitUntilInitialized(),await this.createProviderForOperation(e).delete(t)}getAddress(){return this.cachedAddress}getPublicKey(){return this.cachedPublicKey}createProvider(){let e=this.config.user?.wallets?.[this.chain.name];return e?typeof e=="string"?new S(this.config,this.chain):e.provider?this.createProviderForOperation(e.provider):new S(this.config,this.chain):null}async initializeCache(){let e=await(0,de.initializeWalletCache)(this.walletProvider);this.cachedAddress=e.address,this.cachedPublicKey=e.publicKey,this.isInitializedResolve()}createProviderForOperation(e){let r=this.config.walletProviders?.[this.chain.name]?.[e];if(r){let i=r(this.config,this.chain);if(!i)throw new Error(`Custom wallet provider factory returned null for ${e}`);return i}if(e==="privateKey")return new x(this.config,this.chain);if(e==="mnemonic")return new T(this.config,this.chain);throw new Error(`Unsupported wallet provider for ${this.chain.name}: ${e}`)}};var R={chain:U.WarpChainName.Sui,identifier:"0x2::sui::SUI",name:"SUI",symbol:"SUI",decimals:9,logoUrl:"https://assets.coingecko.com/coins/images/26375/standard/sui-ocean-square.png?1727791290"};function Se(o,e){return(t,r)=>{if(!r)throw new Error(`${o} adapter requires a fallback adapter`);let i=e[t.env];if(!i)throw new Error(`SuiAdapter: chain info not found for chain ${o}`);return{chainInfo:i,builder:()=>new B(t,i),executor:new N(t,i),output:new b(t,i),serializer:new y,registry:r.registry,explorer:new D(t,i),abiBuilder:()=>new C(t,i),brandBuilder:()=>new K(t,i),dataLoader:new k(t,i),wallet:new z(t,i)}}}var Ee=Se(U.WarpChainName.Sui,{mainnet:{name:U.WarpChainName.Sui,displayName:"Sui",chainId:"1",blockTime:3e3,addressHrp:"sui",defaultApiUrl:"https://fullnode.mainnet.sui.io",logoUrl:"https://raw.githubusercontent.com/JoAiHQ/assets/refs/heads/main/chains/logos/sui.svg",nativeToken:R},testnet:{name:U.WarpChainName.Sui,displayName:"Sui Testnet",chainId:"testnet",blockTime:3e3,addressHrp:"sui",defaultApiUrl:"https://fullnode.testnet.sui.io",logoUrl:"https://raw.githubusercontent.com/JoAiHQ/assets/refs/heads/main/chains/logos/sui.svg",nativeToken:R},devnet:{name:U.WarpChainName.Sui,displayName:"Sui Devnet",chainId:"devnet",blockTime:3e3,addressHrp:"sui",defaultApiUrl:"https://fullnode.devnet.sui.io",logoUrl:"https://raw.githubusercontent.com/JoAiHQ/assets/refs/heads/main/chains/logos/sui.svg",nativeToken:R}});var _=class{constructor(e,t){this.abi=new C(e,t)}async loadModuleAbi(e,t){return this.abi.getModuleAbi(e,t)}async loadFunctionAbi(e,t,r){return this.abi.getFunctionAbi(e,t,r)}};0&&(module.exports={ExplorerUrls,KnownTokens,NativeTokenSui,SuiAdapter,SuiExplorers,SuiExplorersConfig,WarpSuiAbiBuilder,WarpSuiBrandBuilder,WarpSuiBuilder,WarpSuiConstants,WarpSuiContractLoader,WarpSuiDataLoader,WarpSuiExecutor,WarpSuiExplorer,WarpSuiOutput,WarpSuiSerializer,WarpSuiWallet,findKnownTokenById,getConfiguredSuiClient});
|
package/dist/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var Me={Sui:{Identifier:"SUI",DisplayName:"Sui",Decimals:9}},X=(a=>(a.SuiVision="suivision",a.SuiVisionTestnet="suivision_testnet",a.SuiVisionDevnet="suivision_devnet",a.SuiScan="suiscan",a.SuiScanTestnet="suiscan_testnet",a.SuiScanDevnet="suiscan_devnet",a))(X||{}),O={sui:{mainnet:["suivision","suiscan"],testnet:["suivision_testnet","suiscan_testnet"],devnet:["suivision_devnet","suiscan_devnet"]}},g={suivision:"https://suivision.xyz",suivision_testnet:"https://testnet.suivision.xyz",suivision_devnet:"https://devnet.suivision.xyz",suiscan:"https://suiscan.xyz",suiscan_testnet:"https://testnet.suiscan.xyz",suiscan_devnet:"https://devnet.suiscan.xyz"};import{SuiClient as Y}from"@mysten/sui/client";import{getProviderConfig as Z}from"@joai/warps";var z=(l,e)=>{let t=Z(l,e.name,l.env,e.defaultApiUrl);return new Y({url:t.url})};import{WarpChainName as S}from"@joai/warps";import{SuiClient as ee}from"@mysten/sui/client";import{getProviderConfig as te}from"@joai/warps";var W=class{constructor(e,t){this.config=e;this.chain=t;let r=te(this.config,this.chain.name,this.config.env,this.chain.defaultApiUrl);this.client=new ee({url:r.url})}async createInscriptionTransaction(e){throw new Error("WarpSuiAbiBuilder: createInscriptionTransaction not implemented")}async createFromRaw(e){return JSON.parse(e)}async createFromTransaction(e){return this.createFromRaw(e.data||"{}")}async createFromTransactionHash(e,t){try{let r=await this.client.getTransactionBlock({digest:e});return r?this.createFromTransaction(r):null}catch{return null}}async getModuleAbi(e,t){return this.client.getNormalizedMoveModule({package:e,module:t})}async getFunctionAbi(e,t,r){return this.client.getNormalizedMoveFunction({package:e,module:t,function:r})}};import{SuiClient as re}from"@mysten/sui/client";import{Transaction as ie}from"@mysten/sui/transactions";import{getProviderConfig as ne}from"@joai/warps";var E=class{constructor(e,t){this.config=e;this.chain=t;let r=ne(this.config,this.chain.name,this.config.env,this.chain.defaultApiUrl);this.client=new re({url:r.url})}createInscriptionTransaction(e){return new ie}async createFromRaw(e){return JSON.parse(e)}async createFromTransaction(e,t){return this.createFromRaw(e.data||"{}")}async createFromTransactionHash(e,t){try{let r=await this.client.getTransactionBlock({digest:e});return r?this.createFromTransaction(r,!1):null}catch{return null}}};import{SuiClient as ae}from"@mysten/sui/client";import{getProviderConfig as se,WarpBuilder as oe,WarpCache as ce}from"@joai/warps";var T=class extends oe{constructor(t,r){super(t);this.config=t;this.chain=r;this.cache=new ce(t.env,t.cache);let i=se(this.config,this.chain.name,this.config.env,this.chain.defaultApiUrl);this.client=new ae({url:i.url})}async createInscriptionTransaction(t){throw new Error("WarpSuiBuilder: on-chain inscription is not supported for Sui")}async createFromTransaction(t){return this.createFromRaw(t)}async createFromTransactionHash(t,r){return null}};import{SuiClient as ue}from"@mysten/sui/client";import{CacheTtl as de,getProviderConfig as he,WarpCache as ge,WarpCacheKey as me}from"@joai/warps";import{WarpChainName as le}from"@joai/warps";var d=le.Sui,pe=[{chain:d,identifier:"0x2::sui::SUI",name:"Sui",symbol:"SUI",decimals:9,logoUrl:"https://assets.coingecko.com/coins/images/26375/small/sui-logo.png"},{chain:d,identifier:"0xa198f3be41cda8c07c3bf1c4e0bb88b8e9827b7c063f36b1e6c3d6da1c4e8753::usdc::USDC",name:"USD Coin",symbol:"USDC",decimals:6,logoUrl:"https://assets.coingecko.com/coins/images/6319/small/USD_Coin_icon.png"},{chain:d,identifier:"0xc060006111016b8a020ad5b33834984a437aaa7d3c74c18e09a95d48ace0cdd97::usdt::USDT",name:"Tether USD",symbol:"USDT",decimals:6,logoUrl:"https://assets.coingecko.com/coins/images/325/small/Tether.png"},{chain:d,identifier:"0xaf8cd5edc19c4512f4259f0bee101a7c94d8a5c0e7c90c7a7c8c8c8c8c8c8c8c8::wbtc::WBTC",name:"Wrapped Bitcoin",symbol:"WBTC",decimals:8,logoUrl:"https://assets.coingecko.com/coins/images/7598/small/wrapped_bitcoin_wbtc.png"},{chain:d,identifier:"0xb8a6a9b7c7a6f4a3e2d1c0b9a8f7e6d5c4b3a2b1c0d9e8f7a6b5c4d3e2f1a0b::weth::WETH",name:"Wrapped Ether",symbol:"WETH",decimals:8,logoUrl:"https://assets.coingecko.com/coins/images/2518/small/weth.png"},{chain:d,identifier:"0x5d4b302506645c37ff133b98c4b50a5ae14841659738d6d733d59d0d217a15e0e9::ocean::OCEAN",name:"Ocean Protocol",symbol:"OCEAN",decimals:9,logoUrl:"https://assets.coingecko.com/coins/images/3687/small/ocean-protocol-logo.png"},{chain:d,identifier:"0x5d1f47ea69bb0de31c313d7acf89b890dbb8991ea8e03c6c35569693fd50fb8b7::deep::DEEP",name:"DeepBook",symbol:"DEEP",decimals:6,logoUrl:"https://assets.coingecko.com/coins/images/30169/small/deepbook.png"},{chain:d,identifier:"0xbde4ba4c2e274a60ce15c1cfff9e5c42e41654ac8b6d906a57efa4bd3c29f47ba3::hasui::HASUI",name:"Haedal Staked SUI",symbol:"HASUI",decimals:9,logoUrl:"https://assets.coingecko.com/coins/images/30027/small/haSUI.png"},{chain:d,identifier:"0xdba34672e30cb065b1f93e3ab55318768fd6fef66c15942c9f7cb846e2f900e935::usdc::USDC",name:"USD Coin (Wormhole)",symbol:"USDC",decimals:6,logoUrl:"https://assets.coingecko.com/coins/images/6319/small/USD_Coin_icon.png"}],$=l=>pe.find(e=>e.identifier===l)||null;var I=class{constructor(e,t){this.config=e;this.chain=t;let r=he(this.config,this.chain.name,this.config.env,this.chain.defaultApiUrl);this.client=new ue({url:r.url}),this.cache=new ge(e.env,e.cache)}async getAccount(e){let t=await this.client.getBalance({owner:e,coinType:"0x2::sui::SUI"});return{chain:this.chain.name,address:e,balance:BigInt(t.totalBalance)}}async getAccountAssets(e){let t=await this.client.getAllBalances({owner:e});console.log("WarpSuiDataLoader.getAccountAssets",t);let r=t.find(a=>a.coinType==="0x2::sui::SUI"),i=t.filter(a=>a.coinType!=="0x2::sui::SUI"&&BigInt(a.totalBalance)>0n),n=[];if(r&&BigInt(r.totalBalance)>0n&&n.push({...this.chain.nativeToken,amount:BigInt(r.totalBalance)}),i.length>0){let a=await Promise.all(i.map(s=>this.getAsset(s.coinType)));n.push(...a.filter(s=>s!==null).map(s=>({...s,amount:BigInt(i.find(o=>o.coinType===s.identifier)?.totalBalance||0)})))}return n}async getAsset(e){let t=me.Asset(this.config.env,this.chain.name,e),r=await this.cache.get(t);if(r)return r;let i=$(e);if(i)return{chain:this.chain.name,identifier:e,name:i.name,symbol:i.symbol,amount:0n,decimals:i.decimals,logoUrl:i.logoUrl};try{let n=await this.client.getCoinMetadata({coinType:e}),a={chain:this.chain.name,identifier:e,name:n?.name||e.split("::").pop()||e,symbol:n?.symbol||e.split("::").pop()||e,amount:0n,decimals:n?.decimals||9,logoUrl:n?.iconUrl||""};return await this.cache.set(t,a,de.OneHour),a}catch{return null}}async getAccountNfts(e,t){try{let r=t?.size||25,i=t?.page||0,n;for(let o=0;o<i;o++){let c=await this.client.getOwnedObjects({owner:e,options:{showContent:!1,showDisplay:!1},limit:r,cursor:n});if(n=c.nextCursor,!c.hasNextPage)return[]}let a=await this.client.getOwnedObjects({owner:e,options:{showContent:!0,showDisplay:!0},limit:r,cursor:n}),s=[];for(let o of a.data){let c=o.data?.content,p=o.data?.display?.data,u=c?.type||"";if(u.startsWith("0x2::coin::Coin"))continue;let P=o.data?.objectId||"",J=p?.name||u.split("::").pop()||P.slice(0,8),q=u.includes("::")?u.split("::").slice(0,2).join("::"):void 0,D=p?.image_url;s.push({chain:this.chain.name,identifier:P,name:J,symbol:"",amount:1n,decimals:0,type:"nft",nft:{collection:q,mediaUrl:D,thumbnailUrl:D}})}return s}catch{return[]}}async getAction(e,t=!1){return null}async getAccountActions(e,t){return[]}};import{SuiClient as Ae}from"@mysten/sui/client";import{Transaction as M}from"@mysten/sui/transactions";import{applyOutputToMessages as Se,extractResolvedInputValues as Pe,getNextInfo as Ee,getProviderConfig as Te,getWarpActionByIndex as k,getWarpWalletAddressFromConfig as Ie}from"@joai/warps";import{SuiClient as We}from"@mysten/sui/client";import{applyOutputToMessages as ve,evaluateOutputCommon as F,getNextInfo as we,getProviderConfig as Ce,getWarpWalletAddressFromConfig as be,parseOutputOutIndex as j,WarpConstants as R}from"@joai/warps";import{Transaction as fe}from"@mysten/sui/transactions";import{WarpSerializer as ye}from"@joai/warps";var h=class{constructor(){this.coreSerializer=new ye}typedToString(e){if(e==null)return"option:null";if(typeof e=="string")return`string:${e}`;if(typeof e=="boolean")return`bool:${e}`;if(typeof e=="number")return`uint64:${e.toString()}`;if(typeof e=="bigint")return`uint64:${e.toString()}`;if(e&&typeof e=="object"&&e.address)return`address:${e.address}`;if(Array.isArray(e)){if(e.length===0)return"vector:u8:";let t=this.typeToString(typeof e[0]),r=e.map(i=>this.typedToString(i).split(":")[1]);return`vector:${t}:${r.join(",")}`}if(e&&typeof e=="object"&&e.type&&e.value&&e.type==="option")return e.value===null||e.value===void 0?"option:null":`option:${this.typedToString(e.value)}`;throw new Error(`WarpSuiSerializer (typedToString): Unsupported input type: ${typeof e}`)}typedToNative(e){let t=this.typedToString(e);return this.coreSerializer.stringToNative(t)}nativeToTyped(e,t){let r=this.coreSerializer.nativeToString(e,t);return this.stringToTyped(r)}stringToTyped(e,t){let r=t||new fe,[i,n]=e.split(/:(.*)/,2);if(i==="object")return r.object(n);if(i==="string")return r.pure.string(n);if(i==="bool")return r.pure.bool(n==="true");if(i==="u8")return r.pure.u8(Number(n));if(i==="u16")return r.pure.u16(Number(n));if(i==="u32")return r.pure.u32(Number(n));if(i==="u64"||i==="uint64")return r.pure.u64(BigInt(n));if(i==="u128")return r.pure.u128(BigInt(n));if(i==="u256")return r.pure.u256(BigInt(n));if(i==="address")return r.pure.address(n);throw new Error(`WarpSuiSerializer (stringToTyped): Unsupported type: ${i}`)}typeToString(e){if(e==="string")return"string";if(e==="bool")return"bool";if(e==="u8")return"u8";if(e==="u16")return"u16";if(e==="u32")return"u32";if(e==="u64"||e==="bigint"||e==="number")return"u64";if(e==="u128")return"u128";if(e==="u256")return"u256";if(e==="address")return"address";if(e==="vector")return"vector";if(e==="option")return"option";throw new Error(`WarpSuiSerializer (typeToString): Unsupported input type: ${e}`)}nativeToType(e){throw new Error("Not implemented")}};var v=class{constructor(e,t){this.config=e;this.chain=t;this.serializer=new h;let r=Ce(this.config,this.chain.name,this.config.env,this.chain.defaultApiUrl);this.client=new We({url:r.url})}async getActionExecution(e,t,r){let i=await this.extractContractOutput(e,t,r,[]),n=we(this.config,[],e,t,i.output),a=ve(e,i.output,this.config);return{status:r.effects?.status?.status==="success"?"success":"error",warp:e,action:t,user:be(this.config,this.chain.name),txHash:r.digest,tx:r,next:n,values:i.values,output:i.output,messages:a,destination:null,resolvedInputs:[]}}async extractContractOutput(e,t,r,i){let n=[],a=[],s={};if(!e.output)return{values:{string:n,native:a,mapped:{}},output:s};for(let[o,c]of Object.entries(e.output)){if(c.startsWith(R.Transform.Prefix))continue;if(c.startsWith("input.")){s[o]=c;continue}let p=j(c);if(p!==null&&p!==t){s[o]=null;continue}if(c.startsWith("out.")){let u=r.returnValues?r.returnValues[o]:null;s[o]=u,n.push(String(u)),a.push(u)}else s[o]=c}return{values:{string:n,native:a,mapped:{}},output:await F(e,s,a,t,i,this.serializer.coreSerializer,this.config)}}async extractQueryOutput(e,t,r,i){let n=t.map(c=>String(c)),a=t,s={string:n,native:a,mapped:{}},o={};if(!e.output)return{values:s,output:o};for(let[c,p]of Object.entries(e.output)){if(p.startsWith(R.Transform.Prefix))continue;let u=j(p);if(u!==null&&u!==r){o[c]=null;continue}if(p.startsWith("out.")||p==="out")if(Array.isArray(t)&&t.length>0&&typeof t[0]=="object"&&t[0]!==null){let P=p.replace(/^out\./,"");o[c]=t[0][P]}else o[c]=t[0];else o[c]=p}return{values:s,output:await F(e,o,a,r,i,this.serializer.coreSerializer,this.config)}}};var x=class{constructor(e,t){this.config=e;this.chain=t;this.serializer=new h,this.output=new v(this.config,this.chain);let r=Te(this.config,this.chain.name,this.config.env,this.chain.defaultApiUrl);this.client=new Ae({url:r.url}),this.userWallet=Ie(this.config,this.chain.name)}async createTransaction(e){let t=k(e.warp,e.action);if(t.type==="transfer")return this.createTransferTransaction(e);if(t.type==="contract")return this.createContractCallTransaction(e);throw t.type==="query"?new Error("WarpSuiExecutor: Invalid action type for createTransaction; Use executeQuery instead"):t.type==="collect"?new Error("WarpSuiExecutor: Invalid action type for createTransaction; Use executeCollect instead"):new Error(`WarpSuiExecutor: Invalid action type (${t.type})`)}async createTransferTransaction(e){if(!this.userWallet)throw new Error("WarpSuiExecutor: createTransfer - user address not set");if(!e.destination)throw new Error("WarpSuiExecutor: Invalid destination address");if(e.value<0)throw new Error(`WarpSuiExecutor: Transfer value cannot be negative: ${e.value}`);let t=new M,r=[];if(e.value>0){let i=await this.handleCoinTransfer(t,"0x2::sui::SUI",e.value);r.push(i)}for(let i of e.transfers){let n=await this.handleCoinTransfer(t,i.identifier,i.amount);r.push(n)}return r.length>0&&t.transferObjects(r,t.pure.address(e.destination)),t}async createContractCallTransaction(e){if(!this.userWallet)throw new Error("WarpSuiExecutor: createContractCall - user address not set");if(!e.destination)throw new Error("WarpSuiExecutor: Invalid contract address");if(e.value<0)throw new Error(`WarpSuiExecutor: Contract call value cannot be negative: ${e.value}`);let t=k(e.warp,e.action);if(!t.func)throw new Error("WarpSuiExecutor: createContractCall - function not set");let r=new M;r.setSender(this.userWallet);let i=[];e.value>0&&i.push(await this.handleCoinTransfer(r,"0x2::sui::SUI",e.value));for(let o of e.transfers)i.push(await this.handleCoinTransfer(r,o.identifier,o.amount));let{target:n,typeArguments:a}=this.parseMoveCallTarget(t),s=e.args.map(o=>this.serializer.stringToTyped(o,r));return n==="0x2::transfer::public_transfer"?i.push(...await this.buildPublicTransferArgs(r,e,s)):i.push(...s),r.moveCall({target:n,arguments:i,typeArguments:a}),r.setGasBudget(1e8),r}async executeQuery(e){if(!e.destination)throw new Error("WarpSuiExecutor: executeQuery - destination not set");let t=k(e.warp,e.action);if(t.type!=="query")throw new Error(`WarpSuiExecutor: Invalid action type for executeQuery: ${t.type}`);let r=await this.client.getObject({id:e.destination,options:{showContent:!0}}),i=[r],{values:n,output:a}=await this.output.extractQueryOutput(e.warp,i,e.action,e.resolvedInputs),s=Ee(this.config,[],e.warp,e.action,a),c=e.resolvedInputs.find(u=>u.input.position==="receiver"||u.input.position==="destination")?.value||e.destination,p=Pe(e.resolvedInputs);return{status:"success",warp:e.warp,action:e.action,user:this.userWallet,txHash:null,tx:null,next:s,values:n,output:{...a,_DATA:r},resolvedInputs:p,messages:Se(e.warp,a,this.config),destination:c}}async signMessage(e,t){throw new Error("Not implemented")}parseMoveCallTarget(e){if(!e.func)throw new Error("WarpSuiExecutor: Function not set");let t=`${e.address}::${e.func}`,r=e.typeArguments;if(!r&&e.func.includes("<")&&e.func.includes(">")){let i=e.func.match(/<([^>]+)>/);i&&(r=[i[1]],t=`${e.address}::${e.func.replace(/<[^>]+>/,"")}`)}return{target:t,typeArguments:r}}async buildPublicTransferArgs(e,t,r){let i=t.resolvedInputs.find(s=>String(s.input.position)==="arg:0")?.value||t.args[0],n=t.resolvedInputs.find(s=>String(s.input.position)==="arg:1")?.value||t.resolvedInputs.find(s=>s.input.type==="address"&&String(s.input.position)!=="arg:0")?.value||t.args[1],a=this.extractObjectId(i);if(!a)return r;try{if(!(await this.client.getObject({id:a,options:{showType:!0,showContent:!0}})).data?.type?.startsWith("0x2::coin::Coin<"))return r;let o=n?this.serializer.stringToTyped(n.includes(":")?n:`address:${n}`,e):r[1]||e.pure.address(this.userWallet);return[e.object(a),o]}catch{return r}}extractObjectId(e){if(!e||typeof e!="string")return null;let t=e.startsWith("object:")?e.substring(7):e;return t.startsWith("0x")?t:null}async handleCoinTransfer(e,t,r){if(t==="0x2::sui::SUI")try{return e.splitCoins(e.gas,[r.toString()])[0]}catch{}return this.createCoinTransferFromObjects(e,t,r)}async createCoinTransferFromObjects(e,t,r){let i=await this.getCoinObjectsForTransfer(t,r);if(i.length===0)throw new Error(`No coin objects found for ${t}`);let n=e.object(i[0].coinObjectId);return i.length>1&&e.mergeCoins(n,i.slice(1).map(a=>e.object(a.coinObjectId))),e.splitCoins(n,[r.toString()])[0]}async getCoinObjectsForTransfer(e,t){if(!this.userWallet)throw new Error("User wallet not set");let{data:r}=await this.client.getCoins({owner:this.userWallet,coinType:e}),i=r.map(s=>({coinObjectId:s.coinObjectId,balance:s.balance})).sort((s,o)=>BigInt(o.balance)>BigInt(s.balance)?1:-1),n=BigInt(0),a=[];for(let s of i)if(a.push(s),n+=BigInt(s.balance),n>=t)return a;throw new Error(`Insufficient ${e} balance. Required: ${t}, Available: ${n}`)}};var U=class{constructor(e,t){this.config=e;this.chain=t}getExplorers(){let e=O[this.chain.name];if(!e)return["suivision"];let t=e[this.config.env];return t||["suivision"]}getPrimaryExplorer(){return this.getExplorers()[0]}getExplorerUrlByName(e){let t=this.config.preferences?.explorers?.[this.chain.name];if(t&&!e){let n=g[t];if(n)return n}if(e){let n=g[e];if(n)return n}let r=this.getPrimaryExplorer();return g[r]||g[r]}getAccountUrl(e,t){return`${this.getExplorerUrlByName(t)}/account/${e}`}getTransactionUrl(e,t){return`${this.getExplorerUrlByName(t)}/txblock/${e}`}getBlockUrl(e,t){return`${this.getExplorerUrlByName(t)}/block/${e}`}getAssetUrl(e,t){return`${this.getExplorerUrlByName(t)}/coin/${e}`}getContractUrl(e,t){return`${this.getExplorerUrlByName(t)}/object/${e}`}getAllExplorers(){return this.getExplorers()}getExplorerByName(e){return this.getExplorers().find(r=>r.toLowerCase()===e.toLowerCase())}getAccountUrls(e){let t=this.getAllExplorers(),r={};return t.forEach(i=>{let n=g[i];n&&(r[i]=`${n}/account/${e}`)}),r}getTransactionUrls(e){let t=this.getAllExplorers(),r={};return t.forEach(i=>{let n=g[i];n&&(r[i]=`${n}/txblock/${e}`)}),r}};import{initializeWalletCache as je}from"@joai/warps";import{Ed25519Keypair as K}from"@mysten/sui/keypairs/ed25519";import*as _ from"@scure/bip39";import{wordlist as xe}from"@scure/bip39/wordlists/english.js";import{getWarpWalletAddressFromConfig as Ue,getWarpWalletMnemonicFromConfig as V,getWarpWalletPrivateKeyFromConfig as Ke,normalizeAndValidateMnemonic as Be,normalizeMnemonic as ke,removeWarpWalletFromConfig as Ne,setWarpWalletInConfig as H,validateMnemonicLength as De}from"@joai/warps";var m=class m{constructor(e,t){this.config=e;this.chain=t;this.keypair=null}async getAddress(){return Ue(this.config,this.chain.name)}async getPublicKey(){try{let t=this.getKeypair().getPublicKey();return Buffer.from(t.toRawBytes()).toString("hex")}catch{return null}}async signTransaction(e){if(e&&typeof e=="object"&&"sign"in e&&typeof e.sign=="function")return e;let t=this.getKeypair(),r=new TextEncoder().encode(JSON.stringify(e)),i=await t.signPersonalMessage(r);return{...e,signature:i.signature}}async signMessage(e){let t=this.getKeypair(),r=new TextEncoder().encode(e);return(await t.signPersonalMessage(r)).signature}getKeypairInstance(){return this.getKeypair()}async importFromMnemonic(e){let t=Be(e),i=K.deriveKeypair(t).getPublicKey().toSuiAddress(),n={provider:m.PROVIDER_NAME,address:i,privateKey:null,mnemonic:t};return H(this.config,this.chain.name,n),n}async importFromPrivateKey(e){let t=Buffer.from(e,"hex"),r;if(t.length===70)r=new Uint8Array(t.subarray(1,33));else if(t.length===32)r=new Uint8Array(t);else throw new Error(`Unsupported private key length: ${t.length} bytes`);let n=K.fromSecretKey(r).getPublicKey().toSuiAddress(),a={provider:m.PROVIDER_NAME,address:n,privateKey:e,mnemonic:null};return H(this.config,this.chain.name,a),a}async export(){let e=this.getKeypair(),t=V(this.config,this.chain.name),r=Ke(this.config,this.chain.name);return{provider:m.PROVIDER_NAME,address:e.getPublicKey().toSuiAddress(),privateKey:r||null,mnemonic:t||null}}async generate(){let e=_.generateMnemonic(xe,256),t=ke(e);De(t);let i=K.deriveKeypair(t).getPublicKey().toSuiAddress();return{provider:m.PROVIDER_NAME,address:i,privateKey:null,mnemonic:t}}async delete(e){Ne(this.config,this.chain.name)}getKeypair(){if(this.keypair)return this.keypair;let e=V(this.config,this.chain.name);if(!e)throw new Error("No mnemonic provided");return this.keypair=K.deriveKeypair(e.trim()),this.keypair}};m.PROVIDER_NAME="mnemonic";var w=m;import{getWarpWalletAddressFromConfig as b,removeWarpWalletFromConfig as Oe}from"@joai/warps";var f=class{constructor(e,t){this.config=e;this.chain=t}async getAddress(){return b(this.config,this.chain.name)}async getPublicKey(){return null}async signTransaction(e){let t=await this.getAddress();throw new Error(`Wallet can not be used for signing: ${t}`)}async signMessage(e){let t=await this.getAddress();throw new Error(`Wallet can not be used for signing: ${t}`)}async importFromMnemonic(e){let t=b(this.config,this.chain.name);throw new Error(`Wallet can not be used for signing: ${t}`)}async importFromPrivateKey(e){let t=b(this.config,this.chain.name);throw new Error(`Wallet can not be used for signing: ${t}`)}async export(){let e=b(this.config,this.chain.name);throw new Error(`Wallet can not be used for signing: ${e}`)}async generate(){let e=b(this.config,this.chain.name);throw new Error(`Wallet can not be used for signing: ${e}`)}async delete(e){Oe(this.config,this.chain.name)}};import{Ed25519Keypair as A}from"@mysten/sui/keypairs/ed25519";import{getWarpWalletAddressFromConfig as ze,getWarpWalletMnemonicFromConfig as $e,getWarpWalletPrivateKeyFromConfig as G,removeWarpWalletFromConfig as Fe,setWarpWalletInConfig as Q}from"@joai/warps";var y=class y{constructor(e,t){this.config=e;this.chain=t;this.keypair=null}async getAddress(){return ze(this.config,this.chain.name)}async getPublicKey(){try{let t=this.getKeypair().getPublicKey();return Buffer.from(t.toRawBytes()).toString("hex")}catch{return null}}async signTransaction(e){if(e&&typeof e=="object"&&"sign"in e&&typeof e.sign=="function")return e;let t=this.getKeypair(),r=new TextEncoder().encode(JSON.stringify(e)),i=await t.signPersonalMessage(r);return{...e,signature:i.signature}}async signMessage(e){let t=this.getKeypair(),r=new TextEncoder().encode(e);return(await t.signPersonalMessage(r)).signature}getKeypairInstance(){return this.getKeypair()}async importFromMnemonic(e){let t=A.deriveKeypair(e.trim()),r=t.getPublicKey().toSuiAddress(),i=Buffer.from(t.getSecretKey()).toString("hex"),n={provider:y.PROVIDER_NAME,address:r,privateKey:i,mnemonic:e};return Q(this.config,this.chain.name,n),n}async importFromPrivateKey(e){let t=Buffer.from(e,"hex"),r;if(t.length===70)r=new Uint8Array(t.subarray(1,33));else if(t.length===32)r=new Uint8Array(t);else throw new Error(`Unsupported private key length: ${t.length} bytes`);let n=A.fromSecretKey(r).getPublicKey().toSuiAddress(),a={provider:y.PROVIDER_NAME,address:n,privateKey:e,mnemonic:null};return Q(this.config,this.chain.name,a),a}async export(){let e=this.getKeypair(),t=G(this.config,this.chain.name),r=$e(this.config,this.chain.name);return{provider:y.PROVIDER_NAME,address:e.getPublicKey().toSuiAddress(),privateKey:t||null,mnemonic:r||null}}async generate(){let e=A.generate(),t=e.getPublicKey().toSuiAddress(),r=Buffer.from(e.getSecretKey()).toString("hex");return{provider:y.PROVIDER_NAME,address:t,privateKey:r,mnemonic:null}}async delete(e){Fe(this.config,this.chain.name)}getKeypair(){if(this.keypair)return this.keypair;let e=G(this.config,this.chain.name);if(!e)throw new Error("Wallet not initialized - no private key provided");try{let t=Buffer.from(e,"hex");if(t.length===70){let r=new Uint8Array(t.subarray(1,33));return this.keypair=A.fromSecretKey(r),this.keypair}else{if(t.length===32)return this.keypair=A.fromSecretKey(new Uint8Array(t)),this.keypair;throw new Error(`Unsupported private key length: ${t.length} bytes`)}}catch(t){throw t}}};y.PROVIDER_NAME="privateKey";var C=y;var B=class{constructor(e,t){this.config=e;this.chain=t;this.cachedAddress=null;this.cachedPublicKey=null;this.client=z(e,t),this.walletProvider=this.createProvider(),this.isInitializedPromise=new Promise(r=>{this.isInitializedResolve=r}),this.initializeCache()}async waitUntilInitialized(){await this.isInitializedPromise}async signTransaction(e){if(await this.waitUntilInitialized(),!e||typeof e!="object")throw new Error("Invalid transaction object");if(!this.walletProvider)throw new Error("No wallet provider available");if(this.walletProvider instanceof f)throw new Error(`Wallet (${this.chain.name}) is read-only`);return(this.walletProvider instanceof C||this.walletProvider instanceof w)&&e&&typeof e=="object"&&"sign"in e&&typeof e.sign=="function"?e:await this.walletProvider.signTransaction(e)}async signMessage(e){if(await this.waitUntilInitialized(),!this.walletProvider)throw new Error("No wallet provider available");if(this.walletProvider instanceof f)throw new Error(`Wallet (${this.chain.name}) is read-only`);return await this.walletProvider.signMessage(e)}async signTransactions(e){return await this.waitUntilInitialized(),e}async sendTransaction(e){if(await this.waitUntilInitialized(),!e||typeof e!="object")throw new Error("Invalid transaction object");if(e.transactionHash)return e.transactionHash;if(e&&typeof e=="object"&&"bytes"in e&&"signature"in e)return(await this.client.executeTransactionBlock({transactionBlock:e.bytes,signature:Array.isArray(e.signature)?e.signature:[e.signature],options:{showEffects:!0,showEvents:!0}})).digest;if(!this.walletProvider)throw new Error("No wallet provider available");if(this.walletProvider instanceof C||this.walletProvider instanceof w){let t=this.walletProvider.getKeypairInstance();if(e&&typeof e=="object"&&"sign"in e&&typeof e.sign=="function")return(await this.client.signAndExecuteTransaction({transaction:e,signer:t,options:{showEffects:!0,showEvents:!0}})).digest;throw new Error(`Transaction must be a Transaction object or have bytes and signature. Got: ${typeof e}, has sign: ${e&&typeof e=="object"&&"sign"in e}, has bytes: ${e&&typeof e=="object"&&"bytes"in e}, has signature: ${e&&typeof e=="object"&&"signature"in e}`)}throw new Error("Remote wallet provider must return signed payload (bytes + signature) or transactionHash for Sui transactions")}async sendTransactions(e){return await this.waitUntilInitialized(),Promise.all(e.map(async t=>this.sendTransaction(t)))}async importFromMnemonic(e){return await this.waitUntilInitialized(),await this.createProviderForOperation("mnemonic").importFromMnemonic(e)}async importFromPrivateKey(e){return await this.waitUntilInitialized(),await this.createProviderForOperation("privateKey").importFromPrivateKey(e)}async export(e){return await this.waitUntilInitialized(),await this.createProviderForOperation(e).export()}async generate(e){return await this.waitUntilInitialized(),await this.createProviderForOperation(e).generate()}async delete(e,t){await this.waitUntilInitialized(),await this.createProviderForOperation(e).delete(t)}getAddress(){return this.cachedAddress}getPublicKey(){return this.cachedPublicKey}createProvider(){let e=this.config.user?.wallets?.[this.chain.name];return e?typeof e=="string"?new f(this.config,this.chain):e.provider?this.createProviderForOperation(e.provider):new f(this.config,this.chain):null}async initializeCache(){let e=await je(this.walletProvider);this.cachedAddress=e.address,this.cachedPublicKey=e.publicKey,this.isInitializedResolve()}createProviderForOperation(e){let r=this.config.walletProviders?.[this.chain.name]?.[e];if(r){let i=r(this.config,this.chain);if(!i)throw new Error(`Custom wallet provider factory returned null for ${e}`);return i}if(e==="privateKey")return new C(this.config,this.chain);if(e==="mnemonic")return new w(this.config,this.chain);throw new Error(`Unsupported wallet provider for ${this.chain.name}: ${e}`)}};var N={chain:S.Sui,identifier:"0x2::sui::SUI",name:"SUI",symbol:"SUI",decimals:9,logoUrl:"https://assets.coingecko.com/coins/images/26375/standard/sui-ocean-square.png?1727791290"};function Re(l,e){return(t,r)=>{if(!r)throw new Error(`${l} adapter requires a fallback adapter`);let i=e[t.env];if(!i)throw new Error(`SuiAdapter: chain info not found for chain ${l}`);return{chainInfo:i,builder:()=>new T(t,i),executor:new x(t,i),output:new v(t,i),serializer:new h,registry:r.registry,explorer:new U(t,i),abiBuilder:()=>new W(t,i),brandBuilder:()=>new E(t,i),dataLoader:new I(t,i),wallet:new B(t,i)}}}var mi=Re(S.Sui,{mainnet:{name:S.Sui,displayName:"Sui",chainId:"1",blockTime:3e3,addressHrp:"sui",defaultApiUrl:"https://fullnode.mainnet.sui.io",logoUrl:"https://raw.githubusercontent.com/JoAiHQ/assets/refs/heads/main/chains/logos/sui.svg",nativeToken:N},testnet:{name:S.Sui,displayName:"Sui Testnet",chainId:"testnet",blockTime:3e3,addressHrp:"sui",defaultApiUrl:"https://fullnode.testnet.sui.io",logoUrl:"https://raw.githubusercontent.com/JoAiHQ/assets/refs/heads/main/chains/logos/sui.svg",nativeToken:N},devnet:{name:S.Sui,displayName:"Sui Devnet",chainId:"devnet",blockTime:3e3,addressHrp:"sui",defaultApiUrl:"https://fullnode.devnet.sui.io",logoUrl:"https://raw.githubusercontent.com/JoAiHQ/assets/refs/heads/main/chains/logos/sui.svg",nativeToken:N}});var L=class{constructor(e,t){this.abi=new W(e,t)}async loadModuleAbi(e,t){return this.abi.getModuleAbi(e,t)}async loadFunctionAbi(e,t,r){return this.abi.getFunctionAbi(e,t,r)}};export{g as ExplorerUrls,pe as KnownTokens,N as NativeTokenSui,mi as SuiAdapter,X as SuiExplorers,O as SuiExplorersConfig,W as WarpSuiAbiBuilder,E as WarpSuiBrandBuilder,T as WarpSuiBuilder,Me as WarpSuiConstants,L as WarpSuiContractLoader,I as WarpSuiDataLoader,x as WarpSuiExecutor,U as WarpSuiExplorer,v as WarpSuiOutput,h as WarpSuiSerializer,B as WarpSuiWallet,$ as findKnownTokenById,z as getConfiguredSuiClient};
|
|
1
|
+
var Me={Sui:{Identifier:"SUI",DisplayName:"Sui",Decimals:9}},X=(a=>(a.SuiVision="suivision",a.SuiVisionTestnet="suivision_testnet",a.SuiVisionDevnet="suivision_devnet",a.SuiScan="suiscan",a.SuiScanTestnet="suiscan_testnet",a.SuiScanDevnet="suiscan_devnet",a))(X||{}),O={sui:{mainnet:["suivision","suiscan"],testnet:["suivision_testnet","suiscan_testnet"],devnet:["suivision_devnet","suiscan_devnet"]}},g={suivision:"https://suivision.xyz",suivision_testnet:"https://testnet.suivision.xyz",suivision_devnet:"https://devnet.suivision.xyz",suiscan:"https://suiscan.xyz",suiscan_testnet:"https://testnet.suiscan.xyz",suiscan_devnet:"https://devnet.suiscan.xyz"};import{SuiClient as Y}from"@mysten/sui/client";import{getProviderConfig as Z}from"@joai/warps";var z=(l,e)=>{let t=Z(l,e.name,l.env,e.defaultApiUrl);return new Y({url:t.url})};import{WarpChainName as S}from"@joai/warps";import{SuiClient as ee}from"@mysten/sui/client";import{getProviderConfig as te}from"@joai/warps";var W=class{constructor(e,t){this.config=e;this.chain=t;let r=te(this.config,this.chain.name,this.config.env,this.chain.defaultApiUrl);this.client=new ee({url:r.url})}async createInscriptionTransaction(e){throw new Error("WarpSuiAbiBuilder: createInscriptionTransaction not implemented")}async createFromRaw(e){return JSON.parse(e)}async createFromTransaction(e){return this.createFromRaw(e.data||"{}")}async createFromTransactionHash(e,t){try{let r=await this.client.getTransactionBlock({digest:e});return r?this.createFromTransaction(r):null}catch{return null}}async getModuleAbi(e,t){return this.client.getNormalizedMoveModule({package:e,module:t})}async getFunctionAbi(e,t,r){return this.client.getNormalizedMoveFunction({package:e,module:t,function:r})}};import{SuiClient as re}from"@mysten/sui/client";import{Transaction as ie}from"@mysten/sui/transactions";import{getProviderConfig as ne}from"@joai/warps";var P=class{constructor(e,t){this.config=e;this.chain=t;let r=ne(this.config,this.chain.name,this.config.env,this.chain.defaultApiUrl);this.client=new re({url:r.url})}createInscriptionTransaction(e){return new ie}async createFromRaw(e){return JSON.parse(e)}async createFromTransaction(e,t){return this.createFromRaw(e.data||"{}")}async createFromTransactionHash(e,t){try{let r=await this.client.getTransactionBlock({digest:e});return r?this.createFromTransaction(r,!1):null}catch{return null}}};import{SuiClient as ae}from"@mysten/sui/client";import{getProviderConfig as se,WarpBuilder as oe,WarpCache as ce}from"@joai/warps";var T=class extends oe{constructor(t,r){super(t);this.config=t;this.chain=r;this.cache=new ce(t.env,t.cache);let i=se(this.config,this.chain.name,this.config.env,this.chain.defaultApiUrl);this.client=new ae({url:i.url})}async createInscriptionTransaction(t){throw new Error("WarpSuiBuilder: on-chain inscription is not supported for Sui")}async createFromTransaction(t){return this.createFromRaw(t)}async createFromTransactionHash(t,r){return null}};import{SuiClient as ue}from"@mysten/sui/client";import{CacheTtl as de,getProviderConfig as he,WarpCache as ge,WarpCacheKey as me}from"@joai/warps";import{WarpChainName as le}from"@joai/warps";var d=le.Sui,pe=[{chain:d,identifier:"0x2::sui::SUI",name:"Sui",symbol:"SUI",decimals:9,logoUrl:"https://assets.coingecko.com/coins/images/26375/small/sui-logo.png"},{chain:d,identifier:"0xa198f3be41cda8c07c3bf1c4e0bb88b8e9827b7c063f36b1e6c3d6da1c4e8753::usdc::USDC",name:"USD Coin",symbol:"USDC",decimals:6,logoUrl:"https://assets.coingecko.com/coins/images/6319/small/USD_Coin_icon.png"},{chain:d,identifier:"0xc060006111016b8a020ad5b33834984a437aaa7d3c74c18e09a95d48ace0cdd97::usdt::USDT",name:"Tether USD",symbol:"USDT",decimals:6,logoUrl:"https://assets.coingecko.com/coins/images/325/small/Tether.png"},{chain:d,identifier:"0xaf8cd5edc19c4512f4259f0bee101a7c94d8a5c0e7c90c7a7c8c8c8c8c8c8c8c8::wbtc::WBTC",name:"Wrapped Bitcoin",symbol:"WBTC",decimals:8,logoUrl:"https://assets.coingecko.com/coins/images/7598/small/wrapped_bitcoin_wbtc.png"},{chain:d,identifier:"0xb8a6a9b7c7a6f4a3e2d1c0b9a8f7e6d5c4b3a2b1c0d9e8f7a6b5c4d3e2f1a0b::weth::WETH",name:"Wrapped Ether",symbol:"WETH",decimals:8,logoUrl:"https://assets.coingecko.com/coins/images/2518/small/weth.png"},{chain:d,identifier:"0x5d4b302506645c37ff133b98c4b50a5ae14841659738d6d733d59d0d217a15e0e9::ocean::OCEAN",name:"Ocean Protocol",symbol:"OCEAN",decimals:9,logoUrl:"https://assets.coingecko.com/coins/images/3687/small/ocean-protocol-logo.png"},{chain:d,identifier:"0x5d1f47ea69bb0de31c313d7acf89b890dbb8991ea8e03c6c35569693fd50fb8b7::deep::DEEP",name:"DeepBook",symbol:"DEEP",decimals:6,logoUrl:"https://assets.coingecko.com/coins/images/30169/small/deepbook.png"},{chain:d,identifier:"0xbde4ba4c2e274a60ce15c1cfff9e5c42e41654ac8b6d906a57efa4bd3c29f47ba3::hasui::HASUI",name:"Haedal Staked SUI",symbol:"HASUI",decimals:9,logoUrl:"https://assets.coingecko.com/coins/images/30027/small/haSUI.png"},{chain:d,identifier:"0xdba34672e30cb065b1f93e3ab55318768fd6fef66c15942c9f7cb846e2f900e935::usdc::USDC",name:"USD Coin (Wormhole)",symbol:"USDC",decimals:6,logoUrl:"https://assets.coingecko.com/coins/images/6319/small/USD_Coin_icon.png"}],$=l=>pe.find(e=>e.identifier===l)||null;var I=class{constructor(e,t){this.config=e;this.chain=t;let r=he(this.config,this.chain.name,this.config.env,this.chain.defaultApiUrl);this.client=new ue({url:r.url}),this.cache=new ge(e.env,e.cache)}async getAccount(e){let t=await this.client.getBalance({owner:e,coinType:"0x2::sui::SUI"});return{chain:this.chain.name,address:e,balance:BigInt(t.totalBalance)}}async getAccountAssets(e){let t=await this.client.getAllBalances({owner:e});console.log("WarpSuiDataLoader.getAccountAssets",t);let r=t.find(a=>a.coinType==="0x2::sui::SUI"),i=t.filter(a=>a.coinType!=="0x2::sui::SUI"&&BigInt(a.totalBalance)>0n),n=[];if(r&&BigInt(r.totalBalance)>0n&&n.push({...this.chain.nativeToken,amount:BigInt(r.totalBalance)}),i.length>0){let a=await Promise.all(i.map(s=>this.getAsset(s.coinType)));n.push(...a.filter(s=>s!==null).map(s=>({...s,amount:BigInt(i.find(o=>o.coinType===s.identifier)?.totalBalance||0)})))}return n}async getAsset(e){let t=me.Asset(this.config.env,this.chain.name,e),r=await this.cache.get(t);if(r)return r;let i=$(e);if(i)return{chain:this.chain.name,identifier:e,name:i.name,symbol:i.symbol,amount:0n,decimals:i.decimals,logoUrl:i.logoUrl};try{let n=await this.client.getCoinMetadata({coinType:e}),a={chain:this.chain.name,identifier:e,name:n?.name||e.split("::").pop()||e,symbol:n?.symbol||e.split("::").pop()||e,amount:0n,decimals:n?.decimals||9,logoUrl:n?.iconUrl||""};return await this.cache.set(t,a,de.OneHour),a}catch{return null}}async getAccountNfts(e,t){try{let r=t?.size||25,i=t?.page||0,n;for(let o=0;o<i;o++){let c=await this.client.getOwnedObjects({owner:e,options:{showContent:!1,showDisplay:!1},limit:r,cursor:n});if(n=c.nextCursor,!c.hasNextPage)return[]}let a=await this.client.getOwnedObjects({owner:e,options:{showContent:!0,showDisplay:!0},limit:r,cursor:n}),s=[];for(let o of a.data){let c=o.data?.content,p=o.data?.display?.data,u=c?.type||"";if(u.startsWith("0x2::coin::Coin"))continue;let E=o.data?.objectId||"",J=p?.name||u.split("::").pop()||E.slice(0,8),q=u.includes("::")?u.split("::").slice(0,2).join("::"):void 0,D=p?.image_url;s.push({chain:this.chain.name,identifier:E,name:J,symbol:"",amount:1n,decimals:0,type:"nft",nft:{collection:q,mediaUrl:D,thumbnailUrl:D}})}return s}catch{return[]}}async getAction(e,t=!1){return null}async getAccountActions(e,t){return[]}};import{SuiClient as Ae}from"@mysten/sui/client";import{Transaction as M}from"@mysten/sui/transactions";import{applyOutputToMessages as Se,extractResolvedInputValues as Ee,getNextInfo as Pe,getProviderConfig as Te,getWarpActionByIndex as k,getWarpWalletAddressFromConfig as Ie}from"@joai/warps";import{SuiClient as We}from"@mysten/sui/client";import{applyOutputToMessages as ve,evaluateOutputCommon as F,getNextInfo as we,getProviderConfig as Ce,getWarpWalletAddressFromConfig as be,parseOutputOutIndex as R,WarpConstants as j}from"@joai/warps";import{Transaction as fe}from"@mysten/sui/transactions";import{WarpSerializer as ye}from"@joai/warps";var h=class{constructor(){this.coreSerializer=new ye}typedToString(e){if(e==null)return"option:null";if(typeof e=="string")return`string:${e}`;if(typeof e=="boolean")return`bool:${e}`;if(typeof e=="number")return`uint64:${e.toString()}`;if(typeof e=="bigint")return`uint64:${e.toString()}`;if(e&&typeof e=="object"&&e.address)return`address:${e.address}`;if(Array.isArray(e)){if(e.length===0)return"vector:u8:";let t=this.typeToString(typeof e[0]),r=e.map(i=>this.typedToString(i).split(":")[1]);return`vector:${t}:${r.join(",")}`}if(e&&typeof e=="object"&&e.type&&e.value&&e.type==="option")return e.value===null||e.value===void 0?"option:null":`option:${this.typedToString(e.value)}`;throw new Error(`WarpSuiSerializer (typedToString): Unsupported input type: ${typeof e}`)}typedToNative(e){let t=this.typedToString(e);return this.coreSerializer.stringToNative(t)}nativeToTyped(e,t){let r=this.coreSerializer.nativeToString(e,t);return this.stringToTyped(r)}stringToTyped(e,t){let r=t||new fe,[i,n]=e.split(/:(.*)/,2);if(i==="object")return r.object(n);if(i==="string")return r.pure.string(n);if(i==="bool")return r.pure.bool(n==="true");if(i==="u8")return r.pure.u8(Number(n));if(i==="u16")return r.pure.u16(Number(n));if(i==="u32")return r.pure.u32(Number(n));if(i==="u64"||i==="uint64")return r.pure.u64(BigInt(n));if(i==="u128")return r.pure.u128(BigInt(n));if(i==="u256")return r.pure.u256(BigInt(n));if(i==="address")return r.pure.address(n);throw new Error(`WarpSuiSerializer (stringToTyped): Unsupported type: ${i}`)}typeToString(e){if(e==="string")return"string";if(e==="bool")return"bool";if(e==="u8")return"u8";if(e==="u16")return"u16";if(e==="u32")return"u32";if(e==="u64"||e==="bigint"||e==="number")return"u64";if(e==="u128")return"u128";if(e==="u256")return"u256";if(e==="address")return"address";if(e==="vector")return"vector";if(e==="option")return"option";throw new Error(`WarpSuiSerializer (typeToString): Unsupported input type: ${e}`)}nativeToType(e){throw new Error("Not implemented")}};var v=class{constructor(e,t){this.config=e;this.chain=t;this.serializer=new h;let r=Ce(this.config,this.chain.name,this.config.env,this.chain.defaultApiUrl);this.client=new We({url:r.url})}async getActionExecution(e,t,r,i){let n=i??[],a=await this.extractContractOutput(e,t,r,[]),s=we(this.config,[],e,t,a.output),o=Object.fromEntries(n.map(p=>[p.input.as||p.input.name,p.value])),c=ve(e,{...o,...a.output},this.config);return{status:r.effects?.status?.status==="success"?"success":"error",warp:e,action:t,user:be(this.config,this.chain.name),txHash:r.digest,tx:r,next:s,values:a.values,output:a.output,messages:c,destination:null,resolvedInputs:[]}}async extractContractOutput(e,t,r,i){let n=[],a=[],s={};if(!e.output)return{values:{string:n,native:a,mapped:{}},output:s};for(let[o,c]of Object.entries(e.output)){if(c.startsWith(j.Transform.Prefix))continue;if(c.startsWith("input.")){s[o]=c;continue}let p=R(c);if(p!==null&&p!==t){s[o]=null;continue}if(c.startsWith("out.")){let u=r.returnValues?r.returnValues[o]:null;s[o]=u,n.push(String(u)),a.push(u)}else s[o]=c}return{values:{string:n,native:a,mapped:{}},output:await F(e,s,a,t,i,this.serializer.coreSerializer,this.config)}}async extractQueryOutput(e,t,r,i){let n=t.map(c=>String(c)),a=t,s={string:n,native:a,mapped:{}},o={};if(!e.output)return{values:s,output:o};for(let[c,p]of Object.entries(e.output)){if(p.startsWith(j.Transform.Prefix))continue;let u=R(p);if(u!==null&&u!==r){o[c]=null;continue}if(p.startsWith("out.")||p==="out")if(Array.isArray(t)&&t.length>0&&typeof t[0]=="object"&&t[0]!==null){let E=p.replace(/^out\./,"");o[c]=t[0][E]}else o[c]=t[0];else o[c]=p}return{values:s,output:await F(e,o,a,r,i,this.serializer.coreSerializer,this.config)}}};var x=class{constructor(e,t){this.config=e;this.chain=t;this.serializer=new h,this.output=new v(this.config,this.chain);let r=Te(this.config,this.chain.name,this.config.env,this.chain.defaultApiUrl);this.client=new Ae({url:r.url}),this.userWallet=Ie(this.config,this.chain.name)}async createTransaction(e){let t=k(e.warp,e.action);if(t.type==="transfer")return this.createTransferTransaction(e);if(t.type==="contract")return this.createContractCallTransaction(e);throw t.type==="query"?new Error("WarpSuiExecutor: Invalid action type for createTransaction; Use executeQuery instead"):t.type==="collect"?new Error("WarpSuiExecutor: Invalid action type for createTransaction; Use executeCollect instead"):new Error(`WarpSuiExecutor: Invalid action type (${t.type})`)}async createTransferTransaction(e){if(!this.userWallet)throw new Error("WarpSuiExecutor: createTransfer - user address not set");if(!e.destination)throw new Error("WarpSuiExecutor: Invalid destination address");if(e.value<0)throw new Error(`WarpSuiExecutor: Transfer value cannot be negative: ${e.value}`);let t=new M,r=[];if(e.value>0){let i=await this.handleCoinTransfer(t,"0x2::sui::SUI",e.value);r.push(i)}for(let i of e.transfers){let n=await this.handleCoinTransfer(t,i.identifier,i.amount);r.push(n)}return r.length>0&&t.transferObjects(r,t.pure.address(e.destination)),t}async createContractCallTransaction(e){if(!this.userWallet)throw new Error("WarpSuiExecutor: createContractCall - user address not set");if(!e.destination)throw new Error("WarpSuiExecutor: Invalid contract address");if(e.value<0)throw new Error(`WarpSuiExecutor: Contract call value cannot be negative: ${e.value}`);let t=k(e.warp,e.action);if(!t.func)throw new Error("WarpSuiExecutor: createContractCall - function not set");let r=new M;r.setSender(this.userWallet);let i=[];e.value>0&&i.push(await this.handleCoinTransfer(r,"0x2::sui::SUI",e.value));for(let o of e.transfers)i.push(await this.handleCoinTransfer(r,o.identifier,o.amount));let{target:n,typeArguments:a}=this.parseMoveCallTarget(t),s=e.args.map(o=>this.serializer.stringToTyped(o,r));return n==="0x2::transfer::public_transfer"?i.push(...await this.buildPublicTransferArgs(r,e,s)):i.push(...s),r.moveCall({target:n,arguments:i,typeArguments:a}),r.setGasBudget(1e8),r}async executeQuery(e){if(!e.destination)throw new Error("WarpSuiExecutor: executeQuery - destination not set");let t=k(e.warp,e.action);if(t.type!=="query")throw new Error(`WarpSuiExecutor: Invalid action type for executeQuery: ${t.type}`);let r=await this.client.getObject({id:e.destination,options:{showContent:!0}}),i=[r],{values:n,output:a}=await this.output.extractQueryOutput(e.warp,i,e.action,e.resolvedInputs),s=Pe(this.config,[],e.warp,e.action,a),c=e.resolvedInputs.find(u=>u.input.position==="receiver"||u.input.position==="destination")?.value||e.destination,p=Ee(e.resolvedInputs);return{status:"success",warp:e.warp,action:e.action,user:this.userWallet,txHash:null,tx:null,next:s,values:n,output:{...a,_DATA:r},resolvedInputs:p,messages:Se(e.warp,a,this.config),destination:c}}async signMessage(e,t){throw new Error("Not implemented")}parseMoveCallTarget(e){if(!e.func)throw new Error("WarpSuiExecutor: Function not set");let t=`${e.address}::${e.func}`,r=e.typeArguments;if(!r&&e.func.includes("<")&&e.func.includes(">")){let i=e.func.match(/<([^>]+)>/);i&&(r=[i[1]],t=`${e.address}::${e.func.replace(/<[^>]+>/,"")}`)}return{target:t,typeArguments:r}}async buildPublicTransferArgs(e,t,r){let i=t.resolvedInputs.find(s=>String(s.input.position)==="arg:0")?.value||t.args[0],n=t.resolvedInputs.find(s=>String(s.input.position)==="arg:1")?.value||t.resolvedInputs.find(s=>s.input.type==="address"&&String(s.input.position)!=="arg:0")?.value||t.args[1],a=this.extractObjectId(i);if(!a)return r;try{if(!(await this.client.getObject({id:a,options:{showType:!0,showContent:!0}})).data?.type?.startsWith("0x2::coin::Coin<"))return r;let o=n?this.serializer.stringToTyped(n.includes(":")?n:`address:${n}`,e):r[1]||e.pure.address(this.userWallet);return[e.object(a),o]}catch{return r}}extractObjectId(e){if(!e||typeof e!="string")return null;let t=e.startsWith("object:")?e.substring(7):e;return t.startsWith("0x")?t:null}async handleCoinTransfer(e,t,r){if(t==="0x2::sui::SUI")try{return e.splitCoins(e.gas,[r.toString()])[0]}catch{}return this.createCoinTransferFromObjects(e,t,r)}async createCoinTransferFromObjects(e,t,r){let i=await this.getCoinObjectsForTransfer(t,r);if(i.length===0)throw new Error(`No coin objects found for ${t}`);let n=e.object(i[0].coinObjectId);return i.length>1&&e.mergeCoins(n,i.slice(1).map(a=>e.object(a.coinObjectId))),e.splitCoins(n,[r.toString()])[0]}async getCoinObjectsForTransfer(e,t){if(!this.userWallet)throw new Error("User wallet not set");let{data:r}=await this.client.getCoins({owner:this.userWallet,coinType:e}),i=r.map(s=>({coinObjectId:s.coinObjectId,balance:s.balance})).sort((s,o)=>BigInt(o.balance)>BigInt(s.balance)?1:-1),n=BigInt(0),a=[];for(let s of i)if(a.push(s),n+=BigInt(s.balance),n>=t)return a;throw new Error(`Insufficient ${e} balance. Required: ${t}, Available: ${n}`)}};var U=class{constructor(e,t){this.config=e;this.chain=t}getExplorers(){let e=O[this.chain.name];if(!e)return["suivision"];let t=e[this.config.env];return t||["suivision"]}getPrimaryExplorer(){return this.getExplorers()[0]}getExplorerUrlByName(e){let t=this.config.preferences?.explorers?.[this.chain.name];if(t&&!e){let n=g[t];if(n)return n}if(e){let n=g[e];if(n)return n}let r=this.getPrimaryExplorer();return g[r]||g[r]}getAccountUrl(e,t){return`${this.getExplorerUrlByName(t)}/account/${e}`}getTransactionUrl(e,t){return`${this.getExplorerUrlByName(t)}/txblock/${e}`}getBlockUrl(e,t){return`${this.getExplorerUrlByName(t)}/block/${e}`}getAssetUrl(e,t){return`${this.getExplorerUrlByName(t)}/coin/${e}`}getContractUrl(e,t){return`${this.getExplorerUrlByName(t)}/object/${e}`}getAllExplorers(){return this.getExplorers()}getExplorerByName(e){return this.getExplorers().find(r=>r.toLowerCase()===e.toLowerCase())}getAccountUrls(e){let t=this.getAllExplorers(),r={};return t.forEach(i=>{let n=g[i];n&&(r[i]=`${n}/account/${e}`)}),r}getTransactionUrls(e){let t=this.getAllExplorers(),r={};return t.forEach(i=>{let n=g[i];n&&(r[i]=`${n}/txblock/${e}`)}),r}};import{initializeWalletCache as Re}from"@joai/warps";import{Ed25519Keypair as K}from"@mysten/sui/keypairs/ed25519";import*as _ from"@scure/bip39";import{wordlist as xe}from"@scure/bip39/wordlists/english.js";import{getWarpWalletAddressFromConfig as Ue,getWarpWalletMnemonicFromConfig as V,getWarpWalletPrivateKeyFromConfig as Ke,normalizeAndValidateMnemonic as Be,normalizeMnemonic as ke,removeWarpWalletFromConfig as Ne,setWarpWalletInConfig as H,validateMnemonicLength as De}from"@joai/warps";var m=class m{constructor(e,t){this.config=e;this.chain=t;this.keypair=null}async getAddress(){return Ue(this.config,this.chain.name)}async getPublicKey(){try{let t=this.getKeypair().getPublicKey();return Buffer.from(t.toRawBytes()).toString("hex")}catch{return null}}async signTransaction(e){if(e&&typeof e=="object"&&"sign"in e&&typeof e.sign=="function")return e;let t=this.getKeypair(),r=new TextEncoder().encode(JSON.stringify(e)),i=await t.signPersonalMessage(r);return{...e,signature:i.signature}}async signMessage(e){let t=this.getKeypair(),r=new TextEncoder().encode(e);return(await t.signPersonalMessage(r)).signature}getKeypairInstance(){return this.getKeypair()}async importFromMnemonic(e){let t=Be(e),i=K.deriveKeypair(t).getPublicKey().toSuiAddress(),n={provider:m.PROVIDER_NAME,address:i,privateKey:null,mnemonic:t};return H(this.config,this.chain.name,n),n}async importFromPrivateKey(e){let t=Buffer.from(e,"hex"),r;if(t.length===70)r=new Uint8Array(t.subarray(1,33));else if(t.length===32)r=new Uint8Array(t);else throw new Error(`Unsupported private key length: ${t.length} bytes`);let n=K.fromSecretKey(r).getPublicKey().toSuiAddress(),a={provider:m.PROVIDER_NAME,address:n,privateKey:e,mnemonic:null};return H(this.config,this.chain.name,a),a}async export(){let e=this.getKeypair(),t=V(this.config,this.chain.name),r=Ke(this.config,this.chain.name);return{provider:m.PROVIDER_NAME,address:e.getPublicKey().toSuiAddress(),privateKey:r||null,mnemonic:t||null}}async generate(){let e=_.generateMnemonic(xe,256),t=ke(e);De(t);let i=K.deriveKeypair(t).getPublicKey().toSuiAddress();return{provider:m.PROVIDER_NAME,address:i,privateKey:null,mnemonic:t}}async delete(e){Ne(this.config,this.chain.name)}getKeypair(){if(this.keypair)return this.keypair;let e=V(this.config,this.chain.name);if(!e)throw new Error("No mnemonic provided");return this.keypair=K.deriveKeypair(e.trim()),this.keypair}};m.PROVIDER_NAME="mnemonic";var w=m;import{getWarpWalletAddressFromConfig as b,removeWarpWalletFromConfig as Oe}from"@joai/warps";var f=class{constructor(e,t){this.config=e;this.chain=t}async getAddress(){return b(this.config,this.chain.name)}async getPublicKey(){return null}async signTransaction(e){let t=await this.getAddress();throw new Error(`Wallet can not be used for signing: ${t}`)}async signMessage(e){let t=await this.getAddress();throw new Error(`Wallet can not be used for signing: ${t}`)}async importFromMnemonic(e){let t=b(this.config,this.chain.name);throw new Error(`Wallet can not be used for signing: ${t}`)}async importFromPrivateKey(e){let t=b(this.config,this.chain.name);throw new Error(`Wallet can not be used for signing: ${t}`)}async export(){let e=b(this.config,this.chain.name);throw new Error(`Wallet can not be used for signing: ${e}`)}async generate(){let e=b(this.config,this.chain.name);throw new Error(`Wallet can not be used for signing: ${e}`)}async delete(e){Oe(this.config,this.chain.name)}};import{Ed25519Keypair as A}from"@mysten/sui/keypairs/ed25519";import{getWarpWalletAddressFromConfig as ze,getWarpWalletMnemonicFromConfig as $e,getWarpWalletPrivateKeyFromConfig as G,removeWarpWalletFromConfig as Fe,setWarpWalletInConfig as Q}from"@joai/warps";var y=class y{constructor(e,t){this.config=e;this.chain=t;this.keypair=null}async getAddress(){return ze(this.config,this.chain.name)}async getPublicKey(){try{let t=this.getKeypair().getPublicKey();return Buffer.from(t.toRawBytes()).toString("hex")}catch{return null}}async signTransaction(e){if(e&&typeof e=="object"&&"sign"in e&&typeof e.sign=="function")return e;let t=this.getKeypair(),r=new TextEncoder().encode(JSON.stringify(e)),i=await t.signPersonalMessage(r);return{...e,signature:i.signature}}async signMessage(e){let t=this.getKeypair(),r=new TextEncoder().encode(e);return(await t.signPersonalMessage(r)).signature}getKeypairInstance(){return this.getKeypair()}async importFromMnemonic(e){let t=A.deriveKeypair(e.trim()),r=t.getPublicKey().toSuiAddress(),i=Buffer.from(t.getSecretKey()).toString("hex"),n={provider:y.PROVIDER_NAME,address:r,privateKey:i,mnemonic:e};return Q(this.config,this.chain.name,n),n}async importFromPrivateKey(e){let t=Buffer.from(e,"hex"),r;if(t.length===70)r=new Uint8Array(t.subarray(1,33));else if(t.length===32)r=new Uint8Array(t);else throw new Error(`Unsupported private key length: ${t.length} bytes`);let n=A.fromSecretKey(r).getPublicKey().toSuiAddress(),a={provider:y.PROVIDER_NAME,address:n,privateKey:e,mnemonic:null};return Q(this.config,this.chain.name,a),a}async export(){let e=this.getKeypair(),t=G(this.config,this.chain.name),r=$e(this.config,this.chain.name);return{provider:y.PROVIDER_NAME,address:e.getPublicKey().toSuiAddress(),privateKey:t||null,mnemonic:r||null}}async generate(){let e=A.generate(),t=e.getPublicKey().toSuiAddress(),r=Buffer.from(e.getSecretKey()).toString("hex");return{provider:y.PROVIDER_NAME,address:t,privateKey:r,mnemonic:null}}async delete(e){Fe(this.config,this.chain.name)}getKeypair(){if(this.keypair)return this.keypair;let e=G(this.config,this.chain.name);if(!e)throw new Error("Wallet not initialized - no private key provided");try{let t=Buffer.from(e,"hex");if(t.length===70){let r=new Uint8Array(t.subarray(1,33));return this.keypair=A.fromSecretKey(r),this.keypair}else{if(t.length===32)return this.keypair=A.fromSecretKey(new Uint8Array(t)),this.keypair;throw new Error(`Unsupported private key length: ${t.length} bytes`)}}catch(t){throw t}}};y.PROVIDER_NAME="privateKey";var C=y;var B=class{constructor(e,t){this.config=e;this.chain=t;this.cachedAddress=null;this.cachedPublicKey=null;this.client=z(e,t),this.walletProvider=this.createProvider(),this.isInitializedPromise=new Promise(r=>{this.isInitializedResolve=r}),this.initializeCache()}async waitUntilInitialized(){await this.isInitializedPromise}async signTransaction(e){if(await this.waitUntilInitialized(),!e||typeof e!="object")throw new Error("Invalid transaction object");if(!this.walletProvider)throw new Error("No wallet provider available");if(this.walletProvider instanceof f)throw new Error(`Wallet (${this.chain.name}) is read-only`);return(this.walletProvider instanceof C||this.walletProvider instanceof w)&&e&&typeof e=="object"&&"sign"in e&&typeof e.sign=="function"?e:await this.walletProvider.signTransaction(e)}async signMessage(e){if(await this.waitUntilInitialized(),!this.walletProvider)throw new Error("No wallet provider available");if(this.walletProvider instanceof f)throw new Error(`Wallet (${this.chain.name}) is read-only`);return await this.walletProvider.signMessage(e)}async signTransactions(e){return await this.waitUntilInitialized(),e}async sendTransaction(e){if(await this.waitUntilInitialized(),!e||typeof e!="object")throw new Error("Invalid transaction object");if(e.transactionHash)return e.transactionHash;if(e&&typeof e=="object"&&"bytes"in e&&"signature"in e)return(await this.client.executeTransactionBlock({transactionBlock:e.bytes,signature:Array.isArray(e.signature)?e.signature:[e.signature],options:{showEffects:!0,showEvents:!0}})).digest;if(!this.walletProvider)throw new Error("No wallet provider available");if(this.walletProvider instanceof C||this.walletProvider instanceof w){let t=this.walletProvider.getKeypairInstance();if(e&&typeof e=="object"&&"sign"in e&&typeof e.sign=="function")return(await this.client.signAndExecuteTransaction({transaction:e,signer:t,options:{showEffects:!0,showEvents:!0}})).digest;throw new Error(`Transaction must be a Transaction object or have bytes and signature. Got: ${typeof e}, has sign: ${e&&typeof e=="object"&&"sign"in e}, has bytes: ${e&&typeof e=="object"&&"bytes"in e}, has signature: ${e&&typeof e=="object"&&"signature"in e}`)}throw new Error("Remote wallet provider must return signed payload (bytes + signature) or transactionHash for Sui transactions")}async sendTransactions(e){return await this.waitUntilInitialized(),Promise.all(e.map(async t=>this.sendTransaction(t)))}async importFromMnemonic(e){return await this.waitUntilInitialized(),await this.createProviderForOperation("mnemonic").importFromMnemonic(e)}async importFromPrivateKey(e){return await this.waitUntilInitialized(),await this.createProviderForOperation("privateKey").importFromPrivateKey(e)}async export(e){return await this.waitUntilInitialized(),await this.createProviderForOperation(e).export()}async generate(e){return await this.waitUntilInitialized(),await this.createProviderForOperation(e).generate()}async delete(e,t){await this.waitUntilInitialized(),await this.createProviderForOperation(e).delete(t)}getAddress(){return this.cachedAddress}getPublicKey(){return this.cachedPublicKey}createProvider(){let e=this.config.user?.wallets?.[this.chain.name];return e?typeof e=="string"?new f(this.config,this.chain):e.provider?this.createProviderForOperation(e.provider):new f(this.config,this.chain):null}async initializeCache(){let e=await Re(this.walletProvider);this.cachedAddress=e.address,this.cachedPublicKey=e.publicKey,this.isInitializedResolve()}createProviderForOperation(e){let r=this.config.walletProviders?.[this.chain.name]?.[e];if(r){let i=r(this.config,this.chain);if(!i)throw new Error(`Custom wallet provider factory returned null for ${e}`);return i}if(e==="privateKey")return new C(this.config,this.chain);if(e==="mnemonic")return new w(this.config,this.chain);throw new Error(`Unsupported wallet provider for ${this.chain.name}: ${e}`)}};var N={chain:S.Sui,identifier:"0x2::sui::SUI",name:"SUI",symbol:"SUI",decimals:9,logoUrl:"https://assets.coingecko.com/coins/images/26375/standard/sui-ocean-square.png?1727791290"};function je(l,e){return(t,r)=>{if(!r)throw new Error(`${l} adapter requires a fallback adapter`);let i=e[t.env];if(!i)throw new Error(`SuiAdapter: chain info not found for chain ${l}`);return{chainInfo:i,builder:()=>new T(t,i),executor:new x(t,i),output:new v(t,i),serializer:new h,registry:r.registry,explorer:new U(t,i),abiBuilder:()=>new W(t,i),brandBuilder:()=>new P(t,i),dataLoader:new I(t,i),wallet:new B(t,i)}}}var mi=je(S.Sui,{mainnet:{name:S.Sui,displayName:"Sui",chainId:"1",blockTime:3e3,addressHrp:"sui",defaultApiUrl:"https://fullnode.mainnet.sui.io",logoUrl:"https://raw.githubusercontent.com/JoAiHQ/assets/refs/heads/main/chains/logos/sui.svg",nativeToken:N},testnet:{name:S.Sui,displayName:"Sui Testnet",chainId:"testnet",blockTime:3e3,addressHrp:"sui",defaultApiUrl:"https://fullnode.testnet.sui.io",logoUrl:"https://raw.githubusercontent.com/JoAiHQ/assets/refs/heads/main/chains/logos/sui.svg",nativeToken:N},devnet:{name:S.Sui,displayName:"Sui Devnet",chainId:"devnet",blockTime:3e3,addressHrp:"sui",defaultApiUrl:"https://fullnode.devnet.sui.io",logoUrl:"https://raw.githubusercontent.com/JoAiHQ/assets/refs/heads/main/chains/logos/sui.svg",nativeToken:N}});var L=class{constructor(e,t){this.abi=new W(e,t)}async loadModuleAbi(e,t){return this.abi.getModuleAbi(e,t)}async loadFunctionAbi(e,t,r){return this.abi.getFunctionAbi(e,t,r)}};export{g as ExplorerUrls,pe as KnownTokens,N as NativeTokenSui,mi as SuiAdapter,X as SuiExplorers,O as SuiExplorersConfig,W as WarpSuiAbiBuilder,P as WarpSuiBrandBuilder,T as WarpSuiBuilder,Me as WarpSuiConstants,L as WarpSuiContractLoader,I as WarpSuiDataLoader,x as WarpSuiExecutor,U as WarpSuiExplorer,v as WarpSuiOutput,h as WarpSuiSerializer,B as WarpSuiWallet,$ as findKnownTokenById,z as getConfiguredSuiClient};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@joai/warps-adapter-sui",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.2",
|
|
4
4
|
"description": "",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
@@ -38,6 +38,6 @@
|
|
|
38
38
|
"dependencies": {
|
|
39
39
|
"@mysten/sui": "^1.45.2",
|
|
40
40
|
"@scure/bip39": "^2.0.1",
|
|
41
|
-
"@joai/warps": "^4.
|
|
41
|
+
"@joai/warps": "^4.15.2"
|
|
42
42
|
}
|
|
43
43
|
}
|