Skip to content

Commit 825d1b8

Browse files
authored
fix(v4-sdk): swap permission check (#433)
1 parent 60fb2f0 commit 825d1b8

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

sdks/v4-sdk/src/utils/hook.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,10 @@ export class Hook {
9797
}
9898

9999
private static _hasPermission(address: string, hookOption: HookOptions) {
100-
return !!(parseInt(address, 16) & (1 << hookFlagIndex[hookOption]))
100+
// Use only the last 4 bytes (32 bits) to avoid JavaScript precision issues
101+
// All hook flags are in bits 0-13, which fit comfortably in 32 bits
102+
const last4Bytes = '0x' + address.slice(-8)
103+
return !!(parseInt(last4Bytes, 16) & (1 << hookFlagIndex[hookOption]))
101104
}
102105

103106
private static _checkAddress(address: string) {

0 commit comments

Comments
 (0)