2022-03-17 13:15:04 +00:00
|
|
|
import pkg/contractabi
|
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/nimcrypto
|
2022-03-28 15:24:28 +00:00
|
|
|
import pkg/ethers/fields
|
|
|
|
import pkg/questionable/results
|
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-23 08:11:15 +00:00
|
|
|
export contractabi
|
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
|
2022-03-23 13:20:36 +00:00
|
|
|
StorageRequest* = object
|
|
|
|
client*: Address
|
|
|
|
duration*: UInt256
|
|
|
|
size*: UInt256
|
|
|
|
contentHash*: array[32, byte]
|
|
|
|
proofProbability*: UInt256
|
|
|
|
maxPrice*: UInt256
|
|
|
|
expiry*: UInt256
|
|
|
|
nonce*: array[32, byte]
|
|
|
|
|
2022-03-28 15:24:28 +00:00
|
|
|
func fromTuple(_: type StorageRequest, tupl: tuple): StorageRequest =
|
|
|
|
StorageRequest(
|
|
|
|
client: tupl[0],
|
|
|
|
duration: tupl[1],
|
|
|
|
size: tupl[2],
|
|
|
|
contentHash: tupl[3],
|
|
|
|
proofProbability: tupl[4],
|
|
|
|
maxPrice: tupl[5],
|
|
|
|
expiry: tupl[6],
|
|
|
|
nonce: tupl[7]
|
2022-03-23 13:20:36 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
func solidityType*(_: type StorageRequest): string =
|
2022-03-28 15:24:28 +00:00
|
|
|
solidityType(StorageRequest.fieldTypes)
|
2022-03-23 13:20:36 +00:00
|
|
|
|
|
|
|
func encode*(encoder: var AbiEncoder, request: StorageRequest) =
|
2022-03-28 15:24:28 +00:00
|
|
|
encoder.write(request.fieldValues)
|
|
|
|
|
|
|
|
func decode*(decoder: var AbiDecoder, T: type StorageRequest): ?!T =
|
|
|
|
let tupl = ?decoder.read(StorageRequest.fieldTypes)
|
|
|
|
success StorageRequest.fromTuple(tupl)
|
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
|
|
|
func id*(request: StorageRequest): array[32, byte] =
|
|
|
|
let encoding = AbiEncoder.encode(request)
|
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
|
|
|
keccak256.digest(encoding).data
|