Skip to content

Commit d68cc82

Browse files
cleanup
1 parent acca8fb commit d68cc82

3 files changed

Lines changed: 7 additions & 53 deletions

File tree

js/compressed-token/CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
- **Delegate approval and revocation** for SPL Token, Token-2022, and light-token, aligned with existing interface helpers:
66
- **Actions:** `approveInterface`, `revokeInterface`.
77
- **Instruction builders:** `createApproveInterfaceInstructions`, `createRevokeInterfaceInstructions` — each inner array is one transaction’s instructions (same batching style as other interface instruction builders).
8-
- **Program-level helpers:** `createLightTokenApproveInstruction`, `createLightTokenRevokeInstruction`
8+
- **Program-level helpers:** `createLightTokenApproveInstruction`, `createLightTokenRevokeInstruction`
99
- **Shared options:** approve/revoke accept optional `InterfaceOptions` (same type as `transferInterface`), including `splInterfaceInfos` when you need to supply SPL interface pool accounts explicitly.
1010

1111
### Changed

js/stateless.js/src/utils/instruction.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,7 @@ import { AccountMeta, PublicKey, SystemProgram } from '@solana/web3.js';
22
import { defaultStaticAccountsStruct, featureFlags } from '../constants';
33
import { LightSystemProgram } from '../programs';
44

5-
const toStrictBool = (value: unknown): boolean =>
6-
value === true || value === 1;
5+
const toStrictBool = (value: unknown): boolean => value === true || value === 1;
76

87
export class PackedAccounts {
98
private preAccounts: AccountMeta[] = [];

sdk-libs/client/src/indexer/types/queue.rs

Lines changed: 5 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -66,59 +66,14 @@ pub struct AddressQueueData {
6666
}
6767

6868
impl AddressQueueData {
69-
/// Reconstruct a merkle proof for a given low_element_index from the deduplicated nodes.
70-
pub fn reconstruct_proof<const HEIGHT: usize>(
69+
/// Reconstruct a single merkle proof for a given address index.
70+
#[cfg(test)]
71+
fn reconstruct_proof<const HEIGHT: usize>(
7172
&self,
7273
address_idx: usize,
7374
) -> Result<[[u8; 32]; HEIGHT], IndexerError> {
74-
let leaf_index = *self.low_element_indices.get(address_idx).ok_or_else(|| {
75-
IndexerError::MissingResult {
76-
context: "reconstruct_proof".to_string(),
77-
message: format!(
78-
"address_idx {} out of bounds for low_element_indices (len {})",
79-
address_idx,
80-
self.low_element_indices.len(),
81-
),
82-
}
83-
})?;
84-
let mut proof = [[0u8; 32]; HEIGHT];
85-
let mut pos = leaf_index;
86-
87-
for (level, proof_element) in proof.iter_mut().enumerate() {
88-
let sibling_pos = if pos.is_multiple_of(2) {
89-
pos + 1
90-
} else {
91-
pos - 1
92-
};
93-
let sibling_idx = Self::encode_node_index(level, sibling_pos);
94-
95-
let hash_idx = self
96-
.nodes
97-
.iter()
98-
.position(|&n| n == sibling_idx)
99-
.ok_or_else(|| IndexerError::MissingResult {
100-
context: "reconstruct_proof".to_string(),
101-
message: format!(
102-
"Missing proof node at level {} position {} (encoded: {})",
103-
level, sibling_pos, sibling_idx
104-
),
105-
})?;
106-
let hash =
107-
self.node_hashes
108-
.get(hash_idx)
109-
.ok_or_else(|| IndexerError::MissingResult {
110-
context: "reconstruct_proof".to_string(),
111-
message: format!(
112-
"node_hashes index {} out of bounds (len {})",
113-
hash_idx,
114-
self.node_hashes.len(),
115-
),
116-
})?;
117-
*proof_element = *hash;
118-
pos /= 2;
119-
}
120-
121-
Ok(proof)
75+
let node_lookup = self.build_node_lookup();
76+
self.reconstruct_proof_with_lookup::<HEIGHT>(address_idx, &node_lookup)
12277
}
12378

12479
/// Reconstruct a contiguous batch of proofs while reusing a single node lookup table.

0 commit comments

Comments
 (0)