Skip to content

Commit

Permalink
feat(rg): Relay group support (#563)
Browse files Browse the repository at this point in the history
* Initial support

* Improvements

* Updates

* Impr

* Apply changes

* chore(relayer-group): Improvements

* feat(status): Add expired to list status

* feat(status): add expired status

* fix example:

* feat(rg-status): Introduce new type for relayer group sstatus

* chore(suggestions): Apply PR suggestions

* Update packages/relay-group/src/models/index.ts

Co-authored-by: Nami <[email protected]>

* chore(remove): Remove duplicate entry

* Update packages/relay-group/src/api/index.ts

---------

Co-authored-by: ShahNami <[email protected]>
  • Loading branch information
zeljkoX and shahnami authored Sep 27, 2024
1 parent 1d9dbd4 commit 08b786a
Show file tree
Hide file tree
Showing 24 changed files with 1,196 additions and 23 deletions.
1 change: 1 addition & 0 deletions examples/create-relay-group/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# example-create-relayer-group
36 changes: 36 additions & 0 deletions examples/create-relay-group/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
require('dotenv').config();

const { Defender } = require('@openzeppelin/defender-sdk');
const https = require('https');

async function main() {
const creds = {
apiKey: process.env.API_KEY,
apiSecret: process.env.API_SECRET,
//optional https config to keep connection alive. You can pass any configs that are accepted by https.Agent
httpsAgent: https.Agent({ keepAlive: true }),
};
const client = new Defender(creds);

const createParams = {
name: 'MyNewRelayerGroup',
network: 'sepolia',
relayers: 4,
minBalance: BigInt(1e17).toString(),
policies: {
EIP1559Pricing: true,
},
};

const relayerGroup = await client.relayGroup.create(createParams);

console.log(relayerGroup);

const relayerGroupApiKey = await client.relayGroup.createKey(relayerGroup.id);

console.log(relayerGroupApiKey);
}

if (require.main === module) {
main().catch(console.error);
}
15 changes: 15 additions & 0 deletions examples/create-relay-group/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"name": "example-create-relayer-group",
"version": "1.13.4",
"private": true,
"main": "index.js",
"author": "Defender <[email protected]>",
"license": "MIT",
"scripts": {
"start": "node index.js"
},
"dependencies": {
"@openzeppelin/defender-sdk": "1.13.4",
"dotenv": "^16.3.1"
}
}
3 changes: 2 additions & 1 deletion packages/defender-sdk/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@
"@openzeppelin/defender-sdk-relay-signer-client": "^1.14.4",
"@openzeppelin/defender-sdk-network-client": "^1.14.4",
"@openzeppelin/defender-sdk-account-client": "^1.14.4",
"@openzeppelin/defender-sdk-key-value-store-client": "^1.14.4"
"@openzeppelin/defender-sdk-key-value-store-client": "^1.14.4",
"@openzeppelin/defender-sdk-relay-group-client": "^1.14.4"
},
"publishConfig": {
"access": "public"
Expand Down
11 changes: 11 additions & 0 deletions packages/defender-sdk/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { DeployClient } from '@openzeppelin/defender-sdk-deploy-client';
import { NotificationChannelClient } from '@openzeppelin/defender-sdk-notification-channel-client';
import { NetworkClient } from '@openzeppelin/defender-sdk-network-client';
import { AccountClient } from '@openzeppelin/defender-sdk-account-client';
import { RelayGroupClient } from '@openzeppelin/defender-sdk-relay-group-client';
import { KeyValueStoreClient, LocalKeyValueStoreCreateParams } from '@openzeppelin/defender-sdk-key-value-store-client';

import { Newable, ClientParams } from './types';
Expand Down Expand Up @@ -134,6 +135,16 @@ export class Defender {
});
}

get relayGroup() {
return getClient(RelayGroupClient, {
apiKey: this.apiKey,
apiSecret: this.apiSecret,
httpsAgent: this.httpsAgent,
retryConfig: this.retryConfig,
authConfig: this.authConfig,
});
}

