Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Preview nullish coalescing operator PR #11

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
132 changes: 24 additions & 108 deletions src/confio/proofs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -428,22 +428,14 @@ export const ExistenceProof = {

fromPartial(object: DeepPartial<ExistenceProof>): ExistenceProof {
const message = { ...baseExistenceProof } as ExistenceProof;
message.path = [];
if (object.key !== undefined && object.key !== null) {
message.key = object.key;
} else {
message.key = new Uint8Array();
}
if (object.value !== undefined && object.value !== null) {
message.value = object.value;
} else {
message.value = new Uint8Array();
}
message.key = object.key ?? new Uint8Array();
message.value = object.value ?? new Uint8Array();
if (object.leaf !== undefined && object.leaf !== null) {
message.leaf = LeafOp.fromPartial(object.leaf);
} else {
message.leaf = undefined;
}
message.path = [];
if (object.path !== undefined && object.path !== null) {
for (const e of object.path) {
message.path.push(InnerOp.fromPartial(e));
Expand Down Expand Up @@ -525,11 +517,7 @@ export const NonExistenceProof = {

fromPartial(object: DeepPartial<NonExistenceProof>): NonExistenceProof {
const message = { ...baseNonExistenceProof } as NonExistenceProof;
if (object.key !== undefined && object.key !== null) {
message.key = object.key;
} else {
message.key = new Uint8Array();
}
message.key = object.key ?? new Uint8Array();
if (object.left !== undefined && object.left !== null) {
message.left = ExistenceProof.fromPartial(object.left);
} else {
Expand Down Expand Up @@ -748,31 +736,11 @@ export const LeafOp = {

fromPartial(object: DeepPartial<LeafOp>): LeafOp {
const message = { ...baseLeafOp } as LeafOp;
if (object.hash !== undefined && object.hash !== null) {
message.hash = object.hash;
} else {
message.hash = 0;
}
if (object.prehashKey !== undefined && object.prehashKey !== null) {
message.prehashKey = object.prehashKey;
} else {
message.prehashKey = 0;
}
if (object.prehashValue !== undefined && object.prehashValue !== null) {
message.prehashValue = object.prehashValue;
} else {
message.prehashValue = 0;
}
if (object.length !== undefined && object.length !== null) {
message.length = object.length;
} else {
message.length = 0;
}
if (object.prefix !== undefined && object.prefix !== null) {
message.prefix = object.prefix;
} else {
message.prefix = new Uint8Array();
}
message.hash = object.hash ?? 0;
message.prehashKey = object.prehashKey ?? 0;
message.prehashValue = object.prehashValue ?? 0;
message.length = object.length ?? 0;
message.prefix = object.prefix ?? new Uint8Array();
return message;
},
};
Expand Down Expand Up @@ -849,21 +817,9 @@ export const InnerOp = {

fromPartial(object: DeepPartial<InnerOp>): InnerOp {
const message = { ...baseInnerOp } as InnerOp;
if (object.hash !== undefined && object.hash !== null) {
message.hash = object.hash;
} else {
message.hash = 0;
}
if (object.prefix !== undefined && object.prefix !== null) {
message.prefix = object.prefix;
} else {
message.prefix = new Uint8Array();
}
if (object.suffix !== undefined && object.suffix !== null) {
message.suffix = object.suffix;
} else {
message.suffix = new Uint8Array();
}
message.hash = object.hash ?? 0;
message.prefix = object.prefix ?? new Uint8Array();
message.suffix = object.suffix ?? new Uint8Array();
return message;
},
};
Expand Down Expand Up @@ -962,16 +918,8 @@ export const ProofSpec = {
} else {
message.innerSpec = undefined;
}
if (object.maxDepth !== undefined && object.maxDepth !== null) {
message.maxDepth = object.maxDepth;
} else {
message.maxDepth = 0;
}
if (object.minDepth !== undefined && object.minDepth !== null) {
message.minDepth = object.minDepth;
} else {
message.minDepth = 0;
}
message.maxDepth = object.maxDepth ?? 0;
message.minDepth = object.minDepth ?? 0;
return message;
},
};
Expand Down Expand Up @@ -1112,31 +1060,11 @@ export const InnerSpec = {
message.childOrder.push(e);
}
}
if (object.childSize !== undefined && object.childSize !== null) {
message.childSize = object.childSize;
} else {
message.childSize = 0;
}
if (object.minPrefixLength !== undefined && object.minPrefixLength !== null) {
message.minPrefixLength = object.minPrefixLength;
} else {
message.minPrefixLength = 0;
}
if (object.maxPrefixLength !== undefined && object.maxPrefixLength !== null) {
message.maxPrefixLength = object.maxPrefixLength;
} else {
message.maxPrefixLength = 0;
}
if (object.emptyChild !== undefined && object.emptyChild !== null) {
message.emptyChild = object.emptyChild;
} else {
message.emptyChild = new Uint8Array();
}
if (object.hash !== undefined && object.hash !== null) {
message.hash = object.hash;
} else {
message.hash = 0;
}
message.childSize = object.childSize ?? 0;
message.minPrefixLength = object.minPrefixLength ?? 0;
message.maxPrefixLength = object.maxPrefixLength ?? 0;
message.emptyChild = object.emptyChild ?? new Uint8Array();
message.hash = object.hash ?? 0;
return message;
},
};
Expand Down Expand Up @@ -1348,12 +1276,12 @@ export const CompressedBatchProof = {
fromPartial(object: DeepPartial<CompressedBatchProof>): CompressedBatchProof {
const message = { ...baseCompressedBatchProof } as CompressedBatchProof;
message.entries = [];
message.lookupInners = [];
if (object.entries !== undefined && object.entries !== null) {
for (const e of object.entries) {
message.entries.push(CompressedBatchEntry.fromPartial(e));
}
}
message.lookupInners = [];
if (object.lookupInners !== undefined && object.lookupInners !== null) {
for (const e of object.lookupInners) {
message.lookupInners.push(InnerOp.fromPartial(e));
Expand Down Expand Up @@ -1536,22 +1464,14 @@ export const CompressedExistenceProof = {

fromPartial(object: DeepPartial<CompressedExistenceProof>): CompressedExistenceProof {
const message = { ...baseCompressedExistenceProof } as CompressedExistenceProof;
message.path = [];
if (object.key !== undefined && object.key !== null) {
message.key = object.key;
} else {
message.key = new Uint8Array();
}
if (object.value !== undefined && object.value !== null) {
message.value = object.value;
} else {
message.value = new Uint8Array();
}
message.key = object.key ?? new Uint8Array();
message.value = object.value ?? new Uint8Array();
if (object.leaf !== undefined && object.leaf !== null) {
message.leaf = LeafOp.fromPartial(object.leaf);
} else {
message.leaf = undefined;
}
message.path = [];
if (object.path !== undefined && object.path !== null) {
for (const e of object.path) {
message.path.push(e);
Expand Down Expand Up @@ -1634,11 +1554,7 @@ export const CompressedNonExistenceProof = {

fromPartial(object: DeepPartial<CompressedNonExistenceProof>): CompressedNonExistenceProof {
const message = { ...baseCompressedNonExistenceProof } as CompressedNonExistenceProof;
if (object.key !== undefined && object.key !== null) {
message.key = object.key;
} else {
message.key = new Uint8Array();
}
message.key = object.key ?? new Uint8Array();
if (object.left !== undefined && object.left !== null) {
message.left = CompressedExistenceProof.fromPartial(object.left);
} else {
Expand Down
14 changes: 3 additions & 11 deletions src/cosmos/auth/v1beta1/auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -116,11 +116,7 @@ export const BaseAccount = {

fromPartial(object: DeepPartial<BaseAccount>): BaseAccount {
const message = { ...baseBaseAccount } as BaseAccount;
if (object.address !== undefined && object.address !== null) {
message.address = object.address;
} else {
message.address = "";
}
message.address = object.address ?? "";
if (object.pubKey !== undefined && object.pubKey !== null) {
message.pubKey = Any.fromPartial(object.pubKey);
} else {
Expand Down Expand Up @@ -217,17 +213,13 @@ export const ModuleAccount = {

fromPartial(object: DeepPartial<ModuleAccount>): ModuleAccount {
const message = { ...baseModuleAccount } as ModuleAccount;
message.permissions = [];
if (object.baseAccount !== undefined && object.baseAccount !== null) {
message.baseAccount = BaseAccount.fromPartial(object.baseAccount);
} else {
message.baseAccount = undefined;
}
if (object.name !== undefined && object.name !== null) {
message.name = object.name;
} else {
message.name = "";
}
message.name = object.name ?? "";
message.permissions = [];
if (object.permissions !== undefined && object.permissions !== null) {
for (const e of object.permissions) {
message.permissions.push(e);
Expand Down
2 changes: 1 addition & 1 deletion src/cosmos/auth/v1beta1/genesis.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,12 +78,12 @@ export const GenesisState = {

fromPartial(object: DeepPartial<GenesisState>): GenesisState {
const message = { ...baseGenesisState } as GenesisState;
message.accounts = [];
if (object.params !== undefined && object.params !== null) {
message.params = Params.fromPartial(object.params);
} else {
message.params = undefined;
}
message.accounts = [];
if (object.accounts !== undefined && object.accounts !== null) {
for (const e of object.accounts) {
message.accounts.push(Any.fromPartial(e));
Expand Down
6 changes: 1 addition & 5 deletions src/cosmos/auth/v1beta1/query.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,11 +73,7 @@ export const QueryAccountRequest = {

fromPartial(object: DeepPartial<QueryAccountRequest>): QueryAccountRequest {
const message = { ...baseQueryAccountRequest } as QueryAccountRequest;
if (object.address !== undefined && object.address !== null) {
message.address = object.address;
} else {
message.address = "";
}
message.address = object.address ?? "";
return message;
},
};
Expand Down
60 changes: 10 additions & 50 deletions src/cosmos/bank/v1beta1/bank.ts
Original file line number Diff line number Diff line change
Expand Up @@ -146,11 +146,7 @@ export const Params = {
message.sendEnabled.push(SendEnabled.fromPartial(e));
}
}
if (object.defaultSendEnabled !== undefined && object.defaultSendEnabled !== null) {
message.defaultSendEnabled = object.defaultSendEnabled;
} else {
message.defaultSendEnabled = false;
}
message.defaultSendEnabled = object.defaultSendEnabled ?? false;
return message;
},
};
Expand Down Expand Up @@ -213,16 +209,8 @@ export const SendEnabled = {

fromPartial(object: DeepPartial<SendEnabled>): SendEnabled {
const message = { ...baseSendEnabled } as SendEnabled;
if (object.denom !== undefined && object.denom !== null) {
message.denom = object.denom;
} else {
message.denom = "";
}
if (object.enabled !== undefined && object.enabled !== null) {
message.enabled = object.enabled;
} else {
message.enabled = false;
}
message.denom = object.denom ?? "";
message.enabled = object.enabled ?? false;
return message;
},
};
Expand Down Expand Up @@ -291,12 +279,8 @@ export const Input = {

fromPartial(object: DeepPartial<Input>): Input {
const message = { ...baseInput } as Input;
message.address = object.address ?? "";
message.coins = [];
if (object.address !== undefined && object.address !== null) {
message.address = object.address;
} else {
message.address = "";
}
if (object.coins !== undefined && object.coins !== null) {
for (const e of object.coins) {
message.coins.push(Coin.fromPartial(e));
Expand Down Expand Up @@ -370,12 +354,8 @@ export const Output = {

fromPartial(object: DeepPartial<Output>): Output {
const message = { ...baseOutput } as Output;
message.address = object.address ?? "";
message.coins = [];
if (object.address !== undefined && object.address !== null) {
message.address = object.address;
} else {
message.address = "";
}
if (object.coins !== undefined && object.coins !== null) {
for (const e of object.coins) {
message.coins.push(Coin.fromPartial(e));
Expand Down Expand Up @@ -523,17 +503,9 @@ export const DenomUnit = {

fromPartial(object: DeepPartial<DenomUnit>): DenomUnit {
const message = { ...baseDenomUnit } as DenomUnit;
message.denom = object.denom ?? "";
message.exponent = object.exponent ?? 0;
message.aliases = [];
if (object.denom !== undefined && object.denom !== null) {
message.denom = object.denom;
} else {
message.denom = "";
}
if (object.exponent !== undefined && object.exponent !== null) {
message.exponent = object.exponent;
} else {
message.exponent = 0;
}
if (object.aliases !== undefined && object.aliases !== null) {
for (const e of object.aliases) {
message.aliases.push(e);
Expand Down Expand Up @@ -631,27 +603,15 @@ export const Metadata = {

fromPartial(object: DeepPartial<Metadata>): Metadata {
const message = { ...baseMetadata } as Metadata;
message.description = object.description ?? "";
message.denomUnits = [];
if (object.description !== undefined && object.description !== null) {
message.description = object.description;
} else {
message.description = "";
}
if (object.denomUnits !== undefined && object.denomUnits !== null) {
for (const e of object.denomUnits) {
message.denomUnits.push(DenomUnit.fromPartial(e));
}
}
if (object.base !== undefined && object.base !== null) {
message.base = object.base;
} else {
message.base = "";
}
if (object.display !== undefined && object.display !== null) {
message.display = object.display;
} else {
message.display = "";
}
message.base = object.base ?? "";
message.display = object.display ?? "";
return message;
},
};
Expand Down
Loading