@palliora.org/chainsdk 0.1.0 → 0.3.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/dist/index.cjs +754 -238
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +658 -193
- package/dist/index.d.ts +658 -193
- package/dist/index.js +725 -209
- package/dist/index.js.map +1 -1
- package/package.json +12 -8
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,12 @@
|
|
|
1
1
|
import * as _polkadot_util_crypto_types from '@polkadot/util-crypto/types';
|
|
2
|
+
import { KeyringPair } from '@polkadot/keyring/types';
|
|
3
|
+
import * as _polkadot_types_types from '@polkadot/types/types';
|
|
4
|
+
import { ISubmittableResult } from '@polkadot/types/types';
|
|
2
5
|
import { ApiPromise, Keyring, WsProvider } from '@polkadot/api';
|
|
3
6
|
export { ApiPromise, HttpProvider, WsProvider } from '@polkadot/api';
|
|
7
|
+
import * as _polkadot_types_interfaces from '@polkadot/types/interfaces';
|
|
8
|
+
import { SignedBlock, EventRecord } from '@polkadot/types/interfaces';
|
|
9
|
+
import { SubmittableExtrinsic } from '@polkadot/api/types';
|
|
4
10
|
import * as _noble_curves_abstract_weierstrass from '@noble/curves/abstract/weierstrass';
|
|
5
11
|
import { ProjPointType } from '@noble/curves/abstract/weierstrass';
|
|
6
12
|
import { Fp, Fp2, Fp12 } from '@noble/curves/abstract/tower';
|
|
@@ -30,7 +36,7 @@ declare enum AccountSourceType {
|
|
|
30
36
|
* @param cryptoType - The crypto type: 'sr25519' | 'ed25519' | 'ecdsa' (default: 'sr25519').
|
|
31
37
|
* @returns The keypair object.
|
|
32
38
|
*/
|
|
33
|
-
declare function createAccount(input:
|
|
39
|
+
declare function createAccount(input: string, type: AccountSourceType, name?: string, cryptoType?: CryptoType): Promise<KeyringPair>;
|
|
34
40
|
declare function pairFromPrivateKeyHex(privateKeyHex: string, cryptoType: CryptoType): _polkadot_util_crypto_types.Keypair;
|
|
35
41
|
|
|
36
42
|
declare const API_RPC: {
|
|
@@ -158,12 +164,182 @@ declare const API_TYPES: {
|
|
|
158
164
|
extra: string;
|
|
159
165
|
types: string;
|
|
160
166
|
};
|
|
167
|
+
FeePayload: {
|
|
168
|
+
compute: string;
|
|
169
|
+
guardian: string;
|
|
170
|
+
verifier: string;
|
|
171
|
+
};
|
|
172
|
+
SilentThresholdParams: {
|
|
173
|
+
td_params: string;
|
|
174
|
+
pk_bytes: string;
|
|
175
|
+
tau_params: string;
|
|
176
|
+
};
|
|
177
|
+
ThresholdParams: {
|
|
178
|
+
_enum: {
|
|
179
|
+
SilentThreshold: string;
|
|
180
|
+
};
|
|
181
|
+
};
|
|
182
|
+
ChaCha20Poly1305Params: {
|
|
183
|
+
nonce: string;
|
|
184
|
+
};
|
|
185
|
+
Aes256GcmParams: {
|
|
186
|
+
nonce: string;
|
|
187
|
+
};
|
|
188
|
+
SymmetricParams: {
|
|
189
|
+
_enum: {
|
|
190
|
+
ChaCha20Poly1305: string;
|
|
191
|
+
Aes256Gcm: string;
|
|
192
|
+
};
|
|
193
|
+
};
|
|
194
|
+
KdfParams: {
|
|
195
|
+
_enum: {
|
|
196
|
+
HkdfSha256: string;
|
|
197
|
+
HkdfSha512: string;
|
|
198
|
+
};
|
|
199
|
+
};
|
|
200
|
+
Secp256k1Params: {
|
|
201
|
+
recipient_public_key: string;
|
|
202
|
+
ephemeral_public_key: string;
|
|
203
|
+
compressed: string;
|
|
204
|
+
kdf: string;
|
|
205
|
+
salt: string;
|
|
206
|
+
info: string;
|
|
207
|
+
};
|
|
208
|
+
Ed25519Params: {
|
|
209
|
+
recipient_public_key: string;
|
|
210
|
+
ephemeral_public_key: string;
|
|
211
|
+
kdf: string;
|
|
212
|
+
salt: string;
|
|
213
|
+
info: string;
|
|
214
|
+
};
|
|
215
|
+
AsymmetricParams: {
|
|
216
|
+
_enum: {
|
|
217
|
+
Secp256k1: string;
|
|
218
|
+
Ed25519: string;
|
|
219
|
+
};
|
|
220
|
+
};
|
|
221
|
+
ThresholdHybridParams: {
|
|
222
|
+
threshold_params: string;
|
|
223
|
+
symmetric_params: string;
|
|
224
|
+
};
|
|
225
|
+
AsymmetricHybridParams: {
|
|
226
|
+
asymmetric_params: string;
|
|
227
|
+
symmetric_params: string;
|
|
228
|
+
};
|
|
229
|
+
CipherSuite: {
|
|
230
|
+
_enum: {
|
|
231
|
+
Plaintext: string;
|
|
232
|
+
ThresholdHybrid: string;
|
|
233
|
+
AsymmetricHybrid: string;
|
|
234
|
+
};
|
|
235
|
+
};
|
|
236
|
+
ConfidentialityLevel: {
|
|
237
|
+
_enum: {
|
|
238
|
+
Trusted: string;
|
|
239
|
+
TEE: string;
|
|
240
|
+
FHE: string;
|
|
241
|
+
SMPC: string;
|
|
242
|
+
};
|
|
243
|
+
};
|
|
244
|
+
NativeExecuteDA: {
|
|
245
|
+
_enum: string[];
|
|
246
|
+
};
|
|
247
|
+
NativeDataDA: {
|
|
248
|
+
_enum: string[];
|
|
249
|
+
};
|
|
250
|
+
DAInputInline: {
|
|
251
|
+
data: string;
|
|
252
|
+
};
|
|
253
|
+
DAInputChainTransaction: {
|
|
254
|
+
block_number: string;
|
|
255
|
+
extrinsic_index: string;
|
|
256
|
+
};
|
|
257
|
+
DAInputIpfs: {
|
|
258
|
+
cid: string;
|
|
259
|
+
size: string;
|
|
260
|
+
};
|
|
261
|
+
DAInputUrl: {
|
|
262
|
+
url: string;
|
|
263
|
+
size: string;
|
|
264
|
+
hash: string;
|
|
265
|
+
};
|
|
266
|
+
DAInput: {
|
|
267
|
+
_enum: {
|
|
268
|
+
Null: string;
|
|
269
|
+
Inline: string;
|
|
270
|
+
ChainTransaction: string;
|
|
271
|
+
Ipfs: string;
|
|
272
|
+
Url: string;
|
|
273
|
+
NativeExecute: string;
|
|
274
|
+
NativeData: string;
|
|
275
|
+
};
|
|
276
|
+
};
|
|
277
|
+
ContractType: {
|
|
278
|
+
_enum: {
|
|
279
|
+
Dormant: string;
|
|
280
|
+
Active: string;
|
|
281
|
+
};
|
|
282
|
+
};
|
|
283
|
+
StoreType: {
|
|
284
|
+
_enum: {
|
|
285
|
+
Dataset: string;
|
|
286
|
+
Model: string;
|
|
287
|
+
Agent: string;
|
|
288
|
+
Other: string;
|
|
289
|
+
};
|
|
290
|
+
};
|
|
291
|
+
ComputeMetadata: {
|
|
292
|
+
name: string;
|
|
293
|
+
description: string;
|
|
294
|
+
store_type: string;
|
|
295
|
+
group_id: string;
|
|
296
|
+
};
|
|
297
|
+
ComputeInfo: {
|
|
298
|
+
cipher: string;
|
|
299
|
+
computer_indices: string;
|
|
300
|
+
fees: string;
|
|
301
|
+
deadline: string;
|
|
302
|
+
confidentiality: string;
|
|
303
|
+
fee_function: string;
|
|
304
|
+
program_env: string;
|
|
305
|
+
input: string;
|
|
306
|
+
program: string;
|
|
307
|
+
metadata: string;
|
|
308
|
+
};
|
|
309
|
+
Contract: {
|
|
310
|
+
contract_type: string;
|
|
311
|
+
guardians: string;
|
|
312
|
+
pre_check: string;
|
|
313
|
+
compute: string;
|
|
314
|
+
post_check: string;
|
|
315
|
+
result_cipher: string;
|
|
316
|
+
};
|
|
317
|
+
AgreementInfo: {
|
|
318
|
+
status: string;
|
|
319
|
+
creator: string;
|
|
320
|
+
index: string;
|
|
321
|
+
};
|
|
161
322
|
ComputePayload: {
|
|
162
323
|
da_type: string;
|
|
163
324
|
agreement: string;
|
|
164
325
|
verification: string;
|
|
165
326
|
compute: string;
|
|
166
327
|
};
|
|
328
|
+
ComputePrefs: {
|
|
329
|
+
trusted: string;
|
|
330
|
+
tee: string;
|
|
331
|
+
mpc: string;
|
|
332
|
+
fhe: string;
|
|
333
|
+
zkp: string;
|
|
334
|
+
};
|
|
335
|
+
GuardianPrefs: {
|
|
336
|
+
pubKey: string;
|
|
337
|
+
guardian: string;
|
|
338
|
+
verifier: string;
|
|
339
|
+
compute: string;
|
|
340
|
+
computePrefs: string;
|
|
341
|
+
feeThreshold: string;
|
|
342
|
+
};
|
|
167
343
|
BlockLengthColumns: string;
|
|
168
344
|
BlockLengthRows: string;
|
|
169
345
|
BlockLength: {
|
|
@@ -252,6 +428,143 @@ declare const API_EXTENSIONS: {
|
|
|
252
428
|
};
|
|
253
429
|
};
|
|
254
430
|
|
|
431
|
+
declare const PALI_SYMBOL = "PALI";
|
|
432
|
+
declare const PALI_DECIMALS = 18;
|
|
433
|
+
interface TokenProperties {
|
|
434
|
+
symbol: string;
|
|
435
|
+
decimals: number;
|
|
436
|
+
}
|
|
437
|
+
type PaliAmountInput = string | number;
|
|
438
|
+
type AtomicPaliAmount = bigint;
|
|
439
|
+
declare const toAtomicPaliAmount: (amount: PaliAmountInput) => AtomicPaliAmount;
|
|
440
|
+
declare const fromAtomicPaliAmount: (amount: bigint) => string;
|
|
441
|
+
declare const formatPaliAmount: (amount: bigint, symbol?: string) => string;
|
|
442
|
+
/**
|
|
443
|
+
* Fetch token name and decimals from RPC system properties
|
|
444
|
+
* Results are cached for subsequent calls
|
|
445
|
+
* @param rpc - RPC provider instance with system.properties method
|
|
446
|
+
* @returns Promise<TokenProperties> with symbol and decimals
|
|
447
|
+
*/
|
|
448
|
+
declare function fetchTokenProperties(): Promise<TokenProperties>;
|
|
449
|
+
/**
|
|
450
|
+
* Get cached token properties without making an RPC call
|
|
451
|
+
* @returns TokenProperties or null if not yet cached
|
|
452
|
+
*/
|
|
453
|
+
declare function getCachedTokenProperties(): TokenProperties | null;
|
|
454
|
+
/**
|
|
455
|
+
* Clear the token properties cache
|
|
456
|
+
*/
|
|
457
|
+
declare function clearTokenCache(): void;
|
|
458
|
+
/**
|
|
459
|
+
* Format balance using cached token properties
|
|
460
|
+
* @param balance - The balance value to format
|
|
461
|
+
* @returns Formatted balance string
|
|
462
|
+
*/
|
|
463
|
+
declare function formatBalanceWithTokenProperties(balance: string | number | bigint): Promise<string>;
|
|
464
|
+
declare const tokenToBigint: (amount: PaliAmountInput) => AtomicPaliAmount;
|
|
465
|
+
|
|
466
|
+
type Hex = `0x${string}`;
|
|
467
|
+
/**
|
|
468
|
+
* Mirrors the on-chain ComputePayload SCALE type (CheckCompute signed extension).
|
|
469
|
+
* `agreement` is an array of 32-byte guardian peer-ID keys, obtained by
|
|
470
|
+
* base58-decoding the peer ID and stripping the first 6 multiaddr prefix bytes.
|
|
471
|
+
*/
|
|
472
|
+
interface ComputePayload {
|
|
473
|
+
/** DA type: 0 = none, 1 = DA. */
|
|
474
|
+
da_type: number;
|
|
475
|
+
/** Guardian agreement keys. Each element is a 32-byte Uint8Array or number[]. */
|
|
476
|
+
agreement?: Uint8Array[] | number[][];
|
|
477
|
+
/** Verification mode. */
|
|
478
|
+
verification: number;
|
|
479
|
+
/** Compute mode. */
|
|
480
|
+
compute: number;
|
|
481
|
+
}
|
|
482
|
+
|
|
483
|
+
interface OnChainRef {
|
|
484
|
+
blockNumber: number;
|
|
485
|
+
index: number;
|
|
486
|
+
}
|
|
487
|
+
interface SilentThresholdParams {
|
|
488
|
+
/** Encoded threshold ciphertext bytes (from encodeCiphertext). */
|
|
489
|
+
td_params: number[];
|
|
490
|
+
/** Guardian group aggregate public key bytes. */
|
|
491
|
+
pk_bytes: number[];
|
|
492
|
+
/** KZG powers-of-tau bytes. */
|
|
493
|
+
tau_params: number[];
|
|
494
|
+
}
|
|
495
|
+
type ThresholdParams = {
|
|
496
|
+
SilentThreshold: SilentThresholdParams;
|
|
497
|
+
};
|
|
498
|
+
type SymmetricParams = {
|
|
499
|
+
ChaCha20Poly1305: {
|
|
500
|
+
nonce: number[];
|
|
501
|
+
};
|
|
502
|
+
} | {
|
|
503
|
+
Aes256Gcm: {
|
|
504
|
+
nonce: number[];
|
|
505
|
+
};
|
|
506
|
+
};
|
|
507
|
+
type KdfParams = "HkdfSha256" | "HkdfSha512";
|
|
508
|
+
interface Secp256k1Params {
|
|
509
|
+
recipient_public_key: number[];
|
|
510
|
+
ephemeral_public_key?: number[] | null;
|
|
511
|
+
compressed: boolean;
|
|
512
|
+
kdf: KdfParams;
|
|
513
|
+
salt?: number[] | null;
|
|
514
|
+
info?: number[] | null;
|
|
515
|
+
}
|
|
516
|
+
interface Ed25519Params {
|
|
517
|
+
recipient_public_key: number[];
|
|
518
|
+
ephemeral_public_key?: number[] | null;
|
|
519
|
+
kdf: KdfParams;
|
|
520
|
+
salt?: number[] | null;
|
|
521
|
+
info?: number[] | null;
|
|
522
|
+
}
|
|
523
|
+
type AsymmetricParams = {
|
|
524
|
+
Secp256k1: Secp256k1Params;
|
|
525
|
+
} | {
|
|
526
|
+
Ed25519: Ed25519Params;
|
|
527
|
+
};
|
|
528
|
+
interface ThresholdHybridParams {
|
|
529
|
+
threshold_params: ThresholdParams;
|
|
530
|
+
symmetric_params: SymmetricParams;
|
|
531
|
+
}
|
|
532
|
+
interface AsymmetricHybridParams {
|
|
533
|
+
asymmetric_params: AsymmetricParams;
|
|
534
|
+
symmetric_params: SymmetricParams;
|
|
535
|
+
}
|
|
536
|
+
/** Mirrors the on-chain CipherSuite enum from spec.ts. */
|
|
537
|
+
type CipherSuite = "Plaintext" | {
|
|
538
|
+
ThresholdHybrid: ThresholdHybridParams;
|
|
539
|
+
} | {
|
|
540
|
+
AsymmetricHybrid: AsymmetricHybridParams;
|
|
541
|
+
};
|
|
542
|
+
interface SubmitTEDataResult {
|
|
543
|
+
ref: OnChainRef;
|
|
544
|
+
cipher: CipherSuite;
|
|
545
|
+
}
|
|
546
|
+
type GuardianAddress = string;
|
|
547
|
+
interface GuardianGroupInfo {
|
|
548
|
+
groupId: string;
|
|
549
|
+
guardians: GuardianAddress[];
|
|
550
|
+
tauParams: string;
|
|
551
|
+
aggKey: string;
|
|
552
|
+
groupPk: string;
|
|
553
|
+
}
|
|
554
|
+
interface UploadOptions {
|
|
555
|
+
name: string;
|
|
556
|
+
description: string;
|
|
557
|
+
price: PaliAmountInput;
|
|
558
|
+
type: "model" | "dataset" | "agent";
|
|
559
|
+
guardianGroupInfo: GuardianGroupInfo;
|
|
560
|
+
ref?: string;
|
|
561
|
+
filePath?: string;
|
|
562
|
+
/** Options forwarded to signAndSend. Defaults to dormant DA payload (da_type=1, compute=0). */
|
|
563
|
+
opts?: {
|
|
564
|
+
compute: ComputePayload;
|
|
565
|
+
};
|
|
566
|
+
}
|
|
567
|
+
|
|
255
568
|
type OnChainFileOptions = {
|
|
256
569
|
file: File;
|
|
257
570
|
filePath: string;
|
|
@@ -259,19 +572,27 @@ type OnChainFileOptions = {
|
|
|
259
572
|
description: string;
|
|
260
573
|
baseCost: bigint;
|
|
261
574
|
ownerL2Address: string;
|
|
262
|
-
guardianInfo:
|
|
575
|
+
guardianInfo: GuardianGroupInfo;
|
|
576
|
+
};
|
|
577
|
+
type ChunkRef = {
|
|
578
|
+
blockNumber: number;
|
|
579
|
+
extrinsicIndex: number;
|
|
580
|
+
};
|
|
581
|
+
type FileMetadata = {
|
|
582
|
+
name: string;
|
|
583
|
+
description: string;
|
|
584
|
+
startRef: [number, number];
|
|
263
585
|
};
|
|
264
586
|
declare class MCryptFs {
|
|
265
587
|
_api: any;
|
|
266
588
|
_init: boolean;
|
|
267
|
-
_metaRef:
|
|
268
|
-
_metadata:
|
|
269
|
-
_chunkRefs:
|
|
270
|
-
|
|
271
|
-
constructor(mcryptApi: any, metadataRef: any, metadata: any);
|
|
589
|
+
_metaRef: [number, number] | null;
|
|
590
|
+
_metadata: FileMetadata | null;
|
|
591
|
+
_chunkRefs: ChunkRef[];
|
|
592
|
+
constructor(mcryptApi: any, metadataRef: [number, number] | null, metadata: FileMetadata | null);
|
|
272
593
|
static dummyInstance(mcryptApi: any): MCryptFs;
|
|
273
594
|
isValid(): void;
|
|
274
|
-
getMetadata():
|
|
595
|
+
getMetadata(): FileMetadata | null;
|
|
275
596
|
}
|
|
276
597
|
declare class MCryptFsWriter {
|
|
277
598
|
_file: File;
|
|
@@ -282,42 +603,45 @@ declare class MCryptFsWriter {
|
|
|
282
603
|
_fileName: string;
|
|
283
604
|
_baseCost: bigint;
|
|
284
605
|
_ownerL2Address: string;
|
|
285
|
-
_guardianInfo:
|
|
606
|
+
_guardianInfo: GuardianGroupInfo;
|
|
286
607
|
_api: any;
|
|
287
|
-
_account:
|
|
288
|
-
_chunkRefs:
|
|
608
|
+
_account: KeyringPair;
|
|
609
|
+
_chunkRefs: ChunkRef[];
|
|
289
610
|
_blockNumber: number;
|
|
290
611
|
_extrinsicIndex: number;
|
|
291
612
|
_progress: {
|
|
292
613
|
iFileSize: number;
|
|
293
614
|
iBlocksWritten: number;
|
|
294
615
|
};
|
|
295
|
-
_error:
|
|
296
|
-
constructor(fileOptions: OnChainFileOptions, chunkSize: number | undefined, mcryptApi: any, account:
|
|
297
|
-
prependMetadata(chunk:
|
|
298
|
-
writeChunk(chunk:
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
616
|
+
_error: Error | null;
|
|
617
|
+
constructor(fileOptions: OnChainFileOptions, chunkSize: number | undefined, mcryptApi: any, account: KeyringPair);
|
|
618
|
+
prependMetadata(chunk: Blob): Blob;
|
|
619
|
+
writeChunk(chunk: Blob): Promise<{
|
|
620
|
+
blockNumber: number;
|
|
621
|
+
index: number;
|
|
622
|
+
}>;
|
|
623
|
+
submitKey(account: KeyringPair, data: string): Promise<{
|
|
624
|
+
blockNumber: number;
|
|
625
|
+
index: number;
|
|
626
|
+
hash: `0x${string}`;
|
|
627
|
+
tx_result: _polkadot_types_types.ISubmittableResult;
|
|
304
628
|
}>;
|
|
305
629
|
writeMetadata(): Promise<{
|
|
306
|
-
blockNumber:
|
|
307
|
-
index:
|
|
308
|
-
hash:
|
|
309
|
-
tx_result:
|
|
630
|
+
blockNumber: number;
|
|
631
|
+
index: number;
|
|
632
|
+
hash: `0x${string}`;
|
|
633
|
+
tx_result: _polkadot_types_types.ISubmittableResult;
|
|
310
634
|
}>;
|
|
311
635
|
writeFile(): Promise<MCryptFs>;
|
|
312
636
|
}
|
|
313
637
|
declare class MCryptFsReader {
|
|
314
638
|
_filename: string;
|
|
315
639
|
_api: any;
|
|
316
|
-
_onChainFile:
|
|
317
|
-
constructor(filename: string, mcryptApi: any, onChainFile:
|
|
640
|
+
_onChainFile: MCryptFs;
|
|
641
|
+
constructor(filename: string, mcryptApi: any, onChainFile: MCryptFs);
|
|
318
642
|
downloadFile(): Promise<Blob>;
|
|
319
643
|
}
|
|
320
|
-
declare const FileFromMetadataRef: (mcryptApi: any, metadataRef:
|
|
644
|
+
declare const FileFromMetadataRef: (mcryptApi: any, metadataRef: [number, number]) => Promise<MCryptFs>;
|
|
321
645
|
|
|
322
646
|
/**
|
|
323
647
|
* Module providing singleton access to Polkadot API, WebSocket provider, and keyring.
|
|
@@ -339,70 +663,6 @@ declare const FileFromMetadataRef: (mcryptApi: any, metadataRef: any) => Promise
|
|
|
339
663
|
* in production.
|
|
340
664
|
*/
|
|
341
665
|
|
|
342
|
-
/**
|
|
343
|
-
* Lightweight manager that holds and controls the lifecycle of the singleton
|
|
344
|
-
* WsProvider, ApiPromise and Keyring instances.
|
|
345
|
-
*
|
|
346
|
-
* @remarks
|
|
347
|
-
* - Instances are created lazily when {@link RpcApi.connect} is called.
|
|
348
|
-
* - The class maintains simple connection state via `isConnected`, `isConnecting`,
|
|
349
|
-
* and `error` fields so callers can inspect the status without directly
|
|
350
|
-
* interrogating the underlying API/provider.
|
|
351
|
-
* - Event handlers are attached to both the provider and the API to update `error`
|
|
352
|
-
* and `isConnected` appropriately when runtime errors or disconnects occur.
|
|
353
|
-
*
|
|
354
|
-
* @example
|
|
355
|
-
* const rpc = getRpcApi();
|
|
356
|
-
* await rpc.connect("wss://example.com");
|
|
357
|
-
* const { api, keyring } = await rpc.getApi();
|
|
358
|
-
*
|
|
359
|
-
* @public
|
|
360
|
-
*/
|
|
361
|
-
declare class RpcApi {
|
|
362
|
-
isConnected: boolean;
|
|
363
|
-
isConnecting: boolean;
|
|
364
|
-
error: string | null;
|
|
365
|
-
constructor();
|
|
366
|
-
/**
|
|
367
|
-
* Establishes a connection to a node at `endpoint` and returns the singleton
|
|
368
|
-
* API and Keyring instances.
|
|
369
|
-
*
|
|
370
|
-
* @param endpoint - WebSocket endpoint URL to connect to (e.g. "wss://...").
|
|
371
|
-
* @returns A promise resolving to an object containing the singleton {@link ApiPromise}
|
|
372
|
-
* instance and the singleton {@link Keyring} instance.
|
|
373
|
-
*
|
|
374
|
-
* @remarks
|
|
375
|
-
* - If a connection already exists (`isConnected === true`) the method returns
|
|
376
|
-
* the already-initialized instances without recreating them.
|
|
377
|
-
* - The method sets `isConnecting` to true while establishing the connection and
|
|
378
|
-
* clears it in a `finally` block.
|
|
379
|
-
* - Provider and API event listeners update the instance `error` and `isConnected`
|
|
380
|
-
* fields on runtime errors and disconnects.
|
|
381
|
-
* - The Keyring created here uses `sr25519` keys. If the standalone `getKeyring`
|
|
382
|
-
* helper is used elsewhere, it will additionally add a default development
|
|
383
|
-
* account derived from the well-known dev URI `//Bob` (named "Bob default").
|
|
384
|
-
*
|
|
385
|
-
* @throws Will re-throw underlying errors encountered while creating the provider
|
|
386
|
-
* or API. In that case `error` will contain the textual error message.
|
|
387
|
-
*/
|
|
388
|
-
connect(endpoint: string): Promise<{
|
|
389
|
-
api: ApiPromise | null;
|
|
390
|
-
keyring: Keyring | null;
|
|
391
|
-
}>;
|
|
392
|
-
/**
|
|
393
|
-
* Gracefully disconnects and nullifies the singleton API, provider and keyring
|
|
394
|
-
* instances managed by this RpcApi instance.
|
|
395
|
-
*
|
|
396
|
-
* @remarks
|
|
397
|
-
* - The method calls `api.disconnect()` and `wsProvider.disconnect()` if they
|
|
398
|
-
* exist, then sets the internal singletons to `null` and `isConnected` to false.
|
|
399
|
-
* - Any error during disconnect is captured in `error`.
|
|
400
|
-
*/
|
|
401
|
-
disconnect(): Promise<void>;
|
|
402
|
-
getApi(): ApiPromise | null;
|
|
403
|
-
getKeyring(): Keyring | null;
|
|
404
|
-
getEncKeyring(): Keyring | null;
|
|
405
|
-
}
|
|
406
666
|
/**
|
|
407
667
|
* getApi()
|
|
408
668
|
*
|
|
@@ -417,9 +677,11 @@ declare class RpcApi {
|
|
|
417
677
|
* cause the process to exit so that an external supervisor can restart the
|
|
418
678
|
* process.
|
|
419
679
|
*
|
|
680
|
+
* @param cb - Optional callback function to attach to the "disconnected" event.
|
|
681
|
+
*
|
|
420
682
|
* @returns The singleton {@link ApiPromise} instance (or `undefined` if no provider).
|
|
421
683
|
*/
|
|
422
|
-
declare function getApi(): Promise<ApiPromise | undefined>;
|
|
684
|
+
declare function getApi(cb?: () => void): Promise<ApiPromise | undefined>;
|
|
423
685
|
/**
|
|
424
686
|
* getKeyring()
|
|
425
687
|
*
|
|
@@ -461,37 +723,222 @@ declare function getKeyring(): Promise<Keyring>;
|
|
|
461
723
|
* @returns The singleton {@link Keyring} instance used for encryption keys.
|
|
462
724
|
*/
|
|
463
725
|
declare function getEncKeyring(): Promise<Keyring>;
|
|
464
|
-
/**
|
|
465
|
-
* Returns the singleton {@link RpcApi} manager instance, creating it on first use.
|
|
466
|
-
*
|
|
467
|
-
* @returns The singleton {@link RpcApi}.
|
|
468
|
-
*/
|
|
469
|
-
declare function getRpcApi(): RpcApi;
|
|
470
726
|
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
727
|
+
/** On-chain proof that a result extrinsic was included in a block. */
|
|
728
|
+
interface SubmissionReceipt {
|
|
729
|
+
/** Hash of the result extrinsic (hex-encoded, "0x..."). */
|
|
730
|
+
extrinsicHash: string;
|
|
731
|
+
/** Block height at which the result extrinsic was included. */
|
|
732
|
+
blockHeight: number;
|
|
733
|
+
/** Zero-based index of the result extrinsic within the block. */
|
|
734
|
+
extrinsicIndex: number;
|
|
735
|
+
}
|
|
736
|
+
|
|
737
|
+
declare const signAndSend: (request: SubmittableExtrinsic<"promise">, account: KeyringPair, opts?: Record<string, unknown>) => Promise<{
|
|
738
|
+
blockNumber: number;
|
|
739
|
+
index: number;
|
|
740
|
+
hash: `0x${string}`;
|
|
741
|
+
tx_result: ISubmittableResult;
|
|
482
742
|
}>;
|
|
483
|
-
declare const getFileMetadataCall: (api:
|
|
743
|
+
declare const getFileMetadataCall: (api: ApiPromise, metadataRef: [number, number]) => Promise<_polkadot_types_types.CallBase<_polkadot_types_types.AnyTuple, _polkadot_types_interfaces.FunctionMetadataLatest>>;
|
|
484
744
|
declare const getGuardianAddress: () => Promise<{
|
|
485
745
|
peerid: string;
|
|
486
746
|
address: string;
|
|
487
747
|
}[]>;
|
|
488
|
-
declare const getGuardianNwParams: () => Promise<
|
|
748
|
+
declare const getGuardianNwParams: () => Promise<string>;
|
|
749
|
+
/**
|
|
750
|
+
* Fetches the block at `blockHeight`, extracts the extrinsic at
|
|
751
|
+
* `extrinsicIndex`, and returns both the raw codec object and its human-readable
|
|
752
|
+
* decoded form.
|
|
753
|
+
*
|
|
754
|
+
* Throws if the block cannot be found or the index is out of range.
|
|
755
|
+
*/
|
|
756
|
+
declare function fetchAndDecodeExtrinsic(blockHeight: number, extrinsicIndex: number): Promise<{
|
|
757
|
+
raw: any;
|
|
758
|
+
decoded: Record<string, unknown>;
|
|
759
|
+
}>;
|
|
760
|
+
type BlockScanFilter = {
|
|
761
|
+
/** Pallet name, e.g. "dataAvailability" (case-insensitive) */
|
|
762
|
+
section: string;
|
|
763
|
+
/** Event name, e.g. "DaccGuardianGroup" (case-insensitive) */
|
|
764
|
+
method: string;
|
|
765
|
+
predicate?: never;
|
|
766
|
+
} | {
|
|
767
|
+
/**
|
|
768
|
+
* Custom predicate called for every event record in each scanned block.
|
|
769
|
+
* The full signed block is pre-fetched before any predicate call.
|
|
770
|
+
* Return true to accept the match and resolve, false to skip and keep scanning.
|
|
771
|
+
*/
|
|
772
|
+
predicate: (block: SignedBlock, event: EventRecord['event'], phase: EventRecord['phase']) => boolean | Promise<boolean>;
|
|
773
|
+
section?: never;
|
|
774
|
+
method?: never;
|
|
775
|
+
};
|
|
776
|
+
type BlockScanResult = {
|
|
777
|
+
blockHash: string;
|
|
778
|
+
blockNumber: number;
|
|
779
|
+
/** Index of the extrinsic that emitted the event, or null for inherents */
|
|
780
|
+
extrinsicIndex: number | null;
|
|
781
|
+
/** Returns the full signed block; cached when predicate mode was used */
|
|
782
|
+
block: () => Promise<SignedBlock>;
|
|
783
|
+
/** All event records for this block */
|
|
784
|
+
events: EventRecord[];
|
|
785
|
+
};
|
|
786
|
+
/**
|
|
787
|
+
* Subscribes to new block headers and resolves with a match descriptor as soon
|
|
788
|
+
* as a qualifying event is found.
|
|
789
|
+
*
|
|
790
|
+
* Supply exactly one of:
|
|
791
|
+
* - `section` + `method` — lightweight name match, no block fetch
|
|
792
|
+
* - `predicate(block, event, phase)` — full control; block is pre-fetched
|
|
793
|
+
*
|
|
794
|
+
* @param api Connected ApiPromise instance
|
|
795
|
+
* @param filter Either a name filter or a predicate (mutually exclusive)
|
|
796
|
+
* @param startBlock Ignore blocks with a number strictly below this value
|
|
797
|
+
* @param maxBlocks Reject after scanning this many blocks; pass 0 to wait indefinitely (default 20)
|
|
798
|
+
*/
|
|
799
|
+
declare const scanForBlockEvent: (api: ApiPromise, filter: BlockScanFilter, startBlock?: number, maxBlocks?: number) => Promise<BlockScanResult>;
|
|
800
|
+
/**
|
|
801
|
+
* Subscribes to new block headers and scans each block's extrinsics until a
|
|
802
|
+
* `compute.result` extrinsic matching `requestId` is found. Resolves with the
|
|
803
|
+
* {@link SubmissionReceipt} (extrinsic hash, block height, and extrinsic index).
|
|
804
|
+
*
|
|
805
|
+
* The result-relay submits the extrinsic asynchronously, so this watcher may
|
|
806
|
+
* need to observe several blocks before the tx lands.
|
|
807
|
+
*
|
|
808
|
+
* @param requestId - The hex-encoded request ID to match (e.g. "0xabc123…").
|
|
809
|
+
* @param timeoutMs - Milliseconds to wait before giving up (default: 10 min).
|
|
810
|
+
*/
|
|
811
|
+
declare function watchForSubmissionReceipt(requestId: string, timeoutMs?: number): Promise<SubmissionReceipt>;
|
|
812
|
+
/**
|
|
813
|
+
* Fetches block events at `blockHeight` and returns the request ID from the
|
|
814
|
+
* `compute.AgreementCreated` event emitted by the extrinsic at `extrinsicIndex`.
|
|
815
|
+
* Returns `null` if no matching event is found for that extrinsic.
|
|
816
|
+
*/
|
|
817
|
+
declare function getAgreementCreatedRequestId(blockHeight: number, extrinsicIndex: number): Promise<string | null>;
|
|
489
818
|
|
|
490
819
|
declare const provider: WsProvider;
|
|
491
820
|
|
|
492
|
-
|
|
821
|
+
interface ComputeContract {
|
|
822
|
+
contract_type: "Active" | "Dormant";
|
|
823
|
+
guardians: GuardianAddress[];
|
|
824
|
+
pre_check?: unknown;
|
|
825
|
+
compute: Record<string, unknown>;
|
|
826
|
+
post_check?: unknown;
|
|
827
|
+
result_cipher: unknown;
|
|
828
|
+
}
|
|
829
|
+
declare function createAgreement(contract: ComputeContract, account: KeyringPair): Promise<{
|
|
830
|
+
blockNumber: number;
|
|
831
|
+
index: number;
|
|
832
|
+
hash: string;
|
|
833
|
+
agreementId?: string;
|
|
834
|
+
}>;
|
|
835
|
+
declare function createSimpleAgreement(): Promise<{
|
|
836
|
+
blockNumber: number;
|
|
837
|
+
index: number;
|
|
838
|
+
hash: string;
|
|
839
|
+
agreementId?: string;
|
|
840
|
+
}>;
|
|
841
|
+
|
|
842
|
+
interface DataContractParams {
|
|
843
|
+
/** URL pointing to the data to store. */
|
|
844
|
+
url: string;
|
|
845
|
+
/** Guardian account IDs that participate in this contract. */
|
|
846
|
+
guardians: string[];
|
|
847
|
+
/** Fee offered for the contract in PALI. Defaults to 0. */
|
|
848
|
+
fees?: PaliAmountInput;
|
|
849
|
+
/** Block number deadline. Defaults to 0 (no deadline). */
|
|
850
|
+
deadline?: number;
|
|
851
|
+
/** Trusted guardian index in the guardians list. Defaults to 0. */
|
|
852
|
+
trustIndex?: number;
|
|
853
|
+
}
|
|
854
|
+
/**
|
|
855
|
+
* Submits a dormant data-store contract on-chain via `compute.agreement`.
|
|
856
|
+
*
|
|
857
|
+
* - No encryption (Plaintext cipher suite)
|
|
858
|
+
* - Trusted confidentiality mode
|
|
859
|
+
* - Input fetched from a URL
|
|
860
|
+
* - No pre-check or post-check verifications
|
|
861
|
+
* - Plain (unencrypted) result
|
|
862
|
+
*/
|
|
863
|
+
declare function dataContract(params: DataContractParams, account: KeyringPair): Promise<{
|
|
864
|
+
blockNumber: number;
|
|
865
|
+
index: number;
|
|
866
|
+
hash: string;
|
|
867
|
+
agreementId?: string;
|
|
868
|
+
}>;
|
|
869
|
+
|
|
870
|
+
interface InferenceComputeParams {
|
|
871
|
+
/** Raw input data — string will be UTF-8 encoded, Uint8Array used as-is. */
|
|
872
|
+
input: Uint8Array | string;
|
|
873
|
+
/** Guardian account IDs that participate in this compute. */
|
|
874
|
+
guardians: string[];
|
|
875
|
+
/** Fee offered for the compute step in PALI. Defaults to 0. */
|
|
876
|
+
fees?: PaliAmountInput;
|
|
877
|
+
/** Block number deadline for the compute step. Defaults to 0 (no deadline). */
|
|
878
|
+
deadline?: number;
|
|
879
|
+
}
|
|
880
|
+
/**
|
|
881
|
+
* Submits a plain (unencrypted, no-confidentiality) inference compute request
|
|
882
|
+
* on-chain via the `compute.agreement` extrinsic.
|
|
883
|
+
*
|
|
884
|
+
* - Input is sent inline (no DA layer indirection).
|
|
885
|
+
* - Program is the native `Inference` executor.
|
|
886
|
+
* - Pre-check and post-check are no-ops (no verification).
|
|
887
|
+
* - Cipher fields carry zero-value placeholders (unused in the trusted path).
|
|
888
|
+
* - Result is returned in plain (no re-encryption).
|
|
889
|
+
*/
|
|
890
|
+
declare function inferenceCompute(params: InferenceComputeParams, account: KeyringPair): Promise<{
|
|
891
|
+
blockNumber: number;
|
|
892
|
+
index: number;
|
|
893
|
+
hash: string;
|
|
894
|
+
agreementId?: string;
|
|
895
|
+
}>;
|
|
896
|
+
|
|
897
|
+
interface GuardianParticipants {
|
|
898
|
+
nwState: {
|
|
899
|
+
localPeerId: string | undefined;
|
|
900
|
+
worker: unknown;
|
|
901
|
+
currentEra: unknown;
|
|
902
|
+
guardians: string | null;
|
|
903
|
+
nextGuardians: string | null;
|
|
904
|
+
currentIndex: unknown;
|
|
905
|
+
nextIndex: number;
|
|
906
|
+
};
|
|
907
|
+
currentGuardians: unknown[];
|
|
908
|
+
upcomingGuardians: unknown[];
|
|
909
|
+
}
|
|
910
|
+
declare function getGuardianParticipants(): Promise<GuardianParticipants>;
|
|
493
911
|
|
|
494
|
-
|
|
912
|
+
interface SimpleComputeParams {
|
|
913
|
+
/** Guardian account IDs that participate in this compute. */
|
|
914
|
+
guardians: string[];
|
|
915
|
+
/** Input reference block number from which to read the tx payload. */
|
|
916
|
+
inputBlockNumber?: number;
|
|
917
|
+
/** Input reference extrinsic index within the input block. */
|
|
918
|
+
inputExtrinsicIndex?: number;
|
|
919
|
+
/** Program location as URL. */
|
|
920
|
+
programUrl: string;
|
|
921
|
+
/** Fee offered for the compute step in PALI. Defaults to 0. */
|
|
922
|
+
fees?: PaliAmountInput;
|
|
923
|
+
/** Block number deadline for the compute step. Defaults to 0 (no deadline). */
|
|
924
|
+
deadline?: number;
|
|
925
|
+
/** Trusted guardian index in the guardians list. Defaults to 0. */
|
|
926
|
+
trustIndex?: number;
|
|
927
|
+
}
|
|
928
|
+
/**
|
|
929
|
+
* Submits a minimal trusted compute agreement:
|
|
930
|
+
* - no encryption (plaintext cipher)
|
|
931
|
+
* - trusted confidentiality mode
|
|
932
|
+
* - input from chain transaction reference
|
|
933
|
+
* - program fetched from URL
|
|
934
|
+
* - no pre/post verification
|
|
935
|
+
*/
|
|
936
|
+
declare function simpleCompute(params: SimpleComputeParams, account: KeyringPair): Promise<{
|
|
937
|
+
blockNumber: number;
|
|
938
|
+
index: number;
|
|
939
|
+
hash: string;
|
|
940
|
+
agreementId?: string;
|
|
941
|
+
}>;
|
|
495
942
|
|
|
496
943
|
declare const gen_stretched_key: (input: Uint8Array) => Uint8Array<ArrayBufferLike>;
|
|
497
944
|
declare const gen_shared_key: (key: Uint8Array, pk: Uint8Array) => Uint8Array<ArrayBufferLike>;
|
|
@@ -625,78 +1072,120 @@ declare const testCrypt: (kzg: string, agg_key: string) => {
|
|
|
625
1072
|
*/
|
|
626
1073
|
declare function generateRandomBytes(length?: number): Uint8Array;
|
|
627
1074
|
|
|
628
|
-
|
|
1075
|
+
declare function writeMetadata(account: KeyringPair, name: string, description: string, ref: OnChainRef, price: bigint, dataType: number, l2Owner: string, groupId: string): Promise<{
|
|
629
1076
|
blockNumber: number;
|
|
630
1077
|
index: number;
|
|
631
|
-
}
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
tauParams: string;
|
|
636
|
-
aggKey: string;
|
|
637
|
-
groupPk: string;
|
|
638
|
-
}
|
|
639
|
-
interface UploadOptions {
|
|
1078
|
+
hash: `0x${string}`;
|
|
1079
|
+
tx_result: _polkadot_types_types.ISubmittableResult;
|
|
1080
|
+
}>;
|
|
1081
|
+
interface DataAgreementMetadata {
|
|
640
1082
|
name: string;
|
|
641
1083
|
description: string;
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
1084
|
+
/** Maps to the on-chain StoreType enum. */
|
|
1085
|
+
storeType: "Dataset" | "Model" | "Agent" | "Other";
|
|
1086
|
+
/** H256 group identifier. */
|
|
1087
|
+
groupId: string;
|
|
1088
|
+
}
|
|
1089
|
+
interface DataAgreementParams {
|
|
1090
|
+
/** DA blob reference returned by submitTEData. */
|
|
1091
|
+
ref: OnChainRef;
|
|
1092
|
+
/** Guardian account IDs that participate in this agreement. */
|
|
1093
|
+
guardians: string[];
|
|
1094
|
+
/** Fee for the agreement in PALI atomic units. */
|
|
1095
|
+
fees: bigint;
|
|
1096
|
+
/** If provided, populates ComputeInfo.metadata in the contract. */
|
|
1097
|
+
metadata?: DataAgreementMetadata;
|
|
1098
|
+
/** Block number deadline. Defaults to 0 (no deadline). */
|
|
1099
|
+
deadline?: number;
|
|
1100
|
+
/** Trusted guardian index in the guardians list. Defaults to 0. */
|
|
1101
|
+
trustIndex?: number;
|
|
1102
|
+
/**
|
|
1103
|
+
* CipherSuite for the compute step input. Defaults to "Plaintext".
|
|
1104
|
+
* Pass the `cipher` from submitTEDataWithCipher for the threshold-encrypted path.
|
|
1105
|
+
*/
|
|
1106
|
+
cipher?: CipherSuite;
|
|
1107
|
+
/**
|
|
1108
|
+
* CipherSuite for the agreement result. Defaults to "Plaintext".
|
|
1109
|
+
*/
|
|
1110
|
+
resultCipher?: CipherSuite;
|
|
647
1111
|
}
|
|
1112
|
+
declare function registerDataAgreement(account: KeyringPair, params: DataAgreementParams): Promise<{
|
|
1113
|
+
blockNumber: number;
|
|
1114
|
+
index: number;
|
|
1115
|
+
hash: string;
|
|
1116
|
+
agreementId?: string;
|
|
1117
|
+
}>;
|
|
648
1118
|
|
|
649
|
-
declare function
|
|
650
|
-
blockNumber:
|
|
651
|
-
index:
|
|
652
|
-
hash:
|
|
653
|
-
tx_result:
|
|
1119
|
+
declare function runAgent(account: KeyringPair, agentRef: OnChainRef, nonce: Uint8Array, ciphertext: Uint8Array, tdParams: Uint8Array, pkBytes: Uint8Array, tauParams: Uint8Array, baseModel: OnChainRef, publicKey: Uint8Array, guardians: Uint8Array[], guardian?: Uint8Array, agreementId?: Uint8Array): Promise<{
|
|
1120
|
+
blockNumber: number;
|
|
1121
|
+
index: number;
|
|
1122
|
+
hash: `0x${string}`;
|
|
1123
|
+
tx_result: _polkadot_types_types.ISubmittableResult;
|
|
654
1124
|
}>;
|
|
655
1125
|
|
|
656
|
-
declare function submitData(account:
|
|
657
|
-
declare function submitTEData(account:
|
|
1126
|
+
declare function submitData(account: KeyringPair, data: string): Promise<void>;
|
|
1127
|
+
declare function submitTEData(account: KeyringPair, data: string, chosenGuardians: string[], tau_params: string, agg_key: string, group_pk: string): Promise<OnChainRef>;
|
|
1128
|
+
/**
|
|
1129
|
+
* Identical to submitTEData but additionally returns the populated CipherSuite
|
|
1130
|
+
* so callers can pass it directly to registerDataAgreement without
|
|
1131
|
+
* re-deriving the cipher parameters.
|
|
1132
|
+
*/
|
|
1133
|
+
declare function submitTEDataWithCipher(account: KeyringPair, data: string, chosenGuardians: string[], tau_params: string, agg_key: string, group_pk: string): Promise<SubmitTEDataResult>;
|
|
658
1134
|
|
|
659
1135
|
declare function uploadData(options: UploadOptions): Promise<void>;
|
|
1136
|
+
/**
|
|
1137
|
+
* Legacy upload: uses submitTEData (returns only OnChainRef) and registers
|
|
1138
|
+
* the agreement with Plaintext cipher and no ComputePayload opts.
|
|
1139
|
+
* Kept for backward compatibility with callers that do not need cipher
|
|
1140
|
+
* parameters surfaced in the on-chain agreement.
|
|
1141
|
+
*/
|
|
1142
|
+
declare function uploadDataLegacy(options: Omit<UploadOptions, "opts">): Promise<void>;
|
|
660
1143
|
|
|
661
1144
|
declare const getGuardianList: () => Promise<string[]>;
|
|
662
1145
|
|
|
663
|
-
declare const createGuardianGroup: (account:
|
|
664
|
-
|
|
665
|
-
|
|
1146
|
+
declare const createGuardianGroup: (account: KeyringPair, selectedGuardians: GuardianAddress[]) => Promise<{
|
|
1147
|
+
blockNumber: number;
|
|
1148
|
+
index: number;
|
|
1149
|
+
hash: `0x${string}`;
|
|
1150
|
+
tx_result: _polkadot_types_types.ISubmittableResult;
|
|
1151
|
+
}>;
|
|
1152
|
+
/**
|
|
1153
|
+
* Creates a guardian group with exactly 3 guardians, waits for tx confirmation,
|
|
1154
|
+
* then watches incoming blocks for the `DaccGuardianGroup` event (emitted by a
|
|
1155
|
+
* subsequent `daccGuardianGroupInfo` extrinsic) and returns the decoded args.
|
|
1156
|
+
*
|
|
1157
|
+
* @param account Signing account
|
|
1158
|
+
* @param guardians Exactly 3 guardian addresses / peer-ids
|
|
1159
|
+
* @param maxBlocks Give up waiting for the event after this many blocks; 0 = indefinite (default 20)
|
|
1160
|
+
*/
|
|
1161
|
+
declare const createGuardianGroupAndWatch: (account: KeyringPair, guardians: GuardianAddress[], maxBlocks?: number) => Promise<GuardianGroupInfo>;
|
|
666
1162
|
|
|
667
|
-
|
|
1163
|
+
interface GuardianJoinPrefs {
|
|
1164
|
+
compute?: string;
|
|
1165
|
+
fee?: bigint | string | number;
|
|
1166
|
+
standard?: boolean;
|
|
1167
|
+
verifier?: boolean;
|
|
1168
|
+
}
|
|
1169
|
+
declare function joinGuardian(account: KeyringPair, prefs: GuardianJoinPrefs): Promise<void>;
|
|
668
1170
|
|
|
669
|
-
declare function
|
|
1171
|
+
declare function addStake(account: KeyringPair, amountBaseUnits: bigint): Promise<void>;
|
|
670
1172
|
|
|
671
|
-
declare function
|
|
1173
|
+
declare function joinIdleStaker(account: KeyringPair): Promise<void>;
|
|
672
1174
|
|
|
673
|
-
declare function
|
|
1175
|
+
declare function newStake(account: KeyringPair, amountBaseUnits: bigint, rewardDestination?: string): Promise<void>;
|
|
674
1176
|
|
|
675
|
-
declare function
|
|
1177
|
+
declare function payoutStake(account: KeyringPair, eras: Array<number>, address?: string): Promise<void>;
|
|
676
1178
|
|
|
677
|
-
declare function
|
|
1179
|
+
declare function reduceStake(account: KeyringPair, amountBaseUnits: bigint): Promise<void>;
|
|
678
1180
|
|
|
679
|
-
declare function
|
|
1181
|
+
declare function removeStake(account: KeyringPair): Promise<void>;
|
|
680
1182
|
|
|
681
|
-
declare function
|
|
1183
|
+
declare function withdrawStake(account: KeyringPair): Promise<void>;
|
|
682
1184
|
|
|
683
|
-
declare function
|
|
1185
|
+
declare function fundAccount(account: KeyringPair, amountBaseUnits: bigint, address?: string): Promise<void>;
|
|
684
1186
|
|
|
685
|
-
|
|
1187
|
+
declare function transfer(account: KeyringPair, amountBaseUnits: bigint, address: string): Promise<void>;
|
|
686
1188
|
|
|
687
|
-
/**
|
|
688
|
-
* Converts a token amount expressed in milliPALI into the smallest PALI denomination (10^-18 PALI) as a bigint.
|
|
689
|
-
*
|
|
690
|
-
* The function takes milliPALI denomination and returns the bigint value in the lowest denomination of the PALI token which is 10^-18.
|
|
691
|
-
*
|
|
692
|
-
* @param arg - The token amount to convert. Can be a string, number, or bigint representing an amount in milliPALI.
|
|
693
|
-
* @returns The token amount converted to the smallest PALI unit (10^-18 PALI) as a bigint.
|
|
694
|
-
*
|
|
695
|
-
* @example
|
|
696
|
-
* // 1 milliPALI => 10^15 lowest-denomination units
|
|
697
|
-
* tokenToBigint("1"); // => 1000000000000000n
|
|
698
|
-
*/
|
|
699
|
-
declare const tokenToBigint: (arg: string | number | bigint) => bigint;
|
|
700
1189
|
/**
|
|
701
1190
|
* Converts a hex string into a Uint8Array.
|
|
702
1191
|
*
|
|
@@ -763,34 +1252,7 @@ declare const decodeField: (field: string, expectedLength?: number) => Uint8Arra
|
|
|
763
1252
|
*/
|
|
764
1253
|
declare const debugLog: (message?: any, ...optionalParams: any[]) => void;
|
|
765
1254
|
|
|
766
|
-
|
|
767
|
-
symbol: string;
|
|
768
|
-
decimals: number;
|
|
769
|
-
}
|
|
770
|
-
/**
|
|
771
|
-
* Fetch token name and decimals from RPC system properties
|
|
772
|
-
* Results are cached for subsequent calls
|
|
773
|
-
* @param rpc - RPC provider instance with system.properties method
|
|
774
|
-
* @returns Promise<TokenProperties> with symbol and decimals
|
|
775
|
-
*/
|
|
776
|
-
declare function fetchTokenProperties(): Promise<TokenProperties>;
|
|
777
|
-
/**
|
|
778
|
-
* Get cached token properties without making an RPC call
|
|
779
|
-
* @returns TokenProperties or null if not yet cached
|
|
780
|
-
*/
|
|
781
|
-
declare function getCachedTokenProperties(): TokenProperties | null;
|
|
782
|
-
/**
|
|
783
|
-
* Clear the token properties cache
|
|
784
|
-
*/
|
|
785
|
-
declare function clearTokenCache(): void;
|
|
786
|
-
/**
|
|
787
|
-
* Format balance using cached token properties
|
|
788
|
-
* @param balance - The balance value to format
|
|
789
|
-
* @returns Formatted balance string
|
|
790
|
-
*/
|
|
791
|
-
declare function formatBalanceWithTokenProperties(balance: string | number): Promise<string>;
|
|
792
|
-
|
|
793
|
-
declare function joinValidator(account: any, commission: number): Promise<void>;
|
|
1255
|
+
declare function joinValidator(account: KeyringPair, commission: number): Promise<void>;
|
|
794
1256
|
|
|
795
1257
|
declare let PALLIORA_WS: string;
|
|
796
1258
|
declare let PALLIORA_RPC_URL: string;
|
|
@@ -803,9 +1265,12 @@ declare function configure(opts: {
|
|
|
803
1265
|
txWaitFinalization?: boolean;
|
|
804
1266
|
}): void;
|
|
805
1267
|
|
|
806
|
-
|
|
1268
|
+
interface IdentityFields {
|
|
1269
|
+
display?: string;
|
|
1270
|
+
}
|
|
1271
|
+
declare function setIdentity(account: KeyringPair, { display }: IdentityFields): Promise<void>;
|
|
807
1272
|
|
|
808
|
-
declare function rotateAndSetKeys(account:
|
|
809
|
-
declare function setWorker(account:
|
|
1273
|
+
declare function rotateAndSetKeys(account: KeyringPair): Promise<void>;
|
|
1274
|
+
declare function setWorker(account: KeyringPair): Promise<void>;
|
|
810
1275
|
|
|
811
|
-
export { API_EXTENSIONS, API_RPC, API_TYPES, AccountSourceType, CryptoType, DEBUG, DEFAULT_COMPUTE_PAYLOAD, DEFAULT_EMPTY_PAYLOAD, FileFromMetadataRef, type GuardianGroupInfo, MCryptFs, MCryptFsReader, MCryptFsWriter, type OnChainRef, PALLIORA_RPC_URL, PALLIORA_WS,
|
|
1276
|
+
export { API_EXTENSIONS, API_RPC, API_TYPES, AccountSourceType, type AsymmetricHybridParams, type AsymmetricParams, type AtomicPaliAmount, type BlockScanFilter, type BlockScanResult, type CipherSuite, type ComputeContract, CryptoType, DEBUG, DEFAULT_COMPUTE_PAYLOAD, DEFAULT_EMPTY_PAYLOAD, type DataAgreementMetadata, type DataAgreementParams, type DataContractParams, type Ed25519Params, FileFromMetadataRef, type GuardianAddress, type GuardianGroupInfo, type GuardianJoinPrefs, type GuardianParticipants, type IdentityFields, type InferenceComputeParams, type KdfParams, MCryptFs, MCryptFsReader, MCryptFsWriter, type OnChainRef, PALI_DECIMALS, PALI_SYMBOL, PALLIORA_RPC_URL, PALLIORA_WS, type PaliAmountInput, type Secp256k1Params, type SilentThresholdParams, type SimpleComputeParams, type SubmissionReceipt, type SubmitTEDataResult, type SymmetricParams, TX_WAIT_FINALIZATION, type ThresholdHybridParams, type ThresholdParams, type UploadOptions, addStake, base64ToUint8Array, clearTokenCache, configure, createAccount, createAgreement, createGuardianGroup, createGuardianGroupAndWatch, createSimpleAgreement, dataContract, debugLog, decodeAggregateKey, decodeField, decodePowersOfTau, decrypt, encrypt as ecncryptTest, encodeCiphertext, encrypt$1 as encrypt, fetchAndDecodeExtrinsic, fetchTokenProperties, formatBalanceWithTokenProperties, formatPaliAmount, fromAtomicPaliAmount, fundAccount, gen_shared_key, gen_stretched_key, generateRandomBytes, getAgreementCreatedRequestId, getApi, getCachedTokenProperties, getEncKeyring, getFileMetadataCall, getGuardianAddress, getGuardianList, getGuardianNwParams, getGuardianParticipants, getKeyring, hexToUint8Array, inferenceCompute, joinGuardian, joinIdleStaker, joinValidator, newStake, pairFromPrivateKeyHex, payoutStake, provider, reduceStake, registerDataAgreement, removeStake, rotateAndSetKeys, runAgent, scanForBlockEvent, setIdentity, setWorker, signAndSend, simpleCompute, submitData, submitTEData, submitTEDataWithCipher, testCrypt, toAtomicPaliAmount, tokenToBigint, transfer, uint8ArrayToBase64, uploadData, uploadDataLegacy, watchForSubmissionReceipt, withdrawStake, writeMetadata };
|