@vleap/warps-adapter-multiversx 0.2.0-alpha.71 → 0.2.0-alpha.72
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.js +1 -1
- package/dist/index.mjs +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var ge=Object.defineProperty;var $e=Object.getOwnPropertyDescriptor;var ze=Object.getOwnPropertyNames;var Ke=Object.prototype.hasOwnProperty;var qe=(i,e)=>{for(var t in e)ge(i,t,{get:e[t],enumerable:!0})},Qe=(i,e,t,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let a of ze(e))!Ke.call(i,a)&&a!==t&&ge(i,a,{get:()=>e[a],enumerable:!(r=$e(e,a))||r.enumerable});return i};var je=i=>Qe(ge({},"__esModule",{value:!0}),i);var Et={};qe(Et,{ExplorerUrls:()=>H,KnownTokens:()=>ye,MultiversxExplorers:()=>Oe,MultiversxExplorersConfig:()=>ve,NativeTokenEgld:()=>de,NativeTokenVibe:()=>Ge,VibechainExplorers:()=>Le,WarpMultiversxAbiBuilder:()=>M,WarpMultiversxBrandBuilder:()=>ne,WarpMultiversxBuilder:()=>ae,WarpMultiversxConstants:()=>Je,WarpMultiversxContractLoader:()=>re,WarpMultiversxDataLoader:()=>se,WarpMultiversxExecutor:()=>ie,WarpMultiversxExplorer:()=>oe,WarpMultiversxInputTypes:()=>T,WarpMultiversxRegistry:()=>pe,WarpMultiversxResults:()=>q,WarpMultiversxSerializer:()=>O,WarpMultiversxWallet:()=>le,address_value:()=>vt,asset_value:()=>Ct,biguint_value:()=>yt,boolean_value:()=>Tt,codemeta:()=>at,codemeta_value:()=>xt,composite_value:()=>ut,createMultiversxAdapter:()=>ue,findKnownTokenById:()=>Te,getAllMultiversxAdapters:()=>tt,getAllMultiversxChainNames:()=>rt,getKnownTokensForChain:()=>Xe,getMultiversxAdapter:()=>Ce,getMultiversxEntrypoint:()=>w,getMultiversxRegistryAddress:()=>I,getNormalizedTokenIdentifier:()=>te,getVibechainAdapter:()=>Ae,hex_value:()=>Wt,isNativeToken:()=>$,list:()=>it,list_value:()=>pt,nothing_value:()=>At,option_value:()=>ot,optional:()=>st,optional_value:()=>ct,string_value:()=>mt,toTypedConfigInfo:()=>We,toTypedRegistryInfo:()=>ce,token:()=>nt,token_value:()=>wt,u16_value:()=>ht,u32_value:()=>gt,u64_value:()=>ft,u8_value:()=>dt,variadic_value:()=>lt});module.exports=je(Et);var Ee=require("@vleap/warps");var Y=require("@vleap/warps");var _e=require("@vleap/warps");var R=require("@multiversx/sdk-core"),E=require("@vleap/warps");var j=require("@multiversx/sdk-core"),be=require("@vleap/warps"),$=i=>!i.includes("-"),te=i=>$(i)?`${i}-000000`:i,w=(i,e,t)=>{let r="warp-sdk",s=t?(0,be.getProviderConfig)(t,i.name,e,i.defaultApiUrl):{url:i.defaultApiUrl},o=s.url,p={headers:s.headers};return e==="devnet"?new j.DevnetEntrypoint({url:o,kind:"api",clientName:r,networkProviderConfig:p}):e==="testnet"?new j.TestnetEntrypoint({url:o,kind:"api",clientName:r,networkProviderConfig:p}):new j.MainnetEntrypoint({url:o,kind:"api",clientName:r,networkProviderConfig:p})};var fe=require("@vleap/warps");var re=class{constructor(e){this.config=e}async getContract(e,t){try{let s=await w(t,this.config.env,this.config).createNetworkProvider().doGetGeneric(`accounts/${e}`);return{address:e,owner:s.ownerAddress,verified:s.isVerified||!1}}catch(r){return fe.WarpLogger.error("WarpContractLoader: getContract error",r),null}}async getVerificationInfo(e,t){try{let s=await w(t,this.config.env,this.config).createNetworkProvider().doGetGeneric(`accounts/${e}/verification`);return{codeHash:s.codeHash,abi:s.source.abi}}catch(r){return fe.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 R.TransactionsFactoryConfig({chainID:this.chain.chainId}),a=new R.TransferTransactionsFactory({config:r}),s=R.Address.newFromBech32(t),o={protocol:(0,E.getLatestProtocolIdentifier)("abi"),content:e},p=JSON.stringify(o),c=await a.createTransactionForTransfer(s,{receiver:s,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),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 s=w(this.chain,this.config.env,this.config).createNetworkProvider();try{let o=await s.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 R.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 R.AbiRegistry.create(r.content)}else{let r=await(await fetch(e.abi)).json();return R.AbiRegistry.create(r)}}};var z=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 z.TransactionsFactoryConfig({chainID:this.chain.chainId}),a=new z.TransferTransactionsFactory({config:r}),s=z.Address.newFromBech32(t),o=JSON.stringify(e);return await a.createTransactionForNativeTokenTransfer(s,{receiver:z.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={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=w(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 K=require("@multiversx/sdk-core"),P=require("@vleap/warps");var ae=class extends P.WarpBuilder{constructor(t,r){super(t);this.config=t;this.chain=r;this.cache=new P.WarpCache(t.cache?.type),this.core=new P.WarpBuilder(t)}async createInscriptionTransaction(t){let r=(0,P.getWarpWalletAddressFromConfig)(this.config,this.chain.name);if(!r)throw new Error("WarpBuilder: user address not set");let a=new K.TransactionsFactoryConfig({chainID:this.chain.chainId}),s=new K.TransferTransactionsFactory({config:a}),o=K.Address.newFromBech32(r),p=JSON.stringify(t),c=await s.createTransactionForTransfer(o,{receiver:K.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,P.createWarpIdentifier)(this.chain.name,"hash",t.hash),hash:t.hash,creator:t.sender.toBech32(),createdAt:new Date(t.timestamp*1e3).toISOString()},a}async createFromTransactionHash(t,r){let a=P.WarpCacheKey.Warp(this.config.env,t);if(r){let p=this.cache.get(a);if(p)return P.WarpLogger.info(`WarpBuilder (createFromTransactionHash): Warp found in cache: ${t}`),p}let o=w(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 P.WarpLogger.error("WarpBuilder: Error creating from transaction hash",p),null}}};var G=require("@multiversx/sdk-core"),X=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"),S=Ne.WarpChainName.Multiversx,Ve=[{chain:S,identifier:"EGLD",name:"eGold",symbol:"EGLD",decimals:18,logoUrl:"https://tools.multiversx.com/assets-cdn/tokens/EGLD-000000/icon.png"},{chain:S,identifier:"EGLD-000000",name:"eGold",symbol:"EGLD",decimals:18,logoUrl:"https://tools.multiversx.com/assets-cdn/tokens/EGLD-000000/icon.png"},{chain:S,identifier:"SEGLD-3ad2d0",name:"StakedEGLD",symbol:"SEGLD",decimals:18,logoUrl:"https://tools.multiversx.com/assets-cdn/tokens/SEGLD-3ad2d0/icon.png"},{chain:S,identifier:"HSEGLD-c13a4e",name:"HatomSEGLD",symbol:"HSEGLD",decimals:8,logoUrl:"https://tools.multiversx.com/assets-cdn/tokens/HSEGLD-c13a4e/icon.png"},{chain:S,identifier:"UTK-2f80e9",name:"xMoney UTK",symbol:"UTK",decimals:18,logoUrl:"https://tools.multiversx.com/assets-cdn/tokens/UTK-2f80e9/icon.png"},{chain:S,identifier:"USDC-c76f1f",name:"WrappedUSDC",symbol:"USDC",decimals:6,logoUrl:"https://tools.multiversx.com/assets-cdn/tokens/USDC-c76f1f/icon.png"},{chain:S,identifier:"WEGLD-bd4d79",name:"WrappedEGLD",symbol:"WEGLD",decimals:18,logoUrl:"https://tools.multiversx.com/assets-cdn/tokens/WEGLD-bd4d79/icon.png"},{chain:S,identifier:"HTM-f51d55",name:"Hatom",symbol:"HTM",decimals:18,logoUrl:"https://tools.multiversx.com/assets-cdn/tokens/HTM-f51d55/icon.png"},{chain:S,identifier:"MEX-455c57",name:"MEX",symbol:"MEX",decimals:18,logoUrl:"https://tools.multiversx.com/assets-cdn/tokens/MEX-455c57/icon.png"},{chain:S,identifier:"WTAO-4f5363",name:"WrappedTAO",symbol:"WTAO",decimals:9,logoUrl:"https://tools.multiversx.com/assets-cdn/tokens/WTAO-4f5363/icon.png"},{chain:S,identifier:"HEGLD-d61095",name:"HatomEGLD",symbol:"HEGLD",decimals:8,logoUrl:"https://tools.multiversx.com/assets-cdn/tokens/HEGLD-d61095/icon.png"},{chain:S,identifier:"WBTC-5349b3",name:"WrappedBTC",symbol:"WBTC",decimals:8,logoUrl:"https://tools.multiversx.com/assets-cdn/tokens/WBTC-5349b3/icon.png"},{chain:S,identifier:"WETH-b4ca29",name:"WrappedETH",symbol:"WETH",decimals:18,logoUrl:"https://tools.multiversx.com/assets-cdn/tokens/WETH-b4ca29/icon.png"},{chain:S,identifier:"USH-111e09",name:"HatomUSD",symbol:"USH",decimals:18,logoUrl:"https://tools.multiversx.com/assets-cdn/tokens/USH-111e09/icon.png"},{chain:S,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"),Re=Me.WarpChainName.Vibechain,me=[{chain:Re,identifier:"VIBE",name:"VIBE",symbol:"VIBE",decimals:18,logoUrl:"https://vleap.ai/images/tokens/vibe.svg"},{chain:Re,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}},Te=(i,e,t)=>(ye[i]?.[e]||[]).find(a=>a.identifier===t)||null,Xe=(i,e)=>ye[i]?.[e]||[];var se=class{constructor(e,t){this.config=e;this.chain=t;this.cache=new X.WarpCache(e.cache?.type)}async getAccount(e){let r=await w(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=w(this.chain,this.config.env,this.config).createNetworkProvider(),r=t.getAccount(G.Address.newFromBech32(e)),a=t.getFungibleTokensOfAccount(G.Address.newFromBech32(e)),[s,o]=await Promise.all([r,a]),p=s.balance>0?[{...this.chain.nativeToken,amount:s.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=X.WarpCacheKey.Asset(this.config.env,this.chain.name,e),r=this.cache.get(t);if(r)return r;let a=Te(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 s=new G.TokenComputer,o=$(e)?0n:s.extractNonceFromExtendedIdentifier(e),p=new G.Token({identifier:e,nonce:BigInt(o||0)}),c=s.isFungible(p),f=w(this.chain,this.config.env,this.config).createNetworkProvider(),g=te(e),d=await f.doGetGeneric(`tokens/${g}`),v={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,v,X.CacheTtl.OneHour),v}async getAction(e,t=!1){let r=w(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(s=>s.raw.returnMessage)[0]||null,tx:a}}async getAccountActions(e,t){let r=w(this.chain,this.config.env,this.config).createNetworkProvider(),a=`accounts/${e}/transactions`,s=new URLSearchParams,o=t?.size||25,p=t?.page||0;if(p>0){let f=p*o;s.append("from",f.toString())}return o!==25&&s.append("size",o.toString()),s.toString()&&(a+=`?${s.toString()}`),(await r.doGetGeneric(a)).map(f=>({chain:this.chain.name,id:f.txHash,receiver:f.receiver,sender:f.sender,value:f.value,function:f.function,status:this.toActionStatus(f),createdAt:this.toActionCreatedAt(f)}))}toActionStatus(e){return e.status.isSuccessful()?"success":e.status.isFailed()?"failed":"pending"}toActionCreatedAt(e){return new Date(e.timestamp||e.timestamp*1e3).toISOString()}};var C=require("@multiversx/sdk-core"),k=require("@vleap/warps");var J=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:i=>i.config.user?.wallets?.[i.chain.name]},ChainApiUrl:{Placeholder:"CHAIN_API",Accessor:i=>i.chain.defaultApiUrl},ChainAddressHrp:{Placeholder:"CHAIN_ADDRESS_HRP",Accessor:i=>i.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}},T={Null:"null",Optional:"optional",List:"list",Token:"token",CodeMeta:"codemeta"},Oe=(r=>(r.MultiversxExplorer="multiversx_explorer",r.MultiversxExplorerDevnet="multiversx_explorer_devnet",r.MultiversxExplorerTestnet="multiversx_explorer_testnet",r))(Oe||{}),Le=(r=>(r.VibechainExplorer="vibechain_explorer",r.VibechainExplorerDevnet="vibechain_explorer_devnet",r.VibechainExplorerTestnet="vibechain_explorer_testnet",r))(Le||{}),ve={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}(.*)`),O=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 g=this.typeToString(t.getFirstTypeParameter());return u.Vector+h.ArgParamsSeparator+g+h.ArgParamsSeparator}let a=r.map(g=>this.typedToString(g));if(a.every(g=>g.startsWith(u.Tuple)))return u.Vector+h.ArgParamsSeparator+a.join(",");let s=a[0],o=s.indexOf(h.ArgParamsSeparator),p=s.substring(0,o),c=a.map(g=>{let d=g.indexOf(h.ArgParamsSeparator);return g.substring(d+1)}),f=p.startsWith(u.Struct)?h.ArgStructSeparator:h.ArgListSeparator;return u.Vector+h.ArgParamsSeparator+p+h.ArgParamsSeparator+c.join(f)}if(t.hasExactClass(n.OptionalType.ClassName)||e.hasClassOrSuperclass(n.OptionalValue.ClassName)){if(!e.isSet())return T.Optional+h.ArgParamsSeparator+"null";let r=this.typedToString(e.getTypedValue());return T.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 T.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 T.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(s=>{let o=this.typedToString(s),p=o.indexOf(h.ArgParamsSeparator),c=o.substring(0,p),f=o.substring(p+1);return`${c},${f}`});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(),s=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+s}if(t.hasExactClass(n.StructType.ClassName)||e.hasClassOrSuperclass(n.Struct.ClassName)){let r=e,s=r.getType().getName(),o=r.getFields();if(o.length===0)return`${u.Struct}(${s})${h.ArgParamsSeparator}`;let p=o.map(c=>{let f=c.value.getType(),d=this.typedToString(c.value).split(h.ArgParamsSeparator),v=d.length>2?d.slice(2).join(h.ArgParamsSeparator):d[1]||"";return`(${c.name}${h.ArgParamsSeparator}${this.typeToString(f)})${v}`});return`${u.Struct}(${s})${h.ArgParamsSeparator}${p.join(h.ArgListSeparator)}`}if(t.hasExactClass(n.TokenIdentifierType.ClassName)||e.hasClassOrSuperclass(n.TokenIdentifierValue.ClassName))return T.Token+h.ArgParamsSeparator+e.valueOf();if(t.hasExactClass(n.CodeMetadataType.ClassName)||e.hasClassOrSuperclass(n.CodeMetadataValue.ClassName))return T.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 s=0;s<r.length;s+=2)a.push(r[s]);return new n.CompositeType(...a.map(s=>this.nativeToType(s)))}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===T.Token)return new n.TokenIdentifierType;if(e===T.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),s=r.substring(0,a),o=r.substring(a+1);if(s.startsWith(u.Tuple)){let d=o.split(",").map(v=>this.stringToTyped(v));return new n.VariadicValue(new n.VariadicType(this.nativeToType(s)),d)}if(o.includes("tuple(")){let g=this.splitTupleStrings(o),d=g.map(x=>this.stringToTyped(x)),b=g[0].match(/^(tuple\([^)]+\))/),y=b?b[1]:"tuple";return new n.VariadicValue(new n.VariadicType(this.nativeToType(y)),d)}let p=s.startsWith(u.Struct)?h.ArgStructSeparator:h.ArgListSeparator,f=o.split(p).map(g=>this.stringToTyped(`${s}:${g}`));return new n.VariadicValue(new n.VariadicType(this.nativeToType(s)),f)}if(t.startsWith(u.Tuple)){let a=t.match(/\(([^)]+)\)/)?.[1];if(!a)throw new Error(`Invalid tuple format: ${t}`);let s=a.split(","),o=[];for(let c=0;c<s.length;c+=2){let f=s[c],g=s[c+1];o.push(this.stringToTyped(`${f}:${g}`))}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(/\(([^)]+)\)/),s=a?a[1]:"CustomStruct";if(!r)return new n.Struct(new n.StructType(s,[]),[]);let o=r.split(h.ArgListSeparator),p=[],c=[];return o.forEach(f=>{let g=f.match(new RegExp(`^\\(([^${h.ArgParamsSeparator}]+)${h.ArgParamsSeparator}([^)]+)\\)(.+)$`));if(g){let[,d,v,b]=g,y=this.stringToTyped(`${v}${h.ArgParamsSeparator}${b}`);p.push(new n.FieldDefinition(d,"",y.getType())),c.push(new n.Field(y,d))}}),new n.Struct(new n.StructType(s,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,s]=r.split(h.ArgCompositeSeparator),o=new n.TokenComputer,p=$(a)?te(a):o.extractIdentifierFromExtendedIdentifier(a),c=$(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(s)),"amount")])}if(t===T.Null)return new n.NothingValue;if(t===T.Optional){let a=this.stringToTyped(r);return a instanceof n.NothingValue?n.OptionalValue.newMissing():new n.OptionalValue(a.getType(),a)}if(t===T.List){let[a,s]=r.split(Ye,2),p=s.split(h.ArgListSeparator).map(c=>this.stringToTyped(a+h.ArgParamsSeparator+c));return new n.List(this.nativeToType(a),p)}if(t===T.Token)return r?new n.TokenIdentifierValue(r):new n.NothingValue;if(t===T.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 s=0;s<e.length;s++){let o=e[s];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 T.Token;if(e.hasExactClass(n.OptionalType.ClassName))return T.Optional+h.ArgParamsSeparator+this.typeToString(e.getFirstTypeParameter());if(e.hasExactClass(n.ListType.ClassName))return T.List+h.ArgParamsSeparator+this.typeToString(e.getFirstTypeParameter());if(e.hasExactClass(n.CodeMetadataType.ClassName))return T.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 q=class{constructor(e,t,r){this.config=e;this.chain=t;this.typeRegistry=r;this.abi=new M(e,t),this.serializer=new O({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))??[],s=await this.extractContractResults(e,t,r,a),o=(0,W.getNextInfo)(this.config,[],e,t,s),p=(0,W.applyResultsToMessages)(e,s.results);return{success:r.status.isSuccessful(),warp:e,action:t,user:(0,W.getWarpWalletAddressFromConfig)(this.config,this.chain.name),txHash:r.hash,tx:r,next:o,values:s.values,results:s.results,messages:p}}async extractContractResults(e,t,r,a){let s=(0,W.getWarpActionByIndex)(e,t),o=[],p=[],c={};if(!e.results||s.type!=="contract")return{values:{string:o,native:p},results:c};if(!Object.values(e.results).some(y=>y.includes("out")||y.includes("event"))){for(let[y,x]of Object.entries(e.results))c[y]=x;return{values:{string:o,native:p},results:await(0,W.evaluateResultsCommon)(e,c,t,a,this.serializer.coreSerializer,this.config.transform?.runner)}}let g=await this.abi.getAbiForAction(s),d=new J.TransactionEventsParser({abi:g}),b=new J.SmartContractTransactionsOutcomeParser({abi:g}).parseExecute({transactionOnNetwork:r,function:s.func||void 0});for(let[y,x]of Object.entries(e.results)){if(x.startsWith(W.WarpConstants.Transform.Prefix))continue;if(x.startsWith("input.")){c[y]=x;continue}let B=(0,W.parseResultsOutIndex)(x);if(B!==null&&B!==t){c[y]=null;continue}let[F,U,Z]=x.split(".");if(F==="event"){if(!U||isNaN(Number(Z)))continue;let Q=Number(Z),A=(0,J.findEventsByFirstTopic)(r,U),He=d.parseEvents({events:A})[0],ee=Object.values(He)[Q]||null;o.push(String(ee)),p.push(ee),c[y]=ee&&ee.valueOf()}else if(F==="out"||F.startsWith("out[")){if(!U)continue;let Q=Number(U),A=b.values[Q-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},results:await(0,W.evaluateResultsCommon)(e,c,t,a,this.serializer.coreSerializer)}}async extractQueryResults(e,t,r,a){let s=t.map(g=>this.serializer.typedToString(g)),o=t.map(g=>this.serializer.typedToNative(g)[1]),p={string:s,native:o},c={};if(!e.results)return{values:p,results:c};let f=g=>{let d=g.split(".").slice(1).map(b=>parseInt(b)-1);if(d.length===0)return;let v=o[d[0]];for(let b=1;b<d.length;b++){if(v==null)return;v=v[d[b]]}return v};for(let[g,d]of Object.entries(e.results)){if(d.startsWith(W.WarpConstants.Transform.Prefix))continue;let v=(0,W.parseResultsOutIndex)(d);if(v!==null&&v!==r){c[g]=null;continue}d.startsWith("out.")||d==="out"||d.startsWith("out[")?c[g]=f(d)||null:c[g]=d}return{values:p,results:await(0,W.evaluateResultsCommon)(e,c,r,a,this.serializer.coreSerializer)}}async resolveWarpResultsRecursively(e){let t=e.warp,r=e.entryActionIndex,a=e.executor,s=e.inputs,o=e.meta,p=new Map,c=new Set,f=this;async function g(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 B=t.actions[y-1];if(!B)throw new Error(`Action ${y} not found`);let F;if(B.type==="query")F=await a.executeQuery(t,y,x);else if(B.type==="collect")F=await a.executeCollect(t,y,x,o);else throw new Error(`Unsupported or interactive action type: ${B.type}`);if(p.set(y,F),t.results)for(let U of Object.values(t.results)){let Q=String(U).match(/^out\[(\d+)\]/);if(Q){let A=parseInt(Q[1],10);A!==y&&!p.has(A)&&await g(A)}}return c.delete(y),F}await g(r,s);let d={};for(let y of p.values())for(let[x,B]of Object.entries(y.results))B!==null?d[x]=B:x in d||(d[x]=null);let v=await(0,W.evaluateResultsCommon)(t,d,r,s,this.serializer.coreSerializer,this.config.transform?.runner);return{...p.get(r),action:r,results:v}}};var Ze="EGLD-000000",ie=class{constructor(e,t,r){this.config=e;this.chain=t;this.typeRegistry=r;this.serializer=new O({typeRegistry:this.typeRegistry}),this.abi=new M(this.config,this.chain),this.results=new q(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){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}),s=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:s?new Uint8Array(s):void 0})}async createContractCallTransaction(e){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),s=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:s,tokenTransfers:this.toTokenTransfers(e.transfers),nativeTransferAmount:e.value})}async executeQuery(e){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(U=>this.serializer.stringToTyped(U)),s=w(e.chain,this.config.env,this.config),o=C.Address.newFromBech32(e.destination),p=s.createSmartContractController(r),c=p.createQuery({contract:o,function:t.func||"",arguments:a}),f=await p.runQuery(c),g=f.returnCode==="ok",d=new C.ArgSerializer,v=r.getEndpoint(f.function||t.func||""),b=(f.returnDataParts||[]).map(U=>Buffer.from(U)),y=d.buffersToValues(b,v.output),{values:x,results:B}=await this.results.extractQueryResults(e.warp,y,e.action,e.resolvedInputs),F=(0,k.getNextInfo)(this.config,[],e.warp,e.action,B);return{success:g,warp:e.warp,action:e.action,user:(0,k.getWarpWalletAddressFromConfig)(this.config,e.chain.name),txHash:null,tx:null,next:F,values:x,results:B,messages:(0,k.applyResultsToMessages)(e.warp,B)}}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=ve[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 s=H[t];if(s)return s}if(e){let s=H[e];if(s)return s}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 s=H[a];s&&(r[a]=`${s}/accounts/${e}`)}),r}getTransactionUrls(e){let t=this.getAllExplorers(),r={};return t.forEach(a=>{let s=H[a];s&&(r[a]=`${s}/transactions/${e}`)}),r}};var m=require("@multiversx/sdk-core"),N=require("@vleap/warps");var we={buildInfo:{rustc:{version:"1.86.0",commitHash:"05f9846f893b09a1be1fc8560e33fc3c815cfecb",commitDate:"2025-03-31",channel:"Stable",short:"rustc 1.86.0 (05f9846f8 2025-03-31)"},contractCrate:{name:"registry",version:"0.0.1"},framework:{name:"multiversx-sc",version:"0.51.1"}},name:"RegistryContract",constructor:{inputs:[{name:"unit_price",type:"BigUint"},{name:"vault",type:"Address"}],outputs:[]},upgradeConstructor:{inputs:[],outputs:[]},endpoints:[{name:"registerWarp",mutability:"mutable",payableInTokens:["EGLD"],inputs:[{name:"hash",type:"bytes"},{name:"alias_opt",type:"optional<bytes>",multi_arg:!0},{name:"brand_opt",type:"optional<bytes>",multi_arg:!0}],outputs:[],allow_multiple_var_args:!0},{name:"unregisterWarp",mutability:"mutable",inputs:[{name:"warp",type:"bytes"}],outputs:[]},{name:"upgradeWarp",mutability:"mutable",payableInTokens:["EGLD"],inputs:[{name:"alias",type:"bytes"},{name:"new_warp",type:"bytes"},{name:"brand_opt",type:"optional<bytes>",multi_arg:!0}],outputs:[]},{name:"setWarpAlias",mutability:"mutable",payableInTokens:["EGLD"],inputs:[{name:"hash",type:"bytes"},{name:"alias",type:"bytes"}],outputs:[]},{name:"forceRemoveAlias",mutability:"mutable",inputs:[{name:"hash",type:"bytes"}],outputs:[]},{name:"verifyWarp",mutability:"mutable",inputs:[{name:"warp",type:"bytes"}],outputs:[]},{name:"transferOwnership",mutability:"mutable",inputs:[{name:"warp",type:"bytes"},{name:"new_owner",type:"Address"}],outputs:[]},{name:"getUserWarps",mutability:"readonly",inputs:[{name:"address",type:"Address"}],outputs:[{type:"variadic<InfoView>",multi_result:!0}]},{name:"getInfoByAlias",mutability:"readonly",inputs:[{name:"alias",type:"bytes"}],outputs:[{type:"InfoView"}]},{name:"getInfoByHash",mutability:"readonly",inputs:[{name:"hash",type:"bytes"}],outputs:[{type:"InfoView"}]},{name:"setVault",onlyOwner:!0,mutability:"mutable",inputs:[{name:"vault",type:"Address"}],outputs:[]},{name:"setUnitPrice",onlyOwner:!0,mutability:"mutable",inputs:[{name:"amount",type:"BigUint"}],outputs:[]},{name:"addAdmin",onlyOwner:!0,mutability:"mutable",inputs:[{name:"address",type:"Address"}],outputs:[]},{name:"removeAdmin",onlyOwner:!0,mutability:"mutable",inputs:[{name:"address",type:"Address"}],outputs:[]},{name:"getConfig",mutability:"readonly",inputs:[],outputs:[{type:"ConfigView"}]},{name:"registerBrand",mutability:"mutable",payableInTokens:["EGLD"],inputs:[{name:"hash",type:"bytes"}],outputs:[]},{name:"brandWarp",mutability:"mutable",payableInTokens:["EGLD"],inputs:[{name:"warp",type:"bytes"},{name:"brand",type:"bytes"}],outputs:[]},{name:"getUserBrands",mutability:"readonly",inputs:[{name:"user",type:"Address"}],outputs:[{type:"variadic<bytes>",multi_result:!0}]}],events:[{identifier:"warpRegistered",inputs:[{name:"hash",type:"bytes",indexed:!0},{name:"alias",type:"bytes",indexed:!0},{name:"trust",type:"bytes",indexed:!0}]},{identifier:"warpUnregistered",inputs:[{name:"hash",type:"bytes",indexed:!0}]},{identifier:"warpUpgraded",inputs:[{name:"alias",type:"bytes",indexed:!0},{name:"new_warp",type:"bytes",indexed:!0},{name:"trust",type:"bytes",indexed:!0}]},{identifier:"warpVerified",inputs:[{name:"hash",type:"bytes",indexed:!0}]},{identifier:"aliasUpdated",inputs:[{name:"hash",type:"bytes",indexed:!0},{name:"alias",type:"bytes",indexed:!0}]},{identifier:"ownershipTransferred",inputs:[{name:"warp",type:"bytes",indexed:!0},{name:"old_owner",type:"Address",indexed:!0},{name:"new_owner",type:"Address",indexed:!0}]}],esdtAttributes:[],hasCallback:!1,types:{ConfigView:{type:"struct",fields:[{name:"unit_price",type:"BigUint"},{name:"admins",type:"List<Address>"}]},InfoView:{type:"struct",fields:[{name:"hash",type:"bytes"},{name:"alias",type:"Option<bytes>"},{name:"trust",type:"bytes"},{name:"owner",type:"Address"},{name:"created_at",type:"u64"},{name:"upgraded_at",type:"u64"},{name:"brand",type:"Option<bytes>"},{name:"upgrade",type:"Option<bytes>"}]}}};var I=i=>{if(i==="devnet")return"erd1qqqqqqqqqqqqqpgqje2f99vr6r7sk54thg03c9suzcvwr4nfl3tsfkdl36";if(i==="testnet")throw new Error("Multiversx testnet is not supported");return"erd1qqqqqqqqqqqqqpgq3mrpj3u6q7tejv6d7eqhnyd27n9v5c5tl3ts08mffe"};var ce=i=>({hash:i.hash.toString("hex"),alias:i.alias?.toString()||null,trust:i.trust.toString(),owner:i.owner.toString(),createdAt:i.created_at.toNumber(),upgradedAt:i.upgraded_at?.toNumber(),brand:i.brand?.toString("hex")||null,upgrade:i.upgrade?.toString("hex")||null}),We=i=>({unitPrice:BigInt(i.unit_price.toString()),admins:i.admins.map(e=>e.toBech32())});var pe=class{constructor(e,t){this.config=e;this.chain=t;this.cache=new N.WarpCache(e.cache?.type),this.registryConfig={unitPrice:BigInt(0),admins:[]},this.userWallet=(0,N.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),s=()=>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(I(this.config.env)),function:"registerWarp",gasLimit:BigInt(1e7),nativeTransferAmount:s(),arguments:o()})}async createWarpUnregisterTransaction(e){if(!this.userWallet)throw new Error("WarpRegistry: user address not set");let t=m.Address.newFromBech32(this.userWallet);return await this.getFactory().createTransactionForExecute(t,{contract:m.Address.newFromBech32(I(this.config.env)),function:"unregisterWarp",gasLimit:BigInt(1e7),arguments:[m.BytesValue.fromHex(e)]})}async createWarpUpgradeTransaction(e,t,r){if(this.registryConfig.unitPrice===BigInt(0))throw new Error("WarpRegistry: config not loaded. forgot to call init()?");if(!this.userWallet)throw new Error("WarpRegistry: user address not set");let a=m.Address.newFromBech32(this.userWallet);return await this.getFactory().createTransactionForExecute(a,{contract:m.Address.newFromBech32(I(this.config.env)),function:"upgradeWarp",gasLimit:BigInt(1e7),nativeTransferAmount:this.isCurrentUserAdmin()?void 0:this.registryConfig.unitPrice,arguments:r?[m.BytesValue.fromUTF8(e),m.BytesValue.fromHex(t),m.BytesValue.fromHex(r)]:[m.BytesValue.fromUTF8(e),m.BytesValue.fromHex(t)]})}async createWarpAliasSetTransaction(e,t){if(!this.userWallet)throw new Error("WarpRegistry: user address not set");let r=m.Address.newFromBech32(this.userWallet);return await this.getFactory().createTransactionForExecute(r,{contract:m.Address.newFromBech32(I(this.config.env)),function:"setWarpAlias",gasLimit:BigInt(1e7),nativeTransferAmount:this.isCurrentUserAdmin()?void 0:this.registryConfig.unitPrice,arguments:[m.BytesValue.fromHex(e),m.BytesValue.fromUTF8(t)]})}async createWarpVerifyTransaction(e){if(!this.userWallet)throw new Error("WarpRegistry: user address not set");let t=m.Address.newFromBech32(this.userWallet);return await this.getFactory().createTransactionForExecute(t,{contract:m.Address.newFromBech32(I(this.config.env)),function:"verifyWarp",gasLimit:BigInt(1e7),arguments:[m.BytesValue.fromHex(e)]})}async createWarpTransferOwnershipTransaction(e,t){if(!this.userWallet)throw new Error("WarpRegistry: user address not set");let r=m.Address.newFromBech32(this.userWallet);return await this.getFactory().createTransactionForExecute(r,{contract:m.Address.newFromBech32(I(this.config.env)),function:"transferOwnership",gasLimit:BigInt(1e7),arguments:[m.BytesValue.fromHex(e),new m.AddressValue(new m.Address(t))]})}async createBrandRegisterTransaction(e){if(this.registryConfig.unitPrice===BigInt(0))throw new Error("WarpRegistry: config not loaded. forgot to call init()?");if(!this.userWallet)throw new Error("WarpRegistry: user address not set");let t=m.Address.newFromBech32(this.userWallet);return await this.getFactory().createTransactionForExecute(t,{contract:m.Address.newFromBech32(I(this.config.env)),function:"registerBrand",gasLimit:BigInt(1e7),nativeTransferAmount:this.isCurrentUserAdmin()?void 0:this.registryConfig.unitPrice,arguments:[m.BytesValue.fromHex(e)]})}async createWarpBrandingTransaction(e,t){if(!this.userWallet)throw new Error("WarpRegistry: user address not set");let r=m.Address.newFromBech32(this.userWallet);return await this.getFactory().createTransactionForExecute(r,{contract:m.Address.newFromBech32(I(this.config.env)),function:"brandWarp",gasLimit:BigInt(1e7),nativeTransferAmount:this.isCurrentUserAdmin()?void 0:this.registryConfig.unitPrice,arguments:[m.BytesValue.fromHex(e),m.BytesValue.fromHex(t)]})}async getInfoByAlias(e,t){try{let r=N.WarpCacheKey.RegistryInfo(this.config.env,e),a=t?this.cache.get(r):null;if(a)return N.WarpLogger.info(`WarpRegistry (getInfoByAlias): RegistryInfo found in cache: ${e}`),a;let s=m.Address.newFromBech32(I(this.config.env)),o=this.getController(),p=o.createQuery({contract:s,function:"getInfoByAlias",arguments:[m.BytesValue.fromUTF8(e)]}),c=await o.runQuery(p),[f]=o.parseQueryResponse(c),g=f?ce(f):null,d=g?.brand?await this.fetchBrand(g.brand):null;return t&&t.ttl&&this.cache.set(r,{registryInfo:g,brand:d},t.ttl),{registryInfo:g,brand:d}}catch{return{registryInfo:null,brand:null}}}async getInfoByHash(e,t){try{let r=N.WarpCacheKey.RegistryInfo(this.config.env,e);if(t){let d=this.cache.get(r);if(d)return N.WarpLogger.info(`WarpRegistry (getInfoByHash): RegistryInfo found in cache: ${e}`),d}let a=m.Address.newFromBech32(I(this.config.env)),s=this.getController(),o=s.createQuery({contract:a,function:"getInfoByHash",arguments:[m.BytesValue.fromHex(e)]}),p=await s.runQuery(o),[c]=s.parseQueryResponse(p),f=c?ce(c):null,g=f?.brand?await this.fetchBrand(f.brand):null;return t&&t.ttl&&this.cache.set(r,{registryInfo:f,brand:g},t.ttl),{registryInfo:f,brand:g}}catch{return{registryInfo:null,brand:null}}}async getUserWarpRegistryInfos(e){try{let t=e||this.userWallet;if(!t)throw new Error("WarpRegistry: user address not set");let r=m.Address.newFromBech32(I(this.config.env)),a=this.getController(),s=a.createQuery({contract:r,function:"getUserWarps",arguments:[new m.AddressValue(new m.Address(t))]}),o=await a.runQuery(s),[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(I(this.config.env)),a=this.getController(),s=a.createQuery({contract:r,function:"getUserBrands",arguments:[new m.AddressValue(new m.Address(t))]}),o=await a.runQuery(s),[p]=a.parseQueryResponse(o),c=p.map(d=>d.toString("hex")),f={ttl:365*24*60*60};return(await Promise.all(c.map(d=>this.fetchBrand(d,f)))).filter(d=>d!==null)}catch{return[]}}async fetchBrand(e,t){let r=N.WarpCacheKey.Brand(this.config.env,e),a=t?this.cache.get(r):null;if(a)return N.WarpLogger.info(`WarpRegistry (fetchBrand): Brand found in cache: ${e}`),a;let o=w(this.chain,this.config.env,this.config).createNetworkProvider();try{let p=await o.getTransaction(e),c=JSON.parse(p.data.toString());return c.meta={chain:this.chain.name,identifier:(0,N.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(I(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(we);return new m.SmartContractTransactionsFactory({config:e,abi:t})}getController(){let e=w(this.chain,this.config.env,this.config),t=m.AbiRegistry.create(we);return e.createSmartContractController(t)}isCurrentUserAdmin(){return!!this.userWallet&&this.registryConfig.admins.includes(this.userWallet)}};var V=require("@multiversx/sdk-core"),L=require("@vleap/warps");var le=class{constructor(e,t){this.config=e;this.chain=t;this.entry=w(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("-----")?V.UserSecretKey.fromPem(t):V.UserSecretKey.fromString(t),s=new V.Account(a);if(e.nonce===0n){let o=await this.entry.recallAccountNonce(s.address),p=this.cache.get(`nonce:${s.address.toBech32()}`)||0,c=BigInt(Math.max(p,Number(o)));e.nonce=c}return e.signature=await s.signTransaction(e),this.cache.set(`nonce:${s.address.toBech32()}`,Number(s.nonce),L.CacheTtl.OneHour),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("-----")?V.UserSecretKey.fromPem(t):V.UserSecretKey.fromString(t),o=await new V.Account(a).signMessage(new V.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=V.Mnemonic.fromString(e).deriveKey(0),a=r.hex();return{address:r.generatePublicKey().toAddress(this.chain.addressHrp).toBech32(),privateKey:a,mnemonic:e}}generate(){let e=V.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=(i,e)=>(t,r)=>{let a=e[t.env],s=new _e.WarpTypeRegistry;return s.registerType("token",{stringToNative:o=>o,nativeToString:o=>`token:${o}`}),s.registerType("codemeta",{stringToNative:o=>o,nativeToString:o=>`codemeta:${o}`}),s.registerTypeAlias("list","vector"),{chainInfo:a,builder:()=>new ae(t,a),executor:new ie(t,a,s),results:new q(t,a,s),serializer:new O({typeRegistry:s}),registry:new pe(t,a),explorer:new oe(i,t),abiBuilder:()=>new M(t,a),brandBuilder:()=>new ne(t,a),dataLoader:new se(t,a),wallet:new le(t,a)}};var de={chain:Y.WarpChainName.Multiversx,identifier:"EGLD",name:"eGold",symbol:"EGLD",decimals:18,logoUrl:"https://vleap.ai/images/tokens/egld.svg"},Ce=ue(Y.WarpChainName.Multiversx,{mainnet:{name:Y.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:Y.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:Y.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=(i,e)=>[Ce(i,e),Ae(i,e)],rt=()=>[Ee.WarpChainName.Multiversx,Ee.WarpChainName.Vibechain];var D=require("@vleap/warps");var nt=i=>new D.WarpSerializer().nativeToString(T.Token,i),at=i=>new D.WarpSerializer().nativeToString(T.CodeMeta,i),st=(i,e)=>{if(e===null)return T.Optional+D.WarpConstants.ArgParamsSeparator;let t=i(e),r=t.indexOf(D.WarpConstants.ArgParamsSeparator),a=t.substring(0,r),s=t.substring(r+1);return T.Optional+D.WarpConstants.ArgParamsSeparator+a+D.WarpConstants.ArgParamsSeparator+s},it=i=>new D.WarpSerializer().nativeToString(T.List,i);var l=require("@multiversx/sdk-core"),ot=(i,e)=>i?l.OptionValue.newProvided(i):e?l.OptionValue.newMissingTyped(e):l.OptionValue.newMissing(),ct=(i,e)=>i?new l.OptionalValue(i.getType(),i):e?new l.OptionalValue(e):l.OptionalValue.newMissing(),pt=i=>{if(i.length===0)throw new Error("Cannot create a list from an empty array");let e=i[0].getType();return new l.List(e,i)},lt=i=>l.VariadicValue.fromItems(...i),ut=i=>{let e=i.map(t=>t.getType());return new l.CompositeValue(new l.CompositeType(...e),i)},mt=i=>l.StringValue.fromUTF8(i),dt=i=>new l.U8Value(i),ht=i=>new l.U16Value(i),gt=i=>new l.U32Value(i),ft=i=>new l.U64Value(i),yt=i=>new l.BigUIntValue(BigInt(i)),Tt=i=>new l.BooleanValue(i),vt=i=>new l.AddressValue(l.Address.newFromBech32(i)),wt=i=>new l.TokenIdentifierValue(i),Wt=i=>l.BytesValue.fromHex(i),Ct=i=>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(i.token.identifier),"token_identifier"),new l.Field(new l.U64Value(BigInt(i.token.nonce)),"token_nonce"),new l.Field(new l.BigUIntValue(BigInt(i.amount)),"amount")]),xt=i=>new l.CodeMetadataValue(l.CodeMetadata.newFromBytes(Uint8Array.from(Buffer.from(i,"hex")))),At=()=>new l.NothingValue;0&&(module.exports={ExplorerUrls,KnownTokens,MultiversxExplorers,MultiversxExplorersConfig,NativeTokenEgld,NativeTokenVibe,VibechainExplorers,WarpMultiversxAbiBuilder,WarpMultiversxBrandBuilder,WarpMultiversxBuilder,WarpMultiversxConstants,WarpMultiversxContractLoader,WarpMultiversxDataLoader,WarpMultiversxExecutor,WarpMultiversxExplorer,WarpMultiversxInputTypes,WarpMultiversxRegistry,WarpMultiversxResults,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 ge=Object.defineProperty;var $e=Object.getOwnPropertyDescriptor;var ze=Object.getOwnPropertyNames;var Ke=Object.prototype.hasOwnProperty;var qe=(i,e)=>{for(var t in e)ge(i,t,{get:e[t],enumerable:!0})},Qe=(i,e,t,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let a of ze(e))!Ke.call(i,a)&&a!==t&&ge(i,a,{get:()=>e[a],enumerable:!(r=$e(e,a))||r.enumerable});return i};var je=i=>Qe(ge({},"__esModule",{value:!0}),i);var Et={};qe(Et,{ExplorerUrls:()=>H,KnownTokens:()=>ye,MultiversxExplorers:()=>Oe,MultiversxExplorersConfig:()=>ve,NativeTokenEgld:()=>de,NativeTokenVibe:()=>Ge,VibechainExplorers:()=>Le,WarpMultiversxAbiBuilder:()=>M,WarpMultiversxBrandBuilder:()=>ne,WarpMultiversxBuilder:()=>ae,WarpMultiversxConstants:()=>Je,WarpMultiversxContractLoader:()=>re,WarpMultiversxDataLoader:()=>se,WarpMultiversxExecutor:()=>ie,WarpMultiversxExplorer:()=>oe,WarpMultiversxInputTypes:()=>T,WarpMultiversxRegistry:()=>pe,WarpMultiversxResults:()=>q,WarpMultiversxSerializer:()=>O,WarpMultiversxWallet:()=>le,address_value:()=>vt,asset_value:()=>Ct,biguint_value:()=>yt,boolean_value:()=>Tt,codemeta:()=>at,codemeta_value:()=>xt,composite_value:()=>ut,createMultiversxAdapter:()=>ue,findKnownTokenById:()=>Te,getAllMultiversxAdapters:()=>tt,getAllMultiversxChainNames:()=>rt,getKnownTokensForChain:()=>Xe,getMultiversxAdapter:()=>Ce,getMultiversxEntrypoint:()=>w,getMultiversxRegistryAddress:()=>I,getNormalizedTokenIdentifier:()=>te,getVibechainAdapter:()=>Ae,hex_value:()=>Wt,isNativeToken:()=>$,list:()=>it,list_value:()=>pt,nothing_value:()=>At,option_value:()=>ot,optional:()=>st,optional_value:()=>ct,string_value:()=>mt,toTypedConfigInfo:()=>We,toTypedRegistryInfo:()=>ce,token:()=>nt,token_value:()=>wt,u16_value:()=>ht,u32_value:()=>gt,u64_value:()=>ft,u8_value:()=>dt,variadic_value:()=>lt});module.exports=je(Et);var Ee=require("@vleap/warps");var Y=require("@vleap/warps");var _e=require("@vleap/warps");var R=require("@multiversx/sdk-core"),E=require("@vleap/warps");var j=require("@multiversx/sdk-core"),be=require("@vleap/warps"),$=i=>!i.includes("-"),te=i=>$(i)?`${i}-000000`:i,w=(i,e,t)=>{let r="warp-sdk",s=t?(0,be.getProviderConfig)(t,i.name,e,i.defaultApiUrl):{url:i.defaultApiUrl},o=s.url,p={headers:s.headers};return e==="devnet"?new j.DevnetEntrypoint({url:o,kind:"api",clientName:r,networkProviderConfig:p}):e==="testnet"?new j.TestnetEntrypoint({url:o,kind:"api",clientName:r,networkProviderConfig:p}):new j.MainnetEntrypoint({url:o,kind:"api",clientName:r,networkProviderConfig:p})};var fe=require("@vleap/warps");var re=class{constructor(e){this.config=e}async getContract(e,t){try{let s=await w(t,this.config.env,this.config).createNetworkProvider().doGetGeneric(`accounts/${e}`);return{address:e,owner:s.ownerAddress,verified:s.isVerified||!1}}catch(r){return fe.WarpLogger.error("WarpContractLoader: getContract error",r),null}}async getVerificationInfo(e,t){try{let s=await w(t,this.config.env,this.config).createNetworkProvider().doGetGeneric(`accounts/${e}/verification`);return{codeHash:s.codeHash,abi:s.source.abi}}catch(r){return fe.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 R.TransactionsFactoryConfig({chainID:this.chain.chainId}),a=new R.TransferTransactionsFactory({config:r}),s=R.Address.newFromBech32(t),o={protocol:(0,E.getLatestProtocolIdentifier)("abi"),content:e},p=JSON.stringify(o),c=await a.createTransactionForTransfer(s,{receiver:s,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),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 s=w(this.chain,this.config.env,this.config).createNetworkProvider();try{let o=await s.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 R.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 R.AbiRegistry.create(r.content)}else{let r=await(await fetch(e.abi)).json();return R.AbiRegistry.create(r)}}};var z=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 z.TransactionsFactoryConfig({chainID:this.chain.chainId}),a=new z.TransferTransactionsFactory({config:r}),s=z.Address.newFromBech32(t),o=JSON.stringify(e);return await a.createTransactionForNativeTokenTransfer(s,{receiver:z.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={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=w(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 K=require("@multiversx/sdk-core"),P=require("@vleap/warps");var ae=class extends P.WarpBuilder{constructor(t,r){super(t);this.config=t;this.chain=r;this.cache=new P.WarpCache(t.cache?.type),this.core=new P.WarpBuilder(t)}async createInscriptionTransaction(t){let r=(0,P.getWarpWalletAddressFromConfig)(this.config,this.chain.name);if(!r)throw new Error("WarpBuilder: user address not set");let a=new K.TransactionsFactoryConfig({chainID:this.chain.chainId}),s=new K.TransferTransactionsFactory({config:a}),o=K.Address.newFromBech32(r),p=JSON.stringify(t),c=await s.createTransactionForTransfer(o,{receiver:K.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,P.createWarpIdentifier)(this.chain.name,"hash",t.hash),hash:t.hash,creator:t.sender.toBech32(),createdAt:new Date(t.timestamp*1e3).toISOString()},a}async createFromTransactionHash(t,r){let a=P.WarpCacheKey.Warp(this.config.env,t);if(r){let p=this.cache.get(a);if(p)return P.WarpLogger.info(`WarpBuilder (createFromTransactionHash): Warp found in cache: ${t}`),p}let o=w(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 P.WarpLogger.error("WarpBuilder: Error creating from transaction hash",p),null}}};var G=require("@multiversx/sdk-core"),X=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"),S=Ne.WarpChainName.Multiversx,Ve=[{chain:S,identifier:"EGLD",name:"eGold",symbol:"EGLD",decimals:18,logoUrl:"https://tools.multiversx.com/assets-cdn/tokens/EGLD-000000/icon.png"},{chain:S,identifier:"EGLD-000000",name:"eGold",symbol:"EGLD",decimals:18,logoUrl:"https://tools.multiversx.com/assets-cdn/tokens/EGLD-000000/icon.png"},{chain:S,identifier:"SEGLD-3ad2d0",name:"StakedEGLD",symbol:"SEGLD",decimals:18,logoUrl:"https://tools.multiversx.com/assets-cdn/tokens/SEGLD-3ad2d0/icon.png"},{chain:S,identifier:"HSEGLD-c13a4e",name:"HatomSEGLD",symbol:"HSEGLD",decimals:8,logoUrl:"https://tools.multiversx.com/assets-cdn/tokens/HSEGLD-c13a4e/icon.png"},{chain:S,identifier:"UTK-2f80e9",name:"xMoney UTK",symbol:"UTK",decimals:18,logoUrl:"https://tools.multiversx.com/assets-cdn/tokens/UTK-2f80e9/icon.png"},{chain:S,identifier:"USDC-c76f1f",name:"WrappedUSDC",symbol:"USDC",decimals:6,logoUrl:"https://tools.multiversx.com/assets-cdn/tokens/USDC-c76f1f/icon.png"},{chain:S,identifier:"WEGLD-bd4d79",name:"WrappedEGLD",symbol:"WEGLD",decimals:18,logoUrl:"https://tools.multiversx.com/assets-cdn/tokens/WEGLD-bd4d79/icon.png"},{chain:S,identifier:"HTM-f51d55",name:"Hatom",symbol:"HTM",decimals:18,logoUrl:"https://tools.multiversx.com/assets-cdn/tokens/HTM-f51d55/icon.png"},{chain:S,identifier:"MEX-455c57",name:"MEX",symbol:"MEX",decimals:18,logoUrl:"https://tools.multiversx.com/assets-cdn/tokens/MEX-455c57/icon.png"},{chain:S,identifier:"WTAO-4f5363",name:"WrappedTAO",symbol:"WTAO",decimals:9,logoUrl:"https://tools.multiversx.com/assets-cdn/tokens/WTAO-4f5363/icon.png"},{chain:S,identifier:"HEGLD-d61095",name:"HatomEGLD",symbol:"HEGLD",decimals:8,logoUrl:"https://tools.multiversx.com/assets-cdn/tokens/HEGLD-d61095/icon.png"},{chain:S,identifier:"WBTC-5349b3",name:"WrappedBTC",symbol:"WBTC",decimals:8,logoUrl:"https://tools.multiversx.com/assets-cdn/tokens/WBTC-5349b3/icon.png"},{chain:S,identifier:"WETH-b4ca29",name:"WrappedETH",symbol:"WETH",decimals:18,logoUrl:"https://tools.multiversx.com/assets-cdn/tokens/WETH-b4ca29/icon.png"},{chain:S,identifier:"USH-111e09",name:"HatomUSD",symbol:"USH",decimals:18,logoUrl:"https://tools.multiversx.com/assets-cdn/tokens/USH-111e09/icon.png"},{chain:S,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"),Re=Me.WarpChainName.Vibechain,me=[{chain:Re,identifier:"VIBE",name:"VIBE",symbol:"VIBE",decimals:18,logoUrl:"https://vleap.ai/images/tokens/vibe.svg"},{chain:Re,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}},Te=(i,e,t)=>(ye[i]?.[e]||[]).find(a=>a.identifier===t)||null,Xe=(i,e)=>ye[i]?.[e]||[];var se=class{constructor(e,t){this.config=e;this.chain=t;this.cache=new X.WarpCache(e.cache?.type)}async getAccount(e){let r=await w(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=w(this.chain,this.config.env,this.config).createNetworkProvider(),r=t.getAccount(G.Address.newFromBech32(e)),a=t.getFungibleTokensOfAccount(G.Address.newFromBech32(e)),[s,o]=await Promise.all([r,a]),p=s.balance>0?[{...this.chain.nativeToken,amount:s.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=X.WarpCacheKey.Asset(this.config.env,this.chain.name,e),r=this.cache.get(t);if(r)return r;let a=Te(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 s=new G.TokenComputer,o=$(e)?0n:s.extractNonceFromExtendedIdentifier(e),p=new G.Token({identifier:e,nonce:BigInt(o||0)}),c=s.isFungible(p),f=w(this.chain,this.config.env,this.config).createNetworkProvider(),g=te(e),d=await f.doGetGeneric(`tokens/${g}`),v={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,v,X.CacheTtl.OneHour),v}async getAction(e,t=!1){let r=w(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(s=>s.raw.returnMessage)[0]||null,tx:a}}async getAccountActions(e,t){let r=w(this.chain,this.config.env,this.config).createNetworkProvider(),a=`accounts/${e}/transactions`,s=new URLSearchParams,o=t?.size||25,p=t?.page||0;if(p>0){let f=p*o;s.append("from",f.toString())}return o!==25&&s.append("size",o.toString()),s.toString()&&(a+=`?${s.toString()}`),(await r.doGetGeneric(a)).map(f=>({chain:this.chain.name,id:f.txHash,receiver:f.receiver,sender:f.sender,value:f.value,function:f.function,status:this.toActionStatus(f),createdAt:this.toActionCreatedAt(f)}))}toActionStatus(e){return e.status.isSuccessful()?"success":e.status.isFailed()?"failed":"pending"}toActionCreatedAt(e){return new Date(e.timestamp||e.timestamp*1e3).toISOString()}};var C=require("@multiversx/sdk-core"),k=require("@vleap/warps");var J=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:i=>i.config.user?.wallets?.[i.chain.name]},ChainApiUrl:{Placeholder:"CHAIN_API",Accessor:i=>i.chain.defaultApiUrl},ChainAddressHrp:{Placeholder:"CHAIN_ADDRESS_HRP",Accessor:i=>i.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}},T={Null:"null",Optional:"optional",List:"list",Token:"token",CodeMeta:"codemeta"},Oe=(r=>(r.MultiversxExplorer="multiversx_explorer",r.MultiversxExplorerDevnet="multiversx_explorer_devnet",r.MultiversxExplorerTestnet="multiversx_explorer_testnet",r))(Oe||{}),Le=(r=>(r.VibechainExplorer="vibechain_explorer",r.VibechainExplorerDevnet="vibechain_explorer_devnet",r.VibechainExplorerTestnet="vibechain_explorer_testnet",r))(Le||{}),ve={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}(.*)`),O=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 g=this.typeToString(t.getFirstTypeParameter());return u.Vector+h.ArgParamsSeparator+g+h.ArgParamsSeparator}let a=r.map(g=>this.typedToString(g));if(a.every(g=>g.startsWith(u.Tuple)))return u.Vector+h.ArgParamsSeparator+a.join(",");let s=a[0],o=s.indexOf(h.ArgParamsSeparator),p=s.substring(0,o),c=a.map(g=>{let d=g.indexOf(h.ArgParamsSeparator);return g.substring(d+1)}),f=p.startsWith(u.Struct)?h.ArgStructSeparator:h.ArgListSeparator;return u.Vector+h.ArgParamsSeparator+p+h.ArgParamsSeparator+c.join(f)}if(t.hasExactClass(n.OptionalType.ClassName)||e.hasClassOrSuperclass(n.OptionalValue.ClassName)){if(!e.isSet())return T.Optional+h.ArgParamsSeparator+"null";let r=this.typedToString(e.getTypedValue());return T.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 T.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 T.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(s=>{let o=this.typedToString(s),p=o.indexOf(h.ArgParamsSeparator),c=o.substring(0,p),f=o.substring(p+1);return`${c},${f}`});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(),s=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+s}if(t.hasExactClass(n.StructType.ClassName)||e.hasClassOrSuperclass(n.Struct.ClassName)){let r=e,s=r.getType().getName(),o=r.getFields();if(o.length===0)return`${u.Struct}(${s})${h.ArgParamsSeparator}`;let p=o.map(c=>{let f=c.value.getType(),d=this.typedToString(c.value).split(h.ArgParamsSeparator),v=d.length>2?d.slice(2).join(h.ArgParamsSeparator):d[1]||"";return`(${c.name}${h.ArgParamsSeparator}${this.typeToString(f)})${v}`});return`${u.Struct}(${s})${h.ArgParamsSeparator}${p.join(h.ArgListSeparator)}`}if(t.hasExactClass(n.TokenIdentifierType.ClassName)||e.hasClassOrSuperclass(n.TokenIdentifierValue.ClassName))return T.Token+h.ArgParamsSeparator+e.valueOf();if(t.hasExactClass(n.CodeMetadataType.ClassName)||e.hasClassOrSuperclass(n.CodeMetadataValue.ClassName))return T.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 s=0;s<r.length;s+=2)a.push(r[s]);return new n.CompositeType(...a.map(s=>this.nativeToType(s)))}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===T.Token)return new n.TokenIdentifierType;if(e===T.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),s=r.substring(0,a),o=r.substring(a+1);if(s.startsWith(u.Tuple)){let d=o.split(",").map(v=>this.stringToTyped(v));return new n.VariadicValue(new n.VariadicType(this.nativeToType(s)),d)}if(o.includes("tuple(")){let g=this.splitTupleStrings(o),d=g.map(x=>this.stringToTyped(x)),b=g[0].match(/^(tuple\([^)]+\))/),y=b?b[1]:"tuple";return new n.VariadicValue(new n.VariadicType(this.nativeToType(y)),d)}let p=s.startsWith(u.Struct)?h.ArgStructSeparator:h.ArgListSeparator,f=o.split(p).map(g=>this.stringToTyped(`${s}:${g}`));return new n.VariadicValue(new n.VariadicType(this.nativeToType(s)),f)}if(t.startsWith(u.Tuple)){let a=t.match(/\(([^)]+)\)/)?.[1];if(!a)throw new Error(`Invalid tuple format: ${t}`);let s=a.split(","),o=[];for(let c=0;c<s.length;c+=2){let f=s[c],g=s[c+1];o.push(this.stringToTyped(`${f}:${g}`))}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(/\(([^)]+)\)/),s=a?a[1]:"CustomStruct";if(!r)return new n.Struct(new n.StructType(s,[]),[]);let o=r.split(h.ArgListSeparator),p=[],c=[];return o.forEach(f=>{let g=f.match(new RegExp(`^\\(([^${h.ArgParamsSeparator}]+)${h.ArgParamsSeparator}([^)]+)\\)(.+)$`));if(g){let[,d,v,b]=g,y=this.stringToTyped(`${v}${h.ArgParamsSeparator}${b}`);p.push(new n.FieldDefinition(d,"",y.getType())),c.push(new n.Field(y,d))}}),new n.Struct(new n.StructType(s,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,s]=r.split(h.ArgCompositeSeparator),o=new n.TokenComputer,p=$(a)?te(a):o.extractIdentifierFromExtendedIdentifier(a),c=$(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(s)),"amount")])}if(t===T.Null)return new n.NothingValue;if(t===T.Optional){let a=this.stringToTyped(r);return a instanceof n.NothingValue?n.OptionalValue.newMissing():new n.OptionalValue(a.getType(),a)}if(t===T.List){let[a,s]=r.split(Ye,2),p=s.split(h.ArgListSeparator).map(c=>this.stringToTyped(a+h.ArgParamsSeparator+c));return new n.List(this.nativeToType(a),p)}if(t===T.Token)return r?new n.TokenIdentifierValue(r):new n.NothingValue;if(t===T.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 s=0;s<e.length;s++){let o=e[s];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 T.Token;if(e.hasExactClass(n.OptionalType.ClassName))return T.Optional+h.ArgParamsSeparator+this.typeToString(e.getFirstTypeParameter());if(e.hasExactClass(n.ListType.ClassName))return T.List+h.ArgParamsSeparator+this.typeToString(e.getFirstTypeParameter());if(e.hasExactClass(n.CodeMetadataType.ClassName))return T.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 q=class{constructor(e,t,r){this.config=e;this.chain=t;this.typeRegistry=r;this.abi=new M(e,t),this.serializer=new O({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))??[],s=await this.extractContractResults(e,t,r,a),o=(0,W.getNextInfo)(this.config,[],e,t,s),p=(0,W.applyResultsToMessages)(e,s.results);return{success:r.status.isSuccessful(),warp:e,action:t,user:(0,W.getWarpWalletAddressFromConfig)(this.config,this.chain.name),txHash:r.hash,tx:r,next:o,values:s.values,results:s.results,messages:p}}async extractContractResults(e,t,r,a){let s=(0,W.getWarpActionByIndex)(e,t),o=[],p=[],c={};if(!e.results||s.type!=="contract")return{values:{string:o,native:p},results:c};if(!Object.values(e.results).some(y=>y.includes("out")||y.includes("event"))){for(let[y,x]of Object.entries(e.results))c[y]=x;return{values:{string:o,native:p},results:await(0,W.evaluateResultsCommon)(e,c,t,a,this.serializer.coreSerializer,this.config.transform?.runner)}}let g=await this.abi.getAbiForAction(s),d=new J.TransactionEventsParser({abi:g}),b=new J.SmartContractTransactionsOutcomeParser({abi:g}).parseExecute({transactionOnNetwork:r,function:s.func||void 0});for(let[y,x]of Object.entries(e.results)){if(x.startsWith(W.WarpConstants.Transform.Prefix))continue;if(x.startsWith("input.")){c[y]=x;continue}let B=(0,W.parseResultsOutIndex)(x);if(B!==null&&B!==t){c[y]=null;continue}let[F,U,Z]=x.split(".");if(F==="event"){if(!U||isNaN(Number(Z)))continue;let Q=Number(Z),A=(0,J.findEventsByFirstTopic)(r,U),He=d.parseEvents({events:A})[0],ee=Object.values(He)[Q]||null;o.push(String(ee)),p.push(ee),c[y]=ee&&ee.valueOf()}else if(F==="out"||F.startsWith("out[")){if(!U)continue;let Q=Number(U),A=b.values[Q-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},results:await(0,W.evaluateResultsCommon)(e,c,t,a,this.serializer.coreSerializer)}}async extractQueryResults(e,t,r,a){let s=t.map(g=>this.serializer.typedToString(g)),o=t.map(g=>this.serializer.typedToNative(g)[1]),p={string:s,native:o},c={};if(!e.results)return{values:p,results:c};let f=g=>{let d=g.split(".").slice(1).map(b=>parseInt(b)-1);if(d.length===0)return;let v=o[d[0]];for(let b=1;b<d.length;b++){if(v==null)return;v=v[d[b]]}return v};for(let[g,d]of Object.entries(e.results)){if(d.startsWith(W.WarpConstants.Transform.Prefix))continue;let v=(0,W.parseResultsOutIndex)(d);if(v!==null&&v!==r){c[g]=null;continue}d.startsWith("out.")||d==="out"||d.startsWith("out[")?c[g]=f(d)||null:c[g]=d}return{values:p,results:await(0,W.evaluateResultsCommon)(e,c,r,a,this.serializer.coreSerializer)}}async resolveWarpResultsRecursively(e){let t=e.warp,r=e.entryActionIndex,a=e.executor,s=e.inputs,o=e.meta,p=new Map,c=new Set,f=this;async function g(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 B=t.actions[y-1];if(!B)throw new Error(`Action ${y} not found`);let F;if(B.type==="query")F=await a.executeQuery(t,y,x);else if(B.type==="collect")F=await a.executeCollect(t,y,x,o);else throw new Error(`Unsupported or interactive action type: ${B.type}`);if(p.set(y,F),t.results)for(let U of Object.values(t.results)){let Q=String(U).match(/^out\[(\d+)\]/);if(Q){let A=parseInt(Q[1],10);A!==y&&!p.has(A)&&await g(A)}}return c.delete(y),F}await g(r,s);let d={};for(let y of p.values())for(let[x,B]of Object.entries(y.results))B!==null?d[x]=B:x in d||(d[x]=null);let v=await(0,W.evaluateResultsCommon)(t,d,r,s,this.serializer.coreSerializer,this.config.transform?.runner);return{...p.get(r),action:r,results:v}}};var Ze="EGLD-000000",ie=class{constructor(e,t,r){this.config=e;this.chain=t;this.typeRegistry=r;this.serializer=new O({typeRegistry:this.typeRegistry}),this.abi=new M(this.config,this.chain),this.results=new q(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){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}),s=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:s?new Uint8Array(s):void 0})}async createContractCallTransaction(e){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),s=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:s,tokenTransfers:this.toTokenTransfers(e.transfers),nativeTransferAmount:e.value})}async executeQuery(e){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(U=>this.serializer.stringToTyped(U)),s=w(e.chain,this.config.env,this.config),o=C.Address.newFromBech32(e.destination),p=s.createSmartContractController(r),c=p.createQuery({contract:o,function:t.func||"",arguments:a}),f=await p.runQuery(c),g=f.returnCode==="ok",d=new C.ArgSerializer,v=r.getEndpoint(f.function||t.func||""),b=(f.returnDataParts||[]).map(U=>Buffer.from(U)),y=d.buffersToValues(b,v.output),{values:x,results:B}=await this.results.extractQueryResults(e.warp,y,e.action,e.resolvedInputs),F=(0,k.getNextInfo)(this.config,[],e.warp,e.action,B);return{success:g,warp:e.warp,action:e.action,user:(0,k.getWarpWalletAddressFromConfig)(this.config,e.chain.name),txHash:null,tx:null,next:F,values:x,results:B,messages:(0,k.applyResultsToMessages)(e.warp,B)}}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=ve[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 s=H[t];if(s)return s}if(e){let s=H[e];if(s)return s}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 s=H[a];s&&(r[a]=`${s}/accounts/${e}`)}),r}getTransactionUrls(e){let t=this.getAllExplorers(),r={};return t.forEach(a=>{let s=H[a];s&&(r[a]=`${s}/transactions/${e}`)}),r}};var m=require("@multiversx/sdk-core"),N=require("@vleap/warps");var we={buildInfo:{rustc:{version:"1.86.0",commitHash:"05f9846f893b09a1be1fc8560e33fc3c815cfecb",commitDate:"2025-03-31",channel:"Stable",short:"rustc 1.86.0 (05f9846f8 2025-03-31)"},contractCrate:{name:"registry",version:"0.0.1"},framework:{name:"multiversx-sc",version:"0.51.1"}},name:"RegistryContract",constructor:{inputs:[{name:"unit_price",type:"BigUint"},{name:"vault",type:"Address"}],outputs:[]},upgradeConstructor:{inputs:[],outputs:[]},endpoints:[{name:"registerWarp",mutability:"mutable",payableInTokens:["EGLD"],inputs:[{name:"hash",type:"bytes"},{name:"alias_opt",type:"optional<bytes>",multi_arg:!0},{name:"brand_opt",type:"optional<bytes>",multi_arg:!0}],outputs:[],allow_multiple_var_args:!0},{name:"unregisterWarp",mutability:"mutable",inputs:[{name:"warp",type:"bytes"}],outputs:[]},{name:"upgradeWarp",mutability:"mutable",payableInTokens:["EGLD"],inputs:[{name:"alias",type:"bytes"},{name:"new_warp",type:"bytes"},{name:"brand_opt",type:"optional<bytes>",multi_arg:!0}],outputs:[]},{name:"setWarpAlias",mutability:"mutable",payableInTokens:["EGLD"],inputs:[{name:"hash",type:"bytes"},{name:"alias",type:"bytes"}],outputs:[]},{name:"forceRemoveAlias",mutability:"mutable",inputs:[{name:"hash",type:"bytes"}],outputs:[]},{name:"verifyWarp",mutability:"mutable",inputs:[{name:"warp",type:"bytes"}],outputs:[]},{name:"transferOwnership",mutability:"mutable",inputs:[{name:"warp",type:"bytes"},{name:"new_owner",type:"Address"}],outputs:[]},{name:"getUserWarps",mutability:"readonly",inputs:[{name:"address",type:"Address"}],outputs:[{type:"variadic<InfoView>",multi_result:!0}]},{name:"getInfoByAlias",mutability:"readonly",inputs:[{name:"alias",type:"bytes"}],outputs:[{type:"InfoView"}]},{name:"getInfoByHash",mutability:"readonly",inputs:[{name:"hash",type:"bytes"}],outputs:[{type:"InfoView"}]},{name:"setVault",onlyOwner:!0,mutability:"mutable",inputs:[{name:"vault",type:"Address"}],outputs:[]},{name:"setUnitPrice",onlyOwner:!0,mutability:"mutable",inputs:[{name:"amount",type:"BigUint"}],outputs:[]},{name:"addAdmin",onlyOwner:!0,mutability:"mutable",inputs:[{name:"address",type:"Address"}],outputs:[]},{name:"removeAdmin",onlyOwner:!0,mutability:"mutable",inputs:[{name:"address",type:"Address"}],outputs:[]},{name:"getConfig",mutability:"readonly",inputs:[],outputs:[{type:"ConfigView"}]},{name:"registerBrand",mutability:"mutable",payableInTokens:["EGLD"],inputs:[{name:"hash",type:"bytes"}],outputs:[]},{name:"brandWarp",mutability:"mutable",payableInTokens:["EGLD"],inputs:[{name:"warp",type:"bytes"},{name:"brand",type:"bytes"}],outputs:[]},{name:"getUserBrands",mutability:"readonly",inputs:[{name:"user",type:"Address"}],outputs:[{type:"variadic<bytes>",multi_result:!0}]}],events:[{identifier:"warpRegistered",inputs:[{name:"hash",type:"bytes",indexed:!0},{name:"alias",type:"bytes",indexed:!0},{name:"trust",type:"bytes",indexed:!0}]},{identifier:"warpUnregistered",inputs:[{name:"hash",type:"bytes",indexed:!0}]},{identifier:"warpUpgraded",inputs:[{name:"alias",type:"bytes",indexed:!0},{name:"new_warp",type:"bytes",indexed:!0},{name:"trust",type:"bytes",indexed:!0}]},{identifier:"warpVerified",inputs:[{name:"hash",type:"bytes",indexed:!0}]},{identifier:"aliasUpdated",inputs:[{name:"hash",type:"bytes",indexed:!0},{name:"alias",type:"bytes",indexed:!0}]},{identifier:"ownershipTransferred",inputs:[{name:"warp",type:"bytes",indexed:!0},{name:"old_owner",type:"Address",indexed:!0},{name:"new_owner",type:"Address",indexed:!0}]}],esdtAttributes:[],hasCallback:!1,types:{ConfigView:{type:"struct",fields:[{name:"unit_price",type:"BigUint"},{name:"admins",type:"List<Address>"}]},InfoView:{type:"struct",fields:[{name:"hash",type:"bytes"},{name:"alias",type:"Option<bytes>"},{name:"trust",type:"bytes"},{name:"owner",type:"Address"},{name:"created_at",type:"u64"},{name:"upgraded_at",type:"u64"},{name:"brand",type:"Option<bytes>"},{name:"upgrade",type:"Option<bytes>"}]}}};var I=i=>{if(i==="devnet")return"erd1qqqqqqqqqqqqqpgqje2f99vr6r7sk54thg03c9suzcvwr4nfl3tsfkdl36";if(i==="testnet")throw new Error("Multiversx testnet is not supported");return"erd1qqqqqqqqqqqqqpgq3mrpj3u6q7tejv6d7eqhnyd27n9v5c5tl3ts08mffe"};var ce=i=>({hash:i.hash.toString("hex"),alias:i.alias?.toString()||null,trust:i.trust.toString(),owner:i.owner.toString(),createdAt:i.created_at.toNumber(),upgradedAt:i.upgraded_at?.toNumber(),brand:i.brand?.toString("hex")||null,upgrade:i.upgrade?.toString("hex")||null}),We=i=>({unitPrice:BigInt(i.unit_price.toString()),admins:i.admins.map(e=>e.toBech32())});var pe=class{constructor(e,t){this.config=e;this.chain=t;this.cache=new N.WarpCache(e.cache?.type),this.registryConfig={unitPrice:BigInt(0),admins:[]},this.userWallet=(0,N.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),s=()=>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(I(this.config.env)),function:"registerWarp",gasLimit:BigInt(1e7),nativeTransferAmount:s(),arguments:o()})}async createWarpUnregisterTransaction(e){if(!this.userWallet)throw new Error("WarpRegistry: user address not set");let t=m.Address.newFromBech32(this.userWallet);return await this.getFactory().createTransactionForExecute(t,{contract:m.Address.newFromBech32(I(this.config.env)),function:"unregisterWarp",gasLimit:BigInt(1e7),arguments:[m.BytesValue.fromHex(e)]})}async createWarpUpgradeTransaction(e,t,r){if(this.registryConfig.unitPrice===BigInt(0))throw new Error("WarpRegistry: config not loaded. forgot to call init()?");if(!this.userWallet)throw new Error("WarpRegistry: user address not set");let a=m.Address.newFromBech32(this.userWallet);return await this.getFactory().createTransactionForExecute(a,{contract:m.Address.newFromBech32(I(this.config.env)),function:"upgradeWarp",gasLimit:BigInt(1e7),nativeTransferAmount:this.isCurrentUserAdmin()?void 0:this.registryConfig.unitPrice,arguments:r?[m.BytesValue.fromUTF8(e),m.BytesValue.fromHex(t),m.BytesValue.fromHex(r)]:[m.BytesValue.fromUTF8(e),m.BytesValue.fromHex(t)]})}async createWarpAliasSetTransaction(e,t){if(!this.userWallet)throw new Error("WarpRegistry: user address not set");let r=m.Address.newFromBech32(this.userWallet);return await this.getFactory().createTransactionForExecute(r,{contract:m.Address.newFromBech32(I(this.config.env)),function:"setWarpAlias",gasLimit:BigInt(1e7),nativeTransferAmount:this.isCurrentUserAdmin()?void 0:this.registryConfig.unitPrice,arguments:[m.BytesValue.fromHex(e),m.BytesValue.fromUTF8(t)]})}async createWarpVerifyTransaction(e){if(!this.userWallet)throw new Error("WarpRegistry: user address not set");let t=m.Address.newFromBech32(this.userWallet);return await this.getFactory().createTransactionForExecute(t,{contract:m.Address.newFromBech32(I(this.config.env)),function:"verifyWarp",gasLimit:BigInt(1e7),arguments:[m.BytesValue.fromHex(e)]})}async createWarpTransferOwnershipTransaction(e,t){if(!this.userWallet)throw new Error("WarpRegistry: user address not set");let r=m.Address.newFromBech32(this.userWallet);return await this.getFactory().createTransactionForExecute(r,{contract:m.Address.newFromBech32(I(this.config.env)),function:"transferOwnership",gasLimit:BigInt(1e7),arguments:[m.BytesValue.fromHex(e),new m.AddressValue(new m.Address(t))]})}async createBrandRegisterTransaction(e){if(this.registryConfig.unitPrice===BigInt(0))throw new Error("WarpRegistry: config not loaded. forgot to call init()?");if(!this.userWallet)throw new Error("WarpRegistry: user address not set");let t=m.Address.newFromBech32(this.userWallet);return await this.getFactory().createTransactionForExecute(t,{contract:m.Address.newFromBech32(I(this.config.env)),function:"registerBrand",gasLimit:BigInt(1e7),nativeTransferAmount:this.isCurrentUserAdmin()?void 0:this.registryConfig.unitPrice,arguments:[m.BytesValue.fromHex(e)]})}async createWarpBrandingTransaction(e,t){if(!this.userWallet)throw new Error("WarpRegistry: user address not set");let r=m.Address.newFromBech32(this.userWallet);return await this.getFactory().createTransactionForExecute(r,{contract:m.Address.newFromBech32(I(this.config.env)),function:"brandWarp",gasLimit:BigInt(1e7),nativeTransferAmount:this.isCurrentUserAdmin()?void 0:this.registryConfig.unitPrice,arguments:[m.BytesValue.fromHex(e),m.BytesValue.fromHex(t)]})}async getInfoByAlias(e,t){try{let r=N.WarpCacheKey.RegistryInfo(this.config.env,e),a=t?this.cache.get(r):null;if(a)return N.WarpLogger.info(`WarpRegistry (getInfoByAlias): RegistryInfo found in cache: ${e}`),a;let s=m.Address.newFromBech32(I(this.config.env)),o=this.getController(),p=o.createQuery({contract:s,function:"getInfoByAlias",arguments:[m.BytesValue.fromUTF8(e)]}),c=await o.runQuery(p),[f]=o.parseQueryResponse(c),g=f?ce(f):null,d=g?.brand?await this.fetchBrand(g.brand):null;return t&&t.ttl&&this.cache.set(r,{registryInfo:g,brand:d},t.ttl),{registryInfo:g,brand:d}}catch{return{registryInfo:null,brand:null}}}async getInfoByHash(e,t){try{let r=N.WarpCacheKey.RegistryInfo(this.config.env,e);if(t){let d=this.cache.get(r);if(d)return N.WarpLogger.info(`WarpRegistry (getInfoByHash): RegistryInfo found in cache: ${e}`),d}let a=m.Address.newFromBech32(I(this.config.env)),s=this.getController(),o=s.createQuery({contract:a,function:"getInfoByHash",arguments:[m.BytesValue.fromHex(e)]}),p=await s.runQuery(o),[c]=s.parseQueryResponse(p),f=c?ce(c):null,g=f?.brand?await this.fetchBrand(f.brand):null;return t&&t.ttl&&this.cache.set(r,{registryInfo:f,brand:g},t.ttl),{registryInfo:f,brand:g}}catch{return{registryInfo:null,brand:null}}}async getUserWarpRegistryInfos(e){try{let t=e||this.userWallet;if(!t)throw new Error("WarpRegistry: user address not set");let r=m.Address.newFromBech32(I(this.config.env)),a=this.getController(),s=a.createQuery({contract:r,function:"getUserWarps",arguments:[new m.AddressValue(new m.Address(t))]}),o=await a.runQuery(s),[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(I(this.config.env)),a=this.getController(),s=a.createQuery({contract:r,function:"getUserBrands",arguments:[new m.AddressValue(new m.Address(t))]}),o=await a.runQuery(s),[p]=a.parseQueryResponse(o),c=p.map(d=>d.toString("hex")),f={ttl:365*24*60*60};return(await Promise.all(c.map(d=>this.fetchBrand(d,f)))).filter(d=>d!==null)}catch{return[]}}async fetchBrand(e,t){let r=N.WarpCacheKey.Brand(this.config.env,e),a=t?this.cache.get(r):null;if(a)return N.WarpLogger.info(`WarpRegistry (fetchBrand): Brand found in cache: ${e}`),a;let o=w(this.chain,this.config.env,this.config).createNetworkProvider();try{let p=await o.getTransaction(e),c=JSON.parse(p.data.toString());return c.meta={chain:this.chain.name,identifier:(0,N.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(I(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(we);return new m.SmartContractTransactionsFactory({config:e,abi:t})}getController(){let e=w(this.chain,this.config.env,this.config),t=m.AbiRegistry.create(we);return e.createSmartContractController(t)}isCurrentUserAdmin(){return!!this.userWallet&&this.registryConfig.admins.includes(this.userWallet)}};var V=require("@multiversx/sdk-core"),L=require("@vleap/warps");var le=class{constructor(e,t){this.config=e;this.chain=t;this.entry=w(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("-----")?V.UserSecretKey.fromPem(t):V.UserSecretKey.fromString(t),s=new V.Account(a);if(e.nonce===0n){let p=await this.entry.recallAccountNonce(s.address),c=this.cache.get(`nonce:${s.address.toBech32()}`)||0,f=BigInt(Math.max(c,Number(p)));e.nonce=f}e.signature=await s.signTransaction(e);let o=Number(s.nonce)+1;return this.cache.set(`nonce:${s.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("-----")?V.UserSecretKey.fromPem(t):V.UserSecretKey.fromString(t),o=await new V.Account(a).signMessage(new V.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=V.Mnemonic.fromString(e).deriveKey(0),a=r.hex();return{address:r.generatePublicKey().toAddress(this.chain.addressHrp).toBech32(),privateKey:a,mnemonic:e}}generate(){let e=V.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=(i,e)=>(t,r)=>{let a=e[t.env],s=new _e.WarpTypeRegistry;return s.registerType("token",{stringToNative:o=>o,nativeToString:o=>`token:${o}`}),s.registerType("codemeta",{stringToNative:o=>o,nativeToString:o=>`codemeta:${o}`}),s.registerTypeAlias("list","vector"),{chainInfo:a,builder:()=>new ae(t,a),executor:new ie(t,a,s),results:new q(t,a,s),serializer:new O({typeRegistry:s}),registry:new pe(t,a),explorer:new oe(i,t),abiBuilder:()=>new M(t,a),brandBuilder:()=>new ne(t,a),dataLoader:new se(t,a),wallet:new le(t,a)}};var de={chain:Y.WarpChainName.Multiversx,identifier:"EGLD",name:"eGold",symbol:"EGLD",decimals:18,logoUrl:"https://vleap.ai/images/tokens/egld.svg"},Ce=ue(Y.WarpChainName.Multiversx,{mainnet:{name:Y.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:Y.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:Y.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=(i,e)=>[Ce(i,e),Ae(i,e)],rt=()=>[Ee.WarpChainName.Multiversx,Ee.WarpChainName.Vibechain];var D=require("@vleap/warps");var nt=i=>new D.WarpSerializer().nativeToString(T.Token,i),at=i=>new D.WarpSerializer().nativeToString(T.CodeMeta,i),st=(i,e)=>{if(e===null)return T.Optional+D.WarpConstants.ArgParamsSeparator;let t=i(e),r=t.indexOf(D.WarpConstants.ArgParamsSeparator),a=t.substring(0,r),s=t.substring(r+1);return T.Optional+D.WarpConstants.ArgParamsSeparator+a+D.WarpConstants.ArgParamsSeparator+s},it=i=>new D.WarpSerializer().nativeToString(T.List,i);var l=require("@multiversx/sdk-core"),ot=(i,e)=>i?l.OptionValue.newProvided(i):e?l.OptionValue.newMissingTyped(e):l.OptionValue.newMissing(),ct=(i,e)=>i?new l.OptionalValue(i.getType(),i):e?new l.OptionalValue(e):l.OptionalValue.newMissing(),pt=i=>{if(i.length===0)throw new Error("Cannot create a list from an empty array");let e=i[0].getType();return new l.List(e,i)},lt=i=>l.VariadicValue.fromItems(...i),ut=i=>{let e=i.map(t=>t.getType());return new l.CompositeValue(new l.CompositeType(...e),i)},mt=i=>l.StringValue.fromUTF8(i),dt=i=>new l.U8Value(i),ht=i=>new l.U16Value(i),gt=i=>new l.U32Value(i),ft=i=>new l.U64Value(i),yt=i=>new l.BigUIntValue(BigInt(i)),Tt=i=>new l.BooleanValue(i),vt=i=>new l.AddressValue(l.Address.newFromBech32(i)),wt=i=>new l.TokenIdentifierValue(i),Wt=i=>l.BytesValue.fromHex(i),Ct=i=>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(i.token.identifier),"token_identifier"),new l.Field(new l.U64Value(BigInt(i.token.nonce)),"token_nonce"),new l.Field(new l.BigUIntValue(BigInt(i.amount)),"amount")]),xt=i=>new l.CodeMetadataValue(l.CodeMetadata.newFromBytes(Uint8Array.from(Buffer.from(i,"hex")))),At=()=>new l.NothingValue;0&&(module.exports={ExplorerUrls,KnownTokens,MultiversxExplorers,MultiversxExplorersConfig,NativeTokenEgld,NativeTokenVibe,VibechainExplorers,WarpMultiversxAbiBuilder,WarpMultiversxBrandBuilder,WarpMultiversxBuilder,WarpMultiversxConstants,WarpMultiversxContractLoader,WarpMultiversxDataLoader,WarpMultiversxExecutor,WarpMultiversxExplorer,WarpMultiversxInputTypes,WarpMultiversxRegistry,WarpMultiversxResults,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 Rt}from"@multiversx/sdk-core";import{createWarpIdentifier as Mt,getLatestProtocolIdentifier as Ot,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 k=i=>!i.includes("-"),_=i=>k(i)?`${i}-000000`:i,T=(i,e,t)=>{let r="warp-sdk",a=t?Ut(t,i.name,e,i.defaultApiUrl):{url:i.defaultApiUrl},s=a.url,c={headers:a.headers};return e==="devnet"?new Pt({url:s,kind:"api",clientName:r,networkProviderConfig:c}):e==="testnet"?new Vt({url:s,kind:"api",clientName:r,networkProviderConfig:c}):new Nt({url:s,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 T(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 T(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 Rt({config:r}),a=kt.newFromBech32(t),s={protocol:Ot("abi"),content:e},c=JSON.stringify(s),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),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 s=this.cache.get(r);if(s)return _e.info(`WarpAbiBuilder (createFromTransactionHash): Warp abi found in cache: ${e}`),s}let a=T(this.chain,this.config.env,this.config).createNetworkProvider();try{let s=await a.getTransaction(e),c=await this.createFromTransaction(s);return t&&t.ttl&&c&&this.cache.set(r,c,t.ttl),c}catch(s){return _e.error("WarpAbiBuilder: Error creating from transaction hash",s),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 Kt,WarpLogger as qt}from"@vleap/warps";import{Buffer as Qt}from"buffer";var H=class{constructor(e,t){this.config=e;this.chain=t;this.core=new Kt(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),s=JSON.stringify(e);return await n.createTransactionForNativeTokenTransfer(a,{receiver:Ge.newFromBech32(t),nativeAmount:BigInt(0),data:Uint8Array.from(Qt.from(s))})}async createFromTransaction(e,t=!1){let r=await this.core.createFromRaw(e.data.toString(),t);return r.meta={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=T(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 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}),s=He.newFromBech32(r),c=JSON.stringify(t),o=await a.createTransactionForTransfer(s,{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),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 s=T(this.chain,this.config.env,this.config).createNetworkProvider();try{let c=await s.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 sr,TokenComputer as ir}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 Ke=tr.Multiversx,qe=[{chain:Ke,identifier:"EGLD",name:"eGold",symbol:"EGLD",decimals:18,logoUrl:"https://tools.multiversx.com/assets-cdn/tokens/EGLD-000000/icon.png"},{chain:Ke,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 x=rr.Multiversx,Qe=[{chain:x,identifier:"EGLD",name:"eGold",symbol:"EGLD",decimals:18,logoUrl:"https://tools.multiversx.com/assets-cdn/tokens/EGLD-000000/icon.png"},{chain:x,identifier:"EGLD-000000",name:"eGold",symbol:"EGLD",decimals:18,logoUrl:"https://tools.multiversx.com/assets-cdn/tokens/EGLD-000000/icon.png"},{chain:x,identifier:"SEGLD-3ad2d0",name:"StakedEGLD",symbol:"SEGLD",decimals:18,logoUrl:"https://tools.multiversx.com/assets-cdn/tokens/SEGLD-3ad2d0/icon.png"},{chain:x,identifier:"HSEGLD-c13a4e",name:"HatomSEGLD",symbol:"HSEGLD",decimals:8,logoUrl:"https://tools.multiversx.com/assets-cdn/tokens/HSEGLD-c13a4e/icon.png"},{chain:x,identifier:"UTK-2f80e9",name:"xMoney UTK",symbol:"UTK",decimals:18,logoUrl:"https://tools.multiversx.com/assets-cdn/tokens/UTK-2f80e9/icon.png"},{chain:x,identifier:"USDC-c76f1f",name:"WrappedUSDC",symbol:"USDC",decimals:6,logoUrl:"https://tools.multiversx.com/assets-cdn/tokens/USDC-c76f1f/icon.png"},{chain:x,identifier:"WEGLD-bd4d79",name:"WrappedEGLD",symbol:"WEGLD",decimals:18,logoUrl:"https://tools.multiversx.com/assets-cdn/tokens/WEGLD-bd4d79/icon.png"},{chain:x,identifier:"HTM-f51d55",name:"Hatom",symbol:"HTM",decimals:18,logoUrl:"https://tools.multiversx.com/assets-cdn/tokens/HTM-f51d55/icon.png"},{chain:x,identifier:"MEX-455c57",name:"MEX",symbol:"MEX",decimals:18,logoUrl:"https://tools.multiversx.com/assets-cdn/tokens/MEX-455c57/icon.png"},{chain:x,identifier:"WTAO-4f5363",name:"WrappedTAO",symbol:"WTAO",decimals:9,logoUrl:"https://tools.multiversx.com/assets-cdn/tokens/WTAO-4f5363/icon.png"},{chain:x,identifier:"HEGLD-d61095",name:"HatomEGLD",symbol:"HEGLD",decimals:8,logoUrl:"https://tools.multiversx.com/assets-cdn/tokens/HEGLD-d61095/icon.png"},{chain:x,identifier:"WBTC-5349b3",name:"WrappedBTC",symbol:"WBTC",decimals:8,logoUrl:"https://tools.multiversx.com/assets-cdn/tokens/WBTC-5349b3/icon.png"},{chain:x,identifier:"WETH-b4ca29",name:"WrappedETH",symbol:"WETH",decimals:18,logoUrl:"https://tools.multiversx.com/assets-cdn/tokens/WETH-b4ca29/icon.png"},{chain:x,identifier:"USH-111e09",name:"HatomUSD",symbol:"USH",decimals:18,logoUrl:"https://tools.multiversx.com/assets-cdn/tokens/USH-111e09/icon.png"},{chain:x,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:qe},vibechain:{mainnet:z,testnet:z,devnet:z}},Ze=(i,e,t)=>(Ye[i]?.[e]||[]).find(n=>n.identifier===t)||null,Ba=(i,e)=>Ye[i]?.[e]||[];var K=class{constructor(e,t){this.config=e;this.chain=t;this.cache=new cr(e.cache?.type)}async getAccount(e){let r=await T(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=T(this.chain,this.config.env,this.config).createNetworkProvider(),r=t.getAccount(le.newFromBech32(e)),n=t.getFungibleTokensOfAccount(le.newFromBech32(e)),[a,s]=await Promise.all([r,n]),c=a.balance>0?[{...this.chain.nativeToken,amount:a.balance}]:[];return c.push(...s.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 ir,s=k(e)?0n:a.extractNonceFromExtendedIdentifier(e),c=new sr({identifier:e,nonce:BigInt(s||0)}),o=a.isFungible(c),d=T(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=T(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=T(this.chain,this.config.env,this.config).createNetworkProvider(),n=`accounts/${e}/transactions`,a=new URLSearchParams,s=t?.size||25,c=t?.page||0;if(c>0){let d=c*s;a.append("from",d.toString())}return s!==25&&a.append("size",s.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{applyResultsToMessages as Vr,getNextInfo as Ur,getWarpActionByIndex as Ee,getWarpWalletAddressFromConfig as be}from"@vleap/warps";import{findEventsByFirstTopic as yr,SmartContractTransactionsOutcomeParser as Tr,TransactionEventsParser as vr}from"@multiversx/sdk-core";import{applyResultsToMessages as wr,evaluateResultsCommon as ee,getNextInfo as Wr,getWarpActionByIndex as Cr,getWarpWalletAddressFromConfig as xr,parseResultsOutIndex as gt,WarpCache as Ar,WarpCacheKey as Er,WarpConstants as ft}from"@vleap/warps";import{Address as mr,AddressType as ue,AddressValue as tt,BigUIntType as q,BigUIntValue as me,BooleanType as de,BooleanValue as rt,BytesType as he,BytesValue as nt,CodeMetadata as dr,CodeMetadataType as ge,CodeMetadataValue as at,CompositeType as fe,CompositeValue as st,Field as Q,FieldDefinition as j,List as it,ListType as ot,NothingValue as b,OptionalType as ct,OptionalValue as ye,OptionType as pt,OptionValue as Te,StringType as ve,StringValue as lt,Struct as X,StructType as V,Token as hr,TokenComputer as ut,TokenIdentifierType as J,TokenIdentifierValue as we,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 O,VariadicValue as Z}from"@multiversx/sdk-core";import{WarpSerializer as gr}from"@vleap/warps";var u={HttpProtocolPrefix:"http",IdentifierParamName:"warp",IdentifierParamSeparator:":",IdentifierChainDefault:"multiversx",IdentifierType:{Alias:"alias",Hash:"hash"},IdentifierAliasMarker:"@",Globals:{UserWallet:{Placeholder:"USER_WALLET",Accessor:i=>i.config.user?.wallets?.[i.chain.name]},ChainApiUrl:{Placeholder:"CHAIN_API",Accessor:i=>i.chain.defaultApiUrl},ChainAddressHrp:{Placeholder:"CHAIN_ADDRESS_HRP",Accessor:i=>i.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 Ka={Egld:{Identifier:"EGLD",EsdtIdentifier:"EGLD-000000",DisplayName:"eGold",Decimals:18}},g={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"]}},N={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 fr=new RegExp(`${u.ArgParamsSeparator}(.*)`),P=class{constructor(e){this.coreSerializer=new gr(e)}typedToString(e){let t=e.getType();if(t.hasExactClass(pt.ClassName)||e.hasClassOrSuperclass(Te.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(O.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],s=a.indexOf(u.ArgParamsSeparator),c=a.substring(0,s),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 g.Optional+u.ArgParamsSeparator+"null";let r=this.typedToString(e.getTypedValue());return g.Optional+u.ArgParamsSeparator+r}if(t.hasExactClass(ot.ClassName)||e.hasClassOrSuperclass(it.ClassName)){let n=e.getItems().map(o=>this.typedToString(o));if(n.every(o=>o.startsWith(p.Tuple)))return g.List+u.ArgParamsSeparator+n.join(",");let s=n.map(o=>o.split(u.ArgParamsSeparator)[0])[0],c=n.map(o=>o.split(u.ArgParamsSeparator)[1]);return g.List+u.ArgParamsSeparator+s+u.ArgParamsSeparator+c.join(u.ArgListSeparator)}if(t.hasExactClass(fe.ClassName)||e.hasClassOrSuperclass(st.ClassName)){let n=e.getItems().map(a=>{let s=this.typedToString(a),c=s.indexOf(u.ArgParamsSeparator),o=s.substring(0,c),d=s.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(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(ve.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(V.ClassName)||e.hasClassOrSuperclass(X.ClassName)){let r=e,a=r.getType().getName(),s=r.getFields();if(s.length===0)return`${p.Struct}(${a})${u.ArgParamsSeparator}`;let c=s.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(we.ClassName))return g.Token+u.ArgParamsSeparator+e.valueOf();if(t.hasExactClass(ge.ClassName)||e.hasClassOrSuperclass(at.ClassName))return g.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 fe(...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 V(r,[])}if(e===p.String)return new ve;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 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 V("EsdtTokenPayment",[new j("token_identifier","",new J),new j("token_nonce","",new Y),new j("amount","",new q)]);if(e===g.Token)return new J;if(e===g.CodeMeta)return new ge;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 b?Te.newMissingTyped(n.getType()):Te.newProvided(n)}if(t===p.Vector){let n=r.indexOf(u.ArgParamsSeparator),a=r.substring(0,n),s=r.substring(n+1);if(a.startsWith(p.Tuple)){let l=s.split(",").map(y=>this.stringToTyped(y));return new Z(new O(this.nativeToType(a)),l)}if(s.includes("tuple(")){let m=this.splitTupleStrings(s),l=m.map(w=>this.stringToTyped(w)),C=m[0].match(/^(tuple\([^)]+\))/),h=C?C[1]:"tuple";return new Z(new O(this.nativeToType(h)),l)}let c=a.startsWith(p.Struct)?u.ArgStructSeparator:u.ArgListSeparator,d=s.split(c).map(m=>this.stringToTyped(`${a}:${m}`));return new Z(new O(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(","),s=[];for(let o=0;o<a.length;o+=2){let d=a[o],m=a[o+1];s.push(this.stringToTyped(`${d}:${m}`))}let c=s.map(o=>o.getType());return new st(new fe(...c),s)}if(t.startsWith(p.Struct)){let n=t.match(/\(([^)]+)\)/),a=n?n[1]:"CustomStruct";if(!r)return new X(new V(a,[]),[]);let s=r.split(u.ArgListSeparator),c=[],o=[];return s.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 V(a,c),o)}if(t===p.String)return r?lt.fromUTF8(r):new b;if(t===p.Uint8)return r?new ht(Number(r)):new b;if(t===p.Uint16)return r?new mt(Number(r)):new b;if(t===p.Uint32)return r?new dt(Number(r)):new b;if(t===p.Uint64)return r?new xe(BigInt(r)):new b;if(t===p.Biguint)return r?new me(BigInt(r)):new b;if(t===p.Bool)return r?new rt(typeof r=="boolean"?r:r==="true"):new b;if(t===p.Address)return r?new tt(mr.newFromBech32(r)):new b;if(t===p.Hex)return r?nt.fromHex(r):new b;if(t===p.Asset){let[n,a]=r.split(u.ArgCompositeSeparator),s=new ut,c=k(n)?_(n):s.extractIdentifierFromExtendedIdentifier(n),o=k(n)?0n:s.extractNonceFromExtendedIdentifier(n);return new X(this.nativeToType("asset"),[new Q(new we(c),"token_identifier"),new Q(new xe(BigInt(o)),"token_nonce"),new Q(new me(BigInt(a)),"amount")])}if(t===g.Null)return new b;if(t===g.Optional){let n=this.stringToTyped(r);return n instanceof b?ye.newMissing():new ye(n.getType(),n)}if(t===g.List){let[n,a]=r.split(fr,2),c=a.split(u.ArgListSeparator).map(o=>this.stringToTyped(n+u.ArgParamsSeparator+o));return new it(this.nativeToType(n),c)}if(t===g.Token)return r?new we(r):new b;if(t===g.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 s=e[a];if(s==="(")n++;else if(s===")")n--;else if(s===","&&n===0){t.push(r.trim()),r="";continue}r+=s}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(O.ClassName))return p.Vector+u.ArgParamsSeparator+this.typeToString(e.getFirstTypeParameter());if(e.hasExactClass(ve.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(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(J.ClassName))return g.Token;if(e.hasExactClass(ct.ClassName))return g.Optional+u.ArgParamsSeparator+this.typeToString(e.getFirstTypeParameter());if(e.hasExactClass(ot.ClassName))return g.List+u.ArgParamsSeparator+this.typeToString(e.getFirstTypeParameter());if(e.hasExactClass(ge.ClassName))return g.CodeMeta;if(e.hasExactClass(V.ClassName)&&e.getClassName()==="EsdtTokenPayment")return p.Asset;if(e.hasExactClass(V.ClassName))return`${p.Struct}(${e.getName()})`;throw new Error(`WarpArgSerializer (typeToString): Unsupported input type: ${e.getClassName()}`)}};var F=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.extractContractResults(e,t,r,n),s=Wr(this.config,[],e,t,a),c=wr(e,a.results);return{success:r.status.isSuccessful(),warp:e,action:t,user:xr(this.config,this.chain.name),txHash:r.hash,tx:r,next:s,values:a.values,results:a.results,messages:c}}async extractContractResults(e,t,r,n){let a=Cr(e,t),s=[],c=[],o={};if(!e.results||a.type!=="contract")return{values:{string:s,native:c},results:o};if(!Object.values(e.results).some(h=>h.includes("out")||h.includes("event"))){for(let[h,w]of Object.entries(e.results))o[h]=w;return{values:{string:s,native:c},results:await ee(e,o,t,n,this.serializer.coreSerializer,this.config.transform?.runner)}}let m=await this.abi.getAbiForAction(a),l=new vr({abi:m}),C=new Tr({abi:m}).parseExecute({transactionOnNetwork:r,function:a.func||void 0});for(let[h,w]of Object.entries(e.results)){if(w.startsWith(ft.Transform.Prefix))continue;if(w.startsWith("input.")){o[h]=w;continue}let A=gt(w);if(A!==null&&A!==t){o[h]=null;continue}let[I,S,R]=w.split(".");if(I==="event"){if(!S||isNaN(Number(R)))continue;let U=Number(R),W=yr(r,S),Bt=l.parseEvents({events:W})[0],M=Object.values(Bt)[U]||null;s.push(String(M)),c.push(M),o[h]=M&&M.valueOf()}else if(I==="out"||I.startsWith("out[")){if(!S)continue;let U=Number(S),W=C.values[U-1]||null;R&&(W=W[R]||null),W&&typeof W=="object"&&(W="toFixed"in W?W.toFixed():W.valueOf()),s.push(String(W)),c.push(W),o[h]=W&&W.valueOf()}else o[h]=w}return{values:{string:s,native:c},results:await ee(e,o,t,n,this.serializer.coreSerializer)}}async extractQueryResults(e,t,r,n){let a=t.map(m=>this.serializer.typedToString(m)),s=t.map(m=>this.serializer.typedToNative(m)[1]),c={string:a,native:s},o={};if(!e.results)return{values:c,results:o};let d=m=>{let l=m.split(".").slice(1).map(C=>parseInt(C)-1);if(l.length===0)return;let y=s[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.results)){if(l.startsWith(ft.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{values:c,results:await ee(e,o,r,n,this.serializer.coreSerializer)}}async resolveWarpResultsRecursively(e){let t=e.warp,r=e.entryActionIndex,n=e.executor,a=e.inputs,s=e.meta,c=new Map,o=new Set,d=this;async function m(h,w=[]){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 A=t.actions[h-1];if(!A)throw new Error(`Action ${h} not found`);let I;if(A.type==="query")I=await n.executeQuery(t,h,w);else if(A.type==="collect")I=await n.executeCollect(t,h,w,s);else throw new Error(`Unsupported or interactive action type: ${A.type}`);if(c.set(h,I),t.results)for(let S of Object.values(t.results)){let U=String(S).match(/^out\[(\d+)\]/);if(U){let W=parseInt(U[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[w,A]of Object.entries(h.results))A!==null?l[w]=A:w in l||(l[w]=null);let y=await ee(t,l,r,a,this.serializer.coreSerializer,this.config.transform?.runner);return{...c.get(r),action:r,results: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.results=new F(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){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,s=e.transfers.length===1&&e.transfers[0].identifier===this.chain.nativeToken?.identifier,o=(s?e.transfers[0].amount:0n)+e.value;return await new Nr({config:n}).createTransactionForTransfer(r,{receiver:L.newFromBech32(e.destination),nativeAmount:o,tokenTransfers:s?[]:this.toTokenTransfers(e.transfers),data:a?new Uint8Array(a):void 0})}async createContractCallTransaction(e){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)),s=new yt({chainID:e.chain.chainId});return new Sr({config:s}).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){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(S=>this.serializer.stringToTyped(S)),a=T(e.chain,this.config.env,this.config),s=L.newFromBech32(e.destination),c=a.createSmartContractController(r),o=c.createQuery({contract:s,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(S=>Buffer.from(S)),h=l.buffersToValues(C,y.output),{values:w,results:A}=await this.results.extractQueryResults(e.warp,h,e.action,e.resolvedInputs),I=Ur(this.config,[],e.warp,e.action,A);return{success:m,warp:e.warp,action:e.action,user:be(this.config,e.chain.name),txHash:null,tx:null,next:I,values:w,results:A,messages:Vr(e.warp,A)}}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=N[t];if(a)return a}if(e){let a=N[e];if(a)return a}let r=this.getPrimaryExplorer();return N[r]||N[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=N[n];a&&(r[n]=`${a}/accounts/${e}`)}),r}getTransactionUrls(e){let t=this.getAllExplorers(),r={};return t.forEach(n=>{let a=N[n];a&&(r[n]=`${a}/transactions/${e}`)}),r}};import{AbiRegistry as vt,Address as f,AddressValue as Ie,BytesValue as v,SmartContractTransactionsFactory as Rr,TransactionsFactoryConfig as Mr}from"@multiversx/sdk-core";import{createWarpIdentifier as Or,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 E=i=>{if(i==="devnet")return"erd1qqqqqqqqqqqqqpgqje2f99vr6r7sk54thg03c9suzcvwr4nfl3tsfkdl36";if(i==="testnet")throw new Error("Multiversx testnet is not supported");return"erd1qqqqqqqqqqqqqpgq3mrpj3u6q7tejv6d7eqhnyd27n9v5c5tl3ts08mffe"};var ne=i=>({hash:i.hash.toString("hex"),alias:i.alias?.toString()||null,trust:i.trust.toString(),owner:i.owner.toString(),createdAt:i.created_at.toNumber(),upgradedAt:i.upgraded_at?.toNumber(),brand:i.brand?.toString("hex")||null,upgrade:i.upgrade?.toString("hex")||null}),Tt=i=>({unitPrice:BigInt(i.unit_price.toString()),admins:i.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=f.newFromBech32(this.userWallet),a=()=>this.isCurrentUserAdmin()?BigInt(0):t&&r?this.registryConfig.unitPrice*BigInt(3):t?this.registryConfig.unitPrice*BigInt(2):this.registryConfig.unitPrice,s=()=>t&&r?[v.fromHex(e),v.fromUTF8(t),v.fromHex(r)]:t?[v.fromHex(e),v.fromUTF8(t)]:[v.fromHex(e)];return await this.getFactory().createTransactionForExecute(n,{contract:f.newFromBech32(E(this.config.env)),function:"registerWarp",gasLimit:BigInt(1e7),nativeTransferAmount:a(),arguments:s()})}async createWarpUnregisterTransaction(e){if(!this.userWallet)throw new Error("WarpRegistry: user address not set");let t=f.newFromBech32(this.userWallet);return await this.getFactory().createTransactionForExecute(t,{contract:f.newFromBech32(E(this.config.env)),function:"unregisterWarp",gasLimit:BigInt(1e7),arguments:[v.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=f.newFromBech32(this.userWallet);return await this.getFactory().createTransactionForExecute(n,{contract:f.newFromBech32(E(this.config.env)),function:"upgradeWarp",gasLimit:BigInt(1e7),nativeTransferAmount:this.isCurrentUserAdmin()?void 0:this.registryConfig.unitPrice,arguments:r?[v.fromUTF8(e),v.fromHex(t),v.fromHex(r)]:[v.fromUTF8(e),v.fromHex(t)]})}async createWarpAliasSetTransaction(e,t){if(!this.userWallet)throw new Error("WarpRegistry: user address not set");let r=f.newFromBech32(this.userWallet);return await this.getFactory().createTransactionForExecute(r,{contract:f.newFromBech32(E(this.config.env)),function:"setWarpAlias",gasLimit:BigInt(1e7),nativeTransferAmount:this.isCurrentUserAdmin()?void 0:this.registryConfig.unitPrice,arguments:[v.fromHex(e),v.fromUTF8(t)]})}async createWarpVerifyTransaction(e){if(!this.userWallet)throw new Error("WarpRegistry: user address not set");let t=f.newFromBech32(this.userWallet);return await this.getFactory().createTransactionForExecute(t,{contract:f.newFromBech32(E(this.config.env)),function:"verifyWarp",gasLimit:BigInt(1e7),arguments:[v.fromHex(e)]})}async createWarpTransferOwnershipTransaction(e,t){if(!this.userWallet)throw new Error("WarpRegistry: user address not set");let r=f.newFromBech32(this.userWallet);return await this.getFactory().createTransactionForExecute(r,{contract:f.newFromBech32(E(this.config.env)),function:"transferOwnership",gasLimit:BigInt(1e7),arguments:[v.fromHex(e),new Ie(new f(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=f.newFromBech32(this.userWallet);return await this.getFactory().createTransactionForExecute(t,{contract:f.newFromBech32(E(this.config.env)),function:"registerBrand",gasLimit:BigInt(1e7),nativeTransferAmount:this.isCurrentUserAdmin()?void 0:this.registryConfig.unitPrice,arguments:[v.fromHex(e)]})}async createWarpBrandingTransaction(e,t){if(!this.userWallet)throw new Error("WarpRegistry: user address not set");let r=f.newFromBech32(this.userWallet);return await this.getFactory().createTransactionForExecute(r,{contract:f.newFromBech32(E(this.config.env)),function:"brandWarp",gasLimit:BigInt(1e7),nativeTransferAmount:this.isCurrentUserAdmin()?void 0:this.registryConfig.unitPrice,arguments:[v.fromHex(e),v.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=f.newFromBech32(E(this.config.env)),s=this.getController(),c=s.createQuery({contract:a,function:"getInfoByAlias",arguments:[v.fromUTF8(e)]}),o=await s.runQuery(c),[d]=s.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=f.newFromBech32(E(this.config.env)),a=this.getController(),s=a.createQuery({contract:n,function:"getInfoByHash",arguments:[v.fromHex(e)]}),c=await a.runQuery(s),[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=f.newFromBech32(E(this.config.env)),n=this.getController(),a=n.createQuery({contract:r,function:"getUserWarps",arguments:[new Ie(new f(t))]}),s=await n.runQuery(a),[c]=n.parseQueryResponse(s);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=f.newFromBech32(E(this.config.env)),n=this.getController(),a=n.createQuery({contract:r,function:"getUserBrands",arguments:[new Ie(new f(t))]}),s=await n.runQuery(a),[c]=n.parseQueryResponse(s),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 s=T(this.chain,this.config.env,this.config).createNetworkProvider();try{let c=await s.getTransaction(e),o=JSON.parse(c.data.toString());return o.meta={chain:this.chain.name,identifier:Or(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=f.newFromBech32(E(this.config.env)),t=this.getController(),[r]=await t.query({contract:e,function:"getConfig",arguments:[]}),n=r?Tt(r):null;this.registryConfig=n||{unitPrice:BigInt(0),admins:[]}}getFactory(){let e=new Mr({chainID:this.chain.chainId}),t=vt.create(Se);return new Rr({config:e,abi:t})}getController(){let e=T(this.chain,this.config.env,this.config),t=vt.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 Wt,UserSecretKey as se}from"@multiversx/sdk-core";import{CacheTtl as Gr,getWarpWalletAddressFromConfig as Hr,getWarpWalletPrivateKeyFromConfig as Ct,WarpCache as $r}from"@vleap/warps";var ie=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 $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("-----")?se.fromPem(t):se.fromString(t),a=new wt(n);if(e.nonce===0n){let s=await this.entry.recallAccountNonce(a.address),c=this.cache.get(`nonce:${a.address.toBech32()}`)||0,o=BigInt(Math.max(c,Number(s)));e.nonce=o}return e.signature=await a.signTransaction(e),this.cache.set(`nonce:${a.address.toBech32()}`,Number(a.nonce),Gr.OneHour),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("-----")?se.fromPem(t):se.fromString(t),s=await new wt(n).signMessage(new _r({data:Buffer.from(e)}));return Buffer.from(s).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=(i,e)=>(t,r)=>{let n=e[t.env],a=new zr;return a.registerType("token",{stringToNative:s=>s,nativeToString:s=>`token:${s}`}),a.registerType("codemeta",{stringToNative:s=>s,nativeToString:s=>`codemeta:${s}`}),a.registerTypeAlias("list","vector"),{chainInfo:n,builder:()=>new $(t,n),executor:new te(t,n,a),results:new F(t,n,a),serializer:new P({typeRegistry:a}),registry:new ae(t,n),explorer:new re(i,t),abiBuilder:()=>new B(t,n),brandBuilder:()=>new H(t,n),dataLoader:new K(t,n),wallet:new ie(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 Kr={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:Kr},At=oe(Ue.Vibechain,{mainnet:Ve,testnet:Ve,devnet:Ve});var Xi=(i,e)=>[xt(i,e),At(i,e)],Ji=()=>[Et.Multiversx,Et.Vibechain];import{WarpConstants as ce,WarpSerializer as ke}from"@vleap/warps";var lo=i=>new ke().nativeToString(g.Token,i),uo=i=>new ke().nativeToString(g.CodeMeta,i),mo=(i,e)=>{if(e===null)return g.Optional+ce.ArgParamsSeparator;let t=i(e),r=t.indexOf(ce.ArgParamsSeparator),n=t.substring(0,r),a=t.substring(r+1);return g.Optional+ce.ArgParamsSeparator+n+ce.ArgParamsSeparator+a},ho=i=>new ke().nativeToString(g.List,i);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 Fe,FieldDefinition as Re,List as rn,NothingValue as nn,OptionalValue as Me,OptionValue as Oe,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 wo=(i,e)=>i?Oe.newProvided(i):e?Oe.newMissingTyped(e):Oe.newMissing(),Wo=(i,e)=>i?new Me(i.getType(),i):e?new Me(e):Me.newMissing(),Co=i=>{if(i.length===0)throw new Error("Cannot create a list from an empty array");let e=i[0].getType();return new rn(e,i)},xo=i=>dn.fromItems(...i),Ao=i=>{let e=i.map(t=>t.getType());return new tn(new en(...e),i)},Eo=i=>an.fromUTF8(i),bo=i=>new mn(i),So=i=>new pn(i),Io=i=>new ln(i),Bo=i=>new It(i),Po=i=>new bt(BigInt(i)),No=i=>new Xr(i),Vo=i=>new Qr(qr.newFromBech32(i)),Uo=i=>new St(i),ko=i=>Jr.fromHex(i),Fo=i=>new sn(new on("EsdtTokenPayment",[new Re("token_identifier","",new cn),new Re("token_nonce","",new un),new Re("amount","",new jr)]),[new Fe(new St(i.token.identifier),"token_identifier"),new Fe(new It(BigInt(i.token.nonce)),"token_nonce"),new Fe(new bt(BigInt(i.amount)),"amount")]),Ro=i=>new Zr(Yr.newFromBytes(Uint8Array.from(Buffer.from(i,"hex")))),Mo=()=>new nn;export{N as ExplorerUrls,Ye as KnownTokens,lr as MultiversxExplorers,et as MultiversxExplorersConfig,Ne as NativeTokenEgld,Kr as NativeTokenVibe,ur as VibechainExplorers,B as WarpMultiversxAbiBuilder,H as WarpMultiversxBrandBuilder,$ as WarpMultiversxBuilder,Ka as WarpMultiversxConstants,G as WarpMultiversxContractLoader,K as WarpMultiversxDataLoader,te as WarpMultiversxExecutor,re as WarpMultiversxExplorer,g as WarpMultiversxInputTypes,ae as WarpMultiversxRegistry,F as WarpMultiversxResults,P as WarpMultiversxSerializer,ie as WarpMultiversxWallet,Vo as address_value,Fo as asset_value,Po as biguint_value,No as boolean_value,uo as codemeta,Ro as codemeta_value,Ao as composite_value,oe as createMultiversxAdapter,Ze as findKnownTokenById,Xi as getAllMultiversxAdapters,Ji as getAllMultiversxChainNames,Ba as getKnownTokensForChain,xt as getMultiversxAdapter,T as getMultiversxEntrypoint,E as getMultiversxRegistryAddress,_ as getNormalizedTokenIdentifier,At as getVibechainAdapter,ko as hex_value,k as isNativeToken,ho as list,Co as list_value,Mo as nothing_value,wo as option_value,mo as optional,Wo as optional_value,Eo as string_value,Tt 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 D}from"@vleap/warps";import{WarpTypeRegistry as zr}from"@vleap/warps";import{AbiRegistry as pe,Address as kt,TransactionsFactoryConfig as Ft,TransferTransactionsFactory as Rt}from"@multiversx/sdk-core";import{createWarpIdentifier as Mt,getLatestProtocolIdentifier as Ot,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 k=i=>!i.includes("-"),_=i=>k(i)?`${i}-000000`:i,T=(i,e,t)=>{let r="warp-sdk",a=t?Ut(t,i.name,e,i.defaultApiUrl):{url:i.defaultApiUrl},s=a.url,c={headers:a.headers};return e==="devnet"?new Pt({url:s,kind:"api",clientName:r,networkProviderConfig:c}):e==="testnet"?new Vt({url:s,kind:"api",clientName:r,networkProviderConfig:c}):new Nt({url:s,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 T(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 T(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 Rt({config:r}),a=kt.newFromBech32(t),s={protocol:Ot("abi"),content:e},c=JSON.stringify(s),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),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 s=this.cache.get(r);if(s)return _e.info(`WarpAbiBuilder (createFromTransactionHash): Warp abi found in cache: ${e}`),s}let a=T(this.chain,this.config.env,this.config).createNetworkProvider();try{let s=await a.getTransaction(e),c=await this.createFromTransaction(s);return t&&t.ttl&&c&&this.cache.set(r,c,t.ttl),c}catch(s){return _e.error("WarpAbiBuilder: Error creating from transaction hash",s),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 Kt,WarpLogger as qt}from"@vleap/warps";import{Buffer as Qt}from"buffer";var H=class{constructor(e,t){this.config=e;this.chain=t;this.core=new Kt(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),s=JSON.stringify(e);return await n.createTransactionForNativeTokenTransfer(a,{receiver:Ge.newFromBech32(t),nativeAmount:BigInt(0),data:Uint8Array.from(Qt.from(s))})}async createFromTransaction(e,t=!1){let r=await this.core.createFromRaw(e.data.toString(),t);return r.meta={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=T(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 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}),s=He.newFromBech32(r),c=JSON.stringify(t),o=await a.createTransactionForTransfer(s,{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),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 s=T(this.chain,this.config.env,this.config).createNetworkProvider();try{let c=await s.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 sr,TokenComputer as ir}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 Ke=tr.Multiversx,qe=[{chain:Ke,identifier:"EGLD",name:"eGold",symbol:"EGLD",decimals:18,logoUrl:"https://tools.multiversx.com/assets-cdn/tokens/EGLD-000000/icon.png"},{chain:Ke,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 x=rr.Multiversx,Qe=[{chain:x,identifier:"EGLD",name:"eGold",symbol:"EGLD",decimals:18,logoUrl:"https://tools.multiversx.com/assets-cdn/tokens/EGLD-000000/icon.png"},{chain:x,identifier:"EGLD-000000",name:"eGold",symbol:"EGLD",decimals:18,logoUrl:"https://tools.multiversx.com/assets-cdn/tokens/EGLD-000000/icon.png"},{chain:x,identifier:"SEGLD-3ad2d0",name:"StakedEGLD",symbol:"SEGLD",decimals:18,logoUrl:"https://tools.multiversx.com/assets-cdn/tokens/SEGLD-3ad2d0/icon.png"},{chain:x,identifier:"HSEGLD-c13a4e",name:"HatomSEGLD",symbol:"HSEGLD",decimals:8,logoUrl:"https://tools.multiversx.com/assets-cdn/tokens/HSEGLD-c13a4e/icon.png"},{chain:x,identifier:"UTK-2f80e9",name:"xMoney UTK",symbol:"UTK",decimals:18,logoUrl:"https://tools.multiversx.com/assets-cdn/tokens/UTK-2f80e9/icon.png"},{chain:x,identifier:"USDC-c76f1f",name:"WrappedUSDC",symbol:"USDC",decimals:6,logoUrl:"https://tools.multiversx.com/assets-cdn/tokens/USDC-c76f1f/icon.png"},{chain:x,identifier:"WEGLD-bd4d79",name:"WrappedEGLD",symbol:"WEGLD",decimals:18,logoUrl:"https://tools.multiversx.com/assets-cdn/tokens/WEGLD-bd4d79/icon.png"},{chain:x,identifier:"HTM-f51d55",name:"Hatom",symbol:"HTM",decimals:18,logoUrl:"https://tools.multiversx.com/assets-cdn/tokens/HTM-f51d55/icon.png"},{chain:x,identifier:"MEX-455c57",name:"MEX",symbol:"MEX",decimals:18,logoUrl:"https://tools.multiversx.com/assets-cdn/tokens/MEX-455c57/icon.png"},{chain:x,identifier:"WTAO-4f5363",name:"WrappedTAO",symbol:"WTAO",decimals:9,logoUrl:"https://tools.multiversx.com/assets-cdn/tokens/WTAO-4f5363/icon.png"},{chain:x,identifier:"HEGLD-d61095",name:"HatomEGLD",symbol:"HEGLD",decimals:8,logoUrl:"https://tools.multiversx.com/assets-cdn/tokens/HEGLD-d61095/icon.png"},{chain:x,identifier:"WBTC-5349b3",name:"WrappedBTC",symbol:"WBTC",decimals:8,logoUrl:"https://tools.multiversx.com/assets-cdn/tokens/WBTC-5349b3/icon.png"},{chain:x,identifier:"WETH-b4ca29",name:"WrappedETH",symbol:"WETH",decimals:18,logoUrl:"https://tools.multiversx.com/assets-cdn/tokens/WETH-b4ca29/icon.png"},{chain:x,identifier:"USH-111e09",name:"HatomUSD",symbol:"USH",decimals:18,logoUrl:"https://tools.multiversx.com/assets-cdn/tokens/USH-111e09/icon.png"},{chain:x,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:qe},vibechain:{mainnet:z,testnet:z,devnet:z}},Ze=(i,e,t)=>(Ye[i]?.[e]||[]).find(n=>n.identifier===t)||null,Ba=(i,e)=>Ye[i]?.[e]||[];var K=class{constructor(e,t){this.config=e;this.chain=t;this.cache=new cr(e.cache?.type)}async getAccount(e){let r=await T(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=T(this.chain,this.config.env,this.config).createNetworkProvider(),r=t.getAccount(le.newFromBech32(e)),n=t.getFungibleTokensOfAccount(le.newFromBech32(e)),[a,s]=await Promise.all([r,n]),c=a.balance>0?[{...this.chain.nativeToken,amount:a.balance}]:[];return c.push(...s.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 ir,s=k(e)?0n:a.extractNonceFromExtendedIdentifier(e),c=new sr({identifier:e,nonce:BigInt(s||0)}),o=a.isFungible(c),d=T(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=T(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=T(this.chain,this.config.env,this.config).createNetworkProvider(),n=`accounts/${e}/transactions`,a=new URLSearchParams,s=t?.size||25,c=t?.page||0;if(c>0){let d=c*s;a.append("from",d.toString())}return s!==25&&a.append("size",s.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{applyResultsToMessages as Vr,getNextInfo as Ur,getWarpActionByIndex as Ee,getWarpWalletAddressFromConfig as be}from"@vleap/warps";import{findEventsByFirstTopic as yr,SmartContractTransactionsOutcomeParser as Tr,TransactionEventsParser as vr}from"@multiversx/sdk-core";import{applyResultsToMessages as wr,evaluateResultsCommon as ee,getNextInfo as Wr,getWarpActionByIndex as Cr,getWarpWalletAddressFromConfig as xr,parseResultsOutIndex as gt,WarpCache as Ar,WarpCacheKey as Er,WarpConstants as ft}from"@vleap/warps";import{Address as mr,AddressType as ue,AddressValue as tt,BigUIntType as q,BigUIntValue as me,BooleanType as de,BooleanValue as rt,BytesType as he,BytesValue as nt,CodeMetadata as dr,CodeMetadataType as ge,CodeMetadataValue as at,CompositeType as fe,CompositeValue as st,Field as Q,FieldDefinition as j,List as it,ListType as ot,NothingValue as b,OptionalType as ct,OptionalValue as ye,OptionType as pt,OptionValue as Te,StringType as ve,StringValue as lt,Struct as X,StructType as V,Token as hr,TokenComputer as ut,TokenIdentifierType as J,TokenIdentifierValue as we,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 O,VariadicValue as Z}from"@multiversx/sdk-core";import{WarpSerializer as gr}from"@vleap/warps";var u={HttpProtocolPrefix:"http",IdentifierParamName:"warp",IdentifierParamSeparator:":",IdentifierChainDefault:"multiversx",IdentifierType:{Alias:"alias",Hash:"hash"},IdentifierAliasMarker:"@",Globals:{UserWallet:{Placeholder:"USER_WALLET",Accessor:i=>i.config.user?.wallets?.[i.chain.name]},ChainApiUrl:{Placeholder:"CHAIN_API",Accessor:i=>i.chain.defaultApiUrl},ChainAddressHrp:{Placeholder:"CHAIN_ADDRESS_HRP",Accessor:i=>i.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 Ka={Egld:{Identifier:"EGLD",EsdtIdentifier:"EGLD-000000",DisplayName:"eGold",Decimals:18}},g={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"]}},N={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 fr=new RegExp(`${u.ArgParamsSeparator}(.*)`),P=class{constructor(e){this.coreSerializer=new gr(e)}typedToString(e){let t=e.getType();if(t.hasExactClass(pt.ClassName)||e.hasClassOrSuperclass(Te.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(O.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],s=a.indexOf(u.ArgParamsSeparator),c=a.substring(0,s),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 g.Optional+u.ArgParamsSeparator+"null";let r=this.typedToString(e.getTypedValue());return g.Optional+u.ArgParamsSeparator+r}if(t.hasExactClass(ot.ClassName)||e.hasClassOrSuperclass(it.ClassName)){let n=e.getItems().map(o=>this.typedToString(o));if(n.every(o=>o.startsWith(p.Tuple)))return g.List+u.ArgParamsSeparator+n.join(",");let s=n.map(o=>o.split(u.ArgParamsSeparator)[0])[0],c=n.map(o=>o.split(u.ArgParamsSeparator)[1]);return g.List+u.ArgParamsSeparator+s+u.ArgParamsSeparator+c.join(u.ArgListSeparator)}if(t.hasExactClass(fe.ClassName)||e.hasClassOrSuperclass(st.ClassName)){let n=e.getItems().map(a=>{let s=this.typedToString(a),c=s.indexOf(u.ArgParamsSeparator),o=s.substring(0,c),d=s.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(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(ve.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(V.ClassName)||e.hasClassOrSuperclass(X.ClassName)){let r=e,a=r.getType().getName(),s=r.getFields();if(s.length===0)return`${p.Struct}(${a})${u.ArgParamsSeparator}`;let c=s.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(we.ClassName))return g.Token+u.ArgParamsSeparator+e.valueOf();if(t.hasExactClass(ge.ClassName)||e.hasClassOrSuperclass(at.ClassName))return g.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 fe(...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 V(r,[])}if(e===p.String)return new ve;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 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 V("EsdtTokenPayment",[new j("token_identifier","",new J),new j("token_nonce","",new Y),new j("amount","",new q)]);if(e===g.Token)return new J;if(e===g.CodeMeta)return new ge;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 b?Te.newMissingTyped(n.getType()):Te.newProvided(n)}if(t===p.Vector){let n=r.indexOf(u.ArgParamsSeparator),a=r.substring(0,n),s=r.substring(n+1);if(a.startsWith(p.Tuple)){let l=s.split(",").map(y=>this.stringToTyped(y));return new Z(new O(this.nativeToType(a)),l)}if(s.includes("tuple(")){let m=this.splitTupleStrings(s),l=m.map(w=>this.stringToTyped(w)),C=m[0].match(/^(tuple\([^)]+\))/),h=C?C[1]:"tuple";return new Z(new O(this.nativeToType(h)),l)}let c=a.startsWith(p.Struct)?u.ArgStructSeparator:u.ArgListSeparator,d=s.split(c).map(m=>this.stringToTyped(`${a}:${m}`));return new Z(new O(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(","),s=[];for(let o=0;o<a.length;o+=2){let d=a[o],m=a[o+1];s.push(this.stringToTyped(`${d}:${m}`))}let c=s.map(o=>o.getType());return new st(new fe(...c),s)}if(t.startsWith(p.Struct)){let n=t.match(/\(([^)]+)\)/),a=n?n[1]:"CustomStruct";if(!r)return new X(new V(a,[]),[]);let s=r.split(u.ArgListSeparator),c=[],o=[];return s.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 V(a,c),o)}if(t===p.String)return r?lt.fromUTF8(r):new b;if(t===p.Uint8)return r?new ht(Number(r)):new b;if(t===p.Uint16)return r?new mt(Number(r)):new b;if(t===p.Uint32)return r?new dt(Number(r)):new b;if(t===p.Uint64)return r?new xe(BigInt(r)):new b;if(t===p.Biguint)return r?new me(BigInt(r)):new b;if(t===p.Bool)return r?new rt(typeof r=="boolean"?r:r==="true"):new b;if(t===p.Address)return r?new tt(mr.newFromBech32(r)):new b;if(t===p.Hex)return r?nt.fromHex(r):new b;if(t===p.Asset){let[n,a]=r.split(u.ArgCompositeSeparator),s=new ut,c=k(n)?_(n):s.extractIdentifierFromExtendedIdentifier(n),o=k(n)?0n:s.extractNonceFromExtendedIdentifier(n);return new X(this.nativeToType("asset"),[new Q(new we(c),"token_identifier"),new Q(new xe(BigInt(o)),"token_nonce"),new Q(new me(BigInt(a)),"amount")])}if(t===g.Null)return new b;if(t===g.Optional){let n=this.stringToTyped(r);return n instanceof b?ye.newMissing():new ye(n.getType(),n)}if(t===g.List){let[n,a]=r.split(fr,2),c=a.split(u.ArgListSeparator).map(o=>this.stringToTyped(n+u.ArgParamsSeparator+o));return new it(this.nativeToType(n),c)}if(t===g.Token)return r?new we(r):new b;if(t===g.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 s=e[a];if(s==="(")n++;else if(s===")")n--;else if(s===","&&n===0){t.push(r.trim()),r="";continue}r+=s}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(O.ClassName))return p.Vector+u.ArgParamsSeparator+this.typeToString(e.getFirstTypeParameter());if(e.hasExactClass(ve.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(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(J.ClassName))return g.Token;if(e.hasExactClass(ct.ClassName))return g.Optional+u.ArgParamsSeparator+this.typeToString(e.getFirstTypeParameter());if(e.hasExactClass(ot.ClassName))return g.List+u.ArgParamsSeparator+this.typeToString(e.getFirstTypeParameter());if(e.hasExactClass(ge.ClassName))return g.CodeMeta;if(e.hasExactClass(V.ClassName)&&e.getClassName()==="EsdtTokenPayment")return p.Asset;if(e.hasExactClass(V.ClassName))return`${p.Struct}(${e.getName()})`;throw new Error(`WarpArgSerializer (typeToString): Unsupported input type: ${e.getClassName()}`)}};var F=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.extractContractResults(e,t,r,n),s=Wr(this.config,[],e,t,a),c=wr(e,a.results);return{success:r.status.isSuccessful(),warp:e,action:t,user:xr(this.config,this.chain.name),txHash:r.hash,tx:r,next:s,values:a.values,results:a.results,messages:c}}async extractContractResults(e,t,r,n){let a=Cr(e,t),s=[],c=[],o={};if(!e.results||a.type!=="contract")return{values:{string:s,native:c},results:o};if(!Object.values(e.results).some(h=>h.includes("out")||h.includes("event"))){for(let[h,w]of Object.entries(e.results))o[h]=w;return{values:{string:s,native:c},results:await ee(e,o,t,n,this.serializer.coreSerializer,this.config.transform?.runner)}}let m=await this.abi.getAbiForAction(a),l=new vr({abi:m}),C=new Tr({abi:m}).parseExecute({transactionOnNetwork:r,function:a.func||void 0});for(let[h,w]of Object.entries(e.results)){if(w.startsWith(ft.Transform.Prefix))continue;if(w.startsWith("input.")){o[h]=w;continue}let A=gt(w);if(A!==null&&A!==t){o[h]=null;continue}let[I,S,R]=w.split(".");if(I==="event"){if(!S||isNaN(Number(R)))continue;let U=Number(R),W=yr(r,S),Bt=l.parseEvents({events:W})[0],M=Object.values(Bt)[U]||null;s.push(String(M)),c.push(M),o[h]=M&&M.valueOf()}else if(I==="out"||I.startsWith("out[")){if(!S)continue;let U=Number(S),W=C.values[U-1]||null;R&&(W=W[R]||null),W&&typeof W=="object"&&(W="toFixed"in W?W.toFixed():W.valueOf()),s.push(String(W)),c.push(W),o[h]=W&&W.valueOf()}else o[h]=w}return{values:{string:s,native:c},results:await ee(e,o,t,n,this.serializer.coreSerializer)}}async extractQueryResults(e,t,r,n){let a=t.map(m=>this.serializer.typedToString(m)),s=t.map(m=>this.serializer.typedToNative(m)[1]),c={string:a,native:s},o={};if(!e.results)return{values:c,results:o};let d=m=>{let l=m.split(".").slice(1).map(C=>parseInt(C)-1);if(l.length===0)return;let y=s[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.results)){if(l.startsWith(ft.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{values:c,results:await ee(e,o,r,n,this.serializer.coreSerializer)}}async resolveWarpResultsRecursively(e){let t=e.warp,r=e.entryActionIndex,n=e.executor,a=e.inputs,s=e.meta,c=new Map,o=new Set,d=this;async function m(h,w=[]){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 A=t.actions[h-1];if(!A)throw new Error(`Action ${h} not found`);let I;if(A.type==="query")I=await n.executeQuery(t,h,w);else if(A.type==="collect")I=await n.executeCollect(t,h,w,s);else throw new Error(`Unsupported or interactive action type: ${A.type}`);if(c.set(h,I),t.results)for(let S of Object.values(t.results)){let U=String(S).match(/^out\[(\d+)\]/);if(U){let W=parseInt(U[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[w,A]of Object.entries(h.results))A!==null?l[w]=A:w in l||(l[w]=null);let y=await ee(t,l,r,a,this.serializer.coreSerializer,this.config.transform?.runner);return{...c.get(r),action:r,results: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.results=new F(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){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,s=e.transfers.length===1&&e.transfers[0].identifier===this.chain.nativeToken?.identifier,o=(s?e.transfers[0].amount:0n)+e.value;return await new Nr({config:n}).createTransactionForTransfer(r,{receiver:L.newFromBech32(e.destination),nativeAmount:o,tokenTransfers:s?[]:this.toTokenTransfers(e.transfers),data:a?new Uint8Array(a):void 0})}async createContractCallTransaction(e){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)),s=new yt({chainID:e.chain.chainId});return new Sr({config:s}).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){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(S=>this.serializer.stringToTyped(S)),a=T(e.chain,this.config.env,this.config),s=L.newFromBech32(e.destination),c=a.createSmartContractController(r),o=c.createQuery({contract:s,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(S=>Buffer.from(S)),h=l.buffersToValues(C,y.output),{values:w,results:A}=await this.results.extractQueryResults(e.warp,h,e.action,e.resolvedInputs),I=Ur(this.config,[],e.warp,e.action,A);return{success:m,warp:e.warp,action:e.action,user:be(this.config,e.chain.name),txHash:null,tx:null,next:I,values:w,results:A,messages:Vr(e.warp,A)}}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=N[t];if(a)return a}if(e){let a=N[e];if(a)return a}let r=this.getPrimaryExplorer();return N[r]||N[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=N[n];a&&(r[n]=`${a}/accounts/${e}`)}),r}getTransactionUrls(e){let t=this.getAllExplorers(),r={};return t.forEach(n=>{let a=N[n];a&&(r[n]=`${a}/transactions/${e}`)}),r}};import{AbiRegistry as vt,Address as f,AddressValue as Ie,BytesValue as v,SmartContractTransactionsFactory as Rr,TransactionsFactoryConfig as Mr}from"@multiversx/sdk-core";import{createWarpIdentifier as Or,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 E=i=>{if(i==="devnet")return"erd1qqqqqqqqqqqqqpgqje2f99vr6r7sk54thg03c9suzcvwr4nfl3tsfkdl36";if(i==="testnet")throw new Error("Multiversx testnet is not supported");return"erd1qqqqqqqqqqqqqpgq3mrpj3u6q7tejv6d7eqhnyd27n9v5c5tl3ts08mffe"};var ne=i=>({hash:i.hash.toString("hex"),alias:i.alias?.toString()||null,trust:i.trust.toString(),owner:i.owner.toString(),createdAt:i.created_at.toNumber(),upgradedAt:i.upgraded_at?.toNumber(),brand:i.brand?.toString("hex")||null,upgrade:i.upgrade?.toString("hex")||null}),Tt=i=>({unitPrice:BigInt(i.unit_price.toString()),admins:i.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=f.newFromBech32(this.userWallet),a=()=>this.isCurrentUserAdmin()?BigInt(0):t&&r?this.registryConfig.unitPrice*BigInt(3):t?this.registryConfig.unitPrice*BigInt(2):this.registryConfig.unitPrice,s=()=>t&&r?[v.fromHex(e),v.fromUTF8(t),v.fromHex(r)]:t?[v.fromHex(e),v.fromUTF8(t)]:[v.fromHex(e)];return await this.getFactory().createTransactionForExecute(n,{contract:f.newFromBech32(E(this.config.env)),function:"registerWarp",gasLimit:BigInt(1e7),nativeTransferAmount:a(),arguments:s()})}async createWarpUnregisterTransaction(e){if(!this.userWallet)throw new Error("WarpRegistry: user address not set");let t=f.newFromBech32(this.userWallet);return await this.getFactory().createTransactionForExecute(t,{contract:f.newFromBech32(E(this.config.env)),function:"unregisterWarp",gasLimit:BigInt(1e7),arguments:[v.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=f.newFromBech32(this.userWallet);return await this.getFactory().createTransactionForExecute(n,{contract:f.newFromBech32(E(this.config.env)),function:"upgradeWarp",gasLimit:BigInt(1e7),nativeTransferAmount:this.isCurrentUserAdmin()?void 0:this.registryConfig.unitPrice,arguments:r?[v.fromUTF8(e),v.fromHex(t),v.fromHex(r)]:[v.fromUTF8(e),v.fromHex(t)]})}async createWarpAliasSetTransaction(e,t){if(!this.userWallet)throw new Error("WarpRegistry: user address not set");let r=f.newFromBech32(this.userWallet);return await this.getFactory().createTransactionForExecute(r,{contract:f.newFromBech32(E(this.config.env)),function:"setWarpAlias",gasLimit:BigInt(1e7),nativeTransferAmount:this.isCurrentUserAdmin()?void 0:this.registryConfig.unitPrice,arguments:[v.fromHex(e),v.fromUTF8(t)]})}async createWarpVerifyTransaction(e){if(!this.userWallet)throw new Error("WarpRegistry: user address not set");let t=f.newFromBech32(this.userWallet);return await this.getFactory().createTransactionForExecute(t,{contract:f.newFromBech32(E(this.config.env)),function:"verifyWarp",gasLimit:BigInt(1e7),arguments:[v.fromHex(e)]})}async createWarpTransferOwnershipTransaction(e,t){if(!this.userWallet)throw new Error("WarpRegistry: user address not set");let r=f.newFromBech32(this.userWallet);return await this.getFactory().createTransactionForExecute(r,{contract:f.newFromBech32(E(this.config.env)),function:"transferOwnership",gasLimit:BigInt(1e7),arguments:[v.fromHex(e),new Ie(new f(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=f.newFromBech32(this.userWallet);return await this.getFactory().createTransactionForExecute(t,{contract:f.newFromBech32(E(this.config.env)),function:"registerBrand",gasLimit:BigInt(1e7),nativeTransferAmount:this.isCurrentUserAdmin()?void 0:this.registryConfig.unitPrice,arguments:[v.fromHex(e)]})}async createWarpBrandingTransaction(e,t){if(!this.userWallet)throw new Error("WarpRegistry: user address not set");let r=f.newFromBech32(this.userWallet);return await this.getFactory().createTransactionForExecute(r,{contract:f.newFromBech32(E(this.config.env)),function:"brandWarp",gasLimit:BigInt(1e7),nativeTransferAmount:this.isCurrentUserAdmin()?void 0:this.registryConfig.unitPrice,arguments:[v.fromHex(e),v.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=f.newFromBech32(E(this.config.env)),s=this.getController(),c=s.createQuery({contract:a,function:"getInfoByAlias",arguments:[v.fromUTF8(e)]}),o=await s.runQuery(c),[d]=s.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=f.newFromBech32(E(this.config.env)),a=this.getController(),s=a.createQuery({contract:n,function:"getInfoByHash",arguments:[v.fromHex(e)]}),c=await a.runQuery(s),[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=f.newFromBech32(E(this.config.env)),n=this.getController(),a=n.createQuery({contract:r,function:"getUserWarps",arguments:[new Ie(new f(t))]}),s=await n.runQuery(a),[c]=n.parseQueryResponse(s);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=f.newFromBech32(E(this.config.env)),n=this.getController(),a=n.createQuery({contract:r,function:"getUserBrands",arguments:[new Ie(new f(t))]}),s=await n.runQuery(a),[c]=n.parseQueryResponse(s),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 s=T(this.chain,this.config.env,this.config).createNetworkProvider();try{let c=await s.getTransaction(e),o=JSON.parse(c.data.toString());return o.meta={chain:this.chain.name,identifier:Or(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=f.newFromBech32(E(this.config.env)),t=this.getController(),[r]=await t.query({contract:e,function:"getConfig",arguments:[]}),n=r?Tt(r):null;this.registryConfig=n||{unitPrice:BigInt(0),admins:[]}}getFactory(){let e=new Mr({chainID:this.chain.chainId}),t=vt.create(Se);return new Rr({config:e,abi:t})}getController(){let e=T(this.chain,this.config.env,this.config),t=vt.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 Wt,UserSecretKey as se}from"@multiversx/sdk-core";import{CacheTtl as Gr,getWarpWalletAddressFromConfig as Hr,getWarpWalletPrivateKeyFromConfig as Ct,WarpCache as $r}from"@vleap/warps";var ie=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 $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("-----")?se.fromPem(t):se.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 s=Number(a.nonce)+1;return this.cache.set(`nonce:${a.address.toBech32()}`,s,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("-----")?se.fromPem(t):se.fromString(t),s=await new wt(n).signMessage(new _r({data:Buffer.from(e)}));return Buffer.from(s).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=(i,e)=>(t,r)=>{let n=e[t.env],a=new zr;return a.registerType("token",{stringToNative:s=>s,nativeToString:s=>`token:${s}`}),a.registerType("codemeta",{stringToNative:s=>s,nativeToString:s=>`codemeta:${s}`}),a.registerTypeAlias("list","vector"),{chainInfo:n,builder:()=>new $(t,n),executor:new te(t,n,a),results:new F(t,n,a),serializer:new P({typeRegistry:a}),registry:new ae(t,n),explorer:new re(i,t),abiBuilder:()=>new B(t,n),brandBuilder:()=>new H(t,n),dataLoader:new K(t,n),wallet:new ie(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 Kr={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:Kr},At=oe(Ue.Vibechain,{mainnet:Ve,testnet:Ve,devnet:Ve});var Xi=(i,e)=>[xt(i,e),At(i,e)],Ji=()=>[Et.Multiversx,Et.Vibechain];import{WarpConstants as ce,WarpSerializer as ke}from"@vleap/warps";var lo=i=>new ke().nativeToString(g.Token,i),uo=i=>new ke().nativeToString(g.CodeMeta,i),mo=(i,e)=>{if(e===null)return g.Optional+ce.ArgParamsSeparator;let t=i(e),r=t.indexOf(ce.ArgParamsSeparator),n=t.substring(0,r),a=t.substring(r+1);return g.Optional+ce.ArgParamsSeparator+n+ce.ArgParamsSeparator+a},ho=i=>new ke().nativeToString(g.List,i);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 Fe,FieldDefinition as Re,List as rn,NothingValue as nn,OptionalValue as Me,OptionValue as Oe,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 wo=(i,e)=>i?Oe.newProvided(i):e?Oe.newMissingTyped(e):Oe.newMissing(),Wo=(i,e)=>i?new Me(i.getType(),i):e?new Me(e):Me.newMissing(),Co=i=>{if(i.length===0)throw new Error("Cannot create a list from an empty array");let e=i[0].getType();return new rn(e,i)},xo=i=>dn.fromItems(...i),Ao=i=>{let e=i.map(t=>t.getType());return new tn(new en(...e),i)},Eo=i=>an.fromUTF8(i),bo=i=>new mn(i),So=i=>new pn(i),Io=i=>new ln(i),Bo=i=>new It(i),Po=i=>new bt(BigInt(i)),No=i=>new Xr(i),Vo=i=>new Qr(qr.newFromBech32(i)),Uo=i=>new St(i),ko=i=>Jr.fromHex(i),Fo=i=>new sn(new on("EsdtTokenPayment",[new Re("token_identifier","",new cn),new Re("token_nonce","",new un),new Re("amount","",new jr)]),[new Fe(new St(i.token.identifier),"token_identifier"),new Fe(new It(BigInt(i.token.nonce)),"token_nonce"),new Fe(new bt(BigInt(i.amount)),"amount")]),Ro=i=>new Zr(Yr.newFromBytes(Uint8Array.from(Buffer.from(i,"hex")))),Mo=()=>new nn;export{N as ExplorerUrls,Ye as KnownTokens,lr as MultiversxExplorers,et as MultiversxExplorersConfig,Ne as NativeTokenEgld,Kr as NativeTokenVibe,ur as VibechainExplorers,B as WarpMultiversxAbiBuilder,H as WarpMultiversxBrandBuilder,$ as WarpMultiversxBuilder,Ka as WarpMultiversxConstants,G as WarpMultiversxContractLoader,K as WarpMultiversxDataLoader,te as WarpMultiversxExecutor,re as WarpMultiversxExplorer,g as WarpMultiversxInputTypes,ae as WarpMultiversxRegistry,F as WarpMultiversxResults,P as WarpMultiversxSerializer,ie as WarpMultiversxWallet,Vo as address_value,Fo as asset_value,Po as biguint_value,No as boolean_value,uo as codemeta,Ro as codemeta_value,Ao as composite_value,oe as createMultiversxAdapter,Ze as findKnownTokenById,Xi as getAllMultiversxAdapters,Ji as getAllMultiversxChainNames,Ba as getKnownTokensForChain,xt as getMultiversxAdapter,T as getMultiversxEntrypoint,E as getMultiversxRegistryAddress,_ as getNormalizedTokenIdentifier,At as getVibechainAdapter,ko as hex_value,k as isNativeToken,ho as list,Co as list_value,Mo as nothing_value,wo as option_value,mo as optional,Wo as optional_value,Eo as string_value,Tt 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};
|