Skip to content

Commit 43d8e0a

Browse files
authored
core: allow native self transfer (#978)
1 parent 5e2ad39 commit 43d8e0a

2 files changed

Lines changed: 21 additions & 2 deletions

File tree

packages/wallet/core/src/wallet.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -342,7 +342,7 @@ export class Wallet {
342342
if (call.delegateCall) {
343343
throw new Error('delegate calls are not allowed in safe mode')
344344
}
345-
if (Address.isEqual(call.to, this.address)) {
345+
if (Address.isEqual(call.to, this.address) && call.data !== '0x') {
346346
throw new Error('calls to the wallet contract itself are not allowed in safe mode')
347347
}
348348
}
@@ -455,7 +455,7 @@ export class Wallet {
455455
if (call.delegateCall) {
456456
throw new Error('delegate calls are not allowed in safe mode')
457457
}
458-
if (Address.isEqual(call.to, this.address)) {
458+
if (Address.isEqual(call.to, this.address) && call.data !== '0x') {
459459
throw new Error('calls to the wallet contract itself are not allowed in safe mode')
460460
}
461461
}

packages/wallet/wdk/test/transactions.test.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -481,12 +481,31 @@ describe('Transactions', () => {
481481
const txId1 = manager.transactions.request(wallet!, Network.ChainId.ARBITRUM, [
482482
{
483483
to: wallet!,
484+
data: '0x1234',
484485
},
485486
])
486487

487488
await expect(txId1).rejects.toThrow()
488489
})
489490

491+
it('Should allow native token transfer to self in safe mode', async () => {
492+
const manager = newManager()
493+
const wallet = await manager.wallets.signUp({
494+
mnemonic: Mnemonic.random(Mnemonic.english),
495+
kind: 'mnemonic',
496+
noGuard: true,
497+
})
498+
499+
const txId1 = await manager.transactions.request(wallet!, Network.ChainId.ARBITRUM, [
500+
{
501+
to: wallet!,
502+
value: 1n,
503+
},
504+
])
505+
506+
expect(txId1).toBeDefined()
507+
})
508+
490509
it('Should allow transactions to self in unsafe mode', async () => {
491510
const manager = newManager()
492511
const wallet = await manager.wallets.signUp({

0 commit comments

Comments
 (0)