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

add new-stake links #23

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
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
2 changes: 1 addition & 1 deletion .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
@@ -1 +1 @@
@dfkadyr @mike-diamond @Cast0001
* @dfkadyr-stakewise @mike-diamond @Cast0001
5 changes: 1 addition & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
- **Signature Verification:** Leverages BLS (Boneh-Lynn-Shacham) signatures to authenticate deposit data against given public keys.
- **Progress Callbacks:** Provides real-time feedback on processing progress, suitable for applications processing large datasets.
- **Error Handling:** Implements comprehensive error handling, with custom error types and callback functions for robust error management.
- **Withdrawal Address Verification:** The verification is carried out to confirm that the Withdrawal Address is included in the deposit data and that it matches any of the eigen pods addresses that we request directly for the restake vault.
## Installation and Setup
```bash
npm i @stakewise/v3-deposit-data-parser
Expand Down Expand Up @@ -76,12 +75,10 @@ self.addEventListener('message', async (event) => {
| Type | Message |
|------------|---------|
| `EMPTY_FILE` | Deposit data file is empty
| `EIGEN_PODS_EMPTY` | No Eigen pods in the Vault
| `INVALID_JSON_FORMAT` | Deposit data file must be in JSON format
| `MERKLE_TREE_GENERATION_ERROR` | Failed to generate the Merkle tree
| `INVALID_PUBLIC_KEY_FORMAT` | Failed to parse deposit data public key
| `DUPLICATE_DEPOSIT_DATA` | The deposit data file has already been uploaded.
| `INVALID_WITHDRAW_ADDRESS` | The withdrawal addresses don’t match Eigen pods
| `DUPLICATE_DEPOSIT_DATA` | The deposit data file has already been uploaded.
| `MISSING_FIELDS` | Failed to verify the deposit data public keys. Missing fields: {fields}
| `DUPLICATE_PUBLIC_KEYS` | Failed to verify the deposit data public keys. All the entries must be unique.
| `INVALID_SIGNATURE` | Failed to verify the deposit data signatures. Please make sure the file is generated for the {network} network.
1,089 changes: 659 additions & 430 deletions package-lock.json

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion src/parser/depositDataParser.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,6 @@ describe('depositDataParser',() => {
it('throws ParserError if the deposit data file has already been uploaded', async () => {

(requests.getVaultInfo as MockVaultInfo).mockResolvedValue({
isRestake: false,
depositDataRoot: '0x406de60516154112c876f7250d8b289d4e3d840074e8cf755922dd5d3c75d1c0',
})

Expand Down
1 change: 0 additions & 1 deletion src/parser/getDepositData.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ const { pubkey } = mockData[0]

const mockInput = {
pubkey,
isRestake: false,
vaultAddress: '0x9b6a6867d222d62dc301528190e3984d60adb06b',
}

Expand Down
9 changes: 2 additions & 7 deletions src/parser/getDepositData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,25 +5,20 @@ import {
ParserError,
getBytes,
getAmount,
getEigenPodAddress,
getWithdrawalCredentials,
} from './helpers'


export type DepositDataInput = {
pubkey: string
isRestake: boolean
vaultAddress: string
withdrawalAddress?: string
network: SupportedNetworks
}

const getDepositData = async (values: DepositDataInput): Promise<DepositData> => {
const { pubkey, vaultAddress, isRestake, withdrawalAddress, network } = values
const { pubkey, vaultAddress, network } = values

const withdrawalCredentialAddress = isRestake
? await getEigenPodAddress({ vaultAddress, withdrawalAddress, network })
: vaultAddress
const withdrawalCredentialAddress = vaultAddress

try {
const withdrawalCredentials = getWithdrawalCredentials(withdrawalCredentialAddress)
Expand Down
4 changes: 0 additions & 4 deletions src/parser/helpers/errors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,20 @@ type DynamicValues = Record<string, any>
export enum ErrorTypes {
EMPTY_FILE = 'EMPTY_FILE',
MISSING_FIELDS = 'MISSING_FIELDS',
EIGEN_PODS_EMPTY = 'EIGEN_PODS_EMPTY',
INVALID_SIGNATURE = 'INVALID_SIGNATURE',
INVALID_JSON_FORMAT = 'INVALID_JSON_FORMAT',
DUPLICATE_PUBLIC_KEYS = 'DUPLICATE_PUBLIC_KEYS',
DUPLICATE_DEPOSIT_DATA = 'DUPLICATE_DEPOSIT_DATA',
INVALID_WITHDRAW_ADDRESS = 'INVALID_WITHDRAW_ADDRESS',
INVALID_PUBLIC_KEY_FORMAT = 'INVALID_PUBLIC_KEY_FORMAT',
MERKLE_TREE_GENERATION_ERROR = 'MERKLE_TREE_GENERATION_ERROR',
}

export const ErrorMessages: Record<ErrorTypes, string> = {
[ErrorTypes.EMPTY_FILE]: 'Deposit data file is empty.',
[ErrorTypes.EIGEN_PODS_EMPTY]: 'No Eigen pods in the Vault',
[ErrorTypes.INVALID_JSON_FORMAT]: 'Deposit data file must be in JSON format.',
[ErrorTypes.MERKLE_TREE_GENERATION_ERROR]: 'Failed to generate the Merkle tree',
[ErrorTypes.INVALID_PUBLIC_KEY_FORMAT]: 'Failed to parse deposit data public key',
[ErrorTypes.DUPLICATE_DEPOSIT_DATA]: `The deposit data file has already been uploaded.`,
[ErrorTypes.INVALID_WITHDRAW_ADDRESS]: `The withdrawal addresses don’t match Eigen pods`,
[ErrorTypes.MISSING_FIELDS]: 'Failed to verify the deposit data public keys. Missing fields: {fields}',
[ErrorTypes.DUPLICATE_PUBLIC_KEYS]: 'Failed to verify the deposit data public keys. All the entries must be unique.',
[ErrorTypes.INVALID_SIGNATURE]: `
Expand Down
68 changes: 0 additions & 68 deletions src/parser/helpers/getEigenPodAddress.spec.ts

