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(guides/adding-delegation): change to account for API changes 🏎 #2837

Merged
merged 5 commits into from
May 16, 2024
Merged
Changes from 3 commits
Commits
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
21 changes: 12 additions & 9 deletions docs/pages/guides/adding-delegation.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ To deploy the delegation system:
# Anvil default private key:
PRIVATE_KEY=0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80

WORLD_ADDRESS=0xC14fBdb7808D9e2a37c1a45b635C8C3fF64a1cc1
WORLD_ADDRESS=0x8d8b6b8414e1e3dcfd4168561b9be6bd3bf6ec4b
```

</CollapseCode>
Expand Down Expand Up @@ -176,7 +176,7 @@ Before moving over to the client, we will verify things work as expected using a
USER_ADDRESS=0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266
USER_ADDRESS_2=0x70997970C51812dc3A010C7d01b50e0d17dc79C8

WORLD_ADDRESS=0xC14fBdb7808D9e2a37c1a45b635C8C3fF64a1cc1
WORLD_ADDRESS=0x8d8b6b8414e1e3dcfd4168561b9be6bd3bf6ec4b
```

</CollapseCode>
Expand Down Expand Up @@ -329,8 +329,9 @@ Before moving over to the client, we will verify things work as expected using a
forge script script/TestDelegation.s.sol --broadcast --rpc-url http://127.0.0.1:8545
```

1. See that the call from `USER_ADDRESS` is now at the bottom, it is the latest call.
Also, the transaction sender is different from the caller.
1. Return to the [user interface](http://localhost:3000/).
Look at the bottom call, that one is the latest.
See that the caller (`USER_ADDRESS`, `0xf39F...2266`) is different from the transaction sender (`USER_ADDRESS_2`, `0x7099...c79C8`).

### Using TypeScript

Expand All @@ -350,7 +351,7 @@ Here is the modified `packages/client/src/App.tsx`:

<CollapseCode>

```typescript filename="App.tsx" copy showLineNumbers {1,3,8-53,116-135,159-199}
```typescript filename="App.tsx" copy showLineNumbers {1,3,8-53,118-142,166-209}
import { encodeFunctionData } from "viem";
import { useMUD } from "./MUDContext";
import {
Expand Down Expand Up @@ -429,7 +430,7 @@ const publicClient = createPublicClient({
// client - a wallet client that uses a random account
Copy link
Member

@holic holic May 15, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we're not returning this anymore, so I don't think we need this comment?
and that said, should we just return the getContract result rather than { world: getContract(...) }?

nevermind, I see references in code below that still use client so maybe we should restore the returned client as client: walletClient?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, major oops on my part, fixed now.

// world - a world contract object that lets us issue newCall
const makeWorldContract = () => {
const client = createWalletClient({
const walletClient = createWalletClient({
...clientOptions,
account: createBurnerAccount(getBurnerPrivateKey(Math.random().toString())),
});
Expand All @@ -438,10 +439,12 @@ const makeWorldContract = () => {
world: getContract({
address: networkConfig.worldAddress as Hex,
abi: IWorldAbi,
publicClient: publicClient,
walletClient: client,
client: {
public: publicClient,
wallet: walletClient,
}
}),
client,
client: walletClient?
holic marked this conversation as resolved.
Show resolved Hide resolved
};
};

Expand Down
Loading