From e52153e2ba0bd1532a35827fd7cef51a5b06d410 Mon Sep 17 00:00:00 2001 From: Mark Spanbroek Date: Mon, 28 Mar 2022 17:28:51 +0200 Subject: [PATCH] [market] Require a storage contract with a signer --- dagger/contracts/market.nim | 5 ++++- tests/contracts/testMarket.nim | 5 +++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/dagger/contracts/market.nim b/dagger/contracts/market.nim index c93c0ec9..175e3cf6 100644 --- a/dagger/contracts/market.nim +++ b/dagger/contracts/market.nim @@ -1,5 +1,6 @@ import pkg/ethers import pkg/upraises +import pkg/questionable import ../market import ./storage @@ -15,7 +16,9 @@ type export market func new*(_: type OnChainMarket, contract: Storage): OnChainMarket = - OnChainMarket(contract: contract, signer: !contract.signer) + without signer =? contract.signer: + raiseAssert("Storage contract should have a signer") + OnChainMarket(contract: contract, signer: signer) method subscribeRequests(market: OnChainMarket, callback: OnRequest): diff --git a/tests/contracts/testMarket.nim b/tests/contracts/testMarket.nim index 8567e06f..6bc29399 100644 --- a/tests/contracts/testMarket.nim +++ b/tests/contracts/testMarket.nim @@ -16,6 +16,11 @@ ethersuite "On-Chain Market": await token.mint(accounts[0], 1000.u256) market = OnChainMarket.new(storage) + test "fails to instantiate when contract does not have a signer": + let storageWithoutSigner = storage.connect(provider) + expect AssertionError: + discard OnChainMarket.new(storageWithoutSigner) + test "supports storage requests": var submitted: seq[StorageRequest] proc onRequest(request: StorageRequest) =