@d9-network/spec 1.2.5 → 1.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.cts CHANGED
@@ -8524,6 +8524,39 @@ declare function toNetworkAddress(address: SS58String$1, targetPrefix: number):
8524
8524
  */
8525
8525
  declare function toD9Address(address: SS58String$1): SS58String$1;
8526
8526
  //#endregion
8527
+ //#region src/wallet/verify.d.ts
8528
+ /**
8529
+ * Verify an SR25519 signature
8530
+ *
8531
+ * @param signature - The signature as a hex string or Uint8Array (64 bytes)
8532
+ * @param message - The message that was signed (string or Uint8Array)
8533
+ * @param publicKey - The public key to verify against (32 bytes)
8534
+ * @returns True if the signature is valid
8535
+ *
8536
+ * @example
8537
+ * ```typescript
8538
+ * const publicKey = ss58DecodePublicKey(address);
8539
+ * const isValid = sr25519Verify(signature, message, publicKey);
8540
+ * ```
8541
+ */
8542
+ declare function sr25519Verify(signature: string | Uint8Array, message: string | Uint8Array, publicKey: Uint8Array): boolean;
8543
+ /**
8544
+ * Verify an SR25519 signature against a wallet address
8545
+ *
8546
+ * Convenience function that decodes the SS58 address and verifies in one step.
8547
+ *
8548
+ * @param walletAddress - The SS58 wallet address
8549
+ * @param signature - The signature as a hex string or Uint8Array
8550
+ * @param message - The message that was signed
8551
+ * @returns True if the signature is valid
8552
+ *
8553
+ * @example
8554
+ * ```typescript
8555
+ * const isValid = verifyWalletSignature(address, signature, message);
8556
+ * ```
8557
+ */
8558
+ declare function verifyWalletSignature(walletAddress: SS58String$1, signature: string | Uint8Array, message: string | Uint8Array): boolean;
8559
+ //#endregion
8527
8560
  //#region src/utils/balance.d.ts
8528
8561
  /**
8529
8562
  * Balance formatting utilities for D9 blockchain
@@ -8793,5 +8826,5 @@ declare function normalizeHex(hex: string): HexString$1;
8793
8826
  */
8794
8827
  declare function selectorToBytes(selector: string): Uint8Array;
8795
8828
  //#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 };
8829
+ 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, sr25519Verify, ss58DecodePublicKey, ss58Reencode, toD9Address, toNetworkAddress, validateMnemonic, verifyWalletSignature };
8797
8830
  //# sourceMappingURL=index.d.cts.map
package/dist/index.d.mts CHANGED
@@ -8524,6 +8524,39 @@ declare function toNetworkAddress(address: SS58String$1, targetPrefix: number):
8524
8524
  */
8525
8525
  declare function toD9Address(address: SS58String$1): SS58String$1;
8526
8526
  //#endregion
8527
+ //#region src/wallet/verify.d.ts
8528
+ /**
8529
+ * Verify an SR25519 signature
8530
+ *
8531
+ * @param signature - The signature as a hex string or Uint8Array (64 bytes)
8532
+ * @param message - The message that was signed (string or Uint8Array)
8533
+ * @param publicKey - The public key to verify against (32 bytes)
8534
+ * @returns True if the signature is valid
8535
+ *
8536
+ * @example
8537
+ * ```typescript
8538
+ * const publicKey = ss58DecodePublicKey(address);
8539
+ * const isValid = sr25519Verify(signature, message, publicKey);
8540
+ * ```
8541
+ */
8542
+ declare function sr25519Verify(signature: string | Uint8Array, message: string | Uint8Array, publicKey: Uint8Array): boolean;
8543
+ /**
8544
+ * Verify an SR25519 signature against a wallet address
8545
+ *
8546
+ * Convenience function that decodes the SS58 address and verifies in one step.
8547
+ *
8548
+ * @param walletAddress - The SS58 wallet address
8549
+ * @param signature - The signature as a hex string or Uint8Array
8550
+ * @param message - The message that was signed
8551
+ * @returns True if the signature is valid
8552
+ *
8553
+ * @example
8554
+ * ```typescript
8555
+ * const isValid = verifyWalletSignature(address, signature, message);
8556
+ * ```
8557
+ */
8558
+ declare function verifyWalletSignature(walletAddress: SS58String$1, signature: string | Uint8Array, message: string | Uint8Array): boolean;
8559
+ //#endregion
8527
8560
  //#region src/utils/balance.d.ts
