@palliora.org/chainsdk 0.1.0 → 0.2.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 +541 -217
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +397 -121
- package/dist/index.d.ts +397 -121
- package/dist/index.js +504 -180
- package/dist/index.js.map +1 -1
- package/package.json +10 -8
package/dist/index.d.cts
CHANGED
|
@@ -158,12 +158,144 @@ declare const API_TYPES: {
|
|
|
158
158
|
extra: string;
|
|
159
159
|
types: string;
|
|
160
160
|
};
|
|
161
|
+
FeePayload: {
|
|
162
|
+
compute: string;
|
|
163
|
+
guardian: string;
|
|
164
|
+
verifier: string;
|
|
165
|
+
};
|
|
166
|
+
SilentThresholdParams: {
|
|
167
|
+
td_params: string;
|
|
168
|
+
pk_bytes: string;
|
|
169
|
+
tau_params: string;
|
|
170
|
+
};
|
|
171
|
+
ThresholdAlgos: {
|
|
172
|
+
_enum: {
|
|
173
|
+
SilentThreshold: string;
|
|
174
|
+
};
|
|
175
|
+
};
|
|
176
|
+
ChaCha20Poly1305Params: {
|
|
177
|
+
nonce: string;
|
|
178
|
+
};
|
|
179
|
+
Aes256GcmParams: {
|
|
180
|
+
nonce: string;
|
|
181
|
+
};
|
|
182
|
+
SymmetricAlgos: {
|
|
183
|
+
_enum: {
|
|
184
|
+
ChaCha20Poly1305: string;
|
|
185
|
+
Aes256Gcm: string;
|
|
186
|
+
};
|
|
187
|
+
};
|
|
188
|
+
CipherSuiteEncrypted: {
|
|
189
|
+
threshold: string;
|
|
190
|
+
symmetric: string;
|
|
191
|
+
};
|
|
192
|
+
CipherSuite: {
|
|
193
|
+
_enum: {
|
|
194
|
+
Plaintext: string;
|
|
195
|
+
Encrypted: string;
|
|
196
|
+
};
|
|
197
|
+
};
|
|
198
|
+
ConfidentialityLevel: {
|
|
199
|
+
_enum: string[];
|
|
200
|
+
};
|
|
201
|
+
NativeExecuteDA: {
|
|
202
|
+
_enum: string[];
|
|
203
|
+
};
|
|
204
|
+
NativeDataDA: {
|
|
205
|
+
_enum: string[];
|
|
206
|
+
};
|
|
207
|
+
DAInputInline: {
|
|
208
|
+
data: string;
|
|
209
|
+
};
|
|
210
|
+
DAInputChainTransaction: {
|
|
211
|
+
block_number: string;
|
|
212
|
+
extrinsic_index: string;
|
|
213
|
+
};
|
|
214
|
+
DAInputIpfs: {
|
|
215
|
+
cid: string;
|
|
216
|
+
size: string;
|
|
217
|
+
};
|
|
218
|
+
DAInputUrl: {
|
|
219
|
+
url: string;
|
|
220
|
+
size: string;
|
|
221
|
+
hash: string;
|
|
222
|
+
};
|
|
223
|
+
DAInput: {
|
|
224
|
+
_enum: {
|
|
225
|
+
Inline: string;
|
|
226
|
+
ChainTransaction: string;
|
|
227
|
+
Ipfs: string;
|
|
228
|
+
Url: string;
|
|
229
|
+
NativeExecute: string;
|
|
230
|
+
NativeData: string;
|
|
231
|
+
};
|
|
232
|
+
};
|
|
233
|
+
ContractType: {
|
|
234
|
+
_enum: {
|
|
235
|
+
Dormant: string;
|
|
236
|
+
Active: string;
|
|
237
|
+
};
|
|
238
|
+
};
|
|
239
|
+
StoreType: {
|
|
240
|
+
_enum: {
|
|
241
|
+
Dataset: string;
|
|
242
|
+
Model: string;
|
|
243
|
+
Agent: string;
|
|
244
|
+
Other: string;
|
|
245
|
+
};
|
|
246
|
+
};
|
|
247
|
+
ComputeMetadata: {
|
|
248
|
+
name: string;
|
|
249
|
+
description: string;
|
|
250
|
+
store_type: string;
|
|
251
|
+
group_id: string;
|
|
252
|
+
};
|
|
253
|
+
ComputeInfo: {
|
|
254
|
+
cipher: string;
|
|
255
|
+
computer_indices: string;
|
|
256
|
+
fees: string;
|
|
257
|
+
deadline: string;
|
|
258
|
+
confidentiality: string;
|
|
259
|
+
fee_function: string;
|
|
260
|
+
program_env: string;
|
|
261
|
+
input: string;
|
|
262
|
+
program: string;
|
|
263
|
+
metadata: string;
|
|
264
|
+
};
|
|
265
|
+
Contract: {
|
|
266
|
+
contract_type: string;
|
|
267
|
+
guardians: string;
|
|
268
|
+
pre_check: string;
|
|
269
|
+
compute: string;
|
|
270
|
+
post_check: string;
|
|
271
|
+
result_cipher: string;
|
|
272
|
+
};
|
|
273
|
+
AgreementInfo: {
|
|
274
|
+
status: string;
|
|
275
|
+
creator: string;
|
|
276
|
+
index: string;
|
|
277
|
+
};
|
|
161
278
|
ComputePayload: {
|
|
162
279
|
da_type: string;
|
|
163
280
|
agreement: string;
|
|
164
281
|
verification: string;
|
|
165
282
|
compute: string;
|
|
166
283
|
};
|
|
284
|
+
ComputePrefs: {
|
|
285
|
+
trusted: string;
|
|
286
|
+
tee: string;
|
|
287
|
+
mpc: string;
|
|
288
|
+
fhe: string;
|
|
289
|
+
zkp: string;
|
|
290
|
+
};
|
|
291
|
+
GuardianPrefs: {
|
|
292
|
+
pubKey: string;
|
|
293
|
+
guardian: string;
|
|
294
|
+
verifier: string;
|
|
295
|
+
compute: string;
|
|
296
|
+
computePrefs: string;
|
|
297
|
+
feeThreshold: string;
|
|
298
|
+
};
|
|
167
299
|
BlockLengthColumns: string;
|
|
168
300
|
BlockLengthRows: string;
|
|
169
301
|
BlockLength: {
|
|
@@ -339,70 +471,6 @@ declare const FileFromMetadataRef: (mcryptApi: any, metadataRef: any) => Promise
|
|
|
339
471
|
* in production.
|
|
340
472
|
*/
|
|
341
473
|
|
|
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
474
|
/**
|
|
407
475
|
* getApi()
|
|
408
476
|
*
|
|
@@ -417,9 +485,11 @@ declare class RpcApi {
|
|
|
417
485
|
* cause the process to exit so that an external supervisor can restart the
|
|
418
486
|
* process.
|
|
419
487
|
*
|
|
488
|
+
* @param cb - Optional callback function to attach to the "disconnected" event.
|
|
489
|
+
*
|
|
420
490
|
* @returns The singleton {@link ApiPromise} instance (or `undefined` if no provider).
|
|
421
491
|
*/
|
|
422
|
-
declare function getApi(): Promise<ApiPromise | undefined>;
|
|
492
|
+
declare function getApi(cb?: () => void): Promise<ApiPromise | undefined>;
|
|
423
493
|
/**
|
|
424
494
|
* getKeyring()
|
|
425
495
|
*
|
|
@@ -461,12 +531,6 @@ declare function getKeyring(): Promise<Keyring>;
|
|
|
461
531
|
* @returns The singleton {@link Keyring} instance used for encryption keys.
|
|
462
532
|
*/
|
|
463
533
|
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
534
|
|
|
471
535
|
declare const signAndSend: (request: any, account: any, opts?: {
|
|
472
536
|
compute: {
|
|
@@ -489,10 +553,151 @@ declare const getGuardianNwParams: () => Promise<any>;
|
|
|
489
553
|
|
|
490
554
|
declare const provider: WsProvider;
|
|
491
555
|
|
|
492
|
-
declare function createAgreement(): Promise<
|
|
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;
|
|
580
|
+
/**
|
|
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
|
|
585
|
+
*/
|
|
586
|
+
declare function fetchTokenProperties(): Promise<TokenProperties>;
|
|
587
|
+
/**
|
|
588
|
+
* Get cached token properties without making an RPC call
|
|
589
|
+
* @returns TokenProperties or null if not yet cached
|
|
590
|
+
*/
|
|
591
|
+
declare function getCachedTokenProperties(): TokenProperties | null;
|
|
592
|
+
/**
|
|
593
|
+
* Clear the token properties cache
|
|
594
|
+
*/
|
|
595
|
+
declare function clearTokenCache(): void;
|
|
596
|
+
/**
|
|
597
|
+
* Format balance using cached token properties
|
|
598
|
+
* @param balance - The balance value to format
|
|
599
|
+
* @returns Formatted balance string
|
|
600
|
+
*/
|
|
601
|
+
declare function formatBalanceWithTokenProperties(balance: string | number | bigint): Promise<string>;
|
|
602
|
+
declare const tokenToBigint: (amount: PaliAmountInput) => AtomicPaliAmount;
|
|
603
|
+
|
|
604
|
+
interface DataContractParams {
|
|
605
|
+
/** URL pointing to the data to store. */
|
|
606
|
+
url: string;
|
|
607
|
+
/** Guardian account IDs that participate in this contract. */
|
|
608
|
+
guardians: {
|
|
609
|
+
peerid: string;
|
|
610
|
+
address: string;
|
|
611
|
+
}[];
|
|
612
|
+
/** Fee offered for the contract in PALI. Defaults to 0. */
|
|
613
|
+
fees?: PaliAmountInput;
|
|
614
|
+
/** Block number deadline. Defaults to 0 (no deadline). */
|
|
615
|
+
deadline?: number;
|
|
616
|
+
/** Trusted guardian index in the guardians list. Defaults to 0. */
|
|
617
|
+
trustIndex?: number;
|
|
618
|
+
}
|
|
619
|
+
/**
|
|
620
|
+
* Submits a dormant data-store contract on-chain via `compute.agreement`.
|
|
621
|
+
*
|
|
622
|
+
* - No encryption (Plaintext cipher suite)
|
|
623
|
+
* - Trusted confidentiality mode
|
|
624
|
+
* - Input fetched from a URL
|
|
625
|
+
* - No pre-check or post-check verifications
|
|
626
|
+
* - Plain (unencrypted) result
|
|
627
|
+
*/
|
|
628
|
+
declare function dataContract(params: DataContractParams): Promise<{
|
|
629
|
+
blockNumber: any;
|
|
630
|
+
index: any;
|
|
631
|
+
hash: any;
|
|
632
|
+
agreementId?: string;
|
|
633
|
+
}>;
|
|
634
|
+
|
|
635
|
+
interface InferenceComputeParams {
|
|
636
|
+
/** Raw input data — string will be UTF-8 encoded, Uint8Array used as-is. */
|
|
637
|
+
input: Uint8Array | string;
|
|
638
|
+
/** Guardian account IDs that participate in this compute. */
|
|
639
|
+
guardians: {
|
|
640
|
+
peerid: string;
|
|
641
|
+
address: string;
|
|
642
|
+
}[];
|
|
643
|
+
/** Fee offered for the compute step in PALI. Defaults to 0. */
|
|
644
|
+
fees?: PaliAmountInput;
|
|
645
|
+
/** Block number deadline for the compute step. Defaults to 0 (no deadline). */
|
|
646
|
+
deadline?: number;
|
|
647
|
+
}
|
|
648
|
+
/**
|
|
649
|
+
* Submits a plain (unencrypted, no-confidentiality) inference compute request
|
|
650
|
+
* on-chain via the `compute.agreement` extrinsic.
|
|
651
|
+
*
|
|
652
|
+
* - Input is sent inline (no DA layer indirection).
|
|
653
|
+
* - Program is the native `Inference` executor.
|
|
654
|
+
* - Pre-check and post-check are no-ops (no verification).
|
|
655
|
+
* - Cipher fields carry zero-value placeholders (unused in the trusted path).
|
|
656
|
+
* - Result is returned in plain (no re-encryption).
|
|
657
|
+
*/
|
|
658
|
+
declare function inferenceCompute(params: InferenceComputeParams): Promise<{
|
|
659
|
+
blockNumber: any;
|
|
660
|
+
index: any;
|
|
661
|
+
hash: any;
|
|
662
|
+
agreementId?: string;
|
|
663
|
+
}>;
|
|
493
664
|
|
|
494
665
|
declare function getGuardianParticipants(): Promise<any>;
|
|
495
666
|
|
|
667
|
+
interface SimpleComputeParams {
|
|
668
|
+
/** Guardian account IDs that participate in this compute. */
|
|
669
|
+
guardians: {
|
|
670
|
+
peerid: string;
|
|
671
|
+
address: string;
|
|
672
|
+
}[];
|
|
673
|
+
/** Input reference block number from which to read the tx payload. */
|
|
674
|
+
inputBlockNumber: number;
|
|
675
|
+
/** Input reference extrinsic index within the input block. */
|
|
676
|
+
inputExtrinsicIndex: number;
|
|
677
|
+
/** Program location as URL. */
|
|
678
|
+
programUrl: string;
|
|
679
|
+
/** Fee offered for the compute step in PALI. Defaults to 0. */
|
|
680
|
+
fees?: PaliAmountInput;
|
|
681
|
+
/** Block number deadline for the compute step. Defaults to 0 (no deadline). */
|
|
682
|
+
deadline?: number;
|
|
683
|
+
/** Trusted guardian index in the guardians list. Defaults to 0. */
|
|
684
|
+
trustIndex?: number;
|
|
685
|
+
}
|
|
686
|
+
/**
|
|
687
|
+
* Submits a minimal trusted compute agreement:
|
|
688
|
+
* - no encryption (plaintext cipher)
|
|
689
|
+
* - trusted confidentiality mode
|
|
690
|
+
* - input from chain transaction reference
|
|
691
|
+
* - program fetched from URL
|
|
692
|
+
* - no pre/post verification
|
|
693
|
+
*/
|
|
694
|
+
declare function simpleCompute(params: SimpleComputeParams): Promise<{
|
|
695
|
+
blockNumber: any;
|
|
696
|
+
index: any;
|
|
697
|
+
hash: any;
|
|
698
|
+
agreementId?: string;
|
|
699
|
+
}>;
|
|
700
|
+
|
|
496
701
|
declare const gen_stretched_key: (input: Uint8Array) => Uint8Array<ArrayBufferLike>;
|
|
497
702
|
declare const gen_shared_key: (key: Uint8Array, pk: Uint8Array) => Uint8Array<ArrayBufferLike>;
|
|
498
703
|
declare const encrypt$1: (plaintext: Uint8Array, key: Uint8Array) => {
|
|
@@ -625,10 +830,59 @@ declare const testCrypt: (kzg: string, agg_key: string) => {
|
|
|
625
830
|
*/
|
|
626
831
|
declare function generateRandomBytes(length?: number): Uint8Array;
|
|
627
832
|
|
|
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
|
+
|
|
628
850
|
interface OnChainRef {
|
|
629
851
|
blockNumber: number;
|
|
630
852
|
index: number;
|
|
631
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
|
+
}
|
|
632
886
|
interface GuardianGroupInfo {
|
|
633
887
|
groupId: string;
|
|
634
888
|
guardians: any[];
|
|
@@ -639,11 +893,15 @@ interface GuardianGroupInfo {
|
|
|
639
893
|
interface UploadOptions {
|
|
640
894
|
name: string;
|
|
641
895
|
description: string;
|
|
642
|
-
price:
|
|
896
|
+
price: PaliAmountInput;
|
|
643
897
|
type: "model" | "dataset" | "agent";
|
|
644
898
|
guardianGroupInfo: GuardianGroupInfo;
|
|
645
899
|
ref?: string;
|
|
646
900
|
filePath?: string;
|
|
901
|
+
/** Options forwarded to signAndSend. Defaults to dormant DA payload (da_type=1, compute=0). */
|
|
902
|
+
opts?: {
|
|
903
|
+
compute: ComputePayload;
|
|
904
|
+
};
|
|
647
905
|
}
|
|
648
906
|
|
|
649
907
|
declare function writeMetadata(account: any, name: string, description: string, ref: OnChainRef, price: bigint, dataType: number, l2Owner: string, groupId: string): Promise<{
|
|
@@ -652,11 +910,71 @@ declare function writeMetadata(account: any, name: string, description: string,
|
|
|
652
910
|
hash: any;
|
|
653
911
|
tx_result: any;
|
|
654
912
|
}>;
|
|
913
|
+
interface DataAgreementMetadata {
|
|
914
|
+
name: string;
|
|
915
|
+
description: string;
|
|
916
|
+
/** Maps to the on-chain StoreType enum. */
|
|
917
|
+
storeType: "Dataset" | "Model" | "Agent" | "Other";
|
|
918
|
+
/** H256 group identifier. */
|
|
919
|
+
groupId: string;
|
|
920
|
+
}
|
|
921
|
+
interface DataAgreementParams {
|
|
922
|
+
/** DA blob reference returned by submitTEData. */
|
|
923
|
+
ref: OnChainRef;
|
|
924
|
+
/** Guardian account IDs that participate in this agreement. */
|
|
925
|
+
guardians: {
|
|
926
|
+
peerid: string;
|
|
927
|
+
address: string;
|
|
928
|
+
}[];
|
|
929
|
+
/** Fee for the agreement in PALI atomic units. */
|
|
930
|
+
fees: bigint;
|
|
931
|
+
/** If provided, populates ComputeInfo.metadata in the contract. */
|
|
932
|
+
metadata?: DataAgreementMetadata;
|
|
933
|
+
/** Block number deadline. Defaults to 0 (no deadline). */
|
|
934
|
+
deadline?: number;
|
|
935
|
+
/** Trusted guardian index in the guardians list. Defaults to 0. */
|
|
936
|
+
trustIndex?: number;
|
|
937
|
+
/**
|
|
938
|
+
* CipherSuite for the compute step input. Defaults to "Plaintext".
|
|
939
|
+
* Pass the `cipher` from submitTEDataWithCipher for the threshold-encrypted path.
|
|
940
|
+
*/
|
|
941
|
+
cipher?: CipherSuite;
|
|
942
|
+
/**
|
|
943
|
+
* CipherSuite for the agreement result. Defaults to "Plaintext".
|
|
944
|
+
*/
|
|
945
|
+
resultCipher?: CipherSuite;
|
|
946
|
+
}
|
|
947
|
+
declare function registerDataAgreement(account: any, params: DataAgreementParams): Promise<{
|
|
948
|
+
blockNumber: any;
|
|
949
|
+
index: any;
|
|
950
|
+
hash: any;
|
|
951
|
+
agreementId?: string;
|
|
952
|
+
}>;
|
|
953
|
+
|
|
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;
|
|
959
|
+
}>;
|
|
655
960
|
|
|
656
961
|
declare function submitData(account: any, data: string): Promise<void>;
|
|
657
962
|
declare function submitTEData(account: any, data: string, chosenGuardians: any[], tau_params: string, agg_key: string, group_pk: string): Promise<OnChainRef>;
|
|
963
|
+
/**
|
|
964
|
+
* Identical to submitTEData but additionally returns the populated CipherSuite
|
|
965
|
+
* so callers can pass it directly to registerDataAgreement without
|
|
966
|
+
* re-deriving the cipher parameters.
|
|
967
|
+
*/
|
|
968
|
+
declare function submitTEDataWithCipher(account: any, data: string, chosenGuardians: any[], tau_params: string, agg_key: string, group_pk: string): Promise<SubmitTEDataResult>;
|
|
658
969
|
|
|
659
970
|
declare function uploadData(options: UploadOptions): Promise<void>;
|
|
971
|
+
/**
|
|
972
|
+
* Legacy upload: uses submitTEData (returns only OnChainRef) and registers
|
|
973
|
+
* the agreement with Plaintext cipher and no ComputePayload opts.
|
|
974
|
+
* Kept for backward compatibility with callers that do not need cipher
|
|
975
|
+
* parameters surfaced in the on-chain agreement.
|
|
976
|
+
*/
|
|
977
|
+
declare function uploadDataLegacy(options: Omit<UploadOptions, "opts">): Promise<void>;
|
|
660
978
|
|
|
661
979
|
declare const getGuardianList: () => Promise<string[]>;
|
|
662
980
|
|
|
@@ -664,39 +982,24 @@ declare const createGuardianGroup: (account: any, selectedGuardians: any) => Pro
|
|
|
664
982
|
|
|
665
983
|
declare function joinGuardian(account: any, prefs: any): Promise<void>;
|
|
666
984
|
|
|
667
|
-
declare function addStake(account: any,
|
|
985
|
+
declare function addStake(account: any, amountBaseUnits: bigint): Promise<void>;
|
|
668
986
|
|
|
669
987
|
declare function joinIdleStaker(account: any): Promise<void>;
|
|
670
988
|
|
|
671
|
-
declare function newStake(account: any,
|
|
989
|
+
declare function newStake(account: any, amountBaseUnits: bigint, rewardDestination?: string): Promise<void>;
|
|
672
990
|
|
|
673
991
|
declare function payoutStake(account: any, eras: Array<number>, address?: string): Promise<void>;
|
|
674
992
|
|
|
675
|
-
declare function reduceStake(account: any,
|
|
993
|
+
declare function reduceStake(account: any, amountBaseUnits: bigint): Promise<void>;
|
|
676
994
|
|
|
677
995
|
declare function removeStake(account: any): Promise<void>;
|
|
678
996
|
|
|
679
997
|
declare function withdrawStake(account: any): Promise<void>;
|
|
680
998
|
|
|
681
|
-
declare function fundAccount(account: any,
|
|
682
|
-
|
|
683
|
-
declare function transfer(account: any, amount: bigint, address: string): Promise<void>;
|
|
999
|
+
declare function fundAccount(account: any, amountBaseUnits: bigint, address?: string): Promise<void>;
|
|
684
1000
|
|
|
685
|
-
|
|
1001
|
+
declare function transfer(account: any, amountBaseUnits: bigint, address: string): Promise<void>;
|
|
686
1002
|
|
|
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
1003
|
/**
|
|
701
1004
|
* Converts a hex string into a Uint8Array.
|
|
702
1005
|
*
|
|
@@ -763,33 +1066,6 @@ declare const decodeField: (field: string, expectedLength?: number) => Uint8Arra
|
|
|
763
1066
|
*/
|
|
764
1067
|
declare const debugLog: (message?: any, ...optionalParams: any[]) => void;
|
|
765
1068
|
|
|
766
|
-
interface TokenProperties {
|
|
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
1069
|
declare function joinValidator(account: any, commission: number): Promise<void>;
|
|
794
1070
|
|
|
795
1071
|
declare let PALLIORA_WS: string;
|
|
@@ -808,4 +1084,4 @@ declare function setIdentity(account: any, { display }: any): Promise<void>;
|
|
|
808
1084
|
declare function rotateAndSetKeys(account: any): Promise<void>;
|
|
809
1085
|
declare function setWorker(account: any): Promise<void>;
|
|
810
1086
|
|
|
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,
|
|
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 };
|