Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: batch transaction #287

Merged
merged 28 commits into from
Oct 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
99fe7ff
Merge pull request #276 from blocto/release/0.7.0
akira02 Sep 13, 2023
0ce038b
feat: move dappauth.js repo into packages/dappauth
q20274982 Sep 6, 2023
5f31080
feat: bundling packages/dappauth
q20274982 Sep 6, 2023
1c968a2
build: setup rollup config
q20274982 Sep 12, 2023
a95a1de
feat: configure copy setting
q20274982 Sep 13, 2023
5ae0ff0
chore: changeset
q20274982 Sep 13, 2023
06ab889
refactor: remove no longer used files
q20274982 Sep 13, 2023
b00abfa
Merge pull request #277 from blocto/feat/dappauth-rollup
q20274982 Sep 13, 2023
4835522
fix: use type string instead to support old typescript
akira02 Sep 15, 2023
8c33dec
Merge pull request #280 from blocto/fix/export-type
akira02 Sep 15, 2023
789d275
docs: remove deprecate connectkit demo
q20274982 Sep 13, 2023
19949da
docs: add newest connectkit demo
q20274982 Sep 13, 2023
d99a439
Merge pull request #279 from blocto/docs/update-connectkit-demo
q20274982 Sep 25, 2023
74575c9
fix: dependabot add web3 ignore
sanyu1225 Oct 15, 2023
7ca595a
fix: downgrade web3js to 1.8.0
sanyu1225 Oct 15, 2023
5b3d270
Merge pull request #286 from blocto/fix/example-evm-batch-transaction
sanyu1225 Oct 16, 2023
5b2604d
fix: onlyUpdateData conditions
sanyu1225 Oct 20, 2023
e742f66
chore: add changeset
sanyu1225 Oct 20, 2023
6e4a929
fix: accountChange use addSelfRemovableHandler
sanyu1225 Oct 20, 2023
23f409d
fix: update changelog
sanyu1225 Oct 20, 2023
eba727c
Merge pull request #305 from blocto/fix/evm-account-change
sanyu1225 Oct 20, 2023
eb4f86e
feat: adjust eth_accounts to not require prior enable
q20274982 Oct 23, 2023
90c6bd2
fix: fix connector.ts type
q20274982 Oct 23, 2023
58ef7a0
chore: add changeset
q20274982 Oct 23, 2023
1628d04
Merge pull request #308 from blocto/feat/adjust-eth_accounts-as-not-r…
q20274982 Oct 23, 2023
18c195a
refactor: adjust web3-react-connector's activate method
q20274982 Oct 24, 2023
1d05082
chore: add changeset
q20274982 Oct 24, 2023
012a44c
Merge pull request #309 from blocto/feat/adjust-web3-react-connector-…
q20274982 Oct 24, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/curvy-students-trade.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@blocto/sdk': patch
---

adjust eth_accounts to not require prior enable
10 changes: 10 additions & 0 deletions .changeset/funny-elephants-thank.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
'@blocto/connectkit-connector': patch
'@blocto/rainbowkit-connector': patch
'@blocto/web3-react-connector': patch
'@blocto/web3modal-connector': patch
'@blocto/wagmi-connector': patch
'@blocto/sdk': patch
---

Fix export unreconize type for old typescript
5 changes: 5 additions & 0 deletions .changeset/gorgeous-hairs-yell.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@blocto/web3-react-connector': patch
---

refactor: adjust web3-react-connector's activate method to comply with @blocto/sdk's changes
5 changes: 5 additions & 0 deletions .changeset/new-brooms-refuse.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@blocto/dappauth': minor
---

restructure @blocto/dappauth and using rollup bundle
5 changes: 5 additions & 0 deletions .changeset/six-foxes-add.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@blocto/sdk': patch
---

AccountChange use addSelfRemovableHandler
8 changes: 8 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
version: 2
updates:
- package-ecosystem: 'yarn'
directory: '/'
schedule:
interval: 'daily'
ignore:
- dependency-name: 'web3'
2 changes: 1 addition & 1 deletion adapters/wagmi-connector/src/connector.ts
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ class BloctoConnector extends Connector<BloctoProvider, BloctoOptions> {
account,
chain,
transport: custom(provider),
});
}) as WalletClient;
}

