@vleap/warps-adapter-multiversx 0.2.0-alpha.37 → 0.2.0-alpha.39
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 +229 -0
- package/dist/index.d.ts +12 -4
- package/dist/index.js +1 -0
- package/dist/index.mjs +1 -1
- package/package.json +3 -2
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,229 @@
|
|
|
1
|
+
import * as _vleap_warps from '@vleap/warps';
|
|
2
|
+
import { WarpClientConfig, Adapter, WarpChain, WarpChainEnv, WarpChainInfo, AdapterFactory, WarpChainAsset, AdapterWarpAbiBuilder, WarpAbi, WarpCacheConfig, WarpContractAction, WarpQueryAction, WarpBrand, WarpBuilder, AdapterWarpBuilder, Warp, WarpContract, WarpContractVerification, AdapterWarpDataLoader, WarpChainAccount, WarpDataLoaderOptions, WarpChainAction, AdapterWarpExecutor, WarpExecutable, WarpExecution, WarpActionInputType, AdapterWarpExplorer, AdapterWarpRegistry, WarpRegistryConfigInfo, WarpRegistryInfo, AdapterWarpResults, ResolvedInput, WarpExecutionResults, AdapterWarpSerializer, WarpSerializer, WarpNativeValue, BaseWarpActionInputType, WarpAdapterGenericType } from '@vleap/warps';
|
|
3
|
+
import { TypedValue, Type, OptionValue, OptionalValue, List, VariadicValue, CompositeValue, StringValue, U8Value, U16Value, U32Value, U64Value, BigUIntValue, BooleanValue, AddressValue, TokenIdentifierValue, BytesValue, TokenTransfer, Struct, CodeMetadataValue, NothingValue, TransactionOnNetwork, AbiRegistry, Transaction, NetworkEntrypoint } from '@multiversx/sdk-core';
|
|
4
|
+
|
|
5
|
+
declare const getAllMultiversxAdapters: (config: WarpClientConfig, fallback?: Adapter) => Adapter[];
|
|
6
|
+
declare const getAllMultiversxChainNames: () => WarpChain[];
|
|
7
|
+
|
|
8
|
+
declare const createMultiversxAdapter: (chainName: string, chainPrefix: string, chainInfos: Record<WarpChainEnv, WarpChainInfo>) => AdapterFactory;
|
|
9
|
+
|
|
10
|
+
declare const NativeTokenEgld: WarpChainAsset;
|
|
11
|
+
declare const getMultiversxAdapter: _vleap_warps.AdapterFactory;
|
|
12
|
+
|
|
13
|
+
declare const NativeTokenVibe: WarpChainAsset;
|
|
14
|
+
declare const getVibechainAdapter: _vleap_warps.AdapterFactory;
|
|
15
|
+
|
|
16
|
+
declare const getMultiversxRegistryAddress: (env: WarpChainEnv) => "erd1qqqqqqqqqqqqqpgqje2f99vr6r7sk54thg03c9suzcvwr4nfl3tsfkdl36" | "erd1qqqqqqqqqqqqqpgq3mrpj3u6q7tejv6d7eqhnyd27n9v5c5tl3ts08mffe";
|
|
17
|
+
|
|
18
|
+
declare const WarpMultiversxConstants: {
|
|
19
|
+
Egld: {
|
|
20
|
+
Identifier: string;
|
|
21
|
+
EsdtIdentifier: string;
|
|
22
|
+
DisplayName: string;
|
|
23
|
+
Decimals: number;
|
|
24
|
+
};
|
|
25
|
+
};
|
|
26
|
+
declare enum MultiversxExplorers {
|
|
27
|
+
MultiversxExplorer = "multiversx_explorer",
|
|
28
|
+
MultiversxExplorerDevnet = "multiversx_explorer_devnet",
|
|
29
|
+
MultiversxExplorerTestnet = "multiversx_explorer_testnet"
|
|
30
|
+
}
|
|
31
|
+
declare enum VibechainExplorers {
|
|
32
|
+
VibechainExplorer = "vibechain_explorer",
|
|
33
|
+
VibechainExplorerDevnet = "vibechain_explorer_devnet",
|
|
34
|
+
VibechainExplorerTestnet = "vibechain_explorer_testnet"
|
|
35
|
+
}
|
|
36
|
+
type ExplorerName = MultiversxExplorers | VibechainExplorers;
|
|
37
|
+
declare const MultiversxExplorersConfig: {
|
|
38
|
+
readonly multiversx: {
|
|
39
|
+
readonly mainnet: readonly [MultiversxExplorers.MultiversxExplorer];
|
|
40
|
+
readonly testnet: readonly [MultiversxExplorers.MultiversxExplorerTestnet];
|
|
41
|
+
readonly devnet: readonly [MultiversxExplorers.MultiversxExplorerDevnet];
|
|
42
|
+
};
|
|
43
|
+
readonly vibechain: {
|
|
44
|
+
readonly mainnet: readonly [VibechainExplorers.VibechainExplorer];
|
|
45
|
+
readonly testnet: readonly [VibechainExplorers.VibechainExplorerTestnet];
|
|
46
|
+
readonly devnet: readonly [VibechainExplorers.VibechainExplorerDevnet];
|
|
47
|
+
};
|
|
48
|
+
};
|
|
49
|
+
declare const ExplorerUrls: Record<ExplorerName, string>;
|
|
50
|
+
|
|
51
|
+
declare const option_value: (value: TypedValue | null, type?: Type) => OptionValue;
|
|
52
|
+
declare const optional_value: (value: TypedValue | null, type?: Type) => OptionalValue;
|
|
53
|
+
declare const list_value: (values: TypedValue[]) => List;
|
|
54
|
+
declare const variadic_value: (values: TypedValue[]) => VariadicValue;
|
|
55
|
+
declare const composite_value: (values: TypedValue[]) => CompositeValue;
|
|
56
|
+
declare const string_value: (value: string) => StringValue;
|
|
57
|
+
declare const u8_value: (value: number) => U8Value;
|
|
58
|
+
declare const u16_value: (value: number) => U16Value;
|
|
59
|
+
declare const u32_value: (value: number) => U32Value;
|
|
60
|
+
declare const u64_value: (value: bigint) => U64Value;
|
|
61
|
+
declare const biguint_value: (value: bigint | string | number) => BigUIntValue;
|
|
62
|
+
declare const boolean_value: (value: boolean) => BooleanValue;
|
|
63
|
+
declare const address_value: (value: string) => AddressValue;
|
|
64
|
+
declare const token_value: (value: string) => TokenIdentifierValue;
|
|
65
|
+
declare const hex_value: (value: string) => BytesValue;
|
|
66
|
+
declare const esdt_value: (value: TokenTransfer) => Struct;
|
|
67
|
+
declare const codemeta_value: (hexString: string) => CodeMetadataValue;
|
|
68
|
+
declare const nothing_value: () => NothingValue;
|
|
69
|
+
|
|
70
|
+
declare class WarpMultiversxAbiBuilder implements AdapterWarpAbiBuilder {
|
|
71
|
+
private readonly config;
|
|
72
|
+
private readonly chain;
|
|
73
|
+
private readonly contractLoader;
|
|
74
|
+
private readonly cache;
|
|
75
|
+
constructor(config: WarpClientConfig, chain: WarpChainInfo);
|
|
76
|
+
createFromRaw(encoded: string): Promise<WarpAbi>;
|
|
77
|
+
createFromTransaction(tx: TransactionOnNetwork): Promise<WarpAbi>;
|
|
78
|
+
createFromTransactionHash(hash: string, cache?: WarpCacheConfig): Promise<WarpAbi | null>;
|
|
79
|
+
getAbiForAction(action: WarpContractAction | WarpQueryAction): Promise<AbiRegistry>;
|
|
80
|
+
fetchAbi(action: WarpContractAction | WarpQueryAction): Promise<AbiRegistry>;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
declare class WarpMultiversxBrandBuilder {
|
|
84
|
+
private readonly config;
|
|
85
|
+
private readonly chain;
|
|
86
|
+
private readonly core;
|
|
87
|
+
constructor(config: WarpClientConfig, chain: WarpChainInfo);
|
|
88
|
+
createInscriptionTransaction(brand: WarpBrand): Promise<Transaction>;
|
|
89
|
+
createFromTransaction(tx: TransactionOnNetwork, validateSchema?: boolean): Promise<WarpBrand>;
|
|
90
|
+
createFromTransactionHash(hash: string): Promise<WarpBrand | null>;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
declare class WarpMultiversxBuilder extends WarpBuilder implements AdapterWarpBuilder {
|
|
94
|
+
protected readonly config: WarpClientConfig;
|
|
95
|
+
private readonly chain;
|
|
96
|
+
private readonly cache;
|
|
97
|
+
private readonly core;
|
|
98
|
+
constructor(config: WarpClientConfig, chain: WarpChainInfo);
|
|
99
|
+
createInscriptionTransaction(warp: Warp): Promise<Transaction>;
|
|
100
|
+
createFromTransaction(tx: TransactionOnNetwork, validate?: boolean): Promise<Warp>;
|
|
101
|
+
createFromTransactionHash(hash: string, cache?: WarpCacheConfig): Promise<Warp | null>;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
declare class WarpMultiversxContractLoader {
|
|
105
|
+
private readonly config;
|
|
106
|
+
constructor(config: WarpClientConfig);
|
|
107
|
+
getContract(address: string, chain: WarpChainInfo): Promise<WarpContract | null>;
|
|
108
|
+
getVerificationInfo(address: string, chain: WarpChainInfo): Promise<WarpContractVerification | null>;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
declare class WarpMultiversxDataLoader implements AdapterWarpDataLoader {
|
|
112
|
+
private readonly config;
|
|
113
|
+
private readonly chain;
|
|
114
|
+
constructor(config: WarpClientConfig, chain: WarpChainInfo);
|
|
115
|
+
getAccount(address: string): Promise<WarpChainAccount>;
|
|
116
|
+
getAccountAssets(address: string): Promise<WarpChainAsset[]>;
|
|
117
|
+
getAccountActions(address: string, options?: WarpDataLoaderOptions): Promise<WarpChainAction[]>;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
declare class WarpMultiversxExecutor implements AdapterWarpExecutor {
|
|
121
|
+
private readonly config;
|
|
122
|
+
private readonly chain;
|
|
123
|
+
private readonly serializer;
|
|
124
|
+
private readonly abi;
|
|
125
|
+
private readonly results;
|
|
126
|
+
constructor(config: WarpClientConfig, chain: WarpChainInfo);
|
|
127
|
+
createTransaction(executable: WarpExecutable): Promise<Transaction>;
|
|
128
|
+
createTransferTransaction(executable: WarpExecutable): Promise<Transaction>;
|
|
129
|
+
createContractCallTransaction(executable: WarpExecutable): Promise<Transaction>;
|
|
130
|
+
executeQuery(executable: WarpExecutable): Promise<WarpExecution>;
|
|
131
|
+
preprocessInput(chain: WarpChainInfo, input: string, type: WarpActionInputType, value: string): Promise<string>;
|
|
132
|
+
static getChainEntrypoint(chainInfo: WarpChainInfo, env: WarpChainEnv, config?: WarpClientConfig): NetworkEntrypoint;
|
|
133
|
+
signMessage(message: string, privateKey: string): Promise<string>;
|
|
134
|
+
private toTokenTransfers;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
declare class WarpMultiversxExplorer implements AdapterWarpExplorer {
|
|
138
|
+
private readonly chain;
|
|
139
|
+
private readonly config;
|
|
140
|
+
constructor(chain: WarpChain, config: WarpClientConfig);
|
|
141
|
+
private getExplorers;
|
|
142
|
+
private getPrimaryExplorer;
|
|
143
|
+
private getExplorerUrlByName;
|
|
144
|
+
getAccountUrl(address: string, explorer?: ExplorerName): string;
|
|
145
|
+
getTransactionUrl(hash: string, explorer?: ExplorerName): string;
|
|
146
|
+
getBlockUrl(blockNumber: string | number, explorer?: ExplorerName): string;
|
|
147
|
+
getAssetUrl(identifier: string, explorer?: ExplorerName): string;
|
|
148
|
+
getContractUrl(address: string, explorer?: ExplorerName): string;
|
|
149
|
+
getAllExplorers(): readonly ExplorerName[];
|
|
150
|
+
getExplorerByName(name: string): ExplorerName | undefined;
|
|
151
|
+
getAccountUrls(address: string): Record<ExplorerName, string>;
|
|
152
|
+
getTransactionUrls(hash: string): Record<ExplorerName, string>;
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
declare class WarpMultiversxRegistry implements AdapterWarpRegistry {
|
|
156
|
+
private config;
|
|
157
|
+
private chain;
|
|
158
|
+
private cache;
|
|
159
|
+
private userWallet;
|
|
160
|
+
registryConfig: WarpRegistryConfigInfo;
|
|
161
|
+
constructor(config: WarpClientConfig, chain: WarpChainInfo);
|
|
162
|
+
init(): Promise<void>;
|
|
163
|
+
getRegistryConfig(): WarpRegistryConfigInfo;
|
|
164
|
+
createWarpRegisterTransaction(txHash: string, alias?: string | null, brand?: string | null): Promise<Transaction>;
|
|
165
|
+
createWarpUnregisterTransaction(txHash: string): Promise<Transaction>;
|
|
166
|
+
createWarpUpgradeTransaction(alias: string, txHash: string): Promise<Transaction>;
|
|
167
|
+
createWarpAliasSetTransaction(txHash: string, alias: string): Promise<Transaction>;
|
|
168
|
+
createWarpVerifyTransaction(txHash: string): Promise<Transaction>;
|
|
169
|
+
createWarpTransferOwnershipTransaction(txHash: string, newOwner: string): Promise<Transaction>;
|
|
170
|
+
createBrandRegisterTransaction(txHash: string): Promise<Transaction>;
|
|
171
|
+
createWarpBrandingTransaction(warpHash: string, brandHash: string): Promise<Transaction>;
|
|
172
|
+
getInfoByAlias(alias: string, cache?: WarpCacheConfig): Promise<{
|
|
173
|
+
registryInfo: WarpRegistryInfo | null;
|
|
174
|
+
brand: WarpBrand | null;
|
|
175
|
+
}>;
|
|
176
|
+
getInfoByHash(hash: string, cache?: WarpCacheConfig): Promise<{
|
|
177
|
+
registryInfo: WarpRegistryInfo | null;
|
|
178
|
+
brand: WarpBrand | null;
|
|
179
|
+
}>;
|
|
180
|
+
getUserWarpRegistryInfos(user?: string): Promise<WarpRegistryInfo[]>;
|
|
181
|
+
getUserBrands(user?: string): Promise<WarpBrand[]>;
|
|
182
|
+
fetchBrand(hash: string, cache?: WarpCacheConfig): Promise<WarpBrand | null>;
|
|
183
|
+
private loadRegistryConfigs;
|
|
184
|
+
private getFactory;
|
|
185
|
+
private getController;
|
|
186
|
+
private isCurrentUserAdmin;
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
declare class WarpMultiversxResults implements AdapterWarpResults {
|
|
190
|
+
private readonly config;
|
|
191
|
+
private readonly chain;
|
|
192
|
+
private readonly abi;
|
|
193
|
+
private readonly serializer;
|
|
194
|
+
private readonly cache;
|
|
195
|
+
constructor(config: WarpClientConfig, chain: WarpChainInfo);
|
|
196
|
+
getTransactionExecutionResults(warp: Warp, tx: TransactionOnNetwork): Promise<WarpExecution>;
|
|
197
|
+
extractContractResults(warp: Warp, tx: TransactionOnNetwork, inputs: ResolvedInput[]): Promise<{
|
|
198
|
+
values: any[];
|
|
199
|
+
results: WarpExecutionResults;
|
|
200
|
+
}>;
|
|
201
|
+
extractQueryResults(warp: Warp, typedValues: TypedValue[], actionIndex: number, inputs: ResolvedInput[]): Promise<{
|
|
202
|
+
values: any[];
|
|
203
|
+
valuesRaw: any[];
|
|
204
|
+
results: WarpExecutionResults;
|
|
205
|
+
}>;
|
|
206
|
+
resolveWarpResultsRecursively(props: {
|
|
207
|
+
warp: Warp;
|
|
208
|
+
entryActionIndex: number;
|
|
209
|
+
executor: {
|
|
210
|
+
executeQuery: Function;
|
|
211
|
+
executeCollect: Function;
|
|
212
|
+
};
|
|
213
|
+
inputs: ResolvedInput[];
|
|
214
|
+
meta?: Record<string, any>;
|
|
215
|
+
}): Promise<any>;
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
declare class WarpMultiversxSerializer implements AdapterWarpSerializer {
|
|
219
|
+
readonly coreSerializer: WarpSerializer;
|
|
220
|
+
constructor();
|
|
221
|
+
typedToString(value: TypedValue): string;
|
|
222
|
+
typedToNative(value: TypedValue): [WarpActionInputType, WarpNativeValue];
|
|
223
|
+
nativeToTyped(type: WarpActionInputType, value: WarpNativeValue): TypedValue;
|
|
224
|
+
nativeToType(type: BaseWarpActionInputType): WarpAdapterGenericType;
|
|
225
|
+
stringToTyped(value: string): TypedValue;
|
|
226
|
+
typeToString(type: Type): WarpActionInputType;
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
export { type ExplorerName, ExplorerUrls, MultiversxExplorers, MultiversxExplorersConfig, NativeTokenEgld, NativeTokenVibe, VibechainExplorers, WarpMultiversxAbiBuilder, WarpMultiversxBrandBuilder, WarpMultiversxBuilder, WarpMultiversxConstants, WarpMultiversxContractLoader, WarpMultiversxDataLoader, WarpMultiversxExecutor, WarpMultiversxExplorer, WarpMultiversxRegistry, WarpMultiversxResults, WarpMultiversxSerializer, address_value, biguint_value, boolean_value, codemeta_value, composite_value, createMultiversxAdapter, esdt_value, getAllMultiversxAdapters, getAllMultiversxChainNames, getMultiversxAdapter, getMultiversxRegistryAddress, getVibechainAdapter, hex_value, list_value, nothing_value, option_value, optional_value, string_value, token_value, u16_value, u32_value, u64_value, u8_value, variadic_value };
|
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, AdapterWarpAbiBuilder, WarpAbi, WarpCacheConfig, WarpContractAction, WarpQueryAction, WarpBrand, WarpBuilder, AdapterWarpBuilder, Warp, WarpContract, WarpContractVerification, AdapterWarpExecutor, WarpExecutable, WarpExecution, WarpActionInputType, AdapterWarpExplorer, AdapterWarpRegistry, WarpRegistryConfigInfo, WarpRegistryInfo, AdapterWarpResults, ResolvedInput, WarpExecutionResults, AdapterWarpSerializer, WarpSerializer, WarpNativeValue, BaseWarpActionInputType, WarpAdapterGenericType } from '@vleap/warps';
|
|
2
|
+
import { WarpClientConfig, Adapter, WarpChain, WarpChainEnv, WarpChainInfo, AdapterFactory, WarpChainAsset, AdapterWarpAbiBuilder, WarpAbi, WarpCacheConfig, WarpContractAction, WarpQueryAction, WarpBrand, WarpBuilder, AdapterWarpBuilder, Warp, WarpContract, WarpContractVerification, AdapterWarpDataLoader, WarpChainAccount, WarpDataLoaderOptions, WarpChainAction, AdapterWarpExecutor, WarpExecutable, WarpExecution, WarpActionInputType, AdapterWarpExplorer, AdapterWarpRegistry, WarpRegistryConfigInfo, WarpRegistryInfo, AdapterWarpResults, ResolvedInput, WarpExecutionResults, AdapterWarpSerializer, WarpSerializer, WarpNativeValue, BaseWarpActionInputType, WarpAdapterGenericType } from '@vleap/warps';
|
|
3
3
|
import { TypedValue, Type, OptionValue, OptionalValue, List, VariadicValue, CompositeValue, StringValue, U8Value, U16Value, U32Value, U64Value, BigUIntValue, BooleanValue, AddressValue, TokenIdentifierValue, BytesValue, TokenTransfer, Struct, CodeMetadataValue, NothingValue, TransactionOnNetwork, AbiRegistry, Transaction, NetworkEntrypoint } from '@multiversx/sdk-core';
|
|
4
4
|
|
|
5
5
|
declare const getAllMultiversxAdapters: (config: WarpClientConfig, fallback?: Adapter) => Adapter[];
|
|
@@ -7,11 +7,9 @@ declare const getAllMultiversxChainNames: () => WarpChain[];
|
|
|
7
7
|
|
|
8
8
|
declare const createMultiversxAdapter: (chainName: string, chainPrefix: string, chainInfos: Record<WarpChainEnv, WarpChainInfo>) => AdapterFactory;
|
|
9
9
|
|
|
10
|
-
declare const ChainNameMultiversx: WarpChain;
|
|
11
10
|
declare const NativeTokenEgld: WarpChainAsset;
|
|
12
11
|
declare const getMultiversxAdapter: _vleap_warps.AdapterFactory;
|
|
13
12
|
|
|
14
|
-
declare const ChainNameVibechain: WarpChain;
|
|
15
13
|
declare const NativeTokenVibe: WarpChainAsset;
|
|
16
14
|
declare const getVibechainAdapter: _vleap_warps.AdapterFactory;
|
|
17
15
|
|
|
@@ -110,6 +108,15 @@ declare class WarpMultiversxContractLoader {
|
|
|
110
108
|
getVerificationInfo(address: string, chain: WarpChainInfo): Promise<WarpContractVerification | null>;
|
|
111
109
|
}
|
|
112
110
|
|
|
111
|
+
declare class WarpMultiversxDataLoader implements AdapterWarpDataLoader {
|
|
112
|
+
private readonly config;
|
|
113
|
+
private readonly chain;
|
|
114
|
+
constructor(config: WarpClientConfig, chain: WarpChainInfo);
|
|
115
|
+
getAccount(address: string): Promise<WarpChainAccount>;
|
|
116
|
+
getAccountAssets(address: string): Promise<WarpChainAsset[]>;
|
|
117
|
+
getAccountActions(address: string, options?: WarpDataLoaderOptions): Promise<WarpChainAction[]>;
|
|
118
|
+
}
|
|
119
|
+
|
|
113
120
|
declare class WarpMultiversxExecutor implements AdapterWarpExecutor {
|
|
114
121
|
private readonly config;
|
|
115
122
|
private readonly chain;
|
|
@@ -193,6 +200,7 @@ declare class WarpMultiversxResults implements AdapterWarpResults {
|
|
|
193
200
|
}>;
|
|
194
201
|
extractQueryResults(warp: Warp, typedValues: TypedValue[], actionIndex: number, inputs: ResolvedInput[]): Promise<{
|
|
195
202
|
values: any[];
|
|
203
|
+
valuesRaw: any[];
|
|
196
204
|
results: WarpExecutionResults;
|
|
197
205
|
}>;
|
|
198
206
|
resolveWarpResultsRecursively(props: {
|
|
@@ -218,4 +226,4 @@ declare class WarpMultiversxSerializer implements AdapterWarpSerializer {
|
|
|
218
226
|
typeToString(type: Type): WarpActionInputType;
|
|
219
227
|
}
|
|
220
228
|
|
|
221
|
-
export {
|
|
229
|
+
export { type ExplorerName, ExplorerUrls, MultiversxExplorers, MultiversxExplorersConfig, NativeTokenEgld, NativeTokenVibe, VibechainExplorers, WarpMultiversxAbiBuilder, WarpMultiversxBrandBuilder, WarpMultiversxBuilder, WarpMultiversxConstants, WarpMultiversxContractLoader, WarpMultiversxDataLoader, WarpMultiversxExecutor, WarpMultiversxExplorer, WarpMultiversxRegistry, WarpMultiversxResults, WarpMultiversxSerializer, address_value, biguint_value, boolean_value, codemeta_value, composite_value, createMultiversxAdapter, esdt_value, getAllMultiversxAdapters, getAllMultiversxChainNames, getMultiversxAdapter, getMultiversxRegistryAddress, getVibechainAdapter, hex_value, list_value, nothing_value, option_value, optional_value, string_value, token_value, u16_value, u32_value, u64_value, u8_value, variadic_value };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var te=Object.defineProperty;var ye=Object.getOwnPropertyDescriptor;var we=Object.getOwnPropertyNames;var Ce=Object.prototype.hasOwnProperty;var xe=(o,e)=>{for(var t in e)te(o,t,{get:e[t],enumerable:!0})},We=(o,e,t,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let a of we(e))!Ce.call(o,a)&&a!==t&&te(o,a,{get:()=>e[a],enumerable:!(r=ye(e,a))||r.enumerable});return o};var Te=o=>We(te({},"__esModule",{value:!0}),o);var He={};xe(He,{ExplorerUrls:()=>P,MultiversxExplorers:()=>fe,MultiversxExplorersConfig:()=>se,NativeTokenEgld:()=>Z,NativeTokenVibe:()=>ge,VibechainExplorers:()=>de,WarpMultiversxAbiBuilder:()=>F,WarpMultiversxBrandBuilder:()=>D,WarpMultiversxBuilder:()=>z,WarpMultiversxConstants:()=>Le,WarpMultiversxContractLoader:()=>q,WarpMultiversxDataLoader:()=>H,WarpMultiversxExecutor:()=>w,WarpMultiversxExplorer:()=>Q,WarpMultiversxRegistry:()=>G,WarpMultiversxResults:()=>U,WarpMultiversxSerializer:()=>R,address_value:()=>Pe,biguint_value:()=>Fe,boolean_value:()=>ke,codemeta_value:()=>Oe,composite_value:()=>Be,createMultiversxAdapter:()=>j,esdt_value:()=>re,getAllMultiversxAdapters:()=>De,getAllMultiversxChainNames:()=>ze,getMultiversxAdapter:()=>oe,getMultiversxRegistryAddress:()=>b,getVibechainAdapter:()=>pe,hex_value:()=>_e,list_value:()=>Ee,nothing_value:()=>Me,option_value:()=>ve,optional_value:()=>be,string_value:()=>Ie,token_value:()=>Ue,u16_value:()=>Ne,u32_value:()=>Se,u64_value:()=>Re,u8_value:()=>Ve,variadic_value:()=>Ae});module.exports=Te(He);var ue=require("@vleap/warps");var $=require("@vleap/warps");var J=require("@multiversx/sdk-core"),V=require("@vleap/warps");var ne=require("@vleap/warps");var f=require("@multiversx/sdk-core"),W=require("@vleap/warps");var M=require("@multiversx/sdk-core"),y=require("@vleap/warps");var n=require("@multiversx/sdk-core"),T=require("@vleap/warps"),le=new RegExp(`${T.WarpConstants.ArgParamsSeparator}(.*)`),R=class{constructor(){this.coreSerializer=new T.WarpSerializer}typedToString(e){let t=e.getType();if(t.hasExactClass(n.OptionType.ClassName)||e.hasClassOrSuperclass(n.OptionValue.ClassName))return e.isSet()?`option:${this.typedToString(e.getTypedValue())}`:"option:null";if(t.hasExactClass(n.OptionalType.ClassName)||e.hasClassOrSuperclass(n.OptionalValue.ClassName))return e.isSet()?`optional:${this.typedToString(e.getTypedValue())}`:"optional:null";if(t.hasExactClass(n.ListType.ClassName)||e.hasClassOrSuperclass(n.List.ClassName)){let r=e.getItems(),s=r.map(i=>this.typedToString(i).split(T.WarpConstants.ArgParamsSeparator)[0])[0],c=r.map(i=>this.typedToString(i).split(T.WarpConstants.ArgParamsSeparator)[1]);return`list:${s}:${c.join(",")}`}if(t.hasExactClass(n.VariadicType.ClassName)||e.hasClassOrSuperclass(n.VariadicValue.ClassName)){let r=e.getItems(),s=r.map(i=>this.typedToString(i).split(T.WarpConstants.ArgParamsSeparator)[0])[0],c=r.map(i=>this.typedToString(i).split(T.WarpConstants.ArgParamsSeparator)[1]);return`variadic:${s}:${c.join(",")}`}if(t.hasExactClass(n.CompositeType.ClassName)||e.hasClassOrSuperclass(n.CompositeValue.ClassName)){let r=e.getItems(),a=r.map(m=>this.typedToString(m).split(T.WarpConstants.ArgParamsSeparator)[0]),s=r.map(m=>this.typedToString(m).split(T.WarpConstants.ArgParamsSeparator)[1]),c=a.join(T.WarpConstants.ArgCompositeSeparator),i=s.join(T.WarpConstants.ArgCompositeSeparator);return`composite(${c}):${i}`}if(t.hasExactClass(n.BigUIntType.ClassName)||e.hasClassOrSuperclass(n.BigUIntValue.ClassName)||t.getName()==="BigUint")return`biguint:${BigInt(e.valueOf().toFixed())}`;if(t.hasExactClass(n.U8Type.ClassName)||e.hasClassOrSuperclass(n.U8Value.ClassName))return`uint8:${e.valueOf().toNumber()}`;if(t.hasExactClass(n.U16Type.ClassName)||e.hasClassOrSuperclass(n.U16Value.ClassName))return`uint16:${e.valueOf().toNumber()}`;if(t.hasExactClass(n.U32Type.ClassName)||e.hasClassOrSuperclass(n.U32Value.ClassName))return`uint32:${e.valueOf().toNumber()}`;if(t.hasExactClass(n.U64Type.ClassName)||e.hasClassOrSuperclass(n.U64Value.ClassName))return`uint64:${BigInt(e.valueOf().toFixed())}`;if(t.hasExactClass(n.StringType.ClassName)||e.hasClassOrSuperclass(n.StringValue.ClassName))return`string:${e.valueOf()}`;if(t.hasExactClass(n.BooleanType.ClassName)||e.hasClassOrSuperclass(n.BooleanValue.ClassName))return`bool:${e.valueOf()}`;if(t.hasExactClass(n.AddressType.ClassName)||e.hasClassOrSuperclass(n.AddressValue.ClassName))return`address:${e.valueOf().toBech32()}`;if(t.hasExactClass(n.TokenIdentifierType.ClassName)||e.hasClassOrSuperclass(n.TokenIdentifierValue.ClassName))return`token:${e.valueOf()}`;if(t.hasExactClass(n.BytesType.ClassName)||e.hasClassOrSuperclass(n.BytesValue.ClassName))return`hex:${e.valueOf().toString("hex")}`;if(t.hasExactClass(n.CodeMetadataType.ClassName)||e.hasClassOrSuperclass(n.CodeMetadataValue.ClassName))return`codemeta:${e.valueOf().toString()}`;if(t.getName()==="EsdtTokenPayment"){let r=e.getFieldValue("token_identifier").valueOf(),a=e.getFieldValue("token_nonce").valueOf(),s=e.getFieldValue("amount").valueOf();return`asset:${r}|${a}|${s}`}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){let r=this.coreSerializer.nativeToString(e,t);return this.stringToTyped(r)}nativeToType(e){if(e.startsWith("composite")){let t=e.match(/\(([^)]+)\)/)?.[1];return new n.CompositeType(...t.split(T.WarpConstants.ArgCompositeSeparator).map(r=>this.nativeToType(r)))}if(e==="string")return new n.StringType;if(e==="uint8")return new n.U8Type;if(e==="uint16")return new n.U16Type;if(e==="uint32")return new n.U32Type;if(e==="uint64")return new n.U64Type;if(e==="biguint")return new n.BigUIntType;if(e==="bool")return new n.BooleanType;if(e==="address")return new n.AddressType;if(e==="token")return new n.TokenIdentifierType;if(e==="hex")return new n.BytesType;if(e==="codemeta")return new n.CodeMetadataType;if(e==="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)]);throw new Error(`WarpArgSerializer (nativeToType): Unsupported input type: ${e}`)}stringToTyped(e){let[t,r]=e.split(/:(.*)/,2);if(t==="null"||t===null)return new n.NothingValue;if(t==="option"){let a=this.stringToTyped(r);return a instanceof n.NothingValue?n.OptionValue.newMissingTyped(a.getType()):n.OptionValue.newProvided(a)}if(t==="optional"){let a=this.stringToTyped(r);return a instanceof n.NothingValue?n.OptionalValue.newMissing():new n.OptionalValue(a.getType(),a)}if(t==="list"){let[a,s]=r.split(le,2),i=s.split(",").map(m=>this.stringToTyped(`${a}:${m}`));return new n.List(this.nativeToType(a),i)}if(t==="variadic"){let[a,s]=r.split(le,2),i=s.split(",").map(m=>this.stringToTyped(`${a}:${m}`));return new n.VariadicValue(new n.VariadicType(this.nativeToType(a)),i)}if(t.startsWith("composite")){let a=t.match(/\(([^)]+)\)/)?.[1],s=r.split(T.WarpConstants.ArgCompositeSeparator),c=a.split(T.WarpConstants.ArgCompositeSeparator),i=s.map((l,d)=>this.stringToTyped(`${c[d]}:${l}`)),m=i.map(l=>l.getType());return new n.CompositeValue(new n.CompositeType(...m),i)}if(t==="string")return r?n.StringValue.fromUTF8(r):new n.NothingValue;if(t==="uint8")return r?new n.U8Value(Number(r)):new n.NothingValue;if(t==="uint16")return r?new n.U16Value(Number(r)):new n.NothingValue;if(t==="uint32")return r?new n.U32Value(Number(r)):new n.NothingValue;if(t==="uint64")return r?new n.U64Value(BigInt(r)):new n.NothingValue;if(t==="biguint")return r?new n.BigUIntValue(BigInt(r)):new n.NothingValue;if(t==="bool")return r?new n.BooleanValue(typeof r=="boolean"?r:r==="true"):new n.NothingValue;if(t==="address")return r?new n.AddressValue(n.Address.newFromBech32(r)):new n.NothingValue;if(t==="token")return r?new n.TokenIdentifierValue(r):new n.NothingValue;if(t==="hex")return r?n.BytesValue.fromHex(r):new n.NothingValue;if(t==="codemeta")return new n.CodeMetadataValue(n.CodeMetadata.newFromBytes(Uint8Array.from(Buffer.from(r,"hex"))));if(t==="asset"){let a=r.split(T.WarpConstants.ArgCompositeSeparator);return new n.Struct(this.nativeToType("asset"),[new n.Field(new n.TokenIdentifierValue(a[0]),"token_identifier"),new n.Field(new n.U64Value(BigInt(a[1])),"token_nonce"),new n.Field(new n.BigUIntValue(BigInt(a[2])),"amount")])}throw new Error(`WarpArgSerializer (stringToTyped): Unsupported input type: ${t}`)}typeToString(e){if(e.hasExactClass(n.OptionType.ClassName))return"option:"+this.typeToString(e.getFirstTypeParameter());if(e.hasExactClass(n.OptionalType.ClassName))return"optional:"+this.typeToString(e.getFirstTypeParameter());if(e.hasExactClass(n.ListType.ClassName))return"list:"+this.typeToString(e.getFirstTypeParameter());if(e.hasExactClass(n.VariadicType.ClassName))return"variadic:"+this.typeToString(e.getFirstTypeParameter());if(e.hasExactClass(n.StringType.ClassName))return"string";if(e.hasExactClass(n.U8Type.ClassName))return"uint8";if(e.hasExactClass(n.U16Type.ClassName))return"uint16";if(e.hasExactClass(n.U32Type.ClassName))return"uint32";if(e.hasExactClass(n.U64Type.ClassName))return"uint64";if(e.hasExactClass(n.BigUIntType.ClassName))return"biguint";if(e.hasExactClass(n.BooleanType.ClassName))return"bool";if(e.hasExactClass(n.AddressType.ClassName))return"address";if(e.hasExactClass(n.TokenIdentifierType.ClassName))return"token";if(e.hasExactClass(n.BytesType.ClassName))return"hex";if(e.hasExactClass(n.CodeMetadataType.ClassName))return"codemeta";if(e.hasExactClass(n.StructType.ClassName)&&e.getClassName()==="EsdtTokenPayment")return"asset";throw new Error(`WarpArgSerializer (typeToString): Unsupported input type: ${e.getClassName()}`)}};var U=class{constructor(e,t){this.config=e;this.chain=t;this.abi=new F(e,t),this.serializer=new R,this.cache=new y.WarpCache(e.cache?.type)}async getTransactionExecutionResults(e,t){let{actionIndex:r}=(0,y.findWarpExecutableAction)(e),a=this.cache.get(y.WarpCacheKey.WarpExecutable(this.config.env,e.meta?.hash||"",r))??[],s=await this.extractContractResults(e,t,a),c=(0,y.getNextInfo)(this.config,[],e,r,s),i=(0,y.applyResultsToMessages)(e,s.results);return{success:t.status.isSuccessful(),warp:e,action:r,user:this.config.user?.wallets?.[this.chain.name]||null,txHash:t.hash,tx:t,next:c,values:s.values,valuesRaw:[],results:s.results,messages:i}}async extractContractResults(e,t,r){let{action:a,actionIndex:s}=(0,y.findWarpExecutableAction)(e),c=[],i={};if(!e.results||a.type!=="contract")return{values:c,results:i};if(!Object.values(e.results).some(v=>v.includes("out")||v.includes("event"))){for(let[v,g]of Object.entries(e.results))i[v]=g;return{values:c,results:await(0,y.evaluateResultsCommon)(e,i,s,r,this.config.transform?.runner)}}let l=await this.abi.getAbiForAction(a),d=new M.TransactionEventsParser({abi:l}),C=new M.SmartContractTransactionsOutcomeParser({abi:l}).parseExecute({transactionOnNetwork:t,function:a.func||void 0});for(let[v,g]of Object.entries(e.results)){if(g.startsWith(y.WarpConstants.Transform.Prefix))continue;if(g.startsWith("input.")){i[v]=g;continue}let B=(0,y.parseResultsOutIndex)(g);if(B!==null&&B!==s){i[v]=null;continue}let[E,A,k]=g.split(".");if(E==="event"){if(!A||isNaN(Number(k)))continue;let I=Number(k),x=(0,M.findEventsByFirstTopic)(t,A),L=d.parseEvents({events:x})[0],K=Object.values(L)[I]||null;c.push(K),i[v]=K&&K.valueOf()}else if(E==="out"||E.startsWith("out[")){if(!A)continue;let I=Number(A),x=C.values[I-1]||null;k&&(x=x[k]||null),x&&typeof x=="object"&&(x="toFixed"in x?x.toFixed():x.valueOf()),c.push(x),i[v]=x&&x.valueOf()}else i[v]=g}return{values:c,results:await(0,y.evaluateResultsCommon)(e,i,s,r)}}async extractQueryResults(e,t,r,a){let s=t.map(l=>this.serializer.typedToString(l)),c=t.map(l=>this.serializer.typedToNative(l)[1]),i={};if(!e.results)return{values:s,valuesRaw:c,results:i};let m=l=>{let d=l.split(".").slice(1).map(C=>parseInt(C)-1);if(d.length===0)return;let h=c[d[0]];for(let C=1;C<d.length;C++){if(h==null)return;h=h[d[C]]}return h};for(let[l,d]of Object.entries(e.results)){if(d.startsWith(y.WarpConstants.Transform.Prefix))continue;let h=(0,y.parseResultsOutIndex)(d);if(h!==null&&h!==r){i[l]=null;continue}d.startsWith("out.")||d==="out"||d.startsWith("out[")?i[l]=m(d)||null:i[l]=d}return{values:s,valuesRaw:c,results:await(0,y.evaluateResultsCommon)(e,i,r,a)}}async resolveWarpResultsRecursively(e){let t=e.warp,r=e.entryActionIndex,a=e.executor,s=e.inputs,c=e.meta,i=new Map,m=new Set,l=this;async function d(g,B=[]){if(i.has(g))return i.get(g);if(m.has(g))throw new Error(`Circular dependency detected at action ${g}`);m.add(g);let E=t.actions[g-1];if(!E)throw new Error(`Action ${g} not found`);let A;if(E.type==="query")A=await a.executeQuery(t,g,B);else if(E.type==="collect")A=await a.executeCollect(t,g,B,c);else throw new Error(`Unsupported or interactive action type: ${E.type}`);if(i.set(g,A),t.results)for(let k of Object.values(t.results)){let x=String(k).match(/^out\[(\d+)\]/);if(x){let L=parseInt(x[1],10);L!==g&&!i.has(L)&&await d(L)}}return m.delete(g),A}await d(r,s);let h={};for(let g of i.values())for(let[B,E]of Object.entries(g.results))E!==null?h[B]=E:B in h||(h[B]=null);let C=await(0,y.evaluateResultsCommon)(t,h,r,s,this.config.transform?.runner);return{...i.get(r),action:r,results:C}}};var p=require("@multiversx/sdk-core"),ve=(o,e)=>o?p.OptionValue.newProvided(o):e?p.OptionValue.newMissingTyped(e):p.OptionValue.newMissing(),be=(o,e)=>o?new p.OptionalValue(o.getType(),o):e?new p.OptionalValue(e):p.OptionalValue.newMissing(),Ee=o=>{if(o.length===0)throw new Error("Cannot create a list from an empty array");let e=o[0].getType();return new p.List(e,o)},Ae=o=>p.VariadicValue.fromItems(...o),Be=o=>{let e=o.map(t=>t.getType());return new p.CompositeValue(new p.CompositeType(...e),o)},Ie=o=>p.StringValue.fromUTF8(o),Ve=o=>new p.U8Value(o),Ne=o=>new p.U16Value(o),Se=o=>new p.U32Value(o),Re=o=>new p.U64Value(o),Fe=o=>new p.BigUIntValue(BigInt(o)),ke=o=>new p.BooleanValue(o),Pe=o=>new p.AddressValue(p.Address.newFromBech32(o)),Ue=o=>new p.TokenIdentifierValue(o),_e=o=>p.BytesValue.fromHex(o),re=o=>new p.Struct(new p.StructType("EsdtTokenPayment",[new p.FieldDefinition("token_identifier","",new p.TokenIdentifierType),new p.FieldDefinition("token_nonce","",new p.U64Type),new p.FieldDefinition("amount","",new p.BigUIntType)]),[new p.Field(new p.TokenIdentifierValue(o.token.identifier),"token_identifier"),new p.Field(new p.U64Value(BigInt(o.token.nonce)),"token_nonce"),new p.Field(new p.BigUIntValue(BigInt(o.amount)),"amount")]),Oe=o=>new p.CodeMetadataValue(p.CodeMetadata.newFromBytes(Uint8Array.from(Buffer.from(o,"hex")))),Me=()=>new p.NothingValue;var $e="EGLD-000000",w=class o{constructor(e,t){this.config=e;this.chain=t;this.serializer=new R,this.abi=new F(this.config,this.chain),this.results=new U(this.config,this.chain)}async createTransaction(e){let t=(0,W.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=this.config.user?.wallets?.[e.chain.name];if(!t)throw new Error("WarpMultiversxExecutor: createTransfer - user address not set");let r=f.Address.newFromBech32(t),a=new f.TransactionsFactoryConfig({chainID:e.chain.chainId}),s=e.data?Buffer.from(this.serializer.stringToTyped(e.data).valueOf()):null;return new f.TransferTransactionsFactory({config:a}).createTransactionForTransfer(r,{receiver:f.Address.newFromBech32(e.destination),nativeAmount:e.value,tokenTransfers:this.toTokenTransfers(e.transfers),data:s?new Uint8Array(s):void 0})}async createContractCallTransaction(e){let t=this.config.user?.wallets?.[e.chain.name];if(!t)throw new Error("WarpMultiversxExecutor: createContractCall - user address not set");let r=(0,W.getWarpActionByIndex)(e.warp,e.action),a=f.Address.newFromBech32(t),s=e.args.map(i=>this.serializer.stringToTyped(i)),c=new f.TransactionsFactoryConfig({chainID:e.chain.chainId});return new f.SmartContractTransactionsFactory({config:c}).createTransactionForExecute(a,{contract:f.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,W.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(I=>this.serializer.stringToTyped(I)),s=o.getChainEntrypoint(e.chain,this.config.env,this.config),c=f.Address.newFromBech32(e.destination),i=s.createSmartContractController(r),m=i.createQuery({contract:c,function:t.func||"",arguments:a}),l=await i.runQuery(m),d=l.returnCode==="ok",h=new f.ArgSerializer,C=r.getEndpoint(l.function||t.func||""),v=(l.returnDataParts||[]).map(I=>Buffer.from(I)),g=h.buffersToValues(v,C.output),{values:B,valuesRaw:E,results:A}=await this.results.extractQueryResults(e.warp,g,e.action,e.resolvedInputs),k=(0,W.getNextInfo)(this.config,[],e.warp,e.action,A);return{success:d,warp:e.warp,action:e.action,user:this.config.user?.wallets?.[e.chain.name]||null,txHash:null,tx:null,next:k,values:B,valuesRaw:E,results:A,messages:(0,W.applyResultsToMessages)(e.warp,A)}}async preprocessInput(e,t,r,a){if(r==="asset"){let[s,c,i,m]=a.split(W.WarpConstants.ArgCompositeSeparator);if(m)return t;let l=new f.Token({identifier:s,nonce:BigInt(c||0)});if(!new f.TokenComputer().isFungible(l))return t;let C=(0,W.findKnownTokenById)(s)?.decimals;if(C||(C=(await(await fetch(`${e.defaultApiUrl}/tokens/${s}`)).json()).decimals),!C)throw new Error(`WarpActionExecutor: Decimals not found for token ${s}`);let v=re(new f.TokenTransfer({token:l,amount:(0,W.shiftBigintBy)(i,C)}));return this.serializer.typedToString(v)+W.WarpConstants.ArgCompositeSeparator+C}return t}static getChainEntrypoint(e,t,r){let a="warp-sdk",c=r?(0,W.getProviderUrl)(r,e.name,t,e.defaultApiUrl):e.defaultApiUrl;return t==="devnet"?new f.DevnetEntrypoint({url:c,kind:"api",clientName:a}):t==="testnet"?new f.TestnetEntrypoint({url:c,kind:"api",clientName:a}):new f.MainnetEntrypoint({url:c,kind:"api",clientName:a})}async signMessage(e,t){let r=f.UserSecretKey.fromString(t);return(await new f.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:$e}:t).map(t=>new f.TokenTransfer({token:new f.Token({identifier:t.identifier,nonce:t.nonce}),amount:t.amount}))}};var q=class{constructor(e){this.config=e}async getContract(e,t){try{let s=await w.getChainEntrypoint(t,this.config.env).createNetworkProvider().doGetGeneric(`accounts/${e}`);return{address:e,owner:s.ownerAddress,verified:s.isVerified||!1}}catch(r){return ne.WarpLogger.error("WarpContractLoader: getContract error",r),null}}async getVerificationInfo(e,t){try{let s=await w.getChainEntrypoint(t,this.config.env).createNetworkProvider().doGetGeneric(`accounts/${e}/verification`);return{codeHash:s.codeHash,abi:s.source.abi}}catch(r){return ne.WarpLogger.error("WarpContractLoader: getVerificationInfo error",r),null}}};var F=class{constructor(e,t){this.config=e;this.chain=t;this.contractLoader=new q(this.config),this.cache=new V.WarpCache(this.config.cache?.type)}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=V.WarpCacheKey.WarpAbi(this.config.env,e);if(t){let c=this.cache.get(r);if(c)return V.WarpLogger.info(`WarpAbiBuilder (createFromTransactionHash): Warp abi found in cache: ${e}`),c}let s=w.getChainEntrypoint(this.chain,this.config.env).createNetworkProvider();try{let c=await s.getTransaction(e),i=await this.createFromTransaction(c);return t&&t.ttl&&i&&this.cache.set(r,i,t.ttl),i}catch(c){return V.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 J.AbiRegistry.create(t.abi)}async fetchAbi(e){if(!e.abi)throw new Error("WarpActionExecutor: ABI not found");if(e.abi.startsWith(V.WarpConstants.IdentifierType.Hash)){let t=e.abi.split(V.WarpConstants.IdentifierParamSeparatorDefault)[1],r=await this.createFromTransactionHash(t);if(!r)throw new Error(`WarpActionExecutor: ABI not found for hash: ${e.abi}`);return J.AbiRegistry.create(r.content)}else{let r=await(await fetch(e.abi)).json();return J.AbiRegistry.create(r)}}};var _=require("@multiversx/sdk-core"),X=require("@vleap/warps"),me=require("buffer");var D=class{constructor(e,t){this.config=e;this.chain=t;this.core=new X.WarpBrandBuilder(e)}async createInscriptionTransaction(e){let t=this.config.user?.wallets?.[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),c=JSON.stringify(e);return await a.createTransactionForNativeTokenTransfer(s,{receiver:_.Address.newFromBech32(t),nativeAmount:BigInt(0),data:Uint8Array.from(me.Buffer.from(c))})}async createFromTransaction(e,t=!1){return await this.core.createFromRaw(e.data.toString(),t)}async createFromTransactionHash(e){let r=w.getChainEntrypoint(this.chain,this.config.env).createNetworkProvider();try{let a=await r.getTransaction(e);return this.createFromTransaction(a)}catch(a){return X.WarpLogger.error("BrandBuilder: Error creating from transaction hash",a),null}}};var O=require("@multiversx/sdk-core"),N=require("@vleap/warps");var z=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=this.config.user?.wallets?.[this.chain.name];if(!r)throw new Error("WarpBuilder: user address not set");let a=new O.TransactionsFactoryConfig({chainID:this.chain.chainId}),s=new O.TransferTransactionsFactory({config:a}),c=O.Address.newFromBech32(r),i=JSON.stringify(t),m=await s.createTransactionForTransfer(c,{receiver:O.Address.newFromBech32(r),nativeAmount:BigInt(0),data:Uint8Array.from(Buffer.from(i))});return m.gasLimit=m.gasLimit+BigInt(2e6),m}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 i=this.cache.get(a);if(i)return N.WarpLogger.info(`WarpBuilder (createFromTransactionHash): Warp found in cache: ${t}`),i}let c=w.getChainEntrypoint(this.chain,this.config.env).createNetworkProvider();try{let i=await c.getTransaction(t),m=await this.createFromTransaction(i);return r&&r.ttl&&m&&this.cache.set(a,m,r.ttl),m}catch(i){return N.WarpLogger.error("WarpBuilder: Error creating from transaction hash",i),null}}};var ae=require("@multiversx/sdk-core");var H=class{constructor(e,t){this.config=e;this.chain=t}async getAccount(e){let r=await w.getChainEntrypoint(this.chain,this.config.env,this.config).createNetworkProvider().getAccount(ae.Address.newFromBech32(e));return{chain:this.chain.name,address:r.address.toBech32(),balance:r.balance}}async getAccountAssets(e){return(await w.getChainEntrypoint(this.chain,this.config.env,this.config).createNetworkProvider().getFungibleTokensOfAccount(ae.Address.newFromBech32(e))).map(a=>({chain:this.chain.name,identifier:a.token.identifier,name:a.raw.name,amount:a.amount,decimals:a.raw.decimals,logoUrl:a.raw.assets?.pngUrl||""}))}async getAccountActions(e,t){let r=w.getChainEntrypoint(this.chain,this.config.env,this.config).createNetworkProvider(),a=`accounts/${e}/transactions`,s=new URLSearchParams,c=t?.size||25,i=t?.page||0;if(i>0){let l=i*c;s.append("from",l.toString())}return c!==25&&s.append("size",c.toString()),s.toString()&&(a+=`?${s.toString()}`),(await r.doGetGeneric(a)).map(l=>({chain:this.chain.name,id:l.txHash,receiver:l.receiver,sender:l.sender,value:l.value,function:l.function,status:l.status,createdAt:new Date(l.timestampMs||l.timestamp*1e3).toISOString()}))}};var Le={Egld:{Identifier:"EGLD",EsdtIdentifier:"EGLD-000000",DisplayName:"eGold",Decimals:18}},fe=(r=>(r.MultiversxExplorer="multiversx_explorer",r.MultiversxExplorerDevnet="multiversx_explorer_devnet",r.MultiversxExplorerTestnet="multiversx_explorer_testnet",r))(fe||{}),de=(r=>(r.VibechainExplorer="vibechain_explorer",r.VibechainExplorerDevnet="vibechain_explorer_devnet",r.VibechainExplorerTestnet="vibechain_explorer_testnet",r))(de||{}),se={multiversx:{mainnet:["multiversx_explorer"],testnet:["multiversx_explorer_testnet"],devnet:["multiversx_explorer_devnet"]},vibechain:{mainnet:["vibechain_explorer"],testnet:["vibechain_explorer_testnet"],devnet:["vibechain_explorer_devnet"]}},P={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 Q=class{constructor(e,t){this.chain=e;this.config=t}getExplorers(){let e=se[this.chain];if(!e)return["multiversx_explorer"];let t=e[this.config.env];return t||["multiversx_explorer"]}getPrimaryExplorer(){return this.getExplorers()[0]}getExplorerUrlByName(e){let t=this.config.preferences?.explorers?.[this.chain];if(t&&!e){let s=P[t];if(s)return s}if(e){let s=P[e];if(s)return s}let r=this.getPrimaryExplorer();return P[r]||P[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=P[a];s&&(r[a]=`${s}/accounts/${e}`)}),r}getTransactionUrls(e){let t=this.getAllExplorers(),r={};return t.forEach(a=>{let s=P[a];s&&(r[a]=`${s}/transactions/${e}`)}),r}};var u=require("@multiversx/sdk-core"),S=require("@vleap/warps");var ie={buildInfo:{rustc:{version:"1.86.0",commitHash:"05f9846f893b09a1be1fc8560e33fc3c815cfecb",commitDate:"2025-03-31",channel:"Stable",short:"rustc 1.86.0 (05f9846f8 2025-03-31)"},contractCrate:{name:"registry",version:"0.0.1"},framework:{name:"multiversx-sc",version:"0.51.1"}},name:"RegistryContract",constructor:{inputs:[{name:"unit_price",type:"BigUint"},{name:"vault",type:"Address"}],outputs:[]},upgradeConstructor:{inputs:[],outputs:[]},endpoints:[{name:"registerWarp",mutability:"mutable",payableInTokens:["EGLD"],inputs:[{name:"hash",type:"bytes"},{name:"alias_opt",type:"optional<bytes>",multi_arg:!0},{name:"brand_opt",type:"optional<bytes>",multi_arg:!0}],outputs:[],allow_multiple_var_args:!0},{name:"unregisterWarp",mutability:"mutable",inputs:[{name:"warp",type:"bytes"}],outputs:[]},{name:"upgradeWarp",mutability:"mutable",payableInTokens:["EGLD"],inputs:[{name:"alias",type:"bytes"},{name:"new_warp",type:"bytes"}],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}]},{name:"setChain",onlyOwner:!0,mutability:"mutable",inputs:[{name:"name",type:"bytes"},{name:"display_name",type:"bytes"},{name:"chain_id",type:"bytes"},{name:"block_time",type:"u32"},{name:"address_hrp",type:"bytes"},{name:"api_url",type:"bytes"},{name:"explorer_url",type:"bytes"},{name:"native_token",type:"bytes"}],outputs:[]},{name:"removeChain",onlyOwner:!0,mutability:"mutable",inputs:[{name:"name",type:"bytes"}],outputs:[]},{name:"getChain",mutability:"readonly",inputs:[{name:"name",type:"bytes"}],outputs:[{type:"ChainView"}]},{name:"getChains",mutability:"readonly",inputs:[],outputs:[{type:"variadic<ChainView>",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:{ChainView:{type:"struct",fields:[{name:"name",type:"bytes"},{name:"display_name",type:"bytes"},{name:"chain_id",type:"bytes"},{name:"block_time",type:"u32"},{name:"address_hrp",type:"bytes"},{name:"api_url",type:"bytes"},{name:"explorer_url",type:"bytes"},{name:"native_token",type:"bytes"}]},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=o=>{if(o==="devnet")return"erd1qqqqqqqqqqqqqpgqje2f99vr6r7sk54thg03c9suzcvwr4nfl3tsfkdl36";if(o==="testnet")throw new Error("Multiversx testnet is not supported");return"erd1qqqqqqqqqqqqqpgq3mrpj3u6q7tejv6d7eqhnyd27n9v5c5tl3ts08mffe"};var Y=o=>({hash:o.hash.toString("hex"),alias:o.alias?.toString()||null,trust:o.trust.toString(),owner:o.owner.toString(),createdAt:o.created_at.toNumber(),upgradedAt:o.upgraded_at?.toNumber(),brand:o.brand?.toString("hex")||null,upgrade:o.upgrade?.toString("hex")||null}),he=o=>({unitPrice:BigInt(o.unit_price.toString()),admins:o.admins.map(e=>e.toBech32())});var G=class{constructor(e,t){this.config=e;this.chain=t;this.cache=new S.WarpCache(e.cache?.type),this.registryConfig={unitPrice:BigInt(0),admins:[]},this.userWallet=this.config.user?.wallets?.[this.chain.name]||null}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=u.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?[u.BytesValue.fromHex(e),u.BytesValue.fromUTF8(t),u.BytesValue.fromHex(r)]:t?[u.BytesValue.fromHex(e),u.BytesValue.fromUTF8(t)]:[u.BytesValue.fromHex(e)];return await this.getFactory().createTransactionForExecute(a,{contract:u.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=u.Address.newFromBech32(this.userWallet);return await this.getFactory().createTransactionForExecute(t,{contract:u.Address.newFromBech32(b(this.config.env)),function:"unregisterWarp",gasLimit:BigInt(1e7),arguments:[u.BytesValue.fromHex(e)]})}async createWarpUpgradeTransaction(e,t){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 r=u.Address.newFromBech32(this.userWallet);return await this.getFactory().createTransactionForExecute(r,{contract:u.Address.newFromBech32(b(this.config.env)),function:"upgradeWarp",gasLimit:BigInt(1e7),nativeTransferAmount:this.isCurrentUserAdmin()?void 0:this.registryConfig.unitPrice,arguments:[u.BytesValue.fromUTF8(e),u.BytesValue.fromHex(t)]})}async createWarpAliasSetTransaction(e,t){if(!this.userWallet)throw new Error("WarpRegistry: user address not set");let r=u.Address.newFromBech32(this.userWallet);return await this.getFactory().createTransactionForExecute(r,{contract:u.Address.newFromBech32(b(this.config.env)),function:"setWarpAlias",gasLimit:BigInt(1e7),nativeTransferAmount:this.isCurrentUserAdmin()?void 0:this.registryConfig.unitPrice,arguments:[u.BytesValue.fromHex(e),u.BytesValue.fromUTF8(t)]})}async createWarpVerifyTransaction(e){if(!this.userWallet)throw new Error("WarpRegistry: user address not set");let t=u.Address.newFromBech32(this.userWallet);return await this.getFactory().createTransactionForExecute(t,{contract:u.Address.newFromBech32(b(this.config.env)),function:"verifyWarp",gasLimit:BigInt(1e7),arguments:[u.BytesValue.fromHex(e)]})}async createWarpTransferOwnershipTransaction(e,t){if(!this.userWallet)throw new Error("WarpRegistry: user address not set");let r=u.Address.newFromBech32(this.userWallet);return await this.getFactory().createTransactionForExecute(r,{contract:u.Address.newFromBech32(b(this.config.env)),function:"transferOwnership",gasLimit:BigInt(1e7),arguments:[u.BytesValue.fromHex(e),new u.AddressValue(new u.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=u.Address.newFromBech32(this.userWallet);return await this.getFactory().createTransactionForExecute(t,{contract:u.Address.newFromBech32(b(this.config.env)),function:"registerBrand",gasLimit:BigInt(1e7),nativeTransferAmount:this.isCurrentUserAdmin()?void 0:this.registryConfig.unitPrice,arguments:[u.BytesValue.fromHex(e)]})}async createWarpBrandingTransaction(e,t){if(!this.userWallet)throw new Error("WarpRegistry: user address not set");let r=u.Address.newFromBech32(this.userWallet);return await this.getFactory().createTransactionForExecute(r,{contract:u.Address.newFromBech32(b(this.config.env)),function:"brandWarp",gasLimit:BigInt(1e7),nativeTransferAmount:this.isCurrentUserAdmin()?void 0:this.registryConfig.unitPrice,arguments:[u.BytesValue.fromHex(e),u.BytesValue.fromHex(t)]})}async getInfoByAlias(e,t){try{let r=S.WarpCacheKey.RegistryInfo(this.config.env,e),a=t?this.cache.get(r):null;if(a)return S.WarpLogger.info(`WarpRegistry (getInfoByAlias): RegistryInfo found in cache: ${e}`),a;let s=u.Address.newFromBech32(b(this.config.env)),c=this.getController(),i=c.createQuery({contract:s,function:"getInfoByAlias",arguments:[u.BytesValue.fromUTF8(e)]}),m=await c.runQuery(i),[l]=c.parseQueryResponse(m),d=l?Y(l):null,h=d?.brand?await this.fetchBrand(d.brand):null;return t&&t.ttl&&this.cache.set(r,{registryInfo:d,brand:h},t.ttl),{registryInfo:d,brand:h}}catch{return{registryInfo:null,brand:null}}}async getInfoByHash(e,t){try{let r=S.WarpCacheKey.RegistryInfo(this.config.env,e);if(t){let h=this.cache.get(r);if(h)return S.WarpLogger.info(`WarpRegistry (getInfoByHash): RegistryInfo found in cache: ${e}`),h}let a=u.Address.newFromBech32(b(this.config.env)),s=this.getController(),c=s.createQuery({contract:a,function:"getInfoByHash",arguments:[u.BytesValue.fromHex(e)]}),i=await s.runQuery(c),[m]=s.parseQueryResponse(i),l=m?Y(m):null,d=l?.brand?await this.fetchBrand(l.brand):null;return t&&t.ttl&&this.cache.set(r,{registryInfo:l,brand:d},t.ttl),{registryInfo:l,brand:d}}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=u.Address.newFromBech32(b(this.config.env)),a=this.getController(),s=a.createQuery({contract:r,function:"getUserWarps",arguments:[new u.AddressValue(new u.Address(t))]}),c=await a.runQuery(s),[i]=a.parseQueryResponse(c);return i.map(Y)}catch{return[]}}async getUserBrands(e){try{let t=e||this.userWallet;if(!t)throw new Error("WarpRegistry: user address not set");let r=u.Address.newFromBech32(b(this.config.env)),a=this.getController(),s=a.createQuery({contract:r,function:"getUserBrands",arguments:[new u.AddressValue(new u.Address(t))]}),c=await a.runQuery(s),[i]=a.parseQueryResponse(c),m=i.map(h=>h.toString("hex")),l={ttl:365*24*60*60};return(await Promise.all(m.map(h=>this.fetchBrand(h,l)))).filter(h=>h!==null)}catch{return[]}}async fetchBrand(e,t){let r=S.WarpCacheKey.Brand(this.config.env,e),a=t?this.cache.get(r):null;if(a)return S.WarpLogger.info(`WarpRegistry (fetchBrand): Brand found in cache: ${e}`),a;let c=w.getChainEntrypoint(this.chain,this.config.env).createNetworkProvider();try{let i=await c.getTransaction(e),m=JSON.parse(i.data.toString());return m.meta={hash:i.hash,creator:i.sender.toBech32(),createdAt:new Date(i.timestamp*1e3).toISOString()},t&&t.ttl&&this.cache.set(r,m,t.ttl),m}catch{return null}}async loadRegistryConfigs(){let e=u.Address.newFromBech32(b(this.config.env)),t=this.getController(),[r]=await t.query({contract:e,function:"getConfig",arguments:[]}),a=r?he(r):null;this.registryConfig=a||{unitPrice:BigInt(0),admins:[]}}getFactory(){let e=new u.TransactionsFactoryConfig({chainID:this.chain.chainId}),t=u.AbiRegistry.create(ie);return new u.SmartContractTransactionsFactory({config:e,abi:t})}getController(){let e=w.getChainEntrypoint(this.chain,this.config.env),t=u.AbiRegistry.create(ie);return e.createSmartContractController(t)}isCurrentUserAdmin(){return!!this.userWallet&&this.registryConfig.admins.includes(this.userWallet)}};var j=(o,e,t)=>(r,a)=>{let s=t[r.env];return{chain:o,chainInfo:s,prefix:e,builder:()=>new z(r,s),executor:new w(r,s),results:new U(r,s),serializer:new R,registry:new G(r,s),explorer:new Q(o,r),abiBuilder:()=>new F(r,s),brandBuilder:()=>new D(r,s),dataLoader:new H(r,s),registerTypes:c=>{c.registerType("token",{stringToNative:i=>i,nativeToString:i=>`token:${i}`}),c.registerType("codemeta",{stringToNative:i=>i,nativeToString:i=>`codemeta:${i}`})}}};var Z={chain:$.WarpChainName.Multiversx,identifier:"EGLD",name:"eGold",decimals:18,logoUrl:"https://vleap.ai/images/tokens/egld.svg"},oe=j($.WarpChainName.Multiversx,"mvx",{mainnet:{name:$.WarpChainName.Multiversx,displayName:"MultiversX",chainId:"1",blockTime:6e3,addressHrp:"erd",defaultApiUrl:"https://api.multiversx.com",nativeToken:Z},testnet:{name:$.WarpChainName.Multiversx,displayName:"MultiversX Testnet",chainId:"T",blockTime:6e3,addressHrp:"erd",defaultApiUrl:"https://testnet-api.multiversx.com",nativeToken:Z},devnet:{name:$.WarpChainName.Multiversx,displayName:"MultiversX Devnet",chainId:"D",blockTime:6e3,addressHrp:"erd",defaultApiUrl:"https://devnet-api.multiversx.com",nativeToken:Z}});var ee=require("@vleap/warps");var ge={chain:ee.WarpChainName.Vibechain,identifier:"VIBE",name:"VIBE",decimals:18,logoUrl:"https://vleap.ai/images/tokens/vibe.svg"},ce={name:ee.WarpChainName.Vibechain,displayName:"VibeChain",chainId:"V",blockTime:600,addressHrp:"vibe",defaultApiUrl:"https://vibeox-api.multiversx.com",nativeToken:ge},pe=j(ee.WarpChainName.Vibechain,"vibe",{mainnet:ce,testnet:ce,devnet:ce});var De=(o,e)=>[oe(o,e),pe(o,e)],ze=()=>[ue.WarpChainName.Multiversx,ue.WarpChainName.Vibechain];0&&(module.exports={ExplorerUrls,MultiversxExplorers,MultiversxExplorersConfig,NativeTokenEgld,NativeTokenVibe,VibechainExplorers,WarpMultiversxAbiBuilder,WarpMultiversxBrandBuilder,WarpMultiversxBuilder,WarpMultiversxConstants,WarpMultiversxContractLoader,WarpMultiversxDataLoader,WarpMultiversxExecutor,WarpMultiversxExplorer,WarpMultiversxRegistry,WarpMultiversxResults,WarpMultiversxSerializer,address_value,biguint_value,boolean_value,codemeta_value,composite_value,createMultiversxAdapter,esdt_value,getAllMultiversxAdapters,getAllMultiversxChainNames,getMultiversxAdapter,getMultiversxRegistryAddress,getVibechainAdapter,hex_value,list_value,nothing_value,option_value,optional_value,string_value,token_value,u16_value,u32_value,u64_value,u8_value,variadic_value});
|
package/dist/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{AbiRegistry as se}from"@multiversx/sdk-core";import{WarpCache as tr,WarpCacheKey as rr,WarpConstants as Ge,WarpLogger as Ke}from"@vleap/warps";import{WarpLogger as je}from"@vleap/warps";import{Address as N,ArgSerializer as $t,DevnetEntrypoint as Lt,MainnetEntrypoint as qt,SmartContractTransactionsFactory as Dt,TestnetEntrypoint as Ht,Token as De,TokenComputer as zt,TokenTransfer as He,TransactionsFactoryConfig as ze,TransferTransactionsFactory as Qt,UserSecretKey as jt,UserSigner as Gt}from"@multiversx/sdk-core";import{EGLD_IDENTIFIER_FOR_MULTI_ESDTNFT_TRANSFER as Kt}from"@multiversx/sdk-core/out/core/constants";import{applyResultsToMessages as Jt,findKnownTokenById as Xt,getNextInfo as Yt,getProviderUrl as Zt,getWarpActionByIndex as ie,shiftBigintBy as er,WarpConstants as Qe}from"@vleap/warps";import{findEventsByFirstTopic as ft,SmartContractTransactionsOutcomeParser as dt,TransactionEventsParser as gt}from"@multiversx/sdk-core";import{applyResultsToMessages as ht,evaluateResultsCommon as U,findWarpExecutableAction as Pe,getNextInfo as yt,parseResultsOutIndex as _e,WarpCache as wt,WarpCacheKey as Wt,WarpConstants as Oe}from"@vleap/warps";import{Address as st,AddressType as fe,AddressValue as de,BigUIntType as z,BigUIntValue as Q,BooleanType as ge,BooleanValue as he,BytesType as ye,BytesValue as we,CodeMetadata as ot,CodeMetadataType as We,CodeMetadataValue as Te,CompositeType as xe,CompositeValue as ve,Field as j,FieldDefinition as G,List as Ce,ListType as ct,NothingValue as x,OptionalType as pt,OptionalValue as K,OptionType as ut,OptionValue as J,StringType as be,StringValue as Ae,Struct as lt,StructType as Ee,TokenIdentifierType as X,TokenIdentifierValue as Y,U16Type as Be,U16Value as Ie,U32Type as Ve,U32Value as Se,U64Type as Z,U64Value as ee,U8Type as Fe,U8Value as Ne,VariadicType as Re,VariadicValue as ke}from"@multiversx/sdk-core";import{WarpConstants as v,WarpSerializer as mt}from"@vleap/warps";var Ue=new RegExp(`${v.ArgParamsSeparator}(.*)`),E=class{constructor(){this.coreSerializer=new mt}typedToString(e){if(e.hasClassOrSuperclass(J.ClassName))return e.isSet()?`option:${this.typedToString(e.getTypedValue())}`:"option:null";if(e.hasClassOrSuperclass(K.ClassName))return e.isSet()?`optional:${this.typedToString(e.getTypedValue())}`:"optional:null";if(e.hasClassOrSuperclass(Ce.ClassName)){let t=e.getItems(),n=t.map(o=>this.typedToString(o).split(v.ArgParamsSeparator)[0])[0],a=t.map(o=>this.typedToString(o).split(v.ArgParamsSeparator)[1]);return`list:${n}:${a.join(",")}`}if(e.hasClassOrSuperclass(ke.ClassName)){let t=e.getItems(),n=t.map(o=>this.typedToString(o).split(v.ArgParamsSeparator)[0])[0],a=t.map(o=>this.typedToString(o).split(v.ArgParamsSeparator)[1]);return`variadic:${n}:${a.join(",")}`}if(e.hasClassOrSuperclass(ve.ClassName)){let t=e.getItems(),r=t.map(i=>this.typedToString(i).split(v.ArgParamsSeparator)[0]),n=t.map(i=>this.typedToString(i).split(v.ArgParamsSeparator)[1]),a=r.join(v.ArgCompositeSeparator),o=n.join(v.ArgCompositeSeparator);return`composite(${a}):${o}`}if(e.hasClassOrSuperclass(Q.ClassName)||e.getType().getName()==="BigUint")return`biguint:${BigInt(e.valueOf().toFixed())}`;if(e.hasClassOrSuperclass(Ne.ClassName))return`uint8:${e.valueOf().toNumber()}`;if(e.hasClassOrSuperclass(Ie.ClassName))return`uint16:${e.valueOf().toNumber()}`;if(e.hasClassOrSuperclass(Se.ClassName))return`uint32:${e.valueOf().toNumber()}`;if(e.hasClassOrSuperclass(ee.ClassName))return`uint64:${BigInt(e.valueOf().toFixed())}`;if(e.hasClassOrSuperclass(Ae.ClassName))return`string:${e.valueOf()}`;if(e.hasClassOrSuperclass(he.ClassName))return`bool:${e.valueOf()}`;if(e.hasClassOrSuperclass(de.ClassName))return`address:${e.valueOf().toBech32()}`;if(e.hasClassOrSuperclass(Y.ClassName))return`token:${e.valueOf()}`;if(e.hasClassOrSuperclass(we.ClassName))return`hex:${e.valueOf().toString("hex")}`;if(e.hasClassOrSuperclass(Te.ClassName))return`codemeta:${e.valueOf().toString()}`;if(e.getType().getName()==="EsdtTokenPayment"){let t=e.getFieldValue("token_identifier").valueOf(),r=e.getFieldValue("token_nonce").valueOf(),n=e.getFieldValue("amount").valueOf();return`asset:${t}|${r}|${n}`}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){let r=this.coreSerializer.nativeToString(e,t);return this.stringToTyped(r)}nativeToType(e){if(e.startsWith("composite")){let t=e.match(/\(([^)]+)\)/)?.[1];return new xe(...t.split(v.ArgCompositeSeparator).map(r=>this.nativeToType(r)))}if(e==="string")return new be;if(e==="uint8")return new Fe;if(e==="uint16")return new Be;if(e==="uint32")return new Ve;if(e==="uint64")return new Z;if(e==="biguint")return new z;if(e==="bool")return new ge;if(e==="address")return new fe;if(e==="token")return new X;if(e==="hex")return new ye;if(e==="codemeta")return new We;if(e==="asset")return new Ee("EsdtTokenPayment",[new G("token_identifier","",new X),new G("token_nonce","",new Z),new G("amount","",new z)]);throw new Error(`WarpArgSerializer (nativeToType): Unsupported input type: ${e}`)}stringToTyped(e){let[t,r]=e.split(/:(.*)/,2);if(t==="null"||t===null)return new x;if(t==="option"){let n=this.stringToTyped(r);return n instanceof x?J.newMissingTyped(n.getType()):J.newProvided(n)}if(t==="optional"){let n=this.stringToTyped(r);return n instanceof x?K.newMissing():new K(n.getType(),n)}if(t==="list"){let[n,a]=r.split(Ue,2),i=a.split(",").map(c=>this.stringToTyped(`${n}:${c}`));return new Ce(this.nativeToType(n),i)}if(t==="variadic"){let[n,a]=r.split(Ue,2),i=a.split(",").map(c=>this.stringToTyped(`${n}:${c}`));return new ke(new Re(this.nativeToType(n)),i)}if(t.startsWith("composite")){let n=t.match(/\(([^)]+)\)/)?.[1],a=r.split(v.ArgCompositeSeparator),o=n.split(v.ArgCompositeSeparator),i=a.map((p,u)=>this.stringToTyped(`${o[u]}:${p}`)),c=i.map(p=>p.getType());return new ve(new xe(...c),i)}if(t==="string")return r?Ae.fromUTF8(r):new x;if(t==="uint8")return r?new Ne(Number(r)):new x;if(t==="uint16")return r?new Ie(Number(r)):new x;if(t==="uint32")return r?new Se(Number(r)):new x;if(t==="uint64")return r?new ee(BigInt(r)):new x;if(t==="biguint")return r?new Q(BigInt(r)):new x;if(t==="bool")return r?new he(typeof r=="boolean"?r:r==="true"):new x;if(t==="address")return r?new de(st.newFromBech32(r)):new x;if(t==="token")return r?new Y(r):new x;if(t==="hex")return r?we.fromHex(r):new x;if(t==="codemeta")return new Te(ot.newFromBytes(Uint8Array.from(Buffer.from(r,"hex"))));if(t==="asset"){let n=r.split(v.ArgCompositeSeparator);return new lt(this.nativeToType("asset"),[new j(new Y(n[0]),"token_identifier"),new j(new ee(BigInt(n[1])),"token_nonce"),new j(new Q(BigInt(n[2])),"amount")])}throw new Error(`WarpArgSerializer (stringToTyped): Unsupported input type: ${t}`)}typeToString(e){if(e instanceof ut)return"option:"+this.typeToString(e.getFirstTypeParameter());if(e instanceof pt)return"optional:"+this.typeToString(e.getFirstTypeParameter());if(e instanceof ct)return"list:"+this.typeToString(e.getFirstTypeParameter());if(e instanceof Re)return"variadic:"+this.typeToString(e.getFirstTypeParameter());if(e instanceof be)return"string";if(e instanceof Fe)return"uint8";if(e instanceof Be)return"uint16";if(e instanceof Ve)return"uint32";if(e instanceof Z)return"uint64";if(e instanceof z)return"biguint";if(e instanceof ge)return"bool";if(e instanceof fe)return"address";if(e instanceof X)return"token";if(e instanceof ye)return"hex";if(e instanceof We)return"codemeta";if(e instanceof Ee&&e.getClassName()==="EsdtTokenPayment")return"asset";throw new Error(`WarpArgSerializer (typeToString): Unsupported input type: ${e.getClassName()}`)}};var V=class{constructor(e,t){this.config=e;this.chain=t;this.abi=new B(e,t),this.serializer=new E,this.cache=new wt(e.cache?.type)}async getTransactionExecutionResults(e,t){let{actionIndex:r}=Pe(e),n=this.cache.get(Wt.WarpExecutable(this.config.env,e.meta?.hash||"",r))??[],a=await this.extractContractResults(e,t,n),o=yt(this.config,[],e,r,a),i=ht(e,a.results);return{success:t.status.isSuccessful(),warp:e,action:r,user:this.config.user?.wallets?.[this.chain.name]||null,txHash:t.hash,tx:t,next:o,values:a.values,results:a.results,messages:i}}async extractContractResults(e,t,r){let{action:n,actionIndex:a}=Pe(e),o=[],i={};if(!e.results||n.type!=="contract")return{values:o,results:i};if(!Object.values(e.results).some(w=>w.includes("out")||w.includes("event"))){for(let[w,m]of Object.entries(e.results))i[w]=m;return{values:o,results:await U(e,i,a,r,this.config.transform?.runner)}}let p=await this.abi.getAbiForAction(n),u=new gt({abi:p}),h=new dt({abi:p}).parseExecute({transactionOnNetwork:t,function:n.func||void 0});for(let[w,m]of Object.entries(e.results)){if(m.startsWith(Oe.Transform.Prefix))continue;if(m.startsWith("input.")){i[w]=m;continue}let C=_e(m);if(C!==null&&C!==a){i[w]=null;continue}let[W,A,b]=m.split(".");if(W==="event"){if(!A||isNaN(Number(b)))continue;let R=Number(b),y=ft(t,A),F=u.parseEvents({events:y})[0],k=Object.values(F)[R]||null;o.push(k),i[w]=k&&k.valueOf()}else if(W==="out"||W.startsWith("out[")){if(!A)continue;let R=Number(A),y=h.values[R-1]||null;b&&(y=y[b]||null),y&&typeof y=="object"&&(y="toFixed"in y?y.toFixed():y.valueOf()),o.push(y),i[w]=y&&y.valueOf()}else i[w]=m}return{values:o,results:await U(e,i,a,r)}}async extractQueryResults(e,t,r,n){let a=t.map(p=>this.serializer.typedToString(p)),o=t.map(p=>this.serializer.typedToNative(p)[1]),i={};if(!e.results)return{values:a,results:i};let c=p=>{let u=p.split(".").slice(1).map(h=>parseInt(h)-1);if(u.length===0)return;let l=o[u[0]];for(let h=1;h<u.length;h++){if(l==null)return;l=l[u[h]]}return l};for(let[p,u]of Object.entries(e.results)){if(u.startsWith(Oe.Transform.Prefix))continue;let l=_e(u);if(l!==null&&l!==r){i[p]=null;continue}u.startsWith("out.")||u==="out"||u.startsWith("out[")?i[p]=c(u)||null:i[p]=u}return{values:a,results:await U(e,i,r,n)}}async resolveWarpResultsRecursively(e){let t=e.warp,r=e.entryActionIndex,n=e.executor,a=e.inputs,o=e.meta,i=new Map,c=new Set,p=this;async function u(m,C=[]){if(i.has(m))return i.get(m);if(c.has(m))throw new Error(`Circular dependency detected at action ${m}`);c.add(m);let W=t.actions[m-1];if(!W)throw new Error(`Action ${m} not found`);let A;if(W.type==="query")A=await n.executeQuery(t,m,C);else if(W.type==="collect")A=await n.executeCollect(t,m,C,o);else throw new Error(`Unsupported or interactive action type: ${W.type}`);if(i.set(m,A),t.results)for(let b of Object.values(t.results)){let y=String(b).match(/^out\[(\d+)\]/);if(y){let F=parseInt(y[1],10);F!==m&&!i.has(F)&&await u(F)}}return c.delete(m),A}await u(r,a);let l={};for(let m of i.values())for(let[C,W]of Object.entries(m.results))W!==null?l[C]=W:C in l||(l[C]=null);let h=await U(t,l,r,a,this.config.transform?.runner);return{...i.get(r),action:r,results:h}}};import{Address as Tt,AddressValue as xt,BigUIntType as vt,BigUIntValue as Me,BooleanValue as Ct,BytesValue as bt,CodeMetadata as At,CodeMetadataValue as Et,CompositeType as Bt,CompositeValue as It,Field as te,FieldDefinition as re,List as Vt,NothingValue as St,OptionalValue as ne,OptionValue as ae,StringValue as Ft,Struct as Nt,StructType as Rt,TokenIdentifierType as kt,TokenIdentifierValue as $e,U16Value as Ut,U32Value as Pt,U64Type as _t,U64Value as Le,U8Value as Ot,VariadicValue as Mt}from"@multiversx/sdk-core";var Kr=(s,e)=>s?ae.newProvided(s):e?ae.newMissingTyped(e):ae.newMissing(),Jr=(s,e)=>s?new ne(s.getType(),s):e?new ne(e):ne.newMissing(),Xr=s=>{if(s.length===0)throw new Error("Cannot create a list from an empty array");let e=s[0].getType();return new Vt(e,s)},Yr=s=>Mt.fromItems(...s),Zr=s=>{let e=s.map(t=>t.getType());return new It(new Bt(...e),s)},en=s=>Ft.fromUTF8(s),tn=s=>new Ot(s),rn=s=>new Ut(s),nn=s=>new Pt(s),an=s=>new Le(s),sn=s=>new Me(BigInt(s)),on=s=>new Ct(s),cn=s=>new xt(Tt.newFromBech32(s)),pn=s=>new $e(s),un=s=>bt.fromHex(s),qe=s=>new Nt(new Rt("EsdtTokenPayment",[new re("token_identifier","",new kt),new re("token_nonce","",new _t),new re("amount","",new vt)]),[new te(new $e(s.token.identifier),"token_identifier"),new te(new Le(BigInt(s.token.nonce)),"token_nonce"),new te(new Me(BigInt(s.amount)),"amount")]),ln=s=>new Et(At.newFromBytes(Uint8Array.from(Buffer.from(s,"hex")))),mn=()=>new St;var d=class s{constructor(e,t){this.config=e;this.chain=t;this.serializer=new E,this.abi=new B(this.config,this.chain),this.results=new V(this.config,this.chain)}async createTransaction(e){let t=ie(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=this.config.user?.wallets?.[e.chain.name];if(!t)throw new Error("WarpMultiversxExecutor: createTransfer - user address not set");let r=N.newFromBech32(t),n=new ze({chainID:e.chain.chainId}),a=e.data?Buffer.from(this.serializer.stringToTyped(e.data).valueOf()):null;return new Qt({config:n}).createTransactionForTransfer(r,{receiver:N.newFromBech32(e.destination),nativeAmount:e.value,tokenTransfers:this.toTokenTransfers(e.transfers),data:a?new Uint8Array(a):void 0})}async createContractCallTransaction(e){let t=this.config.user?.wallets?.[e.chain.name];if(!t)throw new Error("WarpMultiversxExecutor: createContractCall - user address not set");let r=ie(e.warp,e.action),n=N.newFromBech32(t),a=e.args.map(i=>this.serializer.stringToTyped(i)),o=new ze({chainID:e.chain.chainId});return new Dt({config:o}).createTransactionForExecute(n,{contract:N.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=ie(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(b=>this.serializer.stringToTyped(b)),a=s.getChainEntrypoint(e.chain,this.config.env,this.config),o=N.newFromBech32(e.destination),i=a.createSmartContractController(r),c=i.createQuery({contract:o,function:t.func||"",arguments:n}),p=await i.runQuery(c),u=p.returnCode==="ok",l=new $t,h=r.getEndpoint(p.function||t.func||""),w=(p.returnDataParts||[]).map(b=>Buffer.from(b)),m=l.buffersToValues(w,h.output),{values:C,results:W}=await this.results.extractQueryResults(e.warp,m,e.action,e.resolvedInputs),A=Yt(this.config,[],e.warp,e.action,W);return{success:u,warp:e.warp,action:e.action,user:this.config.user?.wallets?.[e.chain.name]||null,txHash:null,tx:null,next:A,values:C,results:W,messages:Jt(e.warp,W)}}async preprocessInput(e,t,r,n){if(r==="asset"){let[a,o,i,c]=n.split(Qe.ArgCompositeSeparator);if(c)return t;let p=new De({identifier:a,nonce:BigInt(o||0)});if(!new zt().isFungible(p))return t;let h=Xt(a)?.decimals;if(h||(h=(await(await fetch(`${e.defaultApiUrl}/tokens/${a}`)).json()).decimals),!h)throw new Error(`WarpActionExecutor: Decimals not found for token ${a}`);let w=qe(new He({token:p,amount:er(i,h)}));return this.serializer.typedToString(w)+Qe.ArgCompositeSeparator+h}return t}static getChainEntrypoint(e,t,r){let n="warp-sdk",o=r?Zt(r,e.name,t,e.defaultApiUrl):e.defaultApiUrl;return t==="devnet"?new Lt({url:o,kind:"api",clientName:n}):t==="testnet"?new Ht({url:o,kind:"api",clientName:n}):new qt({url:o,kind:"api",clientName:n})}async signMessage(e,t){let r=jt.fromString(t);return(await new Gt(r).sign(new Uint8Array(Buffer.from(e,"utf-8")))).toString()}toTokenTransfers(e){return e.map(t=>t.identifier===this.chain.nativeToken.identifier?{...t,identifier:Kt}:t).map(t=>new He({token:new De({identifier:t.identifier,nonce:t.nonce}),amount:t.amount}))}};var P=class{constructor(e){this.config=e}async getContract(e,t){try{let a=await d.getChainEntrypoint(t,this.config.env).createNetworkProvider().doGetGeneric(`accounts/${e}`);return{address:e,owner:a.ownerAddress,verified:a.isVerified||!1}}catch(r){return je.error("WarpContractLoader: getContract error",r),null}}async getVerificationInfo(e,t){try{let a=await d.getChainEntrypoint(t,this.config.env).createNetworkProvider().doGetGeneric(`accounts/${e}/verification`);return{codeHash:a.codeHash,abi:a.source.abi}}catch(r){return je.error("WarpContractLoader: getVerificationInfo error",r),null}}};var B=class{constructor(e,t){this.config=e;this.chain=t;this.contractLoader=new P(this.config),this.cache=new tr(this.config.cache?.type)}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=rr.WarpAbi(this.config.env,e);if(t){let o=this.cache.get(r);if(o)return Ke.info(`WarpAbiBuilder (createFromTransactionHash): Warp abi found in cache: ${e}`),o}let a=d.getChainEntrypoint(this.chain,this.config.env).createNetworkProvider();try{let o=await a.getTransaction(e),i=await this.createFromTransaction(o);return t&&t.ttl&&i&&this.cache.set(r,i,t.ttl),i}catch(o){return Ke.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 se.create(t.abi)}async fetchAbi(e){if(!e.abi)throw new Error("WarpActionExecutor: ABI not found");if(e.abi.startsWith(Ge.IdentifierType.Hash)){let t=e.abi.split(Ge.IdentifierParamSeparatorDefault)[1],r=await this.createFromTransactionHash(t);if(!r)throw new Error(`WarpActionExecutor: ABI not found for hash: ${e.abi}`);return se.create(r.content)}else{let r=await(await fetch(e.abi)).json();return se.create(r)}}};import{Address as Je,TransactionsFactoryConfig as nr,TransferTransactionsFactory as ar}from"@multiversx/sdk-core";import{WarpBrandBuilder as ir,WarpLogger as sr}from"@vleap/warps";import{Buffer as or}from"buffer";var _=class{constructor(e,t){this.config=e;this.chain=t;this.core=new ir(e)}async createInscriptionTransaction(e){let t=this.config.user?.wallets?.[this.chain.name];if(!t)throw new Error("BrandBuilder: user address not set");let r=new nr({chainID:this.chain.chainId}),n=new ar({config:r}),a=Je.newFromBech32(t),o=JSON.stringify(e);return await n.createTransactionForNativeTokenTransfer(a,{receiver:Je.newFromBech32(t),nativeAmount:BigInt(0),data:Uint8Array.from(or.from(o))})}async createFromTransaction(e,t=!1){return await this.core.createFromRaw(e.data.toString(),t)}async createFromTransactionHash(e){let r=d.getChainEntrypoint(this.chain,this.config.env).createNetworkProvider();try{let n=await r.getTransaction(e);return this.createFromTransaction(n)}catch(n){return sr.error("BrandBuilder: Error creating from transaction hash",n),null}}};import{Address as Xe,TransactionsFactoryConfig as cr,TransferTransactionsFactory as pr}from"@multiversx/sdk-core";import{WarpBuilder as Ye,WarpCache as ur,WarpCacheKey as lr,WarpLogger as Ze}from"@vleap/warps";var O=class extends Ye{constructor(t,r){super(t);this.config=t;this.chain=r;this.cache=new ur(t.cache?.type),this.core=new Ye(t)}async createInscriptionTransaction(t){let r=this.config.user?.wallets?.[this.chain.name];if(!r)throw new Error("WarpBuilder: user address not set");let n=new cr({chainID:this.chain.chainId}),a=new pr({config:n}),o=Xe.newFromBech32(r),i=JSON.stringify(t),c=await a.createTransactionForTransfer(o,{receiver:Xe.newFromBech32(r),nativeAmount:BigInt(0),data:Uint8Array.from(Buffer.from(i))});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=lr.Warp(this.config.env,t);if(r){let i=this.cache.get(n);if(i)return Ze.info(`WarpBuilder (createFromTransactionHash): Warp found in cache: ${t}`),i}let o=d.getChainEntrypoint(this.chain,this.config.env).createNetworkProvider();try{let i=await o.getTransaction(t),c=await this.createFromTransaction(i);return r&&r.ttl&&c&&this.cache.set(n,c,r.ttl),c}catch(i){return Ze.error("WarpBuilder: Error creating from transaction hash",i),null}}};import{Address as et}from"@multiversx/sdk-core";var M=class{constructor(e,t){this.config=e;this.chain=t}async getAccount(e){let r=await d.getChainEntrypoint(this.chain,this.config.env,this.config).createNetworkProvider().getAccount(et.newFromBech32(e));return{address:r.address.toBech32(),balance:r.balance}}async getAccountAssets(e){return(await d.getChainEntrypoint(this.chain,this.config.env,this.config).createNetworkProvider().getFungibleTokensOfAccount(et.newFromBech32(e))).map(n=>({identifier:n.token.identifier,name:n.raw.name,amount:n.amount,decimals:n.raw.decimals,logoUrl:n.raw.assets?.pngUrl||""}))}};var Ca={Egld:{Identifier:"EGLD",EsdtIdentifier:"EGLD-000000",DisplayName:"eGold",Decimals:18}},mr=(r=>(r.MultiversxExplorer="multiversx_explorer",r.MultiversxExplorerDevnet="multiversx_explorer_devnet",r.MultiversxExplorerTestnet="multiversx_explorer_testnet",r))(mr||{}),fr=(r=>(r.VibechainExplorer="vibechain_explorer",r.VibechainExplorerDevnet="vibechain_explorer_devnet",r.VibechainExplorerTestnet="vibechain_explorer_testnet",r))(fr||{}),tt={multiversx:{mainnet:["multiversx_explorer"],testnet:["multiversx_explorer_testnet"],devnet:["multiversx_explorer_devnet"]},vibechain:{mainnet:["vibechain_explorer"],testnet:["vibechain_explorer_testnet"],devnet:["vibechain_explorer_devnet"]}},I={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 $=class{constructor(e,t){this.chain=e;this.config=t}getExplorers(){let e=tt[this.chain];if(!e)return["multiversx_explorer"];let t=e[this.config.env];return t||["multiversx_explorer"]}getPrimaryExplorer(){return this.getExplorers()[0]}getExplorerUrlByName(e){let t=this.config.preferences?.explorers?.[this.chain];if(t&&!e){let a=I[t];if(a)return a}if(e){let a=I[e];if(a)return a}let r=this.getPrimaryExplorer();return I[r]||I[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=I[n];a&&(r[n]=`${a}/accounts/${e}`)}),r}getTransactionUrls(e){let t=this.getAllExplorers(),r={};return t.forEach(n=>{let a=I[n];a&&(r[n]=`${a}/transactions/${e}`)}),r}};import{AbiRegistry as nt,Address as f,AddressValue as ce,BytesValue as g,SmartContractTransactionsFactory as gr,TransactionsFactoryConfig as hr}from"@multiversx/sdk-core";import{WarpCache as yr,WarpCacheKey as pe,WarpLogger as ue}from"@vleap/warps";var oe={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"}],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}]},{name:"setChain",onlyOwner:!0,mutability:"mutable",inputs:[{name:"name",type:"bytes"},{name:"display_name",type:"bytes"},{name:"chain_id",type:"bytes"},{name:"block_time",type:"u32"},{name:"address_hrp",type:"bytes"},{name:"api_url",type:"bytes"},{name:"explorer_url",type:"bytes"},{name:"native_token",type:"bytes"}],outputs:[]},{name:"removeChain",onlyOwner:!0,mutability:"mutable",inputs:[{name:"name",type:"bytes"}],outputs:[]},{name:"getChain",mutability:"readonly",inputs:[{name:"name",type:"bytes"}],outputs:[{type:"ChainView"}]},{name:"getChains",mutability:"readonly",inputs:[],outputs:[{type:"variadic<ChainView>",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:{ChainView:{type:"struct",fields:[{name:"name",type:"bytes"},{name:"display_name",type:"bytes"},{name:"chain_id",type:"bytes"},{name:"block_time",type:"u32"},{name:"address_hrp",type:"bytes"},{name:"api_url",type:"bytes"},{name:"explorer_url",type:"bytes"},{name:"native_token",type:"bytes"}]},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 T=s=>{if(s==="devnet")return"erd1qqqqqqqqqqqqqpgqje2f99vr6r7sk54thg03c9suzcvwr4nfl3tsfkdl36";if(s==="testnet")throw new Error("Multiversx testnet is not supported");return"erd1qqqqqqqqqqqqqpgq3mrpj3u6q7tejv6d7eqhnyd27n9v5c5tl3ts08mffe"};var L=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}),rt=s=>({unitPrice:BigInt(s.unit_price.toString()),admins:s.admins.map(e=>e.toBech32())});var q=class{constructor(e,t){this.config=e;this.chain=t;this.cache=new yr(e.cache?.type),this.registryConfig={unitPrice:BigInt(0),admins:[]},this.userWallet=this.config.user?.wallets?.[this.chain.name]||null}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?[g.fromHex(e),g.fromUTF8(t),g.fromHex(r)]:t?[g.fromHex(e),g.fromUTF8(t)]:[g.fromHex(e)];return await this.getFactory().createTransactionForExecute(n,{contract:f.newFromBech32(T(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(T(this.config.env)),function:"unregisterWarp",gasLimit:BigInt(1e7),arguments:[g.fromHex(e)]})}async createWarpUpgradeTransaction(e,t){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 r=f.newFromBech32(this.userWallet);return await this.getFactory().createTransactionForExecute(r,{contract:f.newFromBech32(T(this.config.env)),function:"upgradeWarp",gasLimit:BigInt(1e7),nativeTransferAmount:this.isCurrentUserAdmin()?void 0:this.registryConfig.unitPrice,arguments:[g.fromUTF8(e),g.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(T(this.config.env)),function:"setWarpAlias",gasLimit:BigInt(1e7),nativeTransferAmount:this.isCurrentUserAdmin()?void 0:this.registryConfig.unitPrice,arguments:[g.fromHex(e),g.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(T(this.config.env)),function:"verifyWarp",gasLimit:BigInt(1e7),arguments:[g.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(T(this.config.env)),function:"transferOwnership",gasLimit:BigInt(1e7),arguments:[g.fromHex(e),new ce(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(T(this.config.env)),function:"registerBrand",gasLimit:BigInt(1e7),nativeTransferAmount:this.isCurrentUserAdmin()?void 0:this.registryConfig.unitPrice,arguments:[g.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(T(this.config.env)),function:"brandWarp",gasLimit:BigInt(1e7),nativeTransferAmount:this.isCurrentUserAdmin()?void 0:this.registryConfig.unitPrice,arguments:[g.fromHex(e),g.fromHex(t)]})}async getInfoByAlias(e,t){try{let r=pe.RegistryInfo(this.config.env,e),n=t?this.cache.get(r):null;if(n)return ue.info(`WarpRegistry (getInfoByAlias): RegistryInfo found in cache: ${e}`),n;let a=f.newFromBech32(T(this.config.env)),o=this.getController(),i=o.createQuery({contract:a,function:"getInfoByAlias",arguments:[g.fromUTF8(e)]}),c=await o.runQuery(i),[p]=o.parseQueryResponse(c),u=p?L(p):null,l=u?.brand?await this.fetchBrand(u.brand):null;return t&&t.ttl&&this.cache.set(r,{registryInfo:u,brand:l},t.ttl),{registryInfo:u,brand:l}}catch{return{registryInfo:null,brand:null}}}async getInfoByHash(e,t){try{let r=pe.RegistryInfo(this.config.env,e);if(t){let l=this.cache.get(r);if(l)return ue.info(`WarpRegistry (getInfoByHash): RegistryInfo found in cache: ${e}`),l}let n=f.newFromBech32(T(this.config.env)),a=this.getController(),o=a.createQuery({contract:n,function:"getInfoByHash",arguments:[g.fromHex(e)]}),i=await a.runQuery(o),[c]=a.parseQueryResponse(i),p=c?L(c):null,u=p?.brand?await this.fetchBrand(p.brand):null;return t&&t.ttl&&this.cache.set(r,{registryInfo:p,brand:u},t.ttl),{registryInfo:p,brand:u}}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(T(this.config.env)),n=this.getController(),a=n.createQuery({contract:r,function:"getUserWarps",arguments:[new ce(new f(t))]}),o=await n.runQuery(a),[i]=n.parseQueryResponse(o);return i.map(L)}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(T(this.config.env)),n=this.getController(),a=n.createQuery({contract:r,function:"getUserBrands",arguments:[new ce(new f(t))]}),o=await n.runQuery(a),[i]=n.parseQueryResponse(o),c=i.map(l=>l.toString("hex")),p={ttl:365*24*60*60};return(await Promise.all(c.map(l=>this.fetchBrand(l,p)))).filter(l=>l!==null)}catch{return[]}}async fetchBrand(e,t){let r=pe.Brand(this.config.env,e),n=t?this.cache.get(r):null;if(n)return ue.info(`WarpRegistry (fetchBrand): Brand found in cache: ${e}`),n;let o=d.getChainEntrypoint(this.chain,this.config.env).createNetworkProvider();try{let i=await o.getTransaction(e),c=JSON.parse(i.data.toString());return c.meta={hash:i.hash,creator:i.sender.toBech32(),createdAt:new Date(i.timestamp*1e3).toISOString()},t&&t.ttl&&this.cache.set(r,c,t.ttl),c}catch{return null}}async loadRegistryConfigs(){let e=f.newFromBech32(T(this.config.env)),t=this.getController(),[r]=await t.query({contract:e,function:"getConfig",arguments:[]}),n=r?rt(r):null;this.registryConfig=n||{unitPrice:BigInt(0),admins:[]}}getFactory(){let e=new hr({chainID:this.chain.chainId}),t=nt.create(oe);return new gr({config:e,abi:t})}getController(){let e=d.getChainEntrypoint(this.chain,this.config.env),t=nt.create(oe);return e.createSmartContractController(t)}isCurrentUserAdmin(){return!!this.userWallet&&this.registryConfig.admins.includes(this.userWallet)}};var D=(s,e,t)=>(r,n)=>{let a=t[r.env];return{chain:s,chainInfo:a,prefix:e,builder:()=>new O(r,a),executor:new d(r,a),results:new V(r,a),serializer:new E,registry:new q(r,a),explorer:new $(s,r),abiBuilder:()=>new B(r,a),brandBuilder:()=>new _(r,a),dataLoader:new M(r,a),registerTypes:o=>{o.registerType("token",{stringToNative:i=>i,nativeToString:i=>`token:${i}`}),o.registerType("codemeta",{stringToNative:i=>i,nativeToString:i=>`codemeta:${i}`})}}};var S="multiversx",le={identifier:"EGLD",name:"eGold",decimals:18,logoUrl:"https://vleap.ai/images/tokens/egld.svg"},at=D(S,"mvx",{mainnet:{name:S,displayName:"MultiversX",chainId:"1",blockTime:6e3,addressHrp:"erd",defaultApiUrl:"https://api.multiversx.com",nativeToken:le},testnet:{name:S,displayName:"MultiversX Testnet",chainId:"T",blockTime:6e3,addressHrp:"erd",defaultApiUrl:"https://testnet-api.multiversx.com",nativeToken:le},devnet:{name:S,displayName:"MultiversX Devnet",chainId:"D",blockTime:6e3,addressHrp:"erd",defaultApiUrl:"https://devnet-api.multiversx.com",nativeToken:le}});var H="vibechain",wr={identifier:"VIBE",name:"VIBE",decimals:18,logoUrl:"https://vleap.ai/images/tokens/vibe.svg"},me={name:H,displayName:"VibeChain",chainId:"V",blockTime:600,addressHrp:"vibe",defaultApiUrl:"https://vibeox-api.multiversx.com",nativeToken:wr},it=D(H,"vibe",{mainnet:me,testnet:me,devnet:me});var pi=(s,e)=>[at(s,e),it(s,e)],ui=()=>[S,H];export{S as ChainNameMultiversx,H as ChainNameVibechain,I as ExplorerUrls,mr as MultiversxExplorers,tt as MultiversxExplorersConfig,le as NativeTokenEgld,wr as NativeTokenVibe,fr as VibechainExplorers,B as WarpMultiversxAbiBuilder,_ as WarpMultiversxBrandBuilder,O as WarpMultiversxBuilder,Ca as WarpMultiversxConstants,P as WarpMultiversxContractLoader,d as WarpMultiversxExecutor,$ as WarpMultiversxExplorer,q as WarpMultiversxRegistry,V as WarpMultiversxResults,E as WarpMultiversxSerializer,cn as address_value,sn as biguint_value,on as boolean_value,ln as codemeta_value,Zr as composite_value,D as createMultiversxAdapter,qe as esdt_value,pi as getAllMultiversxAdapters,ui as getAllMultiversxChainNames,at as getMultiversxAdapter,T as getMultiversxRegistryAddress,it as getVibechainAdapter,un as hex_value,Xr as list_value,mn as nothing_value,Kr as option_value,Jr as optional_value,en as string_value,pn as token_value,rn as u16_value,nn as u32_value,an as u64_value,tn as u8_value,Yr as variadic_value};
|
|
1
|
+
import{WarpChainName as pt}from"@vleap/warps";import{WarpChainName as F}from"@vleap/warps";import{AbiRegistry as he}from"@multiversx/sdk-core";import{WarpCache as rr,WarpCacheKey as nr,WarpConstants as Xe,WarpLogger as Ye}from"@vleap/warps";import{WarpLogger as Je}from"@vleap/warps";import{Address as R,ArgSerializer as Lt,DevnetEntrypoint as qt,MainnetEntrypoint as Dt,SmartContractTransactionsFactory as zt,TestnetEntrypoint as Ht,Token as Qe,TokenComputer as Qt,TokenTransfer as Ge,TransactionsFactoryConfig as je,TransferTransactionsFactory as Gt,UserSecretKey as jt,UserSigner as Kt}from"@multiversx/sdk-core";import{applyResultsToMessages as Jt,findKnownTokenById as Xt,getNextInfo as Yt,getProviderUrl as Zt,getWarpActionByIndex as de,shiftBigintBy as er,WarpConstants as Ke}from"@vleap/warps";import{findEventsByFirstTopic as dt,SmartContractTransactionsOutcomeParser as ht,TransactionEventsParser as gt}from"@multiversx/sdk-core";import{applyResultsToMessages as yt,evaluateResultsCommon as O,findWarpExecutableAction as Me,getNextInfo as wt,parseResultsOutIndex as $e,WarpCache as Ct,WarpCacheKey as xt,WarpConstants as Le}from"@vleap/warps";import{Address as ut,AddressType as G,AddressValue as ve,BigUIntType as P,BigUIntValue as j,BooleanType as K,BooleanValue as be,BytesType as J,BytesValue as Ee,CodeMetadata as lt,CodeMetadataType as X,CodeMetadataValue as Ae,CompositeType as Y,CompositeValue as Be,Field as Z,FieldDefinition as ee,List as Ie,ListType as Ve,NothingValue as T,OptionalType as Ne,OptionalValue as te,OptionType as Se,OptionValue as re,StringType as ne,StringValue as Re,Struct as mt,StructType as Fe,TokenIdentifierType as U,TokenIdentifierValue as ae,U16Type as se,U16Value as ke,U32Type as ie,U32Value as Pe,U64Type as _,U64Value as oe,U8Type as ce,U8Value as Ue,VariadicType as pe,VariadicValue as _e}from"@multiversx/sdk-core";import{WarpConstants as v,WarpSerializer as ft}from"@vleap/warps";var Oe=new RegExp(`${v.ArgParamsSeparator}(.*)`),B=class{constructor(){this.coreSerializer=new ft}typedToString(e){let t=e.getType();if(t.hasExactClass(Se.ClassName)||e.hasClassOrSuperclass(re.ClassName))return e.isSet()?`option:${this.typedToString(e.getTypedValue())}`:"option:null";if(t.hasExactClass(Ne.ClassName)||e.hasClassOrSuperclass(te.ClassName))return e.isSet()?`optional:${this.typedToString(e.getTypedValue())}`:"optional:null";if(t.hasExactClass(Ve.ClassName)||e.hasClassOrSuperclass(Ie.ClassName)){let r=e.getItems(),a=r.map(s=>this.typedToString(s).split(v.ArgParamsSeparator)[0])[0],o=r.map(s=>this.typedToString(s).split(v.ArgParamsSeparator)[1]);return`list:${a}:${o.join(",")}`}if(t.hasExactClass(pe.ClassName)||e.hasClassOrSuperclass(_e.ClassName)){let r=e.getItems(),a=r.map(s=>this.typedToString(s).split(v.ArgParamsSeparator)[0])[0],o=r.map(s=>this.typedToString(s).split(v.ArgParamsSeparator)[1]);return`variadic:${a}:${o.join(",")}`}if(t.hasExactClass(Y.ClassName)||e.hasClassOrSuperclass(Be.ClassName)){let r=e.getItems(),n=r.map(p=>this.typedToString(p).split(v.ArgParamsSeparator)[0]),a=r.map(p=>this.typedToString(p).split(v.ArgParamsSeparator)[1]),o=n.join(v.ArgCompositeSeparator),s=a.join(v.ArgCompositeSeparator);return`composite(${o}):${s}`}if(t.hasExactClass(P.ClassName)||e.hasClassOrSuperclass(j.ClassName)||t.getName()==="BigUint")return`biguint:${BigInt(e.valueOf().toFixed())}`;if(t.hasExactClass(ce.ClassName)||e.hasClassOrSuperclass(Ue.ClassName))return`uint8:${e.valueOf().toNumber()}`;if(t.hasExactClass(se.ClassName)||e.hasClassOrSuperclass(ke.ClassName))return`uint16:${e.valueOf().toNumber()}`;if(t.hasExactClass(ie.ClassName)||e.hasClassOrSuperclass(Pe.ClassName))return`uint32:${e.valueOf().toNumber()}`;if(t.hasExactClass(_.ClassName)||e.hasClassOrSuperclass(oe.ClassName))return`uint64:${BigInt(e.valueOf().toFixed())}`;if(t.hasExactClass(ne.ClassName)||e.hasClassOrSuperclass(Re.ClassName))return`string:${e.valueOf()}`;if(t.hasExactClass(K.ClassName)||e.hasClassOrSuperclass(be.ClassName))return`bool:${e.valueOf()}`;if(t.hasExactClass(G.ClassName)||e.hasClassOrSuperclass(ve.ClassName))return`address:${e.valueOf().toBech32()}`;if(t.hasExactClass(U.ClassName)||e.hasClassOrSuperclass(ae.ClassName))return`token:${e.valueOf()}`;if(t.hasExactClass(J.ClassName)||e.hasClassOrSuperclass(Ee.ClassName))return`hex:${e.valueOf().toString("hex")}`;if(t.hasExactClass(X.ClassName)||e.hasClassOrSuperclass(Ae.ClassName))return`codemeta:${e.valueOf().toString()}`;if(t.getName()==="EsdtTokenPayment"){let r=e.getFieldValue("token_identifier").valueOf(),n=e.getFieldValue("token_nonce").valueOf(),a=e.getFieldValue("amount").valueOf();return`asset:${r}|${n}|${a}`}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){let r=this.coreSerializer.nativeToString(e,t);return this.stringToTyped(r)}nativeToType(e){if(e.startsWith("composite")){let t=e.match(/\(([^)]+)\)/)?.[1];return new Y(...t.split(v.ArgCompositeSeparator).map(r=>this.nativeToType(r)))}if(e==="string")return new ne;if(e==="uint8")return new ce;if(e==="uint16")return new se;if(e==="uint32")return new ie;if(e==="uint64")return new _;if(e==="biguint")return new P;if(e==="bool")return new K;if(e==="address")return new G;if(e==="token")return new U;if(e==="hex")return new J;if(e==="codemeta")return new X;if(e==="asset")return new Fe("EsdtTokenPayment",[new ee("token_identifier","",new U),new ee("token_nonce","",new _),new ee("amount","",new P)]);throw new Error(`WarpArgSerializer (nativeToType): Unsupported input type: ${e}`)}stringToTyped(e){let[t,r]=e.split(/:(.*)/,2);if(t==="null"||t===null)return new T;if(t==="option"){let n=this.stringToTyped(r);return n instanceof T?re.newMissingTyped(n.getType()):re.newProvided(n)}if(t==="optional"){let n=this.stringToTyped(r);return n instanceof T?te.newMissing():new te(n.getType(),n)}if(t==="list"){let[n,a]=r.split(Oe,2),s=a.split(",").map(p=>this.stringToTyped(`${n}:${p}`));return new Ie(this.nativeToType(n),s)}if(t==="variadic"){let[n,a]=r.split(Oe,2),s=a.split(",").map(p=>this.stringToTyped(`${n}:${p}`));return new _e(new pe(this.nativeToType(n)),s)}if(t.startsWith("composite")){let n=t.match(/\(([^)]+)\)/)?.[1],a=r.split(v.ArgCompositeSeparator),o=n.split(v.ArgCompositeSeparator),s=a.map((c,u)=>this.stringToTyped(`${o[u]}:${c}`)),p=s.map(c=>c.getType());return new Be(new Y(...p),s)}if(t==="string")return r?Re.fromUTF8(r):new T;if(t==="uint8")return r?new Ue(Number(r)):new T;if(t==="uint16")return r?new ke(Number(r)):new T;if(t==="uint32")return r?new Pe(Number(r)):new T;if(t==="uint64")return r?new oe(BigInt(r)):new T;if(t==="biguint")return r?new j(BigInt(r)):new T;if(t==="bool")return r?new be(typeof r=="boolean"?r:r==="true"):new T;if(t==="address")return r?new ve(ut.newFromBech32(r)):new T;if(t==="token")return r?new ae(r):new T;if(t==="hex")return r?Ee.fromHex(r):new T;if(t==="codemeta")return new Ae(lt.newFromBytes(Uint8Array.from(Buffer.from(r,"hex"))));if(t==="asset"){let n=r.split(v.ArgCompositeSeparator);return new mt(this.nativeToType("asset"),[new Z(new ae(n[0]),"token_identifier"),new Z(new oe(BigInt(n[1])),"token_nonce"),new Z(new j(BigInt(n[2])),"amount")])}throw new Error(`WarpArgSerializer (stringToTyped): Unsupported input type: ${t}`)}typeToString(e){if(e.hasExactClass(Se.ClassName))return"option:"+this.typeToString(e.getFirstTypeParameter());if(e.hasExactClass(Ne.ClassName))return"optional:"+this.typeToString(e.getFirstTypeParameter());if(e.hasExactClass(Ve.ClassName))return"list:"+this.typeToString(e.getFirstTypeParameter());if(e.hasExactClass(pe.ClassName))return"variadic:"+this.typeToString(e.getFirstTypeParameter());if(e.hasExactClass(ne.ClassName))return"string";if(e.hasExactClass(ce.ClassName))return"uint8";if(e.hasExactClass(se.ClassName))return"uint16";if(e.hasExactClass(ie.ClassName))return"uint32";if(e.hasExactClass(_.ClassName))return"uint64";if(e.hasExactClass(P.ClassName))return"biguint";if(e.hasExactClass(K.ClassName))return"bool";if(e.hasExactClass(G.ClassName))return"address";if(e.hasExactClass(U.ClassName))return"token";if(e.hasExactClass(J.ClassName))return"hex";if(e.hasExactClass(X.ClassName))return"codemeta";if(e.hasExactClass(Fe.ClassName)&&e.getClassName()==="EsdtTokenPayment")return"asset";throw new Error(`WarpArgSerializer (typeToString): Unsupported input type: ${e.getClassName()}`)}};var N=class{constructor(e,t){this.config=e;this.chain=t;this.abi=new I(e,t),this.serializer=new B,this.cache=new Ct(e.cache?.type)}async getTransactionExecutionResults(e,t){let{actionIndex:r}=Me(e),n=this.cache.get(xt.WarpExecutable(this.config.env,e.meta?.hash||"",r))??[],a=await this.extractContractResults(e,t,n),o=wt(this.config,[],e,r,a),s=yt(e,a.results);return{success:t.status.isSuccessful(),warp:e,action:r,user:this.config.user?.wallets?.[this.chain.name]||null,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}=Me(e),o=[],s={};if(!e.results||n.type!=="contract")return{values:o,results:s};if(!Object.values(e.results).some(w=>w.includes("out")||w.includes("event"))){for(let[w,m]of Object.entries(e.results))s[w]=m;return{values:o,results:await O(e,s,a,r,this.config.transform?.runner)}}let c=await this.abi.getAbiForAction(n),u=new gt({abi:c}),g=new ht({abi:c}).parseExecute({transactionOnNetwork:t,function:n.func||void 0});for(let[w,m]of Object.entries(e.results)){if(m.startsWith(Le.Transform.Prefix))continue;if(m.startsWith("input.")){s[w]=m;continue}let b=$e(m);if(b!==null&&b!==a){s[w]=null;continue}let[x,W,A]=m.split(".");if(x==="event"){if(!W||isNaN(Number(A)))continue;let E=Number(A),y=dt(t,W),S=u.parseEvents({events:y})[0],k=Object.values(S)[E]||null;o.push(k),s[w]=k&&k.valueOf()}else if(x==="out"||x.startsWith("out[")){if(!W)continue;let E=Number(W),y=g.values[E-1]||null;A&&(y=y[A]||null),y&&typeof y=="object"&&(y="toFixed"in y?y.toFixed():y.valueOf()),o.push(y),s[w]=y&&y.valueOf()}else s[w]=m}return{values:o,results:await O(e,s,a,r)}}async extractQueryResults(e,t,r,n){let a=t.map(c=>this.serializer.typedToString(c)),o=t.map(c=>this.serializer.typedToNative(c)[1]),s={};if(!e.results)return{values:a,valuesRaw:o,results:s};let p=c=>{let u=c.split(".").slice(1).map(g=>parseInt(g)-1);if(u.length===0)return;let l=o[u[0]];for(let g=1;g<u.length;g++){if(l==null)return;l=l[u[g]]}return l};for(let[c,u]of Object.entries(e.results)){if(u.startsWith(Le.Transform.Prefix))continue;let l=$e(u);if(l!==null&&l!==r){s[c]=null;continue}u.startsWith("out.")||u==="out"||u.startsWith("out[")?s[c]=p(u)||null:s[c]=u}return{values:a,valuesRaw:o,results:await O(e,s,r,n)}}async resolveWarpResultsRecursively(e){let t=e.warp,r=e.entryActionIndex,n=e.executor,a=e.inputs,o=e.meta,s=new Map,p=new Set,c=this;async function u(m,b=[]){if(s.has(m))return s.get(m);if(p.has(m))throw new Error(`Circular dependency detected at action ${m}`);p.add(m);let x=t.actions[m-1];if(!x)throw new Error(`Action ${m} not found`);let W;if(x.type==="query")W=await n.executeQuery(t,m,b);else if(x.type==="collect")W=await n.executeCollect(t,m,b,o);else throw new Error(`Unsupported or interactive action type: ${x.type}`);if(s.set(m,W),t.results)for(let A of Object.values(t.results)){let y=String(A).match(/^out\[(\d+)\]/);if(y){let S=parseInt(y[1],10);S!==m&&!s.has(S)&&await u(S)}}return p.delete(m),W}await u(r,a);let l={};for(let m of s.values())for(let[b,x]of Object.entries(m.results))x!==null?l[b]=x:b in l||(l[b]=null);let g=await O(t,l,r,a,this.config.transform?.runner);return{...s.get(r),action:r,results:g}}};import{Address as Wt,AddressValue as Tt,BigUIntType as vt,BigUIntValue as qe,BooleanValue as bt,BytesValue as Et,CodeMetadata as At,CodeMetadataValue as Bt,CompositeType as It,CompositeValue as Vt,Field as ue,FieldDefinition as le,List as Nt,NothingValue as St,OptionalValue as me,OptionValue as fe,StringValue as Rt,Struct as Ft,StructType as kt,TokenIdentifierType as Pt,TokenIdentifierValue as De,U16Value as Ut,U32Value as _t,U64Type as Ot,U64Value as ze,U8Value as Mt,VariadicValue as $t}from"@multiversx/sdk-core";var Jr=(i,e)=>i?fe.newProvided(i):e?fe.newMissingTyped(e):fe.newMissing(),Xr=(i,e)=>i?new me(i.getType(),i):e?new me(e):me.newMissing(),Yr=i=>{if(i.length===0)throw new Error("Cannot create a list from an empty array");let e=i[0].getType();return new Nt(e,i)},Zr=i=>$t.fromItems(...i),en=i=>{let e=i.map(t=>t.getType());return new Vt(new It(...e),i)},tn=i=>Rt.fromUTF8(i),rn=i=>new Mt(i),nn=i=>new Ut(i),an=i=>new _t(i),sn=i=>new ze(i),on=i=>new qe(BigInt(i)),cn=i=>new bt(i),pn=i=>new Tt(Wt.newFromBech32(i)),un=i=>new De(i),ln=i=>Et.fromHex(i),He=i=>new Ft(new kt("EsdtTokenPayment",[new le("token_identifier","",new Pt),new le("token_nonce","",new Ot),new le("amount","",new vt)]),[new ue(new De(i.token.identifier),"token_identifier"),new ue(new ze(BigInt(i.token.nonce)),"token_nonce"),new ue(new qe(BigInt(i.amount)),"amount")]),mn=i=>new Bt(At.newFromBytes(Uint8Array.from(Buffer.from(i,"hex")))),fn=()=>new St;var tr="EGLD-000000",d=class i{constructor(e,t){this.config=e;this.chain=t;this.serializer=new B,this.abi=new I(this.config,this.chain),this.results=new N(this.config,this.chain)}async createTransaction(e){let t=de(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=this.config.user?.wallets?.[e.chain.name];if(!t)throw new Error("WarpMultiversxExecutor: createTransfer - user address not set");let r=R.newFromBech32(t),n=new je({chainID:e.chain.chainId}),a=e.data?Buffer.from(this.serializer.stringToTyped(e.data).valueOf()):null;return new Gt({config:n}).createTransactionForTransfer(r,{receiver:R.newFromBech32(e.destination),nativeAmount:e.value,tokenTransfers:this.toTokenTransfers(e.transfers),data:a?new Uint8Array(a):void 0})}async createContractCallTransaction(e){let t=this.config.user?.wallets?.[e.chain.name];if(!t)throw new Error("WarpMultiversxExecutor: createContractCall - user address not set");let r=de(e.warp,e.action),n=R.newFromBech32(t),a=e.args.map(s=>this.serializer.stringToTyped(s)),o=new je({chainID:e.chain.chainId});return new zt({config:o}).createTransactionForExecute(n,{contract:R.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=de(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(E=>this.serializer.stringToTyped(E)),a=i.getChainEntrypoint(e.chain,this.config.env,this.config),o=R.newFromBech32(e.destination),s=a.createSmartContractController(r),p=s.createQuery({contract:o,function:t.func||"",arguments:n}),c=await s.runQuery(p),u=c.returnCode==="ok",l=new Lt,g=r.getEndpoint(c.function||t.func||""),w=(c.returnDataParts||[]).map(E=>Buffer.from(E)),m=l.buffersToValues(w,g.output),{values:b,valuesRaw:x,results:W}=await this.results.extractQueryResults(e.warp,m,e.action,e.resolvedInputs),A=Yt(this.config,[],e.warp,e.action,W);return{success:u,warp:e.warp,action:e.action,user:this.config.user?.wallets?.[e.chain.name]||null,txHash:null,tx:null,next:A,values:b,valuesRaw:x,results:W,messages:Jt(e.warp,W)}}async preprocessInput(e,t,r,n){if(r==="asset"){let[a,o,s,p]=n.split(Ke.ArgCompositeSeparator);if(p)return t;let c=new Qe({identifier:a,nonce:BigInt(o||0)});if(!new Qt().isFungible(c))return t;let g=Xt(a)?.decimals;if(g||(g=(await(await fetch(`${e.defaultApiUrl}/tokens/${a}`)).json()).decimals),!g)throw new Error(`WarpActionExecutor: Decimals not found for token ${a}`);let w=He(new Ge({token:c,amount:er(s,g)}));return this.serializer.typedToString(w)+Ke.ArgCompositeSeparator+g}return t}static getChainEntrypoint(e,t,r){let n="warp-sdk",o=r?Zt(r,e.name,t,e.defaultApiUrl):e.defaultApiUrl;return t==="devnet"?new qt({url:o,kind:"api",clientName:n}):t==="testnet"?new Ht({url:o,kind:"api",clientName:n}):new Dt({url:o,kind:"api",clientName:n})}async signMessage(e,t){let r=jt.fromString(t);return(await new Kt(r).sign(new Uint8Array(Buffer.from(e,"utf-8")))).toString()}toTokenTransfers(e){return e.map(t=>t.identifier===this.chain.nativeToken.identifier?{...t,identifier:tr}:t).map(t=>new Ge({token:new Qe({identifier:t.identifier,nonce:t.nonce}),amount:t.amount}))}};var M=class{constructor(e){this.config=e}async getContract(e,t){try{let a=await d.getChainEntrypoint(t,this.config.env).createNetworkProvider().doGetGeneric(`accounts/${e}`);return{address:e,owner:a.ownerAddress,verified:a.isVerified||!1}}catch(r){return Je.error("WarpContractLoader: getContract error",r),null}}async getVerificationInfo(e,t){try{let a=await d.getChainEntrypoint(t,this.config.env).createNetworkProvider().doGetGeneric(`accounts/${e}/verification`);return{codeHash:a.codeHash,abi:a.source.abi}}catch(r){return Je.error("WarpContractLoader: getVerificationInfo error",r),null}}};var I=class{constructor(e,t){this.config=e;this.chain=t;this.contractLoader=new M(this.config),this.cache=new rr(this.config.cache?.type)}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=nr.WarpAbi(this.config.env,e);if(t){let o=this.cache.get(r);if(o)return Ye.info(`WarpAbiBuilder (createFromTransactionHash): Warp abi found in cache: ${e}`),o}let a=d.getChainEntrypoint(this.chain,this.config.env).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 Ye.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 he.create(t.abi)}async fetchAbi(e){if(!e.abi)throw new Error("WarpActionExecutor: ABI not found");if(e.abi.startsWith(Xe.IdentifierType.Hash)){let t=e.abi.split(Xe.IdentifierParamSeparatorDefault)[1],r=await this.createFromTransactionHash(t);if(!r)throw new Error(`WarpActionExecutor: ABI not found for hash: ${e.abi}`);return he.create(r.content)}else{let r=await(await fetch(e.abi)).json();return he.create(r)}}};import{Address as Ze,TransactionsFactoryConfig as ar,TransferTransactionsFactory as sr}from"@multiversx/sdk-core";import{WarpBrandBuilder as ir,WarpLogger as or}from"@vleap/warps";import{Buffer as cr}from"buffer";var $=class{constructor(e,t){this.config=e;this.chain=t;this.core=new ir(e)}async createInscriptionTransaction(e){let t=this.config.user?.wallets?.[this.chain.name];if(!t)throw new Error("BrandBuilder: user address not set");let r=new ar({chainID:this.chain.chainId}),n=new sr({config:r}),a=Ze.newFromBech32(t),o=JSON.stringify(e);return await n.createTransactionForNativeTokenTransfer(a,{receiver:Ze.newFromBech32(t),nativeAmount:BigInt(0),data:Uint8Array.from(cr.from(o))})}async createFromTransaction(e,t=!1){return await this.core.createFromRaw(e.data.toString(),t)}async createFromTransactionHash(e){let r=d.getChainEntrypoint(this.chain,this.config.env).createNetworkProvider();try{let n=await r.getTransaction(e);return this.createFromTransaction(n)}catch(n){return or.error("BrandBuilder: Error creating from transaction hash",n),null}}};import{Address as et,TransactionsFactoryConfig as pr,TransferTransactionsFactory as ur}from"@multiversx/sdk-core";import{WarpBuilder as tt,WarpCache as lr,WarpCacheKey as mr,WarpLogger as rt}from"@vleap/warps";var L=class extends tt{constructor(t,r){super(t);this.config=t;this.chain=r;this.cache=new lr(t.cache?.type),this.core=new tt(t)}async createInscriptionTransaction(t){let r=this.config.user?.wallets?.[this.chain.name];if(!r)throw new Error("WarpBuilder: user address not set");let n=new pr({chainID:this.chain.chainId}),a=new ur({config:n}),o=et.newFromBech32(r),s=JSON.stringify(t),p=await a.createTransactionForTransfer(o,{receiver:et.newFromBech32(r),nativeAmount:BigInt(0),data:Uint8Array.from(Buffer.from(s))});return p.gasLimit=p.gasLimit+BigInt(2e6),p}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=mr.Warp(this.config.env,t);if(r){let s=this.cache.get(n);if(s)return rt.info(`WarpBuilder (createFromTransactionHash): Warp found in cache: ${t}`),s}let o=d.getChainEntrypoint(this.chain,this.config.env).createNetworkProvider();try{let s=await o.getTransaction(t),p=await this.createFromTransaction(s);return r&&r.ttl&&p&&this.cache.set(n,p,r.ttl),p}catch(s){return rt.error("WarpBuilder: Error creating from transaction hash",s),null}}};import{Address as nt}from"@multiversx/sdk-core";var q=class{constructor(e,t){this.config=e;this.chain=t}async getAccount(e){let r=await d.getChainEntrypoint(this.chain,this.config.env,this.config).createNetworkProvider().getAccount(nt.newFromBech32(e));return{chain:this.chain.name,address:r.address.toBech32(),balance:r.balance}}async getAccountAssets(e){return(await d.getChainEntrypoint(this.chain,this.config.env,this.config).createNetworkProvider().getFungibleTokensOfAccount(nt.newFromBech32(e))).map(n=>({chain:this.chain.name,identifier:n.token.identifier,name:n.raw.name,amount:n.amount,decimals:n.raw.decimals,logoUrl:n.raw.assets?.pngUrl||""}))}async getAccountActions(e,t){let r=d.getChainEntrypoint(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 c=s*o;a.append("from",c.toString())}return o!==25&&a.append("size",o.toString()),a.toString()&&(n+=`?${a.toString()}`),(await r.doGetGeneric(n)).map(c=>({chain:this.chain.name,id:c.txHash,receiver:c.receiver,sender:c.sender,value:c.value,function:c.function,status:c.status,createdAt:new Date(c.timestampMs||c.timestamp*1e3).toISOString()}))}};var va={Egld:{Identifier:"EGLD",EsdtIdentifier:"EGLD-000000",DisplayName:"eGold",Decimals:18}},fr=(r=>(r.MultiversxExplorer="multiversx_explorer",r.MultiversxExplorerDevnet="multiversx_explorer_devnet",r.MultiversxExplorerTestnet="multiversx_explorer_testnet",r))(fr||{}),dr=(r=>(r.VibechainExplorer="vibechain_explorer",r.VibechainExplorerDevnet="vibechain_explorer_devnet",r.VibechainExplorerTestnet="vibechain_explorer_testnet",r))(dr||{}),at={multiversx:{mainnet:["multiversx_explorer"],testnet:["multiversx_explorer_testnet"],devnet:["multiversx_explorer_devnet"]},vibechain:{mainnet:["vibechain_explorer"],testnet:["vibechain_explorer_testnet"],devnet:["vibechain_explorer_devnet"]}},V={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 D=class{constructor(e,t){this.chain=e;this.config=t}getExplorers(){let e=at[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=V[t];if(a)return a}if(e){let a=V[e];if(a)return a}let r=this.getPrimaryExplorer();return V[r]||V[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=V[n];a&&(r[n]=`${a}/accounts/${e}`)}),r}getTransactionUrls(e){let t=this.getAllExplorers(),r={};return t.forEach(n=>{let a=V[n];a&&(r[n]=`${a}/transactions/${e}`)}),r}};import{AbiRegistry as it,Address as f,AddressValue as ye,BytesValue as h,SmartContractTransactionsFactory as gr,TransactionsFactoryConfig as yr}from"@multiversx/sdk-core";import{WarpCache as wr,WarpCacheKey as we,WarpLogger as Ce}from"@vleap/warps";var ge={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"}],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}]},{name:"setChain",onlyOwner:!0,mutability:"mutable",inputs:[{name:"name",type:"bytes"},{name:"display_name",type:"bytes"},{name:"chain_id",type:"bytes"},{name:"block_time",type:"u32"},{name:"address_hrp",type:"bytes"},{name:"api_url",type:"bytes"},{name:"explorer_url",type:"bytes"},{name:"native_token",type:"bytes"}],outputs:[]},{name:"removeChain",onlyOwner:!0,mutability:"mutable",inputs:[{name:"name",type:"bytes"}],outputs:[]},{name:"getChain",mutability:"readonly",inputs:[{name:"name",type:"bytes"}],outputs:[{type:"ChainView"}]},{name:"getChains",mutability:"readonly",inputs:[],outputs:[{type:"variadic<ChainView>",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:{ChainView:{type:"struct",fields:[{name:"name",type:"bytes"},{name:"display_name",type:"bytes"},{name:"chain_id",type:"bytes"},{name:"block_time",type:"u32"},{name:"address_hrp",type:"bytes"},{name:"api_url",type:"bytes"},{name:"explorer_url",type:"bytes"},{name:"native_token",type:"bytes"}]},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 C=i=>{if(i==="devnet")return"erd1qqqqqqqqqqqqqpgqje2f99vr6r7sk54thg03c9suzcvwr4nfl3tsfkdl36";if(i==="testnet")throw new Error("Multiversx testnet is not supported");return"erd1qqqqqqqqqqqqqpgq3mrpj3u6q7tejv6d7eqhnyd27n9v5c5tl3ts08mffe"};var z=i=>({hash:i.hash.toString("hex"),alias:i.alias?.toString()||null,trust:i.trust.toString(),owner:i.owner.toString(),createdAt:i.created_at.toNumber(),upgradedAt:i.upgraded_at?.toNumber(),brand:i.brand?.toString("hex")||null,upgrade:i.upgrade?.toString("hex")||null}),st=i=>({unitPrice:BigInt(i.unit_price.toString()),admins:i.admins.map(e=>e.toBech32())});var H=class{constructor(e,t){this.config=e;this.chain=t;this.cache=new wr(e.cache?.type),this.registryConfig={unitPrice:BigInt(0),admins:[]},this.userWallet=this.config.user?.wallets?.[this.chain.name]||null}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?[h.fromHex(e),h.fromUTF8(t),h.fromHex(r)]:t?[h.fromHex(e),h.fromUTF8(t)]:[h.fromHex(e)];return await this.getFactory().createTransactionForExecute(n,{contract:f.newFromBech32(C(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(C(this.config.env)),function:"unregisterWarp",gasLimit:BigInt(1e7),arguments:[h.fromHex(e)]})}async createWarpUpgradeTransaction(e,t){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 r=f.newFromBech32(this.userWallet);return await this.getFactory().createTransactionForExecute(r,{contract:f.newFromBech32(C(this.config.env)),function:"upgradeWarp",gasLimit:BigInt(1e7),nativeTransferAmount:this.isCurrentUserAdmin()?void 0:this.registryConfig.unitPrice,arguments:[h.fromUTF8(e),h.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(C(this.config.env)),function:"setWarpAlias",gasLimit:BigInt(1e7),nativeTransferAmount:this.isCurrentUserAdmin()?void 0:this.registryConfig.unitPrice,arguments:[h.fromHex(e),h.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(C(this.config.env)),function:"verifyWarp",gasLimit:BigInt(1e7),arguments:[h.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(C(this.config.env)),function:"transferOwnership",gasLimit:BigInt(1e7),arguments:[h.fromHex(e),new ye(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(C(this.config.env)),function:"registerBrand",gasLimit:BigInt(1e7),nativeTransferAmount:this.isCurrentUserAdmin()?void 0:this.registryConfig.unitPrice,arguments:[h.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(C(this.config.env)),function:"brandWarp",gasLimit:BigInt(1e7),nativeTransferAmount:this.isCurrentUserAdmin()?void 0:this.registryConfig.unitPrice,arguments:[h.fromHex(e),h.fromHex(t)]})}async getInfoByAlias(e,t){try{let r=we.RegistryInfo(this.config.env,e),n=t?this.cache.get(r):null;if(n)return Ce.info(`WarpRegistry (getInfoByAlias): RegistryInfo found in cache: ${e}`),n;let a=f.newFromBech32(C(this.config.env)),o=this.getController(),s=o.createQuery({contract:a,function:"getInfoByAlias",arguments:[h.fromUTF8(e)]}),p=await o.runQuery(s),[c]=o.parseQueryResponse(p),u=c?z(c):null,l=u?.brand?await this.fetchBrand(u.brand):null;return t&&t.ttl&&this.cache.set(r,{registryInfo:u,brand:l},t.ttl),{registryInfo:u,brand:l}}catch{return{registryInfo:null,brand:null}}}async getInfoByHash(e,t){try{let r=we.RegistryInfo(this.config.env,e);if(t){let l=this.cache.get(r);if(l)return Ce.info(`WarpRegistry (getInfoByHash): RegistryInfo found in cache: ${e}`),l}let n=f.newFromBech32(C(this.config.env)),a=this.getController(),o=a.createQuery({contract:n,function:"getInfoByHash",arguments:[h.fromHex(e)]}),s=await a.runQuery(o),[p]=a.parseQueryResponse(s),c=p?z(p):null,u=c?.brand?await this.fetchBrand(c.brand):null;return t&&t.ttl&&this.cache.set(r,{registryInfo:c,brand:u},t.ttl),{registryInfo:c,brand:u}}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(C(this.config.env)),n=this.getController(),a=n.createQuery({contract:r,function:"getUserWarps",arguments:[new ye(new f(t))]}),o=await n.runQuery(a),[s]=n.parseQueryResponse(o);return s.map(z)}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(C(this.config.env)),n=this.getController(),a=n.createQuery({contract:r,function:"getUserBrands",arguments:[new ye(new f(t))]}),o=await n.runQuery(a),[s]=n.parseQueryResponse(o),p=s.map(l=>l.toString("hex")),c={ttl:365*24*60*60};return(await Promise.all(p.map(l=>this.fetchBrand(l,c)))).filter(l=>l!==null)}catch{return[]}}async fetchBrand(e,t){let r=we.Brand(this.config.env,e),n=t?this.cache.get(r):null;if(n)return Ce.info(`WarpRegistry (fetchBrand): Brand found in cache: ${e}`),n;let o=d.getChainEntrypoint(this.chain,this.config.env).createNetworkProvider();try{let s=await o.getTransaction(e),p=JSON.parse(s.data.toString());return p.meta={hash:s.hash,creator:s.sender.toBech32(),createdAt:new Date(s.timestamp*1e3).toISOString()},t&&t.ttl&&this.cache.set(r,p,t.ttl),p}catch{return null}}async loadRegistryConfigs(){let e=f.newFromBech32(C(this.config.env)),t=this.getController(),[r]=await t.query({contract:e,function:"getConfig",arguments:[]}),n=r?st(r):null;this.registryConfig=n||{unitPrice:BigInt(0),admins:[]}}getFactory(){let e=new yr({chainID:this.chain.chainId}),t=it.create(ge);return new gr({config:e,abi:t})}getController(){let e=d.getChainEntrypoint(this.chain,this.config.env),t=it.create(ge);return e.createSmartContractController(t)}isCurrentUserAdmin(){return!!this.userWallet&&this.registryConfig.admins.includes(this.userWallet)}};var Q=(i,e,t)=>(r,n)=>{let a=t[r.env];return{chain:i,chainInfo:a,prefix:e,builder:()=>new L(r,a),executor:new d(r,a),results:new N(r,a),serializer:new B,registry:new H(r,a),explorer:new D(i,r),abiBuilder:()=>new I(r,a),brandBuilder:()=>new $(r,a),dataLoader:new q(r,a),registerTypes:o=>{o.registerType("token",{stringToNative:s=>s,nativeToString:s=>`token:${s}`}),o.registerType("codemeta",{stringToNative:s=>s,nativeToString:s=>`codemeta:${s}`})}}};var xe={chain:F.Multiversx,identifier:"EGLD",name:"eGold",decimals:18,logoUrl:"https://vleap.ai/images/tokens/egld.svg"},ot=Q(F.Multiversx,"mvx",{mainnet:{name:F.Multiversx,displayName:"MultiversX",chainId:"1",blockTime:6e3,addressHrp:"erd",defaultApiUrl:"https://api.multiversx.com",nativeToken:xe},testnet:{name:F.Multiversx,displayName:"MultiversX Testnet",chainId:"T",blockTime:6e3,addressHrp:"erd",defaultApiUrl:"https://testnet-api.multiversx.com",nativeToken:xe},devnet:{name:F.Multiversx,displayName:"MultiversX Devnet",chainId:"D",blockTime:6e3,addressHrp:"erd",defaultApiUrl:"https://devnet-api.multiversx.com",nativeToken:xe}});import{WarpChainName as Te}from"@vleap/warps";var Cr={chain:Te.Vibechain,identifier:"VIBE",name:"VIBE",decimals:18,logoUrl:"https://vleap.ai/images/tokens/vibe.svg"},We={name:Te.Vibechain,displayName:"VibeChain",chainId:"V",blockTime:600,addressHrp:"vibe",defaultApiUrl:"https://vibeox-api.multiversx.com",nativeToken:Cr},ct=Q(Te.Vibechain,"vibe",{mainnet:We,testnet:We,devnet:We});var ws=(i,e)=>[ot(i,e),ct(i,e)],Cs=()=>[pt.Multiversx,pt.Vibechain];export{V as ExplorerUrls,fr as MultiversxExplorers,at as MultiversxExplorersConfig,xe as NativeTokenEgld,Cr as NativeTokenVibe,dr as VibechainExplorers,I as WarpMultiversxAbiBuilder,$ as WarpMultiversxBrandBuilder,L as WarpMultiversxBuilder,va as WarpMultiversxConstants,M as WarpMultiversxContractLoader,q as WarpMultiversxDataLoader,d as WarpMultiversxExecutor,D as WarpMultiversxExplorer,H as WarpMultiversxRegistry,N as WarpMultiversxResults,B as WarpMultiversxSerializer,pn as address_value,on as biguint_value,cn as boolean_value,mn as codemeta_value,en as composite_value,Q as createMultiversxAdapter,He as esdt_value,ws as getAllMultiversxAdapters,Cs as getAllMultiversxChainNames,ot as getMultiversxAdapter,C as getMultiversxRegistryAddress,ct as getVibechainAdapter,ln as hex_value,Yr as list_value,fn as nothing_value,Jr as option_value,Xr as optional_value,tn as string_value,un as token_value,nn as u16_value,an as u32_value,sn as u64_value,rn as u8_value,Zr 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.39",
|
|
4
4
|
"description": "",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
".": {
|
|
9
9
|
"types": "./dist/index.d.ts",
|
|
10
10
|
"import": "./dist/index.mjs",
|
|
11
|
+
"require": "./dist/index.js",
|
|
11
12
|
"default": "./dist/index.mjs"
|
|
12
13
|
}
|
|
13
14
|
},
|
|
@@ -37,6 +38,6 @@
|
|
|
37
38
|
},
|
|
38
39
|
"dependencies": {
|
|
39
40
|
"@multiversx/sdk-core": "^15.0.1",
|
|
40
|
-
"@vleap/warps": "^3.0.0-alpha.
|
|
41
|
+
"@vleap/warps": "^3.0.0-alpha.87"
|
|
41
42
|
}
|
|
42
43
|
}
|