Skip to content

Commit

Permalink
chore: using scanning policy enum where possible
Browse files Browse the repository at this point in the history
  • Loading branch information
r4mmer committed Dec 11, 2023
1 parent e08f70c commit b9dbe79
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
4 changes: 2 additions & 2 deletions src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* LICENSE file in the root directory of this source tree.
*/

import { AddressScanPolicy } from "./types";
import { AddressScanPolicy, SCANNING_POLICY } from "./types";


/**
Expand Down Expand Up @@ -262,4 +262,4 @@ export const HATHOR_MAGIC_BYTES = 'Hathor Signed Message:\n';
/**
* Default address scanning policy
*/
export const DEFAULT_ADDRESS_SCANNING_POLICY: AddressScanPolicy = 'gap-limit';
export const DEFAULT_ADDRESS_SCANNING_POLICY: AddressScanPolicy = SCANNING_POLICY.GAP_LIMIT;
10 changes: 5 additions & 5 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -221,12 +221,12 @@ export enum SCANNING_POLICY {
};

export interface IGapLimitAddressScanPolicy {
policy: 'gap-limit';
policy: SCANNING_POLICY.GAP_LIMIT;
gapLimit: number;
}

export interface IIndexLimitAddressScanPolicy {
policy: 'index-limit';
policy: SCANNING_POLICY.INDEX_LIMIT;
startIndex: number;
endIndex: number;
}
Expand All @@ -239,16 +239,16 @@ export interface IScanPolicyLoadAddresses {
count: number;
}

export type AddressScanPolicy = 'gap-limit' | 'index-limit';
export type AddressScanPolicy = SCANNING_POLICY.GAP_LIMIT | SCANNING_POLICY.INDEX_LIMIT;

export type AddressScanPolicyData = IGapLimitAddressScanPolicy | IIndexLimitAddressScanPolicy;

export function isGapLimitScanPolicy(scanPolicyData: AddressScanPolicyData): scanPolicyData is IGapLimitAddressScanPolicy {
return scanPolicyData.policy === 'gap-limit';
return scanPolicyData.policy === SCANNING_POLICY.GAP_LIMIT;
}

export function isIndexLimitScanPolicy(scanPolicyData: AddressScanPolicyData): scanPolicyData is IIndexLimitAddressScanPolicy {
return scanPolicyData.policy === 'index-limit';
return scanPolicyData.policy === SCANNING_POLICY.INDEX_LIMIT;
}

export interface IWalletData {
Expand Down

0 comments on commit b9dbe79

Please sign in to comment.