From 8038a24cec6d381f1da730f09ba26cd6509fa6bf Mon Sep 17 00:00:00 2001 From: Tim Date: Thu, 26 Oct 2023 17:36:26 +0200 Subject: [PATCH 01/11] Configure jest for `account-abstraction-kit` --- packages/account-abstraction-kit/jest.config.js | 14 ++++++++++++++ packages/account-abstraction-kit/package.json | 2 +- 2 files changed, 15 insertions(+), 1 deletion(-) create mode 100644 packages/account-abstraction-kit/jest.config.js diff --git a/packages/account-abstraction-kit/jest.config.js b/packages/account-abstraction-kit/jest.config.js new file mode 100644 index 000000000..5eb12db13 --- /dev/null +++ b/packages/account-abstraction-kit/jest.config.js @@ -0,0 +1,14 @@ +const config = { + roots: ['/src'], + verbose: true, + transform: { + '^.+\\.ts?$': 'ts-jest' + }, + moduleNameMapper: { + '^@safe-global/protocol-kit/typechain/(.*)$': '/../protocol-kit/typechain/$1', + '^@safe-global/protocol-kit/(.*)$': '/../protocol-kit/src/$1', + '^@safe-global/relay-kit/(.*)$': '/src/$1' + } +} + +module.exports = config diff --git a/packages/account-abstraction-kit/package.json b/packages/account-abstraction-kit/package.json index 3eaec299b..80041f759 100644 --- a/packages/account-abstraction-kit/package.json +++ b/packages/account-abstraction-kit/package.json @@ -15,7 +15,7 @@ "build": "yarn unbuild && tsc && tsc-alias", "format:check": "prettier --check \"*/**/*.{js,json,md,ts}\"", "format": "prettier --write \"*/**/*.{js,json,md,ts}\"", - "test": "echo \"Error: no test specified\"" + "test": "jest src --coverage" }, "repository": { "type": "git", From 4ae1b722e661be323fd4b154dada480d52c215d4 Mon Sep 17 00:00:00 2001 From: Tim Date: Thu, 26 Oct 2023 17:38:49 +0200 Subject: [PATCH 02/11] Unit test AccountAbstraction's constructor + init functions --- .../src/AccountAbstraction.test.ts | 83 +++++++++++++++++++ 1 file changed, 83 insertions(+) create mode 100644 packages/account-abstraction-kit/src/AccountAbstraction.test.ts diff --git a/packages/account-abstraction-kit/src/AccountAbstraction.test.ts b/packages/account-abstraction-kit/src/AccountAbstraction.test.ts new file mode 100644 index 000000000..92a2af8ee --- /dev/null +++ b/packages/account-abstraction-kit/src/AccountAbstraction.test.ts @@ -0,0 +1,83 @@ +import { Signer } from '@ethersproject/abstract-signer' +import Safe, { EthersAdapter, predictSafeAddress } from '@safe-global/protocol-kit' +import { GelatoRelayPack } from '@safe-global/relay-kit' +import { ethers } from 'ethers' +import AccountAbstraction from './AccountAbstraction' + +jest.mock('@safe-global/protocol-kit') + +const SafeMock = Safe as jest.MockedClass +const EthersAdapterMock = EthersAdapter as jest.MockedClass +const predictSafeAddressMock = predictSafeAddress as jest.MockedFunction + +describe('AccountAbstraction', () => { + const signer = { + provider: {}, + getAddress: jest.fn() + } + const signerAddress = '0xSignerAddress' + const predictSafeAddress = '0xPredictSafeAddressMock' + + beforeEach(() => { + jest.clearAllMocks() + // Safe.create = mockSafeCreate + signer.getAddress.mockResolvedValueOnce(signerAddress) + predictSafeAddressMock.mockResolvedValueOnce(predictSafeAddress) + }) + + describe('constructor', () => { + it('should create a new EthersAdapter instance', () => { + new AccountAbstraction(signer as unknown as Signer) + expect(EthersAdapterMock).toHaveBeenCalledTimes(1) + expect(EthersAdapterMock).toHaveBeenCalledWith({ ethers, signerOrProvider: signer }) + }) + + it('should throw an error if signer is not connected to a provider', () => { + expect( + () => new AccountAbstraction({ ...signer, provider: undefined } as unknown as Signer) + ).toThrow('Signer must be connected to a provider') + expect(EthersAdapterMock).not.toHaveBeenCalled() + }) + }) + + describe('init', () => { + const accountAbstraction = new AccountAbstraction(signer as unknown as Signer) + const relayPack = new GelatoRelayPack() + + it('should initialize a Safe instance with its address if contract is deployed already', async () => { + EthersAdapterMock.prototype.isContractDeployed.mockResolvedValueOnce(true) + + await accountAbstraction.init({ relayPack }) + + expect(signer.getAddress).toHaveBeenCalledTimes(1) + expect(predictSafeAddressMock).toHaveBeenCalledTimes(1) + expect(predictSafeAddressMock).toHaveBeenCalledWith({ + ethAdapter: expect.any(EthersAdapterMock), + safeAccountConfig: { owners: ['0xSignerAddress'], threshold: 1 } + }) + expect(SafeMock.create).toHaveBeenCalledTimes(1) + expect(SafeMock.create).toHaveBeenCalledWith({ + ethAdapter: expect.any(EthersAdapterMock), + safeAddress: predictSafeAddress + }) + }) + + it('should initialize a Safe instance with a config if contract is NOT deployed yet', async () => { + EthersAdapterMock.prototype.isContractDeployed.mockResolvedValueOnce(false) + + await accountAbstraction.init({ relayPack }) + + expect(signer.getAddress).toHaveBeenCalledTimes(1) + expect(predictSafeAddressMock).toHaveBeenCalledTimes(1) + expect(predictSafeAddressMock).toHaveBeenCalledWith({ + ethAdapter: expect.any(EthersAdapterMock), + safeAccountConfig: { owners: ['0xSignerAddress'], threshold: 1 } + }) + expect(SafeMock.create).toHaveBeenCalledTimes(1) + expect(SafeMock.create).toHaveBeenCalledWith({ + ethAdapter: expect.any(EthersAdapterMock), + predictedSafe: { safeAccountConfig: { owners: ['0xSignerAddress'], threshold: 1 } } + }) + }) + }) +}) From c4a65a0a9582590aa86c5045cb69687e5097b88e Mon Sep 17 00:00:00 2001 From: Tim Date: Thu, 26 Oct 2023 17:49:31 +0200 Subject: [PATCH 03/11] Unit test `getSignerAddress` function --- .../src/AccountAbstraction.test.ts | 23 ++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/packages/account-abstraction-kit/src/AccountAbstraction.test.ts b/packages/account-abstraction-kit/src/AccountAbstraction.test.ts index 92a2af8ee..c6743bdd8 100644 --- a/packages/account-abstraction-kit/src/AccountAbstraction.test.ts +++ b/packages/account-abstraction-kit/src/AccountAbstraction.test.ts @@ -20,7 +20,6 @@ describe('AccountAbstraction', () => { beforeEach(() => { jest.clearAllMocks() - // Safe.create = mockSafeCreate signer.getAddress.mockResolvedValueOnce(signerAddress) predictSafeAddressMock.mockResolvedValueOnce(predictSafeAddress) }) @@ -80,4 +79,26 @@ describe('AccountAbstraction', () => { }) }) }) + + const initAccountAbstraction = async () => { + const accountAbstraction = new AccountAbstraction(signer as unknown as Signer) + const relayPack = new GelatoRelayPack() + await accountAbstraction.init({ relayPack }) + return accountAbstraction + } + + describe('getSignerAddress', () => { + let accountAbstraction: AccountAbstraction + + beforeEach(async () => { + accountAbstraction = await initAccountAbstraction() + jest.clearAllMocks() + }) + + it("should return the signer's address", async () => { + const result = await accountAbstraction.getSignerAddress() + expect(result).toBe(signerAddress) + expect(signer.getAddress).toHaveBeenCalledTimes(1) + }) + }) }) From 01b081597c239241f7c52a5bb752490a20d1db27 Mon Sep 17 00:00:00 2001 From: Tim Date: Thu, 26 Oct 2023 18:18:33 +0200 Subject: [PATCH 04/11] Unit test `getNonce` function --- .../src/AccountAbstraction.test.ts | 44 ++++++++++++++----- 1 file changed, 33 insertions(+), 11 deletions(-) diff --git a/packages/account-abstraction-kit/src/AccountAbstraction.test.ts b/packages/account-abstraction-kit/src/AccountAbstraction.test.ts index c6743bdd8..2b67be796 100644 --- a/packages/account-abstraction-kit/src/AccountAbstraction.test.ts +++ b/packages/account-abstraction-kit/src/AccountAbstraction.test.ts @@ -80,25 +80,47 @@ describe('AccountAbstraction', () => { }) }) - const initAccountAbstraction = async () => { - const accountAbstraction = new AccountAbstraction(signer as unknown as Signer) - const relayPack = new GelatoRelayPack() - await accountAbstraction.init({ relayPack }) - return accountAbstraction - } + describe('initialized', () => { + const safeInstanceMock = { getNonce: jest.fn() } + + const initAccountAbstraction = async () => { + const accountAbstraction = new AccountAbstraction(signer as unknown as Signer) + const relayPack = new GelatoRelayPack() + await accountAbstraction.init({ relayPack }) + return accountAbstraction + } - describe('getSignerAddress', () => { let accountAbstraction: AccountAbstraction beforeEach(async () => { accountAbstraction = await initAccountAbstraction() jest.clearAllMocks() + SafeMock.create = () => Promise.resolve(safeInstanceMock as unknown as Safe) }) - it("should return the signer's address", async () => { - const result = await accountAbstraction.getSignerAddress() - expect(result).toBe(signerAddress) - expect(signer.getAddress).toHaveBeenCalledTimes(1) + describe('getSignerAddress', () => { + it("should return the signer's address", async () => { + const result = await accountAbstraction.getSignerAddress() + expect(result).toBe(signerAddress) + expect(signer.getAddress).toHaveBeenCalledTimes(1) + }) + }) + + describe('getNonce', () => { + const nonceMock = 123 + safeInstanceMock.getNonce.mockResolvedValueOnce(nonceMock) + + it('should return the nonce received from Safe SDK', async () => { + const result = await accountAbstraction.getNonce() + expect(result).toBe(nonceMock) + expect(safeInstanceMock.getNonce).toHaveBeenCalledTimes(1) + }) + + it('should throw if Safe SDK is not initiallized', async () => { + const accountAbstraction = new AccountAbstraction(signer as unknown as Signer) + expect(accountAbstraction.getNonce()).rejects.toThrow('SDK not initialized') + expect(safeInstanceMock.getNonce).toHaveBeenCalledTimes(0) + }) }) }) }) From 6f279ed3212758beec4d6e040d465c30a75861a2 Mon Sep 17 00:00:00 2001 From: Tim Date: Fri, 27 Oct 2023 18:58:20 +0200 Subject: [PATCH 05/11] Unit test `getSafeAddress` and `isSafeDeployed` functions --- .../src/AccountAbstraction.test.ts | 38 ++++++++++++++++++- 1 file changed, 37 insertions(+), 1 deletion(-) diff --git a/packages/account-abstraction-kit/src/AccountAbstraction.test.ts b/packages/account-abstraction-kit/src/AccountAbstraction.test.ts index 2b67be796..04545fb5f 100644 --- a/packages/account-abstraction-kit/src/AccountAbstraction.test.ts +++ b/packages/account-abstraction-kit/src/AccountAbstraction.test.ts @@ -81,7 +81,11 @@ describe('AccountAbstraction', () => { }) describe('initialized', () => { - const safeInstanceMock = { getNonce: jest.fn() } + const safeInstanceMock = { + getNonce: jest.fn(), + getAddress: jest.fn(), + isSafeDeployed: jest.fn() + } const initAccountAbstraction = async () => { const accountAbstraction = new AccountAbstraction(signer as unknown as Signer) @@ -122,5 +126,37 @@ describe('AccountAbstraction', () => { expect(safeInstanceMock.getNonce).toHaveBeenCalledTimes(0) }) }) + + describe('getSafeAddress', () => { + const safeAddressMock = '0xSafeAddress' + safeInstanceMock.getAddress.mockResolvedValueOnce(safeAddressMock) + + it('should return the address received from Safe SDK', async () => { + const result = await accountAbstraction.getSafeAddress() + expect(result).toBe(safeAddressMock) + expect(safeInstanceMock.getAddress).toHaveBeenCalledTimes(1) + }) + + it('should throw if Safe SDK is not initiallized', async () => { + const accountAbstraction = new AccountAbstraction(signer as unknown as Signer) + expect(accountAbstraction.getSafeAddress()).rejects.toThrow('SDK not initialized') + expect(safeInstanceMock.getAddress).toHaveBeenCalledTimes(0) + }) + }) + + describe('isSafeDeployed', () => { + it.each([true, false])('should return the value received from Safe SDK', async (expected) => { + safeInstanceMock.isSafeDeployed.mockResolvedValueOnce(expected) + const result = await accountAbstraction.isSafeDeployed() + expect(result).toBe(expected) + expect(safeInstanceMock.isSafeDeployed).toHaveBeenCalledTimes(1) + }) + + it('should throw if Safe SDK is not initiallized', async () => { + const accountAbstraction = new AccountAbstraction(signer as unknown as Signer) + expect(accountAbstraction.isSafeDeployed()).rejects.toThrow('SDK not initialized') + expect(safeInstanceMock.isSafeDeployed).toHaveBeenCalledTimes(0) + }) + }) }) }) From d79b076f374c26ae3c381bed659e6f55144049cb Mon Sep 17 00:00:00 2001 From: Tim Date: Fri, 27 Oct 2023 19:07:20 +0200 Subject: [PATCH 06/11] Unit test `relayTransaction` function --- .../src/AccountAbstraction.test.ts | 92 ++++++++++++++++--- 1 file changed, 79 insertions(+), 13 deletions(-) diff --git a/packages/account-abstraction-kit/src/AccountAbstraction.test.ts b/packages/account-abstraction-kit/src/AccountAbstraction.test.ts index 04545fb5f..c48422b09 100644 --- a/packages/account-abstraction-kit/src/AccountAbstraction.test.ts +++ b/packages/account-abstraction-kit/src/AccountAbstraction.test.ts @@ -1,14 +1,17 @@ import { Signer } from '@ethersproject/abstract-signer' import Safe, { EthersAdapter, predictSafeAddress } from '@safe-global/protocol-kit' -import { GelatoRelayPack } from '@safe-global/relay-kit' +import { GelatoRelayPack, RelayPack } from '@safe-global/relay-kit' +import { SafeTransaction } from '@safe-global/safe-core-sdk-types' import { ethers } from 'ethers' import AccountAbstraction from './AccountAbstraction' jest.mock('@safe-global/protocol-kit') +jest.mock('@safe-global/relay-kit') -const SafeMock = Safe as jest.MockedClass const EthersAdapterMock = EthersAdapter as jest.MockedClass +const GelatoRelayPackMock = GelatoRelayPack as jest.MockedClass const predictSafeAddressMock = predictSafeAddress as jest.MockedFunction +const SafeMock = Safe as jest.MockedClass describe('AccountAbstraction', () => { const signer = { @@ -82,15 +85,15 @@ describe('AccountAbstraction', () => { describe('initialized', () => { const safeInstanceMock = { - getNonce: jest.fn(), getAddress: jest.fn(), - isSafeDeployed: jest.fn() + getNonce: jest.fn(), + isSafeDeployed: jest.fn(), + signTransaction: jest.fn() } - const initAccountAbstraction = async () => { + const initAccountAbstraction = async (initOptions = { relayPack: new GelatoRelayPack() }) => { const accountAbstraction = new AccountAbstraction(signer as unknown as Signer) - const relayPack = new GelatoRelayPack() - await accountAbstraction.init({ relayPack }) + await accountAbstraction.init(initOptions) return accountAbstraction } @@ -120,10 +123,10 @@ describe('AccountAbstraction', () => { expect(safeInstanceMock.getNonce).toHaveBeenCalledTimes(1) }) - it('should throw if Safe SDK is not initiallized', async () => { + it('should throw if Safe SDK is not initialized', async () => { const accountAbstraction = new AccountAbstraction(signer as unknown as Signer) expect(accountAbstraction.getNonce()).rejects.toThrow('SDK not initialized') - expect(safeInstanceMock.getNonce).toHaveBeenCalledTimes(0) + expect(safeInstanceMock.getNonce).not.toHaveBeenCalled() }) }) @@ -137,10 +140,10 @@ describe('AccountAbstraction', () => { expect(safeInstanceMock.getAddress).toHaveBeenCalledTimes(1) }) - it('should throw if Safe SDK is not initiallized', async () => { + it('should throw if Safe SDK is not initialized', async () => { const accountAbstraction = new AccountAbstraction(signer as unknown as Signer) expect(accountAbstraction.getSafeAddress()).rejects.toThrow('SDK not initialized') - expect(safeInstanceMock.getAddress).toHaveBeenCalledTimes(0) + expect(safeInstanceMock.getAddress).not.toHaveBeenCalled() }) }) @@ -152,10 +155,73 @@ describe('AccountAbstraction', () => { expect(safeInstanceMock.isSafeDeployed).toHaveBeenCalledTimes(1) }) - it('should throw if Safe SDK is not initiallized', async () => { + it('should throw if Safe SDK is not initialized', async () => { const accountAbstraction = new AccountAbstraction(signer as unknown as Signer) expect(accountAbstraction.isSafeDeployed()).rejects.toThrow('SDK not initialized') - expect(safeInstanceMock.isSafeDeployed).toHaveBeenCalledTimes(0) + expect(safeInstanceMock.isSafeDeployed).not.toHaveBeenCalled() + }) + }) + + describe('relayTransaction', () => { + const transactionsMock = [{ to: '0xToAddress', value: '0.1', data: '0xData' }] + const optionsMock = { isSponsored: true } + const safeTxMock = { data: { foo: 'bar' } } as unknown as SafeTransaction + const signedSafeTxMock = { ...safeTxMock, signed: true } as unknown as SafeTransaction + const relayResponseMock = { taskId: '0xTaskID' } + + it('should return the Gelato taskId of the relayed transaction', async () => { + GelatoRelayPackMock.prototype.createRelayedTransaction.mockResolvedValueOnce(safeTxMock) + safeInstanceMock.signTransaction.mockResolvedValueOnce(signedSafeTxMock) + GelatoRelayPackMock.prototype.executeRelayTransaction.mockResolvedValueOnce( + relayResponseMock + ) + + const result = await accountAbstraction.relayTransaction(transactionsMock, optionsMock) + + expect(result).toBe(relayResponseMock.taskId) + + expect(GelatoRelayPackMock.prototype.createRelayedTransaction).toHaveBeenCalledTimes(1) + expect(GelatoRelayPackMock.prototype.createRelayedTransaction).toHaveBeenCalledWith({ + safe: safeInstanceMock, + transactions: transactionsMock, + options: optionsMock + }) + + expect(safeInstanceMock.signTransaction).toHaveBeenCalledTimes(1) + expect(safeInstanceMock.signTransaction).toHaveBeenCalledWith(safeTxMock) + + expect(GelatoRelayPackMock.prototype.executeRelayTransaction).toHaveBeenCalledTimes(1) + expect(GelatoRelayPackMock.prototype.executeRelayTransaction).toHaveBeenCalledWith( + signedSafeTxMock, + safeInstanceMock, + optionsMock + ) + }) + + it('should throw if Safe SDK is not initialized', async () => { + const accountAbstraction = new AccountAbstraction(signer as unknown as Signer) + accountAbstraction.setRelayPack(new GelatoRelayPack()) + + expect(accountAbstraction.relayTransaction(transactionsMock, optionsMock)).rejects.toThrow( + 'SDK not initialized' + ) + + expect(GelatoRelayPackMock.prototype.createRelayedTransaction).not.toHaveBeenCalled() + expect(safeInstanceMock.signTransaction).not.toHaveBeenCalled() + expect(GelatoRelayPackMock.prototype.executeRelayTransaction).not.toHaveBeenCalled() + }) + + it('should throw if Relay pack is not initialized', async () => { + const accountAbstraction = await initAccountAbstraction() + accountAbstraction.setRelayPack(undefined as unknown as RelayPack) + + expect(accountAbstraction.relayTransaction(transactionsMock, optionsMock)).rejects.toThrow( + 'SDK not initialized' + ) + + expect(GelatoRelayPackMock.prototype.createRelayedTransaction).not.toHaveBeenCalled() + expect(safeInstanceMock.signTransaction).not.toHaveBeenCalled() + expect(GelatoRelayPackMock.prototype.executeRelayTransaction).not.toHaveBeenCalled() }) }) }) From 0ab77009f1902c02807ab2d1859075f5d5dc3b6f Mon Sep 17 00:00:00 2001 From: Tim Date: Fri, 27 Oct 2023 19:07:51 +0200 Subject: [PATCH 07/11] fix: pass options to `executeRelayTransaction` function --- packages/account-abstraction-kit/src/AccountAbstraction.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/account-abstraction-kit/src/AccountAbstraction.ts b/packages/account-abstraction-kit/src/AccountAbstraction.ts index 7e324fd3e..9184e8544 100644 --- a/packages/account-abstraction-kit/src/AccountAbstraction.ts +++ b/packages/account-abstraction-kit/src/AccountAbstraction.ts @@ -106,7 +106,8 @@ class AccountAbstraction { const response = await this.#relayPack.executeRelayTransaction( signedSafeTransaction, - this.#safeSdk + this.#safeSdk, + options ) return response.taskId From 5e2d142dce38ce134bf18593634896a49169df01 Mon Sep 17 00:00:00 2001 From: Tim Date: Fri, 27 Oct 2023 19:09:26 +0200 Subject: [PATCH 08/11] fix: add `await` to asynchronous `getSafeAddress` call --- playground/relay-kit/paid-transaction.ts | 2 +- playground/relay-kit/sponsored-transaction.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/playground/relay-kit/paid-transaction.ts b/playground/relay-kit/paid-transaction.ts index fe00f3d85..f73f1cc53 100644 --- a/playground/relay-kit/paid-transaction.ts +++ b/playground/relay-kit/paid-transaction.ts @@ -52,7 +52,7 @@ async function main() { // Calculate Safe address - const predictedSafeAddress = safeAccountAbstraction.getSafeAddress() + const predictedSafeAddress = await safeAccountAbstraction.getSafeAddress() console.log({ predictedSafeAddress }) const isSafeDeployed = await safeAccountAbstraction.isSafeDeployed() diff --git a/playground/relay-kit/sponsored-transaction.ts b/playground/relay-kit/sponsored-transaction.ts index 87679409a..a9f441243 100644 --- a/playground/relay-kit/sponsored-transaction.ts +++ b/playground/relay-kit/sponsored-transaction.ts @@ -53,7 +53,7 @@ async function main() { // Calculate Safe address - const predictedSafeAddress = safeAccountAbstraction.getSafeAddress() + const predictedSafeAddress = await safeAccountAbstraction.getSafeAddress() console.log({ predictedSafeAddress }) const isSafeDeployed = await safeAccountAbstraction.isSafeDeployed() From c7dd0d269bccb71bde39430cf6493f67c1d23c85 Mon Sep 17 00:00:00 2001 From: Tim Date: Tue, 31 Oct 2023 09:51:00 +0100 Subject: [PATCH 09/11] Fix module name mapper --- packages/account-abstraction-kit/jest.config.js | 2 +- packages/account-abstraction-kit/src/AccountAbstraction.test.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/account-abstraction-kit/jest.config.js b/packages/account-abstraction-kit/jest.config.js index 5eb12db13..b5318a6a5 100644 --- a/packages/account-abstraction-kit/jest.config.js +++ b/packages/account-abstraction-kit/jest.config.js @@ -7,7 +7,7 @@ const config = { moduleNameMapper: { '^@safe-global/protocol-kit/typechain/(.*)$': '/../protocol-kit/typechain/$1', '^@safe-global/protocol-kit/(.*)$': '/../protocol-kit/src/$1', - '^@safe-global/relay-kit/(.*)$': '/src/$1' + '^@safe-global/account-abstraction-kit-poc/(.*)$': '/src/$1' } } diff --git a/packages/account-abstraction-kit/src/AccountAbstraction.test.ts b/packages/account-abstraction-kit/src/AccountAbstraction.test.ts index c48422b09..79d2cc771 100644 --- a/packages/account-abstraction-kit/src/AccountAbstraction.test.ts +++ b/packages/account-abstraction-kit/src/AccountAbstraction.test.ts @@ -1,9 +1,9 @@ import { Signer } from '@ethersproject/abstract-signer' +import AccountAbstraction from '@safe-global/account-abstraction-kit-poc' import Safe, { EthersAdapter, predictSafeAddress } from '@safe-global/protocol-kit' import { GelatoRelayPack, RelayPack } from '@safe-global/relay-kit' import { SafeTransaction } from '@safe-global/safe-core-sdk-types' import { ethers } from 'ethers' -import AccountAbstraction from './AccountAbstraction' jest.mock('@safe-global/protocol-kit') jest.mock('@safe-global/relay-kit') From 357d50b591907c87be4c6cfee6abafbeab8af752 Mon Sep 17 00:00:00 2001 From: Daniel <25051234+dasanra@users.noreply.github.com> Date: Tue, 31 Oct 2023 09:54:09 +0100 Subject: [PATCH 10/11] Submit coverage report on Github Action --- .github/workflows/test.yml | 7 +++++++ packages/account-abstraction-kit/jest.config.js | 1 + 2 files changed, 8 insertions(+) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 30abe51d7..757468a0e 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -39,6 +39,13 @@ jobs: - name: Test run: yarn test + - name: Account Abstraction Kit coverage + uses: coverallsapp/github-action@v2 + with: + github-token: ${{ secrets.GITHUB_TOKEN }} + base-path: packages/account-abstraction-kit + file: packages/account-abstraction-kit/coverage/lcov.info + - name: Auth Kit coverage uses: coverallsapp/github-action@v2 with: diff --git a/packages/account-abstraction-kit/jest.config.js b/packages/account-abstraction-kit/jest.config.js index b5318a6a5..44aaa1c09 100644 --- a/packages/account-abstraction-kit/jest.config.js +++ b/packages/account-abstraction-kit/jest.config.js @@ -7,6 +7,7 @@ const config = { moduleNameMapper: { '^@safe-global/protocol-kit/typechain/(.*)$': '/../protocol-kit/typechain/$1', '^@safe-global/protocol-kit/(.*)$': '/../protocol-kit/src/$1', + '^@safe-global/relay-kit/(.*)$': '/../relay-kit/src/$1', '^@safe-global/account-abstraction-kit-poc/(.*)$': '/src/$1' } } From 27282d5d58976b029db49302ec3b8def4192a107 Mon Sep 17 00:00:00 2001 From: Tim Date: Tue, 31 Oct 2023 10:03:52 +0100 Subject: [PATCH 11/11] Relative import of AccountAbstraction class --- packages/account-abstraction-kit/src/AccountAbstraction.test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/account-abstraction-kit/src/AccountAbstraction.test.ts b/packages/account-abstraction-kit/src/AccountAbstraction.test.ts index 79d2cc771..c48422b09 100644 --- a/packages/account-abstraction-kit/src/AccountAbstraction.test.ts +++ b/packages/account-abstraction-kit/src/AccountAbstraction.test.ts @@ -1,9 +1,9 @@ import { Signer } from '@ethersproject/abstract-signer' -import AccountAbstraction from '@safe-global/account-abstraction-kit-poc' import Safe, { EthersAdapter, predictSafeAddress } from '@safe-global/protocol-kit' import { GelatoRelayPack, RelayPack } from '@safe-global/relay-kit' import { SafeTransaction } from '@safe-global/safe-core-sdk-types' import { ethers } from 'ethers' +import AccountAbstraction from './AccountAbstraction' jest.mock('@safe-global/protocol-kit') jest.mock('@safe-global/relay-kit')