[contracts] Split marketplace.nim into requests.nim and offers.nim

This commit is contained in:
Mark Spanbroek 2022-03-23 09:11:15 +01:00 committed by markspanbroek
parent e92fbd4ad1
commit a3fdd35f73
5 changed files with 23 additions and 16 deletions

View File

@ -1,7 +1,9 @@
import contracts/marketplace
import contracts/requests
import contracts/offers
import contracts/storage
import contracts/deployment
export marketplace
export requests
export offers
export storage
export deployment

View File

@ -0,0 +1,15 @@
import pkg/contractabi
import pkg/nimcrypto
export contractabi
type
StorageOffer* = tuple
host: Address
requestId: array[32, byte]
price: UInt256
expiry: UInt256
func id*(offer: StorageOffer): array[32, byte] =
let encoding = AbiEncoder.encode(offer)
keccak256.digest(encoding).data

View File

@ -1,9 +1,7 @@
import pkg/stint
import pkg/contractabi
import pkg/nimcrypto
import pkg/chronos
export stint
export contractabi
type
StorageRequest* = tuple
@ -15,16 +13,7 @@ type
maxPrice: UInt256
expiry: UInt256
nonce: array[32, byte]
StorageOffer* = tuple
host: Address
requestId: array[32, byte]
price: UInt256
expiry: UInt256
func id*(request: StorageRequest): array[32, byte] =
let encoding = AbiEncoder.encode(request)
keccak256.digest(encoding).data
func id*(offer: StorageOffer): array[32, byte] =
let encoding = AbiEncoder.encode(offer)
keccak256.digest(encoding).data

View File

@ -2,7 +2,8 @@ import pkg/ethers
import pkg/json_rpc/rpcclient
import pkg/stint
import pkg/chronos
import ./marketplace
import ./requests
import ./offers
export stint
export contract

View File

@ -2,7 +2,7 @@ import std/times
import pkg/stint
import pkg/nimcrypto
import pkg/ethers
import dagger/contracts/marketplace
import dagger/contracts
proc randomBytes(amount: static int): array[amount, byte] =
doAssert randomBytes(result) == amount