From bc5e10c14d559d57a6a1b93af2302bbdd165bf5c Mon Sep 17 00:00:00 2001 From: sohrab <4444588+sohrab-@users.noreply.github.com> Date: Thu, 23 Feb 2023 17:42:42 +1100 Subject: [PATCH] feat: add anchor example, update welcome message and acks --- .../client/accounts/AirdropButton.tsx | 2 - src/components/client/results/Results.tsx | 21 ++++---- src/components/header/Examples.tsx | 19 ++++++- src/components/info/Acknowledgements.tsx | 52 +++++++++---------- src/hooks/useTransactionStatusToast.tsx | 6 +-- src/library/examples.ts | 35 ++++++++++++- 6 files changed, 87 insertions(+), 48 deletions(-) diff --git a/src/components/client/accounts/AirdropButton.tsx b/src/components/client/accounts/AirdropButton.tsx index a60b57a..3c5249b 100644 --- a/src/components/client/accounts/AirdropButton.tsx +++ b/src/components/client/accounts/AirdropButton.tsx @@ -26,7 +26,6 @@ import { VStack, } from "@chakra-ui/react"; import { LAMPORTS_PER_SOL, PublicKey } from "@solana/web3.js"; -import { useSessionStoreWithUndo } from "hooks/useSessionStore"; import { useTransactionStatusToast } from "hooks/useTransactionStatusToast"; import { useWeb3Connection } from "hooks/useWeb3Connection"; import React, { useRef, useState } from "react"; @@ -39,7 +38,6 @@ export const AirdropButton: React.FC<{ accountPubkey: IPubKey }> = ({ accountPubkey, }) => { const [value, setValue] = useState("1.0"); - const rpcEndpoint = useSessionStoreWithUndo((state) => state.rpcEndpoint); const initialFocusRef = useRef(null); const connection = useWeb3Connection(); diff --git a/src/components/client/results/Results.tsx b/src/components/client/results/Results.tsx index 659cc7d..f6d04be 100644 --- a/src/components/client/results/Results.tsx +++ b/src/components/client/results/Results.tsx @@ -87,15 +87,18 @@ export const Results = forwardRef< - {endedAt && ( - - - {new Date(endedAt).toLocaleTimeString()} - - - )} + { + // do not display if transaction has been cleared, i.e. no signature + endedAt && transactionRun.signature && ( + + + {new Date(endedAt).toLocaleTimeString()} + + + ) + } {transactionRun.inProgress ? ( )} diff --git a/src/library/examples.ts b/src/library/examples.ts index a308c4d..59d0895 100644 --- a/src/library/examples.ts +++ b/src/library/examples.ts @@ -1,7 +1,5 @@ import { ITransactionExt } from "types/external"; -// TODO add an Anchor example - export const EXAMPLES: Record = { memoV2Program: { version: "1.0.0", @@ -164,4 +162,37 @@ _A lamport is 0.000,000,001 SOL._`, }, ], }, + + anchorSquads: { + version: "1.0.0", + txnVersion: "0", + network: "devnet", + name: "Anchor: Squads", + description: `If an Anchor program has an on-chain IDL, _Better Call Sol_ can help you invoke it. + +For this example, we are using [Squads MPL](https://squads.so/), a popular multisig program. We have pre-populated the program ID for you. + +The tool detects the IDL and see shows ⚓ icon in the Program field. + +1. Click on this button to get a list of possible instructions to pre-populate. +1. Eject out of Anchor instruction into a plain one by clicking ⏏️ button next to the _Anchor Method_ field. +1. Once you eject, you will see that the tool can also detect an Anchor program instruction. Convert back using the 🔁 button, next to the "Detected Anchor Method". + +The latter is particularly useful when you import a transaction from the chain.`, + addressLookupTables: [], + instructions: [ + { + name: "Squads", + programId: "SMPLecH534NA9acpos4G6x7uf3LWbCAwZQE9e8ZekMu", + accounts: [], + data: { + format: "raw", + value: { + encoding: "utf8", + content: "", + }, + }, + }, + ], + }, };