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