This repository has been archived by the owner on Nov 26, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
URANI
committed
Mar 28, 2024
1 parent
b27bc20
commit b29cd60
Showing
29 changed files
with
5,045 additions
and
105 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
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 |
---|---|---|
|
@@ -4,4 +4,6 @@ | |
|
||
### ➡️ [Backend demos](backend) | ||
|
||
### ➡️ [Frontend demos](frontend) | ||
### ➡️ [Frontend demos](frontend) | ||
|
||
|
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,5 +1,9 @@ | ||
|
||
.anchor | ||
.DS_Store | ||
target | ||
Cargo.lock | ||
**/*.rs.bk | ||
node_modules | ||
target/* | ||
.env | ||
test-ledger | ||
.yarn | ||
.env |
12 changes: 0 additions & 12 deletions
12
demos/frontend/01_connecting_to_the_blockchain/migrations/deploy.ts
This file was deleted.
Oops, something went wrong.
19 changes: 0 additions & 19 deletions
19
demos/frontend/01_connecting_to_the_blockchain/programs/connecting/Cargo.toml
This file was deleted.
Oops, something went wrong.
2 changes: 0 additions & 2 deletions
2
demos/frontend/01_connecting_to_the_blockchain/programs/connecting/Xargo.toml
This file was deleted.
Oops, something went wrong.
15 changes: 0 additions & 15 deletions
15
demos/frontend/01_connecting_to_the_blockchain/programs/connecting/src/lib.rs
This file was deleted.
Oops, something went wrong.
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,8 +1,8 @@ | ||
|
||
.anchor | ||
.DS_Store | ||
target | ||
**/*.rs.bk | ||
node_modules | ||
test-ledger | ||
.yarn | ||
.env |
12 changes: 0 additions & 12 deletions
12
demos/frontend/02_non_native_programs/migrations/deploy.ts
This file was deleted.
Oops, something went wrong.
19 changes: 0 additions & 19 deletions
19
demos/frontend/02_non_native_programs/programs/non_native_programs/Cargo.toml
This file was deleted.
Oops, something went wrong.
2 changes: 0 additions & 2 deletions
2
demos/frontend/02_non_native_programs/programs/non_native_programs/Xargo.toml
This file was deleted.
Oops, something went wrong.
15 changes: 0 additions & 15 deletions
15
demos/frontend/02_non_native_programs/programs/non_native_programs/src/lib.rs
This file was deleted.
Oops, something went wrong.
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,9 @@ | ||
|
||
.anchor | ||
.DS_Store | ||
target | ||
**/*.rs.bk | ||
node_modules | ||
test-ledger | ||
.yarn | ||
.next |
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,36 @@ | ||
# 🛹 Demo 3: Connecting with a Wallet | ||
|
||
|
||
<br> | ||
|
||
### tl; dr | ||
|
||
<br> | ||
|
||
* In ths demo, we will use [@solana/wallet-adapter-base and @solana/wallet-adapter-react.-Adapter](https://github.com/anza-xyz/wallet-adapter) to create the frontend for a transaction approval for last's demo ping program. | ||
|
||
<br> | ||
|
||
--- | ||
|
||
### Setup | ||
|
||
<br> | ||
|
||
* Run `npm install` from the root of the project. | ||
* Install [Phantom Wallet](https://phantom.app/). | ||
|
||
|
||
<br> | ||
|
||
--- | ||
|
||
|
||
### Running | ||
|
||
<br> | ||
|
||
``` | ||
npm install | ||
npm run dev | ||
``` |
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,14 @@ | ||
import { FC } from 'react' | ||
import styles from '../styles/Home.module.css' | ||
import { WalletMultiButton } from '@solana/wallet-adapter-react-ui' | ||
import Image from 'next/image' | ||
|
||
export const AppBar: FC = () => { | ||
return ( | ||
<div className={styles.AppHeader}> | ||
<Image src="/solanaLogo.png" height={30} width={200} /> | ||
<span>Wallet-Adapter Example</span> | ||
<WalletMultiButton /> | ||
</div> | ||
) | ||
} |
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,42 @@ | ||
import { useConnection, useWallet } from '@solana/wallet-adapter-react'; | ||
import * as web3 from '@solana/web3.js' | ||
import { FC } from 'react' | ||
import styles from '../styles/PingButton.module.css' | ||
|
||
const PROGRAM_ID = `ChT1B39WKLS8qUrkLvFDXMhEJ4F1XZzwUNHUt4AU9aVa` | ||
const DATA_ACCOUNT_PUBKEY = `Ah9K7dQ8EHaZqcAsgBW8w37yN2eAy3koFmUn4x3CJtod` | ||
|
||
export const PingButton: FC = () => { | ||
const { connection } = useConnection(); | ||
const { publicKey, sendTransaction } = useWallet(); | ||
|
||
const onClick = () => { | ||
if (!connection || !publicKey) { return } | ||
|
||
const programId = new web3.PublicKey(PROGRAM_ID) | ||
const programDataAccount = new web3.PublicKey(DATA_ACCOUNT_PUBKEY) | ||
const transaction = new web3.Transaction() | ||
|
||
const instruction = new web3.TransactionInstruction({ | ||
keys: [ | ||
{ | ||
pubkey: programDataAccount, | ||
isSigner: false, | ||
isWritable: true | ||
}, | ||
], | ||
programId | ||
}); | ||
|
||
transaction.add(instruction) | ||
sendTransaction(transaction, connection).then(sig => { | ||
console.log(sig) | ||
}) | ||
} | ||
|
||
return ( | ||
<div className={styles.buttonContainer} onClick={onClick}> | ||
<button className={styles.button}>Ping!</button> | ||
</div> | ||
) | ||
} |
23 changes: 23 additions & 0 deletions
23
demos/frontend/03_wallets/components/WalletContextProvider.tsx
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,23 @@ | ||
import { FC, ReactNode } from 'react'; | ||
import { ConnectionProvider, WalletProvider } from '@solana/wallet-adapter-react' | ||
import { WalletModalProvider } from "@solana/wallet-adapter-react-ui"; | ||
import * as web3 from '@solana/web3.js' | ||
import * as walletAdapterWallets from '@solana/wallet-adapter-wallets'; | ||
require('@solana/wallet-adapter-react-ui/styles.css'); | ||
|
||
const WalletContextProvider: FC<{ children: ReactNode }> = ({ children }) => { | ||
const endpoint = web3.clusterApiUrl('devnet') | ||
const wallets = [new walletAdapterWallets.PhantomWalletAdapter()] | ||
|
||
return ( | ||
<ConnectionProvider endpoint={endpoint}> | ||
<WalletProvider wallets={wallets}> | ||
<WalletModalProvider> | ||
{ children } | ||
</WalletModalProvider> | ||
</WalletProvider> | ||
</ConnectionProvider> | ||
) | ||
} | ||
|
||
export default WalletContextProvider |
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 @@ | ||
/// <reference types="next" /> | ||
/// <reference types="next/image-types/global" /> | ||
|
||
// NOTE: This file should not be edited | ||
// see https://nextjs.org/docs/basic-features/typescript for more information. |
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,6 @@ | ||
/** @type {import('next').NextConfig} */ | ||
const nextConfig = { | ||
reactStrictMode: true, | ||
} | ||
|
||
module.exports = nextConfig |
Oops, something went wrong.