@vleap/warps-adapter-multiversx 0.2.0-alpha.47 → 0.2.0-alpha.48
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.cts +4 -2
- package/dist/index.d.ts +4 -2
- package/dist/index.js +1 -1
- package/dist/index.mjs +1 -1
- package/package.json +5 -5
package/dist/index.d.cts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import * as _vleap_warps from '@vleap/warps';
|
|
2
|
-
import { WarpClientConfig, Adapter, WarpChain, WarpChainEnv, WarpChainInfo, AdapterFactory, WarpChainAsset, AdapterWarpAbiBuilder, WarpAbi, WarpCacheConfig, WarpContractAction, WarpQueryAction, WarpBrand, WarpBuilder, AdapterWarpBuilder, Warp, WarpContract, WarpContractVerification, AdapterWarpDataLoader, WarpChainAccount, WarpChainAction, WarpDataLoaderOptions, AdapterWarpExecutor, WarpExecutable, WarpExecution, AdapterWarpExplorer, AdapterWarpRegistry, WarpRegistryConfigInfo, WarpRegistryInfo, AdapterWarpResults, ResolvedInput, WarpExecutionResults, AdapterWarpSerializer, WarpSerializer, WarpActionInputType, WarpNativeValue, BaseWarpActionInputType, WarpAdapterGenericType } from '@vleap/warps';
|
|
2
|
+
import { WarpClientConfig, Adapter, WarpChain, WarpChainEnv, WarpChainInfo, AdapterFactory, WarpChainAsset, AdapterWarpAbiBuilder, WarpAbiContents, WarpAdapterGenericTransaction, WarpAbi, WarpCacheConfig, WarpContractAction, WarpQueryAction, WarpBrand, WarpBuilder, AdapterWarpBuilder, Warp, WarpContract, WarpContractVerification, AdapterWarpDataLoader, WarpChainAccount, WarpChainAction, WarpDataLoaderOptions, AdapterWarpExecutor, WarpExecutable, WarpExecution, AdapterWarpExplorer, AdapterWarpRegistry, WarpRegistryConfigInfo, WarpRegistryInfo, AdapterWarpResults, ResolvedInput, WarpExecutionResults, AdapterWarpSerializer, WarpSerializer, WarpActionInputType, WarpNativeValue, BaseWarpActionInputType, WarpAdapterGenericType } from '@vleap/warps';
|
|
3
3
|
import { TypedValue, Type, OptionValue, OptionalValue, List, VariadicValue, CompositeValue, StringValue, U8Value, U16Value, U32Value, U64Value, BigUIntValue, BooleanValue, AddressValue, TokenIdentifierValue, BytesValue, TokenTransfer, Struct, CodeMetadataValue, NothingValue, TransactionOnNetwork, AbiRegistry, Transaction, NetworkEntrypoint } from '@multiversx/sdk-core';
|
|
4
|
+
import { WarpAdapterGenericTransaction as WarpAdapterGenericTransaction$1 } from '@vleap/warps/src/types';
|
|
4
5
|
|
|
5
6
|
declare const getAllMultiversxAdapters: (config: WarpClientConfig, fallback?: Adapter) => Adapter[];
|
|
6
7
|
declare const getAllMultiversxChainNames: () => WarpChain[];
|
|
@@ -76,6 +77,7 @@ declare class WarpMultiversxAbiBuilder implements AdapterWarpAbiBuilder {
|
|
|
76
77
|
private readonly contractLoader;
|
|
77
78
|
private readonly cache;
|
|
78
79
|
constructor(config: WarpClientConfig, chain: WarpChainInfo);
|
|
80
|
+
createInscriptionTransaction(abi: WarpAbiContents): Promise<WarpAdapterGenericTransaction>;
|
|
79
81
|
createFromRaw(encoded: string): Promise<WarpAbi>;
|
|
80
82
|
createFromTransaction(tx: TransactionOnNetwork): Promise<WarpAbi>;
|
|
81
83
|
createFromTransactionHash(hash: string, cache?: WarpCacheConfig): Promise<WarpAbi | null>;
|
|
@@ -99,7 +101,7 @@ declare class WarpMultiversxBuilder extends WarpBuilder implements AdapterWarpBu
|
|
|
99
101
|
private readonly cache;
|
|
100
102
|
private readonly core;
|
|
101
103
|
constructor(config: WarpClientConfig, chain: WarpChainInfo);
|
|
102
|
-
createInscriptionTransaction(warp: Warp): Promise<
|
|
104
|
+
createInscriptionTransaction(warp: Warp): Promise<WarpAdapterGenericTransaction$1>;
|
|
103
105
|
createFromTransaction(tx: TransactionOnNetwork, validate?: boolean): Promise<Warp>;
|
|
104
106
|
createFromTransactionHash(hash: string, cache?: WarpCacheConfig): Promise<Warp | null>;
|
|
105
107
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import * as _vleap_warps from '@vleap/warps';
|
|
2
|
-
import { WarpClientConfig, Adapter, WarpChain, WarpChainEnv, WarpChainInfo, AdapterFactory, WarpChainAsset, AdapterWarpAbiBuilder, WarpAbi, WarpCacheConfig, WarpContractAction, WarpQueryAction, WarpBrand, WarpBuilder, AdapterWarpBuilder, Warp, WarpContract, WarpContractVerification, AdapterWarpDataLoader, WarpChainAccount, WarpChainAction, WarpDataLoaderOptions, AdapterWarpExecutor, WarpExecutable, WarpExecution, AdapterWarpExplorer, AdapterWarpRegistry, WarpRegistryConfigInfo, WarpRegistryInfo, AdapterWarpResults, ResolvedInput, WarpExecutionResults, AdapterWarpSerializer, WarpSerializer, WarpActionInputType, WarpNativeValue, BaseWarpActionInputType, WarpAdapterGenericType } from '@vleap/warps';
|
|
2
|
+
import { WarpClientConfig, Adapter, WarpChain, WarpChainEnv, WarpChainInfo, AdapterFactory, WarpChainAsset, AdapterWarpAbiBuilder, WarpAbiContents, WarpAdapterGenericTransaction, WarpAbi, WarpCacheConfig, WarpContractAction, WarpQueryAction, WarpBrand, WarpBuilder, AdapterWarpBuilder, Warp, WarpContract, WarpContractVerification, AdapterWarpDataLoader, WarpChainAccount, WarpChainAction, WarpDataLoaderOptions, AdapterWarpExecutor, WarpExecutable, WarpExecution, AdapterWarpExplorer, AdapterWarpRegistry, WarpRegistryConfigInfo, WarpRegistryInfo, AdapterWarpResults, ResolvedInput, WarpExecutionResults, AdapterWarpSerializer, WarpSerializer, WarpActionInputType, WarpNativeValue, BaseWarpActionInputType, WarpAdapterGenericType } from '@vleap/warps';
|
|
3
3
|
import { TypedValue, Type, OptionValue, OptionalValue, List, VariadicValue, CompositeValue, StringValue, U8Value, U16Value, U32Value, U64Value, BigUIntValue, BooleanValue, AddressValue, TokenIdentifierValue, BytesValue, TokenTransfer, Struct, CodeMetadataValue, NothingValue, TransactionOnNetwork, AbiRegistry, Transaction, NetworkEntrypoint } from '@multiversx/sdk-core';
|
|
4
|
+
import { WarpAdapterGenericTransaction as WarpAdapterGenericTransaction$1 } from '@vleap/warps/src/types';
|
|
4
5
|
|
|
5
6
|
declare const getAllMultiversxAdapters: (config: WarpClientConfig, fallback?: Adapter) => Adapter[];
|
|
6
7
|
declare const getAllMultiversxChainNames: () => WarpChain[];
|
|
@@ -76,6 +77,7 @@ declare class WarpMultiversxAbiBuilder implements AdapterWarpAbiBuilder {
|
|
|
76
77
|
private readonly contractLoader;
|
|
77
78
|
private readonly cache;
|
|
78
79
|
constructor(config: WarpClientConfig, chain: WarpChainInfo);
|
|
80
|
+
createInscriptionTransaction(abi: WarpAbiContents): Promise<WarpAdapterGenericTransaction>;
|
|
79
81
|
createFromRaw(encoded: string): Promise<WarpAbi>;
|
|
80
82
|
createFromTransaction(tx: TransactionOnNetwork): Promise<WarpAbi>;
|
|
81
83
|
createFromTransactionHash(hash: string, cache?: WarpCacheConfig): Promise<WarpAbi | null>;
|
|
@@ -99,7 +101,7 @@ declare class WarpMultiversxBuilder extends WarpBuilder implements AdapterWarpBu
|
|
|
99
101
|
private readonly cache;
|
|
100
102
|
private readonly core;
|
|
101
103
|
constructor(config: WarpClientConfig, chain: WarpChainInfo);
|
|
102
|
-
createInscriptionTransaction(warp: Warp): Promise<
|
|
104
|
+
createInscriptionTransaction(warp: Warp): Promise<WarpAdapterGenericTransaction$1>;
|
|
103
105
|
createFromTransaction(tx: TransactionOnNetwork, validate?: boolean): Promise<Warp>;
|
|
104
106
|
createFromTransactionHash(hash: string, cache?: WarpCacheConfig): Promise<Warp | null>;
|
|
105
107
|
}
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var ie=Object.defineProperty;var Te=Object.getOwnPropertyDescriptor;var be=Object.getOwnPropertyNames;var Ee=Object.prototype.hasOwnProperty;var Ae=(o,e)=>{for(var t in e)ie(o,t,{get:e[t],enumerable:!0})},Be=(o,e,t,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let a of be(e))!Ee.call(o,a)&&a!==t&&ie(o,a,{get:()=>e[a],enumerable:!(r=Te(e,a))||r.enumerable});return o};var Ie=o=>Be(ie({},"__esModule",{value:!0}),o);var Ye={};Ae(Ye,{ExplorerUrls:()=>P,KnownTokens:()=>we,MultiversxExplorers:()=>Ce,MultiversxExplorersConfig:()=>pe,NativeTokenEgld:()=>ae,NativeTokenVibe:()=>ve,VibechainExplorers:()=>xe,WarpMultiversxAbiBuilder:()=>F,WarpMultiversxBrandBuilder:()=>G,WarpMultiversxBuilder:()=>Q,WarpMultiversxConstants:()=>Ve,WarpMultiversxContractLoader:()=>H,WarpMultiversxDataLoader:()=>j,WarpMultiversxExecutor:()=>y,WarpMultiversxExplorer:()=>K,WarpMultiversxRegistry:()=>J,WarpMultiversxResults:()=>_,WarpMultiversxSerializer:()=>k,address_value:()=>Ge,asset_value:()=>Ke,biguint_value:()=>ze,boolean_value:()=>He,codemeta_value:()=>Je,composite_value:()=>Oe,createMultiversxAdapter:()=>X,findKnownTokenById:()=>ce,getAllMultiversxAdapters:()=>ke,getAllMultiversxChainNames:()=>Fe,getMultiversxAdapter:()=>ue,getMultiversxRegistryAddress:()=>W,getVibechainAdapter:()=>de,hex_value:()=>je,list_value:()=>Pe,nothing_value:()=>Xe,option_value:()=>Re,optional_value:()=>Ue,string_value:()=>Me,token_value:()=>Qe,u16_value:()=>Le,u32_value:()=>De,u64_value:()=>qe,u8_value:()=>$e,variadic_value:()=>_e});module.exports=Ie(Ye);var he=require("@vleap/warps");var q=require("@vleap/warps");var ee=require("@multiversx/sdk-core"),N=require("@vleap/warps");var oe=require("@vleap/warps");var f=require("@multiversx/sdk-core"),I=require("@vleap/warps");var L=require("@multiversx/sdk-core"),w=require("@vleap/warps");var n=require("@multiversx/sdk-core"),x=require("@vleap/warps");var $=o=>!o.includes("-"),Z=o=>$(o)?`${o}-000000`:o;var fe=new RegExp(`${x.WarpConstants.ArgParamsSeparator}(.*)`),k=class{constructor(){this.coreSerializer=new x.WarpSerializer}typedToString(e){let t=e.getType();if(t.hasExactClass(n.OptionType.ClassName)||e.hasClassOrSuperclass(n.OptionValue.ClassName))return e.isSet()?`option:${this.typedToString(e.getTypedValue())}`:"option:null";if(t.hasExactClass(n.OptionalType.ClassName)||e.hasClassOrSuperclass(n.OptionalValue.ClassName))return e.isSet()?`optional:${this.typedToString(e.getTypedValue())}`:"optional:null";if(t.hasExactClass(n.ListType.ClassName)||e.hasClassOrSuperclass(n.List.ClassName)){let r=e.getItems(),s=r.map(i=>this.typedToString(i).split(x.WarpConstants.ArgParamsSeparator)[0])[0],c=r.map(i=>this.typedToString(i).split(x.WarpConstants.ArgParamsSeparator)[1]);return`list:${s}:${c.join(",")}`}if(t.hasExactClass(n.VariadicType.ClassName)||e.hasClassOrSuperclass(n.VariadicValue.ClassName)){let r=e.getItems(),s=r.map(i=>this.typedToString(i).split(x.WarpConstants.ArgParamsSeparator)[0])[0],c=r.map(i=>this.typedToString(i).split(x.WarpConstants.ArgParamsSeparator)[1]);return`variadic:${s}:${c.join(",")}`}if(t.hasExactClass(n.CompositeType.ClassName)||e.hasClassOrSuperclass(n.CompositeValue.ClassName)){let r=e.getItems(),a=r.map(u=>this.typedToString(u).split(x.WarpConstants.ArgParamsSeparator)[0]),s=r.map(u=>this.typedToString(u).split(x.WarpConstants.ArgParamsSeparator)[1]),c=a.join(x.WarpConstants.ArgCompositeSeparator),i=s.join(x.WarpConstants.ArgCompositeSeparator);return`composite(${c}):${i}`}if(t.hasExactClass(n.BigUIntType.ClassName)||e.hasClassOrSuperclass(n.BigUIntValue.ClassName)||t.getName()==="BigUint")return`biguint:${BigInt(e.valueOf().toFixed())}`;if(t.hasExactClass(n.U8Type.ClassName)||e.hasClassOrSuperclass(n.U8Value.ClassName))return`uint8:${e.valueOf().toNumber()}`;if(t.hasExactClass(n.U16Type.ClassName)||e.hasClassOrSuperclass(n.U16Value.ClassName))return`uint16:${e.valueOf().toNumber()}`;if(t.hasExactClass(n.U32Type.ClassName)||e.hasClassOrSuperclass(n.U32Value.ClassName))return`uint32:${e.valueOf().toNumber()}`;if(t.hasExactClass(n.U64Type.ClassName)||e.hasClassOrSuperclass(n.U64Value.ClassName))return`uint64:${BigInt(e.valueOf().toFixed())}`;if(t.hasExactClass(n.StringType.ClassName)||e.hasClassOrSuperclass(n.StringValue.ClassName))return`string:${e.valueOf()}`;if(t.hasExactClass(n.BooleanType.ClassName)||e.hasClassOrSuperclass(n.BooleanValue.ClassName))return`bool:${e.valueOf()}`;if(t.hasExactClass(n.AddressType.ClassName)||e.hasClassOrSuperclass(n.AddressValue.ClassName))return`address:${e.valueOf().toBech32()}`;if(t.hasExactClass(n.TokenIdentifierType.ClassName)||e.hasClassOrSuperclass(n.TokenIdentifierValue.ClassName))return`token:${e.valueOf()}`;if(t.hasExactClass(n.BytesType.ClassName)||e.hasClassOrSuperclass(n.BytesValue.ClassName))return`hex:${e.valueOf().toString("hex")}`;if(t.hasExactClass(n.CodeMetadataType.ClassName)||e.hasClassOrSuperclass(n.CodeMetadataValue.ClassName))return`codemeta:${e.valueOf().toString()}`;if(t.getName()==="EsdtTokenPayment"){let r=e.getFieldValue("token_identifier").valueOf(),a=e.getFieldValue("token_nonce").valueOf(),s=e.getFieldValue("amount").valueOf();return`asset:${new n.TokenComputer().computeExtendedIdentifier(new n.Token({identifier:r,nonce:BigInt(a)}))}|${s}`}throw new Error(`WarpArgSerializer (typedToString): Unsupported input type: ${e.getClassName()}`)}typedToNative(e){let t=this.typedToString(e);return this.coreSerializer.stringToNative(t)}nativeToTyped(e,t){let r=this.coreSerializer.nativeToString(e,t);return this.stringToTyped(r)}nativeToType(e){if(e.startsWith("composite")){let t=e.match(/\(([^)]+)\)/)?.[1];return new n.CompositeType(...t.split(x.WarpConstants.ArgCompositeSeparator).map(r=>this.nativeToType(r)))}if(e==="string")return new n.StringType;if(e==="uint8")return new n.U8Type;if(e==="uint16")return new n.U16Type;if(e==="uint32")return new n.U32Type;if(e==="uint64")return new n.U64Type;if(e==="biguint")return new n.BigUIntType;if(e==="bool")return new n.BooleanType;if(e==="address")return new n.AddressType;if(e==="token")return new n.TokenIdentifierType;if(e==="hex")return new n.BytesType;if(e==="codemeta")return new n.CodeMetadataType;if(e==="asset")return new n.StructType("EsdtTokenPayment",[new n.FieldDefinition("token_identifier","",new n.TokenIdentifierType),new n.FieldDefinition("token_nonce","",new n.U64Type),new n.FieldDefinition("amount","",new n.BigUIntType)]);throw new Error(`WarpArgSerializer (nativeToType): Unsupported input type: ${e}`)}stringToTyped(e){let[t,r]=e.split(/:(.*)/,2);if(t==="null"||t===null)return new n.NothingValue;if(t==="option"){let a=this.stringToTyped(r);return a instanceof n.NothingValue?n.OptionValue.newMissingTyped(a.getType()):n.OptionValue.newProvided(a)}if(t==="optional"){let a=this.stringToTyped(r);return a instanceof n.NothingValue?n.OptionalValue.newMissing():new n.OptionalValue(a.getType(),a)}if(t==="list"){let[a,s]=r.split(fe,2),i=s.split(",").map(u=>this.stringToTyped(`${a}:${u}`));return new n.List(this.nativeToType(a),i)}if(t==="variadic"){let[a,s]=r.split(fe,2),i=s.split(",").map(u=>this.stringToTyped(`${a}:${u}`));return new n.VariadicValue(new n.VariadicType(this.nativeToType(a)),i)}if(t.startsWith("composite")){let a=t.match(/\(([^)]+)\)/)?.[1],s=r.split(x.WarpConstants.ArgCompositeSeparator),c=a.split(x.WarpConstants.ArgCompositeSeparator),i=s.map((m,h)=>this.stringToTyped(`${c[h]}:${m}`)),u=i.map(m=>m.getType());return new n.CompositeValue(new n.CompositeType(...u),i)}if(t==="string")return r?n.StringValue.fromUTF8(r):new n.NothingValue;if(t==="uint8")return r?new n.U8Value(Number(r)):new n.NothingValue;if(t==="uint16")return r?new n.U16Value(Number(r)):new n.NothingValue;if(t==="uint32")return r?new n.U32Value(Number(r)):new n.NothingValue;if(t==="uint64")return r?new n.U64Value(BigInt(r)):new n.NothingValue;if(t==="biguint")return r?new n.BigUIntValue(BigInt(r)):new n.NothingValue;if(t==="bool")return r?new n.BooleanValue(typeof r=="boolean"?r:r==="true"):new n.NothingValue;if(t==="address")return r?new n.AddressValue(n.Address.newFromBech32(r)):new n.NothingValue;if(t==="token")return r?new n.TokenIdentifierValue(r):new n.NothingValue;if(t==="hex")return r?n.BytesValue.fromHex(r):new n.NothingValue;if(t==="codemeta")return new n.CodeMetadataValue(n.CodeMetadata.newFromBytes(Uint8Array.from(Buffer.from(r,"hex"))));if(t==="asset"){let[a,s]=r.split(x.WarpConstants.ArgCompositeSeparator),c=new n.TokenComputer,i=$(a)?Z(a):c.extractIdentifierFromExtendedIdentifier(a),u=$(a)?0n:c.extractNonceFromExtendedIdentifier(a);return new n.Struct(this.nativeToType("asset"),[new n.Field(new n.TokenIdentifierValue(i),"token_identifier"),new n.Field(new n.U64Value(BigInt(u)),"token_nonce"),new n.Field(new n.BigUIntValue(BigInt(s)),"amount")])}throw new Error(`WarpArgSerializer (stringToTyped): Unsupported input type: ${t}`)}typeToString(e){if(e.hasExactClass(n.OptionType.ClassName))return"option:"+this.typeToString(e.getFirstTypeParameter());if(e.hasExactClass(n.OptionalType.ClassName))return"optional:"+this.typeToString(e.getFirstTypeParameter());if(e.hasExactClass(n.ListType.ClassName))return"list:"+this.typeToString(e.getFirstTypeParameter());if(e.hasExactClass(n.VariadicType.ClassName))return"variadic:"+this.typeToString(e.getFirstTypeParameter());if(e.hasExactClass(n.StringType.ClassName))return"string";if(e.hasExactClass(n.U8Type.ClassName))return"uint8";if(e.hasExactClass(n.U16Type.ClassName))return"uint16";if(e.hasExactClass(n.U32Type.ClassName))return"uint32";if(e.hasExactClass(n.U64Type.ClassName))return"uint64";if(e.hasExactClass(n.BigUIntType.ClassName))return"biguint";if(e.hasExactClass(n.BooleanType.ClassName))return"bool";if(e.hasExactClass(n.AddressType.ClassName))return"address";if(e.hasExactClass(n.TokenIdentifierType.ClassName))return"token";if(e.hasExactClass(n.BytesType.ClassName))return"hex";if(e.hasExactClass(n.CodeMetadataType.ClassName))return"codemeta";if(e.hasExactClass(n.StructType.ClassName)&&e.getClassName()==="EsdtTokenPayment")return"asset";throw new Error(`WarpArgSerializer (typeToString): Unsupported input type: ${e.getClassName()}`)}};var _=class{constructor(e,t){this.config=e;this.chain=t;this.abi=new F(e,t),this.serializer=new k,this.cache=new w.WarpCache(e.cache?.type)}async getTransactionExecutionResults(e,t){let{actionIndex:r}=(0,w.findWarpExecutableAction)(e),a=this.cache.get(w.WarpCacheKey.WarpExecutable(this.config.env,e.meta?.hash||"",r))??[],s=await this.extractContractResults(e,t,a),c=(0,w.getNextInfo)(this.config,[],e,r,s),i=(0,w.applyResultsToMessages)(e,s.results);return{success:t.status.isSuccessful(),warp:e,action:r,user:this.config.user?.wallets?.[this.chain.name]||null,txHash:t.hash,tx:t,next:c,values:s.values,valuesRaw:[],results:s.results,messages:i}}async extractContractResults(e,t,r){let{action:a,actionIndex:s}=(0,w.findWarpExecutableAction)(e),c=[],i={};if(!e.results||a.type!=="contract")return{values:c,results:i};if(!Object.values(e.results).some(T=>T.includes("out")||T.includes("event"))){for(let[T,g]of Object.entries(e.results))i[T]=g;return{values:c,results:await(0,w.evaluateResultsCommon)(e,i,s,r,this.config.transform?.runner)}}let m=await this.abi.getAbiForAction(a),h=new L.TransactionEventsParser({abi:m}),v=new L.SmartContractTransactionsOutcomeParser({abi:m}).parseExecute({transactionOnNetwork:t,function:a.func||void 0});for(let[T,g]of Object.entries(e.results)){if(g.startsWith(w.WarpConstants.Transform.Prefix))continue;if(g.startsWith("input.")){i[T]=g;continue}let A=(0,w.parseResultsOutIndex)(g);if(A!==null&&A!==s){i[T]=null;continue}let[b,E,R]=g.split(".");if(b==="event"){if(!E||isNaN(Number(R)))continue;let B=Number(R),C=(0,L.findEventsByFirstTopic)(t,E),z=h.parseEvents({events:C})[0],Y=Object.values(z)[B]||null;c.push(Y),i[T]=Y&&Y.valueOf()}else if(b==="out"||b.startsWith("out[")){if(!E)continue;let B=Number(E),C=v.values[B-1]||null;R&&(C=C[R]||null),C&&typeof C=="object"&&(C="toFixed"in C?C.toFixed():C.valueOf()),c.push(C),i[T]=C&&C.valueOf()}else i[T]=g}return{values:c,results:await(0,w.evaluateResultsCommon)(e,i,s,r)}}async extractQueryResults(e,t,r,a){let s=t.map(m=>this.serializer.typedToString(m)),c=t.map(m=>this.serializer.typedToNative(m)[1]),i={};if(!e.results)return{values:s,valuesRaw:c,results:i};let u=m=>{let h=m.split(".").slice(1).map(v=>parseInt(v)-1);if(h.length===0)return;let d=c[h[0]];for(let v=1;v<h.length;v++){if(d==null)return;d=d[h[v]]}return d};for(let[m,h]of Object.entries(e.results)){if(h.startsWith(w.WarpConstants.Transform.Prefix))continue;let d=(0,w.parseResultsOutIndex)(h);if(d!==null&&d!==r){i[m]=null;continue}h.startsWith("out.")||h==="out"||h.startsWith("out[")?i[m]=u(h)||null:i[m]=h}return{values:s,valuesRaw:c,results:await(0,w.evaluateResultsCommon)(e,i,r,a)}}async resolveWarpResultsRecursively(e){let t=e.warp,r=e.entryActionIndex,a=e.executor,s=e.inputs,c=e.meta,i=new Map,u=new Set,m=this;async function h(g,A=[]){if(i.has(g))return i.get(g);if(u.has(g))throw new Error(`Circular dependency detected at action ${g}`);u.add(g);let b=t.actions[g-1];if(!b)throw new Error(`Action ${g} not found`);let E;if(b.type==="query")E=await a.executeQuery(t,g,A);else if(b.type==="collect")E=await a.executeCollect(t,g,A,c);else throw new Error(`Unsupported or interactive action type: ${b.type}`);if(i.set(g,E),t.results)for(let R of Object.values(t.results)){let C=String(R).match(/^out\[(\d+)\]/);if(C){let z=parseInt(C[1],10);z!==g&&!i.has(z)&&await h(z)}}return u.delete(g),E}await h(r,s);let d={};for(let g of i.values())for(let[A,b]of Object.entries(g.results))b!==null?d[A]=b:A in d||(d[A]=null);let v=await(0,w.evaluateResultsCommon)(t,d,r,s,this.config.transform?.runner);return{...i.get(r),action:r,results:v}}};var Ne="EGLD-000000",y=class o{constructor(e,t){this.config=e;this.chain=t;this.serializer=new k,this.abi=new F(this.config,this.chain),this.results=new _(this.config,this.chain)}async createTransaction(e){let t=(0,I.getWarpActionByIndex)(e.warp,e.action),r=null;if(t.type==="transfer")r=await this.createTransferTransaction(e);else if(t.type==="contract")r=await this.createContractCallTransaction(e);else{if(t.type==="query")throw new Error("WarpMultiversxExecutor: Invalid action type for createTransactionForExecute; Use executeQuery instead");if(t.type==="collect")throw new Error("WarpMultiversxExecutor: Invalid action type for createTransactionForExecute; Use executeCollect instead")}if(!r)throw new Error(`WarpMultiversxExecutor: Invalid action type (${t.type})`);return r}async createTransferTransaction(e){let t=this.config.user?.wallets?.[e.chain.name];if(!t)throw new Error("WarpMultiversxExecutor: createTransfer - user address not set");let r=f.Address.newFromBech32(t),a=new f.TransactionsFactoryConfig({chainID:e.chain.chainId}),s=e.data?Buffer.from(this.serializer.stringToTyped(e.data).valueOf()):null;return new f.TransferTransactionsFactory({config:a}).createTransactionForTransfer(r,{receiver:f.Address.newFromBech32(e.destination),nativeAmount:e.value,tokenTransfers:this.toTokenTransfers(e.transfers),data:s?new Uint8Array(s):void 0})}async createContractCallTransaction(e){let t=this.config.user?.wallets?.[e.chain.name];if(!t)throw new Error("WarpMultiversxExecutor: createContractCall - user address not set");let r=(0,I.getWarpActionByIndex)(e.warp,e.action),a=f.Address.newFromBech32(t),s=e.args.map(i=>this.serializer.stringToTyped(i)),c=new f.TransactionsFactoryConfig({chainID:e.chain.chainId});return new f.SmartContractTransactionsFactory({config:c}).createTransactionForExecute(a,{contract:f.Address.newFromBech32(e.destination),function:"func"in r&&r.func||"",gasLimit:"gasLimit"in r?BigInt(r.gasLimit||0):0n,arguments:s,tokenTransfers:this.toTokenTransfers(e.transfers),nativeTransferAmount:e.value})}async executeQuery(e){let t=(0,I.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)),s=o.getChainEntrypoint(e.chain,this.config.env,this.config),c=f.Address.newFromBech32(e.destination),i=s.createSmartContractController(r),u=i.createQuery({contract:c,function:t.func||"",arguments:a}),m=await i.runQuery(u),h=m.returnCode==="ok",d=new f.ArgSerializer,v=r.getEndpoint(m.function||t.func||""),T=(m.returnDataParts||[]).map(B=>Buffer.from(B)),g=d.buffersToValues(T,v.output),{values:A,valuesRaw:b,results:E}=await this.results.extractQueryResults(e.warp,g,e.action,e.resolvedInputs),R=(0,I.getNextInfo)(this.config,[],e.warp,e.action,E);return{success:h,warp:e.warp,action:e.action,user:this.config.user?.wallets?.[e.chain.name]||null,txHash:null,tx:null,next:R,values:A,valuesRaw:b,results:E,messages:(0,I.applyResultsToMessages)(e.warp,E)}}static getChainEntrypoint(e,t,r){let a="warp-sdk",c=r?(0,I.getProviderUrl)(r,e.name,t,e.defaultApiUrl):e.defaultApiUrl;return t==="devnet"?new f.DevnetEntrypoint({url:c,kind:"api",clientName:a}):t==="testnet"?new f.TestnetEntrypoint({url:c,kind:"api",clientName:a}):new f.MainnetEntrypoint({url:c,kind:"api",clientName:a})}async signMessage(e,t){let r=f.UserSecretKey.fromString(t);return(await new f.UserSigner(r).sign(new Uint8Array(Buffer.from(e,"utf-8")))).toString()}toTokenTransfers(e){return e.map(t=>t.identifier===this.chain.nativeToken.identifier?{...t,identifier:Ne}:t).map(t=>{let a=new f.TokenComputer().extractNonceFromExtendedIdentifier(t.identifier);return new f.TokenTransfer({token:new f.Token({identifier:t.identifier,nonce:BigInt(a||0)}),amount:t.amount})})}};var H=class{constructor(e){this.config=e}async getContract(e,t){try{let s=await y.getChainEntrypoint(t,this.config.env).createNetworkProvider().doGetGeneric(`accounts/${e}`);return{address:e,owner:s.ownerAddress,verified:s.isVerified||!1}}catch(r){return oe.WarpLogger.error("WarpContractLoader: getContract error",r),null}}async getVerificationInfo(e,t){try{let s=await y.getChainEntrypoint(t,this.config.env).createNetworkProvider().doGetGeneric(`accounts/${e}/verification`);return{codeHash:s.codeHash,abi:s.source.abi}}catch(r){return oe.WarpLogger.error("WarpContractLoader: getVerificationInfo error",r),null}}};var F=class{constructor(e,t){this.config=e;this.chain=t;this.contractLoader=new H(this.config),this.cache=new N.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=N.WarpCacheKey.WarpAbi(this.config.env,e);if(t){let c=this.cache.get(r);if(c)return N.WarpLogger.info(`WarpAbiBuilder (createFromTransactionHash): Warp abi found in cache: ${e}`),c}let s=y.getChainEntrypoint(this.chain,this.config.env).createNetworkProvider();try{let c=await s.getTransaction(e),i=await this.createFromTransaction(c);return t&&t.ttl&&i&&this.cache.set(r,i,t.ttl),i}catch(c){return N.WarpLogger.error("WarpAbiBuilder: Error creating from transaction hash",c),null}}async getAbiForAction(e){if(e.abi)return await this.fetchAbi(e);if(!e.address)throw new Error("WarpActionExecutor: Address not found");let t=await this.contractLoader.getVerificationInfo(e.address,this.chain);if(!t)throw new Error("WarpActionExecutor: Verification info not found");return ee.AbiRegistry.create(t.abi)}async fetchAbi(e){if(!e.abi)throw new Error("WarpActionExecutor: ABI not found");if(e.abi.startsWith(N.WarpConstants.IdentifierType.Hash)){let t=e.abi.split(N.WarpConstants.IdentifierParamSeparatorDefault)[1],r=await this.createFromTransactionHash(t);if(!r)throw new Error(`WarpActionExecutor: ABI not found for hash: ${e.abi}`);return ee.AbiRegistry.create(r.content)}else{let r=await(await fetch(e.abi)).json();return ee.AbiRegistry.create(r)}}};var O=require("@multiversx/sdk-core"),te=require("@vleap/warps"),ge=require("buffer");var G=class{constructor(e,t){this.config=e;this.chain=t;this.core=new te.WarpBrandBuilder(e)}async createInscriptionTransaction(e){let t=this.config.user?.wallets?.[this.chain.name];if(!t)throw new Error("BrandBuilder: user address not set");let r=new O.TransactionsFactoryConfig({chainID:this.chain.chainId}),a=new O.TransferTransactionsFactory({config:r}),s=O.Address.newFromBech32(t),c=JSON.stringify(e);return await a.createTransactionForNativeTokenTransfer(s,{receiver:O.Address.newFromBech32(t),nativeAmount:BigInt(0),data:Uint8Array.from(ge.Buffer.from(c))})}async createFromTransaction(e,t=!1){return await this.core.createFromRaw(e.data.toString(),t)}async createFromTransactionHash(e){let r=y.getChainEntrypoint(this.chain,this.config.env).createNetworkProvider();try{let a=await r.getTransaction(e);return this.createFromTransaction(a)}catch(a){return te.WarpLogger.error("BrandBuilder: Error creating from transaction hash",a),null}}};var M=require("@multiversx/sdk-core"),V=require("@vleap/warps");var Q=class extends V.WarpBuilder{constructor(t,r){super(t);this.config=t;this.chain=r;this.cache=new V.WarpCache(t.cache?.type),this.core=new V.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 M.TransactionsFactoryConfig({chainID:this.chain.chainId}),s=new M.TransferTransactionsFactory({config:a}),c=M.Address.newFromBech32(r),i=JSON.stringify(t),u=await s.createTransactionForTransfer(c,{receiver:M.Address.newFromBech32(r),nativeAmount:BigInt(0),data:Uint8Array.from(Buffer.from(i))});return u.gasLimit=u.gasLimit+BigInt(2e6),u}async createFromTransaction(t,r=!1){let a=await this.core.createFromRaw(t.data.toString(),r);return a.meta={chain:this.chain.name,hash:t.hash,creator:t.sender.toBech32(),createdAt:new Date(t.timestamp*1e3).toISOString()},a}async createFromTransactionHash(t,r){let a=V.WarpCacheKey.Warp(this.config.env,t);if(r){let i=this.cache.get(a);if(i)return V.WarpLogger.info(`WarpBuilder (createFromTransactionHash): Warp found in cache: ${t}`),i}let c=y.getChainEntrypoint(this.chain,this.config.env).createNetworkProvider();try{let i=await c.getTransaction(t),u=await this.createFromTransaction(i);return r&&r.ttl&&u&&this.cache.set(a,u,r.ttl),u}catch(i){return V.WarpLogger.error("WarpBuilder: Error creating from transaction hash",i),null}}};var U=require("@multiversx/sdk-core"),D=require("@vleap/warps");var ye=require("@vleap/warps"),re=ye.WarpChainName.Multiversx,we=[{chain:re,identifier:"EGLD",name:"eGold",symbol:"EGLD",decimals:18,logoUrl:"https://tools.multiversx.com/assets-cdn/tokens/EGLD-000000/icon.pngsvg"},{chain:re,identifier:"EGLD-000000",name:"eGold",symbol:"EGLD",decimals:18,logoUrl:"https://tools.multiversx.com/assets-cdn/tokens/EGLD-000000/icon.png"},{chain:re,identifier:"VIBE",name:"VIBE",symbol:"VIBE",decimals:18,logoUrl:"https://vleap.ai/images/tokens/vibe.svg"},{chain:re,identifier:"VIBE-000000",name:"VIBE",symbol:"VIBE",decimals:18,logoUrl:"https://vleap.ai/images/tokens/vibe.svg"}],ce=o=>we.find(e=>e.identifier===o)||null;var j=class{constructor(e,t){this.config=e;this.chain=t;this.cache=new D.WarpCache(e.cache?.type)}async getAccount(e){let r=await y.getChainEntrypoint(this.chain,this.config.env,this.config).createNetworkProvider().getAccount(U.Address.newFromBech32(e));return{chain:this.chain.name,address:r.address.toBech32(),balance:r.balance}}async getAccountAssets(e){let t=y.getChainEntrypoint(this.chain,this.config.env,this.config).createNetworkProvider(),r=t.getAccount(U.Address.newFromBech32(e)),a=t.getFungibleTokensOfAccount(U.Address.newFromBech32(e)),[s,c]=await Promise.all([r,a]),i=s.balance>0?[{...this.chain.nativeToken,amount:s.balance}]:[];return i.push(...c.map(u=>({chain:this.chain.name,identifier:u.token.identifier,name:u.raw.name,symbol:u.raw.ticker,amount:u.amount,decimals:u.raw.decimals,logoUrl:u.raw.assets?.pngUrl||""}))),i}async getAsset(e){let t=D.WarpCacheKey.Asset(this.config.env,this.chain.name,e),r=this.cache.get(t);if(r)return r;let a=ce(e);if(a)return{chain:this.chain.name,identifier:e,name:a.name,symbol:a.symbol,amount:0n,decimals:a.decimals,logoUrl:a.logoUrl};let s=new U.TokenComputer,c=$(e)?0n:s.extractNonceFromExtendedIdentifier(e),i=new U.Token({identifier:e,nonce:BigInt(c||0)}),u=s.isFungible(i),m=y.getChainEntrypoint(this.chain,this.config.env,this.config).createNetworkProvider(),h=Z(e),d=await m.doGetGeneric(`tokens/${h}`),v={chain:this.chain.name,identifier:i.identifier,name:d.name,symbol:d.ticker,amount:0n,decimals:d.decimals,logoUrl:d.assets?.pngUrl||"#"};return this.cache.set(t,v,D.CacheTtl.OneHour),v}async getAction(e,t=!1){let r=y.getChainEntrypoint(this.chain,this.config.env,this.config),a=t?await r.awaitCompletedTransaction(e):await r.getTransaction(e);return{chain:this.chain.name,id:a.hash,receiver:a.receiver.toBech32(),sender:a.sender.toBech32(),value:a.value,function:a.function,status:this.toActionStatus(a),createdAt:this.toActionCreatedAt(a),error:a?.smartContractResults.map(s=>s.raw.returnMessage)[0]||null,tx:a}}async getAccountActions(e,t){let r=y.getChainEntrypoint(this.chain,this.config.env,this.config).createNetworkProvider(),a=`accounts/${e}/transactions`,s=new URLSearchParams,c=t?.size||25,i=t?.page||0;if(i>0){let m=i*c;s.append("from",m.toString())}return c!==25&&s.append("size",c.toString()),s.toString()&&(a+=`?${s.toString()}`),(await r.doGetGeneric(a)).map(m=>({chain:this.chain.name,id:m.txHash,receiver:m.receiver,sender:m.sender,value:m.value,function:m.function,status:this.toActionStatus(m),createdAt:this.toActionCreatedAt(m)}))}toActionStatus(e){return e.status.isSuccessful()?"success":e.status.isFailed()?"failed":"pending"}toActionCreatedAt(e){return new Date(e.timestamp||e.timestamp*1e3).toISOString()}};var Ve={Egld:{Identifier:"EGLD",EsdtIdentifier:"EGLD-000000",DisplayName:"eGold",Decimals:18}},Ce=(r=>(r.MultiversxExplorer="multiversx_explorer",r.MultiversxExplorerDevnet="multiversx_explorer_devnet",r.MultiversxExplorerTestnet="multiversx_explorer_testnet",r))(Ce||{}),xe=(r=>(r.VibechainExplorer="vibechain_explorer",r.VibechainExplorerDevnet="vibechain_explorer_devnet",r.VibechainExplorerTestnet="vibechain_explorer_testnet",r))(xe||{}),pe={multiversx:{mainnet:["multiversx_explorer"],testnet:["multiversx_explorer_testnet"],devnet:["multiversx_explorer_devnet"]},vibechain:{mainnet:["vibechain_explorer"],testnet:["vibechain_explorer_testnet"],devnet:["vibechain_explorer_devnet"]}},P={multiversx_explorer:"https://explorer.multiversx.com",multiversx_explorer_devnet:"https://devnet-explorer.multiversx.com",multiversx_explorer_testnet:"https://testnet-explorer.multiversx.com",vibechain_explorer:"https://vibeox-explorer.multiversx.com",vibechain_explorer_devnet:"https://vibeox-explorer.multiversx.com",vibechain_explorer_testnet:"https://vibeox-explorer.multiversx.com"};var K=class{constructor(e,t){this.chain=e;this.config=t}getExplorers(){let e=pe[this.chain];if(!e)return["multiversx_explorer"];let t=e[this.config.env];return t||["multiversx_explorer"]}getPrimaryExplorer(){return this.getExplorers()[0]}getExplorerUrlByName(e){let t=this.config.preferences?.explorers?.[this.chain];if(t&&!e){let s=P[t];if(s)return s}if(e){let s=P[e];if(s)return s}let r=this.getPrimaryExplorer();return P[r]||P[r]}getAccountUrl(e,t){return`${this.getExplorerUrlByName(t)}/accounts/${e}`}getTransactionUrl(e,t){return`${this.getExplorerUrlByName(t)}/transactions/${e}`}getBlockUrl(e,t){return`${this.getExplorerUrlByName(t)}/blocks/${e}`}getAssetUrl(e,t){return`${this.getExplorerUrlByName(t)}/tokens/${e}`}getContractUrl(e,t){return`${this.getExplorerUrlByName(t)}/accounts/${e}`}getAllExplorers(){return this.getExplorers()}getExplorerByName(e){return this.getExplorers().find(r=>r.toLowerCase()===e.toLowerCase())}getAccountUrls(e){let t=this.getAllExplorers(),r={};return t.forEach(a=>{let s=P[a];s&&(r[a]=`${s}/accounts/${e}`)}),r}getTransactionUrls(e){let t=this.getAllExplorers(),r={};return t.forEach(a=>{let s=P[a];s&&(r[a]=`${s}/transactions/${e}`)}),r}};var l=require("@multiversx/sdk-core"),S=require("@vleap/warps");var le={buildInfo:{rustc:{version:"1.86.0",commitHash:"05f9846f893b09a1be1fc8560e33fc3c815cfecb",commitDate:"2025-03-31",channel:"Stable",short:"rustc 1.86.0 (05f9846f8 2025-03-31)"},contractCrate:{name:"registry",version:"0.0.1"},framework:{name:"multiversx-sc",version:"0.51.1"}},name:"RegistryContract",constructor:{inputs:[{name:"unit_price",type:"BigUint"},{name:"vault",type:"Address"}],outputs:[]},upgradeConstructor:{inputs:[],outputs:[]},endpoints:[{name:"registerWarp",mutability:"mutable",payableInTokens:["EGLD"],inputs:[{name:"hash",type:"bytes"},{name:"alias_opt",type:"optional<bytes>",multi_arg:!0},{name:"brand_opt",type:"optional<bytes>",multi_arg:!0}],outputs:[],allow_multiple_var_args:!0},{name:"unregisterWarp",mutability:"mutable",inputs:[{name:"warp",type:"bytes"}],outputs:[]},{name:"upgradeWarp",mutability:"mutable",payableInTokens:["EGLD"],inputs:[{name:"alias",type:"bytes"},{name:"new_warp",type:"bytes"}],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 W=o=>{if(o==="devnet")return"erd1qqqqqqqqqqqqqpgqje2f99vr6r7sk54thg03c9suzcvwr4nfl3tsfkdl36";if(o==="testnet")throw new Error("Multiversx testnet is not supported");return"erd1qqqqqqqqqqqqqpgq3mrpj3u6q7tejv6d7eqhnyd27n9v5c5tl3ts08mffe"};var ne=o=>({hash:o.hash.toString("hex"),alias:o.alias?.toString()||null,trust:o.trust.toString(),owner:o.owner.toString(),createdAt:o.created_at.toNumber(),upgradedAt:o.upgraded_at?.toNumber(),brand:o.brand?.toString("hex")||null,upgrade:o.upgrade?.toString("hex")||null}),We=o=>({unitPrice:BigInt(o.unit_price.toString()),admins:o.admins.map(e=>e.toBech32())});var J=class{constructor(e,t){this.config=e;this.chain=t;this.cache=new S.WarpCache(e.cache?.type),this.registryConfig={unitPrice:BigInt(0),admins:[]},this.userWallet=this.config.user?.wallets?.[this.chain.name]||null}async init(){await this.loadRegistryConfigs()}getRegistryConfig(){return this.registryConfig}async createWarpRegisterTransaction(e,t,r){if(this.registryConfig.unitPrice===BigInt(0))throw new Error("WarpRegistry: config not loaded. forgot to call init()?");if(!this.userWallet)throw new Error("WarpRegistry: user address not set");let a=l.Address.newFromBech32(this.userWallet),s=()=>this.isCurrentUserAdmin()?BigInt(0):t&&r?this.registryConfig.unitPrice*BigInt(3):t?this.registryConfig.unitPrice*BigInt(2):this.registryConfig.unitPrice,c=()=>t&&r?[l.BytesValue.fromHex(e),l.BytesValue.fromUTF8(t),l.BytesValue.fromHex(r)]:t?[l.BytesValue.fromHex(e),l.BytesValue.fromUTF8(t)]:[l.BytesValue.fromHex(e)];return await this.getFactory().createTransactionForExecute(a,{contract:l.Address.newFromBech32(W(this.config.env)),function:"registerWarp",gasLimit:BigInt(1e7),nativeTransferAmount:s(),arguments:c()})}async createWarpUnregisterTransaction(e){if(!this.userWallet)throw new Error("WarpRegistry: user address not set");let t=l.Address.newFromBech32(this.userWallet);return await this.getFactory().createTransactionForExecute(t,{contract:l.Address.newFromBech32(W(this.config.env)),function:"unregisterWarp",gasLimit:BigInt(1e7),arguments:[l.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=l.Address.newFromBech32(this.userWallet);return await this.getFactory().createTransactionForExecute(r,{contract:l.Address.newFromBech32(W(this.config.env)),function:"upgradeWarp",gasLimit:BigInt(1e7),nativeTransferAmount:this.isCurrentUserAdmin()?void 0:this.registryConfig.unitPrice,arguments:[l.BytesValue.fromUTF8(e),l.BytesValue.fromHex(t)]})}async createWarpAliasSetTransaction(e,t){if(!this.userWallet)throw new Error("WarpRegistry: user address not set");let r=l.Address.newFromBech32(this.userWallet);return await this.getFactory().createTransactionForExecute(r,{contract:l.Address.newFromBech32(W(this.config.env)),function:"setWarpAlias",gasLimit:BigInt(1e7),nativeTransferAmount:this.isCurrentUserAdmin()?void 0:this.registryConfig.unitPrice,arguments:[l.BytesValue.fromHex(e),l.BytesValue.fromUTF8(t)]})}async createWarpVerifyTransaction(e){if(!this.userWallet)throw new Error("WarpRegistry: user address not set");let t=l.Address.newFromBech32(this.userWallet);return await this.getFactory().createTransactionForExecute(t,{contract:l.Address.newFromBech32(W(this.config.env)),function:"verifyWarp",gasLimit:BigInt(1e7),arguments:[l.BytesValue.fromHex(e)]})}async createWarpTransferOwnershipTransaction(e,t){if(!this.userWallet)throw new Error("WarpRegistry: user address not set");let r=l.Address.newFromBech32(this.userWallet);return await this.getFactory().createTransactionForExecute(r,{contract:l.Address.newFromBech32(W(this.config.env)),function:"transferOwnership",gasLimit:BigInt(1e7),arguments:[l.BytesValue.fromHex(e),new l.AddressValue(new l.Address(t))]})}async createBrandRegisterTransaction(e){if(this.registryConfig.unitPrice===BigInt(0))throw new Error("WarpRegistry: config not loaded. forgot to call init()?");if(!this.userWallet)throw new Error("WarpRegistry: user address not set");let t=l.Address.newFromBech32(this.userWallet);return await this.getFactory().createTransactionForExecute(t,{contract:l.Address.newFromBech32(W(this.config.env)),function:"registerBrand",gasLimit:BigInt(1e7),nativeTransferAmount:this.isCurrentUserAdmin()?void 0:this.registryConfig.unitPrice,arguments:[l.BytesValue.fromHex(e)]})}async createWarpBrandingTransaction(e,t){if(!this.userWallet)throw new Error("WarpRegistry: user address not set");let r=l.Address.newFromBech32(this.userWallet);return await this.getFactory().createTransactionForExecute(r,{contract:l.Address.newFromBech32(W(this.config.env)),function:"brandWarp",gasLimit:BigInt(1e7),nativeTransferAmount:this.isCurrentUserAdmin()?void 0:this.registryConfig.unitPrice,arguments:[l.BytesValue.fromHex(e),l.BytesValue.fromHex(t)]})}async getInfoByAlias(e,t){try{let r=S.WarpCacheKey.RegistryInfo(this.config.env,e),a=t?this.cache.get(r):null;if(a)return S.WarpLogger.info(`WarpRegistry (getInfoByAlias): RegistryInfo found in cache: ${e}`),a;let s=l.Address.newFromBech32(W(this.config.env)),c=this.getController(),i=c.createQuery({contract:s,function:"getInfoByAlias",arguments:[l.BytesValue.fromUTF8(e)]}),u=await c.runQuery(i),[m]=c.parseQueryResponse(u),h=m?ne(m):null,d=h?.brand?await this.fetchBrand(h.brand):null;return t&&t.ttl&&this.cache.set(r,{registryInfo:h,brand:d},t.ttl),{registryInfo:h,brand:d}}catch{return{registryInfo:null,brand:null}}}async getInfoByHash(e,t){try{let r=S.WarpCacheKey.RegistryInfo(this.config.env,e);if(t){let d=this.cache.get(r);if(d)return S.WarpLogger.info(`WarpRegistry (getInfoByHash): RegistryInfo found in cache: ${e}`),d}let a=l.Address.newFromBech32(W(this.config.env)),s=this.getController(),c=s.createQuery({contract:a,function:"getInfoByHash",arguments:[l.BytesValue.fromHex(e)]}),i=await s.runQuery(c),[u]=s.parseQueryResponse(i),m=u?ne(u):null,h=m?.brand?await this.fetchBrand(m.brand):null;return t&&t.ttl&&this.cache.set(r,{registryInfo:m,brand:h},t.ttl),{registryInfo:m,brand:h}}catch{return{registryInfo:null,brand:null}}}async getUserWarpRegistryInfos(e){try{let t=e||this.userWallet;if(!t)throw new Error("WarpRegistry: user address not set");let r=l.Address.newFromBech32(W(this.config.env)),a=this.getController(),s=a.createQuery({contract:r,function:"getUserWarps",arguments:[new l.AddressValue(new l.Address(t))]}),c=await a.runQuery(s),[i]=a.parseQueryResponse(c);return i.map(ne)}catch{return[]}}async getUserBrands(e){try{let t=e||this.userWallet;if(!t)throw new Error("WarpRegistry: user address not set");let r=l.Address.newFromBech32(W(this.config.env)),a=this.getController(),s=a.createQuery({contract:r,function:"getUserBrands",arguments:[new l.AddressValue(new l.Address(t))]}),c=await a.runQuery(s),[i]=a.parseQueryResponse(c),u=i.map(d=>d.toString("hex")),m={ttl:365*24*60*60};return(await Promise.all(u.map(d=>this.fetchBrand(d,m)))).filter(d=>d!==null)}catch{return[]}}async fetchBrand(e,t){let r=S.WarpCacheKey.Brand(this.config.env,e),a=t?this.cache.get(r):null;if(a)return S.WarpLogger.info(`WarpRegistry (fetchBrand): Brand found in cache: ${e}`),a;let c=y.getChainEntrypoint(this.chain,this.config.env).createNetworkProvider();try{let i=await c.getTransaction(e),u=JSON.parse(i.data.toString());return u.meta={hash:i.hash,creator:i.sender.toBech32(),createdAt:new Date(i.timestamp*1e3).toISOString()},t&&t.ttl&&this.cache.set(r,u,t.ttl),u}catch{return null}}async loadRegistryConfigs(){let e=l.Address.newFromBech32(W(this.config.env)),t=this.getController(),[r]=await t.query({contract:e,function:"getConfig",arguments:[]}),a=r?We(r):null;this.registryConfig=a||{unitPrice:BigInt(0),admins:[]}}getFactory(){let e=new l.TransactionsFactoryConfig({chainID:this.chain.chainId}),t=l.AbiRegistry.create(le);return new l.SmartContractTransactionsFactory({config:e,abi:t})}getController(){let e=y.getChainEntrypoint(this.chain,this.config.env),t=l.AbiRegistry.create(le);return e.createSmartContractController(t)}isCurrentUserAdmin(){return!!this.userWallet&&this.registryConfig.admins.includes(this.userWallet)}};var X=(o,e,t)=>(r,a)=>{let s=t[r.env];return{chain:o,chainInfo:s,prefix:e,builder:()=>new Q(r,s),executor:new y(r,s),results:new _(r,s),serializer:new k,registry:new J(r,s),explorer:new K(o,r),abiBuilder:()=>new F(r,s),brandBuilder:()=>new G(r,s),dataLoader:new j(r,s),registerTypes:c=>{c.registerType("token",{stringToNative:i=>i,nativeToString:i=>`token:${i}`}),c.registerType("codemeta",{stringToNative:i=>i,nativeToString:i=>`codemeta:${i}`})}}};var ae={chain:q.WarpChainName.Multiversx,identifier:"EGLD",name:"eGold",symbol:"EGLD",decimals:18,logoUrl:"https://vleap.ai/images/tokens/egld.svg"},ue=X(q.WarpChainName.Multiversx,"mvx",{mainnet:{name:q.WarpChainName.Multiversx,displayName:"MultiversX",chainId:"1",blockTime:6e3,addressHrp:"erd",defaultApiUrl:"https://api.multiversx.com",nativeToken:ae},testnet:{name:q.WarpChainName.Multiversx,displayName:"MultiversX Testnet",chainId:"T",blockTime:6e3,addressHrp:"erd",defaultApiUrl:"https://testnet-api.multiversx.com",nativeToken:ae},devnet:{name:q.WarpChainName.Multiversx,displayName:"MultiversX Devnet",chainId:"D",blockTime:6e3,addressHrp:"erd",defaultApiUrl:"https://devnet-api.multiversx.com",nativeToken:ae}});var se=require("@vleap/warps");var ve={chain:se.WarpChainName.Vibechain,identifier:"VIBE",name:"VIBE",symbol:"VIBE",decimals:18,logoUrl:"https://vleap.ai/images/tokens/vibe.svg"},me={name:se.WarpChainName.Vibechain,displayName:"VibeChain",chainId:"V",blockTime:600,addressHrp:"vibe",defaultApiUrl:"https://vibeox-api.multiversx.com",nativeToken:ve},de=X(se.WarpChainName.Vibechain,"vibe",{mainnet:me,testnet:me,devnet:me});var ke=(o,e)=>[ue(o,e),de(o,e)],Fe=()=>[he.WarpChainName.Multiversx,he.WarpChainName.Vibechain];var p=require("@multiversx/sdk-core"),Re=(o,e)=>o?p.OptionValue.newProvided(o):e?p.OptionValue.newMissingTyped(e):p.OptionValue.newMissing(),Ue=(o,e)=>o?new p.OptionalValue(o.getType(),o):e?new p.OptionalValue(e):p.OptionalValue.newMissing(),Pe=o=>{if(o.length===0)throw new Error("Cannot create a list from an empty array");let e=o[0].getType();return new p.List(e,o)},_e=o=>p.VariadicValue.fromItems(...o),Oe=o=>{let e=o.map(t=>t.getType());return new p.CompositeValue(new p.CompositeType(...e),o)},Me=o=>p.StringValue.fromUTF8(o),$e=o=>new p.U8Value(o),Le=o=>new p.U16Value(o),De=o=>new p.U32Value(o),qe=o=>new p.U64Value(o),ze=o=>new p.BigUIntValue(BigInt(o)),He=o=>new p.BooleanValue(o),Ge=o=>new p.AddressValue(p.Address.newFromBech32(o)),Qe=o=>new p.TokenIdentifierValue(o),je=o=>p.BytesValue.fromHex(o),Ke=o=>new p.Struct(new p.StructType("EsdtTokenPayment",[new p.FieldDefinition("token_identifier","",new p.TokenIdentifierType),new p.FieldDefinition("token_nonce","",new p.U64Type),new p.FieldDefinition("amount","",new p.BigUIntType)]),[new p.Field(new p.TokenIdentifierValue(o.token.identifier),"token_identifier"),new p.Field(new p.U64Value(BigInt(o.token.nonce)),"token_nonce"),new p.Field(new p.BigUIntValue(BigInt(o.amount)),"amount")]),Je=o=>new p.CodeMetadataValue(p.CodeMetadata.newFromBytes(Uint8Array.from(Buffer.from(o,"hex")))),Xe=()=>new p.NothingValue;0&&(module.exports={ExplorerUrls,KnownTokens,MultiversxExplorers,MultiversxExplorersConfig,NativeTokenEgld,NativeTokenVibe,VibechainExplorers,WarpMultiversxAbiBuilder,WarpMultiversxBrandBuilder,WarpMultiversxBuilder,WarpMultiversxConstants,WarpMultiversxContractLoader,WarpMultiversxDataLoader,WarpMultiversxExecutor,WarpMultiversxExplorer,WarpMultiversxRegistry,WarpMultiversxResults,WarpMultiversxSerializer,address_value,asset_value,biguint_value,boolean_value,codemeta_value,composite_value,createMultiversxAdapter,findKnownTokenById,getAllMultiversxAdapters,getAllMultiversxChainNames,getMultiversxAdapter,getMultiversxRegistryAddress,getVibechainAdapter,hex_value,list_value,nothing_value,option_value,optional_value,string_value,token_value,u16_value,u32_value,u64_value,u8_value,variadic_value});
|
|
1
|
+
"use strict";var ie=Object.defineProperty;var ve=Object.getOwnPropertyDescriptor;var be=Object.getOwnPropertyNames;var Ee=Object.prototype.hasOwnProperty;var Ae=(o,e)=>{for(var t in e)ie(o,t,{get:e[t],enumerable:!0})},Be=(o,e,t,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let a of be(e))!Ee.call(o,a)&&a!==t&&ie(o,a,{get:()=>e[a],enumerable:!(r=ve(e,a))||r.enumerable});return o};var Ie=o=>Be(ie({},"__esModule",{value:!0}),o);var Ye={};Ae(Ye,{ExplorerUrls:()=>_,KnownTokens:()=>we,MultiversxExplorers:()=>Ce,MultiversxExplorersConfig:()=>pe,NativeTokenEgld:()=>ae,NativeTokenVibe:()=>Te,VibechainExplorers:()=>xe,WarpMultiversxAbiBuilder:()=>R,WarpMultiversxBrandBuilder:()=>Q,WarpMultiversxBuilder:()=>j,WarpMultiversxConstants:()=>Ve,WarpMultiversxContractLoader:()=>G,WarpMultiversxDataLoader:()=>K,WarpMultiversxExecutor:()=>y,WarpMultiversxExplorer:()=>J,WarpMultiversxRegistry:()=>X,WarpMultiversxResults:()=>O,WarpMultiversxSerializer:()=>F,address_value:()=>Ge,asset_value:()=>Ke,biguint_value:()=>ze,boolean_value:()=>He,codemeta_value:()=>Je,composite_value:()=>Oe,createMultiversxAdapter:()=>Y,findKnownTokenById:()=>ce,getAllMultiversxAdapters:()=>ke,getAllMultiversxChainNames:()=>Fe,getMultiversxAdapter:()=>ue,getMultiversxRegistryAddress:()=>W,getVibechainAdapter:()=>de,hex_value:()=>je,list_value:()=>Pe,nothing_value:()=>Xe,option_value:()=>Re,optional_value:()=>Ue,string_value:()=>Me,token_value:()=>Qe,u16_value:()=>Le,u32_value:()=>De,u64_value:()=>qe,u8_value:()=>$e,variadic_value:()=>_e});module.exports=Ie(Ye);var he=require("@vleap/warps");var z=require("@vleap/warps");var V=require("@multiversx/sdk-core"),A=require("@vleap/warps");var oe=require("@vleap/warps");var f=require("@multiversx/sdk-core"),N=require("@vleap/warps");var D=require("@multiversx/sdk-core"),w=require("@vleap/warps");var n=require("@multiversx/sdk-core"),x=require("@vleap/warps");var L=o=>!o.includes("-"),ee=o=>L(o)?`${o}-000000`:o;var fe=new RegExp(`${x.WarpConstants.ArgParamsSeparator}(.*)`),F=class{constructor(){this.coreSerializer=new x.WarpSerializer}typedToString(e){let t=e.getType();if(t.hasExactClass(n.OptionType.ClassName)||e.hasClassOrSuperclass(n.OptionValue.ClassName))return e.isSet()?`option:${this.typedToString(e.getTypedValue())}`:"option:null";if(t.hasExactClass(n.OptionalType.ClassName)||e.hasClassOrSuperclass(n.OptionalValue.ClassName))return e.isSet()?`optional:${this.typedToString(e.getTypedValue())}`:"optional:null";if(t.hasExactClass(n.ListType.ClassName)||e.hasClassOrSuperclass(n.List.ClassName)){let r=e.getItems(),s=r.map(i=>this.typedToString(i).split(x.WarpConstants.ArgParamsSeparator)[0])[0],c=r.map(i=>this.typedToString(i).split(x.WarpConstants.ArgParamsSeparator)[1]);return`list:${s}:${c.join(",")}`}if(t.hasExactClass(n.VariadicType.ClassName)||e.hasClassOrSuperclass(n.VariadicValue.ClassName)){let r=e.getItems(),s=r.map(i=>this.typedToString(i).split(x.WarpConstants.ArgParamsSeparator)[0])[0],c=r.map(i=>this.typedToString(i).split(x.WarpConstants.ArgParamsSeparator)[1]);return`variadic:${s}:${c.join(",")}`}if(t.hasExactClass(n.CompositeType.ClassName)||e.hasClassOrSuperclass(n.CompositeValue.ClassName)){let r=e.getItems(),a=r.map(u=>this.typedToString(u).split(x.WarpConstants.ArgParamsSeparator)[0]),s=r.map(u=>this.typedToString(u).split(x.WarpConstants.ArgParamsSeparator)[1]),c=a.join(x.WarpConstants.ArgCompositeSeparator),i=s.join(x.WarpConstants.ArgCompositeSeparator);return`composite(${c}):${i}`}if(t.hasExactClass(n.BigUIntType.ClassName)||e.hasClassOrSuperclass(n.BigUIntValue.ClassName)||t.getName()==="BigUint")return`biguint:${BigInt(e.valueOf().toFixed())}`;if(t.hasExactClass(n.U8Type.ClassName)||e.hasClassOrSuperclass(n.U8Value.ClassName))return`uint8:${e.valueOf().toNumber()}`;if(t.hasExactClass(n.U16Type.ClassName)||e.hasClassOrSuperclass(n.U16Value.ClassName))return`uint16:${e.valueOf().toNumber()}`;if(t.hasExactClass(n.U32Type.ClassName)||e.hasClassOrSuperclass(n.U32Value.ClassName))return`uint32:${e.valueOf().toNumber()}`;if(t.hasExactClass(n.U64Type.ClassName)||e.hasClassOrSuperclass(n.U64Value.ClassName))return`uint64:${BigInt(e.valueOf().toFixed())}`;if(t.hasExactClass(n.StringType.ClassName)||e.hasClassOrSuperclass(n.StringValue.ClassName))return`string:${e.valueOf()}`;if(t.hasExactClass(n.BooleanType.ClassName)||e.hasClassOrSuperclass(n.BooleanValue.ClassName))return`bool:${e.valueOf()}`;if(t.hasExactClass(n.AddressType.ClassName)||e.hasClassOrSuperclass(n.AddressValue.ClassName))return`address:${e.valueOf().toBech32()}`;if(t.hasExactClass(n.TokenIdentifierType.ClassName)||e.hasClassOrSuperclass(n.TokenIdentifierValue.ClassName))return`token:${e.valueOf()}`;if(t.hasExactClass(n.BytesType.ClassName)||e.hasClassOrSuperclass(n.BytesValue.ClassName))return`hex:${e.valueOf().toString("hex")}`;if(t.hasExactClass(n.CodeMetadataType.ClassName)||e.hasClassOrSuperclass(n.CodeMetadataValue.ClassName))return`codemeta:${e.valueOf().toString()}`;if(t.getName()==="EsdtTokenPayment"){let r=e.getFieldValue("token_identifier").valueOf(),a=e.getFieldValue("token_nonce").valueOf(),s=e.getFieldValue("amount").valueOf();return`asset:${new n.TokenComputer().computeExtendedIdentifier(new n.Token({identifier:r,nonce:BigInt(a)}))}|${s}`}throw new Error(`WarpArgSerializer (typedToString): Unsupported input type: ${e.getClassName()}`)}typedToNative(e){let t=this.typedToString(e);return this.coreSerializer.stringToNative(t)}nativeToTyped(e,t){let r=this.coreSerializer.nativeToString(e,t);return this.stringToTyped(r)}nativeToType(e){if(e.startsWith("composite")){let t=e.match(/\(([^)]+)\)/)?.[1];return new n.CompositeType(...t.split(x.WarpConstants.ArgCompositeSeparator).map(r=>this.nativeToType(r)))}if(e==="string")return new n.StringType;if(e==="uint8")return new n.U8Type;if(e==="uint16")return new n.U16Type;if(e==="uint32")return new n.U32Type;if(e==="uint64")return new n.U64Type;if(e==="biguint")return new n.BigUIntType;if(e==="bool")return new n.BooleanType;if(e==="address")return new n.AddressType;if(e==="token")return new n.TokenIdentifierType;if(e==="hex")return new n.BytesType;if(e==="codemeta")return new n.CodeMetadataType;if(e==="asset")return new n.StructType("EsdtTokenPayment",[new n.FieldDefinition("token_identifier","",new n.TokenIdentifierType),new n.FieldDefinition("token_nonce","",new n.U64Type),new n.FieldDefinition("amount","",new n.BigUIntType)]);throw new Error(`WarpArgSerializer (nativeToType): Unsupported input type: ${e}`)}stringToTyped(e){let[t,r]=e.split(/:(.*)/,2);if(t==="null"||t===null)return new n.NothingValue;if(t==="option"){let a=this.stringToTyped(r);return a instanceof n.NothingValue?n.OptionValue.newMissingTyped(a.getType()):n.OptionValue.newProvided(a)}if(t==="optional"){let a=this.stringToTyped(r);return a instanceof n.NothingValue?n.OptionalValue.newMissing():new n.OptionalValue(a.getType(),a)}if(t==="list"){let[a,s]=r.split(fe,2),i=s.split(",").map(u=>this.stringToTyped(`${a}:${u}`));return new n.List(this.nativeToType(a),i)}if(t==="variadic"){let[a,s]=r.split(fe,2),i=s.split(",").map(u=>this.stringToTyped(`${a}:${u}`));return new n.VariadicValue(new n.VariadicType(this.nativeToType(a)),i)}if(t.startsWith("composite")){let a=t.match(/\(([^)]+)\)/)?.[1],s=r.split(x.WarpConstants.ArgCompositeSeparator),c=a.split(x.WarpConstants.ArgCompositeSeparator),i=s.map((m,h)=>this.stringToTyped(`${c[h]}:${m}`)),u=i.map(m=>m.getType());return new n.CompositeValue(new n.CompositeType(...u),i)}if(t==="string")return r?n.StringValue.fromUTF8(r):new n.NothingValue;if(t==="uint8")return r?new n.U8Value(Number(r)):new n.NothingValue;if(t==="uint16")return r?new n.U16Value(Number(r)):new n.NothingValue;if(t==="uint32")return r?new n.U32Value(Number(r)):new n.NothingValue;if(t==="uint64")return r?new n.U64Value(BigInt(r)):new n.NothingValue;if(t==="biguint")return r?new n.BigUIntValue(BigInt(r)):new n.NothingValue;if(t==="bool")return r?new n.BooleanValue(typeof r=="boolean"?r:r==="true"):new n.NothingValue;if(t==="address")return r?new n.AddressValue(n.Address.newFromBech32(r)):new n.NothingValue;if(t==="token")return r?new n.TokenIdentifierValue(r):new n.NothingValue;if(t==="hex")return r?n.BytesValue.fromHex(r):new n.NothingValue;if(t==="codemeta")return new n.CodeMetadataValue(n.CodeMetadata.newFromBytes(Uint8Array.from(Buffer.from(r,"hex"))));if(t==="asset"){let[a,s]=r.split(x.WarpConstants.ArgCompositeSeparator),c=new n.TokenComputer,i=L(a)?ee(a):c.extractIdentifierFromExtendedIdentifier(a),u=L(a)?0n:c.extractNonceFromExtendedIdentifier(a);return new n.Struct(this.nativeToType("asset"),[new n.Field(new n.TokenIdentifierValue(i),"token_identifier"),new n.Field(new n.U64Value(BigInt(u)),"token_nonce"),new n.Field(new n.BigUIntValue(BigInt(s)),"amount")])}throw new Error(`WarpArgSerializer (stringToTyped): Unsupported input type: ${t}`)}typeToString(e){if(e.hasExactClass(n.OptionType.ClassName))return"option:"+this.typeToString(e.getFirstTypeParameter());if(e.hasExactClass(n.OptionalType.ClassName))return"optional:"+this.typeToString(e.getFirstTypeParameter());if(e.hasExactClass(n.ListType.ClassName))return"list:"+this.typeToString(e.getFirstTypeParameter());if(e.hasExactClass(n.VariadicType.ClassName))return"variadic:"+this.typeToString(e.getFirstTypeParameter());if(e.hasExactClass(n.StringType.ClassName))return"string";if(e.hasExactClass(n.U8Type.ClassName))return"uint8";if(e.hasExactClass(n.U16Type.ClassName))return"uint16";if(e.hasExactClass(n.U32Type.ClassName))return"uint32";if(e.hasExactClass(n.U64Type.ClassName))return"uint64";if(e.hasExactClass(n.BigUIntType.ClassName))return"biguint";if(e.hasExactClass(n.BooleanType.ClassName))return"bool";if(e.hasExactClass(n.AddressType.ClassName))return"address";if(e.hasExactClass(n.TokenIdentifierType.ClassName))return"token";if(e.hasExactClass(n.BytesType.ClassName))return"hex";if(e.hasExactClass(n.CodeMetadataType.ClassName))return"codemeta";if(e.hasExactClass(n.StructType.ClassName)&&e.getClassName()==="EsdtTokenPayment")return"asset";throw new Error(`WarpArgSerializer (typeToString): Unsupported input type: ${e.getClassName()}`)}};var O=class{constructor(e,t){this.config=e;this.chain=t;this.abi=new R(e,t),this.serializer=new F,this.cache=new w.WarpCache(e.cache?.type)}async getTransactionExecutionResults(e,t){let{actionIndex:r}=(0,w.findWarpExecutableAction)(e),a=this.cache.get(w.WarpCacheKey.WarpExecutable(this.config.env,e.meta?.hash||"",r))??[],s=await this.extractContractResults(e,t,a),c=(0,w.getNextInfo)(this.config,[],e,r,s),i=(0,w.applyResultsToMessages)(e,s.results);return{success:t.status.isSuccessful(),warp:e,action:r,user:this.config.user?.wallets?.[this.chain.name]||null,txHash:t.hash,tx:t,next:c,values:s.values,valuesRaw:[],results:s.results,messages:i}}async extractContractResults(e,t,r){let{action:a,actionIndex:s}=(0,w.findWarpExecutableAction)(e),c=[],i={};if(!e.results||a.type!=="contract")return{values:c,results:i};if(!Object.values(e.results).some(v=>v.includes("out")||v.includes("event"))){for(let[v,g]of Object.entries(e.results))i[v]=g;return{values:c,results:await(0,w.evaluateResultsCommon)(e,i,s,r,this.config.transform?.runner)}}let m=await this.abi.getAbiForAction(a),h=new D.TransactionEventsParser({abi:m}),T=new D.SmartContractTransactionsOutcomeParser({abi:m}).parseExecute({transactionOnNetwork:t,function:a.func||void 0});for(let[v,g]of Object.entries(e.results)){if(g.startsWith(w.WarpConstants.Transform.Prefix))continue;if(g.startsWith("input.")){i[v]=g;continue}let B=(0,w.parseResultsOutIndex)(g);if(B!==null&&B!==s){i[v]=null;continue}let[b,E,U]=g.split(".");if(b==="event"){if(!E||isNaN(Number(U)))continue;let I=Number(U),C=(0,D.findEventsByFirstTopic)(t,E),H=h.parseEvents({events:C})[0],Z=Object.values(H)[I]||null;c.push(Z),i[v]=Z&&Z.valueOf()}else if(b==="out"||b.startsWith("out[")){if(!E)continue;let I=Number(E),C=T.values[I-1]||null;U&&(C=C[U]||null),C&&typeof C=="object"&&(C="toFixed"in C?C.toFixed():C.valueOf()),c.push(C),i[v]=C&&C.valueOf()}else i[v]=g}return{values:c,results:await(0,w.evaluateResultsCommon)(e,i,s,r)}}async extractQueryResults(e,t,r,a){let s=t.map(m=>this.serializer.typedToString(m)),c=t.map(m=>this.serializer.typedToNative(m)[1]),i={};if(!e.results)return{values:s,valuesRaw:c,results:i};let u=m=>{let h=m.split(".").slice(1).map(T=>parseInt(T)-1);if(h.length===0)return;let d=c[h[0]];for(let T=1;T<h.length;T++){if(d==null)return;d=d[h[T]]}return d};for(let[m,h]of Object.entries(e.results)){if(h.startsWith(w.WarpConstants.Transform.Prefix))continue;let d=(0,w.parseResultsOutIndex)(h);if(d!==null&&d!==r){i[m]=null;continue}h.startsWith("out.")||h==="out"||h.startsWith("out[")?i[m]=u(h)||null:i[m]=h}return{values:s,valuesRaw:c,results:await(0,w.evaluateResultsCommon)(e,i,r,a)}}async resolveWarpResultsRecursively(e){let t=e.warp,r=e.entryActionIndex,a=e.executor,s=e.inputs,c=e.meta,i=new Map,u=new Set,m=this;async function h(g,B=[]){if(i.has(g))return i.get(g);if(u.has(g))throw new Error(`Circular dependency detected at action ${g}`);u.add(g);let b=t.actions[g-1];if(!b)throw new Error(`Action ${g} not found`);let E;if(b.type==="query")E=await a.executeQuery(t,g,B);else if(b.type==="collect")E=await a.executeCollect(t,g,B,c);else throw new Error(`Unsupported or interactive action type: ${b.type}`);if(i.set(g,E),t.results)for(let U of Object.values(t.results)){let C=String(U).match(/^out\[(\d+)\]/);if(C){let H=parseInt(C[1],10);H!==g&&!i.has(H)&&await h(H)}}return u.delete(g),E}await h(r,s);let d={};for(let g of i.values())for(let[B,b]of Object.entries(g.results))b!==null?d[B]=b:B in d||(d[B]=null);let T=await(0,w.evaluateResultsCommon)(t,d,r,s,this.config.transform?.runner);return{...i.get(r),action:r,results:T}}};var Ne="EGLD-000000",y=class o{constructor(e,t){this.config=e;this.chain=t;this.serializer=new F,this.abi=new R(this.config,this.chain),this.results=new O(this.config,this.chain)}async createTransaction(e){let t=(0,N.getWarpActionByIndex)(e.warp,e.action),r=null;if(t.type==="transfer")r=await this.createTransferTransaction(e);else if(t.type==="contract")r=await this.createContractCallTransaction(e);else{if(t.type==="query")throw new Error("WarpMultiversxExecutor: Invalid action type for createTransactionForExecute; Use executeQuery instead");if(t.type==="collect")throw new Error("WarpMultiversxExecutor: Invalid action type for createTransactionForExecute; Use executeCollect instead")}if(!r)throw new Error(`WarpMultiversxExecutor: Invalid action type (${t.type})`);return r}async createTransferTransaction(e){let t=this.config.user?.wallets?.[e.chain.name];if(!t)throw new Error("WarpMultiversxExecutor: createTransfer - user address not set");let r=f.Address.newFromBech32(t),a=new f.TransactionsFactoryConfig({chainID:e.chain.chainId}),s=e.data?Buffer.from(this.serializer.stringToTyped(e.data).valueOf()):null;return new f.TransferTransactionsFactory({config:a}).createTransactionForTransfer(r,{receiver:f.Address.newFromBech32(e.destination),nativeAmount:e.value,tokenTransfers:this.toTokenTransfers(e.transfers),data:s?new Uint8Array(s):void 0})}async createContractCallTransaction(e){let t=this.config.user?.wallets?.[e.chain.name];if(!t)throw new Error("WarpMultiversxExecutor: createContractCall - user address not set");let r=(0,N.getWarpActionByIndex)(e.warp,e.action),a=f.Address.newFromBech32(t),s=e.args.map(i=>this.serializer.stringToTyped(i)),c=new f.TransactionsFactoryConfig({chainID:e.chain.chainId});return new f.SmartContractTransactionsFactory({config:c}).createTransactionForExecute(a,{contract:f.Address.newFromBech32(e.destination),function:"func"in r&&r.func||"",gasLimit:"gasLimit"in r?BigInt(r.gasLimit||0):0n,arguments:s,tokenTransfers:this.toTokenTransfers(e.transfers),nativeTransferAmount:e.value})}async executeQuery(e){let t=(0,N.getWarpActionByIndex)(e.warp,e.action);if(t.type!=="query")throw new Error(`WarpMultiversxExecutor: Invalid action type for executeQuery: ${t.type}`);let r=await this.abi.getAbiForAction(t),a=e.args.map(I=>this.serializer.stringToTyped(I)),s=o.getChainEntrypoint(e.chain,this.config.env,this.config),c=f.Address.newFromBech32(e.destination),i=s.createSmartContractController(r),u=i.createQuery({contract:c,function:t.func||"",arguments:a}),m=await i.runQuery(u),h=m.returnCode==="ok",d=new f.ArgSerializer,T=r.getEndpoint(m.function||t.func||""),v=(m.returnDataParts||[]).map(I=>Buffer.from(I)),g=d.buffersToValues(v,T.output),{values:B,valuesRaw:b,results:E}=await this.results.extractQueryResults(e.warp,g,e.action,e.resolvedInputs),U=(0,N.getNextInfo)(this.config,[],e.warp,e.action,E);return{success:h,warp:e.warp,action:e.action,user:this.config.user?.wallets?.[e.chain.name]||null,txHash:null,tx:null,next:U,values:B,valuesRaw:b,results:E,messages:(0,N.applyResultsToMessages)(e.warp,E)}}static getChainEntrypoint(e,t,r){let a="warp-sdk",c=r?(0,N.getProviderUrl)(r,e.name,t,e.defaultApiUrl):e.defaultApiUrl;return t==="devnet"?new f.DevnetEntrypoint({url:c,kind:"api",clientName:a}):t==="testnet"?new f.TestnetEntrypoint({url:c,kind:"api",clientName:a}):new f.MainnetEntrypoint({url:c,kind:"api",clientName:a})}async signMessage(e,t){let r=f.UserSecretKey.fromString(t);return(await new f.UserSigner(r).sign(new Uint8Array(Buffer.from(e,"utf-8")))).toString()}toTokenTransfers(e){return e.map(t=>t.identifier===this.chain.nativeToken.identifier?{...t,identifier:Ne}:t).map(t=>{let a=new f.TokenComputer().extractNonceFromExtendedIdentifier(t.identifier);return new f.TokenTransfer({token:new f.Token({identifier:t.identifier,nonce:BigInt(a||0)}),amount:t.amount})})}};var G=class{constructor(e){this.config=e}async getContract(e,t){try{let s=await y.getChainEntrypoint(t,this.config.env).createNetworkProvider().doGetGeneric(`accounts/${e}`);return{address:e,owner:s.ownerAddress,verified:s.isVerified||!1}}catch(r){return oe.WarpLogger.error("WarpContractLoader: getContract error",r),null}}async getVerificationInfo(e,t){try{let s=await y.getChainEntrypoint(t,this.config.env).createNetworkProvider().doGetGeneric(`accounts/${e}/verification`);return{codeHash:s.codeHash,abi:s.source.abi}}catch(r){return oe.WarpLogger.error("WarpContractLoader: getVerificationInfo error",r),null}}};var R=class{constructor(e,t){this.config=e;this.chain=t;this.contractLoader=new G(this.config),this.cache=new A.WarpCache(this.config.cache?.type)}async createInscriptionTransaction(e){let t=this.config.user?.wallets?.[this.chain.name];if(!t)throw new Error("WarpBuilder: user address not set");let r=new V.TransactionsFactoryConfig({chainID:this.chain.chainId}),a=new V.TransferTransactionsFactory({config:r}),s=V.Address.newFromBech32(t),c={protocol:(0,A.getLatestProtocolIdentifier)("abi"),content:e},i=JSON.stringify(c),u=await a.createTransactionForTransfer(s,{receiver:s,nativeAmount:BigInt(0),data:Uint8Array.from(Buffer.from(i))});return u.gasLimit=u.gasLimit+BigInt(2e6),u}async createFromRaw(e){return JSON.parse(e)}async createFromTransaction(e){let t=await this.createFromRaw(e.data.toString());return t.meta={chain:this.chain.name,hash:e.hash,creator:e.sender.toBech32(),createdAt:new Date(e.timestamp*1e3).toISOString()},t}async createFromTransactionHash(e,t){let r=A.WarpCacheKey.WarpAbi(this.config.env,e);if(t){let c=this.cache.get(r);if(c)return A.WarpLogger.info(`WarpAbiBuilder (createFromTransactionHash): Warp abi found in cache: ${e}`),c}let s=y.getChainEntrypoint(this.chain,this.config.env).createNetworkProvider();try{let c=await s.getTransaction(e),i=await this.createFromTransaction(c);return t&&t.ttl&&i&&this.cache.set(r,i,t.ttl),i}catch(c){return A.WarpLogger.error("WarpAbiBuilder: Error creating from transaction hash",c),null}}async getAbiForAction(e){if(e.abi)return await this.fetchAbi(e);if(!e.address)throw new Error("WarpActionExecutor: Address not found");let t=await this.contractLoader.getVerificationInfo(e.address,this.chain);if(!t)throw new Error("WarpActionExecutor: Verification info not found");return V.AbiRegistry.create(t.abi)}async fetchAbi(e){if(!e.abi)throw new Error("WarpActionExecutor: ABI not found");if(e.abi.startsWith(A.WarpConstants.IdentifierType.Hash)){let t=e.abi.split(A.WarpConstants.ArgParamsSeparator)[1],r=await this.createFromTransactionHash(t);if(!r)throw new Error(`WarpActionExecutor: ABI not found for hash: ${e.abi}`);return V.AbiRegistry.create(r.content)}else{let r=await(await fetch(e.abi)).json();return V.AbiRegistry.create(r)}}};var M=require("@multiversx/sdk-core"),te=require("@vleap/warps"),ge=require("buffer");var Q=class{constructor(e,t){this.config=e;this.chain=t;this.core=new te.WarpBrandBuilder(e)}async createInscriptionTransaction(e){let t=this.config.user?.wallets?.[this.chain.name];if(!t)throw new Error("BrandBuilder: user address not set");let r=new M.TransactionsFactoryConfig({chainID:this.chain.chainId}),a=new M.TransferTransactionsFactory({config:r}),s=M.Address.newFromBech32(t),c=JSON.stringify(e);return await a.createTransactionForNativeTokenTransfer(s,{receiver:M.Address.newFromBech32(t),nativeAmount:BigInt(0),data:Uint8Array.from(ge.Buffer.from(c))})}async createFromTransaction(e,t=!1){return await this.core.createFromRaw(e.data.toString(),t)}async createFromTransactionHash(e){let r=y.getChainEntrypoint(this.chain,this.config.env).createNetworkProvider();try{let a=await r.getTransaction(e);return this.createFromTransaction(a)}catch(a){return te.WarpLogger.error("BrandBuilder: Error creating from transaction hash",a),null}}};var $=require("@multiversx/sdk-core"),S=require("@vleap/warps");var j=class extends S.WarpBuilder{constructor(t,r){super(t);this.config=t;this.chain=r;this.cache=new S.WarpCache(t.cache?.type),this.core=new S.WarpBuilder(t)}async createInscriptionTransaction(t){let r=this.config.user?.wallets?.[this.chain.name];if(!r)throw new Error("WarpBuilder: user address not set");let a=new $.TransactionsFactoryConfig({chainID:this.chain.chainId}),s=new $.TransferTransactionsFactory({config:a}),c=$.Address.newFromBech32(r),i=JSON.stringify(t),u=await s.createTransactionForTransfer(c,{receiver:$.Address.newFromBech32(r),nativeAmount:BigInt(0),data:Uint8Array.from(Buffer.from(i))});return u.gasLimit=u.gasLimit+BigInt(2e6),u}async createFromTransaction(t,r=!1){let a=await this.core.createFromRaw(t.data.toString(),r);return a.meta={chain:this.chain.name,hash:t.hash,creator:t.sender.toBech32(),createdAt:new Date(t.timestamp*1e3).toISOString()},a}async createFromTransactionHash(t,r){let a=S.WarpCacheKey.Warp(this.config.env,t);if(r){let i=this.cache.get(a);if(i)return S.WarpLogger.info(`WarpBuilder (createFromTransactionHash): Warp found in cache: ${t}`),i}let c=y.getChainEntrypoint(this.chain,this.config.env).createNetworkProvider();try{let i=await c.getTransaction(t),u=await this.createFromTransaction(i);return r&&r.ttl&&u&&this.cache.set(a,u,r.ttl),u}catch(i){return S.WarpLogger.error("WarpBuilder: Error creating from transaction hash",i),null}}};var P=require("@multiversx/sdk-core"),q=require("@vleap/warps");var ye=require("@vleap/warps"),re=ye.WarpChainName.Multiversx,we=[{chain:re,identifier:"EGLD",name:"eGold",symbol:"EGLD",decimals:18,logoUrl:"https://tools.multiversx.com/assets-cdn/tokens/EGLD-000000/icon.pngsvg"},{chain:re,identifier:"EGLD-000000",name:"eGold",symbol:"EGLD",decimals:18,logoUrl:"https://tools.multiversx.com/assets-cdn/tokens/EGLD-000000/icon.png"},{chain:re,identifier:"VIBE",name:"VIBE",symbol:"VIBE",decimals:18,logoUrl:"https://vleap.ai/images/tokens/vibe.svg"},{chain:re,identifier:"VIBE-000000",name:"VIBE",symbol:"VIBE",decimals:18,logoUrl:"https://vleap.ai/images/tokens/vibe.svg"}],ce=o=>we.find(e=>e.identifier===o)||null;var K=class{constructor(e,t){this.config=e;this.chain=t;this.cache=new q.WarpCache(e.cache?.type)}async getAccount(e){let r=await y.getChainEntrypoint(this.chain,this.config.env,this.config).createNetworkProvider().getAccount(P.Address.newFromBech32(e));return{chain:this.chain.name,address:r.address.toBech32(),balance:r.balance}}async getAccountAssets(e){let t=y.getChainEntrypoint(this.chain,this.config.env,this.config).createNetworkProvider(),r=t.getAccount(P.Address.newFromBech32(e)),a=t.getFungibleTokensOfAccount(P.Address.newFromBech32(e)),[s,c]=await Promise.all([r,a]),i=s.balance>0?[{...this.chain.nativeToken,amount:s.balance}]:[];return i.push(...c.map(u=>({chain:this.chain.name,identifier:u.token.identifier,name:u.raw.name,symbol:u.raw.ticker,amount:u.amount,decimals:u.raw.decimals,logoUrl:u.raw.assets?.pngUrl||""}))),i}async getAsset(e){let t=q.WarpCacheKey.Asset(this.config.env,this.chain.name,e),r=this.cache.get(t);if(r)return r;let a=ce(e);if(a)return{chain:this.chain.name,identifier:e,name:a.name,symbol:a.symbol,amount:0n,decimals:a.decimals,logoUrl:a.logoUrl};let s=new P.TokenComputer,c=L(e)?0n:s.extractNonceFromExtendedIdentifier(e),i=new P.Token({identifier:e,nonce:BigInt(c||0)}),u=s.isFungible(i),m=y.getChainEntrypoint(this.chain,this.config.env,this.config).createNetworkProvider(),h=ee(e),d=await m.doGetGeneric(`tokens/${h}`),T={chain:this.chain.name,identifier:i.identifier,name:d.name,symbol:d.ticker,amount:0n,decimals:d.decimals,logoUrl:d.assets?.pngUrl||"#"};return this.cache.set(t,T,q.CacheTtl.OneHour),T}async getAction(e,t=!1){let r=y.getChainEntrypoint(this.chain,this.config.env,this.config),a=t?await r.awaitCompletedTransaction(e):await r.getTransaction(e);return{chain:this.chain.name,id:a.hash,receiver:a.receiver.toBech32(),sender:a.sender.toBech32(),value:a.value,function:a.function,status:this.toActionStatus(a),createdAt:this.toActionCreatedAt(a),error:a?.smartContractResults.map(s=>s.raw.returnMessage)[0]||null,tx:a}}async getAccountActions(e,t){let r=y.getChainEntrypoint(this.chain,this.config.env,this.config).createNetworkProvider(),a=`accounts/${e}/transactions`,s=new URLSearchParams,c=t?.size||25,i=t?.page||0;if(i>0){let m=i*c;s.append("from",m.toString())}return c!==25&&s.append("size",c.toString()),s.toString()&&(a+=`?${s.toString()}`),(await r.doGetGeneric(a)).map(m=>({chain:this.chain.name,id:m.txHash,receiver:m.receiver,sender:m.sender,value:m.value,function:m.function,status:this.toActionStatus(m),createdAt:this.toActionCreatedAt(m)}))}toActionStatus(e){return e.status.isSuccessful()?"success":e.status.isFailed()?"failed":"pending"}toActionCreatedAt(e){return new Date(e.timestamp||e.timestamp*1e3).toISOString()}};var Ve={Egld:{Identifier:"EGLD",EsdtIdentifier:"EGLD-000000",DisplayName:"eGold",Decimals:18}},Ce=(r=>(r.MultiversxExplorer="multiversx_explorer",r.MultiversxExplorerDevnet="multiversx_explorer_devnet",r.MultiversxExplorerTestnet="multiversx_explorer_testnet",r))(Ce||{}),xe=(r=>(r.VibechainExplorer="vibechain_explorer",r.VibechainExplorerDevnet="vibechain_explorer_devnet",r.VibechainExplorerTestnet="vibechain_explorer_testnet",r))(xe||{}),pe={multiversx:{mainnet:["multiversx_explorer"],testnet:["multiversx_explorer_testnet"],devnet:["multiversx_explorer_devnet"]},vibechain:{mainnet:["vibechain_explorer"],testnet:["vibechain_explorer_testnet"],devnet:["vibechain_explorer_devnet"]}},_={multiversx_explorer:"https://explorer.multiversx.com",multiversx_explorer_devnet:"https://devnet-explorer.multiversx.com",multiversx_explorer_testnet:"https://testnet-explorer.multiversx.com",vibechain_explorer:"https://vibeox-explorer.multiversx.com",vibechain_explorer_devnet:"https://vibeox-explorer.multiversx.com",vibechain_explorer_testnet:"https://vibeox-explorer.multiversx.com"};var J=class{constructor(e,t){this.chain=e;this.config=t}getExplorers(){let e=pe[this.chain];if(!e)return["multiversx_explorer"];let t=e[this.config.env];return t||["multiversx_explorer"]}getPrimaryExplorer(){return this.getExplorers()[0]}getExplorerUrlByName(e){let t=this.config.preferences?.explorers?.[this.chain];if(t&&!e){let s=_[t];if(s)return s}if(e){let s=_[e];if(s)return s}let r=this.getPrimaryExplorer();return _[r]||_[r]}getAccountUrl(e,t){return`${this.getExplorerUrlByName(t)}/accounts/${e}`}getTransactionUrl(e,t){return`${this.getExplorerUrlByName(t)}/transactions/${e}`}getBlockUrl(e,t){return`${this.getExplorerUrlByName(t)}/blocks/${e}`}getAssetUrl(e,t){return`${this.getExplorerUrlByName(t)}/tokens/${e}`}getContractUrl(e,t){return`${this.getExplorerUrlByName(t)}/accounts/${e}`}getAllExplorers(){return this.getExplorers()}getExplorerByName(e){return this.getExplorers().find(r=>r.toLowerCase()===e.toLowerCase())}getAccountUrls(e){let t=this.getAllExplorers(),r={};return t.forEach(a=>{let s=_[a];s&&(r[a]=`${s}/accounts/${e}`)}),r}getTransactionUrls(e){let t=this.getAllExplorers(),r={};return t.forEach(a=>{let s=_[a];s&&(r[a]=`${s}/transactions/${e}`)}),r}};var l=require("@multiversx/sdk-core"),k=require("@vleap/warps");var le={buildInfo:{rustc:{version:"1.86.0",commitHash:"05f9846f893b09a1be1fc8560e33fc3c815cfecb",commitDate:"2025-03-31",channel:"Stable",short:"rustc 1.86.0 (05f9846f8 2025-03-31)"},contractCrate:{name:"registry",version:"0.0.1"},framework:{name:"multiversx-sc",version:"0.51.1"}},name:"RegistryContract",constructor:{inputs:[{name:"unit_price",type:"BigUint"},{name:"vault",type:"Address"}],outputs:[]},upgradeConstructor:{inputs:[],outputs:[]},endpoints:[{name:"registerWarp",mutability:"mutable",payableInTokens:["EGLD"],inputs:[{name:"hash",type:"bytes"},{name:"alias_opt",type:"optional<bytes>",multi_arg:!0},{name:"brand_opt",type:"optional<bytes>",multi_arg:!0}],outputs:[],allow_multiple_var_args:!0},{name:"unregisterWarp",mutability:"mutable",inputs:[{name:"warp",type:"bytes"}],outputs:[]},{name:"upgradeWarp",mutability:"mutable",payableInTokens:["EGLD"],inputs:[{name:"alias",type:"bytes"},{name:"new_warp",type:"bytes"}],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 W=o=>{if(o==="devnet")return"erd1qqqqqqqqqqqqqpgqje2f99vr6r7sk54thg03c9suzcvwr4nfl3tsfkdl36";if(o==="testnet")throw new Error("Multiversx testnet is not supported");return"erd1qqqqqqqqqqqqqpgq3mrpj3u6q7tejv6d7eqhnyd27n9v5c5tl3ts08mffe"};var ne=o=>({hash:o.hash.toString("hex"),alias:o.alias?.toString()||null,trust:o.trust.toString(),owner:o.owner.toString(),createdAt:o.created_at.toNumber(),upgradedAt:o.upgraded_at?.toNumber(),brand:o.brand?.toString("hex")||null,upgrade:o.upgrade?.toString("hex")||null}),We=o=>({unitPrice:BigInt(o.unit_price.toString()),admins:o.admins.map(e=>e.toBech32())});var X=class{constructor(e,t){this.config=e;this.chain=t;this.cache=new k.WarpCache(e.cache?.type),this.registryConfig={unitPrice:BigInt(0),admins:[]},this.userWallet=this.config.user?.wallets?.[this.chain.name]||null}async init(){await this.loadRegistryConfigs()}getRegistryConfig(){return this.registryConfig}async createWarpRegisterTransaction(e,t,r){if(this.registryConfig.unitPrice===BigInt(0))throw new Error("WarpRegistry: config not loaded. forgot to call init()?");if(!this.userWallet)throw new Error("WarpRegistry: user address not set");let a=l.Address.newFromBech32(this.userWallet),s=()=>this.isCurrentUserAdmin()?BigInt(0):t&&r?this.registryConfig.unitPrice*BigInt(3):t?this.registryConfig.unitPrice*BigInt(2):this.registryConfig.unitPrice,c=()=>t&&r?[l.BytesValue.fromHex(e),l.BytesValue.fromUTF8(t),l.BytesValue.fromHex(r)]:t?[l.BytesValue.fromHex(e),l.BytesValue.fromUTF8(t)]:[l.BytesValue.fromHex(e)];return await this.getFactory().createTransactionForExecute(a,{contract:l.Address.newFromBech32(W(this.config.env)),function:"registerWarp",gasLimit:BigInt(1e7),nativeTransferAmount:s(),arguments:c()})}async createWarpUnregisterTransaction(e){if(!this.userWallet)throw new Error("WarpRegistry: user address not set");let t=l.Address.newFromBech32(this.userWallet);return await this.getFactory().createTransactionForExecute(t,{contract:l.Address.newFromBech32(W(this.config.env)),function:"unregisterWarp",gasLimit:BigInt(1e7),arguments:[l.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=l.Address.newFromBech32(this.userWallet);return await this.getFactory().createTransactionForExecute(r,{contract:l.Address.newFromBech32(W(this.config.env)),function:"upgradeWarp",gasLimit:BigInt(1e7),nativeTransferAmount:this.isCurrentUserAdmin()?void 0:this.registryConfig.unitPrice,arguments:[l.BytesValue.fromUTF8(e),l.BytesValue.fromHex(t)]})}async createWarpAliasSetTransaction(e,t){if(!this.userWallet)throw new Error("WarpRegistry: user address not set");let r=l.Address.newFromBech32(this.userWallet);return await this.getFactory().createTransactionForExecute(r,{contract:l.Address.newFromBech32(W(this.config.env)),function:"setWarpAlias",gasLimit:BigInt(1e7),nativeTransferAmount:this.isCurrentUserAdmin()?void 0:this.registryConfig.unitPrice,arguments:[l.BytesValue.fromHex(e),l.BytesValue.fromUTF8(t)]})}async createWarpVerifyTransaction(e){if(!this.userWallet)throw new Error("WarpRegistry: user address not set");let t=l.Address.newFromBech32(this.userWallet);return await this.getFactory().createTransactionForExecute(t,{contract:l.Address.newFromBech32(W(this.config.env)),function:"verifyWarp",gasLimit:BigInt(1e7),arguments:[l.BytesValue.fromHex(e)]})}async createWarpTransferOwnershipTransaction(e,t){if(!this.userWallet)throw new Error("WarpRegistry: user address not set");let r=l.Address.newFromBech32(this.userWallet);return await this.getFactory().createTransactionForExecute(r,{contract:l.Address.newFromBech32(W(this.config.env)),function:"transferOwnership",gasLimit:BigInt(1e7),arguments:[l.BytesValue.fromHex(e),new l.AddressValue(new l.Address(t))]})}async createBrandRegisterTransaction(e){if(this.registryConfig.unitPrice===BigInt(0))throw new Error("WarpRegistry: config not loaded. forgot to call init()?");if(!this.userWallet)throw new Error("WarpRegistry: user address not set");let t=l.Address.newFromBech32(this.userWallet);return await this.getFactory().createTransactionForExecute(t,{contract:l.Address.newFromBech32(W(this.config.env)),function:"registerBrand",gasLimit:BigInt(1e7),nativeTransferAmount:this.isCurrentUserAdmin()?void 0:this.registryConfig.unitPrice,arguments:[l.BytesValue.fromHex(e)]})}async createWarpBrandingTransaction(e,t){if(!this.userWallet)throw new Error("WarpRegistry: user address not set");let r=l.Address.newFromBech32(this.userWallet);return await this.getFactory().createTransactionForExecute(r,{contract:l.Address.newFromBech32(W(this.config.env)),function:"brandWarp",gasLimit:BigInt(1e7),nativeTransferAmount:this.isCurrentUserAdmin()?void 0:this.registryConfig.unitPrice,arguments:[l.BytesValue.fromHex(e),l.BytesValue.fromHex(t)]})}async getInfoByAlias(e,t){try{let r=k.WarpCacheKey.RegistryInfo(this.config.env,e),a=t?this.cache.get(r):null;if(a)return k.WarpLogger.info(`WarpRegistry (getInfoByAlias): RegistryInfo found in cache: ${e}`),a;let s=l.Address.newFromBech32(W(this.config.env)),c=this.getController(),i=c.createQuery({contract:s,function:"getInfoByAlias",arguments:[l.BytesValue.fromUTF8(e)]}),u=await c.runQuery(i),[m]=c.parseQueryResponse(u),h=m?ne(m):null,d=h?.brand?await this.fetchBrand(h.brand):null;return t&&t.ttl&&this.cache.set(r,{registryInfo:h,brand:d},t.ttl),{registryInfo:h,brand:d}}catch{return{registryInfo:null,brand:null}}}async getInfoByHash(e,t){try{let r=k.WarpCacheKey.RegistryInfo(this.config.env,e);if(t){let d=this.cache.get(r);if(d)return k.WarpLogger.info(`WarpRegistry (getInfoByHash): RegistryInfo found in cache: ${e}`),d}let a=l.Address.newFromBech32(W(this.config.env)),s=this.getController(),c=s.createQuery({contract:a,function:"getInfoByHash",arguments:[l.BytesValue.fromHex(e)]}),i=await s.runQuery(c),[u]=s.parseQueryResponse(i),m=u?ne(u):null,h=m?.brand?await this.fetchBrand(m.brand):null;return t&&t.ttl&&this.cache.set(r,{registryInfo:m,brand:h},t.ttl),{registryInfo:m,brand:h}}catch{return{registryInfo:null,brand:null}}}async getUserWarpRegistryInfos(e){try{let t=e||this.userWallet;if(!t)throw new Error("WarpRegistry: user address not set");let r=l.Address.newFromBech32(W(this.config.env)),a=this.getController(),s=a.createQuery({contract:r,function:"getUserWarps",arguments:[new l.AddressValue(new l.Address(t))]}),c=await a.runQuery(s),[i]=a.parseQueryResponse(c);return i.map(ne)}catch{return[]}}async getUserBrands(e){try{let t=e||this.userWallet;if(!t)throw new Error("WarpRegistry: user address not set");let r=l.Address.newFromBech32(W(this.config.env)),a=this.getController(),s=a.createQuery({contract:r,function:"getUserBrands",arguments:[new l.AddressValue(new l.Address(t))]}),c=await a.runQuery(s),[i]=a.parseQueryResponse(c),u=i.map(d=>d.toString("hex")),m={ttl:365*24*60*60};return(await Promise.all(u.map(d=>this.fetchBrand(d,m)))).filter(d=>d!==null)}catch{return[]}}async fetchBrand(e,t){let r=k.WarpCacheKey.Brand(this.config.env,e),a=t?this.cache.get(r):null;if(a)return k.WarpLogger.info(`WarpRegistry (fetchBrand): Brand found in cache: ${e}`),a;let c=y.getChainEntrypoint(this.chain,this.config.env).createNetworkProvider();try{let i=await c.getTransaction(e),u=JSON.parse(i.data.toString());return u.meta={hash:i.hash,creator:i.sender.toBech32(),createdAt:new Date(i.timestamp*1e3).toISOString()},t&&t.ttl&&this.cache.set(r,u,t.ttl),u}catch{return null}}async loadRegistryConfigs(){let e=l.Address.newFromBech32(W(this.config.env)),t=this.getController(),[r]=await t.query({contract:e,function:"getConfig",arguments:[]}),a=r?We(r):null;this.registryConfig=a||{unitPrice:BigInt(0),admins:[]}}getFactory(){let e=new l.TransactionsFactoryConfig({chainID:this.chain.chainId}),t=l.AbiRegistry.create(le);return new l.SmartContractTransactionsFactory({config:e,abi:t})}getController(){let e=y.getChainEntrypoint(this.chain,this.config.env),t=l.AbiRegistry.create(le);return e.createSmartContractController(t)}isCurrentUserAdmin(){return!!this.userWallet&&this.registryConfig.admins.includes(this.userWallet)}};var Y=(o,e,t)=>(r,a)=>{let s=t[r.env];return{chain:o,chainInfo:s,prefix:e,builder:()=>new j(r,s),executor:new y(r,s),results:new O(r,s),serializer:new F,registry:new X(r,s),explorer:new J(o,r),abiBuilder:()=>new R(r,s),brandBuilder:()=>new Q(r,s),dataLoader:new K(r,s),registerTypes:c=>{c.registerType("token",{stringToNative:i=>i,nativeToString:i=>`token:${i}`}),c.registerType("codemeta",{stringToNative:i=>i,nativeToString:i=>`codemeta:${i}`})}}};var ae={chain:z.WarpChainName.Multiversx,identifier:"EGLD",name:"eGold",symbol:"EGLD",decimals:18,logoUrl:"https://vleap.ai/images/tokens/egld.svg"},ue=Y(z.WarpChainName.Multiversx,"mvx",{mainnet:{name:z.WarpChainName.Multiversx,displayName:"MultiversX",chainId:"1",blockTime:6e3,addressHrp:"erd",defaultApiUrl:"https://api.multiversx.com",nativeToken:ae},testnet:{name:z.WarpChainName.Multiversx,displayName:"MultiversX Testnet",chainId:"T",blockTime:6e3,addressHrp:"erd",defaultApiUrl:"https://testnet-api.multiversx.com",nativeToken:ae},devnet:{name:z.WarpChainName.Multiversx,displayName:"MultiversX Devnet",chainId:"D",blockTime:6e3,addressHrp:"erd",defaultApiUrl:"https://devnet-api.multiversx.com",nativeToken:ae}});var se=require("@vleap/warps");var Te={chain:se.WarpChainName.Vibechain,identifier:"VIBE",name:"VIBE",symbol:"VIBE",decimals:18,logoUrl:"https://vleap.ai/images/tokens/vibe.svg"},me={name:se.WarpChainName.Vibechain,displayName:"VibeChain",chainId:"V",blockTime:600,addressHrp:"vibe",defaultApiUrl:"https://vibeox-api.multiversx.com",nativeToken:Te},de=Y(se.WarpChainName.Vibechain,"vibe",{mainnet:me,testnet:me,devnet:me});var ke=(o,e)=>[ue(o,e),de(o,e)],Fe=()=>[he.WarpChainName.Multiversx,he.WarpChainName.Vibechain];var p=require("@multiversx/sdk-core"),Re=(o,e)=>o?p.OptionValue.newProvided(o):e?p.OptionValue.newMissingTyped(e):p.OptionValue.newMissing(),Ue=(o,e)=>o?new p.OptionalValue(o.getType(),o):e?new p.OptionalValue(e):p.OptionalValue.newMissing(),Pe=o=>{if(o.length===0)throw new Error("Cannot create a list from an empty array");let e=o[0].getType();return new p.List(e,o)},_e=o=>p.VariadicValue.fromItems(...o),Oe=o=>{let e=o.map(t=>t.getType());return new p.CompositeValue(new p.CompositeType(...e),o)},Me=o=>p.StringValue.fromUTF8(o),$e=o=>new p.U8Value(o),Le=o=>new p.U16Value(o),De=o=>new p.U32Value(o),qe=o=>new p.U64Value(o),ze=o=>new p.BigUIntValue(BigInt(o)),He=o=>new p.BooleanValue(o),Ge=o=>new p.AddressValue(p.Address.newFromBech32(o)),Qe=o=>new p.TokenIdentifierValue(o),je=o=>p.BytesValue.fromHex(o),Ke=o=>new p.Struct(new p.StructType("EsdtTokenPayment",[new p.FieldDefinition("token_identifier","",new p.TokenIdentifierType),new p.FieldDefinition("token_nonce","",new p.U64Type),new p.FieldDefinition("amount","",new p.BigUIntType)]),[new p.Field(new p.TokenIdentifierValue(o.token.identifier),"token_identifier"),new p.Field(new p.U64Value(BigInt(o.token.nonce)),"token_nonce"),new p.Field(new p.BigUIntValue(BigInt(o.amount)),"amount")]),Je=o=>new p.CodeMetadataValue(p.CodeMetadata.newFromBytes(Uint8Array.from(Buffer.from(o,"hex")))),Xe=()=>new p.NothingValue;0&&(module.exports={ExplorerUrls,KnownTokens,MultiversxExplorers,MultiversxExplorersConfig,NativeTokenEgld,NativeTokenVibe,VibechainExplorers,WarpMultiversxAbiBuilder,WarpMultiversxBrandBuilder,WarpMultiversxBuilder,WarpMultiversxConstants,WarpMultiversxContractLoader,WarpMultiversxDataLoader,WarpMultiversxExecutor,WarpMultiversxExplorer,WarpMultiversxRegistry,WarpMultiversxResults,WarpMultiversxSerializer,address_value,asset_value,biguint_value,boolean_value,codemeta_value,composite_value,createMultiversxAdapter,findKnownTokenById,getAllMultiversxAdapters,getAllMultiversxChainNames,getMultiversxAdapter,getMultiversxRegistryAddress,getVibechainAdapter,hex_value,list_value,nothing_value,option_value,optional_value,string_value,token_value,u16_value,u32_value,u64_value,u8_value,variadic_value});
|
package/dist/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{WarpChainName as ot}from"@vleap/warps";import{WarpChainName as R}from"@vleap/warps";import{AbiRegistry as he}from"@multiversx/sdk-core";import{WarpCache as Ot,WarpCacheKey as Mt,WarpConstants as Ke,WarpLogger as Je}from"@vleap/warps";import{WarpLogger as je}from"@vleap/warps";import{Address as F,ArgSerializer as Tt,DevnetEntrypoint as bt,MainnetEntrypoint as Et,SmartContractTransactionsFactory as At,TestnetEntrypoint as Bt,Token as It,TokenComputer as Nt,TokenTransfer as Vt,TransactionsFactoryConfig as Qe,TransferTransactionsFactory as St,UserSecretKey as kt,UserSigner as Ft}from"@multiversx/sdk-core";import{applyResultsToMessages as Rt,getNextInfo as Ut,getProviderUrl as Pt,getWarpActionByIndex as de}from"@vleap/warps";import{findEventsByFirstTopic as gt,SmartContractTransactionsOutcomeParser as yt,TransactionEventsParser as wt}from"@multiversx/sdk-core";import{applyResultsToMessages as Ct,evaluateResultsCommon as $,findWarpExecutableAction as ze,getNextInfo as xt,parseResultsOutIndex as He,WarpCache as Wt,WarpCacheKey as vt,WarpConstants as Ge}from"@vleap/warps";import{Address as ut,AddressType as J,AddressValue as Be,BigUIntType as _,BigUIntValue as X,BooleanType as Y,BooleanValue as Ie,BytesType as Z,BytesValue as Ne,CodeMetadata as mt,CodeMetadataType as ee,CodeMetadataValue as Ve,CompositeType as te,CompositeValue as Se,Field as re,FieldDefinition as ne,List as ke,ListType as Fe,NothingValue as v,OptionalType as Re,OptionalValue as ae,OptionType as Ue,OptionValue as se,StringType as ie,StringValue as Pe,Struct as dt,StructType as _e,Token as ht,TokenComputer as Oe,TokenIdentifierType as O,TokenIdentifierValue as oe,U16Type as ce,U16Value as Me,U32Type as pe,U32Value as $e,U64Type as M,U64Value as le,U8Type as ue,U8Value as Le,VariadicType as me,VariadicValue as De}from"@multiversx/sdk-core";import{WarpConstants as T,WarpSerializer as ft}from"@vleap/warps";var V=i=>!i.includes("-"),P=i=>V(i)?`${i}-000000`:i;var qe=new RegExp(`${T.ArgParamsSeparator}(.*)`),B=class{constructor(){this.coreSerializer=new ft}typedToString(e){let t=e.getType();if(t.hasExactClass(Ue.ClassName)||e.hasClassOrSuperclass(se.ClassName))return e.isSet()?`option:${this.typedToString(e.getTypedValue())}`:"option:null";if(t.hasExactClass(Re.ClassName)||e.hasClassOrSuperclass(ae.ClassName))return e.isSet()?`optional:${this.typedToString(e.getTypedValue())}`:"optional:null";if(t.hasExactClass(Fe.ClassName)||e.hasClassOrSuperclass(ke.ClassName)){let r=e.getItems(),a=r.map(s=>this.typedToString(s).split(T.ArgParamsSeparator)[0])[0],o=r.map(s=>this.typedToString(s).split(T.ArgParamsSeparator)[1]);return`list:${a}:${o.join(",")}`}if(t.hasExactClass(me.ClassName)||e.hasClassOrSuperclass(De.ClassName)){let r=e.getItems(),a=r.map(s=>this.typedToString(s).split(T.ArgParamsSeparator)[0])[0],o=r.map(s=>this.typedToString(s).split(T.ArgParamsSeparator)[1]);return`variadic:${a}:${o.join(",")}`}if(t.hasExactClass(te.ClassName)||e.hasClassOrSuperclass(Se.ClassName)){let r=e.getItems(),n=r.map(c=>this.typedToString(c).split(T.ArgParamsSeparator)[0]),a=r.map(c=>this.typedToString(c).split(T.ArgParamsSeparator)[1]),o=n.join(T.ArgCompositeSeparator),s=a.join(T.ArgCompositeSeparator);return`composite(${o}):${s}`}if(t.hasExactClass(_.ClassName)||e.hasClassOrSuperclass(X.ClassName)||t.getName()==="BigUint")return`biguint:${BigInt(e.valueOf().toFixed())}`;if(t.hasExactClass(ue.ClassName)||e.hasClassOrSuperclass(Le.ClassName))return`uint8:${e.valueOf().toNumber()}`;if(t.hasExactClass(ce.ClassName)||e.hasClassOrSuperclass(Me.ClassName))return`uint16:${e.valueOf().toNumber()}`;if(t.hasExactClass(pe.ClassName)||e.hasClassOrSuperclass($e.ClassName))return`uint32:${e.valueOf().toNumber()}`;if(t.hasExactClass(M.ClassName)||e.hasClassOrSuperclass(le.ClassName))return`uint64:${BigInt(e.valueOf().toFixed())}`;if(t.hasExactClass(ie.ClassName)||e.hasClassOrSuperclass(Pe.ClassName))return`string:${e.valueOf()}`;if(t.hasExactClass(Y.ClassName)||e.hasClassOrSuperclass(Ie.ClassName))return`bool:${e.valueOf()}`;if(t.hasExactClass(J.ClassName)||e.hasClassOrSuperclass(Be.ClassName))return`address:${e.valueOf().toBech32()}`;if(t.hasExactClass(O.ClassName)||e.hasClassOrSuperclass(oe.ClassName))return`token:${e.valueOf()}`;if(t.hasExactClass(Z.ClassName)||e.hasClassOrSuperclass(Ne.ClassName))return`hex:${e.valueOf().toString("hex")}`;if(t.hasExactClass(ee.ClassName)||e.hasClassOrSuperclass(Ve.ClassName))return`codemeta:${e.valueOf().toString()}`;if(t.getName()==="EsdtTokenPayment"){let r=e.getFieldValue("token_identifier").valueOf(),n=e.getFieldValue("token_nonce").valueOf(),a=e.getFieldValue("amount").valueOf();return`asset:${new Oe().computeExtendedIdentifier(new ht({identifier:r,nonce:BigInt(n)}))}|${a}`}throw new Error(`WarpArgSerializer (typedToString): Unsupported input type: ${e.getClassName()}`)}typedToNative(e){let t=this.typedToString(e);return this.coreSerializer.stringToNative(t)}nativeToTyped(e,t){let r=this.coreSerializer.nativeToString(e,t);return this.stringToTyped(r)}nativeToType(e){if(e.startsWith("composite")){let t=e.match(/\(([^)]+)\)/)?.[1];return new te(...t.split(T.ArgCompositeSeparator).map(r=>this.nativeToType(r)))}if(e==="string")return new ie;if(e==="uint8")return new ue;if(e==="uint16")return new ce;if(e==="uint32")return new pe;if(e==="uint64")return new M;if(e==="biguint")return new _;if(e==="bool")return new Y;if(e==="address")return new J;if(e==="token")return new O;if(e==="hex")return new Z;if(e==="codemeta")return new ee;if(e==="asset")return new _e("EsdtTokenPayment",[new ne("token_identifier","",new O),new ne("token_nonce","",new M),new ne("amount","",new _)]);throw new Error(`WarpArgSerializer (nativeToType): Unsupported input type: ${e}`)}stringToTyped(e){let[t,r]=e.split(/:(.*)/,2);if(t==="null"||t===null)return new v;if(t==="option"){let n=this.stringToTyped(r);return n instanceof v?se.newMissingTyped(n.getType()):se.newProvided(n)}if(t==="optional"){let n=this.stringToTyped(r);return n instanceof v?ae.newMissing():new ae(n.getType(),n)}if(t==="list"){let[n,a]=r.split(qe,2),s=a.split(",").map(c=>this.stringToTyped(`${n}:${c}`));return new ke(this.nativeToType(n),s)}if(t==="variadic"){let[n,a]=r.split(qe,2),s=a.split(",").map(c=>this.stringToTyped(`${n}:${c}`));return new De(new me(this.nativeToType(n)),s)}if(t.startsWith("composite")){let n=t.match(/\(([^)]+)\)/)?.[1],a=r.split(T.ArgCompositeSeparator),o=n.split(T.ArgCompositeSeparator),s=a.map((p,u)=>this.stringToTyped(`${o[u]}:${p}`)),c=s.map(p=>p.getType());return new Se(new te(...c),s)}if(t==="string")return r?Pe.fromUTF8(r):new v;if(t==="uint8")return r?new Le(Number(r)):new v;if(t==="uint16")return r?new Me(Number(r)):new v;if(t==="uint32")return r?new $e(Number(r)):new v;if(t==="uint64")return r?new le(BigInt(r)):new v;if(t==="biguint")return r?new X(BigInt(r)):new v;if(t==="bool")return r?new Ie(typeof r=="boolean"?r:r==="true"):new v;if(t==="address")return r?new Be(ut.newFromBech32(r)):new v;if(t==="token")return r?new oe(r):new v;if(t==="hex")return r?Ne.fromHex(r):new v;if(t==="codemeta")return new Ve(mt.newFromBytes(Uint8Array.from(Buffer.from(r,"hex"))));if(t==="asset"){let[n,a]=r.split(T.ArgCompositeSeparator),o=new Oe,s=V(n)?P(n):o.extractIdentifierFromExtendedIdentifier(n),c=V(n)?0n:o.extractNonceFromExtendedIdentifier(n);return new dt(this.nativeToType("asset"),[new re(new oe(s),"token_identifier"),new re(new le(BigInt(c)),"token_nonce"),new re(new X(BigInt(a)),"amount")])}throw new Error(`WarpArgSerializer (stringToTyped): Unsupported input type: ${t}`)}typeToString(e){if(e.hasExactClass(Ue.ClassName))return"option:"+this.typeToString(e.getFirstTypeParameter());if(e.hasExactClass(Re.ClassName))return"optional:"+this.typeToString(e.getFirstTypeParameter());if(e.hasExactClass(Fe.ClassName))return"list:"+this.typeToString(e.getFirstTypeParameter());if(e.hasExactClass(me.ClassName))return"variadic:"+this.typeToString(e.getFirstTypeParameter());if(e.hasExactClass(ie.ClassName))return"string";if(e.hasExactClass(ue.ClassName))return"uint8";if(e.hasExactClass(ce.ClassName))return"uint16";if(e.hasExactClass(pe.ClassName))return"uint32";if(e.hasExactClass(M.ClassName))return"uint64";if(e.hasExactClass(_.ClassName))return"biguint";if(e.hasExactClass(Y.ClassName))return"bool";if(e.hasExactClass(J.ClassName))return"address";if(e.hasExactClass(O.ClassName))return"token";if(e.hasExactClass(Z.ClassName))return"hex";if(e.hasExactClass(ee.ClassName))return"codemeta";if(e.hasExactClass(_e.ClassName)&&e.getClassName()==="EsdtTokenPayment")return"asset";throw new Error(`WarpArgSerializer (typeToString): Unsupported input type: ${e.getClassName()}`)}};var S=class{constructor(e,t){this.config=e;this.chain=t;this.abi=new I(e,t),this.serializer=new B,this.cache=new Wt(e.cache?.type)}async getTransactionExecutionResults(e,t){let{actionIndex:r}=ze(e),n=this.cache.get(vt.WarpExecutable(this.config.env,e.meta?.hash||"",r))??[],a=await this.extractContractResults(e,t,n),o=xt(this.config,[],e,r,a),s=Ct(e,a.results);return{success:t.status.isSuccessful(),warp:e,action:r,user:this.config.user?.wallets?.[this.chain.name]||null,txHash:t.hash,tx:t,next:o,values:a.values,valuesRaw:[],results:a.results,messages:s}}async extractContractResults(e,t,r){let{action:n,actionIndex:a}=ze(e),o=[],s={};if(!e.results||n.type!=="contract")return{values:o,results:s};if(!Object.values(e.results).some(C=>C.includes("out")||C.includes("event"))){for(let[C,m]of Object.entries(e.results))s[C]=m;return{values:o,results:await $(e,s,a,r,this.config.transform?.runner)}}let p=await this.abi.getAbiForAction(n),u=new wt({abi:p}),y=new yt({abi:p}).parseExecute({transactionOnNetwork:t,function:n.func||void 0});for(let[C,m]of Object.entries(e.results)){if(m.startsWith(Ge.Transform.Prefix))continue;if(m.startsWith("input.")){s[C]=m;continue}let b=He(m);if(b!==null&&b!==a){s[C]=null;continue}let[x,W,A]=m.split(".");if(x==="event"){if(!W||isNaN(Number(A)))continue;let E=Number(A),g=gt(t,W),k=u.parseEvents({events:g})[0],U=Object.values(k)[E]||null;o.push(U),s[C]=U&&U.valueOf()}else if(x==="out"||x.startsWith("out[")){if(!W)continue;let E=Number(W),g=y.values[E-1]||null;A&&(g=g[A]||null),g&&typeof g=="object"&&(g="toFixed"in g?g.toFixed():g.valueOf()),o.push(g),s[C]=g&&g.valueOf()}else s[C]=m}return{values:o,results:await $(e,s,a,r)}}async extractQueryResults(e,t,r,n){let a=t.map(p=>this.serializer.typedToString(p)),o=t.map(p=>this.serializer.typedToNative(p)[1]),s={};if(!e.results)return{values:a,valuesRaw:o,results:s};let c=p=>{let u=p.split(".").slice(1).map(y=>parseInt(y)-1);if(u.length===0)return;let l=o[u[0]];for(let y=1;y<u.length;y++){if(l==null)return;l=l[u[y]]}return l};for(let[p,u]of Object.entries(e.results)){if(u.startsWith(Ge.Transform.Prefix))continue;let l=He(u);if(l!==null&&l!==r){s[p]=null;continue}u.startsWith("out.")||u==="out"||u.startsWith("out[")?s[p]=c(u)||null:s[p]=u}return{values:a,valuesRaw:o,results:await $(e,s,r,n)}}async resolveWarpResultsRecursively(e){let t=e.warp,r=e.entryActionIndex,n=e.executor,a=e.inputs,o=e.meta,s=new Map,c=new Set,p=this;async function u(m,b=[]){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 x=t.actions[m-1];if(!x)throw new Error(`Action ${m} not found`);let W;if(x.type==="query")W=await n.executeQuery(t,m,b);else if(x.type==="collect")W=await n.executeCollect(t,m,b,o);else throw new Error(`Unsupported or interactive action type: ${x.type}`);if(s.set(m,W),t.results)for(let A of Object.values(t.results)){let g=String(A).match(/^out\[(\d+)\]/);if(g){let k=parseInt(g[1],10);k!==m&&!s.has(k)&&await u(k)}}return c.delete(m),W}await u(r,a);let l={};for(let m of s.values())for(let[b,x]of Object.entries(m.results))x!==null?l[b]=x:b in l||(l[b]=null);let y=await $(t,l,r,a,this.config.transform?.runner);return{...s.get(r),action:r,results:y}}};var _t="EGLD-000000",h=class i{constructor(e,t){this.config=e;this.chain=t;this.serializer=new B,this.abi=new I(this.config,this.chain),this.results=new S(this.config,this.chain)}async createTransaction(e){let t=de(e.warp,e.action),r=null;if(t.type==="transfer")r=await this.createTransferTransaction(e);else if(t.type==="contract")r=await this.createContractCallTransaction(e);else{if(t.type==="query")throw new Error("WarpMultiversxExecutor: Invalid action type for createTransactionForExecute; Use executeQuery instead");if(t.type==="collect")throw new Error("WarpMultiversxExecutor: Invalid action type for createTransactionForExecute; Use executeCollect instead")}if(!r)throw new Error(`WarpMultiversxExecutor: Invalid action type (${t.type})`);return r}async createTransferTransaction(e){let t=this.config.user?.wallets?.[e.chain.name];if(!t)throw new Error("WarpMultiversxExecutor: createTransfer - user address not set");let r=F.newFromBech32(t),n=new Qe({chainID:e.chain.chainId}),a=e.data?Buffer.from(this.serializer.stringToTyped(e.data).valueOf()):null;return new St({config:n}).createTransactionForTransfer(r,{receiver:F.newFromBech32(e.destination),nativeAmount:e.value,tokenTransfers:this.toTokenTransfers(e.transfers),data:a?new Uint8Array(a):void 0})}async createContractCallTransaction(e){let t=this.config.user?.wallets?.[e.chain.name];if(!t)throw new Error("WarpMultiversxExecutor: createContractCall - user address not set");let r=de(e.warp,e.action),n=F.newFromBech32(t),a=e.args.map(s=>this.serializer.stringToTyped(s)),o=new Qe({chainID:e.chain.chainId});return new At({config:o}).createTransactionForExecute(n,{contract:F.newFromBech32(e.destination),function:"func"in r&&r.func||"",gasLimit:"gasLimit"in r?BigInt(r.gasLimit||0):0n,arguments:a,tokenTransfers:this.toTokenTransfers(e.transfers),nativeTransferAmount:e.value})}async executeQuery(e){let t=de(e.warp,e.action);if(t.type!=="query")throw new Error(`WarpMultiversxExecutor: Invalid action type for executeQuery: ${t.type}`);let r=await this.abi.getAbiForAction(t),n=e.args.map(E=>this.serializer.stringToTyped(E)),a=i.getChainEntrypoint(e.chain,this.config.env,this.config),o=F.newFromBech32(e.destination),s=a.createSmartContractController(r),c=s.createQuery({contract:o,function:t.func||"",arguments:n}),p=await s.runQuery(c),u=p.returnCode==="ok",l=new Tt,y=r.getEndpoint(p.function||t.func||""),C=(p.returnDataParts||[]).map(E=>Buffer.from(E)),m=l.buffersToValues(C,y.output),{values:b,valuesRaw:x,results:W}=await this.results.extractQueryResults(e.warp,m,e.action,e.resolvedInputs),A=Ut(this.config,[],e.warp,e.action,W);return{success:u,warp:e.warp,action:e.action,user:this.config.user?.wallets?.[e.chain.name]||null,txHash:null,tx:null,next:A,values:b,valuesRaw:x,results:W,messages:Rt(e.warp,W)}}static getChainEntrypoint(e,t,r){let n="warp-sdk",o=r?Pt(r,e.name,t,e.defaultApiUrl):e.defaultApiUrl;return t==="devnet"?new bt({url:o,kind:"api",clientName:n}):t==="testnet"?new Bt({url:o,kind:"api",clientName:n}):new Et({url:o,kind:"api",clientName:n})}async signMessage(e,t){let r=kt.fromString(t);return(await new Ft(r).sign(new Uint8Array(Buffer.from(e,"utf-8")))).toString()}toTokenTransfers(e){return e.map(t=>t.identifier===this.chain.nativeToken.identifier?{...t,identifier:_t}:t).map(t=>{let n=new Nt().extractNonceFromExtendedIdentifier(t.identifier);return new Vt({token:new It({identifier:t.identifier,nonce:BigInt(n||0)}),amount:t.amount})})}};var L=class{constructor(e){this.config=e}async getContract(e,t){try{let a=await h.getChainEntrypoint(t,this.config.env).createNetworkProvider().doGetGeneric(`accounts/${e}`);return{address:e,owner:a.ownerAddress,verified:a.isVerified||!1}}catch(r){return je.error("WarpContractLoader: getContract error",r),null}}async getVerificationInfo(e,t){try{let a=await h.getChainEntrypoint(t,this.config.env).createNetworkProvider().doGetGeneric(`accounts/${e}/verification`);return{codeHash:a.codeHash,abi:a.source.abi}}catch(r){return je.error("WarpContractLoader: getVerificationInfo error",r),null}}};var I=class{constructor(e,t){this.config=e;this.chain=t;this.contractLoader=new L(this.config),this.cache=new Ot(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=Mt.WarpAbi(this.config.env,e);if(t){let o=this.cache.get(r);if(o)return Je.info(`WarpAbiBuilder (createFromTransactionHash): Warp abi found in cache: ${e}`),o}let a=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 Je.error("WarpAbiBuilder: Error creating from transaction hash",o),null}}async getAbiForAction(e){if(e.abi)return await this.fetchAbi(e);if(!e.address)throw new Error("WarpActionExecutor: Address not found");let t=await this.contractLoader.getVerificationInfo(e.address,this.chain);if(!t)throw new Error("WarpActionExecutor: Verification info not found");return he.create(t.abi)}async fetchAbi(e){if(!e.abi)throw new Error("WarpActionExecutor: ABI not found");if(e.abi.startsWith(Ke.IdentifierType.Hash)){let t=e.abi.split(Ke.IdentifierParamSeparatorDefault)[1],r=await this.createFromTransactionHash(t);if(!r)throw new Error(`WarpActionExecutor: ABI not found for hash: ${e.abi}`);return he.create(r.content)}else{let r=await(await fetch(e.abi)).json();return he.create(r)}}};import{Address as Xe,TransactionsFactoryConfig as $t,TransferTransactionsFactory as Lt}from"@multiversx/sdk-core";import{WarpBrandBuilder as Dt,WarpLogger as qt}from"@vleap/warps";import{Buffer as zt}from"buffer";var D=class{constructor(e,t){this.config=e;this.chain=t;this.core=new Dt(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 $t({chainID:this.chain.chainId}),n=new Lt({config:r}),a=Xe.newFromBech32(t),o=JSON.stringify(e);return await n.createTransactionForNativeTokenTransfer(a,{receiver:Xe.newFromBech32(t),nativeAmount:BigInt(0),data:Uint8Array.from(zt.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 qt.error("BrandBuilder: Error creating from transaction hash",n),null}}};import{Address as Ye,TransactionsFactoryConfig as Ht,TransferTransactionsFactory as Gt}from"@multiversx/sdk-core";import{WarpBuilder as Ze,WarpCache as Qt,WarpCacheKey as jt,WarpLogger as et}from"@vleap/warps";var q=class extends Ze{constructor(t,r){super(t);this.config=t;this.chain=r;this.cache=new Qt(t.cache?.type),this.core=new Ze(t)}async createInscriptionTransaction(t){let r=this.config.user?.wallets?.[this.chain.name];if(!r)throw new Error("WarpBuilder: user address not set");let n=new Ht({chainID:this.chain.chainId}),a=new Gt({config:n}),o=Ye.newFromBech32(r),s=JSON.stringify(t),c=await a.createTransactionForTransfer(o,{receiver:Ye.newFromBech32(r),nativeAmount:BigInt(0),data:Uint8Array.from(Buffer.from(s))});return c.gasLimit=c.gasLimit+BigInt(2e6),c}async createFromTransaction(t,r=!1){let n=await this.core.createFromRaw(t.data.toString(),r);return n.meta={chain:this.chain.name,hash:t.hash,creator:t.sender.toBech32(),createdAt:new Date(t.timestamp*1e3).toISOString()},n}async createFromTransactionHash(t,r){let n=jt.Warp(this.config.env,t);if(r){let s=this.cache.get(n);if(s)return et.info(`WarpBuilder (createFromTransactionHash): Warp found in cache: ${t}`),s}let o=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 et.error("WarpBuilder: Error creating from transaction hash",s),null}}};import{Address as fe,Token as Xt,TokenComputer as Yt}from"@multiversx/sdk-core";import{CacheTtl as Zt,WarpCache as er,WarpCacheKey as tr}from"@vleap/warps";import{WarpChainName as Kt}from"@vleap/warps";var z=Kt.Multiversx,Jt=[{chain:z,identifier:"EGLD",name:"eGold",symbol:"EGLD",decimals:18,logoUrl:"https://tools.multiversx.com/assets-cdn/tokens/EGLD-000000/icon.pngsvg"},{chain:z,identifier:"EGLD-000000",name:"eGold",symbol:"EGLD",decimals:18,logoUrl:"https://tools.multiversx.com/assets-cdn/tokens/EGLD-000000/icon.png"},{chain:z,identifier:"VIBE",name:"VIBE",symbol:"VIBE",decimals:18,logoUrl:"https://vleap.ai/images/tokens/vibe.svg"},{chain:z,identifier:"VIBE-000000",name:"VIBE",symbol:"VIBE",decimals:18,logoUrl:"https://vleap.ai/images/tokens/vibe.svg"}],tt=i=>Jt.find(e=>e.identifier===i)||null;var H=class{constructor(e,t){this.config=e;this.chain=t;this.cache=new er(e.cache?.type)}async getAccount(e){let r=await h.getChainEntrypoint(this.chain,this.config.env,this.config).createNetworkProvider().getAccount(fe.newFromBech32(e));return{chain:this.chain.name,address:r.address.toBech32(),balance:r.balance}}async getAccountAssets(e){let t=h.getChainEntrypoint(this.chain,this.config.env,this.config).createNetworkProvider(),r=t.getAccount(fe.newFromBech32(e)),n=t.getFungibleTokensOfAccount(fe.newFromBech32(e)),[a,o]=await Promise.all([r,n]),s=a.balance>0?[{...this.chain.nativeToken,amount:a.balance}]:[];return s.push(...o.map(c=>({chain:this.chain.name,identifier:c.token.identifier,name:c.raw.name,symbol:c.raw.ticker,amount:c.amount,decimals:c.raw.decimals,logoUrl:c.raw.assets?.pngUrl||""}))),s}async getAsset(e){let t=tr.Asset(this.config.env,this.chain.name,e),r=this.cache.get(t);if(r)return r;let n=tt(e);if(n)return{chain:this.chain.name,identifier:e,name:n.name,symbol:n.symbol,amount:0n,decimals:n.decimals,logoUrl:n.logoUrl};let a=new Yt,o=V(e)?0n:a.extractNonceFromExtendedIdentifier(e),s=new Xt({identifier:e,nonce:BigInt(o||0)}),c=a.isFungible(s),p=h.getChainEntrypoint(this.chain,this.config.env,this.config).createNetworkProvider(),u=P(e),l=await p.doGetGeneric(`tokens/${u}`),y={chain:this.chain.name,identifier:s.identifier,name:l.name,symbol:l.ticker,amount:0n,decimals:l.decimals,logoUrl:l.assets?.pngUrl||"#"};return this.cache.set(t,y,Zt.OneHour),y}async getAction(e,t=!1){let r=h.getChainEntrypoint(this.chain,this.config.env,this.config),n=t?await r.awaitCompletedTransaction(e):await r.getTransaction(e);return{chain:this.chain.name,id:n.hash,receiver:n.receiver.toBech32(),sender:n.sender.toBech32(),value:n.value,function:n.function,status:this.toActionStatus(n),createdAt:this.toActionCreatedAt(n),error:n?.smartContractResults.map(a=>a.raw.returnMessage)[0]||null,tx:n}}async getAccountActions(e,t){let r=h.getChainEntrypoint(this.chain,this.config.env,this.config).createNetworkProvider(),n=`accounts/${e}/transactions`,a=new URLSearchParams,o=t?.size||25,s=t?.page||0;if(s>0){let p=s*o;a.append("from",p.toString())}return o!==25&&a.append("size",o.toString()),a.toString()&&(n+=`?${a.toString()}`),(await r.doGetGeneric(n)).map(p=>({chain:this.chain.name,id:p.txHash,receiver:p.receiver,sender:p.sender,value:p.value,function:p.function,status:this.toActionStatus(p),createdAt:this.toActionCreatedAt(p)}))}toActionStatus(e){return e.status.isSuccessful()?"success":e.status.isFailed()?"failed":"pending"}toActionCreatedAt(e){return new Date(e.timestamp||e.timestamp*1e3).toISOString()}};var Aa={Egld:{Identifier:"EGLD",EsdtIdentifier:"EGLD-000000",DisplayName:"eGold",Decimals:18}},rr=(r=>(r.MultiversxExplorer="multiversx_explorer",r.MultiversxExplorerDevnet="multiversx_explorer_devnet",r.MultiversxExplorerTestnet="multiversx_explorer_testnet",r))(rr||{}),nr=(r=>(r.VibechainExplorer="vibechain_explorer",r.VibechainExplorerDevnet="vibechain_explorer_devnet",r.VibechainExplorerTestnet="vibechain_explorer_testnet",r))(nr||{}),rt={multiversx:{mainnet:["multiversx_explorer"],testnet:["multiversx_explorer_testnet"],devnet:["multiversx_explorer_devnet"]},vibechain:{mainnet:["vibechain_explorer"],testnet:["vibechain_explorer_testnet"],devnet:["vibechain_explorer_devnet"]}},N={multiversx_explorer:"https://explorer.multiversx.com",multiversx_explorer_devnet:"https://devnet-explorer.multiversx.com",multiversx_explorer_testnet:"https://testnet-explorer.multiversx.com",vibechain_explorer:"https://vibeox-explorer.multiversx.com",vibechain_explorer_devnet:"https://vibeox-explorer.multiversx.com",vibechain_explorer_testnet:"https://vibeox-explorer.multiversx.com"};var G=class{constructor(e,t){this.chain=e;this.config=t}getExplorers(){let e=rt[this.chain];if(!e)return["multiversx_explorer"];let t=e[this.config.env];return t||["multiversx_explorer"]}getPrimaryExplorer(){return this.getExplorers()[0]}getExplorerUrlByName(e){let t=this.config.preferences?.explorers?.[this.chain];if(t&&!e){let a=N[t];if(a)return a}if(e){let a=N[e];if(a)return a}let r=this.getPrimaryExplorer();return N[r]||N[r]}getAccountUrl(e,t){return`${this.getExplorerUrlByName(t)}/accounts/${e}`}getTransactionUrl(e,t){return`${this.getExplorerUrlByName(t)}/transactions/${e}`}getBlockUrl(e,t){return`${this.getExplorerUrlByName(t)}/blocks/${e}`}getAssetUrl(e,t){return`${this.getExplorerUrlByName(t)}/tokens/${e}`}getContractUrl(e,t){return`${this.getExplorerUrlByName(t)}/accounts/${e}`}getAllExplorers(){return this.getExplorers()}getExplorerByName(e){return this.getExplorers().find(r=>r.toLowerCase()===e.toLowerCase())}getAccountUrls(e){let t=this.getAllExplorers(),r={};return t.forEach(n=>{let a=N[n];a&&(r[n]=`${a}/accounts/${e}`)}),r}getTransactionUrls(e){let t=this.getAllExplorers(),r={};return t.forEach(n=>{let a=N[n];a&&(r[n]=`${a}/transactions/${e}`)}),r}};import{AbiRegistry as at,Address as d,AddressValue as ye,BytesValue as f,SmartContractTransactionsFactory as sr,TransactionsFactoryConfig as ir}from"@multiversx/sdk-core";import{WarpCache as or,WarpCacheKey as we,WarpLogger as Ce}from"@vleap/warps";var ge={buildInfo:{rustc:{version:"1.86.0",commitHash:"05f9846f893b09a1be1fc8560e33fc3c815cfecb",commitDate:"2025-03-31",channel:"Stable",short:"rustc 1.86.0 (05f9846f8 2025-03-31)"},contractCrate:{name:"registry",version:"0.0.1"},framework:{name:"multiversx-sc",version:"0.51.1"}},name:"RegistryContract",constructor:{inputs:[{name:"unit_price",type:"BigUint"},{name:"vault",type:"Address"}],outputs:[]},upgradeConstructor:{inputs:[],outputs:[]},endpoints:[{name:"registerWarp",mutability:"mutable",payableInTokens:["EGLD"],inputs:[{name:"hash",type:"bytes"},{name:"alias_opt",type:"optional<bytes>",multi_arg:!0},{name:"brand_opt",type:"optional<bytes>",multi_arg:!0}],outputs:[],allow_multiple_var_args:!0},{name:"unregisterWarp",mutability:"mutable",inputs:[{name:"warp",type:"bytes"}],outputs:[]},{name:"upgradeWarp",mutability:"mutable",payableInTokens:["EGLD"],inputs:[{name:"alias",type:"bytes"},{name:"new_warp",type:"bytes"}],outputs:[]},{name:"setWarpAlias",mutability:"mutable",payableInTokens:["EGLD"],inputs:[{name:"hash",type:"bytes"},{name:"alias",type:"bytes"}],outputs:[]},{name:"forceRemoveAlias",mutability:"mutable",inputs:[{name:"hash",type:"bytes"}],outputs:[]},{name:"verifyWarp",mutability:"mutable",inputs:[{name:"warp",type:"bytes"}],outputs:[]},{name:"transferOwnership",mutability:"mutable",inputs:[{name:"warp",type:"bytes"},{name:"new_owner",type:"Address"}],outputs:[]},{name:"getUserWarps",mutability:"readonly",inputs:[{name:"address",type:"Address"}],outputs:[{type:"variadic<InfoView>",multi_result:!0}]},{name:"getInfoByAlias",mutability:"readonly",inputs:[{name:"alias",type:"bytes"}],outputs:[{type:"InfoView"}]},{name:"getInfoByHash",mutability:"readonly",inputs:[{name:"hash",type:"bytes"}],outputs:[{type:"InfoView"}]},{name:"setVault",onlyOwner:!0,mutability:"mutable",inputs:[{name:"vault",type:"Address"}],outputs:[]},{name:"setUnitPrice",onlyOwner:!0,mutability:"mutable",inputs:[{name:"amount",type:"BigUint"}],outputs:[]},{name:"addAdmin",onlyOwner:!0,mutability:"mutable",inputs:[{name:"address",type:"Address"}],outputs:[]},{name:"removeAdmin",onlyOwner:!0,mutability:"mutable",inputs:[{name:"address",type:"Address"}],outputs:[]},{name:"getConfig",mutability:"readonly",inputs:[],outputs:[{type:"ConfigView"}]},{name:"registerBrand",mutability:"mutable",payableInTokens:["EGLD"],inputs:[{name:"hash",type:"bytes"}],outputs:[]},{name:"brandWarp",mutability:"mutable",payableInTokens:["EGLD"],inputs:[{name:"warp",type:"bytes"},{name:"brand",type:"bytes"}],outputs:[]},{name:"getUserBrands",mutability:"readonly",inputs:[{name:"user",type:"Address"}],outputs:[{type:"variadic<bytes>",multi_result:!0}]},{name:"setChain",onlyOwner:!0,mutability:"mutable",inputs:[{name:"name",type:"bytes"},{name:"display_name",type:"bytes"},{name:"chain_id",type:"bytes"},{name:"block_time",type:"u32"},{name:"address_hrp",type:"bytes"},{name:"api_url",type:"bytes"},{name:"explorer_url",type:"bytes"},{name:"native_token",type:"bytes"}],outputs:[]},{name:"removeChain",onlyOwner:!0,mutability:"mutable",inputs:[{name:"name",type:"bytes"}],outputs:[]},{name:"getChain",mutability:"readonly",inputs:[{name:"name",type:"bytes"}],outputs:[{type:"ChainView"}]},{name:"getChains",mutability:"readonly",inputs:[],outputs:[{type:"variadic<ChainView>",multi_result:!0}]}],events:[{identifier:"warpRegistered",inputs:[{name:"hash",type:"bytes",indexed:!0},{name:"alias",type:"bytes",indexed:!0},{name:"trust",type:"bytes",indexed:!0}]},{identifier:"warpUnregistered",inputs:[{name:"hash",type:"bytes",indexed:!0}]},{identifier:"warpUpgraded",inputs:[{name:"alias",type:"bytes",indexed:!0},{name:"new_warp",type:"bytes",indexed:!0},{name:"trust",type:"bytes",indexed:!0}]},{identifier:"warpVerified",inputs:[{name:"hash",type:"bytes",indexed:!0}]},{identifier:"aliasUpdated",inputs:[{name:"hash",type:"bytes",indexed:!0},{name:"alias",type:"bytes",indexed:!0}]},{identifier:"ownershipTransferred",inputs:[{name:"warp",type:"bytes",indexed:!0},{name:"old_owner",type:"Address",indexed:!0},{name:"new_owner",type:"Address",indexed:!0}]}],esdtAttributes:[],hasCallback:!1,types:{ChainView:{type:"struct",fields:[{name:"name",type:"bytes"},{name:"display_name",type:"bytes"},{name:"chain_id",type:"bytes"},{name:"block_time",type:"u32"},{name:"address_hrp",type:"bytes"},{name:"api_url",type:"bytes"},{name:"explorer_url",type:"bytes"},{name:"native_token",type:"bytes"}]},ConfigView:{type:"struct",fields:[{name:"unit_price",type:"BigUint"},{name:"admins",type:"List<Address>"}]},InfoView:{type:"struct",fields:[{name:"hash",type:"bytes"},{name:"alias",type:"Option<bytes>"},{name:"trust",type:"bytes"},{name:"owner",type:"Address"},{name:"created_at",type:"u64"},{name:"upgraded_at",type:"u64"},{name:"brand",type:"Option<bytes>"},{name:"upgrade",type:"Option<bytes>"}]}}};var w=i=>{if(i==="devnet")return"erd1qqqqqqqqqqqqqpgqje2f99vr6r7sk54thg03c9suzcvwr4nfl3tsfkdl36";if(i==="testnet")throw new Error("Multiversx testnet is not supported");return"erd1qqqqqqqqqqqqqpgq3mrpj3u6q7tejv6d7eqhnyd27n9v5c5tl3ts08mffe"};var Q=i=>({hash:i.hash.toString("hex"),alias:i.alias?.toString()||null,trust:i.trust.toString(),owner:i.owner.toString(),createdAt:i.created_at.toNumber(),upgradedAt:i.upgraded_at?.toNumber(),brand:i.brand?.toString("hex")||null,upgrade:i.upgrade?.toString("hex")||null}),nt=i=>({unitPrice:BigInt(i.unit_price.toString()),admins:i.admins.map(e=>e.toBech32())});var j=class{constructor(e,t){this.config=e;this.chain=t;this.cache=new or(e.cache?.type),this.registryConfig={unitPrice:BigInt(0),admins:[]},this.userWallet=this.config.user?.wallets?.[this.chain.name]||null}async init(){await this.loadRegistryConfigs()}getRegistryConfig(){return this.registryConfig}async createWarpRegisterTransaction(e,t,r){if(this.registryConfig.unitPrice===BigInt(0))throw new Error("WarpRegistry: config not loaded. forgot to call init()?");if(!this.userWallet)throw new Error("WarpRegistry: user address not set");let n=d.newFromBech32(this.userWallet),a=()=>this.isCurrentUserAdmin()?BigInt(0):t&&r?this.registryConfig.unitPrice*BigInt(3):t?this.registryConfig.unitPrice*BigInt(2):this.registryConfig.unitPrice,o=()=>t&&r?[f.fromHex(e),f.fromUTF8(t),f.fromHex(r)]:t?[f.fromHex(e),f.fromUTF8(t)]:[f.fromHex(e)];return await this.getFactory().createTransactionForExecute(n,{contract:d.newFromBech32(w(this.config.env)),function:"registerWarp",gasLimit:BigInt(1e7),nativeTransferAmount:a(),arguments:o()})}async createWarpUnregisterTransaction(e){if(!this.userWallet)throw new Error("WarpRegistry: user address not set");let t=d.newFromBech32(this.userWallet);return await this.getFactory().createTransactionForExecute(t,{contract:d.newFromBech32(w(this.config.env)),function:"unregisterWarp",gasLimit:BigInt(1e7),arguments:[f.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=d.newFromBech32(this.userWallet);return await this.getFactory().createTransactionForExecute(r,{contract:d.newFromBech32(w(this.config.env)),function:"upgradeWarp",gasLimit:BigInt(1e7),nativeTransferAmount:this.isCurrentUserAdmin()?void 0:this.registryConfig.unitPrice,arguments:[f.fromUTF8(e),f.fromHex(t)]})}async createWarpAliasSetTransaction(e,t){if(!this.userWallet)throw new Error("WarpRegistry: user address not set");let r=d.newFromBech32(this.userWallet);return await this.getFactory().createTransactionForExecute(r,{contract:d.newFromBech32(w(this.config.env)),function:"setWarpAlias",gasLimit:BigInt(1e7),nativeTransferAmount:this.isCurrentUserAdmin()?void 0:this.registryConfig.unitPrice,arguments:[f.fromHex(e),f.fromUTF8(t)]})}async createWarpVerifyTransaction(e){if(!this.userWallet)throw new Error("WarpRegistry: user address not set");let t=d.newFromBech32(this.userWallet);return await this.getFactory().createTransactionForExecute(t,{contract:d.newFromBech32(w(this.config.env)),function:"verifyWarp",gasLimit:BigInt(1e7),arguments:[f.fromHex(e)]})}async createWarpTransferOwnershipTransaction(e,t){if(!this.userWallet)throw new Error("WarpRegistry: user address not set");let r=d.newFromBech32(this.userWallet);return await this.getFactory().createTransactionForExecute(r,{contract:d.newFromBech32(w(this.config.env)),function:"transferOwnership",gasLimit:BigInt(1e7),arguments:[f.fromHex(e),new ye(new d(t))]})}async createBrandRegisterTransaction(e){if(this.registryConfig.unitPrice===BigInt(0))throw new Error("WarpRegistry: config not loaded. forgot to call init()?");if(!this.userWallet)throw new Error("WarpRegistry: user address not set");let t=d.newFromBech32(this.userWallet);return await this.getFactory().createTransactionForExecute(t,{contract:d.newFromBech32(w(this.config.env)),function:"registerBrand",gasLimit:BigInt(1e7),nativeTransferAmount:this.isCurrentUserAdmin()?void 0:this.registryConfig.unitPrice,arguments:[f.fromHex(e)]})}async createWarpBrandingTransaction(e,t){if(!this.userWallet)throw new Error("WarpRegistry: user address not set");let r=d.newFromBech32(this.userWallet);return await this.getFactory().createTransactionForExecute(r,{contract:d.newFromBech32(w(this.config.env)),function:"brandWarp",gasLimit:BigInt(1e7),nativeTransferAmount:this.isCurrentUserAdmin()?void 0:this.registryConfig.unitPrice,arguments:[f.fromHex(e),f.fromHex(t)]})}async getInfoByAlias(e,t){try{let r=we.RegistryInfo(this.config.env,e),n=t?this.cache.get(r):null;if(n)return Ce.info(`WarpRegistry (getInfoByAlias): RegistryInfo found in cache: ${e}`),n;let a=d.newFromBech32(w(this.config.env)),o=this.getController(),s=o.createQuery({contract:a,function:"getInfoByAlias",arguments:[f.fromUTF8(e)]}),c=await o.runQuery(s),[p]=o.parseQueryResponse(c),u=p?Q(p):null,l=u?.brand?await this.fetchBrand(u.brand):null;return t&&t.ttl&&this.cache.set(r,{registryInfo:u,brand:l},t.ttl),{registryInfo:u,brand:l}}catch{return{registryInfo:null,brand:null}}}async getInfoByHash(e,t){try{let r=we.RegistryInfo(this.config.env,e);if(t){let l=this.cache.get(r);if(l)return Ce.info(`WarpRegistry (getInfoByHash): RegistryInfo found in cache: ${e}`),l}let n=d.newFromBech32(w(this.config.env)),a=this.getController(),o=a.createQuery({contract:n,function:"getInfoByHash",arguments:[f.fromHex(e)]}),s=await a.runQuery(o),[c]=a.parseQueryResponse(s),p=c?Q(c):null,u=p?.brand?await this.fetchBrand(p.brand):null;return t&&t.ttl&&this.cache.set(r,{registryInfo:p,brand:u},t.ttl),{registryInfo:p,brand:u}}catch{return{registryInfo:null,brand:null}}}async getUserWarpRegistryInfos(e){try{let t=e||this.userWallet;if(!t)throw new Error("WarpRegistry: user address not set");let r=d.newFromBech32(w(this.config.env)),n=this.getController(),a=n.createQuery({contract:r,function:"getUserWarps",arguments:[new ye(new d(t))]}),o=await n.runQuery(a),[s]=n.parseQueryResponse(o);return s.map(Q)}catch{return[]}}async getUserBrands(e){try{let t=e||this.userWallet;if(!t)throw new Error("WarpRegistry: user address not set");let r=d.newFromBech32(w(this.config.env)),n=this.getController(),a=n.createQuery({contract:r,function:"getUserBrands",arguments:[new ye(new d(t))]}),o=await n.runQuery(a),[s]=n.parseQueryResponse(o),c=s.map(l=>l.toString("hex")),p={ttl:365*24*60*60};return(await Promise.all(c.map(l=>this.fetchBrand(l,p)))).filter(l=>l!==null)}catch{return[]}}async fetchBrand(e,t){let r=we.Brand(this.config.env,e),n=t?this.cache.get(r):null;if(n)return Ce.info(`WarpRegistry (fetchBrand): Brand found in cache: ${e}`),n;let o=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=d.newFromBech32(w(this.config.env)),t=this.getController(),[r]=await t.query({contract:e,function:"getConfig",arguments:[]}),n=r?nt(r):null;this.registryConfig=n||{unitPrice:BigInt(0),admins:[]}}getFactory(){let e=new ir({chainID:this.chain.chainId}),t=at.create(ge);return new sr({config:e,abi:t})}getController(){let e=h.getChainEntrypoint(this.chain,this.config.env),t=at.create(ge);return e.createSmartContractController(t)}isCurrentUserAdmin(){return!!this.userWallet&&this.registryConfig.admins.includes(this.userWallet)}};var K=(i,e,t)=>(r,n)=>{let a=t[r.env];return{chain:i,chainInfo:a,prefix:e,builder:()=>new q(r,a),executor:new h(r,a),results:new S(r,a),serializer:new B,registry:new j(r,a),explorer:new G(i,r),abiBuilder:()=>new I(r,a),brandBuilder:()=>new D(r,a),dataLoader:new H(r,a),registerTypes:o=>{o.registerType("token",{stringToNative:s=>s,nativeToString:s=>`token:${s}`}),o.registerType("codemeta",{stringToNative:s=>s,nativeToString:s=>`codemeta:${s}`})}}};var xe={chain:R.Multiversx,identifier:"EGLD",name:"eGold",symbol:"EGLD",decimals:18,logoUrl:"https://vleap.ai/images/tokens/egld.svg"},st=K(R.Multiversx,"mvx",{mainnet:{name:R.Multiversx,displayName:"MultiversX",chainId:"1",blockTime:6e3,addressHrp:"erd",defaultApiUrl:"https://api.multiversx.com",nativeToken:xe},testnet:{name:R.Multiversx,displayName:"MultiversX Testnet",chainId:"T",blockTime:6e3,addressHrp:"erd",defaultApiUrl:"https://testnet-api.multiversx.com",nativeToken:xe},devnet:{name:R.Multiversx,displayName:"MultiversX Devnet",chainId:"D",blockTime:6e3,addressHrp:"erd",defaultApiUrl:"https://devnet-api.multiversx.com",nativeToken:xe}});import{WarpChainName as ve}from"@vleap/warps";var cr={chain:ve.Vibechain,identifier:"VIBE",name:"VIBE",symbol:"VIBE",decimals:18,logoUrl:"https://vleap.ai/images/tokens/vibe.svg"},We={name:ve.Vibechain,displayName:"VibeChain",chainId:"V",blockTime:600,addressHrp:"vibe",defaultApiUrl:"https://vibeox-api.multiversx.com",nativeToken:cr},it=K(ve.Vibechain,"vibe",{mainnet:We,testnet:We,devnet:We});var Ws=(i,e)=>[st(i,e),it(i,e)],vs=()=>[ot.Multiversx,ot.Vibechain];import{Address as pr,AddressValue as lr,BigUIntType as ur,BigUIntValue as ct,BooleanValue as mr,BytesValue as dr,CodeMetadata as hr,CodeMetadataValue as fr,CompositeType as gr,CompositeValue as yr,Field as Te,FieldDefinition as be,List as wr,NothingValue as Cr,OptionalValue as Ee,OptionValue as Ae,StringValue as xr,Struct as Wr,StructType as vr,TokenIdentifierType as Tr,TokenIdentifierValue as pt,U16Value as br,U32Value as Er,U64Type as Ar,U64Value as lt,U8Value as Br,VariadicValue as Ir}from"@multiversx/sdk-core";var Fs=(i,e)=>i?Ae.newProvided(i):e?Ae.newMissingTyped(e):Ae.newMissing(),Rs=(i,e)=>i?new Ee(i.getType(),i):e?new Ee(e):Ee.newMissing(),Us=i=>{if(i.length===0)throw new Error("Cannot create a list from an empty array");let e=i[0].getType();return new wr(e,i)},Ps=i=>Ir.fromItems(...i),_s=i=>{let e=i.map(t=>t.getType());return new yr(new gr(...e),i)},Os=i=>xr.fromUTF8(i),Ms=i=>new Br(i),$s=i=>new br(i),Ls=i=>new Er(i),Ds=i=>new lt(i),qs=i=>new ct(BigInt(i)),zs=i=>new mr(i),Hs=i=>new lr(pr.newFromBech32(i)),Gs=i=>new pt(i),Qs=i=>dr.fromHex(i),js=i=>new Wr(new vr("EsdtTokenPayment",[new be("token_identifier","",new Tr),new be("token_nonce","",new Ar),new be("amount","",new ur)]),[new Te(new pt(i.token.identifier),"token_identifier"),new Te(new lt(BigInt(i.token.nonce)),"token_nonce"),new Te(new ct(BigInt(i.amount)),"amount")]),Ks=i=>new fr(hr.newFromBytes(Uint8Array.from(Buffer.from(i,"hex")))),Js=()=>new Cr;export{N as ExplorerUrls,Jt as KnownTokens,rr as MultiversxExplorers,rt as MultiversxExplorersConfig,xe as NativeTokenEgld,cr as NativeTokenVibe,nr as VibechainExplorers,I as WarpMultiversxAbiBuilder,D as WarpMultiversxBrandBuilder,q as WarpMultiversxBuilder,Aa as WarpMultiversxConstants,L as WarpMultiversxContractLoader,H as WarpMultiversxDataLoader,h as WarpMultiversxExecutor,G as WarpMultiversxExplorer,j as WarpMultiversxRegistry,S as WarpMultiversxResults,B as WarpMultiversxSerializer,Hs as address_value,js as asset_value,qs as biguint_value,zs as boolean_value,Ks as codemeta_value,_s as composite_value,K as createMultiversxAdapter,tt as findKnownTokenById,Ws as getAllMultiversxAdapters,vs as getAllMultiversxChainNames,st as getMultiversxAdapter,w as getMultiversxRegistryAddress,it as getVibechainAdapter,Qs as hex_value,Us as list_value,Js as nothing_value,Fs as option_value,Rs as optional_value,Os as string_value,Gs as token_value,$s as u16_value,Ls as u32_value,Ds as u64_value,Ms as u8_value,Ps as variadic_value};
|
|
1
|
+
import{WarpChainName as ot}from"@vleap/warps";import{WarpChainName as R}from"@vleap/warps";import{AbiRegistry as he,Address as Ot,TransactionsFactoryConfig as Mt,TransferTransactionsFactory as $t}from"@multiversx/sdk-core";import{getLatestProtocolIdentifier as Lt,WarpCache as Dt,WarpCacheKey as qt,WarpConstants as Ke,WarpLogger as Je}from"@vleap/warps";import{WarpLogger as je}from"@vleap/warps";import{Address as F,ArgSerializer as vt,DevnetEntrypoint as bt,MainnetEntrypoint as Et,SmartContractTransactionsFactory as At,TestnetEntrypoint as Bt,Token as It,TokenComputer as Nt,TokenTransfer as Vt,TransactionsFactoryConfig as Qe,TransferTransactionsFactory as St,UserSecretKey as kt,UserSigner as Ft}from"@multiversx/sdk-core";import{applyResultsToMessages as Rt,getNextInfo as Ut,getProviderUrl as Pt,getWarpActionByIndex as de}from"@vleap/warps";import{findEventsByFirstTopic as gt,SmartContractTransactionsOutcomeParser as yt,TransactionEventsParser as wt}from"@multiversx/sdk-core";import{applyResultsToMessages as Ct,evaluateResultsCommon as $,findWarpExecutableAction as ze,getNextInfo as xt,parseResultsOutIndex as He,WarpCache as Wt,WarpCacheKey as Tt,WarpConstants as Ge}from"@vleap/warps";import{Address as ut,AddressType as J,AddressValue as Be,BigUIntType as _,BigUIntValue as X,BooleanType as Y,BooleanValue as Ie,BytesType as Z,BytesValue as Ne,CodeMetadata as mt,CodeMetadataType as ee,CodeMetadataValue as Ve,CompositeType as te,CompositeValue as Se,Field as re,FieldDefinition as ne,List as ke,ListType as Fe,NothingValue as T,OptionalType as Re,OptionalValue as ae,OptionType as Ue,OptionValue as se,StringType as ie,StringValue as Pe,Struct as dt,StructType as _e,Token as ht,TokenComputer as Oe,TokenIdentifierType as O,TokenIdentifierValue as oe,U16Type as ce,U16Value as Me,U32Type as pe,U32Value as $e,U64Type as M,U64Value as le,U8Type as ue,U8Value as Le,VariadicType as me,VariadicValue as De}from"@multiversx/sdk-core";import{WarpConstants as v,WarpSerializer as ft}from"@vleap/warps";var V=i=>!i.includes("-"),P=i=>V(i)?`${i}-000000`:i;var qe=new RegExp(`${v.ArgParamsSeparator}(.*)`),B=class{constructor(){this.coreSerializer=new ft}typedToString(e){let t=e.getType();if(t.hasExactClass(Ue.ClassName)||e.hasClassOrSuperclass(se.ClassName))return e.isSet()?`option:${this.typedToString(e.getTypedValue())}`:"option:null";if(t.hasExactClass(Re.ClassName)||e.hasClassOrSuperclass(ae.ClassName))return e.isSet()?`optional:${this.typedToString(e.getTypedValue())}`:"optional:null";if(t.hasExactClass(Fe.ClassName)||e.hasClassOrSuperclass(ke.ClassName)){let r=e.getItems(),a=r.map(s=>this.typedToString(s).split(v.ArgParamsSeparator)[0])[0],o=r.map(s=>this.typedToString(s).split(v.ArgParamsSeparator)[1]);return`list:${a}:${o.join(",")}`}if(t.hasExactClass(me.ClassName)||e.hasClassOrSuperclass(De.ClassName)){let r=e.getItems(),a=r.map(s=>this.typedToString(s).split(v.ArgParamsSeparator)[0])[0],o=r.map(s=>this.typedToString(s).split(v.ArgParamsSeparator)[1]);return`variadic:${a}:${o.join(",")}`}if(t.hasExactClass(te.ClassName)||e.hasClassOrSuperclass(Se.ClassName)){let r=e.getItems(),n=r.map(c=>this.typedToString(c).split(v.ArgParamsSeparator)[0]),a=r.map(c=>this.typedToString(c).split(v.ArgParamsSeparator)[1]),o=n.join(v.ArgCompositeSeparator),s=a.join(v.ArgCompositeSeparator);return`composite(${o}):${s}`}if(t.hasExactClass(_.ClassName)||e.hasClassOrSuperclass(X.ClassName)||t.getName()==="BigUint")return`biguint:${BigInt(e.valueOf().toFixed())}`;if(t.hasExactClass(ue.ClassName)||e.hasClassOrSuperclass(Le.ClassName))return`uint8:${e.valueOf().toNumber()}`;if(t.hasExactClass(ce.ClassName)||e.hasClassOrSuperclass(Me.ClassName))return`uint16:${e.valueOf().toNumber()}`;if(t.hasExactClass(pe.ClassName)||e.hasClassOrSuperclass($e.ClassName))return`uint32:${e.valueOf().toNumber()}`;if(t.hasExactClass(M.ClassName)||e.hasClassOrSuperclass(le.ClassName))return`uint64:${BigInt(e.valueOf().toFixed())}`;if(t.hasExactClass(ie.ClassName)||e.hasClassOrSuperclass(Pe.ClassName))return`string:${e.valueOf()}`;if(t.hasExactClass(Y.ClassName)||e.hasClassOrSuperclass(Ie.ClassName))return`bool:${e.valueOf()}`;if(t.hasExactClass(J.ClassName)||e.hasClassOrSuperclass(Be.ClassName))return`address:${e.valueOf().toBech32()}`;if(t.hasExactClass(O.ClassName)||e.hasClassOrSuperclass(oe.ClassName))return`token:${e.valueOf()}`;if(t.hasExactClass(Z.ClassName)||e.hasClassOrSuperclass(Ne.ClassName))return`hex:${e.valueOf().toString("hex")}`;if(t.hasExactClass(ee.ClassName)||e.hasClassOrSuperclass(Ve.ClassName))return`codemeta:${e.valueOf().toString()}`;if(t.getName()==="EsdtTokenPayment"){let r=e.getFieldValue("token_identifier").valueOf(),n=e.getFieldValue("token_nonce").valueOf(),a=e.getFieldValue("amount").valueOf();return`asset:${new Oe().computeExtendedIdentifier(new ht({identifier:r,nonce:BigInt(n)}))}|${a}`}throw new Error(`WarpArgSerializer (typedToString): Unsupported input type: ${e.getClassName()}`)}typedToNative(e){let t=this.typedToString(e);return this.coreSerializer.stringToNative(t)}nativeToTyped(e,t){let r=this.coreSerializer.nativeToString(e,t);return this.stringToTyped(r)}nativeToType(e){if(e.startsWith("composite")){let t=e.match(/\(([^)]+)\)/)?.[1];return new te(...t.split(v.ArgCompositeSeparator).map(r=>this.nativeToType(r)))}if(e==="string")return new ie;if(e==="uint8")return new ue;if(e==="uint16")return new ce;if(e==="uint32")return new pe;if(e==="uint64")return new M;if(e==="biguint")return new _;if(e==="bool")return new Y;if(e==="address")return new J;if(e==="token")return new O;if(e==="hex")return new Z;if(e==="codemeta")return new ee;if(e==="asset")return new _e("EsdtTokenPayment",[new ne("token_identifier","",new O),new ne("token_nonce","",new M),new ne("amount","",new _)]);throw new Error(`WarpArgSerializer (nativeToType): Unsupported input type: ${e}`)}stringToTyped(e){let[t,r]=e.split(/:(.*)/,2);if(t==="null"||t===null)return new T;if(t==="option"){let n=this.stringToTyped(r);return n instanceof T?se.newMissingTyped(n.getType()):se.newProvided(n)}if(t==="optional"){let n=this.stringToTyped(r);return n instanceof T?ae.newMissing():new ae(n.getType(),n)}if(t==="list"){let[n,a]=r.split(qe,2),s=a.split(",").map(c=>this.stringToTyped(`${n}:${c}`));return new ke(this.nativeToType(n),s)}if(t==="variadic"){let[n,a]=r.split(qe,2),s=a.split(",").map(c=>this.stringToTyped(`${n}:${c}`));return new De(new me(this.nativeToType(n)),s)}if(t.startsWith("composite")){let n=t.match(/\(([^)]+)\)/)?.[1],a=r.split(v.ArgCompositeSeparator),o=n.split(v.ArgCompositeSeparator),s=a.map((p,u)=>this.stringToTyped(`${o[u]}:${p}`)),c=s.map(p=>p.getType());return new Se(new te(...c),s)}if(t==="string")return r?Pe.fromUTF8(r):new T;if(t==="uint8")return r?new Le(Number(r)):new T;if(t==="uint16")return r?new Me(Number(r)):new T;if(t==="uint32")return r?new $e(Number(r)):new T;if(t==="uint64")return r?new le(BigInt(r)):new T;if(t==="biguint")return r?new X(BigInt(r)):new T;if(t==="bool")return r?new Ie(typeof r=="boolean"?r:r==="true"):new T;if(t==="address")return r?new Be(ut.newFromBech32(r)):new T;if(t==="token")return r?new oe(r):new T;if(t==="hex")return r?Ne.fromHex(r):new T;if(t==="codemeta")return new Ve(mt.newFromBytes(Uint8Array.from(Buffer.from(r,"hex"))));if(t==="asset"){let[n,a]=r.split(v.ArgCompositeSeparator),o=new Oe,s=V(n)?P(n):o.extractIdentifierFromExtendedIdentifier(n),c=V(n)?0n:o.extractNonceFromExtendedIdentifier(n);return new dt(this.nativeToType("asset"),[new re(new oe(s),"token_identifier"),new re(new le(BigInt(c)),"token_nonce"),new re(new X(BigInt(a)),"amount")])}throw new Error(`WarpArgSerializer (stringToTyped): Unsupported input type: ${t}`)}typeToString(e){if(e.hasExactClass(Ue.ClassName))return"option:"+this.typeToString(e.getFirstTypeParameter());if(e.hasExactClass(Re.ClassName))return"optional:"+this.typeToString(e.getFirstTypeParameter());if(e.hasExactClass(Fe.ClassName))return"list:"+this.typeToString(e.getFirstTypeParameter());if(e.hasExactClass(me.ClassName))return"variadic:"+this.typeToString(e.getFirstTypeParameter());if(e.hasExactClass(ie.ClassName))return"string";if(e.hasExactClass(ue.ClassName))return"uint8";if(e.hasExactClass(ce.ClassName))return"uint16";if(e.hasExactClass(pe.ClassName))return"uint32";if(e.hasExactClass(M.ClassName))return"uint64";if(e.hasExactClass(_.ClassName))return"biguint";if(e.hasExactClass(Y.ClassName))return"bool";if(e.hasExactClass(J.ClassName))return"address";if(e.hasExactClass(O.ClassName))return"token";if(e.hasExactClass(Z.ClassName))return"hex";if(e.hasExactClass(ee.ClassName))return"codemeta";if(e.hasExactClass(_e.ClassName)&&e.getClassName()==="EsdtTokenPayment")return"asset";throw new Error(`WarpArgSerializer (typeToString): Unsupported input type: ${e.getClassName()}`)}};var S=class{constructor(e,t){this.config=e;this.chain=t;this.abi=new I(e,t),this.serializer=new B,this.cache=new Wt(e.cache?.type)}async getTransactionExecutionResults(e,t){let{actionIndex:r}=ze(e),n=this.cache.get(Tt.WarpExecutable(this.config.env,e.meta?.hash||"",r))??[],a=await this.extractContractResults(e,t,n),o=xt(this.config,[],e,r,a),s=Ct(e,a.results);return{success:t.status.isSuccessful(),warp:e,action:r,user:this.config.user?.wallets?.[this.chain.name]||null,txHash:t.hash,tx:t,next:o,values:a.values,valuesRaw:[],results:a.results,messages:s}}async extractContractResults(e,t,r){let{action:n,actionIndex:a}=ze(e),o=[],s={};if(!e.results||n.type!=="contract")return{values:o,results:s};if(!Object.values(e.results).some(C=>C.includes("out")||C.includes("event"))){for(let[C,m]of Object.entries(e.results))s[C]=m;return{values:o,results:await $(e,s,a,r,this.config.transform?.runner)}}let p=await this.abi.getAbiForAction(n),u=new wt({abi:p}),y=new yt({abi:p}).parseExecute({transactionOnNetwork:t,function:n.func||void 0});for(let[C,m]of Object.entries(e.results)){if(m.startsWith(Ge.Transform.Prefix))continue;if(m.startsWith("input.")){s[C]=m;continue}let b=He(m);if(b!==null&&b!==a){s[C]=null;continue}let[x,W,A]=m.split(".");if(x==="event"){if(!W||isNaN(Number(A)))continue;let E=Number(A),g=gt(t,W),k=u.parseEvents({events:g})[0],U=Object.values(k)[E]||null;o.push(U),s[C]=U&&U.valueOf()}else if(x==="out"||x.startsWith("out[")){if(!W)continue;let E=Number(W),g=y.values[E-1]||null;A&&(g=g[A]||null),g&&typeof g=="object"&&(g="toFixed"in g?g.toFixed():g.valueOf()),o.push(g),s[C]=g&&g.valueOf()}else s[C]=m}return{values:o,results:await $(e,s,a,r)}}async extractQueryResults(e,t,r,n){let a=t.map(p=>this.serializer.typedToString(p)),o=t.map(p=>this.serializer.typedToNative(p)[1]),s={};if(!e.results)return{values:a,valuesRaw:o,results:s};let c=p=>{let u=p.split(".").slice(1).map(y=>parseInt(y)-1);if(u.length===0)return;let l=o[u[0]];for(let y=1;y<u.length;y++){if(l==null)return;l=l[u[y]]}return l};for(let[p,u]of Object.entries(e.results)){if(u.startsWith(Ge.Transform.Prefix))continue;let l=He(u);if(l!==null&&l!==r){s[p]=null;continue}u.startsWith("out.")||u==="out"||u.startsWith("out[")?s[p]=c(u)||null:s[p]=u}return{values:a,valuesRaw:o,results:await $(e,s,r,n)}}async resolveWarpResultsRecursively(e){let t=e.warp,r=e.entryActionIndex,n=e.executor,a=e.inputs,o=e.meta,s=new Map,c=new Set,p=this;async function u(m,b=[]){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 x=t.actions[m-1];if(!x)throw new Error(`Action ${m} not found`);let W;if(x.type==="query")W=await n.executeQuery(t,m,b);else if(x.type==="collect")W=await n.executeCollect(t,m,b,o);else throw new Error(`Unsupported or interactive action type: ${x.type}`);if(s.set(m,W),t.results)for(let A of Object.values(t.results)){let g=String(A).match(/^out\[(\d+)\]/);if(g){let k=parseInt(g[1],10);k!==m&&!s.has(k)&&await u(k)}}return c.delete(m),W}await u(r,a);let l={};for(let m of s.values())for(let[b,x]of Object.entries(m.results))x!==null?l[b]=x:b in l||(l[b]=null);let y=await $(t,l,r,a,this.config.transform?.runner);return{...s.get(r),action:r,results:y}}};var _t="EGLD-000000",h=class i{constructor(e,t){this.config=e;this.chain=t;this.serializer=new B,this.abi=new I(this.config,this.chain),this.results=new S(this.config,this.chain)}async createTransaction(e){let t=de(e.warp,e.action),r=null;if(t.type==="transfer")r=await this.createTransferTransaction(e);else if(t.type==="contract")r=await this.createContractCallTransaction(e);else{if(t.type==="query")throw new Error("WarpMultiversxExecutor: Invalid action type for createTransactionForExecute; Use executeQuery instead");if(t.type==="collect")throw new Error("WarpMultiversxExecutor: Invalid action type for createTransactionForExecute; Use executeCollect instead")}if(!r)throw new Error(`WarpMultiversxExecutor: Invalid action type (${t.type})`);return r}async createTransferTransaction(e){let t=this.config.user?.wallets?.[e.chain.name];if(!t)throw new Error("WarpMultiversxExecutor: createTransfer - user address not set");let r=F.newFromBech32(t),n=new Qe({chainID:e.chain.chainId}),a=e.data?Buffer.from(this.serializer.stringToTyped(e.data).valueOf()):null;return new St({config:n}).createTransactionForTransfer(r,{receiver:F.newFromBech32(e.destination),nativeAmount:e.value,tokenTransfers:this.toTokenTransfers(e.transfers),data:a?new Uint8Array(a):void 0})}async createContractCallTransaction(e){let t=this.config.user?.wallets?.[e.chain.name];if(!t)throw new Error("WarpMultiversxExecutor: createContractCall - user address not set");let r=de(e.warp,e.action),n=F.newFromBech32(t),a=e.args.map(s=>this.serializer.stringToTyped(s)),o=new Qe({chainID:e.chain.chainId});return new At({config:o}).createTransactionForExecute(n,{contract:F.newFromBech32(e.destination),function:"func"in r&&r.func||"",gasLimit:"gasLimit"in r?BigInt(r.gasLimit||0):0n,arguments:a,tokenTransfers:this.toTokenTransfers(e.transfers),nativeTransferAmount:e.value})}async executeQuery(e){let t=de(e.warp,e.action);if(t.type!=="query")throw new Error(`WarpMultiversxExecutor: Invalid action type for executeQuery: ${t.type}`);let r=await this.abi.getAbiForAction(t),n=e.args.map(E=>this.serializer.stringToTyped(E)),a=i.getChainEntrypoint(e.chain,this.config.env,this.config),o=F.newFromBech32(e.destination),s=a.createSmartContractController(r),c=s.createQuery({contract:o,function:t.func||"",arguments:n}),p=await s.runQuery(c),u=p.returnCode==="ok",l=new vt,y=r.getEndpoint(p.function||t.func||""),C=(p.returnDataParts||[]).map(E=>Buffer.from(E)),m=l.buffersToValues(C,y.output),{values:b,valuesRaw:x,results:W}=await this.results.extractQueryResults(e.warp,m,e.action,e.resolvedInputs),A=Ut(this.config,[],e.warp,e.action,W);return{success:u,warp:e.warp,action:e.action,user:this.config.user?.wallets?.[e.chain.name]||null,txHash:null,tx:null,next:A,values:b,valuesRaw:x,results:W,messages:Rt(e.warp,W)}}static getChainEntrypoint(e,t,r){let n="warp-sdk",o=r?Pt(r,e.name,t,e.defaultApiUrl):e.defaultApiUrl;return t==="devnet"?new bt({url:o,kind:"api",clientName:n}):t==="testnet"?new Bt({url:o,kind:"api",clientName:n}):new Et({url:o,kind:"api",clientName:n})}async signMessage(e,t){let r=kt.fromString(t);return(await new Ft(r).sign(new Uint8Array(Buffer.from(e,"utf-8")))).toString()}toTokenTransfers(e){return e.map(t=>t.identifier===this.chain.nativeToken.identifier?{...t,identifier:_t}:t).map(t=>{let n=new Nt().extractNonceFromExtendedIdentifier(t.identifier);return new Vt({token:new It({identifier:t.identifier,nonce:BigInt(n||0)}),amount:t.amount})})}};var L=class{constructor(e){this.config=e}async getContract(e,t){try{let a=await h.getChainEntrypoint(t,this.config.env).createNetworkProvider().doGetGeneric(`accounts/${e}`);return{address:e,owner:a.ownerAddress,verified:a.isVerified||!1}}catch(r){return je.error("WarpContractLoader: getContract error",r),null}}async getVerificationInfo(e,t){try{let a=await h.getChainEntrypoint(t,this.config.env).createNetworkProvider().doGetGeneric(`accounts/${e}/verification`);return{codeHash:a.codeHash,abi:a.source.abi}}catch(r){return je.error("WarpContractLoader: getVerificationInfo error",r),null}}};var I=class{constructor(e,t){this.config=e;this.chain=t;this.contractLoader=new L(this.config),this.cache=new Dt(this.config.cache?.type)}async createInscriptionTransaction(e){let t=this.config.user?.wallets?.[this.chain.name];if(!t)throw new Error("WarpBuilder: user address not set");let r=new Mt({chainID:this.chain.chainId}),n=new $t({config:r}),a=Ot.newFromBech32(t),o={protocol:Lt("abi"),content:e},s=JSON.stringify(o),c=await n.createTransactionForTransfer(a,{receiver:a,nativeAmount:BigInt(0),data:Uint8Array.from(Buffer.from(s))});return c.gasLimit=c.gasLimit+BigInt(2e6),c}async createFromRaw(e){return JSON.parse(e)}async createFromTransaction(e){let t=await this.createFromRaw(e.data.toString());return t.meta={chain:this.chain.name,hash:e.hash,creator:e.sender.toBech32(),createdAt:new Date(e.timestamp*1e3).toISOString()},t}async createFromTransactionHash(e,t){let r=qt.WarpAbi(this.config.env,e);if(t){let o=this.cache.get(r);if(o)return Je.info(`WarpAbiBuilder (createFromTransactionHash): Warp abi found in cache: ${e}`),o}let a=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 Je.error("WarpAbiBuilder: Error creating from transaction hash",o),null}}async getAbiForAction(e){if(e.abi)return await this.fetchAbi(e);if(!e.address)throw new Error("WarpActionExecutor: Address not found");let t=await this.contractLoader.getVerificationInfo(e.address,this.chain);if(!t)throw new Error("WarpActionExecutor: Verification info not found");return he.create(t.abi)}async fetchAbi(e){if(!e.abi)throw new Error("WarpActionExecutor: ABI not found");if(e.abi.startsWith(Ke.IdentifierType.Hash)){let t=e.abi.split(Ke.ArgParamsSeparator)[1],r=await this.createFromTransactionHash(t);if(!r)throw new Error(`WarpActionExecutor: ABI not found for hash: ${e.abi}`);return he.create(r.content)}else{let r=await(await fetch(e.abi)).json();return he.create(r)}}};import{Address as Xe,TransactionsFactoryConfig as zt,TransferTransactionsFactory as Ht}from"@multiversx/sdk-core";import{WarpBrandBuilder as Gt,WarpLogger as Qt}from"@vleap/warps";import{Buffer as jt}from"buffer";var D=class{constructor(e,t){this.config=e;this.chain=t;this.core=new Gt(e)}async createInscriptionTransaction(e){let t=this.config.user?.wallets?.[this.chain.name];if(!t)throw new Error("BrandBuilder: user address not set");let r=new zt({chainID:this.chain.chainId}),n=new Ht({config:r}),a=Xe.newFromBech32(t),o=JSON.stringify(e);return await n.createTransactionForNativeTokenTransfer(a,{receiver:Xe.newFromBech32(t),nativeAmount:BigInt(0),data:Uint8Array.from(jt.from(o))})}async createFromTransaction(e,t=!1){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 Qt.error("BrandBuilder: Error creating from transaction hash",n),null}}};import{Address as Ye,TransactionsFactoryConfig as Kt,TransferTransactionsFactory as Jt}from"@multiversx/sdk-core";import{WarpBuilder as Ze,WarpCache as Xt,WarpCacheKey as Yt,WarpLogger as et}from"@vleap/warps";var q=class extends Ze{constructor(t,r){super(t);this.config=t;this.chain=r;this.cache=new Xt(t.cache?.type),this.core=new Ze(t)}async createInscriptionTransaction(t){let r=this.config.user?.wallets?.[this.chain.name];if(!r)throw new Error("WarpBuilder: user address not set");let n=new Kt({chainID:this.chain.chainId}),a=new Jt({config:n}),o=Ye.newFromBech32(r),s=JSON.stringify(t),c=await a.createTransactionForTransfer(o,{receiver:Ye.newFromBech32(r),nativeAmount:BigInt(0),data:Uint8Array.from(Buffer.from(s))});return c.gasLimit=c.gasLimit+BigInt(2e6),c}async createFromTransaction(t,r=!1){let n=await this.core.createFromRaw(t.data.toString(),r);return n.meta={chain:this.chain.name,hash:t.hash,creator:t.sender.toBech32(),createdAt:new Date(t.timestamp*1e3).toISOString()},n}async createFromTransactionHash(t,r){let n=Yt.Warp(this.config.env,t);if(r){let s=this.cache.get(n);if(s)return et.info(`WarpBuilder (createFromTransactionHash): Warp found in cache: ${t}`),s}let o=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 et.error("WarpBuilder: Error creating from transaction hash",s),null}}};import{Address as fe,Token as tr,TokenComputer as rr}from"@multiversx/sdk-core";import{CacheTtl as nr,WarpCache as ar,WarpCacheKey as sr}from"@vleap/warps";import{WarpChainName as Zt}from"@vleap/warps";var z=Zt.Multiversx,er=[{chain:z,identifier:"EGLD",name:"eGold",symbol:"EGLD",decimals:18,logoUrl:"https://tools.multiversx.com/assets-cdn/tokens/EGLD-000000/icon.pngsvg"},{chain:z,identifier:"EGLD-000000",name:"eGold",symbol:"EGLD",decimals:18,logoUrl:"https://tools.multiversx.com/assets-cdn/tokens/EGLD-000000/icon.png"},{chain:z,identifier:"VIBE",name:"VIBE",symbol:"VIBE",decimals:18,logoUrl:"https://vleap.ai/images/tokens/vibe.svg"},{chain:z,identifier:"VIBE-000000",name:"VIBE",symbol:"VIBE",decimals:18,logoUrl:"https://vleap.ai/images/tokens/vibe.svg"}],tt=i=>er.find(e=>e.identifier===i)||null;var H=class{constructor(e,t){this.config=e;this.chain=t;this.cache=new ar(e.cache?.type)}async getAccount(e){let r=await h.getChainEntrypoint(this.chain,this.config.env,this.config).createNetworkProvider().getAccount(fe.newFromBech32(e));return{chain:this.chain.name,address:r.address.toBech32(),balance:r.balance}}async getAccountAssets(e){let t=h.getChainEntrypoint(this.chain,this.config.env,this.config).createNetworkProvider(),r=t.getAccount(fe.newFromBech32(e)),n=t.getFungibleTokensOfAccount(fe.newFromBech32(e)),[a,o]=await Promise.all([r,n]),s=a.balance>0?[{...this.chain.nativeToken,amount:a.balance}]:[];return s.push(...o.map(c=>({chain:this.chain.name,identifier:c.token.identifier,name:c.raw.name,symbol:c.raw.ticker,amount:c.amount,decimals:c.raw.decimals,logoUrl:c.raw.assets?.pngUrl||""}))),s}async getAsset(e){let t=sr.Asset(this.config.env,this.chain.name,e),r=this.cache.get(t);if(r)return r;let n=tt(e);if(n)return{chain:this.chain.name,identifier:e,name:n.name,symbol:n.symbol,amount:0n,decimals:n.decimals,logoUrl:n.logoUrl};let a=new rr,o=V(e)?0n:a.extractNonceFromExtendedIdentifier(e),s=new tr({identifier:e,nonce:BigInt(o||0)}),c=a.isFungible(s),p=h.getChainEntrypoint(this.chain,this.config.env,this.config).createNetworkProvider(),u=P(e),l=await p.doGetGeneric(`tokens/${u}`),y={chain:this.chain.name,identifier:s.identifier,name:l.name,symbol:l.ticker,amount:0n,decimals:l.decimals,logoUrl:l.assets?.pngUrl||"#"};return this.cache.set(t,y,nr.OneHour),y}async getAction(e,t=!1){let r=h.getChainEntrypoint(this.chain,this.config.env,this.config),n=t?await r.awaitCompletedTransaction(e):await r.getTransaction(e);return{chain:this.chain.name,id:n.hash,receiver:n.receiver.toBech32(),sender:n.sender.toBech32(),value:n.value,function:n.function,status:this.toActionStatus(n),createdAt:this.toActionCreatedAt(n),error:n?.smartContractResults.map(a=>a.raw.returnMessage)[0]||null,tx:n}}async getAccountActions(e,t){let r=h.getChainEntrypoint(this.chain,this.config.env,this.config).createNetworkProvider(),n=`accounts/${e}/transactions`,a=new URLSearchParams,o=t?.size||25,s=t?.page||0;if(s>0){let p=s*o;a.append("from",p.toString())}return o!==25&&a.append("size",o.toString()),a.toString()&&(n+=`?${a.toString()}`),(await r.doGetGeneric(n)).map(p=>({chain:this.chain.name,id:p.txHash,receiver:p.receiver,sender:p.sender,value:p.value,function:p.function,status:this.toActionStatus(p),createdAt:this.toActionCreatedAt(p)}))}toActionStatus(e){return e.status.isSuccessful()?"success":e.status.isFailed()?"failed":"pending"}toActionCreatedAt(e){return new Date(e.timestamp||e.timestamp*1e3).toISOString()}};var Sa={Egld:{Identifier:"EGLD",EsdtIdentifier:"EGLD-000000",DisplayName:"eGold",Decimals:18}},ir=(r=>(r.MultiversxExplorer="multiversx_explorer",r.MultiversxExplorerDevnet="multiversx_explorer_devnet",r.MultiversxExplorerTestnet="multiversx_explorer_testnet",r))(ir||{}),or=(r=>(r.VibechainExplorer="vibechain_explorer",r.VibechainExplorerDevnet="vibechain_explorer_devnet",r.VibechainExplorerTestnet="vibechain_explorer_testnet",r))(or||{}),rt={multiversx:{mainnet:["multiversx_explorer"],testnet:["multiversx_explorer_testnet"],devnet:["multiversx_explorer_devnet"]},vibechain:{mainnet:["vibechain_explorer"],testnet:["vibechain_explorer_testnet"],devnet:["vibechain_explorer_devnet"]}},N={multiversx_explorer:"https://explorer.multiversx.com",multiversx_explorer_devnet:"https://devnet-explorer.multiversx.com",multiversx_explorer_testnet:"https://testnet-explorer.multiversx.com",vibechain_explorer:"https://vibeox-explorer.multiversx.com",vibechain_explorer_devnet:"https://vibeox-explorer.multiversx.com",vibechain_explorer_testnet:"https://vibeox-explorer.multiversx.com"};var G=class{constructor(e,t){this.chain=e;this.config=t}getExplorers(){let e=rt[this.chain];if(!e)return["multiversx_explorer"];let t=e[this.config.env];return t||["multiversx_explorer"]}getPrimaryExplorer(){return this.getExplorers()[0]}getExplorerUrlByName(e){let t=this.config.preferences?.explorers?.[this.chain];if(t&&!e){let a=N[t];if(a)return a}if(e){let a=N[e];if(a)return a}let r=this.getPrimaryExplorer();return N[r]||N[r]}getAccountUrl(e,t){return`${this.getExplorerUrlByName(t)}/accounts/${e}`}getTransactionUrl(e,t){return`${this.getExplorerUrlByName(t)}/transactions/${e}`}getBlockUrl(e,t){return`${this.getExplorerUrlByName(t)}/blocks/${e}`}getAssetUrl(e,t){return`${this.getExplorerUrlByName(t)}/tokens/${e}`}getContractUrl(e,t){return`${this.getExplorerUrlByName(t)}/accounts/${e}`}getAllExplorers(){return this.getExplorers()}getExplorerByName(e){return this.getExplorers().find(r=>r.toLowerCase()===e.toLowerCase())}getAccountUrls(e){let t=this.getAllExplorers(),r={};return t.forEach(n=>{let a=N[n];a&&(r[n]=`${a}/accounts/${e}`)}),r}getTransactionUrls(e){let t=this.getAllExplorers(),r={};return t.forEach(n=>{let a=N[n];a&&(r[n]=`${a}/transactions/${e}`)}),r}};import{AbiRegistry as at,Address as d,AddressValue as ye,BytesValue as f,SmartContractTransactionsFactory as pr,TransactionsFactoryConfig as lr}from"@multiversx/sdk-core";import{WarpCache as ur,WarpCacheKey as we,WarpLogger as Ce}from"@vleap/warps";var ge={buildInfo:{rustc:{version:"1.86.0",commitHash:"05f9846f893b09a1be1fc8560e33fc3c815cfecb",commitDate:"2025-03-31",channel:"Stable",short:"rustc 1.86.0 (05f9846f8 2025-03-31)"},contractCrate:{name:"registry",version:"0.0.1"},framework:{name:"multiversx-sc",version:"0.51.1"}},name:"RegistryContract",constructor:{inputs:[{name:"unit_price",type:"BigUint"},{name:"vault",type:"Address"}],outputs:[]},upgradeConstructor:{inputs:[],outputs:[]},endpoints:[{name:"registerWarp",mutability:"mutable",payableInTokens:["EGLD"],inputs:[{name:"hash",type:"bytes"},{name:"alias_opt",type:"optional<bytes>",multi_arg:!0},{name:"brand_opt",type:"optional<bytes>",multi_arg:!0}],outputs:[],allow_multiple_var_args:!0},{name:"unregisterWarp",mutability:"mutable",inputs:[{name:"warp",type:"bytes"}],outputs:[]},{name:"upgradeWarp",mutability:"mutable",payableInTokens:["EGLD"],inputs:[{name:"alias",type:"bytes"},{name:"new_warp",type:"bytes"}],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 w=i=>{if(i==="devnet")return"erd1qqqqqqqqqqqqqpgqje2f99vr6r7sk54thg03c9suzcvwr4nfl3tsfkdl36";if(i==="testnet")throw new Error("Multiversx testnet is not supported");return"erd1qqqqqqqqqqqqqpgq3mrpj3u6q7tejv6d7eqhnyd27n9v5c5tl3ts08mffe"};var Q=i=>({hash:i.hash.toString("hex"),alias:i.alias?.toString()||null,trust:i.trust.toString(),owner:i.owner.toString(),createdAt:i.created_at.toNumber(),upgradedAt:i.upgraded_at?.toNumber(),brand:i.brand?.toString("hex")||null,upgrade:i.upgrade?.toString("hex")||null}),nt=i=>({unitPrice:BigInt(i.unit_price.toString()),admins:i.admins.map(e=>e.toBech32())});var j=class{constructor(e,t){this.config=e;this.chain=t;this.cache=new ur(e.cache?.type),this.registryConfig={unitPrice:BigInt(0),admins:[]},this.userWallet=this.config.user?.wallets?.[this.chain.name]||null}async init(){await this.loadRegistryConfigs()}getRegistryConfig(){return this.registryConfig}async createWarpRegisterTransaction(e,t,r){if(this.registryConfig.unitPrice===BigInt(0))throw new Error("WarpRegistry: config not loaded. forgot to call init()?");if(!this.userWallet)throw new Error("WarpRegistry: user address not set");let n=d.newFromBech32(this.userWallet),a=()=>this.isCurrentUserAdmin()?BigInt(0):t&&r?this.registryConfig.unitPrice*BigInt(3):t?this.registryConfig.unitPrice*BigInt(2):this.registryConfig.unitPrice,o=()=>t&&r?[f.fromHex(e),f.fromUTF8(t),f.fromHex(r)]:t?[f.fromHex(e),f.fromUTF8(t)]:[f.fromHex(e)];return await this.getFactory().createTransactionForExecute(n,{contract:d.newFromBech32(w(this.config.env)),function:"registerWarp",gasLimit:BigInt(1e7),nativeTransferAmount:a(),arguments:o()})}async createWarpUnregisterTransaction(e){if(!this.userWallet)throw new Error("WarpRegistry: user address not set");let t=d.newFromBech32(this.userWallet);return await this.getFactory().createTransactionForExecute(t,{contract:d.newFromBech32(w(this.config.env)),function:"unregisterWarp",gasLimit:BigInt(1e7),arguments:[f.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=d.newFromBech32(this.userWallet);return await this.getFactory().createTransactionForExecute(r,{contract:d.newFromBech32(w(this.config.env)),function:"upgradeWarp",gasLimit:BigInt(1e7),nativeTransferAmount:this.isCurrentUserAdmin()?void 0:this.registryConfig.unitPrice,arguments:[f.fromUTF8(e),f.fromHex(t)]})}async createWarpAliasSetTransaction(e,t){if(!this.userWallet)throw new Error("WarpRegistry: user address not set");let r=d.newFromBech32(this.userWallet);return await this.getFactory().createTransactionForExecute(r,{contract:d.newFromBech32(w(this.config.env)),function:"setWarpAlias",gasLimit:BigInt(1e7),nativeTransferAmount:this.isCurrentUserAdmin()?void 0:this.registryConfig.unitPrice,arguments:[f.fromHex(e),f.fromUTF8(t)]})}async createWarpVerifyTransaction(e){if(!this.userWallet)throw new Error("WarpRegistry: user address not set");let t=d.newFromBech32(this.userWallet);return await this.getFactory().createTransactionForExecute(t,{contract:d.newFromBech32(w(this.config.env)),function:"verifyWarp",gasLimit:BigInt(1e7),arguments:[f.fromHex(e)]})}async createWarpTransferOwnershipTransaction(e,t){if(!this.userWallet)throw new Error("WarpRegistry: user address not set");let r=d.newFromBech32(this.userWallet);return await this.getFactory().createTransactionForExecute(r,{contract:d.newFromBech32(w(this.config.env)),function:"transferOwnership",gasLimit:BigInt(1e7),arguments:[f.fromHex(e),new ye(new d(t))]})}async createBrandRegisterTransaction(e){if(this.registryConfig.unitPrice===BigInt(0))throw new Error("WarpRegistry: config not loaded. forgot to call init()?");if(!this.userWallet)throw new Error("WarpRegistry: user address not set");let t=d.newFromBech32(this.userWallet);return await this.getFactory().createTransactionForExecute(t,{contract:d.newFromBech32(w(this.config.env)),function:"registerBrand",gasLimit:BigInt(1e7),nativeTransferAmount:this.isCurrentUserAdmin()?void 0:this.registryConfig.unitPrice,arguments:[f.fromHex(e)]})}async createWarpBrandingTransaction(e,t){if(!this.userWallet)throw new Error("WarpRegistry: user address not set");let r=d.newFromBech32(this.userWallet);return await this.getFactory().createTransactionForExecute(r,{contract:d.newFromBech32(w(this.config.env)),function:"brandWarp",gasLimit:BigInt(1e7),nativeTransferAmount:this.isCurrentUserAdmin()?void 0:this.registryConfig.unitPrice,arguments:[f.fromHex(e),f.fromHex(t)]})}async getInfoByAlias(e,t){try{let r=we.RegistryInfo(this.config.env,e),n=t?this.cache.get(r):null;if(n)return Ce.info(`WarpRegistry (getInfoByAlias): RegistryInfo found in cache: ${e}`),n;let a=d.newFromBech32(w(this.config.env)),o=this.getController(),s=o.createQuery({contract:a,function:"getInfoByAlias",arguments:[f.fromUTF8(e)]}),c=await o.runQuery(s),[p]=o.parseQueryResponse(c),u=p?Q(p):null,l=u?.brand?await this.fetchBrand(u.brand):null;return t&&t.ttl&&this.cache.set(r,{registryInfo:u,brand:l},t.ttl),{registryInfo:u,brand:l}}catch{return{registryInfo:null,brand:null}}}async getInfoByHash(e,t){try{let r=we.RegistryInfo(this.config.env,e);if(t){let l=this.cache.get(r);if(l)return Ce.info(`WarpRegistry (getInfoByHash): RegistryInfo found in cache: ${e}`),l}let n=d.newFromBech32(w(this.config.env)),a=this.getController(),o=a.createQuery({contract:n,function:"getInfoByHash",arguments:[f.fromHex(e)]}),s=await a.runQuery(o),[c]=a.parseQueryResponse(s),p=c?Q(c):null,u=p?.brand?await this.fetchBrand(p.brand):null;return t&&t.ttl&&this.cache.set(r,{registryInfo:p,brand:u},t.ttl),{registryInfo:p,brand:u}}catch{return{registryInfo:null,brand:null}}}async getUserWarpRegistryInfos(e){try{let t=e||this.userWallet;if(!t)throw new Error("WarpRegistry: user address not set");let r=d.newFromBech32(w(this.config.env)),n=this.getController(),a=n.createQuery({contract:r,function:"getUserWarps",arguments:[new ye(new d(t))]}),o=await n.runQuery(a),[s]=n.parseQueryResponse(o);return s.map(Q)}catch{return[]}}async getUserBrands(e){try{let t=e||this.userWallet;if(!t)throw new Error("WarpRegistry: user address not set");let r=d.newFromBech32(w(this.config.env)),n=this.getController(),a=n.createQuery({contract:r,function:"getUserBrands",arguments:[new ye(new d(t))]}),o=await n.runQuery(a),[s]=n.parseQueryResponse(o),c=s.map(l=>l.toString("hex")),p={ttl:365*24*60*60};return(await Promise.all(c.map(l=>this.fetchBrand(l,p)))).filter(l=>l!==null)}catch{return[]}}async fetchBrand(e,t){let r=we.Brand(this.config.env,e),n=t?this.cache.get(r):null;if(n)return Ce.info(`WarpRegistry (fetchBrand): Brand found in cache: ${e}`),n;let o=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=d.newFromBech32(w(this.config.env)),t=this.getController(),[r]=await t.query({contract:e,function:"getConfig",arguments:[]}),n=r?nt(r):null;this.registryConfig=n||{unitPrice:BigInt(0),admins:[]}}getFactory(){let e=new lr({chainID:this.chain.chainId}),t=at.create(ge);return new pr({config:e,abi:t})}getController(){let e=h.getChainEntrypoint(this.chain,this.config.env),t=at.create(ge);return e.createSmartContractController(t)}isCurrentUserAdmin(){return!!this.userWallet&&this.registryConfig.admins.includes(this.userWallet)}};var K=(i,e,t)=>(r,n)=>{let a=t[r.env];return{chain:i,chainInfo:a,prefix:e,builder:()=>new q(r,a),executor:new h(r,a),results:new S(r,a),serializer:new B,registry:new j(r,a),explorer:new G(i,r),abiBuilder:()=>new I(r,a),brandBuilder:()=>new D(r,a),dataLoader:new H(r,a),registerTypes:o=>{o.registerType("token",{stringToNative:s=>s,nativeToString:s=>`token:${s}`}),o.registerType("codemeta",{stringToNative:s=>s,nativeToString:s=>`codemeta:${s}`})}}};var xe={chain:R.Multiversx,identifier:"EGLD",name:"eGold",symbol:"EGLD",decimals:18,logoUrl:"https://vleap.ai/images/tokens/egld.svg"},st=K(R.Multiversx,"mvx",{mainnet:{name:R.Multiversx,displayName:"MultiversX",chainId:"1",blockTime:6e3,addressHrp:"erd",defaultApiUrl:"https://api.multiversx.com",nativeToken:xe},testnet:{name:R.Multiversx,displayName:"MultiversX Testnet",chainId:"T",blockTime:6e3,addressHrp:"erd",defaultApiUrl:"https://testnet-api.multiversx.com",nativeToken:xe},devnet:{name:R.Multiversx,displayName:"MultiversX Devnet",chainId:"D",blockTime:6e3,addressHrp:"erd",defaultApiUrl:"https://devnet-api.multiversx.com",nativeToken:xe}});import{WarpChainName as Te}from"@vleap/warps";var mr={chain:Te.Vibechain,identifier:"VIBE",name:"VIBE",symbol:"VIBE",decimals:18,logoUrl:"https://vleap.ai/images/tokens/vibe.svg"},We={name:Te.Vibechain,displayName:"VibeChain",chainId:"V",blockTime:600,addressHrp:"vibe",defaultApiUrl:"https://vibeox-api.multiversx.com",nativeToken:mr},it=K(Te.Vibechain,"vibe",{mainnet:We,testnet:We,devnet:We});var As=(i,e)=>[st(i,e),it(i,e)],Bs=()=>[ot.Multiversx,ot.Vibechain];import{Address as dr,AddressValue as hr,BigUIntType as fr,BigUIntValue as ct,BooleanValue as gr,BytesValue as yr,CodeMetadata as wr,CodeMetadataValue as Cr,CompositeType as xr,CompositeValue as Wr,Field as ve,FieldDefinition as be,List as Tr,NothingValue as vr,OptionalValue as Ee,OptionValue as Ae,StringValue as br,Struct as Er,StructType as Ar,TokenIdentifierType as Br,TokenIdentifierValue as pt,U16Value as Ir,U32Value as Nr,U64Type as Vr,U64Value as lt,U8Value as Sr,VariadicValue as kr}from"@multiversx/sdk-core";var Os=(i,e)=>i?Ae.newProvided(i):e?Ae.newMissingTyped(e):Ae.newMissing(),Ms=(i,e)=>i?new Ee(i.getType(),i):e?new Ee(e):Ee.newMissing(),$s=i=>{if(i.length===0)throw new Error("Cannot create a list from an empty array");let e=i[0].getType();return new Tr(e,i)},Ls=i=>kr.fromItems(...i),Ds=i=>{let e=i.map(t=>t.getType());return new Wr(new xr(...e),i)},qs=i=>br.fromUTF8(i),zs=i=>new Sr(i),Hs=i=>new Ir(i),Gs=i=>new Nr(i),Qs=i=>new lt(i),js=i=>new ct(BigInt(i)),Ks=i=>new gr(i),Js=i=>new hr(dr.newFromBech32(i)),Xs=i=>new pt(i),Ys=i=>yr.fromHex(i),Zs=i=>new Er(new Ar("EsdtTokenPayment",[new be("token_identifier","",new Br),new be("token_nonce","",new Vr),new be("amount","",new fr)]),[new ve(new pt(i.token.identifier),"token_identifier"),new ve(new lt(BigInt(i.token.nonce)),"token_nonce"),new ve(new ct(BigInt(i.amount)),"amount")]),ei=i=>new Cr(wr.newFromBytes(Uint8Array.from(Buffer.from(i,"hex")))),ti=()=>new vr;export{N as ExplorerUrls,er as KnownTokens,ir as MultiversxExplorers,rt as MultiversxExplorersConfig,xe as NativeTokenEgld,mr as NativeTokenVibe,or as VibechainExplorers,I as WarpMultiversxAbiBuilder,D as WarpMultiversxBrandBuilder,q as WarpMultiversxBuilder,Sa as WarpMultiversxConstants,L as WarpMultiversxContractLoader,H as WarpMultiversxDataLoader,h as WarpMultiversxExecutor,G as WarpMultiversxExplorer,j as WarpMultiversxRegistry,S as WarpMultiversxResults,B as WarpMultiversxSerializer,Js as address_value,Zs as asset_value,js as biguint_value,Ks as boolean_value,ei as codemeta_value,Ds as composite_value,K as createMultiversxAdapter,tt as findKnownTokenById,As as getAllMultiversxAdapters,Bs as getAllMultiversxChainNames,st as getMultiversxAdapter,w as getMultiversxRegistryAddress,it as getVibechainAdapter,Ys as hex_value,$s as list_value,ti as nothing_value,Os as option_value,Ms as optional_value,qs as string_value,Xs as token_value,Hs as u16_value,Gs as u32_value,Qs as u64_value,zs as u8_value,Ls as variadic_value};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vleap/warps-adapter-multiversx",
|
|
3
|
-
"version": "0.2.0-alpha.
|
|
3
|
+
"version": "0.2.0-alpha.48",
|
|
4
4
|
"description": "",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
@@ -26,8 +26,8 @@
|
|
|
26
26
|
],
|
|
27
27
|
"devDependencies": {
|
|
28
28
|
"@types/jest": "^30.0.0",
|
|
29
|
-
"jest": "^30.
|
|
30
|
-
"jest-environment-jsdom": "^30.
|
|
29
|
+
"jest": "^30.1.3",
|
|
30
|
+
"jest-environment-jsdom": "^30.1.2",
|
|
31
31
|
"jest-fetch-mock": "^3.0.3",
|
|
32
32
|
"ts-jest": "^29.4.1",
|
|
33
33
|
"tsup": "^8.5.0",
|
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
"access": "public"
|
|
38
38
|
},
|
|
39
39
|
"dependencies": {
|
|
40
|
-
"@multiversx/sdk-core": "^15.
|
|
41
|
-
"@vleap/warps": "^3.0.0-alpha.
|
|
40
|
+
"@multiversx/sdk-core": "^15.1.1",
|
|
41
|
+
"@vleap/warps": "^3.0.0-alpha.95"
|
|
42
42
|
}
|
|
43
43
|
}
|