Skip to content

Commit

Permalink
Merge pull request #277 from coinbase/patrick/dsl-nits
Browse files Browse the repository at this point in the history
[constructor] Add `set_blob` and `get_blob` to DSL
  • Loading branch information
patrick-ogrady committed Dec 11, 2020
2 parents ce0d632 + 82b3b5b commit 51ec84a
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 1 deletion.
9 changes: 9 additions & 0 deletions constructor/dsl/dsl_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,15 @@ func TestParse(t *testing.T) {
Input: `{"symbol":"ETH","decimals":18}`,
OutputPath: "currency",
},
{
Type: job.SetBlob,
Input: `{"key":"currency","value":{{currency}}}`,
},
{
Type: job.GetBlob,
Input: `{"key":"currency"}`,
OutputPath: "fetched_currency",
},
{
Type: job.LoadEnv,
Input: `"MIN_BALANCE"`,
Expand Down
3 changes: 2 additions & 1 deletion constructor/dsl/parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,8 @@ func parseActionType(line string) (job.ActionType, string, string, error) {
return job.SetVariable, outputPath, tokens[1], nil
case job.GenerateKey, job.Derive, job.SaveAccount, job.PrintMessage,
job.RandomString, job.Math, job.FindBalance, job.RandomNumber, job.Assert,
job.FindCurrencyAmount, job.LoadEnv, job.HTTPRequest:
job.FindCurrencyAmount, job.LoadEnv, job.HTTPRequest, job.SetBlob,
job.GetBlob:
return thisAction, outputPath, tokens[1], nil
default:
return "", "", "", ErrInvalidActionType
Expand Down
7 changes: 7 additions & 0 deletions constructor/dsl/testdata/simple.ros
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,13 @@ request_funds(1){
"symbol":"ETH",
"decimals":18
};
set_blob({
"key":"currency",
"value":{{currency}}
});
fetched_currency = get_blob({
"key":"currency"
});
env = load_env("MIN_BALANCE");
random_account = find_balance({
"minimum_balance":{
Expand Down

0 comments on commit 51ec84a

Please sign in to comment.