@d9-network/ink 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/chunk-BiucMVzj.mjs +18 -0
- package/dist/index-DgYVGyHC.d.cts +593 -0
- package/dist/index-Doyoeg38.d.mts +591 -0
- package/dist/index.cjs +41 -208
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +10 -415
- package/dist/index.d.mts +10 -415
- package/dist/index.mjs +29 -202
- package/dist/index.mjs.map +1 -1
- package/dist/indexer/index.cjs +11 -0
- package/dist/indexer/index.d.cts +2 -0
- package/dist/indexer/index.d.mts +2 -0
- package/dist/indexer/index.mjs +3 -0
- package/dist/indexer-Buc6flPW.cjs +572 -0
- package/dist/indexer-Buc6flPW.cjs.map +1 -0
- package/dist/indexer-C-EZviUx.mjs +449 -0
- package/dist/indexer-C-EZviUx.mjs.map +1 -0
- package/package.json +11 -1
package/dist/index.d.cts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { A as RawContractCall, C as isMessageCall, D as CallFilterOptions, E as isCallType, M as TypedContractCall, O as ExtractMessageLabels, S as getSelectorForLabel, T as ContractCallParser, _ as SelectorInfo, b as getAllSelectors, g as PSP22_SELECTORS, h as PSP22SelectorKey, j as TypedCallFilterOptions, k as MessageInfo, t as index_d_exports, v as buildLabelMap, w as isPSP22Call, x as getLabelForSelector, y as buildSelectorMap } from "./index-DgYVGyHC.cjs";
|
|
1
2
|
import { Binary, Enum, HexString, PolkadotClient, PolkadotSigner, SS58String } from "polkadot-api";
|
|
2
3
|
import { Event, InkCallableDescriptor, InkDescriptors, InkMetadata, InkStorageDescriptor } from "@polkadot-api/ink-contracts";
|
|
3
4
|
import { Observable } from "rxjs";
|
|
@@ -17,7 +18,14 @@ interface RawContractEvent {
|
|
|
17
18
|
blockHash: string;
|
|
18
19
|
/** Event index in block */
|
|
19
20
|
eventIndex: number;
|
|
20
|
-
/**
|
|
21
|
+
/**
|
|
22
|
+
* Extrinsic index that caused this event (if in ApplyExtrinsic phase)
|
|
23
|
+
*
|
|
24
|
+
* This is extracted from the event's `phase.value` when `phase.type === "ApplyExtrinsic"`.
|
|
25
|
+
* Useful for indexers to correlate events with their originating transactions.
|
|
26
|
+
*/
|
|
27
|
+
extrinsicIndex?: number;
|
|
28
|
+
/** Contract address that emitted the event (always in D9 format) */
|
|
21
29
|
contractAddress: SS58String;
|
|
22
30
|
/** Event data (SCALE encoded) */
|
|
23
31
|
data: Uint8Array;
|
|
@@ -302,86 +310,6 @@ declare function extractContractEmittedData(event: ChainEventRecord): {
|
|
|
302
310
|
topics: Uint8Array[];
|
|
303
311
|
} | null;
|
|
304
312
|
//#endregion
|
|
305
|
-
//#region src/call-types.d.ts
|
|
306
|
-
/**
|
|
307
|
-
* Raw call data from a transaction
|
|
308
|
-
*/
|
|
309
|
-
interface RawContractCall {
|
|
310
|
-
/** The call data (SCALE encoded selector + args) */
|
|
311
|
-
data: Uint8Array;
|
|
312
|
-
/** Contract address being called */
|
|
313
|
-
contractAddress?: SS58String;
|
|
314
|
-
/** Transaction hash (if from a transaction) */
|
|
315
|
-
txHash?: string;
|
|
316
|
-
/** Block number (if from a transaction) */
|
|
317
|
-
blockNumber?: number;
|
|
318
|
-
/** Block hash (if from a transaction) */
|
|
319
|
-
blockHash?: string;
|
|
320
|
-
}
|
|
321
|
-
/**
|
|
322
|
-
* Extract message labels as a union type from InkCallableDescriptor
|
|
323
|
-
* e.g. ExtractMessageLabels<Messages> = "PSP22::transfer" | "PSP22::balance_of" | ...
|
|
324
|
-
*/
|
|
325
|
-
type ExtractMessageLabels<M$1 extends InkCallableDescriptor> = keyof M$1 & string;
|
|
326
|
-
/**
|
|
327
|
-
* Type-safe parsed contract call with discriminated union
|
|
328
|
-
* Enables type narrowing: `if (call.type === "PSP22::transfer") { call.args.to }`
|
|
329
|
-
*/
|
|
330
|
-
type TypedContractCall<M$1 extends InkCallableDescriptor> = { [K in keyof M$1 & string]: {
|
|
331
|
-
/** Call type/method name (discriminant for type narrowing) */
|
|
332
|
-
type: K;
|
|
333
|
-
/** Decoded call arguments (type-safe based on method) */
|
|
334
|
-
args: M$1[K]["message"];
|
|
335
|
-
/** 4-byte selector */
|
|
336
|
-
selector: Uint8Array;
|
|
337
|
-
/** Original raw call data */
|
|
338
|
-
raw: RawContractCall;
|
|
339
|
-
} }[keyof M$1 & string];
|
|
340
|
-
/**
|
|
341
|
-
* Call filter options
|
|
342
|
-
*/
|
|
343
|
-
interface CallFilterOptions {
|
|
344
|
-
/** Message labels to include (e.g., ["PSP22::transfer", "PSP22::approve"]) */
|
|
345
|
-
messageLabels?: string[];
|
|
346
|
-
}
|
|
347
|
-
/**
|
|
348
|
-
* Type-safe call filter options with literal message labels
|
|
349
|
-
* Provides compile-time validation of message label names
|
|
350
|
-
*
|
|
351
|
-
* @typeParam M - The InkCallableDescriptor type (message definitions)
|
|
352
|
-
*
|
|
353
|
-
* @example
|
|
354
|
-
* ```ts
|
|
355
|
-
* const options: TypedCallFilterOptions<typeof contracts.usdt.__types.messages> = {
|
|
356
|
-
* messageLabels: ["PSP22::transfer", "PSP22::approve"], // Must be valid message names
|
|
357
|
-
* };
|
|
358
|
-
* ```
|
|
359
|
-
*/
|
|
360
|
-
interface TypedCallFilterOptions<M$1 extends InkCallableDescriptor> {
|
|
361
|
-
/** Message labels to include (type-safe) */
|
|
362
|
-
messageLabels?: Array<ExtractMessageLabels<M$1>>;
|
|
363
|
-
}
|
|
364
|
-
/**
|
|
365
|
-
* Message info from metadata
|
|
366
|
-
*/
|
|
367
|
-
interface MessageInfo {
|
|
368
|
-
/** Message label (e.g., "PSP22::transfer") */
|
|
369
|
-
label: string;
|
|
370
|
-
/** 4-byte selector */
|
|
371
|
-
selector: Uint8Array;
|
|
372
|
-
/** Whether the message is mutable (writes state) */
|
|
373
|
-
mutates: boolean;
|
|
374
|
-
/** Whether the message is payable */
|
|
375
|
-
payable: boolean;
|
|
376
|
-
/** Argument definitions */
|
|
377
|
-
args: Array<{
|
|
378
|
-
label: string;
|
|
379
|
-
type: {
|
|
380
|
-
type: number;
|
|
381
|
-
};
|
|
382
|
-
}>;
|
|
383
|
-
}
|
|
384
|
-
//#endregion
|
|
385
313
|
//#region src/message-builder.d.ts
|
|
386
314
|
/**
|
|
387
315
|
* Message attributes from metadata
|
|
@@ -1393,182 +1321,6 @@ declare function createNativeTransferStream(client: PolkadotClient, getEvents: (
|
|
|
1393
1321
|
blockHash: string;
|
|
1394
1322
|
}>;
|
|
1395
1323
|
//#endregion
|
|
1396
|
-
//#region src/calls.d.ts
|
|
1397
|
-
/**
|
|
1398
|
-
* Type-safe call parser for a specific contract
|
|
1399
|
-
*
|
|
1400
|
-
* @typeParam S - The storage descriptor type
|
|
1401
|
-
* @typeParam M - The InkCallableDescriptor type (message definitions)
|
|
1402
|
-
* @typeParam C - The constructors descriptor type
|
|
1403
|
-
* @typeParam E - The events Enum type
|
|
1404
|
-
*/
|
|
1405
|
-
declare class ContractCallParser<S extends InkStorageDescriptor = InkStorageDescriptor, M$1 extends InkCallableDescriptor = InkCallableDescriptor, C extends InkCallableDescriptor = InkCallableDescriptor, E extends Event = Event> {
|
|
1406
|
-
private messageDecoders;
|
|
1407
|
-
private selectorToLabel;
|
|
1408
|
-
private metadata;
|
|
1409
|
-
constructor(descriptor: InkDescriptors<S, M$1, C, E>);
|
|
1410
|
-
/**
|
|
1411
|
-
* Parse raw call data into a type-safe contract call
|
|
1412
|
-
*
|
|
1413
|
-
* @param callData - The raw call data (selector + encoded args) or RawContractCall
|
|
1414
|
-
* @returns Parsed call or null if cannot parse
|
|
1415
|
-
*
|
|
1416
|
-
* @example
|
|
1417
|
-
* ```ts
|
|
1418
|
-
* const call = parser.parseCall(callData);
|
|
1419
|
-
* if (call?.type === "PSP22::transfer") {
|
|
1420
|
-
* // call.args is typed as { to: SS58String; value: bigint; data: Uint8Array }
|
|
1421
|
-
* console.log(call.args.to);
|
|
1422
|
-
* }
|
|
1423
|
-
* ```
|
|
1424
|
-
*/
|
|
1425
|
-
parseCall(callData: Uint8Array | RawContractCall): TypedContractCall<M$1> | null;
|
|
1426
|
-
/**
|
|
1427
|
-
* Parse multiple calls and optionally filter by message labels
|
|
1428
|
-
*
|
|
1429
|
-
* @param calls - Array of raw call data
|
|
1430
|
-
* @param options - Filter options
|
|
1431
|
-
* @returns Array of parsed calls
|
|
1432
|
-
*/
|
|
1433
|
-
parseCalls(calls: Array<Uint8Array | RawContractCall>, options?: CallFilterOptions): TypedContractCall<M$1>[];
|
|
1434
|
-
/**
|
|
1435
|
-
* Filter calls by specific type with proper type narrowing
|
|
1436
|
-
*
|
|
1437
|
-
* This method provides better type safety than parseCalls with messageLabels
|
|
1438
|
-
* because TypeScript can narrow the return type to only the specified call type.
|
|
1439
|
-
*
|
|
1440
|
-
* @param calls - Array of raw call data
|
|
1441
|
-
* @param label - The message label to filter by
|
|
1442
|
-
* @returns Array of calls narrowed to the specific type
|
|
1443
|
-
*
|
|
1444
|
-
* @example
|
|
1445
|
-
* ```ts
|
|
1446
|
-
* const transfers = parser.filterByType(callDataArray, "PSP22::transfer");
|
|
1447
|
-
*
|
|
1448
|
-
* for (const t of transfers) {
|
|
1449
|
-
* // t.args is fully typed as PSP22::transfer args
|
|
1450
|
-
* console.log(t.args.to, t.args.value);
|
|
1451
|
-
* }
|
|
1452
|
-
* ```
|
|
1453
|
-
*/
|
|
1454
|
-
filterByType<L extends string>(calls: Array<Uint8Array | RawContractCall>, label: L): Array<TypedContractCall<M$1> & {
|
|
1455
|
-
type: L;
|
|
1456
|
-
}>;
|
|
1457
|
-
/**
|
|
1458
|
-
* Get information about a message by label
|
|
1459
|
-
*/
|
|
1460
|
-
getMessageInfo(label: string): MessageInfo | null;
|
|
1461
|
-
/**
|
|
1462
|
-
* Get all available message labels
|
|
1463
|
-
*/
|
|
1464
|
-
getMessageLabels(): string[];
|
|
1465
|
-
/**
|
|
1466
|
-
* Check if a selector matches a specific message
|
|
1467
|
-
*/
|
|
1468
|
-
matchesMessage(selector: Uint8Array, label: string): boolean;
|
|
1469
|
-
/**
|
|
1470
|
-
* Get selector for a message label
|
|
1471
|
-
*
|
|
1472
|
-
* @param label - Message label (e.g., "PSP22::transfer")
|
|
1473
|
-
* @returns Selector as Uint8Array or null if not found
|
|
1474
|
-
*
|
|
1475
|
-
* @example
|
|
1476
|
-
* ```ts
|
|
1477
|
-
* const selector = parser.getSelector("PSP22::transfer");
|
|
1478
|
-
* // selector is Uint8Array([0xdb, 0x20, 0xf9, 0xf5])
|
|
1479
|
-
* ```
|
|
1480
|
-
*/
|
|
1481
|
-
getSelector(label: string): Uint8Array | null;
|
|
1482
|
-
/**
|
|
1483
|
-
* Get selector as hex string for a message label
|
|
1484
|
-
*
|
|
1485
|
-
* @param label - Message label (e.g., "PSP22::transfer")
|
|
1486
|
-
* @returns Selector hex string (without 0x) or null if not found
|
|
1487
|
-
*
|
|
1488
|
-
* @example
|
|
1489
|
-
* ```ts
|
|
1490
|
-
* const selectorHex = parser.getSelectorHex("PSP22::transfer");
|
|
1491
|
-
* // selectorHex is "db20f9f5"
|
|
1492
|
-
* ```
|
|
1493
|
-
*/
|
|
1494
|
-
getSelectorHex(label: string): string | null;
|
|
1495
|
-
/**
|
|
1496
|
-
* Get the label for a selector
|
|
1497
|
-
*
|
|
1498
|
-
* @param selector - Selector as Uint8Array or hex string (with or without 0x)
|
|
1499
|
-
* @returns Message label or null if not found
|
|
1500
|
-
*
|
|
1501
|
-
* @example
|
|
1502
|
-
* ```ts
|
|
1503
|
-
* const label = parser.getLabel("db20f9f5");
|
|
1504
|
-
* // label is "PSP22::transfer"
|
|
1505
|
-
*
|
|
1506
|
-
* // Also works with Uint8Array
|
|
1507
|
-
* const label2 = parser.getLabel(callData.slice(0, 4));
|
|
1508
|
-
* ```
|
|
1509
|
-
*/
|
|
1510
|
-
getLabel(selector: Uint8Array | string): string | null;
|
|
1511
|
-
/**
|
|
1512
|
-
* Get all selector-to-label mappings
|
|
1513
|
-
*
|
|
1514
|
-
* @returns Map of selector hex (without 0x) -> label
|
|
1515
|
-
*
|
|
1516
|
-
* @example
|
|
1517
|
-
* ```ts
|
|
1518
|
-
* const map = parser.getSelectorMap();
|
|
1519
|
-
* for (const [selectorHex, label] of map) {
|
|
1520
|
-
* console.log(`${selectorHex} -> ${label}`);
|
|
1521
|
-
* }
|
|
1522
|
-
* ```
|
|
1523
|
-
*/
|
|
1524
|
-
getSelectorMap(): Map<string, string>;
|
|
1525
|
-
/**
|
|
1526
|
-
* Check if a selector exists in this contract
|
|
1527
|
-
*
|
|
1528
|
-
* @param selector - Selector to check (Uint8Array or hex string)
|
|
1529
|
-
* @returns True if selector is valid for this contract
|
|
1530
|
-
*
|
|
1531
|
-
* @example
|
|
1532
|
-
* ```ts
|
|
1533
|
-
* if (parser.hasSelector("db20f9f5")) {
|
|
1534
|
-
* // This selector is valid for this contract
|
|
1535
|
-
* }
|
|
1536
|
-
* ```
|
|
1537
|
-
*/
|
|
1538
|
-
hasSelector(selector: Uint8Array | string): boolean;
|
|
1539
|
-
/**
|
|
1540
|
-
* Normalize selector to hex string (without 0x prefix)
|
|
1541
|
-
*/
|
|
1542
|
-
private normalizeSelector;
|
|
1543
|
-
}
|
|
1544
|
-
/**
|
|
1545
|
-
* Type guard for narrowing call types
|
|
1546
|
-
*
|
|
1547
|
-
* Use this function when you have a `TypedContractCall` and need to
|
|
1548
|
-
* narrow it to a specific call type. This is useful when the type
|
|
1549
|
-
* information is lost (e.g., after serialization or in generic functions).
|
|
1550
|
-
*
|
|
1551
|
-
* @typeParam M - The InkCallableDescriptor type (message definitions)
|
|
1552
|
-
* @typeParam L - The specific message label to check
|
|
1553
|
-
* @param call - The call to check
|
|
1554
|
-
* @param label - The message label to match
|
|
1555
|
-
* @returns True if the call type matches the label
|
|
1556
|
-
*
|
|
1557
|
-
* @example
|
|
1558
|
-
* ```ts
|
|
1559
|
-
* const call = parser.parseCall(callData);
|
|
1560
|
-
*
|
|
1561
|
-
* if (call && isCallType(call, "PSP22::transfer")) {
|
|
1562
|
-
* // TypeScript knows call.args is transfer args
|
|
1563
|
-
* console.log(call.args.to);
|
|
1564
|
-
* console.log(call.args.value);
|
|
1565
|
-
* }
|
|
1566
|
-
* ```
|
|
1567
|
-
*/
|
|
1568
|
-
declare function isCallType<M$1 extends InkCallableDescriptor, L extends ExtractMessageLabels<M$1>>(call: TypedContractCall<M$1>, label: L): call is Extract<TypedContractCall<M$1>, {
|
|
1569
|
-
type: L;
|
|
1570
|
-
}>;
|
|
1571
|
-
//#endregion
|
|
1572
1324
|
//#region src/infer-types.d.ts
|
|
1573
1325
|
/**
|
|
1574
1326
|
* Infer ContractCallParser type from a contract descriptor
|
|
@@ -1637,163 +1389,6 @@ type ContractEventParserOf<D> = D extends InkDescriptors<infer S, infer M, infer
|
|
|
1637
1389
|
*/
|
|
1638
1390
|
type D9InkContractOf<D> = D extends InkDescriptors<infer _S, infer M, infer _C, infer E> ? D9InkContract<M extends InkCallableDescriptor ? M : InkCallableDescriptor, E extends Event ? E : Event> : never;
|
|
1639
1391
|
//#endregion
|
|
1640
|
-
//#region src/selectors.d.ts
|
|
1641
|
-
/**
|
|
1642
|
-
* Information about a contract message selector
|
|
1643
|
-
*/
|
|
1644
|
-
interface SelectorInfo {
|
|
1645
|
-
/** Message label (e.g., "PSP22::transfer") */
|
|
1646
|
-
label: string;
|
|
1647
|
-
/** 4-byte selector */
|
|
1648
|
-
selector: Uint8Array;
|
|
1649
|
-
/** Hex string without 0x prefix (e.g., "db20f9f5") */
|
|
1650
|
-
selectorHex: string;
|
|
1651
|
-
/** Whether the message mutates state */
|
|
1652
|
-
mutates: boolean;
|
|
1653
|
-
/** Whether the message is payable */
|
|
1654
|
-
payable: boolean;
|
|
1655
|
-
}
|
|
1656
|
-
/**
|
|
1657
|
-
* PSP22 standard selectors for quick reference
|
|
1658
|
-
*
|
|
1659
|
-
* These are derived from the PSP22 standard and are consistent across implementations.
|
|
1660
|
-
* Use these when you need to quickly check if call data matches a specific PSP22 method.
|
|
1661
|
-
*
|
|
1662
|
-
* @example
|
|
1663
|
-
* ```ts
|
|
1664
|
-
* import { PSP22_SELECTORS, extractSelectorHex } from "@d9-network/ink";
|
|
1665
|
-
*
|
|
1666
|
-
* const selectorHex = extractSelectorHex(callData);
|
|
1667
|
-
* if (selectorHex === PSP22_SELECTORS.transfer) {
|
|
1668
|
-
* // This is a PSP22::transfer call
|
|
1669
|
-
* }
|
|
1670
|
-
* ```
|
|
1671
|
-
*/
|
|
1672
|
-
declare const PSP22_SELECTORS: {
|
|
1673
|
-
/** PSP22::total_supply - 0x162df8c2 */
|
|
1674
|
-
readonly totalSupply: "162df8c2";
|
|
1675
|
-
/** PSP22::balance_of - 0x6568382f */
|
|
1676
|
-
readonly balanceOf: "6568382f";
|
|
1677
|
-
/** PSP22::allowance - 0x4d47d921 */
|
|
1678
|
-
readonly allowance: "4d47d921";
|
|
1679
|
-
/** PSP22::transfer - 0xdb20f9f5 */
|
|
1680
|
-
readonly transfer: "db20f9f5";
|
|
1681
|
-
/** PSP22::transfer_from - 0x54b3c76e */
|
|
1682
|
-
readonly transferFrom: "54b3c76e";
|
|
1683
|
-
/** PSP22::approve - 0xb20f1bbd */
|
|
1684
|
-
readonly approve: "b20f1bbd";
|
|
1685
|
-
/** PSP22::increase_allowance - 0x96d6b57a */
|
|
1686
|
-
readonly increaseAllowance: "96d6b57a";
|
|
1687
|
-
/** PSP22::decrease_allowance - 0xfecb57d5 */
|
|
1688
|
-
readonly decreaseAllowance: "fecb57d5";
|
|
1689
|
-
};
|
|
1690
|
-
/**
|
|
1691
|
-
* PSP22 selector type for type safety
|
|
1692
|
-
*/
|
|
1693
|
-
type PSP22SelectorKey = keyof typeof PSP22_SELECTORS;
|
|
1694
|
-
/**
|
|
1695
|
-
* Build a selector lookup map from contract metadata
|
|
1696
|
-
*
|
|
1697
|
-
* @param metadata - Contract metadata
|
|
1698
|
-
* @returns Map of selector hex (without 0x) -> SelectorInfo
|
|
1699
|
-
*
|
|
1700
|
-
* @example
|
|
1701
|
-
* ```ts
|
|
1702
|
-
* import { contracts } from "@d9-network/spec";
|
|
1703
|
-
* import { buildSelectorMap } from "@d9-network/ink";
|
|
1704
|
-
*
|
|
1705
|
-
* const selectors = buildSelectorMap(contracts.usdt.metadata);
|
|
1706
|
-
* const info = selectors.get("db20f9f5");
|
|
1707
|
-
* if (info) {
|
|
1708
|
-
* console.log(info.label); // "PSP22::transfer"
|
|
1709
|
-
* }
|
|
1710
|
-
* ```
|
|
1711
|
-
*/
|
|
1712
|
-
declare function buildSelectorMap(metadata: InkMetadata): Map<string, SelectorInfo>;
|
|
1713
|
-
/**
|
|
1714
|
-
* Build a reverse lookup map (label -> selector info)
|
|
1715
|
-
*
|
|
1716
|
-
* @param metadata - Contract metadata
|
|
1717
|
-
* @returns Map of label -> SelectorInfo
|
|
1718
|
-
*
|
|
1719
|
-
* @example
|
|
1720
|
-
* ```ts
|
|
1721
|
-
* const labelMap = buildLabelMap(contracts.usdt.metadata);
|
|
1722
|
-
* const info = labelMap.get("PSP22::transfer");
|
|
1723
|
-
* console.log(info?.selectorHex); // "db20f9f5"
|
|
1724
|
-
* ```
|
|
1725
|
-
*/
|
|
1726
|
-
declare function buildLabelMap(metadata: InkMetadata): Map<string, SelectorInfo>;
|
|
1727
|
-
/**
|
|
1728
|
-
* Get selector for a message label
|
|
1729
|
-
*
|
|
1730
|
-
* @param metadata - Contract metadata
|
|
1731
|
-
* @param label - Message label (e.g., "PSP22::transfer")
|
|
1732
|
-
* @returns Selector info or null if not found
|
|
1733
|
-
*
|
|
1734
|
-
* @example
|
|
1735
|
-
* ```ts
|
|
1736
|
-
* const info = getSelectorForLabel(contracts.usdt.metadata, "PSP22::transfer");
|
|
1737
|
-
* console.log(info?.selectorHex); // "db20f9f5"
|
|
1738
|
-
* ```
|
|
1739
|
-
*/
|
|
1740
|
-
declare function getSelectorForLabel(metadata: InkMetadata, label: string): SelectorInfo | null;
|
|
1741
|
-
/**
|
|
1742
|
-
* Get message label for a selector
|
|
1743
|
-
*
|
|
1744
|
-
* @param metadata - Contract metadata
|
|
1745
|
-
* @param selector - Selector as Uint8Array or hex string (with or without 0x)
|
|
1746
|
-
* @returns Selector info or null if not found
|
|
1747
|
-
*
|
|
1748
|
-
* @example
|
|
1749
|
-
* ```ts
|
|
1750
|
-
* const info = getLabelForSelector(contracts.usdt.metadata, "db20f9f5");
|
|
1751
|
-
* console.log(info?.label); // "PSP22::transfer"
|
|
1752
|
-
*
|
|
1753
|
-
* // Also works with Uint8Array
|
|
1754
|
-
* const info2 = getLabelForSelector(contracts.usdt.metadata, callData.slice(0, 4));
|
|
1755
|
-
* ```
|
|
1756
|
-
*/
|
|
1757
|
-
declare function getLabelForSelector(metadata: InkMetadata, selector: Uint8Array | string): SelectorInfo | null;
|
|
1758
|
-
/**
|
|
1759
|
-
* Check if call data matches a specific message
|
|
1760
|
-
*
|
|
1761
|
-
* @param metadata - Contract metadata
|
|
1762
|
-
* @param callData - Call data bytes or hex string
|
|
1763
|
-
* @param label - Message label to check
|
|
1764
|
-
* @returns True if the call data selector matches the label
|
|
1765
|
-
*
|
|
1766
|
-
* @example
|
|
1767
|
-
* ```ts
|
|
1768
|
-
* if (isMessageCall(contracts.usdt.metadata, callData, "PSP22::transfer")) {
|
|
1769
|
-
* // This is a transfer call
|
|
1770
|
-
* }
|
|
1771
|
-
* ```
|
|
1772
|
-
*/
|
|
1773
|
-
declare function isMessageCall(metadata: InkMetadata, callData: Uint8Array | string, label: string): boolean;
|
|
1774
|
-
/**
|
|
1775
|
-
* Check if call data matches a PSP22 method
|
|
1776
|
-
*
|
|
1777
|
-
* @param callData - Call data bytes or hex string
|
|
1778
|
-
* @param method - PSP22 method name (e.g., "transfer", "transferFrom")
|
|
1779
|
-
* @returns True if the call data selector matches the PSP22 method
|
|
1780
|
-
*
|
|
1781
|
-
* @example
|
|
1782
|
-
* ```ts
|
|
1783
|
-
* if (isPSP22Call(callData, "transfer")) {
|
|
1784
|
-
* // This is a PSP22::transfer call
|
|
1785
|
-
* }
|
|
1786
|
-
* ```
|
|
1787
|
-
*/
|
|
1788
|
-
declare function isPSP22Call(callData: Uint8Array | string, method: PSP22SelectorKey): boolean;
|
|
1789
|
-
/**
|
|
1790
|
-
* Get all selectors from contract metadata
|
|
1791
|
-
*
|
|
1792
|
-
* @param metadata - Contract metadata
|
|
1793
|
-
* @returns Array of SelectorInfo for all messages
|
|
1794
|
-
*/
|
|
1795
|
-
declare function getAllSelectors(metadata: InkMetadata): SelectorInfo[];
|
|
1796
|
-
//#endregion
|
|
1797
1392
|
//#region src/extrinsic-parser.d.ts
|
|
1798
1393
|
/**
|
|
1799
1394
|
* Raw extrinsic data that may contain a contract call
|
|
@@ -2128,5 +1723,5 @@ declare function compareGasWeight(a: GasWeight, b: GasWeight): -1 | 0 | 1;
|
|
|
2128
1723
|
*/
|
|
2129
1724
|
declare function gasExceedsLimit(gas: GasWeight, limit: GasWeight): boolean;
|
|
2130
1725
|
//#endregion
|
|
2131
|
-
export { AbortedError, type BalancesTransferChainEvent, type BlockHeader, type CallFilterOptions, type ChainEventRecord, ContractCallParser, type ContractCallParserOf, type ContractCallResult, type ContractCalledChainEvent, type ContractCalledValue, type ContractEmittedChainEvent, type ContractEmittedValue, ContractError, type ContractErrorType, ContractEventParser, type ContractEventParserOf, ContractExecutionError, type ContractMessageBuilder, type ContractStorage, type ContractsCallValue, type CreateContractOptions, type CreateD9InkSdkOptions, type D9InkContract, type D9InkContractFromDescriptor, type D9InkContractOf, type D9InkSdk, type D9InkSdkOptions, type D9InkSdkWithRpc, DecodeError, type DecodedContractEvent, EncodeError, EstimatedCost, type EventFilterOptions, type EventSubscriptionOptions, type ExtractEnumDef, type ExtractEventLabels, type ExtractMessageLabels, type ExtrinsicCall, ExtrinsicParser, type ExtrinsicParserOptions, FormattedGasInfo, type GasInfo, GasWeight, type InferEvents, type InferMessages, InkCodecs, LangError, type MessageAttributes, type MessageInfo, MetadataError, NetworkError, type PSP22SelectorKey, PSP22_SELECTORS, type ParsedContractExtrinsic, type QueryOptions, type QueryResult, type QuerySuccessValue, type RawContractCall, type RawContractEvent, type RawExtrinsic, type ResponseDecoder, type RuntimeVersion, type SelectorInfo, type SendOptions, type SendableTransaction, SignerError, type StorageChangeSet, type StorageDepositInfo, type SubstrateRpcMethods, type SystemHealth, TimeoutError, TransactionError, type TxResult, type TypedCallFilterOptions, type TypedContractCall, type TypedContractEvent, type TypedEventFilterOptions, type TypedMessage, type TypedRpc, applyGasMargin, buildAllEventDecoders, buildAllMessageDecoders, buildEventDecoder, buildLabelMap, buildMessageDecoder, buildSelectorMap, compareGasWeight, createAsciiEventTopic, createCodecRegistry, createContractEventStream, createD9InkContract, createD9InkSdk, createExtrinsicParser, createMessageBuilder, createNativeTransferStream, createPSP22TransferStream, createTypedRpc, decodeContractCallResult, decodeInkValue, encodeCall, encodeContractCall, encodeContractCallWithLimits, estimateTransactionCost, extractContractEmittedData, formatGasInfo, gasExceedsLimit, getAllSelectors, getEventSignature, getLabelForSelector, getSelectorForLabel, isApplyExtrinsicPhase, isBalancesTransferEvent, isCallType, isContractCalledEvent, isContractEmittedEvent, isContractError, isErrorType, isEventType, isLangError, isMessageCall, isPSP22Call, unwrapInkResult };
|
|
1726
|
+
export { AbortedError, type BalancesTransferChainEvent, type BlockHeader, type CallFilterOptions, type ChainEventRecord, ContractCallParser, type ContractCallParserOf, type ContractCallResult, type ContractCalledChainEvent, type ContractCalledValue, type ContractEmittedChainEvent, type ContractEmittedValue, ContractError, type ContractErrorType, ContractEventParser, type ContractEventParserOf, ContractExecutionError, type ContractMessageBuilder, type ContractStorage, type ContractsCallValue, type CreateContractOptions, type CreateD9InkSdkOptions, type D9InkContract, type D9InkContractFromDescriptor, type D9InkContractOf, type D9InkSdk, type D9InkSdkOptions, type D9InkSdkWithRpc, DecodeError, type DecodedContractEvent, EncodeError, EstimatedCost, type EventFilterOptions, type EventSubscriptionOptions, type ExtractEnumDef, type ExtractEventLabels, type ExtractMessageLabels, type ExtrinsicCall, ExtrinsicParser, type ExtrinsicParserOptions, FormattedGasInfo, type GasInfo, GasWeight, type InferEvents, type InferMessages, InkCodecs, LangError, type MessageAttributes, type MessageInfo, MetadataError, NetworkError, type PSP22SelectorKey, PSP22_SELECTORS, type ParsedContractExtrinsic, type QueryOptions, type QueryResult, type QuerySuccessValue, type RawContractCall, type RawContractEvent, type RawExtrinsic, type ResponseDecoder, type RuntimeVersion, type SelectorInfo, type SendOptions, type SendableTransaction, SignerError, type StorageChangeSet, type StorageDepositInfo, type SubstrateRpcMethods, type SystemHealth, TimeoutError, TransactionError, type TxResult, type TypedCallFilterOptions, type TypedContractCall, type TypedContractEvent, type TypedEventFilterOptions, type TypedMessage, type TypedRpc, applyGasMargin, buildAllEventDecoders, buildAllMessageDecoders, buildEventDecoder, buildLabelMap, buildMessageDecoder, buildSelectorMap, compareGasWeight, createAsciiEventTopic, createCodecRegistry, createContractEventStream, createD9InkContract, createD9InkSdk, createExtrinsicParser, createMessageBuilder, createNativeTransferStream, createPSP22TransferStream, createTypedRpc, decodeContractCallResult, decodeInkValue, encodeCall, encodeContractCall, encodeContractCallWithLimits, estimateTransactionCost, extractContractEmittedData, formatGasInfo, gasExceedsLimit, getAllSelectors, getEventSignature, getLabelForSelector, getSelectorForLabel, index_d_exports as indexer, isApplyExtrinsicPhase, isBalancesTransferEvent, isCallType, isContractCalledEvent, isContractEmittedEvent, isContractError, isErrorType, isEventType, isLangError, isMessageCall, isPSP22Call, unwrapInkResult };
|
|
2132
1727
|
//# sourceMappingURL=index.d.cts.map
|