Skip to content

Commit

Permalink
Merge pull request #3019 from JoinColony/maint/coinmachine-prices
Browse files Browse the repository at this point in the history
Fix prices for Coinmachine periods with no sales
  • Loading branch information
rdig authored Dec 12, 2021
2 parents c541a9a + 100e439 commit d1921e6
Show file tree
Hide file tree
Showing 37 changed files with 506 additions and 175 deletions.
1 change: 1 addition & 0 deletions jest.conf.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
"rootDir": "src",
"moduleNameMapper": {
"^\\~constants$": "<rootDir>/modules/constants.ts",
"^\\~externalUrls$": "<rootDir>/modules/externalUrls.ts",
"\\.(jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$": "<rootDir>/__mocks__/fileMock.ts",
"\\.(css|less)$": "<rootDir>/__mocks__/styleMock.ts",
"^\\~context(.*)$": "<rootDir>/context$1",
Expand Down
30 changes: 30 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,7 @@
"react-tabs": "^3.1.0",
"react-textarea-autosize": "^8.3.3",
"react-textfit": "^1.1.1",
"react-twitter-widgets": "^1.10.0",
"recompose": "^0.30.0",
"redux": "^4.0.1",
"redux-immutable": "^4.0.0",
Expand Down
69 changes: 55 additions & 14 deletions src/data/generated.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2031,15 +2031,13 @@ export type CoinMachineHasWhitelistQueryVariables = Exact<{

export type CoinMachineHasWhitelistQuery = Pick<Query, 'coinMachineHasWhitelist'>;

export type SubgraphCoinMachinePeriodsQueryVariables = Exact<{
colonyAddress: Scalars['String'];
extensionAddress: Scalars['String'];
limit: Scalars['Int'];
export type SubgraphCoinMachineExtensionInstalledQueryVariables = Exact<{
argumentsFilter: Scalars['String'];
sortDirection?: Maybe<Scalars['String']>;
}>;


export type SubgraphCoinMachinePeriodsQuery = { coinMachinePeriods: Array<Pick<SalePeriod, 'saleEndedAt' | 'tokensBought' | 'price'>>, extensionInitialisedEvents: Array<(
export type SubgraphCoinMachineExtensionInstalledQuery = { extensionInstalledEvents: Array<(
Pick<SubgraphEvent, 'id' | 'address' | 'name' | 'args' | 'timestamp'>
& { transaction: (
Pick<SubgraphTransaction, 'id'>
Expand All @@ -2049,7 +2047,18 @@ export type SubgraphCoinMachinePeriodsQuery = { coinMachinePeriods: Array<Pick<S
& { number: SubgraphBlock['id'] }
) }
) }
)>, tokenBoughtEvents: Array<(
)> };

export type SubgraphCoinMachinePeriodsQueryVariables = Exact<{
colonyAddress: Scalars['String'];
extensionAddress: Scalars['String'];
limit: Scalars['Int'];
periodsCreatedAfter: Scalars['String'];
sortDirection?: Maybe<Scalars['String']>;
}>;


export type SubgraphCoinMachinePeriodsQuery = { coinMachinePeriods: Array<Pick<SalePeriod, 'saleEndedAt' | 'tokensBought' | 'price'>>, tokenBoughtEvents: Array<(
Pick<SubgraphEvent, 'id' | 'address' | 'name' | 'args' | 'timestamp'>
& { transaction: (
Pick<SubgraphTransaction, 'id'>
Expand Down Expand Up @@ -5377,14 +5386,9 @@ export function useCoinMachineHasWhitelistLazyQuery(baseOptions?: Apollo.LazyQue
export type CoinMachineHasWhitelistQueryHookResult = ReturnType<typeof useCoinMachineHasWhitelistQuery>;
export type CoinMachineHasWhitelistLazyQueryHookResult = ReturnType<typeof useCoinMachineHasWhitelistLazyQuery>;
export type CoinMachineHasWhitelistQueryResult = Apollo.QueryResult<CoinMachineHasWhitelistQuery, CoinMachineHasWhitelistQueryVariables>;
export const SubgraphCoinMachinePeriodsDocument = gql`
query SubgraphCoinMachinePeriods($colonyAddress: String!, $extensionAddress: String!, $limit: Int!, $sortDirection: String = asc) {
coinMachinePeriods(where: {colonyAddress: $colonyAddress}, skip: 0, first: $limit, orderBy: "saleEndedAt", orderDirection: "desc") {
saleEndedAt
tokensBought
price
}
extensionInitialisedEvents: events(orderBy: "timestamp", orderDirection: $sortDirection, where: {name_contains: "ExtensionInitialised", address: $extensionAddress}) {
export const SubgraphCoinMachineExtensionInstalledDocument = gql`
query SubgraphCoinMachineExtensionInstalled($argumentsFilter: String!, $sortDirection: String = desc) {
extensionInstalledEvents: events(orderBy: "timestamp", orderDirection: $sortDirection, where: {name_contains: "ExtensionInstalled", args_contains: $argumentsFilter}) {
id
transaction {
id
Expand All @@ -5400,6 +5404,42 @@ export const SubgraphCoinMachinePeriodsDocument = gql`
args
timestamp
}
}
`;

/**
* __useSubgraphCoinMachineExtensionInstalledQuery__
*
* To run a query within a React component, call `useSubgraphCoinMachineExtensionInstalledQuery` and pass it any options that fit your needs.
* When your component renders, `useSubgraphCoinMachineExtensionInstalledQuery` returns an object from Apollo Client that contains loading, error, and data properties
* you can use to render your UI.
*
* @param baseOptions options that will be passed into the query, supported options are listed on: https://www.apollographql.com/docs/react/api/react-hooks/#options;
*
* @example
* const { data, loading, error } = useSubgraphCoinMachineExtensionInstalledQuery({
* variables: {
* argumentsFilter: // value for 'argumentsFilter'
* sortDirection: // value for 'sortDirection'
* },
* });
*/
export function useSubgraphCoinMachineExtensionInstalledQuery(baseOptions?: Apollo.QueryHookOptions<SubgraphCoinMachineExtensionInstalledQuery, SubgraphCoinMachineExtensionInstalledQueryVariables>) {
return Apollo.useQuery<SubgraphCoinMachineExtensionInstalledQuery, SubgraphCoinMachineExtensionInstalledQueryVariables>(SubgraphCoinMachineExtensionInstalledDocument, baseOptions);
}
export function useSubgraphCoinMachineExtensionInstalledLazyQuery(baseOptions?: Apollo.LazyQueryHookOptions<SubgraphCoinMachineExtensionInstalledQuery, SubgraphCoinMachineExtensionInstalledQueryVariables>) {
return Apollo.useLazyQuery<SubgraphCoinMachineExtensionInstalledQuery, SubgraphCoinMachineExtensionInstalledQueryVariables>(SubgraphCoinMachineExtensionInstalledDocument, baseOptions);
}
export type SubgraphCoinMachineExtensionInstalledQueryHookResult = ReturnType<typeof useSubgraphCoinMachineExtensionInstalledQuery>;
export type SubgraphCoinMachineExtensionInstalledLazyQueryHookResult = ReturnType<typeof useSubgraphCoinMachineExtensionInstalledLazyQuery>;
export type SubgraphCoinMachineExtensionInstalledQueryResult = Apollo.QueryResult<SubgraphCoinMachineExtensionInstalledQuery, SubgraphCoinMachineExtensionInstalledQueryVariables>;
export const SubgraphCoinMachinePeriodsDocument = gql`
query SubgraphCoinMachinePeriods($colonyAddress: String!, $extensionAddress: String!, $limit: Int!, $periodsCreatedAfter: String!, $sortDirection: String = asc) {
coinMachinePeriods(where: {colonyAddress: $colonyAddress, saleEndedAt_gte: $periodsCreatedAfter}, skip: 0, first: $limit, orderBy: "saleEndedAt", orderDirection: "desc") {
saleEndedAt
tokensBought
price
}
tokenBoughtEvents: events(orderBy: "timestamp", orderDirection: $sortDirection, where: {name_contains: "TokensBought", address: $extensionAddress}) {
id
transaction {
Expand Down Expand Up @@ -5434,6 +5474,7 @@ export const SubgraphCoinMachinePeriodsDocument = gql`
* colonyAddress: // value for 'colonyAddress'
* extensionAddress: // value for 'extensionAddress'
* limit: // value for 'limit'
* periodsCreatedAfter: // value for 'periodsCreatedAfter'
* sortDirection: // value for 'sortDirection'
* },
* });
Expand Down
36 changes: 21 additions & 15 deletions src/data/graphql/queries/coinMachine.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -71,24 +71,13 @@ query CoinMachineHasWhitelist($colonyAddress: String!) {
coinMachineHasWhitelist(colonyAddress: $colonyAddress) @client
}

query SubgraphCoinMachinePeriods($colonyAddress: String!, $extensionAddress: String!, $limit: Int!, $sortDirection: String = asc) {
coinMachinePeriods(
where: { colonyAddress: $colonyAddress },
skip: 0,
first: $limit
orderBy: "saleEndedAt",
orderDirection: "desc"
) {
saleEndedAt
tokensBought
price
}
extensionInitialisedEvents: events(
query SubgraphCoinMachineExtensionInstalled($argumentsFilter: String!, $sortDirection: String = desc) {
extensionInstalledEvents: events(
orderBy: "timestamp",
orderDirection: $sortDirection,
where: {
name_contains: "ExtensionInitialised",
address: $extensionAddress
name_contains: "ExtensionInstalled",
args_contains: $argumentsFilter
}
) {
id
Expand All @@ -106,6 +95,23 @@ query SubgraphCoinMachinePeriods($colonyAddress: String!, $extensionAddress: Str
args
timestamp
}
}

query SubgraphCoinMachinePeriods($colonyAddress: String!, $extensionAddress: String!, $limit: Int!, $periodsCreatedAfter: String!, $sortDirection: String = asc) {
coinMachinePeriods(
where: {
colonyAddress: $colonyAddress
saleEndedAt_gte: $periodsCreatedAfter
},
skip: 0,
first: $limit
orderBy: "saleEndedAt",
orderDirection: "desc"
) {
saleEndedAt
tokensBought
price
}
tokenBoughtEvents: events(
orderBy: "timestamp",
orderDirection: $sortDirection,
Expand Down
Loading

0 comments on commit d1921e6

Please sign in to comment.