Skip to content

Commit

Permalink
Adding ownership transfer scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
dimpar committed Aug 10, 2023
1 parent 73bedec commit 89af22b
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 12 deletions.
24 changes: 21 additions & 3 deletions cross-chain/solana/deploy/transfer_authority.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { WormholeGateway } from "./../target/types/wormhole_gateway"
import * as anchor from "@coral-xyz/anchor"
import fs from "fs"
import { PublicKey, Keypair } from "@solana/web3.js"
Expand All @@ -6,15 +7,23 @@ import dotenv from "dotenv"
async function run(): Promise<void> {
dotenv.config({ path: "solana.env" })

anchor.setProvider(anchor.AnchorProvider.env())

const authority = loadKey(process.env.AUTHORITY)
const newAuthority = process.env.THRESHOLD_COUNCIL_MULTISIG

const tbtcProgram = anchor.workspace.Tbtc
const wormholeGatewayProgram = anchor.workspace.WormholeGateway

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

const custodian = PublicKey.findProgramAddressSync(
[Buffer.from("redeemer")],
wormholeGatewayProgram.programId
)[0]

await tbtcProgram.methods
.changeAuthority()
Expand All @@ -23,7 +32,16 @@ async function run(): Promise<void> {
authority,
newAuthority,
})
.instruction();
.rpc()

await wormholeGatewayProgram.methods
.changeAuthority()
.accounts({
custodian,
authority,
newAuthority,
})
.rpc()
}

;(async () => {
Expand All @@ -43,4 +61,4 @@ function loadKey(filename: string): Keypair {
} catch {
console.log("Unable to read keypair...", filename)
}
}
}
5 changes: 0 additions & 5 deletions cross-chain/solana/scripts/deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,5 @@ fi
## And now it's time to initialize tbtc and wormhole_gatewa programs
# make init_programs

## The last step is to transfer authority to the Threshold Council. (for mainnet only)
# make transfer_authority

## Also run transfer_authority.sh script to transfer upgrade authority. (for mainnet only)

## Publishing IDL so that Solana ecosystem can detect and display data nicely (nice to have)
# anchor idl init --provider.cluster $CLUSTER --provider.wallet $AUTHORITY -f target/idl/<program_idl>.json <program_id>
12 changes: 8 additions & 4 deletions cross-chain/solana/scripts/transfer_authority.sh
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
#!/bin/bash
set -eo pipefail

## FOR MAINNET ONLY

# Setting env variables in the current bash shell
source solana.env

# TODO: transfer upgrade authority to Threshold Council Multisig
## Transfer authority to the Threshold Council Multisig. (for mainnet only)
# make transfer_authority

## Transfer upgrade authority to Threshold Council Multisig
# solana program set-upgrade-authority -k <current_keypair_path> <programID> --new-upgrade-authority <pubkey>

# Transfer authority to the Threshold Council Multisig
# TODO: verify if the authority was actually transferred.
anchor run authority --provider.cluster $CLUSTER
## Threshold Council Multisig has to accept the ownership by executing
## `takeAuthority` instruction

0 comments on commit 89af22b

Please sign in to comment.