@d9-network/spec 0.0.13 → 0.0.14

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.cts CHANGED
@@ -8965,6 +8965,18 @@ declare class ContractEventParser<S extends InkStorageDescriptor = InkStorageDes
8965
8965
  * ```
8966
8966
  */
8967
8967
  parseEvent(chainEvent: unknown): TypedContractEvent<E> | null;
8968
+ /**
8969
+ * Extract event label from ASCII-encoded topic (D9 chain format)
8970
+ *
8971
+ * D9 chain uses a format where:
8972
+ * - First byte is 0x00 (null)
8973
+ * - Remaining 31 bytes are ASCII characters of `ContractName::EventLabel`
8974
+ * - Total is exactly 32 bytes (truncated/padded as needed)
8975
+ *
8976
+ * @param topic - The 32-byte topic from the event
8977
+ * @returns The extracted event label, or null if not in ASCII format
8978
+ */
8979
+ private extractEventLabelFromAsciiTopic;
8968
8980
  /**
8969
8981
  * Filter a batch of events and return type-safe results
8970
8982
  *
@@ -9009,10 +9021,6 @@ declare class ContractEventParser<S extends InkStorageDescriptor = InkStorageDes
9009
9021
  * Compare two Uint8Arrays for equality
9010
9022
  */
9011
9023
  private bytesEqual;
9012
- /**
9013
- * Build event signature map from metadata
9014
- */
9015
- private static buildEventSignatureMap;
9016
9024
  }
9017
9025
  /**
9018
9026
  * Type guard for narrowing event types
@@ -9191,5 +9199,304 @@ declare function createAccountFromPrivateKey(options: {
9191
9199
  keyType: "sr25519" | "ed25519" | "secp256k1";
9192
9200
  }): WalletAccount;
9193
9201
  //#endregion
9194
- export { ArithmeticError, BalanceStatus, BalancesTypesReasons, ContractEventParser, CreateD9SdkClientOptions, D9, D9Apis, D9CallData, D9Calls, D9Constants, D9DispatchError, D9Errors, D9Events, D9Extensions, D9Queries, D9SdkClientReturn, D9ViewFns, D9WhitelistEntry, type DecodedContractEvent, DigestItem, DispatchClass, type EventFilterOptions, type EventSubscriptionOptions, GrandpaEquivocation, GrandpaEvent, GrandpaStoredState, type HexString, MultiAddress, Phase, type PolkadotSigner, type RawContractEvent, type SS58String, SessionEvent, Sr25519Keypair, TransactionPaymentEvent, TransactionPaymentReleases, TransactionalError, WalletAccount, WhitelistEntriesByChain, WhitelistEntry, bytesToHex, index_d_exports as contracts, createAccountFromMnemonic, createAccountFromPrivateKey, createContractEventStream, createD9SdkClient, createNativeTransferStream, createPSP22TransferStream, createSr25519SignerFromKeypair, _allDescriptors as d9, generateMnemonic, getMetadata, hexToBytes, isHexString, mnemonicToMiniSecret, sr25519AddressFromKeypair, sr25519AddressFromSecretKeyHex, sr25519DeriveFromMiniSecret, sr25519KeypairFromMiniSecret, ss58DecodePublicKey, ss58Reencode, validateMnemonic };
9202
+ //#region src/wallet/validation.d.ts
9203
+ /**
9204
+ * Check if a value is a valid SS58 address
9205
+ *
9206
+ * @param address - The value to check
9207
+ * @returns True if the value is a valid SS58 address
9208
+ *
9209
+ * @example
9210
+ * ```typescript
9211
+ * isValidAddress("5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY"); // true
9212
+ * isValidAddress("invalid"); // false
9213
+ * isValidAddress(null); // false
9214
+ * ```
9215
+ */
9216
+ declare function isValidAddress(address: unknown): address is SS58String$1;
9217
+ /**
9218
+ * Check if a value is a valid D9 address (SS58 prefix 9)
9219
+ *
9220
+ * @param address - The value to check
9221
+ * @returns True if the value is a valid D9 address
9222
+ *
9223
+ * @example
9224
+ * ```typescript
9225
+ * isValidD9Address("XYZd9..."); // true (if valid D9 prefix)
9226
+ * isValidD9Address("5GrwvaEF..."); // false (Polkadot prefix)
9227
+ * ```
9228
+ */
9229
+ declare function isValidD9Address(address: unknown): address is SS58String$1;
9230
+ /**
9231
+ * Check if a value is a valid address for a specific network
9232
+ *
9233
+ * @param address - The value to check
9234
+ * @param expectedPrefix - The expected SS58 prefix
9235
+ * @returns True if the value is a valid address with the expected prefix
9236
+ *
9237
+ * @example
9238
+ * ```typescript
9239
+ * isValidAddressForNetwork(address, 0); // Polkadot
9240
+ * isValidAddressForNetwork(address, 2); // Kusama
9241
+ * isValidAddressForNetwork(address, 9); // D9
9242
+ * ```
9243
+ */
9244
+ declare function isValidAddressForNetwork(address: unknown, expectedPrefix: number): address is SS58String$1;
9245
+ /**
9246
+ * Get the SS58 prefix of an address
9247
+ *
9248
+ * @param address - The SS58 address
9249
+ * @returns The SS58 prefix
9250
+ * @throws Error if the address is invalid
9251
+ *
9252
+ * @example
9253
+ * ```typescript
9254
+ * getAddressPrefix("5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY"); // 42 (Substrate generic)
9255
+ * ```
9256
+ */
9257
+ declare function getAddressPrefix(address: SS58String$1): number;
9258
+ /**
9259
+ * Compare two addresses for equality (same public key)
9260
+ *
9261
+ * Addresses with different SS58 prefixes can represent the same account.
9262
+ * This function compares the underlying public keys.
9263
+ *
9264
+ * @param a - First address
9265
+ * @param b - Second address
9266
+ * @returns True if both addresses represent the same public key
9267
+ *
9268
+ * @example
9269
+ * ```typescript
9270
+ * // Same account, different network formats
9271
+ * const polkadotAddr = "15oF4uVJwmo4TdGW7VfQxNLavjCXviqxT9S1MgbjMNHr6Sp5";
9272
+ * const genericAddr = "5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY";
9273
+ * addressesEqual(polkadotAddr, genericAddr); // true
9274
+ * ```
9275
+ */
9276
+ declare function addressesEqual(a: SS58String$1, b: SS58String$1): boolean;
9277
+ /**
9278
+ * Convert an address to a specific SS58 format
9279
+ *
9280
+ * @param address - The SS58 address
9281
+ * @param targetPrefix - The target SS58 prefix
9282
+ * @returns The address encoded with the target prefix
9283
+ * @throws Error if the address is invalid
9284
+ *
9285
+ * @example
9286
+ * ```typescript
9287
+ * const d9Address = toNetworkAddress("5GrwvaEF...", 9);
9288
+ * ```
9289
+ */
9290
+ declare function toNetworkAddress(address: SS58String$1, targetPrefix: number): SS58String$1;
9291
+ /**
9292
+ * Convert an address to D9 format
9293
+ *
9294
+ * @param address - The SS58 address
9295
+ * @returns The address encoded with D9 prefix (9)
9296
+ *
9297
+ * @example
9298
+ * ```typescript
9299
+ * const d9Address = toD9Address("5GrwvaEF...");
9300
+ * ```
9301
+ */
9302
+ declare function toD9Address(address: SS58String$1): SS58String$1;
9303
+ //#endregion
9304
+ //#region src/utils/balance.d.ts
9305
+ /**
9306
+ * Balance formatting utilities for D9 blockchain
9307
+ */
9308
+ declare const D9_DECIMALS = 12;
9309
+ declare const D9_SYMBOL = "D9";
9310
+ declare const D9_SS58_PREFIX = 9;
9311
+ declare const USDT_DECIMALS = 2;
9312
+ declare const USDT_SYMBOL = "USDT";
9313
+ /**
9314
+ * Token configuration for formatting
9315
+ */
9316
+ interface TokenConfig {
9317
+ decimals: number;
9318
+ symbol: string;
9319
+ }
9320
+ /**
9321
+ * Pre-configured D9 token
9322
+ */
9323
+ declare const D9_TOKEN: TokenConfig;
9324
+ /**
9325
+ * Pre-configured USDT token
9326
+ */
9327
+ declare const USDT_TOKEN: TokenConfig;
9328
+ /**
9329
+ * Options for formatting balance
9330
+ */
9331
+ interface FormatBalanceOptions {
9332
+ /** Number of decimal places (default: token's decimals) */
9333
+ decimals?: number;
9334
+ /** Maximum decimal places to display (default: 4) */
9335
+ maxDecimals?: number;
9336
+ /** Whether to trim trailing zeros (default: true) */
9337
+ trimTrailingZeros?: boolean;
9338
+ /** Thousands separator (default: none) */
9339
+ thousandsSeparator?: string;
9340
+ }
9341
+ /**
9342
+ * Format a raw planck value to a human-readable balance string
9343
+ *
9344
+ * @param planck - The raw balance in planck units (smallest unit)
9345
+ * @param options - Formatting options
9346
+ * @returns Formatted balance string
9347
+ *
9348
+ * @example
9349
+ * ```typescript
9350
+ * formatBalance(1_500_000_000_000n, { decimals: 12 }); // "1.5"
9351
+ * formatBalance(1_500_000_000_000n, { decimals: 12, maxDecimals: 2 }); // "1.50"
9352
+ * formatBalance(1_000_000_000_000_000n, { decimals: 12, thousandsSeparator: "," }); // "1,000"
9353
+ * ```
9354
+ */
9355
+ declare function formatBalance(planck: bigint, options?: FormatBalanceOptions): string;
9356
+ /**
9357
+ * Parse a human-readable amount string to planck units
9358
+ *
9359
+ * @param amount - The amount as a string or number
9360
+ * @param options - Parse options
9361
+ * @returns The amount in planck units (bigint)
9362
+ *
9363
+ * @example
9364
+ * ```typescript
9365
+ * parseAmount("1.5", { decimals: 12 }); // 1_500_000_000_000n
9366
+ * parseAmount(1.5, { decimals: 12 }); // 1_500_000_000_000n
9367
+ * parseAmount("1,000.50", { decimals: 12 }); // 1_000_500_000_000_000n
9368
+ * ```
9369
+ */
9370
+ declare function parseAmount(amount: string | number, options?: {
9371
+ decimals?: number;
9372
+ }): bigint;
9373
+ /**
9374
+ * Format a token amount with symbol
9375
+ *
9376
+ * @param planck - The raw balance in planck units
9377
+ * @param token - Token configuration
9378
+ * @param options - Additional formatting options
9379
+ * @returns Formatted string with token symbol
9380
+ *
9381
+ * @example
9382
+ * ```typescript
9383
+ * formatTokenAmount(1_500_000_000_000n, D9_TOKEN); // "1.5 D9"
9384
+ * formatTokenAmount(1000n, USDT_TOKEN); // "10 USDT"
9385
+ * ```
9386
+ */
9387
+ declare function formatTokenAmount(planck: bigint, token: TokenConfig, options?: Omit<FormatBalanceOptions, "decimals">): string;
9388
+ //#endregion
9389
+ //#region src/utils/time.d.ts
9390
+ /**
9391
+ * Block time utilities for D9 blockchain
9392
+ */
9393
+ declare const D9_BLOCK_TIME_MS = 3000;
9394
+ declare const BLOCKS_PER_MINUTE = 20;
9395
+ declare const BLOCKS_PER_HOUR = 1200;
9396
+ declare const BLOCKS_PER_DAY = 28800;
9397
+ declare const BLOCKS_PER_WEEK = 201600;
9398
+ /**
9399
+ * Convert milliseconds to blocks
9400
+ *
9401
+ * @param ms - Duration in milliseconds
9402
+ * @returns Number of blocks (rounded down)
9403
+ *
9404
+ * @example
9405
+ * ```typescript
9406
+ * msToBlocks(60_000); // 20 blocks (1 minute)
9407
+ * msToBlocks(3_600_000); // 1200 blocks (1 hour)
9408
+ * ```
9409
+ */
9410
+ declare function msToBlocks(ms: number): number;
9411
+ /**
9412
+ * Convert blocks to milliseconds
9413
+ *
9414
+ * @param blocks - Number of blocks
9415
+ * @returns Duration in milliseconds
9416
+ *
9417
+ * @example
9418
+ * ```typescript
9419
+ * blocksToMs(20); // 60_000 (1 minute)
9420
+ * blocksToMs(1200); // 3_600_000 (1 hour)
9421
+ * ```
9422
+ */
9423
+ declare function blocksToMs(blocks: number): number;
9424
+ /**
9425
+ * Estimate the block number at a target time
9426
+ *
9427
+ * @param targetTime - The target time to estimate block for
9428
+ * @param currentBlock - The current block number
9429
+ * @param currentTime - The current time (default: now)
9430
+ * @returns Estimated block number at target time
9431
+ *
9432
+ * @example
9433
+ * ```typescript
9434
+ * const targetBlock = estimateBlockAtTime(
9435
+ * new Date(Date.now() + 3_600_000), // 1 hour from now
9436
+ * 1000, // current block
9437
+ * ); // ~2200
9438
+ * ```
9439
+ */
9440
+ declare function estimateBlockAtTime(targetTime: Date, currentBlock: number, currentTime?: Date): number;
9441
+ /**
9442
+ * Estimate the time at a target block
9443
+ *
9444
+ * @param targetBlock - The target block number
9445
+ * @param currentBlock - The current block number
9446
+ * @param currentTime - The current time (default: now)
9447
+ * @returns Estimated time at target block
9448
+ *
9449
+ * @example
9450
+ * ```typescript
9451
+ * const unlockTime = estimateTimeAtBlock(
9452
+ * 2200, // target block
9453
+ * 1000, // current block
9454
+ * ); // ~1 hour from now
9455
+ * ```
9456
+ */
9457
+ declare function estimateTimeAtBlock(targetBlock: number, currentBlock: number, currentTime?: Date): Date;
9458
+ /**
9459
+ * Calculate the number of blocks until a target time
9460
+ *
9461
+ * @param targetTime - The target time
9462
+ * @param currentBlock - The current block number
9463
+ * @param currentTime - The current time (default: now)
9464
+ * @returns Number of blocks until target time (negative if in the past)
9465
+ *
9466
+ * @example
9467
+ * ```typescript
9468
+ * const blocksRemaining = blocksUntil(unlockTime, currentBlock);
9469
+ * if (blocksRemaining > 0) {
9470
+ * console.log(`${blocksRemaining} blocks until unlock`);
9471
+ * }
9472
+ * ```
9473
+ */
9474
+ declare function blocksUntil(targetTime: Date, currentBlock: number, currentTime?: Date): number;
9475
+ /**
9476
+ * Format options for duration display
9477
+ */
9478
+ interface FormatDurationOptions {
9479
+ /** Whether to show short units (d, h, m, s) or long (days, hours, minutes, seconds) */
9480
+ short?: boolean;
9481
+ /** Maximum number of units to display (default: 2) */
9482
+ maxUnits?: number;
9483
+ }
9484
+ /**
9485
+ * Format a block duration as a human-readable string
9486
+ *
9487
+ * @param blocks - Number of blocks
9488
+ * @param options - Formatting options
9489
+ * @returns Human-readable duration string
9490
+ *
9491
+ * @example
9492
+ * ```typescript
9493
+ * formatBlockDuration(20); // "1 minute"
9494
+ * formatBlockDuration(1200); // "1 hour"
9495
+ * formatBlockDuration(BLOCKS_PER_DAY); // "1 day"
9496
+ * formatBlockDuration(30000, { short: true }); // "1d 1h"
9497
+ * ```
9498
+ */
9499
+ declare function formatBlockDuration(blocks: number, options?: FormatDurationOptions): string;
9500
+ //#endregion
9501
+ export { ArithmeticError, BLOCKS_PER_DAY, BLOCKS_PER_HOUR, BLOCKS_PER_MINUTE, BLOCKS_PER_WEEK, BalanceStatus, BalancesTypesReasons, ContractEventParser, CreateD9SdkClientOptions, D9, D9Apis, D9CallData, D9Calls, D9Constants, D9DispatchError, D9Errors, D9Events, D9Extensions, D9Queries, D9SdkClientReturn, D9ViewFns, D9WhitelistEntry, D9_BLOCK_TIME_MS, D9_DECIMALS, D9_SS58_PREFIX, D9_SYMBOL, D9_TOKEN, type DecodedContractEvent, DigestItem, DispatchClass, type EventFilterOptions, type EventSubscriptionOptions, FormatBalanceOptions, FormatDurationOptions, GrandpaEquivocation, GrandpaEvent, GrandpaStoredState, type HexString, MultiAddress, Phase, type PolkadotSigner, type RawContractEvent, type SS58String, SessionEvent, Sr25519Keypair, TokenConfig, TransactionPaymentEvent, TransactionPaymentReleases, TransactionalError, USDT_DECIMALS, USDT_SYMBOL, USDT_TOKEN, WalletAccount, WhitelistEntriesByChain, WhitelistEntry, addressesEqual, blocksToMs, blocksUntil, bytesToHex, index_d_exports as contracts, createAccountFromMnemonic, createAccountFromPrivateKey, createContractEventStream, createD9SdkClient, createNativeTransferStream, createPSP22TransferStream, createSr25519SignerFromKeypair, _allDescriptors as d9, estimateBlockAtTime, estimateTimeAtBlock, formatBalance, formatBlockDuration, formatTokenAmount, generateMnemonic, getAddressPrefix, getMetadata, hexToBytes, isHexString, isValidAddress, isValidAddressForNetwork, isValidD9Address, mnemonicToMiniSecret, msToBlocks, parseAmount, sr25519AddressFromKeypair, sr25519AddressFromSecretKeyHex, sr25519DeriveFromMiniSecret, sr25519KeypairFromMiniSecret, ss58DecodePublicKey, ss58Reencode, toD9Address, toNetworkAddress, validateMnemonic };
9195
9502
  //# sourceMappingURL=index.d.cts.map
package/dist/index.d.mts CHANGED
@@ -8965,6 +8965,18 @@ declare class ContractEventParser<S extends InkStorageDescriptor = InkStorageDes
8965
8965
  * ```
