@vleap/warps-adapter-multiversx 0.2.0-alpha.5 → 0.2.0-alpha.50

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