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