diff --git a/app/scripts/controllers/transactions/index.js b/app/scripts/controllers/transactions/index.js index 37de2830e610..9b9218345410 100644 --- a/app/scripts/controllers/transactions/index.js +++ b/app/scripts/controllers/transactions/index.js @@ -359,6 +359,10 @@ export default class TransactionController extends EventEmitter { undefined, undefined, opts.id, + undefined, + ///: BEGIN:ONLY_INCLUDE_IN(blockaid) + opts.securityAlertResponse, + ///: END:ONLY_INCLUDE_IN ); const txId = initialTxMeta.id; @@ -1600,6 +1604,9 @@ export default class TransactionController extends EventEmitter { sendFlowHistory = [], actionId, options, + ///: BEGIN:ONLY_INCLUDE_IN(blockaid) + securityAlertResponse, + ///: END:ONLY_INCLUDE_IN ) { if ( transactionType !== undefined && @@ -1636,6 +1643,9 @@ export default class TransactionController extends EventEmitter { txParams: normalizedTxParams, origin, sendFlowHistory, + ///: BEGIN:ONLY_INCLUDE_IN(blockaid) + securityAlertResponse, + ///: END:ONLY_INCLUDE_IN }); // Add actionId to txMeta to check if same actionId is seen again @@ -2322,6 +2332,9 @@ export default class TransactionController extends EventEmitter { finalApprovalAmount, contractMethodName, securityProviderResponse, + ///: BEGIN:ONLY_INCLUDE_IN(blockaid) + securityAlertResponse, + ///: END:ONLY_INCLUDE_IN } = txMeta; const source = referrer === ORIGIN_METAMASK ? 'user' : 'dapp'; @@ -2498,6 +2511,11 @@ export default class TransactionController extends EventEmitter { transaction_type: transactionType, transaction_speed_up: type === TransactionType.retry, ui_customizations: uiCustomizations, + ///: BEGIN:ONLY_INCLUDE_IN(blockaid) + security_alert_response: + securityAlertResponse?.result_type ?? 'not_applicable', + security_alert_reason: securityAlertResponse?.reason ?? 'not_applicable', + ///: END:ONLY_INCLUDE_IN }; if (transactionContractMethod === contractMethodNames.APPROVE) { diff --git a/app/scripts/controllers/transactions/index.test.js b/app/scripts/controllers/transactions/index.test.js index 8600f08dc4b5..8303fd63de93 100644 --- a/app/scripts/controllers/transactions/index.test.js +++ b/app/scripts/controllers/transactions/index.test.js @@ -2423,6 +2423,8 @@ describe('Transaction Controller', function () { device_model: 'N/A', transaction_speed_up: false, ui_customizations: null, + security_alert_reason: 'not_applicable', + security_alert_response: 'not_applicable', }, sensitiveProperties: { default_gas: '0.000031501', @@ -2510,6 +2512,8 @@ describe('Transaction Controller', function () { device_model: 'N/A', transaction_speed_up: false, ui_customizations: null, + security_alert_reason: 'not_applicable', + security_alert_response: 'not_applicable', }, sensitiveProperties: { default_gas: '0.000031501', @@ -2609,6 +2613,8 @@ describe('Transaction Controller', function () { device_model: 'N/A', transaction_speed_up: false, ui_customizations: null, + security_alert_reason: 'not_applicable', + security_alert_response: 'not_applicable', }, sensitiveProperties: { default_gas: '0.000031501', @@ -2698,6 +2704,8 @@ describe('Transaction Controller', function () { device_model: 'N/A', transaction_speed_up: false, ui_customizations: null, + security_alert_reason: 'not_applicable', + security_alert_response: 'not_applicable', }, sensitiveProperties: { default_gas: '0.000031501', @@ -2765,6 +2773,10 @@ describe('Transaction Controller', function () { securityProviderResponse: { flagAsDangerous: 0, }, + securityAlertResponse: { + result_type: 'Benign', + reason: 'none', + }, }; const expectedPayload = { @@ -2789,6 +2801,8 @@ describe('Transaction Controller', function () { device_model: 'N/A', transaction_speed_up: false, ui_customizations: null, + security_alert_response: 'Benign', + security_alert_reason: 'none', }, sensitiveProperties: { gas_price: '2', @@ -2861,6 +2875,8 @@ describe('Transaction Controller', function () { device_model: 'N/A', transaction_speed_up: false, ui_customizations: null, + security_alert_reason: 'not_applicable', + security_alert_response: 'not_applicable', }, sensitiveProperties: { baz: 3.0, @@ -2935,6 +2951,8 @@ describe('Transaction Controller', function () { device_model: 'N/A', transaction_speed_up: false, ui_customizations: ['flagged_as_malicious'], + security_alert_reason: 'not_applicable', + security_alert_response: 'not_applicable', }, sensitiveProperties: { baz: 3.0, @@ -3009,6 +3027,8 @@ describe('Transaction Controller', function () { device_model: 'N/A', transaction_speed_up: false, ui_customizations: ['flagged_as_safety_unknown'], + security_alert_reason: 'not_applicable', + security_alert_response: 'not_applicable', }, sensitiveProperties: { baz: 3.0, @@ -3091,6 +3111,8 @@ describe('Transaction Controller', function () { device_model: 'N/A', transaction_speed_up: false, ui_customizations: null, + security_alert_reason: 'not_applicable', + security_alert_response: 'not_applicable', }, sensitiveProperties: { baz: 3.0,