-
Notifications
You must be signed in to change notification settings - Fork 570
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
move function to
snap-utils
and add JSDocs
- Loading branch information
1 parent
ee67e9e
commit 311858f
Showing
8 changed files
with
58 additions
and
48 deletions.
There are no files selected for viewing
This file contains 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 |
---|---|---|
@@ -1,6 +1,6 @@ | ||
{ | ||
"branches": 93.4, | ||
"functions": 96.81, | ||
"lines": 98.18, | ||
"functions": 96.8, | ||
"lines": 98.17, | ||
"statements": 97.91 | ||
} |
This file contains 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 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 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 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 |
---|---|---|
|
@@ -2,5 +2,5 @@ | |
"branches": 99.74, | ||
"functions": 98.92, | ||
"lines": 99.61, | ||
"statements": 96.91 | ||
"statements": 96.92 | ||
} |
This file contains 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,15 @@ | ||
import { createAddressList } from './address'; | ||
|
||
describe('createAddressList', () => { | ||
it('creates an address list from an account', () => { | ||
const result = createAddressList( | ||
'0x1234567890123456789012345678901234567890', | ||
['eip155:1', 'eip155:2'], | ||
); | ||
|
||
expect(result).toStrictEqual([ | ||
'eip155:1:0x1234567890123456789012345678901234567890', | ||
'eip155:2:0x1234567890123456789012345678901234567890', | ||
]); | ||
}); | ||
}); |
This file contains 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,19 @@ | ||
import type { CaipAccountId, CaipChainId } from '@metamask/utils'; | ||
import { parseCaipChainId, toCaipAccountId } from '@metamask/utils'; | ||
|
||
/** | ||
* Create a list of CAIP account IDs from an address and a list of scopes. | ||
* | ||
* @param address - The address to create the account IDs from. | ||
* @param scopes - The scopes to create the account IDs from. | ||
* @returns The list of CAIP account IDs. | ||
*/ | ||
export function createAddressList( | ||
address: string, | ||
scopes: CaipChainId[], | ||
): CaipAccountId[] { | ||
return scopes.map((scope) => { | ||
const { namespace, reference } = parseCaipChainId(scope); | ||
return toCaipAccountId(namespace, reference, address); | ||
}); | ||
} |
This file contains 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