Skip to content
This repository has been archived by the owner on Oct 7, 2024. It is now read-only.

Commit

Permalink
Merge branch 'main' into replace-superstruct-with-fork
Browse files Browse the repository at this point in the history
  • Loading branch information
MajorLift authored Jun 6, 2024
2 parents 34d0639 + 5d9c4ba commit 7bab3f3
Show file tree
Hide file tree
Showing 5 changed files with 457 additions and 253 deletions.
12 changes: 11 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,15 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

## [4.2.1]

### Changed

- Fixed 4337 methods enum ([#312](https://github.com/MetaMask/eth-snap-keyring/pull/312))
- Bump @metamask/post-message-stream from 8.0.0 to 8.1.0 ([#297](https://github.com/MetaMask/eth-snap-keyring/pull/297))
- Bump @metamask/permission-controller from 9.0.2 to 9.1.0 ([#306](https://github.com/MetaMask/eth-snap-keyring/pull/306))
- Bump @metamask/snaps-sdk from 4.2.0 to 4.3.0 ([#308](https://github.com/MetaMask/eth-snap-keyring/pull/308))

## [4.2.0]

### Added
Expand Down Expand Up @@ -253,7 +262,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

- Initial release.

[Unreleased]: https://github.com/MetaMask/eth-snap-keyring/compare/v4.2.0...HEAD
[Unreleased]: https://github.com/MetaMask/eth-snap-keyring/compare/v4.2.1...HEAD
[4.2.1]: https://github.com/MetaMask/eth-snap-keyring/compare/v4.2.0...v4.2.1
[4.2.0]: https://github.com/MetaMask/eth-snap-keyring/compare/v4.1.1...v4.2.0
[4.1.1]: https://github.com/MetaMask/eth-snap-keyring/compare/v4.1.0...v4.1.1
[4.1.0]: https://github.com/MetaMask/eth-snap-keyring/compare/v4.0.0...v4.1.0
Expand Down
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@metamask/eth-snap-keyring",
"version": "4.2.0",
"version": "4.2.1",
"description": "Snaps keyring bridge.",
"repository": {
"type": "git",
Expand All @@ -27,7 +27,7 @@
"dependencies": {
"@ethereumjs/tx": "^4.2.0",
"@metamask/eth-sig-util": "^7.0.1",
"@metamask/keyring-api": "^6.2.1",
"@metamask/keyring-api": "^6.3.1",
"@metamask/snaps-controllers": "^8.1.1",
"@metamask/snaps-sdk": "^4.2.0",
"@metamask/snaps-utils": "^7.4.0",
Expand All @@ -37,7 +37,7 @@
"uuid": "^9.0.0"
},
"devDependencies": {
"@lavamoat/allow-scripts": "^2.3.1",
"@lavamoat/allow-scripts": "^3.0.4",
"@metamask/auto-changelog": "^3.4.4",
"@metamask/eslint-config": "^12.2.0",
"@metamask/eslint-config-jest": "^12.1.0",
Expand Down
24 changes: 19 additions & 5 deletions src/SnapKeyring.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import {
BtcAccountType,
BtcMethod,
EthAccountType,
EthErc4337Method,
EthMethod,
} from '@metamask/keyring-api';
import { KeyringEvent } from '@metamask/keyring-api/dist/events';
Expand All @@ -25,6 +24,21 @@ import { SnapKeyring } from '.';
const regexForUUIDInRequiredSyncErrorMessage =
/Request '[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}' to snap 'local:snap.mock' is pending and expectSync is true/u;

const ETH_4337_METHODS = [
EthMethod.PatchUserOperation,
EthMethod.PrepareUserOperation,
EthMethod.SignUserOperation,
];

const ETH_EOA_METHODS = [
EthMethod.PersonalSign,
EthMethod.Sign,
EthMethod.SignTransaction,
EthMethod.SignTypedDataV1,
EthMethod.SignTypedDataV3,
EthMethod.SignTypedDataV4,
];

describe('SnapKeyring', () => {
let keyring: SnapKeyring;

Expand Down Expand Up @@ -62,29 +76,29 @@ describe('SnapKeyring', () => {
id: 'b05d918a-b37c-497a-bb28-3d15c0d56b7a',
address: '0xC728514Df8A7F9271f4B7a4dd2Aa6d2D723d3eE3'.toLowerCase(),
options: {},
methods: [...Object.values(EthMethod)],
methods: ETH_EOA_METHODS,
type: EthAccountType.Eoa,
};
const ethEoaAccount2 = {
id: '33c96b60-2237-488e-a7bb-233576f3d22f',
address: '0x34b13912eAc00152bE0Cb409A301Ab8E55739e63'.toLowerCase(),
options: {},
methods: [...Object.values(EthMethod)],
methods: ETH_EOA_METHODS,
type: EthAccountType.Eoa,
};
const ethEoaAccount3 = {
id: 'c6697bcf-5710-4751-a1cb-340e4b50617a',
address: '0xab1G3q98V7C67T9103g30C0417610237A137d763'.toLowerCase(),
options: {},
methods: [...Object.values(EthMethod)],
methods: ETH_EOA_METHODS,
type: EthAccountType.Eoa,
};

const ethErc4337Account = {
id: 'fc926fff-f515-4eb5-9952-720bbd9b9849',
address: '0x2f15b30952aebe0ed5fdbfe5bf16fb9ecdb31d9a'.toLowerCase(),
options: {},
methods: [...Object.values(EthErc4337Method)],
methods: ETH_4337_METHODS,
type: EthAccountType.Erc4337,
};
const btcP2wpkhAccount = {
Expand Down
9 changes: 4 additions & 5 deletions src/SnapKeyring.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ import {
AccountUpdatedEventStruct,
EthBaseUserOperationStruct,
EthBytesStruct,
EthErc4337Method,
EthMethod,
EthUserOperationPatchStruct,
KeyringEvent,
Expand Down Expand Up @@ -57,7 +56,7 @@ export const SNAP_KEYRING_TYPE = 'Snap Keyring';

// TODO: to be removed when this is added to the keyring-api

type AccountMethod = EthMethod | EthErc4337Method | BtcMethod;
type AccountMethod = EthMethod | BtcMethod;

/**
* Snap keyring state.
Expand Down Expand Up @@ -743,7 +742,7 @@ export class SnapKeyring extends EventEmitter {
return strictMask(
await this.#submitRequest({
address,
method: EthErc4337Method.PrepareUserOperation,
method: EthMethod.PrepareUserOperation,
params: toJson<Json[]>(transactions),
expectSync: true,
// We assume the chain ID is already well formatted
Expand All @@ -770,7 +769,7 @@ export class SnapKeyring extends EventEmitter {
return strictMask(
await this.#submitRequest({
address,
method: EthErc4337Method.PatchUserOperation,
method: EthMethod.PatchUserOperation,
params: toJson<Json[]>([userOp]),
expectSync: true,
// We assume the chain ID is already well formatted
Expand All @@ -796,7 +795,7 @@ export class SnapKeyring extends EventEmitter {
return strictMask(
await this.#submitRequest({
address,
method: EthErc4337Method.SignUserOperation,
method: EthMethod.SignUserOperation,
params: toJson<Json[]>([userOp]),
// We assume the chain ID is already well formatted
chainId: toCaipChainId(KnownCaipNamespace.Eip155, context.chainId),
Expand Down
Loading

0 comments on commit 7bab3f3

Please sign in to comment.