Skip to content

Commit

Permalink
Merge pull request #3 from ligolang/fix/tests
Browse files Browse the repository at this point in the history
Fix tests
  • Loading branch information
melwyn95 authored Dec 6, 2022
2 parents 794155e + 6a1fc2b commit dacdf4f
Show file tree
Hide file tree
Showing 9 changed files with 53 additions and 14 deletions.
3 changes: 3 additions & 0 deletions esy.lock/.gitattributes

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions esy.lock/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

33 changes: 33 additions & 0 deletions esy.lock/index.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "@ligo/permit",
"version": "1.0.0",
"dependencies": {
"ligo-generic-fa2": "^1.0.2"
"ligo-extendable-fa2": "^1.0.2"
},
"repository": {
"type": "git",
Expand Down
6 changes: 3 additions & 3 deletions src/main.mligo
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#import "ligo-generic-fa2/lib/multi_asset/fa2.mligo" "FA2"
#import "ligo-extendable-fa2/lib/multi_asset/fa2.mligo" "FA2"
#import "./constants.mligo" "Constants"
#import "./storage.mligo" "Storage"
#import "./extension.mligo" "Extension"
Expand Down Expand Up @@ -109,7 +109,7 @@ let transfer_permitted (transfer:FA2.transfer) (s: storage) =
let transfer_from_hash = Crypto.blake2b (Bytes.pack transfer_from) in
let permit_key : Extension.permit_key = (transfer_from.from_, transfer_from_hash) in
let (is_transfer_authorized, ext) = Extension.transfer_presigned ext permit_key in
let {from_; tx} = transfer_from in
let {from_; txs} = transfer_from in
let ledger = List.fold
(fun (ledger, dst : FA2.Ledger.t * FA2.atomic_trans) ->
let {token_id; amount; to_} = dst in
Expand All @@ -120,7 +120,7 @@ let transfer_permitted (transfer:FA2.transfer) (s: storage) =
let ledger = FA2.Ledger.decrease_token_amount_for_user ledger from_ token_id amount in
let ledger = FA2.Ledger.increase_token_amount_for_user ledger to_ token_id amount in
ledger
) tx ledger in
) txs ledger in
(ledger, ext)
in
let (new_ledger, new_ext) = List.fold make_transfer transfer (s.ledger, s.extension)
Expand Down
2 changes: 1 addition & 1 deletion src/storage.mligo
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#import "ligo-generic-fa2/lib/multi_asset/fa2.mligo" "FA2"
#import "ligo-extendable-fa2/lib/multi_asset/fa2.mligo" "FA2"
#import "./errors.mligo" "Errors"
#import "./extension.mligo" "Extension"

Expand Down
2 changes: 1 addition & 1 deletion src/token_total_supply.mligo
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#import "ligo-generic-fa2/lib/multi_asset/fa2.mligo" "FA2"
#import "ligo-extendable-fa2/lib/multi_asset/fa2.mligo" "FA2"

