-
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(world-modules): add
callWithSignature
(#2592)
- Loading branch information
Showing
21 changed files
with
207 additions
and
305 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
108 changes: 0 additions & 108 deletions
108
e2e/packages/sync-test/data/callRegisterDelegationWithSignature.ts
This file was deleted.
Oops, something went wrong.
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,37 @@ | ||
import { Page } from "@playwright/test"; | ||
import { GetContractReturnType, PublicClient, WalletClient } from "viem"; | ||
import { AbiParametersToPrimitiveTypes, ExtractAbiFunction, ExtractAbiFunctionNames } from "abitype"; | ||
import CallWithSignatureAbi from "@latticexyz/world-modules/out/Unstable_CallWithSignatureSystem.sol/Unstable_CallWithSignatureSystem.abi.json"; | ||
|
||
type CallWithSignatureAbi = typeof CallWithSignatureAbi; | ||
|
||
type WorldContract = GetContractReturnType<CallWithSignatureAbi, PublicClient, WalletClient>; | ||
|
||
type WriteMethodName = ExtractAbiFunctionNames<CallWithSignatureAbi>; | ||
type WriteMethod<TMethod extends WriteMethodName> = ExtractAbiFunction<CallWithSignatureAbi, TMethod>; | ||
type WriteArgs<TMethod extends WriteMethodName> = AbiParametersToPrimitiveTypes<WriteMethod<TMethod>["inputs"]>; | ||
|
||
export function callWithSignature(page: Page, args?: WriteArgs<"callWithSignature">) { | ||
return page.evaluate( | ||
([_args, _CallWithSignatureAbi]) => { | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
const walletClient = (window as any).walletClient as WalletClient; | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
const worldContract = (window as any).worldContract as WorldContract; | ||
|
||
return walletClient | ||
.writeContract({ | ||
address: worldContract.address, | ||
abi: _CallWithSignatureAbi, | ||
functionName: "callWithSignature", | ||
args: _args, | ||
}) | ||
.then((tx) => window["waitForTransaction"](tx)) | ||
.catch((error) => { | ||
console.error(error); | ||
throw new Error([`Error executing callWithSignature with args:`, JSON.stringify(_args), error].join("\n\n")); | ||
}); | ||
}, | ||
[args, CallWithSignatureAbi], | ||
); | ||
} |
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
23 changes: 0 additions & 23 deletions
23
packages/world-modules/src/interfaces/IUnstable_DelegationWithSignatureSystem.sol
This file was deleted.
Oops, something went wrong.
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
Oops, something went wrong.