Skip to content

Commit

Permalink
Merge pull request #61 from argentlabs/more-restrictions-on-validation
Browse files Browse the repository at this point in the history
More restrictions on validation
  • Loading branch information
sgc-code authored Jul 5, 2024
2 parents da52dcf + 95850fb commit 20e0348
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
8 changes: 4 additions & 4 deletions gas-report.txt
Original file line number Diff line number Diff line change
Expand Up @@ -32,19 +32,19 @@ Resources:
│ Transfer ETH (FeeToken: WEI) │ 0 │ 3 │ 0 │ 0 │ 25 │ 0 │ 181 │ 8184 │
│ Transfer STRK (FeeToken: WEI) │ 0 │ 3 │ 0 │ 0 │ 25 │ 0 │ 181 │ 8184 │
│ Gifting WEI (FeeToken: WEI) │ 0 │ 3 │ 0 │ 0 │ 48 │ 0 │ 339 │ 14624 │
│ Claiming WEI (FeeToken: WEI) │ 0 │ 3 │ 0 │ 0 │ 47 │ 0 │ 373 │ 11715
│ Claiming WEI (FeeToken: WEI) │ 0 │ 3 │ 0 │ 0 │ 47 │ 0 │ 373 │ 11725
│ Claiming external WEI (FeeToken: WEI) │ 0 │ 6 │ 0 │ 0 │ 52 │ 4 │ 477 │ 16713 │
│ Get dust WEI (FeeToken: WEI) │ 0 │ 3 │ 0 │ 0 │ 49 │ 0 │ 480 │ 16585 │
│ Gifting WEI (FeeToken: FRI) │ 0 │ 3 │ 0 │ 0 │ 64 │ 0 │ 465 │ 20607 │
│ Claiming WEI (FeeToken: FRI) │ 0 │ 3 │ 0 │ 0 │ 47 │ 0 │ 407 │ 11913
│ Claiming WEI (FeeToken: FRI) │ 0 │ 3 │ 0 │ 0 │ 47 │ 0 │ 407 │ 11923
│ Claiming external WEI (FeeToken: FRI) │ 0 │ 6 │ 0 │ 0 │ 52 │ 4 │ 477 │ 16713 │
│ Get dust WEI (FeeToken: FRI) │ 0 │ 3 │ 0 │ 0 │ 50 │ 0 │ 514 │ 17757 │
│ Gifting FRI (FeeToken: WEI) │ 0 │ 3 │ 0 │ 0 │ 64 │ 0 │ 465 │ 20606 │
│ Claiming FRI (FeeToken: WEI) │ 0 │ 3 │ 0 │ 0 │ 47 │ 0 │ 373 │ 11715
│ Claiming FRI (FeeToken: WEI) │ 0 │ 3 │ 0 │ 0 │ 47 │ 0 │ 373 │ 11725
│ Claiming external FRI (FeeToken: WEI) │ 0 │ 6 │ 0 │ 0 │ 52 │ 4 │ 477 │ 16713 │
│ Get dust FRI (FeeToken: WEI) │ 0 │ 3 │ 0 │ 0 │ 50 │ 0 │ 514 │ 17757 │
│ Gifting FRI (FeeToken: FRI) │ 0 │ 3 │ 0 │ 0 │ 48 │ 0 │ 339 │ 14625 │
│ Claiming FRI (FeeToken: FRI) │ 0 │ 3 │ 0 │ 0 │ 47 │ 0 │ 407 │ 11913
│ Claiming FRI (FeeToken: FRI) │ 0 │ 3 │ 0 │ 0 │ 47 │ 0 │ 407 │ 11923
│ Claiming external FRI (FeeToken: FRI) │ 0 │ 6 │ 0 │ 0 │ 52 │ 4 │ 477 │ 16713 │
│ Get dust FRI (FeeToken: FRI) │ 0 │ 3 │ 0 │ 0 │ 49 │ 0 │ 480 │ 16585 │
│ Get dust 2 (FeeToken: WEI) │ 0 │ 3 │ 0 │ 0 │ 83 │ 0 │ 856 │ 28376 │
Expand Down
7 changes: 6 additions & 1 deletion src/contracts/escrow_account.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -77,14 +77,19 @@ mod EscrowAccount {
fn __validate__(ref self: ContractState, calls: Array<Call>) -> felt252 {
let execution_info = get_execution_info().unbox();
assert(execution_info.caller_address.is_zero(), 'escrow/only-protocol');
let tx_info = execution_info.tx_info.unbox();
// When paymaster is implemented on starknet it might break the logic in this method
assert(tx_info.paymaster_data.is_empty(), 'escrow/unsupported-paymaster');
// No need to allow deployment
assert(tx_info.account_deployment_data.is_empty(), 'escrow/invalid-deployment-data');

assert(calls.len() == 1, 'escrow/invalid-call-len');
let Call { to, selector, calldata } = calls.at(0);
assert(*to == get_contract_address(), 'escrow/invalid-call-to');
assert(*selector == selector!("claim_internal"), 'escrow/invalid-call-selector');
let (gift, _): (GiftData, ContractAddress) = full_deserialize(*calldata).expect('escrow/invalid-calldata');
assert_valid_claim(gift);

let tx_info = execution_info.tx_info.unbox();
assert(tx_info.nonce == 0, 'escrow/invalid-gift-nonce');
let execution_hash = tx_info.transaction_hash;
let signature = tx_info.signature;
Expand Down

0 comments on commit 20e0348

Please sign in to comment.