Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,11 @@
"turbo": "^2.6.1",
"typescript": "^5.8.3"
},
"pnpm": {
"overrides": {
"ox": "^0.9.17"
}
},
"packageManager": "[email protected]",
"engines": {
"node": ">=18"
Expand Down
2 changes: 1 addition & 1 deletion packages/services/guard/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,6 @@
"vitest": "^4.0.14"
},
"dependencies": {
"ox": "^0.7.2"
"ox": "^0.9.17"
}
}
2 changes: 1 addition & 1 deletion packages/services/identity-instrument/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,6 @@
"dependencies": {
"json-canonicalize": "^2.0.0",
"jwt-decode": "^4.0.0",
"ox": "^0.7.2"
"ox": "^0.9.17"
}
}
4 changes: 2 additions & 2 deletions packages/services/relayer/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
"dependencies": {
"@0xsequence/wallet-primitives": "workspace:^",
"mipd": "^0.0.7",
"ox": "^0.7.2",
"viem": "^2.37.8"
"ox": "^0.9.17",
"viem": "^2.40.3"
}
}
4 changes: 2 additions & 2 deletions packages/wallet/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
"@0xsequence/relayer": "workspace:^",
"@0xsequence/wallet-primitives": "workspace:^",
"mipd": "^0.0.7",
"ox": "^0.7.2",
"viem": "^2.37.8"
"ox": "^0.9.17",
"viem": "^2.40.3"
}
}
18 changes: 11 additions & 7 deletions packages/wallet/core/src/state/sequence/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -377,10 +377,14 @@ const recoverSapientSignatureCompactSignature =
const recoverSapientSignatureCompactFunction = AbiFunction.from(recoverSapientSignatureCompactSignature)

class PasskeySignatureValidator implements oxProvider.Provider {
request: oxProvider.Provider['request'] = (({ method, params }: { method: string; params: unknown }) => {
switch (method) {
request: oxProvider.Provider['request'] = (async (request) => {
switch (request.method) {
case 'eth_call':
const transaction: TransactionRequest.Rpc = (params as any)[0]
if (!request.params || !Array.isArray(request.params) || request.params.length === 0) {
throw new Error('eth_call requires transaction parameters')
}

const transaction: TransactionRequest.Rpc = request.params[0]

if (!transaction.data?.startsWith(AbiFunction.getSelector(recoverSapientSignatureCompactFunction))) {
throw new Error(
Expand All @@ -403,15 +407,15 @@ class PasskeySignatureValidator implements oxProvider.Provider {
}

default:
throw new Error(`method ${method} not implemented`)
throw new Error(`method ${request.method} not implemented`)
}
}) as any
}) as oxProvider.Provider['request']

on(event: string) {
on: oxProvider.Provider['on'] = (event: string) => {
throw new Error(`unable to listen for ${event}: not implemented`)
}

removeListener(event: string) {
removeListener: oxProvider.Provider['removeListener'] = (event: string) => {
throw new Error(`unable to remove listener for ${event}: not implemented`)
}
}
Expand Down
2 changes: 1 addition & 1 deletion packages/wallet/dapp-client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,6 @@
"@0xsequence/relayer": "workspace:^",
"@0xsequence/wallet-core": "workspace:^",
"@0xsequence/wallet-primitives": "workspace:^",
"ox": "^0.7.2"
"ox": "^0.9.17"
}
}
2 changes: 1 addition & 1 deletion packages/wallet/primitives-cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
},
"dependencies": {
"@0xsequence/wallet-primitives": "workspace:^",
"ox": "^0.7.2",
"ox": "^0.9.17",
"yargs": "^18.0.0"
}
}
2 changes: 1 addition & 1 deletion packages/wallet/primitives/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,6 @@
"vitest": "^4.0.14"
},
"dependencies": {
"ox": "^0.7.2"
"ox": "^0.9.17"
}
}
14 changes: 7 additions & 7 deletions packages/wallet/primitives/src/erc-6492.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { AbiFunction, AbiParameters, Address, Bytes, Hex, Provider } from 'ox'
import { WrappedSignature } from 'ox/erc6492'
import { SignatureErc6492 } from 'ox/erc6492'
import { DEPLOY } from './constants.js'
import { Context } from './context.js'

Expand Down Expand Up @@ -29,7 +29,7 @@ export function wrap<T extends Bytes.Bytes | Hex.Hex>(
[{ type: 'address' }, { type: 'bytes' }, { type: 'bytes' }],
[to, Hex.from(data), Hex.from(signature)],
),
WrappedSignature.magicBytes,
SignatureErc6492.magicBytes,
)

