feat: integrate dagger contracts
Integrate dagger contracts from `nim-dagger-contracts` repo.
Add `dagger-contracts`, `nim-web3`, and all of `nim-web3`’s transitive deps as submodule deps to `nim-dagger`. Note: `nim-web3` and its transitive deps may no longer be needed when we switch to `nim-ethers`.
Add a `testContracts` nimble task to test all of the contracts functionality. Namely, this spins up an ethereum simulator, deploys the contracts (in `dagger-contracts`), runs the contract tests, and finally, regardless of success/error, kills the ethereum sim processes. The nimble task can be run with `./env.sh nimble testContracts`.
We also tested `nim-dagger-contracts` as a submodule dep of `nim-dagger`, and while the tests run as expected, the preference is to merge `nim-dagger-contracts` inside of `nim-dagger` for ease of parallel development. There’s also a high probability that `nim-dagger-contracts` is not being used as a dep by other projects. Are there any strong objections to this?
Co-authored-by: Michael Bradley <michaelsbradleyjr@gmail.com>
2022-01-25 00:22:58 +00:00
|
|
|
import pkg/ethers
|
|
|
|
import pkg/json_rpc/rpcclient
|
|
|
|
import pkg/stint
|
|
|
|
import pkg/chronos
|
2022-03-23 08:11:15 +00:00
|
|
|
import ./requests
|
|
|
|
import ./offers
|
feat: integrate dagger contracts
Integrate dagger contracts from `nim-dagger-contracts` repo.
Add `dagger-contracts`, `nim-web3`, and all of `nim-web3`’s transitive deps as submodule deps to `nim-dagger`. Note: `nim-web3` and its transitive deps may no longer be needed when we switch to `nim-ethers`.
Add a `testContracts` nimble task to test all of the contracts functionality. Namely, this spins up an ethereum simulator, deploys the contracts (in `dagger-contracts`), runs the contract tests, and finally, regardless of success/error, kills the ethereum sim processes. The nimble task can be run with `./env.sh nimble testContracts`.
We also tested `nim-dagger-contracts` as a submodule dep of `nim-dagger`, and while the tests run as expected, the preference is to merge `nim-dagger-contracts` inside of `nim-dagger` for ease of parallel development. There’s also a high probability that `nim-dagger-contracts` is not being used as a dep by other projects. Are there any strong objections to this?
Co-authored-by: Michael Bradley <michaelsbradleyjr@gmail.com>
2022-01-25 00:22:58 +00:00
|
|
|
|
|
|
|
export stint
|
2022-03-29 07:47:49 +00:00
|
|
|
export ethers
|
feat: integrate dagger contracts
Integrate dagger contracts from `nim-dagger-contracts` repo.
Add `dagger-contracts`, `nim-web3`, and all of `nim-web3`’s transitive deps as submodule deps to `nim-dagger`. Note: `nim-web3` and its transitive deps may no longer be needed when we switch to `nim-ethers`.
Add a `testContracts` nimble task to test all of the contracts functionality. Namely, this spins up an ethereum simulator, deploys the contracts (in `dagger-contracts`), runs the contract tests, and finally, regardless of success/error, kills the ethereum sim processes. The nimble task can be run with `./env.sh nimble testContracts`.
We also tested `nim-dagger-contracts` as a submodule dep of `nim-dagger`, and while the tests run as expected, the preference is to merge `nim-dagger-contracts` inside of `nim-dagger` for ease of parallel development. There’s also a high probability that `nim-dagger-contracts` is not being used as a dep by other projects. Are there any strong objections to this?
Co-authored-by: Michael Bradley <michaelsbradleyjr@gmail.com>
2022-01-25 00:22:58 +00:00
|
|
|
|
|
|
|
type
|
|
|
|
Storage* = ref object of Contract
|
|
|
|
Id = array[32, byte]
|
2022-03-28 15:24:28 +00:00
|
|
|
StorageRequested* = object of Event
|
|
|
|
requestId*: Id
|
|
|
|
request*: StorageRequest
|
2022-03-29 07:47:49 +00:00
|
|
|
StorageOffered* = object of Event
|
|
|
|
offerId*: Id
|
|
|
|
offer*: StorageOffer
|
|
|
|
requestId* {.indexed.}: Id
|
feat: integrate dagger contracts
Integrate dagger contracts from `nim-dagger-contracts` repo.
Add `dagger-contracts`, `nim-web3`, and all of `nim-web3`’s transitive deps as submodule deps to `nim-dagger`. Note: `nim-web3` and its transitive deps may no longer be needed when we switch to `nim-ethers`.
Add a `testContracts` nimble task to test all of the contracts functionality. Namely, this spins up an ethereum simulator, deploys the contracts (in `dagger-contracts`), runs the contract tests, and finally, regardless of success/error, kills the ethereum sim processes. The nimble task can be run with `./env.sh nimble testContracts`.
We also tested `nim-dagger-contracts` as a submodule dep of `nim-dagger`, and while the tests run as expected, the preference is to merge `nim-dagger-contracts` inside of `nim-dagger` for ease of parallel development. There’s also a high probability that `nim-dagger-contracts` is not being used as a dep by other projects. Are there any strong objections to this?
Co-authored-by: Michael Bradley <michaelsbradleyjr@gmail.com>
2022-01-25 00:22:58 +00:00
|
|
|
|
2022-03-15 16:29:56 +00:00
|
|
|
proc collateralAmount*(storage: Storage): UInt256 {.contract, view.}
|
2022-03-17 13:15:04 +00:00
|
|
|
proc slashMisses*(storage: Storage): UInt256 {.contract, view.}
|
|
|
|
proc slashPercentage*(storage: Storage): UInt256 {.contract, view.}
|
|
|
|
|
2022-03-15 16:29:56 +00:00
|
|
|
proc deposit*(storage: Storage, amount: UInt256) {.contract.}
|
|
|
|
proc withdraw*(storage: Storage) {.contract.}
|
|
|
|
proc balanceOf*(storage: Storage, account: Address): UInt256 {.contract, view.}
|
2022-03-17 13:15:04 +00:00
|
|
|
|
|
|
|
proc requestStorage*(storage: Storage, request: StorageRequest) {.contract.}
|
|
|
|
proc offerStorage*(storage: Storage, offer: StorageOffer) {.contract.}
|
|
|
|
proc selectOffer*(storage: Storage, id: Id) {.contract.}
|
|
|
|
|
feat: integrate dagger contracts
Integrate dagger contracts from `nim-dagger-contracts` repo.
Add `dagger-contracts`, `nim-web3`, and all of `nim-web3`’s transitive deps as submodule deps to `nim-dagger`. Note: `nim-web3` and its transitive deps may no longer be needed when we switch to `nim-ethers`.
Add a `testContracts` nimble task to test all of the contracts functionality. Namely, this spins up an ethereum simulator, deploys the contracts (in `dagger-contracts`), runs the contract tests, and finally, regardless of success/error, kills the ethereum sim processes. The nimble task can be run with `./env.sh nimble testContracts`.
We also tested `nim-dagger-contracts` as a submodule dep of `nim-dagger`, and while the tests run as expected, the preference is to merge `nim-dagger-contracts` inside of `nim-dagger` for ease of parallel development. There’s also a high probability that `nim-dagger-contracts` is not being used as a dep by other projects. Are there any strong objections to this?
Co-authored-by: Michael Bradley <michaelsbradleyjr@gmail.com>
2022-01-25 00:22:58 +00:00
|
|
|
proc startContract*(storage: Storage, id: Id) {.contract.}
|
|
|
|
proc finishContract*(storage: Storage, id: Id) {.contract.}
|
|
|
|
|
2022-03-17 13:15:04 +00:00
|
|
|
proc proofPeriod*(storage: Storage): UInt256 {.contract, view.}
|
|
|
|
proc proofTimeout*(storage: Storage): UInt256 {.contract, view.}
|
|
|
|
|
|
|
|
proc proofEnd*(storage: Storage, id: Id): UInt256 {.contract, view.}
|
|
|
|
proc missingProofs*(storage: Storage, id: Id): UInt256 {.contract, view.}
|
|
|
|
proc isProofRequired*(storage: Storage, id: Id): bool {.contract, view.}
|
|
|
|
proc getChallenge*(storage: Storage, id: Id): array[32, byte] {.contract, view.}
|
|
|
|
proc getPointer*(storage: Storage, id: Id): uint8 {.contract, view.}
|
feat: integrate dagger contracts
Integrate dagger contracts from `nim-dagger-contracts` repo.
Add `dagger-contracts`, `nim-web3`, and all of `nim-web3`’s transitive deps as submodule deps to `nim-dagger`. Note: `nim-web3` and its transitive deps may no longer be needed when we switch to `nim-ethers`.
Add a `testContracts` nimble task to test all of the contracts functionality. Namely, this spins up an ethereum simulator, deploys the contracts (in `dagger-contracts`), runs the contract tests, and finally, regardless of success/error, kills the ethereum sim processes. The nimble task can be run with `./env.sh nimble testContracts`.
We also tested `nim-dagger-contracts` as a submodule dep of `nim-dagger`, and while the tests run as expected, the preference is to merge `nim-dagger-contracts` inside of `nim-dagger` for ease of parallel development. There’s also a high probability that `nim-dagger-contracts` is not being used as a dep by other projects. Are there any strong objections to this?
Co-authored-by: Michael Bradley <michaelsbradleyjr@gmail.com>
2022-01-25 00:22:58 +00:00
|
|
|
|
2022-03-17 13:15:04 +00:00
|
|
|
proc submitProof*(storage: Storage, id: Id, proof: bool) {.contract.}
|
|
|
|
proc markProofAsMissing*(storage: Storage, id: Id, period: UInt256) {.contract.}
|