2022-03-23 08:11:15 +00:00
|
|
|
import pkg/contractabi
|
|
|
|
import pkg/nimcrypto
|
|
|
|
|
|
|
|
export contractabi
|
|
|
|
|
|
|
|
type
|
2022-03-23 13:20:36 +00:00
|
|
|
StorageOffer* = object
|
|
|
|
host*: Address
|
|
|
|
requestId*: array[32, byte]
|
|
|
|
price*: UInt256
|
|
|
|
expiry*: UInt256
|
|
|
|
|
|
|
|
func toTuple(offer: StorageOffer): auto =
|
|
|
|
(
|
|
|
|
offer.host,
|
|
|
|
offer.requestId,
|
|
|
|
offer.price,
|
|
|
|
offer.expiry
|
|
|
|
)
|
|
|
|
|
|
|
|
func solidityType*(_: type StorageOffer): string =
|
|
|
|
solidityType(typeof StorageOffer.default.toTuple)
|
|
|
|
|
|
|
|
func encode*(encoder: var AbiEncoder, offer: StorageOffer) =
|
|
|
|
encoder.write(offer.toTuple)
|
2022-03-23 08:11:15 +00:00
|
|
|
|
|
|
|
func id*(offer: StorageOffer): array[32, byte] =
|
|
|
|
let encoding = AbiEncoder.encode(offer)
|
|
|
|
keccak256.digest(encoding).data
|