@palliora.org/chainsdk 0.3.3 → 0.4.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.cts CHANGED
@@ -119,6 +119,13 @@ declare const API_TYPES: {
119
119
  active: string;
120
120
  maximum: string;
121
121
  };
122
+ CurrencyId: {
123
+ _enum: {
124
+ Native: string;
125
+ USDC: string;
126
+ ForeignAsset: string;
127
+ };
128
+ };
122
129
  GuardianNwParams: {
123
130
  kzg: string;
124
131
  aggKey: string;
@@ -321,6 +328,7 @@ declare const API_TYPES: {
321
328
  compute: string;
322
329
  postCheck: string;
323
330
  resultCipher: string;
331
+ currencyId: string;
324
332
  };
325
333
  AgreementInfo: {
326
334
  status: string;
@@ -470,6 +478,13 @@ declare const API_EXTENSIONS: {
470
478
  };
471
479
  payload: {};
472
480
  };
481
+ ChargeCurrencyTransactionPayment: {
482
+ extrinsic: {
483
+ tip: string;
484
+ currencyId: string;
485
+ };
486
+ payload: {};
487
+ };
473
488
  };
474
489
 
475
490
  declare const PALI_SYMBOL = "PALI";
@@ -768,6 +783,10 @@ declare function getKeyring(): Promise<Keyring>;
768
783
  */
769
784
  declare function getEncKeyring(): Promise<Keyring>;
770
785
 
786
+ /** Identifies the currency used for fee payment / contract settlement. Mirrors runtime `primitives::CurrencyId`. */
787
+ type CurrencyId = "Native" | "USDC" | {
788
+ ForeignAsset: number;
789
+ };
771
790
  /** Fee terms for a compute step: an absolute amount plus an optional dynamic compute rate. */
