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
2 changes: 1 addition & 1 deletion packages/wallet/core/src/state/local/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ export interface Store {
export class Provider implements ProviderInterface {
constructor(
private readonly store: Store = new MemoryStore(),
public readonly extensions: Extensions.Extensions = Extensions.Rc4,
public readonly extensions: Extensions.Extensions = Extensions.Rc5,
) {}

getConfiguration(imageHash: Hex.Hex): Promise<Config.Config | undefined> {
Expand Down
1 change: 1 addition & 0 deletions packages/wallet/core/src/state/sequence/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -369,6 +369,7 @@ const passkeySigners = [
Extensions.Dev2.passkeys,
Extensions.Rc3.passkeys,
Extensions.Rc4.passkeys,
Extensions.Rc5.passkeys,
].map(Address.checksum)

const recoverSapientSignatureCompactSignature =
Expand Down
4 changes: 4 additions & 0 deletions packages/wallet/core/test/session-manager.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@ const ALL_EXTENSIONS = [
name: 'Rc4',
...Extensions.Rc4,
},
{
name: 'Rc5',
...Extensions.Rc5,
},
]

// Handle the increment call being first or last depending on the session manager version
Expand Down
4 changes: 2 additions & 2 deletions packages/wallet/dapp-client/src/ChainSessionManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ export class ChainSessionManager {
stateProvider: this.stateProvider,
})
this.sessionManager = new Signers.SessionManager(this.wallet, {
sessionManagerAddress: Extensions.Rc4.sessions,
sessionManagerAddress: Extensions.Rc5.sessions,
provider: this.provider!,
})
this.isInitialized = true
Expand Down Expand Up @@ -731,7 +731,7 @@ export class ChainSessionManager {
for (let attempt = 1; attempt <= maxRetries; attempt++) {
try {
const tempManager = new Signers.SessionManager(this.wallet, {
sessionManagerAddress: Extensions.Rc4.sessions,
sessionManagerAddress: Extensions.Rc5.sessions,
provider: this.provider,
})
const topology = await tempManager.getTopology()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ const addressCommand: CommandModule = {
.option('creationCode', {
type: 'string',
description: 'Creation code (optional)',
default: Context.Rc4.creationCode,
default: Context.Rc5.creationCode,
})
},
async (argv) => {
Expand Down
2 changes: 1 addition & 1 deletion packages/wallet/primitives/src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { Abi } from 'ox'
export const ZeroAddress = '0x0000000000000000000000000000000000000000' as const
export const PlaceholderAddress = '0xffff0000ffff0000ffff0000ffff0000ffff0000' as const

export const DefaultGuestAddress = '0x0000000000601fcA38f0cCA649453F6739436d6C' as const
export const DefaultGuestAddress = '0x0000000000006Ac72ed1d192fa28f0058D3F8806' as const

// ERC1271
export const IS_VALID_SIGNATURE = Abi.from([
Expand Down
21 changes: 21 additions & 0 deletions packages/wallet/primitives/src/context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,25 @@ export const Rc4_4337: Context = {
},
}

export const Rc5: Context = {
factory: '0x00000000000018A77519fcCCa060c2537c9D6d3F',
stage1: '0x0000000000001f3C39d61698ab21131a12134454',
stage2: '0xD0ae8eF93b7DA4eabb32Ec4d81b7a501DCa04D4C',
creationCode: '0x6041600e3d396021805130553df33d3d36153402601f57363d3d373d363d30545af43d82803e903d91601f57fd5bf3',
}

export const Rc5_4337: Context = {
factory: '0x00000000000018A77519fcCCa060c2537c9D6d3F',
stage1: '0x0000000000009caFdeDb6f64Bf5F31a22124B2a8',
stage2: '0xcBca3328a731deffE6Ce4c2fb51b585c3c37FB92',
creationCode: '0x6041600e3d396021805130553df33d3d36153402601f57363d3d373d363d30545af43d82803e903d91601f57fd5bf3',
capabilities: {
erc4337: {
entrypoint: '0x0000000071727De22E5E9d8BAf0edAc6f37da032',
},
},
}

export type KnownContext = Context & {
name: string
development: boolean
Expand All @@ -91,6 +110,8 @@ export const KnownContexts: KnownContext[] = [
{ name: 'Rc3_4337', development: true, ...Rc3_4337 },
{ name: 'Rc4', development: false, ...Rc4 },
{ name: 'Rc4_4337', development: false, ...Rc4_4337 },
{ name: 'Rc5', development: false, ...Rc5 },
{ name: 'Rc5_4337', development: false, ...Rc5_4337 },
]

export function isKnownContext(context: Context): context is KnownContext {
Expand Down
6 changes: 6 additions & 0 deletions packages/wallet/primitives/src/extensions/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,11 @@ export const Rc4: Extensions = {
sessions: '0x00000000000030Bcc832F7d657f50D6Be35C92b3',
}

export const Rc5: Extensions = {
passkeys: '0x0000000000005204F3711851EAD52CC9c241499a',
recovery: '0x000000000000AB36D17eB1150116371520565205',
sessions: '0x00000000000030Bcc832F7d657f50D6Be35C92b3',
}

export * as Passkeys from './passkeys.js'
export * as Recovery from './recovery.js'
15 changes: 14 additions & 1 deletion packages/wallet/primitives/test/address.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { describe, expect, it } from 'vitest'
import { Address, Bytes, Hash, Hex } from 'ox'

import { from } from '../src/address.js'
import { Context, Dev1, Dev2, Rc3, Rc4 } from '../src/context.js'
import { Context, Dev1, Dev2, Rc3, Rc4, Rc5 } from '../src/context.js'
import { Config, hashConfiguration } from '../src/config.js'

describe('Address', () => {
Expand Down Expand Up @@ -134,6 +134,19 @@ describe('Address', () => {
expect(address).not.toBe(dev2Address)
})

it('should work with Rc5 context', () => {
const { stage2, ...rc5Context } = Rc5
const address = from(sampleConfig, rc5Context)

expect(() => Address.assert(address)).not.toThrow()
expect(address).toMatch(/^0x[a-fA-F0-9]{40}$/)

// Should be different from Dev2
const { stage2: _, ...dev2Context } = Dev2
const dev2Address = from(sampleConfig, dev2Context)
expect(address).not.toBe(dev2Address)
})

it('should handle complex topology configurations', () => {
const complexConfig: Config = {
threshold: 2n,
Expand Down
6 changes: 3 additions & 3 deletions packages/wallet/wdk/src/sequence/manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,9 +95,9 @@ export type ManagerOptions = {
export const ManagerOptionsDefaults = {
verbose: false,

extensions: Extensions.Rc4,
context: Context.Rc4,
context4337: Context.Rc4_4337,
extensions: Extensions.Rc5,
context: Context.Rc5,
context4337: Context.Rc5_4337,
guest: Constants.DefaultGuestAddress,

encryptedPksDb: new CoreSigners.Pk.Encrypted.EncryptedPksDb(),
Expand Down
37 changes: 29 additions & 8 deletions packages/wallet/wdk/test/sessions.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,44 @@ import { AbiFunction, Address, Bytes, Hex, Mnemonic, Provider, RpcTransport, Sec
import { beforeEach, describe, expect, it } from 'vitest'
import { Signers as CoreSigners, Wallet as CoreWallet, Envelope, State } from '../../core/src/index.js'
import { ExplicitSession } from '../../core/src/utils/session/types.js'
import { Extensions, Network, Payload, Permission } from '../../primitives/src/index.js'
import { Context, Extensions, Network, Payload, Permission } from '../../primitives/src/index.js'
import { Sequence } from '../src/index.js'
import { EMITTER_ABI, EMITTER_ADDRESS, LOCAL_RPC_URL } from './constants'

const ALL_EXTENSIONS = [
const ALL_EXTENSIONS: {
name: string
extensions: Extensions.Extensions
context: Context.Context
context4337?: Context.Context
}[] = [
{
name: 'Dev1',
...Extensions.Dev1,
extensions: Extensions.Dev1,
context: Context.Dev1,
},
{
name: 'Dev2',
...Extensions.Dev2,
extensions: Extensions.Dev2,
context: Context.Dev2,
context4337: Context.Dev2_4337,
},
{
name: 'Rc3',
...Extensions.Rc3,
extensions: Extensions.Rc3,
context: Context.Rc3,
context4337: Context.Rc3_4337,
},
{
name: 'Rc4',
...Extensions.Rc4,
extensions: Extensions.Rc4,
context: Context.Rc4,
context4337: Context.Rc4_4337,
},
{
name: 'Rc5',
extensions: Extensions.Rc5,
context: Context.Rc5,
context4337: Context.Rc5_4337,
},
]

Expand Down Expand Up @@ -85,6 +103,9 @@ for (const extension of ALL_EXTENSIONS) {
// Create manager
const opts = Sequence.applyManagerOptionsDefaults({
stateProvider,
extensions: extension.extensions,
context: extension.context,
context4337: extension.context4337 ?? extension.context,
relayers: [], // No relayers needed for testing
networks: [
{
Expand Down Expand Up @@ -143,7 +164,7 @@ for (const extension of ALL_EXTENSIONS) {
wallet: coreWallet,
sessionManager: new CoreSigners.SessionManager(coreWallet, {
provider,
sessionManagerAddress: Extensions.Rc4.sessions,
sessionManagerAddress: extension.extensions.sessions,
}),
}
})
Expand Down Expand Up @@ -233,7 +254,7 @@ for (const extension of ALL_EXTENSIONS) {
dapp.wallet = coreWallet
dapp.sessionManager = new CoreSigners.SessionManager(coreWallet, {
provider,
sessionManagerAddress: Extensions.Rc4.sessions,
sessionManagerAddress: extension.extensions.sessions,
})

// At this point the wallet should NOT have a session topology
Expand Down