# Changelog

## [3.0.1] - 2026-08-12

### Fixed
- `exports` now declares `"."` explicitly and exposes `./package.json`. The previous conditional-shorthand form left the subpath unmapped, so `require('@particle-network/universal-account-sdk/package.json')` threw `ERR_PACKAGE_PATH_NOT_EXPORTED` — version probes and bundle analysers read that path. A `types` condition was added in the same object because a fully-specified `exports` map takes over type resolution under `moduleResolution: node16` / `bundler`, which then no longer falls back to the top-level `types` field.

## [3.0.0] - 2026-08-12

### Breaking
- **EIP-7702 is now the default account model.** `smartAccountOptions.useEIP7702` defaults to `true`; it previously defaulted to unset, which the server treats as the classic model.

  The two models derive **different smart account addresses from the same owner**, on both EVM and Solana. An integrator who upgrades without setting the field will therefore see every user's address change, and balances held by the classic account will no longer be visible or spendable through the SDK. The funds are not lost — they remain in the classic account — but reaching them requires opting back in:

  ```ts
  new UniversalAccount({
      // …
      smartAccountOptions: { name: 'UNIVERSAL', version: '2.0.1', ownerAddress, useEIP7702: false },
  });
  ```

  The default changed because the classic model is not executable everywhere: Robinhood (`4663`) rejects it at simulation time with `-32606`, while the same transaction succeeds under EIP-7702. Verify which model your users' funds live under before upgrading.

### Added
- Robinhood Chain (`4663`) as a supported chain: `CHAIN_ID.ROBINHOOD_MAINNET`, added to `UNIVERSAL_ACCOUNT_VERSION_V2_SUPPORTED_CHAIN_IDS`. Universal Server scopes chain `4663` to universal account versions `2.0.0` / `2.0.1` and their EIP-7702 modes, so the SDK's chain set now matches the server's exactly.
- `SUPPORTED_TOKEN_TYPE.USDG` (`usdg`) and its primary-token entry on Robinhood (`0x5fc5360D0400a0Fd4f2af552ADD042D716F1d168`, 6 on-chain decimals). USDG is Robinhood's only stable coin and the token that chain settles "USD first" trades into; including it in the default `usePrimaryTokens` lets USDG balances fund transactions and pay fees instead of relying on the server-side settlement-fee fallback.
- Primary-token entry for native ETH on Robinhood.
- Primary-token entries for X Layer (`196`) USDT (`0x779Ded0c9e1022225f8E0630b35a9b54bE713736`) and USDC (`0x74b7F16337b8972027F6196A17a631aC6dE26d22`). X Layer was a supported chain with no primary tokens at all, so these two resolved through the `${chainId}_${address}` fallback in `getTokenConfig` instead of their token type. Balance aggregation is computed server-side from the server's own registry and was never affected.
- A registry test that fails when a supported chain has no primary token, when a default primary token type has no entry, or when the table gains a duplicate `(chainId, address)`, a bad EIP-55 checksum, or a second `isMultiChainDefault` for one type.

### Changed
- **The default `usePrimaryTokens` is now `[eth, usdt, usdc, bnb, sol, usdg]`.** This is a runtime change for every caller that does not pass `usePrimaryTokens` explicitly: a user's Robinhood USDG balance becomes eligible as an input token and as a fee token on any transaction the SDK builds, including transactions targeting other chains. Pass an explicit `usePrimaryTokens` to keep the previous set.
- `SUPPORTED_TOKEN_TYPE` gained a member, which is a compile-time break for callers that switch exhaustively over it or key a `Record` by it.
- `UNIVERSAL_ACCOUNT_VERSION_V2_SUPPORTED_TOKEN_TYPES` is now `SUPPORTED_TOKEN_TYPES` (the enum itself) instead of a hand-maintained copy that had to be edited twice to add one token. Same members in the same order, so the value on the wire is unchanged; it does make explicit that the default funding and fee set is every token type this SDK version knows about.
- The unsupported-chain error no longer interpolates `smartAccountOptions.version`; it now reads `Chain <id> is not supported by universal account 2.x`. The chain list is the 2.x scope and the guard never consulted the version, so the old message claimed a version-awareness the SDK does not have.

### Removed
- Three dependencies that no source, test or build file ever imported: `@noble/hashes`, `@solana/spl-token` and `fast-json-stable-stringify`. Dropping `@solana/spl-token` also removes the `@solana/buffer-layout-utils` → `bigint-buffer` path.

