@vleap/warps-adapter-multiversx 0.2.0-alpha.7 → 0.2.0-alpha.70
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 +291 -0
- package/dist/index.d.ts +173 -42
- package/dist/index.js +1 -1
- package/dist/index.mjs +1 -1
- package/package.json +18 -11
- package/dist/index.d.mts +0 -160
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var G=Object.defineProperty;var nt=Object.getOwnPropertyDescriptor;var at=Object.getOwnPropertyNames;var it=Object.prototype.hasOwnProperty;var st=(i,t)=>{for(var e in t)G(i,e,{get:t[e],enumerable:!0})},ot=(i,t,e,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let a of at(t))!it.call(i,a)&&a!==e&&G(i,a,{get:()=>t[a],enumerable:!(r=nt(t,a))||r.enumerable});return i};var ct=i=>ot(G({},"__esModule",{value:!0}),i);var Bt={};st(Bt,{WarpMultiversxAbi:()=>P,WarpMultiversxBrandBuilder:()=>Z,WarpMultiversxBuilder:()=>L,WarpMultiversxConstants:()=>ut,WarpMultiversxContractLoader:()=>M,WarpMultiversxExecutor:()=>W,WarpMultiversxRegistry:()=>Q,WarpMultiversxResults:()=>_,WarpMultiversxSerializer:()=>F,address_value:()=>Ct,biguint_value:()=>wt,boolean_value:()=>Tt,codemeta_value:()=>It,composite_value:()=>dt,esdt_value:()=>X,getMultiversxAdapter:()=>xt,hex_value:()=>bt,list_value:()=>ft,nothing_value:()=>At,option_value:()=>pt,optional_value:()=>lt,string_value:()=>S,token_value:()=>Wt,u16_value:()=>mt,u32_value:()=>J,u64_value:()=>ht,u8_value:()=>yt,variadic_value:()=>gt});module.exports=ct(Bt);var ut={Egld:{Identifier:"EGLD",EsdtIdentifier:"EGLD-000000",DisplayName:"eGold",Decimals:18}};var O=require("@multiversx/sdk-core"),V=require("@vleap/warps");var y=require("@multiversx/sdk-core"),v=require("@vleap/warps");var D=require("@multiversx/sdk-core"),x=require("@vleap/warps");var K=require("@vleap/warps");var M=class{constructor(t){this.config=t}async getContract(t,e){try{let o=await W.getChainEntrypoint(e,this.config.env).createNetworkProvider().doGetGeneric(`accounts/${t}`);return{address:t,owner:o.ownerAddress,verified:o.isVerified||!1}}catch(r){return K.WarpLogger.error("WarpContractLoader: getContract error",r),null}}async getVerificationInfo(t,e){try{let o=await W.getChainEntrypoint(e,this.config.env).createNetworkProvider().doGetGeneric(`accounts/${t}/verification`);return{codeHash:o.codeHash,abi:o.source.abi}}catch(r){return K.WarpLogger.error("WarpContractLoader: getVerificationInfo error",r),null}}};var P=class{constructor(t){this.config=t;this.contractLoader=new M(this.config),this.cache=new x.WarpCache(this.config.cache?.type)}async createFromRaw(t){return JSON.parse(t)}async createFromTransaction(t){let e=await this.createFromRaw(t.data.toString());return e.meta={hash:t.hash,creator:t.sender.bech32(),createdAt:new Date(t.timestamp*1e3).toISOString()},e}async createFromTransactionHash(t,e){let r=x.WarpCacheKey.WarpAbi(this.config.env,t);if(e){let s=this.cache.get(r);if(s)return x.WarpLogger.info(`WarpAbiBuilder (createFromTransactionHash): Warp abi found in cache: ${t}`),s}let a=(0,x.getMainChainInfo)(this.config),u=W.getChainEntrypoint(a,this.config.env).createNetworkProvider();try{let s=await u.getTransaction(t),f=await this.createFromTransaction(s);return e&&e.ttl&&f&&this.cache.set(r,f,e.ttl),f}catch(s){return x.WarpLogger.error("WarpAbiBuilder: Error creating from transaction hash",s),null}}async getAbiForAction(t){if(t.abi)return await this.fetchAbi(t);if(!t.address)throw new Error("WarpActionExecutor: Address not found");let e=(0,x.getMainChainInfo)(this.config),r=await this.contractLoader.getVerificationInfo(t.address,e);if(!r)throw new Error("WarpActionExecutor: Verification info not found");return D.AbiRegistry.create(r.abi)}async fetchAbi(t){if(!t.abi)throw new Error("WarpActionExecutor: ABI not found");if(t.abi.startsWith(x.WarpConstants.IdentifierType.Hash)){let e=t.abi.split(x.WarpConstants.IdentifierParamSeparator)[1],r=await this.createFromTransactionHash(e);if(!r)throw new Error(`WarpActionExecutor: ABI not found for hash: ${t.abi}`);return D.AbiRegistry.create(r.content)}else{let r=await(await fetch(t.abi)).json();return D.AbiRegistry.create(r)}}};var U=require("@multiversx/sdk-core"),w=require("@vleap/warps"),q=require("@vleap/warps/src/helpers");var n=require("@multiversx/sdk-core"),b=require("@vleap/warps"),tt=new RegExp(`${b.WarpConstants.ArgParamsSeparator}(.*)`),F=class{constructor(){this.coreSerializer=new b.WarpSerializer}typedToString(t){if(t.hasClassOrSuperclass(n.OptionValue.ClassName))return t.isSet()?`option:${this.typedToString(t.getTypedValue())}`:"option:null";if(t.hasClassOrSuperclass(n.OptionalValue.ClassName))return t.isSet()?`optional:${this.typedToString(t.getTypedValue())}`:"optional:null";if(t.hasClassOrSuperclass(n.List.ClassName)){let e=t.getItems(),a=e.map(u=>this.typedToString(u).split(b.WarpConstants.ArgParamsSeparator)[0])[0],o=e.map(u=>this.typedToString(u).split(b.WarpConstants.ArgParamsSeparator)[1]);return`list:${a}:${o.join(",")}`}if(t.hasClassOrSuperclass(n.VariadicValue.ClassName)){let e=t.getItems(),a=e.map(u=>this.typedToString(u).split(b.WarpConstants.ArgParamsSeparator)[0])[0],o=e.map(u=>this.typedToString(u).split(b.WarpConstants.ArgParamsSeparator)[1]);return`variadic:${a}:${o.join(",")}`}if(t.hasClassOrSuperclass(n.CompositeValue.ClassName)){let e=t.getItems(),r=e.map(s=>this.typedToString(s).split(b.WarpConstants.ArgParamsSeparator)[0]),a=e.map(s=>this.typedToString(s).split(b.WarpConstants.ArgParamsSeparator)[1]),o=r.join(b.WarpConstants.ArgCompositeSeparator),u=a.join(b.WarpConstants.ArgCompositeSeparator);return`composite(${o}):${u}`}if(t.hasClassOrSuperclass(n.BigUIntValue.ClassName)||t.getType().getName()==="BigUint")return`biguint:${BigInt(t.valueOf().toFixed())}`;if(t.hasClassOrSuperclass(n.U8Value.ClassName))return`uint8:${t.valueOf().toNumber()}`;if(t.hasClassOrSuperclass(n.U16Value.ClassName))return`uint16:${t.valueOf().toNumber()}`;if(t.hasClassOrSuperclass(n.U32Value.ClassName))return`uint32:${t.valueOf().toNumber()}`;if(t.hasClassOrSuperclass(n.U64Value.ClassName))return`uint64:${BigInt(t.valueOf().toFixed())}`;if(t.hasClassOrSuperclass(n.StringValue.ClassName))return`string:${t.valueOf()}`;if(t.hasClassOrSuperclass(n.BooleanValue.ClassName))return`bool:${t.valueOf()}`;if(t.hasClassOrSuperclass(n.AddressValue.ClassName))return`address:${t.valueOf().bech32()}`;if(t.hasClassOrSuperclass(n.TokenIdentifierValue.ClassName))return`token:${t.valueOf()}`;if(t.hasClassOrSuperclass(n.BytesValue.ClassName))return`hex:${t.valueOf().toString("hex")}`;if(t.hasClassOrSuperclass(n.CodeMetadataValue.ClassName))return`codemeta:${t.valueOf().toBuffer().toString("hex")}`;if(t.getType().getName()==="EsdtTokenPayment"){let e=t.getFieldValue("token_identifier").valueOf(),r=t.getFieldValue("token_nonce").valueOf(),a=t.getFieldValue("amount").valueOf();return`esdt:${e}|${r}|${a}`}throw new Error(`WarpArgSerializer (typedToString): Unsupported input type: ${t.getClassName()}`)}typedToNative(t){let e=this.typedToString(t);return this.coreSerializer.stringToNative(e)}nativeToTyped(t,e){let r=this.coreSerializer.nativeToString(t,e);return this.stringToTyped(r)}nativeToType(t){if(t.startsWith("composite")){let e=t.match(/\(([^)]+)\)/)?.[1];return new n.CompositeType(...e.split(b.WarpConstants.ArgCompositeSeparator).map(r=>this.nativeToType(r)))}if(t==="string")return new n.StringType;if(t==="uint8")return new n.U8Type;if(t==="uint16")return new n.U16Type;if(t==="uint32")return new n.U32Type;if(t==="uint64")return new n.U64Type;if(t==="biguint")return new n.BigUIntType;if(t==="bool")return new n.BooleanType;if(t==="address")return new n.AddressType;if(t==="token")return new n.TokenIdentifierType;if(t==="hex")return new n.BytesType;if(t==="codemeta")return new n.CodeMetadataType;if(t==="esdt"||t==="nft")return new n.StructType("EsdtTokenPayment",[new n.FieldDefinition("token_identifier","",new n.TokenIdentifierType),new n.FieldDefinition("token_nonce","",new n.U64Type),new n.FieldDefinition("amount","",new n.BigUIntType)]);throw new Error(`WarpArgSerializer (nativeToType): Unsupported input type: ${t}`)}stringToTyped(t){let[e,r]=t.split(/:(.*)/,2);if(e==="null"||e===null)return new n.NothingValue;if(e==="option"){let a=this.stringToTyped(r);return a instanceof n.NothingValue?n.OptionValue.newMissingTyped(a.getType()):n.OptionValue.newProvided(a)}if(e==="optional"){let a=this.stringToTyped(r);return a instanceof n.NothingValue?n.OptionalValue.newMissing():new n.OptionalValue(a.getType(),a)}if(e==="list"){let[a,o]=r.split(tt,2),s=o.split(",").map(f=>this.stringToTyped(`${a}:${f}`));return new n.List(this.nativeToType(a),s)}if(e==="variadic"){let[a,o]=r.split(tt,2),s=o.split(",").map(f=>this.stringToTyped(`${a}:${f}`));return new n.VariadicValue(new n.VariadicType(this.nativeToType(a)),s)}if(e.startsWith("composite")){let a=e.match(/\(([^)]+)\)/)?.[1],o=r.split(b.WarpConstants.ArgCompositeSeparator),u=a.split(b.WarpConstants.ArgCompositeSeparator),s=o.map((p,g)=>this.stringToTyped(`${u[g]}:${p}`)),f=s.map(p=>p.getType());return new n.CompositeValue(new n.CompositeType(...f),s)}if(e==="string")return r?n.StringValue.fromUTF8(r):new n.NothingValue;if(e==="uint8")return r?new n.U8Value(Number(r)):new n.NothingValue;if(e==="uint16")return r?new n.U16Value(Number(r)):new n.NothingValue;if(e==="uint32")return r?new n.U32Value(Number(r)):new n.NothingValue;if(e==="uint64")return r?new n.U64Value(BigInt(r)):new n.NothingValue;if(e==="biguint")return r?new n.BigUIntValue(BigInt(r)):new n.NothingValue;if(e==="bool")return r?new n.BooleanValue(typeof r=="boolean"?r:r==="true"):new n.NothingValue;if(e==="address")return r?new n.AddressValue(n.Address.newFromBech32(r)):new n.NothingValue;if(e==="token")return r?new n.TokenIdentifierValue(r):new n.NothingValue;if(e==="hex")return r?n.BytesValue.fromHex(r):new n.NothingValue;if(e==="codemeta")return new n.CodeMetadataValue(n.CodeMetadata.newFromBytes(Uint8Array.from(Buffer.from(r,"hex"))));if(e==="esdt"){let a=r.split(b.WarpConstants.ArgCompositeSeparator);return new n.Struct(this.nativeToType("esdt"),[new n.Field(new n.TokenIdentifierValue(a[0]),"token_identifier"),new n.Field(new n.U64Value(BigInt(a[1])),"token_nonce"),new n.Field(new n.BigUIntValue(BigInt(a[2])),"amount")])}throw new Error(`WarpArgSerializer (stringToTyped): Unsupported input type: ${e}`)}typeToString(t){if(t instanceof n.OptionType)return"option:"+this.typeToString(t.getFirstTypeParameter());if(t instanceof n.OptionalType)return"optional:"+this.typeToString(t.getFirstTypeParameter());if(t instanceof n.ListType)return"list:"+this.typeToString(t.getFirstTypeParameter());if(t instanceof n.VariadicType)return"variadic:"+this.typeToString(t.getFirstTypeParameter());if(t instanceof n.StringType)return"string";if(t instanceof n.U8Type)return"uint8";if(t instanceof n.U16Type)return"uint16";if(t instanceof n.U32Type)return"uint32";if(t instanceof n.U64Type)return"uint64";if(t instanceof n.BigUIntType)return"biguint";if(t instanceof n.BooleanType)return"bool";if(t instanceof n.AddressType)return"address";if(t instanceof n.TokenIdentifierType)return"token";if(t instanceof n.BytesType)return"hex";if(t instanceof n.CodeMetadataType)return"codemeta";if(t instanceof n.StructType&&t.getClassName()==="EsdtTokenPayment")return"esdt";throw new Error(`WarpArgSerializer (typeToString): Unsupported input type: ${t.getClassName()}`)}};var _=class{constructor(t){this.config=t;this.abi=new P(t),this.serializer=new F,this.cache=new w.WarpCache(t.cache?.type)}async getTransactionExecutionResults(t,e){let[r,a]=(0,q.findWarpExecutableAction)(t),o=this.cache.get(w.WarpCacheKey.WarpExecutable(this.config.env,t.meta?.hash||"",a))??[],u=await this.extractContractResults(t,e,o),s=(0,w.getNextInfo)(this.config,t,a,u),f=(0,w.applyResultsToMessages)(t,u.results);return{success:e.status.isSuccessful(),warp:t,action:a,user:this.config.user?.wallet||null,txHash:e.hash,next:s,values:u.values,results:u.results,messages:f}}async extractContractResults(t,e,r){let[a,o]=(0,q.findWarpExecutableAction)(t),u=[],s={};if(!t.results||a.type!=="contract")return{values:u,results:s};if(!Object.values(t.results).some(I=>I.includes("out")||I.includes("event"))){for(let[I,m]of Object.entries(t.results))s[I]=m;return{values:u,results:await(0,w.evaluateResultsCommon)(t,s,o,r)}}let p=await this.abi.getAbiForAction(a),g=new U.TransactionEventsParser({abi:p}),T=new U.SmartContractTransactionsOutcomeParser({abi:p}).parseExecute({transactionOnNetwork:e,function:a.func||void 0});for(let[I,m]of Object.entries(t.results)){if(m.startsWith(w.WarpConstants.Transform.Prefix))continue;if(m.startsWith("input.")){s[I]=m;continue}let B=(0,w.parseResultsOutIndex)(m);if(B!==null&&B!==o){s[I]=null;continue}let[A,R,E]=m.split(".");if(A==="event"){if(!R||isNaN(Number(E)))continue;let z=Number(E),C=(0,U.findEventsByFirstTopic)(e,R),$=g.parseEvents({events:C})[0],H=Object.values($)[z]||null;u.push(H),s[I]=H&&H.valueOf()}else if(A==="out"||A.startsWith("out[")){if(!R)continue;let z=Number(R),C=T.values[z-1]||null;E&&(C=C[E]||null),C&&typeof C=="object"&&(C="toFixed"in C?C.toFixed():C.valueOf()),u.push(C),s[I]=C&&C.valueOf()}else s[I]=m}return{values:u,results:await(0,w.evaluateResultsCommon)(t,s,o,r)}}async extractQueryResults(t,e,r,a){let o=e.map(p=>this.serializer.typedToString(p)),u=e.map(p=>this.serializer.typedToNative(p)[1]),s={};if(!t.results)return{values:o,results:s};let f=p=>{let g=p.split(".").slice(1).map(T=>parseInt(T)-1);if(g.length===0)return;let d=u[g[0]];for(let T=1;T<g.length;T++){if(d==null)return;d=d[g[T]]}return d};for(let[p,g]of Object.entries(t.results)){if(g.startsWith(w.WarpConstants.Transform.Prefix))continue;let d=(0,w.parseResultsOutIndex)(g);if(d!==null&&d!==r){s[p]=null;continue}g.startsWith("out.")||g==="out"||g.startsWith("out[")?s[p]=f(g)||null:s[p]=g}return{values:o,results:await(0,w.evaluateResultsCommon)(t,s,r,a)}}async resolveWarpResultsRecursively(t){let e=t.warp,r=t.entryActionIndex,a=t.executor,o=t.inputs,u=t.meta,s=new Map,f=new Set,p=this;async function g(m,B=[]){if(s.has(m))return s.get(m);if(f.has(m))throw new Error(`Circular dependency detected at action ${m}`);f.add(m);let A=e.actions[m-1];if(!A)throw new Error(`Action ${m} not found`);let R;if(A.type==="query")R=await a.executeQuery(e,m,B);else if(A.type==="collect")R=await a.executeCollect(e,m,B,u);else throw new Error(`Unsupported or interactive action type: ${A.type}`);if(s.set(m,R),e.results)for(let E of Object.values(e.results)){let C=String(E).match(/^out\[(\d+)\]/);if(C){let $=parseInt(C[1],10);$!==m&&!s.has($)&&await g($)}}return f.delete(m),R}await g(r,o);let d={};for(let m of s.values())for(let[B,A]of Object.entries(m.results))A!==null?d[B]=A:B in d||(d[B]=null);let T=await(0,w.evaluateResultsCommon)(e,d,r,o);return{...s.get(r),action:r,results:T}}};var c=require("@multiversx/sdk-core"),pt=(i,t)=>i?c.OptionValue.newProvided(i):t?c.OptionValue.newMissingTyped(t):c.OptionValue.newMissing(),lt=(i,t)=>i?new c.OptionalValue(i.getType(),i):t?new c.OptionalValue(t):c.OptionalValue.newMissing(),ft=i=>{if(i.length===0)throw new Error("Cannot create a list from an empty array");let t=i[0].getType();return new c.List(t,i)},gt=i=>c.VariadicValue.fromItems(...i),dt=i=>{let t=i.map(e=>e.getType());return new c.CompositeValue(new c.CompositeType(...t),i)},S=i=>c.StringValue.fromUTF8(i),yt=i=>new c.U8Value(i),mt=i=>new c.U16Value(i),J=i=>new c.U32Value(i),ht=i=>new c.U64Value(i),wt=i=>new c.BigUIntValue(BigInt(i)),Tt=i=>new c.BooleanValue(i),Ct=i=>new c.AddressValue(c.Address.newFromBech32(i)),Wt=i=>new c.TokenIdentifierValue(i),bt=i=>c.BytesValue.fromHex(i),X=i=>new c.Struct(new c.StructType("EsdtTokenPayment",[new c.FieldDefinition("token_identifier","",new c.TokenIdentifierType),new c.FieldDefinition("token_nonce","",new c.U64Type),new c.FieldDefinition("amount","",new c.BigUIntType)]),[new c.Field(new c.TokenIdentifierValue(i.token.identifier),"token_identifier"),new c.Field(new c.U64Value(BigInt(i.token.nonce)),"token_nonce"),new c.Field(new c.BigUIntValue(BigInt(i.amount)),"amount")]),It=i=>new c.CodeMetadataValue(c.CodeMetadata.newFromBytes(Uint8Array.from(Buffer.from(i,"hex")))),At=()=>new c.NothingValue;var W=class i{constructor(t){this.config=t;this.serializer=new F,this.abi=new P(this.config),this.results=new _(this.config)}async createTransaction(t){let e=(0,v.getWarpActionByIndex)(t.warp,t.action),r=null;if(e.type==="transfer")r=await this.createTransferTransaction(t);else if(e.type==="contract")r=await this.createContractCallTransaction(t);else{if(e.type==="query")throw new Error("WarpMultiversxExecutor: Invalid action type for createTransactionForExecute; Use executeQuery instead");if(e.type==="collect")throw new Error("WarpMultiversxExecutor: Invalid action type for createTransactionForExecute; Use executeCollect instead")}if(!r)throw new Error(`WarpMultiversxExecutor: Invalid action type (${e.type})`);return r}async createTransferTransaction(t){if(!this.config.user?.wallet)throw new Error("WarpMultiversxExecutor: createTransfer - user address not set");let e=y.Address.newFromBech32(this.config.user.wallet),r=new y.TransactionsFactoryConfig({chainID:t.chain.chainId}),a=t.data?Buffer.from(this.serializer.stringToTyped(t.data).valueOf()):null;return new y.TransferTransactionsFactory({config:r}).createTransactionForTransfer(e,{receiver:y.Address.newFromBech32(t.destination),nativeAmount:t.value,data:a?new Uint8Array(a):void 0})}async createContractCallTransaction(t){if(!this.config.user?.wallet)throw new Error("WarpMultiversxExecutor: createContractCall - user address not set");let e=(0,v.getWarpActionByIndex)(t.warp,t.action),r=y.Address.newFromBech32(this.config.user.wallet),a=t.args.map(u=>this.serializer.stringToTyped(u)),o=new y.TransactionsFactoryConfig({chainID:t.chain.chainId});return new y.SmartContractTransactionsFactory({config:o}).createTransactionForExecute(r,{contract:y.Address.newFromBech32(t.destination),function:"func"in e&&e.func||"",gasLimit:"gasLimit"in e?BigInt(e.gasLimit||0):0n,arguments:a,nativeTransferAmount:t.value})}async executeQuery(t){let e=(0,v.getWarpActionByIndex)(t.warp,t.action);if(e.type!=="query")throw new Error(`WarpMultiversxExecutor: Invalid action type for executeQuery: ${e.type}`);let r=await this.abi.getAbiForAction(e),a=t.args.map(E=>this.serializer.stringToTyped(E)),o=i.getChainEntrypoint(t.chain,this.config.env),u=y.Address.newFromBech32(t.destination),s=o.createSmartContractController(r),f=s.createQuery({contract:u,function:e.func||"",arguments:a}),p=await s.runQuery(f),g=p.returnCode==="ok",d=new y.ArgSerializer,T=r.getEndpoint(p.function||e.func||""),I=(p.returnDataParts||[]).map(E=>Buffer.from(E)),m=d.buffersToValues(I,T.output),{values:B,results:A}=await this.results.extractQueryResults(t.warp,m,t.action,t.resolvedInputs),R=(0,v.getNextInfo)(this.config,t.warp,t.action,A);return{success:g,warp:t.warp,action:t.action,user:this.config.user?.wallet||null,txHash:null,next:R,values:B,results:A,messages:(0,v.applyResultsToMessages)(t.warp,A)}}async preprocessInput(t,e,r,a){if(r==="esdt"){let[o,u,s,f]=a.split(v.WarpConstants.ArgCompositeSeparator);if(f)return e;let p=new y.Token({identifier:o,nonce:BigInt(u)});if(!new y.TokenComputer().isFungible(p))return e;let T=(0,v.findKnownTokenById)(o)?.decimals;if(T||(T=(await(await fetch(`${t.apiUrl}/tokens/${o}`)).json()).decimals),!T)throw new Error(`WarpActionExecutor: Decimals not found for token ${o}`);let I=X(new y.TokenTransfer({token:p,amount:(0,v.shiftBigintBy)(s,T)}));return this.serializer.typedToString(I)+v.WarpConstants.ArgCompositeSeparator+T}return e}static getChainEntrypoint(t,e){let r="warp-sdk",a="api";return e==="devnet"?new y.DevnetEntrypoint(t.apiUrl,a,r):e==="testnet"?new y.TestnetEntrypoint(t.apiUrl,a,r):new y.MainnetEntrypoint(t.apiUrl,a,r)}};var L=class{constructor(t){this.config=t,this.cache=new V.WarpCache(t.cache?.type),this.core=new V.WarpBuilder(t)}createInscriptionTransaction(t){if(!this.config.user?.wallet)throw new Error("WarpBuilder: user address not set");let e=(0,V.getMainChainInfo)(this.config),r=new O.TransactionsFactoryConfig({chainID:e.chainId}),a=new O.TransferTransactionsFactory({config:r}),o=O.Address.newFromBech32(this.config.user.wallet),u=JSON.stringify(t),s=a.createTransactionForTransfer(o,{receiver:O.Address.newFromBech32(this.config.user.wallet),nativeAmount:BigInt(0),data:Uint8Array.from(Buffer.from(u))});return s.gasLimit=s.gasLimit+BigInt(2e6),s}async createFromTransaction(t,e=!1){let r=await this.core.createFromRaw(t.data.toString(),e);return r.meta={hash:t.hash,creator:t.sender.toBech32(),createdAt:new Date(t.timestamp*1e3).toISOString()},r}async createFromTransactionHash(t,e){let r=V.WarpCacheKey.Warp(this.config.env,t);if(e){let s=this.cache.get(r);if(s)return V.WarpLogger.info(`WarpBuilder (createFromTransactionHash): Warp found in cache: ${t}`),s}let a=(0,V.getMainChainInfo)(this.config),u=W.getChainEntrypoint(a,this.config.env).createNetworkProvider();try{let s=await u.getTransaction(t),f=await this.createFromTransaction(s);return e&&e.ttl&&f&&this.cache.set(r,f,e.ttl),f}catch(s){return V.WarpLogger.error("WarpBuilder: Error creating from transaction hash",s),null}}};var l=require("@multiversx/sdk-core"),h=require("@vleap/warps");var Y={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 j=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}),et=i=>({unitPrice:BigInt(i.unit_price.toString()),admins:i.admins.map(t=>t.toBech32())});var Q=class{constructor(t){this.config=t,this.cache=new h.WarpCache(t.cache?.type),this.registryConfig={unitPrice:BigInt(0),admins:[]}}async init(){await this.loadRegistryConfigs()}createWarpRegisterTransaction(t,e,r){if(this.registryConfig.unitPrice===BigInt(0))throw new Error("WarpRegistry: config not loaded. forgot to call init()?");if(!this.config.user?.wallet)throw new Error("WarpRegistry: user address not set");let a=l.Address.newFromBech32(this.config.user.wallet),o=()=>this.isCurrentUserAdmin()?BigInt(0):e&&r?this.registryConfig.unitPrice*BigInt(3):e?this.registryConfig.unitPrice*BigInt(2):this.registryConfig.unitPrice,u=()=>e&&r?[l.BytesValue.fromHex(t),l.BytesValue.fromUTF8(e),l.BytesValue.fromHex(r)]:e?[l.BytesValue.fromHex(t),l.BytesValue.fromUTF8(e)]:[l.BytesValue.fromHex(t)];return this.getFactory().createTransactionForExecute(a,{contract:this.getRegistryContractAddress(),function:"registerWarp",gasLimit:BigInt(1e7),nativeTransferAmount:o(),arguments:u()})}createWarpUnregisterTransaction(t){if(!this.config.user?.wallet)throw new Error("WarpRegistry: user address not set");let e=l.Address.newFromBech32(this.config.user.wallet);return this.getFactory().createTransactionForExecute(e,{contract:this.getRegistryContractAddress(),function:"unregisterWarp",gasLimit:BigInt(1e7),arguments:[l.BytesValue.fromHex(t)]})}createWarpUpgradeTransaction(t,e){if(this.registryConfig.unitPrice===BigInt(0))throw new Error("WarpRegistry: config not loaded. forgot to call init()?");if(!this.config.user?.wallet)throw new Error("WarpRegistry: user address not set");let r=l.Address.newFromBech32(this.config.user.wallet);return this.getFactory().createTransactionForExecute(r,{contract:this.getRegistryContractAddress(),function:"upgradeWarp",gasLimit:BigInt(1e7),nativeTransferAmount:this.isCurrentUserAdmin()?void 0:this.registryConfig.unitPrice,arguments:[l.BytesValue.fromUTF8(t),l.BytesValue.fromHex(e)]})}createWarpAliasSetTransaction(t,e){if(!this.config.user?.wallet)throw new Error("WarpRegistry: user address not set");let r=l.Address.newFromBech32(this.config.user.wallet);return this.getFactory().createTransactionForExecute(r,{contract:this.getRegistryContractAddress(),function:"setWarpAlias",gasLimit:BigInt(1e7),nativeTransferAmount:this.isCurrentUserAdmin()?void 0:this.registryConfig.unitPrice,arguments:[l.BytesValue.fromHex(t),l.BytesValue.fromUTF8(e)]})}createWarpVerifyTransaction(t){if(!this.config.user?.wallet)throw new Error("WarpRegistry: user address not set");let e=l.Address.newFromBech32(this.config.user.wallet);return this.getFactory().createTransactionForExecute(e,{contract:this.getRegistryContractAddress(),function:"verifyWarp",gasLimit:BigInt(1e7),arguments:[l.BytesValue.fromHex(t)]})}createWarpTransferOwnershipTransaction(t,e){if(!this.config.user?.wallet)throw new Error("WarpRegistry: user address not set");let r=l.Address.newFromBech32(this.config.user.wallet);return this.getFactory().createTransactionForExecute(r,{contract:this.getRegistryContractAddress(),function:"transferOwnership",gasLimit:BigInt(1e7),arguments:[l.BytesValue.fromHex(t),new l.AddressValue(new l.Address(e))]})}createBrandRegisterTransaction(t){if(this.registryConfig.unitPrice===BigInt(0))throw new Error("WarpRegistry: config not loaded. forgot to call init()?");if(!this.config.user?.wallet)throw new Error("WarpRegistry: user address not set");let e=l.Address.newFromBech32(this.config.user.wallet);return this.getFactory().createTransactionForExecute(e,{contract:this.getRegistryContractAddress(),function:"registerBrand",gasLimit:BigInt(1e7),nativeTransferAmount:this.isCurrentUserAdmin()?void 0:this.registryConfig.unitPrice,arguments:[l.BytesValue.fromHex(t)]})}createWarpBrandingTransaction(t,e){if(!this.config.user?.wallet)throw new Error("WarpRegistry: user address not set");let r=l.Address.newFromBech32(this.config.user.wallet);return this.getFactory().createTransactionForExecute(r,{contract:this.getRegistryContractAddress(),function:"brandWarp",gasLimit:BigInt(1e7),nativeTransferAmount:this.isCurrentUserAdmin()?void 0:this.registryConfig.unitPrice,arguments:[l.BytesValue.fromHex(t),l.BytesValue.fromHex(e)]})}async getInfoByAlias(t,e){try{let r=h.WarpCacheKey.RegistryInfo(this.config.env,t),a=e?this.cache.get(r):null;if(a)return h.WarpLogger.info(`WarpRegistry (getInfoByAlias): RegistryInfo found in cache: ${t}`),a;let o=this.getRegistryContractAddress(),u=this.getController(),s=u.createQuery({contract:o,function:"getInfoByAlias",arguments:[l.BytesValue.fromUTF8(t)]}),f=await u.runQuery(s),[p]=u.parseQueryResponse(f),g=p?j(p):null,d=g?.brand?await this.fetchBrand(g.brand):null;return e&&e.ttl&&this.cache.set(r,{registryInfo:g,brand:d},e.ttl),{registryInfo:g,brand:d}}catch{return{registryInfo:null,brand:null}}}async getInfoByHash(t,e){try{let r=h.WarpCacheKey.RegistryInfo(this.config.env,t);if(e){let d=this.cache.get(r);if(d)return h.WarpLogger.info(`WarpRegistry (getInfoByHash): RegistryInfo found in cache: ${t}`),d}let a=this.getRegistryContractAddress(),o=this.getController(),u=o.createQuery({contract:a,function:"getInfoByHash",arguments:[l.BytesValue.fromHex(t)]}),s=await o.runQuery(u),[f]=o.parseQueryResponse(s),p=f?j(f):null,g=p?.brand?await this.fetchBrand(p.brand):null;return e&&e.ttl&&this.cache.set(r,{registryInfo:p,brand:g},e.ttl),{registryInfo:p,brand:g}}catch{return{registryInfo:null,brand:null}}}async getUserWarpRegistryInfos(t){try{let e=t||this.config.user?.wallet;if(!e)throw new Error("WarpRegistry: user address not set");let r=this.getRegistryContractAddress(),a=this.getController(),o=a.createQuery({contract:r,function:"getUserWarps",arguments:[new l.AddressValue(new l.Address(e))]}),u=await a.runQuery(o),[s]=a.parseQueryResponse(u);return s.map(j)}catch{return[]}}async getUserBrands(t){try{let e=t||this.config.user?.wallet;if(!e)throw new Error("WarpRegistry: user address not set");let r=this.getRegistryContractAddress(),a=this.getController(),o=a.createQuery({contract:r,function:"getUserBrands",arguments:[new l.AddressValue(new l.Address(e))]}),u=await a.runQuery(o),[s]=a.parseQueryResponse(u),f=s.map(d=>d.toString("hex")),p={ttl:365*24*60*60};return(await Promise.all(f.map(d=>this.fetchBrand(d,p)))).filter(d=>d!==null)}catch{return[]}}async getChainInfos(t){let e=h.WarpCacheKey.ChainInfos(this.config.env);if(t&&t.ttl){let p=this.cache.get(e);if(p)return h.WarpLogger.info("WarpRegistry (getChainInfos): ChainInfos found in cache"),p}let r=this.getRegistryContractAddress(),a=this.getController(),o=a.createQuery({contract:r,function:"getChains",arguments:[]}),u=await a.runQuery(o),[s]=a.parseQueryResponse(u),f=s.map(h.toTypedChainInfo);if(t&&t.ttl){for(let p of f)this.cache.set(h.WarpCacheKey.ChainInfo(this.config.env,p.chain),p,t.ttl);this.cache.set(e,f,t.ttl)}return f}async getChainInfo(t,e){try{let r=h.WarpCacheKey.ChainInfo(this.config.env,t),a=e?this.cache.get(r):null;if(a)return h.WarpLogger.info(`WarpRegistry (getChainInfo): ChainInfo found in cache: ${t}`),a;let o=this.getRegistryContractAddress(),u=this.getController(),s=u.createQuery({contract:o,function:"getChain",arguments:[l.BytesValue.fromUTF8(t)]}),f=await u.runQuery(s),[p]=u.parseQueryResponse(f),g=p?(0,h.toTypedChainInfo)(p):null;return e&&e.ttl&&g&&this.cache.set(r,g,e.ttl),g}catch{return null}}async setChain(t){if(!this.config.user?.wallet)throw new Error("WarpRegistry: user address not set");let e=l.Address.newFromBech32(this.config.user.wallet);return this.getFactory().createTransactionForExecute(e,{contract:this.getRegistryContractAddress(),function:"setChain",gasLimit:BigInt(1e7),arguments:[S(t.name),S(t.displayName),S(t.chainId),J(t.blockTime),S(t.addressHrp),S(t.apiUrl),S(t.explorerUrl),S(t.nativeToken)]})}async removeChain(t){if(!this.config.user?.wallet)throw new Error("WarpRegistry: user address not set");let e=l.Address.newFromBech32(this.config.user.wallet);return this.getFactory().createTransactionForExecute(e,{contract:this.getRegistryContractAddress(),function:"removeChain",gasLimit:BigInt(1e7),arguments:[S(t)]})}async fetchBrand(t,e){let r=h.WarpCacheKey.Brand(this.config.env,t),a=e?this.cache.get(r):null;if(a)return h.WarpLogger.info(`WarpRegistry (fetchBrand): Brand found in cache: ${t}`),a;let o=(0,h.getMainChainInfo)(this.config),s=W.getChainEntrypoint(o,this.config.env).createNetworkProvider();try{let f=await s.getTransaction(t),p=JSON.parse(f.data.toString());return p.meta={hash:f.hash,creator:f.sender.bech32(),createdAt:new Date(f.timestamp*1e3).toISOString()},e&&e.ttl&&this.cache.set(r,p,e.ttl),p}catch{return null}}getRegistryContractAddress(){return l.Address.newFromBech32(this.config.registry?.contract||h.WarpConfig.Registry.Contract(this.config.env))}async loadRegistryConfigs(){let t=this.getRegistryContractAddress(),e=this.getController(),[r]=await e.query({contract:t,function:"getConfig",arguments:[]}),a=r?et(r):null;this.registryConfig=a||{unitPrice:BigInt(0),admins:[]}}getFactory(){let t=(0,h.getMainChainInfo)(this.config),e=new l.TransactionsFactoryConfig({chainID:t.chainId}),r=l.AbiRegistry.create(Y);return new l.SmartContractTransactionsFactory({config:e,abi:r})}getController(){let t=(0,h.getMainChainInfo)(this.config),e=W.getChainEntrypoint(t,this.config.env),r=l.AbiRegistry.create(Y);return e.createSmartContractController(r)}isCurrentUserAdmin(){return!!this.config.user?.wallet&&this.registryConfig.admins.includes(this.config.user.wallet)}};var xt=i=>({chain:"multiversx",builder:new L(i),executor:new W(i),results:new _(i),serializer:new F,registry:new Q(i)});var k=require("@multiversx/sdk-core"),N=require("@vleap/warps"),rt=require("buffer");var Z=class{constructor(t){this.config=t,this.core=new N.WarpBrandBuilder(t)}createInscriptionTransaction(t){if(!this.config.user?.wallet)throw new Error("BrandBuilder: user address not set");let e=(0,N.getMainChainInfo)(this.config),r=new k.TransactionsFactoryConfig({chainID:e.chainId}),a=new k.TransferTransactionsFactory({config:r}),o=k.Address.newFromBech32(this.config.user.wallet),u=JSON.stringify(t);return a.createTransactionForNativeTokenTransfer(o,{receiver:k.Address.newFromBech32(this.config.user.wallet),nativeAmount:BigInt(0),data:Uint8Array.from(rt.Buffer.from(u))})}async createFromTransaction(t,e=!1){return await this.core.createFromRaw(t.data.toString(),e)}async createFromTransactionHash(t){let e=(0,N.getMainChainInfo)(this.config),a=W.getChainEntrypoint(e,this.config.env).createNetworkProvider();try{let o=await a.getTransaction(t);return this.createFromTransaction(o)}catch(o){return N.WarpLogger.error("BrandBuilder: Error creating from transaction hash",o),null}}};0&&(module.exports={WarpMultiversxAbi,WarpMultiversxBrandBuilder,WarpMultiversxBuilder,WarpMultiversxConstants,WarpMultiversxContractLoader,WarpMultiversxExecutor,WarpMultiversxRegistry,WarpMultiversxResults,WarpMultiversxSerializer,address_value,biguint_value,boolean_value,codemeta_value,composite_value,esdt_value,getMultiversxAdapter,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 ge=Object.defineProperty;var $e=Object.getOwnPropertyDescriptor;var ze=Object.getOwnPropertyNames;var Ke=Object.prototype.hasOwnProperty;var qe=(i,e)=>{for(var t in e)ge(i,t,{get:e[t],enumerable:!0})},Qe=(i,e,t,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let a of ze(e))!Ke.call(i,a)&&a!==t&&ge(i,a,{get:()=>e[a],enumerable:!(r=$e(e,a))||r.enumerable});return i};var je=i=>Qe(ge({},"__esModule",{value:!0}),i);var Et={};qe(Et,{ExplorerUrls:()=>G,KnownTokens:()=>ye,MultiversxExplorers:()=>Oe,MultiversxExplorersConfig:()=>Te,NativeTokenEgld:()=>de,NativeTokenVibe:()=>Ge,VibechainExplorers:()=>Le,WarpMultiversxAbiBuilder:()=>M,WarpMultiversxBrandBuilder:()=>ne,WarpMultiversxBuilder:()=>ae,WarpMultiversxConstants:()=>Je,WarpMultiversxContractLoader:()=>re,WarpMultiversxDataLoader:()=>se,WarpMultiversxExecutor:()=>ie,WarpMultiversxExplorer:()=>oe,WarpMultiversxInputTypes:()=>v,WarpMultiversxRegistry:()=>pe,WarpMultiversxResults:()=>K,WarpMultiversxSerializer:()=>O,WarpMultiversxWallet:()=>le,address_value:()=>Tt,asset_value:()=>Ct,biguint_value:()=>yt,boolean_value:()=>vt,codemeta:()=>at,codemeta_value:()=>xt,composite_value:()=>ut,createMultiversxAdapter:()=>ue,findKnownTokenById:()=>ve,getAllMultiversxAdapters:()=>tt,getAllMultiversxChainNames:()=>rt,getKnownTokensForChain:()=>Xe,getMultiversxAdapter:()=>Ce,getMultiversxEntrypoint:()=>w,getMultiversxRegistryAddress:()=>S,getNormalizedTokenIdentifier:()=>te,getVibechainAdapter:()=>Ae,hex_value:()=>Wt,isNativeToken:()=>H,list:()=>it,list_value:()=>pt,nothing_value:()=>At,option_value:()=>ot,optional:()=>st,optional_value:()=>ct,string_value:()=>mt,toTypedConfigInfo:()=>We,toTypedRegistryInfo:()=>ce,token:()=>nt,token_value:()=>wt,u16_value:()=>ht,u32_value:()=>gt,u64_value:()=>ft,u8_value:()=>dt,variadic_value:()=>lt});module.exports=je(Et);var Ee=require("@vleap/warps");var Y=require("@vleap/warps");var _e=require("@vleap/warps");var R=require("@multiversx/sdk-core"),B=require("@vleap/warps");var Q=require("@multiversx/sdk-core"),be=require("@vleap/warps"),H=i=>!i.includes("-"),te=i=>H(i)?`${i}-000000`:i,w=(i,e,t)=>{let r="warp-sdk",s=t?(0,be.getProviderConfig)(t,i.name,e,i.defaultApiUrl):{url:i.defaultApiUrl},o=s.url,c={headers:s.headers};return e==="devnet"?new Q.DevnetEntrypoint({url:o,kind:"api",clientName:r,networkProviderConfig:c}):e==="testnet"?new Q.TestnetEntrypoint({url:o,kind:"api",clientName:r,networkProviderConfig:c}):new Q.MainnetEntrypoint({url:o,kind:"api",clientName:r,networkProviderConfig:c})};var fe=require("@vleap/warps");var re=class{constructor(e){this.config=e}async getContract(e,t){try{let s=await w(t,this.config.env,this.config).createNetworkProvider().doGetGeneric(`accounts/${e}`);return{address:e,owner:s.ownerAddress,verified:s.isVerified||!1}}catch(r){return fe.WarpLogger.error("WarpContractLoader: getContract error",r),null}}async getVerificationInfo(e,t){try{let s=await w(t,this.config.env,this.config).createNetworkProvider().doGetGeneric(`accounts/${e}/verification`);return{codeHash:s.codeHash,abi:s.source.abi}}catch(r){return fe.WarpLogger.error("WarpContractLoader: getVerificationInfo error",r),null}}};var M=class{constructor(e,t){this.config=e;this.chain=t;this.contractLoader=new re(this.config),this.cache=new B.WarpCache(this.config.cache?.type)}async createInscriptionTransaction(e){let t=(0,B.getWarpWalletAddressFromConfig)(this.config,this.chain.name);if(!t)throw new Error("WarpBuilder: user address not set");let r=new R.TransactionsFactoryConfig({chainID:this.chain.chainId}),a=new R.TransferTransactionsFactory({config:r}),s=R.Address.newFromBech32(t),o={protocol:(0,B.getLatestProtocolIdentifier)("abi"),content:e},c=JSON.stringify(o),p=await a.createTransactionForTransfer(s,{receiver:s,nativeAmount:BigInt(0),data:Uint8Array.from(Buffer.from(c))});return p.gasLimit=p.gasLimit+BigInt(2e6),p}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=B.WarpCacheKey.WarpAbi(this.config.env,e);if(t){let o=this.cache.get(r);if(o)return B.WarpLogger.info(`WarpAbiBuilder (createFromTransactionHash): Warp abi found in cache: ${e}`),o}let s=w(this.chain,this.config.env,this.config).createNetworkProvider();try{let o=await s.getTransaction(e),c=await this.createFromTransaction(o);return t&&t.ttl&&c&&this.cache.set(r,c,t.ttl),c}catch(o){return B.WarpLogger.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 R.AbiRegistry.create(t.abi)}async fetchAbi(e){if(!e.abi)throw new Error("WarpActionExecutor: ABI not found");if(e.abi.startsWith(B.WarpConstants.IdentifierType.Hash)){let t=e.abi.split(B.WarpConstants.ArgParamsSeparator)[1],r=await this.createFromTransactionHash(t);if(!r)throw new Error(`WarpActionExecutor: ABI not found for hash: ${e.abi}`);return R.AbiRegistry.create(r.content)}else{let r=await(await fetch(e.abi)).json();return R.AbiRegistry.create(r)}}};var $=require("@multiversx/sdk-core"),j=require("@vleap/warps"),Se=require("buffer");var ne=class{constructor(e,t){this.config=e;this.chain=t;this.core=new j.WarpBrandBuilder(e)}async createInscriptionTransaction(e){let t=(0,j.getWarpWalletAddressFromConfig)(this.config,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),o=JSON.stringify(e);return await a.createTransactionForNativeTokenTransfer(s,{receiver:$.Address.newFromBech32(t),nativeAmount:BigInt(0),data:Uint8Array.from(Se.Buffer.from(o))})}async createFromTransaction(e,t=!1){let r=await this.core.createFromRaw(e.data.toString(),t);return r.meta={chain:this.chain.name,hash:e.hash,creator:e.sender.toBech32(),createdAt:new Date(e.timestamp*1e3).toISOString()},r}async createFromTransactionHash(e){let r=w(this.chain,this.config.env,this.config).createNetworkProvider();try{let a=await r.getTransaction(e);return this.createFromTransaction(a)}catch(a){return j.WarpLogger.error("BrandBuilder: Error creating from transaction hash",a),null}}};var z=require("@multiversx/sdk-core"),V=require("@vleap/warps");var ae=class extends V.WarpBuilder{constructor(t,r){super(t);this.config=t;this.chain=r;this.cache=new V.WarpCache(t.cache?.type),this.core=new V.WarpBuilder(t)}async createInscriptionTransaction(t){let r=(0,V.getWarpWalletAddressFromConfig)(this.config,this.chain.name);if(!r)throw new Error("WarpBuilder: user address not set");let a=new z.TransactionsFactoryConfig({chainID:this.chain.chainId}),s=new z.TransferTransactionsFactory({config:a}),o=z.Address.newFromBech32(r),c=JSON.stringify(t),p=await s.createTransactionForTransfer(o,{receiver:z.Address.newFromBech32(r),nativeAmount:BigInt(0),data:Uint8Array.from(Buffer.from(c))});return p.gasLimit=p.gasLimit+BigInt(2e6),p}async createFromTransaction(t,r=!1){let a=await this.core.createFromRaw(t.data.toString(),r);return a.meta={chain:this.chain.name,hash:t.hash,creator:t.sender.toBech32(),createdAt:new Date(t.timestamp*1e3).toISOString()},a}async createFromTransactionHash(t,r){let a=V.WarpCacheKey.Warp(this.config.env,t);if(r){let c=this.cache.get(a);if(c)return V.WarpLogger.info(`WarpBuilder (createFromTransactionHash): Warp found in cache: ${t}`),c}let o=w(this.chain,this.config.env,this.config).createNetworkProvider();try{let c=await o.getTransaction(t),p=await this.createFromTransaction(c);return r&&r.ttl&&p&&this.cache.set(a,p,r.ttl),p}catch(c){return V.WarpLogger.error("WarpBuilder: Error creating from transaction hash",c),null}}};var _=require("@multiversx/sdk-core"),X=require("@vleap/warps");var Be=require("@vleap/warps"),Ie=Be.WarpChainName.Multiversx,Pe=[{chain:Ie,identifier:"EGLD",name:"eGold",symbol:"EGLD",decimals:18,logoUrl:"https://tools.multiversx.com/assets-cdn/tokens/EGLD-000000/icon.png"},{chain:Ie,identifier:"EGLD-000000",name:"eGold",symbol:"EGLD",decimals:18,logoUrl:"https://tools.multiversx.com/assets-cdn/tokens/EGLD-000000/icon.png"}];var Ne=require("@vleap/warps"),b=Ne.WarpChainName.Multiversx,Ve=[{chain:b,identifier:"EGLD",name:"eGold",symbol:"EGLD",decimals:18,logoUrl:"https://tools.multiversx.com/assets-cdn/tokens/EGLD-000000/icon.png"},{chain:b,identifier:"EGLD-000000",name:"eGold",symbol:"EGLD",decimals:18,logoUrl:"https://tools.multiversx.com/assets-cdn/tokens/EGLD-000000/icon.png"},{chain:b,identifier:"SEGLD-3ad2d0",name:"StakedEGLD",symbol:"SEGLD",decimals:18,logoUrl:"https://tools.multiversx.com/assets-cdn/tokens/SEGLD-3ad2d0/icon.png"},{chain:b,identifier:"HSEGLD-c13a4e",name:"HatomSEGLD",symbol:"HSEGLD",decimals:8,logoUrl:"https://tools.multiversx.com/assets-cdn/tokens/HSEGLD-c13a4e/icon.png"},{chain:b,identifier:"UTK-2f80e9",name:"xMoney UTK",symbol:"UTK",decimals:18,logoUrl:"https://tools.multiversx.com/assets-cdn/tokens/UTK-2f80e9/icon.png"},{chain:b,identifier:"USDC-c76f1f",name:"WrappedUSDC",symbol:"USDC",decimals:6,logoUrl:"https://tools.multiversx.com/assets-cdn/tokens/USDC-c76f1f/icon.png"},{chain:b,identifier:"WEGLD-bd4d79",name:"WrappedEGLD",symbol:"WEGLD",decimals:18,logoUrl:"https://tools.multiversx.com/assets-cdn/tokens/WEGLD-bd4d79/icon.png"},{chain:b,identifier:"HTM-f51d55",name:"Hatom",symbol:"HTM",decimals:18,logoUrl:"https://tools.multiversx.com/assets-cdn/tokens/HTM-f51d55/icon.png"},{chain:b,identifier:"MEX-455c57",name:"MEX",symbol:"MEX",decimals:18,logoUrl:"https://tools.multiversx.com/assets-cdn/tokens/MEX-455c57/icon.png"},{chain:b,identifier:"WTAO-4f5363",name:"WrappedTAO",symbol:"WTAO",decimals:9,logoUrl:"https://tools.multiversx.com/assets-cdn/tokens/WTAO-4f5363/icon.png"},{chain:b,identifier:"HEGLD-d61095",name:"HatomEGLD",symbol:"HEGLD",decimals:8,logoUrl:"https://tools.multiversx.com/assets-cdn/tokens/HEGLD-d61095/icon.png"},{chain:b,identifier:"WBTC-5349b3",name:"WrappedBTC",symbol:"WBTC",decimals:8,logoUrl:"https://tools.multiversx.com/assets-cdn/tokens/WBTC-5349b3/icon.png"},{chain:b,identifier:"WETH-b4ca29",name:"WrappedETH",symbol:"WETH",decimals:18,logoUrl:"https://tools.multiversx.com/assets-cdn/tokens/WETH-b4ca29/icon.png"},{chain:b,identifier:"USH-111e09",name:"HatomUSD",symbol:"USH",decimals:18,logoUrl:"https://tools.multiversx.com/assets-cdn/tokens/USH-111e09/icon.png"},{chain:b,identifier:"USDT-f8c08c",name:"WrappedUSDT",symbol:"USDT",decimals:6,logoUrl:"https://tools.multiversx.com/assets-cdn/tokens/USDT-f8c08c/icon.png"}];var ke=require("@vleap/warps"),Ue=ke.WarpChainName.Multiversx,Fe=[{chain:Ue,identifier:"EGLD",name:"eGold",symbol:"EGLD",decimals:18,logoUrl:"https://tools.multiversx.com/assets-cdn/tokens/EGLD-000000/icon.png"},{chain:Ue,identifier:"EGLD-000000",name:"eGold",symbol:"EGLD",decimals:18,logoUrl:"https://tools.multiversx.com/assets-cdn/tokens/EGLD-000000/icon.png"}];var Me=require("@vleap/warps"),Re=Me.WarpChainName.Vibechain,me=[{chain:Re,identifier:"VIBE",name:"VIBE",symbol:"VIBE",decimals:18,logoUrl:"https://vleap.ai/images/tokens/vibe.svg"},{chain:Re,identifier:"VIBE-000000",name:"VIBE",symbol:"VIBE",decimals:18,logoUrl:"https://vleap.ai/images/tokens/vibe.svg"}];var ye={multiversx:{mainnet:Ve,testnet:Fe,devnet:Pe},vibechain:{mainnet:me,testnet:me,devnet:me}},ve=(i,e,t)=>(ye[i]?.[e]||[]).find(a=>a.identifier===t)||null,Xe=(i,e)=>ye[i]?.[e]||[];var se=class{constructor(e,t){this.config=e;this.chain=t;this.cache=new X.WarpCache(e.cache?.type)}async getAccount(e){let r=await w(this.chain,this.config.env,this.config).createNetworkProvider().getAccount(_.Address.newFromBech32(e));return{chain:this.chain.name,address:r.address.toBech32(),balance:r.balance}}async getAccountAssets(e){let t=w(this.chain,this.config.env,this.config).createNetworkProvider(),r=t.getAccount(_.Address.newFromBech32(e)),a=t.getFungibleTokensOfAccount(_.Address.newFromBech32(e)),[s,o]=await Promise.all([r,a]),c=s.balance>0?[{...this.chain.nativeToken,amount:s.balance}]:[];return c.push(...o.map(p=>({chain:this.chain.name,identifier:p.token.identifier,name:p.raw.name,symbol:p.raw.ticker,amount:p.amount,decimals:p.raw.decimals,logoUrl:p.raw.assets?.pngUrl||"",price:p.raw.price?Number(p.raw.price):void 0,supply:p.raw.supply?BigInt(p.raw.supply):void 0}))),c}async getAsset(e){let t=X.WarpCacheKey.Asset(this.config.env,this.chain.name,e),r=this.cache.get(t);if(r)return r;let a=ve(this.chain.name,this.config.env,e);if(a)return{chain:this.chain.name,identifier:e,name:a.name,symbol:a.symbol,amount:0n,decimals:a.decimals,logoUrl:a.logoUrl};let s=new _.TokenComputer,o=H(e)?0n:s.extractNonceFromExtendedIdentifier(e),c=new _.Token({identifier:e,nonce:BigInt(o||0)}),p=s.isFungible(c),f=w(this.chain,this.config.env,this.config).createNetworkProvider(),g=te(e),d=await f.doGetGeneric(`tokens/${g}`),T={chain:this.chain.name,identifier:c.identifier,name:d.name,symbol:d.ticker,amount:0n,decimals:d.decimals,logoUrl:d.assets?.pngUrl||null,price:d.price?Number(d.price):void 0,supply:d.supply?BigInt(d.supply):void 0};return this.cache.set(t,T,X.CacheTtl.OneHour),T}async getAction(e,t=!1){let r=w(this.chain,this.config.env,this.config),a=t?await r.awaitCompletedTransaction(e):await r.getTransaction(e);return{chain:this.chain.name,id:a.hash,receiver:a.receiver.toBech32(),sender:a.sender.toBech32(),value:a.value,function:a.function,status:this.toActionStatus(a),createdAt:this.toActionCreatedAt(a),error:a?.smartContractResults.map(s=>s.raw.returnMessage)[0]||null,tx:a}}async getAccountActions(e,t){let r=w(this.chain,this.config.env,this.config).createNetworkProvider(),a=`accounts/${e}/transactions`,s=new URLSearchParams,o=t?.size||25,c=t?.page||0;if(c>0){let f=c*o;s.append("from",f.toString())}return o!==25&&s.append("size",o.toString()),s.toString()&&(a+=`?${s.toString()}`),(await r.doGetGeneric(a)).map(f=>({chain:this.chain.name,id:f.txHash,receiver:f.receiver,sender:f.sender,value:f.value,function:f.function,status:this.toActionStatus(f),createdAt:this.toActionCreatedAt(f)}))}toActionStatus(e){return e.status.isSuccessful()?"success":e.status.isFailed()?"failed":"pending"}toActionCreatedAt(e){return new Date(e.timestamp||e.timestamp*1e3).toISOString()}};var C=require("@multiversx/sdk-core"),U=require("@vleap/warps");var J=require("@multiversx/sdk-core"),W=require("@vleap/warps");var n=require("@multiversx/sdk-core"),De=require("@vleap/warps");var h={HttpProtocolPrefix:"http",IdentifierParamName:"warp",IdentifierParamSeparator:":",IdentifierChainDefault:"multiversx",IdentifierType:{Alias:"alias",Hash:"hash"},IdentifierAliasMarker:"@",Globals:{UserWallet:{Placeholder:"USER_WALLET",Accessor:i=>i.config.user?.wallets?.[i.chain.name]},ChainApiUrl:{Placeholder:"CHAIN_API",Accessor:i=>i.chain.defaultApiUrl},ChainAddressHrp:{Placeholder:"CHAIN_ADDRESS_HRP",Accessor:i=>i.chain.addressHrp}},Vars:{Query:"query",Env:"env"},ArgParamsSeparator:":",ArgCompositeSeparator:"|",ArgListSeparator:",",ArgStructSeparator:";",Transform:{Prefix:"transform:"},Source:{UserWallet:"user:wallet"},Position:{Payload:"payload:"},Alerts:{TriggerEventPrefix:"event"}},u={Option:"option",Vector:"vector",Tuple:"tuple",Struct:"struct",String:"string",Uint8:"uint8",Uint16:"uint16",Uint32:"uint32",Uint64:"uint64",Uint128:"uint128",Uint256:"uint256",Biguint:"biguint",Bool:"bool",Address:"address",Asset:"asset",Hex:"hex"};var Je={Egld:{Identifier:"EGLD",EsdtIdentifier:"EGLD-000000",DisplayName:"eGold",Decimals:18}},v={Null:"null",Optional:"optional",List:"list",Token:"token",CodeMeta:"codemeta"},Oe=(r=>(r.MultiversxExplorer="multiversx_explorer",r.MultiversxExplorerDevnet="multiversx_explorer_devnet",r.MultiversxExplorerTestnet="multiversx_explorer_testnet",r))(Oe||{}),Le=(r=>(r.VibechainExplorer="vibechain_explorer",r.VibechainExplorerDevnet="vibechain_explorer_devnet",r.VibechainExplorerTestnet="vibechain_explorer_testnet",r))(Le||{}),Te={multiversx:{mainnet:["multiversx_explorer"],testnet:["multiversx_explorer_testnet"],devnet:["multiversx_explorer_devnet"]},vibechain:{mainnet:["vibechain_explorer"],testnet:["vibechain_explorer_testnet"],devnet:["vibechain_explorer_devnet"]}},G={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 Ye=new RegExp(`${h.ArgParamsSeparator}(.*)`),O=class{constructor(e){this.coreSerializer=new De.WarpSerializer(e)}typedToString(e){let t=e.getType();if(t.hasExactClass(n.OptionType.ClassName)||e.hasClassOrSuperclass(n.OptionValue.ClassName)){if(!e.isSet())return u.Option+h.ArgParamsSeparator+"null";let r=this.typedToString(e.getTypedValue());return u.Option+h.ArgParamsSeparator+r}if(t.hasExactClass(n.VariadicType.ClassName)||e.hasClassOrSuperclass(n.VariadicValue.ClassName)){let r=e.getItems();if(r.length===0){let g=this.typeToString(t.getFirstTypeParameter());return u.Vector+h.ArgParamsSeparator+g+h.ArgParamsSeparator}let a=r.map(g=>this.typedToString(g));if(a.every(g=>g.startsWith(u.Tuple)))return u.Vector+h.ArgParamsSeparator+a.join(",");let s=a[0],o=s.indexOf(h.ArgParamsSeparator),c=s.substring(0,o),p=a.map(g=>{let d=g.indexOf(h.ArgParamsSeparator);return g.substring(d+1)}),f=c.startsWith(u.Struct)?h.ArgStructSeparator:h.ArgListSeparator;return u.Vector+h.ArgParamsSeparator+c+h.ArgParamsSeparator+p.join(f)}if(t.hasExactClass(n.OptionalType.ClassName)||e.hasClassOrSuperclass(n.OptionalValue.ClassName)){if(!e.isSet())return v.Optional+h.ArgParamsSeparator+"null";let r=this.typedToString(e.getTypedValue());return v.Optional+h.ArgParamsSeparator+r}if(t.hasExactClass(n.ListType.ClassName)||e.hasClassOrSuperclass(n.List.ClassName)){let a=e.getItems().map(p=>this.typedToString(p));if(a.every(p=>p.startsWith(u.Tuple)))return v.List+h.ArgParamsSeparator+a.join(",");let o=a.map(p=>p.split(h.ArgParamsSeparator)[0])[0],c=a.map(p=>p.split(h.ArgParamsSeparator)[1]);return v.List+h.ArgParamsSeparator+o+h.ArgParamsSeparator+c.join(h.ArgListSeparator)}if(t.hasExactClass(n.CompositeType.ClassName)||e.hasClassOrSuperclass(n.CompositeValue.ClassName)){let a=e.getItems().map(s=>{let o=this.typedToString(s),c=o.indexOf(h.ArgParamsSeparator),p=o.substring(0,c),f=o.substring(c+1);return`${p},${f}`});return`${u.Tuple}(${a.join(",")})`}if(t.hasExactClass(n.BigUIntType.ClassName)||e.hasClassOrSuperclass(n.BigUIntValue.ClassName)||t.getName()==="BigUint")return u.Biguint+h.ArgParamsSeparator+BigInt(e.valueOf().toFixed());if(t.hasExactClass(n.U8Type.ClassName)||e.hasClassOrSuperclass(n.U8Value.ClassName))return u.Uint8+h.ArgParamsSeparator+e.valueOf().toNumber();if(t.hasExactClass(n.U16Type.ClassName)||e.hasClassOrSuperclass(n.U16Value.ClassName))return u.Uint16+h.ArgParamsSeparator+e.valueOf().toNumber();if(t.hasExactClass(n.U32Type.ClassName)||e.hasClassOrSuperclass(n.U32Value.ClassName))return u.Uint32+h.ArgParamsSeparator+e.valueOf().toNumber();if(t.hasExactClass(n.U64Type.ClassName)||e.hasClassOrSuperclass(n.U64Value.ClassName))return u.Uint64+h.ArgParamsSeparator+BigInt(e.valueOf().toFixed());if(t.hasExactClass(n.StringType.ClassName)||e.hasClassOrSuperclass(n.StringValue.ClassName))return u.String+h.ArgParamsSeparator+e.valueOf();if(t.hasExactClass(n.BooleanType.ClassName)||e.hasClassOrSuperclass(n.BooleanValue.ClassName))return u.Bool+h.ArgParamsSeparator+e.valueOf();if(t.hasExactClass(n.AddressType.ClassName)||e.hasClassOrSuperclass(n.AddressValue.ClassName))return u.Address+h.ArgParamsSeparator+e.valueOf().toBech32();if(t.hasExactClass(n.BytesType.ClassName)||e.hasClassOrSuperclass(n.BytesValue.ClassName))return u.Hex+h.ArgParamsSeparator+e.valueOf().toString("hex");if(t.getName()==="EsdtTokenPayment"){let r=e.getFieldValue("token_identifier").valueOf(),a=e.getFieldValue("token_nonce").valueOf(),s=e.getFieldValue("amount").valueOf(),c=new n.TokenComputer().computeExtendedIdentifier(new n.Token({identifier:r,nonce:BigInt(a)}));return u.Asset+h.ArgParamsSeparator+c+h.ArgCompositeSeparator+s}if(t.hasExactClass(n.StructType.ClassName)||e.hasClassOrSuperclass(n.Struct.ClassName)){let r=e,s=r.getType().getName(),o=r.getFields();if(o.length===0)return`${u.Struct}(${s})${h.ArgParamsSeparator}`;let c=o.map(p=>{let f=p.value.getType(),d=this.typedToString(p.value).split(h.ArgParamsSeparator),T=d.length>2?d.slice(2).join(h.ArgParamsSeparator):d[1]||"";return`(${p.name}${h.ArgParamsSeparator}${this.typeToString(f)})${T}`});return`${u.Struct}(${s})${h.ArgParamsSeparator}${c.join(h.ArgListSeparator)}`}if(t.hasExactClass(n.TokenIdentifierType.ClassName)||e.hasClassOrSuperclass(n.TokenIdentifierValue.ClassName))return v.Token+h.ArgParamsSeparator+e.valueOf();if(t.hasExactClass(n.CodeMetadataType.ClassName)||e.hasClassOrSuperclass(n.CodeMetadataValue.ClassName))return v.CodeMeta+h.ArgParamsSeparator+e.valueOf().toString();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){if(e.startsWith(u.Tuple))return this.stringToTyped(e+":");let r=this.coreSerializer.nativeToString(e,t);return this.stringToTyped(r)}nativeToType(e){if(e.startsWith(u.Tuple)){let t=e.match(/\(([^)]+)\)/)?.[1];if(!t)throw new Error(`Invalid tuple type format: ${e}`);let r=t.split(","),a=[];for(let s=0;s<r.length;s+=2)a.push(r[s]);return new n.CompositeType(...a.map(s=>this.nativeToType(s)))}if(e.startsWith(u.Struct)){let t=e.match(/\(([^)]+)\)/);if(!t)throw new Error("Struct type must include a name in the format struct(Name)");let r=t[1];return new n.StructType(r,[])}if(e===u.String)return new n.StringType;if(e===u.Uint8)return new n.U8Type;if(e===u.Uint16)return new n.U16Type;if(e===u.Uint32)return new n.U32Type;if(e===u.Uint64)return new n.U64Type;if(e===u.Biguint)return new n.BigUIntType;if(e===u.Bool)return new n.BooleanType;if(e===u.Address)return new n.AddressType;if(e===u.Hex)return new n.BytesType;if(e===u.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)]);if(e===v.Token)return new n.TokenIdentifierType;if(e===v.CodeMeta)return new n.CodeMetadataType;throw new Error(`WarpArgSerializer (nativeToType): Unsupported input type: ${e}`)}stringToTyped(e){let[t,r]=e.split(/:(.*)/,2);if(t===u.Option){let a=this.stringToTyped(r);return a instanceof n.NothingValue?n.OptionValue.newMissingTyped(a.getType()):n.OptionValue.newProvided(a)}if(t===u.Vector){let a=r.indexOf(h.ArgParamsSeparator),s=r.substring(0,a),o=r.substring(a+1);if(s.startsWith(u.Tuple)){let d=o.split(",").map(T=>this.stringToTyped(T));return new n.VariadicValue(new n.VariadicType(this.nativeToType(s)),d)}if(o.includes("tuple(")){let g=this.splitTupleStrings(o),d=g.map(x=>this.stringToTyped(x)),E=g[0].match(/^(tuple\([^)]+\))/),y=E?E[1]:"tuple";return new n.VariadicValue(new n.VariadicType(this.nativeToType(y)),d)}let c=s.startsWith(u.Struct)?h.ArgStructSeparator:h.ArgListSeparator,f=o.split(c).map(g=>this.stringToTyped(`${s}:${g}`));return new n.VariadicValue(new n.VariadicType(this.nativeToType(s)),f)}if(t.startsWith(u.Tuple)){let a=t.match(/\(([^)]+)\)/)?.[1];if(!a)throw new Error(`Invalid tuple format: ${t}`);let s=a.split(","),o=[];for(let p=0;p<s.length;p+=2){let f=s[p],g=s[p+1];o.push(this.stringToTyped(`${f}:${g}`))}let c=o.map(p=>p.getType());return new n.CompositeValue(new n.CompositeType(...c),o)}if(t.startsWith(u.Struct)){let a=t.match(/\(([^)]+)\)/),s=a?a[1]:"CustomStruct";if(!r)return new n.Struct(new n.StructType(s,[]),[]);let o=r.split(h.ArgListSeparator),c=[],p=[];return o.forEach(f=>{let g=f.match(new RegExp(`^\\(([^${h.ArgParamsSeparator}]+)${h.ArgParamsSeparator}([^)]+)\\)(.+)$`));if(g){let[,d,T,E]=g,y=this.stringToTyped(`${T}${h.ArgParamsSeparator}${E}`);c.push(new n.FieldDefinition(d,"",y.getType())),p.push(new n.Field(y,d))}}),new n.Struct(new n.StructType(s,c),p)}if(t===u.String)return r?n.StringValue.fromUTF8(r):new n.NothingValue;if(t===u.Uint8)return r?new n.U8Value(Number(r)):new n.NothingValue;if(t===u.Uint16)return r?new n.U16Value(Number(r)):new n.NothingValue;if(t===u.Uint32)return r?new n.U32Value(Number(r)):new n.NothingValue;if(t===u.Uint64)return r?new n.U64Value(BigInt(r)):new n.NothingValue;if(t===u.Biguint)return r?new n.BigUIntValue(BigInt(r)):new n.NothingValue;if(t===u.Bool)return r?new n.BooleanValue(typeof r=="boolean"?r:r==="true"):new n.NothingValue;if(t===u.Address)return r?new n.AddressValue(n.Address.newFromBech32(r)):new n.NothingValue;if(t===u.Hex)return r?n.BytesValue.fromHex(r):new n.NothingValue;if(t===u.Asset){let[a,s]=r.split(h.ArgCompositeSeparator),o=new n.TokenComputer,c=H(a)?te(a):o.extractIdentifierFromExtendedIdentifier(a),p=H(a)?0n:o.extractNonceFromExtendedIdentifier(a);return new n.Struct(this.nativeToType("asset"),[new n.Field(new n.TokenIdentifierValue(c),"token_identifier"),new n.Field(new n.U64Value(BigInt(p)),"token_nonce"),new n.Field(new n.BigUIntValue(BigInt(s)),"amount")])}if(t===v.Null)return new n.NothingValue;if(t===v.Optional){let a=this.stringToTyped(r);return a instanceof n.NothingValue?n.OptionalValue.newMissing():new n.OptionalValue(a.getType(),a)}if(t===v.List){let[a,s]=r.split(Ye,2),c=s.split(h.ArgListSeparator).map(p=>this.stringToTyped(a+h.ArgParamsSeparator+p));return new n.List(this.nativeToType(a),c)}if(t===v.Token)return r?new n.TokenIdentifierValue(r):new n.NothingValue;if(t===v.CodeMeta)return new n.CodeMetadataValue(n.CodeMetadata.newFromBytes(Uint8Array.from(Buffer.from(r,"hex"))));throw new Error(`WarpArgSerializer (stringToTyped): Unsupported input type: ${t}`)}splitTupleStrings(e){let t=[],r="",a=0;for(let s=0;s<e.length;s++){let o=e[s];if(o==="(")a++;else if(o===")")a--;else if(o===","&&a===0){t.push(r.trim()),r="";continue}r+=o}return r.trim()&&t.push(r.trim()),t}typeToString(e){if(e.hasExactClass(n.OptionType.ClassName))return u.Option+h.ArgParamsSeparator+this.typeToString(e.getFirstTypeParameter());if(e.hasExactClass(n.VariadicType.ClassName))return u.Vector+h.ArgParamsSeparator+this.typeToString(e.getFirstTypeParameter());if(e.hasExactClass(n.StringType.ClassName))return u.String;if(e.hasExactClass(n.U8Type.ClassName))return u.Uint8;if(e.hasExactClass(n.U16Type.ClassName))return u.Uint16;if(e.hasExactClass(n.U32Type.ClassName))return u.Uint32;if(e.hasExactClass(n.U64Type.ClassName))return u.Uint64;if(e.hasExactClass(n.BigUIntType.ClassName))return u.Biguint;if(e.hasExactClass(n.BooleanType.ClassName))return u.Bool;if(e.hasExactClass(n.AddressType.ClassName))return u.Address;if(e.hasExactClass(n.BytesType.ClassName))return u.Hex;if(e.hasExactClass(n.TokenIdentifierType.ClassName))return v.Token;if(e.hasExactClass(n.OptionalType.ClassName))return v.Optional+h.ArgParamsSeparator+this.typeToString(e.getFirstTypeParameter());if(e.hasExactClass(n.ListType.ClassName))return v.List+h.ArgParamsSeparator+this.typeToString(e.getFirstTypeParameter());if(e.hasExactClass(n.CodeMetadataType.ClassName))return v.CodeMeta;if(e.hasExactClass(n.StructType.ClassName)&&e.getClassName()==="EsdtTokenPayment")return u.Asset;if(e.hasExactClass(n.StructType.ClassName))return`${u.Struct}(${e.getName()})`;throw new Error(`WarpArgSerializer (typeToString): Unsupported input type: ${e.getClassName()}`)}};var K=class{constructor(e,t,r){this.config=e;this.chain=t;this.typeRegistry=r;this.abi=new M(e,t),this.serializer=new O({typeRegistry:this.typeRegistry}),this.cache=new W.WarpCache(e.cache?.type)}async getActionExecution(e,t,r){let a=this.cache.get(W.WarpCacheKey.WarpExecutable(this.config.env,e.meta?.hash||"",t))??[],s=await this.extractContractResults(e,t,r,a),o=(0,W.getNextInfo)(this.config,[],e,t,s),c=(0,W.applyResultsToMessages)(e,s.results);return{success:r.status.isSuccessful(),warp:e,action:t,user:(0,W.getWarpWalletAddressFromConfig)(this.config,this.chain.name),txHash:r.hash,tx:r,next:o,values:s.values,results:s.results,messages:c}}async extractContractResults(e,t,r,a){let s=(0,W.getWarpActionByIndex)(e,t),o=[],c=[],p={};if(!e.results||s.type!=="contract")return{values:{string:o,native:c},results:p};if(!Object.values(e.results).some(y=>y.includes("out")||y.includes("event"))){for(let[y,x]of Object.entries(e.results))p[y]=x;return{values:{string:o,native:c},results:await(0,W.evaluateResultsCommon)(e,p,t,a,this.serializer.coreSerializer,this.config.transform?.runner)}}let g=await this.abi.getAbiForAction(s),d=new J.TransactionEventsParser({abi:g}),E=new J.SmartContractTransactionsOutcomeParser({abi:g}).parseExecute({transactionOnNetwork:r,function:s.func||void 0});for(let[y,x]of Object.entries(e.results)){if(x.startsWith(W.WarpConstants.Transform.Prefix))continue;if(x.startsWith("input.")){p[y]=x;continue}let I=(0,W.parseResultsOutIndex)(x);if(I!==null&&I!==t){p[y]=null;continue}let[F,N,Z]=x.split(".");if(F==="event"){if(!N||isNaN(Number(Z)))continue;let q=Number(Z),A=(0,J.findEventsByFirstTopic)(r,N),He=d.parseEvents({events:A})[0],ee=Object.values(He)[q]||null;o.push(String(ee)),c.push(ee),p[y]=ee&&ee.valueOf()}else if(F==="out"||F.startsWith("out[")){if(!N)continue;let q=Number(N),A=E.values[q-1]||null;Z&&(A=A[Z]||null),A&&typeof A=="object"&&(A="toFixed"in A?A.toFixed():A.valueOf()),o.push(String(A)),c.push(A),p[y]=A&&A.valueOf()}else p[y]=x}return{values:{string:o,native:c},results:await(0,W.evaluateResultsCommon)(e,p,t,a,this.serializer.coreSerializer)}}async extractQueryResults(e,t,r,a){let s=t.map(g=>this.serializer.typedToString(g)),o=t.map(g=>this.serializer.typedToNative(g)[1]),c={string:s,native:o},p={};if(!e.results)return{values:c,results:p};let f=g=>{let d=g.split(".").slice(1).map(E=>parseInt(E)-1);if(d.length===0)return;let T=o[d[0]];for(let E=1;E<d.length;E++){if(T==null)return;T=T[d[E]]}return T};for(let[g,d]of Object.entries(e.results)){if(d.startsWith(W.WarpConstants.Transform.Prefix))continue;let T=(0,W.parseResultsOutIndex)(d);if(T!==null&&T!==r){p[g]=null;continue}d.startsWith("out.")||d==="out"||d.startsWith("out[")?p[g]=f(d)||null:p[g]=d}return{values:c,results:await(0,W.evaluateResultsCommon)(e,p,r,a,this.serializer.coreSerializer)}}async resolveWarpResultsRecursively(e){let t=e.warp,r=e.entryActionIndex,a=e.executor,s=e.inputs,o=e.meta,c=new Map,p=new Set,f=this;async function g(y,x=[]){if(c.has(y))return c.get(y);if(p.has(y))throw new Error(`Circular dependency detected at action ${y}`);p.add(y);let I=t.actions[y-1];if(!I)throw new Error(`Action ${y} not found`);let F;if(I.type==="query")F=await a.executeQuery(t,y,x);else if(I.type==="collect")F=await a.executeCollect(t,y,x,o);else throw new Error(`Unsupported or interactive action type: ${I.type}`);if(c.set(y,F),t.results)for(let N of Object.values(t.results)){let q=String(N).match(/^out\[(\d+)\]/);if(q){let A=parseInt(q[1],10);A!==y&&!c.has(A)&&await g(A)}}return p.delete(y),F}await g(r,s);let d={};for(let y of c.values())for(let[x,I]of Object.entries(y.results))I!==null?d[x]=I:x in d||(d[x]=null);let T=await(0,W.evaluateResultsCommon)(t,d,r,s,this.serializer.coreSerializer,this.config.transform?.runner);return{...c.get(r),action:r,results:T}}};var Ze="EGLD-000000",ie=class{constructor(e,t,r){this.config=e;this.chain=t;this.typeRegistry=r;this.serializer=new O({typeRegistry:this.typeRegistry}),this.abi=new M(this.config,this.chain),this.results=new K(this.config,this.chain,this.typeRegistry)}async createTransaction(e){let t=(0,U.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=(0,U.getWarpWalletAddressFromConfig)(this.config,e.chain.name);if(!t)throw new Error("WarpMultiversxExecutor: createTransfer - user address not set");let r=C.Address.newFromBech32(t),a=new C.TransactionsFactoryConfig({chainID:e.chain.chainId}),s=e.data?Buffer.from(this.serializer.stringToTyped(e.data).valueOf()):null,o=e.transfers.length===1&&e.transfers[0].identifier===this.chain.nativeToken?.identifier,p=(o?e.transfers[0].amount:0n)+e.value;return await new C.TransferTransactionsFactory({config:a}).createTransactionForTransfer(r,{receiver:C.Address.newFromBech32(e.destination),nativeAmount:p,tokenTransfers:o?[]:this.toTokenTransfers(e.transfers),data:s?new Uint8Array(s):void 0})}async createContractCallTransaction(e){let t=(0,U.getWarpWalletAddressFromConfig)(this.config,e.chain.name);if(!t)throw new Error("WarpMultiversxExecutor: createContractCall - user address not set");let r=(0,U.getWarpActionByIndex)(e.warp,e.action),a=C.Address.newFromBech32(t),s=e.args.map(c=>this.serializer.stringToTyped(c)),o=new C.TransactionsFactoryConfig({chainID:e.chain.chainId});return new C.SmartContractTransactionsFactory({config:o}).createTransactionForExecute(a,{contract:C.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,U.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(N=>this.serializer.stringToTyped(N)),s=w(e.chain,this.config.env,this.config),o=C.Address.newFromBech32(e.destination),c=s.createSmartContractController(r),p=c.createQuery({contract:o,function:t.func||"",arguments:a}),f=await c.runQuery(p),g=f.returnCode==="ok",d=new C.ArgSerializer,T=r.getEndpoint(f.function||t.func||""),E=(f.returnDataParts||[]).map(N=>Buffer.from(N)),y=d.buffersToValues(E,T.output),{values:x,results:I}=await this.results.extractQueryResults(e.warp,y,e.action,e.resolvedInputs),F=(0,U.getNextInfo)(this.config,[],e.warp,e.action,I);return{success:g,warp:e.warp,action:e.action,user:(0,U.getWarpWalletAddressFromConfig)(this.config,e.chain.name),txHash:null,tx:null,next:F,values:x,results:I,messages:(0,U.applyResultsToMessages)(e.warp,I)}}toTokenTransfers(e){return e.map(t=>t.identifier===this.chain.nativeToken.identifier?{...t,identifier:Ze}:t).map(t=>{let a=new C.TokenComputer().extractNonceFromExtendedIdentifier(t.identifier);return new C.TokenTransfer({token:new C.Token({identifier:t.identifier,nonce:BigInt(a||0)}),amount:t.amount})})}};var oe=class{constructor(e,t){this.chain=e;this.config=t}getExplorers(){let e=Te[this.chain];if(!e)return["multiversx_explorer"];let t=e[this.config.env];return t||["multiversx_explorer"]}getPrimaryExplorer(){return this.getExplorers()[0]}getExplorerUrlByName(e){let t=this.config.preferences?.explorers?.[this.chain];if(t&&!e){let s=G[t];if(s)return s}if(e){let s=G[e];if(s)return s}let r=this.getPrimaryExplorer();return G[r]||G[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=G[a];s&&(r[a]=`${s}/accounts/${e}`)}),r}getTransactionUrls(e){let t=this.getAllExplorers(),r={};return t.forEach(a=>{let s=G[a];s&&(r[a]=`${s}/transactions/${e}`)}),r}};var m=require("@multiversx/sdk-core"),k=require("@vleap/warps");var we={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"},{name:"brand_opt",type:"optional<bytes>",multi_arg:!0}],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}]}],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:{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 S=i=>{if(i==="devnet")return"erd1qqqqqqqqqqqqqpgqje2f99vr6r7sk54thg03c9suzcvwr4nfl3tsfkdl36";if(i==="testnet")throw new Error("Multiversx testnet is not supported");return"erd1qqqqqqqqqqqqqpgq3mrpj3u6q7tejv6d7eqhnyd27n9v5c5tl3ts08mffe"};var ce=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}),We=i=>({unitPrice:BigInt(i.unit_price.toString()),admins:i.admins.map(e=>e.toBech32())});var pe=class{constructor(e,t){this.config=e;this.chain=t;this.cache=new k.WarpCache(e.cache?.type),this.registryConfig={unitPrice:BigInt(0),admins:[]},this.userWallet=(0,k.getWarpWalletAddressFromConfig)(this.config,this.chain.name)}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=m.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,o=()=>t&&r?[m.BytesValue.fromHex(e),m.BytesValue.fromUTF8(t),m.BytesValue.fromHex(r)]:t?[m.BytesValue.fromHex(e),m.BytesValue.fromUTF8(t)]:[m.BytesValue.fromHex(e)];return await this.getFactory().createTransactionForExecute(a,{contract:m.Address.newFromBech32(S(this.config.env)),function:"registerWarp",gasLimit:BigInt(1e7),nativeTransferAmount:s(),arguments:o()})}async createWarpUnregisterTransaction(e){if(!this.userWallet)throw new Error("WarpRegistry: user address not set");let t=m.Address.newFromBech32(this.userWallet);return await this.getFactory().createTransactionForExecute(t,{contract:m.Address.newFromBech32(S(this.config.env)),function:"unregisterWarp",gasLimit:BigInt(1e7),arguments:[m.BytesValue.fromHex(e)]})}async createWarpUpgradeTransaction(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=m.Address.newFromBech32(this.userWallet);return await this.getFactory().createTransactionForExecute(a,{contract:m.Address.newFromBech32(S(this.config.env)),function:"upgradeWarp",gasLimit:BigInt(1e7),nativeTransferAmount:this.isCurrentUserAdmin()?void 0:this.registryConfig.unitPrice,arguments:r?[m.BytesValue.fromUTF8(e),m.BytesValue.fromHex(t),m.BytesValue.fromHex(r)]:[m.BytesValue.fromUTF8(e),m.BytesValue.fromHex(t)]})}async createWarpAliasSetTransaction(e,t){if(!this.userWallet)throw new Error("WarpRegistry: user address not set");let r=m.Address.newFromBech32(this.userWallet);return await this.getFactory().createTransactionForExecute(r,{contract:m.Address.newFromBech32(S(this.config.env)),function:"setWarpAlias",gasLimit:BigInt(1e7),nativeTransferAmount:this.isCurrentUserAdmin()?void 0:this.registryConfig.unitPrice,arguments:[m.BytesValue.fromHex(e),m.BytesValue.fromUTF8(t)]})}async createWarpVerifyTransaction(e){if(!this.userWallet)throw new Error("WarpRegistry: user address not set");let t=m.Address.newFromBech32(this.userWallet);return await this.getFactory().createTransactionForExecute(t,{contract:m.Address.newFromBech32(S(this.config.env)),function:"verifyWarp",gasLimit:BigInt(1e7),arguments:[m.BytesValue.fromHex(e)]})}async createWarpTransferOwnershipTransaction(e,t){if(!this.userWallet)throw new Error("WarpRegistry: user address not set");let r=m.Address.newFromBech32(this.userWallet);return await this.getFactory().createTransactionForExecute(r,{contract:m.Address.newFromBech32(S(this.config.env)),function:"transferOwnership",gasLimit:BigInt(1e7),arguments:[m.BytesValue.fromHex(e),new m.AddressValue(new m.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=m.Address.newFromBech32(this.userWallet);return await this.getFactory().createTransactionForExecute(t,{contract:m.Address.newFromBech32(S(this.config.env)),function:"registerBrand",gasLimit:BigInt(1e7),nativeTransferAmount:this.isCurrentUserAdmin()?void 0:this.registryConfig.unitPrice,arguments:[m.BytesValue.fromHex(e)]})}async createWarpBrandingTransaction(e,t){if(!this.userWallet)throw new Error("WarpRegistry: user address not set");let r=m.Address.newFromBech32(this.userWallet);return await this.getFactory().createTransactionForExecute(r,{contract:m.Address.newFromBech32(S(this.config.env)),function:"brandWarp",gasLimit:BigInt(1e7),nativeTransferAmount:this.isCurrentUserAdmin()?void 0:this.registryConfig.unitPrice,arguments:[m.BytesValue.fromHex(e),m.BytesValue.fromHex(t)]})}async getInfoByAlias(e,t){try{let r=k.WarpCacheKey.RegistryInfo(this.config.env,e),a=t?this.cache.get(r):null;if(a)return k.WarpLogger.info(`WarpRegistry (getInfoByAlias): RegistryInfo found in cache: ${e}`),a;let s=m.Address.newFromBech32(S(this.config.env)),o=this.getController(),c=o.createQuery({contract:s,function:"getInfoByAlias",arguments:[m.BytesValue.fromUTF8(e)]}),p=await o.runQuery(c),[f]=o.parseQueryResponse(p),g=f?ce(f):null,d=g?.brand?await this.fetchBrand(g.brand):null;return t&&t.ttl&&this.cache.set(r,{registryInfo:g,brand:d},t.ttl),{registryInfo:g,brand:d}}catch{return{registryInfo:null,brand:null}}}async getInfoByHash(e,t){try{let r=k.WarpCacheKey.RegistryInfo(this.config.env,e);if(t){let d=this.cache.get(r);if(d)return k.WarpLogger.info(`WarpRegistry (getInfoByHash): RegistryInfo found in cache: ${e}`),d}let a=m.Address.newFromBech32(S(this.config.env)),s=this.getController(),o=s.createQuery({contract:a,function:"getInfoByHash",arguments:[m.BytesValue.fromHex(e)]}),c=await s.runQuery(o),[p]=s.parseQueryResponse(c),f=p?ce(p):null,g=f?.brand?await this.fetchBrand(f.brand):null;return t&&t.ttl&&this.cache.set(r,{registryInfo:f,brand:g},t.ttl),{registryInfo:f,brand:g}}catch{return{registryInfo:null,brand:null}}}async getUserWarpRegistryInfos(e){try{let t=e||this.userWallet;if(!t)throw new Error("WarpRegistry: user address not set");let r=m.Address.newFromBech32(S(this.config.env)),a=this.getController(),s=a.createQuery({contract:r,function:"getUserWarps",arguments:[new m.AddressValue(new m.Address(t))]}),o=await a.runQuery(s),[c]=a.parseQueryResponse(o);return c.map(ce)}catch{return[]}}async getUserBrands(e){try{let t=e||this.userWallet;if(!t)throw new Error("WarpRegistry: user address not set");let r=m.Address.newFromBech32(S(this.config.env)),a=this.getController(),s=a.createQuery({contract:r,function:"getUserBrands",arguments:[new m.AddressValue(new m.Address(t))]}),o=await a.runQuery(s),[c]=a.parseQueryResponse(o),p=c.map(d=>d.toString("hex")),f={ttl:365*24*60*60};return(await Promise.all(p.map(d=>this.fetchBrand(d,f)))).filter(d=>d!==null)}catch{return[]}}async fetchBrand(e,t){let r=k.WarpCacheKey.Brand(this.config.env,e),a=t?this.cache.get(r):null;if(a)return k.WarpLogger.info(`WarpRegistry (fetchBrand): Brand found in cache: ${e}`),a;let o=w(this.chain,this.config.env,this.config).createNetworkProvider();try{let c=await o.getTransaction(e),p=JSON.parse(c.data.toString());return p.meta={chain:this.chain.name,hash:c.hash,creator:c.sender.toBech32(),createdAt:new Date(c.timestamp*1e3).toISOString()},t&&t.ttl&&this.cache.set(r,p,t.ttl),p}catch{return null}}async loadRegistryConfigs(){let e=m.Address.newFromBech32(S(this.config.env)),t=this.getController(),[r]=await t.query({contract:e,function:"getConfig",arguments:[]}),a=r?We(r):null;this.registryConfig=a||{unitPrice:BigInt(0),admins:[]}}getFactory(){let e=new m.TransactionsFactoryConfig({chainID:this.chain.chainId}),t=m.AbiRegistry.create(we);return new m.SmartContractTransactionsFactory({config:e,abi:t})}getController(){let e=w(this.chain,this.config.env,this.config),t=m.AbiRegistry.create(we);return e.createSmartContractController(t)}isCurrentUserAdmin(){return!!this.userWallet&&this.registryConfig.admins.includes(this.userWallet)}};var P=require("@multiversx/sdk-core"),L=require("@vleap/warps");var le=class{constructor(e,t){this.config=e;this.chain=t;this.entry=w(t,e.env,e),this.provider=this.entry.createNetworkProvider(),this.cache=new L.WarpCache(e.cache?.type)}async signTransaction(e){if(!e||typeof e!="object")throw new Error("Invalid transaction object");let t=(0,L.getWarpWalletPrivateKeyFromConfig)(this.config,this.chain.name);if(!t)throw new Error("Wallet not initialized - no private key provided");let a=t.startsWith("-----")?P.UserSecretKey.fromPem(t):P.UserSecretKey.fromString(t),s=new P.Account(a);if(e.nonce===0n){let o=await this.entry.recallAccountNonce(s.address),c=this.cache.get(`nonce:${s.address.toBech32()}`)||0,p=BigInt(Math.max(c,Number(o)));e.nonce=p}return e.signature=await s.signTransaction(e),this.cache.set(`nonce:${s.address.toBech32()}`,Number(s.nonce),L.CacheTtl.OneHour),e}async signTransactions(e){return Promise.all(e.map(async t=>this.signTransaction(t)))}async signMessage(e){let t=(0,L.getWarpWalletPrivateKeyFromConfig)(this.config,this.chain.name);if(!t)throw new Error("Wallet not initialized - no private key provided");let a=t.startsWith("-----")?P.UserSecretKey.fromPem(t):P.UserSecretKey.fromString(t),o=await new P.Account(a).signMessage(new P.Message({data:Buffer.from(e)}));return Buffer.from(o).toString("hex")}async sendTransactions(e){return Promise.all(e.map(async t=>this.sendTransaction(t)))}async sendTransaction(e){if(!e||typeof e!="object")throw new Error("Invalid transaction object");if(!e.signature)throw new Error("Transaction must be signed before sending");return await this.entry.sendTransaction(e)}create(e){let r=P.Mnemonic.fromString(e).deriveKey(0),a=r.hex();return{address:r.generatePublicKey().toAddress(this.chain.addressHrp).toBech32(),privateKey:a,mnemonic:e}}generate(){let e=P.Mnemonic.generate(),t=e.toString(),r=e.deriveKey(0),a=r.hex();return{address:r.generatePublicKey().toAddress(this.chain.addressHrp).toBech32(),privateKey:a,mnemonic:t}}getAddress(){return(0,L.getWarpWalletAddressFromConfig)(this.config,this.chain.name)}};var ue=(i,e,t)=>(r,a)=>{let s=t[r.env],o=new _e.WarpTypeRegistry;return o.registerType("token",{stringToNative:c=>c,nativeToString:c=>`token:${c}`}),o.registerType("codemeta",{stringToNative:c=>c,nativeToString:c=>`codemeta:${c}`}),o.registerTypeAlias("list","vector"),{chainInfo:s,prefix:e,builder:()=>new ae(r,s),executor:new ie(r,s,o),results:new K(r,s,o),serializer:new O({typeRegistry:o}),registry:new pe(r,s),explorer:new oe(i,r),abiBuilder:()=>new M(r,s),brandBuilder:()=>new ne(r,s),dataLoader:new se(r,s),wallet:new le(r,s)}};var de={chain:Y.WarpChainName.Multiversx,identifier:"EGLD",name:"eGold",symbol:"EGLD",decimals:18,logoUrl:"https://vleap.ai/images/tokens/egld.svg"},Ce=ue(Y.WarpChainName.Multiversx,"multiversx",{mainnet:{name:Y.WarpChainName.Multiversx,displayName:"MultiversX",chainId:"1",blockTime:6e3,addressHrp:"erd",defaultApiUrl:"https://api.multiversx.com",logoUrl:"https://vleap.ai/images/chains/multiversx.svg",nativeToken:de},testnet:{name:Y.WarpChainName.Multiversx,displayName:"MultiversX Testnet",chainId:"T",blockTime:6e3,addressHrp:"erd",defaultApiUrl:"https://testnet-api.multiversx.com",logoUrl:"https://vleap.ai/images/chains/multiversx.svg",nativeToken:de},devnet:{name:Y.WarpChainName.Multiversx,displayName:"MultiversX Devnet",chainId:"D",blockTime:6e3,addressHrp:"erd",defaultApiUrl:"https://devnet-api.multiversx.com",logoUrl:"https://vleap.ai/images/chains/multiversx.svg",nativeToken:de}});var he=require("@vleap/warps");var Ge={chain:he.WarpChainName.Vibechain,identifier:"VIBE",name:"VIBE",symbol:"VIBE",decimals:18,logoUrl:"https://vleap.ai/images/tokens/vibe.svg"},xe={name:he.WarpChainName.Vibechain,displayName:"VibeChain",chainId:"V",blockTime:600,addressHrp:"vibe",defaultApiUrl:"https://vibeox-api.multiversx.com",logoUrl:"https://vleap.ai/images/chains/vibechain.svg",nativeToken:Ge},Ae=ue(he.WarpChainName.Vibechain,"vibe",{mainnet:xe,testnet:xe,devnet:xe});var tt=(i,e)=>[Ce(i,e),Ae(i,e)],rt=()=>[Ee.WarpChainName.Multiversx,Ee.WarpChainName.Vibechain];var D=require("@vleap/warps");var nt=i=>new D.WarpSerializer().nativeToString(v.Token,i),at=i=>new D.WarpSerializer().nativeToString(v.CodeMeta,i),st=(i,e)=>{if(e===null)return v.Optional+D.WarpConstants.ArgParamsSeparator;let t=i(e),r=t.indexOf(D.WarpConstants.ArgParamsSeparator),a=t.substring(0,r),s=t.substring(r+1);return v.Optional+D.WarpConstants.ArgParamsSeparator+a+D.WarpConstants.ArgParamsSeparator+s},it=i=>new D.WarpSerializer().nativeToString(v.List,i);var l=require("@multiversx/sdk-core"),ot=(i,e)=>i?l.OptionValue.newProvided(i):e?l.OptionValue.newMissingTyped(e):l.OptionValue.newMissing(),ct=(i,e)=>i?new l.OptionalValue(i.getType(),i):e?new l.OptionalValue(e):l.OptionalValue.newMissing(),pt=i=>{if(i.length===0)throw new Error("Cannot create a list from an empty array");let e=i[0].getType();return new l.List(e,i)},lt=i=>l.VariadicValue.fromItems(...i),ut=i=>{let e=i.map(t=>t.getType());return new l.CompositeValue(new l.CompositeType(...e),i)},mt=i=>l.StringValue.fromUTF8(i),dt=i=>new l.U8Value(i),ht=i=>new l.U16Value(i),gt=i=>new l.U32Value(i),ft=i=>new l.U64Value(i),yt=i=>new l.BigUIntValue(BigInt(i)),vt=i=>new l.BooleanValue(i),Tt=i=>new l.AddressValue(l.Address.newFromBech32(i)),wt=i=>new l.TokenIdentifierValue(i),Wt=i=>l.BytesValue.fromHex(i),Ct=i=>new l.Struct(new l.StructType("EsdtTokenPayment",[new l.FieldDefinition("token_identifier","",new l.TokenIdentifierType),new l.FieldDefinition("token_nonce","",new l.U64Type),new l.FieldDefinition("amount","",new l.BigUIntType)]),[new l.Field(new l.TokenIdentifierValue(i.token.identifier),"token_identifier"),new l.Field(new l.U64Value(BigInt(i.token.nonce)),"token_nonce"),new l.Field(new l.BigUIntValue(BigInt(i.amount)),"amount")]),xt=i=>new l.CodeMetadataValue(l.CodeMetadata.newFromBytes(Uint8Array.from(Buffer.from(i,"hex")))),At=()=>new l.NothingValue;0&&(module.exports={ExplorerUrls,KnownTokens,MultiversxExplorers,MultiversxExplorersConfig,NativeTokenEgld,NativeTokenVibe,VibechainExplorers,WarpMultiversxAbiBuilder,WarpMultiversxBrandBuilder,WarpMultiversxBuilder,WarpMultiversxConstants,WarpMultiversxContractLoader,WarpMultiversxDataLoader,WarpMultiversxExecutor,WarpMultiversxExplorer,WarpMultiversxInputTypes,WarpMultiversxRegistry,WarpMultiversxResults,WarpMultiversxSerializer,WarpMultiversxWallet,address_value,asset_value,biguint_value,boolean_value,codemeta,codemeta_value,composite_value,createMultiversxAdapter,findKnownTokenById,getAllMultiversxAdapters,getAllMultiversxChainNames,getKnownTokensForChain,getMultiversxAdapter,getMultiversxEntrypoint,getMultiversxRegistryAddress,getNormalizedTokenIdentifier,getVibechainAdapter,hex_value,isNativeToken,list,list_value,nothing_value,option_value,optional,optional_value,string_value,toTypedConfigInfo,toTypedRegistryInfo,token,token_value,u16_value,u32_value,u64_value,u8_value,variadic_value});
|
package/dist/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var or={Egld:{Identifier:"EGLD",EsdtIdentifier:"EGLD-000000",DisplayName:"eGold",Decimals:18}};import{Address as Qt,TransactionsFactoryConfig as je,TransferTransactionsFactory as Ge}from"@multiversx/sdk-core";import{getMainChainInfo as zt,WarpBuilder as Ke,WarpCache as qe,WarpCacheKey as Je,WarpLogger as Ht}from"@vleap/warps";import{Address as S,ArgSerializer as Pe,DevnetEntrypoint as _e,MainnetEntrypoint as Oe,SmartContractTransactionsFactory as ke,TestnetEntrypoint as Ne,Token as Ue,TokenComputer as $e,TokenTransfer as Me,TransactionsFactoryConfig as Mt,TransferTransactionsFactory as Le}from"@multiversx/sdk-core";import{applyResultsToMessages as Qe,findKnownTokenById as ze,getNextInfo as He,getWarpActionByIndex as et,shiftBigintBy as De,WarpConstants as Lt}from"@vleap/warps";import{AbiRegistry as M}from"@multiversx/sdk-core";import{getMainChainInfo as st,WarpCache as Xt,WarpCacheKey as Yt,WarpConstants as ot,WarpLogger as ct}from"@vleap/warps";import{WarpLogger as it}from"@vleap/warps";var O=class{constructor(t){this.config=t}async getContract(t,e){try{let s=await m.getChainEntrypoint(e,this.config.env).createNetworkProvider().doGetGeneric(`accounts/${t}`);return{address:t,owner:s.ownerAddress,verified:s.isVerified||!1}}catch(r){return it.error("WarpContractLoader: getContract error",r),null}}async getVerificationInfo(t,e){try{let s=await m.getChainEntrypoint(e,this.config.env).createNetworkProvider().doGetGeneric(`accounts/${t}/verification`);return{codeHash:s.codeHash,abi:s.source.abi}}catch(r){return it.error("WarpContractLoader: getVerificationInfo error",r),null}}};var B=class{constructor(t){this.config=t;this.contractLoader=new O(this.config),this.cache=new Xt(this.config.cache?.type)}async createFromRaw(t){return JSON.parse(t)}async createFromTransaction(t){let e=await this.createFromRaw(t.data.toString());return e.meta={hash:t.hash,creator:t.sender.bech32(),createdAt:new Date(t.timestamp*1e3).toISOString()},e}async createFromTransactionHash(t,e){let r=Yt.WarpAbi(this.config.env,t);if(e){let a=this.cache.get(r);if(a)return ct.info(`WarpAbiBuilder (createFromTransactionHash): Warp abi found in cache: ${t}`),a}let n=st(this.config),o=m.getChainEntrypoint(n,this.config.env).createNetworkProvider();try{let a=await o.getTransaction(t),u=await this.createFromTransaction(a);return e&&e.ttl&&u&&this.cache.set(r,u,e.ttl),u}catch(a){return ct.error("WarpAbiBuilder: Error creating from transaction hash",a),null}}async getAbiForAction(t){if(t.abi)return await this.fetchAbi(t);if(!t.address)throw new Error("WarpActionExecutor: Address not found");let e=st(this.config),r=await this.contractLoader.getVerificationInfo(t.address,e);if(!r)throw new Error("WarpActionExecutor: Verification info not found");return M.create(r.abi)}async fetchAbi(t){if(!t.abi)throw new Error("WarpActionExecutor: ABI not found");if(t.abi.startsWith(ot.IdentifierType.Hash)){let e=t.abi.split(ot.IdentifierParamSeparator)[1],r=await this.createFromTransactionHash(e);if(!r)throw new Error(`WarpActionExecutor: ABI not found for hash: ${t.abi}`);return M.create(r.content)}else{let r=await(await fetch(t.abi)).json();return M.create(r)}}};import{findEventsByFirstTopic as se,SmartContractTransactionsOutcomeParser as oe,TransactionEventsParser as ce}from"@multiversx/sdk-core";import{applyResultsToMessages as ue,evaluateResultsCommon as k,getNextInfo as pe,parseResultsOutIndex as Ft,WarpCache as le,WarpCacheKey as fe,WarpConstants as Pt}from"@vleap/warps";import{findWarpExecutableAction as _t}from"@vleap/warps/src/helpers";import{Address as Zt,AddressType as ut,AddressValue as pt,BigUIntType as L,BigUIntValue as Q,BooleanType as lt,BooleanValue as ft,BytesType as gt,BytesValue as dt,CodeMetadata as te,CodeMetadataType as yt,CodeMetadataValue as mt,CompositeType as ht,CompositeValue as wt,Field as z,FieldDefinition as H,List as Tt,ListType as ee,NothingValue as C,OptionalType as re,OptionalValue as D,OptionType as ne,OptionValue as j,StringType as Ct,StringValue as Wt,Struct as ae,StructType as bt,TokenIdentifierType as G,TokenIdentifierValue as K,U16Type as It,U16Value as At,U32Type as vt,U32Value as xt,U64Type as q,U64Value as J,U8Type as Bt,U8Value as Et,VariadicType as Vt,VariadicValue as Rt}from"@multiversx/sdk-core";import{WarpConstants as W,WarpSerializer as ie}from"@vleap/warps";var St=new RegExp(`${W.ArgParamsSeparator}(.*)`),x=class{constructor(){this.coreSerializer=new ie}typedToString(t){if(t.hasClassOrSuperclass(j.ClassName))return t.isSet()?`option:${this.typedToString(t.getTypedValue())}`:"option:null";if(t.hasClassOrSuperclass(D.ClassName))return t.isSet()?`optional:${this.typedToString(t.getTypedValue())}`:"optional:null";if(t.hasClassOrSuperclass(Tt.ClassName)){let e=t.getItems(),n=e.map(o=>this.typedToString(o).split(W.ArgParamsSeparator)[0])[0],s=e.map(o=>this.typedToString(o).split(W.ArgParamsSeparator)[1]);return`list:${n}:${s.join(",")}`}if(t.hasClassOrSuperclass(Rt.ClassName)){let e=t.getItems(),n=e.map(o=>this.typedToString(o).split(W.ArgParamsSeparator)[0])[0],s=e.map(o=>this.typedToString(o).split(W.ArgParamsSeparator)[1]);return`variadic:${n}:${s.join(",")}`}if(t.hasClassOrSuperclass(wt.ClassName)){let e=t.getItems(),r=e.map(a=>this.typedToString(a).split(W.ArgParamsSeparator)[0]),n=e.map(a=>this.typedToString(a).split(W.ArgParamsSeparator)[1]),s=r.join(W.ArgCompositeSeparator),o=n.join(W.ArgCompositeSeparator);return`composite(${s}):${o}`}if(t.hasClassOrSuperclass(Q.ClassName)||t.getType().getName()==="BigUint")return`biguint:${BigInt(t.valueOf().toFixed())}`;if(t.hasClassOrSuperclass(Et.ClassName))return`uint8:${t.valueOf().toNumber()}`;if(t.hasClassOrSuperclass(At.ClassName))return`uint16:${t.valueOf().toNumber()}`;if(t.hasClassOrSuperclass(xt.ClassName))return`uint32:${t.valueOf().toNumber()}`;if(t.hasClassOrSuperclass(J.ClassName))return`uint64:${BigInt(t.valueOf().toFixed())}`;if(t.hasClassOrSuperclass(Wt.ClassName))return`string:${t.valueOf()}`;if(t.hasClassOrSuperclass(ft.ClassName))return`bool:${t.valueOf()}`;if(t.hasClassOrSuperclass(pt.ClassName))return`address:${t.valueOf().bech32()}`;if(t.hasClassOrSuperclass(K.ClassName))return`token:${t.valueOf()}`;if(t.hasClassOrSuperclass(dt.ClassName))return`hex:${t.valueOf().toString("hex")}`;if(t.hasClassOrSuperclass(mt.ClassName))return`codemeta:${t.valueOf().toBuffer().toString("hex")}`;if(t.getType().getName()==="EsdtTokenPayment"){let e=t.getFieldValue("token_identifier").valueOf(),r=t.getFieldValue("token_nonce").valueOf(),n=t.getFieldValue("amount").valueOf();return`esdt:${e}|${r}|${n}`}throw new Error(`WarpArgSerializer (typedToString): Unsupported input type: ${t.getClassName()}`)}typedToNative(t){let e=this.typedToString(t);return this.coreSerializer.stringToNative(e)}nativeToTyped(t,e){let r=this.coreSerializer.nativeToString(t,e);return this.stringToTyped(r)}nativeToType(t){if(t.startsWith("composite")){let e=t.match(/\(([^)]+)\)/)?.[1];return new ht(...e.split(W.ArgCompositeSeparator).map(r=>this.nativeToType(r)))}if(t==="string")return new Ct;if(t==="uint8")return new Bt;if(t==="uint16")return new It;if(t==="uint32")return new vt;if(t==="uint64")return new q;if(t==="biguint")return new L;if(t==="bool")return new lt;if(t==="address")return new ut;if(t==="token")return new G;if(t==="hex")return new gt;if(t==="codemeta")return new yt;if(t==="esdt"||t==="nft")return new bt("EsdtTokenPayment",[new H("token_identifier","",new G),new H("token_nonce","",new q),new H("amount","",new L)]);throw new Error(`WarpArgSerializer (nativeToType): Unsupported input type: ${t}`)}stringToTyped(t){let[e,r]=t.split(/:(.*)/,2);if(e==="null"||e===null)return new C;if(e==="option"){let n=this.stringToTyped(r);return n instanceof C?j.newMissingTyped(n.getType()):j.newProvided(n)}if(e==="optional"){let n=this.stringToTyped(r);return n instanceof C?D.newMissing():new D(n.getType(),n)}if(e==="list"){let[n,s]=r.split(St,2),a=s.split(",").map(u=>this.stringToTyped(`${n}:${u}`));return new Tt(this.nativeToType(n),a)}if(e==="variadic"){let[n,s]=r.split(St,2),a=s.split(",").map(u=>this.stringToTyped(`${n}:${u}`));return new Rt(new Vt(this.nativeToType(n)),a)}if(e.startsWith("composite")){let n=e.match(/\(([^)]+)\)/)?.[1],s=r.split(W.ArgCompositeSeparator),o=n.split(W.ArgCompositeSeparator),a=s.map((c,p)=>this.stringToTyped(`${o[p]}:${c}`)),u=a.map(c=>c.getType());return new wt(new ht(...u),a)}if(e==="string")return r?Wt.fromUTF8(r):new C;if(e==="uint8")return r?new Et(Number(r)):new C;if(e==="uint16")return r?new At(Number(r)):new C;if(e==="uint32")return r?new xt(Number(r)):new C;if(e==="uint64")return r?new J(BigInt(r)):new C;if(e==="biguint")return r?new Q(BigInt(r)):new C;if(e==="bool")return r?new ft(typeof r=="boolean"?r:r==="true"):new C;if(e==="address")return r?new pt(Zt.newFromBech32(r)):new C;if(e==="token")return r?new K(r):new C;if(e==="hex")return r?dt.fromHex(r):new C;if(e==="codemeta")return new mt(te.newFromBytes(Uint8Array.from(Buffer.from(r,"hex"))));if(e==="esdt"){let n=r.split(W.ArgCompositeSeparator);return new ae(this.nativeToType("esdt"),[new z(new K(n[0]),"token_identifier"),new z(new J(BigInt(n[1])),"token_nonce"),new z(new Q(BigInt(n[2])),"amount")])}throw new Error(`WarpArgSerializer (stringToTyped): Unsupported input type: ${e}`)}typeToString(t){if(t instanceof ne)return"option:"+this.typeToString(t.getFirstTypeParameter());if(t instanceof re)return"optional:"+this.typeToString(t.getFirstTypeParameter());if(t instanceof ee)return"list:"+this.typeToString(t.getFirstTypeParameter());if(t instanceof Vt)return"variadic:"+this.typeToString(t.getFirstTypeParameter());if(t instanceof Ct)return"string";if(t instanceof Bt)return"uint8";if(t instanceof It)return"uint16";if(t instanceof vt)return"uint32";if(t instanceof q)return"uint64";if(t instanceof L)return"biguint";if(t instanceof lt)return"bool";if(t instanceof ut)return"address";if(t instanceof G)return"token";if(t instanceof gt)return"hex";if(t instanceof yt)return"codemeta";if(t instanceof bt&&t.getClassName()==="EsdtTokenPayment")return"esdt";throw new Error(`WarpArgSerializer (typeToString): Unsupported input type: ${t.getClassName()}`)}};var E=class{constructor(t){this.config=t;this.abi=new B(t),this.serializer=new x,this.cache=new le(t.cache?.type)}async getTransactionExecutionResults(t,e){let[r,n]=_t(t),s=this.cache.get(fe.WarpExecutable(this.config.env,t.meta?.hash||"",n))??[],o=await this.extractContractResults(t,e,s),a=pe(this.config,t,n,o),u=ue(t,o.results);return{success:e.status.isSuccessful(),warp:t,action:n,user:this.config.user?.wallet||null,txHash:e.hash,next:a,values:o.values,results:o.results,messages:u}}async extractContractResults(t,e,r){let[n,s]=_t(t),o=[],a={};if(!t.results||n.type!=="contract")return{values:o,results:a};if(!Object.values(t.results).some(h=>h.includes("out")||h.includes("event"))){for(let[h,f]of Object.entries(t.results))a[h]=f;return{values:o,results:await k(t,a,s,r)}}let c=await this.abi.getAbiForAction(n),p=new ce({abi:c}),d=new oe({abi:c}).parseExecute({transactionOnNetwork:e,function:n.func||void 0});for(let[h,f]of Object.entries(t.results)){if(f.startsWith(Pt.Transform.Prefix))continue;if(f.startsWith("input.")){a[h]=f;continue}let b=Ft(f);if(b!==null&&b!==s){a[h]=null;continue}let[w,A,I]=f.split(".");if(w==="event"){if(!A||isNaN(Number(I)))continue;let P=Number(I),y=se(e,A),R=p.parseEvents({events:y})[0],_=Object.values(R)[P]||null;o.push(_),a[h]=_&&_.valueOf()}else if(w==="out"||w.startsWith("out[")){if(!A)continue;let P=Number(A),y=d.values[P-1]||null;I&&(y=y[I]||null),y&&typeof y=="object"&&(y="toFixed"in y?y.toFixed():y.valueOf()),o.push(y),a[h]=y&&y.valueOf()}else a[h]=f}return{values:o,results:await k(t,a,s,r)}}async extractQueryResults(t,e,r,n){let s=e.map(c=>this.serializer.typedToString(c)),o=e.map(c=>this.serializer.typedToNative(c)[1]),a={};if(!t.results)return{values:s,results:a};let u=c=>{let p=c.split(".").slice(1).map(d=>parseInt(d)-1);if(p.length===0)return;let l=o[p[0]];for(let d=1;d<p.length;d++){if(l==null)return;l=l[p[d]]}return l};for(let[c,p]of Object.entries(t.results)){if(p.startsWith(Pt.Transform.Prefix))continue;let l=Ft(p);if(l!==null&&l!==r){a[c]=null;continue}p.startsWith("out.")||p==="out"||p.startsWith("out[")?a[c]=u(p)||null:a[c]=p}return{values:s,results:await k(t,a,r,n)}}async resolveWarpResultsRecursively(t){let e=t.warp,r=t.entryActionIndex,n=t.executor,s=t.inputs,o=t.meta,a=new Map,u=new Set,c=this;async function p(f,b=[]){if(a.has(f))return a.get(f);if(u.has(f))throw new Error(`Circular dependency detected at action ${f}`);u.add(f);let w=e.actions[f-1];if(!w)throw new Error(`Action ${f} not found`);let A;if(w.type==="query")A=await n.executeQuery(e,f,b);else if(w.type==="collect")A=await n.executeCollect(e,f,b,o);else throw new Error(`Unsupported or interactive action type: ${w.type}`);if(a.set(f,A),e.results)for(let I of Object.values(e.results)){let y=String(I).match(/^out\[(\d+)\]/);if(y){let R=parseInt(y[1],10);R!==f&&!a.has(R)&&await p(R)}}return u.delete(f),A}await p(r,s);let l={};for(let f of a.values())for(let[b,w]of Object.entries(f.results))w!==null?l[b]=w:b in l||(l[b]=null);let d=await k(e,l,r,s);return{...a.get(r),action:r,results:d}}};import{Address as ge,AddressValue as de,BigUIntType as ye,BigUIntValue as Ot,BooleanValue as me,BytesValue as he,CodeMetadata as we,CodeMetadataValue as Te,CompositeType as Ce,CompositeValue as We,Field as X,FieldDefinition as Y,List as be,NothingValue as Ie,OptionalValue as Z,OptionValue as tt,StringValue as Ae,Struct as ve,StructType as xe,TokenIdentifierType as Be,TokenIdentifierValue as kt,U16Value as Ee,U32Value as Ve,U64Type as Re,U64Value as Nt,U8Value as Se,VariadicValue as Fe}from"@multiversx/sdk-core";var nn=(i,t)=>i?tt.newProvided(i):t?tt.newMissingTyped(t):tt.newMissing(),an=(i,t)=>i?new Z(i.getType(),i):t?new Z(t):Z.newMissing(),sn=i=>{if(i.length===0)throw new Error("Cannot create a list from an empty array");let t=i[0].getType();return new be(t,i)},on=i=>Fe.fromItems(...i),cn=i=>{let t=i.map(e=>e.getType());return new We(new Ce(...t),i)},v=i=>Ae.fromUTF8(i),un=i=>new Se(i),pn=i=>new Ee(i),Ut=i=>new Ve(i),ln=i=>new Nt(i),fn=i=>new Ot(BigInt(i)),gn=i=>new me(i),dn=i=>new de(ge.newFromBech32(i)),yn=i=>new kt(i),mn=i=>he.fromHex(i),$t=i=>new ve(new xe("EsdtTokenPayment",[new Y("token_identifier","",new Be),new Y("token_nonce","",new Re),new Y("amount","",new ye)]),[new X(new kt(i.token.identifier),"token_identifier"),new X(new Nt(BigInt(i.token.nonce)),"token_nonce"),new X(new Ot(BigInt(i.amount)),"amount")]),hn=i=>new Te(we.newFromBytes(Uint8Array.from(Buffer.from(i,"hex")))),wn=()=>new Ie;var m=class i{constructor(t){this.config=t;this.serializer=new x,this.abi=new B(this.config),this.results=new E(this.config)}async createTransaction(t){let e=et(t.warp,t.action),r=null;if(e.type==="transfer")r=await this.createTransferTransaction(t);else if(e.type==="contract")r=await this.createContractCallTransaction(t);else{if(e.type==="query")throw new Error("WarpMultiversxExecutor: Invalid action type for createTransactionForExecute; Use executeQuery instead");if(e.type==="collect")throw new Error("WarpMultiversxExecutor: Invalid action type for createTransactionForExecute; Use executeCollect instead")}if(!r)throw new Error(`WarpMultiversxExecutor: Invalid action type (${e.type})`);return r}async createTransferTransaction(t){if(!this.config.user?.wallet)throw new Error("WarpMultiversxExecutor: createTransfer - user address not set");let e=S.newFromBech32(this.config.user.wallet),r=new Mt({chainID:t.chain.chainId}),n=t.data?Buffer.from(this.serializer.stringToTyped(t.data).valueOf()):null;return new Le({config:r}).createTransactionForTransfer(e,{receiver:S.newFromBech32(t.destination),nativeAmount:t.value,data:n?new Uint8Array(n):void 0})}async createContractCallTransaction(t){if(!this.config.user?.wallet)throw new Error("WarpMultiversxExecutor: createContractCall - user address not set");let e=et(t.warp,t.action),r=S.newFromBech32(this.config.user.wallet),n=t.args.map(o=>this.serializer.stringToTyped(o)),s=new Mt({chainID:t.chain.chainId});return new ke({config:s}).createTransactionForExecute(r,{contract:S.newFromBech32(t.destination),function:"func"in e&&e.func||"",gasLimit:"gasLimit"in e?BigInt(e.gasLimit||0):0n,arguments:n,nativeTransferAmount:t.value})}async executeQuery(t){let e=et(t.warp,t.action);if(e.type!=="query")throw new Error(`WarpMultiversxExecutor: Invalid action type for executeQuery: ${e.type}`);let r=await this.abi.getAbiForAction(e),n=t.args.map(I=>this.serializer.stringToTyped(I)),s=i.getChainEntrypoint(t.chain,this.config.env),o=S.newFromBech32(t.destination),a=s.createSmartContractController(r),u=a.createQuery({contract:o,function:e.func||"",arguments:n}),c=await a.runQuery(u),p=c.returnCode==="ok",l=new Pe,d=r.getEndpoint(c.function||e.func||""),h=(c.returnDataParts||[]).map(I=>Buffer.from(I)),f=l.buffersToValues(h,d.output),{values:b,results:w}=await this.results.extractQueryResults(t.warp,f,t.action,t.resolvedInputs),A=He(this.config,t.warp,t.action,w);return{success:p,warp:t.warp,action:t.action,user:this.config.user?.wallet||null,txHash:null,next:A,values:b,results:w,messages:Qe(t.warp,w)}}async preprocessInput(t,e,r,n){if(r==="esdt"){let[s,o,a,u]=n.split(Lt.ArgCompositeSeparator);if(u)return e;let c=new Ue({identifier:s,nonce:BigInt(o)});if(!new $e().isFungible(c))return e;let d=ze(s)?.decimals;if(d||(d=(await(await fetch(`${t.apiUrl}/tokens/${s}`)).json()).decimals),!d)throw new Error(`WarpActionExecutor: Decimals not found for token ${s}`);let h=$t(new Me({token:c,amount:De(a,d)}));return this.serializer.typedToString(h)+Lt.ArgCompositeSeparator+d}return e}static getChainEntrypoint(t,e){let r="warp-sdk",n="api";return e==="devnet"?new _e(t.apiUrl,n,r):e==="testnet"?new Ne(t.apiUrl,n,r):new Oe(t.apiUrl,n,r)}};var N=class{constructor(t){this.config=t,this.cache=new qe(t.cache?.type),this.core=new Ke(t)}createInscriptionTransaction(t){if(!this.config.user?.wallet)throw new Error("WarpBuilder: user address not set");let e=zt(this.config),r=new je({chainID:e.chainId}),n=new Ge({config:r}),s=Qt.newFromBech32(this.config.user.wallet),o=JSON.stringify(t),a=n.createTransactionForTransfer(s,{receiver:Qt.newFromBech32(this.config.user.wallet),nativeAmount:BigInt(0),data:Uint8Array.from(Buffer.from(o))});return a.gasLimit=a.gasLimit+BigInt(2e6),a}async createFromTransaction(t,e=!1){let r=await this.core.createFromRaw(t.data.toString(),e);return r.meta={hash:t.hash,creator:t.sender.toBech32(),createdAt:new Date(t.timestamp*1e3).toISOString()},r}async createFromTransactionHash(t,e){let r=Je.Warp(this.config.env,t);if(e){let a=this.cache.get(r);if(a)return Ht.info(`WarpBuilder (createFromTransactionHash): Warp found in cache: ${t}`),a}let n=zt(this.config),o=m.getChainEntrypoint(n,this.config.env).createNetworkProvider();try{let a=await o.getTransaction(t),u=await this.createFromTransaction(a);return e&&e.ttl&&u&&this.cache.set(r,u,e.ttl),u}catch(a){return Ht.error("WarpBuilder: Error creating from transaction hash",a),null}}};import{AbiRegistry as jt,Address as T,AddressValue as nt,BytesValue as g,SmartContractTransactionsFactory as Ye,TransactionsFactoryConfig as Ze}from"@multiversx/sdk-core";import{getMainChainInfo as at,toTypedChainInfo as Gt,WarpCache as tr,WarpCacheKey as V,WarpConfig as er,WarpLogger as F}from"@vleap/warps";var rt={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 U=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}),Dt=i=>({unitPrice:BigInt(i.unit_price.toString()),admins:i.admins.map(t=>t.toBech32())});var $=class{constructor(t){this.config=t,this.cache=new tr(t.cache?.type),this.registryConfig={unitPrice:BigInt(0),admins:[]}}async init(){await this.loadRegistryConfigs()}createWarpRegisterTransaction(t,e,r){if(this.registryConfig.unitPrice===BigInt(0))throw new Error("WarpRegistry: config not loaded. forgot to call init()?");if(!this.config.user?.wallet)throw new Error("WarpRegistry: user address not set");let n=T.newFromBech32(this.config.user.wallet),s=()=>this.isCurrentUserAdmin()?BigInt(0):e&&r?this.registryConfig.unitPrice*BigInt(3):e?this.registryConfig.unitPrice*BigInt(2):this.registryConfig.unitPrice,o=()=>e&&r?[g.fromHex(t),g.fromUTF8(e),g.fromHex(r)]:e?[g.fromHex(t),g.fromUTF8(e)]:[g.fromHex(t)];return this.getFactory().createTransactionForExecute(n,{contract:this.getRegistryContractAddress(),function:"registerWarp",gasLimit:BigInt(1e7),nativeTransferAmount:s(),arguments:o()})}createWarpUnregisterTransaction(t){if(!this.config.user?.wallet)throw new Error("WarpRegistry: user address not set");let e=T.newFromBech32(this.config.user.wallet);return this.getFactory().createTransactionForExecute(e,{contract:this.getRegistryContractAddress(),function:"unregisterWarp",gasLimit:BigInt(1e7),arguments:[g.fromHex(t)]})}createWarpUpgradeTransaction(t,e){if(this.registryConfig.unitPrice===BigInt(0))throw new Error("WarpRegistry: config not loaded. forgot to call init()?");if(!this.config.user?.wallet)throw new Error("WarpRegistry: user address not set");let r=T.newFromBech32(this.config.user.wallet);return this.getFactory().createTransactionForExecute(r,{contract:this.getRegistryContractAddress(),function:"upgradeWarp",gasLimit:BigInt(1e7),nativeTransferAmount:this.isCurrentUserAdmin()?void 0:this.registryConfig.unitPrice,arguments:[g.fromUTF8(t),g.fromHex(e)]})}createWarpAliasSetTransaction(t,e){if(!this.config.user?.wallet)throw new Error("WarpRegistry: user address not set");let r=T.newFromBech32(this.config.user.wallet);return this.getFactory().createTransactionForExecute(r,{contract:this.getRegistryContractAddress(),function:"setWarpAlias",gasLimit:BigInt(1e7),nativeTransferAmount:this.isCurrentUserAdmin()?void 0:this.registryConfig.unitPrice,arguments:[g.fromHex(t),g.fromUTF8(e)]})}createWarpVerifyTransaction(t){if(!this.config.user?.wallet)throw new Error("WarpRegistry: user address not set");let e=T.newFromBech32(this.config.user.wallet);return this.getFactory().createTransactionForExecute(e,{contract:this.getRegistryContractAddress(),function:"verifyWarp",gasLimit:BigInt(1e7),arguments:[g.fromHex(t)]})}createWarpTransferOwnershipTransaction(t,e){if(!this.config.user?.wallet)throw new Error("WarpRegistry: user address not set");let r=T.newFromBech32(this.config.user.wallet);return this.getFactory().createTransactionForExecute(r,{contract:this.getRegistryContractAddress(),function:"transferOwnership",gasLimit:BigInt(1e7),arguments:[g.fromHex(t),new nt(new T(e))]})}createBrandRegisterTransaction(t){if(this.registryConfig.unitPrice===BigInt(0))throw new Error("WarpRegistry: config not loaded. forgot to call init()?");if(!this.config.user?.wallet)throw new Error("WarpRegistry: user address not set");let e=T.newFromBech32(this.config.user.wallet);return this.getFactory().createTransactionForExecute(e,{contract:this.getRegistryContractAddress(),function:"registerBrand",gasLimit:BigInt(1e7),nativeTransferAmount:this.isCurrentUserAdmin()?void 0:this.registryConfig.unitPrice,arguments:[g.fromHex(t)]})}createWarpBrandingTransaction(t,e){if(!this.config.user?.wallet)throw new Error("WarpRegistry: user address not set");let r=T.newFromBech32(this.config.user.wallet);return this.getFactory().createTransactionForExecute(r,{contract:this.getRegistryContractAddress(),function:"brandWarp",gasLimit:BigInt(1e7),nativeTransferAmount:this.isCurrentUserAdmin()?void 0:this.registryConfig.unitPrice,arguments:[g.fromHex(t),g.fromHex(e)]})}async getInfoByAlias(t,e){try{let r=V.RegistryInfo(this.config.env,t),n=e?this.cache.get(r):null;if(n)return F.info(`WarpRegistry (getInfoByAlias): RegistryInfo found in cache: ${t}`),n;let s=this.getRegistryContractAddress(),o=this.getController(),a=o.createQuery({contract:s,function:"getInfoByAlias",arguments:[g.fromUTF8(t)]}),u=await o.runQuery(a),[c]=o.parseQueryResponse(u),p=c?U(c):null,l=p?.brand?await this.fetchBrand(p.brand):null;return e&&e.ttl&&this.cache.set(r,{registryInfo:p,brand:l},e.ttl),{registryInfo:p,brand:l}}catch{return{registryInfo:null,brand:null}}}async getInfoByHash(t,e){try{let r=V.RegistryInfo(this.config.env,t);if(e){let l=this.cache.get(r);if(l)return F.info(`WarpRegistry (getInfoByHash): RegistryInfo found in cache: ${t}`),l}let n=this.getRegistryContractAddress(),s=this.getController(),o=s.createQuery({contract:n,function:"getInfoByHash",arguments:[g.fromHex(t)]}),a=await s.runQuery(o),[u]=s.parseQueryResponse(a),c=u?U(u):null,p=c?.brand?await this.fetchBrand(c.brand):null;return e&&e.ttl&&this.cache.set(r,{registryInfo:c,brand:p},e.ttl),{registryInfo:c,brand:p}}catch{return{registryInfo:null,brand:null}}}async getUserWarpRegistryInfos(t){try{let e=t||this.config.user?.wallet;if(!e)throw new Error("WarpRegistry: user address not set");let r=this.getRegistryContractAddress(),n=this.getController(),s=n.createQuery({contract:r,function:"getUserWarps",arguments:[new nt(new T(e))]}),o=await n.runQuery(s),[a]=n.parseQueryResponse(o);return a.map(U)}catch{return[]}}async getUserBrands(t){try{let e=t||this.config.user?.wallet;if(!e)throw new Error("WarpRegistry: user address not set");let r=this.getRegistryContractAddress(),n=this.getController(),s=n.createQuery({contract:r,function:"getUserBrands",arguments:[new nt(new T(e))]}),o=await n.runQuery(s),[a]=n.parseQueryResponse(o),u=a.map(l=>l.toString("hex")),c={ttl:365*24*60*60};return(await Promise.all(u.map(l=>this.fetchBrand(l,c)))).filter(l=>l!==null)}catch{return[]}}async getChainInfos(t){let e=V.ChainInfos(this.config.env);if(t&&t.ttl){let c=this.cache.get(e);if(c)return F.info("WarpRegistry (getChainInfos): ChainInfos found in cache"),c}let r=this.getRegistryContractAddress(),n=this.getController(),s=n.createQuery({contract:r,function:"getChains",arguments:[]}),o=await n.runQuery(s),[a]=n.parseQueryResponse(o),u=a.map(Gt);if(t&&t.ttl){for(let c of u)this.cache.set(V.ChainInfo(this.config.env,c.chain),c,t.ttl);this.cache.set(e,u,t.ttl)}return u}async getChainInfo(t,e){try{let r=V.ChainInfo(this.config.env,t),n=e?this.cache.get(r):null;if(n)return F.info(`WarpRegistry (getChainInfo): ChainInfo found in cache: ${t}`),n;let s=this.getRegistryContractAddress(),o=this.getController(),a=o.createQuery({contract:s,function:"getChain",arguments:[g.fromUTF8(t)]}),u=await o.runQuery(a),[c]=o.parseQueryResponse(u),p=c?Gt(c):null;return e&&e.ttl&&p&&this.cache.set(r,p,e.ttl),p}catch{return null}}async setChain(t){if(!this.config.user?.wallet)throw new Error("WarpRegistry: user address not set");let e=T.newFromBech32(this.config.user.wallet);return this.getFactory().createTransactionForExecute(e,{contract:this.getRegistryContractAddress(),function:"setChain",gasLimit:BigInt(1e7),arguments:[v(t.name),v(t.displayName),v(t.chainId),Ut(t.blockTime),v(t.addressHrp),v(t.apiUrl),v(t.explorerUrl),v(t.nativeToken)]})}async removeChain(t){if(!this.config.user?.wallet)throw new Error("WarpRegistry: user address not set");let e=T.newFromBech32(this.config.user.wallet);return this.getFactory().createTransactionForExecute(e,{contract:this.getRegistryContractAddress(),function:"removeChain",gasLimit:BigInt(1e7),arguments:[v(t)]})}async fetchBrand(t,e){let r=V.Brand(this.config.env,t),n=e?this.cache.get(r):null;if(n)return F.info(`WarpRegistry (fetchBrand): Brand found in cache: ${t}`),n;let s=at(this.config),a=m.getChainEntrypoint(s,this.config.env).createNetworkProvider();try{let u=await a.getTransaction(t),c=JSON.parse(u.data.toString());return c.meta={hash:u.hash,creator:u.sender.bech32(),createdAt:new Date(u.timestamp*1e3).toISOString()},e&&e.ttl&&this.cache.set(r,c,e.ttl),c}catch{return null}}getRegistryContractAddress(){return T.newFromBech32(this.config.registry?.contract||er.Registry.Contract(this.config.env))}async loadRegistryConfigs(){let t=this.getRegistryContractAddress(),e=this.getController(),[r]=await e.query({contract:t,function:"getConfig",arguments:[]}),n=r?Dt(r):null;this.registryConfig=n||{unitPrice:BigInt(0),admins:[]}}getFactory(){let t=at(this.config),e=new Ze({chainID:t.chainId}),r=jt.create(rt);return new Ye({config:e,abi:r})}getController(){let t=at(this.config),e=m.getChainEntrypoint(t,this.config.env),r=jt.create(rt);return e.createSmartContractController(r)}isCurrentUserAdmin(){return!!this.config.user?.wallet&&this.registryConfig.admins.includes(this.config.user.wallet)}};var ha=i=>({chain:"multiversx",builder:new N(i),executor:new m(i),results:new E(i),serializer:new x,registry:new $(i)});import{Address as Kt,TransactionsFactoryConfig as rr,TransferTransactionsFactory as nr}from"@multiversx/sdk-core";import{getMainChainInfo as qt,WarpBrandBuilder as ar,WarpLogger as ir}from"@vleap/warps";import{Buffer as sr}from"buffer";var Jt=class{constructor(t){this.config=t,this.core=new ar(t)}createInscriptionTransaction(t){if(!this.config.user?.wallet)throw new Error("BrandBuilder: user address not set");let e=qt(this.config),r=new rr({chainID:e.chainId}),n=new nr({config:r}),s=Kt.newFromBech32(this.config.user.wallet),o=JSON.stringify(t);return n.createTransactionForNativeTokenTransfer(s,{receiver:Kt.newFromBech32(this.config.user.wallet),nativeAmount:BigInt(0),data:Uint8Array.from(sr.from(o))})}async createFromTransaction(t,e=!1){return await this.core.createFromRaw(t.data.toString(),e)}async createFromTransactionHash(t){let e=qt(this.config),n=m.getChainEntrypoint(e,this.config.env).createNetworkProvider();try{let s=await n.getTransaction(t);return this.createFromTransaction(s)}catch(s){return ir.error("BrandBuilder: Error creating from transaction hash",s),null}}};export{B as WarpMultiversxAbi,Jt as WarpMultiversxBrandBuilder,N as WarpMultiversxBuilder,or as WarpMultiversxConstants,O as WarpMultiversxContractLoader,m as WarpMultiversxExecutor,$ as WarpMultiversxRegistry,E as WarpMultiversxResults,x as WarpMultiversxSerializer,dn as address_value,fn as biguint_value,gn as boolean_value,hn as codemeta_value,cn as composite_value,$t as esdt_value,ha as getMultiversxAdapter,mn as hex_value,sn as list_value,wn as nothing_value,nn as option_value,an as optional_value,v as string_value,yn as token_value,pn as u16_value,Ut as u32_value,ln as u64_value,un as u8_value,on as variadic_value};
|
|
1
|
+
import{WarpChainName as Et}from"@vleap/warps";import{WarpChainName as D}from"@vleap/warps";import{WarpTypeRegistry as _r}from"@vleap/warps";import{AbiRegistry as pe,Address as kt,TransactionsFactoryConfig as Ft,TransferTransactionsFactory as Rt}from"@multiversx/sdk-core";import{getLatestProtocolIdentifier as Mt,getWarpWalletAddressFromConfig as Ot,WarpCache as Lt,WarpCacheKey as Dt,WarpConstants as De,WarpLogger as _e}from"@vleap/warps";import{DevnetEntrypoint as Pt,MainnetEntrypoint as Nt,TestnetEntrypoint as Vt}from"@multiversx/sdk-core";import{getProviderConfig as Ut}from"@vleap/warps";var k=i=>!i.includes("-"),_=i=>k(i)?`${i}-000000`:i,v=(i,e,t)=>{let r="warp-sdk",a=t?Ut(t,i.name,e,i.defaultApiUrl):{url:i.defaultApiUrl},s=a.url,o={headers:a.headers};return e==="devnet"?new Pt({url:s,kind:"api",clientName:r,networkProviderConfig:o}):e==="testnet"?new Vt({url:s,kind:"api",clientName:r,networkProviderConfig:o}):new Nt({url:s,kind:"api",clientName:r,networkProviderConfig:o})};import{WarpLogger as Le}from"@vleap/warps";var G=class{constructor(e){this.config=e}async getContract(e,t){try{let a=await v(t,this.config.env,this.config).createNetworkProvider().doGetGeneric(`accounts/${e}`);return{address:e,owner:a.ownerAddress,verified:a.isVerified||!1}}catch(r){return Le.error("WarpContractLoader: getContract error",r),null}}async getVerificationInfo(e,t){try{let a=await v(t,this.config.env,this.config).createNetworkProvider().doGetGeneric(`accounts/${e}/verification`);return{codeHash:a.codeHash,abi:a.source.abi}}catch(r){return Le.error("WarpContractLoader: getVerificationInfo error",r),null}}};var B=class{constructor(e,t){this.config=e;this.chain=t;this.contractLoader=new G(this.config),this.cache=new Lt(this.config.cache?.type)}async createInscriptionTransaction(e){let t=Ot(this.config,this.chain.name);if(!t)throw new Error("WarpBuilder: user address not set");let r=new Ft({chainID:this.chain.chainId}),n=new Rt({config:r}),a=kt.newFromBech32(t),s={protocol:Mt("abi"),content:e},o=JSON.stringify(s),c=await n.createTransactionForTransfer(a,{receiver:a,nativeAmount:BigInt(0),data:Uint8Array.from(Buffer.from(o))});return c.gasLimit=c.gasLimit+BigInt(2e6),c}async createFromRaw(e){return JSON.parse(e)}async createFromTransaction(e){let t=await this.createFromRaw(e.data.toString());return t.meta={chain:this.chain.name,hash:e.hash,creator:e.sender.toBech32(),createdAt:new Date(e.timestamp*1e3).toISOString()},t}async createFromTransactionHash(e,t){let r=Dt.WarpAbi(this.config.env,e);if(t){let s=this.cache.get(r);if(s)return _e.info(`WarpAbiBuilder (createFromTransactionHash): Warp abi found in cache: ${e}`),s}let a=v(this.chain,this.config.env,this.config).createNetworkProvider();try{let s=await a.getTransaction(e),o=await this.createFromTransaction(s);return t&&t.ttl&&o&&this.cache.set(r,o,t.ttl),o}catch(s){return _e.error("WarpAbiBuilder: Error creating from transaction hash",s),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 pe.create(t.abi)}async fetchAbi(e){if(!e.abi)throw new Error("WarpActionExecutor: ABI not found");if(e.abi.startsWith(De.IdentifierType.Hash)){let t=e.abi.split(De.ArgParamsSeparator)[1],r=await this.createFromTransactionHash(t);if(!r)throw new Error(`WarpActionExecutor: ABI not found for hash: ${e.abi}`);return pe.create(r.content)}else{let r=await(await fetch(e.abi)).json();return pe.create(r)}}};import{Address as Ge,TransactionsFactoryConfig as _t,TransferTransactionsFactory as Gt}from"@multiversx/sdk-core";import{getWarpWalletAddressFromConfig as Ht,WarpBrandBuilder as $t,WarpLogger as zt}from"@vleap/warps";import{Buffer as Kt}from"buffer";var H=class{constructor(e,t){this.config=e;this.chain=t;this.core=new $t(e)}async createInscriptionTransaction(e){let t=Ht(this.config,this.chain.name);if(!t)throw new Error("BrandBuilder: user address not set");let r=new _t({chainID:this.chain.chainId}),n=new Gt({config:r}),a=Ge.newFromBech32(t),s=JSON.stringify(e);return await n.createTransactionForNativeTokenTransfer(a,{receiver:Ge.newFromBech32(t),nativeAmount:BigInt(0),data:Uint8Array.from(Kt.from(s))})}async createFromTransaction(e,t=!1){let r=await this.core.createFromRaw(e.data.toString(),t);return r.meta={chain:this.chain.name,hash:e.hash,creator:e.sender.toBech32(),createdAt:new Date(e.timestamp*1e3).toISOString()},r}async createFromTransactionHash(e){let r=v(this.chain,this.config.env,this.config).createNetworkProvider();try{let n=await r.getTransaction(e);return this.createFromTransaction(n)}catch(n){return zt.error("BrandBuilder: Error creating from transaction hash",n),null}}};import{Address as He,TransactionsFactoryConfig as qt,TransferTransactionsFactory as Qt}from"@multiversx/sdk-core";import{getWarpWalletAddressFromConfig as jt,WarpBuilder as $e,WarpCache as Xt,WarpCacheKey as Jt,WarpLogger as ze}from"@vleap/warps";var $=class extends $e{constructor(t,r){super(t);this.config=t;this.chain=r;this.cache=new Xt(t.cache?.type),this.core=new $e(t)}async createInscriptionTransaction(t){let r=jt(this.config,this.chain.name);if(!r)throw new Error("WarpBuilder: user address not set");let n=new qt({chainID:this.chain.chainId}),a=new Qt({config:n}),s=He.newFromBech32(r),o=JSON.stringify(t),c=await a.createTransactionForTransfer(s,{receiver:He.newFromBech32(r),nativeAmount:BigInt(0),data:Uint8Array.from(Buffer.from(o))});return c.gasLimit=c.gasLimit+BigInt(2e6),c}async createFromTransaction(t,r=!1){let n=await this.core.createFromRaw(t.data.toString(),r);return n.meta={chain:this.chain.name,hash:t.hash,creator:t.sender.toBech32(),createdAt:new Date(t.timestamp*1e3).toISOString()},n}async createFromTransactionHash(t,r){let n=Jt.Warp(this.config.env,t);if(r){let o=this.cache.get(n);if(o)return ze.info(`WarpBuilder (createFromTransactionHash): Warp found in cache: ${t}`),o}let s=v(this.chain,this.config.env,this.config).createNetworkProvider();try{let o=await s.getTransaction(t),c=await this.createFromTransaction(o);return r&&r.ttl&&c&&this.cache.set(n,c,r.ttl),c}catch(o){return ze.error("WarpBuilder: Error creating from transaction hash",o),null}}};import{Address as le,Token as rr,TokenComputer as nr}from"@multiversx/sdk-core";import{CacheTtl as ar,WarpCache as sr,WarpCacheKey as ir}from"@vleap/warps";import{WarpChainName as Yt}from"@vleap/warps";var Ke=Yt.Multiversx,qe=[{chain:Ke,identifier:"EGLD",name:"eGold",symbol:"EGLD",decimals:18,logoUrl:"https://tools.multiversx.com/assets-cdn/tokens/EGLD-000000/icon.png"},{chain:Ke,identifier:"EGLD-000000",name:"eGold",symbol:"EGLD",decimals:18,logoUrl:"https://tools.multiversx.com/assets-cdn/tokens/EGLD-000000/icon.png"}];import{WarpChainName as Zt}from"@vleap/warps";var x=Zt.Multiversx,Qe=[{chain:x,identifier:"EGLD",name:"eGold",symbol:"EGLD",decimals:18,logoUrl:"https://tools.multiversx.com/assets-cdn/tokens/EGLD-000000/icon.png"},{chain:x,identifier:"EGLD-000000",name:"eGold",symbol:"EGLD",decimals:18,logoUrl:"https://tools.multiversx.com/assets-cdn/tokens/EGLD-000000/icon.png"},{chain:x,identifier:"SEGLD-3ad2d0",name:"StakedEGLD",symbol:"SEGLD",decimals:18,logoUrl:"https://tools.multiversx.com/assets-cdn/tokens/SEGLD-3ad2d0/icon.png"},{chain:x,identifier:"HSEGLD-c13a4e",name:"HatomSEGLD",symbol:"HSEGLD",decimals:8,logoUrl:"https://tools.multiversx.com/assets-cdn/tokens/HSEGLD-c13a4e/icon.png"},{chain:x,identifier:"UTK-2f80e9",name:"xMoney UTK",symbol:"UTK",decimals:18,logoUrl:"https://tools.multiversx.com/assets-cdn/tokens/UTK-2f80e9/icon.png"},{chain:x,identifier:"USDC-c76f1f",name:"WrappedUSDC",symbol:"USDC",decimals:6,logoUrl:"https://tools.multiversx.com/assets-cdn/tokens/USDC-c76f1f/icon.png"},{chain:x,identifier:"WEGLD-bd4d79",name:"WrappedEGLD",symbol:"WEGLD",decimals:18,logoUrl:"https://tools.multiversx.com/assets-cdn/tokens/WEGLD-bd4d79/icon.png"},{chain:x,identifier:"HTM-f51d55",name:"Hatom",symbol:"HTM",decimals:18,logoUrl:"https://tools.multiversx.com/assets-cdn/tokens/HTM-f51d55/icon.png"},{chain:x,identifier:"MEX-455c57",name:"MEX",symbol:"MEX",decimals:18,logoUrl:"https://tools.multiversx.com/assets-cdn/tokens/MEX-455c57/icon.png"},{chain:x,identifier:"WTAO-4f5363",name:"WrappedTAO",symbol:"WTAO",decimals:9,logoUrl:"https://tools.multiversx.com/assets-cdn/tokens/WTAO-4f5363/icon.png"},{chain:x,identifier:"HEGLD-d61095",name:"HatomEGLD",symbol:"HEGLD",decimals:8,logoUrl:"https://tools.multiversx.com/assets-cdn/tokens/HEGLD-d61095/icon.png"},{chain:x,identifier:"WBTC-5349b3",name:"WrappedBTC",symbol:"WBTC",decimals:8,logoUrl:"https://tools.multiversx.com/assets-cdn/tokens/WBTC-5349b3/icon.png"},{chain:x,identifier:"WETH-b4ca29",name:"WrappedETH",symbol:"WETH",decimals:18,logoUrl:"https://tools.multiversx.com/assets-cdn/tokens/WETH-b4ca29/icon.png"},{chain:x,identifier:"USH-111e09",name:"HatomUSD",symbol:"USH",decimals:18,logoUrl:"https://tools.multiversx.com/assets-cdn/tokens/USH-111e09/icon.png"},{chain:x,identifier:"USDT-f8c08c",name:"WrappedUSDT",symbol:"USDT",decimals:6,logoUrl:"https://tools.multiversx.com/assets-cdn/tokens/USDT-f8c08c/icon.png"}];import{WarpChainName as er}from"@vleap/warps";var je=er.Multiversx,Xe=[{chain:je,identifier:"EGLD",name:"eGold",symbol:"EGLD",decimals:18,logoUrl:"https://tools.multiversx.com/assets-cdn/tokens/EGLD-000000/icon.png"},{chain:je,identifier:"EGLD-000000",name:"eGold",symbol:"EGLD",decimals:18,logoUrl:"https://tools.multiversx.com/assets-cdn/tokens/EGLD-000000/icon.png"}];import{WarpChainName as tr}from"@vleap/warps";var Je=tr.Vibechain,z=[{chain:Je,identifier:"VIBE",name:"VIBE",symbol:"VIBE",decimals:18,logoUrl:"https://vleap.ai/images/tokens/vibe.svg"},{chain:Je,identifier:"VIBE-000000",name:"VIBE",symbol:"VIBE",decimals:18,logoUrl:"https://vleap.ai/images/tokens/vibe.svg"}];var Ye={multiversx:{mainnet:Qe,testnet:Xe,devnet:qe},vibechain:{mainnet:z,testnet:z,devnet:z}},Ze=(i,e,t)=>(Ye[i]?.[e]||[]).find(n=>n.identifier===t)||null,Ea=(i,e)=>Ye[i]?.[e]||[];var K=class{constructor(e,t){this.config=e;this.chain=t;this.cache=new sr(e.cache?.type)}async getAccount(e){let r=await v(this.chain,this.config.env,this.config).createNetworkProvider().getAccount(le.newFromBech32(e));return{chain:this.chain.name,address:r.address.toBech32(),balance:r.balance}}async getAccountAssets(e){let t=v(this.chain,this.config.env,this.config).createNetworkProvider(),r=t.getAccount(le.newFromBech32(e)),n=t.getFungibleTokensOfAccount(le.newFromBech32(e)),[a,s]=await Promise.all([r,n]),o=a.balance>0?[{...this.chain.nativeToken,amount:a.balance}]:[];return o.push(...s.map(c=>({chain:this.chain.name,identifier:c.token.identifier,name:c.raw.name,symbol:c.raw.ticker,amount:c.amount,decimals:c.raw.decimals,logoUrl:c.raw.assets?.pngUrl||"",price:c.raw.price?Number(c.raw.price):void 0,supply:c.raw.supply?BigInt(c.raw.supply):void 0}))),o}async getAsset(e){let t=ir.Asset(this.config.env,this.chain.name,e),r=this.cache.get(t);if(r)return r;let n=Ze(this.chain.name,this.config.env,e);if(n)return{chain:this.chain.name,identifier:e,name:n.name,symbol:n.symbol,amount:0n,decimals:n.decimals,logoUrl:n.logoUrl};let a=new nr,s=k(e)?0n:a.extractNonceFromExtendedIdentifier(e),o=new rr({identifier:e,nonce:BigInt(s||0)}),c=a.isFungible(o),d=v(this.chain,this.config.env,this.config).createNetworkProvider(),m=_(e),l=await d.doGetGeneric(`tokens/${m}`),y={chain:this.chain.name,identifier:o.identifier,name:l.name,symbol:l.ticker,amount:0n,decimals:l.decimals,logoUrl:l.assets?.pngUrl||null,price:l.price?Number(l.price):void 0,supply:l.supply?BigInt(l.supply):void 0};return this.cache.set(t,y,ar.OneHour),y}async getAction(e,t=!1){let r=v(this.chain,this.config.env,this.config),n=t?await r.awaitCompletedTransaction(e):await r.getTransaction(e);return{chain:this.chain.name,id:n.hash,receiver:n.receiver.toBech32(),sender:n.sender.toBech32(),value:n.value,function:n.function,status:this.toActionStatus(n),createdAt:this.toActionCreatedAt(n),error:n?.smartContractResults.map(a=>a.raw.returnMessage)[0]||null,tx:n}}async getAccountActions(e,t){let r=v(this.chain,this.config.env,this.config).createNetworkProvider(),n=`accounts/${e}/transactions`,a=new URLSearchParams,s=t?.size||25,o=t?.page||0;if(o>0){let d=o*s;a.append("from",d.toString())}return s!==25&&a.append("size",s.toString()),a.toString()&&(n+=`?${a.toString()}`),(await r.doGetGeneric(n)).map(d=>({chain:this.chain.name,id:d.txHash,receiver:d.receiver,sender:d.sender,value:d.value,function:d.function,status:this.toActionStatus(d),createdAt:this.toActionCreatedAt(d)}))}toActionStatus(e){return e.status.isSuccessful()?"success":e.status.isFailed()?"failed":"pending"}toActionCreatedAt(e){return new Date(e.timestamp||e.timestamp*1e3).toISOString()}};import{Address as L,ArgSerializer as xr,SmartContractTransactionsFactory as Ar,Token as Er,TokenComputer as br,TokenTransfer as Sr,TransactionsFactoryConfig as yt,TransferTransactionsFactory as Ir}from"@multiversx/sdk-core";import{applyResultsToMessages as Br,getNextInfo as Pr,getWarpActionByIndex as Ee,getWarpWalletAddressFromConfig as be}from"@vleap/warps";import{findEventsByFirstTopic as hr,SmartContractTransactionsOutcomeParser as gr,TransactionEventsParser as fr}from"@multiversx/sdk-core";import{applyResultsToMessages as yr,evaluateResultsCommon as ee,getNextInfo as vr,getWarpActionByIndex as Tr,getWarpWalletAddressFromConfig as wr,parseResultsOutIndex as gt,WarpCache as Wr,WarpCacheKey as Cr,WarpConstants as ft}from"@vleap/warps";import{Address as pr,AddressType as ue,AddressValue as tt,BigUIntType as q,BigUIntValue as me,BooleanType as de,BooleanValue as rt,BytesType as he,BytesValue as nt,CodeMetadata as lr,CodeMetadataType as ge,CodeMetadataValue as at,CompositeType as fe,CompositeValue as st,Field as Q,FieldDefinition as j,List as it,ListType as ot,NothingValue as b,OptionalType as ct,OptionalValue as ye,OptionType as pt,OptionValue as ve,StringType as Te,StringValue as lt,Struct as X,StructType as V,Token as ur,TokenComputer as ut,TokenIdentifierType as J,TokenIdentifierValue as we,U16Type as We,U16Value as mt,U32Type as Ce,U32Value as dt,U64Type as Y,U64Value as xe,U8Type as Ae,U8Value as ht,VariadicType as O,VariadicValue as Z}from"@multiversx/sdk-core";import{WarpSerializer as mr}from"@vleap/warps";var u={HttpProtocolPrefix:"http",IdentifierParamName:"warp",IdentifierParamSeparator:":",IdentifierChainDefault:"multiversx",IdentifierType:{Alias:"alias",Hash:"hash"},IdentifierAliasMarker:"@",Globals:{UserWallet:{Placeholder:"USER_WALLET",Accessor:i=>i.config.user?.wallets?.[i.chain.name]},ChainApiUrl:{Placeholder:"CHAIN_API",Accessor:i=>i.chain.defaultApiUrl},ChainAddressHrp:{Placeholder:"CHAIN_ADDRESS_HRP",Accessor:i=>i.chain.addressHrp}},Vars:{Query:"query",Env:"env"},ArgParamsSeparator:":",ArgCompositeSeparator:"|",ArgListSeparator:",",ArgStructSeparator:";",Transform:{Prefix:"transform:"},Source:{UserWallet:"user:wallet"},Position:{Payload:"payload:"},Alerts:{TriggerEventPrefix:"event"}},p={Option:"option",Vector:"vector",Tuple:"tuple",Struct:"struct",String:"string",Uint8:"uint8",Uint16:"uint16",Uint32:"uint32",Uint64:"uint64",Uint128:"uint128",Uint256:"uint256",Biguint:"biguint",Bool:"bool",Address:"address",Asset:"asset",Hex:"hex"};var Ga={Egld:{Identifier:"EGLD",EsdtIdentifier:"EGLD-000000",DisplayName:"eGold",Decimals:18}},g={Null:"null",Optional:"optional",List:"list",Token:"token",CodeMeta:"codemeta"},or=(r=>(r.MultiversxExplorer="multiversx_explorer",r.MultiversxExplorerDevnet="multiversx_explorer_devnet",r.MultiversxExplorerTestnet="multiversx_explorer_testnet",r))(or||{}),cr=(r=>(r.VibechainExplorer="vibechain_explorer",r.VibechainExplorerDevnet="vibechain_explorer_devnet",r.VibechainExplorerTestnet="vibechain_explorer_testnet",r))(cr||{}),et={multiversx:{mainnet:["multiversx_explorer"],testnet:["multiversx_explorer_testnet"],devnet:["multiversx_explorer_devnet"]},vibechain:{mainnet:["vibechain_explorer"],testnet:["vibechain_explorer_testnet"],devnet:["vibechain_explorer_devnet"]}},N={multiversx_explorer:"https://explorer.multiversx.com",multiversx_explorer_devnet:"https://devnet-explorer.multiversx.com",multiversx_explorer_testnet:"https://testnet-explorer.multiversx.com",vibechain_explorer:"https://vibeox-explorer.multiversx.com",vibechain_explorer_devnet:"https://vibeox-explorer.multiversx.com",vibechain_explorer_testnet:"https://vibeox-explorer.multiversx.com"};var dr=new RegExp(`${u.ArgParamsSeparator}(.*)`),P=class{constructor(e){this.coreSerializer=new mr(e)}typedToString(e){let t=e.getType();if(t.hasExactClass(pt.ClassName)||e.hasClassOrSuperclass(ve.ClassName)){if(!e.isSet())return p.Option+u.ArgParamsSeparator+"null";let r=this.typedToString(e.getTypedValue());return p.Option+u.ArgParamsSeparator+r}if(t.hasExactClass(O.ClassName)||e.hasClassOrSuperclass(Z.ClassName)){let r=e.getItems();if(r.length===0){let m=this.typeToString(t.getFirstTypeParameter());return p.Vector+u.ArgParamsSeparator+m+u.ArgParamsSeparator}let n=r.map(m=>this.typedToString(m));if(n.every(m=>m.startsWith(p.Tuple)))return p.Vector+u.ArgParamsSeparator+n.join(",");let a=n[0],s=a.indexOf(u.ArgParamsSeparator),o=a.substring(0,s),c=n.map(m=>{let l=m.indexOf(u.ArgParamsSeparator);return m.substring(l+1)}),d=o.startsWith(p.Struct)?u.ArgStructSeparator:u.ArgListSeparator;return p.Vector+u.ArgParamsSeparator+o+u.ArgParamsSeparator+c.join(d)}if(t.hasExactClass(ct.ClassName)||e.hasClassOrSuperclass(ye.ClassName)){if(!e.isSet())return g.Optional+u.ArgParamsSeparator+"null";let r=this.typedToString(e.getTypedValue());return g.Optional+u.ArgParamsSeparator+r}if(t.hasExactClass(ot.ClassName)||e.hasClassOrSuperclass(it.ClassName)){let n=e.getItems().map(c=>this.typedToString(c));if(n.every(c=>c.startsWith(p.Tuple)))return g.List+u.ArgParamsSeparator+n.join(",");let s=n.map(c=>c.split(u.ArgParamsSeparator)[0])[0],o=n.map(c=>c.split(u.ArgParamsSeparator)[1]);return g.List+u.ArgParamsSeparator+s+u.ArgParamsSeparator+o.join(u.ArgListSeparator)}if(t.hasExactClass(fe.ClassName)||e.hasClassOrSuperclass(st.ClassName)){let n=e.getItems().map(a=>{let s=this.typedToString(a),o=s.indexOf(u.ArgParamsSeparator),c=s.substring(0,o),d=s.substring(o+1);return`${c},${d}`});return`${p.Tuple}(${n.join(",")})`}if(t.hasExactClass(q.ClassName)||e.hasClassOrSuperclass(me.ClassName)||t.getName()==="BigUint")return p.Biguint+u.ArgParamsSeparator+BigInt(e.valueOf().toFixed());if(t.hasExactClass(Ae.ClassName)||e.hasClassOrSuperclass(ht.ClassName))return p.Uint8+u.ArgParamsSeparator+e.valueOf().toNumber();if(t.hasExactClass(We.ClassName)||e.hasClassOrSuperclass(mt.ClassName))return p.Uint16+u.ArgParamsSeparator+e.valueOf().toNumber();if(t.hasExactClass(Ce.ClassName)||e.hasClassOrSuperclass(dt.ClassName))return p.Uint32+u.ArgParamsSeparator+e.valueOf().toNumber();if(t.hasExactClass(Y.ClassName)||e.hasClassOrSuperclass(xe.ClassName))return p.Uint64+u.ArgParamsSeparator+BigInt(e.valueOf().toFixed());if(t.hasExactClass(Te.ClassName)||e.hasClassOrSuperclass(lt.ClassName))return p.String+u.ArgParamsSeparator+e.valueOf();if(t.hasExactClass(de.ClassName)||e.hasClassOrSuperclass(rt.ClassName))return p.Bool+u.ArgParamsSeparator+e.valueOf();if(t.hasExactClass(ue.ClassName)||e.hasClassOrSuperclass(tt.ClassName))return p.Address+u.ArgParamsSeparator+e.valueOf().toBech32();if(t.hasExactClass(he.ClassName)||e.hasClassOrSuperclass(nt.ClassName))return p.Hex+u.ArgParamsSeparator+e.valueOf().toString("hex");if(t.getName()==="EsdtTokenPayment"){let r=e.getFieldValue("token_identifier").valueOf(),n=e.getFieldValue("token_nonce").valueOf(),a=e.getFieldValue("amount").valueOf(),o=new ut().computeExtendedIdentifier(new ur({identifier:r,nonce:BigInt(n)}));return p.Asset+u.ArgParamsSeparator+o+u.ArgCompositeSeparator+a}if(t.hasExactClass(V.ClassName)||e.hasClassOrSuperclass(X.ClassName)){let r=e,a=r.getType().getName(),s=r.getFields();if(s.length===0)return`${p.Struct}(${a})${u.ArgParamsSeparator}`;let o=s.map(c=>{let d=c.value.getType(),l=this.typedToString(c.value).split(u.ArgParamsSeparator),y=l.length>2?l.slice(2).join(u.ArgParamsSeparator):l[1]||"";return`(${c.name}${u.ArgParamsSeparator}${this.typeToString(d)})${y}`});return`${p.Struct}(${a})${u.ArgParamsSeparator}${o.join(u.ArgListSeparator)}`}if(t.hasExactClass(J.ClassName)||e.hasClassOrSuperclass(we.ClassName))return g.Token+u.ArgParamsSeparator+e.valueOf();if(t.hasExactClass(ge.ClassName)||e.hasClassOrSuperclass(at.ClassName))return g.CodeMeta+u.ArgParamsSeparator+e.valueOf().toString();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){if(e.startsWith(p.Tuple))return this.stringToTyped(e+":");let r=this.coreSerializer.nativeToString(e,t);return this.stringToTyped(r)}nativeToType(e){if(e.startsWith(p.Tuple)){let t=e.match(/\(([^)]+)\)/)?.[1];if(!t)throw new Error(`Invalid tuple type format: ${e}`);let r=t.split(","),n=[];for(let a=0;a<r.length;a+=2)n.push(r[a]);return new fe(...n.map(a=>this.nativeToType(a)))}if(e.startsWith(p.Struct)){let t=e.match(/\(([^)]+)\)/);if(!t)throw new Error("Struct type must include a name in the format struct(Name)");let r=t[1];return new V(r,[])}if(e===p.String)return new Te;if(e===p.Uint8)return new Ae;if(e===p.Uint16)return new We;if(e===p.Uint32)return new Ce;if(e===p.Uint64)return new Y;if(e===p.Biguint)return new q;if(e===p.Bool)return new de;if(e===p.Address)return new ue;if(e===p.Hex)return new he;if(e===p.Asset)return new V("EsdtTokenPayment",[new j("token_identifier","",new J),new j("token_nonce","",new Y),new j("amount","",new q)]);if(e===g.Token)return new J;if(e===g.CodeMeta)return new ge;throw new Error(`WarpArgSerializer (nativeToType): Unsupported input type: ${e}`)}stringToTyped(e){let[t,r]=e.split(/:(.*)/,2);if(t===p.Option){let n=this.stringToTyped(r);return n instanceof b?ve.newMissingTyped(n.getType()):ve.newProvided(n)}if(t===p.Vector){let n=r.indexOf(u.ArgParamsSeparator),a=r.substring(0,n),s=r.substring(n+1);if(a.startsWith(p.Tuple)){let l=s.split(",").map(y=>this.stringToTyped(y));return new Z(new O(this.nativeToType(a)),l)}if(s.includes("tuple(")){let m=this.splitTupleStrings(s),l=m.map(w=>this.stringToTyped(w)),C=m[0].match(/^(tuple\([^)]+\))/),h=C?C[1]:"tuple";return new Z(new O(this.nativeToType(h)),l)}let o=a.startsWith(p.Struct)?u.ArgStructSeparator:u.ArgListSeparator,d=s.split(o).map(m=>this.stringToTyped(`${a}:${m}`));return new Z(new O(this.nativeToType(a)),d)}if(t.startsWith(p.Tuple)){let n=t.match(/\(([^)]+)\)/)?.[1];if(!n)throw new Error(`Invalid tuple format: ${t}`);let a=n.split(","),s=[];for(let c=0;c<a.length;c+=2){let d=a[c],m=a[c+1];s.push(this.stringToTyped(`${d}:${m}`))}let o=s.map(c=>c.getType());return new st(new fe(...o),s)}if(t.startsWith(p.Struct)){let n=t.match(/\(([^)]+)\)/),a=n?n[1]:"CustomStruct";if(!r)return new X(new V(a,[]),[]);let s=r.split(u.ArgListSeparator),o=[],c=[];return s.forEach(d=>{let m=d.match(new RegExp(`^\\(([^${u.ArgParamsSeparator}]+)${u.ArgParamsSeparator}([^)]+)\\)(.+)$`));if(m){let[,l,y,C]=m,h=this.stringToTyped(`${y}${u.ArgParamsSeparator}${C}`);o.push(new j(l,"",h.getType())),c.push(new Q(h,l))}}),new X(new V(a,o),c)}if(t===p.String)return r?lt.fromUTF8(r):new b;if(t===p.Uint8)return r?new ht(Number(r)):new b;if(t===p.Uint16)return r?new mt(Number(r)):new b;if(t===p.Uint32)return r?new dt(Number(r)):new b;if(t===p.Uint64)return r?new xe(BigInt(r)):new b;if(t===p.Biguint)return r?new me(BigInt(r)):new b;if(t===p.Bool)return r?new rt(typeof r=="boolean"?r:r==="true"):new b;if(t===p.Address)return r?new tt(pr.newFromBech32(r)):new b;if(t===p.Hex)return r?nt.fromHex(r):new b;if(t===p.Asset){let[n,a]=r.split(u.ArgCompositeSeparator),s=new ut,o=k(n)?_(n):s.extractIdentifierFromExtendedIdentifier(n),c=k(n)?0n:s.extractNonceFromExtendedIdentifier(n);return new X(this.nativeToType("asset"),[new Q(new we(o),"token_identifier"),new Q(new xe(BigInt(c)),"token_nonce"),new Q(new me(BigInt(a)),"amount")])}if(t===g.Null)return new b;if(t===g.Optional){let n=this.stringToTyped(r);return n instanceof b?ye.newMissing():new ye(n.getType(),n)}if(t===g.List){let[n,a]=r.split(dr,2),o=a.split(u.ArgListSeparator).map(c=>this.stringToTyped(n+u.ArgParamsSeparator+c));return new it(this.nativeToType(n),o)}if(t===g.Token)return r?new we(r):new b;if(t===g.CodeMeta)return new at(lr.newFromBytes(Uint8Array.from(Buffer.from(r,"hex"))));throw new Error(`WarpArgSerializer (stringToTyped): Unsupported input type: ${t}`)}splitTupleStrings(e){let t=[],r="",n=0;for(let a=0;a<e.length;a++){let s=e[a];if(s==="(")n++;else if(s===")")n--;else if(s===","&&n===0){t.push(r.trim()),r="";continue}r+=s}return r.trim()&&t.push(r.trim()),t}typeToString(e){if(e.hasExactClass(pt.ClassName))return p.Option+u.ArgParamsSeparator+this.typeToString(e.getFirstTypeParameter());if(e.hasExactClass(O.ClassName))return p.Vector+u.ArgParamsSeparator+this.typeToString(e.getFirstTypeParameter());if(e.hasExactClass(Te.ClassName))return p.String;if(e.hasExactClass(Ae.ClassName))return p.Uint8;if(e.hasExactClass(We.ClassName))return p.Uint16;if(e.hasExactClass(Ce.ClassName))return p.Uint32;if(e.hasExactClass(Y.ClassName))return p.Uint64;if(e.hasExactClass(q.ClassName))return p.Biguint;if(e.hasExactClass(de.ClassName))return p.Bool;if(e.hasExactClass(ue.ClassName))return p.Address;if(e.hasExactClass(he.ClassName))return p.Hex;if(e.hasExactClass(J.ClassName))return g.Token;if(e.hasExactClass(ct.ClassName))return g.Optional+u.ArgParamsSeparator+this.typeToString(e.getFirstTypeParameter());if(e.hasExactClass(ot.ClassName))return g.List+u.ArgParamsSeparator+this.typeToString(e.getFirstTypeParameter());if(e.hasExactClass(ge.ClassName))return g.CodeMeta;if(e.hasExactClass(V.ClassName)&&e.getClassName()==="EsdtTokenPayment")return p.Asset;if(e.hasExactClass(V.ClassName))return`${p.Struct}(${e.getName()})`;throw new Error(`WarpArgSerializer (typeToString): Unsupported input type: ${e.getClassName()}`)}};var F=class{constructor(e,t,r){this.config=e;this.chain=t;this.typeRegistry=r;this.abi=new B(e,t),this.serializer=new P({typeRegistry:this.typeRegistry}),this.cache=new Wr(e.cache?.type)}async getActionExecution(e,t,r){let n=this.cache.get(Cr.WarpExecutable(this.config.env,e.meta?.hash||"",t))??[],a=await this.extractContractResults(e,t,r,n),s=vr(this.config,[],e,t,a),o=yr(e,a.results);return{success:r.status.isSuccessful(),warp:e,action:t,user:wr(this.config,this.chain.name),txHash:r.hash,tx:r,next:s,values:a.values,results:a.results,messages:o}}async extractContractResults(e,t,r,n){let a=Tr(e,t),s=[],o=[],c={};if(!e.results||a.type!=="contract")return{values:{string:s,native:o},results:c};if(!Object.values(e.results).some(h=>h.includes("out")||h.includes("event"))){for(let[h,w]of Object.entries(e.results))c[h]=w;return{values:{string:s,native:o},results:await ee(e,c,t,n,this.serializer.coreSerializer,this.config.transform?.runner)}}let m=await this.abi.getAbiForAction(a),l=new fr({abi:m}),C=new gr({abi:m}).parseExecute({transactionOnNetwork:r,function:a.func||void 0});for(let[h,w]of Object.entries(e.results)){if(w.startsWith(ft.Transform.Prefix))continue;if(w.startsWith("input.")){c[h]=w;continue}let A=gt(w);if(A!==null&&A!==t){c[h]=null;continue}let[I,S,R]=w.split(".");if(I==="event"){if(!S||isNaN(Number(R)))continue;let U=Number(R),W=hr(r,S),Bt=l.parseEvents({events:W})[0],M=Object.values(Bt)[U]||null;s.push(String(M)),o.push(M),c[h]=M&&M.valueOf()}else if(I==="out"||I.startsWith("out[")){if(!S)continue;let U=Number(S),W=C.values[U-1]||null;R&&(W=W[R]||null),W&&typeof W=="object"&&(W="toFixed"in W?W.toFixed():W.valueOf()),s.push(String(W)),o.push(W),c[h]=W&&W.valueOf()}else c[h]=w}return{values:{string:s,native:o},results:await ee(e,c,t,n,this.serializer.coreSerializer)}}async extractQueryResults(e,t,r,n){let a=t.map(m=>this.serializer.typedToString(m)),s=t.map(m=>this.serializer.typedToNative(m)[1]),o={string:a,native:s},c={};if(!e.results)return{values:o,results:c};let d=m=>{let l=m.split(".").slice(1).map(C=>parseInt(C)-1);if(l.length===0)return;let y=s[l[0]];for(let C=1;C<l.length;C++){if(y==null)return;y=y[l[C]]}return y};for(let[m,l]of Object.entries(e.results)){if(l.startsWith(ft.Transform.Prefix))continue;let y=gt(l);if(y!==null&&y!==r){c[m]=null;continue}l.startsWith("out.")||l==="out"||l.startsWith("out[")?c[m]=d(l)||null:c[m]=l}return{values:o,results:await ee(e,c,r,n,this.serializer.coreSerializer)}}async resolveWarpResultsRecursively(e){let t=e.warp,r=e.entryActionIndex,n=e.executor,a=e.inputs,s=e.meta,o=new Map,c=new Set,d=this;async function m(h,w=[]){if(o.has(h))return o.get(h);if(c.has(h))throw new Error(`Circular dependency detected at action ${h}`);c.add(h);let A=t.actions[h-1];if(!A)throw new Error(`Action ${h} not found`);let I;if(A.type==="query")I=await n.executeQuery(t,h,w);else if(A.type==="collect")I=await n.executeCollect(t,h,w,s);else throw new Error(`Unsupported or interactive action type: ${A.type}`);if(o.set(h,I),t.results)for(let S of Object.values(t.results)){let U=String(S).match(/^out\[(\d+)\]/);if(U){let W=parseInt(U[1],10);W!==h&&!o.has(W)&&await m(W)}}return c.delete(h),I}await m(r,a);let l={};for(let h of o.values())for(let[w,A]of Object.entries(h.results))A!==null?l[w]=A:w in l||(l[w]=null);let y=await ee(t,l,r,a,this.serializer.coreSerializer,this.config.transform?.runner);return{...o.get(r),action:r,results:y}}};var Nr="EGLD-000000",te=class{constructor(e,t,r){this.config=e;this.chain=t;this.typeRegistry=r;this.serializer=new P({typeRegistry:this.typeRegistry}),this.abi=new B(this.config,this.chain),this.results=new F(this.config,this.chain,this.typeRegistry)}async createTransaction(e){let t=Ee(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=be(this.config,e.chain.name);if(!t)throw new Error("WarpMultiversxExecutor: createTransfer - user address not set");let r=L.newFromBech32(t),n=new yt({chainID:e.chain.chainId}),a=e.data?Buffer.from(this.serializer.stringToTyped(e.data).valueOf()):null,s=e.transfers.length===1&&e.transfers[0].identifier===this.chain.nativeToken?.identifier,c=(s?e.transfers[0].amount:0n)+e.value;return await new Ir({config:n}).createTransactionForTransfer(r,{receiver:L.newFromBech32(e.destination),nativeAmount:c,tokenTransfers:s?[]:this.toTokenTransfers(e.transfers),data:a?new Uint8Array(a):void 0})}async createContractCallTransaction(e){let t=be(this.config,e.chain.name);if(!t)throw new Error("WarpMultiversxExecutor: createContractCall - user address not set");let r=Ee(e.warp,e.action),n=L.newFromBech32(t),a=e.args.map(o=>this.serializer.stringToTyped(o)),s=new yt({chainID:e.chain.chainId});return new Ar({config:s}).createTransactionForExecute(n,{contract:L.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=Ee(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(S=>this.serializer.stringToTyped(S)),a=v(e.chain,this.config.env,this.config),s=L.newFromBech32(e.destination),o=a.createSmartContractController(r),c=o.createQuery({contract:s,function:t.func||"",arguments:n}),d=await o.runQuery(c),m=d.returnCode==="ok",l=new xr,y=r.getEndpoint(d.function||t.func||""),C=(d.returnDataParts||[]).map(S=>Buffer.from(S)),h=l.buffersToValues(C,y.output),{values:w,results:A}=await this.results.extractQueryResults(e.warp,h,e.action,e.resolvedInputs),I=Pr(this.config,[],e.warp,e.action,A);return{success:m,warp:e.warp,action:e.action,user:be(this.config,e.chain.name),txHash:null,tx:null,next:I,values:w,results:A,messages:Br(e.warp,A)}}toTokenTransfers(e){return e.map(t=>t.identifier===this.chain.nativeToken.identifier?{...t,identifier:Nr}:t).map(t=>{let n=new br().extractNonceFromExtendedIdentifier(t.identifier);return new Sr({token:new Er({identifier:t.identifier,nonce:BigInt(n||0)}),amount:t.amount})})}};var re=class{constructor(e,t){this.chain=e;this.config=t}getExplorers(){let e=et[this.chain];if(!e)return["multiversx_explorer"];let t=e[this.config.env];return t||["multiversx_explorer"]}getPrimaryExplorer(){return this.getExplorers()[0]}getExplorerUrlByName(e){let t=this.config.preferences?.explorers?.[this.chain];if(t&&!e){let a=N[t];if(a)return a}if(e){let a=N[e];if(a)return a}let r=this.getPrimaryExplorer();return N[r]||N[r]}getAccountUrl(e,t){return`${this.getExplorerUrlByName(t)}/accounts/${e}`}getTransactionUrl(e,t){return`${this.getExplorerUrlByName(t)}/transactions/${e}`}getBlockUrl(e,t){return`${this.getExplorerUrlByName(t)}/blocks/${e}`}getAssetUrl(e,t){return`${this.getExplorerUrlByName(t)}/tokens/${e}`}getContractUrl(e,t){return`${this.getExplorerUrlByName(t)}/accounts/${e}`}getAllExplorers(){return this.getExplorers()}getExplorerByName(e){return this.getExplorers().find(r=>r.toLowerCase()===e.toLowerCase())}getAccountUrls(e){let t=this.getAllExplorers(),r={};return t.forEach(n=>{let a=N[n];a&&(r[n]=`${a}/accounts/${e}`)}),r}getTransactionUrls(e){let t=this.getAllExplorers(),r={};return t.forEach(n=>{let a=N[n];a&&(r[n]=`${a}/transactions/${e}`)}),r}};import{AbiRegistry as Tt,Address as f,AddressValue as Ie,BytesValue as T,SmartContractTransactionsFactory as Ur,TransactionsFactoryConfig as kr}from"@multiversx/sdk-core";import{getWarpWalletAddressFromConfig as Fr,WarpCache as Rr,WarpCacheKey as Be,WarpLogger as Pe}from"@vleap/warps";var Se={buildInfo:{rustc:{version:"1.86.0",commitHash:"05f9846f893b09a1be1fc8560e33fc3c815cfecb",commitDate:"2025-03-31",channel:"Stable",short:"rustc 1.86.0 (05f9846f8 2025-03-31)"},contractCrate:{name:"registry",version:"0.0.1"},framework:{name:"multiversx-sc",version:"0.51.1"}},name:"RegistryContract",constructor:{inputs:[{name:"unit_price",type:"BigUint"},{name:"vault",type:"Address"}],outputs:[]},upgradeConstructor:{inputs:[],outputs:[]},endpoints:[{name:"registerWarp",mutability:"mutable",payableInTokens:["EGLD"],inputs:[{name:"hash",type:"bytes"},{name:"alias_opt",type:"optional<bytes>",multi_arg:!0},{name:"brand_opt",type:"optional<bytes>",multi_arg:!0}],outputs:[],allow_multiple_var_args:!0},{name:"unregisterWarp",mutability:"mutable",inputs:[{name:"warp",type:"bytes"}],outputs:[]},{name:"upgradeWarp",mutability:"mutable",payableInTokens:["EGLD"],inputs:[{name:"alias",type:"bytes"},{name:"new_warp",type:"bytes"},{name:"brand_opt",type:"optional<bytes>",multi_arg:!0}],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}]}],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:{ConfigView:{type:"struct",fields:[{name:"unit_price",type:"BigUint"},{name:"admins",type:"List<Address>"}]},InfoView:{type:"struct",fields:[{name:"hash",type:"bytes"},{name:"alias",type:"Option<bytes>"},{name:"trust",type:"bytes"},{name:"owner",type:"Address"},{name:"created_at",type:"u64"},{name:"upgraded_at",type:"u64"},{name:"brand",type:"Option<bytes>"},{name:"upgrade",type:"Option<bytes>"}]}}};var E=i=>{if(i==="devnet")return"erd1qqqqqqqqqqqqqpgqje2f99vr6r7sk54thg03c9suzcvwr4nfl3tsfkdl36";if(i==="testnet")throw new Error("Multiversx testnet is not supported");return"erd1qqqqqqqqqqqqqpgq3mrpj3u6q7tejv6d7eqhnyd27n9v5c5tl3ts08mffe"};var ne=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}),vt=i=>({unitPrice:BigInt(i.unit_price.toString()),admins:i.admins.map(e=>e.toBech32())});var ae=class{constructor(e,t){this.config=e;this.chain=t;this.cache=new Rr(e.cache?.type),this.registryConfig={unitPrice:BigInt(0),admins:[]},this.userWallet=Fr(this.config,this.chain.name)}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,s=()=>t&&r?[T.fromHex(e),T.fromUTF8(t),T.fromHex(r)]:t?[T.fromHex(e),T.fromUTF8(t)]:[T.fromHex(e)];return await this.getFactory().createTransactionForExecute(n,{contract:f.newFromBech32(E(this.config.env)),function:"registerWarp",gasLimit:BigInt(1e7),nativeTransferAmount:a(),arguments:s()})}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(E(this.config.env)),function:"unregisterWarp",gasLimit:BigInt(1e7),arguments:[T.fromHex(e)]})}async createWarpUpgradeTransaction(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);return await this.getFactory().createTransactionForExecute(n,{contract:f.newFromBech32(E(this.config.env)),function:"upgradeWarp",gasLimit:BigInt(1e7),nativeTransferAmount:this.isCurrentUserAdmin()?void 0:this.registryConfig.unitPrice,arguments:r?[T.fromUTF8(e),T.fromHex(t),T.fromHex(r)]:[T.fromUTF8(e),T.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(E(this.config.env)),function:"setWarpAlias",gasLimit:BigInt(1e7),nativeTransferAmount:this.isCurrentUserAdmin()?void 0:this.registryConfig.unitPrice,arguments:[T.fromHex(e),T.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(E(this.config.env)),function:"verifyWarp",gasLimit:BigInt(1e7),arguments:[T.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(E(this.config.env)),function:"transferOwnership",gasLimit:BigInt(1e7),arguments:[T.fromHex(e),new Ie(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(E(this.config.env)),function:"registerBrand",gasLimit:BigInt(1e7),nativeTransferAmount:this.isCurrentUserAdmin()?void 0:this.registryConfig.unitPrice,arguments:[T.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(E(this.config.env)),function:"brandWarp",gasLimit:BigInt(1e7),nativeTransferAmount:this.isCurrentUserAdmin()?void 0:this.registryConfig.unitPrice,arguments:[T.fromHex(e),T.fromHex(t)]})}async getInfoByAlias(e,t){try{let r=Be.RegistryInfo(this.config.env,e),n=t?this.cache.get(r):null;if(n)return Pe.info(`WarpRegistry (getInfoByAlias): RegistryInfo found in cache: ${e}`),n;let a=f.newFromBech32(E(this.config.env)),s=this.getController(),o=s.createQuery({contract:a,function:"getInfoByAlias",arguments:[T.fromUTF8(e)]}),c=await s.runQuery(o),[d]=s.parseQueryResponse(c),m=d?ne(d):null,l=m?.brand?await this.fetchBrand(m.brand):null;return t&&t.ttl&&this.cache.set(r,{registryInfo:m,brand:l},t.ttl),{registryInfo:m,brand:l}}catch{return{registryInfo:null,brand:null}}}async getInfoByHash(e,t){try{let r=Be.RegistryInfo(this.config.env,e);if(t){let l=this.cache.get(r);if(l)return Pe.info(`WarpRegistry (getInfoByHash): RegistryInfo found in cache: ${e}`),l}let n=f.newFromBech32(E(this.config.env)),a=this.getController(),s=a.createQuery({contract:n,function:"getInfoByHash",arguments:[T.fromHex(e)]}),o=await a.runQuery(s),[c]=a.parseQueryResponse(o),d=c?ne(c):null,m=d?.brand?await this.fetchBrand(d.brand):null;return t&&t.ttl&&this.cache.set(r,{registryInfo:d,brand:m},t.ttl),{registryInfo:d,brand:m}}catch{return{registryInfo:null,brand:null}}}async getUserWarpRegistryInfos(e){try{let t=e||this.userWallet;if(!t)throw new Error("WarpRegistry: user address not set");let r=f.newFromBech32(E(this.config.env)),n=this.getController(),a=n.createQuery({contract:r,function:"getUserWarps",arguments:[new Ie(new f(t))]}),s=await n.runQuery(a),[o]=n.parseQueryResponse(s);return o.map(ne)}catch{return[]}}async getUserBrands(e){try{let t=e||this.userWallet;if(!t)throw new Error("WarpRegistry: user address not set");let r=f.newFromBech32(E(this.config.env)),n=this.getController(),a=n.createQuery({contract:r,function:"getUserBrands",arguments:[new Ie(new f(t))]}),s=await n.runQuery(a),[o]=n.parseQueryResponse(s),c=o.map(l=>l.toString("hex")),d={ttl:365*24*60*60};return(await Promise.all(c.map(l=>this.fetchBrand(l,d)))).filter(l=>l!==null)}catch{return[]}}async fetchBrand(e,t){let r=Be.Brand(this.config.env,e),n=t?this.cache.get(r):null;if(n)return Pe.info(`WarpRegistry (fetchBrand): Brand found in cache: ${e}`),n;let s=v(this.chain,this.config.env,this.config).createNetworkProvider();try{let o=await s.getTransaction(e),c=JSON.parse(o.data.toString());return c.meta={chain:this.chain.name,hash:o.hash,creator:o.sender.toBech32(),createdAt:new Date(o.timestamp*1e3).toISOString()},t&&t.ttl&&this.cache.set(r,c,t.ttl),c}catch{return null}}async loadRegistryConfigs(){let e=f.newFromBech32(E(this.config.env)),t=this.getController(),[r]=await t.query({contract:e,function:"getConfig",arguments:[]}),n=r?vt(r):null;this.registryConfig=n||{unitPrice:BigInt(0),admins:[]}}getFactory(){let e=new kr({chainID:this.chain.chainId}),t=Tt.create(Se);return new Ur({config:e,abi:t})}getController(){let e=v(this.chain,this.config.env,this.config),t=Tt.create(Se);return e.createSmartContractController(t)}isCurrentUserAdmin(){return!!this.userWallet&&this.registryConfig.admins.includes(this.userWallet)}};import{Account as wt,Message as Mr,Mnemonic as Wt,UserSecretKey as se}from"@multiversx/sdk-core";import{CacheTtl as Or,getWarpWalletAddressFromConfig as Lr,getWarpWalletPrivateKeyFromConfig as Ct,WarpCache as Dr}from"@vleap/warps";var ie=class{constructor(e,t){this.config=e;this.chain=t;this.entry=v(t,e.env,e),this.provider=this.entry.createNetworkProvider(),this.cache=new Dr(e.cache?.type)}async signTransaction(e){if(!e||typeof e!="object")throw new Error("Invalid transaction object");let t=Ct(this.config,this.chain.name);if(!t)throw new Error("Wallet not initialized - no private key provided");let n=t.startsWith("-----")?se.fromPem(t):se.fromString(t),a=new wt(n);if(e.nonce===0n){let s=await this.entry.recallAccountNonce(a.address),o=this.cache.get(`nonce:${a.address.toBech32()}`)||0,c=BigInt(Math.max(o,Number(s)));e.nonce=c}return e.signature=await a.signTransaction(e),this.cache.set(`nonce:${a.address.toBech32()}`,Number(a.nonce),Or.OneHour),e}async signTransactions(e){return Promise.all(e.map(async t=>this.signTransaction(t)))}async signMessage(e){let t=Ct(this.config,this.chain.name);if(!t)throw new Error("Wallet not initialized - no private key provided");let n=t.startsWith("-----")?se.fromPem(t):se.fromString(t),s=await new wt(n).signMessage(new Mr({data:Buffer.from(e)}));return Buffer.from(s).toString("hex")}async sendTransactions(e){return Promise.all(e.map(async t=>this.sendTransaction(t)))}async sendTransaction(e){if(!e||typeof e!="object")throw new Error("Invalid transaction object");if(!e.signature)throw new Error("Transaction must be signed before sending");return await this.entry.sendTransaction(e)}create(e){let r=Wt.fromString(e).deriveKey(0),n=r.hex();return{address:r.generatePublicKey().toAddress(this.chain.addressHrp).toBech32(),privateKey:n,mnemonic:e}}generate(){let e=Wt.generate(),t=e.toString(),r=e.deriveKey(0),n=r.hex();return{address:r.generatePublicKey().toAddress(this.chain.addressHrp).toBech32(),privateKey:n,mnemonic:t}}getAddress(){return Lr(this.config,this.chain.name)}};var oe=(i,e,t)=>(r,n)=>{let a=t[r.env],s=new _r;return s.registerType("token",{stringToNative:o=>o,nativeToString:o=>`token:${o}`}),s.registerType("codemeta",{stringToNative:o=>o,nativeToString:o=>`codemeta:${o}`}),s.registerTypeAlias("list","vector"),{chainInfo:a,prefix:e,builder:()=>new $(r,a),executor:new te(r,a,s),results:new F(r,a,s),serializer:new P({typeRegistry:s}),registry:new ae(r,a),explorer:new re(i,r),abiBuilder:()=>new B(r,a),brandBuilder:()=>new H(r,a),dataLoader:new K(r,a),wallet:new ie(r,a)}};var Ne={chain:D.Multiversx,identifier:"EGLD",name:"eGold",symbol:"EGLD",decimals:18,logoUrl:"https://vleap.ai/images/tokens/egld.svg"},xt=oe(D.Multiversx,"multiversx",{mainnet:{name:D.Multiversx,displayName:"MultiversX",chainId:"1",blockTime:6e3,addressHrp:"erd",defaultApiUrl:"https://api.multiversx.com",logoUrl:"https://vleap.ai/images/chains/multiversx.svg",nativeToken:Ne},testnet:{name:D.Multiversx,displayName:"MultiversX Testnet",chainId:"T",blockTime:6e3,addressHrp:"erd",defaultApiUrl:"https://testnet-api.multiversx.com",logoUrl:"https://vleap.ai/images/chains/multiversx.svg",nativeToken:Ne},devnet:{name:D.Multiversx,displayName:"MultiversX Devnet",chainId:"D",blockTime:6e3,addressHrp:"erd",defaultApiUrl:"https://devnet-api.multiversx.com",logoUrl:"https://vleap.ai/images/chains/multiversx.svg",nativeToken:Ne}});import{WarpChainName as Ue}from"@vleap/warps";var Gr={chain:Ue.Vibechain,identifier:"VIBE",name:"VIBE",symbol:"VIBE",decimals:18,logoUrl:"https://vleap.ai/images/tokens/vibe.svg"},Ve={name:Ue.Vibechain,displayName:"VibeChain",chainId:"V",blockTime:600,addressHrp:"vibe",defaultApiUrl:"https://vibeox-api.multiversx.com",logoUrl:"https://vleap.ai/images/chains/vibechain.svg",nativeToken:Gr},At=oe(Ue.Vibechain,"vibe",{mainnet:Ve,testnet:Ve,devnet:Ve});var Ki=(i,e)=>[xt(i,e),At(i,e)],qi=()=>[Et.Multiversx,Et.Vibechain];import{WarpConstants as ce,WarpSerializer as ke}from"@vleap/warps";var io=i=>new ke().nativeToString(g.Token,i),oo=i=>new ke().nativeToString(g.CodeMeta,i),co=(i,e)=>{if(e===null)return g.Optional+ce.ArgParamsSeparator;let t=i(e),r=t.indexOf(ce.ArgParamsSeparator),n=t.substring(0,r),a=t.substring(r+1);return g.Optional+ce.ArgParamsSeparator+n+ce.ArgParamsSeparator+a},po=i=>new ke().nativeToString(g.List,i);import{Address as Hr,AddressValue as $r,BigUIntType as zr,BigUIntValue as bt,BooleanValue as Kr,BytesValue as qr,CodeMetadata as Qr,CodeMetadataValue as jr,CompositeType as Xr,CompositeValue as Jr,Field as Fe,FieldDefinition as Re,List as Yr,NothingValue as Zr,OptionalValue as Me,OptionValue as Oe,StringValue as en,Struct as tn,StructType as rn,TokenIdentifierType as nn,TokenIdentifierValue as St,U16Value as an,U32Value as sn,U64Type as on,U64Value as It,U8Value as cn,VariadicValue as pn}from"@multiversx/sdk-core";var fo=(i,e)=>i?Oe.newProvided(i):e?Oe.newMissingTyped(e):Oe.newMissing(),yo=(i,e)=>i?new Me(i.getType(),i):e?new Me(e):Me.newMissing(),vo=i=>{if(i.length===0)throw new Error("Cannot create a list from an empty array");let e=i[0].getType();return new Yr(e,i)},To=i=>pn.fromItems(...i),wo=i=>{let e=i.map(t=>t.getType());return new Jr(new Xr(...e),i)},Wo=i=>en.fromUTF8(i),Co=i=>new cn(i),xo=i=>new an(i),Ao=i=>new sn(i),Eo=i=>new It(i),bo=i=>new bt(BigInt(i)),So=i=>new Kr(i),Io=i=>new $r(Hr.newFromBech32(i)),Bo=i=>new St(i),Po=i=>qr.fromHex(i),No=i=>new tn(new rn("EsdtTokenPayment",[new Re("token_identifier","",new nn),new Re("token_nonce","",new on),new Re("amount","",new zr)]),[new Fe(new St(i.token.identifier),"token_identifier"),new Fe(new It(BigInt(i.token.nonce)),"token_nonce"),new Fe(new bt(BigInt(i.amount)),"amount")]),Vo=i=>new jr(Qr.newFromBytes(Uint8Array.from(Buffer.from(i,"hex")))),Uo=()=>new Zr;export{N as ExplorerUrls,Ye as KnownTokens,or as MultiversxExplorers,et as MultiversxExplorersConfig,Ne as NativeTokenEgld,Gr as NativeTokenVibe,cr as VibechainExplorers,B as WarpMultiversxAbiBuilder,H as WarpMultiversxBrandBuilder,$ as WarpMultiversxBuilder,Ga as WarpMultiversxConstants,G as WarpMultiversxContractLoader,K as WarpMultiversxDataLoader,te as WarpMultiversxExecutor,re as WarpMultiversxExplorer,g as WarpMultiversxInputTypes,ae as WarpMultiversxRegistry,F as WarpMultiversxResults,P as WarpMultiversxSerializer,ie as WarpMultiversxWallet,Io as address_value,No as asset_value,bo as biguint_value,So as boolean_value,oo as codemeta,Vo as codemeta_value,wo as composite_value,oe as createMultiversxAdapter,Ze as findKnownTokenById,Ki as getAllMultiversxAdapters,qi as getAllMultiversxChainNames,Ea as getKnownTokensForChain,xt as getMultiversxAdapter,v as getMultiversxEntrypoint,E as getMultiversxRegistryAddress,_ as getNormalizedTokenIdentifier,At as getVibechainAdapter,Po as hex_value,k as isNativeToken,po as list,vo as list_value,Uo as nothing_value,fo as option_value,co as optional,yo as optional_value,Wo as string_value,vt as toTypedConfigInfo,ne as toTypedRegistryInfo,io as token,Bo as token_value,xo as u16_value,Ao as u32_value,Eo as u64_value,Co as u8_value,To as variadic_value};
|
package/package.json
CHANGED
|
@@ -1,13 +1,20 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vleap/warps-adapter-multiversx",
|
|
3
|
-
"version": "0.2.0-alpha.
|
|
3
|
+
"version": "0.2.0-alpha.70",
|
|
4
4
|
"description": "",
|
|
5
|
-
"
|
|
5
|
+
"type": "module",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
7
|
-
"
|
|
7
|
+
"exports": {
|
|
8
|
+
".": {
|
|
9
|
+
"types": "./dist/index.d.ts",
|
|
10
|
+
"import": "./dist/index.mjs",
|
|
11
|
+
"require": "./dist/index.js",
|
|
12
|
+
"default": "./dist/index.mjs"
|
|
13
|
+
}
|
|
14
|
+
},
|
|
8
15
|
"scripts": {
|
|
9
16
|
"build": "tsup",
|
|
10
|
-
"test": "jest --config jest.config.
|
|
17
|
+
"test": "jest --config jest.config.mjs",
|
|
11
18
|
"lint": "tsc --noEmit",
|
|
12
19
|
"prepare": "npm run build",
|
|
13
20
|
"preversion": "npm run lint && npm run build"
|
|
@@ -18,19 +25,19 @@
|
|
|
18
25
|
"dist"
|
|
19
26
|
],
|
|
20
27
|
"devDependencies": {
|
|
21
|
-
"@types/jest": "^
|
|
22
|
-
"jest": "^30.
|
|
23
|
-
"jest-environment-jsdom": "^30.
|
|
28
|
+
"@types/jest": "^30.0.0",
|
|
29
|
+
"jest": "^30.2.0",
|
|
30
|
+
"jest-environment-jsdom": "^30.2.0",
|
|
24
31
|
"jest-fetch-mock": "^3.0.3",
|
|
25
|
-
"ts-jest": "^29.4.
|
|
32
|
+
"ts-jest": "^29.4.5",
|
|
26
33
|
"tsup": "^8.5.0",
|
|
27
|
-
"typescript": "^5.
|
|
34
|
+
"typescript": "^5.9.3"
|
|
28
35
|
},
|
|
29
36
|
"publishConfig": {
|
|
30
37
|
"access": "public"
|
|
31
38
|
},
|
|
32
39
|
"dependencies": {
|
|
33
|
-
"@multiversx/sdk-core": "^
|
|
34
|
-
"@vleap/warps": "^3.0.0-alpha.
|
|
40
|
+
"@multiversx/sdk-core": "^15.3.0",
|
|
41
|
+
"@vleap/warps": "^3.0.0-alpha.139"
|
|
35
42
|
}
|
|
36
43
|
}
|