@vleap/warps-adapter-multiversx 0.2.0-alpha.39 → 0.2.0-alpha.41
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 +9 -1
- package/dist/index.d.ts +9 -1
- package/dist/index.js +1 -1
- package/dist/index.mjs +1 -1
- package/package.json +2 -2
package/dist/index.d.cts
CHANGED
|
@@ -48,6 +48,14 @@ declare const MultiversxExplorersConfig: {
|
|
|
48
48
|
};
|
|
49
49
|
declare const ExplorerUrls: Record<ExplorerName, string>;
|
|
50
50
|
|
|
51
|
+
type KnownToken = {
|
|
52
|
+
id: string;
|
|
53
|
+
name: string;
|
|
54
|
+
decimals: number;
|
|
55
|
+
};
|
|
56
|
+
declare const KnownTokens: KnownToken[];
|
|
57
|
+
declare const findKnownTokenById: (id: string) => KnownToken | null;
|
|
58
|
+
|
|
51
59
|
declare const option_value: (value: TypedValue | null, type?: Type) => OptionValue;
|
|
52
60
|
declare const optional_value: (value: TypedValue | null, type?: Type) => OptionalValue;
|
|
53
61
|
declare const list_value: (values: TypedValue[]) => List;
|
|
@@ -226,4 +234,4 @@ declare class WarpMultiversxSerializer implements AdapterWarpSerializer {
|
|
|
226
234
|
typeToString(type: Type): WarpActionInputType;
|
|
227
235
|
}
|
|
228
236
|
|
|
229
|
-
export { type ExplorerName, ExplorerUrls, MultiversxExplorers, MultiversxExplorersConfig, NativeTokenEgld, NativeTokenVibe, VibechainExplorers, WarpMultiversxAbiBuilder, WarpMultiversxBrandBuilder, WarpMultiversxBuilder, WarpMultiversxConstants, WarpMultiversxContractLoader, WarpMultiversxDataLoader, WarpMultiversxExecutor, WarpMultiversxExplorer, WarpMultiversxRegistry, WarpMultiversxResults, WarpMultiversxSerializer, address_value, biguint_value, boolean_value, codemeta_value, composite_value, createMultiversxAdapter, esdt_value, getAllMultiversxAdapters, getAllMultiversxChainNames, getMultiversxAdapter, getMultiversxRegistryAddress, getVibechainAdapter, hex_value, list_value, nothing_value, option_value, optional_value, string_value, token_value, u16_value, u32_value, u64_value, u8_value, variadic_value };
|
|
237
|
+
export { type ExplorerName, ExplorerUrls, type KnownToken, KnownTokens, MultiversxExplorers, MultiversxExplorersConfig, NativeTokenEgld, NativeTokenVibe, VibechainExplorers, WarpMultiversxAbiBuilder, WarpMultiversxBrandBuilder, WarpMultiversxBuilder, WarpMultiversxConstants, WarpMultiversxContractLoader, WarpMultiversxDataLoader, WarpMultiversxExecutor, WarpMultiversxExplorer, WarpMultiversxRegistry, WarpMultiversxResults, WarpMultiversxSerializer, address_value, biguint_value, boolean_value, codemeta_value, composite_value, createMultiversxAdapter, esdt_value, findKnownTokenById, getAllMultiversxAdapters, getAllMultiversxChainNames, getMultiversxAdapter, getMultiversxRegistryAddress, getVibechainAdapter, hex_value, list_value, nothing_value, option_value, optional_value, string_value, token_value, u16_value, u32_value, u64_value, u8_value, variadic_value };
|
package/dist/index.d.ts
CHANGED
|
@@ -48,6 +48,14 @@ declare const MultiversxExplorersConfig: {
|
|
|
48
48
|
};
|
|
49
49
|
declare const ExplorerUrls: Record<ExplorerName, string>;
|
|
50
50
|
|
|
51
|
+
type KnownToken = {
|
|
52
|
+
id: string;
|
|
53
|
+
name: string;
|
|
54
|
+
decimals: number;
|
|
55
|
+
};
|
|
56
|
+
declare const KnownTokens: KnownToken[];
|
|
57
|
+
declare const findKnownTokenById: (id: string) => KnownToken | null;
|
|
58
|
+
|
|
51
59
|
declare const option_value: (value: TypedValue | null, type?: Type) => OptionValue;
|
|
52
60
|
declare const optional_value: (value: TypedValue | null, type?: Type) => OptionalValue;
|
|
53
61
|
declare const list_value: (values: TypedValue[]) => List;
|
|
@@ -226,4 +234,4 @@ declare class WarpMultiversxSerializer implements AdapterWarpSerializer {
|
|
|
226
234
|
typeToString(type: Type): WarpActionInputType;
|
|
227
235
|
}
|
|
228
236
|
|
|
229
|
-
export { type ExplorerName, ExplorerUrls, MultiversxExplorers, MultiversxExplorersConfig, NativeTokenEgld, NativeTokenVibe, VibechainExplorers, WarpMultiversxAbiBuilder, WarpMultiversxBrandBuilder, WarpMultiversxBuilder, WarpMultiversxConstants, WarpMultiversxContractLoader, WarpMultiversxDataLoader, WarpMultiversxExecutor, WarpMultiversxExplorer, WarpMultiversxRegistry, WarpMultiversxResults, WarpMultiversxSerializer, address_value, biguint_value, boolean_value, codemeta_value, composite_value, createMultiversxAdapter, esdt_value, getAllMultiversxAdapters, getAllMultiversxChainNames, getMultiversxAdapter, getMultiversxRegistryAddress, getVibechainAdapter, hex_value, list_value, nothing_value, option_value, optional_value, string_value, token_value, u16_value, u32_value, u64_value, u8_value, variadic_value };
|
|
237
|
+
export { type ExplorerName, ExplorerUrls, type KnownToken, KnownTokens, MultiversxExplorers, MultiversxExplorersConfig, NativeTokenEgld, NativeTokenVibe, VibechainExplorers, WarpMultiversxAbiBuilder, WarpMultiversxBrandBuilder, WarpMultiversxBuilder, WarpMultiversxConstants, WarpMultiversxContractLoader, WarpMultiversxDataLoader, WarpMultiversxExecutor, WarpMultiversxExplorer, WarpMultiversxRegistry, WarpMultiversxResults, WarpMultiversxSerializer, address_value, biguint_value, boolean_value, codemeta_value, composite_value, createMultiversxAdapter, esdt_value, findKnownTokenById, getAllMultiversxAdapters, getAllMultiversxChainNames, getMultiversxAdapter, getMultiversxRegistryAddress, getVibechainAdapter, hex_value, list_value, nothing_value, option_value, optional_value, string_value, token_value, u16_value, u32_value, u64_value, u8_value, variadic_value };
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var te=Object.defineProperty;var ye=Object.getOwnPropertyDescriptor;var we=Object.getOwnPropertyNames;var Ce=Object.prototype.hasOwnProperty;var xe=(o,e)=>{for(var t in e)te(o,t,{get:e[t],enumerable:!0})},We=(o,e,t,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let a of we(e))!Ce.call(o,a)&&a!==t&&te(o,a,{get:()=>e[a],enumerable:!(r=ye(e,a))||r.enumerable});return o};var Te=o=>We(te({},"__esModule",{value:!0}),o);var He={};xe(He,{ExplorerUrls:()=>P,MultiversxExplorers:()=>fe,MultiversxExplorersConfig:()=>se,NativeTokenEgld:()=>Z,NativeTokenVibe:()=>ge,VibechainExplorers:()=>de,WarpMultiversxAbiBuilder:()=>F,WarpMultiversxBrandBuilder:()=>D,WarpMultiversxBuilder:()=>z,WarpMultiversxConstants:()=>Le,WarpMultiversxContractLoader:()=>q,WarpMultiversxDataLoader:()=>H,WarpMultiversxExecutor:()=>w,WarpMultiversxExplorer:()=>Q,WarpMultiversxRegistry:()=>G,WarpMultiversxResults:()=>U,WarpMultiversxSerializer:()=>R,address_value:()=>Pe,biguint_value:()=>Fe,boolean_value:()=>ke,codemeta_value:()=>Oe,composite_value:()=>Be,createMultiversxAdapter:()=>j,esdt_value:()=>re,getAllMultiversxAdapters:()=>De,getAllMultiversxChainNames:()=>ze,getMultiversxAdapter:()=>oe,getMultiversxRegistryAddress:()=>b,getVibechainAdapter:()=>pe,hex_value:()=>_e,list_value:()=>Ee,nothing_value:()=>Me,option_value:()=>ve,optional_value:()=>be,string_value:()=>Ie,token_value:()=>Ue,u16_value:()=>Ne,u32_value:()=>Se,u64_value:()=>Re,u8_value:()=>Ve,variadic_value:()=>Ae});module.exports=Te(He);var ue=require("@vleap/warps");var $=require("@vleap/warps");var J=require("@multiversx/sdk-core"),V=require("@vleap/warps");var ne=require("@vleap/warps");var f=require("@multiversx/sdk-core"),W=require("@vleap/warps");var M=require("@multiversx/sdk-core"),y=require("@vleap/warps");var n=require("@multiversx/sdk-core"),T=require("@vleap/warps"),le=new RegExp(`${T.WarpConstants.ArgParamsSeparator}(.*)`),R=class{constructor(){this.coreSerializer=new T.WarpSerializer}typedToString(e){let t=e.getType();if(t.hasExactClass(n.OptionType.ClassName)||e.hasClassOrSuperclass(n.OptionValue.ClassName))return e.isSet()?`option:${this.typedToString(e.getTypedValue())}`:"option:null";if(t.hasExactClass(n.OptionalType.ClassName)||e.hasClassOrSuperclass(n.OptionalValue.ClassName))return e.isSet()?`optional:${this.typedToString(e.getTypedValue())}`:"optional:null";if(t.hasExactClass(n.ListType.ClassName)||e.hasClassOrSuperclass(n.List.ClassName)){let r=e.getItems(),s=r.map(i=>this.typedToString(i).split(T.WarpConstants.ArgParamsSeparator)[0])[0],c=r.map(i=>this.typedToString(i).split(T.WarpConstants.ArgParamsSeparator)[1]);return`list:${s}:${c.join(",")}`}if(t.hasExactClass(n.VariadicType.ClassName)||e.hasClassOrSuperclass(n.VariadicValue.ClassName)){let r=e.getItems(),s=r.map(i=>this.typedToString(i).split(T.WarpConstants.ArgParamsSeparator)[0])[0],c=r.map(i=>this.typedToString(i).split(T.WarpConstants.ArgParamsSeparator)[1]);return`variadic:${s}:${c.join(",")}`}if(t.hasExactClass(n.CompositeType.ClassName)||e.hasClassOrSuperclass(n.CompositeValue.ClassName)){let r=e.getItems(),a=r.map(m=>this.typedToString(m).split(T.WarpConstants.ArgParamsSeparator)[0]),s=r.map(m=>this.typedToString(m).split(T.WarpConstants.ArgParamsSeparator)[1]),c=a.join(T.WarpConstants.ArgCompositeSeparator),i=s.join(T.WarpConstants.ArgCompositeSeparator);return`composite(${c}):${i}`}if(t.hasExactClass(n.BigUIntType.ClassName)||e.hasClassOrSuperclass(n.BigUIntValue.ClassName)||t.getName()==="BigUint")return`biguint:${BigInt(e.valueOf().toFixed())}`;if(t.hasExactClass(n.U8Type.ClassName)||e.hasClassOrSuperclass(n.U8Value.ClassName))return`uint8:${e.valueOf().toNumber()}`;if(t.hasExactClass(n.U16Type.ClassName)||e.hasClassOrSuperclass(n.U16Value.ClassName))return`uint16:${e.valueOf().toNumber()}`;if(t.hasExactClass(n.U32Type.ClassName)||e.hasClassOrSuperclass(n.U32Value.ClassName))return`uint32:${e.valueOf().toNumber()}`;if(t.hasExactClass(n.U64Type.ClassName)||e.hasClassOrSuperclass(n.U64Value.ClassName))return`uint64:${BigInt(e.valueOf().toFixed())}`;if(t.hasExactClass(n.StringType.ClassName)||e.hasClassOrSuperclass(n.StringValue.ClassName))return`string:${e.valueOf()}`;if(t.hasExactClass(n.BooleanType.ClassName)||e.hasClassOrSuperclass(n.BooleanValue.ClassName))return`bool:${e.valueOf()}`;if(t.hasExactClass(n.AddressType.ClassName)||e.hasClassOrSuperclass(n.AddressValue.ClassName))return`address:${e.valueOf().toBech32()}`;if(t.hasExactClass(n.TokenIdentifierType.ClassName)||e.hasClassOrSuperclass(n.TokenIdentifierValue.ClassName))return`token:${e.valueOf()}`;if(t.hasExactClass(n.BytesType.ClassName)||e.hasClassOrSuperclass(n.BytesValue.ClassName))return`hex:${e.valueOf().toString("hex")}`;if(t.hasExactClass(n.CodeMetadataType.ClassName)||e.hasClassOrSuperclass(n.CodeMetadataValue.ClassName))return`codemeta:${e.valueOf().toString()}`;if(t.getName()==="EsdtTokenPayment"){let r=e.getFieldValue("token_identifier").valueOf(),a=e.getFieldValue("token_nonce").valueOf(),s=e.getFieldValue("amount").valueOf();return`asset:${r}|${a}|${s}`}throw new Error(`WarpArgSerializer (typedToString): Unsupported input type: ${e.getClassName()}`)}typedToNative(e){let t=this.typedToString(e);return this.coreSerializer.stringToNative(t)}nativeToTyped(e,t){let r=this.coreSerializer.nativeToString(e,t);return this.stringToTyped(r)}nativeToType(e){if(e.startsWith("composite")){let t=e.match(/\(([^)]+)\)/)?.[1];return new n.CompositeType(...t.split(T.WarpConstants.ArgCompositeSeparator).map(r=>this.nativeToType(r)))}if(e==="string")return new n.StringType;if(e==="uint8")return new n.U8Type;if(e==="uint16")return new n.U16Type;if(e==="uint32")return new n.U32Type;if(e==="uint64")return new n.U64Type;if(e==="biguint")return new n.BigUIntType;if(e==="bool")return new n.BooleanType;if(e==="address")return new n.AddressType;if(e==="token")return new n.TokenIdentifierType;if(e==="hex")return new n.BytesType;if(e==="codemeta")return new n.CodeMetadataType;if(e==="asset")return new n.StructType("EsdtTokenPayment",[new n.FieldDefinition("token_identifier","",new n.TokenIdentifierType),new n.FieldDefinition("token_nonce","",new n.U64Type),new n.FieldDefinition("amount","",new n.BigUIntType)]);throw new Error(`WarpArgSerializer (nativeToType): Unsupported input type: ${e}`)}stringToTyped(e){let[t,r]=e.split(/:(.*)/,2);if(t==="null"||t===null)return new n.NothingValue;if(t==="option"){let a=this.stringToTyped(r);return a instanceof n.NothingValue?n.OptionValue.newMissingTyped(a.getType()):n.OptionValue.newProvided(a)}if(t==="optional"){let a=this.stringToTyped(r);return a instanceof n.NothingValue?n.OptionalValue.newMissing():new n.OptionalValue(a.getType(),a)}if(t==="list"){let[a,s]=r.split(le,2),i=s.split(",").map(m=>this.stringToTyped(`${a}:${m}`));return new n.List(this.nativeToType(a),i)}if(t==="variadic"){let[a,s]=r.split(le,2),i=s.split(",").map(m=>this.stringToTyped(`${a}:${m}`));return new n.VariadicValue(new n.VariadicType(this.nativeToType(a)),i)}if(t.startsWith("composite")){let a=t.match(/\(([^)]+)\)/)?.[1],s=r.split(T.WarpConstants.ArgCompositeSeparator),c=a.split(T.WarpConstants.ArgCompositeSeparator),i=s.map((l,d)=>this.stringToTyped(`${c[d]}:${l}`)),m=i.map(l=>l.getType());return new n.CompositeValue(new n.CompositeType(...m),i)}if(t==="string")return r?n.StringValue.fromUTF8(r):new n.NothingValue;if(t==="uint8")return r?new n.U8Value(Number(r)):new n.NothingValue;if(t==="uint16")return r?new n.U16Value(Number(r)):new n.NothingValue;if(t==="uint32")return r?new n.U32Value(Number(r)):new n.NothingValue;if(t==="uint64")return r?new n.U64Value(BigInt(r)):new n.NothingValue;if(t==="biguint")return r?new n.BigUIntValue(BigInt(r)):new n.NothingValue;if(t==="bool")return r?new n.BooleanValue(typeof r=="boolean"?r:r==="true"):new n.NothingValue;if(t==="address")return r?new n.AddressValue(n.Address.newFromBech32(r)):new n.NothingValue;if(t==="token")return r?new n.TokenIdentifierValue(r):new n.NothingValue;if(t==="hex")return r?n.BytesValue.fromHex(r):new n.NothingValue;if(t==="codemeta")return new n.CodeMetadataValue(n.CodeMetadata.newFromBytes(Uint8Array.from(Buffer.from(r,"hex"))));if(t==="asset"){let a=r.split(T.WarpConstants.ArgCompositeSeparator);return new n.Struct(this.nativeToType("asset"),[new n.Field(new n.TokenIdentifierValue(a[0]),"token_identifier"),new n.Field(new n.U64Value(BigInt(a[1])),"token_nonce"),new n.Field(new n.BigUIntValue(BigInt(a[2])),"amount")])}throw new Error(`WarpArgSerializer (stringToTyped): Unsupported input type: ${t}`)}typeToString(e){if(e.hasExactClass(n.OptionType.ClassName))return"option:"+this.typeToString(e.getFirstTypeParameter());if(e.hasExactClass(n.OptionalType.ClassName))return"optional:"+this.typeToString(e.getFirstTypeParameter());if(e.hasExactClass(n.ListType.ClassName))return"list:"+this.typeToString(e.getFirstTypeParameter());if(e.hasExactClass(n.VariadicType.ClassName))return"variadic:"+this.typeToString(e.getFirstTypeParameter());if(e.hasExactClass(n.StringType.ClassName))return"string";if(e.hasExactClass(n.U8Type.ClassName))return"uint8";if(e.hasExactClass(n.U16Type.ClassName))return"uint16";if(e.hasExactClass(n.U32Type.ClassName))return"uint32";if(e.hasExactClass(n.U64Type.ClassName))return"uint64";if(e.hasExactClass(n.BigUIntType.ClassName))return"biguint";if(e.hasExactClass(n.BooleanType.ClassName))return"bool";if(e.hasExactClass(n.AddressType.ClassName))return"address";if(e.hasExactClass(n.TokenIdentifierType.ClassName))return"token";if(e.hasExactClass(n.BytesType.ClassName))return"hex";if(e.hasExactClass(n.CodeMetadataType.ClassName))return"codemeta";if(e.hasExactClass(n.StructType.ClassName)&&e.getClassName()==="EsdtTokenPayment")return"asset";throw new Error(`WarpArgSerializer (typeToString): Unsupported input type: ${e.getClassName()}`)}};var U=class{constructor(e,t){this.config=e;this.chain=t;this.abi=new F(e,t),this.serializer=new R,this.cache=new y.WarpCache(e.cache?.type)}async getTransactionExecutionResults(e,t){let{actionIndex:r}=(0,y.findWarpExecutableAction)(e),a=this.cache.get(y.WarpCacheKey.WarpExecutable(this.config.env,e.meta?.hash||"",r))??[],s=await this.extractContractResults(e,t,a),c=(0,y.getNextInfo)(this.config,[],e,r,s),i=(0,y.applyResultsToMessages)(e,s.results);return{success:t.status.isSuccessful(),warp:e,action:r,user:this.config.user?.wallets?.[this.chain.name]||null,txHash:t.hash,tx:t,next:c,values:s.values,valuesRaw:[],results:s.results,messages:i}}async extractContractResults(e,t,r){let{action:a,actionIndex:s}=(0,y.findWarpExecutableAction)(e),c=[],i={};if(!e.results||a.type!=="contract")return{values:c,results:i};if(!Object.values(e.results).some(v=>v.includes("out")||v.includes("event"))){for(let[v,g]of Object.entries(e.results))i[v]=g;return{values:c,results:await(0,y.evaluateResultsCommon)(e,i,s,r,this.config.transform?.runner)}}let l=await this.abi.getAbiForAction(a),d=new M.TransactionEventsParser({abi:l}),C=new M.SmartContractTransactionsOutcomeParser({abi:l}).parseExecute({transactionOnNetwork:t,function:a.func||void 0});for(let[v,g]of Object.entries(e.results)){if(g.startsWith(y.WarpConstants.Transform.Prefix))continue;if(g.startsWith("input.")){i[v]=g;continue}let B=(0,y.parseResultsOutIndex)(g);if(B!==null&&B!==s){i[v]=null;continue}let[E,A,k]=g.split(".");if(E==="event"){if(!A||isNaN(Number(k)))continue;let I=Number(k),x=(0,M.findEventsByFirstTopic)(t,A),L=d.parseEvents({events:x})[0],K=Object.values(L)[I]||null;c.push(K),i[v]=K&&K.valueOf()}else if(E==="out"||E.startsWith("out[")){if(!A)continue;let I=Number(A),x=C.values[I-1]||null;k&&(x=x[k]||null),x&&typeof x=="object"&&(x="toFixed"in x?x.toFixed():x.valueOf()),c.push(x),i[v]=x&&x.valueOf()}else i[v]=g}return{values:c,results:await(0,y.evaluateResultsCommon)(e,i,s,r)}}async extractQueryResults(e,t,r,a){let s=t.map(l=>this.serializer.typedToString(l)),c=t.map(l=>this.serializer.typedToNative(l)[1]),i={};if(!e.results)return{values:s,valuesRaw:c,results:i};let m=l=>{let d=l.split(".").slice(1).map(C=>parseInt(C)-1);if(d.length===0)return;let h=c[d[0]];for(let C=1;C<d.length;C++){if(h==null)return;h=h[d[C]]}return h};for(let[l,d]of Object.entries(e.results)){if(d.startsWith(y.WarpConstants.Transform.Prefix))continue;let h=(0,y.parseResultsOutIndex)(d);if(h!==null&&h!==r){i[l]=null;continue}d.startsWith("out.")||d==="out"||d.startsWith("out[")?i[l]=m(d)||null:i[l]=d}return{values:s,valuesRaw:c,results:await(0,y.evaluateResultsCommon)(e,i,r,a)}}async resolveWarpResultsRecursively(e){let t=e.warp,r=e.entryActionIndex,a=e.executor,s=e.inputs,c=e.meta,i=new Map,m=new Set,l=this;async function d(g,B=[]){if(i.has(g))return i.get(g);if(m.has(g))throw new Error(`Circular dependency detected at action ${g}`);m.add(g);let E=t.actions[g-1];if(!E)throw new Error(`Action ${g} not found`);let A;if(E.type==="query")A=await a.executeQuery(t,g,B);else if(E.type==="collect")A=await a.executeCollect(t,g,B,c);else throw new Error(`Unsupported or interactive action type: ${E.type}`);if(i.set(g,A),t.results)for(let k of Object.values(t.results)){let x=String(k).match(/^out\[(\d+)\]/);if(x){let L=parseInt(x[1],10);L!==g&&!i.has(L)&&await d(L)}}return m.delete(g),A}await d(r,s);let h={};for(let g of i.values())for(let[B,E]of Object.entries(g.results))E!==null?h[B]=E:B in h||(h[B]=null);let C=await(0,y.evaluateResultsCommon)(t,h,r,s,this.config.transform?.runner);return{...i.get(r),action:r,results:C}}};var p=require("@multiversx/sdk-core"),ve=(o,e)=>o?p.OptionValue.newProvided(o):e?p.OptionValue.newMissingTyped(e):p.OptionValue.newMissing(),be=(o,e)=>o?new p.OptionalValue(o.getType(),o):e?new p.OptionalValue(e):p.OptionalValue.newMissing(),Ee=o=>{if(o.length===0)throw new Error("Cannot create a list from an empty array");let e=o[0].getType();return new p.List(e,o)},Ae=o=>p.VariadicValue.fromItems(...o),Be=o=>{let e=o.map(t=>t.getType());return new p.CompositeValue(new p.CompositeType(...e),o)},Ie=o=>p.StringValue.fromUTF8(o),Ve=o=>new p.U8Value(o),Ne=o=>new p.U16Value(o),Se=o=>new p.U32Value(o),Re=o=>new p.U64Value(o),Fe=o=>new p.BigUIntValue(BigInt(o)),ke=o=>new p.BooleanValue(o),Pe=o=>new p.AddressValue(p.Address.newFromBech32(o)),Ue=o=>new p.TokenIdentifierValue(o),_e=o=>p.BytesValue.fromHex(o),re=o=>new p.Struct(new p.StructType("EsdtTokenPayment",[new p.FieldDefinition("token_identifier","",new p.TokenIdentifierType),new p.FieldDefinition("token_nonce","",new p.U64Type),new p.FieldDefinition("amount","",new p.BigUIntType)]),[new p.Field(new p.TokenIdentifierValue(o.token.identifier),"token_identifier"),new p.Field(new p.U64Value(BigInt(o.token.nonce)),"token_nonce"),new p.Field(new p.BigUIntValue(BigInt(o.amount)),"amount")]),Oe=o=>new p.CodeMetadataValue(p.CodeMetadata.newFromBytes(Uint8Array.from(Buffer.from(o,"hex")))),Me=()=>new p.NothingValue;var $e="EGLD-000000",w=class o{constructor(e,t){this.config=e;this.chain=t;this.serializer=new R,this.abi=new F(this.config,this.chain),this.results=new U(this.config,this.chain)}async createTransaction(e){let t=(0,W.getWarpActionByIndex)(e.warp,e.action),r=null;if(t.type==="transfer")r=await this.createTransferTransaction(e);else if(t.type==="contract")r=await this.createContractCallTransaction(e);else{if(t.type==="query")throw new Error("WarpMultiversxExecutor: Invalid action type for createTransactionForExecute; Use executeQuery instead");if(t.type==="collect")throw new Error("WarpMultiversxExecutor: Invalid action type for createTransactionForExecute; Use executeCollect instead")}if(!r)throw new Error(`WarpMultiversxExecutor: Invalid action type (${t.type})`);return r}async createTransferTransaction(e){let t=this.config.user?.wallets?.[e.chain.name];if(!t)throw new Error("WarpMultiversxExecutor: createTransfer - user address not set");let r=f.Address.newFromBech32(t),a=new f.TransactionsFactoryConfig({chainID:e.chain.chainId}),s=e.data?Buffer.from(this.serializer.stringToTyped(e.data).valueOf()):null;return new f.TransferTransactionsFactory({config:a}).createTransactionForTransfer(r,{receiver:f.Address.newFromBech32(e.destination),nativeAmount:e.value,tokenTransfers:this.toTokenTransfers(e.transfers),data:s?new Uint8Array(s):void 0})}async createContractCallTransaction(e){let t=this.config.user?.wallets?.[e.chain.name];if(!t)throw new Error("WarpMultiversxExecutor: createContractCall - user address not set");let r=(0,W.getWarpActionByIndex)(e.warp,e.action),a=f.Address.newFromBech32(t),s=e.args.map(i=>this.serializer.stringToTyped(i)),c=new f.TransactionsFactoryConfig({chainID:e.chain.chainId});return new f.SmartContractTransactionsFactory({config:c}).createTransactionForExecute(a,{contract:f.Address.newFromBech32(e.destination),function:"func"in r&&r.func||"",gasLimit:"gasLimit"in r?BigInt(r.gasLimit||0):0n,arguments:s,tokenTransfers:this.toTokenTransfers(e.transfers),nativeTransferAmount:e.value})}async executeQuery(e){let t=(0,W.getWarpActionByIndex)(e.warp,e.action);if(t.type!=="query")throw new Error(`WarpMultiversxExecutor: Invalid action type for executeQuery: ${t.type}`);let r=await this.abi.getAbiForAction(t),a=e.args.map(I=>this.serializer.stringToTyped(I)),s=o.getChainEntrypoint(e.chain,this.config.env,this.config),c=f.Address.newFromBech32(e.destination),i=s.createSmartContractController(r),m=i.createQuery({contract:c,function:t.func||"",arguments:a}),l=await i.runQuery(m),d=l.returnCode==="ok",h=new f.ArgSerializer,C=r.getEndpoint(l.function||t.func||""),v=(l.returnDataParts||[]).map(I=>Buffer.from(I)),g=h.buffersToValues(v,C.output),{values:B,valuesRaw:E,results:A}=await this.results.extractQueryResults(e.warp,g,e.action,e.resolvedInputs),k=(0,W.getNextInfo)(this.config,[],e.warp,e.action,A);return{success:d,warp:e.warp,action:e.action,user:this.config.user?.wallets?.[e.chain.name]||null,txHash:null,tx:null,next:k,values:B,valuesRaw:E,results:A,messages:(0,W.applyResultsToMessages)(e.warp,A)}}async preprocessInput(e,t,r,a){if(r==="asset"){let[s,c,i,m]=a.split(W.WarpConstants.ArgCompositeSeparator);if(m)return t;let l=new f.Token({identifier:s,nonce:BigInt(c||0)});if(!new f.TokenComputer().isFungible(l))return t;let C=(0,W.findKnownTokenById)(s)?.decimals;if(C||(C=(await(await fetch(`${e.defaultApiUrl}/tokens/${s}`)).json()).decimals),!C)throw new Error(`WarpActionExecutor: Decimals not found for token ${s}`);let v=re(new f.TokenTransfer({token:l,amount:(0,W.shiftBigintBy)(i,C)}));return this.serializer.typedToString(v)+W.WarpConstants.ArgCompositeSeparator+C}return t}static getChainEntrypoint(e,t,r){let a="warp-sdk",c=r?(0,W.getProviderUrl)(r,e.name,t,e.defaultApiUrl):e.defaultApiUrl;return t==="devnet"?new f.DevnetEntrypoint({url:c,kind:"api",clientName:a}):t==="testnet"?new f.TestnetEntrypoint({url:c,kind:"api",clientName:a}):new f.MainnetEntrypoint({url:c,kind:"api",clientName:a})}async signMessage(e,t){let r=f.UserSecretKey.fromString(t);return(await new f.UserSigner(r).sign(new Uint8Array(Buffer.from(e,"utf-8")))).toString()}toTokenTransfers(e){return e.map(t=>t.identifier===this.chain.nativeToken.identifier?{...t,identifier:$e}:t).map(t=>new f.TokenTransfer({token:new f.Token({identifier:t.identifier,nonce:t.nonce}),amount:t.amount}))}};var q=class{constructor(e){this.config=e}async getContract(e,t){try{let s=await w.getChainEntrypoint(t,this.config.env).createNetworkProvider().doGetGeneric(`accounts/${e}`);return{address:e,owner:s.ownerAddress,verified:s.isVerified||!1}}catch(r){return ne.WarpLogger.error("WarpContractLoader: getContract error",r),null}}async getVerificationInfo(e,t){try{let s=await w.getChainEntrypoint(t,this.config.env).createNetworkProvider().doGetGeneric(`accounts/${e}/verification`);return{codeHash:s.codeHash,abi:s.source.abi}}catch(r){return ne.WarpLogger.error("WarpContractLoader: getVerificationInfo error",r),null}}};var F=class{constructor(e,t){this.config=e;this.chain=t;this.contractLoader=new q(this.config),this.cache=new V.WarpCache(this.config.cache?.type)}async createFromRaw(e){return JSON.parse(e)}async createFromTransaction(e){let t=await this.createFromRaw(e.data.toString());return t.meta={chain:this.chain.name,hash:e.hash,creator:e.sender.toBech32(),createdAt:new Date(e.timestamp*1e3).toISOString()},t}async createFromTransactionHash(e,t){let r=V.WarpCacheKey.WarpAbi(this.config.env,e);if(t){let c=this.cache.get(r);if(c)return V.WarpLogger.info(`WarpAbiBuilder (createFromTransactionHash): Warp abi found in cache: ${e}`),c}let s=w.getChainEntrypoint(this.chain,this.config.env).createNetworkProvider();try{let c=await s.getTransaction(e),i=await this.createFromTransaction(c);return t&&t.ttl&&i&&this.cache.set(r,i,t.ttl),i}catch(c){return V.WarpLogger.error("WarpAbiBuilder: Error creating from transaction hash",c),null}}async getAbiForAction(e){if(e.abi)return await this.fetchAbi(e);if(!e.address)throw new Error("WarpActionExecutor: Address not found");let t=await this.contractLoader.getVerificationInfo(e.address,this.chain);if(!t)throw new Error("WarpActionExecutor: Verification info not found");return J.AbiRegistry.create(t.abi)}async fetchAbi(e){if(!e.abi)throw new Error("WarpActionExecutor: ABI not found");if(e.abi.startsWith(V.WarpConstants.IdentifierType.Hash)){let t=e.abi.split(V.WarpConstants.IdentifierParamSeparatorDefault)[1],r=await this.createFromTransactionHash(t);if(!r)throw new Error(`WarpActionExecutor: ABI not found for hash: ${e.abi}`);return J.AbiRegistry.create(r.content)}else{let r=await(await fetch(e.abi)).json();return J.AbiRegistry.create(r)}}};var _=require("@multiversx/sdk-core"),X=require("@vleap/warps"),me=require("buffer");var D=class{constructor(e,t){this.config=e;this.chain=t;this.core=new X.WarpBrandBuilder(e)}async createInscriptionTransaction(e){let t=this.config.user?.wallets?.[this.chain.name];if(!t)throw new Error("BrandBuilder: user address not set");let r=new _.TransactionsFactoryConfig({chainID:this.chain.chainId}),a=new _.TransferTransactionsFactory({config:r}),s=_.Address.newFromBech32(t),c=JSON.stringify(e);return await a.createTransactionForNativeTokenTransfer(s,{receiver:_.Address.newFromBech32(t),nativeAmount:BigInt(0),data:Uint8Array.from(me.Buffer.from(c))})}async createFromTransaction(e,t=!1){return await this.core.createFromRaw(e.data.toString(),t)}async createFromTransactionHash(e){let r=w.getChainEntrypoint(this.chain,this.config.env).createNetworkProvider();try{let a=await r.getTransaction(e);return this.createFromTransaction(a)}catch(a){return X.WarpLogger.error("BrandBuilder: Error creating from transaction hash",a),null}}};var O=require("@multiversx/sdk-core"),N=require("@vleap/warps");var z=class extends N.WarpBuilder{constructor(t,r){super(t);this.config=t;this.chain=r;this.cache=new N.WarpCache(t.cache?.type),this.core=new N.WarpBuilder(t)}async createInscriptionTransaction(t){let r=this.config.user?.wallets?.[this.chain.name];if(!r)throw new Error("WarpBuilder: user address not set");let a=new O.TransactionsFactoryConfig({chainID:this.chain.chainId}),s=new O.TransferTransactionsFactory({config:a}),c=O.Address.newFromBech32(r),i=JSON.stringify(t),m=await s.createTransactionForTransfer(c,{receiver:O.Address.newFromBech32(r),nativeAmount:BigInt(0),data:Uint8Array.from(Buffer.from(i))});return m.gasLimit=m.gasLimit+BigInt(2e6),m}async createFromTransaction(t,r=!1){let a=await this.core.createFromRaw(t.data.toString(),r);return a.meta={chain:this.chain.name,hash:t.hash,creator:t.sender.toBech32(),createdAt:new Date(t.timestamp*1e3).toISOString()},a}async createFromTransactionHash(t,r){let a=N.WarpCacheKey.Warp(this.config.env,t);if(r){let i=this.cache.get(a);if(i)return N.WarpLogger.info(`WarpBuilder (createFromTransactionHash): Warp found in cache: ${t}`),i}let c=w.getChainEntrypoint(this.chain,this.config.env).createNetworkProvider();try{let i=await c.getTransaction(t),m=await this.createFromTransaction(i);return r&&r.ttl&&m&&this.cache.set(a,m,r.ttl),m}catch(i){return N.WarpLogger.error("WarpBuilder: Error creating from transaction hash",i),null}}};var ae=require("@multiversx/sdk-core");var H=class{constructor(e,t){this.config=e;this.chain=t}async getAccount(e){let r=await w.getChainEntrypoint(this.chain,this.config.env,this.config).createNetworkProvider().getAccount(ae.Address.newFromBech32(e));return{chain:this.chain.name,address:r.address.toBech32(),balance:r.balance}}async getAccountAssets(e){return(await w.getChainEntrypoint(this.chain,this.config.env,this.config).createNetworkProvider().getFungibleTokensOfAccount(ae.Address.newFromBech32(e))).map(a=>({chain:this.chain.name,identifier:a.token.identifier,name:a.raw.name,amount:a.amount,decimals:a.raw.decimals,logoUrl:a.raw.assets?.pngUrl||""}))}async getAccountActions(e,t){let r=w.getChainEntrypoint(this.chain,this.config.env,this.config).createNetworkProvider(),a=`accounts/${e}/transactions`,s=new URLSearchParams,c=t?.size||25,i=t?.page||0;if(i>0){let l=i*c;s.append("from",l.toString())}return c!==25&&s.append("size",c.toString()),s.toString()&&(a+=`?${s.toString()}`),(await r.doGetGeneric(a)).map(l=>({chain:this.chain.name,id:l.txHash,receiver:l.receiver,sender:l.sender,value:l.value,function:l.function,status:l.status,createdAt:new Date(l.timestampMs||l.timestamp*1e3).toISOString()}))}};var Le={Egld:{Identifier:"EGLD",EsdtIdentifier:"EGLD-000000",DisplayName:"eGold",Decimals:18}},fe=(r=>(r.MultiversxExplorer="multiversx_explorer",r.MultiversxExplorerDevnet="multiversx_explorer_devnet",r.MultiversxExplorerTestnet="multiversx_explorer_testnet",r))(fe||{}),de=(r=>(r.VibechainExplorer="vibechain_explorer",r.VibechainExplorerDevnet="vibechain_explorer_devnet",r.VibechainExplorerTestnet="vibechain_explorer_testnet",r))(de||{}),se={multiversx:{mainnet:["multiversx_explorer"],testnet:["multiversx_explorer_testnet"],devnet:["multiversx_explorer_devnet"]},vibechain:{mainnet:["vibechain_explorer"],testnet:["vibechain_explorer_testnet"],devnet:["vibechain_explorer_devnet"]}},P={multiversx_explorer:"https://explorer.multiversx.com",multiversx_explorer_devnet:"https://devnet-explorer.multiversx.com",multiversx_explorer_testnet:"https://testnet-explorer.multiversx.com",vibechain_explorer:"https://vibeox-explorer.multiversx.com",vibechain_explorer_devnet:"https://vibeox-explorer.multiversx.com",vibechain_explorer_testnet:"https://vibeox-explorer.multiversx.com"};var Q=class{constructor(e,t){this.chain=e;this.config=t}getExplorers(){let e=se[this.chain];if(!e)return["multiversx_explorer"];let t=e[this.config.env];return t||["multiversx_explorer"]}getPrimaryExplorer(){return this.getExplorers()[0]}getExplorerUrlByName(e){let t=this.config.preferences?.explorers?.[this.chain];if(t&&!e){let s=P[t];if(s)return s}if(e){let s=P[e];if(s)return s}let r=this.getPrimaryExplorer();return P[r]||P[r]}getAccountUrl(e,t){return`${this.getExplorerUrlByName(t)}/accounts/${e}`}getTransactionUrl(e,t){return`${this.getExplorerUrlByName(t)}/transactions/${e}`}getBlockUrl(e,t){return`${this.getExplorerUrlByName(t)}/blocks/${e}`}getAssetUrl(e,t){return`${this.getExplorerUrlByName(t)}/tokens/${e}`}getContractUrl(e,t){return`${this.getExplorerUrlByName(t)}/accounts/${e}`}getAllExplorers(){return this.getExplorers()}getExplorerByName(e){return this.getExplorers().find(r=>r.toLowerCase()===e.toLowerCase())}getAccountUrls(e){let t=this.getAllExplorers(),r={};return t.forEach(a=>{let s=P[a];s&&(r[a]=`${s}/accounts/${e}`)}),r}getTransactionUrls(e){let t=this.getAllExplorers(),r={};return t.forEach(a=>{let s=P[a];s&&(r[a]=`${s}/transactions/${e}`)}),r}};var u=require("@multiversx/sdk-core"),S=require("@vleap/warps");var ie={buildInfo:{rustc:{version:"1.86.0",commitHash:"05f9846f893b09a1be1fc8560e33fc3c815cfecb",commitDate:"2025-03-31",channel:"Stable",short:"rustc 1.86.0 (05f9846f8 2025-03-31)"},contractCrate:{name:"registry",version:"0.0.1"},framework:{name:"multiversx-sc",version:"0.51.1"}},name:"RegistryContract",constructor:{inputs:[{name:"unit_price",type:"BigUint"},{name:"vault",type:"Address"}],outputs:[]},upgradeConstructor:{inputs:[],outputs:[]},endpoints:[{name:"registerWarp",mutability:"mutable",payableInTokens:["EGLD"],inputs:[{name:"hash",type:"bytes"},{name:"alias_opt",type:"optional<bytes>",multi_arg:!0},{name:"brand_opt",type:"optional<bytes>",multi_arg:!0}],outputs:[],allow_multiple_var_args:!0},{name:"unregisterWarp",mutability:"mutable",inputs:[{name:"warp",type:"bytes"}],outputs:[]},{name:"upgradeWarp",mutability:"mutable",payableInTokens:["EGLD"],inputs:[{name:"alias",type:"bytes"},{name:"new_warp",type:"bytes"}],outputs:[]},{name:"setWarpAlias",mutability:"mutable",payableInTokens:["EGLD"],inputs:[{name:"hash",type:"bytes"},{name:"alias",type:"bytes"}],outputs:[]},{name:"forceRemoveAlias",mutability:"mutable",inputs:[{name:"hash",type:"bytes"}],outputs:[]},{name:"verifyWarp",mutability:"mutable",inputs:[{name:"warp",type:"bytes"}],outputs:[]},{name:"transferOwnership",mutability:"mutable",inputs:[{name:"warp",type:"bytes"},{name:"new_owner",type:"Address"}],outputs:[]},{name:"getUserWarps",mutability:"readonly",inputs:[{name:"address",type:"Address"}],outputs:[{type:"variadic<InfoView>",multi_result:!0}]},{name:"getInfoByAlias",mutability:"readonly",inputs:[{name:"alias",type:"bytes"}],outputs:[{type:"InfoView"}]},{name:"getInfoByHash",mutability:"readonly",inputs:[{name:"hash",type:"bytes"}],outputs:[{type:"InfoView"}]},{name:"setVault",onlyOwner:!0,mutability:"mutable",inputs:[{name:"vault",type:"Address"}],outputs:[]},{name:"setUnitPrice",onlyOwner:!0,mutability:"mutable",inputs:[{name:"amount",type:"BigUint"}],outputs:[]},{name:"addAdmin",onlyOwner:!0,mutability:"mutable",inputs:[{name:"address",type:"Address"}],outputs:[]},{name:"removeAdmin",onlyOwner:!0,mutability:"mutable",inputs:[{name:"address",type:"Address"}],outputs:[]},{name:"getConfig",mutability:"readonly",inputs:[],outputs:[{type:"ConfigView"}]},{name:"registerBrand",mutability:"mutable",payableInTokens:["EGLD"],inputs:[{name:"hash",type:"bytes"}],outputs:[]},{name:"brandWarp",mutability:"mutable",payableInTokens:["EGLD"],inputs:[{name:"warp",type:"bytes"},{name:"brand",type:"bytes"}],outputs:[]},{name:"getUserBrands",mutability:"readonly",inputs:[{name:"user",type:"Address"}],outputs:[{type:"variadic<bytes>",multi_result:!0}]},{name:"setChain",onlyOwner:!0,mutability:"mutable",inputs:[{name:"name",type:"bytes"},{name:"display_name",type:"bytes"},{name:"chain_id",type:"bytes"},{name:"block_time",type:"u32"},{name:"address_hrp",type:"bytes"},{name:"api_url",type:"bytes"},{name:"explorer_url",type:"bytes"},{name:"native_token",type:"bytes"}],outputs:[]},{name:"removeChain",onlyOwner:!0,mutability:"mutable",inputs:[{name:"name",type:"bytes"}],outputs:[]},{name:"getChain",mutability:"readonly",inputs:[{name:"name",type:"bytes"}],outputs:[{type:"ChainView"}]},{name:"getChains",mutability:"readonly",inputs:[],outputs:[{type:"variadic<ChainView>",multi_result:!0}]}],events:[{identifier:"warpRegistered",inputs:[{name:"hash",type:"bytes",indexed:!0},{name:"alias",type:"bytes",indexed:!0},{name:"trust",type:"bytes",indexed:!0}]},{identifier:"warpUnregistered",inputs:[{name:"hash",type:"bytes",indexed:!0}]},{identifier:"warpUpgraded",inputs:[{name:"alias",type:"bytes",indexed:!0},{name:"new_warp",type:"bytes",indexed:!0},{name:"trust",type:"bytes",indexed:!0}]},{identifier:"warpVerified",inputs:[{name:"hash",type:"bytes",indexed:!0}]},{identifier:"aliasUpdated",inputs:[{name:"hash",type:"bytes",indexed:!0},{name:"alias",type:"bytes",indexed:!0}]},{identifier:"ownershipTransferred",inputs:[{name:"warp",type:"bytes",indexed:!0},{name:"old_owner",type:"Address",indexed:!0},{name:"new_owner",type:"Address",indexed:!0}]}],esdtAttributes:[],hasCallback:!1,types:{ChainView:{type:"struct",fields:[{name:"name",type:"bytes"},{name:"display_name",type:"bytes"},{name:"chain_id",type:"bytes"},{name:"block_time",type:"u32"},{name:"address_hrp",type:"bytes"},{name:"api_url",type:"bytes"},{name:"explorer_url",type:"bytes"},{name:"native_token",type:"bytes"}]},ConfigView:{type:"struct",fields:[{name:"unit_price",type:"BigUint"},{name:"admins",type:"List<Address>"}]},InfoView:{type:"struct",fields:[{name:"hash",type:"bytes"},{name:"alias",type:"Option<bytes>"},{name:"trust",type:"bytes"},{name:"owner",type:"Address"},{name:"created_at",type:"u64"},{name:"upgraded_at",type:"u64"},{name:"brand",type:"Option<bytes>"},{name:"upgrade",type:"Option<bytes>"}]}}};var b=o=>{if(o==="devnet")return"erd1qqqqqqqqqqqqqpgqje2f99vr6r7sk54thg03c9suzcvwr4nfl3tsfkdl36";if(o==="testnet")throw new Error("Multiversx testnet is not supported");return"erd1qqqqqqqqqqqqqpgq3mrpj3u6q7tejv6d7eqhnyd27n9v5c5tl3ts08mffe"};var Y=o=>({hash:o.hash.toString("hex"),alias:o.alias?.toString()||null,trust:o.trust.toString(),owner:o.owner.toString(),createdAt:o.created_at.toNumber(),upgradedAt:o.upgraded_at?.toNumber(),brand:o.brand?.toString("hex")||null,upgrade:o.upgrade?.toString("hex")||null}),he=o=>({unitPrice:BigInt(o.unit_price.toString()),admins:o.admins.map(e=>e.toBech32())});var G=class{constructor(e,t){this.config=e;this.chain=t;this.cache=new S.WarpCache(e.cache?.type),this.registryConfig={unitPrice:BigInt(0),admins:[]},this.userWallet=this.config.user?.wallets?.[this.chain.name]||null}async init(){await this.loadRegistryConfigs()}getRegistryConfig(){return this.registryConfig}async createWarpRegisterTransaction(e,t,r){if(this.registryConfig.unitPrice===BigInt(0))throw new Error("WarpRegistry: config not loaded. forgot to call init()?");if(!this.userWallet)throw new Error("WarpRegistry: user address not set");let a=u.Address.newFromBech32(this.userWallet),s=()=>this.isCurrentUserAdmin()?BigInt(0):t&&r?this.registryConfig.unitPrice*BigInt(3):t?this.registryConfig.unitPrice*BigInt(2):this.registryConfig.unitPrice,c=()=>t&&r?[u.BytesValue.fromHex(e),u.BytesValue.fromUTF8(t),u.BytesValue.fromHex(r)]:t?[u.BytesValue.fromHex(e),u.BytesValue.fromUTF8(t)]:[u.BytesValue.fromHex(e)];return await this.getFactory().createTransactionForExecute(a,{contract:u.Address.newFromBech32(b(this.config.env)),function:"registerWarp",gasLimit:BigInt(1e7),nativeTransferAmount:s(),arguments:c()})}async createWarpUnregisterTransaction(e){if(!this.userWallet)throw new Error("WarpRegistry: user address not set");let t=u.Address.newFromBech32(this.userWallet);return await this.getFactory().createTransactionForExecute(t,{contract:u.Address.newFromBech32(b(this.config.env)),function:"unregisterWarp",gasLimit:BigInt(1e7),arguments:[u.BytesValue.fromHex(e)]})}async createWarpUpgradeTransaction(e,t){if(this.registryConfig.unitPrice===BigInt(0))throw new Error("WarpRegistry: config not loaded. forgot to call init()?");if(!this.userWallet)throw new Error("WarpRegistry: user address not set");let r=u.Address.newFromBech32(this.userWallet);return await this.getFactory().createTransactionForExecute(r,{contract:u.Address.newFromBech32(b(this.config.env)),function:"upgradeWarp",gasLimit:BigInt(1e7),nativeTransferAmount:this.isCurrentUserAdmin()?void 0:this.registryConfig.unitPrice,arguments:[u.BytesValue.fromUTF8(e),u.BytesValue.fromHex(t)]})}async createWarpAliasSetTransaction(e,t){if(!this.userWallet)throw new Error("WarpRegistry: user address not set");let r=u.Address.newFromBech32(this.userWallet);return await this.getFactory().createTransactionForExecute(r,{contract:u.Address.newFromBech32(b(this.config.env)),function:"setWarpAlias",gasLimit:BigInt(1e7),nativeTransferAmount:this.isCurrentUserAdmin()?void 0:this.registryConfig.unitPrice,arguments:[u.BytesValue.fromHex(e),u.BytesValue.fromUTF8(t)]})}async createWarpVerifyTransaction(e){if(!this.userWallet)throw new Error("WarpRegistry: user address not set");let t=u.Address.newFromBech32(this.userWallet);return await this.getFactory().createTransactionForExecute(t,{contract:u.Address.newFromBech32(b(this.config.env)),function:"verifyWarp",gasLimit:BigInt(1e7),arguments:[u.BytesValue.fromHex(e)]})}async createWarpTransferOwnershipTransaction(e,t){if(!this.userWallet)throw new Error("WarpRegistry: user address not set");let r=u.Address.newFromBech32(this.userWallet);return await this.getFactory().createTransactionForExecute(r,{contract:u.Address.newFromBech32(b(this.config.env)),function:"transferOwnership",gasLimit:BigInt(1e7),arguments:[u.BytesValue.fromHex(e),new u.AddressValue(new u.Address(t))]})}async createBrandRegisterTransaction(e){if(this.registryConfig.unitPrice===BigInt(0))throw new Error("WarpRegistry: config not loaded. forgot to call init()?");if(!this.userWallet)throw new Error("WarpRegistry: user address not set");let t=u.Address.newFromBech32(this.userWallet);return await this.getFactory().createTransactionForExecute(t,{contract:u.Address.newFromBech32(b(this.config.env)),function:"registerBrand",gasLimit:BigInt(1e7),nativeTransferAmount:this.isCurrentUserAdmin()?void 0:this.registryConfig.unitPrice,arguments:[u.BytesValue.fromHex(e)]})}async createWarpBrandingTransaction(e,t){if(!this.userWallet)throw new Error("WarpRegistry: user address not set");let r=u.Address.newFromBech32(this.userWallet);return await this.getFactory().createTransactionForExecute(r,{contract:u.Address.newFromBech32(b(this.config.env)),function:"brandWarp",gasLimit:BigInt(1e7),nativeTransferAmount:this.isCurrentUserAdmin()?void 0:this.registryConfig.unitPrice,arguments:[u.BytesValue.fromHex(e),u.BytesValue.fromHex(t)]})}async getInfoByAlias(e,t){try{let r=S.WarpCacheKey.RegistryInfo(this.config.env,e),a=t?this.cache.get(r):null;if(a)return S.WarpLogger.info(`WarpRegistry (getInfoByAlias): RegistryInfo found in cache: ${e}`),a;let s=u.Address.newFromBech32(b(this.config.env)),c=this.getController(),i=c.createQuery({contract:s,function:"getInfoByAlias",arguments:[u.BytesValue.fromUTF8(e)]}),m=await c.runQuery(i),[l]=c.parseQueryResponse(m),d=l?Y(l):null,h=d?.brand?await this.fetchBrand(d.brand):null;return t&&t.ttl&&this.cache.set(r,{registryInfo:d,brand:h},t.ttl),{registryInfo:d,brand:h}}catch{return{registryInfo:null,brand:null}}}async getInfoByHash(e,t){try{let r=S.WarpCacheKey.RegistryInfo(this.config.env,e);if(t){let h=this.cache.get(r);if(h)return S.WarpLogger.info(`WarpRegistry (getInfoByHash): RegistryInfo found in cache: ${e}`),h}let a=u.Address.newFromBech32(b(this.config.env)),s=this.getController(),c=s.createQuery({contract:a,function:"getInfoByHash",arguments:[u.BytesValue.fromHex(e)]}),i=await s.runQuery(c),[m]=s.parseQueryResponse(i),l=m?Y(m):null,d=l?.brand?await this.fetchBrand(l.brand):null;return t&&t.ttl&&this.cache.set(r,{registryInfo:l,brand:d},t.ttl),{registryInfo:l,brand:d}}catch{return{registryInfo:null,brand:null}}}async getUserWarpRegistryInfos(e){try{let t=e||this.userWallet;if(!t)throw new Error("WarpRegistry: user address not set");let r=u.Address.newFromBech32(b(this.config.env)),a=this.getController(),s=a.createQuery({contract:r,function:"getUserWarps",arguments:[new u.AddressValue(new u.Address(t))]}),c=await a.runQuery(s),[i]=a.parseQueryResponse(c);return i.map(Y)}catch{return[]}}async getUserBrands(e){try{let t=e||this.userWallet;if(!t)throw new Error("WarpRegistry: user address not set");let r=u.Address.newFromBech32(b(this.config.env)),a=this.getController(),s=a.createQuery({contract:r,function:"getUserBrands",arguments:[new u.AddressValue(new u.Address(t))]}),c=await a.runQuery(s),[i]=a.parseQueryResponse(c),m=i.map(h=>h.toString("hex")),l={ttl:365*24*60*60};return(await Promise.all(m.map(h=>this.fetchBrand(h,l)))).filter(h=>h!==null)}catch{return[]}}async fetchBrand(e,t){let r=S.WarpCacheKey.Brand(this.config.env,e),a=t?this.cache.get(r):null;if(a)return S.WarpLogger.info(`WarpRegistry (fetchBrand): Brand found in cache: ${e}`),a;let c=w.getChainEntrypoint(this.chain,this.config.env).createNetworkProvider();try{let i=await c.getTransaction(e),m=JSON.parse(i.data.toString());return m.meta={hash:i.hash,creator:i.sender.toBech32(),createdAt:new Date(i.timestamp*1e3).toISOString()},t&&t.ttl&&this.cache.set(r,m,t.ttl),m}catch{return null}}async loadRegistryConfigs(){let e=u.Address.newFromBech32(b(this.config.env)),t=this.getController(),[r]=await t.query({contract:e,function:"getConfig",arguments:[]}),a=r?he(r):null;this.registryConfig=a||{unitPrice:BigInt(0),admins:[]}}getFactory(){let e=new u.TransactionsFactoryConfig({chainID:this.chain.chainId}),t=u.AbiRegistry.create(ie);return new u.SmartContractTransactionsFactory({config:e,abi:t})}getController(){let e=w.getChainEntrypoint(this.chain,this.config.env),t=u.AbiRegistry.create(ie);return e.createSmartContractController(t)}isCurrentUserAdmin(){return!!this.userWallet&&this.registryConfig.admins.includes(this.userWallet)}};var j=(o,e,t)=>(r,a)=>{let s=t[r.env];return{chain:o,chainInfo:s,prefix:e,builder:()=>new z(r,s),executor:new w(r,s),results:new U(r,s),serializer:new R,registry:new G(r,s),explorer:new Q(o,r),abiBuilder:()=>new F(r,s),brandBuilder:()=>new D(r,s),dataLoader:new H(r,s),registerTypes:c=>{c.registerType("token",{stringToNative:i=>i,nativeToString:i=>`token:${i}`}),c.registerType("codemeta",{stringToNative:i=>i,nativeToString:i=>`codemeta:${i}`})}}};var Z={chain:$.WarpChainName.Multiversx,identifier:"EGLD",name:"eGold",decimals:18,logoUrl:"https://vleap.ai/images/tokens/egld.svg"},oe=j($.WarpChainName.Multiversx,"mvx",{mainnet:{name:$.WarpChainName.Multiversx,displayName:"MultiversX",chainId:"1",blockTime:6e3,addressHrp:"erd",defaultApiUrl:"https://api.multiversx.com",nativeToken:Z},testnet:{name:$.WarpChainName.Multiversx,displayName:"MultiversX Testnet",chainId:"T",blockTime:6e3,addressHrp:"erd",defaultApiUrl:"https://testnet-api.multiversx.com",nativeToken:Z},devnet:{name:$.WarpChainName.Multiversx,displayName:"MultiversX Devnet",chainId:"D",blockTime:6e3,addressHrp:"erd",defaultApiUrl:"https://devnet-api.multiversx.com",nativeToken:Z}});var ee=require("@vleap/warps");var ge={chain:ee.WarpChainName.Vibechain,identifier:"VIBE",name:"VIBE",decimals:18,logoUrl:"https://vleap.ai/images/tokens/vibe.svg"},ce={name:ee.WarpChainName.Vibechain,displayName:"VibeChain",chainId:"V",blockTime:600,addressHrp:"vibe",defaultApiUrl:"https://vibeox-api.multiversx.com",nativeToken:ge},pe=j(ee.WarpChainName.Vibechain,"vibe",{mainnet:ce,testnet:ce,devnet:ce});var De=(o,e)=>[oe(o,e),pe(o,e)],ze=()=>[ue.WarpChainName.Multiversx,ue.WarpChainName.Vibechain];0&&(module.exports={ExplorerUrls,MultiversxExplorers,MultiversxExplorersConfig,NativeTokenEgld,NativeTokenVibe,VibechainExplorers,WarpMultiversxAbiBuilder,WarpMultiversxBrandBuilder,WarpMultiversxBuilder,WarpMultiversxConstants,WarpMultiversxContractLoader,WarpMultiversxDataLoader,WarpMultiversxExecutor,WarpMultiversxExplorer,WarpMultiversxRegistry,WarpMultiversxResults,WarpMultiversxSerializer,address_value,biguint_value,boolean_value,codemeta_value,composite_value,createMultiversxAdapter,esdt_value,getAllMultiversxAdapters,getAllMultiversxChainNames,getMultiversxAdapter,getMultiversxRegistryAddress,getVibechainAdapter,hex_value,list_value,nothing_value,option_value,optional_value,string_value,token_value,u16_value,u32_value,u64_value,u8_value,variadic_value});
|
|
1
|
+
"use strict";var re=Object.defineProperty;var Ce=Object.getOwnPropertyDescriptor;var xe=Object.getOwnPropertyNames;var We=Object.prototype.hasOwnProperty;var Te=(o,e)=>{for(var t in e)re(o,t,{get:e[t],enumerable:!0})},ve=(o,e,t,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let a of xe(e))!We.call(o,a)&&a!==t&&re(o,a,{get:()=>e[a],enumerable:!(r=Ce(e,a))||r.enumerable});return o};var be=o=>ve(re({},"__esModule",{value:!0}),o);var Ge={};Te(Ge,{ExplorerUrls:()=>P,KnownTokens:()=>de,MultiversxExplorers:()=>he,MultiversxExplorersConfig:()=>ie,NativeTokenEgld:()=>ee,NativeTokenVibe:()=>we,VibechainExplorers:()=>ge,WarpMultiversxAbiBuilder:()=>k,WarpMultiversxBrandBuilder:()=>D,WarpMultiversxBuilder:()=>z,WarpMultiversxConstants:()=>De,WarpMultiversxContractLoader:()=>q,WarpMultiversxDataLoader:()=>H,WarpMultiversxExecutor:()=>w,WarpMultiversxExplorer:()=>Q,WarpMultiversxRegistry:()=>G,WarpMultiversxResults:()=>U,WarpMultiversxSerializer:()=>F,address_value:()=>_e,biguint_value:()=>Pe,boolean_value:()=>Ue,codemeta_value:()=>$e,composite_value:()=>Ve,createMultiversxAdapter:()=>j,esdt_value:()=>ae,findKnownTokenById:()=>ne,getAllMultiversxAdapters:()=>He,getAllMultiversxChainNames:()=>Qe,getMultiversxAdapter:()=>ce,getMultiversxRegistryAddress:()=>v,getVibechainAdapter:()=>ue,hex_value:()=>Me,list_value:()=>Be,nothing_value:()=>Le,option_value:()=>Ee,optional_value:()=>Ae,string_value:()=>Ne,token_value:()=>Oe,u16_value:()=>Fe,u32_value:()=>ke,u64_value:()=>Re,u8_value:()=>Se,variadic_value:()=>Ie});module.exports=be(Ge);var le=require("@vleap/warps");var $=require("@vleap/warps");var J=require("@multiversx/sdk-core"),V=require("@vleap/warps");var se=require("@vleap/warps");var d=require("@multiversx/sdk-core"),T=require("@vleap/warps");var M=require("@multiversx/sdk-core"),y=require("@vleap/warps");var n=require("@multiversx/sdk-core"),W=require("@vleap/warps"),me=new RegExp(`${W.WarpConstants.ArgParamsSeparator}(.*)`),F=class{constructor(){this.coreSerializer=new W.WarpSerializer}typedToString(e){let t=e.getType();if(t.hasExactClass(n.OptionType.ClassName)||e.hasClassOrSuperclass(n.OptionValue.ClassName))return e.isSet()?`option:${this.typedToString(e.getTypedValue())}`:"option:null";if(t.hasExactClass(n.OptionalType.ClassName)||e.hasClassOrSuperclass(n.OptionalValue.ClassName))return e.isSet()?`optional:${this.typedToString(e.getTypedValue())}`:"optional:null";if(t.hasExactClass(n.ListType.ClassName)||e.hasClassOrSuperclass(n.List.ClassName)){let r=e.getItems(),s=r.map(i=>this.typedToString(i).split(W.WarpConstants.ArgParamsSeparator)[0])[0],c=r.map(i=>this.typedToString(i).split(W.WarpConstants.ArgParamsSeparator)[1]);return`list:${s}:${c.join(",")}`}if(t.hasExactClass(n.VariadicType.ClassName)||e.hasClassOrSuperclass(n.VariadicValue.ClassName)){let r=e.getItems(),s=r.map(i=>this.typedToString(i).split(W.WarpConstants.ArgParamsSeparator)[0])[0],c=r.map(i=>this.typedToString(i).split(W.WarpConstants.ArgParamsSeparator)[1]);return`variadic:${s}:${c.join(",")}`}if(t.hasExactClass(n.CompositeType.ClassName)||e.hasClassOrSuperclass(n.CompositeValue.ClassName)){let r=e.getItems(),a=r.map(l=>this.typedToString(l).split(W.WarpConstants.ArgParamsSeparator)[0]),s=r.map(l=>this.typedToString(l).split(W.WarpConstants.ArgParamsSeparator)[1]),c=a.join(W.WarpConstants.ArgCompositeSeparator),i=s.join(W.WarpConstants.ArgCompositeSeparator);return`composite(${c}):${i}`}if(t.hasExactClass(n.BigUIntType.ClassName)||e.hasClassOrSuperclass(n.BigUIntValue.ClassName)||t.getName()==="BigUint")return`biguint:${BigInt(e.valueOf().toFixed())}`;if(t.hasExactClass(n.U8Type.ClassName)||e.hasClassOrSuperclass(n.U8Value.ClassName))return`uint8:${e.valueOf().toNumber()}`;if(t.hasExactClass(n.U16Type.ClassName)||e.hasClassOrSuperclass(n.U16Value.ClassName))return`uint16:${e.valueOf().toNumber()}`;if(t.hasExactClass(n.U32Type.ClassName)||e.hasClassOrSuperclass(n.U32Value.ClassName))return`uint32:${e.valueOf().toNumber()}`;if(t.hasExactClass(n.U64Type.ClassName)||e.hasClassOrSuperclass(n.U64Value.ClassName))return`uint64:${BigInt(e.valueOf().toFixed())}`;if(t.hasExactClass(n.StringType.ClassName)||e.hasClassOrSuperclass(n.StringValue.ClassName))return`string:${e.valueOf()}`;if(t.hasExactClass(n.BooleanType.ClassName)||e.hasClassOrSuperclass(n.BooleanValue.ClassName))return`bool:${e.valueOf()}`;if(t.hasExactClass(n.AddressType.ClassName)||e.hasClassOrSuperclass(n.AddressValue.ClassName))return`address:${e.valueOf().toBech32()}`;if(t.hasExactClass(n.TokenIdentifierType.ClassName)||e.hasClassOrSuperclass(n.TokenIdentifierValue.ClassName))return`token:${e.valueOf()}`;if(t.hasExactClass(n.BytesType.ClassName)||e.hasClassOrSuperclass(n.BytesValue.ClassName))return`hex:${e.valueOf().toString("hex")}`;if(t.hasExactClass(n.CodeMetadataType.ClassName)||e.hasClassOrSuperclass(n.CodeMetadataValue.ClassName))return`codemeta:${e.valueOf().toString()}`;if(t.getName()==="EsdtTokenPayment"){let r=e.getFieldValue("token_identifier").valueOf(),a=e.getFieldValue("token_nonce").valueOf(),s=e.getFieldValue("amount").valueOf();return`asset:${r}|${a}|${s}`}throw new Error(`WarpArgSerializer (typedToString): Unsupported input type: ${e.getClassName()}`)}typedToNative(e){let t=this.typedToString(e);return this.coreSerializer.stringToNative(t)}nativeToTyped(e,t){let r=this.coreSerializer.nativeToString(e,t);return this.stringToTyped(r)}nativeToType(e){if(e.startsWith("composite")){let t=e.match(/\(([^)]+)\)/)?.[1];return new n.CompositeType(...t.split(W.WarpConstants.ArgCompositeSeparator).map(r=>this.nativeToType(r)))}if(e==="string")return new n.StringType;if(e==="uint8")return new n.U8Type;if(e==="uint16")return new n.U16Type;if(e==="uint32")return new n.U32Type;if(e==="uint64")return new n.U64Type;if(e==="biguint")return new n.BigUIntType;if(e==="bool")return new n.BooleanType;if(e==="address")return new n.AddressType;if(e==="token")return new n.TokenIdentifierType;if(e==="hex")return new n.BytesType;if(e==="codemeta")return new n.CodeMetadataType;if(e==="asset")return new n.StructType("EsdtTokenPayment",[new n.FieldDefinition("token_identifier","",new n.TokenIdentifierType),new n.FieldDefinition("token_nonce","",new n.U64Type),new n.FieldDefinition("amount","",new n.BigUIntType)]);throw new Error(`WarpArgSerializer (nativeToType): Unsupported input type: ${e}`)}stringToTyped(e){let[t,r]=e.split(/:(.*)/,2);if(t==="null"||t===null)return new n.NothingValue;if(t==="option"){let a=this.stringToTyped(r);return a instanceof n.NothingValue?n.OptionValue.newMissingTyped(a.getType()):n.OptionValue.newProvided(a)}if(t==="optional"){let a=this.stringToTyped(r);return a instanceof n.NothingValue?n.OptionalValue.newMissing():new n.OptionalValue(a.getType(),a)}if(t==="list"){let[a,s]=r.split(me,2),i=s.split(",").map(l=>this.stringToTyped(`${a}:${l}`));return new n.List(this.nativeToType(a),i)}if(t==="variadic"){let[a,s]=r.split(me,2),i=s.split(",").map(l=>this.stringToTyped(`${a}:${l}`));return new n.VariadicValue(new n.VariadicType(this.nativeToType(a)),i)}if(t.startsWith("composite")){let a=t.match(/\(([^)]+)\)/)?.[1],s=r.split(W.WarpConstants.ArgCompositeSeparator),c=a.split(W.WarpConstants.ArgCompositeSeparator),i=s.map((m,f)=>this.stringToTyped(`${c[f]}:${m}`)),l=i.map(m=>m.getType());return new n.CompositeValue(new n.CompositeType(...l),i)}if(t==="string")return r?n.StringValue.fromUTF8(r):new n.NothingValue;if(t==="uint8")return r?new n.U8Value(Number(r)):new n.NothingValue;if(t==="uint16")return r?new n.U16Value(Number(r)):new n.NothingValue;if(t==="uint32")return r?new n.U32Value(Number(r)):new n.NothingValue;if(t==="uint64")return r?new n.U64Value(BigInt(r)):new n.NothingValue;if(t==="biguint")return r?new n.BigUIntValue(BigInt(r)):new n.NothingValue;if(t==="bool")return r?new n.BooleanValue(typeof r=="boolean"?r:r==="true"):new n.NothingValue;if(t==="address")return r?new n.AddressValue(n.Address.newFromBech32(r)):new n.NothingValue;if(t==="token")return r?new n.TokenIdentifierValue(r):new n.NothingValue;if(t==="hex")return r?n.BytesValue.fromHex(r):new n.NothingValue;if(t==="codemeta")return new n.CodeMetadataValue(n.CodeMetadata.newFromBytes(Uint8Array.from(Buffer.from(r,"hex"))));if(t==="asset"){let a=r.split(W.WarpConstants.ArgCompositeSeparator);return new n.Struct(this.nativeToType("asset"),[new n.Field(new n.TokenIdentifierValue(a[0]),"token_identifier"),new n.Field(new n.U64Value(BigInt(a[1])),"token_nonce"),new n.Field(new n.BigUIntValue(BigInt(a[2])),"amount")])}throw new Error(`WarpArgSerializer (stringToTyped): Unsupported input type: ${t}`)}typeToString(e){if(e.hasExactClass(n.OptionType.ClassName))return"option:"+this.typeToString(e.getFirstTypeParameter());if(e.hasExactClass(n.OptionalType.ClassName))return"optional:"+this.typeToString(e.getFirstTypeParameter());if(e.hasExactClass(n.ListType.ClassName))return"list:"+this.typeToString(e.getFirstTypeParameter());if(e.hasExactClass(n.VariadicType.ClassName))return"variadic:"+this.typeToString(e.getFirstTypeParameter());if(e.hasExactClass(n.StringType.ClassName))return"string";if(e.hasExactClass(n.U8Type.ClassName))return"uint8";if(e.hasExactClass(n.U16Type.ClassName))return"uint16";if(e.hasExactClass(n.U32Type.ClassName))return"uint32";if(e.hasExactClass(n.U64Type.ClassName))return"uint64";if(e.hasExactClass(n.BigUIntType.ClassName))return"biguint";if(e.hasExactClass(n.BooleanType.ClassName))return"bool";if(e.hasExactClass(n.AddressType.ClassName))return"address";if(e.hasExactClass(n.TokenIdentifierType.ClassName))return"token";if(e.hasExactClass(n.BytesType.ClassName))return"hex";if(e.hasExactClass(n.CodeMetadataType.ClassName))return"codemeta";if(e.hasExactClass(n.StructType.ClassName)&&e.getClassName()==="EsdtTokenPayment")return"asset";throw new Error(`WarpArgSerializer (typeToString): Unsupported input type: ${e.getClassName()}`)}};var U=class{constructor(e,t){this.config=e;this.chain=t;this.abi=new k(e,t),this.serializer=new F,this.cache=new y.WarpCache(e.cache?.type)}async getTransactionExecutionResults(e,t){let{actionIndex:r}=(0,y.findWarpExecutableAction)(e),a=this.cache.get(y.WarpCacheKey.WarpExecutable(this.config.env,e.meta?.hash||"",r))??[],s=await this.extractContractResults(e,t,a),c=(0,y.getNextInfo)(this.config,[],e,r,s),i=(0,y.applyResultsToMessages)(e,s.results);return{success:t.status.isSuccessful(),warp:e,action:r,user:this.config.user?.wallets?.[this.chain.name]||null,txHash:t.hash,tx:t,next:c,values:s.values,valuesRaw:[],results:s.results,messages:i}}async extractContractResults(e,t,r){let{action:a,actionIndex:s}=(0,y.findWarpExecutableAction)(e),c=[],i={};if(!e.results||a.type!=="contract")return{values:c,results:i};if(!Object.values(e.results).some(C=>C.includes("out")||C.includes("event"))){for(let[C,g]of Object.entries(e.results))i[C]=g;return{values:c,results:await(0,y.evaluateResultsCommon)(e,i,s,r,this.config.transform?.runner)}}let m=await this.abi.getAbiForAction(a),f=new M.TransactionEventsParser({abi:m}),A=new M.SmartContractTransactionsOutcomeParser({abi:m}).parseExecute({transactionOnNetwork:t,function:a.func||void 0});for(let[C,g]of Object.entries(e.results)){if(g.startsWith(y.WarpConstants.Transform.Prefix))continue;if(g.startsWith("input.")){i[C]=g;continue}let B=(0,y.parseResultsOutIndex)(g);if(B!==null&&B!==s){i[C]=null;continue}let[b,E,R]=g.split(".");if(b==="event"){if(!E||isNaN(Number(R)))continue;let I=Number(R),x=(0,M.findEventsByFirstTopic)(t,E),L=f.parseEvents({events:x})[0],K=Object.values(L)[I]||null;c.push(K),i[C]=K&&K.valueOf()}else if(b==="out"||b.startsWith("out[")){if(!E)continue;let I=Number(E),x=A.values[I-1]||null;R&&(x=x[R]||null),x&&typeof x=="object"&&(x="toFixed"in x?x.toFixed():x.valueOf()),c.push(x),i[C]=x&&x.valueOf()}else i[C]=g}return{values:c,results:await(0,y.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 l=m=>{let f=m.split(".").slice(1).map(A=>parseInt(A)-1);if(f.length===0)return;let h=c[f[0]];for(let A=1;A<f.length;A++){if(h==null)return;h=h[f[A]]}return h};for(let[m,f]of Object.entries(e.results)){if(f.startsWith(y.WarpConstants.Transform.Prefix))continue;let h=(0,y.parseResultsOutIndex)(f);if(h!==null&&h!==r){i[m]=null;continue}f.startsWith("out.")||f==="out"||f.startsWith("out[")?i[m]=l(f)||null:i[m]=f}return{values:s,valuesRaw:c,results:await(0,y.evaluateResultsCommon)(e,i,r,a)}}async resolveWarpResultsRecursively(e){let t=e.warp,r=e.entryActionIndex,a=e.executor,s=e.inputs,c=e.meta,i=new Map,l=new Set,m=this;async function f(g,B=[]){if(i.has(g))return i.get(g);if(l.has(g))throw new Error(`Circular dependency detected at action ${g}`);l.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 R of Object.values(t.results)){let x=String(R).match(/^out\[(\d+)\]/);if(x){let L=parseInt(x[1],10);L!==g&&!i.has(L)&&await f(L)}}return l.delete(g),E}await f(r,s);let h={};for(let g of i.values())for(let[B,b]of Object.entries(g.results))b!==null?h[B]=b:B in h||(h[B]=null);let A=await(0,y.evaluateResultsCommon)(t,h,r,s,this.config.transform?.runner);return{...i.get(r),action:r,results:A}}};var de=[{id:"EGLD",name:"eGold",decimals:18},{id:"EGLD-000000",name:"eGold",decimals:18},{id:"VIBE-000000",name:"VIBE",decimals:18}],ne=o=>de.find(e=>e.id===o)||null;var p=require("@multiversx/sdk-core"),Ee=(o,e)=>o?p.OptionValue.newProvided(o):e?p.OptionValue.newMissingTyped(e):p.OptionValue.newMissing(),Ae=(o,e)=>o?new p.OptionalValue(o.getType(),o):e?new p.OptionalValue(e):p.OptionalValue.newMissing(),Be=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)},Ie=o=>p.VariadicValue.fromItems(...o),Ve=o=>{let e=o.map(t=>t.getType());return new p.CompositeValue(new p.CompositeType(...e),o)},Ne=o=>p.StringValue.fromUTF8(o),Se=o=>new p.U8Value(o),Fe=o=>new p.U16Value(o),ke=o=>new p.U32Value(o),Re=o=>new p.U64Value(o),Pe=o=>new p.BigUIntValue(BigInt(o)),Ue=o=>new p.BooleanValue(o),_e=o=>new p.AddressValue(p.Address.newFromBech32(o)),Oe=o=>new p.TokenIdentifierValue(o),Me=o=>p.BytesValue.fromHex(o),ae=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")]),$e=o=>new p.CodeMetadataValue(p.CodeMetadata.newFromBytes(Uint8Array.from(Buffer.from(o,"hex")))),Le=()=>new p.NothingValue;var qe="EGLD-000000",w=class o{constructor(e,t){this.config=e;this.chain=t;this.serializer=new F,this.abi=new k(this.config,this.chain),this.results=new U(this.config,this.chain)}async createTransaction(e){let t=(0,T.getWarpActionByIndex)(e.warp,e.action),r=null;if(t.type==="transfer")r=await this.createTransferTransaction(e);else if(t.type==="contract")r=await this.createContractCallTransaction(e);else{if(t.type==="query")throw new Error("WarpMultiversxExecutor: Invalid action type for createTransactionForExecute; Use executeQuery instead");if(t.type==="collect")throw new Error("WarpMultiversxExecutor: Invalid action type for createTransactionForExecute; Use executeCollect instead")}if(!r)throw new Error(`WarpMultiversxExecutor: Invalid action type (${t.type})`);return r}async createTransferTransaction(e){let t=this.config.user?.wallets?.[e.chain.name];if(!t)throw new Error("WarpMultiversxExecutor: createTransfer - user address not set");let r=d.Address.newFromBech32(t),a=new d.TransactionsFactoryConfig({chainID:e.chain.chainId}),s=e.data?Buffer.from(this.serializer.stringToTyped(e.data).valueOf()):null;return new d.TransferTransactionsFactory({config:a}).createTransactionForTransfer(r,{receiver:d.Address.newFromBech32(e.destination),nativeAmount:e.value,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,T.getWarpActionByIndex)(e.warp,e.action),a=d.Address.newFromBech32(t),s=e.args.map(i=>this.serializer.stringToTyped(i)),c=new d.TransactionsFactoryConfig({chainID:e.chain.chainId});return new d.SmartContractTransactionsFactory({config:c}).createTransactionForExecute(a,{contract:d.Address.newFromBech32(e.destination),function:"func"in r&&r.func||"",gasLimit:"gasLimit"in r?BigInt(r.gasLimit||0):0n,arguments:s,tokenTransfers:this.toTokenTransfers(e.transfers),nativeTransferAmount:e.value})}async executeQuery(e){let t=(0,T.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=d.Address.newFromBech32(e.destination),i=s.createSmartContractController(r),l=i.createQuery({contract:c,function:t.func||"",arguments:a}),m=await i.runQuery(l),f=m.returnCode==="ok",h=new d.ArgSerializer,A=r.getEndpoint(m.function||t.func||""),C=(m.returnDataParts||[]).map(I=>Buffer.from(I)),g=h.buffersToValues(C,A.output),{values:B,valuesRaw:b,results:E}=await this.results.extractQueryResults(e.warp,g,e.action,e.resolvedInputs),R=(0,T.getNextInfo)(this.config,[],e.warp,e.action,E);return{success:f,warp:e.warp,action:e.action,user:this.config.user?.wallets?.[e.chain.name]||null,txHash:null,tx:null,next:R,values:B,valuesRaw:b,results:E,messages:(0,T.applyResultsToMessages)(e.warp,E)}}async preprocessInput(e,t,r,a){if(r==="asset"){let[s,c,i]=a.split(T.WarpConstants.ArgCompositeSeparator);if(i)return t;let l=new d.TokenComputer,m=l.extractNonceFromExtendedIdentifier(s),f=new d.Token({identifier:s,nonce:BigInt(m||0)});if(!l.isFungible(f))return t;let C=ne(s)?.decimals;if(C||(C=(await(await fetch(`${e.defaultApiUrl}/tokens/${s}`)).json()).decimals),!C)throw new Error(`WarpActionExecutor: Decimals not found for token ${s}`);let g=ae(new d.TokenTransfer({token:f,amount:(0,T.shiftBigintBy)(c,C)}));return this.serializer.typedToString(g)+T.WarpConstants.ArgCompositeSeparator+C}return t}static getChainEntrypoint(e,t,r){let a="warp-sdk",c=r?(0,T.getProviderUrl)(r,e.name,t,e.defaultApiUrl):e.defaultApiUrl;return t==="devnet"?new d.DevnetEntrypoint({url:c,kind:"api",clientName:a}):t==="testnet"?new d.TestnetEntrypoint({url:c,kind:"api",clientName:a}):new d.MainnetEntrypoint({url:c,kind:"api",clientName:a})}async signMessage(e,t){let r=d.UserSecretKey.fromString(t);return(await new d.UserSigner(r).sign(new Uint8Array(Buffer.from(e,"utf-8")))).toString()}toTokenTransfers(e){return e.map(t=>t.identifier===this.chain.nativeToken.identifier?{...t,identifier:qe}:t).map(t=>{let a=new d.TokenComputer().extractNonceFromExtendedIdentifier(t.identifier);return new d.TokenTransfer({token:new d.Token({identifier:t.identifier,nonce:BigInt(a||0)}),amount:t.amount})})}};var q=class{constructor(e){this.config=e}async getContract(e,t){try{let s=await w.getChainEntrypoint(t,this.config.env).createNetworkProvider().doGetGeneric(`accounts/${e}`);return{address:e,owner:s.ownerAddress,verified:s.isVerified||!1}}catch(r){return se.WarpLogger.error("WarpContractLoader: getContract error",r),null}}async getVerificationInfo(e,t){try{let s=await w.getChainEntrypoint(t,this.config.env).createNetworkProvider().doGetGeneric(`accounts/${e}/verification`);return{codeHash:s.codeHash,abi:s.source.abi}}catch(r){return se.WarpLogger.error("WarpContractLoader: getVerificationInfo error",r),null}}};var k=class{constructor(e,t){this.config=e;this.chain=t;this.contractLoader=new q(this.config),this.cache=new V.WarpCache(this.config.cache?.type)}async createFromRaw(e){return JSON.parse(e)}async createFromTransaction(e){let t=await this.createFromRaw(e.data.toString());return t.meta={chain:this.chain.name,hash:e.hash,creator:e.sender.toBech32(),createdAt:new Date(e.timestamp*1e3).toISOString()},t}async createFromTransactionHash(e,t){let r=V.WarpCacheKey.WarpAbi(this.config.env,e);if(t){let c=this.cache.get(r);if(c)return V.WarpLogger.info(`WarpAbiBuilder (createFromTransactionHash): Warp abi found in cache: ${e}`),c}let s=w.getChainEntrypoint(this.chain,this.config.env).createNetworkProvider();try{let c=await s.getTransaction(e),i=await this.createFromTransaction(c);return t&&t.ttl&&i&&this.cache.set(r,i,t.ttl),i}catch(c){return V.WarpLogger.error("WarpAbiBuilder: Error creating from transaction hash",c),null}}async getAbiForAction(e){if(e.abi)return await this.fetchAbi(e);if(!e.address)throw new Error("WarpActionExecutor: Address not found");let t=await this.contractLoader.getVerificationInfo(e.address,this.chain);if(!t)throw new Error("WarpActionExecutor: Verification info not found");return J.AbiRegistry.create(t.abi)}async fetchAbi(e){if(!e.abi)throw new Error("WarpActionExecutor: ABI not found");if(e.abi.startsWith(V.WarpConstants.IdentifierType.Hash)){let t=e.abi.split(V.WarpConstants.IdentifierParamSeparatorDefault)[1],r=await this.createFromTransactionHash(t);if(!r)throw new Error(`WarpActionExecutor: ABI not found for hash: ${e.abi}`);return J.AbiRegistry.create(r.content)}else{let r=await(await fetch(e.abi)).json();return J.AbiRegistry.create(r)}}};var _=require("@multiversx/sdk-core"),X=require("@vleap/warps"),fe=require("buffer");var D=class{constructor(e,t){this.config=e;this.chain=t;this.core=new X.WarpBrandBuilder(e)}async createInscriptionTransaction(e){let t=this.config.user?.wallets?.[this.chain.name];if(!t)throw new Error("BrandBuilder: user address not set");let r=new _.TransactionsFactoryConfig({chainID:this.chain.chainId}),a=new _.TransferTransactionsFactory({config:r}),s=_.Address.newFromBech32(t),c=JSON.stringify(e);return await a.createTransactionForNativeTokenTransfer(s,{receiver:_.Address.newFromBech32(t),nativeAmount:BigInt(0),data:Uint8Array.from(fe.Buffer.from(c))})}async createFromTransaction(e,t=!1){return await this.core.createFromRaw(e.data.toString(),t)}async createFromTransactionHash(e){let r=w.getChainEntrypoint(this.chain,this.config.env).createNetworkProvider();try{let a=await r.getTransaction(e);return this.createFromTransaction(a)}catch(a){return X.WarpLogger.error("BrandBuilder: Error creating from transaction hash",a),null}}};var O=require("@multiversx/sdk-core"),N=require("@vleap/warps");var z=class extends N.WarpBuilder{constructor(t,r){super(t);this.config=t;this.chain=r;this.cache=new N.WarpCache(t.cache?.type),this.core=new N.WarpBuilder(t)}async createInscriptionTransaction(t){let r=this.config.user?.wallets?.[this.chain.name];if(!r)throw new Error("WarpBuilder: user address not set");let a=new O.TransactionsFactoryConfig({chainID:this.chain.chainId}),s=new O.TransferTransactionsFactory({config:a}),c=O.Address.newFromBech32(r),i=JSON.stringify(t),l=await s.createTransactionForTransfer(c,{receiver:O.Address.newFromBech32(r),nativeAmount:BigInt(0),data:Uint8Array.from(Buffer.from(i))});return l.gasLimit=l.gasLimit+BigInt(2e6),l}async createFromTransaction(t,r=!1){let a=await this.core.createFromRaw(t.data.toString(),r);return a.meta={chain:this.chain.name,hash:t.hash,creator:t.sender.toBech32(),createdAt:new Date(t.timestamp*1e3).toISOString()},a}async createFromTransactionHash(t,r){let a=N.WarpCacheKey.Warp(this.config.env,t);if(r){let i=this.cache.get(a);if(i)return N.WarpLogger.info(`WarpBuilder (createFromTransactionHash): Warp found in cache: ${t}`),i}let c=w.getChainEntrypoint(this.chain,this.config.env).createNetworkProvider();try{let i=await c.getTransaction(t),l=await this.createFromTransaction(i);return r&&r.ttl&&l&&this.cache.set(a,l,r.ttl),l}catch(i){return N.WarpLogger.error("WarpBuilder: Error creating from transaction hash",i),null}}};var Y=require("@multiversx/sdk-core");var H=class{constructor(e,t){this.config=e;this.chain=t}async getAccount(e){let r=await w.getChainEntrypoint(this.chain,this.config.env,this.config).createNetworkProvider().getAccount(Y.Address.newFromBech32(e));return{chain:this.chain.name,address:r.address.toBech32(),balance:r.balance}}async getAccountAssets(e){let t=w.getChainEntrypoint(this.chain,this.config.env,this.config).createNetworkProvider(),r=t.getAccount(Y.Address.newFromBech32(e)),a=t.getFungibleTokensOfAccount(Y.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(l=>({chain:this.chain.name,identifier:l.token.identifier,name:l.raw.name,amount:l.amount,decimals:l.raw.decimals,logoUrl:l.raw.assets?.pngUrl||""}))),i}async getAccountActions(e,t){let r=w.getChainEntrypoint(this.chain,this.config.env,this.config).createNetworkProvider(),a=`accounts/${e}/transactions`,s=new URLSearchParams,c=t?.size||25,i=t?.page||0;if(i>0){let 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:m.status,createdAt:new Date(m.timestampMs||m.timestamp*1e3).toISOString()}))}};var De={Egld:{Identifier:"EGLD",EsdtIdentifier:"EGLD-000000",DisplayName:"eGold",Decimals:18}},he=(r=>(r.MultiversxExplorer="multiversx_explorer",r.MultiversxExplorerDevnet="multiversx_explorer_devnet",r.MultiversxExplorerTestnet="multiversx_explorer_testnet",r))(he||{}),ge=(r=>(r.VibechainExplorer="vibechain_explorer",r.VibechainExplorerDevnet="vibechain_explorer_devnet",r.VibechainExplorerTestnet="vibechain_explorer_testnet",r))(ge||{}),ie={multiversx:{mainnet:["multiversx_explorer"],testnet:["multiversx_explorer_testnet"],devnet:["multiversx_explorer_devnet"]},vibechain:{mainnet:["vibechain_explorer"],testnet:["vibechain_explorer_testnet"],devnet:["vibechain_explorer_devnet"]}},P={multiversx_explorer:"https://explorer.multiversx.com",multiversx_explorer_devnet:"https://devnet-explorer.multiversx.com",multiversx_explorer_testnet:"https://testnet-explorer.multiversx.com",vibechain_explorer:"https://vibeox-explorer.multiversx.com",vibechain_explorer_devnet:"https://vibeox-explorer.multiversx.com",vibechain_explorer_testnet:"https://vibeox-explorer.multiversx.com"};var Q=class{constructor(e,t){this.chain=e;this.config=t}getExplorers(){let e=ie[this.chain];if(!e)return["multiversx_explorer"];let t=e[this.config.env];return t||["multiversx_explorer"]}getPrimaryExplorer(){return this.getExplorers()[0]}getExplorerUrlByName(e){let t=this.config.preferences?.explorers?.[this.chain];if(t&&!e){let s=P[t];if(s)return s}if(e){let s=P[e];if(s)return s}let r=this.getPrimaryExplorer();return P[r]||P[r]}getAccountUrl(e,t){return`${this.getExplorerUrlByName(t)}/accounts/${e}`}getTransactionUrl(e,t){return`${this.getExplorerUrlByName(t)}/transactions/${e}`}getBlockUrl(e,t){return`${this.getExplorerUrlByName(t)}/blocks/${e}`}getAssetUrl(e,t){return`${this.getExplorerUrlByName(t)}/tokens/${e}`}getContractUrl(e,t){return`${this.getExplorerUrlByName(t)}/accounts/${e}`}getAllExplorers(){return this.getExplorers()}getExplorerByName(e){return this.getExplorers().find(r=>r.toLowerCase()===e.toLowerCase())}getAccountUrls(e){let t=this.getAllExplorers(),r={};return t.forEach(a=>{let s=P[a];s&&(r[a]=`${s}/accounts/${e}`)}),r}getTransactionUrls(e){let t=this.getAllExplorers(),r={};return t.forEach(a=>{let s=P[a];s&&(r[a]=`${s}/transactions/${e}`)}),r}};var u=require("@multiversx/sdk-core"),S=require("@vleap/warps");var oe={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 v=o=>{if(o==="devnet")return"erd1qqqqqqqqqqqqqpgqje2f99vr6r7sk54thg03c9suzcvwr4nfl3tsfkdl36";if(o==="testnet")throw new Error("Multiversx testnet is not supported");return"erd1qqqqqqqqqqqqqpgq3mrpj3u6q7tejv6d7eqhnyd27n9v5c5tl3ts08mffe"};var Z=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}),ye=o=>({unitPrice:BigInt(o.unit_price.toString()),admins:o.admins.map(e=>e.toBech32())});var G=class{constructor(e,t){this.config=e;this.chain=t;this.cache=new S.WarpCache(e.cache?.type),this.registryConfig={unitPrice:BigInt(0),admins:[]},this.userWallet=this.config.user?.wallets?.[this.chain.name]||null}async init(){await this.loadRegistryConfigs()}getRegistryConfig(){return this.registryConfig}async createWarpRegisterTransaction(e,t,r){if(this.registryConfig.unitPrice===BigInt(0))throw new Error("WarpRegistry: config not loaded. forgot to call init()?");if(!this.userWallet)throw new Error("WarpRegistry: user address not set");let a=u.Address.newFromBech32(this.userWallet),s=()=>this.isCurrentUserAdmin()?BigInt(0):t&&r?this.registryConfig.unitPrice*BigInt(3):t?this.registryConfig.unitPrice*BigInt(2):this.registryConfig.unitPrice,c=()=>t&&r?[u.BytesValue.fromHex(e),u.BytesValue.fromUTF8(t),u.BytesValue.fromHex(r)]:t?[u.BytesValue.fromHex(e),u.BytesValue.fromUTF8(t)]:[u.BytesValue.fromHex(e)];return await this.getFactory().createTransactionForExecute(a,{contract:u.Address.newFromBech32(v(this.config.env)),function:"registerWarp",gasLimit:BigInt(1e7),nativeTransferAmount:s(),arguments:c()})}async createWarpUnregisterTransaction(e){if(!this.userWallet)throw new Error("WarpRegistry: user address not set");let t=u.Address.newFromBech32(this.userWallet);return await this.getFactory().createTransactionForExecute(t,{contract:u.Address.newFromBech32(v(this.config.env)),function:"unregisterWarp",gasLimit:BigInt(1e7),arguments:[u.BytesValue.fromHex(e)]})}async createWarpUpgradeTransaction(e,t){if(this.registryConfig.unitPrice===BigInt(0))throw new Error("WarpRegistry: config not loaded. forgot to call init()?");if(!this.userWallet)throw new Error("WarpRegistry: user address not set");let r=u.Address.newFromBech32(this.userWallet);return await this.getFactory().createTransactionForExecute(r,{contract:u.Address.newFromBech32(v(this.config.env)),function:"upgradeWarp",gasLimit:BigInt(1e7),nativeTransferAmount:this.isCurrentUserAdmin()?void 0:this.registryConfig.unitPrice,arguments:[u.BytesValue.fromUTF8(e),u.BytesValue.fromHex(t)]})}async createWarpAliasSetTransaction(e,t){if(!this.userWallet)throw new Error("WarpRegistry: user address not set");let r=u.Address.newFromBech32(this.userWallet);return await this.getFactory().createTransactionForExecute(r,{contract:u.Address.newFromBech32(v(this.config.env)),function:"setWarpAlias",gasLimit:BigInt(1e7),nativeTransferAmount:this.isCurrentUserAdmin()?void 0:this.registryConfig.unitPrice,arguments:[u.BytesValue.fromHex(e),u.BytesValue.fromUTF8(t)]})}async createWarpVerifyTransaction(e){if(!this.userWallet)throw new Error("WarpRegistry: user address not set");let t=u.Address.newFromBech32(this.userWallet);return await this.getFactory().createTransactionForExecute(t,{contract:u.Address.newFromBech32(v(this.config.env)),function:"verifyWarp",gasLimit:BigInt(1e7),arguments:[u.BytesValue.fromHex(e)]})}async createWarpTransferOwnershipTransaction(e,t){if(!this.userWallet)throw new Error("WarpRegistry: user address not set");let r=u.Address.newFromBech32(this.userWallet);return await this.getFactory().createTransactionForExecute(r,{contract:u.Address.newFromBech32(v(this.config.env)),function:"transferOwnership",gasLimit:BigInt(1e7),arguments:[u.BytesValue.fromHex(e),new u.AddressValue(new u.Address(t))]})}async createBrandRegisterTransaction(e){if(this.registryConfig.unitPrice===BigInt(0))throw new Error("WarpRegistry: config not loaded. forgot to call init()?");if(!this.userWallet)throw new Error("WarpRegistry: user address not set");let t=u.Address.newFromBech32(this.userWallet);return await this.getFactory().createTransactionForExecute(t,{contract:u.Address.newFromBech32(v(this.config.env)),function:"registerBrand",gasLimit:BigInt(1e7),nativeTransferAmount:this.isCurrentUserAdmin()?void 0:this.registryConfig.unitPrice,arguments:[u.BytesValue.fromHex(e)]})}async createWarpBrandingTransaction(e,t){if(!this.userWallet)throw new Error("WarpRegistry: user address not set");let r=u.Address.newFromBech32(this.userWallet);return await this.getFactory().createTransactionForExecute(r,{contract:u.Address.newFromBech32(v(this.config.env)),function:"brandWarp",gasLimit:BigInt(1e7),nativeTransferAmount:this.isCurrentUserAdmin()?void 0:this.registryConfig.unitPrice,arguments:[u.BytesValue.fromHex(e),u.BytesValue.fromHex(t)]})}async getInfoByAlias(e,t){try{let r=S.WarpCacheKey.RegistryInfo(this.config.env,e),a=t?this.cache.get(r):null;if(a)return S.WarpLogger.info(`WarpRegistry (getInfoByAlias): RegistryInfo found in cache: ${e}`),a;let s=u.Address.newFromBech32(v(this.config.env)),c=this.getController(),i=c.createQuery({contract:s,function:"getInfoByAlias",arguments:[u.BytesValue.fromUTF8(e)]}),l=await c.runQuery(i),[m]=c.parseQueryResponse(l),f=m?Z(m):null,h=f?.brand?await this.fetchBrand(f.brand):null;return t&&t.ttl&&this.cache.set(r,{registryInfo:f,brand:h},t.ttl),{registryInfo:f,brand:h}}catch{return{registryInfo:null,brand:null}}}async getInfoByHash(e,t){try{let r=S.WarpCacheKey.RegistryInfo(this.config.env,e);if(t){let h=this.cache.get(r);if(h)return S.WarpLogger.info(`WarpRegistry (getInfoByHash): RegistryInfo found in cache: ${e}`),h}let a=u.Address.newFromBech32(v(this.config.env)),s=this.getController(),c=s.createQuery({contract:a,function:"getInfoByHash",arguments:[u.BytesValue.fromHex(e)]}),i=await s.runQuery(c),[l]=s.parseQueryResponse(i),m=l?Z(l):null,f=m?.brand?await this.fetchBrand(m.brand):null;return t&&t.ttl&&this.cache.set(r,{registryInfo:m,brand:f},t.ttl),{registryInfo:m,brand:f}}catch{return{registryInfo:null,brand:null}}}async getUserWarpRegistryInfos(e){try{let t=e||this.userWallet;if(!t)throw new Error("WarpRegistry: user address not set");let r=u.Address.newFromBech32(v(this.config.env)),a=this.getController(),s=a.createQuery({contract:r,function:"getUserWarps",arguments:[new u.AddressValue(new u.Address(t))]}),c=await a.runQuery(s),[i]=a.parseQueryResponse(c);return i.map(Z)}catch{return[]}}async getUserBrands(e){try{let t=e||this.userWallet;if(!t)throw new Error("WarpRegistry: user address not set");let r=u.Address.newFromBech32(v(this.config.env)),a=this.getController(),s=a.createQuery({contract:r,function:"getUserBrands",arguments:[new u.AddressValue(new u.Address(t))]}),c=await a.runQuery(s),[i]=a.parseQueryResponse(c),l=i.map(h=>h.toString("hex")),m={ttl:365*24*60*60};return(await Promise.all(l.map(h=>this.fetchBrand(h,m)))).filter(h=>h!==null)}catch{return[]}}async fetchBrand(e,t){let r=S.WarpCacheKey.Brand(this.config.env,e),a=t?this.cache.get(r):null;if(a)return S.WarpLogger.info(`WarpRegistry (fetchBrand): Brand found in cache: ${e}`),a;let c=w.getChainEntrypoint(this.chain,this.config.env).createNetworkProvider();try{let i=await c.getTransaction(e),l=JSON.parse(i.data.toString());return l.meta={hash:i.hash,creator:i.sender.toBech32(),createdAt:new Date(i.timestamp*1e3).toISOString()},t&&t.ttl&&this.cache.set(r,l,t.ttl),l}catch{return null}}async loadRegistryConfigs(){let e=u.Address.newFromBech32(v(this.config.env)),t=this.getController(),[r]=await t.query({contract:e,function:"getConfig",arguments:[]}),a=r?ye(r):null;this.registryConfig=a||{unitPrice:BigInt(0),admins:[]}}getFactory(){let e=new u.TransactionsFactoryConfig({chainID:this.chain.chainId}),t=u.AbiRegistry.create(oe);return new u.SmartContractTransactionsFactory({config:e,abi:t})}getController(){let e=w.getChainEntrypoint(this.chain,this.config.env),t=u.AbiRegistry.create(oe);return e.createSmartContractController(t)}isCurrentUserAdmin(){return!!this.userWallet&&this.registryConfig.admins.includes(this.userWallet)}};var j=(o,e,t)=>(r,a)=>{let s=t[r.env];return{chain:o,chainInfo:s,prefix:e,builder:()=>new z(r,s),executor:new w(r,s),results:new U(r,s),serializer:new F,registry:new G(r,s),explorer:new Q(o,r),abiBuilder:()=>new k(r,s),brandBuilder:()=>new D(r,s),dataLoader:new H(r,s),registerTypes:c=>{c.registerType("token",{stringToNative:i=>i,nativeToString:i=>`token:${i}`}),c.registerType("codemeta",{stringToNative:i=>i,nativeToString:i=>`codemeta:${i}`})}}};var ee={chain:$.WarpChainName.Multiversx,identifier:"EGLD",name:"eGold",decimals:18,logoUrl:"https://vleap.ai/images/tokens/egld.svg"},ce=j($.WarpChainName.Multiversx,"mvx",{mainnet:{name:$.WarpChainName.Multiversx,displayName:"MultiversX",chainId:"1",blockTime:6e3,addressHrp:"erd",defaultApiUrl:"https://api.multiversx.com",nativeToken:ee},testnet:{name:$.WarpChainName.Multiversx,displayName:"MultiversX Testnet",chainId:"T",blockTime:6e3,addressHrp:"erd",defaultApiUrl:"https://testnet-api.multiversx.com",nativeToken:ee},devnet:{name:$.WarpChainName.Multiversx,displayName:"MultiversX Devnet",chainId:"D",blockTime:6e3,addressHrp:"erd",defaultApiUrl:"https://devnet-api.multiversx.com",nativeToken:ee}});var te=require("@vleap/warps");var we={chain:te.WarpChainName.Vibechain,identifier:"VIBE",name:"VIBE",decimals:18,logoUrl:"https://vleap.ai/images/tokens/vibe.svg"},pe={name:te.WarpChainName.Vibechain,displayName:"VibeChain",chainId:"V",blockTime:600,addressHrp:"vibe",defaultApiUrl:"https://vibeox-api.multiversx.com",nativeToken:we},ue=j(te.WarpChainName.Vibechain,"vibe",{mainnet:pe,testnet:pe,devnet:pe});var He=(o,e)=>[ce(o,e),ue(o,e)],Qe=()=>[le.WarpChainName.Multiversx,le.WarpChainName.Vibechain];0&&(module.exports={ExplorerUrls,KnownTokens,MultiversxExplorers,MultiversxExplorersConfig,NativeTokenEgld,NativeTokenVibe,VibechainExplorers,WarpMultiversxAbiBuilder,WarpMultiversxBrandBuilder,WarpMultiversxBuilder,WarpMultiversxConstants,WarpMultiversxContractLoader,WarpMultiversxDataLoader,WarpMultiversxExecutor,WarpMultiversxExplorer,WarpMultiversxRegistry,WarpMultiversxResults,WarpMultiversxSerializer,address_value,biguint_value,boolean_value,codemeta_value,composite_value,createMultiversxAdapter,esdt_value,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 pt}from"@vleap/warps";import{WarpChainName as F}from"@vleap/warps";import{AbiRegistry as he}from"@multiversx/sdk-core";import{WarpCache as rr,WarpCacheKey as nr,WarpConstants as Xe,WarpLogger as Ye}from"@vleap/warps";import{WarpLogger as Je}from"@vleap/warps";import{Address as R,ArgSerializer as Lt,DevnetEntrypoint as qt,MainnetEntrypoint as Dt,SmartContractTransactionsFactory as zt,TestnetEntrypoint as Ht,Token as Qe,TokenComputer as Qt,TokenTransfer as Ge,TransactionsFactoryConfig as je,TransferTransactionsFactory as Gt,UserSecretKey as jt,UserSigner as Kt}from"@multiversx/sdk-core";import{applyResultsToMessages as Jt,findKnownTokenById as Xt,getNextInfo as Yt,getProviderUrl as Zt,getWarpActionByIndex as de,shiftBigintBy as er,WarpConstants as Ke}from"@vleap/warps";import{findEventsByFirstTopic as dt,SmartContractTransactionsOutcomeParser as ht,TransactionEventsParser as gt}from"@multiversx/sdk-core";import{applyResultsToMessages as yt,evaluateResultsCommon as O,findWarpExecutableAction as Me,getNextInfo as wt,parseResultsOutIndex as $e,WarpCache as Ct,WarpCacheKey as xt,WarpConstants as Le}from"@vleap/warps";import{Address as ut,AddressType as G,AddressValue as ve,BigUIntType as P,BigUIntValue as j,BooleanType as K,BooleanValue as be,BytesType as J,BytesValue as Ee,CodeMetadata as lt,CodeMetadataType as X,CodeMetadataValue as Ae,CompositeType as Y,CompositeValue as Be,Field as Z,FieldDefinition as ee,List as Ie,ListType as Ve,NothingValue as T,OptionalType as Ne,OptionalValue as te,OptionType as Se,OptionValue as re,StringType as ne,StringValue as Re,Struct as mt,StructType as Fe,TokenIdentifierType as U,TokenIdentifierValue as ae,U16Type as se,U16Value as ke,U32Type as ie,U32Value as Pe,U64Type as _,U64Value as oe,U8Type as ce,U8Value as Ue,VariadicType as pe,VariadicValue as _e}from"@multiversx/sdk-core";import{WarpConstants as v,WarpSerializer as ft}from"@vleap/warps";var Oe=new RegExp(`${v.ArgParamsSeparator}(.*)`),B=class{constructor(){this.coreSerializer=new ft}typedToString(e){let t=e.getType();if(t.hasExactClass(Se.ClassName)||e.hasClassOrSuperclass(re.ClassName))return e.isSet()?`option:${this.typedToString(e.getTypedValue())}`:"option:null";if(t.hasExactClass(Ne.ClassName)||e.hasClassOrSuperclass(te.ClassName))return e.isSet()?`optional:${this.typedToString(e.getTypedValue())}`:"optional:null";if(t.hasExactClass(Ve.ClassName)||e.hasClassOrSuperclass(Ie.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(pe.ClassName)||e.hasClassOrSuperclass(_e.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(Y.ClassName)||e.hasClassOrSuperclass(Be.ClassName)){let r=e.getItems(),n=r.map(p=>this.typedToString(p).split(v.ArgParamsSeparator)[0]),a=r.map(p=>this.typedToString(p).split(v.ArgParamsSeparator)[1]),o=n.join(v.ArgCompositeSeparator),s=a.join(v.ArgCompositeSeparator);return`composite(${o}):${s}`}if(t.hasExactClass(P.ClassName)||e.hasClassOrSuperclass(j.ClassName)||t.getName()==="BigUint")return`biguint:${BigInt(e.valueOf().toFixed())}`;if(t.hasExactClass(ce.ClassName)||e.hasClassOrSuperclass(Ue.ClassName))return`uint8:${e.valueOf().toNumber()}`;if(t.hasExactClass(se.ClassName)||e.hasClassOrSuperclass(ke.ClassName))return`uint16:${e.valueOf().toNumber()}`;if(t.hasExactClass(ie.ClassName)||e.hasClassOrSuperclass(Pe.ClassName))return`uint32:${e.valueOf().toNumber()}`;if(t.hasExactClass(_.ClassName)||e.hasClassOrSuperclass(oe.ClassName))return`uint64:${BigInt(e.valueOf().toFixed())}`;if(t.hasExactClass(ne.ClassName)||e.hasClassOrSuperclass(Re.ClassName))return`string:${e.valueOf()}`;if(t.hasExactClass(K.ClassName)||e.hasClassOrSuperclass(be.ClassName))return`bool:${e.valueOf()}`;if(t.hasExactClass(G.ClassName)||e.hasClassOrSuperclass(ve.ClassName))return`address:${e.valueOf().toBech32()}`;if(t.hasExactClass(U.ClassName)||e.hasClassOrSuperclass(ae.ClassName))return`token:${e.valueOf()}`;if(t.hasExactClass(J.ClassName)||e.hasClassOrSuperclass(Ee.ClassName))return`hex:${e.valueOf().toString("hex")}`;if(t.hasExactClass(X.ClassName)||e.hasClassOrSuperclass(Ae.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:${r}|${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 Y(...t.split(v.ArgCompositeSeparator).map(r=>this.nativeToType(r)))}if(e==="string")return new ne;if(e==="uint8")return new ce;if(e==="uint16")return new se;if(e==="uint32")return new ie;if(e==="uint64")return new _;if(e==="biguint")return new P;if(e==="bool")return new K;if(e==="address")return new G;if(e==="token")return new U;if(e==="hex")return new J;if(e==="codemeta")return new X;if(e==="asset")return new Fe("EsdtTokenPayment",[new ee("token_identifier","",new U),new ee("token_nonce","",new _),new ee("amount","",new P)]);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?re.newMissingTyped(n.getType()):re.newProvided(n)}if(t==="optional"){let n=this.stringToTyped(r);return n instanceof T?te.newMissing():new te(n.getType(),n)}if(t==="list"){let[n,a]=r.split(Oe,2),s=a.split(",").map(p=>this.stringToTyped(`${n}:${p}`));return new Ie(this.nativeToType(n),s)}if(t==="variadic"){let[n,a]=r.split(Oe,2),s=a.split(",").map(p=>this.stringToTyped(`${n}:${p}`));return new _e(new pe(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((c,u)=>this.stringToTyped(`${o[u]}:${c}`)),p=s.map(c=>c.getType());return new Be(new Y(...p),s)}if(t==="string")return r?Re.fromUTF8(r):new T;if(t==="uint8")return r?new Ue(Number(r)):new T;if(t==="uint16")return r?new ke(Number(r)):new T;if(t==="uint32")return r?new Pe(Number(r)):new T;if(t==="uint64")return r?new oe(BigInt(r)):new T;if(t==="biguint")return r?new j(BigInt(r)):new T;if(t==="bool")return r?new be(typeof r=="boolean"?r:r==="true"):new T;if(t==="address")return r?new ve(ut.newFromBech32(r)):new T;if(t==="token")return r?new ae(r):new T;if(t==="hex")return r?Ee.fromHex(r):new T;if(t==="codemeta")return new Ae(lt.newFromBytes(Uint8Array.from(Buffer.from(r,"hex"))));if(t==="asset"){let n=r.split(v.ArgCompositeSeparator);return new mt(this.nativeToType("asset"),[new Z(new ae(n[0]),"token_identifier"),new Z(new oe(BigInt(n[1])),"token_nonce"),new Z(new j(BigInt(n[2])),"amount")])}throw new Error(`WarpArgSerializer (stringToTyped): Unsupported input type: ${t}`)}typeToString(e){if(e.hasExactClass(Se.ClassName))return"option:"+this.typeToString(e.getFirstTypeParameter());if(e.hasExactClass(Ne.ClassName))return"optional:"+this.typeToString(e.getFirstTypeParameter());if(e.hasExactClass(Ve.ClassName))return"list:"+this.typeToString(e.getFirstTypeParameter());if(e.hasExactClass(pe.ClassName))return"variadic:"+this.typeToString(e.getFirstTypeParameter());if(e.hasExactClass(ne.ClassName))return"string";if(e.hasExactClass(ce.ClassName))return"uint8";if(e.hasExactClass(se.ClassName))return"uint16";if(e.hasExactClass(ie.ClassName))return"uint32";if(e.hasExactClass(_.ClassName))return"uint64";if(e.hasExactClass(P.ClassName))return"biguint";if(e.hasExactClass(K.ClassName))return"bool";if(e.hasExactClass(G.ClassName))return"address";if(e.hasExactClass(U.ClassName))return"token";if(e.hasExactClass(J.ClassName))return"hex";if(e.hasExactClass(X.ClassName))return"codemeta";if(e.hasExactClass(Fe.ClassName)&&e.getClassName()==="EsdtTokenPayment")return"asset";throw new Error(`WarpArgSerializer (typeToString): Unsupported input type: ${e.getClassName()}`)}};var N=class{constructor(e,t){this.config=e;this.chain=t;this.abi=new I(e,t),this.serializer=new B,this.cache=new Ct(e.cache?.type)}async getTransactionExecutionResults(e,t){let{actionIndex:r}=Me(e),n=this.cache.get(xt.WarpExecutable(this.config.env,e.meta?.hash||"",r))??[],a=await this.extractContractResults(e,t,n),o=wt(this.config,[],e,r,a),s=yt(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}=Me(e),o=[],s={};if(!e.results||n.type!=="contract")return{values:o,results:s};if(!Object.values(e.results).some(w=>w.includes("out")||w.includes("event"))){for(let[w,m]of Object.entries(e.results))s[w]=m;return{values:o,results:await O(e,s,a,r,this.config.transform?.runner)}}let c=await this.abi.getAbiForAction(n),u=new gt({abi:c}),g=new ht({abi:c}).parseExecute({transactionOnNetwork:t,function:n.func||void 0});for(let[w,m]of Object.entries(e.results)){if(m.startsWith(Le.Transform.Prefix))continue;if(m.startsWith("input.")){s[w]=m;continue}let b=$e(m);if(b!==null&&b!==a){s[w]=null;continue}let[x,W,A]=m.split(".");if(x==="event"){if(!W||isNaN(Number(A)))continue;let E=Number(A),y=dt(t,W),S=u.parseEvents({events:y})[0],k=Object.values(S)[E]||null;o.push(k),s[w]=k&&k.valueOf()}else if(x==="out"||x.startsWith("out[")){if(!W)continue;let E=Number(W),y=g.values[E-1]||null;A&&(y=y[A]||null),y&&typeof y=="object"&&(y="toFixed"in y?y.toFixed():y.valueOf()),o.push(y),s[w]=y&&y.valueOf()}else s[w]=m}return{values:o,results:await O(e,s,a,r)}}async extractQueryResults(e,t,r,n){let a=t.map(c=>this.serializer.typedToString(c)),o=t.map(c=>this.serializer.typedToNative(c)[1]),s={};if(!e.results)return{values:a,valuesRaw:o,results:s};let p=c=>{let u=c.split(".").slice(1).map(g=>parseInt(g)-1);if(u.length===0)return;let l=o[u[0]];for(let g=1;g<u.length;g++){if(l==null)return;l=l[u[g]]}return l};for(let[c,u]of Object.entries(e.results)){if(u.startsWith(Le.Transform.Prefix))continue;let l=$e(u);if(l!==null&&l!==r){s[c]=null;continue}u.startsWith("out.")||u==="out"||u.startsWith("out[")?s[c]=p(u)||null:s[c]=u}return{values:a,valuesRaw:o,results:await O(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,p=new Set,c=this;async function u(m,b=[]){if(s.has(m))return s.get(m);if(p.has(m))throw new Error(`Circular dependency detected at action ${m}`);p.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 y=String(A).match(/^out\[(\d+)\]/);if(y){let S=parseInt(y[1],10);S!==m&&!s.has(S)&&await u(S)}}return p.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 g=await O(t,l,r,a,this.config.transform?.runner);return{...s.get(r),action:r,results:g}}};import{Address as Wt,AddressValue as Tt,BigUIntType as vt,BigUIntValue as qe,BooleanValue as bt,BytesValue as Et,CodeMetadata as At,CodeMetadataValue as Bt,CompositeType as It,CompositeValue as Vt,Field as ue,FieldDefinition as le,List as Nt,NothingValue as St,OptionalValue as me,OptionValue as fe,StringValue as Rt,Struct as Ft,StructType as kt,TokenIdentifierType as Pt,TokenIdentifierValue as De,U16Value as Ut,U32Value as _t,U64Type as Ot,U64Value as ze,U8Value as Mt,VariadicValue as $t}from"@multiversx/sdk-core";var Jr=(i,e)=>i?fe.newProvided(i):e?fe.newMissingTyped(e):fe.newMissing(),Xr=(i,e)=>i?new me(i.getType(),i):e?new me(e):me.newMissing(),Yr=i=>{if(i.length===0)throw new Error("Cannot create a list from an empty array");let e=i[0].getType();return new Nt(e,i)},Zr=i=>$t.fromItems(...i),en=i=>{let e=i.map(t=>t.getType());return new Vt(new It(...e),i)},tn=i=>Rt.fromUTF8(i),rn=i=>new Mt(i),nn=i=>new Ut(i),an=i=>new _t(i),sn=i=>new ze(i),on=i=>new qe(BigInt(i)),cn=i=>new bt(i),pn=i=>new Tt(Wt.newFromBech32(i)),un=i=>new De(i),ln=i=>Et.fromHex(i),He=i=>new Ft(new kt("EsdtTokenPayment",[new le("token_identifier","",new Pt),new le("token_nonce","",new Ot),new le("amount","",new vt)]),[new ue(new De(i.token.identifier),"token_identifier"),new ue(new ze(BigInt(i.token.nonce)),"token_nonce"),new ue(new qe(BigInt(i.amount)),"amount")]),mn=i=>new Bt(At.newFromBytes(Uint8Array.from(Buffer.from(i,"hex")))),fn=()=>new St;var tr="EGLD-000000",d=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 N(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=R.newFromBech32(t),n=new je({chainID:e.chain.chainId}),a=e.data?Buffer.from(this.serializer.stringToTyped(e.data).valueOf()):null;return new Gt({config:n}).createTransactionForTransfer(r,{receiver:R.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=R.newFromBech32(t),a=e.args.map(s=>this.serializer.stringToTyped(s)),o=new je({chainID:e.chain.chainId});return new zt({config:o}).createTransactionForExecute(n,{contract:R.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=R.newFromBech32(e.destination),s=a.createSmartContractController(r),p=s.createQuery({contract:o,function:t.func||"",arguments:n}),c=await s.runQuery(p),u=c.returnCode==="ok",l=new Lt,g=r.getEndpoint(c.function||t.func||""),w=(c.returnDataParts||[]).map(E=>Buffer.from(E)),m=l.buffersToValues(w,g.output),{values:b,valuesRaw:x,results:W}=await this.results.extractQueryResults(e.warp,m,e.action,e.resolvedInputs),A=Yt(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:Jt(e.warp,W)}}async preprocessInput(e,t,r,n){if(r==="asset"){let[a,o,s,p]=n.split(Ke.ArgCompositeSeparator);if(p)return t;let c=new Qe({identifier:a,nonce:BigInt(o||0)});if(!new Qt().isFungible(c))return t;let g=Xt(a)?.decimals;if(g||(g=(await(await fetch(`${e.defaultApiUrl}/tokens/${a}`)).json()).decimals),!g)throw new Error(`WarpActionExecutor: Decimals not found for token ${a}`);let w=He(new Ge({token:c,amount:er(s,g)}));return this.serializer.typedToString(w)+Ke.ArgCompositeSeparator+g}return t}static getChainEntrypoint(e,t,r){let n="warp-sdk",o=r?Zt(r,e.name,t,e.defaultApiUrl):e.defaultApiUrl;return t==="devnet"?new qt({url:o,kind:"api",clientName:n}):t==="testnet"?new Ht({url:o,kind:"api",clientName:n}):new Dt({url:o,kind:"api",clientName:n})}async signMessage(e,t){let r=jt.fromString(t);return(await new Kt(r).sign(new Uint8Array(Buffer.from(e,"utf-8")))).toString()}toTokenTransfers(e){return e.map(t=>t.identifier===this.chain.nativeToken.identifier?{...t,identifier:tr}:t).map(t=>new Ge({token:new Qe({identifier:t.identifier,nonce:t.nonce}),amount:t.amount}))}};var M=class{constructor(e){this.config=e}async getContract(e,t){try{let a=await d.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 d.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 M(this.config),this.cache=new rr(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=nr.WarpAbi(this.config.env,e);if(t){let o=this.cache.get(r);if(o)return Ye.info(`WarpAbiBuilder (createFromTransactionHash): Warp abi found in cache: ${e}`),o}let a=d.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 Ye.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(Xe.IdentifierType.Hash)){let t=e.abi.split(Xe.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 Ze,TransactionsFactoryConfig as ar,TransferTransactionsFactory as sr}from"@multiversx/sdk-core";import{WarpBrandBuilder as ir,WarpLogger as or}from"@vleap/warps";import{Buffer as cr}from"buffer";var $=class{constructor(e,t){this.config=e;this.chain=t;this.core=new ir(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 ar({chainID:this.chain.chainId}),n=new sr({config:r}),a=Ze.newFromBech32(t),o=JSON.stringify(e);return await n.createTransactionForNativeTokenTransfer(a,{receiver:Ze.newFromBech32(t),nativeAmount:BigInt(0),data:Uint8Array.from(cr.from(o))})}async createFromTransaction(e,t=!1){return await this.core.createFromRaw(e.data.toString(),t)}async createFromTransactionHash(e){let r=d.getChainEntrypoint(this.chain,this.config.env).createNetworkProvider();try{let n=await r.getTransaction(e);return this.createFromTransaction(n)}catch(n){return or.error("BrandBuilder: Error creating from transaction hash",n),null}}};import{Address as et,TransactionsFactoryConfig as pr,TransferTransactionsFactory as ur}from"@multiversx/sdk-core";import{WarpBuilder as tt,WarpCache as lr,WarpCacheKey as mr,WarpLogger as rt}from"@vleap/warps";var L=class extends tt{constructor(t,r){super(t);this.config=t;this.chain=r;this.cache=new lr(t.cache?.type),this.core=new tt(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 pr({chainID:this.chain.chainId}),a=new ur({config:n}),o=et.newFromBech32(r),s=JSON.stringify(t),p=await a.createTransactionForTransfer(o,{receiver:et.newFromBech32(r),nativeAmount:BigInt(0),data:Uint8Array.from(Buffer.from(s))});return p.gasLimit=p.gasLimit+BigInt(2e6),p}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=mr.Warp(this.config.env,t);if(r){let s=this.cache.get(n);if(s)return rt.info(`WarpBuilder (createFromTransactionHash): Warp found in cache: ${t}`),s}let o=d.getChainEntrypoint(this.chain,this.config.env).createNetworkProvider();try{let s=await o.getTransaction(t),p=await this.createFromTransaction(s);return r&&r.ttl&&p&&this.cache.set(n,p,r.ttl),p}catch(s){return rt.error("WarpBuilder: Error creating from transaction hash",s),null}}};import{Address as nt}from"@multiversx/sdk-core";var q=class{constructor(e,t){this.config=e;this.chain=t}async getAccount(e){let r=await d.getChainEntrypoint(this.chain,this.config.env,this.config).createNetworkProvider().getAccount(nt.newFromBech32(e));return{chain:this.chain.name,address:r.address.toBech32(),balance:r.balance}}async getAccountAssets(e){return(await d.getChainEntrypoint(this.chain,this.config.env,this.config).createNetworkProvider().getFungibleTokensOfAccount(nt.newFromBech32(e))).map(n=>({chain:this.chain.name,identifier:n.token.identifier,name:n.raw.name,amount:n.amount,decimals:n.raw.decimals,logoUrl:n.raw.assets?.pngUrl||""}))}async getAccountActions(e,t){let r=d.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 c=s*o;a.append("from",c.toString())}return o!==25&&a.append("size",o.toString()),a.toString()&&(n+=`?${a.toString()}`),(await r.doGetGeneric(n)).map(c=>({chain:this.chain.name,id:c.txHash,receiver:c.receiver,sender:c.sender,value:c.value,function:c.function,status:c.status,createdAt:new Date(c.timestampMs||c.timestamp*1e3).toISOString()}))}};var va={Egld:{Identifier:"EGLD",EsdtIdentifier:"EGLD-000000",DisplayName:"eGold",Decimals:18}},fr=(r=>(r.MultiversxExplorer="multiversx_explorer",r.MultiversxExplorerDevnet="multiversx_explorer_devnet",r.MultiversxExplorerTestnet="multiversx_explorer_testnet",r))(fr||{}),dr=(r=>(r.VibechainExplorer="vibechain_explorer",r.VibechainExplorerDevnet="vibechain_explorer_devnet",r.VibechainExplorerTestnet="vibechain_explorer_testnet",r))(dr||{}),at={multiversx:{mainnet:["multiversx_explorer"],testnet:["multiversx_explorer_testnet"],devnet:["multiversx_explorer_devnet"]},vibechain:{mainnet:["vibechain_explorer"],testnet:["vibechain_explorer_testnet"],devnet:["vibechain_explorer_devnet"]}},V={multiversx_explorer:"https://explorer.multiversx.com",multiversx_explorer_devnet:"https://devnet-explorer.multiversx.com",multiversx_explorer_testnet:"https://testnet-explorer.multiversx.com",vibechain_explorer:"https://vibeox-explorer.multiversx.com",vibechain_explorer_devnet:"https://vibeox-explorer.multiversx.com",vibechain_explorer_testnet:"https://vibeox-explorer.multiversx.com"};var D=class{constructor(e,t){this.chain=e;this.config=t}getExplorers(){let e=at[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=V[t];if(a)return a}if(e){let a=V[e];if(a)return a}let r=this.getPrimaryExplorer();return V[r]||V[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=V[n];a&&(r[n]=`${a}/accounts/${e}`)}),r}getTransactionUrls(e){let t=this.getAllExplorers(),r={};return t.forEach(n=>{let a=V[n];a&&(r[n]=`${a}/transactions/${e}`)}),r}};import{AbiRegistry as it,Address as f,AddressValue as ye,BytesValue as h,SmartContractTransactionsFactory as gr,TransactionsFactoryConfig as yr}from"@multiversx/sdk-core";import{WarpCache as wr,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 C=i=>{if(i==="devnet")return"erd1qqqqqqqqqqqqqpgqje2f99vr6r7sk54thg03c9suzcvwr4nfl3tsfkdl36";if(i==="testnet")throw new Error("Multiversx testnet is not supported");return"erd1qqqqqqqqqqqqqpgq3mrpj3u6q7tejv6d7eqhnyd27n9v5c5tl3ts08mffe"};var z=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}),st=i=>({unitPrice:BigInt(i.unit_price.toString()),admins:i.admins.map(e=>e.toBech32())});var H=class{constructor(e,t){this.config=e;this.chain=t;this.cache=new wr(e.cache?.type),this.registryConfig={unitPrice:BigInt(0),admins:[]},this.userWallet=this.config.user?.wallets?.[this.chain.name]||null}async init(){await this.loadRegistryConfigs()}getRegistryConfig(){return this.registryConfig}async createWarpRegisterTransaction(e,t,r){if(this.registryConfig.unitPrice===BigInt(0))throw new Error("WarpRegistry: config not loaded. forgot to call init()?");if(!this.userWallet)throw new Error("WarpRegistry: user address not set");let n=f.newFromBech32(this.userWallet),a=()=>this.isCurrentUserAdmin()?BigInt(0):t&&r?this.registryConfig.unitPrice*BigInt(3):t?this.registryConfig.unitPrice*BigInt(2):this.registryConfig.unitPrice,o=()=>t&&r?[h.fromHex(e),h.fromUTF8(t),h.fromHex(r)]:t?[h.fromHex(e),h.fromUTF8(t)]:[h.fromHex(e)];return await this.getFactory().createTransactionForExecute(n,{contract:f.newFromBech32(C(this.config.env)),function:"registerWarp",gasLimit:BigInt(1e7),nativeTransferAmount:a(),arguments:o()})}async createWarpUnregisterTransaction(e){if(!this.userWallet)throw new Error("WarpRegistry: user address not set");let t=f.newFromBech32(this.userWallet);return await this.getFactory().createTransactionForExecute(t,{contract:f.newFromBech32(C(this.config.env)),function:"unregisterWarp",gasLimit:BigInt(1e7),arguments:[h.fromHex(e)]})}async createWarpUpgradeTransaction(e,t){if(this.registryConfig.unitPrice===BigInt(0))throw new Error("WarpRegistry: config not loaded. forgot to call init()?");if(!this.userWallet)throw new Error("WarpRegistry: user address not set");let r=f.newFromBech32(this.userWallet);return await this.getFactory().createTransactionForExecute(r,{contract:f.newFromBech32(C(this.config.env)),function:"upgradeWarp",gasLimit:BigInt(1e7),nativeTransferAmount:this.isCurrentUserAdmin()?void 0:this.registryConfig.unitPrice,arguments:[h.fromUTF8(e),h.fromHex(t)]})}async createWarpAliasSetTransaction(e,t){if(!this.userWallet)throw new Error("WarpRegistry: user address not set");let r=f.newFromBech32(this.userWallet);return await this.getFactory().createTransactionForExecute(r,{contract:f.newFromBech32(C(this.config.env)),function:"setWarpAlias",gasLimit:BigInt(1e7),nativeTransferAmount:this.isCurrentUserAdmin()?void 0:this.registryConfig.unitPrice,arguments:[h.fromHex(e),h.fromUTF8(t)]})}async createWarpVerifyTransaction(e){if(!this.userWallet)throw new Error("WarpRegistry: user address not set");let t=f.newFromBech32(this.userWallet);return await this.getFactory().createTransactionForExecute(t,{contract:f.newFromBech32(C(this.config.env)),function:"verifyWarp",gasLimit:BigInt(1e7),arguments:[h.fromHex(e)]})}async createWarpTransferOwnershipTransaction(e,t){if(!this.userWallet)throw new Error("WarpRegistry: user address not set");let r=f.newFromBech32(this.userWallet);return await this.getFactory().createTransactionForExecute(r,{contract:f.newFromBech32(C(this.config.env)),function:"transferOwnership",gasLimit:BigInt(1e7),arguments:[h.fromHex(e),new ye(new f(t))]})}async createBrandRegisterTransaction(e){if(this.registryConfig.unitPrice===BigInt(0))throw new Error("WarpRegistry: config not loaded. forgot to call init()?");if(!this.userWallet)throw new Error("WarpRegistry: user address not set");let t=f.newFromBech32(this.userWallet);return await this.getFactory().createTransactionForExecute(t,{contract:f.newFromBech32(C(this.config.env)),function:"registerBrand",gasLimit:BigInt(1e7),nativeTransferAmount:this.isCurrentUserAdmin()?void 0:this.registryConfig.unitPrice,arguments:[h.fromHex(e)]})}async createWarpBrandingTransaction(e,t){if(!this.userWallet)throw new Error("WarpRegistry: user address not set");let r=f.newFromBech32(this.userWallet);return await this.getFactory().createTransactionForExecute(r,{contract:f.newFromBech32(C(this.config.env)),function:"brandWarp",gasLimit:BigInt(1e7),nativeTransferAmount:this.isCurrentUserAdmin()?void 0:this.registryConfig.unitPrice,arguments:[h.fromHex(e),h.fromHex(t)]})}async getInfoByAlias(e,t){try{let r=we.RegistryInfo(this.config.env,e),n=t?this.cache.get(r):null;if(n)return Ce.info(`WarpRegistry (getInfoByAlias): RegistryInfo found in cache: ${e}`),n;let a=f.newFromBech32(C(this.config.env)),o=this.getController(),s=o.createQuery({contract:a,function:"getInfoByAlias",arguments:[h.fromUTF8(e)]}),p=await o.runQuery(s),[c]=o.parseQueryResponse(p),u=c?z(c):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=f.newFromBech32(C(this.config.env)),a=this.getController(),o=a.createQuery({contract:n,function:"getInfoByHash",arguments:[h.fromHex(e)]}),s=await a.runQuery(o),[p]=a.parseQueryResponse(s),c=p?z(p):null,u=c?.brand?await this.fetchBrand(c.brand):null;return t&&t.ttl&&this.cache.set(r,{registryInfo:c,brand:u},t.ttl),{registryInfo:c,brand:u}}catch{return{registryInfo:null,brand:null}}}async getUserWarpRegistryInfos(e){try{let t=e||this.userWallet;if(!t)throw new Error("WarpRegistry: user address not set");let r=f.newFromBech32(C(this.config.env)),n=this.getController(),a=n.createQuery({contract:r,function:"getUserWarps",arguments:[new ye(new f(t))]}),o=await n.runQuery(a),[s]=n.parseQueryResponse(o);return s.map(z)}catch{return[]}}async getUserBrands(e){try{let t=e||this.userWallet;if(!t)throw new Error("WarpRegistry: user address not set");let r=f.newFromBech32(C(this.config.env)),n=this.getController(),a=n.createQuery({contract:r,function:"getUserBrands",arguments:[new ye(new f(t))]}),o=await n.runQuery(a),[s]=n.parseQueryResponse(o),p=s.map(l=>l.toString("hex")),c={ttl:365*24*60*60};return(await Promise.all(p.map(l=>this.fetchBrand(l,c)))).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=d.getChainEntrypoint(this.chain,this.config.env).createNetworkProvider();try{let s=await o.getTransaction(e),p=JSON.parse(s.data.toString());return p.meta={hash:s.hash,creator:s.sender.toBech32(),createdAt:new Date(s.timestamp*1e3).toISOString()},t&&t.ttl&&this.cache.set(r,p,t.ttl),p}catch{return null}}async loadRegistryConfigs(){let e=f.newFromBech32(C(this.config.env)),t=this.getController(),[r]=await t.query({contract:e,function:"getConfig",arguments:[]}),n=r?st(r):null;this.registryConfig=n||{unitPrice:BigInt(0),admins:[]}}getFactory(){let e=new yr({chainID:this.chain.chainId}),t=it.create(ge);return new gr({config:e,abi:t})}getController(){let e=d.getChainEntrypoint(this.chain,this.config.env),t=it.create(ge);return e.createSmartContractController(t)}isCurrentUserAdmin(){return!!this.userWallet&&this.registryConfig.admins.includes(this.userWallet)}};var Q=(i,e,t)=>(r,n)=>{let a=t[r.env];return{chain:i,chainInfo:a,prefix:e,builder:()=>new L(r,a),executor:new d(r,a),results:new N(r,a),serializer:new B,registry:new H(r,a),explorer:new D(i,r),abiBuilder:()=>new I(r,a),brandBuilder:()=>new $(r,a),dataLoader:new q(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:F.Multiversx,identifier:"EGLD",name:"eGold",decimals:18,logoUrl:"https://vleap.ai/images/tokens/egld.svg"},ot=Q(F.Multiversx,"mvx",{mainnet:{name:F.Multiversx,displayName:"MultiversX",chainId:"1",blockTime:6e3,addressHrp:"erd",defaultApiUrl:"https://api.multiversx.com",nativeToken:xe},testnet:{name:F.Multiversx,displayName:"MultiversX Testnet",chainId:"T",blockTime:6e3,addressHrp:"erd",defaultApiUrl:"https://testnet-api.multiversx.com",nativeToken:xe},devnet:{name:F.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 Cr={chain:Te.Vibechain,identifier:"VIBE",name:"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:Cr},ct=Q(Te.Vibechain,"vibe",{mainnet:We,testnet:We,devnet:We});var ws=(i,e)=>[ot(i,e),ct(i,e)],Cs=()=>[pt.Multiversx,pt.Vibechain];export{V as ExplorerUrls,fr as MultiversxExplorers,at as MultiversxExplorersConfig,xe as NativeTokenEgld,Cr as NativeTokenVibe,dr as VibechainExplorers,I as WarpMultiversxAbiBuilder,$ as WarpMultiversxBrandBuilder,L as WarpMultiversxBuilder,va as WarpMultiversxConstants,M as WarpMultiversxContractLoader,q as WarpMultiversxDataLoader,d as WarpMultiversxExecutor,D as WarpMultiversxExplorer,H as WarpMultiversxRegistry,N as WarpMultiversxResults,B as WarpMultiversxSerializer,pn as address_value,on as biguint_value,cn as boolean_value,mn as codemeta_value,en as composite_value,Q as createMultiversxAdapter,He as esdt_value,ws as getAllMultiversxAdapters,Cs as getAllMultiversxChainNames,ot as getMultiversxAdapter,C as getMultiversxRegistryAddress,ct as getVibechainAdapter,ln as hex_value,Yr as list_value,fn as nothing_value,Jr as option_value,Xr as optional_value,tn as string_value,un as token_value,nn as u16_value,an as u32_value,sn as u64_value,rn as u8_value,Zr as variadic_value};
|
|
1
|
+
import{WarpChainName as lt}from"@vleap/warps";import{WarpChainName as k}from"@vleap/warps";import{AbiRegistry as he}from"@multiversx/sdk-core";import{WarpCache as nr,WarpCacheKey as ar,WarpConstants as et,WarpLogger as tt}from"@vleap/warps";import{WarpLogger as Ze}from"@vleap/warps";import{Address as F,ArgSerializer as zt,DevnetEntrypoint as Ht,MainnetEntrypoint as Qt,SmartContractTransactionsFactory as Gt,TestnetEntrypoint as jt,Token as je,TokenComputer as Ke,TokenTransfer as Je,TransactionsFactoryConfig as Xe,TransferTransactionsFactory as Kt,UserSecretKey as Jt,UserSigner as Xt}from"@multiversx/sdk-core";import{applyResultsToMessages as Yt,getNextInfo as Zt,getProviderUrl as er,getWarpActionByIndex as fe,shiftBigintBy as tr,WarpConstants as Ye}from"@vleap/warps";import{findEventsByFirstTopic as gt,SmartContractTransactionsOutcomeParser as yt,TransactionEventsParser as wt}from"@multiversx/sdk-core";import{applyResultsToMessages as Ct,evaluateResultsCommon as O,findWarpExecutableAction as $e,getNextInfo as xt,parseResultsOutIndex as Le,WarpCache as Wt,WarpCacheKey as Tt,WarpConstants as qe}from"@vleap/warps";import{Address as mt,AddressType as G,AddressValue as be,BigUIntType as P,BigUIntValue as j,BooleanType as K,BooleanValue as Ee,BytesType as J,BytesValue as Ae,CodeMetadata as dt,CodeMetadataType as X,CodeMetadataValue as Be,CompositeType as Y,CompositeValue as Ie,Field as Z,FieldDefinition as ee,List as Ve,ListType as Ne,NothingValue as W,OptionalType as Se,OptionalValue as te,OptionType as Fe,OptionValue as re,StringType as ne,StringValue as ke,Struct as ft,StructType as Re,TokenIdentifierType as U,TokenIdentifierValue as ae,U16Type as se,U16Value as Pe,U32Type as ie,U32Value as Ue,U64Type as _,U64Value as oe,U8Type as ce,U8Value as _e,VariadicType as pe,VariadicValue as Oe}from"@multiversx/sdk-core";import{WarpConstants as T,WarpSerializer as ht}from"@vleap/warps";var Me=new RegExp(`${T.ArgParamsSeparator}(.*)`),B=class{constructor(){this.coreSerializer=new ht}typedToString(e){let t=e.getType();if(t.hasExactClass(Fe.ClassName)||e.hasClassOrSuperclass(re.ClassName))return e.isSet()?`option:${this.typedToString(e.getTypedValue())}`:"option:null";if(t.hasExactClass(Se.ClassName)||e.hasClassOrSuperclass(te.ClassName))return e.isSet()?`optional:${this.typedToString(e.getTypedValue())}`:"optional:null";if(t.hasExactClass(Ne.ClassName)||e.hasClassOrSuperclass(Ve.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(pe.ClassName)||e.hasClassOrSuperclass(Oe.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(Y.ClassName)||e.hasClassOrSuperclass(Ie.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(P.ClassName)||e.hasClassOrSuperclass(j.ClassName)||t.getName()==="BigUint")return`biguint:${BigInt(e.valueOf().toFixed())}`;if(t.hasExactClass(ce.ClassName)||e.hasClassOrSuperclass(_e.ClassName))return`uint8:${e.valueOf().toNumber()}`;if(t.hasExactClass(se.ClassName)||e.hasClassOrSuperclass(Pe.ClassName))return`uint16:${e.valueOf().toNumber()}`;if(t.hasExactClass(ie.ClassName)||e.hasClassOrSuperclass(Ue.ClassName))return`uint32:${e.valueOf().toNumber()}`;if(t.hasExactClass(_.ClassName)||e.hasClassOrSuperclass(oe.ClassName))return`uint64:${BigInt(e.valueOf().toFixed())}`;if(t.hasExactClass(ne.ClassName)||e.hasClassOrSuperclass(ke.ClassName))return`string:${e.valueOf()}`;if(t.hasExactClass(K.ClassName)||e.hasClassOrSuperclass(Ee.ClassName))return`bool:${e.valueOf()}`;if(t.hasExactClass(G.ClassName)||e.hasClassOrSuperclass(be.ClassName))return`address:${e.valueOf().toBech32()}`;if(t.hasExactClass(U.ClassName)||e.hasClassOrSuperclass(ae.ClassName))return`token:${e.valueOf()}`;if(t.hasExactClass(J.ClassName)||e.hasClassOrSuperclass(Ae.ClassName))return`hex:${e.valueOf().toString("hex")}`;if(t.hasExactClass(X.ClassName)||e.hasClassOrSuperclass(Be.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:${r}|${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 Y(...t.split(T.ArgCompositeSeparator).map(r=>this.nativeToType(r)))}if(e==="string")return new ne;if(e==="uint8")return new ce;if(e==="uint16")return new se;if(e==="uint32")return new ie;if(e==="uint64")return new _;if(e==="biguint")return new P;if(e==="bool")return new K;if(e==="address")return new G;if(e==="token")return new U;if(e==="hex")return new J;if(e==="codemeta")return new X;if(e==="asset")return new Re("EsdtTokenPayment",[new ee("token_identifier","",new U),new ee("token_nonce","",new _),new ee("amount","",new P)]);throw new Error(`WarpArgSerializer (nativeToType): Unsupported input type: ${e}`)}stringToTyped(e){let[t,r]=e.split(/:(.*)/,2);if(t==="null"||t===null)return new W;if(t==="option"){let n=this.stringToTyped(r);return n instanceof W?re.newMissingTyped(n.getType()):re.newProvided(n)}if(t==="optional"){let n=this.stringToTyped(r);return n instanceof W?te.newMissing():new te(n.getType(),n)}if(t==="list"){let[n,a]=r.split(Me,2),s=a.split(",").map(c=>this.stringToTyped(`${n}:${c}`));return new Ve(this.nativeToType(n),s)}if(t==="variadic"){let[n,a]=r.split(Me,2),s=a.split(",").map(c=>this.stringToTyped(`${n}:${c}`));return new Oe(new pe(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 Ie(new Y(...c),s)}if(t==="string")return r?ke.fromUTF8(r):new W;if(t==="uint8")return r?new _e(Number(r)):new W;if(t==="uint16")return r?new Pe(Number(r)):new W;if(t==="uint32")return r?new Ue(Number(r)):new W;if(t==="uint64")return r?new oe(BigInt(r)):new W;if(t==="biguint")return r?new j(BigInt(r)):new W;if(t==="bool")return r?new Ee(typeof r=="boolean"?r:r==="true"):new W;if(t==="address")return r?new be(mt.newFromBech32(r)):new W;if(t==="token")return r?new ae(r):new W;if(t==="hex")return r?Ae.fromHex(r):new W;if(t==="codemeta")return new Be(dt.newFromBytes(Uint8Array.from(Buffer.from(r,"hex"))));if(t==="asset"){let n=r.split(T.ArgCompositeSeparator);return new ft(this.nativeToType("asset"),[new Z(new ae(n[0]),"token_identifier"),new Z(new oe(BigInt(n[1])),"token_nonce"),new Z(new j(BigInt(n[2])),"amount")])}throw new Error(`WarpArgSerializer (stringToTyped): Unsupported input type: ${t}`)}typeToString(e){if(e.hasExactClass(Fe.ClassName))return"option:"+this.typeToString(e.getFirstTypeParameter());if(e.hasExactClass(Se.ClassName))return"optional:"+this.typeToString(e.getFirstTypeParameter());if(e.hasExactClass(Ne.ClassName))return"list:"+this.typeToString(e.getFirstTypeParameter());if(e.hasExactClass(pe.ClassName))return"variadic:"+this.typeToString(e.getFirstTypeParameter());if(e.hasExactClass(ne.ClassName))return"string";if(e.hasExactClass(ce.ClassName))return"uint8";if(e.hasExactClass(se.ClassName))return"uint16";if(e.hasExactClass(ie.ClassName))return"uint32";if(e.hasExactClass(_.ClassName))return"uint64";if(e.hasExactClass(P.ClassName))return"biguint";if(e.hasExactClass(K.ClassName))return"bool";if(e.hasExactClass(G.ClassName))return"address";if(e.hasExactClass(U.ClassName))return"token";if(e.hasExactClass(J.ClassName))return"hex";if(e.hasExactClass(X.ClassName))return"codemeta";if(e.hasExactClass(Re.ClassName)&&e.getClassName()==="EsdtTokenPayment")return"asset";throw new Error(`WarpArgSerializer (typeToString): Unsupported input type: ${e.getClassName()}`)}};var N=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}=$e(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}=$e(e),o=[],s={};if(!e.results||n.type!=="contract")return{values:o,results:s};if(!Object.values(e.results).some(h=>h.includes("out")||h.includes("event"))){for(let[h,m]of Object.entries(e.results))s[h]=m;return{values:o,results:await O(e,s,a,r,this.config.transform?.runner)}}let p=await this.abi.getAbiForAction(n),u=new wt({abi:p}),v=new yt({abi:p}).parseExecute({transactionOnNetwork:t,function:n.func||void 0});for(let[h,m]of Object.entries(e.results)){if(m.startsWith(qe.Transform.Prefix))continue;if(m.startsWith("input.")){s[h]=m;continue}let b=Le(m);if(b!==null&&b!==a){s[h]=null;continue}let[w,x,A]=m.split(".");if(w==="event"){if(!x||isNaN(Number(A)))continue;let E=Number(A),y=gt(t,x),S=u.parseEvents({events:y})[0],R=Object.values(S)[E]||null;o.push(R),s[h]=R&&R.valueOf()}else if(w==="out"||w.startsWith("out[")){if(!x)continue;let E=Number(x),y=v.values[E-1]||null;A&&(y=y[A]||null),y&&typeof y=="object"&&(y="toFixed"in y?y.toFixed():y.valueOf()),o.push(y),s[h]=y&&y.valueOf()}else s[h]=m}return{values:o,results:await O(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(v=>parseInt(v)-1);if(u.length===0)return;let l=o[u[0]];for(let v=1;v<u.length;v++){if(l==null)return;l=l[u[v]]}return l};for(let[p,u]of Object.entries(e.results)){if(u.startsWith(qe.Transform.Prefix))continue;let l=Le(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 O(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 w=t.actions[m-1];if(!w)throw new Error(`Action ${m} not found`);let x;if(w.type==="query")x=await n.executeQuery(t,m,b);else if(w.type==="collect")x=await n.executeCollect(t,m,b,o);else throw new Error(`Unsupported or interactive action type: ${w.type}`);if(s.set(m,x),t.results)for(let A of Object.values(t.results)){let y=String(A).match(/^out\[(\d+)\]/);if(y){let S=parseInt(y[1],10);S!==m&&!s.has(S)&&await u(S)}}return c.delete(m),x}await u(r,a);let l={};for(let m of s.values())for(let[b,w]of Object.entries(m.results))w!==null?l[b]=w:b in l||(l[b]=null);let v=await O(t,l,r,a,this.config.transform?.runner);return{...s.get(r),action:r,results:v}}};var vt=[{id:"EGLD",name:"eGold",decimals:18},{id:"EGLD-000000",name:"eGold",decimals:18},{id:"VIBE-000000",name:"VIBE",decimals:18}],De=i=>vt.find(e=>e.id===i)||null;import{Address as bt,AddressValue as Et,BigUIntType as At,BigUIntValue as ze,BooleanValue as Bt,BytesValue as It,CodeMetadata as Vt,CodeMetadataValue as Nt,CompositeType as St,CompositeValue as Ft,Field as ue,FieldDefinition as le,List as kt,NothingValue as Rt,OptionalValue as me,OptionValue as de,StringValue as Pt,Struct as Ut,StructType as _t,TokenIdentifierType as Ot,TokenIdentifierValue as He,U16Value as Mt,U32Value as $t,U64Type as Lt,U64Value as Qe,U8Value as qt,VariadicValue as Dt}from"@multiversx/sdk-core";var Yr=(i,e)=>i?de.newProvided(i):e?de.newMissingTyped(e):de.newMissing(),Zr=(i,e)=>i?new me(i.getType(),i):e?new me(e):me.newMissing(),en=i=>{if(i.length===0)throw new Error("Cannot create a list from an empty array");let e=i[0].getType();return new kt(e,i)},tn=i=>Dt.fromItems(...i),rn=i=>{let e=i.map(t=>t.getType());return new Ft(new St(...e),i)},nn=i=>Pt.fromUTF8(i),an=i=>new qt(i),sn=i=>new Mt(i),on=i=>new $t(i),cn=i=>new Qe(i),pn=i=>new ze(BigInt(i)),un=i=>new Bt(i),ln=i=>new Et(bt.newFromBech32(i)),mn=i=>new He(i),dn=i=>It.fromHex(i),Ge=i=>new Ut(new _t("EsdtTokenPayment",[new le("token_identifier","",new Ot),new le("token_nonce","",new Lt),new le("amount","",new At)]),[new ue(new He(i.token.identifier),"token_identifier"),new ue(new Qe(BigInt(i.token.nonce)),"token_nonce"),new ue(new ze(BigInt(i.amount)),"amount")]),fn=i=>new Nt(Vt.newFromBytes(Uint8Array.from(Buffer.from(i,"hex")))),hn=()=>new Rt;var rr="EGLD-000000",f=class i{constructor(e,t){this.config=e;this.chain=t;this.serializer=new B,this.abi=new I(this.config,this.chain),this.results=new N(this.config,this.chain)}async createTransaction(e){let t=fe(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 Xe({chainID:e.chain.chainId}),a=e.data?Buffer.from(this.serializer.stringToTyped(e.data).valueOf()):null;return new Kt({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=fe(e.warp,e.action),n=F.newFromBech32(t),a=e.args.map(s=>this.serializer.stringToTyped(s)),o=new Xe({chainID:e.chain.chainId});return new Gt({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=fe(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 zt,v=r.getEndpoint(p.function||t.func||""),h=(p.returnDataParts||[]).map(E=>Buffer.from(E)),m=l.buffersToValues(h,v.output),{values:b,valuesRaw:w,results:x}=await this.results.extractQueryResults(e.warp,m,e.action,e.resolvedInputs),A=Zt(this.config,[],e.warp,e.action,x);return{success:u,warp:e.warp,action:e.action,user:this.config.user?.wallets?.[e.chain.name]||null,txHash:null,tx:null,next:A,values:b,valuesRaw:w,results:x,messages:Yt(e.warp,x)}}async preprocessInput(e,t,r,n){if(r==="asset"){let[a,o,s]=n.split(Ye.ArgCompositeSeparator);if(s)return t;let c=new Ke,p=c.extractNonceFromExtendedIdentifier(a),u=new je({identifier:a,nonce:BigInt(p||0)});if(!c.isFungible(u))return t;let h=De(a)?.decimals;if(h||(h=(await(await fetch(`${e.defaultApiUrl}/tokens/${a}`)).json()).decimals),!h)throw new Error(`WarpActionExecutor: Decimals not found for token ${a}`);let m=Ge(new Je({token:u,amount:tr(o,h)}));return this.serializer.typedToString(m)+Ye.ArgCompositeSeparator+h}return t}static getChainEntrypoint(e,t,r){let n="warp-sdk",o=r?er(r,e.name,t,e.defaultApiUrl):e.defaultApiUrl;return t==="devnet"?new Ht({url:o,kind:"api",clientName:n}):t==="testnet"?new jt({url:o,kind:"api",clientName:n}):new Qt({url:o,kind:"api",clientName:n})}async signMessage(e,t){let r=Jt.fromString(t);return(await new Xt(r).sign(new Uint8Array(Buffer.from(e,"utf-8")))).toString()}toTokenTransfers(e){return e.map(t=>t.identifier===this.chain.nativeToken.identifier?{...t,identifier:rr}:t).map(t=>{let n=new Ke().extractNonceFromExtendedIdentifier(t.identifier);return new Je({token:new je({identifier:t.identifier,nonce:BigInt(n||0)}),amount:t.amount})})}};var M=class{constructor(e){this.config=e}async getContract(e,t){try{let a=await f.getChainEntrypoint(t,this.config.env).createNetworkProvider().doGetGeneric(`accounts/${e}`);return{address:e,owner:a.ownerAddress,verified:a.isVerified||!1}}catch(r){return Ze.error("WarpContractLoader: getContract error",r),null}}async getVerificationInfo(e,t){try{let a=await f.getChainEntrypoint(t,this.config.env).createNetworkProvider().doGetGeneric(`accounts/${e}/verification`);return{codeHash:a.codeHash,abi:a.source.abi}}catch(r){return Ze.error("WarpContractLoader: getVerificationInfo error",r),null}}};var I=class{constructor(e,t){this.config=e;this.chain=t;this.contractLoader=new M(this.config),this.cache=new nr(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=ar.WarpAbi(this.config.env,e);if(t){let o=this.cache.get(r);if(o)return tt.info(`WarpAbiBuilder (createFromTransactionHash): Warp abi found in cache: ${e}`),o}let a=f.getChainEntrypoint(this.chain,this.config.env).createNetworkProvider();try{let o=await a.getTransaction(e),s=await this.createFromTransaction(o);return t&&t.ttl&&s&&this.cache.set(r,s,t.ttl),s}catch(o){return tt.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(et.IdentifierType.Hash)){let t=e.abi.split(et.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 rt,TransactionsFactoryConfig as sr,TransferTransactionsFactory as ir}from"@multiversx/sdk-core";import{WarpBrandBuilder as or,WarpLogger as cr}from"@vleap/warps";import{Buffer as pr}from"buffer";var $=class{constructor(e,t){this.config=e;this.chain=t;this.core=new or(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 sr({chainID:this.chain.chainId}),n=new ir({config:r}),a=rt.newFromBech32(t),o=JSON.stringify(e);return await n.createTransactionForNativeTokenTransfer(a,{receiver:rt.newFromBech32(t),nativeAmount:BigInt(0),data:Uint8Array.from(pr.from(o))})}async createFromTransaction(e,t=!1){return await this.core.createFromRaw(e.data.toString(),t)}async createFromTransactionHash(e){let r=f.getChainEntrypoint(this.chain,this.config.env).createNetworkProvider();try{let n=await r.getTransaction(e);return this.createFromTransaction(n)}catch(n){return cr.error("BrandBuilder: Error creating from transaction hash",n),null}}};import{Address as nt,TransactionsFactoryConfig as ur,TransferTransactionsFactory as lr}from"@multiversx/sdk-core";import{WarpBuilder as at,WarpCache as mr,WarpCacheKey as dr,WarpLogger as st}from"@vleap/warps";var L=class extends at{constructor(t,r){super(t);this.config=t;this.chain=r;this.cache=new mr(t.cache?.type),this.core=new at(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 ur({chainID:this.chain.chainId}),a=new lr({config:n}),o=nt.newFromBech32(r),s=JSON.stringify(t),c=await a.createTransactionForTransfer(o,{receiver:nt.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=dr.Warp(this.config.env,t);if(r){let s=this.cache.get(n);if(s)return st.info(`WarpBuilder (createFromTransactionHash): Warp found in cache: ${t}`),s}let o=f.getChainEntrypoint(this.chain,this.config.env).createNetworkProvider();try{let s=await o.getTransaction(t),c=await this.createFromTransaction(s);return r&&r.ttl&&c&&this.cache.set(n,c,r.ttl),c}catch(s){return st.error("WarpBuilder: Error creating from transaction hash",s),null}}};import{Address as ge}from"@multiversx/sdk-core";var q=class{constructor(e,t){this.config=e;this.chain=t}async getAccount(e){let r=await f.getChainEntrypoint(this.chain,this.config.env,this.config).createNetworkProvider().getAccount(ge.newFromBech32(e));return{chain:this.chain.name,address:r.address.toBech32(),balance:r.balance}}async getAccountAssets(e){let t=f.getChainEntrypoint(this.chain,this.config.env,this.config).createNetworkProvider(),r=t.getAccount(ge.newFromBech32(e)),n=t.getFungibleTokensOfAccount(ge.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,amount:c.amount,decimals:c.raw.decimals,logoUrl:c.raw.assets?.pngUrl||""}))),s}async getAccountActions(e,t){let r=f.getChainEntrypoint(this.chain,this.config.env,this.config).createNetworkProvider(),n=`accounts/${e}/transactions`,a=new URLSearchParams,o=t?.size||25,s=t?.page||0;if(s>0){let p=s*o;a.append("from",p.toString())}return o!==25&&a.append("size",o.toString()),a.toString()&&(n+=`?${a.toString()}`),(await r.doGetGeneric(n)).map(p=>({chain:this.chain.name,id:p.txHash,receiver:p.receiver,sender:p.sender,value:p.value,function:p.function,status:p.status,createdAt:new Date(p.timestampMs||p.timestamp*1e3).toISOString()}))}};var Aa={Egld:{Identifier:"EGLD",EsdtIdentifier:"EGLD-000000",DisplayName:"eGold",Decimals:18}},fr=(r=>(r.MultiversxExplorer="multiversx_explorer",r.MultiversxExplorerDevnet="multiversx_explorer_devnet",r.MultiversxExplorerTestnet="multiversx_explorer_testnet",r))(fr||{}),hr=(r=>(r.VibechainExplorer="vibechain_explorer",r.VibechainExplorerDevnet="vibechain_explorer_devnet",r.VibechainExplorerTestnet="vibechain_explorer_testnet",r))(hr||{}),it={multiversx:{mainnet:["multiversx_explorer"],testnet:["multiversx_explorer_testnet"],devnet:["multiversx_explorer_devnet"]},vibechain:{mainnet:["vibechain_explorer"],testnet:["vibechain_explorer_testnet"],devnet:["vibechain_explorer_devnet"]}},V={multiversx_explorer:"https://explorer.multiversx.com",multiversx_explorer_devnet:"https://devnet-explorer.multiversx.com",multiversx_explorer_testnet:"https://testnet-explorer.multiversx.com",vibechain_explorer:"https://vibeox-explorer.multiversx.com",vibechain_explorer_devnet:"https://vibeox-explorer.multiversx.com",vibechain_explorer_testnet:"https://vibeox-explorer.multiversx.com"};var D=class{constructor(e,t){this.chain=e;this.config=t}getExplorers(){let e=it[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=V[t];if(a)return a}if(e){let a=V[e];if(a)return a}let r=this.getPrimaryExplorer();return V[r]||V[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=V[n];a&&(r[n]=`${a}/accounts/${e}`)}),r}getTransactionUrls(e){let t=this.getAllExplorers(),r={};return t.forEach(n=>{let a=V[n];a&&(r[n]=`${a}/transactions/${e}`)}),r}};import{AbiRegistry as ct,Address as d,AddressValue as we,BytesValue as g,SmartContractTransactionsFactory as yr,TransactionsFactoryConfig as wr}from"@multiversx/sdk-core";import{WarpCache as Cr,WarpCacheKey as Ce,WarpLogger as xe}from"@vleap/warps";var ye={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 C=i=>{if(i==="devnet")return"erd1qqqqqqqqqqqqqpgqje2f99vr6r7sk54thg03c9suzcvwr4nfl3tsfkdl36";if(i==="testnet")throw new Error("Multiversx testnet is not supported");return"erd1qqqqqqqqqqqqqpgq3mrpj3u6q7tejv6d7eqhnyd27n9v5c5tl3ts08mffe"};var z=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}),ot=i=>({unitPrice:BigInt(i.unit_price.toString()),admins:i.admins.map(e=>e.toBech32())});var H=class{constructor(e,t){this.config=e;this.chain=t;this.cache=new Cr(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?[g.fromHex(e),g.fromUTF8(t),g.fromHex(r)]:t?[g.fromHex(e),g.fromUTF8(t)]:[g.fromHex(e)];return await this.getFactory().createTransactionForExecute(n,{contract:d.newFromBech32(C(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(C(this.config.env)),function:"unregisterWarp",gasLimit:BigInt(1e7),arguments:[g.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(C(this.config.env)),function:"upgradeWarp",gasLimit:BigInt(1e7),nativeTransferAmount:this.isCurrentUserAdmin()?void 0:this.registryConfig.unitPrice,arguments:[g.fromUTF8(e),g.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(C(this.config.env)),function:"setWarpAlias",gasLimit:BigInt(1e7),nativeTransferAmount:this.isCurrentUserAdmin()?void 0:this.registryConfig.unitPrice,arguments:[g.fromHex(e),g.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(C(this.config.env)),function:"verifyWarp",gasLimit:BigInt(1e7),arguments:[g.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(C(this.config.env)),function:"transferOwnership",gasLimit:BigInt(1e7),arguments:[g.fromHex(e),new we(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(C(this.config.env)),function:"registerBrand",gasLimit:BigInt(1e7),nativeTransferAmount:this.isCurrentUserAdmin()?void 0:this.registryConfig.unitPrice,arguments:[g.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(C(this.config.env)),function:"brandWarp",gasLimit:BigInt(1e7),nativeTransferAmount:this.isCurrentUserAdmin()?void 0:this.registryConfig.unitPrice,arguments:[g.fromHex(e),g.fromHex(t)]})}async getInfoByAlias(e,t){try{let r=Ce.RegistryInfo(this.config.env,e),n=t?this.cache.get(r):null;if(n)return xe.info(`WarpRegistry (getInfoByAlias): RegistryInfo found in cache: ${e}`),n;let a=d.newFromBech32(C(this.config.env)),o=this.getController(),s=o.createQuery({contract:a,function:"getInfoByAlias",arguments:[g.fromUTF8(e)]}),c=await o.runQuery(s),[p]=o.parseQueryResponse(c),u=p?z(p):null,l=u?.brand?await this.fetchBrand(u.brand):null;return t&&t.ttl&&this.cache.set(r,{registryInfo:u,brand:l},t.ttl),{registryInfo:u,brand:l}}catch{return{registryInfo:null,brand:null}}}async getInfoByHash(e,t){try{let r=Ce.RegistryInfo(this.config.env,e);if(t){let l=this.cache.get(r);if(l)return xe.info(`WarpRegistry (getInfoByHash): RegistryInfo found in cache: ${e}`),l}let n=d.newFromBech32(C(this.config.env)),a=this.getController(),o=a.createQuery({contract:n,function:"getInfoByHash",arguments:[g.fromHex(e)]}),s=await a.runQuery(o),[c]=a.parseQueryResponse(s),p=c?z(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(C(this.config.env)),n=this.getController(),a=n.createQuery({contract:r,function:"getUserWarps",arguments:[new we(new d(t))]}),o=await n.runQuery(a),[s]=n.parseQueryResponse(o);return s.map(z)}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(C(this.config.env)),n=this.getController(),a=n.createQuery({contract:r,function:"getUserBrands",arguments:[new we(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=Ce.Brand(this.config.env,e),n=t?this.cache.get(r):null;if(n)return xe.info(`WarpRegistry (fetchBrand): Brand found in cache: ${e}`),n;let o=f.getChainEntrypoint(this.chain,this.config.env).createNetworkProvider();try{let s=await o.getTransaction(e),c=JSON.parse(s.data.toString());return c.meta={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(C(this.config.env)),t=this.getController(),[r]=await t.query({contract:e,function:"getConfig",arguments:[]}),n=r?ot(r):null;this.registryConfig=n||{unitPrice:BigInt(0),admins:[]}}getFactory(){let e=new wr({chainID:this.chain.chainId}),t=ct.create(ye);return new yr({config:e,abi:t})}getController(){let e=f.getChainEntrypoint(this.chain,this.config.env),t=ct.create(ye);return e.createSmartContractController(t)}isCurrentUserAdmin(){return!!this.userWallet&&this.registryConfig.admins.includes(this.userWallet)}};var Q=(i,e,t)=>(r,n)=>{let a=t[r.env];return{chain:i,chainInfo:a,prefix:e,builder:()=>new L(r,a),executor:new f(r,a),results:new N(r,a),serializer:new B,registry:new H(r,a),explorer:new D(i,r),abiBuilder:()=>new I(r,a),brandBuilder:()=>new $(r,a),dataLoader:new q(r,a),registerTypes:o=>{o.registerType("token",{stringToNative:s=>s,nativeToString:s=>`token:${s}`}),o.registerType("codemeta",{stringToNative:s=>s,nativeToString:s=>`codemeta:${s}`})}}};var We={chain:k.Multiversx,identifier:"EGLD",name:"eGold",decimals:18,logoUrl:"https://vleap.ai/images/tokens/egld.svg"},pt=Q(k.Multiversx,"mvx",{mainnet:{name:k.Multiversx,displayName:"MultiversX",chainId:"1",blockTime:6e3,addressHrp:"erd",defaultApiUrl:"https://api.multiversx.com",nativeToken:We},testnet:{name:k.Multiversx,displayName:"MultiversX Testnet",chainId:"T",blockTime:6e3,addressHrp:"erd",defaultApiUrl:"https://testnet-api.multiversx.com",nativeToken:We},devnet:{name:k.Multiversx,displayName:"MultiversX Devnet",chainId:"D",blockTime:6e3,addressHrp:"erd",defaultApiUrl:"https://devnet-api.multiversx.com",nativeToken:We}});import{WarpChainName as ve}from"@vleap/warps";var xr={chain:ve.Vibechain,identifier:"VIBE",name:"VIBE",decimals:18,logoUrl:"https://vleap.ai/images/tokens/vibe.svg"},Te={name:ve.Vibechain,displayName:"VibeChain",chainId:"V",blockTime:600,addressHrp:"vibe",defaultApiUrl:"https://vibeox-api.multiversx.com",nativeToken:xr},ut=Q(ve.Vibechain,"vibe",{mainnet:Te,testnet:Te,devnet:Te});var Ws=(i,e)=>[pt(i,e),ut(i,e)],Ts=()=>[lt.Multiversx,lt.Vibechain];export{V as ExplorerUrls,vt as KnownTokens,fr as MultiversxExplorers,it as MultiversxExplorersConfig,We as NativeTokenEgld,xr as NativeTokenVibe,hr as VibechainExplorers,I as WarpMultiversxAbiBuilder,$ as WarpMultiversxBrandBuilder,L as WarpMultiversxBuilder,Aa as WarpMultiversxConstants,M as WarpMultiversxContractLoader,q as WarpMultiversxDataLoader,f as WarpMultiversxExecutor,D as WarpMultiversxExplorer,H as WarpMultiversxRegistry,N as WarpMultiversxResults,B as WarpMultiversxSerializer,ln as address_value,pn as biguint_value,un as boolean_value,fn as codemeta_value,rn as composite_value,Q as createMultiversxAdapter,Ge as esdt_value,De as findKnownTokenById,Ws as getAllMultiversxAdapters,Ts as getAllMultiversxChainNames,pt as getMultiversxAdapter,C as getMultiversxRegistryAddress,ut as getVibechainAdapter,dn as hex_value,en as list_value,hn as nothing_value,Yr as option_value,Zr as optional_value,nn as string_value,mn as token_value,sn as u16_value,on as u32_value,cn as u64_value,an as u8_value,tn 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.41",
|
|
4
4
|
"description": "",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
@@ -38,6 +38,6 @@
|
|
|
38
38
|
},
|
|
39
39
|
"dependencies": {
|
|
40
40
|
"@multiversx/sdk-core": "^15.0.1",
|
|
41
|
-
"@vleap/warps": "^3.0.0-alpha.
|
|
41
|
+
"@vleap/warps": "^3.0.0-alpha.88"
|
|
42
42
|
}
|
|
43
43
|
}
|