Skip to content

Commit

Permalink
Allow referencing existing Defender resources (#27)
Browse files Browse the repository at this point in the history
* Add DefenderId type and ensure commands ignore direct defender references

* Filter out defender referencted from resources

* remove console logs and fix category stackResourceId

* Fix resources schema to accept string or object

* Fix referencing defender relayer directly in actions

* Allow referencing action-trigger and action-condition in monitors

* Fix reference to address-from-relayer

* align resources formatting

* Allow referencing notificationIds in category

* Allow referencing category and notification in monitor

* Allow referencing contracts in monitor

* Add documentation to README

* add quotes for consistency

* replace version in example project
  • Loading branch information
shahnami authored Oct 28, 2023
1 parent 0698af4 commit efe1439
Show file tree
Hide file tree
Showing 67 changed files with 1,477 additions and 605 deletions.
2 changes: 1 addition & 1 deletion examples/defender-test-project/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
],
"license": "MIT",
"devDependencies": {
"@openzeppelin/defender-as-code": "2.1.0",
"@openzeppelin/defender-as-code": "^2.0.0",
"serverless": "^3.20.0"
}
}
25 changes: 16 additions & 9 deletions examples/defender-test-project/serverless.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ resources:
name: 'Hello world from serverless'
path: './actions/hello-world'
# optional
relayer: ${self:resources.relayers.relayer-1}
relayer: ${self:resources.relayers.relayer-3}
trigger:
type: 'schedule' # or webhook
# optional if not cron
Expand All @@ -44,6 +44,7 @@ resources:
trigger:
type: 'webhook'
paused: false
action-example-4: '516dfd2f-9715-47d4-bcdf-d1f9a7b4d80d'

policies:
policy-1:
Expand Down Expand Up @@ -75,6 +76,7 @@ resources:
abi: ${file(./abis/demoflash.json.abi)}
# optional
nat-spec: null
contract-2: 'goerli-0xd70d6A0480420b4C788AF91d0E1b0ca6141A9De8'

relayers:
relayer-1:
Expand All @@ -93,6 +95,14 @@ resources:
address-from-relayer: ${self:resources.relayers.relayer-1}
# optional
policy: ${self:resources.policies.policy-1}
relayer-3: 'bcb659c6-7e11-4d37-a15b-0fa9f3d3442c' # relayerId referenced from Defender
relayer-4:
name: 'Test Relayer 4'
network: 'mainnet'
min-balance: 1000
address-from-relayer: ${self:resources.relayers.relayer-3}
# optional
policy: ${self:resources.policies.policy-1}

notifications:
email-1:
Expand Down Expand Up @@ -134,9 +144,10 @@ resources:
type: 'BLOCK'
network: 'goerli'
risk-category: 'TECHNICAL' # optional
addresses:
- '0x0f06aB75c7DD497981b75CD82F6566e3a5CAd8f2'
# optional
# optional - either contracts OR addresses should be defined
contracts:
- ${self:resources.contracts.contract-2}
# optional - will default to first contract in contracts if not defined
abi: ${file(./abis/erc721.json.abi)}
# optional
alert-threshold:
Expand All @@ -145,7 +156,7 @@ resources:
# optional
paused: false
# optional
action-condition: ${self:resources.actions.action-example-1}
action-condition: ${self:resources.actions.action-example-4}
# optional
action-trigger: null
# optional
Expand All @@ -167,10 +178,6 @@ resources:
forta-example:
name: 'Forta Example'
type: 'FORTA'
network: 'mainnet'
# optional if agent-ids is defined
addresses:
- '0x318958A61A3dFa42fBdAA6A28A4F481678D943cC'
# optional
alert-threshold:
amount: 2
Expand Down
Loading

0 comments on commit efe1439

Please sign in to comment.