-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #108 from lidofinance/feature/adapter-coinbase
Coinbase Wallet Adapter
- Loading branch information
Showing
28 changed files
with
247 additions
and
112 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
53 changes: 53 additions & 0 deletions
53
packages/connect-wallet-modal/src/connectButtons/ConnectCoinbase.tsx
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,53 @@ | ||
import React, { FC, useCallback } from 'react'; | ||
import { useConnect } from 'wagmi'; | ||
import { useDisconnect } from '@reef-knot/web3-react'; | ||
import { ConnectButton } from '../components/ConnectButton'; | ||
import { ConnectInjectedProps } from './types'; | ||
|
||
export const ConnectCoinbase: FC<ConnectInjectedProps> = ( | ||
props: ConnectInjectedProps, | ||
) => { | ||
const { | ||
onConnect, | ||
onBeforeConnect, | ||
setRequirements, | ||
shouldInvertWalletIcon, | ||
metrics, | ||
walletId, | ||
walletName, | ||
icon: WalletIcon, | ||
downloadURLs, | ||
detector, | ||
connector, | ||
...rest | ||
} = props; | ||
|
||
const metricsOnConnect = metrics?.events?.connect?.handlers.onConnectCoinbase; | ||
const metricsOnClick = metrics?.events?.click?.handlers.onClickCoinbase; | ||
|
||
const { connect } = useConnect({ | ||
onSuccess() { | ||
onConnect?.(); | ||
metricsOnConnect?.(); | ||
}, | ||
}); | ||
const { disconnect } = useDisconnect(); | ||
|
||
const handleConnect = useCallback(() => { | ||
onBeforeConnect?.(); | ||
metricsOnClick?.(); | ||
disconnect?.(); | ||
connect({ connector }); | ||
}, [connect, connector, disconnect, metricsOnClick, onBeforeConnect]); | ||
|
||
return ( | ||
<ConnectButton | ||
{...rest} | ||
icon={WalletIcon} | ||
shouldInvertWalletIcon={shouldInvertWalletIcon} | ||
onClick={handleConnect} | ||
> | ||
{walletName} | ||
</ConnectButton> | ||
); | ||
}; |
33 changes: 0 additions & 33 deletions
33
packages/connect-wallet-modal/src/connectButtons/connectCoinbase.tsx
This file was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -1,5 +1,5 @@ | ||
export { default as ConnectCoinbase } from './connectCoinbase'; | ||
export { default as ConnectLedger } from './connectLedger'; | ||
export { default as ConnectMetamask } from './connectMetamask'; | ||
export * from './ConnectInjected'; | ||
export * from './ConnectWC'; | ||
export * from './ConnectCoinbase'; |
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,9 @@ | ||
{ | ||
"root": true, | ||
"extends": [ | ||
"custom" | ||
], | ||
"rules": { | ||
"import/no-extraneous-dependencies": "warn" | ||
} | ||
} |
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,43 @@ | ||
{ | ||
"name": "@reef-knot/wallet-adapter-coinbase", | ||
"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": "^1.3.0", | ||
"@svgr/rollup": "^6.5.1", | ||
"eslint-config-custom": "*" | ||
}, | ||
"peerDependencies": { | ||
"wagmi": "^0.12.19", | ||
"@reef-knot/types": "^1.2.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,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, | ||
}); |
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,4 @@ | ||
declare module '*.svg' { | ||
const content: React.FunctionComponent<React.SVGAttributes<SVGElement>>; | ||
export default content; | ||
} |
File renamed without changes
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 @@ | ||
export { default as WalletIcon } from './coinbase.svg'; |
Oops, something went wrong.