protected onAccountsChanged(): void {
Expand Down
2 changes: 1 addition & 1 deletion adapters/web3-react-connector/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ export class BloctoConnector extends Connector {
!desiredChainId ||
parseChainId(desiredChainId) === parseChainId(this.provider.chainId)
) {
const accounts = await this.provider.request({ method: 'eth_accounts' });
const accounts = await this.provider.request({ method: 'eth_requestAccounts' });
return this.actions.update({
chainId: parseChainId(this.provider.chainId),
accounts,
Expand Down
2 changes: 1 addition & 1 deletion examples/with-evm-blocto-batch-transaction/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"react-dom": "^18.2.0",
"react-scripts": "5.0.1",
"web-vitals": "^2.1.4",
"web3": "^4.1.1"
"web3": "^1.8.0"
},
"scripts": {
"start": "react-scripts start",
Expand Down
1,775 changes: 1,538 additions & 237 deletions examples/with-evm-blocto-batch-transaction/yarn.lock

Large diffs are not rendered by default.

32 changes: 28 additions & 4 deletions examples/with-evm-connectkit/.gitignore
Original file line number Diff line number Diff line change
@@ -1,23 +1,47 @@
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.

# dependencies

/node_modules
/.pnp
.pnp.js

# testing

/coverage

# vite

dist
dist-ssr

# production

/build

# misc

.DS_Store
.env.local
.env.development.local
.env.test.local
.env.production.local
\*.pem
*.local

# debug

npm-debug.log*
yarn-debug.log*
yarn-error.log*
.pnpm-debug.log*

# local env files

.env
.env\*.local

# vercel

.vercel

# typescript

\*.tsbuildinfo
next-env.d.ts
21 changes: 17 additions & 4 deletions examples/with-evm-connectkit/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,19 @@
# [Create React App](https://github.com/facebook/create-react-app) + [TypeScript](https://www.typescriptlang.org/) + ConnectKit Example
This is a [wagmi](https://wagmi.sh) + [ConnectKit](https://docs.family.co/connectkit) project bootstrapped with [Create React App](https://github.com/facebook/create-react-app), Simultaneously Integrating [Blocto](https://blocto.io) wallet.

This is a simple example of how to implement ConnectKit with [Create React App](https://github.com/facebook/create-react-app) in TypeScript.
# Getting Started

- If you'd like to look at an example online, try this [CodeSandbox](https://codesandbox.io/s/5rhqm0?file=/README.md)
- If you want to run the example locally have a look at the [instructions in the main README](https://github.com/family/connectkit/blob/main/README.md#running-examples-locally)
### `npm start`

Runs the app in the development mode.\
Open [http://localhost:3000](http://localhost:3000) to view it in your browser.

The page will reload when you make changes.\
You may also see any lint errors in the console.

# Learn more

To learn more about [ConnectKit](https://docs.family.co/connectkit) or [wagmi](https://wagmi.sh), check out the following resources:

- [wagmi Documentation](https://wagmi.sh) – learn about wagmi Hooks and API.
- [wagmi Examples](https://wagmi.sh/examples/connect-wallet) – a suite of simple examples using wagmi.
- [ConnectKit Documentation](https://docs.family.co/connectkit) – learn more about ConnectKit (configuration, theming, advanced usage, etc).
42 changes: 24 additions & 18 deletions examples/with-evm-connectkit/package.json
Original file line number Diff line number Diff line change
@@ -1,32 +1,38 @@
{
"name": "cra",
"version": "0.0.0",
"name": "with-evm-connectkit",
"version": "0.1.0",
"private": true,
"dependencies": {
"@testing-library/jest-dom": "^5.16.5",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-scripts": "5.0.1",
"util": "^0.12.4",
"viem": "~0.3.36",
"wagmi": "^1.0.6",
"@blocto/connectkit-connector": "latest",
"connectkit": "1.5.3"
},
"devDependencies": {
"@testing-library/jest-dom": "^5.17.0",
"@testing-library/react": "^13.4.0",
"@testing-library/user-event": "^13.5.0",
"@types/jest": "^27.5.2",
"@types/node": "^16.11.59",
"@types/react": "^18.0.20",
"@types/react-dom": "^18.0.6",
"connectkit": "^1",
"react": "^18.0.0",
"react-dom": "^18.0.0",
"react-scripts": "5.0.1",
"typescript": "^4.9.5",
"viem": "^1.0.0",
"wagmi": "^1.1.1",
"web-vitals": "^2.1.4",
"use-debounce": "^9.0.4"
"@types/node": "^16.18.43",
"@types/react": "^18.2.21",
"@types/react-dom": "^18.2.7",
"typescript": "^4.9.5"
},
"scripts": {
"dev": "react-scripts start",
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject",
"lint": "eslint src --ext .ts"
"eject": "react-scripts eject"
},
"eslintConfig": {
"extends": [
"react-app",
"react-app/jest"
]
},
"browserslist": {
"production": [
Expand Down
29 changes: 24 additions & 5 deletions examples/with-evm-connectkit/public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,35 @@
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="theme-color" content="#000000" />
<meta
name="viewport"
content="width=device-width, initial-scale=1, maximum-scale=1"
name="description"
content="Web site created using create-react-app"
/>
<meta name="theme-color" content="#000000" />
<meta name="description" content="ConnectKit CRA Example" />
<title>ConnectKit CRA Example</title>
<!--
Notice the use of %PUBLIC_URL% in the tags above.
It will be replaced with the URL of the `public` folder during the build.
Only files inside the `public` folder can be referenced from the HTML.
Unlike "/favicon.ico" or "favicon.ico", "%PUBLIC_URL%/favicon.ico" will
work correctly both with client-side routing and a non-root public URL.
Learn how to configure a non-root public URL by running `npm run build`.
-->
<title>React App</title>
</head>
<body>
<noscript>You need to enable JavaScript to run this app.</noscript>
<div id="root"></div>
<!--
This HTML file is a template.
If you open it directly in the browser, you will see an empty page.
You can add webfonts, meta tags, or analytics to this file.
The build step will place the bundled scripts into the <body> tag.
To begin the development, run `npm start` or `yarn start`.
To create a production bundle, use `npm run build` or `yarn build`.
-->
</body>
</html>
3 changes: 0 additions & 3 deletions examples/with-evm-connectkit/public/robots.txt

This file was deleted.

47 changes: 27 additions & 20 deletions examples/with-evm-connectkit/src/App.tsx
Original file line number Diff line number Diff line change
@@ -1,32 +1,39 @@
import { ConnectKitButton } from 'connectkit';
import { useAccount } from 'wagmi';
import SignMessage from './components/SignMessage';
import SendTransaction from './components/SendTransaction';
import { useAccount } from 'wagmi'

function App() {
const { isConnected } = useAccount();
import { NetworkSwitcher } from './components/NetworkSwitcher'
import { SendTransaction } from './components/SendTransaction'
import { SignMessage } from './components/SignMessage'
import { SignTypedData } from './components/SignTypedData'
import { ConnectKitButton } from 'connectkit'

export function App() {
const { isConnected } = useAccount()

return (
<div
style={{
display: 'flex',
flexDirection: 'column',
alignItems: 'center',
justifyContent: 'center',
gap: '10px',
height: '100vh',
}}
>
<>
<h1>wagmi + Connectkit</h1>

<ConnectKitButton />

{isConnected && (
<>
<hr />
<h2>Network</h2>
<NetworkSwitcher />
<br />
<hr />
<h2>Send Transaction</h2>
<SendTransaction />
<br />
<hr />
<h2>Sign Message</h2>
<SignMessage />
<br />
<hr />
<h2>Sign Typed Data</h2>
<SignTypedData />
</>
)}
</div>
);
</>
)
}

export default App;
32 changes: 32 additions & 0 deletions examples/with-evm-connectkit/src/components/Connect.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import { BaseError } from 'viem'
import { useAccount, useConnect, useDisconnect } from 'wagmi'

export function Connect() {
const { connector, isConnected } = useAccount()
const { connect, connectors, error, isLoading, pendingConnector } =
useConnect()
const { disconnect } = useDisconnect()

return (
<div>
<div>
{isConnected && (
<button onClick={() => disconnect()}>
Disconnect from {connector?.name}
</button>
)}

{connectors
.filter((x) => x.ready && x.id !== connector?.id)
.map((x) => (
<button key={x.id} onClick={() => connect({ connector: x })}>
{x.name}
{isLoading && x.id === pendingConnector?.id && ' (connecting)'}
</button>
))}
</div>

{error && <div>{(error as BaseError).shortMessage}</div>}
</div>
)
}
8 changes: 8 additions & 0 deletions examples/with-evm-connectkit/src/components/Connected.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { useAccount } from 'wagmi'

export function Connected({ children }: { children: React.ReactNode }) {
const { isConnected } = useAccount()

if (!isConnected) return null
return <>{children}</>
}
32 changes: 32 additions & 0 deletions examples/with-evm-connectkit/src/components/NetworkSwitcher.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import { useNetwork, useSwitchNetwork } from 'wagmi'

export function NetworkSwitcher() {
const { chain } = useNetwork()
const { chains, error, isLoading, pendingChainId, switchNetwork } =
useSwitchNetwork()

return (
<div>
<div>
Connected to {chain?.name ?? chain?.id}
{chain?.unsupported && ' (unsupported)'}
</div>
<br />
{switchNetwork && (
<div>
Switch to:{' '}
{chains.map((x) =>
x.id === chain?.id ? null : (
<button key={x.id} onClick={() => switchNetwork(x.id)}>
{x.name}
{isLoading && x.id === pendingChainId && ' (switching)'}
</button>
),
)}
</div>
)}

<div>{error?.message}</div>
</div>
)
}
Loading