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

support v1.8.0 #31

Merged
merged 12 commits into from
Mar 18, 2024
Merged
Show file tree
Hide file tree
Changes from 11 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
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
"ethers": "^6.4.0",
"nock": "^13.5.3",
"release-it": "^17.1.1",
"semver": "^7.6.0",
"typescript-eslint": "^7.1.0",
"uuid": "^9.0.0"
},
Expand Down
2 changes: 2 additions & 0 deletions src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -116,3 +116,5 @@ export enum DefinitionFlow {

export const DEFAULT_BASE_URL = 'https://api.obol.tech'
export const DEFAULT_CHAIN_ID = 1

export const ETHER_TO_GWEI = 10 ** 9
256 changes: 0 additions & 256 deletions src/hash.ts

This file was deleted.

2 changes: 1 addition & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import {
type ClusterPayload,
type OperatorPayload,
} from './types.js'
import { clusterConfigOrDefinitionHash } from './hash.js'
import { clusterConfigOrDefinitionHash } from './verification/common.js'
import { validatePayload } from './ajv.js'
import { definitionSchema, operatorPayloadSchema } from './schema.js'
export * from './types.js'
Expand Down
2 changes: 1 addition & 1 deletion src/services.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { type ClusterLock } from './types.js'
import { isValidClusterLock } from './verify.js'
import { isValidClusterLock } from './verification/common.js'

/**
* Verifies Cluster Lock's validity.
Expand Down
19 changes: 14 additions & 5 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,11 @@ export interface ClusterPayload {
/** The cluster nodes operators addresses. */
operators: ClusterOperator[]

/** The clusters validators information. */
/** The cluster validators information. */
validators: ClusterValidator[]

/** The cluster partial deposits in gwei or 32000000000. */
deposit_amounts?: string[]
}

/**
Expand Down Expand Up @@ -110,6 +113,9 @@ export interface ClusterDefintion extends ClusterPayload {
/** The number of distributed validators in the cluster. */
num_validators: number

/** The cluster partial deposits in gwei or 32000000000. */
deposit_amounts?: string[]

/** The hash of the cluster definition. */
definition_hash?: string
}
Expand Down Expand Up @@ -172,11 +178,14 @@ export interface DistributedValidator {
/** The public key of the node distributed validator share. */
public_shares: string[]

/** The required deposit data for activating the DV. */
deposit_data: Partial<DepositData>
/** The deposit data for activating the DV. */
deposit_data?: Partial<DepositData>

/** The deposit data with partial amounts or full amount for activating the DV. */
partial_deposit_data?: Array<Partial<DepositData>>

/** pre-generated signed validator builder registration to be sent to builder network. */
builder_registration: BuilderRegistration
builder_registration?: BuilderRegistration
}

/**
Expand All @@ -196,5 +205,5 @@ export interface ClusterLock {
lock_hash: string

/** Node Signature for the lock hash by the node secp256k1 key. */
node_signatures: string[]
node_signatures?: string[]
}
49 changes: 49 additions & 0 deletions src/utils.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,56 @@
import { DefinitionFlow } from './constants'
import { type ClusterDefintion } from './types'

export const hexWithout0x = (hex: string): string => {
return hex.slice(2, hex.length)
}

export const strToUint8Array = (str: string): Uint8Array => {
return new TextEncoder().encode(str)
}

export const definitionFlow = (
clusterDefinition: ClusterDefintion,
): DefinitionFlow | null => {
if (
clusterDefinition.creator.address &&
clusterDefinition.creator.config_signature &&
clusterDefinition.operators.every((operator) => {
return (
operator.address &&
operator.config_signature &&
operator.enr &&
operator.enr_signature
)
})
) {
return DefinitionFlow.Group
} else if (
clusterDefinition.creator.address &&
clusterDefinition.creator.config_signature &&
clusterDefinition.operators.every((operator) => {
return (
!operator.address &&
!operator.config_signature &&
operator.enr &&
!operator.enr_signature
)
})
) {
return DefinitionFlow.Solo
} else if (
!clusterDefinition.creator.address &&
!clusterDefinition.creator.config_signature &&
clusterDefinition.operators.every((operator) => {
return (
!operator.address &&
!operator.config_signature &&
operator.enr &&
!operator.enr_signature
)
})
) {
return DefinitionFlow.Charon
}
return null
}
Loading
Loading