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
|
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
|
2022-04-11 18:03:55 +00:00
|
|
|
ask*: StorageAsk
|
2022-06-13 13:04:12 +00:00
|
|
|
RequestFulfilled* = object of Event
|
2022-03-29 09:20:07 +00:00
|
|
|
requestId* {.indexed.}: Id
|
2022-04-13 16:41:48 +00:00
|
|
|
ProofSubmitted* = object of Event
|
|
|
|
id*: Id
|
|
|
|
proof*: seq[byte]
|
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.}
|
2022-07-20 13:30:13 +00:00
|
|
|
proc fillSlot*(storage: Storage, requestId: Id, slotIndex: UInt256, proof: seq[byte]) {.contract.}
|
|
|
|
proc payoutSlot*(storage: Storage, requestId: Id, slotIndex: UInt256) {.contract.}
|
2022-06-15 12:12:34 +00:00
|
|
|
proc getRequest*(storage: Storage, id: Id): StorageRequest {.contract, view.}
|
2022-07-04 10:11:18 +00:00
|
|
|
proc getHost*(storage: Storage, id: Id): Address {.contract, view.}
|
2022-03-17 13:15:04 +00:00
|
|
|
|
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 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.}
|
2022-04-08 21:58:16 +00:00
|
|
|
proc willProofBeRequired*(storage: Storage, id: Id): bool {.contract, view.}
|
2022-03-17 13:15:04 +00:00
|
|
|
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-04-13 16:41:48 +00:00
|
|
|
proc submitProof*(storage: Storage, id: Id, proof: seq[byte]) {.contract.}
|
2022-03-17 13:15:04 +00:00
|
|
|
proc markProofAsMissing*(storage: Storage, id: Id, period: UInt256) {.contract.}
|