From af4ebd692dd26ef96fbc1acf05763df3027cb178 Mon Sep 17 00:00:00 2001 From: Makoto Inoue <2630+makoto@users.noreply.github.com> Date: Tue, 25 Aug 2020 14:18:11 +0100 Subject: [PATCH] Add support for DOT --- src/__tests__/index.test.ts | 7 +++++++ src/index.ts | 10 ++++++++++ 2 files changed, 17 insertions(+) diff --git a/src/__tests__/index.test.ts b/src/__tests__/index.test.ts index 79e386f9..7c5490b4 100644 --- a/src/__tests__/index.test.ts +++ b/src/__tests__/index.test.ts @@ -170,6 +170,13 @@ const vectors: Array = [ { text: 'TJCnKsPa7y5okkXvQAidZBzqx3QyQ6sxMW', hex: '415a523b449890854c8fc460ab602df9f31fe4293f'}, ], }, + { + name: 'DOT', + coinType: 354, + passingVectors: [ + { text: '1FRMM8PEiWXYax7rpS6X4XZX1aAAxSWx1CrKTyrVYhV24fg', hex: '0aff6865635ae11013a83835c019d44ec3f865145943f487ae82a8e7bed3a66b' }, + ], + }, { name: 'KSM', coinType: 434, diff --git a/src/index.ts b/src/index.ts index 5436d85e..d5f705dc 100644 --- a/src/index.ts +++ b/src/index.ts @@ -238,6 +238,10 @@ function ksmAddrEncoder(data: Buffer): string { return ss58Encode(Uint8Array.from(data), 2) } +function dotAddrEncoder(data: Buffer): string { + return ss58Encode(Uint8Array.from(data), 0) +} + function ksmAddrDecoder(data: string): Buffer { return new Buffer(ss58Decode(data)) } @@ -296,6 +300,12 @@ const formats: IFormat[] = [ encoder: bs58Encode, name: 'TRX', }, + { + coinType: 354, + decoder: ksmAddrDecoder, + encoder: dotAddrEncoder, + name: 'DOT' + }, { coinType: 434, decoder: ksmAddrDecoder,