-
Notifications
You must be signed in to change notification settings - Fork 78
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Moved teku deserializers from teku into web3signer (#1015)
Web3signer is referencing a few deserializers / serializers from teku, and I'm removing them from teku, so I've recreated them in web3signer to reduce integration issues...
- Loading branch information
Showing
6 changed files
with
162 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 31 additions & 0 deletions
31
...ain/java/tech/pegasys/web3signer/core/service/http/serializers/BLSPubKeyDeserializer.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
/* | ||
* Copyright 2024 ConsenSys AG. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with | ||
* the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on | ||
* an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations under the License. | ||
*/ | ||
package tech.pegasys.web3signer.core.service.http.serializers; | ||
|
||
import tech.pegasys.teku.api.schema.BLSPubKey; | ||
|
||
import java.io.IOException; | ||
|
||
import com.fasterxml.jackson.core.JsonParser; | ||
import com.fasterxml.jackson.databind.DeserializationContext; | ||
import com.fasterxml.jackson.databind.JsonDeserializer; | ||
import org.apache.tuweni.bytes.Bytes; | ||
|
||
public class BLSPubKeyDeserializer extends JsonDeserializer<BLSPubKey> { | ||
public BLSPubKeyDeserializer() {} | ||
|
||
@Override | ||
public BLSPubKey deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { | ||
return new BLSPubKey(Bytes.fromHexString(p.getValueAsString())); | ||
} | ||
} |
32 changes: 32 additions & 0 deletions
32
.../main/java/tech/pegasys/web3signer/core/service/http/serializers/BLSPubKeySerializer.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
/* | ||
* Copyright 2024 ConsenSys AG. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with | ||
* the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on | ||
* an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations under the License. | ||
*/ | ||
package tech.pegasys.web3signer.core.service.http.serializers; | ||
|
||
import tech.pegasys.teku.api.schema.BLSPubKey; | ||
|
||
import java.io.IOException; | ||
import java.util.Locale; | ||
|
||
import com.fasterxml.jackson.core.JsonGenerator; | ||
import com.fasterxml.jackson.databind.JsonSerializer; | ||
import com.fasterxml.jackson.databind.SerializerProvider; | ||
|
||
public class BLSPubKeySerializer extends JsonSerializer<BLSPubKey> { | ||
public BLSPubKeySerializer() {} | ||
|
||
@Override | ||
public void serialize(BLSPubKey value, JsonGenerator gen, SerializerProvider serializers) | ||
throws IOException { | ||
gen.writeString(value.toHexString().toLowerCase(Locale.ROOT)); | ||
} | ||
} |
30 changes: 30 additions & 0 deletions
30
.../java/tech/pegasys/web3signer/core/service/http/serializers/BLSSignatureDeserializer.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
/* | ||
* Copyright 2024 ConsenSys AG. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with | ||
* the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on | ||
* an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations under the License. | ||
*/ | ||
package tech.pegasys.web3signer.core.service.http.serializers; | ||
|
||
import tech.pegasys.teku.api.schema.BLSSignature; | ||
|
||
import java.io.IOException; | ||
|
||
import com.fasterxml.jackson.core.JsonParser; | ||
import com.fasterxml.jackson.databind.DeserializationContext; | ||
import com.fasterxml.jackson.databind.JsonDeserializer; | ||
|
||
public class BLSSignatureDeserializer extends JsonDeserializer<BLSSignature> { | ||
public BLSSignatureDeserializer() {} | ||
|
||
@Override | ||
public BLSSignature deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { | ||
return BLSSignature.fromHexString(p.getValueAsString()); | ||
} | ||
} |
32 changes: 32 additions & 0 deletions
32
...in/java/tech/pegasys/web3signer/core/service/http/serializers/BLSSignatureSerializer.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
/* | ||
* Copyright 2024 ConsenSys AG. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with | ||
* the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on | ||
* an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations under the License. | ||
*/ | ||
package tech.pegasys.web3signer.core.service.http.serializers; | ||
|
||
import tech.pegasys.teku.api.schema.BLSSignature; | ||
|
||
import java.io.IOException; | ||
import java.util.Locale; | ||
|
||
import com.fasterxml.jackson.core.JsonGenerator; | ||
import com.fasterxml.jackson.databind.JsonSerializer; | ||
import com.fasterxml.jackson.databind.SerializerProvider; | ||
|
||
public class BLSSignatureSerializer extends JsonSerializer<BLSSignature> { | ||
public BLSSignatureSerializer() {} | ||
|
||
@Override | ||
public void serialize(BLSSignature value, JsonGenerator gen, SerializerProvider serializers) | ||
throws IOException { | ||
gen.writeString(value.toHexString().toLowerCase(Locale.ROOT)); | ||
} | ||
} |
32 changes: 32 additions & 0 deletions
32
...in/java/tech/pegasys/web3signer/core/service/http/serializers/SszBitvectorSerializer.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
/* | ||
* Copyright 2024 ConsenSys AG. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with | ||
* the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on | ||
* an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations under the License. | ||
*/ | ||
package tech.pegasys.web3signer.core.service.http.serializers; | ||
|
||
import tech.pegasys.teku.infrastructure.ssz.collections.SszBitvector; | ||
|
||
import java.io.IOException; | ||
import java.util.Locale; | ||
|
||
import com.fasterxml.jackson.core.JsonGenerator; | ||
import com.fasterxml.jackson.databind.JsonSerializer; | ||
import com.fasterxml.jackson.databind.SerializerProvider; | ||
|
||
public class SszBitvectorSerializer extends JsonSerializer<SszBitvector> { | ||
public SszBitvectorSerializer() {} | ||
|
||
@Override | ||
public void serialize(SszBitvector value, JsonGenerator gen, SerializerProvider serializers) | ||
throws IOException { | ||
gen.writeString(value.sszSerialize().toHexString().toLowerCase(Locale.ROOT)); | ||
} | ||
} |