8528
8561
  /**
8529
8562
  * Balance formatting utilities for D9 blockchain
@@ -8793,5 +8826,5 @@ declare function normalizeHex(hex: string): HexString$1;
8793
8826
  */
8794
8827
  declare function selectorToBytes(selector: string): Uint8Array;
8795
8828
  //#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 };
8829
+ 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, sr25519Verify, ss58DecodePublicKey, ss58Reencode, toD9Address, toNetworkAddress, validateMnemonic, verifyWalletSignature };
8797
8830
  //# sourceMappingURL=index.d.mts.map
package/dist/index.mjs CHANGED
@@ -1,6 +1,6 @@
1
1
  import { t as __export } from "./chunk-7P6ASYW6-kh065yQz.mjs";
2
2
  import { _Enum } from "polkadot-api";
3
- import { generateMnemonic as generateMnemonic$1, mnemonicToMiniSecret as mnemonicToMiniSecret$1, ss58Decode, ss58Encode, validateMnemonic as validateMnemonic$1 } from "@polkadot-labs/hdkd-helpers";
3
+ import { generateMnemonic as generateMnemonic$1, mnemonicToMiniSecret as mnemonicToMiniSecret$1, sr25519, ss58Decode, ss58Encode, validateMnemonic as validateMnemonic$1 } from "@polkadot-labs/hdkd-helpers";
4
4
  import { sr25519CreateDerive, withNetworkAccount } from "@polkadot-labs/hdkd";
5
5
 
6
6
  //#region ../../node_modules/.bun/@polkadot-api+descriptors@file+packages+spec+.papi+descriptors+ec2463ed5a666297/node_modules/@polkadot-api/descriptors/dist/index.mjs
@@ -7983,9 +7983,9 @@ var compactEnc = (input) => {
7983
7983
  return result;
7984
7984
  };
7985
7985
  var compact = createCodec(compactEnc, compactDec);
7986
- var textEncoder = new TextEncoder();
7986
+ var textEncoder$1 = new TextEncoder();
7987
7987
  var strEnc = (str2) => {
7988
- const val = textEncoder.encode(str2);
7988
+ const val = textEncoder$1.encode(str2);
7989
7989
  return mergeUint8([compact.enc(val.length), val]);
7990
7990
  };
7991
7991
  var textDecoder = new TextDecoder();
@@ -10396,6 +10396,48 @@ function toD9Address(address) {
10396
10396
  return toNetworkAddress(address, D9_SS58_PREFIX);
10397
10397
  }
10398
10398
 
10399
+ //#endregion
10400
+ //#region src/wallet/verify.ts
10401
+ const textEncoder = new TextEncoder();
10402
+ /**
10403
+ * Verify an SR25519 signature
10404
+ *
10405
+ * @param signature - The signature as a hex string or Uint8Array (64 bytes)
10406
+ * @param message - The message that was signed (string or Uint8Array)
10407
+ * @param publicKey - The public key to verify against (32 bytes)
10408
+ * @returns True if the signature is valid
10409
+ *
10410
+ * @example
10411
+ * ```typescript
10412
+ * const publicKey = ss58DecodePublicKey(address);
10413
+ * const isValid = sr25519Verify(signature, message, publicKey);
10414
+ * ```
10415
+ */
10416
+ function sr25519Verify(signature, message, publicKey) {
10417
+ const sigBytes = typeof signature === "string" ? isHexString(signature) ? hexToBytes(signature) : hexToBytes(`0x${signature}`) : signature;
10418
+ const msgBytes = typeof message === "string" ? textEncoder.encode(message) : message;
10419
+ return sr25519.verify(sigBytes, msgBytes, publicKey);
10420
+ }
10421
+ /**
10422
+ * Verify an SR25519 signature against a wallet address
10423
+ *
10424
+ * Convenience function that decodes the SS58 address and verifies in one step.
10425
+ *
10426
+ * @param walletAddress - The SS58 wallet address
10427
+ * @param signature - The signature as a hex string or Uint8Array
10428
+ * @param message - The message that was signed
10429
+ * @returns True if the signature is valid
10430
+ *
10431
+ * @example
10432
+ * ```typescript
10433
+ * const isValid = verifyWalletSignature(address, signature, message);
10434
+ * ```
10435
+ */
10436
+ function verifyWalletSignature(walletAddress, signature, message) {
10437
+ const [publicKey] = ss58Decode(walletAddress);
10438
+ return sr25519Verify(signature, message, publicKey);
10439
+ }
10440
+
10399
10441
  //#endregion
