This repository was archived by the owner on Jan 22, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 939
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Loading status checks…
React hooks you can use to obtain
@solana/signers
types from Wallet…
… Standard wallet accounts (#2795) # Summary This is the big one; the hooks that most applications should use when dealing with wallets. 1. Select a wallet account, using the `@wallet-standard/react` hooks 2. Create a signer out of that wallet account 3. Create a transaction message with that signer 4. Pass it to `signAndSendTransactionMessageWithSigners()` 5. ??? 6. Success # Notes * I made all of the `*Signer` types as conservative as possible, meaning that they presume the _maximum_ wallet interference with messages and transactions. Because an application can not guarantee that a wallet won't modify a transaction or message, I've used the `MessageModifying` and `TransactionModifying` variants of the `@solana/signers` types. # Example ```tsx const signer = useWalletAccountTransactionSendingSigner(walletAccount); function onDoTransaction() { const message = pipe( createTransaction({ version: 0 }), m => setTransactionMessageFeePayerSigner(signer, m), m => setTransactionMessageLifetimeUsingBlockhash(latestBlockhash, m), m => addTransactionMessageInstruction( getTransferSolInstruction({ amount: lamports(1_000_000_000), destination: address('...'), source: signer, }), m, ), ); await signAndSendTransactionMessageWithSigners(message); } ```
1 parent
8fe4551
commit ce876d9
Showing
16 changed files
with
1,069 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
'@solana/react': patch | ||
--- | ||
|
||
Added React hooks to which you can pass a Wallet Standard `UiWalletAccount` and obtain a `MessageModifyingSigner`, `TransactionModifyingSigner`, or `TransactionSendingSigner` for use in constructing, signing, and sending Solana transactions and messages |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.