switch (typeof signature) {
Expand All @@ -46,24 +46,24 @@ export function decode<T extends Bytes.Bytes | Hex.Hex>(
switch (typeof signature) {
case 'object':
if (
Bytes.toHex(signature.subarray(-WrappedSignature.magicBytes.slice(2).length / 2)) ===
WrappedSignature.magicBytes
Bytes.toHex(signature.subarray(-SignatureErc6492.magicBytes.slice(2).length / 2)) ===
SignatureErc6492.magicBytes
) {
const [to, data, decoded] = AbiParameters.decode(
[{ type: 'address' }, { type: 'bytes' }, { type: 'bytes' }],
signature.subarray(0, -WrappedSignature.magicBytes.slice(2).length / 2),
signature.subarray(0, -SignatureErc6492.magicBytes.slice(2).length / 2),
)
return { signature: Hex.toBytes(decoded) as T, erc6492: { to, data: Hex.toBytes(data) as T } }
} else {
return { signature }
}

case 'string':
if (signature.endsWith(WrappedSignature.magicBytes.slice(2))) {
if (signature.endsWith(SignatureErc6492.magicBytes.slice(2))) {
try {
const [to, data, decoded] = AbiParameters.decode(
[{ type: 'address' }, { type: 'bytes' }, { type: 'bytes' }],
signature.slice(0, -WrappedSignature.magicBytes.slice(2).length) as Hex.Hex,
signature.slice(0, -SignatureErc6492.magicBytes.slice(2).length) as Hex.Hex,
)
return { signature: decoded as T, erc6492: { to, data: data as T } }
} catch {
Expand Down
14 changes: 7 additions & 7 deletions packages/wallet/primitives/test/erc-6492.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { describe, expect, it, vi } from 'vitest'
import { Address, Bytes, Hex, Provider } from 'ox'
import { WrappedSignature } from 'ox/erc6492'
import { SignatureErc6492 } from 'ox/erc6492'

import { deploy, wrap, decode, isValid } from '../src/erc-6492.js'
import { Context } from '../src/context.js'
Expand Down Expand Up @@ -82,7 +82,7 @@ describe('ERC-6492', () => {
expect(result.startsWith('0x')).toBe(true)

// Should end with the magic bytes
expect(result.endsWith(WrappedSignature.magicBytes.slice(2))).toBe(true)
expect(result.endsWith(SignatureErc6492.magicBytes.slice(2))).toBe(true)

// Should contain the original signature data somewhere
expect(result.length).toBeGreaterThan(testSignature.length)
Expand All @@ -96,7 +96,7 @@ describe('ERC-6492', () => {

// Convert to hex to check magic bytes
const resultHex = Bytes.toHex(result)
expect(resultHex.endsWith(WrappedSignature.magicBytes.slice(2))).toBe(true)
expect(resultHex.endsWith(SignatureErc6492.magicBytes.slice(2))).toBe(true)
})

it('should return same type as input signature', () => {
Expand Down Expand Up @@ -133,7 +133,7 @@ describe('ERC-6492', () => {
// The wrapped signature should contain encoded: address, bytes (data), bytes (signature)
expect(result.length).toBeGreaterThan(testSignature.length + deployData.data.length)
expect(result).toContain(testAddress.slice(2)) // Address without 0x
expect(result.endsWith(WrappedSignature.magicBytes.slice(2))).toBe(true)
expect(result.endsWith(SignatureErc6492.magicBytes.slice(2))).toBe(true)
})
})

Expand Down Expand Up @@ -209,7 +209,7 @@ describe('ERC-6492', () => {

it('should handle malformed wrapped signature gracefully', () => {
// Create a signature that ends with magic bytes but has invalid encoding
const malformedSig = ('0x1234' + WrappedSignature.magicBytes.slice(2)) as Hex.Hex
const malformedSig = ('0x1234' + SignatureErc6492.magicBytes.slice(2)) as Hex.Hex
const result = decode(malformedSig)

// Should return original signature when decoding fails
Expand Down Expand Up @@ -391,7 +391,7 @@ describe('ERC-6492', () => {

// 2. Wrap signature with deploy data
const wrappedSig = wrap(testSignature, deployCall)
expect(wrappedSig.endsWith(WrappedSignature.magicBytes.slice(2))).toBe(true)
expect(wrappedSig.endsWith(SignatureErc6492.magicBytes.slice(2))).toBe(true)

// 3. Decode wrapped signature
const decoded = decode(wrappedSig)
Expand Down Expand Up @@ -457,7 +457,7 @@ describe('ERC-6492', () => {

it('should handle signatures that accidentally contain magic bytes', () => {
// Create a signature that contains the magic bytes but isn't wrapped
const magicInSignature = (testSignature + WrappedSignature.magicBytes.slice(2) + '1234') as Hex.Hex
const magicInSignature = (testSignature + SignatureErc6492.magicBytes.slice(2) + '1234') as Hex.Hex
const result = decode(magicInSignature)

// Should try to decode, but if it fails, should return original
Expand Down
2 changes: 1 addition & 1 deletion packages/wallet/wdk/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
"@0xsequence/wallet-primitives": "workspace:^",
"idb": "^8.0.3",
"jwt-decode": "^4.0.0",
"ox": "^0.7.2",
"ox": "^0.9.17",
"uuid": "^13.0.0"
}
}
Loading