diff --git a/CHANGELOG.md b/CHANGELOG.md
index f48c60aef..9a67b1afa 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -39,6 +39,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Features
+- [#84](https://github.com/alleslabs/celatone-frontend/pull/84) Contract proposals table ui and wireup
- [#82](https://github.com/alleslabs/celatone-frontend/pull/82) Add all codes page
- [#83](https://github.com/alleslabs/celatone-frontend/pull/83) Add invalid code state
- [#73](https://github.com/alleslabs/celatone-frontend/pull/73) Wireup migration table
diff --git a/src/lib/data/queries.ts b/src/lib/data/queries.ts
index 7ccfda54f..d1e37ed61 100644
--- a/src/lib/data/queries.ts
+++ b/src/lib/data/queries.ts
@@ -184,6 +184,46 @@ export const getMigrationHistoriesCountByContractAddress = graphql(`
}
`);
+export const getRelatedProposalsByContractAddress = graphql(`
+ query getRelatedProposalsByContractAddress(
+ $contractAddress: String!
+ $offset: Int!
+ $pageSize: Int!
+ ) {
+ contract_proposals(
+ where: { contract: { address: { _eq: $contractAddress } } }
+ order_by: { proposal_id: desc }
+ offset: $offset
+ limit: $pageSize
+ ) {
+ proposal {
+ title
+ status
+ voting_end_time
+ deposit_end_time
+ type
+ account {
+ address
+ }
+ }
+ proposal_id
+ resolved_height
+ }
+ }
+`);
+
+export const getRelatedProposalsCountByContractAddress = graphql(`
+ query getRelatedProposalsCountByContractAddress($contractAddress: String!) {
+ contract_proposals_aggregate(
+ where: { contract: { address: { _eq: $contractAddress } } }
+ ) {
+ aggregate {
+ count
+ }
+ }
+ }
+`);
+
export const getContractListByCodeId = graphql(`
query getContractListByCodeId($codeId: Int!, $offset: Int!, $pageSize: Int!) {
contracts(
diff --git a/src/lib/gql/gql.ts b/src/lib/gql/gql.ts
index b6725c731..ce31f30e7 100644
--- a/src/lib/gql/gql.ts
+++ b/src/lib/gql/gql.ts
@@ -23,6 +23,10 @@ const documents = {
types.GetMigrationHistoriesByContractAddressDocument,
"\n query getMigrationHistoriesCountByContractAddress($contractAddress: String!) {\n contract_histories_aggregate(\n where: { contract: { address: { _eq: $contractAddress } } }\n ) {\n aggregate {\n count\n }\n }\n }\n":
types.GetMigrationHistoriesCountByContractAddressDocument,
+ "\n query getRelatedProposalsByContractAddress(\n $contractAddress: String!\n $offset: Int!\n $pageSize: Int!\n ) {\n contract_proposals(\n where: { contract: { address: { _eq: $contractAddress } } }\n order_by: { proposal_id: desc }\n offset: $offset\n limit: $pageSize\n ) {\n proposal {\n title\n status\n voting_end_time\n deposit_end_time\n type\n account {\n address\n }\n }\n proposal_id\n resolved_height\n }\n }\n":
+ types.GetRelatedProposalsByContractAddressDocument,
+ "\n query getRelatedProposalsCountByContractAddress($contractAddress: String!) {\n contract_proposals_aggregate(\n where: { contract: { address: { _eq: $contractAddress } } }\n ) {\n aggregate {\n count\n }\n }\n }\n":
+ types.GetRelatedProposalsCountByContractAddressDocument,
"\n query getContractListByCodeId($codeId: Int!, $offset: Int!, $pageSize: Int!) {\n contracts(\n where: { code_id: { _eq: $codeId } }\n order_by: { transaction: { block: { timestamp: desc } } }\n offset: $offset\n limit: $pageSize\n ) {\n address\n label\n transaction {\n block {\n timestamp\n }\n account {\n address\n }\n }\n }\n }\n":
types.GetContractListByCodeIdDocument,
"\n query getContractListCountByCodeId($codeId: Int!) {\n contracts_aggregate(where: { code_id: { _eq: $codeId } }) {\n aggregate {\n count\n }\n }\n }\n":
@@ -61,6 +65,12 @@ export function graphql(
export function graphql(
source: "\n query getMigrationHistoriesCountByContractAddress($contractAddress: String!) {\n contract_histories_aggregate(\n where: { contract: { address: { _eq: $contractAddress } } }\n ) {\n aggregate {\n count\n }\n }\n }\n"
): typeof documents["\n query getMigrationHistoriesCountByContractAddress($contractAddress: String!) {\n contract_histories_aggregate(\n where: { contract: { address: { _eq: $contractAddress } } }\n ) {\n aggregate {\n count\n }\n }\n }\n"];
+export function graphql(
+ source: "\n query getRelatedProposalsByContractAddress(\n $contractAddress: String!\n $offset: Int!\n $pageSize: Int!\n ) {\n contract_proposals(\n where: { contract: { address: { _eq: $contractAddress } } }\n order_by: { proposal_id: desc }\n offset: $offset\n limit: $pageSize\n ) {\n proposal {\n title\n status\n voting_end_time\n deposit_end_time\n type\n account {\n address\n }\n }\n proposal_id\n resolved_height\n }\n }\n"
+): typeof documents["\n query getRelatedProposalsByContractAddress(\n $contractAddress: String!\n $offset: Int!\n $pageSize: Int!\n ) {\n contract_proposals(\n where: { contract: { address: { _eq: $contractAddress } } }\n order_by: { proposal_id: desc }\n offset: $offset\n limit: $pageSize\n ) {\n proposal {\n title\n status\n voting_end_time\n deposit_end_time\n type\n account {\n address\n }\n }\n proposal_id\n resolved_height\n }\n }\n"];
+export function graphql(
+ source: "\n query getRelatedProposalsCountByContractAddress($contractAddress: String!) {\n contract_proposals_aggregate(\n where: { contract: { address: { _eq: $contractAddress } } }\n ) {\n aggregate {\n count\n }\n }\n }\n"
+): typeof documents["\n query getRelatedProposalsCountByContractAddress($contractAddress: String!) {\n contract_proposals_aggregate(\n where: { contract: { address: { _eq: $contractAddress } } }\n ) {\n aggregate {\n count\n }\n }\n }\n"];
export function graphql(
source: "\n query getContractListByCodeId($codeId: Int!, $offset: Int!, $pageSize: Int!) {\n contracts(\n where: { code_id: { _eq: $codeId } }\n order_by: { transaction: { block: { timestamp: desc } } }\n offset: $offset\n limit: $pageSize\n ) {\n address\n label\n transaction {\n block {\n timestamp\n }\n account {\n address\n }\n }\n }\n }\n"
): typeof documents["\n query getContractListByCodeId($codeId: Int!, $offset: Int!, $pageSize: Int!) {\n contracts(\n where: { code_id: { _eq: $codeId } }\n order_by: { transaction: { block: { timestamp: desc } } }\n offset: $offset\n limit: $pageSize\n ) {\n address\n label\n transaction {\n block {\n timestamp\n }\n account {\n address\n }\n }\n }\n }\n"];
diff --git a/src/lib/gql/graphql.ts b/src/lib/gql/graphql.ts
index 2d85c0d5d..f96d32909 100644
--- a/src/lib/gql/graphql.ts
+++ b/src/lib/gql/graphql.ts
@@ -6424,6 +6424,45 @@ export type GetMigrationHistoriesCountByContractAddressQuery = {
};
};
+export type GetRelatedProposalsByContractAddressQueryVariables = Exact<{
+ contractAddress: Scalars["String"];
+ offset: Scalars["Int"];
+ pageSize: Scalars["Int"];
+}>;
+
+export type GetRelatedProposalsByContractAddressQuery = {
+ __typename?: "query_root";
+ contract_proposals: Array<{
+ __typename?: "contract_proposals";
+ proposal_id: number;
+ resolved_height?: number | null;
+ proposal: {
+ __typename?: "proposals";
+ title: string;
+ status: any;
+ voting_end_time: any;
+ deposit_end_time: any;
+ type: string;
+ account?: { __typename?: "accounts"; address: string } | null;
+ };
+ }>;
+};
+
+export type GetRelatedProposalsCountByContractAddressQueryVariables = Exact<{
+ contractAddress: Scalars["String"];
+}>;
+
+export type GetRelatedProposalsCountByContractAddressQuery = {
+ __typename?: "query_root";
+ contract_proposals_aggregate: {
+ __typename?: "contract_proposals_aggregate";
+ aggregate?: {
+ __typename?: "contract_proposals_aggregate_fields";
+ count: number;
+ } | null;
+ };
+};
+
export type GetContractListByCodeIdQueryVariables = Exact<{
codeId: Scalars["Int"];
offset: Scalars["Int"];
@@ -7789,6 +7828,278 @@ export const GetMigrationHistoriesCountByContractAddressDocument = {
GetMigrationHistoriesCountByContractAddressQuery,
GetMigrationHistoriesCountByContractAddressQueryVariables
>;
+export const GetRelatedProposalsByContractAddressDocument = {
+ kind: "Document",
+ definitions: [
+ {
+ kind: "OperationDefinition",
+ operation: "query",
+ name: { kind: "Name", value: "getRelatedProposalsByContractAddress" },
+ variableDefinitions: [
+ {
+ kind: "VariableDefinition",
+ variable: {
+ kind: "Variable",
+ name: { kind: "Name", value: "contractAddress" },
+ },
+ type: {
+ kind: "NonNullType",
+ type: {
+ kind: "NamedType",
+ name: { kind: "Name", value: "String" },
+ },
+ },
+ },
+ {
+ kind: "VariableDefinition",
+ variable: {
+ kind: "Variable",
+ name: { kind: "Name", value: "offset" },
+ },
+ type: {
+ kind: "NonNullType",
+ type: { kind: "NamedType", name: { kind: "Name", value: "Int" } },
+ },
+ },
+ {
+ kind: "VariableDefinition",
+ variable: {
+ kind: "Variable",
+ name: { kind: "Name", value: "pageSize" },
+ },
+ type: {
+ kind: "NonNullType",
+ type: { kind: "NamedType", name: { kind: "Name", value: "Int" } },
+ },
+ },
+ ],
+ selectionSet: {
+ kind: "SelectionSet",
+ selections: [
+ {
+ kind: "Field",
+ name: { kind: "Name", value: "contract_proposals" },
+ arguments: [
+ {
+ kind: "Argument",
+ name: { kind: "Name", value: "where" },
+ value: {
+ kind: "ObjectValue",
+ fields: [
+ {
+ kind: "ObjectField",
+ name: { kind: "Name", value: "contract" },
+ value: {
+ kind: "ObjectValue",
+ fields: [
+ {
+ kind: "ObjectField",
+ name: { kind: "Name", value: "address" },
+ value: {
+ kind: "ObjectValue",
+ fields: [
+ {
+ kind: "ObjectField",
+ name: { kind: "Name", value: "_eq" },
+ value: {
+ kind: "Variable",
+ name: {
+ kind: "Name",
+ value: "contractAddress",
+ },
+ },
+ },
+ ],
+ },
+ },
+ ],
+ },
+ },
+ ],
+ },
+ },
+ {
+ kind: "Argument",
+ name: { kind: "Name", value: "order_by" },
+ value: {
+ kind: "ObjectValue",
+ fields: [
+ {
+ kind: "ObjectField",
+ name: { kind: "Name", value: "proposal_id" },
+ value: { kind: "EnumValue", value: "desc" },
+ },
+ ],
+ },
+ },
+ {
+ kind: "Argument",
+ name: { kind: "Name", value: "offset" },
+ value: {
+ kind: "Variable",
+ name: { kind: "Name", value: "offset" },
+ },
+ },
+ {
+ kind: "Argument",
+ name: { kind: "Name", value: "limit" },
+ value: {
+ kind: "Variable",
+ name: { kind: "Name", value: "pageSize" },
+ },
+ },
+ ],
+ selectionSet: {
+ kind: "SelectionSet",
+ selections: [
+ {
+ kind: "Field",
+ name: { kind: "Name", value: "proposal" },
+ selectionSet: {
+ kind: "SelectionSet",
+ selections: [
+ { kind: "Field", name: { kind: "Name", value: "title" } },
+ {
+ kind: "Field",
+ name: { kind: "Name", value: "status" },
+ },
+ {
+ kind: "Field",
+ name: { kind: "Name", value: "voting_end_time" },
+ },
+ {
+ kind: "Field",
+ name: { kind: "Name", value: "deposit_end_time" },
+ },
+ { kind: "Field", name: { kind: "Name", value: "type" } },
+ {
+ kind: "Field",
+ name: { kind: "Name", value: "account" },
+ selectionSet: {
+ kind: "SelectionSet",
+ selections: [
+ {
+ kind: "Field",
+ name: { kind: "Name", value: "address" },
+ },
+ ],
+ },
+ },
+ ],
+ },
+ },
+ { kind: "Field", name: { kind: "Name", value: "proposal_id" } },
+ {
+ kind: "Field",
+ name: { kind: "Name", value: "resolved_height" },
+ },
+ ],
+ },
+ },
+ ],
+ },
+ },
+ ],
+} as unknown as DocumentNode<
+ GetRelatedProposalsByContractAddressQuery,
+ GetRelatedProposalsByContractAddressQueryVariables
+>;
+export const GetRelatedProposalsCountByContractAddressDocument = {
+ kind: "Document",
+ definitions: [
+ {
+ kind: "OperationDefinition",
+ operation: "query",
+ name: {
+ kind: "Name",
+ value: "getRelatedProposalsCountByContractAddress",
+ },
+ variableDefinitions: [
+ {
+ kind: "VariableDefinition",
+ variable: {
+ kind: "Variable",
+ name: { kind: "Name", value: "contractAddress" },
+ },
+ type: {
+ kind: "NonNullType",
+ type: {
+ kind: "NamedType",
+ name: { kind: "Name", value: "String" },
+ },
+ },
+ },
+ ],
+ selectionSet: {
+ kind: "SelectionSet",
+ selections: [
+ {
+ kind: "Field",
+ name: { kind: "Name", value: "contract_proposals_aggregate" },
+ arguments: [
+ {
+ kind: "Argument",
+ name: { kind: "Name", value: "where" },
+ value: {
+ kind: "ObjectValue",
+ fields: [
+ {
+ kind: "ObjectField",
+ name: { kind: "Name", value: "contract" },
+ value: {
+ kind: "ObjectValue",
+ fields: [
+ {
+ kind: "ObjectField",
+ name: { kind: "Name", value: "address" },
+ value: {
+ kind: "ObjectValue",
+ fields: [
+ {
+ kind: "ObjectField",
+ name: { kind: "Name", value: "_eq" },
+ value: {
+ kind: "Variable",
+ name: {
+ kind: "Name",
+ value: "contractAddress",
+ },
+ },
+ },
+ ],
+ },
+ },
+ ],
+ },
+ },
+ ],
+ },
+ },
+ ],
+ selectionSet: {
+ kind: "SelectionSet",
+ selections: [
+ {
+ kind: "Field",
+ name: { kind: "Name", value: "aggregate" },
+ selectionSet: {
+ kind: "SelectionSet",
+ selections: [
+ { kind: "Field", name: { kind: "Name", value: "count" } },
+ ],
+ },
+ },
+ ],
+ },
+ },
+ ],
+ },
+ },
+ ],
+} as unknown as DocumentNode<
+ GetRelatedProposalsCountByContractAddressQuery,
+ GetRelatedProposalsCountByContractAddressQueryVariables
+>;
export const GetContractListByCodeIdDocument = {
kind: "Document",
definitions: [
diff --git a/src/lib/model/contract.ts b/src/lib/model/contract.ts
index 079384041..c3c6ec165 100644
--- a/src/lib/model/contract.ts
+++ b/src/lib/model/contract.ts
@@ -16,6 +16,7 @@ import {
useInstantiateDetailByContractQuery,
useInstantiatedListByUserQuery,
useMigrationHistoriesCountByContractAddress,
+ useRelatedProposalsCountByContractAddress,
} from "lib/services/contractService";
import type { CodeLocalInfo } from "lib/stores/code";
import type { ContractInfo, ContractListInfo } from "lib/stores/contract";
@@ -145,12 +146,16 @@ export const useContractDetailsTableCounts = (
useExecuteTxsCountByContractAddress(contractAddress);
const { data: migrationCount = 0, refetch: refetchMigration } =
useMigrationHistoriesCountByContractAddress(contractAddress);
+ const { data: relatedProposalsCount = 0, refetch: refetchRelatedProposals } =
+ useRelatedProposalsCountByContractAddress(contractAddress);
return {
tableCounts: {
executeCount,
migrationCount,
+ relatedProposalsCount,
},
refetchExecute,
refetchMigration,
+ refetchRelatedProposals,
};
};
diff --git a/src/lib/pages/contract-details/components/tables/execute/Execute.tsx b/src/lib/pages/contract-details/components/tables/execute/Execute.tsx
index 6562fd2c9..4fbb5688d 100644
--- a/src/lib/pages/contract-details/components/tables/execute/Execute.tsx
+++ b/src/lib/pages/contract-details/components/tables/execute/Execute.tsx
@@ -85,16 +85,18 @@ export const ExecuteTable = ({
templateColumnsStyle={templateColumnsStyle}
/>
))}
- {isGovernance ? "Through Proposal ID" : "Tx Hash"} {isGovernance ? `${prefix} Proposal ID` : `${prefix} Tx`}
({dateFromNow(history.timestamp)})
- -{isDepositPeriod ? "Voting not started" : formatUTC(votingEndTime)}
++ ( + {isDepositPeriod + ? `Deposit Period ends in ${dateFromNow(depositEndTime)}` + : dateFromNow(votingEndTime)} + ) +
+