Skip to content

Commit e53cbf2

Browse files
fix: make queue field nullable in accounts table (helius-labs#280)
* Make queue field nullable in accounts table * regenerate schema
1 parent af8feed commit e53cbf2

16 files changed

Lines changed: 42 additions & 38 deletions

File tree

src/api/method/get_compressed_account_proof/v2.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ pub async fn get_compressed_account_proof_v2(
127127

128128
// Enrich with account data if available
129129
if let Some(account) = account {
130-
result.tree_context.tree_type = account.tree_type as u16;
130+
result.tree_context.tree_type = account.tree_type.map(|t| t as u16).unwrap_or(0);
131131
result.tree_context.queue = SerializablePubkey::try_from(account.queue)?;
132132
}
133133

src/api/method/get_multiple_compressed_account_proofs/v2.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ pub async fn get_multiple_compressed_account_proofs_v2(
146146
for value in &mut result {
147147
if let Some(account) = account_map.get(&value.hash.to_vec()) {
148148
value.tree_context = TreeContextInfo {
149-
tree_type: account.tree_type as u16,
149+
tree_type: account.tree_type.map(|t| t as u16).unwrap_or(0),
150150
tree: SerializablePubkey::try_from(account.tree.clone())?,
151151
queue: SerializablePubkey::try_from(account.queue.clone())?,
152152
cpi_context: None,

src/api/method/get_validity_proof/v2.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ pub async fn get_validity_proof_v2(
200200
root_index: None.into(), // prove_by_index = true
201201
leaf_index: acc_model.leaf_index as u64,
202202
merkle_context: MerkleContextV2 {
203-
tree_type: acc_model.tree_type as u16,
203+
tree_type: acc_model.tree_type.map(|t| t as u16).unwrap_or(0),
204204
tree: SerializablePubkey::try_from_slice(&acc_model.tree)
205205
.unwrap_or_default(),
206206
queue: SerializablePubkey::try_from_slice(&acc_model.queue)

src/common/typedefs/account/context.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ impl TryFrom<Model> for AccountWithContext {
146146
.map(|index| UnsignedInteger(index as u64)),
147147
nullifier: account.nullifier.map(Hash::try_from).transpose()?,
148148
tx_hash: account.tx_hash.map(Hash::try_from).transpose()?,
149-
tree_type: account.tree_type as u16,
149+
tree_type: account.tree_type.map(|t| t as u16).unwrap_or(0),
150150
},
151151
})
152152
}

src/common/typedefs/account/v2.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ impl TryFrom<Model> for AccountV2 {
6868
seq: account.seq.map(|seq| UnsignedInteger(seq as u64)),
6969
prove_by_index: account.in_output_queue,
7070
merkle_context: MerkleContextV2 {
71-
tree_type: account.tree_type as u16,
71+
tree_type: account.tree_type.map(|t| t as u16).unwrap_or(0),
7272
tree: account.tree.try_into()?,
7373
queue: account.queue.clone().try_into()?,
7474
cpi_context: None,

src/dao/generated/accounts.rs

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,23 +12,22 @@ pub struct Model {
1212
pub address: Option<Vec<u8>>,
1313
pub owner: Vec<u8>,
1414
pub tree: Vec<u8>,
15-
/// Queue pubkey, for batched trees output queue pubkey
16-
pub queue: Vec<u8>,
1715
pub leaf_index: i64,
18-
pub in_output_queue: bool,
19-
pub nullifier_queue_index: Option<i64>,
20-
pub nullified_in_tree: bool,
21-
pub tree_type: i32,
22-
pub nullifier: Option<Vec<u8>>,
23-
pub tx_hash: Option<Vec<u8>>,
2416
pub seq: Option<i64>,
2517
pub slot_created: i64,
2618
pub spent: bool,
2719
pub prev_spent: Option<bool>,
28-
#[sea_orm(column_type = "Decimal(Some((20, 0)))")]
20+
#[sea_orm(column_type = "Decimal(Some((23, 0)))")]
2921
pub lamports: Decimal,
30-
#[sea_orm(column_type = "Decimal(Some((20, 0)))", nullable)]
22+
#[sea_orm(column_type = "Decimal(Some((23, 0)))", nullable)]
3123
pub discriminator: Option<Decimal>,
24+
pub tree_type: Option<i32>,
25+
pub nullified_in_tree: bool,
26+
pub nullifier_queue_index: Option<i64>,
27+
pub in_output_queue: bool,
28+
pub queue: Vec<u8>,
29+
pub nullifier: Option<Vec<u8>>,
30+
pub tx_hash: Option<Vec<u8>>,
3231
}
3332

3433
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@ use sea_orm::entity::prelude::*;
55
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)]
66
#[sea_orm(table_name = "address_queues")]
77
pub struct Model {
8+
pub tree: Vec<u8>,
89
#[sea_orm(primary_key, auto_increment = false)]
910
pub address: Vec<u8>,
10-
pub tree: Vec<u8>,
1111
pub queue_index: i64,
1212
}
1313

src/dao/generated/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ pub mod prelude;
44

55
pub mod account_transactions;
66
pub mod accounts;
7-
pub mod address_queue;
7+
pub mod address_queues;
88
pub mod blocks;
99
pub mod indexed_trees;
1010
pub mod owner_balances;

src/dao/generated/owner_balances.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use sea_orm::entity::prelude::*;
77
pub struct Model {
88
#[sea_orm(primary_key, auto_increment = false)]
99
pub owner: Vec<u8>,
10-
#[sea_orm(column_type = "Decimal(Some((20, 0)))")]
10+
#[sea_orm(column_type = "Decimal(Some((23, 0)))")]
1111
pub lamports: Decimal,
1212
}
1313

src/dao/generated/prelude.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
33
pub use super::account_transactions::Entity as AccountTransactions;
44
pub use super::accounts::Entity as Accounts;
5+
pub use super::address_queues::Entity as AddressQueues;
56
pub use super::blocks::Entity as Blocks;
67
pub use super::indexed_trees::Entity as IndexedTrees;
78
pub use super::owner_balances::Entity as OwnerBalances;

0 commit comments

Comments
 (0)