Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/develop' into cryptodev2s/bump-u…
Browse files Browse the repository at this point in the history
…ser-operatin-controller-19.0.0
  • Loading branch information
cryptodev-2s committed Nov 29, 2024
2 parents 9a9a2f8 + 7143c96 commit 87d926c
Show file tree
Hide file tree
Showing 39 changed files with 389 additions and 279 deletions.
1 change: 0 additions & 1 deletion app/scripts/constants/sentry-state.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,6 @@ export const SENTRY_BACKGROUND_STATE = {
termsOfUseLastAgreed: true,
timeoutMinutes: true,
trezorModel: true,
usedNetworks: true,
},
MultichainBalancesController: {
balances: false,
Expand Down
11 changes: 0 additions & 11 deletions app/scripts/controllers/app-state-controller.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -374,17 +374,6 @@ describe('AppStateController', () => {
});
});

describe('setFirstTimeUsedNetwork', () => {
it('updates the array of the first time used networks', () => {
const chainId = '0x1';

appStateController.setFirstTimeUsedNetwork(chainId);
expect(appStateController.store.getState().usedNetworks[chainId]).toBe(
true,
);
});
});

describe('setLastInteractedConfirmationInfo', () => {
it('sets information about last confirmation user has interacted with', () => {
const lastInteractedConfirmationInfo = {
Expand Down
20 changes: 0 additions & 20 deletions app/scripts/controllers/app-state-controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ export type AppStateControllerState = {
hadAdvancedGasFeesSetPriorToMigration92_3: boolean;
qrHardware: Json;
nftsDropdownState: Json;
usedNetworks: Record<string, boolean>;
surveyLinkLastClickedOrClosed: number | null;
signatureSecurityAlertResponses: Record<string, SecurityAlertResponse>;
// States used for displaying the changed network toast
Expand Down Expand Up @@ -138,7 +137,6 @@ type AppStateControllerInitState = Partial<
AppStateControllerState,
| 'qrHardware'
| 'nftsDropdownState'
| 'usedNetworks'
| 'surveyLinkLastClickedOrClosed'
| 'signatureSecurityAlertResponses'
| 'switchedNetworkDetails'
Expand Down Expand Up @@ -184,11 +182,6 @@ const getDefaultAppStateControllerState = (
...initState,
qrHardware: {},
nftsDropdownState: {},
usedNetworks: {
'0x1': true,
'0x5': true,
'0x539': true,
},
surveyLinkLastClickedOrClosed: null,
signatureSecurityAlertResponses: {},
switchedNetworkDetails: null,
Expand Down Expand Up @@ -704,19 +697,6 @@ export class AppStateController extends EventEmitter {
});
}

/**
* Updates the array of the first time used networks
*
* @param chainId
*/
setFirstTimeUsedNetwork(chainId: string): void {
const currentState = this.store.getState();
const { usedNetworks } = currentState;
usedNetworks[chainId] = true;

this.store.updateState({ usedNetworks });
}

///: BEGIN:ONLY_INCLUDE_IF(build-mmi)
/**
* Set the interactive replacement token with a url and the old refresh token
Expand Down
2 changes: 1 addition & 1 deletion app/scripts/controllers/mmi-controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,7 @@ export class MMIController {
}
}

const txList = this.txStateManager.getTransactions({}, [], false); // Includes all transactions, but we are looping through keyrings. Currently filtering is done in updateCustodianTransactions :-/
const txList = this.txStateManager.getTransactions(); // Includes all transactions, but we are looping through keyrings. Currently filtering is done in updateCustodianTransactions :-/

try {
updateCustodianTransactions({
Expand Down
1 change: 1 addition & 0 deletions app/scripts/lib/transaction/metrics.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ describe('Transaction metrics', () => {
type: TransactionType.simpleSend,
origin: ORIGIN_METAMASK,
chainId: mockChainId,
networkClientId: 'testNetworkClientId',
time: 1624408066355,
defaultGasEstimates: {
gas: '0x7b0d',
Expand Down
1 change: 1 addition & 0 deletions app/scripts/lib/transaction/smart-transactions.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,7 @@ function withRequest<ReturnValue>(
},
type: TransactionType.simpleSend,
chainId: CHAIN_IDS.MAINNET,
networkClientId: 'testNetworkClientId',
time: 1624408066355,
defaultGasEstimates: {
gas: '0x7b0d',
Expand Down
39 changes: 1 addition & 38 deletions app/scripts/lib/transaction/util.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ const TRANSACTION_PARAMS_MOCK: TransactionParams = {

const TRANSACTION_OPTIONS_MOCK: AddTransactionOptions = {
actionId: 'mockActionId',
networkClientId: 'mockNetworkClientId',
origin: 'mockOrigin',
requireApproval: false,
type: TransactionType.simpleSend,
Expand Down Expand Up @@ -151,23 +152,6 @@ describe('Transaction Utils', () => {
});
});

it('adds transaction with networkClientId if process.env.TRANSACTION_MULTICHAIN is set', async () => {
process.env.TRANSACTION_MULTICHAIN = '1';

await addTransaction(request);

expect(
request.transactionController.addTransaction,
).toHaveBeenCalledTimes(1);
expect(
request.transactionController.addTransaction,
).toHaveBeenCalledWith(TRANSACTION_PARAMS_MOCK, {
...TRANSACTION_OPTIONS_MOCK,
networkClientId: 'mockNetworkClientId',
});
process.env.TRANSACTION_MULTICHAIN = '';
});

it('returns transaction meta', async () => {
const transactionMeta = await addTransaction(request);
expect(transactionMeta).toStrictEqual(TRANSACTION_META_MOCK);
Expand Down Expand Up @@ -541,27 +525,6 @@ describe('Transaction Utils', () => {
});
});

it('adds transaction with networkClientId if process.env.TRANSACTION_MULTICHAIN is set', async () => {
process.env.TRANSACTION_MULTICHAIN = '1';

await addDappTransaction(dappRequest);

expect(
request.transactionController.addTransaction,
).toHaveBeenCalledTimes(1);
expect(
request.transactionController.addTransaction,
).toHaveBeenCalledWith(TRANSACTION_PARAMS_MOCK, {
...TRANSACTION_OPTIONS_MOCK,
networkClientId: 'mockNetworkClientId',
method: DAPP_REQUEST_MOCK.method,
requireApproval: true,
securityAlertResponse: DAPP_REQUEST_MOCK.securityAlertResponse,
type: undefined,
});
process.env.TRANSACTION_MULTICHAIN = '';
});

it('returns transaction hash', async () => {
const transactionHash = await addDappTransaction(dappRequest);
expect(transactionHash).toStrictEqual(TRANSACTION_META_MOCK.hash);
Expand Down
7 changes: 4 additions & 3 deletions app/scripts/lib/transaction/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ type BaseAddTransactionRequest = {
};

type FinalAddTransactionRequest = BaseAddTransactionRequest & {
transactionOptions: AddTransactionOptions;
transactionOptions: Partial<AddTransactionOptions>;
};

export type AddTransactionRequest = FinalAddTransactionRequest & {
Expand All @@ -66,7 +66,7 @@ export async function addDappTransaction(
const { id: actionId, method, origin } = dappRequest;
const { securityAlertResponse, traceContext } = dappRequest;

const transactionOptions: AddTransactionOptions = {
const transactionOptions: Partial<AddTransactionOptions> = {
actionId,
method,
origin,
Expand Down Expand Up @@ -143,10 +143,11 @@ async function addTransactionWithController(
transactionParams,
networkClientId,
} = request;

const { result, transactionMeta } =
await transactionController.addTransaction(transactionParams, {
...transactionOptions,
...(process.env.TRANSACTION_MULTICHAIN ? { networkClientId } : {}),
networkClientId,
});

return {
Expand Down
Loading

0 comments on commit 87d926c

Please sign in to comment.