Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FIX: bug in coin type definition #190

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions src/constants/coins.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,4 @@
*
* @category Constants
*/

export const QI_COIN_TYPE = 969;
export const QUAI_COIN_TYPE = 994;
export type AllowedCoinType = 969 | 994;
2 changes: 1 addition & 1 deletion src/constants/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ export { N, WeiPerEther, MaxUint256, MinInt256, MaxInt256 } from './numbers.js';
export { quaisymbol, MessagePrefix } from './strings.js';
export { toShard, Shard, ShardData } from './shards.js';
export { toZone, Zone, ZoneData } from './zones.js';
export { QI_COIN_TYPE, QUAI_COIN_TYPE } from './coins.js';
export { AllowedCoinType } from './coins.js';
3 changes: 2 additions & 1 deletion src/wallet/hdwallet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { randomBytes } from "../crypto/index.js";
import { getZoneForAddress, isQiAddress } from "../utils/index.js";
import { Zone } from '../constants/index.js';
import { TransactionRequest, Provider, TransactionResponse } from '../providers/index.js';
import { AllowedCoinType } from "../constants/index.js";

export interface NeuteredAddressInfo {
pubKey: string;
Expand All @@ -20,7 +21,7 @@ export interface NeuteredAddressInfo {
const MAX_ADDRESS_DERIVATION_ATTEMPTS = 10000000;

export abstract class AbstractHDWallet {
protected static _coinType?: number = 969 || 994;
protected static _coinType?: AllowedCoinType;

// Map of account number to HDNodeWallet
protected _accounts: Map<number, HDNodeWallet> = new Map();
Expand Down
4 changes: 2 additions & 2 deletions src/wallet/qi-hdwallet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { keccak_256 } from '@noble/hashes/sha3';
import { musigCrypto } from '../crypto/index.js';
import { Outpoint } from '../transaction/utxo.js';
import { getZoneForAddress } from '../utils/index.js';
import { Zone } from '../constants/index.js';
import { AllowedCoinType, Zone } from '../constants/index.js';

type OutpointInfo = {
outpoint: Outpoint;
Expand All @@ -25,7 +25,7 @@ export class QiHDWallet extends AbstractHDWallet {

protected static _GAP_LIMIT: number = 20;

protected static _cointype: number = 969;
protected static _coinType: AllowedCoinType = 969;

// Map of change addresses to address info
protected _changeAddresses: Map<string, NeuteredAddressInfo> = new Map();
Expand Down
3 changes: 2 additions & 1 deletion src/wallet/quai-hdwallet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@ import { AbstractHDWallet } from './hdwallet';
import { HDNodeWallet } from "./hdnodewallet";
import { QuaiTransactionRequest, Provider, TransactionResponse } from '../providers/index.js';
import { resolveAddress } from '../address/index.js';
import { AllowedCoinType } from "../constants/index.js";

export class QuaiHDWallet extends AbstractHDWallet {
protected static _cointype: number = 994;
protected static _coinType: AllowedCoinType = 994;

private constructor(root: HDNodeWallet, provider?: Provider) {
super(root, provider);
Expand Down
Loading