Skip to content
Merged
Changes from 1 commit
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
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.rpc.context.RpcDecoderContext;
import com.strategyobject.substrateclient.transport.RpcObject;
import lombok.NonNull;
import lombok.RequiredArgsConstructor;

@RequiredArgsConstructor
@AutoRegister(types = AccountId.class)
public class AccountIdDecoder implements RpcDecoder<AccountId> {
private final @NonNull RpcDecoderContext rpcDecoderContext;

@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());
}
}
Loading