772
791
  interface Fee {
773
792
  /** Absolute fee offered for the compute step, in PALI. Defaults to 0. */
@@ -884,6 +903,8 @@ interface ComputeContract {
884
903
  compute: Record<string, unknown>;
885
904
  postCheck?: unknown;
886
905
  resultCipher: unknown;
906
+ /** Currency the deposit is reserved in and settlement is paid out in. Defaults to "Native". */
907
+ currencyId?: CurrencyId;
887
908
  }
888
909
  declare function createAgreement(contract: ComputeContract, account: KeyringPair, oracle_quore_id?: string | undefined): Promise<{
889
910
  blockNumber: number;
@@ -930,6 +951,84 @@ declare function dataContract(params: DataContractParams, account: KeyringPair):
930
951
  agreementId?: string;
931
952
  }>;
932
953
 
954
+ interface EncryptedInferenceSubscriptionParams {
955
+ /** Guardian account addresses that participate in this compute. */
956
+ guardians: string[];
957
+ /** Fee offered for the compute step. Defaults to 0. */
958
+ fee?: Fee;
959
+ /** Block number deadline. Defaults to 0 (no deadline). */
960
+ deadline?: number;
961
+ }
962
+ interface EncryptedInferenceSubscriptionInvocationParams {
963
+ /** Hex-encoded agreement ID returned by encryptedInferenceSubscription. */
964
+ agreementId: string;
965
+ /** Input payload to encrypt and submit. String is UTF-8 encoded. */
966
+ input: Uint8Array | string;
967
+ /** Guardian addresses to route the compute request to. */
968
+ guardians: string[];
969
+ /** Guardian group cryptographic parameters for threshold encryption. */
970
+ guardianInfo: GuardianGroupInfo;
971
+ }
972
+ interface EncryptedInferenceComputeParams {
973
+ /** Input payload to encrypt and submit. String is UTF-8 encoded. */
974
+ input: Uint8Array | string;
975
+ /** Guardian account addresses that participate in this compute. */
976
+ guardians: string[];
977
+ /** Guardian group cryptographic parameters for threshold encryption. */
978
+ guardianInfo: GuardianGroupInfo;
979
+ /** Fee offered for the compute step. Defaults to 0. */
980
+ fee?: Fee;
981
+ /** Block number deadline. Defaults to 0 (no deadline). */
982
+ deadline?: number;
983
+ }
984
+ /**
985
+ * Creates a Dormant agreement that registers encrypted inference compute terms.
986
+ * The agreement ID returned here is passed to encryptedInferenceSubscriptionInvocation
987
+ * for each subsequent encrypted inference call.
988
+ */
989
+ declare function encryptedInferenceSubscription(params: EncryptedInferenceSubscriptionParams, account: KeyringPair): Promise<{
990
+ blockNumber: number;
991
+ index: number;
992
+ hash: string;
993
+ agreementId?: string;
994
+ }>;
995
+ /**
996
+ * Invokes an existing encrypted inference subscription agreement with a
997
+ * threshold-encrypted input payload. The result is encrypted back to encAccount.
998
+ *
999
+ * @param params - Agreement ID, input payload, guardians, and guardian group crypto params.
1000
+ * @param encAccount - Ed25519 keypair whose public key is used to receive the encrypted result.
1001
+ * @param account - Keypair used to sign and submit the transaction.
1002
+ */
1003
+ declare function encryptedInferenceSubscriptionInvocation(params: EncryptedInferenceSubscriptionInvocationParams, encAccount: KeyringPair, account: KeyringPair): Promise<{
1004
+ blockNumber: number;
1005
+ index: number;
1006
+ hash: `0x${string}`;
1007
+ tx_result: _polkadot_types_types.ISubmittableResult;
1008
+ }>;
1009
+ /**
1010
+ * Convenience wrapper: creates an encrypted inference subscription then
1011
+ * immediately invokes it with the given input. Returns both receipts.
1012
+ *
1013
+ * @param params - Input payload, guardians, guardian group crypto params, and fee.
1014
+ * @param encAccount - Ed25519 keypair whose public key is used to receive the encrypted result.
1015
+ * @param account - Keypair used to sign and submit both transactions.
1016
+ */
1017
+ declare function encryptedInferenceCompute(params: EncryptedInferenceComputeParams, encAccount: KeyringPair, account: KeyringPair): Promise<{
1018
+ subscription: {
1019
+ blockNumber: number;
1020
+ index: number;
1021
+ hash: string;
1022
+ agreementId?: string;
1023
+ };
1024
+ invocation: {
1025
+ blockNumber: number;
1026
+ index: number;
1027
+ hash: `0x${string}`;
1028
+ tx_result: _polkadot_types_types.ISubmittableResult;
1029
+ };
1030
+ }>;
1031
+
933
1032
  interface InferenceComputeParams {
934
1033
  /** Raw input data — string will be UTF-8 encoded, Uint8Array used as-is. */
935
1034
  input: Uint8Array | string;
@@ -1340,4 +1439,4 @@ declare function setIdentity(account: KeyringPair, { display }: IdentityFields):
1340
1439
  declare function rotateAndSetKeys(account: KeyringPair): Promise<void>;
1341
1440
  declare function setWorker(account: KeyringPair): Promise<void>;
1342
1441
 
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 };
1442
+ export { API_EXTENSIONS, API_RPC, API_TYPES, AccountSourceType, type AsymmetricHybridParams, type AsymmetricParams, type AtomicPaliAmount, type BlockScanFilter, type BlockScanResult, type CipherSuite, type ComputeContract, CryptoType, type CurrencyId, DEBUG, DEFAULT_COMPUTE_PAYLOAD, DEFAULT_EMPTY_PAYLOAD, type DataAgreementMetadata, type DataAgreementParams, type DataContractParams, type Ed25519Params, type EncryptedInferenceComputeParams, type EncryptedInferenceSubscriptionInvocationParams, type EncryptedInferenceSubscriptionParams, 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, encryptedInferenceCompute, encryptedInferenceSubscription, encryptedInferenceSubscriptionInvocation, 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 };
package/dist/index.d.ts CHANGED
@@ -119,6 +119,13 @@ declare const API_TYPES: {
119
119
  active: string;
120
120
  maximum: string;
121
121
  };
122
+ CurrencyId: {
123
+ _enum: {
124
+ Native: string;
125
+ USDC: string;
126
+ ForeignAsset: string;
127
+ };
128
+ };
122
129
  GuardianNwParams: {
123
130
  kzg: string;
124
131
  aggKey: string;
@@ -321,6 +328,7 @@ declare const API_TYPES: {
321
328
  compute: string;
322
329
  postCheck: string;
323
330
  resultCipher: string;
331
+ currencyId: string;
324
332
  };
325
333
  AgreementInfo: {
326
334
  status: string;
@@ -470,6 +478,13 @@ declare const API_EXTENSIONS: {
470
478
  };
471
479
  payload: {};
472
480
  };
481
+ ChargeCurrencyTransactionPayment: {
482
+ extrinsic: {
483
+ tip: string;
484
+ currencyId: string;
485
+ };
486
+ payload: {};
487
+ };
473
488
  };
474
489
 
475
490
  declare const PALI_SYMBOL = "PALI";
@@ -768,6 +783,10 @@ declare function getKeyring(): Promise<Keyring>;
768
783
  */
769
784
  declare function getEncKeyring(): Promise<Keyring>;
770
785
 
786
+ /** Identifies the currency used for fee payment / contract settlement. Mirrors runtime `primitives::CurrencyId`. */
787
+ type CurrencyId = "Native" | "USDC" | {
788
+ ForeignAsset: number;
789
+ };
771
790
  /** Fee terms for a compute step: an absolute amount plus an optional dynamic compute rate. */
772
791
  interface Fee {
773
792
  /** Absolute fee offered for the compute step, in PALI. Defaults to 0. */
@@ -884,6 +903,8 @@ interface ComputeContract {
884
903
  compute: Record<string, unknown>;
885
904
  postCheck?: unknown;
886
905
  resultCipher: unknown;
906
+ /** Currency the deposit is reserved in and settlement is paid out in. Defaults to "Native". */
907
+ currencyId?: CurrencyId;
887
908
  }
888
909
  declare function createAgreement(contract: ComputeContract, account: KeyringPair, oracle_quore_id?: string | undefined): Promise<{
889
910
  blockNumber: number;
@@ -930,6 +951,84 @@ declare function dataContract(params: DataContractParams, account: KeyringPair):
930
951
  agreementId?: string;
931
952
  }>;
932
953
 
954
+ interface EncryptedInferenceSubscriptionParams {
955
+ /** Guardian account addresses that participate in this compute. */
956
+ guardians: string[];
957
+ /** Fee offered for the compute step. Defaults to 0. */
958
+ fee?: Fee;
959
+ /** Block number deadline. Defaults to 0 (no deadline). */
960
+ deadline?: number;
961
+ }
962
+ interface EncryptedInferenceSubscriptionInvocationParams {
963
+ /** Hex-encoded agreement ID returned by encryptedInferenceSubscription. */
964
+ agreementId: string;
965
+ /** Input payload to encrypt and submit. String is UTF-8 encoded. */
966
+ input: Uint8Array | string;
967
+ /** Guardian addresses to route the compute request to. */
968
+ guardians: string[];
969
+ /** Guardian group cryptographic parameters for threshold encryption. */
970
+ guardianInfo: GuardianGroupInfo;
971
+ }
972
+ interface EncryptedInferenceComputeParams {
973
+ /** Input payload to encrypt and submit. String is UTF-8 encoded. */
974
+ input: Uint8Array | string;
975
+ /** Guardian account addresses that participate in this compute. */
976
+ guardians: string[];
977
+ /** Guardian group cryptographic parameters for threshold encryption. */
978
+ guardianInfo: GuardianGroupInfo;
979
+ /** Fee offered for the compute step. Defaults to 0. */
980
+ fee?: Fee;
981
+ /** Block number deadline. Defaults to 0 (no deadline). */
982
+ deadline?: number;
983
+ }
984
+ /**
985
+ * Creates a Dormant agreement that registers encrypted inference compute terms.
986
+ * The agreement ID returned here is passed to encryptedInferenceSubscriptionInvocation
987
+ * for each subsequent encrypted inference call.
988
+ */
989
+ declare function encryptedInferenceSubscription(params: EncryptedInferenceSubscriptionParams, account: KeyringPair): Promise<{
990
+ blockNumber: number;
991
+ index: number;
992
+ hash: string;
993
+ agreementId?: string;
994
+ }>;
995
+ /**
996
+ * Invokes an existing encrypted inference subscription agreement with a
997
+ * threshold-encrypted input payload. The result is encrypted back to encAccount.
998
+ *
999
+ * @param params - Agreement ID, input payload, guardians, and guardian group crypto params.
1000
+ * @param encAccount - Ed25519 keypair whose public key is used to receive the encrypted result.
1001
+ * @param account - Keypair used to sign and submit the transaction.
1002
+ */
1003
+ declare function encryptedInferenceSubscriptionInvocation(params: EncryptedInferenceSubscriptionInvocationParams, encAccount: KeyringPair, account: KeyringPair): Promise<{
1004
+ blockNumber: number;
1005
+ index: number;
1006
+ hash: `0x${string}`;
1007
+ tx_result: _polkadot_types_types.ISubmittableResult;
1008
+ }>;
1009
+ /**
1010
+ * Convenience wrapper: creates an encrypted inference subscription then
1011
+ * immediately invokes it with the given input. Returns both receipts.
1012
+ *
1013
+ * @param params - Input payload, guardians, guardian group crypto params, and fee.
1014
+ * @param encAccount - Ed25519 keypair whose public key is used to receive the encrypted result.
1015
+ * @param account - Keypair used to sign and submit both transactions.
1016
+ */
1017
+ declare function encryptedInferenceCompute(params: EncryptedInferenceComputeParams, encAccount: KeyringPair, account: KeyringPair): Promise<{
1018
+ subscription: {
1019
+ blockNumber: number;
1020
+ index: number;
1021
+ hash: string;
1022
+ agreementId?: string;
1023
+ };
1024
+ invocation: {
1025
+ blockNumber: number;
1026
+ index: number;
1027
+ hash: `0x${string}`;
1028
+ tx_result: _polkadot_types_types.ISubmittableResult;
1029
+ };
1030
+ }>;
1031
+
933
1032
  interface InferenceComputeParams {
934
1033
  /** Raw input data — string will be UTF-8 encoded, Uint8Array used as-is. */
935
1034
  input: Uint8Array | string;
@@ -1340,4 +1439,4 @@ declare function setIdentity(account: KeyringPair, { display }: IdentityFields):
1340
1439
  declare function rotateAndSetKeys(account: KeyringPair): Promise<void>;
1341
1440
  declare function setWorker(account: KeyringPair): Promise<void>;
1342
1441
 
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 };
1442
+ export { API_EXTENSIONS, API_RPC, API_TYPES, AccountSourceType, type AsymmetricHybridParams, type AsymmetricParams, type AtomicPaliAmount, type BlockScanFilter, type BlockScanResult, type CipherSuite, type ComputeContract, CryptoType, type CurrencyId, DEBUG, DEFAULT_COMPUTE_PAYLOAD, DEFAULT_EMPTY_PAYLOAD, type DataAgreementMetadata, type DataAgreementParams, type DataContractParams, type Ed25519Params, type EncryptedInferenceComputeParams, type EncryptedInferenceSubscriptionInvocationParams, type EncryptedInferenceSubscriptionParams, 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, encryptedInferenceCompute, encryptedInferenceSubscription, encryptedInferenceSubscriptionInvocation, 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 };
package/dist/index.js CHANGED
@@ -201,6 +201,13 @@ var API_TYPES = {
201
201
  active: "u32",
202
202
  maximum: "u32"
203
203
  },
204
+ CurrencyId: {
205
+ _enum: {
206
+ Native: "Null",
207
+ USDC: "Null",
208
+ ForeignAsset: "u32"
209
+ }
210
+ },
204
211
  GuardianNwParams: {
205
212
  kzg: "Vec<u8>",
206
213
  aggKey: "Vec<u8>"
@@ -402,7 +409,8 @@ var API_TYPES = {
402
409
  preCheck: "Option<ComputeInfo>",
403
410
  compute: "ComputeInfo",
404
411
  postCheck: "Option<ComputeInfo>",
405
- resultCipher: "CipherSuite"
412
+ resultCipher: "CipherSuite",
413
+ currencyId: "CurrencyId"
406
414
  },
407
415
  AgreementInfo: {
408
416
  status: "AgreementStatus",
@@ -538,6 +546,18 @@ var API_EXTENSIONS = {
538
546
  compute: "ComputePayload"
539
547
  },
540
548
  payload: {}
549
+ },
550
+ // Replaces pallet_transaction_payment::ChargeTransactionPayment. Since this
551
+ // identifier isn't one @polkadot/api knows natively, this definition entirely
552
+ // replaces (not merges with) the built-in one, so `tip` must be re-declared
553
+ // here alongside the new `currencyId` field or it silently drops from the
554
+ // encoded extra bytes, shifting every extrinsic out of alignment.
555
+ ChargeCurrencyTransactionPayment: {
556
+ extrinsic: {
557
+ tip: "Compact<Balance>",
558
+ currencyId: "Option<CurrencyId>"
559
+ },
560
+ payload: {}
541
561
  }
542
562
  };
543
563
 
@@ -1121,8 +1141,9 @@ async function joinGuardian(account, prefs) {
1121
1141
 
1122
1142
  // src/chain/utils.ts
1123
1143
  var signAndSend = async (request, account, opts = DEFAULT_COMPUTE_PAYLOAD) => {
1144
+ const signOpts = { currencyId: null, ...opts };
1124
1145
  const tx_result = await new Promise((res, err) => {
1125
- request.signAndSend(account, opts, (result) => {
1146
+ request.signAndSend(account, signOpts, (result) => {
1126
1147
  if (result.isFinalized) {
1127
1148
  res(result);
1128
1149
  }
@@ -1442,7 +1463,7 @@ var MCryptFsWriter = class {
1442
1463
  );
1443
1464
  console.log("account: ", this._account);
1444
1465
  return new Promise((resolve) => {
1445
- request.signAndSend(this._account, { app_id: 1 }, (result) => {
1466
+ request.signAndSend(this._account, { app_id: 1, currencyId: null }, (result) => {
1446
1467
  if (result.isInBlock || result.isFinalized || result.isError) {
1447
1468
  resolve({
1448
1469
  blockNumber: result.blockNumber?.toNumber() ?? 0,
@@ -1566,7 +1587,8 @@ function buildFee(fee) {
1566
1587
  async function createAgreement(contract, account, oracle_quore_id = void 0) {
1567
1588
  const api2 = await getApi();
1568
1589
  if (!api2) throw new Error("Api not initialized");
1569
- const tx = api2.tx["compute"]["agreement"](contract, oracle_quore_id ?? null);
1590
+ const onChainContract = { currencyId: "Native", ...contract };
1591
+ const tx = api2.tx["compute"]["agreement"](onChainContract, oracle_quore_id ?? null);
1570
1592
  const opts = {
1571
1593
  compute: {
1572
1594
  daType: 1,
@@ -1655,6 +1677,103 @@ async function dataContract(params, account) {
1655
1677
  return createAgreement(contract, account);
1656
1678
  }
1657
1679
 
1680
+ // src/compute/encryptedInference.ts
1681
+ import { edwardsToMontgomeryPub as edwardsToMontgomeryPub2 } from "@noble/curves/ed25519";
1682
+
1683
+ // src/crypto/random.ts
1684
+ function generateRandomBytes(length = 32) {
1685
+ const bytes = new Uint8Array(length);
1686
+ const cr = globalThis.crypto;
1687
+ if (!cr || typeof cr.getRandomValues !== "function") {
1688
+ throw new Error(
1689
+ "crypto.getRandomValues is not available. Ensure you're running in a supported environment (browser or Node.js 18+)."
1690
+ );
1691
+ }
1692
+ cr.getRandomValues(bytes);
1693
+ return bytes;
1694
+ }
1695
+
1696
+ // src/compute/encryptedInference.ts
1697
+ async function encryptedInferenceSubscription(params, account) {
1698
+ const computeStep = {
1699
+ cipher: "Plaintext",
1700
+ computerIndices: params.guardians.map((_, i) => i),
1701
+ ...buildFee(params.fee),
1702
+ deadline: params.deadline ?? 0,
1703
+ confidentiality: { Trusted: 0 },
1704
+ feeFunction: null,
1705
+ input: null,
1706
+ program: { NativeExecute: "Inference" }
1707
+ };
1708
+ const contract = {
1709
+ contractType: "Dormant",
1710
+ guardians: params.guardians,
1711
+ preCheck: null,
1712
+ compute: computeStep,
1713
+ postCheck: null,
1714
+ resultCipher: "Plaintext"
1715
+ };
1716
+ return createAgreement(contract, account);
1717
+ }
1718
+ async function encryptedInferenceSubscriptionInvocation(params, encAccount, account) {
1719
+ const api2 = await getApi();
1720
+ if (!api2) throw new Error("Api not initialized");
1721
+ const inputBytes = typeof params.input === "string" ? new TextEncoder().encode(params.input) : params.input;
1722
+ const { encoded: cyphtxt, ikm } = testCrypt(
1723
+ params.guardianInfo.tauParams,
1724
+ params.guardianInfo.aggKey
1725
+ );
1726
+ const sharedKey = gen_stretched_key(hexToUint8Array(ikm));
1727
+ const { ciphertext, nonce } = encrypt2(inputBytes, sharedKey);
1728
+ const cyphtxtBytes = hexToUint8Array(cyphtxt);
1729
+ const groupPkBytes = hexToUint8Array(params.guardianInfo.groupPk);
1730
+ const tauParamsBytes = hexToUint8Array(params.guardianInfo.tauParams);
1731
+ const tx = api2.tx["dataAvailability"]["daccComputeRequest"](
1732
+ edwardsToMontgomeryPub2(encAccount.publicKey),
1733
+ nonce,
1734
+ Array.from(ciphertext),
1735
+ params.guardians[0],
1736
+ Array.from(cyphtxtBytes),
1737
+ Array.from(groupPkBytes),
1738
+ Array.from(tauParamsBytes),
1739
+ params.guardians
1740
+ );
1741
+ const idHex = params.agreementId.startsWith("0x") ? params.agreementId.slice(2) : params.agreementId;
1742
+ const opts = {
1743
+ compute: {
1744
+ da_type: 4,
1745
+ agreement: [Buffer.from(idHex, "hex")],
1746
+ verification: 0,
1747
+ compute: 1
1748
+ }
1749
+ };
1750
+ return signAndSend(tx, account, opts);
1751
+ }
1752
+ async function encryptedInferenceCompute(params, encAccount, account) {
1753
+ const subscription = await encryptedInferenceSubscription(
1754
+ {
1755
+ guardians: params.guardians,
1756
+ fee: params.fee,
1757
+ deadline: params.deadline
1758
+ },
1759
+ account
1760
+ );
1761
+ if (!subscription.agreementId) {
1762
+ throw new Error("Subscription creation did not return an agreement ID");
1763
+ }
1764
+ const invocation = await encryptedInferenceSubscriptionInvocation(
1765
+ {
1766
+ agreementId: subscription.agreementId,
1767
+ input: params.input,
1768
+ guardians: params.guardians,
1769
+ guardianInfo: params.guardianInfo
1770
+ },
1771
+ encAccount,
1772
+ account
1773
+ );
1774
+ return { subscription, invocation };
1775
+ }
1776
+
1658
1777
  // src/compute/inference.ts
1659
1778
  async function inferenceCompute(params, account) {
1660
1779
  const inputData = typeof params.input === "string" ? Array.from(new TextEncoder().encode(params.input)) : Array.from(params.input);
@@ -1769,19 +1888,6 @@ async function simpleCompute(params, account) {
1769
1888
  return createAgreement(contract, account);
1770
1889
  }
1771
1890
 
1772
- // src/crypto/random.ts
1773
- function generateRandomBytes(length = 32) {
1774
- const bytes = new Uint8Array(length);
1775
- const cr = globalThis.crypto;
1776
- if (!cr || typeof cr.getRandomValues !== "function") {
1777
- throw new Error(
1778
- "crypto.getRandomValues is not available. Ensure you're running in a supported environment (browser or Node.js 18+)."
1779
- );
1780
- }
1781
- cr.getRandomValues(bytes);
1782
- return bytes;
1783
- }
1784
-
1785
1891
  // src/da/register.ts
1786
1892
  async function writeMetadata(account, name, description, ref, price, dataType, l2Owner, groupId) {
1787
1893
  const blobRef = [ref.blockNumber, ref.index];
@@ -2686,6 +2792,9 @@ export {
2686
2792
  encrypt as ecncryptTest,
2687
2793
  encodeCiphertext,
2688
2794
  encrypt2 as encrypt,
2795
+ encryptedInferenceCompute,
2796
+ encryptedInferenceSubscription,
2797
+ encryptedInferenceSubscriptionInvocation,
2689
2798
  fetchAndDecodeExtrinsic,
2690
2799
  fetchTokenProperties,
2691
2800
  formatBalanceWithTokenProperties,