Skip to content

Commit 9b0c926

Browse files
authored
feat: include 'AuthorizationList' params in tx init and log requests (#7246)
## Explanation <!-- Thanks for your contribution! Take a moment to answer these questions so that reviewers have the information they need to properly understand your changes: * What is the current state of things and why does it need to change? * What is the solution your changes offer and how does it work? * Are there any changes whose purpose might not obvious to those unfamiliar with the domain? * If your primary goal was to update one package but you found you had to update another one along the way, why did you do so? * If you had to upgrade a dependency, why did you do so? --> This PR adds 7702 tx params in shield init and log requests. ## References <!-- Are there any issues that this pull request is tied to? Are there other links that reviewers should consult to understand these changes better? Are there client or consumer pull requests to adopt any breaking changes? For example: * Fixes #12345 * Related to #67890 --> ## Checklist - [x] I've updated the test suite for new or updated code as appropriate - [ ] I've updated documentation (JSDoc, Markdown, etc.) for new or updated code as appropriate - [ ] I've communicated my changes to consumers by [updating changelogs for packages I've changed](https://github.com/MetaMask/core/tree/main/docs/contributing.md#updating-changelogs) - [ ] I've introduced [breaking changes](https://github.com/MetaMask/core/tree/main/docs/breaking-changes.md) in this PR and have prepared draft pull requests for clients and consumer packages to resolve them <!-- CURSOR_SUMMARY --> --- > [!NOTE] > Adds AuthorizationList to transaction coverage init/log request bodies, exports makeInitCoverageCheckBody, and updates tests and changelog. > > - **Backend**: > - Update `InitCoverageCheckRequest` to include optional `authorizationList` in `txParams` and propagate it in `makeInitCoverageCheckBody`. > - Export `makeInitCoverageCheckBody` from `backend.ts`. > - **Tests**: > - Import and test `makeInitCoverageCheckBody` for cases with/without `authorizationList`. > - **Docs**: > - Update `CHANGELOG.md` noting addition of `AuthorizationList` in transaction init and log requests for 7702 transactions. > > <sup>Written by [Cursor Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit 66e0169. This will update automatically on new commits. Configure [here](https://cursor.com/dashboard?tab=bugbot).</sup> <!-- /CURSOR_SUMMARY -->
1 parent c2f0185 commit 9b0c926

File tree

3 files changed

+50
-2
lines changed

3 files changed

+50
-2
lines changed

packages/shield-controller/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## [Unreleased]
99

10+
### Added
11+
12+
- Added `AuthorizationList` in transaction init and log requests for 7702 transactions. ([#7246](https://github.com/MetaMask/core/pull/7246))
13+
1014
### Changed
1115

1216
- 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))

packages/shield-controller/src/backend.test.ts

Lines changed: 42 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,11 @@ import {
33
SignatureRequestType,
44
} from '@metamask/signature-controller';
55

6-
import { parseSignatureRequestMethod, ShieldRemoteBackend } from './backend';
6+
import {
7+
makeInitCoverageCheckBody,
8+
parseSignatureRequestMethod,
9+
ShieldRemoteBackend,
10+
} from './backend';
711
import { SignTypedDataVersion } from './constants';
812
import {
913
generateMockSignatureRequest,
@@ -423,4 +427,41 @@ describe('ShieldRemoteBackend', () => {
423427
);
424428
});
425429
});
430+
431+
describe('makeInitCoverageCheckBody', () => {
432+
it('makes init coverage check body', () => {
433+
const txMeta = generateMockTxMeta();
434+
const body = makeInitCoverageCheckBody(txMeta);
435+
expect(body).toMatchObject({
436+
txParams: [txMeta.txParams],
437+
});
438+
});
439+
440+
it('makes init coverage check body with authorization list', () => {
441+
const txMeta = generateMockTxMeta();
442+
const body = makeInitCoverageCheckBody({
443+
...txMeta,
444+
txParams: {
445+
...txMeta.txParams,
446+
authorizationList: [
447+
{
448+
address: '0x0000000000000000000000000000000000000000',
449+
},
450+
],
451+
},
452+
});
453+
expect(body).toMatchObject({
454+
txParams: [
455+
{
456+
...txMeta.txParams,
457+
authorizationList: [
458+
{
459+
address: '0x0000000000000000000000000000000000000000',
460+
},
461+
],
462+
},
463+
],
464+
});
465+
});
466+
});
426467
});

packages/shield-controller/src/backend.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import {
99
type SignatureRequest,
1010
} from '@metamask/signature-controller';
1111
import type { TransactionMeta } from '@metamask/transaction-controller';
12+
import type { AuthorizationList } from '@metamask/transaction-controller';
1213
import type { Json } from '@metamask/utils';
1314

1415
import { SignTypedDataVersion } from './constants';
@@ -26,6 +27,7 @@ import type {
2627
export type InitCoverageCheckRequest = {
2728
txParams: [
2829
{
30+
authorizationList?: AuthorizationList;
2931
from: string;
3032
to?: string;
3133
value?: string;
@@ -284,12 +286,13 @@ export class ShieldRemoteBackend implements ShieldBackend {
284286
* @param txMeta - The transaction metadata.
285287
* @returns The body for the init coverage check request.
286288
*/
287-
function makeInitCoverageCheckBody(
289+
export function makeInitCoverageCheckBody(
288290
txMeta: TransactionMeta,
289291
): InitCoverageCheckRequest {
290292
return {
291293
txParams: [
292294
{
295+
authorizationList: txMeta.txParams.authorizationList,
293296
from: txMeta.txParams.from,
294297
to: txMeta.txParams.to,
295298
value: txMeta.txParams.value,

0 commit comments

Comments
 (0)