File tree Expand file tree Collapse file tree 1 file changed +37
-0
lines changed Expand file tree Collapse file tree 1 file changed +37
-0
lines changed Original file line number Diff line number Diff line change @@ -51,6 +51,43 @@ import { AnyAmino } from '../src/codegen/google/protobuf/any';
5151 return this . toString ( ) ;
5252} ;
5353
54+ function encodeAmino (
55+ typeUrl : string ,
56+ pubkey : { key : Uint8Array } ,
57+ pubkeyType : string ,
58+ prefix : string
59+ ) : AnyAmino {
60+ const pubKeyString = toBase64 ( pubkey . key ) ;
61+
62+ const cryptoEncodedPubkey = encodeBech32Pubkey (
63+ {
64+ type : pubkeyType ,
65+ value : pubKeyString ,
66+ } ,
67+ prefix
68+ ) ;
69+
70+ return {
71+ type : typeUrl ,
72+ value : {
73+ key : new TextEncoder ( ) . encode ( cryptoEncodedPubkey ) ,
74+ } ,
75+ } ;
76+ }
77+
78+ function decodeAmino ( typeUrl : string , pubkey : { key : Uint8Array } ) {
79+ const cryptoEncodedKeyString = new TextDecoder ( ) . decode ( pubkey . key ) ;
80+
81+ const cryptoDecodedPubkey = decodeBech32Pubkey ( cryptoEncodedKeyString ) ;
82+
83+ return {
84+ typeUrl : typeUrl ,
85+ value : {
86+ key : new TextEncoder ( ) . encode ( cryptoDecodedPubkey . value ) ,
87+ } ,
88+ } ;
89+ }
90+
5491const library = {
5592 title : 'Telescope' ,
5693 text : 'telescope' ,
You can’t perform that action at this time.
0 commit comments