10400
10442
  //#region src/utils/balance.ts
10401
10443
  /**
@@ -10736,5 +10778,5 @@ function selectorToBytes(selector) {
10736
10778
  }
10737
10779
 
10738
10780
  //#endregion
10739
- export { AbortedError, ArithmeticError, BLOCKS_PER_DAY, BLOCKS_PER_HOUR, BLOCKS_PER_MINUTE, BLOCKS_PER_WEEK, BalanceStatus, BalancesTypesReasons, ContractError, ContractExecutionError, D9_BLOCK_TIME_MS, D9_DECIMALS, D9_SS58_PREFIX, D9_SYMBOL, D9_TOKEN, DecodeError, DigestItem, DispatchClass, EncodeError, GrandpaEquivocation, GrandpaEvent, GrandpaStoredState, LangError, MetadataError, MultiAddress, NetworkError, Phase, SessionEvent, SignerError, TimeoutError, TransactionError, TransactionPaymentEvent, TransactionPaymentReleases, TransactionalError, USDT_DECIMALS, USDT_SYMBOL, USDT_TOKEN, addressesEqual, blocksToMs, blocksUntil, bytesEqual, bytesToHex, concatBytes, contracts_exports as contracts, createAccountFromMnemonic, createAccountFromPrivateKey, createSr25519SignerFromKeypair, d9_default as d9, estimateBlockAtTime, estimateTimeAtBlock, extractSelector, extractSelectorHex, formatBalance, formatBlockDuration, formatTokenAmount, generateMnemonic, getAddressPrefix, getMetadata2 as getMetadata, hexToBytes, isContractError, isErrorType, isHexString, isValidAddress, isValidAddressForNetwork, isValidD9Address, mnemonicToMiniSecret, msToBlocks, normalizeHex, parseAmount, safeSlice, selectorToBytes, sr25519AddressFromKeypair, sr25519AddressFromSecretKeyHex, sr25519DeriveFromMiniSecret, sr25519KeypairFromMiniSecret, ss58DecodePublicKey, ss58Reencode, toD9Address, toNetworkAddress, validateMnemonic };
10781
+ export { AbortedError, ArithmeticError, BLOCKS_PER_DAY, BLOCKS_PER_HOUR, BLOCKS_PER_MINUTE, BLOCKS_PER_WEEK, BalanceStatus, BalancesTypesReasons, ContractError, ContractExecutionError, D9_BLOCK_TIME_MS, D9_DECIMALS, D9_SS58_PREFIX, D9_SYMBOL, D9_TOKEN, DecodeError, DigestItem, DispatchClass, EncodeError, GrandpaEquivocation, GrandpaEvent, GrandpaStoredState, LangError, MetadataError, MultiAddress, NetworkError, Phase, SessionEvent, SignerError, TimeoutError, TransactionError, TransactionPaymentEvent, TransactionPaymentReleases, TransactionalError, USDT_DECIMALS, USDT_SYMBOL, USDT_TOKEN, addressesEqual, blocksToMs, blocksUntil, bytesEqual, bytesToHex, concatBytes, contracts_exports as contracts, createAccountFromMnemonic, createAccountFromPrivateKey, createSr25519SignerFromKeypair, d9_default as d9, estimateBlockAtTime, estimateTimeAtBlock, extractSelector, extractSelectorHex, formatBalance, formatBlockDuration, formatTokenAmount, generateMnemonic, getAddressPrefix, getMetadata2 as getMetadata, hexToBytes, isContractError, isErrorType, isHexString, isValidAddress, isValidAddressForNetwork, isValidD9Address, mnemonicToMiniSecret, msToBlocks, normalizeHex, parseAmount, safeSlice, selectorToBytes, sr25519AddressFromKeypair, sr25519AddressFromSecretKeyHex, sr25519DeriveFromMiniSecret, sr25519KeypairFromMiniSecret, sr25519Verify, ss58DecodePublicKey, ss58Reencode, toD9Address, toNetworkAddress, validateMnemonic, verifyWalletSignature };
10740
10782
  //# sourceMappingURL=index.mjs.map