mirror of https://github.com/certusone/oyster.git
Merge pull request #59 from solana-labs/drop_unneeded_timelock_account
Remove timelock program in a refactor
This commit is contained in:
commit
35f96871c2
|
@ -58,10 +58,11 @@ export function approve(
|
||||||
|
|
||||||
// if delegate is not passed ephemeral transfer authority is used
|
// if delegate is not passed ephemeral transfer authority is used
|
||||||
delegate?: PublicKey,
|
delegate?: PublicKey,
|
||||||
|
existingTransferAuthority?: Account,
|
||||||
): Account {
|
): Account {
|
||||||
const tokenProgram = TOKEN_PROGRAM_ID;
|
const tokenProgram = TOKEN_PROGRAM_ID;
|
||||||
|
|
||||||
const transferAuthority = new Account();
|
const transferAuthority = existingTransferAuthority || new Account();
|
||||||
const delegateKey = delegate ?? transferAuthority.publicKey;
|
const delegateKey = delegate ?? transferAuthority.publicKey;
|
||||||
|
|
||||||
const instruction = Token.createApproveInstruction(
|
const instruction = Token.createApproveInstruction(
|
||||||
|
|
|
@ -29,7 +29,6 @@ let WORMHOLE_BRIDGE: {
|
||||||
|
|
||||||
let TIMELOCK: {
|
let TIMELOCK: {
|
||||||
programId: PublicKey;
|
programId: PublicKey;
|
||||||
programAccountId: PublicKey;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
let SWAP_PROGRAM_ID: PublicKey;
|
let SWAP_PROGRAM_ID: PublicKey;
|
||||||
|
@ -49,9 +48,6 @@ export const PROGRAM_IDS = [
|
||||||
{
|
{
|
||||||
name: 'mainnet-beta',
|
name: 'mainnet-beta',
|
||||||
timelock: () => ({
|
timelock: () => ({
|
||||||
programAccountId: new PublicKey(
|
|
||||||
'9gBhDCCKV7KELLFRY8sAJZXqDmvUfmNzFzpB2b4FUVVr',
|
|
||||||
),
|
|
||||||
programId: new PublicKey('9iAeqqppjn7g1Jn8o2cQCqU5aQVV3h4q9bbWdKRbeC2w'),
|
programId: new PublicKey('9iAeqqppjn7g1Jn8o2cQCqU5aQVV3h4q9bbWdKRbeC2w'),
|
||||||
}),
|
}),
|
||||||
wormhole: () => ({
|
wormhole: () => ({
|
||||||
|
@ -73,10 +69,7 @@ export const PROGRAM_IDS = [
|
||||||
{
|
{
|
||||||
name: 'testnet',
|
name: 'testnet',
|
||||||
timelock: () => ({
|
timelock: () => ({
|
||||||
programAccountId: new PublicKey(
|
programId: new PublicKey('DCVPuhaGNMLh73FRWFroH4o3ERUhBKMRWfBgJV94VqRk'),
|
||||||
'7CxEuz8Qtius9aCyJqGnWZyBNvf6WTTNmA8G26BdMTSF',
|
|
||||||
),
|
|
||||||
programId: new PublicKey('8DevpkpN6CsdczP6rQ64CHraApXFrq96oGm4VjSNCs4q'),
|
|
||||||
}),
|
}),
|
||||||
wormhole: () => ({
|
wormhole: () => ({
|
||||||
pubkey: new PublicKey('5gQf5AUhAgWYgUCt9ouShm9H7dzzXUsLdssYwe5krKhg'),
|
pubkey: new PublicKey('5gQf5AUhAgWYgUCt9ouShm9H7dzzXUsLdssYwe5krKhg'),
|
||||||
|
@ -94,10 +87,7 @@ export const PROGRAM_IDS = [
|
||||||
{
|
{
|
||||||
name: 'devnet',
|
name: 'devnet',
|
||||||
timelock: () => ({
|
timelock: () => ({
|
||||||
programAccountId: new PublicKey(
|
programId: new PublicKey('DCVPuhaGNMLh73FRWFroH4o3ERUhBKMRWfBgJV94VqRk'),
|
||||||
'9qR84VknBPtVyRw9XwCYRP6B1GiBtZohNo6TqETzw9Jv',
|
|
||||||
),
|
|
||||||
programId: new PublicKey('GWXcJzvWpJb7Sq2iqGSnJNiQJ3HmS3Zjg3vhyJf4JwBU'),
|
|
||||||
}),
|
}),
|
||||||
wormhole: () => ({
|
wormhole: () => ({
|
||||||
pubkey: new PublicKey('WormT3McKhFJ2RkiGpdw9GKvNCrB2aB54gb2uV9MfQC'),
|
pubkey: new PublicKey('WormT3McKhFJ2RkiGpdw9GKvNCrB2aB54gb2uV9MfQC'),
|
||||||
|
@ -115,9 +105,6 @@ export const PROGRAM_IDS = [
|
||||||
{
|
{
|
||||||
name: 'localnet',
|
name: 'localnet',
|
||||||
timelock: () => ({
|
timelock: () => ({
|
||||||
programAccountId: new PublicKey(
|
|
||||||
'5jmddiXrpvPp587iRvhtAnNrJa2PNMFRm5cxFW6yCG14',
|
|
||||||
),
|
|
||||||
programId: new PublicKey('3KEiR9eX7isb8xeFzTzbLZij8tKH6YFYUbMyjBp8ygDK'),
|
programId: new PublicKey('3KEiR9eX7isb8xeFzTzbLZij8tKH6YFYUbMyjBp8ygDK'),
|
||||||
}),
|
}),
|
||||||
wormhole: () => ({
|
wormhole: () => ({
|
||||||
|
|
|
@ -50,7 +50,7 @@ export const addCustomSingleSignerTransaction = async (
|
||||||
});
|
});
|
||||||
|
|
||||||
const [authority] = await PublicKey.findProgramAddress(
|
const [authority] = await PublicKey.findProgramAddress(
|
||||||
[PROGRAM_IDS.timelock.programAccountId.toBuffer()],
|
[proposal.pubkey.toBuffer()],
|
||||||
PROGRAM_IDS.timelock.programId,
|
PROGRAM_IDS.timelock.programId,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -71,6 +71,7 @@ export const addCustomSingleSignerTransaction = async (
|
||||||
await serializeInstruction({
|
await serializeInstruction({
|
||||||
connection,
|
connection,
|
||||||
instr: pingInstruction(),
|
instr: pingInstruction(),
|
||||||
|
proposal
|
||||||
})
|
})
|
||||||
).base64;
|
).base64;
|
||||||
|
|
||||||
|
@ -79,6 +80,7 @@ export const addCustomSingleSignerTransaction = async (
|
||||||
await serializeInstruction({
|
await serializeInstruction({
|
||||||
connection,
|
connection,
|
||||||
instr: pingInstruction(),
|
instr: pingInstruction(),
|
||||||
|
proposal
|
||||||
})
|
})
|
||||||
).byteArray;
|
).byteArray;
|
||||||
|
|
||||||
|
|
|
@ -47,7 +47,7 @@ export const addSigner = async (
|
||||||
);
|
);
|
||||||
|
|
||||||
const [mintAuthority] = await PublicKey.findProgramAddress(
|
const [mintAuthority] = await PublicKey.findProgramAddress(
|
||||||
[PROGRAM_IDS.timelock.programAccountId.toBuffer()],
|
[proposal.pubkey.toBuffer()],
|
||||||
PROGRAM_IDS.timelock.programId,
|
PROGRAM_IDS.timelock.programId,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
|
@ -49,6 +49,8 @@ export const createProposal = async (
|
||||||
)
|
)
|
||||||
).decimals;
|
).decimals;
|
||||||
|
|
||||||
|
const timelockSetKey = new Account();
|
||||||
|
|
||||||
const {
|
const {
|
||||||
sigMint,
|
sigMint,
|
||||||
voteMint,
|
voteMint,
|
||||||
|
@ -73,6 +75,7 @@ export const createProposal = async (
|
||||||
timelockConfig,
|
timelockConfig,
|
||||||
useGovernance,
|
useGovernance,
|
||||||
sourceMintDecimals,
|
sourceMintDecimals,
|
||||||
|
timelockSetKey,
|
||||||
);
|
);
|
||||||
|
|
||||||
let createTimelockAccountsSigners: Account[] = [];
|
let createTimelockAccountsSigners: Account[] = [];
|
||||||
|
@ -86,7 +89,6 @@ export const createProposal = async (
|
||||||
TimelockStateLayout.span,
|
TimelockStateLayout.span,
|
||||||
);
|
);
|
||||||
|
|
||||||
const timelockSetKey = new Account();
|
|
||||||
const timelockStateKey = new Account();
|
const timelockStateKey = new Account();
|
||||||
|
|
||||||
const uninitializedTimelockStateInstruction = SystemProgram.createAccount({
|
const uninitializedTimelockStateInstruction = SystemProgram.createAccount({
|
||||||
|
@ -112,7 +114,7 @@ export const createProposal = async (
|
||||||
signers.push(timelockSetKey);
|
signers.push(timelockSetKey);
|
||||||
createTimelockAccountsSigners.push(timelockSetKey);
|
createTimelockAccountsSigners.push(timelockSetKey);
|
||||||
createTimelockAccountsInstructions.push(uninitializedTimelockSetInstruction);
|
createTimelockAccountsInstructions.push(uninitializedTimelockSetInstruction);
|
||||||
console.log('useGov ernance is', useGovernance, timelockConfig);
|
|
||||||
instructions.push(
|
instructions.push(
|
||||||
initTimelockSetInstruction(
|
initTimelockSetInstruction(
|
||||||
timelockStateKey.publicKey,
|
timelockStateKey.publicKey,
|
||||||
|
@ -198,11 +200,12 @@ async function getAssociatedAccountsAndInstructions(
|
||||||
timelockConfig: ParsedAccount<TimelockConfig>,
|
timelockConfig: ParsedAccount<TimelockConfig>,
|
||||||
useGovernance: boolean,
|
useGovernance: boolean,
|
||||||
sourceMintDecimals: number,
|
sourceMintDecimals: number,
|
||||||
|
newProposalKey: Account,
|
||||||
): Promise<ValidationReturn> {
|
): Promise<ValidationReturn> {
|
||||||
const PROGRAM_IDS = utils.programIds();
|
const PROGRAM_IDS = utils.programIds();
|
||||||
|
|
||||||
const [authority] = await PublicKey.findProgramAddress(
|
const [authority] = await PublicKey.findProgramAddress(
|
||||||
[PROGRAM_IDS.timelock.programAccountId.toBuffer()],
|
[newProposalKey.publicKey.toBuffer()],
|
||||||
PROGRAM_IDS.timelock.programId,
|
PROGRAM_IDS.timelock.programId,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
|
@ -66,7 +66,7 @@ export const depositSourceTokensAndVote = async (
|
||||||
|
|
||||||
const [governanceVotingRecord] = await PublicKey.findProgramAddress(
|
const [governanceVotingRecord] = await PublicKey.findProgramAddress(
|
||||||
[
|
[
|
||||||
PROGRAM_IDS.timelock.programAccountId.toBuffer(),
|
PROGRAM_IDS.timelock.programId.toBuffer(),
|
||||||
proposal.pubkey.toBuffer(),
|
proposal.pubkey.toBuffer(),
|
||||||
existingVoteAccount.toBuffer(),
|
existingVoteAccount.toBuffer(),
|
||||||
],
|
],
|
||||||
|
@ -107,7 +107,7 @@ export const depositSourceTokensAndVote = async (
|
||||||
}
|
}
|
||||||
|
|
||||||
const [mintAuthority] = await PublicKey.findProgramAddress(
|
const [mintAuthority] = await PublicKey.findProgramAddress(
|
||||||
[PROGRAM_IDS.timelock.programAccountId.toBuffer()],
|
[proposal.pubkey.toBuffer()],
|
||||||
PROGRAM_IDS.timelock.programId,
|
PROGRAM_IDS.timelock.programId,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
|
@ -113,7 +113,7 @@ export const registerProgramGovernance = async (
|
||||||
|
|
||||||
const [timelockConfigKey] = await PublicKey.findProgramAddress(
|
const [timelockConfigKey] = await PublicKey.findProgramAddress(
|
||||||
[
|
[
|
||||||
PROGRAM_IDS.timelock.programAccountId.toBuffer(),
|
PROGRAM_IDS.timelock.programId.toBuffer(),
|
||||||
uninitializedTimelockConfig.governanceMint.toBuffer(),
|
uninitializedTimelockConfig.governanceMint.toBuffer(),
|
||||||
uninitializedTimelockConfig.councilMint.toBuffer(),
|
uninitializedTimelockConfig.councilMint.toBuffer(),
|
||||||
uninitializedTimelockConfig.program.toBuffer(),
|
uninitializedTimelockConfig.program.toBuffer(),
|
||||||
|
|
|
@ -25,7 +25,7 @@ export const removeSigner = async (
|
||||||
let instructions: TransactionInstruction[] = [];
|
let instructions: TransactionInstruction[] = [];
|
||||||
|
|
||||||
const [mintAuthority] = await PublicKey.findProgramAddress(
|
const [mintAuthority] = await PublicKey.findProgramAddress(
|
||||||
[PROGRAM_IDS.timelock.programAccountId.toBuffer()],
|
[proposal.pubkey.toBuffer()],
|
||||||
PROGRAM_IDS.timelock.programId,
|
PROGRAM_IDS.timelock.programId,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
|
@ -26,7 +26,7 @@ export const sign = async (
|
||||||
let instructions: TransactionInstruction[] = [];
|
let instructions: TransactionInstruction[] = [];
|
||||||
|
|
||||||
const [mintAuthority] = await PublicKey.findProgramAddress(
|
const [mintAuthority] = await PublicKey.findProgramAddress(
|
||||||
[PROGRAM_IDS.timelock.programAccountId.toBuffer()],
|
[proposal.pubkey.toBuffer()],
|
||||||
PROGRAM_IDS.timelock.programId,
|
PROGRAM_IDS.timelock.programId,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
|
@ -79,7 +79,7 @@ export const withdrawVotingTokens = async (
|
||||||
}
|
}
|
||||||
|
|
||||||
const [mintAuthority] = await PublicKey.findProgramAddress(
|
const [mintAuthority] = await PublicKey.findProgramAddress(
|
||||||
[PROGRAM_IDS.timelock.programAccountId.toBuffer()],
|
[proposal.pubkey.toBuffer()],
|
||||||
PROGRAM_IDS.timelock.programId,
|
PROGRAM_IDS.timelock.programId,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -93,25 +93,31 @@ export const withdrawVotingTokens = async (
|
||||||
votingTokenAmount,
|
votingTokenAmount,
|
||||||
);
|
);
|
||||||
|
|
||||||
const yesTransferAuthority = approve(
|
approve(
|
||||||
instructions,
|
instructions,
|
||||||
[],
|
[],
|
||||||
existingYesVoteAccount,
|
existingYesVoteAccount,
|
||||||
wallet.publicKey,
|
wallet.publicKey,
|
||||||
votingTokenAmount,
|
votingTokenAmount,
|
||||||
|
undefined,
|
||||||
|
undefined,
|
||||||
|
transferAuthority,
|
||||||
);
|
);
|
||||||
|
|
||||||
const noTransferAuthority = approve(
|
approve(
|
||||||
instructions,
|
instructions,
|
||||||
[],
|
[],
|
||||||
existingNoVoteAccount,
|
existingNoVoteAccount,
|
||||||
wallet.publicKey,
|
wallet.publicKey,
|
||||||
votingTokenAmount,
|
votingTokenAmount,
|
||||||
|
undefined,
|
||||||
|
undefined,
|
||||||
|
transferAuthority,
|
||||||
);
|
);
|
||||||
|
|
||||||
const [governanceVotingRecord] = await PublicKey.findProgramAddress(
|
const [governanceVotingRecord] = await PublicKey.findProgramAddress(
|
||||||
[
|
[
|
||||||
PROGRAM_IDS.timelock.programAccountId.toBuffer(),
|
PROGRAM_IDS.timelock.programId.toBuffer(),
|
||||||
proposal.pubkey.toBuffer(),
|
proposal.pubkey.toBuffer(),
|
||||||
existingVoteAccount.toBuffer(),
|
existingVoteAccount.toBuffer(),
|
||||||
],
|
],
|
||||||
|
@ -119,8 +125,6 @@ export const withdrawVotingTokens = async (
|
||||||
);
|
);
|
||||||
|
|
||||||
signers.push(transferAuthority);
|
signers.push(transferAuthority);
|
||||||
signers.push(yesTransferAuthority);
|
|
||||||
signers.push(noTransferAuthority);
|
|
||||||
|
|
||||||
instructions.push(
|
instructions.push(
|
||||||
withdrawVotingTokensInstruction(
|
withdrawVotingTokensInstruction(
|
||||||
|
@ -138,8 +142,6 @@ export const withdrawVotingTokens = async (
|
||||||
state.pubkey,
|
state.pubkey,
|
||||||
proposal.pubkey,
|
proposal.pubkey,
|
||||||
transferAuthority.publicKey,
|
transferAuthority.publicKey,
|
||||||
yesTransferAuthority.publicKey,
|
|
||||||
noTransferAuthority.publicKey,
|
|
||||||
mintAuthority,
|
mintAuthority,
|
||||||
votingTokenAmount,
|
votingTokenAmount,
|
||||||
),
|
),
|
||||||
|
|
|
@ -43,6 +43,7 @@ export function WithdrawVote({
|
||||||
votingTokens > 0 &&
|
votingTokens > 0 &&
|
||||||
(state.info.status === TimelockStateStatus.Voting ||
|
(state.info.status === TimelockStateStatus.Voting ||
|
||||||
state.info.status === TimelockStateStatus.Completed ||
|
state.info.status === TimelockStateStatus.Completed ||
|
||||||
|
state.info.status === TimelockStateStatus.Executing ||
|
||||||
state.info.status === TimelockStateStatus.Defeated);
|
state.info.status === TimelockStateStatus.Defeated);
|
||||||
|
|
||||||
const [btnLabel, title, msg, action] =
|
const [btnLabel, title, msg, action] =
|
||||||
|
|
|
@ -187,7 +187,7 @@ function useSetupProposalsCache({
|
||||||
return () => {
|
return () => {
|
||||||
connection.removeProgramAccountChangeListener(subID);
|
connection.removeProgramAccountChangeListener(subID);
|
||||||
};
|
};
|
||||||
}, [connection, PROGRAM_IDS.timelock.programAccountId.toBase58()]);
|
}, [connection, PROGRAM_IDS.timelock.programId.toBase58()]);
|
||||||
}
|
}
|
||||||
export const useProposals = () => {
|
export const useProposals = () => {
|
||||||
const context = useContext(ProposalsContext);
|
const context = useContext(ProposalsContext);
|
||||||
|
|
|
@ -23,8 +23,7 @@ import BN from 'bn.js';
|
||||||
/// 5. `[]` Timelock Config account.
|
/// 5. `[]` Timelock Config account.
|
||||||
/// 6. `[]` Transfer authority
|
/// 6. `[]` Transfer authority
|
||||||
/// 7. `[]` Timelock mint authority
|
/// 7. `[]` Timelock mint authority
|
||||||
/// 8. `[]` Timelock program account.
|
/// 8. `[]` Token program account.
|
||||||
/// 9. `[]` Token program account.
|
|
||||||
export const addCustomSingleSignerTransactionInstruction = (
|
export const addCustomSingleSignerTransactionInstruction = (
|
||||||
timelockTransactionAccount: PublicKey,
|
timelockTransactionAccount: PublicKey,
|
||||||
timelockStateAccount: PublicKey,
|
timelockStateAccount: PublicKey,
|
||||||
|
@ -94,11 +93,6 @@ export const addCustomSingleSignerTransactionInstruction = (
|
||||||
{ pubkey: timelockConfigAccount, isSigner: false, isWritable: false },
|
{ pubkey: timelockConfigAccount, isSigner: false, isWritable: false },
|
||||||
{ pubkey: transferAuthority, isSigner: true, isWritable: false },
|
{ pubkey: transferAuthority, isSigner: true, isWritable: false },
|
||||||
{ pubkey: authority, isSigner: false, isWritable: false },
|
{ pubkey: authority, isSigner: false, isWritable: false },
|
||||||
{
|
|
||||||
pubkey: PROGRAM_IDS.timelock.programAccountId,
|
|
||||||
isSigner: false,
|
|
||||||
isWritable: false,
|
|
||||||
},
|
|
||||||
{ pubkey: PROGRAM_IDS.token, isSigner: false, isWritable: false },
|
{ pubkey: PROGRAM_IDS.token, isSigner: false, isWritable: false },
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|
|
@ -16,8 +16,7 @@ import { TimelockInstruction } from './timelock';
|
||||||
/// 5. `[]` Timelock set account.
|
/// 5. `[]` Timelock set account.
|
||||||
/// 6. `[]` Transfer authority
|
/// 6. `[]` Transfer authority
|
||||||
/// 7. `[]` Timelock program mint authority
|
/// 7. `[]` Timelock program mint authority
|
||||||
/// 8. `[]` Timelock program account.
|
/// 8. '[]` Token program id.
|
||||||
/// 9. '[]` Token program id.
|
|
||||||
export const addSignerInstruction = (
|
export const addSignerInstruction = (
|
||||||
signatoryAccount: PublicKey,
|
signatoryAccount: PublicKey,
|
||||||
signatoryMintAccount: PublicKey,
|
signatoryMintAccount: PublicKey,
|
||||||
|
@ -50,11 +49,6 @@ export const addSignerInstruction = (
|
||||||
{ pubkey: timelockSetAccount, isSigner: false, isWritable: false },
|
{ pubkey: timelockSetAccount, isSigner: false, isWritable: false },
|
||||||
{ pubkey: transferAuthority, isSigner: true, isWritable: false },
|
{ pubkey: transferAuthority, isSigner: true, isWritable: false },
|
||||||
{ pubkey: mintAuthority, isSigner: false, isWritable: false },
|
{ pubkey: mintAuthority, isSigner: false, isWritable: false },
|
||||||
{
|
|
||||||
pubkey: PROGRAM_IDS.timelock.programAccountId,
|
|
||||||
isSigner: false,
|
|
||||||
isWritable: false,
|
|
||||||
},
|
|
||||||
{ pubkey: PROGRAM_IDS.token, isSigner: false, isWritable: false },
|
{ pubkey: PROGRAM_IDS.token, isSigner: false, isWritable: false },
|
||||||
];
|
];
|
||||||
return new TransactionInstruction({
|
return new TransactionInstruction({
|
||||||
|
|
|
@ -8,9 +8,8 @@ import { TimelockInstruction } from './timelock';
|
||||||
/// 1. `[]` Proposal key
|
/// 1. `[]` Proposal key
|
||||||
/// 2. `[]` Your voting account
|
/// 2. `[]` Your voting account
|
||||||
/// 3. `[]` Payer
|
/// 3. `[]` Payer
|
||||||
/// 4. `[]` Timelock program account pub key.
|
/// 4. `[]` Timelock program pub key.
|
||||||
/// 5. `[]` Timelock program pub key. Different from program account - is the actual id of the executable.
|
/// 5. `[]` System account.
|
||||||
/// 6. `[]` System account.
|
|
||||||
export const createEmptyGovernanceVotingRecordInstruction = (
|
export const createEmptyGovernanceVotingRecordInstruction = (
|
||||||
governanceRecordAccount: PublicKey,
|
governanceRecordAccount: PublicKey,
|
||||||
proposalAccount: PublicKey,
|
proposalAccount: PublicKey,
|
||||||
|
@ -35,12 +34,6 @@ export const createEmptyGovernanceVotingRecordInstruction = (
|
||||||
{ pubkey: proposalAccount, isSigner: false, isWritable: false },
|
{ pubkey: proposalAccount, isSigner: false, isWritable: false },
|
||||||
{ pubkey: votingAccount, isSigner: false, isWritable: false },
|
{ pubkey: votingAccount, isSigner: false, isWritable: false },
|
||||||
{ pubkey: payer, isSigner: true, isWritable: false },
|
{ pubkey: payer, isSigner: true, isWritable: false },
|
||||||
|
|
||||||
{
|
|
||||||
pubkey: PROGRAM_IDS.timelock.programAccountId,
|
|
||||||
isSigner: false,
|
|
||||||
isWritable: false,
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
pubkey: PROGRAM_IDS.timelock.programId,
|
pubkey: PROGRAM_IDS.timelock.programId,
|
||||||
isSigner: false,
|
isSigner: false,
|
||||||
|
|
|
@ -15,10 +15,8 @@ import * as Layout from '../utils/layout';
|
||||||
/// 2. `[]` Governance mint to tie this config to
|
/// 2. `[]` Governance mint to tie this config to
|
||||||
/// 3. `[]` Council mint [optional] to tie this config to [Pass in 0s otherwise]
|
/// 3. `[]` Council mint [optional] to tie this config to [Pass in 0s otherwise]
|
||||||
/// 4. `[]` Payer
|
/// 4. `[]` Payer
|
||||||
/// 5. `[]` Timelock program account pub key.
|
/// 6. `[]` Timelock program pub key.
|
||||||
/// 6. `[]` Timelock program pub key. Different from program account - is the actual id of the executable.
|
/// 7. `[]` System account.
|
||||||
/// 7. `[]` Token program account.
|
|
||||||
/// 8. `[]` System account.
|
|
||||||
export const createEmptyTimelockConfigInstruction = (
|
export const createEmptyTimelockConfigInstruction = (
|
||||||
timelockConfigAccount: PublicKey,
|
timelockConfigAccount: PublicKey,
|
||||||
programAccount: PublicKey,
|
programAccount: PublicKey,
|
||||||
|
@ -46,17 +44,11 @@ export const createEmptyTimelockConfigInstruction = (
|
||||||
{ pubkey: councilMint, isSigner: false, isWritable: false },
|
{ pubkey: councilMint, isSigner: false, isWritable: false },
|
||||||
{ pubkey: payer, isSigner: true, isWritable: false },
|
{ pubkey: payer, isSigner: true, isWritable: false },
|
||||||
|
|
||||||
{
|
|
||||||
pubkey: PROGRAM_IDS.timelock.programAccountId,
|
|
||||||
isSigner: false,
|
|
||||||
isWritable: false,
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
pubkey: PROGRAM_IDS.timelock.programId,
|
pubkey: PROGRAM_IDS.timelock.programId,
|
||||||
isSigner: false,
|
isSigner: false,
|
||||||
isWritable: false,
|
isWritable: false,
|
||||||
},
|
},
|
||||||
{ pubkey: PROGRAM_IDS.token, isSigner: false, isWritable: false },
|
|
||||||
{ pubkey: PROGRAM_IDS.system, isSigner: false, isWritable: false },
|
{ pubkey: PROGRAM_IDS.system, isSigner: false, isWritable: false },
|
||||||
];
|
];
|
||||||
return new TransactionInstruction({
|
return new TransactionInstruction({
|
||||||
|
|
|
@ -19,8 +19,7 @@ import BN from 'bn.js';
|
||||||
/// 5. `[]` Timelock set account.
|
/// 5. `[]` Timelock set account.
|
||||||
/// 6. `[]` Transfer authority
|
/// 6. `[]` Transfer authority
|
||||||
/// 7. `[]` Timelock program mint authority
|
/// 7. `[]` Timelock program mint authority
|
||||||
/// 8. `[]` Timelock program account pub key.
|
/// 8. `[]` Token program account.
|
||||||
/// 9. `[]` Token program account.
|
|
||||||
export const depositSourceTokensInstruction = (
|
export const depositSourceTokensInstruction = (
|
||||||
governanceVotingRecord: PublicKey,
|
governanceVotingRecord: PublicKey,
|
||||||
votingAccount: PublicKey,
|
votingAccount: PublicKey,
|
||||||
|
@ -58,11 +57,6 @@ export const depositSourceTokensInstruction = (
|
||||||
{ pubkey: timelockSetAccount, isSigner: false, isWritable: false },
|
{ pubkey: timelockSetAccount, isSigner: false, isWritable: false },
|
||||||
{ pubkey: transferAuthority, isSigner: false, isWritable: false },
|
{ pubkey: transferAuthority, isSigner: false, isWritable: false },
|
||||||
{ pubkey: mintAuthority, isSigner: false, isWritable: false },
|
{ pubkey: mintAuthority, isSigner: false, isWritable: false },
|
||||||
{
|
|
||||||
pubkey: PROGRAM_IDS.timelock.programAccountId,
|
|
||||||
isSigner: false,
|
|
||||||
isWritable: false,
|
|
||||||
},
|
|
||||||
{ pubkey: PROGRAM_IDS.token, isSigner: false, isWritable: false },
|
{ pubkey: PROGRAM_IDS.token, isSigner: false, isWritable: false },
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|
|
@ -14,8 +14,7 @@ import { TimelockInstruction } from './timelock';
|
||||||
/// 2. `[]` Program being invoked account
|
/// 2. `[]` Program being invoked account
|
||||||
/// 3. `[]` Timelock set account.
|
/// 3. `[]` Timelock set account.
|
||||||
/// 4. `[]` Timelock config
|
/// 4. `[]` Timelock config
|
||||||
/// 5. `[]` Timelock program account pub key.
|
/// 5. `[]` Clock sysvar.
|
||||||
/// 6. `[]` Clock sysvar.
|
|
||||||
/// 7+ Any extra accounts that are part of the instruction, in order
|
/// 7+ Any extra accounts that are part of the instruction, in order
|
||||||
export const executeInstruction = (
|
export const executeInstruction = (
|
||||||
transactionAccount: PublicKey,
|
transactionAccount: PublicKey,
|
||||||
|
@ -49,11 +48,6 @@ export const executeInstruction = (
|
||||||
{ pubkey: programBeingInvokedAccount, isSigner: false, isWritable: false },
|
{ pubkey: programBeingInvokedAccount, isSigner: false, isWritable: false },
|
||||||
{ pubkey: timelockSetAccount, isSigner: false, isWritable: false },
|
{ pubkey: timelockSetAccount, isSigner: false, isWritable: false },
|
||||||
{ pubkey: timelockConfig, isSigner: false, isWritable: false },
|
{ pubkey: timelockConfig, isSigner: false, isWritable: false },
|
||||||
{
|
|
||||||
pubkey: PROGRAM_IDS.timelock.programAccountId,
|
|
||||||
isSigner: false,
|
|
||||||
isWritable: false,
|
|
||||||
},
|
|
||||||
{ pubkey: SYSVAR_CLOCK_PUBKEY, isSigner: false, isWritable: false },
|
{ pubkey: SYSVAR_CLOCK_PUBKEY, isSigner: false, isWritable: false },
|
||||||
...accountInfos,
|
...accountInfos,
|
||||||
];
|
];
|
||||||
|
|
|
@ -14,8 +14,6 @@ import * as Layout from '../utils/layout';
|
||||||
/// 1. `[]` Program account that this config uses
|
/// 1. `[]` Program account that this config uses
|
||||||
/// 2. `[]` Governance mint that this config uses
|
/// 2. `[]` Governance mint that this config uses
|
||||||
/// 3. `[]` Council mint that this config uses [Optional] [Pass in 0s otherwise]
|
/// 3. `[]` Council mint that this config uses [Optional] [Pass in 0s otherwise]
|
||||||
/// 4. `[]` Timelock program account pub key.
|
|
||||||
/// 5. `[]` Token program account.
|
|
||||||
export const initTimelockConfigInstruction = (
|
export const initTimelockConfigInstruction = (
|
||||||
timelockConfigAccount: PublicKey,
|
timelockConfigAccount: PublicKey,
|
||||||
programAccount: PublicKey,
|
programAccount: PublicKey,
|
||||||
|
@ -72,12 +70,6 @@ export const initTimelockConfigInstruction = (
|
||||||
{ pubkey: programAccount, isSigner: false, isWritable: false },
|
{ pubkey: programAccount, isSigner: false, isWritable: false },
|
||||||
{ pubkey: governanceMint, isSigner: false, isWritable: false },
|
{ pubkey: governanceMint, isSigner: false, isWritable: false },
|
||||||
{ pubkey: councilMint, isSigner: false, isWritable: false },
|
{ pubkey: councilMint, isSigner: false, isWritable: false },
|
||||||
{
|
|
||||||
pubkey: PROGRAM_IDS.timelock.programAccountId,
|
|
||||||
isSigner: false,
|
|
||||||
isWritable: false,
|
|
||||||
},
|
|
||||||
{ pubkey: PROGRAM_IDS.token, isSigner: false, isWritable: false },
|
|
||||||
];
|
];
|
||||||
return new TransactionInstruction({
|
return new TransactionInstruction({
|
||||||
keys,
|
keys,
|
||||||
|
|
|
@ -28,9 +28,8 @@ import { DESC_SIZE, NAME_SIZE, TimelockInstruction } from './timelock';
|
||||||
/// 15. `[writable]` Initialized source holding account
|
/// 15. `[writable]` Initialized source holding account
|
||||||
/// 16. `[]` Source mint
|
/// 16. `[]` Source mint
|
||||||
/// 17. `[]` Timelock minting authority
|
/// 17. `[]` Timelock minting authority
|
||||||
/// 18. `[]` Timelock Program
|
/// 18. '[]` Token program id
|
||||||
/// 19. '[]` Token program id
|
/// 19. `[]` Rent sysvar
|
||||||
/// 20. `[]` Rent sysvar
|
|
||||||
export const initTimelockSetInstruction = (
|
export const initTimelockSetInstruction = (
|
||||||
timelockStateAccount: PublicKey,
|
timelockStateAccount: PublicKey,
|
||||||
timelockSetAccount: PublicKey,
|
timelockSetAccount: PublicKey,
|
||||||
|
@ -111,11 +110,6 @@ export const initTimelockSetInstruction = (
|
||||||
isWritable: false,
|
isWritable: false,
|
||||||
},
|
},
|
||||||
{ pubkey: authority, isSigner: false, isWritable: false },
|
{ pubkey: authority, isSigner: false, isWritable: false },
|
||||||
{
|
|
||||||
pubkey: PROGRAM_IDS.timelock.programAccountId,
|
|
||||||
isSigner: false,
|
|
||||||
isWritable: false,
|
|
||||||
},
|
|
||||||
{ pubkey: PROGRAM_IDS.token, isSigner: false, isWritable: false },
|
{ pubkey: PROGRAM_IDS.token, isSigner: false, isWritable: false },
|
||||||
{ pubkey: SYSVAR_RENT_PUBKEY, isSigner: false, isWritable: false },
|
{ pubkey: SYSVAR_RENT_PUBKEY, isSigner: false, isWritable: false },
|
||||||
];
|
];
|
||||||
|
|
|
@ -12,8 +12,7 @@ import { TimelockInstruction } from './timelock';
|
||||||
/// 3. `[writable]` Admin validation account.
|
/// 3. `[writable]` Admin validation account.
|
||||||
/// 4. `[]` Timelock set account.
|
/// 4. `[]` Timelock set account.
|
||||||
/// 5. `[]` Transfer authority
|
/// 5. `[]` Transfer authority
|
||||||
/// 5. `[]` Timelock program mint authority
|
/// 6. `[]` Timelock program mint authority
|
||||||
/// 6. `[]` Timelock program account.
|
|
||||||
/// 7. '[]` Token program id.
|
/// 7. '[]` Token program id.
|
||||||
export const removeSignerInstruction = (
|
export const removeSignerInstruction = (
|
||||||
signatoryAccount: PublicKey,
|
signatoryAccount: PublicKey,
|
||||||
|
@ -45,11 +44,6 @@ export const removeSignerInstruction = (
|
||||||
{ pubkey: timelockSetAccount, isSigner: false, isWritable: true },
|
{ pubkey: timelockSetAccount, isSigner: false, isWritable: true },
|
||||||
{ pubkey: transferAuthority, isSigner: true, isWritable: false },
|
{ pubkey: transferAuthority, isSigner: true, isWritable: false },
|
||||||
{ pubkey: mintAuthority, isSigner: false, isWritable: false },
|
{ pubkey: mintAuthority, isSigner: false, isWritable: false },
|
||||||
{
|
|
||||||
pubkey: PROGRAM_IDS.timelock.programAccountId,
|
|
||||||
isSigner: false,
|
|
||||||
isWritable: false,
|
|
||||||
},
|
|
||||||
{ pubkey: PROGRAM_IDS.token, isSigner: false, isWritable: false },
|
{ pubkey: PROGRAM_IDS.token, isSigner: false, isWritable: false },
|
||||||
];
|
];
|
||||||
return new TransactionInstruction({
|
return new TransactionInstruction({
|
||||||
|
|
|
@ -17,9 +17,8 @@ import { TimelockInstruction } from './timelock';
|
||||||
/// 3. `[]` Timelock set account pub key.
|
/// 3. `[]` Timelock set account pub key.
|
||||||
/// 4. `[]` Transfer authority
|
/// 4. `[]` Transfer authority
|
||||||
/// 5. `[]` Timelock mint authority
|
/// 5. `[]` Timelock mint authority
|
||||||
/// 6. `[]` Timelock program account pub key.
|
/// 6. `[]` Token program account.
|
||||||
/// 7. `[]` Token program account.
|
/// 7. `[]` Clock sysvar.
|
||||||
/// 8. `[]` Clock sysvar.
|
|
||||||
export const signInstruction = (
|
export const signInstruction = (
|
||||||
timelockStateAccount: PublicKey,
|
timelockStateAccount: PublicKey,
|
||||||
signatoryAccount: PublicKey,
|
signatoryAccount: PublicKey,
|
||||||
|
@ -48,11 +47,6 @@ export const signInstruction = (
|
||||||
{ pubkey: timelockSetAccount, isSigner: false, isWritable: false },
|
{ pubkey: timelockSetAccount, isSigner: false, isWritable: false },
|
||||||
{ pubkey: transferAuthority, isSigner: true, isWritable: false },
|
{ pubkey: transferAuthority, isSigner: true, isWritable: false },
|
||||||
{ pubkey: mintAuthority, isSigner: false, isWritable: false },
|
{ pubkey: mintAuthority, isSigner: false, isWritable: false },
|
||||||
{
|
|
||||||
pubkey: PROGRAM_IDS.timelock.programAccountId,
|
|
||||||
isSigner: false,
|
|
||||||
isWritable: false,
|
|
||||||
},
|
|
||||||
{ pubkey: PROGRAM_IDS.token, isSigner: false, isWritable: false },
|
{ pubkey: PROGRAM_IDS.token, isSigner: false, isWritable: false },
|
||||||
{ pubkey: SYSVAR_CLOCK_PUBKEY, isSigner: false, isWritable: false },
|
{ pubkey: SYSVAR_CLOCK_PUBKEY, isSigner: false, isWritable: false },
|
||||||
];
|
];
|
||||||
|
|
|
@ -171,6 +171,7 @@ for (let i = 0; i < TRANSACTION_SLOTS; i++) {
|
||||||
export const TimelockSetLayout: typeof BufferLayout.Structure = BufferLayout.struct(
|
export const TimelockSetLayout: typeof BufferLayout.Structure = BufferLayout.struct(
|
||||||
[
|
[
|
||||||
Layout.publicKey('config'),
|
Layout.publicKey('config'),
|
||||||
|
Layout.publicKey('tokenProgramId'),
|
||||||
Layout.publicKey('state'),
|
Layout.publicKey('state'),
|
||||||
BufferLayout.u8('version'),
|
BufferLayout.u8('version'),
|
||||||
Layout.publicKey('signatoryMint'),
|
Layout.publicKey('signatoryMint'),
|
||||||
|
@ -213,6 +214,9 @@ export interface TimelockSet {
|
||||||
/// configuration values
|
/// configuration values
|
||||||
config: PublicKey;
|
config: PublicKey;
|
||||||
|
|
||||||
|
/// Token Program ID
|
||||||
|
tokenProgramId: PublicKey;
|
||||||
|
|
||||||
/// state values
|
/// state values
|
||||||
state: PublicKey;
|
state: PublicKey;
|
||||||
|
|
||||||
|
@ -296,6 +300,7 @@ export const TimelockSetParser = (
|
||||||
},
|
},
|
||||||
info: {
|
info: {
|
||||||
config: data.config,
|
config: data.config,
|
||||||
|
tokenProgramId: data.tokenProgramId,
|
||||||
state: data.state,
|
state: data.state,
|
||||||
version: data.version,
|
version: data.version,
|
||||||
signatoryMint: data.signatoryMint,
|
signatoryMint: data.signatoryMint,
|
||||||
|
|
|
@ -29,9 +29,8 @@ import BN from 'bn.js';
|
||||||
/// 10. `[]` Timelock config account.
|
/// 10. `[]` Timelock config account.
|
||||||
/// 12. `[]` Transfer authority
|
/// 12. `[]` Transfer authority
|
||||||
/// 13. `[]` Timelock program mint authority
|
/// 13. `[]` Timelock program mint authority
|
||||||
/// 14. `[]` Timelock program account pub key.
|
/// 14. `[]` Token program account.
|
||||||
/// 15. `[]` Token program account.
|
/// 15. `[]` Clock sysvar.
|
||||||
/// 16. `[]` Clock sysvar.
|
|
||||||
export const voteInstruction = (
|
export const voteInstruction = (
|
||||||
governanceVotingRecord: PublicKey,
|
governanceVotingRecord: PublicKey,
|
||||||
timelockStateAccount: PublicKey,
|
timelockStateAccount: PublicKey,
|
||||||
|
@ -82,11 +81,6 @@ export const voteInstruction = (
|
||||||
{ pubkey: timelockConfig, isSigner: false, isWritable: false },
|
{ pubkey: timelockConfig, isSigner: false, isWritable: false },
|
||||||
{ pubkey: transferAuthority, isSigner: true, isWritable: false },
|
{ pubkey: transferAuthority, isSigner: true, isWritable: false },
|
||||||
{ pubkey: mintAuthority, isSigner: false, isWritable: false },
|
{ pubkey: mintAuthority, isSigner: false, isWritable: false },
|
||||||
{
|
|
||||||
pubkey: PROGRAM_IDS.timelock.programAccountId,
|
|
||||||
isSigner: false,
|
|
||||||
isWritable: false,
|
|
||||||
},
|
|
||||||
{ pubkey: PROGRAM_IDS.token, isSigner: false, isWritable: false },
|
{ pubkey: PROGRAM_IDS.token, isSigner: false, isWritable: false },
|
||||||
{ pubkey: SYSVAR_CLOCK_PUBKEY, isSigner: false, isWritable: false },
|
{ pubkey: SYSVAR_CLOCK_PUBKEY, isSigner: false, isWritable: false },
|
||||||
];
|
];
|
||||||
|
|
|
@ -20,11 +20,8 @@ import BN from 'bn.js';
|
||||||
/// 11. `[]` Timelock state account.
|
/// 11. `[]` Timelock state account.
|
||||||
/// 12. `[]` Timelock set account.
|
/// 12. `[]` Timelock set account.
|
||||||
/// 13. `[]` Transfer authority
|
/// 13. `[]` Transfer authority
|
||||||
/// 14. `[]` Yes Transfer authority
|
/// 14. `[]` Timelock program mint authority
|
||||||
/// 15. `[]` No Transfer authority
|
/// 15. `[]` Token program account.
|
||||||
/// 16. `[]` Timelock program mint authority
|
|
||||||
/// 17. `[]` Timelock program account pub key.
|
|
||||||
/// 18. `[]` Token program account.
|
|
||||||
export const withdrawVotingTokensInstruction = (
|
export const withdrawVotingTokensInstruction = (
|
||||||
governanceVotingRecord: PublicKey,
|
governanceVotingRecord: PublicKey,
|
||||||
votingAccount: PublicKey,
|
votingAccount: PublicKey,
|
||||||
|
@ -40,8 +37,6 @@ export const withdrawVotingTokensInstruction = (
|
||||||
timelockStateAccount: PublicKey,
|
timelockStateAccount: PublicKey,
|
||||||
timelockSetAccount: PublicKey,
|
timelockSetAccount: PublicKey,
|
||||||
transferAuthority: PublicKey,
|
transferAuthority: PublicKey,
|
||||||
yesTransferAuthority: PublicKey,
|
|
||||||
noTransferAuthority: PublicKey,
|
|
||||||
mintAuthority: PublicKey,
|
mintAuthority: PublicKey,
|
||||||
votingTokenAmount: number,
|
votingTokenAmount: number,
|
||||||
): TransactionInstruction => {
|
): TransactionInstruction => {
|
||||||
|
@ -76,15 +71,8 @@ export const withdrawVotingTokensInstruction = (
|
||||||
{ pubkey: noVotingMint, isSigner: false, isWritable: true },
|
{ pubkey: noVotingMint, isSigner: false, isWritable: true },
|
||||||
{ pubkey: timelockStateAccount, isSigner: false, isWritable: false },
|
{ pubkey: timelockStateAccount, isSigner: false, isWritable: false },
|
||||||
{ pubkey: timelockSetAccount, isSigner: false, isWritable: false },
|
{ pubkey: timelockSetAccount, isSigner: false, isWritable: false },
|
||||||
{ pubkey: transferAuthority, isSigner: false, isWritable: false },
|
{ pubkey: transferAuthority, isSigner: true, isWritable: false },
|
||||||
{ pubkey: yesTransferAuthority, isSigner: false, isWritable: false },
|
|
||||||
{ pubkey: noTransferAuthority, isSigner: false, isWritable: false },
|
|
||||||
{ pubkey: mintAuthority, isSigner: false, isWritable: false },
|
{ pubkey: mintAuthority, isSigner: false, isWritable: false },
|
||||||
{
|
|
||||||
pubkey: PROGRAM_IDS.timelock.programAccountId,
|
|
||||||
isSigner: false,
|
|
||||||
isWritable: false,
|
|
||||||
},
|
|
||||||
{ pubkey: PROGRAM_IDS.token, isSigner: false, isWritable: false },
|
{ pubkey: PROGRAM_IDS.token, isSigner: false, isWritable: false },
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import { utils } from '@oyster/common';
|
import { ParsedAccount, utils } from '@oyster/common';
|
||||||
import {
|
import {
|
||||||
Connection,
|
Connection,
|
||||||
TransactionInstruction,
|
TransactionInstruction,
|
||||||
|
@ -6,12 +6,15 @@ import {
|
||||||
PublicKey,
|
PublicKey,
|
||||||
Message,
|
Message,
|
||||||
} from '@solana/web3.js';
|
} from '@solana/web3.js';
|
||||||
|
import { TimelockSet } from '../models/timelock';
|
||||||
export async function serializeInstruction({
|
export async function serializeInstruction({
|
||||||
connection,
|
connection,
|
||||||
instr,
|
instr,
|
||||||
|
proposal,
|
||||||
}: {
|
}: {
|
||||||
connection: Connection;
|
connection: Connection;
|
||||||
instr: TransactionInstruction;
|
instr: TransactionInstruction;
|
||||||
|
proposal: ParsedAccount<TimelockSet>;
|
||||||
}): Promise<{ base64: string; byteArray: Uint8Array }> {
|
}): Promise<{ base64: string; byteArray: Uint8Array }> {
|
||||||
const PROGRAM_IDS = utils.programIds();
|
const PROGRAM_IDS = utils.programIds();
|
||||||
let instructionTransaction = new Transaction();
|
let instructionTransaction = new Transaction();
|
||||||
|
@ -20,7 +23,7 @@ export async function serializeInstruction({
|
||||||
await connection.getRecentBlockhash('max')
|
await connection.getRecentBlockhash('max')
|
||||||
).blockhash;
|
).blockhash;
|
||||||
const [authority] = await PublicKey.findProgramAddress(
|
const [authority] = await PublicKey.findProgramAddress(
|
||||||
[PROGRAM_IDS.timelock.programAccountId.toBuffer()],
|
[proposal.pubkey.toBuffer()],
|
||||||
PROGRAM_IDS.timelock.programId,
|
PROGRAM_IDS.timelock.programId,
|
||||||
);
|
);
|
||||||
instructionTransaction.setSigners(authority);
|
instructionTransaction.setSigners(authority);
|
||||||
|
|
Loading…
Reference in New Issue