Skip to content

Commit

Permalink
feat: pass data in input to slangroom-chain (#205)
Browse files Browse the repository at this point in the history
  • Loading branch information
matteo-cristino authored Jun 10, 2024
1 parent 9d47b3a commit 9e071c0
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 3 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
"outputPath": "./"
},
"dependencies": {
"@dyne/slangroom-chain": "^1.5.0",
"@dyne/slangroom-chain": "^1.6.0",
"@slangroom/core": "^1.33.1",
"@slangroom/db": "^1.33.1",
"@slangroom/ethereum": "^1.33.1",
Expand Down
2 changes: 1 addition & 1 deletion pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,7 @@ const generateRoutes = (app: TemplatedApp) => {
let jsonResult: Record <string, unknown>;
try {
if (chain) {
jsonResult = JSON.parse(await slangroomChainExecute(chain));
jsonResult = JSON.parse(await slangroomChainExecute(chain, data? JSON.stringify(data) : undefined));
} else {
({ result: jsonResult } = await s.execute(contract, { keys, data, conf }));
}
Expand Down
10 changes: 10 additions & 0 deletions tests/fixtures/chain/hello_with_input.chain.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
() => {
return {
"steps": [
{
"id": "first",
"zencode": "Given I have a 'string' named 'say_hi'\nThen print 'say_hi'"
}
]
}
}
20 changes: 20 additions & 0 deletions tests/workflow.stepci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -383,6 +383,26 @@ tests:
json:
say_hi: hello from dataTransform

- name: hello chain with input GET
http:
url: http://${{env.host}}/chain/hello_with_input?say_hi=bonjour
method: GET
check:
status: 200
json:
say_hi: bonjour

- name: hello chain with input POST
http:
url: http://${{env.host}}/chain/hello_with_input
method: POST
json:
say_hi: Buen día
check:
status: 200
json:
say_hi: Buen día

public_dir:
steps:
- name: public with wrong precondition
Expand Down

0 comments on commit 9e071c0

Please sign in to comment.