Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
wenty22 committed Dec 13, 2023
2 parents 60e42a9 + 82e3521 commit 5453dc5
Show file tree
Hide file tree
Showing 70 changed files with 799 additions and 510 deletions.
3 changes: 1 addition & 2 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
.next
dist
CHANGELOG.md
build.cjs
**/*.md
19 changes: 19 additions & 0 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,22 @@
- [ ] I have read the **CONTRIBUTING** document.
- [ ] I have added tests to cover my changes.
- [ ] All new and existing tests passed.

## For adding a new wallet

For more detail, please click [here](../CONTRIBUTING.md#notice-test-cases-for-adding-a-new-wallet)

<!--- If you are adding a new wallet, we hope you can complete the following tests before the code is merged into the main branch -->
|test case|support?|connected?|switch networks?|support testnet?|
|-|-|-|-|-|
|PC, browser extension| ✔️ | ✔️ |||
|Android, in system browser| | | | |
|Android, in wallet dapp browser| | | | |
|iOS, in system browser| | | | |
|iOS, in wallet dapp browser| | | | |
|WalletConnect, PC| | | | |
|WalletConnect, Android, in system browser| | | | |
|WalletConnect, Android, in wallet dapp browser| | | | |
|WalletConnect, iOS, in system browser| | | | |
|WalletConnect, iOS, in wallet dapp browser| | | | |

25 changes: 25 additions & 0 deletions .github/actions/setup/action.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: 'setup'
description: Prepare the environment

runs:
using: composite
steps:
- name: Setup node.js
uses: actions/setup-node@v3
with:
node-version: 16

- name: Setup pnpm
uses: pnpm/action-setup@v2
id: pnpm-install
with:
version: 8
run_install: false

- name: Setup pnpm config
shell: bash
run: pnpm config set store-dir .pnpm-store

- name: Install dependencies
shell: bash
run: pnpm install
38 changes: 38 additions & 0 deletions .github/workflows/docs.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: Deploy docs
on:
push:
branches:
- main
- alpha

jobs:
release:
name: deploy docs
if: github.repository == 'node-real/walletkit'
timeout-minutes: 10
runs-on: ubuntu-latest
steps:
- name: Checkout code repository
uses: actions/checkout@v3
with:
fetch-depth: 0

- uses: ./.github/actions/setup

- name: Build docs
run: pnpm build:docs

- name: Redirect
run: |
mkdir -p ./website/dist/website/dist
cat << EOF > "./website/dist/website/dist/index.html"
<script>window.location.href='https://node-real.github.io/walletkit'</script>
EOF
- name: Deploy docs
uses: JamesIves/github-pages-deploy-action@v4
with:
folder: ./website/dist
branch: 'docs'
clean: true
force: true
30 changes: 6 additions & 24 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,35 +3,26 @@ on:
push:
branches:
- main
- alpha
- 0.x

env:
CI: true
PNPM_CACHE_FOLDER: .pnpm-store
- 0.x-alpha

jobs:
release:
name: release
if: github.repository == 'node-real/walletkit'
timeout-minutes: 15
timeout-minutes: 10
runs-on: ubuntu-latest
steps:
- name: Checkout code repository
uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Setup node.js
uses: actions/setup-node@v3
with:
node-version: 16
- uses: ./.github/actions/setup

- name: Setup pnpm
uses: pnpm/action-setup@v2
id: pnpm-install
with:
version: 8
run_install: false
- name: Build packages
run: pnpm build

- name: Creating .npmrc
run: |
Expand All @@ -41,15 +32,6 @@ jobs:
env:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}

- name: Setup pnpm config
run: pnpm config set store-dir $PNPM_CACHE_FOLDER

- name: Install dependencies
run: pnpm install

- name: Build packages
run: pnpm --filter "@totejs/**" build

- name: Create and publish versions
uses: changesets/action@v1
with:
Expand Down
2 changes: 1 addition & 1 deletion .prettierignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
.next
dist
CHANGELOG.md
**/*.md
32 changes: 26 additions & 6 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,11 @@ Before adding a new wallet, you need to collect some information:

