add seeds for auth and vault

This commit is contained in:
Richard
2023-11-28 08:58:15 -05:00
parent ce42be1e99
commit f08d450971
9 changed files with 3766 additions and 201 deletions

1
ts/.yarnrc.yml Normal file
View File

@@ -0,0 +1 @@
nodeLinker: node-modules

View File

@@ -1,7 +1,19 @@
import { Connection, Keypair, SystemProgram, PublicKey, Commitment } from "@solana/web3.js"
import { Program, Wallet, AnchorProvider, Address, BN } from "@project-serum/anchor"
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 wallet from "../wba-wallet.json";
// Import our keypair from the wallet file
const keypair = Keypair.fromSecretKey(new Uint8Array(wallet));
@@ -13,36 +25,37 @@ const commitment: Commitment = "confirmed";
const connection = new Connection("https://api.devnet.solana.com");
// Create our anchor provider
const provider = new AnchorProvider(connection, new Wallet(keypair), { commitment });
const provider = new AnchorProvider(connection, new Wallet(keypair), {
commitment,
});
// Create our program
const program = new Program<WbaVault>(IDL, "<address>" as Address, provider);
// Create a random keypair
const vaultState = new PublicKey("<address>")
const vaultState = new PublicKey("<address>")(
// Create the PDA for our enrollment account
// Seeds are "auth", vaultState
// const vaultAuth = ???
// Create the PDA for our enrollment account
// const vaultAuth = ???
// Create the vault key
// Seeds are "vault", vaultAuth
// const vault = ???
// Create the vault key
// const vault = ???
// Execute our enrollment transaction
(async () => {
// Execute our enrollment transaction
async () => {
try {
// const signature = await program.methods
// .deposit(new BN(<number>) )
// .accounts({
// ???
// })
// .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}`)
// const signature = await program.methods
// .deposit(new BN(<number>) )
// .accounts({
// ???
// })
// .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}`);
}
})();
},
)();

View File

@@ -1,8 +1,24 @@
import { Connection, Keypair, SystemProgram, PublicKey, Commitment } from "@solana/web3.js"
import { Program, Wallet, AnchorProvider, Address, BN } from "@project-serum/anchor"
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 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));
@@ -14,18 +30,22 @@ const commitment: Commitment = "confirmed";
const connection = new Connection("https://api.devnet.solana.com");
// Create our anchor provider
const provider = new AnchorProvider(connection, new Wallet(keypair), { commitment });
const provider = new AnchorProvider(connection, new Wallet(keypair), {
commitment,
});
// Create our program
const program = new Program<WbaVault>(IDL, "<address>" as Address, provider);
// Create a random keypair
const vaultState = new PublicKey("<address>")
const vaultState = new PublicKey("<address>");
// Create the PDA for our vault auth
// Create the PDA for our enrollment account
// Seeds are "auth", vaultState
// const vaultAuth = ???
// Create the vault key
// Seeds are "vault", vaultAuth
// const vault = ???
// Mint address
@@ -33,34 +53,45 @@ const mint = new PublicKey("<address>");
// Execute our deposit transaction
(async () => {
try {
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];
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(
// ???
// );
// 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(
// ???
// );
// // 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({
// ???
// })
// .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}`)
}
})();
// const signature = await program.methods
// .depositNft()
// .accounts({
// ???
// })
// .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}`);
}
})();

View File

@@ -1,8 +1,23 @@
import { Connection, Keypair, SystemProgram, PublicKey, Commitment } from "@solana/web3.js"
import { Program, Wallet, AnchorProvider, Address, BN } from "@project-serum/anchor"
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 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));
@@ -14,18 +29,22 @@ const commitment: Commitment = "confirmed";
const connection = new Connection("https://api.devnet.solana.com");
// Create our anchor provider
const provider = new AnchorProvider(connection, new Wallet(keypair), { commitment });
const provider = new AnchorProvider(connection, new Wallet(keypair), {
commitment,
});
// Create our program
const program = new Program<WbaVault>(IDL, "<address>" as Address, provider);
// Create a random keypair
const vaultState = new PublicKey("<address>")
const vaultState = new PublicKey("<address>");
// Create the PDA for our vault auth
// Create the PDA for our enrollment account
// Seeds are "auth", vaultState
// const vaultAuth = ???
// Create the vault key
// Seeds are "vault", vaultAuth
// const vault = ???
// const token_decimals = ???
@@ -35,30 +54,25 @@ const mint = new PublicKey("<address>");
// 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(<number>))
// .accounts({
// ???
// })
// .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}`)
}
})();
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(<number>))
// .accounts({
// ???
// })
// .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}`);
}
})();

View File

@@ -1,7 +1,18 @@
import { Connection, Keypair, SystemProgram, PublicKey, Commitment } from "@solana/web3.js"
import { Program, Wallet, AnchorProvider, Address } from "@project-serum/anchor"
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 wallet from "./wallet/wba-wallet.json";
// Import our keypair from the wallet file
const keypair = Keypair.fromSecretKey(new Uint8Array(wallet));
@@ -13,7 +24,9 @@ const commitment: Commitment = "confirmed";
const connection = new Connection("https://api.devnet.solana.com");
// Create our anchor provider
const provider = new AnchorProvider(connection, new Wallet(keypair), { commitment });
const provider = new AnchorProvider(connection, new Wallet(keypair), {
commitment,
});
// Create our program
const program = new Program<WbaVault>(IDL, "<addressIDL>" as Address, provider);
@@ -23,24 +36,22 @@ const vaultState = Keypair.generate();
console.log(`Vault public key: ${vaultState.publicKey.toBase58()}`);
// Create the PDA for our enrollment account
// Seeds are "auth", vaultState
// const vaultAuth = ???
// Create the vault key
// Seeds are "vault", vaultAuth
// const vault = ???
// Execute our enrollment transaction
(async () => {
try {
// const signature = await program.methods.initialize()
// .accounts({
// ???
// }).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}`)
}
})();
try {
// const signature = await program.methods.initialize()
// .accounts({
// ???
// }).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}`);
}
})();

