-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
streamline l2: get rid of special inputsMatch entrypoint
- Loading branch information
Showing
11 changed files
with
122 additions
and
102 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
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,2 +1 @@ | ||
export { inputsMatch } from "./inputsMatch" | ||
export { allow, EVERYTHING, ethSdk } from "./kit" |
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
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,14 +1,38 @@ | ||
import { keccak256, toUtf8Bytes } from "ethers/lib/utils" | ||
import { keccak256, ParamType, toUtf8Bytes } from "ethers/lib/utils" | ||
|
||
import { PresetAllowEntry, PresetFunction } from "./types" | ||
import { | ||
PresetAllowEntry, | ||
PresetAllowEntryCoerced, | ||
PresetFunction, | ||
PresetFunctionCoerced, | ||
} from "./types" | ||
|
||
export const sighash = (signature: string): string => | ||
const sighash = (signature: string): string => | ||
keccak256(toUtf8Bytes(signature)).substring(0, 10) | ||
|
||
export const isScoped = (entry: PresetAllowEntry): entry is PresetFunction => | ||
"selector" in entry || "signature" in entry | ||
export const coercePresetFunction = ( | ||
entry: PresetFunction | ||
): PresetFunctionCoerced => { | ||
return { | ||
targetAddress: entry.targetAddress.toLowerCase(), | ||
selector: | ||
"selector" in entry | ||
? entry.selector.toLowerCase() | ||
: sighash(entry.signature), | ||
condition: | ||
typeof entry.condition === "function" | ||
? entry.condition(ParamType.from("bytes")) | ||
: entry.condition, | ||
send: entry.send, | ||
delegatecall: entry.delegatecall, | ||
} | ||
} | ||
|
||
export const functionId = (entry: PresetFunction) => | ||
`${entry.targetAddress.toLowerCase()}.${ | ||
"selector" in entry ? entry.selector : sighash(entry.signature) | ||
}` | ||
export const isScoped = (entry: PresetAllowEntry): entry is PresetFunction => { | ||
return "selector" in entry || "signature" in entry | ||
} | ||
|
||
export const allowEntryId = (entry: PresetAllowEntryCoerced) => | ||
"selector" in entry | ||
? `${entry.targetAddress.toLowerCase()}.${entry.selector}` | ||
: entry.targetAddress.toLowerCase() |
Oops, something went wrong.