| item | description | e.g. | required |
| ------------------ | --------------------------------------------------------------------------------------------------- | ----------------------------------- | -------- |
| wallet name | - | Trust Wallet | yes |
| wallet name | - | Trust Wallet | ✔️ |
| short name | If display space is insufficient, the short name will be displayed. | Trust | optional |
| wallet logo | logo in svg format. | - | yes |
| download url | - | https://trustwallet.com/download | yes |
| deeplink | After clicking deeplink in the system browser, we can directly open dapp in the app's dapp browser. | trust://open_url?coin_id=60&url=xxx | yes |
| wallet logo | logo in svg format. | - | ✔️ |
| download url | - | https://trustwallet.com/download | ✔️ |
| deeplink | After clicking deeplink in the system browser, we can directly open dapp in the app's dapp browser. | trust://open_url?coin_id=60&url=xxx | ✔️ |
| WalletConnect link | If your app supports WalletConnect, please provides the WalletConnect uri. | trust://wc?uri=xxx | optional |

Then you can add it to project by following steps:
Expand Down Expand Up @@ -117,7 +117,7 @@ export function trustWallet(props: TrustWalletProps = {}): WalletProps {
default: 'https://trustwallet.com/',
},
spinnerColor: '#1098FC',
installed: isTrustWallet(),
isInstalled: isTrustWallet,
createConnector: (chains: Chain[]) => {
return new TrustWalletConnector({
chains,
Expand Down Expand Up @@ -163,7 +163,7 @@ export interface WalletProps {
};
spinnerColor?: string;
showQRCode?: boolean;
installed: boolean | undefined;
isInstalled: () => boolean | undefined;
createConnector: (chains: Chain[]) => Connector;
getDeepLink: () => string | undefined;
getQRCodeUri?: (uri: string) => string;
Expand Down Expand Up @@ -205,6 +205,26 @@ const config = createConfig(
);
```
## Notice!!! Test cases for adding a new wallet
Before merging the PR to main branch, we hope you complete the following tests, and fill the test results into the PR template, otherwise the PR may not be approved.
In general, wallet is available at several different platforms, such as PC browser extension, Android, iOS and WalletConnect. If your wallet supports the corresponding platform, please make sure your wallet is worked, can it be connected, can it switch networks, and can it support testnet?
|test case|steps|support?|connected?|switch networks?|support testnet?|
|-|-|-|-|-|-|
|PC, browser extension|<ol><li>Open dapp in PC browser</li><li>Select your wallet, check the functions</li><ol>|✔️|✔️|✔️|✔️|
|Android, in system browser|<ol><li>Open dapp in Android system browser, select your wallet</li><li>The wallet app will be evoked, and the dapp will be open in the wallet dapp browser</li><li>Select your wallet, check the functions</li></ol>|✔️|✔️|❌|✔️|
|Android, in wallet dapp browser|<ol><li>Open dapp in the wallet dapp browser</li><li>Select your wallet, check the functions</li><ol>|✔️|✔️|✔️|✔️|
|iOS, in system browser|<ol><li>Open dapp in iOS system browser, select your wallet</li><li>The wallet app will be evoked, and the dapp will be open in the wallet dapp browser</li><li>Select your wallet, check the functions</li></ol>|✔️|✔️|✔️|❌|
|iOS, in wallet dapp browser|<ol><li>Open dapp in the wallet dapp browser </li><li>Select your wallet, check the functions</li></ol>|✔️|✔️|✔️|❌|
|WalletConnect, PC|<ol><li>Scan the QR code of WalletConnect using your wallet app</li><li>You will see a popup on the wallet app that asks you to connect WalletConnect</li><li>Check the functions</li></ol>|✔️|✔️|✔️|✔️|
|WalletConnect, Android, in system browser|<ol><li>Open dapp in Android system browser, select WalletConnect, choose your wallet in WalletConnect wallet list</li><li>The wallet app will be evoked, a popup for applying to connect WalletConnect will be displayed. </li><li>Check the functions</li></ol>|✔️|✔️|✔️|✔️|
|WalletConnect, Android, in wallet dapp browser|<ol><li>Open dapp in the wallet dapp browser</li><li>Select WalletConnect, choose your wallet in WalletConnect wallet list</li><li>A popup for applying to connect WalletConnect will be displayed</li><li>Check the functions</li><ol>|✔️|✔️|✔️|✔️|
|WalletConnect, iOS, in system browser|<ol><li>Open dapp in iOS system browser, select WalletConnect, choose your wallet in WalletConnect wallet list</li><li>The wallet app will be evoked, a popup for applying to connect WalletConnect will be displayed. </li><li>Check the functions</li></ol>|✔️|✔️|✔️|✔️|
|WalletConnect, iOS, in wallet dapp browser|<ol><li>Open dapp in the wallet dapp browser</li><li>Select WalletConnect, choose your wallet in WalletConnect wallet list</li><li>A popup for applying to connect WalletConnect will be displayed</li><li>Check the functions</li><ol>|✔️|✔️|✔️|✔️|
## Release notes
A complete development workflow like following:
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@ WalletKit is a React component library for easily connecting a wallet to your dA

## Documentation

For full documentation, visit [here](https://node-real.github.io/walletkit/website/dist/#/index).
For full documentation, visit [here](https://node-real.github.io/walletkit).

## Examples

The following examples are provided in the [examples](./examples/) folder of this repo.

- [nextjs](https://github.com/node-real/walletkit/tree/main/examples/nextjs)
- [vite](https://github.com/node-real/walletkit/tree/main/examples/vite)
- [nextjs](./examples/nextjs/)
- [vite](./examples/vite/)

## Installation

Expand Down
4 changes: 2 additions & 2 deletions examples/nextjs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@
"next": "^13.5.6",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"viem": "^1.19.8",
"viem": "^1.19.9",
"wagmi": "^1.4.7"
},
"devDependencies": {
"@types/node": "^20.10.0",
"@types/react": "^18.2.38",
"@types/react": "^18.2.39",
"@types/react-dom": "^18.2.17",
"typescript": "^5.3.2"
}
Expand Down
2 changes: 1 addition & 1 deletion examples/nextjs/pages/_app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ const config = createConfig(
);

const options: WalletKitOptions = {
initialChainId: 56,
initialChainId: 1,
};

export default function App({ Component, pageProps }: AppProps) {
Expand Down
2 changes: 2 additions & 0 deletions examples/nextjs/pages/_document.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
import { Html, Head, Main, NextScript } from 'next/document';
import { EthereumScript } from '@totejs/walletkit';

export default function Document() {
return (
<Html lang="en">
<Head>
<title>WalletKit Next.js Example</title>
<EthereumScript />
</Head>
<body>
<Main />
Expand Down
4 changes: 2 additions & 2 deletions examples/vite/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@
"@totejs/walletkit": "workspace:*",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"viem": "^1.19.8",
"viem": "^1.19.9",
"wagmi": "^1.4.7"
},
"devDependencies": {
"@types/react": "^18.2.38",
"@types/react": "^18.2.39",
"@types/react-dom": "^18.2.17",
"@vitejs/plugin-react": "^4.2.0",
"typescript": "^5.3.2",
Expand Down
2 changes: 1 addition & 1 deletion examples/vite/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ const config = createConfig(
);

const options: WalletKitOptions = {
initialChainId: 56,
initialChainId: 1,
};

export default function App() {
Expand Down
13 changes: 9 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,17 @@
"scripts": {
"prepare": "husky install",
"lint": "pnpm eslint .",
"dev": "pnpm --filter @totejs/walletkit dev",
"ci:version": "pnpm changeset version && pnpm install && cp README.md packages/walletkit/README.md",
"ci:publish": "pnpm publish -r"
"dev": "pnpm --F @totejs/walletkit dev",
"build": "pnpm --F @totejs/walletkit build",
"dev:docs": "pnpm --F @totejs/walletkit build:watch & pnpm --F website dev",
"build:docs": "pnpm --F @totejs/walletkit build && pnpm --F website build",
"pre:enter": "pnpm changeset pre enter alpha",
"pre:exit": "pnpm changeset pre exit",
"ci:version": "pnpm changeset version && cp README.md packages/walletkit/README.md",
"ci:publish": "pnpm changeset publish"
},
"devDependencies": {
"@changesets/cli": "^2.26.2",
"@changesets/cli": "^2.27.1",
"@commitlint/cli": "^18.4.3",
"@commitlint/config-conventional": "^18.4.3",
"@typescript-eslint/eslint-plugin": "^5.62.0",
Expand Down
Loading

0 comments on commit 5453dc5

Please sign in to comment.