-
Notifications
You must be signed in to change notification settings - Fork 195
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
104 additions
and
12 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,12 @@ | ||
import { Abi, type ContractFunctionName } from "viem"; | ||
import IWorldCallAbi from "../out/IWorldKernel.sol/IWorldCall.abi.json"; | ||
import { SystemCall, encodeSystemCall } from "./encodeSystemCall"; | ||
import type { AbiParametersToPrimitiveTypes, ExtractAbiFunction } from "abitype"; | ||
import { worldCallAbi } from "./worldCallAbi"; | ||
|
||
/** Encode system calls to be passed as arguments into `World.batchCall` */ | ||
export function encodeSystemCalls<abi extends Abi, functionName extends ContractFunctionName<abi>>( | ||
abi: abi, | ||
systemCalls: readonly Omit<SystemCall<abi, functionName>, "abi">[], | ||
): AbiParametersToPrimitiveTypes<ExtractAbiFunction<typeof IWorldCallAbi, "call">["inputs"]>[] { | ||
): AbiParametersToPrimitiveTypes<ExtractAbiFunction<worldCallAbi, "call">["inputs"]>[] { | ||
return systemCalls.map((systemCall) => encodeSystemCall({ ...systemCall, abi } as SystemCall<abi, functionName>)); | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
// TODO: replace this with abi-ts generated files once we move to | ||
// generating full TS files rather than DTS | ||
|
||
export const worldCallAbi = [ | ||
{ | ||
type: "function", | ||
name: "call", | ||
inputs: [ | ||
{ | ||
name: "systemId", | ||
type: "bytes32", | ||
internalType: "ResourceId", | ||
}, | ||
{ | ||
name: "callData", | ||
type: "bytes", | ||
internalType: "bytes", | ||
}, | ||
], | ||
outputs: [ | ||
{ | ||
name: "", | ||
type: "bytes", | ||
internalType: "bytes", | ||
}, | ||
], | ||
stateMutability: "payable", | ||
}, | ||
{ | ||
type: "function", | ||
name: "callFrom", | ||
inputs: [ | ||
{ | ||
name: "delegator", | ||
type: "address", | ||
internalType: "address", | ||
}, | ||
{ | ||
name: "systemId", | ||
type: "bytes32", | ||
internalType: "ResourceId", | ||
}, | ||
{ | ||
name: "callData", | ||
type: "bytes", | ||
internalType: "bytes", | ||
}, | ||
], | ||
outputs: [ | ||
{ | ||
name: "", | ||
type: "bytes", | ||
internalType: "bytes", | ||
}, | ||
], | ||
stateMutability: "payable", | ||
}, | ||
] as const; | ||
|
||
export type worldCallAbi = typeof worldCallAbi; |