### Security
- Refreshed the lockfile within the existing ranges: `axios` 1.8.4 → 1.19.0 (and with it `form-data` 4.0.2 → 4.0.6), `viem` 2.24.3 → 2.55.13 (and `ws` → 8.21.0), `@solana/web3.js` 1.98.0 → 1.98.4, `bn.js` → 5.2.5, `jayson` → 4.3.0. No declared range changed, so consumers resolving from `package.json` were never affected — these were stale pins in this repository's lockfile.
- `npm audit --omit=dev` goes from 13 findings (1 critical, 6 high, 6 moderate) to 7 (1 high, 6 moderate). The critical (`form-data`) and the `bigint-buffer` findings are gone.
- What remains is pinned by `jayson@4.3.0` (`ws: ^7.5.10`, `uuid: ^8.3.2`) underneath `@solana/web3.js` 1.x, which has no fixed 1.x release. Resolving it means migrating off `@solana/web3.js` 1.x — `@coral-xyz/anchor` depends on it too — and is out of scope here. The SDK never opens a Solana RPC connection (`@solana/web3.js` is a type-only import and the anchor `Program` is constructed with a null provider), so `jayson`'s websocket client is not instantiated on any SDK code path.

### Upgrade notes
- On the `createUniversalTransaction` / `createConvertTransaction` path the SDK sends the primary token types verbatim as `fee.tokenTypes` and `inputTokens`, and Universal Server rejects unknown token types outright (`-32602 Invalid token type`) on that path rather than dropping them the way the buy / sell / transfer path does. Point this release at a deployment that already knows `usdg`.
- `usdg` is a valid `expectToken.type` only on Robinhood. Building a "convert to…" menu by enumerating `SUPPORTED_TOKEN_TYPES` will offer it on chains where the server rejects it.

## [2.0.3] - 2026-06-29

### Removed
- **Breaking:** removed legacy universal account v1 (`1.0.3`) support — `UNIVERSAL_ACCOUNT_VERSION_V1` and all version-branching logic; every account is now treated as v2.
- **Breaking:** removed the unused `SUPPORTED_TARGET_TOKENS_V1` / `SUPPORTED_TARGET_TOKENS_V2` / `SUPPORTED_TARGET_TOKENS` tables (token resolution uses `SUPPORTED_PRIMARY_TOKENS`).
- **Breaking:** trimmed `CHAIN_ID` and `SUPPORTED_PRIMARY_TOKENS` to the 6 supported chains (Solana, Ethereum, BSC, Base, X Layer, Arbitrum).
- **Breaking:** removed the deprecated top-level `ownerAddress` from `IUniversalAccountConfig` (use `smartAccountOptions.ownerAddress`).

### Changed
- Removed the now-vestigial token-type guards; the chain guard was simplified to `assertSupportedChain`.

## [2.0.2] - 2026-06-29

### Removed
- Removed the `BTC` token type from `SUPPORTED_TOKEN_TYPE` and from all token tables (the v1 target-token list and the primary-token list).
- Removed the `SUPPORTED_TOKEN_PARTI` constant.
- Removed the `universalGas` option from `ITradeConfig`, along with the related "use PARTI as gas" fee-token logic in `createUniversalTransaction` / `getTradeOptions`.

## [2.0.1] - 2026-06-29

### Fixed
- Corrected the default production RPC endpoint to `https://universal-rpc-proxy.particle.network`. An explicit `rpcUrl` or the `UNIVERSALX_RPC_URL` env var still takes precedence.

## [2.0.0] - 2026-06-29

First stable 2.0.0 release. Rolls up the 2.0.0-beta.1–beta.3 changes:

- Default universal account version is `2.0.1`, limited to Solana, Ethereum, Base, Arbitrum, BNB Chain, and X Layer, with primary token types `SOL`, `ETH`, `BNB`, `USDT`, and `USDC`. Unsupported token types now throw a clear error before sending.
- Multi-chain tokens are no longer mapped to `universal_` asset ids; the unused multi-chain token data and exports were removed, shrinking the bundle from ~530KB to ~46KB.
- `UniversalError` carries the JSON-RPC `error.data` and exposes `code`/`data`; the SDK no longer logs RPC errors to the console.
- The default RPC endpoint is the production endpoint (`https://universal-rpc.particle.network`). An explicit `rpcUrl` or the `UNIVERSALX_RPC_URL` env var still takes precedence.

