Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deployment scripts for Solana #688

Merged
merged 19 commits into from
Aug 21, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion cross-chain/solana/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@ target
node_modules
test-ledger
artifacts-mainnet
artifacts-testnet
artifacts-testnet
solana.env
3 changes: 3 additions & 0 deletions cross-chain/solana/.prettierrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module.exports = {
...require("@thesis-co/prettier-config"),
}
1 change: 1 addition & 0 deletions cross-chain/solana/Anchor.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ wallet = "~/.config/solana/id.json"

[scripts]
test = "npx ts-mocha -p ./tsconfig.json -t 1000000 tests/**/*.ts"
authority = "ts-node --files ./typescript/transfer_authority.ts"
a5-pickle marked this conversation as resolved.
Show resolved Hide resolved

[test]
startup_wait = 10000
Expand Down
84 changes: 75 additions & 9 deletions cross-chain/solana/migrations/deploy.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,78 @@
// Migrations are an early feature. Currently, they're nothing more than this
// single deploy script that's invoked from the CLI, injecting a provider
// configured from the workspace's Anchor.toml.

const anchor = require("@coral-xyz/anchor");
import * as anchor from "@coral-xyz/anchor"
import fs from "fs"
import { PublicKey, Keypair } from "@solana/web3.js"
import dotenv from "dotenv"
import { PROGRAM_ID as METADATA_PROGRAM_ID } from "@metaplex-foundation/mpl-token-metadata";

module.exports = async function (provider) {
// Configure client to use the provider.
anchor.setProvider(provider);
dotenv.config({ path: "../solana.env" })

anchor.setProvider(provider)

const tbtcProgram = anchor.workspace.Tbtc
// This wallet deployed the program and is also an authority
const authority = loadKey(process.env.AUTHORITY)
const newAuthority = process.env.THRESHOLD_COUNCIL_MULTISIG
a5-pickle marked this conversation as resolved.
Show resolved Hide resolved

const mint = PublicKey.findProgramAddressSync(
[Buffer.from("tbtc-mint")],
tbtcProgram.programId
)[0];

const config = PublicKey.findProgramAddressSync(
[Buffer.from("config")],
tbtcProgram.programId
)[0];

const guardians = PublicKey.findProgramAddressSync(
[Buffer.from("guardians")],
tbtcProgram.programId
)[0];

const minters = PublicKey.findProgramAddressSync(
[Buffer.from("minters")],
tbtcProgram.programId
)[0];

const tbtcMetadata = PublicKey.findProgramAddressSync(
[
Buffer.from("metadata"),
METADATA_PROGRAM_ID.toBuffer(),
mint.toBuffer(),
],
METADATA_PROGRAM_ID
)[0];

const mplTokenMetadataProgram = METADATA_PROGRAM_ID;

// Initalize tbtc program
await tbtcProgram.methods
.initialize()
.accounts({
mint,
config,
guardians,
minters,
authority,
tbtcMetadata,
mplTokenMetadataProgram
})
.instruction()

// add minter

// add guardian?

// update mappings (self, base, arbitrum, optimism, polygon)
}

function loadKey(filename: string): Keypair {
try {
const contents = fs.readFileSync(filename).toString()
const bs = Uint8Array.from(JSON.parse(contents))

// Add your deploy script here.
};
return Keypair.fromSecretKey(bs)
} catch {
console.log("Unable to read keypair...", filename)
}
}
Loading