Skip to content

Commit

Permalink
fix: remove static values initializer
Browse files Browse the repository at this point in the history
  • Loading branch information
getlarge committed Mar 5, 2021
1 parent 95d6e38 commit 526bc13
Show file tree
Hide file tree
Showing 7 changed files with 74 additions and 35 deletions.
4 changes: 2 additions & 2 deletions types/lib/condition.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Asn1Json, TypeAsn1Condition } from '../types';
import { TypeAsn1Condition } from '../types';

export interface ConditionAsn1Json {
type: TypeAsn1Condition;
Expand Down Expand Up @@ -54,7 +54,7 @@ export default class Condition {

serializeBinary(): Buffer;

getAsn1Json(): Asn1Json;
getAsn1Json(): ConditionAsn1Json;

validate(): boolean;
}
6 changes: 4 additions & 2 deletions types/lib/fulfillment.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ import {
ThresholdSha256Json,
TypeAsn1Fulfillment,
TypeName,
TypeId,
} from '../types';
import Condition from './condition';

interface FulfillmentAsn1JsonValueMap {
[TypeAsn1Fulfillment.PreimageSha256]: PreimageSha256Json;
Expand All @@ -32,7 +34,7 @@ export default class Fulfillment {
json: PreimageSha256Json | PrefixSha256Json | ThresholdSha256Json | RsaSha256Json | Ed25519Sha256Json
): Fulfillment;

getTypeId(): TypeIds;
getTypeId(): TypeId;

getTypeName(): TypeName;

Expand Down Expand Up @@ -60,5 +62,5 @@ export default class Fulfillment {

serializeBase64Url(): string;

validate(): boolean;
validate(message?: Buffer): boolean;
}
20 changes: 14 additions & 6 deletions types/types/ed25519-sha256.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,25 @@ import type {
} from '.';
import type BaseSha256 from './base-sha256';

export const TYPE_ID: TypeId.Ed25519Sha256;
export const TYPE_NAME: TypeName.Ed25519Sha256;
export const TYPE_ASN1_CONDITION: TypeAsn1Condition.Ed25519Sha256;
export const TYPE_ASN1_FULFILLMENT: TypeAsn1Fulfillment.Ed25519Sha256;
export const TYPE_CATEGORY: TypeCategory.Ed25519Sha256;

export const TYPE_ID = TypeId.Ed25519Sha256;
export const CONSTANT_COST = 131072;
export default class Ed25519Sha256 extends BaseSha256 {
private publicKey: Buffer;
private signature: Buffer;

static TYPE_ID = TypeId.Ed25519Sha256;
static TYPE_NAME = TypeName.Ed25519Sha256;
static TYPE_ASN1_CONDITION = TypeAsn1Condition.Ed25519Sha256;
static TYPE_ASN1_FULFILLMENT = TypeAsn1Fulfillment.Ed25519Sha256;
static TYPE_CATEGORY = TypeCategory.Ed25519Sha256;
static TYPE_ID: TypeId.Ed25519Sha256;
static TYPE_NAME: TypeName.Ed25519Sha256;
static TYPE_ASN1_CONDITION: TypeAsn1Condition.Ed25519Sha256;
static TYPE_ASN1_FULFILLMENT: TypeAsn1Fulfillment.Ed25519Sha256;
static TYPE_CATEGORY: TypeCategory.Ed25519Sha256;

static CONSTANT_COST = 131072;
static CONSTANT_COST: number;

constructor();

Expand Down
23 changes: 16 additions & 7 deletions types/types/prefix-sha256.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,28 @@ import type Condition from '../lib/condition';
import type Fulfillment from '../lib/fulfillment';
import type BaseSha256 from './base-sha256';

export const TYPE_ID = TypeId.PrefixSha256;
export const TYPE_NAME: TypeName.PrefixSha256;
export const TYPE_ASN1_CONDITION: TypeAsn1Condition.PrefixSha256;
export const TYPE_ASN1_FULFILLMENT: TypeAsn1Fulfillment.PrefixSha256;
export const TYPE_CATEGORY: TypeCategory.PrefixSha256;

export const CONSTANT_BASE_COST = 16384;
export const CONSTANT_COST_DIVISOR = 256;

export default class PrefixSha256 extends BaseSha256 {
private prefix: Buffer;
private subcondition: Condition | Fulfillment;
private maxMessageLength: number;

static TYPE_ID = TypeId.PrefixSha256;
static TYPE_NAME = TypeName.PrefixSha256;
static TYPE_ASN1_CONDITION = TypeAsn1Condition.PrefixSha256;
static TYPE_ASN1_FULFILLMENT = TypeAsn1Fulfillment.PrefixSha256;
static TYPE_CATEGORY = TypeCategory.PrefixSha256;
static TYPE_ID: TypeId.PrefixSha256;
static TYPE_NAME: TypeName.PrefixSha256;
static TYPE_ASN1_CONDITION: TypeAsn1Condition.PrefixSha256;
static TYPE_ASN1_FULFILLMENT: TypeAsn1Fulfillment.PrefixSha256;
static TYPE_CATEGORY: TypeCategory.PrefixSha256;

static CONSTANT_BASE_COST = 16384;
static CONSTANT_COST_DIVISOR = 256;
static CONSTANT_BASE_COST: number;
static CONSTANT_COST_DIVISOR: number;

constructor();

Expand Down
16 changes: 11 additions & 5 deletions types/types/preimage-sha256.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,20 @@ import type {
} from '.';
import type BaseSha256 from './base-sha256';

export const TYPE_ID = TypeId.PreimageSha256;
export const TYPE_NAME = TypeName.PreimageSha256;
export const TYPE_ASN1_CONDITION = TypeAsn1Condition.PreimageSha256;
export const TYPE_ASN1_FULFILLMENT = TypeAsn1Fulfillment.PreimageSha256;
export const TYPE_CATEGORY = TypeCategory.PreimageSha256;

export default class PreimageSha256 extends BaseSha256 {
private preimage: Buffer;

static TYPE_ID = TypeId.PreimageSha256;
static TYPE_NAME = TypeName.PreimageSha256;
static TYPE_ASN1_CONDITION = TypeAsn1Condition.PreimageSha256;
static TYPE_ASN1_FULFILLMENT = TypeAsn1Fulfillment.PreimageSha256;
static TYPE_CATEGORY = TypeCategory.PreimageSha256;
static TYPE_ID: TypeId.PreimageSha256;
static TYPE_NAME: TypeName.PreimageSha256;
static TYPE_ASN1_CONDITION: TypeAsn1Condition.PreimageSha256;
static TYPE_ASN1_FULFILLMENT: TypeAsn1Fulfillment.PreimageSha256;
static TYPE_CATEGORY: TypeCategory.PreimageSha256;

private getFingerprintContents(): Buffer;

Expand Down
20 changes: 14 additions & 6 deletions types/types/rsa-sha256.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,25 @@ import type {
} from '.';
import type BaseSha256 from './base-sha256';

export const TYPE_ID = TypeId.RsaSha256;
export const TYPE_NAME = TypeName.RsaSha256;
export const TYPE_ASN1_CONDITION = TypeAsn1Condition.RsaSha256;
export const TYPE_ASN1_FULFILLMENT = TypeAsn1Fulfillment.RsaSha256;
export const TYPE_CATEGORY = TypeCategory.RsaSha256;

export const COST_RIGHT_SHIFT = 6; // 2^6 = 64

export default class RsaSha256 extends BaseSha256 {
private modulus: Buffer;
private signature: Buffer;

static TYPE_ID = TypeId.RsaSha256;
static TYPE_NAME = TypeName.RsaSha256;
static TYPE_ASN1_CONDITION = TypeAsn1Condition.RsaSha256;
static TYPE_ASN1_FULFILLMENT = TypeAsn1Fulfillment.RsaSha256;
static TYPE_CATEGORY = TypeCategory.RsaSha256;
static TYPE_ID: TypeId.RsaSha256;
static TYPE_NAME: TypeName.RsaSha256;
static TYPE_ASN1_CONDITION: TypeAsn1Condition.RsaSha256;
static TYPE_ASN1_FULFILLMENT: TypeAsn1Fulfillment.RsaSha256;
static TYPE_CATEGORY: TypeCategory.RsaSha256;

static COST_RIGHT_SHIFT = 6; // 2^6 = 64
static COST_RIGHT_SHIFT: number;

constructor();

Expand Down
20 changes: 13 additions & 7 deletions types/types/threshold-sha256.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ import type Condition from '../lib/condition';
import type Fulfillment from '../lib/fulfillment';
import type BaseSha256 from './base-sha256';

declare const CONDITION = 'condition';
declare const FULFILLMENT = 'fulfillment';
export const CONDITION = 'condition';
export const FULFILLMENT = 'fulfillment';

interface SubConditionBodyMap {
condition: Condition;
Expand All @@ -24,15 +24,21 @@ export type SubCondition<T = 'condition' | 'fulfillment'> = {
body: SubConditionBodyMap[T];
};

export const TYPE_ID = TypeId.ThresholdSha256;
export const TYPE_NAME = TypeName.ThresholdSha256;
export const TYPE_ASN1_CONDITION = TypeAsn1Condition.ThresholdSha256;
export const TYPE_ASN1_FULFILLMENT = TypeAsn1Fulfillment.ThresholdSha256;
export const TYPE_CATEGORY = TypeCategory.ThresholdSha256;

export default class ThresholdSha256 extends BaseSha256 {
private threshold: number;
private subconditions: SubCondition[];

static TYPE_ID = TypeId.ThresholdSha256;
static TYPE_NAME = TypeName.ThresholdSha256;
static TYPE_ASN1_CONDITION = TypeAsn1Condition.ThresholdSha256;
static TYPE_ASN1_FULFILLMENT = TypeAsn1Fulfillment.ThresholdSha256;
static TYPE_CATEGORY = TypeCategory.ThresholdSha256;
static TYPE_ID: TypeId.ThresholdSha256;
static TYPE_NAME: TypeName.ThresholdSha256;
static TYPE_ASN1_CONDITION: TypeAsn1Condition.ThresholdSha256;
static TYPE_ASN1_FULFILLMENT: TypeAsn1Fulfillment.ThresholdSha256;
static TYPE_CATEGORY: TypeCategory.ThresholdSha256;

constructor();

Expand Down

0 comments on commit 526bc13

Please sign in to comment.