Upgrade apollo libraries in Navigator (#8124)

changelog_begin
changelog_end
This commit is contained in:
Moritz Kiefer 2020-12-02 12:47:30 +01:00 committed by GitHub
parent 08dfb8a628
commit 9afce5b35a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
42 changed files with 972 additions and 1026 deletions

View File

@ -20,6 +20,7 @@
"lint": "tslint --project tslint.json"
},
"devDependencies": {
"@types/modernizr": "^3.5.3",
"@bazel/hide-bazel-files": "1.6.0",
"@types/async": "2.0.39",
"@types/babel-core": "^6.25.3",
@ -36,7 +37,7 @@
"@types/route-parser": "0.0.0",
"@types/styled-components": "^5.1.0",
"@types/uuidjs": "3.3.2",
"apollo": "^2.5.1",
"apollo": "^2.31.1",
"case-sensitive-paths-webpack-plugin": "2.2.0",
"css-loader": "3.2.0",
"favicons-webpack-plugin": "1.0.2",
@ -52,25 +53,25 @@
"tslint": "5.20.1",
"tslint-loader": "3.5.4",
"tslint-react": "4.1.0",
"typescript": "3.0.3",
"typescript": "4.1.2",
"url-loader": "2.2.0",
"webpack": "4.41.2",
"webpack-cli": "3.3.10",
"webpack-dev-server": "3.9.0"
},
"dependencies": {
"apollo-client": "~1.4.1",
"@apollo/client": "^3.2.9",
"babel-standalone": "^6.26.0",
"color": "1.0.3",
"deep-equal": "~1.0.1",
"enzyme": "^3.11.0",
"es6-promise": "^4.1.1",
"graphql": "^15.4.0",
"lodash": "^4.17.19",
"modernizr": "^3.6.0",
"modernizr": "^3.11.4",
"moment": "^2.23.0",
"normalize.css": "^7.0.0",
"react": "^16.13.1",
"react-apollo": "^1.4.15",
"react-autosuggest": "9.3.2",
"react-dom": "^16.13.1",
"react-is": "^16.13.1",
@ -82,12 +83,12 @@
"redux-thunk": "~2.2.0",
"route-parser": "0.0.5",
"styled-components": "^5.1.1",
"subscriptions-transport-ws": "^0.9.18",
"typescript-collections": "1.2.5",
"uuidjs": "3.5.3",
"whatwg-fetch": "^2.0.3"
},
"resolutions": {
"**/apollo-client": "~1.4.0",
"**/elliptic": "^6.5.3",
"**/resize-img": "^2.0.0",
"**/jpeg-js": "^0.4.1",

View File

@ -1,14 +1,15 @@
import * as OpaqueTypes from '@da/ui-core/lib/api/OpaqueTypes'
/* tslint:disable */
/* eslint-disable */
// @generated
// This file was automatically generated and should not be edited.
// ====================================================
// GraphQL query operation: ContractDetailsById
// ====================================================
export interface ContractDetailsById_node_Transaction {
__typename: "Transaction" | "Template" | "DamlLfDefDataType" | "CreatedEvent" | "ExercisedEvent" | "CreateCommand" | "ExerciseCommand";
export interface ContractDetailsById_node_CreateCommand {
__typename: "CreateCommand" | "CreatedEvent" | "DamlLfDefDataType" | "ExerciseCommand" | "ExercisedEvent" | "Template" | "Transaction";
}
export interface ContractDetailsById_node_Contract_archiveEvent {
@ -41,7 +42,7 @@ export interface ContractDetailsById_node_Contract {
template: ContractDetailsById_node_Contract_template;
}
export type ContractDetailsById_node = ContractDetailsById_node_Transaction | ContractDetailsById_node_Contract;
export type ContractDetailsById_node = ContractDetailsById_node_CreateCommand | ContractDetailsById_node_Contract;
export interface ContractDetailsById {
node: ContractDetailsById_node | null;
@ -53,6 +54,7 @@ export interface ContractDetailsByIdVariables {
/* tslint:disable */
/* eslint-disable */
// @generated
// This file was automatically generated and should not be edited.
// ====================================================
@ -71,6 +73,7 @@ export interface ContractExerciseVariables {
/* tslint:disable */
/* eslint-disable */
// @generated
// This file was automatically generated and should not be edited.
// ====================================================
@ -138,14 +141,15 @@ export interface ContractsQueryVariables {
/* tslint:disable */
/* eslint-disable */
// @generated
// This file was automatically generated and should not be edited.
// ====================================================
// GraphQL query operation: TemplateInstance
// ====================================================
export interface TemplateInstance_node_Transaction {
__typename: "Transaction" | "DamlLfDefDataType" | "Contract" | "CreatedEvent" | "ExercisedEvent" | "CreateCommand" | "ExerciseCommand";
export interface TemplateInstance_node_Contract {
__typename: "Contract" | "CreateCommand" | "CreatedEvent" | "DamlLfDefDataType" | "ExerciseCommand" | "ExercisedEvent" | "Transaction";
}
export interface TemplateInstance_node_Template {
@ -155,7 +159,7 @@ export interface TemplateInstance_node_Template {
topLevelDecl: string;
}
export type TemplateInstance_node = TemplateInstance_node_Transaction | TemplateInstance_node_Template;
export type TemplateInstance_node = TemplateInstance_node_Contract | TemplateInstance_node_Template;
export interface TemplateInstance {
node: TemplateInstance_node | null;
@ -167,6 +171,7 @@ export interface TemplateInstanceVariables {
/* tslint:disable */
/* eslint-disable */
// @generated
// This file was automatically generated and should not be edited.
// ====================================================
@ -184,14 +189,15 @@ export interface CreateContractVariables {
/* tslint:disable */
/* eslint-disable */
// @generated
// This file was automatically generated and should not be edited.
// ====================================================
// GraphQL query operation: ContractsByTemplateParamQuery
// ====================================================
export interface ContractsByTemplateParamQuery_node_Transaction {
__typename: "Transaction" | "DamlLfDefDataType" | "Contract" | "CreatedEvent" | "ExercisedEvent" | "CreateCommand" | "ExerciseCommand";
export interface ContractsByTemplateParamQuery_node_Contract {
__typename: "Contract" | "CreateCommand" | "CreatedEvent" | "DamlLfDefDataType" | "ExerciseCommand" | "ExercisedEvent" | "Transaction";
}
export interface ContractsByTemplateParamQuery_node_Template_parameterDef {
@ -205,7 +211,7 @@ export interface ContractsByTemplateParamQuery_node_Template {
parameterDef: ContractsByTemplateParamQuery_node_Template_parameterDef;
}
export type ContractsByTemplateParamQuery_node = ContractsByTemplateParamQuery_node_Transaction | ContractsByTemplateParamQuery_node_Template;
export type ContractsByTemplateParamQuery_node = ContractsByTemplateParamQuery_node_Contract | ContractsByTemplateParamQuery_node_Template;
export interface ContractsByTemplateParamQuery {
node: ContractsByTemplateParamQuery_node | null;
@ -217,14 +223,15 @@ export interface ContractsByTemplateParamQueryVariables {
/* tslint:disable */
/* eslint-disable */
// @generated
// This file was automatically generated and should not be edited.
// ====================================================
// GraphQL query operation: ContractsByTemplateQuery
// ====================================================
export interface ContractsByTemplateQuery_node_Transaction {
__typename: "Transaction" | "DamlLfDefDataType" | "Contract" | "CreatedEvent" | "ExercisedEvent" | "CreateCommand" | "ExerciseCommand";
export interface ContractsByTemplateQuery_node_Contract {
__typename: "Contract" | "CreateCommand" | "CreatedEvent" | "DamlLfDefDataType" | "ExerciseCommand" | "ExercisedEvent" | "Transaction";
}
export interface ContractsByTemplateQuery_node_Template_choices {
@ -286,7 +293,7 @@ export interface ContractsByTemplateQuery_node_Template {
contracts: ContractsByTemplateQuery_node_Template_contracts;
}
export type ContractsByTemplateQuery_node = ContractsByTemplateQuery_node_Transaction | ContractsByTemplateQuery_node_Template;
export type ContractsByTemplateQuery_node = ContractsByTemplateQuery_node_Contract | ContractsByTemplateQuery_node_Template;
export interface ContractsByTemplateQuery {
node: ContractsByTemplateQuery_node | null;
@ -303,6 +310,7 @@ export interface ContractsByTemplateQueryVariables {
/* tslint:disable */
/* eslint-disable */
// @generated
// This file was automatically generated and should not be edited.
// ====================================================
@ -345,233 +353,7 @@ export interface TemplatesQueryVariables {
/* tslint:disable */
/* eslint-disable */
// This file was automatically generated and should not be edited.
// ====================================================
// GraphQL mutation operation: advanceTime
// ====================================================
export interface advanceTime_advanceTime {
__typename: "LedgerTime";
id: string;
time: OpaqueTypes.Time;
type: TimeType;
}
export interface advanceTime {
advanceTime: advanceTime_advanceTime;
}
export interface advanceTimeVariables {
time: OpaqueTypes.Time;
}
/* tslint:disable */
/* eslint-disable */
// This file was automatically generated and should not be edited.
// ====================================================
// GraphQL query operation: ContractsByIdQuery
// ====================================================
export interface ContractsByIdQuery_nodes_Transaction {
__typename: "Transaction" | "Template" | "DamlLfDefDataType" | "CreatedEvent" | "ExercisedEvent" | "CreateCommand" | "ExerciseCommand";
id: string;
}
export interface ContractsByIdQuery_nodes_Contract_archiveEvent {
__typename: "ExercisedEvent";
id: string;
}
export interface ContractsByIdQuery_nodes_Contract {
__typename: "Contract";
id: string;
archiveEvent: ContractsByIdQuery_nodes_Contract_archiveEvent | null;
}
export type ContractsByIdQuery_nodes = ContractsByIdQuery_nodes_Transaction | ContractsByIdQuery_nodes_Contract;
export interface ContractsByIdQuery {
nodes: ContractsByIdQuery_nodes[];
}
export interface ContractsByIdQueryVariables {
contractIds: string[];
}
/* tslint:disable */
/* eslint-disable */
// This file was automatically generated and should not be edited.
// ====================================================
// GraphQL query operation: CommandResultsQuery
// ====================================================
export interface CommandResultsQuery_nodes_Transaction {
__typename: "Transaction" | "Template" | "DamlLfDefDataType" | "Contract" | "CreatedEvent" | "ExercisedEvent";
id: string;
}
export interface CommandResultsQuery_nodes_CreateCommand_status_CommandStatusWaiting {
__typename: "CommandStatusWaiting" | "CommandStatusSuccess" | "CommandStatusUnknown";
}
export interface CommandResultsQuery_nodes_CreateCommand_status_CommandStatusError {
__typename: "CommandStatusError";
code: string;
details: string;
}
export type CommandResultsQuery_nodes_CreateCommand_status = CommandResultsQuery_nodes_CreateCommand_status_CommandStatusWaiting | CommandResultsQuery_nodes_CreateCommand_status_CommandStatusError;
export interface CommandResultsQuery_nodes_CreateCommand {
__typename: "CreateCommand" | "ExerciseCommand";
id: string;
status: CommandResultsQuery_nodes_CreateCommand_status;
}
export type CommandResultsQuery_nodes = CommandResultsQuery_nodes_Transaction | CommandResultsQuery_nodes_CreateCommand;
export interface CommandResultsQuery {
nodes: CommandResultsQuery_nodes[];
}
export interface CommandResultsQueryVariables {
commandIds: string[];
}
/* tslint:disable */
/* eslint-disable */
// This file was automatically generated and should not be edited.
// ====================================================
// GraphQL query operation: ParameterFormContractIdQuery
// ====================================================
export interface ParameterFormContractIdQuery_contracts_edges_node_createEvent_transaction {
__typename: "Transaction";
effectiveAt: OpaqueTypes.Time;
}
export interface ParameterFormContractIdQuery_contracts_edges_node_createEvent {
__typename: "CreatedEvent";
id: string;
transaction: ParameterFormContractIdQuery_contracts_edges_node_createEvent_transaction;
}
export interface ParameterFormContractIdQuery_contracts_edges_node_archiveEvent_transaction {
__typename: "Transaction";
effectiveAt: OpaqueTypes.Time;
}
export interface ParameterFormContractIdQuery_contracts_edges_node_archiveEvent {
__typename: "ExercisedEvent";
transaction: ParameterFormContractIdQuery_contracts_edges_node_archiveEvent_transaction;
}
export interface ParameterFormContractIdQuery_contracts_edges_node_template {
__typename: "Template";
id: string;
}
export interface ParameterFormContractIdQuery_contracts_edges_node {
__typename: "Contract";
id: string;
createEvent: ParameterFormContractIdQuery_contracts_edges_node_createEvent;
archiveEvent: ParameterFormContractIdQuery_contracts_edges_node_archiveEvent | null;
template: ParameterFormContractIdQuery_contracts_edges_node_template;
}
export interface ParameterFormContractIdQuery_contracts_edges {
__typename: "ContractEdge";
node: ParameterFormContractIdQuery_contracts_edges_node;
}
export interface ParameterFormContractIdQuery_contracts {
__typename: "ContractPagination";
totalCount: number;
edges: ParameterFormContractIdQuery_contracts_edges[];
}
export interface ParameterFormContractIdQuery {
contracts: ParameterFormContractIdQuery_contracts;
}
export interface ParameterFormContractIdQueryVariables {
filter: string;
includeArchived: boolean;
count: number;
sort?: SortCriterion[] | null;
}
/* tslint:disable */
/* eslint-disable */
// This file was automatically generated and should not be edited.
// ====================================================
// GraphQL query operation: ParameterFormTypeQuery
// ====================================================
export interface ParameterFormTypeQuery_node_Transaction {
__typename: "Transaction" | "Template" | "Contract" | "CreatedEvent" | "ExercisedEvent" | "CreateCommand" | "ExerciseCommand";
}
export interface ParameterFormTypeQuery_node_DamlLfDefDataType {
__typename: "DamlLfDefDataType";
dataType: OpaqueTypes.DamlLfDataType;
typeVars: string[];
}
export type ParameterFormTypeQuery_node = ParameterFormTypeQuery_node_Transaction | ParameterFormTypeQuery_node_DamlLfDefDataType;
export interface ParameterFormTypeQuery {
node: ParameterFormTypeQuery_node | null;
}
export interface ParameterFormTypeQueryVariables {
id: string;
}
/* tslint:disable */
/* eslint-disable */
// This file was automatically generated and should not be edited.
// ====================================================
// GraphQL mutation operation: WithExerciseQuery
// ====================================================
export interface WithExerciseQuery {
exercise: OpaqueTypes.CommandId;
}
export interface WithExerciseQueryVariables {
contractId: string;
choiceId: string;
argument?: OpaqueTypes.DamlLfValue | null;
}
/* tslint:disable */
/* eslint-disable */
// This file was automatically generated and should not be edited.
// ====================================================
// GraphQL query operation: LedgerTimeQuery
// ====================================================
export interface LedgerTimeQuery_ledgerTime {
__typename: "LedgerTime";
id: string;
time: OpaqueTypes.Time;
type: TimeType;
}
export interface LedgerTimeQuery {
ledgerTime: LedgerTimeQuery_ledgerTime;
}
/* tslint:disable */
/* eslint-disable */
// @generated
// This file was automatically generated and should not be edited.
//==============================================================
@ -583,12 +365,6 @@ export enum Direction {
DESCENDING = "DESCENDING",
}
export enum TimeType {
simulated = "simulated",
static = "static",
wallclock = "wallclock",
}
export interface FilterCriterion {
field: string;
value: string;

View File

@ -4,9 +4,7 @@
import { defaultTheme, Dispatch, ThemeInterface, ThemeProvider } from '@da/ui-core';
import * as LedgerWatcher from '@da/ui-core/lib/ledger-watcher';
import * as Session from '@da/ui-core/lib/session';
import { ApolloAction } from 'apollo-client/actions';
import * as React from 'react';
import { ApolloClient } from 'react-apollo';
import { connect } from 'react-redux';
import { Action as ReduxAction } from 'redux';
import Frame from '../../components/Frame';
@ -18,7 +16,7 @@ import {
EvalConfigResult,
} from '../../config';
import * as Either from '../../config/either';
import logoUrl = require('../../images/logo-large.png');
import logoUrl from '../../images/logo-large.png';
import { Connect } from '../../types';
import * as ConfigSource from '../configsource';
import * as Page from '../page';
@ -29,7 +27,6 @@ export type Action
| { type: 'TO_WATCHER', action: LedgerWatcher.Action }
| { type: 'TO_CONFIG', action: ConfigSource.Action }
| { type: 'RESET_APP' }
| ApolloAction
export const toPage = (action: Page.Action): Action =>
({ type: 'TO_PAGE', action });
@ -49,23 +46,17 @@ export const resetApp = (): Action =>
export const initSession = () => Session.init(toSession);
export const initConfig = () => ConfigSource.reload(toConfig);
export type ApolloState = {};
export type ApolloReducer = (state?: ApolloState, action?: ReduxAction) => {};
export interface State {
apollo: ApolloState;
session: Session.State;
page: Page.State;
watcher: LedgerWatcher.State;
configSource: ConfigSource.State;
}
export function makeReducer(client: ApolloClient) {
const apollo = client.reducer() as ApolloReducer;
export function makeReducer() {
return function reduce(state?: State, anyAction?: ReduxAction): State {
if (state === undefined || anyAction === undefined) {
return {
apollo: apollo(state, anyAction),
session: Session.reduce(),
page: Page.reduce(),
watcher: LedgerWatcher.reduce(),
@ -106,7 +97,7 @@ export function makeReducer(client: ApolloClient) {
configSource: ConfigSource.reduce(state.configSource, action.action),
};
default:
return { ...state, apollo: apollo(state.apollo, action) };
return state;
}
}
}

View File

@ -52,8 +52,10 @@ interface ActiveLinkProps extends OwnProps {
isActive: boolean;
}
const ActiveLink = (props: ActiveLinkProps) => (
<Link {...props} />
const ActiveLink: React.FC<ActiveLinkProps> = (props) => (
<Link {...props}>
{props.children}
</Link>
);
const ChoiceLink = styled(ActiveLink)`
@ -173,4 +175,4 @@ export default (props: Props) => {
</Content>
</Wrapper>
);
}
};

View File

@ -1,6 +1,8 @@
// Copyright (c) 2020 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved.
// SPDX-License-Identifier: Apache-2.0
import { ApolloClient } from '@apollo/client';
import { withApollo } from '@apollo/client/react/hoc';
import {
ParameterForm,
Strong,
@ -12,7 +14,6 @@ import {
default as ParameterDataProvider,
} from '@da/ui-core/lib/ParameterForm/ApolloDataProvider';
import * as React from 'react';
import { ApolloClient, withApollo } from 'react-apollo';
import { SubHeader } from './ContractComponent';
interface Props {
@ -22,7 +23,8 @@ interface Props {
error?: string;
onSubmit(e: React.MouseEvent<HTMLButtonElement>, argument?: DamlLfValue): void;
className?: string;
client: ApolloClient;
// tslint:disable-next-line:no-any
client: ApolloClient<any>;
}
interface Local {
@ -66,4 +68,4 @@ class Component extends React.Component<Props, Local> {
}
}
export default withApollo(Component);
export default withApollo<Omit<Props, 'client'>>(Component);

View File

@ -1,11 +1,12 @@
// Copyright (c) 2020 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved.
// SPDX-License-Identifier: Apache-2.0
import { gql } from '@apollo/client';
import { withMutation, withQuery } from '@apollo/client/react/hoc';
import { Dispatch } from '@da/ui-core';
import { DamlLfValue } from '@da/ui-core/lib/api/DamlLfValue';
import * as LedgerWatcher from '@da/ui-core/lib/ledger-watcher';
import * as React from 'react';
import { gql, graphql } from 'react-apollo';
import { connect } from 'react-redux';
import { compose } from 'redux';
import {
@ -186,20 +187,26 @@ const mutation = gql`
// generally confusing to say the least, but works out with a bit of care and
// thinking about the ordering and what each connect function adds.
const withMutation: Connect<MutationProps, OwnProps> =
graphql<ContractExercise, OwnProps>(mutation, {
props: ({ mutate }) => ({
exercise: (contractId: string, choiceId: string, argument?: DamlLfValue) =>
(mutate && mutate({ variables: { contractId, choiceId, argument } })),
}),
});
const _withMutation: Connect<MutationProps, OwnProps> =
withMutation<OwnProps, ContractExercise, {}, MutationProps>(mutation,
{
props: ({mutate}): MutationProps => ({
exercise: mutate && ((contractId: string, choiceId: String, argument?: DamlLfValue) =>
mutate({variables: { contractId, choiceId, argument}})
)}),
},
);
const withQuery: Connect<QueryProps, OwnProps & MutationProps> =
graphql<ContractDetailsById, OwnProps & MutationProps>(query, {
props: ({ data }) => ({
isLoading: data ? data.loading : false,
contract: data ? data.node : null,
}),
const _withQuery: Connect<QueryProps, OwnProps & MutationProps> =
withQuery<OwnProps, ContractDetailsById, ContractDetailsByIdVariables, QueryProps>(query, {
props: ({ data }) => {
const node = data?.node;
const contract = (node && node.__typename === 'Contract') ? node : null;
return {
isLoading: data ? data.loading : false,
contract,
}
},
options: ({ state: { id } }: OwnProps) => ({ variables: { id } as ContractDetailsByIdVariables}),
});
@ -207,7 +214,7 @@ const withRedux: Connect<ReduxProps, OwnProps & QueryProps & MutationProps> =
connect();
export const UI = compose(
withMutation,
withQuery,
_withMutation,
_withQuery,
withRedux,
)(Component);

View File

@ -1,11 +1,12 @@
// Copyright (c) 2020 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved.
// SPDX-License-Identifier: Apache-2.0
import { gql } from '@apollo/client';
import { QueryControls } from '@apollo/client/react/hoc';
import {
ContractTableConfig,
} from '@da/ui-core';
import { DocumentNode } from 'graphql';
import { gql, QueryProps } from 'react-apollo';
import {
ContractsQuery,
ContractsQuery_contracts_edges_node,
@ -62,7 +63,7 @@ export function makeQueryVariables(config: ContractTableConfig): ContractsQueryV
};
}
export function dataToRows(data: QueryProps & ContractsQuery) {
export function dataToRows(data: QueryControls & ContractsQuery) {
if (data.loading || data.error) {
return { contracts: [], totalCount: 0 }
} else {

View File

@ -1,9 +1,7 @@
// Copyright (c) 2020 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved.
// SPDX-License-Identifier: Apache-2.0
// Copyright (c) 2020, Digital Asset (Switzerland) GmbH and/or its affiliates.
// All rights reserved.
import { ApolloClient } from '@apollo/client';
import { withApollo } from '@apollo/client/react/hoc'
import {
ApolloDataProvider,
ContractColumn,
@ -13,7 +11,6 @@ import {
} from '@da/ui-core';
import { User } from '@da/ui-core/lib/session';
import * as React from 'react';
import { ApolloClient, withApollo } from 'react-apollo';
import { connect } from 'react-redux';
import { compose } from 'redux';
import { contract as contractRoute } from '../../routes';
@ -57,7 +54,8 @@ interface ReduxProps {
}
interface ApolloProps {
client: ApolloClient;
// tslint:disable-next-line:no-any
client: ApolloClient<any>;
}
interface OwnProps {
@ -116,6 +114,6 @@ class Component extends React.Component<Props, {}> {
const withRedux: Connect<ReduxProps, OwnProps & ApolloProps> = connect();
export const UI: React.ComponentClass<OwnProps> = compose(
withApollo,
(x) => withApollo<OwnProps>(x),
withRedux,
)(Component);

View File

@ -1,6 +1,8 @@
// Copyright (c) 2020 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved.
// SPDX-License-Identifier: Apache-2.0
import { ApolloClient } from '@apollo/client';
import { withApollo } from '@apollo/client/react/hoc';
import { ParameterForm, styled, Truncate } from '@da/ui-core';
import * as DamlLfValueF from '@da/ui-core/lib/api/DamlLfValue';
import { DamlLfValue } from '@da/ui-core/lib/api/DamlLfValue';
@ -8,7 +10,6 @@ import {
default as ParameterDataProvider,
} from '@da/ui-core/lib/ParameterForm/ApolloDataProvider';
import * as React from 'react';
import { ApolloClient, withApollo } from 'react-apollo';
import { Template } from '.'
const Wrapper = styled.div`
@ -38,18 +39,22 @@ interface Props {
isLoading: boolean;
onSubmit(e: React.MouseEvent<HTMLButtonElement>, argument?: DamlLfValue): void;
error?: string;
client: ApolloClient;
}
interface Local {
argument: DamlLfValue;
}
class Component extends React.Component<Props, Local> {
interface ApolloProps {
// tslint:disable-next-line: no-any
client: ApolloClient<any>
}
class Component extends React.Component<Props & ApolloProps, Local> {
private paramDataProvider: ParameterDataProvider;
constructor(props: Props) {
constructor(props: Props & ApolloProps) {
super(props);
this.paramDataProvider = new ParameterDataProvider(props.client);
this.state = {
@ -78,4 +83,4 @@ class Component extends React.Component<Props, Local> {
}
}
export default withApollo(Component);
export default withApollo<Props>(Component);

View File

@ -1,14 +1,16 @@
// Copyright (c) 2020 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved.
// SPDX-License-Identifier: Apache-2.0
import { FetchResult, gql } from '@apollo/client';
import { QueryControls, withMutation, withQuery } from '@apollo/client/react/hoc';
import { Dispatch } from '@da/ui-core';
import { DamlLfValue } from '@da/ui-core/lib/api/DamlLfValue';
import * as LedgerWatcher from '@da/ui-core/lib/ledger-watcher';
import * as React from 'react';
import { gql, graphql, OptionProps, QueryProps as RAQueryProps } from 'react-apollo';
import { connect } from 'react-redux';
import { compose } from 'redux';
import {
CreateContract,
CreateContractVariables,
TemplateInstance,
TemplateInstance_node_Template,
@ -60,11 +62,11 @@ type ReduxProps = {
interface MutationProps {
//tslint:disable-next-line:no-any
create(templateId: string, argument: DamlLfValue): Promise<any>;
create?(templateId: string, argument: DamlLfValue): Promise<FetchResult<CreateContract>>;
}
interface QueryProps {
data: RAQueryProps & TemplateInstance;
data: QueryControls & TemplateInstance;
}
type Props = OwnProps & ReduxProps & MutationProps & QueryProps;
@ -83,7 +85,7 @@ class Component extends React.Component<Props, {}> {
dispatch(toSelf(setLoading(true)));
create(id, argument)
.then(({ data }) => {
dispatch(toWatcher(LedgerWatcher.registerCommand(data.create)));
dispatch(toWatcher(LedgerWatcher.registerCommand(data!.create)));
dispatch(pathToAction(dashboardRoute.render({})));
}).catch((error: Error) => {
dispatch(toSelf(setLoading(false)));
@ -94,9 +96,12 @@ class Component extends React.Component<Props, {}> {
render() {
const { state, data } = this.props;
if (data.loading) { return <p>Loading</p>; }
else if (data.node === null) {
if (data.loading) {
return <p>Loading</p>;
} else if (data.node === null) {
return <p>Could not find template {state.id}</p>;
} else if (data.node.__typename !== 'Template') {
return <p>Expected Template node but got {data.node.__typename}</p>;
} else {
const template = data.node;
@ -137,25 +142,25 @@ const mutation = gql`
* - the contract data fetched from the GraphQL API
*/
const withMutation: Connect<MutationProps, OwnProps> =
graphql(mutation, {
props: ({ mutate }: OptionProps<OwnProps, QueryProps>) => ({
create: (templateId: string, argument: DamlLfValue) =>
(mutate && mutate({ variables: { templateId, argument } as CreateContractVariables })),
}),
const _withMutation: Connect<MutationProps, OwnProps> =
withMutation<OwnProps, CreateContract, CreateContractVariables, MutationProps>(mutation, {
props: ({ mutate }) => ({
create: mutate && ((templateId: string, argument: DamlLfValue) =>
mutate({ variables: { templateId, argument } })
)}),
});
const withQuery: Connect<QueryProps, OwnProps & MutationProps> =
graphql(query, {
options: ({ state: { id } }: OwnProps & MutationProps) =>
({ variables: { templateId: id } as TemplateInstanceVariables }),
const _withQuery: Connect<QueryProps, OwnProps & MutationProps> =
withQuery<OwnProps, TemplateInstance, TemplateInstanceVariables, QueryProps>(query, {
options: ({ state: { id } }) =>
({ variables: { templateId: id } }),
});
const withRedux: Connect<ReduxProps, OwnProps & QueryProps & MutationProps> =
connect();
export const UI = compose(
withMutation,
withQuery,
_withMutation,
_withQuery,
withRedux,
)(Component);

View File

@ -2,8 +2,9 @@
// SPDX-License-Identifier: Apache-2.0
import { gql } from '@apollo/client';
import { QueryControls } from '@apollo/client/react/hoc';
import { DocumentNode } from 'graphql';
import { gql, QueryProps } from 'react-apollo';
import { State, TableConfig } from '.';
import {
ContractsByTemplateParamQuery,
@ -95,7 +96,7 @@ export function makeParamQueryVariables<
};
}
export function dataToRows(data: QueryProps & ContractsByTemplateQuery) {
export function dataToRows(data: QueryControls & ContractsByTemplateQuery) {
if (data.loading || data.error) {
return { contracts: [], totalCount: 0 }
} else if (data.node && data.node.__typename === 'Template') {

View File

@ -1,22 +1,24 @@
// Copyright (c) 2020 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved.
// SPDX-License-Identifier: Apache-2.0
import { ApolloClient } from '@apollo/client';
import { withApollo, withQuery } from '@apollo/client/react/hoc';
import {
ApolloDataProvider,
ContractColumn,
ContractTable,
ContractTableConfig,
Dispatch,
WithGraphQL,
WithRedux,
} from '@da/ui-core';
import { User } from '@da/ui-core/lib/session';
import * as React from 'react';
import { ApolloClient, graphql, withApollo } from 'react-apollo';
import { connect } from 'react-redux';
import { compose } from 'redux';
import { ContractsByTemplateParamQuery, ContractsByTemplateParamQueryVariables } from 'src/api/Queries';
import { contract as contractRoute } from '../../routes';
import { pathToAction } from '../../routes';
import { Connect } from '../../types';
import * as App from '../app';
import makeColumns from './columns';
import {
@ -65,7 +67,8 @@ interface ReduxProps {
}
interface ApolloProps {
client: ApolloClient;
// tslint:disable-next-line: no-any
client: ApolloClient<any>;
}
interface GraphQLProps {
@ -129,12 +132,14 @@ class Component extends React.Component<Props, {}> {
}
}
const withRedux: WithRedux<Props> = connect();
const withGraphQL: WithGraphQL<Props>
= graphql(paramQuery, { options: (s) => makeParamQueryVariables(s) });
const withRedux: Connect<ReduxProps, ApolloProps & OwnProps> = connect();
const withGraphQL: Connect<GraphQLProps, ReduxProps & ApolloProps & OwnProps>
=
withQuery<Props, ContractsByTemplateParamQuery, ContractsByTemplateParamQueryVariables, GraphQLProps>(
paramQuery, { options: (s) => makeParamQueryVariables(s) });
export const UI: React.ComponentClass<OwnProps> = compose(
withApollo,
(x) => withApollo<OwnProps>(x),
withRedux,
withGraphQL,
)(Component);

View File

@ -1,12 +1,13 @@
// Copyright (c) 2020 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved.
// SPDX-License-Identifier: Apache-2.0
import { gql, QueryFunctionOptions } from '@apollo/client';
import { QueryControls } from '@apollo/client/react/hoc';
import {
DataTableConfig,
DataTableProps,
} from '@da/ui-core';
import { DocumentNode } from 'graphql';
import { gql, QueryOpts, QueryProps } from 'react-apollo';
import {
TemplatesQuery,
TemplatesQuery_templates_edges_node,
@ -46,7 +47,7 @@ export type TableConfig = DataTableConfig;
export type TableProps = DataTableProps<TableConfig, Template, RawData>
// Computing query variables from table config
export function makeQueryVariables({config}: TableProps): QueryOpts {
export function makeQueryVariables({config}: TableProps): QueryFunctionOptions {
return {
variables: {
search: config.search,
@ -59,7 +60,7 @@ export function makeQueryVariables({config}: TableProps): QueryOpts {
}
// Computing row data from raw data
export function dataToRows(data: QueryProps & TemplatesQuery) {
export function dataToRows(data: QueryControls & TemplatesQuery) {
if (data.loading || data.error) {
return { data: [], totalCount: 0 }
} else {

View File

@ -1,6 +1,8 @@
// Copyright (c) 2020 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved.
// SPDX-License-Identifier: Apache-2.0
import { ApolloClient } from '@apollo/client';
import { withApollo, withQuery } from '@apollo/client/react/hoc';
import {
DataColumnConfig,
DataTable,
@ -11,15 +13,11 @@ import {
} from '@da/ui-core';
import { User } from '@da/ui-core/lib/session';
import * as React from 'react';
import {
ApolloClient,
graphql,
withApollo,
} from 'react-apollo';
import { connect } from 'react-redux';
import { compose } from 'redux';
import { template as templateRoute } from '../../routes';
import { pathToAction } from '../../routes';
import { Connect } from '../../types';
import * as App from '../app';
import columns from './columns';
import {
@ -61,7 +59,7 @@ export const reduce = (state?: State, action?: Action): State => {
// GraphQL-enhanced data table
const withGraphql: WithGraphQL<TableProps>
= graphql(query, { options: makeQueryVariables });
= withQuery(query, { options: makeQueryVariables });
export const TemplateTable = withGraphql(DataTable);
interface ReduxProps {
@ -69,7 +67,8 @@ interface ReduxProps {
}
interface ApolloProps {
client: ApolloClient;
// tslint:disable-next-line: no-any
client: ApolloClient<any>;
}
interface OwnProps {
@ -122,8 +121,9 @@ class Component
}
const withRedux: WithRedux<Props & ApolloProps> = connect();
const _withApollo: Connect<ApolloProps, Omit<Props, keyof ApolloProps>> = (x) => withApollo<Props>(x);
export const UI: React.ComponentClass<OwnProps> = compose(
withApollo,
_withApollo,
withRedux,
)(Component);

View File

@ -8,7 +8,7 @@ import * as React from 'react';
import { connect } from 'react-redux';
import styled from 'styled-components';
import * as App from '../applets/app';
import logoUrl = require('../images/logo-large.png');
import logoUrl from '../images/logo-large.png';
import { about } from '../routes';
import { Icon } from './Icon';
import Link from './Link';

View File

@ -1,7 +1,6 @@
// Copyright (c) 2020 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved.
// SPDX-License-Identifier: Apache-2.0
import * as configAPISource from '!raw-loader!../config/api/v1';
import * as UICore from '@da/ui-core';
import * as Session from '@da/ui-core/lib/session';

View File

@ -7,51 +7,35 @@ import './polyfills';
// Load global styles
import './styles/base.css';
import { ApolloClient, ApolloProvider, createHttpLink, InMemoryCache } from '@apollo/client';
import * as Router from '@da/redux-router';
import { defaultTheme, ThemeProvider } from '@da/ui-core';
import * as introspectionQueryResultData from '@da/ui-core/lib/api/fragmentTypes.json';
import { IntrospectionResultData } from 'apollo-client/data/fragmentMatcher'
import possibleTypes from '@da/ui-core/lib/api/possibleTypes.json';
import * as React from 'react';
import {
ApolloClient,
ApolloProvider,
createNetworkInterface,
IntrospectionFragmentMatcher,
} from 'react-apollo';
import * as ReactDOM from 'react-dom';
import { Provider } from 'react-redux';
import { applyMiddleware, compose, createStore, Store } from 'redux';
import ReduxThunk from 'redux-thunk';
import * as App from './applets/app';
import { pathToAction, stateToPath } from './routes';
const networkInterface = createNetworkInterface({
const link = createHttpLink({
uri: '/api/graphql',
// Include credentials (cookies) with GraphQL queries
opts: { credentials: 'same-origin' },
credentials: 'same-origin',
});
export function dataIdFromObject(result: { id: string, __typename: string }) {
const dataIdFromObject = (result: { id: string, __typename: string }) => {
if (result.id && result.__typename) {
return `${result.__typename}:${result.id}`;
} else {
return undefined;
}
}
};
const client = new ApolloClient({
networkInterface,
dataIdFromObject,
// The default fragment matcher does not work with interfaces and unions.
// The apollo docs suggest using the introspection fragment matcher
// initialized with a schema dump:
// https://www.apollographql.com/docs/react/advanced/fragments.html#fragment-matcher
fragmentMatcher: new IntrospectionFragmentMatcher({
// TODO: The IntrospectionResultData type has a slightly wrong type definition inside apollo,
// work around this with an explicit type cast.
introspectionQueryResultData: introspectionQueryResultData as IntrospectionResultData,
}),
link,
cache: new InMemoryCache({dataIdFromObject, possibleTypes}),
});
// Set up a function to compose Redux enhancers such that Redux DevTools
@ -64,20 +48,22 @@ const composeEnhancers =
// Create Redux store
const store: Store<App.State> = createStore<App.State>(
App.makeReducer(client),
App.makeReducer(),
composeEnhancers(applyMiddleware(
client.middleware(),
Router.middleware({ stateToUrl: stateToPath, urlToAction: pathToAction }),
ReduxThunk,
)),
);
ReactDOM.render((
<ApolloProvider store={store} client={client}>
<ThemeProvider theme={defaultTheme}>
<App.UI />
</ThemeProvider>
</ApolloProvider>
<Provider store={store}>
<ApolloProvider client={client}>
<ThemeProvider theme={defaultTheme}>
<App.UI />
</ThemeProvider>
</ApolloProvider>
</Provider>
),
document.getElementById('app'),
);

View File

@ -1,9 +1,11 @@
// Copyright (c) 2020 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved.
// SPDX-License-Identifier: Apache-2.0
import * as Moment from 'moment';
import { gql } from '@apollo/client';
import { MutateProps, withMutation } from '@apollo/client/react/hoc';
import Moment from 'moment';
import * as React from 'react';
import { gql, graphql } from 'react-apollo';
import styled from 'styled-components';
import Button from '../Button';
import DateTimePicker from '../DateTimePicker';
@ -27,12 +29,7 @@ const InlineDiv = styled.div`
display: inline;
`;
interface GraphQLProps {
//tslint:disable-next-line:no-any
mutate: any;
}
type Props = GraphQLProps & InnerProps;
type Props = MutateProps & InnerProps;
interface State {
isOpen: boolean;
@ -102,7 +99,7 @@ export const defaultAdvanceTimeQuery = gql`
function makeAdvanceTime(
advanceTimeQuery: typeof defaultAdvanceTimeQuery,
) {
return graphql(advanceTimeQuery)(withLedgerTime(AdvanceTime));
return withMutation(advanceTimeQuery)(withLedgerTime(AdvanceTime));
}
/** An AdvanceTime component with default sandbox GraphQL queries */

View File

@ -2,7 +2,7 @@
// SPDX-License-Identifier: Apache-2.0
import * as React from 'react';
import * as Input from 'react-autosuggest';
import Input from 'react-autosuggest';
import { StyledTextInput } from '../Input';
import styled, { hardcodedStyle } from '../theme';
@ -91,7 +91,7 @@ export default class Autosuggest<R>
onSuggestionFetchRequested({ value }: { value: string }) {
clearTimeout(this.delayTimer);
this.delayTimer = setTimeout(() => {
this.delayTimer = window.setTimeout(() => {
this.props.onFetchSuggestions(value, (suggestions: R[]) => {
this.setState({ suggestions });
});

View File

@ -1,7 +1,7 @@
// Copyright (c) 2020 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved.
// SPDX-License-Identifier: Apache-2.0
import * as Color from 'color';
import Color from 'color';
import * as React from 'react';
import { default as styled, hardcodedStyle, ThemeInterface } from '../theme';
export { StyledComponent } from 'styled-components';

View File

@ -1,12 +1,12 @@
// Copyright (c) 2020 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved.
// SPDX-License-Identifier: Apache-2.0
import { DocumentNode } from 'graphql';
import {
ApolloClient,
ObservableQuery,
Subscription,
} from 'react-apollo';
ObservableSubscription,
} from '@apollo/client';
import { DocumentNode } from 'graphql';
import {
ContractsResult,
ContractTableConfig,
@ -16,16 +16,17 @@ import {
export class ApolloDataProvider<C extends ContractTableConfig>
implements DataProvider<C> {
client: ApolloClient;
// tslint:disable-next-line:no-any
client: ApolloClient<any>;
query: DocumentNode;
observableQuery: ObservableQuery<{}>;
querySubscription?: Subscription;
querySubscription?: ObservableSubscription;
createVariables: (config: ContractTableConfig) => {};
dataToContractsResult: (data: {}) => ContractsResult;
constructor(
client: ApolloClient,
// tslint:disable-next-line:no-any
client: ApolloClient<any>,
query: DocumentNode,
createVariables: (config: ContractTableConfig) => {},
dataToContractsResult: (data: {}) => ContractsResult,
@ -60,7 +61,7 @@ export class ApolloDataProvider<C extends ContractTableConfig>
});
const next = () => {
onResult(this.dataToContractsResult(
this.observableQuery.currentResult().data));
this.observableQuery.getCurrentResult().data));
};
this.querySubscription = this.observableQuery.subscribe({ next });
}

View File

@ -1,8 +1,8 @@
// Copyright (c) 2020 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved.
// SPDX-License-Identifier: Apache-2.0
import cx = require('classnames');
import deepEqual = require('deep-equal');
import cx from 'classnames';
import deepEqual from 'deep-equal';
import * as React from 'react';
import {
AutoSizer,
@ -319,7 +319,7 @@ export default class ContractTable<C extends ContractTableConfig>
if (!this.state.isLoading) {
// If we're not loading, schedule reload after clearing existing one.
if (this.reloadTimer) { clearTimeout(this.reloadTimer); }
this.reloadTimer = setTimeout(() => {
this.reloadTimer = window.setTimeout(() => {
this.reload(false);
}, DEFAULT_POLL_INTERVAL);
}
@ -348,7 +348,7 @@ export default class ContractTable<C extends ContractTableConfig>
}
}
if (oldest >= 0) {
this.rerenderTimer = setTimeout(() => {
this.rerenderTimer = window.setTimeout(() => {
this.rerenderTimer = undefined;
this.table.recomputeRowHeights(0);
this.forceUpdate();

View File

@ -1,7 +1,7 @@
// Copyright (c) 2020 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved.
// SPDX-License-Identifier: Apache-2.0
import deepEqual = require('deep-equal');
import deepEqual from 'deep-equal';
import * as React from 'react';
import {
AutoSizer,

View File

@ -9,7 +9,7 @@
// In the future, we may decide to use another library to implement
// this component.
import * as _ from 'lodash';
import * as Moment from 'moment';
import Moment from 'moment';
import * as React from 'react';
import Button from '../Button';
import UntypedIcon from '../Icon';

View File

@ -8,7 +8,7 @@
// The code was copied in order to simplify extensive customization.
// In the future, we may decide to use another library to implement
// this component.
import * as Moment from 'moment';
import Moment from 'moment';
import * as React from 'react';
import Button from '../Button';
import styled from '../theme';

View File

@ -8,7 +8,7 @@
// The code was copied in order to simplify extensive customization.
// In the future, we may decide to use another library to implement
// this component.
import * as Moment from 'moment';
import Moment from 'moment';
import * as React from 'react';
import Button from '../Button';
import { default as styled, hardcodedStyle } from '../theme';

View File

@ -2,7 +2,7 @@
// SPDX-License-Identifier: Apache-2.0
import * as React from 'react';
import ReactMarkdown = require('react-markdown');
import ReactMarkdown from 'react-markdown';
import styled from '../theme';
/**

View File

@ -1,7 +1,7 @@
// Copyright (c) 2020 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved.
// SPDX-License-Identifier: Apache-2.0
import { ApolloClient, gql } from 'react-apollo';
import { ApolloClient, gql } from '@apollo/client';
import * as DamlLfTypeF from '../api/DamlLfType';
import { DamlLfDefDataType, DamlLfIdentifier } from '../api/DamlLfType';
import {
@ -59,9 +59,11 @@ query ParameterFormTypeQuery($id: ID!) {
export default class ApolloDataProvider implements ContractIdProvider, TypeProvider {
readonly client: ApolloClient;
// tslint:disable-next-line:no-any
readonly client: ApolloClient<any>;
constructor(client: ApolloClient) {
// tslint:disable-next-line:no-any
constructor(client: ApolloClient<any>) {
this.client = client;
}

View File

@ -60,6 +60,7 @@ interface InputProps<T> {
onChange(val: T): void;
argument: DamlLfValue;
validate?(val: T): boolean;
name: string;
}
@ -549,7 +550,7 @@ const BoolInput = (props: InputProps<DamlLfValueBool>): JSX.Element => {
<StyledRadioInput
type="radio"
disabled={disabled}
name={name}
name={`${name}.true`}
checked={value}
onChange={(_) => { onChange(DamlLfValueF.bool(true)); }}
/>
@ -560,7 +561,7 @@ const BoolInput = (props: InputProps<DamlLfValueBool>): JSX.Element => {
<StyledRadioInput
type="radio"
disabled={disabled}
name={name}
name={`${name}.false`}
checked={!value}
onChange={(_) => { onChange(DamlLfValueF.bool(false)); }}
/>
@ -980,7 +981,8 @@ export const ParameterInput = (props: ParameterInputProps): JSX.Element => {
} = props;
if (parameter.type === 'primitive') {
switch (parameter.name) {
const primt = parameter.name;
switch (primt) {
case 'text': return (
<TextInput
parameter={parameter}
@ -988,6 +990,7 @@ export const ParameterInput = (props: ParameterInputProps): JSX.Element => {
onChange={onChange}
argument={argument}
validate={validate}
name={name}
/>
);
case 'party': return (
@ -997,6 +1000,7 @@ export const ParameterInput = (props: ParameterInputProps): JSX.Element => {
onChange={onChange}
argument={argument}
validate={validate}
name={name}
/>
);
case 'contractid': return (
@ -1017,6 +1021,7 @@ export const ParameterInput = (props: ParameterInputProps): JSX.Element => {
onChange={onChange}
argument={argument}
validate={validate}
name={name}
/>
);
case 'timestamp': return (
@ -1042,6 +1047,7 @@ export const ParameterInput = (props: ParameterInputProps): JSX.Element => {
onChange={onChange}
argument={argument}
validate={validate}
name={name}
/>
);
case 'unit': return (
@ -1051,6 +1057,7 @@ export const ParameterInput = (props: ParameterInputProps): JSX.Element => {
onChange={onChange}
argument={argument}
validate={validate}
name={name}
/>
);
case 'list': {
@ -1106,7 +1113,7 @@ export const ParameterInput = (props: ParameterInputProps): JSX.Element => {
/>
);
}
default: throw new NonExhaustiveMatch(parameter.name)
default: throw new NonExhaustiveMatch(primt)
}
} else if (parameter.type === 'numeric') {
return (

View File

@ -1,7 +1,7 @@
// Copyright (c) 2020 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved.
// SPDX-License-Identifier: Apache-2.0
import RouteParser = require('route-parser');
import RouteParser from 'route-parser';
export type Path = string;

View File

@ -35,7 +35,7 @@ export default class SearchInput extends React.Component<Props, State> {
const value = event.target.value;
this.setState({ value });
clearTimeout(this.delayTimer);
this.delayTimer = setTimeout(() => {
this.delayTimer = window.setTimeout(() => {
this.props.onChange(value);
}, this.props.debounceTime || DEBOUNCE_TIME_DEFAULT);
}

View File

@ -1,9 +1,9 @@
// Copyright (c) 2020, Digital Asset (Switzerland) GmbH and/or its affiliates.
// All rights reserved.
import * as Moment from 'moment';
import Moment from 'moment';
import {NonExhaustiveMatch} from '../util'
import {DamlLfEnum, DamlLfIdentifier, DamlLfRecord, DamlLfType, DamlLfVariant} from './DamlLfType';
import {DamlLfEnum, DamlLfIdentifier, DamlLfPrimType, DamlLfRecord, DamlLfType, DamlLfVariant} from './DamlLfType';
// --------------------------------------------------------------------------------------------------------------------
// Type definitions
@ -212,7 +212,9 @@ export function initialValue(type: DamlLfType): DamlLfValue {
case 'typevar': return undef();
case 'typecon': return undef();
case 'numeric': return undef();
case 'primitive': switch (type.name) {
case 'primitive':
const n: DamlLfPrimType = type.name;
switch (n) {
case 'text': return undef();
case 'int64': return undef();
case 'bool': return bool(false);
@ -225,7 +227,7 @@ export function initialValue(type: DamlLfType): DamlLfValue {
case 'list': return list([]);
case 'textmap': return textmap([]);
case 'genmap': return genmap([]);
default: throw new NonExhaustiveMatch(type.name);
default: throw new NonExhaustiveMatch(n);
}
default: throw new NonExhaustiveMatch(type);
}

View File

@ -1,6 +1,7 @@
import * as OpaqueTypes from './OpaqueTypes'
/* tslint:disable */
/* eslint-disable */
// @generated
// This file was automatically generated and should not be edited.
// ====================================================
@ -24,14 +25,15 @@ export interface advanceTimeVariables {
/* tslint:disable */
/* eslint-disable */
// @generated
// This file was automatically generated and should not be edited.
// ====================================================
// GraphQL query operation: ContractsByIdQuery
// ====================================================
export interface ContractsByIdQuery_nodes_Transaction {
__typename: "Transaction" | "Template" | "DamlLfDefDataType" | "CreatedEvent" | "ExercisedEvent" | "CreateCommand" | "ExerciseCommand";
export interface ContractsByIdQuery_nodes_CreateCommand {
__typename: "CreateCommand" | "CreatedEvent" | "DamlLfDefDataType" | "ExerciseCommand" | "ExercisedEvent" | "Template" | "Transaction";
id: string;
}
@ -46,7 +48,7 @@ export interface ContractsByIdQuery_nodes_Contract {
archiveEvent: ContractsByIdQuery_nodes_Contract_archiveEvent | null;
}
export type ContractsByIdQuery_nodes = ContractsByIdQuery_nodes_Transaction | ContractsByIdQuery_nodes_Contract;
export type ContractsByIdQuery_nodes = ContractsByIdQuery_nodes_CreateCommand | ContractsByIdQuery_nodes_Contract;
export interface ContractsByIdQuery {
nodes: ContractsByIdQuery_nodes[];
@ -58,14 +60,15 @@ export interface ContractsByIdQueryVariables {
/* tslint:disable */
/* eslint-disable */
// @generated
// This file was automatically generated and should not be edited.
// ====================================================
// GraphQL query operation: CommandResultsQuery
// ====================================================
export interface CommandResultsQuery_nodes_Transaction {
__typename: "Transaction" | "Template" | "DamlLfDefDataType" | "Contract" | "CreatedEvent" | "ExercisedEvent";
export interface CommandResultsQuery_nodes_Contract {
__typename: "Contract" | "CreatedEvent" | "DamlLfDefDataType" | "ExercisedEvent" | "Template" | "Transaction";
id: string;
}
@ -87,7 +90,7 @@ export interface CommandResultsQuery_nodes_CreateCommand {
status: CommandResultsQuery_nodes_CreateCommand_status;
}
export type CommandResultsQuery_nodes = CommandResultsQuery_nodes_Transaction | CommandResultsQuery_nodes_CreateCommand;
export type CommandResultsQuery_nodes = CommandResultsQuery_nodes_Contract | CommandResultsQuery_nodes_CreateCommand;
export interface CommandResultsQuery {
nodes: CommandResultsQuery_nodes[];
@ -99,6 +102,7 @@ export interface CommandResultsQueryVariables {
/* tslint:disable */
/* eslint-disable */
// @generated
// This file was automatically generated and should not be edited.
// ====================================================
@ -163,14 +167,15 @@ export interface ParameterFormContractIdQueryVariables {
/* tslint:disable */
/* eslint-disable */
// @generated
// This file was automatically generated and should not be edited.
// ====================================================
// GraphQL query operation: ParameterFormTypeQuery
// ====================================================
export interface ParameterFormTypeQuery_node_Transaction {
__typename: "Transaction" | "Template" | "Contract" | "CreatedEvent" | "ExercisedEvent" | "CreateCommand" | "ExerciseCommand";
export interface ParameterFormTypeQuery_node_Contract {
__typename: "Contract" | "CreateCommand" | "CreatedEvent" | "ExerciseCommand" | "ExercisedEvent" | "Template" | "Transaction";
}
export interface ParameterFormTypeQuery_node_DamlLfDefDataType {
@ -179,7 +184,7 @@ export interface ParameterFormTypeQuery_node_DamlLfDefDataType {
typeVars: string[];
}
export type ParameterFormTypeQuery_node = ParameterFormTypeQuery_node_Transaction | ParameterFormTypeQuery_node_DamlLfDefDataType;
export type ParameterFormTypeQuery_node = ParameterFormTypeQuery_node_Contract | ParameterFormTypeQuery_node_DamlLfDefDataType;
export interface ParameterFormTypeQuery {
node: ParameterFormTypeQuery_node | null;
@ -191,24 +196,7 @@ export interface ParameterFormTypeQueryVariables {
/* tslint:disable */
/* eslint-disable */
// This file was automatically generated and should not be edited.
// ====================================================
// GraphQL mutation operation: WithExerciseQuery
// ====================================================
export interface WithExerciseQuery {
exercise: OpaqueTypes.CommandId;
}
export interface WithExerciseQueryVariables {
contractId: string;
choiceId: string;
argument?: OpaqueTypes.DamlLfValue | null;
}
/* tslint:disable */
/* eslint-disable */
// @generated
// This file was automatically generated and should not be edited.
// ====================================================
@ -228,6 +216,7 @@ export interface LedgerTimeQuery {
/* tslint:disable */
/* eslint-disable */
// @generated
// This file was automatically generated and should not be edited.
//==============================================================

View File

@ -1,90 +0,0 @@
{
"__schema": {
"types": [
{
"kind": "INTERFACE",
"name": "Command",
"possibleTypes": [
{
"name": "CreateCommand"
},
{
"name": "ExerciseCommand"
}
]
},
{
"kind": "INTERFACE",
"name": "CommandStatus",
"possibleTypes": [
{
"name": "CommandStatusError"
},
{
"name": "CommandStatusSuccess"
},
{
"name": "CommandStatusUnknown"
},
{
"name": "CommandStatusWaiting"
}
]
},
{
"kind": "INTERFACE",
"name": "DamlLfNode",
"possibleTypes": [
{
"name": "DamlLfDefDataType"
},
{
"name": "Template"
}
]
},
{
"kind": "INTERFACE",
"name": "Event",
"possibleTypes": [
{
"name": "CreatedEvent"
},
{
"name": "ExercisedEvent"
}
]
},
{
"kind": "INTERFACE",
"name": "Node",
"possibleTypes": [
{
"name": "Contract"
},
{
"name": "CreateCommand"
},
{
"name": "CreatedEvent"
},
{
"name": "DamlLfDefDataType"
},
{
"name": "ExerciseCommand"
},
{
"name": "ExercisedEvent"
},
{
"name": "Template"
},
{
"name": "Transaction"
}
]
}
]
}
}

View File

@ -0,0 +1 @@
{"Command":["CreateCommand","ExerciseCommand"],"CommandStatus":["CommandStatusError","CommandStatusSuccess","CommandStatusUnknown","CommandStatusWaiting"],"DamlLfNode":["DamlLfDefDataType","Template"],"Event":["CreatedEvent","ExercisedEvent"],"Node":["Contract","CreateCommand","CreatedEvent","DamlLfDefDataType","ExerciseCommand","ExercisedEvent","Template","Transaction"]}

View File

@ -7,7 +7,7 @@ import * as React from 'react';
import {
ApolloClient,
ApolloProvider,
} from 'react-apollo';
} from '@apollo/client';
import * as ReactDOM from 'react-dom';
import ArgumentDisplayGuide from '../ArgumentDisplay/Guide';
import AutosuggestGuide from '../Autosuggest/Guide';
@ -48,7 +48,7 @@ const apolloMock = {
query: () => mockRejectPromise,
mutate: () => mockRejectPromise,
// tslint:disable-next-line:no-any
} as any as ApolloClient
} as any as ApolloClient<any>
const App = (_: {}): JSX.Element => (
<ApolloProvider client={apolloMock}>

View File

@ -1,11 +1,9 @@
// Copyright (c) 2020 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved.
// SPDX-License-Identifier: Apache-2.0
import { ApolloClient } from '@apollo/client';
import { withApollo } from '@apollo/client/react/hoc';
import * as React from 'react';
import {
ApolloClient,
withApollo,
} from 'react-apollo';
import { connect } from 'react-redux';
import { AnyAction, compose } from 'redux';
import { Set } from 'typescript-collections';
@ -46,7 +44,8 @@ export interface OwnProps<A extends Action> {
}
export interface ApolloProps {
client: ApolloClient;
// tslint:disable-next-line:no-any
client: ApolloClient<any>;
}
export interface ReduxProps<A extends Action> {
@ -131,16 +130,13 @@ class Component<A extends Action>
}
}
const _withApollo: Connect<ApolloProps, OwnProps<AnyAction>>
= withApollo;
const withRedux: Connect<
ReduxProps<AnyAction>,
OwnProps<AnyAction> & ApolloProps
>
= connect();
export const UI = compose(
_withApollo,
export const UI: React.ComponentClass<OwnProps<AnyAction>> = compose(
(x) => withApollo<OwnProps<AnyAction>>(x),
withRedux,
)(Component);

View File

@ -1,7 +1,7 @@
// Copyright (c) 2020 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved.
// SPDX-License-Identifier: Apache-2.0
import { ApolloClient } from 'apollo-client';
import { ApolloClient } from '@apollo/client';
import gql from 'graphql-tag';
import {
CommandResultsQuery,
@ -230,7 +230,8 @@ class Watcher {
contractsTimer: number;
commandsTimer: number;
constructor(
private client: ApolloClient,
// tslint:disable-next-line:no-any
private client: ApolloClient<any>,
private getWatcherState: () => State,
private dispatch: (action: Action) => void) {
this.start = this.start.bind(this);
@ -240,9 +241,9 @@ class Watcher {
}
start(): void {
this.contractsTimer = setTimeout(this.processContracts,
this.contractsTimer = window.setTimeout(this.processContracts,
CONTRACTS_POLL_INTERVAL);
this.commandsTimer = setTimeout(this.processCommands,
this.commandsTimer = window.setTimeout(this.processCommands,
COMMANDS_POLL_INTERVAL);
}
@ -264,7 +265,7 @@ class Watcher {
console.error('Error fetching contract archiving updates:', err);
});
}
this.contractsTimer = setTimeout(this.processContracts,
this.contractsTimer = window.setTimeout(this.processContracts,
CONTRACTS_POLL_INTERVAL);
}
@ -299,7 +300,7 @@ class Watcher {
});
}
}
this.commandsTimer = setTimeout(this.processCommands,
this.commandsTimer = window.setTimeout(this.processCommands,
COMMANDS_POLL_INTERVAL);
}
}

View File

@ -26,9 +26,6 @@ export interface Dispatch<S> {
// Types for higher order components
// ----------------------------------------------------------------------------
export type Diff<T, U> = T extends U ? never : T;
export type Omit<T, K extends keyof T> = Pick<T, Diff<keyof T, K>>;
/**
* Given a component with properties P,
* returns a component with properties ((P - Remove) & Add).

View File

@ -1,18 +1,17 @@
// Copyright (c) 2020 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved.
// SPDX-License-Identifier: Apache-2.0
import * as Moment from 'moment';
import * as React from 'react';
import {
ApolloClient,
ApolloError,
ApolloQueryResult,
gql,
NetworkStatus,
QueryProps,
Subscription,
withApollo,
} from 'react-apollo';
ObservableSubscription,
} from '@apollo/client';
import { QueryControls, withApollo } from '@apollo/client/react/hoc';
import Moment from 'moment';
import * as React from 'react';
import { TimeType } from '../api/OpaqueTypes';
import { LedgerTimeQuery } from '../api/Queries';
import { Connect } from '../types';
@ -30,7 +29,7 @@ interface ApolloCurrentResult<T> {
// ------------------------------------------------------------------------------------------------
// Props
// ------------------------------------------------------------------------------------------------
interface QueryData extends QueryProps {
interface QueryData extends QueryControls {
ledgerTime: LedgerTimeResult;
}
@ -50,7 +49,8 @@ export interface InnerProps {
}
export interface ApolloProps {
client: ApolloClient;
// tslint:disable-next-line:no-any
client: ApolloClient<any>;
}
export interface State {
@ -131,7 +131,7 @@ export default function withLedgerTime<P extends {}>(C: React.ComponentType<Inne
type Props = P & ApolloProps;
class Component extends React.Component<Props, State> {
private timeoutId: number | undefined = undefined;
private querySubscription: Subscription | undefined = undefined;
private querySubscription: ObservableSubscription | undefined = undefined;
constructor(props: Props) {
super(props);
@ -158,7 +158,7 @@ export default function withLedgerTime<P extends {}>(C: React.ComponentType<Inne
query: timeQuery,
});
const next = () => {
const qr = observableQuery.currentResult();
const qr = observableQuery.getCurrentResult();
const newState = resultToState(qr);
this.setState(newState);
this.scheduleUpdate(getUpdateInterval(newState.timeType));
@ -182,7 +182,7 @@ export default function withLedgerTime<P extends {}>(C: React.ComponentType<Inne
scheduleUpdate(interval: number) {
if (interval < Infinity) {
this.timeoutId = setTimeout(() => {
this.timeoutId = window.setTimeout(() => {
this.forceUpdate();
this.scheduleUpdate(interval);
}, interval);

View File

@ -1,6 +1,8 @@
{
"compilerOptions": {
"module": "commonjs",
"module": "es2015",
"esModuleInterop": true,
"moduleResolution": "node",
"target": "es5",
"jsx": "react",
"sourceMap": true,

File diff suppressed because it is too large Load Diff