@palliora.org/chainsdk 0.3.1 → 0.3.3

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.cts CHANGED
@@ -1,5 +1,6 @@
1
1
  import * as _polkadot_util_crypto_types from '@polkadot/util-crypto/types';
2
2
  import { KeyringPair } from '@polkadot/keyring/types';
3
+ export { KeyringPair } from '@polkadot/keyring/types';
3
4
  import * as _polkadot_types_types from '@polkadot/types/types';
4
5
  import { ISubmittableResult } from '@polkadot/types/types';
5
6
  import { ApiPromise, Keyring, WsProvider } from '@polkadot/api';
@@ -15,6 +16,7 @@ import * as utilCrypto from '@polkadot/util-crypto';
15
16
  export { utilCrypto };
16
17
  import * as wasmCrypto from '@polkadot/wasm-crypto';
17
18
  export { wasmCrypto };
19
+ export { Keyring } from '@polkadot/keyring';
18
20
 
19
21
  declare enum CryptoType {
20
22
  SR25519 = "sr25519",
@@ -36,7 +38,7 @@ declare enum AccountSourceType {
36
38
  * @param cryptoType - The crypto type: 'sr25519' | 'ed25519' | 'ecdsa' (default: 'sr25519').
37
39
  * @returns The keypair object.
38
40
  */
39
- declare function createAccount(input: string, type: AccountSourceType, name?: string, cryptoType?: CryptoType): Promise<KeyringPair>;
41
+ declare function createAccount(input: string, type: AccountSourceType, name?: string, cryptoType?: CryptoType, signedMsg?: string): Promise<KeyringPair>;
40
42
  declare function pairFromPrivateKeyHex(privateKeyHex: string, cryptoType: CryptoType): _polkadot_util_crypto_types.Keypair;
41
43
 
42
44
  declare const API_RPC: {
@@ -119,7 +121,7 @@ declare const API_TYPES: {
119
121
  };
120
122
  GuardianNwParams: {
121
123
  kzg: string;
122
- agg_key: string;
124
+ aggKey: string;
123
125
  };
124
126
  AppId: string;
125
127
  DataLookupItem: {
@@ -170,9 +172,9 @@ declare const API_TYPES: {
170
172
  verifier: string;
171
173
  };
172
174
  SilentThresholdParams: {
173
- td_params: string;
174
- pk_bytes: string;
175
- tau_params: string;
175
+ tdParams: string;
176
+ pkBytes: string;
177
+ tauParams: string;
176
178
  };
177
179
  ThresholdParams: {
178
180
  _enum: {
@@ -198,16 +200,16 @@ declare const API_TYPES: {
198
200
  };
199
201
  };
200
202
  Secp256k1Params: {
201
- recipient_public_key: string;
202
- ephemeral_public_key: string;
203
+ recipientPublicKey: string;
204
+ ephemeralPublicKey: string;
203
205
  compressed: string;
204
206
  kdf: string;
205
207
  salt: string;
206
208
  info: string;
207
209
  };
208
210
  Ed25519Params: {
209
- recipient_public_key: string;
210
- ephemeral_public_key: string;
211
+ recipientPublicKey: string;
212
+ ephemeralPublicKey: string;
211
213
  kdf: string;
212
214
  salt: string;
213
215
  info: string;
@@ -219,12 +221,12 @@ declare const API_TYPES: {
219
221
  };
220
222
  };
221
223
  ThresholdHybridParams: {
222
- threshold_params: string;
223
- symmetric_params: string;
224
+ thresholdParams: string;
225
+ symmetricParams: string;
224
226
  };
225
227
  AsymmetricHybridParams: {
226
- asymmetric_params: string;
227
- symmetric_params: string;
228
+ asymmetricParams: string;
229
+ symmetricParams: string;
228
230
  };
229
231
  CipherSuite: {
230
232
  _enum: {
@@ -251,8 +253,11 @@ declare const API_TYPES: {
251
253
  data: string;
252
254
  };
253
255
  DAInputChainTransaction: {
254
- block_number: string;
255
- extrinsic_index: string;
256
+ blockNumber: string;
257
+ extrinsicIndex: string;
258
+ };
259
+ DAInputContractId: {
260
+ id: string;
256
261
  };
257
262
  DAInputIpfs: {
258
263
  cid: string;
@@ -268,6 +273,7 @@ declare const API_TYPES: {
268
273
  Null: string;
269
274
  Inline: string;
270
275
  ChainTransaction: string;
276
+ ContractId: string;
271
277
  Ipfs: string;
272
278
  Url: string;
273
279
  NativeExecute: string;
@@ -278,6 +284,7 @@ declare const API_TYPES: {
278
284
  _enum: {
279
285
  Dormant: string;
280
286
  Active: string;
287
+ Subscription: string;
281
288
  };
282
289
  };
283
290
  StoreType: {
@@ -291,28 +298,29 @@ declare const API_TYPES: {
291
298
  ComputeMetadata: {
292
299
  name: string;
293
300
  description: string;
294
- store_type: string;
295
- group_id: string;
301
+ storeType: string;
302
+ groupId: string;
296
303
  };
297
304
  ComputeInfo: {
298
305
  cipher: string;
299
- computer_indices: string;
306
+ computerIndices: string;
300
307
  fees: string;
308
+ computeRate: string;
301
309
  deadline: string;
302
310
  confidentiality: string;
303
- fee_function: string;
304
- program_env: string;
311
+ feeFunction: string;
312
+ programEnv: string;
305
313
  input: string;
306
314
  program: string;
307
315
  metadata: string;
308
316
  };
309
317
  Contract: {
310
- contract_type: string;
318
+ contractType: string;
311
319
  guardians: string;
312
- pre_check: string;
320
+ preCheck: string;
313
321
  compute: string;
314
- post_check: string;
315
- result_cipher: string;
322
+ postCheck: string;
323
+ resultCipher: string;
316
324
  };
317
325
  AgreementInfo: {
318
326
  status: string;
@@ -320,7 +328,7 @@ declare const API_TYPES: {
320
328
  index: string;
321
329
  };
322
330
  ComputePayload: {
323
- da_type: string;
331
+ daType: string;
324
332
  agreement: string;
325
333
  verification: string;
326
334
  compute: string;
@@ -397,17 +405,53 @@ declare const API_TYPES: {
397
405
  GProof: string;
398
406
  GRow: string;
399
407
  GDataProof: string;
408
+ AgreementStatus: {
409
+ _enum: string[];
410
+ };
411
+ AcceptedSubStatus: {
412
+ _enum: string[];
413
+ };
414
+ RejectedSubStatus: {
415
+ _enum: string[];
416
+ };
417
+ SettlementReason: {
418
+ _enum: string[];
419
+ };
420
+ ExecutionOutcome: {
421
+ _enum: string[];
422
+ };
423
+ ContractInfo: {
424
+ status: string;
425
+ owner: string;
426
+ originBlock: string;
427
+ invocationBlock: string;
428
+ index: string;
429
+ usagePrice: string;
430
+ contractType: string;
431
+ };
432
+ SettlementInfo: {
433
+ computeRate: string;
434
+ inputContractId: string;
435
+ guardians: string;
436
+ };
437
+ AppKeyInfo: {
438
+ owner: string;
439
+ id: string;
440
+ };
441
+ DataType: {
442
+ _enum: string[];
443
+ };
400
444
  };
401
445
  declare const DEFAULT_COMPUTE_PAYLOAD: {
402
446
  compute: {
403
- da_type: number;
447
+ daType: number;
404
448
  verification: number;
405
449
  compute: number;
406
450
  };
407
451
  };
408
452
  declare const DEFAULT_EMPTY_PAYLOAD: {
409
453
  compute: {
410
- da_type: number;
454
+ daType: number;
411
455
  verification: number;
412
456
  compute: number;
413
457
  agreement: never[];
@@ -471,7 +515,7 @@ type Hex = `0x${string}`;
471
515
  */
472
516
  interface ComputePayload {
473
517
  /** DA type: 0 = none, 1 = DA. */
474
- da_type: number;
518
+ daType: number;
475
519
  /** Guardian agreement keys. Each element is a 32-byte Uint8Array or number[]. */
476
520
  agreement?: Uint8Array[] | number[][];
477
521
  /** Verification mode. */
@@ -486,11 +530,11 @@ interface OnChainRef {
486
530
  }
487
531
  interface SilentThresholdParams {
488
532
  /** Encoded threshold ciphertext bytes (from encodeCiphertext). */
489
- td_params: number[];
533
+ tdParams: number[];
490
534
  /** Guardian group aggregate public key bytes. */
491
- pk_bytes: number[];
535
+ pkBytes: number[];
492
536
  /** KZG powers-of-tau bytes. */
493
- tau_params: number[];
537
+ tauParams: number[];
494
538
  }
495
539
  type ThresholdParams = {
496
540
  SilentThreshold: SilentThresholdParams;
@@ -506,16 +550,16 @@ type SymmetricParams = {
506
550
  };
507
551
  type KdfParams = "HkdfSha256" | "HkdfSha512";
508
552
  interface Secp256k1Params {
509
- recipient_public_key: number[];
510
- ephemeral_public_key?: number[] | null;
553
+ recipientPublicKey: number[];
554
+ ephemeralPublicKey?: number[] | null;
511
555
  compressed: boolean;
512
556
  kdf: KdfParams;
513
557
  salt?: number[] | null;
514
558
  info?: number[] | null;
515
559
  }
516
560
  interface Ed25519Params {
517
- recipient_public_key: number[];
518
- ephemeral_public_key?: number[] | null;
561
+ recipientPublicKey: number[];
562
+ ephemeralPublicKey?: number[] | null;
519
563
  kdf: KdfParams;
520
564
  salt?: number[] | null;
521
565
  info?: number[] | null;
@@ -526,12 +570,12 @@ type AsymmetricParams = {
526
570
  Ed25519: Ed25519Params;
527
571
  };
528
572
  interface ThresholdHybridParams {
529
- threshold_params: ThresholdParams;
530
- symmetric_params: SymmetricParams;
573
+ thresholdParams: ThresholdParams;
574
+ symmetricParams: SymmetricParams;
531
575
  }
532
576
  interface AsymmetricHybridParams {
533
- asymmetric_params: AsymmetricParams;
534
- symmetric_params: SymmetricParams;
577
+ asymmetricParams: AsymmetricParams;
578
+ symmetricParams: SymmetricParams;
535
579
  }
536
580
  /** Mirrors the on-chain CipherSuite enum from spec.ts. */
537
581
  type CipherSuite = "Plaintext" | {
@@ -559,7 +603,7 @@ interface UploadOptions {
559
603
  guardianGroupInfo: GuardianGroupInfo;
560
604
  ref?: string;
561
605
  filePath?: string;
562
- /** Options forwarded to signAndSend. Defaults to dormant DA payload (da_type=1, compute=0). */
606
+ /** Options forwarded to signAndSend. Defaults to dormant DA payload (daType=1, compute=0). */
563
607
  opts?: {
564
608
  compute: ComputePayload;
565
609
  };
@@ -724,6 +768,13 @@ declare function getKeyring(): Promise<Keyring>;
724
768
  */
725
769
  declare function getEncKeyring(): Promise<Keyring>;
726
770
 
771
+ /** Fee terms for a compute step: an absolute amount plus an optional dynamic compute rate. */
772
+ interface Fee {
773
+ /** Absolute fee offered for the compute step, in PALI. Defaults to 0. */
774
+ amount?: PaliAmountInput;
775
+ /** Compute rate used for dynamic fee calculation, in PALI. Defaults to 0. */
776
+ computeRate?: PaliAmountInput;
777
+ }
727
778
  /** On-chain proof that a result extrinsic was included in a block. */
728
779
  interface SubmissionReceipt {
729
780
  /** Hash of the result extrinsic (hex-encoded, "0x..."). */
@@ -816,15 +867,25 @@ declare function watchForSubmissionReceipt(requestId: string, timeoutMs?: number
816
867
  */
817
868
  declare function getAgreementCreatedRequestId(blockHeight: number, extrinsicIndex: number): Promise<string | null>;
818
869
 
870
+ /**
871
+ * Converts a {@link Fee} into the on-chain `fees` / `computeRate` pair.
872
+ * `computeRate` only has meaning for `Active` contracts (it drives dynamic
873
+ * fee calculation during `compute.result`); omit `computeRate` for `Dormant`
874
+ * contracts.
875
+ */
876
+ declare function buildFee(fee?: Fee): {
877
+ fees: bigint;
878
+ computeRate: bigint;
879
+ };
819
880
  interface ComputeContract {
820
- contract_type: "Active" | "Dormant";
881
+ contractType: "Active" | "Dormant";
821
882
  guardians: GuardianAddress[];
822
- pre_check?: unknown;
883
+ preCheck?: unknown;
823
884
  compute: Record<string, unknown>;
824
- post_check?: unknown;
825
- result_cipher: unknown;
885
+ postCheck?: unknown;
886
+ resultCipher: unknown;
826
887
  }
827
- declare function createAgreement(contract: ComputeContract, account: KeyringPair): Promise<{
888
+ declare function createAgreement(contract: ComputeContract, account: KeyringPair, oracle_quore_id?: string | undefined): Promise<{
828
889
  blockNumber: number;
829
890
  index: number;
830
891
  hash: string;
@@ -842,8 +903,12 @@ interface DataContractParams {
842
903
  url: string;
843
904
  /** Guardian account IDs that participate in this contract. */
844
905
  guardians: string[];
845
- /** Fee offered for the contract in PALI. Defaults to 0. */
846
- fees?: PaliAmountInput;
906
+ /**
907
+ * Absolute fee offered for the contract. Defaults to 0.
908
+ * `computeRate` is omitted: this is a `Dormant` contract and the
909
+ * compute rate only applies to `Active` contracts.
910
+ */
911
+ fee: Fee;
847
912
  /** Block number deadline. Defaults to 0 (no deadline). */
848
913
  deadline?: number;
849
914
  /** Trusted guardian index in the guardians list. Defaults to 0. */
@@ -870,8 +935,8 @@ interface InferenceComputeParams {
870
935
  input: Uint8Array | string;
871
936
  /** Guardian account IDs that participate in this compute. */
872
937
  guardians: string[];
873
- /** Fee offered for the compute step in PALI. Defaults to 0. */
874
- fees?: PaliAmountInput;
938
+ /** Fee offered for the compute step. Defaults to 0 amount and 0 compute rate. */
939
+ fee: Fee;
875
940
  /** Block number deadline for the compute step. Defaults to 0 (no deadline). */
876
941
  deadline?: number;
877
942
  }
@@ -916,8 +981,8 @@ interface SimpleComputeParams {
916
981
  inputExtrinsicIndex?: number;
917
982
  /** Program location as URL. */
918
983
  programUrl: string;
919
- /** Fee offered for the compute step in PALI. Defaults to 0. */
920
- fees?: PaliAmountInput;
984
+ /** Fee offered for the compute step. Defaults to 0 amount and 0 compute rate. */
985
+ fee?: Fee;
921
986
  /** Block number deadline for the compute step. Defaults to 0 (no deadline). */
922
987
  deadline?: number;
923
988
  /** Trusted guardian index in the guardians list. Defaults to 0. */
@@ -1089,8 +1154,11 @@ interface DataAgreementParams {
1089
1154
  ref: OnChainRef;
1090
1155
  /** Guardian account IDs that participate in this agreement. */
1091
1156
  guardians: string[];
1092
- /** Fee for the agreement in PALI atomic units. */
1093
- fees: bigint;
1157
+ /**
1158
+ * Absolute fee for the agreement. `computeRate` is omitted: this is a
1159
+ * `Dormant` contract and the compute rate only applies to `Active` contracts.
1160
+ */
1161
+ fee: Pick<Fee, "amount">;
1094
1162
  /** If provided, populates ComputeInfo.metadata in the contract. */
1095
1163
  metadata?: DataAgreementMetadata;
1096
1164
  /** Block number deadline. Defaults to 0 (no deadline). */
@@ -1272,4 +1340,4 @@ declare function setIdentity(account: KeyringPair, { display }: IdentityFields):
1272
1340
  declare function rotateAndSetKeys(account: KeyringPair): Promise<void>;
1273
1341
  declare function setWorker(account: KeyringPair): Promise<void>;
1274
1342
 
1275
- 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 };
1343
+ 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, type Fee, 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, buildFee, 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 };