@d9-network/spec 1.0.2 → 1.1.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/README.md +12 -0
- package/dist/index.cjs +125 -2540
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +78 -1
- package/dist/index.d.mts +78 -1
- package/dist/index.mjs +118 -2540
- package/dist/index.mjs.map +1 -1
- package/package.json +4 -4
package/dist/index.d.cts
CHANGED
|
@@ -8716,5 +8716,82 @@ interface FormatDurationOptions {
|
|
|
8716
8716
|
*/
|
|
8717
8717
|
declare function formatBlockDuration(blocks: number, options?: FormatDurationOptions): string;
|
|
8718
8718
|
//#endregion
|
|
8719
|
-
|
|
8719
|
+
//#region src/utils/bytes.d.ts
|
|
8720
|
+
/**
|
|
8721
|
+
* Concatenate multiple Uint8Arrays into one
|
|
8722
|
+
*
|
|
8723
|
+
* @param arrays - Arrays to concatenate
|
|
8724
|
+
* @returns Combined Uint8Array
|
|
8725
|
+
*
|
|
8726
|
+
* @example
|
|
8727
|
+
* ```ts
|
|
8728
|
+
* const selector = hexToBytes("0xdb20f9f5");
|
|
8729
|
+
* const args = encodeArgs(...);
|
|
8730
|
+
* const callData = concatBytes(selector, args);
|
|
8731
|
+
* ```
|
|
8732
|
+
*/
|
|
8733
|
+
declare function concatBytes(...arrays: Uint8Array[]): Uint8Array;
|
|
8734
|
+
/**
|
|
8735
|
+
* Compare two Uint8Arrays for equality
|
|
8736
|
+
*
|
|
8737
|
+
* @param a - First array
|
|
8738
|
+
* @param b - Second array
|
|
8739
|
+
* @returns True if arrays are equal
|
|
8740
|
+
*/
|
|
8741
|
+
declare function bytesEqual(a: Uint8Array, b: Uint8Array): boolean;
|
|
8742
|
+
/**
|
|
8743
|
+
* Extract a slice from a Uint8Array with bounds checking
|
|
8744
|
+
*
|
|
8745
|
+
* @param data - Source array
|
|
8746
|
+
* @param start - Start index
|
|
8747
|
+
* @param length - Optional length (defaults to rest of array)
|
|
8748
|
+
* @returns Sliced array
|
|
8749
|
+
* @throws If indices are out of bounds
|
|
8750
|
+
*/
|
|
8751
|
+
declare function safeSlice(data: Uint8Array, start: number, length?: number): Uint8Array;
|
|
8752
|
+
/**
|
|
8753
|
+
* Extract selector (first 4 bytes) from call data
|
|
8754
|
+
*
|
|
8755
|
+
* @param callData - The call data (Uint8Array or hex string)
|
|
8756
|
+
* @returns 4-byte selector
|
|
8757
|
+
* @throws If data is less than 4 bytes
|
|
8758
|
+
*
|
|
8759
|
+
* @example
|
|
8760
|
+
* ```ts
|
|
8761
|
+
* const selector = extractSelector(callData);
|
|
8762
|
+
* const selectorHex = bytesToHex(selector); // "0xdb20f9f5"
|
|
8763
|
+
* ```
|
|
8764
|
+
*/
|
|
8765
|
+
declare function extractSelector(callData: Uint8Array | HexString$1): Uint8Array;
|
|
8766
|
+
/**
|
|
8767
|
+
* Extract selector as hex string from call data
|
|
8768
|
+
*
|
|
8769
|
+
* @param callData - The call data (Uint8Array or hex string)
|
|
8770
|
+
* @returns Hex string without 0x prefix (e.g., "db20f9f5")
|
|
8771
|
+
*
|
|
8772
|
+
* @example
|
|
8773
|
+
* ```ts
|
|
8774
|
+
* const selectorHex = extractSelectorHex(callData);
|
|
8775
|
+
* if (selectorHex === "db20f9f5") {
|
|
8776
|
+
* // PSP22::transfer
|
|
8777
|
+
* }
|
|
8778
|
+
* ```
|
|
8779
|
+
*/
|
|
8780
|
+
declare function extractSelectorHex(callData: Uint8Array | HexString$1): string;
|
|
8781
|
+
/**
|
|
8782
|
+
* Normalize a hex string (ensure 0x prefix, lowercase)
|
|
8783
|
+
*
|
|
8784
|
+
* @param hex - Hex string with or without 0x prefix
|
|
8785
|
+
* @returns Normalized hex string with 0x prefix
|
|
8786
|
+
*/
|
|
8787
|
+
declare function normalizeHex(hex: string): HexString$1;
|
|
8788
|
+
/**
|
|
8789
|
+
* Convert a selector string (with or without 0x) to Uint8Array
|
|
8790
|
+
*
|
|
8791
|
+
* @param selector - Selector as hex string
|
|
8792
|
+
* @returns 4-byte Uint8Array
|
|
8793
|
+
*/
|
|
8794
|
+
declare function selectorToBytes(selector: string): Uint8Array;
|
|
8795
|
+
//#endregion
|
|
8796
|
+
export { AbortedError, ArithmeticError, BLOCKS_PER_DAY, BLOCKS_PER_HOUR, BLOCKS_PER_MINUTE, BLOCKS_PER_WEEK, BalanceStatus, BalancesTypesReasons, ContractError, type ContractErrorType, ContractExecutionError, D9, D9Apis, D9CallData, D9Calls, D9Constants, D9DispatchError, D9Errors, D9Events, D9Extensions, D9Queries, D9ViewFns, D9WhitelistEntry, D9_BLOCK_TIME_MS, D9_DECIMALS, D9_SS58_PREFIX, D9_SYMBOL, D9_TOKEN, DecodeError, DigestItem, DispatchClass, EncodeError, FormatBalanceOptions, FormatDurationOptions, GrandpaEquivocation, GrandpaEvent, GrandpaStoredState, type HexString, LangError, MetadataError, MultiAddress, NetworkError, Phase, type PolkadotSigner, type SS58String, SessionEvent, SignerError, Sr25519Keypair, TimeoutError, TokenConfig, TransactionError, TransactionPaymentEvent, TransactionPaymentReleases, TransactionalError, USDT_DECIMALS, USDT_SYMBOL, USDT_TOKEN, WalletAccount, WhitelistEntriesByChain, WhitelistEntry, addressesEqual, blocksToMs, blocksUntil, bytesEqual, bytesToHex, concatBytes, index_d_exports as contracts, createAccountFromMnemonic, createAccountFromPrivateKey, createSr25519SignerFromKeypair, _allDescriptors as d9, estimateBlockAtTime, estimateTimeAtBlock, extractSelector, extractSelectorHex, formatBalance, formatBlockDuration, formatTokenAmount, generateMnemonic, getAddressPrefix, getMetadata, hexToBytes, isContractError, isErrorType, isHexString, isValidAddress, isValidAddressForNetwork, isValidD9Address, mnemonicToMiniSecret, msToBlocks, normalizeHex, parseAmount, safeSlice, selectorToBytes, sr25519AddressFromKeypair, sr25519AddressFromSecretKeyHex, sr25519DeriveFromMiniSecret, sr25519KeypairFromMiniSecret, ss58DecodePublicKey, ss58Reencode, toD9Address, toNetworkAddress, validateMnemonic };
|
|
8720
8797
|
//# sourceMappingURL=index.d.cts.map
|
package/dist/index.d.mts
CHANGED
|
@@ -8716,5 +8716,82 @@ interface FormatDurationOptions {
|
|
|
8716
8716
|
*/
|
|
8717
8717
|
declare function formatBlockDuration(blocks: number, options?: FormatDurationOptions): string;
|
|
8718
8718
|
//#endregion
|
|
8719
|
-
|
|
8719
|
+
//#region src/utils/bytes.d.ts
|
|
8720
|
+
/**
|
|
8721
|
+
* Concatenate multiple Uint8Arrays into one
|
|
8722
|
+
*
|
|
8723
|
+
* @param arrays - Arrays to concatenate
|
|
8724
|
+
* @returns Combined Uint8Array
|
|
8725
|
+
*
|
|
8726
|
+
* @example
|
|
8727
|
+
* ```ts
|
|
8728
|
+
* const selector = hexToBytes("0xdb20f9f5");
|
|
8729
|
+
* const args = encodeArgs(...);
|
|
8730
|
+
* const callData = concatBytes(selector, args);
|
|
8731
|
+
* ```
|
|
8732
|
+
*/
|
|
8733
|
+
declare function concatBytes(...arrays: Uint8Array[]): Uint8Array;
|
|
8734
|
+
/**
|
|
8735
|
+
* Compare two Uint8Arrays for equality
|
|
8736
|
+
*
|
|
8737
|
+
* @param a - First array
|
|
8738
|
+
* @param b - Second array
|
|
8739
|
+
* @returns True if arrays are equal
|
|
8740
|
+
*/
|
|
8741
|
+
declare function bytesEqual(a: Uint8Array, b: Uint8Array): boolean;
|
|
8742
|
+
/**
|
|
8743
|
+
* Extract a slice from a Uint8Array with bounds checking
|
|
8744
|
+
*
|
|
8745
|
+
* @param data - Source array
|
|
8746
|
+
* @param start - Start index
|
|
8747
|
+
* @param length - Optional length (defaults to rest of array)
|
|
8748
|
+
* @returns Sliced array
|
|
8749
|
+
* @throws If indices are out of bounds
|
|
8750
|
+
*/
|
|
8751
|
+
declare function safeSlice(data: Uint8Array, start: number, length?: number): Uint8Array;
|
|
8752
|
+
/**
|
|
8753
|
+
* Extract selector (first 4 bytes) from call data
|
|
8754
|
+
*
|
|
8755
|
+
* @param callData - The call data (Uint8Array or hex string)
|
|
8756
|
+
* @returns 4-byte selector
|
|
8757
|
+
* @throws If data is less than 4 bytes
|
|
8758
|
+
*
|
|
8759
|
+
* @example
|
|
8760
|
+
* ```ts
|
|
8761
|
+
* const selector = extractSelector(callData);
|
|
8762
|
+
* const selectorHex = bytesToHex(selector); // "0xdb20f9f5"
|
|
8763
|
+
* ```
|
|
8764
|
+
*/
|
|
8765
|
+
declare function extractSelector(callData: Uint8Array | HexString$1): Uint8Array;
|
|
8766
|
+
/**
|
|
8767
|
+
* Extract selector as hex string from call data
|
|
8768
|
+
*
|
|
8769
|
+
* @param callData - The call data (Uint8Array or hex string)
|
|
8770
|
+
* @returns Hex string without 0x prefix (e.g., "db20f9f5")
|
|
8771
|
+
*
|
|
8772
|
+
* @example
|
|
8773
|
+
* ```ts
|
|
8774
|
+
* const selectorHex = extractSelectorHex(callData);
|
|
8775
|
+
* if (selectorHex === "db20f9f5") {
|
|
8776
|
+
* // PSP22::transfer
|
|
8777
|
+
* }
|
|
8778
|
+
* ```
|
|
8779
|
+
*/
|
|
8780
|
+
declare function extractSelectorHex(callData: Uint8Array | HexString$1): string;
|
|
8781
|
+
/**
|
|
8782
|
+
* Normalize a hex string (ensure 0x prefix, lowercase)
|
|
8783
|
+
*
|
|
8784
|
+
* @param hex - Hex string with or without 0x prefix
|
|
8785
|
+
* @returns Normalized hex string with 0x prefix
|
|
8786
|
+
*/
|
|
8787
|
+
declare function normalizeHex(hex: string): HexString$1;
|
|
8788
|
+
/**
|
|
8789
|
+
* Convert a selector string (with or without 0x) to Uint8Array
|
|
8790
|
+
*
|
|
8791
|
+
* @param selector - Selector as hex string
|
|
8792
|
+
* @returns 4-byte Uint8Array
|
|
8793
|
+
*/
|
|
8794
|
+
declare function selectorToBytes(selector: string): Uint8Array;
|
|
8795
|
+
//#endregion
|
|
8796
|
+
export { AbortedError, ArithmeticError, BLOCKS_PER_DAY, BLOCKS_PER_HOUR, BLOCKS_PER_MINUTE, BLOCKS_PER_WEEK, BalanceStatus, BalancesTypesReasons, ContractError, type ContractErrorType, ContractExecutionError, D9, D9Apis, D9CallData, D9Calls, D9Constants, D9DispatchError, D9Errors, D9Events, D9Extensions, D9Queries, D9ViewFns, D9WhitelistEntry, D9_BLOCK_TIME_MS, D9_DECIMALS, D9_SS58_PREFIX, D9_SYMBOL, D9_TOKEN, DecodeError, DigestItem, DispatchClass, EncodeError, FormatBalanceOptions, FormatDurationOptions, GrandpaEquivocation, GrandpaEvent, GrandpaStoredState, type HexString, LangError, MetadataError, MultiAddress, NetworkError, Phase, type PolkadotSigner, type SS58String, SessionEvent, SignerError, Sr25519Keypair, TimeoutError, TokenConfig, TransactionError, TransactionPaymentEvent, TransactionPaymentReleases, TransactionalError, USDT_DECIMALS, USDT_SYMBOL, USDT_TOKEN, WalletAccount, WhitelistEntriesByChain, WhitelistEntry, addressesEqual, blocksToMs, blocksUntil, bytesEqual, bytesToHex, concatBytes, index_d_exports as contracts, createAccountFromMnemonic, createAccountFromPrivateKey, createSr25519SignerFromKeypair, _allDescriptors as d9, estimateBlockAtTime, estimateTimeAtBlock, extractSelector, extractSelectorHex, formatBalance, formatBlockDuration, formatTokenAmount, generateMnemonic, getAddressPrefix, getMetadata, hexToBytes, isContractError, isErrorType, isHexString, isValidAddress, isValidAddressForNetwork, isValidD9Address, mnemonicToMiniSecret, msToBlocks, normalizeHex, parseAmount, safeSlice, selectorToBytes, sr25519AddressFromKeypair, sr25519AddressFromSecretKeyHex, sr25519DeriveFromMiniSecret, sr25519KeypairFromMiniSecret, ss58DecodePublicKey, ss58Reencode, toD9Address, toNetworkAddress, validateMnemonic };
|
|
8720
8797
|
//# sourceMappingURL=index.d.mts.map
|