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