@neuraiproject/neurai-assets 1.7.1 → 1.7.2
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 +13 -0
- package/dist/index.d.cts +500 -0
- package/package.json +12 -6
package/README.md
CHANGED
|
@@ -1132,6 +1132,19 @@ remain available as `totalSats` / raw methods; never use a rounded display value
|
|
|
1132
1132
|
as a new transaction input.
|
|
1133
1133
|
|
|
1134
1134
|
|
|
1135
|
+
## 1.7.2: CommonJS type declarations
|
|
1136
|
+
|
|
1137
|
+
`require()` loads `dist/index.cjs`, but the package only published the ESM
|
|
1138
|
+
declarations (`index.d.ts`), so a CommonJS file compiled with
|
|
1139
|
+
`moduleResolution: "node16"` got `TS1471` and no types. The `require`
|
|
1140
|
+
condition now has its own declarations, `dist/index.d.cts`, written by the
|
|
1141
|
+
build from `index.d.ts` (both entry points export the same values, with
|
|
1142
|
+
`default === NeuraiAssets`). No runtime or API change. `npm run test:types`
|
|
1143
|
+
also compiles ESM, CommonJS and browser consumers against the declarations
|
|
1144
|
+
(NodeNext, Node16, Bundler; `skipLibCheck: false`), and `npm run
|
|
1145
|
+
test:package` checks the packed tarball in a clean project, with TypeScript
|
|
1146
|
+
4.7 too.
|
|
1147
|
+
|
|
1135
1148
|
## 1.7.1: type declarations
|
|
1136
1149
|
|
|
1137
1150
|
`index.d.ts` exported `AssetQueries` twice (`export class AssetQueries` plus
|
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,500 @@
|
|
|
1
|
+
/** Display units and protocol integers are distinct contracts. */
|
|
2
|
+
export type DecimalAmount = number | string;
|
|
3
|
+
export type RawAmount = bigint | number | string;
|
|
4
|
+
|
|
5
|
+
export interface AssetAmountUtilities {
|
|
6
|
+
PROTOCOL_DECIMALS: 8;
|
|
7
|
+
PROTOCOL_SCALE: bigint;
|
|
8
|
+
MAX_MONEY_RAW: bigint;
|
|
9
|
+
assetAmountToRaw(value: DecimalAmount, units?: number | null, options?: { label?: string }): bigint;
|
|
10
|
+
xnaAmountToSats(value: DecimalAmount, options?: {
|
|
11
|
+
label?: string; allowNegative?: boolean; rounding?: 'exact' | 'ceil';
|
|
12
|
+
}): bigint;
|
|
13
|
+
formatRawAsDecimal(raw: bigint): string;
|
|
14
|
+
rawToDisplayAmount(raw: RawAmount): DecimalAmount;
|
|
15
|
+
rawToDisplayNumber(raw: bigint, label?: string): number;
|
|
16
|
+
toProtocolInteger(value: RawAmount, label?: string): bigint;
|
|
17
|
+
sumProtocolIntegers(items: Array<Record<string, unknown>>, field?: string, label?: string): bigint;
|
|
18
|
+
expandScientificNotation(text: string): string;
|
|
19
|
+
normalizeDecimalText(value: DecimalAmount, label: string): string;
|
|
20
|
+
scaleDecimalText(text: string, decimals: number, label: string, rounding?: 'exact' | 'ceil'): bigint;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/** @deprecated Uses legacy 10^units scaling and may round. Use utils.AssetAmount. */
|
|
24
|
+
export interface LegacyAmountConverter {
|
|
25
|
+
new(): object;
|
|
26
|
+
toSatoshis(amount: number, units: number): number;
|
|
27
|
+
fromSatoshis(satoshis: number, units: number): number;
|
|
28
|
+
format(amount: number, units: number): string;
|
|
29
|
+
parse(formattedAmount: string): number;
|
|
30
|
+
getDecimalPlaces(amount: number): number;
|
|
31
|
+
adjustToUnits(amount: number, units: number): number;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/** Destination kind of an address or scriptPubKey. */
|
|
35
|
+
export type AddressKind = 'p2pkh' | 'authscript' | 'pq' | 'ecdsa' | 'unknown';
|
|
36
|
+
|
|
37
|
+
export interface FeeSizingVbytes {
|
|
38
|
+
readonly baseTxOverheadBytes: number;
|
|
39
|
+
readonly segwitMarkerVbytes: number;
|
|
40
|
+
readonly legacyInputVbytes: number;
|
|
41
|
+
readonly pqInputVbytes: number;
|
|
42
|
+
readonly ecdsaWitnessInputVbytes: number;
|
|
43
|
+
readonly legacyOutputBytes: number;
|
|
44
|
+
readonly witnessOutputBytes: number;
|
|
45
|
+
/** @deprecated Same as witnessOutputBytes. */
|
|
46
|
+
readonly pqOutputBytes: number;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export interface FeeSizingInput {
|
|
50
|
+
script?: string;
|
|
51
|
+
address?: string;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
export type FeeSizingOutput = string | {
|
|
55
|
+
address?: string;
|
|
56
|
+
assetName?: string;
|
|
57
|
+
kind?: 'transfer' | 'owner' | 'issue' | 'reissue' | 'tag' | 'restriction' | 'globalRestriction' | 'verifier';
|
|
58
|
+
hasIpfs?: boolean;
|
|
59
|
+
ipfsHash?: string;
|
|
60
|
+
verifierString?: string;
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
export interface FeeSizingUtilities {
|
|
64
|
+
VBYTES: FeeSizingVbytes;
|
|
65
|
+
getAddressKind(address: string): AddressKind;
|
|
66
|
+
getScriptKind(scriptHex: string): AddressKind;
|
|
67
|
+
/** True for PQ v2 and generic AuthScript v1 addresses. */
|
|
68
|
+
isPQAddress(address: string): boolean;
|
|
69
|
+
/** True for OP_1 / OP_2 scriptPubKeys with a 32-byte program. */
|
|
70
|
+
isPQScript(scriptHex: string): boolean;
|
|
71
|
+
estimateInputVbytes(utxo: FeeSizingInput): number;
|
|
72
|
+
estimateOutputBytes(target: FeeSizingOutput): number;
|
|
73
|
+
estimateTransactionVbytes(inputs: FeeSizingInput[], outputs: FeeSizingOutput[]): number;
|
|
74
|
+
assetPayloadBytes(descriptor: FeeSizingOutput): number;
|
|
75
|
+
compactSizeBytes(n: number): number;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
export interface AssetUtilities extends Record<string, unknown> {
|
|
79
|
+
AssetAmount: AssetAmountUtilities;
|
|
80
|
+
/** @deprecated Uses legacy scaling and may round. Use AssetAmount. */
|
|
81
|
+
AmountConverter: LegacyAmountConverter;
|
|
82
|
+
FeeSizing: FeeSizingUtilities;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
export interface InsufficientFundsErrorInstance extends Error {
|
|
86
|
+
code: 'INSUFFICIENT_FUNDS';
|
|
87
|
+
required: DecimalAmount;
|
|
88
|
+
available: DecimalAmount;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
export interface AssetErrors extends Record<string, unknown> {
|
|
92
|
+
InsufficientFundsError: new(message: string, required: DecimalAmount, available: DecimalAmount) => InsufficientFundsErrorInstance;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* NIP-040 asset payload marker. The chain decides which one new asset
|
|
97
|
+
* outputs must carry; the node reports it as
|
|
98
|
+
* `getblockchaininfo.asset_marker`. Omit to let the builders ask the node
|
|
99
|
+
* (falls back to 'rvn' on nodes that do not report the field).
|
|
100
|
+
*/
|
|
101
|
+
export type AssetMarker = 'rvn' | 'xna';
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* What to do when `getblockchaininfo` FAILS while resolving the marker.
|
|
105
|
+
*
|
|
106
|
+
* - `legacy-fallback` (default in 1.x): resolve `'rvn'`, as 1.4.x did.
|
|
107
|
+
* - `strict`: propagate the error. On a post-NIP-040 chain a guessed `'rvn'`
|
|
108
|
+
* builds a transaction the node rejects, so "the node did not answer" must
|
|
109
|
+
* not become "the node said rvn".
|
|
110
|
+
*
|
|
111
|
+
* A node that simply predates the field resolves `'rvn'` under both policies:
|
|
112
|
+
* that is an answer, not a failure.
|
|
113
|
+
*/
|
|
114
|
+
export type AssetMarkerPolicy = 'strict' | 'legacy-fallback';
|
|
115
|
+
|
|
116
|
+
export interface NeuraiAssetsConfig {
|
|
117
|
+
network?: string;
|
|
118
|
+
addresses?: string[];
|
|
119
|
+
changeAddress?: string | null;
|
|
120
|
+
toAddress?: string | null;
|
|
121
|
+
assetMarker?: AssetMarker;
|
|
122
|
+
assetMarkerPolicy?: AssetMarkerPolicy;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
/**
|
|
126
|
+
* @deprecated Since 1.5.0. Use {@link NeuraiAssetsBuildResult.createTransactionBuild},
|
|
127
|
+
* which is the exact shape `createFromOperation` accepts. Removed in 2.0.0.
|
|
128
|
+
*/
|
|
129
|
+
export type LegacyOperationType =
|
|
130
|
+
| 'ISSUE_ROOT'
|
|
131
|
+
| 'ISSUE_SUB'
|
|
132
|
+
| 'ISSUE_DEPIN'
|
|
133
|
+
| 'ISSUE_UNIQUE'
|
|
134
|
+
| 'ISSUE_QUALIFIER'
|
|
135
|
+
| 'ISSUE_SUB_QUALIFIER'
|
|
136
|
+
| 'ISSUE_RESTRICTED'
|
|
137
|
+
| 'REISSUE'
|
|
138
|
+
| 'REISSUE_RESTRICTED'
|
|
139
|
+
| 'TAG_ADDRESSES'
|
|
140
|
+
| 'UNTAG_ADDRESSES'
|
|
141
|
+
| 'FREEZE_ADDRESSES'
|
|
142
|
+
| 'UNFREEZE_ADDRESSES'
|
|
143
|
+
| 'FREEZE_ASSET'
|
|
144
|
+
| 'UNFREEZE_ASSET';
|
|
145
|
+
|
|
146
|
+
/** @deprecated Alias kept for 1.x consumers. Use {@link LegacyOperationType}. */
|
|
147
|
+
export type OperationType = LegacyOperationType;
|
|
148
|
+
|
|
149
|
+
/**
|
|
150
|
+
* How `rawTx` was produced. `'rpc-node'`: the node's `createrawtransaction`.
|
|
151
|
+
* `'local-builder'`: built locally with `createFromOperation` — used by the
|
|
152
|
+
* reissue operations since 1.5.0, because the RPC's reissue objects cannot
|
|
153
|
+
* express "keep the current units" and reject any asset with units > 0.
|
|
154
|
+
*/
|
|
155
|
+
export type BuildStrategy = 'rpc-node' | 'local-builder';
|
|
156
|
+
|
|
157
|
+
export interface BuildInput {
|
|
158
|
+
txid: string;
|
|
159
|
+
vout: number;
|
|
160
|
+
address: string;
|
|
161
|
+
satoshis: RawAmount;
|
|
162
|
+
assetName?: string;
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
/**
|
|
166
|
+
* @deprecated Since 1.5.0. Its `*Raw` fields carry DISPLAY amounts, its
|
|
167
|
+
* `TRANSFER` discriminant is not one `createFromOperation` accepts, and its
|
|
168
|
+
* `params` is an open record with no narrowing. Kept unchanged through 1.x for
|
|
169
|
+
* existing consumers; removed in 2.0.0. Use `createTransactionBuild`.
|
|
170
|
+
*/
|
|
171
|
+
export interface LocalRawBuild {
|
|
172
|
+
operationType: LegacyOperationType | 'TRANSFER';
|
|
173
|
+
/** Includes `assetMarker` (NIP-040) for createFromOperation >= 0.7.0. */
|
|
174
|
+
params: Record<string, unknown> & { assetMarker?: AssetMarker };
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
/** The canonical network labels the serializer understands. */
|
|
178
|
+
export type CanonicalNetwork = 'xna' | 'xna-test';
|
|
179
|
+
|
|
180
|
+
/** Outpoint reference, exactly as create-transaction consumes it. */
|
|
181
|
+
export interface CanonicalInput {
|
|
182
|
+
txid: string;
|
|
183
|
+
vout: number;
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
/** An XNA payment output. */
|
|
187
|
+
export interface CanonicalPayment {
|
|
188
|
+
address: string;
|
|
189
|
+
valueSats: bigint;
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
/** One asset transfer output. `amountRaw` is 10^8-scaled, never a display value. */
|
|
193
|
+
export interface CanonicalTransfer {
|
|
194
|
+
address: string;
|
|
195
|
+
assetName: string;
|
|
196
|
+
amountRaw: bigint;
|
|
197
|
+
assetMarker?: AssetMarker;
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
/** Fields every canonical build carries. */
|
|
201
|
+
export interface CanonicalParamsBase {
|
|
202
|
+
inputs: CanonicalInput[];
|
|
203
|
+
assetMarker: AssetMarker;
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
/** The XNA envelope shared by the operations that burn and/or return change. */
|
|
207
|
+
export interface CanonicalXnaEnvelope {
|
|
208
|
+
burnAddress?: string;
|
|
209
|
+
burnAmountSats?: bigint;
|
|
210
|
+
xnaChangeAddress?: string;
|
|
211
|
+
xnaChangeSats?: bigint;
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
export interface CanonicalIssueParams extends CanonicalParamsBase, CanonicalXnaEnvelope {
|
|
215
|
+
toAddress: string;
|
|
216
|
+
assetName: string;
|
|
217
|
+
quantityRaw: bigint;
|
|
218
|
+
units?: number;
|
|
219
|
+
reissuable?: boolean;
|
|
220
|
+
ipfsHash?: string;
|
|
221
|
+
ownerTokenAddress?: string;
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
export interface CanonicalIssueSubParams extends CanonicalParamsBase, CanonicalXnaEnvelope {
|
|
225
|
+
toAddress: string;
|
|
226
|
+
assetName: string;
|
|
227
|
+
quantityRaw: bigint;
|
|
228
|
+
units?: number;
|
|
229
|
+
reissuable?: boolean;
|
|
230
|
+
ipfsHash?: string;
|
|
231
|
+
parentOwnerAddress?: string;
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
export interface CanonicalIssueDepinParams extends CanonicalParamsBase, CanonicalXnaEnvelope {
|
|
235
|
+
toAddress: string;
|
|
236
|
+
assetName: string;
|
|
237
|
+
quantityRaw: bigint;
|
|
238
|
+
ipfsHash?: string;
|
|
239
|
+
ownerTokenAddress?: string;
|
|
240
|
+
reissuable?: boolean;
|
|
241
|
+
/** Canonical label, so the serializer's mainnet DePIN guard actually runs. */
|
|
242
|
+
network: CanonicalNetwork;
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
export interface CanonicalIssueUniqueParams extends CanonicalParamsBase, CanonicalXnaEnvelope {
|
|
246
|
+
toAddress: string;
|
|
247
|
+
rootName: string;
|
|
248
|
+
assetTags: string[];
|
|
249
|
+
ipfsHashes?: Array<string | undefined>;
|
|
250
|
+
ownerTokenAddress?: string;
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
export interface CanonicalIssueQualifierParams extends CanonicalParamsBase, CanonicalXnaEnvelope {
|
|
254
|
+
toAddress: string;
|
|
255
|
+
assetName: string;
|
|
256
|
+
quantityRaw: bigint;
|
|
257
|
+
ipfsHash?: string;
|
|
258
|
+
rootChangeAddress?: string;
|
|
259
|
+
changeQuantityRaw?: bigint;
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
export interface CanonicalIssueRestrictedParams extends CanonicalParamsBase, CanonicalXnaEnvelope {
|
|
263
|
+
toAddress: string;
|
|
264
|
+
assetName: string;
|
|
265
|
+
quantityRaw: bigint;
|
|
266
|
+
verifierString: string;
|
|
267
|
+
units?: number;
|
|
268
|
+
reissuable?: boolean;
|
|
269
|
+
ipfsHash?: string;
|
|
270
|
+
ownerChangeAddress?: string;
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
export interface CanonicalReissueParams extends CanonicalParamsBase, CanonicalXnaEnvelope {
|
|
274
|
+
toAddress: string;
|
|
275
|
+
assetName: string;
|
|
276
|
+
quantityRaw: bigint;
|
|
277
|
+
/**
|
|
278
|
+
* Always omitted by this library: it has no API to change an asset's units,
|
|
279
|
+
* so its builds mean "keep the current ones", which the serializer encodes
|
|
280
|
+
* as `0xff`. Present in the type because create-transaction accepts it.
|
|
281
|
+
*/
|
|
282
|
+
units?: number;
|
|
283
|
+
reissuable?: boolean;
|
|
284
|
+
ipfsHash?: string;
|
|
285
|
+
ownerChangeAddress?: string;
|
|
286
|
+
verifierString?: string;
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
export interface CanonicalTagParams extends CanonicalParamsBase {
|
|
290
|
+
qualifierName: string;
|
|
291
|
+
targetAddresses: string[];
|
|
292
|
+
burnAddress: string;
|
|
293
|
+
burnAmountSats: bigint;
|
|
294
|
+
xnaChangeAddress: string;
|
|
295
|
+
xnaChangeSats: bigint;
|
|
296
|
+
qualifierChangeAddress: string;
|
|
297
|
+
qualifierChangeAmountRaw: bigint;
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
export interface CanonicalFreezeAddressesParams extends CanonicalParamsBase {
|
|
301
|
+
assetName: string;
|
|
302
|
+
targetAddresses: string[];
|
|
303
|
+
ownerChangeAddress: string;
|
|
304
|
+
xnaChangeAddress?: string;
|
|
305
|
+
xnaChangeSats?: bigint;
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
export interface CanonicalFreezeAssetParams extends CanonicalParamsBase {
|
|
309
|
+
assetName: string;
|
|
310
|
+
ownerChangeAddress: string;
|
|
311
|
+
xnaChangeAddress?: string;
|
|
312
|
+
xnaChangeSats?: bigint;
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
export interface CanonicalStandardTransferParams extends CanonicalParamsBase {
|
|
316
|
+
payments: CanonicalPayment[];
|
|
317
|
+
transfers: CanonicalTransfer[];
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
export interface CanonicalDepinTransferParams extends CanonicalParamsBase {
|
|
321
|
+
transfers: CanonicalTransfer[];
|
|
322
|
+
/** Destination of the escorting `&X!` output, which the serializer emits itself. */
|
|
323
|
+
ownerChangeAddress: string;
|
|
324
|
+
xnaChangeAddress?: string;
|
|
325
|
+
xnaChangeSats?: bigint;
|
|
326
|
+
network: CanonicalNetwork;
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
/**
|
|
330
|
+
* The exact value `createFromOperation` accepts, with no adaptation:
|
|
331
|
+
*
|
|
332
|
+
* ```ts
|
|
333
|
+
* const result = await assets.transferAsset({ ... });
|
|
334
|
+
* const built = createFromOperation(result.createTransactionBuild);
|
|
335
|
+
* ```
|
|
336
|
+
*
|
|
337
|
+
* Discriminated on `operationType`, closed (no index signature), and every
|
|
338
|
+
* amount is a protocol integer.
|
|
339
|
+
*/
|
|
340
|
+
export type CreateTransactionBuild =
|
|
341
|
+
| { operationType: 'ISSUE_ROOT'; params: CanonicalIssueParams }
|
|
342
|
+
| { operationType: 'ISSUE_SUB'; params: CanonicalIssueSubParams }
|
|
343
|
+
| { operationType: 'ISSUE_DEPIN'; params: CanonicalIssueDepinParams }
|
|
344
|
+
| { operationType: 'ISSUE_UNIQUE'; params: CanonicalIssueUniqueParams }
|
|
345
|
+
| { operationType: 'ISSUE_QUALIFIER' | 'ISSUE_SUB_QUALIFIER'; params: CanonicalIssueQualifierParams }
|
|
346
|
+
| { operationType: 'ISSUE_RESTRICTED'; params: CanonicalIssueRestrictedParams }
|
|
347
|
+
| { operationType: 'REISSUE' | 'REISSUE_RESTRICTED'; params: CanonicalReissueParams }
|
|
348
|
+
| { operationType: 'TAG_ADDRESSES' | 'UNTAG_ADDRESSES'; params: CanonicalTagParams }
|
|
349
|
+
| { operationType: 'FREEZE_ADDRESSES' | 'UNFREEZE_ADDRESSES'; params: CanonicalFreezeAddressesParams }
|
|
350
|
+
| { operationType: 'FREEZE_ASSET' | 'UNFREEZE_ASSET'; params: CanonicalFreezeAssetParams }
|
|
351
|
+
| { operationType: 'STANDARD_TRANSFER'; params: CanonicalStandardTransferParams }
|
|
352
|
+
| { operationType: 'TRANSFER_DEPIN'; params: CanonicalDepinTransferParams };
|
|
353
|
+
|
|
354
|
+
/** The discriminants this library exposes canonically. */
|
|
355
|
+
export type CreateTransactionOperationType = CreateTransactionBuild['operationType'];
|
|
356
|
+
|
|
357
|
+
export interface NeuraiAssetsBuildResult {
|
|
358
|
+
rawTx: string;
|
|
359
|
+
fee: number | string;
|
|
360
|
+
burnAmount: number;
|
|
361
|
+
network: string;
|
|
362
|
+
buildStrategy: BuildStrategy;
|
|
363
|
+
burnAddress: string | null;
|
|
364
|
+
changeAddress: string | null;
|
|
365
|
+
changeAmount: DecimalAmount | null;
|
|
366
|
+
operationType?: LegacyOperationType | 'TRANSFER';
|
|
367
|
+
/**
|
|
368
|
+
* Ready for `createFromOperation(...)` as-is. Always present on a successful
|
|
369
|
+
* build; narrow it with `operationType`.
|
|
370
|
+
*/
|
|
371
|
+
createTransactionBuild: CreateTransactionBuild;
|
|
372
|
+
/** @deprecated Since 1.5.0; removed in 2.0.0. See {@link LocalRawBuild}. */
|
|
373
|
+
localRawBuild?: LocalRawBuild;
|
|
374
|
+
inputs: BuildInput[];
|
|
375
|
+
/**
|
|
376
|
+
* The `createrawtransaction` output envelope, in display amounts.
|
|
377
|
+
*
|
|
378
|
+
* Do NOT index these against `rawTx`'s vouts. They match on the `'rpc-node'`
|
|
379
|
+
* path, but not on `'local-builder'` (the reissue operations since 1.5.0):
|
|
380
|
+
* the node auto-generates the owner-token return while processing a reissue
|
|
381
|
+
* entry, so this envelope omits it, whereas the locally built `rawTx`
|
|
382
|
+
* carries it explicitly — three entries here against four vouts there.
|
|
383
|
+
* Both are valid; they are simply two descriptions of the same operation.
|
|
384
|
+
* Parse `rawTx` when you need the outputs the chain will see.
|
|
385
|
+
*/
|
|
386
|
+
outputs: Array<Record<string, unknown>>;
|
|
387
|
+
utxos?: unknown[];
|
|
388
|
+
assetData?: Record<string, unknown>;
|
|
389
|
+
[key: string]: unknown;
|
|
390
|
+
}
|
|
391
|
+
|
|
392
|
+
export interface DepinHolderEntry {
|
|
393
|
+
address: string;
|
|
394
|
+
amount?: number;
|
|
395
|
+
valid?: boolean;
|
|
396
|
+
[key: string]: unknown;
|
|
397
|
+
}
|
|
398
|
+
|
|
399
|
+
export interface DepinValidityResult {
|
|
400
|
+
assetName?: string;
|
|
401
|
+
address: string;
|
|
402
|
+
valid: boolean;
|
|
403
|
+
[key: string]: unknown;
|
|
404
|
+
}
|
|
405
|
+
|
|
406
|
+
declare class AssetQueries {
|
|
407
|
+
constructor(rpc: (method: string, params?: unknown[]) => Promise<unknown> | unknown);
|
|
408
|
+
getAssetData(assetName: string): Promise<Record<string, unknown>>;
|
|
409
|
+
listAssets(filter?: string, verbose?: boolean, count?: number, start?: number): Promise<unknown>;
|
|
410
|
+
listMyAssets(assetName?: string, verbose?: boolean, count?: number, start?: number, confs?: number): Promise<Record<string, unknown>>;
|
|
411
|
+
listAddressesByAsset(assetName: string, onlyCount?: boolean, count?: number, start?: number): Promise<unknown>;
|
|
412
|
+
listAssetBalancesByAddress(address: string, onlyTotal?: boolean, count?: number, start?: number): Promise<unknown>;
|
|
413
|
+
checkAddressTag(address: string, qualifierName: string): Promise<boolean>;
|
|
414
|
+
listTagsForAddress(address: string): Promise<string[]>;
|
|
415
|
+
listAddressesForTag(qualifierName: string): Promise<string[]>;
|
|
416
|
+
checkAddressRestriction(address: string, restrictedAssetName: string): Promise<boolean>;
|
|
417
|
+
isAddressFrozen(address: string, restrictedAssetName: string): Promise<boolean>;
|
|
418
|
+
checkGlobalRestriction(restrictedAssetName: string): Promise<boolean>;
|
|
419
|
+
getVerifierString(restrictedAssetName: string): Promise<string>;
|
|
420
|
+
isValidVerifierString(verifierString: string): Promise<boolean>;
|
|
421
|
+
getSnapshotRequest(assetName: string, blockHeight: number): Promise<Record<string, unknown>>;
|
|
422
|
+
cancelSnapshotRequest(assetName: string, blockHeight: number): Promise<boolean>;
|
|
423
|
+
listDepinHolders(assetName: string): Promise<DepinHolderEntry[]>;
|
|
424
|
+
checkDepinValidity(assetName: string, address: string): Promise<DepinValidityResult>;
|
|
425
|
+
assetExists(assetName: string): Promise<boolean>;
|
|
426
|
+
getAssetType(assetName: string): string;
|
|
427
|
+
getAssetCount(): Promise<number>;
|
|
428
|
+
}
|
|
429
|
+
|
|
430
|
+
declare class NeuraiAssets {
|
|
431
|
+
constructor(rpc: (method: string, params?: unknown[]) => Promise<unknown> | unknown, config?: NeuraiAssetsConfig);
|
|
432
|
+
|
|
433
|
+
rpc: (method: string, params?: unknown[]) => Promise<unknown> | unknown;
|
|
434
|
+
config: Required<NeuraiAssetsConfig>;
|
|
435
|
+
queries: AssetQueries;
|
|
436
|
+
|
|
437
|
+
updateConfig(config: Partial<NeuraiAssetsConfig>): void;
|
|
438
|
+
|
|
439
|
+
createRootAsset(params: Record<string, unknown>): Promise<NeuraiAssetsBuildResult>;
|
|
440
|
+
createSubAsset(params: Record<string, unknown>): Promise<NeuraiAssetsBuildResult>;
|
|
441
|
+
createDepinAsset(params: Record<string, unknown>): Promise<NeuraiAssetsBuildResult>;
|
|
442
|
+
reissueAsset(params: Record<string, unknown>): Promise<NeuraiAssetsBuildResult>;
|
|
443
|
+
transferAsset(params: Record<string, unknown>): Promise<NeuraiAssetsBuildResult>;
|
|
444
|
+
createUniqueAssets(params: Record<string, unknown>): Promise<NeuraiAssetsBuildResult>;
|
|
445
|
+
createQualifier(params: Record<string, unknown>): Promise<NeuraiAssetsBuildResult>;
|
|
446
|
+
tagAddresses(params: Record<string, unknown>): Promise<NeuraiAssetsBuildResult>;
|
|
447
|
+
untagAddresses(params: Record<string, unknown>): Promise<NeuraiAssetsBuildResult>;
|
|
448
|
+
createRestrictedAsset(params: Record<string, unknown>): Promise<NeuraiAssetsBuildResult>;
|
|
449
|
+
reissueRestrictedAsset(params: Record<string, unknown>): Promise<NeuraiAssetsBuildResult>;
|
|
450
|
+
freezeAddresses(params: Record<string, unknown>): Promise<NeuraiAssetsBuildResult>;
|
|
451
|
+
unfreezeAddresses(params: Record<string, unknown>): Promise<NeuraiAssetsBuildResult>;
|
|
452
|
+
freezeAssetGlobally(params: Record<string, unknown>): Promise<NeuraiAssetsBuildResult>;
|
|
453
|
+
unfreezeAssetGlobally(params: Record<string, unknown>): Promise<NeuraiAssetsBuildResult>;
|
|
454
|
+
|
|
455
|
+
getAssetData(assetName: string): Promise<Record<string, unknown>>;
|
|
456
|
+
listAssets(filter?: string, verbose?: boolean, count?: number, start?: number): Promise<unknown>;
|
|
457
|
+
listMyAssets(assetName?: string, verbose?: boolean, count?: number, start?: number, confs?: number): Promise<Record<string, unknown>>;
|
|
458
|
+
listAddressesByAsset(assetName: string, onlyCount?: boolean, count?: number, start?: number): Promise<unknown>;
|
|
459
|
+
listAssetBalancesByAddress(address: string, onlyTotal?: boolean, count?: number, start?: number): Promise<unknown>;
|
|
460
|
+
checkAddressTag(address: string, qualifierName: string): Promise<boolean>;
|
|
461
|
+
listTagsForAddress(address: string): Promise<string[]>;
|
|
462
|
+
listAddressesForTag(qualifierName: string): Promise<string[]>;
|
|
463
|
+
checkAddressRestriction(address: string, restrictedAssetName: string): Promise<boolean>;
|
|
464
|
+
isAddressFrozen(address: string, restrictedAssetName: string): Promise<boolean>;
|
|
465
|
+
checkGlobalRestriction(restrictedAssetName: string): Promise<boolean>;
|
|
466
|
+
getVerifierString(restrictedAssetName: string): Promise<string>;
|
|
467
|
+
isValidVerifierString(verifierString: string): Promise<boolean>;
|
|
468
|
+
getSnapshotRequest(assetName: string, blockHeight: number): Promise<Record<string, unknown>>;
|
|
469
|
+
cancelSnapshotRequest(assetName: string, blockHeight: number): Promise<boolean>;
|
|
470
|
+
listDepinHolders(assetName: string): Promise<DepinHolderEntry[]>;
|
|
471
|
+
checkDepinValidity(assetName: string, address: string): Promise<DepinValidityResult>;
|
|
472
|
+
assetExists(assetName: string): Promise<boolean>;
|
|
473
|
+
getAssetType(assetName: string): string;
|
|
474
|
+
getAssetCount(): Promise<number>;
|
|
475
|
+
|
|
476
|
+
static NeuraiAssets: typeof NeuraiAssets;
|
|
477
|
+
static AssetQueries: typeof AssetQueries;
|
|
478
|
+
static builders: Record<string, unknown>;
|
|
479
|
+
static constants: Record<string, unknown>;
|
|
480
|
+
static errors: AssetErrors;
|
|
481
|
+
static validators: Record<string, unknown>;
|
|
482
|
+
static utils: AssetUtilities;
|
|
483
|
+
}
|
|
484
|
+
|
|
485
|
+
declare const builders: Record<string, unknown>;
|
|
486
|
+
declare const constants: Record<string, unknown>;
|
|
487
|
+
declare const errors: AssetErrors;
|
|
488
|
+
declare const validators: Record<string, unknown>;
|
|
489
|
+
declare const utils: AssetUtilities;
|
|
490
|
+
|
|
491
|
+
export default NeuraiAssets;
|
|
492
|
+
export {
|
|
493
|
+
AssetQueries,
|
|
494
|
+
NeuraiAssets,
|
|
495
|
+
builders,
|
|
496
|
+
constants,
|
|
497
|
+
errors,
|
|
498
|
+
utils,
|
|
499
|
+
validators
|
|
500
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@neuraiproject/neurai-assets",
|
|
3
|
-
"version": "1.7.
|
|
3
|
+
"version": "1.7.2",
|
|
4
4
|
"description": "Non-custodial Neurai asset management library for JavaScript",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.cjs",
|
|
@@ -9,9 +9,14 @@
|
|
|
9
9
|
"types": "./index.d.ts",
|
|
10
10
|
"exports": {
|
|
11
11
|
".": {
|
|
12
|
-
"
|
|
13
|
-
|
|
14
|
-
|
|
12
|
+
"import": {
|
|
13
|
+
"types": "./index.d.ts",
|
|
14
|
+
"default": "./dist/index.js"
|
|
15
|
+
},
|
|
16
|
+
"require": {
|
|
17
|
+
"types": "./dist/index.d.cts",
|
|
18
|
+
"default": "./dist/index.cjs"
|
|
19
|
+
}
|
|
15
20
|
},
|
|
16
21
|
"./browser": {
|
|
17
22
|
"types": "./index.d.ts",
|
|
@@ -25,13 +30,14 @@
|
|
|
25
30
|
"README.md"
|
|
26
31
|
],
|
|
27
32
|
"scripts": {
|
|
28
|
-
"build": "rollup -c rollup.config.mjs",
|
|
33
|
+
"build": "rollup -c rollup.config.mjs && node scripts/write-cjs-declarations.mjs",
|
|
29
34
|
"test": "npm run build && mocha ./tests/unit/**/*.test.js ./tests/integration/**/*.test.js ./tests/browser/**/*.test.js && npm run test:types",
|
|
30
35
|
"test:unit": "mocha ./tests/unit/**/*.test.js",
|
|
31
36
|
"test:integration": "mocha ./tests/integration/**/*.test.js",
|
|
32
37
|
"test:browser": "npm run build && mocha ./tests/browser/**/*.test.js",
|
|
33
38
|
"test:watch": "mocha --watch ./tests/**/*.test.js",
|
|
34
|
-
"test:types": "tsc -p tsconfig.types.json && tsc -p tsconfig.dts.json"
|
|
39
|
+
"test:types": "tsc -p tsconfig.types.json && tsc -p tsconfig.dts.json && tsc -p tsconfig.types-nodenext.json && tsc -p tsconfig.types-node16.json && tsc -p tsconfig.types-bundler.json",
|
|
40
|
+
"test:package": "npm run build && node scripts/check-package.mjs"
|
|
35
41
|
},
|
|
36
42
|
"repository": {
|
|
37
43
|
"type": "git",
|