@vleap/warps-adapter-multiversx 0.2.0-beta.79 → 0.2.0-beta.80

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
@@ -288,6 +288,7 @@ declare class WarpMultiversxWallet implements AdapterWarpWallet {
288
288
  mnemonic: string;
289
289
  };
290
290
  getAddress(): string | null;
291
+ getPublicKey(): string | null;
291
292
  }
292
293
 
293
294
  export { type ExplorerName, ExplorerUrls, KnownTokens, MultiversxExplorers, MultiversxExplorersConfig, NativeTokenEgld, NativeTokenVibe, 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, getMultiversxAdapter, getMultiversxEntrypoint, getMultiversxRegistryAddress, getNormalizedTokenIdentifier, getVibechainAdapter, 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.d.ts CHANGED
@@ -288,6 +288,7 @@ declare class WarpMultiversxWallet implements AdapterWarpWallet {
288
288
  mnemonic: string;
289
289
  };
290
290
  getAddress(): string | null;
291
+ getPublicKey(): string | null;
291
292
  }
292
293
 
293
294
  export { type ExplorerName, ExplorerUrls, KnownTokens, MultiversxExplorers, MultiversxExplorersConfig, NativeTokenEgld, NativeTokenVibe, 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, getMultiversxAdapter, getMultiversxEntrypoint, getMultiversxRegistryAddress, getNormalizedTokenIdentifier, getVibechainAdapter, 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.js CHANGED
@@ -1 +1 @@
1
- "use strict";var fe=Object.defineProperty;var $e=Object.getOwnPropertyDescriptor;var ze=Object.getOwnPropertyNames;var qe=Object.prototype.hasOwnProperty;var Ke=(s,e)=>{for(var t in e)fe(s,t,{get:e[t],enumerable:!0})},Qe=(s,e,t,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let a of ze(e))!qe.call(s,a)&&a!==t&&fe(s,a,{get:()=>e[a],enumerable:!(r=$e(e,a))||r.enumerable});return s};var je=s=>Qe(fe({},"__esModule",{value:!0}),s);var Et={};Ke(Et,{ExplorerUrls:()=>H,KnownTokens:()=>ye,MultiversxExplorers:()=>Re,MultiversxExplorersConfig:()=>we,NativeTokenEgld:()=>de,NativeTokenVibe:()=>Ge,VibechainExplorers:()=>Le,WarpMultiversxAbiBuilder:()=>M,WarpMultiversxBrandBuilder:()=>ne,WarpMultiversxBuilder:()=>ae,WarpMultiversxConstants:()=>Je,WarpMultiversxContractLoader:()=>re,WarpMultiversxDataLoader:()=>ie,WarpMultiversxExecutor:()=>se,WarpMultiversxExplorer:()=>oe,WarpMultiversxInputTypes:()=>v,WarpMultiversxOutput:()=>j,WarpMultiversxRegistry:()=>pe,WarpMultiversxSerializer:()=>R,WarpMultiversxWallet:()=>le,address_value:()=>wt,asset_value:()=>Ct,biguint_value:()=>yt,boolean_value:()=>vt,codemeta:()=>at,codemeta_value:()=>xt,composite_value:()=>ut,createMultiversxAdapter:()=>ue,findKnownTokenById:()=>ve,getAllMultiversxAdapters:()=>tt,getAllMultiversxChainNames:()=>rt,getKnownTokensForChain:()=>Xe,getMultiversxAdapter:()=>Ce,getMultiversxEntrypoint:()=>T,getMultiversxRegistryAddress:()=>B,getNormalizedTokenIdentifier:()=>te,getVibechainAdapter:()=>Ae,hex_value:()=>Wt,isNativeToken:()=>q,list:()=>st,list_value:()=>pt,nothing_value:()=>At,option_value:()=>ot,optional:()=>it,optional_value:()=>ct,string_value:()=>mt,toTypedConfigInfo:()=>We,toTypedRegistryInfo:()=>ce,token:()=>nt,token_value:()=>Tt,u16_value:()=>ht,u32_value:()=>ft,u64_value:()=>gt,u8_value:()=>dt,variadic_value:()=>lt});module.exports=je(Et);var Ee=require("@vleap/warps");var Z=require("@vleap/warps");var _e=require("@vleap/warps");var O=require("@multiversx/sdk-core"),E=require("@vleap/warps");var X=require("@multiversx/sdk-core"),be=require("@vleap/warps"),q=s=>!s.includes("-"),te=s=>q(s)?`${s}-000000`:s,T=(s,e,t)=>{let r="warp-sdk",i=t?(0,be.getProviderConfig)(t,s.name,e,s.defaultApiUrl):{url:s.defaultApiUrl},o=i.url,p={headers:i.headers};return e==="devnet"?new X.DevnetEntrypoint({url:o,kind:"api",clientName:r,networkProviderConfig:p}):e==="testnet"?new X.TestnetEntrypoint({url:o,kind:"api",clientName:r,networkProviderConfig:p}):new X.MainnetEntrypoint({url:o,kind:"api",clientName:r,networkProviderConfig:p})};var ge=require("@vleap/warps");var re=class{constructor(e){this.config=e}async getContract(e,t){try{let i=await T(t,this.config.env,this.config).createNetworkProvider().doGetGeneric(`accounts/${e}`);return{address:e,owner:i.ownerAddress,verified:i.isVerified||!1}}catch(r){return ge.WarpLogger.error("WarpContractLoader: getContract error",r),null}}async getVerificationInfo(e,t){try{let i=await T(t,this.config.env,this.config).createNetworkProvider().doGetGeneric(`accounts/${e}/verification`);return{codeHash:i.codeHash,abi:i.source.abi}}catch(r){return ge.WarpLogger.error("WarpContractLoader: getVerificationInfo error",r),null}}};var M=class{constructor(e,t){this.config=e;this.chain=t;this.contractLoader=new re(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 O.TransactionsFactoryConfig({chainID:this.chain.chainId}),a=new O.TransferTransactionsFactory({config:r}),i=O.Address.newFromBech32(t),o={protocol:(0,E.getLatestProtocolIdentifier)("abi"),content:e},p=JSON.stringify(o),c=await a.createTransactionForTransfer(i,{receiver:i,nativeAmount:BigInt(0),data:Uint8Array.from(Buffer.from(p))});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=T(this.chain,this.config.env,this.config).createNetworkProvider();try{let o=await i.getTransaction(e),p=await this.createFromTransaction(o);return t&&t.ttl&&p&&this.cache.set(r,p,t.ttl),p}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 O.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 O.AbiRegistry.create(r.content)}else{let r=await(await fetch(e.abi)).json();return O.AbiRegistry.create(r)}}};var K=require("@multiversx/sdk-core"),_=require("@vleap/warps"),Se=require("buffer");var ne=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 K.TransactionsFactoryConfig({chainID:this.chain.chainId}),a=new K.TransferTransactionsFactory({config:r}),i=K.Address.newFromBech32(t),o=JSON.stringify(e);return await a.createTransactionForNativeTokenTransfer(i,{receiver:K.Address.newFromBech32(t),nativeAmount:BigInt(0),data:Uint8Array.from(Se.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=T(this.chain,this.config.env,this.config).createNetworkProvider();try{let a=await r.getTransaction(e);return this.createFromTransaction(a)}catch(a){return _.WarpLogger.error("BrandBuilder: Error creating from transaction hash",a),null}}};var Q=require("@multiversx/sdk-core"),N=require("@vleap/warps");var ae=class extends N.WarpBuilder{constructor(t,r){super(t);this.config=t;this.chain=r;this.cache=new N.WarpCache(t.cache?.type),this.core=new N.WarpBuilder(t)}async createInscriptionTransaction(t){let r=(0,N.getWarpWalletAddressFromConfig)(this.config,this.chain.name);if(!r)throw new Error("WarpBuilder: user address not set");let a=new Q.TransactionsFactoryConfig({chainID:this.chain.chainId}),i=new Q.TransferTransactionsFactory({config:a}),o=Q.Address.newFromBech32(r),p=JSON.stringify(t),c=await i.createTransactionForTransfer(o,{receiver:Q.Address.newFromBech32(r),nativeAmount:BigInt(0),data:Uint8Array.from(Buffer.from(p))});return c.gasLimit=c.gasLimit+BigInt(2e6),c}async createFromTransaction(t,r=!1){let a=await this.core.createFromRaw(t.data.toString(),r);return a.meta={chain:this.chain.name,identifier:(0,N.createWarpIdentifier)(this.chain.name,"hash",t.hash),query:null,hash:t.hash,creator:t.sender.toBech32(),createdAt:new Date(t.timestamp*1e3).toISOString()},a}async createFromTransactionHash(t,r){let a=N.WarpCacheKey.Warp(this.config.env,t);if(r){let p=this.cache.get(a);if(p)return N.WarpLogger.info(`WarpBuilder (createFromTransactionHash): Warp found in cache: ${t}`),p}let o=T(this.chain,this.config.env,this.config).createNetworkProvider();try{let p=await o.getTransaction(t),c=await this.createFromTransaction(p);return r&&r.ttl&&c&&this.cache.set(a,c,r.ttl),c}catch(p){return N.WarpLogger.error("WarpBuilder: Error creating from transaction hash",p),null}}};var G=require("@multiversx/sdk-core"),J=require("@vleap/warps");var Be=require("@vleap/warps"),Ie=Be.WarpChainName.Multiversx,Pe=[{chain:Ie,identifier:"EGLD",name:"eGold",symbol:"EGLD",decimals:18,logoUrl:"https://tools.multiversx.com/assets-cdn/tokens/EGLD-000000/icon.png"},{chain:Ie,identifier:"EGLD-000000",name:"eGold",symbol:"EGLD",decimals:18,logoUrl:"https://tools.multiversx.com/assets-cdn/tokens/EGLD-000000/icon.png"}];var Ne=require("@vleap/warps"),I=Ne.WarpChainName.Multiversx,Ve=[{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 ke=require("@vleap/warps"),Ue=ke.WarpChainName.Multiversx,Fe=[{chain:Ue,identifier:"EGLD",name:"eGold",symbol:"EGLD",decimals:18,logoUrl:"https://tools.multiversx.com/assets-cdn/tokens/EGLD-000000/icon.png"},{chain:Ue,identifier:"EGLD-000000",name:"eGold",symbol:"EGLD",decimals:18,logoUrl:"https://tools.multiversx.com/assets-cdn/tokens/EGLD-000000/icon.png"}];var Me=require("@vleap/warps"),Oe=Me.WarpChainName.Vibechain,me=[{chain:Oe,identifier:"VIBE",name:"VIBE",symbol:"VIBE",decimals:18,logoUrl:"https://vleap.ai/images/tokens/vibe.svg"},{chain:Oe,identifier:"VIBE-000000",name:"VIBE",symbol:"VIBE",decimals:18,logoUrl:"https://vleap.ai/images/tokens/vibe.svg"}];var ye={multiversx:{mainnet:Ve,testnet:Fe,devnet:Pe},vibechain:{mainnet:me,testnet:me,devnet:me}},ve=(s,e,t)=>(ye[s]?.[e]||[]).find(a=>a.identifier===t)||null,Xe=(s,e)=>ye[s]?.[e]||[];var ie=class{constructor(e,t){this.config=e;this.chain=t;this.cache=new J.WarpCache(e.cache?.type)}async getAccount(e){let r=await T(this.chain,this.config.env,this.config).createNetworkProvider().getAccount(G.Address.newFromBech32(e));return{chain:this.chain.name,address:r.address.toBech32(),balance:r.balance}}async getAccountAssets(e){let t=T(this.chain,this.config.env,this.config).createNetworkProvider(),r=t.getAccount(G.Address.newFromBech32(e)),a=t.getFungibleTokensOfAccount(G.Address.newFromBech32(e)),[i,o]=await Promise.all([r,a]),p=i.balance>0?[{...this.chain.nativeToken,amount:i.balance}]:[];return p.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}))),p}async getAsset(e){let t=J.WarpCacheKey.Asset(this.config.env,this.chain.name,e),r=this.cache.get(t);if(r)return r;let a=ve(this.chain.name,this.config.env,e);if(a)return{chain:this.chain.name,identifier:e,name:a.name,symbol:a.symbol,amount:0n,decimals:a.decimals,logoUrl:a.logoUrl};let i=new G.TokenComputer,o=q(e)?0n:i.extractNonceFromExtendedIdentifier(e),p=new G.Token({identifier:e,nonce:BigInt(o||0)}),c=i.isFungible(p),g=T(this.chain,this.config.env,this.config).createNetworkProvider(),f=te(e),d=await g.doGetGeneric(`tokens/${f}`),w={chain:this.chain.name,identifier:p.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,w,J.CacheTtl.OneHour),w}async getAction(e,t=!1){let r=T(this.chain,this.config.env,this.config),a=t?await r.awaitCompletedTransaction(e):await r.getTransaction(e);return{chain:this.chain.name,id:a.hash,receiver:a.receiver.toBech32(),sender:a.sender.toBech32(),value:a.value,function:a.function,status:this.toActionStatus(a),createdAt:this.toActionCreatedAt(a),error:a?.smartContractResults.map(i=>i.raw.returnMessage)[0]||null,tx:a}}async getAccountActions(e,t){let r=T(this.chain,this.config.env,this.config).createNetworkProvider(),a=`accounts/${e}/transactions`,i=new URLSearchParams,o=t?.size||25,p=t?.page||0;if(p>0){let g=p*o;i.append("from",g.toString())}return o!==25&&i.append("size",o.toString()),i.toString()&&(a+=`?${i.toString()}`),(await r.doGetGeneric(a)).map(g=>({chain:this.chain.name,id:g.txHash,receiver:g.receiver,sender:g.sender,value:g.value,function:g.function,status:this.toActionStatus(g),createdAt:this.toActionCreatedAt(g)}))}toActionStatus(e){return e.status.isSuccessful()?"success":e.status.isFailed()?"failed":"pending"}toActionCreatedAt(e){return new Date(e.timestamp||e.timestamp*1e3).toISOString()}};var C=require("@multiversx/sdk-core"),k=require("@vleap/warps");var Y=require("@multiversx/sdk-core"),W=require("@vleap/warps");var n=require("@multiversx/sdk-core"),De=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.chain.name]},ChainApiUrl:{Placeholder:"CHAIN_API",Accessor:s=>s.chain.defaultApiUrl},ChainAddressHrp:{Placeholder:"CHAIN_ADDRESS_HRP",Accessor:s=>s.chain.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 Je={Egld:{Identifier:"EGLD",EsdtIdentifier:"EGLD-000000",DisplayName:"eGold",Decimals:18}},v={Null:"null",Optional:"optional",List:"list",Token:"token",CodeMeta:"codemeta"},Re=(r=>(r.MultiversxExplorer="multiversx_explorer",r.MultiversxExplorerDevnet="multiversx_explorer_devnet",r.MultiversxExplorerTestnet="multiversx_explorer_testnet",r))(Re||{}),Le=(r=>(r.VibechainExplorer="vibechain_explorer",r.VibechainExplorerDevnet="vibechain_explorer_devnet",r.VibechainExplorerTestnet="vibechain_explorer_testnet",r))(Le||{}),we={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 Ye=new RegExp(`${h.ArgParamsSeparator}(.*)`),R=class{constructor(e){this.coreSerializer=new De.WarpSerializer(e)}typedToString(e){let t=e.getType();if(t.hasExactClass(n.OptionType.ClassName)||e.hasClassOrSuperclass(n.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(n.VariadicType.ClassName)||e.hasClassOrSuperclass(n.VariadicValue.ClassName)){let r=e.getItems();if(r.length===0){let f=this.typeToString(t.getFirstTypeParameter());return u.Vector+h.ArgParamsSeparator+f+h.ArgParamsSeparator}let a=r.map(f=>this.typedToString(f));if(a.every(f=>f.startsWith(u.Tuple)))return u.Vector+h.ArgParamsSeparator+a.join(",");let i=a[0],o=i.indexOf(h.ArgParamsSeparator),p=i.substring(0,o),c=a.map(f=>{let d=f.indexOf(h.ArgParamsSeparator);return f.substring(d+1)}),g=p.startsWith(u.Struct)?h.ArgStructSeparator:h.ArgListSeparator;return u.Vector+h.ArgParamsSeparator+p+h.ArgParamsSeparator+c.join(g)}if(t.hasExactClass(n.OptionalType.ClassName)||e.hasClassOrSuperclass(n.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(n.ListType.ClassName)||e.hasClassOrSuperclass(n.List.ClassName)){let a=e.getItems().map(c=>this.typedToString(c));if(a.every(c=>c.startsWith(u.Tuple)))return v.List+h.ArgParamsSeparator+a.join(",");let o=a.map(c=>c.split(h.ArgParamsSeparator)[0])[0],p=a.map(c=>c.split(h.ArgParamsSeparator)[1]);return v.List+h.ArgParamsSeparator+o+h.ArgParamsSeparator+p.join(h.ArgListSeparator)}if(t.hasExactClass(n.CompositeType.ClassName)||e.hasClassOrSuperclass(n.CompositeValue.ClassName)){let a=e.getItems().map(i=>{let o=this.typedToString(i),p=o.indexOf(h.ArgParamsSeparator),c=o.substring(0,p),g=o.substring(p+1);return`${c},${g}`});return`${u.Tuple}(${a.join(",")})`}if(t.hasExactClass(n.BigUIntType.ClassName)||e.hasClassOrSuperclass(n.BigUIntValue.ClassName)||t.getName()==="BigUint")return u.Biguint+h.ArgParamsSeparator+BigInt(e.valueOf().toFixed());if(t.hasExactClass(n.U8Type.ClassName)||e.hasClassOrSuperclass(n.U8Value.ClassName))return u.Uint8+h.ArgParamsSeparator+e.valueOf().toNumber();if(t.hasExactClass(n.U16Type.ClassName)||e.hasClassOrSuperclass(n.U16Value.ClassName))return u.Uint16+h.ArgParamsSeparator+e.valueOf().toNumber();if(t.hasExactClass(n.U32Type.ClassName)||e.hasClassOrSuperclass(n.U32Value.ClassName))return u.Uint32+h.ArgParamsSeparator+e.valueOf().toNumber();if(t.hasExactClass(n.U64Type.ClassName)||e.hasClassOrSuperclass(n.U64Value.ClassName))return u.Uint64+h.ArgParamsSeparator+BigInt(e.valueOf().toFixed());if(t.hasExactClass(n.StringType.ClassName)||e.hasClassOrSuperclass(n.StringValue.ClassName))return u.String+h.ArgParamsSeparator+e.valueOf();if(t.hasExactClass(n.BooleanType.ClassName)||e.hasClassOrSuperclass(n.BooleanValue.ClassName))return u.Bool+h.ArgParamsSeparator+e.valueOf();if(t.hasExactClass(n.AddressType.ClassName)||e.hasClassOrSuperclass(n.AddressValue.ClassName))return u.Address+h.ArgParamsSeparator+e.valueOf().toBech32();if(t.hasExactClass(n.BytesType.ClassName)||e.hasClassOrSuperclass(n.BytesValue.ClassName))return u.Hex+h.ArgParamsSeparator+e.valueOf().toString("hex");if(t.getName()==="EsdtTokenPayment"){let r=e.getFieldValue("token_identifier").valueOf(),a=e.getFieldValue("token_nonce").valueOf(),i=e.getFieldValue("amount").valueOf(),p=new n.TokenComputer().computeExtendedIdentifier(new n.Token({identifier:r,nonce:BigInt(a)}));return u.Asset+h.ArgParamsSeparator+p+h.ArgCompositeSeparator+i}if(t.hasExactClass(n.StructType.ClassName)||e.hasClassOrSuperclass(n.Struct.ClassName)){let r=e,i=r.getType().getName(),o=r.getFields();if(o.length===0)return`${u.Struct}(${i})${h.ArgParamsSeparator}`;let p=o.map(c=>{let g=c.value.getType(),d=this.typedToString(c.value).split(h.ArgParamsSeparator),w=d.length>2?d.slice(2).join(h.ArgParamsSeparator):d[1]||"";return`(${c.name}${h.ArgParamsSeparator}${this.typeToString(g)})${w}`});return`${u.Struct}(${i})${h.ArgParamsSeparator}${p.join(h.ArgListSeparator)}`}if(t.hasExactClass(n.TokenIdentifierType.ClassName)||e.hasClassOrSuperclass(n.TokenIdentifierValue.ClassName))return v.Token+h.ArgParamsSeparator+e.valueOf();if(t.hasExactClass(n.CodeMetadataType.ClassName)||e.hasClassOrSuperclass(n.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(","),a=[];for(let i=0;i<r.length;i+=2)a.push(r[i]);return new n.CompositeType(...a.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 n.StructType(r,[])}if(e===u.String)return new n.StringType;if(e===u.Uint8)return new n.U8Type;if(e===u.Uint16)return new n.U16Type;if(e===u.Uint32)return new n.U32Type;if(e===u.Uint64)return new n.U64Type;if(e===u.Biguint)return new n.BigUIntType;if(e===u.Bool)return new n.BooleanType;if(e===u.Address)return new n.AddressType;if(e===u.Hex)return new n.BytesType;if(e===u.Asset)return new n.StructType("EsdtTokenPayment",[new n.FieldDefinition("token_identifier","",new n.TokenIdentifierType),new n.FieldDefinition("token_nonce","",new n.U64Type),new n.FieldDefinition("amount","",new n.BigUIntType)]);if(e===v.Token)return new n.TokenIdentifierType;if(e===v.CodeMeta)return new n.CodeMetadataType;throw new Error(`WarpArgSerializer (nativeToType): Unsupported input type: ${e}`)}stringToTyped(e){let[t,r]=e.split(/:(.*)/,2);if(t===u.Option){let a=this.stringToTyped(r);return a instanceof n.NothingValue?n.OptionValue.newMissingTyped(a.getType()):n.OptionValue.newProvided(a)}if(t===u.Vector){let a=r.indexOf(h.ArgParamsSeparator),i=r.substring(0,a),o=r.substring(a+1);if(i.startsWith(u.Tuple)){let d=o.split(",").map(w=>this.stringToTyped(w));return new n.VariadicValue(new n.VariadicType(this.nativeToType(i)),d)}if(o.includes("tuple(")){let f=this.splitTupleStrings(o),d=f.map(x=>this.stringToTyped(x)),b=f[0].match(/^(tuple\([^)]+\))/),y=b?b[1]:"tuple";return new n.VariadicValue(new n.VariadicType(this.nativeToType(y)),d)}let p=i.startsWith(u.Struct)?h.ArgStructSeparator:h.ArgListSeparator,g=o.split(p).map(f=>this.stringToTyped(`${i}:${f}`));return new n.VariadicValue(new n.VariadicType(this.nativeToType(i)),g)}if(t.startsWith(u.Tuple)){let a=t.match(/\(([^)]+)\)/)?.[1];if(!a)throw new Error(`Invalid tuple format: ${t}`);let i=a.split(","),o=[];for(let c=0;c<i.length;c+=2){let g=i[c],f=i[c+1];o.push(this.stringToTyped(`${g}:${f}`))}let p=o.map(c=>c.getType());return new n.CompositeValue(new n.CompositeType(...p),o)}if(t.startsWith(u.Struct)){let a=t.match(/\(([^)]+)\)/),i=a?a[1]:"CustomStruct";if(!r)return new n.Struct(new n.StructType(i,[]),[]);let o=r.split(h.ArgListSeparator),p=[],c=[];return o.forEach(g=>{let f=g.match(new RegExp(`^\\(([^${h.ArgParamsSeparator}]+)${h.ArgParamsSeparator}([^)]+)\\)(.+)$`));if(f){let[,d,w,b]=f,y=this.stringToTyped(`${w}${h.ArgParamsSeparator}${b}`);p.push(new n.FieldDefinition(d,"",y.getType())),c.push(new n.Field(y,d))}}),new n.Struct(new n.StructType(i,p),c)}if(t===u.String)return r?n.StringValue.fromUTF8(r):new n.NothingValue;if(t===u.Uint8)return r?new n.U8Value(Number(r)):new n.NothingValue;if(t===u.Uint16)return r?new n.U16Value(Number(r)):new n.NothingValue;if(t===u.Uint32)return r?new n.U32Value(Number(r)):new n.NothingValue;if(t===u.Uint64)return r?new n.U64Value(BigInt(r)):new n.NothingValue;if(t===u.Biguint)return r?new n.BigUIntValue(BigInt(r)):new n.NothingValue;if(t===u.Bool)return r?new n.BooleanValue(typeof r=="boolean"?r:r==="true"):new n.NothingValue;if(t===u.Address)return r?new n.AddressValue(n.Address.newFromBech32(r)):new n.NothingValue;if(t===u.Hex)return r?n.BytesValue.fromHex(r):new n.NothingValue;if(t===u.Asset){let[a,i]=r.split(h.ArgCompositeSeparator),o=new n.TokenComputer,p=q(a)?te(a):o.extractIdentifierFromExtendedIdentifier(a),c=q(a)?0n:o.extractNonceFromExtendedIdentifier(a);return new n.Struct(this.nativeToType("asset"),[new n.Field(new n.TokenIdentifierValue(p),"token_identifier"),new n.Field(new n.U64Value(BigInt(c)),"token_nonce"),new n.Field(new n.BigUIntValue(BigInt(i)),"amount")])}if(t===v.Null)return new n.NothingValue;if(t===v.Optional){let a=this.stringToTyped(r);return a instanceof n.NothingValue?n.OptionalValue.newMissing():new n.OptionalValue(a.getType(),a)}if(t===v.List){let[a,i]=r.split(Ye,2),p=i.split(h.ArgListSeparator).map(c=>this.stringToTyped(a+h.ArgParamsSeparator+c));return new n.List(this.nativeToType(a),p)}if(t===v.Token)return r?new n.TokenIdentifierValue(r):new n.NothingValue;if(t===v.CodeMeta)return new n.CodeMetadataValue(n.CodeMetadata.newFromBytes(Uint8Array.from(Buffer.from(r,"hex"))));throw new Error(`WarpArgSerializer (stringToTyped): Unsupported input type: ${t}`)}splitTupleStrings(e){let t=[],r="",a=0;for(let i=0;i<e.length;i++){let o=e[i];if(o==="(")a++;else if(o===")")a--;else if(o===","&&a===0){t.push(r.trim()),r="";continue}r+=o}return r.trim()&&t.push(r.trim()),t}typeToString(e){if(e.hasExactClass(n.OptionType.ClassName))return u.Option+h.ArgParamsSeparator+this.typeToString(e.getFirstTypeParameter());if(e.hasExactClass(n.VariadicType.ClassName))return u.Vector+h.ArgParamsSeparator+this.typeToString(e.getFirstTypeParameter());if(e.hasExactClass(n.StringType.ClassName))return u.String;if(e.hasExactClass(n.U8Type.ClassName))return u.Uint8;if(e.hasExactClass(n.U16Type.ClassName))return u.Uint16;if(e.hasExactClass(n.U32Type.ClassName))return u.Uint32;if(e.hasExactClass(n.U64Type.ClassName))return u.Uint64;if(e.hasExactClass(n.BigUIntType.ClassName))return u.Biguint;if(e.hasExactClass(n.BooleanType.ClassName))return u.Bool;if(e.hasExactClass(n.AddressType.ClassName))return u.Address;if(e.hasExactClass(n.BytesType.ClassName))return u.Hex;if(e.hasExactClass(n.TokenIdentifierType.ClassName))return v.Token;if(e.hasExactClass(n.OptionalType.ClassName))return v.Optional+h.ArgParamsSeparator+this.typeToString(e.getFirstTypeParameter());if(e.hasExactClass(n.ListType.ClassName))return v.List+h.ArgParamsSeparator+this.typeToString(e.getFirstTypeParameter());if(e.hasExactClass(n.CodeMetadataType.ClassName))return v.CodeMeta;if(e.hasExactClass(n.StructType.ClassName)&&e.getClassName()==="EsdtTokenPayment")return u.Asset;if(e.hasExactClass(n.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 M(e,t),this.serializer=new R({typeRegistry:this.typeRegistry}),this.cache=new W.WarpCache(e.cache?.type)}async getActionExecution(e,t,r){let a=this.cache.get(W.WarpCacheKey.WarpExecutable(this.config.env,e.meta?.hash||"",t))??[],i=await this.extractContractOutput(e,t,r,a),o=(0,W.getNextInfo)(this.config,[],e,t,i.output),p=(0,W.applyOutputToMessages)(e,i.output,this.config);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:p,destination:null}}async extractContractOutput(e,t,r,a){let i=(0,W.getWarpActionByIndex)(e,t),o=[],p=[],c={};if(!e.output||i.type!=="contract")return{values:{string:o,native:p,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:p,mapped:{}},output:await(0,W.evaluateOutputCommon)(e,c,t,a,this.serializer.coreSerializer,this.config)}}let f=await this.abi.getAbiForAction(i),d=new Y.TransactionEventsParser({abi:f}),b=new Y.SmartContractTransactionsOutcomeParser({abi:f}).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[F,$,z]=x.split(".");if(F==="event"){if(!$||isNaN(Number(z)))continue;let S=Number(z),A=(0,Y.findEventsByFirstTopic)(r,$),He=d.parseEvents({events:A})[0],ee=Object.values(He)[S]||null;o.push(String(ee)),p.push(ee),c[y]=ee&&ee.valueOf()}else if(F==="out"||F.startsWith("out[")){if(!$)continue;let S=Number($),A=b.values[S-1]||null;z&&(A=A[z]||null),A&&typeof A=="object"&&(A="toFixed"in A?A.toFixed():A.valueOf()),o.push(String(A)),p.push(A),c[y]=A&&A.valueOf()}else c[y]=x}return{values:{string:o,native:p,mapped:{}},output:await(0,W.evaluateOutputCommon)(e,c,t,a,this.serializer.coreSerializer,this.config)}}async extractQueryOutput(e,t,r,a){let i=t.map(f=>this.serializer.typedToString(f)),o=t.map(f=>this.serializer.typedToNative(f)[1]),p={string:i,native:o,mapped:{}},c={};if(!e.output)return{values:p,output:c};let g=f=>{let d=f.split(".").slice(1).map(b=>parseInt(b)-1);if(d.length===0)return;let w=o[d[0]];for(let b=1;b<d.length;b++){if(w==null)return;w=w[d[b]]}return w};for(let[f,d]of Object.entries(e.output)){if(d.startsWith(W.WarpConstants.Transform.Prefix))continue;let w=(0,W.parseOutputOutIndex)(d);if(w!==null&&w!==r){c[f]=null;continue}d.startsWith("out.")||d==="out"||d.startsWith("out[")?c[f]=g(d)||null:c[f]=d}return c=await(0,W.evaluateOutputCommon)(e,c,r,a,this.serializer.coreSerializer,this.config),{values:p,output:c}}async resolveWarpOutputRecursively(e){let t=e.warp,r=e.entryActionIndex,a=e.executor,i=e.inputs,o=e.meta,p=new Map,c=new Set,g=this;async function f(y,x=[]){if(p.has(y))return p.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 F;if(P.type==="query")F=await a.executeQuery(t,y,x);else if(P.type==="collect")F=await a.executeCollect(t,y,x,o);else throw new Error(`Unsupported or interactive action type: ${P.type}`);if(p.set(y,F),t.output)for(let $ of Object.values(t.output)){let S=String($).match(/^out\[(\d+)\]/);if(S){let A=parseInt(S[1],10);A!==y&&!p.has(A)&&await f(A)}}return c.delete(y),F}await f(r,i);let d={};for(let y of p.values())for(let[x,P]of Object.entries(y.output))P!==null?d[x]=P:x in d||(d[x]=null);let w=await(0,W.evaluateOutputCommon)(t,d,r,i,this.serializer.coreSerializer,this.config);return{...p.get(r),action:r,output:w}}};var Ze="EGLD-000000",se=class{constructor(e,t,r){this.config=e;this.chain=t;this.typeRegistry=r;this.serializer=new R({typeRegistry:this.typeRegistry}),this.abi=new M(this.config,this.chain),this.output=new j(this.config,this.chain,this.typeRegistry)}async createTransaction(e){let t=(0,k.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,k.getWarpWalletAddressFromConfig)(this.config,e.chain.name);if(!t)throw new Error("WarpMultiversxExecutor: createTransfer - user address not set");let r=C.Address.newFromBech32(t),a=new C.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 C.TransferTransactionsFactory({config:a}).createTransactionForTransfer(r,{receiver:C.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,k.getWarpWalletAddressFromConfig)(this.config,e.chain.name);if(!t)throw new Error("WarpMultiversxExecutor: createContractCall - user address not set");let r=(0,k.getWarpActionByIndex)(e.warp,e.action),a=C.Address.newFromBech32(t),i=e.args.map(p=>this.serializer.stringToTyped(p)),o=new C.TransactionsFactoryConfig({chainID:e.chain.chainId});return new C.SmartContractTransactionsFactory({config:o}).createTransactionForExecute(a,{contract:C.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,k.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),a=e.args.map(S=>this.serializer.stringToTyped(S)),i=T(e.chain,this.config.env,this.config),o=C.Address.newFromBech32(e.destination),p=i.createSmartContractController(r),c=p.createQuery({contract:o,function:t.func||"",arguments:a}),g=await p.runQuery(c),f=g.returnCode==="ok",d=new C.ArgSerializer,w=r.getEndpoint(g.function||t.func||""),b=(g.returnDataParts||[]).map(S=>Buffer.from(S)),y=d.buffersToValues(b,w.output),{values:x,output:P}=await this.output.extractQueryOutput(e.warp,y,e.action,e.resolvedInputs),F=(0,k.getNextInfo)(this.config,[],e.warp,e.action,P),z=e.resolvedInputs.find(S=>S.input.position==="receiver"||S.input.position==="destination")?.value||e.destination;return{status:f?"success":"error",warp:e.warp,action:e.action,user:(0,k.getWarpWalletAddressFromConfig)(this.config,e.chain.name),txHash:null,tx:null,next:F,values:x,output:{...P,_DATA:y},messages:(0,k.applyOutputToMessages)(e.warp,P,this.config),destination:z}}toTokenTransfers(e){return e.map(t=>t.identifier===this.chain.nativeToken.identifier?{...t,identifier:Ze}:t).map(t=>{let a=new C.TokenComputer().extractNonceFromExtendedIdentifier(t.identifier);return new C.TokenTransfer({token:new C.Token({identifier:t.identifier,nonce:BigInt(a||0)}),amount:t.amount})})}};var oe=class{constructor(e,t){this.chain=e;this.config=t}getExplorers(){let e=we[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(a=>{let i=H[a];i&&(r[a]=`${i}/accounts/${e}`)}),r}getTransactionUrls(e){let t=this.getAllExplorers(),r={};return t.forEach(a=>{let i=H[a];i&&(r[a]=`${i}/transactions/${e}`)}),r}};var m=require("@multiversx/sdk-core"),V=require("@vleap/warps");var Te={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 B=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}),We=s=>({unitPrice:BigInt(s.unit_price.toString()),admins:s.admins.map(e=>e.toBech32())});var pe=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 a=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(a,{contract:m.Address.newFromBech32(B(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(B(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 a=m.Address.newFromBech32(this.userWallet);return await this.getFactory().createTransactionForExecute(a,{contract:m.Address.newFromBech32(B(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(B(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(B(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(B(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(B(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(B(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),a=t?this.cache.get(r):null;if(a)return V.WarpLogger.info(`WarpRegistry (getInfoByAlias): RegistryInfo found in cache: ${e}`),a;let i=m.Address.newFromBech32(B(this.config.env)),o=this.getController(),p=o.createQuery({contract:i,function:"getInfoByAlias",arguments:[m.BytesValue.fromUTF8(e)]}),c=await o.runQuery(p),[g]=o.parseQueryResponse(c),f=g?ce(g):null,d=f?.brand?await this.fetchBrand(f.brand):null;return t&&t.ttl&&this.cache.set(r,{registryInfo:f,brand:d},t.ttl),{registryInfo:f,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 a=m.Address.newFromBech32(B(this.config.env)),i=this.getController(),o=i.createQuery({contract:a,function:"getInfoByHash",arguments:[m.BytesValue.fromHex(e)]}),p=await i.runQuery(o),[c]=i.parseQueryResponse(p),g=c?ce(c):null,f=g?.brand?await this.fetchBrand(g.brand):null;return t&&t.ttl&&this.cache.set(r,{registryInfo:g,brand:f},t.ttl),{registryInfo:g,brand:f}}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(B(this.config.env)),a=this.getController(),i=a.createQuery({contract:r,function:"getUserWarps",arguments:[new m.AddressValue(new m.Address(t))]}),o=await a.runQuery(i),[p]=a.parseQueryResponse(o);return p.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=m.Address.newFromBech32(B(this.config.env)),a=this.getController(),i=a.createQuery({contract:r,function:"getUserBrands",arguments:[new m.AddressValue(new m.Address(t))]}),o=await a.runQuery(i),[p]=a.parseQueryResponse(o),c=p.map(d=>d.toString("hex")),g={ttl:365*24*60*60};return(await Promise.all(c.map(d=>this.fetchBrand(d,g)))).filter(d=>d!==null)}catch{return[]}}async fetchBrand(e,t){let r=V.WarpCacheKey.Brand(this.config.env,e),a=t?this.cache.get(r):null;if(a)return V.WarpLogger.info(`WarpRegistry (fetchBrand): Brand found in cache: ${e}`),a;let o=T(this.chain,this.config.env,this.config).createNetworkProvider();try{let p=await o.getTransaction(e),c=JSON.parse(p.data.toString());return c.meta={query:null,chain:this.chain.name,identifier:(0,V.createWarpIdentifier)(this.chain.name,"hash",e),hash:p.hash,creator:p.sender.toBech32(),createdAt:new Date(p.timestamp*1e3).toISOString()},t&&t.ttl&&this.cache.set(r,c,t.ttl),c}catch{return null}}async loadRegistryConfigs(){let e=m.Address.newFromBech32(B(this.config.env)),t=this.getController(),[r]=await t.query({contract:e,function:"getConfig",arguments:[]}),a=r?We(r):null;this.registryConfig=a||{unitPrice:BigInt(0),admins:[]}}getFactory(){let e=new m.TransactionsFactoryConfig({chainID:this.chain.chainId}),t=m.AbiRegistry.create(Te);return new m.SmartContractTransactionsFactory({config:e,abi:t})}getController(){let e=T(this.chain,this.config.env,this.config),t=m.AbiRegistry.create(Te);return e.createSmartContractController(t)}isCurrentUserAdmin(){return!!this.userWallet&&this.registryConfig.admins.includes(this.userWallet)}};var U=require("@multiversx/sdk-core"),L=require("@vleap/warps");var le=class{constructor(e,t){this.config=e;this.chain=t;this.entry=T(t,e.env,e),this.provider=this.entry.createNetworkProvider(),this.cache=new L.WarpCache(e.cache?.type)}async signTransaction(e){if(!e||typeof e!="object")throw new Error("Invalid transaction object");let t=(0,L.getWarpWalletPrivateKeyFromConfig)(this.config,this.chain.name);if(!t)throw new Error("Wallet not initialized - no private key provided");let a=t.startsWith("-----")?U.UserSecretKey.fromPem(t):U.UserSecretKey.fromString(t),i=new U.Account(a);if(e.nonce===0n){let p=await this.entry.recallAccountNonce(i.address),c=this.cache.get(`nonce:${i.address.toBech32()}`)||0,g=BigInt(Math.max(c,Number(p)));e.nonce=g}e.signature=await i.signTransaction(e);let o=Number(i.nonce)+1;return this.cache.set(`nonce:${i.address.toBech32()}`,o,L.CacheTtl.OneMinute),e}async signTransactions(e){return Promise.all(e.map(async t=>this.signTransaction(t)))}async signMessage(e){let t=(0,L.getWarpWalletPrivateKeyFromConfig)(this.config,this.chain.name);if(!t)throw new Error("Wallet not initialized - no private key provided");let a=t.startsWith("-----")?U.UserSecretKey.fromPem(t):U.UserSecretKey.fromString(t),o=await new U.Account(a).signMessage(new U.Message({data:Buffer.from(e)}));return Buffer.from(o).toString("hex")}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){let r=U.Mnemonic.fromString(e).deriveKey(0),a=r.hex();return{address:r.generatePublicKey().toAddress(this.chain.addressHrp).toBech32(),privateKey:a,mnemonic:e}}generate(){let e=U.Mnemonic.generate(),t=e.toString(),r=e.deriveKey(0),a=r.hex();return{address:r.generatePublicKey().toAddress(this.chain.addressHrp).toBech32(),privateKey:a,mnemonic:t}}getAddress(){return(0,L.getWarpWalletAddressFromConfig)(this.config,this.chain.name)}};var ue=(s,e)=>(t,r)=>{let a=e[t.env],i=new _e.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:a,builder:()=>new ae(t,a),executor:new se(t,a,i),output:new j(t,a,i),serializer:new R({typeRegistry:i}),registry:new pe(t,a),explorer:new oe(s,t),abiBuilder:()=>new M(t,a),brandBuilder:()=>new ne(t,a),dataLoader:new ie(t,a),wallet:new le(t,a)}};var de={chain:Z.WarpChainName.Multiversx,identifier:"EGLD",name:"eGold",symbol:"EGLD",decimals:18,logoUrl:"https://vleap.ai/images/tokens/egld.svg"},Ce=ue(Z.WarpChainName.Multiversx,{mainnet:{name:Z.WarpChainName.Multiversx,displayName:"MultiversX",chainId:"1",blockTime:6e3,addressHrp:"erd",defaultApiUrl:"https://api.multiversx.com",logoUrl:"https://vleap.ai/images/chains/multiversx.svg",nativeToken:de},testnet:{name:Z.WarpChainName.Multiversx,displayName:"MultiversX Testnet",chainId:"T",blockTime:6e3,addressHrp:"erd",defaultApiUrl:"https://testnet-api.multiversx.com",logoUrl:"https://vleap.ai/images/chains/multiversx.svg",nativeToken:de},devnet:{name:Z.WarpChainName.Multiversx,displayName:"MultiversX Devnet",chainId:"D",blockTime:6e3,addressHrp:"erd",defaultApiUrl:"https://devnet-api.multiversx.com",logoUrl:"https://vleap.ai/images/chains/multiversx.svg",nativeToken:de}});var he=require("@vleap/warps");var Ge={chain:he.WarpChainName.Vibechain,identifier:"VIBE",name:"VIBE",symbol:"VIBE",decimals:18,logoUrl:"https://vleap.ai/images/tokens/vibe.svg"},xe={name:he.WarpChainName.Vibechain,displayName:"VibeChain",chainId:"V",blockTime:600,addressHrp:"vibe",defaultApiUrl:"https://vibeox-api.multiversx.com",logoUrl:"https://vleap.ai/images/chains/vibechain.svg",nativeToken:Ge},Ae=ue(he.WarpChainName.Vibechain,{mainnet:xe,testnet:xe,devnet:xe});var tt=(s,e)=>[Ce(s,e),Ae(s,e)],rt=()=>[Ee.WarpChainName.Multiversx,Ee.WarpChainName.Vibechain];var D=require("@vleap/warps");var nt=s=>new D.WarpSerializer().nativeToString(v.Token,s),at=s=>new D.WarpSerializer().nativeToString(v.CodeMeta,s),it=(s,e)=>{if(e===null)return v.Optional+D.WarpConstants.ArgParamsSeparator;let t=s(e),r=t.indexOf(D.WarpConstants.ArgParamsSeparator),a=t.substring(0,r),i=t.substring(r+1);return v.Optional+D.WarpConstants.ArgParamsSeparator+a+D.WarpConstants.ArgParamsSeparator+i},st=s=>new D.WarpSerializer().nativeToString(v.List,s);var l=require("@multiversx/sdk-core"),ot=(s,e)=>s?l.OptionValue.newProvided(s):e?l.OptionValue.newMissingTyped(e):l.OptionValue.newMissing(),ct=(s,e)=>s?new l.OptionalValue(s.getType(),s):e?new l.OptionalValue(e):l.OptionalValue.newMissing(),pt=s=>{if(s.length===0)throw new Error("Cannot create a list from an empty array");let e=s[0].getType();return new l.List(e,s)},lt=s=>l.VariadicValue.fromItems(...s),ut=s=>{let e=s.map(t=>t.getType());return new l.CompositeValue(new l.CompositeType(...e),s)},mt=s=>l.StringValue.fromUTF8(s),dt=s=>new l.U8Value(s),ht=s=>new l.U16Value(s),ft=s=>new l.U32Value(s),gt=s=>new l.U64Value(s),yt=s=>new l.BigUIntValue(BigInt(s)),vt=s=>new l.BooleanValue(s),wt=s=>new l.AddressValue(l.Address.newFromBech32(s)),Tt=s=>new l.TokenIdentifierValue(s),Wt=s=>l.BytesValue.fromHex(s),Ct=s=>new l.Struct(new l.StructType("EsdtTokenPayment",[new l.FieldDefinition("token_identifier","",new l.TokenIdentifierType),new l.FieldDefinition("token_nonce","",new l.U64Type),new l.FieldDefinition("amount","",new l.BigUIntType)]),[new l.Field(new l.TokenIdentifierValue(s.token.identifier),"token_identifier"),new l.Field(new l.U64Value(BigInt(s.token.nonce)),"token_nonce"),new l.Field(new l.BigUIntValue(BigInt(s.amount)),"amount")]),xt=s=>new l.CodeMetadataValue(l.CodeMetadata.newFromBytes(Uint8Array.from(Buffer.from(s,"hex")))),At=()=>new l.NothingValue;0&&(module.exports={ExplorerUrls,KnownTokens,MultiversxExplorers,MultiversxExplorersConfig,NativeTokenEgld,NativeTokenVibe,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,getMultiversxAdapter,getMultiversxEntrypoint,getMultiversxRegistryAddress,getNormalizedTokenIdentifier,getVibechainAdapter,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 fe=Object.defineProperty;var $e=Object.getOwnPropertyDescriptor;var Ke=Object.getOwnPropertyNames;var ze=Object.prototype.hasOwnProperty;var qe=(s,e)=>{for(var t in e)fe(s,t,{get:e[t],enumerable:!0})},Qe=(s,e,t,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let a of Ke(e))!ze.call(s,a)&&a!==t&&fe(s,a,{get:()=>e[a],enumerable:!(r=$e(e,a))||r.enumerable});return s};var je=s=>Qe(fe({},"__esModule",{value:!0}),s);var Et={};qe(Et,{ExplorerUrls:()=>H,KnownTokens:()=>ye,MultiversxExplorers:()=>Re,MultiversxExplorersConfig:()=>we,NativeTokenEgld:()=>de,NativeTokenVibe:()=>Ge,VibechainExplorers:()=>Le,WarpMultiversxAbiBuilder:()=>R,WarpMultiversxBrandBuilder:()=>ne,WarpMultiversxBuilder:()=>ae,WarpMultiversxConstants:()=>Je,WarpMultiversxContractLoader:()=>re,WarpMultiversxDataLoader:()=>ie,WarpMultiversxExecutor:()=>se,WarpMultiversxExplorer:()=>oe,WarpMultiversxInputTypes:()=>v,WarpMultiversxOutput:()=>j,WarpMultiversxRegistry:()=>pe,WarpMultiversxSerializer:()=>L,WarpMultiversxWallet:()=>le,address_value:()=>wt,asset_value:()=>Ct,biguint_value:()=>yt,boolean_value:()=>vt,codemeta:()=>at,codemeta_value:()=>xt,composite_value:()=>ut,createMultiversxAdapter:()=>ue,findKnownTokenById:()=>ve,getAllMultiversxAdapters:()=>tt,getAllMultiversxChainNames:()=>rt,getKnownTokensForChain:()=>Xe,getMultiversxAdapter:()=>Ce,getMultiversxEntrypoint:()=>T,getMultiversxRegistryAddress:()=>B,getNormalizedTokenIdentifier:()=>te,getVibechainAdapter:()=>Ae,hex_value:()=>Wt,isNativeToken:()=>z,list:()=>st,list_value:()=>pt,nothing_value:()=>At,option_value:()=>ot,optional:()=>it,optional_value:()=>ct,string_value:()=>mt,toTypedConfigInfo:()=>We,toTypedRegistryInfo:()=>ce,token:()=>nt,token_value:()=>Tt,u16_value:()=>ht,u32_value:()=>ft,u64_value:()=>gt,u8_value:()=>dt,variadic_value:()=>lt});module.exports=je(Et);var Ee=require("@vleap/warps");var Z=require("@vleap/warps");var _e=require("@vleap/warps");var O=require("@multiversx/sdk-core"),E=require("@vleap/warps");var X=require("@multiversx/sdk-core"),be=require("@vleap/warps"),z=s=>!s.includes("-"),te=s=>z(s)?`${s}-000000`:s,T=(s,e,t)=>{let r="warp-sdk",i=t?(0,be.getProviderConfig)(t,s.name,e,s.defaultApiUrl):{url:s.defaultApiUrl},o=i.url,p={headers:i.headers};return e==="devnet"?new X.DevnetEntrypoint({url:o,kind:"api",clientName:r,networkProviderConfig:p}):e==="testnet"?new X.TestnetEntrypoint({url:o,kind:"api",clientName:r,networkProviderConfig:p}):new X.MainnetEntrypoint({url:o,kind:"api",clientName:r,networkProviderConfig:p})};var ge=require("@vleap/warps");var re=class{constructor(e){this.config=e}async getContract(e,t){try{let i=await T(t,this.config.env,this.config).createNetworkProvider().doGetGeneric(`accounts/${e}`);return{address:e,owner:i.ownerAddress,verified:i.isVerified||!1}}catch(r){return ge.WarpLogger.error("WarpContractLoader: getContract error",r),null}}async getVerificationInfo(e,t){try{let i=await T(t,this.config.env,this.config).createNetworkProvider().doGetGeneric(`accounts/${e}/verification`);return{codeHash:i.codeHash,abi:i.source.abi}}catch(r){return ge.WarpLogger.error("WarpContractLoader: getVerificationInfo error",r),null}}};var R=class{constructor(e,t){this.config=e;this.chain=t;this.contractLoader=new re(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 O.TransactionsFactoryConfig({chainID:this.chain.chainId}),a=new O.TransferTransactionsFactory({config:r}),i=O.Address.newFromBech32(t),o={protocol:(0,E.getLatestProtocolIdentifier)("abi"),content:e},p=JSON.stringify(o),c=await a.createTransactionForTransfer(i,{receiver:i,nativeAmount:BigInt(0),data:Uint8Array.from(Buffer.from(p))});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=T(this.chain,this.config.env,this.config).createNetworkProvider();try{let o=await i.getTransaction(e),p=await this.createFromTransaction(o);return t&&t.ttl&&p&&this.cache.set(r,p,t.ttl),p}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 O.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 O.AbiRegistry.create(r.content)}else{let r=await(await fetch(e.abi)).json();return O.AbiRegistry.create(r)}}};var q=require("@multiversx/sdk-core"),_=require("@vleap/warps"),Se=require("buffer");var ne=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}),a=new q.TransferTransactionsFactory({config:r}),i=q.Address.newFromBech32(t),o=JSON.stringify(e);return await a.createTransactionForNativeTokenTransfer(i,{receiver:q.Address.newFromBech32(t),nativeAmount:BigInt(0),data:Uint8Array.from(Se.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=T(this.chain,this.config.env,this.config).createNetworkProvider();try{let a=await r.getTransaction(e);return this.createFromTransaction(a)}catch(a){return _.WarpLogger.error("BrandBuilder: Error creating from transaction hash",a),null}}};var Q=require("@multiversx/sdk-core"),V=require("@vleap/warps");var ae=class extends V.WarpBuilder{constructor(t,r){super(t);this.config=t;this.chain=r;this.cache=new V.WarpCache(t.cache?.type),this.core=new V.WarpBuilder(t)}async createInscriptionTransaction(t){let r=(0,V.getWarpWalletAddressFromConfig)(this.config,this.chain.name);if(!r)throw new Error("WarpBuilder: user address not set");let a=new Q.TransactionsFactoryConfig({chainID:this.chain.chainId}),i=new Q.TransferTransactionsFactory({config:a}),o=Q.Address.newFromBech32(r),p=JSON.stringify(t),c=await i.createTransactionForTransfer(o,{receiver:Q.Address.newFromBech32(r),nativeAmount:BigInt(0),data:Uint8Array.from(Buffer.from(p))});return c.gasLimit=c.gasLimit+BigInt(2e6),c}async createFromTransaction(t,r=!1){let a=await this.core.createFromRaw(t.data.toString(),r);return a.meta={chain:this.chain.name,identifier:(0,V.createWarpIdentifier)(this.chain.name,"hash",t.hash),query:null,hash:t.hash,creator:t.sender.toBech32(),createdAt:new Date(t.timestamp*1e3).toISOString()},a}async createFromTransactionHash(t,r){let a=V.WarpCacheKey.Warp(this.config.env,t);if(r){let p=this.cache.get(a);if(p)return V.WarpLogger.info(`WarpBuilder (createFromTransactionHash): Warp found in cache: ${t}`),p}let o=T(this.chain,this.config.env,this.config).createNetworkProvider();try{let p=await o.getTransaction(t),c=await this.createFromTransaction(p);return r&&r.ttl&&c&&this.cache.set(a,c,r.ttl),c}catch(p){return V.WarpLogger.error("WarpBuilder: Error creating from transaction hash",p),null}}};var G=require("@multiversx/sdk-core"),J=require("@vleap/warps");var Be=require("@vleap/warps"),Ie=Be.WarpChainName.Multiversx,Pe=[{chain:Ie,identifier:"EGLD",name:"eGold",symbol:"EGLD",decimals:18,logoUrl:"https://tools.multiversx.com/assets-cdn/tokens/EGLD-000000/icon.png"},{chain:Ie,identifier:"EGLD-000000",name:"eGold",symbol:"EGLD",decimals:18,logoUrl:"https://tools.multiversx.com/assets-cdn/tokens/EGLD-000000/icon.png"}];var Ne=require("@vleap/warps"),I=Ne.WarpChainName.Multiversx,Ve=[{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 ke=require("@vleap/warps"),Ue=ke.WarpChainName.Multiversx,Fe=[{chain:Ue,identifier:"EGLD",name:"eGold",symbol:"EGLD",decimals:18,logoUrl:"https://tools.multiversx.com/assets-cdn/tokens/EGLD-000000/icon.png"},{chain:Ue,identifier:"EGLD-000000",name:"eGold",symbol:"EGLD",decimals:18,logoUrl:"https://tools.multiversx.com/assets-cdn/tokens/EGLD-000000/icon.png"}];var Me=require("@vleap/warps"),Oe=Me.WarpChainName.Vibechain,me=[{chain:Oe,identifier:"VIBE",name:"VIBE",symbol:"VIBE",decimals:18,logoUrl:"https://vleap.ai/images/tokens/vibe.svg"},{chain:Oe,identifier:"VIBE-000000",name:"VIBE",symbol:"VIBE",decimals:18,logoUrl:"https://vleap.ai/images/tokens/vibe.svg"}];var ye={multiversx:{mainnet:Ve,testnet:Fe,devnet:Pe},vibechain:{mainnet:me,testnet:me,devnet:me}},ve=(s,e,t)=>(ye[s]?.[e]||[]).find(a=>a.identifier===t)||null,Xe=(s,e)=>ye[s]?.[e]||[];var ie=class{constructor(e,t){this.config=e;this.chain=t;this.cache=new J.WarpCache(e.cache?.type)}async getAccount(e){let r=await T(this.chain,this.config.env,this.config).createNetworkProvider().getAccount(G.Address.newFromBech32(e));return{chain:this.chain.name,address:r.address.toBech32(),balance:r.balance}}async getAccountAssets(e){let t=T(this.chain,this.config.env,this.config).createNetworkProvider(),r=t.getAccount(G.Address.newFromBech32(e)),a=t.getFungibleTokensOfAccount(G.Address.newFromBech32(e)),[i,o]=await Promise.all([r,a]),p=i.balance>0?[{...this.chain.nativeToken,amount:i.balance}]:[];return p.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}))),p}async getAsset(e){let t=J.WarpCacheKey.Asset(this.config.env,this.chain.name,e),r=this.cache.get(t);if(r)return r;let a=ve(this.chain.name,this.config.env,e);if(a)return{chain:this.chain.name,identifier:e,name:a.name,symbol:a.symbol,amount:0n,decimals:a.decimals,logoUrl:a.logoUrl};let i=new G.TokenComputer,o=z(e)?0n:i.extractNonceFromExtendedIdentifier(e),p=new G.Token({identifier:e,nonce:BigInt(o||0)}),c=i.isFungible(p),g=T(this.chain,this.config.env,this.config).createNetworkProvider(),f=te(e),d=await g.doGetGeneric(`tokens/${f}`),w={chain:this.chain.name,identifier:p.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,w,J.CacheTtl.OneHour),w}async getAction(e,t=!1){let r=T(this.chain,this.config.env,this.config),a=t?await r.awaitCompletedTransaction(e):await r.getTransaction(e);return{chain:this.chain.name,id:a.hash,receiver:a.receiver.toBech32(),sender:a.sender.toBech32(),value:a.value,function:a.function,status:this.toActionStatus(a),createdAt:this.toActionCreatedAt(a),error:a?.smartContractResults.map(i=>i.raw.returnMessage)[0]||null,tx:a}}async getAccountActions(e,t){let r=T(this.chain,this.config.env,this.config).createNetworkProvider(),a=`accounts/${e}/transactions`,i=new URLSearchParams,o=t?.size||25,p=t?.page||0;if(p>0){let g=p*o;i.append("from",g.toString())}return o!==25&&i.append("size",o.toString()),i.toString()&&(a+=`?${i.toString()}`),(await r.doGetGeneric(a)).map(g=>({chain:this.chain.name,id:g.txHash,receiver:g.receiver,sender:g.sender,value:g.value,function:g.function,status:this.toActionStatus(g),createdAt:this.toActionCreatedAt(g)}))}toActionStatus(e){return e.status.isSuccessful()?"success":e.status.isFailed()?"failed":"pending"}toActionCreatedAt(e){return new Date(e.timestamp||e.timestamp*1e3).toISOString()}};var C=require("@multiversx/sdk-core"),k=require("@vleap/warps");var Y=require("@multiversx/sdk-core"),W=require("@vleap/warps");var n=require("@multiversx/sdk-core"),De=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 Je={Egld:{Identifier:"EGLD",EsdtIdentifier:"EGLD-000000",DisplayName:"eGold",Decimals:18}},v={Null:"null",Optional:"optional",List:"list",Token:"token",CodeMeta:"codemeta"},Re=(r=>(r.MultiversxExplorer="multiversx_explorer",r.MultiversxExplorerDevnet="multiversx_explorer_devnet",r.MultiversxExplorerTestnet="multiversx_explorer_testnet",r))(Re||{}),Le=(r=>(r.VibechainExplorer="vibechain_explorer",r.VibechainExplorerDevnet="vibechain_explorer_devnet",r.VibechainExplorerTestnet="vibechain_explorer_testnet",r))(Le||{}),we={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 Ye=new RegExp(`${h.ArgParamsSeparator}(.*)`),L=class{constructor(e){this.coreSerializer=new De.WarpSerializer(e)}typedToString(e){let t=e.getType();if(t.hasExactClass(n.OptionType.ClassName)||e.hasClassOrSuperclass(n.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(n.VariadicType.ClassName)||e.hasClassOrSuperclass(n.VariadicValue.ClassName)){let r=e.getItems();if(r.length===0){let f=this.typeToString(t.getFirstTypeParameter());return u.Vector+h.ArgParamsSeparator+f+h.ArgParamsSeparator}let a=r.map(f=>this.typedToString(f));if(a.every(f=>f.startsWith(u.Tuple)))return u.Vector+h.ArgParamsSeparator+a.join(",");let i=a[0],o=i.indexOf(h.ArgParamsSeparator),p=i.substring(0,o),c=a.map(f=>{let d=f.indexOf(h.ArgParamsSeparator);return f.substring(d+1)}),g=p.startsWith(u.Struct)?h.ArgStructSeparator:h.ArgListSeparator;return u.Vector+h.ArgParamsSeparator+p+h.ArgParamsSeparator+c.join(g)}if(t.hasExactClass(n.OptionalType.ClassName)||e.hasClassOrSuperclass(n.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(n.ListType.ClassName)||e.hasClassOrSuperclass(n.List.ClassName)){let a=e.getItems().map(c=>this.typedToString(c));if(a.every(c=>c.startsWith(u.Tuple)))return v.List+h.ArgParamsSeparator+a.join(",");let o=a.map(c=>c.split(h.ArgParamsSeparator)[0])[0],p=a.map(c=>c.split(h.ArgParamsSeparator)[1]);return v.List+h.ArgParamsSeparator+o+h.ArgParamsSeparator+p.join(h.ArgListSeparator)}if(t.hasExactClass(n.CompositeType.ClassName)||e.hasClassOrSuperclass(n.CompositeValue.ClassName)){let a=e.getItems().map(i=>{let o=this.typedToString(i),p=o.indexOf(h.ArgParamsSeparator),c=o.substring(0,p),g=o.substring(p+1);return`${c},${g}`});return`${u.Tuple}(${a.join(",")})`}if(t.hasExactClass(n.BigUIntType.ClassName)||e.hasClassOrSuperclass(n.BigUIntValue.ClassName)||t.getName()==="BigUint")return u.Biguint+h.ArgParamsSeparator+BigInt(e.valueOf().toFixed());if(t.hasExactClass(n.U8Type.ClassName)||e.hasClassOrSuperclass(n.U8Value.ClassName))return u.Uint8+h.ArgParamsSeparator+e.valueOf().toNumber();if(t.hasExactClass(n.U16Type.ClassName)||e.hasClassOrSuperclass(n.U16Value.ClassName))return u.Uint16+h.ArgParamsSeparator+e.valueOf().toNumber();if(t.hasExactClass(n.U32Type.ClassName)||e.hasClassOrSuperclass(n.U32Value.ClassName))return u.Uint32+h.ArgParamsSeparator+e.valueOf().toNumber();if(t.hasExactClass(n.U64Type.ClassName)||e.hasClassOrSuperclass(n.U64Value.ClassName))return u.Uint64+h.ArgParamsSeparator+BigInt(e.valueOf().toFixed());if(t.hasExactClass(n.StringType.ClassName)||e.hasClassOrSuperclass(n.StringValue.ClassName))return u.String+h.ArgParamsSeparator+e.valueOf();if(t.hasExactClass(n.BooleanType.ClassName)||e.hasClassOrSuperclass(n.BooleanValue.ClassName))return u.Bool+h.ArgParamsSeparator+e.valueOf();if(t.hasExactClass(n.AddressType.ClassName)||e.hasClassOrSuperclass(n.AddressValue.ClassName))return u.Address+h.ArgParamsSeparator+e.valueOf().toBech32();if(t.hasExactClass(n.BytesType.ClassName)||e.hasClassOrSuperclass(n.BytesValue.ClassName))return u.Hex+h.ArgParamsSeparator+e.valueOf().toString("hex");if(t.getName()==="EsdtTokenPayment"){let r=e.getFieldValue("token_identifier").valueOf(),a=e.getFieldValue("token_nonce").valueOf(),i=e.getFieldValue("amount").valueOf(),p=new n.TokenComputer().computeExtendedIdentifier(new n.Token({identifier:r,nonce:BigInt(a)}));return u.Asset+h.ArgParamsSeparator+p+h.ArgCompositeSeparator+i}if(t.hasExactClass(n.StructType.ClassName)||e.hasClassOrSuperclass(n.Struct.ClassName)){let r=e,i=r.getType().getName(),o=r.getFields();if(o.length===0)return`${u.Struct}(${i})${h.ArgParamsSeparator}`;let p=o.map(c=>{let g=c.value.getType(),d=this.typedToString(c.value).split(h.ArgParamsSeparator),w=d.length>2?d.slice(2).join(h.ArgParamsSeparator):d[1]||"";return`(${c.name}${h.ArgParamsSeparator}${this.typeToString(g)})${w}`});return`${u.Struct}(${i})${h.ArgParamsSeparator}${p.join(h.ArgListSeparator)}`}if(t.hasExactClass(n.TokenIdentifierType.ClassName)||e.hasClassOrSuperclass(n.TokenIdentifierValue.ClassName))return v.Token+h.ArgParamsSeparator+e.valueOf();if(t.hasExactClass(n.CodeMetadataType.ClassName)||e.hasClassOrSuperclass(n.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(","),a=[];for(let i=0;i<r.length;i+=2)a.push(r[i]);return new n.CompositeType(...a.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 n.StructType(r,[])}if(e===u.String)return new n.StringType;if(e===u.Uint8)return new n.U8Type;if(e===u.Uint16)return new n.U16Type;if(e===u.Uint32)return new n.U32Type;if(e===u.Uint64)return new n.U64Type;if(e===u.Biguint)return new n.BigUIntType;if(e===u.Bool)return new n.BooleanType;if(e===u.Address)return new n.AddressType;if(e===u.Hex)return new n.BytesType;if(e===u.Asset)return new n.StructType("EsdtTokenPayment",[new n.FieldDefinition("token_identifier","",new n.TokenIdentifierType),new n.FieldDefinition("token_nonce","",new n.U64Type),new n.FieldDefinition("amount","",new n.BigUIntType)]);if(e===v.Token)return new n.TokenIdentifierType;if(e===v.CodeMeta)return new n.CodeMetadataType;throw new Error(`WarpArgSerializer (nativeToType): Unsupported input type: ${e}`)}stringToTyped(e){let[t,r]=e.split(/:(.*)/,2);if(t===u.Option){let a=this.stringToTyped(r);return a instanceof n.NothingValue?n.OptionValue.newMissingTyped(a.getType()):n.OptionValue.newProvided(a)}if(t===u.Vector){let a=r.indexOf(h.ArgParamsSeparator),i=r.substring(0,a),o=r.substring(a+1);if(i.startsWith(u.Tuple)){let d=o.split(",").map(w=>this.stringToTyped(w));return new n.VariadicValue(new n.VariadicType(this.nativeToType(i)),d)}if(o.includes("tuple(")){let f=this.splitTupleStrings(o),d=f.map(x=>this.stringToTyped(x)),b=f[0].match(/^(tuple\([^)]+\))/),y=b?b[1]:"tuple";return new n.VariadicValue(new n.VariadicType(this.nativeToType(y)),d)}let p=i.startsWith(u.Struct)?h.ArgStructSeparator:h.ArgListSeparator,g=o.split(p).map(f=>this.stringToTyped(`${i}:${f}`));return new n.VariadicValue(new n.VariadicType(this.nativeToType(i)),g)}if(t.startsWith(u.Tuple)){let a=t.match(/\(([^)]+)\)/)?.[1];if(!a)throw new Error(`Invalid tuple format: ${t}`);let i=a.split(","),o=[];for(let c=0;c<i.length;c+=2){let g=i[c],f=i[c+1];o.push(this.stringToTyped(`${g}:${f}`))}let p=o.map(c=>c.getType());return new n.CompositeValue(new n.CompositeType(...p),o)}if(t.startsWith(u.Struct)){let a=t.match(/\(([^)]+)\)/),i=a?a[1]:"CustomStruct";if(!r)return new n.Struct(new n.StructType(i,[]),[]);let o=r.split(h.ArgListSeparator),p=[],c=[];return o.forEach(g=>{let f=g.match(new RegExp(`^\\(([^${h.ArgParamsSeparator}]+)${h.ArgParamsSeparator}([^)]+)\\)(.+)$`));if(f){let[,d,w,b]=f,y=this.stringToTyped(`${w}${h.ArgParamsSeparator}${b}`);p.push(new n.FieldDefinition(d,"",y.getType())),c.push(new n.Field(y,d))}}),new n.Struct(new n.StructType(i,p),c)}if(t===u.String)return r?n.StringValue.fromUTF8(r):new n.NothingValue;if(t===u.Uint8)return r?new n.U8Value(Number(r)):new n.NothingValue;if(t===u.Uint16)return r?new n.U16Value(Number(r)):new n.NothingValue;if(t===u.Uint32)return r?new n.U32Value(Number(r)):new n.NothingValue;if(t===u.Uint64)return r?new n.U64Value(BigInt(r)):new n.NothingValue;if(t===u.Biguint)return r?new n.BigUIntValue(BigInt(r)):new n.NothingValue;if(t===u.Bool)return r?new n.BooleanValue(typeof r=="boolean"?r:r==="true"):new n.NothingValue;if(t===u.Address)return r?new n.AddressValue(n.Address.newFromBech32(r)):new n.NothingValue;if(t===u.Hex)return r?n.BytesValue.fromHex(r):new n.NothingValue;if(t===u.Asset){let[a,i]=r.split(h.ArgCompositeSeparator),o=new n.TokenComputer,p=z(a)?te(a):o.extractIdentifierFromExtendedIdentifier(a),c=z(a)?0n:o.extractNonceFromExtendedIdentifier(a);return new n.Struct(this.nativeToType("asset"),[new n.Field(new n.TokenIdentifierValue(p),"token_identifier"),new n.Field(new n.U64Value(BigInt(c)),"token_nonce"),new n.Field(new n.BigUIntValue(BigInt(i)),"amount")])}if(t===v.Null)return new n.NothingValue;if(t===v.Optional){let a=this.stringToTyped(r);return a instanceof n.NothingValue?n.OptionalValue.newMissing():new n.OptionalValue(a.getType(),a)}if(t===v.List){let[a,i]=r.split(Ye,2),p=i.split(h.ArgListSeparator).map(c=>this.stringToTyped(a+h.ArgParamsSeparator+c));return new n.List(this.nativeToType(a),p)}if(t===v.Token)return r?new n.TokenIdentifierValue(r):new n.NothingValue;if(t===v.CodeMeta)return new n.CodeMetadataValue(n.CodeMetadata.newFromBytes(Uint8Array.from(Buffer.from(r,"hex"))));throw new Error(`WarpArgSerializer (stringToTyped): Unsupported input type: ${t}`)}splitTupleStrings(e){let t=[],r="",a=0;for(let i=0;i<e.length;i++){let o=e[i];if(o==="(")a++;else if(o===")")a--;else if(o===","&&a===0){t.push(r.trim()),r="";continue}r+=o}return r.trim()&&t.push(r.trim()),t}typeToString(e){if(e.hasExactClass(n.OptionType.ClassName))return u.Option+h.ArgParamsSeparator+this.typeToString(e.getFirstTypeParameter());if(e.hasExactClass(n.VariadicType.ClassName))return u.Vector+h.ArgParamsSeparator+this.typeToString(e.getFirstTypeParameter());if(e.hasExactClass(n.StringType.ClassName))return u.String;if(e.hasExactClass(n.U8Type.ClassName))return u.Uint8;if(e.hasExactClass(n.U16Type.ClassName))return u.Uint16;if(e.hasExactClass(n.U32Type.ClassName))return u.Uint32;if(e.hasExactClass(n.U64Type.ClassName))return u.Uint64;if(e.hasExactClass(n.BigUIntType.ClassName))return u.Biguint;if(e.hasExactClass(n.BooleanType.ClassName))return u.Bool;if(e.hasExactClass(n.AddressType.ClassName))return u.Address;if(e.hasExactClass(n.BytesType.ClassName))return u.Hex;if(e.hasExactClass(n.TokenIdentifierType.ClassName))return v.Token;if(e.hasExactClass(n.OptionalType.ClassName))return v.Optional+h.ArgParamsSeparator+this.typeToString(e.getFirstTypeParameter());if(e.hasExactClass(n.ListType.ClassName))return v.List+h.ArgParamsSeparator+this.typeToString(e.getFirstTypeParameter());if(e.hasExactClass(n.CodeMetadataType.ClassName))return v.CodeMeta;if(e.hasExactClass(n.StructType.ClassName)&&e.getClassName()==="EsdtTokenPayment")return u.Asset;if(e.hasExactClass(n.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 L({typeRegistry:this.typeRegistry}),this.cache=new W.WarpCache(e.cache?.type)}async getActionExecution(e,t,r){let a=this.cache.get(W.WarpCacheKey.WarpExecutable(this.config.env,e.meta?.hash||"",t))??[],i=await this.extractContractOutput(e,t,r,a),o=(0,W.getNextInfo)(this.config,[],e,t,i.output),p=(0,W.applyOutputToMessages)(e,i.output,this.config);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:p,destination:null}}async extractContractOutput(e,t,r,a){let i=(0,W.getWarpActionByIndex)(e,t),o=[],p=[],c={};if(!e.output||i.type!=="contract")return{values:{string:o,native:p,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:p,mapped:{}},output:await(0,W.evaluateOutputCommon)(e,c,t,a,this.serializer.coreSerializer,this.config)}}let f=await this.abi.getAbiForAction(i),d=new Y.TransactionEventsParser({abi:f}),b=new Y.SmartContractTransactionsOutcomeParser({abi:f}).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 N=(0,W.parseOutputOutIndex)(x);if(N!==null&&N!==t){c[y]=null;continue}let[F,$,K]=x.split(".");if(F==="event"){if(!$||isNaN(Number(K)))continue;let S=Number(K),A=(0,Y.findEventsByFirstTopic)(r,$),He=d.parseEvents({events:A})[0],ee=Object.values(He)[S]||null;o.push(String(ee)),p.push(ee),c[y]=ee&&ee.valueOf()}else if(F==="out"||F.startsWith("out[")){if(!$)continue;let S=Number($),A=b.values[S-1]||null;K&&(A=A[K]||null),A&&typeof A=="object"&&(A="toFixed"in A?A.toFixed():A.valueOf()),o.push(String(A)),p.push(A),c[y]=A&&A.valueOf()}else c[y]=x}return{values:{string:o,native:p,mapped:{}},output:await(0,W.evaluateOutputCommon)(e,c,t,a,this.serializer.coreSerializer,this.config)}}async extractQueryOutput(e,t,r,a){let i=t.map(f=>this.serializer.typedToString(f)),o=t.map(f=>this.serializer.typedToNative(f)[1]),p={string:i,native:o,mapped:{}},c={};if(!e.output)return{values:p,output:c};let g=f=>{let d=f.split(".").slice(1).map(b=>parseInt(b)-1);if(d.length===0)return;let w=o[d[0]];for(let b=1;b<d.length;b++){if(w==null)return;w=w[d[b]]}return w};for(let[f,d]of Object.entries(e.output)){if(d.startsWith(W.WarpConstants.Transform.Prefix))continue;let w=(0,W.parseOutputOutIndex)(d);if(w!==null&&w!==r){c[f]=null;continue}d.startsWith("out.")||d==="out"||d.startsWith("out[")?c[f]=g(d)||null:c[f]=d}return c=await(0,W.evaluateOutputCommon)(e,c,r,a,this.serializer.coreSerializer,this.config),{values:p,output:c}}async resolveWarpOutputRecursively(e){let t=e.warp,r=e.entryActionIndex,a=e.executor,i=e.inputs,o=e.meta,p=new Map,c=new Set,g=this;async function f(y,x=[]){if(p.has(y))return p.get(y);if(c.has(y))throw new Error(`Circular dependency detected at action ${y}`);c.add(y);let N=t.actions[y-1];if(!N)throw new Error(`Action ${y} not found`);let F;if(N.type==="query")F=await a.executeQuery(t,y,x);else if(N.type==="collect")F=await a.executeCollect(t,y,x,o);else throw new Error(`Unsupported or interactive action type: ${N.type}`);if(p.set(y,F),t.output)for(let $ of Object.values(t.output)){let S=String($).match(/^out\[(\d+)\]/);if(S){let A=parseInt(S[1],10);A!==y&&!p.has(A)&&await f(A)}}return c.delete(y),F}await f(r,i);let d={};for(let y of p.values())for(let[x,N]of Object.entries(y.output))N!==null?d[x]=N:x in d||(d[x]=null);let w=await(0,W.evaluateOutputCommon)(t,d,r,i,this.serializer.coreSerializer,this.config);return{...p.get(r),action:r,output:w}}};var Ze="EGLD-000000",se=class{constructor(e,t,r){this.config=e;this.chain=t;this.typeRegistry=r;this.serializer=new L({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,k.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,k.getWarpWalletAddressFromConfig)(this.config,e.chain.name);if(!t)throw new Error("WarpMultiversxExecutor: createTransfer - user address not set");let r=C.Address.newFromBech32(t),a=new C.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 C.TransferTransactionsFactory({config:a}).createTransactionForTransfer(r,{receiver:C.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,k.getWarpWalletAddressFromConfig)(this.config,e.chain.name);if(!t)throw new Error("WarpMultiversxExecutor: createContractCall - user address not set");let r=(0,k.getWarpActionByIndex)(e.warp,e.action),a=C.Address.newFromBech32(t),i=e.args.map(p=>this.serializer.stringToTyped(p)),o=new C.TransactionsFactoryConfig({chainID:e.chain.chainId});return new C.SmartContractTransactionsFactory({config:o}).createTransactionForExecute(a,{contract:C.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,k.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),a=e.args.map(S=>this.serializer.stringToTyped(S)),i=T(e.chain,this.config.env,this.config),o=C.Address.newFromBech32(e.destination),p=i.createSmartContractController(r),c=p.createQuery({contract:o,function:t.func||"",arguments:a}),g=await p.runQuery(c),f=g.returnCode==="ok",d=new C.ArgSerializer,w=r.getEndpoint(g.function||t.func||""),b=(g.returnDataParts||[]).map(S=>Buffer.from(S)),y=d.buffersToValues(b,w.output),{values:x,output:N}=await this.output.extractQueryOutput(e.warp,y,e.action,e.resolvedInputs),F=(0,k.getNextInfo)(this.config,[],e.warp,e.action,N),K=e.resolvedInputs.find(S=>S.input.position==="receiver"||S.input.position==="destination")?.value||e.destination;return{status:f?"success":"error",warp:e.warp,action:e.action,user:(0,k.getWarpWalletAddressFromConfig)(this.config,e.chain.name),txHash:null,tx:null,next:F,values:x,output:{...N,_DATA:y},messages:(0,k.applyOutputToMessages)(e.warp,N,this.config),destination:K}}toTokenTransfers(e){return e.map(t=>t.identifier===this.chain.nativeToken.identifier?{...t,identifier:Ze}:t).map(t=>{let a=new C.TokenComputer().extractNonceFromExtendedIdentifier(t.identifier);return new C.TokenTransfer({token:new C.Token({identifier:t.identifier,nonce:BigInt(a||0)}),amount:t.amount})})}};var oe=class{constructor(e,t){this.chain=e;this.config=t}getExplorers(){let e=we[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(a=>{let i=H[a];i&&(r[a]=`${i}/accounts/${e}`)}),r}getTransactionUrls(e){let t=this.getAllExplorers(),r={};return t.forEach(a=>{let i=H[a];i&&(r[a]=`${i}/transactions/${e}`)}),r}};var m=require("@multiversx/sdk-core"),U=require("@vleap/warps");var Te={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 B=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}),We=s=>({unitPrice:BigInt(s.unit_price.toString()),admins:s.admins.map(e=>e.toBech32())});var pe=class{constructor(e,t){this.config=e;this.chain=t;this.cache=new U.WarpCache(e.cache?.type),this.registryConfig={unitPrice:BigInt(0),admins:[]},this.userWallet=(0,U.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 a=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(a,{contract:m.Address.newFromBech32(B(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(B(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 a=m.Address.newFromBech32(this.userWallet);return await this.getFactory().createTransactionForExecute(a,{contract:m.Address.newFromBech32(B(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(B(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(B(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(B(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(B(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(B(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=U.WarpCacheKey.RegistryInfo(this.config.env,e),a=t?this.cache.get(r):null;if(a)return U.WarpLogger.info(`WarpRegistry (getInfoByAlias): RegistryInfo found in cache: ${e}`),a;let i=m.Address.newFromBech32(B(this.config.env)),o=this.getController(),p=o.createQuery({contract:i,function:"getInfoByAlias",arguments:[m.BytesValue.fromUTF8(e)]}),c=await o.runQuery(p),[g]=o.parseQueryResponse(c),f=g?ce(g):null,d=f?.brand?await this.fetchBrand(f.brand):null;return t&&t.ttl&&this.cache.set(r,{registryInfo:f,brand:d},t.ttl),{registryInfo:f,brand:d}}catch{return{registryInfo:null,brand:null}}}async getInfoByHash(e,t){try{let r=U.WarpCacheKey.RegistryInfo(this.config.env,e);if(t){let d=this.cache.get(r);if(d)return U.WarpLogger.info(`WarpRegistry (getInfoByHash): RegistryInfo found in cache: ${e}`),d}let a=m.Address.newFromBech32(B(this.config.env)),i=this.getController(),o=i.createQuery({contract:a,function:"getInfoByHash",arguments:[m.BytesValue.fromHex(e)]}),p=await i.runQuery(o),[c]=i.parseQueryResponse(p),g=c?ce(c):null,f=g?.brand?await this.fetchBrand(g.brand):null;return t&&t.ttl&&this.cache.set(r,{registryInfo:g,brand:f},t.ttl),{registryInfo:g,brand:f}}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(B(this.config.env)),a=this.getController(),i=a.createQuery({contract:r,function:"getUserWarps",arguments:[new m.AddressValue(new m.Address(t))]}),o=await a.runQuery(i),[p]=a.parseQueryResponse(o);return p.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=m.Address.newFromBech32(B(this.config.env)),a=this.getController(),i=a.createQuery({contract:r,function:"getUserBrands",arguments:[new m.AddressValue(new m.Address(t))]}),o=await a.runQuery(i),[p]=a.parseQueryResponse(o),c=p.map(d=>d.toString("hex")),g={ttl:365*24*60*60};return(await Promise.all(c.map(d=>this.fetchBrand(d,g)))).filter(d=>d!==null)}catch{return[]}}async fetchBrand(e,t){let r=U.WarpCacheKey.Brand(this.config.env,e),a=t?this.cache.get(r):null;if(a)return U.WarpLogger.info(`WarpRegistry (fetchBrand): Brand found in cache: ${e}`),a;let o=T(this.chain,this.config.env,this.config).createNetworkProvider();try{let p=await o.getTransaction(e),c=JSON.parse(p.data.toString());return c.meta={query:null,chain:this.chain.name,identifier:(0,U.createWarpIdentifier)(this.chain.name,"hash",e),hash:p.hash,creator:p.sender.toBech32(),createdAt:new Date(p.timestamp*1e3).toISOString()},t&&t.ttl&&this.cache.set(r,c,t.ttl),c}catch{return null}}async loadRegistryConfigs(){let e=m.Address.newFromBech32(B(this.config.env)),t=this.getController(),[r]=await t.query({contract:e,function:"getConfig",arguments:[]}),a=r?We(r):null;this.registryConfig=a||{unitPrice:BigInt(0),admins:[]}}getFactory(){let e=new m.TransactionsFactoryConfig({chainID:this.chain.chainId}),t=m.AbiRegistry.create(Te);return new m.SmartContractTransactionsFactory({config:e,abi:t})}getController(){let e=T(this.chain,this.config.env,this.config),t=m.AbiRegistry.create(Te);return e.createSmartContractController(t)}isCurrentUserAdmin(){return!!this.userWallet&&this.registryConfig.admins.includes(this.userWallet)}};var P=require("@multiversx/sdk-core"),M=require("@vleap/warps");var le=class{constructor(e,t){this.config=e;this.chain=t;this.entry=T(t,e.env,e),this.provider=this.entry.createNetworkProvider(),this.cache=new M.WarpCache(e.cache?.type)}async signTransaction(e){if(!e||typeof e!="object")throw new Error("Invalid transaction object");let t=(0,M.getWarpWalletPrivateKeyFromConfig)(this.config,this.chain.name);if(!t)throw new Error("Wallet not initialized - no private key provided");let a=t.startsWith("-----")?P.UserSecretKey.fromPem(t):P.UserSecretKey.fromString(t),i=new P.Account(a);if(e.nonce===0n){let p=await this.entry.recallAccountNonce(i.address),c=this.cache.get(`nonce:${i.address.toBech32()}`)||0,g=BigInt(Math.max(c,Number(p)));e.nonce=g}e.signature=await i.signTransaction(e);let o=Number(i.nonce)+1;return this.cache.set(`nonce:${i.address.toBech32()}`,o,M.CacheTtl.OneMinute),e}async signTransactions(e){return Promise.all(e.map(async t=>this.signTransaction(t)))}async signMessage(e){let t=(0,M.getWarpWalletPrivateKeyFromConfig)(this.config,this.chain.name);if(!t)throw new Error("Wallet not initialized - no private key provided");let a=t.startsWith("-----")?P.UserSecretKey.fromPem(t):P.UserSecretKey.fromString(t),o=await new P.Account(a).signMessage(new P.Message({data:Buffer.from(e)}));return Buffer.from(o).toString("hex")}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){let r=P.Mnemonic.fromString(e).deriveKey(0),a=r.hex();return{address:r.generatePublicKey().toAddress(this.chain.addressHrp).toBech32(),privateKey:a,mnemonic:e}}generate(){let e=P.Mnemonic.generate(),t=e.toString(),r=e.deriveKey(0),a=r.hex();return{address:r.generatePublicKey().toAddress(this.chain.addressHrp).toBech32(),privateKey:a,mnemonic:t}}getAddress(){return(0,M.getWarpWalletAddressFromConfig)(this.config,this.chain.name)}getPublicKey(){let e=(0,M.getWarpWalletPrivateKeyFromConfig)(this.config,this.chain.name);return e?(e.startsWith("-----")?P.UserSecretKey.fromPem(e):P.UserSecretKey.fromString(e)).generatePublicKey().hex():null}};var ue=(s,e)=>(t,r)=>{let a=e[t.env],i=new _e.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:a,builder:()=>new ae(t,a),executor:new se(t,a,i),output:new j(t,a,i),serializer:new L({typeRegistry:i}),registry:new pe(t,a),explorer:new oe(s,t),abiBuilder:()=>new R(t,a),brandBuilder:()=>new ne(t,a),dataLoader:new ie(t,a),wallet:new le(t,a)}};var de={chain:Z.WarpChainName.Multiversx,identifier:"EGLD",name:"eGold",symbol:"EGLD",decimals:18,logoUrl:"https://vleap.ai/images/tokens/egld.svg"},Ce=ue(Z.WarpChainName.Multiversx,{mainnet:{name:Z.WarpChainName.Multiversx,displayName:"MultiversX",chainId:"1",blockTime:6e3,addressHrp:"erd",defaultApiUrl:"https://api.multiversx.com",logoUrl:"https://vleap.ai/images/chains/multiversx.svg",nativeToken:de},testnet:{name:Z.WarpChainName.Multiversx,displayName:"MultiversX Testnet",chainId:"T",blockTime:6e3,addressHrp:"erd",defaultApiUrl:"https://testnet-api.multiversx.com",logoUrl:"https://vleap.ai/images/chains/multiversx.svg",nativeToken:de},devnet:{name:Z.WarpChainName.Multiversx,displayName:"MultiversX Devnet",chainId:"D",blockTime:6e3,addressHrp:"erd",defaultApiUrl:"https://devnet-api.multiversx.com",logoUrl:"https://vleap.ai/images/chains/multiversx.svg",nativeToken:de}});var he=require("@vleap/warps");var Ge={chain:he.WarpChainName.Vibechain,identifier:"VIBE",name:"VIBE",symbol:"VIBE",decimals:18,logoUrl:"https://vleap.ai/images/tokens/vibe.svg"},xe={name:he.WarpChainName.Vibechain,displayName:"VibeChain",chainId:"V",blockTime:600,addressHrp:"vibe",defaultApiUrl:"https://vibeox-api.multiversx.com",logoUrl:"https://vleap.ai/images/chains/vibechain.svg",nativeToken:Ge},Ae=ue(he.WarpChainName.Vibechain,{mainnet:xe,testnet:xe,devnet:xe});var tt=(s,e)=>[Ce(s,e),Ae(s,e)],rt=()=>[Ee.WarpChainName.Multiversx,Ee.WarpChainName.Vibechain];var D=require("@vleap/warps");var nt=s=>new D.WarpSerializer().nativeToString(v.Token,s),at=s=>new D.WarpSerializer().nativeToString(v.CodeMeta,s),it=(s,e)=>{if(e===null)return v.Optional+D.WarpConstants.ArgParamsSeparator;let t=s(e),r=t.indexOf(D.WarpConstants.ArgParamsSeparator),a=t.substring(0,r),i=t.substring(r+1);return v.Optional+D.WarpConstants.ArgParamsSeparator+a+D.WarpConstants.ArgParamsSeparator+i},st=s=>new D.WarpSerializer().nativeToString(v.List,s);var l=require("@multiversx/sdk-core"),ot=(s,e)=>s?l.OptionValue.newProvided(s):e?l.OptionValue.newMissingTyped(e):l.OptionValue.newMissing(),ct=(s,e)=>s?new l.OptionalValue(s.getType(),s):e?new l.OptionalValue(e):l.OptionalValue.newMissing(),pt=s=>{if(s.length===0)throw new Error("Cannot create a list from an empty array");let e=s[0].getType();return new l.List(e,s)},lt=s=>l.VariadicValue.fromItems(...s),ut=s=>{let e=s.map(t=>t.getType());return new l.CompositeValue(new l.CompositeType(...e),s)},mt=s=>l.StringValue.fromUTF8(s),dt=s=>new l.U8Value(s),ht=s=>new l.U16Value(s),ft=s=>new l.U32Value(s),gt=s=>new l.U64Value(s),yt=s=>new l.BigUIntValue(BigInt(s)),vt=s=>new l.BooleanValue(s),wt=s=>new l.AddressValue(l.Address.newFromBech32(s)),Tt=s=>new l.TokenIdentifierValue(s),Wt=s=>l.BytesValue.fromHex(s),Ct=s=>new l.Struct(new l.StructType("EsdtTokenPayment",[new l.FieldDefinition("token_identifier","",new l.TokenIdentifierType),new l.FieldDefinition("token_nonce","",new l.U64Type),new l.FieldDefinition("amount","",new l.BigUIntType)]),[new l.Field(new l.TokenIdentifierValue(s.token.identifier),"token_identifier"),new l.Field(new l.U64Value(BigInt(s.token.nonce)),"token_nonce"),new l.Field(new l.BigUIntValue(BigInt(s.amount)),"amount")]),xt=s=>new l.CodeMetadataValue(l.CodeMetadata.newFromBytes(Uint8Array.from(Buffer.from(s,"hex")))),At=()=>new l.NothingValue;0&&(module.exports={ExplorerUrls,KnownTokens,MultiversxExplorers,MultiversxExplorersConfig,NativeTokenEgld,NativeTokenVibe,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,getMultiversxAdapter,getMultiversxEntrypoint,getMultiversxRegistryAddress,getNormalizedTokenIdentifier,getVibechainAdapter,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 Et}from"@vleap/warps";import{WarpChainName as D}from"@vleap/warps";import{WarpTypeRegistry as zr}from"@vleap/warps";import{AbiRegistry as pe,Address as kt,TransactionsFactoryConfig as Ft,TransferTransactionsFactory as Ot}from"@multiversx/sdk-core";import{createWarpIdentifier as Mt,getLatestProtocolIdentifier as Rt,getWarpWalletAddressFromConfig as Lt,WarpCache as Dt,WarpCacheKey as _t,WarpConstants as De,WarpLogger as _e}from"@vleap/warps";import{DevnetEntrypoint as Pt,MainnetEntrypoint as Nt,TestnetEntrypoint as Vt}from"@multiversx/sdk-core";import{getProviderConfig as Ut}from"@vleap/warps";var F=s=>!s.includes("-"),_=s=>F(s)?`${s}-000000`:s,v=(s,e,t)=>{let r="warp-sdk",a=t?Ut(t,s.name,e,s.defaultApiUrl):{url:s.defaultApiUrl},i=a.url,c={headers:a.headers};return e==="devnet"?new Pt({url:i,kind:"api",clientName:r,networkProviderConfig:c}):e==="testnet"?new Vt({url:i,kind:"api",clientName:r,networkProviderConfig:c}):new Nt({url:i,kind:"api",clientName:r,networkProviderConfig:c})};import{WarpLogger as Le}from"@vleap/warps";var G=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 Le.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 Le.error("WarpContractLoader: getVerificationInfo error",r),null}}};var B=class{constructor(e,t){this.config=e;this.chain=t;this.contractLoader=new G(this.config),this.cache=new Dt(this.config.cache?.type)}async createInscriptionTransaction(e){let t=Lt(this.config,this.chain.name);if(!t)throw new Error("WarpBuilder: user address not set");let r=new Ft({chainID:this.chain.chainId}),n=new Ot({config:r}),a=kt.newFromBech32(t),i={protocol:Rt("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:Mt(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=_t.WarpAbi(this.config.env,e);if(t){let i=this.cache.get(r);if(i)return _e.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),c=await this.createFromTransaction(i);return t&&t.ttl&&c&&this.cache.set(r,c,t.ttl),c}catch(i){return _e.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 pe.create(t.abi)}async fetchAbi(e){if(!e.abi)throw new Error("WarpActionExecutor: ABI not found");if(e.abi.startsWith(De.IdentifierType.Hash)){let t=e.abi.split(De.ArgParamsSeparator)[1],r=await this.createFromTransactionHash(t);if(!r)throw new Error(`WarpActionExecutor: ABI not found for hash: ${e.abi}`);return pe.create(r.content)}else{let r=await(await fetch(e.abi)).json();return pe.create(r)}}};import{Address as Ge,TransactionsFactoryConfig as Gt,TransferTransactionsFactory as Ht}from"@multiversx/sdk-core";import{createWarpIdentifier as $t,getWarpWalletAddressFromConfig as zt,WarpBrandBuilder as qt,WarpLogger as Kt}from"@vleap/warps";import{Buffer as Qt}from"buffer";var H=class{constructor(e,t){this.config=e;this.chain=t;this.core=new qt(e)}async createInscriptionTransaction(e){let t=zt(this.config,this.chain.name);if(!t)throw new Error("BrandBuilder: user address not set");let r=new Gt({chainID:this.chain.chainId}),n=new Ht({config:r}),a=Ge.newFromBech32(t),i=JSON.stringify(e);return await n.createTransactionForNativeTokenTransfer(a,{receiver:Ge.newFromBech32(t),nativeAmount:BigInt(0),data:Uint8Array.from(Qt.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:$t(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 Kt.error("BrandBuilder: Error creating from transaction hash",n),null}}};import{Address as He,TransactionsFactoryConfig as jt,TransferTransactionsFactory as Xt}from"@multiversx/sdk-core";import{createWarpIdentifier as Jt,getWarpWalletAddressFromConfig as Yt,WarpBuilder as $e,WarpCache as Zt,WarpCacheKey as er,WarpLogger as ze}from"@vleap/warps";var $=class extends $e{constructor(t,r){super(t);this.config=t;this.chain=r;this.cache=new Zt(t.cache?.type),this.core=new $e(t)}async createInscriptionTransaction(t){let r=Yt(this.config,this.chain.name);if(!r)throw new Error("WarpBuilder: user address not set");let n=new jt({chainID:this.chain.chainId}),a=new Xt({config:n}),i=He.newFromBech32(r),c=JSON.stringify(t),o=await a.createTransactionForTransfer(i,{receiver:He.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:Jt(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=er.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=v(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 le,Token as ir,TokenComputer as sr}from"@multiversx/sdk-core";import{CacheTtl as or,WarpCache as cr,WarpCacheKey as pr}from"@vleap/warps";import{WarpChainName as tr}from"@vleap/warps";var qe=tr.Multiversx,Ke=[{chain:qe,identifier:"EGLD",name:"eGold",symbol:"EGLD",decimals:18,logoUrl:"https://tools.multiversx.com/assets-cdn/tokens/EGLD-000000/icon.png"},{chain:qe,identifier:"EGLD-000000",name:"eGold",symbol:"EGLD",decimals:18,logoUrl:"https://tools.multiversx.com/assets-cdn/tokens/EGLD-000000/icon.png"}];import{WarpChainName as rr}from"@vleap/warps";var A=rr.Multiversx,Qe=[{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 nr}from"@vleap/warps";var je=nr.Multiversx,Xe=[{chain:je,identifier:"EGLD",name:"eGold",symbol:"EGLD",decimals:18,logoUrl:"https://tools.multiversx.com/assets-cdn/tokens/EGLD-000000/icon.png"},{chain:je,identifier:"EGLD-000000",name:"eGold",symbol:"EGLD",decimals:18,logoUrl:"https://tools.multiversx.com/assets-cdn/tokens/EGLD-000000/icon.png"}];import{WarpChainName as ar}from"@vleap/warps";var Je=ar.Vibechain,z=[{chain:Je,identifier:"VIBE",name:"VIBE",symbol:"VIBE",decimals:18,logoUrl:"https://vleap.ai/images/tokens/vibe.svg"},{chain:Je,identifier:"VIBE-000000",name:"VIBE",symbol:"VIBE",decimals:18,logoUrl:"https://vleap.ai/images/tokens/vibe.svg"}];var Ye={multiversx:{mainnet:Qe,testnet:Xe,devnet:Ke},vibechain:{mainnet:z,testnet:z,devnet:z}},Ze=(s,e,t)=>(Ye[s]?.[e]||[]).find(n=>n.identifier===t)||null,Ba=(s,e)=>Ye[s]?.[e]||[];var q=class{constructor(e,t){this.config=e;this.chain=t;this.cache=new cr(e.cache?.type)}async getAccount(e){let r=await v(this.chain,this.config.env,this.config).createNetworkProvider().getAccount(le.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(le.newFromBech32(e)),n=t.getFungibleTokensOfAccount(le.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=pr.Asset(this.config.env,this.chain.name,e),r=this.cache.get(t);if(r)return r;let n=Ze(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 sr,i=F(e)?0n:a.extractNonceFromExtendedIdentifier(e),c=new ir({identifier:e,nonce:BigInt(i||0)}),o=a.isFungible(c),d=v(this.chain,this.config.env,this.config).createNetworkProvider(),m=_(e),l=await d.doGetGeneric(`tokens/${m}`),y={chain:this.chain.name,identifier:c.identifier,name:l.name,symbol:l.ticker,amount:0n,decimals:l.decimals,logoUrl:l.assets?.pngUrl||null,price:l.price?Number(l.price):void 0,supply:l.supply?BigInt(l.supply):void 0};return this.cache.set(t,y,or.OneHour),y}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,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 L,ArgSerializer as br,SmartContractTransactionsFactory as Sr,Token as Ir,TokenComputer as Br,TokenTransfer as Pr,TransactionsFactoryConfig as yt,TransferTransactionsFactory as Nr}from"@multiversx/sdk-core";import{applyOutputToMessages as Vr,getNextInfo as Ur,getWarpActionByIndex as Ee,getWarpWalletAddressFromConfig as be}from"@vleap/warps";import{findEventsByFirstTopic as yr,SmartContractTransactionsOutcomeParser as vr,TransactionEventsParser as wr}from"@multiversx/sdk-core";import{applyOutputToMessages as Tr,evaluateOutputCommon as ee,getNextInfo as Wr,getWarpActionByIndex as Cr,getWarpWalletAddressFromConfig as xr,parseOutputOutIndex as ft,WarpCache as Ar,WarpCacheKey as Er,WarpConstants as gt}from"@vleap/warps";import{Address as mr,AddressType as ue,AddressValue as tt,BigUIntType as K,BigUIntValue as me,BooleanType as de,BooleanValue as rt,BytesType as he,BytesValue as nt,CodeMetadata as dr,CodeMetadataType as fe,CodeMetadataValue as at,CompositeType as ge,CompositeValue as it,Field as Q,FieldDefinition as j,List as st,ListType as ot,NothingValue as S,OptionalType as ct,OptionalValue as ye,OptionType as pt,OptionValue as ve,StringType as we,StringValue as lt,Struct as X,StructType as k,Token as hr,TokenComputer as ut,TokenIdentifierType as J,TokenIdentifierValue as Te,U16Type as We,U16Value as mt,U32Type as Ce,U32Value as dt,U64Type as Y,U64Value as xe,U8Type as Ae,U8Value as ht,VariadicType as R,VariadicValue as Z}from"@multiversx/sdk-core";import{WarpSerializer as fr}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.chain.name]},ChainApiUrl:{Placeholder:"CHAIN_API",Accessor:s=>s.chain.defaultApiUrl},ChainAddressHrp:{Placeholder:"CHAIN_ADDRESS_HRP",Accessor:s=>s.chain.addressHrp}},Vars:{Query:"query",Env:"env"},ArgParamsSeparator:":",ArgCompositeSeparator:"|",ArgListSeparator:",",ArgStructSeparator:";",Transform:{Prefix:"transform:"},Source:{UserWallet:"user:wallet"},Position:{Payload:"payload:"},Alerts:{TriggerEventPrefix:"event"}},p={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 qa={Egld:{Identifier:"EGLD",EsdtIdentifier:"EGLD-000000",DisplayName:"eGold",Decimals:18}},f={Null:"null",Optional:"optional",List:"list",Token:"token",CodeMeta:"codemeta"},lr=(r=>(r.MultiversxExplorer="multiversx_explorer",r.MultiversxExplorerDevnet="multiversx_explorer_devnet",r.MultiversxExplorerTestnet="multiversx_explorer_testnet",r))(lr||{}),ur=(r=>(r.VibechainExplorer="vibechain_explorer",r.VibechainExplorerDevnet="vibechain_explorer_devnet",r.VibechainExplorerTestnet="vibechain_explorer_testnet",r))(ur||{}),et={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 gr=new RegExp(`${u.ArgParamsSeparator}(.*)`),P=class{constructor(e){this.coreSerializer=new fr(e)}typedToString(e){let t=e.getType();if(t.hasExactClass(pt.ClassName)||e.hasClassOrSuperclass(ve.ClassName)){if(!e.isSet())return p.Option+u.ArgParamsSeparator+"null";let r=this.typedToString(e.getTypedValue());return p.Option+u.ArgParamsSeparator+r}if(t.hasExactClass(R.ClassName)||e.hasClassOrSuperclass(Z.ClassName)){let r=e.getItems();if(r.length===0){let m=this.typeToString(t.getFirstTypeParameter());return p.Vector+u.ArgParamsSeparator+m+u.ArgParamsSeparator}let n=r.map(m=>this.typedToString(m));if(n.every(m=>m.startsWith(p.Tuple)))return p.Vector+u.ArgParamsSeparator+n.join(",");let a=n[0],i=a.indexOf(u.ArgParamsSeparator),c=a.substring(0,i),o=n.map(m=>{let l=m.indexOf(u.ArgParamsSeparator);return m.substring(l+1)}),d=c.startsWith(p.Struct)?u.ArgStructSeparator:u.ArgListSeparator;return p.Vector+u.ArgParamsSeparator+c+u.ArgParamsSeparator+o.join(d)}if(t.hasExactClass(ct.ClassName)||e.hasClassOrSuperclass(ye.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(ot.ClassName)||e.hasClassOrSuperclass(st.ClassName)){let n=e.getItems().map(o=>this.typedToString(o));if(n.every(o=>o.startsWith(p.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(ge.ClassName)||e.hasClassOrSuperclass(it.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`${p.Tuple}(${n.join(",")})`}if(t.hasExactClass(K.ClassName)||e.hasClassOrSuperclass(me.ClassName)||t.getName()==="BigUint")return p.Biguint+u.ArgParamsSeparator+BigInt(e.valueOf().toFixed());if(t.hasExactClass(Ae.ClassName)||e.hasClassOrSuperclass(ht.ClassName))return p.Uint8+u.ArgParamsSeparator+e.valueOf().toNumber();if(t.hasExactClass(We.ClassName)||e.hasClassOrSuperclass(mt.ClassName))return p.Uint16+u.ArgParamsSeparator+e.valueOf().toNumber();if(t.hasExactClass(Ce.ClassName)||e.hasClassOrSuperclass(dt.ClassName))return p.Uint32+u.ArgParamsSeparator+e.valueOf().toNumber();if(t.hasExactClass(Y.ClassName)||e.hasClassOrSuperclass(xe.ClassName))return p.Uint64+u.ArgParamsSeparator+BigInt(e.valueOf().toFixed());if(t.hasExactClass(we.ClassName)||e.hasClassOrSuperclass(lt.ClassName))return p.String+u.ArgParamsSeparator+e.valueOf();if(t.hasExactClass(de.ClassName)||e.hasClassOrSuperclass(rt.ClassName))return p.Bool+u.ArgParamsSeparator+e.valueOf();if(t.hasExactClass(ue.ClassName)||e.hasClassOrSuperclass(tt.ClassName))return p.Address+u.ArgParamsSeparator+e.valueOf().toBech32();if(t.hasExactClass(he.ClassName)||e.hasClassOrSuperclass(nt.ClassName))return p.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 ut().computeExtendedIdentifier(new hr({identifier:r,nonce:BigInt(n)}));return p.Asset+u.ArgParamsSeparator+c+u.ArgCompositeSeparator+a}if(t.hasExactClass(k.ClassName)||e.hasClassOrSuperclass(X.ClassName)){let r=e,a=r.getType().getName(),i=r.getFields();if(i.length===0)return`${p.Struct}(${a})${u.ArgParamsSeparator}`;let c=i.map(o=>{let d=o.value.getType(),l=this.typedToString(o.value).split(u.ArgParamsSeparator),y=l.length>2?l.slice(2).join(u.ArgParamsSeparator):l[1]||"";return`(${o.name}${u.ArgParamsSeparator}${this.typeToString(d)})${y}`});return`${p.Struct}(${a})${u.ArgParamsSeparator}${c.join(u.ArgListSeparator)}`}if(t.hasExactClass(J.ClassName)||e.hasClassOrSuperclass(Te.ClassName))return f.Token+u.ArgParamsSeparator+e.valueOf();if(t.hasExactClass(fe.ClassName)||e.hasClassOrSuperclass(at.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(p.Tuple))return this.stringToTyped(e+":");let r=this.coreSerializer.nativeToString(e,t);return this.stringToTyped(r)}nativeToType(e){if(e.startsWith(p.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 ge(...n.map(a=>this.nativeToType(a)))}if(e.startsWith(p.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===p.String)return new we;if(e===p.Uint8)return new Ae;if(e===p.Uint16)return new We;if(e===p.Uint32)return new Ce;if(e===p.Uint64)return new Y;if(e===p.Biguint)return new K;if(e===p.Bool)return new de;if(e===p.Address)return new ue;if(e===p.Hex)return new he;if(e===p.Asset)return new k("EsdtTokenPayment",[new j("token_identifier","",new J),new j("token_nonce","",new Y),new j("amount","",new K)]);if(e===f.Token)return new J;if(e===f.CodeMeta)return new fe;throw new Error(`WarpArgSerializer (nativeToType): Unsupported input type: ${e}`)}stringToTyped(e){let[t,r]=e.split(/:(.*)/,2);if(t===p.Option){let n=this.stringToTyped(r);return n instanceof S?ve.newMissingTyped(n.getType()):ve.newProvided(n)}if(t===p.Vector){let n=r.indexOf(u.ArgParamsSeparator),a=r.substring(0,n),i=r.substring(n+1);if(a.startsWith(p.Tuple)){let l=i.split(",").map(y=>this.stringToTyped(y));return new Z(new R(this.nativeToType(a)),l)}if(i.includes("tuple(")){let m=this.splitTupleStrings(i),l=m.map(T=>this.stringToTyped(T)),C=m[0].match(/^(tuple\([^)]+\))/),h=C?C[1]:"tuple";return new Z(new R(this.nativeToType(h)),l)}let c=a.startsWith(p.Struct)?u.ArgStructSeparator:u.ArgListSeparator,d=i.split(c).map(m=>this.stringToTyped(`${a}:${m}`));return new Z(new R(this.nativeToType(a)),d)}if(t.startsWith(p.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 it(new ge(...c),i)}if(t.startsWith(p.Struct)){let n=t.match(/\(([^)]+)\)/),a=n?n[1]:"CustomStruct";if(!r)return new X(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[,l,y,C]=m,h=this.stringToTyped(`${y}${u.ArgParamsSeparator}${C}`);c.push(new j(l,"",h.getType())),o.push(new Q(h,l))}}),new X(new k(a,c),o)}if(t===p.String)return r?lt.fromUTF8(r):new S;if(t===p.Uint8)return r?new ht(Number(r)):new S;if(t===p.Uint16)return r?new mt(Number(r)):new S;if(t===p.Uint32)return r?new dt(Number(r)):new S;if(t===p.Uint64)return r?new xe(BigInt(r)):new S;if(t===p.Biguint)return r?new me(BigInt(r)):new S;if(t===p.Bool)return r?new rt(typeof r=="boolean"?r:r==="true"):new S;if(t===p.Address)return r?new tt(mr.newFromBech32(r)):new S;if(t===p.Hex)return r?nt.fromHex(r):new S;if(t===p.Asset){let[n,a]=r.split(u.ArgCompositeSeparator),i=new ut,c=F(n)?_(n):i.extractIdentifierFromExtendedIdentifier(n),o=F(n)?0n:i.extractNonceFromExtendedIdentifier(n);return new X(this.nativeToType("asset"),[new Q(new Te(c),"token_identifier"),new Q(new xe(BigInt(o)),"token_nonce"),new Q(new me(BigInt(a)),"amount")])}if(t===f.Null)return new S;if(t===f.Optional){let n=this.stringToTyped(r);return n instanceof S?ye.newMissing():new ye(n.getType(),n)}if(t===f.List){let[n,a]=r.split(gr,2),c=a.split(u.ArgListSeparator).map(o=>this.stringToTyped(n+u.ArgParamsSeparator+o));return new st(this.nativeToType(n),c)}if(t===f.Token)return r?new Te(r):new S;if(t===f.CodeMeta)return new at(dr.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(pt.ClassName))return p.Option+u.ArgParamsSeparator+this.typeToString(e.getFirstTypeParameter());if(e.hasExactClass(R.ClassName))return p.Vector+u.ArgParamsSeparator+this.typeToString(e.getFirstTypeParameter());if(e.hasExactClass(we.ClassName))return p.String;if(e.hasExactClass(Ae.ClassName))return p.Uint8;if(e.hasExactClass(We.ClassName))return p.Uint16;if(e.hasExactClass(Ce.ClassName))return p.Uint32;if(e.hasExactClass(Y.ClassName))return p.Uint64;if(e.hasExactClass(K.ClassName))return p.Biguint;if(e.hasExactClass(de.ClassName))return p.Bool;if(e.hasExactClass(ue.ClassName))return p.Address;if(e.hasExactClass(he.ClassName))return p.Hex;if(e.hasExactClass(J.ClassName))return f.Token;if(e.hasExactClass(ct.ClassName))return f.Optional+u.ArgParamsSeparator+this.typeToString(e.getFirstTypeParameter());if(e.hasExactClass(ot.ClassName))return f.List+u.ArgParamsSeparator+this.typeToString(e.getFirstTypeParameter());if(e.hasExactClass(fe.ClassName))return f.CodeMeta;if(e.hasExactClass(k.ClassName)&&e.getClassName()==="EsdtTokenPayment")return p.Asset;if(e.hasExactClass(k.ClassName))return`${p.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 B(e,t),this.serializer=new P({typeRegistry:this.typeRegistry}),this.cache=new Ar(e.cache?.type)}async getActionExecution(e,t,r){let n=this.cache.get(Er.WarpExecutable(this.config.env,e.meta?.hash||"",t))??[],a=await this.extractContractOutput(e,t,r,n),i=Wr(this.config,[],e,t,a.output),c=Tr(e,a.output,this.config);return{status:r.status.isSuccessful()?"success":"error",warp:e,action:t,user:xr(this.config,this.chain.name),txHash:r.hash,tx:r,next:i,values:a.values,output:a.output,messages:c,destination:null}}async extractContractOutput(e,t,r,n){let a=Cr(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 ee(e,o,t,n,this.serializer.coreSerializer,this.config)}}let m=await this.abi.getAbiForAction(a),l=new wr({abi:m}),C=new vr({abi:m}).parseExecute({transactionOnNetwork:r,function:a.func||void 0});for(let[h,T]of Object.entries(e.output)){if(T.startsWith(gt.Transform.Prefix))continue;if(T.startsWith("input.")){o[h]=T;continue}let E=ft(T);if(E!==null&&E!==t){o[h]=null;continue}let[I,N,V]=T.split(".");if(I==="event"){if(!N||isNaN(Number(V)))continue;let x=Number(V),W=yr(r,N),Bt=l.parseEvents({events:W})[0],M=Object.values(Bt)[x]||null;i.push(String(M)),c.push(M),o[h]=M&&M.valueOf()}else if(I==="out"||I.startsWith("out[")){if(!N)continue;let x=Number(N),W=C.values[x-1]||null;V&&(W=W[V]||null),W&&typeof W=="object"&&(W="toFixed"in W?W.toFixed():W.valueOf()),i.push(String(W)),c.push(W),o[h]=W&&W.valueOf()}else o[h]=T}return{values:{string:i,native:c,mapped:{}},output:await ee(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 l=m.split(".").slice(1).map(C=>parseInt(C)-1);if(l.length===0)return;let y=i[l[0]];for(let C=1;C<l.length;C++){if(y==null)return;y=y[l[C]]}return y};for(let[m,l]of Object.entries(e.output)){if(l.startsWith(gt.Transform.Prefix))continue;let y=ft(l);if(y!==null&&y!==r){o[m]=null;continue}l.startsWith("out.")||l==="out"||l.startsWith("out[")?o[m]=d(l)||null:o[m]=l}return o=await ee(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 E=t.actions[h-1];if(!E)throw new Error(`Action ${h} not found`);let I;if(E.type==="query")I=await n.executeQuery(t,h,T);else if(E.type==="collect")I=await n.executeCollect(t,h,T,i);else throw new Error(`Unsupported or interactive action type: ${E.type}`);if(c.set(h,I),t.output)for(let N of Object.values(t.output)){let x=String(N).match(/^out\[(\d+)\]/);if(x){let W=parseInt(x[1],10);W!==h&&!c.has(W)&&await m(W)}}return o.delete(h),I}await m(r,a);let l={};for(let h of c.values())for(let[T,E]of Object.entries(h.output))E!==null?l[T]=E:T in l||(l[T]=null);let y=await ee(t,l,r,a,this.serializer.coreSerializer,this.config);return{...c.get(r),action:r,output:y}}};var kr="EGLD-000000",te=class{constructor(e,t,r){this.config=e;this.chain=t;this.typeRegistry=r;this.serializer=new P({typeRegistry:this.typeRegistry}),this.abi=new B(this.config,this.chain),this.output=new O(this.config,this.chain,this.typeRegistry)}async createTransaction(e){let t=Ee(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=L.newFromBech32(t),n=new yt({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 Nr({config:n}).createTransactionForTransfer(r,{receiver:L.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=Ee(e.warp,e.action),n=L.newFromBech32(t),a=e.args.map(c=>this.serializer.stringToTyped(c)),i=new yt({chainID:e.chain.chainId});return new Sr({config:i}).createTransactionForExecute(n,{contract:L.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=Ee(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(x=>this.serializer.stringToTyped(x)),a=v(e.chain,this.config.env,this.config),i=L.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",l=new br,y=r.getEndpoint(d.function||t.func||""),C=(d.returnDataParts||[]).map(x=>Buffer.from(x)),h=l.buffersToValues(C,y.output),{values:T,output:E}=await this.output.extractQueryOutput(e.warp,h,e.action,e.resolvedInputs),I=Ur(this.config,[],e.warp,e.action,E),V=e.resolvedInputs.find(x=>x.input.position==="receiver"||x.input.position==="destination")?.value||e.destination;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:{...E,_DATA:h},messages:Vr(e.warp,E,this.config),destination:V}}toTokenTransfers(e){return e.map(t=>t.identifier===this.chain.nativeToken.identifier?{...t,identifier:kr}:t).map(t=>{let n=new Br().extractNonceFromExtendedIdentifier(t.identifier);return new Pr({token:new Ir({identifier:t.identifier,nonce:BigInt(n||0)}),amount:t.amount})})}};var re=class{constructor(e,t){this.chain=e;this.config=t}getExplorers(){let e=et[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 wt,Address as g,AddressValue as Ie,BytesValue as w,SmartContractTransactionsFactory as Or,TransactionsFactoryConfig as Mr}from"@multiversx/sdk-core";import{createWarpIdentifier as Rr,getWarpWalletAddressFromConfig as Lr,WarpCache as Dr,WarpCacheKey as Be,WarpLogger as Pe}from"@vleap/warps";var Se={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 b=s=>{if(s==="devnet")return"erd1qqqqqqqqqqqqqpgqje2f99vr6r7sk54thg03c9suzcvwr4nfl3tsfkdl36";if(s==="testnet")throw new Error("Multiversx testnet is not supported");return"erd1qqqqqqqqqqqqqpgq3mrpj3u6q7tejv6d7eqhnyd27n9v5c5tl3ts08mffe"};var ne=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}),vt=s=>({unitPrice:BigInt(s.unit_price.toString()),admins:s.admins.map(e=>e.toBech32())});var ae=class{constructor(e,t){this.config=e;this.chain=t;this.cache=new Dr(e.cache?.type),this.registryConfig={unitPrice:BigInt(0),admins:[]},this.userWallet=Lr(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=g.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:g.newFromBech32(b(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=g.newFromBech32(this.userWallet);return await this.getFactory().createTransactionForExecute(t,{contract:g.newFromBech32(b(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=g.newFromBech32(this.userWallet);return await this.getFactory().createTransactionForExecute(n,{contract:g.newFromBech32(b(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=g.newFromBech32(this.userWallet);return await this.getFactory().createTransactionForExecute(r,{contract:g.newFromBech32(b(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=g.newFromBech32(this.userWallet);return await this.getFactory().createTransactionForExecute(t,{contract:g.newFromBech32(b(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=g.newFromBech32(this.userWallet);return await this.getFactory().createTransactionForExecute(r,{contract:g.newFromBech32(b(this.config.env)),function:"transferOwnership",gasLimit:BigInt(1e7),arguments:[w.fromHex(e),new Ie(new g(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=g.newFromBech32(this.userWallet);return await this.getFactory().createTransactionForExecute(t,{contract:g.newFromBech32(b(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=g.newFromBech32(this.userWallet);return await this.getFactory().createTransactionForExecute(r,{contract:g.newFromBech32(b(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=Be.RegistryInfo(this.config.env,e),n=t?this.cache.get(r):null;if(n)return Pe.info(`WarpRegistry (getInfoByAlias): RegistryInfo found in cache: ${e}`),n;let a=g.newFromBech32(b(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?ne(d):null,l=m?.brand?await this.fetchBrand(m.brand):null;return t&&t.ttl&&this.cache.set(r,{registryInfo:m,brand:l},t.ttl),{registryInfo:m,brand:l}}catch{return{registryInfo:null,brand:null}}}async getInfoByHash(e,t){try{let r=Be.RegistryInfo(this.config.env,e);if(t){let l=this.cache.get(r);if(l)return Pe.info(`WarpRegistry (getInfoByHash): RegistryInfo found in cache: ${e}`),l}let n=g.newFromBech32(b(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?ne(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=g.newFromBech32(b(this.config.env)),n=this.getController(),a=n.createQuery({contract:r,function:"getUserWarps",arguments:[new Ie(new g(t))]}),i=await n.runQuery(a),[c]=n.parseQueryResponse(i);return c.map(ne)}catch{return[]}}async getUserBrands(e){try{let t=e||this.userWallet;if(!t)throw new Error("WarpRegistry: user address not set");let r=g.newFromBech32(b(this.config.env)),n=this.getController(),a=n.createQuery({contract:r,function:"getUserBrands",arguments:[new Ie(new g(t))]}),i=await n.runQuery(a),[c]=n.parseQueryResponse(i),o=c.map(l=>l.toString("hex")),d={ttl:365*24*60*60};return(await Promise.all(o.map(l=>this.fetchBrand(l,d)))).filter(l=>l!==null)}catch{return[]}}async fetchBrand(e,t){let r=Be.Brand(this.config.env,e),n=t?this.cache.get(r):null;if(n)return Pe.info(`WarpRegistry (fetchBrand): Brand found in cache: ${e}`),n;let i=v(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:Rr(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=g.newFromBech32(b(this.config.env)),t=this.getController(),[r]=await t.query({contract:e,function:"getConfig",arguments:[]}),n=r?vt(r):null;this.registryConfig=n||{unitPrice:BigInt(0),admins:[]}}getFactory(){let e=new Mr({chainID:this.chain.chainId}),t=wt.create(Se);return new Or({config:e,abi:t})}getController(){let e=v(this.chain,this.config.env,this.config),t=wt.create(Se);return e.createSmartContractController(t)}isCurrentUserAdmin(){return!!this.userWallet&&this.registryConfig.admins.includes(this.userWallet)}};import{Account as Tt,Message as _r,Mnemonic as Wt,UserSecretKey as ie}from"@multiversx/sdk-core";import{CacheTtl as Gr,getWarpWalletAddressFromConfig as Hr,getWarpWalletPrivateKeyFromConfig as Ct,WarpCache as $r}from"@vleap/warps";var se=class{constructor(e,t){this.config=e;this.chain=t;this.entry=v(t,e.env,e),this.provider=this.entry.createNetworkProvider(),this.cache=new $r(e.cache?.type)}async signTransaction(e){if(!e||typeof e!="object")throw new Error("Invalid transaction object");let t=Ct(this.config,this.chain.name);if(!t)throw new Error("Wallet not initialized - no private key provided");let n=t.startsWith("-----")?ie.fromPem(t):ie.fromString(t),a=new Tt(n);if(e.nonce===0n){let c=await this.entry.recallAccountNonce(a.address),o=this.cache.get(`nonce:${a.address.toBech32()}`)||0,d=BigInt(Math.max(o,Number(c)));e.nonce=d}e.signature=await a.signTransaction(e);let i=Number(a.nonce)+1;return this.cache.set(`nonce:${a.address.toBech32()}`,i,Gr.OneMinute),e}async signTransactions(e){return Promise.all(e.map(async t=>this.signTransaction(t)))}async signMessage(e){let t=Ct(this.config,this.chain.name);if(!t)throw new Error("Wallet not initialized - no private key provided");let n=t.startsWith("-----")?ie.fromPem(t):ie.fromString(t),i=await new Tt(n).signMessage(new _r({data:Buffer.from(e)}));return Buffer.from(i).toString("hex")}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){let r=Wt.fromString(e).deriveKey(0),n=r.hex();return{address:r.generatePublicKey().toAddress(this.chain.addressHrp).toBech32(),privateKey:n,mnemonic:e}}generate(){let e=Wt.generate(),t=e.toString(),r=e.deriveKey(0),n=r.hex();return{address:r.generatePublicKey().toAddress(this.chain.addressHrp).toBech32(),privateKey:n,mnemonic:t}}getAddress(){return Hr(this.config,this.chain.name)}};var oe=(s,e)=>(t,r)=>{let n=e[t.env],a=new zr;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 $(t,n),executor:new te(t,n,a),output:new O(t,n,a),serializer:new P({typeRegistry:a}),registry:new ae(t,n),explorer:new re(s,t),abiBuilder:()=>new B(t,n),brandBuilder:()=>new H(t,n),dataLoader:new q(t,n),wallet:new se(t,n)}};var Ne={chain:D.Multiversx,identifier:"EGLD",name:"eGold",symbol:"EGLD",decimals:18,logoUrl:"https://vleap.ai/images/tokens/egld.svg"},xt=oe(D.Multiversx,{mainnet:{name:D.Multiversx,displayName:"MultiversX",chainId:"1",blockTime:6e3,addressHrp:"erd",defaultApiUrl:"https://api.multiversx.com",logoUrl:"https://vleap.ai/images/chains/multiversx.svg",nativeToken:Ne},testnet:{name:D.Multiversx,displayName:"MultiversX Testnet",chainId:"T",blockTime:6e3,addressHrp:"erd",defaultApiUrl:"https://testnet-api.multiversx.com",logoUrl:"https://vleap.ai/images/chains/multiversx.svg",nativeToken:Ne},devnet:{name:D.Multiversx,displayName:"MultiversX Devnet",chainId:"D",blockTime:6e3,addressHrp:"erd",defaultApiUrl:"https://devnet-api.multiversx.com",logoUrl:"https://vleap.ai/images/chains/multiversx.svg",nativeToken:Ne}});import{WarpChainName as Ue}from"@vleap/warps";var qr={chain:Ue.Vibechain,identifier:"VIBE",name:"VIBE",symbol:"VIBE",decimals:18,logoUrl:"https://vleap.ai/images/tokens/vibe.svg"},Ve={name:Ue.Vibechain,displayName:"VibeChain",chainId:"V",blockTime:600,addressHrp:"vibe",defaultApiUrl:"https://vibeox-api.multiversx.com",logoUrl:"https://vleap.ai/images/chains/vibechain.svg",nativeToken:qr},At=oe(Ue.Vibechain,{mainnet:Ve,testnet:Ve,devnet:Ve});var Xs=(s,e)=>[xt(s,e),At(s,e)],Js=()=>[Et.Multiversx,Et.Vibechain];import{WarpConstants as ce,WarpSerializer as ke}from"@vleap/warps";var lo=s=>new ke().nativeToString(f.Token,s),uo=s=>new ke().nativeToString(f.CodeMeta,s),mo=(s,e)=>{if(e===null)return f.Optional+ce.ArgParamsSeparator;let t=s(e),r=t.indexOf(ce.ArgParamsSeparator),n=t.substring(0,r),a=t.substring(r+1);return f.Optional+ce.ArgParamsSeparator+n+ce.ArgParamsSeparator+a},ho=s=>new ke().nativeToString(f.List,s);import{Address as Kr,AddressValue as Qr,BigUIntType as jr,BigUIntValue as bt,BooleanValue as Xr,BytesValue as Jr,CodeMetadata as Yr,CodeMetadataValue as Zr,CompositeType as en,CompositeValue as tn,Field as Fe,FieldDefinition as Oe,List as rn,NothingValue as nn,OptionalValue as Me,OptionValue as Re,StringValue as an,Struct as sn,StructType as on,TokenIdentifierType as cn,TokenIdentifierValue as St,U16Value as pn,U32Value as ln,U64Type as un,U64Value as It,U8Value as mn,VariadicValue as dn}from"@multiversx/sdk-core";var To=(s,e)=>s?Re.newProvided(s):e?Re.newMissingTyped(e):Re.newMissing(),Wo=(s,e)=>s?new Me(s.getType(),s):e?new Me(e):Me.newMissing(),Co=s=>{if(s.length===0)throw new Error("Cannot create a list from an empty array");let e=s[0].getType();return new rn(e,s)},xo=s=>dn.fromItems(...s),Ao=s=>{let e=s.map(t=>t.getType());return new tn(new en(...e),s)},Eo=s=>an.fromUTF8(s),bo=s=>new mn(s),So=s=>new pn(s),Io=s=>new ln(s),Bo=s=>new It(s),Po=s=>new bt(BigInt(s)),No=s=>new Xr(s),Vo=s=>new Qr(Kr.newFromBech32(s)),Uo=s=>new St(s),ko=s=>Jr.fromHex(s),Fo=s=>new sn(new on("EsdtTokenPayment",[new Oe("token_identifier","",new cn),new Oe("token_nonce","",new un),new Oe("amount","",new jr)]),[new Fe(new St(s.token.identifier),"token_identifier"),new Fe(new It(BigInt(s.token.nonce)),"token_nonce"),new Fe(new bt(BigInt(s.amount)),"amount")]),Oo=s=>new Zr(Yr.newFromBytes(Uint8Array.from(Buffer.from(s,"hex")))),Mo=()=>new nn;export{U as ExplorerUrls,Ye as KnownTokens,lr as MultiversxExplorers,et as MultiversxExplorersConfig,Ne as NativeTokenEgld,qr as NativeTokenVibe,ur as VibechainExplorers,B as WarpMultiversxAbiBuilder,H as WarpMultiversxBrandBuilder,$ as WarpMultiversxBuilder,qa as WarpMultiversxConstants,G as WarpMultiversxContractLoader,q as WarpMultiversxDataLoader,te as WarpMultiversxExecutor,re as WarpMultiversxExplorer,f as WarpMultiversxInputTypes,O as WarpMultiversxOutput,ae as WarpMultiversxRegistry,P as WarpMultiversxSerializer,se as WarpMultiversxWallet,Vo as address_value,Fo as asset_value,Po as biguint_value,No as boolean_value,uo as codemeta,Oo as codemeta_value,Ao as composite_value,oe as createMultiversxAdapter,Ze as findKnownTokenById,Xs as getAllMultiversxAdapters,Js as getAllMultiversxChainNames,Ba as getKnownTokensForChain,xt as getMultiversxAdapter,v as getMultiversxEntrypoint,b as getMultiversxRegistryAddress,_ as getNormalizedTokenIdentifier,At as getVibechainAdapter,ko as hex_value,F as isNativeToken,ho as list,Co as list_value,Mo as nothing_value,To as option_value,mo as optional,Wo as optional_value,Eo as string_value,vt as toTypedConfigInfo,ne as toTypedRegistryInfo,lo as token,Uo as token_value,So as u16_value,Io as u32_value,Bo as u64_value,bo as u8_value,xo as variadic_value};
1
+ import{WarpChainName as Et}from"@vleap/warps";import{WarpChainName as _}from"@vleap/warps";import{WarpTypeRegistry as Kr}from"@vleap/warps";import{AbiRegistry as pe,Address as kt,TransactionsFactoryConfig as Ft,TransferTransactionsFactory as Ot}from"@multiversx/sdk-core";import{createWarpIdentifier as Mt,getLatestProtocolIdentifier as Rt,getWarpWalletAddressFromConfig as Lt,WarpCache as Dt,WarpCacheKey as _t,WarpConstants as _e,WarpLogger as Ge}from"@vleap/warps";import{DevnetEntrypoint as Pt,MainnetEntrypoint as Nt,TestnetEntrypoint as Vt}from"@multiversx/sdk-core";import{getProviderConfig as Ut}from"@vleap/warps";var F=s=>!s.includes("-"),G=s=>F(s)?`${s}-000000`:s,v=(s,e,t)=>{let r="warp-sdk",a=t?Ut(t,s.name,e,s.defaultApiUrl):{url:s.defaultApiUrl},i=a.url,c={headers:a.headers};return e==="devnet"?new Pt({url:i,kind:"api",clientName:r,networkProviderConfig:c}):e==="testnet"?new Vt({url:i,kind:"api",clientName:r,networkProviderConfig:c}):new Nt({url:i,kind:"api",clientName:r,networkProviderConfig:c})};import{WarpLogger as De}from"@vleap/warps";var H=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 De.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 De.error("WarpContractLoader: getVerificationInfo error",r),null}}};var B=class{constructor(e,t){this.config=e;this.chain=t;this.contractLoader=new H(this.config),this.cache=new Dt(this.config.cache?.type)}async createInscriptionTransaction(e){let t=Lt(this.config,this.chain.name);if(!t)throw new Error("WarpBuilder: user address not set");let r=new Ft({chainID:this.chain.chainId}),n=new Ot({config:r}),a=kt.newFromBech32(t),i={protocol:Rt("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:Mt(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=_t.WarpAbi(this.config.env,e);if(t){let i=this.cache.get(r);if(i)return Ge.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),c=await this.createFromTransaction(i);return t&&t.ttl&&c&&this.cache.set(r,c,t.ttl),c}catch(i){return Ge.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 pe.create(t.abi)}async fetchAbi(e){if(!e.abi)throw new Error("WarpActionExecutor: ABI not found");if(e.abi.startsWith(_e.IdentifierType.Hash)){let t=e.abi.split(_e.ArgParamsSeparator)[1],r=await this.createFromTransactionHash(t);if(!r)throw new Error(`WarpActionExecutor: ABI not found for hash: ${e.abi}`);return pe.create(r.content)}else{let r=await(await fetch(e.abi)).json();return pe.create(r)}}};import{Address as He,TransactionsFactoryConfig as Gt,TransferTransactionsFactory as Ht}from"@multiversx/sdk-core";import{createWarpIdentifier as $t,getWarpWalletAddressFromConfig as Kt,WarpBrandBuilder as zt,WarpLogger as qt}from"@vleap/warps";import{Buffer as Qt}from"buffer";var $=class{constructor(e,t){this.config=e;this.chain=t;this.core=new zt(e)}async createInscriptionTransaction(e){let t=Kt(this.config,this.chain.name);if(!t)throw new Error("BrandBuilder: user address not set");let r=new Gt({chainID:this.chain.chainId}),n=new Ht({config:r}),a=He.newFromBech32(t),i=JSON.stringify(e);return await n.createTransactionForNativeTokenTransfer(a,{receiver:He.newFromBech32(t),nativeAmount:BigInt(0),data:Uint8Array.from(Qt.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:$t(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 qt.error("BrandBuilder: Error creating from transaction hash",n),null}}};import{Address as $e,TransactionsFactoryConfig as jt,TransferTransactionsFactory as Xt}from"@multiversx/sdk-core";import{createWarpIdentifier as Jt,getWarpWalletAddressFromConfig as Yt,WarpBuilder as Ke,WarpCache as Zt,WarpCacheKey as er,WarpLogger as ze}from"@vleap/warps";var K=class extends Ke{constructor(t,r){super(t);this.config=t;this.chain=r;this.cache=new Zt(t.cache?.type),this.core=new Ke(t)}async createInscriptionTransaction(t){let r=Yt(this.config,this.chain.name);if(!r)throw new Error("WarpBuilder: user address not set");let n=new jt({chainID:this.chain.chainId}),a=new Xt({config:n}),i=$e.newFromBech32(r),c=JSON.stringify(t),o=await a.createTransactionForTransfer(i,{receiver:$e.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:Jt(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=er.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=v(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 le,Token as ir,TokenComputer as sr}from"@multiversx/sdk-core";import{CacheTtl as or,WarpCache as cr,WarpCacheKey as pr}from"@vleap/warps";import{WarpChainName as tr}from"@vleap/warps";var qe=tr.Multiversx,Qe=[{chain:qe,identifier:"EGLD",name:"eGold",symbol:"EGLD",decimals:18,logoUrl:"https://tools.multiversx.com/assets-cdn/tokens/EGLD-000000/icon.png"},{chain:qe,identifier:"EGLD-000000",name:"eGold",symbol:"EGLD",decimals:18,logoUrl:"https://tools.multiversx.com/assets-cdn/tokens/EGLD-000000/icon.png"}];import{WarpChainName as rr}from"@vleap/warps";var A=rr.Multiversx,je=[{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 nr}from"@vleap/warps";var Xe=nr.Multiversx,Je=[{chain:Xe,identifier:"EGLD",name:"eGold",symbol:"EGLD",decimals:18,logoUrl:"https://tools.multiversx.com/assets-cdn/tokens/EGLD-000000/icon.png"},{chain:Xe,identifier:"EGLD-000000",name:"eGold",symbol:"EGLD",decimals:18,logoUrl:"https://tools.multiversx.com/assets-cdn/tokens/EGLD-000000/icon.png"}];import{WarpChainName as ar}from"@vleap/warps";var Ye=ar.Vibechain,z=[{chain:Ye,identifier:"VIBE",name:"VIBE",symbol:"VIBE",decimals:18,logoUrl:"https://vleap.ai/images/tokens/vibe.svg"},{chain:Ye,identifier:"VIBE-000000",name:"VIBE",symbol:"VIBE",decimals:18,logoUrl:"https://vleap.ai/images/tokens/vibe.svg"}];var Ze={multiversx:{mainnet:je,testnet:Je,devnet:Qe},vibechain:{mainnet:z,testnet:z,devnet:z}},et=(s,e,t)=>(Ze[s]?.[e]||[]).find(n=>n.identifier===t)||null,Ba=(s,e)=>Ze[s]?.[e]||[];var q=class{constructor(e,t){this.config=e;this.chain=t;this.cache=new cr(e.cache?.type)}async getAccount(e){let r=await v(this.chain,this.config.env,this.config).createNetworkProvider().getAccount(le.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(le.newFromBech32(e)),n=t.getFungibleTokensOfAccount(le.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=pr.Asset(this.config.env,this.chain.name,e),r=this.cache.get(t);if(r)return r;let n=et(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 sr,i=F(e)?0n:a.extractNonceFromExtendedIdentifier(e),c=new ir({identifier:e,nonce:BigInt(i||0)}),o=a.isFungible(c),d=v(this.chain,this.config.env,this.config).createNetworkProvider(),m=G(e),l=await d.doGetGeneric(`tokens/${m}`),y={chain:this.chain.name,identifier:c.identifier,name:l.name,symbol:l.ticker,amount:0n,decimals:l.decimals,logoUrl:l.assets?.pngUrl||null,price:l.price?Number(l.price):void 0,supply:l.supply?BigInt(l.supply):void 0};return this.cache.set(t,y,or.OneHour),y}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,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 D,ArgSerializer as br,SmartContractTransactionsFactory as Sr,Token as Ir,TokenComputer as Br,TokenTransfer as Pr,TransactionsFactoryConfig as vt,TransferTransactionsFactory as Nr}from"@multiversx/sdk-core";import{applyOutputToMessages as Vr,getNextInfo as Ur,getWarpActionByIndex as Ee,getWarpWalletAddressFromConfig as be}from"@vleap/warps";import{findEventsByFirstTopic as yr,SmartContractTransactionsOutcomeParser as vr,TransactionEventsParser as wr}from"@multiversx/sdk-core";import{applyOutputToMessages as Tr,evaluateOutputCommon as te,getNextInfo as Wr,getWarpActionByIndex as Cr,getWarpWalletAddressFromConfig as xr,parseOutputOutIndex as gt,WarpCache as Ar,WarpCacheKey as Er,WarpConstants as yt}from"@vleap/warps";import{Address as mr,AddressType as ue,AddressValue as rt,BigUIntType as Q,BigUIntValue as me,BooleanType as de,BooleanValue as nt,BytesType as he,BytesValue as at,CodeMetadata as dr,CodeMetadataType as fe,CodeMetadataValue as it,CompositeType as ge,CompositeValue as st,Field as j,FieldDefinition as X,List as ot,ListType as ct,NothingValue as S,OptionalType as pt,OptionalValue as ye,OptionType as lt,OptionValue as ve,StringType as we,StringValue as ut,Struct as J,StructType as k,Token as hr,TokenComputer as mt,TokenIdentifierType as Y,TokenIdentifierValue as Te,U16Type as We,U16Value as dt,U32Type as Ce,U32Value as ht,U64Type as Z,U64Value as xe,U8Type as Ae,U8Value as ft,VariadicType as L,VariadicValue as ee}from"@multiversx/sdk-core";import{WarpSerializer as fr}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"}},p={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 za={Egld:{Identifier:"EGLD",EsdtIdentifier:"EGLD-000000",DisplayName:"eGold",Decimals:18}},f={Null:"null",Optional:"optional",List:"list",Token:"token",CodeMeta:"codemeta"},lr=(r=>(r.MultiversxExplorer="multiversx_explorer",r.MultiversxExplorerDevnet="multiversx_explorer_devnet",r.MultiversxExplorerTestnet="multiversx_explorer_testnet",r))(lr||{}),ur=(r=>(r.VibechainExplorer="vibechain_explorer",r.VibechainExplorerDevnet="vibechain_explorer_devnet",r.VibechainExplorerTestnet="vibechain_explorer_testnet",r))(ur||{}),tt={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 gr=new RegExp(`${u.ArgParamsSeparator}(.*)`),P=class{constructor(e){this.coreSerializer=new fr(e)}typedToString(e){let t=e.getType();if(t.hasExactClass(lt.ClassName)||e.hasClassOrSuperclass(ve.ClassName)){if(!e.isSet())return p.Option+u.ArgParamsSeparator+"null";let r=this.typedToString(e.getTypedValue());return p.Option+u.ArgParamsSeparator+r}if(t.hasExactClass(L.ClassName)||e.hasClassOrSuperclass(ee.ClassName)){let r=e.getItems();if(r.length===0){let m=this.typeToString(t.getFirstTypeParameter());return p.Vector+u.ArgParamsSeparator+m+u.ArgParamsSeparator}let n=r.map(m=>this.typedToString(m));if(n.every(m=>m.startsWith(p.Tuple)))return p.Vector+u.ArgParamsSeparator+n.join(",");let a=n[0],i=a.indexOf(u.ArgParamsSeparator),c=a.substring(0,i),o=n.map(m=>{let l=m.indexOf(u.ArgParamsSeparator);return m.substring(l+1)}),d=c.startsWith(p.Struct)?u.ArgStructSeparator:u.ArgListSeparator;return p.Vector+u.ArgParamsSeparator+c+u.ArgParamsSeparator+o.join(d)}if(t.hasExactClass(pt.ClassName)||e.hasClassOrSuperclass(ye.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(ct.ClassName)||e.hasClassOrSuperclass(ot.ClassName)){let n=e.getItems().map(o=>this.typedToString(o));if(n.every(o=>o.startsWith(p.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(ge.ClassName)||e.hasClassOrSuperclass(st.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`${p.Tuple}(${n.join(",")})`}if(t.hasExactClass(Q.ClassName)||e.hasClassOrSuperclass(me.ClassName)||t.getName()==="BigUint")return p.Biguint+u.ArgParamsSeparator+BigInt(e.valueOf().toFixed());if(t.hasExactClass(Ae.ClassName)||e.hasClassOrSuperclass(ft.ClassName))return p.Uint8+u.ArgParamsSeparator+e.valueOf().toNumber();if(t.hasExactClass(We.ClassName)||e.hasClassOrSuperclass(dt.ClassName))return p.Uint16+u.ArgParamsSeparator+e.valueOf().toNumber();if(t.hasExactClass(Ce.ClassName)||e.hasClassOrSuperclass(ht.ClassName))return p.Uint32+u.ArgParamsSeparator+e.valueOf().toNumber();if(t.hasExactClass(Z.ClassName)||e.hasClassOrSuperclass(xe.ClassName))return p.Uint64+u.ArgParamsSeparator+BigInt(e.valueOf().toFixed());if(t.hasExactClass(we.ClassName)||e.hasClassOrSuperclass(ut.ClassName))return p.String+u.ArgParamsSeparator+e.valueOf();if(t.hasExactClass(de.ClassName)||e.hasClassOrSuperclass(nt.ClassName))return p.Bool+u.ArgParamsSeparator+e.valueOf();if(t.hasExactClass(ue.ClassName)||e.hasClassOrSuperclass(rt.ClassName))return p.Address+u.ArgParamsSeparator+e.valueOf().toBech32();if(t.hasExactClass(he.ClassName)||e.hasClassOrSuperclass(at.ClassName))return p.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 mt().computeExtendedIdentifier(new hr({identifier:r,nonce:BigInt(n)}));return p.Asset+u.ArgParamsSeparator+c+u.ArgCompositeSeparator+a}if(t.hasExactClass(k.ClassName)||e.hasClassOrSuperclass(J.ClassName)){let r=e,a=r.getType().getName(),i=r.getFields();if(i.length===0)return`${p.Struct}(${a})${u.ArgParamsSeparator}`;let c=i.map(o=>{let d=o.value.getType(),l=this.typedToString(o.value).split(u.ArgParamsSeparator),y=l.length>2?l.slice(2).join(u.ArgParamsSeparator):l[1]||"";return`(${o.name}${u.ArgParamsSeparator}${this.typeToString(d)})${y}`});return`${p.Struct}(${a})${u.ArgParamsSeparator}${c.join(u.ArgListSeparator)}`}if(t.hasExactClass(Y.ClassName)||e.hasClassOrSuperclass(Te.ClassName))return f.Token+u.ArgParamsSeparator+e.valueOf();if(t.hasExactClass(fe.ClassName)||e.hasClassOrSuperclass(it.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(p.Tuple))return this.stringToTyped(e+":");let r=this.coreSerializer.nativeToString(e,t);return this.stringToTyped(r)}nativeToType(e){if(e.startsWith(p.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 ge(...n.map(a=>this.nativeToType(a)))}if(e.startsWith(p.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===p.String)return new we;if(e===p.Uint8)return new Ae;if(e===p.Uint16)return new We;if(e===p.Uint32)return new Ce;if(e===p.Uint64)return new Z;if(e===p.Biguint)return new Q;if(e===p.Bool)return new de;if(e===p.Address)return new ue;if(e===p.Hex)return new he;if(e===p.Asset)return new k("EsdtTokenPayment",[new X("token_identifier","",new Y),new X("token_nonce","",new Z),new X("amount","",new Q)]);if(e===f.Token)return new Y;if(e===f.CodeMeta)return new fe;throw new Error(`WarpArgSerializer (nativeToType): Unsupported input type: ${e}`)}stringToTyped(e){let[t,r]=e.split(/:(.*)/,2);if(t===p.Option){let n=this.stringToTyped(r);return n instanceof S?ve.newMissingTyped(n.getType()):ve.newProvided(n)}if(t===p.Vector){let n=r.indexOf(u.ArgParamsSeparator),a=r.substring(0,n),i=r.substring(n+1);if(a.startsWith(p.Tuple)){let l=i.split(",").map(y=>this.stringToTyped(y));return new ee(new L(this.nativeToType(a)),l)}if(i.includes("tuple(")){let m=this.splitTupleStrings(i),l=m.map(T=>this.stringToTyped(T)),C=m[0].match(/^(tuple\([^)]+\))/),h=C?C[1]:"tuple";return new ee(new L(this.nativeToType(h)),l)}let c=a.startsWith(p.Struct)?u.ArgStructSeparator:u.ArgListSeparator,d=i.split(c).map(m=>this.stringToTyped(`${a}:${m}`));return new ee(new L(this.nativeToType(a)),d)}if(t.startsWith(p.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 st(new ge(...c),i)}if(t.startsWith(p.Struct)){let n=t.match(/\(([^)]+)\)/),a=n?n[1]:"CustomStruct";if(!r)return new J(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[,l,y,C]=m,h=this.stringToTyped(`${y}${u.ArgParamsSeparator}${C}`);c.push(new X(l,"",h.getType())),o.push(new j(h,l))}}),new J(new k(a,c),o)}if(t===p.String)return r?ut.fromUTF8(r):new S;if(t===p.Uint8)return r?new ft(Number(r)):new S;if(t===p.Uint16)return r?new dt(Number(r)):new S;if(t===p.Uint32)return r?new ht(Number(r)):new S;if(t===p.Uint64)return r?new xe(BigInt(r)):new S;if(t===p.Biguint)return r?new me(BigInt(r)):new S;if(t===p.Bool)return r?new nt(typeof r=="boolean"?r:r==="true"):new S;if(t===p.Address)return r?new rt(mr.newFromBech32(r)):new S;if(t===p.Hex)return r?at.fromHex(r):new S;if(t===p.Asset){let[n,a]=r.split(u.ArgCompositeSeparator),i=new mt,c=F(n)?G(n):i.extractIdentifierFromExtendedIdentifier(n),o=F(n)?0n:i.extractNonceFromExtendedIdentifier(n);return new J(this.nativeToType("asset"),[new j(new Te(c),"token_identifier"),new j(new xe(BigInt(o)),"token_nonce"),new j(new me(BigInt(a)),"amount")])}if(t===f.Null)return new S;if(t===f.Optional){let n=this.stringToTyped(r);return n instanceof S?ye.newMissing():new ye(n.getType(),n)}if(t===f.List){let[n,a]=r.split(gr,2),c=a.split(u.ArgListSeparator).map(o=>this.stringToTyped(n+u.ArgParamsSeparator+o));return new ot(this.nativeToType(n),c)}if(t===f.Token)return r?new Te(r):new S;if(t===f.CodeMeta)return new it(dr.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(lt.ClassName))return p.Option+u.ArgParamsSeparator+this.typeToString(e.getFirstTypeParameter());if(e.hasExactClass(L.ClassName))return p.Vector+u.ArgParamsSeparator+this.typeToString(e.getFirstTypeParameter());if(e.hasExactClass(we.ClassName))return p.String;if(e.hasExactClass(Ae.ClassName))return p.Uint8;if(e.hasExactClass(We.ClassName))return p.Uint16;if(e.hasExactClass(Ce.ClassName))return p.Uint32;if(e.hasExactClass(Z.ClassName))return p.Uint64;if(e.hasExactClass(Q.ClassName))return p.Biguint;if(e.hasExactClass(de.ClassName))return p.Bool;if(e.hasExactClass(ue.ClassName))return p.Address;if(e.hasExactClass(he.ClassName))return p.Hex;if(e.hasExactClass(Y.ClassName))return f.Token;if(e.hasExactClass(pt.ClassName))return f.Optional+u.ArgParamsSeparator+this.typeToString(e.getFirstTypeParameter());if(e.hasExactClass(ct.ClassName))return f.List+u.ArgParamsSeparator+this.typeToString(e.getFirstTypeParameter());if(e.hasExactClass(fe.ClassName))return f.CodeMeta;if(e.hasExactClass(k.ClassName)&&e.getClassName()==="EsdtTokenPayment")return p.Asset;if(e.hasExactClass(k.ClassName))return`${p.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 B(e,t),this.serializer=new P({typeRegistry:this.typeRegistry}),this.cache=new Ar(e.cache?.type)}async getActionExecution(e,t,r){let n=this.cache.get(Er.WarpExecutable(this.config.env,e.meta?.hash||"",t))??[],a=await this.extractContractOutput(e,t,r,n),i=Wr(this.config,[],e,t,a.output),c=Tr(e,a.output,this.config);return{status:r.status.isSuccessful()?"success":"error",warp:e,action:t,user:xr(this.config,this.chain.name),txHash:r.hash,tx:r,next:i,values:a.values,output:a.output,messages:c,destination:null}}async extractContractOutput(e,t,r,n){let a=Cr(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 te(e,o,t,n,this.serializer.coreSerializer,this.config)}}let m=await this.abi.getAbiForAction(a),l=new wr({abi:m}),C=new vr({abi:m}).parseExecute({transactionOnNetwork:r,function:a.func||void 0});for(let[h,T]of Object.entries(e.output)){if(T.startsWith(yt.Transform.Prefix))continue;if(T.startsWith("input.")){o[h]=T;continue}let E=gt(T);if(E!==null&&E!==t){o[h]=null;continue}let[I,N,V]=T.split(".");if(I==="event"){if(!N||isNaN(Number(V)))continue;let x=Number(V),W=yr(r,N),Bt=l.parseEvents({events:W})[0],R=Object.values(Bt)[x]||null;i.push(String(R)),c.push(R),o[h]=R&&R.valueOf()}else if(I==="out"||I.startsWith("out[")){if(!N)continue;let x=Number(N),W=C.values[x-1]||null;V&&(W=W[V]||null),W&&typeof W=="object"&&(W="toFixed"in W?W.toFixed():W.valueOf()),i.push(String(W)),c.push(W),o[h]=W&&W.valueOf()}else o[h]=T}return{values:{string:i,native:c,mapped:{}},output:await te(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 l=m.split(".").slice(1).map(C=>parseInt(C)-1);if(l.length===0)return;let y=i[l[0]];for(let C=1;C<l.length;C++){if(y==null)return;y=y[l[C]]}return y};for(let[m,l]of Object.entries(e.output)){if(l.startsWith(yt.Transform.Prefix))continue;let y=gt(l);if(y!==null&&y!==r){o[m]=null;continue}l.startsWith("out.")||l==="out"||l.startsWith("out[")?o[m]=d(l)||null:o[m]=l}return o=await te(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 E=t.actions[h-1];if(!E)throw new Error(`Action ${h} not found`);let I;if(E.type==="query")I=await n.executeQuery(t,h,T);else if(E.type==="collect")I=await n.executeCollect(t,h,T,i);else throw new Error(`Unsupported or interactive action type: ${E.type}`);if(c.set(h,I),t.output)for(let N of Object.values(t.output)){let x=String(N).match(/^out\[(\d+)\]/);if(x){let W=parseInt(x[1],10);W!==h&&!c.has(W)&&await m(W)}}return o.delete(h),I}await m(r,a);let l={};for(let h of c.values())for(let[T,E]of Object.entries(h.output))E!==null?l[T]=E:T in l||(l[T]=null);let y=await te(t,l,r,a,this.serializer.coreSerializer,this.config);return{...c.get(r),action:r,output:y}}};var kr="EGLD-000000",re=class{constructor(e,t,r){this.config=e;this.chain=t;this.typeRegistry=r;this.serializer=new P({typeRegistry:this.typeRegistry}),this.abi=new B(this.config,this.chain),this.output=new O(this.config,this.chain,this.typeRegistry)}async createTransaction(e){let t=Ee(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=D.newFromBech32(t),n=new vt({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 Nr({config:n}).createTransactionForTransfer(r,{receiver:D.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=Ee(e.warp,e.action),n=D.newFromBech32(t),a=e.args.map(c=>this.serializer.stringToTyped(c)),i=new vt({chainID:e.chain.chainId});return new Sr({config:i}).createTransactionForExecute(n,{contract:D.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=Ee(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(x=>this.serializer.stringToTyped(x)),a=v(e.chain,this.config.env,this.config),i=D.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",l=new br,y=r.getEndpoint(d.function||t.func||""),C=(d.returnDataParts||[]).map(x=>Buffer.from(x)),h=l.buffersToValues(C,y.output),{values:T,output:E}=await this.output.extractQueryOutput(e.warp,h,e.action,e.resolvedInputs),I=Ur(this.config,[],e.warp,e.action,E),V=e.resolvedInputs.find(x=>x.input.position==="receiver"||x.input.position==="destination")?.value||e.destination;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:{...E,_DATA:h},messages:Vr(e.warp,E,this.config),destination:V}}toTokenTransfers(e){return e.map(t=>t.identifier===this.chain.nativeToken.identifier?{...t,identifier:kr}:t).map(t=>{let n=new Br().extractNonceFromExtendedIdentifier(t.identifier);return new Pr({token:new Ir({identifier:t.identifier,nonce:BigInt(n||0)}),amount:t.amount})})}};var ne=class{constructor(e,t){this.chain=e;this.config=t}getExplorers(){let e=tt[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 Tt,Address as g,AddressValue as Ie,BytesValue as w,SmartContractTransactionsFactory as Or,TransactionsFactoryConfig as Mr}from"@multiversx/sdk-core";import{createWarpIdentifier as Rr,getWarpWalletAddressFromConfig as Lr,WarpCache as Dr,WarpCacheKey as Be,WarpLogger as Pe}from"@vleap/warps";var Se={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 b=s=>{if(s==="devnet")return"erd1qqqqqqqqqqqqqpgqje2f99vr6r7sk54thg03c9suzcvwr4nfl3tsfkdl36";if(s==="testnet")throw new Error("Multiversx testnet is not supported");return"erd1qqqqqqqqqqqqqpgq3mrpj3u6q7tejv6d7eqhnyd27n9v5c5tl3ts08mffe"};var ae=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}),wt=s=>({unitPrice:BigInt(s.unit_price.toString()),admins:s.admins.map(e=>e.toBech32())});var ie=class{constructor(e,t){this.config=e;this.chain=t;this.cache=new Dr(e.cache?.type),this.registryConfig={unitPrice:BigInt(0),admins:[]},this.userWallet=Lr(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=g.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:g.newFromBech32(b(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=g.newFromBech32(this.userWallet);return await this.getFactory().createTransactionForExecute(t,{contract:g.newFromBech32(b(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=g.newFromBech32(this.userWallet);return await this.getFactory().createTransactionForExecute(n,{contract:g.newFromBech32(b(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=g.newFromBech32(this.userWallet);return await this.getFactory().createTransactionForExecute(r,{contract:g.newFromBech32(b(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=g.newFromBech32(this.userWallet);return await this.getFactory().createTransactionForExecute(t,{contract:g.newFromBech32(b(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=g.newFromBech32(this.userWallet);return await this.getFactory().createTransactionForExecute(r,{contract:g.newFromBech32(b(this.config.env)),function:"transferOwnership",gasLimit:BigInt(1e7),arguments:[w.fromHex(e),new Ie(new g(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=g.newFromBech32(this.userWallet);return await this.getFactory().createTransactionForExecute(t,{contract:g.newFromBech32(b(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=g.newFromBech32(this.userWallet);return await this.getFactory().createTransactionForExecute(r,{contract:g.newFromBech32(b(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=Be.RegistryInfo(this.config.env,e),n=t?this.cache.get(r):null;if(n)return Pe.info(`WarpRegistry (getInfoByAlias): RegistryInfo found in cache: ${e}`),n;let a=g.newFromBech32(b(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?ae(d):null,l=m?.brand?await this.fetchBrand(m.brand):null;return t&&t.ttl&&this.cache.set(r,{registryInfo:m,brand:l},t.ttl),{registryInfo:m,brand:l}}catch{return{registryInfo:null,brand:null}}}async getInfoByHash(e,t){try{let r=Be.RegistryInfo(this.config.env,e);if(t){let l=this.cache.get(r);if(l)return Pe.info(`WarpRegistry (getInfoByHash): RegistryInfo found in cache: ${e}`),l}let n=g.newFromBech32(b(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?ae(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=g.newFromBech32(b(this.config.env)),n=this.getController(),a=n.createQuery({contract:r,function:"getUserWarps",arguments:[new Ie(new g(t))]}),i=await n.runQuery(a),[c]=n.parseQueryResponse(i);return c.map(ae)}catch{return[]}}async getUserBrands(e){try{let t=e||this.userWallet;if(!t)throw new Error("WarpRegistry: user address not set");let r=g.newFromBech32(b(this.config.env)),n=this.getController(),a=n.createQuery({contract:r,function:"getUserBrands",arguments:[new Ie(new g(t))]}),i=await n.runQuery(a),[c]=n.parseQueryResponse(i),o=c.map(l=>l.toString("hex")),d={ttl:365*24*60*60};return(await Promise.all(o.map(l=>this.fetchBrand(l,d)))).filter(l=>l!==null)}catch{return[]}}async fetchBrand(e,t){let r=Be.Brand(this.config.env,e),n=t?this.cache.get(r):null;if(n)return Pe.info(`WarpRegistry (fetchBrand): Brand found in cache: ${e}`),n;let i=v(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:Rr(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=g.newFromBech32(b(this.config.env)),t=this.getController(),[r]=await t.query({contract:e,function:"getConfig",arguments:[]}),n=r?wt(r):null;this.registryConfig=n||{unitPrice:BigInt(0),admins:[]}}getFactory(){let e=new Mr({chainID:this.chain.chainId}),t=Tt.create(Se);return new Or({config:e,abi:t})}getController(){let e=v(this.chain,this.config.env,this.config),t=Tt.create(Se);return e.createSmartContractController(t)}isCurrentUserAdmin(){return!!this.userWallet&&this.registryConfig.admins.includes(this.userWallet)}};import{Account as Wt,Message as _r,Mnemonic as Ct,UserSecretKey as M}from"@multiversx/sdk-core";import{CacheTtl as Gr,getWarpWalletAddressFromConfig as Hr,getWarpWalletPrivateKeyFromConfig as Ne,WarpCache as $r}from"@vleap/warps";var se=class{constructor(e,t){this.config=e;this.chain=t;this.entry=v(t,e.env,e),this.provider=this.entry.createNetworkProvider(),this.cache=new $r(e.cache?.type)}async signTransaction(e){if(!e||typeof e!="object")throw new Error("Invalid transaction object");let t=Ne(this.config,this.chain.name);if(!t)throw new Error("Wallet not initialized - no private key provided");let n=t.startsWith("-----")?M.fromPem(t):M.fromString(t),a=new Wt(n);if(e.nonce===0n){let c=await this.entry.recallAccountNonce(a.address),o=this.cache.get(`nonce:${a.address.toBech32()}`)||0,d=BigInt(Math.max(o,Number(c)));e.nonce=d}e.signature=await a.signTransaction(e);let i=Number(a.nonce)+1;return this.cache.set(`nonce:${a.address.toBech32()}`,i,Gr.OneMinute),e}async signTransactions(e){return Promise.all(e.map(async t=>this.signTransaction(t)))}async signMessage(e){let t=Ne(this.config,this.chain.name);if(!t)throw new Error("Wallet not initialized - no private key provided");let n=t.startsWith("-----")?M.fromPem(t):M.fromString(t),i=await new Wt(n).signMessage(new _r({data:Buffer.from(e)}));return Buffer.from(i).toString("hex")}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){let r=Ct.fromString(e).deriveKey(0),n=r.hex();return{address:r.generatePublicKey().toAddress(this.chain.addressHrp).toBech32(),privateKey:n,mnemonic:e}}generate(){let e=Ct.generate(),t=e.toString(),r=e.deriveKey(0),n=r.hex();return{address:r.generatePublicKey().toAddress(this.chain.addressHrp).toBech32(),privateKey:n,mnemonic:t}}getAddress(){return Hr(this.config,this.chain.name)}getPublicKey(){let e=Ne(this.config,this.chain.name);return e?(e.startsWith("-----")?M.fromPem(e):M.fromString(e)).generatePublicKey().hex():null}};var oe=(s,e)=>(t,r)=>{let n=e[t.env],a=new Kr;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 K(t,n),executor:new re(t,n,a),output:new O(t,n,a),serializer:new P({typeRegistry:a}),registry:new ie(t,n),explorer:new ne(s,t),abiBuilder:()=>new B(t,n),brandBuilder:()=>new $(t,n),dataLoader:new q(t,n),wallet:new se(t,n)}};var Ve={chain:_.Multiversx,identifier:"EGLD",name:"eGold",symbol:"EGLD",decimals:18,logoUrl:"https://vleap.ai/images/tokens/egld.svg"},xt=oe(_.Multiversx,{mainnet:{name:_.Multiversx,displayName:"MultiversX",chainId:"1",blockTime:6e3,addressHrp:"erd",defaultApiUrl:"https://api.multiversx.com",logoUrl:"https://vleap.ai/images/chains/multiversx.svg",nativeToken:Ve},testnet:{name:_.Multiversx,displayName:"MultiversX Testnet",chainId:"T",blockTime:6e3,addressHrp:"erd",defaultApiUrl:"https://testnet-api.multiversx.com",logoUrl:"https://vleap.ai/images/chains/multiversx.svg",nativeToken:Ve},devnet:{name:_.Multiversx,displayName:"MultiversX Devnet",chainId:"D",blockTime:6e3,addressHrp:"erd",defaultApiUrl:"https://devnet-api.multiversx.com",logoUrl:"https://vleap.ai/images/chains/multiversx.svg",nativeToken:Ve}});import{WarpChainName as ke}from"@vleap/warps";var zr={chain:ke.Vibechain,identifier:"VIBE",name:"VIBE",symbol:"VIBE",decimals:18,logoUrl:"https://vleap.ai/images/tokens/vibe.svg"},Ue={name:ke.Vibechain,displayName:"VibeChain",chainId:"V",blockTime:600,addressHrp:"vibe",defaultApiUrl:"https://vibeox-api.multiversx.com",logoUrl:"https://vleap.ai/images/chains/vibechain.svg",nativeToken:zr},At=oe(ke.Vibechain,{mainnet:Ue,testnet:Ue,devnet:Ue});var Xs=(s,e)=>[xt(s,e),At(s,e)],Js=()=>[Et.Multiversx,Et.Vibechain];import{WarpConstants as ce,WarpSerializer as Fe}from"@vleap/warps";var lo=s=>new Fe().nativeToString(f.Token,s),uo=s=>new Fe().nativeToString(f.CodeMeta,s),mo=(s,e)=>{if(e===null)return f.Optional+ce.ArgParamsSeparator;let t=s(e),r=t.indexOf(ce.ArgParamsSeparator),n=t.substring(0,r),a=t.substring(r+1);return f.Optional+ce.ArgParamsSeparator+n+ce.ArgParamsSeparator+a},ho=s=>new Fe().nativeToString(f.List,s);import{Address as qr,AddressValue as Qr,BigUIntType as jr,BigUIntValue as bt,BooleanValue as Xr,BytesValue as Jr,CodeMetadata as Yr,CodeMetadataValue as Zr,CompositeType as en,CompositeValue as tn,Field as Oe,FieldDefinition as Me,List as rn,NothingValue as nn,OptionalValue as Re,OptionValue as Le,StringValue as an,Struct as sn,StructType as on,TokenIdentifierType as cn,TokenIdentifierValue as St,U16Value as pn,U32Value as ln,U64Type as un,U64Value as It,U8Value as mn,VariadicValue as dn}from"@multiversx/sdk-core";var To=(s,e)=>s?Le.newProvided(s):e?Le.newMissingTyped(e):Le.newMissing(),Wo=(s,e)=>s?new Re(s.getType(),s):e?new Re(e):Re.newMissing(),Co=s=>{if(s.length===0)throw new Error("Cannot create a list from an empty array");let e=s[0].getType();return new rn(e,s)},xo=s=>dn.fromItems(...s),Ao=s=>{let e=s.map(t=>t.getType());return new tn(new en(...e),s)},Eo=s=>an.fromUTF8(s),bo=s=>new mn(s),So=s=>new pn(s),Io=s=>new ln(s),Bo=s=>new It(s),Po=s=>new bt(BigInt(s)),No=s=>new Xr(s),Vo=s=>new Qr(qr.newFromBech32(s)),Uo=s=>new St(s),ko=s=>Jr.fromHex(s),Fo=s=>new sn(new on("EsdtTokenPayment",[new Me("token_identifier","",new cn),new Me("token_nonce","",new un),new Me("amount","",new jr)]),[new Oe(new St(s.token.identifier),"token_identifier"),new Oe(new It(BigInt(s.token.nonce)),"token_nonce"),new Oe(new bt(BigInt(s.amount)),"amount")]),Oo=s=>new Zr(Yr.newFromBytes(Uint8Array.from(Buffer.from(s,"hex")))),Mo=()=>new nn;export{U as ExplorerUrls,Ze as KnownTokens,lr as MultiversxExplorers,tt as MultiversxExplorersConfig,Ve as NativeTokenEgld,zr as NativeTokenVibe,ur as VibechainExplorers,B as WarpMultiversxAbiBuilder,$ as WarpMultiversxBrandBuilder,K as WarpMultiversxBuilder,za as WarpMultiversxConstants,H as WarpMultiversxContractLoader,q as WarpMultiversxDataLoader,re as WarpMultiversxExecutor,ne as WarpMultiversxExplorer,f as WarpMultiversxInputTypes,O as WarpMultiversxOutput,ie as WarpMultiversxRegistry,P as WarpMultiversxSerializer,se as WarpMultiversxWallet,Vo as address_value,Fo as asset_value,Po as biguint_value,No as boolean_value,uo as codemeta,Oo as codemeta_value,Ao as composite_value,oe as createMultiversxAdapter,et as findKnownTokenById,Xs as getAllMultiversxAdapters,Js as getAllMultiversxChainNames,Ba as getKnownTokensForChain,xt as getMultiversxAdapter,v as getMultiversxEntrypoint,b as getMultiversxRegistryAddress,G as getNormalizedTokenIdentifier,At as getVibechainAdapter,ko as hex_value,F as isNativeToken,ho as list,Co as list_value,Mo as nothing_value,To as option_value,mo as optional,Wo as optional_value,Eo as string_value,wt as toTypedConfigInfo,ae as toTypedRegistryInfo,lo as token,Uo as token_value,So as u16_value,Io as u32_value,Bo as u64_value,bo as u8_value,xo 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.79",
3
+ "version": "0.2.0-beta.80",
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.0",
41
- "@vleap/warps": "^3.0.0-beta.157"
41
+ "@vleap/warps": "^3.0.0-beta.159"
42
42
  }
43
43
  }