## [2.0.0-beta.3] - 2026-06-22

### Changed
- Beta builds default to the staging RPC endpoint when no `rpcUrl` or `UNIVERSALX_RPC_URL` is provided. An explicit `rpcUrl` or the `UNIVERSALX_RPC_URL` env var still takes precedence; production stays the default for stable releases.

## [2.0.0-beta.2] - 2026-06-22

### Removed
- Removed the unused multi-chain token data and the `MULTI_CHAIN_TOKENS`, `MULTI_CHAIN_TOKENS_MAP`, and `MULTI_CHAIN_TOKENS_PREFIX` exports (the `universal_` mapping was already disabled). Shrinks the built bundle from ~530KB to ~46KB.

## [2.0.0-beta.1] - 2026-06-22

### Changed
- Default universal account version is now `2.0.1`.
- `2.0.1` accounts are limited to Solana, Ethereum, Base, Arbitrum, BNB Chain, and X Layer.
- `2.0.1` primary token types are limited to `SOL`, `ETH`, `BNB`, `USDT`, and `USDC`.
- For `2.0.1` accounts, a token whose type is not supported (e.g. `BTC`) on an otherwise supported chain now throws a clear error before sending, instead of silently resolving to a raw `<chainId>_<address>` asset id.
- Multi-chain tokens are no longer mapped to `universal_` asset ids.
- `UniversalError` now carries the JSON-RPC `error.data` and exposes `code`/`data` publicly, so callers can read structured error fields. The SDK no longer logs RPC errors to the console — handling is left to the caller.

## [1.0.25]

### Added
- Added `PREFER_TOKEN_TYPE` enum to support token preference configuration
  - `USD`: Prefer USD tokens
  - `NATIVE`: Prefer native tokens
- Added `preferTokenType` option to `ITradeConfig` interface for specifying token preference in trading operations
- Restored `warmUpToken` method to pre-warm token asset routing for faster subsequent transactions
  - Supports specifying the token to warm up via `chainId` and `address`


## [1.0.20]

### Added
- Added EIP-7702 support for EOA delegation
  - Added `useEIP7702` option to `ISmartAccountOptions` for enabling EIP-7702 delegation
  - Added `authorizations` parameter to `sendTransaction` method for EIP-7702 authorization support
  - Added `getEIP7702Deployments` method to retrieve EIP-7702 deployment addresses
  - Added `getEIP7702Auth` method to create EIP-7702 delegation authorization

## [1.0.11]

### Added
- Added `MEV_PROTECTION_TYPE` enum to support MEV protection configuration
  - `MEV_PROTECTION_OFF`: Disable MEV protection
  - `MEV_PROTECTION_REDUCE`: Enable reduced MEV protection
  - `MEV_PROTECTION_SECURITY`: Enable full security MEV protection
- Added `mevProtection` option to `ITradeConfig` interface for configuring MEV protection in trading operations

## [1.0.10]

### Removed
- Removed `getUniversalSignature` method

## [1.0.9] - 2025-01-19
- Complete Type

## [1.0.8] - 2025-01-13

### Added
- Added `getTokenPair` method to retrieve token pair information for trading
  - Returns pair address and factory address for the specified token
- Added `priorityFeeRatio` option to `ITradeConfig` for  transaction priority fee configuration
- Added `tokenPair` option to `ITradeConfig` for specifying custom token pair in trading operations

### Deprecated
- Marked `warmUpToken` method as deprecated

## [1.0.7] - 2025-10-27

### Added
- Added `getTransactions` method to retrieve transaction history with pagination support
  - Supports filtering by transaction tag
  - Supports pagination with page and limit parameters
- Added `getTokenTransactions` method to retrieve token-specific transaction history
  - Supports pagination with pageToken parameter
  - Filters transactions by specific token asset

### Changed
- Code style improvements: standardized quote usage from double quotes to single quotes
- Improved code formatting and consistency across the codebase

## [1.0.6] - 2025-10-15

### Added
- Added `warmUpToken` method to pre-warm token asset routing for faster subsequent transactions
  - Supports specifying the token to warm up via `chainId` and `address`

## [1.0.5]

### Features
- Added `tradeConfig` parameter support for `createConvertTransaction`
- Added `tradeConfig` parameter support for `createUniversalTransaction`
- Added `addressLookupTableAccountAddresses` option to `tradeConfig`
