From 6a1fc2b5755df029a726d51076c96ea6dee02890 Mon Sep 17 00:00:00 2001 From: Melwyn Saldanha Date: Tue, 6 Dec 2022 16:16:28 +0530 Subject: [PATCH] Fix tests --- esy.lock/.gitattributes | 3 +++ esy.lock/.gitignore | 3 +++ esy.lock/index.json | 33 +++++++++++++++++++++++++++++++++ package.json | 2 +- src/main.mligo | 6 +++--- src/storage.mligo | 2 +- src/token_total_supply.mligo | 2 +- test/permit.test.mligo | 10 +++++----- test/transfer.test.mligo | 6 +++--- 9 files changed, 53 insertions(+), 14 deletions(-) create mode 100644 esy.lock/.gitattributes create mode 100644 esy.lock/.gitignore create mode 100644 esy.lock/index.json diff --git a/esy.lock/.gitattributes b/esy.lock/.gitattributes new file mode 100644 index 0000000..e0b4e26 --- /dev/null +++ b/esy.lock/.gitattributes @@ -0,0 +1,3 @@ + +# Set eol to LF so files aren't converted to CRLF-eol on Windows. +* text eol=lf linguist-generated diff --git a/esy.lock/.gitignore b/esy.lock/.gitignore new file mode 100644 index 0000000..a221be2 --- /dev/null +++ b/esy.lock/.gitignore @@ -0,0 +1,3 @@ + +# Reset any possible .gitignore, we want all esy.lock to be un-ignored. +!* diff --git a/esy.lock/index.json b/esy.lock/index.json new file mode 100644 index 0000000..7ac65d9 --- /dev/null +++ b/esy.lock/index.json @@ -0,0 +1,33 @@ +{ + "checksum": "b6ec0762b9fbc17b4750f8185d0f4188", + "root": "@ligo/permit@link-dev:./package.json", + "node": { + "ligo-extendable-fa2@1.0.4@d41d8cd9": { + "id": "ligo-extendable-fa2@1.0.4@d41d8cd9", + "name": "ligo-extendable-fa2", + "version": "1.0.4", + "source": { + "type": "install", + "source": [ + "archive:https://packages.ligolang.org/-/api/ligo-extendable-fa2/-/ligo-extendable-fa2-1.0.4.tgz#sha1:e8e94c317cfcb84737301837c725828279d9b782" + ] + }, + "overrides": [], + "dependencies": [], + "devDependencies": [] + }, + "@ligo/permit@link-dev:./package.json": { + "id": "@ligo/permit@link-dev:./package.json", + "name": "@ligo/permit", + "version": "link-dev:./package.json", + "source": { + "type": "link-dev", + "path": ".", + "manifest": "package.json" + }, + "overrides": [], + "dependencies": [ "ligo-extendable-fa2@1.0.4@d41d8cd9" ], + "devDependencies": [] + } + } +} \ No newline at end of file diff --git a/package.json b/package.json index 36c9a28..f3422c8 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/src/main.mligo b/src/main.mligo index 2cf1fe8..f4f4fe7 100644 --- a/src/main.mligo +++ b/src/main.mligo @@ -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" @@ -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 @@ -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) diff --git a/src/storage.mligo b/src/storage.mligo index 35e5ac2..e2258ae 100644 --- a/src/storage.mligo +++ b/src/storage.mligo @@ -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" diff --git a/src/token_total_supply.mligo b/src/token_total_supply.mligo index cebdad8..b79afe8 100644 --- a/src/token_total_supply.mligo +++ b/src/token_total_supply.mligo @@ -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 diff --git a/test/permit.test.mligo b/test/permit.test.mligo index 4138b8b..83e7f3a 100644 --- a/test/permit.test.mligo +++ b/test/permit.test.mligo @@ -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 @@ -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 @@ -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 @@ -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 diff --git a/test/transfer.test.mligo b/test/transfer.test.mligo index 752ca1a..3e32b01 100644 --- a/test/transfer.test.mligo +++ b/test/transfer.test.mligo @@ -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 @@ -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 @@ -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