Skip to content

Commit

Permalink
fixed address checker
Browse files Browse the repository at this point in the history
  • Loading branch information
Hicaru committed Mar 6, 2023
1 parent c73e1be commit a1e8569
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 6 deletions.
4 changes: 2 additions & 2 deletions core/background/account/account.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import {
ACCOUNT_NAME_MUST_UNIQUE,
ACCOUNT_PRODUCT_ID_MUST_UNIQUE
} from './errors';
import { INVALID_BASE58 } from 'background/contacts/errors';
import { INVALID_BASE58_ADDRESS } from 'lib/address/errors';
import { addressFromPublicKey, isBase58Address, publicKeyBytesFromPrivateKey } from 'lib/address';
import { base58PrivateKeyToBytes, isPrivateKey } from 'lib/validator';
import { TypeOf } from 'lib/type';
Expand Down Expand Up @@ -196,7 +196,7 @@ export class AccountController {
}

async addAccountForTrack(base58: string, name: string) {
assert(await isBase58Address(base58), INVALID_BASE58, AccountError);
assert(await isBase58Address(base58), INVALID_BASE58_ADDRESS, AccountError);

const index = this.lastIndexTracker;
const type = AccountTypes.Track;
Expand Down
4 changes: 3 additions & 1 deletion core/background/background/transaction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,9 @@ export class BackgroundTransaction {
try {
this.#core.guard.checkSession();

assert(await isBase58Address(params.toAddr), INVALID_BASE58_ADDRESS);
if (!params.code) {
assert(await isBase58Address(params.toAddr), INVALID_BASE58_ADDRESS);
}

if (params.domain) {
const has = this.#core.connections.has(params.domain);
Expand Down
1 change: 0 additions & 1 deletion core/background/contacts/errors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,3 @@ export class ContactsError extends BaseError {

export const UINIQE_NAME = 'name must be unique';
export const UINIQE_ADDRESS = 'address must be unique';
export const INVALID_BASE58 = 'invalid base58 address';
5 changes: 3 additions & 2 deletions core/background/contacts/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ import type { Contact } from 'types';
import { BrowserStorage, buildObject } from 'lib/storage';
import { Fields } from 'config/fields';
import { assert } from 'lib/assert';
import { UINIQE_NAME, ContactsError, UINIQE_ADDRESS, INVALID_BASE58 } from './errors';
import { UINIQE_NAME, ContactsError, UINIQE_ADDRESS } from './errors';
import { INVALID_BASE58_ADDRESS } from 'lib/address/errors';
import { isBase58Address } from 'lib/address';


Expand Down Expand Up @@ -42,7 +43,7 @@ export class ContactController {

assert(
await isBase58Address(connect.address),
INVALID_BASE58,
INVALID_BASE58_ADDRESS,
ContactsError
);

Expand Down

0 comments on commit a1e8569

Please sign in to comment.