Skip to content

Commit 37021da

Browse files
committed
chore: remove default spend limits
1 parent 4539500 commit 37021da

File tree

5 files changed

+14
-46
lines changed

5 files changed

+14
-46
lines changed

examples/testapp/src/pages/auto-sub-account/index.page.tsx

Lines changed: 0 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ import {
1212
VStack,
1313
} from '@chakra-ui/react';
1414
import { getCryptoKeyAccount } from '@coinbase/wallet-sdk';
15-
import { SpendPermissionConfig } from '@coinbase/wallet-sdk/dist/core/provider/interface';
1615
import React, { useEffect, useState } from 'react';
1716
import { createPublicClient, http, numberToHex, parseEther } from 'viem';
1817
import { privateKeyToAccount } from 'viem/accounts';
@@ -215,24 +214,6 @@ export default function AutoSubAccount() {
215214
}
216215
};
217216

218-
const handleSetDefaultSpendPermissions = (value: string) => {
219-
const defaultSpendPermissions = {
220-
[baseSepolia.id]: [
221-
{
222-
token: '0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE',
223-
allowance: '0x2386F26FC10000',
224-
period: 86400,
225-
} as SpendPermissionConfig,
226-
],
227-
};
228-
229-
if (value === 'true') {
230-
setSubAccountsConfig((prev) => ({ ...prev, defaultSpendPermissions }));
231-
} else {
232-
setSubAccountsConfig((prev) => ({ ...prev, defaultSpendPermissions: {} }));
233-
}
234-
};
235-
236217
const handleEthSend = async (amount: string) => {
237218
if (!provider || !accounts.length) return;
238219

@@ -326,18 +307,6 @@ export default function AutoSubAccount() {
326307
</Stack>
327308
</RadioGroup>
328309
</FormControl>
329-
<FormControl>
330-
<FormLabel>Default Spend Permissions</FormLabel>
331-
<RadioGroup
332-
value={subAccountsConfig?.defaultSpendPermissions?.[baseSepolia.id] ? 'true' : 'false'}
333-
onChange={handleSetDefaultSpendPermissions}
334-
>
335-
<Stack direction="row">
336-
<Radio value="true">Enabled</Radio>
337-
<Radio value="false">Disabled</Radio>
338-
</Stack>
339-
</RadioGroup>
340-
</FormControl>
341310
<FormControl>
342311
<FormLabel>Attribution</FormLabel>
343312
<RadioGroup value={getAttributionMode()} onChange={handleAttributionModeChange}>

packages/wallet-sdk/src/core/provider/interface.ts

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -96,11 +96,6 @@ export type SubAccountOptions = {
9696
* @returns The owner account that will be used to sign the subaccount transactions.
9797
*/
9898
toOwnerAccount?: ToOwnerAccountFn;
99-
/**
100-
* Spend permissions requested on app connect if a matching existing one does not exist.
101-
* Only supports native chain tokens currently.
102-
*/
103-
defaultSpendPermissions?: Record<number, SpendPermissionConfig[]>;
10499
};
105100

106101
export interface ConstructorOptions {

packages/wallet-sdk/src/createCoinbaseWalletSDK.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,6 @@ export function createCoinbaseWalletSDK(params: CreateCoinbaseWalletSDKOptions)
5858
store.subAccountsConfig.set({
5959
toOwnerAccount: params.subAccounts?.toOwnerAccount,
6060
enableAutoSubAccounts: params.subAccounts?.enableAutoSubAccounts,
61-
defaultSpendPermissions: params.subAccounts?.defaultSpendPermissions,
6261
});
6362

6463
// set the options in the store

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

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -120,9 +120,15 @@ describe('assertGetCapabilitiesParams', () => {
120120
expect(() => assertGetCapabilitiesParams(['0x123'])).toThrow(); // Too short
121121
expect(() => assertGetCapabilitiesParams(['0x123abc'])).toThrow(); // Too short
122122
expect(() => assertGetCapabilitiesParams(['xyz123'])).toThrow(); // No 0x prefix
123-
expect(() => assertGetCapabilitiesParams(['0x12345678901234567890123456789012345678gg'])).toThrow(); // Invalid hex characters
124-
expect(() => assertGetCapabilitiesParams(['0x123456789012345678901234567890123456789'])).toThrow(); // Too short (39 chars)
125-
expect(() => assertGetCapabilitiesParams(['0x12345678901234567890123456789012345678901'])).toThrow(); // Too long (41 chars)
123+
expect(() =>
124+
assertGetCapabilitiesParams(['0x12345678901234567890123456789012345678gg'])
125+
).toThrow(); // Invalid hex characters
126+
expect(() =>
127+
assertGetCapabilitiesParams(['0x123456789012345678901234567890123456789'])
128+
).toThrow(); // Too short (39 chars)
129+
expect(() =>
130+
assertGetCapabilitiesParams(['0x12345678901234567890123456789012345678901'])
131+
).toThrow(); // Too long (41 chars)
126132
});
127133

128134
it('should not throw for valid single parameter (valid Ethereum address)', () => {
@@ -148,7 +154,9 @@ describe('assertGetCapabilitiesParams', () => {
148154
it('should not throw for valid parameters with filter array', () => {
149155
expect(() => assertGetCapabilitiesParams([VALID_ADDRESS_1, []])).not.toThrow();
150156
expect(() => assertGetCapabilitiesParams([VALID_ADDRESS_1, ['0x1']])).not.toThrow();
151-
expect(() => assertGetCapabilitiesParams([VALID_ADDRESS_1, ['0x1', '0x2', '0x3']])).not.toThrow();
157+
expect(() =>
158+
assertGetCapabilitiesParams([VALID_ADDRESS_1, ['0x1', '0x2', '0x3']])
159+
).not.toThrow();
152160
expect(() => assertGetCapabilitiesParams([VALID_ADDRESS_1, ['0xabcdef', '0x0']])).not.toThrow();
153161
expect(() => assertGetCapabilitiesParams([VALID_ADDRESS_2, ['0x1', '0xa']])).not.toThrow();
154162
});

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

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -167,10 +167,6 @@ export async function initSubAccountConfig() {
167167
};
168168
}
169169

170-
if (config.defaultSpendPermissions) {
171-
capabilities.spendPermissions = config.defaultSpendPermissions;
172-
}
173-
174170
// Store the owner account and capabilities in the non-persisted config
175171
store.subAccountsConfig.set({
176172
capabilities,
@@ -591,7 +587,8 @@ export async function getCachedWalletConnectResponse(): Promise<WalletConnectRes
591587
address: account,
592588
capabilities: {
593589
subAccounts: subAccount ? [subAccount] : undefined,
594-
spendPermissions: spendPermissions.length > 0 ? { permissions: spendPermissions } : undefined,
590+
spendPermissions:
591+
spendPermissions.length > 0 ? { permissions: spendPermissions } : undefined,
595592
},
596593
})
597594
);

0 commit comments

Comments
 (0)