Skip to content

Commit

Permalink
Merge pull request #149 from lidofinance/feature/si-1430-research-soi…
Browse files Browse the repository at this point in the history
…nbase-smart-wallet

Coinbase smart wallet
  • Loading branch information
alx-khramov committed Sep 17, 2024
2 parents 742e4c2 + 6ed50bc commit aec464d
Show file tree
Hide file tree
Showing 20 changed files with 223 additions and 11 deletions.
11 changes: 11 additions & 0 deletions packages/connect-wallet-modal/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
# @reef-knot/connect-wallet-modal

## 5.4.0

### Minor Changes

- Coinbase smart wallet connector

### Patch Changes

- Updated dependencies
- @reef-knot/wallets-list@2.3.0

## 5.3.3

### Patch Changes
Expand Down
4 changes: 2 additions & 2 deletions packages/connect-wallet-modal/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@reef-knot/connect-wallet-modal",
"version": "5.3.3",
"version": "5.4.0",
"main": "dist/index.js",
"types": "dist/index.d.ts",
"exports": {
Expand Down Expand Up @@ -41,7 +41,7 @@
"@ledgerhq/hw-app-eth": "^6.37.1",
"@ledgerhq/hw-transport-webhid": "^6.29.0",
"@lidofinance/lido-ui": "^3.18.0",
"@reef-knot/wallets-list": "^2.2.2",
"@reef-knot/wallets-list": "^2.3.0",
"@types/react": "18.2.45",
"@types/react-dom": "18.2.17"
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ const WALLETS_DISPLAY_CONFIG_DEFAULT: WalletsModalEthProps['walletsShown'] = [
'walletConnect',
'binanceWallet',
'coinbase',
'coinbaseSmartWallet',
'trust',
'exodus',
'brave',
Expand Down
8 changes: 8 additions & 0 deletions packages/reef-knot/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# reef-knot

## 5.6.0

### Patch Changes

- Updated dependencies
- @reef-knot/connect-wallet-modal@5.4.0
- @reef-knot/wallets-list@2.3.0

## 5.5.4

### Patch Changes
Expand Down
6 changes: 3 additions & 3 deletions packages/reef-knot/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "reef-knot",
"version": "5.5.4",
"version": "5.6.0",
"main": "dist/index.js",
"types": "dist/index.d.ts",
"exports": {
Expand Down Expand Up @@ -41,11 +41,11 @@
"lint": "eslint --ext ts,tsx,js,mjs ."
},
"dependencies": {
"@reef-knot/connect-wallet-modal": "5.3.3",
"@reef-knot/connect-wallet-modal": "5.4.0",
"@reef-knot/core-react": "4.2.1",
"@reef-knot/web3-react": "4.0.1",
"@reef-knot/ui-react": "2.1.3",
"@reef-knot/wallets-list": "2.2.3",
"@reef-knot/wallets-list": "2.3.0",
"@reef-knot/wallets-helpers": "2.1.0",
"@reef-knot/types": "2.1.0",
"@reef-knot/ledger-connector": "4.1.0"
Expand Down
12 changes: 12 additions & 0 deletions packages/wallets-list/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,17 @@
# @reef-knot/wallets-list

## 2.3.0

### Minor Changes

- Coinbase smart wallet connector

### Patch Changes

- Updated dependencies
- @reef-knot/wallet-adapter-coinbase-smart-wallet@1.0.0
- @reef-knot/wallet-adapter-coinbase@2.2.0

## 2.2.3

### Patch Changes
Expand Down
5 changes: 3 additions & 2 deletions packages/wallets-list/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@reef-knot/wallets-list",
"version": "2.2.3",
"version": "2.3.0",
"main": "dist/index.js",
"types": "dist/index.d.ts",
"exports": {
Expand Down Expand Up @@ -50,7 +50,8 @@
"@reef-knot/wallet-adapter-imtoken": "2.0.1",
"@reef-knot/wallet-adapter-trust": "2.1.0",
"@reef-knot/wallet-adapter-xdefi": "2.1.0",
"@reef-knot/wallet-adapter-coinbase": "2.1.0",
"@reef-knot/wallet-adapter-coinbase": "2.2.0",
"@reef-knot/wallet-adapter-coinbase-smart-wallet": "1.0.0",
"@reef-knot/wallet-adapter-ledger-hid": "3.0.1",
"@reef-knot/wallet-adapter-ledger-live": "3.0.1",
"@reef-knot/wallet-adapter-dapp-browser-injected": "2.0.1",
Expand Down
5 changes: 5 additions & 0 deletions packages/wallets-list/src/ethereum.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ import { ImToken, id as idImToken } from '@reef-knot/wallet-adapter-imtoken';
import { Trust, id as idTrust } from '@reef-knot/wallet-adapter-trust';
import { Xdefi, id as idXdefi } from '@reef-knot/wallet-adapter-xdefi';
import { Coinbase, id as idCoinbase } from '@reef-knot/wallet-adapter-coinbase';
import {
CoinbaseSmartWallet,
id as idCoinbaseSmartWallet,
} from '@reef-knot/wallet-adapter-coinbase-smart-wallet';
import { Ledger, id as idLedger } from '@reef-knot/wallet-adapter-ledger-hid';
import {
LedgerLive,
Expand Down Expand Up @@ -48,6 +52,7 @@ export const WalletsListEthereum = {
[idTrust]: Trust,
[idXdefi]: Xdefi,
[idCoinbase]: Coinbase,
[idCoinbaseSmartWallet]: CoinbaseSmartWallet,
[idDAppBrowserInjected]: DAppBrowserInjected,
[idSafe]: Safe,
[idBinanceWallet]: BinanceWeb3Wallet,
Expand Down
9 changes: 9 additions & 0 deletions packages/wallets/coinbase-smart-wallet/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"root": true,
"extends": [
"custom"
],
"rules": {
"import/no-extraneous-dependencies": "warn"
}
}
7 changes: 7 additions & 0 deletions packages/wallets/coinbase-smart-wallet/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# @reef-knot/wallet-adapter-coinbase-smart-wallet

## 1.0.0

### Major Changes

- Coinbase smart wallet connector
44 changes: 44 additions & 0 deletions packages/wallets/coinbase-smart-wallet/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
{
"name": "@reef-knot/wallet-adapter-coinbase-smart-wallet",
"version": "1.0.0",
"main": "dist/index.js",
"types": "dist/index.d.ts",
"exports": {
".": "./dist/index.js"
},
"typesVersions": {
"*": {
".": [
"dist/index.d.ts"
]
}
},
"type": "module",
"files": [
"dist"
],
"license": "MIT",
"homepage": "https://github.com/lidofinance/reef-knot",
"bugs": {
"url": "https://github.com/lidofinance/reef-knot/issues"
},
"publishConfig": {
"registry": "https://registry.npmjs.org/",
"access": "public"
},
"scripts": {
"build": "rollup -c",
"dev": "dev=on rollup -c -w",
"lint": "eslint --ext ts,tsx,js,mjs ."
},
"devDependencies": {
"@reef-knot/types": "^2.0.0",
"@svgr/rollup": "^6.5.1",
"eslint-config-custom": "*"
},
"peerDependencies": {
"wagmi": "2.10.4",
"@reef-knot/types": "^2.0.0",
"@tanstack/react-query": "^5.29.0"
}
}
57 changes: 57 additions & 0 deletions packages/wallets/coinbase-smart-wallet/rollup.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
import * as process from 'node:process';
import fs from 'node:fs';
import ts from 'typescript';
import { defineConfig } from 'rollup';
import del from 'rollup-plugin-delete';
import resolve from '@rollup/plugin-node-resolve';
import typescript from 'rollup-plugin-typescript2';
import { babel } from '@rollup/plugin-babel';
import svgr from '@svgr/rollup';

const extensions = ['.js', '.jsx', '.ts', '.tsx', '.svg'];
const { dependencies = {}, peerDependencies = {} } =
JSON.parse(fs.readFileSync('package.json', 'utf-8'));
const commonExternal = [
'react/jsx-runtime',
// Do not include in the bundle subpath exports like:
/^@reef-knot\/.*/, // e.g. @reef-knot/<package>/<exports-field-entry>
/^reef-knot\/.*/, // e.g. reef-knot/wallets-icons/react
];
const external = [
...commonExternal,
...Object.keys({ ...dependencies, ...peerDependencies }),
/node_modules/
];
const isDevMode = process.env.dev === 'on';

export default defineConfig({
input: './src/index',
output: {
format: 'es',
dir: 'dist',
preserveModules: true,
preserveModulesRoot: 'src',
generatedCode: 'es2015'
},
plugins: [
isDevMode ? null : del({ targets: 'dist/*', runOnce: true }),
resolve({ extensions, preferBuiltins: true }),
svgr({
typescript: true,
prettier: false,
memo: true,
svgo: false,
}),
typescript({
typescript: ts,
tsconfig: 'tsconfig.json',
check: false,
}),
babel({
exclude: 'node_modules/**',
babelHelpers: 'bundled',
extensions,
}),
],
external,
});
4 changes: 4 additions & 0 deletions packages/wallets/coinbase-smart-wallet/src/custom.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
declare module '*.svg' {
const content: React.FunctionComponent<React.SVGAttributes<SVGElement>>;
export default content;
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions packages/wallets/coinbase-smart-wallet/src/icons/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { default as WalletIcon } from './coinbase.svg';
33 changes: 33 additions & 0 deletions packages/wallets/coinbase-smart-wallet/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import { WalletAdapterType } from '@reef-knot/types';
import { coinbaseWallet } from 'wagmi/connectors';
import { isProviderExistsEIP6963 } from '@reef-knot/wallets-helpers';
import { WalletIcon } from './icons/index.js';

export const id = 'coinbaseSmartWallet';
export const name = 'Coinbase Smart Wallet';
export const rdns = 'com.coinbase.wallet';

type ConfigType = Parameters<ReturnType<typeof coinbaseWallet>>[0];

export const getCoinbaseSmartWalletConnector = (config: ConfigType) => {
const coinbaseCreateConnectorFn = coinbaseWallet({
preference: 'smartWalletOnly',
appName: globalThis.window?.location?.hostname,
});

const coinbaseConnector = coinbaseCreateConnectorFn(config);

return {
...coinbaseConnector,
name,
};
};

export const CoinbaseSmartWallet: WalletAdapterType = ({ providersStore }) => ({
walletName: name,
walletId: id,
type: coinbaseWallet.type,
icon: WalletIcon,
detector: () => isProviderExistsEIP6963(providersStore, rdns),
createConnectorFn: getCoinbaseSmartWalletConnector,
});
8 changes: 8 additions & 0 deletions packages/wallets/coinbase-smart-wallet/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"extends": "tsconfig/react-library.json",
"include": ["src/**/*"],
"exclude": ["node_modules", "dist", "**/*.test.*"],
"compilerOptions": {
"rootDir": "src",
}
}
6 changes: 6 additions & 0 deletions packages/wallets/coinbase/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# @reef-knot/wallet-adapter-coinbase

## 2.2.0

### Minor Changes

- Coinbase smart wallet connector

## 2.1.0

### Minor Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/wallets/coinbase/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@reef-knot/wallet-adapter-coinbase",
"version": "2.1.0",
"version": "2.2.0",
"main": "dist/index.js",
"types": "dist/index.d.ts",
"exports": {
Expand Down
10 changes: 7 additions & 3 deletions packages/wallets/coinbase/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,17 @@ export const id = 'coinbase';
export const name = 'Coinbase';
export const rdns = 'com.coinbase.wallet';

export const getCoinbaseConnector = () =>
coinbaseWallet({
preference: 'eoaOnly',
appName: globalThis.window?.location?.hostname,
});

export const Coinbase: WalletAdapterType = ({ providersStore }) => ({
walletName: name,
walletId: id,
type: coinbaseWallet.type,
icon: WalletIcon,
detector: () => isProviderExistsEIP6963(providersStore, rdns),
createConnectorFn: coinbaseWallet({
appName: globalThis.window?.location?.hostname,
}),
createConnectorFn: getCoinbaseConnector(),
});

0 comments on commit aec464d

Please sign in to comment.