@d9-network/spec 0.0.3 → 0.0.6
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/d9_metadata-KHMVPHO2-BILssUTo.mjs +6 -0
- package/dist/d9_metadata-KHMVPHO2-BILssUTo.mjs.map +1 -0
- package/dist/d9_metadata-KHMVPHO2-CTHNW2Z9.cjs +7 -0
- package/dist/d9_metadata-KHMVPHO2-CTHNW2Z9.cjs.map +1 -0
- package/dist/descriptors-KKD7UFMX-BQkrqfg1.mjs +16 -0
- package/dist/descriptors-KKD7UFMX-BQkrqfg1.mjs.map +1 -0
- package/dist/descriptors-KKD7UFMX-DBUb__c-.cjs +17 -0
- package/dist/descriptors-KKD7UFMX-DBUb__c-.cjs.map +1 -0
- package/dist/index.cjs +250 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +8712 -0
- package/dist/index.d.mts +8712 -0
- package/dist/index.mjs +195 -0
- package/dist/index.mjs.map +1 -0
- package/dist/metadataTypes-LUDFOAMC-DTvnnJbu.cjs +7 -0
- package/dist/metadataTypes-LUDFOAMC-DTvnnJbu.cjs.map +1 -0
- package/dist/metadataTypes-LUDFOAMC-FMlTA1su.mjs +6 -0
- package/dist/metadataTypes-LUDFOAMC-FMlTA1su.mjs.map +1 -0
- package/package.json +4 -1
- package/.claude/settings.local.json +0 -8
- package/.papi/contracts/burnManager.json +0 -1300
- package/.papi/contracts/burnMining.json +0 -1385
- package/.papi/contracts/crossChainTransfer.json +0 -1693
- package/.papi/contracts/marketMaker.json +0 -1470
- package/.papi/contracts/merchantMining.json +0 -1750
- package/.papi/contracts/miningPool.json +0 -1019
- package/.papi/contracts/nodeReward.json +0 -1214
- package/.papi/contracts/usdt.json +0 -1036
- package/.papi/descriptors/.gitignore +0 -3
- package/.papi/descriptors/package.json +0 -24
- package/.papi/metadata/d9.scale +0 -0
- package/.papi/polkadot-api.json +0 -22
- package/assets/ABIs/burn-manager.json +0 -1300
- package/assets/ABIs/burn-mining.json +0 -1385
- package/assets/ABIs/cross-chain-transfer.json +0 -1693
- package/assets/ABIs/market-maker.json +0 -1470
- package/assets/ABIs/merchant-mining.json +0 -1750
- package/assets/ABIs/mining-pool.json +0 -1019
- package/assets/ABIs/node-reward.json +0 -1214
- package/assets/ABIs/usdt.json +0 -1036
- package/docs/CLAUDE.md +0 -364
- package/docs/CONTRACTS.md +0 -603
- package/docs/PALLETS.md +0 -726
- package/docs/TYPES.md +0 -618
- package/scripts/papi-add-ink.ts +0 -104
- package/src/client.ts +0 -68
- package/src/index.ts +0 -17
- package/src/wallet/account.ts +0 -57
- package/src/wallet/hex.ts +0 -30
- package/src/wallet/index.ts +0 -6
- package/src/wallet/mnemonic.ts +0 -19
- package/src/wallet/signer.ts +0 -9
- package/src/wallet/sr25519.ts +0 -42
- package/src/wallet/ss58.ts +0 -14
- package/test/client.test.ts +0 -15
- package/test/descriptors.test.ts +0 -32
- package/test/wallet.test.ts +0 -65
- package/tsconfig.json +0 -13
- package/tsdown.config.ts +0 -19
package/docs/TYPES.md
DELETED
|
@@ -1,618 +0,0 @@
|
|
|
1
|
-
# D9 Chain Types Documentation
|
|
2
|
-
|
|
3
|
-
This document describes the type system used by the D9 blockchain, including common types, enums, and type utilities from the polkadot-api integration.
|
|
4
|
-
|
|
5
|
-
## Table of Contents
|
|
6
|
-
|
|
7
|
-
1. [Core Types](#core-types)
|
|
8
|
-
2. [Account Types](#account-types)
|
|
9
|
-
3. [Balance Types](#balance-types)
|
|
10
|
-
4. [Governance Types](#governance-types)
|
|
11
|
-
5. [Session Types](#session-types)
|
|
12
|
-
6. [Contract Types](#contract-types)
|
|
13
|
-
7. [Event Types](#event-types)
|
|
14
|
-
8. [Error Types](#error-types)
|
|
15
|
-
9. [Type Utilities](#type-utilities)
|
|
16
|
-
|
|
17
|
-
---
|
|
18
|
-
|
|
19
|
-
## Core Types
|
|
20
|
-
|
|
21
|
-
### Basic Types
|
|
22
|
-
|
|
23
|
-
| Type | TypeScript | Description |
|
|
24
|
-
|------|------------|-------------|
|
|
25
|
-
| `SS58String` | `string` | SS58-encoded account address (prefix 9 for D9) |
|
|
26
|
-
| `Binary` | `Uint8Array` | Variable-length binary data |
|
|
27
|
-
| `FixedSizeBinary<N>` | `Uint8Array` | Fixed-length binary (N bytes) |
|
|
28
|
-
| `Hash` / `H256` | `FixedSizeBinary<32>` | 256-bit hash |
|
|
29
|
-
| `BlockNumber` | `number` | Block number (u32) |
|
|
30
|
-
| `Balance` | `bigint` | Token balance (u128) |
|
|
31
|
-
| `AccountId` | `SS58String` | Account identifier |
|
|
32
|
-
| `Index` | `number` | Account nonce |
|
|
33
|
-
|
|
34
|
-
### Timestamp
|
|
35
|
-
|
|
36
|
-
```typescript
|
|
37
|
-
// Milliseconds since Unix epoch
|
|
38
|
-
type Moment = bigint;
|
|
39
|
-
```
|
|
40
|
-
|
|
41
|
-
### Weight
|
|
42
|
-
|
|
43
|
-
```typescript
|
|
44
|
-
type Weight = {
|
|
45
|
-
ref_time: bigint; // Reference time
|
|
46
|
-
proof_size: bigint; // Proof size
|
|
47
|
-
};
|
|
48
|
-
```
|
|
49
|
-
|
|
50
|
-
---
|
|
51
|
-
|
|
52
|
-
## Account Types
|
|
53
|
-
|
|
54
|
-
### AccountInfo
|
|
55
|
-
|
|
56
|
-
Full account information stored in the System pallet.
|
|
57
|
-
|
|
58
|
-
```typescript
|
|
59
|
-
type AccountInfo = {
|
|
60
|
-
nonce: number; // Transaction count
|
|
61
|
-
consumers: number; // Consumer reference count
|
|
62
|
-
providers: number; // Provider reference count
|
|
63
|
-
sufficients: number; // Sufficient reference count
|
|
64
|
-
data: AccountData; // Balance data
|
|
65
|
-
};
|
|
66
|
-
```
|
|
67
|
-
|
|
68
|
-
### AccountData
|
|
69
|
-
|
|
70
|
-
Account balance information.
|
|
71
|
-
|
|
72
|
-
```typescript
|
|
73
|
-
type AccountData = {
|
|
74
|
-
free: bigint; // Free balance
|
|
75
|
-
reserved: bigint; // Reserved balance
|
|
76
|
-
frozen: bigint; // Frozen balance (max of misc_frozen and fee_frozen)
|
|
77
|
-
flags: bigint; // Extra account flags
|
|
78
|
-
};
|
|
79
|
-
```
|
|
80
|
-
|
|
81
|
-
### MultiAddress
|
|
82
|
-
|
|
83
|
-
Multi-format address used in extrinsics.
|
|
84
|
-
|
|
85
|
-
```typescript
|
|
86
|
-
type MultiAddress = Enum<{
|
|
87
|
-
Id: SS58String; // Raw account ID
|
|
88
|
-
Index: number; // Account index
|
|
89
|
-
Raw: Binary; // Raw bytes
|
|
90
|
-
Address32: FixedSizeBinary<32>;
|
|
91
|
-
Address20: FixedSizeBinary<20>;
|
|
92
|
-
}>;
|
|
93
|
-
```
|
|
94
|
-
|
|
95
|
-
---
|
|
96
|
-
|
|
97
|
-
## Balance Types
|
|
98
|
-
|
|
99
|
-
### BalanceLock
|
|
100
|
-
|
|
101
|
-
Balance lock information.
|
|
102
|
-
|
|
103
|
-
```typescript
|
|
104
|
-
type BalanceLock = {
|
|
105
|
-
id: FixedSizeBinary<8>; // Lock identifier
|
|
106
|
-
amount: bigint; // Locked amount
|
|
107
|
-
reasons: BalancesTypesReasons;
|
|
108
|
-
};
|
|
109
|
-
|
|
110
|
-
type BalancesTypesReasons = Enum<{
|
|
111
|
-
Fee: undefined;
|
|
112
|
-
Misc: undefined;
|
|
113
|
-
All: undefined;
|
|
114
|
-
}>;
|
|
115
|
-
```
|
|
116
|
-
|
|
117
|
-
### ReserveData
|
|
118
|
-
|
|
119
|
-
Named reserve information.
|
|
120
|
-
|
|
121
|
-
```typescript
|
|
122
|
-
type ReserveData = {
|
|
123
|
-
id: FixedSizeBinary<8>; // Reserve identifier
|
|
124
|
-
amount: bigint; // Reserved amount
|
|
125
|
-
};
|
|
126
|
-
```
|
|
127
|
-
|
|
128
|
-
### BalanceStatus
|
|
129
|
-
|
|
130
|
-
Balance status for reserve repatriation.
|
|
131
|
-
|
|
132
|
-
```typescript
|
|
133
|
-
type BalanceStatus = Enum<{
|
|
134
|
-
Free: undefined;
|
|
135
|
-
Reserved: undefined;
|
|
136
|
-
}>;
|
|
137
|
-
```
|
|
138
|
-
|
|
139
|
-
---
|
|
140
|
-
|
|
141
|
-
## Governance Types
|
|
142
|
-
|
|
143
|
-
### Votes
|
|
144
|
-
|
|
145
|
-
Voting information for a proposal.
|
|
146
|
-
|
|
147
|
-
```typescript
|
|
148
|
-
type Votes = {
|
|
149
|
-
index: number; // Proposal index
|
|
150
|
-
threshold: number; // Required votes
|
|
151
|
-
ayes: SS58String[]; // Accounts voting aye
|
|
152
|
-
nays: SS58String[]; // Accounts voting nay
|
|
153
|
-
end: number; // End block number
|
|
154
|
-
};
|
|
155
|
-
```
|
|
156
|
-
|
|
157
|
-
### Proposal (Treasury)
|
|
158
|
-
|
|
159
|
-
Treasury spending proposal.
|
|
160
|
-
|
|
161
|
-
```typescript
|
|
162
|
-
type TreasuryProposal = {
|
|
163
|
-
proposer: SS58String;
|
|
164
|
-
value: bigint;
|
|
165
|
-
beneficiary: SS58String;
|
|
166
|
-
bond: bigint;
|
|
167
|
-
};
|
|
168
|
-
```
|
|
169
|
-
|
|
170
|
-
### Phase
|
|
171
|
-
|
|
172
|
-
Execution phase of the block.
|
|
173
|
-
|
|
174
|
-
```typescript
|
|
175
|
-
type Phase = Enum<{
|
|
176
|
-
ApplyExtrinsic: number; // Extrinsic index
|
|
177
|
-
Finalization: undefined;
|
|
178
|
-
Initialization: undefined;
|
|
179
|
-
}>;
|
|
180
|
-
```
|
|
181
|
-
|
|
182
|
-
---
|
|
183
|
-
|
|
184
|
-
## Session Types
|
|
185
|
-
|
|
186
|
-
### SessionKeys
|
|
187
|
-
|
|
188
|
-
Session keys for validators.
|
|
189
|
-
|
|
190
|
-
```typescript
|
|
191
|
-
type SessionKeys = {
|
|
192
|
-
aura: FixedSizeBinary<32>; // Aura key
|
|
193
|
-
grandpa: FixedSizeBinary<32>; // GRANDPA key
|
|
194
|
-
im_online: FixedSizeBinary<32>; // ImOnline key
|
|
195
|
-
authority_discovery: FixedSizeBinary<32>;
|
|
196
|
-
};
|
|
197
|
-
```
|
|
198
|
-
|
|
199
|
-
### ValidatorVoteStats
|
|
200
|
-
|
|
201
|
-
Validator voting statistics.
|
|
202
|
-
|
|
203
|
-
```typescript
|
|
204
|
-
type ValidatorVoteStats = {
|
|
205
|
-
total_votes: bigint;
|
|
206
|
-
supporter_share: number; // Percentage (0-100)
|
|
207
|
-
};
|
|
208
|
-
```
|
|
209
|
-
|
|
210
|
-
### NodeMetadata
|
|
211
|
-
|
|
212
|
-
Node/candidate metadata.
|
|
213
|
-
|
|
214
|
-
```typescript
|
|
215
|
-
type NodeMetadata = {
|
|
216
|
-
name: string;
|
|
217
|
-
sharing_percent: number;
|
|
218
|
-
};
|
|
219
|
-
```
|
|
220
|
-
|
|
221
|
-
---
|
|
222
|
-
|
|
223
|
-
## Contract Types
|
|
224
|
-
|
|
225
|
-
### ContractInfo
|
|
226
|
-
|
|
227
|
-
Contract instance information.
|
|
228
|
-
|
|
229
|
-
```typescript
|
|
230
|
-
type ContractInfo = {
|
|
231
|
-
trie_id: Binary; // Storage trie ID
|
|
232
|
-
code_hash: FixedSizeBinary<32>;
|
|
233
|
-
storage_bytes: number;
|
|
234
|
-
storage_items: number;
|
|
235
|
-
storage_byte_deposit: bigint;
|
|
236
|
-
storage_item_deposit: bigint;
|
|
237
|
-
storage_base_deposit: bigint;
|
|
238
|
-
};
|
|
239
|
-
```
|
|
240
|
-
|
|
241
|
-
### InstrumentedCode
|
|
242
|
-
|
|
243
|
-
Instrumented WASM code for execution.
|
|
244
|
-
|
|
245
|
-
```typescript
|
|
246
|
-
type InstrumentedCode = {
|
|
247
|
-
code: Binary;
|
|
248
|
-
initial: number;
|
|
249
|
-
maximum: number;
|
|
250
|
-
};
|
|
251
|
-
```
|
|
252
|
-
|
|
253
|
-
### CodeOwnerInfo
|
|
254
|
-
|
|
255
|
-
Code ownership information.
|
|
256
|
-
|
|
257
|
-
```typescript
|
|
258
|
-
type CodeOwnerInfo = {
|
|
259
|
-
owner: SS58String;
|
|
260
|
-
deposit: bigint;
|
|
261
|
-
refcount: bigint;
|
|
262
|
-
};
|
|
263
|
-
```
|
|
264
|
-
|
|
265
|
-
### Determinism
|
|
266
|
-
|
|
267
|
-
Code determinism mode.
|
|
268
|
-
|
|
269
|
-
```typescript
|
|
270
|
-
type Determinism = Enum<{
|
|
271
|
-
Enforced: undefined;
|
|
272
|
-
Relaxed: undefined;
|
|
273
|
-
}>;
|
|
274
|
-
```
|
|
275
|
-
|
|
276
|
-
---
|
|
277
|
-
|
|
278
|
-
## Event Types
|
|
279
|
-
|
|
280
|
-
### EventRecord
|
|
281
|
-
|
|
282
|
-
Event record stored in blocks.
|
|
283
|
-
|
|
284
|
-
```typescript
|
|
285
|
-
type EventRecord = {
|
|
286
|
-
phase: Phase;
|
|
287
|
-
event: RuntimeEvent; // The actual event
|
|
288
|
-
topics: FixedSizeBinary<32>[];
|
|
289
|
-
};
|
|
290
|
-
```
|
|
291
|
-
|
|
292
|
-
### DispatchInfo
|
|
293
|
-
|
|
294
|
-
Dispatch information for extrinsics.
|
|
295
|
-
|
|
296
|
-
```typescript
|
|
297
|
-
type DispatchInfo = {
|
|
298
|
-
weight: Weight;
|
|
299
|
-
class: DispatchClass;
|
|
300
|
-
pays_fee: Pays;
|
|
301
|
-
};
|
|
302
|
-
|
|
303
|
-
type DispatchClass = Enum<{
|
|
304
|
-
Normal: undefined;
|
|
305
|
-
Operational: undefined;
|
|
306
|
-
Mandatory: undefined;
|
|
307
|
-
}>;
|
|
308
|
-
|
|
309
|
-
type Pays = Enum<{
|
|
310
|
-
Yes: undefined;
|
|
311
|
-
No: undefined;
|
|
312
|
-
}>;
|
|
313
|
-
```
|
|
314
|
-
|
|
315
|
-
---
|
|
316
|
-
|
|
317
|
-
## Error Types
|
|
318
|
-
|
|
319
|
-
### DispatchError
|
|
320
|
-
|
|
321
|
-
Top-level dispatch error type.
|
|
322
|
-
|
|
323
|
-
```typescript
|
|
324
|
-
type DispatchError = Enum<{
|
|
325
|
-
Other: undefined;
|
|
326
|
-
CannotLookup: undefined;
|
|
327
|
-
BadOrigin: undefined;
|
|
328
|
-
Module: ModuleError;
|
|
329
|
-
ConsumerRemaining: undefined;
|
|
330
|
-
NoProviders: undefined;
|
|
331
|
-
TooManyConsumers: undefined;
|
|
332
|
-
Token: TokenError;
|
|
333
|
-
Arithmetic: ArithmeticError;
|
|
334
|
-
Transactional: TransactionalError;
|
|
335
|
-
Exhausted: undefined;
|
|
336
|
-
Corruption: undefined;
|
|
337
|
-
Unavailable: undefined;
|
|
338
|
-
}>;
|
|
339
|
-
```
|
|
340
|
-
|
|
341
|
-
### ModuleError
|
|
342
|
-
|
|
343
|
-
Pallet-specific error.
|
|
344
|
-
|
|
345
|
-
```typescript
|
|
346
|
-
type ModuleError = {
|
|
347
|
-
index: number; // Pallet index
|
|
348
|
-
error: FixedSizeBinary<4>; // Error variant
|
|
349
|
-
};
|
|
350
|
-
```
|
|
351
|
-
|
|
352
|
-
### ArithmeticError
|
|
353
|
-
|
|
354
|
-
Arithmetic operation errors.
|
|
355
|
-
|
|
356
|
-
```typescript
|
|
357
|
-
type ArithmeticError = Enum<{
|
|
358
|
-
Underflow: undefined;
|
|
359
|
-
Overflow: undefined;
|
|
360
|
-
DivisionByZero: undefined;
|
|
361
|
-
}>;
|
|
362
|
-
```
|
|
363
|
-
|
|
364
|
-
### TokenError
|
|
365
|
-
|
|
366
|
-
Token-related errors.
|
|
367
|
-
|
|
368
|
-
```typescript
|
|
369
|
-
type TokenError = Enum<{
|
|
370
|
-
FundsUnavailable: undefined;
|
|
371
|
-
OnlyProvider: undefined;
|
|
372
|
-
BelowMinimum: undefined;
|
|
373
|
-
CannotCreate: undefined;
|
|
374
|
-
UnknownAsset: undefined;
|
|
375
|
-
Frozen: undefined;
|
|
376
|
-
Unsupported: undefined;
|
|
377
|
-
CannotCreateHold: undefined;
|
|
378
|
-
NotExpendable: undefined;
|
|
379
|
-
}>;
|
|
380
|
-
```
|
|
381
|
-
|
|
382
|
-
### TransactionalError
|
|
383
|
-
|
|
384
|
-
Transactional layer errors.
|
|
385
|
-
|
|
386
|
-
```typescript
|
|
387
|
-
type TransactionalError = Enum<{
|
|
388
|
-
LimitReached: undefined;
|
|
389
|
-
NoLayer: undefined;
|
|
390
|
-
}>;
|
|
391
|
-
```
|
|
392
|
-
|
|
393
|
-
---
|
|
394
|
-
|
|
395
|
-
## Type Utilities
|
|
396
|
-
|
|
397
|
-
### Enum<T>
|
|
398
|
-
|
|
399
|
-
Rust-style enum type. Only one variant is active at a time.
|
|
400
|
-
|
|
401
|
-
```typescript
|
|
402
|
-
type MyEnum = Enum<{
|
|
403
|
-
VariantA: undefined; // Unit variant
|
|
404
|
-
VariantB: number; // Variant with data
|
|
405
|
-
VariantC: { foo: string }; // Struct variant
|
|
406
|
-
}>;
|
|
407
|
-
|
|
408
|
-
// Usage
|
|
409
|
-
const value: MyEnum = { type: 'VariantB', value: 42 };
|
|
410
|
-
```
|
|
411
|
-
|
|
412
|
-
### ResultPayload<T, E>
|
|
413
|
-
|
|
414
|
-
Rust Result type for fallible operations.
|
|
415
|
-
|
|
416
|
-
```typescript
|
|
417
|
-
type ResultPayload<T, E> =
|
|
418
|
-
| { success: true; value: T }
|
|
419
|
-
| { success: false; value: E };
|
|
420
|
-
```
|
|
421
|
-
|
|
422
|
-
### FixedSizeArray<N, T>
|
|
423
|
-
|
|
424
|
-
Fixed-length array type.
|
|
425
|
-
|
|
426
|
-
```typescript
|
|
427
|
-
type FixedSizeArray<N extends number, T> = T[] & { length: N };
|
|
428
|
-
|
|
429
|
-
// Example: 2-element tuple
|
|
430
|
-
type Pair = FixedSizeArray<2, bigint>; // [bigint, bigint]
|
|
431
|
-
```
|
|
432
|
-
|
|
433
|
-
### Anonymize<T>
|
|
434
|
-
|
|
435
|
-
Type utility for normalizing complex types (used internally by polkadot-api).
|
|
436
|
-
|
|
437
|
-
```typescript
|
|
438
|
-
// Converts nested structures to plain objects
|
|
439
|
-
// Handles FixedSizeBinary, Enum, and tuple types
|
|
440
|
-
type Anonymize<T> = /* ... */;
|
|
441
|
-
```
|
|
442
|
-
|
|
443
|
-
---
|
|
444
|
-
|
|
445
|
-
## D9-Specific Types
|
|
446
|
-
|
|
447
|
-
### VotingInterests
|
|
448
|
-
|
|
449
|
-
User voting power in the D9NodeVoting pallet.
|
|
450
|
-
|
|
451
|
-
```typescript
|
|
452
|
-
type VotingInterests = {
|
|
453
|
-
total_votes: bigint; // Total voting power
|
|
454
|
-
available_votes: bigint; // Available to delegate
|
|
455
|
-
};
|
|
456
|
-
```
|
|
457
|
-
|
|
458
|
-
### LockInfo (CouncilLock)
|
|
459
|
-
|
|
460
|
-
Account lock information.
|
|
461
|
-
|
|
462
|
-
```typescript
|
|
463
|
-
type LockInfo = {
|
|
464
|
-
locked_at: number; // Block number when locked
|
|
465
|
-
reason: string; // Lock reason
|
|
466
|
-
};
|
|
467
|
-
```
|
|
468
|
-
|
|
469
|
-
### Referendum
|
|
470
|
-
|
|
471
|
-
Active referendum data.
|
|
472
|
-
|
|
473
|
-
```typescript
|
|
474
|
-
type Referendum = {
|
|
475
|
-
account: SS58String;
|
|
476
|
-
proposal_type: 'Lock' | 'Unlock';
|
|
477
|
-
votes_for: number;
|
|
478
|
-
votes_against: number;
|
|
479
|
-
end_block: number;
|
|
480
|
-
};
|
|
481
|
-
```
|
|
482
|
-
|
|
483
|
-
### MultiSignatureAccount
|
|
484
|
-
|
|
485
|
-
Multi-sig account information.
|
|
486
|
-
|
|
487
|
-
```typescript
|
|
488
|
-
type MultiSignatureAccount = {
|
|
489
|
-
signatories: SS58String[];
|
|
490
|
-
authors: SS58String[];
|
|
491
|
-
min_approvals: number;
|
|
492
|
-
};
|
|
493
|
-
```
|
|
494
|
-
|
|
495
|
-
### PendingCall
|
|
496
|
-
|
|
497
|
-
Pending multi-sig call.
|
|
498
|
-
|
|
499
|
-
```typescript
|
|
500
|
-
type PendingCall = {
|
|
501
|
-
call_id: FixedSizeBinary<32>;
|
|
502
|
-
author: SS58String;
|
|
503
|
-
call_data: Binary;
|
|
504
|
-
approvals: SS58String[];
|
|
505
|
-
created_at: number;
|
|
506
|
-
};
|
|
507
|
-
```
|
|
508
|
-
|
|
509
|
-
---
|
|
510
|
-
|
|
511
|
-
## Exported Types from @d9-network/spec
|
|
512
|
-
|
|
513
|
-
The SDK exports the following type utilities:
|
|
514
|
-
|
|
515
|
-
```typescript
|
|
516
|
-
import type {
|
|
517
|
-
D9, // Chain descriptor type
|
|
518
|
-
D9Queries, // All query types
|
|
519
|
-
D9Calls, // All extrinsic types
|
|
520
|
-
D9Events, // All event types
|
|
521
|
-
D9Errors, // All error types
|
|
522
|
-
D9Constants, // All constant types
|
|
523
|
-
D9DispatchError, // Dispatch error type
|
|
524
|
-
D9CallData, // Call data type
|
|
525
|
-
D9WhitelistEntry, // Whitelist entry type
|
|
526
|
-
} from '@d9-network/spec';
|
|
527
|
-
```
|
|
528
|
-
|
|
529
|
-
### Query Types
|
|
530
|
-
|
|
531
|
-
```typescript
|
|
532
|
-
// Query a specific storage item
|
|
533
|
-
type BalanceQuery = D9Queries['Balances']['Account'];
|
|
534
|
-
// Returns: (key: SS58String) => Promise<AccountData>
|
|
535
|
-
```
|
|
536
|
-
|
|
537
|
-
### Call Types
|
|
538
|
-
|
|
539
|
-
```typescript
|
|
540
|
-
// Build a specific extrinsic
|
|
541
|
-
type TransferCall = D9Calls['Balances']['transfer_keep_alive'];
|
|
542
|
-
// Parameters: { dest: MultiAddress, value: bigint }
|
|
543
|
-
```
|
|
544
|
-
|
|
545
|
-
### Event Types
|
|
546
|
-
|
|
547
|
-
```typescript
|
|
548
|
-
// Handle a specific event
|
|
549
|
-
type TransferEvent = D9Events['Balances']['Transfer'];
|
|
550
|
-
// Data: { from: SS58String, to: SS58String, amount: bigint }
|
|
551
|
-
```
|
|
552
|
-
|
|
553
|
-
---
|
|
554
|
-
|
|
555
|
-
## Contract Result Types
|
|
556
|
-
|
|
557
|
-
### Contract Call Result
|
|
558
|
-
|
|
559
|
-
```typescript
|
|
560
|
-
type ContractCallResult<T, E> = ResultPayload<
|
|
561
|
-
ResultPayload<T, E>, // Contract result
|
|
562
|
-
{ CouldNotReadInput: undefined } // Decode error
|
|
563
|
-
>;
|
|
564
|
-
```
|
|
565
|
-
|
|
566
|
-
### Common Contract Errors
|
|
567
|
-
|
|
568
|
-
```typescript
|
|
569
|
-
// PSP22 Token Errors
|
|
570
|
-
type PSP22Error = Enum<{
|
|
571
|
-
Custom: string;
|
|
572
|
-
InsufficientBalance: undefined;
|
|
573
|
-
InsufficientAllowance: undefined;
|
|
574
|
-
ZeroRecipientAddress: undefined;
|
|
575
|
-
ZeroSenderAddress: undefined;
|
|
576
|
-
SafeTransferCheckFailed: string;
|
|
577
|
-
}>;
|
|
578
|
-
|
|
579
|
-
// Cross-contract call errors
|
|
580
|
-
type InkEnvError = Enum<{
|
|
581
|
-
SomeEnvironmentError: undefined;
|
|
582
|
-
CalledContractTrapped: undefined;
|
|
583
|
-
CalledContractReverted: undefined;
|
|
584
|
-
NotCallable: undefined;
|
|
585
|
-
SomeDecodeError: undefined;
|
|
586
|
-
// ... more variants
|
|
587
|
-
}>;
|
|
588
|
-
```
|
|
589
|
-
|
|
590
|
-
---
|
|
591
|
-
|
|
592
|
-
## SS58 Address Format
|
|
593
|
-
|
|
594
|
-
D9 uses SS58 prefix `9` for addresses.
|
|
595
|
-
|
|
596
|
-
```typescript
|
|
597
|
-
// Example D9 address
|
|
598
|
-
const address: SS58String = "9aBC123...xyz";
|
|
599
|
-
|
|
600
|
-
// Converting from raw public key
|
|
601
|
-
import { encodeAddress } from '@polkadot/util-crypto';
|
|
602
|
-
const ss58Address = encodeAddress(publicKey, 9);
|
|
603
|
-
```
|
|
604
|
-
|
|
605
|
-
### Address Validation
|
|
606
|
-
|
|
607
|
-
```typescript
|
|
608
|
-
import { isAddress } from '@polkadot/util-crypto';
|
|
609
|
-
|
|
610
|
-
// Check if valid SS58 address with prefix 9
|
|
611
|
-
const isValidD9Address = (addr: string) => {
|
|
612
|
-
try {
|
|
613
|
-
return isAddress(addr) && decodeAddress(addr);
|
|
614
|
-
} catch {
|
|
615
|
-
return false;
|
|
616
|
-
}
|
|
617
|
-
};
|
|
618
|
-
```
|
package/scripts/papi-add-ink.ts
DELETED
|
@@ -1,104 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env bun
|
|
2
|
-
|
|
3
|
-
import { Glob } from "bun";
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* Script to add all JSON files from assets/ABIs directory using papi ink add
|
|
7
|
-
*/
|
|
8
|
-
|
|
9
|
-
const SCRIPT_DIR = import.meta.dir!;
|
|
10
|
-
const SDK_DIR = `${SCRIPT_DIR}/..`;
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* Convert filename to camelCase key
|
|
14
|
-
* Examples:
|
|
15
|
-
* - "d9-usdt.json" -> "d9Usdt"
|
|
16
|
-
* - "burn-manager.json" -> "burnManager"
|
|
17
|
-
* - "cross_chain_transfer.json" -> "crossChainTransfer"
|
|
18
|
-
* - "node_reward.json" -> "nodeReward"
|
|
19
|
-
*/
|
|
20
|
-
function toCamelCase(filename: string): string {
|
|
21
|
-
// Remove .json extension
|
|
22
|
-
const name = filename.replace(/\.json$/, "");
|
|
23
|
-
|
|
24
|
-
// Split by hyphens, underscores, or camelCase boundaries
|
|
25
|
-
const parts = name.split(/[-_]/);
|
|
26
|
-
|
|
27
|
-
// Convert to camelCase
|
|
28
|
-
return parts
|
|
29
|
-
.map((part, index) => {
|
|
30
|
-
if (index === 0) {
|
|
31
|
-
// Keep first part as-is (could be lowercase or have numbers)
|
|
32
|
-
return part;
|
|
33
|
-
}
|
|
34
|
-
// Capitalize first letter of subsequent parts
|
|
35
|
-
return part.charAt(0).toUpperCase() + part.slice(1).toLowerCase();
|
|
36
|
-
})
|
|
37
|
-
.join("");
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
async function main() {
|
|
41
|
-
try {
|
|
42
|
-
// Use Bun Glob to find all JSON files in assets/ABIs directory
|
|
43
|
-
const glob = new Glob("assets/ABIs/*.json");
|
|
44
|
-
const jsonFiles: string[] = [];
|
|
45
|
-
|
|
46
|
-
for await (const file of glob.scan({
|
|
47
|
-
cwd: SDK_DIR,
|
|
48
|
-
})) {
|
|
49
|
-
jsonFiles.push(file);
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
if (jsonFiles.length === 0) {
|
|
53
|
-
console.log("No JSON files found in assets/ABIs directory");
|
|
54
|
-
return;
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
console.log(`Found ${jsonFiles.length} JSON file(s) to process:\n`);
|
|
58
|
-
jsonFiles.forEach((file: string) => console.log(` - ${file}`));
|
|
59
|
-
console.log();
|
|
60
|
-
|
|
61
|
-
// Process each JSON file
|
|
62
|
-
for (const file of jsonFiles) {
|
|
63
|
-
const fileName = file.split("/").pop() || file;
|
|
64
|
-
const camelKey = toCamelCase(fileName);
|
|
65
|
-
console.log(`Processing: ${fileName} (key: ${camelKey})`);
|
|
66
|
-
|
|
67
|
-
try {
|
|
68
|
-
// Execute papi ink add command with -k parameter using Bun.$ from SDK directory
|
|
69
|
-
const result = await Bun.$`bun papi ink add ${file} -k ${camelKey} --skip-codegen`.cwd(SDK_DIR);
|
|
70
|
-
|
|
71
|
-
if (result.exitCode === 0) {
|
|
72
|
-
console.log(`✓ Successfully added: ${fileName}`);
|
|
73
|
-
const output = result.stdout.toString().trim();
|
|
74
|
-
if (output) {
|
|
75
|
-
console.log(` ${output}`);
|
|
76
|
-
}
|
|
77
|
-
console.log();
|
|
78
|
-
} else {
|
|
79
|
-
console.error(`✗ Failed to add: ${fileName}`);
|
|
80
|
-
const errorOutput = result.stderr.toString().trim();
|
|
81
|
-
if (errorOutput) {
|
|
82
|
-
console.error(` ${errorOutput}`);
|
|
83
|
-
}
|
|
84
|
-
const stdoutOutput = result.stdout.toString().trim();
|
|
85
|
-
if (stdoutOutput) {
|
|
86
|
-
console.error(` ${stdoutOutput}`);
|
|
87
|
-
}
|
|
88
|
-
console.log();
|
|
89
|
-
}
|
|
90
|
-
} catch (error) {
|
|
91
|
-
console.error(`✗ Error processing ${fileName}:`, error);
|
|
92
|
-
console.log();
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
Bun.$`bun papi`.cwd(SDK_DIR);
|
|
97
|
-
console.log("Done!");
|
|
98
|
-
} catch (error) {
|
|
99
|
-
console.error("Error processing files:", error);
|
|
100
|
-
process.exit(1);
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
main();
|