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

wip entrykit #3240

Draft
wants to merge 450 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
450 commits
Select commit Hold shift + click to select a range
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
e7555f4
Merge remote-tracking branch 'origin/main' into entry
holic Sep 23, 2024
09af7c3
rename
holic Sep 23, 2024
a9b6d68
various fixes
holic Sep 23, 2024
f1296fe
more renaming and fixes
holic Sep 23, 2024
4ef5b3c
rip out some smart account stuff for now
holic Sep 23, 2024
495b1a0
fix clean
holic Sep 24, 2024
f39a135
skip explorer in dev
holic Sep 26, 2024
a8e2f40
Merge remote-tracking branch 'origin/main' into entry
holic Sep 26, 2024
2560685
dont bundle react
holic Sep 26, 2024
414bddb
small fixes
holic Sep 30, 2024
e25efc4
rename to entrykit
holic Sep 30, 2024
2ef8a62
Merge remote-tracking branch 'origin/main' into entry
holic Sep 30, 2024
2df1483
update ts paths
holic Sep 30, 2024
897c4db
bring over passkey connector
holic Sep 30, 2024
c7ea288
bump mprocs
holic Sep 30, 2024
75d9003
ignore all logs
holic Sep 30, 2024
c1491c7
move rainbowkit usage into entrykit
holic Sep 30, 2024
5ef3b14
connect passkey wallet
holic Sep 30, 2024
5407f24
trying to figure out why its not reconnecting
holic Oct 1, 2024
71bd0fc
wip
holic Oct 2, 2024
969fcca
sorta working again
holic Oct 3, 2024
3316b5b
move extended client to connector
holic Oct 3, 2024
b4aa3fb
clean up
holic Oct 3, 2024
c644b65
clean up
holic Oct 3, 2024
e0b721b
move smart account to a single place
holic Oct 3, 2024
6dd143e
attach initializer
holic Oct 4, 2024
d69ab7a
Revert "attach initializer"
holic Oct 4, 2024
647f9a9
rework sign in flow
holic Oct 4, 2024
60b1383
modal tweaks for small screens
holic Oct 4, 2024
66acc3d
show account when connected
holic Oct 4, 2024
a4ae218
improve transitions, remove gas balance from dropdown
holic Oct 4, 2024
e5f24ff
start bringing in new onboarding flow
holic Oct 4, 2024
668baf8
little bit of polish
holic Oct 4, 2024
bf3d375
Merge remote-tracking branch 'origin/main' into entrykit
holic Oct 7, 2024
848fb81
sketch out steps
holic Oct 8, 2024
2073012
use regular anvil port to make it easier to use with metamask
holic Oct 8, 2024
3e7dff3
Merge remote-tracking branch 'origin/main' into entrykit
holic Oct 8, 2024
32939ac
start integrating paymaster
holic Oct 8, 2024
4e7a85d
copy over toCoinbaseSmartAccount
holic Oct 8, 2024
f2ec899
wip paymaster
holic Oct 9, 2024
9e2c702
Merge remote-tracking branch 'origin/main' into entrykit
holic Oct 9, 2024
037c09e
move gas fee calculation
holic Oct 9, 2024
519cca8
trying a new strategy for steps
holic Oct 9, 2024
ae78ff3
wip initializer
holic Oct 10, 2024
bc1cb9b
no initializer, claim gas pass
holic Oct 10, 2024
c0247f1
clean up
holic Oct 10, 2024
d93670e
its workingggg
holic Oct 10, 2024
9985219
Merge remote-tracking branch 'origin/main' into entrykit
holic Oct 10, 2024
ec73e9e
send user op now
holic Oct 11, 2024
b9425d9
update alto, run from source
holic Oct 11, 2024
04df216
remove all unused stuff
holic Oct 11, 2024
e0499a8
remove old comment
holic Oct 11, 2024
9d16d7a
exports and type fixes
holic Oct 11, 2024
b0347b9
Merge remote-tracking branch 'origin/main' into entrykit
holic Oct 14, 2024
0050426
various tweaks
holic Oct 14, 2024
d07784f
update playground
holic Oct 15, 2024
37b7650
various tweaks
holic Oct 15, 2024
edbfe6b
.1 seems like enough for now
holic Oct 15, 2024
d3a1f48
Merge remote-tracking branch 'origin/main' into entrykit
holic Oct 15, 2024
e54a1f8
refactor with our own bundler client
holic Oct 16, 2024
8e84871
Merge remote-tracking branch 'origin/main' into entrykit
holic Oct 16, 2024
a13e785
Merge remote-tracking branch 'origin/main' into entrykit
holic Oct 16, 2024
e97d2eb
update tsup config after merge
holic Oct 16, 2024
d844186
move shared deps to peer deps
holic Oct 16, 2024
a58cc13
add observer
holic Oct 16, 2024
86f7eb4
various fixes
holic Oct 16, 2024
5af68a8
Merge remote-tracking branch 'origin/main' into entrykit
holic Oct 16, 2024
8af96e1
lower min balance
holic Oct 16, 2024
bc150f8
crappy eoa for now
holic Oct 17, 2024
898cdd6
update playground deploy
holic Oct 17, 2024
01b57db
modal/connect UI tweaks
holic Oct 17, 2024
3586519
fix paymaster/issuer
holic Oct 17, 2024
d8d9d97
rework onboarding flow
holic Oct 17, 2024
097d5f2
change button order if has known passkeys
holic Oct 17, 2024
4d17bb9
small polish
holic Oct 17, 2024
c1d42b3
fix button/tab order
holic Oct 17, 2024
b246780
more prominent slide in
holic Oct 17, 2024
9301901
disable upcoming steps
holic Oct 18, 2024
53019fc
auto claim allowance
holic Oct 18, 2024
24486ee
test that deleteRecord triggers update
holic Oct 18, 2024
464b26e
test singleton tables
holic Oct 18, 2024
beb8d1d
attach user address to app account client
holic Oct 18, 2024
c0b663d
update user op endpoint, fake the receipt
holic Oct 18, 2024
fad4cda
don't saturate account button
holic Oct 18, 2024
660fba5
merge: alvs/ws-keepalive
holic Oct 18, 2024
726159c
remove content slide in animation for now
holic Oct 20, 2024
3626e44
adjust terms
holic Oct 21, 2024
be51fef
fix sizing/spacing issues with modal
holic Oct 23, 2024
0124fe7
Merge remote-tracking branch 'origin/main' into entrykit
holic Oct 23, 2024
c234485
don't use flex with min-h
holic Oct 23, 2024
55baa96
preload app account client
holic Oct 23, 2024
1ae4a02
workaround chain data not available after receipt
holic Oct 23, 2024
5d62534
assume user op receipt success
holic Oct 23, 2024
df8b6bc
quick workaround for sizing/positioning issue
holic Oct 24, 2024
bcef423
Merge remote-tracking branch 'origin/main' into entrykit
holic Oct 24, 2024
bfd56fe
Merge remote-tracking branch 'origin/main' into entrykit
holic Oct 24, 2024
0033091
Merge remote-tracking branch 'origin/main' into entrykit
holic Oct 24, 2024
13adf1a
Merge remote-tracking branch 'origin/main' into entrykit
holic Oct 25, 2024
91970a7
try reconnecting on close
holic Oct 25, 2024
9f0ee91
lots more logs
holic Oct 25, 2024
cb78e29
try more async
holic Oct 26, 2024
13527f5
Merge remote-tracking branch 'origin/main' into entrykit
holic Oct 26, 2024
4326c74
oops my bad
holic Oct 26, 2024
f915b77
close socket client instead of subscription
holic Oct 26, 2024
bd42f16
trying to let viem do its thing
holic Oct 27, 2024
5f05e72
try closing socket
holic Oct 27, 2024
ad6909b
some more logs
holic Oct 27, 2024
87d9e97
feels good enough
holic Oct 27, 2024
c30e073
app account -> session
holic Oct 27, 2024
37df6a5
Merge remote-tracking branch 'origin/main' into entrykit
holic Oct 27, 2024
9b5a40e
refactor for pending state of session client
holic Oct 27, 2024
08b84b5
fix some cache issues, start setup automatically, show step in button…
holic Oct 27, 2024
d864105
fix(world): use fetchLogs in getFunctions
holic Oct 28, 2024
5f71502
feat(common): add rhodolite websocket url
holic Oct 28, 2024
d791f1e
Merge remote-tracking branch 'origin/main' into entrykit
holic Oct 28, 2024
4cb3d65
trying to fix nonces for smart accounts
holic Oct 28, 2024
ef40ea6
Revert "trying to fix nonces for smart accounts"
holic Oct 28, 2024
a55684b
route calls to wiresaw_call
holic Oct 29, 2024
9f7c977
rework steps a bit for better dismissing modal
holic Oct 29, 2024
caebe53
Merge branch 'main' into entrykit
alvrs Oct 30, 2024
9e2f624
small fixes
holic Oct 30, 2024
16d558c
Merge remote-tracking branch 'origin/main' into entrykit
holic Oct 30, 2024
64656da
test that results are memoized
holic Oct 30, 2024
e66a8c9
save first value when doing unique by
holic Oct 31, 2024
a79eec2
remove unnecessary abitype dep
holic Oct 31, 2024
c319dd4
move viem to peer deps
holic Oct 31, 2024
298de61
revert catalog usage
holic Oct 31, 2024
b10158e
add polling interval
holic Oct 31, 2024
b0b7aa3
implement getNonce
holic Oct 31, 2024
2c133d5
rework clients and transports to use chain config
holic Nov 1, 2024
adf9cbe
rewrite wiresaw transport
holic Nov 1, 2024
9a48aca
merge alvrs/update-watch-logs
holic Nov 1, 2024
1dfd769
remove wiresaw export
holic Nov 1, 2024
1af29a3
wire up wiresaw
holic Nov 1, 2024
e20c07f
move stuff to chain config, rework naming
holic Nov 1, 2024
b6f9730
wrap transports in wiresaw
holic Nov 1, 2024
88f3abd
set up EOA with signatures
holic Nov 1, 2024
fc34d5e
fix various bugs during state transitions
holic Nov 1, 2024
7c66951
small tweaks
holic Nov 1, 2024
72b3659
don't set initial chain
holic Nov 2, 2024
e01a72a
update paymaster address
alvrs Nov 5, 2024
94d7121
update playground
holic Nov 2, 2024
cd7ae99
Merge remote-tracking branch 'origin/main' into entrykit-catch-up
holic Nov 5, 2024
9e962cb
try fixing EOA automatic chain switch
holic Nov 5, 2024
b979be6
deploy with smart account
holic Nov 6, 2024
83ec575
handle user op receipts in transport
holic Nov 7, 2024
07c5b56
Merge branch 'main' into entrykit
alvrs Nov 7, 2024
2096820
move out wiresaw/paymaster stuff (#3367)
holic Nov 7, 2024
1694d69
update imports
holic Nov 7, 2024
d77b89f
fix app info
holic Nov 8, 2024
4c25d1e
smartpass (#3362)
holic Nov 8, 2024
b5cf00b
various tweaks/fixes
holic Nov 9, 2024
d97ebc1
no need for these headers
holic Nov 9, 2024
051e0dd
update anvil state snapshot
holic Nov 9, 2024
3b489ec
parse receipt for success
holic Nov 9, 2024
ea92cda
revert ID url
holic Nov 9, 2024
1b6f1ed
mud ID url configurable by chain
holic Nov 9, 2024
335157d
fix
holic Nov 9, 2024
e8cf1c3
bring back user op fees
holic Nov 9, 2024
c1d240e
remove hardcoded gas
holic Nov 9, 2024
c1ba62d
break cache
holic Nov 9, 2024
e48e9d8
Revert "remove hardcoded gas"
holic Nov 9, 2024
a4f4f26
remove observer for now, return partial user op receipts for speed
holic Nov 9, 2024
cd0f1a0
wiresaw over ws
holic Nov 9, 2024
5f6904e
revert MUD ID
holic Nov 9, 2024
f785166
Revert "revert MUD ID"
holic Nov 9, 2024
5e77502
try using same window name
holic Nov 9, 2024
56c3f96
improve error
holic Nov 9, 2024
3c83157
Revert "Revert "revert MUD ID""
holic Nov 9, 2024
1359882
back to original cache
holic Nov 9, 2024
1d780b2
add credential options
holic Nov 9, 2024
c23f4f5
set allowance in local
holic Nov 10, 2024
b0257a4
don't compute gas locally
holic Nov 10, 2024
ac2cd2e
faster polling for local bundler
holic Nov 10, 2024
539787c
update explorer transports/poll interval
holic Nov 11, 2024
f3113a2
add smart account option to dev-contracts
holic Nov 11, 2024
a12e037
dont deploy with wiresaw for now
holic Nov 11, 2024
a877ba6
Merge remote-tracking branch 'origin/main' into entrykit
holic Nov 11, 2024
1c24e47
Merge branch 'main' into entrykit
alvrs Nov 11, 2024
cabf846
fix ts paths
holic Nov 11, 2024
8b53d23
more accurate update list
holic Nov 11, 2024
889293d
update snapshots
holic Nov 11, 2024
d6c6139
apply updates
holic Nov 11, 2024
900aa88
remove barrel file, export applyUpdates
holic Nov 11, 2024
40213b4
queue updates and notify subscribers in microtask
holic Nov 11, 2024
ff56a0e
try piping watchLogs to queue scheduler
holic Nov 11, 2024
35f1941
update stash storage adapter to apply updates once
holic Nov 11, 2024
c941317
preserve first prev
holic Nov 12, 2024
510cc59
Revert "try piping watchLogs to queue scheduler"
holic Nov 12, 2024
d928bff
don't use microtask
holic Nov 12, 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
5 changes: 5 additions & 0 deletions .changeset/dirty-tools-hammer.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@latticexyz/store-sync": patch
---

Updated the `watchLogs` util to accept the updated RPC response type.
10 changes: 10 additions & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,15 @@
},
},
],
// disable the base rule as it can report incorrect errors
"no-unused-vars": "off",
"@typescript-eslint/no-unused-vars": [
"error",
{
"argsIgnorePattern": "^_",
"varsIgnorePattern": "^_",
"caughtErrorsIgnorePattern": "^_",
},
],
},
}
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,10 @@ node_modules
package-lock.json
yarn.lock