8966
8966
  */
8967
8967
  parseEvent(chainEvent: unknown): TypedContractEvent<E> | null;
8968
+ /**
8969
+ * Extract event label from ASCII-encoded topic (D9 chain format)
8970
+ *
8971
+ * D9 chain uses a format where:
8972
+ * - First byte is 0x00 (null)
8973
+ * - Remaining 31 bytes are ASCII characters of `ContractName::EventLabel`
8974
+ * - Total is exactly 32 bytes (truncated/padded as needed)
8975
+ *
8976
+ * @param topic - The 32-byte topic from the event
8977
+ * @returns The extracted event label, or null if not in ASCII format
8978
+ */
8979
+ private extractEventLabelFromAsciiTopic;
8968
8980
  /**
8969
8981
  * Filter a batch of events and return type-safe results
8970
8982
  *
@@ -9009,10 +9021,6 @@ declare class ContractEventParser<S extends InkStorageDescriptor = InkStorageDes
9009
9021
  * Compare two Uint8Arrays for equality
9010
9022
  */
9011
9023
  private bytesEqual;
9012
- /**
9013
- * Build event signature map from metadata
9014
- */
9015
- private static buildEventSignatureMap;
9016
9024
  }
9017
9025
  /**
9018
9026
  * Type guard for narrowing event types
@@ -9191,5 +9199,304 @@ declare function createAccountFromPrivateKey(options: {
9191
9199
  keyType: "sr25519" | "ed25519" | "secp256k1";
9192
9200
  }): WalletAccount;
9193
9201
  //#endregion
9194
- export { ArithmeticError, BalanceStatus, BalancesTypesReasons, ContractEventParser, CreateD9SdkClientOptions, D9, D9Apis, D9CallData, D9Calls, D9Constants, D9DispatchError, D9Errors, D9Events, D9Extensions, D9Queries, D9SdkClientReturn, D9ViewFns, D9WhitelistEntry, type DecodedContractEvent, DigestItem, DispatchClass, type EventFilterOptions, type EventSubscriptionOptions, GrandpaEquivocation, GrandpaEvent, GrandpaStoredState, type HexString, MultiAddress, Phase, type PolkadotSigner, type RawContractEvent, type SS58String, SessionEvent, Sr25519Keypair, TransactionPaymentEvent, TransactionPaymentReleases, TransactionalError, WalletAccount, WhitelistEntriesByChain, WhitelistEntry, bytesToHex, index_d_exports as contracts, createAccountFromMnemonic, createAccountFromPrivateKey, createContractEventStream, createD9SdkClient, createNativeTransferStream, createPSP22TransferStream, createSr25519SignerFromKeypair, _allDescriptors as d9, generateMnemonic, getMetadata, hexToBytes, isHexString, mnemonicToMiniSecret, sr25519AddressFromKeypair, sr25519AddressFromSecretKeyHex, sr25519DeriveFromMiniSecret, sr25519KeypairFromMiniSecret, ss58DecodePublicKey, ss58Reencode, validateMnemonic };
9202
+ //#region src/wallet/validation.d.ts
9203
+ /**
9204
+ * Check if a value is a valid SS58 address
9205
+ *
9206
+ * @param address - The value to check
9207
+ * @returns True if the value is a valid SS58 address
9208
+ *
9209
+ * @example
9210
+ * ```typescript
9211
+ * isValidAddress("5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY"); // true
9212
+ * isValidAddress("invalid"); // false
9213
+ * isValidAddress(null); // false
9214
+ * ```
9215
+ */
9216
+ declare function isValidAddress(address: unknown): address is SS58String$1;
9217
+ /**
9218
+ * Check if a value is a valid D9 address (SS58 prefix 9)
9219
+ *
9220
+ * @param address - The value to check
9221
+ * @returns True if the value is a valid D9 address
9222
+ *
9223
+ * @example
9224
+ * ```typescript
9225
+ * isValidD9Address("XYZd9..."); // true (if valid D9 prefix)
9226
+ * isValidD9Address("5GrwvaEF..."); // false (Polkadot prefix)
9227
+ * ```
9228
+ */
9229
+ declare function isValidD9Address(address: unknown): address is SS58String$1;
9230
+ /**
9231
+ * Check if a value is a valid address for a specific network
9232
+ *
9233
+ * @param address - The value to check
9234
+ * @param expectedPrefix - The expected SS58 prefix
9235
+ * @returns True if the value is a valid address with the expected prefix
9236
+ *
9237
+ * @example
9238
+ * ```typescript
9239
+ * isValidAddressForNetwork(address, 0); // Polkadot
9240
+ * isValidAddressForNetwork(address, 2); // Kusama
9241
+ * isValidAddressForNetwork(address, 9); // D9
9242
+ * ```
9243
+ */
9244
+ declare function isValidAddressForNetwork(address: unknown, expectedPrefix: number): address is SS58String$1;
9245
+ /**
9246
+ * Get the SS58 prefix of an address
9247
+ *
9248
+ * @param address - The SS58 address
9249
+ * @returns The SS58 prefix
9250
+ * @throws Error if the address is invalid
9251
+ *
9252
+ * @example
9253
+ * ```typescript
9254
+ * getAddressPrefix("5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY"); // 42 (Substrate generic)
9255
+ * ```
9256
+ */
9257
+ declare function getAddressPrefix(address: SS58String$1): number;
9258
+ /**
9259
+ * Compare two addresses for equality (same public key)
9260
+ *
9261
+ * Addresses with different SS58 prefixes can represent the same account.
9262
+ * This function compares the underlying public keys.
9263
+ *
9264
+ * @param a - First address
9265
+ * @param b - Second address
9266
+ * @returns True if both addresses represent the same public key
9267
+ *
9268
+ * @example
9269
+ * ```typescript
9270
+ * // Same account, different network formats
9271
+ * const polkadotAddr = "15oF4uVJwmo4TdGW7VfQxNLavjCXviqxT9S1MgbjMNHr6Sp5";
9272
+ * const genericAddr = "5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY";
9273
+ * addressesEqual(polkadotAddr, genericAddr); // true
9274
+ * ```
9275
+ */
9276
+ declare function addressesEqual(a: SS58String$1, b: SS58String$1): boolean;
9277
+ /**
9278
+ * Convert an address to a specific SS58 format
9279
+ *
9280
+ * @param address - The SS58 address
9281
+ * @param targetPrefix - The target SS58 prefix
9282
+ * @returns The address encoded with the target prefix
9283
+ * @throws Error if the address is invalid
9284
+ *
9285
+ * @example
9286
+ * ```typescript
9287
+ * const d9Address = toNetworkAddress("5GrwvaEF...", 9);
9288
+ * ```
9289
+ */
9290
+ declare function toNetworkAddress(address: SS58String$1, targetPrefix: number): SS58String$1;
9291
+ /**
9292
+ * Convert an address to D9 format
9293
+ *
9294
+ * @param address - The SS58 address
9295
+ * @returns The address encoded with D9 prefix (9)
9296
+ *
9297
+ * @example
9298
+ * ```typescript
9299
+ * const d9Address = toD9Address("5GrwvaEF...");
9300
+ * ```
9301
+ */
9302
+ declare function toD9Address(address: SS58String$1): SS58String$1;
9303
+ //#endregion
9304
+ //#region src/utils/balance.d.ts
9305
+ /**
9306
+ * Balance formatting utilities for D9 blockchain
9307
+ */
9308
+ declare const D9_DECIMALS = 12;
9309
+ declare const D9_SYMBOL = "D9";
9310
+ declare const D9_SS58_PREFIX = 9;
9311
+ declare const USDT_DECIMALS = 2;
9312
+ declare const USDT_SYMBOL = "USDT";
9313
+ /**
9314
+ * Token configuration for formatting
9315
+ */
9316
+ interface TokenConfig {
9317
+ decimals: number;
9318
+ symbol: string;
9319
+ }
9320
+ /**
9321
+ * Pre-configured D9 token
9322
+ */
9323
+ declare const D9_TOKEN: TokenConfig;
9324
+ /**
9325
+ * Pre-configured USDT token
9326
+ */
9327
+ declare const USDT_TOKEN: TokenConfig;
9328
+ /**
9329
+ * Options for formatting balance
9330
+ */
9331
+ interface FormatBalanceOptions {
9332
+ /** Number of decimal places (default: token's decimals) */
9333
+ decimals?: number;
9334
+ /** Maximum decimal places to display (default: 4) */
9335
+ maxDecimals?: number;
9336
+ /** Whether to trim trailing zeros (default: true) */
9337
+ trimTrailingZeros?: boolean;
9338
+ /** Thousands separator (default: none) */
9339
+ thousandsSeparator?: string;
9340
+ }
9341
+ /**
9342
+ * Format a raw planck value to a human-readable balance string
9343
+ *
9344
+ * @param planck - The raw balance in planck units (smallest unit)
9345
+ * @param options - Formatting options
9346
+ * @returns Formatted balance string
9347
+ *
9348
+ * @example
9349
+ * ```typescript
9350
+ * formatBalance(1_500_000_000_000n, { decimals: 12 }); // "1.5"
9351
+ * formatBalance(1_500_000_000_000n, { decimals: 12, maxDecimals: 2 }); // "1.50"
9352
+ * formatBalance(1_000_000_000_000_000n, { decimals: 12, thousandsSeparator: "," }); // "1,000"
9353
+ * ```
9354
+ */
9355
+ declare function formatBalance(planck: bigint, options?: FormatBalanceOptions): string;
9356
+ /**
9357
+ * Parse a human-readable amount string to planck units
9358
+ *
9359
+ * @param amount - The amount as a string or number
9360
+ * @param options - Parse options
9361
+ * @returns The amount in planck units (bigint)
9362
+ *
9363
+ * @example
9364
+ * ```typescript
9365
+ * parseAmount("1.5", { decimals: 12 }); // 1_500_000_000_000n
9366
+ * parseAmount(1.5, { decimals: 12 }); // 1_500_000_000_000n
9367
+ * parseAmount("1,000.50", { decimals: 12 }); // 1_000_500_000_000_000n
9368
+ * ```
9369
+ */
9370
+ declare function parseAmount(amount: string | number, options?: {
9371
+ decimals?: number;
9372
+ }): bigint;
9373
+ /**
9374
+ * Format a token amount with symbol
9375
+ *
9376
+ * @param planck - The raw balance in planck units
9377
+ * @param token - Token configuration
9378
+ * @param options - Additional formatting options
9379
+ * @returns Formatted string with token symbol
9380
+ *
9381
+ * @example
9382
+ * ```typescript
9383
+ * formatTokenAmount(1_500_000_000_000n, D9_TOKEN); // "1.5 D9"
9384
+ * formatTokenAmount(1000n, USDT_TOKEN); // "10 USDT"
9385
+ * ```
9386
+ */
9387
+ declare function formatTokenAmount(planck: bigint, token: TokenConfig, options?: Omit<FormatBalanceOptions, "decimals">): string;
9388
+ //#endregion
9389
+ //#region src/utils/time.d.ts
9390
+ /**
9391
+ * Block time utilities for D9 blockchain
9392
+ */
9393
+ declare const D9_BLOCK_TIME_MS = 3000;
9394
+ declare const BLOCKS_PER_MINUTE = 20;
9395
+ declare const BLOCKS_PER_HOUR = 1200;
9396
+ declare const BLOCKS_PER_DAY = 28800;
9397
+ declare const BLOCKS_PER_WEEK = 201600;
9398
+ /**
9399
+ * Convert milliseconds to blocks
9400
+ *
9401
+ * @param ms - Duration in milliseconds
9402
+ * @returns Number of blocks (rounded down)
9403
+ *
9404
+ * @example
9405
+ * ```typescript
9406
+ * msToBlocks(60_000); // 20 blocks (1 minute)
9407
+ * msToBlocks(3_600_000); // 1200 blocks (1 hour)
9408
+ * ```
9409
+ */
9410
+ declare function msToBlocks(ms: number): number;
9411
+ /**
9412
+ * Convert blocks to milliseconds
9413
+ *
9414
+ * @param blocks - Number of blocks
9415
+ * @returns Duration in milliseconds
9416
+ *
9417
+ * @example
9418
+ * ```typescript
9419
+ * blocksToMs(20); // 60_000 (1 minute)
9420
+ * blocksToMs(1200); // 3_600_000 (1 hour)
9421
+ * ```
9422
+ */
9423
+ declare function blocksToMs(blocks: number): number;
9424
+ /**
9425
+ * Estimate the block number at a target time
9426
+ *
9427
+ * @param targetTime - The target time to estimate block for
9428
+ * @param currentBlock - The current block number
9429
+ * @param currentTime - The current time (default: now)
9430
+ * @returns Estimated block number at target time
9431
+ *
9432
+ * @example
9433
+ * ```typescript
9434
+ * const targetBlock = estimateBlockAtTime(
9435
+ * new Date(Date.now() + 3_600_000), // 1 hour from now
9436
+ * 1000, // current block
9437
+ * ); // ~2200
9438
+ * ```
9439
+ */
9440
+ declare function estimateBlockAtTime(targetTime: Date, currentBlock: number, currentTime?: Date): number;
9441
+ /**
9442
+ * Estimate the time at a target block
9443
+ *
9444
+ * @param targetBlock - The target block number
9445
+ * @param currentBlock - The current block number
9446
+ * @param currentTime - The current time (default: now)
9447
+ * @returns Estimated time at target block
9448
+ *
9449
+ * @example
9450
+ * ```typescript
9451
+ * const unlockTime = estimateTimeAtBlock(
9452
+ * 2200, // target block
9453
+ * 1000, // current block
9454
+ * ); // ~1 hour from now
9455
+ * ```
9456
+ */
9457
+ declare function estimateTimeAtBlock(targetBlock: number, currentBlock: number, currentTime?: Date): Date;
9458
+ /**
9459
+ * Calculate the number of blocks until a target time
9460
+ *
9461
+ * @param targetTime - The target time
9462
+ * @param currentBlock - The current block number
9463
+ * @param currentTime - The current time (default: now)
9464
+ * @returns Number of blocks until target time (negative if in the past)
9465
+ *
9466
+ * @example
9467
+ * ```typescript
9468
+ * const blocksRemaining = blocksUntil(unlockTime, currentBlock);
9469
+ * if (blocksRemaining > 0) {
9470
+ * console.log(`${blocksRemaining} blocks until unlock`);
9471
+ * }
9472
+ * ```
9473
+ */
9474
+ declare function blocksUntil(targetTime: Date, currentBlock: number, currentTime?: Date): number;
9475
+ /**
9476
+ * Format options for duration display
9477
+ */
9478
+ interface FormatDurationOptions {
9479
+ /** Whether to show short units (d, h, m, s) or long (days, hours, minutes, seconds) */
9480
+ short?: boolean;
9481
+ /** Maximum number of units to display (default: 2) */
9482
+ maxUnits?: number;
9483
+ }
9484
+ /**
9485
+ * Format a block duration as a human-readable string
9486
+ *
9487
+ * @param blocks - Number of blocks
9488
+ * @param options - Formatting options
9489
+ * @returns Human-readable duration string
9490
+ *
9491
+ * @example
9492
+ * ```typescript
9493
+ * formatBlockDuration(20); // "1 minute"
9494
+ * formatBlockDuration(1200); // "1 hour"
9495
+ * formatBlockDuration(BLOCKS_PER_DAY); // "1 day"
9496
+ * formatBlockDuration(30000, { short: true }); // "1d 1h"
9497
+ * ```
9498
+ */
9499
+ declare function formatBlockDuration(blocks: number, options?: FormatDurationOptions): string;
9500
+ //#endregion
9501
+ export { ArithmeticError, BLOCKS_PER_DAY, BLOCKS_PER_HOUR, BLOCKS_PER_MINUTE, BLOCKS_PER_WEEK, BalanceStatus, BalancesTypesReasons, ContractEventParser, CreateD9SdkClientOptions, D9, D9Apis, D9CallData, D9Calls, D9Constants, D9DispatchError, D9Errors, D9Events, D9Extensions, D9Queries, D9SdkClientReturn, D9ViewFns, D9WhitelistEntry, D9_BLOCK_TIME_MS, D9_DECIMALS, D9_SS58_PREFIX, D9_SYMBOL, D9_TOKEN, type DecodedContractEvent, DigestItem, DispatchClass, type EventFilterOptions, type EventSubscriptionOptions, FormatBalanceOptions, FormatDurationOptions, GrandpaEquivocation, GrandpaEvent, GrandpaStoredState, type HexString, MultiAddress, Phase, type PolkadotSigner, type RawContractEvent, type SS58String, SessionEvent, Sr25519Keypair, TokenConfig, TransactionPaymentEvent, TransactionPaymentReleases, TransactionalError, USDT_DECIMALS, USDT_SYMBOL, USDT_TOKEN, WalletAccount, WhitelistEntriesByChain, WhitelistEntry, addressesEqual, blocksToMs, blocksUntil, bytesToHex, index_d_exports as contracts, createAccountFromMnemonic, createAccountFromPrivateKey, createContractEventStream, createD9SdkClient, createNativeTransferStream, createPSP22TransferStream, createSr25519SignerFromKeypair, _allDescriptors as d9, estimateBlockAtTime, estimateTimeAtBlock, formatBalance, formatBlockDuration, formatTokenAmount, generateMnemonic, getAddressPrefix, getMetadata, hexToBytes, isHexString, isValidAddress, isValidAddressForNetwork, isValidD9Address, mnemonicToMiniSecret, msToBlocks, parseAmount, sr25519AddressFromKeypair, sr25519AddressFromSecretKeyHex, sr25519DeriveFromMiniSecret, sr25519KeypairFromMiniSecret, ss58DecodePublicKey, ss58Reencode, toD9Address, toNetworkAddress, validateMnemonic };
9195
9502
  //# sourceMappingURL=index.d.mts.map