-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: implement web-solana-ui library
- Loading branch information
Showing
51 changed files
with
1,034 additions
and
746 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 |
---|---|---|
|
@@ -91,5 +91,8 @@ | |
] | ||
} | ||
} | ||
] | ||
], | ||
"metadata": { | ||
"address": "5t7i8rFcWxrBhf7PYbxBQudXYQLnJW4zBS4xiknaFuCv" | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import { Group } from '@mantine/core' | ||
import { | ||
SolanaUiAccountBalanceButton, | ||
SolanaUiAccountChecker, | ||
SolanaUiClusterChecker, | ||
SolanaUiClusterSelect, | ||
WalletIcon, | ||
} from '@pubkey-stack/web-solana-ui' | ||
import { UiHeaderProfile } from '@pubkey-stack/web-ui-core' | ||
import { UiHeader, UiLayout } from '@pubkey-ui/core' | ||
import { useWallet } from '@solana/wallet-adapter-react' | ||
import { ReactNode } from 'react' | ||
|
||
export function WebShellLayout({ children }: { children: ReactNode }) { | ||
const { publicKey } = useWallet() | ||
return ( | ||
<UiLayout | ||
header={ | ||
<UiHeader | ||
links={[ | ||
{ link: '/dashboard', label: 'Dashboard' }, | ||
{ link: '/solana', label: 'Solana' }, | ||
]} | ||
profile={ | ||
<Group gap="xs"> | ||
{publicKey && <SolanaUiAccountBalanceButton address={publicKey} />} | ||
{publicKey && <SolanaUiClusterSelect />} | ||
<WalletIcon /> | ||
<UiHeaderProfile /> | ||
</Group> | ||
} | ||
/> | ||
} | ||
> | ||
<SolanaUiClusterChecker> | ||
<SolanaUiAccountChecker /> | ||
</SolanaUiClusterChecker> | ||
{children} | ||
</UiLayout> | ||
) | ||
} |
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 |
---|---|---|
@@ -1,4 +1,5 @@ | ||
export * from './lib/solana-explorer-link' | ||
export * from './lib/create-transaction' | ||
export * from './lib/toast-signature-link' | ||
export * from './lib/use-account' | ||
export * from './lib/web-cluster-provider' | ||
export * from './lib/web-solana-provider' |
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,50 @@ | ||
import { | ||
Connection, | ||
LAMPORTS_PER_SOL, | ||
PublicKey, | ||
SystemProgram, | ||
TransactionMessage, | ||
VersionedTransaction, | ||
} from '@solana/web3.js' | ||
|
||
export async function createTransaction({ | ||
publicKey, | ||
destination, | ||
amount, | ||
connection, | ||
}: { | ||
publicKey: PublicKey | ||
destination: PublicKey | ||
amount: number | ||
connection: Connection | ||
}): Promise<{ | ||
transaction: VersionedTransaction | ||
latestBlockhash: { blockhash: string; lastValidBlockHeight: number } | ||
}> { | ||
// Get the latest blockhash to use in our transaction | ||
const latestBlockhash = await connection.getLatestBlockhash() | ||
|
||
// Create instructions to send, in this case a simple transfer | ||
const instructions = [ | ||
SystemProgram.transfer({ | ||
fromPubkey: publicKey, | ||
toPubkey: destination, | ||
lamports: amount * LAMPORTS_PER_SOL, | ||
}), | ||
] | ||
|
||
// Create a new TransactionMessage with version and compile it to legacy | ||
const messageLegacy = new TransactionMessage({ | ||
payerKey: publicKey, | ||
recentBlockhash: latestBlockhash.blockhash, | ||
instructions, | ||
}).compileToLegacyMessage() | ||
|
||
// Create a new VersionedTransaction which supports legacy and v0 | ||
const transaction = new VersionedTransaction(messageLegacy) | ||
|
||
return { | ||
transaction, | ||
latestBlockhash, | ||
} | ||
} |
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.