Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Gateway client script: added readme and json pretty print #11361

Merged
merged 6 commits into from
Nov 30, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions core/scripts/gateway/client/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# A gateway client script

This script is used to connect to a gateway server and send commands to it.

## Usage

All requests have to be signed on behalf of a user, you need to provide your private key in .env file, e.g.

```
PRIVATE_KEY=1a2b3c...
```

The script will automatically sign the message using the provided private key.
Run the script without arguments to get the list of available commands.

## Example

```
go run . -gateway_url https://01.functions-gateway.chain.link -don_id fun-avalanche-mainnet-2 -method secrets_list -message_id 123
```
7 changes: 6 additions & 1 deletion core/scripts/gateway/client/send_request.go
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,12 @@ func main() {
return
}

fmt.Println(string(body))
var prettyJSON bytes.Buffer
if err := json.Indent(&prettyJSON, body, "", " "); err != nil {
fmt.Println(string(body))
} else {
fmt.Println(prettyJSON.String())
}
}

sendRequest()
Expand Down
Loading