Skip to content

Commit

Permalink
fromJSON done
Browse files Browse the repository at this point in the history
  • Loading branch information
hoangdv2429 committed Jul 11, 2023
1 parent c176b0d commit 8f1aa65
Show file tree
Hide file tree
Showing 11 changed files with 729 additions and 701 deletions.
436 changes: 218 additions & 218 deletions packages/ast/src/encoding/__snapshots__/object.spec.ts.snap

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,10 @@ exports[`cosmos/authz/v1beta1/authz date 2`] = `
return message;
},
fromJSON(object: any): Grant {
return {
authorization: isSet(object.authorization) ? Any.fromJSON(object.authorization) : undefined,
expiration: isSet(object.expiration) ? new Date(object.expiration) : undefined
};
const obj = createBaseGrant();
if (isSet(object.authorization)) obj.authorization = Any.fromJSON(object.authorization);
if (isSet(object.expiration)) obj.expiration = new Date(object.expiration);
return obj;
},
toJSON(message: Grant): unknown {
const obj: any = {};
Expand All @@ -61,7 +61,7 @@ exports[`cosmos/authz/v1beta1/authz date 2`] = `
},
fromPartial(object: DeepPartial<Grant>): Grant {
const message = createBaseGrant();
message.authorization = object.authorization !== undefined && object.authorization !== null ? Any.fromPartial(object.authorization) : undefined;
message.authorization = object.authorization !== undefined && object.authorization !== null ? Any.fromPartial(object.authorization) : Any.fromPartial({});
message.expiration = object.expiration ?? undefined;
return message;
},
Expand Down Expand Up @@ -176,10 +176,10 @@ exports[`cosmos/authz/v1beta1/authz timestamp 2`] = `
return message;
},
fromJSON(object: any): Grant {
return {
authorization: isSet(object.authorization) ? Any.fromJSON(object.authorization) : undefined,
expiration: isSet(object.expiration) ? fromJsonTimestamp(object.expiration) : undefined
};
const obj = createBaseGrant();
if (isSet(object.authorization)) obj.authorization = Any.fromJSON(object.authorization);
if (isSet(object.expiration)) obj.expiration = fromJsonTimestamp(object.expiration);
return obj;
},
toJSON(message: Grant): unknown {
const obj: any = {};
Expand All @@ -189,8 +189,8 @@ exports[`cosmos/authz/v1beta1/authz timestamp 2`] = `
},
fromPartial(object: DeepPartial<Grant>): Grant {
const message = createBaseGrant();
message.authorization = object.authorization !== undefined && object.authorization !== null ? Any.fromPartial(object.authorization) : undefined;
message.expiration = object.expiration !== undefined && object.expiration !== null ? Timestamp.fromPartial(object.expiration) : undefined;
message.authorization = object.authorization !== undefined && object.authorization !== null ? Any.fromPartial(object.authorization) : Any.fromPartial({});
message.expiration = object.expiration !== undefined && object.expiration !== null ? Timestamp.fromPartial(object.expiration) : Timestamp.fromPartial({});
return message;
},
fromSDK(object: GrantSDKType): Grant {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,11 @@ exports[`osmosis/lockup/tx duration 2`] = `
return message;
},
fromJSON(object: any): MsgLockTokens {
return {
owner: isSet(object.owner) ? String(object.owner) : "",
duration: isSet(object.duration) ? Duration.fromJSON(object.duration) : undefined,
coins: Array.isArray(object?.coins) ? object.coins.map((e: any) => Coin.fromJSON(e)) : []
};
const obj = createBaseMsgLockTokens();
if (isSet(object.owner)) obj.owner = String(object.owner);
if (isSet(object.duration)) obj.duration = Duration.fromJSON(object.duration);
if (Array.isArray(object?.coins)) object.coins.map((e: any) => Coin.fromJSON(e));
return obj;
},
toJSON(message: MsgLockTokens): unknown {
const obj: any = {};
Expand All @@ -66,7 +66,7 @@ exports[`osmosis/lockup/tx duration 2`] = `
fromPartial(object: DeepPartial<MsgLockTokens>): MsgLockTokens {
const message = createBaseMsgLockTokens();
message.owner = object.owner ?? "";
message.duration = object.duration !== undefined && object.duration !== null ? Duration.fromPartial(object.duration) : undefined;
message.duration = object.duration !== undefined && object.duration !== null ? Duration.fromPartial(object.duration) : Duration.fromPartial({});
message.coins = object.coins?.map(e => Coin.fromPartial(e)) || [];
return message;
},
Expand Down Expand Up @@ -193,11 +193,11 @@ exports[`osmosis/lockup/tx string 2`] = `
return message;
},
fromJSON(object: any): MsgLockTokens {
return {
owner: isSet(object.owner) ? String(object.owner) : "",
duration: isSet(object.duration) ? String(object.duration) : undefined,
coins: Array.isArray(object?.coins) ? object.coins.map((e: any) => Coin.fromJSON(e)) : []
};
const obj = createBaseMsgLockTokens();
if (isSet(object.owner)) obj.owner = String(object.owner);
if (isSet(object.duration)) obj.duration = String(object.duration);
if (Array.isArray(object?.coins)) object.coins.map((e: any) => Coin.fromJSON(e));
return obj;
},
toJSON(message: MsgLockTokens): unknown {
const obj: any = {};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,19 +132,19 @@ exports[`ibc/lightclients/tendermint/v1/tendermint duration 2`] = `
return message;
},
fromJSON(object: any): ClientState {
return {
chainId: isSet(object.chainId) ? String(object.chainId) : "",
trustLevel: isSet(object.trustLevel) ? Fraction.fromJSON(object.trustLevel) : undefined,
trustingPeriod: isSet(object.trustingPeriod) ? Duration.fromJSON(object.trustingPeriod) : undefined,
unbondingPeriod: isSet(object.unbondingPeriod) ? Duration.fromJSON(object.unbondingPeriod) : undefined,
maxClockDrift: isSet(object.maxClockDrift) ? Duration.fromJSON(object.maxClockDrift) : undefined,
frozenHeight: isSet(object.frozenHeight) ? Height.fromJSON(object.frozenHeight) : undefined,
latestHeight: isSet(object.latestHeight) ? Height.fromJSON(object.latestHeight) : undefined,
proofSpecs: Array.isArray(object?.proofSpecs) ? object.proofSpecs.map((e: any) => ProofSpec.fromJSON(e)) : [],
upgradePath: Array.isArray(object?.upgradePath) ? object.upgradePath.map((e: any) => String(e)) : [],
allowUpdateAfterExpiry: isSet(object.allowUpdateAfterExpiry) ? Boolean(object.allowUpdateAfterExpiry) : false,
allowUpdateAfterMisbehaviour: isSet(object.allowUpdateAfterMisbehaviour) ? Boolean(object.allowUpdateAfterMisbehaviour) : false
};
const obj = createBaseClientState();
if (isSet(object.chainId)) obj.chainId = String(object.chainId);
if (isSet(object.trustLevel)) obj.trustLevel = Fraction.fromJSON(object.trustLevel);
if (isSet(object.trustingPeriod)) obj.trustingPeriod = Duration.fromJSON(object.trustingPeriod);
if (isSet(object.unbondingPeriod)) obj.unbondingPeriod = Duration.fromJSON(object.unbondingPeriod);
if (isSet(object.maxClockDrift)) obj.maxClockDrift = Duration.fromJSON(object.maxClockDrift);
if (isSet(object.frozenHeight)) obj.frozenHeight = Height.fromJSON(object.frozenHeight);
if (isSet(object.latestHeight)) obj.latestHeight = Height.fromJSON(object.latestHeight);
if (Array.isArray(object?.proofSpecs)) object.proofSpecs.map((e: any) => ProofSpec.fromJSON(e));
if (Array.isArray(object?.upgradePath)) object.upgradePath.map((e: any) => String(e));
if (isSet(object.allowUpdateAfterExpiry)) obj.allowUpdateAfterExpiry = Boolean(object.allowUpdateAfterExpiry);
if (isSet(object.allowUpdateAfterMisbehaviour)) obj.allowUpdateAfterMisbehaviour = Boolean(object.allowUpdateAfterMisbehaviour);
return obj;
},
toJSON(message: ClientState): unknown {
const obj: any = {};
Expand Down Expand Up @@ -172,12 +172,12 @@ exports[`ibc/lightclients/tendermint/v1/tendermint duration 2`] = `
fromPartial(object: DeepPartial<ClientState>): ClientState {
const message = createBaseClientState();
message.chainId = object.chainId ?? "";
message.trustLevel = object.trustLevel !== undefined && object.trustLevel !== null ? Fraction.fromPartial(object.trustLevel) : undefined;
message.trustingPeriod = object.trustingPeriod !== undefined && object.trustingPeriod !== null ? Duration.fromPartial(object.trustingPeriod) : undefined;
message.unbondingPeriod = object.unbondingPeriod !== undefined && object.unbondingPeriod !== null ? Duration.fromPartial(object.unbondingPeriod) : undefined;
message.maxClockDrift = object.maxClockDrift !== undefined && object.maxClockDrift !== null ? Duration.fromPartial(object.maxClockDrift) : undefined;
message.frozenHeight = object.frozenHeight !== undefined && object.frozenHeight !== null ? Height.fromPartial(object.frozenHeight) : undefined;
message.latestHeight = object.latestHeight !== undefined && object.latestHeight !== null ? Height.fromPartial(object.latestHeight) : undefined;
message.trustLevel = object.trustLevel !== undefined && object.trustLevel !== null ? Fraction.fromPartial(object.trustLevel) : Fraction.fromPartial({});
message.trustingPeriod = object.trustingPeriod !== undefined && object.trustingPeriod !== null ? Duration.fromPartial(object.trustingPeriod) : Duration.fromPartial({});
message.unbondingPeriod = object.unbondingPeriod !== undefined && object.unbondingPeriod !== null ? Duration.fromPartial(object.unbondingPeriod) : Duration.fromPartial({});
message.maxClockDrift = object.maxClockDrift !== undefined && object.maxClockDrift !== null ? Duration.fromPartial(object.maxClockDrift) : Duration.fromPartial({});
message.frozenHeight = object.frozenHeight !== undefined && object.frozenHeight !== null ? Height.fromPartial(object.frozenHeight) : Height.fromPartial({});
message.latestHeight = object.latestHeight !== undefined && object.latestHeight !== null ? Height.fromPartial(object.latestHeight) : Height.fromPartial({});
message.proofSpecs = object.proofSpecs?.map(e => ProofSpec.fromPartial(e)) || [];
message.upgradePath = object.upgradePath?.map(e => e) || [];
message.allowUpdateAfterExpiry = object.allowUpdateAfterExpiry ?? false;
Expand Down Expand Up @@ -531,19 +531,19 @@ exports[`ibc/lightclients/tendermint/v1/tendermint string 2`] = `
return message;
},
fromJSON(object: any): ClientState {
return {
chainId: isSet(object.chainId) ? String(object.chainId) : "",
trustLevel: isSet(object.trustLevel) ? Fraction.fromJSON(object.trustLevel) : undefined,
trustingPeriod: isSet(object.trustingPeriod) ? String(object.trustingPeriod) : undefined,
unbondingPeriod: isSet(object.unbondingPeriod) ? String(object.unbondingPeriod) : undefined,
maxClockDrift: isSet(object.maxClockDrift) ? String(object.maxClockDrift) : undefined,
frozenHeight: isSet(object.frozenHeight) ? Height.fromJSON(object.frozenHeight) : undefined,
latestHeight: isSet(object.latestHeight) ? Height.fromJSON(object.latestHeight) : undefined,
proofSpecs: Array.isArray(object?.proofSpecs) ? object.proofSpecs.map((e: any) => ProofSpec.fromJSON(e)) : [],
upgradePath: Array.isArray(object?.upgradePath) ? object.upgradePath.map((e: any) => String(e)) : [],
allowUpdateAfterExpiry: isSet(object.allowUpdateAfterExpiry) ? Boolean(object.allowUpdateAfterExpiry) : false,
allowUpdateAfterMisbehaviour: isSet(object.allowUpdateAfterMisbehaviour) ? Boolean(object.allowUpdateAfterMisbehaviour) : false
};
const obj = createBaseClientState();
if (isSet(object.chainId)) obj.chainId = String(object.chainId);
if (isSet(object.trustLevel)) obj.trustLevel = Fraction.fromJSON(object.trustLevel);
if (isSet(object.trustingPeriod)) obj.trustingPeriod = String(object.trustingPeriod);
if (isSet(object.unbondingPeriod)) obj.unbondingPeriod = String(object.unbondingPeriod);
if (isSet(object.maxClockDrift)) obj.maxClockDrift = String(object.maxClockDrift);
if (isSet(object.frozenHeight)) obj.frozenHeight = Height.fromJSON(object.frozenHeight);
if (isSet(object.latestHeight)) obj.latestHeight = Height.fromJSON(object.latestHeight);
if (Array.isArray(object?.proofSpecs)) object.proofSpecs.map((e: any) => ProofSpec.fromJSON(e));
if (Array.isArray(object?.upgradePath)) object.upgradePath.map((e: any) => String(e));
if (isSet(object.allowUpdateAfterExpiry)) obj.allowUpdateAfterExpiry = Boolean(object.allowUpdateAfterExpiry);
if (isSet(object.allowUpdateAfterMisbehaviour)) obj.allowUpdateAfterMisbehaviour = Boolean(object.allowUpdateAfterMisbehaviour);
return obj;
},
toJSON(message: ClientState): unknown {
const obj: any = {};
Expand Down Expand Up @@ -571,12 +571,12 @@ exports[`ibc/lightclients/tendermint/v1/tendermint string 2`] = `
fromPartial(object: DeepPartial<ClientState>): ClientState {
const message = createBaseClientState();
message.chainId = object.chainId ?? "";
message.trustLevel = object.trustLevel !== undefined && object.trustLevel !== null ? Fraction.fromPartial(object.trustLevel) : undefined;
message.trustLevel = object.trustLevel !== undefined && object.trustLevel !== null ? Fraction.fromPartial(object.trustLevel) : Fraction.fromPartial({});
message.trustingPeriod = object.trustingPeriod ?? undefined;
message.unbondingPeriod = object.unbondingPeriod ?? undefined;
message.maxClockDrift = object.maxClockDrift ?? undefined;
message.frozenHeight = object.frozenHeight !== undefined && object.frozenHeight !== null ? Height.fromPartial(object.frozenHeight) : undefined;
message.latestHeight = object.latestHeight !== undefined && object.latestHeight !== null ? Height.fromPartial(object.latestHeight) : undefined;
message.frozenHeight = object.frozenHeight !== undefined && object.frozenHeight !== null ? Height.fromPartial(object.frozenHeight) : Height.fromPartial({});
message.latestHeight = object.latestHeight !== undefined && object.latestHeight !== null ? Height.fromPartial(object.latestHeight) : Height.fromPartial({});
message.proofSpecs = object.proofSpecs?.map(e => ProofSpec.fromPartial(e)) || [];
message.upgradePath = object.upgradePath?.map(e => e) || [];
message.allowUpdateAfterExpiry = object.allowUpdateAfterExpiry ?? false;
Expand Down
Loading

0 comments on commit 8f1aa65

Please sign in to comment.