Skip to content

Commit

Permalink
Add deploy script
Browse files Browse the repository at this point in the history
  • Loading branch information
tevdoradze committed Oct 21, 2022
1 parent daf3bc0 commit eb2998e
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 3 deletions.
3 changes: 3 additions & 0 deletions Anchor.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ seeds = false
[programs.localnet]
casier = "Fg6PaFpoGXkYsidMpWTK6W2BeZ7FEfcYkg476zPFsLnS"

[programs.mainnet]
casier = "CAsieqooSrgVxhgWRwh21gyjq7Rmuhmo4qTW9XzXtAvW"

[registry]
url = "https://anchor.projectserum.com"

Expand Down
59 changes: 56 additions & 3 deletions migrations/deploy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,64 @@
// single deploy script that's invoked from the CLI, injecting a provider
// configured from the workspace's Anchor.toml.

const anchor = require("@project-serum/anchor");
import * as anchor from "@project-serum/anchor";
import { Program, AnchorProvider, Wallet } from "@project-serum/anchor";
import { Casier } from "../target/types/casier";
import {
PublicKey,
Connection,
Keypair,
SystemProgram,
SYSVAR_RENT_PUBKEY,
} from "@solana/web3.js";
import * as fs from "fs";

module.exports = async function (provider) {
function loadKeypair(keypairPath: string): any {
return <any>JSON.parse(fs.readFileSync(keypairPath).toString());
}

function loadWallet(keypair: string): Keypair {
return Keypair.fromSecretKey(new Uint8Array(loadKeypair(keypair)));
}

const fee_payer = loadWallet(process.env.FEE_PAYER_KEY_PATH);

module.exports = async function () {
// Configure client to use the provider.
anchor.setProvider(provider);
const idl = JSON.parse(
require("fs")
.readFileSync(`${process.cwd()}/../target/idl/casier.json`, "utf8")
.toString()
);
const connection = new Connection(
"https://aurory.rpcpool.com/76a89d061372798b1eab339287e7",
"recent"
);
const wallet = new Wallet(fee_payer);
const provider = new AnchorProvider(connection, wallet, {
commitment: "recent",
});
const program = new Program<Casier>(
idl,
new PublicKey("CAsieqooSrgVxhgWRwh21gyjq7Rmuhmo4qTW9XzXtAvW"),
provider
);
const tx1 = await program.methods.initialize().rpc();
console.log(tx1);
const [configPDA] = await PublicKey.findProgramAddress(
[anchor.utils.bytes.utf8.encode("config")],
program.programId
);
const tx2 = await program.methods
.initConfig()
.accounts({
config: configPDA,
feePayer: fee_payer.publicKey,
systemProgram: SystemProgram.programId,
rent: SYSVAR_RENT_PUBKEY,
})
.rpc();
console.log(tx2);

// Add your deploy script here.
};

0 comments on commit eb2998e

Please sign in to comment.