Skip to content

Commit eb153a3

Browse files
committed
Ignore EIP1271 validation for config updates. Signer may not be deployed
1 parent 0ce5bc6 commit eb153a3

File tree

6 files changed

+101
-13
lines changed

6 files changed

+101
-13
lines changed

packages/account/src/account.ts

+3-2
Original file line numberDiff line numberDiff line change
@@ -520,7 +520,7 @@ export class Account {
520520
async publishWitness(chainId: ethers.BigNumberish = 0, referenceChainId?: ethers.BigNumberish): Promise<void> {
521521
const digest = ethers.id(`This is a Sequence account woo! ${Date.now()}`)
522522
// Apply ERC-6492 to undeployed children
523-
const signature = await this.signDigest(digest, 0, false, 'ignore', {referenceChainId, cantValidateBehavior: "eip6492"})
523+
const signature = await this.signDigest(digest, 0, false, 'ignore', {chainId, referenceChainId, cantValidateBehavior: "eip6492"})
524524
const decoded = this.coders.signature.decode(signature)
525525
const recovered = await this.coders.signature.recover(decoded, { digest, chainId, address: this.address })
526526
const signatures = this.coders.signature.signaturesOf(recovered.config)
@@ -669,7 +669,8 @@ export class Account {
669669
await this.tracker.savePresignedConfiguration({
670670
wallet: this.address,
671671
nextConfig: config,
672-
signature
672+
signature,
673+
validateBehavior: 'ignore'
673674
})
674675

675676
// safety check, tracker should have a reverse lookup for the imageHash

packages/api/src/api.gen.ts

+86-7
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/* eslint-disable */
2-
// sequence-api v0.4.0 470a0f88ea399c2a57ff8c22da54358c033ed5f0
2+
// sequence-api v0.4.0 bbe47e0331a18438fe5f7fe590a4b7b4e5102738
33
// --
4-
// Code generated by webrpc-gen@v0.18.7 with typescript generator. DO NOT EDIT.
4+
// Code generated by webrpc-gen@v0.20.3 with typescript generator. DO NOT EDIT.
55
//
66
// webrpc-gen -schema=api.ridl -target=typescript -client -out=./clients/api.gen.ts
77

@@ -12,7 +12,7 @@ export const WebRPCVersion = 'v1'
1212
export const WebRPCSchemaVersion = 'v0.4.0'
1313

1414
// Schema hash generated from your RIDL schema
15-
export const WebRPCSchemaHash = '470a0f88ea399c2a57ff8c22da54358c033ed5f0'
15+
export const WebRPCSchemaHash = 'bbe47e0331a18438fe5f7fe590a4b7b4e5102738'
1616

1717
//
1818
// Types
@@ -78,6 +78,12 @@ export interface SequenceContext {
7878
utils: string
7979
}
8080

81+
export interface PublicKey {
82+
id: string
83+
x: string
84+
y: string
85+
}
86+
8187
export interface User {
8288
address: string
8389
username: string
@@ -362,7 +368,7 @@ export interface SwapPrice {
362368
currencyAddress: string
363369
currencyBalance: string
364370
price: string
365-
to: string
371+
maxPrice: string
366372
transactionValue: string
367373
}
368374

@@ -445,6 +451,8 @@ export interface API {
445451
headers?: object,
446452
signal?: AbortSignal
447453
): Promise<SendPasswordlessLinkReturn>
454+
registerPublicKey(args: RegisterPublicKeyArgs, headers?: object, signal?: AbortSignal): Promise<RegisterPublicKeyReturn>
455+
getPublicKey(args: GetPublicKeyArgs, headers?: object, signal?: AbortSignal): Promise<GetPublicKeyReturn>
448456
friendList(args: FriendListArgs, headers?: object, signal?: AbortSignal): Promise<FriendListReturn>
449457
getFriendByAddress(args: GetFriendByAddressArgs, headers?: object, signal?: AbortSignal): Promise<GetFriendByAddressReturn>
450458
searchFriends(args: SearchFriendsArgs, headers?: object, signal?: AbortSignal): Promise<SearchFriendsReturn>
@@ -539,6 +547,7 @@ export interface API {
539547
headers?: object,
540548
signal?: AbortSignal
541549
): Promise<ValidateWaaSVerificationNonceReturn>
550+
getSwapPrice(args: GetSwapPriceArgs, headers?: object, signal?: AbortSignal): Promise<GetSwapPriceReturn>
542551
getSwapPrices(args: GetSwapPricesArgs, headers?: object, signal?: AbortSignal): Promise<GetSwapPricesReturn>
543552
getSwapQuote(args: GetSwapQuoteArgs, headers?: object, signal?: AbortSignal): Promise<GetSwapQuoteReturn>
544553
listCurrencyGroups(headers?: object, signal?: AbortSignal): Promise<ListCurrencyGroupsReturn>
@@ -635,6 +644,20 @@ export interface SendPasswordlessLinkArgs {
635644
export interface SendPasswordlessLinkReturn {
636645
status: boolean
637646
}
647+
export interface RegisterPublicKeyArgs {
648+
publicKey: PublicKey
649+
}
650+
651+
export interface RegisterPublicKeyReturn {
652+
status: boolean
653+
}
654+
export interface GetPublicKeyArgs {
655+
id: string
656+
}
657+
658+
export interface GetPublicKeyReturn {
659+
publicKey: PublicKey
660+
}
638661
export interface FriendListArgs {
639662
nickname?: string
640663
page?: Page
@@ -971,8 +994,6 @@ export interface RemoveLinkedWalletArgs {
971994
parentWalletMessage: string
972995
parentWalletSignature: string
973996
linkedWalletAddress: string
974-
linkedWalletMessage: string
975-
linkedWalletSignature: string
976997
signatureChainId: string
977998
}
978999

@@ -997,11 +1018,23 @@ export interface ValidateWaaSVerificationNonceArgs {
9971018
export interface ValidateWaaSVerificationNonceReturn {
9981019
walletAddress: string
9991020
}
1021+
export interface GetSwapPriceArgs {
1022+
buyCurrencyAddress: string
1023+
sellCurrencyAddress: string
1024+
buyAmount: string
1025+
chainId: number
1026+
slippagePercentage?: number
1027+
}
1028+
1029+
export interface GetSwapPriceReturn {
1030+
swapPrice: SwapPrice
1031+
}
10001032
export interface GetSwapPricesArgs {
10011033
userAddress: string
10021034
buyCurrencyAddress: string
10031035
buyAmount: string
10041036
chainId: number
1037+
slippagePercentage?: number
10051038
}
10061039

10071040
export interface GetSwapPricesReturn {
@@ -1014,6 +1047,7 @@ export interface GetSwapQuoteArgs {
10141047
buyAmount: string
10151048
chainId: number
10161049
includeApprove: boolean
1050+
slippagePercentage?: number
10171051
}
10181052

10191053
export interface GetSwapQuoteReturn {
@@ -1086,7 +1120,7 @@ export class API implements API {
10861120
protected path = '/rpc/API/'
10871121

10881122
constructor(hostname: string, fetch: Fetch) {
1089-
this.hostname = hostname
1123+
this.hostname = hostname.replace(/\/*$/, '')
10901124
this.fetch = (input: RequestInfo, init?: RequestInit) => fetch(input, init)
10911125
}
10921126

@@ -1224,6 +1258,36 @@ export class API implements API {
12241258
)
12251259
}
12261260

1261+
registerPublicKey = (args: RegisterPublicKeyArgs, headers?: object, signal?: AbortSignal): Promise<RegisterPublicKeyReturn> => {
1262+
return this.fetch(this.url('RegisterPublicKey'), createHTTPRequest(args, headers, signal)).then(
1263+
res => {
1264+
return buildResponse(res).then(_data => {
1265+
return {
1266+
status: <boolean>_data.status
1267+
}
1268+
})
1269+
},
1270+
error => {
1271+
throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` })
1272+
}
1273+
)
1274+
}
1275+
1276+
getPublicKey = (args: GetPublicKeyArgs, headers?: object, signal?: AbortSignal): Promise<GetPublicKeyReturn> => {
1277+
return this.fetch(this.url('GetPublicKey'), createHTTPRequest(args, headers, signal)).then(
1278+
res => {
1279+
return buildResponse(res).then(_data => {
1280+
return {
1281+
publicKey: <PublicKey>_data.publicKey
1282+
}
1283+
})
1284+
},
1285+
error => {
1286+
throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` })
1287+
}
1288+
)
1289+
}
1290+
12271291
friendList = (args: FriendListArgs, headers?: object, signal?: AbortSignal): Promise<FriendListReturn> => {
12281292
return this.fetch(this.url('FriendList'), createHTTPRequest(args, headers, signal)).then(
12291293
res => {
@@ -1999,6 +2063,21 @@ export class API implements API {
19992063
)
20002064
}
20012065

2066+
getSwapPrice = (args: GetSwapPriceArgs, headers?: object, signal?: AbortSignal): Promise<GetSwapPriceReturn> => {
2067+
return this.fetch(this.url('GetSwapPrice'), createHTTPRequest(args, headers, signal)).then(
2068+
res => {
2069+
return buildResponse(res).then(_data => {
2070+
return {
2071+
swapPrice: <SwapPrice>_data.swapPrice
2072+
}
2073+
})
2074+
},
2075+
error => {
2076+
throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` })
2077+
}
2078+
)
2079+
}
2080+
20022081
getSwapPrices = (args: GetSwapPricesArgs, headers?: object, signal?: AbortSignal): Promise<GetSwapPricesReturn> => {
20032082
return this.fetch(this.url('GetSwapPrices'), createHTTPRequest(args, headers, signal)).then(
20042083
res => {

packages/passkeys/src/index.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ export type PasskeySignerContext = {
3838
}
3939

4040
export type PasskeySignMetadata = {
41+
chainId?: ethers.BigNumberish
4142
referenceChainId?: ethers.BigNumberish
4243
cantValidateBehavior?: 'ignore' | 'eip6492' | 'throw'
4344
}
@@ -181,7 +182,7 @@ export class SequencePasskeySigner implements signers.SapientSigner {
181182
}
182183

183184
async sign(digest: ethers.BytesLike, metadata: PasskeySignMetadata): Promise<ethers.BytesLike> {
184-
const referenceChainId = metadata?.referenceChainId ?? this.chainId
185+
const referenceChainId = metadata?.referenceChainId ?? metadata?.chainId ?? this.chainId
185186
const subdigest = subDigestOf(await this.getAddress(), referenceChainId, ethers.hexlify(digest))
186187

187188
const signature = await this.doSign(digest, subdigest)

packages/sessions/src/tracker.ts

+1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ export type PresignedConfig = {
66
nextConfig: commons.config.Config
77
signature: string
88
referenceChainId?: string
9+
validateBehavior?: 'ignore' | 'throw'
910
}
1011

1112
export type PresignedConfigLink = Omit<PresignedConfig, 'nextConfig'> & { nextImageHash: string }

packages/sessions/src/trackers/local.ts

+6-1
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,12 @@ export class LocalConfigTracker implements ConfigTracker, migrator.PresignedMigr
235235
const savePayload = this.savePayload({ payload })
236236
const saveNextConfig = this.saveWalletConfig({ config: args.nextConfig })
237237

238-
const recovered = await v2.signature.SignatureCoder.recover(decoded, payload, this.provider)
238+
const validateBehavior = args.validateBehavior ?? 'throw'
239+
const recovered = await v2.signature.SignatureCoder.recover(
240+
decoded,
241+
payload,
242+
validateBehavior === 'ignore' ? undefined : this.provider // Only validate if we are not ignoring
243+
)
239244

240245
// Save the recovered configuration and all signature parts
241246
const signatures = v2.signature.signaturesOf(recovered.config.tree)

packages/wallet/src/wallet.ts

+3-2
Original file line numberDiff line numberDiff line change
@@ -433,11 +433,12 @@ export class Wallet<
433433
}
434434

435435
async fillGasLimits(txs: commons.transaction.Transactionish): Promise<commons.transaction.SimulatedTransaction[]> {
436-
const transaction = await resolveArrayProperties<commons.transaction.Transactionish>(txs)
437-
const transactions = commons.transaction.fromTransactionish(this.address, transaction)
438436
const relayer = this.relayer
439437
if (!relayer) throw new Error('Wallet fillGasLimits requires a relayer')
440438

439+
const transaction = await resolveArrayProperties<commons.transaction.Transactionish>(txs)
440+
const transactions = commons.transaction.fromTransactionish(this.address, transaction)
441+
441442
const simulations = await relayer.simulate(this.address, ...transactions)
442443
return transactions.map((tx, i) => {
443444
const gasLimit = tx.gasLimit ? Number(tx.gasLimit) : simulations[i].gasLimit

0 commit comments

Comments
 (0)