Commit b9a1cc8a authored by Amaury Martiny's avatar Amaury Martiny
Browse files

feat: Add deriveAddress

parent a8d817d0
import { deriveAddress } from './deriveAddress';
describe('generateKeypair', () => {
it('should work', () => {
const address = deriveAddress(
'0x96074594cccf1cd185fa8a72ceaeefd86648f8d45514f3ce33c31bdd07e4655d'
);
expect(address).toBe('Fy2rsYCoowQBtuFXqLE65ehAY9T6KWcGiNCQAyPDCkfpm4s');
});
});
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);
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment