-
Notifications
You must be signed in to change notification settings - Fork 200
chore: refactor to invert logic to injectable #1584
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
chore: refactor to invert logic to injectable #1584
Conversation
|
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
e10a1ec to
046dc9c
Compare
000d716 to
eda07aa
Compare
0c607c8 to
a8a7491
Compare
| transactionComponents: { | ||
| preSend: async (transaction) => { | ||
| if ("version" in transaction) { | ||
| transaction.sign([stakeAccount]); | ||
| } | ||
| return signers.fromSigner(transaction); | ||
| }, |
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.
this is something that app devs need to know about?
is this not something that our hook can do to simplify things?
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.
This is in the case we want to over write the sending, for example on this one we have one more signer, and then we need the logic for the previous. It will fail on the simulation for the send transaction if we forgot the original from signer
And in the case of poke the duck, there is no signer except the sponsor, so the overwrite is just an identity function.
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.
So, the components of the sendSolanaTransaction
(transfer? ) -> instructions --transactionBuilder-> Transaction --preSend-> Broadcast
And now as params are the components that make up this function in the cases we want custom logic, it is easy for a one off change now.
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.
stateDiagram-v2
[*] --> instructions
[*] --> transfer
transfer --> instructions
instructions --> Transaction : transformInstruction
Transaction --> broadcastedResult : preSend
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.
Could have also been
preSend: async (transaction) => {
if ("version" in transaction) {
transaction.sign([stakeAccount]);
}
await solanaSigner.addSignature(transaction);
return transaction
},
7536552 to
bffc846
Compare
moldy530
left a comment
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.
LGMT with one small nit
| transaction.message.staticAccountKeys.find( | ||
| (key) => key.toBase58() === signer?.address | ||
| ) |
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.
nit: this should also check that transaction.message.isSigner(idx) is true
* Revert "feat: solana nft demo (#1578)" This reverts commit 7ad9c20. * Revert "Revert "feat: solana nft demo (#1578)"" This reverts commit 9b84edc. * Revert "Revert "feat: solana nft demo (#1578)" (#1582)" This reverts commit 4691730. * fix: pr changes * chore: fix test that has a timing issue maybe * fix: allow the one card to do all * Update examples/ui-demo/src/components/small-cards/SolanaNftCard.tsx * feat: do auto from airdrop * chore: refactor to invert logic to injectable (#1584) * chore: refactor to invert logic to injectable * feat: do auto from airdrop * feat: make it so the adding self signer is automatically * chore: adding in the other transaction filtering based on the keys * fix: edge case on key may not be signer * feat: remove the address from the solana card * fix: link to transaction needs three lines for card * chore: remove old new badges for other cards * fix: imports are not .js * chore: undo stage change * fix: weird bug on import * chore: change the function * chore: add in the doc build * chore: change the sponsoring to include rent * fix: styling in card to match comments made in pr
Pull Request Checklist
yarn test)sitefolder, and guidelines for updating/adding docs can be found in the contribution guide)feat!: breaking change)yarn lint:check) and fix any issues? (yarn lint:write)PR-Codex overview
This PR focuses on refactoring the transaction handling in the
SolanaNftCardcomponent and theuseSolanaTransactionhook to improve the transaction flow and introduce new capabilities for pre-processing transactions.Detailed summary
PKfunction fromSolanaNftCard.sendTransactionAsyncto includetransactionComponentsfor pre-send handling.PreSendandTransformInstructiontypes inuseSolanaTransaction.useSolanaTransactionto handle transaction preparation and signing more flexibly.getInstructionsandneedsSignerToSignhelper functions inuseSolanaTransaction.missingfunction for better clarity.