Skip to content

Commit

Permalink
fix typo in indexNullifierQueuePubkeyIndex
Browse files Browse the repository at this point in the history
  • Loading branch information
Swen committed Mar 28, 2024
1 parent 31ea106 commit ab57fb4
Show file tree
Hide file tree
Showing 12 changed files with 44 additions and 42 deletions.
4 changes: 2 additions & 2 deletions js/compressed-token/src/idl/psp_compressed_token.ts
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ export type PspCompressedToken = {
type: 'u8';
},
{
name: 'indexNullifierQueuePubkeyIndex';
name: 'nullifierQueuePubkeyIndex';
type: 'u8';
},
{
Expand Down Expand Up @@ -911,7 +911,7 @@ export const IDL: PspCompressedToken = {
type: 'u8',
},
{
name: 'indexNullifierQueuePubkeyIndex',
name: 'nullifierQueuePubkeyIndex',
type: 'u8',
},
{
Expand Down
4 changes: 2 additions & 2 deletions js/stateless.js/src/idls/psp_compressed_pda.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ export type PspCompressedPda = {
type: 'u8';
},
{
name: 'indexNullifierQueuePubkeyIndex';
name: 'nullifierQueuePubkeyIndex';
type: 'u8';
},
{
Expand Down Expand Up @@ -564,7 +564,7 @@ export const IDL: PspCompressedPda = {
type: 'u8',
},
{
name: 'indexNullifierQueuePubkeyIndex',
name: 'nullifierQueuePubkeyIndex',
type: 'u8',
},
{
Expand Down
8 changes: 4 additions & 4 deletions js/stateless.js/src/instruction/pack-compressed-accounts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,11 +86,11 @@ export function packCompressedAccounts(

/// input
inputCompressedAccounts.forEach(account => {
const indexMerkleTree = getIndexOrAdd(
const merkleTreePubkeyIndex = getIndexOrAdd(
_remainingAccounts,
account.merkleTree,
);
const indexNullifierQueue = getIndexOrAdd(
const nullifierQueuePubkeyIndex = getIndexOrAdd(
_remainingAccounts,
account.nullifierQueue,
);
Expand All @@ -102,8 +102,8 @@ export function packCompressedAccounts(
address: account.address,
data: account.data,
},
merkleTreePubkeyIndex: indexMerkleTree,
nullifierQueuePubkeyIndex: indexNullifierQueue,
merkleTreePubkeyIndex,
nullifierQueuePubkeyIndex,
leafIndex: account.leafIndex,
});
});
Expand Down
2 changes: 1 addition & 1 deletion js/stateless.js/src/state/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ export interface PublicTransactionEvent {
outputStateMerkleTreeAccountIndices: Uint8Array; // bytes
outputLeafIndices: number[]; // Vec<u32>
relayFee: BN | null; // Option<u64>
deCompressAmount: BN | null; // Option<u64>
isCompress: boolean; // bool
deCompressAmount: BN | null; // Option<u64>
pubkeyArray: PublicKey[]; // Vec<PublicKey>
message: Uint8Array | null; // Option<bytes>
}
Expand Down
29 changes: 16 additions & 13 deletions js/stateless.js/tests/e2e/serde.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,26 +54,29 @@ describe('serde', () => {

it('decode event ', async () => {
const data = [
0, 0, 0, 0, 1, 0, 0, 0, 21, 2, 159, 146, 115, 243, 27, 245, 225, 130, 22,
145, 247, 216, 21, 84, 136, 140, 91, 209, 249, 136, 44, 124, 235, 209,
230, 254, 72, 190, 187, 107, 0, 0, 0, 0, 1, 0, 0, 0, 191, 190, 219, 108,
109, 150, 78, 142, 89, 168, 144, 217, 102, 58, 224, 64, 118, 152, 19, 51,
97, 198, 36, 158, 140, 153, 125, 208, 187, 78, 107, 249, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 68,
77, 125, 32, 76, 128, 61, 180, 1, 207, 69, 44, 121, 118, 153, 17, 179,
183, 115, 34, 163, 127, 102, 214, 1, 87, 175, 177, 95, 49, 65, 69, 0,
0, 0, 0, 0, 1, 0, 0, 0, 33, 32, 204, 221, 5, 83, 170, 139, 228, 191, 81,
173, 10, 116, 229, 191, 155, 209, 23, 164, 28, 64, 188, 34, 248, 127, 110,
97, 26, 188, 139, 164, 0, 0, 0, 0, 1, 0, 0, 0, 22, 143, 135, 215, 254,
121, 58, 95, 241, 202, 91, 53, 255, 47, 224, 255, 67, 218, 48, 172, 51,
208, 29, 102, 177, 187, 207, 73, 108, 18, 59, 255, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 68, 77,
125, 32, 76, 128, 61, 180, 1, 207, 69, 44, 121, 118, 153, 17, 179, 183,
115, 34, 163, 127, 102, 214, 1, 87, 175, 177, 95, 49, 65, 69, 0,
];
const event: PublicTransactionEvent =
LightSystemProgram.program.coder.types.decode(
'PublicTransactionEvent',
Buffer.from(data),
);

const ref = [
21, 2, 159, 146, 115, 243, 27, 245, 225, 130, 22, 145, 247, 216, 21, 84,
136, 140, 91, 209, 249, 136, 44, 124, 235, 209, 230, 254, 72, 190, 187,
107,
const refOutputCompressedAccountHash = [
33, 32, 204, 221, 5, 83, 170, 139, 228, 191, 81, 173, 10, 116, 229, 191,
155, 209, 23, 164, 28, 64, 188, 34, 248, 127, 110, 97, 26, 188, 139, 164,
];
expect(bn(event.outputCompressedAccountHashes[0]).eq(bn(ref))).toBe(true);
expect(
bn(event.outputCompressedAccountHashes[0]).eq(
bn(refOutputCompressedAccountHash),
),
).toBe(true);
});
});
2 changes: 1 addition & 1 deletion programs/compressed-pda/src/compressed_account.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use light_utils::hash_to_bn254_field_size_le;
pub struct CompressedAccountWithMerkleContext {
pub compressed_account: CompressedAccount,
pub merkle_tree_pubkey_index: u8,
pub index_nullifier_queue_pubkey_index: u8,
pub nullifier_queue_pubkey_index: u8,
pub leaf_index: u32,
}

Expand Down
9 changes: 4 additions & 5 deletions programs/compressed-pda/src/nullify_state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,10 @@ pub fn insert_nullifiers<'a, 'b, 'c: 'info, 'info>(
.collect::<Vec<Pubkey>>();
let mut indexed_array_account_infos = Vec::<AccountInfo>::new();
for account in inputs.input_compressed_accounts_with_merkle_context.iter() {
indexed_array_account_infos.push(
ctx.remaining_accounts[account.index_nullifier_queue_pubkey_index as usize].clone(),
);
indexed_array_account_infos
.push(ctx.remaining_accounts[account.nullifier_queue_pubkey_index as usize].clone());
let unpacked_queue_account = AccountLoader::<IndexedArrayAccount>::try_from(
&ctx.remaining_accounts[account.index_nullifier_queue_pubkey_index as usize],
&ctx.remaining_accounts[account.nullifier_queue_pubkey_index as usize],
)
.unwrap();
let array_account = unpacked_queue_account.load()?;
Expand All @@ -35,7 +34,7 @@ pub fn insert_nullifiers<'a, 'b, 'c: 'info, 'info>(
if !account_is_associated_with_state_merkle_tree {
msg!(
"Nullifier queue account {:?} is not associated with any state Merkle tree. Provided state Merkle trees {:?}",
ctx.remaining_accounts[account.index_nullifier_queue_pubkey_index as usize].key(), state_merkle_tree_pubkeys);
ctx.remaining_accounts[account.nullifier_queue_pubkey_index as usize].key(), state_merkle_tree_pubkeys);
return Err(crate::ErrorCode::InvalidNullifierQueue.into());
}
}
Expand Down
12 changes: 6 additions & 6 deletions programs/compressed-pda/src/sdk.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ pub fn create_execute_compressed_instruction(
_input_compressed_accounts.push(CompressedAccountWithMerkleContext {
compressed_account: input_compressed_accounts[i].clone(),
merkle_tree_pubkey_index: *remaining_accounts.get(mt).unwrap() as u8,
index_nullifier_queue_pubkey_index: 0,
nullifier_queue_pubkey_index: 0,
leaf_index: input_compressed_accounts_leaf_indices[i],
});
}
Expand All @@ -55,7 +55,7 @@ pub fn create_execute_compressed_instruction(
remaining_accounts.insert(*mt, i + len);
}
};
_input_compressed_accounts[i].index_nullifier_queue_pubkey_index =
_input_compressed_accounts[i].nullifier_queue_pubkey_index =
*remaining_accounts.get(mt).unwrap() as u8;
}
let len: usize = remaining_accounts.len();
Expand Down Expand Up @@ -376,12 +376,12 @@ mod test {
assert_eq!(instruction.accounts[0], ref_account_meta);
assert_eq!(
deserialized_instruction_data.input_compressed_accounts_with_merkle_context[0]
.index_nullifier_queue_pubkey_index,
.nullifier_queue_pubkey_index,
1
);
assert_eq!(
deserialized_instruction_data.input_compressed_accounts_with_merkle_context[1]
.index_nullifier_queue_pubkey_index,
.nullifier_queue_pubkey_index,
1
);
assert_eq!(
Expand All @@ -399,13 +399,13 @@ mod test {
assert_eq!(
instruction.accounts[7 + deserialized_instruction_data
.input_compressed_accounts_with_merkle_context[0]
.index_nullifier_queue_pubkey_index as usize],
.nullifier_queue_pubkey_index as usize],
AccountMeta::new(nullifier_array_pubkey, false)
);
assert_eq!(
instruction.accounts[7 + deserialized_instruction_data
.input_compressed_accounts_with_merkle_context[1]
.index_nullifier_queue_pubkey_index as usize],
.nullifier_queue_pubkey_index as usize],
AccountMeta::new(nullifier_array_pubkey, false)
);
assert_eq!(
Expand Down
8 changes: 4 additions & 4 deletions programs/compressed-pda/src/verify_state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -466,7 +466,7 @@ mod test {
data: None,
},
merkle_tree_pubkey_index: 0,
index_nullifier_queue_pubkey_index: 0,
nullifier_queue_pubkey_index: 0,
leaf_index: 0,
},
CompressedAccountWithMerkleContext {
Expand All @@ -477,7 +477,7 @@ mod test {
data: None,
},
merkle_tree_pubkey_index: 0,
index_nullifier_queue_pubkey_index: 0,
nullifier_queue_pubkey_index: 0,
leaf_index: 1,
},
];
Expand Down Expand Up @@ -511,7 +511,7 @@ mod test {
data: None,
},
merkle_tree_pubkey_index: 0,
index_nullifier_queue_pubkey_index: 0,
nullifier_queue_pubkey_index: 0,
leaf_index: 0,
},
CompressedAccountWithMerkleContext {
Expand All @@ -522,7 +522,7 @@ mod test {
data: None,
},
merkle_tree_pubkey_index: 0,
index_nullifier_queue_pubkey_index: 0,
nullifier_queue_pubkey_index: 0,
leaf_index: 1,
},
];
Expand Down
2 changes: 1 addition & 1 deletion programs/compressed-pda/tests/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -656,7 +656,7 @@ impl MockIndexer {
compressed_account: compressed_account.clone(),
leaf_index: event.output_leaf_indices[i as usize],
merkle_tree_pubkey_index: 0,
index_nullifier_queue_pubkey_index: 0,
nullifier_queue_pubkey_index: 0,
});
indices.push(self.compressed_accounts.len() - 1);
self.merkle_tree
Expand Down
4 changes: 2 additions & 2 deletions programs/compressed-token/src/process_transfer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -436,7 +436,7 @@ pub mod transfer_sdk {
CompressedAccountWithMerkleContext {
compressed_account: input_compressed_account,
merkle_tree_pubkey_index: *remaining_accounts.get(mt).unwrap() as u8,
index_nullifier_queue_pubkey_index: 0,
nullifier_queue_pubkey_index: 0,
leaf_index: *leaf_index,
},
);
Expand All @@ -449,7 +449,7 @@ pub mod transfer_sdk {
remaining_accounts.insert(*mt, i + len);
}
};
input_compressed_accounts_with_merkle_context[i].index_nullifier_queue_pubkey_index =
input_compressed_accounts_with_merkle_context[i].nullifier_queue_pubkey_index =
*remaining_accounts.get(mt).unwrap() as u8;
}
let len: usize = remaining_accounts.len();
Expand Down
2 changes: 1 addition & 1 deletion programs/compressed-token/tests/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1320,7 +1320,7 @@ impl MockIndexer {
compressed_account: compressed_account.clone(),
leaf_index: event.output_leaf_indices[i as usize],
merkle_tree_pubkey_index: 0,
index_nullifier_queue_pubkey_index: 0,
nullifier_queue_pubkey_index: 0,
});
indices.push(self.compressed_accounts.len() - 1);
self.merkle_tree
Expand Down

0 comments on commit ab57fb4

Please sign in to comment.