[contracts] Use command line parameters for ContractInteractions
This commit is contained in:
parent
0738606303
commit
142ddd0fd3
|
@ -29,7 +29,16 @@ proc new*(_: type ContractInteractions,
|
||||||
proving: Proving.new(proofs)
|
proving: Proving.new(proofs)
|
||||||
)
|
)
|
||||||
|
|
||||||
proc new*(_: type ContractInteractions): ContractInteractions =
|
proc new*(_: type ContractInteractions,
|
||||||
let provider = JsonRpcProvider.new("ws://localhost:8545")
|
providerUrl: string,
|
||||||
let signer = provider.getSigner()
|
account = Address.default): ContractInteractions =
|
||||||
|
let provider = JsonRpcProvider.new(providerUrl)
|
||||||
|
var signer: Signer
|
||||||
|
if account == Address.default:
|
||||||
|
signer = provider.getSigner()
|
||||||
|
else:
|
||||||
|
signer = provider.getSigner(account)
|
||||||
ContractInteractions.new(signer, deployment())
|
ContractInteractions.new(signer, deployment())
|
||||||
|
|
||||||
|
proc new*(_: type ContractInteractions): ContractInteractions =
|
||||||
|
ContractInteractions.new("ws://localhost:8545")
|
||||||
|
|
|
@ -122,7 +122,7 @@ proc new*(T: type DaggerServer, config: DaggerConf): T =
|
||||||
engine = BlockExcEngine.new(localStore, wallet, network, discovery)
|
engine = BlockExcEngine.new(localStore, wallet, network, discovery)
|
||||||
store = NetworkStore.new(engine, localStore)
|
store = NetworkStore.new(engine, localStore)
|
||||||
erasure = Erasure.new(store, leoEncoderProvider, leoDecoderProvider)
|
erasure = Erasure.new(store, leoEncoderProvider, leoDecoderProvider)
|
||||||
contracts = ContractInteractions.new()
|
contracts = ContractInteractions.new(config.ethProvider, config.ethAccount)
|
||||||
daggerNode = DaggerNodeRef.new(switch, store, engine, erasure, discovery, contracts)
|
daggerNode = DaggerNodeRef.new(switch, store, engine, erasure, discovery, contracts)
|
||||||
restServer = RestServerRef.new(
|
restServer = RestServerRef.new(
|
||||||
daggerNode.initRestApi(),
|
daggerNode.initRestApi(),
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
import ./ethertest
|
import ./ethertest
|
||||||
import dagger/contracts
|
import dagger/contracts
|
||||||
|
import ./examples
|
||||||
|
|
||||||
ethersuite "Storage Contract Interactions":
|
ethersuite "Storage Contract Interactions":
|
||||||
|
|
||||||
|
@ -13,6 +14,12 @@ ethersuite "Storage Contract Interactions":
|
||||||
let deployment = deployment()
|
let deployment = deployment()
|
||||||
check ContractInteractions.new(signer, deployment) != nil
|
check ContractInteractions.new(signer, deployment) != nil
|
||||||
|
|
||||||
|
test "can be instantiated with a provider url and account":
|
||||||
|
let url = "http://localhost:8545"
|
||||||
|
let account = Address.example
|
||||||
|
check ContractInteractions.new(url) != nil
|
||||||
|
check ContractInteractions.new(url, account) != nil
|
||||||
|
|
||||||
test "provides purchasing":
|
test "provides purchasing":
|
||||||
check contracts.purchasing != nil
|
check contracts.purchasing != nil
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue