diff --git a/crypto/src/jni-crypto/Cargo.toml b/crypto/src/jni-crypto/Cargo.toml index 5cbf3b59..220015b4 100644 --- a/crypto/src/jni-crypto/Cargo.toml +++ b/crypto/src/jni-crypto/Cargo.toml @@ -12,6 +12,12 @@ curve25519-dalek = { version = "2.1.0", default-features = false } schnorrkel = { version = "0.9.1", features = ["preaudit_deprecated", "u64_backend"] } hex = "0.4.3" +# Pinned transitive dependencies +proc-macro2 = { version = "=1.0.81" } +unicode-ident = { version = "=1.0.12" } +quote = { version = "=1.0.36" } +log = { version = "=0.4.21" } + [dev-dependencies] hex-literal = "0.2.0" -rand = { version = "0.7.3", features = ["wasm-bindgen"] } \ No newline at end of file +rand = { version = "0.7.3", features = ["wasm-bindgen"] } diff --git a/rpc/rpc-api/src/main/java/com/strategyobject/substrateclient/rpc/api/AccountIdDecoder.java b/rpc/rpc-api/src/main/java/com/strategyobject/substrateclient/rpc/api/AccountIdDecoder.java new file mode 100644 index 00000000..3a6dfd36 --- /dev/null +++ b/rpc/rpc-api/src/main/java/com/strategyobject/substrateclient/rpc/api/AccountIdDecoder.java @@ -0,0 +1,22 @@ +package com.strategyobject.substrateclient.rpc.api; + +import com.strategyobject.substrateclient.crypto.ss58.SS58Codec; +import com.strategyobject.substrateclient.rpc.DecoderPair; +import com.strategyobject.substrateclient.rpc.RpcDecoder; +import com.strategyobject.substrateclient.rpc.annotation.AutoRegister; +import com.strategyobject.substrateclient.transport.RpcObject; +import lombok.RequiredArgsConstructor; + +@RequiredArgsConstructor +@AutoRegister(types = AccountId.class) +public class AccountIdDecoder implements RpcDecoder { + + @Override + public AccountId decode(RpcObject value, DecoderPair... decoders) { + if (value.isNull()) { return null; } + if (decoders != null && decoders.length > 0) throw new IllegalArgumentException(); + + return AccountId.fromBytes(SS58Codec.decode(value.asString()).getAddress()); + } + +}