Skip to content

Commit

Permalink
feature: Removed unneeded slot state variable.
Browse files Browse the repository at this point in the history
  • Loading branch information
rado0x54 committed Feb 23, 2023
1 parent 7896119 commit 32ccbdf
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 25 deletions.
20 changes: 2 additions & 18 deletions packages/client/idl/src/cryptid.ts
Original file line number Diff line number Diff line change
Expand Up @@ -586,14 +586,6 @@ export type Cryptid = {
"option": "publicKey"
}
},
{
"name": "slot",
"docs": [
"The slot in which the transaction was proposed",
"This is used to prevent replay attacks"
],
"type": "u8"
},
{
"name": "state",
"docs": [
Expand Down Expand Up @@ -853,7 +845,7 @@ export type Cryptid = {
{
"code": 6017,
"name": "AlreadyAuthorizedTransactionAccount",
"msg": "Already authorized Transaction Account."
"msg": "Transaction Account is already authorized and cannot be authorized again."
}
]
};
Expand Down Expand Up @@ -1446,14 +1438,6 @@ export const IDL: Cryptid = {
"option": "publicKey"
}
},
{
"name": "slot",
"docs": [
"The slot in which the transaction was proposed",
"This is used to prevent replay attacks"
],
"type": "u8"
},
{
"name": "state",
"docs": [
Expand Down Expand Up @@ -1713,7 +1697,7 @@ export const IDL: Cryptid = {
{
"code": 6017,
"name": "AlreadyAuthorizedTransactionAccount",
"msg": "Already authorized Transaction Account."
"msg": "Transaction Account is already authorized and cannot be authorized again."
}
]
};
2 changes: 0 additions & 2 deletions programs/cryptid/src/instructions/propose_transaction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -122,8 +122,6 @@ pub fn propose_transaction<'info>(
// despite being index 0 in the remaining accounts.
ctx.accounts.transaction_account.accounts = all_accounts.iter().map(|a| *a.key).collect();

// TODO: Set slot OR move any Slot / Expiry constraints to middleware
// ctx.accounts.transaction_account.slot = Clock::get()?.slot;
ctx.accounts.transaction_account.did = *ctx.accounts.did.key;
ctx.accounts.transaction_account.instructions = instructions;
ctx.accounts.transaction_account.cryptid_account = *ctx.accounts.cryptid_account.key;
Expand Down
5 changes: 0 additions & 5 deletions programs/cryptid/src/state/transaction_account.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,6 @@ pub struct TransactionAccount {
pub instructions: Vec<AbbreviatedInstructionData>,
/// The most recent middleware PDA that approved the transaction
pub approved_middleware: Option<Pubkey>,
/// The slot in which the transaction was proposed
/// This is used to prevent replay attacks
pub slot: u8,
/// The transaction state, to prevent replay attacks
/// in case an executed transaction account is not immediately
/// garbage-collected by the runtime
Expand All @@ -46,7 +43,6 @@ impl TransactionAccount {
+ 4 + 32 * (num_accounts + 4) //accounts (+4 for the named accounts)
+ 4 + instruction_sizes.into_iter().map(AbbreviatedInstructionData::calculate_size).sum::<usize>() //transaction_instructions
+ 1 + 32 // approved_middleware
+ 1 // slot
+ 1 // state
+ 1 + 32 // unauthorized signer
+ 1 // authorized
Expand Down Expand Up @@ -104,7 +100,6 @@ mod test {
data: vec![0],
}],
approved_middleware: None,
slot: 0,
state: TransactionState::Ready,
unauthorized_signer: None,
authorized: true,
Expand Down

0 comments on commit 32ccbdf

Please sign in to comment.