This file was deleted.

35 changes: 0 additions & 35 deletions src/parser/helpers/getEigenPodAddress.ts

This file was deleted.

1 change: 0 additions & 1 deletion src/parser/helpers/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,5 @@ export { default as getAmount } from './getAmount'
export { default as containers } from './containers'
export { default as computeDomain } from './computeDomain'
export { default as getForkVersion } from './getForkVersion'
export { default as getEigenPodAddress } from './getEigenPodAddress'
export { default as ParserError, ErrorMessages, ErrorTypes } from './errors'
export { default as getWithdrawalCredentials } from './getWithdrawalCredentials'
22 changes: 0 additions & 22 deletions src/parser/helpers/requests/getEigenPods.ts

This file was deleted.

2 changes: 1 addition & 1 deletion src/parser/helpers/requests/getVaultInfo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { SupportedNetworks } from '../../types'


const getVaultInfo = async (vaultId: string, network: SupportedNetworks) => {
const query = `query Vault($vaultId: ID!) { vault(id: $vaultId) { isRestake depositDataRoot }}`
const query = `query Vault($vaultId: ID!) { vault(id: $vaultId) { depositDataRoot }}`

const variables = { vaultId: vaultId.toLowerCase() }

Expand Down
1 change: 0 additions & 1 deletion src/parser/helpers/requests/index.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
export { default as getEigenPods } from './getEigenPods'
export { default as getVaultInfo } from './getVaultInfo'
8 changes: 4 additions & 4 deletions src/parser/helpers/requests/urls.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import type { SupportedNetworks } from '../../types'


export const urls: Record<SupportedNetworks, string> = {
'holesky': 'https://holesky-graph.stakewise.io/subgraphs/name/stakewise/stakewise',
'mainnet': 'https://mainnet-graph.stakewise.io/subgraphs/name/stakewise/stakewise',
'gnosis': 'https://gnosis-graph.stakewise.io/subgraphs/name/stakewise/stakewise',
'chiado': 'https://chiado-graph.stakewise.io/subgraphs/name/stakewise/stakewise',
'mainnet': 'https://graphs.stakewise.io/mainnet/subgraphs/name/stakewise/prod',
'holesky': 'https://graphs.stakewise.io/holesky/subgraphs/name/stakewise/prod',
'gnosis': 'https://graphs.stakewise.io/gnosis/subgraphs/name/stakewise/prod',
'chiado': 'https://graphs.stakewise.io/chiado/subgraphs/name/stakewise/prod',
}
2 changes: 0 additions & 2 deletions src/parser/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,6 @@ export const depositDataParser = async (input: ParserInput) => {
const depositData = await getDepositData({
network,
pubkey, vaultAddress,
isRestake: vaultInfo?.isRestake,
withdrawalAddress: withdrawal_address,
})

verifySignature({ bls, pubkey, signature, depositData, network })
Expand Down
Loading