Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

### Changed
- **BREAKING**: The controller now reads feature flags directly from `RemoteFeatureFlagController` via the messenger instead of using the `getFeatureFlags` callback
- Clients must configure `RemoteFeatureFlagController:getState` as an allowed action in the controller messenger
- The `getFeatureFlags` constructor option is now deprecated and ignored

## [20.1.0]

### Added
Expand Down
39 changes: 39 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,45 @@ or
Run `yarn test` to run the tests once. To run tests on file changes, run `yarn test:watch`.

Run `yarn lint` to run the linter, or run `yarn lint:fix` to run the linter and fix any automatically fixable issues.
### Feature Flags

Smart transactions feature flags are managed via `RemoteFeatureFlagController` (LaunchDarkly). The configuration uses a `default` object for global settings and chain-specific overrides keyed by hex chain ID.

#### Adding a New Flag

1. **Add the field to the schema** in `src/utils/validators.ts`:

```typescript
export const SmartTransactionsNetworkConfigSchema = type({
// ... existing fields
myNewFlag: optional(boolean()),
});
```

The `SmartTransactionsNetworkConfig` type is automatically inferred from this schema.

2. **Add default value** in `src/constants.ts` under `DEFAULT_SMART_TRANSACTIONS_FEATURE_FLAGS`:

```typescript
export const DEFAULT_SMART_TRANSACTIONS_FEATURE_FLAGS = {
default: {
// ... existing defaults
myNewFlag: false,
},
};
```

3. **Use in clients** via the exported selectors:

```typescript
import { selectSmartTransactionsFeatureFlagsForChain } from '@metamask/smart-transactions-controller';

const chainConfig = selectSmartTransactionsFeatureFlagsForChain(state, '0x1');
if (chainConfig.myNewFlag) {
// Feature is enabled
}
```


### Release & Publishing

Expand Down
12 changes: 8 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,22 +51,27 @@
"@metamask/eth-query": "^4.0.0",
"@metamask/messenger": "^0.3.0",
"@metamask/polling-controller": "^15.0.0",
"@metamask/superstruct": "^3.1.0",
"@metamask/utils": "^11.0.0",
"bignumber.js": "^9.0.1",
"fast-json-patch": "^3.1.0",
"lodash": "^4.17.21"
"lodash": "^4.17.21",
"reselect": "^5.1.1"
},
"devDependencies": {
"@arethetypeswrong/cli": "^0.18.2",
"@lavamoat/allow-scripts": "^3.2.1",
"@lavamoat/preinstall-always-fail": "^2.1.0",
"@metamask/auto-changelog": "^3.1.0",
"@metamask/error-reporting-service": "^3.0.0",
"@metamask/eslint-config": "^12.2.0",
"@metamask/eslint-config-jest": "^12.1.0",
"@metamask/eslint-config-nodejs": "^12.1.0",
"@metamask/eslint-config-typescript": "^12.1.0",
"@metamask/gas-fee-controller": "^22.0.0",
"@metamask/json-rpc-engine": "^10.0.1",
"@metamask/network-controller": "^25.0.0",
"@metamask/remote-feature-flag-controller": "^2.0.0",
"@metamask/transaction-controller": "^61.0.0",
"@ts-bridge/cli": "^0.6.3",
"@types/jest": "^26.0.24",
Expand All @@ -93,7 +98,9 @@
"typescript": "~4.8.4"
},
"peerDependencies": {
"@metamask/error-reporting-service": "^3.0.0",
"@metamask/network-controller": "^25.0.0",
"@metamask/remote-feature-flag-controller": "^2.0.0",
"@metamask/transaction-controller": "^61.0.0"
},
"peerDependenciesMeta": {
Expand All @@ -108,9 +115,6 @@
},
"@metamask/gas-fee-controller": {
"optional": true
},
"@metamask/remote-feature-flag-controller": {
"optional": true
}
},
"packageManager": "yarn@3.2.1",
Expand Down
Loading
Loading