@palliora.org/chainsdk 0.2.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.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: any, type: AccountSourceType, name?: string, cryptoType?: CryptoType): Promise<any>;
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: {
@@ -168,7 +174,7 @@ declare const API_TYPES: {
168
174
  pk_bytes: string;
169
175
  tau_params: string;
170
176
  };
171
- ThresholdAlgos: {
177
+ ThresholdParams: {
172
178
  _enum: {
173
179
  SilentThreshold: string;
174
180
  };
@@ -179,24 +185,61 @@ declare const API_TYPES: {
179
185
  Aes256GcmParams: {
180
186
  nonce: string;
181
187
  };
182
- SymmetricAlgos: {
188
+ SymmetricParams: {
183
189
  _enum: {
184
190
  ChaCha20Poly1305: string;
185
191
  Aes256Gcm: string;
186
192
  };
187
193
  };
188
- CipherSuiteEncrypted: {
189
- threshold: string;
190
- symmetric: string;
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;
191
228
  };
192
229
  CipherSuite: {
193
230
  _enum: {
194
231
  Plaintext: string;
195
- Encrypted: string;
232
+ ThresholdHybrid: string;
233
+ AsymmetricHybrid: string;
196
234
  };
197
235
  };
198
236
  ConfidentialityLevel: {
199
- _enum: string[];
237
+ _enum: {
238
+ Trusted: string;
239
+ TEE: string;
240
+ FHE: string;
241
+ SMPC: string;
242
+ };
200
243
  };
201
244
  NativeExecuteDA: {
202
245
  _enum: string[];
@@ -222,6 +265,7 @@ declare const API_TYPES: {
222
265
  };
223
266
  DAInput: {
224
267
  _enum: {
268
+ Null: string;
225
269
  Inline: string;
226
270
  ChainTransaction: string;
227
271
  Ipfs: string;
@@ -384,6 +428,143 @@ declare const API_EXTENSIONS: {
384
428
  };
385
429
  };
386
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
+
387
568
  type OnChainFileOptions = {
388
569
  file: File;
389
570
  filePath: string;
@@ -391,19 +572,27 @@ type OnChainFileOptions = {
391
572
  description: string;
392
573
  baseCost: bigint;
393
574
  ownerL2Address: string;
394
- guardianInfo: any;
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];
395
585
  };
396
586
  declare class MCryptFs {
397
587
  _api: any;
398
588
  _init: boolean;
399
- _metaRef: any;
400
- _metadata: any;
401
- _chunkRefs: any;
402
- _startRef: any;
403
- 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);
404
593
  static dummyInstance(mcryptApi: any): MCryptFs;
405
594
  isValid(): void;
406
- getMetadata(): any;
595
+ getMetadata(): FileMetadata | null;
407
596
  }
408
597
  declare class MCryptFsWriter {
409
598
  _file: File;
@@ -414,42 +603,45 @@ declare class MCryptFsWriter {
414
603
  _fileName: string;
415
604
  _baseCost: bigint;
416
605
  _ownerL2Address: string;
417
- _guardianInfo: any;
606
+ _guardianInfo: GuardianGroupInfo;
418
607
  _api: any;
419
- _account: any;
420
- _chunkRefs: any[];
608
+ _account: KeyringPair;
609
+ _chunkRefs: ChunkRef[];
421
610
  _blockNumber: number;
422
611
  _extrinsicIndex: number;
423
612
  _progress: {
424
613
  iFileSize: number;
425
614
  iBlocksWritten: number;
426
615
  };
427
- _error: any;
428
- constructor(fileOptions: OnChainFileOptions, chunkSize: number | undefined, mcryptApi: any, account: any);
429
- prependMetadata(chunk: any): Blob;
430
- writeChunk(chunk: any): Promise<unknown>;
431
- submitKey(account: any, data: any): Promise<{
432
- blockNumber: any;
433
- index: any;
434
- hash: any;
435
- tx_result: any;
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;
436
628
  }>;
437
629
  writeMetadata(): Promise<{
438
- blockNumber: any;
439
- index: any;
440
- hash: any;
441
- tx_result: any;
630
+ blockNumber: number;
631
+ index: number;
632
+ hash: `0x${string}`;
633
+ tx_result: _polkadot_types_types.ISubmittableResult;
442
634
  }>;
443
635
  writeFile(): Promise<MCryptFs>;
444
636
  }
445
637
  declare class MCryptFsReader {
446
638
  _filename: string;
447
639
  _api: any;
448
- _onChainFile: any;
449
- constructor(filename: string, mcryptApi: any, onChainFile: any);
640
+ _onChainFile: MCryptFs;
641
+ constructor(filename: string, mcryptApi: any, onChainFile: MCryptFs);
450
642
  downloadFile(): Promise<Blob>;
451
643
  }
452
- declare const FileFromMetadataRef: (mcryptApi: any, metadataRef: any) => Promise<MCryptFs>;
644
+ declare const FileFromMetadataRef: (mcryptApi: any, metadataRef: [number, number]) => Promise<MCryptFs>;
453
645
 
454
646
  /**
455
647
  * Module providing singleton access to Polkadot API, WebSocket provider, and keyring.
@@ -532,83 +724,126 @@ declare function getKeyring(): Promise<Keyring>;
532
724
  */
533
725
  declare function getEncKeyring(): Promise<Keyring>;
534
726
 
535
- declare const signAndSend: (request: any, account: any, opts?: {
536
- compute: {
537
- da_type: number;
538
- verification: number;
539
- compute: number;
540
- };
541
- }) => Promise<{
542
- blockNumber: any;
543
- index: any;
544
- hash: any;
545
- tx_result: any;
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;
546
742
  }>;
547
- declare const getFileMetadataCall: (api: any, metadataRef: [number, number]) => Promise<any>;
743
+ declare const getFileMetadataCall: (api: ApiPromise, metadataRef: [number, number]) => Promise<_polkadot_types_types.CallBase<_polkadot_types_types.AnyTuple, _polkadot_types_interfaces.FunctionMetadataLatest>>;
548
744
  declare const getGuardianAddress: () => Promise<{
549
745
  peerid: string;
550
746
  address: string;
551
747
  }[]>;
552
- declare const getGuardianNwParams: () => Promise<any>;
553
-
554
- declare const provider: WsProvider;
555
-
556
- declare function createAgreement(contract: any, account: any): Promise<{
557
- blockNumber: any;
558
- index: any;
559
- hash: any;
560
- agreementId?: string;
561
- }>;
562
- declare function createSimpleAgreement(): Promise<{
563
- blockNumber: any;
564
- index: any;
565
- hash: any;
566
- agreementId?: string;
567
- }>;
568
-
569
- declare const PALI_SYMBOL = "PALI";
570
- declare const PALI_DECIMALS = 18;
571
- interface TokenProperties {
572
- symbol: string;
573
- decimals: number;
574
- }
575
- type PaliAmountInput = string | number;
576
- type AtomicPaliAmount = bigint;
577
- declare const toAtomicPaliAmount: (amount: PaliAmountInput) => AtomicPaliAmount;
578
- declare const fromAtomicPaliAmount: (amount: bigint) => string;
579
- declare const formatPaliAmount: (amount: bigint, symbol?: string) => string;
748
+ declare const getGuardianNwParams: () => Promise<string>;
580
749
  /**
581
- * Fetch token name and decimals from RPC system properties
582
- * Results are cached for subsequent calls
583
- * @param rpc - RPC provider instance with system.properties method
584
- * @returns Promise<TokenProperties> with symbol and decimals
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.
585
755
  */
586
- declare function fetchTokenProperties(): Promise<TokenProperties>;
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
+ };
587
786
  /**
588
- * Get cached token properties without making an RPC call
589
- * @returns TokenProperties or null if not yet cached
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)
590
798
  */
591
- declare function getCachedTokenProperties(): TokenProperties | null;
799
+ declare const scanForBlockEvent: (api: ApiPromise, filter: BlockScanFilter, startBlock?: number, maxBlocks?: number) => Promise<BlockScanResult>;
592
800
  /**
593
- * Clear the token properties cache
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).
594
810
  */
595
- declare function clearTokenCache(): void;
811
+ declare function watchForSubmissionReceipt(requestId: string, timeoutMs?: number): Promise<SubmissionReceipt>;
596
812
  /**
597
- * Format balance using cached token properties
598
- * @param balance - The balance value to format
599
- * @returns Formatted balance string
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.
600
816
  */
601
- declare function formatBalanceWithTokenProperties(balance: string | number | bigint): Promise<string>;
602
- declare const tokenToBigint: (amount: PaliAmountInput) => AtomicPaliAmount;
817
+ declare function getAgreementCreatedRequestId(blockHeight: number, extrinsicIndex: number): Promise<string | null>;
818
+
819
+ declare const provider: WsProvider;
820
+
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
+ }>;
603
841
 
604
842
  interface DataContractParams {
605
843
  /** URL pointing to the data to store. */
606
844
  url: string;
607
845
  /** Guardian account IDs that participate in this contract. */
608
- guardians: {
609
- peerid: string;
610
- address: string;
611
- }[];
846
+ guardians: string[];
612
847
  /** Fee offered for the contract in PALI. Defaults to 0. */
613
848
  fees?: PaliAmountInput;
614
849
  /** Block number deadline. Defaults to 0 (no deadline). */
@@ -625,10 +860,10 @@ interface DataContractParams {
625
860
  * - No pre-check or post-check verifications
626
861
  * - Plain (unencrypted) result
627
862
  */
628
- declare function dataContract(params: DataContractParams): Promise<{
629
- blockNumber: any;
630
- index: any;
631
- hash: any;
863
+ declare function dataContract(params: DataContractParams, account: KeyringPair): Promise<{
864
+ blockNumber: number;
865
+ index: number;
866
+ hash: string;
632
867
  agreementId?: string;
633
868
  }>;
634
869
 
@@ -636,10 +871,7 @@ interface InferenceComputeParams {
636
871
  /** Raw input data — string will be UTF-8 encoded, Uint8Array used as-is. */
637
872
  input: Uint8Array | string;
638
873
  /** Guardian account IDs that participate in this compute. */
639
- guardians: {
640
- peerid: string;
641
- address: string;
642
- }[];
874
+ guardians: string[];
643
875
  /** Fee offered for the compute step in PALI. Defaults to 0. */
644
876
  fees?: PaliAmountInput;
645
877
  /** Block number deadline for the compute step. Defaults to 0 (no deadline). */
@@ -655,25 +887,35 @@ interface InferenceComputeParams {
655
887
  * - Cipher fields carry zero-value placeholders (unused in the trusted path).
656
888
  * - Result is returned in plain (no re-encryption).
657
889
  */
658
- declare function inferenceCompute(params: InferenceComputeParams): Promise<{
659
- blockNumber: any;
660
- index: any;
661
- hash: any;
890
+ declare function inferenceCompute(params: InferenceComputeParams, account: KeyringPair): Promise<{
891
+ blockNumber: number;
892
+ index: number;
893
+ hash: string;
662
894
  agreementId?: string;
663
895
  }>;
664
896
 
665
- declare function getGuardianParticipants(): Promise<any>;
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>;
666
911
 
667
912
  interface SimpleComputeParams {
668
913
  /** Guardian account IDs that participate in this compute. */
669
- guardians: {
670
- peerid: string;
671
- address: string;
672
- }[];
914
+ guardians: string[];
673
915
  /** Input reference block number from which to read the tx payload. */
674
- inputBlockNumber: number;
916
+ inputBlockNumber?: number;
675
917
  /** Input reference extrinsic index within the input block. */
676
- inputExtrinsicIndex: number;
918
+ inputExtrinsicIndex?: number;
677
919
  /** Program location as URL. */
678
920
  programUrl: string;
679
921
  /** Fee offered for the compute step in PALI. Defaults to 0. */
@@ -691,10 +933,10 @@ interface SimpleComputeParams {
691
933
  * - program fetched from URL
692
934
  * - no pre/post verification
693
935
  */
694
- declare function simpleCompute(params: SimpleComputeParams): Promise<{
695
- blockNumber: any;
696
- index: any;
697
- hash: any;
936
+ declare function simpleCompute(params: SimpleComputeParams, account: KeyringPair): Promise<{
937
+ blockNumber: number;
938
+ index: number;
939
+ hash: string;
698
940
  agreementId?: string;
699
941
  }>;
700
942
 
@@ -830,85 +1072,11 @@ declare const testCrypt: (kzg: string, agg_key: string) => {
830
1072
  */
831
1073
  declare function generateRandomBytes(length?: number): Uint8Array;
832
1074
 
833
- type Hex = `0x${string}`;
834
- /**
835
- * Mirrors the on-chain ComputePayload SCALE type (CheckCompute signed extension).
836
- * `agreement` is an array of 32-byte guardian peer-ID keys, obtained by
837
- * base58-decoding the peer ID and stripping the first 6 multiaddr prefix bytes.
838
- */
839
- interface ComputePayload {
840
- /** DA type: 0 = none, 1 = DA. */
841
- da_type: number;
842
- /** Guardian agreement keys. Each element is a 32-byte Uint8Array or number[]. */
843
- agreement?: Uint8Array[] | number[][];
844
- /** Verification mode. */
845
- verification: number;
846
- /** Compute mode. */
847
- compute: number;
848
- }
849
-
850
- interface OnChainRef {
1075
+ declare function writeMetadata(account: KeyringPair, name: string, description: string, ref: OnChainRef, price: bigint, dataType: number, l2Owner: string, groupId: string): Promise<{
851
1076
  blockNumber: number;
852
1077
  index: number;
853
- }
854
- interface SilentThresholdParams {
855
- /** Encoded threshold ciphertext bytes (from encodeCiphertext). */
856
- td_params: number[];
857
- /** Guardian group aggregate public key bytes. */
858
- pk_bytes: number[];
859
- /** KZG powers-of-tau bytes. */
860
- tau_params: number[];
861
- }
862
- type ThresholdAlgos = {
863
- SilentThreshold: SilentThresholdParams;
864
- };
865
- type SymmetricAlgos = {
866
- ChaCha20Poly1305: {
867
- nonce: number[];
868
- };
869
- } | {
870
- Aes256Gcm: {
871
- nonce: number[];
872
- };
873
- };
874
- interface CipherSuiteEncrypted {
875
- threshold: ThresholdAlgos;
876
- symmetric: SymmetricAlgos;
877
- }
878
- /** Mirrors the on-chain CipherSuite enum from spec.ts. */
879
- type CipherSuite = "Plaintext" | {
880
- Encrypted: CipherSuiteEncrypted;
881
- };
882
- interface SubmitTEDataResult {
883
- ref: OnChainRef;
884
- cipher: CipherSuite;
885
- }
886
- interface GuardianGroupInfo {
887
- groupId: string;
888
- guardians: any[];
889
- tauParams: string;
890
- aggKey: string;
891
- groupPk: string;
892
- }
893
- interface UploadOptions {
894
- name: string;
895
- description: string;
896
- price: PaliAmountInput;
897
- type: "model" | "dataset" | "agent";
898
- guardianGroupInfo: GuardianGroupInfo;
899
- ref?: string;
900
- filePath?: string;
901
- /** Options forwarded to signAndSend. Defaults to dormant DA payload (da_type=1, compute=0). */
902
- opts?: {
903
- compute: ComputePayload;
904
- };
905
- }
906
-
907
- declare function writeMetadata(account: any, name: string, description: string, ref: OnChainRef, price: bigint, dataType: number, l2Owner: string, groupId: string): Promise<{
908
- blockNumber: any;
909
- index: any;
910
- hash: any;
911
- tx_result: any;
1078
+ hash: `0x${string}`;
1079
+ tx_result: _polkadot_types_types.ISubmittableResult;
912
1080
  }>;
913
1081
  interface DataAgreementMetadata {
914
1082
  name: string;
@@ -922,10 +1090,7 @@ interface DataAgreementParams {
922
1090
  /** DA blob reference returned by submitTEData. */
923
1091
  ref: OnChainRef;
924
1092
  /** Guardian account IDs that participate in this agreement. */
925
- guardians: {
926
- peerid: string;
927
- address: string;
928
- }[];
1093
+ guardians: string[];
929
1094
  /** Fee for the agreement in PALI atomic units. */
930
1095
  fees: bigint;
931
1096
  /** If provided, populates ComputeInfo.metadata in the contract. */
@@ -944,28 +1109,28 @@ interface DataAgreementParams {
944
1109
  */
945
1110
  resultCipher?: CipherSuite;
946
1111
  }
947
- declare function registerDataAgreement(account: any, params: DataAgreementParams): Promise<{
948
- blockNumber: any;
949
- index: any;
950
- hash: any;
1112
+ declare function registerDataAgreement(account: KeyringPair, params: DataAgreementParams): Promise<{
1113
+ blockNumber: number;
1114
+ index: number;
1115
+ hash: string;
951
1116
  agreementId?: string;
952
1117
  }>;
953
1118
 
954
- declare function runAgent(account: any, agentRef: OnChainRef, nonce: Uint8Array, ciphertext: Uint8Array, tdParams: Uint8Array, pkBytes: Uint8Array, tauParams: Uint8Array, baseModel: OnChainRef, publicKey: Uint8Array, guardians: Uint8Array[], guardian?: Uint8Array, agreementId?: Uint8Array): Promise<{
955
- blockNumber: any;
956
- index: any;
957
- hash: any;
958
- tx_result: any;
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;
959
1124
  }>;
960
1125
 
961
- declare function submitData(account: any, data: string): Promise<void>;
962
- declare function submitTEData(account: any, data: string, chosenGuardians: any[], tau_params: string, agg_key: string, group_pk: string): Promise<OnChainRef>;
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>;
963
1128
  /**
964
1129
  * Identical to submitTEData but additionally returns the populated CipherSuite
965
1130
  * so callers can pass it directly to registerDataAgreement without
966
1131
  * re-deriving the cipher parameters.
967
1132
  */
968
- declare function submitTEDataWithCipher(account: any, data: string, chosenGuardians: any[], tau_params: string, agg_key: string, group_pk: string): Promise<SubmitTEDataResult>;
1133
+ declare function submitTEDataWithCipher(account: KeyringPair, data: string, chosenGuardians: string[], tau_params: string, agg_key: string, group_pk: string): Promise<SubmitTEDataResult>;
969
1134
 
970
1135
  declare function uploadData(options: UploadOptions): Promise<void>;
971
1136
  /**
@@ -978,27 +1143,48 @@ declare function uploadDataLegacy(options: Omit<UploadOptions, "opts">): Promise
978
1143
 
979
1144
  declare const getGuardianList: () => Promise<string[]>;
980
1145
 
981
- declare const createGuardianGroup: (account: any, selectedGuardians: any) => Promise<void>;
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>;
982
1162
 
983
- declare function joinGuardian(account: any, prefs: any): Promise<void>;
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>;
984
1170
 
985
- declare function addStake(account: any, amountBaseUnits: bigint): Promise<void>;
1171
+ declare function addStake(account: KeyringPair, amountBaseUnits: bigint): Promise<void>;
986
1172
 
987
- declare function joinIdleStaker(account: any): Promise<void>;
1173
+ declare function joinIdleStaker(account: KeyringPair): Promise<void>;
988
1174
 
989
- declare function newStake(account: any, amountBaseUnits: bigint, rewardDestination?: string): Promise<void>;
1175
+ declare function newStake(account: KeyringPair, amountBaseUnits: bigint, rewardDestination?: string): Promise<void>;
990
1176
 
991
- declare function payoutStake(account: any, eras: Array<number>, address?: string): Promise<void>;
1177
+ declare function payoutStake(account: KeyringPair, eras: Array<number>, address?: string): Promise<void>;
992
1178
 
993
- declare function reduceStake(account: any, amountBaseUnits: bigint): Promise<void>;
1179
+ declare function reduceStake(account: KeyringPair, amountBaseUnits: bigint): Promise<void>;
994
1180
 
995
- declare function removeStake(account: any): Promise<void>;
1181
+ declare function removeStake(account: KeyringPair): Promise<void>;
996
1182
 
997
- declare function withdrawStake(account: any): Promise<void>;
1183
+ declare function withdrawStake(account: KeyringPair): Promise<void>;
998
1184
 
999
- declare function fundAccount(account: any, amountBaseUnits: bigint, address?: string): Promise<void>;
1185
+ declare function fundAccount(account: KeyringPair, amountBaseUnits: bigint, address?: string): Promise<void>;
1000
1186
 
1001
- declare function transfer(account: any, amountBaseUnits: bigint, address: string): Promise<void>;
1187
+ declare function transfer(account: KeyringPair, amountBaseUnits: bigint, address: string): Promise<void>;
1002
1188
 
1003
1189
  /**
1004
1190
  * Converts a hex string into a Uint8Array.
@@ -1066,7 +1252,7 @@ declare const decodeField: (field: string, expectedLength?: number) => Uint8Arra
1066
1252
  */
1067
1253
  declare const debugLog: (message?: any, ...optionalParams: any[]) => void;
1068
1254
 
1069
- declare function joinValidator(account: any, commission: number): Promise<void>;
1255
+ declare function joinValidator(account: KeyringPair, commission: number): Promise<void>;
1070
1256
 
1071
1257
  declare let PALLIORA_WS: string;
1072
1258
  declare let PALLIORA_RPC_URL: string;
@@ -1079,9 +1265,12 @@ declare function configure(opts: {
1079
1265
  txWaitFinalization?: boolean;
1080
1266
  }): void;
1081
1267
 
1082
- declare function setIdentity(account: any, { display }: any): Promise<void>;
1268
+ interface IdentityFields {
1269
+ display?: string;
1270
+ }
1271
+ declare function setIdentity(account: KeyringPair, { display }: IdentityFields): Promise<void>;
1083
1272
 
1084
- declare function rotateAndSetKeys(account: any): Promise<void>;
1085
- declare function setWorker(account: any): Promise<void>;
1273
+ declare function rotateAndSetKeys(account: KeyringPair): Promise<void>;
1274
+ declare function setWorker(account: KeyringPair): Promise<void>;
1086
1275
 
1087
- export { API_EXTENSIONS, API_RPC, API_TYPES, AccountSourceType, type AtomicPaliAmount, type CipherSuite, type CipherSuiteEncrypted, CryptoType, DEBUG, DEFAULT_COMPUTE_PAYLOAD, DEFAULT_EMPTY_PAYLOAD, type DataAgreementMetadata, type DataAgreementParams, type DataContractParams, FileFromMetadataRef, type GuardianGroupInfo, type InferenceComputeParams, MCryptFs, MCryptFsReader, MCryptFsWriter, type OnChainRef, PALI_DECIMALS, PALI_SYMBOL, PALLIORA_RPC_URL, PALLIORA_WS, type PaliAmountInput, type SilentThresholdParams, type SimpleComputeParams, type SubmitTEDataResult, type SymmetricAlgos, TX_WAIT_FINALIZATION, type ThresholdAlgos, type UploadOptions, addStake, base64ToUint8Array, clearTokenCache, configure, createAccount, createAgreement, createGuardianGroup, createSimpleAgreement, dataContract, debugLog, decodeAggregateKey, decodeField, decodePowersOfTau, decrypt, encrypt as ecncryptTest, encodeCiphertext, encrypt$1 as encrypt, fetchTokenProperties, formatBalanceWithTokenProperties, formatPaliAmount, fromAtomicPaliAmount, fundAccount, gen_shared_key, gen_stretched_key, generateRandomBytes, getApi, getCachedTokenProperties, getEncKeyring, getFileMetadataCall, getGuardianAddress, getGuardianList, getGuardianNwParams, getGuardianParticipants, getKeyring, hexToUint8Array, inferenceCompute, joinGuardian, joinIdleStaker, joinValidator, newStake, pairFromPrivateKeyHex, payoutStake, provider, reduceStake, registerDataAgreement, removeStake, rotateAndSetKeys, runAgent, setIdentity, setWorker, signAndSend, simpleCompute, submitData, submitTEData, submitTEDataWithCipher, testCrypt, toAtomicPaliAmount, tokenToBigint, transfer, uint8ArrayToBase64, uploadData, uploadDataLegacy, withdrawStake, writeMetadata };
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 };