[contracts] ContractInteractions wraps purchasing, sales and proving
This commit is contained in:
parent
ce59dbd4a2
commit
9cbf6d0b6c
|
@ -4,6 +4,7 @@ import contracts/storage
|
||||||
import contracts/deployment
|
import contracts/deployment
|
||||||
import contracts/market
|
import contracts/market
|
||||||
import contracts/proofs
|
import contracts/proofs
|
||||||
|
import contracts/interactions
|
||||||
|
|
||||||
export requests
|
export requests
|
||||||
export offers
|
export offers
|
||||||
|
@ -11,3 +12,4 @@ export storage
|
||||||
export deployment
|
export deployment
|
||||||
export market
|
export market
|
||||||
export proofs
|
export proofs
|
||||||
|
export interactions
|
||||||
|
|
|
@ -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())
|
|
@ -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
|
|
@ -2,5 +2,6 @@ import ./contracts/testCollateral
|
||||||
import ./contracts/testContracts
|
import ./contracts/testContracts
|
||||||
import ./contracts/testMarket
|
import ./contracts/testMarket
|
||||||
import ./contracts/testProofs
|
import ./contracts/testProofs
|
||||||
|
import ./contracts/testInteractions
|
||||||
|
|
||||||
{.warning[UnusedImport]:off.}
|
{.warning[UnusedImport]:off.}
|
||||||
|
|
Loading…
Reference in New Issue