Skip to content

Commit c431e53

Browse files
committed
Using Address.isEqual
1 parent b771069 commit c431e53

File tree

6 files changed

+8
-14
lines changed

6 files changed

+8
-14
lines changed

packages/wallet/core/src/wallet.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -338,12 +338,11 @@ export class Wallet {
338338
// is not "dangerous", aka it does not have any delegate calls
339339
// or calls to the wallet contract itself
340340
if (!options?.unsafe) {
341-
const lowerCaseSelf = this.address.toLowerCase()
342341
for (const call of calls) {
343342
if (call.delegateCall) {
344343
throw new Error('delegate calls are not allowed in safe mode')
345344
}
346-
if (call.to.toLowerCase() === lowerCaseSelf) {
345+
if (Address.isEqual(call.to, this.address)) {
347346
throw new Error('calls to the wallet contract itself are not allowed in safe mode')
348347
}
349348
}
@@ -452,12 +451,11 @@ export class Wallet {
452451
// is not "dangerous", aka it does not have any delegate calls
453452
// or calls to the wallet contract itself
454453
if (!options?.unsafe) {
455-
const lowerCaseSelf = this.address.toLowerCase()
456454
for (const call of calls) {
457455
if (call.delegateCall) {
458456
throw new Error('delegate calls are not allowed in safe mode')
459457
}
460-
if (call.to.toLowerCase() === lowerCaseSelf) {
458+
if (Address.isEqual(call.to, this.address)) {
461459
throw new Error('calls to the wallet contract itself are not allowed in safe mode')
462460
}
463461
}

packages/wallet/wdk/src/identity/signer.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ export class IdentitySigner implements Signers.Signer {
3030
readonly authKey: AuthKey,
3131
) {}
3232

33-
get address(): `0x${string}` {
33+
get address(): Address.Address {
3434
if (!Address.validate(this.authKey.identitySigner)) {
3535
throw new Error('No signer address found')
3636
}

packages/wallet/wdk/src/sequence/handlers/mnemonic.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ export class MnemonicHandler implements Handler {
6666
return reject('invalid-mnemonic')
6767
}
6868

69-
if (signer.address.toLowerCase() !== address.toLowerCase()) {
69+
if (!Address.isEqual(signer.address, address)) {
7070
return reject('wrong-mnemonic')
7171
}
7272

packages/wallet/wdk/src/sequence/recovery.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ export class Recovery {
2727
transformer: (leaves: Extensions.Recovery.RecoveryLeaf[]) => Extensions.Recovery.RecoveryLeaf[],
2828
) {
2929
const ext = this.shared.sequence.extensions.recovery
30-
const idx = modules.findIndex((m) => m.address === ext)
30+
const idx = modules.findIndex((m) => Address.isEqual(m.address, ext))
3131
if (idx === -1) {
3232
return
3333
}

packages/wallet/wdk/src/sequence/wallets.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -765,7 +765,7 @@ export class Wallets {
765765
const nextDevicesTopology = buildCappedTree([
766766
...Config.getSigners(devicesTopology)
767767
.signers.filter(
768-
(x) => x !== '0x0000000000000000000000000000000000000000' && x.toLowerCase() !== device.address.toLowerCase(),
768+
(x) => x !== '0x0000000000000000000000000000000000000000' && !Address.isEqual(x, device.address),
769769
)
770770
.map((x) => ({ address: x })),
771771
...Config.getSigners(devicesTopology).sapientSigners,

packages/wallet/wdk/test/sessions.test.ts

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -220,9 +220,7 @@ describe('Sessions (via Manager)', () => {
220220

221221
// Sign and complete the request
222222
const sigRequest = await wdk.manager.getSignatureRequest(requestId)
223-
const identitySigner = sigRequest.signers.find(
224-
(s) => s.address.toLowerCase() === wdk.identitySignerAddress.toLowerCase(),
225-
)
223+
const identitySigner = sigRequest.signers.find((s) => Address.isEqual(s.address, wdk.identitySignerAddress))
226224
if (!identitySigner || (identitySigner.status !== 'actionable' && identitySigner.status !== 'ready')) {
227225
throw new Error(`Identity signer not found or not ready/actionable: ${identitySigner?.status}`)
228226
}
@@ -305,9 +303,7 @@ describe('Sessions (via Manager)', () => {
305303

306304
// Sign and complete the request
307305
const sigRequest = await wdk.manager.getSignatureRequest(requestId)
308-
const identitySigner = sigRequest.signers.find(
309-
(s) => s.address.toLowerCase() === wdk.identitySignerAddress.toLowerCase(),
310-
)
306+
const identitySigner = sigRequest.signers.find((s) => Address.isEqual(s.address, wdk.identitySignerAddress))
311307
if (!identitySigner || (identitySigner.status !== 'actionable' && identitySigner.status !== 'ready')) {
312308
throw new Error(`Identity signer not found or not ready/actionable: ${identitySigner?.status}`)
313309
}

0 commit comments

Comments
 (0)