-
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.
Adjusting deployment scripts to utilize Makefile
- Moved init TS scripts to /deploy dir - Building programs with make build - Deploying programs with solana cli instead of anchor
- Loading branch information
Showing
9 changed files
with
128 additions
and
97 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 |
---|---|---|
@@ -0,0 +1,6 @@ | ||
export AUTHORITY=<path_to_keypair_deployer> | ||
export THRESHOLD_COUNCIL_MULTISIG=<multisig_address> | ||
export NETWORK=<solana-devnet, mainnet> | ||
export CLUSTER=<devnet, mainnet-beta> | ||
export ANCHOR_PROVIDER_URL=<http://localhost:8899, https://api.devnet.solana.com, https://api.mainnet-beta.solana.com> | ||
export ANCHOR_WALLET=<path_to_keypair_deployer> |
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 |
---|---|---|
|
@@ -8,4 +8,4 @@ node_modules | |
test-ledger | ||
artifacts-mainnet | ||
artifacts-testnet | ||
solana.env | ||
.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
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 |
---|---|---|
@@ -0,0 +1,89 @@ | ||
import * as anchor from "@coral-xyz/anchor" | ||
import fs from "fs" | ||
import { PublicKey, Keypair } from "@solana/web3.js" | ||
import dotenv from "dotenv" | ||
import { Program } from "@coral-xyz/anchor"; | ||
import { Tbtc } from "../target/types/tbtc"; | ||
import { PROGRAM_ID as METADATA_PROGRAM_ID } from "@metaplex-foundation/mpl-token-metadata"; | ||
|
||
async function run(): Promise<void> { | ||
dotenv.config({ path: "../solana.env" }) | ||
|
||
anchor.setProvider(anchor.AnchorProvider.env()); | ||
|
||
const tbtcProgram = anchor.workspace.Tbtc as Program<Tbtc>; | ||
|
||
// This wallet deployed the program and is also an authority | ||
const authority = (loadKey(process.env.AUTHORITY)).publicKey | ||
|
||
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) | ||
} | ||
|
||
;(async () => { | ||
try { | ||
await run() | ||
} catch (e) { | ||
console.log("Exception called:", e) | ||
} | ||
})() | ||
|
||
function loadKey(filename: string): Keypair { | ||
try { | ||
const contents = fs.readFileSync(filename).toString() | ||
const bs = Uint8Array.from(JSON.parse(contents)) | ||
|
||
return Keypair.fromSecretKey(bs) | ||
} catch { | ||
console.log("Unable to read keypair...", filename) | ||
} | ||
} |
File renamed without changes.
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,78 +1,11 @@ | ||
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"; | ||
// 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. | ||
|
||
module.exports = async function (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 anchor = require("@coral-xyz/anchor"); | ||
|
||
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)) | ||
|
||
return Keypair.fromSecretKey(bs) | ||
} catch { | ||
console.log("Unable to read keypair...", filename) | ||
} | ||
} | ||
module.exports = async function (provider) { | ||
// Configure client to use the provider. | ||
anchor.setProvider(provider); | ||
// Add your deploy script here. | ||
}; |
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 was deleted.
Oops, something went wrong.