Skip to content

Commit

Permalink
Migrate from defender autotask sdk to platform sdk
Browse files Browse the repository at this point in the history
  • Loading branch information
ggonzalez94 committed Jul 10, 2023
1 parent 596c42a commit f42fe84
Show file tree
Hide file tree
Showing 16 changed files with 460 additions and 257 deletions.
13 changes: 13 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Ignore relevant files in fixtures, sometimes they are intentionally malformed
packages/**/fixtures/**/*.json
packages/**/fixtures/**/*.md
packages/**/fixtures/**/*.js

# Ignore all YAML file
*.yaml
*.yml

# Ignore gitignore
.gitignore

dist
3 changes: 3 additions & 0 deletions .prettierrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module.exports = {
...require('code-style/.prettierrc.js'),
};
9 changes: 9 additions & 0 deletions .prettierrc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# https://prettier.io/docs/en/options.html
printWidth: 120
trailingComma: 'all'
singleQuote: true
useTabs: false
tabWidth: 2
semi: true
arrowParens: 'always'
quoteProps: 'consistent'
16 changes: 8 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ Alternatively, you can install it directly into an existing project with:

## Setup

This plugin allows you to define Autotasks, Sentinels, Notifications, Relayers, Contracts, Policies and Secrets declaratively from a `serverless.yml` and provision them via the CLI using `serverless deploy`. An example template below with an autotask, a relayer, a policy and a single relayer API key defined:
This plugin allows you to define Actions, Sentinels, Notifications, Relayers, Contracts, Policies and Secrets declaratively from a `serverless.yml` and provision them via the CLI using `serverless deploy`. An example template below with an action, a relayer, a policy and a single relayer API key defined:

```yaml
service: defender-serverless-template
Expand All @@ -42,9 +42,9 @@ defender:
secret: '${env:TEAM_API_SECRET}'

functions:
autotask-example-1:
action-example-1:
name: 'Hello world from serverless'
path: './autotasks/hello-world'
path: './actions/hello-world'
relayer: ${self:resources.Resources.relayers.relayer-1}
trigger:
type: 'schedule'
Expand Down Expand Up @@ -90,9 +90,9 @@ Any resource removed from the `serverless.yml` file does _not_ get automatically

Exported serverless configurations with Block Explorer Api Keys will not contain the `key` field but instead a `key-hash` field which is a keccak256 hash of the key. This must be replaced with the actual `key` field (and `key-hash` removed) before deploying

### Secrets (Autotask)
### Secrets (Action)

Autotask secrets can be defined both globally and per stack. Secrets defined under `global` are not affected by changes to the `stackName` and will retain when redeployed under a new stack. Secrets defined under `stack` will be removed (on the condition that [SSOT mode](#SSOT-mode) is enabled) when the stack is redeployed under a new `stackName`. To reference secrets defined under `stack`, use the following format: `<stackname>_<secretkey>`, for example `mystack_test`.
Action secrets can be defined both globally and per stack. Secrets defined under `global` are not affected by changes to the `stackName` and will retain when redeployed under a new stack. Secrets defined under `stack` will be removed (on the condition that [SSOT mode](#SSOT-mode) is enabled) when the stack is redeployed under a new `stackName`. To reference secrets defined under `stack`, use the following format: `<stackname>_<secretkey>`, for example `mystack_test`.

```yaml
secrets:
Expand All @@ -111,7 +111,7 @@ We provide auto-generated documentation based on the JSON schemas:

- [Defender Property](https://github.com/OpenZeppelin/defender-serverless/blob/main/src/types/docs/defender.md)
- [Provider Property](https://github.com/OpenZeppelin/defender-serverless/blob/main/src/types/docs/provider.md)
- [Function (Autotask) Property](https://github.com/OpenZeppelin/defender-serverless/blob/main/src/types/docs/function.md)
- [Function (Action) Property](https://github.com/OpenZeppelin/defender-serverless/blob/main/src/types/docs/function.md)
- [Resources Property](https://github.com/OpenZeppelin/defender-serverless/blob/main/src/types/docs/resources.md)

More information on types can be found [here](https://github.com/OpenZeppelin/defender-serverless/blob/main/src/types/index.ts). Specifically, the types preceded with `Y` (e.g. YRelayer). For the schemas, you can check out the [docs-schema](https://github.com/OpenZeppelin/defender-serverless/blob/main/src/types/docs-schemas) folder.
Expand Down Expand Up @@ -144,11 +144,11 @@ You can use `sls remove` to remove all defender resources defined in the `server

### Logs

You can use `sls logs --function <stack_resource_id> --data {...}` to retrieve the latest autotask logs for a given autotask identifier (e.g. mystack.autotask-example-1). This command will run continiously and retrieve logs every 2 seconds. The `--data` flag is optional.
You can use `sls logs --function <stack_resource_id> --data {...}` to retrieve the latest action logs for a given action identifier (e.g. mystack.action-example-1). This command will run continiously and retrieve logs every 2 seconds. The `--data` flag is optional.

### Invoke

You can use `sls invoke --function <stack_resource_id>` to manually run an autotask, given its identifier (e.g. mystack.autotask-example-1).
You can use `sls invoke --function <stack_resource_id>` to manually run an action, given its identifier (e.g. mystack.action-example-1).

> Each command has a standard output to a JSON object.

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,10 @@
},
"dependencies": {
"@openzeppelin/defender-admin-client": "^1.46.0",
"@openzeppelin/defender-autotask-client": "^1.46.0",
"@openzeppelin/defender-relay-client": "^1.46.0",
"@openzeppelin/defender-sentinel-client": "^1.46.0",
"@openzeppelin/platform-deploy-client": "^0.8.0",
"@openzeppelin/platform-sdk": "^0.1.0",
"keccak256": "^1.0.6",
"lodash": "^4.17.21",
"prompt": "^1.3.0"
Expand Down
Loading

0 comments on commit f42fe84

Please sign in to comment.