diff --git a/codex/conf.nim b/codex/conf.nim index 38a24b7f..9ac7a7fc 100644 --- a/codex/conf.nim +++ b/codex/conf.nim @@ -295,10 +295,8 @@ type payoutAddress* {. desc: "Address to send reward payouts to" - defaultValue: EthAddress.none - defaultValueDesc: "Rewards will be sent to the SP's address (derived from --eth-private-key)" name: "payout-address" - .}: Option[EthAddress] + .}: EthAddress case persistenceCmd* {. defaultValue: noCmd diff --git a/codex/contracts/market.nim b/codex/contracts/market.nim index 513ef207..2420d44b 100644 --- a/codex/contracts/market.nim +++ b/codex/contracts/market.nim @@ -19,7 +19,7 @@ type OnChainMarket* = ref object of Market contract: Marketplace signer: Signer - payoutAddress: ?Address + payoutAddress: Address MarketSubscription = market.Subscription EventSubscription = ethers.Subscription OnChainMarketSubscription = ref object of MarketSubscription @@ -28,7 +28,7 @@ type func new*( _: type OnChainMarket, contract: Marketplace, - payoutAddress = Address.none): OnChainMarket = + payoutAddress: Address): OnChainMarket = without signer =? contract.signer: raiseAssert("Marketplace contract should have a signer") @@ -167,12 +167,9 @@ method fillSlot(market: OnChainMarket, convertEthersError: await market.approveFunds(collateral) - var fillSlot: Future[?TransactionResponse] - if payoutAddress =? market.payoutAddress: - fillSlot = market.contract.fillSlot(requestId, slotIndex, proof, payoutAddress) - else: - fillSlot = market.contract.fillSlot(requestId, slotIndex, proof) - discard await fillSlot.confirm(0) + discard await market.contract.fillSlot( + requestId, slotIndex, proof, market.payoutAddress + ).confirm(0) method freeSlot*(market: OnChainMarket, slotId: SlotId) {.async.} = convertEthersError: diff --git a/codex/contracts/marketplace.nim b/codex/contracts/marketplace.nim index 6f4a2e7e..400981cb 100644 --- a/codex/contracts/marketplace.nim +++ b/codex/contracts/marketplace.nim @@ -43,7 +43,6 @@ proc slashPercentage*(marketplace: Marketplace): UInt256 {.contract, view.} proc minCollateralThreshold*(marketplace: Marketplace): UInt256 {.contract, view.} proc requestStorage*(marketplace: Marketplace, request: StorageRequest): ?TransactionResponse {.contract.} -proc fillSlot*(marketplace: Marketplace, requestId: RequestId, slotIndex: UInt256, proof: Groth16Proof): ?TransactionResponse {.contract.} proc fillSlot*(marketplace: Marketplace, requestId: RequestId, slotIndex: UInt256, proof: Groth16Proof, payoutAddress: Address): ?TransactionResponse {.contract.} proc withdrawFunds*(marketplace: Marketplace, requestId: RequestId): ?TransactionResponse {.contract.} proc freeSlot*(marketplace: Marketplace, id: SlotId): ?TransactionResponse {.contract.} diff --git a/tests/contracts/testContracts.nim b/tests/contracts/testContracts.nim index 4432160d..5d3a5790 100644 --- a/tests/contracts/testContracts.nim +++ b/tests/contracts/testContracts.nim @@ -11,6 +11,7 @@ ethersuite "Marketplace contracts": let proof = Groth16Proof.example var client, host: Signer + var payoutAddress: Address var marketplace: Marketplace var token: Erc20Token var periodicity: Periodicity @@ -24,6 +25,7 @@ ethersuite "Marketplace contracts": setup: client = ethProvider.getSigner(accounts[0]) host = ethProvider.getSigner(accounts[1]) + payoutAddress = accounts[2] let address = Marketplace.address(dummyVerifier = true) marketplace = Marketplace.new(address, ethProvider.getSigner()) @@ -42,7 +44,7 @@ ethersuite "Marketplace contracts": discard await marketplace.requestStorage(request) switchAccount(host) discard await token.approve(marketplace.address, request.ask.collateral) - discard await marketplace.fillSlot(request.id, 0.u256, proof) + discard await marketplace.fillSlot(request.id, 0.u256, proof, payoutAddress) slotId = request.slotId(0.u256) proc waitUntilProofRequired(slotId: SlotId) {.async.} = @@ -57,7 +59,7 @@ ethersuite "Marketplace contracts": proc startContract() {.async.} = for slotIndex in 1..