View File

@@ -1,7 +1,19 @@
import { Connection, Keypair, SystemProgram, PublicKey, Commitment } from "@solana/web3.js"
import { Program, Wallet, AnchorProvider, Address, BN } from "@project-serum/anchor"
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 wallet from "../wba-wallet.json";
// Import our keypair from the wallet file
const keypair = Keypair.fromSecretKey(new Uint8Array(wallet));
@@ -13,36 +25,37 @@ const commitment: Commitment = "confirmed";
const connection = new Connection("https://api.devnet.solana.com");
// Create our anchor provider
const provider = new AnchorProvider(connection, new Wallet(keypair), { commitment });
const provider = new AnchorProvider(connection, new Wallet(keypair), {
commitment,
});
// Create our program
const program = new Program<WbaVault>(IDL, "<address>" as Address, provider);
// Create a random keypair
const vaultState = new PublicKey("<address>")
const vaultState = new PublicKey("<address>")(
// Create the PDA for our enrollment account
// Seeds are "auth", vaultState
// const vaultAuth = ???
// Create the PDA for our enrollment account
// const vaultAuth = ???
// Create the vault key
// Seeds are "vault", vaultAuth
// const vault = ???
// Create the vault key
// const vault = ???
// Execute our enrollment transaction
(async () => {
// Execute our enrollment transaction
async () => {
try {
// const signature = await program.methods
// .withdraw(new BN(<number>))
// .accounts({
// ???
// })
// .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}`)
// const signature = await program.methods
// .withdraw(new BN(<number>))
// .accounts({
// ???
// })
// .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}`);
}
})();
},
)();

View File

@@ -1,8 +1,24 @@
import { Connection, Keypair, SystemProgram, PublicKey, Commitment } from "@solana/web3.js"
import { Program, Wallet, AnchorProvider, Address, BN } from "@project-serum/anchor"
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 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));
@@ -14,18 +30,22 @@ const commitment: Commitment = "confirmed";
const connection = new Connection("https://api.devnet.solana.com");
// Create our anchor provider
const provider = new AnchorProvider(connection, new Wallet(keypair), { commitment });
const provider = new AnchorProvider(connection, new Wallet(keypair), {
commitment,
});
// Create our program
const program = new Program<WbaVault>(IDL, "<address>" as Address, provider);
// Create a random keypair
const vaultState = new PublicKey("<address>")
const vaultState = new PublicKey("<address>");
// Create the PDA for our vault auth
// Create the PDA for our enrollment account
// Seeds are "auth", vaultState
// const vaultAuth = ???
// Create the vault key
// Seeds are "vault", vaultAuth
// const vault = ???
// Mint address
@@ -33,33 +53,44 @@ const mint = new PublicKey("<address>");
// Execute our enrollment transaction
(async () => {
try {
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];
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 ownerAta = await getOrCreateAssociatedTokenAccount(
// ???
// );
// Get the token account of the fromWallet address, and if it does not exist, create it
// const vaultAta = 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({
// ???
// })
// .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}`)
}
})();
// const signature = await program.methods
// .withdrawNft()
// .accounts({
// ???
// })
// .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}`);
}
})();

View File

@@ -1,7 +1,19 @@
import { Connection, Keypair, SystemProgram, PublicKey, Commitment } from "@solana/web3.js"
import { Program, Wallet, AnchorProvider, Address, BN } from "@project-serum/anchor"
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 wallet from "../wba-wallet.json";
// Import our keypair from the wallet file
const keypair = Keypair.fromSecretKey(new Uint8Array(wallet));
@@ -13,35 +25,37 @@ const commitment: Commitment = "confirmed";
const connection = new Connection("https://api.devnet.solana.com");
// Create our anchor provider
const provider = new AnchorProvider(connection, new Wallet(keypair), { commitment });
const provider = new AnchorProvider(connection, new Wallet(keypair), {
commitment,
});
// Create our program
const program = new Program<WbaVault>(IDL, "<address>" as Address, provider);
// Create a random keypair
const vaultState = new PublicKey("<address>")
const vaultState = new PublicKey("<address>")(
// Create the PDA for our enrollment account
// Seeds are "auth", vaultState
// const vaultAuth = ???
// Create the PDA for our enrollment account
// const vaultAuth = ???
// Create the vault key
// Seeds are "vault", vaultAuth
// const vault = ???
// Create the vault key
// const vault = ???
// Execute our enrollment transaction
(async () => {
// Execute our enrollment transaction
async () => {
try {
// const signature = await program.methods
// .withdraw(new BN(<number>))
// .accounts({
// ???
// })
// .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}`)
// const signature = await program.methods
// .withdraw(new BN(<number>))
// .accounts({
// ???
// })
// .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}`);
}
})();
},
)();

3437
ts/package-lock.json generated Normal file

File diff suppressed because it is too large Load Diff