diff --git a/ts/cluster1/programs/wba_vault.ts b/ts/cluster1/programs/wba_vault.ts new file mode 100644 index 0000000..a599c8a --- /dev/null +++ b/ts/cluster1/programs/wba_vault.ts @@ -0,0 +1,7 @@ +export type WbaVault = { + +} + +export const IDL: WbaVault = { + +} \ No newline at end of file diff --git a/ts/cluster1/vault_close.ts b/ts/cluster1/vault_close.ts new file mode 100644 index 0000000..f834b9f --- /dev/null +++ b/ts/cluster1/vault_close.ts @@ -0,0 +1,47 @@ +import { Connection, Keypair, SystemProgram, PublicKey, Commitment } from "@solana/web3.js" +import { Program, Wallet, AnchorProvider, Address, BN } from "@project-serum/anchor" +import { WbaVault, IDL } from "../programs/wba_vault"; +import wallet from "../wba-wallet.json" + +// Import our keypair from the wallet file +const keypair = Keypair.fromSecretKey(new Uint8Array(wallet)); + +// Commitment +const commitment: Commitment = "confirmed"; + +// Create a devnet connection +const connection = new Connection("https://api.devnet.solana.com"); + +// Create our anchor provider +const provider = new AnchorProvider(connection, new Wallet(keypair), { commitment }); + +// Create our program +const program = new Program(IDL, "
" as Address, provider); + +// Create a random keypair +const vaultState = new PublicKey("
"); + +// Create a random keypair +// const closeVaultState = ??? + +// Execute our enrollment transaction +(async () => { + try { + + // const signature = await program.methods + // .closeAccount() + // .accounts({ + // owner: , + // vaultState: , + // closeVaultState: , + // systemProgram: , + // }) + // .signers([ + // keypair + // ]).rpc(); + // console.log(`Close success! Check out your TX here:\n\nhttps://explorer.solana.com/tx/${signature}?cluster=devnet`); + + } catch(e) { + console.error(`Oops, something went wrong: ${e}`) + } +})(); \ No newline at end of file diff --git a/ts/cluster1/vault_deposit.ts b/ts/cluster1/vault_deposit.ts new file mode 100644 index 0000000..b331406 --- /dev/null +++ b/ts/cluster1/vault_deposit.ts @@ -0,0 +1,52 @@ +import { Connection, Keypair, SystemProgram, PublicKey, Commitment } from "@solana/web3.js" +import { Program, Wallet, AnchorProvider, Address, BN } from "@project-serum/anchor" +import { WbaVault, IDL } from "../programs/wba_vault"; +import wallet from "../wba-wallet.json" + +// Import our keypair from the wallet file +const keypair = Keypair.fromSecretKey(new Uint8Array(wallet)); + +// Commitment +const commitment: Commitment = "confirmed"; + +// Create a devnet connection +const connection = new Connection("https://api.devnet.solana.com"); + +// Create our anchor provider +const provider = new AnchorProvider(connection, new Wallet(keypair), { commitment }); + +// Create our program +const program = new Program(IDL, "
" as Address, provider); + +// Create a random keypair +const vaultState = new PublicKey("
") + +// Create the PDA for our enrollment account +// const vaultAuth = ??? + +// Create the vault key +// const vault = ??? + +// Execute our enrollment transaction +(async () => { + try { + + // const signature = await program.methods + // .deposit(new BN() ) + // .accounts({ + // owner: , + // vaultState: , + // vaultAuth: , + // vault: , + // systemProgram: SystemProgram.programId, + // }) + // .signers([ + // keypair + // ]).rpc(); + + // console.log(`Deposit success! Check out your TX here:\n\nhttps://explorer.solana.com/tx/${signature}?cluster=devnet`); + + } catch(e) { + console.error(`Oops, something went wrong: ${e}`) + } +})(); \ No newline at end of file diff --git a/ts/cluster1/vault_deposit_nft.ts b/ts/cluster1/vault_deposit_nft.ts new file mode 100644 index 0000000..73997e2 --- /dev/null +++ b/ts/cluster1/vault_deposit_nft.ts @@ -0,0 +1,77 @@ +import { Connection, Keypair, SystemProgram, PublicKey, Commitment } from "@solana/web3.js" +import { Program, Wallet, AnchorProvider, Address, BN } from "@project-serum/anchor" +import { WbaVault, IDL } from "../programs/wba_vault"; +import wallet from "../wba-wallet.json" +import { ASSOCIATED_TOKEN_PROGRAM_ID, TOKEN_PROGRAM_ID, getOrCreateAssociatedTokenAccount } from "@solana/spl-token"; + +// Import our keypair from the wallet file +const keypair = Keypair.fromSecretKey(new Uint8Array(wallet)); + +// Commitment +const commitment: Commitment = "confirmed"; + +// Create a devnet connection +const connection = new Connection("https://api.devnet.solana.com"); + +// Create our anchor provider +const provider = new AnchorProvider(connection, new Wallet(keypair), { commitment }); + +// Create our program +const program = new Program(IDL, "
" as Address, provider); + +// Create a random keypair +const vaultState = new PublicKey("
") + +// Create the PDA for our vault auth +// const vaultAuth = ??? + +// Create the vault key +// const vault = ??? + +// Mint address +const mint = new PublicKey("
"); + +// Execute our deposit transaction +(async () => { + try { + + const metadataProgram = new PublicKey("metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s"); + const metadataAccount = PublicKey.findProgramAddressSync([Buffer.from("metadata"), metadataProgram.toBuffer(), mint.toBuffer()],metadataProgram)[0]; + const masterEdition = PublicKey.findProgramAddressSync([Buffer.from("metadata"), metadataProgram.toBuffer(), mint.toBuffer(), Buffer.from("edition")],metadataProgram)[0]; + + // b"metadata", MetadataProgramID.key.as_ref(), mint.key.as_ref() "master" + // Get the token account of the fromWallet address, and if it does not exist, create it + // const ownerAta = await getOrCreateAssociatedTokenAccount( + // ??? + // ); + + // // Get the token account of the fromWallet address, and if it does not exist, create it + // const vaultAta = await getOrCreateAssociatedTokenAccount( + // ??? + // ); + + // const signature = await program.methods + // .depositNft() + // .accounts({ + // owner: , + // ownerAta: , + // vaultState: , + // vaultAuth: , + // vaultAta: , + // tokenMint: , + // nftMetadata: , + // nftMasterEdition: , + // tokenProgram: TOKEN_PROGRAM_ID, + // associatedTokenProgram: ASSOCIATED_TOKEN_PROGRAM_ID, + // metadataProgram: metadataProgram, + // systemProgram: SystemProgram.programId, + // }) + // .signers([ + // keypair + // ]).rpc(); + // console.log(`Deposit success! Check out your TX here:\n\nhttps://explorer.solana.com/tx/${signature}?cluster=devnet`); + + } catch(e) { + console.error(`Oops, something went wrong: ${e}`) + } +})(); \ No newline at end of file diff --git a/ts/cluster1/vault_deposit_spl.ts b/ts/cluster1/vault_deposit_spl.ts new file mode 100644 index 0000000..feb9778 --- /dev/null +++ b/ts/cluster1/vault_deposit_spl.ts @@ -0,0 +1,71 @@ +import { Connection, Keypair, SystemProgram, PublicKey, Commitment } from "@solana/web3.js" +import { Program, Wallet, AnchorProvider, Address, BN } from "@project-serum/anchor" +import { WbaVault, IDL } from "../programs/wba_vault"; +import wallet from "../wba-wallet.json" +import { TOKEN_PROGRAM_ID, getOrCreateAssociatedTokenAccount } from "@solana/spl-token"; + +// Import our keypair from the wallet file +const keypair = Keypair.fromSecretKey(new Uint8Array(wallet)); + +// Commitment +const commitment: Commitment = "confirmed"; + +// Create a devnet connection +const connection = new Connection("https://api.devnet.solana.com"); + +// Create our anchor provider +const provider = new AnchorProvider(connection, new Wallet(keypair), { commitment }); + +// Create our program +const program = new Program(IDL, "
" as Address, provider); + +// Create a random keypair +const vaultState = new PublicKey("
") + +// Create the PDA for our vault auth +// const vaultAuth = ??? + +// Create the vault key +// const vault = ??? + +// const token_decimals = ??? + +// Mint address +const mint = new PublicKey("
"); + +// Execute our enrollment transaction +(async () => { + try { + + // Get the token account of the fromWallet address, and if it does not exist, create it + // const ownerAta = await getOrCreateAssociatedTokenAccount( + // ??? + // ); + + // Get the token account of the fromWallet address, and if it does not exist, create it + // const vaultAta = await getOrCreateAssociatedTokenAccount( + // ??? + // ); + + // const signature = await program.methods + // .depositSpl(new BN()) + // .accounts({ + // owner: , + // ownerAta: , + // vaultState: , + // vaultAuth: , + // vaultAta: , + // tokenMint: , + // tokenProgram: TOKEN_PROGRAM_ID, + // systemProgram: SystemProgram.programId, + // }) + // .signers([ + // keypair + // ]).rpc(); + + // console.log(`Deposit success! Check out your TX here:\n\nhttps://explorer.solana.com/tx/${signature}?cluster=devnet`); + + } catch(e) { + console.error(`Oops, something went wrong: ${e}`) + } +})(); \ No newline at end of file diff --git a/ts/cluster1/vault_init.ts b/ts/cluster1/vault_init.ts new file mode 100644 index 0000000..6644c24 --- /dev/null +++ b/ts/cluster1/vault_init.ts @@ -0,0 +1,50 @@ +import { Connection, Keypair, SystemProgram, PublicKey, Commitment } from "@solana/web3.js" +import { Program, Wallet, AnchorProvider, Address } from "@project-serum/anchor" +import { WbaVault, IDL } from "./programs/wba_vault"; +import wallet from "./wallet/wba-wallet.json" + +// Import our keypair from the wallet file +const keypair = Keypair.fromSecretKey(new Uint8Array(wallet)); + +// Commitment +const commitment: Commitment = "confirmed"; + +// Create a devnet connection +const connection = new Connection("https://api.devnet.solana.com"); + +// Create our anchor provider +const provider = new AnchorProvider(connection, new Wallet(keypair), { commitment }); + +// Create our program +const program = new Program(IDL, "" as Address, provider); + +// Create a random keypair +const vaultState = Keypair.generate(); +console.log(`Vault public key: ${vaultState.publicKey.toBase58()}`); + +// Create the PDA for our enrollment account +// const vaultAuth = ??? + +// Create the vault key +// const vault = ??? + +// Execute our enrollment transaction +(async () => { + + try { + + // const signature = await program.methods.initialize() + // .accounts({ + // owner: + // vaultState: + // vaultAuth: , + // vault: , + // systemProgram: SystemProgram.programId + // }).signers([keypair, vaultState]).rpc(); + // console.log(`Init success! Check out your TX here:\n\nhttps://explorer.solana.com/tx/${signature}?cluster=devnet`); + + } catch(e) { + console.error(`Oops, something went wrong: ${e}`) + } + +})(); \ No newline at end of file diff --git a/ts/cluster1/vault_withdraw.ts b/ts/cluster1/vault_withdraw.ts new file mode 100644 index 0000000..a5fa91d --- /dev/null +++ b/ts/cluster1/vault_withdraw.ts @@ -0,0 +1,52 @@ +import { Connection, Keypair, SystemProgram, PublicKey, Commitment } from "@solana/web3.js" +import { Program, Wallet, AnchorProvider, Address, BN } from "@project-serum/anchor" +import { WbaVault, IDL } from "../programs/wba_vault"; +import wallet from "../wba-wallet.json" + +// Import our keypair from the wallet file +const keypair = Keypair.fromSecretKey(new Uint8Array(wallet)); + +// Commitment +const commitment: Commitment = "confirmed"; + +// Create a devnet connection +const connection = new Connection("https://api.devnet.solana.com"); + +// Create our anchor provider +const provider = new AnchorProvider(connection, new Wallet(keypair), { commitment }); + +// Create our program +const program = new Program(IDL, "
" as Address, provider); + +// Create a random keypair +const vaultState = new PublicKey("
") + +// Create the PDA for our enrollment account +// const vaultAuth = ??? + +// Create the vault key +// const vault = ??? + +// Execute our enrollment transaction +(async () => { + try { + + // const signature = await program.methods + // .withdraw(new BN()) + // .accounts({ + // owner: , + // vaultState: , + // vaultAuth: , + // vault: , + // systemProgram: SystemProgram.programId, + // }) + // .signers([ + // keypair + // ]).rpc(); + + // console.log(`Withdraw success! Check out your TX here:\n\nhttps://explorer.solana.com/tx/${signature}?cluster=devnet`); + + } catch(e) { + console.error(`Oops, something went wrong: ${e}`) + } +})(); \ No newline at end of file diff --git a/ts/cluster1/vault_withdraw_nft.ts b/ts/cluster1/vault_withdraw_nft.ts new file mode 100644 index 0000000..5b21025 --- /dev/null +++ b/ts/cluster1/vault_withdraw_nft.ts @@ -0,0 +1,76 @@ +import { Connection, Keypair, SystemProgram, PublicKey, Commitment } from "@solana/web3.js" +import { Program, Wallet, AnchorProvider, Address, BN } from "@project-serum/anchor" +import { WbaVault, IDL } from "../programs/wba_vault"; +import wallet from "../wba-wallet.json" +import { ASSOCIATED_TOKEN_PROGRAM_ID, TOKEN_PROGRAM_ID, getOrCreateAssociatedTokenAccount } from "@solana/spl-token"; + +// Import our keypair from the wallet file +const keypair = Keypair.fromSecretKey(new Uint8Array(wallet)); + +// Commitment +const commitment: Commitment = "confirmed"; + +// Create a devnet connection +const connection = new Connection("https://api.devnet.solana.com"); + +// Create our anchor provider +const provider = new AnchorProvider(connection, new Wallet(keypair), { commitment }); + +// Create our program +const program = new Program(IDL, "
" as Address, provider); + +// Create a random keypair +const vaultState = new PublicKey("
") + +// Create the PDA for our vault auth +// const vaultAuth = ??? + +// Create the vault key +// const vault = ??? + +// Mint address +const mint = new PublicKey("
"); + +// Execute our enrollment transaction +(async () => { + try { + + const metadataProgram = new PublicKey("metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s"); + const metadataAccount = PublicKey.findProgramAddressSync([Buffer.from("metadata"), metadataProgram.toBuffer(), mint.toBuffer()],metadataProgram)[0]; + const masterEdition = PublicKey.findProgramAddressSync([Buffer.from("metadata"), metadataProgram.toBuffer(), mint.toBuffer(), Buffer.from("edition")],metadataProgram)[0]; + + // Get the token account of the fromWallet address, and if it does not exist, create it + // const ownerAta = await getOrCreateAssociatedTokenAccount( + // ??? + // ); + + // Get the token account of the fromWallet address, and if it does not exist, create it + // const vaultAta = await getOrCreateAssociatedTokenAccount( + // ??? + // ); + + // const signature = await program.methods + // .withdrawNft() + // .accounts({ + // owner: , + // ownerAta: , + // vaultState: , + // vaultAuth: , + // vaultAta: , + // tokenMint: , + // nftMetadata: , + // nftMasterEdition: , + // tokenProgram: TOKEN_PROGRAM_ID, + // associatedTokenProgram: ASSOCIATED_TOKEN_PROGRAM_ID, + // metadataProgram: metadataProgram, + // systemProgram: SystemProgram.programId, + // }) + // .signers([ + // keypair + // ]).rpc(); + // console.log(`Deposit success! Check out your TX here:\n\nhttps://explorer.solana.com/tx/${signature}?cluster=devnet`); + + } catch(e) { + console.error(`Oops, something went wrong: ${e}`) + } +})(); \ No newline at end of file diff --git a/ts/cluster1/vault_withdraw_spl.ts b/ts/cluster1/vault_withdraw_spl.ts new file mode 100644 index 0000000..4fce5b6 --- /dev/null +++ b/ts/cluster1/vault_withdraw_spl.ts @@ -0,0 +1,51 @@ +import { Connection, Keypair, SystemProgram, PublicKey, Commitment } from "@solana/web3.js" +import { Program, Wallet, AnchorProvider, Address, BN } from "@project-serum/anchor" +import { WbaVault, IDL } from "../programs/wba_vault"; +import wallet from "../wba-wallet.json" + +// Import our keypair from the wallet file +const keypair = Keypair.fromSecretKey(new Uint8Array(wallet)); + +// Commitment +const commitment: Commitment = "confirmed"; + +// Create a devnet connection +const connection = new Connection("https://api.devnet.solana.com"); + +// Create our anchor provider +const provider = new AnchorProvider(connection, new Wallet(keypair), { commitment }); + +// Create our program +const program = new Program(IDL, "
" as Address, provider); + +// Create a random keypair +const vaultState = new PublicKey("
") + +// Create the PDA for our enrollment account +// const vaultAuth = ??? + +// Create the vault key +// const vault = ??? + +// Execute our enrollment transaction +(async () => { + try { + + // const signature = await program.methods + // .withdraw(new BN()) + // .accounts({ + // owner: , + // vaultState: , + // vaultAuth: , + // vault: , + // systemProgram: SystemProgram.programId, + // }) + // .signers([ + // keypair + // ]).rpc(); + // console.log(`Withdraw success! Check out your TX here:\n\nhttps://explorer.solana.com/tx/${signature}?cluster=devnet`); + + } catch(e) { + console.error(`Oops, something went wrong: ${e}`) + } +})(); \ No newline at end of file diff --git a/ts/cluster1/wallet/.gitignore b/ts/cluster1/wallet/.gitignore new file mode 100644 index 0000000..23b6362 --- /dev/null +++ b/ts/cluster1/wallet/.gitignore @@ -0,0 +1,3 @@ + +*wallet.json +