MCPcopy Create free account
hub / github.com/Lightprotocol/light-protocol-v1 / unpack_from_slice

Method unpack_from_slice

program/src/state.rs:40–102  ·  view source on GitHub ↗
(input: &[u8])

Source from the content-addressed store, hash-verified

38 const LEN: usize = 3900 + ENCRYPTED_UTXOS_LENGTH; //3900; // 1020
39
40 fn unpack_from_slice(input: &[u8]) -> Result<Self, ProgramError> {
41 let input = array_ref![input, 0, ChecksAndTransferState::LEN];
42
43 let (
44 _is_initialized,
45 account_type,
46 found_root,
47 merkle_tree_index,
48 signing_address, // is relayer address
49 relayer_fee,
50 recipient,
51 ext_amount,
52 amount,
53 root_hash,
54 _unused, // is commit hash until changed
55 tx_integrity_hash,
56 current_instruction_index,
57 //220
58 _unused_remainder,
59 proof_a_b_c_leaves_and_nullifiers,
60 ) = array_refs![
61 input,
62 1,
63 1,
64 1,
65 1,
66 32,
67 8,
68 32,
69 8,
70 32,
71 32,
72 32,
73 32,
74 8,
75 3296,
76 384 + ENCRYPTED_UTXOS_LENGTH
77 ];
78
79 if _is_initialized[0] != 0u8 && account_type[0] != TMP_STORAGE_ACCOUNT_TYPE {
80 msg!("Wrong account type.");
81 return Err(ProgramError::InvalidAccountData);
82 }
83
84 Ok(ChecksAndTransferState {
85 is_initialized: true,
86
87 found_root: found_root[0], //0
88 account_type: account_type[0], //1
89 merkle_tree_index: merkle_tree_index[0], //2
90 signing_address: signing_address.to_vec(), //3
91 relayer_fee: relayer_fee.to_vec(), //4
92 recipient: recipient.to_vec(), //5
93 ext_amount: ext_amount.to_vec(), //6
94 amount: amount.to_vec(), //7
95 root_hash: root_hash.to_vec(), //8
96 tx_integrity_hash: tx_integrity_hash.to_vec(), //10
97 proof_a_b_c_leaves_and_nullifiers: proof_a_b_c_leaves_and_nullifiers.to_vec(), //11

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected