@d9-network/spec 0.2.0 → 1.0.1
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 +24 -21
- package/dist/index.cjs +2746 -83
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +109 -888
- package/dist/index.d.mts +109 -888
- package/dist/index.mjs +2721 -51
- package/dist/index.mjs.map +1 -1
- package/package.json +3 -6
package/README.md
CHANGED
|
@@ -15,22 +15,21 @@ pnpm add @d9-network/spec
|
|
|
15
15
|
## Quick Start
|
|
16
16
|
|
|
17
17
|
```typescript
|
|
18
|
-
import {
|
|
18
|
+
import { createD9Client } from "@d9-network/client";
|
|
19
|
+
import { generateMnemonic, createAccountFromMnemonic } from "@d9-network/spec";
|
|
19
20
|
|
|
20
|
-
// Create
|
|
21
|
-
const
|
|
22
|
-
endpoint: "wss://mainnet.d9network.xyz:40300",
|
|
23
|
-
});
|
|
21
|
+
// Create client
|
|
22
|
+
const client = createD9Client();
|
|
24
23
|
|
|
25
24
|
// Generate a new wallet
|
|
26
25
|
const mnemonic = generateMnemonic();
|
|
27
|
-
const
|
|
28
|
-
console.log("Address:",
|
|
26
|
+
const account = createAccountFromMnemonic(mnemonic);
|
|
27
|
+
console.log("Address:", account.address);
|
|
29
28
|
|
|
30
29
|
// Query USDT balance
|
|
31
|
-
const result = await
|
|
32
|
-
origin:
|
|
33
|
-
args: { owner:
|
|
30
|
+
const result = await client.inkSdk.usdt.query("PSP22::balance_of", {
|
|
31
|
+
origin: account.address,
|
|
32
|
+
args: { owner: account.address },
|
|
34
33
|
});
|
|
35
34
|
|
|
36
35
|
if (result.success) {
|
|
@@ -40,20 +39,14 @@ if (result.success) {
|
|
|
40
39
|
|
|
41
40
|
## Features
|
|
42
41
|
|
|
43
|
-
- **D9 Blockchain Client**: Pre-configured Polkadot-API client for D9 network
|
|
44
42
|
- **Wallet Management**: HD wallet derivation, SR25519 signing, SS58 encoding
|
|
45
43
|
- **Contract Descriptors**: Type-safe descriptors for D9 smart contracts
|
|
46
44
|
- **Chain Specifications**: D9 network metadata and type definitions
|
|
47
|
-
- **Utility Functions**: Balance formatting, address validation
|
|
45
|
+
- **Utility Functions**: Balance formatting, address validation
|
|
46
|
+
- **Constants**: D9 chain constants (SS58 prefix, decimals, etc.)
|
|
48
47
|
|
|
49
48
|
## API Overview
|
|
50
49
|
|
|
51
|
-
### Client
|
|
52
|
-
|
|
53
|
-
| Export | Description |
|
|
54
|
-
| ------------------- | ------------------------------------------ |
|
|
55
|
-
| `createD9SdkClient` | Create D9 SDK client with contract support |
|
|
56
|
-
|
|
57
50
|
### Wallet
|
|
58
51
|
|
|
59
52
|
| Export | Description |
|
|
@@ -67,12 +60,22 @@ if (result.success) {
|
|
|
67
60
|
| Export | Description |
|
|
68
61
|
| ---------------- | -------------------------------- |
|
|
69
62
|
| `formatBalance` | Format token balance for display |
|
|
70
|
-
| `
|
|
63
|
+
| `parseAmount` | Parse balance string to bigint |
|
|
71
64
|
| `isValidAddress` | Validate SS58 address |
|
|
72
65
|
|
|
66
|
+
### Constants
|
|
67
|
+
|
|
68
|
+
| Export | Description |
|
|
69
|
+
| ---------------- | ------------------------------ |
|
|
70
|
+
| `D9_SS58_PREFIX` | D9 network SS58 prefix (9) |
|
|
71
|
+
| `D9_DECIMALS` | D9 token decimals (12) |
|
|
72
|
+
| `D9_SYMBOL` | D9 token symbol ("D9") |
|
|
73
|
+
| `USDT_DECIMALS` | USDT token decimals (2) |
|
|
74
|
+
| `USDT_SYMBOL` | USDT token symbol ("USDT") |
|
|
75
|
+
|
|
73
76
|
### Contract Descriptors
|
|
74
77
|
|
|
75
|
-
Pre-built descriptors for D9 smart contracts:
|
|
78
|
+
Pre-built descriptors for D9 smart contracts (from `@polkadot-api/descriptors`):
|
|
76
79
|
|
|
77
80
|
- `usdt` - USDT PSP22 token
|
|
78
81
|
- `burnManager` - Token burning mechanism
|
|
@@ -82,7 +85,7 @@ Pre-built descriptors for D9 smart contracts:
|
|
|
82
85
|
|
|
83
86
|
For complete documentation, examples, and API reference, visit:
|
|
84
87
|
|
|
85
|
-
- [D9 SDK Documentation](https://docs.d9network.
|
|
88
|
+
- [D9 SDK Documentation](https://docs.d9network.com/docs/sdk/spec/overview)
|
|
86
89
|
|
|
87
90
|
## License
|
|
88
91
|
|