fix: remove decimal string support from PublicKey ctor
This commit is contained in:
@ -12,25 +12,17 @@ export class PublicKey {
|
||||
/**
|
||||
* Create a new PublicKey object
|
||||
*/
|
||||
constructor(number: number | string | Buffer | Array<number>) {
|
||||
|
||||
for (;;) {
|
||||
if (typeof number === 'string') {
|
||||
// base 58 encoded?
|
||||
if (/^[1-9A-HJ-NP-Za-km-z]{43,44}$/.test(number)) {
|
||||
this._bn = new BN(bs58.decode(number));
|
||||
break;
|
||||
}
|
||||
|
||||
// hexadecimal number
|
||||
if (number.startsWith('0x')) {
|
||||
this._bn = new BN(number.substring(2), 16);
|
||||
break;
|
||||
}
|
||||
constructor(value: number | string | Buffer | Array<number>) {
|
||||
if (typeof value === 'string') {
|
||||
// hexadecimal number
|
||||
if (value.startsWith('0x')) {
|
||||
this._bn = new BN(value.substring(2), 16);
|
||||
} else {
|
||||
// assume base 58 encoding by default
|
||||
this._bn = new BN(bs58.decode(value));
|
||||
}
|
||||
|
||||
this._bn = new BN(number);
|
||||
break;
|
||||
} else {
|
||||
this._bn = new BN(value);
|
||||
}
|
||||
|
||||
if (this._bn.byteLength() > 32) {
|
||||
|
Reference in New Issue
Block a user