DAG & Dependencies
RLock's DAG is implicit: pass a list of intents to buildTransaction. The builder:
- Inserts ComputeBudget instructions.
- Optionally resolves ALTs.
- Compiles a v0 message.
- Checks size and throws
TransactionTooLargeErrorif it exceeds maxMessageSize (default 1232 bytes).
Builder checks
TransactionTooLargeErrorwhen serialized.length > maxMessageSize.- Uses your
AddressLookupSourceto offload keys and shorten the message.
If it overflows
Split the intents across multiple transactions.
Binary-search "chunker" (userland helper, not part of SDK)
import { buildTransaction, TransactionTooLargeError, type BuildTransactionOptions } from '@rlock/cpsr-sdk';
export async function buildInChunks(
base: Omit<BuildTransactionOptions, 'intents'>,
intents: BuildTransactionOptions['intents'],
maxMessageSize = 1232
) {
const txs = [];
let start = 0;
while (start < intents.length) {
let end = intents.length;
let built: any = null;
// Find the largest slice that fits
let lo = start + 1, hi = intents.length;
while (lo <= hi) {
const mid = Math.floor((lo + hi) / 2);
try {
built = await buildTransaction({ ...base, intents: intents.slice(start, mid), maxMessageSize });
lo = mid + 1; end = mid;
} catch (e) {
if (e instanceof TransactionTooLargeError) hi = mid - 1;
else throw e;
}
}
if (!built) {
await buildTransaction({ ...base, intents: intents.slice(start, start + 1), maxMessageSize });
}
txs.push(built!);
start = end;
}
return txs;
}