-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
450f18a
commit 9521ad1
Showing
2 changed files
with
58 additions
and
0 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,12 @@ | ||
|
||
if [[ -z $SOLANA_RPC_URL || \ | ||
-z $AUTHORITY ]; then | ||
echo "Error: One or more required environment variables are not set." | ||
echo "SOLANA_RPC_URL: $SOLANA_RPC_URL" | ||
echo "LEDGER_PUB_KEY: $AUTHORITY" | ||
exit 1 | ||
fi | ||
|
||
while IFS= read -r TREASURY; do | ||
TREASURY=$TREASURY NEW_AUTHORITY=$AUTHORITY npx ts-node ./ts/scripts/transfer-treasury.ts | ||
done < "$(dirname "$0")/treasuries" |
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,46 @@ | ||
import { | ||
PublicKey, | ||
SystemProgram, | ||
AddressLookupTableProgram, | ||
SYSVAR_INSTRUCTIONS_PUBKEY, | ||
} from "@solana/web3.js"; | ||
|
||
import { TokenDispenserSdk } from "../sdk"; | ||
import { ledgerSignAndSend, ledgerSignAndSendV0 } from "./helpers"; | ||
import { connection, getSigner, getEnv } from "./env"; | ||
import { funders, tokenDispenserProgramId, treasuries } from "./config"; | ||
import { | ||
ASSOCIATED_TOKEN_PROGRAM_ID, | ||
AuthorityType, | ||
TOKEN_PROGRAM_ID, | ||
createSetAuthorityInstruction, | ||
} from "@solana/spl-token"; | ||
|
||
type Config = { | ||
treasury: PublicKey; | ||
newAuthority: PublicKey; | ||
}; | ||
|
||
(async () => { | ||
const config: Config = { | ||
treasury: new PublicKey(getEnv("TREASURY")), | ||
newAuthority: new PublicKey(getEnv("NEW_AUTHORITY")), | ||
}; | ||
|
||
const signer = await getSigner(); | ||
const signerPk = new PublicKey(await signer.getAddress()); | ||
|
||
// AuthorityType.AccountOwner; | ||
const setAuthorityIx = createSetAuthorityInstruction( | ||
config.treasury, | ||
signerPk, | ||
AuthorityType.AccountOwner, | ||
config.newAuthority, | ||
); | ||
|
||
console.log(`Setting account ${config.treasury.toBase58()} authority to ${config.newAuthority.toBase58()}`); | ||
const result = await ledgerSignAndSendV0([setAuthorityIx], []); | ||
console.log("Tx Sent: ", result); | ||
const txIncluded = await connection.confirmTransaction(result); | ||
console.log("Tx Included"); | ||
})(); |