-
Notifications
You must be signed in to change notification settings - Fork 922
Added programId field in TokenBalance type #3592
Added programId field in TokenBalance type #3592
Conversation
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Adding this property to the TypeScript type is insufficient to vend it to the caller.
Look here:
https://github.com/solana-labs/solana-web3.js/blob/maintenance/v1.x/src/connection.ts#L2329-L2334
To get your PRs in faster, make sure to test your changes, to write down in your PR description exactly what you did, and to paste in the results as proof that the code works.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To get your PRs in faster, make sure to test your changes, to write down in your PR description exactly what you did, and to paste in the results as proof that the code works.
Doing this will make it really easy for me to accept your PR with high confidence.
-
Run code quality scripts
pnpm test:lint && pnpm test:typecheck && pnpm test:prettier
-
Build the code
pnpm compile:js && pnpm compile:typedefs
-
Start a REPL
pnpm node > const { Connection } = require('./lib/index.cjs.js'); > const connection = new Connection('https://api.devnet.solana.com');
-
Do your testing. Use the
connection
instance to make a query, show that theprogramId
field materializes on the response, and that there are no fatals. Paste all of your steps and results into the PR description.
src/connection.ts
Outdated
@@ -2330,6 +2331,7 @@ const TokenBalanceResult = pick({ | |||
accountIndex: number(), | |||
mint: string(), | |||
owner: optional(string()), | |||
programId:optional(string()), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can see that you haven't run any tests or build scripts, because this line of code isn't formatted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Almost!
The data structure you edited is called TokenBalance
https://github.com/solana-labs/solana-web3.js/blob/maintenance/v1.x/src/connection.ts#L1049-L1054
You can see it in use here:
https://github.com/solana-labs/solana-web3.js/blob/maintenance/v1.x/src/connection.ts#L1085-L1088
And here:
https://github.com/solana-labs/solana-web3.js/blob/maintenance/v1.x/src/connection.ts#L1116-L1119
Those properties are materialized here:
https://github.com/solana-labs/solana-web3.js/blob/maintenance/v1.x/src/connection.ts#L2344-L2370
And here:
https://github.com/solana-labs/solana-web3.js/blob/maintenance/v1.x/src/connection.ts#L2375-L2395
Look at all of the RPC calls that materialize ConfirmedTransactionMetaResult
and ParsedConfirmedTransactionMetaResult
.
You'll see that one such call is this one:
https://github.com/solana-labs/solana-web3.js/blob/maintenance/v1.x/src/connection.ts#L2573C7-L2583
So find out where that is used:
https://github.com/solana-labs/solana-web3.js/blob/maintenance/v1.x/src/connection.ts#L5053-L5083
And there we have an actual RPC call you can make; getTransaction()
. There are many others, but this is one. You could conceive of a transaction that you could get, then check result.meta.postTokenBalances
to see if you got the new property!
Just make sure you actually use a transaction that involves SPL tokens, or that array will be empty and you won't learn anything.
Beautiful. Thank you! |
526ce5f
into
solana-labs:maintenance/v1.x
🎉 This PR is included in version 1.95.5 🎉 The release is available on: Your semantic-release bot 📦🚀 |
Thank you so much @steveluscher |
Because there has been no activity on this PR for 14 days since it was merged, it has been automatically locked. Please open a new issue if it requires a follow up. |
Tackles the issue (#3091)
Done proper linting , built and complied properly , also tested to see if programId returns as expected ,
also added the screenshots
Please tell me if I am missing something and Thank you for being patient and helping me through this.