diff --git a/cross-chain/solana/migrations/deploy.ts b/cross-chain/solana/migrations/deploy.ts index 3a704d356..28cf44789 100644 --- a/cross-chain/solana/migrations/deploy.ts +++ b/cross-chain/solana/migrations/deploy.ts @@ -1,27 +1,27 @@ -import * as anchor from "@coral-xyz/anchor"; -import * as web3 from "@solana/web3.js"; -import fs from "fs"; -import { Keypair } from "@solana/web3.js"; -import dotenv from "dotenv"; +import * as anchor from "@coral-xyz/anchor" +import * as web3 from "@solana/web3.js" +import fs from "fs" +import { Keypair } from "@solana/web3.js" +import dotenv from "dotenv" module.exports = async function (provider) { dotenv.config({ path: "../solana.env" }) - anchor.setProvider(provider); + anchor.setProvider(provider) - const program = anchor.workspace.Tbtc; + const program = anchor.workspace.Tbtc // This wallet deployed the program and is also an authority - const authority = loadKey(process.env.WALLET); - const tbtcKeys = loadKey(process.env.TBTC_KEYS); - const minterKeys = loadKey(process.env.MINTER_KEYS); + const authority = loadKey(process.env.WALLET) + const tbtcKeys = loadKey(process.env.TBTC_KEYS) + const minterKeys = loadKey(process.env.MINTER_KEYS) - const [tbtcMintPDA, ] = web3.PublicKey.findProgramAddressSync( + const [tbtcMintPDA] = web3.PublicKey.findProgramAddressSync( [ anchor.utils.bytes.utf8.encode("tbtc-mint"), tbtcKeys.publicKey.toBuffer(), ], - program.programId, - ); + program.programId + ) // Initalize tbtc program await program.methods @@ -32,17 +32,17 @@ module.exports = async function (provider) { authority: authority.publicKey, }) .signers([tbtcKeys]) - .rpc(); + .rpc() - const [minterInfoPDA, ] = web3.PublicKey.findProgramAddressSync( + const [minterInfoPDA] = web3.PublicKey.findProgramAddressSync( [ - anchor.utils.bytes.utf8.encode('minter-info'), + anchor.utils.bytes.utf8.encode("minter-info"), tbtcKeys.publicKey.toBuffer(), minterKeys.publicKey.toBuffer(), ], program.programId - ); - + ) + // add minter keys (minterKeys is the wormholeGateway-keypair) await program.methods .addMinter() @@ -54,20 +54,20 @@ module.exports = async function (provider) { minterInfo: minterInfoPDA, }) .signers([minterKeys]) - .rpc(); - + .rpc() + // add a guardian? // update mappings (self, arbitrum, optimism, polygon) -}; +} function loadKey(filename: string): Keypair { try { - const contents = fs.readFileSync(filename).toString(); - const bs = Uint8Array.from(JSON.parse(contents)); + const contents = fs.readFileSync(filename).toString() + const bs = Uint8Array.from(JSON.parse(contents)) - return Keypair.fromSecretKey(bs); + return Keypair.fromSecretKey(bs) } catch { - console.log("Unable to read keypair...", filename); + console.log("Unable to read keypair...", filename) } }