@joai/warps-adapter-multiversx 1.0.1 → 1.1.1

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