Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions packages/shield-controller/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
43 changes: 42 additions & 1 deletion packages/shield-controller/src/backend.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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',
},
],
},
],
});
});
});
});
5 changes: 4 additions & 1 deletion packages/shield-controller/src/backend.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -26,6 +27,7 @@ import type {
export type InitCoverageCheckRequest = {
txParams: [
{
authorizationList?: AuthorizationList;
from: string;
to?: string;
value?: string;
Expand Down Expand Up @@ -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,
Expand Down
Loading