Skip to content

Commit b49ff15

Browse files
authored
util: rename withdrawal request's validatorPublicKey to validatorPubkey (#3474)
1 parent a8a8973 commit b49ff15

File tree

6 files changed

+20
-22
lines changed

6 files changed

+20
-22
lines changed

packages/block/src/from-beacon-payload.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ type BeaconDepositRequest = {
2020

2121
type BeaconWithdrawalRequest = {
2222
source_address: PrefixedHexString
23-
validator_public_key: PrefixedHexString
23+
validator_pub_key: PrefixedHexString
2424
amount: PrefixedHexString
2525
}
2626

@@ -160,7 +160,7 @@ export function executionPayloadFromBeaconPayload(payload: BeaconPayloadJson): E
160160
if (payload.withdrawal_requests !== undefined && payload.withdrawal_requests !== null) {
161161
executionPayload.withdrawalRequests = payload.withdrawal_requests.map((breq) => ({
162162
sourceAddress: breq.source_address,
163-
validatorPublicKey: breq.validator_public_key,
163+
validatorPubkey: breq.validator_pub_key,
164164
amount: breq.amount,
165165
}))
166166
}

packages/block/test/eip7685block.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ function getRandomDepositRequest(): CLRequest<CLRequestType> {
2626
function getRandomWithdrawalRequest(): CLRequest<CLRequestType> {
2727
const withdrawalRequestData = {
2828
sourceAddress: randomBytes(20),
29-
validatorPublicKey: randomBytes(48),
29+
validatorPubkey: randomBytes(48),
3030
amount: bytesToBigInt(randomBytes(8)),
3131
}
3232
return WithdrawalRequest.fromRequestData(withdrawalRequestData) as CLRequest<CLRequestType>

packages/client/src/rpc/validation.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -485,7 +485,7 @@ export const validators = {
485485
},
486486

487487
get withdrawalRequest() {
488-
return (requiredFields: string[] = ['sourceAddress', 'validatorPublicKey', 'amount']) => {
488+
return (requiredFields: string[] = ['sourceAddress', 'validatorPubkey', 'amount']) => {
489489
return (params: any[], index: number) => {
490490
if (typeof params[index] !== 'object') {
491491
return {
@@ -517,8 +517,8 @@ export const validators = {
517517
if (v !== undefined) return v
518518
}
519519

520-
// validate validatorPublicKey
521-
for (const field of [wt.validatorPublicKey]) {
520+
// validate validatorPubkey
521+
for (const field of [wt.validatorPubkey]) {
522522
const v = validate(field, this.bytes48)
523523
if (v !== undefined) return v
524524
}

packages/util/src/requests.ts

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ export type DepositRequestV1 = {
3030

3131
export type WithdrawalRequestV1 = {
3232
sourceAddress: PrefixedHexString // DATA 20 bytes
33-
validatorPublicKey: PrefixedHexString // DATA 48 bytes
33+
validatorPubkey: PrefixedHexString // DATA 48 bytes
3434
amount: PrefixedHexString // QUANTITY 8 bytes in gwei
3535
}
3636

@@ -49,7 +49,7 @@ export type DepositRequestData = {
4949

5050
export type WithdrawalRequestData = {
5151
sourceAddress: Uint8Array
52-
validatorPublicKey: Uint8Array
52+
validatorPubkey: Uint8Array
5353
amount: bigint
5454
}
5555

@@ -140,22 +140,22 @@ export class DepositRequest extends CLRequest<CLRequestType.Deposit> {
140140
export class WithdrawalRequest extends CLRequest<CLRequestType.Withdrawal> {
141141
constructor(
142142
public readonly sourceAddress: Uint8Array,
143-
public readonly validatorPublicKey: Uint8Array,
143+
public readonly validatorPubkey: Uint8Array,
144144
public readonly amount: bigint
145145
) {
146146
super(CLRequestType.Withdrawal)
147147
}
148148

149149
public static fromRequestData(withdrawalData: WithdrawalRequestData): WithdrawalRequest {
150-
const { sourceAddress, validatorPublicKey, amount } = withdrawalData
151-
return new WithdrawalRequest(sourceAddress, validatorPublicKey, amount)
150+
const { sourceAddress, validatorPubkey, amount } = withdrawalData
151+
return new WithdrawalRequest(sourceAddress, validatorPubkey, amount)
152152
}
153153

154154
public static fromJSON(jsonData: WithdrawalRequestV1): WithdrawalRequest {
155-
const { sourceAddress, validatorPublicKey, amount } = jsonData
155+
const { sourceAddress, validatorPubkey, amount } = jsonData
156156
return this.fromRequestData({
157157
sourceAddress: hexToBytes(sourceAddress),
158-
validatorPublicKey: hexToBytes(validatorPublicKey),
158+
validatorPubkey: hexToBytes(validatorPubkey),
159159
amount: hexToBigInt(amount),
160160
})
161161
}
@@ -165,27 +165,27 @@ export class WithdrawalRequest extends CLRequest<CLRequestType.Withdrawal> {
165165

166166
return concatBytes(
167167
Uint8Array.from([this.type]),
168-
RLP.encode([this.sourceAddress, this.validatorPublicKey, amountBytes])
168+
RLP.encode([this.sourceAddress, this.validatorPubkey, amountBytes])
169169
)
170170
}
171171

172172
toJSON(): WithdrawalRequestV1 {
173173
return {
174174
sourceAddress: bytesToHex(this.sourceAddress),
175-
validatorPublicKey: bytesToHex(this.validatorPublicKey),
175+
validatorPubkey: bytesToHex(this.validatorPubkey),
176176
amount: bigIntToHex(this.amount),
177177
}
178178
}
179179

180180
public static deserialize(bytes: Uint8Array): WithdrawalRequest {
181-
const [sourceAddress, validatorPublicKey, amount] = RLP.decode(bytes.slice(1)) as [
181+
const [sourceAddress, validatorPubkey, amount] = RLP.decode(bytes.slice(1)) as [
182182
Uint8Array,
183183
Uint8Array,
184184
Uint8Array
185185
]
186186
return this.fromRequestData({
187187
sourceAddress,
188-
validatorPublicKey,
188+
validatorPubkey,
189189
amount: bytesToBigInt(amount),
190190
})
191191
}

packages/util/test/requests.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ describe('Requests', () => {
3838
it('withdrawal request', () => {
3939
const withdrawalRequestData = {
4040
sourceAddress: randomBytes(20),
41-
validatorPublicKey: randomBytes(48),
41+
validatorPubkey: randomBytes(48),
4242
amount: bytesToBigInt(randomBytes(8)),
4343
}
4444

packages/vm/src/requests.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -89,11 +89,9 @@ const accumulateEIP7002Requests = async (
8989
for (let startByte = 0; startByte < resultsBytes.length; startByte += 76) {
9090
const slicedBytes = resultsBytes.slice(startByte, startByte + 76)
9191
const sourceAddress = slicedBytes.slice(0, 20) // 20 Bytes
92-
const validatorPublicKey = slicedBytes.slice(20, 68) // 48 Bytes
92+
const validatorPubkey = slicedBytes.slice(20, 68) // 48 Bytes
9393
const amount = bytesToBigInt(unpadBytes(slicedBytes.slice(68, 76))) // 8 Bytes / Uint64
94-
requests.push(
95-
WithdrawalRequest.fromRequestData({ sourceAddress, validatorPublicKey, amount })
96-
)
94+
requests.push(WithdrawalRequest.fromRequestData({ sourceAddress, validatorPubkey, amount }))
9795
}
9896
}
9997

0 commit comments

Comments
 (0)