@vleap/warps 2.3.0-alpha.7 → 3.0.0-alpha.100

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.
@@ -0,0 +1,901 @@
1
+ import QRCodeStyling from 'qr-code-styling';
2
+
3
+ type WarpBrand = {
4
+ protocol: string;
5
+ name: string;
6
+ description: string;
7
+ logo: string;
8
+ urls?: WarpBrandUrls;
9
+ colors?: WarpBrandColors;
10
+ cta?: WarpBrandCta;
11
+ meta?: WarpMeta;
12
+ };
13
+ type WarpBrandUrls = {
14
+ web?: string;
15
+ };
16
+ type WarpBrandColors = {
17
+ primary?: string;
18
+ secondary?: string;
19
+ };
20
+ type WarpBrandCta = {
21
+ title: string;
22
+ description: string;
23
+ label: string;
24
+ url: string;
25
+ };
26
+
27
+ type ClientCacheConfig = {
28
+ ttl?: number;
29
+ type?: WarpCacheType;
30
+ };
31
+ type WarpCacheType = 'memory' | 'localStorage';
32
+
33
+ type WarpChainEnv = 'mainnet' | 'testnet' | 'devnet';
34
+ type ProtocolName = 'warp' | 'brand' | 'abi';
35
+
36
+ type WarpTrustStatus = 'unverified' | 'verified' | 'blacklisted';
37
+ type WarpRegistryInfo = {
38
+ hash: string;
39
+ alias: string | null;
40
+ trust: WarpTrustStatus;
41
+ owner: string;
42
+ createdAt: number;
43
+ upgradedAt: number;
44
+ brand: string | null;
45
+ upgrade: string | null;
46
+ };
47
+ type WarpRegistryConfigInfo = {
48
+ unitPrice: bigint;
49
+ admins: string[];
50
+ };
51
+
52
+ type WarpExecution = {
53
+ success: boolean;
54
+ warp: Warp;
55
+ action: number;
56
+ user: string | null;
57
+ txHash: string | null;
58
+ tx: WarpAdapterGenericTransaction | null;
59
+ next: WarpExecutionNextInfo | null;
60
+ values: any[];
61
+ valuesRaw: any[];
62
+ results: WarpExecutionResults;
63
+ messages: WarpExecutionMessages;
64
+ };
65
+ type WarpExecutionNextInfo = {
66
+ identifier: string | null;
67
+ url: string;
68
+ }[];
69
+ type WarpExecutionResults = Record<WarpResultName, any | null>;
70
+ type WarpExecutionMessages = Record<WarpMessageName, string | null>;
71
+
72
+ type ClientIndexConfig = {
73
+ url?: string;
74
+ apiKey?: string;
75
+ searchParamName?: string;
76
+ };
77
+ type WarpSearchResult = {
78
+ hits: WarpSearchHit[];
79
+ };
80
+ type WarpSearchHit = {
81
+ hash: string;
82
+ alias: string;
83
+ name: string;
84
+ title: string;
85
+ description: string;
86
+ preview: string;
87
+ status: string;
88
+ category: string;
89
+ featured: boolean;
90
+ };
91
+
92
+ interface TransformRunner {
93
+ run(code: string, context: any): Promise<any>;
94
+ }
95
+ type ClientTransformConfig = {
96
+ runner?: TransformRunner | null;
97
+ };
98
+
99
+ type WarpUserWallets = Record<WarpChain, string | null>;
100
+ type WarpProviderConfig = Record<WarpChainEnv, string>;
101
+ type WarpClientConfig = {
102
+ env: WarpChainEnv;
103
+ clientUrl?: string;
104
+ currentUrl?: string;
105
+ vars?: Record<string, string | number>;
106
+ user?: {
107
+ wallets?: WarpUserWallets;
108
+ };
109
+ preferences?: {
110
+ explorers?: Record<WarpChain, WarpExplorerName>;
111
+ };
112
+ providers?: Record<WarpChain, WarpProviderConfig>;
113
+ schema?: {
114
+ warp?: string;
115
+ brand?: string;
116
+ };
117
+ cache?: ClientCacheConfig;
118
+ transform?: ClientTransformConfig;
119
+ index?: ClientIndexConfig;
120
+ };
121
+ type WarpCacheConfig = {
122
+ ttl?: number;
123
+ };
124
+ type AdapterFactory = (config: WarpClientConfig, fallback?: Adapter) => Adapter;
125
+ type Adapter = {
126
+ chainInfo: WarpChainInfo;
127
+ prefix: string;
128
+ builder: () => CombinedWarpBuilder;
129
+ executor: AdapterWarpExecutor;
130
+ results: AdapterWarpResults;
131
+ serializer: AdapterWarpSerializer;
132
+ registry: AdapterWarpRegistry;
133
+ explorer: AdapterWarpExplorer;
134
+ abiBuilder: () => AdapterWarpAbiBuilder;
135
+ brandBuilder: () => AdapterWarpBrandBuilder;
136
+ dataLoader: AdapterWarpDataLoader;
137
+ registerTypes?: (typeRegistry: WarpTypeRegistry) => void;
138
+ };
139
+ type WarpAdapterGenericTransaction = any;
140
+ type WarpAdapterGenericRemoteTransaction = any;
141
+ type WarpAdapterGenericValue = any;
142
+ type WarpAdapterGenericType = any;
143
+ interface WarpTypeHandler {
144
+ stringToNative(value: string): any;
145
+ nativeToString(value: any): string;
146
+ }
147
+ interface WarpTypeRegistry {
148
+ registerType(typeName: string, handler: WarpTypeHandler): void;
149
+ hasType(typeName: string): boolean;
150
+ getHandler(typeName: string): WarpTypeHandler | undefined;
151
+ getRegisteredTypes(): string[];
152
+ }
153
+ interface BaseWarpBuilder {
154
+ createFromRaw(encoded: string, validate?: boolean): Promise<Warp>;
155
+ createFromUrl(url: string): Promise<Warp>;
156
+ setName(name: string): BaseWarpBuilder;
157
+ setTitle(title: string): BaseWarpBuilder;
158
+ setDescription(description: string): BaseWarpBuilder;
159
+ setPreview(preview: string): BaseWarpBuilder;
160
+ setActions(actions: WarpAction[]): BaseWarpBuilder;
161
+ addAction(action: WarpAction): BaseWarpBuilder;
162
+ build(): Promise<Warp>;
163
+ }
164
+ interface AdapterWarpBuilder {
165
+ createInscriptionTransaction(warp: Warp): Promise<WarpAdapterGenericTransaction>;
166
+ createFromTransaction(tx: WarpAdapterGenericTransaction, validate?: boolean): Promise<Warp>;
167
+ createFromTransactionHash(hash: string, cache?: WarpCacheConfig): Promise<Warp | null>;
168
+ }
169
+ type CombinedWarpBuilder = AdapterWarpBuilder & BaseWarpBuilder;
170
+ interface AdapterWarpAbiBuilder {
171
+ createInscriptionTransaction(abi: WarpAbiContents): Promise<WarpAdapterGenericTransaction>;
172
+ createFromRaw(encoded: string): Promise<any>;
173
+ createFromTransaction(tx: WarpAdapterGenericTransaction): Promise<any>;
174
+ createFromTransactionHash(hash: string, cache?: WarpCacheConfig): Promise<any | null>;
175
+ }
176
+ interface AdapterWarpBrandBuilder {
177
+ createInscriptionTransaction(brand: WarpBrand): WarpAdapterGenericTransaction;
178
+ createFromTransaction(tx: WarpAdapterGenericTransaction, validate?: boolean): Promise<WarpBrand>;
179
+ createFromTransactionHash(hash: string, cache?: WarpCacheConfig): Promise<WarpBrand | null>;
180
+ }
181
+ interface AdapterWarpExecutor {
182
+ createTransaction(executable: WarpExecutable): Promise<WarpAdapterGenericTransaction>;
183
+ executeQuery(executable: WarpExecutable): Promise<WarpExecution>;
184
+ signMessage(message: string, privateKey: string): Promise<string>;
185
+ }
186
+ interface AdapterWarpResults {
187
+ getTransactionExecutionResults(warp: Warp, tx: WarpAdapterGenericRemoteTransaction): Promise<WarpExecution>;
188
+ }
189
+ interface AdapterWarpSerializer {
190
+ typedToString(value: WarpAdapterGenericValue): string;
191
+ typedToNative(value: WarpAdapterGenericValue): [WarpActionInputType, WarpNativeValue];
192
+ nativeToTyped(type: WarpActionInputType, value: WarpNativeValue): WarpAdapterGenericValue;
193
+ nativeToType(type: BaseWarpActionInputType): WarpAdapterGenericType;
194
+ stringToTyped(value: string): WarpAdapterGenericValue;
195
+ }
196
+ interface AdapterWarpRegistry {
197
+ init(): Promise<void>;
198
+ getRegistryConfig(): WarpRegistryConfigInfo;
199
+ createWarpRegisterTransaction(txHash: string, alias?: string | null, brand?: string | null): Promise<WarpAdapterGenericTransaction>;
200
+ createWarpUnregisterTransaction(txHash: string): Promise<WarpAdapterGenericTransaction>;
201
+ createWarpUpgradeTransaction(alias: string, txHash: string, brand?: string | null): Promise<WarpAdapterGenericTransaction>;
202
+ createWarpAliasSetTransaction(txHash: string, alias: string): Promise<WarpAdapterGenericTransaction>;
203
+ createWarpVerifyTransaction(txHash: string): Promise<WarpAdapterGenericTransaction>;
204
+ createWarpTransferOwnershipTransaction(txHash: string, newOwner: string): Promise<WarpAdapterGenericTransaction>;
205
+ createBrandRegisterTransaction(txHash: string): Promise<WarpAdapterGenericTransaction>;
206
+ createWarpBrandingTransaction(warpHash: string, brandHash: string): Promise<WarpAdapterGenericTransaction>;
207
+ getInfoByAlias(alias: string, cache?: WarpCacheConfig): Promise<{
208
+ registryInfo: WarpRegistryInfo | null;
209
+ brand: WarpBrand | null;
210
+ }>;
211
+ getInfoByHash(hash: string, cache?: WarpCacheConfig): Promise<{
212
+ registryInfo: WarpRegistryInfo | null;
213
+ brand: WarpBrand | null;
214
+ }>;
215
+ getUserWarpRegistryInfos(user?: string): Promise<WarpRegistryInfo[]>;
216
+ getUserBrands(user?: string): Promise<WarpBrand[]>;
217
+ fetchBrand(hash: string, cache?: WarpCacheConfig): Promise<WarpBrand | null>;
218
+ }
219
+ interface AdapterWarpExplorer {
220
+ getAccountUrl(address: string): string;
221
+ getTransactionUrl(hash: string): string;
222
+ getAssetUrl(identifier: string): string;
223
+ getContractUrl(address: string): string;
224
+ }
225
+ interface WarpDataLoaderOptions {
226
+ page?: number;
227
+ size?: number;
228
+ }
229
+ interface AdapterWarpDataLoader {
230
+ getAccount(address: string): Promise<WarpChainAccount>;
231
+ getAccountAssets(address: string): Promise<WarpChainAsset[]>;
232
+ getAsset(identifier: string): Promise<WarpChainAsset | null>;
233
+ getAction(identifier: string, awaitCompleted?: boolean): Promise<WarpChainAction | null>;
234
+ getAccountActions(address: string, options?: WarpDataLoaderOptions): Promise<WarpChainAction[]>;
235
+ }
236
+
237
+ type WarpChainAccount = {
238
+ chain: WarpChain;
239
+ address: string;
240
+ balance: bigint;
241
+ };
242
+ type WarpChainAssetValue = {
243
+ identifier: string;
244
+ amount: bigint;
245
+ };
246
+ type WarpChainAsset = {
247
+ chain: WarpChain;
248
+ identifier: string;
249
+ name: string;
250
+ symbol: string;
251
+ amount?: bigint;
252
+ decimals?: number;
253
+ logoUrl?: string;
254
+ };
255
+ type WarpChainAction = {
256
+ chain: WarpChain;
257
+ id: string;
258
+ sender: string;
259
+ receiver: string;
260
+ value: bigint;
261
+ function: string;
262
+ status: WarpChainActionStatus;
263
+ createdAt: string;
264
+ error?: string | null;
265
+ tx?: WarpAdapterGenericRemoteTransaction | null;
266
+ };
267
+ type WarpChainActionStatus = 'pending' | 'success' | 'failed';
268
+
269
+ type WarpChain = string;
270
+ type WarpExplorerName = string;
271
+ type WarpChainInfo = {
272
+ name: string;
273
+ displayName: string;
274
+ chainId: string;
275
+ blockTime: number;
276
+ addressHrp: string;
277
+ defaultApiUrl: string;
278
+ nativeToken: WarpChainAsset;
279
+ };
280
+ type WarpIdType = 'hash' | 'alias';
281
+ type WarpVarPlaceholder = string;
282
+ type WarpResultName = string;
283
+ type WarpResulutionPath = string;
284
+ type WarpMessageName = string;
285
+ type Warp = {
286
+ protocol: string;
287
+ name: string;
288
+ title: string;
289
+ description: string | null;
290
+ bot?: string;
291
+ preview?: string;
292
+ vars?: Record<WarpVarPlaceholder, string>;
293
+ actions: WarpAction[];
294
+ next?: string;
295
+ results?: Record<WarpResultName, WarpResulutionPath>;
296
+ messages?: Record<WarpMessageName, string>;
297
+ meta?: WarpMeta;
298
+ };
299
+ type WarpMeta = {
300
+ chain: WarpChain;
301
+ hash: string;
302
+ creator: string;
303
+ createdAt: string;
304
+ };
305
+ type WarpAction = WarpTransferAction | WarpContractAction | WarpQueryAction | WarpCollectAction | WarpLinkAction;
306
+ type WarpActionIndex = number;
307
+ type WarpActionType = 'transfer' | 'contract' | 'query' | 'collect' | 'link';
308
+ type WarpTransferAction = {
309
+ type: WarpActionType;
310
+ chain?: WarpChain;
311
+ label: string;
312
+ description?: string | null;
313
+ address?: string;
314
+ data?: string;
315
+ value?: string;
316
+ transfers?: string[];
317
+ inputs?: WarpActionInput[];
318
+ next?: string;
319
+ };
320
+ type WarpContractAction = {
321
+ type: WarpActionType;
322
+ chain?: WarpChain;
323
+ label: string;
324
+ description?: string | null;
325
+ address?: string;
326
+ func?: string | null;
327
+ args?: string[];
328
+ value?: string;
329
+ gasLimit: number;
330
+ transfers?: string[];
331
+ abi?: string;
332
+ inputs?: WarpActionInput[];
333
+ next?: string;
334
+ };
335
+ type WarpQueryAction = {
336
+ type: WarpActionType;
337
+ chain?: WarpChain;
338
+ label: string;
339
+ description?: string | null;
340
+ address?: string;
341
+ func?: string;
342
+ args?: string[];
343
+ abi?: string;
344
+ inputs?: WarpActionInput[];
345
+ next?: string;
346
+ };
347
+ type WarpCollectAction = {
348
+ type: WarpActionType;
349
+ chain?: WarpChain;
350
+ label: string;
351
+ description?: string | null;
352
+ destination: {
353
+ url: string;
354
+ method?: 'GET' | 'POST' | 'PUT' | 'DELETE';
355
+ headers?: Record<string, string>;
356
+ };
357
+ inputs?: WarpActionInput[];
358
+ next?: string;
359
+ };
360
+ type WarpLinkAction = {
361
+ type: WarpActionType;
362
+ chain?: WarpChain;
363
+ label: string;
364
+ description?: string | null;
365
+ url: string;
366
+ inputs?: WarpActionInput[];
367
+ };
368
+ type WarpActionInputSource = 'field' | 'query' | 'user:wallet' | 'hidden';
369
+ type BaseWarpActionInputType = 'string' | 'uint8' | 'uint16' | 'uint32' | 'uint64' | 'uint128' | 'uint256' | 'biguint' | 'bool' | 'address' | 'hex' | string;
370
+ type WarpActionInputType = string;
371
+ type WarpNativeValue = string | number | bigint | boolean | WarpChainAssetValue | null | WarpNativeValue[];
372
+ type WarpActionInputPosition = 'receiver' | 'value' | 'transfer' | `arg:${1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10}` | 'data' | 'chain' | `payload:${string}`;
373
+ type WarpActionInputModifier = 'scale';
374
+ type WarpActionInput = {
375
+ name: string;
376
+ as?: string;
377
+ description?: string | null;
378
+ bot?: string;
379
+ type: WarpActionInputType;
380
+ position?: WarpActionInputPosition;
381
+ source: WarpActionInputSource;
382
+ required?: boolean;
383
+ min?: number | WarpVarPlaceholder;
384
+ max?: number | WarpVarPlaceholder;
385
+ pattern?: string;
386
+ patternDescription?: string;
387
+ options?: string[] | {
388
+ [key: string]: string;
389
+ };
390
+ modifier?: string;
391
+ default?: string | number | boolean;
392
+ };
393
+ type ResolvedInput = {
394
+ input: WarpActionInput;
395
+ value: string | null;
396
+ };
397
+ type WarpContract = {
398
+ address: string;
399
+ owner: string;
400
+ verified: boolean;
401
+ };
402
+ type WarpContractVerification = {
403
+ codeHash: string;
404
+ abi: object;
405
+ };
406
+ type WarpExecutable = {
407
+ chain: WarpChainInfo;
408
+ warp: Warp;
409
+ action: number;
410
+ destination: string;
411
+ args: string[];
412
+ value: bigint;
413
+ transfers: WarpChainAssetValue[];
414
+ data: string | null;
415
+ resolvedInputs: ResolvedInput[];
416
+ };
417
+
418
+ type WarpAbi = {
419
+ protocol: string;
420
+ content: WarpAbiContents;
421
+ meta?: WarpMeta;
422
+ };
423
+ type WarpAbiContents = {
424
+ name?: string;
425
+ constructor?: any;
426
+ upgradeConstructor?: any;
427
+ endpoints?: any[];
428
+ types?: Record<string, any>;
429
+ events?: any[];
430
+ };
431
+
432
+ declare enum WarpChainName {
433
+ Multiversx = "multiversx",
434
+ Vibechain = "vibechain",
435
+ Sui = "sui",
436
+ Ethereum = "ethereum",
437
+ Base = "base",
438
+ Arbitrum = "arbitrum",
439
+ Somnia = "somnia",
440
+ Fastset = "fastset"
441
+ }
442
+ declare const WarpConstants: {
443
+ HttpProtocolPrefix: string;
444
+ IdentifierParamName: string;
445
+ IdentifierParamSeparator: string[];
446
+ IdentifierParamSeparatorDefault: string;
447
+ IdentifierChainDefault: string;
448
+ IdentifierType: {
449
+ Alias: WarpIdType;
450
+ Hash: WarpIdType;
451
+ };
452
+ Globals: {
453
+ UserWallet: {
454
+ Placeholder: string;
455
+ Accessor: (bag: InterpolationBag) => string | null | undefined;
456
+ };
457
+ ChainApiUrl: {
458
+ Placeholder: string;
459
+ Accessor: (bag: InterpolationBag) => string;
460
+ };
461
+ ChainAddressHrp: {
462
+ Placeholder: string;
463
+ Accessor: (bag: InterpolationBag) => string;
464
+ };
465
+ };
466
+ Vars: {
467
+ Query: string;
468
+ Env: string;
469
+ };
470
+ ArgParamsSeparator: string;
471
+ ArgCompositeSeparator: string;
472
+ Transform: {
473
+ Prefix: string;
474
+ };
475
+ Source: {
476
+ UserWallet: string;
477
+ };
478
+ Position: {
479
+ Payload: string;
480
+ };
481
+ };
482
+ declare const WarpInputTypes: {
483
+ Option: string;
484
+ Optional: string;
485
+ List: string;
486
+ Variadic: string;
487
+ Composite: string;
488
+ String: string;
489
+ U8: string;
490
+ U16: string;
491
+ U32: string;
492
+ U64: string;
493
+ U128: string;
494
+ U256: string;
495
+ Biguint: string;
496
+ Boolean: string;
497
+ Address: string;
498
+ Asset: string;
499
+ Hex: string;
500
+ };
501
+
502
+ type InterpolationBag = {
503
+ config: WarpClientConfig;
504
+ chain: WarpChainName;
505
+ chainInfo: WarpChainInfo;
506
+ };
507
+
508
+ declare const WarpProtocolVersions: {
509
+ Warp: string;
510
+ Brand: string;
511
+ Abi: string;
512
+ };
513
+ declare const WarpConfig: {
514
+ LatestWarpSchemaUrl: string;
515
+ LatestBrandSchemaUrl: string;
516
+ DefaultClientUrl: (env: WarpChainEnv) => "https://usewarp.to" | "https://testnet.usewarp.to" | "https://devnet.usewarp.to";
517
+ DefaultChainPrefix: string;
518
+ SuperClientUrls: string[];
519
+ AvailableActionInputSources: WarpActionInputSource[];
520
+ AvailableActionInputTypes: WarpActionInputType[];
521
+ AvailableActionInputPositions: WarpActionInputPosition[];
522
+ };
523
+
524
+ interface CryptoProvider {
525
+ getRandomBytes(size: number): Promise<Uint8Array>;
526
+ }
527
+ declare class BrowserCryptoProvider implements CryptoProvider {
528
+ getRandomBytes(size: number): Promise<Uint8Array>;
529
+ }
530
+ declare class NodeCryptoProvider implements CryptoProvider {
531
+ getRandomBytes(size: number): Promise<Uint8Array>;
532
+ }
533
+ declare function getCryptoProvider(): CryptoProvider;
534
+ declare function setCryptoProvider(provider: CryptoProvider): void;
535
+ declare function getRandomBytes(size: number, cryptoProvider?: CryptoProvider): Promise<Uint8Array>;
536
+ declare function bytesToHex(bytes: Uint8Array): string;
537
+ declare function bytesToBase64(bytes: Uint8Array): string;
538
+ declare function getRandomHex(length: number, cryptoProvider?: CryptoProvider): Promise<string>;
539
+ declare function testCryptoAvailability(): Promise<{
540
+ randomBytes: boolean;
541
+ environment: 'browser' | 'nodejs' | 'unknown';
542
+ }>;
543
+ declare function createCryptoProvider(): CryptoProvider;
544
+
545
+ declare const findWarpAdapterForChain: (chain: WarpChain, adapters: Adapter[]) => Adapter;
546
+ declare const findWarpAdapterByPrefix: (prefix: string, adapters: Adapter[]) => Adapter;
547
+ declare const getLatestProtocolIdentifier: (name: ProtocolName) => string;
548
+ declare const getWarpActionByIndex: (warp: Warp, index: number) => WarpAction;
549
+ declare const findWarpExecutableAction: (warp: Warp) => {
550
+ action: WarpAction;
551
+ actionIndex: WarpActionIndex;
552
+ };
553
+ declare const shiftBigintBy: (value: bigint | string | number, decimals: number) => bigint;
554
+ declare const toPreviewText: (text: string, maxChars?: number) => string;
555
+ declare const replacePlaceholders: (message: string, bag: Record<string, any>) => string;
556
+ declare const applyResultsToMessages: (warp: Warp, results: Record<string, any>) => Record<string, string>;
557
+
558
+ declare const getWarpInfoFromIdentifier: (prefixedIdentifier: string) => {
559
+ chainPrefix: string;
560
+ type: WarpIdType;
561
+ identifier: string;
562
+ identifierBase: string;
563
+ } | null;
564
+ declare const extractIdentifierInfoFromUrl: (url: string) => {
565
+ chainPrefix: string;
566
+ type: WarpIdType;
567
+ identifier: string;
568
+ identifierBase: string;
569
+ } | null;
570
+
571
+ /**
572
+ * Splits an input string into type and value, using only the first colon as separator.
573
+ * This handles cases where the value itself contains colons (like SUI token IDs).
574
+ */
575
+ declare const splitInput: (input: string) => [WarpActionInputType, string];
576
+ declare const hasInputPrefix: (input: string) => boolean;
577
+
578
+ declare const getNextInfo: (config: WarpClientConfig, adapters: Adapter[], warp: Warp, actionIndex: number, results: WarpExecutionResults) => WarpExecutionNextInfo | null;
579
+
580
+ /**
581
+ * Builds a nested payload object from a position string and field value.
582
+ * Position strings should be in format: "payload:path.to.nested.location"
583
+ *
584
+ * @param position - The position string defining where to place the value
585
+ * @param fieldName - The field name to use for the value
586
+ * @param value - The value to place at the position
587
+ * @returns A nested object structure or flat object if position doesn't start with 'payload:'
588
+ */
589
+ declare function buildNestedPayload(position: string, fieldName: string, value: any): any;
590
+ /**
591
+ * Recursively merges a source object into a target object and returns the merged result.
592
+ * Existing nested objects are merged recursively, primitive values are overwritten.
593
+ * Does not mutate the original target or source objects.
594
+ *
595
+ * @param target - The target object to merge into
596
+ * @param source - The source object to merge from
597
+ * @returns A new object with the merged result
598
+ */
599
+ declare function mergeNestedPayload(target: any, source: any): any;
600
+
601
+ declare const getProviderUrl: (config: WarpClientConfig, chain: WarpChain, env: WarpChainEnv, defaultProvider: string) => string;
602
+ declare const getProviderConfig: (config: WarpClientConfig, chain: WarpChain) => WarpProviderConfig | undefined;
603
+
604
+ declare const extractCollectResults: (warp: Warp, response: any, actionIndex: number, inputs: ResolvedInput[], transformRunner?: TransformRunner | null) => Promise<{
605
+ values: any[];
606
+ results: WarpExecutionResults;
607
+ }>;
608
+ declare const evaluateResultsCommon: (warp: Warp, baseResults: WarpExecutionResults, actionIndex: number, inputs: ResolvedInput[], transformRunner?: TransformRunner | null) => Promise<WarpExecutionResults>;
609
+ /**
610
+ * Parses out[N] notation and returns the action index (1-based) or null if invalid.
611
+ * Also handles plain "out" which defaults to action index 1.
612
+ */
613
+ declare const parseResultsOutIndex: (resultPath: string) => number | null;
614
+
615
+ /**
616
+ * Signing utilities for creating and validating signed messages
617
+ * Works with any crypto provider or uses automatic detection
618
+ */
619
+
620
+ interface SignableMessage {
621
+ wallet: string;
622
+ nonce: string;
623
+ expiresAt: string;
624
+ purpose: string;
625
+ }
626
+ type HttpAuthHeaders = Record<string, string> & {
627
+ 'X-Signer-Wallet': string;
628
+ 'X-Signer-Signature': string;
629
+ 'X-Signer-Nonce': string;
630
+ 'X-Signer-ExpiresAt': string;
631
+ };
632
+ /**
633
+ * Creates a signable message with standard security fields
634
+ * This can be used for any type of proof or authentication
635
+ */
636
+ declare function createSignableMessage(walletAddress: string, purpose: string, cryptoProvider?: CryptoProvider, expiresInMinutes?: number): Promise<{
637
+ message: string;
638
+ nonce: string;
639
+ expiresAt: string;
640
+ }>;
641
+ /**
642
+ * Creates a signable message for HTTP authentication
643
+ * This is a convenience function that uses the standard format
644
+ */
645
+ declare function createAuthMessage(walletAddress: string, appName: string, cryptoProvider?: CryptoProvider, purpose?: string): Promise<{
646
+ message: string;
647
+ nonce: string;
648
+ expiresAt: string;
649
+ }>;
650
+ /**
651
+ * Creates HTTP authentication headers from a signature
652
+ */
653
+ declare function createAuthHeaders(walletAddress: string, signature: string, nonce: string, expiresAt: string): HttpAuthHeaders;
654
+ /**
655
+ * Creates HTTP authentication headers for a wallet using the provided signing function
656
+ */
657
+ declare function createHttpAuthHeaders(walletAddress: string, signMessage: (message: string) => Promise<string>, appName: string, cryptoProvider?: CryptoProvider): Promise<HttpAuthHeaders>;
658
+ /**
659
+ * Validates a signed message by checking expiration
660
+ */
661
+ declare function validateSignedMessage(expiresAt: string): boolean;
662
+ /**
663
+ * Parses a signed message to extract its components
664
+ */
665
+ declare function parseSignedMessage(message: string): SignableMessage;
666
+
667
+ declare const string: (value: string) => string;
668
+ declare const u8: (value: number) => string;
669
+ declare const u16: (value: number) => string;
670
+ declare const u32: (value: number) => string;
671
+ declare const u64: (value: bigint | number) => string;
672
+ declare const biguint: (value: bigint | string | number) => string;
673
+ declare const boolean: (value: boolean) => string;
674
+ declare const address: (value: string) => string;
675
+ declare const asset: (value: WarpChainAsset) => string;
676
+ declare const hex: (value: string) => string;
677
+
678
+ declare class WarpBrandBuilder {
679
+ private config;
680
+ private pendingBrand;
681
+ constructor(config: WarpClientConfig);
682
+ createFromRaw(encoded: string, validateSchema?: boolean): Promise<WarpBrand>;
683
+ setName(name: string): WarpBrandBuilder;
684
+ setDescription(description: string): WarpBrandBuilder;
685
+ setLogo(logo: string): WarpBrandBuilder;
686
+ setUrls(urls: WarpBrandUrls): WarpBrandBuilder;
687
+ setColors(colors: WarpBrandColors): WarpBrandBuilder;
688
+ setCta(cta: WarpBrandCta): WarpBrandBuilder;
689
+ build(): Promise<WarpBrand>;
690
+ private ensure;
691
+ private ensureValidSchema;
692
+ }
693
+
694
+ declare class WarpBuilder implements BaseWarpBuilder {
695
+ protected readonly config: WarpClientConfig;
696
+ private pendingWarp;
697
+ constructor(config: WarpClientConfig);
698
+ createFromRaw(encoded: string, validate?: boolean): Promise<Warp>;
699
+ createFromUrl(url: string): Promise<Warp>;
700
+ setName(name: string): WarpBuilder;
701
+ setTitle(title: string): WarpBuilder;
702
+ setDescription(description: string): WarpBuilder;
703
+ setPreview(preview: string): WarpBuilder;
704
+ setActions(actions: WarpAction[]): WarpBuilder;
705
+ addAction(action: WarpAction): WarpBuilder;
706
+ build(): Promise<Warp>;
707
+ getDescriptionPreview(description: string, maxChars?: number): string;
708
+ private ensure;
709
+ private validate;
710
+ }
711
+
712
+ declare const CacheTtl: {
713
+ OneMinute: number;
714
+ OneHour: number;
715
+ OneDay: number;
716
+ OneWeek: number;
717
+ OneMonth: number;
718
+ OneYear: number;
719
+ };
720
+ declare const WarpCacheKey: {
721
+ Warp: (env: WarpChainEnv, id: string) => string;
722
+ WarpAbi: (env: WarpChainEnv, id: string) => string;
723
+ WarpExecutable: (env: WarpChainEnv, id: string, action: number) => string;
724
+ RegistryInfo: (env: WarpChainEnv, id: string) => string;
725
+ Brand: (env: WarpChainEnv, hash: string) => string;
726
+ Asset: (env: WarpChainEnv, chain: string, identifier: string) => string;
727
+ };
728
+ declare class WarpCache {
729
+ private strategy;
730
+ constructor(type?: WarpCacheType);
731
+ private selectStrategy;
732
+ set<T>(key: string, value: T, ttl: number): void;
733
+ get<T>(key: string): T | null;
734
+ forget(key: string): void;
735
+ clear(): void;
736
+ }
737
+
738
+ type ExecutionHandlers = {
739
+ onExecuted?: (result: WarpExecution) => void;
740
+ onError?: (params: {
741
+ message: string;
742
+ }) => void;
743
+ onSignRequest?: (params: {
744
+ message: string;
745
+ chain: WarpChainInfo;
746
+ }) => Promise<string>;
747
+ };
748
+ declare class WarpExecutor {
749
+ private config;
750
+ private adapters;
751
+ private handlers?;
752
+ private factory;
753
+ private serializer;
754
+ constructor(config: WarpClientConfig, adapters: Adapter[], handlers?: ExecutionHandlers | undefined);
755
+ execute(warp: Warp, inputs: string[], env?: Record<string, any>): Promise<{
756
+ tx: WarpAdapterGenericTransaction | null;
757
+ chain: WarpChainInfo | null;
758
+ }>;
759
+ evaluateResults(warp: Warp, chain: WarpChain, tx: WarpAdapterGenericRemoteTransaction): Promise<void>;
760
+ private executeCollect;
761
+ }
762
+
763
+ declare class WarpFactory {
764
+ private config;
765
+ private adapters;
766
+ private url;
767
+ private serializer;
768
+ private cache;
769
+ constructor(config: WarpClientConfig, adapters: Adapter[]);
770
+ createExecutable(warp: Warp, actionIndex: number, inputs: string[], envs?: Record<string, any>): Promise<WarpExecutable>;
771
+ getChainInfoForAction(action: WarpAction, inputs?: string[]): Promise<WarpChainInfo>;
772
+ getResolvedInputs(chain: WarpChain, action: WarpAction, inputArgs: string[]): Promise<ResolvedInput[]>;
773
+ getModifiedInputs(inputs: ResolvedInput[]): ResolvedInput[];
774
+ preprocessInput(chain: WarpChain, input: string): Promise<string>;
775
+ private getDestinationFromAction;
776
+ private getPreparedArgs;
777
+ private tryGetChainFromInputs;
778
+ }
779
+
780
+ declare class WarpIndex {
781
+ private config;
782
+ constructor(config: WarpClientConfig);
783
+ search(query: string, params?: Record<string, any>, headers?: Record<string, string>): Promise<WarpSearchHit[]>;
784
+ }
785
+
786
+ declare class WarpLinkBuilder {
787
+ private readonly config;
788
+ private readonly adapters;
789
+ constructor(config: WarpClientConfig, adapters: Adapter[]);
790
+ isValid(url: string): boolean;
791
+ build(chain: WarpChain, type: WarpIdType, id: string): string;
792
+ buildFromPrefixedIdentifier(identifier: string): string | null;
793
+ generateQrCode(chain: WarpChain, type: WarpIdType, id: string, size?: number, background?: string, color?: string, logoColor?: string): QRCodeStyling;
794
+ }
795
+
796
+ type DetectionResult = {
797
+ match: boolean;
798
+ url: string;
799
+ warp: Warp | null;
800
+ chain: WarpChain | null;
801
+ registryInfo: WarpRegistryInfo | null;
802
+ brand: WarpBrand | null;
803
+ };
804
+ type DetectionResultFromHtml = {
805
+ match: boolean;
806
+ results: {
807
+ url: string;
808
+ warp: Warp;
809
+ }[];
810
+ };
811
+ declare class WarpLinkDetecter {
812
+ private config;
813
+ private adapters;
814
+ constructor(config: WarpClientConfig, adapters: Adapter[]);
815
+ isValid(url: string): boolean;
816
+ detectFromHtml(content: string): Promise<DetectionResultFromHtml>;
817
+ detect(url: string, cache?: WarpCacheConfig): Promise<DetectionResult>;
818
+ }
819
+
820
+ declare class WarpClient {
821
+ private readonly config;
822
+ private adapters;
823
+ constructor(config: WarpClientConfig, adapters: Adapter[]);
824
+ getConfig(): WarpClientConfig;
825
+ getAdapters(): Adapter[];
826
+ addAdapter(adapter: Adapter): WarpClient;
827
+ createExecutor(handlers?: ExecutionHandlers): WarpExecutor;
828
+ detectWarp(urlOrId: string, cache?: WarpCacheConfig): Promise<DetectionResult>;
829
+ executeWarp(warpOrIdentifierOrUrl: string | Warp, inputs: string[], handlers?: ExecutionHandlers, options?: {
830
+ cache?: WarpCacheConfig;
831
+ }): Promise<{
832
+ tx: WarpAdapterGenericTransaction | null;
833
+ chain: WarpChainInfo | null;
834
+ evaluateResults: (remoteTx: WarpAdapterGenericRemoteTransaction) => Promise<void>;
835
+ }>;
836
+ createInscriptionTransaction(chain: WarpChain, warp: Warp): WarpAdapterGenericTransaction;
837
+ createFromTransaction(chain: WarpChain, tx: WarpAdapterGenericRemoteTransaction, validate?: boolean): Promise<Warp>;
838
+ createFromTransactionHash(hash: string, cache?: WarpCacheConfig): Promise<Warp | null>;
839
+ signMessage(chain: WarpChain, message: string, privateKey: string): Promise<string>;
840
+ getExplorer(chain: WarpChain): AdapterWarpExplorer;
841
+ getResults(chain: WarpChain): AdapterWarpResults;
842
+ getRegistry(chain: WarpChain): Promise<AdapterWarpRegistry>;
843
+ getDataLoader(chain: WarpChain): AdapterWarpDataLoader;
844
+ get factory(): WarpFactory;
845
+ get index(): WarpIndex;
846
+ get linkBuilder(): WarpLinkBuilder;
847
+ createBuilder(chain: WarpChain): CombinedWarpBuilder;
848
+ createAbiBuilder(chain: WarpChain): AdapterWarpAbiBuilder;
849
+ createBrandBuilder(chain: WarpChain): AdapterWarpBrandBuilder;
850
+ }
851
+
852
+ declare class WarpInterpolator {
853
+ private config;
854
+ private adapter;
855
+ constructor(config: WarpClientConfig, adapter: Adapter);
856
+ apply(config: WarpClientConfig, warp: Warp, envs?: Record<string, any>): Promise<Warp>;
857
+ applyGlobals(config: WarpClientConfig, warp: Warp): Promise<Warp>;
858
+ applyVars(config: WarpClientConfig, warp: Warp, envs?: Record<string, any>): Warp;
859
+ private applyRootGlobals;
860
+ private applyActionGlobals;
861
+ }
862
+
863
+ declare class WarpLogger {
864
+ private static isTestEnv;
865
+ static debug(...args: any[]): void;
866
+ static info(...args: any[]): void;
867
+ static warn(...args: any[]): void;
868
+ static error(...args: any[]): void;
869
+ }
870
+
871
+ declare class WarpSerializer {
872
+ private typeRegistry;
873
+ setTypeRegistry(typeRegistry: WarpTypeRegistry): void;
874
+ nativeToString(type: WarpActionInputType, value: WarpNativeValue): string;
875
+ stringToNative(value: string): [WarpActionInputType, WarpNativeValue];
876
+ }
877
+
878
+ declare class WarpTypeRegistryImpl implements WarpTypeRegistry {
879
+ private typeHandlers;
880
+ registerType(typeName: string, handler: WarpTypeHandler): void;
881
+ hasType(typeName: string): boolean;
882
+ getHandler(typeName: string): WarpTypeHandler | undefined;
883
+ getRegisteredTypes(): string[];
884
+ }
885
+
886
+ type ValidationResult = {
887
+ valid: boolean;
888
+ errors: ValidationError[];
889
+ };
890
+ type ValidationError = string;
891
+ declare class WarpValidator {
892
+ private config;
893
+ constructor(config: WarpClientConfig);
894
+ validate(warp: Warp): Promise<ValidationResult>;
895
+ private validateMaxOneValuePosition;
896
+ private validateVariableNamesAndResultNamesUppercase;
897
+ private validateAbiIsSetIfApplicable;
898
+ private validateSchema;
899
+ }
900
+
901
+ export { type Adapter, type AdapterFactory, type AdapterWarpAbiBuilder, type AdapterWarpBrandBuilder, type AdapterWarpBuilder, type AdapterWarpDataLoader, type AdapterWarpExecutor, type AdapterWarpExplorer, type AdapterWarpRegistry, type AdapterWarpResults, type AdapterWarpSerializer, type BaseWarpActionInputType, type BaseWarpBuilder, BrowserCryptoProvider, CacheTtl, type ClientIndexConfig, type ClientTransformConfig, type CombinedWarpBuilder, type CryptoProvider, type DetectionResult, type DetectionResultFromHtml, type ExecutionHandlers, type HttpAuthHeaders, type InterpolationBag, NodeCryptoProvider, type ProtocolName, type ResolvedInput, type SignableMessage, type TransformRunner, type Warp, type WarpAbi, type WarpAbiContents, type WarpAction, type WarpActionIndex, type WarpActionInput, type WarpActionInputModifier, type WarpActionInputPosition, type WarpActionInputSource, type WarpActionInputType, type WarpActionType, type WarpAdapterGenericRemoteTransaction, type WarpAdapterGenericTransaction, type WarpAdapterGenericType, type WarpAdapterGenericValue, type WarpBrand, WarpBrandBuilder, type WarpBrandColors, type WarpBrandCta, type WarpBrandUrls, WarpBuilder, WarpCache, type WarpCacheConfig, WarpCacheKey, type WarpChain, type WarpChainAccount, type WarpChainAction, type WarpChainActionStatus, type WarpChainAsset, type WarpChainAssetValue, type WarpChainEnv, type WarpChainInfo, WarpChainName, WarpClient, type WarpClientConfig, type WarpCollectAction, WarpConfig, WarpConstants, type WarpContract, type WarpContractAction, type WarpContractVerification, type WarpDataLoaderOptions, type WarpExecutable, type WarpExecution, type WarpExecutionMessages, type WarpExecutionNextInfo, type WarpExecutionResults, WarpExecutor, type WarpExplorerName, WarpFactory, type WarpIdType, WarpIndex, WarpInputTypes, WarpInterpolator, type WarpLinkAction, WarpLinkBuilder, WarpLinkDetecter, WarpLogger, type WarpMessageName, type WarpMeta, type WarpNativeValue, WarpProtocolVersions, type WarpProviderConfig, type WarpQueryAction, type WarpRegistryConfigInfo, type WarpRegistryInfo, type WarpResultName, type WarpResulutionPath, type WarpSearchHit, type WarpSearchResult, WarpSerializer, type WarpTransferAction, type WarpTrustStatus, type WarpTypeHandler, type WarpTypeRegistry, WarpTypeRegistryImpl, type WarpUserWallets, WarpValidator, type WarpVarPlaceholder, address, applyResultsToMessages, asset, biguint, boolean, buildNestedPayload, bytesToBase64, bytesToHex, createAuthHeaders, createAuthMessage, createCryptoProvider, createHttpAuthHeaders, createSignableMessage, evaluateResultsCommon, extractCollectResults, extractIdentifierInfoFromUrl, findWarpAdapterByPrefix, findWarpAdapterForChain, findWarpExecutableAction, getCryptoProvider, getLatestProtocolIdentifier, getNextInfo, getProviderConfig, getProviderUrl, getRandomBytes, getRandomHex, getWarpActionByIndex, getWarpInfoFromIdentifier, hasInputPrefix, hex, mergeNestedPayload, parseResultsOutIndex, parseSignedMessage, replacePlaceholders, setCryptoProvider, shiftBigintBy, splitInput, string, testCryptoAvailability, toPreviewText, u16, u32, u64, u8, validateSignedMessage };