cosmjs icon indicating copy to clipboard operation
cosmjs copied to clipboard

how to decode uint8array from AuthExtension.auth.account

Open trikunai opened this issue 3 years ago • 1 comments

Hi,

I am looking to extract the vesting data from a given address. For that i came across with this way.


  const wallet = 'cosmos1fgzk5kruvxk7wceyjm2nqjk0jpt23lcp9flgqd';
  const queryClientAuth = QueryClient.withExtensions(client.queryClient.tmClient, setupAuthExtension);
  const authAccount = await queryClientAuth.auth.account(wallet);

it returns this:

{ typeUrl: "/cosmos.vesting.v1beta1.ContinuousVestingAccount", value: new Uint8Array([10, 154, 1, 10, 125, 10, 45, 99, 111, 115, 109, 111, 115, 49, 102, 103, 122, 107, 53, 107, 114, 117, 118, 120, 107, 55, 119, 99, 101, 121, 106, 109, 50, 110, 113, 106, 107, 48, 106, 112, 116, 50, 51, 108, 99, 112, 57, 102, 108, 103, 113, 100, 18, 70, 10, 31, 47, 99, 111, 115, 109, 111, 115, 46, 99, 114, 121, 112, 116, 111, 46, 115, 101, 99, 112, 50, 53, 54, 107, 49, 46, 80, 117, 98, 75, 101, 121, 18, 35, 10, 33, 2, 252, 53, 241, 15, 14, 20, 42, 134, 101, 39, 252, 208, 67, 149, 184, 59, 232, 48, 95, 138, 242, 243, 153, 11, 70, 97, 152, 206, 37, 184, 19, 164, 24, 235, 220, 26, 32, 34, 18, 19, 10, 5, 117, 97, 116, 111, 109, 18, 10, 51, 50, 54, 54, 54, 54, 54, 54, 54, 55, 40, 224, 205, 221, 153, 6, 16, 178, 142, 141, 138, 6]), }

i get the desired data but i am not able to extract the proper data from ".value" after a decode. I tried several options, like TextDecoder and many other conversions, without any luck...

the best simillar data after a decoide was something like:

"\n�\u0001\n}\n-cosmos1fgzk5kruvxk7wceyjm2nqjk0jpt23lcp9flgqd\u0012F\n\u001f/cosmos.crypto.secp256k1.PubKey\u0012#\n!\u0002�5�\u000f\u000e\u0014*�e'��C��;�0_���\u000bFa��%�\u0013�\u0018��\u001a \"\u0012\u0013\n\u0005uatom\u0012\n3266666667(��ݙ\u0006\u0010����\u0006"

could you help me? thanks

trikunai avatar Sep 29 '22 17:09 trikunai

Hi, has anybody encountered this problem? Any help would be appreciated

iicc1 avatar Nov 10 '22 13:11 iicc1