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