Add support for extended-auth account types
Gajumaru Serialization Tests / tests (push) Successful in 11s
Gajumaru Serialization Tests / tests (push) Successful in 11s
This commit is contained in:
@@ -36,6 +36,7 @@
|
||||
| transaction
|
||||
| tx_hash
|
||||
| account_pubkey
|
||||
| {account_pubkey, 0..6}
|
||||
| account_seckey
|
||||
| associate_chain
|
||||
| entry
|
||||
@@ -107,8 +108,12 @@ safe_decode_keypair(#{<<"pub">> := EncPub, <<"priv">> := EncPriv}) ->
|
||||
|
||||
-spec encode(known_type(), payload() | gmser_id:id()) -> encoded().
|
||||
encode(id_hash, Payload) ->
|
||||
{IdType, Val} = gmser_id:specialize(Payload),
|
||||
encode(id2type(IdType), Val);
|
||||
case gmser_id:to_map(Payload) of
|
||||
#{type := account, subtype := SubT, value := Val} ->
|
||||
encode({account_pubkey, SubT}, Val);
|
||||
#{type := IdType, value := Val} ->
|
||||
encode(id2type(IdType), Val)
|
||||
end;
|
||||
encode(Type, Payload) ->
|
||||
case type_size_check(Type, Payload) of
|
||||
ok ->
|
||||
@@ -237,17 +242,16 @@ id2type(associate_chain) -> associate_chain;
|
||||
id2type(channel) -> channel;
|
||||
id2type(commitment) -> commitment;
|
||||
id2type(contract) -> contract_pubkey;
|
||||
id2type(contract_source) -> contract_source;
|
||||
id2type(name) -> name;
|
||||
id2type(native_token) -> native_token;
|
||||
id2type(entry) -> entry.
|
||||
|
||||
type2id({account_pubkey, SubT}) -> {account, SubT};
|
||||
type2id(account_pubkey) -> account;
|
||||
type2id(associate_chain) -> associate_chain;
|
||||
type2id(channel) -> channel;
|
||||
type2id(commitment) -> commitment;
|
||||
type2id(contract_pubkey) -> contract;
|
||||
type2id(contract_source) -> contract_source;
|
||||
type2id(name) -> name;
|
||||
type2id(native_token) -> native_token;
|
||||
type2id(entry) -> entry.
|
||||
@@ -266,6 +270,7 @@ type2enc(contract_store_value) -> ?BASE64;
|
||||
type2enc(contract_source) -> ?BASE64;
|
||||
type2enc(transaction) -> ?BASE64;
|
||||
type2enc(tx_hash) -> ?BASE58;
|
||||
type2enc({account_pubkey, _}) -> ?BASE58;
|
||||
type2enc(account_pubkey) -> ?BASE58;
|
||||
type2enc(account_seckey) -> ?BASE58;
|
||||
type2enc(associate_chain) -> ?BASE58;
|
||||
@@ -298,6 +303,13 @@ type2pfx(contract_store_value) -> <<"cv">>;
|
||||
type2pfx(contract_source) -> <<"cx">>;
|
||||
type2pfx(transaction) -> <<"tx">>;
|
||||
type2pfx(tx_hash) -> <<"th">>;
|
||||
type2pfx({account_pubkey,0}) -> <<"a0">>;
|
||||
type2pfx({account_pubkey,1}) -> <<"a1">>;
|
||||
type2pfx({account_pubkey,2}) -> <<"a2">>;
|
||||
type2pfx({account_pubkey,3}) -> <<"a3">>;
|
||||
type2pfx({account_pubkey,4}) -> <<"a4">>;
|
||||
type2pfx({account_pubkey,5}) -> <<"a5">>;
|
||||
type2pfx({account_pubkey,6}) -> <<"a6">>;
|
||||
type2pfx(account_pubkey) -> <<"ak">>;
|
||||
type2pfx(account_seckey) -> <<"sk">>;
|
||||
type2pfx(associate_chain) -> <<"ac">>;
|
||||
@@ -329,6 +341,13 @@ pfx2type(<<"ct">>) -> contract_pubkey;
|
||||
pfx2type(<<"cx">>) -> contract_source;
|
||||
pfx2type(<<"tx">>) -> transaction;
|
||||
pfx2type(<<"th">>) -> tx_hash;
|
||||
pfx2type(<<"a0">>) -> {account_pubkey, 0};
|
||||
pfx2type(<<"a1">>) -> {account_pubkey, 1};
|
||||
pfx2type(<<"a2">>) -> {account_pubkey, 2};
|
||||
pfx2type(<<"a3">>) -> {account_pubkey, 3};
|
||||
pfx2type(<<"a4">>) -> {account_pubkey, 4};
|
||||
pfx2type(<<"a5">>) -> {account_pubkey, 5};
|
||||
pfx2type(<<"a6">>) -> {account_pubkey, 6};
|
||||
pfx2type(<<"ak">>) -> account_pubkey;
|
||||
pfx2type(<<"sk">>) -> account_seckey;
|
||||
pfx2type(<<"ac">>) -> associate_chain;
|
||||
@@ -363,6 +382,7 @@ byte_size_for_type(contract_source) -> not_applicable;
|
||||
byte_size_for_type(transaction) -> not_applicable;
|
||||
byte_size_for_type(tx_hash) -> 32;
|
||||
byte_size_for_type(account_pubkey) -> 32;
|
||||
byte_size_for_type({account_pubkey, _}) -> 32;
|
||||
byte_size_for_type(account_seckey) -> 32;
|
||||
byte_size_for_type(associate_chain) -> 32;
|
||||
byte_size_for_type(signature) -> 64;
|
||||
|
||||
Reference in New Issue
Block a user