Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
parity
txwrapper
Commits
b9a1cc8a
Commit
b9a1cc8a
authored
Nov 28, 2019
by
Amaury Martiny
Browse files
feat: Add deriveAddress
parent
a8d817d0
Changes
2
Hide whitespace changes
Inline
Side-by-side
src/deriveAddress.spec.ts
0 → 100644
View file @
b9a1cc8a
import
{
deriveAddress
}
from
'
./deriveAddress
'
;
describe
(
'
generateKeypair
'
,
()
=>
{
it
(
'
should work
'
,
()
=>
{
const
address
=
deriveAddress
(
'
0x96074594cccf1cd185fa8a72ceaeefd86648f8d45514f3ce33c31bdd07e4655d
'
);
expect
(
address
).
toBe
(
'
Fy2rsYCoowQBtuFXqLE65ehAY9T6KWcGiNCQAyPDCkfpm4s
'
);
});
});
src/deriveAddress.ts
0 → 100644
View file @
b9a1cc8a
import
{
encodeAddress
}
from
'
@polkadot/keyring
'
;
const
KUSAMA_SS58_FORMAT
=
2
;
/**
* Derive an address from a cryptographic public key offline
*
* @param publicKey - The public key to derive from
* @param ss58Format - The SS58 format to use
*/
export
function
deriveAddress
(
publicKey
:
string
|
Uint8Array
,
ss58Format
:
number
=
KUSAMA_SS58_FORMAT
):
string
{
return
encodeAddress
(
publicKey
,
ss58Format
);
}
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment