quantumcoin 7.0.6 → 7.0.8
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-SDK.md +53 -1
- package/SPEC.md +1 -1
- package/examples/package-lock.json +103 -454
- package/examples/package.json +1 -1
- package/generate-sdk.js +1 -0
- package/package.json +2 -2
- package/src/utils/fixednumber.d.ts +57 -0
- package/src/utils/fixednumber.js +366 -0
- package/src/utils/hashing.js +1 -1
- package/src/utils/index.d.ts +1 -0
- package/src/utils/index.js +1 -0
- package/src/wallet/wallet.d.ts +15 -1
- package/src/wallet/wallet.js +45 -3
- package/test/unit/address-wallet.test.js +172 -0
- package/test/unit/address-wallet.test.ts +170 -0
- package/test/unit/fixednumber.test.js +656 -0
- package/test/unit/fixednumber.test.ts +660 -0
- package/test/unit/hashing.test.js +7 -0
- package/test/unit/hashing.test.ts +7 -0
package/README-SDK.md
CHANGED
|
@@ -386,7 +386,9 @@ User-facing wallet class.
|
|
|
386
386
|
- `new Wallet(privateKeyOrBytesOrSigningKey, provider?: AbstractProvider)`
|
|
387
387
|
|
|
388
388
|
**Static methods**
|
|
389
|
-
- `Wallet.createRandom(provider?: AbstractProvider): Wallet`
|
|
389
|
+
- `Wallet.createRandom(provider?: AbstractProvider, keyType?: number | null): Wallet` — `keyType`: `null`/`3` (default, hybrid compact) or `5` (hybrid5)
|
|
390
|
+
- `Wallet.createRandomSeed(keyType?: number | null): string[]` — returns seed words (32 for keyType 3, 36 for keyType 5); pass to `fromPhrase` to open
|
|
391
|
+
- `Wallet.fromSeed(seed: number[], provider?: AbstractProvider): Wallet` — opens wallet from raw seed bytes (64/72/96 length)
|
|
390
392
|
- `Wallet.fromEncryptedJsonSync(json: string, password: string, provider?: AbstractProvider): Wallet`
|
|
391
393
|
- `Wallet.fromPhrase(phrase: string | string[], provider?: AbstractProvider): Wallet`
|
|
392
394
|
- `Wallet.fromKeys(privateKey: Uint8Array | string, publicKey: Uint8Array | string, provider?: AbstractProvider): Wallet`
|
|
@@ -635,6 +637,56 @@ const asOutput: Uint256 = 123n;
|
|
|
635
637
|
- `formatEther(value: BigNumberish): string`
|
|
636
638
|
- `parseEther(value: string): bigint`
|
|
637
639
|
|
|
640
|
+
### FixedNumber (fixed-point arithmetic)
|
|
641
|
+
|
|
642
|
+
Fixed-point decimal arithmetic compatible with ethers.js v5/v6.
|
|
643
|
+
|
|
644
|
+
**FixedFormat type:**
|
|
645
|
+
`number | string | { signed?: boolean, width?: number, decimals?: number }`
|
|
646
|
+
|
|
647
|
+
Default format: `"fixed128x18"` (signed, 128-bit, 18 decimals).
|
|
648
|
+
|
|
649
|
+
**Static factories:**
|
|
650
|
+
- `FixedNumber.fromString(value: string, format?: FixedFormat): FixedNumber`
|
|
651
|
+
- `FixedNumber.fromValue(value: BigNumberish, decimals?: number, format?: FixedFormat): FixedNumber`
|
|
652
|
+
- `FixedNumber.fromBytes(value: BytesLike, format?: FixedFormat): FixedNumber`
|
|
653
|
+
- `FixedNumber.from(value: any, format?: FixedFormat): FixedNumber` — dispatches to `fromString`, `fromBytes`, or `fromValue`
|
|
654
|
+
- `FixedNumber.isFixedNumber(value: any): boolean`
|
|
655
|
+
|
|
656
|
+
**Properties (read-only):**
|
|
657
|
+
- `format: string` — e.g. `"fixed128x18"`
|
|
658
|
+
- `signed: boolean`
|
|
659
|
+
- `width: number`
|
|
660
|
+
- `decimals: number`
|
|
661
|
+
- `value: bigint` — raw internal integer
|
|
662
|
+
|
|
663
|
+
**Arithmetic (safe throws on overflow, unsafe wraps silently):**
|
|
664
|
+
- `add(other)` / `addUnsafe(other): FixedNumber`
|
|
665
|
+
- `sub(other)` / `subUnsafe(other): FixedNumber`
|
|
666
|
+
- `mul(other)` / `mulUnsafe(other): FixedNumber`
|
|
667
|
+
- `div(other)` / `divUnsafe(other): FixedNumber`
|
|
668
|
+
- `mulSignal(other): FixedNumber` — throws on precision loss
|
|
669
|
+
- `divSignal(other): FixedNumber` — throws on precision loss
|
|
670
|
+
|
|
671
|
+
**Comparison:**
|
|
672
|
+
- `cmp(other): number` — returns `-1`, `0`, or `1`
|
|
673
|
+
- `eq(other)`, `lt(other)`, `lte(other)`, `gt(other)`, `gte(other): boolean`
|
|
674
|
+
|
|
675
|
+
**Rounding:**
|
|
676
|
+
- `floor(): FixedNumber`
|
|
677
|
+
- `ceiling(): FixedNumber`
|
|
678
|
+
- `round(decimals?: number): FixedNumber`
|
|
679
|
+
|
|
680
|
+
**Inspection:**
|
|
681
|
+
- `isZero(): boolean`
|
|
682
|
+
- `isNegative(): boolean`
|
|
683
|
+
|
|
684
|
+
**Conversion:**
|
|
685
|
+
- `toString(): string`
|
|
686
|
+
- `toUnsafeFloat(): number`
|
|
687
|
+
- `toFormat(format: FixedFormat): FixedNumber`
|
|
688
|
+
- `toHexString(width?: number): string`
|
|
689
|
+
|
|
638
690
|
### RLP
|
|
639
691
|
|
|
640
692
|
- `encodeRlp(value: any): string`
|
package/SPEC.md
CHANGED
|
@@ -2360,7 +2360,7 @@ The following utility classes are exported from ethers.js but not implemented in
|
|
|
2360
2360
|
|
|
2361
2361
|
**Purpose**: Represents fixed-point decimal numbers
|
|
2362
2362
|
|
|
2363
|
-
**
|
|
2363
|
+
**Status**: Implemented in `src/utils/fixednumber.js`. Provides ethers.js v5/v6-compatible fixed-point arithmetic using native `bigint`, including `fromString`, `fromValue`, `fromBytes`, `from`, safe/unsafe/signal arithmetic, comparison, rounding, and format conversion. See `README-SDK.md` for full API documentation.
|
|
2364
2364
|
|
|
2365
2365
|
---
|
|
2366
2366
|
|