get proposal() {
return getClient(ProposalClient, {
apiKey: this.apiKey,
Expand Down
251 changes: 251 additions & 0 deletions packages/relay-group/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,251 @@
# @openzeppelin/defender-sdk-relay-group-client

## 1.13.4

### Patch Changes

- 985443f: feat: add backwards compatibility to ethersv5
- Updated dependencies [985443f]
- @openzeppelin/defender-sdk-base-client@1.13.4

## 1.13.3

### Patch Changes

- 2d1655d: feat: Add stackId in update relayer request
feat: Add Auth v2 support with `useCredentialsCaching` to cache access token
- Updated dependencies [2d1655d]
- @openzeppelin/defender-sdk-base-client@1.13.3

## 1.13.3

### Patch Changes

- e55d50a: Patch: Fix aws-sdk v3 action error payload
- Updated dependencies [e55d50a]
- @openzeppelin/defender-sdk-base-client@1.13.3

## 1.13.0

### Minor Changes

- ff4a967: - feat: add exponential backoff logic for retry
- fix: add conditional imports for v2 and v3 for actions
- chore: add loadbalance example for rate limit number of transactions

### Patch Changes

- Updated dependencies [ff4a967]
- @openzeppelin/defender-sdk-base-client@1.13.0

## 1.12.0

### Minor Changes

- 6b45bce: - feat: Support Holesky & Amoy networks.
- chore: Add retries to 520 errors.
- feat: Allow optional httpsAgent options.
- fix: Avoid relaySigner ENS resolution by default.
- chore: Upgrade dependencies.

### Patch Changes

- Updated dependencies [6b45bce]
- @openzeppelin/defender-sdk-base-client@1.12.0

## 1.11.0

### Minor Changes

- 49c1994: refactor: Deprecate optimism-goerli network
chore: Enable zkEVM networks
chore: Upgrade npm packages

### Patch Changes

- Updated dependencies [49c1994]
- @openzeppelin/defender-sdk-base-client@1.11.0

## 1.10.0

### Minor Changes

- 7e14499: fix: Add missing dependencies for cli tool to manage actions.
fix: Add confirmation property to tx override.
refactor: Remove deprecated config resources

### Patch Changes

- Updated dependencies [7e14499]
- @openzeppelin/defender-sdk-base-client@1.10.0

## 1.9.0

### Minor Changes

- ed29a58: - chore: Autotask & actions condition names.
- feat: Add Web3 & list contract examples.
- feat: Add support to Zksync sepolia.
- feat: Upgrade dependencies.

### Patch Changes

- Updated dependencies [ed29a58]
- @openzeppelin/defender-sdk-base-client@1.9.0

## 1.8.0

### Minor Changes

- 688e4de: chore: Remove all non-required attributes from artifact
feat: Add new private network endpoints
feat: Add abi configuration for listing contracts
chore: Add missing artifact attributes
chore: Rename simulation transaction type
chore: Add txOverrides parameter

### Patch Changes

- Updated dependencies [688e4de]
- @openzeppelin/defender-sdk-base-client@1.8.0

## 1.7.0

### Minor Changes

- 97d593c: Feat: Add support to Base Sepolia & Optimism Sepolia networks.
Feat: Add support to ethers v6

### Patch Changes

- Updated dependencies [97d593c]
- @openzeppelin/defender-sdk-base-client@1.7.0

## 1.6.0

### Minor Changes

- 9583851: Feat: Support Arbitrum sepolia

### Patch Changes

- Updated dependencies [9583851]
- @openzeppelin/defender-sdk-base-client@1.6.0

## 1.5.0

### Minor Changes

- 29be958: feat: add environment variable endpoints to actions
feat: add meld network

### Patch Changes

- Updated dependencies [29be958]
- @openzeppelin/defender-sdk-base-client@1.5.0

## 1.4.0

### Minor Changes

- c538fb7: - feat: Add support to scroll mainnet
- feat: Added missing actions utilities
- chore: Bump platform SDK dependencies

### Patch Changes

- Updated dependencies [c538fb7]
- @openzeppelin/defender-sdk-base-client@1.4.0

## 1.3.0

### Minor Changes

- 001029a: - feat: add scroll sepolia network
- feat: enforce base package to build first
- feat: export created types
- feat: changed sentinel attribute by monitor

### Patch Changes

- Updated dependencies [001029a]
- @openzeppelin/defender-sdk-base-client@1.3.0

## 1.2.0

### Minor Changes

- 37edbc7: - feat: forked networks support
- feat: network client
- ci: security updates
- fix: actions example

### Patch Changes

- Updated dependencies [37edbc7]
- @openzeppelin/defender-sdk-base-client@1.2.0

## 1.1.0

### Minor Changes

- 0851ae2: - Fix: Create relayer key bug
- Fix: Notification client typo
- Fix: Patch security vulnerabilities

### Patch Changes

- Updated dependencies [0851ae2]
- @openzeppelin/defender-sdk-base-client@1.1.0

## 1.0.0

### Major Changes

- 8711a12: - Migrate platform-sdk to defender-sdk

### Patch Changes

- Updated dependencies [8711a12]
- @openzeppelin/defender-sdk-base-client@1.0.0

## 0.4.0

### Minor Changes

- be73034: Feat: Support linea & base

### Patch Changes

- Updated dependencies [be73034]
- @openzeppelin/platform-sdk-base-client@0.4.0

## 0.3.0

### Minor Changes

- efefd68: feat: Add support of instantiating defender-sdk package from Defender Actions

### Patch Changes

- Updated dependencies [efefd68]
- @openzeppelin/defender-sdk-base-client@0.3.0

## 0.2.0

### Minor Changes

- 496f88d: ### CHANGES

- feat: list network endpoints
- ci: fix ci bugs
- fix: type with actionId
- feat: add support to base mainnet
- feat: add `skipABIValidation` flag to monitor create request
- ci: add changeset actions
- ci: remove provenance

### Patch Changes

- Updated dependencies [496f88d]
- @openzeppelin/defender-sdk-base-client@0.2.0
5 changes: 5 additions & 0 deletions packages/relay-group/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Defender SDK Relay Group Client

The OpenZeppelin Defender provides a security operations (SecOps) platform for Ethereum with built-in best practices. Development teams implement Defender to ship faster and minimize security risks.

This library provides methods related to relayer groups. See Examples for usage.
1 change: 1 addition & 0 deletions packages/relay-group/jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = require('../../jest.config');
30 changes: 30 additions & 0 deletions packages/relay-group/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
{
"name": "@openzeppelin/defender-sdk-relay-group-client",
"version": "1.14.4",
"description": "",
"main": "./lib/index.js",
"types": "./lib/index.d.ts",
"scripts": {
"build": "rm -rf lib && tsc",
"test": "npm run test:unit",
"test:unit": "jest --verbose --passWithNoTests --forceExit",
"watch": "tsc -w"
},
"files": [
"lib",
"!*.test.js",
"!*.test.js.map",
"!*.test.d.ts",
"!*__mocks__"
],
"author": "OpenZeppelin Defender <[email protected]>",
"license": "MIT",
"dependencies": {
"@openzeppelin/defender-sdk-base-client": "^1.14.4",
"axios": "^1.7.2",
"lodash": "^4.17.21"
},
"publishConfig": {
"access": "public"
}
}
Loading

0 comments on commit 08b786a

Please sign in to comment.