Skip to content

Commit

Permalink
Merge pull request #5 from smartcontractkit/bugs/allow-empty-eth32-pa…
Browse files Browse the repository at this point in the history
…rams

Allow no params for the EthBytes32 adapter
  • Loading branch information
dimroc authored Dec 12, 2017
2 parents b86b031 + 98d436c commit b54c808
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
9 changes: 8 additions & 1 deletion models/task.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ func (self Task) Adapter() (adapters.Adapter, error) {
return temp, err
case "EthBytes32":
temp := &adapters.EthBytes32{}
err := json.Unmarshal(self.Params, temp)
err := unmarshalOrEmpty(self.Params, temp)
return temp, err
case "EthSendTx":
temp := &adapters.EthSendTx{}
Expand All @@ -48,3 +48,10 @@ func (self Task) Adapter() (adapters.Adapter, error) {

return nil, fmt.Errorf("%s is not a supported adapter type", self.Type)
}

func unmarshalOrEmpty(params json.RawMessage, dst interface{}) error {
if len(params) > 0 {
return json.Unmarshal(params, dst)
}
return nil
}
2 changes: 1 addition & 1 deletion web/controllers/fixtures/create_jobs.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"tasks": [
{ "type": "HttpGet", "params": { "endpoint": "https://bitstamp.net/api/ticker/" } },
{ "type": "JsonParse", "params": { "path": ["last"] } },
{ "type": "EthBytes32", "params": {} },
{ "type": "EthBytes32" },
{ "type": "EthSendTx", "params": { "address": "0x356a04bce728ba4c62a30294a55e6a8600a320b3", "functionID": "12345679" } }
],
"schedule": {"endAt": "2019-11-27T23:05:49Z", "runAt": ["2018-11-27T23:05:49Z"], "cron": "* 7 * * *"},
Expand Down

0 comments on commit b54c808

Please sign in to comment.