@usearete/sdk 0.10.0 → 0.12.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
@@ -413,10 +413,14 @@ interface ArgSchema {
413
413
  */
414
414
  type ArgType = 'u8' | 'u16' | 'u32' | 'u64' | 'u128' | 'i8' | 'i16' | 'i32' | 'i64' | 'i128' | 'f32' | 'f64' | 'bool' | 'string' | 'pubkey' | 'bytes' | {
415
415
  vec: ArgType;
416
+ } | {
417
+ vecU64Len: ArgType;
416
418
  } | {
417
419
  option: ArgType;
418
420
  } | {
419
421
  array: readonly [ArgType, number];
422
+ } | {
423
+ tuple: readonly ArgType[];
420
424
  } | {
421
425
  hashMap: readonly [ArgType, ArgType];
422
426
  } | {
@@ -1512,7 +1516,7 @@ interface TokenBalanceInput {
1512
1516
  interface RawAccountInfo {
1513
1517
  address: string;
1514
1518
  ownerProgram: string;
1515
- lamports: number;
1519
+ lamports: bigint;
1516
1520
  executable: boolean;
1517
1521
  data: Uint8Array;
1518
1522
  }
@@ -1523,6 +1527,7 @@ interface ChainClient {
1523
1527
  minimumBalanceForRentExemption(space: number): Promise<number>;
1524
1528
  clock(): Promise<ChainClock>;
1525
1529
  account(address: string): Promise<RawAccountInfo | null>;
1530
+ accounts(addresses: readonly string[]): Promise<(RawAccountInfo | null)[]>;
1526
1531
  mint(address: string): Promise<MintAccountInfo | null>;
1527
1532
  tokenAccount(address: string): Promise<TokenAccountInfo | null>;
1528
1533
  balance(input: TokenBalanceInput, options?: ContextSlotOptions): Promise<TokenBalanceInfo>;
@@ -2242,6 +2247,16 @@ declare function createSession<TDef extends SessionDefinition, TStackPrograms ex
2242
2247
  */
2243
2248
  declare function withProgramRead<TProgram extends ProgramSdkDefinition>(program: TProgram, descriptor: ProgramReadDescriptor): TProgram;
2244
2249
 
2250
+ /**
2251
+ * Non-enumerable brand attached by the operation and read factories so
2252
+ * tooling (e.g. the knowledge-layer extractor's runtime walk) can classify
2253
+ * values by brand instead of duck-typing. Non-enumerable keeps JSON
2254
+ * serialization and object spreads of surrounding containers unchanged.
2255
+ */
2256
+ declare const OPERATION_KIND: "__areteOperationKind";
2257
+ type OperationKindBrand = 'instruction' | 'transaction' | 'flow' | 'account-fetch' | 'query';
2258
+ declare function getOperationKind(value: unknown): string | undefined;
2259
+
2245
2260
  interface HostedSolanaGatewayTransportOptions {
2246
2261
  readonly auth?: AuthConfig;
2247
2262
  readonly fetch?: typeof fetch;
@@ -2416,5 +2431,5 @@ declare const Arete: typeof Arete$1 & {
2416
2431
  session: typeof createSession;
2417
2432
  };
2418
2433
 
2419
- export { ASSOCIATED_TOKEN_PROGRAM_ADDRESS, Arete, AreteError, ConnectionManager, DEFAULT_CONFIG, DEFAULT_MAX_ENTRIES_PER_VIEW, FrameProcessor, InstructionError, MemoryAdapter, 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, 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 };
2420
- 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, 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 };
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 };
package/dist/index.esm.js CHANGED
@@ -3121,6 +3121,30 @@ function createTypedViews(stack, storage, subscriptionRegistry) {
3121
3121
  return views;
3122
3122
  }
3123
3123
 
3124
+ /**
3125
+ * Non-enumerable brand attached by the operation and read factories so
3126
+ * tooling (e.g. the knowledge-layer extractor's runtime walk) can classify
3127
+ * values by brand instead of duck-typing. Non-enumerable keeps JSON
3128
+ * serialization and object spreads of surrounding containers unchanged.
3129
+ */
3130
+ const OPERATION_KIND = '__areteOperationKind';
3131
+ function brandOperationKind(value, kind) {
3132
+ Object.defineProperty(value, OPERATION_KIND, {
3133
+ value: kind,
3134
+ enumerable: false,
3135
+ writable: false,
3136
+ configurable: false,
3137
+ });
3138
+ return value;
3139
+ }
3140
+ function getOperationKind(value) {
3141
+ if (value === null || (typeof value !== 'object' && typeof value !== 'function')) {
3142
+ return undefined;
3143
+ }
3144
+ const kind = value[OPERATION_KIND];
3145
+ return typeof kind === 'string' ? kind : undefined;
3146
+ }
3147
+
3124
3148
  class ReadRequestError extends Error {
3125
3149
  constructor(input) {
3126
3150
  super(`Read request to '${input.path}' failed (${input.status}): ${input.body}`);
@@ -3157,26 +3181,26 @@ async function parseReadResponse(response, path) {
3157
3181
  return response.json();
3158
3182
  }
3159
3183
  function programAccountRead(input) {
3160
- return {
3184
+ return brandOperationKind({
3161
3185
  account: input.account,
3162
3186
  schema: input.schema,
3163
- };
3187
+ }, 'account-fetch');
3164
3188
  }
3165
3189
  function programQuery(input) {
3166
- return {
3190
+ return brandOperationKind({
3167
3191
  name: input.name,
3168
3192
  path: input.path,
3169
3193
  method: input.method,
3170
3194
  schema: input.schema,
3171
- };
3195
+ }, 'query');
3172
3196
  }
3173
3197
  function stackQuery(input) {
3174
- return {
3198
+ return brandOperationKind({
3175
3199
  name: input.name,
3176
3200
  path: input.path,
3177
3201
  method: input.method,
3178
3202
  schema: input.schema,
3179
- };
3203
+ }, 'query');
3180
3204
  }
3181
3205
 
3182
3206
  function joinUrl(baseUrl, path) {
@@ -3197,6 +3221,19 @@ function decodeBase64(encoded) {
3197
3221
  }
3198
3222
  throw new Error('No base64 decoder available in this environment');
3199
3223
  }
3224
+ const MAX_BATCH_ADDRESSES = 100;
3225
+ function toRawAccount(body) {
3226
+ if (!body) {
3227
+ return null;
3228
+ }
3229
+ return {
3230
+ address: body.address,
3231
+ ownerProgram: body.ownerProgram,
3232
+ lamports: decimalU64(body.lamports, 'lamports'),
3233
+ executable: body.executable,
3234
+ data: decodeBase64(body.data),
3235
+ };
3236
+ }
3200
3237
  function decimalU64(value, field) {
3201
3238
  if (!/^\d+$/.test(value)) {
3202
3239
  throw new TypeError(`${field} must be a decimal u64 string`);
@@ -3284,17 +3321,33 @@ function createChainClient(httpBaseUrl, fetchImpl) {
3284
3321
  async account(address) {
3285
3322
  const path = `/chain/accounts/${encodeURIComponent(address)}`;
3286
3323
  const response = await fetchImpl(joinUrl(httpBaseUrl, path));
3324
+ return toRawAccount(await parseReadResponse(response, path));
3325
+ },
3326
+ async accounts(addresses) {
3327
+ // Copied before anything else: `readonly string[]` accepts a mutable array, so a caller can
3328
+ // splice it while the request is in flight and the cardinality check below would then compare
3329
+ // the response against a list that is no longer what was asked for. The Python client copies
3330
+ // for the same reason.
3331
+ const requested = [...addresses];
3332
+ if (requested.length > MAX_BATCH_ADDRESSES) {
3333
+ throw new RangeError(`addresses exceeds the ${MAX_BATCH_ADDRESSES}-address limit for one batch`);
3334
+ }
3335
+ if (requested.length === 0) {
3336
+ return [];
3337
+ }
3338
+ const path = '/chain/accounts';
3339
+ const response = await fetchImpl(joinUrl(httpBaseUrl, path), {
3340
+ method: 'POST',
3341
+ headers: { 'content-type': 'application/json' },
3342
+ body: JSON.stringify({ addresses: requested }),
3343
+ });
3287
3344
  const body = await parseReadResponse(response, path);
3288
- if (!body) {
3289
- return null;
3345
+ // A different count would shift every later account onto the wrong address.
3346
+ if (body.items.length !== requested.length) {
3347
+ throw new TypeError(`Invalid chain response for '${path}': expected ${requested.length} items, got ${body.items.length}`);
3290
3348
  }
3291
- return {
3292
- address: body.address,
3293
- ownerProgram: body.ownerProgram,
3294
- lamports: body.lamports,
3295
- executable: body.executable,
3296
- data: decodeBase64(body.data),
3297
- };
3349
+ // Positionally aligned with `requested`; absent accounts arrive as null.
3350
+ return body.items.map(toRawAccount);
3298
3351
  },
3299
3352
  async mint(address) {
3300
3353
  const path = `/chain/mints/${encodeURIComponent(address)}`;
@@ -4803,12 +4856,18 @@ function serializeValue(value, type) {
4803
4856
  if ('vec' in type) {
4804
4857
  return serializeVec(value, type.vec);
4805
4858
  }
4859
+ if ('vecU64Len' in type) {
4860
+ return serializeVec(value, type.vecU64Len, 8);
4861
+ }
4806
4862
  if ('option' in type) {
4807
4863
  return serializeOption(value, type.option);
4808
4864
  }
4809
4865
  if ('array' in type) {
4810
4866
  return serializeArray(value, type.array[0], type.array[1]);
4811
4867
  }
4868
+ if ('tuple' in type) {
4869
+ return serializeTuple(value, type.tuple);
4870
+ }
4812
4871
  if ('hashMap' in type) {
4813
4872
  return serializeHashMap(value, type.hashMap[0], type.hashMap[1]);
4814
4873
  }
@@ -4836,6 +4895,15 @@ function serializeStruct(value, fields) {
4836
4895
  }
4837
4896
  return Buffer.concat(buffers);
4838
4897
  }
4898
+ function serializeTuple(value, elementTypes) {
4899
+ if (!Array.isArray(value)) {
4900
+ throw new Error(`Tuple value must be an array, got ${typeof value}`);
4901
+ }
4902
+ if (value.length !== elementTypes.length) {
4903
+ throw new Error(`Tuple length mismatch: expected ${elementTypes.length}, got ${value.length}`);
4904
+ }
4905
+ return Buffer.concat(elementTypes.map((elementType, index) => serializeValue(value[index], elementType)));
4906
+ }
4839
4907
  function serializeHashMap(value, keyType, valueType) {
4840
4908
  if (keyType !== 'string') {
4841
4909
  throw new Error(`Instruction hashMap keys must use the 'string' schema, got ${JSON.stringify(keyType)}`);
@@ -5009,9 +5077,15 @@ function serializePrimitive(value, type) {
5009
5077
  throw new Error(`Unknown primitive type: ${type}`);
5010
5078
  }
5011
5079
  }
5012
- function serializeVec(values, elementType) {
5013
- const len = Buffer.alloc(4);
5014
- len.writeUInt32LE(values.length, 0);
5080
+ // `lengthBytes`: 4 for Borsh, 8 for bincode-style sequences.
5081
+ function serializeVec(values, elementType, lengthBytes = 4) {
5082
+ const len = Buffer.alloc(lengthBytes);
5083
+ if (lengthBytes === 8) {
5084
+ len.writeBigUInt64LE(BigInt(values.length), 0);
5085
+ }
5086
+ else {
5087
+ len.writeUInt32LE(values.length, 0);
5088
+ }
5015
5089
  const elementBuffers = values.map(v => serializeValue(v, elementType));
5016
5090
  return Buffer.concat([len, ...elementBuffers]);
5017
5091
  }
@@ -7243,22 +7317,22 @@ async function createSession(definition, ...args) {
7243
7317
  }
7244
7318
 
7245
7319
  function instructionOperation(prepare) {
7246
- return {
7320
+ return brandOperationKind({
7247
7321
  kind: 'instruction',
7248
7322
  prepare: async (input) => prepare(input),
7249
- };
7323
+ }, 'instruction');
7250
7324
  }
7251
7325
  function transactionOperation(prepare) {
7252
- return {
7326
+ return brandOperationKind({
7253
7327
  kind: 'transaction',
7254
7328
  prepare: async (input) => prepare(input),
7255
- };
7329
+ }, 'transaction');
7256
7330
  }
7257
7331
  function flowOperation(prepare) {
7258
- return {
7332
+ return brandOperationKind({
7259
7333
  kind: 'flow',
7260
7334
  prepare: async (input) => prepare(input),
7261
- };
7335
+ }, 'flow');
7262
7336
  }
7263
7337
 
7264
7338
  function chainAccountLoader(chain) {
@@ -7420,5 +7494,5 @@ function stringifyBigints(value) {
7420
7494
 
7421
7495
  const Arete = Object.assign(Arete$1, { session: createSession });
7422
7496
 
7423
- export { ASSOCIATED_TOKEN_PROGRAM_ADDRESS, Arete, AreteError, ConnectionManager, DEFAULT_CONFIG, DEFAULT_MAX_ENTRIES_PER_VIEW, FrameProcessor, InstructionError, MemoryAdapter, 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, 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 };
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 };
7424
7498
  //# sourceMappingURL=index.esm.js.map