Skip to content

Commit

Permalink
Merge pull request #4 from marigold-dev/cc@workaround_for_bugs_of_ligo
Browse files Browse the repository at this point in the history
workaround for bugs of ligo
  • Loading branch information
xvw authored Nov 30, 2022
2 parents 213dab7 + 1a12b6f commit 2b3160d
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 12 deletions.
5 changes: 2 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
.PHONY: test test-list-ext

LIGO_COMPILER_VERSION:=0.49.0
TEZOS_PROTOCOL:=jakarta
LIGO_COMPILER_VERSION:=0.55.0
LIGO_DOCKER := docker run --rm -v $(PWD):$(PWD) -w $(PWD) ligolang/ligo:$(LIGO_COMPILER_VERSION)

define test_ligo
$(LIGO_DOCKER) run test $(1) --protocol $(TEZOS_PROTOCOL)
$(LIGO_DOCKER) run test $(1)
endef

test: test-list-ext test-auction test-ticket-factory
Expand Down
7 changes: 4 additions & 3 deletions examples/ticket_factory/src/mint_sc.mligo
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ type applied = operation list * storage
let tez_to_nat (xtz: tez) : nat = xtz / 1mutez
let nat_to_tez (x: nat) : tez = x * 1mutez

let create_new_ticket (storage: storage) (qty: tez) : bytes ticket =
let create_new_ticket (storage: storage) (qty: tez) : bytes ticket option =
if qty < storage.minimal_amount then failwith "mint_sc: amount too low"
else
let qty_nat = tez_to_nat qty in
Expand All @@ -40,8 +40,9 @@ let process_mint
(storage: storage)
(callback: bytes ticket contract)
(qty: tez) : operation =
let fresh_ticket = create_new_ticket storage qty in
Tezos.transaction fresh_ticket 0tez callback
match create_new_ticket storage qty with
| Some fresh_ticket -> Tezos.transaction fresh_ticket 0tez callback
| None -> failwith "Ticket creation failure"

let process_redeem
(storage: storage)
Expand Down
21 changes: 16 additions & 5 deletions lib/contract.mligo
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,10 @@ let originate
(main: (a * b -> (operation list * b)))
(storage: b)
(quantity: tez) : (a, b) originated =
let typed_address, _, _ = Test.originate main storage quantity in
let address = Test.originate_contract (Test.compile_contract main) (Test.eval storage) quantity in
let typed_address = Test.cast_address address in
let contract = Test.to_contract typed_address in
let address = Tezos.address contract in

let () =
Logger.log level ("originated smart contract", name, address, storage, quantity)
in
Expand All @@ -50,16 +51,26 @@ let originate
; originated_address = address }


(** [transfert_to contract entrypoint amount] will transfert amount to an originated SC. *)
(** [transfert_to contract parameter amount] will transfert amount to an originated SC. *)
let transfert_to
(type a b)
(originated: (a, b) originated)
(entrypoint: a)
(parameter: a)
(fund: tez) : Result.result =
let contract = originated.originated_contract in
Result.try_with
(fun () -> Test.transfer_to_contract contract entrypoint fund)
(fun () -> Test.transfer_to_contract contract parameter fund)

(** [transfert_with_entrypoint_to contract entrypoint parameter amount] will transfert amount to an originated SC. *)
let transfert_with_entrypoint_to
(type a b c)
(originated: (a, b) originated)
(entrypoint: string)
(parameter: c)
(fund: tez) : Result.result =
let contract = Test.to_entrypoint entrypoint originated.originated_typed_address in
Result.try_with
(fun () -> Test.transfer_to_contract contract parameter fund)

(** [storage_of originated_contract] will retreive the storage of an originated smart-contract. *)
let storage_of
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"type": "git",
"url": "git+https://github.com/marigold-dev/breathalyzer.git"
},
"version": "1.0.0",
"version": "1.2.0",
"author": "Marigold <[email protected]>",
"license": "MIT",
"scripts": {
Expand Down

0 comments on commit 2b3160d

Please sign in to comment.