Skip to content

Commit

Permalink
Merge branch 'release/1.2.1'
Browse files Browse the repository at this point in the history
  • Loading branch information
rhyslbw committed Dec 15, 2020
2 parents eaae663 + a4db748 commit 561af50
Show file tree
Hide file tree
Showing 18 changed files with 123 additions and 48 deletions.
12 changes: 12 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,18 @@
Changelog
=========

## 1.2.1

### Compatible with:

- [`cardano-graphql`: `3.0.0`](https://github.com/input-output-hk/cardano-graphql/releases/tag/3.0.0)

Compatibility upgrade

### Fixes
- scope withdrawals query to address ([cad9e3f](https://github.com/input-output-hk/cardano-explorer-app/commit/cad9e3f48948cbe6bfb6f6adb795a6bc06fde2fb))
- check search strings for shelley-era addresses, to avoid clash with testnet stake addresses and hashes ([58c004a](https://github.com/input-output-hk/cardano-explorer-app/commit/58c004a4422c01aef320802bb780361a93334a27))

## 1.2.0

### Compatible with:
Expand Down
2 changes: 1 addition & 1 deletion codegen.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
overwrite: true
schema: node_modules/@cardano-graphql/client-ts/api/schema.graphql
schema: node_modules/@cardano-graphql/client-ts/api/cardano-db-hasura/schema.graphql
documents: "source/**/*.graphql"
generates:
generated/typings/graphql-schema.d.ts:
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "cardano-explorer-app",
"version": "1.2.0",
"version": "1.2.1",
"description": "Cardano Explorer App",
"author": "Daedalus Team @ Input Output HK",
"license": "Apache-2.0",
Expand Down Expand Up @@ -71,7 +71,7 @@
"@babel/plugin-transform-react-display-name": "7.8.3",
"@babel/plugin-transform-react-jsx-self": "7.9.0",
"@babel/plugin-transform-react-jsx-source": "7.9.0",
"@cardano-graphql/client-ts": "2.2.0",
"@cardano-graphql/client-ts": "3.0.0",
"@cypress/webpack-preprocessor": "4.1.1",
"@graphql-codegen/cli": "1.2.0",
"@graphql-codegen/typescript": "1.2.0",
Expand Down
Binary file removed packages-cache/@cardano-graphql-client-ts-2.2.0.tgz
Binary file not shown.
Binary file not shown.
2 changes: 1 addition & 1 deletion source/features/search/api/searchById.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#import "../../transactions/api/TransactionDetails.graphql"

query searchById(
$id: Hash32HexString!
$id: Hash32Hex!
) {
blocks(
where: {
Expand Down
10 changes: 8 additions & 2 deletions source/features/search/api/searchForStakeAddress.graphql
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#import "../../transactions/api/TransactionDetails.graphql"

query searchForStakeAddress(
$address: String!
$address: StakeAddress!
) {
transactions_aggregate (
where: {
Expand All @@ -16,7 +16,13 @@ query searchForStakeAddress(
count
}
}
withdrawals {
withdrawals (
where: {
address: {
_eq: $address
}
}
) {
transaction {
...TransactionDetails
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#import "../../transactions/api/TransactionDetails.graphql"

query searchForTransactionById(
$id: Hash32HexString
$id: Hash32Hex
) {
transactions(
where: {
Expand Down
4 changes: 2 additions & 2 deletions source/features/search/specs/helpers/exampleAddressData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,6 @@ export const examplePaymentAddressData = {

export const exampleStakeAddressData = {
address: 'stake1u8gu2vzsk2nc6hsphudhl3p6aum7nd59ajqjg9zp00uvxcqwsdray',
totalWithdrawn: '1563.774139',
transactionsCount: '1',
totalWithdrawn: 1563.774139,
transactionsCount: 1,
};
8 changes: 6 additions & 2 deletions source/features/search/specs/searchForStakeAddress.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,14 @@ describe('Searching for a stake address summary', () => {

// 3. Access the observable search result provided by the store
await waitForExpect(() => {
expect(search.store?.stakeAddressSearchResult?.totalWithdrawn).toBe(
expect(
parseFloat(search.store?.stakeAddressSearchResult?.totalWithdrawn as string)
).toBeGreaterThanOrEqual(
exampleStakeAddressData.totalWithdrawn
);
expect(search.store?.stakeAddressSearchResult?.transactionsCount).toBe(
expect(
parseInt(search.store?.stakeAddressSearchResult?.transactionsCount as string)
).toBeGreaterThanOrEqual(
exampleStakeAddressData.transactionsCount
);
});
Expand Down
17 changes: 12 additions & 5 deletions source/features/search/ui/AddressSearchResult.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,11 @@ export const AddressSearchResult = () => {
<Observer>
{() => {
const { paymentAddressSearchResult, stakeAddressSearchResult } = store;
const address = paymentAddressSearchResult?.address || stakeAddressSearchResult?.address || null;
const transactionsCount = paymentAddressSearchResult?.transactionsCount || stakeAddressSearchResult?.transactionsCount;
const address = paymentAddressSearchResult?.address ||
stakeAddressSearchResult?.address ||
null;
const transactionsCount = paymentAddressSearchResult?.transactionsCount ||
stakeAddressSearchResult?.transactionsCount;
if (
( paymentAddressSearchResult && !api.searchForPaymentAddressQuery.hasBeenExecutedAtLeastOnce ) ||
( stakeAddressSearchResult && !api.searchForStakeAddressQuery.hasBeenExecutedAtLeastOnce ) ||
Expand Down Expand Up @@ -69,10 +72,13 @@ export const AddressSearchResult = () => {
<div className={styles.transactionList}>
{<TransactionBrowser
isLoading={
transactions.api.getAddressTransactionsQuery.isExecuting
transactions.api.getPaymentAddressTransactionsQuery.isExecuting ||
transactions.api.getStakeAddressTransactionsQuery.isExecuting
}
isLoadingFirstTime={
transactions.api.getAddressTransactionsQuery
transactions.api.getPaymentAddressTransactionsQuery
.isExecutingTheFirstTime ||
transactions.api.getStakeAddressTransactionsQuery
.isExecutingTheFirstTime
}
onChangePage={(page) => {
Expand All @@ -96,7 +102,8 @@ export const AddressSearchResult = () => {
}}
perPage={navigation.store.query.perPage as string}
currentPage={(navigation.store.query.page as string) ?? 1}
total={parseInt(paymentAddressSearchResult?.transactionsCount || stakeAddressSearchResult?.transactionsCount || '0', 10)}
total={parseInt(paymentAddressSearchResult?.transactionsCount ||
stakeAddressSearchResult?.transactionsCount || '0', 10)}
transactions={transactions.store.browsedAddressTransactions}
/>}
</div>
Expand Down
7 changes: 6 additions & 1 deletion source/features/search/ui/SearchBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,11 @@ export const SearchBar = (props: ISearchBarProps) => {
const networkInfo = useNetworkInfoFeature().store;
const introspectQuery = (query: string, type?: string) => {
const typeOfSearch = type ? type : searchType;
if (query?.length === 64) {
if (query.substring(0, 4) === 'addr' || query.substring(0, 5) === 'stake') {
search.actions.addressSearchRequested.trigger({
address: query,
});
} else if (query?.length === 64) {
search.actions.idSearchRequested.trigger({ id: query });
} else if (/^\d+$/.test(query)) {
const searchNumber = parseInt(query, 10);
Expand All @@ -42,6 +46,7 @@ export const SearchBar = (props: ISearchBarProps) => {
}
}
} else {
// Byron-era addresses have no prefix or standard length
search.actions.addressSearchRequested.trigger({
address: query,
});
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#import "./TransactionDetails.graphql"

query getBlockTransactions(
$blockId: Hash32HexString!
$blockId: Hash32Hex!
$offset: Int!
$limit: Int!
) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,13 @@
#import "./TransactionDetails.graphql"

query getAddressTransactions(
query getPaymentAddressTransactions(
$address: String!
$offset: Int!
$limit: Int!
) {
transactions(
where: {
_or: [{
withdrawals: {
address: {
_eq: $address
}
}
}, {
inputs: {
address: {
_eq: $address
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#import "./TransactionDetails.graphql"

query getStakeAddressTransactions(
$address: StakeAddress!
$offset: Int!
$limit: Int!
) {
transactions(
where: {
withdrawals: {
address: {
_eq: $address
}
}
}
offset: $offset
limit: $limit
) {
...TransactionDetails
}
}
27 changes: 19 additions & 8 deletions source/features/transactions/api/index.ts
Original file line number Diff line number Diff line change
@@ -1,31 +1,42 @@
import { GraphQLClient } from 'graphql-request';
import {
GetAddressTransactionsQuery,
GetAddressTransactionsQueryVariables,
GetBlockTransactionsQuery,
GetBlockTransactionsQueryVariables,
GetPaymentAddressTransactionsQuery,
GetPaymentAddressTransactionsQueryVariables,
GetStakeAddressTransactionsQuery,
GetStakeAddressTransactionsQueryVariables,
} from '../../../../generated/typings/graphql-schema';
import { GraphQLRequest } from '../../../lib/graphql/GraphQLRequest';
import getAddressTransactions from './getAddressTransactions.graphql';
import getBlockTransactions from './getBlockTransactions.graphql';
import getPaymentAddressTransactions from './getPaymentAddressTransactions.graphql';
import getStakeAddressTransactions from './getStakeAddressTransactions.graphql';

export class TransactionsApi {
public getBlockTransactionsQuery: GraphQLRequest<
GetBlockTransactionsQuery,
GetBlockTransactionsQueryVariables
>;
public getAddressTransactionsQuery: GraphQLRequest<
GetAddressTransactionsQuery,
GetAddressTransactionsQueryVariables
public getPaymentAddressTransactionsQuery: GraphQLRequest<
GetPaymentAddressTransactionsQuery,
GetPaymentAddressTransactionsQueryVariables
>;
public getStakeAddressTransactionsQuery: GraphQLRequest<
GetStakeAddressTransactionsQuery,
GetStakeAddressTransactionsQueryVariables
>;
constructor(client: GraphQLClient) {
this.getBlockTransactionsQuery = new GraphQLRequest(
client,
getBlockTransactions
);
this.getAddressTransactionsQuery = new GraphQLRequest(
this.getPaymentAddressTransactionsQuery = new GraphQLRequest(
client,
getPaymentAddressTransactions
);
this.getStakeAddressTransactionsQuery = new GraphQLRequest(
client,
getAddressTransactions
getStakeAddressTransactions
);
}
}
37 changes: 26 additions & 11 deletions source/features/transactions/store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,17 +37,32 @@ export class TransactionsStore extends Store {
typeof TransactionsActions.prototype.browseAddressTransactions
>
): Promise<void> => {
// Do not execute queries multiple times!
if (this.api.getAddressTransactionsQuery.isExecuting) {
return;
}
const result = await this.api.getAddressTransactionsQuery.execute(params);
if (result) {
runInAction(() => {
this.browsedAddressTransactions = result.transactions
.filter(isDefined)
.map(transactionDetailsTransformer);
});
if (params.address.substring(0, 5) === 'stake') {
// Do not execute queries multiple times!
if (this.api.getStakeAddressTransactionsQuery.isExecuting) {
return;
}
const result = await this.api.getStakeAddressTransactionsQuery.execute(params);
if (result) {
runInAction(() => {
this.browsedAddressTransactions = result.transactions
.filter(isDefined)
.map(transactionDetailsTransformer);
});
}
} else {
// Do not execute queries multiple times!
if (this.api.getPaymentAddressTransactionsQuery.isExecuting) {
return;
}
const result = await this.api.getPaymentAddressTransactionsQuery.execute(params);
if (result) {
runInAction(() => {
this.browsedAddressTransactions = result.transactions
.filter(isDefined)
.map(transactionDetailsTransformer);
});
}
}
};

Expand Down
8 changes: 4 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1443,10 +1443,10 @@
resolved "https://registry.yarnpkg.com/@bcoe/v8-coverage/-/v8-coverage-0.2.3.tgz#75a2e8b51cb758a7553d6804a5932d7aace75c39"
integrity sha512-0hYQ8SB4Db5zvZB4axdMHGwEaQjkZzFjQiN9LVYvIFB2nSUHW9tYpxWriPrWDASIxiaXax83REcLxuSdnGPZtw==

"@cardano-graphql/client-ts@2.2.0":
version "2.2.0"
resolved "https://registry.yarnpkg.com/@cardano-graphql/client-ts/-/client-ts-2.2.0.tgz#a8f725ab642a9605f9c4aee3b78d2a637f568675"
integrity sha512-1ob9UboUijZxXllSlaYtsoOWM4EXcmPlKyhm1o5+kY2qkD7lRzOs6TBpJegrU4xQX+TGhLALawP+l6lNiHIsTg==
"@cardano-graphql/client-ts@3.0.0":
version "3.0.0"
resolved "https://registry.yarnpkg.com/@cardano-graphql/client-ts/-/client-ts-3.0.0.tgz#629fe7b4dcff75504d32f1beb6964d1ec8a93c7b"
integrity sha512-wmqTmnf8pc8GouLRB6Gm/GaXTidWi6sYFY4eJPm8C4ntS3JiP0Gb2LSv+Y5UqlZGxP8A8xq8hXUQp4/tAATWXA==

"@cnakazawa/watch@^1.0.3":
version "1.0.4"
Expand Down

0 comments on commit 561af50

Please sign in to comment.