[contracts] ContractInteractions wraps purchasing, sales and proving

This commit is contained in:
Mark Spanbroek 2022-04-13 13:18:38 +02:00 committed by markspanbroek
parent ce59dbd4a2
commit 9cbf6d0b6c
4 changed files with 61 additions and 0 deletions

View File

@ -4,6 +4,7 @@ import contracts/storage
import contracts/deployment
import contracts/market
import contracts/proofs
import contracts/interactions
export requests
export offers
@ -11,3 +12,4 @@ export storage
export deployment
export market
export proofs
export interactions

View File

@ -0,0 +1,35 @@
import pkg/ethers
import ../purchasing
import ../sales
import ../proving
import ./deployment
import ./storage
import ./market
import ./proofs
export purchasing
export sales
export proving
type
ContractInteractions* = ref object
purchasing*: Purchasing
sales*: Sales
proving*: Proving
proc new*(_: type ContractInteractions,
signer: Signer,
deployment: Deployment): ContractInteractions =
let contract = Storage.new(!deployment.address(Storage), signer)
let market = OnChainMarket.new(contract)
let proofs = OnChainProofs.new(contract)
ContractInteractions(
purchasing: Purchasing.new(market),
sales: Sales.new(market),
proving: Proving.new(proofs)
)
proc new*(_: type ContractInteractions): ContractInteractions =
let provider = JsonRpcProvider.new("ws://localhost:8545")
let signer = provider.getSigner()
ContractInteractions.new(signer, deployment())

View File

@ -0,0 +1,23 @@
import ./ethertest
import dagger/contracts
ethersuite "Storage Contract Interactions":
var contracts: ContractInteractions
setup:
contracts = ContractInteractions.new()
test "can be instantiated with a signer and deployment info":
let signer = provider.getSigner()
let deployment = deployment()
check ContractInteractions.new(signer, deployment) != nil
test "provides purchasing":
check contracts.purchasing != nil
test "provides sales":
check contracts.sales != nil
test "provides proving":
check contracts.proving != nil

View File

@ -2,5 +2,6 @@ import ./contracts/testCollateral
import ./contracts/testContracts
import ./contracts/testMarket
import ./contracts/testProofs
import ./contracts/testInteractions
{.warning[UnusedImport]:off.}