createSpendPermissionTypedDataWithSeconds: soft production guard (console.warn) should be a hard throw to prevent silent misuse

Open Beginner friendly
#325 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
78/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Quiet
Tech stack
typescript
Domain
testing

Research direction

Open packages/account-sdk/src/interface/public-utilities/spend-permission/utils.ts and inspect createSpendPermissionTypedDataWithSeconds around lines 109–154, especially the production guard at lines 126–131. Replace the soft warning behavior with the requested fail-fast behavior, then verify that production calls no longer return typed data while non-production behavior remains usable.

Written by the indexing model from the issue text.

Description

File: packages/account-sdk/src/interface/public-utilities/spend-permission/utils.ts
Lines: 109–154 (HEAD 24ab30c)

Summary

createSpendPermissionTypedDataWithSeconds is documented as test-only (@testOnly JSDoc, warning comment). Its production guard (line 126–131) is:

if (process.env.NODE_ENV === 'production') {
  console.warn(
    '⚠️ createSpendPermissionTypedDataWithSeconds is being used. ' +
      'This function is intended for testing purposes only.'
  );
}

The function then continues and returns valid SpendPermissionTypedData regardless of environment. A console.warn in a production bundle is typically invisible to end-users and silently swallowed by logging pipelines. The "guard" does not guard: a developer who accidentally ships a call to this function in production will receive a fully-formed typed-data object that can be signed and submitted on-chain.

Expected behavior

The guard should be a hard throw (or at minimum prevent returning typed data) so that production callers fail fast and loudly:

if (process.env.NODE_ENV === 'production') {
  throw new Error(
    'createSpendPermissionTypedDataWithSeconds is for testing only and must not be called in production.'
  );
}

Why this matters

Spend permissions authorise recurring token withdrawals from user accounts. A test utility that creates permissions with arbitrary second-level periods could be used (accidentally or intentionally) in production, creating permissions with very short periods that drain allowances rapidly and are not supported by the production UX.

No existing issue found (searched createSpendPermissionTypedDataWithSeconds, testOnly production guard, console.warn throw across all states).

Dominant language
TypeScript
Stars
172
Forks
207
Avg merge
49m
Merged PRs (30d)
1

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from base/account-sdk

All issues in base/account-sdk

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.