*.log
# npm pack
*.tgz

*.log
.eslintcache
.parcel-cache
.docs
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
"package.json": "pnpm fix:package-json"
},
"devDependencies": {
"@ark/attest": "catalog:",
"@ark/attest": "0.12.1",
"@changesets/cli": "^2.27.7",
"@types/node": "^18.15.11",
"@typescript-eslint/eslint-plugin": "7.1.1",
Expand All @@ -58,7 +58,7 @@
"tsx": "4.19.0",
"turbo": "^1.9.3",
"typescript": "5.4.2",
"viem": "catalog:",
"viem": "2.21.19",
"vitest": "2.1.2"
},
"packageManager": "[email protected]",
Expand Down
7 changes: 5 additions & 2 deletions packages/block-logs-stream/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,17 @@
"dependencies": {
"@latticexyz/common": "workspace:*",
"debug": "^4.3.4",
"rxjs": "7.5.5",
"viem": "catalog:"
"rxjs": "7.5.5"
},
"devDependencies": {
"@types/debug": "^4.1.7",
"tsup": "^6.7.0",
"viem": "2.21.19",
"vitest": "0.34.6"
},
"peerDependencies": {
"viem": "2.x"
},
"publishConfig": {
"access": "public"
}
Expand Down
9 changes: 6 additions & 3 deletions packages/cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,20 +39,22 @@
"test:ci": "pnpm run test"
},
"dependencies": {
"@ark/util": "catalog:",
"@ark/util": "0.2.2",
"@aws-sdk/client-kms": "^3.556.0",
"@latticexyz/abi-ts": "workspace:*",
"@latticexyz/block-logs-stream": "workspace:*",
"@latticexyz/common": "workspace:*",
"@latticexyz/config": "workspace:*",
"@latticexyz/gas-report": "workspace:*",
"@latticexyz/paymaster": "workspace:*",
"@latticexyz/protocol-parser": "workspace:*",
"@latticexyz/schema-type": "workspace:*",
"@latticexyz/store": "workspace:*",
"@latticexyz/utils": "workspace:*",
"@latticexyz/wiresaw": "workspace:*",
"@latticexyz/world": "workspace:*",
"@latticexyz/world-module-metadata": "workspace:*",
"abitype": "catalog:",
"abitype": "1.0.6",
"asn1.js": "^5.4.1",
"chalk": "^5.0.1",
"chokidar": "^3.5.3",
Expand All @@ -65,11 +67,12 @@
"p-queue": "^7.4.1",
"p-retry": "^5.1.2",
"path": "^0.12.7",
"permissionless": "^0.2.3",
"rxjs": "7.5.5",
"throttle-debounce": "^5.0.0",
"toposort": "^2.0.2",
"typescript": "5.4.2",
"viem": "catalog:",
"viem": "2.21.19",
"yargs": "^17.7.1",
"zod": "3.23.8",
"zod-validation-error": "^1.3.0"
Expand Down
1 change: 1 addition & 0 deletions packages/cli/src/commands/dev-contracts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ const devOptions = {
alwaysRunPostDeploy: deployOptions.alwaysRunPostDeploy,
forgeScriptOptions: deployOptions.forgeScriptOptions,
worldAddress: deployOptions.worldAddress,
smartAccount: deployOptions.smartAccount,
};

const commandModule: CommandModule<typeof devOptions, InferredOptionTypes<typeof devOptions>> = {
Expand Down
9 changes: 7 additions & 2 deletions packages/cli/src/commands/trace.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { getChainId, readContract } from "viem/actions";
import { World as WorldConfig } from "@latticexyz/world";
import { resolveSystems } from "@latticexyz/world/node";
import { worldAbi } from "../deploy/common";
import { getAction } from "viem/utils";

const systemsTableId = worldConfig.namespaces.world.tables.Systems.tableId;

Expand Down Expand Up @@ -63,15 +64,19 @@ const commandModule: CommandModule<Options, Options> = {
const config = (await loadConfig(configPath)) as WorldConfig;

const client = createClient({ transport: http(rpc) });
const chainId = await getChainId(client);
const chainId = await getAction(client, getChainId, "getChainId")({});
const worldAddress = (args.worldAddress ?? getWorldAddress(config.deploy.worldsFile, chainId)) as Hex;

const systems = await resolveSystems({ rootDir, config });

const labels = await Promise.all(
systems.map(async (system) => ({
label: system.label,
address: await readContract(client, {
address: await getAction(
client,
readContract,
"readContract",
)({
abi: worldAbi,
address: worldAddress,
functionName: "getField",
Expand Down
31 changes: 24 additions & 7 deletions packages/cli/src/deploy/deployCustomWorld.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Account, Chain, Client, Hex, Transport, concatHex, encodeDeployData, getCreate2Address, isHex } from "viem";
import { waitForTransactionReceipt } from "viem/actions";
import { resourceToHex, sendTransaction, writeContract } from "@latticexyz/common";
import { waitForTransactionReceipt, writeContract, sendTransaction } from "viem/actions";
import { resourceToHex } from "@latticexyz/common";
import { debug } from "./debug";
import { logsToWorldDeploy } from "./logsToWorldDeploy";
import { WorldDeploy, salt, worldAbi } from "./common";
Expand All @@ -9,6 +9,7 @@ import { ensureContractsDeployed } from "./ensureContractsDeployed";
import { ContractArtifact, ReferenceIdentifier } from "@latticexyz/world/node";
import { World } from "@latticexyz/world";
import { waitForTransactions } from "./waitForTransactions";
import { getAction } from "viem/utils";

function findArtifact(ref: ReferenceIdentifier, artifacts: readonly ContractArtifact[]): ContractArtifact {
const artifact = artifacts.find((a) => a.sourcePath === ref.sourcePath && a.name === ref.name);
Expand Down Expand Up @@ -78,17 +79,23 @@ export async function deployCustomWorld({

// Deploy custom world without deterministic deployer for now
debug("deploying custom world");
const deployTx = await sendTransaction(client, {
const deployTx = await getAction(
client,
sendTransaction,
"sendTransaction",
)({
chain: client.chain ?? null,
account: client.account,
data: encodeDeployData({
abi: worldArtifact.abi,
args: [], // TODO (https://github.com/latticexyz/mud/issues/3150)
bytecode: getDeployable(deployerAddress, worldArtifact, artifacts),
}),
gas: 10_000_000n,
});

debug("waiting for custom world deploy");
const receipt = await waitForTransactionReceipt(client, { hash: deployTx });
debug("waiting for custom world deploy at tx", deployTx);
const receipt = await getAction(client, waitForTransactionReceipt, "waitForTransactionReceipt")({ hash: deployTx });
if (receipt.status !== "success") {
console.error("world deploy failed", receipt);
throw new Error("world deploy failed");
Expand All @@ -98,8 +105,13 @@ export async function deployCustomWorld({
debug("deployed custom world to", deploy.address, "at block", deploy.deployBlock);

// initialize world via init module
const initTx = await writeContract(client, {
const initTx = await getAction(
client,
writeContract,
"writeContract",
)({
chain: client.chain ?? null,
account: client.account,
address: deploy.address,
abi: worldAbi,
functionName: "initialize",
Expand All @@ -108,8 +120,13 @@ export async function deployCustomWorld({
await waitForTransactions({ client, hashes: [initTx], debugLabel: "world init" });

// transfer root namespace to deployer after init module is installed so `transferOwnership` method is available
const transferOwnershipTx = await writeContract(client, {
const transferOwnershipTx = await getAction(
client,
writeContract,
"writeContract",
)({
chain: client.chain ?? null,
account: client.account,
address: deploy.address,
abi: worldAbi,
functionName: "transferOwnership",
Expand Down
29 changes: 23 additions & 6 deletions packages/cli/src/deploy/deployWorld.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import { Account, Chain, Client, Hex, Transport } from "viem";
import { waitForTransactionReceipt } from "viem/actions";
import { Account, Chain, Client, Hex, Transport, parseEventLogs } from "viem";
import { waitForTransactionReceipt, writeContract } from "viem/actions";
import { ensureWorldFactory } from "./ensureWorldFactory";
import WorldFactoryAbi from "@latticexyz/world/out/WorldFactory.sol/WorldFactory.abi.json" assert { type: "json" };
import { writeContract } from "@latticexyz/common";
import { debug } from "./debug";
import { logsToWorldDeploy } from "./logsToWorldDeploy";
import { WorldDeploy } from "./common";
import { getAction } from "viem/utils";
import { entryPoint07Abi } from "viem/account-abstraction";

export async function deployWorld(
client: Client<Transport, Chain | undefined, Account>,
Expand All @@ -16,19 +17,35 @@ export async function deployWorld(
const worldFactory = await ensureWorldFactory(client, deployerAddress, withWorldProxy);

debug("deploying world");
const tx = await writeContract(client, {
const tx = await getAction(
client,
writeContract,
"writeContract",
)({
chain: client.chain ?? null,
account: client.account,
address: worldFactory,
abi: WorldFactoryAbi,
functionName: "deployWorld",
args: [salt],
});

debug("waiting for world deploy");
const receipt = await waitForTransactionReceipt(client, { hash: tx });
debug("waiting for world deploy at tx", tx);
const receipt = await getAction(client, waitForTransactionReceipt, "waitForTransactionReceipt")({ hash: tx });
if (receipt.status !== "success") {
console.error("world deploy failed", receipt);
throw new Error("world deploy failed");
} else if (client.account.type === "smart") {
// TODO: lift this out into something better that doesn't assume one tx
const parsedLogs = parseEventLogs({
logs: receipt.logs,
abi: entryPoint07Abi,
eventName: "UserOperationEvent" as const,
});
if (!parsedLogs[0].args.success) {
console.error("world deploy failed");
throw new Error("world deploy failed");
}
}

const deploy = logsToWorldDeploy(receipt.logs);
Expand Down
13 changes: 9 additions & 4 deletions packages/cli/src/deploy/ensureContract.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { Client, Transport, Chain, Account, concatHex, getCreate2Address, Hex } from "viem";
import { getBytecode } from "viem/actions";
import { getCode, sendTransaction } from "viem/actions";
import { contractSizeLimit, salt } from "./common";
import { sendTransaction } from "@latticexyz/common";
import { debug } from "./debug";
import pRetry from "p-retry";
import { getAction } from "viem/utils";

export type Contract = {
bytecode: Hex;
Expand All @@ -27,7 +27,7 @@ export async function ensureContract({

const address = getCreate2Address({ from: deployerAddress, salt, bytecode });

const contractCode = await getBytecode(client, { address, blockTag: "pending" });
const contractCode = await getAction(client, getCode, "getCode")({ address, blockTag: "pending" });
if (contractCode) {
debug("found", debugLabel, "at", address);
return [];
Expand All @@ -50,8 +50,13 @@ export async function ensureContract({
return [
await pRetry(
() =>
sendTransaction(client, {
getAction(
client,
sendTransaction,
"sendTransaction",
)({
chain: client.chain ?? null,
account: client.account,
to: deployerAddress,
data: concatHex([salt, bytecode]),
}),
Expand Down
Loading
Loading