From bd782aa6b8b6460a4737789decac7ece2292607e Mon Sep 17 00:00:00 2001 From: Tim <4171783+tmjssz@users.noreply.github.com> Date: Mon, 29 Apr 2024 14:18:30 +0200 Subject: [PATCH] fix(auth-kit/onramp-kit): Migrate to Sepolia + various small fixes (#788) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * fix(onramp-kit): Use valid mock contract address to fix unit test * Bump `@monerium/sdk` to v2.12.0 for Sepolia support * Switch chain for onramp-kit example app from görli to sepolia * fix(onramp-kit): Fix unit test to use sepolia instead of goerli * feat(onramp-kit): Show loader for monerium demo only while order is pending * docs(auth-kit): Update broken links in README --- packages/auth-kit/README.md | 4 ++-- packages/auth-kit/example/README.md | 3 +-- packages/onramp-kit/example/client/.env.sample | 1 + packages/onramp-kit/example/client/package.json | 2 +- packages/onramp-kit/example/client/src/AuthContext.tsx | 2 +- .../example/client/src/components/monerium/Connected.tsx | 4 +++- packages/onramp-kit/package.json | 2 +- .../src/packs/monerium/SafeMoneriumClient.test.ts | 8 ++++---- 8 files changed, 14 insertions(+), 12 deletions(-) diff --git a/packages/auth-kit/README.md b/packages/auth-kit/README.md index d72f26e16..85b924c62 100644 --- a/packages/auth-kit/README.md +++ b/packages/auth-kit/README.md @@ -8,9 +8,9 @@ The Auth Kit provides a way to authenticate blockchain accounts using email addr ## Reference -- [Auth Kit integration guides](https://docs.safe.global/safe-core-aa-sdk/auth-kit) +- [Auth Kit integration guides](https://docs.safe.global/sdk/auth-kit) -- [Auth Kit reference](https://docs.safe.global/reference/auth-kit) +- [Auth Kit reference](https://docs.safe.global/sdk/auth-kit/reference) ## Example diff --git a/packages/auth-kit/example/README.md b/packages/auth-kit/example/README.md index dbd6c2456..633607dee 100644 --- a/packages/auth-kit/example/README.md +++ b/packages/auth-kit/example/README.md @@ -23,5 +23,4 @@ To use the example properly in your local machine follow these steps: **In the auth-kit example root folder** 3. `yarn install` -4. Configure `.env` following `.env.sample` -5. `yarn start` +4. `yarn start` diff --git a/packages/onramp-kit/example/client/.env.sample b/packages/onramp-kit/example/client/.env.sample index b3166dbe1..cbe051c43 100644 --- a/packages/onramp-kit/example/client/.env.sample +++ b/packages/onramp-kit/example/client/.env.sample @@ -8,6 +8,7 @@ VITE_STRIPE_PUBLIC_KEY= VITE_SAFE_STRIPE_BACKEND_BASE_URL= # Configure the Monerium client ID. You need to get one from Monerium. +# Add the client ID for the authorization code flow here (not the one for the client credentials flow). # More info here: # https://monerium.dev/docs/getting-started/create-app VITE_MONERIUM_CLIENT_ID= diff --git a/packages/onramp-kit/example/client/package.json b/packages/onramp-kit/example/client/package.json index c54925480..32a3674ae 100644 --- a/packages/onramp-kit/example/client/package.json +++ b/packages/onramp-kit/example/client/package.json @@ -11,7 +11,7 @@ "dependencies": { "@emotion/react": "^11.11.4", "@emotion/styled": "^11.11.5", - "@monerium/sdk": "^2.9.0", + "@monerium/sdk": "^2.12.0", "@mui/material": "^5.15.15", "@safe-global/auth-kit": "file:../../../auth-kit", "@safe-global/onramp-kit": "file:../../", diff --git a/packages/onramp-kit/example/client/src/AuthContext.tsx b/packages/onramp-kit/example/client/src/AuthContext.tsx index d1f3c5430..b1d431b41 100644 --- a/packages/onramp-kit/example/client/src/AuthContext.tsx +++ b/packages/onramp-kit/example/client/src/AuthContext.tsx @@ -38,7 +38,7 @@ const AuthProvider = ({ children }: AuthContextProviderProps) => { const options: SafeAuthInitOptions = { enableLogging: true, showWidgetButton: false, - chainConfig: { chainId: '0x5', rpcTarget: 'https://rpc.ankr.com/eth_goerli' } + chainConfig: { chainId: '0xaa36a7', rpcTarget: 'https://rpc.ankr.com/eth_sepolia' } } await authPack.init(options) diff --git a/packages/onramp-kit/example/client/src/components/monerium/Connected.tsx b/packages/onramp-kit/example/client/src/components/monerium/Connected.tsx index 8e6e0630b..969f063a1 100644 --- a/packages/onramp-kit/example/client/src/components/monerium/Connected.tsx +++ b/packages/onramp-kit/example/client/src/components/monerium/Connected.tsx @@ -31,7 +31,9 @@ function Connected({ authContext, orderState, safe, onLogout, onTransfer }: Conn {isLoading ? ( - + {orderState && [OrderState.placed, OrderState.pending].includes(orderState) && ( + + )} {orderState && ( <> {orderState === OrderState.placed && Order placed} diff --git a/packages/onramp-kit/package.json b/packages/onramp-kit/package.json index 009972f42..b34fd817b 100644 --- a/packages/onramp-kit/package.json +++ b/packages/onramp-kit/package.json @@ -35,7 +35,7 @@ "access": "public" }, "dependencies": { - "@monerium/sdk": "^2.9.0", + "@monerium/sdk": "^2.12.0", "@safe-global/api-kit": "^2.3.0", "@safe-global/protocol-kit": "3.1.0-alpha.0", "@safe-global/safe-core-sdk-types": "^4.0.2", diff --git a/packages/onramp-kit/src/packs/monerium/SafeMoneriumClient.test.ts b/packages/onramp-kit/src/packs/monerium/SafeMoneriumClient.test.ts index 172c4fad0..fd29fbd2d 100644 --- a/packages/onramp-kit/src/packs/monerium/SafeMoneriumClient.test.ts +++ b/packages/onramp-kit/src/packs/monerium/SafeMoneriumClient.test.ts @@ -225,7 +225,7 @@ describe('SafeMoneriumClient', () => { jest.spyOn(protocolKitPackage, 'getSignMessageLibContract').mockResolvedValueOnce({ safeVersion: '1.3.0', contractName: 'signMessageLibVersion', - contract: new Contract('target', []), + contract: new Contract('0x0000000000000000000000000000000000000001', []), safeProvider: protocolKit.getSafeProvider() as protocolKitPackage.SafeProvider, encode: jest.fn(), contractAbi: signMessageLib_1_4_1_ContractArtifacts.abi, @@ -268,7 +268,7 @@ describe('SafeMoneriumClient', () => { it('should map the protocol kit chainId to the Monerium Chain types', async () => { protocolKit.getChainId = jest.fn().mockResolvedValueOnce(1n) expect(await safeMoneriumClient.getChain()).toBe('ethereum') - protocolKit.getChainId = jest.fn().mockResolvedValueOnce(5n) + protocolKit.getChainId = jest.fn().mockResolvedValueOnce(11155111n) expect(await safeMoneriumClient.getChain()).toBe('ethereum') protocolKit.getChainId = jest.fn().mockResolvedValueOnce(100n) expect(await safeMoneriumClient.getChain()).toBe('gnosis') @@ -285,8 +285,8 @@ describe('SafeMoneriumClient', () => { it('should map the protocol kit chainId to the Monerium Network types', async () => { protocolKit.getChainId = jest.fn().mockResolvedValueOnce(1n) expect(await safeMoneriumClient.getNetwork()).toBe('mainnet') - protocolKit.getChainId = jest.fn().mockResolvedValueOnce(5n) - expect(await safeMoneriumClient.getNetwork()).toBe('goerli') + protocolKit.getChainId = jest.fn().mockResolvedValueOnce(11155111n) + expect(await safeMoneriumClient.getNetwork()).toBe('sepolia') protocolKit.getChainId = jest.fn().mockResolvedValueOnce(100n) expect(await safeMoneriumClient.getNetwork()).toBe('mainnet') protocolKit.getChainId = jest.fn().mockResolvedValueOnce(10200n)