Skip to content

Commit 6e095fb

Browse files
github-actions[bot]tao-stonessteveluscher
authored
add loadedAccountsDataSize to simulate transaction response (#521) (#821)
* add loadedAccountsDataSize to simulate transaction response * alpha-order new field with type number * update test * add changeset * alpha-order error code * update set-transaction-test for added field * Ran `pnpm style:fix` * Change allowed numeric path to `value.loadedAccountsDataSize` --------- (cherry picked from commit 98bde94) Co-authored-by: Tao Zhu <82401714+tao-stones@users.noreply.github.com> Co-authored-by: Steven Luscher <steven.luscher@anza.xyz>
1 parent f4913bc commit 6e095fb

File tree

6 files changed

+24
-1
lines changed

6 files changed

+24
-1
lines changed

.changeset/tidy-baths-rule.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@solana/kit': patch
3+
---
4+
5+
Add loadedAccountsDataSize to simulateTransaction response

packages/errors/src/json-rpc-error.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ export interface RpcSimulateTransactionResult {
8484
)[];
8585
}[]
8686
| null;
87+
loadedAccountsDataSize: number | null;
8788
logs: string[] | null;
8889
replacementBlockhash: string | null;
8990
returnData: {

packages/rpc-api/src/__tests__/send-transaction-test.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -247,6 +247,7 @@ describe('sendTransaction', () => {
247247
accounts: null,
248248
cause: new SolanaError(SOLANA_ERROR__TRANSACTION_ERROR__ACCOUNT_NOT_FOUND),
249249
innerInstructions: null,
250+
loadedAccountsDataSize: 0,
250251
logs: [],
251252
replacementBlockhash: null,
252253
returnData: null,
@@ -283,6 +284,7 @@ describe('sendTransaction', () => {
283284
accounts: null,
284285
cause: new SolanaError(SOLANA_ERROR__TRANSACTION_ERROR__INSUFFICIENT_FUNDS_FOR_FEE),
285286
innerInstructions: null,
287+
loadedAccountsDataSize: 0,
286288
logs: [],
287289
replacementBlockhash: null,
288290
returnData: null,
@@ -316,6 +318,7 @@ describe('sendTransaction', () => {
316318
accounts: null,
317319
cause: new SolanaError(SOLANA_ERROR__TRANSACTION_ERROR__BLOCKHASH_NOT_FOUND),
318320
innerInstructions: null,
321+
loadedAccountsDataSize: 0,
319322
logs: [],
320323
replacementBlockhash: null,
321324
returnData: null,

packages/rpc-api/src/__tests__/simulate-transaction-test.ts

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,7 @@ describe('simulateTransaction', () => {
173173
accounts: null,
174174
err: null,
175175
innerInstructions: null,
176+
loadedAccountsDataSize: expect.any(Number),
176177
logs: expect.any(Array),
177178
replacementBlockhash: null,
178179
returnData: null,
@@ -284,6 +285,7 @@ describe('simulateTransaction', () => {
284285
accounts: null,
285286
err: null,
286287
innerInstructions: null,
288+
loadedAccountsDataSize: expect.any(Number),
287289
logs: expect.any(Array),
288290
replacementBlockhash: null,
289291
returnData: null,
@@ -324,6 +326,7 @@ describe('simulateTransaction', () => {
324326
accounts: null,
325327
err: 'BlockhashNotFound',
326328
innerInstructions: null,
329+
loadedAccountsDataSize: expect.any(Number),
327330
logs: expect.any(Array),
328331
replacementBlockhash: null,
329332
returnData: null,
@@ -364,6 +367,7 @@ describe('simulateTransaction', () => {
364367
accounts: null,
365368
err: null,
366369
innerInstructions: null,
370+
loadedAccountsDataSize: expect.any(Number),
367371
logs: expect.any(Array),
368372
replacementBlockhash: {
369373
blockhash: expect.any(String),
@@ -469,6 +473,7 @@ describe('simulateTransaction', () => {
469473
accounts: null,
470474
err: 'AccountNotFound',
471475
innerInstructions: null,
476+
loadedAccountsDataSize: expect.any(Number),
472477
logs: expect.any(Array),
473478
replacementBlockhash: null,
474479
returnData: null,
@@ -519,6 +524,7 @@ describe('simulateTransaction', () => {
519524
],
520525
err: null,
521526
innerInstructions: null,
527+
loadedAccountsDataSize: expect.any(Number),
522528
logs: expect.any(Array),
523529
replacementBlockhash: null,
524530
returnData: null,
@@ -569,6 +575,7 @@ describe('simulateTransaction', () => {
569575
],
570576
err: null,
571577
innerInstructions: null,
578+
loadedAccountsDataSize: expect.any(Number),
572579
logs: expect.any(Array),
573580
replacementBlockhash: null,
574581
returnData: null,
@@ -636,6 +643,7 @@ describe('simulateTransaction', () => {
636643
],
637644
err: null,
638645
innerInstructions: null,
646+
loadedAccountsDataSize: expect.any(Number),
639647
logs: expect.any(Array),
640648
replacementBlockhash: null,
641649
returnData: null,
@@ -687,6 +695,7 @@ describe('simulateTransaction', () => {
687695
],
688696
err: null,
689697
innerInstructions: null,
698+
loadedAccountsDataSize: expect.any(Number),
690699
logs: expect.any(Array),
691700
replacementBlockhash: null,
692701
returnData: null,
@@ -736,7 +745,7 @@ describe('simulateTransaction', () => {
736745
],
737746
err: null,
738747
innerInstructions: null,
739-
748+
loadedAccountsDataSize: expect.any(Number),
740749
logs: expect.any(Array),
741750
replacementBlockhash: null,
742751
returnData: null,
@@ -792,6 +801,7 @@ describe('simulateTransaction', () => {
792801
],
793802
err: null,
794803
innerInstructions: null,
804+
loadedAccountsDataSize: expect.any(Number),
795805
logs: expect.any(Array),
796806
replacementBlockhash: null,
797807
returnData: null,
@@ -833,6 +843,7 @@ describe('simulateTransaction', () => {
833843
accounts: null,
834844
err: null,
835845
innerInstructions: null,
846+
loadedAccountsDataSize: expect.any(Number),
836847
logs: expect.any(Array),
837848
replacementBlockhash: null,
838849
returnData: null,

packages/rpc-api/src/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -343,6 +343,7 @@ function getAllowedNumericKeypaths(): AllowedNumericKeypaths<RpcApi<SolanaRpcApi
343343
['delinquent', KEYPATH_WILDCARD, 'commission'],
344344
],
345345
simulateTransaction: [
346+
['value', 'loadedAccountsDataSize'],
346347
...jsonParsedAccountsConfigs.map(c => ['value', 'accounts', KEYPATH_WILDCARD, ...c]),
347348
...innerInstructionsConfigs.map(c => ['value', 'innerInstructions', KEYPATH_WILDCARD, ...c]),
348349
],

packages/rpc-api/src/simulateTransaction.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,8 @@ type WithInnerInstructionsConfig = Readonly<{
9696
type SimulateTransactionApiResponseBase = Readonly<{
9797
/** If the transaction failed, this property will contain the error */
9898
err: TransactionError | null;
99+
/** The number of bytes of all accounts loaded by this transaction */
100+
loadedAccountsDataSize?: number;
99101
/**
100102
* Array of log messages the transaction instructions output during execution, `null` if
101103
* simulation failed before the transaction was able to execute (for example due to an invalid

0 commit comments

Comments
 (0)