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

feat: account kit #2623

Closed
wants to merge 261 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
261 commits
Select commit Hold shift + click to select a range
83bea14
expose connect pending state
holic Apr 8, 2024
0a564f5
various style tweaks
holic Apr 8, 2024
3f5644a
remove unused dep
holic Apr 8, 2024
bbaba1b
fix scroll issue
holic Apr 8, 2024
0ebda7f
Revert "remove unused dep"
holic Apr 8, 2024
1552c1e
back to tsup
holic Apr 8, 2024
d4ed96f
set button variants
holic Apr 8, 2024
0b14798
css text loader
holic Apr 8, 2024
f12642a
add todos
holic Apr 9, 2024
22e994c
move mud-specific utils to utils dir for now
holic Apr 9, 2024
72c4c8c
mud-login -> account-kit
holic Apr 9, 2024
20da417
more renaming
holic Apr 9, 2024
56009de
log in -> sign in
holic Apr 9, 2024
8b88d81
organize
holic Apr 9, 2024
af511f8
refactor with modal sidebar
holic Apr 9, 2024
b46bd81
quick pass at sign in button
holic Apr 9, 2024
cf1b9e7
fleshing out modal
holic Apr 9, 2024
122d043
temp connected content
holic Apr 9, 2024
5abf396
close modal on disconnect
holic Apr 11, 2024
50c339d
signer per account
holic Apr 11, 2024
133beb7
Merge remote-tracking branch 'origin/main' into account-kit
holic Apr 12, 2024
b0fe740
Merge remote-tracking branch 'origin/main' into account-kit
holic Apr 12, 2024
14c63c2
attempt to resolve issue with connect vs account modal
holic Apr 12, 2024
7a32dbe
rework connect approach
holic Apr 12, 2024
6266226
add todo
holic Apr 12, 2024
1e406c2
Merge remote-tracking branch 'origin/main' into account-kit
holic Apr 12, 2024
17946aa
don't switch chains
holic Apr 12, 2024
d0fd101
fix: storage slot computation
alvrs Apr 12, 2024
935f3c3
add chain switch to deposit
holic Apr 12, 2024
cfd7637
simplify
holic Apr 12, 2024
f8cb6be
worldChainId -> chainId
holic Apr 12, 2024
f227065
selectable onboarding steps
holic Apr 12, 2024
9b6d2f1
refetch gas balance
holic Apr 12, 2024
c3b2a99
don't shrink sidebar
holic Apr 12, 2024
a85c056
add todo
holic Apr 12, 2024
223190a
remove unused screen
holic Apr 13, 2024
48a456b
advance to next step
holic Apr 13, 2024
a8c991c
shadow forward ref
holic Apr 13, 2024
b1a5f35
dropdown menu
holic Apr 13, 2024
fe2aa7c
transition tweaks
holic Apr 13, 2024
d800123
ens name/avatar
holic Apr 13, 2024
7d2d974
more light/dark mode variants
holic Apr 13, 2024
4952044
rework buttons
holic Apr 14, 2024
5b7c403
feat(account-kit): add cli for local bundler setup (#2653)
alvrs Apr 14, 2024
47a6943
wip signer
holic Apr 14, 2024
e007aef
fix(gas-tank): dev command
alvrs Apr 14, 2024
3b3c9ee
finish up signer screen
holic Apr 14, 2024
a2a6050
show check for completed steps
holic Apr 14, 2024
a91ac18
feat(account-kit): bridging (#2629)
karooolis Apr 14, 2024
3ba04bf
message signature, pull out app info
holic Apr 14, 2024
92ebdcf
Merge remote-tracking branch 'origin/main' into account-kit
holic Apr 14, 2024
069308c
don't refetch image
holic Apr 14, 2024
b102a59
private key
holic Apr 14, 2024
6a6ab3c
fill in sign in step
holic Apr 15, 2024
35a2dcc
rework steps order
holic Apr 15, 2024
46d2d1c
garnet redeploy
karooolis Apr 15, 2024
3853f72
rename
holic Apr 15, 2024
97ed299
rework app account modal with both signatures
holic Apr 15, 2024
3115c64
reset step after signing
holic Apr 15, 2024
38c0351
rework AccountModal to always be mounted as part of provider
holic Apr 15, 2024
8b219a4
separate bundle for mounting
holic Apr 15, 2024
4a0f4c5
fix export
holic Apr 15, 2024
424d69b
remove unused package
holic Apr 15, 2024
e929653
show deposit method based on source/app chain
karooolis Apr 16, 2024
010fed3
deposit content screen based on source/app chain
karooolis Apr 16, 2024
976368f
clean-up direct deposit
karooolis Apr 16, 2024
829b794
Merge remote-tracking branch 'origin/main' into account-kit
holic Apr 16, 2024
5f1f926
update lockfile
holic Apr 16, 2024
2de4786
add finalizing step
holic Apr 16, 2024
6a4bc02
fix opening bug
holic Apr 16, 2024
cafb1a0
fix finalizing requirements
holic Apr 16, 2024
cc3d95e
feat(account-kit): separate bundled export for non-react environments…
holic Apr 16, 2024
c938886
add hook to return app account client only after all requirements are…
holic Apr 16, 2024
b66fbff
Merge remote-tracking branch 'origin/main' into account-kit
holic Apr 16, 2024
1a79a2e
update message with account instead of address
holic Apr 16, 2024
de34cb1
Merge remote-tracking branch 'origin/main' into account-kit
holic Apr 16, 2024
848b699
add initial chain select
karooolis Apr 16, 2024
f03bee7
add direct deposit estimates layout
karooolis Apr 16, 2024
c2d6c80
direct deposit set amount
karooolis Apr 16, 2024
82c4cc6
just export the store
holic Apr 16, 2024
3e758a9
add bundle dts
holic Apr 16, 2024
530249e
Merge remote-tracking branch 'origin/main' into account-kit
holic Apr 16, 2024
65578d9
integration tweaks
holic Apr 16, 2024
e7a88ef
allow setting theme
holic Apr 16, 2024
b423aa4
dont ignore worldjson
alvrs Apr 16, 2024
5258e9b
reduce min balance
alvrs Apr 16, 2024
af0c1b9
extend with all public actions
alvrs Apr 16, 2024
b3773cd
fix extend
alvrs Apr 16, 2024
bb03c15
dont override prepareTransaction
alvrs Apr 16, 2024
40dbabf
differ gas tank states (wip)
karooolis Apr 16, 2024
8aedfaa
fix pnpm-lock
karooolis Apr 17, 2024
cc979e4
show gas tank top states based on amount input
karooolis Apr 17, 2024
c082ddc
log stuff
holic Apr 17, 2024
cad886e
fix reading contracts from public client
alvrs Apr 17, 2024
bae1af1
show estimate tx fees
karooolis Apr 17, 2024
7290909
estimate actions per top-up
karooolis Apr 17, 2024
329d542
use public actions on app account client
alvrs Apr 17, 2024
253d1b9
refactor to common bridge components (amount, chain, fees)
karooolis Apr 17, 2024
8dd3cc6
useDirectDeposit hook, common amount input
karooolis Apr 17, 2024
77bec70
add debug logs
alvrs Apr 17, 2024
100263a
add useDepositQuery
karooolis Apr 17, 2024
c26aa75
move submit handlers to hooks (direct, standard deposit)
karooolis Apr 17, 2024
b00fe4e
refactor record fetching
holic Apr 17, 2024
aafbd88
fix query invalidation after rebase
holic Apr 17, 2024
4938c83
deposit layout cleanup
karooolis Apr 17, 2024
2749da0
fix select zindex
holic Apr 17, 2024
5a1ddeb
add link to radix code
holic Apr 17, 2024
f567799
default gas tank to one on the chain
holic Apr 17, 2024
02801dd
wip bundler as rpc url
holic Apr 17, 2024
81fcc07
Merge remote-tracking branch 'origin/main' into account-kit
holic Apr 17, 2024
275f169
add direct bridge deposit + success
karooolis Apr 17, 2024
0524971
format available balance
karooolis Apr 17, 2024
cf73bcf
wait for balance to increase for success
karooolis Apr 17, 2024
24e3202
remove unused components
karooolis Apr 17, 2024
f92d5b1
make smart account client work with viem bundle
alvrs Apr 17, 2024
2b06b95
fix dev command
holic Apr 17, 2024
c52c180
Merge remote-tracking branch 'origin/main' into account-kit
holic Apr 17, 2024
3a61a77
try peer deps
holic Apr 17, 2024
86de905
optional peer deps
holic Apr 17, 2024
1a75a0b
update lockfile
holic Apr 17, 2024
555cf8c
worlds.json address hex
holic Apr 17, 2024
9ae2be0
ignore npm pack files
holic Apr 17, 2024
bdf954c
try installing gas-tank
holic Apr 17, 2024
d954220
missing return
holic Apr 17, 2024
e29266b
try npm install
holic Apr 17, 2024
f6c9277
usePrevious for prev gasTankBalance
karooolis Apr 17, 2024
cd7e3f6
useDepositHandler for all deposit types refactor
karooolis Apr 18, 2024
c2b07d7
set initial deposit method directly in state
karooolis Apr 18, 2024
43ab567
track balance for deposit completion
karooolis Apr 18, 2024
325440e
show correct user balance + hardcode estimate time
karooolis Apr 18, 2024
4d00905
add approx. fee estimates
karooolis Apr 18, 2024
eb0aa83
fix local bundler (i'm sorry frolic)
alvrs Apr 18, 2024
e799d1c
move from shadow dom to iframes
holic Apr 18, 2024
926691f
update gas tank address
holic Apr 18, 2024
c07a1d3
fix chain select
holic Apr 18, 2024
f475021
dark mode bridge styles
karooolis Apr 18, 2024
c002251
remove unused button prop
karooolis Apr 18, 2024
12006ec
fix account button dropdown
holic Apr 18, 2024
d578faf
more logging for transport observer
alvrs Apr 18, 2024
73fc2f6
small tweaks
holic Apr 18, 2024
6f8afcb
didn't mean to leave that in
holic Apr 18, 2024
c0383ee
rework config
holic Apr 18, 2024
4855275
more aggressive polling
alvrs Apr 18, 2024
0339cb4
improve error styling + bridge inputs as form
karooolis Apr 19, 2024
cff3979
improve input amount handling
karooolis Apr 19, 2024
dc21f11
use pimlico_getUserOperationStatus api if available
alvrs Apr 19, 2024
b94a2bd
single mount point
holic Apr 19, 2024
9df4640
handle container synchronously
holic Apr 19, 2024
8f1b9eb
clean up root container
holic Apr 19, 2024
09748da
rename gas-tank to deposit
holic Apr 19, 2024
8851a78
disable outline on dialog content
holic Apr 19, 2024
5c323d3
update type
alvrs Apr 19, 2024
22938ac
fix action order to make callFrom work
alvrs Apr 19, 2024
c5963b3
migrate away from useAppAccount hook
holic Apr 19, 2024
4be322e
move things around so bg doesn't impact slide in
holic Apr 19, 2024
f09dcb6
return app signer client if no erc4337 config
holic Apr 19, 2024
4877853
add vite react plugin
holic Apr 19, 2024
5e1a248
conditional deposit flow based on client type
holic Apr 19, 2024
586b9be
Merge remote-tracking branch 'origin/main' into account-kit
holic Apr 19, 2024
b657fd8
remove deps that should be peer deps and unused deps
holic Apr 19, 2024
f2f48ad
latency improvements for submitting user operations (#2697)
alvrs Apr 19, 2024
7c568fb
remove unused dep
holic Apr 20, 2024
88feb72
add dev server for easier local dev, rearrange components for hot rel…
holic Apr 20, 2024
1fd65dc
add dev tsconfig
holic Apr 20, 2024
a3e5d77
playing with border gradients
holic Apr 20, 2024
686611d
double gradient with highlight
holic Apr 22, 2024
49e54f3
set up local world deploy
holic Apr 22, 2024
a28c27e
wip account kit deposit (#2730)
holic Apr 25, 2024
46c44c7
Merge remote-tracking branch 'origin/main' into account-kit
holic Apr 25, 2024
7bb60d3
fix sign call
holic Apr 25, 2024
24867a0
testing other chains
holic Apr 25, 2024
bca5dbd
remove unused files
holic Apr 25, 2024
8e96908
bump wagmi
holic Apr 26, 2024
4d2e526
fill in connected wallet screen
holic Apr 26, 2024
38d6040
don't show finalizing if complete
holic Apr 26, 2024
983339c
rename to playground
holic Apr 26, 2024
bb13a08
also run mud
holic Apr 26, 2024
3ddf8be
eth symbol in amount input
holic Apr 26, 2024
78abd44
rework input and submit
holic Apr 26, 2024
910d64a
Merge remote-tracking branch 'origin/main' into account-kit
holic Apr 26, 2024
2399178
fixes after merge
holic Apr 26, 2024
cf664e6
fix chain icon ref
holic Apr 26, 2024
1e40a68
estimate bridge gas
holic Apr 26, 2024
5b24a53
add back in chain types
holic Apr 26, 2024
3870902
disable button if not enough funds, hardcode time estimate
holic Apr 26, 2024
6e51dda
clean up
holic Apr 26, 2024
58ac2c2
fill in signing key screen
holic Apr 27, 2024
28c29a4
show bridge txs
holic Apr 28, 2024
657d162
add revoke button for testing
holic Apr 28, 2024
9a4e6cd
Merge remote-tracking branch 'origin/main' into account-kit
holic Apr 28, 2024
4d25913
more tests
holic Apr 28, 2024
54cc61c
local deploy with callwithsignature module
holic Apr 28, 2024
794861c
rework playground chains to configurable by url param
holic Apr 28, 2024
64ef7c5
set up some real playgrounds
holic Apr 28, 2024
6f3f62d
clean up dark mode
holic Apr 28, 2024
d9672df
rework finalizing step
holic Apr 28, 2024
e3d101f
hide relay options
holic Apr 28, 2024
9708e77
expose user account client, address, chain ID
holic Apr 29, 2024
745124f
clean up query invalidation
holic Apr 29, 2024
83927b0
add terms/privacy options
holic Apr 29, 2024
40d2e59
move close modal into step handler
holic Apr 29, 2024
70c22d2
add playground option to open on mount
holic Apr 29, 2024
54b368a
relay wiring
holic Apr 29, 2024
c0a6862
lift transaction status
holic Apr 29, 2024
0e75745
bump relay SDK
holic Apr 29, 2024
0a300ec
relay deposit status, add error icon and logging
holic Apr 30, 2024
65df37f
dismiss deposit status
holic Apr 30, 2024
ec6f0f7
button label tweak
holic Apr 30, 2024
d04b822
Merge remote-tracking branch 'origin/main' into account-kit
holic May 1, 2024
9719b90
fix type after merge
holic May 1, 2024
062d5a1
this can be done in wagmiConfig
holic May 2, 2024
4b87473
improve errors, add error boundary
holic May 2, 2024
6e10677
rework button pending
holic May 2, 2024
8565421
tweaks
holic May 2, 2024
5e81468
bump wagmi
holic May 3, 2024
a040377
Merge remote-tracking branch 'origin/main' into account-kit
holic May 3, 2024
517c30c
debounce amount
holic May 3, 2024
f48006d
swap Ξ for eth icon
holic May 3, 2024
1f2eff1
fix toast dismiss hover
holic May 3, 2024
2020888
add transfer status
holic May 3, 2024
1362c46
fix eth icon size
holic May 3, 2024
1b05310
withdraw button
holic May 4, 2024
6bf442e
extend OP chain contracts
holic May 4, 2024
4e4bf09
rework action calculation
holic May 5, 2024
ec25005
rework balance invalidation
holic May 5, 2024
c3f00da
remove unused alto/gas-tank stuff for now
holic May 22, 2024
30a9934
Merge remote-tracking branch 'origin/main' into account-kit
holic May 22, 2024
f17b530
fix playground with polyfills
holic May 22, 2024
db57e6e
try to calculate withdraw fees
holic May 22, 2024
ec85a14
Revert "try to calculate withdraw fees"
holic May 22, 2024
01aee7e
add note about async onClick
holic May 22, 2024
e1c8a21
trying again
holic May 22, 2024
10002da
refactor with proper fee calculation
holic May 22, 2024
27d878b
don't retry on known error
holic May 23, 2024
10ea925
Merge remote-tracking branch 'origin/main' into account-kit
holic May 23, 2024
fb34be9
Merge remote-tracking branch 'origin/main' into account-kit
holic May 23, 2024
65b4bd5
Merge remote-tracking branch 'origin/main' into account-kit
holic May 24, 2024
9160f5e
set up account kit in react template
holic Jun 1, 2024
72f3555
fix template mustache thing
holic Jun 1, 2024
595f432
ugh
holic Jun 1, 2024
5eff5e3
few fixes
holic Jun 1, 2024
d00e90d
writeContract from client
holic Jun 5, 2024
0958d9e
enable tx queue, extend AppAccountClient type with actions
holic Jun 5, 2024
46a18a6
use built in client
holic Jun 5, 2024
5b0f2e7
return chain id from getChainId
holic Jun 5, 2024
1097fe0
use getAction in more places
holic Jun 5, 2024
e911a4b
Merge remote-tracking branch 'origin/main' into account-kit
holic Jun 6, 2024
347c7a2
Merge remote-tracking branch 'origin/main' into account-kit
holic Jul 4, 2024
957ab7d
Merge remote-tracking branch 'origin/main' into account-kit
holic Jul 11, 2024
817df99
fix: remove console.trace() (#2973)
transmissions11 Jul 29, 2024
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ yarn.lock
lerna-debug.log
yarn-error.log
.turbo
*.tgz

# We don't want projects created from templates to ignore their lockfiles, but we don't
# want to check them in here, so we'll ignore them from the root.
Expand Down
7 changes: 7 additions & 0 deletions packages/account-kit/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"extends": ["../../.eslintrc", "plugin:react/recommended", "plugin:react-hooks/recommended"],
"plugins": ["react", "react-hooks"],
"rules": {
"react/react-in-jsx-scope": "off"
}
}
13 changes: 13 additions & 0 deletions packages/account-kit/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# MUD Account Kit

UI kit to streamline signing in to MUD apps.

## Installation

```
npm install @latticexyz/account-kit
```

## Usage

TODO
4 changes: 4 additions & 0 deletions packages/account-kit/inline-import.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
declare module "*?inline" {
const content: string;
export default content;
}
10 changes: 10 additions & 0 deletions packages/account-kit/mprocs.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
procs:
client:
shell: pnpm vite dev playground
anvil:
# To hydrate `anvil-state.json`, swap the command below and then deploy a MUD world to it.
# shell: anvil --dump-state playground/anvil-state.json
shell: anvil --block-time 2 --load-state playground/anvil-state.json
mud:
cwd: ../..
shell: pnpm run dev --filter=!@latticexyz/account-kit
80 changes: 80 additions & 0 deletions packages/account-kit/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
{
"name": "@latticexyz/account-kit",
"version": "2.0.4",
"description": "MUD account kit for easy user onboarding",
"repository": {
"type": "git",
"url": "https://github.com/latticexyz/mud.git",
"directory": "packages/account-kit"
},
"license": "MIT",
"type": "module",
"exports": {
".": "./dist/tsup/index.js",
"./internal": "./dist/tsup/internal.js",
"./bundle": "./dist/vite/bundle.js"
},
"files": [
"dist"
],
"scripts": {
"build": "pnpm run build:js",
"build:js": "tsup & vite build",
"clean": "pnpm run clean:js",
"clean:js": "rimraf dist",
"dev": "tsup --watch & vite build --watch",
"playground": "mprocs",
"test": "tsc --noEmit && vitest",
"test:ci": "tsc --noEmit && vitest --run"
},
"dependencies": {
"@latticexyz/common": "workspace:*",
"@latticexyz/config": "workspace:*",
"@latticexyz/protocol-parser": "workspace:*",
"@latticexyz/store": "workspace:*",
"@latticexyz/world": "workspace:*",
"@latticexyz/world-modules": "workspace:*",
"@radix-ui/react-dialog": "^1.0.5",
"@radix-ui/react-dropdown-menu": "^2.0.6",
"@radix-ui/react-select": "^2.0.0",
"@radix-ui/react-slot": "^1.0.2",
"@rainbow-me/rainbowkit": "^2.0.2",
"@reservoir0x/relay-sdk": "^0.4.0",
"@tanstack/react-query": "^5.28.8",
"abitype": "1.0.0",
"debug": "^4.3.4",
"execa": "^7.0.0",
"p-retry": "^5.1.2",
"permissionless": "^0.1.17",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-error-boundary": "^4.0.13",
"react-merge-refs": "^2.1.1",
"react-router-dom": "^6.11.0",
"tailwind-merge": "^1.12.0",
"usehooks-ts": "^3.0.2",
"viem": "2.9.20",
"wagmi": "^2.8.0",
"zustand": "^4.5.2"
},
"devDependencies": {
"@types/debug": "^4.1.7",
"@types/react": "18.2.22",
"@types/react-dom": "18.2.7",
"@types/ws": "^8.5.4",
"@vitejs/plugin-react": "^4.0.0",
"autoprefixer": "^10.4.14",
"eslint-plugin-react": "7.31.11",
"eslint-plugin-react-hooks": "4.6.0",
"mprocs": "^0.6.4",
"postcss": "^8.4.23",
"tailwindcss": "^3.4.3",
"tsup": "^6.7.0",
"vite": "^4.3.6",
"vite-plugin-dts": "^3.8.3",
"vitest": "0.34.6"
},
"publishConfig": {
"access": "public"
}
}
29 changes: 29 additions & 0 deletions packages/account-kit/playground/App.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import { useEffect } from "react";
import { AccountButton, useAccountModal } from "../src/exports";
import { useLocalStorage } from "usehooks-ts";

export function App() {
const { openAccountModal } = useAccountModal();

const [openModal, setOpenModal] = useLocalStorage<boolean>("mud:accountKitPlayground:openModalOnMount", false);

useEffect(() => {
if (openModal) {
openAccountModal();
}
}, [openAccountModal, openModal]);

return (
<div style={{ display: "flex", flexDirection: "column", gap: "0.5em" }}>
<div>
<AccountButton />
</div>
<div>
<label style={{ display: "flex", gap: "0.25em" }}>
<input type="checkbox" checked={openModal} onChange={(event) => setOpenModal(event.currentTarget.checked)} />
Open modal on mount
</label>
</div>
</div>
);
}
1 change: 1 addition & 0 deletions packages/account-kit/playground/anvil-state.json

Large diffs are not rendered by default.

12 changes: 12 additions & 0 deletions packages/account-kit/playground/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Account Kit playground</title>
</head>
<body>
<div id="react-root"></div>
<script type="module" src="./index.tsx"></script>
</body>
</html>
71 changes: 71 additions & 0 deletions packages/account-kit/playground/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
import "./polyfills";
import "@rainbow-me/rainbowkit/styles.css";
import { StrictMode } from "react";
import ReactDOM from "react-dom/client";
import { WagmiProvider, createConfig } from "wagmi";
import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
import { RainbowKitProvider, lightTheme, midnightTheme } from "@rainbow-me/rainbowkit";
import { garnet, mudFoundry, redstone } from "@latticexyz/common/chains";
import { AccountModal } from "../src/AccountModal";
import { AccountKitConfigProvider } from "../src/AccountKitConfigProvider";
import { App } from "./App";
import { Hex, createClient, http } from "viem";
import { chains } from "../src/exports/chains";

const queryClient = new QueryClient();

const wagmiConfig = createConfig({
chains: [mudFoundry, ...chains],
client: ({ chain }) =>
createClient({
chain,
// We intentionally don't use fallback+webSocket here because if a chain's RPC config
// doesn't include a `webSocket` entry, it doesn't seem to fallback and instead just
// ~never makes any requests and all queries seem to sit idle.
transport: http(),
}),
});

const testWorlds = {
[mudFoundry.id]: "0x8d8b6b8414e1e3dcfd4168561b9be6bd3bf6ec4b",
[garnet.id]: "0x352bd50fc7cbb8a1b3e5f84cf6f4e7d84792acd1",
[redstone.id]: "0x51778368cd250e4e3800a8fb20c32474c5f1c8cd",
} as Partial<Record<string, Hex>>;

const searchParams = new URLSearchParams(window.location.search);
const chainId = parseInt(searchParams.get("chainId") ?? "") || mudFoundry.id;
const worldAddress = testWorlds[chainId];
if (!worldAddress) {
throw new Error(`Account Kit playground is not configured with a test world address for chain ID ${chainId}`);
}

const accountKitConfig = {
chainId,
worldAddress,
erc4337: false,
appInfo: {
termsOfUse: "#terms",
privacyPolicy: "#privacy",
},
} as const;

const root = ReactDOM.createRoot(document.querySelector("#react-root")!);
root.render(
<StrictMode>
<WagmiProvider config={wagmiConfig}>
<QueryClientProvider client={queryClient}>
<RainbowKitProvider
theme={{
lightMode: lightTheme({ borderRadius: "none" }),
darkMode: midnightTheme({ borderRadius: "none" }),
}}
>
<AccountKitConfigProvider config={accountKitConfig}>
<App />
<AccountModal />
</AccountKitConfigProvider>
</RainbowKitProvider>
</QueryClientProvider>
</WagmiProvider>
</StrictMode>,
);
6 changes: 6 additions & 0 deletions packages/account-kit/playground/polyfills.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
// See https://www.rainbowkit.com/docs/installation#vite

window.global = window.global ?? window;
window.process = window.process ?? { env: {} };

export {};
4 changes: 4 additions & 0 deletions packages/account-kit/playground/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"extends": "../tsconfig.json",
"include": ["."]
}
15 changes: 15 additions & 0 deletions packages/account-kit/playground/vite.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { defineConfig } from "vite";
import react from "@vitejs/plugin-react";

export default defineConfig({
plugins: [react()],
optimizeDeps: {
esbuildOptions: {
target: "es2020",
// Node.js global to browser globalThis
define: {
global: "globalThis",
},
},
},
});
6 changes: 6 additions & 0 deletions packages/account-kit/postcss.config.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
module.exports = {
plugins: {
tailwindcss: {},
autoprefixer: {},
},
};
Loading
Loading