export { getTransactionJson, SOLANA_MAX_SUPPORTED_TRANSACTION_VERSION } from './solana-transaction-read'; import type { VersionedTransaction } from '@solana/web3.js'; import type { AuthProvider, SolanaTransactionResult } from '../types'; import type { SetOptions } from './operations'; /** * Minimal base58 encoder, used ONLY to derive a Solana transaction signature * from already-signed bytes. Core deliberately does not take a `bs58` * dependency for eighteen lines of arithmetic. */ export declare function encodeBase58(bytes: Uint8Array): string; /** * Derive the transaction signature from the SIGNED bytes, before broadcasting. * * Without this the signature is only learned when `sendRawTransaction` resolves, * so an RPC that accepted the bytes but whose response was lost throws with * nothing recorded — and a retry builds a DIFFERENT transaction that can land * beside the first. */ /** true when the base64 wire is a SIMD-0385 v1 transaction (first byte 0x81). */ export declare function isTransactionV1Base64(serializedTransaction: string): boolean; export declare function deriveTransactionSignature(signedTransaction: VersionedTransaction): string; export declare function isDefinitiveSolanaSendFailure(error: unknown): boolean; /** * Whether a definitive Solana send/confirm failure is the BOUNDED PROGRAM * rejecting the write in simulation - a policy rule or a cap/invariant check - * as opposed to an infra failure (blockhash, fees, account not found). Only the * former is a stale-mirror race and safe to advertise as retryable. */ export declare function isBoundedOnchainRuleRejection(error: unknown, extraLogs?: unknown): boolean; /** * A Bounded on-chain rule/invariant rejection surfaced with a message the caller * can act on. This write already PASSED the off-chain preflight (otherwise it * would have been declined before a transaction was ever built), so the program * disagreeing here means the authoritative on-chain state is ahead of a * not-yet-converged read mirror - re-read and retry. If it keeps failing, the * rule is genuinely unsatisfied (the cap is truly exceeded, or the write is not * authorized). Carries the original error as `cause` and the raw program logs. */ export declare class BoundedOnchainRuleRejection extends Error { readonly boundedRuleRejection = true; readonly retryable = true; readonly logs: string[]; constructor(cause: unknown, extraLogs?: unknown); } export declare function errorText(error: unknown): string; /** * One expected field operation, derived from the caller's request document. * `value`/`delta` are the JSON-round-tripped request values (what the server * actually parsed), NOT the pre-serialization JS objects. */ export type ExpectedFieldOperation = { key: string; kind: 'write'; value: unknown; } | { key: string; kind: 'delete'; } | { key: string; kind: 'timestamp'; } | { key: string; kind: 'increment'; delta: number; }; export interface ExpectedWriteIntent { documents: Array<{ path: string; operations: ExpectedFieldOperation[]; }>; deletePaths: string[]; } /** * Build the expected write intent from the exact request the client POSTed * (`[{ destinationPath, document }]`, a `null` document being a delete). * * Each document is JSON-round-tripped first: the server parsed the SERIALIZED * body, so the intent must be derived from the same bytes - this drops * `undefined` values, turns `NaN`/`Infinity` into `null`, and normalizes key * order exactly as the server's JSON.parse did. * * Operation order mirrors the worker's transform (normalizeWriteBody -> * resolveOperationFields -> documentToOperations): plain fields in request key * order, then increment fields appended in the order they appeared. The * comparison is therefore ORDERED, not a multiset - the honest builder is * deterministic given the request, and ordering additionally catches * duplicate-path and reordering tampering that the retired set comparison hid. */ export declare function buildExpectedWriteIntent(documents: Array<{ destinationPath: string; document: any; }>): ExpectedWriteIntent; /** * Minimal base58 decoder, used ONLY to recognize a declared-Address field: a * request string that decodes to exactly the 32 bytes the instruction carries * is a faithful AddressVal encoding of that string. Returns null on any * non-base58 character. */ export declare function decodeBase58(text: string): Uint8Array | null; type PublicKeyClass = typeof import('@solana/web3.js')['PublicKey']; type PublicKeyInstance = InstanceType; export interface ServerTransactionInstructionView { programId: string; accountKeyIndexes: number[]; data: Uint8Array; } /** * The format-blind half of pre-sign validation: every instruction must be a * program the server builder is allowed to emit, the two setup shapes must * recompute to this write's values, and exactly one Bounded set-documents * instruction must bind the caller's own intent (OA-0001). The v0 path feeds it * web3.js's compiled message; the SIMD-0385 v1 lane feeds it kit's decoded * instruction headers and payloads. */ export declare function validateServerTransactionSemantics(input: { label: string; expectedAppId: string; expectedIntent: ExpectedWriteIntent; accountKeys: PublicKeyInstance[]; isAccountSigner: (index: number) => boolean; instructions: ServerTransactionInstructionView[]; PublicKeyCtor: PublicKeyClass; }): void; export declare function handlePreBuiltTransaction(tx: { serializedTransaction: string; blockhash: string; lastValidBlockHeight: number; network: string; }, authProvider: AuthProvider, options: SetOptions | undefined, expectedIntent: ExpectedWriteIntent): Promise;