From b03511bdf6d053a450e8367e2c3377a058c6259f Mon Sep 17 00:00:00 2001 From: Florin Dzeladini Date: Mon, 30 Nov 2026 10:55:32 +0100 Subject: [PATCH 1/2] feat(keyring-api): add XRPL account types and scopes --- packages/keyring-api/CHANGELOG.md | 4 ++ packages/keyring-api/src/api/account.ts | 18 +++++++ packages/keyring-api/src/index.ts | 2 + packages/keyring-api/src/xrp/constants.ts | 10 ++++ packages/keyring-api/src/xrp/index.ts | 2 + packages/keyring-api/src/xrp/types.test-d.ts | 8 +++ packages/keyring-api/src/xrp/types.test.ts | 29 ++++++++++ packages/keyring-api/src/xrp/types.ts | 54 +++++++++++++++++++ packages/keyring-internal-api/CHANGELOG.md | 4 ++ .../keyring-internal-api/src/types.test.ts | 6 +++ packages/keyring-internal-api/src/types.ts | 21 +++++++- packages/keyring-snap-bridge/CHANGELOG.md | 4 ++ .../src/SnapKeyring.test.ts | 32 +++++++++++ packages/keyring-snap-bridge/src/account.ts | 8 +++ .../keyring-snap-bridge/src/migrations/v1.ts | 8 +++ 15 files changed, 208 insertions(+), 2 deletions(-) create mode 100644 packages/keyring-api/src/xrp/constants.ts create mode 100644 packages/keyring-api/src/xrp/index.ts create mode 100644 packages/keyring-api/src/xrp/types.test-d.ts create mode 100644 packages/keyring-api/src/xrp/types.test.ts create mode 100644 packages/keyring-api/src/xrp/types.ts diff --git a/packages/keyring-api/CHANGELOG.md b/packages/keyring-api/CHANGELOG.md index 202f15635..7f0453b54 100644 --- a/packages/keyring-api/CHANGELOG.md +++ b/packages/keyring-api/CHANGELOG.md @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +### Added + +- Add XRPL account types and scopes (`XrpScope`, `XrpAccountType`, `XrpAccount`, etc.) + ## [24.3.0] ### Added diff --git a/packages/keyring-api/src/api/account.ts b/packages/keyring-api/src/api/account.ts index 6c53a4ffa..5ed2815ee 100644 --- a/packages/keyring-api/src/api/account.ts +++ b/packages/keyring-api/src/api/account.ts @@ -49,6 +49,19 @@ export enum XlmAccountType { Account = 'stellar:account', } +/** + * Supported XRPL account types. + * + * We currently model only the classic XRPL account (`r…` address). + * This excludes X-addresses (`X…`); use a classic address plus an optional + * destination tag instead. + * + * @see https://xrpl.org/docs/concepts/accounts/addresses + */ +export enum XrpAccountType { + Account = 'xrpl:account', +} + /** * A generic account type. It can be used to represent any account type that is * not covered by the other account types. It only applies to non-EVM chains. @@ -70,6 +83,7 @@ export type KeyringAccountType = | `${SolAccountType.DataAccount}` | `${TrxAccountType.Eoa}` | `${XlmAccountType.Account}` + | `${XrpAccountType.Account}` | `${AnyAccountType.Account}`; /** @@ -85,9 +99,11 @@ export const KeyringAccountTypeStruct = enums([ `${SolAccountType.DataAccount}`, `${TrxAccountType.Eoa}`, `${XlmAccountType.Account}`, + `${XrpAccountType.Account}`, `${AnyAccountType.Account}`, ]); + /** * A struct which represents a Keyring account object. It is abstract enough to * be used with any blockchain. Specific blockchain account types should extend @@ -114,9 +130,11 @@ export const KeyringAccountStruct = object({ `${SolAccountType.DataAccount}`, `${TrxAccountType.Eoa}`, `${XlmAccountType.Account}`, + `${XrpAccountType.Account}`, `${AnyAccountType.Account}`, ]), + /** * Account main address. */ diff --git a/packages/keyring-api/src/index.ts b/packages/keyring-api/src/index.ts index 3f403407f..c791006cd 100644 --- a/packages/keyring-api/src/index.ts +++ b/packages/keyring-api/src/index.ts @@ -4,6 +4,8 @@ export * from './sol'; export * from './eth'; export * from './trx'; export * from './xlm'; +export * from './xrp'; export type * from './contexts'; + export * from './rpc'; export * from './events'; diff --git a/packages/keyring-api/src/xrp/constants.ts b/packages/keyring-api/src/xrp/constants.ts new file mode 100644 index 000000000..e932b9925 --- /dev/null +++ b/packages/keyring-api/src/xrp/constants.ts @@ -0,0 +1,10 @@ +// istanbul ignore file + +/** + * Scopes for XRPL account type. See {@link KeyringAccount.scopes}. + * + * @see https://namespaces.chainagnostic.org/xrpl/caip2 + */ +export enum XrpScope { + Mainnet = 'xrpl:0', +} diff --git a/packages/keyring-api/src/xrp/index.ts b/packages/keyring-api/src/xrp/index.ts new file mode 100644 index 000000000..4fbce9564 --- /dev/null +++ b/packages/keyring-api/src/xrp/index.ts @@ -0,0 +1,2 @@ +export * from './constants'; +export * from './types'; diff --git a/packages/keyring-api/src/xrp/types.test-d.ts b/packages/keyring-api/src/xrp/types.test-d.ts new file mode 100644 index 000000000..4af6924bf --- /dev/null +++ b/packages/keyring-api/src/xrp/types.test-d.ts @@ -0,0 +1,8 @@ +import type { Extends } from '@metamask/keyring-utils'; +import { expectTrue } from '@metamask/keyring-utils'; + +import type { XrpAccount } from './types'; +import type { KeyringAccount } from '../api'; + +// `XrpAccount` extends `KeyringAccount` +expectTrue>(); diff --git a/packages/keyring-api/src/xrp/types.test.ts b/packages/keyring-api/src/xrp/types.test.ts new file mode 100644 index 000000000..15a59db26 --- /dev/null +++ b/packages/keyring-api/src/xrp/types.test.ts @@ -0,0 +1,29 @@ +import { XrpAddressStruct } from './types'; + +describe('types', () => { + describe('XrpAddressStruct', () => { + it.each([ + 'rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh', + 'rPEPPER7kfTD9w2To4CQk6UCfuHM9c6GDY', + ])('is valid address: %s', (address) => { + expect(() => XrpAddressStruct.assert(address)).not.toThrow(); + }); + + it.each([ + // Empty or invalid input + '', + // Eth style address + '0x1234', + 'not-an-address', + // Too short (fewer than 25 chars total) + 'rHb9CJAWyB4rj91VRWn', + // X-address (not supported) + 'XVPcpSm47b1CZkf5AkKM9a84dQHe3m4sBhsrA4XtnBECTAc', + + ])('rejects invalid address: %s', (address) => { + expect(() => XrpAddressStruct.assert(address)).toThrow( + `Expected a value of type \`XrpAddress\`, but received: \`"${address}"\``, + ); + }); + }); +}); diff --git a/packages/keyring-api/src/xrp/types.ts b/packages/keyring-api/src/xrp/types.ts new file mode 100644 index 000000000..3841d16c0 --- /dev/null +++ b/packages/keyring-api/src/xrp/types.ts @@ -0,0 +1,54 @@ +import type { Infer } from '@metamask/superstruct'; +import { array, enums, literal, nonempty, object } from '@metamask/superstruct'; +import { definePattern } from '@metamask/utils'; + +import { + CaipChainIdStruct, + KeyringAccountStruct, + XrpAccountType, +} from '../api'; + +/** + * XRPL classic account addresses are Base58Check-encoded strings that start + * with `r` and are typically 25–35 characters. X-addresses (`X…`) are not + * supported; callers should use a classic address plus optional destination + * tag. + * + * TODO: Add checksum validation. + * + * @see https://xrpl.org/docs/concepts/accounts/addresses + */ +export const XrpAddressStruct = definePattern( + 'XrpAddress', + /^r[1-9A-HJ-NP-Za-km-z]{24,34}$/u, +); + +/** + * Supported XRPL methods. + */ +export enum XrpMethod { + SignMessage = 'signMessage', + SignTransaction = 'signTransaction', +} + +export const XrpAccountStruct = object({ + ...KeyringAccountStruct.schema, + /** + * Account address. + */ + address: XrpAddressStruct, + /** + * Account type. + */ + type: literal(`${XrpAccountType.Account}`), + /** + * Account supported scopes (CAIP-2 chain IDs). + */ + scopes: nonempty(array(CaipChainIdStruct)), + /** + * Account supported methods. + */ + methods: array(enums(Object.values(XrpMethod))), +}); + +export type XrpAccount = Infer; diff --git a/packages/keyring-internal-api/CHANGELOG.md b/packages/keyring-internal-api/CHANGELOG.md index ea365babd..c54608b96 100644 --- a/packages/keyring-internal-api/CHANGELOG.md +++ b/packages/keyring-internal-api/CHANGELOG.md @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +### Added + +- Add internal XRPL account struct (`InternalXrpAccount`) + ## [12.1.2] ### Changed diff --git a/packages/keyring-internal-api/src/types.test.ts b/packages/keyring-internal-api/src/types.test.ts index e37f381e4..50387ce2c 100644 --- a/packages/keyring-internal-api/src/types.test.ts +++ b/packages/keyring-internal-api/src/types.test.ts @@ -16,7 +16,13 @@ describe('InternalAccount', () => { address: 'GAKGOF5HPQSMKOJ6L4I2LNTLY6EERIRC7ZB6F7MOAXDLPZ7D5I4NZGNZ', scopes: ['stellar:pubnet', 'stellar:testnet'], }, + { + type: 'xrpl:account', + address: 'rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh', + scopes: ['xrpl:0'], + }, ])('should have the correct structure: %s', ({ type, address, scopes }) => { + const account = { id: '606a7759-b0fb-48e4-9874-bab62ff8e7eb', address, diff --git a/packages/keyring-internal-api/src/types.ts b/packages/keyring-internal-api/src/types.ts index 4e8f1704e..552ab872f 100644 --- a/packages/keyring-internal-api/src/types.ts +++ b/packages/keyring-internal-api/src/types.ts @@ -17,7 +17,10 @@ import { TrxEoaAccountStruct, XlmAccountType, XlmAccountStruct, + XrpAccountType, + XrpAccountStruct, } from '@metamask/keyring-api'; + import type { Infer, Struct } from '@metamask/superstruct'; import { exactOptional, object, string, number } from '@metamask/superstruct'; @@ -26,7 +29,9 @@ export type InternalAccountType = | BtcAccountType | SolAccountType | TrxAccountType - | XlmAccountType; + | XlmAccountType + | XrpAccountType; + export const InternalAccountMetadataStruct = object({ metadata: object({ @@ -90,8 +95,14 @@ export const InternalXlmAccountStruct = object({ ...InternalAccountMetadataStruct.schema, }); +export const InternalXrpAccountStruct = object({ + ...XrpAccountStruct.schema, + ...InternalAccountMetadataStruct.schema, +}); + export type InternalEthEoaAccount = Infer; + export type InternalEthErc4337Account = Infer< typeof InternalEthErc4337AccountStruct >; @@ -114,6 +125,8 @@ export type InternalTrxEoaAccount = Infer; export type InternalXlmAccount = Infer; +export type InternalXrpAccount = Infer; + export const InternalAccountStructs: Record< string, | Struct @@ -125,6 +138,7 @@ export const InternalAccountStructs: Record< | Struct | Struct | Struct + | Struct > = { [`${EthAccountType.Eoa}`]: InternalEthEoaAccountStruct, [`${EthAccountType.Erc4337}`]: InternalEthErc4337AccountStruct, @@ -135,6 +149,7 @@ export const InternalAccountStructs: Record< [`${SolAccountType.DataAccount}`]: InternalSolDataAccountStruct, [`${TrxAccountType.Eoa}`]: InternalTrxEoaAccountStruct, [`${XlmAccountType.Account}`]: InternalXlmAccountStruct, + [`${XrpAccountType.Account}`]: InternalXrpAccountStruct, }; export type InternalAccountTypes = @@ -146,7 +161,9 @@ export type InternalAccountTypes = | InternalBtcP2trAccount | InternalSolDataAccount | InternalTrxEoaAccount - | InternalXlmAccount; + | InternalXlmAccount + | InternalXrpAccount; + export const InternalAccountStruct = object({ ...KeyringAccountStruct.schema, diff --git a/packages/keyring-snap-bridge/CHANGELOG.md b/packages/keyring-snap-bridge/CHANGELOG.md index fe2a084ba..bc3932258 100644 --- a/packages/keyring-snap-bridge/CHANGELOG.md +++ b/packages/keyring-snap-bridge/CHANGELOG.md @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +### Added + +- Support XRPL (`xrpl:account`) accounts in account assertions and v1 migrations + ### Changed - Bump `@metamask/keyring-sdk` from `^4.2.1` to `^4.3.0` ([#720](https://github.com/MetaMask/accounts/pull/720)) diff --git a/packages/keyring-snap-bridge/src/SnapKeyring.test.ts b/packages/keyring-snap-bridge/src/SnapKeyring.test.ts index 1140cd167..a7da6262f 100644 --- a/packages/keyring-snap-bridge/src/SnapKeyring.test.ts +++ b/packages/keyring-snap-bridge/src/SnapKeyring.test.ts @@ -34,8 +34,12 @@ import { XlmScope, XlmMethod, XlmAccountType, + XrpScope, + XrpMethod, + XrpAccountType, AccountCreationType, } from '@metamask/keyring-api'; + import { SnapManageAccountsMethod } from '@metamask/keyring-snap-sdk'; import type { JsonRpcRequest } from '@metamask/keyring-utils'; import { Messenger, MOCK_ANY_NAMESPACE } from '@metamask/messenger'; @@ -233,7 +237,17 @@ describe('SnapKeyring', () => { type: XlmAccountType.Account, }; + const xrpAccount = { + id: '890ee179-5ab5-449d-9c25-34e12c1ada69', + address: 'rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh', + options: {}, + methods: [...Object.values(XrpMethod)], + scopes: [XrpScope.Mainnet], + type: XrpAccountType.Account, + }; + // This is an example generic chain, its scope and address are bogus. + const anyGenericAccount: KeyringAccount = { id: '6131c205-26b5-40a8-9626-4761423bb1d5', address: 'test-address-1234', @@ -280,9 +294,11 @@ describe('SnapKeyring', () => { solDataAccount, trxEoaAccount, xlmAccount, + xrpAccount, anyGenericAccount, ] as const; + const executionContext: KeyringExecutionContext = { chainId: '1', }; @@ -1245,11 +1261,13 @@ describe('SnapKeyring', () => { solDataAccount.address, trxEoaAccount.address, xlmAccount.address, + xrpAccount.address, anyGenericAccount.address, ]); }); it('cannot delete an account owned by another Snap', async () => { + await expect( keyring.handleKeyringSnapMessage('invalid-snap-id' as SnapId, { method: KeyringEvent.AccountDeleted, @@ -1270,11 +1288,13 @@ describe('SnapKeyring', () => { solDataAccount.address, trxEoaAccount.address, xlmAccount.address, + xrpAccount.address, anyGenericAccount.address, ]); }); it('returns null when removing an account that does not exist', async () => { + mockCallbacks.removeAccount.mockImplementation(async (address) => { await keyring.removeAccount(address); }); @@ -1487,12 +1507,14 @@ describe('SnapKeyring', () => { solDataAccount.address, trxEoaAccount.address, xlmAccount.address, + xrpAccount.address, anyGenericAccount.address, ]); }); }); describe('setSelectedAccounts', () => { + beforeEach(() => { mockMessengerHandleRequest({ [KeyringRpcMethod.SetSelectedAccounts]: () => null, @@ -1534,7 +1556,9 @@ describe('SnapKeyring', () => { [solDataAccount.id]: { account: solDataAccount, snapId }, [trxEoaAccount.id]: { account: trxEoaAccount, snapId }, [xlmAccount.id]: { account: xlmAccount, snapId }, + [xrpAccount.id]: { account: xrpAccount, snapId }, [anyGenericAccount.id]: { account: anyGenericAccount, snapId }, + }, }; const state = await keyring.serialize(); @@ -1614,7 +1638,9 @@ describe('SnapKeyring', () => { solDataAccount, trxEoaAccount, xlmAccount, + xrpAccount, ])('migrates accounts v1: %s', async (expectedAccount: KeyringAccount) => { + // A v1 account has no scopes, so remove it. const state = { accounts: { @@ -1638,6 +1664,7 @@ describe('SnapKeyring', () => { solDataAccount, trxEoaAccount, xlmAccount, + xrpAccount, anyGenericAccount, ])( 'migrates v2 accounts to v1 accounts is noop: %s', @@ -1646,6 +1673,7 @@ describe('SnapKeyring', () => { }, ); + it('unknown v1 accounts scopes defaults to EOA scopes', () => { expect(getScopesForAccountV1(unknownAccount)).toStrictEqual([ EthScope.Eoa, @@ -2299,10 +2327,12 @@ describe('SnapKeyring', () => { accounts[9].address, accounts[10].address, accounts[11].address, + accounts[12].address, ]); }); it('drops the per-snap wrapper when the last account for that Snap is removed', async () => { + const isolatedKeyring = new SnapKeyring({ messenger: mockSnapKeyringMessenger, callbacks: mockCallbacks, @@ -2369,11 +2399,13 @@ describe('SnapKeyring', () => { accounts[9].address, accounts[10].address, accounts[11].address, + accounts[12].address, ]); expect(console.error).toHaveBeenCalledWith( `Account '${ethEoaAccount1.id}' may not have been removed from snap '${snapId}':`, 'some error', ); + spy.mockRestore(); }); }); diff --git a/packages/keyring-snap-bridge/src/account.ts b/packages/keyring-snap-bridge/src/account.ts index afe9f34eb..c65983fe1 100644 --- a/packages/keyring-snap-bridge/src/account.ts +++ b/packages/keyring-snap-bridge/src/account.ts @@ -16,8 +16,11 @@ import { TrxEoaAccountStruct, XlmAccountType, XlmAccountStruct, + XrpAccountType, + XrpAccountStruct, isEvmAccountType, } from '@metamask/keyring-api'; + import { assert, omit } from '@metamask/superstruct'; import type { Infer } from '@metamask/superstruct'; @@ -79,7 +82,12 @@ export function assertKeyringAccount< assert(account, XlmAccountStruct); return account; } + case XrpAccountType.Account: { + assert(account, XrpAccountStruct); + return account; + } case AnyAccountType.Account: { + assert(account, KeyringAccountStruct); return account; } diff --git a/packages/keyring-snap-bridge/src/migrations/v1.ts b/packages/keyring-snap-bridge/src/migrations/v1.ts index d298b3541..a15c05eaf 100644 --- a/packages/keyring-snap-bridge/src/migrations/v1.ts +++ b/packages/keyring-snap-bridge/src/migrations/v1.ts @@ -9,7 +9,10 @@ import { TrxAccountType, XlmScope, XlmAccountType, + XrpScope, + XrpAccountType, } from '@metamask/keyring-api'; + import type { CaipChainId, KeyringAccount } from '@metamask/keyring-api'; import { isBtcMainnetAddress } from '@metamask/keyring-utils'; import { is } from '@metamask/superstruct'; @@ -77,7 +80,12 @@ export function getScopesForAccountV1( // Stellar account supports mainnet and testnet. return [XlmScope.Pubnet, XlmScope.Testnet]; } + case XrpAccountType.Account: { + // XRPL account currently supports mainnet only. + return [XrpScope.Mainnet]; + } default: + // We re-use EOA scopes if we don't know what to do for now. return [EthScope.Eoa]; } From 0630ee95600ac3500d62f5917a01ad547af3e7ee Mon Sep 17 00:00:00 2001 From: Florin Dzeladini Date: Mon, 30 Nov 2026 15:34:39 +0100 Subject: [PATCH 2/2] chore: lint ci --- packages/keyring-api/CHANGELOG.md | 2 +- packages/keyring-api/src/api/account.ts | 2 -- packages/keyring-api/src/xrp/types.test-d.ts | 2 +- packages/keyring-api/src/xrp/types.test.ts | 1 - packages/keyring-internal-api/CHANGELOG.md | 2 +- packages/keyring-internal-api/src/types.test.ts | 1 - packages/keyring-internal-api/src/types.ts | 4 ---- packages/keyring-snap-bridge/CHANGELOG.md | 2 +- packages/keyring-snap-bridge/src/SnapKeyring.test.ts | 9 --------- packages/keyring-snap-bridge/src/account.ts | 2 -- packages/keyring-snap-bridge/src/migrations/v1.ts | 2 -- 11 files changed, 4 insertions(+), 25 deletions(-) diff --git a/packages/keyring-api/CHANGELOG.md b/packages/keyring-api/CHANGELOG.md index 7f0453b54..33478471e 100644 --- a/packages/keyring-api/CHANGELOG.md +++ b/packages/keyring-api/CHANGELOG.md @@ -9,7 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Added -- Add XRPL account types and scopes (`XrpScope`, `XrpAccountType`, `XrpAccount`, etc.) +- Add XRPL account types and scopes (`XrpScope`, `XrpAccountType`, `XrpAccount`, etc.) ([#723](https://github.com/MetaMask/accounts/pull/723)) ## [24.3.0] diff --git a/packages/keyring-api/src/api/account.ts b/packages/keyring-api/src/api/account.ts index 5ed2815ee..aad697d5c 100644 --- a/packages/keyring-api/src/api/account.ts +++ b/packages/keyring-api/src/api/account.ts @@ -103,7 +103,6 @@ export const KeyringAccountTypeStruct = enums([ `${AnyAccountType.Account}`, ]); - /** * A struct which represents a Keyring account object. It is abstract enough to * be used with any blockchain. Specific blockchain account types should extend @@ -134,7 +133,6 @@ export const KeyringAccountStruct = object({ `${AnyAccountType.Account}`, ]), - /** * Account main address. */ diff --git a/packages/keyring-api/src/xrp/types.test-d.ts b/packages/keyring-api/src/xrp/types.test-d.ts index 4af6924bf..b51529050 100644 --- a/packages/keyring-api/src/xrp/types.test-d.ts +++ b/packages/keyring-api/src/xrp/types.test-d.ts @@ -1,8 +1,8 @@ import type { Extends } from '@metamask/keyring-utils'; import { expectTrue } from '@metamask/keyring-utils'; -import type { XrpAccount } from './types'; import type { KeyringAccount } from '../api'; +import type { XrpAccount } from './types'; // `XrpAccount` extends `KeyringAccount` expectTrue>(); diff --git a/packages/keyring-api/src/xrp/types.test.ts b/packages/keyring-api/src/xrp/types.test.ts index 15a59db26..5a437512a 100644 --- a/packages/keyring-api/src/xrp/types.test.ts +++ b/packages/keyring-api/src/xrp/types.test.ts @@ -19,7 +19,6 @@ describe('types', () => { 'rHb9CJAWyB4rj91VRWn', // X-address (not supported) 'XVPcpSm47b1CZkf5AkKM9a84dQHe3m4sBhsrA4XtnBECTAc', - ])('rejects invalid address: %s', (address) => { expect(() => XrpAddressStruct.assert(address)).toThrow( `Expected a value of type \`XrpAddress\`, but received: \`"${address}"\``, diff --git a/packages/keyring-internal-api/CHANGELOG.md b/packages/keyring-internal-api/CHANGELOG.md index c54608b96..0defb976f 100644 --- a/packages/keyring-internal-api/CHANGELOG.md +++ b/packages/keyring-internal-api/CHANGELOG.md @@ -9,7 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Added -- Add internal XRPL account struct (`InternalXrpAccount`) +- Add internal XRPL account struct (`InternalXrpAccount`) ([#723](https://github.com/MetaMask/accounts/pull/723)) ## [12.1.2] diff --git a/packages/keyring-internal-api/src/types.test.ts b/packages/keyring-internal-api/src/types.test.ts index 50387ce2c..ca36be35c 100644 --- a/packages/keyring-internal-api/src/types.test.ts +++ b/packages/keyring-internal-api/src/types.test.ts @@ -22,7 +22,6 @@ describe('InternalAccount', () => { scopes: ['xrpl:0'], }, ])('should have the correct structure: %s', ({ type, address, scopes }) => { - const account = { id: '606a7759-b0fb-48e4-9874-bab62ff8e7eb', address, diff --git a/packages/keyring-internal-api/src/types.ts b/packages/keyring-internal-api/src/types.ts index 552ab872f..2f8fc37e1 100644 --- a/packages/keyring-internal-api/src/types.ts +++ b/packages/keyring-internal-api/src/types.ts @@ -20,7 +20,6 @@ import { XrpAccountType, XrpAccountStruct, } from '@metamask/keyring-api'; - import type { Infer, Struct } from '@metamask/superstruct'; import { exactOptional, object, string, number } from '@metamask/superstruct'; @@ -32,7 +31,6 @@ export type InternalAccountType = | XlmAccountType | XrpAccountType; - export const InternalAccountMetadataStruct = object({ metadata: object({ name: string(), @@ -102,7 +100,6 @@ export const InternalXrpAccountStruct = object({ export type InternalEthEoaAccount = Infer; - export type InternalEthErc4337Account = Infer< typeof InternalEthErc4337AccountStruct >; @@ -164,7 +161,6 @@ export type InternalAccountTypes = | InternalXlmAccount | InternalXrpAccount; - export const InternalAccountStruct = object({ ...KeyringAccountStruct.schema, ...InternalAccountMetadataStruct.schema, diff --git a/packages/keyring-snap-bridge/CHANGELOG.md b/packages/keyring-snap-bridge/CHANGELOG.md index bc3932258..543c8fa73 100644 --- a/packages/keyring-snap-bridge/CHANGELOG.md +++ b/packages/keyring-snap-bridge/CHANGELOG.md @@ -9,7 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Added -- Support XRPL (`xrpl:account`) accounts in account assertions and v1 migrations +- Support XRPL (`xrpl:account`) accounts in account assertions and v1 migrations ([#723](https://github.com/MetaMask/accounts/pull/723)) ### Changed diff --git a/packages/keyring-snap-bridge/src/SnapKeyring.test.ts b/packages/keyring-snap-bridge/src/SnapKeyring.test.ts index a7da6262f..31ffb3c19 100644 --- a/packages/keyring-snap-bridge/src/SnapKeyring.test.ts +++ b/packages/keyring-snap-bridge/src/SnapKeyring.test.ts @@ -39,7 +39,6 @@ import { XrpAccountType, AccountCreationType, } from '@metamask/keyring-api'; - import { SnapManageAccountsMethod } from '@metamask/keyring-snap-sdk'; import type { JsonRpcRequest } from '@metamask/keyring-utils'; import { Messenger, MOCK_ANY_NAMESPACE } from '@metamask/messenger'; @@ -298,7 +297,6 @@ describe('SnapKeyring', () => { anyGenericAccount, ] as const; - const executionContext: KeyringExecutionContext = { chainId: '1', }; @@ -1267,7 +1265,6 @@ describe('SnapKeyring', () => { }); it('cannot delete an account owned by another Snap', async () => { - await expect( keyring.handleKeyringSnapMessage('invalid-snap-id' as SnapId, { method: KeyringEvent.AccountDeleted, @@ -1294,7 +1291,6 @@ describe('SnapKeyring', () => { }); it('returns null when removing an account that does not exist', async () => { - mockCallbacks.removeAccount.mockImplementation(async (address) => { await keyring.removeAccount(address); }); @@ -1514,7 +1510,6 @@ describe('SnapKeyring', () => { }); describe('setSelectedAccounts', () => { - beforeEach(() => { mockMessengerHandleRequest({ [KeyringRpcMethod.SetSelectedAccounts]: () => null, @@ -1558,7 +1553,6 @@ describe('SnapKeyring', () => { [xlmAccount.id]: { account: xlmAccount, snapId }, [xrpAccount.id]: { account: xrpAccount, snapId }, [anyGenericAccount.id]: { account: anyGenericAccount, snapId }, - }, }; const state = await keyring.serialize(); @@ -1640,7 +1634,6 @@ describe('SnapKeyring', () => { xlmAccount, xrpAccount, ])('migrates accounts v1: %s', async (expectedAccount: KeyringAccount) => { - // A v1 account has no scopes, so remove it. const state = { accounts: { @@ -1673,7 +1666,6 @@ describe('SnapKeyring', () => { }, ); - it('unknown v1 accounts scopes defaults to EOA scopes', () => { expect(getScopesForAccountV1(unknownAccount)).toStrictEqual([ EthScope.Eoa, @@ -2332,7 +2324,6 @@ describe('SnapKeyring', () => { }); it('drops the per-snap wrapper when the last account for that Snap is removed', async () => { - const isolatedKeyring = new SnapKeyring({ messenger: mockSnapKeyringMessenger, callbacks: mockCallbacks, diff --git a/packages/keyring-snap-bridge/src/account.ts b/packages/keyring-snap-bridge/src/account.ts index c65983fe1..38294e060 100644 --- a/packages/keyring-snap-bridge/src/account.ts +++ b/packages/keyring-snap-bridge/src/account.ts @@ -20,7 +20,6 @@ import { XrpAccountStruct, isEvmAccountType, } from '@metamask/keyring-api'; - import { assert, omit } from '@metamask/superstruct'; import type { Infer } from '@metamask/superstruct'; @@ -87,7 +86,6 @@ export function assertKeyringAccount< return account; } case AnyAccountType.Account: { - assert(account, KeyringAccountStruct); return account; } diff --git a/packages/keyring-snap-bridge/src/migrations/v1.ts b/packages/keyring-snap-bridge/src/migrations/v1.ts index a15c05eaf..796efc486 100644 --- a/packages/keyring-snap-bridge/src/migrations/v1.ts +++ b/packages/keyring-snap-bridge/src/migrations/v1.ts @@ -12,7 +12,6 @@ import { XrpScope, XrpAccountType, } from '@metamask/keyring-api'; - import type { CaipChainId, KeyringAccount } from '@metamask/keyring-api'; import { isBtcMainnetAddress } from '@metamask/keyring-utils'; import { is } from '@metamask/superstruct'; @@ -85,7 +84,6 @@ export function getScopesForAccountV1( return [XrpScope.Mainnet]; } default: - // We re-use EOA scopes if we don't know what to do for now. return [EthScope.Eoa]; }