Okay let’s try and make some progress on an actual interface.
From vm/embedded/definition/spork.go
, we can take the ABI
jsonSpork = `
[
{"type":"function","name":"CreateSpork","inputs":[{"name":"name","type":"string"},{"name":"description","type":"string"}]},
{"type":"function","name":"ActivateSpork","inputs":[{"name":"id","type":"hash"}]},
{"type":"variable", "name":"sporkInfo", "inputs":[
{"name":"id", "type":"hash"},
{"name":"name", "type":"string"},
{"name":"description", "type":"string"},
{"name":"activated", "type": "bool"},
{"name":"enforcementHeight", "type": "uint64"}
]}
]`
Let’s use this as a starting point for possible ABIs.
For people who aren’t familiar with this structure, functions determine the transactions that people can make to interact with the contract, and variables are mostly for deciding how data should be stored.
For read-only functions, there the RPC interface. We should design that too, but I think it’s more straightforward and easier once the ABI is there.
There’s also plasma requirements and of course the actual logic, but ABI is a good place to start imo.
From vm/embedded/definition/accelerator.go
we can see that items that can be voted on have a status and some timestamps, which i’m guessing are used validate that votes are within voting period
{"type":"variable","name":"project","inputs":[
{"name":"id", "type":"hash"},
{"name":"owner","type":"address"},
{"name":"name","type":"string"},
{"name":"description","type":"string"},
{"name":"url","type":"string"},
{"name":"znnFundsNeeded","type":"uint256"},
{"name":"qsrFundsNeeded","type":"uint256"},
{"name":"creationTimestamp","type":"int64"},
{"name":"lastUpdateTimestamp","type":"int64"},
{"name":"status","type":"uint8"},
{"name":"phaseIds","type":"hash[]"}
]},
{"type":"variable","name":"phase","inputs":[
{"name":"id", "type":"hash"},
{"name":"projectId", "type":"hash"},
{"name":"name","type":"string"},
{"name":"description","type":"string"},
{"name":"url","type":"string"},
{"name":"znnFundsNeeded","type":"uint256"},
{"name":"qsrFundsNeeded","type":"uint256"},
{"name":"creationTimestamp","type":"int64"},
{"name":"acceptedTimestamp","type":"int64"},
{"name":"status","type":"uint8"}
]}
So if we wanted to start with a very quick passthrough spork contract with pillar voting, it could look something like:
jsonSpork = `
[
{"type":"function","name":"ProposeCreateSpork","inputs":[{"name":"name","type":"string"},{"name":"description","type":"string"}]},
{"type":"function","name":"ProposeActivateSpork","inputs":[{"name":"id","type":"hash"}]},
{"type":"variable", "name":"proposedSporkInfo", "inputs":[
{"name":"id", "type":"hash"},
{"name":"name", "type":"string"},
{"name":"description", "type":"string"},
{"name":"proposalTimestamp","type":"int64"},
{"name":"creationTimestamp","type":"int64"},
{"name":"activationTimestamp","type":"int64"},
{"name":"lastUpdateTimestamp","type":"int64"},
{"name":"status", "type": "uint8"},
]}
]`
status
can be an enum, of Proposed, Created, Activated
Need to keep in mind that the id used for the ProposeActivateSpork function will be different that the Proposal Id which will be used for voting.
We might not need all of the timestamps, but just putting them there to start.
From vm/embedded/definition/common.go
, we can take the common voting ABI
{"type":"variable","name":"pillarVote","inputs":[
{"name":"id","type":"hash"},
{"name":"name","type":"string"},
{"name":"vote","type":"uint8"}
]},
{"type":"variable","name":"votableHash","inputs":[
{"name":"exists","type":"bool"}
]},
{"type":"variable","name":"pillarVote","inputs":[
{"name":"id","type":"hash"},
{"name":"name","type":"string"},
{"name":"vote","type":"uint8"}
]},
{"type":"variable","name":"votableHash","inputs":[
{"name":"exists","type":"bool"}
]},
We should break down exactly how these work.
and we likely need Update functions to trigger vote tallying
{"type":"function","name":"Update", "inputs":[]},
{"type":"variable","name":"lastUpdate","inputs":[{"name":"height","type":"uint64"}]},
{"type":"variable","name":"lastEpochUpdate","inputs":[{"name":"lastEpoch", "type": "int64"}]},
Please ask questions if any part of this doesn’t make sense.
We need to work with our pillars who want to understand.