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