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
|
2022-03-28 15:24:28 +00:00
|
|
|
StorageRequested* = object of Event
|
2022-08-17 02:29:44 +00:00
|
|
|
requestId*: RequestId
|
2022-04-11 18:03:55 +00:00
|
|
|
ask*: StorageAsk
|
2022-07-28 12:33:17 +00:00
|
|
|
SlotFilled* = object of Event
|
2022-08-17 02:29:44 +00:00
|
|
|
requestId* {.indexed.}: RequestId
|
2022-07-28 12:33:17 +00:00
|
|
|
slotIndex* {.indexed.}: UInt256
|
2022-08-17 02:29:44 +00:00
|
|
|
slotId* {.indexed.}: SlotId
|
2022-06-13 13:04:12 +00:00
|
|
|
RequestFulfilled* = object of Event
|
2022-08-17 02:29:44 +00:00
|
|
|
requestId* {.indexed.}: RequestId
|
2022-08-18 06:01:47 +00:00
|
|
|
RequestCancelled* = object of Event
|
|
|
|
requestId* {.indexed.}: Id
|
2022-04-13 16:41:48 +00:00
|
|
|
ProofSubmitted* = object of Event
|
2022-08-17 02:29:44 +00:00
|
|
|
id*: SlotId
|
2022-04-13 16:41:48 +00:00
|
|
|
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-07-28 12:33:17 +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-08-17 02:29:44 +00:00
|
|
|
proc fillSlot*(storage: Storage, requestId: RequestId, slotIndex: UInt256, proof: seq[byte]) {.contract.}
|
2022-08-18 06:01:47 +00:00
|
|
|
proc withdrawFunds*(storage: Storage, requestId: Id) {.contract.}
|
2022-08-17 02:29:44 +00:00
|
|
|
proc payoutSlot*(storage: Storage, requestId: RequestId, slotIndex: UInt256) {.contract.}
|
|
|
|
proc getRequest*(storage: Storage, id: RequestId): StorageRequest {.contract, view.}
|
|
|
|
proc getHost*(storage: Storage, id: SlotId): Address {.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 proofPeriod*(storage: Storage): UInt256 {.contract, view.}
|
|
|
|
proc proofTimeout*(storage: Storage): UInt256 {.contract, view.}
|
|
|
|
|
2022-08-17 02:29:44 +00:00
|
|
|
proc proofEnd*(storage: Storage, id: SlotId): UInt256 {.contract, view.}
|
|
|
|
proc missingProofs*(storage: Storage, id: SlotId): UInt256 {.contract, view.}
|
2022-08-17 04:02:53 +00:00
|
|
|
proc isCancelled*(storage: Storage, id: Id): bool {.contract, view.}
|
|
|
|
proc isSlotCancelled*(storage: Storage, id: Id): bool {.contract, view.}
|
2022-08-17 02:29:44 +00:00
|
|
|
proc isProofRequired*(storage: Storage, id: SlotId): bool {.contract, view.}
|
|
|
|
proc willProofBeRequired*(storage: Storage, id: SlotId): bool {.contract, view.}
|
|
|
|
proc getChallenge*(storage: Storage, id: SlotId): array[32, byte] {.contract, view.}
|
|
|
|
proc getPointer*(storage: Storage, id: SlotId): 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-08-17 02:29:44 +00:00
|
|
|
proc submitProof*(storage: Storage, id: SlotId, proof: seq[byte]) {.contract.}
|
|
|
|
proc markProofAsMissing*(storage: Storage, id: SlotId, period: UInt256) {.contract.}
|