@d9-network/spec 0.1.1 → 0.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/README.md +89 -0
- package/dist/index.cjs +101 -111
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +3 -7
- package/dist/index.d.mts +3 -7
- package/dist/index.mjs +101 -106
- package/dist/index.mjs.map +1 -1
- package/package.json +4 -4
package/dist/index.d.cts
CHANGED
|
@@ -8325,7 +8325,8 @@ type TypedContractEvent<E extends Event> = E extends Enum<infer T> ? { [K in key
|
|
|
8325
8325
|
raw: RawContractEvent;
|
|
8326
8326
|
};
|
|
8327
8327
|
/**
|
|
8328
|
-
* Decoded contract event
|
|
8328
|
+
* Decoded contract event with generic data type.
|
|
8329
|
+
* For full type safety with discriminated unions, use TypedContractEvent instead.
|
|
8329
8330
|
*/
|
|
8330
8331
|
interface DecodedContractEvent<T$1 = unknown> {
|
|
8331
8332
|
/** Event label from metadata (e.g., "Transfer", "Approval") */
|
|
@@ -9306,11 +9307,6 @@ declare function toD9Address(address: SS58String$1): SS58String$1;
|
|
|
9306
9307
|
/**
|
|
9307
9308
|
* Balance formatting utilities for D9 blockchain
|
|
9308
9309
|
*/
|
|
9309
|
-
declare const D9_DECIMALS = 2;
|
|
9310
|
-
declare const D9_SYMBOL = "D9";
|
|
9311
|
-
declare const D9_SS58_PREFIX = 9;
|
|
9312
|
-
declare const USDT_DECIMALS = 2;
|
|
9313
|
-
declare const USDT_SYMBOL = "USDT";
|
|
9314
9310
|
/**
|
|
9315
9311
|
* Token configuration for formatting
|
|
9316
9312
|
*/
|
|
@@ -9499,5 +9495,5 @@ interface FormatDurationOptions {
|
|
|
9499
9495
|
*/
|
|
9500
9496
|
declare function formatBlockDuration(blocks: number, options?: FormatDurationOptions): string;
|
|
9501
9497
|
//#endregion
|
|
9502
|
-
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,
|
|
9498
|
+
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_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_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 };
|
|
9503
9499
|
//# sourceMappingURL=index.d.cts.map
|
package/dist/index.d.mts
CHANGED
|
@@ -8325,7 +8325,8 @@ type TypedContractEvent<E extends Event> = E extends Enum<infer T> ? { [K in key
|
|
|
8325
8325
|
raw: RawContractEvent;
|
|
8326
8326
|
};
|
|
8327
8327
|
/**
|
|
8328
|
-
* Decoded contract event
|
|
8328
|
+
* Decoded contract event with generic data type.
|
|
8329
|
+
* For full type safety with discriminated unions, use TypedContractEvent instead.
|
|
8329
8330
|
*/
|
|
8330
8331
|
interface DecodedContractEvent<T$1 = unknown> {
|
|
8331
8332
|
/** Event label from metadata (e.g., "Transfer", "Approval") */
|
|
@@ -9306,11 +9307,6 @@ declare function toD9Address(address: SS58String$1): SS58String$1;
|
|
|
9306
9307
|
/**
|
|
9307
9308
|
* Balance formatting utilities for D9 blockchain
|
|
9308
9309
|
*/
|
|
9309
|
-
declare const D9_DECIMALS = 2;
|
|
9310
|
-
declare const D9_SYMBOL = "D9";
|
|
9311
|
-
declare const D9_SS58_PREFIX = 9;
|
|
9312
|
-
declare const USDT_DECIMALS = 2;
|
|
9313
|
-
declare const USDT_SYMBOL = "USDT";
|
|
9314
9310
|
/**
|
|
9315
9311
|
* Token configuration for formatting
|
|
9316
9312
|
*/
|
|
@@ -9499,5 +9495,5 @@ interface FormatDurationOptions {
|
|
|
9499
9495
|
*/
|
|
9500
9496
|
declare function formatBlockDuration(blocks: number, options?: FormatDurationOptions): string;
|
|
9501
9497
|
//#endregion
|
|
9502
|
-
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,
|
|
9498
|
+
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_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_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 };
|
|
9503
9499
|
//# sourceMappingURL=index.d.mts.map
|
package/dist/index.mjs
CHANGED
|
@@ -3,7 +3,7 @@ import { _Enum, createClient } from "polkadot-api";
|
|
|
3
3
|
import { getWsProvider } from "polkadot-api/ws-provider";
|
|
4
4
|
import { withPolkadotSdkCompat } from "polkadot-api/polkadot-sdk-compat";
|
|
5
5
|
import { withLegacy } from "@polkadot-api/legacy-provider";
|
|
6
|
-
import { ContractEventParser, D9_DECIMALS
|
|
6
|
+
import { ContractEventParser, D9_DECIMALS, D9_SS58_PREFIX, D9_SYMBOL, USDT_DECIMALS, USDT_SYMBOL, createContractEventStream, createD9InkSdk, createNativeTransferStream, createPSP22TransferStream } from "@d9-network/ink";
|
|
7
7
|
import { generateMnemonic as generateMnemonic$1, mnemonicToMiniSecret as mnemonicToMiniSecret$1, ss58Decode, ss58Encode, validateMnemonic as validateMnemonic$1 } from "@polkadot-labs/hdkd-helpers";
|
|
8
8
|
import { sr25519CreateDerive, withNetworkAccount } from "@polkadot-labs/hdkd";
|
|
9
9
|
import { getPolkadotSigner } from "@polkadot-api/signer";
|
|
@@ -7584,110 +7584,6 @@ function createAccountFromPrivateKey(options) {
|
|
|
7584
7584
|
};
|
|
7585
7585
|
}
|
|
7586
7586
|
|
|
7587
|
-
//#endregion
|
|
7588
|
-
//#region src/utils/balance.ts
|
|
7589
|
-
/**
|
|
7590
|
-
* Balance formatting utilities for D9 blockchain
|
|
7591
|
-
*/
|
|
7592
|
-
const D9_DECIMALS = D9_DECIMALS$1;
|
|
7593
|
-
const D9_SYMBOL = D9_SYMBOL$1;
|
|
7594
|
-
const D9_SS58_PREFIX = D9_SS58_PREFIX$1;
|
|
7595
|
-
const USDT_DECIMALS = USDT_DECIMALS$1;
|
|
7596
|
-
const USDT_SYMBOL = USDT_SYMBOL$1;
|
|
7597
|
-
/**
|
|
7598
|
-
* Pre-configured D9 token
|
|
7599
|
-
*/
|
|
7600
|
-
const D9_TOKEN = {
|
|
7601
|
-
decimals: D9_DECIMALS,
|
|
7602
|
-
symbol: D9_SYMBOL
|
|
7603
|
-
};
|
|
7604
|
-
/**
|
|
7605
|
-
* Pre-configured USDT token
|
|
7606
|
-
*/
|
|
7607
|
-
const USDT_TOKEN = {
|
|
7608
|
-
decimals: USDT_DECIMALS,
|
|
7609
|
-
symbol: USDT_SYMBOL
|
|
7610
|
-
};
|
|
7611
|
-
/**
|
|
7612
|
-
* Format a raw planck value to a human-readable balance string
|
|
7613
|
-
*
|
|
7614
|
-
* @param planck - The raw balance in planck units (smallest unit)
|
|
7615
|
-
* @param options - Formatting options
|
|
7616
|
-
* @returns Formatted balance string
|
|
7617
|
-
*
|
|
7618
|
-
* @example
|
|
7619
|
-
* ```typescript
|
|
7620
|
-
* formatBalance(1_500_000_000_000n, { decimals: 12 }); // "1.5"
|
|
7621
|
-
* formatBalance(1_500_000_000_000n, { decimals: 12, maxDecimals: 2 }); // "1.50"
|
|
7622
|
-
* formatBalance(1_000_000_000_000_000n, { decimals: 12, thousandsSeparator: "," }); // "1,000"
|
|
7623
|
-
* ```
|
|
7624
|
-
*/
|
|
7625
|
-
function formatBalance(planck, options = {}) {
|
|
7626
|
-
const { decimals = D9_DECIMALS, maxDecimals = 4, trimTrailingZeros = true, thousandsSeparator } = options;
|
|
7627
|
-
if (decimals < 0 || decimals > 30) throw new Error("Decimals must be between 0 and 30");
|
|
7628
|
-
const divisor = 10n ** BigInt(decimals);
|
|
7629
|
-
const isNegative = planck < 0n;
|
|
7630
|
-
const absolutePlanck = isNegative ? -planck : planck;
|
|
7631
|
-
const wholePart = absolutePlanck / divisor;
|
|
7632
|
-
const fractionalPart = absolutePlanck % divisor;
|
|
7633
|
-
let wholeStr = wholePart.toString();
|
|
7634
|
-
if (thousandsSeparator && wholeStr.length > 3) wholeStr = wholeStr.replace(/\B(?=(\d{3})+(?!\d))/g, thousandsSeparator);
|
|
7635
|
-
if (decimals === 0 || maxDecimals === 0) return isNegative ? `-${wholeStr}` : wholeStr;
|
|
7636
|
-
let fractionalStr = fractionalPart.toString().padStart(decimals, "0");
|
|
7637
|
-
if (fractionalStr.length > maxDecimals) fractionalStr = fractionalStr.slice(0, maxDecimals);
|
|
7638
|
-
if (trimTrailingZeros) fractionalStr = fractionalStr.replace(/0+$/, "");
|
|
7639
|
-
const prefix = isNegative ? "-" : "";
|
|
7640
|
-
if (fractionalStr === "") return `${prefix}${wholeStr}`;
|
|
7641
|
-
return `${prefix}${wholeStr}.${fractionalStr}`;
|
|
7642
|
-
}
|
|
7643
|
-
/**
|
|
7644
|
-
* Parse a human-readable amount string to planck units
|
|
7645
|
-
*
|
|
7646
|
-
* @param amount - The amount as a string or number
|
|
7647
|
-
* @param options - Parse options
|
|
7648
|
-
* @returns The amount in planck units (bigint)
|
|
7649
|
-
*
|
|
7650
|
-
* @example
|
|
7651
|
-
* ```typescript
|
|
7652
|
-
* parseAmount("1.5", { decimals: 12 }); // 1_500_000_000_000n
|
|
7653
|
-
* parseAmount(1.5, { decimals: 12 }); // 1_500_000_000_000n
|
|
7654
|
-
* parseAmount("1,000.50", { decimals: 12 }); // 1_000_500_000_000_000n
|
|
7655
|
-
* ```
|
|
7656
|
-
*/
|
|
7657
|
-
function parseAmount(amount, options = {}) {
|
|
7658
|
-
const { decimals = D9_DECIMALS } = options;
|
|
7659
|
-
if (decimals < 0 || decimals > 30) throw new Error("Decimals must be between 0 and 30");
|
|
7660
|
-
let amountStr = String(amount).replace(/,/g, "").trim();
|
|
7661
|
-
const isNegative = amountStr.startsWith("-");
|
|
7662
|
-
if (isNegative) amountStr = amountStr.slice(1);
|
|
7663
|
-
if (!/^\d*\.?\d*$/.test(amountStr) || amountStr === "" || amountStr === ".") throw new Error(`Invalid amount format: ${amount}`);
|
|
7664
|
-
const [wholePart = "0", fractionalPart = ""] = amountStr.split(".");
|
|
7665
|
-
if (fractionalPart.length > decimals) throw new Error(`Amount has more decimal places (${fractionalPart.length}) than supported (${decimals})`);
|
|
7666
|
-
const planckStr = wholePart + fractionalPart.padEnd(decimals, "0");
|
|
7667
|
-
const planck = BigInt(planckStr);
|
|
7668
|
-
return isNegative ? -planck : planck;
|
|
7669
|
-
}
|
|
7670
|
-
/**
|
|
7671
|
-
* Format a token amount with symbol
|
|
7672
|
-
*
|
|
7673
|
-
* @param planck - The raw balance in planck units
|
|
7674
|
-
* @param token - Token configuration
|
|
7675
|
-
* @param options - Additional formatting options
|
|
7676
|
-
* @returns Formatted string with token symbol
|
|
7677
|
-
*
|
|
7678
|
-
* @example
|
|
7679
|
-
* ```typescript
|
|
7680
|
-
* formatTokenAmount(1_500_000_000_000n, D9_TOKEN); // "1.5 D9"
|
|
7681
|
-
* formatTokenAmount(1000n, USDT_TOKEN); // "10 USDT"
|
|
7682
|
-
* ```
|
|
7683
|
-
*/
|
|
7684
|
-
function formatTokenAmount(planck, token, options = {}) {
|
|
7685
|
-
return `${formatBalance(planck, {
|
|
7686
|
-
...options,
|
|
7687
|
-
decimals: token.decimals
|
|
7688
|
-
})} ${token.symbol}`;
|
|
7689
|
-
}
|
|
7690
|
-
|
|
7691
7587
|
//#endregion
|
|
7692
7588
|
//#region src/wallet/validation.ts
|
|
7693
7589
|
/**
|
|
@@ -7830,6 +7726,105 @@ function toD9Address(address) {
|
|
|
7830
7726
|
return toNetworkAddress(address, D9_SS58_PREFIX);
|
|
7831
7727
|
}
|
|
7832
7728
|
|
|
7729
|
+
//#endregion
|
|
7730
|
+
//#region src/utils/balance.ts
|
|
7731
|
+
/**
|
|
7732
|
+
* Balance formatting utilities for D9 blockchain
|
|
7733
|
+
*/
|
|
7734
|
+
/**
|
|
7735
|
+
* Pre-configured D9 token
|
|
7736
|
+
*/
|
|
7737
|
+
const D9_TOKEN = {
|
|
7738
|
+
decimals: D9_DECIMALS,
|
|
7739
|
+
symbol: D9_SYMBOL
|
|
7740
|
+
};
|
|
7741
|
+
/**
|
|
7742
|
+
* Pre-configured USDT token
|
|
7743
|
+
*/
|
|
7744
|
+
const USDT_TOKEN = {
|
|
7745
|
+
decimals: USDT_DECIMALS,
|
|
7746
|
+
symbol: USDT_SYMBOL
|
|
7747
|
+
};
|
|
7748
|
+
/**
|
|
7749
|
+
* Format a raw planck value to a human-readable balance string
|
|
7750
|
+
*
|
|
7751
|
+
* @param planck - The raw balance in planck units (smallest unit)
|
|
7752
|
+
* @param options - Formatting options
|
|
7753
|
+
* @returns Formatted balance string
|
|
7754
|
+
*
|
|
7755
|
+
* @example
|
|
7756
|
+
* ```typescript
|
|
7757
|
+
* formatBalance(1_500_000_000_000n, { decimals: 12 }); // "1.5"
|
|
7758
|
+
* formatBalance(1_500_000_000_000n, { decimals: 12, maxDecimals: 2 }); // "1.50"
|
|
7759
|
+
* formatBalance(1_000_000_000_000_000n, { decimals: 12, thousandsSeparator: "," }); // "1,000"
|
|
7760
|
+
* ```
|
|
7761
|
+
*/
|
|
7762
|
+
function formatBalance(planck, options = {}) {
|
|
7763
|
+
const { decimals = D9_DECIMALS, maxDecimals = 4, trimTrailingZeros = true, thousandsSeparator } = options;
|
|
7764
|
+
if (decimals < 0 || decimals > 30) throw new Error("Decimals must be between 0 and 30");
|
|
7765
|
+
const divisor = 10n ** BigInt(decimals);
|
|
7766
|
+
const isNegative = planck < 0n;
|
|
7767
|
+
const absolutePlanck = isNegative ? -planck : planck;
|
|
7768
|
+
const wholePart = absolutePlanck / divisor;
|
|
7769
|
+
const fractionalPart = absolutePlanck % divisor;
|
|
7770
|
+
let wholeStr = wholePart.toString();
|
|
7771
|
+
if (thousandsSeparator && wholeStr.length > 3) wholeStr = wholeStr.replace(/\B(?=(\d{3})+(?!\d))/g, thousandsSeparator);
|
|
7772
|
+
if (decimals === 0 || maxDecimals === 0) return isNegative ? `-${wholeStr}` : wholeStr;
|
|
7773
|
+
let fractionalStr = fractionalPart.toString().padStart(decimals, "0");
|
|
7774
|
+
if (fractionalStr.length > maxDecimals) fractionalStr = fractionalStr.slice(0, maxDecimals);
|
|
7775
|
+
if (trimTrailingZeros) fractionalStr = fractionalStr.replace(/0+$/, "");
|
|
7776
|
+
const prefix = isNegative ? "-" : "";
|
|
7777
|
+
if (fractionalStr === "") return `${prefix}${wholeStr}`;
|
|
7778
|
+
return `${prefix}${wholeStr}.${fractionalStr}`;
|
|
7779
|
+
}
|
|
7780
|
+
/**
|
|
7781
|
+
* Parse a human-readable amount string to planck units
|
|
7782
|
+
*
|
|
7783
|
+
* @param amount - The amount as a string or number
|
|
7784
|
+
* @param options - Parse options
|
|
7785
|
+
* @returns The amount in planck units (bigint)
|
|
7786
|
+
*
|
|
7787
|
+
* @example
|
|
7788
|
+
* ```typescript
|
|
7789
|
+
* parseAmount("1.5", { decimals: 12 }); // 1_500_000_000_000n
|
|
7790
|
+
* parseAmount(1.5, { decimals: 12 }); // 1_500_000_000_000n
|
|
7791
|
+
* parseAmount("1,000.50", { decimals: 12 }); // 1_000_500_000_000_000n
|
|
7792
|
+
* ```
|
|
7793
|
+
*/
|
|
7794
|
+
function parseAmount(amount, options = {}) {
|
|
7795
|
+
const { decimals = D9_DECIMALS } = options;
|
|
7796
|
+
if (decimals < 0 || decimals > 30) throw new Error("Decimals must be between 0 and 30");
|
|
7797
|
+
let amountStr = String(amount).replace(/,/g, "").trim();
|
|
7798
|
+
const isNegative = amountStr.startsWith("-");
|
|
7799
|
+
if (isNegative) amountStr = amountStr.slice(1);
|
|
7800
|
+
if (!/^\d*\.?\d*$/.test(amountStr) || amountStr === "" || amountStr === ".") throw new Error(`Invalid amount format: ${amount}`);
|
|
7801
|
+
const [wholePart = "0", fractionalPart = ""] = amountStr.split(".");
|
|
7802
|
+
if (fractionalPart.length > decimals) throw new Error(`Amount has more decimal places (${fractionalPart.length}) than supported (${decimals})`);
|
|
7803
|
+
const planckStr = wholePart + fractionalPart.padEnd(decimals, "0");
|
|
7804
|
+
const planck = BigInt(planckStr);
|
|
7805
|
+
return isNegative ? -planck : planck;
|
|
7806
|
+
}
|
|
7807
|
+
/**
|
|
7808
|
+
* Format a token amount with symbol
|
|
7809
|
+
*
|
|
7810
|
+
* @param planck - The raw balance in planck units
|
|
7811
|
+
* @param token - Token configuration
|
|
7812
|
+
* @param options - Additional formatting options
|
|
7813
|
+
* @returns Formatted string with token symbol
|
|
7814
|
+
*
|
|
7815
|
+
* @example
|
|
7816
|
+
* ```typescript
|
|
7817
|
+
* formatTokenAmount(1_500_000_000_000n, D9_TOKEN); // "1.5 D9"
|
|
7818
|
+
* formatTokenAmount(1000n, USDT_TOKEN); // "10 USDT"
|
|
7819
|
+
* ```
|
|
7820
|
+
*/
|
|
7821
|
+
function formatTokenAmount(planck, token, options = {}) {
|
|
7822
|
+
return `${formatBalance(planck, {
|
|
7823
|
+
...options,
|
|
7824
|
+
decimals: token.decimals
|
|
7825
|
+
})} ${token.symbol}`;
|
|
7826
|
+
}
|
|
7827
|
+
|
|
7833
7828
|
//#endregion
|
|
7834
7829
|
//#region src/utils/time.ts
|
|
7835
7830
|
/**
|
|
@@ -7965,5 +7960,5 @@ function formatBlockDuration(blocks, options = {}) {
|
|
|
7965
7960
|
}
|
|
7966
7961
|
|
|
7967
7962
|
//#endregion
|
|
7968
|
-
export { ArithmeticError, BLOCKS_PER_DAY, BLOCKS_PER_HOUR, BLOCKS_PER_MINUTE, BLOCKS_PER_WEEK, BalanceStatus, BalancesTypesReasons, ContractEventParser, D9_BLOCK_TIME_MS,
|
|
7963
|
+
export { ArithmeticError, BLOCKS_PER_DAY, BLOCKS_PER_HOUR, BLOCKS_PER_MINUTE, BLOCKS_PER_WEEK, BalanceStatus, BalancesTypesReasons, ContractEventParser, D9_BLOCK_TIME_MS, D9_TOKEN, DigestItem, DispatchClass, GrandpaEquivocation, GrandpaEvent, GrandpaStoredState, MultiAddress, Phase, SessionEvent, TransactionPaymentEvent, TransactionPaymentReleases, TransactionalError, USDT_TOKEN, addressesEqual, blocksToMs, blocksUntil, bytesToHex, contracts_exports as contracts, createAccountFromMnemonic, createAccountFromPrivateKey, createContractEventStream, createD9SdkClient, createNativeTransferStream, createPSP22TransferStream, createSr25519SignerFromKeypair, d9_default as d9, estimateBlockAtTime, estimateTimeAtBlock, formatBalance, formatBlockDuration, formatTokenAmount, generateMnemonic, getAddressPrefix, getMetadata2 as getMetadata, hexToBytes, isHexString, isValidAddress, isValidAddressForNetwork, isValidD9Address, mnemonicToMiniSecret, msToBlocks, parseAmount, sr25519AddressFromKeypair, sr25519AddressFromSecretKeyHex, sr25519DeriveFromMiniSecret, sr25519KeypairFromMiniSecret, ss58DecodePublicKey, ss58Reencode, toD9Address, toNetworkAddress, validateMnemonic };
|
|
7969
7964
|
//# sourceMappingURL=index.mjs.map
|