-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into plat-5507-enable-use-of-relayer-signer-packa…
…ge-without-specifying
- Loading branch information
Showing
40 changed files
with
890 additions
and
2,225 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
require('dotenv').config(); | ||
import { Defender } from '@openzeppelin/defender-sdk'; | ||
|
||
// Default timeout is not enough, using 15s timeout instead. | ||
jest.setTimeout(15 * 1000); | ||
|
||
describe('address-book', () => { | ||
const addressBookClient = new Defender({ | ||
apiKey: process.env.API_KEY, | ||
apiSecret: process.env.API_SECRET, | ||
}).addressBook; | ||
|
||
it('should list addresses', async () => { | ||
const result = await addressBookClient.list(); | ||
expect(result).toBeDefined(); | ||
}); | ||
|
||
it('should create and delete an address', async () => { | ||
const result = await addressBookClient.create({ | ||
address: '0x1234567890123456789012345678901234567890', | ||
network: 'mainnet', | ||
type: 'EOA', | ||
alias: 'My Address', | ||
}); | ||
expect(result.addressBookId).toBe('mainnet|0x1234567890123456789012345678901234567890'); | ||
|
||
const deleteResult = await addressBookClient.delete(result.addressBookId); | ||
expect(deleteResult.message).toBe('mainnet|0x1234567890123456789012345678901234567890 deleted'); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
require('dotenv').config(); | ||
import { Defender } from '@openzeppelin/defender-sdk'; | ||
|
||
// Default timeout is not enough, using 15s timeout instead. | ||
jest.setTimeout(15 * 1000); | ||
|
||
describe('Approval process', () => { | ||
const approvalProcessClient = new Defender({ | ||
apiKey: process.env.API_KEY, | ||
apiSecret: process.env.API_SECRET, | ||
}).approvalProcess; | ||
|
||
it('should list approval processes', async () => { | ||
const result = await approvalProcessClient.list(); | ||
expect(result).toBeDefined(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
require('dotenv').config(); | ||
|
||
const { Defender } = require('@openzeppelin/defender-sdk'); | ||
|
||
async function main() { | ||
const client = new Defender({ | ||
apiKey: process.env.API_KEY, | ||
apiSecret: process.env.API_SECRET, | ||
}); | ||
|
||
const addresses = await client.addressBook.list(); | ||
console.log('addresses:', addresses); | ||
|
||
const created = await client.addressBook.create({ | ||
address: '0x1A8943463a20f55B8BC7a318dB77C4AEDBC3fae6', | ||
name: 'My EOA Address', | ||
network: 'sepolia', | ||
type: 'EOA', | ||
alias: 'Deployer EOA address', | ||
}); | ||
console.log('created address:', created); | ||
|
||
const deleteRes = await client.addressBook.delete(created.addressBookId); | ||
console.log(deleteRes); | ||
} | ||
|
||
if (require.main === module) { | ||
main().catch(console.error); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
{ | ||
"name": "@openzeppelin/defender-sdk-example-address-book-actions", | ||
"version": "1.14.4", | ||
"private": true, | ||
"main": "index.js", | ||
"author": "OpenZeppelin Defender <[email protected]>", | ||
"license": "MIT", | ||
"scripts": { | ||
"start": "node index.js" | ||
}, | ||
"dependencies": { | ||
"@openzeppelin/defender-sdk": "1.15.0", | ||
"dotenv": "^16.3.1" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
require('dotenv').config(); | ||
|
||
const { Defender } = require('@openzeppelin/defender-sdk'); | ||
|
||
async function main() { | ||
const creds = { apiKey: process.env.API_KEY, apiSecret: process.env.API_SECRET }; | ||
const client = new Defender(creds); | ||
|
||
const relayers = await client.relay.list(); | ||
let relayer = relayers.items.find((relayer) => relayer.network === 'sepolia'); | ||
if (!relayer) { | ||
console.log('Relayer not found, creating one'); | ||
relayer = await client.relay.create({ name: 'My Testnet Relayer', network: 'sepolia', minBalance: 0 }); | ||
} | ||
|
||
const approvalProcess = await client.approvalProcess.create({ | ||
name: 'My Approval Process 2', | ||
network: 'sepolia', | ||
via: relayer.address, | ||
viaType: 'Relayer', | ||
relayerId: relayer.relayerId, | ||
}); | ||
|
||
console.log(approvalProcess); | ||
} | ||
|
||
if (require.main === module) { | ||
main().catch(console.error); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
{ | ||
"name": "@openzeppelin/defender-sdk-example-create-approval-process", | ||
"version": "1.15.0", | ||
"private": true, | ||
"main": "index.js", | ||
"author": "OpenZeppelin Defender <[email protected]>", | ||
"license": "MIT", | ||
"scripts": { | ||
"start": "node index.js" | ||
}, | ||
"dependencies": { | ||
"@openzeppelin/defender-sdk": "1.15.0", | ||
"dotenv": "^16.3.1" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# Defender SDK Address Book 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 address book. See Examples for usage. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
module.exports = require('../../jest.config'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
{ | ||
"name": "@openzeppelin/defender-sdk-address-book-client", | ||
"version": "1.15.0", | ||
"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.15.0", | ||
"lodash": "^4.17.21", | ||
"dotenv": "^16.3.1" | ||
}, | ||
"publishConfig": { | ||
"access": "public" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import { BaseApiClient } from '@openzeppelin/defender-sdk-base-client'; | ||
import { AddressBookResponse, CreateAddressBookRequest } from '../models/address-book'; | ||
|
||
const PATH = '/address-book'; | ||
|
||
export class AddressBookClient extends BaseApiClient { | ||
protected getPoolId(): string { | ||
return process.env.DEFENDER_POOL_ID ?? 'us-west-2_94f3puJWv'; | ||
} | ||
|
||
protected getPoolClientId(): string { | ||
return process.env.DEFENDER_POOL_CLIENT_ID ?? '40e58hbc7pktmnp9i26hh5nsav'; | ||
} | ||
|
||
protected getApiUrl(): string { | ||
return process.env.DEFENDER_API_URL ?? 'https://defender-api.openzeppelin.com/'; | ||
} | ||
|
||
public async list(): Promise<AddressBookResponse[]> { | ||
return this.apiCall(async (api) => api.get(`${PATH}`)); | ||
} | ||
|
||
public async create(address: CreateAddressBookRequest): Promise<AddressBookResponse> { | ||
return this.apiCall(async (api) => api.post(`${PATH}`, address)); | ||
} | ||
|
||
public async delete(addressBookId: string): Promise<{ message: string }> { | ||
const encodedId = encodeURIComponent(addressBookId); | ||
return this.apiCall(async (api) => api.delete(`${PATH}/${encodedId}`)); | ||
} | ||
} |
Oops, something went wrong.