@vleap/warps 3.0.0-alpha.8 → 3.0.0-alpha.81
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +538 -281
- package/dist/index.mjs +2 -2
- package/package.json +18 -16
- package/dist/chunk-3SAEGOMQ.mjs +0 -1
- package/dist/index.d.mts +0 -596
- package/dist/index.js +0 -12
- package/dist/vm-JCVDACTR.mjs +0 -11
package/dist/index.js
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
"use strict";var Et=Object.create;var it=Object.defineProperty;var Rt=Object.getOwnPropertyDescriptor;var Pt=Object.getOwnPropertyNames;var Vt=Object.getPrototypeOf,Ut=Object.prototype.hasOwnProperty;var Nt=(i,t)=>()=>(i&&(t=i(i=0)),t);var ht=(i,t)=>{for(var e in t)it(i,e,{get:t[e],enumerable:!0})},yt=(i,t,e,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of Pt(t))!Ut.call(i,n)&&n!==e&&it(i,n,{get:()=>t[n],enumerable:!(r=Rt(t,n))||r.enumerable});return i};var pt=(i,t,e)=>(e=i!=null?Et(Vt(i)):{},yt(t||!i||!i.__esModule?it(e,"default",{value:i,enumerable:!0}):e,i)),Ot=i=>yt(it({},"__esModule",{value:!0}),i);var bt={};ht(bt,{runInVm:()=>ne});var ne,vt=Nt(()=>{"use strict";ne=async(i,t)=>{if(typeof window>"u"){let e;try{e=require("vm2").VM}catch{throw new Error('The optional dependency "vm2" is not installed. To use runInVm in Node.js, please install vm2: npm install vm2 --save. This is not required for browser usage.')}let r=new e({timeout:1e3,sandbox:{result:t},eval:!1,wasm:!1});return i.trim().startsWith("(")&&i.includes("=>")?r.run(`(${i})(result)`):null}return new Promise((e,r)=>{try{let n=new Blob([`
|
|
2
|
-
self.onmessage = function(e) {
|
|
3
|
-
try {
|
|
4
|
-
const result = e.data;
|
|
5
|
-
const output = (${i})(result);
|
|
6
|
-
self.postMessage({ result: output });
|
|
7
|
-
} catch (error) {
|
|
8
|
-
self.postMessage({ error: error.toString() });
|
|
9
|
-
}
|
|
10
|
-
};
|
|
11
|
-
`],{type:"application/javascript"}),a=URL.createObjectURL(n),s=new Worker(a);s.onmessage=function(o){o.data.error?r(new Error(o.data.error)):e(o.data.result),s.terminate(),URL.revokeObjectURL(a)},s.onerror=function(o){r(new Error(`Error in transform: ${o.message}`)),s.terminate(),URL.revokeObjectURL(a)},s.postMessage(t)}catch(n){return r(n)}})}});var ce={};ht(ce,{BrandBuilder:()=>ft,CacheKey:()=>S,CacheTtl:()=>Y,WarpAbiBuilder:()=>rt,WarpActionExecutor:()=>gt,WarpArgSerializer:()=>k,WarpBuilder:()=>tt,WarpCache:()=>V,WarpConfig:()=>x,WarpConstants:()=>f,WarpContractLoader:()=>nt,WarpIndex:()=>mt,WarpInterpolator:()=>N,WarpLink:()=>et,WarpProtocolVersions:()=>$,WarpRegistry:()=>_,WarpUtils:()=>T,WarpValidator:()=>Z,address:()=>Xt,biguint:()=>Kt,boolean:()=>Jt,codemeta:()=>ee,composite:()=>Ht,esdt:()=>te,getChainExplorerUrl:()=>Ft,getLatestProtocolIdentifier:()=>L,getMainChainInfo:()=>A,getWarpActionByIndex:()=>O,hex:()=>Zt,list:()=>_t,nothing:()=>re,option:()=>Lt,optional:()=>qt,replacePlaceholders:()=>K,shiftBigintBy:()=>z,string:()=>jt,toPreviewText:()=>ut,toTypedChainInfo:()=>at,token:()=>Yt,u16:()=>Qt,u32:()=>Gt,u64:()=>zt,u8:()=>Dt,variadic:()=>Mt});module.exports=Ot(ce);var M=require("@multiversx/sdk-core"),Ct=pt(require("ajv"));var f={HttpProtocolPrefix:"http",IdentifierParamName:"warp",IdentifierParamSeparator:":",IdentifierType:{Alias:"alias",Hash:"hash"},Source:{UserWallet:"user:wallet"},Globals:{UserWallet:{Placeholder:"USER_WALLET",Accessor:i=>i.config.user?.wallet},ChainApiUrl:{Placeholder:"CHAIN_API",Accessor:i=>i.chain.apiUrl},ChainExplorerUrl:{Placeholder:"CHAIN_EXPLORER",Accessor:i=>i.chain.explorerUrl}},Vars:{Query:"query",Env:"env"},ArgParamsSeparator:":",ArgCompositeSeparator:"|",Transform:{Prefix:"transform:"},Egld:{Identifier:"EGLD",EsdtIdentifier:"EGLD-000000",DisplayName:"eGold",Decimals:18}};var $={Warp:"2.0.1",Brand:"0.1.0",Abi:"0.1.0"},x={LatestWarpSchemaUrl:`https://raw.githubusercontent.com/vLeapGroup/warps-specs/refs/heads/main/schemas/v${$.Warp}.schema.json`,LatestBrandSchemaUrl:`https://raw.githubusercontent.com/vLeapGroup/warps-specs/refs/heads/main/schemas/brand/v${$.Brand}.schema.json`,DefaultClientUrl:i=>i==="devnet"?"https://devnet.usewarp.to":i==="testnet"?"https://testnet.usewarp.to":"https://usewarp.to",SuperClientUrls:["https://usewarp.to","https://testnet.usewarp.to","https://devnet.usewarp.to"],MainChain:{Name:"multiversx",DisplayName:"MultiversX",ApiUrl:i=>i==="devnet"?"https://devnet-api.multiversx.com":i==="testnet"?"https://testnet-api.multiversx.com":"https://api.multiversx.com",ExplorerUrl:i=>i==="devnet"?"https://devnet-explorer.multiversx.com":i==="testnet"?"https://testnet-explorer.multiversx.com":"https://explorer.multiversx.com",BlockTime:i=>6e3,AddressHrp:"erd",ChainId:i=>i==="devnet"?"D":i==="testnet"?"T":"1"},Registry:{Contract:i=>i==="devnet"?"erd1qqqqqqqqqqqqqpgqje2f99vr6r7sk54thg03c9suzcvwr4nfl3tsfkdl36":i==="testnet"?"####":"erd1qqqqqqqqqqqqqpgq3mrpj3u6q7tejv6d7eqhnyd27n9v5c5tl3ts08mffe"},AvailableActionInputSources:["field","query",f.Source.UserWallet],AvailableActionInputTypes:["string","uint8","uint16","uint32","uint64","biguint","boolean","address"],AvailableActionInputPositions:["receiver","value","transfer","arg:1","arg:2","arg:3","arg:4","arg:5","arg:6","arg:7","arg:8","arg:9","arg:10","data","ignore"]};var A=i=>({name:x.MainChain.Name,displayName:x.MainChain.DisplayName,chainId:x.MainChain.ChainId(i.env),blockTime:x.MainChain.BlockTime(i.env),addressHrp:x.MainChain.AddressHrp,apiUrl:x.MainChain.ApiUrl(i.env),explorerUrl:x.MainChain.ExplorerUrl(i.env)}),Ft=(i,t)=>i.explorerUrl+(t?"/"+t:""),L=i=>{if(i==="warp")return`warp:${$.Warp}`;if(i==="brand")return`brand:${$.Brand}`;if(i==="abi")return`abi:${$.Abi}`;throw new Error(`getLatestProtocolIdentifier: Invalid protocol name: ${i}`)},O=(i,t)=>i?.actions[t-1],at=i=>({name:i.name.toString(),displayName:i.display_name.toString(),chainId:i.chain_id.toString(),blockTime:i.block_time.toNumber(),addressHrp:i.address_hrp.toString(),apiUrl:i.api_url.toString(),explorerUrl:i.explorer_url.toString()}),z=(i,t)=>{let e=i.toString(),[r,n=""]=e.split("."),a=Math.abs(t);if(t>0)return BigInt(r+n.padEnd(a,"0"));if(t<0){let s=r+n;if(a>=s.length)return 0n;let o=s.slice(0,-a)||"0";return BigInt(o)}else return e.includes(".")?BigInt(e.split(".")[0]):BigInt(e)},ut=(i,t=100)=>{if(!i)return"";let e=i.replace(/<\/?(h[1-6])[^>]*>/gi," - ").replace(/<\/?(p|div|ul|ol|li|br|hr)[^>]*>/gi," ").replace(/<[^>]+>/g,"").replace(/\s+/g," ").trim();return e=e.startsWith("- ")?e.slice(2):e,e=e.length>t?e.substring(0,e.lastIndexOf(" ",t))+"...":e,e},K=(i,t)=>i.replace(/\{\{([^}]+)\}\}/g,(e,r)=>t[r]||"");var j=class j{static info(...t){j.isTestEnv||console.info(...t)}static warn(...t){j.isTestEnv||console.warn(...t)}static error(...t){j.isTestEnv||console.error(...t)}};j.isTestEnv=typeof process<"u"&&process.env.JEST_WORKER_ID!==void 0;var C=j;var D=require("@multiversx/sdk-core");var J=class{constructor(t="warp-cache"){this.prefix=t}getKey(t){return`${this.prefix}:${t}`}get(t){try{let e=localStorage.getItem(this.getKey(t));if(!e)return null;let r=JSON.parse(e);return Date.now()>r.expiresAt?(localStorage.removeItem(this.getKey(t)),null):r.value}catch{return null}}set(t,e,r){let n={value:e,expiresAt:Date.now()+r*1e3};localStorage.setItem(this.getKey(t),JSON.stringify(n))}forget(t){localStorage.removeItem(this.getKey(t))}clear(){for(let t=0;t<localStorage.length;t++){let e=localStorage.key(t);e?.startsWith(this.prefix)&&localStorage.removeItem(e)}}};var F=class F{get(t){let e=F.cache.get(t);return e?Date.now()>e.expiresAt?(F.cache.delete(t),null):e.value:null}set(t,e,r){let n=Date.now()+r*1e3;F.cache.set(t,{value:e,expiresAt:n})}forget(t){F.cache.delete(t)}clear(){F.cache.clear()}};F.cache=new Map;var X=F;var Y={OneMinute:60,OneHour:60*60,OneDay:60*60*24,OneWeek:60*60*24*7,OneMonth:60*60*24*30,OneYear:60*60*24*365},S={Warp:i=>`warp:${i}`,WarpAbi:i=>`warp-abi:${i}`,LastWarpExecutionInputs:(i,t)=>`warp-exec-inputs:${i}:${t}`,RegistryInfo:i=>`registry-info:${i}`,Brand:i=>`brand:${i}`,ChainInfo:i=>`chain:${i}`,ChainInfos:()=>"chains"},V=class{constructor(t){this.strategy=this.selectStrategy(t)}selectStrategy(t){return t==="localStorage"?new J:t==="memory"?new X:typeof window<"u"&&window.localStorage?new J:new X}set(t,e,r){this.strategy.set(t,e,r)}get(t){return this.strategy.get(t)}forget(t){this.strategy.forget(t)}clear(){this.strategy.clear()}};var Tt=pt(require("qr-code-styling"));var q=require("@multiversx/sdk-core");var wt=pt(require("ajv"));var Z=class{constructor(t){this.config=t;this.config=t}async validate(t){let e=[];return e.push(...this.validateMaxOneValuePosition(t)),e.push(...this.validateVariableNamesAndResultNamesUppercase(t)),e.push(...this.validateAbiIsSetIfApplicable(t)),e.push(...await this.validateSchema(t)),{valid:e.length===0,errors:e}}validateMaxOneValuePosition(t){return t.actions.filter(r=>r.inputs?r.inputs.some(n=>n.position==="value"):!1).length>1?["Only one value position action is allowed"]:[]}validateVariableNamesAndResultNamesUppercase(t){let e=[],r=(n,a)=>{n&&Object.keys(n).forEach(s=>{s!==s.toUpperCase()&&e.push(`${a} name '${s}' must be uppercase`)})};return r(t.vars,"Variable"),r(t.results,"Result"),e}validateAbiIsSetIfApplicable(t){let e=t.actions.some(s=>s.type==="contract"),r=t.actions.some(s=>s.type==="query");if(!e&&!r)return[];let n=t.actions.some(s=>s.abi),a=Object.values(t.results||{}).some(s=>s.startsWith("out.")||s.startsWith("event."));return t.results&&!n&&a?["ABI is required when results are present for contract or query actions"]:[]}async validateSchema(t){try{let e=this.config.schema?.warp||x.LatestWarpSchemaUrl,n=await(await fetch(e)).json(),a=new wt.default,s=a.compile(n);return s(t)?[]:[`Schema validation failed: ${a.errorsText(s.errors)}`]}catch(e){return[`Schema validation failed: ${e instanceof Error?e.message:String(e)}`]}}};var tt=class{constructor(t){this.pendingWarp={protocol:L("warp"),name:"",title:"",description:null,preview:"",actions:[]};this.config=t,this.cache=new V(t.cache?.type)}createInscriptionTransaction(t){if(!this.config.user?.wallet)throw new Error("WarpBuilder: user address not set");let e=A(this.config),r=new q.TransactionsFactoryConfig({chainID:e.chainId}),n=new q.TransferTransactionsFactory({config:r}),a=q.Address.newFromBech32(this.config.user.wallet),s=JSON.stringify(t),o=n.createTransactionForTransfer(a,{receiver:q.Address.newFromBech32(this.config.user.wallet),nativeAmount:BigInt(0),data:Uint8Array.from(Buffer.from(s))});return o.gasLimit=o.gasLimit+BigInt(2e6),o}async createFromRaw(t,e=!0){let r=JSON.parse(t);return e&&await this.validate(r),r}async createFromTransaction(t,e=!1){let r=await this.createFromRaw(t.data.toString(),e);return r.meta={hash:t.hash,creator:t.sender.toBech32(),createdAt:new Date(t.timestamp*1e3).toISOString()},r}async createFromTransactionHash(t,e){let r=S.Warp(t);if(e){let o=this.cache.get(r);if(o)return C.info(`WarpBuilder (createFromTransactionHash): Warp found in cache: ${t}`),o}let n=A(this.config),s=T.getChainEntrypoint(n,this.config.env).createNetworkProvider();try{let o=await s.getTransaction(t),p=await this.createFromTransaction(o);return e&&e.ttl&&p&&this.cache.set(r,p,e.ttl),p}catch(o){return C.error("WarpBuilder: Error creating from transaction hash",o),null}}setName(t){return this.pendingWarp.name=t,this}setTitle(t){return this.pendingWarp.title=t,this}setDescription(t){return this.pendingWarp.description=t,this}setPreview(t){return this.pendingWarp.preview=t,this}setActions(t){return this.pendingWarp.actions=t,this}addAction(t){return this.pendingWarp.actions.push(t),this}async build(){return this.ensure(this.pendingWarp.protocol,"protocol is required"),this.ensure(this.pendingWarp.name,"name is required"),this.ensure(this.pendingWarp.title,"title is required"),this.ensure(this.pendingWarp.actions.length>0,"actions are required"),await this.validate(this.pendingWarp),this.pendingWarp}getDescriptionPreview(t,e=100){return ut(t,e)}ensure(t,e){if(!t)throw new Error(e)}async validate(t){let r=await new Z(this.config).validate(t);if(!r.valid)throw new Error(r.errors.join(`
|
|
12
|
-
`))}};var N=class{static async apply(t,e){let r=this.applyVars(t,e);return await this.applyGlobals(t,r)}static async applyGlobals(t,e){let r={...e};return r.actions=await Promise.all(r.actions.map(async n=>await this.applyActionGlobals(t,n))),r=await this.applyRootGlobals(r,t),r}static applyVars(t,e){if(!e?.vars)return e;let r=JSON.stringify(e),n=(a,s)=>{r=r.replace(new RegExp(`{{${a.toUpperCase()}}}`,"g"),s.toString())};return Object.entries(e.vars).forEach(([a,s])=>{if(typeof s!="string")n(a,s);else if(s.startsWith(`${f.Vars.Query}:`)){if(!t.currentUrl)throw new Error("WarpUtils: currentUrl config is required to prepare vars");let o=s.split(`${f.Vars.Query}:`)[1],p=new URLSearchParams(t.currentUrl.split("?")[1]).get(o);p&&n(a,p)}else if(s.startsWith(`${f.Vars.Env}:`)){let o=s.split(`${f.Vars.Env}:`)[1],p=t.vars?.[o];p&&n(a,p)}else s===f.Source.UserWallet&&t.user?.wallet?n(a,t.user.wallet):n(a,s)}),JSON.parse(r)}static async applyRootGlobals(t,e){let r=JSON.stringify(t),n={config:e,chain:A(e)};return Object.values(f.Globals).forEach(a=>{let s=a.Accessor(n);s!=null&&(r=r.replace(new RegExp(`{{${a.Placeholder}}}`,"g"),s.toString()))}),JSON.parse(r)}static async applyActionGlobals(t,e){let r=await T.getChainInfoForAction(t,e),n=JSON.stringify(e),a={config:t,chain:r};return Object.values(f.Globals).forEach(s=>{let o=s.Accessor(a);o!=null&&(n=n.replace(new RegExp(`{{${s.Placeholder}}}`,"g"),o.toString()))}),JSON.parse(n)}};var h=require("@multiversx/sdk-core/out");var lt={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"}],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"}]},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 st=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}),Wt=i=>({unitPrice:BigInt(i.unit_price.toString()),admins:i.admins.map(t=>t.toBech32())});var _=class{constructor(t){this.config=t,this.cache=new V(t.cache?.type),this.registryConfig={unitPrice:BigInt(0),admins:[]}}async init(){await this.loadRegistryConfigs()}createWarpRegisterTransaction(t,e,r){if(this.registryConfig.unitPrice===BigInt(0))throw new Error("WarpRegistry: config not loaded. forgot to call init()?");if(!this.config.user?.wallet)throw new Error("WarpRegistry: user address not set");let n=h.Address.newFromBech32(this.config.user.wallet),a=()=>this.isCurrentUserAdmin()?BigInt(0):e&&r?this.registryConfig.unitPrice*BigInt(3):e?this.registryConfig.unitPrice*BigInt(2):this.registryConfig.unitPrice,s=()=>e&&r?[h.BytesValue.fromHex(t),h.BytesValue.fromUTF8(e),h.BytesValue.fromHex(r)]:e?[h.BytesValue.fromHex(t),h.BytesValue.fromUTF8(e)]:[h.BytesValue.fromHex(t)];return this.getFactory().createTransactionForExecute(n,{contract:this.getRegistryContractAddress(),function:"registerWarp",gasLimit:BigInt(1e7),nativeTransferAmount:a(),arguments:s()})}createWarpUnregisterTransaction(t){if(!this.config.user?.wallet)throw new Error("WarpRegistry: user address not set");let e=h.Address.newFromBech32(this.config.user.wallet);return this.getFactory().createTransactionForExecute(e,{contract:this.getRegistryContractAddress(),function:"unregisterWarp",gasLimit:BigInt(1e7),arguments:[h.BytesValue.fromHex(t)]})}createWarpUpgradeTransaction(t,e){if(this.registryConfig.unitPrice===BigInt(0))throw new Error("WarpRegistry: config not loaded. forgot to call init()?");if(!this.config.user?.wallet)throw new Error("WarpRegistry: user address not set");let r=h.Address.newFromBech32(this.config.user.wallet);return this.getFactory().createTransactionForExecute(r,{contract:this.getRegistryContractAddress(),function:"upgradeWarp",gasLimit:BigInt(1e7),nativeTransferAmount:this.isCurrentUserAdmin()?void 0:this.registryConfig.unitPrice,arguments:[h.BytesValue.fromUTF8(t),h.BytesValue.fromHex(e)]})}createWarpAliasSetTransaction(t,e){if(!this.config.user?.wallet)throw new Error("WarpRegistry: user address not set");let r=h.Address.newFromBech32(this.config.user.wallet);return this.getFactory().createTransactionForExecute(r,{contract:this.getRegistryContractAddress(),function:"setWarpAlias",gasLimit:BigInt(1e7),nativeTransferAmount:this.isCurrentUserAdmin()?void 0:this.registryConfig.unitPrice,arguments:[h.BytesValue.fromHex(t),h.BytesValue.fromUTF8(e)]})}createWarpVerifyTransaction(t){if(!this.config.user?.wallet)throw new Error("WarpRegistry: user address not set");let e=h.Address.newFromBech32(this.config.user.wallet);return this.getFactory().createTransactionForExecute(e,{contract:this.getRegistryContractAddress(),function:"verifyWarp",gasLimit:BigInt(1e7),arguments:[h.BytesValue.fromHex(t)]})}createWarpTransferOwnershipTransaction(t,e){if(!this.config.user?.wallet)throw new Error("WarpRegistry: user address not set");let r=h.Address.newFromBech32(this.config.user.wallet);return this.getFactory().createTransactionForExecute(r,{contract:this.getRegistryContractAddress(),function:"transferOwnership",gasLimit:BigInt(1e7),arguments:[h.BytesValue.fromHex(t),new h.AddressValue(new h.Address(e))]})}createBrandRegisterTransaction(t){if(this.registryConfig.unitPrice===BigInt(0))throw new Error("WarpRegistry: config not loaded. forgot to call init()?");if(!this.config.user?.wallet)throw new Error("WarpRegistry: user address not set");let e=h.Address.newFromBech32(this.config.user.wallet);return this.getFactory().createTransactionForExecute(e,{contract:this.getRegistryContractAddress(),function:"registerBrand",gasLimit:BigInt(1e7),nativeTransferAmount:this.isCurrentUserAdmin()?void 0:this.registryConfig.unitPrice,arguments:[h.BytesValue.fromHex(t)]})}createWarpBrandingTransaction(t,e){if(!this.config.user?.wallet)throw new Error("WarpRegistry: user address not set");let r=h.Address.newFromBech32(this.config.user.wallet);return this.getFactory().createTransactionForExecute(r,{contract:this.getRegistryContractAddress(),function:"brandWarp",gasLimit:BigInt(1e7),nativeTransferAmount:this.isCurrentUserAdmin()?void 0:this.registryConfig.unitPrice,arguments:[h.BytesValue.fromHex(t),h.BytesValue.fromHex(e)]})}async getInfoByAlias(t,e){try{let r=S.RegistryInfo(t),n=e?this.cache.get(r):null;if(n)return C.info(`WarpRegistry (getInfoByAlias): RegistryInfo found in cache: ${t}`),n;let a=this.getRegistryContractAddress(),s=this.getController(),o=s.createQuery({contract:a,function:"getInfoByAlias",arguments:[h.BytesValue.fromUTF8(t)]}),p=await s.runQuery(o),[u]=s.parseQueryResponse(p),d=u?st(u):null,g=d?.brand?await this.fetchBrand(d.brand):null;return e&&e.ttl&&this.cache.set(r,{registryInfo:d,brand:g},e.ttl),{registryInfo:d,brand:g}}catch{return{registryInfo:null,brand:null}}}async getInfoByHash(t,e){try{let r=S.RegistryInfo(t);if(e){let g=this.cache.get(r);if(g)return C.info(`WarpRegistry (getInfoByHash): RegistryInfo found in cache: ${t}`),g}let n=this.getRegistryContractAddress(),a=this.getController(),s=a.createQuery({contract:n,function:"getInfoByHash",arguments:[h.BytesValue.fromHex(t)]}),o=await a.runQuery(s),[p]=a.parseQueryResponse(o),u=p?st(p):null,d=u?.brand?await this.fetchBrand(u.brand):null;return e&&e.ttl&&this.cache.set(r,{registryInfo:u,brand:d},e.ttl),{registryInfo:u,brand:d}}catch{return{registryInfo:null,brand:null}}}async getUserWarpRegistryInfos(t){try{let e=t||this.config.user?.wallet;if(!e)throw new Error("WarpRegistry: user address not set");let r=this.getRegistryContractAddress(),n=this.getController(),a=n.createQuery({contract:r,function:"getUserWarps",arguments:[new h.AddressValue(new h.Address(e))]}),s=await n.runQuery(a),[o]=n.parseQueryResponse(s);return o.map(st)}catch{return[]}}async getUserBrands(t){try{let e=t||this.config.user?.wallet;if(!e)throw new Error("WarpRegistry: user address not set");let r=this.getRegistryContractAddress(),n=this.getController(),a=n.createQuery({contract:r,function:"getUserBrands",arguments:[new h.AddressValue(new h.Address(e))]}),s=await n.runQuery(a),[o]=n.parseQueryResponse(s),p=o.map(g=>g.toString("hex")),u={ttl:365*24*60*60};return(await Promise.all(p.map(g=>this.fetchBrand(g,u)))).filter(g=>g!==null)}catch{return[]}}async getChainInfos(t){let e=S.ChainInfos();if(t&&t.ttl){let u=this.cache.get(e);if(u)return C.info("WarpRegistry (getChainInfos): ChainInfos found in cache"),u}let r=this.getRegistryContractAddress(),n=this.getController(),a=n.createQuery({contract:r,function:"getChains",arguments:[]}),s=await n.runQuery(a),[o]=n.parseQueryResponse(s),p=o.map(at);if(t&&t.ttl){for(let u of p)this.cache.set(S.ChainInfo(u.chain),u,t.ttl);this.cache.set(e,p,t.ttl)}return p}async getChainInfo(t,e){try{let r=S.ChainInfo(t),n=e?this.cache.get(r):null;if(n)return C.info(`WarpRegistry (getChainInfo): ChainInfo found in cache: ${t}`),n;let a=this.getRegistryContractAddress(),s=this.getController(),o=s.createQuery({contract:a,function:"getChain",arguments:[h.BytesValue.fromUTF8(t)]}),p=await s.runQuery(o),[u]=s.parseQueryResponse(p),d=u?at(u):null;return e&&e.ttl&&d&&this.cache.set(r,d,e.ttl),d}catch{return null}}async fetchBrand(t,e){let r=S.Brand(t),n=e?this.cache.get(r):null;if(n)return C.info(`WarpRegistry (fetchBrand): Brand found in cache: ${t}`),n;let a=A(this.config),o=T.getChainEntrypoint(a,this.config.env).createNetworkProvider();try{let p=await o.getTransaction(t),u=JSON.parse(p.data.toString());return u.meta={hash:p.hash,creator:p.sender.bech32(),createdAt:new Date(p.timestamp*1e3).toISOString()},e&&e.ttl&&this.cache.set(r,u,e.ttl),u}catch{return null}}getRegistryContractAddress(){return h.Address.newFromBech32(this.config.registry?.contract||x.Registry.Contract(this.config.env))}async loadRegistryConfigs(){let t=this.getRegistryContractAddress(),e=this.getController(),[r]=await e.query({contract:t,function:"getConfig",arguments:[]}),n=r?Wt(r):null;this.registryConfig=n||{unitPrice:BigInt(0),admins:[]}}getFactory(){let t=A(this.config),e=new h.TransactionsFactoryConfig({chainID:t.chainId}),r=h.AbiRegistry.create(lt);return new h.SmartContractTransactionsFactory({config:e,abi:r})}getController(){let t=A(this.config),e=T.getChainEntrypoint(t,this.config.env),r=h.AbiRegistry.create(lt);return e.createSmartContractController(r)}isCurrentUserAdmin(){return!!this.config.user?.wallet&&this.registryConfig.admins.includes(this.config.user.wallet)}};var et=class{constructor(t){this.config=t;this.config=t}isValid(t){return t.startsWith(f.HttpProtocolPrefix)?!!this.extractIdentifierInfoFromUrl(t):!1}async detectFromHtml(t){if(!t.length)return{match:!1,results:[]};let n=[...t.matchAll(/https?:\/\/[^\s"'<>]+/gi)].map(u=>u[0]).filter(u=>this.isValid(u)).map(u=>this.detect(u)),s=(await Promise.all(n)).filter(u=>u.match),o=s.length>0,p=s.map(u=>({url:u.url,warp:u.warp}));return{match:o,results:p}}async detect(t,e){let r={match:!1,url:t,warp:null,registryInfo:null,brand:null},n=t.startsWith(f.HttpProtocolPrefix)?this.extractIdentifierInfoFromUrl(t):T.getInfoFromPrefixedIdentifier(t);if(!n)return r;try{let{type:a,identifierBase:s}=n,o=new tt(this.config),p=new _(this.config),u=null,d=null,g=null;if(a==="hash"){u=await o.createFromTransactionHash(s,e);let y=await p.getInfoByHash(s,e);d=y.registryInfo,g=y.brand}else if(a==="alias"){let y=await p.getInfoByAlias(s,e);d=y.registryInfo,g=y.brand,y.registryInfo&&(u=await o.createFromTransactionHash(y.registryInfo.hash,e))}let w=u?await N.apply(this.config,u):null;return w?{match:!0,url:t,warp:w,registryInfo:d,brand:g}:r}catch(a){return C.error("Error detecting warp link",a),r}}build(t,e){let r=this.config.clientUrl||x.DefaultClientUrl(this.config.env),n=t===f.IdentifierType.Alias?encodeURIComponent(e):encodeURIComponent(t+f.IdentifierParamSeparator+e);return x.SuperClientUrls.includes(r)?`${r}/${n}`:`${r}?${f.IdentifierParamName}=${n}`}buildFromPrefixedIdentifier(t){let e=T.getInfoFromPrefixedIdentifier(t);return e?this.build(e.type,e.identifierBase):""}generateQrCode(t,e,r=512,n="white",a="black",s="#23F7DD"){let o=this.build(t,e);return new Tt.default({type:"svg",width:r,height:r,data:String(o),margin:16,qrOptions:{typeNumber:0,mode:"Byte",errorCorrectionLevel:"Q"},backgroundOptions:{color:n},dotsOptions:{type:"extra-rounded",color:a},cornersSquareOptions:{type:"extra-rounded",color:a},cornersDotOptions:{type:"square",color:a},imageOptions:{hideBackgroundDots:!0,imageSize:.4,margin:8},image:`data:image/svg+xml;utf8,<svg width="16" height="16" viewBox="0 0 100 100" fill="${encodeURIComponent(s)}" xmlns="http://www.w3.org/2000/svg"><path d="M54.8383 50.0242L95 28.8232L88.2456 16L51.4717 30.6974C50.5241 31.0764 49.4759 31.0764 48.5283 30.6974L11.7544 16L5 28.8232L45.1616 50.0242L5 71.2255L11.7544 84.0488L48.5283 69.351C49.4759 68.9724 50.5241 68.9724 51.4717 69.351L88.2456 84.0488L95 71.2255L54.8383 50.0242Z"/></svg>`})}extractIdentifierInfoFromUrl(t){let e=new URL(t),r=x.SuperClientUrls.includes(e.origin),n=e.searchParams.get(f.IdentifierParamName),a=r&&!n?e.pathname.split("/")[1]:n;if(!a)return null;let s=decodeURIComponent(a);return T.getInfoFromPrefixedIdentifier(s)}};var $t="https://",T=class{static getInfoFromPrefixedIdentifier(t){let e=decodeURIComponent(t),r=e.includes(f.IdentifierParamSeparator)?e:`${f.IdentifierType.Alias}${f.IdentifierParamSeparator}${e}`,[n,a]=r.split(f.IdentifierParamSeparator),s=a.split("?")[0];return{type:n,identifier:a,identifierBase:s}}static getNextInfo(t,e,r,n){let a=e.actions?.[r]?.next||e.next||null;if(!a)return null;if(a.startsWith($t))return[{identifier:null,url:a}];let[s,o]=a.split("?");if(!o)return[{identifier:s,url:this.buildNextUrl(s,t)}];let p=o.match(/{{([^}]+)\[\](\.[^}]+)?}}/g)||[];if(p.length===0){let m=K(o,{...e.vars,...n}),W=m?`${s}?${m}`:s;return[{identifier:W,url:this.buildNextUrl(W,t)}]}let u=p[0];if(!u)return[];let d=u.match(/{{([^[]+)\[\]/),g=d?d[1]:null;if(!g||n[g]===void 0)return[];let w=Array.isArray(n[g])?n[g]:[n[g]];if(w.length===0)return[];let y=p.filter(m=>m.includes(`{{${g}[]`)).map(m=>{let W=m.match(/\[\](\.[^}]+)?}}/),v=W&&W[1]||"";return{placeholder:m,field:v?v.slice(1):"",regex:new RegExp(m.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),"g")}});return w.map(m=>{let W=o;for(let{regex:E,field:P}of y){let b=P?this.getNestedValue(m,P):m;if(b==null)return null;W=W.replace(E,b)}if(W.includes("{{")||W.includes("}}"))return null;let v=W?`${s}?${W}`:s;return{identifier:v,url:this.buildNextUrl(v,t)}}).filter(m=>m!==null)}static buildNextUrl(t,e){let[r,n]=t.split("?"),a=this.getInfoFromPrefixedIdentifier(r)||{type:"alias",identifier:r,identifierBase:r},o=new et(e).build(a.type,a.identifierBase);if(!n)return o;let p=new URL(o);return new URLSearchParams(n).forEach((u,d)=>p.searchParams.set(d,u)),p.toString().replace(/\/\?/,"?")}static getNestedValue(t,e){return e.split(".").reduce((r,n)=>r?.[n],t)}static async getChainInfoForAction(t,e){if(!e.chain)return A(t);let r=await new _(t).getChainInfo(e.chain,{ttl:Y.OneWeek});if(!r)throw new Error(`WarpActionExecutor: Chain info not found for ${e.chain}`);return r}static getChainEntrypoint(t,e){let r="warp-sdk",n="api";return e==="devnet"?new D.DevnetEntrypoint(t.apiUrl,n,r):e==="testnet"?new D.TestnetEntrypoint(t.apiUrl,n,r):new D.MainnetEntrypoint(t.apiUrl,n,r)}};var ft=class{constructor(t){this.pendingBrand={protocol:L("brand"),name:"",description:"",logo:""};this.config=t}createInscriptionTransaction(t){if(!this.config.user?.wallet)throw new Error("BrandBuilder: user address not set");let e=A(this.config),r=new M.TransactionsFactoryConfig({chainID:e.chainId}),n=new M.TransferTransactionsFactory({config:r}),a=M.Address.newFromBech32(this.config.user.wallet),s=JSON.stringify(t);return n.createTransactionForNativeTokenTransfer(a,{receiver:M.Address.newFromBech32(this.config.user.wallet),nativeAmount:BigInt(0),data:Uint8Array.from(Buffer.from(s))})}async createFromRaw(t,e=!0){let r=JSON.parse(t);return e&&await this.ensureValidSchema(r),r}async createFromTransaction(t,e=!1){return await this.createFromRaw(t.data.toString(),e)}async createFromTransactionHash(t){let e=A(this.config),n=T.getChainEntrypoint(e,this.config.env).createNetworkProvider();try{let a=await n.getTransaction(t);return this.createFromTransaction(a)}catch(a){return C.error("BrandBuilder: Error creating from transaction hash",a),null}}setName(t){return this.pendingBrand.name=t,this}setDescription(t){return this.pendingBrand.description=t,this}setLogo(t){return this.pendingBrand.logo=t,this}setUrls(t){return this.pendingBrand.urls=t,this}setColors(t){return this.pendingBrand.colors=t,this}setCta(t){return this.pendingBrand.cta=t,this}async build(){return this.ensure(this.pendingBrand.name,"name is required"),this.ensure(this.pendingBrand.description,"description is required"),this.ensure(this.pendingBrand.logo,"logo is required"),await this.ensureValidSchema(this.pendingBrand),this.pendingBrand}ensure(t,e){if(!t)throw new Error(`Warp: ${e}`)}async ensureValidSchema(t){let e=this.config.schema?.brand||x.LatestBrandSchemaUrl,n=await(await fetch(e)).json(),a=new Ct.default,s=a.compile(n);if(!s(t))throw new Error(`BrandBuilder: schema validation failed: ${a.errorsText(s.errors)}`)}};var l=require("@multiversx/sdk-core/out"),Lt=(i,t)=>i?l.OptionValue.newProvided(i):t?l.OptionValue.newMissingTyped(t):l.OptionValue.newMissing(),qt=(i,t)=>i?new l.OptionalValue(i.getType(),i):t?new l.OptionalValue(t):l.OptionalValue.newMissing(),_t=i=>{if(i.length===0)throw new Error("Cannot create a list from an empty array");let t=i[0].getType();return new l.List(t,i)},Mt=i=>l.VariadicValue.fromItems(...i),Ht=i=>{let t=i.map(e=>e.getType());return new l.CompositeValue(new l.CompositeType(...t),i)},jt=i=>l.StringValue.fromUTF8(i),Dt=i=>new l.U8Value(i),Qt=i=>new l.U16Value(i),Gt=i=>new l.U32Value(i),zt=i=>new l.U64Value(i),Kt=i=>new l.BigUIntValue(BigInt(i)),Jt=i=>new l.BooleanValue(i),Xt=i=>new l.AddressValue(l.Address.newFromBech32(i)),Yt=i=>new l.TokenIdentifierValue(i),Zt=i=>l.BytesValue.fromHex(i),te=i=>new l.Struct(new l.StructType("EsdtTokenPayment",[new l.FieldDefinition("token_identifier","",new l.TokenIdentifierType),new l.FieldDefinition("token_nonce","",new l.U64Type),new l.FieldDefinition("amount","",new l.BigUIntType)]),[new l.Field(new l.TokenIdentifierValue(i.token.identifier),"token_identifier"),new l.Field(new l.U64Value(BigInt(i.token.nonce)),"token_nonce"),new l.Field(new l.BigUIntValue(BigInt(i.amount)),"amount")]),ee=i=>new l.CodeMetadataValue(l.CodeMetadata.newFromBytes(Uint8Array.from(Buffer.from(i,"hex")))),re=()=>new l.NothingValue;var Q=require("@multiversx/sdk-core");var rt=class{constructor(t){this.cache=new V;this.config=t}createInscriptionTransaction(t){if(!this.config.user?.wallet)throw new Error("WarpBuilder: user address not set");let e=A(this.config),r=new Q.TransactionsFactoryConfig({chainID:e.chainId}),n=new Q.TransferTransactionsFactory({config:r}),a={protocol:L("abi"),content:t},s=Q.Address.newFromBech32(this.config.user.wallet),o=JSON.stringify(a),p=n.createTransactionForTransfer(s,{receiver:s,nativeAmount:BigInt(0),data:Uint8Array.from(Buffer.from(o))});return p.gasLimit=p.gasLimit+BigInt(2e6),p}async createFromRaw(t){return JSON.parse(t)}async createFromTransaction(t){let e=await this.createFromRaw(t.data.toString());return e.meta={hash:t.hash,creator:t.sender.bech32(),createdAt:new Date(t.timestamp*1e3).toISOString()},e}async createFromTransactionHash(t,e){let r=S.WarpAbi(t);if(e){let o=this.cache.get(r);if(o)return C.info(`WarpAbiBuilder (createFromTransactionHash): Warp abi found in cache: ${t}`),o}let n=A(this.config),s=T.getChainEntrypoint(n,this.config.env).createNetworkProvider();try{let o=await s.getTransaction(t),p=await this.createFromTransaction(o);return e&&e.ttl&&p&&this.cache.set(r,p,e.ttl),p}catch(o){return C.error("WarpAbiBuilder: Error creating from transaction hash",o),null}}};var I=require("@multiversx/sdk-core");var G=require("@multiversx/sdk-core/out");var c=require("@multiversx/sdk-core/out");var It=new RegExp(`${f.ArgParamsSeparator}(.*)`),k=class{nativeToString(t,e){return t==="esdt"&&e instanceof c.TokenTransfer?`esdt:${e.token.identifier}|${e.token.nonce.toString()}|${e.amount.toString()}`:`${t}:${e?.toString()??""}`}typedToString(t){if(t.hasClassOrSuperclass(c.OptionValue.ClassName))return t.isSet()?`option:${this.typedToString(t.getTypedValue())}`:"option:null";if(t.hasClassOrSuperclass(c.OptionalValue.ClassName))return t.isSet()?`optional:${this.typedToString(t.getTypedValue())}`:"optional:null";if(t.hasClassOrSuperclass(c.List.ClassName)){let e=t.getItems(),n=e.map(s=>this.typedToString(s).split(f.ArgParamsSeparator)[0])[0],a=e.map(s=>this.typedToString(s).split(f.ArgParamsSeparator)[1]);return`list:${n}:${a.join(",")}`}if(t.hasClassOrSuperclass(c.VariadicValue.ClassName)){let e=t.getItems(),n=e.map(s=>this.typedToString(s).split(f.ArgParamsSeparator)[0])[0],a=e.map(s=>this.typedToString(s).split(f.ArgParamsSeparator)[1]);return`variadic:${n}:${a.join(",")}`}if(t.hasClassOrSuperclass(c.CompositeValue.ClassName)){let e=t.getItems(),r=e.map(o=>this.typedToString(o).split(f.ArgParamsSeparator)[0]),n=e.map(o=>this.typedToString(o).split(f.ArgParamsSeparator)[1]),a=r.join(f.ArgCompositeSeparator),s=n.join(f.ArgCompositeSeparator);return`composite(${a}):${s}`}if(t.hasClassOrSuperclass(c.BigUIntValue.ClassName)||t.getType().getName()==="BigUint")return`biguint:${BigInt(t.valueOf().toFixed())}`;if(t.hasClassOrSuperclass(c.U8Value.ClassName))return`uint8:${t.valueOf().toNumber()}`;if(t.hasClassOrSuperclass(c.U16Value.ClassName))return`uint16:${t.valueOf().toNumber()}`;if(t.hasClassOrSuperclass(c.U32Value.ClassName))return`uint32:${t.valueOf().toNumber()}`;if(t.hasClassOrSuperclass(c.U64Value.ClassName))return`uint64:${BigInt(t.valueOf().toFixed())}`;if(t.hasClassOrSuperclass(c.StringValue.ClassName))return`string:${t.valueOf()}`;if(t.hasClassOrSuperclass(c.BooleanValue.ClassName))return`bool:${t.valueOf()}`;if(t.hasClassOrSuperclass(c.AddressValue.ClassName))return`address:${t.valueOf().bech32()}`;if(t.hasClassOrSuperclass(c.TokenIdentifierValue.ClassName))return`token:${t.valueOf()}`;if(t.hasClassOrSuperclass(c.BytesValue.ClassName))return`hex:${t.valueOf().toString("hex")}`;if(t.hasClassOrSuperclass(c.CodeMetadataValue.ClassName))return`codemeta:${t.valueOf().toBuffer().toString("hex")}`;if(t.getType().getName()==="EsdtTokenPayment"){let e=t.getFieldValue("token_identifier").valueOf(),r=t.getFieldValue("token_nonce").valueOf(),n=t.getFieldValue("amount").valueOf();return`esdt:${e}|${r}|${n}`}throw new Error(`WarpArgSerializer (typedToString): Unsupported input type: ${t.getClassName()}`)}typedToNative(t){let e=this.typedToString(t);return this.stringToNative(e)}nativeToTyped(t,e){let r=this.nativeToString(t,e);return this.stringToTyped(r)}nativeToType(t){if(t.startsWith("composite")){let e=t.match(/\(([^)]+)\)/)?.[1];return new c.CompositeType(...e.split(f.ArgCompositeSeparator).map(r=>this.nativeToType(r)))}if(t==="string")return new c.StringType;if(t==="uint8")return new c.U8Type;if(t==="uint16")return new c.U16Type;if(t==="uint32")return new c.U32Type;if(t==="uint64")return new c.U64Type;if(t==="biguint")return new c.BigUIntType;if(t==="bool")return new c.BooleanType;if(t==="address")return new c.AddressType;if(t==="token")return new c.TokenIdentifierType;if(t==="hex")return new c.BytesType;if(t==="codemeta")return new c.CodeMetadataType;if(t==="esdt"||t==="nft")return 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)]);throw new Error(`WarpArgSerializer (nativeToType): Unsupported input type: ${t}`)}stringToNative(t){let e=t.split(f.ArgParamsSeparator),r=e[0],n=e.slice(1).join(f.ArgParamsSeparator);if(r==="null")return[r,null];if(r==="option"){let[a,s]=n.split(f.ArgParamsSeparator);return[`option:${a}`,s||null]}else if(r==="optional"){let[a,s]=n.split(f.ArgParamsSeparator);return[`optional:${a}`,s||null]}else if(r==="list"){let a=n.split(f.ArgParamsSeparator),s=a.slice(0,-1).join(f.ArgParamsSeparator),o=a[a.length-1],u=(o?o.split(","):[]).map(d=>this.stringToNative(`${s}:${d}`)[1]);return[`list:${s}`,u]}else if(r==="variadic"){let a=n.split(f.ArgParamsSeparator),s=a.slice(0,-1).join(f.ArgParamsSeparator),o=a[a.length-1],u=(o?o.split(","):[]).map(d=>this.stringToNative(`${s}:${d}`)[1]);return[`variadic:${s}`,u]}else if(r.startsWith("composite")){let a=r.match(/\(([^)]+)\)/)?.[1]?.split(f.ArgCompositeSeparator),o=n.split(f.ArgCompositeSeparator).map((p,u)=>this.stringToNative(`${a[u]}:${p}`)[1]);return[r,o]}else{if(r==="string")return[r,n];if(r==="uint8"||r==="uint16"||r==="uint32")return[r,Number(n)];if(r==="uint64"||r==="biguint")return[r,BigInt(n||0)];if(r==="bool")return[r,n==="true"];if(r==="address")return[r,n];if(r==="token")return[r,n];if(r==="hex")return[r,n];if(r==="codemeta")return[r,n];if(r==="esdt"){let[a,s,o]=n.split(f.ArgCompositeSeparator);return[r,new c.TokenTransfer({token:new c.Token({identifier:a,nonce:BigInt(s)}),amount:BigInt(o)})]}}throw new Error(`WarpArgSerializer (stringToNative): Unsupported input type: ${r}`)}stringToTyped(t){let[e,r]=t.split(/:(.*)/,2);if(e==="null"||e===null)return new c.NothingValue;if(e==="option"){let n=this.stringToTyped(r);return n instanceof c.NothingValue?c.OptionValue.newMissingTyped(n.getType()):c.OptionValue.newProvided(n)}if(e==="optional"){let n=this.stringToTyped(r);return n instanceof c.NothingValue?c.OptionalValue.newMissing():new c.OptionalValue(n.getType(),n)}if(e==="list"){let[n,a]=r.split(It,2),o=a.split(",").map(p=>this.stringToTyped(`${n}:${p}`));return new c.List(this.nativeToType(n),o)}if(e==="variadic"){let[n,a]=r.split(It,2),o=a.split(",").map(p=>this.stringToTyped(`${n}:${p}`));return new c.VariadicValue(new c.VariadicType(this.nativeToType(n)),o)}if(e.startsWith("composite")){let n=e.match(/\(([^)]+)\)/)?.[1],a=r.split(f.ArgCompositeSeparator),s=n.split(f.ArgCompositeSeparator),o=a.map((u,d)=>this.stringToTyped(`${s[d]}:${u}`)),p=o.map(u=>u.getType());return new c.CompositeValue(new c.CompositeType(...p),o)}if(e==="string")return r?c.StringValue.fromUTF8(r):new c.NothingValue;if(e==="uint8")return r?new c.U8Value(Number(r)):new c.NothingValue;if(e==="uint16")return r?new c.U16Value(Number(r)):new c.NothingValue;if(e==="uint32")return r?new c.U32Value(Number(r)):new c.NothingValue;if(e==="uint64")return r?new c.U64Value(BigInt(r)):new c.NothingValue;if(e==="biguint")return r?new c.BigUIntValue(BigInt(r)):new c.NothingValue;if(e==="bool")return r?new c.BooleanValue(typeof r=="boolean"?r:r==="true"):new c.NothingValue;if(e==="address")return r?new c.AddressValue(c.Address.newFromBech32(r)):new c.NothingValue;if(e==="token")return r?new c.TokenIdentifierValue(r):new c.NothingValue;if(e==="hex")return r?c.BytesValue.fromHex(r):new c.NothingValue;if(e==="codemeta")return new c.CodeMetadataValue(c.CodeMetadata.newFromBytes(Uint8Array.from(Buffer.from(r,"hex"))));if(e==="esdt"){let n=r.split(f.ArgCompositeSeparator);return new c.Struct(this.nativeToType("esdt"),[new c.Field(new c.TokenIdentifierValue(n[0]),"token_identifier"),new c.Field(new c.U64Value(BigInt(n[1])),"token_nonce"),new c.Field(new c.BigUIntValue(BigInt(n[2])),"amount")])}throw new Error(`WarpArgSerializer (stringToTyped): Unsupported input type: ${e}`)}typeToString(t){if(t instanceof c.OptionType)return"option:"+this.typeToString(t.getFirstTypeParameter());if(t instanceof c.OptionalType)return"optional:"+this.typeToString(t.getFirstTypeParameter());if(t instanceof c.ListType)return"list:"+this.typeToString(t.getFirstTypeParameter());if(t instanceof c.VariadicType)return"variadic:"+this.typeToString(t.getFirstTypeParameter());if(t instanceof c.StringType)return"string";if(t instanceof c.U8Type)return"uint8";if(t instanceof c.U16Type)return"uint16";if(t instanceof c.U32Type)return"uint32";if(t instanceof c.U64Type)return"uint64";if(t instanceof c.BigUIntType)return"biguint";if(t instanceof c.BooleanType)return"bool";if(t instanceof c.AddressType)return"address";if(t instanceof c.TokenIdentifierType)return"token";if(t instanceof c.BytesType)return"hex";if(t instanceof c.CodeMetadataType)return"codemeta";if(t instanceof c.StructType&&t.getClassName()==="EsdtTokenPayment")return"esdt";throw new Error(`WarpArgSerializer (typeToString): Unsupported input type: ${t.getClassName()}`)}};var dt=i=>{if(i==="out")return 1;let t=i.match(/^out\[(\d+)\]/);return t?parseInt(t[1],10):(i.startsWith("out.")||i.startsWith("event."),null)},ie=(i,t)=>t.reduce((e,r)=>e&&e[r]!==void 0?e[r]:null,i),At=async(i,t,e,r,n,a)=>{let s=[],o={};if(!t.results||e.type!=="contract")return{values:s,results:o};if(!Object.values(t.results).some(y=>y.includes("out")||y.includes("event"))){for(let[y,B]of Object.entries(t.results))o[y]=B;return{values:s,results:await ot(t,o,n,a)}}let u=await i.getAbiForAction(e),d=new G.TransactionEventsParser({abi:u}),w=new G.SmartContractTransactionsOutcomeParser({abi:u}).parseExecute({transactionOnNetwork:r,function:e.func||void 0});for(let[y,B]of Object.entries(t.results)){if(B.startsWith(f.Transform.Prefix))continue;if(B.startsWith("input.")){o[y]=B;continue}let m=dt(B);if(m!==null&&m!==n){o[y]=null;continue}let[W,v,E]=B.split(".");if(W==="event"){if(!v||isNaN(Number(E)))continue;let P=Number(E),b=(0,G.findEventsByFirstTopic)(r,v),H=d.parseEvents({events:b})[0],U=Object.values(H)[P]||null;s.push(U),o[y]=U&&U.valueOf()}else if(W==="out"||W.startsWith("out[")){if(!v)continue;let P=Number(v),b=w.values[P-1]||null;E&&(b=b[E]||null),b&&typeof b=="object"&&(b="toFixed"in b?b.toFixed():b.valueOf()),s.push(b),o[y]=b&&b.valueOf()}else o[y]=B}return{values:s,results:await ot(t,o,n,a)}},xt=async(i,t,e,r)=>{let n=new k,a=t.map(u=>n.typedToString(u)),s=t.map(u=>n.typedToNative(u)[1]),o={};if(!i.results)return{values:a,results:o};let p=u=>{let d=u.split(".").slice(1).map(w=>parseInt(w)-1);if(d.length===0)return;let g=s[d[0]];for(let w=1;w<d.length;w++){if(g==null)return;g=g[d[w]]}return g};for(let[u,d]of Object.entries(i.results)){if(d.startsWith(f.Transform.Prefix))continue;let g=dt(d);if(g!==null&&g!==e){o[u]=null;continue}d.startsWith("out.")||d==="out"||d.startsWith("out[")?o[u]=p(d)||null:o[u]=d}return{values:a,results:await ot(i,o,e,r)}},Bt=async(i,t,e,r)=>{let n=[],a={};for(let[s,o]of Object.entries(i.results||{})){if(o.startsWith(f.Transform.Prefix))continue;let p=dt(o);if(p!==null&&p!==e){a[s]=null;continue}let[u,...d]=o.split(".");if(u==="out"||u.startsWith("out[")){let g=d.length===0?t?.data||t:ie(t,d);n.push(g),a[s]=g}else a[s]=o}return{values:n,results:await ot(i,a,e,r)}};var ot=async(i,t,e,r)=>{if(!i.results)return t;let n={...t};return n=ae(n,i,e,r),n=await se(i,n),n},ae=(i,t,e,r)=>{let n={...i},a=O(t,e)?.inputs||[],s=new k;for(let[o,p]of Object.entries(n))if(typeof p=="string"&&p.startsWith("input.")){let u=p.split(".")[1],d=a.findIndex(w=>w.as===u||w.name===u),g=d!==-1?r[d]?.value:null;n[o]=g?s.stringToNative(g)[1]:null}return n},se=async(i,t)=>{if(!i.results)return t;let e={...t},r=Object.entries(i.results).filter(([,n])=>n.startsWith(f.Transform.Prefix)).map(([n,a])=>({key:n,code:a.substring(f.Transform.Prefix.length)}));for(let{key:n,code:a}of r)try{let{runInVm:s}=await Promise.resolve().then(()=>(vt(),bt));e[n]=await s(a,e)}catch(s){C.error(`Transform error for result '${n}':`,s),e[n]=null}return e};var oe=[{id:"EGLD",name:"eGold",decimals:18},{id:"EGLD-000000",name:"eGold",decimals:18}],St=i=>oe.find(t=>t.id===i)||null;var nt=class{constructor(t){this.config=t}async getContract(t,e){try{let a=await T.getChainEntrypoint(e,this.config.env).createNetworkProvider().doGetGeneric(`accounts/${t}`);return{address:t,owner:a.ownerAddress,verified:a.isVerified||!1}}catch(r){return C.error("WarpContractLoader: getContract error",r),null}}async getVerificationInfo(t,e){try{let a=await T.getChainEntrypoint(e,this.config.env).createNetworkProvider().doGetGeneric(`accounts/${t}/verification`);return{codeHash:a.codeHash,abi:a.source.abi}}catch(r){return C.error("WarpContractLoader: getVerificationInfo error",r),null}}};var gt=class{constructor(t){if(!t.currentUrl)throw new Error("WarpActionExecutor: currentUrl config not set");this.config=t,this.url=new URL(t.currentUrl),this.serializer=new k,this.contractLoader=new nt(t),this.cache=new V(t.cache?.type)}async createTransactionForExecute(t,e,r){let n=O(t,e);if(!this.config.user?.wallet)throw new Error("WarpActionExecutor: user address not set");let a=I.Address.newFromBech32(this.config.user.wallet),s=await T.getChainInfoForAction(this.config,n),o=new I.TransactionsFactoryConfig({chainID:s.chainId}),{destination:p,args:u,value:d,transfers:g,data:w,resolvedInputs:y}=await this.getTxComponentsFromInputs(s,n,r,a),B=u.map(W=>this.serializer.stringToTyped(W)),m=null;if(n.type==="transfer")m=new I.TransferTransactionsFactory({config:o}).createTransactionForTransfer(a,{receiver:p,nativeAmount:d,tokenTransfers:g,data:w?new Uint8Array(w):void 0});else if(n.type==="contract"&&p.isSmartContract())m=new I.SmartContractTransactionsFactory({config:o}).createTransactionForExecute(a,{contract:p,function:"func"in n&&n.func||"",gasLimit:"gasLimit"in n?BigInt(n.gasLimit||0):0n,arguments:B,tokenTransfers:g,nativeTransferAmount:d});else{if(n.type==="query")throw new Error("WarpActionExecutor: Invalid action type for createTransactionForExecute; Use executeQuery instead");if(n.type==="collect")throw new Error("WarpActionExecutor: Invalid action type for createTransactionForExecute; Use executeCollect instead")}if(!m)throw new Error(`WarpActionExecutor: Invalid action type (${n.type})`);return this.cache.set(S.LastWarpExecutionInputs(t.meta?.hash||"",e),y,Y.OneWeek),m}async getTransactionExecutionResults(t,e,r){let n=await N.apply(this.config,t),a=O(n,e),s=this.cache.get(S.LastWarpExecutionInputs(t.meta?.hash||"",e))??[],{values:o,results:p}=await At(this,n,a,r,e,s),u=T.getNextInfo(this.config,n,e,p),d=this.getPreparedMessages(n,p);return{success:r.status.isSuccessful(),warp:n,action:e,user:this.config.user?.wallet||null,txHash:r.hash,next:u,values:o,results:p,messages:d}}async executeQuery(t,e,r){let n=O(t,e);if(!n)throw new Error("WarpActionExecutor: Action not found");if(!n.func)throw new Error("WarpActionExecutor: Function not found");let a=await T.getChainInfoForAction(this.config,n),s=await N.apply(this.config,t),o=await this.getAbiForAction(n),{args:p,resolvedInputs:u}=await this.getTxComponentsFromInputs(a,n,r),d=p.map(ct=>this.serializer.stringToTyped(ct)),g=T.getChainEntrypoint(a,this.config.env),w=I.Address.newFromBech32(n.address),y=g.createSmartContractController(o),B=y.createQuery({contract:w,function:n.func,arguments:d}),m=await y.runQuery(B),W=m.returnCode==="ok",v=new I.ArgSerializer,E=o.getEndpoint(m.function),P=m.returnDataParts.map(ct=>Buffer.from(ct)),b=v.buffersToValues(P,E.output),{values:H,results:U}=await xt(s,b,e,u),R=T.getNextInfo(this.config,s,e,U);return{success:W,warp:s,action:e,user:this.config.user?.wallet||null,txHash:null,next:R,values:H,results:U,messages:this.getPreparedMessages(s,U)}}async executeCollect(t,e,r,n){let a=O(t,e);if(!a)throw new Error("WarpActionExecutor: Action not found");let s=await T.getChainInfoForAction(this.config,a),o=await N.apply(this.config,t),p=await this.getResolvedInputs(s,a,r),u=this.getModifiedInputs(p),d=m=>{if(!m.value)return null;let W=this.serializer.stringToNative(m.value)[1];if(m.input.type==="biguint")return W.toString();if(m.input.type==="esdt"){let v=W;return{token:v.token.identifier,nonce:v.token.nonce.toString(),amount:v.amount.toString()}}else return W},g=new Headers;g.set("Content-Type","application/json"),g.set("Accept","application/json"),Object.entries(a.destination.headers||{}).forEach(([m,W])=>{g.set(m,W)});let w=Object.fromEntries(u.map(m=>[m.input.as||m.input.name,d(m)])),y=a.destination.method||"GET",B=y==="GET"?void 0:JSON.stringify({inputs:w,meta:n});try{let m=await fetch(a.destination.url,{method:y,headers:g,body:B}),W=await m.json(),{values:v,results:E}=await Bt(o,W,e,u),P=T.getNextInfo(this.config,o,e,E);return{success:m.ok,warp:o,action:e,user:this.config.user?.wallet||null,txHash:null,next:P,values:v,results:E,messages:this.getPreparedMessages(o,E)}}catch(m){return C.error("WarpActionExecutor: Error executing collect",m),{success:!1,warp:o,action:e,user:this.config.user?.wallet||null,txHash:null,next:null,values:[],results:{error:m instanceof Error?m.message:"Unknown error"},messages:{}}}}async getTxComponentsFromInputs(t,e,r,n){let a=await this.getResolvedInputs(t,e,r),s=this.getModifiedInputs(a),o=s.find(R=>R.input.position==="receiver")?.value,p="address"in e?e.address:null,u=o?.split(":")[1]||p||n?.toBech32();if(!u)throw new Error("WarpActionExecutor: Destination/Receiver not provided");let d=I.Address.newFromBech32(u),g=this.getPreparedArgs(e,s),w=s.find(R=>R.input.position==="value")?.value||null,y="value"in e?e.value:null,B=BigInt(w?.split(":")[1]||y||0),m=s.filter(R=>R.input.position==="transfer"&&R.value).map(R=>R.value),v=[...("transfers"in e?e.transfers:[])?.map(this.toTypedTransfer)||[],...m?.map(R=>this.serializer.stringToNative(R)[1])||[]],E=s.find(R=>R.input.position==="data")?.value,P="data"in e?e.data||"":null,b=E||P||null,H=b?this.serializer.stringToTyped(b).valueOf():null,U=H?Buffer.from(H):null;return{destination:d,args:g,value:B,transfers:v,data:U,resolvedInputs:s}}async getResolvedInputs(t,e,r){let n=e.inputs||[],a=await Promise.all(r.map(o=>this.preprocessInput(t,o))),s=(o,p)=>{if(o.source==="query"){let u=this.url.searchParams.get(o.name);return u?this.serializer.nativeToString(o.type,u):null}else return o.source===f.Source.UserWallet?this.config.user?.wallet?this.serializer.nativeToString("address",this.config.user.wallet):null:a[p]||null};return n.map((o,p)=>({input:o,value:s(o,p)}))}getModifiedInputs(t){return t.map((e,r)=>{if(e.input.modifier?.startsWith("scale:")){let[,n]=e.input.modifier.split(":");if(isNaN(Number(n))){let a=Number(t.find(p=>p.input.name===n)?.value?.split(":")[1]);if(!a)throw new Error(`WarpActionExecutor: Exponent value not found for input ${n}`);let s=e.value?.split(":")[1];if(!s)throw new Error("WarpActionExecutor: Scalable value not found");let o=z(s,+a);return{...e,value:`${e.input.type}:${o}`}}else{let a=e.value?.split(":")[1];if(!a)throw new Error("WarpActionExecutor: Scalable value not found");let s=z(a,+n);return{...e,value:`${e.input.type}:${s}`}}}else return e})}async preprocessInput(t,e){try{let[r,n]=e.split(f.ArgParamsSeparator,2);if(r==="esdt"){let[a,s,o,p]=n.split(f.ArgCompositeSeparator);if(p)return e;let u=new I.Token({identifier:a,nonce:BigInt(s)});if(!new I.TokenComputer().isFungible(u))return e;let w=St(a)?.decimals;if(w||(w=(await(await fetch(`${t.apiUrl}/tokens/${a}`)).json()).decimals),!w)throw new Error(`WarpActionExecutor: Decimals not found for token ${a}`);let y=new I.TokenTransfer({token:u,amount:z(o,w)});return this.serializer.nativeToString(r,y)+f.ArgCompositeSeparator+w}return e}catch{return e}}async getAbiForAction(t){if(t.abi)return await this.fetchAbi(t);let e=A(this.config),r=await this.contractLoader.getVerificationInfo(t.address,e);if(!r)throw new Error("WarpActionExecutor: Verification info not found");return I.AbiRegistry.create(r.abi)}getPreparedArgs(t,e){let r="args"in t?t.args||[]:[];return e.forEach(({input:n,value:a})=>{if(!a||!n.position?.startsWith("arg:"))return;let s=Number(n.position.split(":")[1])-1;r.splice(s,0,a)}),r}getPreparedMessages(t,e){let r=Object.entries(t.messages||{}).map(([n,a])=>[n,K(a,e)]);return Object.fromEntries(r)}async fetchAbi(t){if(!t.abi)throw new Error("WarpActionExecutor: ABI not found");if(t.abi.startsWith(f.IdentifierType.Hash)){let e=new rt(this.config),r=t.abi.split(f.IdentifierParamSeparator)[1],n=await e.createFromTransactionHash(r);if(!n)throw new Error(`WarpActionExecutor: ABI not found for hash: ${t.abi}`);return I.AbiRegistry.create(n.content)}else{let r=await(await fetch(t.abi)).json();return I.AbiRegistry.create(r)}}toTypedTransfer(t){return new I.TokenTransfer({token:new I.Token({identifier:t.token,nonce:BigInt(t.nonce||0)}),amount:BigInt(t.amount||0)})}};var mt=class{constructor(t){this.config=t}async search(t,e,r){if(!this.config.index?.url)throw new Error("WarpIndex: Index URL is not set");try{let n=await fetch(this.config.index?.url,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${this.config.index?.apiKey}`,...r},body:JSON.stringify({[this.config.index?.searchParamName||"search"]:t,...e})});if(!n.ok)throw new Error(`WarpIndex: search failed with status ${n.status}`);return(await n.json()).hits}catch(n){throw C.error("WarpIndex: Error searching for warps: ",n),n}}};0&&(module.exports={BrandBuilder,CacheKey,CacheTtl,WarpAbiBuilder,WarpActionExecutor,WarpArgSerializer,WarpBuilder,WarpCache,WarpConfig,WarpConstants,WarpContractLoader,WarpIndex,WarpInterpolator,WarpLink,WarpProtocolVersions,WarpRegistry,WarpUtils,WarpValidator,address,biguint,boolean,codemeta,composite,esdt,getChainExplorerUrl,getLatestProtocolIdentifier,getMainChainInfo,getWarpActionByIndex,hex,list,nothing,option,optional,replacePlaceholders,shiftBigintBy,string,toPreviewText,toTypedChainInfo,token,u16,u32,u64,u8,variadic});
|
package/dist/vm-JCVDACTR.mjs
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import{a as l}from"./chunk-3SAEGOMQ.mjs";var u=async(n,i)=>{if(typeof window>"u"){let s;try{s=l("vm2").VM}catch{throw new Error('The optional dependency "vm2" is not installed. To use runInVm in Node.js, please install vm2: npm install vm2 --save. This is not required for browser usage.')}let e=new s({timeout:1e3,sandbox:{result:i},eval:!1,wasm:!1});return n.trim().startsWith("(")&&n.includes("=>")?e.run(`(${n})(result)`):null}return new Promise((s,e)=>{try{let o=new Blob([`
|
|
2
|
-
self.onmessage = function(e) {
|
|
3
|
-
try {
|
|
4
|
-
const result = e.data;
|
|
5
|
-
const output = (${n})(result);
|
|
6
|
-
self.postMessage({ result: output });
|
|
7
|
-
} catch (error) {
|
|
8
|
-
self.postMessage({ error: error.toString() });
|
|
9
|
-
}
|
|
10
|
-
};
|
|
11
|
-
`],{type:"application/javascript"}),a=URL.createObjectURL(o),r=new Worker(a);r.onmessage=function(t){t.data.error?e(new Error(t.data.error)):s(t.data.result),r.terminate(),URL.revokeObjectURL(a)},r.onerror=function(t){e(new Error(`Error in transform: ${t.message}`)),r.terminate(),URL.revokeObjectURL(a)},r.postMessage(i)}catch(o){return e(o)}})};export{u as runInVm};
|