diff --git a/packages/shield-controller/CHANGELOG.md b/packages/shield-controller/CHANGELOG.md index ebc007fed33..b59a5201404 100644 --- a/packages/shield-controller/CHANGELOG.md +++ b/packages/shield-controller/CHANGELOG.md @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +### Added + +- Added `AuthorizationList` in transaction init and log requests for 7702 transactions. ([#7246](https://github.com/MetaMask/core/pull/7246)) + ### Changed - Move peer dependencies for controller and service packages to direct dependencies ([#7209](https://github.com/MetaMask/core/pull/7209), [#7220](https://github.com/MetaMask/core/pull/7220), [#7236](https://github.com/MetaMask/core/pull/7236)) diff --git a/packages/shield-controller/src/backend.test.ts b/packages/shield-controller/src/backend.test.ts index 820986bc948..fa6d1cae82d 100644 --- a/packages/shield-controller/src/backend.test.ts +++ b/packages/shield-controller/src/backend.test.ts @@ -3,7 +3,11 @@ import { SignatureRequestType, } from '@metamask/signature-controller'; -import { parseSignatureRequestMethod, ShieldRemoteBackend } from './backend'; +import { + makeInitCoverageCheckBody, + parseSignatureRequestMethod, + ShieldRemoteBackend, +} from './backend'; import { SignTypedDataVersion } from './constants'; import { generateMockSignatureRequest, @@ -423,4 +427,41 @@ describe('ShieldRemoteBackend', () => { ); }); }); + + describe('makeInitCoverageCheckBody', () => { + it('makes init coverage check body', () => { + const txMeta = generateMockTxMeta(); + const body = makeInitCoverageCheckBody(txMeta); + expect(body).toMatchObject({ + txParams: [txMeta.txParams], + }); + }); + + it('makes init coverage check body with authorization list', () => { + const txMeta = generateMockTxMeta(); + const body = makeInitCoverageCheckBody({ + ...txMeta, + txParams: { + ...txMeta.txParams, + authorizationList: [ + { + address: '0x0000000000000000000000000000000000000000', + }, + ], + }, + }); + expect(body).toMatchObject({ + txParams: [ + { + ...txMeta.txParams, + authorizationList: [ + { + address: '0x0000000000000000000000000000000000000000', + }, + ], + }, + ], + }); + }); + }); }); diff --git a/packages/shield-controller/src/backend.ts b/packages/shield-controller/src/backend.ts index cd94bc910a7..83a52fcf05b 100644 --- a/packages/shield-controller/src/backend.ts +++ b/packages/shield-controller/src/backend.ts @@ -9,6 +9,7 @@ import { type SignatureRequest, } from '@metamask/signature-controller'; import type { TransactionMeta } from '@metamask/transaction-controller'; +import type { AuthorizationList } from '@metamask/transaction-controller'; import type { Json } from '@metamask/utils'; import { SignTypedDataVersion } from './constants'; @@ -26,6 +27,7 @@ import type { export type InitCoverageCheckRequest = { txParams: [ { + authorizationList?: AuthorizationList; from: string; to?: string; value?: string; @@ -284,12 +286,13 @@ export class ShieldRemoteBackend implements ShieldBackend { * @param txMeta - The transaction metadata. * @returns The body for the init coverage check request. */ -function makeInitCoverageCheckBody( +export function makeInitCoverageCheckBody( txMeta: TransactionMeta, ): InitCoverageCheckRequest { return { txParams: [ { + authorizationList: txMeta.txParams.authorizationList, from: txMeta.txParams.from, to: txMeta.txParams.to, value: txMeta.txParams.value,