Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
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
3 changes: 2 additions & 1 deletion packages/keyring-api/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Added

- Add Stellar account types and scopes (`XlmScope`, `XlmAccountType`, `XlmAccount`, etc.) ([#483](https://github.com/MetaMask/accounts/pull/483))
- Add keyring v2 RPC types and structs (`KeyringRpcV2`, `KeyringRpcV2Method`, `isKeyringRpcV2Method`, and request/response structs) ([#408](https://github.com/MetaMask/accounts/pull/408))

### Changed

- Improve return type of `isKeyringRpcMethod` to use type predicate `method is KeyringRpcMethod` ([#408](https://github.com/MetaMask/accounts/pull/408))
- Bump `@metamask/utils` from `^11.1.0` to `^11.10.0` ([#489](https://github.com/MetaMask/accounts/pull/489))
- Bump `@metamask/utils` from `^11.1.0` to `^11.11.0` ([#489](https://github.com/MetaMask/accounts/pull/489), [#483](https://github.com/MetaMask/accounts/pull/483))

## [22.0.0]

Expand Down
2 changes: 1 addition & 1 deletion packages/keyring-api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
"dependencies": {
"@metamask/keyring-utils": "^3.2.0",
"@metamask/superstruct": "^3.1.0",
"@metamask/utils": "^11.10.0",
"@metamask/utils": "^11.11.0",
"bitcoin-address-validation": "^2.2.3"
},
"devDependencies": {
Expand Down
15 changes: 15 additions & 0 deletions packages/keyring-api/src/api/account.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,18 @@ export enum TrxAccountType {
Eoa = 'tron:eoa',
}

/**
* Supported Stellar account types.
*
* We currently model only the standard Stellar account (G-address).
* This excludes advanced formats such as muxed (M...) accounts.
*
* See: https://developers.stellar.org/docs/build/guides/transactions/pooled-accounts-muxed-accounts-memos
*/
export enum XlmAccountType {
Account = 'stellar: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.
Expand All @@ -57,6 +69,7 @@ export type KeyringAccountType =
| `${BtcAccountType.P2tr}`
| `${SolAccountType.DataAccount}`
| `${TrxAccountType.Eoa}`
| `${XlmAccountType.Account}`
| `${AnyAccountType.Account}`;

/**
Expand All @@ -71,6 +84,7 @@ export const KeyringAccountTypeStruct = enums([
`${BtcAccountType.P2tr}`,
`${SolAccountType.DataAccount}`,
`${TrxAccountType.Eoa}`,
`${XlmAccountType.Account}`,
`${AnyAccountType.Account}`,
]);

Expand Down Expand Up @@ -99,6 +113,7 @@ export const KeyringAccountStruct = object({
`${BtcAccountType.P2tr}`,
`${SolAccountType.DataAccount}`,
`${TrxAccountType.Eoa}`,
`${XlmAccountType.Account}`,
`${AnyAccountType.Account}`,
]),

Expand Down
1 change: 1 addition & 0 deletions packages/keyring-api/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ export * from './btc';
export * from './sol';
export * from './eth';
export * from './trx';
export * from './xlm';
export type * from './contexts';
export * from './rpc';
export * from './events';
11 changes: 11 additions & 0 deletions packages/keyring-api/src/xlm/constants.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// istanbul ignore file

/**
* Scopes for Stellar account type. See {@link KeyringAccount.scopes}.
*
* @see https://namespaces.chainagnostic.org/stellar/caip2
*/
export enum XlmScope {
Pubnet = 'stellar:pubnet',
Testnet = 'stellar:testnet',
}
2 changes: 2 additions & 0 deletions packages/keyring-api/src/xlm/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export * from './constants';
export * from './types';
8 changes: 8 additions & 0 deletions packages/keyring-api/src/xlm/types.test-d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import type { Extends } from '@metamask/keyring-utils';
import { expectTrue } from '@metamask/keyring-utils';

import type { XlmAccount } from './types';
import type { KeyringAccount } from '../api';

// `XlmAccount` extends `KeyringAccount`
expectTrue<Extends<XlmAccount, KeyringAccount>>();
30 changes: 30 additions & 0 deletions packages/keyring-api/src/xlm/types.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import { XlmAddressStruct } from './types';

describe('types', () => {
describe('XlmAddressStruct', () => {
it.each([
'GAKGOF5HPQSMKOJ6L4I2LNTLY6EERIRC7ZB6F7MOAXDLPZ7D5I4NZGNZ',
'GDAMXWN25KO5HFBYY6GYVF56QQLJKKZJ5FTSBKFXVBVKQCV4AI5HAQOA',
])('is valid address: %s', (address) => {
expect(() => XlmAddressStruct.assert(address)).not.toThrow();
});

it.each([
// Invalid lengths, too long (57 chars)
'GAKGOF5HPQSMKOJ6L4I2LNTLY6EERIRC7ZB6F7MOAXDLPZ7D5I4NZGNZ1',
// Too short (54 chars after G)
'GAKGOF5HPQSMKOJ6L4I2LNTLY6EERIRC7ZB6F7MOAXDLPZ7D5I4NZGN',
// Empty or invalid input
'',
// Eth style address
'0x1234',
'not-an-address',
// Muxed address (not supported)
'MAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABWTA',
])('rejects invalid address: %s', (address) => {
expect(() => XlmAddressStruct.assert(address)).toThrow(
`Expected a value of type \`XlmAddress\`, but received: \`"${address}"\``,
);
});
});
});
48 changes: 48 additions & 0 deletions packages/keyring-api/src/xlm/types.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
import { object } from '@metamask/keyring-utils';
import type { Infer } from '@metamask/superstruct';
import { array, enums, literal, nonempty } from '@metamask/superstruct';
import { definePattern } from '@metamask/utils';

import {
CaipChainIdStruct,
KeyringAccountStruct,
XlmAccountType,
} from '../api';

/**
* Stellar account addresses use strkey encoding: non-muxed accounts start with `G`
* and are 56 characters long.
*
* TODO: Add checksum validation.
*/
export const XlmAddressStruct = definePattern('XlmAddress', /^G[A-Z2-7]{55}$/u);

/**
* Supported Stellar methods.
*/
export enum XlmMethod {
SignMessage = 'signMessage',
SignTransaction = 'signTransaction',
}

export const XlmAccountStruct = object({
...KeyringAccountStruct.schema,
/**
* Account address.
*/
address: XlmAddressStruct,
/**
* Account type.
*/
type: literal(`${XlmAccountType.Account}`),
/**
* Account supported scopes (CAIP-2 chain IDs).
*/
scopes: nonempty(array(CaipChainIdStruct)),
/**
* Account supported methods.
*/
methods: array(enums(Object.values(XlmMethod))),
});

export type XlmAccount = Infer<typeof XlmAccountStruct>;
4 changes: 4 additions & 0 deletions packages/keyring-eth-hd/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]

### Changed

- Bump `@metamask/utils` from `^11.10.0` to `^11.11.0` ([#483](https://github.com/MetaMask/accounts/pull/483))

## [13.1.1]

### Changed
Expand Down
2 changes: 1 addition & 1 deletion packages/keyring-eth-hd/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
"@metamask/keyring-utils": "^3.2.0",
"@metamask/scure-bip39": "^2.1.1",
"@metamask/superstruct": "^3.1.0",
"@metamask/utils": "^11.10.0",
"@metamask/utils": "^11.11.0",
"ethereum-cryptography": "^2.2.1"
},
"devDependencies": {
Expand Down
4 changes: 4 additions & 0 deletions packages/keyring-eth-ledger-bridge/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]

### Changed

- Bump `@metamask/utils` from `^11.10.0` to `^11.11.0` ([#483](https://github.com/MetaMask/accounts/pull/483))

## [11.4.0]

### Added
Expand Down
2 changes: 1 addition & 1 deletion packages/keyring-eth-ledger-bridge/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@
"@metamask/account-api": "^1.0.1",
"@metamask/auto-changelog": "^3.4.4",
"@metamask/keyring-utils": "^3.2.0",
"@metamask/utils": "^11.10.0",
"@metamask/utils": "^11.11.0",
"@ts-bridge/cli": "^0.6.3",
"@types/ethereumjs-tx": "^1.0.1",
"@types/hdkey": "^2.0.1",
Expand Down
1 change: 1 addition & 0 deletions packages/keyring-eth-money/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Changed

- Bump `@metamask/utils` from `^11.10.0` to `^11.11.0` ([#483](https://github.com/MetaMask/accounts/pull/483))
- Bump `@metamask/eth-hd-keyring` from `^13.1.0` to `^13.1.1` ([#509](https://github.com/MetaMask/accounts/pull/509))

## [2.0.0]
Expand Down
2 changes: 1 addition & 1 deletion packages/keyring-eth-money/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
"@metamask/auto-changelog": "^3.4.4",
"@metamask/eth-sig-util": "^8.2.0",
"@metamask/key-tree": "^10.0.2",
"@metamask/utils": "^11.10.0",
"@metamask/utils": "^11.11.0",
"@ts-bridge/cli": "^0.6.3",
"@types/jest": "^29.5.12",
"deepmerge": "^4.2.2",
Expand Down
2 changes: 1 addition & 1 deletion packages/keyring-eth-qr/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Changed

- Bump `@metamask/utils` from `^11.1.0` to `^11.10.0` ([#489](https://github.com/MetaMask/accounts/pull/489))
- Bump `@metamask/utils` from `^11.1.0` to `^11.11.0` ([#489](https://github.com/MetaMask/accounts/pull/489), [#483](https://github.com/MetaMask/accounts/pull/483))

## [1.1.0]

Expand Down
2 changes: 1 addition & 1 deletion packages/keyring-eth-qr/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
"@metamask/keyring-api": "^22.0.0",
"@metamask/keyring-sdk": "^1.2.0",
"@metamask/keyring-utils": "^3.2.0",
"@metamask/utils": "^11.10.0",
"@metamask/utils": "^11.11.0",
"async-mutex": "^0.5.0",
"hdkey": "^2.1.0",
"uuid": "^9.0.1"
Expand Down
4 changes: 4 additions & 0 deletions packages/keyring-eth-simple/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]

### Changed

- Bump `@metamask/utils` from `^11.10.0` to `^11.11.0` ([#483](https://github.com/MetaMask/accounts/pull/483))

## [11.1.2]

### Changed
Expand Down
2 changes: 1 addition & 1 deletion packages/keyring-eth-simple/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
"@metamask/eth-sig-util": "^8.2.0",
"@metamask/keyring-api": "^22.0.0",
"@metamask/keyring-sdk": "^1.2.0",
"@metamask/utils": "^11.10.0",
"@metamask/utils": "^11.11.0",
"ethereum-cryptography": "^2.2.1",
"randombytes": "^2.1.0"
},
Expand Down
4 changes: 4 additions & 0 deletions packages/keyring-eth-trezor/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]

### Changed

- Bump `@metamask/utils` from `^11.10.0` to `^11.11.0` ([#483](https://github.com/MetaMask/accounts/pull/483))

## [9.1.1]

### Changed
Expand Down
2 changes: 1 addition & 1 deletion packages/keyring-eth-trezor/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
"@metamask/keyring-api": "^22.0.0",
"@metamask/keyring-sdk": "^1.2.0",
"@metamask/keyring-utils": "^3.2.0",
"@metamask/utils": "^11.10.0",
"@metamask/utils": "^11.11.0",
"@trezor/connect-plugin-ethereum": "^9.0.5",
"@trezor/connect-web": "^9.6.0",
"hdkey": "^2.1.0",
Expand Down
4 changes: 4 additions & 0 deletions packages/keyring-internal-api/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

- Add internal Stellar account struct (`InternalXlmAccount`) ([#483](https://github.com/MetaMask/accounts/pull/483))

## [10.0.1]

### Changed
Expand Down
5 changes: 5 additions & 0 deletions packages/keyring-internal-api/src/types.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@ describe('InternalAccount', () => {
address: 'bc1qw508d6qejxtdg4y5r3zarvary0c5xw7kv8f3t4',
scopes: ['bip122:000000000019d6689c085ae165831e93'],
},
{
type: 'stellar:account',
address: 'GDRF6HX6XUA74N7LFSXVYPPINW5QRLFPQS4PNFG7HJF6DFQQNT2TI4F',
Copy link
Copy Markdown
Member

@gantunesr gantunesr Apr 13, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like this address is invalid, can you double check it?

Image

source: https://coin.space/stellar-address-check/

scopes: ['stellar:pubnet', 'stellar:testnet'],
},
])('should have the correct structure: %s', ({ type, address, scopes }) => {
const account = {
id: '606a7759-b0fb-48e4-9874-bab62ff8e7eb',
Expand Down
17 changes: 15 additions & 2 deletions packages/keyring-internal-api/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ import {
SolDataAccountStruct,
TrxAccountType,
TrxEoaAccountStruct,
XlmAccountType,
XlmAccountStruct,
} from '@metamask/keyring-api';
import { exactOptional, object } from '@metamask/keyring-utils';
import type { Infer, Struct } from '@metamask/superstruct';
Expand All @@ -25,7 +27,8 @@ export type InternalAccountType =
| EthAccountType
| BtcAccountType
| SolAccountType
| TrxAccountType;
| TrxAccountType
| XlmAccountType;

export const InternalAccountMetadataStruct = object({
metadata: object({
Expand Down Expand Up @@ -86,6 +89,11 @@ export const InternalTrxEoaAccountStruct = object({
...InternalAccountMetadataStruct.schema,
});

export const InternalXlmAccountStruct = object({
...XlmAccountStruct.schema,
...InternalAccountMetadataStruct.schema,
});

export type InternalEthEoaAccount = Infer<typeof InternalEthEoaAccountStruct>;

export type InternalEthErc4337Account = Infer<
Expand All @@ -108,6 +116,8 @@ export type InternalSolDataAccount = Infer<typeof InternalSolDataAccountStruct>;

export type InternalTrxEoaAccount = Infer<typeof InternalTrxEoaAccountStruct>;

export type InternalXlmAccount = Infer<typeof InternalXlmAccountStruct>;

export const InternalAccountStructs: Record<
string,
| Struct<InternalEthEoaAccount>
Expand All @@ -118,6 +128,7 @@ export const InternalAccountStructs: Record<
| Struct<InternalBtcP2trAccount>
| Struct<InternalSolDataAccount>
| Struct<InternalTrxEoaAccount>
| Struct<InternalXlmAccount>
> = {
[`${EthAccountType.Eoa}`]: InternalEthEoaAccountStruct,
[`${EthAccountType.Erc4337}`]: InternalEthErc4337AccountStruct,
Expand All @@ -127,6 +138,7 @@ export const InternalAccountStructs: Record<
[`${BtcAccountType.P2tr}`]: InternalBtcP2trAccountStruct,
[`${SolAccountType.DataAccount}`]: InternalSolDataAccountStruct,
[`${TrxAccountType.Eoa}`]: InternalTrxEoaAccountStruct,
[`${XlmAccountType.Account}`]: InternalXlmAccountStruct,
};

export type InternalAccountTypes =
Expand All @@ -137,7 +149,8 @@ export type InternalAccountTypes =
| InternalBtcP2wpkhAccount
| InternalBtcP2trAccount
| InternalSolDataAccount
| InternalTrxEoaAccount;
| InternalTrxEoaAccount
| InternalXlmAccount;

export const InternalAccountStruct = object({
...KeyringAccountStruct.schema,
Expand Down
1 change: 1 addition & 0 deletions packages/keyring-internal-snap-client/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Changed

- Bump `@metamask/messenger` from `^0.3.0` to `^1.1.1` ([#489](https://github.com/MetaMask/accounts/pull/489), [#500](https://github.com/MetaMask/accounts/pull/500))
- Bump `@metamask/utils` from `^11.10.0` to `^11.11.0` ([#483](https://github.com/MetaMask/accounts/pull/483))

## [9.0.1]

Expand Down
2 changes: 1 addition & 1 deletion packages/keyring-internal-snap-client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
"@metamask/snaps-controllers": "^19.0.1",
"@metamask/snaps-sdk": "^11.0.0",
"@metamask/snaps-utils": "^12.1.3",
"@metamask/utils": "^11.10.0",
"@metamask/utils": "^11.11.0",
"@ts-bridge/cli": "^0.6.3",
"@types/jest": "^29.5.12",
"@types/node": "^20.12.12",
Expand Down
Loading
Loading