-
-
Notifications
You must be signed in to change notification settings - Fork 11
feat: add Stellar (XLM) support to keyring-api, keyring-internal-api, and eth-snap-keyring #483
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
khanti42
wants to merge
21
commits into
main
Choose a base branch
from
feat/add-stellar-pubnet-testnet
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
7cb7f9a
feat: add Stellar (XLM) support to keyring-api, keyring-internal-api,…
khanti42 4245f7b
chore: update PR number in changelog
khanti42 6fa3fed
Merge branch 'main' into feat/add-stellar-pubnet-testnet
stanleyyconsensys 35f1ebe
Merge branch 'main' into feat/add-stellar-pubnet-testnet
khanti42 efd7fcf
chore: handle comments
khanti42 0753040
chore: cursor comments
khanti42 b92df0e
chore: typo
khanti42 ce68bc6
chore: lint + test
khanti42 faabcaf
Merge branch 'main' into feat/add-stellar-pubnet-testnet
khanti42 48604bf
chore: bump up utils
khanti42 5746e61
chore: dedupe @metamask/utils step
khanti42 695be49
core: changelog entries
khanti42 8cfdab1
Merge branch 'main' into feat/add-stellar-pubnet-testnet
wantedsystem 8fd0d17
chore: fix changelog formatting and missing unreleased entry
wantedsystem b71adee
Merge branch main into feat/add-stellar-pubnet-testnet
wantedsystem 851cc30
chore: add missing unreleased changelog entries after release 99.0.0
wantedsystem ba67bec
Merge branch 'main' into feat/add-stellar-pubnet-testnet
khanti42 7d43bfe
Merge branch 'main' into feat/add-stellar-pubnet-testnet
khanti42 a49dc9c
chore: changelog
khanti42 c0e24bb
chore: comments
khanti42 97109b1
chore: lint typo
khanti42 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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', | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| export * from './constants'; | ||
| export * from './types'; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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>>(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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}"\``, | ||
| ); | ||
| }); | ||
| }); | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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); | ||
khanti42 marked this conversation as resolved.
Show resolved
Hide resolved
khanti42 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| /** | ||
| * 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>; | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -11,6 +11,11 @@ describe('InternalAccount', () => { | |
| address: 'bc1qw508d6qejxtdg4y5r3zarvary0c5xw7kv8f3t4', | ||
| scopes: ['bip122:000000000019d6689c085ae165831e93'], | ||
| }, | ||
| { | ||
| type: 'stellar:account', | ||
| address: 'GDRF6HX6XUA74N7LFSXVYPPINW5QRLFPQS4PNFG7HJF6DFQQNT2TI4F', | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
| scopes: ['stellar:pubnet', 'stellar:testnet'], | ||
| }, | ||
cursor[bot] marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| ])('should have the correct structure: %s', ({ type, address, scopes }) => { | ||
| const account = { | ||
| id: '606a7759-b0fb-48e4-9874-bab62ff8e7eb', | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.

Uh oh!
There was an error while loading. Please reload this page.