Skip to content

Commit

Permalink
add for Timestamp and Date, rm for duration, coin
Browse files Browse the repository at this point in the history
  • Loading branch information
hoangdv2429 committed Jul 13, 2023
1 parent bd2b530 commit 9b5cf97
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ export interface authz {
exports[`createCreateProtoType Grant 1`] = `
"function createBaseGrant(): Grant {
return {
authorization: undefined,
authorization: Any.fromPartial({}),
expiration: undefined
};
}"
Expand Down
28 changes: 19 additions & 9 deletions packages/ast/src/encoding/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -451,19 +451,29 @@ export const getDefaultTSTypeFromProtoType = (

// OTHER TYPES
case 'google.protobuf.Timestamp':
return t.identifier('undefined');
case 'google.protobuf.Duration':
return t.identifier('undefined');
case 'google.protobuf.Any':
return t.identifier('undefined');
if(context.pluginValue('prototypes.typingsFormat.timestamp') === 'timestamp') {
return t.callExpression(
t.memberExpression(
t.identifier('Timestamp'),
t.identifier('fromPartial')
),
[t.objectExpression([])]
)
}
if(context.pluginValue('prototypes.typingsFormat.timestamp') === 'date') {
return t.newExpression(
t.identifier('Date'),
[]
);
}
// TODO: add cases for this later on
// case 'google.protobuf.Duration':
// return t.identifier('undefined');


case 'cosmos.base.v1beta1.Coins':
return t.arrayExpression([]);
case 'cosmos.base.v1beta1.Coin':
return t.identifier('undefined');
default:
// console.warn('getDefaultTSTypeFromProtoType() type not found, it\'ll probably still work but need review: ' + field.type);
// return t.identifier('undefined');
if (!field.type) {
console.warn('Undefined! Can\'t get field of type:', field);
return t.identifier('undefined');
Expand Down

0 comments on commit 9b5cf97

Please sign in to comment.