@usearete/sdk 0.13.0 → 0.15.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.ts CHANGED
@@ -25,6 +25,8 @@ interface TransactionSimulationResult {
25
25
  err: unknown | null;
26
26
  logs: readonly string[] | null;
27
27
  unitsConsumed?: bigint;
28
+ /** Loaded account data size, when the relay reports it. */
29
+ loadedAccountsDataSize?: bigint;
28
30
  accounts?: readonly unknown[] | null;
29
31
  }
30
32
  interface TransactionSendOptions {
@@ -116,13 +118,127 @@ interface BuiltInstruction {
116
118
  * - `finalized`: Transaction finalized (recommended for production)
117
119
  */
118
120
  type ConfirmationLevel = 'processed' | 'confirmed' | 'finalized';
121
+ /**
122
+ * Transaction version requested by the caller.
123
+ *
124
+ * Numeric versions stay JSON numbers; they are versions, not u64 quantities.
125
+ */
126
+ type TransactionVersion = 'legacy' | 0 | 1;
127
+ /**
128
+ * u32 resource quantity: an exact integer (`number` or `bigint`) or a decimal
129
+ * string. Only representations that may already have lost precision are
130
+ * rejected, and below 2^32 a `number` cannot.
131
+ */
132
+ type ResourceUnits = number | bigint | string;
133
+ /**
134
+ * u64 resource quantity: a `bigint` or a decimal string.
135
+ *
136
+ * A plain `number` is rejected: every JS number is a double, so a u64 that
137
+ * arrived as one may already have lost precision.
138
+ */
139
+ type ResourceLamports = bigint | string;
140
+ /**
141
+ * Resource budget options shared by sending and unsigned inspection.
142
+ *
143
+ * The two fee fields are mutually exclusive and version-bound:
144
+ * `priorityFeeLamports` is V1 only, `computeUnitPriceMicroLamports` is
145
+ * legacy/v0 only.
146
+ */
147
+ interface TransactionResourceOptions {
148
+ /** Compute unit ceiling (u32). */
149
+ computeUnitLimit?: ResourceUnits;
150
+ /** Loaded account data ceiling in bytes (u32). */
151
+ loadedAccountsDataSizeLimit?: ResourceUnits;
152
+ /** Heap frame bytes (u32). */
153
+ heapSize?: ResourceUnits;
154
+ /** Total priority fee in lamports (u64). Transaction V1 only. */
155
+ priorityFeeLamports?: ResourceLamports;
156
+ /** Per-compute-unit price in micro-lamports (u64). Legacy/v0 only. */
157
+ computeUnitPriceMicroLamports?: ResourceLamports;
158
+ }
159
+ /** Canonical resource option keys, in contract order. */
160
+ declare const TRANSACTION_RESOURCE_OPTION_KEYS: readonly ["computeUnitLimit", "loadedAccountsDataSizeLimit", "heapSize", "priorityFeeLamports", "computeUnitPriceMicroLamports"];
161
+ type TransactionResourceOptionKey = typeof TRANSACTION_RESOURCE_OPTION_KEYS[number];
162
+ /**
163
+ * Version + resource options understood by version-aware adapters.
164
+ *
165
+ * The resource budget is a nested, closed object: an unrecognized key inside
166
+ * `resources` is rejected, which a flat shape could not enforce against the
167
+ * open index signature on {@link SendOptions}.
168
+ */
169
+ interface TransactionBuildOptions {
170
+ /** Explicit transaction version. Omitted means the adapter's default (v0). */
171
+ transactionVersion?: TransactionVersion;
172
+ /** Resource budget for this transaction. */
173
+ resources?: TransactionResourceOptions;
174
+ }
175
+ /** Adapter capability declaration consulted before a build. */
176
+ interface TransactionBuildCapability {
177
+ /**
178
+ * Versions the adapter can build. `undefined` means unknown, never empty:
179
+ * ordinary operations keep working, but an explicit V1 request fails.
180
+ */
181
+ readonly supportedTransactionVersions?: readonly TransactionVersion[];
182
+ /**
183
+ * Resource options the adapter honours. `undefined` means unknown and is not
184
+ * policed; an empty array means the adapter honours none and every supplied
185
+ * resource option is rejected rather than silently dropped.
186
+ */
187
+ readonly supportedResourceOptions?: readonly TransactionResourceOptionKey[];
188
+ }
189
+ type TransactionOptionsErrorCode = 'unsupported_transaction_version' | 'unsupported_resource_option' | 'invalid_transaction_option';
190
+ /** Typed rejection for malformed or unsupported build options. */
191
+ declare class TransactionOptionsError extends Error {
192
+ readonly code: TransactionOptionsErrorCode;
193
+ readonly option?: string;
194
+ readonly requestedVersion?: TransactionVersion;
195
+ readonly supportedVersions?: readonly TransactionVersion[];
196
+ constructor(code: TransactionOptionsErrorCode, message: string, details?: {
197
+ option?: string;
198
+ requestedVersion?: TransactionVersion;
199
+ supportedVersions?: readonly TransactionVersion[];
200
+ });
201
+ }
202
+ /** Resource budget after validation: every quantity normalized to a bigint. */
203
+ interface ResolvedTransactionResourceOptions {
204
+ readonly computeUnitLimit?: bigint;
205
+ readonly loadedAccountsDataSizeLimit?: bigint;
206
+ readonly heapSize?: bigint;
207
+ readonly priorityFeeLamports?: bigint;
208
+ readonly computeUnitPriceMicroLamports?: bigint;
209
+ }
210
+ /** Build options after validation. */
211
+ interface ResolvedTransactionBuildOptions {
212
+ /** Effective version: the explicit request, or the v0 default. */
213
+ readonly transactionVersion: TransactionVersion;
214
+ readonly resources: ResolvedTransactionResourceOptions;
215
+ }
216
+ /**
217
+ * Validate build options against an adapter's declared capability and
218
+ * normalize every quantity to a bigint.
219
+ *
220
+ * Rejections are never silent downgrades: an explicit version the adapter does
221
+ * not advertise fails, and a fee field used against the wrong version fails
222
+ * instead of being converted.
223
+ */
224
+ declare function resolveTransactionBuildOptions(options?: TransactionBuildOptions, capability?: TransactionBuildCapability): ResolvedTransactionBuildOptions;
225
+ /**
226
+ * Boundary form of a resolved resource budget: flat canonical camelCase keys,
227
+ * every present value a decimal string, absent keys omitted.
228
+ *
229
+ * Mirrors Rust `TransactionResourceOptions::to_json()` and Python `to_wire()`.
230
+ * Key order is not part of the contract (Rust sorts, Python uses declaration
231
+ * order); the keys and their decimal-string values are. bigint stays the
232
+ * in-process type; `JSON.stringify` cannot emit one.
233
+ */
234
+ declare function toWireResourceOptions(resources: ResolvedTransactionResourceOptions): Record<string, string>;
119
235
  /**
120
236
  * Options forwarded to the wallet adapter when sending a transaction.
121
237
  *
122
238
  * The core SDK does not interpret these; it passes them straight through to
123
239
  * the adapter, which owns all RPC semantics.
124
240
  */
125
- interface SendOptions {
241
+ interface SendOptions extends TransactionBuildOptions {
126
242
  /** Confirmation level the adapter should wait for */
127
243
  confirmationLevel?: ConfirmationLevel;
128
244
  /** Skip the RPC preflight simulation */
@@ -152,7 +268,7 @@ interface SendResult {
152
268
  * Inspection must not sign or submit the transaction. Concrete adapters may
153
269
  * accept additional simulation options through this passthrough object.
154
270
  */
155
- interface TransactionInspectionOptions {
271
+ interface TransactionInspectionOptions extends TransactionBuildOptions {
156
272
  [key: string]: unknown;
157
273
  }
158
274
  /**
@@ -167,6 +283,8 @@ interface TransactionInspectionResult {
167
283
  computeUnitsConsumed?: number;
168
284
  /** RPC context slot for the inspection, when available. */
169
285
  contextSlot?: number;
286
+ /** Loaded account data size reported by simulation, when available. */
287
+ loadedAccountsDataSize?: number;
170
288
  /** Raw simulation failure, if the inspected transaction would fail. */
171
289
  error?: unknown;
172
290
  /** Adapter-specific inspection fields. */
@@ -187,6 +305,13 @@ interface WalletAdapter {
187
305
  publicKey: string;
188
306
  /** Signer addresses the adapter can satisfy without per-send signers. */
189
307
  readonly signerAddresses?: readonly string[];
308
+ /**
309
+ * Transaction versions this adapter can build.
310
+ *
311
+ * Omitting the field means unknown, not unsupported: existing operations keep
312
+ * working, but an explicit V1 request is rejected rather than downgraded.
313
+ */
314
+ readonly supportedTransactionVersions?: readonly TransactionVersion[];
190
315
  /**
191
316
  * Compile, sign, and broadcast one or more built instructions as a single
192
317
  * transaction.
@@ -2431,5 +2556,5 @@ declare const Arete: typeof Arete$1 & {
2431
2556
  session: typeof createSession;
2432
2557
  };
2433
2558
 
2434
- export { ASSOCIATED_TOKEN_PROGRAM_ADDRESS, Arete, AreteError, ConnectionManager, DEFAULT_CONFIG, DEFAULT_MAX_ENTRIES_PER_VIEW, FrameProcessor, InstructionError, MemoryAdapter, OPERATION_KIND, OperationCallbackError, OperationExecutionError, PROGRAM_OPERATION_EXTENSIONS, ProcessedSlotTimeoutError, QueryStore, ReadRequestError, SPL_TOKEN_PROGRAM_ADDRESS, STACK_RUNTIME_EXTENSIONS, SYSTEM_PROGRAM_ADDRESS, SubscriptionRegistry, TOKEN_2022_PROGRAM_ADDRESS, TransactionExecutionError, TransactionTransportError, account, appendFlowTransactions, appendTransactionInstructions, applyConnectedStackExtensions, arg, buildInstruction, bytes, canonicalQueryKey, chainAccountLoader, createChainClient, createEntityStream, createHostedSolanaGatewayTransports, createInstructionExecutor, createInstructionHandler, createPreparedFlow, createPreparedInstruction, createPreparedTransaction, createPreparedTransactionBody, createProgramPdas, createPublicKeySeed, createRichUpdateStream, createSeed, createSession, createSignerRegistry, createSubscriptionId, createTransactionTransport, createTypedListView, createTypedStateView, createTypedViews, createUpdateStream, decodeBase58, defineProgramExtensions, defineStackExtensions, deriveAssociatedTokenAccount, deriveHttpEndpoint, findProgramAddress as derivePda, describePreparedOperation, encodeBase58, executeInstruction, executePreparedOperation, extendProgram, extendPrograms, extendStack, findProgramAddress, findProgramAddressSync, flowOperation, formatPreparedOperation, formatProgramError, formatRawToUi, getMintDecimals, getOperationKind, getProgramRuntimeExtensions, getStackRuntimeExtensions, getTransactionFailureOutcome, inspectPreparedOperation, instructionOperation, isEntityFrame, isErrorFrame, isHostedAreteEndpoint, isSnapshotFrame, isSubscribedFrame, isUnsubscribedFrame, isValidFrame, literal, normalizeSubscription, normalizeSubscriptionQuery, normalizeSubscriptionRequest, normalizeTransactionError, parseFrame, parseFrameFromBlob, parseInstructionError, parseUiAmountToRaw, pda, prependFlowTransactionInstructions, prependTransactionInstructions, programAccountRead, programQuery, resolveAccounts, resolveAmount, resolveAmountToRaw, resolveAmountsToRaw, resolveTokenProgramAddress, safeToRawAmount, serializeInstructionData, serializeViewKey, stackQuery, stringifyBigints, toJsonValue, toRawAmount, transactionOperation, unwrapOperationExecutionError, validateAccountResolution, validateProgramReadDescriptor, validateSubscriptionId, withProgramRead, withPrograms };
2435
- export type { AccountCategory, AccountLoader, AccountMeta, AccountResolutionOptions, AccountResolutionResult, AmountInput, AnyOperation, AreteConfig, AreteOptions, AreteOptionsWithStorage, ArgSchema, ArgType, AuthConfig, AuthTokenRequest, AuthTokenResult, AuthTokenTarget, BuildOptions, BuiltAccountMeta, BuiltInstruction, ChainClient, ChainClock, ChainFailedTransactionOutcome, CompositionSessionOptions, ConfirmationLevel, ConfirmedTransactionOutcome, ConnectOptions, ConnectedArete, ConnectedStackClient, ConnectionState, ConnectionStateCallback, ContextSlotOptions, CreatePreparedFlowInput, CreatePreparedInstructionInput, CreatePreparedTransactionInput, DefaultViewKey, EntityFrame, ErrorFrame, ErrorMetadata, ExecuteOptions, ExecutionResult, ExtendedProgramDefinition, ExtendedStackDefinition, FlowOperation, FlowOperationNamespace, FlowOperationReceipt, Frame, FrameMode, FrameOp, FrameProcessorConfig, FrameValidationDiagnostic, HostedSolanaGatewayBindings, HostedSolanaGatewayCapabilityBinding, HostedSolanaGatewayTransportOptions, HostedSolanaGatewayTransports, HttpAuthMetadata, InstructionExecutor, InstructionHandler, InstructionHandlerConfig, InstructionOperation, InstructionOperationNamespace, JsonObject, JsonPrimitive, JsonValue, LatestBlockhashResult, MergeProgramMaps, MintAccountInfo, NativeBalanceInfo, NonEmptyReadonlyArray, NotSubmittedTransactionOutcome, OperationCallbackPhase, OperationExecutionEvent, OperationExecutionHost, OperationExecutionOptions, OperationExecutionSuccessEvent, OperationInspection, OperationInspectionOptions, OperationKind, OperationKindBrand, OperationNamespace, OperationPlan, OperationReceiptFor, OperationTransactionReceipt, PdaConfig, PdaDeriveContext, PdaFactory, PdaProgram, PdaProgramSelector, PdaSeed, PreparedFlow, PreparedInstruction, PreparedOperation, PreparedOperationDescription, PreparedTransaction, PreparedTransactionBody, PreparedTransactionInstruction, PreparedTransactionOperation, ProgramAccountBatchItem, ProgramAccountBatchResult, ProgramAccountReadDefinition, ProgramError, ProgramExtensionInput, ProgramInterface, ProgramOperationContext, ProgramOperations, ProgramOperationsOf, ProgramPdas, ProgramQueryDefinition, ProgramReadBinding, ProgramReadBindingAuthTarget, ProgramReadDescriptor, ProgramReadDescriptors, ProgramReadOf, ProgramReadOverride, ProgramReadOverrides, ProgramReadRequest, ProgramReadTransport, ProgramReleaseReference, ProgramRuntimeExtensionCarrier, ProgramRuntimeExtensions, ProgramSdkDefinition, ProgramsInterface, QueriesInterface, QueryLease, QuerySnapshot, RawAccountInfo, RawInstructionsInterface, RawProgramsInterface, ReadArgumentCount, ReadArgumentCounts, ReadTransportMethod, ResolvedAccount, ResolvedAccounts, RichUpdate, RichUpdateCallback, Schema, SchemaResult, SeedDef, SendOptions, SendResult, Session, SessionDefinition, SessionMemberOptions, SessionOptions, SignerRegistry, SingleTransactionOperationReceipt, SnapshotEntity, SnapshotFrame, SocketIssue, SocketIssueCallback, SolanaGatewayAuthMetadata, SolanaGatewayAuthScope, SolanaGatewayBindingAuthTarget, SortConfig, SortOrder, StackConnectedExtensions, StackDefinition, StackEndpoints, StackExtensionClient, StackExtensionInput, StackQueryDefinition, StackRuntimeExtensionCarrier, StackRuntimeExtensions, StackWithAttachedPrograms, StorageAdapter, StorageAdapterConfig, StringifiedBigints, SubmittedUnknownTransactionOutcome, SubscribeCallback, SubscribedFrame, Subscription, SubscriptionIdentity, SubscriptionOptions, SubscriptionQuery, SubscriptionRequest, SubscriptionSnapshotOptions, TokenAccountInfo, TokenBalanceInfo, TokenBalanceInput, TransactionCommitment, TransactionFailureOutcome, TransactionFailurePhase, TransactionFailureStatus, TransactionFeeResult, TransactionInspectionOptions, TransactionInspectionResult, TransactionOperation, TransactionOperationNamespace, TransactionOptions, TransactionOutcome, TransactionRequestContext, TransactionSendOptions, TransactionSendResult, TransactionSignatureStatus, TransactionSimulationOptions, TransactionSimulationResult, TransactionTransport, TransactionTransportErrorBody, TypedAccountReader, TypedInstruction, TypedListView, TypedQueryExecutor, TypedStateView, TypedViewGroup, TypedViews, UnsubscribeFn, UnsubscribedFrame, Update, UpdateCallback, ViewDef, ViewGroup, ViewKeyFields, ViewKeyValue, ViewSortConfig, WaitForProcessedSlotOptions, WalletAdapter, WalletConnectOptions, WalletExecutionContext, WalletState, WatchOptions, WebSocketFactoryInit };
2559
+ export { ASSOCIATED_TOKEN_PROGRAM_ADDRESS, Arete, AreteError, ConnectionManager, DEFAULT_CONFIG, DEFAULT_MAX_ENTRIES_PER_VIEW, FrameProcessor, InstructionError, MemoryAdapter, OPERATION_KIND, OperationCallbackError, OperationExecutionError, PROGRAM_OPERATION_EXTENSIONS, ProcessedSlotTimeoutError, QueryStore, ReadRequestError, SPL_TOKEN_PROGRAM_ADDRESS, STACK_RUNTIME_EXTENSIONS, SYSTEM_PROGRAM_ADDRESS, SubscriptionRegistry, TOKEN_2022_PROGRAM_ADDRESS, TRANSACTION_RESOURCE_OPTION_KEYS, TransactionExecutionError, TransactionOptionsError, TransactionTransportError, account, appendFlowTransactions, appendTransactionInstructions, applyConnectedStackExtensions, arg, buildInstruction, bytes, canonicalQueryKey, chainAccountLoader, createChainClient, createEntityStream, createHostedSolanaGatewayTransports, createInstructionExecutor, createInstructionHandler, createPreparedFlow, createPreparedInstruction, createPreparedTransaction, createPreparedTransactionBody, createProgramPdas, createPublicKeySeed, createRichUpdateStream, createSeed, createSession, createSignerRegistry, createSubscriptionId, createTransactionTransport, createTypedListView, createTypedStateView, createTypedViews, createUpdateStream, decodeBase58, defineProgramExtensions, defineStackExtensions, deriveAssociatedTokenAccount, deriveHttpEndpoint, findProgramAddress as derivePda, describePreparedOperation, encodeBase58, executeInstruction, executePreparedOperation, extendProgram, extendPrograms, extendStack, findProgramAddress, findProgramAddressSync, flowOperation, formatPreparedOperation, formatProgramError, formatRawToUi, getMintDecimals, getOperationKind, getProgramRuntimeExtensions, getStackRuntimeExtensions, getTransactionFailureOutcome, inspectPreparedOperation, instructionOperation, isEntityFrame, isErrorFrame, isHostedAreteEndpoint, isSnapshotFrame, isSubscribedFrame, isUnsubscribedFrame, isValidFrame, literal, normalizeSubscription, normalizeSubscriptionQuery, normalizeSubscriptionRequest, normalizeTransactionError, parseFrame, parseFrameFromBlob, parseInstructionError, parseUiAmountToRaw, pda, prependFlowTransactionInstructions, prependTransactionInstructions, programAccountRead, programQuery, resolveAccounts, resolveAmount, resolveAmountToRaw, resolveAmountsToRaw, resolveTokenProgramAddress, resolveTransactionBuildOptions, safeToRawAmount, serializeInstructionData, serializeViewKey, stackQuery, stringifyBigints, toJsonValue, toRawAmount, toWireResourceOptions, transactionOperation, unwrapOperationExecutionError, validateAccountResolution, validateProgramReadDescriptor, validateSubscriptionId, withProgramRead, withPrograms };
2560
+ export type { AccountCategory, AccountLoader, AccountMeta, AccountResolutionOptions, AccountResolutionResult, AmountInput, AnyOperation, AreteConfig, AreteOptions, AreteOptionsWithStorage, ArgSchema, ArgType, AuthConfig, AuthTokenRequest, AuthTokenResult, AuthTokenTarget, BuildOptions, BuiltAccountMeta, BuiltInstruction, ChainClient, ChainClock, ChainFailedTransactionOutcome, CompositionSessionOptions, ConfirmationLevel, ConfirmedTransactionOutcome, ConnectOptions, ConnectedArete, ConnectedStackClient, ConnectionState, ConnectionStateCallback, ContextSlotOptions, CreatePreparedFlowInput, CreatePreparedInstructionInput, CreatePreparedTransactionInput, DefaultViewKey, EntityFrame, ErrorFrame, ErrorMetadata, ExecuteOptions, ExecutionResult, ExtendedProgramDefinition, ExtendedStackDefinition, FlowOperation, FlowOperationNamespace, FlowOperationReceipt, Frame, FrameMode, FrameOp, FrameProcessorConfig, FrameValidationDiagnostic, HostedSolanaGatewayBindings, HostedSolanaGatewayCapabilityBinding, HostedSolanaGatewayTransportOptions, HostedSolanaGatewayTransports, HttpAuthMetadata, InstructionExecutor, InstructionHandler, InstructionHandlerConfig, InstructionOperation, InstructionOperationNamespace, JsonObject, JsonPrimitive, JsonValue, LatestBlockhashResult, MergeProgramMaps, MintAccountInfo, NativeBalanceInfo, NonEmptyReadonlyArray, NotSubmittedTransactionOutcome, OperationCallbackPhase, OperationExecutionEvent, OperationExecutionHost, OperationExecutionOptions, OperationExecutionSuccessEvent, OperationInspection, OperationInspectionOptions, OperationKind, OperationKindBrand, OperationNamespace, OperationPlan, OperationReceiptFor, OperationTransactionReceipt, PdaConfig, PdaDeriveContext, PdaFactory, PdaProgram, PdaProgramSelector, PdaSeed, PreparedFlow, PreparedInstruction, PreparedOperation, PreparedOperationDescription, PreparedTransaction, PreparedTransactionBody, PreparedTransactionInstruction, PreparedTransactionOperation, ProgramAccountBatchItem, ProgramAccountBatchResult, ProgramAccountReadDefinition, ProgramError, ProgramExtensionInput, ProgramInterface, ProgramOperationContext, ProgramOperations, ProgramOperationsOf, ProgramPdas, ProgramQueryDefinition, ProgramReadBinding, ProgramReadBindingAuthTarget, ProgramReadDescriptor, ProgramReadDescriptors, ProgramReadOf, ProgramReadOverride, ProgramReadOverrides, ProgramReadRequest, ProgramReadTransport, ProgramReleaseReference, ProgramRuntimeExtensionCarrier, ProgramRuntimeExtensions, ProgramSdkDefinition, ProgramsInterface, QueriesInterface, QueryLease, QuerySnapshot, RawAccountInfo, RawInstructionsInterface, RawProgramsInterface, ReadArgumentCount, ReadArgumentCounts, ReadTransportMethod, ResolvedAccount, ResolvedAccounts, ResolvedTransactionBuildOptions, ResolvedTransactionResourceOptions, ResourceLamports, ResourceUnits, RichUpdate, RichUpdateCallback, Schema, SchemaResult, SeedDef, SendOptions, SendResult, Session, SessionDefinition, SessionMemberOptions, SessionOptions, SignerRegistry, SingleTransactionOperationReceipt, SnapshotEntity, SnapshotFrame, SocketIssue, SocketIssueCallback, SolanaGatewayAuthMetadata, SolanaGatewayAuthScope, SolanaGatewayBindingAuthTarget, SortConfig, SortOrder, StackConnectedExtensions, StackDefinition, StackEndpoints, StackExtensionClient, StackExtensionInput, StackQueryDefinition, StackRuntimeExtensionCarrier, StackRuntimeExtensions, StackWithAttachedPrograms, StorageAdapter, StorageAdapterConfig, StringifiedBigints, SubmittedUnknownTransactionOutcome, SubscribeCallback, SubscribedFrame, Subscription, SubscriptionIdentity, SubscriptionOptions, SubscriptionQuery, SubscriptionRequest, SubscriptionSnapshotOptions, TokenAccountInfo, TokenBalanceInfo, TokenBalanceInput, TransactionBuildCapability, TransactionBuildOptions, TransactionCommitment, TransactionFailureOutcome, TransactionFailurePhase, TransactionFailureStatus, TransactionFeeResult, TransactionInspectionOptions, TransactionInspectionResult, TransactionOperation, TransactionOperationNamespace, TransactionOptions, TransactionOptionsErrorCode, TransactionOutcome, TransactionRequestContext, TransactionResourceOptionKey, TransactionResourceOptions, TransactionSendOptions, TransactionSendResult, TransactionSignatureStatus, TransactionSimulationOptions, TransactionSimulationResult, TransactionTransport, TransactionTransportErrorBody, TransactionVersion, TypedAccountReader, TypedInstruction, TypedListView, TypedQueryExecutor, TypedStateView, TypedViewGroup, TypedViews, UnsubscribeFn, UnsubscribedFrame, Update, UpdateCallback, ViewDef, ViewGroup, ViewKeyFields, ViewKeyValue, ViewSortConfig, WaitForProcessedSlotOptions, WalletAdapter, WalletConnectOptions, WalletExecutionContext, WalletState, WatchOptions, WebSocketFactoryInit };
package/dist/index.esm.js CHANGED
@@ -3121,6 +3121,195 @@ function createTypedViews(stack, storage, subscriptionRegistry) {
3121
3121
  return views;
3122
3122
  }
3123
3123
 
3124
+ /**
3125
+ * Wallet adapter boundary for the Arete SDK.
3126
+ *
3127
+ * The core SDK is intentionally RPC-free: it only constructs `BuiltInstruction`
3128
+ * objects. Everything network-related (recent blockhash, message compilation,
3129
+ * signing, sending, and confirmation) lives behind the `WalletAdapter`
3130
+ * boundary, implemented by adapters that wrap the Solana library of your choice
3131
+ * (@solana/web3.js, @solana/kit, a raw Keypair signer for scripts, etc.).
3132
+ */
3133
+ /** Canonical resource option keys, in contract order. */
3134
+ const TRANSACTION_RESOURCE_OPTION_KEYS = [
3135
+ 'computeUnitLimit',
3136
+ 'loadedAccountsDataSizeLimit',
3137
+ 'heapSize',
3138
+ 'priorityFeeLamports',
3139
+ 'computeUnitPriceMicroLamports',
3140
+ ];
3141
+ /** Typed rejection for malformed or unsupported build options. */
3142
+ class TransactionOptionsError extends Error {
3143
+ constructor(code, message, details = {}) {
3144
+ super(message);
3145
+ this.name = 'TransactionOptionsError';
3146
+ this.code = code;
3147
+ this.option = details.option;
3148
+ this.requestedVersion = details.requestedVersion;
3149
+ this.supportedVersions = details.supportedVersions;
3150
+ }
3151
+ }
3152
+ const U32_MAX = 0xffffffffn;
3153
+ const U64_MAX = (1n << 64n) - 1n;
3154
+ const DECIMAL = /^\d+$/;
3155
+ function inRange(value, max, option) {
3156
+ if (value > max) {
3157
+ throw new TransactionOptionsError('invalid_transaction_option', `Transaction option '${option}' exceeds its maximum of ${max}`, { option });
3158
+ }
3159
+ return value;
3160
+ }
3161
+ function parseUnits(value, option) {
3162
+ if (value === undefined)
3163
+ return undefined;
3164
+ if (typeof value === 'bigint') {
3165
+ if (value < 0n) {
3166
+ throw new TransactionOptionsError('invalid_transaction_option', `Transaction option '${option}' must not be negative`, { option });
3167
+ }
3168
+ return inRange(value, U32_MAX, option);
3169
+ }
3170
+ if (typeof value === 'number') {
3171
+ if (!Number.isInteger(value) || value < 0) {
3172
+ throw new TransactionOptionsError('invalid_transaction_option', `Transaction option '${option}' must be a non-negative integer or decimal string, `
3173
+ + `received ${value}`, { option });
3174
+ }
3175
+ return inRange(BigInt(value), U32_MAX, option);
3176
+ }
3177
+ if (typeof value === 'string' && DECIMAL.test(value)) {
3178
+ return inRange(BigInt(value), U32_MAX, option);
3179
+ }
3180
+ throw new TransactionOptionsError('invalid_transaction_option', `Transaction option '${option}' must be a non-negative integer or decimal string`, { option });
3181
+ }
3182
+ function parseLamports(value, option) {
3183
+ if (value === undefined)
3184
+ return undefined;
3185
+ if (typeof value === 'number') {
3186
+ throw new TransactionOptionsError('invalid_transaction_option', `Transaction option '${option}' must be a bigint or decimal string, never a number: `
3187
+ + 'every JavaScript number is a double, so a u64 passed as one may already have lost '
3188
+ + `precision before it reached the SDK (received ${value})`, { option });
3189
+ }
3190
+ if (typeof value === 'bigint') {
3191
+ if (value < 0n) {
3192
+ throw new TransactionOptionsError('invalid_transaction_option', `Transaction option '${option}' must not be negative`, { option });
3193
+ }
3194
+ return inRange(value, U64_MAX, option);
3195
+ }
3196
+ if (typeof value === 'string' && DECIMAL.test(value)) {
3197
+ return inRange(BigInt(value), U64_MAX, option);
3198
+ }
3199
+ throw new TransactionOptionsError('invalid_transaction_option', `Transaction option '${option}' must be a bigint or decimal string`, { option });
3200
+ }
3201
+ /**
3202
+ * Merge execution defaults with per-call send options.
3203
+ *
3204
+ * `resources` merges key by key, so a per-call fee does not discard a
3205
+ * configured compute budget — except for the two fee fields, which are one
3206
+ * slot: setting either clears the other, or the merged budget would hold both
3207
+ * and be refused as mutually exclusive. Shared by every entry point that has
3208
+ * defaults to merge; duplicating this logic is how `session` came to disagree
3209
+ * with `Arete.execute`.
3210
+ */
3211
+ function mergeSendOptions(defaults, override) {
3212
+ if (!defaults)
3213
+ return override;
3214
+ if (!override)
3215
+ return defaults;
3216
+ const inherited = { ...defaults.resources };
3217
+ if (override.resources?.priorityFeeLamports !== undefined ||
3218
+ override.resources?.computeUnitPriceMicroLamports !== undefined) {
3219
+ delete inherited.priorityFeeLamports;
3220
+ delete inherited.computeUnitPriceMicroLamports;
3221
+ }
3222
+ const resources = defaults.resources || override.resources
3223
+ ? { ...inherited, ...override.resources }
3224
+ : undefined;
3225
+ return { ...defaults, ...override, ...(resources ? { resources } : {}) };
3226
+ }
3227
+ /**
3228
+ * Validate build options against an adapter's declared capability and
3229
+ * normalize every quantity to a bigint.
3230
+ *
3231
+ * Rejections are never silent downgrades: an explicit version the adapter does
3232
+ * not advertise fails, and a fee field used against the wrong version fails
3233
+ * instead of being converted.
3234
+ */
3235
+ function resolveTransactionBuildOptions(options, capability) {
3236
+ const requested = options?.transactionVersion;
3237
+ if (requested !== undefined && requested !== 'legacy' && requested !== 0 && requested !== 1) {
3238
+ throw new TransactionOptionsError('invalid_transaction_option', `Unknown transactionVersion ${JSON.stringify(requested)}: expected 'legacy', 0, or 1`, { option: 'transactionVersion' });
3239
+ }
3240
+ const supported = capability?.supportedTransactionVersions;
3241
+ if (requested !== undefined) {
3242
+ // Undeclared capability means unknown, not unsupported: old versions keep
3243
+ // working, and only an explicit V1 request needs proof of support.
3244
+ const unsupported = supported ? !supported.includes(requested) : requested === 1;
3245
+ if (unsupported) {
3246
+ throw new TransactionOptionsError('unsupported_transaction_version', `Wallet adapter does not support transaction version ${JSON.stringify(requested)}`
3247
+ + (supported
3248
+ ? ` (supported: ${supported.map((version) => JSON.stringify(version)).join(', ')})`
3249
+ : ' (adapter declares no supported versions)'), { option: 'transactionVersion', requestedVersion: requested, supportedVersions: supported });
3250
+ }
3251
+ }
3252
+ const resources = options?.resources;
3253
+ if (resources !== undefined) {
3254
+ if (typeof resources !== 'object' || resources === null || Array.isArray(resources)) {
3255
+ throw new TransactionOptionsError('invalid_transaction_option', 'Transaction option \'resources\' must be an object of canonical resource options', { option: 'resources' });
3256
+ }
3257
+ // Closed key set: an unrecognized budget key is a rejection, never a
3258
+ // silently ignored passthrough.
3259
+ const unknownKey = Object.keys(resources).find((key) => !TRANSACTION_RESOURCE_OPTION_KEYS.includes(key));
3260
+ if (unknownKey) {
3261
+ throw new TransactionOptionsError('unsupported_resource_option', `Unknown resource option '${unknownKey}': expected one of `
3262
+ + TRANSACTION_RESOURCE_OPTION_KEYS.join(', '), { option: unknownKey });
3263
+ }
3264
+ }
3265
+ const honoured = capability?.supportedResourceOptions;
3266
+ if (honoured) {
3267
+ const rejected = TRANSACTION_RESOURCE_OPTION_KEYS.find((key) => resources?.[key] !== undefined && !honoured.includes(key));
3268
+ if (rejected) {
3269
+ throw new TransactionOptionsError('unsupported_resource_option', `Wallet adapter does not apply the '${rejected}' resource option`, { option: rejected });
3270
+ }
3271
+ }
3272
+ const version = requested ?? 0;
3273
+ if (resources?.priorityFeeLamports !== undefined
3274
+ && resources?.computeUnitPriceMicroLamports !== undefined) {
3275
+ throw new TransactionOptionsError('invalid_transaction_option', 'priorityFeeLamports and computeUnitPriceMicroLamports are mutually exclusive', { option: 'priorityFeeLamports', requestedVersion: version });
3276
+ }
3277
+ if (resources?.priorityFeeLamports !== undefined && version !== 1) {
3278
+ throw new TransactionOptionsError('unsupported_resource_option', `priorityFeeLamports requires transaction version 1, not ${JSON.stringify(version)}`, { option: 'priorityFeeLamports', requestedVersion: version });
3279
+ }
3280
+ if (resources?.computeUnitPriceMicroLamports !== undefined && version === 1) {
3281
+ throw new TransactionOptionsError('unsupported_resource_option', 'computeUnitPriceMicroLamports applies to legacy/v0 only; version 1 uses priorityFeeLamports', { option: 'computeUnitPriceMicroLamports', requestedVersion: version });
3282
+ }
3283
+ return {
3284
+ transactionVersion: version,
3285
+ resources: {
3286
+ computeUnitLimit: parseUnits(resources?.computeUnitLimit, 'computeUnitLimit'),
3287
+ loadedAccountsDataSizeLimit: parseUnits(resources?.loadedAccountsDataSizeLimit, 'loadedAccountsDataSizeLimit'),
3288
+ heapSize: parseUnits(resources?.heapSize, 'heapSize'),
3289
+ priorityFeeLamports: parseLamports(resources?.priorityFeeLamports, 'priorityFeeLamports'),
3290
+ computeUnitPriceMicroLamports: parseLamports(resources?.computeUnitPriceMicroLamports, 'computeUnitPriceMicroLamports'),
3291
+ },
3292
+ };
3293
+ }
3294
+ /**
3295
+ * Boundary form of a resolved resource budget: flat canonical camelCase keys,
3296
+ * every present value a decimal string, absent keys omitted.
3297
+ *
3298
+ * Mirrors Rust `TransactionResourceOptions::to_json()` and Python `to_wire()`.
3299
+ * Key order is not part of the contract (Rust sorts, Python uses declaration
3300
+ * order); the keys and their decimal-string values are. bigint stays the
3301
+ * in-process type; `JSON.stringify` cannot emit one.
3302
+ */
3303
+ function toWireResourceOptions(resources) {
3304
+ const wire = {};
3305
+ for (const key of TRANSACTION_RESOURCE_OPTION_KEYS) {
3306
+ const value = resources[key];
3307
+ if (value !== undefined)
3308
+ wire[key] = value.toString(10);
3309
+ }
3310
+ return wire;
3311
+ }
3312
+
3124
3313
  /**
3125
3314
  * Non-enumerable brand attached by the operation and read factories so
3126
3315
  * tooling (e.g. the knowledge-layer extractor's runtime walk) can classify
@@ -3471,6 +3660,7 @@ function createTransactionTransport(baseUrl, authenticatedFetch) {
3471
3660
  err: value.err ?? null,
3472
3661
  logs: value.logs ?? null,
3473
3662
  unitsConsumed: optionalBigint(value.unitsConsumed, 'unitsConsumed'),
3663
+ loadedAccountsDataSize: optionalBigint(value.loadedAccountsDataSize, 'loadedAccountsDataSize'),
3474
3664
  accounts: value.accounts,
3475
3665
  };
3476
3666
  },
@@ -6247,6 +6437,7 @@ async function inspectPreparedOperation(wallet, operation, options, context) {
6247
6437
  if (!wallet?.inspectTransaction) {
6248
6438
  throw new Error('Wallet adapter does not support unsigned transaction inspection');
6249
6439
  }
6440
+ resolveTransactionBuildOptions(options, wallet);
6250
6441
  const transaction = operation.plan.transactions[0];
6251
6442
  const description = describePreparedOperation(operation);
6252
6443
  const inspection = context
@@ -6941,13 +7132,17 @@ let Arete$1 = class Arete {
6941
7132
  cause,
6942
7133
  });
6943
7134
  }
7135
+ const sendOptions = {
7136
+ ...(options?.send ?? {}),
7137
+ };
7138
+ if (options?.signers !== undefined) {
7139
+ sendOptions.signers = options.signers;
7140
+ }
7141
+ // Version/resource options are validated before anything reaches the
7142
+ // adapter, so an unsupported request throws the typed options error rather
7143
+ // than a wrapped execution failure.
7144
+ resolveTransactionBuildOptions(sendOptions, wallet);
6944
7145
  try {
6945
- const sendOptions = {
6946
- ...(options?.send ?? {}),
6947
- };
6948
- if (options?.signers !== undefined) {
6949
- sendOptions.signers = options.signers;
6950
- }
6951
7146
  const result = await wallet.signAndSend(instructions, sendOptions, {
6952
7147
  transactionTransport: options?.transactionTransport ?? this._transactions,
6953
7148
  });
@@ -6961,9 +7156,7 @@ let Arete$1 = class Arete {
6961
7156
  const defaults = this.executionDefaults;
6962
7157
  return executePreparedOperation(this, prepared, {
6963
7158
  wallet: options?.wallet ?? defaults?.wallet,
6964
- send: defaults?.send || options?.send
6965
- ? { ...(defaults?.send ?? {}), ...(options?.send ?? {}) }
6966
- : undefined,
7159
+ send: mergeSendOptions(defaults?.send, options?.send),
6967
7160
  signers: options?.signers ?? defaults?.signers,
6968
7161
  transactionTransport: options?.transactionTransport ?? defaults?.transactionTransport,
6969
7162
  signerRegistry: options?.signerRegistry ?? defaults?.signerRegistry,
@@ -7277,9 +7470,7 @@ async function createSession(definition, ...args) {
7277
7470
  return executionHost.transaction(instructions, {
7278
7471
  wallet: transactionOptions?.wallet ?? defaults?.wallet,
7279
7472
  transactionTransport: transactionOptions?.transactionTransport ?? transactions,
7280
- send: defaults?.send || transactionOptions?.send
7281
- ? { ...(defaults?.send ?? {}), ...(transactionOptions?.send ?? {}) }
7282
- : undefined,
7473
+ send: mergeSendOptions(defaults?.send, transactionOptions?.send),
7283
7474
  errors: transactionOptions?.errors,
7284
7475
  signers: signers.length > 0 ? signers : undefined,
7285
7476
  });
@@ -7290,9 +7481,7 @@ async function createSession(definition, ...args) {
7290
7481
  return executionHost.execute(prepared, {
7291
7482
  wallet: executionOptions?.wallet ?? defaults?.wallet,
7292
7483
  transactionTransport: executionOptions?.transactionTransport ?? defaults?.transactionTransport ?? transactions,
7293
- send: defaults?.send || executionOptions?.send
7294
- ? { ...(defaults?.send ?? {}), ...(executionOptions?.send ?? {}) }
7295
- : undefined,
7484
+ send: mergeSendOptions(defaults?.send, executionOptions?.send),
7296
7485
  signers: configuredSigners,
7297
7486
  signerRegistry,
7298
7487
  availableSignerAddresses: executionOptions?.availableSignerAddresses ?? defaults?.availableSignerAddresses,
@@ -7494,5 +7683,5 @@ function stringifyBigints(value) {
7494
7683
 
7495
7684
  const Arete = Object.assign(Arete$1, { session: createSession });
7496
7685
 
7497
- export { ASSOCIATED_TOKEN_PROGRAM_ADDRESS, Arete, AreteError, ConnectionManager, DEFAULT_CONFIG, DEFAULT_MAX_ENTRIES_PER_VIEW, FrameProcessor, InstructionError, MemoryAdapter, OPERATION_KIND, OperationCallbackError, OperationExecutionError, PROGRAM_OPERATION_EXTENSIONS, ProcessedSlotTimeoutError, QueryStore, ReadRequestError, SPL_TOKEN_PROGRAM_ADDRESS, STACK_RUNTIME_EXTENSIONS, SYSTEM_PROGRAM_ADDRESS, SubscriptionRegistry, TOKEN_2022_PROGRAM_ADDRESS, TransactionExecutionError, TransactionTransportError, account, appendFlowTransactions, appendTransactionInstructions, applyConnectedStackExtensions, arg, buildInstruction, bytes, canonicalQueryKey, chainAccountLoader, createChainClient, createEntityStream, createHostedSolanaGatewayTransports, createInstructionExecutor, createInstructionHandler, createPreparedFlow, createPreparedInstruction, createPreparedTransaction, createPreparedTransactionBody, createProgramPdas, createPublicKeySeed, createRichUpdateStream, createSeed, createSession, createSignerRegistry, createSubscriptionId, createTransactionTransport, createTypedListView, createTypedStateView, createTypedViews, createUpdateStream, decodeBase58, defineProgramExtensions, defineStackExtensions, deriveAssociatedTokenAccount, deriveHttpEndpoint, findProgramAddress as derivePda, describePreparedOperation, encodeBase58, executeInstruction, executePreparedOperation, extendProgram, extendPrograms, extendStack, findProgramAddress, findProgramAddressSync, flowOperation, formatPreparedOperation, formatProgramError, formatRawToUi, getMintDecimals, getOperationKind, getProgramRuntimeExtensions, getStackRuntimeExtensions, getTransactionFailureOutcome, inspectPreparedOperation, instructionOperation, isEntityFrame, isErrorFrame, isHostedAreteEndpoint, isSnapshotFrame, isSubscribedFrame, isUnsubscribedFrame, isValidFrame, literal, normalizeSubscription, normalizeSubscriptionQuery, normalizeSubscriptionRequest, normalizeTransactionError, parseFrame, parseFrameFromBlob, parseInstructionError, parseUiAmountToRaw, pda, prependFlowTransactionInstructions, prependTransactionInstructions, programAccountRead, programQuery, resolveAccounts, resolveAmount, resolveAmountToRaw, resolveAmountsToRaw, resolveTokenProgramAddress, safeToRawAmount, serializeInstructionData, serializeViewKey, stackQuery, stringifyBigints, toJsonValue, toRawAmount, transactionOperation, unwrapOperationExecutionError, validateAccountResolution, validateProgramReadDescriptor, validateSubscriptionId, withProgramRead, withPrograms };
7686
+ export { ASSOCIATED_TOKEN_PROGRAM_ADDRESS, Arete, AreteError, ConnectionManager, DEFAULT_CONFIG, DEFAULT_MAX_ENTRIES_PER_VIEW, FrameProcessor, InstructionError, MemoryAdapter, OPERATION_KIND, OperationCallbackError, OperationExecutionError, PROGRAM_OPERATION_EXTENSIONS, ProcessedSlotTimeoutError, QueryStore, ReadRequestError, SPL_TOKEN_PROGRAM_ADDRESS, STACK_RUNTIME_EXTENSIONS, SYSTEM_PROGRAM_ADDRESS, SubscriptionRegistry, TOKEN_2022_PROGRAM_ADDRESS, TRANSACTION_RESOURCE_OPTION_KEYS, TransactionExecutionError, TransactionOptionsError, TransactionTransportError, account, appendFlowTransactions, appendTransactionInstructions, applyConnectedStackExtensions, arg, buildInstruction, bytes, canonicalQueryKey, chainAccountLoader, createChainClient, createEntityStream, createHostedSolanaGatewayTransports, createInstructionExecutor, createInstructionHandler, createPreparedFlow, createPreparedInstruction, createPreparedTransaction, createPreparedTransactionBody, createProgramPdas, createPublicKeySeed, createRichUpdateStream, createSeed, createSession, createSignerRegistry, createSubscriptionId, createTransactionTransport, createTypedListView, createTypedStateView, createTypedViews, createUpdateStream, decodeBase58, defineProgramExtensions, defineStackExtensions, deriveAssociatedTokenAccount, deriveHttpEndpoint, findProgramAddress as derivePda, describePreparedOperation, encodeBase58, executeInstruction, executePreparedOperation, extendProgram, extendPrograms, extendStack, findProgramAddress, findProgramAddressSync, flowOperation, formatPreparedOperation, formatProgramError, formatRawToUi, getMintDecimals, getOperationKind, getProgramRuntimeExtensions, getStackRuntimeExtensions, getTransactionFailureOutcome, inspectPreparedOperation, instructionOperation, isEntityFrame, isErrorFrame, isHostedAreteEndpoint, isSnapshotFrame, isSubscribedFrame, isUnsubscribedFrame, isValidFrame, literal, normalizeSubscription, normalizeSubscriptionQuery, normalizeSubscriptionRequest, normalizeTransactionError, parseFrame, parseFrameFromBlob, parseInstructionError, parseUiAmountToRaw, pda, prependFlowTransactionInstructions, prependTransactionInstructions, programAccountRead, programQuery, resolveAccounts, resolveAmount, resolveAmountToRaw, resolveAmountsToRaw, resolveTokenProgramAddress, resolveTransactionBuildOptions, safeToRawAmount, serializeInstructionData, serializeViewKey, stackQuery, stringifyBigints, toJsonValue, toRawAmount, toWireResourceOptions, transactionOperation, unwrapOperationExecutionError, validateAccountResolution, validateProgramReadDescriptor, validateSubscriptionId, withProgramRead, withPrograms };
7498
7687
  //# sourceMappingURL=index.esm.js.map