Skip to content

Commit

Permalink
Add a new "userOptInV2" prop (#222)
Browse files Browse the repository at this point in the history
  • Loading branch information
dan437 authored Nov 3, 2023
1 parent 697941a commit b21c8bf
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
9 changes: 6 additions & 3 deletions src/SmartTransactionsController.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,7 @@ const defaultState = {
[CHAIN_IDS.ETHEREUM]: [],
},
userOptIn: undefined,
userOptInV2: undefined,
fees: {
approvalTxFees: undefined,
tradeTxFees: undefined,
Expand Down Expand Up @@ -496,15 +497,15 @@ describe('SmartTransactionsController', () => {
it('sets optIn state', () => {
smartTransactionsController.setOptInState(true);
expect(
smartTransactionsController.state.smartTransactionsState.userOptIn,
smartTransactionsController.state.smartTransactionsState.userOptInV2,
).toBe(true);
smartTransactionsController.setOptInState(false);
expect(
smartTransactionsController.state.smartTransactionsState.userOptIn,
smartTransactionsController.state.smartTransactionsState.userOptInV2,
).toBe(false);
smartTransactionsController.setOptInState(undefined);
expect(
smartTransactionsController.state.smartTransactionsState.userOptIn,
smartTransactionsController.state.smartTransactionsState.userOptInV2,
).toBeUndefined();
});
});
Expand Down Expand Up @@ -611,6 +612,7 @@ describe('SmartTransactionsController', () => {
[CHAIN_IDS.ETHEREUM]: [pendingTransaction],
},
userOptIn: undefined,
userOptInV2: undefined,
fees: {
approvalTxFees: undefined,
tradeTxFees: undefined,
Expand Down Expand Up @@ -666,6 +668,7 @@ describe('SmartTransactionsController', () => {
],
},
userOptIn: undefined,
userOptInV2: undefined,
fees: {
approvalTxFees: undefined,
tradeTxFees: undefined,
Expand Down
4 changes: 3 additions & 1 deletion src/SmartTransactionsController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ export type SmartTransactionsControllerState = BaseState & {
smartTransactionsState: {
smartTransactions: Record<Hex, SmartTransaction[]>;
userOptIn: boolean | undefined;
userOptInV2: boolean | undefined;
liveness: boolean | undefined;
fees: FeeEstimates;
feesByChainId: Record<Hex, FeeEstimates>;
Expand Down Expand Up @@ -126,6 +127,7 @@ export default class SmartTransactionsController extends PollingControllerV1<
smartTransactionsState: {
smartTransactions: {},
userOptIn: undefined,
userOptInV2: undefined,
fees: {
approvalTxFees: undefined,
tradeTxFees: undefined,
Expand Down Expand Up @@ -232,7 +234,7 @@ export default class SmartTransactionsController extends PollingControllerV1<
this.update({
smartTransactionsState: {
...this.state.smartTransactionsState,
userOptIn: state,
userOptInV2: state,
},
});
}
Expand Down

0 comments on commit b21c8bf

Please sign in to comment.