@vleap/warps-adapter-multiversx 0.2.0-alpha.27 → 0.2.0-alpha.28
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.mjs +1 -1
- package/package.json +11 -5
- package/dist/index.d.mts +0 -218
- package/dist/index.js +0 -1
package/dist/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{AbiRegistry as se}from"@multiversx/sdk-core";import{WarpCache as Yt,WarpCacheKey as Zt,WarpConstants as ze,WarpLogger as Qe}from"@vleap/warps";import{WarpLogger as He}from"@vleap/warps";import{Address as N,ArgSerializer as _t,DevnetEntrypoint as Ot,MainnetEntrypoint as Mt,SmartContractTransactionsFactory as $t,TestnetEntrypoint as Lt,Token as qt,TokenComputer as Dt,TokenTransfer as Ht,TransactionsFactoryConfig as qe,TransferTransactionsFactory as zt,UserSecretKey as Qt,UserSigner as jt}from"@multiversx/sdk-core";import{applyResultsToMessages as Gt,findKnownTokenById as Kt,getNextInfo as Jt,getWarpActionByIndex as ie,shiftBigintBy as Xt,WarpConstants as De}from"@vleap/warps";import{findEventsByFirstTopic as ut,SmartContractTransactionsOutcomeParser as lt,TransactionEventsParser as mt}from"@multiversx/sdk-core";import{applyResultsToMessages as ft,evaluateResultsCommon as U,findWarpExecutableAction as Ue,getNextInfo as dt,parseResultsOutIndex as ke,WarpCache as gt,WarpCacheKey as yt,WarpConstants as _e}from"@vleap/warps";import{Address as nt,AddressType as me,AddressValue as fe,BigUIntType as z,BigUIntValue as Q,BooleanType as de,BooleanValue as ge,BytesType as ye,BytesValue as he,CodeMetadata as at,CodeMetadataType as we,CodeMetadataValue as We,CompositeType as xe,CompositeValue as Te,Field as j,FieldDefinition as G,List as Ce,ListType as it,NothingValue as T,OptionalType as st,OptionalValue as K,OptionType as ot,OptionValue as J,StringType as ve,StringValue as be,Struct as ct,StructType as Ae,TokenIdentifierType as X,TokenIdentifierValue as Y,U16Type as Ee,U16Value as Be,U32Type as Ie,U32Value as Ve,U64Type as Z,U64Value as ee,U8Type as Se,U8Value as Fe,VariadicType as Ne,VariadicValue as Re}from"@multiversx/sdk-core";import{WarpConstants as C,WarpSerializer as pt}from"@vleap/warps";var Pe=new RegExp(`${C.ArgParamsSeparator}(.*)`),E=class{constructor(){this.coreSerializer=new pt}typedToString(e){if(e.hasClassOrSuperclass(J.ClassName))return e.isSet()?`option:${this.typedToString(e.getTypedValue())}`:"option:null";if(e.hasClassOrSuperclass(K.ClassName))return e.isSet()?`optional:${this.typedToString(e.getTypedValue())}`:"optional:null";if(e.hasClassOrSuperclass(Ce.ClassName)){let t=e.getItems(),n=t.map(o=>this.typedToString(o).split(C.ArgParamsSeparator)[0])[0],a=t.map(o=>this.typedToString(o).split(C.ArgParamsSeparator)[1]);return`list:${n}:${a.join(",")}`}if(e.hasClassOrSuperclass(Re.ClassName)){let t=e.getItems(),n=t.map(o=>this.typedToString(o).split(C.ArgParamsSeparator)[0])[0],a=t.map(o=>this.typedToString(o).split(C.ArgParamsSeparator)[1]);return`variadic:${n}:${a.join(",")}`}if(e.hasClassOrSuperclass(Te.ClassName)){let t=e.getItems(),r=t.map(s=>this.typedToString(s).split(C.ArgParamsSeparator)[0]),n=t.map(s=>this.typedToString(s).split(C.ArgParamsSeparator)[1]),a=r.join(C.ArgCompositeSeparator),o=n.join(C.ArgCompositeSeparator);return`composite(${a}):${o}`}if(e.hasClassOrSuperclass(Q.ClassName)||e.getType().getName()==="BigUint")return`biguint:${BigInt(e.valueOf().toFixed())}`;if(e.hasClassOrSuperclass(Fe.ClassName))return`uint8:${e.valueOf().toNumber()}`;if(e.hasClassOrSuperclass(Be.ClassName))return`uint16:${e.valueOf().toNumber()}`;if(e.hasClassOrSuperclass(Ve.ClassName))return`uint32:${e.valueOf().toNumber()}`;if(e.hasClassOrSuperclass(ee.ClassName))return`uint64:${BigInt(e.valueOf().toFixed())}`;if(e.hasClassOrSuperclass(be.ClassName))return`string:${e.valueOf()}`;if(e.hasClassOrSuperclass(ge.ClassName))return`bool:${e.valueOf()}`;if(e.hasClassOrSuperclass(fe.ClassName))return`address:${e.valueOf().toBech32()}`;if(e.hasClassOrSuperclass(Y.ClassName))return`token:${e.valueOf()}`;if(e.hasClassOrSuperclass(he.ClassName))return`hex:${e.valueOf().toString("hex")}`;if(e.hasClassOrSuperclass(We.ClassName))return`codemeta:${e.valueOf().toString()}`;if(e.getType().getName()==="EsdtTokenPayment"){let t=e.getFieldValue("token_identifier").valueOf(),r=e.getFieldValue("token_nonce").valueOf(),n=e.getFieldValue("amount").valueOf();return`esdt:${t}|${r}|${n}`}throw new Error(`WarpArgSerializer (typedToString): Unsupported input type: ${e.getClassName()}`)}typedToNative(e){let t=this.typedToString(e);return this.coreSerializer.stringToNative(t)}nativeToTyped(e,t){let r=this.coreSerializer.nativeToString(e,t);return this.stringToTyped(r)}nativeToType(e){if(e.startsWith("composite")){let t=e.match(/\(([^)]+)\)/)?.[1];return new xe(...t.split(C.ArgCompositeSeparator).map(r=>this.nativeToType(r)))}if(e==="string")return new ve;if(e==="uint8")return new Se;if(e==="uint16")return new Ee;if(e==="uint32")return new Ie;if(e==="uint64")return new Z;if(e==="biguint")return new z;if(e==="bool")return new de;if(e==="address")return new me;if(e==="token")return new X;if(e==="hex")return new ye;if(e==="codemeta")return new we;if(e==="esdt"||e==="nft")return new Ae("EsdtTokenPayment",[new G("token_identifier","",new X),new G("token_nonce","",new Z),new G("amount","",new z)]);throw new Error(`WarpArgSerializer (nativeToType): Unsupported input type: ${e}`)}stringToTyped(e){let[t,r]=e.split(/:(.*)/,2);if(t==="null"||t===null)return new T;if(t==="option"){let n=this.stringToTyped(r);return n instanceof T?J.newMissingTyped(n.getType()):J.newProvided(n)}if(t==="optional"){let n=this.stringToTyped(r);return n instanceof T?K.newMissing():new K(n.getType(),n)}if(t==="list"){let[n,a]=r.split(Pe,2),s=a.split(",").map(c=>this.stringToTyped(`${n}:${c}`));return new Ce(this.nativeToType(n),s)}if(t==="variadic"){let[n,a]=r.split(Pe,2),s=a.split(",").map(c=>this.stringToTyped(`${n}:${c}`));return new Re(new Ne(this.nativeToType(n)),s)}if(t.startsWith("composite")){let n=t.match(/\(([^)]+)\)/)?.[1],a=r.split(C.ArgCompositeSeparator),o=n.split(C.ArgCompositeSeparator),s=a.map((p,u)=>this.stringToTyped(`${o[u]}:${p}`)),c=s.map(p=>p.getType());return new Te(new xe(...c),s)}if(t==="string")return r?be.fromUTF8(r):new T;if(t==="uint8")return r?new Fe(Number(r)):new T;if(t==="uint16")return r?new Be(Number(r)):new T;if(t==="uint32")return r?new Ve(Number(r)):new T;if(t==="uint64")return r?new ee(BigInt(r)):new T;if(t==="biguint")return r?new Q(BigInt(r)):new T;if(t==="bool")return r?new ge(typeof r=="boolean"?r:r==="true"):new T;if(t==="address")return r?new fe(nt.newFromBech32(r)):new T;if(t==="token")return r?new Y(r):new T;if(t==="hex")return r?he.fromHex(r):new T;if(t==="codemeta")return new We(at.newFromBytes(Uint8Array.from(Buffer.from(r,"hex"))));if(t==="esdt"){let n=r.split(C.ArgCompositeSeparator);return new ct(this.nativeToType("esdt"),[new j(new Y(n[0]),"token_identifier"),new j(new ee(BigInt(n[1])),"token_nonce"),new j(new Q(BigInt(n[2])),"amount")])}throw new Error(`WarpArgSerializer (stringToTyped): Unsupported input type: ${t}`)}typeToString(e){if(e instanceof ot)return"option:"+this.typeToString(e.getFirstTypeParameter());if(e instanceof st)return"optional:"+this.typeToString(e.getFirstTypeParameter());if(e instanceof it)return"list:"+this.typeToString(e.getFirstTypeParameter());if(e instanceof Ne)return"variadic:"+this.typeToString(e.getFirstTypeParameter());if(e instanceof ve)return"string";if(e instanceof Se)return"uint8";if(e instanceof Ee)return"uint16";if(e instanceof Ie)return"uint32";if(e instanceof Z)return"uint64";if(e instanceof z)return"biguint";if(e instanceof de)return"bool";if(e instanceof me)return"address";if(e instanceof X)return"token";if(e instanceof ye)return"hex";if(e instanceof we)return"codemeta";if(e instanceof Ae&&e.getClassName()==="EsdtTokenPayment")return"esdt";throw new Error(`WarpArgSerializer (typeToString): Unsupported input type: ${e.getClassName()}`)}};var V=class{constructor(e,t){this.config=e;this.chain=t;this.abi=new B(e,t),this.serializer=new E,this.cache=new gt(e.cache?.type)}async getTransactionExecutionResults(e,t){let{actionIndex:r}=Ue(e),n=this.cache.get(yt.WarpExecutable(this.config.env,e.meta?.hash||"",r))??[],a=await this.extractContractResults(e,t,n),o=dt(this.config,[],e,r,a),s=ft(e,a.results);return{success:t.status.isSuccessful(),warp:e,action:r,user:this.config.user?.wallets?.[this.chain.name]||null,txHash:t.hash,next:o,values:a.values,results:a.results,messages:s}}async extractContractResults(e,t,r){let{action:n,actionIndex:a}=Ue(e),o=[],s={};if(!e.results||n.type!=="contract")return{values:o,results:s};if(!Object.values(e.results).some(w=>w.includes("out")||w.includes("event"))){for(let[w,m]of Object.entries(e.results))s[w]=m;return{values:o,results:await U(e,s,a,r)}}let p=await this.abi.getAbiForAction(n),u=new mt({abi:p}),y=new lt({abi:p}).parseExecute({transactionOnNetwork:t,function:n.func||void 0});for(let[w,m]of Object.entries(e.results)){if(m.startsWith(_e.Transform.Prefix))continue;if(m.startsWith("input.")){s[w]=m;continue}let v=ke(m);if(v!==null&&v!==a){s[w]=null;continue}let[W,A,b]=m.split(".");if(W==="event"){if(!A||isNaN(Number(b)))continue;let R=Number(b),h=ut(t,A),F=u.parseEvents({events:h})[0],P=Object.values(F)[R]||null;o.push(P),s[w]=P&&P.valueOf()}else if(W==="out"||W.startsWith("out[")){if(!A)continue;let R=Number(A),h=y.values[R-1]||null;b&&(h=h[b]||null),h&&typeof h=="object"&&(h="toFixed"in h?h.toFixed():h.valueOf()),o.push(h),s[w]=h&&h.valueOf()}else s[w]=m}return{values:o,results:await U(e,s,a,r)}}async extractQueryResults(e,t,r,n){let a=t.map(p=>this.serializer.typedToString(p)),o=t.map(p=>this.serializer.typedToNative(p)[1]),s={};if(!e.results)return{values:a,results:s};let c=p=>{let u=p.split(".").slice(1).map(y=>parseInt(y)-1);if(u.length===0)return;let l=o[u[0]];for(let y=1;y<u.length;y++){if(l==null)return;l=l[u[y]]}return l};for(let[p,u]of Object.entries(e.results)){if(u.startsWith(_e.Transform.Prefix))continue;let l=ke(u);if(l!==null&&l!==r){s[p]=null;continue}u.startsWith("out.")||u==="out"||u.startsWith("out[")?s[p]=c(u)||null:s[p]=u}return{values:a,results:await U(e,s,r,n)}}async resolveWarpResultsRecursively(e){let t=e.warp,r=e.entryActionIndex,n=e.executor,a=e.inputs,o=e.meta,s=new Map,c=new Set,p=this;async function u(m,v=[]){if(s.has(m))return s.get(m);if(c.has(m))throw new Error(`Circular dependency detected at action ${m}`);c.add(m);let W=t.actions[m-1];if(!W)throw new Error(`Action ${m} not found`);let A;if(W.type==="query")A=await n.executeQuery(t,m,v);else if(W.type==="collect")A=await n.executeCollect(t,m,v,o);else throw new Error(`Unsupported or interactive action type: ${W.type}`);if(s.set(m,A),t.results)for(let b of Object.values(t.results)){let h=String(b).match(/^out\[(\d+)\]/);if(h){let F=parseInt(h[1],10);F!==m&&!s.has(F)&&await u(F)}}return c.delete(m),A}await u(r,a);let l={};for(let m of s.values())for(let[v,W]of Object.entries(m.results))W!==null?l[v]=W:v in l||(l[v]=null);let y=await U(t,l,r,a);return{...s.get(r),action:r,results:y}}};import{Address as ht,AddressValue as wt,BigUIntType as Wt,BigUIntValue as Oe,BooleanValue as xt,BytesValue as Tt,CodeMetadata as Ct,CodeMetadataValue as vt,CompositeType as bt,CompositeValue as At,Field as te,FieldDefinition as re,List as Et,NothingValue as Bt,OptionalValue as ne,OptionValue as ae,StringValue as It,Struct as Vt,StructType as St,TokenIdentifierType as Ft,TokenIdentifierValue as Me,U16Value as Nt,U32Value as Rt,U64Type as Pt,U64Value as $e,U8Value as Ut,VariadicValue as kt}from"@multiversx/sdk-core";var zr=(i,e)=>i?ae.newProvided(i):e?ae.newMissingTyped(e):ae.newMissing(),Qr=(i,e)=>i?new ne(i.getType(),i):e?new ne(e):ne.newMissing(),jr=i=>{if(i.length===0)throw new Error("Cannot create a list from an empty array");let e=i[0].getType();return new Et(e,i)},Gr=i=>kt.fromItems(...i),Kr=i=>{let e=i.map(t=>t.getType());return new At(new bt(...e),i)},Jr=i=>It.fromUTF8(i),Xr=i=>new Ut(i),Yr=i=>new Nt(i),Zr=i=>new Rt(i),en=i=>new $e(i),tn=i=>new Oe(BigInt(i)),rn=i=>new xt(i),nn=i=>new wt(ht.newFromBech32(i)),an=i=>new Me(i),sn=i=>Tt.fromHex(i),Le=i=>new Vt(new St("EsdtTokenPayment",[new re("token_identifier","",new Ft),new re("token_nonce","",new Pt),new re("amount","",new Wt)]),[new te(new Me(i.token.identifier),"token_identifier"),new te(new $e(BigInt(i.token.nonce)),"token_nonce"),new te(new Oe(BigInt(i.amount)),"amount")]),on=i=>new vt(Ct.newFromBytes(Uint8Array.from(Buffer.from(i,"hex")))),cn=()=>new Bt;var d=class i{constructor(e,t){this.config=e;this.chain=t;this.serializer=new E,this.abi=new B(this.config,this.chain),this.results=new V(this.config,this.chain)}async createTransaction(e){let t=ie(e.warp,e.action),r=null;if(t.type==="transfer")r=await this.createTransferTransaction(e);else if(t.type==="contract")r=await this.createContractCallTransaction(e);else{if(t.type==="query")throw new Error("WarpMultiversxExecutor: Invalid action type for createTransactionForExecute; Use executeQuery instead");if(t.type==="collect")throw new Error("WarpMultiversxExecutor: Invalid action type for createTransactionForExecute; Use executeCollect instead")}if(!r)throw new Error(`WarpMultiversxExecutor: Invalid action type (${t.type})`);return r}async createTransferTransaction(e){let t=this.config.user?.wallets?.[e.chain.name];if(!t)throw new Error("WarpMultiversxExecutor: createTransfer - user address not set");let r=N.newFromBech32(t),n=new qe({chainID:e.chain.chainId}),a=e.data?Buffer.from(this.serializer.stringToTyped(e.data).valueOf()):null;return new zt({config:n}).createTransactionForTransfer(r,{receiver:N.newFromBech32(e.destination),nativeAmount:e.value,data:a?new Uint8Array(a):void 0})}async createContractCallTransaction(e){let t=this.config.user?.wallets?.[e.chain.name];if(!t)throw new Error("WarpMultiversxExecutor: createContractCall - user address not set");let r=ie(e.warp,e.action),n=N.newFromBech32(t),a=e.args.map(s=>this.serializer.stringToTyped(s)),o=new qe({chainID:e.chain.chainId});return new $t({config:o}).createTransactionForExecute(n,{contract:N.newFromBech32(e.destination),function:"func"in r&&r.func||"",gasLimit:"gasLimit"in r?BigInt(r.gasLimit||0):0n,arguments:a,nativeTransferAmount:e.value})}async executeQuery(e){let t=ie(e.warp,e.action);if(t.type!=="query")throw new Error(`WarpMultiversxExecutor: Invalid action type for executeQuery: ${t.type}`);let r=await this.abi.getAbiForAction(t),n=e.args.map(b=>this.serializer.stringToTyped(b)),a=i.getChainEntrypoint(e.chain,this.config.env),o=N.newFromBech32(e.destination),s=a.createSmartContractController(r),c=s.createQuery({contract:o,function:t.func||"",arguments:n}),p=await s.runQuery(c),u=p.returnCode==="ok",l=new _t,y=r.getEndpoint(p.function||t.func||""),w=(p.returnDataParts||[]).map(b=>Buffer.from(b)),m=l.buffersToValues(w,y.output),{values:v,results:W}=await this.results.extractQueryResults(e.warp,m,e.action,e.resolvedInputs),A=Jt(this.config,[],e.warp,e.action,W);return{success:u,warp:e.warp,action:e.action,user:this.config.user?.wallets?.[e.chain.name]||null,txHash:null,next:A,values:v,results:W,messages:Gt(e.warp,W)}}async preprocessInput(e,t,r,n){if(r==="esdt"){let[a,o,s,c]=n.split(De.ArgCompositeSeparator);if(c)return t;let p=new qt({identifier:a,nonce:BigInt(o)});if(!new Dt().isFungible(p))return t;let y=Kt(a)?.decimals;if(y||(y=(await(await fetch(`${e.apiUrl}/tokens/${a}`)).json()).decimals),!y)throw new Error(`WarpActionExecutor: Decimals not found for token ${a}`);let w=Le(new Ht({token:p,amount:Xt(s,y)}));return this.serializer.typedToString(w)+De.ArgCompositeSeparator+y}return t}static getChainEntrypoint(e,t){let r="warp-sdk";return t==="devnet"?new Ot({url:e.apiUrl,kind:"api",clientName:r}):t==="testnet"?new Lt({url:e.apiUrl,kind:"api",clientName:r}):new Mt({url:e.apiUrl,kind:"api",clientName:r})}async signMessage(e,t){let r=Qt.fromString(t);return(await new jt(r).sign(new Uint8Array(Buffer.from(e,"utf-8")))).toString()}};var k=class{constructor(e){this.config=e}async getContract(e,t){try{let a=await d.getChainEntrypoint(t,this.config.env).createNetworkProvider().doGetGeneric(`accounts/${e}`);return{address:e,owner:a.ownerAddress,verified:a.isVerified||!1}}catch(r){return He.error("WarpContractLoader: getContract error",r),null}}async getVerificationInfo(e,t){try{let a=await d.getChainEntrypoint(t,this.config.env).createNetworkProvider().doGetGeneric(`accounts/${e}/verification`);return{codeHash:a.codeHash,abi:a.source.abi}}catch(r){return He.error("WarpContractLoader: getVerificationInfo error",r),null}}};var B=class{constructor(e,t){this.config=e;this.chain=t;this.contractLoader=new k(this.config),this.cache=new Yt(this.config.cache?.type)}async createFromRaw(e){return JSON.parse(e)}async createFromTransaction(e){let t=await this.createFromRaw(e.data.toString());return t.meta={chain:this.chain.name,hash:e.hash,creator:e.sender.toBech32(),createdAt:new Date(e.timestamp*1e3).toISOString()},t}async createFromTransactionHash(e,t){let r=Zt.WarpAbi(this.config.env,e);if(t){let o=this.cache.get(r);if(o)return Qe.info(`WarpAbiBuilder (createFromTransactionHash): Warp abi found in cache: ${e}`),o}let a=d.getChainEntrypoint(this.chain,this.config.env).createNetworkProvider();try{let o=await a.getTransaction(e),s=await this.createFromTransaction(o);return t&&t.ttl&&s&&this.cache.set(r,s,t.ttl),s}catch(o){return Qe.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 se.create(t.abi)}async fetchAbi(e){if(!e.abi)throw new Error("WarpActionExecutor: ABI not found");if(e.abi.startsWith(ze.IdentifierType.Hash)){let t=e.abi.split(ze.IdentifierParamSeparatorDefault)[1],r=await this.createFromTransactionHash(t);if(!r)throw new Error(`WarpActionExecutor: ABI not found for hash: ${e.abi}`);return se.create(r.content)}else{let r=await(await fetch(e.abi)).json();return se.create(r)}}};import{Address as je,TransactionsFactoryConfig as er,TransferTransactionsFactory as tr}from"@multiversx/sdk-core";import{WarpBrandBuilder as rr,WarpLogger as nr}from"@vleap/warps";import{Buffer as ar}from"buffer";var _=class{constructor(e,t){this.config=e;this.chain=t;this.core=new rr(e)}async createInscriptionTransaction(e){let t=this.config.user?.wallets?.[this.chain.name];if(!t)throw new Error("BrandBuilder: user address not set");let r=new er({chainID:this.chain.chainId}),n=new tr({config:r}),a=je.newFromBech32(t),o=JSON.stringify(e);return await n.createTransactionForNativeTokenTransfer(a,{receiver:je.newFromBech32(t),nativeAmount:BigInt(0),data:Uint8Array.from(ar.from(o))})}async createFromTransaction(e,t=!1){return await this.core.createFromRaw(e.data.toString(),t)}async createFromTransactionHash(e){let r=d.getChainEntrypoint(this.chain,this.config.env).createNetworkProvider();try{let n=await r.getTransaction(e);return this.createFromTransaction(n)}catch(n){return nr.error("BrandBuilder: Error creating from transaction hash",n),null}}};import{Address as Ge,TransactionsFactoryConfig as ir,TransferTransactionsFactory as sr}from"@multiversx/sdk-core";import{WarpBuilder as Ke,WarpCache as or,WarpCacheKey as cr,WarpLogger as Je}from"@vleap/warps";var O=class extends Ke{constructor(t,r){super(t);this.config=t;this.chain=r;this.cache=new or(t.cache?.type),this.core=new Ke(t)}async createInscriptionTransaction(t){let r=this.config.user?.wallets?.[this.chain.name];if(!r)throw new Error("WarpBuilder: user address not set");let n=new ir({chainID:this.chain.chainId}),a=new sr({config:n}),o=Ge.newFromBech32(r),s=JSON.stringify(t),c=await a.createTransactionForTransfer(o,{receiver:Ge.newFromBech32(r),nativeAmount:BigInt(0),data:Uint8Array.from(Buffer.from(s))});return c.gasLimit=c.gasLimit+BigInt(2e6),c}async createFromTransaction(t,r=!1){let n=await this.core.createFromRaw(t.data.toString(),r);return n.meta={chain:this.chain.name,hash:t.hash,creator:t.sender.toBech32(),createdAt:new Date(t.timestamp*1e3).toISOString()},n}async createFromTransactionHash(t,r){let n=cr.Warp(this.config.env,t);if(r){let s=this.cache.get(n);if(s)return Je.info(`WarpBuilder (createFromTransactionHash): Warp found in cache: ${t}`),s}let o=d.getChainEntrypoint(this.chain,this.config.env).createNetworkProvider();try{let s=await o.getTransaction(t),c=await this.createFromTransaction(s);return r&&r.ttl&&c&&this.cache.set(n,c,r.ttl),c}catch(s){return Je.error("WarpBuilder: Error creating from transaction hash",s),null}}};import{Address as Xe}from"@multiversx/sdk-core";var M=class{constructor(e,t){this.config=e;this.chain=t}async getAccount(e){let r=await d.getChainEntrypoint(this.chain,this.config.env).createNetworkProvider().getAccount(Xe.newFromBech32(e));return{address:r.address.toBech32(),balance:r.balance}}async getAccountAssets(e){return(await d.getChainEntrypoint(this.chain,this.config.env).createNetworkProvider().getFungibleTokensOfAccount(Xe.newFromBech32(e))).map(n=>({identifier:n.token.identifier,name:n.raw.name,amount:n.amount,decimals:n.raw.decimals,logoUrl:n.raw.assets?.pngUrl||""}))}};var ha={Egld:{Identifier:"EGLD",EsdtIdentifier:"EGLD-000000",DisplayName:"eGold",Decimals:18}},pr=(r=>(r.MultiversxExplorer="multiversx_explorer",r.MultiversxExplorerDevnet="multiversx_explorer_devnet",r.MultiversxExplorerTestnet="multiversx_explorer_testnet",r))(pr||{}),ur=(r=>(r.VibechainExplorer="vibechain_explorer",r.VibechainExplorerDevnet="vibechain_explorer_devnet",r.VibechainExplorerTestnet="vibechain_explorer_testnet",r))(ur||{}),Ye={multiversx:{mainnet:["multiversx_explorer"],testnet:["multiversx_explorer_testnet"],devnet:["multiversx_explorer_devnet"]},vibechain:{mainnet:["vibechain_explorer"],testnet:["vibechain_explorer_testnet"],devnet:["vibechain_explorer_devnet"]}},I={multiversx_explorer:"https://explorer.multiversx.com",multiversx_explorer_devnet:"https://devnet-explorer.multiversx.com",multiversx_explorer_testnet:"https://testnet-explorer.multiversx.com",vibechain_explorer:"https://vibeox-explorer.multiversx.com",vibechain_explorer_devnet:"https://vibeox-explorer.multiversx.com",vibechain_explorer_testnet:"https://vibeox-explorer.multiversx.com"};var $=class{constructor(e,t){this.chain=e;this.config=t}getExplorers(){let e=Ye[this.chain];if(!e)return["multiversx_explorer"];let t=e[this.config.env];return t||["multiversx_explorer"]}getPrimaryExplorer(){return this.getExplorers()[0]}getExplorerUrlByName(e){let t=this.config.preferences?.explorers?.[this.chain];if(t&&!e){let a=I[t];if(a)return a}if(e){let a=I[e];if(a)return a}let r=this.getPrimaryExplorer();return I[r]||I[r]}getAccountUrl(e,t){return`${this.getExplorerUrlByName(t)}/accounts/${e}`}getTransactionUrl(e,t){return`${this.getExplorerUrlByName(t)}/transactions/${e}`}getBlockUrl(e,t){return`${this.getExplorerUrlByName(t)}/blocks/${e}`}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=I[n];a&&(r[n]=`${a}/accounts/${e}`)}),r}getTransactionUrls(e){let t=this.getAllExplorers(),r={};return t.forEach(n=>{let a=I[n];a&&(r[n]=`${a}/transactions/${e}`)}),r}};import{AbiRegistry as et,Address as f,AddressValue as ce,BytesValue as g,SmartContractTransactionsFactory as mr,TransactionsFactoryConfig as fr}from"@multiversx/sdk-core";import{WarpCache as dr,WarpCacheKey as pe,WarpLogger as ue}from"@vleap/warps";var oe={buildInfo:{rustc:{version:"1.86.0",commitHash:"05f9846f893b09a1be1fc8560e33fc3c815cfecb",commitDate:"2025-03-31",channel:"Stable",short:"rustc 1.86.0 (05f9846f8 2025-03-31)"},contractCrate:{name:"registry",version:"0.0.1"},framework:{name:"multiversx-sc",version:"0.51.1"}},name:"RegistryContract",constructor:{inputs:[{name:"unit_price",type:"BigUint"},{name:"vault",type:"Address"}],outputs:[]},upgradeConstructor:{inputs:[],outputs:[]},endpoints:[{name:"registerWarp",mutability:"mutable",payableInTokens:["EGLD"],inputs:[{name:"hash",type:"bytes"},{name:"alias_opt",type:"optional<bytes>",multi_arg:!0},{name:"brand_opt",type:"optional<bytes>",multi_arg:!0}],outputs:[],allow_multiple_var_args:!0},{name:"unregisterWarp",mutability:"mutable",inputs:[{name:"warp",type:"bytes"}],outputs:[]},{name:"upgradeWarp",mutability:"mutable",payableInTokens:["EGLD"],inputs:[{name:"alias",type:"bytes"},{name:"new_warp",type:"bytes"}],outputs:[]},{name:"setWarpAlias",mutability:"mutable",payableInTokens:["EGLD"],inputs:[{name:"hash",type:"bytes"},{name:"alias",type:"bytes"}],outputs:[]},{name:"forceRemoveAlias",mutability:"mutable",inputs:[{name:"hash",type:"bytes"}],outputs:[]},{name:"verifyWarp",mutability:"mutable",inputs:[{name:"warp",type:"bytes"}],outputs:[]},{name:"transferOwnership",mutability:"mutable",inputs:[{name:"warp",type:"bytes"},{name:"new_owner",type:"Address"}],outputs:[]},{name:"getUserWarps",mutability:"readonly",inputs:[{name:"address",type:"Address"}],outputs:[{type:"variadic<InfoView>",multi_result:!0}]},{name:"getInfoByAlias",mutability:"readonly",inputs:[{name:"alias",type:"bytes"}],outputs:[{type:"InfoView"}]},{name:"getInfoByHash",mutability:"readonly",inputs:[{name:"hash",type:"bytes"}],outputs:[{type:"InfoView"}]},{name:"setVault",onlyOwner:!0,mutability:"mutable",inputs:[{name:"vault",type:"Address"}],outputs:[]},{name:"setUnitPrice",onlyOwner:!0,mutability:"mutable",inputs:[{name:"amount",type:"BigUint"}],outputs:[]},{name:"addAdmin",onlyOwner:!0,mutability:"mutable",inputs:[{name:"address",type:"Address"}],outputs:[]},{name:"removeAdmin",onlyOwner:!0,mutability:"mutable",inputs:[{name:"address",type:"Address"}],outputs:[]},{name:"getConfig",mutability:"readonly",inputs:[],outputs:[{type:"ConfigView"}]},{name:"registerBrand",mutability:"mutable",payableInTokens:["EGLD"],inputs:[{name:"hash",type:"bytes"}],outputs:[]},{name:"brandWarp",mutability:"mutable",payableInTokens:["EGLD"],inputs:[{name:"warp",type:"bytes"},{name:"brand",type:"bytes"}],outputs:[]},{name:"getUserBrands",mutability:"readonly",inputs:[{name:"user",type:"Address"}],outputs:[{type:"variadic<bytes>",multi_result:!0}]},{name:"setChain",onlyOwner:!0,mutability:"mutable",inputs:[{name:"name",type:"bytes"},{name:"display_name",type:"bytes"},{name:"chain_id",type:"bytes"},{name:"block_time",type:"u32"},{name:"address_hrp",type:"bytes"},{name:"api_url",type:"bytes"},{name:"explorer_url",type:"bytes"},{name:"native_token",type:"bytes"}],outputs:[]},{name:"removeChain",onlyOwner:!0,mutability:"mutable",inputs:[{name:"name",type:"bytes"}],outputs:[]},{name:"getChain",mutability:"readonly",inputs:[{name:"name",type:"bytes"}],outputs:[{type:"ChainView"}]},{name:"getChains",mutability:"readonly",inputs:[],outputs:[{type:"variadic<ChainView>",multi_result:!0}]}],events:[{identifier:"warpRegistered",inputs:[{name:"hash",type:"bytes",indexed:!0},{name:"alias",type:"bytes",indexed:!0},{name:"trust",type:"bytes",indexed:!0}]},{identifier:"warpUnregistered",inputs:[{name:"hash",type:"bytes",indexed:!0}]},{identifier:"warpUpgraded",inputs:[{name:"alias",type:"bytes",indexed:!0},{name:"new_warp",type:"bytes",indexed:!0},{name:"trust",type:"bytes",indexed:!0}]},{identifier:"warpVerified",inputs:[{name:"hash",type:"bytes",indexed:!0}]},{identifier:"aliasUpdated",inputs:[{name:"hash",type:"bytes",indexed:!0},{name:"alias",type:"bytes",indexed:!0}]},{identifier:"ownershipTransferred",inputs:[{name:"warp",type:"bytes",indexed:!0},{name:"old_owner",type:"Address",indexed:!0},{name:"new_owner",type:"Address",indexed:!0}]}],esdtAttributes:[],hasCallback:!1,types:{ChainView:{type:"struct",fields:[{name:"name",type:"bytes"},{name:"display_name",type:"bytes"},{name:"chain_id",type:"bytes"},{name:"block_time",type:"u32"},{name:"address_hrp",type:"bytes"},{name:"api_url",type:"bytes"},{name:"explorer_url",type:"bytes"},{name:"native_token",type:"bytes"}]},ConfigView:{type:"struct",fields:[{name:"unit_price",type:"BigUint"},{name:"admins",type:"List<Address>"}]},InfoView:{type:"struct",fields:[{name:"hash",type:"bytes"},{name:"alias",type:"Option<bytes>"},{name:"trust",type:"bytes"},{name:"owner",type:"Address"},{name:"created_at",type:"u64"},{name:"upgraded_at",type:"u64"},{name:"brand",type:"Option<bytes>"},{name:"upgrade",type:"Option<bytes>"}]}}};var x=i=>{if(i==="devnet")return"erd1qqqqqqqqqqqqqpgqje2f99vr6r7sk54thg03c9suzcvwr4nfl3tsfkdl36";if(i==="testnet")throw new Error("Multiversx testnet is not supported");return"erd1qqqqqqqqqqqqqpgq3mrpj3u6q7tejv6d7eqhnyd27n9v5c5tl3ts08mffe"};var L=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}),Ze=i=>({unitPrice:BigInt(i.unit_price.toString()),admins:i.admins.map(e=>e.toBech32())});var q=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=this.config.user?.wallets?.[this.chain.name]||null}async init(){await this.loadRegistryConfigs()}getRegistryConfig(){return this.registryConfig}async createWarpRegisterTransaction(e,t,r){if(this.registryConfig.unitPrice===BigInt(0))throw new Error("WarpRegistry: config not loaded. forgot to call init()?");if(!this.userWallet)throw new Error("WarpRegistry: user address not set");let n=f.newFromBech32(this.userWallet),a=()=>this.isCurrentUserAdmin()?BigInt(0):t&&r?this.registryConfig.unitPrice*BigInt(3):t?this.registryConfig.unitPrice*BigInt(2):this.registryConfig.unitPrice,o=()=>t&&r?[g.fromHex(e),g.fromUTF8(t),g.fromHex(r)]:t?[g.fromHex(e),g.fromUTF8(t)]:[g.fromHex(e)];return await this.getFactory().createTransactionForExecute(n,{contract:f.newFromBech32(x(this.config.env)),function:"registerWarp",gasLimit:BigInt(1e7),nativeTransferAmount:a(),arguments:o()})}async createWarpUnregisterTransaction(e){if(!this.userWallet)throw new Error("WarpRegistry: user address not set");let t=f.newFromBech32(this.userWallet);return await this.getFactory().createTransactionForExecute(t,{contract:f.newFromBech32(x(this.config.env)),function:"unregisterWarp",gasLimit:BigInt(1e7),arguments:[g.fromHex(e)]})}async createWarpUpgradeTransaction(e,t){if(this.registryConfig.unitPrice===BigInt(0))throw new Error("WarpRegistry: config not loaded. forgot to call init()?");if(!this.userWallet)throw new Error("WarpRegistry: user address not set");let r=f.newFromBech32(this.userWallet);return await this.getFactory().createTransactionForExecute(r,{contract:f.newFromBech32(x(this.config.env)),function:"upgradeWarp",gasLimit:BigInt(1e7),nativeTransferAmount:this.isCurrentUserAdmin()?void 0:this.registryConfig.unitPrice,arguments:[g.fromUTF8(e),g.fromHex(t)]})}async createWarpAliasSetTransaction(e,t){if(!this.userWallet)throw new Error("WarpRegistry: user address not set");let r=f.newFromBech32(this.userWallet);return await this.getFactory().createTransactionForExecute(r,{contract:f.newFromBech32(x(this.config.env)),function:"setWarpAlias",gasLimit:BigInt(1e7),nativeTransferAmount:this.isCurrentUserAdmin()?void 0:this.registryConfig.unitPrice,arguments:[g.fromHex(e),g.fromUTF8(t)]})}async createWarpVerifyTransaction(e){if(!this.userWallet)throw new Error("WarpRegistry: user address not set");let t=f.newFromBech32(this.userWallet);return await this.getFactory().createTransactionForExecute(t,{contract:f.newFromBech32(x(this.config.env)),function:"verifyWarp",gasLimit:BigInt(1e7),arguments:[g.fromHex(e)]})}async createWarpTransferOwnershipTransaction(e,t){if(!this.userWallet)throw new Error("WarpRegistry: user address not set");let r=f.newFromBech32(this.userWallet);return await this.getFactory().createTransactionForExecute(r,{contract:f.newFromBech32(x(this.config.env)),function:"transferOwnership",gasLimit:BigInt(1e7),arguments:[g.fromHex(e),new ce(new f(t))]})}async createBrandRegisterTransaction(e){if(this.registryConfig.unitPrice===BigInt(0))throw new Error("WarpRegistry: config not loaded. forgot to call init()?");if(!this.userWallet)throw new Error("WarpRegistry: user address not set");let t=f.newFromBech32(this.userWallet);return await this.getFactory().createTransactionForExecute(t,{contract:f.newFromBech32(x(this.config.env)),function:"registerBrand",gasLimit:BigInt(1e7),nativeTransferAmount:this.isCurrentUserAdmin()?void 0:this.registryConfig.unitPrice,arguments:[g.fromHex(e)]})}async createWarpBrandingTransaction(e,t){if(!this.userWallet)throw new Error("WarpRegistry: user address not set");let r=f.newFromBech32(this.userWallet);return await this.getFactory().createTransactionForExecute(r,{contract:f.newFromBech32(x(this.config.env)),function:"brandWarp",gasLimit:BigInt(1e7),nativeTransferAmount:this.isCurrentUserAdmin()?void 0:this.registryConfig.unitPrice,arguments:[g.fromHex(e),g.fromHex(t)]})}async getInfoByAlias(e,t){try{let r=pe.RegistryInfo(this.config.env,e),n=t?this.cache.get(r):null;if(n)return ue.info(`WarpRegistry (getInfoByAlias): RegistryInfo found in cache: ${e}`),n;let a=f.newFromBech32(x(this.config.env)),o=this.getController(),s=o.createQuery({contract:a,function:"getInfoByAlias",arguments:[g.fromUTF8(e)]}),c=await o.runQuery(s),[p]=o.parseQueryResponse(c),u=p?L(p):null,l=u?.brand?await this.fetchBrand(u.brand):null;return t&&t.ttl&&this.cache.set(r,{registryInfo:u,brand:l},t.ttl),{registryInfo:u,brand:l}}catch{return{registryInfo:null,brand:null}}}async getInfoByHash(e,t){try{let r=pe.RegistryInfo(this.config.env,e);if(t){let l=this.cache.get(r);if(l)return ue.info(`WarpRegistry (getInfoByHash): RegistryInfo found in cache: ${e}`),l}let n=f.newFromBech32(x(this.config.env)),a=this.getController(),o=a.createQuery({contract:n,function:"getInfoByHash",arguments:[g.fromHex(e)]}),s=await a.runQuery(o),[c]=a.parseQueryResponse(s),p=c?L(c):null,u=p?.brand?await this.fetchBrand(p.brand):null;return t&&t.ttl&&this.cache.set(r,{registryInfo:p,brand:u},t.ttl),{registryInfo:p,brand:u}}catch{return{registryInfo:null,brand:null}}}async getUserWarpRegistryInfos(e){try{let t=e||this.userWallet;if(!t)throw new Error("WarpRegistry: user address not set");let r=f.newFromBech32(x(this.config.env)),n=this.getController(),a=n.createQuery({contract:r,function:"getUserWarps",arguments:[new ce(new f(t))]}),o=await n.runQuery(a),[s]=n.parseQueryResponse(o);return s.map(L)}catch{return[]}}async getUserBrands(e){try{let t=e||this.userWallet;if(!t)throw new Error("WarpRegistry: user address not set");let r=f.newFromBech32(x(this.config.env)),n=this.getController(),a=n.createQuery({contract:r,function:"getUserBrands",arguments:[new ce(new f(t))]}),o=await n.runQuery(a),[s]=n.parseQueryResponse(o),c=s.map(l=>l.toString("hex")),p={ttl:365*24*60*60};return(await Promise.all(c.map(l=>this.fetchBrand(l,p)))).filter(l=>l!==null)}catch{return[]}}async fetchBrand(e,t){let r=pe.Brand(this.config.env,e),n=t?this.cache.get(r):null;if(n)return ue.info(`WarpRegistry (fetchBrand): Brand found in cache: ${e}`),n;let o=d.getChainEntrypoint(this.chain,this.config.env).createNetworkProvider();try{let s=await o.getTransaction(e),c=JSON.parse(s.data.toString());return c.meta={hash:s.hash,creator:s.sender.toBech32(),createdAt:new Date(s.timestamp*1e3).toISOString()},t&&t.ttl&&this.cache.set(r,c,t.ttl),c}catch{return null}}async loadRegistryConfigs(){let e=f.newFromBech32(x(this.config.env)),t=this.getController(),[r]=await t.query({contract:e,function:"getConfig",arguments:[]}),n=r?Ze(r):null;this.registryConfig=n||{unitPrice:BigInt(0),admins:[]}}getFactory(){let e=new fr({chainID:this.chain.chainId}),t=et.create(oe);return new mr({config:e,abi:t})}getController(){let e=d.getChainEntrypoint(this.chain,this.config.env),t=et.create(oe);return e.createSmartContractController(t)}isCurrentUserAdmin(){return!!this.userWallet&&this.registryConfig.admins.includes(this.userWallet)}};var D=(i,e,t)=>(r,n)=>{let a=t[r.env];return{chain:i,chainInfo:a,prefix:e,builder:()=>new O(r,a),executor:new d(r,a),results:new V(r,a),serializer:new E,registry:new q(r,a),explorer:new $(i,r),abiBuilder:()=>new B(r,a),brandBuilder:()=>new _(r,a),dataLoader:new M(r,a)}};var S="multiversx",tt=D(S,"mvx",{mainnet:{name:S,displayName:"MultiversX",chainId:"1",blockTime:6e3,addressHrp:"erd",apiUrl:"https://api.multiversx.com",nativeToken:"EGLD"},testnet:{name:S,displayName:"MultiversX Testnet",chainId:"T",blockTime:6e3,addressHrp:"erd",apiUrl:"https://testnet-api.multiversx.com",nativeToken:"EGLD"},devnet:{name:S,displayName:"MultiversX Devnet",chainId:"D",blockTime:6e3,addressHrp:"erd",apiUrl:"https://devnet-api.multiversx.com",nativeToken:"EGLD"}});var H="vibechain",le={name:H,displayName:"VibeChain",chainId:"V",blockTime:600,addressHrp:"vibe",apiUrl:"https://vibeox-api.multiversx.com",nativeToken:"VIBE"},rt=D(H,"vibe",{mainnet:le,testnet:le,devnet:le});var ni=(i,e)=>[tt(i,e),rt(i,e)],ai=()=>[S,H];export{S as ChainNameMultiversx,H as ChainNameVibechain,I as ExplorerUrls,pr as MultiversxExplorers,Ye as MultiversxExplorersConfig,ur as VibechainExplorers,B as WarpMultiversxAbiBuilder,_ as WarpMultiversxBrandBuilder,O as WarpMultiversxBuilder,ha as WarpMultiversxConstants,k as WarpMultiversxContractLoader,d as WarpMultiversxExecutor,$ as WarpMultiversxExplorer,q as WarpMultiversxRegistry,V as WarpMultiversxResults,E as WarpMultiversxSerializer,nn as address_value,tn as biguint_value,rn as boolean_value,on as codemeta_value,Kr as composite_value,D as createMultiversxAdapter,Le as esdt_value,ni as getAllMultiversxAdapters,ai as getAllMultiversxChainNames,tt as getMultiversxAdapter,x as getMultiversxRegistryAddress,rt as getVibechainAdapter,sn as hex_value,jr as list_value,cn as nothing_value,zr as option_value,Qr as optional_value,Jr as string_value,an as token_value,Yr as u16_value,Zr as u32_value,en as u64_value,Xr as u8_value,Gr as variadic_value};
|
|
1
|
+
import{AbiRegistry as se}from"@multiversx/sdk-core";import{WarpCache as Yt,WarpCacheKey as Zt,WarpConstants as ze,WarpLogger as Qe}from"@vleap/warps";import{WarpLogger as He}from"@vleap/warps";import{Address as N,ArgSerializer as _t,DevnetEntrypoint as Ot,MainnetEntrypoint as Mt,SmartContractTransactionsFactory as $t,TestnetEntrypoint as Lt,Token as qt,TokenComputer as Dt,TokenTransfer as Ht,TransactionsFactoryConfig as qe,TransferTransactionsFactory as zt,UserSecretKey as Qt,UserSigner as jt}from"@multiversx/sdk-core";import{applyResultsToMessages as Gt,findKnownTokenById as Kt,getNextInfo as Jt,getWarpActionByIndex as ie,shiftBigintBy as Xt,WarpConstants as De}from"@vleap/warps";import{findEventsByFirstTopic as ut,SmartContractTransactionsOutcomeParser as lt,TransactionEventsParser as mt}from"@multiversx/sdk-core";import{applyResultsToMessages as ft,evaluateResultsCommon as U,findWarpExecutableAction as Ue,getNextInfo as dt,parseResultsOutIndex as ke,WarpCache as gt,WarpCacheKey as ht,WarpConstants as _e}from"@vleap/warps";import{Address as nt,AddressType as me,AddressValue as fe,BigUIntType as z,BigUIntValue as Q,BooleanType as de,BooleanValue as ge,BytesType as he,BytesValue as ye,CodeMetadata as at,CodeMetadataType as we,CodeMetadataValue as We,CompositeType as xe,CompositeValue as Te,Field as j,FieldDefinition as G,List as Ce,ListType as it,NothingValue as T,OptionalType as st,OptionalValue as K,OptionType as ot,OptionValue as J,StringType as ve,StringValue as be,Struct as ct,StructType as Ae,TokenIdentifierType as X,TokenIdentifierValue as Y,U16Type as Ee,U16Value as Be,U32Type as Ie,U32Value as Ve,U64Type as Z,U64Value as ee,U8Type as Se,U8Value as Fe,VariadicType as Ne,VariadicValue as Re}from"@multiversx/sdk-core";import{WarpConstants as C,WarpSerializer as pt}from"@vleap/warps";var Pe=new RegExp(`${C.ArgParamsSeparator}(.*)`),E=class{constructor(){this.coreSerializer=new pt}typedToString(e){if(e.hasClassOrSuperclass(J.ClassName))return e.isSet()?`option:${this.typedToString(e.getTypedValue())}`:"option:null";if(e.hasClassOrSuperclass(K.ClassName))return e.isSet()?`optional:${this.typedToString(e.getTypedValue())}`:"optional:null";if(e.hasClassOrSuperclass(Ce.ClassName)){let t=e.getItems(),n=t.map(o=>this.typedToString(o).split(C.ArgParamsSeparator)[0])[0],a=t.map(o=>this.typedToString(o).split(C.ArgParamsSeparator)[1]);return`list:${n}:${a.join(",")}`}if(e.hasClassOrSuperclass(Re.ClassName)){let t=e.getItems(),n=t.map(o=>this.typedToString(o).split(C.ArgParamsSeparator)[0])[0],a=t.map(o=>this.typedToString(o).split(C.ArgParamsSeparator)[1]);return`variadic:${n}:${a.join(",")}`}if(e.hasClassOrSuperclass(Te.ClassName)){let t=e.getItems(),r=t.map(s=>this.typedToString(s).split(C.ArgParamsSeparator)[0]),n=t.map(s=>this.typedToString(s).split(C.ArgParamsSeparator)[1]),a=r.join(C.ArgCompositeSeparator),o=n.join(C.ArgCompositeSeparator);return`composite(${a}):${o}`}if(e.hasClassOrSuperclass(Q.ClassName)||e.getType().getName()==="BigUint")return`biguint:${BigInt(e.valueOf().toFixed())}`;if(e.hasClassOrSuperclass(Fe.ClassName))return`uint8:${e.valueOf().toNumber()}`;if(e.hasClassOrSuperclass(Be.ClassName))return`uint16:${e.valueOf().toNumber()}`;if(e.hasClassOrSuperclass(Ve.ClassName))return`uint32:${e.valueOf().toNumber()}`;if(e.hasClassOrSuperclass(ee.ClassName))return`uint64:${BigInt(e.valueOf().toFixed())}`;if(e.hasClassOrSuperclass(be.ClassName))return`string:${e.valueOf()}`;if(e.hasClassOrSuperclass(ge.ClassName))return`bool:${e.valueOf()}`;if(e.hasClassOrSuperclass(fe.ClassName))return`address:${e.valueOf().toBech32()}`;if(e.hasClassOrSuperclass(Y.ClassName))return`token:${e.valueOf()}`;if(e.hasClassOrSuperclass(ye.ClassName))return`hex:${e.valueOf().toString("hex")}`;if(e.hasClassOrSuperclass(We.ClassName))return`codemeta:${e.valueOf().toString()}`;if(e.getType().getName()==="EsdtTokenPayment"){let t=e.getFieldValue("token_identifier").valueOf(),r=e.getFieldValue("token_nonce").valueOf(),n=e.getFieldValue("amount").valueOf();return`esdt:${t}|${r}|${n}`}throw new Error(`WarpArgSerializer (typedToString): Unsupported input type: ${e.getClassName()}`)}typedToNative(e){let t=this.typedToString(e);return this.coreSerializer.stringToNative(t)}nativeToTyped(e,t){let r=this.coreSerializer.nativeToString(e,t);return this.stringToTyped(r)}nativeToType(e){if(e.startsWith("composite")){let t=e.match(/\(([^)]+)\)/)?.[1];return new xe(...t.split(C.ArgCompositeSeparator).map(r=>this.nativeToType(r)))}if(e==="string")return new ve;if(e==="uint8")return new Se;if(e==="uint16")return new Ee;if(e==="uint32")return new Ie;if(e==="uint64")return new Z;if(e==="biguint")return new z;if(e==="bool")return new de;if(e==="address")return new me;if(e==="token")return new X;if(e==="hex")return new he;if(e==="codemeta")return new we;if(e==="esdt"||e==="nft")return new Ae("EsdtTokenPayment",[new G("token_identifier","",new X),new G("token_nonce","",new Z),new G("amount","",new z)]);throw new Error(`WarpArgSerializer (nativeToType): Unsupported input type: ${e}`)}stringToTyped(e){let[t,r]=e.split(/:(.*)/,2);if(t==="null"||t===null)return new T;if(t==="option"){let n=this.stringToTyped(r);return n instanceof T?J.newMissingTyped(n.getType()):J.newProvided(n)}if(t==="optional"){let n=this.stringToTyped(r);return n instanceof T?K.newMissing():new K(n.getType(),n)}if(t==="list"){let[n,a]=r.split(Pe,2),s=a.split(",").map(c=>this.stringToTyped(`${n}:${c}`));return new Ce(this.nativeToType(n),s)}if(t==="variadic"){let[n,a]=r.split(Pe,2),s=a.split(",").map(c=>this.stringToTyped(`${n}:${c}`));return new Re(new Ne(this.nativeToType(n)),s)}if(t.startsWith("composite")){let n=t.match(/\(([^)]+)\)/)?.[1],a=r.split(C.ArgCompositeSeparator),o=n.split(C.ArgCompositeSeparator),s=a.map((p,u)=>this.stringToTyped(`${o[u]}:${p}`)),c=s.map(p=>p.getType());return new Te(new xe(...c),s)}if(t==="string")return r?be.fromUTF8(r):new T;if(t==="uint8")return r?new Fe(Number(r)):new T;if(t==="uint16")return r?new Be(Number(r)):new T;if(t==="uint32")return r?new Ve(Number(r)):new T;if(t==="uint64")return r?new ee(BigInt(r)):new T;if(t==="biguint")return r?new Q(BigInt(r)):new T;if(t==="bool")return r?new ge(typeof r=="boolean"?r:r==="true"):new T;if(t==="address")return r?new fe(nt.newFromBech32(r)):new T;if(t==="token")return r?new Y(r):new T;if(t==="hex")return r?ye.fromHex(r):new T;if(t==="codemeta")return new We(at.newFromBytes(Uint8Array.from(Buffer.from(r,"hex"))));if(t==="esdt"){let n=r.split(C.ArgCompositeSeparator);return new ct(this.nativeToType("esdt"),[new j(new Y(n[0]),"token_identifier"),new j(new ee(BigInt(n[1])),"token_nonce"),new j(new Q(BigInt(n[2])),"amount")])}throw new Error(`WarpArgSerializer (stringToTyped): Unsupported input type: ${t}`)}typeToString(e){if(e instanceof ot)return"option:"+this.typeToString(e.getFirstTypeParameter());if(e instanceof st)return"optional:"+this.typeToString(e.getFirstTypeParameter());if(e instanceof it)return"list:"+this.typeToString(e.getFirstTypeParameter());if(e instanceof Ne)return"variadic:"+this.typeToString(e.getFirstTypeParameter());if(e instanceof ve)return"string";if(e instanceof Se)return"uint8";if(e instanceof Ee)return"uint16";if(e instanceof Ie)return"uint32";if(e instanceof Z)return"uint64";if(e instanceof z)return"biguint";if(e instanceof de)return"bool";if(e instanceof me)return"address";if(e instanceof X)return"token";if(e instanceof he)return"hex";if(e instanceof we)return"codemeta";if(e instanceof Ae&&e.getClassName()==="EsdtTokenPayment")return"esdt";throw new Error(`WarpArgSerializer (typeToString): Unsupported input type: ${e.getClassName()}`)}};var V=class{constructor(e,t){this.config=e;this.chain=t;this.abi=new B(e,t),this.serializer=new E,this.cache=new gt(e.cache?.type)}async getTransactionExecutionResults(e,t){let{actionIndex:r}=Ue(e),n=this.cache.get(ht.WarpExecutable(this.config.env,e.meta?.hash||"",r))??[],a=await this.extractContractResults(e,t,n),o=dt(this.config,[],e,r,a),s=ft(e,a.results);return{success:t.status.isSuccessful(),warp:e,action:r,user:this.config.user?.wallets?.[this.chain.name]||null,txHash:t.hash,next:o,values:a.values,results:a.results,messages:s}}async extractContractResults(e,t,r){let{action:n,actionIndex:a}=Ue(e),o=[],s={};if(!e.results||n.type!=="contract")return{values:o,results:s};if(!Object.values(e.results).some(w=>w.includes("out")||w.includes("event"))){for(let[w,m]of Object.entries(e.results))s[w]=m;return{values:o,results:await U(e,s,a,r,this.config.transform?.runner)}}let p=await this.abi.getAbiForAction(n),u=new mt({abi:p}),h=new lt({abi:p}).parseExecute({transactionOnNetwork:t,function:n.func||void 0});for(let[w,m]of Object.entries(e.results)){if(m.startsWith(_e.Transform.Prefix))continue;if(m.startsWith("input.")){s[w]=m;continue}let v=ke(m);if(v!==null&&v!==a){s[w]=null;continue}let[W,A,b]=m.split(".");if(W==="event"){if(!A||isNaN(Number(b)))continue;let R=Number(b),y=ut(t,A),F=u.parseEvents({events:y})[0],P=Object.values(F)[R]||null;o.push(P),s[w]=P&&P.valueOf()}else if(W==="out"||W.startsWith("out[")){if(!A)continue;let R=Number(A),y=h.values[R-1]||null;b&&(y=y[b]||null),y&&typeof y=="object"&&(y="toFixed"in y?y.toFixed():y.valueOf()),o.push(y),s[w]=y&&y.valueOf()}else s[w]=m}return{values:o,results:await U(e,s,a,r)}}async extractQueryResults(e,t,r,n){let a=t.map(p=>this.serializer.typedToString(p)),o=t.map(p=>this.serializer.typedToNative(p)[1]),s={};if(!e.results)return{values:a,results:s};let c=p=>{let u=p.split(".").slice(1).map(h=>parseInt(h)-1);if(u.length===0)return;let l=o[u[0]];for(let h=1;h<u.length;h++){if(l==null)return;l=l[u[h]]}return l};for(let[p,u]of Object.entries(e.results)){if(u.startsWith(_e.Transform.Prefix))continue;let l=ke(u);if(l!==null&&l!==r){s[p]=null;continue}u.startsWith("out.")||u==="out"||u.startsWith("out[")?s[p]=c(u)||null:s[p]=u}return{values:a,results:await U(e,s,r,n)}}async resolveWarpResultsRecursively(e){let t=e.warp,r=e.entryActionIndex,n=e.executor,a=e.inputs,o=e.meta,s=new Map,c=new Set,p=this;async function u(m,v=[]){if(s.has(m))return s.get(m);if(c.has(m))throw new Error(`Circular dependency detected at action ${m}`);c.add(m);let W=t.actions[m-1];if(!W)throw new Error(`Action ${m} not found`);let A;if(W.type==="query")A=await n.executeQuery(t,m,v);else if(W.type==="collect")A=await n.executeCollect(t,m,v,o);else throw new Error(`Unsupported or interactive action type: ${W.type}`);if(s.set(m,A),t.results)for(let b of Object.values(t.results)){let y=String(b).match(/^out\[(\d+)\]/);if(y){let F=parseInt(y[1],10);F!==m&&!s.has(F)&&await u(F)}}return c.delete(m),A}await u(r,a);let l={};for(let m of s.values())for(let[v,W]of Object.entries(m.results))W!==null?l[v]=W:v in l||(l[v]=null);let h=await U(t,l,r,a,this.config.transform?.runner);return{...s.get(r),action:r,results:h}}};import{Address as yt,AddressValue as wt,BigUIntType as Wt,BigUIntValue as Oe,BooleanValue as xt,BytesValue as Tt,CodeMetadata as Ct,CodeMetadataValue as vt,CompositeType as bt,CompositeValue as At,Field as te,FieldDefinition as re,List as Et,NothingValue as Bt,OptionalValue as ne,OptionValue as ae,StringValue as It,Struct as Vt,StructType as St,TokenIdentifierType as Ft,TokenIdentifierValue as Me,U16Value as Nt,U32Value as Rt,U64Type as Pt,U64Value as $e,U8Value as Ut,VariadicValue as kt}from"@multiversx/sdk-core";var zr=(i,e)=>i?ae.newProvided(i):e?ae.newMissingTyped(e):ae.newMissing(),Qr=(i,e)=>i?new ne(i.getType(),i):e?new ne(e):ne.newMissing(),jr=i=>{if(i.length===0)throw new Error("Cannot create a list from an empty array");let e=i[0].getType();return new Et(e,i)},Gr=i=>kt.fromItems(...i),Kr=i=>{let e=i.map(t=>t.getType());return new At(new bt(...e),i)},Jr=i=>It.fromUTF8(i),Xr=i=>new Ut(i),Yr=i=>new Nt(i),Zr=i=>new Rt(i),en=i=>new $e(i),tn=i=>new Oe(BigInt(i)),rn=i=>new xt(i),nn=i=>new wt(yt.newFromBech32(i)),an=i=>new Me(i),sn=i=>Tt.fromHex(i),Le=i=>new Vt(new St("EsdtTokenPayment",[new re("token_identifier","",new Ft),new re("token_nonce","",new Pt),new re("amount","",new Wt)]),[new te(new Me(i.token.identifier),"token_identifier"),new te(new $e(BigInt(i.token.nonce)),"token_nonce"),new te(new Oe(BigInt(i.amount)),"amount")]),on=i=>new vt(Ct.newFromBytes(Uint8Array.from(Buffer.from(i,"hex")))),cn=()=>new Bt;var d=class i{constructor(e,t){this.config=e;this.chain=t;this.serializer=new E,this.abi=new B(this.config,this.chain),this.results=new V(this.config,this.chain)}async createTransaction(e){let t=ie(e.warp,e.action),r=null;if(t.type==="transfer")r=await this.createTransferTransaction(e);else if(t.type==="contract")r=await this.createContractCallTransaction(e);else{if(t.type==="query")throw new Error("WarpMultiversxExecutor: Invalid action type for createTransactionForExecute; Use executeQuery instead");if(t.type==="collect")throw new Error("WarpMultiversxExecutor: Invalid action type for createTransactionForExecute; Use executeCollect instead")}if(!r)throw new Error(`WarpMultiversxExecutor: Invalid action type (${t.type})`);return r}async createTransferTransaction(e){let t=this.config.user?.wallets?.[e.chain.name];if(!t)throw new Error("WarpMultiversxExecutor: createTransfer - user address not set");let r=N.newFromBech32(t),n=new qe({chainID:e.chain.chainId}),a=e.data?Buffer.from(this.serializer.stringToTyped(e.data).valueOf()):null;return new zt({config:n}).createTransactionForTransfer(r,{receiver:N.newFromBech32(e.destination),nativeAmount:e.value,data:a?new Uint8Array(a):void 0})}async createContractCallTransaction(e){let t=this.config.user?.wallets?.[e.chain.name];if(!t)throw new Error("WarpMultiversxExecutor: createContractCall - user address not set");let r=ie(e.warp,e.action),n=N.newFromBech32(t),a=e.args.map(s=>this.serializer.stringToTyped(s)),o=new qe({chainID:e.chain.chainId});return new $t({config:o}).createTransactionForExecute(n,{contract:N.newFromBech32(e.destination),function:"func"in r&&r.func||"",gasLimit:"gasLimit"in r?BigInt(r.gasLimit||0):0n,arguments:a,nativeTransferAmount:e.value})}async executeQuery(e){let t=ie(e.warp,e.action);if(t.type!=="query")throw new Error(`WarpMultiversxExecutor: Invalid action type for executeQuery: ${t.type}`);let r=await this.abi.getAbiForAction(t),n=e.args.map(b=>this.serializer.stringToTyped(b)),a=i.getChainEntrypoint(e.chain,this.config.env),o=N.newFromBech32(e.destination),s=a.createSmartContractController(r),c=s.createQuery({contract:o,function:t.func||"",arguments:n}),p=await s.runQuery(c),u=p.returnCode==="ok",l=new _t,h=r.getEndpoint(p.function||t.func||""),w=(p.returnDataParts||[]).map(b=>Buffer.from(b)),m=l.buffersToValues(w,h.output),{values:v,results:W}=await this.results.extractQueryResults(e.warp,m,e.action,e.resolvedInputs),A=Jt(this.config,[],e.warp,e.action,W);return{success:u,warp:e.warp,action:e.action,user:this.config.user?.wallets?.[e.chain.name]||null,txHash:null,next:A,values:v,results:W,messages:Gt(e.warp,W)}}async preprocessInput(e,t,r,n){if(r==="esdt"){let[a,o,s,c]=n.split(De.ArgCompositeSeparator);if(c)return t;let p=new qt({identifier:a,nonce:BigInt(o)});if(!new Dt().isFungible(p))return t;let h=Kt(a)?.decimals;if(h||(h=(await(await fetch(`${e.apiUrl}/tokens/${a}`)).json()).decimals),!h)throw new Error(`WarpActionExecutor: Decimals not found for token ${a}`);let w=Le(new Ht({token:p,amount:Xt(s,h)}));return this.serializer.typedToString(w)+De.ArgCompositeSeparator+h}return t}static getChainEntrypoint(e,t){let r="warp-sdk";return t==="devnet"?new Ot({url:e.apiUrl,kind:"api",clientName:r}):t==="testnet"?new Lt({url:e.apiUrl,kind:"api",clientName:r}):new Mt({url:e.apiUrl,kind:"api",clientName:r})}async signMessage(e,t){let r=Qt.fromString(t);return(await new jt(r).sign(new Uint8Array(Buffer.from(e,"utf-8")))).toString()}};var k=class{constructor(e){this.config=e}async getContract(e,t){try{let a=await d.getChainEntrypoint(t,this.config.env).createNetworkProvider().doGetGeneric(`accounts/${e}`);return{address:e,owner:a.ownerAddress,verified:a.isVerified||!1}}catch(r){return He.error("WarpContractLoader: getContract error",r),null}}async getVerificationInfo(e,t){try{let a=await d.getChainEntrypoint(t,this.config.env).createNetworkProvider().doGetGeneric(`accounts/${e}/verification`);return{codeHash:a.codeHash,abi:a.source.abi}}catch(r){return He.error("WarpContractLoader: getVerificationInfo error",r),null}}};var B=class{constructor(e,t){this.config=e;this.chain=t;this.contractLoader=new k(this.config),this.cache=new Yt(this.config.cache?.type)}async createFromRaw(e){return JSON.parse(e)}async createFromTransaction(e){let t=await this.createFromRaw(e.data.toString());return t.meta={chain:this.chain.name,hash:e.hash,creator:e.sender.toBech32(),createdAt:new Date(e.timestamp*1e3).toISOString()},t}async createFromTransactionHash(e,t){let r=Zt.WarpAbi(this.config.env,e);if(t){let o=this.cache.get(r);if(o)return Qe.info(`WarpAbiBuilder (createFromTransactionHash): Warp abi found in cache: ${e}`),o}let a=d.getChainEntrypoint(this.chain,this.config.env).createNetworkProvider();try{let o=await a.getTransaction(e),s=await this.createFromTransaction(o);return t&&t.ttl&&s&&this.cache.set(r,s,t.ttl),s}catch(o){return Qe.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 se.create(t.abi)}async fetchAbi(e){if(!e.abi)throw new Error("WarpActionExecutor: ABI not found");if(e.abi.startsWith(ze.IdentifierType.Hash)){let t=e.abi.split(ze.IdentifierParamSeparatorDefault)[1],r=await this.createFromTransactionHash(t);if(!r)throw new Error(`WarpActionExecutor: ABI not found for hash: ${e.abi}`);return se.create(r.content)}else{let r=await(await fetch(e.abi)).json();return se.create(r)}}};import{Address as je,TransactionsFactoryConfig as er,TransferTransactionsFactory as tr}from"@multiversx/sdk-core";import{WarpBrandBuilder as rr,WarpLogger as nr}from"@vleap/warps";import{Buffer as ar}from"buffer";var _=class{constructor(e,t){this.config=e;this.chain=t;this.core=new rr(e)}async createInscriptionTransaction(e){let t=this.config.user?.wallets?.[this.chain.name];if(!t)throw new Error("BrandBuilder: user address not set");let r=new er({chainID:this.chain.chainId}),n=new tr({config:r}),a=je.newFromBech32(t),o=JSON.stringify(e);return await n.createTransactionForNativeTokenTransfer(a,{receiver:je.newFromBech32(t),nativeAmount:BigInt(0),data:Uint8Array.from(ar.from(o))})}async createFromTransaction(e,t=!1){return await this.core.createFromRaw(e.data.toString(),t)}async createFromTransactionHash(e){let r=d.getChainEntrypoint(this.chain,this.config.env).createNetworkProvider();try{let n=await r.getTransaction(e);return this.createFromTransaction(n)}catch(n){return nr.error("BrandBuilder: Error creating from transaction hash",n),null}}};import{Address as Ge,TransactionsFactoryConfig as ir,TransferTransactionsFactory as sr}from"@multiversx/sdk-core";import{WarpBuilder as Ke,WarpCache as or,WarpCacheKey as cr,WarpLogger as Je}from"@vleap/warps";var O=class extends Ke{constructor(t,r){super(t);this.config=t;this.chain=r;this.cache=new or(t.cache?.type),this.core=new Ke(t)}async createInscriptionTransaction(t){let r=this.config.user?.wallets?.[this.chain.name];if(!r)throw new Error("WarpBuilder: user address not set");let n=new ir({chainID:this.chain.chainId}),a=new sr({config:n}),o=Ge.newFromBech32(r),s=JSON.stringify(t),c=await a.createTransactionForTransfer(o,{receiver:Ge.newFromBech32(r),nativeAmount:BigInt(0),data:Uint8Array.from(Buffer.from(s))});return c.gasLimit=c.gasLimit+BigInt(2e6),c}async createFromTransaction(t,r=!1){let n=await this.core.createFromRaw(t.data.toString(),r);return n.meta={chain:this.chain.name,hash:t.hash,creator:t.sender.toBech32(),createdAt:new Date(t.timestamp*1e3).toISOString()},n}async createFromTransactionHash(t,r){let n=cr.Warp(this.config.env,t);if(r){let s=this.cache.get(n);if(s)return Je.info(`WarpBuilder (createFromTransactionHash): Warp found in cache: ${t}`),s}let o=d.getChainEntrypoint(this.chain,this.config.env).createNetworkProvider();try{let s=await o.getTransaction(t),c=await this.createFromTransaction(s);return r&&r.ttl&&c&&this.cache.set(n,c,r.ttl),c}catch(s){return Je.error("WarpBuilder: Error creating from transaction hash",s),null}}};import{Address as Xe}from"@multiversx/sdk-core";var M=class{constructor(e,t){this.config=e;this.chain=t}async getAccount(e){let r=await d.getChainEntrypoint(this.chain,this.config.env).createNetworkProvider().getAccount(Xe.newFromBech32(e));return{address:r.address.toBech32(),balance:r.balance}}async getAccountAssets(e){return(await d.getChainEntrypoint(this.chain,this.config.env).createNetworkProvider().getFungibleTokensOfAccount(Xe.newFromBech32(e))).map(n=>({identifier:n.token.identifier,name:n.raw.name,amount:n.amount,decimals:n.raw.decimals,logoUrl:n.raw.assets?.pngUrl||""}))}};var ya={Egld:{Identifier:"EGLD",EsdtIdentifier:"EGLD-000000",DisplayName:"eGold",Decimals:18}},pr=(r=>(r.MultiversxExplorer="multiversx_explorer",r.MultiversxExplorerDevnet="multiversx_explorer_devnet",r.MultiversxExplorerTestnet="multiversx_explorer_testnet",r))(pr||{}),ur=(r=>(r.VibechainExplorer="vibechain_explorer",r.VibechainExplorerDevnet="vibechain_explorer_devnet",r.VibechainExplorerTestnet="vibechain_explorer_testnet",r))(ur||{}),Ye={multiversx:{mainnet:["multiversx_explorer"],testnet:["multiversx_explorer_testnet"],devnet:["multiversx_explorer_devnet"]},vibechain:{mainnet:["vibechain_explorer"],testnet:["vibechain_explorer_testnet"],devnet:["vibechain_explorer_devnet"]}},I={multiversx_explorer:"https://explorer.multiversx.com",multiversx_explorer_devnet:"https://devnet-explorer.multiversx.com",multiversx_explorer_testnet:"https://testnet-explorer.multiversx.com",vibechain_explorer:"https://vibeox-explorer.multiversx.com",vibechain_explorer_devnet:"https://vibeox-explorer.multiversx.com",vibechain_explorer_testnet:"https://vibeox-explorer.multiversx.com"};var $=class{constructor(e,t){this.chain=e;this.config=t}getExplorers(){let e=Ye[this.chain];if(!e)return["multiversx_explorer"];let t=e[this.config.env];return t||["multiversx_explorer"]}getPrimaryExplorer(){return this.getExplorers()[0]}getExplorerUrlByName(e){let t=this.config.preferences?.explorers?.[this.chain];if(t&&!e){let a=I[t];if(a)return a}if(e){let a=I[e];if(a)return a}let r=this.getPrimaryExplorer();return I[r]||I[r]}getAccountUrl(e,t){return`${this.getExplorerUrlByName(t)}/accounts/${e}`}getTransactionUrl(e,t){return`${this.getExplorerUrlByName(t)}/transactions/${e}`}getBlockUrl(e,t){return`${this.getExplorerUrlByName(t)}/blocks/${e}`}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=I[n];a&&(r[n]=`${a}/accounts/${e}`)}),r}getTransactionUrls(e){let t=this.getAllExplorers(),r={};return t.forEach(n=>{let a=I[n];a&&(r[n]=`${a}/transactions/${e}`)}),r}};import{AbiRegistry as et,Address as f,AddressValue as ce,BytesValue as g,SmartContractTransactionsFactory as mr,TransactionsFactoryConfig as fr}from"@multiversx/sdk-core";import{WarpCache as dr,WarpCacheKey as pe,WarpLogger as ue}from"@vleap/warps";var oe={buildInfo:{rustc:{version:"1.86.0",commitHash:"05f9846f893b09a1be1fc8560e33fc3c815cfecb",commitDate:"2025-03-31",channel:"Stable",short:"rustc 1.86.0 (05f9846f8 2025-03-31)"},contractCrate:{name:"registry",version:"0.0.1"},framework:{name:"multiversx-sc",version:"0.51.1"}},name:"RegistryContract",constructor:{inputs:[{name:"unit_price",type:"BigUint"},{name:"vault",type:"Address"}],outputs:[]},upgradeConstructor:{inputs:[],outputs:[]},endpoints:[{name:"registerWarp",mutability:"mutable",payableInTokens:["EGLD"],inputs:[{name:"hash",type:"bytes"},{name:"alias_opt",type:"optional<bytes>",multi_arg:!0},{name:"brand_opt",type:"optional<bytes>",multi_arg:!0}],outputs:[],allow_multiple_var_args:!0},{name:"unregisterWarp",mutability:"mutable",inputs:[{name:"warp",type:"bytes"}],outputs:[]},{name:"upgradeWarp",mutability:"mutable",payableInTokens:["EGLD"],inputs:[{name:"alias",type:"bytes"},{name:"new_warp",type:"bytes"}],outputs:[]},{name:"setWarpAlias",mutability:"mutable",payableInTokens:["EGLD"],inputs:[{name:"hash",type:"bytes"},{name:"alias",type:"bytes"}],outputs:[]},{name:"forceRemoveAlias",mutability:"mutable",inputs:[{name:"hash",type:"bytes"}],outputs:[]},{name:"verifyWarp",mutability:"mutable",inputs:[{name:"warp",type:"bytes"}],outputs:[]},{name:"transferOwnership",mutability:"mutable",inputs:[{name:"warp",type:"bytes"},{name:"new_owner",type:"Address"}],outputs:[]},{name:"getUserWarps",mutability:"readonly",inputs:[{name:"address",type:"Address"}],outputs:[{type:"variadic<InfoView>",multi_result:!0}]},{name:"getInfoByAlias",mutability:"readonly",inputs:[{name:"alias",type:"bytes"}],outputs:[{type:"InfoView"}]},{name:"getInfoByHash",mutability:"readonly",inputs:[{name:"hash",type:"bytes"}],outputs:[{type:"InfoView"}]},{name:"setVault",onlyOwner:!0,mutability:"mutable",inputs:[{name:"vault",type:"Address"}],outputs:[]},{name:"setUnitPrice",onlyOwner:!0,mutability:"mutable",inputs:[{name:"amount",type:"BigUint"}],outputs:[]},{name:"addAdmin",onlyOwner:!0,mutability:"mutable",inputs:[{name:"address",type:"Address"}],outputs:[]},{name:"removeAdmin",onlyOwner:!0,mutability:"mutable",inputs:[{name:"address",type:"Address"}],outputs:[]},{name:"getConfig",mutability:"readonly",inputs:[],outputs:[{type:"ConfigView"}]},{name:"registerBrand",mutability:"mutable",payableInTokens:["EGLD"],inputs:[{name:"hash",type:"bytes"}],outputs:[]},{name:"brandWarp",mutability:"mutable",payableInTokens:["EGLD"],inputs:[{name:"warp",type:"bytes"},{name:"brand",type:"bytes"}],outputs:[]},{name:"getUserBrands",mutability:"readonly",inputs:[{name:"user",type:"Address"}],outputs:[{type:"variadic<bytes>",multi_result:!0}]},{name:"setChain",onlyOwner:!0,mutability:"mutable",inputs:[{name:"name",type:"bytes"},{name:"display_name",type:"bytes"},{name:"chain_id",type:"bytes"},{name:"block_time",type:"u32"},{name:"address_hrp",type:"bytes"},{name:"api_url",type:"bytes"},{name:"explorer_url",type:"bytes"},{name:"native_token",type:"bytes"}],outputs:[]},{name:"removeChain",onlyOwner:!0,mutability:"mutable",inputs:[{name:"name",type:"bytes"}],outputs:[]},{name:"getChain",mutability:"readonly",inputs:[{name:"name",type:"bytes"}],outputs:[{type:"ChainView"}]},{name:"getChains",mutability:"readonly",inputs:[],outputs:[{type:"variadic<ChainView>",multi_result:!0}]}],events:[{identifier:"warpRegistered",inputs:[{name:"hash",type:"bytes",indexed:!0},{name:"alias",type:"bytes",indexed:!0},{name:"trust",type:"bytes",indexed:!0}]},{identifier:"warpUnregistered",inputs:[{name:"hash",type:"bytes",indexed:!0}]},{identifier:"warpUpgraded",inputs:[{name:"alias",type:"bytes",indexed:!0},{name:"new_warp",type:"bytes",indexed:!0},{name:"trust",type:"bytes",indexed:!0}]},{identifier:"warpVerified",inputs:[{name:"hash",type:"bytes",indexed:!0}]},{identifier:"aliasUpdated",inputs:[{name:"hash",type:"bytes",indexed:!0},{name:"alias",type:"bytes",indexed:!0}]},{identifier:"ownershipTransferred",inputs:[{name:"warp",type:"bytes",indexed:!0},{name:"old_owner",type:"Address",indexed:!0},{name:"new_owner",type:"Address",indexed:!0}]}],esdtAttributes:[],hasCallback:!1,types:{ChainView:{type:"struct",fields:[{name:"name",type:"bytes"},{name:"display_name",type:"bytes"},{name:"chain_id",type:"bytes"},{name:"block_time",type:"u32"},{name:"address_hrp",type:"bytes"},{name:"api_url",type:"bytes"},{name:"explorer_url",type:"bytes"},{name:"native_token",type:"bytes"}]},ConfigView:{type:"struct",fields:[{name:"unit_price",type:"BigUint"},{name:"admins",type:"List<Address>"}]},InfoView:{type:"struct",fields:[{name:"hash",type:"bytes"},{name:"alias",type:"Option<bytes>"},{name:"trust",type:"bytes"},{name:"owner",type:"Address"},{name:"created_at",type:"u64"},{name:"upgraded_at",type:"u64"},{name:"brand",type:"Option<bytes>"},{name:"upgrade",type:"Option<bytes>"}]}}};var x=i=>{if(i==="devnet")return"erd1qqqqqqqqqqqqqpgqje2f99vr6r7sk54thg03c9suzcvwr4nfl3tsfkdl36";if(i==="testnet")throw new Error("Multiversx testnet is not supported");return"erd1qqqqqqqqqqqqqpgq3mrpj3u6q7tejv6d7eqhnyd27n9v5c5tl3ts08mffe"};var L=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}),Ze=i=>({unitPrice:BigInt(i.unit_price.toString()),admins:i.admins.map(e=>e.toBech32())});var q=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=this.config.user?.wallets?.[this.chain.name]||null}async init(){await this.loadRegistryConfigs()}getRegistryConfig(){return this.registryConfig}async createWarpRegisterTransaction(e,t,r){if(this.registryConfig.unitPrice===BigInt(0))throw new Error("WarpRegistry: config not loaded. forgot to call init()?");if(!this.userWallet)throw new Error("WarpRegistry: user address not set");let n=f.newFromBech32(this.userWallet),a=()=>this.isCurrentUserAdmin()?BigInt(0):t&&r?this.registryConfig.unitPrice*BigInt(3):t?this.registryConfig.unitPrice*BigInt(2):this.registryConfig.unitPrice,o=()=>t&&r?[g.fromHex(e),g.fromUTF8(t),g.fromHex(r)]:t?[g.fromHex(e),g.fromUTF8(t)]:[g.fromHex(e)];return await this.getFactory().createTransactionForExecute(n,{contract:f.newFromBech32(x(this.config.env)),function:"registerWarp",gasLimit:BigInt(1e7),nativeTransferAmount:a(),arguments:o()})}async createWarpUnregisterTransaction(e){if(!this.userWallet)throw new Error("WarpRegistry: user address not set");let t=f.newFromBech32(this.userWallet);return await this.getFactory().createTransactionForExecute(t,{contract:f.newFromBech32(x(this.config.env)),function:"unregisterWarp",gasLimit:BigInt(1e7),arguments:[g.fromHex(e)]})}async createWarpUpgradeTransaction(e,t){if(this.registryConfig.unitPrice===BigInt(0))throw new Error("WarpRegistry: config not loaded. forgot to call init()?");if(!this.userWallet)throw new Error("WarpRegistry: user address not set");let r=f.newFromBech32(this.userWallet);return await this.getFactory().createTransactionForExecute(r,{contract:f.newFromBech32(x(this.config.env)),function:"upgradeWarp",gasLimit:BigInt(1e7),nativeTransferAmount:this.isCurrentUserAdmin()?void 0:this.registryConfig.unitPrice,arguments:[g.fromUTF8(e),g.fromHex(t)]})}async createWarpAliasSetTransaction(e,t){if(!this.userWallet)throw new Error("WarpRegistry: user address not set");let r=f.newFromBech32(this.userWallet);return await this.getFactory().createTransactionForExecute(r,{contract:f.newFromBech32(x(this.config.env)),function:"setWarpAlias",gasLimit:BigInt(1e7),nativeTransferAmount:this.isCurrentUserAdmin()?void 0:this.registryConfig.unitPrice,arguments:[g.fromHex(e),g.fromUTF8(t)]})}async createWarpVerifyTransaction(e){if(!this.userWallet)throw new Error("WarpRegistry: user address not set");let t=f.newFromBech32(this.userWallet);return await this.getFactory().createTransactionForExecute(t,{contract:f.newFromBech32(x(this.config.env)),function:"verifyWarp",gasLimit:BigInt(1e7),arguments:[g.fromHex(e)]})}async createWarpTransferOwnershipTransaction(e,t){if(!this.userWallet)throw new Error("WarpRegistry: user address not set");let r=f.newFromBech32(this.userWallet);return await this.getFactory().createTransactionForExecute(r,{contract:f.newFromBech32(x(this.config.env)),function:"transferOwnership",gasLimit:BigInt(1e7),arguments:[g.fromHex(e),new ce(new f(t))]})}async createBrandRegisterTransaction(e){if(this.registryConfig.unitPrice===BigInt(0))throw new Error("WarpRegistry: config not loaded. forgot to call init()?");if(!this.userWallet)throw new Error("WarpRegistry: user address not set");let t=f.newFromBech32(this.userWallet);return await this.getFactory().createTransactionForExecute(t,{contract:f.newFromBech32(x(this.config.env)),function:"registerBrand",gasLimit:BigInt(1e7),nativeTransferAmount:this.isCurrentUserAdmin()?void 0:this.registryConfig.unitPrice,arguments:[g.fromHex(e)]})}async createWarpBrandingTransaction(e,t){if(!this.userWallet)throw new Error("WarpRegistry: user address not set");let r=f.newFromBech32(this.userWallet);return await this.getFactory().createTransactionForExecute(r,{contract:f.newFromBech32(x(this.config.env)),function:"brandWarp",gasLimit:BigInt(1e7),nativeTransferAmount:this.isCurrentUserAdmin()?void 0:this.registryConfig.unitPrice,arguments:[g.fromHex(e),g.fromHex(t)]})}async getInfoByAlias(e,t){try{let r=pe.RegistryInfo(this.config.env,e),n=t?this.cache.get(r):null;if(n)return ue.info(`WarpRegistry (getInfoByAlias): RegistryInfo found in cache: ${e}`),n;let a=f.newFromBech32(x(this.config.env)),o=this.getController(),s=o.createQuery({contract:a,function:"getInfoByAlias",arguments:[g.fromUTF8(e)]}),c=await o.runQuery(s),[p]=o.parseQueryResponse(c),u=p?L(p):null,l=u?.brand?await this.fetchBrand(u.brand):null;return t&&t.ttl&&this.cache.set(r,{registryInfo:u,brand:l},t.ttl),{registryInfo:u,brand:l}}catch{return{registryInfo:null,brand:null}}}async getInfoByHash(e,t){try{let r=pe.RegistryInfo(this.config.env,e);if(t){let l=this.cache.get(r);if(l)return ue.info(`WarpRegistry (getInfoByHash): RegistryInfo found in cache: ${e}`),l}let n=f.newFromBech32(x(this.config.env)),a=this.getController(),o=a.createQuery({contract:n,function:"getInfoByHash",arguments:[g.fromHex(e)]}),s=await a.runQuery(o),[c]=a.parseQueryResponse(s),p=c?L(c):null,u=p?.brand?await this.fetchBrand(p.brand):null;return t&&t.ttl&&this.cache.set(r,{registryInfo:p,brand:u},t.ttl),{registryInfo:p,brand:u}}catch{return{registryInfo:null,brand:null}}}async getUserWarpRegistryInfos(e){try{let t=e||this.userWallet;if(!t)throw new Error("WarpRegistry: user address not set");let r=f.newFromBech32(x(this.config.env)),n=this.getController(),a=n.createQuery({contract:r,function:"getUserWarps",arguments:[new ce(new f(t))]}),o=await n.runQuery(a),[s]=n.parseQueryResponse(o);return s.map(L)}catch{return[]}}async getUserBrands(e){try{let t=e||this.userWallet;if(!t)throw new Error("WarpRegistry: user address not set");let r=f.newFromBech32(x(this.config.env)),n=this.getController(),a=n.createQuery({contract:r,function:"getUserBrands",arguments:[new ce(new f(t))]}),o=await n.runQuery(a),[s]=n.parseQueryResponse(o),c=s.map(l=>l.toString("hex")),p={ttl:365*24*60*60};return(await Promise.all(c.map(l=>this.fetchBrand(l,p)))).filter(l=>l!==null)}catch{return[]}}async fetchBrand(e,t){let r=pe.Brand(this.config.env,e),n=t?this.cache.get(r):null;if(n)return ue.info(`WarpRegistry (fetchBrand): Brand found in cache: ${e}`),n;let o=d.getChainEntrypoint(this.chain,this.config.env).createNetworkProvider();try{let s=await o.getTransaction(e),c=JSON.parse(s.data.toString());return c.meta={hash:s.hash,creator:s.sender.toBech32(),createdAt:new Date(s.timestamp*1e3).toISOString()},t&&t.ttl&&this.cache.set(r,c,t.ttl),c}catch{return null}}async loadRegistryConfigs(){let e=f.newFromBech32(x(this.config.env)),t=this.getController(),[r]=await t.query({contract:e,function:"getConfig",arguments:[]}),n=r?Ze(r):null;this.registryConfig=n||{unitPrice:BigInt(0),admins:[]}}getFactory(){let e=new fr({chainID:this.chain.chainId}),t=et.create(oe);return new mr({config:e,abi:t})}getController(){let e=d.getChainEntrypoint(this.chain,this.config.env),t=et.create(oe);return e.createSmartContractController(t)}isCurrentUserAdmin(){return!!this.userWallet&&this.registryConfig.admins.includes(this.userWallet)}};var D=(i,e,t)=>(r,n)=>{let a=t[r.env];return{chain:i,chainInfo:a,prefix:e,builder:()=>new O(r,a),executor:new d(r,a),results:new V(r,a),serializer:new E,registry:new q(r,a),explorer:new $(i,r),abiBuilder:()=>new B(r,a),brandBuilder:()=>new _(r,a),dataLoader:new M(r,a)}};var S="multiversx",tt=D(S,"mvx",{mainnet:{name:S,displayName:"MultiversX",chainId:"1",blockTime:6e3,addressHrp:"erd",apiUrl:"https://api.multiversx.com",nativeToken:"EGLD"},testnet:{name:S,displayName:"MultiversX Testnet",chainId:"T",blockTime:6e3,addressHrp:"erd",apiUrl:"https://testnet-api.multiversx.com",nativeToken:"EGLD"},devnet:{name:S,displayName:"MultiversX Devnet",chainId:"D",blockTime:6e3,addressHrp:"erd",apiUrl:"https://devnet-api.multiversx.com",nativeToken:"EGLD"}});var H="vibechain",le={name:H,displayName:"VibeChain",chainId:"V",blockTime:600,addressHrp:"vibe",apiUrl:"https://vibeox-api.multiversx.com",nativeToken:"VIBE"},rt=D(H,"vibe",{mainnet:le,testnet:le,devnet:le});var ni=(i,e)=>[tt(i,e),rt(i,e)],ai=()=>[S,H];export{S as ChainNameMultiversx,H as ChainNameVibechain,I as ExplorerUrls,pr as MultiversxExplorers,Ye as MultiversxExplorersConfig,ur as VibechainExplorers,B as WarpMultiversxAbiBuilder,_ as WarpMultiversxBrandBuilder,O as WarpMultiversxBuilder,ya as WarpMultiversxConstants,k as WarpMultiversxContractLoader,d as WarpMultiversxExecutor,$ as WarpMultiversxExplorer,q as WarpMultiversxRegistry,V as WarpMultiversxResults,E as WarpMultiversxSerializer,nn as address_value,tn as biguint_value,rn as boolean_value,on as codemeta_value,Kr as composite_value,D as createMultiversxAdapter,Le as esdt_value,ni as getAllMultiversxAdapters,ai as getAllMultiversxChainNames,tt as getMultiversxAdapter,x as getMultiversxRegistryAddress,rt as getVibechainAdapter,sn as hex_value,jr as list_value,cn as nothing_value,zr as option_value,Qr as optional_value,Jr as string_value,an as token_value,Yr as u16_value,Zr as u32_value,en as u64_value,Xr as u8_value,Gr as variadic_value};
|
package/package.json
CHANGED
|
@@ -1,13 +1,19 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vleap/warps-adapter-multiversx",
|
|
3
|
-
"version": "0.2.0-alpha.
|
|
3
|
+
"version": "0.2.0-alpha.28",
|
|
4
4
|
"description": "",
|
|
5
|
-
"
|
|
5
|
+
"type": "module",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
7
|
-
"
|
|
7
|
+
"exports": {
|
|
8
|
+
".": {
|
|
9
|
+
"types": "./dist/index.d.ts",
|
|
10
|
+
"import": "./dist/index.mjs",
|
|
11
|
+
"default": "./dist/index.mjs"
|
|
12
|
+
}
|
|
13
|
+
},
|
|
8
14
|
"scripts": {
|
|
9
15
|
"build": "tsup",
|
|
10
|
-
"test": "jest --config jest.config.
|
|
16
|
+
"test": "jest --config jest.config.mjs",
|
|
11
17
|
"lint": "tsc --noEmit",
|
|
12
18
|
"prepare": "npm run build",
|
|
13
19
|
"preversion": "npm run lint && npm run build"
|
|
@@ -31,6 +37,6 @@
|
|
|
31
37
|
},
|
|
32
38
|
"dependencies": {
|
|
33
39
|
"@multiversx/sdk-core": "^15.0.1",
|
|
34
|
-
"@vleap/warps": "^3.0.0-alpha.
|
|
40
|
+
"@vleap/warps": "^3.0.0-alpha.73"
|
|
35
41
|
}
|
|
36
42
|
}
|
package/dist/index.d.mts
DELETED
|
@@ -1,218 +0,0 @@
|
|
|
1
|
-
import * as _vleap_warps from '@vleap/warps';
|
|
2
|
-
import { WarpClientConfig, Adapter, WarpChain, WarpChainEnv, WarpChainInfo, AdapterFactory, AdapterWarpAbiBuilder, WarpAbi, WarpCacheConfig, WarpContractAction, WarpQueryAction, WarpBrand, WarpBuilder, AdapterWarpBuilder, Warp, WarpContract, WarpContractVerification, AdapterWarpExecutor, WarpExecutable, WarpExecution, WarpActionInputType, AdapterWarpExplorer, AdapterWarpRegistry, WarpRegistryConfigInfo, WarpRegistryInfo, AdapterWarpResults, ResolvedInput, WarpExecutionResults, AdapterWarpSerializer, WarpSerializer, WarpNativeValue, BaseWarpActionInputType, WarpAdapterGenericType } from '@vleap/warps';
|
|
3
|
-
import { TypedValue, Type, OptionValue, OptionalValue, List, VariadicValue, CompositeValue, StringValue, U8Value, U16Value, U32Value, U64Value, BigUIntValue, BooleanValue, AddressValue, TokenIdentifierValue, BytesValue, TokenTransfer, Struct, CodeMetadataValue, NothingValue, TransactionOnNetwork, AbiRegistry, Transaction, NetworkEntrypoint } from '@multiversx/sdk-core';
|
|
4
|
-
|
|
5
|
-
declare const getAllMultiversxAdapters: (config: WarpClientConfig, fallback?: Adapter) => Adapter[];
|
|
6
|
-
declare const getAllMultiversxChainNames: () => WarpChain[];
|
|
7
|
-
|
|
8
|
-
declare const createMultiversxAdapter: (chainName: string, chainPrefix: string, chainInfos: Record<WarpChainEnv, WarpChainInfo>) => AdapterFactory;
|
|
9
|
-
|
|
10
|
-
declare const ChainNameMultiversx: WarpChain;
|
|
11
|
-
declare const getMultiversxAdapter: _vleap_warps.AdapterFactory;
|
|
12
|
-
|
|
13
|
-
declare const ChainNameVibechain: WarpChain;
|
|
14
|
-
declare const getVibechainAdapter: _vleap_warps.AdapterFactory;
|
|
15
|
-
|
|
16
|
-
declare const getMultiversxRegistryAddress: (env: WarpChainEnv) => "erd1qqqqqqqqqqqqqpgqje2f99vr6r7sk54thg03c9suzcvwr4nfl3tsfkdl36" | "erd1qqqqqqqqqqqqqpgq3mrpj3u6q7tejv6d7eqhnyd27n9v5c5tl3ts08mffe";
|
|
17
|
-
|
|
18
|
-
declare const WarpMultiversxConstants: {
|
|
19
|
-
Egld: {
|
|
20
|
-
Identifier: string;
|
|
21
|
-
EsdtIdentifier: string;
|
|
22
|
-
DisplayName: string;
|
|
23
|
-
Decimals: number;
|
|
24
|
-
};
|
|
25
|
-
};
|
|
26
|
-
declare enum MultiversxExplorers {
|
|
27
|
-
MultiversxExplorer = "multiversx_explorer",
|
|
28
|
-
MultiversxExplorerDevnet = "multiversx_explorer_devnet",
|
|
29
|
-
MultiversxExplorerTestnet = "multiversx_explorer_testnet"
|
|
30
|
-
}
|
|
31
|
-
declare enum VibechainExplorers {
|
|
32
|
-
VibechainExplorer = "vibechain_explorer",
|
|
33
|
-
VibechainExplorerDevnet = "vibechain_explorer_devnet",
|
|
34
|
-
VibechainExplorerTestnet = "vibechain_explorer_testnet"
|
|
35
|
-
}
|
|
36
|
-
type ExplorerName = MultiversxExplorers | VibechainExplorers;
|
|
37
|
-
declare const MultiversxExplorersConfig: {
|
|
38
|
-
readonly multiversx: {
|
|
39
|
-
readonly mainnet: readonly [MultiversxExplorers.MultiversxExplorer];
|
|
40
|
-
readonly testnet: readonly [MultiversxExplorers.MultiversxExplorerTestnet];
|
|
41
|
-
readonly devnet: readonly [MultiversxExplorers.MultiversxExplorerDevnet];
|
|
42
|
-
};
|
|
43
|
-
readonly vibechain: {
|
|
44
|
-
readonly mainnet: readonly [VibechainExplorers.VibechainExplorer];
|
|
45
|
-
readonly testnet: readonly [VibechainExplorers.VibechainExplorerTestnet];
|
|
46
|
-
readonly devnet: readonly [VibechainExplorers.VibechainExplorerDevnet];
|
|
47
|
-
};
|
|
48
|
-
};
|
|
49
|
-
declare const ExplorerUrls: Record<ExplorerName, string>;
|
|
50
|
-
|
|
51
|
-
declare const option_value: (value: TypedValue | null, type?: Type) => OptionValue;
|
|
52
|
-
declare const optional_value: (value: TypedValue | null, type?: Type) => OptionalValue;
|
|
53
|
-
declare const list_value: (values: TypedValue[]) => List;
|
|
54
|
-
declare const variadic_value: (values: TypedValue[]) => VariadicValue;
|
|
55
|
-
declare const composite_value: (values: TypedValue[]) => CompositeValue;
|
|
56
|
-
declare const string_value: (value: string) => StringValue;
|
|
57
|
-
declare const u8_value: (value: number) => U8Value;
|
|
58
|
-
declare const u16_value: (value: number) => U16Value;
|
|
59
|
-
declare const u32_value: (value: number) => U32Value;
|
|
60
|
-
declare const u64_value: (value: bigint) => U64Value;
|
|
61
|
-
declare const biguint_value: (value: bigint | string | number) => BigUIntValue;
|
|
62
|
-
declare const boolean_value: (value: boolean) => BooleanValue;
|
|
63
|
-
declare const address_value: (value: string) => AddressValue;
|
|
64
|
-
declare const token_value: (value: string) => TokenIdentifierValue;
|
|
65
|
-
declare const hex_value: (value: string) => BytesValue;
|
|
66
|
-
declare const esdt_value: (value: TokenTransfer) => Struct;
|
|
67
|
-
declare const codemeta_value: (hexString: string) => CodeMetadataValue;
|
|
68
|
-
declare const nothing_value: () => NothingValue;
|
|
69
|
-
|
|
70
|
-
declare class WarpMultiversxAbiBuilder implements AdapterWarpAbiBuilder {
|
|
71
|
-
private readonly config;
|
|
72
|
-
private readonly chain;
|
|
73
|
-
private readonly contractLoader;
|
|
74
|
-
private readonly cache;
|
|
75
|
-
constructor(config: WarpClientConfig, chain: WarpChainInfo);
|
|
76
|
-
createFromRaw(encoded: string): Promise<WarpAbi>;
|
|
77
|
-
createFromTransaction(tx: TransactionOnNetwork): Promise<WarpAbi>;
|
|
78
|
-
createFromTransactionHash(hash: string, cache?: WarpCacheConfig): Promise<WarpAbi | null>;
|
|
79
|
-
getAbiForAction(action: WarpContractAction | WarpQueryAction): Promise<AbiRegistry>;
|
|
80
|
-
fetchAbi(action: WarpContractAction | WarpQueryAction): Promise<AbiRegistry>;
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
declare class WarpMultiversxBrandBuilder {
|
|
84
|
-
private readonly config;
|
|
85
|
-
private readonly chain;
|
|
86
|
-
private readonly core;
|
|
87
|
-
constructor(config: WarpClientConfig, chain: WarpChainInfo);
|
|
88
|
-
createInscriptionTransaction(brand: WarpBrand): Promise<Transaction>;
|
|
89
|
-
createFromTransaction(tx: TransactionOnNetwork, validateSchema?: boolean): Promise<WarpBrand>;
|
|
90
|
-
createFromTransactionHash(hash: string): Promise<WarpBrand | null>;
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
declare class WarpMultiversxBuilder extends WarpBuilder implements AdapterWarpBuilder {
|
|
94
|
-
protected readonly config: WarpClientConfig;
|
|
95
|
-
private readonly chain;
|
|
96
|
-
private readonly cache;
|
|
97
|
-
private readonly core;
|
|
98
|
-
constructor(config: WarpClientConfig, chain: WarpChainInfo);
|
|
99
|
-
createInscriptionTransaction(warp: Warp): Promise<Transaction>;
|
|
100
|
-
createFromTransaction(tx: TransactionOnNetwork, validate?: boolean): Promise<Warp>;
|
|
101
|
-
createFromTransactionHash(hash: string, cache?: WarpCacheConfig): Promise<Warp | null>;
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
declare class WarpMultiversxContractLoader {
|
|
105
|
-
private readonly config;
|
|
106
|
-
constructor(config: WarpClientConfig);
|
|
107
|
-
getContract(address: string, chain: WarpChainInfo): Promise<WarpContract | null>;
|
|
108
|
-
getVerificationInfo(address: string, chain: WarpChainInfo): Promise<WarpContractVerification | null>;
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
declare class WarpMultiversxExecutor implements AdapterWarpExecutor {
|
|
112
|
-
private readonly config;
|
|
113
|
-
private readonly chain;
|
|
114
|
-
private readonly serializer;
|
|
115
|
-
private readonly abi;
|
|
116
|
-
private readonly results;
|
|
117
|
-
constructor(config: WarpClientConfig, chain: WarpChainInfo);
|
|
118
|
-
createTransaction(executable: WarpExecutable): Promise<Transaction>;
|
|
119
|
-
createTransferTransaction(executable: WarpExecutable): Promise<Transaction>;
|
|
120
|
-
createContractCallTransaction(executable: WarpExecutable): Promise<Transaction>;
|
|
121
|
-
executeQuery(executable: WarpExecutable): Promise<WarpExecution>;
|
|
122
|
-
preprocessInput(chain: WarpChainInfo, input: string, type: WarpActionInputType, value: string): Promise<string>;
|
|
123
|
-
static getChainEntrypoint(chainInfo: WarpChainInfo, env: WarpChainEnv): NetworkEntrypoint;
|
|
124
|
-
signMessage(message: string, privateKey: string): Promise<string>;
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
declare class WarpMultiversxExplorer implements AdapterWarpExplorer {
|
|
128
|
-
private readonly chain;
|
|
129
|
-
private readonly config;
|
|
130
|
-
constructor(chain: WarpChain, config: WarpClientConfig);
|
|
131
|
-
private getExplorers;
|
|
132
|
-
private getPrimaryExplorer;
|
|
133
|
-
private getExplorerUrlByName;
|
|
134
|
-
getAccountUrl(address: string, explorer?: ExplorerName): string;
|
|
135
|
-
getTransactionUrl(hash: string, explorer?: ExplorerName): string;
|
|
136
|
-
getBlockUrl(blockNumber: string | number, explorer?: ExplorerName): string;
|
|
137
|
-
getAssetUrl(identifier: string, explorer?: ExplorerName): string;
|
|
138
|
-
getContractUrl(address: string, explorer?: ExplorerName): string;
|
|
139
|
-
getAllExplorers(): readonly ExplorerName[];
|
|
140
|
-
getExplorerByName(name: string): ExplorerName | undefined;
|
|
141
|
-
getAccountUrls(address: string): Record<ExplorerName, string>;
|
|
142
|
-
getTransactionUrls(hash: string): Record<ExplorerName, string>;
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
declare class WarpMultiversxRegistry implements AdapterWarpRegistry {
|
|
146
|
-
private config;
|
|
147
|
-
private chain;
|
|
148
|
-
private cache;
|
|
149
|
-
private userWallet;
|
|
150
|
-
registryConfig: WarpRegistryConfigInfo;
|
|
151
|
-
constructor(config: WarpClientConfig, chain: WarpChainInfo);
|
|
152
|
-
init(): Promise<void>;
|
|
153
|
-
getRegistryConfig(): WarpRegistryConfigInfo;
|
|
154
|
-
createWarpRegisterTransaction(txHash: string, alias?: string | null, brand?: string | null): Promise<Transaction>;
|
|
155
|
-
createWarpUnregisterTransaction(txHash: string): Promise<Transaction>;
|
|
156
|
-
createWarpUpgradeTransaction(alias: string, txHash: string): Promise<Transaction>;
|
|
157
|
-
createWarpAliasSetTransaction(txHash: string, alias: string): Promise<Transaction>;
|
|
158
|
-
createWarpVerifyTransaction(txHash: string): Promise<Transaction>;
|
|
159
|
-
createWarpTransferOwnershipTransaction(txHash: string, newOwner: string): Promise<Transaction>;
|
|
160
|
-
createBrandRegisterTransaction(txHash: string): Promise<Transaction>;
|
|
161
|
-
createWarpBrandingTransaction(warpHash: string, brandHash: string): Promise<Transaction>;
|
|
162
|
-
getInfoByAlias(alias: string, cache?: WarpCacheConfig): Promise<{
|
|
163
|
-
registryInfo: WarpRegistryInfo | null;
|
|
164
|
-
brand: WarpBrand | null;
|
|
165
|
-
}>;
|
|
166
|
-
getInfoByHash(hash: string, cache?: WarpCacheConfig): Promise<{
|
|
167
|
-
registryInfo: WarpRegistryInfo | null;
|
|
168
|
-
brand: WarpBrand | null;
|
|
169
|
-
}>;
|
|
170
|
-
getUserWarpRegistryInfos(user?: string): Promise<WarpRegistryInfo[]>;
|
|
171
|
-
getUserBrands(user?: string): Promise<WarpBrand[]>;
|
|
172
|
-
fetchBrand(hash: string, cache?: WarpCacheConfig): Promise<WarpBrand | null>;
|
|
173
|
-
private loadRegistryConfigs;
|
|
174
|
-
private getFactory;
|
|
175
|
-
private getController;
|
|
176
|
-
private isCurrentUserAdmin;
|
|
177
|
-
}
|
|
178
|
-
|
|
179
|
-
declare class WarpMultiversxResults implements AdapterWarpResults {
|
|
180
|
-
private readonly config;
|
|
181
|
-
private readonly chain;
|
|
182
|
-
private readonly abi;
|
|
183
|
-
private readonly serializer;
|
|
184
|
-
private readonly cache;
|
|
185
|
-
constructor(config: WarpClientConfig, chain: WarpChainInfo);
|
|
186
|
-
getTransactionExecutionResults(warp: Warp, tx: TransactionOnNetwork): Promise<WarpExecution>;
|
|
187
|
-
extractContractResults(warp: Warp, tx: TransactionOnNetwork, inputs: ResolvedInput[]): Promise<{
|
|
188
|
-
values: any[];
|
|
189
|
-
results: WarpExecutionResults;
|
|
190
|
-
}>;
|
|
191
|
-
extractQueryResults(warp: Warp, typedValues: TypedValue[], actionIndex: number, inputs: ResolvedInput[]): Promise<{
|
|
192
|
-
values: any[];
|
|
193
|
-
results: WarpExecutionResults;
|
|
194
|
-
}>;
|
|
195
|
-
resolveWarpResultsRecursively(props: {
|
|
196
|
-
warp: Warp;
|
|
197
|
-
entryActionIndex: number;
|
|
198
|
-
executor: {
|
|
199
|
-
executeQuery: Function;
|
|
200
|
-
executeCollect: Function;
|
|
201
|
-
};
|
|
202
|
-
inputs: ResolvedInput[];
|
|
203
|
-
meta?: Record<string, any>;
|
|
204
|
-
}): Promise<any>;
|
|
205
|
-
}
|
|
206
|
-
|
|
207
|
-
declare class WarpMultiversxSerializer implements AdapterWarpSerializer {
|
|
208
|
-
readonly coreSerializer: WarpSerializer;
|
|
209
|
-
constructor();
|
|
210
|
-
typedToString(value: TypedValue): string;
|
|
211
|
-
typedToNative(value: TypedValue): [WarpActionInputType, WarpNativeValue];
|
|
212
|
-
nativeToTyped(type: WarpActionInputType, value: WarpNativeValue): TypedValue;
|
|
213
|
-
nativeToType(type: BaseWarpActionInputType): WarpAdapterGenericType;
|
|
214
|
-
stringToTyped(value: string): TypedValue;
|
|
215
|
-
typeToString(type: Type): WarpActionInputType;
|
|
216
|
-
}
|
|
217
|
-
|
|
218
|
-
export { ChainNameMultiversx, ChainNameVibechain, type ExplorerName, ExplorerUrls, MultiversxExplorers, MultiversxExplorersConfig, VibechainExplorers, WarpMultiversxAbiBuilder, WarpMultiversxBrandBuilder, WarpMultiversxBuilder, WarpMultiversxConstants, WarpMultiversxContractLoader, WarpMultiversxExecutor, WarpMultiversxExplorer, WarpMultiversxRegistry, WarpMultiversxResults, WarpMultiversxSerializer, address_value, biguint_value, boolean_value, codemeta_value, composite_value, createMultiversxAdapter, esdt_value, getAllMultiversxAdapters, getAllMultiversxChainNames, getMultiversxAdapter, getMultiversxRegistryAddress, getVibechainAdapter, hex_value, list_value, nothing_value, option_value, optional_value, string_value, token_value, u16_value, u32_value, u64_value, u8_value, variadic_value };
|
package/dist/index.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";var ee=Object.defineProperty;var de=Object.getOwnPropertyDescriptor;var ge=Object.getOwnPropertyNames;var ye=Object.prototype.hasOwnProperty;var he=(s,e)=>{for(var t in e)ee(s,t,{get:e[t],enumerable:!0})},we=(s,e,t,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let a of ge(e))!ye.call(s,a)&&a!==t&&ee(s,a,{get:()=>e[a],enumerable:!(r=de(e,a))||r.enumerable});return s};var We=s=>we(ee({},"__esModule",{value:!0}),s);var Le={};he(Le,{ChainNameMultiversx:()=>O,ChainNameVibechain:()=>j,ExplorerUrls:()=>P,MultiversxExplorers:()=>le,MultiversxExplorersConfig:()=>ae,VibechainExplorers:()=>me,WarpMultiversxAbiBuilder:()=>R,WarpMultiversxBrandBuilder:()=>q,WarpMultiversxBuilder:()=>D,WarpMultiversxConstants:()=>_e,WarpMultiversxContractLoader:()=>L,WarpMultiversxExecutor:()=>w,WarpMultiversxExplorer:()=>H,WarpMultiversxRegistry:()=>z,WarpMultiversxResults:()=>U,WarpMultiversxSerializer:()=>N,address_value:()=>Ne,biguint_value:()=>Se,boolean_value:()=>Fe,codemeta_value:()=>Ue,composite_value:()=>be,createMultiversxAdapter:()=>Q,esdt_value:()=>te,getAllMultiversxAdapters:()=>Me,getAllMultiversxChainNames:()=>$e,getMultiversxAdapter:()=>se,getMultiversxRegistryAddress:()=>A,getVibechainAdapter:()=>ce,hex_value:()=>Pe,list_value:()=>Ce,nothing_value:()=>ke,option_value:()=>xe,optional_value:()=>Te,string_value:()=>Ae,token_value:()=>Re,u16_value:()=>Be,u32_value:()=>Ie,u64_value:()=>Ve,u8_value:()=>Ee,variadic_value:()=>ve});module.exports=We(Le);var J=require("@multiversx/sdk-core"),V=require("@vleap/warps");var re=require("@vleap/warps");var d=require("@multiversx/sdk-core"),b=require("@vleap/warps");var M=require("@multiversx/sdk-core"),h=require("@vleap/warps");var n=require("@multiversx/sdk-core"),T=require("@vleap/warps"),pe=new RegExp(`${T.WarpConstants.ArgParamsSeparator}(.*)`),N=class{constructor(){this.coreSerializer=new T.WarpSerializer}typedToString(e){if(e.hasClassOrSuperclass(n.OptionValue.ClassName))return e.isSet()?`option:${this.typedToString(e.getTypedValue())}`:"option:null";if(e.hasClassOrSuperclass(n.OptionalValue.ClassName))return e.isSet()?`optional:${this.typedToString(e.getTypedValue())}`:"optional:null";if(e.hasClassOrSuperclass(n.List.ClassName)){let t=e.getItems(),a=t.map(p=>this.typedToString(p).split(T.WarpConstants.ArgParamsSeparator)[0])[0],i=t.map(p=>this.typedToString(p).split(T.WarpConstants.ArgParamsSeparator)[1]);return`list:${a}:${i.join(",")}`}if(e.hasClassOrSuperclass(n.VariadicValue.ClassName)){let t=e.getItems(),a=t.map(p=>this.typedToString(p).split(T.WarpConstants.ArgParamsSeparator)[0])[0],i=t.map(p=>this.typedToString(p).split(T.WarpConstants.ArgParamsSeparator)[1]);return`variadic:${a}:${i.join(",")}`}if(e.hasClassOrSuperclass(n.CompositeValue.ClassName)){let t=e.getItems(),r=t.map(o=>this.typedToString(o).split(T.WarpConstants.ArgParamsSeparator)[0]),a=t.map(o=>this.typedToString(o).split(T.WarpConstants.ArgParamsSeparator)[1]),i=r.join(T.WarpConstants.ArgCompositeSeparator),p=a.join(T.WarpConstants.ArgCompositeSeparator);return`composite(${i}):${p}`}if(e.hasClassOrSuperclass(n.BigUIntValue.ClassName)||e.getType().getName()==="BigUint")return`biguint:${BigInt(e.valueOf().toFixed())}`;if(e.hasClassOrSuperclass(n.U8Value.ClassName))return`uint8:${e.valueOf().toNumber()}`;if(e.hasClassOrSuperclass(n.U16Value.ClassName))return`uint16:${e.valueOf().toNumber()}`;if(e.hasClassOrSuperclass(n.U32Value.ClassName))return`uint32:${e.valueOf().toNumber()}`;if(e.hasClassOrSuperclass(n.U64Value.ClassName))return`uint64:${BigInt(e.valueOf().toFixed())}`;if(e.hasClassOrSuperclass(n.StringValue.ClassName))return`string:${e.valueOf()}`;if(e.hasClassOrSuperclass(n.BooleanValue.ClassName))return`bool:${e.valueOf()}`;if(e.hasClassOrSuperclass(n.AddressValue.ClassName))return`address:${e.valueOf().toBech32()}`;if(e.hasClassOrSuperclass(n.TokenIdentifierValue.ClassName))return`token:${e.valueOf()}`;if(e.hasClassOrSuperclass(n.BytesValue.ClassName))return`hex:${e.valueOf().toString("hex")}`;if(e.hasClassOrSuperclass(n.CodeMetadataValue.ClassName))return`codemeta:${e.valueOf().toString()}`;if(e.getType().getName()==="EsdtTokenPayment"){let t=e.getFieldValue("token_identifier").valueOf(),r=e.getFieldValue("token_nonce").valueOf(),a=e.getFieldValue("amount").valueOf();return`esdt:${t}|${r}|${a}`}throw new Error(`WarpArgSerializer (typedToString): Unsupported input type: ${e.getClassName()}`)}typedToNative(e){let t=this.typedToString(e);return this.coreSerializer.stringToNative(t)}nativeToTyped(e,t){let r=this.coreSerializer.nativeToString(e,t);return this.stringToTyped(r)}nativeToType(e){if(e.startsWith("composite")){let t=e.match(/\(([^)]+)\)/)?.[1];return new n.CompositeType(...t.split(T.WarpConstants.ArgCompositeSeparator).map(r=>this.nativeToType(r)))}if(e==="string")return new n.StringType;if(e==="uint8")return new n.U8Type;if(e==="uint16")return new n.U16Type;if(e==="uint32")return new n.U32Type;if(e==="uint64")return new n.U64Type;if(e==="biguint")return new n.BigUIntType;if(e==="bool")return new n.BooleanType;if(e==="address")return new n.AddressType;if(e==="token")return new n.TokenIdentifierType;if(e==="hex")return new n.BytesType;if(e==="codemeta")return new n.CodeMetadataType;if(e==="esdt"||e==="nft")return new n.StructType("EsdtTokenPayment",[new n.FieldDefinition("token_identifier","",new n.TokenIdentifierType),new n.FieldDefinition("token_nonce","",new n.U64Type),new n.FieldDefinition("amount","",new n.BigUIntType)]);throw new Error(`WarpArgSerializer (nativeToType): Unsupported input type: ${e}`)}stringToTyped(e){let[t,r]=e.split(/:(.*)/,2);if(t==="null"||t===null)return new n.NothingValue;if(t==="option"){let a=this.stringToTyped(r);return a instanceof n.NothingValue?n.OptionValue.newMissingTyped(a.getType()):n.OptionValue.newProvided(a)}if(t==="optional"){let a=this.stringToTyped(r);return a instanceof n.NothingValue?n.OptionalValue.newMissing():new n.OptionalValue(a.getType(),a)}if(t==="list"){let[a,i]=r.split(pe,2),o=i.split(",").map(l=>this.stringToTyped(`${a}:${l}`));return new n.List(this.nativeToType(a),o)}if(t==="variadic"){let[a,i]=r.split(pe,2),o=i.split(",").map(l=>this.stringToTyped(`${a}:${l}`));return new n.VariadicValue(new n.VariadicType(this.nativeToType(a)),o)}if(t.startsWith("composite")){let a=t.match(/\(([^)]+)\)/)?.[1],i=r.split(T.WarpConstants.ArgCompositeSeparator),p=a.split(T.WarpConstants.ArgCompositeSeparator),o=i.map((m,f)=>this.stringToTyped(`${p[f]}:${m}`)),l=o.map(m=>m.getType());return new n.CompositeValue(new n.CompositeType(...l),o)}if(t==="string")return r?n.StringValue.fromUTF8(r):new n.NothingValue;if(t==="uint8")return r?new n.U8Value(Number(r)):new n.NothingValue;if(t==="uint16")return r?new n.U16Value(Number(r)):new n.NothingValue;if(t==="uint32")return r?new n.U32Value(Number(r)):new n.NothingValue;if(t==="uint64")return r?new n.U64Value(BigInt(r)):new n.NothingValue;if(t==="biguint")return r?new n.BigUIntValue(BigInt(r)):new n.NothingValue;if(t==="bool")return r?new n.BooleanValue(typeof r=="boolean"?r:r==="true"):new n.NothingValue;if(t==="address")return r?new n.AddressValue(n.Address.newFromBech32(r)):new n.NothingValue;if(t==="token")return r?new n.TokenIdentifierValue(r):new n.NothingValue;if(t==="hex")return r?n.BytesValue.fromHex(r):new n.NothingValue;if(t==="codemeta")return new n.CodeMetadataValue(n.CodeMetadata.newFromBytes(Uint8Array.from(Buffer.from(r,"hex"))));if(t==="esdt"){let a=r.split(T.WarpConstants.ArgCompositeSeparator);return new n.Struct(this.nativeToType("esdt"),[new n.Field(new n.TokenIdentifierValue(a[0]),"token_identifier"),new n.Field(new n.U64Value(BigInt(a[1])),"token_nonce"),new n.Field(new n.BigUIntValue(BigInt(a[2])),"amount")])}throw new Error(`WarpArgSerializer (stringToTyped): Unsupported input type: ${t}`)}typeToString(e){if(e instanceof n.OptionType)return"option:"+this.typeToString(e.getFirstTypeParameter());if(e instanceof n.OptionalType)return"optional:"+this.typeToString(e.getFirstTypeParameter());if(e instanceof n.ListType)return"list:"+this.typeToString(e.getFirstTypeParameter());if(e instanceof n.VariadicType)return"variadic:"+this.typeToString(e.getFirstTypeParameter());if(e instanceof n.StringType)return"string";if(e instanceof n.U8Type)return"uint8";if(e instanceof n.U16Type)return"uint16";if(e instanceof n.U32Type)return"uint32";if(e instanceof n.U64Type)return"uint64";if(e instanceof n.BigUIntType)return"biguint";if(e instanceof n.BooleanType)return"bool";if(e instanceof n.AddressType)return"address";if(e instanceof n.TokenIdentifierType)return"token";if(e instanceof n.BytesType)return"hex";if(e instanceof n.CodeMetadataType)return"codemeta";if(e instanceof n.StructType&&e.getClassName()==="EsdtTokenPayment")return"esdt";throw new Error(`WarpArgSerializer (typeToString): Unsupported input type: ${e.getClassName()}`)}};var U=class{constructor(e,t){this.config=e;this.chain=t;this.abi=new R(e,t),this.serializer=new N,this.cache=new h.WarpCache(e.cache?.type)}async getTransactionExecutionResults(e,t){let{actionIndex:r}=(0,h.findWarpExecutableAction)(e),a=this.cache.get(h.WarpCacheKey.WarpExecutable(this.config.env,e.meta?.hash||"",r))??[],i=await this.extractContractResults(e,t,a),p=(0,h.getNextInfo)(this.config,[],e,r,i),o=(0,h.applyResultsToMessages)(e,i.results);return{success:t.status.isSuccessful(),warp:e,action:r,user:this.config.user?.wallets?.[this.chain.name]||null,txHash:t.hash,next:p,values:i.values,results:i.results,messages:o}}async extractContractResults(e,t,r){let{action:a,actionIndex:i}=(0,h.findWarpExecutableAction)(e),p=[],o={};if(!e.results||a.type!=="contract")return{values:p,results:o};if(!Object.values(e.results).some(C=>C.includes("out")||C.includes("event"))){for(let[C,y]of Object.entries(e.results))o[C]=y;return{values:p,results:await(0,h.evaluateResultsCommon)(e,o,i,r)}}let m=await this.abi.getAbiForAction(a),f=new M.TransactionEventsParser({abi:m}),W=new M.SmartContractTransactionsOutcomeParser({abi:m}).parseExecute({transactionOnNetwork:t,function:a.func||void 0});for(let[C,y]of Object.entries(e.results)){if(y.startsWith(h.WarpConstants.Transform.Prefix))continue;if(y.startsWith("input.")){o[C]=y;continue}let E=(0,h.parseResultsOutIndex)(y);if(E!==null&&E!==i){o[C]=null;continue}let[v,I,B]=y.split(".");if(v==="event"){if(!I||isNaN(Number(B)))continue;let G=Number(B),x=(0,M.findEventsByFirstTopic)(t,I),$=f.parseEvents({events:x})[0],K=Object.values($)[G]||null;p.push(K),o[C]=K&&K.valueOf()}else if(v==="out"||v.startsWith("out[")){if(!I)continue;let G=Number(I),x=W.values[G-1]||null;B&&(x=x[B]||null),x&&typeof x=="object"&&(x="toFixed"in x?x.toFixed():x.valueOf()),p.push(x),o[C]=x&&x.valueOf()}else o[C]=y}return{values:p,results:await(0,h.evaluateResultsCommon)(e,o,i,r)}}async extractQueryResults(e,t,r,a){let i=t.map(m=>this.serializer.typedToString(m)),p=t.map(m=>this.serializer.typedToNative(m)[1]),o={};if(!e.results)return{values:i,results:o};let l=m=>{let f=m.split(".").slice(1).map(W=>parseInt(W)-1);if(f.length===0)return;let g=p[f[0]];for(let W=1;W<f.length;W++){if(g==null)return;g=g[f[W]]}return g};for(let[m,f]of Object.entries(e.results)){if(f.startsWith(h.WarpConstants.Transform.Prefix))continue;let g=(0,h.parseResultsOutIndex)(f);if(g!==null&&g!==r){o[m]=null;continue}f.startsWith("out.")||f==="out"||f.startsWith("out[")?o[m]=l(f)||null:o[m]=f}return{values:i,results:await(0,h.evaluateResultsCommon)(e,o,r,a)}}async resolveWarpResultsRecursively(e){let t=e.warp,r=e.entryActionIndex,a=e.executor,i=e.inputs,p=e.meta,o=new Map,l=new Set,m=this;async function f(y,E=[]){if(o.has(y))return o.get(y);if(l.has(y))throw new Error(`Circular dependency detected at action ${y}`);l.add(y);let v=t.actions[y-1];if(!v)throw new Error(`Action ${y} not found`);let I;if(v.type==="query")I=await a.executeQuery(t,y,E);else if(v.type==="collect")I=await a.executeCollect(t,y,E,p);else throw new Error(`Unsupported or interactive action type: ${v.type}`);if(o.set(y,I),t.results)for(let B of Object.values(t.results)){let x=String(B).match(/^out\[(\d+)\]/);if(x){let $=parseInt(x[1],10);$!==y&&!o.has($)&&await f($)}}return l.delete(y),I}await f(r,i);let g={};for(let y of o.values())for(let[E,v]of Object.entries(y.results))v!==null?g[E]=v:E in g||(g[E]=null);let W=await(0,h.evaluateResultsCommon)(t,g,r,i);return{...o.get(r),action:r,results:W}}};var c=require("@multiversx/sdk-core"),xe=(s,e)=>s?c.OptionValue.newProvided(s):e?c.OptionValue.newMissingTyped(e):c.OptionValue.newMissing(),Te=(s,e)=>s?new c.OptionalValue(s.getType(),s):e?new c.OptionalValue(e):c.OptionalValue.newMissing(),Ce=s=>{if(s.length===0)throw new Error("Cannot create a list from an empty array");let e=s[0].getType();return new c.List(e,s)},ve=s=>c.VariadicValue.fromItems(...s),be=s=>{let e=s.map(t=>t.getType());return new c.CompositeValue(new c.CompositeType(...e),s)},Ae=s=>c.StringValue.fromUTF8(s),Ee=s=>new c.U8Value(s),Be=s=>new c.U16Value(s),Ie=s=>new c.U32Value(s),Ve=s=>new c.U64Value(s),Se=s=>new c.BigUIntValue(BigInt(s)),Fe=s=>new c.BooleanValue(s),Ne=s=>new c.AddressValue(c.Address.newFromBech32(s)),Re=s=>new c.TokenIdentifierValue(s),Pe=s=>c.BytesValue.fromHex(s),te=s=>new c.Struct(new c.StructType("EsdtTokenPayment",[new c.FieldDefinition("token_identifier","",new c.TokenIdentifierType),new c.FieldDefinition("token_nonce","",new c.U64Type),new c.FieldDefinition("amount","",new c.BigUIntType)]),[new c.Field(new c.TokenIdentifierValue(s.token.identifier),"token_identifier"),new c.Field(new c.U64Value(BigInt(s.token.nonce)),"token_nonce"),new c.Field(new c.BigUIntValue(BigInt(s.amount)),"amount")]),Ue=s=>new c.CodeMetadataValue(c.CodeMetadata.newFromBytes(Uint8Array.from(Buffer.from(s,"hex")))),ke=()=>new c.NothingValue;var w=class s{constructor(e,t){this.config=e;this.chain=t;this.serializer=new N,this.abi=new R(this.config,this.chain),this.results=new U(this.config,this.chain)}async createTransaction(e){let t=(0,b.getWarpActionByIndex)(e.warp,e.action),r=null;if(t.type==="transfer")r=await this.createTransferTransaction(e);else if(t.type==="contract")r=await this.createContractCallTransaction(e);else{if(t.type==="query")throw new Error("WarpMultiversxExecutor: Invalid action type for createTransactionForExecute; Use executeQuery instead");if(t.type==="collect")throw new Error("WarpMultiversxExecutor: Invalid action type for createTransactionForExecute; Use executeCollect instead")}if(!r)throw new Error(`WarpMultiversxExecutor: Invalid action type (${t.type})`);return r}async createTransferTransaction(e){let t=this.config.user?.wallets?.[e.chain.name];if(!t)throw new Error("WarpMultiversxExecutor: createTransfer - user address not set");let r=d.Address.newFromBech32(t),a=new d.TransactionsFactoryConfig({chainID:e.chain.chainId}),i=e.data?Buffer.from(this.serializer.stringToTyped(e.data).valueOf()):null;return new d.TransferTransactionsFactory({config:a}).createTransactionForTransfer(r,{receiver:d.Address.newFromBech32(e.destination),nativeAmount:e.value,data:i?new Uint8Array(i):void 0})}async createContractCallTransaction(e){let t=this.config.user?.wallets?.[e.chain.name];if(!t)throw new Error("WarpMultiversxExecutor: createContractCall - user address not set");let r=(0,b.getWarpActionByIndex)(e.warp,e.action),a=d.Address.newFromBech32(t),i=e.args.map(o=>this.serializer.stringToTyped(o)),p=new d.TransactionsFactoryConfig({chainID:e.chain.chainId});return new d.SmartContractTransactionsFactory({config:p}).createTransactionForExecute(a,{contract:d.Address.newFromBech32(e.destination),function:"func"in r&&r.func||"",gasLimit:"gasLimit"in r?BigInt(r.gasLimit||0):0n,arguments:i,nativeTransferAmount:e.value})}async executeQuery(e){let t=(0,b.getWarpActionByIndex)(e.warp,e.action);if(t.type!=="query")throw new Error(`WarpMultiversxExecutor: Invalid action type for executeQuery: ${t.type}`);let r=await this.abi.getAbiForAction(t),a=e.args.map(B=>this.serializer.stringToTyped(B)),i=s.getChainEntrypoint(e.chain,this.config.env),p=d.Address.newFromBech32(e.destination),o=i.createSmartContractController(r),l=o.createQuery({contract:p,function:t.func||"",arguments:a}),m=await o.runQuery(l),f=m.returnCode==="ok",g=new d.ArgSerializer,W=r.getEndpoint(m.function||t.func||""),C=(m.returnDataParts||[]).map(B=>Buffer.from(B)),y=g.buffersToValues(C,W.output),{values:E,results:v}=await this.results.extractQueryResults(e.warp,y,e.action,e.resolvedInputs),I=(0,b.getNextInfo)(this.config,[],e.warp,e.action,v);return{success:f,warp:e.warp,action:e.action,user:this.config.user?.wallets?.[e.chain.name]||null,txHash:null,next:I,values:E,results:v,messages:(0,b.applyResultsToMessages)(e.warp,v)}}async preprocessInput(e,t,r,a){if(r==="esdt"){let[i,p,o,l]=a.split(b.WarpConstants.ArgCompositeSeparator);if(l)return t;let m=new d.Token({identifier:i,nonce:BigInt(p)});if(!new d.TokenComputer().isFungible(m))return t;let W=(0,b.findKnownTokenById)(i)?.decimals;if(W||(W=(await(await fetch(`${e.apiUrl}/tokens/${i}`)).json()).decimals),!W)throw new Error(`WarpActionExecutor: Decimals not found for token ${i}`);let C=te(new d.TokenTransfer({token:m,amount:(0,b.shiftBigintBy)(o,W)}));return this.serializer.typedToString(C)+b.WarpConstants.ArgCompositeSeparator+W}return t}static getChainEntrypoint(e,t){let r="warp-sdk";return t==="devnet"?new d.DevnetEntrypoint({url:e.apiUrl,kind:"api",clientName:r}):t==="testnet"?new d.TestnetEntrypoint({url:e.apiUrl,kind:"api",clientName:r}):new d.MainnetEntrypoint({url:e.apiUrl,kind:"api",clientName:r})}async signMessage(e,t){let r=d.UserSecretKey.fromString(t);return(await new d.UserSigner(r).sign(new Uint8Array(Buffer.from(e,"utf-8")))).toString()}};var L=class{constructor(e){this.config=e}async getContract(e,t){try{let i=await w.getChainEntrypoint(t,this.config.env).createNetworkProvider().doGetGeneric(`accounts/${e}`);return{address:e,owner:i.ownerAddress,verified:i.isVerified||!1}}catch(r){return re.WarpLogger.error("WarpContractLoader: getContract error",r),null}}async getVerificationInfo(e,t){try{let i=await w.getChainEntrypoint(t,this.config.env).createNetworkProvider().doGetGeneric(`accounts/${e}/verification`);return{codeHash:i.codeHash,abi:i.source.abi}}catch(r){return re.WarpLogger.error("WarpContractLoader: getVerificationInfo error",r),null}}};var R=class{constructor(e,t){this.config=e;this.chain=t;this.contractLoader=new L(this.config),this.cache=new V.WarpCache(this.config.cache?.type)}async createFromRaw(e){return JSON.parse(e)}async createFromTransaction(e){let t=await this.createFromRaw(e.data.toString());return t.meta={chain:this.chain.name,hash:e.hash,creator:e.sender.toBech32(),createdAt:new Date(e.timestamp*1e3).toISOString()},t}async createFromTransactionHash(e,t){let r=V.WarpCacheKey.WarpAbi(this.config.env,e);if(t){let p=this.cache.get(r);if(p)return V.WarpLogger.info(`WarpAbiBuilder (createFromTransactionHash): Warp abi found in cache: ${e}`),p}let i=w.getChainEntrypoint(this.chain,this.config.env).createNetworkProvider();try{let p=await i.getTransaction(e),o=await this.createFromTransaction(p);return t&&t.ttl&&o&&this.cache.set(r,o,t.ttl),o}catch(p){return V.WarpLogger.error("WarpAbiBuilder: Error creating from transaction hash",p),null}}async getAbiForAction(e){if(e.abi)return await this.fetchAbi(e);if(!e.address)throw new Error("WarpActionExecutor: Address not found");let t=await this.contractLoader.getVerificationInfo(e.address,this.chain);if(!t)throw new Error("WarpActionExecutor: Verification info not found");return J.AbiRegistry.create(t.abi)}async fetchAbi(e){if(!e.abi)throw new Error("WarpActionExecutor: ABI not found");if(e.abi.startsWith(V.WarpConstants.IdentifierType.Hash)){let t=e.abi.split(V.WarpConstants.IdentifierParamSeparatorDefault)[1],r=await this.createFromTransactionHash(t);if(!r)throw new Error(`WarpActionExecutor: ABI not found for hash: ${e.abi}`);return J.AbiRegistry.create(r.content)}else{let r=await(await fetch(e.abi)).json();return J.AbiRegistry.create(r)}}};var k=require("@multiversx/sdk-core"),X=require("@vleap/warps"),ue=require("buffer");var q=class{constructor(e,t){this.config=e;this.chain=t;this.core=new X.WarpBrandBuilder(e)}async createInscriptionTransaction(e){let t=this.config.user?.wallets?.[this.chain.name];if(!t)throw new Error("BrandBuilder: user address not set");let r=new k.TransactionsFactoryConfig({chainID:this.chain.chainId}),a=new k.TransferTransactionsFactory({config:r}),i=k.Address.newFromBech32(t),p=JSON.stringify(e);return await a.createTransactionForNativeTokenTransfer(i,{receiver:k.Address.newFromBech32(t),nativeAmount:BigInt(0),data:Uint8Array.from(ue.Buffer.from(p))})}async createFromTransaction(e,t=!1){return await this.core.createFromRaw(e.data.toString(),t)}async createFromTransactionHash(e){let r=w.getChainEntrypoint(this.chain,this.config.env).createNetworkProvider();try{let a=await r.getTransaction(e);return this.createFromTransaction(a)}catch(a){return X.WarpLogger.error("BrandBuilder: Error creating from transaction hash",a),null}}};var _=require("@multiversx/sdk-core"),S=require("@vleap/warps");var D=class extends S.WarpBuilder{constructor(t,r){super(t);this.config=t;this.chain=r;this.cache=new S.WarpCache(t.cache?.type),this.core=new S.WarpBuilder(t)}async createInscriptionTransaction(t){let r=this.config.user?.wallets?.[this.chain.name];if(!r)throw new Error("WarpBuilder: user address not set");let a=new _.TransactionsFactoryConfig({chainID:this.chain.chainId}),i=new _.TransferTransactionsFactory({config:a}),p=_.Address.newFromBech32(r),o=JSON.stringify(t),l=await i.createTransactionForTransfer(p,{receiver:_.Address.newFromBech32(r),nativeAmount:BigInt(0),data:Uint8Array.from(Buffer.from(o))});return l.gasLimit=l.gasLimit+BigInt(2e6),l}async createFromTransaction(t,r=!1){let a=await this.core.createFromRaw(t.data.toString(),r);return a.meta={chain:this.chain.name,hash:t.hash,creator:t.sender.toBech32(),createdAt:new Date(t.timestamp*1e3).toISOString()},a}async createFromTransactionHash(t,r){let a=S.WarpCacheKey.Warp(this.config.env,t);if(r){let o=this.cache.get(a);if(o)return S.WarpLogger.info(`WarpBuilder (createFromTransactionHash): Warp found in cache: ${t}`),o}let p=w.getChainEntrypoint(this.chain,this.config.env).createNetworkProvider();try{let o=await p.getTransaction(t),l=await this.createFromTransaction(o);return r&&r.ttl&&l&&this.cache.set(a,l,r.ttl),l}catch(o){return S.WarpLogger.error("WarpBuilder: Error creating from transaction hash",o),null}}};var ne=require("@multiversx/sdk-core");var Y=class{constructor(e,t){this.config=e;this.chain=t}async getAccount(e){let r=await w.getChainEntrypoint(this.chain,this.config.env).createNetworkProvider().getAccount(ne.Address.newFromBech32(e));return{address:r.address.toBech32(),balance:r.balance}}async getAccountAssets(e){return(await w.getChainEntrypoint(this.chain,this.config.env).createNetworkProvider().getFungibleTokensOfAccount(ne.Address.newFromBech32(e))).map(a=>({identifier:a.token.identifier,name:a.raw.name,amount:a.amount,decimals:a.raw.decimals,logoUrl:a.raw.assets?.pngUrl||""}))}};var _e={Egld:{Identifier:"EGLD",EsdtIdentifier:"EGLD-000000",DisplayName:"eGold",Decimals:18}},le=(r=>(r.MultiversxExplorer="multiversx_explorer",r.MultiversxExplorerDevnet="multiversx_explorer_devnet",r.MultiversxExplorerTestnet="multiversx_explorer_testnet",r))(le||{}),me=(r=>(r.VibechainExplorer="vibechain_explorer",r.VibechainExplorerDevnet="vibechain_explorer_devnet",r.VibechainExplorerTestnet="vibechain_explorer_testnet",r))(me||{}),ae={multiversx:{mainnet:["multiversx_explorer"],testnet:["multiversx_explorer_testnet"],devnet:["multiversx_explorer_devnet"]},vibechain:{mainnet:["vibechain_explorer"],testnet:["vibechain_explorer_testnet"],devnet:["vibechain_explorer_devnet"]}},P={multiversx_explorer:"https://explorer.multiversx.com",multiversx_explorer_devnet:"https://devnet-explorer.multiversx.com",multiversx_explorer_testnet:"https://testnet-explorer.multiversx.com",vibechain_explorer:"https://vibeox-explorer.multiversx.com",vibechain_explorer_devnet:"https://vibeox-explorer.multiversx.com",vibechain_explorer_testnet:"https://vibeox-explorer.multiversx.com"};var H=class{constructor(e,t){this.chain=e;this.config=t}getExplorers(){let e=ae[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=P[t];if(i)return i}if(e){let i=P[e];if(i)return i}let r=this.getPrimaryExplorer();return P[r]||P[r]}getAccountUrl(e,t){return`${this.getExplorerUrlByName(t)}/accounts/${e}`}getTransactionUrl(e,t){return`${this.getExplorerUrlByName(t)}/transactions/${e}`}getBlockUrl(e,t){return`${this.getExplorerUrlByName(t)}/blocks/${e}`}getAssetUrl(e,t){return`${this.getExplorerUrlByName(t)}/tokens/${e}`}getContractUrl(e,t){return`${this.getExplorerUrlByName(t)}/accounts/${e}`}getAllExplorers(){return this.getExplorers()}getExplorerByName(e){return this.getExplorers().find(r=>r.toLowerCase()===e.toLowerCase())}getAccountUrls(e){let t=this.getAllExplorers(),r={};return t.forEach(a=>{let i=P[a];i&&(r[a]=`${i}/accounts/${e}`)}),r}getTransactionUrls(e){let t=this.getAllExplorers(),r={};return t.forEach(a=>{let i=P[a];i&&(r[a]=`${i}/transactions/${e}`)}),r}};var u=require("@multiversx/sdk-core"),F=require("@vleap/warps");var ie={buildInfo:{rustc:{version:"1.86.0",commitHash:"05f9846f893b09a1be1fc8560e33fc3c815cfecb",commitDate:"2025-03-31",channel:"Stable",short:"rustc 1.86.0 (05f9846f8 2025-03-31)"},contractCrate:{name:"registry",version:"0.0.1"},framework:{name:"multiversx-sc",version:"0.51.1"}},name:"RegistryContract",constructor:{inputs:[{name:"unit_price",type:"BigUint"},{name:"vault",type:"Address"}],outputs:[]},upgradeConstructor:{inputs:[],outputs:[]},endpoints:[{name:"registerWarp",mutability:"mutable",payableInTokens:["EGLD"],inputs:[{name:"hash",type:"bytes"},{name:"alias_opt",type:"optional<bytes>",multi_arg:!0},{name:"brand_opt",type:"optional<bytes>",multi_arg:!0}],outputs:[],allow_multiple_var_args:!0},{name:"unregisterWarp",mutability:"mutable",inputs:[{name:"warp",type:"bytes"}],outputs:[]},{name:"upgradeWarp",mutability:"mutable",payableInTokens:["EGLD"],inputs:[{name:"alias",type:"bytes"},{name:"new_warp",type:"bytes"}],outputs:[]},{name:"setWarpAlias",mutability:"mutable",payableInTokens:["EGLD"],inputs:[{name:"hash",type:"bytes"},{name:"alias",type:"bytes"}],outputs:[]},{name:"forceRemoveAlias",mutability:"mutable",inputs:[{name:"hash",type:"bytes"}],outputs:[]},{name:"verifyWarp",mutability:"mutable",inputs:[{name:"warp",type:"bytes"}],outputs:[]},{name:"transferOwnership",mutability:"mutable",inputs:[{name:"warp",type:"bytes"},{name:"new_owner",type:"Address"}],outputs:[]},{name:"getUserWarps",mutability:"readonly",inputs:[{name:"address",type:"Address"}],outputs:[{type:"variadic<InfoView>",multi_result:!0}]},{name:"getInfoByAlias",mutability:"readonly",inputs:[{name:"alias",type:"bytes"}],outputs:[{type:"InfoView"}]},{name:"getInfoByHash",mutability:"readonly",inputs:[{name:"hash",type:"bytes"}],outputs:[{type:"InfoView"}]},{name:"setVault",onlyOwner:!0,mutability:"mutable",inputs:[{name:"vault",type:"Address"}],outputs:[]},{name:"setUnitPrice",onlyOwner:!0,mutability:"mutable",inputs:[{name:"amount",type:"BigUint"}],outputs:[]},{name:"addAdmin",onlyOwner:!0,mutability:"mutable",inputs:[{name:"address",type:"Address"}],outputs:[]},{name:"removeAdmin",onlyOwner:!0,mutability:"mutable",inputs:[{name:"address",type:"Address"}],outputs:[]},{name:"getConfig",mutability:"readonly",inputs:[],outputs:[{type:"ConfigView"}]},{name:"registerBrand",mutability:"mutable",payableInTokens:["EGLD"],inputs:[{name:"hash",type:"bytes"}],outputs:[]},{name:"brandWarp",mutability:"mutable",payableInTokens:["EGLD"],inputs:[{name:"warp",type:"bytes"},{name:"brand",type:"bytes"}],outputs:[]},{name:"getUserBrands",mutability:"readonly",inputs:[{name:"user",type:"Address"}],outputs:[{type:"variadic<bytes>",multi_result:!0}]},{name:"setChain",onlyOwner:!0,mutability:"mutable",inputs:[{name:"name",type:"bytes"},{name:"display_name",type:"bytes"},{name:"chain_id",type:"bytes"},{name:"block_time",type:"u32"},{name:"address_hrp",type:"bytes"},{name:"api_url",type:"bytes"},{name:"explorer_url",type:"bytes"},{name:"native_token",type:"bytes"}],outputs:[]},{name:"removeChain",onlyOwner:!0,mutability:"mutable",inputs:[{name:"name",type:"bytes"}],outputs:[]},{name:"getChain",mutability:"readonly",inputs:[{name:"name",type:"bytes"}],outputs:[{type:"ChainView"}]},{name:"getChains",mutability:"readonly",inputs:[],outputs:[{type:"variadic<ChainView>",multi_result:!0}]}],events:[{identifier:"warpRegistered",inputs:[{name:"hash",type:"bytes",indexed:!0},{name:"alias",type:"bytes",indexed:!0},{name:"trust",type:"bytes",indexed:!0}]},{identifier:"warpUnregistered",inputs:[{name:"hash",type:"bytes",indexed:!0}]},{identifier:"warpUpgraded",inputs:[{name:"alias",type:"bytes",indexed:!0},{name:"new_warp",type:"bytes",indexed:!0},{name:"trust",type:"bytes",indexed:!0}]},{identifier:"warpVerified",inputs:[{name:"hash",type:"bytes",indexed:!0}]},{identifier:"aliasUpdated",inputs:[{name:"hash",type:"bytes",indexed:!0},{name:"alias",type:"bytes",indexed:!0}]},{identifier:"ownershipTransferred",inputs:[{name:"warp",type:"bytes",indexed:!0},{name:"old_owner",type:"Address",indexed:!0},{name:"new_owner",type:"Address",indexed:!0}]}],esdtAttributes:[],hasCallback:!1,types:{ChainView:{type:"struct",fields:[{name:"name",type:"bytes"},{name:"display_name",type:"bytes"},{name:"chain_id",type:"bytes"},{name:"block_time",type:"u32"},{name:"address_hrp",type:"bytes"},{name:"api_url",type:"bytes"},{name:"explorer_url",type:"bytes"},{name:"native_token",type:"bytes"}]},ConfigView:{type:"struct",fields:[{name:"unit_price",type:"BigUint"},{name:"admins",type:"List<Address>"}]},InfoView:{type:"struct",fields:[{name:"hash",type:"bytes"},{name:"alias",type:"Option<bytes>"},{name:"trust",type:"bytes"},{name:"owner",type:"Address"},{name:"created_at",type:"u64"},{name:"upgraded_at",type:"u64"},{name:"brand",type:"Option<bytes>"},{name:"upgrade",type:"Option<bytes>"}]}}};var A=s=>{if(s==="devnet")return"erd1qqqqqqqqqqqqqpgqje2f99vr6r7sk54thg03c9suzcvwr4nfl3tsfkdl36";if(s==="testnet")throw new Error("Multiversx testnet is not supported");return"erd1qqqqqqqqqqqqqpgq3mrpj3u6q7tejv6d7eqhnyd27n9v5c5tl3ts08mffe"};var Z=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}),fe=s=>({unitPrice:BigInt(s.unit_price.toString()),admins:s.admins.map(e=>e.toBech32())});var z=class{constructor(e,t){this.config=e;this.chain=t;this.cache=new F.WarpCache(e.cache?.type),this.registryConfig={unitPrice:BigInt(0),admins:[]},this.userWallet=this.config.user?.wallets?.[this.chain.name]||null}async init(){await this.loadRegistryConfigs()}getRegistryConfig(){return this.registryConfig}async createWarpRegisterTransaction(e,t,r){if(this.registryConfig.unitPrice===BigInt(0))throw new Error("WarpRegistry: config not loaded. forgot to call init()?");if(!this.userWallet)throw new Error("WarpRegistry: user address not set");let a=u.Address.newFromBech32(this.userWallet),i=()=>this.isCurrentUserAdmin()?BigInt(0):t&&r?this.registryConfig.unitPrice*BigInt(3):t?this.registryConfig.unitPrice*BigInt(2):this.registryConfig.unitPrice,p=()=>t&&r?[u.BytesValue.fromHex(e),u.BytesValue.fromUTF8(t),u.BytesValue.fromHex(r)]:t?[u.BytesValue.fromHex(e),u.BytesValue.fromUTF8(t)]:[u.BytesValue.fromHex(e)];return await this.getFactory().createTransactionForExecute(a,{contract:u.Address.newFromBech32(A(this.config.env)),function:"registerWarp",gasLimit:BigInt(1e7),nativeTransferAmount:i(),arguments:p()})}async createWarpUnregisterTransaction(e){if(!this.userWallet)throw new Error("WarpRegistry: user address not set");let t=u.Address.newFromBech32(this.userWallet);return await this.getFactory().createTransactionForExecute(t,{contract:u.Address.newFromBech32(A(this.config.env)),function:"unregisterWarp",gasLimit:BigInt(1e7),arguments:[u.BytesValue.fromHex(e)]})}async createWarpUpgradeTransaction(e,t){if(this.registryConfig.unitPrice===BigInt(0))throw new Error("WarpRegistry: config not loaded. forgot to call init()?");if(!this.userWallet)throw new Error("WarpRegistry: user address not set");let r=u.Address.newFromBech32(this.userWallet);return await this.getFactory().createTransactionForExecute(r,{contract:u.Address.newFromBech32(A(this.config.env)),function:"upgradeWarp",gasLimit:BigInt(1e7),nativeTransferAmount:this.isCurrentUserAdmin()?void 0:this.registryConfig.unitPrice,arguments:[u.BytesValue.fromUTF8(e),u.BytesValue.fromHex(t)]})}async createWarpAliasSetTransaction(e,t){if(!this.userWallet)throw new Error("WarpRegistry: user address not set");let r=u.Address.newFromBech32(this.userWallet);return await this.getFactory().createTransactionForExecute(r,{contract:u.Address.newFromBech32(A(this.config.env)),function:"setWarpAlias",gasLimit:BigInt(1e7),nativeTransferAmount:this.isCurrentUserAdmin()?void 0:this.registryConfig.unitPrice,arguments:[u.BytesValue.fromHex(e),u.BytesValue.fromUTF8(t)]})}async createWarpVerifyTransaction(e){if(!this.userWallet)throw new Error("WarpRegistry: user address not set");let t=u.Address.newFromBech32(this.userWallet);return await this.getFactory().createTransactionForExecute(t,{contract:u.Address.newFromBech32(A(this.config.env)),function:"verifyWarp",gasLimit:BigInt(1e7),arguments:[u.BytesValue.fromHex(e)]})}async createWarpTransferOwnershipTransaction(e,t){if(!this.userWallet)throw new Error("WarpRegistry: user address not set");let r=u.Address.newFromBech32(this.userWallet);return await this.getFactory().createTransactionForExecute(r,{contract:u.Address.newFromBech32(A(this.config.env)),function:"transferOwnership",gasLimit:BigInt(1e7),arguments:[u.BytesValue.fromHex(e),new u.AddressValue(new u.Address(t))]})}async createBrandRegisterTransaction(e){if(this.registryConfig.unitPrice===BigInt(0))throw new Error("WarpRegistry: config not loaded. forgot to call init()?");if(!this.userWallet)throw new Error("WarpRegistry: user address not set");let t=u.Address.newFromBech32(this.userWallet);return await this.getFactory().createTransactionForExecute(t,{contract:u.Address.newFromBech32(A(this.config.env)),function:"registerBrand",gasLimit:BigInt(1e7),nativeTransferAmount:this.isCurrentUserAdmin()?void 0:this.registryConfig.unitPrice,arguments:[u.BytesValue.fromHex(e)]})}async createWarpBrandingTransaction(e,t){if(!this.userWallet)throw new Error("WarpRegistry: user address not set");let r=u.Address.newFromBech32(this.userWallet);return await this.getFactory().createTransactionForExecute(r,{contract:u.Address.newFromBech32(A(this.config.env)),function:"brandWarp",gasLimit:BigInt(1e7),nativeTransferAmount:this.isCurrentUserAdmin()?void 0:this.registryConfig.unitPrice,arguments:[u.BytesValue.fromHex(e),u.BytesValue.fromHex(t)]})}async getInfoByAlias(e,t){try{let r=F.WarpCacheKey.RegistryInfo(this.config.env,e),a=t?this.cache.get(r):null;if(a)return F.WarpLogger.info(`WarpRegistry (getInfoByAlias): RegistryInfo found in cache: ${e}`),a;let i=u.Address.newFromBech32(A(this.config.env)),p=this.getController(),o=p.createQuery({contract:i,function:"getInfoByAlias",arguments:[u.BytesValue.fromUTF8(e)]}),l=await p.runQuery(o),[m]=p.parseQueryResponse(l),f=m?Z(m):null,g=f?.brand?await this.fetchBrand(f.brand):null;return t&&t.ttl&&this.cache.set(r,{registryInfo:f,brand:g},t.ttl),{registryInfo:f,brand:g}}catch{return{registryInfo:null,brand:null}}}async getInfoByHash(e,t){try{let r=F.WarpCacheKey.RegistryInfo(this.config.env,e);if(t){let g=this.cache.get(r);if(g)return F.WarpLogger.info(`WarpRegistry (getInfoByHash): RegistryInfo found in cache: ${e}`),g}let a=u.Address.newFromBech32(A(this.config.env)),i=this.getController(),p=i.createQuery({contract:a,function:"getInfoByHash",arguments:[u.BytesValue.fromHex(e)]}),o=await i.runQuery(p),[l]=i.parseQueryResponse(o),m=l?Z(l):null,f=m?.brand?await this.fetchBrand(m.brand):null;return t&&t.ttl&&this.cache.set(r,{registryInfo:m,brand:f},t.ttl),{registryInfo:m,brand:f}}catch{return{registryInfo:null,brand:null}}}async getUserWarpRegistryInfos(e){try{let t=e||this.userWallet;if(!t)throw new Error("WarpRegistry: user address not set");let r=u.Address.newFromBech32(A(this.config.env)),a=this.getController(),i=a.createQuery({contract:r,function:"getUserWarps",arguments:[new u.AddressValue(new u.Address(t))]}),p=await a.runQuery(i),[o]=a.parseQueryResponse(p);return o.map(Z)}catch{return[]}}async getUserBrands(e){try{let t=e||this.userWallet;if(!t)throw new Error("WarpRegistry: user address not set");let r=u.Address.newFromBech32(A(this.config.env)),a=this.getController(),i=a.createQuery({contract:r,function:"getUserBrands",arguments:[new u.AddressValue(new u.Address(t))]}),p=await a.runQuery(i),[o]=a.parseQueryResponse(p),l=o.map(g=>g.toString("hex")),m={ttl:365*24*60*60};return(await Promise.all(l.map(g=>this.fetchBrand(g,m)))).filter(g=>g!==null)}catch{return[]}}async fetchBrand(e,t){let r=F.WarpCacheKey.Brand(this.config.env,e),a=t?this.cache.get(r):null;if(a)return F.WarpLogger.info(`WarpRegistry (fetchBrand): Brand found in cache: ${e}`),a;let p=w.getChainEntrypoint(this.chain,this.config.env).createNetworkProvider();try{let o=await p.getTransaction(e),l=JSON.parse(o.data.toString());return l.meta={hash:o.hash,creator:o.sender.toBech32(),createdAt:new Date(o.timestamp*1e3).toISOString()},t&&t.ttl&&this.cache.set(r,l,t.ttl),l}catch{return null}}async loadRegistryConfigs(){let e=u.Address.newFromBech32(A(this.config.env)),t=this.getController(),[r]=await t.query({contract:e,function:"getConfig",arguments:[]}),a=r?fe(r):null;this.registryConfig=a||{unitPrice:BigInt(0),admins:[]}}getFactory(){let e=new u.TransactionsFactoryConfig({chainID:this.chain.chainId}),t=u.AbiRegistry.create(ie);return new u.SmartContractTransactionsFactory({config:e,abi:t})}getController(){let e=w.getChainEntrypoint(this.chain,this.config.env),t=u.AbiRegistry.create(ie);return e.createSmartContractController(t)}isCurrentUserAdmin(){return!!this.userWallet&&this.registryConfig.admins.includes(this.userWallet)}};var Q=(s,e,t)=>(r,a)=>{let i=t[r.env];return{chain:s,chainInfo:i,prefix:e,builder:()=>new D(r,i),executor:new w(r,i),results:new U(r,i),serializer:new N,registry:new z(r,i),explorer:new H(s,r),abiBuilder:()=>new R(r,i),brandBuilder:()=>new q(r,i),dataLoader:new Y(r,i)}};var O="multiversx",se=Q(O,"mvx",{mainnet:{name:O,displayName:"MultiversX",chainId:"1",blockTime:6e3,addressHrp:"erd",apiUrl:"https://api.multiversx.com",nativeToken:"EGLD"},testnet:{name:O,displayName:"MultiversX Testnet",chainId:"T",blockTime:6e3,addressHrp:"erd",apiUrl:"https://testnet-api.multiversx.com",nativeToken:"EGLD"},devnet:{name:O,displayName:"MultiversX Devnet",chainId:"D",blockTime:6e3,addressHrp:"erd",apiUrl:"https://devnet-api.multiversx.com",nativeToken:"EGLD"}});var j="vibechain",oe={name:j,displayName:"VibeChain",chainId:"V",blockTime:600,addressHrp:"vibe",apiUrl:"https://vibeox-api.multiversx.com",nativeToken:"VIBE"},ce=Q(j,"vibe",{mainnet:oe,testnet:oe,devnet:oe});var Me=(s,e)=>[se(s,e),ce(s,e)],$e=()=>[O,j];0&&(module.exports={ChainNameMultiversx,ChainNameVibechain,ExplorerUrls,MultiversxExplorers,MultiversxExplorersConfig,VibechainExplorers,WarpMultiversxAbiBuilder,WarpMultiversxBrandBuilder,WarpMultiversxBuilder,WarpMultiversxConstants,WarpMultiversxContractLoader,WarpMultiversxExecutor,WarpMultiversxExplorer,WarpMultiversxRegistry,WarpMultiversxResults,WarpMultiversxSerializer,address_value,biguint_value,boolean_value,codemeta_value,composite_value,createMultiversxAdapter,esdt_value,getAllMultiversxAdapters,getAllMultiversxChainNames,getMultiversxAdapter,getMultiversxRegistryAddress,getVibechainAdapter,hex_value,list_value,nothing_value,option_value,optional_value,string_value,token_value,u16_value,u32_value,u64_value,u8_value,variadic_value});
|