From 204a2080aee25f539a60dcf185bf7dec22b33af7 Mon Sep 17 00:00:00 2001 From: Ryan Christoffersen <12519942+ryanchristo@users.noreply.github.com> Date: Thu, 13 Jul 2023 09:28:48 -0700 Subject: [PATCH] fix: minimal ts erros for group-ui imports (#79) * fix: minimal ts erros for group-ui imports * fix: minimal ts erros for group-ui imports * add note to readme --- README.md | 4 ++++ packages/api/src/codegen/cosmos/group/v1/types.ts | 14 ++++++++++---- .../src/codegen/cosmos/staking/v1beta1/staking.ts | 12 ++++++------ .../api/src/codegen/cosmos/staking/v1beta1/tx.ts | 12 ++++++------ packages/api/src/codegen/google/protobuf/any.ts | 2 +- .../api/src/codegen/google/protobuf/timestamp.ts | 4 ++-- 6 files changed, 29 insertions(+), 19 deletions(-) diff --git a/README.md b/README.md index 65d4cede..41df7a49 100644 --- a/README.md +++ b/README.md @@ -17,6 +17,10 @@ This API is still under heavy construction, be ready for unexpected breaking changes. +### v1.0.0-alpha4 + +The `v1.0.0-alpha4` release tag includes a manual override of some generated code in `src` in order to resolve a downstream issue within [regen-network/groups-ui](https://github.com/regen-network/groups-ui). For more information, see [#79](https://github.com/regen-network/regen-js/pull/79) and [regen-network/groups-ui#69](https://github.com/regen-network/groups-ui/pull/69). + ## Get Started ### Install and build diff --git a/packages/api/src/codegen/cosmos/group/v1/types.ts b/packages/api/src/codegen/cosmos/group/v1/types.ts index ea123217..d0a4fa94 100644 --- a/packages/api/src/codegen/cosmos/group/v1/types.ts +++ b/packages/api/src/codegen/cosmos/group/v1/types.ts @@ -1560,7 +1560,7 @@ export const GroupPolicyInfo = { message.version = (reader.uint64() as Long); break; case 6: - message.decisionPolicy = (DecisionPolicy_InterfaceDecoder(reader) as Any); + message.decisionPolicy = (DecisionPolicy_InterfaceDecoder(reader) as ThresholdDecisionPolicy & PercentageDecisionPolicy & Any); break; case 7: message.createdAt = Timestamp.decode(reader, reader.uint32()); @@ -1579,7 +1579,9 @@ export const GroupPolicyInfo = { admin: isSet(object.admin) ? String(object.admin) : "", metadata: isSet(object.metadata) ? String(object.metadata) : "", version: isSet(object.version) ? Long.fromValue(object.version) : Long.UZERO, - decisionPolicy: isSet(object.decisionPolicy) ? Any.fromJSON(object.decisionPolicy) : undefined, + decisionPolicy: isSet(object.decisionPolicy) + ? Any.fromJSON(object.decisionPolicy) as (ThresholdDecisionPolicy & PercentageDecisionPolicy & Any) + : undefined, createdAt: isSet(object.createdAt) ? fromJsonTimestamp(object.createdAt) : undefined }; }, @@ -1601,7 +1603,9 @@ export const GroupPolicyInfo = { message.admin = object.admin ?? ""; message.metadata = object.metadata ?? ""; message.version = object.version !== undefined && object.version !== null ? Long.fromValue(object.version) : Long.UZERO; - message.decisionPolicy = object.decisionPolicy !== undefined && object.decisionPolicy !== null ? Any.fromPartial(object.decisionPolicy) : undefined; + message.decisionPolicy = object.decisionPolicy !== undefined && object.decisionPolicy !== null + ? Any.fromPartial(object.decisionPolicy) as (ThresholdDecisionPolicy & PercentageDecisionPolicy & Any) + : undefined; message.createdAt = object.createdAt !== undefined && object.createdAt !== null ? Timestamp.fromPartial(object.createdAt) : undefined; return message; }, @@ -1612,7 +1616,9 @@ export const GroupPolicyInfo = { admin: object.admin, metadata: object.metadata, version: Long.fromString(object.version), - decisionPolicy: object?.decision_policy ? DecisionPolicy_FromAmino(object.decision_policy) : undefined, + decisionPolicy: object?.decision_policy + ? DecisionPolicy_FromAmino(object.decision_policy) as (ThresholdDecisionPolicy & PercentageDecisionPolicy & Any) + : undefined, createdAt: object?.created_at ? Timestamp.fromAmino(object.created_at) : undefined }; }, diff --git a/packages/api/src/codegen/cosmos/staking/v1beta1/staking.ts b/packages/api/src/codegen/cosmos/staking/v1beta1/staking.ts index 59cb2189..893f4bd0 100644 --- a/packages/api/src/codegen/cosmos/staking/v1beta1/staking.ts +++ b/packages/api/src/codegen/cosmos/staking/v1beta1/staking.ts @@ -1391,10 +1391,10 @@ export const Validator = { fromAmino(object: ValidatorAmino): Validator { return { operatorAddress: object.operator_address, - consensusPubkey: encodeBech32Pubkey({ - type: "tendermint/PubKeySecp256k1", - value: toBase64(object.consensus_pubkey.value) - }, "cosmos"), + consensusPubkey: { + typeUrl: "tendermint/PubKeySecp256k1", + value: object.consensus_pubkey?.value + }, jailed: object.jailed, status: isSet(object.status) ? bondStatusFromJSON(object.status) : 0, tokens: object.tokens, @@ -1411,7 +1411,7 @@ export const Validator = { obj.operator_address = message.operatorAddress; obj.consensus_pubkey = message.consensusPubkey ? { typeUrl: "/cosmos.crypto.secp256k1.PubKey", - value: fromBase64(decodeBech32Pubkey(message.consensusPubkey).value) + value: message.consensusPubkey.value } : undefined; obj.jailed = message.jailed; obj.status = message.status; @@ -2951,6 +2951,6 @@ export const Cosmos_cryptoPubKey_FromAmino = (content: AnyAmino) => { export const Cosmos_cryptoPubKey_ToAmino = (content: Any) => { return { typeUrl: "/cosmos.crypto.secp256k1.PubKey", - value: fromBase64(decodeBech32Pubkey(content).value) + value: content.value }; }; \ No newline at end of file diff --git a/packages/api/src/codegen/cosmos/staking/v1beta1/tx.ts b/packages/api/src/codegen/cosmos/staking/v1beta1/tx.ts index 3851e8e6..18aeb804 100644 --- a/packages/api/src/codegen/cosmos/staking/v1beta1/tx.ts +++ b/packages/api/src/codegen/cosmos/staking/v1beta1/tx.ts @@ -460,10 +460,10 @@ export const MsgCreateValidator = { minSelfDelegation: object.min_self_delegation, delegatorAddress: object.delegator_address, validatorAddress: object.validator_address, - pubkey: encodeBech32Pubkey({ - type: "tendermint/PubKeySecp256k1", - value: toBase64(object.pubkey.value) - }, "cosmos"), + pubkey: { + typeUrl: "tendermint/PubKeySecp256k1", + value: object.pubkey?.value, + }, value: object?.value ? Coin.fromAmino(object.value) : undefined }; }, @@ -476,7 +476,7 @@ export const MsgCreateValidator = { obj.validator_address = message.validatorAddress; obj.pubkey = message.pubkey ? { typeUrl: "/cosmos.crypto.secp256k1.PubKey", - value: fromBase64(decodeBech32Pubkey(message.pubkey).value) + value: message.pubkey.value } : undefined; obj.value = message.value ? Coin.toAmino(message.value) : undefined; return obj; @@ -1452,6 +1452,6 @@ export const Cosmos_cryptoPubKey_FromAmino = (content: AnyAmino) => { export const Cosmos_cryptoPubKey_ToAmino = (content: Any) => { return { typeUrl: "/cosmos.crypto.secp256k1.PubKey", - value: fromBase64(decodeBech32Pubkey(content).value) + value: content.value }; }; \ No newline at end of file diff --git a/packages/api/src/codegen/google/protobuf/any.ts b/packages/api/src/codegen/google/protobuf/any.ts index 1ca054ae..da1bf3c5 100644 --- a/packages/api/src/codegen/google/protobuf/any.ts +++ b/packages/api/src/codegen/google/protobuf/any.ts @@ -382,7 +382,7 @@ export const Any = { }, fromAmino(object: AnyAmino): Any { return { - typeUrl: object.type_url, + typeUrl: object.type, value: object.value }; }, diff --git a/packages/api/src/codegen/google/protobuf/timestamp.ts b/packages/api/src/codegen/google/protobuf/timestamp.ts index 9364146d..fd454b9e 100644 --- a/packages/api/src/codegen/google/protobuf/timestamp.ts +++ b/packages/api/src/codegen/google/protobuf/timestamp.ts @@ -336,8 +336,8 @@ export const Timestamp = { }, fromAmino(object: TimestampAmino): Timestamp { return { - seconds: Long.fromString(object.seconds), - nanos: object.nanos + seconds: Long.fromNumber(new Date(object).getSeconds()), + nanos: 0 }; }, toAmino(message: Timestamp): TimestampAmino {