@vleap/warps-adapter-multiversx 0.2.0-alpha.22 → 0.2.0-alpha.23
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 +8 -13
- package/dist/index.d.ts +8 -13
- package/dist/index.js +1 -1
- package/dist/index.mjs +1 -1
- package/package.json +2 -2
package/dist/index.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as _vleap_warps from '@vleap/warps';
|
|
2
|
-
import { WarpClientConfig, Adapter, WarpChainEnv, WarpChainInfo, AdapterFactory, AdapterWarpAbiBuilder,
|
|
2
|
+
import { WarpClientConfig, Adapter, WarpChainEnv, WarpChainInfo, AdapterFactory, AdapterWarpAbiBuilder, WarpAbi, WarpCacheConfig, WarpContractAction, WarpQueryAction, WarpBrand, WarpBuilder, AdapterWarpBuilder, Warp, WarpContract, WarpContractVerification, AdapterWarpExecutor, WarpExecutable, WarpExecution, WarpActionInputType, AdapterWarpExplorer, WarpChain, AdapterWarpRegistry, WarpRegistryConfigInfo, WarpRegistryInfo, AdapterWarpResults, ResolvedInput, WarpExecutionResults, AdapterWarpSerializer, WarpSerializer, WarpNativeValue, BaseWarpActionInputType, WarpAdapterGenericType } from '@vleap/warps';
|
|
3
3
|
import { TypedValue, Type, OptionValue, OptionalValue, List, VariadicValue, CompositeValue, StringValue, U8Value, U16Value, U32Value, U64Value, BigUIntValue, BooleanValue, AddressValue, TokenIdentifierValue, BytesValue, TokenTransfer, Struct, CodeMetadataValue, NothingValue, TransactionOnNetwork, AbiRegistry, Transaction, NetworkEntrypoint } from '@multiversx/sdk-core';
|
|
4
4
|
|
|
5
5
|
declare const getAllMultiversxAdapters: (config: WarpClientConfig, fallback?: Adapter) => Adapter[];
|
|
@@ -67,10 +67,9 @@ declare const nothing_value: () => NothingValue;
|
|
|
67
67
|
declare class WarpMultiversxAbiBuilder implements AdapterWarpAbiBuilder {
|
|
68
68
|
private readonly config;
|
|
69
69
|
private readonly chain;
|
|
70
|
-
private readonly chainInfo;
|
|
71
70
|
private readonly contractLoader;
|
|
72
71
|
private readonly cache;
|
|
73
|
-
constructor(config: WarpClientConfig, chain:
|
|
72
|
+
constructor(config: WarpClientConfig, chain: WarpChainInfo);
|
|
74
73
|
createFromRaw(encoded: string): Promise<WarpAbi>;
|
|
75
74
|
createFromTransaction(tx: TransactionOnNetwork): Promise<WarpAbi>;
|
|
76
75
|
createFromTransactionHash(hash: string, cache?: WarpCacheConfig): Promise<WarpAbi | null>;
|
|
@@ -81,9 +80,8 @@ declare class WarpMultiversxAbiBuilder implements AdapterWarpAbiBuilder {
|
|
|
81
80
|
declare class WarpMultiversxBrandBuilder {
|
|
82
81
|
private readonly config;
|
|
83
82
|
private readonly chain;
|
|
84
|
-
private readonly chainInfo;
|
|
85
83
|
private readonly core;
|
|
86
|
-
constructor(config: WarpClientConfig, chain:
|
|
84
|
+
constructor(config: WarpClientConfig, chain: WarpChainInfo);
|
|
87
85
|
createInscriptionTransaction(brand: WarpBrand): Promise<Transaction>;
|
|
88
86
|
createFromTransaction(tx: TransactionOnNetwork, validateSchema?: boolean): Promise<WarpBrand>;
|
|
89
87
|
createFromTransactionHash(hash: string): Promise<WarpBrand | null>;
|
|
@@ -92,10 +90,9 @@ declare class WarpMultiversxBrandBuilder {
|
|
|
92
90
|
declare class WarpMultiversxBuilder extends WarpBuilder implements AdapterWarpBuilder {
|
|
93
91
|
protected readonly config: WarpClientConfig;
|
|
94
92
|
private readonly chain;
|
|
95
|
-
private readonly chainInfo;
|
|
96
93
|
private readonly cache;
|
|
97
94
|
private readonly core;
|
|
98
|
-
constructor(config: WarpClientConfig, chain:
|
|
95
|
+
constructor(config: WarpClientConfig, chain: WarpChainInfo);
|
|
99
96
|
createInscriptionTransaction(warp: Warp): Promise<Transaction>;
|
|
100
97
|
createFromTransaction(tx: TransactionOnNetwork, validate?: boolean): Promise<Warp>;
|
|
101
98
|
createFromTransactionHash(hash: string, cache?: WarpCacheConfig): Promise<Warp | null>;
|
|
@@ -111,11 +108,10 @@ declare class WarpMultiversxContractLoader {
|
|
|
111
108
|
declare class WarpMultiversxExecutor implements AdapterWarpExecutor {
|
|
112
109
|
private readonly config;
|
|
113
110
|
private readonly chain;
|
|
114
|
-
private readonly chainInfo;
|
|
115
111
|
private readonly serializer;
|
|
116
112
|
private readonly abi;
|
|
117
113
|
private readonly results;
|
|
118
|
-
constructor(config: WarpClientConfig, chain:
|
|
114
|
+
constructor(config: WarpClientConfig, chain: WarpChainInfo);
|
|
119
115
|
createTransaction(executable: WarpExecutable): Promise<Transaction>;
|
|
120
116
|
createTransferTransaction(executable: WarpExecutable): Promise<Transaction>;
|
|
121
117
|
createContractCallTransaction(executable: WarpExecutable): Promise<Transaction>;
|
|
@@ -145,11 +141,11 @@ declare class WarpMultiversxExplorer implements AdapterWarpExplorer {
|
|
|
145
141
|
|
|
146
142
|
declare class WarpMultiversxRegistry implements AdapterWarpRegistry {
|
|
147
143
|
private config;
|
|
144
|
+
private chain;
|
|
148
145
|
private cache;
|
|
149
146
|
private userWallet;
|
|
150
|
-
private chainInfo;
|
|
151
147
|
registryConfig: WarpRegistryConfigInfo;
|
|
152
|
-
constructor(config: WarpClientConfig);
|
|
148
|
+
constructor(config: WarpClientConfig, chain: WarpChainInfo);
|
|
153
149
|
init(): Promise<void>;
|
|
154
150
|
getRegistryConfig(): WarpRegistryConfigInfo;
|
|
155
151
|
createWarpRegisterTransaction(txHash: string, alias?: string | null, brand?: string | null): Promise<Transaction>;
|
|
@@ -180,11 +176,10 @@ declare class WarpMultiversxRegistry implements AdapterWarpRegistry {
|
|
|
180
176
|
declare class WarpMultiversxResults implements AdapterWarpResults {
|
|
181
177
|
private readonly config;
|
|
182
178
|
private readonly chain;
|
|
183
|
-
private readonly chainInfo;
|
|
184
179
|
private readonly abi;
|
|
185
180
|
private readonly serializer;
|
|
186
181
|
private readonly cache;
|
|
187
|
-
constructor(config: WarpClientConfig, chain:
|
|
182
|
+
constructor(config: WarpClientConfig, chain: WarpChainInfo);
|
|
188
183
|
getTransactionExecutionResults(warp: Warp, tx: TransactionOnNetwork): Promise<WarpExecution>;
|
|
189
184
|
extractContractResults(warp: Warp, tx: TransactionOnNetwork, inputs: ResolvedInput[]): Promise<{
|
|
190
185
|
values: any[];
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as _vleap_warps from '@vleap/warps';
|
|
2
|
-
import { WarpClientConfig, Adapter, WarpChainEnv, WarpChainInfo, AdapterFactory, AdapterWarpAbiBuilder,
|
|
2
|
+
import { WarpClientConfig, Adapter, WarpChainEnv, WarpChainInfo, AdapterFactory, AdapterWarpAbiBuilder, WarpAbi, WarpCacheConfig, WarpContractAction, WarpQueryAction, WarpBrand, WarpBuilder, AdapterWarpBuilder, Warp, WarpContract, WarpContractVerification, AdapterWarpExecutor, WarpExecutable, WarpExecution, WarpActionInputType, AdapterWarpExplorer, WarpChain, AdapterWarpRegistry, WarpRegistryConfigInfo, WarpRegistryInfo, AdapterWarpResults, ResolvedInput, WarpExecutionResults, AdapterWarpSerializer, WarpSerializer, WarpNativeValue, BaseWarpActionInputType, WarpAdapterGenericType } from '@vleap/warps';
|
|
3
3
|
import { TypedValue, Type, OptionValue, OptionalValue, List, VariadicValue, CompositeValue, StringValue, U8Value, U16Value, U32Value, U64Value, BigUIntValue, BooleanValue, AddressValue, TokenIdentifierValue, BytesValue, TokenTransfer, Struct, CodeMetadataValue, NothingValue, TransactionOnNetwork, AbiRegistry, Transaction, NetworkEntrypoint } from '@multiversx/sdk-core';
|
|
4
4
|
|
|
5
5
|
declare const getAllMultiversxAdapters: (config: WarpClientConfig, fallback?: Adapter) => Adapter[];
|
|
@@ -67,10 +67,9 @@ declare const nothing_value: () => NothingValue;
|
|
|
67
67
|
declare class WarpMultiversxAbiBuilder implements AdapterWarpAbiBuilder {
|
|
68
68
|
private readonly config;
|
|
69
69
|
private readonly chain;
|
|
70
|
-
private readonly chainInfo;
|
|
71
70
|
private readonly contractLoader;
|
|
72
71
|
private readonly cache;
|
|
73
|
-
constructor(config: WarpClientConfig, chain:
|
|
72
|
+
constructor(config: WarpClientConfig, chain: WarpChainInfo);
|
|
74
73
|
createFromRaw(encoded: string): Promise<WarpAbi>;
|
|
75
74
|
createFromTransaction(tx: TransactionOnNetwork): Promise<WarpAbi>;
|
|
76
75
|
createFromTransactionHash(hash: string, cache?: WarpCacheConfig): Promise<WarpAbi | null>;
|
|
@@ -81,9 +80,8 @@ declare class WarpMultiversxAbiBuilder implements AdapterWarpAbiBuilder {
|
|
|
81
80
|
declare class WarpMultiversxBrandBuilder {
|
|
82
81
|
private readonly config;
|
|
83
82
|
private readonly chain;
|
|
84
|
-
private readonly chainInfo;
|
|
85
83
|
private readonly core;
|
|
86
|
-
constructor(config: WarpClientConfig, chain:
|
|
84
|
+
constructor(config: WarpClientConfig, chain: WarpChainInfo);
|
|
87
85
|
createInscriptionTransaction(brand: WarpBrand): Promise<Transaction>;
|
|
88
86
|
createFromTransaction(tx: TransactionOnNetwork, validateSchema?: boolean): Promise<WarpBrand>;
|
|
89
87
|
createFromTransactionHash(hash: string): Promise<WarpBrand | null>;
|
|
@@ -92,10 +90,9 @@ declare class WarpMultiversxBrandBuilder {
|
|
|
92
90
|
declare class WarpMultiversxBuilder extends WarpBuilder implements AdapterWarpBuilder {
|
|
93
91
|
protected readonly config: WarpClientConfig;
|
|
94
92
|
private readonly chain;
|
|
95
|
-
private readonly chainInfo;
|
|
96
93
|
private readonly cache;
|
|
97
94
|
private readonly core;
|
|
98
|
-
constructor(config: WarpClientConfig, chain:
|
|
95
|
+
constructor(config: WarpClientConfig, chain: WarpChainInfo);
|
|
99
96
|
createInscriptionTransaction(warp: Warp): Promise<Transaction>;
|
|
100
97
|
createFromTransaction(tx: TransactionOnNetwork, validate?: boolean): Promise<Warp>;
|
|
101
98
|
createFromTransactionHash(hash: string, cache?: WarpCacheConfig): Promise<Warp | null>;
|
|
@@ -111,11 +108,10 @@ declare class WarpMultiversxContractLoader {
|
|
|
111
108
|
declare class WarpMultiversxExecutor implements AdapterWarpExecutor {
|
|
112
109
|
private readonly config;
|
|
113
110
|
private readonly chain;
|
|
114
|
-
private readonly chainInfo;
|
|
115
111
|
private readonly serializer;
|
|
116
112
|
private readonly abi;
|
|
117
113
|
private readonly results;
|
|
118
|
-
constructor(config: WarpClientConfig, chain:
|
|
114
|
+
constructor(config: WarpClientConfig, chain: WarpChainInfo);
|
|
119
115
|
createTransaction(executable: WarpExecutable): Promise<Transaction>;
|
|
120
116
|
createTransferTransaction(executable: WarpExecutable): Promise<Transaction>;
|
|
121
117
|
createContractCallTransaction(executable: WarpExecutable): Promise<Transaction>;
|
|
@@ -145,11 +141,11 @@ declare class WarpMultiversxExplorer implements AdapterWarpExplorer {
|
|
|
145
141
|
|
|
146
142
|
declare class WarpMultiversxRegistry implements AdapterWarpRegistry {
|
|
147
143
|
private config;
|
|
144
|
+
private chain;
|
|
148
145
|
private cache;
|
|
149
146
|
private userWallet;
|
|
150
|
-
private chainInfo;
|
|
151
147
|
registryConfig: WarpRegistryConfigInfo;
|
|
152
|
-
constructor(config: WarpClientConfig);
|
|
148
|
+
constructor(config: WarpClientConfig, chain: WarpChainInfo);
|
|
153
149
|
init(): Promise<void>;
|
|
154
150
|
getRegistryConfig(): WarpRegistryConfigInfo;
|
|
155
151
|
createWarpRegisterTransaction(txHash: string, alias?: string | null, brand?: string | null): Promise<Transaction>;
|
|
@@ -180,11 +176,10 @@ declare class WarpMultiversxRegistry implements AdapterWarpRegistry {
|
|
|
180
176
|
declare class WarpMultiversxResults implements AdapterWarpResults {
|
|
181
177
|
private readonly config;
|
|
182
178
|
private readonly chain;
|
|
183
|
-
private readonly chainInfo;
|
|
184
179
|
private readonly abi;
|
|
185
180
|
private readonly serializer;
|
|
186
181
|
private readonly cache;
|
|
187
|
-
constructor(config: WarpClientConfig, chain:
|
|
182
|
+
constructor(config: WarpClientConfig, chain: WarpChainInfo);
|
|
188
183
|
getTransactionExecutionResults(warp: Warp, tx: TransactionOnNetwork): Promise<WarpExecution>;
|
|
189
184
|
extractContractResults(warp: Warp, tx: TransactionOnNetwork, inputs: ResolvedInput[]): Promise<{
|
|
190
185
|
values: any[];
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var Z=Object.defineProperty;var fe=Object.getOwnPropertyDescriptor;var me=Object.getOwnPropertyNames;var de=Object.prototype.hasOwnProperty;var ye=(i,e)=>{for(var t in e)Z(i,t,{get:e[t],enumerable:!0})},ge=(i,e,t,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let a of me(e))!de.call(i,a)&&a!==t&&Z(i,a,{get:()=>e[a],enumerable:!(r=fe(e,a))||r.enumerable});return i};var he=i=>ge(Z({},"__esModule",{value:!0}),i);var Oe={};ye(Oe,{ExplorerUrls:()=>U,MultiversxExplorers:()=>ce,MultiversxExplorersConfig:()=>re,VibechainExplorers:()=>pe,WarpMultiversxAbiBuilder:()=>N,WarpMultiversxBrandBuilder:()=>L,WarpMultiversxBuilder:()=>q,WarpMultiversxConstants:()=>Pe,WarpMultiversxContractLoader:()=>$,WarpMultiversxExecutor:()=>x,WarpMultiversxExplorer:()=>D,WarpMultiversxRegistry:()=>H,WarpMultiversxResults:()=>P,WarpMultiversxSerializer:()=>R,address_value:()=>Se,biguint_value:()=>Be,boolean_value:()=>Ve,codemeta_value:()=>Ne,composite_value:()=>Ce,createMultiversxAdapter:()=>Q,esdt_value:()=>ee,getAllMultiversxAdapters:()=>_e,getMultiversxAdapter:()=>z,getMultiversxRegistryAddress:()=>E,getVibechainAdapter:()=>ie,hex_value:()=>Re,list_value:()=>xe,nothing_value:()=>Ue,option_value:()=>we,optional_value:()=>We,string_value:()=>ve,token_value:()=>Fe,u16_value:()=>Ee,u32_value:()=>Ae,u64_value:()=>Ie,u8_value:()=>be,variadic_value:()=>Te});module.exports=he(Oe);var K=require("@multiversx/sdk-core"),V=require("@vleap/warps");var te=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"),se=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(se,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(se,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 N(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(C=>C.includes("out")||C.includes("event"))){for(let[C,g]of Object.entries(e.results))o[C]=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[C,g]of Object.entries(e.results)){if(g.startsWith(h.WarpConstants.Transform.Prefix))continue;if(g.startsWith("input.")){o[C]=g;continue}let A=(0,h.parseResultsOutIndex)(g);if(A!==null&&A!==s){o[C]=null;continue}let[v,B,I]=g.split(".");if(v==="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[C]=G&&G.valueOf()}else if(v==="out"||v.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[C]=W&&W.valueOf()}else o[C]=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 v=t.actions[g-1];if(!v)throw new Error(`Action ${g} not found`);let B;if(v.type==="query")B=await a.executeQuery(t,g,A);else if(v.type==="collect")B=await a.executeCollect(t,g,A,p);else throw new Error(`Unsupported or interactive action type: ${v.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,v]of Object.entries(g.results))v!==null?y[A]=v: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"),we=(i,e)=>i?c.OptionValue.newProvided(i):e?c.OptionValue.newMissingTyped(e):c.OptionValue.newMissing(),We=(i,e)=>i?new c.OptionalValue(i.getType(),i):e?new c.OptionalValue(e):c.OptionalValue.newMissing(),xe=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)},Te=i=>c.VariadicValue.fromItems(...i),Ce=i=>{let e=i.map(t=>t.getType());return new c.CompositeValue(new c.CompositeType(...e),i)},ve=i=>c.StringValue.fromUTF8(i),be=i=>new c.U8Value(i),Ee=i=>new c.U16Value(i),Ae=i=>new c.U32Value(i),Ie=i=>new c.U64Value(i),Be=i=>new c.BigUIntValue(BigInt(i)),Ve=i=>new c.BooleanValue(i),Se=i=>new c.AddressValue(c.Address.newFromBech32(i)),Fe=i=>new c.TokenIdentifierValue(i),Re=i=>c.BytesValue.fromHex(i),ee=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")]),Ne=i=>new c.CodeMetadataValue(c.CodeMetadata.newFromBytes(Uint8Array.from(Buffer.from(i,"hex")))),Ue=()=>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 N(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||""),C=(f.returnDataParts||[]).map(I=>Buffer.from(I)),g=y.buffersToValues(C,w.output),{values:A,results:v}=await this.results.extractQueryResults(e.warp,g,e.action,e.resolvedInputs),B=(0,b.getNextInfo)(this.config,[],e.warp,e.action,v);return{success:m,warp:e.warp,action:e.action,user:this.config.user?.wallets?.[e.chain]||null,txHash:null,next:B,values:A,results:v,messages:(0,b.applyResultsToMessages)(e.warp,v)}}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 C=ee(new d.TokenTransfer({token:f,amount:(0,b.shiftBigintBy)(o,w)}));return this.serializer.typedToString(C)+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 te.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 te.WarpLogger.error("WarpContractLoader: getVerificationInfo error",r),null}}};var N=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"),oe=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(oe.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 Pe={Egld:{Identifier:"EGLD",EsdtIdentifier:"EGLD-000000",DisplayName:"eGold",Decimals:18}},ce=(r=>(r.MultiversxExplorer="multiversx_explorer",r.MultiversxExplorerDevnet="multiversx_explorer_devnet",r.MultiversxExplorerTestnet="multiversx_explorer_testnet",r))(ce||{}),pe=(r=>(r.VibechainExplorer="vibechain_explorer",r.VibechainExplorerDevnet="vibechain_explorer_devnet",r.VibechainExplorerTestnet="vibechain_explorer_testnet",r))(pe||{}),re={multiversx:{mainnet:["multiversx_explorer"],testnet:["multiversx_explorer_testnet"],devnet:["multiversx_explorer_devnet"]},vibechain:{mainnet:["vibechain_explorer"],testnet:["vibechain_explorer_testnet"],devnet:["vibechain_explorer_devnet"]}},U={multiversx_explorer:"https://explorer.multiversx.com",multiversx_explorer_devnet:"https://devnet-explorer.multiversx.com",multiversx_explorer_testnet:"https://testnet-explorer.multiversx.com",vibechain_explorer:"https://vibeox-explorer.multiversx.com",vibechain_explorer_devnet:"https://vibeox-explorer.multiversx.com",vibechain_explorer_testnet:"https://vibeox-explorer.multiversx.com"};var D=class{constructor(e,t){this.chain=e;this.config=t}getExplorers(){let e=re[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=U[t];if(s)return s}if(e){let s=U[e];if(s)return s}let r=this.getPrimaryExplorer();return U[r]||U[r]}getAccountUrl(e,t){return`${this.getExplorerUrlByName(t)}/accounts/${e}`}getTransactionUrl(e,t){return`${this.getExplorerUrlByName(t)}/transactions/${e}`}getBlockUrl(e,t){return`${this.getExplorerUrlByName(t)}/blocks/${e}`}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=U[a];s&&(r[a]=`${s}/accounts/${e}`)}),r}getTransactionUrls(e){let t=this.getAllExplorers(),r={};return t.forEach(a=>{let s=U[a];s&&(r[a]=`${s}/transactions/${e}`)}),r}};var u=require("@multiversx/sdk-core"),F=require("@vleap/warps");var ne={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}),ue=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?ue(r):null;this.registryConfig=a||{unitPrice:BigInt(0),admins:[]}}getFactory(){let e=new u.TransactionsFactoryConfig({chainID:this.chainInfo.chainId}),t=u.AbiRegistry.create(ne);return new u.SmartContractTransactionsFactory({config:e,abi:t})}getController(){let e=x.getChainEntrypoint(this.chainInfo,this.config.env),t=u.AbiRegistry.create(ne);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 N(r,i,s),brandBuilder:()=>new L(r,i,s)}};var Y="multiversx",z=Q(Y,"mvx",{mainnet:{name:Y,displayName:"MultiversX",chainId:"1",blockTime:6e3,addressHrp:"erd",apiUrl:"https://api.multiversx.com",nativeToken:"EGLD"},testnet:{name:Y,displayName:"MultiversX Testnet",chainId:"T",blockTime:6e3,addressHrp:"erd",apiUrl:"https://testnet-api.multiversx.com",nativeToken:"EGLD"},devnet:{name:Y,displayName:"MultiversX Devnet",chainId:"D",blockTime:6e3,addressHrp:"erd",apiUrl:"https://devnet-api.multiversx.com",nativeToken:"EGLD"}});var le="vibechain",ae={name:le,displayName:"VibeChain",chainId:"V",blockTime:600,addressHrp:"vibe",apiUrl:"https://vibeox-api.multiversx.com",nativeToken:"VIBE"},ie=Q(le,"vibe",{mainnet:ae,testnet:ae,devnet:ae});var _e=(i,e)=>[z(i,e),ie(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});
|
|
1
|
+
"use strict";var Y=Object.defineProperty;var me=Object.getOwnPropertyDescriptor;var fe=Object.getOwnPropertyNames;var de=Object.prototype.hasOwnProperty;var ge=(s,e)=>{for(var t in e)Y(s,t,{get:e[t],enumerable:!0})},ye=(s,e,t,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let a of fe(e))!de.call(s,a)&&a!==t&&Y(s,a,{get:()=>e[a],enumerable:!(r=me(e,a))||r.enumerable});return s};var he=s=>ye(Y({},"__esModule",{value:!0}),s);var Oe={};ge(Oe,{ExplorerUrls:()=>U,MultiversxExplorers:()=>ce,MultiversxExplorersConfig:()=>te,VibechainExplorers:()=>pe,WarpMultiversxAbiBuilder:()=>N,WarpMultiversxBrandBuilder:()=>L,WarpMultiversxBuilder:()=>q,WarpMultiversxConstants:()=>Pe,WarpMultiversxContractLoader:()=>$,WarpMultiversxExecutor:()=>x,WarpMultiversxExplorer:()=>D,WarpMultiversxRegistry:()=>H,WarpMultiversxResults:()=>P,WarpMultiversxSerializer:()=>R,address_value:()=>Se,biguint_value:()=>Ie,boolean_value:()=>Ve,codemeta_value:()=>Ne,composite_value:()=>Ce,createMultiversxAdapter:()=>z,esdt_value:()=>Z,getAllMultiversxAdapters:()=>_e,getMultiversxAdapter:()=>ne,getMultiversxRegistryAddress:()=>E,getVibechainAdapter:()=>ie,hex_value:()=>Re,list_value:()=>xe,nothing_value:()=>Ue,option_value:()=>we,optional_value:()=>We,string_value:()=>ve,token_value:()=>Fe,u16_value:()=>Ee,u32_value:()=>Ae,u64_value:()=>Be,u8_value:()=>be,variadic_value:()=>Te});module.exports=he(Oe);var G=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"),se=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],i=t.map(p=>this.typedToString(p).split(T.WarpConstants.ArgParamsSeparator)[1]);return`list:${a}:${i.join(",")}`}if(e.hasClassOrSuperclass(n.VariadicValue.ClassName)){let t=e.getItems(),a=t.map(p=>this.typedToString(p).split(T.WarpConstants.ArgParamsSeparator)[0])[0],i=t.map(p=>this.typedToString(p).split(T.WarpConstants.ArgParamsSeparator)[1]);return`variadic:${a}:${i.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]),i=r.join(T.WarpConstants.ArgCompositeSeparator),p=a.join(T.WarpConstants.ArgCompositeSeparator);return`composite(${i}):${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,i]=r.split(se,2),o=i.split(",").map(l=>this.stringToTyped(`${a}:${l}`));return new n.List(this.nativeToType(a),o)}if(t==="variadic"){let[a,i]=r.split(se,2),o=i.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],i=r.split(T.WarpConstants.ArgCompositeSeparator),p=a.split(T.WarpConstants.ArgCompositeSeparator),o=i.map((m,f)=>this.stringToTyped(`${p[f]}:${m}`)),l=o.map(m=>m.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){this.config=e;this.chain=t;this.abi=new N(e,t),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))??[],i=await this.extractContractResults(e,t,a),p=(0,h.getNextInfo)(this.config,[],e,r,i),o=(0,h.applyResultsToMessages)(e,i.results);return{success:t.status.isSuccessful(),warp:e,action:r,user:this.config.user?.wallets?.[this.chain.name]||null,txHash:t.hash,next:p,values:i.values,results:i.results,messages:o}}async extractContractResults(e,t,r){let{action:a,actionIndex:i}=(0,h.findWarpExecutableAction)(e),p=[],o={};if(!e.results||a.type!=="contract")return{values:p,results:o};if(!Object.values(e.results).some(C=>C.includes("out")||C.includes("event"))){for(let[C,y]of Object.entries(e.results))o[C]=y;return{values:p,results:await(0,h.evaluateResultsCommon)(e,o,i,r)}}let m=await this.abi.getAbiForAction(a),f=new O.TransactionEventsParser({abi:m}),w=new O.SmartContractTransactionsOutcomeParser({abi:m}).parseExecute({transactionOnNetwork:t,function:a.func||void 0});for(let[C,y]of Object.entries(e.results)){if(y.startsWith(h.WarpConstants.Transform.Prefix))continue;if(y.startsWith("input.")){o[C]=y;continue}let A=(0,h.parseResultsOutIndex)(y);if(A!==null&&A!==i){o[C]=null;continue}let[v,I,B]=y.split(".");if(v==="event"){if(!I||isNaN(Number(B)))continue;let Q=Number(B),W=(0,O.findEventsByFirstTopic)(t,I),M=f.parseEvents({events:W})[0],j=Object.values(M)[Q]||null;p.push(j),o[C]=j&&j.valueOf()}else if(v==="out"||v.startsWith("out[")){if(!I)continue;let Q=Number(I),W=w.values[Q-1]||null;B&&(W=W[B]||null),W&&typeof W=="object"&&(W="toFixed"in W?W.toFixed():W.valueOf()),p.push(W),o[C]=W&&W.valueOf()}else o[C]=y}return{values:p,results:await(0,h.evaluateResultsCommon)(e,o,i,r)}}async extractQueryResults(e,t,r,a){let i=t.map(m=>this.serializer.typedToString(m)),p=t.map(m=>this.serializer.typedToNative(m)[1]),o={};if(!e.results)return{values:i,results:o};let l=m=>{let f=m.split(".").slice(1).map(w=>parseInt(w)-1);if(f.length===0)return;let g=p[f[0]];for(let w=1;w<f.length;w++){if(g==null)return;g=g[f[w]]}return g};for(let[m,f]of Object.entries(e.results)){if(f.startsWith(h.WarpConstants.Transform.Prefix))continue;let g=(0,h.parseResultsOutIndex)(f);if(g!==null&&g!==r){o[m]=null;continue}f.startsWith("out.")||f==="out"||f.startsWith("out[")?o[m]=l(f)||null:o[m]=f}return{values:i,results:await(0,h.evaluateResultsCommon)(e,o,r,a)}}async resolveWarpResultsRecursively(e){let t=e.warp,r=e.entryActionIndex,a=e.executor,i=e.inputs,p=e.meta,o=new Map,l=new Set,m=this;async function f(y,A=[]){if(o.has(y))return o.get(y);if(l.has(y))throw new Error(`Circular dependency detected at action ${y}`);l.add(y);let v=t.actions[y-1];if(!v)throw new Error(`Action ${y} not found`);let I;if(v.type==="query")I=await a.executeQuery(t,y,A);else if(v.type==="collect")I=await a.executeCollect(t,y,A,p);else throw new Error(`Unsupported or interactive action type: ${v.type}`);if(o.set(y,I),t.results)for(let B of Object.values(t.results)){let W=String(B).match(/^out\[(\d+)\]/);if(W){let M=parseInt(W[1],10);M!==y&&!o.has(M)&&await f(M)}}return l.delete(y),I}await f(r,i);let g={};for(let y of o.values())for(let[A,v]of Object.entries(y.results))v!==null?g[A]=v:A in g||(g[A]=null);let w=await(0,h.evaluateResultsCommon)(t,g,r,i);return{...o.get(r),action:r,results:w}}};var c=require("@multiversx/sdk-core"),we=(s,e)=>s?c.OptionValue.newProvided(s):e?c.OptionValue.newMissingTyped(e):c.OptionValue.newMissing(),We=(s,e)=>s?new c.OptionalValue(s.getType(),s):e?new c.OptionalValue(e):c.OptionalValue.newMissing(),xe=s=>{if(s.length===0)throw new Error("Cannot create a list from an empty array");let e=s[0].getType();return new c.List(e,s)},Te=s=>c.VariadicValue.fromItems(...s),Ce=s=>{let e=s.map(t=>t.getType());return new c.CompositeValue(new c.CompositeType(...e),s)},ve=s=>c.StringValue.fromUTF8(s),be=s=>new c.U8Value(s),Ee=s=>new c.U16Value(s),Ae=s=>new c.U32Value(s),Be=s=>new c.U64Value(s),Ie=s=>new c.BigUIntValue(BigInt(s)),Ve=s=>new c.BooleanValue(s),Se=s=>new c.AddressValue(c.Address.newFromBech32(s)),Fe=s=>new c.TokenIdentifierValue(s),Re=s=>c.BytesValue.fromHex(s),Z=s=>new c.Struct(new c.StructType("EsdtTokenPayment",[new c.FieldDefinition("token_identifier","",new c.TokenIdentifierType),new c.FieldDefinition("token_nonce","",new c.U64Type),new c.FieldDefinition("amount","",new c.BigUIntType)]),[new c.Field(new c.TokenIdentifierValue(s.token.identifier),"token_identifier"),new c.Field(new c.U64Value(BigInt(s.token.nonce)),"token_nonce"),new c.Field(new c.BigUIntValue(BigInt(s.amount)),"amount")]),Ne=s=>new c.CodeMetadataValue(c.CodeMetadata.newFromBytes(Uint8Array.from(Buffer.from(s,"hex")))),Ue=()=>new c.NothingValue;var x=class s{constructor(e,t){this.config=e;this.chain=t;this.serializer=new R,this.abi=new N(this.config,this.chain),this.results=new P(this.config,this.chain)}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.name];if(!t)throw new Error("WarpMultiversxExecutor: createTransfer - user address not set");let r=d.Address.newFromBech32(t),a=new d.TransactionsFactoryConfig({chainID:e.chain.chainId}),i=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:i?new Uint8Array(i):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,b.getWarpActionByIndex)(e.warp,e.action),a=d.Address.newFromBech32(t),i=e.args.map(o=>this.serializer.stringToTyped(o)),p=new d.TransactionsFactoryConfig({chainID:e.chain.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:i,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(B=>this.serializer.stringToTyped(B)),i=s.getChainEntrypoint(e.chain,this.config.env),p=d.Address.newFromBech32(e.destination),o=i.createSmartContractController(r),l=o.createQuery({contract:p,function:t.func||"",arguments:a}),m=await o.runQuery(l),f=m.returnCode==="ok",g=new d.ArgSerializer,w=r.getEndpoint(m.function||t.func||""),C=(m.returnDataParts||[]).map(B=>Buffer.from(B)),y=g.buffersToValues(C,w.output),{values:A,results:v}=await this.results.extractQueryResults(e.warp,y,e.action,e.resolvedInputs),I=(0,b.getNextInfo)(this.config,[],e.warp,e.action,v);return{success:f,warp:e.warp,action:e.action,user:this.config.user?.wallets?.[e.chain.name]||null,txHash:null,next:I,values:A,results:v,messages:(0,b.applyResultsToMessages)(e.warp,v)}}async preprocessInput(e,t,r,a){if(r==="esdt"){let[i,p,o,l]=a.split(b.WarpConstants.ArgCompositeSeparator);if(l)return t;let m=new d.Token({identifier:i,nonce:BigInt(p)});if(!new d.TokenComputer().isFungible(m))return t;let w=(0,b.findKnownTokenById)(i)?.decimals;if(w||(w=(await(await fetch(`${e.apiUrl}/tokens/${i}`)).json()).decimals),!w)throw new Error(`WarpActionExecutor: Decimals not found for token ${i}`);let C=Z(new d.TokenTransfer({token:m,amount:(0,b.shiftBigintBy)(o,w)}));return this.serializer.typedToString(C)+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 i=await x.getChainEntrypoint(t,this.config.env).createNetworkProvider().doGetGeneric(`accounts/${e}`);return{address:e,owner:i.ownerAddress,verified:i.isVerified||!1}}catch(r){return ee.WarpLogger.error("WarpContractLoader: getContract error",r),null}}async getVerificationInfo(e,t){try{let i=await x.getChainEntrypoint(t,this.config.env).createNetworkProvider().doGetGeneric(`accounts/${e}/verification`);return{codeHash:i.codeHash,abi:i.source.abi}}catch(r){return ee.WarpLogger.error("WarpContractLoader: getVerificationInfo error",r),null}}};var N=class{constructor(e,t){this.config=e;this.chain=t;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.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 p=this.cache.get(r);if(p)return V.WarpLogger.info(`WarpAbiBuilder (createFromTransactionHash): Warp abi found in cache: ${e}`),p}let i=x.getChainEntrypoint(this.chain,this.config.env).createNetworkProvider();try{let p=await i.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.chain);if(!t)throw new Error("WarpActionExecutor: Verification info not found");return G.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 G.AbiRegistry.create(r.content)}else{let r=await(await fetch(e.abi)).json();return G.AbiRegistry.create(r)}}};var k=require("@multiversx/sdk-core"),K=require("@vleap/warps"),oe=require("buffer");var L=class{constructor(e,t){this.config=e;this.chain=t;this.core=new K.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 k.TransactionsFactoryConfig({chainID:this.chain.chainId}),a=new k.TransferTransactionsFactory({config:r}),i=k.Address.newFromBech32(t),p=JSON.stringify(e);return await a.createTransactionForNativeTokenTransfer(i,{receiver:k.Address.newFromBech32(t),nativeAmount:BigInt(0),data:Uint8Array.from(oe.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.chain,this.config.env).createNetworkProvider();try{let a=await r.getTransaction(e);return this.createFromTransaction(a)}catch(a){return K.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){super(t);this.config=t;this.chain=r;this.cache=new S.WarpCache(t.cache?.type),this.core=new S.WarpBuilder(t)}async createInscriptionTransaction(t){let r=this.config.user?.wallets?.[this.chain.name];if(!r)throw new Error("WarpBuilder: user address not set");let a=new _.TransactionsFactoryConfig({chainID:this.chain.chainId}),i=new _.TransferTransactionsFactory({config:a}),p=_.Address.newFromBech32(r),o=JSON.stringify(t),l=await i.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.name,hash:t.hash,creator:t.sender.toBech32(),createdAt:new Date(t.timestamp*1e3).toISOString()},a}async createFromTransactionHash(t,r){let a=S.WarpCacheKey.Warp(this.config.env,t);if(r){let o=this.cache.get(a);if(o)return S.WarpLogger.info(`WarpBuilder (createFromTransactionHash): Warp found in cache: ${t}`),o}let p=x.getChainEntrypoint(this.chain,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 Pe={Egld:{Identifier:"EGLD",EsdtIdentifier:"EGLD-000000",DisplayName:"eGold",Decimals:18}},ce=(r=>(r.MultiversxExplorer="multiversx_explorer",r.MultiversxExplorerDevnet="multiversx_explorer_devnet",r.MultiversxExplorerTestnet="multiversx_explorer_testnet",r))(ce||{}),pe=(r=>(r.VibechainExplorer="vibechain_explorer",r.VibechainExplorerDevnet="vibechain_explorer_devnet",r.VibechainExplorerTestnet="vibechain_explorer_testnet",r))(pe||{}),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"]}},U={multiversx_explorer:"https://explorer.multiversx.com",multiversx_explorer_devnet:"https://devnet-explorer.multiversx.com",multiversx_explorer_testnet:"https://testnet-explorer.multiversx.com",vibechain_explorer:"https://vibeox-explorer.multiversx.com",vibechain_explorer_devnet:"https://vibeox-explorer.multiversx.com",vibechain_explorer_testnet:"https://vibeox-explorer.multiversx.com"};var 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 i=U[t];if(i)return i}if(e){let i=U[e];if(i)return i}let r=this.getPrimaryExplorer();return U[r]||U[r]}getAccountUrl(e,t){return`${this.getExplorerUrlByName(t)}/accounts/${e}`}getTransactionUrl(e,t){return`${this.getExplorerUrlByName(t)}/transactions/${e}`}getBlockUrl(e,t){return`${this.getExplorerUrlByName(t)}/blocks/${e}`}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 i=U[a];i&&(r[a]=`${i}/accounts/${e}`)}),r}getTransactionUrls(e){let t=this.getAllExplorers(),r={};return t.forEach(a=>{let i=U[a];i&&(r[a]=`${i}/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=s=>{if(s==="devnet")return"erd1qqqqqqqqqqqqqpgqje2f99vr6r7sk54thg03c9suzcvwr4nfl3tsfkdl36";if(s==="testnet")throw new Error("Multiversx testnet is not supported");return"erd1qqqqqqqqqqqqqpgq3mrpj3u6q7tejv6d7eqhnyd27n9v5c5tl3ts08mffe"};var J=s=>({hash:s.hash.toString("hex"),alias:s.alias?.toString()||null,trust:s.trust.toString(),owner:s.owner.toString(),createdAt:s.created_at.toNumber(),upgradedAt:s.upgraded_at?.toNumber(),brand:s.brand?.toString("hex")||null,upgrade:s.upgrade?.toString("hex")||null}),ue=s=>({unitPrice:BigInt(s.unit_price.toString()),admins:s.admins.map(e=>e.toBech32())});var H=class{constructor(e,t){this.config=e;this.chain=t;this.cache=new F.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),i=()=>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:i(),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 i=u.Address.newFromBech32(E(this.config.env)),p=this.getController(),o=p.createQuery({contract:i,function:"getInfoByAlias",arguments:[u.BytesValue.fromUTF8(e)]}),l=await p.runQuery(o),[m]=p.parseQueryResponse(l),f=m?J(m):null,g=f?.brand?await this.fetchBrand(f.brand):null;return t&&t.ttl&&this.cache.set(r,{registryInfo:f,brand:g},t.ttl),{registryInfo:f,brand:g}}catch{return{registryInfo:null,brand:null}}}async getInfoByHash(e,t){try{let r=F.WarpCacheKey.RegistryInfo(this.config.env,e);if(t){let g=this.cache.get(r);if(g)return F.WarpLogger.info(`WarpRegistry (getInfoByHash): RegistryInfo found in cache: ${e}`),g}let a=u.Address.newFromBech32(E(this.config.env)),i=this.getController(),p=i.createQuery({contract:a,function:"getInfoByHash",arguments:[u.BytesValue.fromHex(e)]}),o=await i.runQuery(p),[l]=i.parseQueryResponse(o),m=l?J(l):null,f=m?.brand?await this.fetchBrand(m.brand):null;return t&&t.ttl&&this.cache.set(r,{registryInfo:m,brand:f},t.ttl),{registryInfo:m,brand:f}}catch{return{registryInfo:null,brand:null}}}async getUserWarpRegistryInfos(e){try{let t=e||this.userWallet;if(!t)throw new Error("WarpRegistry: user address not set");let r=u.Address.newFromBech32(E(this.config.env)),a=this.getController(),i=a.createQuery({contract:r,function:"getUserWarps",arguments:[new u.AddressValue(new u.Address(t))]}),p=await a.runQuery(i),[o]=a.parseQueryResponse(p);return o.map(J)}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(),i=a.createQuery({contract:r,function:"getUserBrands",arguments:[new u.AddressValue(new u.Address(t))]}),p=await a.runQuery(i),[o]=a.parseQueryResponse(p),l=o.map(g=>g.toString("hex")),m={ttl:365*24*60*60};return(await Promise.all(l.map(g=>this.fetchBrand(g,m)))).filter(g=>g!==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.chain,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?ue(r):null;this.registryConfig=a||{unitPrice:BigInt(0),admins:[]}}getFactory(){let e=new u.TransactionsFactoryConfig({chainID:this.chain.chainId}),t=u.AbiRegistry.create(re);return new u.SmartContractTransactionsFactory({config:e,abi:t})}getController(){let e=x.getChainEntrypoint(this.chain,this.config.env),t=u.AbiRegistry.create(re);return e.createSmartContractController(t)}isCurrentUserAdmin(){return!!this.userWallet&&this.registryConfig.admins.includes(this.userWallet)}};var z=(s,e,t)=>(r,a)=>{let i=t[r.env];return{chain:s,chainInfo:i,prefix:e,builder:()=>new q(r,i),executor:new x(r,i),results:new P(r,i),serializer:new R,registry:new H(r,i),explorer:new D(s,r),abiBuilder:()=>new N(r,i),brandBuilder:()=>new L(r,i)}};var X="multiversx",ne=z(X,"mvx",{mainnet:{name:X,displayName:"MultiversX",chainId:"1",blockTime:6e3,addressHrp:"erd",apiUrl:"https://api.multiversx.com",nativeToken:"EGLD"},testnet:{name:X,displayName:"MultiversX Testnet",chainId:"T",blockTime:6e3,addressHrp:"erd",apiUrl:"https://testnet-api.multiversx.com",nativeToken:"EGLD"},devnet:{name:X,displayName:"MultiversX Devnet",chainId:"D",blockTime:6e3,addressHrp:"erd",apiUrl:"https://devnet-api.multiversx.com",nativeToken:"EGLD"}});var le="vibechain",ae={name:le,displayName:"VibeChain",chainId:"V",blockTime:600,addressHrp:"vibe",apiUrl:"https://vibeox-api.multiversx.com",nativeToken:"VIBE"},ie=z(le,"vibe",{mainnet:ae,testnet:ae,devnet:ae});var _e=(s,e)=>[ne(s,e),ie(s,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
|
-
import{AbiRegistry as ie}from"@multiversx/sdk-core";import{WarpCache as Jt,WarpCacheKey as Xt,WarpConstants as He,WarpLogger as ze}from"@vleap/warps";import{WarpLogger as De}from"@vleap/warps";import{Address as F,ArgSerializer as Pt,DevnetEntrypoint as kt,MainnetEntrypoint as _t,SmartContractTransactionsFactory as Ot,TestnetEntrypoint as Mt,Token as $t,TokenComputer as Lt,TokenTransfer as qt,TransactionsFactoryConfig as Le,TransferTransactionsFactory as Dt,UserSecretKey as Ht,UserSigner as zt}from"@multiversx/sdk-core";import{applyResultsToMessages as Qt,findKnownTokenById as jt,getNextInfo as Gt,getWarpActionByIndex as ae,shiftBigintBy as Kt,WarpConstants as qe}from"@vleap/warps";import{findEventsByFirstTopic as ct,SmartContractTransactionsOutcomeParser as pt,TransactionEventsParser as ut}from"@multiversx/sdk-core";import{applyResultsToMessages as lt,evaluateResultsCommon as U,findWarpExecutableAction as Ue,getNextInfo as ft,parseResultsOutIndex as Pe,WarpCache as mt,WarpCacheKey as dt,WarpConstants as ke}from"@vleap/warps";import{Address as tt,AddressType as le,AddressValue as fe,BigUIntType as H,BigUIntValue as z,BooleanType as me,BooleanValue as de,BytesType as ye,BytesValue as ge,CodeMetadata as rt,CodeMetadataType as he,CodeMetadataValue as we,CompositeType as We,CompositeValue as xe,Field as Q,FieldDefinition as j,List as Te,ListType as nt,NothingValue as T,OptionalType as at,OptionalValue as G,OptionType as it,OptionValue as K,StringType as Ce,StringValue as ve,Struct as st,StructType as be,TokenIdentifierType as J,TokenIdentifierValue as X,U16Type as Ee,U16Value as Ae,U32Type as Ie,U32Value as Be,U64Type as Y,U64Value as Z,U8Type as Ve,U8Value as Se,VariadicType as Fe,VariadicValue as Re}from"@multiversx/sdk-core";import{WarpConstants as C,WarpSerializer as ot}from"@vleap/warps";var Ne=new RegExp(`${C.ArgParamsSeparator}(.*)`),A=class{constructor(){this.coreSerializer=new ot}typedToString(e){if(e.hasClassOrSuperclass(K.ClassName))return e.isSet()?`option:${this.typedToString(e.getTypedValue())}`:"option:null";if(e.hasClassOrSuperclass(G.ClassName))return e.isSet()?`optional:${this.typedToString(e.getTypedValue())}`:"optional:null";if(e.hasClassOrSuperclass(Te.ClassName)){let t=e.getItems(),n=t.map(o=>this.typedToString(o).split(C.ArgParamsSeparator)[0])[0],a=t.map(o=>this.typedToString(o).split(C.ArgParamsSeparator)[1]);return`list:${n}:${a.join(",")}`}if(e.hasClassOrSuperclass(Re.ClassName)){let t=e.getItems(),n=t.map(o=>this.typedToString(o).split(C.ArgParamsSeparator)[0])[0],a=t.map(o=>this.typedToString(o).split(C.ArgParamsSeparator)[1]);return`variadic:${n}:${a.join(",")}`}if(e.hasClassOrSuperclass(xe.ClassName)){let t=e.getItems(),r=t.map(s=>this.typedToString(s).split(C.ArgParamsSeparator)[0]),n=t.map(s=>this.typedToString(s).split(C.ArgParamsSeparator)[1]),a=r.join(C.ArgCompositeSeparator),o=n.join(C.ArgCompositeSeparator);return`composite(${a}):${o}`}if(e.hasClassOrSuperclass(z.ClassName)||e.getType().getName()==="BigUint")return`biguint:${BigInt(e.valueOf().toFixed())}`;if(e.hasClassOrSuperclass(Se.ClassName))return`uint8:${e.valueOf().toNumber()}`;if(e.hasClassOrSuperclass(Ae.ClassName))return`uint16:${e.valueOf().toNumber()}`;if(e.hasClassOrSuperclass(Be.ClassName))return`uint32:${e.valueOf().toNumber()}`;if(e.hasClassOrSuperclass(Z.ClassName))return`uint64:${BigInt(e.valueOf().toFixed())}`;if(e.hasClassOrSuperclass(ve.ClassName))return`string:${e.valueOf()}`;if(e.hasClassOrSuperclass(de.ClassName))return`bool:${e.valueOf()}`;if(e.hasClassOrSuperclass(fe.ClassName))return`address:${e.valueOf().toBech32()}`;if(e.hasClassOrSuperclass(X.ClassName))return`token:${e.valueOf()}`;if(e.hasClassOrSuperclass(ge.ClassName))return`hex:${e.valueOf().toString("hex")}`;if(e.hasClassOrSuperclass(we.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(C.ArgCompositeSeparator).map(r=>this.nativeToType(r)))}if(e==="string")return new Ce;if(e==="uint8")return new Ve;if(e==="uint16")return new Ee;if(e==="uint32")return new Ie;if(e==="uint64")return new Y;if(e==="biguint")return new H;if(e==="bool")return new me;if(e==="address")return new le;if(e==="token")return new J;if(e==="hex")return new ye;if(e==="codemeta")return new he;if(e==="esdt"||e==="nft")return new be("EsdtTokenPayment",[new j("token_identifier","",new J),new j("token_nonce","",new Y),new j("amount","",new H)]);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?K.newMissingTyped(n.getType()):K.newProvided(n)}if(t==="optional"){let n=this.stringToTyped(r);return n instanceof T?G.newMissing():new G(n.getType(),n)}if(t==="list"){let[n,a]=r.split(Ne,2),s=a.split(",").map(c=>this.stringToTyped(`${n}:${c}`));return new Te(this.nativeToType(n),s)}if(t==="variadic"){let[n,a]=r.split(Ne,2),s=a.split(",").map(c=>this.stringToTyped(`${n}:${c}`));return new Re(new Fe(this.nativeToType(n)),s)}if(t.startsWith("composite")){let n=t.match(/\(([^)]+)\)/)?.[1],a=r.split(C.ArgCompositeSeparator),o=n.split(C.ArgCompositeSeparator),s=a.map((p,u)=>this.stringToTyped(`${o[u]}:${p}`)),c=s.map(p=>p.getType());return new xe(new We(...c),s)}if(t==="string")return r?ve.fromUTF8(r):new T;if(t==="uint8")return r?new Se(Number(r)):new T;if(t==="uint16")return r?new Ae(Number(r)):new T;if(t==="uint32")return r?new Be(Number(r)):new T;if(t==="uint64")return r?new Z(BigInt(r)):new T;if(t==="biguint")return r?new z(BigInt(r)):new T;if(t==="bool")return r?new de(typeof r=="boolean"?r:r==="true"):new T;if(t==="address")return r?new fe(tt.newFromBech32(r)):new T;if(t==="token")return r?new X(r):new T;if(t==="hex")return r?ge.fromHex(r):new T;if(t==="codemeta")return new we(rt.newFromBytes(Uint8Array.from(Buffer.from(r,"hex"))));if(t==="esdt"){let n=r.split(C.ArgCompositeSeparator);return new st(this.nativeToType("esdt"),[new Q(new X(n[0]),"token_identifier"),new Q(new Z(BigInt(n[1])),"token_nonce"),new Q(new z(BigInt(n[2])),"amount")])}throw new Error(`WarpArgSerializer (stringToTyped): Unsupported input type: ${t}`)}typeToString(e){if(e instanceof it)return"option:"+this.typeToString(e.getFirstTypeParameter());if(e instanceof at)return"optional:"+this.typeToString(e.getFirstTypeParameter());if(e instanceof nt)return"list:"+this.typeToString(e.getFirstTypeParameter());if(e instanceof Fe)return"variadic:"+this.typeToString(e.getFirstTypeParameter());if(e instanceof Ce)return"string";if(e instanceof Ve)return"uint8";if(e instanceof Ee)return"uint16";if(e instanceof Ie)return"uint32";if(e instanceof Y)return"uint64";if(e instanceof H)return"biguint";if(e instanceof me)return"bool";if(e instanceof le)return"address";if(e instanceof J)return"token";if(e instanceof ye)return"hex";if(e instanceof he)return"codemeta";if(e instanceof be&&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 mt(e.cache?.type)}async getTransactionExecutionResults(e,t){let{actionIndex:r}=Ue(e),n=this.cache.get(dt.WarpExecutable(this.config.env,e.meta?.hash||"",r))??[],a=await this.extractContractResults(e,t,n),o=ft(this.config,[],e,r,a),s=lt(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 U(e,s,a,r)}}let p=await this.abi.getAbiForAction(n),u=new ut({abi:p}),y=new pt({abi:p}).parseExecute({transactionOnNetwork:t,function:n.func||void 0});for(let[w,f]of Object.entries(e.results)){if(f.startsWith(ke.Transform.Prefix))continue;if(f.startsWith("input.")){s[w]=f;continue}let v=Pe(f);if(v!==null&&v!==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=ct(t,E),S=u.parseEvents({events:g})[0],N=Object.values(S)[R]||null;o.push(N),s[w]=N&&N.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 U(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(ke.Transform.Prefix))continue;let l=Pe(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 U(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,v=[]){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,v);else if(W.type==="collect")E=await n.executeCollect(t,f,v,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[v,W]of Object.entries(f.results))W!==null?l[v]=W:v in l||(l[v]=null);let y=await U(t,l,r,a);return{...s.get(r),action:r,results:y}}};import{Address as yt,AddressValue as gt,BigUIntType as ht,BigUIntValue as _e,BooleanValue as wt,BytesValue as Wt,CodeMetadata as xt,CodeMetadataValue as Tt,CompositeType as Ct,CompositeValue as vt,Field as ee,FieldDefinition as te,List as bt,NothingValue as Et,OptionalValue as re,OptionValue as ne,StringValue as At,Struct as It,StructType as Bt,TokenIdentifierType as Vt,TokenIdentifierValue as Oe,U16Value as St,U32Value as Ft,U64Type as Rt,U64Value as Me,U8Value as Nt,VariadicValue as Ut}from"@multiversx/sdk-core";var Hr=(i,e)=>i?ne.newProvided(i):e?ne.newMissingTyped(e):ne.newMissing(),zr=(i,e)=>i?new re(i.getType(),i):e?new re(e):re.newMissing(),Qr=i=>{if(i.length===0)throw new Error("Cannot create a list from an empty array");let e=i[0].getType();return new bt(e,i)},jr=i=>Ut.fromItems(...i),Gr=i=>{let e=i.map(t=>t.getType());return new vt(new Ct(...e),i)},Kr=i=>At.fromUTF8(i),Jr=i=>new Nt(i),Xr=i=>new St(i),Yr=i=>new Ft(i),Zr=i=>new Me(i),en=i=>new _e(BigInt(i)),tn=i=>new wt(i),rn=i=>new gt(yt.newFromBech32(i)),nn=i=>new Oe(i),an=i=>Wt.fromHex(i),$e=i=>new It(new Bt("EsdtTokenPayment",[new te("token_identifier","",new Vt),new te("token_nonce","",new Rt),new te("amount","",new ht)]),[new ee(new Oe(i.token.identifier),"token_identifier"),new ee(new Me(BigInt(i.token.nonce)),"token_nonce"),new ee(new _e(BigInt(i.amount)),"amount")]),sn=i=>new Tt(xt.newFromBytes(Uint8Array.from(Buffer.from(i,"hex")))),on=()=>new Et;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=ae(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 Le({chainID:e.chainInfo.chainId}),a=e.data?Buffer.from(this.serializer.stringToTyped(e.data).valueOf()):null;return new Dt({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=ae(e.warp,e.action),n=F.newFromBech32(t),a=e.args.map(s=>this.serializer.stringToTyped(s)),o=new Le({chainID:e.chainInfo.chainId});return new Ot({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=ae(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 Pt,y=r.getEndpoint(p.function||t.func||""),w=(p.returnDataParts||[]).map(b=>Buffer.from(b)),f=l.buffersToValues(w,y.output),{values:v,results:W}=await this.results.extractQueryResults(e.warp,f,e.action,e.resolvedInputs),E=Gt(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:v,results:W,messages:Qt(e.warp,W)}}async preprocessInput(e,t,r,n){if(r==="esdt"){let[a,o,s,c]=n.split(qe.ArgCompositeSeparator);if(c)return t;let p=new $t({identifier:a,nonce:BigInt(o)});if(!new Lt().isFungible(p))return t;let y=jt(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=$e(new qt({token:p,amount:Kt(s,y)}));return this.serializer.typedToString(w)+qe.ArgCompositeSeparator+y}return t}static getChainEntrypoint(e,t){let r="warp-sdk";return t==="devnet"?new kt({url:e.apiUrl,kind:"api",clientName:r}):t==="testnet"?new Mt({url:e.apiUrl,kind:"api",clientName:r}):new _t({url:e.apiUrl,kind:"api",clientName:r})}async signMessage(e,t){let r=Ht.fromString(t);return(await new zt(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 De.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 De.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 Jt(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=Xt.WarpAbi(this.config.env,e);if(t){let o=this.cache.get(r);if(o)return ze.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 ze.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 ie.create(t.abi)}async fetchAbi(e){if(!e.abi)throw new Error("WarpActionExecutor: ABI not found");if(e.abi.startsWith(He.IdentifierType.Hash)){let t=e.abi.split(He.IdentifierParamSeparatorDefault)[1],r=await this.createFromTransactionHash(t);if(!r)throw new Error(`WarpActionExecutor: ABI not found for hash: ${e.abi}`);return ie.create(r.content)}else{let r=await(await fetch(e.abi)).json();return ie.create(r)}}};import{Address as Qe,TransactionsFactoryConfig as Yt,TransferTransactionsFactory as Zt}from"@multiversx/sdk-core";import{WarpBrandBuilder as er,WarpLogger as tr}from"@vleap/warps";import{Buffer as rr}from"buffer";var k=class{constructor(e,t,r){this.config=e;this.chain=t;this.chainInfo=r;this.core=new er(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 Yt({chainID:this.chainInfo.chainId}),n=new Zt({config:r}),a=Qe.newFromBech32(t),o=JSON.stringify(e);return await n.createTransactionForNativeTokenTransfer(a,{receiver:Qe.newFromBech32(t),nativeAmount:BigInt(0),data:Uint8Array.from(rr.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 tr.error("BrandBuilder: Error creating from transaction hash",n),null}}};import{Address as je,TransactionsFactoryConfig as nr,TransferTransactionsFactory as ar}from"@multiversx/sdk-core";import{WarpBuilder as Ge,WarpCache as ir,WarpCacheKey as sr,WarpLogger as Ke}from"@vleap/warps";var _=class extends Ge{constructor(t,r,n){super(t);this.config=t;this.chain=r;this.chainInfo=n;this.cache=new ir(t.cache?.type),this.core=new Ge(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 nr({chainID:this.chainInfo.chainId}),a=new ar({config:n}),o=je.newFromBech32(r),s=JSON.stringify(t),c=await a.createTransactionForTransfer(o,{receiver:je.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=sr.Warp(this.config.env,t);if(r){let s=this.cache.get(n);if(s)return Ke.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 Ke.error("WarpBuilder: Error creating from transaction hash",s),null}}};var ha={Egld:{Identifier:"EGLD",EsdtIdentifier:"EGLD-000000",DisplayName:"eGold",Decimals:18}},or=(r=>(r.MultiversxExplorer="multiversx_explorer",r.MultiversxExplorerDevnet="multiversx_explorer_devnet",r.MultiversxExplorerTestnet="multiversx_explorer_testnet",r))(or||{}),cr=(r=>(r.VibechainExplorer="vibechain_explorer",r.VibechainExplorerDevnet="vibechain_explorer_devnet",r.VibechainExplorerTestnet="vibechain_explorer_testnet",r))(cr||{}),Je={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=Je[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 Ye,Address as m,AddressValue as oe,BytesValue as d,SmartContractTransactionsFactory as ur,TransactionsFactoryConfig as lr}from"@multiversx/sdk-core";import{WarpCache as fr,WarpCacheKey as ce,WarpLogger as pe}from"@vleap/warps";var se={buildInfo:{rustc:{version:"1.86.0",commitHash:"05f9846f893b09a1be1fc8560e33fc3c815cfecb",commitDate:"2025-03-31",channel:"Stable",short:"rustc 1.86.0 (05f9846f8 2025-03-31)"},contractCrate:{name:"registry",version:"0.0.1"},framework:{name:"multiversx-sc",version:"0.51.1"}},name:"RegistryContract",constructor:{inputs:[{name:"unit_price",type:"BigUint"},{name:"vault",type:"Address"}],outputs:[]},upgradeConstructor:{inputs:[],outputs:[]},endpoints:[{name:"registerWarp",mutability:"mutable",payableInTokens:["EGLD"],inputs:[{name:"hash",type:"bytes"},{name:"alias_opt",type:"optional<bytes>",multi_arg:!0},{name:"brand_opt",type:"optional<bytes>",multi_arg:!0}],outputs:[],allow_multiple_var_args:!0},{name:"unregisterWarp",mutability:"mutable",inputs:[{name:"warp",type:"bytes"}],outputs:[]},{name:"upgradeWarp",mutability:"mutable",payableInTokens:["EGLD"],inputs:[{name:"alias",type:"bytes"},{name:"new_warp",type:"bytes"}],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}),Xe=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 fr(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 oe(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=ce.RegistryInfo(this.config.env,e),n=t?this.cache.get(r):null;if(n)return pe.info(`WarpRegistry (getInfoByAlias): RegistryInfo found in cache: ${e}`),n;let a=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=ce.RegistryInfo(this.config.env,e);if(t){let l=this.cache.get(r);if(l)return pe.info(`WarpRegistry (getInfoByHash): RegistryInfo found in cache: ${e}`),l}let n=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 oe(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 oe(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=ce.Brand(this.config.env,e),n=t?this.cache.get(r):null;if(n)return pe.info(`WarpRegistry (fetchBrand): Brand found in cache: ${e}`),n;let 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?Xe(r):null;this.registryConfig=n||{unitPrice:BigInt(0),admins:[]}}getFactory(){let e=new lr({chainID:this.chainInfo.chainId}),t=Ye.create(se);return new ur({config:e,abi:t})}getController(){let e=h.getChainEntrypoint(this.chainInfo,this.config.env),t=Ye.create(se);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 D="multiversx",L=q(D,"mvx",{mainnet:{name:D,displayName:"MultiversX",chainId:"1",blockTime:6e3,addressHrp:"erd",apiUrl:"https://api.multiversx.com",nativeToken:"EGLD"},testnet:{name:D,displayName:"MultiversX Testnet",chainId:"T",blockTime:6e3,addressHrp:"erd",apiUrl:"https://testnet-api.multiversx.com",nativeToken:"EGLD"},devnet:{name:D,displayName:"MultiversX Devnet",chainId:"D",blockTime:6e3,addressHrp:"erd",apiUrl:"https://devnet-api.multiversx.com",nativeToken:"EGLD"}});var Ze="vibechain",ue={name:Ze,displayName:"VibeChain",chainId:"V",blockTime:600,addressHrp:"vibe",apiUrl:"https://vibeox-api.multiversx.com",nativeToken:"VIBE"},et=q(Ze,"vibe",{mainnet:ue,testnet:ue,devnet:ue});var ni=(i,e)=>[L(i,e),et(i,e)];export{B as ExplorerUrls,or as MultiversxExplorers,Je as MultiversxExplorersConfig,cr as VibechainExplorers,I as WarpMultiversxAbiBuilder,k as WarpMultiversxBrandBuilder,_ as WarpMultiversxBuilder,ha as WarpMultiversxConstants,P as WarpMultiversxContractLoader,h as WarpMultiversxExecutor,O as WarpMultiversxExplorer,$ as WarpMultiversxRegistry,V as WarpMultiversxResults,A as WarpMultiversxSerializer,rn as address_value,en as biguint_value,tn as boolean_value,sn as codemeta_value,Gr as composite_value,q as createMultiversxAdapter,$e as esdt_value,ni as getAllMultiversxAdapters,L as getMultiversxAdapter,x as getMultiversxRegistryAddress,et as getVibechainAdapter,an as hex_value,Qr as list_value,on as nothing_value,Hr as option_value,zr as optional_value,Kr as string_value,nn as token_value,Xr as u16_value,Yr as u32_value,Zr as u64_value,Jr as u8_value,jr as variadic_value};
|
|
1
|
+
import{AbiRegistry as ae}from"@multiversx/sdk-core";import{WarpCache as Jt,WarpCacheKey as Xt,WarpConstants as De,WarpLogger as He}from"@vleap/warps";import{WarpLogger as qe}from"@vleap/warps";import{Address as F,ArgSerializer as Pt,DevnetEntrypoint as kt,MainnetEntrypoint as _t,SmartContractTransactionsFactory as Ot,TestnetEntrypoint as Mt,Token as $t,TokenComputer as Lt,TokenTransfer as qt,TransactionsFactoryConfig as $e,TransferTransactionsFactory as Dt,UserSecretKey as Ht,UserSigner as zt}from"@multiversx/sdk-core";import{applyResultsToMessages as Qt,findKnownTokenById as jt,getNextInfo as Gt,getWarpActionByIndex as ne,shiftBigintBy as Kt,WarpConstants as Le}from"@vleap/warps";import{findEventsByFirstTopic as ct,SmartContractTransactionsOutcomeParser as pt,TransactionEventsParser as ut}from"@multiversx/sdk-core";import{applyResultsToMessages as lt,evaluateResultsCommon as U,findWarpExecutableAction as Ne,getNextInfo as mt,parseResultsOutIndex as Ue,WarpCache as ft,WarpCacheKey as dt,WarpConstants as Pe}from"@vleap/warps";import{Address as tt,AddressType as ue,AddressValue as le,BigUIntType as D,BigUIntValue as H,BooleanType as me,BooleanValue as fe,BytesType as de,BytesValue as ge,CodeMetadata as rt,CodeMetadataType as ye,CodeMetadataValue as he,CompositeType as we,CompositeValue as We,Field as z,FieldDefinition as Q,List as xe,ListType as nt,NothingValue as T,OptionalType as at,OptionalValue as j,OptionType as it,OptionValue as G,StringType as Te,StringValue as Ce,Struct as st,StructType as ve,TokenIdentifierType as K,TokenIdentifierValue as J,U16Type as be,U16Value as Ee,U32Type as Ae,U32Value as Be,U64Type as X,U64Value as Y,U8Type as Ie,U8Value as Ve,VariadicType as Se,VariadicValue as Fe}from"@multiversx/sdk-core";import{WarpConstants as C,WarpSerializer as ot}from"@vleap/warps";var Re=new RegExp(`${C.ArgParamsSeparator}(.*)`),A=class{constructor(){this.coreSerializer=new ot}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(C.ArgParamsSeparator)[0])[0],a=t.map(o=>this.typedToString(o).split(C.ArgParamsSeparator)[1]);return`list:${n}:${a.join(",")}`}if(e.hasClassOrSuperclass(Fe.ClassName)){let t=e.getItems(),n=t.map(o=>this.typedToString(o).split(C.ArgParamsSeparator)[0])[0],a=t.map(o=>this.typedToString(o).split(C.ArgParamsSeparator)[1]);return`variadic:${n}:${a.join(",")}`}if(e.hasClassOrSuperclass(We.ClassName)){let t=e.getItems(),r=t.map(s=>this.typedToString(s).split(C.ArgParamsSeparator)[0]),n=t.map(s=>this.typedToString(s).split(C.ArgParamsSeparator)[1]),a=r.join(C.ArgCompositeSeparator),o=n.join(C.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(Be.ClassName))return`uint32:${e.valueOf().toNumber()}`;if(e.hasClassOrSuperclass(Y.ClassName))return`uint64:${BigInt(e.valueOf().toFixed())}`;if(e.hasClassOrSuperclass(Ce.ClassName))return`string:${e.valueOf()}`;if(e.hasClassOrSuperclass(fe.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(ge.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(C.ArgCompositeSeparator).map(r=>this.nativeToType(r)))}if(e==="string")return new Te;if(e==="uint8")return new Ie;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 me;if(e==="address")return new ue;if(e==="token")return new K;if(e==="hex")return new de;if(e==="codemeta")return new ye;if(e==="esdt"||e==="nft")return new ve("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(C.ArgCompositeSeparator),o=n.split(C.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?Ce.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 Be(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 fe(typeof r=="boolean"?r:r==="true"):new T;if(t==="address")return r?new le(tt.newFromBech32(r)):new T;if(t==="token")return r?new J(r):new T;if(t==="hex")return r?ge.fromHex(r):new T;if(t==="codemeta")return new he(rt.newFromBytes(Uint8Array.from(Buffer.from(r,"hex"))));if(t==="esdt"){let n=r.split(C.ArgCompositeSeparator);return new st(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 it)return"option:"+this.typeToString(e.getFirstTypeParameter());if(e instanceof at)return"optional:"+this.typeToString(e.getFirstTypeParameter());if(e instanceof nt)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 Ie)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 me)return"bool";if(e instanceof ue)return"address";if(e instanceof K)return"token";if(e instanceof de)return"hex";if(e instanceof ye)return"codemeta";if(e instanceof ve&&e.getClassName()==="EsdtTokenPayment")return"esdt";throw new Error(`WarpArgSerializer (typeToString): Unsupported input type: ${e.getClassName()}`)}};var V=class{constructor(e,t){this.config=e;this.chain=t;this.abi=new B(e,t),this.serializer=new A,this.cache=new ft(e.cache?.type)}async getTransactionExecutionResults(e,t){let{actionIndex:r}=Ne(e),n=this.cache.get(dt.WarpExecutable(this.config.env,e.meta?.hash||"",r))??[],a=await this.extractContractResults(e,t,n),o=mt(this.config,[],e,r,a),s=lt(e,a.results);return{success:t.status.isSuccessful(),warp:e,action:r,user:this.config.user?.wallets?.[this.chain.name]||null,txHash:t.hash,next:o,values:a.values,results:a.results,messages:s}}async extractContractResults(e,t,r){let{action:n,actionIndex:a}=Ne(e),o=[],s={};if(!e.results||n.type!=="contract")return{values:o,results:s};if(!Object.values(e.results).some(w=>w.includes("out")||w.includes("event"))){for(let[w,m]of Object.entries(e.results))s[w]=m;return{values:o,results:await U(e,s,a,r)}}let p=await this.abi.getAbiForAction(n),u=new ut({abi:p}),g=new pt({abi:p}).parseExecute({transactionOnNetwork:t,function:n.func||void 0});for(let[w,m]of Object.entries(e.results)){if(m.startsWith(Pe.Transform.Prefix))continue;if(m.startsWith("input.")){s[w]=m;continue}let v=Ue(m);if(v!==null&&v!==a){s[w]=null;continue}let[W,E,b]=m.split(".");if(W==="event"){if(!E||isNaN(Number(b)))continue;let R=Number(b),y=ct(t,E),S=u.parseEvents({events:y})[0],N=Object.values(S)[R]||null;o.push(N),s[w]=N&&N.valueOf()}else if(W==="out"||W.startsWith("out[")){if(!E)continue;let R=Number(E),y=g.values[R-1]||null;b&&(y=y[b]||null),y&&typeof y=="object"&&(y="toFixed"in y?y.toFixed():y.valueOf()),o.push(y),s[w]=y&&y.valueOf()}else s[w]=m}return{values:o,results:await U(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(g=>parseInt(g)-1);if(u.length===0)return;let l=o[u[0]];for(let g=1;g<u.length;g++){if(l==null)return;l=l[u[g]]}return l};for(let[p,u]of Object.entries(e.results)){if(u.startsWith(Pe.Transform.Prefix))continue;let l=Ue(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 U(e,s,r,n)}}async resolveWarpResultsRecursively(e){let t=e.warp,r=e.entryActionIndex,n=e.executor,a=e.inputs,o=e.meta,s=new Map,c=new Set,p=this;async function u(m,v=[]){if(s.has(m))return s.get(m);if(c.has(m))throw new Error(`Circular dependency detected at action ${m}`);c.add(m);let W=t.actions[m-1];if(!W)throw new Error(`Action ${m} not found`);let E;if(W.type==="query")E=await n.executeQuery(t,m,v);else if(W.type==="collect")E=await n.executeCollect(t,m,v,o);else throw new Error(`Unsupported or interactive action type: ${W.type}`);if(s.set(m,E),t.results)for(let b of Object.values(t.results)){let y=String(b).match(/^out\[(\d+)\]/);if(y){let S=parseInt(y[1],10);S!==m&&!s.has(S)&&await u(S)}}return c.delete(m),E}await u(r,a);let l={};for(let m of s.values())for(let[v,W]of Object.entries(m.results))W!==null?l[v]=W:v in l||(l[v]=null);let g=await U(t,l,r,a);return{...s.get(r),action:r,results:g}}};import{Address as gt,AddressValue as yt,BigUIntType as ht,BigUIntValue as ke,BooleanValue as wt,BytesValue as Wt,CodeMetadata as xt,CodeMetadataValue as Tt,CompositeType as Ct,CompositeValue as vt,Field as Z,FieldDefinition as ee,List as bt,NothingValue as Et,OptionalValue as te,OptionValue as re,StringValue as At,Struct as Bt,StructType as It,TokenIdentifierType as Vt,TokenIdentifierValue as _e,U16Value as St,U32Value as Ft,U64Type as Rt,U64Value as Oe,U8Value as Nt,VariadicValue as Ut}from"@multiversx/sdk-core";var Dr=(i,e)=>i?re.newProvided(i):e?re.newMissingTyped(e):re.newMissing(),Hr=(i,e)=>i?new te(i.getType(),i):e?new te(e):te.newMissing(),zr=i=>{if(i.length===0)throw new Error("Cannot create a list from an empty array");let e=i[0].getType();return new bt(e,i)},Qr=i=>Ut.fromItems(...i),jr=i=>{let e=i.map(t=>t.getType());return new vt(new Ct(...e),i)},Gr=i=>At.fromUTF8(i),Kr=i=>new Nt(i),Jr=i=>new St(i),Xr=i=>new Ft(i),Yr=i=>new Oe(i),Zr=i=>new ke(BigInt(i)),en=i=>new wt(i),tn=i=>new yt(gt.newFromBech32(i)),rn=i=>new _e(i),nn=i=>Wt.fromHex(i),Me=i=>new Bt(new It("EsdtTokenPayment",[new ee("token_identifier","",new Vt),new ee("token_nonce","",new Rt),new ee("amount","",new ht)]),[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")]),an=i=>new Tt(xt.newFromBytes(Uint8Array.from(Buffer.from(i,"hex")))),sn=()=>new Et;var h=class i{constructor(e,t){this.config=e;this.chain=t;this.serializer=new A,this.abi=new B(this.config,this.chain),this.results=new V(this.config,this.chain)}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.name];if(!t)throw new Error("WarpMultiversxExecutor: createTransfer - user address not set");let r=F.newFromBech32(t),n=new $e({chainID:e.chain.chainId}),a=e.data?Buffer.from(this.serializer.stringToTyped(e.data).valueOf()):null;return new Dt({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.name];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.chain.chainId});return new Ot({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.chain,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 Pt,g=r.getEndpoint(p.function||t.func||""),w=(p.returnDataParts||[]).map(b=>Buffer.from(b)),m=l.buffersToValues(w,g.output),{values:v,results:W}=await this.results.extractQueryResults(e.warp,m,e.action,e.resolvedInputs),E=Gt(this.config,[],e.warp,e.action,W);return{success:u,warp:e.warp,action:e.action,user:this.config.user?.wallets?.[e.chain.name]||null,txHash:null,next:E,values:v,results:W,messages:Qt(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 $t({identifier:a,nonce:BigInt(o)});if(!new Lt().isFungible(p))return t;let g=jt(a)?.decimals;if(g||(g=(await(await fetch(`${e.apiUrl}/tokens/${a}`)).json()).decimals),!g)throw new Error(`WarpActionExecutor: Decimals not found for token ${a}`);let w=Me(new qt({token:p,amount:Kt(s,g)}));return this.serializer.typedToString(w)+Le.ArgCompositeSeparator+g}return t}static getChainEntrypoint(e,t){let r="warp-sdk";return t==="devnet"?new kt({url:e.apiUrl,kind:"api",clientName:r}):t==="testnet"?new Mt({url:e.apiUrl,kind:"api",clientName:r}):new _t({url:e.apiUrl,kind:"api",clientName:r})}async signMessage(e,t){let r=Ht.fromString(t);return(await new zt(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 B=class{constructor(e,t){this.config=e;this.chain=t;this.contractLoader=new P(this.config),this.cache=new Jt(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=Xt.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.chain,this.config.env).createNetworkProvider();try{let o=await a.getTransaction(e),s=await this.createFromTransaction(o);return t&&t.ttl&&s&&this.cache.set(r,s,t.ttl),s}catch(o){return 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.chain);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 Yt,TransferTransactionsFactory as Zt}from"@multiversx/sdk-core";import{WarpBrandBuilder as er,WarpLogger as tr}from"@vleap/warps";import{Buffer as rr}from"buffer";var k=class{constructor(e,t){this.config=e;this.chain=t;this.core=new er(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 Yt({chainID:this.chain.chainId}),n=new Zt({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(rr.from(o))})}async createFromTransaction(e,t=!1){return await this.core.createFromRaw(e.data.toString(),t)}async createFromTransactionHash(e){let r=h.getChainEntrypoint(this.chain,this.config.env).createNetworkProvider();try{let n=await r.getTransaction(e);return this.createFromTransaction(n)}catch(n){return tr.error("BrandBuilder: Error creating from transaction hash",n),null}}};import{Address as Qe,TransactionsFactoryConfig as nr,TransferTransactionsFactory as ar}from"@multiversx/sdk-core";import{WarpBuilder as je,WarpCache as ir,WarpCacheKey as sr,WarpLogger as Ge}from"@vleap/warps";var _=class extends je{constructor(t,r){super(t);this.config=t;this.chain=r;this.cache=new ir(t.cache?.type),this.core=new je(t)}async createInscriptionTransaction(t){let r=this.config.user?.wallets?.[this.chain.name];if(!r)throw new Error("WarpBuilder: user address not set");let n=new nr({chainID:this.chain.chainId}),a=new ar({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.name,hash:t.hash,creator:t.sender.toBech32(),createdAt:new Date(t.timestamp*1e3).toISOString()},n}async createFromTransactionHash(t,r){let n=sr.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.chain,this.config.env).createNetworkProvider();try{let s=await o.getTransaction(t),c=await this.createFromTransaction(s);return r&&r.ttl&&c&&this.cache.set(n,c,r.ttl),c}catch(s){return Ge.error("WarpBuilder: Error creating from transaction hash",s),null}}};var ma={Egld:{Identifier:"EGLD",EsdtIdentifier:"EGLD-000000",DisplayName:"eGold",Decimals:18}},or=(r=>(r.MultiversxExplorer="multiversx_explorer",r.MultiversxExplorerDevnet="multiversx_explorer_devnet",r.MultiversxExplorerTestnet="multiversx_explorer_testnet",r))(or||{}),cr=(r=>(r.VibechainExplorer="vibechain_explorer",r.VibechainExplorerDevnet="vibechain_explorer_devnet",r.VibechainExplorerTestnet="vibechain_explorer_testnet",r))(cr||{}),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"]}},I={multiversx_explorer:"https://explorer.multiversx.com",multiversx_explorer_devnet:"https://devnet-explorer.multiversx.com",multiversx_explorer_testnet:"https://testnet-explorer.multiversx.com",vibechain_explorer:"https://vibeox-explorer.multiversx.com",vibechain_explorer_devnet:"https://vibeox-explorer.multiversx.com",vibechain_explorer_testnet:"https://vibeox-explorer.multiversx.com"};var 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=I[t];if(a)return a}if(e){let a=I[e];if(a)return a}let r=this.getPrimaryExplorer();return I[r]||I[r]}getAccountUrl(e,t){return`${this.getExplorerUrlByName(t)}/accounts/${e}`}getTransactionUrl(e,t){return`${this.getExplorerUrlByName(t)}/transactions/${e}`}getBlockUrl(e,t){return`${this.getExplorerUrlByName(t)}/blocks/${e}`}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=I[n];a&&(r[n]=`${a}/accounts/${e}`)}),r}getTransactionUrls(e){let t=this.getAllExplorers(),r={};return t.forEach(n=>{let a=I[n];a&&(r[n]=`${a}/transactions/${e}`)}),r}};import{AbiRegistry as Xe,Address as f,AddressValue as se,BytesValue as d,SmartContractTransactionsFactory as ur,TransactionsFactoryConfig as lr}from"@multiversx/sdk-core";import{WarpCache as mr,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,t){this.config=e;this.chain=t;this.cache=new mr(e.cache?.type),this.registryConfig={unitPrice:BigInt(0),admins:[]},this.userWallet=this.config.user?.wallets?.[this.chain.name]||null}async init(){await this.loadRegistryConfigs()}getRegistryConfig(){return this.registryConfig}async createWarpRegisterTransaction(e,t,r){if(this.registryConfig.unitPrice===BigInt(0))throw new Error("WarpRegistry: config not loaded. forgot to call init()?");if(!this.userWallet)throw new Error("WarpRegistry: user address not set");let n=f.newFromBech32(this.userWallet),a=()=>this.isCurrentUserAdmin()?BigInt(0):t&&r?this.registryConfig.unitPrice*BigInt(3):t?this.registryConfig.unitPrice*BigInt(2):this.registryConfig.unitPrice,o=()=>t&&r?[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:f.newFromBech32(x(this.config.env)),function:"registerWarp",gasLimit:BigInt(1e7),nativeTransferAmount:a(),arguments:o()})}async createWarpUnregisterTransaction(e){if(!this.userWallet)throw new Error("WarpRegistry: user address not set");let t=f.newFromBech32(this.userWallet);return await this.getFactory().createTransactionForExecute(t,{contract:f.newFromBech32(x(this.config.env)),function:"unregisterWarp",gasLimit:BigInt(1e7),arguments:[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=f.newFromBech32(this.userWallet);return await this.getFactory().createTransactionForExecute(r,{contract:f.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=f.newFromBech32(this.userWallet);return await this.getFactory().createTransactionForExecute(r,{contract:f.newFromBech32(x(this.config.env)),function:"setWarpAlias",gasLimit:BigInt(1e7),nativeTransferAmount:this.isCurrentUserAdmin()?void 0:this.registryConfig.unitPrice,arguments:[d.fromHex(e),d.fromUTF8(t)]})}async createWarpVerifyTransaction(e){if(!this.userWallet)throw new Error("WarpRegistry: user address not set");let t=f.newFromBech32(this.userWallet);return await this.getFactory().createTransactionForExecute(t,{contract:f.newFromBech32(x(this.config.env)),function:"verifyWarp",gasLimit:BigInt(1e7),arguments:[d.fromHex(e)]})}async createWarpTransferOwnershipTransaction(e,t){if(!this.userWallet)throw new Error("WarpRegistry: user address not set");let r=f.newFromBech32(this.userWallet);return await this.getFactory().createTransactionForExecute(r,{contract:f.newFromBech32(x(this.config.env)),function:"transferOwnership",gasLimit:BigInt(1e7),arguments:[d.fromHex(e),new se(new f(t))]})}async createBrandRegisterTransaction(e){if(this.registryConfig.unitPrice===BigInt(0))throw new Error("WarpRegistry: config not loaded. forgot to call init()?");if(!this.userWallet)throw new Error("WarpRegistry: user address not set");let t=f.newFromBech32(this.userWallet);return await this.getFactory().createTransactionForExecute(t,{contract:f.newFromBech32(x(this.config.env)),function:"registerBrand",gasLimit:BigInt(1e7),nativeTransferAmount:this.isCurrentUserAdmin()?void 0:this.registryConfig.unitPrice,arguments:[d.fromHex(e)]})}async createWarpBrandingTransaction(e,t){if(!this.userWallet)throw new Error("WarpRegistry: user address not set");let r=f.newFromBech32(this.userWallet);return await this.getFactory().createTransactionForExecute(r,{contract:f.newFromBech32(x(this.config.env)),function:"brandWarp",gasLimit:BigInt(1e7),nativeTransferAmount:this.isCurrentUserAdmin()?void 0:this.registryConfig.unitPrice,arguments:[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=f.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=f.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=f.newFromBech32(x(this.config.env)),n=this.getController(),a=n.createQuery({contract:r,function:"getUserWarps",arguments:[new se(new f(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=f.newFromBech32(x(this.config.env)),n=this.getController(),a=n.createQuery({contract:r,function:"getUserBrands",arguments:[new se(new f(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.chain,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=f.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 lr({chainID:this.chain.chainId}),t=Xe.create(ie);return new ur({config:e,abi:t})}getController(){let e=h.getChainEntrypoint(this.chain,this.config.env),t=Xe.create(ie);return e.createSmartContractController(t)}isCurrentUserAdmin(){return!!this.userWallet&&this.registryConfig.admins.includes(this.userWallet)}};var L=(i,e,t)=>(r,n)=>{let a=t[r.env];return{chain:i,chainInfo:a,prefix:e,builder:()=>new _(r,a),executor:new h(r,a),results:new V(r,a),serializer:new A,registry:new $(r,a),explorer:new O(i,r),abiBuilder:()=>new B(r,a),brandBuilder:()=>new k(r,a)}};var q="multiversx",Ye=L(q,"mvx",{mainnet:{name:q,displayName:"MultiversX",chainId:"1",blockTime:6e3,addressHrp:"erd",apiUrl:"https://api.multiversx.com",nativeToken:"EGLD"},testnet:{name:q,displayName:"MultiversX Testnet",chainId:"T",blockTime:6e3,addressHrp:"erd",apiUrl:"https://testnet-api.multiversx.com",nativeToken:"EGLD"},devnet:{name:q,displayName:"MultiversX Devnet",chainId:"D",blockTime:6e3,addressHrp:"erd",apiUrl:"https://devnet-api.multiversx.com",nativeToken:"EGLD"}});var Ze="vibechain",pe={name:Ze,displayName:"VibeChain",chainId:"V",blockTime:600,addressHrp:"vibe",apiUrl:"https://vibeox-api.multiversx.com",nativeToken:"VIBE"},et=L(Ze,"vibe",{mainnet:pe,testnet:pe,devnet:pe});var Xa=(i,e)=>[Ye(i,e),et(i,e)];export{I as ExplorerUrls,or as MultiversxExplorers,Ke as MultiversxExplorersConfig,cr as VibechainExplorers,B as WarpMultiversxAbiBuilder,k as WarpMultiversxBrandBuilder,_ as WarpMultiversxBuilder,ma as WarpMultiversxConstants,P as WarpMultiversxContractLoader,h as WarpMultiversxExecutor,O as WarpMultiversxExplorer,$ as WarpMultiversxRegistry,V as WarpMultiversxResults,A as WarpMultiversxSerializer,tn as address_value,Zr as biguint_value,en as boolean_value,an as codemeta_value,jr as composite_value,L as createMultiversxAdapter,Me as esdt_value,Xa as getAllMultiversxAdapters,Ye as getMultiversxAdapter,x as getMultiversxRegistryAddress,et as getVibechainAdapter,nn as hex_value,zr as list_value,sn as nothing_value,Dr as option_value,Hr as optional_value,Gr as string_value,rn as token_value,Jr as u16_value,Xr as u32_value,Yr as u64_value,Kr as u8_value,Qr as variadic_value};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vleap/warps-adapter-multiversx",
|
|
3
|
-
"version": "0.2.0-alpha.
|
|
3
|
+
"version": "0.2.0-alpha.23",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
@@ -31,6 +31,6 @@
|
|
|
31
31
|
},
|
|
32
32
|
"dependencies": {
|
|
33
33
|
"@multiversx/sdk-core": "^15.0.0",
|
|
34
|
-
"@vleap/warps": "^3.0.0-alpha.
|
|
34
|
+
"@vleap/warps": "^3.0.0-alpha.63"
|
|
35
35
|
}
|
|
36
36
|
}
|