Skip to content

Commit 8976c0d

Browse files
Addres fmt lints
1 parent ed78558 commit 8976c0d

File tree

9 files changed

+96
-38
lines changed

9 files changed

+96
-38
lines changed

wasm/src/programs/execution.rs

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,14 @@ use crate::{
2020
Transition,
2121
log,
2222
native::ProgramIDNative,
23-
types::native::{CurrentNetwork, ExecutionNative, IdentifierNative, ProcessNative, ProgramNative, VerifyingKeyNative},
23+
types::native::{
24+
CurrentNetwork,
25+
ExecutionNative,
26+
IdentifierNative,
27+
ProcessNative,
28+
ProgramNative,
29+
VerifyingKeyNative,
30+
},
2431
};
2532
use snarkvm_algorithms::snark::varuna::VarunaVersion;
2633
use snarkvm_console::network::Network;
@@ -178,10 +185,13 @@ pub fn verify_function_execution(
178185

179186
// Verify the execution.
180187
let consensus_version = <CurrentNetwork as Network>::CONSENSUS_VERSION(block_height).map_err(|e| e.to_string())?;
181-
let inclusion_version = if block_height >= <CurrentNetwork as Network>::INCLUSION_UPGRADE_HEIGHT().map_err(|e| e.to_string())? {
182-
InclusionVersion::V1
183-
} else {
184-
InclusionVersion::V0
185-
};
186-
process.verify_execution(consensus_version, VarunaVersion::V2, inclusion_version, execution).map_or(Ok(false), |_| Ok(true))
188+
let inclusion_version =
189+
if block_height >= <CurrentNetwork as Network>::INCLUSION_UPGRADE_HEIGHT().map_err(|e| e.to_string())? {
190+
InclusionVersion::V1
191+
} else {
192+
InclusionVersion::V0
193+
};
194+
process
195+
.verify_execution(consensus_version, VarunaVersion::V2, inclusion_version, execution)
196+
.map_or(Ok(false), |_| Ok(true))
187197
}

wasm/src/programs/macros.rs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,11 +59,14 @@ macro_rules! authorize {
5959

6060
log(&format!("Creating authorization for {program_id}:{function_name}"));
6161
if $unchecked {
62-
$process.authorize_unchecked::<CurrentAleo, _>($private_key, program.id(), function_name, $inputs.iter(), $rng).map_err(|err| err.to_string())?
62+
$process
63+
.authorize_unchecked::<CurrentAleo, _>($private_key, program.id(), function_name, $inputs.iter(), $rng)
64+
.map_err(|err| err.to_string())?
6365
} else {
64-
$process.authorize::<CurrentAleo, _>($private_key, program.id(), function_name, $inputs.iter(), $rng).map_err(|err| err.to_string())?
66+
$process
67+
.authorize::<CurrentAleo, _>($private_key, program.id(), function_name, $inputs.iter(), $rng)
68+
.map_err(|err| err.to_string())?
6569
}
66-
6770
}};
6871
}
6972

wasm/src/programs/manager/authorize.rs

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,15 @@ impl ProgramManager {
5959

6060
// Authorize the main program.
6161
let unchecked = false;
62-
let authorization =
63-
Authorization::from(authorize!(process, process_inputs!(inputs), program, function_name, private_key, rng, unchecked));
62+
let authorization = Authorization::from(authorize!(
63+
process,
64+
process_inputs!(inputs),
65+
program,
66+
function_name,
67+
private_key,
68+
rng,
69+
unchecked
70+
));
6471
Ok(authorization)
6572
}
6673

@@ -91,8 +98,15 @@ impl ProgramManager {
9198

9299
// Authorize the main program.
93100
let unchecked = true;
94-
let authorization =
95-
Authorization::from(authorize!(process, process_inputs!(inputs), program, function_name, private_key, rng, unchecked));
101+
let authorization = Authorization::from(authorize!(
102+
process,
103+
process_inputs!(inputs),
104+
program,
105+
function_name,
106+
private_key,
107+
rng,
108+
unchecked
109+
));
96110
Ok(authorization)
97111
}
98112

