-
Notifications
You must be signed in to change notification settings - Fork 47
Add P2IDE note example #704
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: next
Are you sure you want to change the base?
Conversation
inputs: vec![ | ||
alice_account.id().prefix().as_felt(), | ||
alice_account.id().suffix(), | ||
timelock_height.into(), | ||
reclaim_height.into(), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
4 inputs to the note
examples/p2ide-note/src/lib.rs
Outdated
let inputs = note::get_inputs(); | ||
let target_account_id_prefix = inputs[0]; | ||
let target_account_id_suffix = inputs[1]; | ||
let timelock_height = inputs[2]; | ||
let reclaim_height = inputs[3]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note consumption fails when more than 2 inputs. If timelock_height
& reclaim_height
are commented out, note consumption works.
examples/p2ide-note/src/lib.rs
Outdated
// get block number | ||
let block_number = tx::get_block_number(); | ||
|
||
assert!(block_number >= timelock_height); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The reason for step 2 failure is this assert!
. The timelock_height
is 1000, but the test suite is bootstrapping the chain so the block_number
should be low digits. If you set timelock_height
to 1
this assert!
is passing. After that the test fails at step 5.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wish this was the issue. I updated the code to demonstrate that this is not the issue. The issue is that if you try to initialize more than 2 variables from note inputs:
let inputs = note::get_inputs();
let target_account_id_prefix = inputs[0];
let target_account_id_suffix = inputs[1];
let timelock_height = inputs[2]; // fails when uncommented
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, this fails on step 5. In this case send_asset_to_account
makes a note providing only 2 elements (account id) as note inputs. So there are only 2 elements in inputs
.
fn run(_arg: Word) { | ||
let inputs = note::get_inputs(); | ||
let target_account_id_prefix = inputs[0]; | ||
let target_account_id_suffix = inputs[1]; | ||
|
||
let timelock_height = inputs[2]; // fails when uncommented |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fails when trying to initialize more than 2 inputs.
This PR adds the P2IDE note as an example note.