Skip to content

Commit b981297

Browse files
committed
add validator test page to telescope
1 parent 2e3906b commit b981297

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed

examples/telescope/pages/validator-test.tsx

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff 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+
5491
const library = {
5592
title: 'Telescope',
5693
text: 'telescope',

0 commit comments

Comments
 (0)