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