-
Notifications
You must be signed in to change notification settings - Fork 196
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(common,world): improvements for smart accounts (#2578)
Co-authored-by: mous <[email protected]> Co-authored-by: alvrs <[email protected]> Co-authored-by: karooolis <[email protected]>
- Loading branch information
1 parent
66865c5
commit d2e4d0f
Showing
10 changed files
with
76 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
--- | ||
"@latticexyz/common": patch | ||
--- | ||
|
||
`transactionQueue` decorator now accepts an optional `publicClient` argument, which will be used in place of the extended viem client for making public action calls (`getChainId`, `getTransactionCount`, `simulateContract`, `call`). This helps in cases where the extended viem client is a smart account client, like in [permissionless.js](https://github.com/pimlicolabs/permissionless.js), where the transport is the bundler, not an RPC. | ||
|
||
`writeObserver` decorator now accepts any `Client`, not just a `WalletClient`. | ||
|
||
`createBurnerAccount` now returns a `PrivateKeyAccount`, the more specific `Account` type. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"@latticexyz/world": patch | ||
--- | ||
|
||
`callFrom` decorator now accepts any `Client`, not just a `WalletClient`. It also no longer attempts to wrap/redirect calls to `call`, `callFrom`, and `registerDelegationWithSignature`. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,20 @@ | ||
import type { Transport, Chain, Account, WalletActions, WalletClient } from "viem"; | ||
import type { Transport, Chain, Account, WalletActions, Client, PublicClient } from "viem"; | ||
import { writeContract as mud_writeContract } from "../writeContract"; | ||
import { sendTransaction as mud_sendTransaction } from "../sendTransaction"; | ||
|
||
export function transactionQueue<TChain extends Chain, TAccount extends Account>(): ( | ||
client: WalletClient<Transport, TChain, TAccount>, | ||
) => Pick<WalletActions<TChain, TAccount>, "writeContract" | "sendTransaction"> { | ||
export type TransactionQueueOptions<chain extends Chain> = { | ||
publicClient?: PublicClient<Transport, chain>; | ||
}; | ||
|
||
export function transactionQueue<chain extends Chain, account extends Account>({ | ||
publicClient, | ||
}: TransactionQueueOptions<chain> = {}): ( | ||
client: Client<Transport, chain, account>, | ||
) => Pick<WalletActions<chain, account>, "writeContract" | "sendTransaction"> { | ||
return (client) => ({ | ||
// Applies to: `client.writeContract`, `getContract(client, ...).write` | ||
writeContract: (args) => mud_writeContract(client, args), | ||
writeContract: (args) => mud_writeContract(client, args, publicClient), | ||
// Applies to: `client.sendTransaction` | ||
sendTransaction: (args) => mud_sendTransaction(client, args), | ||
sendTransaction: (args) => mud_sendTransaction(client, args, publicClient), | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters