|
| 1 | +/* |
| 2 | + * Copyright Consensys Software Inc., 2024 |
| 3 | + * |
| 4 | + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with |
| 5 | + * the License. You may obtain a copy of the License at |
| 6 | + * |
| 7 | + * http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | + * |
| 9 | + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on |
| 10 | + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the |
| 11 | + * specific language governing permissions and limitations under the License. |
| 12 | + */ |
| 13 | + |
| 14 | +package tech.pegasys.teku.spec.datastructures.state.versions.electra; |
| 15 | + |
| 16 | +import tech.pegasys.teku.infrastructure.ssz.containers.Container5; |
| 17 | +import tech.pegasys.teku.infrastructure.ssz.containers.ContainerSchema5; |
| 18 | +import tech.pegasys.teku.infrastructure.ssz.primitive.SszBytes32; |
| 19 | +import tech.pegasys.teku.infrastructure.ssz.primitive.SszUInt64; |
| 20 | +import tech.pegasys.teku.infrastructure.ssz.schema.SszPrimitiveSchemas; |
| 21 | +import tech.pegasys.teku.infrastructure.ssz.tree.TreeNode; |
| 22 | +import tech.pegasys.teku.infrastructure.unsigned.UInt64; |
| 23 | +import tech.pegasys.teku.spec.datastructures.type.SszPublicKey; |
| 24 | +import tech.pegasys.teku.spec.datastructures.type.SszPublicKeySchema; |
| 25 | +import tech.pegasys.teku.spec.datastructures.type.SszSignature; |
| 26 | +import tech.pegasys.teku.spec.datastructures.type.SszSignatureSchema; |
| 27 | + |
| 28 | +public class PendingDeposit |
| 29 | + extends Container5< |
| 30 | + PendingDeposit, SszPublicKey, SszBytes32, SszUInt64, SszSignature, SszUInt64> { |
| 31 | + |
| 32 | + public static class PendingDepositSchema |
| 33 | + extends ContainerSchema5< |
| 34 | + PendingDeposit, SszPublicKey, SszBytes32, SszUInt64, SszSignature, SszUInt64> { |
| 35 | + |
| 36 | + public PendingDepositSchema() { |
| 37 | + super( |
| 38 | + "PendingDeposit", |
| 39 | + namedSchema("pubkey", SszPublicKeySchema.INSTANCE), |
| 40 | + namedSchema("withdrawal_credentials", SszPrimitiveSchemas.BYTES32_SCHEMA), |
| 41 | + namedSchema("amount", SszPrimitiveSchemas.UINT64_SCHEMA), |
| 42 | + namedSchema("signature", SszSignatureSchema.INSTANCE), |
| 43 | + namedSchema("slot", SszPrimitiveSchemas.UINT64_SCHEMA)); |
| 44 | + } |
| 45 | + |
| 46 | + @Override |
| 47 | + public PendingDeposit createFromBackingNode(final TreeNode node) { |
| 48 | + return new PendingDeposit(this, node); |
| 49 | + } |
| 50 | + |
| 51 | + public PendingDeposit create( |
| 52 | + final SszPublicKey publicKey, |
| 53 | + final SszBytes32 withdrawalCredentials, |
| 54 | + final SszUInt64 amount, |
| 55 | + final SszSignature signature, |
| 56 | + final SszUInt64 slot) { |
| 57 | + return new PendingDeposit(this, publicKey, withdrawalCredentials, amount, signature, slot); |
| 58 | + } |
| 59 | + |
| 60 | + public SszPublicKey getPublicKeySchema() { |
| 61 | + return (SszPublicKey) getFieldSchema0(); |
| 62 | + } |
| 63 | + |
| 64 | + public SszBytes32 getWithdrawalCredentialsSchema() { |
| 65 | + return (SszBytes32) getFieldSchema1(); |
| 66 | + } |
| 67 | + |
| 68 | + public SszUInt64 getAmountSchema() { |
| 69 | + return (SszUInt64) getFieldSchema2(); |
| 70 | + } |
| 71 | + |
| 72 | + public SszSignatureSchema getSignatureSchema() { |
| 73 | + return (SszSignatureSchema) getFieldSchema3(); |
| 74 | + } |
| 75 | + |
| 76 | + public SszUInt64 getSlotSchema() { |
| 77 | + return (SszUInt64) getFieldSchema4(); |
| 78 | + } |
| 79 | + } |
| 80 | + |
| 81 | + private PendingDeposit(final PendingDepositSchema type, final TreeNode backingNode) { |
| 82 | + super(type, backingNode); |
| 83 | + } |
| 84 | + |
| 85 | + private PendingDeposit( |
| 86 | + final PendingDepositSchema type, |
| 87 | + final SszPublicKey publicKey, |
| 88 | + final SszBytes32 withdrawalCredentials, |
| 89 | + final SszUInt64 amount, |
| 90 | + final SszSignature signature, |
| 91 | + final SszUInt64 slot) { |
| 92 | + super(type, publicKey, withdrawalCredentials, amount, signature, slot); |
| 93 | + } |
| 94 | + |
| 95 | + public int getIndex() { |
| 96 | + return ((SszUInt64) get(0)).get().intValue(); |
| 97 | + } |
| 98 | + |
| 99 | + public UInt64 getAmount() { |
| 100 | + return ((SszUInt64) get(1)).get(); |
| 101 | + } |
| 102 | +} |
0 commit comments