From 8d675800b432510661994519a25ea9ec7f14f06e Mon Sep 17 00:00:00 2001 From: Marcos Date: Wed, 4 Oct 2023 10:17:08 -0300 Subject: [PATCH 1/2] run prettier --- examples/create-batch-proposal/index.js | 6 ++-- examples/create-forked-network/index.js | 2 +- .../base/src/api/__mocks__/axios-error.ts | 8 +++--- .../src/api/block-explorer-api-key.test.ts | 4 +-- packages/deploy/src/api/deployment.test.ts | 4 +-- packages/monitor/src/api/index.test.ts | 28 ++++--------------- packages/network/src/api/index.test.ts | 2 +- packages/proposal/src/models/simulation.ts | 2 +- .../src/action/index-rate.test.ts | 4 +-- .../relay-signer/src/action/index.test.ts | 4 +-- packages/relay-signer/src/ethers/provider.ts | 2 +- packages/relay-signer/src/models/relayer.ts | 7 ++++- .../relay-signer/src/models/transactions.ts | 3 +- packages/relay-signer/src/relayer.ts | 11 ++++++-- 14 files changed, 39 insertions(+), 48 deletions(-) diff --git a/examples/create-batch-proposal/index.js b/examples/create-batch-proposal/index.js index 440bd7d8..97556bc4 100644 --- a/examples/create-batch-proposal/index.js +++ b/examples/create-batch-proposal/index.js @@ -10,15 +10,13 @@ const contracts = [ address: ERC20Token, name: 'ERC20 Token', network: 'goerli', - abi: - '[{"inputs":[{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"mint","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"transfer","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"}]', + abi: '[{"inputs":[{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"mint","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"transfer","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"}]', }, { address: RolesContract, network: 'goerli', name: 'Roles Contract', - abi: - '[{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"grantRole","outputs":[],"stateMutability":"nonpayable","type":"function"}]', + abi: '[{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"grantRole","outputs":[],"stateMutability":"nonpayable","type":"function"}]', }, ]; diff --git a/examples/create-forked-network/index.js b/examples/create-forked-network/index.js index d6663b3c..515d9ed5 100644 --- a/examples/create-forked-network/index.js +++ b/examples/create-forked-network/index.js @@ -11,7 +11,7 @@ async function main() { name: 'MyForkedNetwork', forkedNetwork: 'mainnet', rpcUrl: '', // Add your RPC URL here - }) + }); console.log(network); } diff --git a/packages/base/src/api/__mocks__/axios-error.ts b/packages/base/src/api/__mocks__/axios-error.ts index a852cb26..35fe3b52 100644 --- a/packages/base/src/api/__mocks__/axios-error.ts +++ b/packages/base/src/api/__mocks__/axios-error.ts @@ -6,13 +6,13 @@ export const mockAxiosError: AxiosError = { config: { url: '/relayer', method: 'get', - headers: ({ + headers: { 'Accept': 'application/json, text/plain, */*', 'X-Api-Key': '4Rfp2GEHDjgesA6MdseUM1n8B8kT9hgs', 'Authorization': 'Bearer WRONG', 'Content-Type': 'application/json', 'User-Agent': 'axios/0.21.4', - } as unknown) as AxiosRequestHeaders, + } as unknown as AxiosRequestHeaders, baseURL: 'https://defender-api.openzeppelin.com/', timeout: 0, xsrfCookieName: 'XSRF-TOKEN', @@ -142,13 +142,13 @@ export const mockAxiosError: AxiosError = { maxContentLength: -1, maxBodyLength: -1, data: undefined, - headers: ({ + headers: { 'Accept': 'application/json, text/plain, */*', 'X-Api-Key': '4Rfp2GEHDjgesA6MdseUM1n8B8kT9hgs', 'Authorization': 'Bearer WRONG', 'Content-Type': 'application/json', 'User-Agent': 'axios/0.21.4', - } as unknown) as AxiosRequestHeaders, + } as unknown as AxiosRequestHeaders, }, request: { _eventsCount: 7, diff --git a/packages/deploy/src/api/block-explorer-api-key.test.ts b/packages/deploy/src/api/block-explorer-api-key.test.ts index 3a2bda72..b8972ca6 100644 --- a/packages/deploy/src/api/block-explorer-api-key.test.ts +++ b/packages/deploy/src/api/block-explorer-api-key.test.ts @@ -20,10 +20,10 @@ describe('Block Explorer Api Key Client', () => { key: 'random-key', }; beforeEach(() => { - client = (new DeployClient({ + client = new DeployClient({ apiKey: 'key', apiSecret: 'secret', - }) as unknown) as TestClient; + }) as unknown as TestClient; createAuthenticatedApi.mockClear(); }); describe('constructor', () => { diff --git a/packages/deploy/src/api/deployment.test.ts b/packages/deploy/src/api/deployment.test.ts index 6239bdd5..fcedfe28 100644 --- a/packages/deploy/src/api/deployment.test.ts +++ b/packages/deploy/src/api/deployment.test.ts @@ -20,10 +20,10 @@ describe('Deploy Client', () => { verifySourceCode: true, }; beforeEach(() => { - deployClient = (new DeployClient({ + deployClient = new DeployClient({ apiKey: 'key', apiSecret: 'secret', - }) as unknown) as TestClient; + }) as unknown as TestClient; createAuthenticatedApi.mockClear(); }); describe('constructor', () => { diff --git a/packages/monitor/src/api/index.test.ts b/packages/monitor/src/api/index.test.ts index 610d18b8..dd7e4815 100644 --- a/packages/monitor/src/api/index.test.ts +++ b/packages/monitor/src/api/index.test.ts @@ -119,7 +119,7 @@ describe('MonitorClient', () => { }; beforeEach(() => { - monitor = (new MonitorClient({ apiKey: 'key', apiSecret: 'secret' }) as unknown) as TestMonitorClient; + monitor = new MonitorClient({ apiKey: 'key', apiSecret: 'secret' }) as unknown as TestMonitorClient; createAuthenticatedApi.mockClear(); listBlockwatchersSpy = jest.spyOn(monitor, 'listBlockwatchers').mockImplementation(async () => [ { @@ -184,17 +184,8 @@ describe('MonitorClient', () => { describe('create', () => { it('passes correct BLOCK type arguments to the API', async () => { - const { - name, - network, - paused, - type, - addresses, - abi, - txCondition, - eventConditions, - functionConditions, - } = createBlockPayload; + const { name, network, paused, type, addresses, abi, txCondition, eventConditions, functionConditions } = + createBlockPayload; const expectedApiRequest = { paused, @@ -301,17 +292,8 @@ describe('MonitorClient', () => { it('passes correct BLOCK type arguments to the API', async () => { jest.spyOn(monitor, 'get').mockImplementation(async () => oldBlockMonitor); - const { - name, - network, - paused, - type, - addresses, - abi, - txCondition, - eventConditions, - functionConditions, - } = createBlockPayload; + const { name, network, paused, type, addresses, abi, txCondition, eventConditions, functionConditions } = + createBlockPayload; const expectedApiRequest = { paused, diff --git a/packages/network/src/api/index.test.ts b/packages/network/src/api/index.test.ts index d9fe1bb2..ac893396 100644 --- a/packages/network/src/api/index.test.ts +++ b/packages/network/src/api/index.test.ts @@ -27,7 +27,7 @@ describe('NetworkClient', () => { let networkClient: TestNetworkClient; beforeEach(() => { - networkClient = (new NetworkClient({ apiKey: 'key', apiSecret: 'secret' }) as unknown) as TestNetworkClient; + networkClient = new NetworkClient({ apiKey: 'key', apiSecret: 'secret' }) as unknown as TestNetworkClient; createAuthenticatedApi.mockClear(); }); diff --git a/packages/proposal/src/models/simulation.ts b/packages/proposal/src/models/simulation.ts index 3ef79c40..bffe7ce7 100644 --- a/packages/proposal/src/models/simulation.ts +++ b/packages/proposal/src/models/simulation.ts @@ -9,7 +9,7 @@ export type Log = [ Address | string[] | string, Address | string[] | string, Address | string[] | string, - ...(Address | string[] | string)[] + ...(Address | string[] | string)[], ]; export type BigUInt = string | string | number; diff --git a/packages/relay-signer/src/action/index-rate.test.ts b/packages/relay-signer/src/action/index-rate.test.ts index fb0b7787..29332bb9 100644 --- a/packages/relay-signer/src/action/index-rate.test.ts +++ b/packages/relay-signer/src/action/index-rate.test.ts @@ -32,10 +32,10 @@ describe('ActionRelayer', () => { let relayer: TestActionRelayer; beforeEach(async function () { - relayer = (new ActionRelayer({ + relayer = new ActionRelayer({ credentials: JSON.stringify(credentials), relayerARN: 'arn', - }) as unknown) as TestActionRelayer; + }) as unknown as TestActionRelayer; }); describe('get rate limited', () => { diff --git a/packages/relay-signer/src/action/index.test.ts b/packages/relay-signer/src/action/index.test.ts index a7e64372..96159da9 100644 --- a/packages/relay-signer/src/action/index.test.ts +++ b/packages/relay-signer/src/action/index.test.ts @@ -21,10 +21,10 @@ describe('ActionRelayer', () => { let relayer: TestActionRelayer; beforeEach(async function () { - relayer = (new ActionRelayer({ + relayer = new ActionRelayer({ credentials: JSON.stringify(credentials), relayerARN: 'arn', - }) as unknown) as TestActionRelayer; + }) as unknown as TestActionRelayer; }); describe('constructor', () => { diff --git a/packages/relay-signer/src/ethers/provider.ts b/packages/relay-signer/src/ethers/provider.ts index eff3c6b2..08d7c789 100644 --- a/packages/relay-signer/src/ethers/provider.ts +++ b/packages/relay-signer/src/ethers/provider.ts @@ -75,6 +75,6 @@ export class DefenderRelayProvider extends StaticJsonRpcProvider { } getSigner(): JsonRpcSigner { - return (new DefenderRelaySigner(this.relayer, this, {}) as any) as JsonRpcSigner; + return new DefenderRelaySigner(this.relayer, this, {}) as any as JsonRpcSigner; } } diff --git a/packages/relay-signer/src/models/relayer.ts b/packages/relay-signer/src/models/relayer.ts index 5bdeeba7..e747d281 100644 --- a/packages/relay-signer/src/models/relayer.ts +++ b/packages/relay-signer/src/models/relayer.ts @@ -1,6 +1,11 @@ import https from 'https'; import { Network } from '@openzeppelin/defender-sdk-base-client'; -import { ListTransactionsRequest, PaginatedTransactionResponse, RelayerTransaction, RelayerTransactionPayload } from './transactions'; +import { + ListTransactionsRequest, + PaginatedTransactionResponse, + RelayerTransaction, + RelayerTransactionPayload, +} from './transactions'; import { JsonRpcResponse, SignMessagePayload, SignTypedDataPayload, SignedMessagePayload } from './rpc'; // TODO Defender Address model for this diff --git a/packages/relay-signer/src/models/transactions.ts b/packages/relay-signer/src/models/transactions.ts index fe5bff30..a1238990 100644 --- a/packages/relay-signer/src/models/transactions.ts +++ b/packages/relay-signer/src/models/transactions.ts @@ -71,8 +71,7 @@ export type ListTransactionsRequest = { usePagination?: boolean; }; - export type PaginatedTransactionResponse = { items: RelayerTransaction[]; next?: string; -} \ No newline at end of file +}; diff --git a/packages/relay-signer/src/relayer.ts b/packages/relay-signer/src/relayer.ts index 19c3d171..93359bbe 100644 --- a/packages/relay-signer/src/relayer.ts +++ b/packages/relay-signer/src/relayer.ts @@ -1,6 +1,11 @@ import { IRelayer, RelayerGetResponse, RelayerParams } from './models/relayer'; import { JsonRpcResponse, SignMessagePayload, SignTypedDataPayload, SignedMessagePayload } from './models/rpc'; -import { ListTransactionsRequest, PaginatedTransactionResponse, RelayerTransaction, RelayerTransactionPayload } from './models/transactions'; +import { + ListTransactionsRequest, + PaginatedTransactionResponse, + RelayerTransaction, + RelayerTransactionPayload, +} from './models/transactions'; import { isApiCredentials, isActionCredentials, validatePayload } from './ethers/utils'; import { RelaySignerClient } from './api'; import { DefenderRelayProvider, DefenderRelaySigner, DefenderRelaySignerOptions } from './ethers'; @@ -66,7 +71,9 @@ export class Relayer implements IRelayer { return this.relayer.getTransaction(id); } - public listTransactions(criteria?: ListTransactionsRequest): Promise { + public listTransactions( + criteria?: ListTransactionsRequest, + ): Promise { return this.relayer.listTransactions(criteria); } From 158c02077f0771fd86375cc59701d06d1e7a7d91 Mon Sep 17 00:00:00 2001 From: Marcos Date: Wed, 4 Oct 2023 10:18:18 -0300 Subject: [PATCH 2/2] add scroll sepolia network --- packages/base/src/utils/network.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/packages/base/src/utils/network.ts b/packages/base/src/utils/network.ts index ac784650..635b61e6 100644 --- a/packages/base/src/utils/network.ts +++ b/packages/base/src/utils/network.ts @@ -39,7 +39,8 @@ export type PublicNetwork = | 'base-goerli' | 'linea-goerli' | 'linea' - | 'mantle'; + | 'mantle' + | 'scroll-sepolia'; export type CustomNetwork = 'x-dfk-avax-chain' | 'x-dfk-avax-chain-test' | 'x-security-alliance'; export type ForkedNetwork = string; @@ -84,6 +85,7 @@ export const Networks: Network[] = [ 'x-dfk-avax-chain-test', 'x-security-alliance', 'mantle', + 'scroll-sepolia', ]; export function isValidNetwork(text: string): text is Network { @@ -139,4 +141,5 @@ const chainIds: { [key in Network]: number } = { 'x-dfk-avax-chain-test': 335, 'x-security-alliance': 888, 'mantle': 5000, + 'scroll-sepolia': 534351, };