-
Notifications
You must be signed in to change notification settings - Fork 0
feat(payments): implement order abis #7
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
Conversation
|
i believe that same as in trade - only the Operator can submit trades I so think that also here only the Operator can cancel_orders so the check needs to be |
045a77a to
eff0739
Compare
MohammadNassar1
left a comment
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.
Reviewable status: 0 of 3 files reviewed, 1 unresolved discussion (waiting on @ishay-starkware)
src/payments.cairo line 101 at r1 (raw file):
Previously, ishay-starkware wrote…
i believe that same as in trade - only the Operator can submit trades I so think that also here only the Operator can cancel_orders so the check needs to be
only_operatorand not that thecaller == order.address
Done.
7d54df9 to
9f19b17
Compare
ishay-starkware
left a comment
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.
Reviewed 2 of 3 files at r1.
Reviewable status: 0 of 3 files reviewed, 1 unresolved discussion (waiting on @MohammadNassar1)
src/errors.cairo line 3 at r2 (raw file):
pub const INVALID_ZERO_ADDRESS: felt252 = 'INVALID_ZERO_ADDRESS'; pub const TOKEN_ALREADY_REGISTERED: felt252 = 'TOKEN_ALREADY_REGISTERED'; pub const TOKEN_NOT_REGISTERED: felt252 = 'TOKEN_NOT_REGISTERED';
not part of this pr
Code quote:
pub const INVALID_ZERO_ADDRESS: felt252 = 'INVALID_ZERO_ADDRESS';
pub const TOKEN_ALREADY_REGISTERED: felt252 = 'TOKEN_ALREADY_REGISTERED';
pub const TOKEN_NOT_REGISTERED: felt252 = 'TOKEN_NOT_REGISTERED';
MohammadNassar1
left a comment
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.
Reviewable status: 0 of 3 files reviewed, 1 unresolved discussion (waiting on @ishay-starkware and @MohammadNassar1)
src/errors.cairo line 3 at r2 (raw file):
Previously, ishay-starkware wrote…
not part of this pr
These were added in the previous PR.
Note that no change in this file.
ishay-starkware
left a comment
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.
Reviewed 2 of 3 files at r2.
Reviewable status: 2 of 3 files reviewed, 1 unresolved discussion (waiting on @MohammadNassar1)
src/payments.cairo line 124 at r2 (raw file):
// TODO(Mohammad): Replace with actual hash computation logic. let order_hash: HashType = Default::default(); self.fulfillment.write(order_hash, order.amount_a.abs());
change the value of the map to an Enum that has variants of Canceled, Fulfilled, Partial_Fulfilled, Not_Exist (default) and that can save amounts that was already fulfilled from the order
9f19b17 to
b2b201c
Compare
b2b201c to
d4b25f6
Compare
MohammadNassar1
left a comment
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.
Reviewable status: 0 of 4 files reviewed, 1 unresolved discussion (waiting on @ishay-starkware and @MohammadNassar1)
src/payments.cairo line 124 at r2 (raw file):
Previously, ishay-starkware wrote…
change the value of the map to an Enum that has variants of Canceled, Fulfilled, Partial_Fulfilled, Not_Exist (default) and that can save amounts that was already fulfilled from the order
Done.
ishay-starkware
left a comment
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.
Reviewable status: 0 of 4 files reviewed, 1 unresolved discussion (waiting on @MohammadNassar1)
src/interface.cairo line 9 at r3 (raw file):
PartialFulfilled: u128, Canceled: u128, Fulfilled,
i think we better keep this with the amount as well
ishay-starkware
left a comment
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.
Reviewed 4 of 4 files at r3, all commit messages.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @MohammadNassar1)
d687b8d to
f6a1c75
Compare
d4b25f6 to
8a1e3bb
Compare
MohammadNassar1
left a comment
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.
Reviewable status: 2 of 4 files reviewed, 1 unresolved discussion (waiting on @ishay-starkware)
src/interface.cairo line 9 at r3 (raw file):
Previously, ishay-starkware wrote…
i think we better keep this with the amount as well
Done.
|
we need to check if this enum size is only one felt |
RoeeGross
left a comment
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.
Reviewed all commit messages.
Reviewable status: 2 of 4 files reviewed, 2 unresolved discussions (waiting on @ishay-starkware and @MohammadNassar1)
|
let's keep it hash move the handle of sigle order to a private function also consider to create version with single order |
dd3f538 to
e741742
Compare
8a1e3bb to
0c63b19
Compare
MohammadNassar1
left a comment
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.
Reviewable status: 2 of 5 files reviewed, 3 unresolved discussions (waiting on @ishay-starkware and @RoeeGross)
src/payments.cairo line 147 at r4 (raw file):
Previously, RoeeGross wrote…
let's keep it hash
move the handle of sigle order to a private function
also consider to create version with single order
Done.
|
a point for the future we maybe need to cancel the approve also |
RoeeGross
left a comment
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.
Reviewed 2 of 4 files at r6.
Reviewable status: all files reviewed, 9 unresolved discussions (waiting on @ishay-starkware and @MohammadNassar1)
0c63b19 to
5351bfb
Compare
MohammadNassar1
left a comment
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.
Reviewable status: all files reviewed (commit messages unreviewed), 9 unresolved discussions (waiting on @ishay-starkware and @RoeeGross)
src/interface.cairo line 10 at r6 (raw file):
Previously, RoeeGross wrote…
why do we need u128 in case of Canceld?
what is mean?
please add some docs
(As I understand now, the u128 means the consume amount and in the case of Fulfilled
you can ignore it
It shows the amount that was fulfilled before the order was canceled.
src/payments.cairo line 212 at r6 (raw file):
Previously, RoeeGross wrote…
a point for the future we maybe need to cancel the approve also
Now the approval is not part of the contract.
src/tests/test_payments.cairo line 151 at r6 (raw file):
Previously, RoeeGross wrote…
array
wdym? :)
The hash is felt252.
src/tests/test_payments.cairo line 155 at r6 (raw file):
Previously, RoeeGross wrote…
loop and also check the order_hash_3
Done.
src/tests/test_payments.cairo line 168 at r6 (raw file):
Previously, RoeeGross wrote…
you can also need to chech the case of cancel partial full...
you can do that by edit the storage
Correct, but partial fulfillment requires a flow test that involves trade. It will be done once the trade is merged.
src/tests/test_payments.cairo line 171 at r6 (raw file):
Previously, RoeeGross wrote…
loop
Done.
src/tests/test_payments.cairo line 184 at r6 (raw file):
Previously, RoeeGross wrote…
add before this line chect call adrees with the adrres 'non operator'
so the test will be more explicity
Done.
|
Previously, MohammadNassar1 (mohammad-starkware) wrote…
Okay, so let's remove the u128 from Fulfilled |
|
Previously, MohammadNassar1 (mohammad-starkware) wrote…
But we need to clear the approval. |
|
Previously, MohammadNassar1 (mohammad-starkware) wrote…
create array of felt252 and instead of |
|
Previously, MohammadNassar1 (mohammad-starkware) wrote…
you can test it without the trade flow |
RoeeGross
left a comment
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.
Reviewed 1 of 2 files at r8.
Reviewable status: 4 of 5 files reviewed, 6 unresolved discussions (waiting on @ishay-starkware and @MohammadNassar1)
5351bfb to
d18b1cf
Compare
MohammadNassar1
left a comment
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.
Reviewable status: 4 of 5 files reviewed, 6 unresolved discussions (waiting on @ishay-starkware and @RoeeGross)
src/interface.cairo line 10 at r6 (raw file):
Previously, RoeeGross wrote…
Okay, so let's remove the u128 from Fulfilled
or remove the Fulfilled variant
@ishay-starkware requested here to keep the u128 for fulfilled.
src/payments.cairo line 212 at r6 (raw file):
Previously, RoeeGross wrote…
But we need to clear the approval.
Hmm, why should this be part of the contract?
Since approval itself isn’t part of the contract, I’d expect the approval clearing to also be handled outside of it.
wdyt?
src/tests/test_payments.cairo line 151 at r6 (raw file):
Previously, RoeeGross wrote…
create array of felt252 and instead of
oreder_hash_i
you got
order_hash[i]
Done.
src/tests/test_payments.cairo line 168 at r6 (raw file):
Previously, RoeeGross wrote…
you can test it without the trade flow
just wdit the storage and set it to be cancel
Done.
|
Previously, MohammadNassar1 (mohammad-starkware) wrote…
It's not part of the contract but we cancel some order so it's make sense to clear every 'resources' |
|
Previously, MohammadNassar1 (mohammad-starkware) wrote…
not done.... |
RoeeGross
left a comment
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.
Reviewed 2 of 2 files at r9, all commit messages.
Reviewable status: all files reviewed, 4 unresolved discussions (waiting on @ishay-starkware, @MohammadNassar1, and @remollemo)
d18b1cf to
cca51ba
Compare
MohammadNassar1
left a comment
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.
Reviewable status: 4 of 5 files reviewed, 4 unresolved discussions (waiting on @ishay-starkware, @remollemo, and @RoeeGross)
src/interface.cairo line 5 at r4 (raw file):
Previously, RoeeGross wrote…
we need to check if this enum size is only one felt
I see that the enum is using 2 felts.
I see it when using store/load, it returns an array of 2 felts. one felt for the enum, and other for the amount.
src/payments.cairo line 212 at r6 (raw file):
Previously, RoeeGross wrote…
It's not part of the contract but we cancel some order so it's make sense to clear every 'resources'
but I suggest to ask @remollemo
Will discuss it with @remollemo.
src/tests/test_payments.cairo line 151 at r6 (raw file):
Previously, RoeeGross wrote…
not done....
Changed to an array,
Please note that at method returns reference, so I had to add deref when using the values.
|
Previously, MohammadNassar1 (mohammad-starkware) wrote…
#[test] |
RoeeGross
left a comment
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.
Reviewable status: 4 of 5 files reviewed, 4 unresolved discussions (waiting on @ishay-starkware, @MohammadNassar1, and @remollemo)
src/interface.cairo line 5 at r4 (raw file):
Previously, MohammadNassar1 (mohammad-starkware) wrote…
I see that the enum is using 2 felts.
I see it when using store/load, it returns an array of 2 felts. one felt for the enum, and other for the amount.
so, we need to add store packing
cca51ba to
9dfc9e2
Compare
MohammadNassar1
left a comment
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.
Reviewable status: 4 of 5 files reviewed, 4 unresolved discussions (waiting on @ishay-starkware, @remollemo, and @RoeeGross)
src/tests/test_payments.cairo line 151 at r6 (raw file):
Previously, RoeeGross wrote…
#[test]
fn test_successful_handle_order() {
let contract_address = init_contract_with_roles();
let dispatcher = IPaymentsDispatcher { contract_address };
let order_hashes = array!['order_hash_1', 'order_hash_2', 'order_hash_3'];for order_hash in order_hashes.span() { assert_eq!( dispatcher.get_order_fulfillment(*order_hash), FulfilledStatus::PartialFulfilled(0), ); } cheat_caller_address_once(:contract_address, caller_address: testing_constants::OPERATOR); dispatcher.cancel_orders(order_hashes: array![*(order_hashes[0])].span()); assert_eq!(dispatcher.get_order_fulfillment(*(order_hashes[0])), FulfilledStatus::Canceled(0)); for order_hash in order_hashes.span().slice(1, 2) { assert_eq!( dispatcher.get_order_fulfillment(*order_hash), FulfilledStatus::PartialFulfilled(0), ); }
Done.
RoeeGross
left a comment
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.
Reviewed 1 of 1 files at r11.
Reviewable status: all files reviewed (commit messages unreviewed), 2 unresolved discussions (waiting on @ishay-starkware and @MohammadNassar1)
|
Previously, RoeeGross wrote…
Please use store packing for each "starknet::Store" if you can |
RoeeGross
left a comment
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.
Reviewed 1 of 4 files at r3, 2 of 4 files at r6, 1 of 1 files at r11, all commit messages.
Reviewable status: all files reviewed, 2 unresolved discussions (waiting on @ishay-starkware and @MohammadNassar1)
RoeeGross
left a comment
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.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @ishay-starkware)
RoeeGross
left a comment
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.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @ishay-starkware)
Gross has approved the PR.
MohammadNassar1
left a comment
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.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @ishay-starkware)
src/interface.cairo line 5 at r4 (raw file):
Previously, RoeeGross wrote…
Please use store packing for each "starknet::Store" if you can
Let's do it in a separate PR.
This change is