@vleap/warps-adapter-multiversx 0.2.0-alpha.9 → 0.2.0-beta.77

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