@vleap/warps 1.1.0 → 1.2.0

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.mts CHANGED
@@ -2,8 +2,26 @@ import { Transaction, TransactionOnNetwork, TypedValue as TypedValue$1, Address,
2
2
  import { TypedValue, Type, OptionValue, OptionalValue, List, VariadicValue, CompositeValue, StringValue, U8Value, U16Value, U32Value, U64Value, BigUIntValue, BooleanValue, AddressValue, TokenIdentifierValue, BytesValue, TokenTransfer, Struct, CodeMetadataValue, NothingValue, Transaction as Transaction$1, Address as Address$1 } from '@multiversx/sdk-core/out';
3
3
  import QRCodeStyling from 'qr-code-styling';
4
4
 
5
+ declare const CacheKey: {
6
+ Warp: (id: string) => string;
7
+ WarpAbi: (id: string) => string;
8
+ RegistryInfo: (id: string) => string;
9
+ Brand: (hash: string) => string;
10
+ ChainInfo: (chain: WarpChain) => string;
11
+ };
12
+ type CacheType = 'memory' | 'localStorage';
13
+ declare class WarpCache {
14
+ private strategy;
15
+ constructor(type?: CacheType);
16
+ private selectStrategy;
17
+ set<T>(key: string, value: T, ttl: number): void;
18
+ get<T>(key: string): T | null;
19
+ clear(): void;
20
+ }
21
+
5
22
  type ChainEnv = 'mainnet' | 'testnet' | 'devnet';
6
23
  type ProtocolName = 'warp' | 'brand' | 'abi';
24
+ type WarpChain = string;
7
25
  type WarpConfig = {
8
26
  env: ChainEnv;
9
27
  clientUrl?: string;
@@ -13,6 +31,7 @@ type WarpConfig = {
13
31
  warpSchemaUrl?: string;
14
32
  brandSchemaUrl?: string;
15
33
  cacheTtl?: number;
34
+ cacheType?: CacheType;
16
35
  registryContract?: string;
17
36
  indexUrl?: string;
18
37
  indexApiKey?: string;
@@ -32,6 +51,10 @@ type RegistryInfo = {
32
51
  brand: string | null;
33
52
  upgrade: string | null;
34
53
  };
54
+ type ChainInfo = {
55
+ chainId: string;
56
+ apiUrl: string;
57
+ };
35
58
  type WarpIdType = 'hash' | 'alias';
36
59
  type WarpVarPlaceholder = string;
37
60
  type Warp = {
@@ -55,6 +78,7 @@ type WarpAction = WarpTransferAction | WarpContractAction | WarpQueryAction | Wa
55
78
  type WarpActionType = 'transfer' | 'contract' | 'query' | 'collect' | 'link';
56
79
  type WarpTransferAction = {
57
80
  type: WarpActionType;
81
+ chain?: WarpChain;
58
82
  label: string;
59
83
  description?: string | null;
60
84
  address?: string;
@@ -66,6 +90,7 @@ type WarpTransferAction = {
66
90
  };
67
91
  type WarpContractAction = {
68
92
  type: WarpActionType;
93
+ chain?: WarpChain;
69
94
  label: string;
70
95
  description?: string | null;
71
96
  address: string;
@@ -91,6 +116,7 @@ type WarpLinkAction = {
91
116
  };
92
117
  type WarpQueryAction = {
93
118
  type: WarpActionType;
119
+ chain?: WarpChain;
94
120
  label: string;
95
121
  description?: string | null;
96
122
  address: string;
@@ -262,9 +288,11 @@ declare const WarpConstants: {
262
288
  };
263
289
 
264
290
  declare const getChainId: (env: ChainEnv) => string;
291
+ declare const getDefaultChainInfo: (config: WarpConfig) => ChainInfo;
265
292
  declare const getLatestProtocolIdentifier: (name: ProtocolName) => string;
266
293
  declare const getWarpActionByIndex: (warp: Warp, index: number) => WarpAction;
267
294
  declare const toTypedRegistryInfo: (registryInfo: any) => RegistryInfo;
295
+ declare const toTypedChainInfo: (chainInfo: any) => ChainInfo;
268
296
  declare const shiftBigintBy: (value: bigint | string, decimals: number) => bigint;
269
297
  declare const toPreviewText: (text: string, maxChars?: number) => string;
270
298
 
@@ -297,11 +325,16 @@ declare class WarpAbiBuilder {
297
325
  createFromTransactionHash(hash: string, cache?: WarpCacheConfig): Promise<WarpAbi | null>;
298
326
  }
299
327
 
328
+ type ResolvedInput = {
329
+ input: WarpActionInput;
330
+ value: string | null;
331
+ };
300
332
  declare class WarpActionExecutor {
301
333
  private config;
302
334
  private url;
303
335
  private serializer;
304
336
  private contractLoader;
337
+ private registry;
305
338
  constructor(config: WarpConfig);
306
339
  createTransactionForExecute(action: WarpTransferAction | WarpContractAction, inputs: string[]): Promise<Transaction>;
307
340
  executeQuery(action: WarpQueryAction, inputs: string[]): Promise<TypedValue$1>;
@@ -313,10 +346,11 @@ declare class WarpActionExecutor {
313
346
  transfers: TokenTransfer$1[];
314
347
  data: Buffer | null;
315
348
  }>;
316
- private getModifiedInputs;
317
- private getResolvedInputs;
318
- private preprocessInput;
349
+ getResolvedInputs(action: WarpAction, inputArgs: string[]): Promise<ResolvedInput[]>;
350
+ getModifiedInputs(inputs: ResolvedInput[]): ResolvedInput[];
351
+ preprocessInput(input: string): Promise<string>;
319
352
  private getPreparedArgs;
353
+ private getChainInfoForAction;
320
354
  private getAbiForAction;
321
355
  private fetchAbi;
322
356
  private toTypedTransfer;
@@ -354,19 +388,6 @@ declare class WarpBuilder {
354
388
  private ensure;
355
389
  }
356
390
 
357
- declare const CacheKey: {
358
- Warp: (id: string) => string;
359
- WarpAbi: (id: string) => string;
360
- RegistryInfo: (id: string) => string;
361
- Brand: (hash: string) => string;
362
- };
363
- declare class WarpCache {
364
- private cache;
365
- set<T>(key: string, value: T, ttl: number): void;
366
- get<T>(key: string): T | null;
367
- clear(): void;
368
- }
369
-
370
391
  declare class WarpContractLoader {
371
392
  private readonly config;
372
393
  constructor(config: WarpConfig);
@@ -428,6 +449,7 @@ declare class WarpRegistry {
428
449
  }>;
429
450
  getUserWarpRegistryInfos(user?: string): Promise<RegistryInfo[]>;
430
451
  getUserBrands(user?: string): Promise<Brand[]>;
452
+ getChainInfo(chain: WarpChain, cache?: WarpCacheConfig): Promise<ChainInfo | null>;
431
453
  fetchBrand(hash: string, cache?: WarpCacheConfig): Promise<Brand | null>;
432
454
  getRegistryContractAddress(): Address$1;
433
455
  private loadRegistryConfigs;
@@ -442,7 +464,7 @@ declare class WarpUtils {
442
464
  id: string;
443
465
  } | null;
444
466
  static getNextStepUrl(warp: Warp, config: WarpConfig): string | null;
445
- static getChainEntrypoint(config: WarpConfig): NetworkEntrypoint;
467
+ static getChainEntrypoint(chainInfo: ChainInfo, env: ChainEnv): NetworkEntrypoint;
446
468
  static getConfiguredChainApi(config: WarpConfig): ApiNetworkProvider;
447
469
  }
448
470
 
@@ -454,4 +476,4 @@ declare class WarpValidator {
454
476
  private ensureValidSchema;
455
477
  }
456
478
 
457
- export { type AbiContents, type BaseWarpActionInputType, type Brand, BrandBuilder, type BrandColors, type BrandCta, type BrandMeta, type BrandUrls, CacheKey, type ChainEnv, Config, type ProtocolName, type RegistryInfo, type TrustStatus, type Warp, type WarpAbi, WarpAbiBuilder, type WarpAction, type WarpActionExecutionResult, WarpActionExecutor, type WarpActionInput, type WarpActionInputModifier, type WarpActionInputPosition, type WarpActionInputSource, type WarpActionInputType, type WarpActionType, WarpArgSerializer, WarpBuilder, WarpCache, type WarpCacheConfig, type WarpCollectAction, type WarpConfig, WarpConstants, type WarpContract, type WarpContractAction, type WarpContractActionTransfer, WarpContractLoader, type WarpContractVerification, type WarpIdType, WarpIndex, WarpLink, type WarpLinkAction, type WarpMeta, type WarpNativeValue, WarpProtocolVersions, type WarpQueryAction, WarpRegistry, type WarpSearchHit, type WarpSearchResult, type WarpTransferAction, WarpUtils, WarpValidator, type WarpVarPlaceholder, address, biguint, boolean, codemeta, composite, esdt, getChainId, getLatestProtocolIdentifier, getWarpActionByIndex, hex, list, nothing, option, optional, shiftBigintBy, string, toPreviewText, toTypedRegistryInfo, token, u16, u32, u64, u8, variadic };
479
+ export { type AbiContents, type BaseWarpActionInputType, type Brand, BrandBuilder, type BrandColors, type BrandCta, type BrandMeta, type BrandUrls, CacheKey, type CacheType, type ChainEnv, type ChainInfo, Config, type ProtocolName, type RegistryInfo, type TrustStatus, type Warp, type WarpAbi, WarpAbiBuilder, type WarpAction, type WarpActionExecutionResult, WarpActionExecutor, type WarpActionInput, type WarpActionInputModifier, type WarpActionInputPosition, type WarpActionInputSource, type WarpActionInputType, type WarpActionType, WarpArgSerializer, WarpBuilder, WarpCache, type WarpCacheConfig, type WarpChain, type WarpCollectAction, type WarpConfig, WarpConstants, type WarpContract, type WarpContractAction, type WarpContractActionTransfer, WarpContractLoader, type WarpContractVerification, type WarpIdType, WarpIndex, WarpLink, type WarpLinkAction, type WarpMeta, type WarpNativeValue, WarpProtocolVersions, type WarpQueryAction, WarpRegistry, type WarpSearchHit, type WarpSearchResult, type WarpTransferAction, WarpUtils, WarpValidator, type WarpVarPlaceholder, address, biguint, boolean, codemeta, composite, esdt, getChainId, getDefaultChainInfo, getLatestProtocolIdentifier, getWarpActionByIndex, hex, list, nothing, option, optional, shiftBigintBy, string, toPreviewText, toTypedChainInfo, toTypedRegistryInfo, token, u16, u32, u64, u8, variadic };
package/dist/index.d.ts CHANGED
@@ -2,8 +2,26 @@ import { Transaction, TransactionOnNetwork, TypedValue as TypedValue$1, Address,
2
2
  import { TypedValue, Type, OptionValue, OptionalValue, List, VariadicValue, CompositeValue, StringValue, U8Value, U16Value, U32Value, U64Value, BigUIntValue, BooleanValue, AddressValue, TokenIdentifierValue, BytesValue, TokenTransfer, Struct, CodeMetadataValue, NothingValue, Transaction as Transaction$1, Address as Address$1 } from '@multiversx/sdk-core/out';
3
3
  import QRCodeStyling from 'qr-code-styling';
4
4
 
5
+ declare const CacheKey: {
6
+ Warp: (id: string) => string;
7
+ WarpAbi: (id: string) => string;
8
+ RegistryInfo: (id: string) => string;
9
+ Brand: (hash: string) => string;
10
+ ChainInfo: (chain: WarpChain) => string;
11
+ };
12
+ type CacheType = 'memory' | 'localStorage';
13
+ declare class WarpCache {
14
+ private strategy;
15
+ constructor(type?: CacheType);
16
+ private selectStrategy;
17
+ set<T>(key: string, value: T, ttl: number): void;
18
+ get<T>(key: string): T | null;
19
+ clear(): void;
20
+ }
21
+
5
22
  type ChainEnv = 'mainnet' | 'testnet' | 'devnet';
6
23
  type ProtocolName = 'warp' | 'brand' | 'abi';
24
+ type WarpChain = string;
7
25
  type WarpConfig = {
8
26
  env: ChainEnv;
9
27
  clientUrl?: string;
@@ -13,6 +31,7 @@ type WarpConfig = {
13
31
  warpSchemaUrl?: string;
14
32
  brandSchemaUrl?: string;
15
33
  cacheTtl?: number;
34
+ cacheType?: CacheType;
16
35
  registryContract?: string;
17
36
  indexUrl?: string;
18
37
  indexApiKey?: string;
@@ -32,6 +51,10 @@ type RegistryInfo = {
32
51
  brand: string | null;
33
52
  upgrade: string | null;
34
53
  };
54
+ type ChainInfo = {
55
+ chainId: string;
56
+ apiUrl: string;
57
+ };
35
58
  type WarpIdType = 'hash' | 'alias';
36
59
  type WarpVarPlaceholder = string;
37
60
  type Warp = {
@@ -55,6 +78,7 @@ type WarpAction = WarpTransferAction | WarpContractAction | WarpQueryAction | Wa
55
78
  type WarpActionType = 'transfer' | 'contract' | 'query' | 'collect' | 'link';
56
79
  type WarpTransferAction = {
57
80
  type: WarpActionType;
81
+ chain?: WarpChain;
58
82
  label: string;
59
83
  description?: string | null;
60
84
  address?: string;
@@ -66,6 +90,7 @@ type WarpTransferAction = {
66
90
  };
67
91
  type WarpContractAction = {
68
92
  type: WarpActionType;
93
+ chain?: WarpChain;
69
94
  label: string;
70
95
  description?: string | null;
71
96
  address: string;
@@ -91,6 +116,7 @@ type WarpLinkAction = {
91
116
  };
92
117
  type WarpQueryAction = {
93
118
  type: WarpActionType;
119
+ chain?: WarpChain;
94
120
  label: string;
95
121
  description?: string | null;
96
122
  address: string;
@@ -262,9 +288,11 @@ declare const WarpConstants: {
262
288
  };
263
289
 
264
290
  declare const getChainId: (env: ChainEnv) => string;
291
+ declare const getDefaultChainInfo: (config: WarpConfig) => ChainInfo;
265
292
  declare const getLatestProtocolIdentifier: (name: ProtocolName) => string;
266
293
  declare const getWarpActionByIndex: (warp: Warp, index: number) => WarpAction;
267
294
  declare const toTypedRegistryInfo: (registryInfo: any) => RegistryInfo;
295
+ declare const toTypedChainInfo: (chainInfo: any) => ChainInfo;
268
296
  declare const shiftBigintBy: (value: bigint | string, decimals: number) => bigint;
269
297
  declare const toPreviewText: (text: string, maxChars?: number) => string;
270
298
 
@@ -297,11 +325,16 @@ declare class WarpAbiBuilder {
297
325
  createFromTransactionHash(hash: string, cache?: WarpCacheConfig): Promise<WarpAbi | null>;
298
326
  }
299
327
 
328
+ type ResolvedInput = {
329
+ input: WarpActionInput;
330
+ value: string | null;
331
+ };
300
332
  declare class WarpActionExecutor {
301
333
  private config;
302
334
  private url;
303
335
  private serializer;
304
336
  private contractLoader;
337
+ private registry;
305
338
  constructor(config: WarpConfig);
306
339
  createTransactionForExecute(action: WarpTransferAction | WarpContractAction, inputs: string[]): Promise<Transaction>;
307
340
  executeQuery(action: WarpQueryAction, inputs: string[]): Promise<TypedValue$1>;
@@ -313,10 +346,11 @@ declare class WarpActionExecutor {
313
346
  transfers: TokenTransfer$1[];
314
347
  data: Buffer | null;
315
348
  }>;
316
- private getModifiedInputs;
317
- private getResolvedInputs;
318
- private preprocessInput;
349
+ getResolvedInputs(action: WarpAction, inputArgs: string[]): Promise<ResolvedInput[]>;
350
+ getModifiedInputs(inputs: ResolvedInput[]): ResolvedInput[];
351
+ preprocessInput(input: string): Promise<string>;
319
352
  private getPreparedArgs;
353
+ private getChainInfoForAction;
320
354
  private getAbiForAction;
321
355
  private fetchAbi;
322
356
  private toTypedTransfer;
@@ -354,19 +388,6 @@ declare class WarpBuilder {
354
388
  private ensure;
355
389
  }
356
390
 
357
- declare const CacheKey: {
358
- Warp: (id: string) => string;
359
- WarpAbi: (id: string) => string;
360
- RegistryInfo: (id: string) => string;
361
- Brand: (hash: string) => string;
362
- };
363
- declare class WarpCache {
364
- private cache;
365
- set<T>(key: string, value: T, ttl: number): void;
366
- get<T>(key: string): T | null;
367
- clear(): void;
368
- }
369
-
370
391
  declare class WarpContractLoader {
371
392
  private readonly config;
372
393
  constructor(config: WarpConfig);
@@ -428,6 +449,7 @@ declare class WarpRegistry {
428
449
  }>;
429
450
  getUserWarpRegistryInfos(user?: string): Promise<RegistryInfo[]>;
430
451
  getUserBrands(user?: string): Promise<Brand[]>;
452
+ getChainInfo(chain: WarpChain, cache?: WarpCacheConfig): Promise<ChainInfo | null>;
431
453
  fetchBrand(hash: string, cache?: WarpCacheConfig): Promise<Brand | null>;
432
454
  getRegistryContractAddress(): Address$1;
433
455
  private loadRegistryConfigs;
@@ -442,7 +464,7 @@ declare class WarpUtils {
442
464
  id: string;
443
465
  } | null;
444
466
  static getNextStepUrl(warp: Warp, config: WarpConfig): string | null;
445
- static getChainEntrypoint(config: WarpConfig): NetworkEntrypoint;
467
+ static getChainEntrypoint(chainInfo: ChainInfo, env: ChainEnv): NetworkEntrypoint;
446
468
  static getConfiguredChainApi(config: WarpConfig): ApiNetworkProvider;
447
469
  }
448
470
 
@@ -454,4 +476,4 @@ declare class WarpValidator {
454
476
  private ensureValidSchema;
455
477
  }
456
478
 
457
- export { type AbiContents, type BaseWarpActionInputType, type Brand, BrandBuilder, type BrandColors, type BrandCta, type BrandMeta, type BrandUrls, CacheKey, type ChainEnv, Config, type ProtocolName, type RegistryInfo, type TrustStatus, type Warp, type WarpAbi, WarpAbiBuilder, type WarpAction, type WarpActionExecutionResult, WarpActionExecutor, type WarpActionInput, type WarpActionInputModifier, type WarpActionInputPosition, type WarpActionInputSource, type WarpActionInputType, type WarpActionType, WarpArgSerializer, WarpBuilder, WarpCache, type WarpCacheConfig, type WarpCollectAction, type WarpConfig, WarpConstants, type WarpContract, type WarpContractAction, type WarpContractActionTransfer, WarpContractLoader, type WarpContractVerification, type WarpIdType, WarpIndex, WarpLink, type WarpLinkAction, type WarpMeta, type WarpNativeValue, WarpProtocolVersions, type WarpQueryAction, WarpRegistry, type WarpSearchHit, type WarpSearchResult, type WarpTransferAction, WarpUtils, WarpValidator, type WarpVarPlaceholder, address, biguint, boolean, codemeta, composite, esdt, getChainId, getLatestProtocolIdentifier, getWarpActionByIndex, hex, list, nothing, option, optional, shiftBigintBy, string, toPreviewText, toTypedRegistryInfo, token, u16, u32, u64, u8, variadic };
479
+ export { type AbiContents, type BaseWarpActionInputType, type Brand, BrandBuilder, type BrandColors, type BrandCta, type BrandMeta, type BrandUrls, CacheKey, type CacheType, type ChainEnv, type ChainInfo, Config, type ProtocolName, type RegistryInfo, type TrustStatus, type Warp, type WarpAbi, WarpAbiBuilder, type WarpAction, type WarpActionExecutionResult, WarpActionExecutor, type WarpActionInput, type WarpActionInputModifier, type WarpActionInputPosition, type WarpActionInputSource, type WarpActionInputType, type WarpActionType, WarpArgSerializer, WarpBuilder, WarpCache, type WarpCacheConfig, type WarpChain, type WarpCollectAction, type WarpConfig, WarpConstants, type WarpContract, type WarpContractAction, type WarpContractActionTransfer, WarpContractLoader, type WarpContractVerification, type WarpIdType, WarpIndex, WarpLink, type WarpLinkAction, type WarpMeta, type WarpNativeValue, WarpProtocolVersions, type WarpQueryAction, WarpRegistry, type WarpSearchHit, type WarpSearchResult, type WarpTransferAction, WarpUtils, WarpValidator, type WarpVarPlaceholder, address, biguint, boolean, codemeta, composite, esdt, getChainId, getDefaultChainInfo, getLatestProtocolIdentifier, getWarpActionByIndex, hex, list, nothing, option, optional, shiftBigintBy, string, toPreviewText, toTypedChainInfo, toTypedRegistryInfo, token, u16, u32, u64, u8, variadic };
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- "use strict";var pt=Object.create;var q=Object.defineProperty;var ut=Object.getOwnPropertyDescriptor;var lt=Object.getOwnPropertyNames;var dt=Object.getPrototypeOf,gt=Object.prototype.hasOwnProperty;var ft=(s,t)=>{for(var e in t)q(s,e,{get:t[e],enumerable:!0})},Z=(s,t,e,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of lt(t))!gt.call(s,n)&&n!==e&&q(s,n,{get:()=>t[n],enumerable:!(r=ut(t,n))||r.enumerable});return s};var H=(s,t,e)=>(e=s!=null?pt(dt(s)):{},Z(t||!s||!s.__esModule?q(e,"default",{value:s,enumerable:!0}):e,s)),mt=s=>Z(q({},"__esModule",{value:!0}),s);var Ot={};ft(Ot,{BrandBuilder:()=>z,CacheKey:()=>C,Config:()=>w,WarpAbiBuilder:()=>N,WarpActionExecutor:()=>M,WarpArgSerializer:()=>$,WarpBuilder:()=>E,WarpCache:()=>A,WarpConstants:()=>d,WarpContractLoader:()=>O,WarpIndex:()=>G,WarpLink:()=>k,WarpProtocolVersions:()=>I,WarpRegistry:()=>F,WarpUtils:()=>y,WarpValidator:()=>x,address:()=>Rt,biguint:()=>Vt,boolean:()=>Pt,codemeta:()=>kt,composite:()=>bt,esdt:()=>Ft,getChainId:()=>W,getLatestProtocolIdentifier:()=>B,getWarpActionByIndex:()=>ht,hex:()=>Et,list:()=>At,nothing:()=>Nt,option:()=>Tt,optional:()=>Wt,shiftBigintBy:()=>U,string:()=>It,toPreviewText:()=>j,toTypedRegistryInfo:()=>R,token:()=>Ut,u16:()=>vt,u32:()=>St,u64:()=>xt,u8:()=>Bt,variadic:()=>Ct});module.exports=mt(Ot);var S=require("@multiversx/sdk-core"),rt=H(require("ajv"));var I={Warp:"1.0.0",Brand:"0.1.0",Abi:"0.1.0"},w={LatestWarpSchemaUrl:`https://raw.githubusercontent.com/vLeapGroup/warps-specs/refs/heads/main/schemas/v${I.Warp}.schema.json`,LatestBrandSchemaUrl:`https://raw.githubusercontent.com/vLeapGroup/warps-specs/refs/heads/main/schemas/brand/v${I.Brand}.schema.json`,DefaultClientUrl:s=>s==="devnet"?"https://devnet.usewarp.to":s==="testnet"?"https://testnet.usewarp.to":"https://usewarp.to",SuperClientUrls:["https://usewarp.to","https://testnet.usewarp.to","https://devnet.usewarp.to"],Chain:{ApiUrl:s=>s==="devnet"?"https://devnet-api.multiversx.com":s==="testnet"?"https://testnet-api.multiversx.com":"https://api.multiversx.com"},Registry:{Contract:s=>s==="devnet"?"erd1qqqqqqqqqqqqqpgqje2f99vr6r7sk54thg03c9suzcvwr4nfl3tsfkdl36":s==="testnet"?"####":"erd1qqqqqqqqqqqqqpgq3mrpj3u6q7tejv6d7eqhnyd27n9v5c5tl3ts08mffe"},AvailableActionInputSources:["field","query"],AvailableActionInputTypes:["string","uint8","uint16","uint32","uint64","biguint","boolean","address"],AvailableActionInputPositions:["value","arg:1","arg:2","arg:3","arg:4","arg:5","arg:6","arg:7","arg:8","arg:9","arg:10"]};var W=s=>s==="devnet"?"D":s==="testnet"?"T":"1",B=s=>{if(s==="warp")return`warp:${I.Warp}`;if(s==="brand")return`brand:${I.Brand}`;if(s==="abi")return`abi:${I.Abi}`;throw new Error(`getLatestProtocolIdentifier: Invalid protocol name: ${s}`)},ht=(s,t)=>s?.actions[t-1],R=s=>({hash:s.hash.toString("hex"),alias:s.alias?.toString()||null,trust:s.trust.toString(),creator:s.creator.toString(),createdAt:s.created_at.toNumber(),brand:s.brand?.toString("hex")||null,upgrade:s.upgrade?.toString("hex")||null}),U=(s,t)=>{let e=s.toString(),[r,n=""]=e.split("."),a=Math.abs(t);if(t>0)return BigInt(r+n.padEnd(a,"0"));if(t<0){let o=r+n;if(a>=o.length)return 0n;let p=o.slice(0,-a)||"0";return BigInt(p)}else return BigInt(s)},j=(s,t=100)=>{if(!s)return"";let e=s.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};var b=require("@multiversx/sdk-core");var d={HttpProtocolPrefix:"http",IdentifierParamName:"warp",IdentifierParamSeparator:":",IdentifierType:{Alias:"alias",Hash:"hash"},ArgParamsSeparator:":",ArgCompositeSeparator:"|",Egld:{Identifier:"EGLD",DisplayName:"eGold",Decimals:18}};var Y=H(require("qr-code-styling"));var v=require("@multiversx/sdk-core");var C={Warp:s=>`warp:${s}`,WarpAbi:s=>`warp-abi:${s}`,RegistryInfo:s=>`registry-info:${s}`,Brand:s=>`brand:${s}`},A=class{constructor(){this.cache=new Map}set(t,e,r){let n=Date.now()+r*1e3;this.cache.set(t,{value:e,expiresAt:n})}get(t){let e=this.cache.get(t);return e?Date.now()>e.expiresAt?(this.cache.delete(t),null):e.value:null}clear(){this.cache.clear()}};var X=H(require("ajv"));var x=class{constructor(t){this.config=t;this.config=t}async validate(t){this.ensureMaxOneValuePosition(t),await this.ensureValidSchema(t)}ensureMaxOneValuePosition(t){if(t.actions.filter(r=>"position"in r?r.position==="value":!1).length>1)throw new Error("WarpBuilder: only one value position action is allowed")}async ensureValidSchema(t){let e=this.config.warpSchemaUrl||w.LatestWarpSchemaUrl,n=await(await fetch(e)).json(),a=new X.default,o=a.compile(n);if(!o(t))throw new Error(`WarpBuilder: schema validation failed: ${a.errorsText(o.errors)}`)}};var E=class{constructor(t){this.cache=new A;this.pendingWarp={protocol:B("warp"),name:"",title:"",description:null,preview:"",actions:[]};this.config=t}createInscriptionTransaction(t){if(!this.config.userAddress)throw new Error("WarpBuilder: user address not set");let e=new v.TransactionsFactoryConfig({chainID:W(this.config.env)}),r=new v.TransferTransactionsFactory({config:e}),n=v.Address.newFromBech32(this.config.userAddress),a=JSON.stringify(t),o=r.createTransactionForTransfer(n,{receiver:v.Address.newFromBech32(this.config.userAddress),nativeAmount:BigInt(0),data:Uint8Array.from(Buffer.from(a))});return o.gasLimit=o.gasLimit+BigInt(2e6),o}async createFromRaw(t,e=!0){let r=JSON.parse(t);return e&&await new x(this.config).validate(r),y.prepareVars(r,this.config)}async createFromTransaction(t,e=!1){let r=await this.createFromRaw(t.data.toString(),e);return r.meta={hash:t.hash,creator:t.sender.bech32(),createdAt:new Date(t.timestamp*1e3).toISOString()},r}async createFromTransactionHash(t,e){let r=C.Warp(t);if(e){let a=this.cache.get(r);if(a)return console.log(`WarpBuilder (createFromTransactionHash): Warp found in cache: ${t}`),a}let n=y.getConfiguredChainApi(this.config);try{let a=await n.getTransaction(t),o=await this.createFromTransaction(a);return e&&e.ttl&&o&&this.cache.set(r,o,e.ttl),o}catch(a){return console.error("WarpBuilder: Error creating from transaction hash",a),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 new x(this.config).validate(this.pendingWarp),this.pendingWarp}getDescriptionPreview(t,e=100){return j(t,e)}ensure(t,e){if(!t)throw new Error(`WarpBuilder: ${e}`)}};var g=require("@multiversx/sdk-core/out");var Q={buildInfo:{rustc:{version:"1.80.0-nightly",commitHash:"791adf759cc065316f054961875052d5bc03e16c",commitDate:"2024-05-21",channel:"Nightly",short:"rustc 1.80.0-nightly (791adf759 2024-05-21)"},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:"verifyWarp",onlyOwner:!0,mutability:"mutable",inputs:[{name:"warp",type:"bytes"}],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:"getConfig",mutability:"readonly",inputs:[],outputs:[{type:"BigUint"}]},{name:"registerBrand",mutability:"mutable",payableInTokens:["EGLD"],inputs:[{name:"hash",type:"bytes"}],outputs:[]},{name:"brandWarp",mutability:"mutable",payableInTokens:["EGLD"],inputs:[{name:"warp",type:"bytes"},{name:"brand",type:"bytes"}],outputs:[]},{name:"getUserBrands",mutability:"readonly",inputs:[{name:"user",type:"Address"}],outputs:[{type:"variadic<bytes>",multi_result:!0}]}],events:[{identifier:"warpRegistered",inputs:[{name:"hash",type:"bytes",indexed:!0},{name:"alias",type:"bytes",indexed:!0}]},{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}]},{identifier:"warpVerified",inputs:[{name:"hash",type:"bytes",indexed:!0}]},{identifier:"aliasUpdated",inputs:[{name:"hash",type:"bytes",indexed:!0},{name:"alias",type:"bytes",indexed:!0}]}],esdtAttributes:[],hasCallback:!1,types:{InfoView:{type:"struct",fields:[{name:"hash",type:"bytes"},{name:"alias",type:"Option<bytes>"},{name:"trust",type:"bytes"},{name:"creator",type:"Address"},{name:"created_at",type:"u64"},{name:"brand",type:"Option<bytes>"},{name:"upgrade",type:"Option<bytes>"}]}}};var F=class{constructor(t){this.cache=new A;this.config=t,this.unitPrice=BigInt(0)}async init(){await this.loadRegistryConfigs()}createWarpRegisterTransaction(t,e){if(this.unitPrice===BigInt(0))throw new Error("WarpRegistry: config not loaded. forgot to call init()?");if(!this.config.userAddress)throw new Error("WarpRegistry: user address not set");let r=g.Address.newFromBech32(this.config.userAddress),n=e?this.unitPrice*BigInt(2):this.unitPrice;return this.getFactory().createTransactionForExecute(r,{contract:this.getRegistryContractAddress(),function:"registerWarp",gasLimit:BigInt(1e7),nativeTransferAmount:n,arguments:e?[g.BytesValue.fromHex(t),g.BytesValue.fromUTF8(e)]:[g.BytesValue.fromHex(t)]})}createWarpUnregisterTransaction(t){if(!this.config.userAddress)throw new Error("WarpRegistry: user address not set");let e=g.Address.newFromBech32(this.config.userAddress);return this.getFactory().createTransactionForExecute(e,{contract:this.getRegistryContractAddress(),function:"unregisterWarp",gasLimit:BigInt(1e7),arguments:[g.BytesValue.fromHex(t)]})}createWarpUpgradeTransaction(t,e){if(this.unitPrice===BigInt(0))throw new Error("WarpRegistry: config not loaded. forgot to call init()?");if(!this.config.userAddress)throw new Error("WarpRegistry: user address not set");let r=g.Address.newFromBech32(this.config.userAddress);return this.getFactory().createTransactionForExecute(r,{contract:this.getRegistryContractAddress(),function:"upgradeWarp",gasLimit:BigInt(1e7),nativeTransferAmount:this.unitPrice,arguments:[g.BytesValue.fromUTF8(t),g.BytesValue.fromHex(e)]})}createWarpAliasSetTransaction(t,e){if(!this.config.userAddress)throw new Error("WarpRegistry: user address not set");let r=g.Address.newFromBech32(this.config.userAddress);return this.getFactory().createTransactionForExecute(r,{contract:this.getRegistryContractAddress(),function:"setWarpAlias",gasLimit:BigInt(1e7),nativeTransferAmount:this.unitPrice,arguments:[g.BytesValue.fromHex(t),g.BytesValue.fromUTF8(e)]})}createWarpVerifyTransaction(t){if(!this.config.userAddress)throw new Error("WarpRegistry: user address not set");let e=g.Address.newFromBech32(this.config.userAddress);return this.getFactory().createTransactionForExecute(e,{contract:this.getRegistryContractAddress(),function:"verifyWarp",gasLimit:BigInt(1e7),arguments:[g.BytesValue.fromHex(t)]})}createBrandRegisterTransaction(t){if(this.unitPrice===BigInt(0))throw new Error("WarpRegistry: config not loaded. forgot to call init()?");if(!this.config.userAddress)throw new Error("WarpRegistry: user address not set");let e=g.Address.newFromBech32(this.config.userAddress);return this.getFactory().createTransactionForExecute(e,{contract:this.getRegistryContractAddress(),function:"registerBrand",gasLimit:BigInt(1e7),nativeTransferAmount:this.unitPrice,arguments:[g.BytesValue.fromHex(t)]})}createWarpBrandingTransaction(t,e){if(!this.config.userAddress)throw new Error("WarpRegistry: user address not set");let r=g.Address.newFromBech32(this.config.userAddress);return this.getFactory().createTransactionForExecute(r,{contract:this.getRegistryContractAddress(),function:"brandWarp",gasLimit:BigInt(1e7),nativeTransferAmount:this.unitPrice,arguments:[g.BytesValue.fromHex(t),g.BytesValue.fromHex(e)]})}async getInfoByAlias(t,e){let r=C.RegistryInfo(t);if(e){let h=this.cache.get(r);if(h)return console.log(`WarpRegistry (getInfoByAlias): RegistryInfo found in cache: ${t}`),h}let n=this.getRegistryContractAddress(),a=this.getController(),o=a.createQuery({contract:n,function:"getInfoByAlias",arguments:[g.BytesValue.fromUTF8(t)]}),p=await a.runQuery(o),[u]=a.parseQueryResponse(p),l=u?R(u):null,f=l?.brand?await this.fetchBrand(l.brand):null;return e&&e.ttl&&this.cache.set(r,{registryInfo:l,brand:f},e.ttl),{registryInfo:l,brand:f}}async getInfoByHash(t,e){let r=C.RegistryInfo(t);if(e){let h=this.cache.get(r);if(h)return console.log(`WarpRegistry (getInfoByHash): RegistryInfo found in cache: ${t}`),h}let n=this.getRegistryContractAddress(),a=this.getController(),o=a.createQuery({contract:n,function:"getInfoByHash",arguments:[g.BytesValue.fromHex(t)]}),p=await a.runQuery(o),[u]=a.parseQueryResponse(p),l=u?R(u):null,f=l?.brand?await this.fetchBrand(l.brand):null;return e&&e.ttl&&this.cache.set(r,{registryInfo:l,brand:f},e.ttl),{registryInfo:l,brand:f}}async getUserWarpRegistryInfos(t){let e=t||this.config.userAddress;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 g.AddressValue(new g.Address(e))]}),o=await n.runQuery(a),[p]=n.parseQueryResponse(o);return p.map(R)}async getUserBrands(t){let e=t||this.config.userAddress;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 g.AddressValue(new g.Address(e))]}),o=await n.runQuery(a),[p]=n.parseQueryResponse(o),u=p.map(h=>h.toString("hex")),l={ttl:365*24*60*60};return(await Promise.all(u.map(h=>this.fetchBrand(h,l)))).filter(h=>h!==null)}async fetchBrand(t,e){let r=C.Brand(t);if(e){let a=this.cache.get(r);if(a)return console.log(`WarpRegistry (fetchBrand): Brand found in cache: ${t}`),a}let n=y.getConfiguredChainApi(this.config);try{let a=await n.getTransaction(t),o=JSON.parse(a.data.toString());return o.meta={hash:a.hash,creator:a.sender.bech32(),createdAt:new Date(a.timestamp*1e3).toISOString()},e&&e.ttl&&this.cache.set(r,o,e.ttl),o}catch(a){return console.error("WarpRegistry: Error fetching brand from transaction hash",a),null}}getRegistryContractAddress(){return g.Address.newFromBech32(this.config.registryContract||w.Registry.Contract(this.config.env))}async loadRegistryConfigs(){let t=this.getRegistryContractAddress(),e=this.getController(),[r]=await e.query({contract:t,function:"getConfig",arguments:[]}),n=BigInt(r.toString());this.unitPrice=n}getFactory(){let t=new g.TransactionsFactoryConfig({chainID:W(this.config.env)}),e=g.AbiRegistry.create(Q);return new g.SmartContractTransactionsFactory({config:t,abi:e})}getController(){let t=y.getChainEntrypoint(this.config),e=g.AbiRegistry.create(Q);return t.createSmartContractController(e)}};var k=class{constructor(t){this.config=t;this.config=t}isValid(t){return t.startsWith(d.HttpProtocolPrefix)?!!this.extractIdentifierInfoFromUrl(t):!1}async detectFromHtml(t){if(!t.length)return{match:!1,results:[]};let n=[...t.matchAll(/https?:\/\/[^\s"'<>]+/gi)].map(l=>l[0]).filter(l=>this.isValid(l)).map(l=>this.detect(l)),o=(await Promise.all(n)).filter(l=>l.match),p=o.length>0,u=o.map(l=>({url:l.url,warp:l.warp}));return{match:p,results:u}}async detect(t){let e=t.startsWith(d.HttpProtocolPrefix)?this.extractIdentifierInfoFromUrl(t):y.getInfoFromPrefixedIdentifier(t);if(!e)return{match:!1,url:t,warp:null,registryInfo:null,brand:null};let{type:r,id:n}=e,a=new E(this.config),o=new F(this.config),p=null,u=null,l=null;if(r==="hash"){p=await a.createFromTransactionHash(n);try{let{registryInfo:f,brand:h}=await o.getInfoByHash(n);u=f,l=h}catch{}}else if(r==="alias"){let{registryInfo:f,brand:h}=await o.getInfoByAlias(n);u=f,l=h,f&&(p=await a.createFromTransactionHash(f.hash))}return p?{match:!0,url:t,warp:p,registryInfo:u,brand:l}:{match:!1,url:t,warp:null,registryInfo:null,brand:null}}build(t,e){let r=this.config.clientUrl||w.DefaultClientUrl(this.config.env),n=t===d.IdentifierType.Alias?encodeURIComponent(e):encodeURIComponent(t+d.IdentifierParamSeparator+e);return w.SuperClientUrls.includes(r)?`${r}/${n}`:`${r}?${d.IdentifierParamName}=${n}`}generateQrCode(t,e,r=512,n="white",a="black",o="#23F7DD"){let p=this.build(t,e);return new Y.default({type:"svg",width:r,height:r,data:String(p),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(o)}" 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=w.SuperClientUrls.includes(e.origin),n=e.searchParams.get(d.IdentifierParamName),a=r&&!n?e.pathname.split("/")[1]:n;if(!a)return null;let o=decodeURIComponent(a);return y.getInfoFromPrefixedIdentifier(o)}};var wt="https://",tt="query",et="env",y=class s{static prepareVars(t,e){if(!t?.vars)return t;let r=JSON.stringify(t),n=(a,o)=>{r=r.replace(new RegExp(`{{${a.toUpperCase()}}}`,"g"),o.toString())};return Object.entries(t.vars).forEach(([a,o])=>{if(typeof o=="string"&&o.startsWith(`${tt}:`)){if(!e.currentUrl)throw new Error("WarpUtils: currentUrl config is required to prepare vars");let p=o.split(`${tt}:`)[1],u=new URL(e.currentUrl).searchParams.get(p);u&&n(a,u)}else if(typeof o=="string"&&o.startsWith(`${et}:`)){let p=o.split(`${et}:`)[1],u=e.vars?.[p];u&&n(a,u)}else n(a,o)}),JSON.parse(r)}static getInfoFromPrefixedIdentifier(t){let e=decodeURIComponent(t),r=e.includes(d.IdentifierParamSeparator)?e:`${d.IdentifierType.Alias}${d.IdentifierParamSeparator}${e}`,[n,a]=r.split(d.IdentifierParamSeparator);return{type:n,id:a}}static getNextStepUrl(t,e){if(!t?.next)return null;if(t.next.startsWith(wt))return t.next;{let r=new k(e),n=s.getInfoFromPrefixedIdentifier(t.next);return n?r.build(n.type,n.id):null}}static getChainEntrypoint(t){return t.env==="devnet"?new b.DevnetEntrypoint:t.env==="testnet"?new b.TestnetEntrypoint:new b.MainnetEntrypoint}static getConfiguredChainApi(t){let e=t.chainApiUrl||w.Chain.ApiUrl(t.env);if(!e)throw new Error("WarpUtils: Chain API URL not configured");return new b.ApiNetworkProvider(e,{timeout:3e4,clientName:"warp-sdk"})}};var z=class{constructor(t){this.pendingBrand={protocol:B("brand"),name:"",description:"",logo:""};this.config=t}createInscriptionTransaction(t){if(!this.config.userAddress)throw new Error("BrandBuilder: user address not set");let e=new S.TransactionsFactoryConfig({chainID:W(this.config.env)}),r=new S.TransferTransactionsFactory({config:e}),n=S.Address.newFromBech32(this.config.userAddress),a=JSON.stringify(t);return r.createTransactionForNativeTokenTransfer(n,{receiver:S.Address.newFromBech32(this.config.userAddress),nativeAmount:BigInt(0),data:Uint8Array.from(Buffer.from(a))})}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=y.getConfiguredChainApi(this.config);try{let r=await e.getTransaction(t);return this.createFromTransaction(r)}catch(r){return console.error("BrandBuilder: Error creating from transaction hash",r),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.brandSchemaUrl||w.LatestBrandSchemaUrl,n=await(await fetch(e)).json(),a=new rt.default,o=a.compile(n);if(!o(t))throw new Error(`BrandBuilder: schema validation failed: ${a.errorsText(o.errors)}`)}};var c=require("@multiversx/sdk-core/out"),Tt=(s,t)=>s?c.OptionValue.newProvided(s):t?c.OptionValue.newMissingTyped(t):c.OptionValue.newMissing(),Wt=(s,t)=>s?new c.OptionalValue(s.getType(),s):t?new c.OptionalValue(t):c.OptionalValue.newMissing(),At=s=>{if(s.length===0)throw new Error("Cannot create a list from an empty array");let t=s[0].getType();return new c.List(t,s)},Ct=s=>c.VariadicValue.fromItems(...s),bt=s=>{let t=s.map(e=>e.getType());return new c.CompositeValue(new c.CompositeType(...t),s)},It=s=>c.StringValue.fromUTF8(s),Bt=s=>new c.U8Value(s),vt=s=>new c.U16Value(s),St=s=>new c.U32Value(s),xt=s=>new c.U64Value(s),Vt=s=>new c.BigUIntValue(BigInt(s)),Pt=s=>new c.BooleanValue(s),Rt=s=>new c.AddressValue(c.Address.newFromBech32(s)),Ut=s=>new c.TokenIdentifierValue(s),Et=s=>c.BytesValue.fromHex(s),Ft=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")]),kt=s=>new c.CodeMetadataValue(c.CodeMetadata.newFromBytes(Uint8Array.from(Buffer.from(s,"hex")))),Nt=()=>new c.NothingValue;var V=require("@multiversx/sdk-core");var N=class{constructor(t){this.cache=new A;this.config=t}createInscriptionTransaction(t){if(!this.config.userAddress)throw new Error("WarpBuilder: user address not set");let e=new V.TransactionsFactoryConfig({chainID:W(this.config.env)}),r=new V.TransferTransactionsFactory({config:e}),n={protocol:B("abi"),content:t},a=V.Address.newFromBech32(this.config.userAddress),o=JSON.stringify(n),p=r.createTransactionForTransfer(a,{receiver:a,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=C.WarpAbi(t);if(e){let a=this.cache.get(r);if(a)return console.log(`WarpAbiBuilder (createFromTransactionHash): Warp abi found in cache: ${t}`),a}let n=y.getConfiguredChainApi(this.config);try{let a=await n.getTransaction(t),o=await this.createFromTransaction(a);return e&&e.ttl&&o&&this.cache.set(r,o,e.ttl),o}catch(a){return console.error("WarpAbiBuilder: Error creating from transaction hash",a),null}}};var m=require("@multiversx/sdk-core");var $t=[{id:"EGLD",name:"eGold",decimals:18},{id:"EGLD-000000",name:"eGold",decimals:18}],nt=s=>$t.find(t=>t.id===s)||null;var i=require("@multiversx/sdk-core/out");var it=new RegExp(`${d.ArgParamsSeparator}(.*)`),$=class{nativeToString(t,e){return t==="esdt"&&e instanceof i.TokenTransfer?`esdt:${e.token.identifier}|${e.token.nonce.toString()}|${e.amount.toString()}`:`${t}:${e?.toString()??""}`}typedToString(t){if(t.hasClassOrSuperclass(i.OptionValue.ClassName))return t.isSet()?`option:${this.typedToString(t.getTypedValue())}`:"option:null";if(t.hasClassOrSuperclass(i.OptionalValue.ClassName))return t.isSet()?`optional:${this.typedToString(t.getTypedValue())}`:"optional:null";if(t.hasClassOrSuperclass(i.List.ClassName)){let e=t.getItems(),n=e.map(o=>this.typedToString(o).split(d.ArgParamsSeparator)[0])[0],a=e.map(o=>this.typedToString(o).split(d.ArgParamsSeparator)[1]);return`list:${n}:${a.join(",")}`}if(t.hasClassOrSuperclass(i.VariadicValue.ClassName)){let e=t.getItems(),n=e.map(o=>this.typedToString(o).split(d.ArgParamsSeparator)[0])[0],a=e.map(o=>this.typedToString(o).split(d.ArgParamsSeparator)[1]);return`variadic:${n}:${a.join(",")}`}if(t.hasClassOrSuperclass(i.CompositeValue.ClassName)){let e=t.getItems(),r=e.map(p=>this.typedToString(p).split(d.ArgParamsSeparator)[0]),n=e.map(p=>this.typedToString(p).split(d.ArgParamsSeparator)[1]),a=r.join(d.ArgCompositeSeparator),o=n.join(d.ArgCompositeSeparator);return`composite(${a}):${o}`}if(t.hasClassOrSuperclass(i.BigUIntValue.ClassName)||t.getType().getName()==="BigUint")return`biguint:${BigInt(t.valueOf().toFixed())}`;if(t.hasClassOrSuperclass(i.U8Value.ClassName))return`uint8:${t.valueOf().toNumber()}`;if(t.hasClassOrSuperclass(i.U16Value.ClassName))return`uint16:${t.valueOf().toNumber()}`;if(t.hasClassOrSuperclass(i.U32Value.ClassName))return`uint32:${t.valueOf().toNumber()}`;if(t.hasClassOrSuperclass(i.U64Value.ClassName))return`uint64:${BigInt(t.valueOf().toFixed())}`;if(t.hasClassOrSuperclass(i.StringValue.ClassName))return`string:${t.valueOf()}`;if(t.hasClassOrSuperclass(i.BooleanValue.ClassName))return`bool:${t.valueOf()}`;if(t.hasClassOrSuperclass(i.AddressValue.ClassName))return`address:${t.valueOf().bech32()}`;if(t.hasClassOrSuperclass(i.TokenIdentifierValue.ClassName))return`token:${t.valueOf()}`;if(t.hasClassOrSuperclass(i.BytesValue.ClassName))return`hex:${t.valueOf().toString("hex")}`;if(t.hasClassOrSuperclass(i.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 i.CompositeType(...e.split(d.ArgCompositeSeparator).map(r=>this.nativeToType(r)))}if(t==="string")return new i.StringType;if(t==="uint8")return new i.U8Type;if(t==="uint16")return new i.U16Type;if(t==="uint32")return new i.U32Type;if(t==="uint64")return new i.U64Type;if(t==="biguint")return new i.BigUIntType;if(t==="bool")return new i.BooleanType;if(t==="address")return new i.AddressType;if(t==="token")return new i.TokenIdentifierType;if(t==="hex")return new i.BytesType;if(t==="codemeta")return new i.CodeMetadataType;if(t==="esdt"||t==="nft")return new i.StructType("EsdtTokenPayment",[new i.FieldDefinition("token_identifier","",new i.TokenIdentifierType),new i.FieldDefinition("token_nonce","",new i.U64Type),new i.FieldDefinition("amount","",new i.BigUIntType)]);throw new Error(`WarpArgSerializer (nativeToType): Unsupported input type: ${t}`)}stringToNative(t){let e=t.split(d.ArgParamsSeparator),r=e[0],n=e.slice(1).join(d.ArgParamsSeparator);if(r==="null")return[r,null];if(r==="option"){let[a,o]=n.split(d.ArgParamsSeparator);return[`option:${a}`,o||null]}else if(r==="optional"){let[a,o]=n.split(d.ArgParamsSeparator);return[`optional:${a}`,o||null]}else if(r==="list"){let a=n.split(d.ArgParamsSeparator),o=a.slice(0,-1).join(d.ArgParamsSeparator),p=a[a.length-1],l=(p?p.split(","):[]).map(f=>this.stringToNative(`${o}:${f}`)[1]);return[`list:${o}`,l]}else if(r==="variadic"){let a=n.split(d.ArgParamsSeparator),o=a.slice(0,-1).join(d.ArgParamsSeparator),p=a[a.length-1],l=(p?p.split(","):[]).map(f=>this.stringToNative(`${o}:${f}`)[1]);return[`variadic:${o}`,l]}else if(r.startsWith("composite")){let a=r.match(/\(([^)]+)\)/)?.[1]?.split(d.ArgCompositeSeparator),p=n.split(d.ArgCompositeSeparator).map((u,l)=>this.stringToNative(`${a[l]}:${u}`)[1]);return[r,p]}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,o,p]=n.split(d.ArgCompositeSeparator);return[r,new i.TokenTransfer({token:new i.Token({identifier:a,nonce:BigInt(o)}),amount:BigInt(p)})]}}throw new Error(`WarpArgSerializer (stringToNative): Unsupported input type: ${r}`)}stringToTyped(t){let[e,r]=t.split(/:(.*)/,2);if(e==="null"||e===null)return new i.NothingValue;if(e==="option"){let n=this.stringToTyped(r);return n instanceof i.NothingValue?i.OptionValue.newMissingTyped(n.getType()):i.OptionValue.newProvided(n)}if(e==="optional"){let n=this.stringToTyped(r);return n instanceof i.NothingValue?i.OptionalValue.newMissing():new i.OptionalValue(n.getType(),n)}if(e==="list"){let[n,a]=r.split(it,2),p=a.split(",").map(u=>this.stringToTyped(`${n}:${u}`));return new i.List(this.nativeToType(n),p)}if(e==="variadic"){let[n,a]=r.split(it,2),p=a.split(",").map(u=>this.stringToTyped(`${n}:${u}`));return new i.VariadicValue(new i.VariadicType(this.nativeToType(n)),p)}if(e.startsWith("composite")){let n=e.match(/\(([^)]+)\)/)?.[1],a=r.split(d.ArgCompositeSeparator),o=n.split(d.ArgCompositeSeparator),p=a.map((l,f)=>this.stringToTyped(`${o[f]}:${l}`)),u=p.map(l=>l.getType());return new i.CompositeValue(new i.CompositeType(...u),p)}if(e==="string")return r?i.StringValue.fromUTF8(r):new i.NothingValue;if(e==="uint8")return r?new i.U8Value(Number(r)):new i.NothingValue;if(e==="uint16")return r?new i.U16Value(Number(r)):new i.NothingValue;if(e==="uint32")return r?new i.U32Value(Number(r)):new i.NothingValue;if(e==="uint64")return r?new i.U64Value(BigInt(r)):new i.NothingValue;if(e==="biguint")return r?new i.BigUIntValue(BigInt(r)):new i.NothingValue;if(e==="bool")return r?new i.BooleanValue(typeof r=="boolean"?r:r==="true"):new i.NothingValue;if(e==="address")return r?new i.AddressValue(i.Address.newFromBech32(r)):new i.NothingValue;if(e==="token")return r?new i.TokenIdentifierValue(r):new i.NothingValue;if(e==="hex")return r?i.BytesValue.fromHex(r):new i.NothingValue;if(e==="codemeta")return new i.CodeMetadataValue(i.CodeMetadata.newFromBytes(Uint8Array.from(Buffer.from(r,"hex"))));if(e==="esdt"){let n=r.split(d.ArgCompositeSeparator);return new i.Struct(this.nativeToType("esdt"),[new i.Field(new i.TokenIdentifierValue(n[0]),"token_identifier"),new i.Field(new i.U64Value(BigInt(n[1])),"token_nonce"),new i.Field(new i.BigUIntValue(BigInt(n[2])),"amount")])}throw new Error(`WarpArgSerializer (stringToTyped): Unsupported input type: ${e}`)}typeToString(t){if(t instanceof i.OptionType)return"option:"+this.typeToString(t.getFirstTypeParameter());if(t instanceof i.OptionalType)return"optional:"+this.typeToString(t.getFirstTypeParameter());if(t instanceof i.ListType)return"list:"+this.typeToString(t.getFirstTypeParameter());if(t instanceof i.VariadicType)return"variadic:"+this.typeToString(t.getFirstTypeParameter());if(t instanceof i.StringType)return"string";if(t instanceof i.U8Type)return"uint8";if(t instanceof i.U16Type)return"uint16";if(t instanceof i.U32Type)return"uint32";if(t instanceof i.U64Type)return"uint64";if(t instanceof i.BigUIntType)return"biguint";if(t instanceof i.BooleanType)return"bool";if(t instanceof i.AddressType)return"address";if(t instanceof i.TokenIdentifierType)return"token";if(t instanceof i.BytesType)return"hex";if(t instanceof i.CodeMetadataType)return"codemeta";if(t instanceof i.StructType&&t.getClassName()==="EsdtTokenPayment")return"esdt";throw new Error(`WarpArgSerializer (typeToString): Unsupported input type: ${t.getClassName()}`)}};var O=class{constructor(t){this.config=t}async getContract(t){try{let r=await y.getConfiguredChainApi(this.config).doGetGeneric(`accounts/${t}/verification`);return{address:t,owner:r.ownerAddress,verified:r.isVerified}}catch(e){return console.error("WarpContractLoader: getContract error",e),null}}async getVerificationInfo(t){try{let r=await y.getConfiguredChainApi(this.config).doGetGeneric(`accounts/${t}/verification`);return{codeHash:r.codeHash,abi:r.source.abi}}catch(e){return console.error("WarpContractLoader: getVerificationInfo error",e),null}}};var M=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 $,this.contractLoader=new O(t)}async createTransactionForExecute(t,e){if(!this.config.userAddress)throw new Error("WarpActionExecutor: user address not set");let r=m.Address.newFromBech32(this.config.userAddress),n=new m.TransactionsFactoryConfig({chainID:W(this.config.env)}),{destination:a,args:o,value:p,transfers:u,data:l}=await this.getTxComponentsFromInputs(t,e,r),f=o.map(h=>this.serializer.stringToTyped(h));if(t.type==="transfer")return new m.TransferTransactionsFactory({config:n}).createTransactionForTransfer(r,{receiver:a,nativeAmount:p,tokenTransfers:u,data:l?new Uint8Array(l):void 0});if(t.type==="contract"&&a.isSmartContract())return new m.SmartContractTransactionsFactory({config:n}).createTransactionForExecute(r,{contract:a,function:"func"in t&&t.func||"",gasLimit:"gasLimit"in t?BigInt(t.gasLimit||0):0n,arguments:f,tokenTransfers:u,nativeTransferAmount:p});throw t.type==="query"?new Error("WarpActionExecutor: Invalid action type for createTransactionForExecute; Use executeQuery instead"):t.type==="collect"?new Error("WarpActionExecutor: Invalid action type for createTransactionForExecute; Use executeCollect instead"):new Error("WarpActionExecutor: Invalid action type")}async executeQuery(t,e){if(!this.config.chainApiUrl)throw new Error("WarpActionExecutor: Chain API URL not set");if(!t.func)throw new Error("WarpActionExecutor: Function not found");let r=await this.getAbiForAction(t),{args:n}=await this.getTxComponentsFromInputs(t,e),a=n.map(P=>this.serializer.stringToTyped(P)),o=y.getChainEntrypoint(this.config),p=m.Address.newFromBech32(t.address),u=o.createSmartContractController(r),l=u.createQuery({contract:p,function:t.func,arguments:a}),f=await u.runQuery(l);if(!(f.returnCode==="ok"))throw new Error(`WarpActionExecutor: Query failed with return code ${f.returnCode}`);let L=new m.ArgSerializer,D=r.getEndpoint(f.function),_=f.returnDataParts.map(P=>Buffer.from(P));return L.buffersToValues(_,D.output)[0]}async executeCollect(t,e,r){let n=new Headers;n.set("Content-Type","application/json"),n.set("Accept","application/json"),Object.entries(t.destination.headers).forEach(([a,o])=>{n.set(a,o)}),await fetch(t.destination.url,{method:t.destination.method,headers:n,body:JSON.stringify({inputs:e,meta:r})})}async getTxComponentsFromInputs(t,e,r){let n=await this.getResolvedInputs(t,e),a=this.getModifiedInputs(n),o=a.find(T=>T.input.position==="receiver")?.value,p="address"in t?t.address:null,u=o?.split(":")[1]||p||r?.toBech32();if(!u)throw new Error("WarpActionExecutor: Destination/Receiver not provided");let l=m.Address.newFromBech32(u),f=this.getPreparedArgs(t,a),h=a.find(T=>T.input.position==="value")?.value||null,L="value"in t?t.value:null,D=BigInt(h?.split(":")[1]||L||0),_=a.filter(T=>T.input.position==="transfer"&&T.value).map(T=>T.value),P=[...("transfers"in t?t.transfers:[])?.map(this.toTypedTransfer)||[],..._?.map(T=>this.serializer.stringToNative(T)[1])||[]],st=a.find(T=>T.input.position==="data")?.value,ot="data"in t?t.data||"":null,K=st||ot||null,J=K?this.serializer.stringToTyped(K).valueOf():null,ct=J?Buffer.from(J):null;return{destination:l,args:f,value:D,transfers:P,data:ct}}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(u=>u.input.name===n)?.value?.split(":")[1]);if(!a)throw new Error(`WarpActionExecutor: Exponent value not found for input ${n}`);let o=e.value?.split(":")[1];if(!o)throw new Error("WarpActionExecutor: Scalable value not found");let p=U(o,+a);return{...e,value:`${e.input.type}:${p}`}}else{let a=e.value?.split(":")[1];if(!a)throw new Error("WarpActionExecutor: Scalable value not found");let o=U(a,+n);return{...e,value:`${e.input.type}:${o}`}}}else return e})}async getResolvedInputs(t,e){let r=t.inputs||[],n=await Promise.all(e.map(o=>this.preprocessInput(o))),a=(o,p)=>o.source==="query"?this.serializer.nativeToString(o.type,this.url.searchParams.get(o.name)||""):n[p]||null;return r.map((o,p)=>({input:o,value:a(o,p)}))}async preprocessInput(t){try{let[e,r]=this.serializer.stringToNative(t);if(e==="esdt"){let[,,,n]=t.split(d.ArgCompositeSeparator);if(n)return t;let a=r;if(!new m.TokenComputer().isFungible(a.token))return t;let u=nt(a.token.identifier)?.decimals;if(!u){let f=this.config.chainApiUrl||w.Chain.ApiUrl(this.config.env);u=(await(await fetch(`${f}/tokens/${a.token.identifier}`)).json()).decimals}if(!u)throw new Error(`WarpActionExecutor: Decimals not found for token ${a.token.identifier}`);let l=new m.TokenTransfer({token:a.token,amount:U(a.amount,u)});return this.serializer.nativeToString(e,l)+d.ArgCompositeSeparator+u}return t}catch{return t}}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 o=Number(n.position.split(":")[1])-1;r.splice(o,0,a)}),r}async getAbiForAction(t){if(t.abi)return await this.fetchAbi(t);let e=await this.contractLoader.getVerificationInfo(t.address);if(!e)throw new Error("WarpActionExecutor: Verification info not found");return m.AbiRegistry.create(e.abi)}async fetchAbi(t){if(!t.abi)throw new Error("WarpActionExecutor: ABI not found");if(t.abi.startsWith(d.IdentifierType.Hash)){let e=new N(this.config),r=t.abi.split(d.IdentifierParamSeparator)[1],n=await e.createFromTransactionHash(r);if(!n)throw new Error(`WarpActionExecutor: ABI not found for hash: ${t.abi}`);return m.AbiRegistry.create(n.content)}else{let r=await(await fetch(t.abi)).json();return m.AbiRegistry.create(r)}}toTypedTransfer(t){return new m.TokenTransfer({token:new m.Token({identifier:t.token,nonce:BigInt(t.nonce||0)}),amount:BigInt(t.amount||0)})}};var G=class{constructor(t){this.config=t}async search(t,e,r){if(!this.config.indexUrl)throw new Error("WarpIndex: Index URL is not set");try{let n=await fetch(this.config.indexUrl,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${this.config.indexApiKey}`,...r},body:JSON.stringify({[this.config.indexSearchParamName||"search"]:t,...e})});if(!n.ok)throw new Error(`WarpIndex: search failed with status ${n.status}`);return(await n.json()).hits}catch(n){throw console.error("WarpIndex: Error searching for warps: ",n),n}}};0&&(module.exports={BrandBuilder,CacheKey,Config,WarpAbiBuilder,WarpActionExecutor,WarpArgSerializer,WarpBuilder,WarpCache,WarpConstants,WarpContractLoader,WarpIndex,WarpLink,WarpProtocolVersions,WarpRegistry,WarpUtils,WarpValidator,address,biguint,boolean,codemeta,composite,esdt,getChainId,getLatestProtocolIdentifier,getWarpActionByIndex,hex,list,nothing,option,optional,shiftBigintBy,string,toPreviewText,toTypedRegistryInfo,token,u16,u32,u64,u8,variadic});
1
+ "use strict";var gt=Object.create;var j=Object.defineProperty;var ft=Object.getOwnPropertyDescriptor;var mt=Object.getOwnPropertyNames;var ht=Object.getPrototypeOf,yt=Object.prototype.hasOwnProperty;var wt=(a,t)=>{for(var e in t)j(a,e,{get:t[e],enumerable:!0})},nt=(a,t,e,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of mt(t))!yt.call(a,n)&&n!==e&&j(a,n,{get:()=>t[n],enumerable:!(r=ft(t,n))||r.enumerable});return a};var M=(a,t,e)=>(e=a!=null?gt(ht(a)):{},nt(t||!a||!a.__esModule?j(e,"default",{value:a,enumerable:!0}):e,a)),Tt=a=>nt(j({},"__esModule",{value:!0}),a);var _t={};wt(_t,{BrandBuilder:()=>Z,CacheKey:()=>W,Config:()=>w,WarpAbiBuilder:()=>D,WarpActionExecutor:()=>X,WarpArgSerializer:()=>_,WarpBuilder:()=>L,WarpCache:()=>A,WarpConstants:()=>l,WarpContractLoader:()=>H,WarpIndex:()=>Y,WarpLink:()=>q,WarpProtocolVersions:()=>b,WarpRegistry:()=>S,WarpUtils:()=>y,WarpValidator:()=>P,address:()=>$t,biguint:()=>Et,boolean:()=>Ft,codemeta:()=>Lt,composite:()=>St,esdt:()=>Ot,getChainId:()=>C,getDefaultChainInfo:()=>F,getLatestProtocolIdentifier:()=>v,getWarpActionByIndex:()=>Ct,hex:()=>kt,list:()=>vt,nothing:()=>qt,option:()=>It,optional:()=>bt,shiftBigintBy:()=>N,string:()=>xt,toPreviewText:()=>G,toTypedChainInfo:()=>K,toTypedRegistryInfo:()=>$,token:()=>Nt,u16:()=>Pt,u32:()=>Rt,u64:()=>Ut,u8:()=>Vt,variadic:()=>Bt});module.exports=Tt(_t);var x=require("@multiversx/sdk-core"),ct=M(require("ajv"));var b={Warp:"1.1.0",Brand:"0.1.0",Abi:"0.1.0"},w={LatestWarpSchemaUrl:`https://raw.githubusercontent.com/vLeapGroup/warps-specs/refs/heads/main/schemas/v${b.Warp}.schema.json`,LatestBrandSchemaUrl:`https://raw.githubusercontent.com/vLeapGroup/warps-specs/refs/heads/main/schemas/brand/v${b.Brand}.schema.json`,DefaultClientUrl:a=>a==="devnet"?"https://devnet.usewarp.to":a==="testnet"?"https://testnet.usewarp.to":"https://usewarp.to",SuperClientUrls:["https://usewarp.to","https://testnet.usewarp.to","https://devnet.usewarp.to"],Chain:{ApiUrl:a=>a==="devnet"?"https://devnet-api.multiversx.com":a==="testnet"?"https://testnet-api.multiversx.com":"https://api.multiversx.com"},Registry:{Contract:a=>a==="devnet"?"erd1qqqqqqqqqqqqqpgqje2f99vr6r7sk54thg03c9suzcvwr4nfl3tsfkdl36":a==="testnet"?"####":"erd1qqqqqqqqqqqqqpgq3mrpj3u6q7tejv6d7eqhnyd27n9v5c5tl3ts08mffe"},AvailableActionInputSources:["field","query"],AvailableActionInputTypes:["string","uint8","uint16","uint32","uint64","biguint","boolean","address"],AvailableActionInputPositions:["value","arg:1","arg:2","arg:3","arg:4","arg:5","arg:6","arg:7","arg:8","arg:9","arg:10"]};var C=a=>a==="devnet"?"D":a==="testnet"?"T":"1",F=a=>({chainId:C(a.env),apiUrl:a.chainApiUrl||w.Chain.ApiUrl(a.env)}),v=a=>{if(a==="warp")return`warp:${b.Warp}`;if(a==="brand")return`brand:${b.Brand}`;if(a==="abi")return`abi:${b.Abi}`;throw new Error(`getLatestProtocolIdentifier: Invalid protocol name: ${a}`)},Ct=(a,t)=>a?.actions[t-1],$=a=>({hash:a.hash.toString("hex"),alias:a.alias?.toString()||null,trust:a.trust.toString(),creator:a.creator.toString(),createdAt:a.created_at.toNumber(),brand:a.brand?.toString("hex")||null,upgrade:a.upgrade?.toString("hex")||null}),K=a=>({chainId:a.chain_id.toString(),apiUrl:a.api_url.toString()}),N=(a,t)=>{let e=a.toString(),[r,n=""]=e.split("."),s=Math.abs(t);if(t>0)return BigInt(r+n.padEnd(s,"0"));if(t<0){let o=r+n;if(s>=o.length)return 0n;let c=o.slice(0,-s)||"0";return BigInt(c)}else return BigInt(a)},G=(a,t=100)=>{if(!a)return"";let e=a.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};var I=require("@multiversx/sdk-core");var l={HttpProtocolPrefix:"http",IdentifierParamName:"warp",IdentifierParamSeparator:":",IdentifierType:{Alias:"alias",Hash:"hash"},ArgParamsSeparator:":",ArgCompositeSeparator:"|",Egld:{Identifier:"EGLD",DisplayName:"eGold",Decimals:18}};var at=M(require("qr-code-styling"));var B=require("@multiversx/sdk-core");var k=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){try{let n={value:e,expiresAt:Date.now()+r*1e3};localStorage.setItem(this.getKey(t),JSON.stringify(n))}catch{}}clear(){try{for(let t=0;t<localStorage.length;t++){let e=localStorage.key(t);e?.startsWith(this.prefix)&&localStorage.removeItem(e)}}catch{}}};var O=class{constructor(){this.cache=new Map}get(t){let e=this.cache.get(t);return e?Date.now()>e.expiresAt?(this.cache.delete(t),null):e.value:null}set(t,e,r){let n=Date.now()+r*1e3;this.cache.set(t,{value:e,expiresAt:n})}clear(){this.cache.clear()}};var W={Warp:a=>`warp:${a}`,WarpAbi:a=>`warp-abi:${a}`,RegistryInfo:a=>`registry-info:${a}`,Brand:a=>`brand:${a}`,ChainInfo:a=>`chain:${a}`},A=class{constructor(t){this.strategy=this.selectStrategy(t)}selectStrategy(t){return t==="localStorage"?new k:t==="memory"?new O:typeof window<"u"&&window.localStorage?new k:new O}set(t,e,r){this.strategy.set(t,e,r)}get(t){return this.strategy.get(t)}clear(){this.strategy.clear()}};var it=M(require("ajv"));var P=class{constructor(t){this.config=t;this.config=t}async validate(t){this.ensureMaxOneValuePosition(t),await this.ensureValidSchema(t)}ensureMaxOneValuePosition(t){if(t.actions.filter(r=>"position"in r?r.position==="value":!1).length>1)throw new Error("WarpBuilder: only one value position action is allowed")}async ensureValidSchema(t){let e=this.config.warpSchemaUrl||w.LatestWarpSchemaUrl,n=await(await fetch(e)).json(),s=new it.default,o=s.compile(n);if(!o(t))throw new Error(`WarpBuilder: schema validation failed: ${s.errorsText(o.errors)}`)}};var L=class{constructor(t){this.pendingWarp={protocol:v("warp"),name:"",title:"",description:null,preview:"",actions:[]};this.config=t,this.cache=new A(t.cacheType)}createInscriptionTransaction(t){if(!this.config.userAddress)throw new Error("WarpBuilder: user address not set");let e=new B.TransactionsFactoryConfig({chainID:C(this.config.env)}),r=new B.TransferTransactionsFactory({config:e}),n=B.Address.newFromBech32(this.config.userAddress),s=JSON.stringify(t),o=r.createTransactionForTransfer(n,{receiver:B.Address.newFromBech32(this.config.userAddress),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 new P(this.config).validate(r),y.prepareVars(r,this.config)}async createFromTransaction(t,e=!1){let r=await this.createFromRaw(t.data.toString(),e);return r.meta={hash:t.hash,creator:t.sender.bech32(),createdAt:new Date(t.timestamp*1e3).toISOString()},r}async createFromTransactionHash(t,e){let r=W.Warp(t);if(e){let s=this.cache.get(r);if(s)return console.log(`WarpBuilder (createFromTransactionHash): Warp found in cache: ${t}`),s}let n=y.getConfiguredChainApi(this.config);try{let s=await n.getTransaction(t),o=await this.createFromTransaction(s);return e&&e.ttl&&o&&this.cache.set(r,o,e.ttl),o}catch(s){return console.error("WarpBuilder: Error creating from transaction hash",s),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 new P(this.config).validate(this.pendingWarp),this.pendingWarp}getDescriptionPreview(t,e=100){return G(t,e)}ensure(t,e){if(!t)throw new Error(`WarpBuilder: ${e}`)}};var g=require("@multiversx/sdk-core/out");var J={buildInfo:{rustc:{version:"1.80.0-nightly",commitHash:"791adf759cc065316f054961875052d5bc03e16c",commitDate:"2024-05-21",channel:"Nightly",short:"rustc 1.80.0-nightly (791adf759 2024-05-21)"},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:"verifyWarp",onlyOwner:!0,mutability:"mutable",inputs:[{name:"warp",type:"bytes"}],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:"getConfig",mutability:"readonly",inputs:[],outputs:[{type:"BigUint"}]},{name:"registerBrand",mutability:"mutable",payableInTokens:["EGLD"],inputs:[{name:"hash",type:"bytes"}],outputs:[]},{name:"brandWarp",mutability:"mutable",payableInTokens:["EGLD"],inputs:[{name:"warp",type:"bytes"},{name:"brand",type:"bytes"}],outputs:[]},{name:"getUserBrands",mutability:"readonly",inputs:[{name:"user",type:"Address"}],outputs:[{type:"variadic<bytes>",multi_result:!0}]}],events:[{identifier:"warpRegistered",inputs:[{name:"hash",type:"bytes",indexed:!0},{name:"alias",type:"bytes",indexed:!0}]},{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}]},{identifier:"warpVerified",inputs:[{name:"hash",type:"bytes",indexed:!0}]},{identifier:"aliasUpdated",inputs:[{name:"hash",type:"bytes",indexed:!0},{name:"alias",type:"bytes",indexed:!0}]}],esdtAttributes:[],hasCallback:!1,types:{InfoView:{type:"struct",fields:[{name:"hash",type:"bytes"},{name:"alias",type:"Option<bytes>"},{name:"trust",type:"bytes"},{name:"creator",type:"Address"},{name:"created_at",type:"u64"},{name:"brand",type:"Option<bytes>"},{name:"upgrade",type:"Option<bytes>"}]}}};var S=class{constructor(t){this.config=t,this.cache=new A(t.cacheType),this.unitPrice=BigInt(0)}async init(){await this.loadRegistryConfigs()}createWarpRegisterTransaction(t,e){if(this.unitPrice===BigInt(0))throw new Error("WarpRegistry: config not loaded. forgot to call init()?");if(!this.config.userAddress)throw new Error("WarpRegistry: user address not set");let r=g.Address.newFromBech32(this.config.userAddress),n=e?this.unitPrice*BigInt(2):this.unitPrice;return this.getFactory().createTransactionForExecute(r,{contract:this.getRegistryContractAddress(),function:"registerWarp",gasLimit:BigInt(1e7),nativeTransferAmount:n,arguments:e?[g.BytesValue.fromHex(t),g.BytesValue.fromUTF8(e)]:[g.BytesValue.fromHex(t)]})}createWarpUnregisterTransaction(t){if(!this.config.userAddress)throw new Error("WarpRegistry: user address not set");let e=g.Address.newFromBech32(this.config.userAddress);return this.getFactory().createTransactionForExecute(e,{contract:this.getRegistryContractAddress(),function:"unregisterWarp",gasLimit:BigInt(1e7),arguments:[g.BytesValue.fromHex(t)]})}createWarpUpgradeTransaction(t,e){if(this.unitPrice===BigInt(0))throw new Error("WarpRegistry: config not loaded. forgot to call init()?");if(!this.config.userAddress)throw new Error("WarpRegistry: user address not set");let r=g.Address.newFromBech32(this.config.userAddress);return this.getFactory().createTransactionForExecute(r,{contract:this.getRegistryContractAddress(),function:"upgradeWarp",gasLimit:BigInt(1e7),nativeTransferAmount:this.unitPrice,arguments:[g.BytesValue.fromUTF8(t),g.BytesValue.fromHex(e)]})}createWarpAliasSetTransaction(t,e){if(!this.config.userAddress)throw new Error("WarpRegistry: user address not set");let r=g.Address.newFromBech32(this.config.userAddress);return this.getFactory().createTransactionForExecute(r,{contract:this.getRegistryContractAddress(),function:"setWarpAlias",gasLimit:BigInt(1e7),nativeTransferAmount:this.unitPrice,arguments:[g.BytesValue.fromHex(t),g.BytesValue.fromUTF8(e)]})}createWarpVerifyTransaction(t){if(!this.config.userAddress)throw new Error("WarpRegistry: user address not set");let e=g.Address.newFromBech32(this.config.userAddress);return this.getFactory().createTransactionForExecute(e,{contract:this.getRegistryContractAddress(),function:"verifyWarp",gasLimit:BigInt(1e7),arguments:[g.BytesValue.fromHex(t)]})}createBrandRegisterTransaction(t){if(this.unitPrice===BigInt(0))throw new Error("WarpRegistry: config not loaded. forgot to call init()?");if(!this.config.userAddress)throw new Error("WarpRegistry: user address not set");let e=g.Address.newFromBech32(this.config.userAddress);return this.getFactory().createTransactionForExecute(e,{contract:this.getRegistryContractAddress(),function:"registerBrand",gasLimit:BigInt(1e7),nativeTransferAmount:this.unitPrice,arguments:[g.BytesValue.fromHex(t)]})}createWarpBrandingTransaction(t,e){if(!this.config.userAddress)throw new Error("WarpRegistry: user address not set");let r=g.Address.newFromBech32(this.config.userAddress);return this.getFactory().createTransactionForExecute(r,{contract:this.getRegistryContractAddress(),function:"brandWarp",gasLimit:BigInt(1e7),nativeTransferAmount:this.unitPrice,arguments:[g.BytesValue.fromHex(t),g.BytesValue.fromHex(e)]})}async getInfoByAlias(t,e){let r=W.RegistryInfo(t),n=e?this.cache.get(r):null;if(n)return console.log(`WarpRegistry (getInfoByAlias): RegistryInfo found in cache: ${t}`),n;let s=this.getRegistryContractAddress(),o=this.getController(),c=o.createQuery({contract:s,function:"getInfoByAlias",arguments:[g.BytesValue.fromUTF8(t)]}),d=await o.runQuery(c),[u]=o.parseQueryResponse(d),f=u?$(u):null,m=f?.brand?await this.fetchBrand(f.brand):null;return e&&e.ttl&&this.cache.set(r,{registryInfo:f,brand:m},e.ttl),{registryInfo:f,brand:m}}async getInfoByHash(t,e){let r=W.RegistryInfo(t);if(e){let m=this.cache.get(r);if(m)return console.log(`WarpRegistry (getInfoByHash): RegistryInfo found in cache: ${t}`),m}let n=this.getRegistryContractAddress(),s=this.getController(),o=s.createQuery({contract:n,function:"getInfoByHash",arguments:[g.BytesValue.fromHex(t)]}),c=await s.runQuery(o),[d]=s.parseQueryResponse(c),u=d?$(d):null,f=u?.brand?await this.fetchBrand(u.brand):null;return e&&e.ttl&&this.cache.set(r,{registryInfo:u,brand:f},e.ttl),{registryInfo:u,brand:f}}async getUserWarpRegistryInfos(t){let e=t||this.config.userAddress;if(!e)throw new Error("WarpRegistry: user address not set");let r=this.getRegistryContractAddress(),n=this.getController(),s=n.createQuery({contract:r,function:"getUserWarps",arguments:[new g.AddressValue(new g.Address(e))]}),o=await n.runQuery(s),[c]=n.parseQueryResponse(o);return c.map($)}async getUserBrands(t){let e=t||this.config.userAddress;if(!e)throw new Error("WarpRegistry: user address not set");let r=this.getRegistryContractAddress(),n=this.getController(),s=n.createQuery({contract:r,function:"getUserBrands",arguments:[new g.AddressValue(new g.Address(e))]}),o=await n.runQuery(s),[c]=n.parseQueryResponse(o),d=c.map(m=>m.toString("hex")),u={ttl:365*24*60*60};return(await Promise.all(d.map(m=>this.fetchBrand(m,u)))).filter(m=>m!==null)}async getChainInfo(t,e){let r=W.ChainInfo(t),n=e?this.cache.get(r):null;if(n)return console.log(`WarpRegistry (getChainInfo): ChainInfo found in cache: ${t}`),n;let s=this.getRegistryContractAddress(),o=this.getController(),c=o.createQuery({contract:s,function:"getChain",arguments:[g.BytesValue.fromUTF8(t)]}),d=await o.runQuery(c),[u]=o.parseQueryResponse(d),f=u?K(u):null;return f&&e?.ttl&&this.cache.set(r,f,e.ttl),f}async fetchBrand(t,e){let r=W.Brand(t),n=e?this.cache.get(r):null;if(n)return console.log(`WarpRegistry (fetchBrand): Brand found in cache: ${t}`),n;let s=y.getConfiguredChainApi(this.config);try{let o=await s.getTransaction(t),c=JSON.parse(o.data.toString());return c.meta={hash:o.hash,creator:o.sender.bech32(),createdAt:new Date(o.timestamp*1e3).toISOString()},e&&e.ttl&&this.cache.set(r,c,e.ttl),c}catch(o){return console.error("WarpRegistry: Error fetching brand from transaction hash",o),null}}getRegistryContractAddress(){return g.Address.newFromBech32(this.config.registryContract||w.Registry.Contract(this.config.env))}async loadRegistryConfigs(){let t=this.getRegistryContractAddress(),e=this.getController(),[r]=await e.query({contract:t,function:"getConfig",arguments:[]}),n=BigInt(r.toString());this.unitPrice=n}getFactory(){let t=new g.TransactionsFactoryConfig({chainID:C(this.config.env)}),e=g.AbiRegistry.create(J);return new g.SmartContractTransactionsFactory({config:t,abi:e})}getController(){let t=F(this.config),e=y.getChainEntrypoint(t,this.config.env),r=g.AbiRegistry.create(J);return e.createSmartContractController(r)}};var q=class{constructor(t){this.config=t;this.config=t}isValid(t){return t.startsWith(l.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)),o=(await Promise.all(n)).filter(u=>u.match),c=o.length>0,d=o.map(u=>({url:u.url,warp:u.warp}));return{match:c,results:d}}async detect(t){let e=t.startsWith(l.HttpProtocolPrefix)?this.extractIdentifierInfoFromUrl(t):y.getInfoFromPrefixedIdentifier(t);if(!e)return{match:!1,url:t,warp:null,registryInfo:null,brand:null};let{type:r,id:n}=e,s=new L(this.config),o=new S(this.config),c=null,d=null,u=null;if(r==="hash"){c=await s.createFromTransactionHash(n);try{let{registryInfo:f,brand:m}=await o.getInfoByHash(n);d=f,u=m}catch{}}else if(r==="alias"){let{registryInfo:f,brand:m}=await o.getInfoByAlias(n);d=f,u=m,f&&(c=await s.createFromTransactionHash(f.hash))}return c?{match:!0,url:t,warp:c,registryInfo:d,brand:u}:{match:!1,url:t,warp:null,registryInfo:null,brand:null}}build(t,e){let r=this.config.clientUrl||w.DefaultClientUrl(this.config.env),n=t===l.IdentifierType.Alias?encodeURIComponent(e):encodeURIComponent(t+l.IdentifierParamSeparator+e);return w.SuperClientUrls.includes(r)?`${r}/${n}`:`${r}?${l.IdentifierParamName}=${n}`}generateQrCode(t,e,r=512,n="white",s="black",o="#23F7DD"){let c=this.build(t,e);return new at.default({type:"svg",width:r,height:r,data:String(c),margin:16,qrOptions:{typeNumber:0,mode:"Byte",errorCorrectionLevel:"Q"},backgroundOptions:{color:n},dotsOptions:{type:"extra-rounded",color:s},cornersSquareOptions:{type:"extra-rounded",color:s},cornersDotOptions:{type:"square",color:s},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(o)}" 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=w.SuperClientUrls.includes(e.origin),n=e.searchParams.get(l.IdentifierParamName),s=r&&!n?e.pathname.split("/")[1]:n;if(!s)return null;let o=decodeURIComponent(s);return y.getInfoFromPrefixedIdentifier(o)}};var At="https://",st="query",ot="env",y=class a{static prepareVars(t,e){if(!t?.vars)return t;let r=JSON.stringify(t),n=(s,o)=>{r=r.replace(new RegExp(`{{${s.toUpperCase()}}}`,"g"),o.toString())};return Object.entries(t.vars).forEach(([s,o])=>{if(typeof o=="string"&&o.startsWith(`${st}:`)){if(!e.currentUrl)throw new Error("WarpUtils: currentUrl config is required to prepare vars");let c=o.split(`${st}:`)[1],d=new URL(e.currentUrl).searchParams.get(c);d&&n(s,d)}else if(typeof o=="string"&&o.startsWith(`${ot}:`)){let c=o.split(`${ot}:`)[1],d=e.vars?.[c];d&&n(s,d)}else n(s,o)}),JSON.parse(r)}static getInfoFromPrefixedIdentifier(t){let e=decodeURIComponent(t),r=e.includes(l.IdentifierParamSeparator)?e:`${l.IdentifierType.Alias}${l.IdentifierParamSeparator}${e}`,[n,s]=r.split(l.IdentifierParamSeparator);return{type:n,id:s}}static getNextStepUrl(t,e){if(!t?.next)return null;if(t.next.startsWith(At))return t.next;{let r=new q(e),n=a.getInfoFromPrefixedIdentifier(t.next);return n?r.build(n.type,n.id):null}}static getChainEntrypoint(t,e){let r="warp-sdk",n="api";return e==="devnet"?new I.DevnetEntrypoint(t.apiUrl,n,r):e==="testnet"?new I.TestnetEntrypoint(t.apiUrl,n,r):new I.MainnetEntrypoint(t.apiUrl,n,r)}static getConfiguredChainApi(t){let e=t.chainApiUrl||w.Chain.ApiUrl(t.env);if(!e)throw new Error("WarpUtils: Chain API URL not configured");return new I.ApiNetworkProvider(e,{timeout:3e4,clientName:"warp-sdk"})}};var Z=class{constructor(t){this.pendingBrand={protocol:v("brand"),name:"",description:"",logo:""};this.config=t}createInscriptionTransaction(t){if(!this.config.userAddress)throw new Error("BrandBuilder: user address not set");let e=new x.TransactionsFactoryConfig({chainID:C(this.config.env)}),r=new x.TransferTransactionsFactory({config:e}),n=x.Address.newFromBech32(this.config.userAddress),s=JSON.stringify(t);return r.createTransactionForNativeTokenTransfer(n,{receiver:x.Address.newFromBech32(this.config.userAddress),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=y.getConfiguredChainApi(this.config);try{let r=await e.getTransaction(t);return this.createFromTransaction(r)}catch(r){return console.error("BrandBuilder: Error creating from transaction hash",r),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.brandSchemaUrl||w.LatestBrandSchemaUrl,n=await(await fetch(e)).json(),s=new ct.default,o=s.compile(n);if(!o(t))throw new Error(`BrandBuilder: schema validation failed: ${s.errorsText(o.errors)}`)}};var p=require("@multiversx/sdk-core/out"),It=(a,t)=>a?p.OptionValue.newProvided(a):t?p.OptionValue.newMissingTyped(t):p.OptionValue.newMissing(),bt=(a,t)=>a?new p.OptionalValue(a.getType(),a):t?new p.OptionalValue(t):p.OptionalValue.newMissing(),vt=a=>{if(a.length===0)throw new Error("Cannot create a list from an empty array");let t=a[0].getType();return new p.List(t,a)},Bt=a=>p.VariadicValue.fromItems(...a),St=a=>{let t=a.map(e=>e.getType());return new p.CompositeValue(new p.CompositeType(...t),a)},xt=a=>p.StringValue.fromUTF8(a),Vt=a=>new p.U8Value(a),Pt=a=>new p.U16Value(a),Rt=a=>new p.U32Value(a),Ut=a=>new p.U64Value(a),Et=a=>new p.BigUIntValue(BigInt(a)),Ft=a=>new p.BooleanValue(a),$t=a=>new p.AddressValue(p.Address.newFromBech32(a)),Nt=a=>new p.TokenIdentifierValue(a),kt=a=>p.BytesValue.fromHex(a),Ot=a=>new p.Struct(new p.StructType("EsdtTokenPayment",[new p.FieldDefinition("token_identifier","",new p.TokenIdentifierType),new p.FieldDefinition("token_nonce","",new p.U64Type),new p.FieldDefinition("amount","",new p.BigUIntType)]),[new p.Field(new p.TokenIdentifierValue(a.token.identifier),"token_identifier"),new p.Field(new p.U64Value(BigInt(a.token.nonce)),"token_nonce"),new p.Field(new p.BigUIntValue(BigInt(a.amount)),"amount")]),Lt=a=>new p.CodeMetadataValue(p.CodeMetadata.newFromBytes(Uint8Array.from(Buffer.from(a,"hex")))),qt=()=>new p.NothingValue;var R=require("@multiversx/sdk-core");var D=class{constructor(t){this.cache=new A;this.config=t}createInscriptionTransaction(t){if(!this.config.userAddress)throw new Error("WarpBuilder: user address not set");let e=new R.TransactionsFactoryConfig({chainID:C(this.config.env)}),r=new R.TransferTransactionsFactory({config:e}),n={protocol:v("abi"),content:t},s=R.Address.newFromBech32(this.config.userAddress),o=JSON.stringify(n),c=r.createTransactionForTransfer(s,{receiver:s,nativeAmount:BigInt(0),data:Uint8Array.from(Buffer.from(o))});return c.gasLimit=c.gasLimit+BigInt(2e6),c}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=W.WarpAbi(t);if(e){let s=this.cache.get(r);if(s)return console.log(`WarpAbiBuilder (createFromTransactionHash): Warp abi found in cache: ${t}`),s}let n=y.getConfiguredChainApi(this.config);try{let s=await n.getTransaction(t),o=await this.createFromTransaction(s);return e&&e.ttl&&o&&this.cache.set(r,o,e.ttl),o}catch(s){return console.error("WarpAbiBuilder: Error creating from transaction hash",s),null}}};var h=require("@multiversx/sdk-core");var Dt=[{id:"EGLD",name:"eGold",decimals:18},{id:"EGLD-000000",name:"eGold",decimals:18}],pt=a=>Dt.find(t=>t.id===a)||null;var i=require("@multiversx/sdk-core/out");var ut=new RegExp(`${l.ArgParamsSeparator}(.*)`),_=class{nativeToString(t,e){return t==="esdt"&&e instanceof i.TokenTransfer?`esdt:${e.token.identifier}|${e.token.nonce.toString()}|${e.amount.toString()}`:`${t}:${e?.toString()??""}`}typedToString(t){if(t.hasClassOrSuperclass(i.OptionValue.ClassName))return t.isSet()?`option:${this.typedToString(t.getTypedValue())}`:"option:null";if(t.hasClassOrSuperclass(i.OptionalValue.ClassName))return t.isSet()?`optional:${this.typedToString(t.getTypedValue())}`:"optional:null";if(t.hasClassOrSuperclass(i.List.ClassName)){let e=t.getItems(),n=e.map(o=>this.typedToString(o).split(l.ArgParamsSeparator)[0])[0],s=e.map(o=>this.typedToString(o).split(l.ArgParamsSeparator)[1]);return`list:${n}:${s.join(",")}`}if(t.hasClassOrSuperclass(i.VariadicValue.ClassName)){let e=t.getItems(),n=e.map(o=>this.typedToString(o).split(l.ArgParamsSeparator)[0])[0],s=e.map(o=>this.typedToString(o).split(l.ArgParamsSeparator)[1]);return`variadic:${n}:${s.join(",")}`}if(t.hasClassOrSuperclass(i.CompositeValue.ClassName)){let e=t.getItems(),r=e.map(c=>this.typedToString(c).split(l.ArgParamsSeparator)[0]),n=e.map(c=>this.typedToString(c).split(l.ArgParamsSeparator)[1]),s=r.join(l.ArgCompositeSeparator),o=n.join(l.ArgCompositeSeparator);return`composite(${s}):${o}`}if(t.hasClassOrSuperclass(i.BigUIntValue.ClassName)||t.getType().getName()==="BigUint")return`biguint:${BigInt(t.valueOf().toFixed())}`;if(t.hasClassOrSuperclass(i.U8Value.ClassName))return`uint8:${t.valueOf().toNumber()}`;if(t.hasClassOrSuperclass(i.U16Value.ClassName))return`uint16:${t.valueOf().toNumber()}`;if(t.hasClassOrSuperclass(i.U32Value.ClassName))return`uint32:${t.valueOf().toNumber()}`;if(t.hasClassOrSuperclass(i.U64Value.ClassName))return`uint64:${BigInt(t.valueOf().toFixed())}`;if(t.hasClassOrSuperclass(i.StringValue.ClassName))return`string:${t.valueOf()}`;if(t.hasClassOrSuperclass(i.BooleanValue.ClassName))return`bool:${t.valueOf()}`;if(t.hasClassOrSuperclass(i.AddressValue.ClassName))return`address:${t.valueOf().bech32()}`;if(t.hasClassOrSuperclass(i.TokenIdentifierValue.ClassName))return`token:${t.valueOf()}`;if(t.hasClassOrSuperclass(i.BytesValue.ClassName))return`hex:${t.valueOf().toString("hex")}`;if(t.hasClassOrSuperclass(i.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 i.CompositeType(...e.split(l.ArgCompositeSeparator).map(r=>this.nativeToType(r)))}if(t==="string")return new i.StringType;if(t==="uint8")return new i.U8Type;if(t==="uint16")return new i.U16Type;if(t==="uint32")return new i.U32Type;if(t==="uint64")return new i.U64Type;if(t==="biguint")return new i.BigUIntType;if(t==="bool")return new i.BooleanType;if(t==="address")return new i.AddressType;if(t==="token")return new i.TokenIdentifierType;if(t==="hex")return new i.BytesType;if(t==="codemeta")return new i.CodeMetadataType;if(t==="esdt"||t==="nft")return new i.StructType("EsdtTokenPayment",[new i.FieldDefinition("token_identifier","",new i.TokenIdentifierType),new i.FieldDefinition("token_nonce","",new i.U64Type),new i.FieldDefinition("amount","",new i.BigUIntType)]);throw new Error(`WarpArgSerializer (nativeToType): Unsupported input type: ${t}`)}stringToNative(t){let e=t.split(l.ArgParamsSeparator),r=e[0],n=e.slice(1).join(l.ArgParamsSeparator);if(r==="null")return[r,null];if(r==="option"){let[s,o]=n.split(l.ArgParamsSeparator);return[`option:${s}`,o||null]}else if(r==="optional"){let[s,o]=n.split(l.ArgParamsSeparator);return[`optional:${s}`,o||null]}else if(r==="list"){let s=n.split(l.ArgParamsSeparator),o=s.slice(0,-1).join(l.ArgParamsSeparator),c=s[s.length-1],u=(c?c.split(","):[]).map(f=>this.stringToNative(`${o}:${f}`)[1]);return[`list:${o}`,u]}else if(r==="variadic"){let s=n.split(l.ArgParamsSeparator),o=s.slice(0,-1).join(l.ArgParamsSeparator),c=s[s.length-1],u=(c?c.split(","):[]).map(f=>this.stringToNative(`${o}:${f}`)[1]);return[`variadic:${o}`,u]}else if(r.startsWith("composite")){let s=r.match(/\(([^)]+)\)/)?.[1]?.split(l.ArgCompositeSeparator),c=n.split(l.ArgCompositeSeparator).map((d,u)=>this.stringToNative(`${s[u]}:${d}`)[1]);return[r,c]}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[s,o,c]=n.split(l.ArgCompositeSeparator);return[r,new i.TokenTransfer({token:new i.Token({identifier:s,nonce:BigInt(o)}),amount:BigInt(c)})]}}throw new Error(`WarpArgSerializer (stringToNative): Unsupported input type: ${r}`)}stringToTyped(t){let[e,r]=t.split(/:(.*)/,2);if(e==="null"||e===null)return new i.NothingValue;if(e==="option"){let n=this.stringToTyped(r);return n instanceof i.NothingValue?i.OptionValue.newMissingTyped(n.getType()):i.OptionValue.newProvided(n)}if(e==="optional"){let n=this.stringToTyped(r);return n instanceof i.NothingValue?i.OptionalValue.newMissing():new i.OptionalValue(n.getType(),n)}if(e==="list"){let[n,s]=r.split(ut,2),c=s.split(",").map(d=>this.stringToTyped(`${n}:${d}`));return new i.List(this.nativeToType(n),c)}if(e==="variadic"){let[n,s]=r.split(ut,2),c=s.split(",").map(d=>this.stringToTyped(`${n}:${d}`));return new i.VariadicValue(new i.VariadicType(this.nativeToType(n)),c)}if(e.startsWith("composite")){let n=e.match(/\(([^)]+)\)/)?.[1],s=r.split(l.ArgCompositeSeparator),o=n.split(l.ArgCompositeSeparator),c=s.map((u,f)=>this.stringToTyped(`${o[f]}:${u}`)),d=c.map(u=>u.getType());return new i.CompositeValue(new i.CompositeType(...d),c)}if(e==="string")return r?i.StringValue.fromUTF8(r):new i.NothingValue;if(e==="uint8")return r?new i.U8Value(Number(r)):new i.NothingValue;if(e==="uint16")return r?new i.U16Value(Number(r)):new i.NothingValue;if(e==="uint32")return r?new i.U32Value(Number(r)):new i.NothingValue;if(e==="uint64")return r?new i.U64Value(BigInt(r)):new i.NothingValue;if(e==="biguint")return r?new i.BigUIntValue(BigInt(r)):new i.NothingValue;if(e==="bool")return r?new i.BooleanValue(typeof r=="boolean"?r:r==="true"):new i.NothingValue;if(e==="address")return r?new i.AddressValue(i.Address.newFromBech32(r)):new i.NothingValue;if(e==="token")return r?new i.TokenIdentifierValue(r):new i.NothingValue;if(e==="hex")return r?i.BytesValue.fromHex(r):new i.NothingValue;if(e==="codemeta")return new i.CodeMetadataValue(i.CodeMetadata.newFromBytes(Uint8Array.from(Buffer.from(r,"hex"))));if(e==="esdt"){let n=r.split(l.ArgCompositeSeparator);return new i.Struct(this.nativeToType("esdt"),[new i.Field(new i.TokenIdentifierValue(n[0]),"token_identifier"),new i.Field(new i.U64Value(BigInt(n[1])),"token_nonce"),new i.Field(new i.BigUIntValue(BigInt(n[2])),"amount")])}throw new Error(`WarpArgSerializer (stringToTyped): Unsupported input type: ${e}`)}typeToString(t){if(t instanceof i.OptionType)return"option:"+this.typeToString(t.getFirstTypeParameter());if(t instanceof i.OptionalType)return"optional:"+this.typeToString(t.getFirstTypeParameter());if(t instanceof i.ListType)return"list:"+this.typeToString(t.getFirstTypeParameter());if(t instanceof i.VariadicType)return"variadic:"+this.typeToString(t.getFirstTypeParameter());if(t instanceof i.StringType)return"string";if(t instanceof i.U8Type)return"uint8";if(t instanceof i.U16Type)return"uint16";if(t instanceof i.U32Type)return"uint32";if(t instanceof i.U64Type)return"uint64";if(t instanceof i.BigUIntType)return"biguint";if(t instanceof i.BooleanType)return"bool";if(t instanceof i.AddressType)return"address";if(t instanceof i.TokenIdentifierType)return"token";if(t instanceof i.BytesType)return"hex";if(t instanceof i.CodeMetadataType)return"codemeta";if(t instanceof i.StructType&&t.getClassName()==="EsdtTokenPayment")return"esdt";throw new Error(`WarpArgSerializer (typeToString): Unsupported input type: ${t.getClassName()}`)}};var H=class{constructor(t){this.config=t}async getContract(t){try{let r=await y.getConfiguredChainApi(this.config).doGetGeneric(`accounts/${t}/verification`);return{address:t,owner:r.ownerAddress,verified:r.isVerified}}catch(e){return console.error("WarpContractLoader: getContract error",e),null}}async getVerificationInfo(t){try{let r=await y.getConfiguredChainApi(this.config).doGetGeneric(`accounts/${t}/verification`);return{codeHash:r.codeHash,abi:r.source.abi}}catch(e){return console.error("WarpContractLoader: getVerificationInfo error",e),null}}};var X=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 _,this.contractLoader=new H(t),this.registry=new S(t)}async createTransactionForExecute(t,e){if(!this.config.userAddress)throw new Error("WarpActionExecutor: user address not set");let r=h.Address.newFromBech32(this.config.userAddress),n=await this.getChainInfoForAction(t),s=new h.TransactionsFactoryConfig({chainID:n.chainId}),{destination:o,args:c,value:d,transfers:u,data:f}=await this.getTxComponentsFromInputs(t,e,r),m=c.map(V=>this.serializer.stringToTyped(V));if(t.type==="transfer")return new h.TransferTransactionsFactory({config:s}).createTransactionForTransfer(r,{receiver:o,nativeAmount:d,tokenTransfers:u,data:f?new Uint8Array(f):void 0});if(t.type==="contract"&&o.isSmartContract())return new h.SmartContractTransactionsFactory({config:s}).createTransactionForExecute(r,{contract:o,function:"func"in t&&t.func||"",gasLimit:"gasLimit"in t?BigInt(t.gasLimit||0):0n,arguments:m,tokenTransfers:u,nativeTransferAmount:d});throw t.type==="query"?new Error("WarpActionExecutor: Invalid action type for createTransactionForExecute; Use executeQuery instead"):t.type==="collect"?new Error("WarpActionExecutor: Invalid action type for createTransactionForExecute; Use executeCollect instead"):new Error(`WarpActionExecutor: Invalid action type (${t.type})`)}async executeQuery(t,e){if(!t.func)throw new Error("WarpActionExecutor: Function not found");let r=await this.getChainInfoForAction(t),n=await this.getAbiForAction(t),{args:s}=await this.getTxComponentsFromInputs(t,e),o=s.map(E=>this.serializer.stringToTyped(E)),c=y.getChainEntrypoint(r,this.config.env),d=h.Address.newFromBech32(t.address),u=c.createSmartContractController(n),f=u.createQuery({contract:d,function:t.func,arguments:o}),m=await u.runQuery(f);if(!(m.returnCode==="ok"))throw new Error(`WarpActionExecutor: Query failed with return code ${m.returnCode}`);let U=new h.ArgSerializer,Q=n.getEndpoint(m.function),z=m.returnDataParts.map(E=>Buffer.from(E));return U.buffersToValues(z,Q.output)[0]}async executeCollect(t,e,r){let n=new Headers;n.set("Content-Type","application/json"),n.set("Accept","application/json"),Object.entries(t.destination.headers).forEach(([s,o])=>{n.set(s,o)}),await fetch(t.destination.url,{method:t.destination.method,headers:n,body:JSON.stringify({inputs:e,meta:r})})}async getTxComponentsFromInputs(t,e,r){let n=await this.getResolvedInputs(t,e),s=this.getModifiedInputs(n),o=s.find(T=>T.input.position==="receiver")?.value,c="address"in t?t.address:null,d=o?.split(":")[1]||c||r?.toBech32();if(!d)throw new Error("WarpActionExecutor: Destination/Receiver not provided");let u=h.Address.newFromBech32(d),f=this.getPreparedArgs(t,s),m=s.find(T=>T.input.position==="value")?.value||null,V="value"in t?t.value:null,U=BigInt(m?.split(":")[1]||V||0),Q=s.filter(T=>T.input.position==="transfer"&&T.value).map(T=>T.value),tt=[...("transfers"in t?t.transfers:[])?.map(this.toTypedTransfer)||[],...Q?.map(T=>this.serializer.stringToNative(T)[1])||[]],E=s.find(T=>T.input.position==="data")?.value,lt="data"in t?t.data||"":null,et=E||lt||null,rt=et?this.serializer.stringToTyped(et).valueOf():null,dt=rt?Buffer.from(rt):null;return{destination:u,args:f,value:U,transfers:tt,data:dt}}async getResolvedInputs(t,e){let r=t.inputs||[],n=await Promise.all(e.map(o=>this.preprocessInput(o))),s=(o,c)=>o.source==="query"?this.serializer.nativeToString(o.type,this.url.searchParams.get(o.name)||""):n[c]||null;return r.map((o,c)=>({input:o,value:s(o,c)}))}getModifiedInputs(t){return t.map((e,r)=>{if(e.input.modifier?.startsWith("scale:")){let[,n]=e.input.modifier.split(":");if(isNaN(Number(n))){let s=Number(t.find(d=>d.input.name===n)?.value?.split(":")[1]);if(!s)throw new Error(`WarpActionExecutor: Exponent value not found for input ${n}`);let o=e.value?.split(":")[1];if(!o)throw new Error("WarpActionExecutor: Scalable value not found");let c=N(o,+s);return{...e,value:`${e.input.type}:${c}`}}else{let s=e.value?.split(":")[1];if(!s)throw new Error("WarpActionExecutor: Scalable value not found");let o=N(s,+n);return{...e,value:`${e.input.type}:${o}`}}}else return e})}async preprocessInput(t){try{let[e,r]=t.split(l.ArgParamsSeparator,2);if(e==="esdt"){let[n,s,o,c]=r.split(l.ArgCompositeSeparator);if(c)return t;let d=new h.Token({identifier:n,nonce:BigInt(s)});if(!new h.TokenComputer().isFungible(d))return t;let m=pt(n)?.decimals;if(!m){let U=this.config.chainApiUrl||w.Chain.ApiUrl(this.config.env);m=(await(await fetch(`${U}/tokens/${n}`)).json()).decimals}if(!m)throw new Error(`WarpActionExecutor: Decimals not found for token ${n}`);let V=new h.TokenTransfer({token:d,amount:N(o,m)});return this.serializer.nativeToString(e,V)+l.ArgCompositeSeparator+m}return t}catch{return t}}getPreparedArgs(t,e){let r="args"in t?t.args||[]:[];return e.forEach(({input:n,value:s})=>{if(!s||!n.position.startsWith("arg:"))return;let o=Number(n.position.split(":")[1])-1;r.splice(o,0,s)}),r}async getChainInfoForAction(t){if(!t.chain)return F(this.config);let e=await this.registry.getChainInfo(t.chain);if(!e)throw new Error(`WarpActionExecutor: Chain info not found for ${t.chain}`);return e}async getAbiForAction(t){if(t.abi)return await this.fetchAbi(t);let e=await this.contractLoader.getVerificationInfo(t.address);if(!e)throw new Error("WarpActionExecutor: Verification info not found");return h.AbiRegistry.create(e.abi)}async fetchAbi(t){if(!t.abi)throw new Error("WarpActionExecutor: ABI not found");if(t.abi.startsWith(l.IdentifierType.Hash)){let e=new D(this.config),r=t.abi.split(l.IdentifierParamSeparator)[1],n=await e.createFromTransactionHash(r);if(!n)throw new Error(`WarpActionExecutor: ABI not found for hash: ${t.abi}`);return h.AbiRegistry.create(n.content)}else{let r=await(await fetch(t.abi)).json();return h.AbiRegistry.create(r)}}toTypedTransfer(t){return new h.TokenTransfer({token:new h.Token({identifier:t.token,nonce:BigInt(t.nonce||0)}),amount:BigInt(t.amount||0)})}};var Y=class{constructor(t){this.config=t}async search(t,e,r){if(!this.config.indexUrl)throw new Error("WarpIndex: Index URL is not set");try{let n=await fetch(this.config.indexUrl,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${this.config.indexApiKey}`,...r},body:JSON.stringify({[this.config.indexSearchParamName||"search"]:t,...e})});if(!n.ok)throw new Error(`WarpIndex: search failed with status ${n.status}`);return(await n.json()).hits}catch(n){throw console.error("WarpIndex: Error searching for warps: ",n),n}}};0&&(module.exports={BrandBuilder,CacheKey,Config,WarpAbiBuilder,WarpActionExecutor,WarpArgSerializer,WarpBuilder,WarpCache,WarpConstants,WarpContractLoader,WarpIndex,WarpLink,WarpProtocolVersions,WarpRegistry,WarpUtils,WarpValidator,address,biguint,boolean,codemeta,composite,esdt,getChainId,getDefaultChainInfo,getLatestProtocolIdentifier,getWarpActionByIndex,hex,list,nothing,option,optional,shiftBigintBy,string,toPreviewText,toTypedChainInfo,toTypedRegistryInfo,token,u16,u32,u64,u8,variadic});
package/dist/index.mjs CHANGED
@@ -1 +1 @@
1
- import{Address as ct,TransactionsFactoryConfig as ne,TransferTransactionsFactory as ie}from"@multiversx/sdk-core";import ae from"ajv";var C={Warp:"1.0.0",Brand:"0.1.0",Abi:"0.1.0"},f={LatestWarpSchemaUrl:`https://raw.githubusercontent.com/vLeapGroup/warps-specs/refs/heads/main/schemas/v${C.Warp}.schema.json`,LatestBrandSchemaUrl:`https://raw.githubusercontent.com/vLeapGroup/warps-specs/refs/heads/main/schemas/brand/v${C.Brand}.schema.json`,DefaultClientUrl:s=>s==="devnet"?"https://devnet.usewarp.to":s==="testnet"?"https://testnet.usewarp.to":"https://usewarp.to",SuperClientUrls:["https://usewarp.to","https://testnet.usewarp.to","https://devnet.usewarp.to"],Chain:{ApiUrl:s=>s==="devnet"?"https://devnet-api.multiversx.com":s==="testnet"?"https://testnet-api.multiversx.com":"https://api.multiversx.com"},Registry:{Contract:s=>s==="devnet"?"erd1qqqqqqqqqqqqqpgqje2f99vr6r7sk54thg03c9suzcvwr4nfl3tsfkdl36":s==="testnet"?"####":"erd1qqqqqqqqqqqqqpgq3mrpj3u6q7tejv6d7eqhnyd27n9v5c5tl3ts08mffe"},AvailableActionInputSources:["field","query"],AvailableActionInputTypes:["string","uint8","uint16","uint32","uint64","biguint","boolean","address"],AvailableActionInputPositions:["value","arg:1","arg:2","arg:3","arg:4","arg:5","arg:6","arg:7","arg:8","arg:9","arg:10"]};var w=s=>s==="devnet"?"D":s==="testnet"?"T":"1",b=s=>{if(s==="warp")return`warp:${C.Warp}`;if(s==="brand")return`brand:${C.Brand}`;if(s==="abi")return`abi:${C.Abi}`;throw new Error(`getLatestProtocolIdentifier: Invalid protocol name: ${s}`)},Qe=(s,t)=>s?.actions[t-1],S=s=>({hash:s.hash.toString("hex"),alias:s.alias?.toString()||null,trust:s.trust.toString(),creator:s.creator.toString(),createdAt:s.created_at.toNumber(),brand:s.brand?.toString("hex")||null,upgrade:s.upgrade?.toString("hex")||null}),x=(s,t)=>{let e=s.toString(),[r,n=""]=e.split("."),i=Math.abs(t);if(t>0)return BigInt(r+n.padEnd(i,"0"));if(t<0){let a=r+n;if(i>=a.length)return 0n;let o=a.slice(0,-i)||"0";return BigInt(o)}else return BigInt(s)},rt=(s,t=100)=>{if(!s)return"";let e=s.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};import{ApiNetworkProvider as Xt,DevnetEntrypoint as Yt,MainnetEntrypoint as te,TestnetEntrypoint as ee}from"@multiversx/sdk-core";var u={HttpProtocolPrefix:"http",IdentifierParamName:"warp",IdentifierParamSeparator:":",IdentifierType:{Alias:"alias",Hash:"hash"},ArgParamsSeparator:":",ArgCompositeSeparator:"|",Egld:{Identifier:"EGLD",DisplayName:"eGold",Decimals:18}};import Zt from"qr-code-styling";import{Address as nt,TransactionsFactoryConfig as zt,TransferTransactionsFactory as Mt}from"@multiversx/sdk-core";var A={Warp:s=>`warp:${s}`,WarpAbi:s=>`warp-abi:${s}`,RegistryInfo:s=>`registry-info:${s}`,Brand:s=>`brand:${s}`},W=class{constructor(){this.cache=new Map}set(t,e,r){let n=Date.now()+r*1e3;this.cache.set(t,{value:e,expiresAt:n})}get(t){let e=this.cache.get(t);return e?Date.now()>e.expiresAt?(this.cache.delete(t),null):e.value:null}clear(){this.cache.clear()}};import Qt from"ajv";var B=class{constructor(t){this.config=t;this.config=t}async validate(t){this.ensureMaxOneValuePosition(t),await this.ensureValidSchema(t)}ensureMaxOneValuePosition(t){if(t.actions.filter(r=>"position"in r?r.position==="value":!1).length>1)throw new Error("WarpBuilder: only one value position action is allowed")}async ensureValidSchema(t){let e=this.config.warpSchemaUrl||f.LatestWarpSchemaUrl,n=await(await fetch(e)).json(),i=new Qt,a=i.compile(n);if(!a(t))throw new Error(`WarpBuilder: schema validation failed: ${i.errorsText(a.errors)}`)}};var V=class{constructor(t){this.cache=new W;this.pendingWarp={protocol:b("warp"),name:"",title:"",description:null,preview:"",actions:[]};this.config=t}createInscriptionTransaction(t){if(!this.config.userAddress)throw new Error("WarpBuilder: user address not set");let e=new zt({chainID:w(this.config.env)}),r=new Mt({config:e}),n=nt.newFromBech32(this.config.userAddress),i=JSON.stringify(t),a=r.createTransactionForTransfer(n,{receiver:nt.newFromBech32(this.config.userAddress),nativeAmount:BigInt(0),data:Uint8Array.from(Buffer.from(i))});return a.gasLimit=a.gasLimit+BigInt(2e6),a}async createFromRaw(t,e=!0){let r=JSON.parse(t);return e&&await new B(this.config).validate(r),g.prepareVars(r,this.config)}async createFromTransaction(t,e=!1){let r=await this.createFromRaw(t.data.toString(),e);return r.meta={hash:t.hash,creator:t.sender.bech32(),createdAt:new Date(t.timestamp*1e3).toISOString()},r}async createFromTransactionHash(t,e){let r=A.Warp(t);if(e){let i=this.cache.get(r);if(i)return console.log(`WarpBuilder (createFromTransactionHash): Warp found in cache: ${t}`),i}let n=g.getConfiguredChainApi(this.config);try{let i=await n.getTransaction(t),a=await this.createFromTransaction(i);return e&&e.ttl&&a&&this.cache.set(r,a,e.ttl),a}catch(i){return console.error("WarpBuilder: Error creating from transaction hash",i),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 new B(this.config).validate(this.pendingWarp),this.pendingWarp}getDescriptionPreview(t,e=100){return rt(t,e)}ensure(t,e){if(!t)throw new Error(`WarpBuilder: ${e}`)}};import{AbiRegistry as it,Address as T,AddressValue as at,BytesValue as m,SmartContractTransactionsFactory as Kt,TransactionsFactoryConfig as Jt}from"@multiversx/sdk-core/out";var $={buildInfo:{rustc:{version:"1.80.0-nightly",commitHash:"791adf759cc065316f054961875052d5bc03e16c",commitDate:"2024-05-21",channel:"Nightly",short:"rustc 1.80.0-nightly (791adf759 2024-05-21)"},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:"verifyWarp",onlyOwner:!0,mutability:"mutable",inputs:[{name:"warp",type:"bytes"}],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:"getConfig",mutability:"readonly",inputs:[],outputs:[{type:"BigUint"}]},{name:"registerBrand",mutability:"mutable",payableInTokens:["EGLD"],inputs:[{name:"hash",type:"bytes"}],outputs:[]},{name:"brandWarp",mutability:"mutable",payableInTokens:["EGLD"],inputs:[{name:"warp",type:"bytes"},{name:"brand",type:"bytes"}],outputs:[]},{name:"getUserBrands",mutability:"readonly",inputs:[{name:"user",type:"Address"}],outputs:[{type:"variadic<bytes>",multi_result:!0}]}],events:[{identifier:"warpRegistered",inputs:[{name:"hash",type:"bytes",indexed:!0},{name:"alias",type:"bytes",indexed:!0}]},{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}]},{identifier:"warpVerified",inputs:[{name:"hash",type:"bytes",indexed:!0}]},{identifier:"aliasUpdated",inputs:[{name:"hash",type:"bytes",indexed:!0},{name:"alias",type:"bytes",indexed:!0}]}],esdtAttributes:[],hasCallback:!1,types:{InfoView:{type:"struct",fields:[{name:"hash",type:"bytes"},{name:"alias",type:"Option<bytes>"},{name:"trust",type:"bytes"},{name:"creator",type:"Address"},{name:"created_at",type:"u64"},{name:"brand",type:"Option<bytes>"},{name:"upgrade",type:"Option<bytes>"}]}}};var P=class{constructor(t){this.cache=new W;this.config=t,this.unitPrice=BigInt(0)}async init(){await this.loadRegistryConfigs()}createWarpRegisterTransaction(t,e){if(this.unitPrice===BigInt(0))throw new Error("WarpRegistry: config not loaded. forgot to call init()?");if(!this.config.userAddress)throw new Error("WarpRegistry: user address not set");let r=T.newFromBech32(this.config.userAddress),n=e?this.unitPrice*BigInt(2):this.unitPrice;return this.getFactory().createTransactionForExecute(r,{contract:this.getRegistryContractAddress(),function:"registerWarp",gasLimit:BigInt(1e7),nativeTransferAmount:n,arguments:e?[m.fromHex(t),m.fromUTF8(e)]:[m.fromHex(t)]})}createWarpUnregisterTransaction(t){if(!this.config.userAddress)throw new Error("WarpRegistry: user address not set");let e=T.newFromBech32(this.config.userAddress);return this.getFactory().createTransactionForExecute(e,{contract:this.getRegistryContractAddress(),function:"unregisterWarp",gasLimit:BigInt(1e7),arguments:[m.fromHex(t)]})}createWarpUpgradeTransaction(t,e){if(this.unitPrice===BigInt(0))throw new Error("WarpRegistry: config not loaded. forgot to call init()?");if(!this.config.userAddress)throw new Error("WarpRegistry: user address not set");let r=T.newFromBech32(this.config.userAddress);return this.getFactory().createTransactionForExecute(r,{contract:this.getRegistryContractAddress(),function:"upgradeWarp",gasLimit:BigInt(1e7),nativeTransferAmount:this.unitPrice,arguments:[m.fromUTF8(t),m.fromHex(e)]})}createWarpAliasSetTransaction(t,e){if(!this.config.userAddress)throw new Error("WarpRegistry: user address not set");let r=T.newFromBech32(this.config.userAddress);return this.getFactory().createTransactionForExecute(r,{contract:this.getRegistryContractAddress(),function:"setWarpAlias",gasLimit:BigInt(1e7),nativeTransferAmount:this.unitPrice,arguments:[m.fromHex(t),m.fromUTF8(e)]})}createWarpVerifyTransaction(t){if(!this.config.userAddress)throw new Error("WarpRegistry: user address not set");let e=T.newFromBech32(this.config.userAddress);return this.getFactory().createTransactionForExecute(e,{contract:this.getRegistryContractAddress(),function:"verifyWarp",gasLimit:BigInt(1e7),arguments:[m.fromHex(t)]})}createBrandRegisterTransaction(t){if(this.unitPrice===BigInt(0))throw new Error("WarpRegistry: config not loaded. forgot to call init()?");if(!this.config.userAddress)throw new Error("WarpRegistry: user address not set");let e=T.newFromBech32(this.config.userAddress);return this.getFactory().createTransactionForExecute(e,{contract:this.getRegistryContractAddress(),function:"registerBrand",gasLimit:BigInt(1e7),nativeTransferAmount:this.unitPrice,arguments:[m.fromHex(t)]})}createWarpBrandingTransaction(t,e){if(!this.config.userAddress)throw new Error("WarpRegistry: user address not set");let r=T.newFromBech32(this.config.userAddress);return this.getFactory().createTransactionForExecute(r,{contract:this.getRegistryContractAddress(),function:"brandWarp",gasLimit:BigInt(1e7),nativeTransferAmount:this.unitPrice,arguments:[m.fromHex(t),m.fromHex(e)]})}async getInfoByAlias(t,e){let r=A.RegistryInfo(t);if(e){let d=this.cache.get(r);if(d)return console.log(`WarpRegistry (getInfoByAlias): RegistryInfo found in cache: ${t}`),d}let n=this.getRegistryContractAddress(),i=this.getController(),a=i.createQuery({contract:n,function:"getInfoByAlias",arguments:[m.fromUTF8(t)]}),o=await i.runQuery(a),[c]=i.parseQueryResponse(o),p=c?S(c):null,l=p?.brand?await this.fetchBrand(p.brand):null;return e&&e.ttl&&this.cache.set(r,{registryInfo:p,brand:l},e.ttl),{registryInfo:p,brand:l}}async getInfoByHash(t,e){let r=A.RegistryInfo(t);if(e){let d=this.cache.get(r);if(d)return console.log(`WarpRegistry (getInfoByHash): RegistryInfo found in cache: ${t}`),d}let n=this.getRegistryContractAddress(),i=this.getController(),a=i.createQuery({contract:n,function:"getInfoByHash",arguments:[m.fromHex(t)]}),o=await i.runQuery(a),[c]=i.parseQueryResponse(o),p=c?S(c):null,l=p?.brand?await this.fetchBrand(p.brand):null;return e&&e.ttl&&this.cache.set(r,{registryInfo:p,brand:l},e.ttl),{registryInfo:p,brand:l}}async getUserWarpRegistryInfos(t){let e=t||this.config.userAddress;if(!e)throw new Error("WarpRegistry: user address not set");let r=this.getRegistryContractAddress(),n=this.getController(),i=n.createQuery({contract:r,function:"getUserWarps",arguments:[new at(new T(e))]}),a=await n.runQuery(i),[o]=n.parseQueryResponse(a);return o.map(S)}async getUserBrands(t){let e=t||this.config.userAddress;if(!e)throw new Error("WarpRegistry: user address not set");let r=this.getRegistryContractAddress(),n=this.getController(),i=n.createQuery({contract:r,function:"getUserBrands",arguments:[new at(new T(e))]}),a=await n.runQuery(i),[o]=n.parseQueryResponse(a),c=o.map(d=>d.toString("hex")),p={ttl:365*24*60*60};return(await Promise.all(c.map(d=>this.fetchBrand(d,p)))).filter(d=>d!==null)}async fetchBrand(t,e){let r=A.Brand(t);if(e){let i=this.cache.get(r);if(i)return console.log(`WarpRegistry (fetchBrand): Brand found in cache: ${t}`),i}let n=g.getConfiguredChainApi(this.config);try{let i=await n.getTransaction(t),a=JSON.parse(i.data.toString());return a.meta={hash:i.hash,creator:i.sender.bech32(),createdAt:new Date(i.timestamp*1e3).toISOString()},e&&e.ttl&&this.cache.set(r,a,e.ttl),a}catch(i){return console.error("WarpRegistry: Error fetching brand from transaction hash",i),null}}getRegistryContractAddress(){return T.newFromBech32(this.config.registryContract||f.Registry.Contract(this.config.env))}async loadRegistryConfigs(){let t=this.getRegistryContractAddress(),e=this.getController(),[r]=await e.query({contract:t,function:"getConfig",arguments:[]}),n=BigInt(r.toString());this.unitPrice=n}getFactory(){let t=new Jt({chainID:w(this.config.env)}),e=it.create($);return new Kt({config:t,abi:e})}getController(){let t=g.getChainEntrypoint(this.config),e=it.create($);return t.createSmartContractController(e)}};var R=class{constructor(t){this.config=t;this.config=t}isValid(t){return t.startsWith(u.HttpProtocolPrefix)?!!this.extractIdentifierInfoFromUrl(t):!1}async detectFromHtml(t){if(!t.length)return{match:!1,results:[]};let n=[...t.matchAll(/https?:\/\/[^\s"'<>]+/gi)].map(p=>p[0]).filter(p=>this.isValid(p)).map(p=>this.detect(p)),a=(await Promise.all(n)).filter(p=>p.match),o=a.length>0,c=a.map(p=>({url:p.url,warp:p.warp}));return{match:o,results:c}}async detect(t){let e=t.startsWith(u.HttpProtocolPrefix)?this.extractIdentifierInfoFromUrl(t):g.getInfoFromPrefixedIdentifier(t);if(!e)return{match:!1,url:t,warp:null,registryInfo:null,brand:null};let{type:r,id:n}=e,i=new V(this.config),a=new P(this.config),o=null,c=null,p=null;if(r==="hash"){o=await i.createFromTransactionHash(n);try{let{registryInfo:l,brand:d}=await a.getInfoByHash(n);c=l,p=d}catch{}}else if(r==="alias"){let{registryInfo:l,brand:d}=await a.getInfoByAlias(n);c=l,p=d,l&&(o=await i.createFromTransactionHash(l.hash))}return o?{match:!0,url:t,warp:o,registryInfo:c,brand:p}:{match:!1,url:t,warp:null,registryInfo:null,brand:null}}build(t,e){let r=this.config.clientUrl||f.DefaultClientUrl(this.config.env),n=t===u.IdentifierType.Alias?encodeURIComponent(e):encodeURIComponent(t+u.IdentifierParamSeparator+e);return f.SuperClientUrls.includes(r)?`${r}/${n}`:`${r}?${u.IdentifierParamName}=${n}`}generateQrCode(t,e,r=512,n="white",i="black",a="#23F7DD"){let o=this.build(t,e);return new Zt({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:i},cornersSquareOptions:{type:"extra-rounded",color:i},cornersDotOptions:{type:"square",color:i},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(a)}" 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=f.SuperClientUrls.includes(e.origin),n=e.searchParams.get(u.IdentifierParamName),i=r&&!n?e.pathname.split("/")[1]:n;if(!i)return null;let a=decodeURIComponent(i);return g.getInfoFromPrefixedIdentifier(a)}};var re="https://",st="query",ot="env",g=class s{static prepareVars(t,e){if(!t?.vars)return t;let r=JSON.stringify(t),n=(i,a)=>{r=r.replace(new RegExp(`{{${i.toUpperCase()}}}`,"g"),a.toString())};return Object.entries(t.vars).forEach(([i,a])=>{if(typeof a=="string"&&a.startsWith(`${st}:`)){if(!e.currentUrl)throw new Error("WarpUtils: currentUrl config is required to prepare vars");let o=a.split(`${st}:`)[1],c=new URL(e.currentUrl).searchParams.get(o);c&&n(i,c)}else if(typeof a=="string"&&a.startsWith(`${ot}:`)){let o=a.split(`${ot}:`)[1],c=e.vars?.[o];c&&n(i,c)}else n(i,a)}),JSON.parse(r)}static getInfoFromPrefixedIdentifier(t){let e=decodeURIComponent(t),r=e.includes(u.IdentifierParamSeparator)?e:`${u.IdentifierType.Alias}${u.IdentifierParamSeparator}${e}`,[n,i]=r.split(u.IdentifierParamSeparator);return{type:n,id:i}}static getNextStepUrl(t,e){if(!t?.next)return null;if(t.next.startsWith(re))return t.next;{let r=new R(e),n=s.getInfoFromPrefixedIdentifier(t.next);return n?r.build(n.type,n.id):null}}static getChainEntrypoint(t){return t.env==="devnet"?new Yt:t.env==="testnet"?new ee:new te}static getConfiguredChainApi(t){let e=t.chainApiUrl||f.Chain.ApiUrl(t.env);if(!e)throw new Error("WarpUtils: Chain API URL not configured");return new Xt(e,{timeout:3e4,clientName:"warp-sdk"})}};var pt=class{constructor(t){this.pendingBrand={protocol:b("brand"),name:"",description:"",logo:""};this.config=t}createInscriptionTransaction(t){if(!this.config.userAddress)throw new Error("BrandBuilder: user address not set");let e=new ne({chainID:w(this.config.env)}),r=new ie({config:e}),n=ct.newFromBech32(this.config.userAddress),i=JSON.stringify(t);return r.createTransactionForNativeTokenTransfer(n,{receiver:ct.newFromBech32(this.config.userAddress),nativeAmount:BigInt(0),data:Uint8Array.from(Buffer.from(i))})}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=g.getConfiguredChainApi(this.config);try{let r=await e.getTransaction(t);return this.createFromTransaction(r)}catch(r){return console.error("BrandBuilder: Error creating from transaction hash",r),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.brandSchemaUrl||f.LatestBrandSchemaUrl,n=await(await fetch(e)).json(),i=new ae,a=i.compile(n);if(!a(t))throw new Error(`BrandBuilder: schema validation failed: ${i.errorsText(a.errors)}`)}};import{Address as se,AddressValue as oe,BigUIntType as ce,BigUIntValue as ut,BooleanValue as pe,BytesValue as ue,CodeMetadata as le,CodeMetadataValue as de,CompositeType as ge,CompositeValue as fe,Field as O,FieldDefinition as L,List as me,NothingValue as he,OptionalValue as q,OptionValue as D,StringValue as ye,Struct as we,StructType as Te,TokenIdentifierType as We,TokenIdentifierValue as lt,U16Value as Ae,U32Value as Ce,U64Type as be,U64Value as dt,U8Value as Ie,VariadicValue as Be}from"@multiversx/sdk-core/out";var Dr=(s,t)=>s?D.newProvided(s):t?D.newMissingTyped(t):D.newMissing(),_r=(s,t)=>s?new q(s.getType(),s):t?new q(t):q.newMissing(),Hr=s=>{if(s.length===0)throw new Error("Cannot create a list from an empty array");let t=s[0].getType();return new me(t,s)},jr=s=>Be.fromItems(...s),Qr=s=>{let t=s.map(e=>e.getType());return new fe(new ge(...t),s)},zr=s=>ye.fromUTF8(s),Mr=s=>new Ie(s),Gr=s=>new Ae(s),Kr=s=>new Ce(s),Jr=s=>new dt(s),Zr=s=>new ut(BigInt(s)),Xr=s=>new pe(s),Yr=s=>new oe(se.newFromBech32(s)),tn=s=>new lt(s),en=s=>ue.fromHex(s),rn=s=>new we(new Te("EsdtTokenPayment",[new L("token_identifier","",new We),new L("token_nonce","",new be),new L("amount","",new ce)]),[new O(new lt(s.token.identifier),"token_identifier"),new O(new dt(BigInt(s.token.nonce)),"token_nonce"),new O(new ut(BigInt(s.amount)),"amount")]),nn=s=>new de(le.newFromBytes(Uint8Array.from(Buffer.from(s,"hex")))),an=()=>new he;import{Address as ve,TransactionsFactoryConfig as Se,TransferTransactionsFactory as xe}from"@multiversx/sdk-core";var U=class{constructor(t){this.cache=new W;this.config=t}createInscriptionTransaction(t){if(!this.config.userAddress)throw new Error("WarpBuilder: user address not set");let e=new Se({chainID:w(this.config.env)}),r=new xe({config:e}),n={protocol:b("abi"),content:t},i=ve.newFromBech32(this.config.userAddress),a=JSON.stringify(n),o=r.createTransactionForTransfer(i,{receiver:i,nativeAmount:BigInt(0),data:Uint8Array.from(Buffer.from(a))});return o.gasLimit=o.gasLimit+BigInt(2e6),o}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=A.WarpAbi(t);if(e){let i=this.cache.get(r);if(i)return console.log(`WarpAbiBuilder (createFromTransactionHash): Warp abi found in cache: ${t}`),i}let n=g.getConfiguredChainApi(this.config);try{let i=await n.getTransaction(t),a=await this.createFromTransaction(i);return e&&e.ttl&&a&&this.cache.set(r,a,e.ttl),a}catch(i){return console.error("WarpAbiBuilder: Error creating from transaction hash",i),null}}};import{AbiRegistry as X,Address as Y,ArgSerializer as $e,SmartContractTransactionsFactory as Oe,Token as Le,TokenComputer as qe,TokenTransfer as Ot,TransactionsFactoryConfig as De,TransferTransactionsFactory as _e}from"@multiversx/sdk-core";var Ve=[{id:"EGLD",name:"eGold",decimals:18},{id:"EGLD-000000",name:"eGold",decimals:18}],gt=s=>Ve.find(t=>t.id===s)||null;import{Address as Pe,AddressType as ft,AddressValue as mt,BigUIntType as _,BigUIntValue as H,BooleanType as ht,BooleanValue as yt,BytesType as wt,BytesValue as Tt,CodeMetadata as Re,CodeMetadataType as Wt,CodeMetadataValue as At,CompositeType as Ct,CompositeValue as bt,Field as j,FieldDefinition as Q,List as It,ListType as Ue,NothingValue as h,OptionalType as Ee,OptionalValue as z,OptionType as Fe,OptionValue as M,StringType as Bt,StringValue as vt,Struct as ke,StructType as St,Token as Ne,TokenIdentifierType as G,TokenIdentifierValue as K,TokenTransfer as xt,U16Type as Vt,U16Value as Pt,U32Type as Rt,U32Value as Ut,U64Type as J,U64Value as Z,U8Type as Et,U8Value as Ft,VariadicType as kt,VariadicValue as Nt}from"@multiversx/sdk-core/out";var $t=new RegExp(`${u.ArgParamsSeparator}(.*)`),E=class{nativeToString(t,e){return t==="esdt"&&e instanceof xt?`esdt:${e.token.identifier}|${e.token.nonce.toString()}|${e.amount.toString()}`:`${t}:${e?.toString()??""}`}typedToString(t){if(t.hasClassOrSuperclass(M.ClassName))return t.isSet()?`option:${this.typedToString(t.getTypedValue())}`:"option:null";if(t.hasClassOrSuperclass(z.ClassName))return t.isSet()?`optional:${this.typedToString(t.getTypedValue())}`:"optional:null";if(t.hasClassOrSuperclass(It.ClassName)){let e=t.getItems(),n=e.map(a=>this.typedToString(a).split(u.ArgParamsSeparator)[0])[0],i=e.map(a=>this.typedToString(a).split(u.ArgParamsSeparator)[1]);return`list:${n}:${i.join(",")}`}if(t.hasClassOrSuperclass(Nt.ClassName)){let e=t.getItems(),n=e.map(a=>this.typedToString(a).split(u.ArgParamsSeparator)[0])[0],i=e.map(a=>this.typedToString(a).split(u.ArgParamsSeparator)[1]);return`variadic:${n}:${i.join(",")}`}if(t.hasClassOrSuperclass(bt.ClassName)){let e=t.getItems(),r=e.map(o=>this.typedToString(o).split(u.ArgParamsSeparator)[0]),n=e.map(o=>this.typedToString(o).split(u.ArgParamsSeparator)[1]),i=r.join(u.ArgCompositeSeparator),a=n.join(u.ArgCompositeSeparator);return`composite(${i}):${a}`}if(t.hasClassOrSuperclass(H.ClassName)||t.getType().getName()==="BigUint")return`biguint:${BigInt(t.valueOf().toFixed())}`;if(t.hasClassOrSuperclass(Ft.ClassName))return`uint8:${t.valueOf().toNumber()}`;if(t.hasClassOrSuperclass(Pt.ClassName))return`uint16:${t.valueOf().toNumber()}`;if(t.hasClassOrSuperclass(Ut.ClassName))return`uint32:${t.valueOf().toNumber()}`;if(t.hasClassOrSuperclass(Z.ClassName))return`uint64:${BigInt(t.valueOf().toFixed())}`;if(t.hasClassOrSuperclass(vt.ClassName))return`string:${t.valueOf()}`;if(t.hasClassOrSuperclass(yt.ClassName))return`bool:${t.valueOf()}`;if(t.hasClassOrSuperclass(mt.ClassName))return`address:${t.valueOf().bech32()}`;if(t.hasClassOrSuperclass(K.ClassName))return`token:${t.valueOf()}`;if(t.hasClassOrSuperclass(Tt.ClassName))return`hex:${t.valueOf().toString("hex")}`;if(t.hasClassOrSuperclass(At.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 Ct(...e.split(u.ArgCompositeSeparator).map(r=>this.nativeToType(r)))}if(t==="string")return new Bt;if(t==="uint8")return new Et;if(t==="uint16")return new Vt;if(t==="uint32")return new Rt;if(t==="uint64")return new J;if(t==="biguint")return new _;if(t==="bool")return new ht;if(t==="address")return new ft;if(t==="token")return new G;if(t==="hex")return new wt;if(t==="codemeta")return new Wt;if(t==="esdt"||t==="nft")return new St("EsdtTokenPayment",[new Q("token_identifier","",new G),new Q("token_nonce","",new J),new Q("amount","",new _)]);throw new Error(`WarpArgSerializer (nativeToType): Unsupported input type: ${t}`)}stringToNative(t){let e=t.split(u.ArgParamsSeparator),r=e[0],n=e.slice(1).join(u.ArgParamsSeparator);if(r==="null")return[r,null];if(r==="option"){let[i,a]=n.split(u.ArgParamsSeparator);return[`option:${i}`,a||null]}else if(r==="optional"){let[i,a]=n.split(u.ArgParamsSeparator);return[`optional:${i}`,a||null]}else if(r==="list"){let i=n.split(u.ArgParamsSeparator),a=i.slice(0,-1).join(u.ArgParamsSeparator),o=i[i.length-1],p=(o?o.split(","):[]).map(l=>this.stringToNative(`${a}:${l}`)[1]);return[`list:${a}`,p]}else if(r==="variadic"){let i=n.split(u.ArgParamsSeparator),a=i.slice(0,-1).join(u.ArgParamsSeparator),o=i[i.length-1],p=(o?o.split(","):[]).map(l=>this.stringToNative(`${a}:${l}`)[1]);return[`variadic:${a}`,p]}else if(r.startsWith("composite")){let i=r.match(/\(([^)]+)\)/)?.[1]?.split(u.ArgCompositeSeparator),o=n.split(u.ArgCompositeSeparator).map((c,p)=>this.stringToNative(`${i[p]}:${c}`)[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[i,a,o]=n.split(u.ArgCompositeSeparator);return[r,new xt({token:new Ne({identifier:i,nonce:BigInt(a)}),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 h;if(e==="option"){let n=this.stringToTyped(r);return n instanceof h?M.newMissingTyped(n.getType()):M.newProvided(n)}if(e==="optional"){let n=this.stringToTyped(r);return n instanceof h?z.newMissing():new z(n.getType(),n)}if(e==="list"){let[n,i]=r.split($t,2),o=i.split(",").map(c=>this.stringToTyped(`${n}:${c}`));return new It(this.nativeToType(n),o)}if(e==="variadic"){let[n,i]=r.split($t,2),o=i.split(",").map(c=>this.stringToTyped(`${n}:${c}`));return new Nt(new kt(this.nativeToType(n)),o)}if(e.startsWith("composite")){let n=e.match(/\(([^)]+)\)/)?.[1],i=r.split(u.ArgCompositeSeparator),a=n.split(u.ArgCompositeSeparator),o=i.map((p,l)=>this.stringToTyped(`${a[l]}:${p}`)),c=o.map(p=>p.getType());return new bt(new Ct(...c),o)}if(e==="string")return r?vt.fromUTF8(r):new h;if(e==="uint8")return r?new Ft(Number(r)):new h;if(e==="uint16")return r?new Pt(Number(r)):new h;if(e==="uint32")return r?new Ut(Number(r)):new h;if(e==="uint64")return r?new Z(BigInt(r)):new h;if(e==="biguint")return r?new H(BigInt(r)):new h;if(e==="bool")return r?new yt(typeof r=="boolean"?r:r==="true"):new h;if(e==="address")return r?new mt(Pe.newFromBech32(r)):new h;if(e==="token")return r?new K(r):new h;if(e==="hex")return r?Tt.fromHex(r):new h;if(e==="codemeta")return new At(Re.newFromBytes(Uint8Array.from(Buffer.from(r,"hex"))));if(e==="esdt"){let n=r.split(u.ArgCompositeSeparator);return new ke(this.nativeToType("esdt"),[new j(new K(n[0]),"token_identifier"),new j(new Z(BigInt(n[1])),"token_nonce"),new j(new H(BigInt(n[2])),"amount")])}throw new Error(`WarpArgSerializer (stringToTyped): Unsupported input type: ${e}`)}typeToString(t){if(t instanceof Fe)return"option:"+this.typeToString(t.getFirstTypeParameter());if(t instanceof Ee)return"optional:"+this.typeToString(t.getFirstTypeParameter());if(t instanceof Ue)return"list:"+this.typeToString(t.getFirstTypeParameter());if(t instanceof kt)return"variadic:"+this.typeToString(t.getFirstTypeParameter());if(t instanceof Bt)return"string";if(t instanceof Et)return"uint8";if(t instanceof Vt)return"uint16";if(t instanceof Rt)return"uint32";if(t instanceof J)return"uint64";if(t instanceof _)return"biguint";if(t instanceof ht)return"bool";if(t instanceof ft)return"address";if(t instanceof G)return"token";if(t instanceof wt)return"hex";if(t instanceof Wt)return"codemeta";if(t instanceof St&&t.getClassName()==="EsdtTokenPayment")return"esdt";throw new Error(`WarpArgSerializer (typeToString): Unsupported input type: ${t.getClassName()}`)}};var F=class{constructor(t){this.config=t}async getContract(t){try{let r=await g.getConfiguredChainApi(this.config).doGetGeneric(`accounts/${t}/verification`);return{address:t,owner:r.ownerAddress,verified:r.isVerified}}catch(e){return console.error("WarpContractLoader: getContract error",e),null}}async getVerificationInfo(t){try{let r=await g.getConfiguredChainApi(this.config).doGetGeneric(`accounts/${t}/verification`);return{codeHash:r.codeHash,abi:r.source.abi}}catch(e){return console.error("WarpContractLoader: getVerificationInfo error",e),null}}};var Lt=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 E,this.contractLoader=new F(t)}async createTransactionForExecute(t,e){if(!this.config.userAddress)throw new Error("WarpActionExecutor: user address not set");let r=Y.newFromBech32(this.config.userAddress),n=new De({chainID:w(this.config.env)}),{destination:i,args:a,value:o,transfers:c,data:p}=await this.getTxComponentsFromInputs(t,e,r),l=a.map(d=>this.serializer.stringToTyped(d));if(t.type==="transfer")return new _e({config:n}).createTransactionForTransfer(r,{receiver:i,nativeAmount:o,tokenTransfers:c,data:p?new Uint8Array(p):void 0});if(t.type==="contract"&&i.isSmartContract())return new Oe({config:n}).createTransactionForExecute(r,{contract:i,function:"func"in t&&t.func||"",gasLimit:"gasLimit"in t?BigInt(t.gasLimit||0):0n,arguments:l,tokenTransfers:c,nativeTransferAmount:o});throw t.type==="query"?new Error("WarpActionExecutor: Invalid action type for createTransactionForExecute; Use executeQuery instead"):t.type==="collect"?new Error("WarpActionExecutor: Invalid action type for createTransactionForExecute; Use executeCollect instead"):new Error("WarpActionExecutor: Invalid action type")}async executeQuery(t,e){if(!this.config.chainApiUrl)throw new Error("WarpActionExecutor: Chain API URL not set");if(!t.func)throw new Error("WarpActionExecutor: Function not found");let r=await this.getAbiForAction(t),{args:n}=await this.getTxComponentsFromInputs(t,e),i=n.map(I=>this.serializer.stringToTyped(I)),a=g.getChainEntrypoint(this.config),o=Y.newFromBech32(t.address),c=a.createSmartContractController(r),p=c.createQuery({contract:o,function:t.func,arguments:i}),l=await c.runQuery(p);if(!(l.returnCode==="ok"))throw new Error(`WarpActionExecutor: Query failed with return code ${l.returnCode}`);let v=new $e,k=r.getEndpoint(l.function),N=l.returnDataParts.map(I=>Buffer.from(I));return v.buffersToValues(N,k.output)[0]}async executeCollect(t,e,r){let n=new Headers;n.set("Content-Type","application/json"),n.set("Accept","application/json"),Object.entries(t.destination.headers).forEach(([i,a])=>{n.set(i,a)}),await fetch(t.destination.url,{method:t.destination.method,headers:n,body:JSON.stringify({inputs:e,meta:r})})}async getTxComponentsFromInputs(t,e,r){let n=await this.getResolvedInputs(t,e),i=this.getModifiedInputs(n),a=i.find(y=>y.input.position==="receiver")?.value,o="address"in t?t.address:null,c=a?.split(":")[1]||o||r?.toBech32();if(!c)throw new Error("WarpActionExecutor: Destination/Receiver not provided");let p=Y.newFromBech32(c),l=this.getPreparedArgs(t,i),d=i.find(y=>y.input.position==="value")?.value||null,v="value"in t?t.value:null,k=BigInt(d?.split(":")[1]||v||0),N=i.filter(y=>y.input.position==="transfer"&&y.value).map(y=>y.value),I=[...("transfers"in t?t.transfers:[])?.map(this.toTypedTransfer)||[],...N?.map(y=>this.serializer.stringToNative(y)[1])||[]],_t=i.find(y=>y.input.position==="data")?.value,Ht="data"in t?t.data||"":null,tt=_t||Ht||null,et=tt?this.serializer.stringToTyped(tt).valueOf():null,jt=et?Buffer.from(et):null;return{destination:p,args:l,value:k,transfers:I,data:jt}}getModifiedInputs(t){return t.map((e,r)=>{if(e.input.modifier?.startsWith("scale:")){let[,n]=e.input.modifier.split(":");if(isNaN(Number(n))){let i=Number(t.find(c=>c.input.name===n)?.value?.split(":")[1]);if(!i)throw new Error(`WarpActionExecutor: Exponent value not found for input ${n}`);let a=e.value?.split(":")[1];if(!a)throw new Error("WarpActionExecutor: Scalable value not found");let o=x(a,+i);return{...e,value:`${e.input.type}:${o}`}}else{let i=e.value?.split(":")[1];if(!i)throw new Error("WarpActionExecutor: Scalable value not found");let a=x(i,+n);return{...e,value:`${e.input.type}:${a}`}}}else return e})}async getResolvedInputs(t,e){let r=t.inputs||[],n=await Promise.all(e.map(a=>this.preprocessInput(a))),i=(a,o)=>a.source==="query"?this.serializer.nativeToString(a.type,this.url.searchParams.get(a.name)||""):n[o]||null;return r.map((a,o)=>({input:a,value:i(a,o)}))}async preprocessInput(t){try{let[e,r]=this.serializer.stringToNative(t);if(e==="esdt"){let[,,,n]=t.split(u.ArgCompositeSeparator);if(n)return t;let i=r;if(!new qe().isFungible(i.token))return t;let c=gt(i.token.identifier)?.decimals;if(!c){let l=this.config.chainApiUrl||f.Chain.ApiUrl(this.config.env);c=(await(await fetch(`${l}/tokens/${i.token.identifier}`)).json()).decimals}if(!c)throw new Error(`WarpActionExecutor: Decimals not found for token ${i.token.identifier}`);let p=new Ot({token:i.token,amount:x(i.amount,c)});return this.serializer.nativeToString(e,p)+u.ArgCompositeSeparator+c}return t}catch{return t}}getPreparedArgs(t,e){let r="args"in t?t.args||[]:[];return e.forEach(({input:n,value:i})=>{if(!i||!n.position.startsWith("arg:"))return;let a=Number(n.position.split(":")[1])-1;r.splice(a,0,i)}),r}async getAbiForAction(t){if(t.abi)return await this.fetchAbi(t);let e=await this.contractLoader.getVerificationInfo(t.address);if(!e)throw new Error("WarpActionExecutor: Verification info not found");return X.create(e.abi)}async fetchAbi(t){if(!t.abi)throw new Error("WarpActionExecutor: ABI not found");if(t.abi.startsWith(u.IdentifierType.Hash)){let e=new U(this.config),r=t.abi.split(u.IdentifierParamSeparator)[1],n=await e.createFromTransactionHash(r);if(!n)throw new Error(`WarpActionExecutor: ABI not found for hash: ${t.abi}`);return X.create(n.content)}else{let r=await(await fetch(t.abi)).json();return X.create(r)}}toTypedTransfer(t){return new Ot({token:new Le({identifier:t.token,nonce:BigInt(t.nonce||0)}),amount:BigInt(t.amount||0)})}};var qt=class{constructor(t){this.config=t}async search(t,e,r){if(!this.config.indexUrl)throw new Error("WarpIndex: Index URL is not set");try{let n=await fetch(this.config.indexUrl,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${this.config.indexApiKey}`,...r},body:JSON.stringify({[this.config.indexSearchParamName||"search"]:t,...e})});if(!n.ok)throw new Error(`WarpIndex: search failed with status ${n.status}`);return(await n.json()).hits}catch(n){throw console.error("WarpIndex: Error searching for warps: ",n),n}}};export{pt as BrandBuilder,A as CacheKey,f as Config,U as WarpAbiBuilder,Lt as WarpActionExecutor,E as WarpArgSerializer,V as WarpBuilder,W as WarpCache,u as WarpConstants,F as WarpContractLoader,qt as WarpIndex,R as WarpLink,C as WarpProtocolVersions,P as WarpRegistry,g as WarpUtils,B as WarpValidator,Yr as address,Zr as biguint,Xr as boolean,nn as codemeta,Qr as composite,rn as esdt,w as getChainId,b as getLatestProtocolIdentifier,Qe as getWarpActionByIndex,en as hex,Hr as list,an as nothing,Dr as option,_r as optional,x as shiftBigintBy,zr as string,rt as toPreviewText,S as toTypedRegistryInfo,tn as token,Gr as u16,Kr as u32,Jr as u64,Mr as u8,jr as variadic};
1
+ import{Address as ft,TransactionsFactoryConfig as ce,TransferTransactionsFactory as pe}from"@multiversx/sdk-core";import ue from"ajv";var I={Warp:"1.1.0",Brand:"0.1.0",Abi:"0.1.0"},f={LatestWarpSchemaUrl:`https://raw.githubusercontent.com/vLeapGroup/warps-specs/refs/heads/main/schemas/v${I.Warp}.schema.json`,LatestBrandSchemaUrl:`https://raw.githubusercontent.com/vLeapGroup/warps-specs/refs/heads/main/schemas/brand/v${I.Brand}.schema.json`,DefaultClientUrl:s=>s==="devnet"?"https://devnet.usewarp.to":s==="testnet"?"https://testnet.usewarp.to":"https://usewarp.to",SuperClientUrls:["https://usewarp.to","https://testnet.usewarp.to","https://devnet.usewarp.to"],Chain:{ApiUrl:s=>s==="devnet"?"https://devnet-api.multiversx.com":s==="testnet"?"https://testnet-api.multiversx.com":"https://api.multiversx.com"},Registry:{Contract:s=>s==="devnet"?"erd1qqqqqqqqqqqqqpgqje2f99vr6r7sk54thg03c9suzcvwr4nfl3tsfkdl36":s==="testnet"?"####":"erd1qqqqqqqqqqqqqpgq3mrpj3u6q7tejv6d7eqhnyd27n9v5c5tl3ts08mffe"},AvailableActionInputSources:["field","query"],AvailableActionInputTypes:["string","uint8","uint16","uint32","uint64","biguint","boolean","address"],AvailableActionInputPositions:["value","arg:1","arg:2","arg:3","arg:4","arg:5","arg:6","arg:7","arg:8","arg:9","arg:10"]};var T=s=>s==="devnet"?"D":s==="testnet"?"T":"1",U=s=>({chainId:T(s.env),apiUrl:s.chainApiUrl||f.Chain.ApiUrl(s.env)}),b=s=>{if(s==="warp")return`warp:${I.Warp}`;if(s==="brand")return`brand:${I.Brand}`;if(s==="abi")return`abi:${I.Abi}`;throw new Error(`getLatestProtocolIdentifier: Invalid protocol name: ${s}`)},Ge=(s,t)=>s?.actions[t-1],E=s=>({hash:s.hash.toString("hex"),alias:s.alias?.toString()||null,trust:s.trust.toString(),creator:s.creator.toString(),createdAt:s.created_at.toNumber(),brand:s.brand?.toString("hex")||null,upgrade:s.upgrade?.toString("hex")||null}),ot=s=>({chainId:s.chain_id.toString(),apiUrl:s.api_url.toString()}),F=(s,t)=>{let e=s.toString(),[r,n=""]=e.split("."),i=Math.abs(t);if(t>0)return BigInt(r+n.padEnd(i,"0"));if(t<0){let a=r+n;if(i>=a.length)return 0n;let o=a.slice(0,-i)||"0";return BigInt(o)}else return BigInt(s)},ct=(s,t=100)=>{if(!s)return"";let e=s.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};import{ApiNetworkProvider as ne,DevnetEntrypoint as ie,MainnetEntrypoint as ae,TestnetEntrypoint as se}from"@multiversx/sdk-core";var u={HttpProtocolPrefix:"http",IdentifierParamName:"warp",IdentifierParamSeparator:":",IdentifierType:{Alias:"alias",Hash:"hash"},ArgParamsSeparator:":",ArgCompositeSeparator:"|",Egld:{Identifier:"EGLD",DisplayName:"eGold",Decimals:18}};import re from"qr-code-styling";import{Address as pt,TransactionsFactoryConfig as Zt,TransferTransactionsFactory as Xt}from"@multiversx/sdk-core";var x=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){try{let n={value:e,expiresAt:Date.now()+r*1e3};localStorage.setItem(this.getKey(t),JSON.stringify(n))}catch{}}clear(){try{for(let t=0;t<localStorage.length;t++){let e=localStorage.key(t);e?.startsWith(this.prefix)&&localStorage.removeItem(e)}}catch{}}};var V=class{constructor(){this.cache=new Map}get(t){let e=this.cache.get(t);return e?Date.now()>e.expiresAt?(this.cache.delete(t),null):e.value:null}set(t,e,r){let n=Date.now()+r*1e3;this.cache.set(t,{value:e,expiresAt:n})}clear(){this.cache.clear()}};var C={Warp:s=>`warp:${s}`,WarpAbi:s=>`warp-abi:${s}`,RegistryInfo:s=>`registry-info:${s}`,Brand:s=>`brand:${s}`,ChainInfo:s=>`chain:${s}`},W=class{constructor(t){this.strategy=this.selectStrategy(t)}selectStrategy(t){return t==="localStorage"?new x:t==="memory"?new V:typeof window<"u"&&window.localStorage?new x:new V}set(t,e,r){this.strategy.set(t,e,r)}get(t){return this.strategy.get(t)}clear(){this.strategy.clear()}};import Jt from"ajv";var P=class{constructor(t){this.config=t;this.config=t}async validate(t){this.ensureMaxOneValuePosition(t),await this.ensureValidSchema(t)}ensureMaxOneValuePosition(t){if(t.actions.filter(r=>"position"in r?r.position==="value":!1).length>1)throw new Error("WarpBuilder: only one value position action is allowed")}async ensureValidSchema(t){let e=this.config.warpSchemaUrl||f.LatestWarpSchemaUrl,n=await(await fetch(e)).json(),i=new Jt,a=i.compile(n);if(!a(t))throw new Error(`WarpBuilder: schema validation failed: ${i.errorsText(a.errors)}`)}};var $=class{constructor(t){this.pendingWarp={protocol:b("warp"),name:"",title:"",description:null,preview:"",actions:[]};this.config=t,this.cache=new W(t.cacheType)}createInscriptionTransaction(t){if(!this.config.userAddress)throw new Error("WarpBuilder: user address not set");let e=new Zt({chainID:T(this.config.env)}),r=new Xt({config:e}),n=pt.newFromBech32(this.config.userAddress),i=JSON.stringify(t),a=r.createTransactionForTransfer(n,{receiver:pt.newFromBech32(this.config.userAddress),nativeAmount:BigInt(0),data:Uint8Array.from(Buffer.from(i))});return a.gasLimit=a.gasLimit+BigInt(2e6),a}async createFromRaw(t,e=!0){let r=JSON.parse(t);return e&&await new P(this.config).validate(r),g.prepareVars(r,this.config)}async createFromTransaction(t,e=!1){let r=await this.createFromRaw(t.data.toString(),e);return r.meta={hash:t.hash,creator:t.sender.bech32(),createdAt:new Date(t.timestamp*1e3).toISOString()},r}async createFromTransactionHash(t,e){let r=C.Warp(t);if(e){let i=this.cache.get(r);if(i)return console.log(`WarpBuilder (createFromTransactionHash): Warp found in cache: ${t}`),i}let n=g.getConfiguredChainApi(this.config);try{let i=await n.getTransaction(t),a=await this.createFromTransaction(i);return e&&e.ttl&&a&&this.cache.set(r,a,e.ttl),a}catch(i){return console.error("WarpBuilder: Error creating from transaction hash",i),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 new P(this.config).validate(this.pendingWarp),this.pendingWarp}getDescriptionPreview(t,e=100){return ct(t,e)}ensure(t,e){if(!t)throw new Error(`WarpBuilder: ${e}`)}};import{AbiRegistry as ut,Address as w,AddressValue as lt,BytesValue as m,SmartContractTransactionsFactory as te,TransactionsFactoryConfig as ee}from"@multiversx/sdk-core/out";var D={buildInfo:{rustc:{version:"1.80.0-nightly",commitHash:"791adf759cc065316f054961875052d5bc03e16c",commitDate:"2024-05-21",channel:"Nightly",short:"rustc 1.80.0-nightly (791adf759 2024-05-21)"},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:"verifyWarp",onlyOwner:!0,mutability:"mutable",inputs:[{name:"warp",type:"bytes"}],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:"getConfig",mutability:"readonly",inputs:[],outputs:[{type:"BigUint"}]},{name:"registerBrand",mutability:"mutable",payableInTokens:["EGLD"],inputs:[{name:"hash",type:"bytes"}],outputs:[]},{name:"brandWarp",mutability:"mutable",payableInTokens:["EGLD"],inputs:[{name:"warp",type:"bytes"},{name:"brand",type:"bytes"}],outputs:[]},{name:"getUserBrands",mutability:"readonly",inputs:[{name:"user",type:"Address"}],outputs:[{type:"variadic<bytes>",multi_result:!0}]}],events:[{identifier:"warpRegistered",inputs:[{name:"hash",type:"bytes",indexed:!0},{name:"alias",type:"bytes",indexed:!0}]},{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}]},{identifier:"warpVerified",inputs:[{name:"hash",type:"bytes",indexed:!0}]},{identifier:"aliasUpdated",inputs:[{name:"hash",type:"bytes",indexed:!0},{name:"alias",type:"bytes",indexed:!0}]}],esdtAttributes:[],hasCallback:!1,types:{InfoView:{type:"struct",fields:[{name:"hash",type:"bytes"},{name:"alias",type:"Option<bytes>"},{name:"trust",type:"bytes"},{name:"creator",type:"Address"},{name:"created_at",type:"u64"},{name:"brand",type:"Option<bytes>"},{name:"upgrade",type:"Option<bytes>"}]}}};var v=class{constructor(t){this.config=t,this.cache=new W(t.cacheType),this.unitPrice=BigInt(0)}async init(){await this.loadRegistryConfigs()}createWarpRegisterTransaction(t,e){if(this.unitPrice===BigInt(0))throw new Error("WarpRegistry: config not loaded. forgot to call init()?");if(!this.config.userAddress)throw new Error("WarpRegistry: user address not set");let r=w.newFromBech32(this.config.userAddress),n=e?this.unitPrice*BigInt(2):this.unitPrice;return this.getFactory().createTransactionForExecute(r,{contract:this.getRegistryContractAddress(),function:"registerWarp",gasLimit:BigInt(1e7),nativeTransferAmount:n,arguments:e?[m.fromHex(t),m.fromUTF8(e)]:[m.fromHex(t)]})}createWarpUnregisterTransaction(t){if(!this.config.userAddress)throw new Error("WarpRegistry: user address not set");let e=w.newFromBech32(this.config.userAddress);return this.getFactory().createTransactionForExecute(e,{contract:this.getRegistryContractAddress(),function:"unregisterWarp",gasLimit:BigInt(1e7),arguments:[m.fromHex(t)]})}createWarpUpgradeTransaction(t,e){if(this.unitPrice===BigInt(0))throw new Error("WarpRegistry: config not loaded. forgot to call init()?");if(!this.config.userAddress)throw new Error("WarpRegistry: user address not set");let r=w.newFromBech32(this.config.userAddress);return this.getFactory().createTransactionForExecute(r,{contract:this.getRegistryContractAddress(),function:"upgradeWarp",gasLimit:BigInt(1e7),nativeTransferAmount:this.unitPrice,arguments:[m.fromUTF8(t),m.fromHex(e)]})}createWarpAliasSetTransaction(t,e){if(!this.config.userAddress)throw new Error("WarpRegistry: user address not set");let r=w.newFromBech32(this.config.userAddress);return this.getFactory().createTransactionForExecute(r,{contract:this.getRegistryContractAddress(),function:"setWarpAlias",gasLimit:BigInt(1e7),nativeTransferAmount:this.unitPrice,arguments:[m.fromHex(t),m.fromUTF8(e)]})}createWarpVerifyTransaction(t){if(!this.config.userAddress)throw new Error("WarpRegistry: user address not set");let e=w.newFromBech32(this.config.userAddress);return this.getFactory().createTransactionForExecute(e,{contract:this.getRegistryContractAddress(),function:"verifyWarp",gasLimit:BigInt(1e7),arguments:[m.fromHex(t)]})}createBrandRegisterTransaction(t){if(this.unitPrice===BigInt(0))throw new Error("WarpRegistry: config not loaded. forgot to call init()?");if(!this.config.userAddress)throw new Error("WarpRegistry: user address not set");let e=w.newFromBech32(this.config.userAddress);return this.getFactory().createTransactionForExecute(e,{contract:this.getRegistryContractAddress(),function:"registerBrand",gasLimit:BigInt(1e7),nativeTransferAmount:this.unitPrice,arguments:[m.fromHex(t)]})}createWarpBrandingTransaction(t,e){if(!this.config.userAddress)throw new Error("WarpRegistry: user address not set");let r=w.newFromBech32(this.config.userAddress);return this.getFactory().createTransactionForExecute(r,{contract:this.getRegistryContractAddress(),function:"brandWarp",gasLimit:BigInt(1e7),nativeTransferAmount:this.unitPrice,arguments:[m.fromHex(t),m.fromHex(e)]})}async getInfoByAlias(t,e){let r=C.RegistryInfo(t),n=e?this.cache.get(r):null;if(n)return console.log(`WarpRegistry (getInfoByAlias): RegistryInfo found in cache: ${t}`),n;let i=this.getRegistryContractAddress(),a=this.getController(),o=a.createQuery({contract:i,function:"getInfoByAlias",arguments:[m.fromUTF8(t)]}),p=await a.runQuery(o),[c]=a.parseQueryResponse(p),l=c?E(c):null,d=l?.brand?await this.fetchBrand(l.brand):null;return e&&e.ttl&&this.cache.set(r,{registryInfo:l,brand:d},e.ttl),{registryInfo:l,brand:d}}async getInfoByHash(t,e){let r=C.RegistryInfo(t);if(e){let d=this.cache.get(r);if(d)return console.log(`WarpRegistry (getInfoByHash): RegistryInfo found in cache: ${t}`),d}let n=this.getRegistryContractAddress(),i=this.getController(),a=i.createQuery({contract:n,function:"getInfoByHash",arguments:[m.fromHex(t)]}),o=await i.runQuery(a),[p]=i.parseQueryResponse(o),c=p?E(p):null,l=c?.brand?await this.fetchBrand(c.brand):null;return e&&e.ttl&&this.cache.set(r,{registryInfo:c,brand:l},e.ttl),{registryInfo:c,brand:l}}async getUserWarpRegistryInfos(t){let e=t||this.config.userAddress;if(!e)throw new Error("WarpRegistry: user address not set");let r=this.getRegistryContractAddress(),n=this.getController(),i=n.createQuery({contract:r,function:"getUserWarps",arguments:[new lt(new w(e))]}),a=await n.runQuery(i),[o]=n.parseQueryResponse(a);return o.map(E)}async getUserBrands(t){let e=t||this.config.userAddress;if(!e)throw new Error("WarpRegistry: user address not set");let r=this.getRegistryContractAddress(),n=this.getController(),i=n.createQuery({contract:r,function:"getUserBrands",arguments:[new lt(new w(e))]}),a=await n.runQuery(i),[o]=n.parseQueryResponse(a),p=o.map(d=>d.toString("hex")),c={ttl:365*24*60*60};return(await Promise.all(p.map(d=>this.fetchBrand(d,c)))).filter(d=>d!==null)}async getChainInfo(t,e){let r=C.ChainInfo(t),n=e?this.cache.get(r):null;if(n)return console.log(`WarpRegistry (getChainInfo): ChainInfo found in cache: ${t}`),n;let i=this.getRegistryContractAddress(),a=this.getController(),o=a.createQuery({contract:i,function:"getChain",arguments:[m.fromUTF8(t)]}),p=await a.runQuery(o),[c]=a.parseQueryResponse(p),l=c?ot(c):null;return l&&e?.ttl&&this.cache.set(r,l,e.ttl),l}async fetchBrand(t,e){let r=C.Brand(t),n=e?this.cache.get(r):null;if(n)return console.log(`WarpRegistry (fetchBrand): Brand found in cache: ${t}`),n;let i=g.getConfiguredChainApi(this.config);try{let a=await i.getTransaction(t),o=JSON.parse(a.data.toString());return o.meta={hash:a.hash,creator:a.sender.bech32(),createdAt:new Date(a.timestamp*1e3).toISOString()},e&&e.ttl&&this.cache.set(r,o,e.ttl),o}catch(a){return console.error("WarpRegistry: Error fetching brand from transaction hash",a),null}}getRegistryContractAddress(){return w.newFromBech32(this.config.registryContract||f.Registry.Contract(this.config.env))}async loadRegistryConfigs(){let t=this.getRegistryContractAddress(),e=this.getController(),[r]=await e.query({contract:t,function:"getConfig",arguments:[]}),n=BigInt(r.toString());this.unitPrice=n}getFactory(){let t=new ee({chainID:T(this.config.env)}),e=ut.create(D);return new te({config:t,abi:e})}getController(){let t=U(this.config),e=g.getChainEntrypoint(t,this.config.env),r=ut.create(D);return e.createSmartContractController(r)}};var N=class{constructor(t){this.config=t;this.config=t}isValid(t){return t.startsWith(u.HttpProtocolPrefix)?!!this.extractIdentifierInfoFromUrl(t):!1}async detectFromHtml(t){if(!t.length)return{match:!1,results:[]};let n=[...t.matchAll(/https?:\/\/[^\s"'<>]+/gi)].map(c=>c[0]).filter(c=>this.isValid(c)).map(c=>this.detect(c)),a=(await Promise.all(n)).filter(c=>c.match),o=a.length>0,p=a.map(c=>({url:c.url,warp:c.warp}));return{match:o,results:p}}async detect(t){let e=t.startsWith(u.HttpProtocolPrefix)?this.extractIdentifierInfoFromUrl(t):g.getInfoFromPrefixedIdentifier(t);if(!e)return{match:!1,url:t,warp:null,registryInfo:null,brand:null};let{type:r,id:n}=e,i=new $(this.config),a=new v(this.config),o=null,p=null,c=null;if(r==="hash"){o=await i.createFromTransactionHash(n);try{let{registryInfo:l,brand:d}=await a.getInfoByHash(n);p=l,c=d}catch{}}else if(r==="alias"){let{registryInfo:l,brand:d}=await a.getInfoByAlias(n);p=l,c=d,l&&(o=await i.createFromTransactionHash(l.hash))}return o?{match:!0,url:t,warp:o,registryInfo:p,brand:c}:{match:!1,url:t,warp:null,registryInfo:null,brand:null}}build(t,e){let r=this.config.clientUrl||f.DefaultClientUrl(this.config.env),n=t===u.IdentifierType.Alias?encodeURIComponent(e):encodeURIComponent(t+u.IdentifierParamSeparator+e);return f.SuperClientUrls.includes(r)?`${r}/${n}`:`${r}?${u.IdentifierParamName}=${n}`}generateQrCode(t,e,r=512,n="white",i="black",a="#23F7DD"){let o=this.build(t,e);return new re({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:i},cornersSquareOptions:{type:"extra-rounded",color:i},cornersDotOptions:{type:"square",color:i},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(a)}" 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=f.SuperClientUrls.includes(e.origin),n=e.searchParams.get(u.IdentifierParamName),i=r&&!n?e.pathname.split("/")[1]:n;if(!i)return null;let a=decodeURIComponent(i);return g.getInfoFromPrefixedIdentifier(a)}};var oe="https://",dt="query",gt="env",g=class s{static prepareVars(t,e){if(!t?.vars)return t;let r=JSON.stringify(t),n=(i,a)=>{r=r.replace(new RegExp(`{{${i.toUpperCase()}}}`,"g"),a.toString())};return Object.entries(t.vars).forEach(([i,a])=>{if(typeof a=="string"&&a.startsWith(`${dt}:`)){if(!e.currentUrl)throw new Error("WarpUtils: currentUrl config is required to prepare vars");let o=a.split(`${dt}:`)[1],p=new URL(e.currentUrl).searchParams.get(o);p&&n(i,p)}else if(typeof a=="string"&&a.startsWith(`${gt}:`)){let o=a.split(`${gt}:`)[1],p=e.vars?.[o];p&&n(i,p)}else n(i,a)}),JSON.parse(r)}static getInfoFromPrefixedIdentifier(t){let e=decodeURIComponent(t),r=e.includes(u.IdentifierParamSeparator)?e:`${u.IdentifierType.Alias}${u.IdentifierParamSeparator}${e}`,[n,i]=r.split(u.IdentifierParamSeparator);return{type:n,id:i}}static getNextStepUrl(t,e){if(!t?.next)return null;if(t.next.startsWith(oe))return t.next;{let r=new N(e),n=s.getInfoFromPrefixedIdentifier(t.next);return n?r.build(n.type,n.id):null}}static getChainEntrypoint(t,e){let r="warp-sdk",n="api";return e==="devnet"?new ie(t.apiUrl,n,r):e==="testnet"?new se(t.apiUrl,n,r):new ae(t.apiUrl,n,r)}static getConfiguredChainApi(t){let e=t.chainApiUrl||f.Chain.ApiUrl(t.env);if(!e)throw new Error("WarpUtils: Chain API URL not configured");return new ne(e,{timeout:3e4,clientName:"warp-sdk"})}};var mt=class{constructor(t){this.pendingBrand={protocol:b("brand"),name:"",description:"",logo:""};this.config=t}createInscriptionTransaction(t){if(!this.config.userAddress)throw new Error("BrandBuilder: user address not set");let e=new ce({chainID:T(this.config.env)}),r=new pe({config:e}),n=ft.newFromBech32(this.config.userAddress),i=JSON.stringify(t);return r.createTransactionForNativeTokenTransfer(n,{receiver:ft.newFromBech32(this.config.userAddress),nativeAmount:BigInt(0),data:Uint8Array.from(Buffer.from(i))})}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=g.getConfiguredChainApi(this.config);try{let r=await e.getTransaction(t);return this.createFromTransaction(r)}catch(r){return console.error("BrandBuilder: Error creating from transaction hash",r),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.brandSchemaUrl||f.LatestBrandSchemaUrl,n=await(await fetch(e)).json(),i=new ue,a=i.compile(n);if(!a(t))throw new Error(`BrandBuilder: schema validation failed: ${i.errorsText(a.errors)}`)}};import{Address as le,AddressValue as de,BigUIntType as ge,BigUIntValue as ht,BooleanValue as fe,BytesValue as me,CodeMetadata as he,CodeMetadataValue as ye,CompositeType as we,CompositeValue as Te,Field as _,FieldDefinition as H,List as Ce,NothingValue as We,OptionalValue as Q,OptionValue as j,StringValue as Ae,Struct as Ie,StructType as be,TokenIdentifierType as ve,TokenIdentifierValue as yt,U16Value as Be,U32Value as Se,U64Type as xe,U64Value as wt,U8Value as Ve,VariadicValue as Pe}from"@multiversx/sdk-core/out";var Gr=(s,t)=>s?j.newProvided(s):t?j.newMissingTyped(t):j.newMissing(),Jr=(s,t)=>s?new Q(s.getType(),s):t?new Q(t):Q.newMissing(),Zr=s=>{if(s.length===0)throw new Error("Cannot create a list from an empty array");let t=s[0].getType();return new Ce(t,s)},Xr=s=>Pe.fromItems(...s),Yr=s=>{let t=s.map(e=>e.getType());return new Te(new we(...t),s)},tn=s=>Ae.fromUTF8(s),en=s=>new Ve(s),rn=s=>new Be(s),nn=s=>new Se(s),an=s=>new wt(s),sn=s=>new ht(BigInt(s)),on=s=>new fe(s),cn=s=>new de(le.newFromBech32(s)),pn=s=>new yt(s),un=s=>me.fromHex(s),ln=s=>new Ie(new be("EsdtTokenPayment",[new H("token_identifier","",new ve),new H("token_nonce","",new xe),new H("amount","",new ge)]),[new _(new yt(s.token.identifier),"token_identifier"),new _(new wt(BigInt(s.token.nonce)),"token_nonce"),new _(new ht(BigInt(s.amount)),"amount")]),dn=s=>new ye(he.newFromBytes(Uint8Array.from(Buffer.from(s,"hex")))),gn=()=>new We;import{Address as Re,TransactionsFactoryConfig as Ue,TransferTransactionsFactory as Ee}from"@multiversx/sdk-core";var k=class{constructor(t){this.cache=new W;this.config=t}createInscriptionTransaction(t){if(!this.config.userAddress)throw new Error("WarpBuilder: user address not set");let e=new Ue({chainID:T(this.config.env)}),r=new Ee({config:e}),n={protocol:b("abi"),content:t},i=Re.newFromBech32(this.config.userAddress),a=JSON.stringify(n),o=r.createTransactionForTransfer(i,{receiver:i,nativeAmount:BigInt(0),data:Uint8Array.from(Buffer.from(a))});return o.gasLimit=o.gasLimit+BigInt(2e6),o}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=C.WarpAbi(t);if(e){let i=this.cache.get(r);if(i)return console.log(`WarpAbiBuilder (createFromTransactionHash): Warp abi found in cache: ${t}`),i}let n=g.getConfiguredChainApi(this.config);try{let i=await n.getTransaction(t),a=await this.createFromTransaction(i);return e&&e.ttl&&a&&this.cache.set(r,a,e.ttl),a}catch(i){return console.error("WarpAbiBuilder: Error creating from transaction hash",i),null}}};import{AbiRegistry as rt,Address as nt,ArgSerializer as _e,SmartContractTransactionsFactory as He,Token as Qt,TokenComputer as Qe,TokenTransfer as jt,TransactionsFactoryConfig as je,TransferTransactionsFactory as ze}from"@multiversx/sdk-core";var Fe=[{id:"EGLD",name:"eGold",decimals:18},{id:"EGLD-000000",name:"eGold",decimals:18}],Tt=s=>Fe.find(t=>t.id===s)||null;import{Address as $e,AddressType as Ct,AddressValue as Wt,BigUIntType as z,BigUIntValue as M,BooleanType as At,BooleanValue as It,BytesType as bt,BytesValue as vt,CodeMetadata as Ne,CodeMetadataType as Bt,CodeMetadataValue as St,CompositeType as xt,CompositeValue as Vt,Field as K,FieldDefinition as G,List as Pt,ListType as ke,NothingValue as h,OptionalType as Oe,OptionalValue as J,OptionType as Le,OptionValue as Z,StringType as Rt,StringValue as Ut,Struct as qe,StructType as Et,Token as De,TokenIdentifierType as X,TokenIdentifierValue as Y,TokenTransfer as Ft,U16Type as $t,U16Value as Nt,U32Type as kt,U32Value as Ot,U64Type as tt,U64Value as et,U8Type as Lt,U8Value as qt,VariadicType as Dt,VariadicValue as _t}from"@multiversx/sdk-core/out";var Ht=new RegExp(`${u.ArgParamsSeparator}(.*)`),O=class{nativeToString(t,e){return t==="esdt"&&e instanceof Ft?`esdt:${e.token.identifier}|${e.token.nonce.toString()}|${e.amount.toString()}`:`${t}:${e?.toString()??""}`}typedToString(t){if(t.hasClassOrSuperclass(Z.ClassName))return t.isSet()?`option:${this.typedToString(t.getTypedValue())}`:"option:null";if(t.hasClassOrSuperclass(J.ClassName))return t.isSet()?`optional:${this.typedToString(t.getTypedValue())}`:"optional:null";if(t.hasClassOrSuperclass(Pt.ClassName)){let e=t.getItems(),n=e.map(a=>this.typedToString(a).split(u.ArgParamsSeparator)[0])[0],i=e.map(a=>this.typedToString(a).split(u.ArgParamsSeparator)[1]);return`list:${n}:${i.join(",")}`}if(t.hasClassOrSuperclass(_t.ClassName)){let e=t.getItems(),n=e.map(a=>this.typedToString(a).split(u.ArgParamsSeparator)[0])[0],i=e.map(a=>this.typedToString(a).split(u.ArgParamsSeparator)[1]);return`variadic:${n}:${i.join(",")}`}if(t.hasClassOrSuperclass(Vt.ClassName)){let e=t.getItems(),r=e.map(o=>this.typedToString(o).split(u.ArgParamsSeparator)[0]),n=e.map(o=>this.typedToString(o).split(u.ArgParamsSeparator)[1]),i=r.join(u.ArgCompositeSeparator),a=n.join(u.ArgCompositeSeparator);return`composite(${i}):${a}`}if(t.hasClassOrSuperclass(M.ClassName)||t.getType().getName()==="BigUint")return`biguint:${BigInt(t.valueOf().toFixed())}`;if(t.hasClassOrSuperclass(qt.ClassName))return`uint8:${t.valueOf().toNumber()}`;if(t.hasClassOrSuperclass(Nt.ClassName))return`uint16:${t.valueOf().toNumber()}`;if(t.hasClassOrSuperclass(Ot.ClassName))return`uint32:${t.valueOf().toNumber()}`;if(t.hasClassOrSuperclass(et.ClassName))return`uint64:${BigInt(t.valueOf().toFixed())}`;if(t.hasClassOrSuperclass(Ut.ClassName))return`string:${t.valueOf()}`;if(t.hasClassOrSuperclass(It.ClassName))return`bool:${t.valueOf()}`;if(t.hasClassOrSuperclass(Wt.ClassName))return`address:${t.valueOf().bech32()}`;if(t.hasClassOrSuperclass(Y.ClassName))return`token:${t.valueOf()}`;if(t.hasClassOrSuperclass(vt.ClassName))return`hex:${t.valueOf().toString("hex")}`;if(t.hasClassOrSuperclass(St.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 xt(...e.split(u.ArgCompositeSeparator).map(r=>this.nativeToType(r)))}if(t==="string")return new Rt;if(t==="uint8")return new Lt;if(t==="uint16")return new $t;if(t==="uint32")return new kt;if(t==="uint64")return new tt;if(t==="biguint")return new z;if(t==="bool")return new At;if(t==="address")return new Ct;if(t==="token")return new X;if(t==="hex")return new bt;if(t==="codemeta")return new Bt;if(t==="esdt"||t==="nft")return new Et("EsdtTokenPayment",[new G("token_identifier","",new X),new G("token_nonce","",new tt),new G("amount","",new z)]);throw new Error(`WarpArgSerializer (nativeToType): Unsupported input type: ${t}`)}stringToNative(t){let e=t.split(u.ArgParamsSeparator),r=e[0],n=e.slice(1).join(u.ArgParamsSeparator);if(r==="null")return[r,null];if(r==="option"){let[i,a]=n.split(u.ArgParamsSeparator);return[`option:${i}`,a||null]}else if(r==="optional"){let[i,a]=n.split(u.ArgParamsSeparator);return[`optional:${i}`,a||null]}else if(r==="list"){let i=n.split(u.ArgParamsSeparator),a=i.slice(0,-1).join(u.ArgParamsSeparator),o=i[i.length-1],c=(o?o.split(","):[]).map(l=>this.stringToNative(`${a}:${l}`)[1]);return[`list:${a}`,c]}else if(r==="variadic"){let i=n.split(u.ArgParamsSeparator),a=i.slice(0,-1).join(u.ArgParamsSeparator),o=i[i.length-1],c=(o?o.split(","):[]).map(l=>this.stringToNative(`${a}:${l}`)[1]);return[`variadic:${a}`,c]}else if(r.startsWith("composite")){let i=r.match(/\(([^)]+)\)/)?.[1]?.split(u.ArgCompositeSeparator),o=n.split(u.ArgCompositeSeparator).map((p,c)=>this.stringToNative(`${i[c]}:${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[i,a,o]=n.split(u.ArgCompositeSeparator);return[r,new Ft({token:new De({identifier:i,nonce:BigInt(a)}),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 h;if(e==="option"){let n=this.stringToTyped(r);return n instanceof h?Z.newMissingTyped(n.getType()):Z.newProvided(n)}if(e==="optional"){let n=this.stringToTyped(r);return n instanceof h?J.newMissing():new J(n.getType(),n)}if(e==="list"){let[n,i]=r.split(Ht,2),o=i.split(",").map(p=>this.stringToTyped(`${n}:${p}`));return new Pt(this.nativeToType(n),o)}if(e==="variadic"){let[n,i]=r.split(Ht,2),o=i.split(",").map(p=>this.stringToTyped(`${n}:${p}`));return new _t(new Dt(this.nativeToType(n)),o)}if(e.startsWith("composite")){let n=e.match(/\(([^)]+)\)/)?.[1],i=r.split(u.ArgCompositeSeparator),a=n.split(u.ArgCompositeSeparator),o=i.map((c,l)=>this.stringToTyped(`${a[l]}:${c}`)),p=o.map(c=>c.getType());return new Vt(new xt(...p),o)}if(e==="string")return r?Ut.fromUTF8(r):new h;if(e==="uint8")return r?new qt(Number(r)):new h;if(e==="uint16")return r?new Nt(Number(r)):new h;if(e==="uint32")return r?new Ot(Number(r)):new h;if(e==="uint64")return r?new et(BigInt(r)):new h;if(e==="biguint")return r?new M(BigInt(r)):new h;if(e==="bool")return r?new It(typeof r=="boolean"?r:r==="true"):new h;if(e==="address")return r?new Wt($e.newFromBech32(r)):new h;if(e==="token")return r?new Y(r):new h;if(e==="hex")return r?vt.fromHex(r):new h;if(e==="codemeta")return new St(Ne.newFromBytes(Uint8Array.from(Buffer.from(r,"hex"))));if(e==="esdt"){let n=r.split(u.ArgCompositeSeparator);return new qe(this.nativeToType("esdt"),[new K(new Y(n[0]),"token_identifier"),new K(new et(BigInt(n[1])),"token_nonce"),new K(new M(BigInt(n[2])),"amount")])}throw new Error(`WarpArgSerializer (stringToTyped): Unsupported input type: ${e}`)}typeToString(t){if(t instanceof Le)return"option:"+this.typeToString(t.getFirstTypeParameter());if(t instanceof Oe)return"optional:"+this.typeToString(t.getFirstTypeParameter());if(t instanceof ke)return"list:"+this.typeToString(t.getFirstTypeParameter());if(t instanceof Dt)return"variadic:"+this.typeToString(t.getFirstTypeParameter());if(t instanceof Rt)return"string";if(t instanceof Lt)return"uint8";if(t instanceof $t)return"uint16";if(t instanceof kt)return"uint32";if(t instanceof tt)return"uint64";if(t instanceof z)return"biguint";if(t instanceof At)return"bool";if(t instanceof Ct)return"address";if(t instanceof X)return"token";if(t instanceof bt)return"hex";if(t instanceof Bt)return"codemeta";if(t instanceof Et&&t.getClassName()==="EsdtTokenPayment")return"esdt";throw new Error(`WarpArgSerializer (typeToString): Unsupported input type: ${t.getClassName()}`)}};var L=class{constructor(t){this.config=t}async getContract(t){try{let r=await g.getConfiguredChainApi(this.config).doGetGeneric(`accounts/${t}/verification`);return{address:t,owner:r.ownerAddress,verified:r.isVerified}}catch(e){return console.error("WarpContractLoader: getContract error",e),null}}async getVerificationInfo(t){try{let r=await g.getConfiguredChainApi(this.config).doGetGeneric(`accounts/${t}/verification`);return{codeHash:r.codeHash,abi:r.source.abi}}catch(e){return console.error("WarpContractLoader: getVerificationInfo error",e),null}}};var zt=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 O,this.contractLoader=new L(t),this.registry=new v(t)}async createTransactionForExecute(t,e){if(!this.config.userAddress)throw new Error("WarpActionExecutor: user address not set");let r=nt.newFromBech32(this.config.userAddress),n=await this.getChainInfoForAction(t),i=new je({chainID:n.chainId}),{destination:a,args:o,value:p,transfers:c,data:l}=await this.getTxComponentsFromInputs(t,e,r),d=o.map(A=>this.serializer.stringToTyped(A));if(t.type==="transfer")return new ze({config:i}).createTransactionForTransfer(r,{receiver:a,nativeAmount:p,tokenTransfers:c,data:l?new Uint8Array(l):void 0});if(t.type==="contract"&&a.isSmartContract())return new He({config:i}).createTransactionForExecute(r,{contract:a,function:"func"in t&&t.func||"",gasLimit:"gasLimit"in t?BigInt(t.gasLimit||0):0n,arguments:d,tokenTransfers:c,nativeTransferAmount:p});throw t.type==="query"?new Error("WarpActionExecutor: Invalid action type for createTransactionForExecute; Use executeQuery instead"):t.type==="collect"?new Error("WarpActionExecutor: Invalid action type for createTransactionForExecute; Use executeCollect instead"):new Error(`WarpActionExecutor: Invalid action type (${t.type})`)}async executeQuery(t,e){if(!t.func)throw new Error("WarpActionExecutor: Function not found");let r=await this.getChainInfoForAction(t),n=await this.getAbiForAction(t),{args:i}=await this.getTxComponentsFromInputs(t,e),a=i.map(S=>this.serializer.stringToTyped(S)),o=g.getChainEntrypoint(r,this.config.env),p=nt.newFromBech32(t.address),c=o.createSmartContractController(n),l=c.createQuery({contract:p,function:t.func,arguments:a}),d=await c.runQuery(l);if(!(d.returnCode==="ok"))throw new Error(`WarpActionExecutor: Query failed with return code ${d.returnCode}`);let B=new _e,R=n.getEndpoint(d.function),q=d.returnDataParts.map(S=>Buffer.from(S));return B.buffersToValues(q,R.output)[0]}async executeCollect(t,e,r){let n=new Headers;n.set("Content-Type","application/json"),n.set("Accept","application/json"),Object.entries(t.destination.headers).forEach(([i,a])=>{n.set(i,a)}),await fetch(t.destination.url,{method:t.destination.method,headers:n,body:JSON.stringify({inputs:e,meta:r})})}async getTxComponentsFromInputs(t,e,r){let n=await this.getResolvedInputs(t,e),i=this.getModifiedInputs(n),a=i.find(y=>y.input.position==="receiver")?.value,o="address"in t?t.address:null,p=a?.split(":")[1]||o||r?.toBech32();if(!p)throw new Error("WarpActionExecutor: Destination/Receiver not provided");let c=nt.newFromBech32(p),l=this.getPreparedArgs(t,i),d=i.find(y=>y.input.position==="value")?.value||null,A="value"in t?t.value:null,B=BigInt(d?.split(":")[1]||A||0),R=i.filter(y=>y.input.position==="transfer"&&y.value).map(y=>y.value),it=[...("transfers"in t?t.transfers:[])?.map(this.toTypedTransfer)||[],...R?.map(y=>this.serializer.stringToNative(y)[1])||[]],S=i.find(y=>y.input.position==="data")?.value,Kt="data"in t?t.data||"":null,at=S||Kt||null,st=at?this.serializer.stringToTyped(at).valueOf():null,Gt=st?Buffer.from(st):null;return{destination:c,args:l,value:B,transfers:it,data:Gt}}async getResolvedInputs(t,e){let r=t.inputs||[],n=await Promise.all(e.map(a=>this.preprocessInput(a))),i=(a,o)=>a.source==="query"?this.serializer.nativeToString(a.type,this.url.searchParams.get(a.name)||""):n[o]||null;return r.map((a,o)=>({input:a,value:i(a,o)}))}getModifiedInputs(t){return t.map((e,r)=>{if(e.input.modifier?.startsWith("scale:")){let[,n]=e.input.modifier.split(":");if(isNaN(Number(n))){let i=Number(t.find(p=>p.input.name===n)?.value?.split(":")[1]);if(!i)throw new Error(`WarpActionExecutor: Exponent value not found for input ${n}`);let a=e.value?.split(":")[1];if(!a)throw new Error("WarpActionExecutor: Scalable value not found");let o=F(a,+i);return{...e,value:`${e.input.type}:${o}`}}else{let i=e.value?.split(":")[1];if(!i)throw new Error("WarpActionExecutor: Scalable value not found");let a=F(i,+n);return{...e,value:`${e.input.type}:${a}`}}}else return e})}async preprocessInput(t){try{let[e,r]=t.split(u.ArgParamsSeparator,2);if(e==="esdt"){let[n,i,a,o]=r.split(u.ArgCompositeSeparator);if(o)return t;let p=new Qt({identifier:n,nonce:BigInt(i)});if(!new Qe().isFungible(p))return t;let d=Tt(n)?.decimals;if(!d){let B=this.config.chainApiUrl||f.Chain.ApiUrl(this.config.env);d=(await(await fetch(`${B}/tokens/${n}`)).json()).decimals}if(!d)throw new Error(`WarpActionExecutor: Decimals not found for token ${n}`);let A=new jt({token:p,amount:F(a,d)});return this.serializer.nativeToString(e,A)+u.ArgCompositeSeparator+d}return t}catch{return t}}getPreparedArgs(t,e){let r="args"in t?t.args||[]:[];return e.forEach(({input:n,value:i})=>{if(!i||!n.position.startsWith("arg:"))return;let a=Number(n.position.split(":")[1])-1;r.splice(a,0,i)}),r}async getChainInfoForAction(t){if(!t.chain)return U(this.config);let e=await this.registry.getChainInfo(t.chain);if(!e)throw new Error(`WarpActionExecutor: Chain info not found for ${t.chain}`);return e}async getAbiForAction(t){if(t.abi)return await this.fetchAbi(t);let e=await this.contractLoader.getVerificationInfo(t.address);if(!e)throw new Error("WarpActionExecutor: Verification info not found");return rt.create(e.abi)}async fetchAbi(t){if(!t.abi)throw new Error("WarpActionExecutor: ABI not found");if(t.abi.startsWith(u.IdentifierType.Hash)){let e=new k(this.config),r=t.abi.split(u.IdentifierParamSeparator)[1],n=await e.createFromTransactionHash(r);if(!n)throw new Error(`WarpActionExecutor: ABI not found for hash: ${t.abi}`);return rt.create(n.content)}else{let r=await(await fetch(t.abi)).json();return rt.create(r)}}toTypedTransfer(t){return new jt({token:new Qt({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.indexUrl)throw new Error("WarpIndex: Index URL is not set");try{let n=await fetch(this.config.indexUrl,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${this.config.indexApiKey}`,...r},body:JSON.stringify({[this.config.indexSearchParamName||"search"]:t,...e})});if(!n.ok)throw new Error(`WarpIndex: search failed with status ${n.status}`);return(await n.json()).hits}catch(n){throw console.error("WarpIndex: Error searching for warps: ",n),n}}};export{mt as BrandBuilder,C as CacheKey,f as Config,k as WarpAbiBuilder,zt as WarpActionExecutor,O as WarpArgSerializer,$ as WarpBuilder,W as WarpCache,u as WarpConstants,L as WarpContractLoader,Mt as WarpIndex,N as WarpLink,I as WarpProtocolVersions,v as WarpRegistry,g as WarpUtils,P as WarpValidator,cn as address,sn as biguint,on as boolean,dn as codemeta,Yr as composite,ln as esdt,T as getChainId,U as getDefaultChainInfo,b as getLatestProtocolIdentifier,Ge as getWarpActionByIndex,un as hex,Zr as list,gn as nothing,Gr as option,Jr as optional,F as shiftBigintBy,tn as string,ct as toPreviewText,ot as toTypedChainInfo,E as toTypedRegistryInfo,pn as token,rn as u16,nn as u32,an as u64,en as u8,Xr as variadic};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vleap/warps",
3
- "version": "1.1.0",
3
+ "version": "1.2.0",
4
4
  "description": "",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",