(* token_id -> total_supply *)
type t = (FA2.Ledger.token_id, nat) big_map
Expand Down
10 changes: 5 additions & 5 deletions test/permit.test.mligo
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ let test_success_add_permit_one =
let (owner1_addr, _, _) = owner1 in
let (owner2_addr, _, _) = owner2 in
let transfer_requests = ([
({from_=owner1_addr; tx=([{to_=owner2_addr;amount=2n;token_id=1n}] : Token.FA2.atomic_trans list)});
({from_=owner1_addr; txs=([{to_=owner2_addr;amount=2n;token_id=1n}] : Token.FA2.atomic_trans list)});
] : Token.FA2.transfer) in
let hash_ = Crypto.blake2b (Bytes.pack transfer_requests) in
let permit = Token_helper.make_permit(hash_, owner1, tok.addr, 0n) in
Expand All @@ -36,12 +36,12 @@ let test_success_add_permit_list =
let (owner1_addr, _, _) = owner1 in
let (owner2_addr, _, _) = owner2 in
let transfer_requests = ([
({from_=owner1_addr; tx=([{to_=owner2_addr;amount=2n;token_id=1n}] : Token.FA2.atomic_trans list)});
({from_=owner1_addr; txs=([{to_=owner2_addr;amount=2n;token_id=1n}] : Token.FA2.atomic_trans list)});
] : Token.FA2.transfer) in
let hash_ = Crypto.blake2b (Bytes.pack transfer_requests) in
let permit1 = Token_helper.make_permit(hash_, owner1, tok.addr, 0n) in
let transfer_requests = ([
({from_=owner2_addr; tx=([{to_=owner1_addr;amount=2n;token_id=1n}] : Token.FA2.atomic_trans list)});
({from_=owner2_addr; txs=([{to_=owner1_addr;amount=2n;token_id=1n}] : Token.FA2.atomic_trans list)});
] : Token.FA2.transfer) in
let hash_ = Crypto.blake2b (Bytes.pack transfer_requests) in
let permit2 = Token_helper.make_permit(hash_, owner2, tok.addr, 1n) in
Expand All @@ -62,7 +62,7 @@ let test_success_update_permit =
let (owner2_addr, _, _) = owner2 in

let transfer_requests = ([
({from_=owner1_addr; tx=([{to_=owner2_addr;amount=2n;token_id=1n}] : Token.FA2.atomic_trans list)});
({from_=owner1_addr; txs=([{to_=owner2_addr;amount=2n;token_id=1n}] : Token.FA2.atomic_trans list)});
] : Token.FA2.transfer) in
let hash_ = Crypto.blake2b (Bytes.pack transfer_requests) in

Expand All @@ -84,7 +84,7 @@ let test_success_update_permit =
let (owner1_addr, _, _) = owner1 in
let (owner2_addr, _, _) = owner2 in
let transfer_requests = ([
({from_=owner1_addr; tx=([{to_=owner2_addr;amount=2n;token_id=1n}] : Token.FA2.atomic_trans list)});
({from_=owner1_addr; txs=([{to_=owner2_addr;amount=2n;token_id=1n}] : Token.FA2.atomic_trans list)});
] : Token.FA2.transfer) in
let hash_ = Crypto.blake2b (Bytes.pack transfer_requests) in
let permit = Token_helper.make_permit(hash_, owner1, tok.addr, 0n) in
Expand Down
6 changes: 3 additions & 3 deletions test/transfer.test.mligo
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ let test_success =
let (owner2_addr, _, _) = owner2 in
let transfer_request = ({
from_=owner1_addr;
tx=([{to_=owner2_addr;amount=2n;token_id=1n}] : Token.FA2.atomic_trans list)
txs=([{to_=owner2_addr;amount=2n;token_id=1n}] : Token.FA2.atomic_trans list)
}) in
let hash_ = Crypto.blake2b (Bytes.pack transfer_request) in
let permit = Token_helper.make_permit(hash_, owner1, tok.addr, 0n) in
Expand All @@ -49,7 +49,7 @@ let test_success_by_operator_with_expired_permit =

let transfer_request = ({
from_=owner1_addr;
tx=([{to_=owner2_addr;amount=2n;token_id=1n}] : Token.FA2.atomic_trans list)
txs=([{to_=owner2_addr;amount=2n;token_id=1n}] : Token.FA2.atomic_trans list)
}) in
let hash_ = Crypto.blake2b (Bytes.pack transfer_request) in

Expand Down Expand Up @@ -80,7 +80,7 @@ let test_failure_expired_permit =

let transfer_request = ({
from_=owner1_addr;
tx=([{to_=owner2_addr;amount=2n;token_id=1n}] : Token.FA2.atomic_trans list)
txs=([{to_=owner2_addr;amount=2n;token_id=1n}] : Token.FA2.atomic_trans list)
}) in
let hash_ = Crypto.blake2b (Bytes.pack transfer_request) in

Expand Down

0 comments on commit dacdf4f

Please sign in to comment.