-
Notifications
You must be signed in to change notification settings - Fork 36
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Drafting deployment scripts for Solana
These changes include bash scripts and typescripts that are used to build and deploy programs on Solana. We also need to initalize these programs. More init work to come..
- Loading branch information
Showing
10 changed files
with
3,253 additions
and
341 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,4 +7,5 @@ target | |
node_modules | ||
test-ledger | ||
artifacts-mainnet | ||
artifacts-testnet | ||
artifacts-testnet | ||
solana.env |
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,3 @@ | ||
module.exports = { | ||
...require("@thesis-co/prettier-config"), | ||
} |
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 |
---|---|---|
@@ -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 | ||
|
||
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) | ||
} | ||
} |
Oops, something went wrong.