Skip to content

Commit 15b5a8e

Browse files
authored
chore: do not handle insufficent balance error if error data is not available (#1671)
1 parent bc07c0f commit 15b5a8e

File tree

3 files changed

+61
-2
lines changed

3 files changed

+61
-2
lines changed

packages/wallet-sdk/src/sign/scw/SCWSigner.test.ts

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1034,6 +1034,61 @@ describe('SCWSigner', () => {
10341034
expect(handleAddSubAccountOwner).toHaveBeenCalled();
10351035
});
10361036

1037+
it('should not handle insufficient balance error if external funding source data is not provided', async () => {
1038+
(createSubAccountSigner as Mock).mockImplementation(async () => {
1039+
const request = vi.fn((args) => {
1040+
throw new HttpRequestError({
1041+
body: args,
1042+
url: 'https://eth-rpc.example.com/1',
1043+
details: JSON.stringify({
1044+
code: -32090,
1045+
message: 'transfer amount exceeds balance',
1046+
data: undefined,
1047+
}),
1048+
});
1049+
});
1050+
1051+
return {
1052+
request,
1053+
};
1054+
});
1055+
1056+
await signer.request({
1057+
method: 'eth_requestAccounts',
1058+
params: [],
1059+
});
1060+
1061+
const mockRequest: RequestArguments = {
1062+
method: 'wallet_sendCalls',
1063+
params: [
1064+
{
1065+
calls: [
1066+
{
1067+
to: '0x',
1068+
value: '0x0',
1069+
data: '0x',
1070+
},
1071+
],
1072+
chainId: numberToHex(84532),
1073+
from: subAccountAddress,
1074+
version: '1.0',
1075+
},
1076+
],
1077+
};
1078+
1079+
signer = new SCWSigner({
1080+
metadata: mockMetadata,
1081+
communicator: mockCommunicator,
1082+
callback: mockCallback,
1083+
});
1084+
1085+
await expect(signer.request(mockRequest)).rejects.toThrow();
1086+
1087+
expect(handleInsufficientBalanceError).not.toHaveBeenCalled();
1088+
1089+
(createSubAccountSigner as Mock).mockRestore();
1090+
});
1091+
10371092
it('should handle insufficient balance error if external funding source is present', async () => {
10381093
(createSubAccountSigner as Mock).mockImplementation(async () => {
10391094
const request = vi.fn((args) => {

packages/wallet-sdk/src/sign/scw/SCWSigner.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -743,6 +743,10 @@ export class SCWSigner implements Signer {
743743
throw error;
744744
}
745745

746+
if (!errorObject.data) {
747+
throw error;
748+
}
749+
746750
const correlationId = correlationIds.get(request);
747751
logInsufficientBalanceErrorHandlingStarted({ method: request.method, correlationId });
748752
try {

packages/wallet-sdk/src/sign/scw/utils.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -424,11 +424,11 @@ export async function presentSubAccountFundingDialog() {
424424
logSnackbarShown({ snackbarContext: 'sub_account_insufficient_balance' });
425425
snackbar.presentItem({
426426
autoExpand: true,
427-
message: 'Insufficient spend limit. Choose how to proceed:',
427+
message: 'Insufficient spend permission. Choose how to proceed:',
428428
menuItems: [
429429
{
430430
isRed: false,
431-
info: 'Create new Spend Limit',
431+
info: 'Create new Spend Permission',
432432
svgWidth: '10',
433433
svgHeight: '11',
434434
path: '',

0 commit comments

Comments
 (0)