wasm/src/programs/manager/execute.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ use crate::{
4040
use snarkvm_algorithms::snark::varuna::VarunaVersion;
4141
use snarkvm_console::network::{ConsensusVersion, Network};
4242
use snarkvm_ledger_query::QueryTrait;
43-
use snarkvm_synthesizer::prelude::{cost_in_microcredits_v1, execution_cost_v1, execution_cost_v2, InclusionVersion};
43+
use snarkvm_synthesizer::prelude::{InclusionVersion, cost_in_microcredits_v1, execution_cost_v1, execution_cost_v2};
4444

4545
use core::ops::Add;
4646
use js_sys::{Array, Object};
@@ -229,7 +229,9 @@ impl ProgramManager {
229229
);
230230

231231
// Verify the execution
232-
process.verify_execution(ConsensusVersion::V8, VarunaVersion::V2, InclusionVersion::V1, &execution).map_err(|err| err.to_string())?;
232+
process
233+
.verify_execution(ConsensusVersion::V8, VarunaVersion::V2, InclusionVersion::V1, &execution)
234+
.map_err(|err| err.to_string())?;
233235

234236
log("Creating execution transaction");
235237
let transaction = TransactionNative::from_execution(execution, Some(fee)).map_err(|err| err.to_string())?;

wasm/src/programs/manager/join.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ use crate::{
3939
use snarkvm_algorithms::snark::varuna::VarunaVersion;
4040
use snarkvm_console::prelude::{ConsensusVersion, Network};
4141
use snarkvm_ledger_query::QueryTrait;
42-
use snarkvm_synthesizer::prelude::{execution_cost_v1, execution_cost_v2, InclusionVersion};
42+
use snarkvm_synthesizer::prelude::{InclusionVersion, execution_cost_v1, execution_cost_v2};
4343
use snarkvm_synthesizer_program::StackKeys;
4444

4545
use js_sys::Array;
@@ -134,7 +134,9 @@ impl ProgramManager {
134134
let execution_id = execution.to_execution_id().map_err(|e| e.to_string())?;
135135

136136
log("Verifying the join execution");
137-
process.verify_execution(ConsensusVersion::V8, VarunaVersion::V2, InclusionVersion::V1, &execution).map_err(|err| err.to_string())?;
137+
process
138+
.verify_execution(ConsensusVersion::V8, VarunaVersion::V2, InclusionVersion::V1, &execution)
139+
.map_err(|err| err.to_string())?;
138140

139141
// Calculate the minimum execution fee.
140142
log("Calculating the minimum execution fee");

wasm/src/programs/manager/split.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,9 @@ use crate::{
2929
use js_sys::Array;
3030
use rand::{SeedableRng, rngs::StdRng};
3131
use snarkvm_algorithms::snark::varuna::VarunaVersion;
32-
use std::{ops::Add, str::FromStr};
3332
use snarkvm_console::network::ConsensusVersion;
3433
use snarkvm_synthesizer::prelude::InclusionVersion;
34+
use std::{ops::Add, str::FromStr};
3535

3636
#[wasm_bindgen]
3737
impl ProgramManager {
@@ -99,7 +99,9 @@ impl ProgramManager {
9999
.map_err(|e| e.to_string())?;
100100

101101
log("Verifying the split execution");
102-
process.verify_execution(ConsensusVersion::V8, VarunaVersion::V2, InclusionVersion::V1, &execution).map_err(|err| err.to_string())?;
102+
process
103+
.verify_execution(ConsensusVersion::V8, VarunaVersion::V2, InclusionVersion::V1, &execution)
104+
.map_err(|err| err.to_string())?;
103105

104106
log("Creating execution transaction for split");
105107
let transaction = TransactionNative::from_execution(execution, None).map_err(|err| err.to_string())?;

wasm/src/programs/manager/transfer.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ use crate::{
3939
use snarkvm_algorithms::snark::varuna::VarunaVersion;
4040
use snarkvm_console::prelude::{ConsensusVersion, Network};
4141
use snarkvm_ledger_query::QueryTrait;
42-
use snarkvm_synthesizer::prelude::{execution_cost_v1, execution_cost_v2, InclusionVersion};
42+
use snarkvm_synthesizer::prelude::{InclusionVersion, execution_cost_v1, execution_cost_v2};
4343
use snarkvm_synthesizer_program::StackKeys;
4444

4545
use rand::{SeedableRng, rngs::StdRng};
@@ -191,7 +191,9 @@ impl ProgramManager {
191191
let execution_id = execution.to_execution_id().map_err(|e| e.to_string())?;
192192

193193
log("Verifying the transfer execution");
194-
process.verify_execution(ConsensusVersion::V8, VarunaVersion::V2, InclusionVersion::V1, &execution).map_err(|err| err.to_string())?;
194+
process
195+
.verify_execution(ConsensusVersion::V8, VarunaVersion::V2, InclusionVersion::V1, &execution)
196+
.map_err(|err| err.to_string())?;
195197

196198
// Calculate the minimum execution fee.
197199
log("Calculating the minimum execution fee");

wasm/src/record/record_plaintext.rs

Lines changed: 31 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -14,19 +14,30 @@
1414
// You should have received a copy of the GNU General Public License
1515
// along with the Provable SDK library. If not, see <https://www.gnu.org/licenses/>.
1616

17-
use crate::{Address, Credits, GraphKey, Plaintext, PrivateKey, js_array_from_fields, record_to_js_object, to_bits_array_le, types::{
18-
Field,
19-
Group,
20-
native::{
21-
CurrentNetwork,
22-
FieldNative,
23-
IdentifierNative,
24-
PlaintextEntryNative,
25-
PlaintextNative,
26-
ProgramIDNative,
27-
RecordPlaintextNative,
17+
use crate::{
18+
Address,
19+
Credits,
20+
GraphKey,
21+
Plaintext,
22+
PrivateKey,
23+
ViewKey,
24+
js_array_from_fields,
25+
record_to_js_object,
26+
to_bits_array_le,
27+
types::{
28+
Field,
29+
Group,
30+
native::{
31+
CurrentNetwork,
32+
FieldNative,
33+
IdentifierNative,
34+
PlaintextEntryNative,
35+
PlaintextNative,
36+
ProgramIDNative,
37+
RecordPlaintextNative,
38+
},
2839
},
29-
}, ViewKey};
40+
};
3041
use snarkvm_console::{
3142
prelude::{FromBytes, ToBits, ToBytes, ToFields},
3243
program::Owner,
@@ -374,8 +385,14 @@ mod tests {
374385
let record_name = "credits";
375386
let expected_sn = "8170619507075647151199239049653235187042661744691458644751012032123701508940field";
376387
let record_view_key = record.record_view_key(&vk);
377-
assert_eq!(expected_sn, record.serial_number_string(&pk, program_id, record_name, &record_view_key.to_string()).unwrap());
378-
assert_eq!(expected_sn, record.serial_number_string(&pk, program_id, record_name, &record_view_key.to_string()).unwrap());
388+
assert_eq!(
389+
expected_sn,
390+
record.serial_number_string(&pk, program_id, record_name, &record_view_key.to_string()).unwrap()
391+
);
392+
assert_eq!(
393+
expected_sn,
394+
record.serial_number_string(&pk, program_id, record_name, &record_view_key.to_string()).unwrap()
395+
);
379396
}
380397

381398
#[wasm_bindgen_test]

wasm/src/utilities/encrypt.rs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -138,10 +138,16 @@ impl EncryptionToolkit {
138138
}
139139

140140
// Return the decrypted record.
141-
let decrypted_record = if let Ok(record) = RecordPlaintextNative::from_plaintext(owner.clone(), decrypted_data.clone(), *record_native.nonce(), U8Native::new(0u8)) {
141+
let decrypted_record = if let Ok(record) = RecordPlaintextNative::from_plaintext(
142+
owner.clone(),
143+
decrypted_data.clone(),
144+
*record_native.nonce(),
145+
U8Native::new(0u8),
146+
) {
142147
record
143148
} else {
144-
RecordPlaintextNative::from_plaintext(owner, decrypted_data, *record_native.nonce(), U8Native::new(1u8)).map_err(|e| e.to_string())?
149+
RecordPlaintextNative::from_plaintext(owner, decrypted_data, *record_native.nonce(), U8Native::new(1u8))
150+
.map_err(|e| e.to_string())?
145151
};
146152

147153
Ok(RecordPlaintext::from(decrypted_record))

0 commit comments

Comments
 (0)