@palliora.org/chainsdk 0.3.3 → 0.5.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
@@ -39,8 +39,37 @@ declare enum AccountSourceType {
39
39
  * @returns The keypair object.
40
40
  */
41
41
  declare function createAccount(input: string, type: AccountSourceType, name?: string, cryptoType?: CryptoType, signedMsg?: string): Promise<KeyringPair>;
42
+ /**
43
+ * Derives a Substrate account from a Magic Link (or other Ethereum-compatible)
44
+ * signature over the fixed message `createAccount` expects for signature-derived
45
+ * accounts, wiring passwordless/email-based onboarding into the existing
46
+ * `AccountSourceType.DERIVED` flow.
47
+ *
48
+ * @param signature - Hex-encoded signature (0x-prefixed) produced by the Magic Link signer.
49
+ */
50
+ declare function createAccountFromMagicLink(signature: string, name?: string, cryptoType?: CryptoType): Promise<KeyringPair>;
42
51
  declare function pairFromPrivateKeyHex(privateKeyHex: string, cryptoType: CryptoType): _polkadot_util_crypto_types.Keypair;
43
52
 
53
+ interface Balance {
54
+ free: bigint;
55
+ reserved: bigint;
56
+ frozen: bigint;
57
+ /** Free balance formatted with the chain's token symbol/decimals, e.g. "1.5 PALI". */
58
+ formatted: string;
59
+ }
60
+ /** Reads an account's free/reserved/frozen balance from `system.account`. */
61
+ declare function getBalance(address: string): Promise<Balance>;
62
+
63
+ interface AccountInfo {
64
+ address: string;
65
+ nonce: number;
66
+ balance: Balance;
67
+ /** On-chain identity display name, or `null` if none is set. */
68
+ displayName: string | null;
69
+ }
70
+ /** Convenience read combining balance, nonce, and identity display name for a single account. */
71
+ declare function getAccountInfo(address: string): Promise<AccountInfo>;
72
+
44
73
  declare const API_RPC: {
45
74
  kate: {
46
75
  queryRows: {
@@ -119,6 +148,13 @@ declare const API_TYPES: {
119
148
  active: string;
120
149
  maximum: string;
121
150
  };
151
+ CurrencyId: {
152
+ _enum: {
153
+ Native: string;
154
+ USDC: string;
155
+ ForeignAsset: string;
156
+ };
157
+ };
122
158
  GuardianNwParams: {
123
159
  kzg: string;
124
160
  aggKey: string;
@@ -292,6 +328,7 @@ declare const API_TYPES: {
292
328
  Dataset: string;
293
329
  Model: string;
294
330
  Agent: string;
331
+ Executable: string;
295
332
  Other: string;
296
333
  };
297
334
  };
@@ -321,6 +358,7 @@ declare const API_TYPES: {
321
358
  compute: string;
322
359
  postCheck: string;
323
360
  resultCipher: string;
361
+ currencyId: string;
324
362
  };
325
363
  AgreementInfo: {
326
364
  status: string;
@@ -340,13 +378,16 @@ declare const API_TYPES: {
340
378
  fhe: string;
341
379
  zkp: string;
342
380
  };
381
+ ComputeType: {
382
+ _enum: string[];
383
+ };
343
384
  GuardianPrefs: {
344
385
  pubKey: string;
345
386
  guardian: string;
346
387
  verifier: string;
347
388
  compute: string;
348
389
  computePrefs: string;
349
- feeThreshold: string;
390
+ feeThresholds: string;
350
391
  };
351
392
  BlockLengthColumns: string;
352
393
  BlockLengthRows: string;
@@ -470,6 +511,13 @@ declare const API_EXTENSIONS: {
470
511
  };
471
512
  payload: {};
472
513
  };
514
+ ChargeCurrencyTransactionPayment: {
515
+ extrinsic: {
516
+ tip: string;
517
+ currencyId: string;
518
+ };
519
+ payload: {};
520
+ };
473
521
  };
474
522
 
475
523
  declare const PALI_SYMBOL = "PALI";
@@ -599,7 +647,7 @@ interface UploadOptions {
599
647
  name: string;
600
648
  description: string;
601
649
  price: PaliAmountInput;
602
- type: "model" | "dataset" | "agent";
650
+ type: "model" | "dataset" | "agent" | "executable";
603
651
  guardianGroupInfo: GuardianGroupInfo;
604
652
  ref?: string;
605
653
  filePath?: string;
@@ -713,8 +761,8 @@ declare const FileFromMetadataRef: (mcryptApi: any, metadataRef: [number, number
713
761
  * Returns the singleton {@link ApiPromise} instance, creating it if necessary.
714
762
  *
715
763
  * @remarks
716
- * - If no underlying `provider` is configured (the module-level `provider`
717
- * imported from "./wsProvider"), this function returns `undefined`.
764
+ * - Throws if the SDK has not been initialized with a `pallioraWs` endpoint
765
+ * (see `init` in "../config").
718
766
  * - When creating the API, the configured `rpc`, `types` and `signedExtensions`
719
767
  * are applied.
720
768
  * - In non-test environments, top-level API `error` and `disconnected` events
@@ -723,9 +771,19 @@ declare const FileFromMetadataRef: (mcryptApi: any, metadataRef: [number, number
723
771
  *
724
772
  * @param cb - Optional callback function to attach to the "disconnected" event.
725
773
  *
726
- * @returns The singleton {@link ApiPromise} instance (or `undefined` if no provider).
774
+ * @returns The singleton {@link ApiPromise} instance.
775
+ */
776
+ declare function getApi(cb?: () => void): Promise<ApiPromise>;
777
+ /**
778
+ * disconnectApi()
779
+ *
780
+ * Tears down the singleton {@link ApiPromise} instance, if one exists.
781
+ *
782
+ * @remarks
783
+ * Safe to call when no API has been created yet (no-op). After this resolves,
784
+ * the next call to {@link getApi} creates a fresh instance.
727
785
  */
728
- declare function getApi(cb?: () => void): Promise<ApiPromise | undefined>;
786
+ declare function disconnectApi(): Promise<void>;
729
787
  /**
730
788
  * getKeyring()
731
789
  *
@@ -768,6 +826,10 @@ declare function getKeyring(): Promise<Keyring>;
768
826
  */
769
827
  declare function getEncKeyring(): Promise<Keyring>;
770
828
 
829
+ /** Identifies the currency used for fee payment / contract settlement. Mirrors runtime `primitives::CurrencyId`. */
830
+ type CurrencyId = "Native" | "USDC" | {
831
+ ForeignAsset: number;
832
+ };
771
833
  /** Fee terms for a compute step: an absolute amount plus an optional dynamic compute rate. */
772
834
  interface Fee {
773
835
  /** Absolute fee offered for the compute step, in PALI. Defaults to 0. */
@@ -784,6 +846,30 @@ interface SubmissionReceipt {
784
846
  /** Zero-based index of the result extrinsic within the block. */
785
847
  extrinsicIndex: number;
786
848
  }
849
+ /** Union of `AgreementStatus` variant names, read straight off {@link API_TYPES} (chain/spec.ts). */
850
+ type AgreementStatus = keyof typeof API_TYPES.AgreementStatus._enum;
851
+ /** Union of `ContractType` variant names, read straight off {@link API_TYPES} (chain/spec.ts). */
852
+ type ContractType = keyof typeof API_TYPES.ContractType._enum;
853
+ /**
854
+ * On-chain record for an agreement/contract, read back from `compute.agreementsInfo`.
855
+ * Mirrors the `ContractInfo` type registered in {@link API_TYPES} (chain/spec.ts).
856
+ */
857
+ interface ContractInfo {
858
+ /** Current settlement status of the agreement. */
859
+ status: AgreementStatus;
860
+ /** Address of the account that owns the contract. */
861
+ owner: string;
862
+ /** Block number at which the contract originated. */
863
+ originBlock: number;
864
+ /** Block number at which the contract was last invoked. */
865
+ invocationBlock: number;
866
+ /** Sequential index assigned to the agreement. */
867
+ index: number;
868
+ /** Usage price charged per invocation, in atomic units. */
869
+ usagePrice: bigint;
870
+ /** Contract lifecycle type. */
871
+ contractType: ContractType;
872
+ }
787
873
 
788
874
  declare const signAndSend: (request: SubmittableExtrinsic<"promise">, account: KeyringPair, opts?: Record<string, unknown>) => Promise<{
789
875
  blockNumber: number;
@@ -791,12 +877,36 @@ declare const signAndSend: (request: SubmittableExtrinsic<"promise">, account: K
791
877
  hash: `0x${string}`;
792
878
  tx_result: ISubmittableResult;
793
879
  }>;
880
+ /**
881
+ * Retries {@link signAndSend} with exponential backoff, for RPC endpoints that
882
+ * intermittently drop connections or time out mid-submission.
883
+ *
884
+ * @param request Unsigned extrinsic to submit
885
+ * @param account Signing account
886
+ * @param opts Extra signer options, forwarded to `signAndSend` (see its defaults)
887
+ * @param retries Number of retry attempts after the initial try (default 3)
888
+ * @param backoffMs Base delay before the first retry; doubles each subsequent attempt (default 1000)
889
+ */
890
+ declare const retrySignAndSend: (request: SubmittableExtrinsic<"promise">, account: KeyringPair, opts?: Record<string, unknown>, retries?: number, backoffMs?: number) => Promise<{
891
+ blockNumber: number;
892
+ index: number;
893
+ hash: `0x${string}`;
894
+ tx_result: ISubmittableResult;
895
+ }>;
794
896
  declare const getFileMetadataCall: (api: ApiPromise, metadataRef: [number, number]) => Promise<_polkadot_types_types.CallBase<_polkadot_types_types.AnyTuple, _polkadot_types_interfaces.FunctionMetadataLatest>>;
795
897
  declare const getGuardianAddress: () => Promise<{
796
898
  peerid: string;
797
899
  address: string;
798
900
  }[]>;
799
901
  declare const getGuardianNwParams: () => Promise<string>;
902
+ /**
903
+ * Reads back the on-chain record for an agreement/contract created via
904
+ * `createAgreement`, from `compute.contracts`.
905
+ *
906
+ * @param contractId - Hex-encoded agreement ID (as returned by `createAgreement`).
907
+ * @returns The decoded {@link ContractInfo}, or `null` if no contract exists for that ID.
908
+ */
909
+ declare function getContractInfo(contractId: string): Promise<ContractInfo | null>;
800
910
  /**
801
911
  * Fetches the block at `blockHeight`, extracts the extrinsic at
802
912
  * `extrinsicIndex`, and returns both the raw codec object and its human-readable
@@ -808,6 +918,11 @@ declare function fetchAndDecodeExtrinsic(blockHeight: number, extrinsicIndex: nu
808
918
  raw: any;
809
919
  decoded: Record<string, unknown>;
810
920
  }>;
921
+ /**
922
+ * Finds the first event record matching `section`/`method` (case-insensitive)
923
+ * among a transaction's emitted events, e.g. `tx_result.events` from {@link signAndSend}.
924
+ */
925
+ declare function findEvent(events: EventRecord[], section: string, method: string): EventRecord | undefined;
811
926
  type BlockScanFilter = {
812
927
  /** Pallet name, e.g. "dataAvailability" (case-insensitive) */
813
928
  section: string;
@@ -848,6 +963,14 @@ type BlockScanResult = {
848
963
  * @param maxBlocks Reject after scanning this many blocks; pass 0 to wait indefinitely (default 20)
849
964
  */
850
965
  declare const scanForBlockEvent: (api: ApiPromise, filter: BlockScanFilter, startBlock?: number, maxBlocks?: number) => Promise<BlockScanResult>;
966
+ /**
967
+ * Resolves as soon as the next block header is produced. Useful as a plain
968
+ * polling tick, e.g. between rounds of a manual wait loop.
969
+ */
970
+ declare function waitForNextBlock(): Promise<{
971
+ blockNumber: number;
972
+ blockHash: string;
973
+ }>;
851
974
  /**
852
975
  * Subscribes to new block headers and scans each block's extrinsics until a
853
976
  * `compute.result` extrinsic matching `requestId` is found. Resolves with the
@@ -867,6 +990,24 @@ declare function watchForSubmissionReceipt(requestId: string, timeoutMs?: number
867
990
  */
868
991
  declare function getAgreementCreatedRequestId(blockHeight: number, extrinsicIndex: number): Promise<string | null>;
869
992
 
993
+ interface LatestBlock {
994
+ height: number;
995
+ hash: string;
996
+ time: number;
997
+ validator: string;
998
+ eventsCount: number;
999
+ extrinsicsCount: number;
1000
+ }
1001
+ interface LatestBlocksResult {
1002
+ blocks: LatestBlock[];
1003
+ latestHeight: number;
1004
+ }
1005
+ /**
1006
+ * Newest on-chain blocks first, paged backward from the current tip.
1007
+ * Uses RPC rather than the indexer `/api/blocks` list.
1008
+ */
1009
+ declare function getLatestBlocks(count: number, page?: number, apiInstance?: ApiPromise): Promise<LatestBlocksResult>;
1010
+
870
1011
  /**
871
1012
  * Converts a {@link Fee} into the on-chain `fees` / `computeRate` pair.
872
1013
  * `computeRate` only has meaning for `Active` contracts (it drives dynamic
@@ -877,6 +1018,42 @@ declare function buildFee(fee?: Fee): {
877
1018
  fees: bigint;
878
1019
  computeRate: bigint;
879
1020
  };
1021
+ /** Zero `H256` — the `groupId` of a contract that belongs to no guardian group. */
1022
+ declare const NO_GUARDIAN_GROUP: string;
1023
+ /**
1024
+ * Classification carried in `ComputeMetadata.storeType`.
1025
+ *
1026
+ * Mirrors `pallet_compute::StoreType` variant-for-variant via {@link API_TYPES}.
1027
+ * Order is the encoding: the variant index is what goes on the wire, so an
1028
+ * omitted or reordered variant silently shifts every one after it.
1029
+ */
1030
+ type StoreType = keyof typeof API_TYPES.StoreType._enum;
1031
+ interface ComputeMetadataInput {
1032
+ /** Human-readable name of the registered artifact. */
1033
+ name: string;
1034
+ /** Human-readable description of the registered artifact. */
1035
+ description: string;
1036
+ /** What kind of artifact this is. */
1037
+ storeType: StoreType;
1038
+ /**
1039
+ * H256 of the guardian group this entry belongs to. Defaults to
1040
+ * {@link NO_GUARDIAN_GROUP} — correct for plaintext contracts, which have no
1041
+ * group. The chain stores this field but never reads it.
1042
+ */
1043
+ groupId?: string;
1044
+ }
1045
+ /**
1046
+ * Converts a {@link ComputeMetadataInput} into the on-chain `ComputeMetadata`,
1047
+ * whose `name` and `description` are byte vectors rather than strings.
1048
+ * Returns `null` for absent metadata, which is what `Option<ComputeMetadata>`
1049
+ * expects.
1050
+ */
1051
+ declare function buildComputeMetadata(metadata?: ComputeMetadataInput): {
1052
+ name: number[];
1053
+ description: number[];
1054
+ storeType: "Dataset" | "Model" | "Agent" | "Executable" | "Other";
1055
+ groupId: string;
1056
+ } | null;
880
1057
  interface ComputeContract {
881
1058
  contractType: "Active" | "Dormant";
882
1059
  guardians: GuardianAddress[];
@@ -884,6 +1061,8 @@ interface ComputeContract {
884
1061
  compute: Record<string, unknown>;
885
1062
  postCheck?: unknown;
886
1063
  resultCipher: unknown;
1064
+ /** Currency the deposit is reserved in and settlement is paid out in. Defaults to "Native". */
1065
+ currencyId?: CurrencyId;
887
1066
  }
888
1067
  declare function createAgreement(contract: ComputeContract, account: KeyringPair, oracle_quore_id?: string | undefined): Promise<{
889
1068
  blockNumber: number;
@@ -891,6 +1070,26 @@ declare function createAgreement(contract: ComputeContract, account: KeyringPair
891
1070
  hash: string;
892
1071
  agreementId?: string;
893
1072
  }>;
1073
+ interface InvokeAgreementInput {
1074
+ /** Guardian account IDs handling the invocation; matches the agreement's guardian set. */
1075
+ guardians: GuardianAddress[];
1076
+ /** Cipher suite describing how `data` is encrypted. Use "Plaintext" for unencrypted payloads. */
1077
+ cipher: unknown;
1078
+ /** Invocation payload bytes (already encrypted if `cipher` is not "Plaintext"). */
1079
+ data: Uint8Array | number[];
1080
+ }
1081
+ /**
1082
+ * Invokes an existing `Subscription`-type agreement with a new payload, via
1083
+ * `compute.invoke`.
1084
+ *
1085
+ * @param agreementId - Hex-encoded agreement ID (as returned by `createAgreement`).
1086
+ */
1087
+ declare function invokeAgreement(agreementId: string, input: InvokeAgreementInput, account: KeyringPair, opts?: Record<string, unknown>): Promise<{
1088
+ blockNumber: number;
1089
+ index: number;
1090
+ hash: `0x${string}`;
1091
+ tx_result: _polkadot_types_types.ISubmittableResult;
1092
+ }>;
894
1093
  declare function createSimpleAgreement(): Promise<{
895
1094
  blockNumber: number;
896
1095
  index: number;
@@ -899,8 +1098,13 @@ declare function createSimpleAgreement(): Promise<{
899
1098
  }>;
900
1099
 
901
1100
  interface DataContractParams {
902
- /** URL pointing to the data to store. */
903
- url: string;
1101
+ /** URL pointing to the data to store. Mutually exclusive with `data`. */
1102
+ url?: string;
1103
+ /**
1104
+ * Bytes carried in the extrinsic itself, for payloads small enough not to
1105
+ * warrant off-chain hosting. Mutually exclusive with `url`.
1106
+ */
1107
+ data?: string | Uint8Array;
904
1108
  /** Guardian account IDs that participate in this contract. */
905
1109
  guardians: string[];
906
1110
  /**
@@ -909,6 +1113,13 @@ interface DataContractParams {
909
1113
  * compute rate only applies to `Active` contracts.
910
1114
  */
911
1115
  fee: Fee;
1116
+ /**
1117
+ * Describes the registered artifact — name, description, and the `storeType`
1118
+ * saying what kind of thing it is. Omitted metadata registers the contract
1119
+ * anonymously, which leaves nothing on-chain to tell a stored dataset from a
1120
+ * stored program.
1121
+ */
1122
+ metadata?: ComputeMetadataInput;
912
1123
  /** Block number deadline. Defaults to 0 (no deadline). */
913
1124
  deadline?: number;
914
1125
  /** Trusted guardian index in the guardians list. Defaults to 0. */
@@ -919,9 +1130,15 @@ interface DataContractParams {
919
1130
  *
920
1131
  * - No encryption (Plaintext cipher suite)
921
1132
  * - Trusted confidentiality mode
922
- * - Input fetched from a URL
1133
+ * - Input fetched from a URL, or carried inline in the extrinsic
923
1134
  * - No pre-check or post-check verifications
924
1135
  * - Plain (unencrypted) result
1136
+ *
1137
+ * The artifact goes in `compute.input` and `compute.program` stays inert: a
1138
+ * `Dormant` contract registers something rather than running it. A later
1139
+ * `Active` contract reaches this artifact with `{ ContractId: { id } }`, in
1140
+ * either its own `input` or its `program`, and pays this contract's owner the
1141
+ * `fee` offered here as the usage price.
925
1142
  */
926
1143
  declare function dataContract(params: DataContractParams, account: KeyringPair): Promise<{
927
1144
  blockNumber: number;
@@ -930,6 +1147,146 @@ declare function dataContract(params: DataContractParams, account: KeyringPair):
930
1147
  agreementId?: string;
931
1148
  }>;
932
1149
 
1150
+ /**
1151
+ * The chain-side parameters the compute fee floor is derived from.
1152
+ *
1153
+ * All four are read live: the first three are root-settable storage values
1154
+ * (`compute.setMaxDaStorageSize`, `setProviderStorageRate`,
1155
+ * `setThresholdDecryptionFee`), so a hard-coded copy goes stale silently and
1156
+ * surfaces only as an `InsufficientFreeBalance` at submission time.
1157
+ */
1158
+ interface FeeParams {
1159
+ /** Bytes of DA storage a result is priced against. */
1160
+ maxDaStorageSize: bigint;
1161
+ /** Price per byte of DA storage, in atomic units. */
1162
+ providerStorageRate: bigint;
1163
+ /** Flat fee split between the contract's guardians, in atomic units. */
1164
+ thresholdDecryptionFee: bigint;
1165
+ /** Block time in milliseconds, the multiplier applied to `computeRate`. */
1166
+ millisecondsPerBlock: bigint;
1167
+ }
1168
+ interface MinFeeInput {
1169
+ /** Per-millisecond compute rate the contract offers, in PALI. */
1170
+ computeRate: PaliAmountInput;
1171
+ /** Contract ID supplying the input, whose owner is owed the input fee. */
1172
+ inputContractId?: string;
1173
+ }
1174
+ /** The fee floor and the four components it is built from, all in atomic units. */
1175
+ interface MinFeeBreakdown {
1176
+ /** `maxDaStorageSize * providerStorageRate` — pays whoever submits the result. */
1177
+ resultFee: bigint;
1178
+ /** `usagePrice` of the referenced input contract, or 0 when none is referenced. */
1179
+ inputFee: bigint;
1180
+ /** Flat threshold-decryption fee, split between the contract's guardians. */
1181
+ thresholdDecryptionFee: bigint;
1182
+ /** `computeRate * millisecondsPerBlock` — one block's worth of compute. */
1183
+ offeredComponent: bigint;
1184
+ /** The sum: the smallest `fees` the chain accepts for this contract. */
1185
+ minFee: bigint;
1186
+ }
1187
+ /**
1188
+ * Reads the four live chain parameters that define the compute fee floor.
1189
+ *
1190
+ * Throws when the connected runtime predates the metered-compute upgrade: older
1191
+ * runtimes expose a `compute` pallet with neither these storage items nor the
1192
+ * `Contract`-shaped `agreement` call, so there is no fee floor to report.
1193
+ */
1194
+ declare function getFeeParams(): Promise<FeeParams>;
1195
+ /**
1196
+ * Computes the smallest `fees` an `Active` or `Subscription` contract may offer.
1197
+ *
1198
+ * Mirrors `pallet_compute::Pallet::fee_components`, which `CheckCompute` enforces
1199
+ * when validating the extrinsic and which `compute.result` settles against. An
1200
+ * offer below this floor is rejected as `InsufficientFreeBalance` before the
1201
+ * agreement is ever included in a block.
1202
+ *
1203
+ * Clearing this floor is necessary but not sufficient: guardians independently
1204
+ * reject an agreement whose `computeRate` is under their own per-compute-type
1205
+ * threshold. See CHAIN-RULES.md ("Two gates, not one").
1206
+ *
1207
+ * `Dormant` contracts reserve nothing and are exempt — they may offer any `fees`,
1208
+ * including zero.
1209
+ */
1210
+ declare function estimateMinFee(input: MinFeeInput): Promise<MinFeeBreakdown>;
1211
+
1212
+ interface EncryptedInferenceSubscriptionParams {
1213
+ /** Guardian account addresses that participate in this compute. */
1214
+ guardians: string[];
1215
+ /** Fee offered for the compute step. Defaults to 0. */
1216
+ fee?: Fee;
1217
+ /** Block number deadline. Defaults to 0 (no deadline). */
1218
+ deadline?: number;
1219
+ }
1220
+ interface EncryptedInferenceSubscriptionInvocationParams {
1221
+ /** Hex-encoded agreement ID returned by encryptedInferenceSubscription. */
1222
+ agreementId: string;
1223
+ /** Input payload to encrypt and submit. String is UTF-8 encoded. */
1224
+ input: Uint8Array | string;
1225
+ /** Guardian addresses to route the compute request to. */
1226
+ guardians: string[];
1227
+ /** Guardian group cryptographic parameters for threshold encryption. */
1228
+ guardianInfo: GuardianGroupInfo;
1229
+ }
1230
+ interface EncryptedInferenceComputeParams {
1231
+ /** Input payload to encrypt and submit. String is UTF-8 encoded. */
1232
+ input: Uint8Array | string;
1233
+ /** Guardian account addresses that participate in this compute. */
1234
+ guardians: string[];
1235
+ /** Guardian group cryptographic parameters for threshold encryption. */
1236
+ guardianInfo: GuardianGroupInfo;
1237
+ /** Fee offered for the compute step. Defaults to 0. */
1238
+ fee?: Fee;
1239
+ /** Block number deadline. Defaults to 0 (no deadline). */
1240
+ deadline?: number;
1241
+ }
1242
+ /**
1243
+ * Creates a Dormant agreement that registers encrypted inference compute terms.
1244
+ * The agreement ID returned here is passed to encryptedInferenceSubscriptionInvocation
1245
+ * for each subsequent encrypted inference call.
1246
+ */
1247
+ declare function encryptedInferenceSubscription(params: EncryptedInferenceSubscriptionParams, account: KeyringPair): Promise<{
1248
+ blockNumber: number;
1249
+ index: number;
1250
+ hash: string;
1251
+ agreementId?: string;
1252
+ }>;
1253
+ /**
1254
+ * Invokes an existing encrypted inference subscription agreement with a
1255
+ * threshold-encrypted input payload. The result is encrypted back to encAccount.
1256
+ *
1257
+ * @param params - Agreement ID, input payload, guardians, and guardian group crypto params.
1258
+ * @param encAccount - Ed25519 keypair whose public key is used to receive the encrypted result.
1259
+ * @param account - Keypair used to sign and submit the transaction.
1260
+ */
1261
+ declare function encryptedInferenceSubscriptionInvocation(params: EncryptedInferenceSubscriptionInvocationParams, encAccount: KeyringPair, account: KeyringPair): Promise<{
1262
+ blockNumber: number;
1263
+ index: number;
1264
+ hash: `0x${string}`;
1265
+ tx_result: _polkadot_types_types.ISubmittableResult;
1266
+ }>;
1267
+ /**
1268
+ * Convenience wrapper: creates an encrypted inference subscription then
1269
+ * immediately invokes it with the given input. Returns both receipts.
1270
+ *
1271
+ * @param params - Input payload, guardians, guardian group crypto params, and fee.
1272
+ * @param encAccount - Ed25519 keypair whose public key is used to receive the encrypted result.
1273
+ * @param account - Keypair used to sign and submit both transactions.
1274
+ */
1275
+ declare function encryptedInferenceCompute(params: EncryptedInferenceComputeParams, encAccount: KeyringPair, account: KeyringPair): Promise<{
1276
+ subscription: {
1277
+ blockNumber: number;
1278
+ index: number;
1279
+ hash: string;
1280
+ agreementId?: string;
1281
+ };
1282
+ invocation: {
1283
+ blockNumber: number;
1284
+ index: number;
1285
+ hash: `0x${string}`;
1286
+ tx_result: _polkadot_types_types.ISubmittableResult;
1287
+ };
1288
+ }>;
1289
+
933
1290
  interface InferenceComputeParams {
934
1291
  /** Raw input data — string will be UTF-8 encoded, Uint8Array used as-is. */
935
1292
  input: Uint8Array | string;
@@ -1003,6 +1360,261 @@ declare function simpleCompute(params: SimpleComputeParams, account: KeyringPair
1003
1360
  agreementId?: string;
1004
1361
  }>;
1005
1362
 
1363
+ interface StoredComputeParams {
1364
+ /** Guardian account IDs that participate in this compute. */
1365
+ guardians: string[];
1366
+ /** Contract ID of the `Dormant` contract registering the program. */
1367
+ programContractId: string;
1368
+ /** Contract ID of the `Dormant` contract registering the input data. */
1369
+ inputContractId: string;
1370
+ /**
1371
+ * Fee offered for the compute step. Must clear the floor returned by
1372
+ * `estimateMinFee({ computeRate, inputContractId })` — referencing a stored
1373
+ * input raises that floor by the input contract's usage price.
1374
+ */
1375
+ fee: Fee;
1376
+ /** Describes this execution. Unlike the contracts it references, it registers
1377
+ * nothing — so `storeType` is `"Other"` unless the run itself produces a
1378
+ * classifiable artifact. */
1379
+ metadata?: ComputeMetadataInput;
1380
+ /** Block number deadline for the compute step. Defaults to 0 (no deadline). */
1381
+ deadline?: number;
1382
+ /** Trusted guardian index in the guardians list. Defaults to 0. */
1383
+ trustIndex?: number;
1384
+ }
1385
+ /**
1386
+ * Submits an `Active` agreement whose program and input both live in contracts
1387
+ * already registered on-chain.
1388
+ *
1389
+ * Where {@link simpleCompute} carries the program as a URL and the input as a
1390
+ * block coordinate, this points at two `Dormant` contracts instead. Each
1391
+ * `{ ContractId: { id } }` resolves to that contract's `compute.input` — the
1392
+ * field {@link dataContract} stores an artifact in — so the program contract
1393
+ * supplies the image and the input contract supplies the data.
1394
+ *
1395
+ * Only the `input` reference is billed: settlement pays the input contract's
1396
+ * owner its `usage_price`, which is why that ID is also what
1397
+ * `estimateMinFee` needs to quote the floor.
1398
+ */
1399
+ declare function storedCompute(params: StoredComputeParams, account: KeyringPair): Promise<{
1400
+ blockNumber: number;
1401
+ index: number;
1402
+ hash: string;
1403
+ agreementId?: string;
1404
+ }>;
1405
+
1406
+ /** Thrown for any non-2xx response from the cost estimation service. */
1407
+ declare class CostEstimationError extends Error {
1408
+ readonly status: number;
1409
+ constructor(message: string, status: number);
1410
+ }
1411
+
1412
+ /** Confidentiality mode a compute contract requires guardians to support. */
1413
+ type ComputeMode = "Trusted" | "TEE" | "MPC" | "FHE" | "ZKP";
1414
+ /** Request body for {@link startEstimate} (`POST /estimate`). */
1415
+ interface ContractParams {
1416
+ /** Confidentiality mode eligible guardians must support. */
1417
+ computeMode: ComputeMode;
1418
+ /** Drives duration prediction. Omit to fall back to the service's default duration. */
1419
+ programRef?: string;
1420
+ /** Existing on-chain contract id. Omit to zero the input-fee component of the estimate. */
1421
+ contractId?: string;
1422
+ }
1423
+ /** A guardian entry as returned in an estimate's eligible set. */
1424
+ interface GuardianEntry {
1425
+ address: string;
1426
+ pubKey: string;
1427
+ /** On-chain reserve rate, in atomic units. */
1428
+ feeThreshold: bigint;
1429
+ }
1430
+ /** Resolved outcome of a `"completed"` estimate. */
1431
+ interface EstimateResult {
1432
+ predictedDurationMs: number;
1433
+ /** Winning auctioned rate, in atomic units. */
1434
+ auctionedRate: bigint;
1435
+ /** `resultFee + inputFee + thresholdDecryptionFee + auctionedRate * predictedDurationMs`. */
1436
+ estimatedCost: bigint;
1437
+ /** Full eligible guardian set at auction start, not just the winner. */
1438
+ guardians: GuardianEntry[];
1439
+ }
1440
+ /** Response from {@link getEstimateResult} (`GET /estimates/:id`). */
1441
+ type EstimateStatusResponse = {
1442
+ status: "pending";
1443
+ auctionId: string;
1444
+ } | {
1445
+ status: "completed";
1446
+ auctionId: string;
1447
+ result: EstimateResult;
1448
+ } | {
1449
+ status: "failed";
1450
+ auctionId: string;
1451
+ error: string;
1452
+ };
1453
+ /** An auction currently open (unresolved), as listed by `GET /auctions` and friends. */
1454
+ interface OpenAuction {
1455
+ auctionId: string;
1456
+ contractId: string;
1457
+ guardians: string[];
1458
+ /** Auction resolution deadline, epoch ms. */
1459
+ deadline: number;
1460
+ }
1461
+ /** The winning bid on a resolved auction. */
1462
+ interface AuctionWinner {
1463
+ guardian: string;
1464
+ /** Winning rate, in atomic units. */
1465
+ rate: bigint;
1466
+ }
1467
+ /**
1468
+ * A resolved auction this guardian was eligible for, as returned by
1469
+ * {@link listResolvedGuardianAuctions} (`GET /guardians/:address/auctions?resolved=true`).
1470
+ */
1471
+ interface ResolvedAuction {
1472
+ auctionId: string;
1473
+ contractId: string;
1474
+ guardians: string[];
1475
+ deadline: number;
1476
+ winner: AuctionWinner;
1477
+ }
1478
+ /**
1479
+ * Full detail for a single auction regardless of resolution status, as returned by
1480
+ * {@link getAuction} (`GET /auctions/:id`). A resolved auction is never deleted from
1481
+ * the service's store, only excluded from `GET /auctions` / `GET /guardians/:address/auctions`
1482
+ * — this is the only endpoint that can return its outcome once it has dropped off those lists.
1483
+ */
1484
+ interface AuctionDetail {
1485
+ auctionId: string;
1486
+ contractId: string;
1487
+ guardians: string[];
1488
+ deadline: number;
1489
+ resolved: boolean;
1490
+ /** Present only once `resolved` is `true`. */
1491
+ winner?: AuctionWinner;
1492
+ }
1493
+
1494
+ interface StartedEstimate {
1495
+ estimateId: string;
1496
+ /**
1497
+ * Id of the auction backing this estimate. Usable with {@link getAuction} once a
1498
+ * resolved auction has dropped off `GET /auctions` / `GET /guardians/:address/auctions`
1499
+ * — most callers never need it and can just poll {@link getEstimateResult}.
1500
+ */
1501
+ auctionId: string;
1502
+ }
1503
+ /**
1504
+ * Starts a cost estimate via `POST /estimate`.
1505
+ *
1506
+ * Asynchronous: returns as soon as the rate auction is created, well before it
1507
+ * resolves (~`AUCTION_WINDOW_MS`, 5000ms by default). Poll {@link getEstimateResult}
1508
+ * with the returned id for the outcome, or use {@link waitForEstimate} to do both in
1509
+ * one call.
1510
+ *
1511
+ * Not idempotent — every call starts a brand-new auction with a new id, and can
1512
+ * resolve to a different `estimatedCost` even for identical input.
1513
+ *
1514
+ * @throws {CostEstimationError} 400 if `computeMode` is missing/invalid; 422 if no
1515
+ * guardians are eligible for that mode (do not tight-loop retry).
1516
+ */
1517
+ declare function startEstimate(params: ContractParams): Promise<StartedEstimate>;
1518
+ /**
1519
+ * Fetches the current state of an estimate started via {@link startEstimate}.
1520
+ *
1521
+ * `auctionedRate`, `estimatedCost`, and `feeThreshold` are returned as `bigint` —
1522
+ * never treat them as floating-point numbers.
1523
+ *
1524
+ * @throws {CostEstimationError} 404 if `estimateId` is unrecognized (terminal — a
1525
+ * restart of the service does not invalidate a previously issued id).
1526
+ */
1527
+ declare function getEstimateResult(estimateId: string): Promise<EstimateStatusResponse>;
1528
+ interface WaitForEstimateOptions {
1529
+ /** Milliseconds between polls. Defaults to 5000ms (the service's default auction window). */
1530
+ intervalMs?: number;
1531
+ /** Upper bound on total wait time in milliseconds. Defaults to 60000ms. */
1532
+ timeoutMs?: number;
1533
+ }
1534
+ /**
1535
+ * Starts an estimate and polls {@link getEstimateResult} until it leaves
1536
+ * `"pending"`, spacing requests `intervalMs` apart rather than tight-looping.
1537
+ *
1538
+ * Resolves with the terminal `"completed"` or `"failed"` status. Rejects if
1539
+ * `timeoutMs` elapses first — the estimate keeps running server-side regardless,
1540
+ * and can still be recovered later via {@link getEstimateResult} with the same id.
1541
+ */
1542
+ declare function waitForEstimate(params: ContractParams, options?: WaitForEstimateOptions): Promise<{
1543
+ estimateId: string;
1544
+ status: EstimateStatusResponse;
1545
+ }>;
1546
+
1547
+ /**
1548
+ * Lists currently open (unresolved) auctions via `GET /auctions`, so a guardian can
1549
+ * discover an `auctionId` while it is still running in the background after a
1550
+ * {@link startEstimate} call returned. Only relevant when acting on behalf of a
1551
+ * guardian — a plain cost lookup never needs this.
1552
+ */
1553
+ declare function listOpenAuctions(): Promise<OpenAuction[]>;
1554
+ /**
1555
+ * Same as {@link listOpenAuctions}, pre-filtered server-side (via
1556
+ * `GET /guardians/:address/auctions`) to auctions `guardianAddress` is eligible for.
1557
+ */
1558
+ declare function listGuardianAuctions(guardianAddress: string): Promise<OpenAuction[]>;
1559
+ /**
1560
+ * Looks up a single auction via `GET /auctions/:id`, regardless of resolution status.
1561
+ * A resolved auction is never deleted from the service's store, only excluded from
1562
+ * {@link listOpenAuctions} / {@link listGuardianAuctions} — this is the only way to
1563
+ * retrieve its outcome (including the winning guardian's address) once resolved.
1564
+ *
1565
+ * @throws {CostEstimationError} 404 if `auctionId` is unrecognized — terminal.
1566
+ */
1567
+ declare function getAuction(auctionId: string): Promise<AuctionDetail>;
1568
+ /**
1569
+ * Lists auctions `guardianAddress` was eligible for and that have since resolved, via
1570
+ * `GET /guardians/:address/auctions?resolved=true`. Use this instead of
1571
+ * {@link listGuardianAuctions} (which only ever shows currently open auctions) when
1572
+ * fetching a confirmed auction for a guardian you don't already have an `auctionId`
1573
+ * for — no need to guess the guardian's `computeMode` and start a throwaway estimate.
1574
+ */
1575
+ declare function listResolvedGuardianAuctions(guardianAddress: string): Promise<ResolvedAuction[]>;
1576
+ /**
1577
+ * Submits a signed rate bid into an open auction via `POST /auctions/:id/bid`,
1578
+ * signed with `guardian`'s sr25519 key over the literal string
1579
+ * `${auctionId}:${rate}`, as required by the service.
1580
+ *
1581
+ * Lowest `rate` wins; ties break by earliest submission time, then by
1582
+ * lexicographically smallest address. A guardian that never bids keeps its default
1583
+ * entry — its own on-chain threshold for the compute type this auction was opened
1584
+ * for, which reads as zero when it declared none.
1585
+ *
1586
+ * @param rate - Bid rate as a decimal-integer string, in atomic units.
1587
+ * @throws {CostEstimationError} 422 if the auction is unknown, already closed, or
1588
+ * `guardian` isn't in its eligible set — terminal, do not retry the same bid.
1589
+ */
1590
+ declare function submitAuctionBid(auctionId: string, rate: string, guardian: KeyringPair): Promise<void>;
1591
+
1592
+ /**
1593
+ * Registers a webhook URL for `guardian` via `POST /guardians/:address/webhook`, so
1594
+ * it gets a best-effort push (`{ auctionId, contractId, deadline }`) whenever it's
1595
+ * placed in a new auction, instead of polling {@link listGuardianAuctions}.
1596
+ *
1597
+ * Signed with `guardian`'s sr25519 key over the literal string `webhook:${url}`, as
1598
+ * required by the service — this binds the registration to the exact URL so it
1599
+ * can't be replayed to redirect notifications elsewhere.
1600
+ *
1601
+ * Replaces any previously registered webhook for this guardian; there is no
1602
+ * list/unregister endpoint. Delivery is best-effort and unawaited by the service —
1603
+ * a failed push is only logged server-side, never retried, so don't rely on this as
1604
+ * a substitute for polling if missing an auction would be costly.
1605
+ *
1606
+ * @throws {CostEstimationError} 400 if `url` isn't an absolute http(s) URL; 404 if
1607
+ * `guardian` has no resolvable on-chain guardian entry; 422 if the signature doesn't
1608
+ * verify.
1609
+ */
1610
+ declare function registerGuardianWebhook(url: string, guardian: KeyringPair): Promise<void>;
1611
+
1612
+ /**
1613
+ * Liveness probe via `GET /health`. Does not verify chain connectivity — a healthy
1614
+ * response does not guarantee {@link startEstimate} will succeed.
1615
+ */
1616
+ declare function healthCheck(): Promise<boolean>;
1617
+
1006
1618
  declare const gen_stretched_key: (input: Uint8Array) => Uint8Array<ArrayBufferLike>;
1007
1619
  declare const gen_shared_key: (key: Uint8Array, pk: Uint8Array) => Uint8Array<ArrayBufferLike>;
1008
1620
  declare const encrypt$1: (plaintext: Uint8Array, key: Uint8Array) => {
@@ -1145,7 +1757,7 @@ interface DataAgreementMetadata {
1145
1757
  name: string;
1146
1758
  description: string;
1147
1759
  /** Maps to the on-chain StoreType enum. */
1148
- storeType: "Dataset" | "Model" | "Agent" | "Other";
1760
+ storeType: StoreType;
1149
1761
  /** H256 group identifier. */
1150
1762
  groupId: string;
1151
1763
  }
@@ -1208,6 +1820,16 @@ declare function uploadData(options: UploadOptions): Promise<void>;
1208
1820
  declare function uploadDataLegacy(options: Omit<UploadOptions, "opts">): Promise<void>;
1209
1821
 
1210
1822
  declare const getGuardianList: () => Promise<string[]>;
1823
+ interface ActiveGuardian {
1824
+ account: string;
1825
+ guardianPrefs: Record<string, unknown> | null;
1826
+ stakersOverview: Record<string, unknown> | null;
1827
+ }
1828
+ /**
1829
+ * Current-era on-chain guardians with staking prefs and ledger totals.
1830
+ * Does not disconnect the shared API.
1831
+ */
1832
+ declare function getActiveGuardians(apiInstance?: ApiPromise): Promise<ActiveGuardian[]>;
1211
1833
 
1212
1834
  declare const createGuardianGroup: (account: KeyringPair, selectedGuardians: GuardianAddress[]) => Promise<{
1213
1835
  blockNumber: number;
@@ -1225,10 +1847,43 @@ declare const createGuardianGroup: (account: KeyringPair, selectedGuardians: Gua
1225
1847
  * @param maxBlocks Give up waiting for the event after this many blocks; 0 = indefinite (default 20)
1226
1848
  */
1227
1849
  declare const createGuardianGroupAndWatch: (account: KeyringPair, guardians: GuardianAddress[], maxBlocks?: number) => Promise<GuardianGroupInfo>;
1850
+ /**
1851
+ * Reconstructs a guardian group's full crypto params from the two on-chain
1852
+ * extrinsics that together define it. There is no direct RPC to query group
1853
+ * info by ID, so this reads it back from where it was written:
1854
+ *
1855
+ * - `dataAvailability.daccGuardianGroup(selectedGuardians, tauParams)` — the
1856
+ * creation extrinsic; carries the guardian list.
1857
+ * - `dataAvailability.daccGuardianGroupInfo(groupId, groupPk, tauParams, aggKey)`
1858
+ * — the result extrinsic (submitted separately once the group's crypto
1859
+ * params are computed); carries the actual group_id/group_pk/tau_params/agg_key.
1860
+ *
1861
+ * `groupId` isn't a required input — like {@link createGuardianGroupAndWatch},
1862
+ * it's derived from decoding the result extrinsic, not supplied by the caller.
1863
+ *
1864
+ * @param creationRef Block number + extrinsic index of the group creation extrinsic
1865
+ * @param resultRef Block number + extrinsic index of the group creation result
1866
+ * extrinsic. If omitted, blocks are scanned forward from
1867
+ * `creationRef` to find it (see `maxBlocks`).
1868
+ * @param maxBlocks Only used when `resultRef` is omitted. Give up scanning after
1869
+ * this many blocks; 0 = scan to current chain tip (default 20)
1870
+ */
1871
+ declare const getGuardianGroupInfo: (creationRef: OnChainRef, resultRef?: OnChainRef, maxBlocks?: number) => Promise<GuardianGroupInfo>;
1228
1872
 
1873
+ /** Classes of compute a guardian can declare a fee threshold against. */
1874
+ declare const COMPUTE_TYPES: readonly ["trusted", "tee", "mpc", "fhe", "zkp"];
1875
+ type ComputeType = (typeof COMPUTE_TYPES)[number];
1876
+ /** A rate in atomic units, already converted from PALI by the caller. */
1877
+ type FeeThresholdInput = bigint | string | number;
1229
1878
  interface GuardianJoinPrefs {
1230
1879
  compute?: string;
1231
- fee?: bigint | string | number;
1880
+ /**
1881
+ * Minimum rate to take work on at, in atomic units. A single amount applies to every
1882
+ * compute type named in `compute`; a per-type record prices each one separately.
1883
+ * Compute types left unpriced carry no threshold on chain, which reads as zero — the
1884
+ * guardian accepts any rate for them.
1885
+ */
1886
+ fee?: FeeThresholdInput | Partial<Record<ComputeType, FeeThresholdInput>>;
1232
1887
  standard?: boolean;
1233
1888
  verifier?: boolean;
1234
1889
  }
@@ -1248,6 +1903,36 @@ declare function removeStake(account: KeyringPair): Promise<void>;
1248
1903
 
1249
1904
  declare function withdrawStake(account: KeyringPair): Promise<void>;
1250
1905
 
1906
+ interface StorageProvider {
1907
+ /** Unique identifier for the storage backend (e.g., 's3', 'ipfs') */
1908
+ readonly id: string;
1909
+ /** Generates the deterministic URL where the file will be stored */
1910
+ getDeterministicUrl(hash: string): string;
1911
+ /**
1912
+ * Fetches the authorized upload URL (e.g., a Pre-signed URL) from the Auth Service
1913
+ * after the on-chain agreement has been created.
1914
+ */
1915
+ getUploadUrl(txHash: string, fileHash: string, blockNumber: number, expectedUrl: string): Promise<string>;
1916
+ /** Uploads the raw bytes to the authorized URL */
1917
+ upload(url: string, data: Uint8Array): Promise<void>;
1918
+ }
1919
+
1920
+ declare class S3Provider implements StorageProvider {
1921
+ readonly id = "s3";
1922
+ getDeterministicUrl(hash: string): string;
1923
+ getUploadUrl(txHash: string, fileHash: string, blockNumber: number, expectedUrl: string): Promise<string>;
1924
+ upload(url: string, data: Uint8Array): Promise<void>;
1925
+ }
1926
+
1927
+ declare class StorageRouter {
1928
+ private providers;
1929
+ private defaultProvider;
1930
+ constructor();
1931
+ register(provider: StorageProvider): void;
1932
+ getProvider(id?: string): StorageProvider;
1933
+ }
1934
+ declare const storageRouter: StorageRouter;
1935
+
1251
1936
  declare function fundAccount(account: KeyringPair, amountBaseUnits: bigint, address?: string): Promise<void>;
1252
1937
 
1253
1938
  declare function transfer(account: KeyringPair, amountBaseUnits: bigint, address: string): Promise<void>;
@@ -1311,7 +1996,7 @@ declare const base64ToUint8Array: (base64: string) => Uint8Array;
1311
1996
  declare const decodeField: (field: string, expectedLength?: number) => Uint8Array;
1312
1997
  /**
1313
1998
  * Conditional debug logging utility.
1314
- * Only logs when DEBUG flag is enabled in config.
1999
+ * Only logs when the debug flag is enabled in config.
1315
2000
  *
1316
2001
  * @param message - The message to log
1317
2002
  * @param optionalParams - Additional parameters to log
@@ -1320,24 +2005,684 @@ declare const debugLog: (message?: any, ...optionalParams: any[]) => void;
1320
2005
 
1321
2006
  declare function joinValidator(account: KeyringPair, commission: number): Promise<void>;
1322
2007
 
1323
- declare let PALLIORA_WS: string;
1324
- declare let PALLIORA_RPC_URL: string;
1325
- declare let DEBUG: boolean;
1326
- declare let TX_WAIT_FINALIZATION: boolean;
1327
- declare let provider: WsProvider;
1328
- declare function configure(opts: {
1329
- pallioraWs?: string;
1330
- pallioraRpcUrl?: string;
1331
- debug?: boolean;
1332
- txWaitFinalization?: boolean;
1333
- }): void;
2008
+ /** Values the host application must supply through {@link init}. */
2009
+ interface PallioraConfig {
2010
+ /** WebSocket endpoint used for the chain API connection. */
2011
+ pallioraWs: string;
2012
+ /** RPC endpoint, when it differs from {@link PallioraConfig.pallioraWs}. */
2013
+ pallioraRpcUrl: string;
2014
+ /** Base URL of the cost-estimation service. */
2015
+ costEstimatorUrl: string;
2016
+ /** Base URL of the auth service that issues S3 pre-signed URLs. */
2017
+ authServiceUrl: string;
2018
+ /** AWS region of the artifact storage bucket. */
2019
+ awsRegion: string;
2020
+ /** Name of the artifact storage bucket. */
2021
+ awsS3Bucket: string;
2022
+ /** Enables debug logging. Defaults to `false`. */
2023
+ debug: boolean;
2024
+ /** Waits for finalization instead of returning once a tx is in-block. Defaults to `false`. */
2025
+ txWaitFinalization: boolean;
2026
+ }
2027
+ /**
2028
+ * Initializes the SDK. Call this once, before any other SDK function.
2029
+ *
2030
+ * @remarks
2031
+ * Repeated calls merge into the existing configuration, so a host can supply
2032
+ * the chain endpoint at startup and storage settings later.
2033
+ */
2034
+ declare function init(options: Partial<PallioraConfig>): void;
2035
+ /** Whether {@link init} has been called. */
2036
+ declare function isInitialized(): boolean;
2037
+ /** Clears the configuration. Intended for tests. */
2038
+ declare function resetConfig(): void;
2039
+ /** @throws when `pallioraWs` was not supplied to {@link init}. */
2040
+ declare const getPallioraWs: () => string;
2041
+ /** @throws when `pallioraRpcUrl` was not supplied to {@link init}. */
2042
+ declare const getPallioraRpcUrl: () => string;
2043
+ /** @throws when `costEstimatorUrl` was not supplied to {@link init}. */
2044
+ declare const getCostEstimatorUrl: () => string;
2045
+ /** @throws when `authServiceUrl` was not supplied to {@link init}. */
2046
+ declare const getAuthServiceUrl: () => string;
2047
+ /** @throws when `awsRegion` was not supplied to {@link init}. */
2048
+ declare const getAwsRegion: () => string;
2049
+ /** @throws when `awsS3Bucket` was not supplied to {@link init}. */
2050
+ declare const getAwsS3Bucket: () => string;
2051
+ /** Defaults to `false` when not supplied to {@link init}. */
2052
+ declare const isDebug: () => boolean;
2053
+ /** Defaults to `false` when not supplied to {@link init}. */
2054
+ declare const waitsForFinalization: () => boolean;
2055
+ /**
2056
+ * Returns the shared {@link WsProvider}, creating it on first use and replacing
2057
+ * it whenever `pallioraWs` changes.
2058
+ *
2059
+ * @throws when `pallioraWs` was not supplied to {@link init}.
2060
+ */
2061
+ declare function getProvider(): WsProvider;
1334
2062
 
1335
2063
  interface IdentityFields {
1336
2064
  display?: string;
1337
2065
  }
1338
2066
  declare function setIdentity(account: KeyringPair, { display }: IdentityFields): Promise<void>;
1339
2067
 
2068
+ interface IndexerClientOptions {
2069
+ /** Base URL of the indexer server (default: `http://localhost:5020`). */
2070
+ baseUrl?: string;
2071
+ /**
2072
+ * Custom fetch implementation. Defaults to the global `fetch`.
2073
+ * Useful for injecting a test double or a polyfill in older Node versions.
2074
+ */
2075
+ fetch?: typeof globalThis.fetch;
2076
+ }
2077
+ /**
2078
+ * Lightweight wrapper around `fetch` that targets the `@statescan/indexer` REST API.
2079
+ *
2080
+ * Every public method on the domain modules receives an `IndexerClient` instance,
2081
+ * keeping configuration (base URL, custom fetch) in one place.
2082
+ *
2083
+ * @example
2084
+ * ```ts
2085
+ * import { IndexerClient } from "@palliora.org/chainsdk";
2086
+ *
2087
+ * const client = new IndexerClient({ baseUrl: "https://indexer.palliora.org" });
2088
+ * ```
2089
+ */
2090
+ declare class IndexerClient {
2091
+ readonly baseUrl: string;
2092
+ private readonly _fetch;
2093
+ constructor(options?: IndexerClientOptions);
2094
+ /**
2095
+ * Performs a GET request against the indexer and returns the parsed JSON body.
2096
+ *
2097
+ * @throws {IndexerHttpError} When the response indicates failure (`success: false`)
2098
+ * or the HTTP status is not 2xx.
2099
+ */
2100
+ get<T>(path: string, params?: Record<string, string | number | boolean | null | undefined>): Promise<T>;
2101
+ }
2102
+ /**
2103
+ * Error thrown when the indexer returns a non-2xx response or an error envelope.
2104
+ */
2105
+ declare class IndexerHttpError extends Error {
2106
+ readonly statusCode: number;
2107
+ constructor(statusCode: number, message: string);
2108
+ }
2109
+
2110
+ /** Common `indexer` subdocument present on most indexed documents. */
2111
+ interface IndexerMeta {
2112
+ blockHeight: number;
2113
+ blockHash: string;
2114
+ blockTime: number;
2115
+ extrinsicIndex: number;
2116
+ eventIndex: number;
2117
+ }
2118
+ /** @deprecated Prefer {@link StoreType}. Kept for backward compatibility. */
2119
+ type ArtefactType = StoreType | "Data";
2120
+ interface ArtefactDocument {
2121
+ contractId: string;
2122
+ creator: string;
2123
+ owner: string;
2124
+ storeType: StoreType | string | null;
2125
+ contractType: string;
2126
+ status?: string;
2127
+ groupId: string | null;
2128
+ name?: string | null;
2129
+ description?: string | null;
2130
+ /** @deprecated Prefer `storeType`. May be absent on newer documents. */
2131
+ artefactType?: ArtefactType;
2132
+ blobRefs?: Array<[number, number] | unknown>;
2133
+ indexer: IndexerMeta;
2134
+ [key: string]: unknown;
2135
+ }
2136
+ interface ArtefactsQuery {
2137
+ /** Server-side filter when supported by the indexer. Prefer client helpers for `storeType`. */
2138
+ artefactType?: ArtefactType;
2139
+ storeType?: StoreType;
2140
+ }
2141
+ interface ArtefactAccessQuery {
2142
+ blockHeight?: number;
2143
+ extrinsicIndex?: number;
2144
+ retriver?: string;
2145
+ }
2146
+ interface ArtefactContractsQuery {
2147
+ blockHeight?: number;
2148
+ extrinsicIndex?: number;
2149
+ retriver?: string;
2150
+ }
2151
+ interface ContractResponse {
2152
+ peerId?: string;
2153
+ acceptance?: boolean;
2154
+ creationTime?: number;
2155
+ [key: string]: unknown;
2156
+ }
2157
+ interface ContractDocument {
2158
+ contractId: string;
2159
+ creator?: string;
2160
+ owner?: string;
2161
+ storeType?: string;
2162
+ contractType?: string;
2163
+ status?: string;
2164
+ groupId?: string;
2165
+ artefactType?: string;
2166
+ parties?: string[];
2167
+ responses?: ContractResponse[];
2168
+ fee?: string | number;
2169
+ creationTime?: number;
2170
+ computeTx?: unknown;
2171
+ indexer?: IndexerMeta;
2172
+ [key: string]: unknown;
2173
+ }
2174
+ interface ContractsQuery {
2175
+ page?: number;
2176
+ page_size?: number;
2177
+ }
2178
+ interface ComputeDocument {
2179
+ jobId?: string;
2180
+ contractId?: string;
2181
+ orchestrator?: string;
2182
+ parties?: string[];
2183
+ resultTx?: unknown;
2184
+ computeReward?: string | number;
2185
+ decryptionFee?: unknown;
2186
+ fee?: string | number;
2187
+ indexer?: IndexerMeta;
2188
+ [key: string]: unknown;
2189
+ }
2190
+ interface ResultFeeParty {
2191
+ recipient?: string;
2192
+ amount?: string;
2193
+ kind?: string;
2194
+ [key: string]: unknown;
2195
+ }
2196
+ interface ResultFeeBreakdown {
2197
+ inputFee?: ResultFeeParty | null;
2198
+ programFee?: ResultFeeParty | null;
2199
+ thresholdDecryptionFee?: unknown;
2200
+ computeFee?: ResultFeeParty | null;
2201
+ submitorFee?: ResultFeeParty | null;
2202
+ resultFee?: string;
2203
+ totalCharged?: string;
2204
+ reservedFee?: string;
2205
+ refundedAmount?: string;
2206
+ [key: string]: unknown;
2207
+ }
2208
+ /** One execution stored in `palliora-compute.results`. */
2209
+ interface ResultDocument {
2210
+ resultId: string;
2211
+ contractId: string;
2212
+ contractType?: string;
2213
+ submitor?: string;
2214
+ computeDurationMs?: number;
2215
+ executionOutcome?: unknown;
2216
+ feeBreakdown?: ResultFeeBreakdown;
2217
+ indexer?: IndexerMeta;
2218
+ [key: string]: unknown;
2219
+ }
2220
+ interface ResultsQuery {
2221
+ /** Filter `palliora-compute.results` by parent contract. Required by the indexer. */
2222
+ contractId: string;
2223
+ }
2224
+ type ContractFlowStatus = "PENDING" | "ACCEPTED" | "PROCESSING" | "COMPLETED";
2225
+ interface ContractFlowPhase {
2226
+ id: "phase-1" | "phase-2" | "phase-3" | "phase-4" | "phase-5";
2227
+ title: string;
2228
+ status: string;
2229
+ description: string;
2230
+ json: Record<string, unknown>;
2231
+ active: boolean;
2232
+ complete: boolean;
2233
+ pending: boolean;
2234
+ }
2235
+ /** Combined compute-contract lifecycle assembled from `/api/contract/:id` + `/api/compute/:id` + `/api/results`. */
2236
+ interface ContractFlow {
2237
+ agreement: ContractDocument;
2238
+ /** Latest compute request, if any. Prefer {@link ContractFlow.computes} for session flows. */
2239
+ compute: ComputeDocument | null;
2240
+ /** Every compute request on this agreement, oldest first. */
2241
+ computes: ComputeDocument[];
2242
+ /** Execution rows from `palliora-compute.results` for this contract. */
2243
+ results: ResultDocument[];
2244
+ status: ContractFlowStatus;
2245
+ phases: ContractFlowPhase[];
2246
+ }
2247
+ /** Combined artefact + access + blobs for a dataset/model/agent detail page. */
2248
+ interface ArtefactFlow {
2249
+ artefact: ArtefactDocument;
2250
+ access: unknown[];
2251
+ blobs: BlobDocument[];
2252
+ }
2253
+ interface BlockDocument {
2254
+ height: number;
2255
+ hash: string;
2256
+ time: number;
2257
+ validator?: string;
2258
+ parentHash?: string;
2259
+ stateRoot?: string;
2260
+ extrinsicsRoot?: string;
2261
+ eventsCount?: number;
2262
+ extrinsicsCount?: number;
2263
+ [key: string]: unknown;
2264
+ }
2265
+ /** Payload inside `GET /api/blocks` — `{ data: { blocks, stats } }`. */
2266
+ interface BlocksData {
2267
+ blocks: BlockDocument[];
2268
+ stats?: Record<string, unknown>;
2269
+ [key: string]: unknown;
2270
+ }
2271
+ interface BlocksQuery {
2272
+ page?: number;
2273
+ page_size?: number;
2274
+ }
2275
+ interface CallDocument {
2276
+ [key: string]: unknown;
2277
+ }
2278
+ interface CallQuery {
2279
+ blockHeight: number;
2280
+ extrinsicIndex: number;
2281
+ }
2282
+ interface CallMetadataDocument {
2283
+ [key: string]: unknown;
2284
+ }
2285
+ interface CallMetadataQuery {
2286
+ blockHeight: number;
2287
+ extrinsicIndex: number;
2288
+ }
2289
+ interface CallArgsDocument {
2290
+ [key: string]: unknown;
2291
+ }
2292
+ interface CallArgsQuery {
2293
+ metadataHash: string;
2294
+ }
2295
+ interface TransferDocument {
2296
+ indexer: IndexerMeta;
2297
+ [key: string]: unknown;
2298
+ }
2299
+ interface TransfersQuery {
2300
+ page?: number;
2301
+ page_size?: number;
2302
+ }
2303
+ interface ExtrinsicDocument {
2304
+ indexer: {
2305
+ blockHeight: number;
2306
+ extrinsicIndex: number;
2307
+ blockHash?: string;
2308
+ blockTime?: number;
2309
+ eventIndex?: number;
2310
+ };
2311
+ hash: string;
2312
+ isSigned: boolean;
2313
+ [key: string]: unknown;
2314
+ }
2315
+ interface ExtrinsicsQuery {
2316
+ page?: number;
2317
+ page_size?: number;
2318
+ /** Set to `"true"` to return only signed extrinsics. */
2319
+ signed_only?: "true" | "false" | boolean;
2320
+ }
2321
+ interface AddressDocument {
2322
+ address: string;
2323
+ balance: string | number;
2324
+ [key: string]: unknown;
2325
+ }
2326
+ interface BlobDocument {
2327
+ indexer: IndexerMeta;
2328
+ [key: string]: unknown;
2329
+ }
2330
+ /**
2331
+ * Identity-enriched guardian from `GET /api/guardian-groups`.
2332
+ * `displayName` is the on-chain identity display, or `null` if none is set.
2333
+ */
2334
+ interface GuardianDocument {
2335
+ account: string;
2336
+ displayName: string | null;
2337
+ }
2338
+ interface GuardianGroupDocument {
2339
+ groupId: string;
2340
+ creator?: string;
2341
+ guardians: string[];
2342
+ /**
2343
+ * Parallel to {@link GuardianGroupDocument.guardians}.
2344
+ * Identity display name for each address, or `null` if unset.
2345
+ */
2346
+ guardianNames: Array<string | null>;
2347
+ groupPk?: string;
2348
+ tauParams?: string;
2349
+ aggKey?: string;
2350
+ status?: string;
2351
+ success?: boolean;
2352
+ indexer?: IndexerMeta;
2353
+ creationTime?: number;
2354
+ [key: string]: unknown;
2355
+ }
2356
+ interface GuardianGroupsQuery {
2357
+ guardian?: string;
2358
+ }
2359
+ interface AccessDocument {
2360
+ [key: string]: unknown;
2361
+ }
2362
+ interface AccessQuery {
2363
+ blockHeight?: number;
2364
+ extrinsicIndex?: number;
2365
+ retriver?: string;
2366
+ }
2367
+ /** Standard success response: `{ success: true, data: T }`. */
2368
+ interface SuccessResponse<T> {
2369
+ success: true;
2370
+ data: T;
2371
+ }
2372
+ /** Paginated success response: `{ success: true, data: T[], total: number }`. */
2373
+ interface PaginatedResponse<T> {
2374
+ success: true;
2375
+ data: T[];
2376
+ total: number;
2377
+ }
2378
+ /** Access-style success response: `{ success: true, data: T[], message: string }`. */
2379
+ interface AccessResponse<T> {
2380
+ success: true;
2381
+ data: T[];
2382
+ message: string;
2383
+ }
2384
+ /** Address-style response (no `success` flag): `{ data: T }`. */
2385
+ interface DataOnlyResponse<T> {
2386
+ data: T;
2387
+ }
2388
+ /** Error response from the indexer. */
2389
+ interface ErrorResponse {
2390
+ success: false;
2391
+ message: string;
2392
+ }
2393
+
2394
+ /**
2395
+ * Fetch all artefacts, optionally filtered by type.
2396
+ *
2397
+ * `GET /api/artefacts`
2398
+ *
2399
+ * For UI categorization by `storeType`, prefer the dedicated helpers:
2400
+ * {@link getDatasets}, {@link getModels}, {@link getAgents}, {@link getExecutables}.
2401
+ *
2402
+ * @param client Configured {@link IndexerClient}
2403
+ * @param query Optional filter — `storeType` / `artefactType`
2404
+ * @returns `{ success: true, data: ArtefactDocument[] }`
2405
+ */
2406
+ declare function getArtefacts(client: IndexerClient, query?: ArtefactsQuery): Promise<SuccessResponse<ArtefactDocument[]>>;
2407
+ /**
2408
+ * Fetch artefacts filtered by `storeType`.
2409
+ *
2410
+ * Loads `/api/artefacts` and filters client-side so results are reliable even when
2411
+ * the indexer ignores the `storeType` query param.
2412
+ */
2413
+ declare function getArtefactsByStoreType(client: IndexerClient, storeType: StoreType): Promise<SuccessResponse<ArtefactDocument[]>>;
2414
+ /** Fetch artefacts with `storeType: "Dataset"`. */
2415
+ declare function getDatasets(client: IndexerClient): Promise<SuccessResponse<ArtefactDocument[]>>;
2416
+ /** Fetch artefacts with `storeType: "Model"`. */
2417
+ declare function getModels(client: IndexerClient): Promise<SuccessResponse<ArtefactDocument[]>>;
2418
+ /** Fetch artefacts with `storeType: "Agent"`. */
2419
+ declare function getAgents(client: IndexerClient): Promise<SuccessResponse<ArtefactDocument[]>>;
2420
+ /** Fetch artefacts with `storeType: "Executable"`. */
2421
+ declare function getExecutables(client: IndexerClient): Promise<SuccessResponse<ArtefactDocument[]>>;
2422
+ /**
2423
+ * Fetch a single artefact by its contract ID.
2424
+ *
2425
+ * `GET /api/artefact/:id`
2426
+ *
2427
+ * @param client Configured {@link IndexerClient}
2428
+ * @param id The `contractId` of the artefact
2429
+ */
2430
+ declare function getArtefact(client: IndexerClient, id: string): Promise<SuccessResponse<ArtefactDocument>>;
2431
+ /**
2432
+ * Fetch access records for a specific artefact.
2433
+ *
2434
+ * `GET /api/artefact/:id/access`
2435
+ *
2436
+ * @param client Configured {@link IndexerClient}
2437
+ * @param id The `contractId` of the artefact
2438
+ * @param query Optional filters — `blockHeight`, `extrinsicIndex`, `retriver`
2439
+ */
2440
+ declare function getArtefactAccess(client: IndexerClient, id: string, query?: ArtefactAccessQuery): Promise<SuccessResponse<unknown[]>>;
2441
+ /** True when `doc` is a compute contract that references this artefact. */
2442
+ declare function isArtefactUsage(doc: Record<string, unknown> | null | undefined, artefactId: string): boolean;
2443
+ /**
2444
+ * Fetch compute contracts that use this artefact as input or program.
2445
+ *
2446
+ * `GET /api/artefact/:id/contracts`
2447
+ *
2448
+ * Older indexers returned the artefact document itself. In that case this
2449
+ * helper scans `/api/artefacts` and keeps rows that reference the artefact.
2450
+ *
2451
+ * @param client Configured {@link IndexerClient}
2452
+ * @param id The artefact `contractId`
2453
+ * @param query Optional filters — `blockHeight`, `extrinsicIndex`, `retriver`
2454
+ */
2455
+ declare function getArtefactContracts(client: IndexerClient, id: string, query?: ArtefactContractsQuery): Promise<SuccessResponse<unknown[]>>;
2456
+
2457
+ /**
2458
+ * Fetch a paginated list of contracts.
2459
+ *
2460
+ * `GET /api/contracts`
2461
+ *
2462
+ * @param client Configured {@link IndexerClient}
2463
+ * @param query Pagination — `page` (0-indexed), `page_size` (default 25)
2464
+ * @returns `{ success: true, data: ContractDocument[], total: number }`
2465
+ */
2466
+ declare function getContracts(client: IndexerClient, query?: ContractsQuery): Promise<PaginatedResponse<ContractDocument>>;
2467
+ /**
2468
+ * Fetch a single contract by its ID.
2469
+ *
2470
+ * `GET /api/contract/:id`
2471
+ *
2472
+ * @param client Configured {@link IndexerClient}
2473
+ * @param id The contract identifier
2474
+ */
2475
+ declare function getContract(client: IndexerClient, id: string): Promise<SuccessResponse<ContractDocument>>;
2476
+ /**
2477
+ * Fetch compute request data for a specific contract.
2478
+ *
2479
+ * `GET /api/compute/:id`
2480
+ *
2481
+ * @param client Configured {@link IndexerClient}
2482
+ * @param id The contract identifier
2483
+ */
2484
+ declare function getCompute(client: IndexerClient, id: string): Promise<SuccessResponse<ComputeDocument>>;
2485
+ /**
2486
+ * Fetch compute results for a contract from `palliora-compute.results`.
2487
+ *
2488
+ * `GET /api/results?contractId=`
2489
+ */
2490
+ declare function getResults(client: IndexerClient, query: ResultsQuery): Promise<SuccessResponse<ResultDocument[]>>;
2491
+ /**
2492
+ * Fetch a single compute result by `resultId`.
2493
+ *
2494
+ * `GET /api/result/:id`
2495
+ */
2496
+ declare function getResult(client: IndexerClient, id: string): Promise<SuccessResponse<ResultDocument>>;
2497
+
2498
+ type ComputeInput = ComputeDocument | ComputeDocument[] | null | undefined;
2499
+ declare function normalizeComputes(compute: ComputeInput): ComputeDocument[];
2500
+ /**
2501
+ * Map a `palliora-compute.results` row onto the compute-request shape used by
2502
+ * session phases (jobId, orchestrator, resultTx, fees).
2503
+ */
2504
+ declare function resultToCompute(result: ResultDocument): ComputeDocument;
2505
+ declare function deriveContractStatus(agreement: ContractDocument | null | undefined, compute: ComputeInput): ContractFlowStatus | "—";
2506
+ declare function buildContractPhases(agreement: ContractDocument | null | undefined, compute: ComputeInput): ContractFlowPhase[];
2507
+ /**
2508
+ * Fetch a compute contract, optional `/api/compute/:id` payload, and
2509
+ * `palliora-compute.results` rows, then derive session lifecycle status and
2510
+ * the five UI phases used by the explorer.
2511
+ *
2512
+ * Missing compute (`404`) or results (`404`) is treated as empty.
2513
+ */
2514
+ declare function getContractFlow(client: IndexerClient, id: string): Promise<SuccessResponse<ContractFlow>>;
2515
+ /**
2516
+ * Fetch an artefact together with its access records and blobs.
2517
+ *
2518
+ * Missing access (`404`) becomes `[]`. Missing blobs are skipped.
2519
+ */
2520
+ declare function getArtefactFlow(client: IndexerClient, id: string, accessQuery?: ArtefactAccessQuery): Promise<SuccessResponse<ArtefactFlow>>;
2521
+
2522
+ /**
2523
+ * Fetch a paginated list of blocks, including chain stats.
2524
+ *
2525
+ * `GET /api/blocks`
2526
+ *
2527
+ * Response shape: `{ success: true, data: { blocks: BlockDocument[], stats? } }`
2528
+ *
2529
+ * @param client Configured {@link IndexerClient}
2530
+ * @param query Pagination — `page` (0-indexed), `page_size`
2531
+ */
2532
+ declare function getBlocks(client: IndexerClient, query?: BlocksQuery): Promise<SuccessResponse<BlocksData>>;
2533
+
2534
+ /**
2535
+ * Fetch a call by block height and extrinsic index.
2536
+ *
2537
+ * `GET /api/call`
2538
+ *
2539
+ * @param client Configured {@link IndexerClient}
2540
+ * @param query **Required** — `blockHeight` and `extrinsicIndex`
2541
+ */
2542
+ declare function getCall(client: IndexerClient, query: CallQuery): Promise<SuccessResponse<CallDocument>>;
2543
+ /**
2544
+ * Fetch call metadata by block height and extrinsic index.
2545
+ *
2546
+ * `GET /api/call-metadata`
2547
+ *
2548
+ * @param client Configured {@link IndexerClient}
2549
+ * @param query **Required** — `blockHeight` and `extrinsicIndex`
2550
+ */
2551
+ declare function getCallMetadata(client: IndexerClient, query: CallMetadataQuery): Promise<SuccessResponse<CallMetadataDocument>>;
2552
+ /**
2553
+ * Fetch call arguments by metadata hash.
2554
+ *
2555
+ * `GET /api/call-args`
2556
+ *
2557
+ * @param client Configured {@link IndexerClient}
2558
+ * @param query **Required** — `metadataHash`
2559
+ */
2560
+ declare function getCallArgs(client: IndexerClient, query: CallArgsQuery): Promise<SuccessResponse<CallArgsDocument>>;
2561
+
2562
+ /**
2563
+ * Fetch a paginated list of transfers, sorted by block height descending.
2564
+ *
2565
+ * `GET /api/transfers`
2566
+ *
2567
+ * @param client Configured {@link IndexerClient}
2568
+ * @param query Pagination — `page` (0-indexed), `page_size`
2569
+ */
2570
+ declare function getTransfers(client: IndexerClient, query?: TransfersQuery): Promise<SuccessResponse<TransferDocument[]>>;
2571
+
2572
+ /**
2573
+ * Fetch a paginated list of extrinsics, sorted by block height descending.
2574
+ *
2575
+ * `GET /api/extrinsics`
2576
+ *
2577
+ * Fields `nonce`, `_id`, `tip`, and `signature` are excluded by the indexer.
2578
+ *
2579
+ * @param client Configured {@link IndexerClient}
2580
+ * @param query Pagination — `page` (0-indexed, default 0), `page_size` (default 10, max 100);
2581
+ * `signed_only: true` filters to signed extrinsics only
2582
+ * @returns `{ success: true, data: ExtrinsicDocument[], total: number }`
2583
+ */
2584
+ declare function getExtrinsics(client: IndexerClient, query?: ExtrinsicsQuery): Promise<PaginatedResponse<ExtrinsicDocument>>;
2585
+ /**
2586
+ * Fetch a single extrinsic by block index or transaction hash.
2587
+ *
2588
+ * `GET /api/extrinsic/:indexOrHash`
2589
+ *
2590
+ * Accepts either:
2591
+ * - Block index: `blockHeight-extrinsicIndex` (e.g. `"2528092-2"`)
2592
+ * - Transaction hash: `0x`-prefixed 64-char hex string
2593
+ *
2594
+ * @param client Configured {@link IndexerClient}
2595
+ * @param indexOrHash Block-index pair or extrinsic hash
2596
+ * @throws {IndexerHttpError} `400` for invalid id format, `404` when not found
2597
+ */
2598
+ declare function getExtrinsic(client: IndexerClient, indexOrHash: string): Promise<SuccessResponse<ExtrinsicDocument>>;
2599
+
2600
+ /**
2601
+ * Fetch the top 50 addresses by balance.
2602
+ *
2603
+ * `GET /api/addresses`
2604
+ *
2605
+ * **Note:** This endpoint returns a raw array, not a `{ success, data }` envelope.
2606
+ *
2607
+ * @param client Configured {@link IndexerClient}
2608
+ */
2609
+ declare function getAddresses(client: IndexerClient): Promise<AddressDocument[]>;
2610
+ /**
2611
+ * Fetch a single address document.
2612
+ *
2613
+ * `GET /api/address/:address`
2614
+ *
2615
+ * **Note:** This endpoint returns `{ data }` without a `success` field.
2616
+ *
2617
+ * @param client Configured {@link IndexerClient}
2618
+ * @param address The substrate address to look up
2619
+ */
2620
+ declare function getAddress(client: IndexerClient, address: string): Promise<DataOnlyResponse<AddressDocument>>;
2621
+
2622
+ /**
2623
+ * Fetch a blob by its block-height ID.
2624
+ *
2625
+ * `GET /api/blob/:id`
2626
+ *
2627
+ * @param client Configured {@link IndexerClient}
2628
+ * @param id Block height (integer) identifying the blob
2629
+ */
2630
+ declare function getBlob(client: IndexerClient, id: number): Promise<SuccessResponse<BlobDocument>>;
2631
+
2632
+ /**
2633
+ * Fetch guardian groups, optionally filtered by guardian address.
2634
+ * Results are deduplicated and enriched with identity names.
2635
+ *
2636
+ * `GET /api/guardian-groups`
2637
+ *
2638
+ * Each group includes `guardians: string[]` and a parallel `guardianNames`
2639
+ * array (`string | null`) from the identity database.
2640
+ *
2641
+ * @param client Configured {@link IndexerClient}
2642
+ * @param query Optional filter — `guardian` address
2643
+ */
2644
+ declare function getGuardianGroups(client: IndexerClient, query?: GuardianGroupsQuery): Promise<SuccessResponse<GuardianGroupDocument[]>>;
2645
+ /**
2646
+ * Flatten identity-enriched guardian groups into a unique list of guardians.
2647
+ *
2648
+ * Derived from {@link getGuardianGroups}; there is no separate `/api/guardians`
2649
+ * endpoint. A 404 (no groups) returns an empty list.
2650
+ *
2651
+ * @returns `{ success: true, data: GuardianDocument[] }`
2652
+ * where each item is `{ account, displayName }`.
2653
+ */
2654
+ declare function getGuardians(client: IndexerClient): Promise<SuccessResponse<GuardianDocument[]>>;
2655
+ /**
2656
+ * Fetch identity for a single guardian account.
2657
+ *
2658
+ * Uses `GET /api/guardian-groups?guardian=<account>` and returns
2659
+ * `{ account, displayName }`. `displayName` is `null` when the account has
2660
+ * no identity or is not in any indexed group.
2661
+ */
2662
+ declare function getGuardian(client: IndexerClient, account: string): Promise<SuccessResponse<GuardianDocument>>;
2663
+ /**
2664
+ * Fetch a single guardian group by its group ID.
2665
+ *
2666
+ * `GET /api/guardian-group/:id`
2667
+ *
2668
+ * @param client Configured {@link IndexerClient}
2669
+ * @param id The `groupId`
2670
+ */
2671
+ declare function getGuardianGroup(client: IndexerClient, id: string): Promise<SuccessResponse<GuardianGroupDocument>>;
2672
+
2673
+ /**
2674
+ * Fetch access records from the **legacy** statescan-polkadot-data database.
2675
+ *
2676
+ * `GET /api/access`
2677
+ *
2678
+ * > **Deprecated** — superseded by `getArtefactAccess`. Kept for backward compatibility.
2679
+ *
2680
+ * @param client Configured {@link IndexerClient}
2681
+ * @param query Optional filters — `blockHeight`, `extrinsicIndex`, `retriver`
2682
+ */
2683
+ declare function getAccess(client: IndexerClient, query?: AccessQuery): Promise<AccessResponse<AccessDocument>>;
2684
+
1340
2685
  declare function rotateAndSetKeys(account: KeyringPair): Promise<void>;
1341
2686
  declare function setWorker(account: KeyringPair): Promise<void>;
1342
2687
 
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 };
2688
+ export { API_EXTENSIONS, API_RPC, API_TYPES, type AccessDocument, type AccessQuery, type AccessResponse, type AccountInfo, AccountSourceType, type ActiveGuardian, type AddressDocument, type AgreementStatus, type ArtefactAccessQuery, type ArtefactContractsQuery, type ArtefactDocument, type ArtefactFlow, type ArtefactType, type ArtefactsQuery, type AsymmetricHybridParams, type AsymmetricParams, type AtomicPaliAmount, type AuctionDetail, type AuctionWinner, type Balance, type BlobDocument, type BlockDocument, type BlockScanFilter, type BlockScanResult, type BlocksData, type BlocksQuery, COMPUTE_TYPES, type CallArgsDocument, type CallArgsQuery, type CallDocument, type CallMetadataDocument, type CallMetadataQuery, type CallQuery, type CipherSuite, type ComputeContract, type ComputeDocument, type ComputeMetadataInput, type ComputeMode, type ComputeType, type ContractDocument, type ContractFlow, type ContractFlowPhase, type ContractFlowStatus, type ContractInfo, type ContractParams, type ContractResponse, type ContractType, type ContractsQuery, CostEstimationError, CryptoType, type CurrencyId, DEFAULT_COMPUTE_PAYLOAD, DEFAULT_EMPTY_PAYLOAD, type DataAgreementMetadata, type DataAgreementParams, type DataContractParams, type DataOnlyResponse, type Ed25519Params, type EncryptedInferenceComputeParams, type EncryptedInferenceSubscriptionInvocationParams, type EncryptedInferenceSubscriptionParams, type ErrorResponse, type EstimateResult, type EstimateStatusResponse, type ExtrinsicDocument, type ExtrinsicsQuery, type Fee, type FeeParams, type FeeThresholdInput, FileFromMetadataRef, type GuardianAddress, type GuardianDocument, type GuardianEntry, type GuardianGroupDocument, type GuardianGroupInfo, type GuardianGroupsQuery, type GuardianJoinPrefs, type GuardianParticipants, type IdentityFields, IndexerClient, type IndexerClientOptions, IndexerHttpError, type IndexerMeta, type InferenceComputeParams, type InvokeAgreementInput, type KdfParams, type LatestBlock, type LatestBlocksResult, MCryptFs, MCryptFsReader, MCryptFsWriter, type MinFeeBreakdown, type MinFeeInput, NO_GUARDIAN_GROUP, type OnChainRef, type OpenAuction, PALI_DECIMALS, PALI_SYMBOL, type PaginatedResponse, type PaliAmountInput, type PallioraConfig, type ResolvedAuction, type ResultDocument, type ResultFeeBreakdown, type ResultFeeParty, type ResultsQuery, S3Provider, type Secp256k1Params, type SilentThresholdParams, type SimpleComputeParams, type StartedEstimate, type StorageProvider, StorageRouter, type StoreType, type StoredComputeParams, type SubmissionReceipt, type SubmitTEDataResult, type SuccessResponse, type SymmetricParams, type ThresholdHybridParams, type ThresholdParams, type TransferDocument, type TransfersQuery, type UploadOptions, type WaitForEstimateOptions, addStake, base64ToUint8Array, buildComputeMetadata, buildContractPhases, buildFee, clearTokenCache, createAccount, createAccountFromMagicLink, createAgreement, createGuardianGroup, createGuardianGroupAndWatch, createSimpleAgreement, dataContract, debugLog, decodeAggregateKey, decodeField, decodePowersOfTau, decrypt, deriveContractStatus, disconnectApi, encrypt as ecncryptTest, encodeCiphertext, encrypt$1 as encrypt, encryptedInferenceCompute, encryptedInferenceSubscription, encryptedInferenceSubscriptionInvocation, estimateMinFee, fetchAndDecodeExtrinsic, fetchTokenProperties, findEvent, formatBalanceWithTokenProperties, formatPaliAmount, fromAtomicPaliAmount, fundAccount, gen_shared_key, gen_stretched_key, generateRandomBytes, getAccess, getAccountInfo, getActiveGuardians, getAddress, getAddresses, getAgents, getAgreementCreatedRequestId, getApi, getArtefact, getArtefactAccess, getArtefactContracts, getArtefactFlow, getArtefacts, getArtefactsByStoreType, getAuction, getAuthServiceUrl, getAwsRegion, getAwsS3Bucket, getBalance, getBlob, getBlocks, getCachedTokenProperties, getCall, getCallArgs, getCallMetadata, getCompute, getContract, getContractFlow, getContractInfo, getContracts, getCostEstimatorUrl, getDatasets, getEncKeyring, getEstimateResult, getExecutables, getExtrinsic, getExtrinsics, getFeeParams, getFileMetadataCall, getGuardian, getGuardianAddress, getGuardianGroup, getGuardianGroupInfo, getGuardianGroups, getGuardianList, getGuardianNwParams, getGuardianParticipants, getGuardians, getKeyring, getLatestBlocks, getModels, getPallioraRpcUrl, getPallioraWs, getProvider, getResult, getResults, getTransfers, healthCheck, hexToUint8Array, inferenceCompute, init, invokeAgreement, isArtefactUsage, isDebug, isInitialized, joinGuardian, joinIdleStaker, joinValidator, listGuardianAuctions, listOpenAuctions, listResolvedGuardianAuctions, newStake, normalizeComputes, pairFromPrivateKeyHex, payoutStake, reduceStake, registerDataAgreement, registerGuardianWebhook, removeStake, resetConfig, resultToCompute, retrySignAndSend, rotateAndSetKeys, runAgent, scanForBlockEvent, setIdentity, setWorker, signAndSend, simpleCompute, startEstimate, storageRouter, storedCompute, submitAuctionBid, submitData, submitTEData, submitTEDataWithCipher, testCrypt, toAtomicPaliAmount, tokenToBigint, transfer, uint8ArrayToBase64, uploadData, uploadDataLegacy, waitForEstimate, waitForNextBlock, waitsForFinalization, watchForSubmissionReceipt, withdrawStake, writeMetadata };