Skip to content

Commit

Permalink
add case and snapshot for PubKey
Browse files Browse the repository at this point in the history
  • Loading branch information
hoangdv2429 committed Jun 26, 2023
1 parent dd39028 commit 246fd87
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,15 @@ exports[`createCreateProtoType MsgJoinPool 1`] = `
}"
`;

exports[`createCreateProtoType ValidatorUpdate 1`] = `
"function createBaseValidatorUpdate(): ValidatorUpdate {
return {
pubKey: PublicKey.fromPartial({}),
power: Long.ZERO
};
}"
`;

exports[`oneofs Value 1`] = `
"/**
* \`Value\` represents a dynamically typed value which can be either
Expand Down
14 changes: 14 additions & 0 deletions packages/ast/src/encoding/proto/proto.type.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { createProtoType, createCreateProtoType } from './interface';
import authz from '../../../../../__fixtures__/proto-json/cosmos/authz/v1beta1/authz.json';
import gamm from '../../../../../__fixtures__/proto-json/osmosis/gamm/v1beta1/tx.json';
import types from '../../../../../__fixtures__/proto-json/tendermint/abci/types.json';

import { traverse, getNestedProto } from '@osmonauts/proto-parser'
import { defaultTelescopeOptions } from '@osmonauts/types'
Expand Down Expand Up @@ -58,6 +59,19 @@ describe('createCreateProtoType', () => {
));
});
});
//create type for pubKey
describe('createCreateProtoType', () => {
const ref = store.findProto('tendermint/abci/types.proto');
const context = new ProtoParseContext(ref, store, defaultTelescopeOptions);

it('ValidatorUpdate', () => {
expectCode(createCreateProtoType(
context,
'ValidatorUpdate',
getNestedProto(types).ValidatorUpdate
));
});
});

describe('traversed', () => {
it('osmosis/claim/v1beta1/params', async () => {
Expand Down
8 changes: 8 additions & 0 deletions packages/ast/src/encoding/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -461,6 +461,14 @@ export const getDefaultTSTypeFromProtoType = (
return t.arrayExpression([]);
case 'cosmos.base.v1beta1.Coin':
return t.identifier('undefined');
case 'tendermint.crypto.PublicKey':
return t.callExpression(
t.memberExpression(
t.identifier('PublicKey'),
t.identifier('fromPartial')
),
[t.objectExpression([])]
)

default:
// console.warn('getDefaultTSTypeFromProtoType() type not found: ' + type);
Expand Down

0 comments on commit 246fd87

Please sign in to comment.