@vleap/warps-adapter-multiversx 0.2.0-beta.90 → 0.2.0-beta.91

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 CHANGED
@@ -280,8 +280,10 @@ declare class WarpMultiversxWallet implements AdapterWarpWallet {
280
280
  signMessage(message: string): Promise<string>;
281
281
  sendTransactions(txs: WarpAdapterGenericTransaction[]): Promise<string[]>;
282
282
  sendTransaction(tx: WarpAdapterGenericTransaction): Promise<string>;
283
- create(provider: WarpWalletProvider, mnemonic: string): WarpWalletDetails;
284
- generate(provider: WarpWalletProvider): WarpWalletDetails;
283
+ importFromMnemonic(provider: WarpWalletProvider, mnemonic: string): Promise<WarpWalletDetails>;
284
+ importFromPrivateKey(provider: WarpWalletProvider, privateKey: string): Promise<WarpWalletDetails>;
285
+ export(provider: WarpWalletProvider): Promise<WarpWalletDetails>;
286
+ generate(provider: WarpWalletProvider): Promise<WarpWalletDetails>;
285
287
  getAddress(): string | null;
286
288
  getPublicKey(): string | null;
287
289
  private createProvider;
package/dist/index.d.ts CHANGED
@@ -280,8 +280,10 @@ declare class WarpMultiversxWallet implements AdapterWarpWallet {
280
280
  signMessage(message: string): Promise<string>;
281
281
  sendTransactions(txs: WarpAdapterGenericTransaction[]): Promise<string[]>;
282
282
  sendTransaction(tx: WarpAdapterGenericTransaction): Promise<string>;
283
- create(provider: WarpWalletProvider, mnemonic: string): WarpWalletDetails;
284
- generate(provider: WarpWalletProvider): WarpWalletDetails;
283
+ importFromMnemonic(provider: WarpWalletProvider, mnemonic: string): Promise<WarpWalletDetails>;
284
+ importFromPrivateKey(provider: WarpWalletProvider, privateKey: string): Promise<WarpWalletDetails>;
285
+ export(provider: WarpWalletProvider): Promise<WarpWalletDetails>;
286
+ generate(provider: WarpWalletProvider): Promise<WarpWalletDetails>;
285
287
  getAddress(): string | null;
286
288
  getPublicKey(): string | null;
287
289
  private createProvider;
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- "use strict";var xe=Object.defineProperty;var et=Object.getOwnPropertyDescriptor;var tt=Object.getOwnPropertyNames;var rt=Object.prototype.hasOwnProperty;var nt=(s,e)=>{for(var t in e)xe(s,t,{get:e[t],enumerable:!0})},at=(s,e,t,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of tt(e))!rt.call(s,n)&&n!==t&&xe(s,n,{get:()=>e[n],enumerable:!(r=et(e,n))||r.enumerable});return s};var it=s=>at(xe({},"__esModule",{value:!0}),s);var Ft={};nt(Ft,{ExplorerUrls:()=>$,KnownTokens:()=>Ie,MultiversxAdapter:()=>Ve,MultiversxExplorers:()=>qe,MultiversxExplorersConfig:()=>Pe,NativeTokenEgld:()=>Ce,NativeTokenVibe:()=>Ye,VibechainAdapter:()=>ke,VibechainExplorers:()=>je,WarpMultiversxAbiBuilder:()=>O,WarpMultiversxBrandBuilder:()=>oe,WarpMultiversxBuilder:()=>ce,WarpMultiversxConstants:()=>ct,WarpMultiversxContractLoader:()=>se,WarpMultiversxDataLoader:()=>le,WarpMultiversxExecutor:()=>pe,WarpMultiversxExplorer:()=>ue,WarpMultiversxInputTypes:()=>w,WarpMultiversxOutput:()=>Q,WarpMultiversxRegistry:()=>de,WarpMultiversxSerializer:()=>M,WarpMultiversxWallet:()=>fe,address_value:()=>Pt,asset_value:()=>Vt,biguint_value:()=>It,boolean_value:()=>St,codemeta:()=>ht,codemeta_value:()=>Ut,composite_value:()=>Tt,createMultiversxAdapter:()=>ye,findKnownTokenById:()=>Se,getAllMultiversxAdapters:()=>mt,getAllMultiversxChainNames:()=>st,getKnownTokensForChain:()=>ot,getMultiversxEntrypoint:()=>C,getMultiversxRegistryAddress:()=>S,getNormalizedTokenIdentifier:()=>ie,hex_value:()=>Nt,isNativeToken:()=>z,list:()=>ft,list_value:()=>wt,nothing_value:()=>kt,option_value:()=>yt,optional:()=>gt,optional_value:()=>vt,string_value:()=>Ct,toTypedConfigInfo:()=>Ne,toTypedRegistryInfo:()=>me,token:()=>dt,token_value:()=>Bt,u16_value:()=>xt,u32_value:()=>Et,u64_value:()=>bt,u8_value:()=>At,variadic_value:()=>Wt});module.exports=it(Ft);var Ee=require("@vleap/warps"),st=()=>[Ee.WarpChainName.Multiversx,Ee.WarpChainName.Vibechain];var Je=require("@vleap/warps");var k=require("@multiversx/sdk-core"),E=require("@vleap/warps");var J=require("@multiversx/sdk-core"),Fe=require("@vleap/warps"),z=s=>!s.includes("-"),ie=s=>z(s)?`${s}-000000`:s,C=(s,e,t)=>{let r="warp-sdk",i=t?(0,Fe.getProviderConfig)(t,s.name,e,s.defaultApiUrl):{url:s.defaultApiUrl},o=i.url,l={headers:i.headers};return e==="devnet"?new J.DevnetEntrypoint({url:o,kind:"api",clientName:r,networkProviderConfig:l}):e==="testnet"?new J.TestnetEntrypoint({url:o,kind:"api",clientName:r,networkProviderConfig:l}):new J.MainnetEntrypoint({url:o,kind:"api",clientName:r,networkProviderConfig:l})};var be=require("@vleap/warps");var se=class{constructor(e){this.config=e}async getContract(e,t){try{let i=await C(t,this.config.env,this.config).createNetworkProvider().doGetGeneric(`accounts/${e}`);return{address:e,owner:i.ownerAddress,verified:i.isVerified||!1}}catch(r){return be.WarpLogger.error("WarpContractLoader: getContract error",r),null}}async getVerificationInfo(e,t){try{let i=await C(t,this.config.env,this.config).createNetworkProvider().doGetGeneric(`accounts/${e}/verification`);return{codeHash:i.codeHash,abi:i.source.abi}}catch(r){return be.WarpLogger.error("WarpContractLoader: getVerificationInfo error",r),null}}};var O=class{constructor(e,t){this.config=e;this.chain=t;this.contractLoader=new se(this.config),this.cache=new E.WarpCache(this.config.cache?.type)}async createInscriptionTransaction(e){let t=(0,E.getWarpWalletAddressFromConfig)(this.config,this.chain.name);if(!t)throw new Error("WarpBuilder: user address not set");let r=new k.TransactionsFactoryConfig({chainID:this.chain.chainId}),n=new k.TransferTransactionsFactory({config:r}),i=k.Address.newFromBech32(t),o={protocol:(0,E.getLatestProtocolIdentifier)("abi"),content:e},l=JSON.stringify(o),c=await n.createTransactionForTransfer(i,{receiver:i,nativeAmount:BigInt(0),data:Uint8Array.from(Buffer.from(l))});return c.gasLimit=c.gasLimit+BigInt(2e6),c}async createFromRaw(e){return JSON.parse(e)}async createFromTransaction(e){let t=await this.createFromRaw(e.data.toString());return t.meta={chain:this.chain.name,identifier:(0,E.createWarpIdentifier)(this.chain.name,"hash",e.hash),query:null,hash:e.hash,creator:e.sender.toBech32(),createdAt:new Date(e.timestamp*1e3).toISOString()},t}async createFromTransactionHash(e,t){let r=E.WarpCacheKey.WarpAbi(this.config.env,e);if(t){let o=this.cache.get(r);if(o)return E.WarpLogger.info(`WarpAbiBuilder (createFromTransactionHash): Warp abi found in cache: ${e}`),o}let i=C(this.chain,this.config.env,this.config).createNetworkProvider();try{let o=await i.getTransaction(e),l=await this.createFromTransaction(o);return t&&t.ttl&&l&&this.cache.set(r,l,t.ttl),l}catch(o){return E.WarpLogger.error("WarpAbiBuilder: Error creating from transaction hash",o),null}}async getAbiForAction(e){if(e.abi)return await this.fetchAbi(e);if(!e.address)throw new Error("WarpActionExecutor: Address not found");let t=await this.contractLoader.getVerificationInfo(e.address,this.chain);if(!t)throw new Error("WarpActionExecutor: Verification info not found");return k.AbiRegistry.create(t.abi)}async fetchAbi(e){if(!e.abi)throw new Error("WarpActionExecutor: ABI not found");if(e.abi.startsWith(E.WarpConstants.IdentifierType.Hash)){let t=e.abi.split(E.WarpConstants.ArgParamsSeparator)[1],r=await this.createFromTransactionHash(t);if(!r)throw new Error(`WarpActionExecutor: ABI not found for hash: ${e.abi}`);return k.AbiRegistry.create(r.content)}else{let r=await(await fetch(e.abi)).json();return k.AbiRegistry.create(r)}}};var q=require("@multiversx/sdk-core"),L=require("@vleap/warps"),Oe=require("buffer");var oe=class{constructor(e,t){this.config=e;this.chain=t;this.core=new L.WarpBrandBuilder(e)}async createInscriptionTransaction(e){let t=(0,L.getWarpWalletAddressFromConfig)(this.config,this.chain.name);if(!t)throw new Error("BrandBuilder: user address not set");let r=new q.TransactionsFactoryConfig({chainID:this.chain.chainId}),n=new q.TransferTransactionsFactory({config:r}),i=q.Address.newFromBech32(t),o=JSON.stringify(e);return await n.createTransactionForNativeTokenTransfer(i,{receiver:q.Address.newFromBech32(t),nativeAmount:BigInt(0),data:Uint8Array.from(Oe.Buffer.from(o))})}async createFromTransaction(e,t=!1){let r=await this.core.createFromRaw(e.data.toString(),t);return r.meta={query:null,chain:this.chain.name,identifier:(0,L.createWarpIdentifier)(this.chain.name,"hash",e.hash),hash:e.hash,creator:e.sender.toBech32(),createdAt:new Date(e.timestamp*1e3).toISOString()},r}async createFromTransactionHash(e){let r=C(this.chain,this.config.env,this.config).createNetworkProvider();try{let n=await r.getTransaction(e);return this.createFromTransaction(n)}catch(n){return L.WarpLogger.error("BrandBuilder: Error creating from transaction hash",n),null}}};var j=require("@multiversx/sdk-core"),B=require("@vleap/warps");var ce=class extends B.WarpBuilder{constructor(t,r){super(t);this.config=t;this.chain=r;this.cache=new B.WarpCache(t.cache?.type),this.core=new B.WarpBuilder(t)}async createInscriptionTransaction(t){let r=(0,B.getWarpWalletAddressFromConfig)(this.config,this.chain.name);if(!r)throw new Error("WarpBuilder: user address not set");let n=new j.TransactionsFactoryConfig({chainID:this.chain.chainId}),i=new j.TransferTransactionsFactory({config:n}),o=j.Address.newFromBech32(r),l=JSON.stringify(t),c=await i.createTransactionForTransfer(o,{receiver:j.Address.newFromBech32(r),nativeAmount:BigInt(0),data:Uint8Array.from(Buffer.from(l))});return c.gasLimit=c.gasLimit+BigInt(2e6),c}async createFromTransaction(t,r=!1){let n=await this.core.createFromRaw(t.data.toString(),r);return n.meta={chain:this.chain.name,identifier:(0,B.createWarpIdentifier)(this.chain.name,"hash",t.hash),query:null,hash:t.hash,creator:t.sender.toBech32(),createdAt:new Date(t.timestamp*1e3).toISOString()},n}async createFromTransactionHash(t,r){let n=B.WarpCacheKey.Warp(this.config.env,t);if(r){let l=this.cache.get(n);if(l)return B.WarpLogger.info(`WarpBuilder (createFromTransactionHash): Warp found in cache: ${t}`),l}let o=C(this.chain,this.config.env,this.config).createNetworkProvider();try{let l=await o.getTransaction(t),c=await this.createFromTransaction(l);return r&&r.ttl&&c&&this.cache.set(n,c,r.ttl),c}catch(l){return B.WarpLogger.error("WarpBuilder: Error creating from transaction hash",l),null}}};var _=require("@multiversx/sdk-core"),Y=require("@vleap/warps");var Re=require("@vleap/warps"),Me=Re.WarpChainName.Multiversx,De=[{chain:Me,identifier:"EGLD",name:"eGold",symbol:"EGLD",decimals:18,logoUrl:"https://tools.multiversx.com/assets-cdn/tokens/EGLD-000000/icon.png"},{chain:Me,identifier:"EGLD-000000",name:"eGold",symbol:"EGLD",decimals:18,logoUrl:"https://tools.multiversx.com/assets-cdn/tokens/EGLD-000000/icon.png"}];var Le=require("@vleap/warps"),I=Le.WarpChainName.Multiversx,_e=[{chain:I,identifier:"EGLD",name:"eGold",symbol:"EGLD",decimals:18,logoUrl:"https://tools.multiversx.com/assets-cdn/tokens/EGLD-000000/icon.png"},{chain:I,identifier:"EGLD-000000",name:"eGold",symbol:"EGLD",decimals:18,logoUrl:"https://tools.multiversx.com/assets-cdn/tokens/EGLD-000000/icon.png"},{chain:I,identifier:"SEGLD-3ad2d0",name:"StakedEGLD",symbol:"SEGLD",decimals:18,logoUrl:"https://tools.multiversx.com/assets-cdn/tokens/SEGLD-3ad2d0/icon.png"},{chain:I,identifier:"HSEGLD-c13a4e",name:"HatomSEGLD",symbol:"HSEGLD",decimals:8,logoUrl:"https://tools.multiversx.com/assets-cdn/tokens/HSEGLD-c13a4e/icon.png"},{chain:I,identifier:"UTK-2f80e9",name:"xMoney UTK",symbol:"UTK",decimals:18,logoUrl:"https://tools.multiversx.com/assets-cdn/tokens/UTK-2f80e9/icon.png"},{chain:I,identifier:"USDC-c76f1f",name:"WrappedUSDC",symbol:"USDC",decimals:6,logoUrl:"https://tools.multiversx.com/assets-cdn/tokens/USDC-c76f1f/icon.png"},{chain:I,identifier:"WEGLD-bd4d79",name:"WrappedEGLD",symbol:"WEGLD",decimals:18,logoUrl:"https://tools.multiversx.com/assets-cdn/tokens/WEGLD-bd4d79/icon.png"},{chain:I,identifier:"HTM-f51d55",name:"Hatom",symbol:"HTM",decimals:18,logoUrl:"https://tools.multiversx.com/assets-cdn/tokens/HTM-f51d55/icon.png"},{chain:I,identifier:"MEX-455c57",name:"MEX",symbol:"MEX",decimals:18,logoUrl:"https://tools.multiversx.com/assets-cdn/tokens/MEX-455c57/icon.png"},{chain:I,identifier:"WTAO-4f5363",name:"WrappedTAO",symbol:"WTAO",decimals:9,logoUrl:"https://tools.multiversx.com/assets-cdn/tokens/WTAO-4f5363/icon.png"},{chain:I,identifier:"HEGLD-d61095",name:"HatomEGLD",symbol:"HEGLD",decimals:8,logoUrl:"https://tools.multiversx.com/assets-cdn/tokens/HEGLD-d61095/icon.png"},{chain:I,identifier:"WBTC-5349b3",name:"WrappedBTC",symbol:"WBTC",decimals:8,logoUrl:"https://tools.multiversx.com/assets-cdn/tokens/WBTC-5349b3/icon.png"},{chain:I,identifier:"WETH-b4ca29",name:"WrappedETH",symbol:"WETH",decimals:18,logoUrl:"https://tools.multiversx.com/assets-cdn/tokens/WETH-b4ca29/icon.png"},{chain:I,identifier:"USH-111e09",name:"HatomUSD",symbol:"USH",decimals:18,logoUrl:"https://tools.multiversx.com/assets-cdn/tokens/USH-111e09/icon.png"},{chain:I,identifier:"USDT-f8c08c",name:"WrappedUSDT",symbol:"USDT",decimals:6,logoUrl:"https://tools.multiversx.com/assets-cdn/tokens/USDT-f8c08c/icon.png"}];var Ge=require("@vleap/warps"),$e=Ge.WarpChainName.Multiversx,He=[{chain:$e,identifier:"EGLD",name:"eGold",symbol:"EGLD",decimals:18,logoUrl:"https://tools.multiversx.com/assets-cdn/tokens/EGLD-000000/icon.png"},{chain:$e,identifier:"EGLD-000000",name:"eGold",symbol:"EGLD",decimals:18,logoUrl:"https://tools.multiversx.com/assets-cdn/tokens/EGLD-000000/icon.png"}];var ze=require("@vleap/warps"),Ke=ze.WarpChainName.Vibechain,ve=[{chain:Ke,identifier:"VIBE",name:"VIBE",symbol:"VIBE",decimals:18,logoUrl:"https://joai.ai/images/tokens/vibe.svg"},{chain:Ke,identifier:"VIBE-000000",name:"VIBE",symbol:"VIBE",decimals:18,logoUrl:"https://joai.ai/images/tokens/vibe.svg"}];var Ie={multiversx:{mainnet:_e,testnet:He,devnet:De},vibechain:{mainnet:ve,testnet:ve,devnet:ve}},Se=(s,e,t)=>(Ie[s]?.[e]||[]).find(n=>n.identifier===t)||null,ot=(s,e)=>Ie[s]?.[e]||[];var le=class{constructor(e,t){this.config=e;this.chain=t;this.cache=new Y.WarpCache(e.cache?.type)}async getAccount(e){let r=await C(this.chain,this.config.env,this.config).createNetworkProvider().getAccount(_.Address.newFromBech32(e));return{chain:this.chain.name,address:r.address.toBech32(),balance:r.balance}}async getAccountAssets(e){let t=C(this.chain,this.config.env,this.config).createNetworkProvider(),r=t.getAccount(_.Address.newFromBech32(e)),n=t.getFungibleTokensOfAccount(_.Address.newFromBech32(e)),[i,o]=await Promise.all([r,n]),l=i.balance>0?[{...this.chain.nativeToken,amount:i.balance}]:[];return l.push(...o.map(c=>({chain:this.chain.name,identifier:c.token.identifier,name:c.raw.name,symbol:c.raw.ticker,amount:c.amount,decimals:c.raw.decimals,logoUrl:c.raw.assets?.pngUrl||"",price:c.raw.price?Number(c.raw.price):void 0,supply:c.raw.supply?BigInt(c.raw.supply):void 0}))),l}async getAsset(e){let t=Y.WarpCacheKey.Asset(this.config.env,this.chain.name,e),r=this.cache.get(t);if(r)return r;let n=Se(this.chain.name,this.config.env,e);if(n)return{chain:this.chain.name,identifier:e,name:n.name,symbol:n.symbol,amount:0n,decimals:n.decimals,logoUrl:n.logoUrl};let i=new _.TokenComputer,o=z(e)?0n:i.extractNonceFromExtendedIdentifier(e),l=new _.Token({identifier:e,nonce:BigInt(o||0)}),c=i.isFungible(l),f=C(this.chain,this.config.env,this.config).createNetworkProvider(),g=ie(e),d=await f.doGetGeneric(`tokens/${g}`),T={chain:this.chain.name,identifier:l.identifier,name:d.name,symbol:d.ticker,amount:0n,decimals:d.decimals,logoUrl:d.assets?.pngUrl||null,price:d.price?Number(d.price):void 0,supply:d.supply?BigInt(d.supply):void 0};return this.cache.set(t,T,Y.CacheTtl.OneHour),T}async getAction(e,t=!1){let r=C(this.chain,this.config.env,this.config),n=t?await r.awaitCompletedTransaction(e):await r.getTransaction(e);return{chain:this.chain.name,id:n.hash,receiver:n.receiver.toBech32(),sender:n.sender.toBech32(),value:n.value,function:n.function,status:this.toActionStatus(n),createdAt:this.toActionCreatedAt(n),error:n?.smartContractResults.map(i=>i.raw.returnMessage)[0]||null,tx:n}}async getAccountActions(e,t){let r=C(this.chain,this.config.env,this.config).createNetworkProvider(),n=`accounts/${e}/transactions`,i=new URLSearchParams,o=t?.size||25,l=t?.page||0;if(l>0){let f=l*o;i.append("from",f.toString())}return o!==25&&i.append("size",o.toString()),i.toString()&&(n+=`?${i.toString()}`),(await r.doGetGeneric(n)).map(f=>({chain:this.chain.name,id:f.txHash,receiver:f.receiver,sender:f.sender,value:f.value,function:f.function,status:this.toActionStatus(f),createdAt:this.toActionCreatedAt(f)}))}toActionStatus(e){return e.status.isSuccessful()?"success":e.status.isFailed()?"failed":"pending"}toActionCreatedAt(e){return new Date(e.timestamp||e.timestamp*1e3).toISOString()}};var A=require("@multiversx/sdk-core"),N=require("@vleap/warps");var Z=require("@multiversx/sdk-core"),W=require("@vleap/warps");var a=require("@multiversx/sdk-core"),Qe=require("@vleap/warps");var h={HttpProtocolPrefix:"http",IdentifierParamName:"warp",IdentifierParamSeparator:":",IdentifierChainDefault:"multiversx",IdentifierType:{Alias:"alias",Hash:"hash"},IdentifierAliasMarker:"@",Globals:{UserWallet:{Placeholder:"USER_WALLET",Accessor:s=>s.config.user?.wallets?.[s.adapter.chainInfo.name]},UserWalletPublicKey:{Placeholder:"USER_WALLET_PUBLICKEY",Accessor:s=>{if(!s.adapter.wallet)return null;try{return s.adapter.wallet.getPublicKey()||null}catch{return null}}},ChainApiUrl:{Placeholder:"CHAIN_API",Accessor:s=>s.adapter.chainInfo.defaultApiUrl},ChainAddressHrp:{Placeholder:"CHAIN_ADDRESS_HRP",Accessor:s=>s.adapter.chainInfo.addressHrp}},Vars:{Query:"query",Env:"env"},ArgParamsSeparator:":",ArgCompositeSeparator:"|",ArgListSeparator:",",ArgStructSeparator:";",Transform:{Prefix:"transform:"},Source:{UserWallet:"user:wallet"},Position:{Payload:"payload:"},Alerts:{TriggerEventPrefix:"event"}},u={Option:"option",Vector:"vector",Tuple:"tuple",Struct:"struct",String:"string",Uint8:"uint8",Uint16:"uint16",Uint32:"uint32",Uint64:"uint64",Uint128:"uint128",Uint256:"uint256",Biguint:"biguint",Bool:"bool",Address:"address",Asset:"asset",Hex:"hex"};var ct={Egld:{Identifier:"EGLD",EsdtIdentifier:"EGLD-000000",DisplayName:"eGold",Decimals:18}},w={Null:"null",Optional:"optional",List:"list",Token:"token",CodeMeta:"codemeta"},qe=(r=>(r.MultiversxExplorer="multiversx_explorer",r.MultiversxExplorerDevnet="multiversx_explorer_devnet",r.MultiversxExplorerTestnet="multiversx_explorer_testnet",r))(qe||{}),je=(r=>(r.VibechainExplorer="vibechain_explorer",r.VibechainExplorerDevnet="vibechain_explorer_devnet",r.VibechainExplorerTestnet="vibechain_explorer_testnet",r))(je||{}),Pe={multiversx:{mainnet:["multiversx_explorer"],testnet:["multiversx_explorer_testnet"],devnet:["multiversx_explorer_devnet"]},vibechain:{mainnet:["vibechain_explorer"],testnet:["vibechain_explorer_testnet"],devnet:["vibechain_explorer_devnet"]}},$={multiversx_explorer:"https://explorer.multiversx.com",multiversx_explorer_devnet:"https://devnet-explorer.multiversx.com",multiversx_explorer_testnet:"https://testnet-explorer.multiversx.com",vibechain_explorer:"https://vibeox-explorer.multiversx.com",vibechain_explorer_devnet:"https://vibeox-explorer.multiversx.com",vibechain_explorer_testnet:"https://vibeox-explorer.multiversx.com"};var lt=new RegExp(`${h.ArgParamsSeparator}(.*)`),M=class{constructor(e){this.coreSerializer=new Qe.WarpSerializer(e)}typedToString(e){let t=e.getType();if(t.hasExactClass(a.OptionType.ClassName)||e.hasClassOrSuperclass(a.OptionValue.ClassName)){if(!e.isSet())return u.Option+h.ArgParamsSeparator+"null";let r=this.typedToString(e.getTypedValue());return u.Option+h.ArgParamsSeparator+r}if(t.hasExactClass(a.VariadicType.ClassName)||e.hasClassOrSuperclass(a.VariadicValue.ClassName)){let r=e.getItems();if(r.length===0){let g=this.typeToString(t.getFirstTypeParameter());return u.Vector+h.ArgParamsSeparator+g+h.ArgParamsSeparator}let n=r.map(g=>this.typedToString(g));if(n.every(g=>g.startsWith(u.Tuple)))return u.Vector+h.ArgParamsSeparator+n.join(",");let i=n[0],o=i.indexOf(h.ArgParamsSeparator),l=i.substring(0,o),c=n.map(g=>{let d=g.indexOf(h.ArgParamsSeparator);return g.substring(d+1)}),f=l.startsWith(u.Struct)?h.ArgStructSeparator:h.ArgListSeparator;return u.Vector+h.ArgParamsSeparator+l+h.ArgParamsSeparator+c.join(f)}if(t.hasExactClass(a.OptionalType.ClassName)||e.hasClassOrSuperclass(a.OptionalValue.ClassName)){if(!e.isSet())return w.Optional+h.ArgParamsSeparator+"null";let r=this.typedToString(e.getTypedValue());return w.Optional+h.ArgParamsSeparator+r}if(t.hasExactClass(a.ListType.ClassName)||e.hasClassOrSuperclass(a.List.ClassName)){let n=e.getItems().map(c=>this.typedToString(c));if(n.every(c=>c.startsWith(u.Tuple)))return w.List+h.ArgParamsSeparator+n.join(",");let o=n.map(c=>c.split(h.ArgParamsSeparator)[0])[0],l=n.map(c=>c.split(h.ArgParamsSeparator)[1]);return w.List+h.ArgParamsSeparator+o+h.ArgParamsSeparator+l.join(h.ArgListSeparator)}if(t.hasExactClass(a.CompositeType.ClassName)||e.hasClassOrSuperclass(a.CompositeValue.ClassName)){let n=e.getItems().map(i=>{let o=this.typedToString(i),l=o.indexOf(h.ArgParamsSeparator),c=o.substring(0,l),f=o.substring(l+1);return`${c},${f}`});return`${u.Tuple}(${n.join(",")})`}if(t.hasExactClass(a.BigUIntType.ClassName)||e.hasClassOrSuperclass(a.BigUIntValue.ClassName)||t.getName()==="BigUint")return u.Biguint+h.ArgParamsSeparator+BigInt(e.valueOf().toFixed());if(t.hasExactClass(a.U8Type.ClassName)||e.hasClassOrSuperclass(a.U8Value.ClassName))return u.Uint8+h.ArgParamsSeparator+e.valueOf().toNumber();if(t.hasExactClass(a.U16Type.ClassName)||e.hasClassOrSuperclass(a.U16Value.ClassName))return u.Uint16+h.ArgParamsSeparator+e.valueOf().toNumber();if(t.hasExactClass(a.U32Type.ClassName)||e.hasClassOrSuperclass(a.U32Value.ClassName))return u.Uint32+h.ArgParamsSeparator+e.valueOf().toNumber();if(t.hasExactClass(a.U64Type.ClassName)||e.hasClassOrSuperclass(a.U64Value.ClassName))return u.Uint64+h.ArgParamsSeparator+BigInt(e.valueOf().toFixed());if(t.hasExactClass(a.StringType.ClassName)||e.hasClassOrSuperclass(a.StringValue.ClassName))return u.String+h.ArgParamsSeparator+e.valueOf();if(t.hasExactClass(a.BooleanType.ClassName)||e.hasClassOrSuperclass(a.BooleanValue.ClassName))return u.Bool+h.ArgParamsSeparator+e.valueOf();if(t.hasExactClass(a.AddressType.ClassName)||e.hasClassOrSuperclass(a.AddressValue.ClassName))return u.Address+h.ArgParamsSeparator+e.valueOf().toBech32();if(t.hasExactClass(a.BytesType.ClassName)||e.hasClassOrSuperclass(a.BytesValue.ClassName))return u.Hex+h.ArgParamsSeparator+e.valueOf().toString("hex");if(t.getName()==="EsdtTokenPayment"){let r=e.getFieldValue("token_identifier").valueOf(),n=e.getFieldValue("token_nonce").valueOf(),i=e.getFieldValue("amount").valueOf(),l=new a.TokenComputer().computeExtendedIdentifier(new a.Token({identifier:r,nonce:BigInt(n)}));return u.Asset+h.ArgParamsSeparator+l+h.ArgCompositeSeparator+i}if(t.hasExactClass(a.StructType.ClassName)||e.hasClassOrSuperclass(a.Struct.ClassName)){let r=e,i=r.getType().getName(),o=r.getFields();if(o.length===0)return`${u.Struct}(${i})${h.ArgParamsSeparator}`;let l=o.map(c=>{let f=c.value.getType(),d=this.typedToString(c.value).split(h.ArgParamsSeparator),T=d.length>2?d.slice(2).join(h.ArgParamsSeparator):d[1]||"";return`(${c.name}${h.ArgParamsSeparator}${this.typeToString(f)})${T}`});return`${u.Struct}(${i})${h.ArgParamsSeparator}${l.join(h.ArgListSeparator)}`}if(t.hasExactClass(a.TokenIdentifierType.ClassName)||e.hasClassOrSuperclass(a.TokenIdentifierValue.ClassName))return w.Token+h.ArgParamsSeparator+e.valueOf();if(t.hasExactClass(a.CodeMetadataType.ClassName)||e.hasClassOrSuperclass(a.CodeMetadataValue.ClassName))return w.CodeMeta+h.ArgParamsSeparator+e.valueOf().toString();throw new Error(`WarpArgSerializer (typedToString): Unsupported input type: ${e.getClassName()}`)}typedToNative(e){let t=this.typedToString(e);return this.coreSerializer.stringToNative(t)}nativeToTyped(e,t){if(e.startsWith(u.Tuple))return this.stringToTyped(e+":");let r=this.coreSerializer.nativeToString(e,t);return this.stringToTyped(r)}nativeToType(e){if(e.startsWith(u.Tuple)){let t=e.match(/\(([^)]+)\)/)?.[1];if(!t)throw new Error(`Invalid tuple type format: ${e}`);let r=t.split(","),n=[];for(let i=0;i<r.length;i+=2)n.push(r[i]);return new a.CompositeType(...n.map(i=>this.nativeToType(i)))}if(e.startsWith(u.Struct)){let t=e.match(/\(([^)]+)\)/);if(!t)throw new Error("Struct type must include a name in the format struct(Name)");let r=t[1];return new a.StructType(r,[])}if(e===u.String)return new a.StringType;if(e===u.Uint8)return new a.U8Type;if(e===u.Uint16)return new a.U16Type;if(e===u.Uint32)return new a.U32Type;if(e===u.Uint64)return new a.U64Type;if(e===u.Biguint)return new a.BigUIntType;if(e===u.Bool)return new a.BooleanType;if(e===u.Address)return new a.AddressType;if(e===u.Hex)return new a.BytesType;if(e===u.Asset)return new a.StructType("EsdtTokenPayment",[new a.FieldDefinition("token_identifier","",new a.TokenIdentifierType),new a.FieldDefinition("token_nonce","",new a.U64Type),new a.FieldDefinition("amount","",new a.BigUIntType)]);if(e===w.Token)return new a.TokenIdentifierType;if(e===w.CodeMeta)return new a.CodeMetadataType;throw new Error(`WarpArgSerializer (nativeToType): Unsupported input type: ${e}`)}stringToTyped(e){let[t,r]=e.split(/:(.*)/,2);if(t===u.Option){let n=this.stringToTyped(r);return n instanceof a.NothingValue?a.OptionValue.newMissingTyped(n.getType()):a.OptionValue.newProvided(n)}if(t===u.Vector){let n=r.indexOf(h.ArgParamsSeparator),i=r.substring(0,n),o=r.substring(n+1);if(i.startsWith(u.Tuple)){let d=o.split(",").map(T=>this.stringToTyped(T));return new a.VariadicValue(new a.VariadicType(this.nativeToType(i)),d)}if(o.includes("tuple(")){let g=this.splitTupleStrings(o),d=g.map(x=>this.stringToTyped(x)),b=g[0].match(/^(tuple\([^)]+\))/),y=b?b[1]:"tuple";return new a.VariadicValue(new a.VariadicType(this.nativeToType(y)),d)}let l=i.startsWith(u.Struct)?h.ArgStructSeparator:h.ArgListSeparator,f=o.split(l).map(g=>this.stringToTyped(`${i}:${g}`));return new a.VariadicValue(new a.VariadicType(this.nativeToType(i)),f)}if(t.startsWith(u.Tuple)){let n=t.match(/\(([^)]+)\)/)?.[1];if(!n)throw new Error(`Invalid tuple format: ${t}`);let i=n.split(","),o=[];for(let c=0;c<i.length;c+=2){let f=i[c],g=i[c+1];o.push(this.stringToTyped(`${f}:${g}`))}let l=o.map(c=>c.getType());return new a.CompositeValue(new a.CompositeType(...l),o)}if(t.startsWith(u.Struct)){let n=t.match(/\(([^)]+)\)/),i=n?n[1]:"CustomStruct";if(!r)return new a.Struct(new a.StructType(i,[]),[]);let o=r.split(h.ArgListSeparator),l=[],c=[];return o.forEach(f=>{let g=f.match(new RegExp(`^\\(([^${h.ArgParamsSeparator}]+)${h.ArgParamsSeparator}([^)]+)\\)(.+)$`));if(g){let[,d,T,b]=g,y=this.stringToTyped(`${T}${h.ArgParamsSeparator}${b}`);l.push(new a.FieldDefinition(d,"",y.getType())),c.push(new a.Field(y,d))}}),new a.Struct(new a.StructType(i,l),c)}if(t===u.String)return r?a.StringValue.fromUTF8(r):new a.NothingValue;if(t===u.Uint8)return r?new a.U8Value(Number(r)):new a.NothingValue;if(t===u.Uint16)return r?new a.U16Value(Number(r)):new a.NothingValue;if(t===u.Uint32)return r?new a.U32Value(Number(r)):new a.NothingValue;if(t===u.Uint64)return r?new a.U64Value(BigInt(r)):new a.NothingValue;if(t===u.Biguint)return r?new a.BigUIntValue(BigInt(r)):new a.NothingValue;if(t===u.Bool)return r?new a.BooleanValue(typeof r=="boolean"?r:r==="true"):new a.NothingValue;if(t===u.Address)return r?new a.AddressValue(a.Address.newFromBech32(r)):new a.NothingValue;if(t===u.Hex)return r?a.BytesValue.fromHex(r):new a.NothingValue;if(t===u.Asset){let[n,i]=r.split(h.ArgCompositeSeparator),o=new a.TokenComputer,l=z(n)?ie(n):o.extractIdentifierFromExtendedIdentifier(n),c=z(n)?0n:o.extractNonceFromExtendedIdentifier(n);return new a.Struct(this.nativeToType("asset"),[new a.Field(new a.TokenIdentifierValue(l),"token_identifier"),new a.Field(new a.U64Value(BigInt(c)),"token_nonce"),new a.Field(new a.BigUIntValue(BigInt(i)),"amount")])}if(t===w.Null)return new a.NothingValue;if(t===w.Optional){let n=this.stringToTyped(r);return n instanceof a.NothingValue?a.OptionalValue.newMissing():new a.OptionalValue(n.getType(),n)}if(t===w.List){let[n,i]=r.split(lt,2),l=i.split(h.ArgListSeparator).map(c=>this.stringToTyped(n+h.ArgParamsSeparator+c));return new a.List(this.nativeToType(n),l)}if(t===w.Token)return r?new a.TokenIdentifierValue(r):new a.NothingValue;if(t===w.CodeMeta)return new a.CodeMetadataValue(a.CodeMetadata.newFromBytes(Uint8Array.from(Buffer.from(r,"hex"))));throw new Error(`WarpArgSerializer (stringToTyped): Unsupported input type: ${t}`)}splitTupleStrings(e){let t=[],r="",n=0;for(let i=0;i<e.length;i++){let o=e[i];if(o==="(")n++;else if(o===")")n--;else if(o===","&&n===0){t.push(r.trim()),r="";continue}r+=o}return r.trim()&&t.push(r.trim()),t}typeToString(e){if(e.hasExactClass(a.OptionType.ClassName))return u.Option+h.ArgParamsSeparator+this.typeToString(e.getFirstTypeParameter());if(e.hasExactClass(a.VariadicType.ClassName))return u.Vector+h.ArgParamsSeparator+this.typeToString(e.getFirstTypeParameter());if(e.hasExactClass(a.StringType.ClassName))return u.String;if(e.hasExactClass(a.U8Type.ClassName))return u.Uint8;if(e.hasExactClass(a.U16Type.ClassName))return u.Uint16;if(e.hasExactClass(a.U32Type.ClassName))return u.Uint32;if(e.hasExactClass(a.U64Type.ClassName))return u.Uint64;if(e.hasExactClass(a.BigUIntType.ClassName))return u.Biguint;if(e.hasExactClass(a.BooleanType.ClassName))return u.Bool;if(e.hasExactClass(a.AddressType.ClassName))return u.Address;if(e.hasExactClass(a.BytesType.ClassName))return u.Hex;if(e.hasExactClass(a.TokenIdentifierType.ClassName))return w.Token;if(e.hasExactClass(a.OptionalType.ClassName))return w.Optional+h.ArgParamsSeparator+this.typeToString(e.getFirstTypeParameter());if(e.hasExactClass(a.ListType.ClassName))return w.List+h.ArgParamsSeparator+this.typeToString(e.getFirstTypeParameter());if(e.hasExactClass(a.CodeMetadataType.ClassName))return w.CodeMeta;if(e.hasExactClass(a.StructType.ClassName)&&e.getClassName()==="EsdtTokenPayment")return u.Asset;if(e.hasExactClass(a.StructType.ClassName))return`${u.Struct}(${e.getName()})`;throw new Error(`WarpArgSerializer (typeToString): Unsupported input type: ${e.getClassName()}`)}};var Q=class{constructor(e,t,r){this.config=e;this.chain=t;this.typeRegistry=r;this.abi=new O(e,t),this.serializer=new M({typeRegistry:this.typeRegistry}),this.cache=new W.WarpCache(e.cache?.type)}async getActionExecution(e,t,r){let n=this.cache.get(W.WarpCacheKey.WarpExecutable(this.config.env,e.meta?.hash||"",t))??[],i=await this.extractContractOutput(e,t,r,n),o=(0,W.getNextInfo)(this.config,[],e,t,i.output),l=(0,W.applyOutputToMessages)(e,i.output,this.config),c=(0,W.extractResolvedInputValues)(n);return{status:r.status.isSuccessful()?"success":"error",warp:e,action:t,user:(0,W.getWarpWalletAddressFromConfig)(this.config,this.chain.name),txHash:r.hash,tx:r,next:o,values:i.values,output:i.output,messages:l,destination:null,resolvedInputs:c}}async extractContractOutput(e,t,r,n){let i=(0,W.getWarpActionByIndex)(e,t),o=[],l=[],c={};if(!e.output||i.type!=="contract")return{values:{string:o,native:l,mapped:{}},output:c};if(!Object.values(e.output).some(y=>y.includes("out")||y.includes("event"))){for(let[y,x]of Object.entries(e.output))c[y]=x;return{values:{string:o,native:l,mapped:{}},output:await(0,W.evaluateOutputCommon)(e,c,t,n,this.serializer.coreSerializer,this.config)}}let g=await this.abi.getAbiForAction(i),d=new Z.TransactionEventsParser({abi:g}),b=new Z.SmartContractTransactionsOutcomeParser({abi:g}).parseExecute({transactionOnNetwork:r,function:i.func||void 0});for(let[y,x]of Object.entries(e.output)){if(x.startsWith(W.WarpConstants.Transform.Prefix))continue;if(x.startsWith("input.")){c[y]=x;continue}let P=(0,W.parseOutputOutIndex)(x);if(P!==null&&P!==t){c[y]=null;continue}let[U,H,K]=x.split(".");if(U==="event"){if(!H||isNaN(Number(K)))continue;let D=Number(K),v=(0,Z.findEventsByFirstTopic)(r,H),Ze=d.parseEvents({events:v})[0],ae=Object.values(Ze)[D]||null;o.push(String(ae)),l.push(ae),c[y]=ae&&ae.valueOf()}else if(U==="out"||U.startsWith("out[")){if(!H)continue;let D=Number(H),v=b.values[D-1]||null;K&&(v=v[K]||null),v&&typeof v=="object"&&(v="toFixed"in v?v.toFixed():v.valueOf()),o.push(String(v)),l.push(v),c[y]=v&&v.valueOf()}else c[y]=x}return{values:{string:o,native:l,mapped:{}},output:await(0,W.evaluateOutputCommon)(e,c,t,n,this.serializer.coreSerializer,this.config)}}async extractQueryOutput(e,t,r,n){let i=t.map(g=>this.serializer.typedToString(g)),o=t.map(g=>this.serializer.typedToNative(g)[1]),l={string:i,native:o,mapped:{}},c={};if(!e.output)return{values:l,output:c};let f=g=>{let d=g.split(".").slice(1).map(b=>parseInt(b)-1);if(d.length===0)return;let T=o[d[0]];for(let b=1;b<d.length;b++){if(T==null)return;T=T[d[b]]}return T};for(let[g,d]of Object.entries(e.output)){if(d.startsWith(W.WarpConstants.Transform.Prefix))continue;let T=(0,W.parseOutputOutIndex)(d);if(T!==null&&T!==r){c[g]=null;continue}d.startsWith("out.")||d==="out"||d.startsWith("out[")?c[g]=f(d)||null:c[g]=d}return c=await(0,W.evaluateOutputCommon)(e,c,r,n,this.serializer.coreSerializer,this.config),{values:l,output:c}}async resolveWarpOutputRecursively(e){let t=e.warp,r=e.entryActionIndex,n=e.executor,i=e.inputs,o=e.meta,l=new Map,c=new Set,f=this;async function g(y,x=[]){if(l.has(y))return l.get(y);if(c.has(y))throw new Error(`Circular dependency detected at action ${y}`);c.add(y);let P=t.actions[y-1];if(!P)throw new Error(`Action ${y} not found`);let U;if(P.type==="query")U=await n.executeQuery(t,y,x);else if(P.type==="collect")U=await n.executeCollect(t,y,x,o);else throw new Error(`Unsupported or interactive action type: ${P.type}`);if(l.set(y,U),t.output)for(let H of Object.values(t.output)){let D=String(H).match(/^out\[(\d+)\]/);if(D){let v=parseInt(D[1],10);v!==y&&!l.has(v)&&await g(v)}}return c.delete(y),U}await g(r,i);let d={};for(let y of l.values())for(let[x,P]of Object.entries(y.output))P!==null?d[x]=P:x in d||(d[x]=null);let T=await(0,W.evaluateOutputCommon)(t,d,r,i,this.serializer.coreSerializer,this.config);return{...l.get(r),action:r,output:T}}};var pt="EGLD-000000",pe=class{constructor(e,t,r){this.config=e;this.chain=t;this.typeRegistry=r;this.serializer=new M({typeRegistry:this.typeRegistry}),this.abi=new O(this.config,this.chain),this.output=new Q(this.config,this.chain,this.typeRegistry)}async createTransaction(e){let t=(0,N.getWarpActionByIndex)(e.warp,e.action),r=null;if(t.type==="transfer")r=await this.createTransferTransaction(e);else if(t.type==="contract")r=await this.createContractCallTransaction(e);else{if(t.type==="query")throw new Error("WarpMultiversxExecutor: Invalid action type for createTransactionForExecute; Use executeQuery instead");if(t.type==="collect")throw new Error("WarpMultiversxExecutor: Invalid action type for createTransactionForExecute; Use executeCollect instead")}if(!r)throw new Error(`WarpMultiversxExecutor: Invalid action type (${t.type})`);return r}async createTransferTransaction(e){if(!e.destination)throw new Error("WarpMultiversxExecutor: createTransfer - destination not set");let t=(0,N.getWarpWalletAddressFromConfig)(this.config,e.chain.name);if(!t)throw new Error("WarpMultiversxExecutor: createTransfer - user address not set");let r=A.Address.newFromBech32(t),n=new A.TransactionsFactoryConfig({chainID:e.chain.chainId}),i=e.data?Buffer.from(this.serializer.stringToTyped(e.data).valueOf()):null,o=e.transfers.length===1&&e.transfers[0].identifier===this.chain.nativeToken?.identifier,c=(o?e.transfers[0].amount:0n)+e.value;return await new A.TransferTransactionsFactory({config:n}).createTransactionForTransfer(r,{receiver:A.Address.newFromBech32(e.destination),nativeAmount:c,tokenTransfers:o?[]:this.toTokenTransfers(e.transfers),data:i?new Uint8Array(i):void 0})}async createContractCallTransaction(e){if(!e.destination)throw new Error("WarpMultiversxExecutor: createContractCall - destination not set");let t=(0,N.getWarpWalletAddressFromConfig)(this.config,e.chain.name);if(!t)throw new Error("WarpMultiversxExecutor: createContractCall - user address not set");let r=(0,N.getWarpActionByIndex)(e.warp,e.action),n=A.Address.newFromBech32(t),i=e.args.map(l=>this.serializer.stringToTyped(l)),o=new A.TransactionsFactoryConfig({chainID:e.chain.chainId});return new A.SmartContractTransactionsFactory({config:o}).createTransactionForExecute(n,{contract:A.Address.newFromBech32(e.destination),function:"func"in r&&r.func||"",gasLimit:"gasLimit"in r?BigInt(r.gasLimit||0):0n,arguments:i,tokenTransfers:this.toTokenTransfers(e.transfers),nativeTransferAmount:e.value})}async executeQuery(e){if(!e.destination)throw new Error("WarpMultiversxExecutor: executeQuery - destination not set");let t=(0,N.getWarpActionByIndex)(e.warp,e.action);if(t.type!=="query")throw new Error(`WarpMultiversxExecutor: Invalid action type for executeQuery: ${t.type}`);let r=await this.abi.getAbiForAction(t),n=e.args.map(v=>this.serializer.stringToTyped(v)),i=C(e.chain,this.config.env,this.config),o=A.Address.newFromBech32(e.destination),l=i.createSmartContractController(r),c=l.createQuery({contract:o,function:t.func||"",arguments:n}),f=await l.runQuery(c),g=f.returnCode==="ok",d=new A.ArgSerializer,T=r.getEndpoint(f.function||t.func||""),b=(f.returnDataParts||[]).map(v=>Buffer.from(v)),y=d.buffersToValues(b,T.output),{values:x,output:P}=await this.output.extractQueryOutput(e.warp,y,e.action,e.resolvedInputs),U=(0,N.getNextInfo)(this.config,[],e.warp,e.action,P),K=e.resolvedInputs.find(v=>v.input.position==="receiver"||v.input.position==="destination")?.value||e.destination,D=(0,N.extractResolvedInputValues)(e.resolvedInputs);return{status:g?"success":"error",warp:e.warp,action:e.action,user:(0,N.getWarpWalletAddressFromConfig)(this.config,e.chain.name),txHash:null,tx:null,next:U,values:x,output:{...P,_DATA:y},messages:(0,N.applyOutputToMessages)(e.warp,P,this.config),destination:K,resolvedInputs:D}}toTokenTransfers(e){return e.map(t=>t.identifier===this.chain.nativeToken.identifier?{...t,identifier:pt}:t).map(t=>{let n=new A.TokenComputer().extractNonceFromExtendedIdentifier(t.identifier);return new A.TokenTransfer({token:new A.Token({identifier:t.identifier,nonce:BigInt(n||0)}),amount:t.amount})})}};var ue=class{constructor(e,t){this.chain=e;this.config=t}getExplorers(){let e=Pe[this.chain];if(!e)return["multiversx_explorer"];let t=e[this.config.env];return t||["multiversx_explorer"]}getPrimaryExplorer(){return this.getExplorers()[0]}getExplorerUrlByName(e){let t=this.config.preferences?.explorers?.[this.chain];if(t&&!e){let i=$[t];if(i)return i}if(e){let i=$[e];if(i)return i}let r=this.getPrimaryExplorer();return $[r]||$[r]}getAccountUrl(e,t){return`${this.getExplorerUrlByName(t)}/accounts/${e}`}getTransactionUrl(e,t){return`${this.getExplorerUrlByName(t)}/transactions/${e}`}getBlockUrl(e,t){return`${this.getExplorerUrlByName(t)}/blocks/${e}`}getAssetUrl(e,t){return`${this.getExplorerUrlByName(t)}/tokens/${e}`}getContractUrl(e,t){return`${this.getExplorerUrlByName(t)}/accounts/${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(n=>{let i=$[n];i&&(r[n]=`${i}/accounts/${e}`)}),r}getTransactionUrls(e){let t=this.getAllExplorers(),r={};return t.forEach(n=>{let i=$[n];i&&(r[n]=`${i}/transactions/${e}`)}),r}};var m=require("@multiversx/sdk-core"),V=require("@vleap/warps");var Be={buildInfo:{rustc:{version:"1.86.0",commitHash:"05f9846f893b09a1be1fc8560e33fc3c815cfecb",commitDate:"2025-03-31",channel:"Stable",short:"rustc 1.86.0 (05f9846f8 2025-03-31)"},contractCrate:{name:"registry",version:"0.0.1"},framework:{name:"multiversx-sc",version:"0.51.1"}},name:"RegistryContract",constructor:{inputs:[{name:"unit_price",type:"BigUint"},{name:"vault",type:"Address"}],outputs:[]},upgradeConstructor:{inputs:[],outputs:[]},endpoints:[{name:"registerWarp",mutability:"mutable",payableInTokens:["EGLD"],inputs:[{name:"hash",type:"bytes"},{name:"alias_opt",type:"optional<bytes>",multi_arg:!0},{name:"brand_opt",type:"optional<bytes>",multi_arg:!0}],outputs:[],allow_multiple_var_args:!0},{name:"unregisterWarp",mutability:"mutable",inputs:[{name:"warp",type:"bytes"}],outputs:[]},{name:"upgradeWarp",mutability:"mutable",payableInTokens:["EGLD"],inputs:[{name:"alias",type:"bytes"},{name:"new_warp",type:"bytes"},{name:"brand_opt",type:"optional<bytes>",multi_arg:!0}],outputs:[]},{name:"setWarpAlias",mutability:"mutable",payableInTokens:["EGLD"],inputs:[{name:"hash",type:"bytes"},{name:"alias",type:"bytes"}],outputs:[]},{name:"forceRemoveAlias",mutability:"mutable",inputs:[{name:"hash",type:"bytes"}],outputs:[]},{name:"verifyWarp",mutability:"mutable",inputs:[{name:"warp",type:"bytes"}],outputs:[]},{name:"transferOwnership",mutability:"mutable",inputs:[{name:"warp",type:"bytes"},{name:"new_owner",type:"Address"}],outputs:[]},{name:"getUserWarps",mutability:"readonly",inputs:[{name:"address",type:"Address"}],outputs:[{type:"variadic<InfoView>",multi_result:!0}]},{name:"getInfoByAlias",mutability:"readonly",inputs:[{name:"alias",type:"bytes"}],outputs:[{type:"InfoView"}]},{name:"getInfoByHash",mutability:"readonly",inputs:[{name:"hash",type:"bytes"}],outputs:[{type:"InfoView"}]},{name:"setVault",onlyOwner:!0,mutability:"mutable",inputs:[{name:"vault",type:"Address"}],outputs:[]},{name:"setUnitPrice",onlyOwner:!0,mutability:"mutable",inputs:[{name:"amount",type:"BigUint"}],outputs:[]},{name:"addAdmin",onlyOwner:!0,mutability:"mutable",inputs:[{name:"address",type:"Address"}],outputs:[]},{name:"removeAdmin",onlyOwner:!0,mutability:"mutable",inputs:[{name:"address",type:"Address"}],outputs:[]},{name:"getConfig",mutability:"readonly",inputs:[],outputs:[{type:"ConfigView"}]},{name:"registerBrand",mutability:"mutable",payableInTokens:["EGLD"],inputs:[{name:"hash",type:"bytes"}],outputs:[]},{name:"brandWarp",mutability:"mutable",payableInTokens:["EGLD"],inputs:[{name:"warp",type:"bytes"},{name:"brand",type:"bytes"}],outputs:[]},{name:"getUserBrands",mutability:"readonly",inputs:[{name:"user",type:"Address"}],outputs:[{type:"variadic<bytes>",multi_result:!0}]}],events:[{identifier:"warpRegistered",inputs:[{name:"hash",type:"bytes",indexed:!0},{name:"alias",type:"bytes",indexed:!0},{name:"trust",type:"bytes",indexed:!0}]},{identifier:"warpUnregistered",inputs:[{name:"hash",type:"bytes",indexed:!0}]},{identifier:"warpUpgraded",inputs:[{name:"alias",type:"bytes",indexed:!0},{name:"new_warp",type:"bytes",indexed:!0},{name:"trust",type:"bytes",indexed:!0}]},{identifier:"warpVerified",inputs:[{name:"hash",type:"bytes",indexed:!0}]},{identifier:"aliasUpdated",inputs:[{name:"hash",type:"bytes",indexed:!0},{name:"alias",type:"bytes",indexed:!0}]},{identifier:"ownershipTransferred",inputs:[{name:"warp",type:"bytes",indexed:!0},{name:"old_owner",type:"Address",indexed:!0},{name:"new_owner",type:"Address",indexed:!0}]}],esdtAttributes:[],hasCallback:!1,types:{ConfigView:{type:"struct",fields:[{name:"unit_price",type:"BigUint"},{name:"admins",type:"List<Address>"}]},InfoView:{type:"struct",fields:[{name:"hash",type:"bytes"},{name:"alias",type:"Option<bytes>"},{name:"trust",type:"bytes"},{name:"owner",type:"Address"},{name:"created_at",type:"u64"},{name:"upgraded_at",type:"u64"},{name:"brand",type:"Option<bytes>"},{name:"upgrade",type:"Option<bytes>"}]}}};var S=s=>{if(s==="devnet")return"erd1qqqqqqqqqqqqqpgqje2f99vr6r7sk54thg03c9suzcvwr4nfl3tsfkdl36";if(s==="testnet")throw new Error("Multiversx testnet is not supported");return"erd1qqqqqqqqqqqqqpgq3mrpj3u6q7tejv6d7eqhnyd27n9v5c5tl3ts08mffe"};var me=s=>({hash:s.hash.toString("hex"),alias:s.alias?.toString()||null,trust:s.trust.toString(),owner:s.owner.toString(),createdAt:s.created_at.toNumber(),upgradedAt:s.upgraded_at?.toNumber(),brand:s.brand?.toString("hex")||null,upgrade:s.upgrade?.toString("hex")||null}),Ne=s=>({unitPrice:BigInt(s.unit_price.toString()),admins:s.admins.map(e=>e.toBech32())});var de=class{constructor(e,t){this.config=e;this.chain=t;this.cache=new V.WarpCache(e.cache?.type),this.registryConfig={unitPrice:BigInt(0),admins:[]},this.userWallet=(0,V.getWarpWalletAddressFromConfig)(this.config,this.chain.name)}async init(){await this.loadRegistryConfigs()}getRegistryConfig(){return this.registryConfig}async createWarpRegisterTransaction(e,t,r){if(this.registryConfig.unitPrice===BigInt(0))throw new Error("WarpRegistry: config not loaded. forgot to call init()?");if(!this.userWallet)throw new Error("WarpRegistry: user address not set");let n=m.Address.newFromBech32(this.userWallet),i=()=>this.isCurrentUserAdmin()?BigInt(0):t&&r?this.registryConfig.unitPrice*BigInt(3):t?this.registryConfig.unitPrice*BigInt(2):this.registryConfig.unitPrice,o=()=>t&&r?[m.BytesValue.fromHex(e),m.BytesValue.fromUTF8(t),m.BytesValue.fromHex(r)]:t?[m.BytesValue.fromHex(e),m.BytesValue.fromUTF8(t)]:[m.BytesValue.fromHex(e)];return await this.getFactory().createTransactionForExecute(n,{contract:m.Address.newFromBech32(S(this.config.env)),function:"registerWarp",gasLimit:BigInt(1e7),nativeTransferAmount:i(),arguments:o()})}async createWarpUnregisterTransaction(e){if(!this.userWallet)throw new Error("WarpRegistry: user address not set");let t=m.Address.newFromBech32(this.userWallet);return await this.getFactory().createTransactionForExecute(t,{contract:m.Address.newFromBech32(S(this.config.env)),function:"unregisterWarp",gasLimit:BigInt(1e7),arguments:[m.BytesValue.fromHex(e)]})}async createWarpUpgradeTransaction(e,t,r){if(this.registryConfig.unitPrice===BigInt(0))throw new Error("WarpRegistry: config not loaded. forgot to call init()?");if(!this.userWallet)throw new Error("WarpRegistry: user address not set");let n=m.Address.newFromBech32(this.userWallet);return await this.getFactory().createTransactionForExecute(n,{contract:m.Address.newFromBech32(S(this.config.env)),function:"upgradeWarp",gasLimit:BigInt(1e7),nativeTransferAmount:this.isCurrentUserAdmin()?void 0:this.registryConfig.unitPrice,arguments:r?[m.BytesValue.fromUTF8(e),m.BytesValue.fromHex(t),m.BytesValue.fromHex(r)]:[m.BytesValue.fromUTF8(e),m.BytesValue.fromHex(t)]})}async createWarpAliasSetTransaction(e,t){if(!this.userWallet)throw new Error("WarpRegistry: user address not set");let r=m.Address.newFromBech32(this.userWallet);return await this.getFactory().createTransactionForExecute(r,{contract:m.Address.newFromBech32(S(this.config.env)),function:"setWarpAlias",gasLimit:BigInt(1e7),nativeTransferAmount:this.isCurrentUserAdmin()?void 0:this.registryConfig.unitPrice,arguments:[m.BytesValue.fromHex(e),m.BytesValue.fromUTF8(t)]})}async createWarpVerifyTransaction(e){if(!this.userWallet)throw new Error("WarpRegistry: user address not set");let t=m.Address.newFromBech32(this.userWallet);return await this.getFactory().createTransactionForExecute(t,{contract:m.Address.newFromBech32(S(this.config.env)),function:"verifyWarp",gasLimit:BigInt(1e7),arguments:[m.BytesValue.fromHex(e)]})}async createWarpTransferOwnershipTransaction(e,t){if(!this.userWallet)throw new Error("WarpRegistry: user address not set");let r=m.Address.newFromBech32(this.userWallet);return await this.getFactory().createTransactionForExecute(r,{contract:m.Address.newFromBech32(S(this.config.env)),function:"transferOwnership",gasLimit:BigInt(1e7),arguments:[m.BytesValue.fromHex(e),new m.AddressValue(new m.Address(t))]})}async createBrandRegisterTransaction(e){if(this.registryConfig.unitPrice===BigInt(0))throw new Error("WarpRegistry: config not loaded. forgot to call init()?");if(!this.userWallet)throw new Error("WarpRegistry: user address not set");let t=m.Address.newFromBech32(this.userWallet);return await this.getFactory().createTransactionForExecute(t,{contract:m.Address.newFromBech32(S(this.config.env)),function:"registerBrand",gasLimit:BigInt(1e7),nativeTransferAmount:this.isCurrentUserAdmin()?void 0:this.registryConfig.unitPrice,arguments:[m.BytesValue.fromHex(e)]})}async createWarpBrandingTransaction(e,t){if(!this.userWallet)throw new Error("WarpRegistry: user address not set");let r=m.Address.newFromBech32(this.userWallet);return await this.getFactory().createTransactionForExecute(r,{contract:m.Address.newFromBech32(S(this.config.env)),function:"brandWarp",gasLimit:BigInt(1e7),nativeTransferAmount:this.isCurrentUserAdmin()?void 0:this.registryConfig.unitPrice,arguments:[m.BytesValue.fromHex(e),m.BytesValue.fromHex(t)]})}async getInfoByAlias(e,t){try{let r=V.WarpCacheKey.RegistryInfo(this.config.env,e),n=t?this.cache.get(r):null;if(n)return V.WarpLogger.info(`WarpRegistry (getInfoByAlias): RegistryInfo found in cache: ${e}`),n;let i=m.Address.newFromBech32(S(this.config.env)),o=this.getController(),l=o.createQuery({contract:i,function:"getInfoByAlias",arguments:[m.BytesValue.fromUTF8(e)]}),c=await o.runQuery(l),[f]=o.parseQueryResponse(c),g=f?me(f):null,d=g?.brand?await this.fetchBrand(g.brand):null;return t&&t.ttl&&this.cache.set(r,{registryInfo:g,brand:d},t.ttl),{registryInfo:g,brand:d}}catch{return{registryInfo:null,brand:null}}}async getInfoByHash(e,t){try{let r=V.WarpCacheKey.RegistryInfo(this.config.env,e);if(t){let d=this.cache.get(r);if(d)return V.WarpLogger.info(`WarpRegistry (getInfoByHash): RegistryInfo found in cache: ${e}`),d}let n=m.Address.newFromBech32(S(this.config.env)),i=this.getController(),o=i.createQuery({contract:n,function:"getInfoByHash",arguments:[m.BytesValue.fromHex(e)]}),l=await i.runQuery(o),[c]=i.parseQueryResponse(l),f=c?me(c):null,g=f?.brand?await this.fetchBrand(f.brand):null;return t&&t.ttl&&this.cache.set(r,{registryInfo:f,brand:g},t.ttl),{registryInfo:f,brand:g}}catch{return{registryInfo:null,brand:null}}}async getUserWarpRegistryInfos(e){try{let t=e||this.userWallet;if(!t)throw new Error("WarpRegistry: user address not set");let r=m.Address.newFromBech32(S(this.config.env)),n=this.getController(),i=n.createQuery({contract:r,function:"getUserWarps",arguments:[new m.AddressValue(new m.Address(t))]}),o=await n.runQuery(i),[l]=n.parseQueryResponse(o);return l.map(me)}catch{return[]}}async getUserBrands(e){try{let t=e||this.userWallet;if(!t)throw new Error("WarpRegistry: user address not set");let r=m.Address.newFromBech32(S(this.config.env)),n=this.getController(),i=n.createQuery({contract:r,function:"getUserBrands",arguments:[new m.AddressValue(new m.Address(t))]}),o=await n.runQuery(i),[l]=n.parseQueryResponse(o),c=l.map(d=>d.toString("hex")),f={ttl:365*24*60*60};return(await Promise.all(c.map(d=>this.fetchBrand(d,f)))).filter(d=>d!==null)}catch{return[]}}async fetchBrand(e,t){let r=V.WarpCacheKey.Brand(this.config.env,e),n=t?this.cache.get(r):null;if(n)return V.WarpLogger.info(`WarpRegistry (fetchBrand): Brand found in cache: ${e}`),n;let o=C(this.chain,this.config.env,this.config).createNetworkProvider();try{let l=await o.getTransaction(e),c=JSON.parse(l.data.toString());return c.meta={query:null,chain:this.chain.name,identifier:(0,V.createWarpIdentifier)(this.chain.name,"hash",e),hash:l.hash,creator:l.sender.toBech32(),createdAt:new Date(l.timestamp*1e3).toISOString()},t&&t.ttl&&this.cache.set(r,c,t.ttl),c}catch{return null}}async loadRegistryConfigs(){let e=m.Address.newFromBech32(S(this.config.env)),t=this.getController(),[r]=await t.query({contract:e,function:"getConfig",arguments:[]}),n=r?Ne(r):null;this.registryConfig=n||{unitPrice:BigInt(0),admins:[]}}getFactory(){let e=new m.TransactionsFactoryConfig({chainID:this.chain.chainId}),t=m.AbiRegistry.create(Be);return new m.SmartContractTransactionsFactory({config:e,abi:t})}getController(){let e=C(this.chain,this.config.env,this.config),t=m.AbiRegistry.create(Be);return e.createSmartContractController(t)}isCurrentUserAdmin(){return!!this.userWallet&&this.registryConfig.admins.includes(this.userWallet)}};var Xe=require("@multiversx/sdk-core"),X=require("@vleap/warps");var G=require("@multiversx/sdk-core"),we=require("@vleap/warps"),he=class he{constructor(e,t){this.config=e;this.chain=t;this.account=null}async getAddress(){let e=(0,we.getWarpWalletAddressFromConfig)(this.config,this.chain.name);if(e)return e;try{return this.getAccount().address.toBech32()}catch{return null}}async getPublicKey(){try{return this.getAccount().publicKey.hex()}catch{return null}}async signTransaction(e){return await this.getAccount().signTransaction(e),e}async signMessage(e){let t=this.getAccount(),r=new TextEncoder().encode(e),n=await t.signMessage(new G.Message({data:r}));return Buffer.from(n).toString("hex")}getAccountInstance(){return this.getAccount()}create(e){let i=G.Mnemonic.fromString(e).deriveKey(0).generatePublicKey().toAddress(this.chain.addressHrp).toBech32();return{provider:he.PROVIDER_NAME,address:i,privateKey:null,mnemonic:e}}generate(){let e=G.Mnemonic.generate(),t=e.toString(),i=e.deriveKey(0).generatePublicKey().toAddress(this.chain.addressHrp).toBech32();return{provider:he.PROVIDER_NAME,address:i,privateKey:null,mnemonic:t}}getAccount(){if(this.account)return this.account;let e=(0,we.getWarpWalletMnemonicFromConfig)(this.config,this.chain.name);if(!e)throw new Error("No mnemonic provided");let r=G.Mnemonic.fromString(e).deriveKey(0);return this.account=new G.Account(r),this.account}};he.PROVIDER_NAME="mnemonic";var ee=he;var F=require("@multiversx/sdk-core"),We=require("@vleap/warps"),ge=class ge{constructor(e,t){this.config=e;this.chain=t;this.account=null}async getAddress(){let e=(0,We.getWarpWalletAddressFromConfig)(this.config,this.chain.name);if(e)return e;try{return this.getAccount().address.toBech32()}catch{return null}}async getPublicKey(){try{return this.getAccount().publicKey.hex()}catch{return null}}async signTransaction(e){return await this.getAccount().signTransaction(e),e}async signMessage(e){let t=this.getAccount(),r=new TextEncoder().encode(e),n=await t.signMessage(new F.Message({data:r}));return Buffer.from(n).toString("hex")}getAccountInstance(){return this.getAccount()}create(e){let r=F.Mnemonic.fromString(e).deriveKey(0),n=r.hex(),o=r.generatePublicKey().toAddress(this.chain.addressHrp).toBech32();return{provider:ge.PROVIDER_NAME,address:o,privateKey:n,mnemonic:null}}generate(){let e=F.UserSecretKey.generate(),t=e.hex(),n=e.generatePublicKey().toAddress(this.chain.addressHrp).toBech32();return{provider:ge.PROVIDER_NAME,address:n,privateKey:t,mnemonic:null}}getAccount(){if(this.account)return this.account;let e=(0,We.getWarpWalletPrivateKeyFromConfig)(this.config,this.chain.name);if(!e)throw new Error("No private key provided");let r=e.startsWith("-----")?F.UserSecretKey.fromPem(e):F.UserSecretKey.fromString(e);return this.account=new F.Account(r),this.account}};ge.PROVIDER_NAME="privateKey";var te=ge;var Te=require("@vleap/warps"),re=class{constructor(e,t){this.config=e;this.chain=t}async getAddress(){return(0,Te.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}`)}create(e){let t=(0,Te.getWarpWalletAddressFromConfig)(this.config,this.chain.name);throw new Error(`Wallet can not be used for signing: ${t}`)}generate(){let e=(0,Te.getWarpWalletAddressFromConfig)(this.config,this.chain.name);throw new Error(`Wallet can not be used for signing: ${e}`)}};var fe=class{constructor(e,t){this.config=e;this.chain=t;this.cachedAddress=null;this.cachedPublicKey=null;this.entry=C(t,e.env,e),this.cache=new X.WarpCache(e.cache?.type),this.walletProvider=this.createProvider(),this.initializeCache()}async signTransaction(e){if(!e||typeof e!="object")throw new Error("Invalid transaction object");if(!this.walletProvider)throw new Error("No wallet provider available");if(this.walletProvider instanceof re)throw new Error(`Wallet (${this.chain.name}) is read-only`);if(this.walletProvider instanceof te||this.walletProvider instanceof ee){let r=this.walletProvider.getAccountInstance();if(e.nonce===0n){let n=await this.entry.recallAccountNonce(r.address),i=this.cache.get(`nonce:${r.address.toBech32()}`)||0,o=BigInt(Math.max(i,Number(n)));e.nonce=o}}else if(e.nonce===0n&&this.cachedAddress){let r=Xe.Address.newFromBech32(this.cachedAddress),n=await this.entry.recallAccountNonce(r),i=this.cache.get(`nonce:${this.cachedAddress}`)||0,o=BigInt(Math.max(i,Number(n)));e.nonce=o}let t=await this.walletProvider.signTransaction(e);if(this.walletProvider instanceof te||this.walletProvider instanceof ee){let r=this.walletProvider.getAccountInstance(),n=Number(r.nonce)+1;this.cache.set(`nonce:${r.address.toBech32()}`,n,X.CacheTtl.OneMinute)}else if(this.cachedAddress){let r=e.nonce?Number(e.nonce):0;this.cache.set(`nonce:${this.cachedAddress}`,r+1,X.CacheTtl.OneMinute)}return t}async signTransactions(e){let t=[];for(let r of e)t.push(await this.signTransaction(r));return t}async signMessage(e){if(!this.walletProvider)throw new Error("No wallet provider available");if(this.walletProvider instanceof re)throw new Error(`Wallet (${this.chain.name}) is read-only`);return await this.walletProvider.signMessage(e)}async sendTransactions(e){return Promise.all(e.map(async t=>this.sendTransaction(t)))}async sendTransaction(e){if(!e||typeof e!="object")throw new Error("Invalid transaction object");if(!e.signature)throw new Error("Transaction must be signed before sending");return await this.entry.sendTransaction(e)}create(e,t){return this.createProviderForOperation(e).create(t)}generate(e){return this.createProviderForOperation(e).generate()}getAddress(){return this.cachedAddress}getPublicKey(){return this.cachedPublicKey}createProvider(){let e=this.config.user?.wallets?.[this.chain.name];return e?typeof e=="string"?new re(this.config,this.chain):this.createProviderForOperation(e.provider):null}initializeCache(){(0,X.initializeWalletCache)(this.walletProvider).then(e=>{this.cachedAddress=e.address,this.cachedPublicKey=e.publicKey})}createProviderForOperation(e){let r=this.config.walletProviders?.[this.chain.name]?.[e];if(r){let n=r(this.config,this.chain);if(!n)throw new Error(`Custom wallet provider factory returned null for ${e}`);return n}if(e==="privateKey")return new te(this.config,this.chain);if(e==="mnemonic")return new ee(this.config,this.chain);throw new Error(`Unsupported wallet provider for ${this.chain.name}: ${e}`)}};var ye=(s,e)=>(t,r)=>{let n=e[t.env],i=new Je.WarpTypeRegistry;return i.registerType("token",{stringToNative:o=>o,nativeToString:o=>`token:${o}`}),i.registerType("codemeta",{stringToNative:o=>o,nativeToString:o=>`codemeta:${o}`}),i.registerTypeAlias("list","vector"),{chainInfo:n,builder:()=>new ce(t,n),executor:new pe(t,n,i),output:new Q(t,n,i),serializer:new M({typeRegistry:i}),registry:new de(t,n),explorer:new ue(s,t),abiBuilder:()=>new O(t,n),brandBuilder:()=>new oe(t,n),dataLoader:new le(t,n),wallet:new fe(t,n)}};var ne=require("@vleap/warps");var Ce={chain:ne.WarpChainName.Multiversx,identifier:"EGLD",name:"eGold",symbol:"EGLD",decimals:18,logoUrl:"https://joai.ai/images/tokens/egld.svg"},Ve=ye(ne.WarpChainName.Multiversx,{mainnet:{name:ne.WarpChainName.Multiversx,displayName:"MultiversX",chainId:"1",blockTime:6e3,addressHrp:"erd",defaultApiUrl:"https://api.multiversx.com",logoUrl:"https://joai.ai/images/chains/multiversx.svg",nativeToken:Ce},testnet:{name:ne.WarpChainName.Multiversx,displayName:"MultiversX Testnet",chainId:"T",blockTime:6e3,addressHrp:"erd",defaultApiUrl:"https://testnet-api.multiversx.com",logoUrl:"https://joai.ai/images/chains/multiversx.svg",nativeToken:Ce},devnet:{name:ne.WarpChainName.Multiversx,displayName:"MultiversX Devnet",chainId:"D",blockTime:6e3,addressHrp:"erd",defaultApiUrl:"https://devnet-api.multiversx.com",logoUrl:"https://joai.ai/images/chains/multiversx.svg",nativeToken:Ce}});var Ae=require("@vleap/warps");var Ye={chain:Ae.WarpChainName.Vibechain,identifier:"VIBE",name:"VIBE",symbol:"VIBE",decimals:18,logoUrl:"https://joai.ai/images/tokens/vibe.svg"},Ue={name:Ae.WarpChainName.Vibechain,displayName:"VibeChain",chainId:"V",blockTime:600,addressHrp:"vibe",defaultApiUrl:"https://vibeox-api.multiversx.com",logoUrl:"https://joai.ai/images/chains/vibechain.svg",nativeToken:Ye},ke=ye(Ae.WarpChainName.Vibechain,{mainnet:Ue,testnet:Ue,devnet:Ue});var mt=()=>[Ve,ke];var R=require("@vleap/warps");var dt=s=>new R.WarpSerializer().nativeToString(w.Token,s),ht=s=>new R.WarpSerializer().nativeToString(w.CodeMeta,s),gt=(s,e)=>{if(e===null)return w.Optional+R.WarpConstants.ArgParamsSeparator;let t=s(e),r=t.indexOf(R.WarpConstants.ArgParamsSeparator),n=t.substring(0,r),i=t.substring(r+1);return w.Optional+R.WarpConstants.ArgParamsSeparator+n+R.WarpConstants.ArgParamsSeparator+i},ft=s=>new R.WarpSerializer().nativeToString(w.List,s);var p=require("@multiversx/sdk-core"),yt=(s,e)=>s?p.OptionValue.newProvided(s):e?p.OptionValue.newMissingTyped(e):p.OptionValue.newMissing(),vt=(s,e)=>s?new p.OptionalValue(s.getType(),s):e?new p.OptionalValue(e):p.OptionalValue.newMissing(),wt=s=>{if(s.length===0)throw new Error("Cannot create a list from an empty array");let e=s[0].getType();return new p.List(e,s)},Wt=s=>p.VariadicValue.fromItems(...s),Tt=s=>{let e=s.map(t=>t.getType());return new p.CompositeValue(new p.CompositeType(...e),s)},Ct=s=>p.StringValue.fromUTF8(s),At=s=>new p.U8Value(s),xt=s=>new p.U16Value(s),Et=s=>new p.U32Value(s),bt=s=>new p.U64Value(s),It=s=>new p.BigUIntValue(BigInt(s)),St=s=>new p.BooleanValue(s),Pt=s=>new p.AddressValue(p.Address.newFromBech32(s)),Bt=s=>new p.TokenIdentifierValue(s),Nt=s=>p.BytesValue.fromHex(s),Vt=s=>new p.Struct(new p.StructType("EsdtTokenPayment",[new p.FieldDefinition("token_identifier","",new p.TokenIdentifierType),new p.FieldDefinition("token_nonce","",new p.U64Type),new p.FieldDefinition("amount","",new p.BigUIntType)]),[new p.Field(new p.TokenIdentifierValue(s.token.identifier),"token_identifier"),new p.Field(new p.U64Value(BigInt(s.token.nonce)),"token_nonce"),new p.Field(new p.BigUIntValue(BigInt(s.amount)),"amount")]),Ut=s=>new p.CodeMetadataValue(p.CodeMetadata.newFromBytes(Uint8Array.from(Buffer.from(s,"hex")))),kt=()=>new p.NothingValue;0&&(module.exports={ExplorerUrls,KnownTokens,MultiversxAdapter,MultiversxExplorers,MultiversxExplorersConfig,NativeTokenEgld,NativeTokenVibe,VibechainAdapter,VibechainExplorers,WarpMultiversxAbiBuilder,WarpMultiversxBrandBuilder,WarpMultiversxBuilder,WarpMultiversxConstants,WarpMultiversxContractLoader,WarpMultiversxDataLoader,WarpMultiversxExecutor,WarpMultiversxExplorer,WarpMultiversxInputTypes,WarpMultiversxOutput,WarpMultiversxRegistry,WarpMultiversxSerializer,WarpMultiversxWallet,address_value,asset_value,biguint_value,boolean_value,codemeta,codemeta_value,composite_value,createMultiversxAdapter,findKnownTokenById,getAllMultiversxAdapters,getAllMultiversxChainNames,getKnownTokensForChain,getMultiversxEntrypoint,getMultiversxRegistryAddress,getNormalizedTokenIdentifier,hex_value,isNativeToken,list,list_value,nothing_value,option_value,optional,optional_value,string_value,toTypedConfigInfo,toTypedRegistryInfo,token,token_value,u16_value,u32_value,u64_value,u8_value,variadic_value});
1
+ "use strict";var tt=Object.create;var Te=Object.defineProperty;var rt=Object.getOwnPropertyDescriptor;var nt=Object.getOwnPropertyNames;var at=Object.getPrototypeOf,it=Object.prototype.hasOwnProperty;var st=(s,e)=>{for(var t in e)Te(s,t,{get:e[t],enumerable:!0})},Fe=(s,e,t,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of nt(e))!it.call(s,n)&&n!==t&&Te(s,n,{get:()=>e[n],enumerable:!(r=rt(e,n))||r.enumerable});return s};var ot=(s,e,t)=>(t=s!=null?tt(at(s)):{},Fe(e||!s||!s.__esModule?Te(t,"default",{value:s,enumerable:!0}):t,s)),ct=s=>Fe(Te({},"__esModule",{value:!0}),s);var Rt={};st(Rt,{ExplorerUrls:()=>H,KnownTokens:()=>Pe,MultiversxAdapter:()=>Ve,MultiversxExplorers:()=>je,MultiversxExplorersConfig:()=>Se,NativeTokenEgld:()=>Ae,NativeTokenVibe:()=>Ze,VibechainAdapter:()=>ke,VibechainExplorers:()=>Qe,WarpMultiversxAbiBuilder:()=>R,WarpMultiversxBrandBuilder:()=>me,WarpMultiversxBuilder:()=>de,WarpMultiversxConstants:()=>ut,WarpMultiversxContractLoader:()=>ue,WarpMultiversxDataLoader:()=>he,WarpMultiversxExecutor:()=>ge,WarpMultiversxExplorer:()=>fe,WarpMultiversxInputTypes:()=>v,WarpMultiversxOutput:()=>J,WarpMultiversxRegistry:()=>We,WarpMultiversxSerializer:()=>D,WarpMultiversxWallet:()=>ve,address_value:()=>Vt,asset_value:()=>Ft,biguint_value:()=>Bt,boolean_value:()=>Nt,codemeta:()=>yt,codemeta_value:()=>Ot,composite_value:()=>xt,createMultiversxAdapter:()=>we,findKnownTokenById:()=>Ie,getAllMultiversxAdapters:()=>gt,getAllMultiversxChainNames:()=>lt,getKnownTokensForChain:()=>pt,getMultiversxEntrypoint:()=>C,getMultiversxRegistryAddress:()=>I,getNormalizedTokenIdentifier:()=>pe,hex_value:()=>kt,isNativeToken:()=>j,list:()=>vt,list_value:()=>Ct,nothing_value:()=>Mt,option_value:()=>wt,optional:()=>Wt,optional_value:()=>Tt,string_value:()=>Et,toTypedConfigInfo:()=>Ne,toTypedRegistryInfo:()=>ye,token:()=>ft,token_value:()=>Ut,u16_value:()=>Pt,u32_value:()=>It,u64_value:()=>St,u8_value:()=>bt,variadic_value:()=>At});module.exports=ct(Rt);var Ee=require("@vleap/warps"),lt=()=>[Ee.WarpChainName.Multiversx,Ee.WarpChainName.Vibechain];var Ye=require("@vleap/warps");var F=require("@multiversx/sdk-core"),E=require("@vleap/warps");var te=require("@multiversx/sdk-core"),Oe=require("@vleap/warps"),j=s=>!s.includes("-"),pe=s=>j(s)?`${s}-000000`:s,C=(s,e,t)=>{let r="warp-sdk",i=t?(0,Oe.getProviderConfig)(t,s.name,e,s.defaultApiUrl):{url:s.defaultApiUrl},o=i.url,c={headers:i.headers};return e==="devnet"?new te.DevnetEntrypoint({url:o,kind:"api",clientName:r,networkProviderConfig:c}):e==="testnet"?new te.TestnetEntrypoint({url:o,kind:"api",clientName:r,networkProviderConfig:c}):new te.MainnetEntrypoint({url:o,kind:"api",clientName:r,networkProviderConfig:c})};var be=require("@vleap/warps");var ue=class{constructor(e){this.config=e}async getContract(e,t){try{let i=await C(t,this.config.env,this.config).createNetworkProvider().doGetGeneric(`accounts/${e}`);return{address:e,owner:i.ownerAddress,verified:i.isVerified||!1}}catch(r){return be.WarpLogger.error("WarpContractLoader: getContract error",r),null}}async getVerificationInfo(e,t){try{let i=await C(t,this.config.env,this.config).createNetworkProvider().doGetGeneric(`accounts/${e}/verification`);return{codeHash:i.codeHash,abi:i.source.abi}}catch(r){return be.WarpLogger.error("WarpContractLoader: getVerificationInfo error",r),null}}};var R=class{constructor(e,t){this.config=e;this.chain=t;this.contractLoader=new ue(this.config),this.cache=new E.WarpCache(this.config.cache?.type)}async createInscriptionTransaction(e){let t=(0,E.getWarpWalletAddressFromConfig)(this.config,this.chain.name);if(!t)throw new Error("WarpBuilder: user address not set");let r=new F.TransactionsFactoryConfig({chainID:this.chain.chainId}),n=new F.TransferTransactionsFactory({config:r}),i=F.Address.newFromBech32(t),o={protocol:(0,E.getLatestProtocolIdentifier)("abi"),content:e},c=JSON.stringify(o),l=await n.createTransactionForTransfer(i,{receiver:i,nativeAmount:BigInt(0),data:Uint8Array.from(Buffer.from(c))});return l.gasLimit=l.gasLimit+BigInt(2e6),l}async createFromRaw(e){return JSON.parse(e)}async createFromTransaction(e){let t=await this.createFromRaw(e.data.toString());return t.meta={chain:this.chain.name,identifier:(0,E.createWarpIdentifier)(this.chain.name,"hash",e.hash),query:null,hash:e.hash,creator:e.sender.toBech32(),createdAt:new Date(e.timestamp*1e3).toISOString()},t}async createFromTransactionHash(e,t){let r=E.WarpCacheKey.WarpAbi(this.config.env,e);if(t){let o=this.cache.get(r);if(o)return E.WarpLogger.info(`WarpAbiBuilder (createFromTransactionHash): Warp abi found in cache: ${e}`),o}let i=C(this.chain,this.config.env,this.config).createNetworkProvider();try{let o=await i.getTransaction(e),c=await this.createFromTransaction(o);return t&&t.ttl&&c&&this.cache.set(r,c,t.ttl),c}catch(o){return E.WarpLogger.error("WarpAbiBuilder: Error creating from transaction hash",o),null}}async getAbiForAction(e){if(e.abi)return await this.fetchAbi(e);if(!e.address)throw new Error("WarpActionExecutor: Address not found");let t=await this.contractLoader.getVerificationInfo(e.address,this.chain);if(!t)throw new Error("WarpActionExecutor: Verification info not found");return F.AbiRegistry.create(t.abi)}async fetchAbi(e){if(!e.abi)throw new Error("WarpActionExecutor: ABI not found");if(e.abi.startsWith(E.WarpConstants.IdentifierType.Hash)){let t=e.abi.split(E.WarpConstants.ArgParamsSeparator)[1],r=await this.createFromTransactionHash(t);if(!r)throw new Error(`WarpActionExecutor: ABI not found for hash: ${e.abi}`);return F.AbiRegistry.create(r.content)}else{let r=await(await fetch(e.abi)).json();return F.AbiRegistry.create(r)}}};var Q=require("@multiversx/sdk-core"),_=require("@vleap/warps"),Me=require("buffer");var me=class{constructor(e,t){this.config=e;this.chain=t;this.core=new _.WarpBrandBuilder(e)}async createInscriptionTransaction(e){let t=(0,_.getWarpWalletAddressFromConfig)(this.config,this.chain.name);if(!t)throw new Error("BrandBuilder: user address not set");let r=new Q.TransactionsFactoryConfig({chainID:this.chain.chainId}),n=new Q.TransferTransactionsFactory({config:r}),i=Q.Address.newFromBech32(t),o=JSON.stringify(e);return await n.createTransactionForNativeTokenTransfer(i,{receiver:Q.Address.newFromBech32(t),nativeAmount:BigInt(0),data:Uint8Array.from(Me.Buffer.from(o))})}async createFromTransaction(e,t=!1){let r=await this.core.createFromRaw(e.data.toString(),t);return r.meta={query:null,chain:this.chain.name,identifier:(0,_.createWarpIdentifier)(this.chain.name,"hash",e.hash),hash:e.hash,creator:e.sender.toBech32(),createdAt:new Date(e.timestamp*1e3).toISOString()},r}async createFromTransactionHash(e){let r=C(this.chain,this.config.env,this.config).createNetworkProvider();try{let n=await r.getTransaction(e);return this.createFromTransaction(n)}catch(n){return _.WarpLogger.error("BrandBuilder: Error creating from transaction hash",n),null}}};var X=require("@multiversx/sdk-core"),B=require("@vleap/warps");var de=class extends B.WarpBuilder{constructor(t,r){super(t);this.config=t;this.chain=r;this.cache=new B.WarpCache(t.cache?.type),this.core=new B.WarpBuilder(t)}async createInscriptionTransaction(t){let r=(0,B.getWarpWalletAddressFromConfig)(this.config,this.chain.name);if(!r)throw new Error("WarpBuilder: user address not set");let n=new X.TransactionsFactoryConfig({chainID:this.chain.chainId}),i=new X.TransferTransactionsFactory({config:n}),o=X.Address.newFromBech32(r),c=JSON.stringify(t),l=await i.createTransactionForTransfer(o,{receiver:X.Address.newFromBech32(r),nativeAmount:BigInt(0),data:Uint8Array.from(Buffer.from(c))});return l.gasLimit=l.gasLimit+BigInt(2e6),l}async createFromTransaction(t,r=!1){let n=await this.core.createFromRaw(t.data.toString(),r);return n.meta={chain:this.chain.name,identifier:(0,B.createWarpIdentifier)(this.chain.name,"hash",t.hash),query:null,hash:t.hash,creator:t.sender.toBech32(),createdAt:new Date(t.timestamp*1e3).toISOString()},n}async createFromTransactionHash(t,r){let n=B.WarpCacheKey.Warp(this.config.env,t);if(r){let c=this.cache.get(n);if(c)return B.WarpLogger.info(`WarpBuilder (createFromTransactionHash): Warp found in cache: ${t}`),c}let o=C(this.chain,this.config.env,this.config).createNetworkProvider();try{let c=await o.getTransaction(t),l=await this.createFromTransaction(c);return r&&r.ttl&&l&&this.cache.set(n,l,r.ttl),l}catch(c){return B.WarpLogger.error("WarpBuilder: Error creating from transaction hash",c),null}}};var $=require("@multiversx/sdk-core"),re=require("@vleap/warps");var De=require("@vleap/warps"),Re=De.WarpChainName.Multiversx,Le=[{chain:Re,identifier:"EGLD",name:"eGold",symbol:"EGLD",decimals:18,logoUrl:"https://tools.multiversx.com/assets-cdn/tokens/EGLD-000000/icon.png"},{chain:Re,identifier:"EGLD-000000",name:"eGold",symbol:"EGLD",decimals:18,logoUrl:"https://tools.multiversx.com/assets-cdn/tokens/EGLD-000000/icon.png"}];var Ke=require("@vleap/warps"),P=Ke.WarpChainName.Multiversx,_e=[{chain:P,identifier:"EGLD",name:"eGold",symbol:"EGLD",decimals:18,logoUrl:"https://tools.multiversx.com/assets-cdn/tokens/EGLD-000000/icon.png"},{chain:P,identifier:"EGLD-000000",name:"eGold",symbol:"EGLD",decimals:18,logoUrl:"https://tools.multiversx.com/assets-cdn/tokens/EGLD-000000/icon.png"},{chain:P,identifier:"SEGLD-3ad2d0",name:"StakedEGLD",symbol:"SEGLD",decimals:18,logoUrl:"https://tools.multiversx.com/assets-cdn/tokens/SEGLD-3ad2d0/icon.png"},{chain:P,identifier:"HSEGLD-c13a4e",name:"HatomSEGLD",symbol:"HSEGLD",decimals:8,logoUrl:"https://tools.multiversx.com/assets-cdn/tokens/HSEGLD-c13a4e/icon.png"},{chain:P,identifier:"UTK-2f80e9",name:"xMoney UTK",symbol:"UTK",decimals:18,logoUrl:"https://tools.multiversx.com/assets-cdn/tokens/UTK-2f80e9/icon.png"},{chain:P,identifier:"USDC-c76f1f",name:"WrappedUSDC",symbol:"USDC",decimals:6,logoUrl:"https://tools.multiversx.com/assets-cdn/tokens/USDC-c76f1f/icon.png"},{chain:P,identifier:"WEGLD-bd4d79",name:"WrappedEGLD",symbol:"WEGLD",decimals:18,logoUrl:"https://tools.multiversx.com/assets-cdn/tokens/WEGLD-bd4d79/icon.png"},{chain:P,identifier:"HTM-f51d55",name:"Hatom",symbol:"HTM",decimals:18,logoUrl:"https://tools.multiversx.com/assets-cdn/tokens/HTM-f51d55/icon.png"},{chain:P,identifier:"MEX-455c57",name:"MEX",symbol:"MEX",decimals:18,logoUrl:"https://tools.multiversx.com/assets-cdn/tokens/MEX-455c57/icon.png"},{chain:P,identifier:"WTAO-4f5363",name:"WrappedTAO",symbol:"WTAO",decimals:9,logoUrl:"https://tools.multiversx.com/assets-cdn/tokens/WTAO-4f5363/icon.png"},{chain:P,identifier:"HEGLD-d61095",name:"HatomEGLD",symbol:"HEGLD",decimals:8,logoUrl:"https://tools.multiversx.com/assets-cdn/tokens/HEGLD-d61095/icon.png"},{chain:P,identifier:"WBTC-5349b3",name:"WrappedBTC",symbol:"WBTC",decimals:8,logoUrl:"https://tools.multiversx.com/assets-cdn/tokens/WBTC-5349b3/icon.png"},{chain:P,identifier:"WETH-b4ca29",name:"WrappedETH",symbol:"WETH",decimals:18,logoUrl:"https://tools.multiversx.com/assets-cdn/tokens/WETH-b4ca29/icon.png"},{chain:P,identifier:"USH-111e09",name:"HatomUSD",symbol:"USH",decimals:18,logoUrl:"https://tools.multiversx.com/assets-cdn/tokens/USH-111e09/icon.png"},{chain:P,identifier:"USDT-f8c08c",name:"WrappedUSDT",symbol:"USDT",decimals:6,logoUrl:"https://tools.multiversx.com/assets-cdn/tokens/USDT-f8c08c/icon.png"}];var He=require("@vleap/warps"),$e=He.WarpChainName.Multiversx,Ge=[{chain:$e,identifier:"EGLD",name:"eGold",symbol:"EGLD",decimals:18,logoUrl:"https://tools.multiversx.com/assets-cdn/tokens/EGLD-000000/icon.png"},{chain:$e,identifier:"EGLD-000000",name:"eGold",symbol:"EGLD",decimals:18,logoUrl:"https://tools.multiversx.com/assets-cdn/tokens/EGLD-000000/icon.png"}];var qe=require("@vleap/warps"),ze=qe.WarpChainName.Vibechain,Ce=[{chain:ze,identifier:"VIBE",name:"VIBE",symbol:"VIBE",decimals:18,logoUrl:"https://joai.ai/images/tokens/vibe.svg"},{chain:ze,identifier:"VIBE-000000",name:"VIBE",symbol:"VIBE",decimals:18,logoUrl:"https://joai.ai/images/tokens/vibe.svg"}];var Pe={multiversx:{mainnet:_e,testnet:Ge,devnet:Le},vibechain:{mainnet:Ce,testnet:Ce,devnet:Ce}},Ie=(s,e,t)=>(Pe[s]?.[e]||[]).find(n=>n.identifier===t)||null,pt=(s,e)=>Pe[s]?.[e]||[];var he=class{constructor(e,t){this.config=e;this.chain=t;this.cache=new re.WarpCache(e.cache?.type)}async getAccount(e){let r=await C(this.chain,this.config.env,this.config).createNetworkProvider().getAccount($.Address.newFromBech32(e));return{chain:this.chain.name,address:r.address.toBech32(),balance:r.balance}}async getAccountAssets(e){let t=C(this.chain,this.config.env,this.config).createNetworkProvider(),r=t.getAccount($.Address.newFromBech32(e)),n=t.getFungibleTokensOfAccount($.Address.newFromBech32(e)),[i,o]=await Promise.all([r,n]),c=i.balance>0?[{...this.chain.nativeToken,amount:i.balance}]:[];return c.push(...o.map(l=>({chain:this.chain.name,identifier:l.token.identifier,name:l.raw.name,symbol:l.raw.ticker,amount:l.amount,decimals:l.raw.decimals,logoUrl:l.raw.assets?.pngUrl||"",price:l.raw.price?Number(l.raw.price):void 0,supply:l.raw.supply?BigInt(l.raw.supply):void 0}))),c}async getAsset(e){let t=re.WarpCacheKey.Asset(this.config.env,this.chain.name,e),r=this.cache.get(t);if(r)return r;let n=Ie(this.chain.name,this.config.env,e);if(n)return{chain:this.chain.name,identifier:e,name:n.name,symbol:n.symbol,amount:0n,decimals:n.decimals,logoUrl:n.logoUrl};let i=new $.TokenComputer,o=j(e)?0n:i.extractNonceFromExtendedIdentifier(e),c=new $.Token({identifier:e,nonce:BigInt(o||0)}),l=i.isFungible(c),f=C(this.chain,this.config.env,this.config).createNetworkProvider(),g=pe(e),d=await f.doGetGeneric(`tokens/${g}`),T={chain:this.chain.name,identifier:c.identifier,name:d.name,symbol:d.ticker,amount:0n,decimals:d.decimals,logoUrl:d.assets?.pngUrl||null,price:d.price?Number(d.price):void 0,supply:d.supply?BigInt(d.supply):void 0};return this.cache.set(t,T,re.CacheTtl.OneHour),T}async getAction(e,t=!1){let r=C(this.chain,this.config.env,this.config),n=t?await r.awaitCompletedTransaction(e):await r.getTransaction(e);return{chain:this.chain.name,id:n.hash,receiver:n.receiver.toBech32(),sender:n.sender.toBech32(),value:n.value,function:n.function,status:this.toActionStatus(n),createdAt:this.toActionCreatedAt(n),error:n?.smartContractResults.map(i=>i.raw.returnMessage)[0]||null,tx:n}}async getAccountActions(e,t){let r=C(this.chain,this.config.env,this.config).createNetworkProvider(),n=`accounts/${e}/transactions`,i=new URLSearchParams,o=t?.size||25,c=t?.page||0;if(c>0){let f=c*o;i.append("from",f.toString())}return o!==25&&i.append("size",o.toString()),i.toString()&&(n+=`?${i.toString()}`),(await r.doGetGeneric(n)).map(f=>({chain:this.chain.name,id:f.txHash,receiver:f.receiver,sender:f.sender,value:f.value,function:f.function,status:this.toActionStatus(f),createdAt:this.toActionCreatedAt(f)}))}toActionStatus(e){return e.status.isSuccessful()?"success":e.status.isFailed()?"failed":"pending"}toActionCreatedAt(e){return new Date(e.timestamp||e.timestamp*1e3).toISOString()}};var A=require("@multiversx/sdk-core"),N=require("@vleap/warps");var ne=require("@multiversx/sdk-core"),w=require("@vleap/warps");var a=require("@multiversx/sdk-core"),Xe=require("@vleap/warps");var h={HttpProtocolPrefix:"http",IdentifierParamName:"warp",IdentifierParamSeparator:":",IdentifierChainDefault:"multiversx",IdentifierType:{Alias:"alias",Hash:"hash"},IdentifierAliasMarker:"@",Globals:{UserWallet:{Placeholder:"USER_WALLET",Accessor:s=>s.config.user?.wallets?.[s.adapter.chainInfo.name]},UserWalletPublicKey:{Placeholder:"USER_WALLET_PUBLICKEY",Accessor:s=>{if(!s.adapter.wallet)return null;try{return s.adapter.wallet.getPublicKey()||null}catch{return null}}},ChainApiUrl:{Placeholder:"CHAIN_API",Accessor:s=>s.adapter.chainInfo.defaultApiUrl},ChainAddressHrp:{Placeholder:"CHAIN_ADDRESS_HRP",Accessor:s=>s.adapter.chainInfo.addressHrp}},Vars:{Query:"query",Env:"env"},ArgParamsSeparator:":",ArgCompositeSeparator:"|",ArgListSeparator:",",ArgStructSeparator:";",Transform:{Prefix:"transform:"},Source:{UserWallet:"user:wallet"},Position:{Payload:"payload:"},Alerts:{TriggerEventPrefix:"event"}},u={Option:"option",Vector:"vector",Tuple:"tuple",Struct:"struct",String:"string",Uint8:"uint8",Uint16:"uint16",Uint32:"uint32",Uint64:"uint64",Uint128:"uint128",Uint256:"uint256",Biguint:"biguint",Bool:"bool",Address:"address",Asset:"asset",Hex:"hex"};var ut={Egld:{Identifier:"EGLD",EsdtIdentifier:"EGLD-000000",DisplayName:"eGold",Decimals:18}},v={Null:"null",Optional:"optional",List:"list",Token:"token",CodeMeta:"codemeta"},je=(r=>(r.MultiversxExplorer="multiversx_explorer",r.MultiversxExplorerDevnet="multiversx_explorer_devnet",r.MultiversxExplorerTestnet="multiversx_explorer_testnet",r))(je||{}),Qe=(r=>(r.VibechainExplorer="vibechain_explorer",r.VibechainExplorerDevnet="vibechain_explorer_devnet",r.VibechainExplorerTestnet="vibechain_explorer_testnet",r))(Qe||{}),Se={multiversx:{mainnet:["multiversx_explorer"],testnet:["multiversx_explorer_testnet"],devnet:["multiversx_explorer_devnet"]},vibechain:{mainnet:["vibechain_explorer"],testnet:["vibechain_explorer_testnet"],devnet:["vibechain_explorer_devnet"]}},H={multiversx_explorer:"https://explorer.multiversx.com",multiversx_explorer_devnet:"https://devnet-explorer.multiversx.com",multiversx_explorer_testnet:"https://testnet-explorer.multiversx.com",vibechain_explorer:"https://vibeox-explorer.multiversx.com",vibechain_explorer_devnet:"https://vibeox-explorer.multiversx.com",vibechain_explorer_testnet:"https://vibeox-explorer.multiversx.com"};var mt=new RegExp(`${h.ArgParamsSeparator}(.*)`),D=class{constructor(e){this.coreSerializer=new Xe.WarpSerializer(e)}typedToString(e){let t=e.getType();if(t.hasExactClass(a.OptionType.ClassName)||e.hasClassOrSuperclass(a.OptionValue.ClassName)){if(!e.isSet())return u.Option+h.ArgParamsSeparator+"null";let r=this.typedToString(e.getTypedValue());return u.Option+h.ArgParamsSeparator+r}if(t.hasExactClass(a.VariadicType.ClassName)||e.hasClassOrSuperclass(a.VariadicValue.ClassName)){let r=e.getItems();if(r.length===0){let g=this.typeToString(t.getFirstTypeParameter());return u.Vector+h.ArgParamsSeparator+g+h.ArgParamsSeparator}let n=r.map(g=>this.typedToString(g));if(n.every(g=>g.startsWith(u.Tuple)))return u.Vector+h.ArgParamsSeparator+n.join(",");let i=n[0],o=i.indexOf(h.ArgParamsSeparator),c=i.substring(0,o),l=n.map(g=>{let d=g.indexOf(h.ArgParamsSeparator);return g.substring(d+1)}),f=c.startsWith(u.Struct)?h.ArgStructSeparator:h.ArgListSeparator;return u.Vector+h.ArgParamsSeparator+c+h.ArgParamsSeparator+l.join(f)}if(t.hasExactClass(a.OptionalType.ClassName)||e.hasClassOrSuperclass(a.OptionalValue.ClassName)){if(!e.isSet())return v.Optional+h.ArgParamsSeparator+"null";let r=this.typedToString(e.getTypedValue());return v.Optional+h.ArgParamsSeparator+r}if(t.hasExactClass(a.ListType.ClassName)||e.hasClassOrSuperclass(a.List.ClassName)){let n=e.getItems().map(l=>this.typedToString(l));if(n.every(l=>l.startsWith(u.Tuple)))return v.List+h.ArgParamsSeparator+n.join(",");let o=n.map(l=>l.split(h.ArgParamsSeparator)[0])[0],c=n.map(l=>l.split(h.ArgParamsSeparator)[1]);return v.List+h.ArgParamsSeparator+o+h.ArgParamsSeparator+c.join(h.ArgListSeparator)}if(t.hasExactClass(a.CompositeType.ClassName)||e.hasClassOrSuperclass(a.CompositeValue.ClassName)){let n=e.getItems().map(i=>{let o=this.typedToString(i),c=o.indexOf(h.ArgParamsSeparator),l=o.substring(0,c),f=o.substring(c+1);return`${l},${f}`});return`${u.Tuple}(${n.join(",")})`}if(t.hasExactClass(a.BigUIntType.ClassName)||e.hasClassOrSuperclass(a.BigUIntValue.ClassName)||t.getName()==="BigUint")return u.Biguint+h.ArgParamsSeparator+BigInt(e.valueOf().toFixed());if(t.hasExactClass(a.U8Type.ClassName)||e.hasClassOrSuperclass(a.U8Value.ClassName))return u.Uint8+h.ArgParamsSeparator+e.valueOf().toNumber();if(t.hasExactClass(a.U16Type.ClassName)||e.hasClassOrSuperclass(a.U16Value.ClassName))return u.Uint16+h.ArgParamsSeparator+e.valueOf().toNumber();if(t.hasExactClass(a.U32Type.ClassName)||e.hasClassOrSuperclass(a.U32Value.ClassName))return u.Uint32+h.ArgParamsSeparator+e.valueOf().toNumber();if(t.hasExactClass(a.U64Type.ClassName)||e.hasClassOrSuperclass(a.U64Value.ClassName))return u.Uint64+h.ArgParamsSeparator+BigInt(e.valueOf().toFixed());if(t.hasExactClass(a.StringType.ClassName)||e.hasClassOrSuperclass(a.StringValue.ClassName))return u.String+h.ArgParamsSeparator+e.valueOf();if(t.hasExactClass(a.BooleanType.ClassName)||e.hasClassOrSuperclass(a.BooleanValue.ClassName))return u.Bool+h.ArgParamsSeparator+e.valueOf();if(t.hasExactClass(a.AddressType.ClassName)||e.hasClassOrSuperclass(a.AddressValue.ClassName))return u.Address+h.ArgParamsSeparator+e.valueOf().toBech32();if(t.hasExactClass(a.BytesType.ClassName)||e.hasClassOrSuperclass(a.BytesValue.ClassName))return u.Hex+h.ArgParamsSeparator+e.valueOf().toString("hex");if(t.getName()==="EsdtTokenPayment"){let r=e.getFieldValue("token_identifier").valueOf(),n=e.getFieldValue("token_nonce").valueOf(),i=e.getFieldValue("amount").valueOf(),c=new a.TokenComputer().computeExtendedIdentifier(new a.Token({identifier:r,nonce:BigInt(n)}));return u.Asset+h.ArgParamsSeparator+c+h.ArgCompositeSeparator+i}if(t.hasExactClass(a.StructType.ClassName)||e.hasClassOrSuperclass(a.Struct.ClassName)){let r=e,i=r.getType().getName(),o=r.getFields();if(o.length===0)return`${u.Struct}(${i})${h.ArgParamsSeparator}`;let c=o.map(l=>{let f=l.value.getType(),d=this.typedToString(l.value).split(h.ArgParamsSeparator),T=d.length>2?d.slice(2).join(h.ArgParamsSeparator):d[1]||"";return`(${l.name}${h.ArgParamsSeparator}${this.typeToString(f)})${T}`});return`${u.Struct}(${i})${h.ArgParamsSeparator}${c.join(h.ArgListSeparator)}`}if(t.hasExactClass(a.TokenIdentifierType.ClassName)||e.hasClassOrSuperclass(a.TokenIdentifierValue.ClassName))return v.Token+h.ArgParamsSeparator+e.valueOf();if(t.hasExactClass(a.CodeMetadataType.ClassName)||e.hasClassOrSuperclass(a.CodeMetadataValue.ClassName))return v.CodeMeta+h.ArgParamsSeparator+e.valueOf().toString();throw new Error(`WarpArgSerializer (typedToString): Unsupported input type: ${e.getClassName()}`)}typedToNative(e){let t=this.typedToString(e);return this.coreSerializer.stringToNative(t)}nativeToTyped(e,t){if(e.startsWith(u.Tuple))return this.stringToTyped(e+":");let r=this.coreSerializer.nativeToString(e,t);return this.stringToTyped(r)}nativeToType(e){if(e.startsWith(u.Tuple)){let t=e.match(/\(([^)]+)\)/)?.[1];if(!t)throw new Error(`Invalid tuple type format: ${e}`);let r=t.split(","),n=[];for(let i=0;i<r.length;i+=2)n.push(r[i]);return new a.CompositeType(...n.map(i=>this.nativeToType(i)))}if(e.startsWith(u.Struct)){let t=e.match(/\(([^)]+)\)/);if(!t)throw new Error("Struct type must include a name in the format struct(Name)");let r=t[1];return new a.StructType(r,[])}if(e===u.String)return new a.StringType;if(e===u.Uint8)return new a.U8Type;if(e===u.Uint16)return new a.U16Type;if(e===u.Uint32)return new a.U32Type;if(e===u.Uint64)return new a.U64Type;if(e===u.Biguint)return new a.BigUIntType;if(e===u.Bool)return new a.BooleanType;if(e===u.Address)return new a.AddressType;if(e===u.Hex)return new a.BytesType;if(e===u.Asset)return new a.StructType("EsdtTokenPayment",[new a.FieldDefinition("token_identifier","",new a.TokenIdentifierType),new a.FieldDefinition("token_nonce","",new a.U64Type),new a.FieldDefinition("amount","",new a.BigUIntType)]);if(e===v.Token)return new a.TokenIdentifierType;if(e===v.CodeMeta)return new a.CodeMetadataType;throw new Error(`WarpArgSerializer (nativeToType): Unsupported input type: ${e}`)}stringToTyped(e){let[t,r]=e.split(/:(.*)/,2);if(t===u.Option){let n=this.stringToTyped(r);return n instanceof a.NothingValue?a.OptionValue.newMissingTyped(n.getType()):a.OptionValue.newProvided(n)}if(t===u.Vector){let n=r.indexOf(h.ArgParamsSeparator),i=r.substring(0,n),o=r.substring(n+1);if(i.startsWith(u.Tuple)){let d=o.split(",").map(T=>this.stringToTyped(T));return new a.VariadicValue(new a.VariadicType(this.nativeToType(i)),d)}if(o.includes("tuple(")){let g=this.splitTupleStrings(o),d=g.map(x=>this.stringToTyped(x)),b=g[0].match(/^(tuple\([^)]+\))/),y=b?b[1]:"tuple";return new a.VariadicValue(new a.VariadicType(this.nativeToType(y)),d)}let c=i.startsWith(u.Struct)?h.ArgStructSeparator:h.ArgListSeparator,f=o.split(c).map(g=>this.stringToTyped(`${i}:${g}`));return new a.VariadicValue(new a.VariadicType(this.nativeToType(i)),f)}if(t.startsWith(u.Tuple)){let n=t.match(/\(([^)]+)\)/)?.[1];if(!n)throw new Error(`Invalid tuple format: ${t}`);let i=n.split(","),o=[];for(let l=0;l<i.length;l+=2){let f=i[l],g=i[l+1];o.push(this.stringToTyped(`${f}:${g}`))}let c=o.map(l=>l.getType());return new a.CompositeValue(new a.CompositeType(...c),o)}if(t.startsWith(u.Struct)){let n=t.match(/\(([^)]+)\)/),i=n?n[1]:"CustomStruct";if(!r)return new a.Struct(new a.StructType(i,[]),[]);let o=r.split(h.ArgListSeparator),c=[],l=[];return o.forEach(f=>{let g=f.match(new RegExp(`^\\(([^${h.ArgParamsSeparator}]+)${h.ArgParamsSeparator}([^)]+)\\)(.+)$`));if(g){let[,d,T,b]=g,y=this.stringToTyped(`${T}${h.ArgParamsSeparator}${b}`);c.push(new a.FieldDefinition(d,"",y.getType())),l.push(new a.Field(y,d))}}),new a.Struct(new a.StructType(i,c),l)}if(t===u.String)return r?a.StringValue.fromUTF8(r):new a.NothingValue;if(t===u.Uint8)return r?new a.U8Value(Number(r)):new a.NothingValue;if(t===u.Uint16)return r?new a.U16Value(Number(r)):new a.NothingValue;if(t===u.Uint32)return r?new a.U32Value(Number(r)):new a.NothingValue;if(t===u.Uint64)return r?new a.U64Value(BigInt(r)):new a.NothingValue;if(t===u.Biguint)return r?new a.BigUIntValue(BigInt(r)):new a.NothingValue;if(t===u.Bool)return r?new a.BooleanValue(typeof r=="boolean"?r:r==="true"):new a.NothingValue;if(t===u.Address)return r?new a.AddressValue(a.Address.newFromBech32(r)):new a.NothingValue;if(t===u.Hex)return r?a.BytesValue.fromHex(r):new a.NothingValue;if(t===u.Asset){let[n,i]=r.split(h.ArgCompositeSeparator),o=new a.TokenComputer,c=j(n)?pe(n):o.extractIdentifierFromExtendedIdentifier(n),l=j(n)?0n:o.extractNonceFromExtendedIdentifier(n);return new a.Struct(this.nativeToType("asset"),[new a.Field(new a.TokenIdentifierValue(c),"token_identifier"),new a.Field(new a.U64Value(BigInt(l)),"token_nonce"),new a.Field(new a.BigUIntValue(BigInt(i)),"amount")])}if(t===v.Null)return new a.NothingValue;if(t===v.Optional){let n=this.stringToTyped(r);return n instanceof a.NothingValue?a.OptionalValue.newMissing():new a.OptionalValue(n.getType(),n)}if(t===v.List){let[n,i]=r.split(mt,2),c=i.split(h.ArgListSeparator).map(l=>this.stringToTyped(n+h.ArgParamsSeparator+l));return new a.List(this.nativeToType(n),c)}if(t===v.Token)return r?new a.TokenIdentifierValue(r):new a.NothingValue;if(t===v.CodeMeta)return new a.CodeMetadataValue(a.CodeMetadata.newFromBytes(Uint8Array.from(Buffer.from(r,"hex"))));throw new Error(`WarpArgSerializer (stringToTyped): Unsupported input type: ${t}`)}splitTupleStrings(e){let t=[],r="",n=0;for(let i=0;i<e.length;i++){let o=e[i];if(o==="(")n++;else if(o===")")n--;else if(o===","&&n===0){t.push(r.trim()),r="";continue}r+=o}return r.trim()&&t.push(r.trim()),t}typeToString(e){if(e.hasExactClass(a.OptionType.ClassName))return u.Option+h.ArgParamsSeparator+this.typeToString(e.getFirstTypeParameter());if(e.hasExactClass(a.VariadicType.ClassName))return u.Vector+h.ArgParamsSeparator+this.typeToString(e.getFirstTypeParameter());if(e.hasExactClass(a.StringType.ClassName))return u.String;if(e.hasExactClass(a.U8Type.ClassName))return u.Uint8;if(e.hasExactClass(a.U16Type.ClassName))return u.Uint16;if(e.hasExactClass(a.U32Type.ClassName))return u.Uint32;if(e.hasExactClass(a.U64Type.ClassName))return u.Uint64;if(e.hasExactClass(a.BigUIntType.ClassName))return u.Biguint;if(e.hasExactClass(a.BooleanType.ClassName))return u.Bool;if(e.hasExactClass(a.AddressType.ClassName))return u.Address;if(e.hasExactClass(a.BytesType.ClassName))return u.Hex;if(e.hasExactClass(a.TokenIdentifierType.ClassName))return v.Token;if(e.hasExactClass(a.OptionalType.ClassName))return v.Optional+h.ArgParamsSeparator+this.typeToString(e.getFirstTypeParameter());if(e.hasExactClass(a.ListType.ClassName))return v.List+h.ArgParamsSeparator+this.typeToString(e.getFirstTypeParameter());if(e.hasExactClass(a.CodeMetadataType.ClassName))return v.CodeMeta;if(e.hasExactClass(a.StructType.ClassName)&&e.getClassName()==="EsdtTokenPayment")return u.Asset;if(e.hasExactClass(a.StructType.ClassName))return`${u.Struct}(${e.getName()})`;throw new Error(`WarpArgSerializer (typeToString): Unsupported input type: ${e.getClassName()}`)}};var J=class{constructor(e,t,r){this.config=e;this.chain=t;this.typeRegistry=r;this.abi=new R(e,t),this.serializer=new D({typeRegistry:this.typeRegistry}),this.cache=new w.WarpCache(e.cache?.type)}async getActionExecution(e,t,r){let n=this.cache.get(w.WarpCacheKey.WarpExecutable(this.config.env,e.meta?.hash||"",t))??[],i=await this.extractContractOutput(e,t,r,n),o=(0,w.getNextInfo)(this.config,[],e,t,i.output),c=(0,w.applyOutputToMessages)(e,i.output,this.config),l=(0,w.extractResolvedInputValues)(n);return{status:r.status.isSuccessful()?"success":"error",warp:e,action:t,user:(0,w.getWarpWalletAddressFromConfig)(this.config,this.chain.name),txHash:r.hash,tx:r,next:o,values:i.values,output:i.output,messages:c,destination:null,resolvedInputs:l}}async extractContractOutput(e,t,r,n){let i=(0,w.getWarpActionByIndex)(e,t),o=[],c=[],l={};if(!e.output||i.type!=="contract")return{values:{string:o,native:c,mapped:{}},output:l};if(!Object.values(e.output).some(y=>y.includes("out")||y.includes("event"))){for(let[y,x]of Object.entries(e.output))l[y]=x;return{values:{string:o,native:c,mapped:{}},output:await(0,w.evaluateOutputCommon)(e,l,t,n,this.serializer.coreSerializer,this.config)}}let g=await this.abi.getAbiForAction(i),d=new ne.TransactionEventsParser({abi:g}),b=new ne.SmartContractTransactionsOutcomeParser({abi:g}).parseExecute({transactionOnNetwork:r,function:i.func||void 0});for(let[y,x]of Object.entries(e.output)){if(x.startsWith(w.WarpConstants.Transform.Prefix))continue;if(x.startsWith("input.")){l[y]=x;continue}let S=(0,w.parseOutputOutIndex)(x);if(S!==null&&S!==t){l[y]=null;continue}let[k,z,q]=x.split(".");if(k==="event"){if(!z||isNaN(Number(q)))continue;let K=Number(q),W=(0,ne.findEventsByFirstTopic)(r,z),et=d.parseEvents({events:W})[0],le=Object.values(et)[K]||null;o.push(String(le)),c.push(le),l[y]=le&&le.valueOf()}else if(k==="out"||k.startsWith("out[")){if(!z)continue;let K=Number(z),W=b.values[K-1]||null;q&&(W=W[q]||null),W&&typeof W=="object"&&(W="toFixed"in W?W.toFixed():W.valueOf()),o.push(String(W)),c.push(W),l[y]=W&&W.valueOf()}else l[y]=x}return{values:{string:o,native:c,mapped:{}},output:await(0,w.evaluateOutputCommon)(e,l,t,n,this.serializer.coreSerializer,this.config)}}async extractQueryOutput(e,t,r,n){let i=t.map(g=>this.serializer.typedToString(g)),o=t.map(g=>this.serializer.typedToNative(g)[1]),c={string:i,native:o,mapped:{}},l={};if(!e.output)return{values:c,output:l};let f=g=>{let d=g.split(".").slice(1).map(b=>parseInt(b)-1);if(d.length===0)return;let T=o[d[0]];for(let b=1;b<d.length;b++){if(T==null)return;T=T[d[b]]}return T};for(let[g,d]of Object.entries(e.output)){if(d.startsWith(w.WarpConstants.Transform.Prefix))continue;let T=(0,w.parseOutputOutIndex)(d);if(T!==null&&T!==r){l[g]=null;continue}d.startsWith("out.")||d==="out"||d.startsWith("out[")?l[g]=f(d)||null:l[g]=d}return l=await(0,w.evaluateOutputCommon)(e,l,r,n,this.serializer.coreSerializer,this.config),{values:c,output:l}}async resolveWarpOutputRecursively(e){let t=e.warp,r=e.entryActionIndex,n=e.executor,i=e.inputs,o=e.meta,c=new Map,l=new Set,f=this;async function g(y,x=[]){if(c.has(y))return c.get(y);if(l.has(y))throw new Error(`Circular dependency detected at action ${y}`);l.add(y);let S=t.actions[y-1];if(!S)throw new Error(`Action ${y} not found`);let k;if(S.type==="query")k=await n.executeQuery(t,y,x);else if(S.type==="collect")k=await n.executeCollect(t,y,x,o);else throw new Error(`Unsupported or interactive action type: ${S.type}`);if(c.set(y,k),t.output)for(let z of Object.values(t.output)){let K=String(z).match(/^out\[(\d+)\]/);if(K){let W=parseInt(K[1],10);W!==y&&!c.has(W)&&await g(W)}}return l.delete(y),k}await g(r,i);let d={};for(let y of c.values())for(let[x,S]of Object.entries(y.output))S!==null?d[x]=S:x in d||(d[x]=null);let T=await(0,w.evaluateOutputCommon)(t,d,r,i,this.serializer.coreSerializer,this.config);return{...c.get(r),action:r,output:T}}};var dt="EGLD-000000",ge=class{constructor(e,t,r){this.config=e;this.chain=t;this.typeRegistry=r;this.serializer=new D({typeRegistry:this.typeRegistry}),this.abi=new R(this.config,this.chain),this.output=new J(this.config,this.chain,this.typeRegistry)}async createTransaction(e){let t=(0,N.getWarpActionByIndex)(e.warp,e.action),r=null;if(t.type==="transfer")r=await this.createTransferTransaction(e);else if(t.type==="contract")r=await this.createContractCallTransaction(e);else{if(t.type==="query")throw new Error("WarpMultiversxExecutor: Invalid action type for createTransactionForExecute; Use executeQuery instead");if(t.type==="collect")throw new Error("WarpMultiversxExecutor: Invalid action type for createTransactionForExecute; Use executeCollect instead")}if(!r)throw new Error(`WarpMultiversxExecutor: Invalid action type (${t.type})`);return r}async createTransferTransaction(e){if(!e.destination)throw new Error("WarpMultiversxExecutor: createTransfer - destination not set");let t=(0,N.getWarpWalletAddressFromConfig)(this.config,e.chain.name);if(!t)throw new Error("WarpMultiversxExecutor: createTransfer - user address not set");let r=A.Address.newFromBech32(t),n=new A.TransactionsFactoryConfig({chainID:e.chain.chainId}),i=e.data?Buffer.from(this.serializer.stringToTyped(e.data).valueOf()):null,o=e.transfers.length===1&&e.transfers[0].identifier===this.chain.nativeToken?.identifier,l=(o?e.transfers[0].amount:0n)+e.value;return await new A.TransferTransactionsFactory({config:n}).createTransactionForTransfer(r,{receiver:A.Address.newFromBech32(e.destination),nativeAmount:l,tokenTransfers:o?[]:this.toTokenTransfers(e.transfers),data:i?new Uint8Array(i):void 0})}async createContractCallTransaction(e){if(!e.destination)throw new Error("WarpMultiversxExecutor: createContractCall - destination not set");let t=(0,N.getWarpWalletAddressFromConfig)(this.config,e.chain.name);if(!t)throw new Error("WarpMultiversxExecutor: createContractCall - user address not set");let r=(0,N.getWarpActionByIndex)(e.warp,e.action),n=A.Address.newFromBech32(t),i=e.args.map(c=>this.serializer.stringToTyped(c)),o=new A.TransactionsFactoryConfig({chainID:e.chain.chainId});return new A.SmartContractTransactionsFactory({config:o}).createTransactionForExecute(n,{contract:A.Address.newFromBech32(e.destination),function:"func"in r&&r.func||"",gasLimit:"gasLimit"in r?BigInt(r.gasLimit||0):0n,arguments:i,tokenTransfers:this.toTokenTransfers(e.transfers),nativeTransferAmount:e.value})}async executeQuery(e){if(!e.destination)throw new Error("WarpMultiversxExecutor: executeQuery - destination not set");let t=(0,N.getWarpActionByIndex)(e.warp,e.action);if(t.type!=="query")throw new Error(`WarpMultiversxExecutor: Invalid action type for executeQuery: ${t.type}`);let r=await this.abi.getAbiForAction(t),n=e.args.map(W=>this.serializer.stringToTyped(W)),i=C(e.chain,this.config.env,this.config),o=A.Address.newFromBech32(e.destination),c=i.createSmartContractController(r),l=c.createQuery({contract:o,function:t.func||"",arguments:n}),f=await c.runQuery(l),g=f.returnCode==="ok",d=new A.ArgSerializer,T=r.getEndpoint(f.function||t.func||""),b=(f.returnDataParts||[]).map(W=>Buffer.from(W)),y=d.buffersToValues(b,T.output),{values:x,output:S}=await this.output.extractQueryOutput(e.warp,y,e.action,e.resolvedInputs),k=(0,N.getNextInfo)(this.config,[],e.warp,e.action,S),q=e.resolvedInputs.find(W=>W.input.position==="receiver"||W.input.position==="destination")?.value||e.destination,K=(0,N.extractResolvedInputValues)(e.resolvedInputs);return{status:g?"success":"error",warp:e.warp,action:e.action,user:(0,N.getWarpWalletAddressFromConfig)(this.config,e.chain.name),txHash:null,tx:null,next:k,values:x,output:{...S,_DATA:y},messages:(0,N.applyOutputToMessages)(e.warp,S,this.config),destination:q,resolvedInputs:K}}toTokenTransfers(e){return e.map(t=>t.identifier===this.chain.nativeToken.identifier?{...t,identifier:dt}:t).map(t=>{let n=new A.TokenComputer().extractNonceFromExtendedIdentifier(t.identifier);return new A.TokenTransfer({token:new A.Token({identifier:t.identifier,nonce:BigInt(n||0)}),amount:t.amount})})}};var fe=class{constructor(e,t){this.chain=e;this.config=t}getExplorers(){let e=Se[this.chain];if(!e)return["multiversx_explorer"];let t=e[this.config.env];return t||["multiversx_explorer"]}getPrimaryExplorer(){return this.getExplorers()[0]}getExplorerUrlByName(e){let t=this.config.preferences?.explorers?.[this.chain];if(t&&!e){let i=H[t];if(i)return i}if(e){let i=H[e];if(i)return i}let r=this.getPrimaryExplorer();return H[r]||H[r]}getAccountUrl(e,t){return`${this.getExplorerUrlByName(t)}/accounts/${e}`}getTransactionUrl(e,t){return`${this.getExplorerUrlByName(t)}/transactions/${e}`}getBlockUrl(e,t){return`${this.getExplorerUrlByName(t)}/blocks/${e}`}getAssetUrl(e,t){return`${this.getExplorerUrlByName(t)}/tokens/${e}`}getContractUrl(e,t){return`${this.getExplorerUrlByName(t)}/accounts/${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(n=>{let i=H[n];i&&(r[n]=`${i}/accounts/${e}`)}),r}getTransactionUrls(e){let t=this.getAllExplorers(),r={};return t.forEach(n=>{let i=H[n];i&&(r[n]=`${i}/transactions/${e}`)}),r}};var m=require("@multiversx/sdk-core"),V=require("@vleap/warps");var Be={buildInfo:{rustc:{version:"1.86.0",commitHash:"05f9846f893b09a1be1fc8560e33fc3c815cfecb",commitDate:"2025-03-31",channel:"Stable",short:"rustc 1.86.0 (05f9846f8 2025-03-31)"},contractCrate:{name:"registry",version:"0.0.1"},framework:{name:"multiversx-sc",version:"0.51.1"}},name:"RegistryContract",constructor:{inputs:[{name:"unit_price",type:"BigUint"},{name:"vault",type:"Address"}],outputs:[]},upgradeConstructor:{inputs:[],outputs:[]},endpoints:[{name:"registerWarp",mutability:"mutable",payableInTokens:["EGLD"],inputs:[{name:"hash",type:"bytes"},{name:"alias_opt",type:"optional<bytes>",multi_arg:!0},{name:"brand_opt",type:"optional<bytes>",multi_arg:!0}],outputs:[],allow_multiple_var_args:!0},{name:"unregisterWarp",mutability:"mutable",inputs:[{name:"warp",type:"bytes"}],outputs:[]},{name:"upgradeWarp",mutability:"mutable",payableInTokens:["EGLD"],inputs:[{name:"alias",type:"bytes"},{name:"new_warp",type:"bytes"},{name:"brand_opt",type:"optional<bytes>",multi_arg:!0}],outputs:[]},{name:"setWarpAlias",mutability:"mutable",payableInTokens:["EGLD"],inputs:[{name:"hash",type:"bytes"},{name:"alias",type:"bytes"}],outputs:[]},{name:"forceRemoveAlias",mutability:"mutable",inputs:[{name:"hash",type:"bytes"}],outputs:[]},{name:"verifyWarp",mutability:"mutable",inputs:[{name:"warp",type:"bytes"}],outputs:[]},{name:"transferOwnership",mutability:"mutable",inputs:[{name:"warp",type:"bytes"},{name:"new_owner",type:"Address"}],outputs:[]},{name:"getUserWarps",mutability:"readonly",inputs:[{name:"address",type:"Address"}],outputs:[{type:"variadic<InfoView>",multi_result:!0}]},{name:"getInfoByAlias",mutability:"readonly",inputs:[{name:"alias",type:"bytes"}],outputs:[{type:"InfoView"}]},{name:"getInfoByHash",mutability:"readonly",inputs:[{name:"hash",type:"bytes"}],outputs:[{type:"InfoView"}]},{name:"setVault",onlyOwner:!0,mutability:"mutable",inputs:[{name:"vault",type:"Address"}],outputs:[]},{name:"setUnitPrice",onlyOwner:!0,mutability:"mutable",inputs:[{name:"amount",type:"BigUint"}],outputs:[]},{name:"addAdmin",onlyOwner:!0,mutability:"mutable",inputs:[{name:"address",type:"Address"}],outputs:[]},{name:"removeAdmin",onlyOwner:!0,mutability:"mutable",inputs:[{name:"address",type:"Address"}],outputs:[]},{name:"getConfig",mutability:"readonly",inputs:[],outputs:[{type:"ConfigView"}]},{name:"registerBrand",mutability:"mutable",payableInTokens:["EGLD"],inputs:[{name:"hash",type:"bytes"}],outputs:[]},{name:"brandWarp",mutability:"mutable",payableInTokens:["EGLD"],inputs:[{name:"warp",type:"bytes"},{name:"brand",type:"bytes"}],outputs:[]},{name:"getUserBrands",mutability:"readonly",inputs:[{name:"user",type:"Address"}],outputs:[{type:"variadic<bytes>",multi_result:!0}]}],events:[{identifier:"warpRegistered",inputs:[{name:"hash",type:"bytes",indexed:!0},{name:"alias",type:"bytes",indexed:!0},{name:"trust",type:"bytes",indexed:!0}]},{identifier:"warpUnregistered",inputs:[{name:"hash",type:"bytes",indexed:!0}]},{identifier:"warpUpgraded",inputs:[{name:"alias",type:"bytes",indexed:!0},{name:"new_warp",type:"bytes",indexed:!0},{name:"trust",type:"bytes",indexed:!0}]},{identifier:"warpVerified",inputs:[{name:"hash",type:"bytes",indexed:!0}]},{identifier:"aliasUpdated",inputs:[{name:"hash",type:"bytes",indexed:!0},{name:"alias",type:"bytes",indexed:!0}]},{identifier:"ownershipTransferred",inputs:[{name:"warp",type:"bytes",indexed:!0},{name:"old_owner",type:"Address",indexed:!0},{name:"new_owner",type:"Address",indexed:!0}]}],esdtAttributes:[],hasCallback:!1,types:{ConfigView:{type:"struct",fields:[{name:"unit_price",type:"BigUint"},{name:"admins",type:"List<Address>"}]},InfoView:{type:"struct",fields:[{name:"hash",type:"bytes"},{name:"alias",type:"Option<bytes>"},{name:"trust",type:"bytes"},{name:"owner",type:"Address"},{name:"created_at",type:"u64"},{name:"upgraded_at",type:"u64"},{name:"brand",type:"Option<bytes>"},{name:"upgrade",type:"Option<bytes>"}]}}};var I=s=>{if(s==="devnet")return"erd1qqqqqqqqqqqqqpgqje2f99vr6r7sk54thg03c9suzcvwr4nfl3tsfkdl36";if(s==="testnet")throw new Error("Multiversx testnet is not supported");return"erd1qqqqqqqqqqqqqpgq3mrpj3u6q7tejv6d7eqhnyd27n9v5c5tl3ts08mffe"};var ye=s=>({hash:s.hash.toString("hex"),alias:s.alias?.toString()||null,trust:s.trust.toString(),owner:s.owner.toString(),createdAt:s.created_at.toNumber(),upgradedAt:s.upgraded_at?.toNumber(),brand:s.brand?.toString("hex")||null,upgrade:s.upgrade?.toString("hex")||null}),Ne=s=>({unitPrice:BigInt(s.unit_price.toString()),admins:s.admins.map(e=>e.toBech32())});var We=class{constructor(e,t){this.config=e;this.chain=t;this.cache=new V.WarpCache(e.cache?.type),this.registryConfig={unitPrice:BigInt(0),admins:[]},this.userWallet=(0,V.getWarpWalletAddressFromConfig)(this.config,this.chain.name)}async init(){await this.loadRegistryConfigs()}getRegistryConfig(){return this.registryConfig}async createWarpRegisterTransaction(e,t,r){if(this.registryConfig.unitPrice===BigInt(0))throw new Error("WarpRegistry: config not loaded. forgot to call init()?");if(!this.userWallet)throw new Error("WarpRegistry: user address not set");let n=m.Address.newFromBech32(this.userWallet),i=()=>this.isCurrentUserAdmin()?BigInt(0):t&&r?this.registryConfig.unitPrice*BigInt(3):t?this.registryConfig.unitPrice*BigInt(2):this.registryConfig.unitPrice,o=()=>t&&r?[m.BytesValue.fromHex(e),m.BytesValue.fromUTF8(t),m.BytesValue.fromHex(r)]:t?[m.BytesValue.fromHex(e),m.BytesValue.fromUTF8(t)]:[m.BytesValue.fromHex(e)];return await this.getFactory().createTransactionForExecute(n,{contract:m.Address.newFromBech32(I(this.config.env)),function:"registerWarp",gasLimit:BigInt(1e7),nativeTransferAmount:i(),arguments:o()})}async createWarpUnregisterTransaction(e){if(!this.userWallet)throw new Error("WarpRegistry: user address not set");let t=m.Address.newFromBech32(this.userWallet);return await this.getFactory().createTransactionForExecute(t,{contract:m.Address.newFromBech32(I(this.config.env)),function:"unregisterWarp",gasLimit:BigInt(1e7),arguments:[m.BytesValue.fromHex(e)]})}async createWarpUpgradeTransaction(e,t,r){if(this.registryConfig.unitPrice===BigInt(0))throw new Error("WarpRegistry: config not loaded. forgot to call init()?");if(!this.userWallet)throw new Error("WarpRegistry: user address not set");let n=m.Address.newFromBech32(this.userWallet);return await this.getFactory().createTransactionForExecute(n,{contract:m.Address.newFromBech32(I(this.config.env)),function:"upgradeWarp",gasLimit:BigInt(1e7),nativeTransferAmount:this.isCurrentUserAdmin()?void 0:this.registryConfig.unitPrice,arguments:r?[m.BytesValue.fromUTF8(e),m.BytesValue.fromHex(t),m.BytesValue.fromHex(r)]:[m.BytesValue.fromUTF8(e),m.BytesValue.fromHex(t)]})}async createWarpAliasSetTransaction(e,t){if(!this.userWallet)throw new Error("WarpRegistry: user address not set");let r=m.Address.newFromBech32(this.userWallet);return await this.getFactory().createTransactionForExecute(r,{contract:m.Address.newFromBech32(I(this.config.env)),function:"setWarpAlias",gasLimit:BigInt(1e7),nativeTransferAmount:this.isCurrentUserAdmin()?void 0:this.registryConfig.unitPrice,arguments:[m.BytesValue.fromHex(e),m.BytesValue.fromUTF8(t)]})}async createWarpVerifyTransaction(e){if(!this.userWallet)throw new Error("WarpRegistry: user address not set");let t=m.Address.newFromBech32(this.userWallet);return await this.getFactory().createTransactionForExecute(t,{contract:m.Address.newFromBech32(I(this.config.env)),function:"verifyWarp",gasLimit:BigInt(1e7),arguments:[m.BytesValue.fromHex(e)]})}async createWarpTransferOwnershipTransaction(e,t){if(!this.userWallet)throw new Error("WarpRegistry: user address not set");let r=m.Address.newFromBech32(this.userWallet);return await this.getFactory().createTransactionForExecute(r,{contract:m.Address.newFromBech32(I(this.config.env)),function:"transferOwnership",gasLimit:BigInt(1e7),arguments:[m.BytesValue.fromHex(e),new m.AddressValue(new m.Address(t))]})}async createBrandRegisterTransaction(e){if(this.registryConfig.unitPrice===BigInt(0))throw new Error("WarpRegistry: config not loaded. forgot to call init()?");if(!this.userWallet)throw new Error("WarpRegistry: user address not set");let t=m.Address.newFromBech32(this.userWallet);return await this.getFactory().createTransactionForExecute(t,{contract:m.Address.newFromBech32(I(this.config.env)),function:"registerBrand",gasLimit:BigInt(1e7),nativeTransferAmount:this.isCurrentUserAdmin()?void 0:this.registryConfig.unitPrice,arguments:[m.BytesValue.fromHex(e)]})}async createWarpBrandingTransaction(e,t){if(!this.userWallet)throw new Error("WarpRegistry: user address not set");let r=m.Address.newFromBech32(this.userWallet);return await this.getFactory().createTransactionForExecute(r,{contract:m.Address.newFromBech32(I(this.config.env)),function:"brandWarp",gasLimit:BigInt(1e7),nativeTransferAmount:this.isCurrentUserAdmin()?void 0:this.registryConfig.unitPrice,arguments:[m.BytesValue.fromHex(e),m.BytesValue.fromHex(t)]})}async getInfoByAlias(e,t){try{let r=V.WarpCacheKey.RegistryInfo(this.config.env,e),n=t?this.cache.get(r):null;if(n)return V.WarpLogger.info(`WarpRegistry (getInfoByAlias): RegistryInfo found in cache: ${e}`),n;let i=m.Address.newFromBech32(I(this.config.env)),o=this.getController(),c=o.createQuery({contract:i,function:"getInfoByAlias",arguments:[m.BytesValue.fromUTF8(e)]}),l=await o.runQuery(c),[f]=o.parseQueryResponse(l),g=f?ye(f):null,d=g?.brand?await this.fetchBrand(g.brand):null;return t&&t.ttl&&this.cache.set(r,{registryInfo:g,brand:d},t.ttl),{registryInfo:g,brand:d}}catch{return{registryInfo:null,brand:null}}}async getInfoByHash(e,t){try{let r=V.WarpCacheKey.RegistryInfo(this.config.env,e);if(t){let d=this.cache.get(r);if(d)return V.WarpLogger.info(`WarpRegistry (getInfoByHash): RegistryInfo found in cache: ${e}`),d}let n=m.Address.newFromBech32(I(this.config.env)),i=this.getController(),o=i.createQuery({contract:n,function:"getInfoByHash",arguments:[m.BytesValue.fromHex(e)]}),c=await i.runQuery(o),[l]=i.parseQueryResponse(c),f=l?ye(l):null,g=f?.brand?await this.fetchBrand(f.brand):null;return t&&t.ttl&&this.cache.set(r,{registryInfo:f,brand:g},t.ttl),{registryInfo:f,brand:g}}catch{return{registryInfo:null,brand:null}}}async getUserWarpRegistryInfos(e){try{let t=e||this.userWallet;if(!t)throw new Error("WarpRegistry: user address not set");let r=m.Address.newFromBech32(I(this.config.env)),n=this.getController(),i=n.createQuery({contract:r,function:"getUserWarps",arguments:[new m.AddressValue(new m.Address(t))]}),o=await n.runQuery(i),[c]=n.parseQueryResponse(o);return c.map(ye)}catch{return[]}}async getUserBrands(e){try{let t=e||this.userWallet;if(!t)throw new Error("WarpRegistry: user address not set");let r=m.Address.newFromBech32(I(this.config.env)),n=this.getController(),i=n.createQuery({contract:r,function:"getUserBrands",arguments:[new m.AddressValue(new m.Address(t))]}),o=await n.runQuery(i),[c]=n.parseQueryResponse(o),l=c.map(d=>d.toString("hex")),f={ttl:365*24*60*60};return(await Promise.all(l.map(d=>this.fetchBrand(d,f)))).filter(d=>d!==null)}catch{return[]}}async fetchBrand(e,t){let r=V.WarpCacheKey.Brand(this.config.env,e),n=t?this.cache.get(r):null;if(n)return V.WarpLogger.info(`WarpRegistry (fetchBrand): Brand found in cache: ${e}`),n;let o=C(this.chain,this.config.env,this.config).createNetworkProvider();try{let c=await o.getTransaction(e),l=JSON.parse(c.data.toString());return l.meta={query:null,chain:this.chain.name,identifier:(0,V.createWarpIdentifier)(this.chain.name,"hash",e),hash:c.hash,creator:c.sender.toBech32(),createdAt:new Date(c.timestamp*1e3).toISOString()},t&&t.ttl&&this.cache.set(r,l,t.ttl),l}catch{return null}}async loadRegistryConfigs(){let e=m.Address.newFromBech32(I(this.config.env)),t=this.getController(),[r]=await t.query({contract:e,function:"getConfig",arguments:[]}),n=r?Ne(r):null;this.registryConfig=n||{unitPrice:BigInt(0),admins:[]}}getFactory(){let e=new m.TransactionsFactoryConfig({chainID:this.chain.chainId}),t=m.AbiRegistry.create(Be);return new m.SmartContractTransactionsFactory({config:e,abi:t})}getController(){let e=C(this.chain,this.config.env,this.config),t=m.AbiRegistry.create(Be);return e.createSmartContractController(t)}isCurrentUserAdmin(){return!!this.userWallet&&this.registryConfig.admins.includes(this.userWallet)}};var Je=require("@multiversx/sdk-core"),ee=require("@vleap/warps");var G=require("@multiversx/sdk-core"),O=require("@vleap/warps"),Y=class Y{constructor(e,t){this.config=e;this.chain=t;this.account=null}async getAddress(){let e=(0,O.getWarpWalletAddressFromConfig)(this.config,this.chain.name);if(e)return e;try{return this.getAccount().address.toBech32()}catch{return null}}async getPublicKey(){try{return this.getAccount().publicKey.hex()}catch{return null}}async signTransaction(e){return await this.getAccount().signTransaction(e),e}async signMessage(e){let t=this.getAccount(),r=new TextEncoder().encode(e),n=await t.signMessage(new G.Message({data:r}));return Buffer.from(n).toString("hex")}getAccountInstance(){return this.getAccount()}async importFromMnemonic(e){let r=G.Mnemonic.fromString(e).deriveKey(0),n=r.hex(),o=r.generatePublicKey().toAddress(this.chain.addressHrp).toBech32(),c={provider:Y.PROVIDER_NAME,address:o,privateKey:n,mnemonic:e};return(0,O.setWarpWalletInConfig)(this.config,this.chain.name,c),c}async importFromPrivateKey(e){let{UserSecretKey:t}=await import("@multiversx/sdk-wallet"),r=t.fromString(e),n=r.hex(),o=r.generatePublicKey().toAddress(this.chain.addressHrp).toBech32(),c={provider:Y.PROVIDER_NAME,address:o,privateKey:n,mnemonic:null};return(0,O.setWarpWalletInConfig)(this.config,this.chain.name,c),c}async export(){let e=this.getAccount(),t=(0,O.getWarpWalletMnemonicFromConfig)(this.config,this.chain.name),r=(0,O.getWarpWalletPrivateKeyFromConfig)(this.config,this.chain.name);return{provider:Y.PROVIDER_NAME,address:e.address.toBech32(),privateKey:r||null,mnemonic:t||null}}async generate(){let e=G.Mnemonic.generate(),t=e.toString(),i=e.deriveKey(0).generatePublicKey().toAddress(this.chain.addressHrp).toBech32();return{provider:Y.PROVIDER_NAME,address:i,privateKey:null,mnemonic:t}}getAccount(){if(this.account)return this.account;let e=(0,O.getWarpWalletMnemonicFromConfig)(this.config,this.chain.name);if(!e)throw new Error("No mnemonic provided");let r=G.Mnemonic.fromString(e).deriveKey(0);return this.account=new G.Account(r),this.account}};Y.PROVIDER_NAME="mnemonic";var ae=Y;var U=require("@multiversx/sdk-core"),M=require("@vleap/warps"),Z=class Z{constructor(e,t){this.config=e;this.chain=t;this.account=null}async getAddress(){let e=(0,M.getWarpWalletAddressFromConfig)(this.config,this.chain.name);if(e)return e;try{return this.getAccount().address.toBech32()}catch{return null}}async getPublicKey(){try{return this.getAccount().publicKey.hex()}catch{return null}}async signTransaction(e){return await this.getAccount().signTransaction(e),e}async signMessage(e){let t=this.getAccount(),r=new TextEncoder().encode(e),n=await t.signMessage(new U.Message({data:r}));return Buffer.from(n).toString("hex")}getAccountInstance(){return this.getAccount()}async importFromMnemonic(e){let r=U.Mnemonic.fromString(e).deriveKey(0),n=r.hex(),o=r.generatePublicKey().toAddress(this.chain.addressHrp).toBech32(),c={provider:Z.PROVIDER_NAME,address:o,privateKey:n,mnemonic:e};return(0,M.setWarpWalletInConfig)(this.config,this.chain.name,c),c}async importFromPrivateKey(e){let r=e.startsWith("-----")?U.UserSecretKey.fromPem(e):U.UserSecretKey.fromString(e),n=r.hex(),o=r.generatePublicKey().toAddress(this.chain.addressHrp).toBech32(),c={provider:Z.PROVIDER_NAME,address:o,privateKey:n,mnemonic:null};return(0,M.setWarpWalletInConfig)(this.config,this.chain.name,c),c}async export(){let e=this.getAccount(),t=(0,M.getWarpWalletPrivateKeyFromConfig)(this.config,this.chain.name),r=(0,M.getWarpWalletMnemonicFromConfig)(this.config,this.chain.name);return{provider:Z.PROVIDER_NAME,address:e.address.toBech32(),privateKey:t||null,mnemonic:r||null}}async generate(){let e=U.UserSecretKey.generate(),t=e.hex(),n=e.generatePublicKey().toAddress(this.chain.addressHrp).toBech32();return{provider:Z.PROVIDER_NAME,address:n,privateKey:t,mnemonic:null}}getAccount(){if(this.account)return this.account;let e=(0,M.getWarpWalletPrivateKeyFromConfig)(this.config,this.chain.name);if(!e)throw new Error("No private key provided");let r=e.startsWith("-----")?U.UserSecretKey.fromPem(e):U.UserSecretKey.fromString(e);return this.account=new U.Account(r),this.account}};Z.PROVIDER_NAME="privateKey";var ie=Z;var se=require("@vleap/warps"),oe=class{constructor(e,t){this.config=e;this.chain=t}async getAddress(){return(0,se.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,se.getWarpWalletAddressFromConfig)(this.config,this.chain.name);throw new Error(`Wallet can not be used for signing: ${t}`)}async importFromPrivateKey(e){let t=(0,se.getWarpWalletAddressFromConfig)(this.config,this.chain.name);throw new Error(`Wallet can not be used for signing: ${t}`)}async export(){let e=(0,se.getWarpWalletAddressFromConfig)(this.config,this.chain.name);throw new Error(`Wallet can not be used for signing: ${e}`)}async generate(){let e=(0,se.getWarpWalletAddressFromConfig)(this.config,this.chain.name);throw new Error(`Wallet can not be used for signing: ${e}`)}};var ve=class{constructor(e,t){this.config=e;this.chain=t;this.cachedAddress=null;this.cachedPublicKey=null;this.entry=C(t,e.env,e),this.cache=new ee.WarpCache(e.cache?.type),this.walletProvider=this.createProvider(),this.initializeCache()}async signTransaction(e){if(!e||typeof e!="object")throw new Error("Invalid transaction object");if(!this.walletProvider)throw new Error("No wallet provider available");if(this.walletProvider instanceof oe)throw new Error(`Wallet (${this.chain.name}) is read-only`);if(this.walletProvider instanceof ie||this.walletProvider instanceof ae){let r=this.walletProvider.getAccountInstance();if(e.nonce===0n){let n=await this.entry.recallAccountNonce(r.address),i=this.cache.get(`nonce:${r.address.toBech32()}`)||0,o=BigInt(Math.max(i,Number(n)));e.nonce=o}}else if(e.nonce===0n&&this.cachedAddress){let r=Je.Address.newFromBech32(this.cachedAddress),n=await this.entry.recallAccountNonce(r),i=this.cache.get(`nonce:${this.cachedAddress}`)||0,o=BigInt(Math.max(i,Number(n)));e.nonce=o}let t=await this.walletProvider.signTransaction(e);if(this.walletProvider instanceof ie||this.walletProvider instanceof ae){let r=this.walletProvider.getAccountInstance(),n=Number(r.nonce)+1;this.cache.set(`nonce:${r.address.toBech32()}`,n,ee.CacheTtl.OneMinute)}else if(this.cachedAddress){let r=e.nonce?Number(e.nonce):0;this.cache.set(`nonce:${this.cachedAddress}`,r+1,ee.CacheTtl.OneMinute)}return t}async signTransactions(e){let t=[];for(let r of e)t.push(await this.signTransaction(r));return t}async signMessage(e){if(!this.walletProvider)throw new Error("No wallet provider available");if(this.walletProvider instanceof oe)throw new Error(`Wallet (${this.chain.name}) is read-only`);return await this.walletProvider.signMessage(e)}async sendTransactions(e){return Promise.all(e.map(async t=>this.sendTransaction(t)))}async sendTransaction(e){if(!e||typeof e!="object")throw new Error("Invalid transaction object");if(!e.signature)throw new Error("Transaction must be signed before sending");return await this.entry.sendTransaction(e)}async importFromMnemonic(e,t){return await this.createProviderForOperation(e).importFromMnemonic(t)}async importFromPrivateKey(e,t){return await this.createProviderForOperation(e).importFromPrivateKey(t)}async export(e){return await this.createProviderForOperation(e).export()}async generate(e){return await this.createProviderForOperation(e).generate()}getAddress(){return this.cachedAddress}getPublicKey(){return this.cachedPublicKey}createProvider(){let e=this.config.user?.wallets?.[this.chain.name];return e?typeof e=="string"?new oe(this.config,this.chain):this.createProviderForOperation(e.provider):null}initializeCache(){(0,ee.initializeWalletCache)(this.walletProvider).then(e=>{this.cachedAddress=e.address,this.cachedPublicKey=e.publicKey})}createProviderForOperation(e){let r=this.config.walletProviders?.[this.chain.name]?.[e];if(r){let n=r(this.config,this.chain);if(!n)throw new Error(`Custom wallet provider factory returned null for ${e}`);return n}if(e==="privateKey")return new ie(this.config,this.chain);if(e==="mnemonic")return new ae(this.config,this.chain);throw new Error(`Unsupported wallet provider for ${this.chain.name}: ${e}`)}};var we=(s,e)=>(t,r)=>{let n=e[t.env],i=new Ye.WarpTypeRegistry;return i.registerType("token",{stringToNative:o=>o,nativeToString:o=>`token:${o}`}),i.registerType("codemeta",{stringToNative:o=>o,nativeToString:o=>`codemeta:${o}`}),i.registerTypeAlias("list","vector"),{chainInfo:n,builder:()=>new de(t,n),executor:new ge(t,n,i),output:new J(t,n,i),serializer:new D({typeRegistry:i}),registry:new We(t,n),explorer:new fe(s,t),abiBuilder:()=>new R(t,n),brandBuilder:()=>new me(t,n),dataLoader:new he(t,n),wallet:new ve(t,n)}};var ce=require("@vleap/warps");var Ae={chain:ce.WarpChainName.Multiversx,identifier:"EGLD",name:"eGold",symbol:"EGLD",decimals:18,logoUrl:"https://joai.ai/images/tokens/egld.svg"},Ve=we(ce.WarpChainName.Multiversx,{mainnet:{name:ce.WarpChainName.Multiversx,displayName:"MultiversX",chainId:"1",blockTime:6e3,addressHrp:"erd",defaultApiUrl:"https://api.multiversx.com",logoUrl:"https://joai.ai/images/chains/multiversx.svg",nativeToken:Ae},testnet:{name:ce.WarpChainName.Multiversx,displayName:"MultiversX Testnet",chainId:"T",blockTime:6e3,addressHrp:"erd",defaultApiUrl:"https://testnet-api.multiversx.com",logoUrl:"https://joai.ai/images/chains/multiversx.svg",nativeToken:Ae},devnet:{name:ce.WarpChainName.Multiversx,displayName:"MultiversX Devnet",chainId:"D",blockTime:6e3,addressHrp:"erd",defaultApiUrl:"https://devnet-api.multiversx.com",logoUrl:"https://joai.ai/images/chains/multiversx.svg",nativeToken:Ae}});var xe=require("@vleap/warps");var Ze={chain:xe.WarpChainName.Vibechain,identifier:"VIBE",name:"VIBE",symbol:"VIBE",decimals:18,logoUrl:"https://joai.ai/images/tokens/vibe.svg"},Ue={name:xe.WarpChainName.Vibechain,displayName:"VibeChain",chainId:"V",blockTime:600,addressHrp:"vibe",defaultApiUrl:"https://vibeox-api.multiversx.com",logoUrl:"https://joai.ai/images/chains/vibechain.svg",nativeToken:Ze},ke=we(xe.WarpChainName.Vibechain,{mainnet:Ue,testnet:Ue,devnet:Ue});var gt=()=>[Ve,ke];var L=require("@vleap/warps");var ft=s=>new L.WarpSerializer().nativeToString(v.Token,s),yt=s=>new L.WarpSerializer().nativeToString(v.CodeMeta,s),Wt=(s,e)=>{if(e===null)return v.Optional+L.WarpConstants.ArgParamsSeparator;let t=s(e),r=t.indexOf(L.WarpConstants.ArgParamsSeparator),n=t.substring(0,r),i=t.substring(r+1);return v.Optional+L.WarpConstants.ArgParamsSeparator+n+L.WarpConstants.ArgParamsSeparator+i},vt=s=>new L.WarpSerializer().nativeToString(v.List,s);var p=require("@multiversx/sdk-core"),wt=(s,e)=>s?p.OptionValue.newProvided(s):e?p.OptionValue.newMissingTyped(e):p.OptionValue.newMissing(),Tt=(s,e)=>s?new p.OptionalValue(s.getType(),s):e?new p.OptionalValue(e):p.OptionalValue.newMissing(),Ct=s=>{if(s.length===0)throw new Error("Cannot create a list from an empty array");let e=s[0].getType();return new p.List(e,s)},At=s=>p.VariadicValue.fromItems(...s),xt=s=>{let e=s.map(t=>t.getType());return new p.CompositeValue(new p.CompositeType(...e),s)},Et=s=>p.StringValue.fromUTF8(s),bt=s=>new p.U8Value(s),Pt=s=>new p.U16Value(s),It=s=>new p.U32Value(s),St=s=>new p.U64Value(s),Bt=s=>new p.BigUIntValue(BigInt(s)),Nt=s=>new p.BooleanValue(s),Vt=s=>new p.AddressValue(p.Address.newFromBech32(s)),Ut=s=>new p.TokenIdentifierValue(s),kt=s=>p.BytesValue.fromHex(s),Ft=s=>new p.Struct(new p.StructType("EsdtTokenPayment",[new p.FieldDefinition("token_identifier","",new p.TokenIdentifierType),new p.FieldDefinition("token_nonce","",new p.U64Type),new p.FieldDefinition("amount","",new p.BigUIntType)]),[new p.Field(new p.TokenIdentifierValue(s.token.identifier),"token_identifier"),new p.Field(new p.U64Value(BigInt(s.token.nonce)),"token_nonce"),new p.Field(new p.BigUIntValue(BigInt(s.amount)),"amount")]),Ot=s=>new p.CodeMetadataValue(p.CodeMetadata.newFromBytes(Uint8Array.from(Buffer.from(s,"hex")))),Mt=()=>new p.NothingValue;0&&(module.exports={ExplorerUrls,KnownTokens,MultiversxAdapter,MultiversxExplorers,MultiversxExplorersConfig,NativeTokenEgld,NativeTokenVibe,VibechainAdapter,VibechainExplorers,WarpMultiversxAbiBuilder,WarpMultiversxBrandBuilder,WarpMultiversxBuilder,WarpMultiversxConstants,WarpMultiversxContractLoader,WarpMultiversxDataLoader,WarpMultiversxExecutor,WarpMultiversxExplorer,WarpMultiversxInputTypes,WarpMultiversxOutput,WarpMultiversxRegistry,WarpMultiversxSerializer,WarpMultiversxWallet,address_value,asset_value,biguint_value,boolean_value,codemeta,codemeta_value,composite_value,createMultiversxAdapter,findKnownTokenById,getAllMultiversxAdapters,getAllMultiversxChainNames,getKnownTokensForChain,getMultiversxEntrypoint,getMultiversxRegistryAddress,getNormalizedTokenIdentifier,hex_value,isNativeToken,list,list_value,nothing_value,option_value,optional,optional_value,string_value,toTypedConfigInfo,toTypedRegistryInfo,token,token_value,u16_value,u32_value,u64_value,u8_value,variadic_value});
package/dist/index.mjs CHANGED
@@ -1 +1 @@
1
- import{WarpChainName as ze}from"@vleap/warps";var Nn=()=>[ze.Multiversx,ze.Vibechain];import{WarpTypeRegistry as on}from"@vleap/warps";import{AbiRegistry as de,Address as Dt,TransactionsFactoryConfig as Lt,TransferTransactionsFactory as _t}from"@multiversx/sdk-core";import{createWarpIdentifier as $t,getLatestProtocolIdentifier as Gt,getWarpWalletAddressFromConfig as Ht,WarpCache as Kt,WarpCacheKey as zt,WarpConstants as je,WarpLogger as Qe}from"@vleap/warps";import{DevnetEntrypoint as Ft,MainnetEntrypoint as Ot,TestnetEntrypoint as Mt}from"@multiversx/sdk-core";import{getProviderConfig as Rt}from"@vleap/warps";var F=s=>!s.includes("-"),z=s=>F(s)?`${s}-000000`:s,w=(s,e,t)=>{let r="warp-sdk",a=t?Rt(t,s.name,e,s.defaultApiUrl):{url:s.defaultApiUrl},i=a.url,c={headers:a.headers};return e==="devnet"?new Ft({url:i,kind:"api",clientName:r,networkProviderConfig:c}):e==="testnet"?new Mt({url:i,kind:"api",clientName:r,networkProviderConfig:c}):new Ot({url:i,kind:"api",clientName:r,networkProviderConfig:c})};import{WarpLogger as qe}from"@vleap/warps";var q=class{constructor(e){this.config=e}async getContract(e,t){try{let a=await w(t,this.config.env,this.config).createNetworkProvider().doGetGeneric(`accounts/${e}`);return{address:e,owner:a.ownerAddress,verified:a.isVerified||!1}}catch(r){return qe.error("WarpContractLoader: getContract error",r),null}}async getVerificationInfo(e,t){try{let a=await w(t,this.config.env,this.config).createNetworkProvider().doGetGeneric(`accounts/${e}/verification`);return{codeHash:a.codeHash,abi:a.source.abi}}catch(r){return qe.error("WarpContractLoader: getVerificationInfo error",r),null}}};var P=class{constructor(e,t){this.config=e;this.chain=t;this.contractLoader=new q(this.config),this.cache=new Kt(this.config.cache?.type)}async createInscriptionTransaction(e){let t=Ht(this.config,this.chain.name);if(!t)throw new Error("WarpBuilder: user address not set");let r=new Lt({chainID:this.chain.chainId}),n=new _t({config:r}),a=Dt.newFromBech32(t),i={protocol:Gt("abi"),content:e},c=JSON.stringify(i),o=await n.createTransactionForTransfer(a,{receiver:a,nativeAmount:BigInt(0),data:Uint8Array.from(Buffer.from(c))});return o.gasLimit=o.gasLimit+BigInt(2e6),o}async createFromRaw(e){return JSON.parse(e)}async createFromTransaction(e){let t=await this.createFromRaw(e.data.toString());return t.meta={chain:this.chain.name,identifier:$t(this.chain.name,"hash",e.hash),query:null,hash:e.hash,creator:e.sender.toBech32(),createdAt:new Date(e.timestamp*1e3).toISOString()},t}async createFromTransactionHash(e,t){let r=zt.WarpAbi(this.config.env,e);if(t){let i=this.cache.get(r);if(i)return Qe.info(`WarpAbiBuilder (createFromTransactionHash): Warp abi found in cache: ${e}`),i}let a=w(this.chain,this.config.env,this.config).createNetworkProvider();try{let i=await a.getTransaction(e),c=await this.createFromTransaction(i);return t&&t.ttl&&c&&this.cache.set(r,c,t.ttl),c}catch(i){return Qe.error("WarpAbiBuilder: Error creating from transaction hash",i),null}}async getAbiForAction(e){if(e.abi)return await this.fetchAbi(e);if(!e.address)throw new Error("WarpActionExecutor: Address not found");let t=await this.contractLoader.getVerificationInfo(e.address,this.chain);if(!t)throw new Error("WarpActionExecutor: Verification info not found");return de.create(t.abi)}async fetchAbi(e){if(!e.abi)throw new Error("WarpActionExecutor: ABI not found");if(e.abi.startsWith(je.IdentifierType.Hash)){let t=e.abi.split(je.ArgParamsSeparator)[1],r=await this.createFromTransactionHash(t);if(!r)throw new Error(`WarpActionExecutor: ABI not found for hash: ${e.abi}`);return de.create(r.content)}else{let r=await(await fetch(e.abi)).json();return de.create(r)}}};import{Address as Xe,TransactionsFactoryConfig as qt,TransferTransactionsFactory as jt}from"@multiversx/sdk-core";import{createWarpIdentifier as Qt,getWarpWalletAddressFromConfig as Xt,WarpBrandBuilder as Jt,WarpLogger as Yt}from"@vleap/warps";import{Buffer as Zt}from"buffer";var j=class{constructor(e,t){this.config=e;this.chain=t;this.core=new Jt(e)}async createInscriptionTransaction(e){let t=Xt(this.config,this.chain.name);if(!t)throw new Error("BrandBuilder: user address not set");let r=new qt({chainID:this.chain.chainId}),n=new jt({config:r}),a=Xe.newFromBech32(t),i=JSON.stringify(e);return await n.createTransactionForNativeTokenTransfer(a,{receiver:Xe.newFromBech32(t),nativeAmount:BigInt(0),data:Uint8Array.from(Zt.from(i))})}async createFromTransaction(e,t=!1){let r=await this.core.createFromRaw(e.data.toString(),t);return r.meta={query:null,chain:this.chain.name,identifier:Qt(this.chain.name,"hash",e.hash),hash:e.hash,creator:e.sender.toBech32(),createdAt:new Date(e.timestamp*1e3).toISOString()},r}async createFromTransactionHash(e){let r=w(this.chain,this.config.env,this.config).createNetworkProvider();try{let n=await r.getTransaction(e);return this.createFromTransaction(n)}catch(n){return Yt.error("BrandBuilder: Error creating from transaction hash",n),null}}};import{Address as Je,TransactionsFactoryConfig as er,TransferTransactionsFactory as tr}from"@multiversx/sdk-core";import{createWarpIdentifier as rr,getWarpWalletAddressFromConfig as nr,WarpBuilder as Ye,WarpCache as ar,WarpCacheKey as ir,WarpLogger as Ze}from"@vleap/warps";var Q=class extends Ye{constructor(t,r){super(t);this.config=t;this.chain=r;this.cache=new ar(t.cache?.type),this.core=new Ye(t)}async createInscriptionTransaction(t){let r=nr(this.config,this.chain.name);if(!r)throw new Error("WarpBuilder: user address not set");let n=new er({chainID:this.chain.chainId}),a=new tr({config:n}),i=Je.newFromBech32(r),c=JSON.stringify(t),o=await a.createTransactionForTransfer(i,{receiver:Je.newFromBech32(r),nativeAmount:BigInt(0),data:Uint8Array.from(Buffer.from(c))});return o.gasLimit=o.gasLimit+BigInt(2e6),o}async createFromTransaction(t,r=!1){let n=await this.core.createFromRaw(t.data.toString(),r);return n.meta={chain:this.chain.name,identifier:rr(this.chain.name,"hash",t.hash),query:null,hash:t.hash,creator:t.sender.toBech32(),createdAt:new Date(t.timestamp*1e3).toISOString()},n}async createFromTransactionHash(t,r){let n=ir.Warp(this.config.env,t);if(r){let c=this.cache.get(n);if(c)return Ze.info(`WarpBuilder (createFromTransactionHash): Warp found in cache: ${t}`),c}let i=w(this.chain,this.config.env,this.config).createNetworkProvider();try{let c=await i.getTransaction(t),o=await this.createFromTransaction(c);return r&&r.ttl&&o&&this.cache.set(n,o,r.ttl),o}catch(c){return Ze.error("WarpBuilder: Error creating from transaction hash",c),null}}};import{Address as he,Token as pr,TokenComputer as ur}from"@multiversx/sdk-core";import{CacheTtl as mr,WarpCache as dr,WarpCacheKey as hr}from"@vleap/warps";import{WarpChainName as sr}from"@vleap/warps";var et=sr.Multiversx,tt=[{chain:et,identifier:"EGLD",name:"eGold",symbol:"EGLD",decimals:18,logoUrl:"https://tools.multiversx.com/assets-cdn/tokens/EGLD-000000/icon.png"},{chain:et,identifier:"EGLD-000000",name:"eGold",symbol:"EGLD",decimals:18,logoUrl:"https://tools.multiversx.com/assets-cdn/tokens/EGLD-000000/icon.png"}];import{WarpChainName as or}from"@vleap/warps";var A=or.Multiversx,rt=[{chain:A,identifier:"EGLD",name:"eGold",symbol:"EGLD",decimals:18,logoUrl:"https://tools.multiversx.com/assets-cdn/tokens/EGLD-000000/icon.png"},{chain:A,identifier:"EGLD-000000",name:"eGold",symbol:"EGLD",decimals:18,logoUrl:"https://tools.multiversx.com/assets-cdn/tokens/EGLD-000000/icon.png"},{chain:A,identifier:"SEGLD-3ad2d0",name:"StakedEGLD",symbol:"SEGLD",decimals:18,logoUrl:"https://tools.multiversx.com/assets-cdn/tokens/SEGLD-3ad2d0/icon.png"},{chain:A,identifier:"HSEGLD-c13a4e",name:"HatomSEGLD",symbol:"HSEGLD",decimals:8,logoUrl:"https://tools.multiversx.com/assets-cdn/tokens/HSEGLD-c13a4e/icon.png"},{chain:A,identifier:"UTK-2f80e9",name:"xMoney UTK",symbol:"UTK",decimals:18,logoUrl:"https://tools.multiversx.com/assets-cdn/tokens/UTK-2f80e9/icon.png"},{chain:A,identifier:"USDC-c76f1f",name:"WrappedUSDC",symbol:"USDC",decimals:6,logoUrl:"https://tools.multiversx.com/assets-cdn/tokens/USDC-c76f1f/icon.png"},{chain:A,identifier:"WEGLD-bd4d79",name:"WrappedEGLD",symbol:"WEGLD",decimals:18,logoUrl:"https://tools.multiversx.com/assets-cdn/tokens/WEGLD-bd4d79/icon.png"},{chain:A,identifier:"HTM-f51d55",name:"Hatom",symbol:"HTM",decimals:18,logoUrl:"https://tools.multiversx.com/assets-cdn/tokens/HTM-f51d55/icon.png"},{chain:A,identifier:"MEX-455c57",name:"MEX",symbol:"MEX",decimals:18,logoUrl:"https://tools.multiversx.com/assets-cdn/tokens/MEX-455c57/icon.png"},{chain:A,identifier:"WTAO-4f5363",name:"WrappedTAO",symbol:"WTAO",decimals:9,logoUrl:"https://tools.multiversx.com/assets-cdn/tokens/WTAO-4f5363/icon.png"},{chain:A,identifier:"HEGLD-d61095",name:"HatomEGLD",symbol:"HEGLD",decimals:8,logoUrl:"https://tools.multiversx.com/assets-cdn/tokens/HEGLD-d61095/icon.png"},{chain:A,identifier:"WBTC-5349b3",name:"WrappedBTC",symbol:"WBTC",decimals:8,logoUrl:"https://tools.multiversx.com/assets-cdn/tokens/WBTC-5349b3/icon.png"},{chain:A,identifier:"WETH-b4ca29",name:"WrappedETH",symbol:"WETH",decimals:18,logoUrl:"https://tools.multiversx.com/assets-cdn/tokens/WETH-b4ca29/icon.png"},{chain:A,identifier:"USH-111e09",name:"HatomUSD",symbol:"USH",decimals:18,logoUrl:"https://tools.multiversx.com/assets-cdn/tokens/USH-111e09/icon.png"},{chain:A,identifier:"USDT-f8c08c",name:"WrappedUSDT",symbol:"USDT",decimals:6,logoUrl:"https://tools.multiversx.com/assets-cdn/tokens/USDT-f8c08c/icon.png"}];import{WarpChainName as cr}from"@vleap/warps";var nt=cr.Multiversx,at=[{chain:nt,identifier:"EGLD",name:"eGold",symbol:"EGLD",decimals:18,logoUrl:"https://tools.multiversx.com/assets-cdn/tokens/EGLD-000000/icon.png"},{chain:nt,identifier:"EGLD-000000",name:"eGold",symbol:"EGLD",decimals:18,logoUrl:"https://tools.multiversx.com/assets-cdn/tokens/EGLD-000000/icon.png"}];import{WarpChainName as lr}from"@vleap/warps";var it=lr.Vibechain,X=[{chain:it,identifier:"VIBE",name:"VIBE",symbol:"VIBE",decimals:18,logoUrl:"https://joai.ai/images/tokens/vibe.svg"},{chain:it,identifier:"VIBE-000000",name:"VIBE",symbol:"VIBE",decimals:18,logoUrl:"https://joai.ai/images/tokens/vibe.svg"}];var st={multiversx:{mainnet:rt,testnet:at,devnet:tt},vibechain:{mainnet:X,testnet:X,devnet:X}},ot=(s,e,t)=>(st[s]?.[e]||[]).find(n=>n.identifier===t)||null,ja=(s,e)=>st[s]?.[e]||[];var J=class{constructor(e,t){this.config=e;this.chain=t;this.cache=new dr(e.cache?.type)}async getAccount(e){let r=await w(this.chain,this.config.env,this.config).createNetworkProvider().getAccount(he.newFromBech32(e));return{chain:this.chain.name,address:r.address.toBech32(),balance:r.balance}}async getAccountAssets(e){let t=w(this.chain,this.config.env,this.config).createNetworkProvider(),r=t.getAccount(he.newFromBech32(e)),n=t.getFungibleTokensOfAccount(he.newFromBech32(e)),[a,i]=await Promise.all([r,n]),c=a.balance>0?[{...this.chain.nativeToken,amount:a.balance}]:[];return c.push(...i.map(o=>({chain:this.chain.name,identifier:o.token.identifier,name:o.raw.name,symbol:o.raw.ticker,amount:o.amount,decimals:o.raw.decimals,logoUrl:o.raw.assets?.pngUrl||"",price:o.raw.price?Number(o.raw.price):void 0,supply:o.raw.supply?BigInt(o.raw.supply):void 0}))),c}async getAsset(e){let t=hr.Asset(this.config.env,this.chain.name,e),r=this.cache.get(t);if(r)return r;let n=ot(this.chain.name,this.config.env,e);if(n)return{chain:this.chain.name,identifier:e,name:n.name,symbol:n.symbol,amount:0n,decimals:n.decimals,logoUrl:n.logoUrl};let a=new ur,i=F(e)?0n:a.extractNonceFromExtendedIdentifier(e),c=new pr({identifier:e,nonce:BigInt(i||0)}),o=a.isFungible(c),d=w(this.chain,this.config.env,this.config).createNetworkProvider(),m=z(e),p=await d.doGetGeneric(`tokens/${m}`),v={chain:this.chain.name,identifier:c.identifier,name:p.name,symbol:p.ticker,amount:0n,decimals:p.decimals,logoUrl:p.assets?.pngUrl||null,price:p.price?Number(p.price):void 0,supply:p.supply?BigInt(p.supply):void 0};return this.cache.set(t,v,mr.OneHour),v}async getAction(e,t=!1){let r=w(this.chain,this.config.env,this.config),n=t?await r.awaitCompletedTransaction(e):await r.getTransaction(e);return{chain:this.chain.name,id:n.hash,receiver:n.receiver.toBech32(),sender:n.sender.toBech32(),value:n.value,function:n.function,status:this.toActionStatus(n),createdAt:this.toActionCreatedAt(n),error:n?.smartContractResults.map(a=>a.raw.returnMessage)[0]||null,tx:n}}async getAccountActions(e,t){let r=w(this.chain,this.config.env,this.config).createNetworkProvider(),n=`accounts/${e}/transactions`,a=new URLSearchParams,i=t?.size||25,c=t?.page||0;if(c>0){let d=c*i;a.append("from",d.toString())}return i!==25&&a.append("size",i.toString()),a.toString()&&(n+=`?${a.toString()}`),(await r.doGetGeneric(n)).map(d=>({chain:this.chain.name,id:d.txHash,receiver:d.receiver,sender:d.sender,value:d.value,function:d.function,status:this.toActionStatus(d),createdAt:this.toActionCreatedAt(d)}))}toActionStatus(e){return e.status.isSuccessful()?"success":e.status.isFailed()?"failed":"pending"}toActionCreatedAt(e){return new Date(e.timestamp||e.timestamp*1e3).toISOString()}};import{Address as $,ArgSerializer as Vr,SmartContractTransactionsFactory as Ur,Token as kr,TokenComputer as Fr,TokenTransfer as Or,TransactionsFactoryConfig as Et,TransferTransactionsFactory as Mr}from"@multiversx/sdk-core";import{applyOutputToMessages as Rr,extractResolvedInputValues as Dr,getNextInfo as Lr,getWarpActionByIndex as Pe,getWarpWalletAddressFromConfig as Be}from"@vleap/warps";import{findEventsByFirstTopic as Cr,SmartContractTransactionsOutcomeParser as Ar,TransactionEventsParser as xr}from"@multiversx/sdk-core";import{applyOutputToMessages as Er,evaluateOutputCommon as ie,extractResolvedInputValues as br,getNextInfo as Ir,getWarpActionByIndex as Sr,getWarpWalletAddressFromConfig as Pr,parseOutputOutIndex as At,WarpCache as Br,WarpCacheKey as Nr,WarpConstants as xt}from"@vleap/warps";import{Address as yr,AddressType as ge,AddressValue as lt,BigUIntType as Y,BigUIntValue as fe,BooleanType as ye,BooleanValue as pt,BytesType as ve,BytesValue as ut,CodeMetadata as vr,CodeMetadataType as we,CodeMetadataValue as mt,CompositeType as We,CompositeValue as dt,Field as Z,FieldDefinition as ee,List as ht,ListType as gt,NothingValue as b,OptionalType as ft,OptionalValue as Te,OptionType as yt,OptionValue as Ce,StringType as Ae,StringValue as vt,Struct as te,StructType as k,Token as wr,TokenComputer as wt,TokenIdentifierType as re,TokenIdentifierValue as xe,U16Type as Ee,U16Value as Wt,U32Type as be,U32Value as Tt,U64Type as ne,U64Value as Ie,U8Type as Se,U8Value as Ct,VariadicType as _,VariadicValue as ae}from"@multiversx/sdk-core";import{WarpSerializer as Wr}from"@vleap/warps";var u={HttpProtocolPrefix:"http",IdentifierParamName:"warp",IdentifierParamSeparator:":",IdentifierChainDefault:"multiversx",IdentifierType:{Alias:"alias",Hash:"hash"},IdentifierAliasMarker:"@",Globals:{UserWallet:{Placeholder:"USER_WALLET",Accessor:s=>s.config.user?.wallets?.[s.adapter.chainInfo.name]},UserWalletPublicKey:{Placeholder:"USER_WALLET_PUBLICKEY",Accessor:s=>{if(!s.adapter.wallet)return null;try{return s.adapter.wallet.getPublicKey()||null}catch{return null}}},ChainApiUrl:{Placeholder:"CHAIN_API",Accessor:s=>s.adapter.chainInfo.defaultApiUrl},ChainAddressHrp:{Placeholder:"CHAIN_ADDRESS_HRP",Accessor:s=>s.adapter.chainInfo.addressHrp}},Vars:{Query:"query",Env:"env"},ArgParamsSeparator:":",ArgCompositeSeparator:"|",ArgListSeparator:",",ArgStructSeparator:";",Transform:{Prefix:"transform:"},Source:{UserWallet:"user:wallet"},Position:{Payload:"payload:"},Alerts:{TriggerEventPrefix:"event"}},l={Option:"option",Vector:"vector",Tuple:"tuple",Struct:"struct",String:"string",Uint8:"uint8",Uint16:"uint16",Uint32:"uint32",Uint64:"uint64",Uint128:"uint128",Uint256:"uint256",Biguint:"biguint",Bool:"bool",Address:"address",Asset:"asset",Hex:"hex"};var ui={Egld:{Identifier:"EGLD",EsdtIdentifier:"EGLD-000000",DisplayName:"eGold",Decimals:18}},f={Null:"null",Optional:"optional",List:"list",Token:"token",CodeMeta:"codemeta"},gr=(r=>(r.MultiversxExplorer="multiversx_explorer",r.MultiversxExplorerDevnet="multiversx_explorer_devnet",r.MultiversxExplorerTestnet="multiversx_explorer_testnet",r))(gr||{}),fr=(r=>(r.VibechainExplorer="vibechain_explorer",r.VibechainExplorerDevnet="vibechain_explorer_devnet",r.VibechainExplorerTestnet="vibechain_explorer_testnet",r))(fr||{}),ct={multiversx:{mainnet:["multiversx_explorer"],testnet:["multiversx_explorer_testnet"],devnet:["multiversx_explorer_devnet"]},vibechain:{mainnet:["vibechain_explorer"],testnet:["vibechain_explorer_testnet"],devnet:["vibechain_explorer_devnet"]}},U={multiversx_explorer:"https://explorer.multiversx.com",multiversx_explorer_devnet:"https://devnet-explorer.multiversx.com",multiversx_explorer_testnet:"https://testnet-explorer.multiversx.com",vibechain_explorer:"https://vibeox-explorer.multiversx.com",vibechain_explorer_devnet:"https://vibeox-explorer.multiversx.com",vibechain_explorer_testnet:"https://vibeox-explorer.multiversx.com"};var Tr=new RegExp(`${u.ArgParamsSeparator}(.*)`),B=class{constructor(e){this.coreSerializer=new Wr(e)}typedToString(e){let t=e.getType();if(t.hasExactClass(yt.ClassName)||e.hasClassOrSuperclass(Ce.ClassName)){if(!e.isSet())return l.Option+u.ArgParamsSeparator+"null";let r=this.typedToString(e.getTypedValue());return l.Option+u.ArgParamsSeparator+r}if(t.hasExactClass(_.ClassName)||e.hasClassOrSuperclass(ae.ClassName)){let r=e.getItems();if(r.length===0){let m=this.typeToString(t.getFirstTypeParameter());return l.Vector+u.ArgParamsSeparator+m+u.ArgParamsSeparator}let n=r.map(m=>this.typedToString(m));if(n.every(m=>m.startsWith(l.Tuple)))return l.Vector+u.ArgParamsSeparator+n.join(",");let a=n[0],i=a.indexOf(u.ArgParamsSeparator),c=a.substring(0,i),o=n.map(m=>{let p=m.indexOf(u.ArgParamsSeparator);return m.substring(p+1)}),d=c.startsWith(l.Struct)?u.ArgStructSeparator:u.ArgListSeparator;return l.Vector+u.ArgParamsSeparator+c+u.ArgParamsSeparator+o.join(d)}if(t.hasExactClass(ft.ClassName)||e.hasClassOrSuperclass(Te.ClassName)){if(!e.isSet())return f.Optional+u.ArgParamsSeparator+"null";let r=this.typedToString(e.getTypedValue());return f.Optional+u.ArgParamsSeparator+r}if(t.hasExactClass(gt.ClassName)||e.hasClassOrSuperclass(ht.ClassName)){let n=e.getItems().map(o=>this.typedToString(o));if(n.every(o=>o.startsWith(l.Tuple)))return f.List+u.ArgParamsSeparator+n.join(",");let i=n.map(o=>o.split(u.ArgParamsSeparator)[0])[0],c=n.map(o=>o.split(u.ArgParamsSeparator)[1]);return f.List+u.ArgParamsSeparator+i+u.ArgParamsSeparator+c.join(u.ArgListSeparator)}if(t.hasExactClass(We.ClassName)||e.hasClassOrSuperclass(dt.ClassName)){let n=e.getItems().map(a=>{let i=this.typedToString(a),c=i.indexOf(u.ArgParamsSeparator),o=i.substring(0,c),d=i.substring(c+1);return`${o},${d}`});return`${l.Tuple}(${n.join(",")})`}if(t.hasExactClass(Y.ClassName)||e.hasClassOrSuperclass(fe.ClassName)||t.getName()==="BigUint")return l.Biguint+u.ArgParamsSeparator+BigInt(e.valueOf().toFixed());if(t.hasExactClass(Se.ClassName)||e.hasClassOrSuperclass(Ct.ClassName))return l.Uint8+u.ArgParamsSeparator+e.valueOf().toNumber();if(t.hasExactClass(Ee.ClassName)||e.hasClassOrSuperclass(Wt.ClassName))return l.Uint16+u.ArgParamsSeparator+e.valueOf().toNumber();if(t.hasExactClass(be.ClassName)||e.hasClassOrSuperclass(Tt.ClassName))return l.Uint32+u.ArgParamsSeparator+e.valueOf().toNumber();if(t.hasExactClass(ne.ClassName)||e.hasClassOrSuperclass(Ie.ClassName))return l.Uint64+u.ArgParamsSeparator+BigInt(e.valueOf().toFixed());if(t.hasExactClass(Ae.ClassName)||e.hasClassOrSuperclass(vt.ClassName))return l.String+u.ArgParamsSeparator+e.valueOf();if(t.hasExactClass(ye.ClassName)||e.hasClassOrSuperclass(pt.ClassName))return l.Bool+u.ArgParamsSeparator+e.valueOf();if(t.hasExactClass(ge.ClassName)||e.hasClassOrSuperclass(lt.ClassName))return l.Address+u.ArgParamsSeparator+e.valueOf().toBech32();if(t.hasExactClass(ve.ClassName)||e.hasClassOrSuperclass(ut.ClassName))return l.Hex+u.ArgParamsSeparator+e.valueOf().toString("hex");if(t.getName()==="EsdtTokenPayment"){let r=e.getFieldValue("token_identifier").valueOf(),n=e.getFieldValue("token_nonce").valueOf(),a=e.getFieldValue("amount").valueOf(),c=new wt().computeExtendedIdentifier(new wr({identifier:r,nonce:BigInt(n)}));return l.Asset+u.ArgParamsSeparator+c+u.ArgCompositeSeparator+a}if(t.hasExactClass(k.ClassName)||e.hasClassOrSuperclass(te.ClassName)){let r=e,a=r.getType().getName(),i=r.getFields();if(i.length===0)return`${l.Struct}(${a})${u.ArgParamsSeparator}`;let c=i.map(o=>{let d=o.value.getType(),p=this.typedToString(o.value).split(u.ArgParamsSeparator),v=p.length>2?p.slice(2).join(u.ArgParamsSeparator):p[1]||"";return`(${o.name}${u.ArgParamsSeparator}${this.typeToString(d)})${v}`});return`${l.Struct}(${a})${u.ArgParamsSeparator}${c.join(u.ArgListSeparator)}`}if(t.hasExactClass(re.ClassName)||e.hasClassOrSuperclass(xe.ClassName))return f.Token+u.ArgParamsSeparator+e.valueOf();if(t.hasExactClass(we.ClassName)||e.hasClassOrSuperclass(mt.ClassName))return f.CodeMeta+u.ArgParamsSeparator+e.valueOf().toString();throw new Error(`WarpArgSerializer (typedToString): Unsupported input type: ${e.getClassName()}`)}typedToNative(e){let t=this.typedToString(e);return this.coreSerializer.stringToNative(t)}nativeToTyped(e,t){if(e.startsWith(l.Tuple))return this.stringToTyped(e+":");let r=this.coreSerializer.nativeToString(e,t);return this.stringToTyped(r)}nativeToType(e){if(e.startsWith(l.Tuple)){let t=e.match(/\(([^)]+)\)/)?.[1];if(!t)throw new Error(`Invalid tuple type format: ${e}`);let r=t.split(","),n=[];for(let a=0;a<r.length;a+=2)n.push(r[a]);return new We(...n.map(a=>this.nativeToType(a)))}if(e.startsWith(l.Struct)){let t=e.match(/\(([^)]+)\)/);if(!t)throw new Error("Struct type must include a name in the format struct(Name)");let r=t[1];return new k(r,[])}if(e===l.String)return new Ae;if(e===l.Uint8)return new Se;if(e===l.Uint16)return new Ee;if(e===l.Uint32)return new be;if(e===l.Uint64)return new ne;if(e===l.Biguint)return new Y;if(e===l.Bool)return new ye;if(e===l.Address)return new ge;if(e===l.Hex)return new ve;if(e===l.Asset)return new k("EsdtTokenPayment",[new ee("token_identifier","",new re),new ee("token_nonce","",new ne),new ee("amount","",new Y)]);if(e===f.Token)return new re;if(e===f.CodeMeta)return new we;throw new Error(`WarpArgSerializer (nativeToType): Unsupported input type: ${e}`)}stringToTyped(e){let[t,r]=e.split(/:(.*)/,2);if(t===l.Option){let n=this.stringToTyped(r);return n instanceof b?Ce.newMissingTyped(n.getType()):Ce.newProvided(n)}if(t===l.Vector){let n=r.indexOf(u.ArgParamsSeparator),a=r.substring(0,n),i=r.substring(n+1);if(a.startsWith(l.Tuple)){let p=i.split(",").map(v=>this.stringToTyped(v));return new ae(new _(this.nativeToType(a)),p)}if(i.includes("tuple(")){let m=this.splitTupleStrings(i),p=m.map(T=>this.stringToTyped(T)),C=m[0].match(/^(tuple\([^)]+\))/),h=C?C[1]:"tuple";return new ae(new _(this.nativeToType(h)),p)}let c=a.startsWith(l.Struct)?u.ArgStructSeparator:u.ArgListSeparator,d=i.split(c).map(m=>this.stringToTyped(`${a}:${m}`));return new ae(new _(this.nativeToType(a)),d)}if(t.startsWith(l.Tuple)){let n=t.match(/\(([^)]+)\)/)?.[1];if(!n)throw new Error(`Invalid tuple format: ${t}`);let a=n.split(","),i=[];for(let o=0;o<a.length;o+=2){let d=a[o],m=a[o+1];i.push(this.stringToTyped(`${d}:${m}`))}let c=i.map(o=>o.getType());return new dt(new We(...c),i)}if(t.startsWith(l.Struct)){let n=t.match(/\(([^)]+)\)/),a=n?n[1]:"CustomStruct";if(!r)return new te(new k(a,[]),[]);let i=r.split(u.ArgListSeparator),c=[],o=[];return i.forEach(d=>{let m=d.match(new RegExp(`^\\(([^${u.ArgParamsSeparator}]+)${u.ArgParamsSeparator}([^)]+)\\)(.+)$`));if(m){let[,p,v,C]=m,h=this.stringToTyped(`${v}${u.ArgParamsSeparator}${C}`);c.push(new ee(p,"",h.getType())),o.push(new Z(h,p))}}),new te(new k(a,c),o)}if(t===l.String)return r?vt.fromUTF8(r):new b;if(t===l.Uint8)return r?new Ct(Number(r)):new b;if(t===l.Uint16)return r?new Wt(Number(r)):new b;if(t===l.Uint32)return r?new Tt(Number(r)):new b;if(t===l.Uint64)return r?new Ie(BigInt(r)):new b;if(t===l.Biguint)return r?new fe(BigInt(r)):new b;if(t===l.Bool)return r?new pt(typeof r=="boolean"?r:r==="true"):new b;if(t===l.Address)return r?new lt(yr.newFromBech32(r)):new b;if(t===l.Hex)return r?ut.fromHex(r):new b;if(t===l.Asset){let[n,a]=r.split(u.ArgCompositeSeparator),i=new wt,c=F(n)?z(n):i.extractIdentifierFromExtendedIdentifier(n),o=F(n)?0n:i.extractNonceFromExtendedIdentifier(n);return new te(this.nativeToType("asset"),[new Z(new xe(c),"token_identifier"),new Z(new Ie(BigInt(o)),"token_nonce"),new Z(new fe(BigInt(a)),"amount")])}if(t===f.Null)return new b;if(t===f.Optional){let n=this.stringToTyped(r);return n instanceof b?Te.newMissing():new Te(n.getType(),n)}if(t===f.List){let[n,a]=r.split(Tr,2),c=a.split(u.ArgListSeparator).map(o=>this.stringToTyped(n+u.ArgParamsSeparator+o));return new ht(this.nativeToType(n),c)}if(t===f.Token)return r?new xe(r):new b;if(t===f.CodeMeta)return new mt(vr.newFromBytes(Uint8Array.from(Buffer.from(r,"hex"))));throw new Error(`WarpArgSerializer (stringToTyped): Unsupported input type: ${t}`)}splitTupleStrings(e){let t=[],r="",n=0;for(let a=0;a<e.length;a++){let i=e[a];if(i==="(")n++;else if(i===")")n--;else if(i===","&&n===0){t.push(r.trim()),r="";continue}r+=i}return r.trim()&&t.push(r.trim()),t}typeToString(e){if(e.hasExactClass(yt.ClassName))return l.Option+u.ArgParamsSeparator+this.typeToString(e.getFirstTypeParameter());if(e.hasExactClass(_.ClassName))return l.Vector+u.ArgParamsSeparator+this.typeToString(e.getFirstTypeParameter());if(e.hasExactClass(Ae.ClassName))return l.String;if(e.hasExactClass(Se.ClassName))return l.Uint8;if(e.hasExactClass(Ee.ClassName))return l.Uint16;if(e.hasExactClass(be.ClassName))return l.Uint32;if(e.hasExactClass(ne.ClassName))return l.Uint64;if(e.hasExactClass(Y.ClassName))return l.Biguint;if(e.hasExactClass(ye.ClassName))return l.Bool;if(e.hasExactClass(ge.ClassName))return l.Address;if(e.hasExactClass(ve.ClassName))return l.Hex;if(e.hasExactClass(re.ClassName))return f.Token;if(e.hasExactClass(ft.ClassName))return f.Optional+u.ArgParamsSeparator+this.typeToString(e.getFirstTypeParameter());if(e.hasExactClass(gt.ClassName))return f.List+u.ArgParamsSeparator+this.typeToString(e.getFirstTypeParameter());if(e.hasExactClass(we.ClassName))return f.CodeMeta;if(e.hasExactClass(k.ClassName)&&e.getClassName()==="EsdtTokenPayment")return l.Asset;if(e.hasExactClass(k.ClassName))return`${l.Struct}(${e.getName()})`;throw new Error(`WarpArgSerializer (typeToString): Unsupported input type: ${e.getClassName()}`)}};var O=class{constructor(e,t,r){this.config=e;this.chain=t;this.typeRegistry=r;this.abi=new P(e,t),this.serializer=new B({typeRegistry:this.typeRegistry}),this.cache=new Br(e.cache?.type)}async getActionExecution(e,t,r){let n=this.cache.get(Nr.WarpExecutable(this.config.env,e.meta?.hash||"",t))??[],a=await this.extractContractOutput(e,t,r,n),i=Ir(this.config,[],e,t,a.output),c=Er(e,a.output,this.config),o=br(n);return{status:r.status.isSuccessful()?"success":"error",warp:e,action:t,user:Pr(this.config,this.chain.name),txHash:r.hash,tx:r,next:i,values:a.values,output:a.output,messages:c,destination:null,resolvedInputs:o}}async extractContractOutput(e,t,r,n){let a=Sr(e,t),i=[],c=[],o={};if(!e.output||a.type!=="contract")return{values:{string:i,native:c,mapped:{}},output:o};if(!Object.values(e.output).some(h=>h.includes("out")||h.includes("event"))){for(let[h,T]of Object.entries(e.output))o[h]=T;return{values:{string:i,native:c,mapped:{}},output:await ie(e,o,t,n,this.serializer.coreSerializer,this.config)}}let m=await this.abi.getAbiForAction(a),p=new xr({abi:m}),C=new Ar({abi:m}).parseExecute({transactionOnNetwork:r,function:a.func||void 0});for(let[h,T]of Object.entries(e.output)){if(T.startsWith(xt.Transform.Prefix))continue;if(T.startsWith("input.")){o[h]=T;continue}let x=At(T);if(x!==null&&x!==t){o[h]=null;continue}let[I,N,V]=T.split(".");if(I==="event"){if(!N||isNaN(Number(V)))continue;let S=Number(V),g=Cr(r,N),kt=p.parseEvents({events:g})[0],L=Object.values(kt)[S]||null;i.push(String(L)),c.push(L),o[h]=L&&L.valueOf()}else if(I==="out"||I.startsWith("out[")){if(!N)continue;let S=Number(N),g=C.values[S-1]||null;V&&(g=g[V]||null),g&&typeof g=="object"&&(g="toFixed"in g?g.toFixed():g.valueOf()),i.push(String(g)),c.push(g),o[h]=g&&g.valueOf()}else o[h]=T}return{values:{string:i,native:c,mapped:{}},output:await ie(e,o,t,n,this.serializer.coreSerializer,this.config)}}async extractQueryOutput(e,t,r,n){let a=t.map(m=>this.serializer.typedToString(m)),i=t.map(m=>this.serializer.typedToNative(m)[1]),c={string:a,native:i,mapped:{}},o={};if(!e.output)return{values:c,output:o};let d=m=>{let p=m.split(".").slice(1).map(C=>parseInt(C)-1);if(p.length===0)return;let v=i[p[0]];for(let C=1;C<p.length;C++){if(v==null)return;v=v[p[C]]}return v};for(let[m,p]of Object.entries(e.output)){if(p.startsWith(xt.Transform.Prefix))continue;let v=At(p);if(v!==null&&v!==r){o[m]=null;continue}p.startsWith("out.")||p==="out"||p.startsWith("out[")?o[m]=d(p)||null:o[m]=p}return o=await ie(e,o,r,n,this.serializer.coreSerializer,this.config),{values:c,output:o}}async resolveWarpOutputRecursively(e){let t=e.warp,r=e.entryActionIndex,n=e.executor,a=e.inputs,i=e.meta,c=new Map,o=new Set,d=this;async function m(h,T=[]){if(c.has(h))return c.get(h);if(o.has(h))throw new Error(`Circular dependency detected at action ${h}`);o.add(h);let x=t.actions[h-1];if(!x)throw new Error(`Action ${h} not found`);let I;if(x.type==="query")I=await n.executeQuery(t,h,T);else if(x.type==="collect")I=await n.executeCollect(t,h,T,i);else throw new Error(`Unsupported or interactive action type: ${x.type}`);if(c.set(h,I),t.output)for(let N of Object.values(t.output)){let S=String(N).match(/^out\[(\d+)\]/);if(S){let g=parseInt(S[1],10);g!==h&&!c.has(g)&&await m(g)}}return o.delete(h),I}await m(r,a);let p={};for(let h of c.values())for(let[T,x]of Object.entries(h.output))x!==null?p[T]=x:T in p||(p[T]=null);let v=await ie(t,p,r,a,this.serializer.coreSerializer,this.config);return{...c.get(r),action:r,output:v}}};var _r="EGLD-000000",se=class{constructor(e,t,r){this.config=e;this.chain=t;this.typeRegistry=r;this.serializer=new B({typeRegistry:this.typeRegistry}),this.abi=new P(this.config,this.chain),this.output=new O(this.config,this.chain,this.typeRegistry)}async createTransaction(e){let t=Pe(e.warp,e.action),r=null;if(t.type==="transfer")r=await this.createTransferTransaction(e);else if(t.type==="contract")r=await this.createContractCallTransaction(e);else{if(t.type==="query")throw new Error("WarpMultiversxExecutor: Invalid action type for createTransactionForExecute; Use executeQuery instead");if(t.type==="collect")throw new Error("WarpMultiversxExecutor: Invalid action type for createTransactionForExecute; Use executeCollect instead")}if(!r)throw new Error(`WarpMultiversxExecutor: Invalid action type (${t.type})`);return r}async createTransferTransaction(e){if(!e.destination)throw new Error("WarpMultiversxExecutor: createTransfer - destination not set");let t=Be(this.config,e.chain.name);if(!t)throw new Error("WarpMultiversxExecutor: createTransfer - user address not set");let r=$.newFromBech32(t),n=new Et({chainID:e.chain.chainId}),a=e.data?Buffer.from(this.serializer.stringToTyped(e.data).valueOf()):null,i=e.transfers.length===1&&e.transfers[0].identifier===this.chain.nativeToken?.identifier,o=(i?e.transfers[0].amount:0n)+e.value;return await new Mr({config:n}).createTransactionForTransfer(r,{receiver:$.newFromBech32(e.destination),nativeAmount:o,tokenTransfers:i?[]:this.toTokenTransfers(e.transfers),data:a?new Uint8Array(a):void 0})}async createContractCallTransaction(e){if(!e.destination)throw new Error("WarpMultiversxExecutor: createContractCall - destination not set");let t=Be(this.config,e.chain.name);if(!t)throw new Error("WarpMultiversxExecutor: createContractCall - user address not set");let r=Pe(e.warp,e.action),n=$.newFromBech32(t),a=e.args.map(c=>this.serializer.stringToTyped(c)),i=new Et({chainID:e.chain.chainId});return new Ur({config:i}).createTransactionForExecute(n,{contract:$.newFromBech32(e.destination),function:"func"in r&&r.func||"",gasLimit:"gasLimit"in r?BigInt(r.gasLimit||0):0n,arguments:a,tokenTransfers:this.toTokenTransfers(e.transfers),nativeTransferAmount:e.value})}async executeQuery(e){if(!e.destination)throw new Error("WarpMultiversxExecutor: executeQuery - destination not set");let t=Pe(e.warp,e.action);if(t.type!=="query")throw new Error(`WarpMultiversxExecutor: Invalid action type for executeQuery: ${t.type}`);let r=await this.abi.getAbiForAction(t),n=e.args.map(g=>this.serializer.stringToTyped(g)),a=w(e.chain,this.config.env,this.config),i=$.newFromBech32(e.destination),c=a.createSmartContractController(r),o=c.createQuery({contract:i,function:t.func||"",arguments:n}),d=await c.runQuery(o),m=d.returnCode==="ok",p=new Vr,v=r.getEndpoint(d.function||t.func||""),C=(d.returnDataParts||[]).map(g=>Buffer.from(g)),h=p.buffersToValues(C,v.output),{values:T,output:x}=await this.output.extractQueryOutput(e.warp,h,e.action,e.resolvedInputs),I=Lr(this.config,[],e.warp,e.action,x),V=e.resolvedInputs.find(g=>g.input.position==="receiver"||g.input.position==="destination")?.value||e.destination,S=Dr(e.resolvedInputs);return{status:m?"success":"error",warp:e.warp,action:e.action,user:Be(this.config,e.chain.name),txHash:null,tx:null,next:I,values:T,output:{...x,_DATA:h},messages:Rr(e.warp,x,this.config),destination:V,resolvedInputs:S}}toTokenTransfers(e){return e.map(t=>t.identifier===this.chain.nativeToken.identifier?{...t,identifier:_r}:t).map(t=>{let n=new Fr().extractNonceFromExtendedIdentifier(t.identifier);return new Or({token:new kr({identifier:t.identifier,nonce:BigInt(n||0)}),amount:t.amount})})}};var oe=class{constructor(e,t){this.chain=e;this.config=t}getExplorers(){let e=ct[this.chain];if(!e)return["multiversx_explorer"];let t=e[this.config.env];return t||["multiversx_explorer"]}getPrimaryExplorer(){return this.getExplorers()[0]}getExplorerUrlByName(e){let t=this.config.preferences?.explorers?.[this.chain];if(t&&!e){let a=U[t];if(a)return a}if(e){let a=U[e];if(a)return a}let r=this.getPrimaryExplorer();return U[r]||U[r]}getAccountUrl(e,t){return`${this.getExplorerUrlByName(t)}/accounts/${e}`}getTransactionUrl(e,t){return`${this.getExplorerUrlByName(t)}/transactions/${e}`}getBlockUrl(e,t){return`${this.getExplorerUrlByName(t)}/blocks/${e}`}getAssetUrl(e,t){return`${this.getExplorerUrlByName(t)}/tokens/${e}`}getContractUrl(e,t){return`${this.getExplorerUrlByName(t)}/accounts/${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(n=>{let a=U[n];a&&(r[n]=`${a}/accounts/${e}`)}),r}getTransactionUrls(e){let t=this.getAllExplorers(),r={};return t.forEach(n=>{let a=U[n];a&&(r[n]=`${a}/transactions/${e}`)}),r}};import{AbiRegistry as It,Address as y,AddressValue as Ve,BytesValue as W,SmartContractTransactionsFactory as Gr,TransactionsFactoryConfig as Hr}from"@multiversx/sdk-core";import{createWarpIdentifier as Kr,getWarpWalletAddressFromConfig as zr,WarpCache as qr,WarpCacheKey as Ue,WarpLogger as ke}from"@vleap/warps";var Ne={buildInfo:{rustc:{version:"1.86.0",commitHash:"05f9846f893b09a1be1fc8560e33fc3c815cfecb",commitDate:"2025-03-31",channel:"Stable",short:"rustc 1.86.0 (05f9846f8 2025-03-31)"},contractCrate:{name:"registry",version:"0.0.1"},framework:{name:"multiversx-sc",version:"0.51.1"}},name:"RegistryContract",constructor:{inputs:[{name:"unit_price",type:"BigUint"},{name:"vault",type:"Address"}],outputs:[]},upgradeConstructor:{inputs:[],outputs:[]},endpoints:[{name:"registerWarp",mutability:"mutable",payableInTokens:["EGLD"],inputs:[{name:"hash",type:"bytes"},{name:"alias_opt",type:"optional<bytes>",multi_arg:!0},{name:"brand_opt",type:"optional<bytes>",multi_arg:!0}],outputs:[],allow_multiple_var_args:!0},{name:"unregisterWarp",mutability:"mutable",inputs:[{name:"warp",type:"bytes"}],outputs:[]},{name:"upgradeWarp",mutability:"mutable",payableInTokens:["EGLD"],inputs:[{name:"alias",type:"bytes"},{name:"new_warp",type:"bytes"},{name:"brand_opt",type:"optional<bytes>",multi_arg:!0}],outputs:[]},{name:"setWarpAlias",mutability:"mutable",payableInTokens:["EGLD"],inputs:[{name:"hash",type:"bytes"},{name:"alias",type:"bytes"}],outputs:[]},{name:"forceRemoveAlias",mutability:"mutable",inputs:[{name:"hash",type:"bytes"}],outputs:[]},{name:"verifyWarp",mutability:"mutable",inputs:[{name:"warp",type:"bytes"}],outputs:[]},{name:"transferOwnership",mutability:"mutable",inputs:[{name:"warp",type:"bytes"},{name:"new_owner",type:"Address"}],outputs:[]},{name:"getUserWarps",mutability:"readonly",inputs:[{name:"address",type:"Address"}],outputs:[{type:"variadic<InfoView>",multi_result:!0}]},{name:"getInfoByAlias",mutability:"readonly",inputs:[{name:"alias",type:"bytes"}],outputs:[{type:"InfoView"}]},{name:"getInfoByHash",mutability:"readonly",inputs:[{name:"hash",type:"bytes"}],outputs:[{type:"InfoView"}]},{name:"setVault",onlyOwner:!0,mutability:"mutable",inputs:[{name:"vault",type:"Address"}],outputs:[]},{name:"setUnitPrice",onlyOwner:!0,mutability:"mutable",inputs:[{name:"amount",type:"BigUint"}],outputs:[]},{name:"addAdmin",onlyOwner:!0,mutability:"mutable",inputs:[{name:"address",type:"Address"}],outputs:[]},{name:"removeAdmin",onlyOwner:!0,mutability:"mutable",inputs:[{name:"address",type:"Address"}],outputs:[]},{name:"getConfig",mutability:"readonly",inputs:[],outputs:[{type:"ConfigView"}]},{name:"registerBrand",mutability:"mutable",payableInTokens:["EGLD"],inputs:[{name:"hash",type:"bytes"}],outputs:[]},{name:"brandWarp",mutability:"mutable",payableInTokens:["EGLD"],inputs:[{name:"warp",type:"bytes"},{name:"brand",type:"bytes"}],outputs:[]},{name:"getUserBrands",mutability:"readonly",inputs:[{name:"user",type:"Address"}],outputs:[{type:"variadic<bytes>",multi_result:!0}]}],events:[{identifier:"warpRegistered",inputs:[{name:"hash",type:"bytes",indexed:!0},{name:"alias",type:"bytes",indexed:!0},{name:"trust",type:"bytes",indexed:!0}]},{identifier:"warpUnregistered",inputs:[{name:"hash",type:"bytes",indexed:!0}]},{identifier:"warpUpgraded",inputs:[{name:"alias",type:"bytes",indexed:!0},{name:"new_warp",type:"bytes",indexed:!0},{name:"trust",type:"bytes",indexed:!0}]},{identifier:"warpVerified",inputs:[{name:"hash",type:"bytes",indexed:!0}]},{identifier:"aliasUpdated",inputs:[{name:"hash",type:"bytes",indexed:!0},{name:"alias",type:"bytes",indexed:!0}]},{identifier:"ownershipTransferred",inputs:[{name:"warp",type:"bytes",indexed:!0},{name:"old_owner",type:"Address",indexed:!0},{name:"new_owner",type:"Address",indexed:!0}]}],esdtAttributes:[],hasCallback:!1,types:{ConfigView:{type:"struct",fields:[{name:"unit_price",type:"BigUint"},{name:"admins",type:"List<Address>"}]},InfoView:{type:"struct",fields:[{name:"hash",type:"bytes"},{name:"alias",type:"Option<bytes>"},{name:"trust",type:"bytes"},{name:"owner",type:"Address"},{name:"created_at",type:"u64"},{name:"upgraded_at",type:"u64"},{name:"brand",type:"Option<bytes>"},{name:"upgrade",type:"Option<bytes>"}]}}};var E=s=>{if(s==="devnet")return"erd1qqqqqqqqqqqqqpgqje2f99vr6r7sk54thg03c9suzcvwr4nfl3tsfkdl36";if(s==="testnet")throw new Error("Multiversx testnet is not supported");return"erd1qqqqqqqqqqqqqpgq3mrpj3u6q7tejv6d7eqhnyd27n9v5c5tl3ts08mffe"};var ce=s=>({hash:s.hash.toString("hex"),alias:s.alias?.toString()||null,trust:s.trust.toString(),owner:s.owner.toString(),createdAt:s.created_at.toNumber(),upgradedAt:s.upgraded_at?.toNumber(),brand:s.brand?.toString("hex")||null,upgrade:s.upgrade?.toString("hex")||null}),bt=s=>({unitPrice:BigInt(s.unit_price.toString()),admins:s.admins.map(e=>e.toBech32())});var le=class{constructor(e,t){this.config=e;this.chain=t;this.cache=new qr(e.cache?.type),this.registryConfig={unitPrice:BigInt(0),admins:[]},this.userWallet=zr(this.config,this.chain.name)}async init(){await this.loadRegistryConfigs()}getRegistryConfig(){return this.registryConfig}async createWarpRegisterTransaction(e,t,r){if(this.registryConfig.unitPrice===BigInt(0))throw new Error("WarpRegistry: config not loaded. forgot to call init()?");if(!this.userWallet)throw new Error("WarpRegistry: user address not set");let n=y.newFromBech32(this.userWallet),a=()=>this.isCurrentUserAdmin()?BigInt(0):t&&r?this.registryConfig.unitPrice*BigInt(3):t?this.registryConfig.unitPrice*BigInt(2):this.registryConfig.unitPrice,i=()=>t&&r?[W.fromHex(e),W.fromUTF8(t),W.fromHex(r)]:t?[W.fromHex(e),W.fromUTF8(t)]:[W.fromHex(e)];return await this.getFactory().createTransactionForExecute(n,{contract:y.newFromBech32(E(this.config.env)),function:"registerWarp",gasLimit:BigInt(1e7),nativeTransferAmount:a(),arguments:i()})}async createWarpUnregisterTransaction(e){if(!this.userWallet)throw new Error("WarpRegistry: user address not set");let t=y.newFromBech32(this.userWallet);return await this.getFactory().createTransactionForExecute(t,{contract:y.newFromBech32(E(this.config.env)),function:"unregisterWarp",gasLimit:BigInt(1e7),arguments:[W.fromHex(e)]})}async createWarpUpgradeTransaction(e,t,r){if(this.registryConfig.unitPrice===BigInt(0))throw new Error("WarpRegistry: config not loaded. forgot to call init()?");if(!this.userWallet)throw new Error("WarpRegistry: user address not set");let n=y.newFromBech32(this.userWallet);return await this.getFactory().createTransactionForExecute(n,{contract:y.newFromBech32(E(this.config.env)),function:"upgradeWarp",gasLimit:BigInt(1e7),nativeTransferAmount:this.isCurrentUserAdmin()?void 0:this.registryConfig.unitPrice,arguments:r?[W.fromUTF8(e),W.fromHex(t),W.fromHex(r)]:[W.fromUTF8(e),W.fromHex(t)]})}async createWarpAliasSetTransaction(e,t){if(!this.userWallet)throw new Error("WarpRegistry: user address not set");let r=y.newFromBech32(this.userWallet);return await this.getFactory().createTransactionForExecute(r,{contract:y.newFromBech32(E(this.config.env)),function:"setWarpAlias",gasLimit:BigInt(1e7),nativeTransferAmount:this.isCurrentUserAdmin()?void 0:this.registryConfig.unitPrice,arguments:[W.fromHex(e),W.fromUTF8(t)]})}async createWarpVerifyTransaction(e){if(!this.userWallet)throw new Error("WarpRegistry: user address not set");let t=y.newFromBech32(this.userWallet);return await this.getFactory().createTransactionForExecute(t,{contract:y.newFromBech32(E(this.config.env)),function:"verifyWarp",gasLimit:BigInt(1e7),arguments:[W.fromHex(e)]})}async createWarpTransferOwnershipTransaction(e,t){if(!this.userWallet)throw new Error("WarpRegistry: user address not set");let r=y.newFromBech32(this.userWallet);return await this.getFactory().createTransactionForExecute(r,{contract:y.newFromBech32(E(this.config.env)),function:"transferOwnership",gasLimit:BigInt(1e7),arguments:[W.fromHex(e),new Ve(new y(t))]})}async createBrandRegisterTransaction(e){if(this.registryConfig.unitPrice===BigInt(0))throw new Error("WarpRegistry: config not loaded. forgot to call init()?");if(!this.userWallet)throw new Error("WarpRegistry: user address not set");let t=y.newFromBech32(this.userWallet);return await this.getFactory().createTransactionForExecute(t,{contract:y.newFromBech32(E(this.config.env)),function:"registerBrand",gasLimit:BigInt(1e7),nativeTransferAmount:this.isCurrentUserAdmin()?void 0:this.registryConfig.unitPrice,arguments:[W.fromHex(e)]})}async createWarpBrandingTransaction(e,t){if(!this.userWallet)throw new Error("WarpRegistry: user address not set");let r=y.newFromBech32(this.userWallet);return await this.getFactory().createTransactionForExecute(r,{contract:y.newFromBech32(E(this.config.env)),function:"brandWarp",gasLimit:BigInt(1e7),nativeTransferAmount:this.isCurrentUserAdmin()?void 0:this.registryConfig.unitPrice,arguments:[W.fromHex(e),W.fromHex(t)]})}async getInfoByAlias(e,t){try{let r=Ue.RegistryInfo(this.config.env,e),n=t?this.cache.get(r):null;if(n)return ke.info(`WarpRegistry (getInfoByAlias): RegistryInfo found in cache: ${e}`),n;let a=y.newFromBech32(E(this.config.env)),i=this.getController(),c=i.createQuery({contract:a,function:"getInfoByAlias",arguments:[W.fromUTF8(e)]}),o=await i.runQuery(c),[d]=i.parseQueryResponse(o),m=d?ce(d):null,p=m?.brand?await this.fetchBrand(m.brand):null;return t&&t.ttl&&this.cache.set(r,{registryInfo:m,brand:p},t.ttl),{registryInfo:m,brand:p}}catch{return{registryInfo:null,brand:null}}}async getInfoByHash(e,t){try{let r=Ue.RegistryInfo(this.config.env,e);if(t){let p=this.cache.get(r);if(p)return ke.info(`WarpRegistry (getInfoByHash): RegistryInfo found in cache: ${e}`),p}let n=y.newFromBech32(E(this.config.env)),a=this.getController(),i=a.createQuery({contract:n,function:"getInfoByHash",arguments:[W.fromHex(e)]}),c=await a.runQuery(i),[o]=a.parseQueryResponse(c),d=o?ce(o):null,m=d?.brand?await this.fetchBrand(d.brand):null;return t&&t.ttl&&this.cache.set(r,{registryInfo:d,brand:m},t.ttl),{registryInfo:d,brand:m}}catch{return{registryInfo:null,brand:null}}}async getUserWarpRegistryInfos(e){try{let t=e||this.userWallet;if(!t)throw new Error("WarpRegistry: user address not set");let r=y.newFromBech32(E(this.config.env)),n=this.getController(),a=n.createQuery({contract:r,function:"getUserWarps",arguments:[new Ve(new y(t))]}),i=await n.runQuery(a),[c]=n.parseQueryResponse(i);return c.map(ce)}catch{return[]}}async getUserBrands(e){try{let t=e||this.userWallet;if(!t)throw new Error("WarpRegistry: user address not set");let r=y.newFromBech32(E(this.config.env)),n=this.getController(),a=n.createQuery({contract:r,function:"getUserBrands",arguments:[new Ve(new y(t))]}),i=await n.runQuery(a),[c]=n.parseQueryResponse(i),o=c.map(p=>p.toString("hex")),d={ttl:365*24*60*60};return(await Promise.all(o.map(p=>this.fetchBrand(p,d)))).filter(p=>p!==null)}catch{return[]}}async fetchBrand(e,t){let r=Ue.Brand(this.config.env,e),n=t?this.cache.get(r):null;if(n)return ke.info(`WarpRegistry (fetchBrand): Brand found in cache: ${e}`),n;let i=w(this.chain,this.config.env,this.config).createNetworkProvider();try{let c=await i.getTransaction(e),o=JSON.parse(c.data.toString());return o.meta={query:null,chain:this.chain.name,identifier:Kr(this.chain.name,"hash",e),hash:c.hash,creator:c.sender.toBech32(),createdAt:new Date(c.timestamp*1e3).toISOString()},t&&t.ttl&&this.cache.set(r,o,t.ttl),o}catch{return null}}async loadRegistryConfigs(){let e=y.newFromBech32(E(this.config.env)),t=this.getController(),[r]=await t.query({contract:e,function:"getConfig",arguments:[]}),n=r?bt(r):null;this.registryConfig=n||{unitPrice:BigInt(0),admins:[]}}getFactory(){let e=new Hr({chainID:this.chain.chainId}),t=It.create(Ne);return new Gr({config:e,abi:t})}getController(){let e=w(this.chain,this.config.env,this.config),t=It.create(Ne);return e.createSmartContractController(t)}isCurrentUserAdmin(){return!!this.userWallet&&this.registryConfig.admins.includes(this.userWallet)}};import{Address as nn}from"@multiversx/sdk-core";import{CacheTtl as St,initializeWalletCache as an,WarpCache as sn}from"@vleap/warps";import{Account as jr,Message as Qr,Mnemonic as Fe}from"@multiversx/sdk-core";import{getWarpWalletAddressFromConfig as Xr,getWarpWalletMnemonicFromConfig as Jr}from"@vleap/warps";var G=class G{constructor(e,t){this.config=e;this.chain=t;this.account=null}async getAddress(){let e=Xr(this.config,this.chain.name);if(e)return e;try{return this.getAccount().address.toBech32()}catch{return null}}async getPublicKey(){try{return this.getAccount().publicKey.hex()}catch{return null}}async signTransaction(e){return await this.getAccount().signTransaction(e),e}async signMessage(e){let t=this.getAccount(),r=new TextEncoder().encode(e),n=await t.signMessage(new Qr({data:r}));return Buffer.from(n).toString("hex")}getAccountInstance(){return this.getAccount()}create(e){let a=Fe.fromString(e).deriveKey(0).generatePublicKey().toAddress(this.chain.addressHrp).toBech32();return{provider:G.PROVIDER_NAME,address:a,privateKey:null,mnemonic:e}}generate(){let e=Fe.generate(),t=e.toString(),a=e.deriveKey(0).generatePublicKey().toAddress(this.chain.addressHrp).toBech32();return{provider:G.PROVIDER_NAME,address:a,privateKey:null,mnemonic:t}}getAccount(){if(this.account)return this.account;let e=Jr(this.config,this.chain.name);if(!e)throw new Error("No mnemonic provided");let r=Fe.fromString(e).deriveKey(0);return this.account=new jr(r),this.account}};G.PROVIDER_NAME="mnemonic";var M=G;import{Account as Yr,Message as Zr,Mnemonic as en,UserSecretKey as Oe}from"@multiversx/sdk-core";import{getWarpWalletAddressFromConfig as tn,getWarpWalletPrivateKeyFromConfig as rn}from"@vleap/warps";var H=class H{constructor(e,t){this.config=e;this.chain=t;this.account=null}async getAddress(){let e=tn(this.config,this.chain.name);if(e)return e;try{return this.getAccount().address.toBech32()}catch{return null}}async getPublicKey(){try{return this.getAccount().publicKey.hex()}catch{return null}}async signTransaction(e){return await this.getAccount().signTransaction(e),e}async signMessage(e){let t=this.getAccount(),r=new TextEncoder().encode(e),n=await t.signMessage(new Zr({data:r}));return Buffer.from(n).toString("hex")}getAccountInstance(){return this.getAccount()}create(e){let r=en.fromString(e).deriveKey(0),n=r.hex(),i=r.generatePublicKey().toAddress(this.chain.addressHrp).toBech32();return{provider:H.PROVIDER_NAME,address:i,privateKey:n,mnemonic:null}}generate(){let e=Oe.generate(),t=e.hex(),n=e.generatePublicKey().toAddress(this.chain.addressHrp).toBech32();return{provider:H.PROVIDER_NAME,address:n,privateKey:t,mnemonic:null}}getAccount(){if(this.account)return this.account;let e=rn(this.config,this.chain.name);if(!e)throw new Error("No private key provided");let r=e.startsWith("-----")?Oe.fromPem(e):Oe.fromString(e);return this.account=new Yr(r),this.account}};H.PROVIDER_NAME="privateKey";var R=H;import{getWarpWalletAddressFromConfig as Me}from"@vleap/warps";var D=class{constructor(e,t){this.config=e;this.chain=t}async getAddress(){return Me(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}`)}create(e){let t=Me(this.config,this.chain.name);throw new Error(`Wallet can not be used for signing: ${t}`)}generate(){let e=Me(this.config,this.chain.name);throw new Error(`Wallet can not be used for signing: ${e}`)}};var pe=class{constructor(e,t){this.config=e;this.chain=t;this.cachedAddress=null;this.cachedPublicKey=null;this.entry=w(t,e.env,e),this.cache=new sn(e.cache?.type),this.walletProvider=this.createProvider(),this.initializeCache()}async signTransaction(e){if(!e||typeof e!="object")throw new Error("Invalid transaction object");if(!this.walletProvider)throw new Error("No wallet provider available");if(this.walletProvider instanceof D)throw new Error(`Wallet (${this.chain.name}) is read-only`);if(this.walletProvider instanceof R||this.walletProvider instanceof M){let r=this.walletProvider.getAccountInstance();if(e.nonce===0n){let n=await this.entry.recallAccountNonce(r.address),a=this.cache.get(`nonce:${r.address.toBech32()}`)||0,i=BigInt(Math.max(a,Number(n)));e.nonce=i}}else if(e.nonce===0n&&this.cachedAddress){let r=nn.newFromBech32(this.cachedAddress),n=await this.entry.recallAccountNonce(r),a=this.cache.get(`nonce:${this.cachedAddress}`)||0,i=BigInt(Math.max(a,Number(n)));e.nonce=i}let t=await this.walletProvider.signTransaction(e);if(this.walletProvider instanceof R||this.walletProvider instanceof M){let r=this.walletProvider.getAccountInstance(),n=Number(r.nonce)+1;this.cache.set(`nonce:${r.address.toBech32()}`,n,St.OneMinute)}else if(this.cachedAddress){let r=e.nonce?Number(e.nonce):0;this.cache.set(`nonce:${this.cachedAddress}`,r+1,St.OneMinute)}return t}async signTransactions(e){let t=[];for(let r of e)t.push(await this.signTransaction(r));return t}async signMessage(e){if(!this.walletProvider)throw new Error("No wallet provider available");if(this.walletProvider instanceof D)throw new Error(`Wallet (${this.chain.name}) is read-only`);return await this.walletProvider.signMessage(e)}async sendTransactions(e){return Promise.all(e.map(async t=>this.sendTransaction(t)))}async sendTransaction(e){if(!e||typeof e!="object")throw new Error("Invalid transaction object");if(!e.signature)throw new Error("Transaction must be signed before sending");return await this.entry.sendTransaction(e)}create(e,t){return this.createProviderForOperation(e).create(t)}generate(e){return this.createProviderForOperation(e).generate()}getAddress(){return this.cachedAddress}getPublicKey(){return this.cachedPublicKey}createProvider(){let e=this.config.user?.wallets?.[this.chain.name];return e?typeof e=="string"?new D(this.config,this.chain):this.createProviderForOperation(e.provider):null}initializeCache(){an(this.walletProvider).then(e=>{this.cachedAddress=e.address,this.cachedPublicKey=e.publicKey})}createProviderForOperation(e){let r=this.config.walletProviders?.[this.chain.name]?.[e];if(r){let n=r(this.config,this.chain);if(!n)throw new Error(`Custom wallet provider factory returned null for ${e}`);return n}if(e==="privateKey")return new R(this.config,this.chain);if(e==="mnemonic")return new M(this.config,this.chain);throw new Error(`Unsupported wallet provider for ${this.chain.name}: ${e}`)}};var ue=(s,e)=>(t,r)=>{let n=e[t.env],a=new on;return a.registerType("token",{stringToNative:i=>i,nativeToString:i=>`token:${i}`}),a.registerType("codemeta",{stringToNative:i=>i,nativeToString:i=>`codemeta:${i}`}),a.registerTypeAlias("list","vector"),{chainInfo:n,builder:()=>new Q(t,n),executor:new se(t,n,a),output:new O(t,n,a),serializer:new B({typeRegistry:a}),registry:new le(t,n),explorer:new oe(s,t),abiBuilder:()=>new P(t,n),brandBuilder:()=>new j(t,n),dataLoader:new J(t,n),wallet:new pe(t,n)}};import{WarpChainName as K}from"@vleap/warps";var Re={chain:K.Multiversx,identifier:"EGLD",name:"eGold",symbol:"EGLD",decimals:18,logoUrl:"https://joai.ai/images/tokens/egld.svg"},Pt=ue(K.Multiversx,{mainnet:{name:K.Multiversx,displayName:"MultiversX",chainId:"1",blockTime:6e3,addressHrp:"erd",defaultApiUrl:"https://api.multiversx.com",logoUrl:"https://joai.ai/images/chains/multiversx.svg",nativeToken:Re},testnet:{name:K.Multiversx,displayName:"MultiversX Testnet",chainId:"T",blockTime:6e3,addressHrp:"erd",defaultApiUrl:"https://testnet-api.multiversx.com",logoUrl:"https://joai.ai/images/chains/multiversx.svg",nativeToken:Re},devnet:{name:K.Multiversx,displayName:"MultiversX Devnet",chainId:"D",blockTime:6e3,addressHrp:"erd",defaultApiUrl:"https://devnet-api.multiversx.com",logoUrl:"https://joai.ai/images/chains/multiversx.svg",nativeToken:Re}});import{WarpChainName as Le}from"@vleap/warps";var cn={chain:Le.Vibechain,identifier:"VIBE",name:"VIBE",symbol:"VIBE",decimals:18,logoUrl:"https://joai.ai/images/tokens/vibe.svg"},De={name:Le.Vibechain,displayName:"VibeChain",chainId:"V",blockTime:600,addressHrp:"vibe",defaultApiUrl:"https://vibeox-api.multiversx.com",logoUrl:"https://joai.ai/images/chains/vibechain.svg",nativeToken:cn},Bt=ue(Le.Vibechain,{mainnet:De,testnet:De,devnet:De});var Ho=()=>[Pt,Bt];import{WarpConstants as me,WarpSerializer as _e}from"@vleap/warps";var Qo=s=>new _e().nativeToString(f.Token,s),Xo=s=>new _e().nativeToString(f.CodeMeta,s),Jo=(s,e)=>{if(e===null)return f.Optional+me.ArgParamsSeparator;let t=s(e),r=t.indexOf(me.ArgParamsSeparator),n=t.substring(0,r),a=t.substring(r+1);return f.Optional+me.ArgParamsSeparator+n+me.ArgParamsSeparator+a},Yo=s=>new _e().nativeToString(f.List,s);import{Address as ln,AddressValue as pn,BigUIntType as un,BigUIntValue as Nt,BooleanValue as mn,BytesValue as dn,CodeMetadata as hn,CodeMetadataValue as gn,CompositeType as fn,CompositeValue as yn,Field as $e,FieldDefinition as Ge,List as vn,NothingValue as wn,OptionalValue as He,OptionValue as Ke,StringValue as Wn,Struct as Tn,StructType as Cn,TokenIdentifierType as An,TokenIdentifierValue as Vt,U16Value as xn,U32Value as En,U64Type as bn,U64Value as Ut,U8Value as In,VariadicValue as Sn}from"@multiversx/sdk-core";var ac=(s,e)=>s?Ke.newProvided(s):e?Ke.newMissingTyped(e):Ke.newMissing(),ic=(s,e)=>s?new He(s.getType(),s):e?new He(e):He.newMissing(),sc=s=>{if(s.length===0)throw new Error("Cannot create a list from an empty array");let e=s[0].getType();return new vn(e,s)},oc=s=>Sn.fromItems(...s),cc=s=>{let e=s.map(t=>t.getType());return new yn(new fn(...e),s)},lc=s=>Wn.fromUTF8(s),pc=s=>new In(s),uc=s=>new xn(s),mc=s=>new En(s),dc=s=>new Ut(s),hc=s=>new Nt(BigInt(s)),gc=s=>new mn(s),fc=s=>new pn(ln.newFromBech32(s)),yc=s=>new Vt(s),vc=s=>dn.fromHex(s),wc=s=>new Tn(new Cn("EsdtTokenPayment",[new Ge("token_identifier","",new An),new Ge("token_nonce","",new bn),new Ge("amount","",new un)]),[new $e(new Vt(s.token.identifier),"token_identifier"),new $e(new Ut(BigInt(s.token.nonce)),"token_nonce"),new $e(new Nt(BigInt(s.amount)),"amount")]),Wc=s=>new gn(hn.newFromBytes(Uint8Array.from(Buffer.from(s,"hex")))),Tc=()=>new wn;export{U as ExplorerUrls,st as KnownTokens,Pt as MultiversxAdapter,gr as MultiversxExplorers,ct as MultiversxExplorersConfig,Re as NativeTokenEgld,cn as NativeTokenVibe,Bt as VibechainAdapter,fr as VibechainExplorers,P as WarpMultiversxAbiBuilder,j as WarpMultiversxBrandBuilder,Q as WarpMultiversxBuilder,ui as WarpMultiversxConstants,q as WarpMultiversxContractLoader,J as WarpMultiversxDataLoader,se as WarpMultiversxExecutor,oe as WarpMultiversxExplorer,f as WarpMultiversxInputTypes,O as WarpMultiversxOutput,le as WarpMultiversxRegistry,B as WarpMultiversxSerializer,pe as WarpMultiversxWallet,fc as address_value,wc as asset_value,hc as biguint_value,gc as boolean_value,Xo as codemeta,Wc as codemeta_value,cc as composite_value,ue as createMultiversxAdapter,ot as findKnownTokenById,Ho as getAllMultiversxAdapters,Nn as getAllMultiversxChainNames,ja as getKnownTokensForChain,w as getMultiversxEntrypoint,E as getMultiversxRegistryAddress,z as getNormalizedTokenIdentifier,vc as hex_value,F as isNativeToken,Yo as list,sc as list_value,Tc as nothing_value,ac as option_value,Jo as optional,ic as optional_value,lc as string_value,bt as toTypedConfigInfo,ce as toTypedRegistryInfo,Qo as token,yc as token_value,uc as u16_value,mc as u32_value,dc as u64_value,pc as u8_value,oc as variadic_value};
1
+ import{WarpChainName as ze}from"@vleap/warps";var Fn=()=>[ze.Multiversx,ze.Vibechain];import{WarpTypeRegistry as un}from"@vleap/warps";import{AbiRegistry as ge,Address as $t,TransactionsFactoryConfig as Ht,TransferTransactionsFactory as Gt}from"@multiversx/sdk-core";import{createWarpIdentifier as zt,getLatestProtocolIdentifier as qt,getWarpWalletAddressFromConfig as jt,WarpCache as Qt,WarpCacheKey as Xt,WarpConstants as je,WarpLogger as Qe}from"@vleap/warps";import{DevnetEntrypoint as Dt,MainnetEntrypoint as Lt,TestnetEntrypoint as Kt}from"@multiversx/sdk-core";import{getProviderConfig as _t}from"@vleap/warps";var M=s=>!s.includes("-"),j=s=>M(s)?`${s}-000000`:s,v=(s,e,t)=>{let r="warp-sdk",a=t?_t(t,s.name,e,s.defaultApiUrl):{url:s.defaultApiUrl},i=a.url,o={headers:a.headers};return e==="devnet"?new Dt({url:i,kind:"api",clientName:r,networkProviderConfig:o}):e==="testnet"?new Kt({url:i,kind:"api",clientName:r,networkProviderConfig:o}):new Lt({url:i,kind:"api",clientName:r,networkProviderConfig:o})};import{WarpLogger as qe}from"@vleap/warps";var Q=class{constructor(e){this.config=e}async getContract(e,t){try{let a=await v(t,this.config.env,this.config).createNetworkProvider().doGetGeneric(`accounts/${e}`);return{address:e,owner:a.ownerAddress,verified:a.isVerified||!1}}catch(r){return qe.error("WarpContractLoader: getContract error",r),null}}async getVerificationInfo(e,t){try{let a=await v(t,this.config.env,this.config).createNetworkProvider().doGetGeneric(`accounts/${e}/verification`);return{codeHash:a.codeHash,abi:a.source.abi}}catch(r){return qe.error("WarpContractLoader: getVerificationInfo error",r),null}}};var S=class{constructor(e,t){this.config=e;this.chain=t;this.contractLoader=new Q(this.config),this.cache=new Qt(this.config.cache?.type)}async createInscriptionTransaction(e){let t=jt(this.config,this.chain.name);if(!t)throw new Error("WarpBuilder: user address not set");let r=new Ht({chainID:this.chain.chainId}),n=new Gt({config:r}),a=$t.newFromBech32(t),i={protocol:qt("abi"),content:e},o=JSON.stringify(i),c=await n.createTransactionForTransfer(a,{receiver:a,nativeAmount:BigInt(0),data:Uint8Array.from(Buffer.from(o))});return c.gasLimit=c.gasLimit+BigInt(2e6),c}async createFromRaw(e){return JSON.parse(e)}async createFromTransaction(e){let t=await this.createFromRaw(e.data.toString());return t.meta={chain:this.chain.name,identifier:zt(this.chain.name,"hash",e.hash),query:null,hash:e.hash,creator:e.sender.toBech32(),createdAt:new Date(e.timestamp*1e3).toISOString()},t}async createFromTransactionHash(e,t){let r=Xt.WarpAbi(this.config.env,e);if(t){let i=this.cache.get(r);if(i)return Qe.info(`WarpAbiBuilder (createFromTransactionHash): Warp abi found in cache: ${e}`),i}let a=v(this.chain,this.config.env,this.config).createNetworkProvider();try{let i=await a.getTransaction(e),o=await this.createFromTransaction(i);return t&&t.ttl&&o&&this.cache.set(r,o,t.ttl),o}catch(i){return Qe.error("WarpAbiBuilder: Error creating from transaction hash",i),null}}async getAbiForAction(e){if(e.abi)return await this.fetchAbi(e);if(!e.address)throw new Error("WarpActionExecutor: Address not found");let t=await this.contractLoader.getVerificationInfo(e.address,this.chain);if(!t)throw new Error("WarpActionExecutor: Verification info not found");return ge.create(t.abi)}async fetchAbi(e){if(!e.abi)throw new Error("WarpActionExecutor: ABI not found");if(e.abi.startsWith(je.IdentifierType.Hash)){let t=e.abi.split(je.ArgParamsSeparator)[1],r=await this.createFromTransactionHash(t);if(!r)throw new Error(`WarpActionExecutor: ABI not found for hash: ${e.abi}`);return ge.create(r.content)}else{let r=await(await fetch(e.abi)).json();return ge.create(r)}}};import{Address as Xe,TransactionsFactoryConfig as Jt,TransferTransactionsFactory as Yt}from"@multiversx/sdk-core";import{createWarpIdentifier as Zt,getWarpWalletAddressFromConfig as er,WarpBrandBuilder as tr,WarpLogger as rr}from"@vleap/warps";import{Buffer as nr}from"buffer";var X=class{constructor(e,t){this.config=e;this.chain=t;this.core=new tr(e)}async createInscriptionTransaction(e){let t=er(this.config,this.chain.name);if(!t)throw new Error("BrandBuilder: user address not set");let r=new Jt({chainID:this.chain.chainId}),n=new Yt({config:r}),a=Xe.newFromBech32(t),i=JSON.stringify(e);return await n.createTransactionForNativeTokenTransfer(a,{receiver:Xe.newFromBech32(t),nativeAmount:BigInt(0),data:Uint8Array.from(nr.from(i))})}async createFromTransaction(e,t=!1){let r=await this.core.createFromRaw(e.data.toString(),t);return r.meta={query:null,chain:this.chain.name,identifier:Zt(this.chain.name,"hash",e.hash),hash:e.hash,creator:e.sender.toBech32(),createdAt:new Date(e.timestamp*1e3).toISOString()},r}async createFromTransactionHash(e){let r=v(this.chain,this.config.env,this.config).createNetworkProvider();try{let n=await r.getTransaction(e);return this.createFromTransaction(n)}catch(n){return rr.error("BrandBuilder: Error creating from transaction hash",n),null}}};import{Address as Je,TransactionsFactoryConfig as ar,TransferTransactionsFactory as ir}from"@multiversx/sdk-core";import{createWarpIdentifier as sr,getWarpWalletAddressFromConfig as or,WarpBuilder as Ye,WarpCache as cr,WarpCacheKey as lr,WarpLogger as Ze}from"@vleap/warps";var J=class extends Ye{constructor(t,r){super(t);this.config=t;this.chain=r;this.cache=new cr(t.cache?.type),this.core=new Ye(t)}async createInscriptionTransaction(t){let r=or(this.config,this.chain.name);if(!r)throw new Error("WarpBuilder: user address not set");let n=new ar({chainID:this.chain.chainId}),a=new ir({config:n}),i=Je.newFromBech32(r),o=JSON.stringify(t),c=await a.createTransactionForTransfer(i,{receiver:Je.newFromBech32(r),nativeAmount:BigInt(0),data:Uint8Array.from(Buffer.from(o))});return c.gasLimit=c.gasLimit+BigInt(2e6),c}async createFromTransaction(t,r=!1){let n=await this.core.createFromRaw(t.data.toString(),r);return n.meta={chain:this.chain.name,identifier:sr(this.chain.name,"hash",t.hash),query:null,hash:t.hash,creator:t.sender.toBech32(),createdAt:new Date(t.timestamp*1e3).toISOString()},n}async createFromTransactionHash(t,r){let n=lr.Warp(this.config.env,t);if(r){let o=this.cache.get(n);if(o)return Ze.info(`WarpBuilder (createFromTransactionHash): Warp found in cache: ${t}`),o}let i=v(this.chain,this.config.env,this.config).createNetworkProvider();try{let o=await i.getTransaction(t),c=await this.createFromTransaction(o);return r&&r.ttl&&c&&this.cache.set(n,c,r.ttl),c}catch(o){return Ze.error("WarpBuilder: Error creating from transaction hash",o),null}}};import{Address as fe,Token as hr,TokenComputer as gr}from"@multiversx/sdk-core";import{CacheTtl as fr,WarpCache as yr,WarpCacheKey as Wr}from"@vleap/warps";import{WarpChainName as pr}from"@vleap/warps";var et=pr.Multiversx,tt=[{chain:et,identifier:"EGLD",name:"eGold",symbol:"EGLD",decimals:18,logoUrl:"https://tools.multiversx.com/assets-cdn/tokens/EGLD-000000/icon.png"},{chain:et,identifier:"EGLD-000000",name:"eGold",symbol:"EGLD",decimals:18,logoUrl:"https://tools.multiversx.com/assets-cdn/tokens/EGLD-000000/icon.png"}];import{WarpChainName as ur}from"@vleap/warps";var A=ur.Multiversx,rt=[{chain:A,identifier:"EGLD",name:"eGold",symbol:"EGLD",decimals:18,logoUrl:"https://tools.multiversx.com/assets-cdn/tokens/EGLD-000000/icon.png"},{chain:A,identifier:"EGLD-000000",name:"eGold",symbol:"EGLD",decimals:18,logoUrl:"https://tools.multiversx.com/assets-cdn/tokens/EGLD-000000/icon.png"},{chain:A,identifier:"SEGLD-3ad2d0",name:"StakedEGLD",symbol:"SEGLD",decimals:18,logoUrl:"https://tools.multiversx.com/assets-cdn/tokens/SEGLD-3ad2d0/icon.png"},{chain:A,identifier:"HSEGLD-c13a4e",name:"HatomSEGLD",symbol:"HSEGLD",decimals:8,logoUrl:"https://tools.multiversx.com/assets-cdn/tokens/HSEGLD-c13a4e/icon.png"},{chain:A,identifier:"UTK-2f80e9",name:"xMoney UTK",symbol:"UTK",decimals:18,logoUrl:"https://tools.multiversx.com/assets-cdn/tokens/UTK-2f80e9/icon.png"},{chain:A,identifier:"USDC-c76f1f",name:"WrappedUSDC",symbol:"USDC",decimals:6,logoUrl:"https://tools.multiversx.com/assets-cdn/tokens/USDC-c76f1f/icon.png"},{chain:A,identifier:"WEGLD-bd4d79",name:"WrappedEGLD",symbol:"WEGLD",decimals:18,logoUrl:"https://tools.multiversx.com/assets-cdn/tokens/WEGLD-bd4d79/icon.png"},{chain:A,identifier:"HTM-f51d55",name:"Hatom",symbol:"HTM",decimals:18,logoUrl:"https://tools.multiversx.com/assets-cdn/tokens/HTM-f51d55/icon.png"},{chain:A,identifier:"MEX-455c57",name:"MEX",symbol:"MEX",decimals:18,logoUrl:"https://tools.multiversx.com/assets-cdn/tokens/MEX-455c57/icon.png"},{chain:A,identifier:"WTAO-4f5363",name:"WrappedTAO",symbol:"WTAO",decimals:9,logoUrl:"https://tools.multiversx.com/assets-cdn/tokens/WTAO-4f5363/icon.png"},{chain:A,identifier:"HEGLD-d61095",name:"HatomEGLD",symbol:"HEGLD",decimals:8,logoUrl:"https://tools.multiversx.com/assets-cdn/tokens/HEGLD-d61095/icon.png"},{chain:A,identifier:"WBTC-5349b3",name:"WrappedBTC",symbol:"WBTC",decimals:8,logoUrl:"https://tools.multiversx.com/assets-cdn/tokens/WBTC-5349b3/icon.png"},{chain:A,identifier:"WETH-b4ca29",name:"WrappedETH",symbol:"WETH",decimals:18,logoUrl:"https://tools.multiversx.com/assets-cdn/tokens/WETH-b4ca29/icon.png"},{chain:A,identifier:"USH-111e09",name:"HatomUSD",symbol:"USH",decimals:18,logoUrl:"https://tools.multiversx.com/assets-cdn/tokens/USH-111e09/icon.png"},{chain:A,identifier:"USDT-f8c08c",name:"WrappedUSDT",symbol:"USDT",decimals:6,logoUrl:"https://tools.multiversx.com/assets-cdn/tokens/USDT-f8c08c/icon.png"}];import{WarpChainName as mr}from"@vleap/warps";var nt=mr.Multiversx,at=[{chain:nt,identifier:"EGLD",name:"eGold",symbol:"EGLD",decimals:18,logoUrl:"https://tools.multiversx.com/assets-cdn/tokens/EGLD-000000/icon.png"},{chain:nt,identifier:"EGLD-000000",name:"eGold",symbol:"EGLD",decimals:18,logoUrl:"https://tools.multiversx.com/assets-cdn/tokens/EGLD-000000/icon.png"}];import{WarpChainName as dr}from"@vleap/warps";var it=dr.Vibechain,Y=[{chain:it,identifier:"VIBE",name:"VIBE",symbol:"VIBE",decimals:18,logoUrl:"https://joai.ai/images/tokens/vibe.svg"},{chain:it,identifier:"VIBE-000000",name:"VIBE",symbol:"VIBE",decimals:18,logoUrl:"https://joai.ai/images/tokens/vibe.svg"}];var st={multiversx:{mainnet:rt,testnet:at,devnet:tt},vibechain:{mainnet:Y,testnet:Y,devnet:Y}},ot=(s,e,t)=>(st[s]?.[e]||[]).find(n=>n.identifier===t)||null,Ya=(s,e)=>st[s]?.[e]||[];var Z=class{constructor(e,t){this.config=e;this.chain=t;this.cache=new yr(e.cache?.type)}async getAccount(e){let r=await v(this.chain,this.config.env,this.config).createNetworkProvider().getAccount(fe.newFromBech32(e));return{chain:this.chain.name,address:r.address.toBech32(),balance:r.balance}}async getAccountAssets(e){let t=v(this.chain,this.config.env,this.config).createNetworkProvider(),r=t.getAccount(fe.newFromBech32(e)),n=t.getFungibleTokensOfAccount(fe.newFromBech32(e)),[a,i]=await Promise.all([r,n]),o=a.balance>0?[{...this.chain.nativeToken,amount:a.balance}]:[];return o.push(...i.map(c=>({chain:this.chain.name,identifier:c.token.identifier,name:c.raw.name,symbol:c.raw.ticker,amount:c.amount,decimals:c.raw.decimals,logoUrl:c.raw.assets?.pngUrl||"",price:c.raw.price?Number(c.raw.price):void 0,supply:c.raw.supply?BigInt(c.raw.supply):void 0}))),o}async getAsset(e){let t=Wr.Asset(this.config.env,this.chain.name,e),r=this.cache.get(t);if(r)return r;let n=ot(this.chain.name,this.config.env,e);if(n)return{chain:this.chain.name,identifier:e,name:n.name,symbol:n.symbol,amount:0n,decimals:n.decimals,logoUrl:n.logoUrl};let a=new gr,i=M(e)?0n:a.extractNonceFromExtendedIdentifier(e),o=new hr({identifier:e,nonce:BigInt(i||0)}),c=a.isFungible(o),d=v(this.chain,this.config.env,this.config).createNetworkProvider(),m=j(e),p=await d.doGetGeneric(`tokens/${m}`),W={chain:this.chain.name,identifier:o.identifier,name:p.name,symbol:p.ticker,amount:0n,decimals:p.decimals,logoUrl:p.assets?.pngUrl||null,price:p.price?Number(p.price):void 0,supply:p.supply?BigInt(p.supply):void 0};return this.cache.set(t,W,fr.OneHour),W}async getAction(e,t=!1){let r=v(this.chain,this.config.env,this.config),n=t?await r.awaitCompletedTransaction(e):await r.getTransaction(e);return{chain:this.chain.name,id:n.hash,receiver:n.receiver.toBech32(),sender:n.sender.toBech32(),value:n.value,function:n.function,status:this.toActionStatus(n),createdAt:this.toActionCreatedAt(n),error:n?.smartContractResults.map(a=>a.raw.returnMessage)[0]||null,tx:n}}async getAccountActions(e,t){let r=v(this.chain,this.config.env,this.config).createNetworkProvider(),n=`accounts/${e}/transactions`,a=new URLSearchParams,i=t?.size||25,o=t?.page||0;if(o>0){let d=o*i;a.append("from",d.toString())}return i!==25&&a.append("size",i.toString()),a.toString()&&(n+=`?${a.toString()}`),(await r.doGetGeneric(n)).map(d=>({chain:this.chain.name,id:d.txHash,receiver:d.receiver,sender:d.sender,value:d.value,function:d.function,status:this.toActionStatus(d),createdAt:this.toActionCreatedAt(d)}))}toActionStatus(e){return e.status.isSuccessful()?"success":e.status.isFailed()?"failed":"pending"}toActionCreatedAt(e){return new Date(e.timestamp||e.timestamp*1e3).toISOString()}};import{Address as H,ArgSerializer as Or,SmartContractTransactionsFactory as Mr,Token as Rr,TokenComputer as Dr,TokenTransfer as Lr,TransactionsFactoryConfig as Et,TransferTransactionsFactory as Kr}from"@multiversx/sdk-core";import{applyOutputToMessages as _r,extractResolvedInputValues as $r,getNextInfo as Hr,getWarpActionByIndex as Ne,getWarpWalletAddressFromConfig as Ve}from"@vleap/warps";import{findEventsByFirstTopic as br,SmartContractTransactionsOutcomeParser as Pr,TransactionEventsParser as Ir}from"@multiversx/sdk-core";import{applyOutputToMessages as Sr,evaluateOutputCommon as oe,extractResolvedInputValues as Br,getNextInfo as Nr,getWarpActionByIndex as Vr,getWarpWalletAddressFromConfig as Ur,parseOutputOutIndex as At,WarpCache as kr,WarpCacheKey as Fr,WarpConstants as xt}from"@vleap/warps";import{Address as Tr,AddressType as ye,AddressValue as lt,BigUIntType as ee,BigUIntValue as We,BooleanType as ve,BooleanValue as pt,BytesType as we,BytesValue as ut,CodeMetadata as Cr,CodeMetadataType as Te,CodeMetadataValue as mt,CompositeType as Ce,CompositeValue as dt,Field as te,FieldDefinition as re,List as ht,ListType as gt,NothingValue as b,OptionalType as ft,OptionalValue as Ae,OptionType as yt,OptionValue as xe,StringType as Ee,StringValue as Wt,Struct as ne,StructType as k,Token as Ar,TokenComputer as vt,TokenIdentifierType as ae,TokenIdentifierValue as be,U16Type as Pe,U16Value as wt,U32Type as Ie,U32Value as Tt,U64Type as ie,U64Value as Se,U8Type as Be,U8Value as Ct,VariadicType as $,VariadicValue as se}from"@multiversx/sdk-core";import{WarpSerializer as xr}from"@vleap/warps";var u={HttpProtocolPrefix:"http",IdentifierParamName:"warp",IdentifierParamSeparator:":",IdentifierChainDefault:"multiversx",IdentifierType:{Alias:"alias",Hash:"hash"},IdentifierAliasMarker:"@",Globals:{UserWallet:{Placeholder:"USER_WALLET",Accessor:s=>s.config.user?.wallets?.[s.adapter.chainInfo.name]},UserWalletPublicKey:{Placeholder:"USER_WALLET_PUBLICKEY",Accessor:s=>{if(!s.adapter.wallet)return null;try{return s.adapter.wallet.getPublicKey()||null}catch{return null}}},ChainApiUrl:{Placeholder:"CHAIN_API",Accessor:s=>s.adapter.chainInfo.defaultApiUrl},ChainAddressHrp:{Placeholder:"CHAIN_ADDRESS_HRP",Accessor:s=>s.adapter.chainInfo.addressHrp}},Vars:{Query:"query",Env:"env"},ArgParamsSeparator:":",ArgCompositeSeparator:"|",ArgListSeparator:",",ArgStructSeparator:";",Transform:{Prefix:"transform:"},Source:{UserWallet:"user:wallet"},Position:{Payload:"payload:"},Alerts:{TriggerEventPrefix:"event"}},l={Option:"option",Vector:"vector",Tuple:"tuple",Struct:"struct",String:"string",Uint8:"uint8",Uint16:"uint16",Uint32:"uint32",Uint64:"uint64",Uint128:"uint128",Uint256:"uint256",Biguint:"biguint",Bool:"bool",Address:"address",Asset:"asset",Hex:"hex"};var gi={Egld:{Identifier:"EGLD",EsdtIdentifier:"EGLD-000000",DisplayName:"eGold",Decimals:18}},f={Null:"null",Optional:"optional",List:"list",Token:"token",CodeMeta:"codemeta"},vr=(r=>(r.MultiversxExplorer="multiversx_explorer",r.MultiversxExplorerDevnet="multiversx_explorer_devnet",r.MultiversxExplorerTestnet="multiversx_explorer_testnet",r))(vr||{}),wr=(r=>(r.VibechainExplorer="vibechain_explorer",r.VibechainExplorerDevnet="vibechain_explorer_devnet",r.VibechainExplorerTestnet="vibechain_explorer_testnet",r))(wr||{}),ct={multiversx:{mainnet:["multiversx_explorer"],testnet:["multiversx_explorer_testnet"],devnet:["multiversx_explorer_devnet"]},vibechain:{mainnet:["vibechain_explorer"],testnet:["vibechain_explorer_testnet"],devnet:["vibechain_explorer_devnet"]}},U={multiversx_explorer:"https://explorer.multiversx.com",multiversx_explorer_devnet:"https://devnet-explorer.multiversx.com",multiversx_explorer_testnet:"https://testnet-explorer.multiversx.com",vibechain_explorer:"https://vibeox-explorer.multiversx.com",vibechain_explorer_devnet:"https://vibeox-explorer.multiversx.com",vibechain_explorer_testnet:"https://vibeox-explorer.multiversx.com"};var Er=new RegExp(`${u.ArgParamsSeparator}(.*)`),B=class{constructor(e){this.coreSerializer=new xr(e)}typedToString(e){let t=e.getType();if(t.hasExactClass(yt.ClassName)||e.hasClassOrSuperclass(xe.ClassName)){if(!e.isSet())return l.Option+u.ArgParamsSeparator+"null";let r=this.typedToString(e.getTypedValue());return l.Option+u.ArgParamsSeparator+r}if(t.hasExactClass($.ClassName)||e.hasClassOrSuperclass(se.ClassName)){let r=e.getItems();if(r.length===0){let m=this.typeToString(t.getFirstTypeParameter());return l.Vector+u.ArgParamsSeparator+m+u.ArgParamsSeparator}let n=r.map(m=>this.typedToString(m));if(n.every(m=>m.startsWith(l.Tuple)))return l.Vector+u.ArgParamsSeparator+n.join(",");let a=n[0],i=a.indexOf(u.ArgParamsSeparator),o=a.substring(0,i),c=n.map(m=>{let p=m.indexOf(u.ArgParamsSeparator);return m.substring(p+1)}),d=o.startsWith(l.Struct)?u.ArgStructSeparator:u.ArgListSeparator;return l.Vector+u.ArgParamsSeparator+o+u.ArgParamsSeparator+c.join(d)}if(t.hasExactClass(ft.ClassName)||e.hasClassOrSuperclass(Ae.ClassName)){if(!e.isSet())return f.Optional+u.ArgParamsSeparator+"null";let r=this.typedToString(e.getTypedValue());return f.Optional+u.ArgParamsSeparator+r}if(t.hasExactClass(gt.ClassName)||e.hasClassOrSuperclass(ht.ClassName)){let n=e.getItems().map(c=>this.typedToString(c));if(n.every(c=>c.startsWith(l.Tuple)))return f.List+u.ArgParamsSeparator+n.join(",");let i=n.map(c=>c.split(u.ArgParamsSeparator)[0])[0],o=n.map(c=>c.split(u.ArgParamsSeparator)[1]);return f.List+u.ArgParamsSeparator+i+u.ArgParamsSeparator+o.join(u.ArgListSeparator)}if(t.hasExactClass(Ce.ClassName)||e.hasClassOrSuperclass(dt.ClassName)){let n=e.getItems().map(a=>{let i=this.typedToString(a),o=i.indexOf(u.ArgParamsSeparator),c=i.substring(0,o),d=i.substring(o+1);return`${c},${d}`});return`${l.Tuple}(${n.join(",")})`}if(t.hasExactClass(ee.ClassName)||e.hasClassOrSuperclass(We.ClassName)||t.getName()==="BigUint")return l.Biguint+u.ArgParamsSeparator+BigInt(e.valueOf().toFixed());if(t.hasExactClass(Be.ClassName)||e.hasClassOrSuperclass(Ct.ClassName))return l.Uint8+u.ArgParamsSeparator+e.valueOf().toNumber();if(t.hasExactClass(Pe.ClassName)||e.hasClassOrSuperclass(wt.ClassName))return l.Uint16+u.ArgParamsSeparator+e.valueOf().toNumber();if(t.hasExactClass(Ie.ClassName)||e.hasClassOrSuperclass(Tt.ClassName))return l.Uint32+u.ArgParamsSeparator+e.valueOf().toNumber();if(t.hasExactClass(ie.ClassName)||e.hasClassOrSuperclass(Se.ClassName))return l.Uint64+u.ArgParamsSeparator+BigInt(e.valueOf().toFixed());if(t.hasExactClass(Ee.ClassName)||e.hasClassOrSuperclass(Wt.ClassName))return l.String+u.ArgParamsSeparator+e.valueOf();if(t.hasExactClass(ve.ClassName)||e.hasClassOrSuperclass(pt.ClassName))return l.Bool+u.ArgParamsSeparator+e.valueOf();if(t.hasExactClass(ye.ClassName)||e.hasClassOrSuperclass(lt.ClassName))return l.Address+u.ArgParamsSeparator+e.valueOf().toBech32();if(t.hasExactClass(we.ClassName)||e.hasClassOrSuperclass(ut.ClassName))return l.Hex+u.ArgParamsSeparator+e.valueOf().toString("hex");if(t.getName()==="EsdtTokenPayment"){let r=e.getFieldValue("token_identifier").valueOf(),n=e.getFieldValue("token_nonce").valueOf(),a=e.getFieldValue("amount").valueOf(),o=new vt().computeExtendedIdentifier(new Ar({identifier:r,nonce:BigInt(n)}));return l.Asset+u.ArgParamsSeparator+o+u.ArgCompositeSeparator+a}if(t.hasExactClass(k.ClassName)||e.hasClassOrSuperclass(ne.ClassName)){let r=e,a=r.getType().getName(),i=r.getFields();if(i.length===0)return`${l.Struct}(${a})${u.ArgParamsSeparator}`;let o=i.map(c=>{let d=c.value.getType(),p=this.typedToString(c.value).split(u.ArgParamsSeparator),W=p.length>2?p.slice(2).join(u.ArgParamsSeparator):p[1]||"";return`(${c.name}${u.ArgParamsSeparator}${this.typeToString(d)})${W}`});return`${l.Struct}(${a})${u.ArgParamsSeparator}${o.join(u.ArgListSeparator)}`}if(t.hasExactClass(ae.ClassName)||e.hasClassOrSuperclass(be.ClassName))return f.Token+u.ArgParamsSeparator+e.valueOf();if(t.hasExactClass(Te.ClassName)||e.hasClassOrSuperclass(mt.ClassName))return f.CodeMeta+u.ArgParamsSeparator+e.valueOf().toString();throw new Error(`WarpArgSerializer (typedToString): Unsupported input type: ${e.getClassName()}`)}typedToNative(e){let t=this.typedToString(e);return this.coreSerializer.stringToNative(t)}nativeToTyped(e,t){if(e.startsWith(l.Tuple))return this.stringToTyped(e+":");let r=this.coreSerializer.nativeToString(e,t);return this.stringToTyped(r)}nativeToType(e){if(e.startsWith(l.Tuple)){let t=e.match(/\(([^)]+)\)/)?.[1];if(!t)throw new Error(`Invalid tuple type format: ${e}`);let r=t.split(","),n=[];for(let a=0;a<r.length;a+=2)n.push(r[a]);return new Ce(...n.map(a=>this.nativeToType(a)))}if(e.startsWith(l.Struct)){let t=e.match(/\(([^)]+)\)/);if(!t)throw new Error("Struct type must include a name in the format struct(Name)");let r=t[1];return new k(r,[])}if(e===l.String)return new Ee;if(e===l.Uint8)return new Be;if(e===l.Uint16)return new Pe;if(e===l.Uint32)return new Ie;if(e===l.Uint64)return new ie;if(e===l.Biguint)return new ee;if(e===l.Bool)return new ve;if(e===l.Address)return new ye;if(e===l.Hex)return new we;if(e===l.Asset)return new k("EsdtTokenPayment",[new re("token_identifier","",new ae),new re("token_nonce","",new ie),new re("amount","",new ee)]);if(e===f.Token)return new ae;if(e===f.CodeMeta)return new Te;throw new Error(`WarpArgSerializer (nativeToType): Unsupported input type: ${e}`)}stringToTyped(e){let[t,r]=e.split(/:(.*)/,2);if(t===l.Option){let n=this.stringToTyped(r);return n instanceof b?xe.newMissingTyped(n.getType()):xe.newProvided(n)}if(t===l.Vector){let n=r.indexOf(u.ArgParamsSeparator),a=r.substring(0,n),i=r.substring(n+1);if(a.startsWith(l.Tuple)){let p=i.split(",").map(W=>this.stringToTyped(W));return new se(new $(this.nativeToType(a)),p)}if(i.includes("tuple(")){let m=this.splitTupleStrings(i),p=m.map(T=>this.stringToTyped(T)),C=m[0].match(/^(tuple\([^)]+\))/),h=C?C[1]:"tuple";return new se(new $(this.nativeToType(h)),p)}let o=a.startsWith(l.Struct)?u.ArgStructSeparator:u.ArgListSeparator,d=i.split(o).map(m=>this.stringToTyped(`${a}:${m}`));return new se(new $(this.nativeToType(a)),d)}if(t.startsWith(l.Tuple)){let n=t.match(/\(([^)]+)\)/)?.[1];if(!n)throw new Error(`Invalid tuple format: ${t}`);let a=n.split(","),i=[];for(let c=0;c<a.length;c+=2){let d=a[c],m=a[c+1];i.push(this.stringToTyped(`${d}:${m}`))}let o=i.map(c=>c.getType());return new dt(new Ce(...o),i)}if(t.startsWith(l.Struct)){let n=t.match(/\(([^)]+)\)/),a=n?n[1]:"CustomStruct";if(!r)return new ne(new k(a,[]),[]);let i=r.split(u.ArgListSeparator),o=[],c=[];return i.forEach(d=>{let m=d.match(new RegExp(`^\\(([^${u.ArgParamsSeparator}]+)${u.ArgParamsSeparator}([^)]+)\\)(.+)$`));if(m){let[,p,W,C]=m,h=this.stringToTyped(`${W}${u.ArgParamsSeparator}${C}`);o.push(new re(p,"",h.getType())),c.push(new te(h,p))}}),new ne(new k(a,o),c)}if(t===l.String)return r?Wt.fromUTF8(r):new b;if(t===l.Uint8)return r?new Ct(Number(r)):new b;if(t===l.Uint16)return r?new wt(Number(r)):new b;if(t===l.Uint32)return r?new Tt(Number(r)):new b;if(t===l.Uint64)return r?new Se(BigInt(r)):new b;if(t===l.Biguint)return r?new We(BigInt(r)):new b;if(t===l.Bool)return r?new pt(typeof r=="boolean"?r:r==="true"):new b;if(t===l.Address)return r?new lt(Tr.newFromBech32(r)):new b;if(t===l.Hex)return r?ut.fromHex(r):new b;if(t===l.Asset){let[n,a]=r.split(u.ArgCompositeSeparator),i=new vt,o=M(n)?j(n):i.extractIdentifierFromExtendedIdentifier(n),c=M(n)?0n:i.extractNonceFromExtendedIdentifier(n);return new ne(this.nativeToType("asset"),[new te(new be(o),"token_identifier"),new te(new Se(BigInt(c)),"token_nonce"),new te(new We(BigInt(a)),"amount")])}if(t===f.Null)return new b;if(t===f.Optional){let n=this.stringToTyped(r);return n instanceof b?Ae.newMissing():new Ae(n.getType(),n)}if(t===f.List){let[n,a]=r.split(Er,2),o=a.split(u.ArgListSeparator).map(c=>this.stringToTyped(n+u.ArgParamsSeparator+c));return new ht(this.nativeToType(n),o)}if(t===f.Token)return r?new be(r):new b;if(t===f.CodeMeta)return new mt(Cr.newFromBytes(Uint8Array.from(Buffer.from(r,"hex"))));throw new Error(`WarpArgSerializer (stringToTyped): Unsupported input type: ${t}`)}splitTupleStrings(e){let t=[],r="",n=0;for(let a=0;a<e.length;a++){let i=e[a];if(i==="(")n++;else if(i===")")n--;else if(i===","&&n===0){t.push(r.trim()),r="";continue}r+=i}return r.trim()&&t.push(r.trim()),t}typeToString(e){if(e.hasExactClass(yt.ClassName))return l.Option+u.ArgParamsSeparator+this.typeToString(e.getFirstTypeParameter());if(e.hasExactClass($.ClassName))return l.Vector+u.ArgParamsSeparator+this.typeToString(e.getFirstTypeParameter());if(e.hasExactClass(Ee.ClassName))return l.String;if(e.hasExactClass(Be.ClassName))return l.Uint8;if(e.hasExactClass(Pe.ClassName))return l.Uint16;if(e.hasExactClass(Ie.ClassName))return l.Uint32;if(e.hasExactClass(ie.ClassName))return l.Uint64;if(e.hasExactClass(ee.ClassName))return l.Biguint;if(e.hasExactClass(ve.ClassName))return l.Bool;if(e.hasExactClass(ye.ClassName))return l.Address;if(e.hasExactClass(we.ClassName))return l.Hex;if(e.hasExactClass(ae.ClassName))return f.Token;if(e.hasExactClass(ft.ClassName))return f.Optional+u.ArgParamsSeparator+this.typeToString(e.getFirstTypeParameter());if(e.hasExactClass(gt.ClassName))return f.List+u.ArgParamsSeparator+this.typeToString(e.getFirstTypeParameter());if(e.hasExactClass(Te.ClassName))return f.CodeMeta;if(e.hasExactClass(k.ClassName)&&e.getClassName()==="EsdtTokenPayment")return l.Asset;if(e.hasExactClass(k.ClassName))return`${l.Struct}(${e.getName()})`;throw new Error(`WarpArgSerializer (typeToString): Unsupported input type: ${e.getClassName()}`)}};var R=class{constructor(e,t,r){this.config=e;this.chain=t;this.typeRegistry=r;this.abi=new S(e,t),this.serializer=new B({typeRegistry:this.typeRegistry}),this.cache=new kr(e.cache?.type)}async getActionExecution(e,t,r){let n=this.cache.get(Fr.WarpExecutable(this.config.env,e.meta?.hash||"",t))??[],a=await this.extractContractOutput(e,t,r,n),i=Nr(this.config,[],e,t,a.output),o=Sr(e,a.output,this.config),c=Br(n);return{status:r.status.isSuccessful()?"success":"error",warp:e,action:t,user:Ur(this.config,this.chain.name),txHash:r.hash,tx:r,next:i,values:a.values,output:a.output,messages:o,destination:null,resolvedInputs:c}}async extractContractOutput(e,t,r,n){let a=Vr(e,t),i=[],o=[],c={};if(!e.output||a.type!=="contract")return{values:{string:i,native:o,mapped:{}},output:c};if(!Object.values(e.output).some(h=>h.includes("out")||h.includes("event"))){for(let[h,T]of Object.entries(e.output))c[h]=T;return{values:{string:i,native:o,mapped:{}},output:await oe(e,c,t,n,this.serializer.coreSerializer,this.config)}}let m=await this.abi.getAbiForAction(a),p=new Ir({abi:m}),C=new Pr({abi:m}).parseExecute({transactionOnNetwork:r,function:a.func||void 0});for(let[h,T]of Object.entries(e.output)){if(T.startsWith(xt.Transform.Prefix))continue;if(T.startsWith("input.")){c[h]=T;continue}let x=At(T);if(x!==null&&x!==t){c[h]=null;continue}let[P,N,V]=T.split(".");if(P==="event"){if(!N||isNaN(Number(V)))continue;let I=Number(V),g=br(r,N),Rt=p.parseEvents({events:g})[0],_=Object.values(Rt)[I]||null;i.push(String(_)),o.push(_),c[h]=_&&_.valueOf()}else if(P==="out"||P.startsWith("out[")){if(!N)continue;let I=Number(N),g=C.values[I-1]||null;V&&(g=g[V]||null),g&&typeof g=="object"&&(g="toFixed"in g?g.toFixed():g.valueOf()),i.push(String(g)),o.push(g),c[h]=g&&g.valueOf()}else c[h]=T}return{values:{string:i,native:o,mapped:{}},output:await oe(e,c,t,n,this.serializer.coreSerializer,this.config)}}async extractQueryOutput(e,t,r,n){let a=t.map(m=>this.serializer.typedToString(m)),i=t.map(m=>this.serializer.typedToNative(m)[1]),o={string:a,native:i,mapped:{}},c={};if(!e.output)return{values:o,output:c};let d=m=>{let p=m.split(".").slice(1).map(C=>parseInt(C)-1);if(p.length===0)return;let W=i[p[0]];for(let C=1;C<p.length;C++){if(W==null)return;W=W[p[C]]}return W};for(let[m,p]of Object.entries(e.output)){if(p.startsWith(xt.Transform.Prefix))continue;let W=At(p);if(W!==null&&W!==r){c[m]=null;continue}p.startsWith("out.")||p==="out"||p.startsWith("out[")?c[m]=d(p)||null:c[m]=p}return c=await oe(e,c,r,n,this.serializer.coreSerializer,this.config),{values:o,output:c}}async resolveWarpOutputRecursively(e){let t=e.warp,r=e.entryActionIndex,n=e.executor,a=e.inputs,i=e.meta,o=new Map,c=new Set,d=this;async function m(h,T=[]){if(o.has(h))return o.get(h);if(c.has(h))throw new Error(`Circular dependency detected at action ${h}`);c.add(h);let x=t.actions[h-1];if(!x)throw new Error(`Action ${h} not found`);let P;if(x.type==="query")P=await n.executeQuery(t,h,T);else if(x.type==="collect")P=await n.executeCollect(t,h,T,i);else throw new Error(`Unsupported or interactive action type: ${x.type}`);if(o.set(h,P),t.output)for(let N of Object.values(t.output)){let I=String(N).match(/^out\[(\d+)\]/);if(I){let g=parseInt(I[1],10);g!==h&&!o.has(g)&&await m(g)}}return c.delete(h),P}await m(r,a);let p={};for(let h of o.values())for(let[T,x]of Object.entries(h.output))x!==null?p[T]=x:T in p||(p[T]=null);let W=await oe(t,p,r,a,this.serializer.coreSerializer,this.config);return{...o.get(r),action:r,output:W}}};var Gr="EGLD-000000",ce=class{constructor(e,t,r){this.config=e;this.chain=t;this.typeRegistry=r;this.serializer=new B({typeRegistry:this.typeRegistry}),this.abi=new S(this.config,this.chain),this.output=new R(this.config,this.chain,this.typeRegistry)}async createTransaction(e){let t=Ne(e.warp,e.action),r=null;if(t.type==="transfer")r=await this.createTransferTransaction(e);else if(t.type==="contract")r=await this.createContractCallTransaction(e);else{if(t.type==="query")throw new Error("WarpMultiversxExecutor: Invalid action type for createTransactionForExecute; Use executeQuery instead");if(t.type==="collect")throw new Error("WarpMultiversxExecutor: Invalid action type for createTransactionForExecute; Use executeCollect instead")}if(!r)throw new Error(`WarpMultiversxExecutor: Invalid action type (${t.type})`);return r}async createTransferTransaction(e){if(!e.destination)throw new Error("WarpMultiversxExecutor: createTransfer - destination not set");let t=Ve(this.config,e.chain.name);if(!t)throw new Error("WarpMultiversxExecutor: createTransfer - user address not set");let r=H.newFromBech32(t),n=new Et({chainID:e.chain.chainId}),a=e.data?Buffer.from(this.serializer.stringToTyped(e.data).valueOf()):null,i=e.transfers.length===1&&e.transfers[0].identifier===this.chain.nativeToken?.identifier,c=(i?e.transfers[0].amount:0n)+e.value;return await new Kr({config:n}).createTransactionForTransfer(r,{receiver:H.newFromBech32(e.destination),nativeAmount:c,tokenTransfers:i?[]:this.toTokenTransfers(e.transfers),data:a?new Uint8Array(a):void 0})}async createContractCallTransaction(e){if(!e.destination)throw new Error("WarpMultiversxExecutor: createContractCall - destination not set");let t=Ve(this.config,e.chain.name);if(!t)throw new Error("WarpMultiversxExecutor: createContractCall - user address not set");let r=Ne(e.warp,e.action),n=H.newFromBech32(t),a=e.args.map(o=>this.serializer.stringToTyped(o)),i=new Et({chainID:e.chain.chainId});return new Mr({config:i}).createTransactionForExecute(n,{contract:H.newFromBech32(e.destination),function:"func"in r&&r.func||"",gasLimit:"gasLimit"in r?BigInt(r.gasLimit||0):0n,arguments:a,tokenTransfers:this.toTokenTransfers(e.transfers),nativeTransferAmount:e.value})}async executeQuery(e){if(!e.destination)throw new Error("WarpMultiversxExecutor: executeQuery - destination not set");let t=Ne(e.warp,e.action);if(t.type!=="query")throw new Error(`WarpMultiversxExecutor: Invalid action type for executeQuery: ${t.type}`);let r=await this.abi.getAbiForAction(t),n=e.args.map(g=>this.serializer.stringToTyped(g)),a=v(e.chain,this.config.env,this.config),i=H.newFromBech32(e.destination),o=a.createSmartContractController(r),c=o.createQuery({contract:i,function:t.func||"",arguments:n}),d=await o.runQuery(c),m=d.returnCode==="ok",p=new Or,W=r.getEndpoint(d.function||t.func||""),C=(d.returnDataParts||[]).map(g=>Buffer.from(g)),h=p.buffersToValues(C,W.output),{values:T,output:x}=await this.output.extractQueryOutput(e.warp,h,e.action,e.resolvedInputs),P=Hr(this.config,[],e.warp,e.action,x),V=e.resolvedInputs.find(g=>g.input.position==="receiver"||g.input.position==="destination")?.value||e.destination,I=$r(e.resolvedInputs);return{status:m?"success":"error",warp:e.warp,action:e.action,user:Ve(this.config,e.chain.name),txHash:null,tx:null,next:P,values:T,output:{...x,_DATA:h},messages:_r(e.warp,x,this.config),destination:V,resolvedInputs:I}}toTokenTransfers(e){return e.map(t=>t.identifier===this.chain.nativeToken.identifier?{...t,identifier:Gr}:t).map(t=>{let n=new Dr().extractNonceFromExtendedIdentifier(t.identifier);return new Lr({token:new Rr({identifier:t.identifier,nonce:BigInt(n||0)}),amount:t.amount})})}};var le=class{constructor(e,t){this.chain=e;this.config=t}getExplorers(){let e=ct[this.chain];if(!e)return["multiversx_explorer"];let t=e[this.config.env];return t||["multiversx_explorer"]}getPrimaryExplorer(){return this.getExplorers()[0]}getExplorerUrlByName(e){let t=this.config.preferences?.explorers?.[this.chain];if(t&&!e){let a=U[t];if(a)return a}if(e){let a=U[e];if(a)return a}let r=this.getPrimaryExplorer();return U[r]||U[r]}getAccountUrl(e,t){return`${this.getExplorerUrlByName(t)}/accounts/${e}`}getTransactionUrl(e,t){return`${this.getExplorerUrlByName(t)}/transactions/${e}`}getBlockUrl(e,t){return`${this.getExplorerUrlByName(t)}/blocks/${e}`}getAssetUrl(e,t){return`${this.getExplorerUrlByName(t)}/tokens/${e}`}getContractUrl(e,t){return`${this.getExplorerUrlByName(t)}/accounts/${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(n=>{let a=U[n];a&&(r[n]=`${a}/accounts/${e}`)}),r}getTransactionUrls(e){let t=this.getAllExplorers(),r={};return t.forEach(n=>{let a=U[n];a&&(r[n]=`${a}/transactions/${e}`)}),r}};import{AbiRegistry as Pt,Address as y,AddressValue as ke,BytesValue as w,SmartContractTransactionsFactory as qr,TransactionsFactoryConfig as jr}from"@multiversx/sdk-core";import{createWarpIdentifier as Qr,getWarpWalletAddressFromConfig as Xr,WarpCache as Jr,WarpCacheKey as Fe,WarpLogger as Oe}from"@vleap/warps";var Ue={buildInfo:{rustc:{version:"1.86.0",commitHash:"05f9846f893b09a1be1fc8560e33fc3c815cfecb",commitDate:"2025-03-31",channel:"Stable",short:"rustc 1.86.0 (05f9846f8 2025-03-31)"},contractCrate:{name:"registry",version:"0.0.1"},framework:{name:"multiversx-sc",version:"0.51.1"}},name:"RegistryContract",constructor:{inputs:[{name:"unit_price",type:"BigUint"},{name:"vault",type:"Address"}],outputs:[]},upgradeConstructor:{inputs:[],outputs:[]},endpoints:[{name:"registerWarp",mutability:"mutable",payableInTokens:["EGLD"],inputs:[{name:"hash",type:"bytes"},{name:"alias_opt",type:"optional<bytes>",multi_arg:!0},{name:"brand_opt",type:"optional<bytes>",multi_arg:!0}],outputs:[],allow_multiple_var_args:!0},{name:"unregisterWarp",mutability:"mutable",inputs:[{name:"warp",type:"bytes"}],outputs:[]},{name:"upgradeWarp",mutability:"mutable",payableInTokens:["EGLD"],inputs:[{name:"alias",type:"bytes"},{name:"new_warp",type:"bytes"},{name:"brand_opt",type:"optional<bytes>",multi_arg:!0}],outputs:[]},{name:"setWarpAlias",mutability:"mutable",payableInTokens:["EGLD"],inputs:[{name:"hash",type:"bytes"},{name:"alias",type:"bytes"}],outputs:[]},{name:"forceRemoveAlias",mutability:"mutable",inputs:[{name:"hash",type:"bytes"}],outputs:[]},{name:"verifyWarp",mutability:"mutable",inputs:[{name:"warp",type:"bytes"}],outputs:[]},{name:"transferOwnership",mutability:"mutable",inputs:[{name:"warp",type:"bytes"},{name:"new_owner",type:"Address"}],outputs:[]},{name:"getUserWarps",mutability:"readonly",inputs:[{name:"address",type:"Address"}],outputs:[{type:"variadic<InfoView>",multi_result:!0}]},{name:"getInfoByAlias",mutability:"readonly",inputs:[{name:"alias",type:"bytes"}],outputs:[{type:"InfoView"}]},{name:"getInfoByHash",mutability:"readonly",inputs:[{name:"hash",type:"bytes"}],outputs:[{type:"InfoView"}]},{name:"setVault",onlyOwner:!0,mutability:"mutable",inputs:[{name:"vault",type:"Address"}],outputs:[]},{name:"setUnitPrice",onlyOwner:!0,mutability:"mutable",inputs:[{name:"amount",type:"BigUint"}],outputs:[]},{name:"addAdmin",onlyOwner:!0,mutability:"mutable",inputs:[{name:"address",type:"Address"}],outputs:[]},{name:"removeAdmin",onlyOwner:!0,mutability:"mutable",inputs:[{name:"address",type:"Address"}],outputs:[]},{name:"getConfig",mutability:"readonly",inputs:[],outputs:[{type:"ConfigView"}]},{name:"registerBrand",mutability:"mutable",payableInTokens:["EGLD"],inputs:[{name:"hash",type:"bytes"}],outputs:[]},{name:"brandWarp",mutability:"mutable",payableInTokens:["EGLD"],inputs:[{name:"warp",type:"bytes"},{name:"brand",type:"bytes"}],outputs:[]},{name:"getUserBrands",mutability:"readonly",inputs:[{name:"user",type:"Address"}],outputs:[{type:"variadic<bytes>",multi_result:!0}]}],events:[{identifier:"warpRegistered",inputs:[{name:"hash",type:"bytes",indexed:!0},{name:"alias",type:"bytes",indexed:!0},{name:"trust",type:"bytes",indexed:!0}]},{identifier:"warpUnregistered",inputs:[{name:"hash",type:"bytes",indexed:!0}]},{identifier:"warpUpgraded",inputs:[{name:"alias",type:"bytes",indexed:!0},{name:"new_warp",type:"bytes",indexed:!0},{name:"trust",type:"bytes",indexed:!0}]},{identifier:"warpVerified",inputs:[{name:"hash",type:"bytes",indexed:!0}]},{identifier:"aliasUpdated",inputs:[{name:"hash",type:"bytes",indexed:!0},{name:"alias",type:"bytes",indexed:!0}]},{identifier:"ownershipTransferred",inputs:[{name:"warp",type:"bytes",indexed:!0},{name:"old_owner",type:"Address",indexed:!0},{name:"new_owner",type:"Address",indexed:!0}]}],esdtAttributes:[],hasCallback:!1,types:{ConfigView:{type:"struct",fields:[{name:"unit_price",type:"BigUint"},{name:"admins",type:"List<Address>"}]},InfoView:{type:"struct",fields:[{name:"hash",type:"bytes"},{name:"alias",type:"Option<bytes>"},{name:"trust",type:"bytes"},{name:"owner",type:"Address"},{name:"created_at",type:"u64"},{name:"upgraded_at",type:"u64"},{name:"brand",type:"Option<bytes>"},{name:"upgrade",type:"Option<bytes>"}]}}};var E=s=>{if(s==="devnet")return"erd1qqqqqqqqqqqqqpgqje2f99vr6r7sk54thg03c9suzcvwr4nfl3tsfkdl36";if(s==="testnet")throw new Error("Multiversx testnet is not supported");return"erd1qqqqqqqqqqqqqpgq3mrpj3u6q7tejv6d7eqhnyd27n9v5c5tl3ts08mffe"};var pe=s=>({hash:s.hash.toString("hex"),alias:s.alias?.toString()||null,trust:s.trust.toString(),owner:s.owner.toString(),createdAt:s.created_at.toNumber(),upgradedAt:s.upgraded_at?.toNumber(),brand:s.brand?.toString("hex")||null,upgrade:s.upgrade?.toString("hex")||null}),bt=s=>({unitPrice:BigInt(s.unit_price.toString()),admins:s.admins.map(e=>e.toBech32())});var ue=class{constructor(e,t){this.config=e;this.chain=t;this.cache=new Jr(e.cache?.type),this.registryConfig={unitPrice:BigInt(0),admins:[]},this.userWallet=Xr(this.config,this.chain.name)}async init(){await this.loadRegistryConfigs()}getRegistryConfig(){return this.registryConfig}async createWarpRegisterTransaction(e,t,r){if(this.registryConfig.unitPrice===BigInt(0))throw new Error("WarpRegistry: config not loaded. forgot to call init()?");if(!this.userWallet)throw new Error("WarpRegistry: user address not set");let n=y.newFromBech32(this.userWallet),a=()=>this.isCurrentUserAdmin()?BigInt(0):t&&r?this.registryConfig.unitPrice*BigInt(3):t?this.registryConfig.unitPrice*BigInt(2):this.registryConfig.unitPrice,i=()=>t&&r?[w.fromHex(e),w.fromUTF8(t),w.fromHex(r)]:t?[w.fromHex(e),w.fromUTF8(t)]:[w.fromHex(e)];return await this.getFactory().createTransactionForExecute(n,{contract:y.newFromBech32(E(this.config.env)),function:"registerWarp",gasLimit:BigInt(1e7),nativeTransferAmount:a(),arguments:i()})}async createWarpUnregisterTransaction(e){if(!this.userWallet)throw new Error("WarpRegistry: user address not set");let t=y.newFromBech32(this.userWallet);return await this.getFactory().createTransactionForExecute(t,{contract:y.newFromBech32(E(this.config.env)),function:"unregisterWarp",gasLimit:BigInt(1e7),arguments:[w.fromHex(e)]})}async createWarpUpgradeTransaction(e,t,r){if(this.registryConfig.unitPrice===BigInt(0))throw new Error("WarpRegistry: config not loaded. forgot to call init()?");if(!this.userWallet)throw new Error("WarpRegistry: user address not set");let n=y.newFromBech32(this.userWallet);return await this.getFactory().createTransactionForExecute(n,{contract:y.newFromBech32(E(this.config.env)),function:"upgradeWarp",gasLimit:BigInt(1e7),nativeTransferAmount:this.isCurrentUserAdmin()?void 0:this.registryConfig.unitPrice,arguments:r?[w.fromUTF8(e),w.fromHex(t),w.fromHex(r)]:[w.fromUTF8(e),w.fromHex(t)]})}async createWarpAliasSetTransaction(e,t){if(!this.userWallet)throw new Error("WarpRegistry: user address not set");let r=y.newFromBech32(this.userWallet);return await this.getFactory().createTransactionForExecute(r,{contract:y.newFromBech32(E(this.config.env)),function:"setWarpAlias",gasLimit:BigInt(1e7),nativeTransferAmount:this.isCurrentUserAdmin()?void 0:this.registryConfig.unitPrice,arguments:[w.fromHex(e),w.fromUTF8(t)]})}async createWarpVerifyTransaction(e){if(!this.userWallet)throw new Error("WarpRegistry: user address not set");let t=y.newFromBech32(this.userWallet);return await this.getFactory().createTransactionForExecute(t,{contract:y.newFromBech32(E(this.config.env)),function:"verifyWarp",gasLimit:BigInt(1e7),arguments:[w.fromHex(e)]})}async createWarpTransferOwnershipTransaction(e,t){if(!this.userWallet)throw new Error("WarpRegistry: user address not set");let r=y.newFromBech32(this.userWallet);return await this.getFactory().createTransactionForExecute(r,{contract:y.newFromBech32(E(this.config.env)),function:"transferOwnership",gasLimit:BigInt(1e7),arguments:[w.fromHex(e),new ke(new y(t))]})}async createBrandRegisterTransaction(e){if(this.registryConfig.unitPrice===BigInt(0))throw new Error("WarpRegistry: config not loaded. forgot to call init()?");if(!this.userWallet)throw new Error("WarpRegistry: user address not set");let t=y.newFromBech32(this.userWallet);return await this.getFactory().createTransactionForExecute(t,{contract:y.newFromBech32(E(this.config.env)),function:"registerBrand",gasLimit:BigInt(1e7),nativeTransferAmount:this.isCurrentUserAdmin()?void 0:this.registryConfig.unitPrice,arguments:[w.fromHex(e)]})}async createWarpBrandingTransaction(e,t){if(!this.userWallet)throw new Error("WarpRegistry: user address not set");let r=y.newFromBech32(this.userWallet);return await this.getFactory().createTransactionForExecute(r,{contract:y.newFromBech32(E(this.config.env)),function:"brandWarp",gasLimit:BigInt(1e7),nativeTransferAmount:this.isCurrentUserAdmin()?void 0:this.registryConfig.unitPrice,arguments:[w.fromHex(e),w.fromHex(t)]})}async getInfoByAlias(e,t){try{let r=Fe.RegistryInfo(this.config.env,e),n=t?this.cache.get(r):null;if(n)return Oe.info(`WarpRegistry (getInfoByAlias): RegistryInfo found in cache: ${e}`),n;let a=y.newFromBech32(E(this.config.env)),i=this.getController(),o=i.createQuery({contract:a,function:"getInfoByAlias",arguments:[w.fromUTF8(e)]}),c=await i.runQuery(o),[d]=i.parseQueryResponse(c),m=d?pe(d):null,p=m?.brand?await this.fetchBrand(m.brand):null;return t&&t.ttl&&this.cache.set(r,{registryInfo:m,brand:p},t.ttl),{registryInfo:m,brand:p}}catch{return{registryInfo:null,brand:null}}}async getInfoByHash(e,t){try{let r=Fe.RegistryInfo(this.config.env,e);if(t){let p=this.cache.get(r);if(p)return Oe.info(`WarpRegistry (getInfoByHash): RegistryInfo found in cache: ${e}`),p}let n=y.newFromBech32(E(this.config.env)),a=this.getController(),i=a.createQuery({contract:n,function:"getInfoByHash",arguments:[w.fromHex(e)]}),o=await a.runQuery(i),[c]=a.parseQueryResponse(o),d=c?pe(c):null,m=d?.brand?await this.fetchBrand(d.brand):null;return t&&t.ttl&&this.cache.set(r,{registryInfo:d,brand:m},t.ttl),{registryInfo:d,brand:m}}catch{return{registryInfo:null,brand:null}}}async getUserWarpRegistryInfos(e){try{let t=e||this.userWallet;if(!t)throw new Error("WarpRegistry: user address not set");let r=y.newFromBech32(E(this.config.env)),n=this.getController(),a=n.createQuery({contract:r,function:"getUserWarps",arguments:[new ke(new y(t))]}),i=await n.runQuery(a),[o]=n.parseQueryResponse(i);return o.map(pe)}catch{return[]}}async getUserBrands(e){try{let t=e||this.userWallet;if(!t)throw new Error("WarpRegistry: user address not set");let r=y.newFromBech32(E(this.config.env)),n=this.getController(),a=n.createQuery({contract:r,function:"getUserBrands",arguments:[new ke(new y(t))]}),i=await n.runQuery(a),[o]=n.parseQueryResponse(i),c=o.map(p=>p.toString("hex")),d={ttl:365*24*60*60};return(await Promise.all(c.map(p=>this.fetchBrand(p,d)))).filter(p=>p!==null)}catch{return[]}}async fetchBrand(e,t){let r=Fe.Brand(this.config.env,e),n=t?this.cache.get(r):null;if(n)return Oe.info(`WarpRegistry (fetchBrand): Brand found in cache: ${e}`),n;let i=v(this.chain,this.config.env,this.config).createNetworkProvider();try{let o=await i.getTransaction(e),c=JSON.parse(o.data.toString());return c.meta={query:null,chain:this.chain.name,identifier:Qr(this.chain.name,"hash",e),hash:o.hash,creator:o.sender.toBech32(),createdAt:new Date(o.timestamp*1e3).toISOString()},t&&t.ttl&&this.cache.set(r,c,t.ttl),c}catch{return null}}async loadRegistryConfigs(){let e=y.newFromBech32(E(this.config.env)),t=this.getController(),[r]=await t.query({contract:e,function:"getConfig",arguments:[]}),n=r?bt(r):null;this.registryConfig=n||{unitPrice:BigInt(0),admins:[]}}getFactory(){let e=new jr({chainID:this.chain.chainId}),t=Pt.create(Ue);return new qr({config:e,abi:t})}getController(){let e=v(this.chain,this.config.env,this.config),t=Pt.create(Ue);return e.createSmartContractController(t)}isCurrentUserAdmin(){return!!this.userWallet&&this.registryConfig.admins.includes(this.userWallet)}};import{Address as cn}from"@multiversx/sdk-core";import{CacheTtl as Vt,initializeWalletCache as ln,WarpCache as pn}from"@vleap/warps";import{Account as Yr,Message as Zr,Mnemonic as Me}from"@multiversx/sdk-core";import{getWarpWalletAddressFromConfig as en,getWarpWalletMnemonicFromConfig as It,getWarpWalletPrivateKeyFromConfig as tn,setWarpWalletInConfig as St}from"@vleap/warps";var F=class F{constructor(e,t){this.config=e;this.chain=t;this.account=null}async getAddress(){let e=en(this.config,this.chain.name);if(e)return e;try{return this.getAccount().address.toBech32()}catch{return null}}async getPublicKey(){try{return this.getAccount().publicKey.hex()}catch{return null}}async signTransaction(e){return await this.getAccount().signTransaction(e),e}async signMessage(e){let t=this.getAccount(),r=new TextEncoder().encode(e),n=await t.signMessage(new Zr({data:r}));return Buffer.from(n).toString("hex")}getAccountInstance(){return this.getAccount()}async importFromMnemonic(e){let r=Me.fromString(e).deriveKey(0),n=r.hex(),i=r.generatePublicKey().toAddress(this.chain.addressHrp).toBech32(),o={provider:F.PROVIDER_NAME,address:i,privateKey:n,mnemonic:e};return St(this.config,this.chain.name,o),o}async importFromPrivateKey(e){let{UserSecretKey:t}=await import("@multiversx/sdk-wallet"),r=t.fromString(e),n=r.hex(),i=r.generatePublicKey().toAddress(this.chain.addressHrp).toBech32(),o={provider:F.PROVIDER_NAME,address:i,privateKey:n,mnemonic:null};return St(this.config,this.chain.name,o),o}async export(){let e=this.getAccount(),t=It(this.config,this.chain.name),r=tn(this.config,this.chain.name);return{provider:F.PROVIDER_NAME,address:e.address.toBech32(),privateKey:r||null,mnemonic:t||null}}async generate(){let e=Me.generate(),t=e.toString(),a=e.deriveKey(0).generatePublicKey().toAddress(this.chain.addressHrp).toBech32();return{provider:F.PROVIDER_NAME,address:a,privateKey:null,mnemonic:t}}getAccount(){if(this.account)return this.account;let e=It(this.config,this.chain.name);if(!e)throw new Error("No mnemonic provided");let r=Me.fromString(e).deriveKey(0);return this.account=new Yr(r),this.account}};F.PROVIDER_NAME="mnemonic";var D=F;import{Account as rn,Message as nn,Mnemonic as an,UserSecretKey as G}from"@multiversx/sdk-core";import{getWarpWalletAddressFromConfig as sn,getWarpWalletMnemonicFromConfig as on,getWarpWalletPrivateKeyFromConfig as Bt,setWarpWalletInConfig as Nt}from"@vleap/warps";var O=class O{constructor(e,t){this.config=e;this.chain=t;this.account=null}async getAddress(){let e=sn(this.config,this.chain.name);if(e)return e;try{return this.getAccount().address.toBech32()}catch{return null}}async getPublicKey(){try{return this.getAccount().publicKey.hex()}catch{return null}}async signTransaction(e){return await this.getAccount().signTransaction(e),e}async signMessage(e){let t=this.getAccount(),r=new TextEncoder().encode(e),n=await t.signMessage(new nn({data:r}));return Buffer.from(n).toString("hex")}getAccountInstance(){return this.getAccount()}async importFromMnemonic(e){let r=an.fromString(e).deriveKey(0),n=r.hex(),i=r.generatePublicKey().toAddress(this.chain.addressHrp).toBech32(),o={provider:O.PROVIDER_NAME,address:i,privateKey:n,mnemonic:e};return Nt(this.config,this.chain.name,o),o}async importFromPrivateKey(e){let r=e.startsWith("-----")?G.fromPem(e):G.fromString(e),n=r.hex(),i=r.generatePublicKey().toAddress(this.chain.addressHrp).toBech32(),o={provider:O.PROVIDER_NAME,address:i,privateKey:n,mnemonic:null};return Nt(this.config,this.chain.name,o),o}async export(){let e=this.getAccount(),t=Bt(this.config,this.chain.name),r=on(this.config,this.chain.name);return{provider:O.PROVIDER_NAME,address:e.address.toBech32(),privateKey:t||null,mnemonic:r||null}}async generate(){let e=G.generate(),t=e.hex(),n=e.generatePublicKey().toAddress(this.chain.addressHrp).toBech32();return{provider:O.PROVIDER_NAME,address:n,privateKey:t,mnemonic:null}}getAccount(){if(this.account)return this.account;let e=Bt(this.config,this.chain.name);if(!e)throw new Error("No private key provided");let r=e.startsWith("-----")?G.fromPem(e):G.fromString(e);return this.account=new rn(r),this.account}};O.PROVIDER_NAME="privateKey";var L=O;import{getWarpWalletAddressFromConfig as z}from"@vleap/warps";var K=class{constructor(e,t){this.config=e;this.chain=t}async getAddress(){return z(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=z(this.config,this.chain.name);throw new Error(`Wallet can not be used for signing: ${t}`)}async importFromPrivateKey(e){let t=z(this.config,this.chain.name);throw new Error(`Wallet can not be used for signing: ${t}`)}async export(){let e=z(this.config,this.chain.name);throw new Error(`Wallet can not be used for signing: ${e}`)}async generate(){let e=z(this.config,this.chain.name);throw new Error(`Wallet can not be used for signing: ${e}`)}};var me=class{constructor(e,t){this.config=e;this.chain=t;this.cachedAddress=null;this.cachedPublicKey=null;this.entry=v(t,e.env,e),this.cache=new pn(e.cache?.type),this.walletProvider=this.createProvider(),this.initializeCache()}async signTransaction(e){if(!e||typeof e!="object")throw new Error("Invalid transaction object");if(!this.walletProvider)throw new Error("No wallet provider available");if(this.walletProvider instanceof K)throw new Error(`Wallet (${this.chain.name}) is read-only`);if(this.walletProvider instanceof L||this.walletProvider instanceof D){let r=this.walletProvider.getAccountInstance();if(e.nonce===0n){let n=await this.entry.recallAccountNonce(r.address),a=this.cache.get(`nonce:${r.address.toBech32()}`)||0,i=BigInt(Math.max(a,Number(n)));e.nonce=i}}else if(e.nonce===0n&&this.cachedAddress){let r=cn.newFromBech32(this.cachedAddress),n=await this.entry.recallAccountNonce(r),a=this.cache.get(`nonce:${this.cachedAddress}`)||0,i=BigInt(Math.max(a,Number(n)));e.nonce=i}let t=await this.walletProvider.signTransaction(e);if(this.walletProvider instanceof L||this.walletProvider instanceof D){let r=this.walletProvider.getAccountInstance(),n=Number(r.nonce)+1;this.cache.set(`nonce:${r.address.toBech32()}`,n,Vt.OneMinute)}else if(this.cachedAddress){let r=e.nonce?Number(e.nonce):0;this.cache.set(`nonce:${this.cachedAddress}`,r+1,Vt.OneMinute)}return t}async signTransactions(e){let t=[];for(let r of e)t.push(await this.signTransaction(r));return t}async signMessage(e){if(!this.walletProvider)throw new Error("No wallet provider available");if(this.walletProvider instanceof K)throw new Error(`Wallet (${this.chain.name}) is read-only`);return await this.walletProvider.signMessage(e)}async sendTransactions(e){return Promise.all(e.map(async t=>this.sendTransaction(t)))}async sendTransaction(e){if(!e||typeof e!="object")throw new Error("Invalid transaction object");if(!e.signature)throw new Error("Transaction must be signed before sending");return await this.entry.sendTransaction(e)}async importFromMnemonic(e,t){return await this.createProviderForOperation(e).importFromMnemonic(t)}async importFromPrivateKey(e,t){return await this.createProviderForOperation(e).importFromPrivateKey(t)}async export(e){return await this.createProviderForOperation(e).export()}async generate(e){return await this.createProviderForOperation(e).generate()}getAddress(){return this.cachedAddress}getPublicKey(){return this.cachedPublicKey}createProvider(){let e=this.config.user?.wallets?.[this.chain.name];return e?typeof e=="string"?new K(this.config,this.chain):this.createProviderForOperation(e.provider):null}initializeCache(){ln(this.walletProvider).then(e=>{this.cachedAddress=e.address,this.cachedPublicKey=e.publicKey})}createProviderForOperation(e){let r=this.config.walletProviders?.[this.chain.name]?.[e];if(r){let n=r(this.config,this.chain);if(!n)throw new Error(`Custom wallet provider factory returned null for ${e}`);return n}if(e==="privateKey")return new L(this.config,this.chain);if(e==="mnemonic")return new D(this.config,this.chain);throw new Error(`Unsupported wallet provider for ${this.chain.name}: ${e}`)}};var de=(s,e)=>(t,r)=>{let n=e[t.env],a=new un;return a.registerType("token",{stringToNative:i=>i,nativeToString:i=>`token:${i}`}),a.registerType("codemeta",{stringToNative:i=>i,nativeToString:i=>`codemeta:${i}`}),a.registerTypeAlias("list","vector"),{chainInfo:n,builder:()=>new J(t,n),executor:new ce(t,n,a),output:new R(t,n,a),serializer:new B({typeRegistry:a}),registry:new ue(t,n),explorer:new le(s,t),abiBuilder:()=>new S(t,n),brandBuilder:()=>new X(t,n),dataLoader:new Z(t,n),wallet:new me(t,n)}};import{WarpChainName as q}from"@vleap/warps";var Re={chain:q.Multiversx,identifier:"EGLD",name:"eGold",symbol:"EGLD",decimals:18,logoUrl:"https://joai.ai/images/tokens/egld.svg"},Ut=de(q.Multiversx,{mainnet:{name:q.Multiversx,displayName:"MultiversX",chainId:"1",blockTime:6e3,addressHrp:"erd",defaultApiUrl:"https://api.multiversx.com",logoUrl:"https://joai.ai/images/chains/multiversx.svg",nativeToken:Re},testnet:{name:q.Multiversx,displayName:"MultiversX Testnet",chainId:"T",blockTime:6e3,addressHrp:"erd",defaultApiUrl:"https://testnet-api.multiversx.com",logoUrl:"https://joai.ai/images/chains/multiversx.svg",nativeToken:Re},devnet:{name:q.Multiversx,displayName:"MultiversX Devnet",chainId:"D",blockTime:6e3,addressHrp:"erd",defaultApiUrl:"https://devnet-api.multiversx.com",logoUrl:"https://joai.ai/images/chains/multiversx.svg",nativeToken:Re}});import{WarpChainName as Le}from"@vleap/warps";var mn={chain:Le.Vibechain,identifier:"VIBE",name:"VIBE",symbol:"VIBE",decimals:18,logoUrl:"https://joai.ai/images/tokens/vibe.svg"},De={name:Le.Vibechain,displayName:"VibeChain",chainId:"V",blockTime:600,addressHrp:"vibe",defaultApiUrl:"https://vibeox-api.multiversx.com",logoUrl:"https://joai.ai/images/chains/vibechain.svg",nativeToken:mn},kt=de(Le.Vibechain,{mainnet:De,testnet:De,devnet:De});var jo=()=>[Ut,kt];import{WarpConstants as he,WarpSerializer as Ke}from"@vleap/warps";var Zo=s=>new Ke().nativeToString(f.Token,s),ec=s=>new Ke().nativeToString(f.CodeMeta,s),tc=(s,e)=>{if(e===null)return f.Optional+he.ArgParamsSeparator;let t=s(e),r=t.indexOf(he.ArgParamsSeparator),n=t.substring(0,r),a=t.substring(r+1);return f.Optional+he.ArgParamsSeparator+n+he.ArgParamsSeparator+a},rc=s=>new Ke().nativeToString(f.List,s);import{Address as dn,AddressValue as hn,BigUIntType as gn,BigUIntValue as Ft,BooleanValue as fn,BytesValue as yn,CodeMetadata as Wn,CodeMetadataValue as vn,CompositeType as wn,CompositeValue as Tn,Field as _e,FieldDefinition as $e,List as Cn,NothingValue as An,OptionalValue as He,OptionValue as Ge,StringValue as xn,Struct as En,StructType as bn,TokenIdentifierType as Pn,TokenIdentifierValue as Ot,U16Value as In,U32Value as Sn,U64Type as Bn,U64Value as Mt,U8Value as Nn,VariadicValue as Vn}from"@multiversx/sdk-core";var cc=(s,e)=>s?Ge.newProvided(s):e?Ge.newMissingTyped(e):Ge.newMissing(),lc=(s,e)=>s?new He(s.getType(),s):e?new He(e):He.newMissing(),pc=s=>{if(s.length===0)throw new Error("Cannot create a list from an empty array");let e=s[0].getType();return new Cn(e,s)},uc=s=>Vn.fromItems(...s),mc=s=>{let e=s.map(t=>t.getType());return new Tn(new wn(...e),s)},dc=s=>xn.fromUTF8(s),hc=s=>new Nn(s),gc=s=>new In(s),fc=s=>new Sn(s),yc=s=>new Mt(s),Wc=s=>new Ft(BigInt(s)),vc=s=>new fn(s),wc=s=>new hn(dn.newFromBech32(s)),Tc=s=>new Ot(s),Cc=s=>yn.fromHex(s),Ac=s=>new En(new bn("EsdtTokenPayment",[new $e("token_identifier","",new Pn),new $e("token_nonce","",new Bn),new $e("amount","",new gn)]),[new _e(new Ot(s.token.identifier),"token_identifier"),new _e(new Mt(BigInt(s.token.nonce)),"token_nonce"),new _e(new Ft(BigInt(s.amount)),"amount")]),xc=s=>new vn(Wn.newFromBytes(Uint8Array.from(Buffer.from(s,"hex")))),Ec=()=>new An;export{U as ExplorerUrls,st as KnownTokens,Ut as MultiversxAdapter,vr as MultiversxExplorers,ct as MultiversxExplorersConfig,Re as NativeTokenEgld,mn as NativeTokenVibe,kt as VibechainAdapter,wr as VibechainExplorers,S as WarpMultiversxAbiBuilder,X as WarpMultiversxBrandBuilder,J as WarpMultiversxBuilder,gi as WarpMultiversxConstants,Q as WarpMultiversxContractLoader,Z as WarpMultiversxDataLoader,ce as WarpMultiversxExecutor,le as WarpMultiversxExplorer,f as WarpMultiversxInputTypes,R as WarpMultiversxOutput,ue as WarpMultiversxRegistry,B as WarpMultiversxSerializer,me as WarpMultiversxWallet,wc as address_value,Ac as asset_value,Wc as biguint_value,vc as boolean_value,ec as codemeta,xc as codemeta_value,mc as composite_value,de as createMultiversxAdapter,ot as findKnownTokenById,jo as getAllMultiversxAdapters,Fn as getAllMultiversxChainNames,Ya as getKnownTokensForChain,v as getMultiversxEntrypoint,E as getMultiversxRegistryAddress,j as getNormalizedTokenIdentifier,Cc as hex_value,M as isNativeToken,rc as list,pc as list_value,Ec as nothing_value,cc as option_value,tc as optional,lc as optional_value,dc as string_value,bt as toTypedConfigInfo,pe as toTypedRegistryInfo,Zo as token,Tc as token_value,gc as u16_value,fc as u32_value,yc as u64_value,hc as u8_value,uc as variadic_value};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vleap/warps-adapter-multiversx",
3
- "version": "0.2.0-beta.90",
3
+ "version": "0.2.0-beta.91",
4
4
  "description": "",
5
5
  "type": "module",
6
6
  "types": "./dist/index.d.ts",
@@ -38,6 +38,6 @@
38
38
  },
39
39
  "dependencies": {
40
40
  "@multiversx/sdk-core": "^15.3.1",
41
- "@vleap/warps": "^3.0.0-beta.181"
41
+ "@vleap/warps": "^3.0.0-beta.184"
42
42
  }
43
43
  }