Skip to content

Commit

Permalink
Merge pull request #17 from CosmWasm/update-cosmjs-0.24-alpha22
Browse files Browse the repository at this point in the history
Update cosmjs 0.24-alpha.22
  • Loading branch information
ethanfrey authored Jan 29, 2021
2 parents 55fe307 + cb1bebb commit 6085a8e
Show file tree
Hide file tree
Showing 7 changed files with 167 additions and 138 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
# generated tailwind
/src/tailwind.output.css

# deployment
.netlify

# dependencies
/node_modules
/.pnp
Expand Down
27 changes: 15 additions & 12 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@
"private": true,
"license": "Apache-2.0",
"dependencies": {
"@cosmjs/cosmwasm": "^0.24.0-alpha.10",
"@cosmjs/encoding": "^0.24.0-alpha.10",
"@cosmjs/launchpad": "^0.24.0-alpha.10",
"@cosmjs/math": "^0.24.0-alpha.10",
"@cosmjs/stargate": "^0.24.0-alpha.10",
"@cosmjs/tendermint-rpc": "^0.24.0-alpha.10",
"@cosmjs/utils": "^0.24.0-alpha.10",
"@cosmjs/cosmwasm": "^0.24.0-alpha.22",
"@cosmjs/encoding": "^0.24.0-alpha.22",
"@cosmjs/launchpad": "^0.24.0-alpha.22",
"@cosmjs/math": "^0.24.0-alpha.22",
"@cosmjs/stargate": "^0.24.0-alpha.22",
"@cosmjs/tendermint-rpc": "^0.24.0-alpha.22",
"@cosmjs/utils": "^0.24.0-alpha.22",
"@testing-library/jest-dom": "^5.11.4",
"@testing-library/react": "^11.1.0",
"@testing-library/user-event": "^12.1.10",
Expand All @@ -28,11 +28,14 @@
},
"scripts": {
"build:tailwind": "tailwindcss build src/index.css -o src/tailwind.output.css",
"prebuild": "NODE_ENV=production yarn run build:tailwind",
"build": "react-scripts build",
"prestart": "yarn run build:tailwind",
"start": "react-scripts start",
"start:musselnet": "REACT_APP_NETWORK=musselnet yarn start",
"prebuild": "NODE_ENV=production yarn build:tailwind",
"build:base": "react-scripts build",
"build": "yarn build:musselnet",
"build:musselnet": "REACT_APP_NETWORK=musselnet yarn build:base",
"prestart": "yarn build:tailwind",
"start:base": "react-scripts start",
"start": "yarn start:musselnet",
"start:musselnet": "REACT_APP_NETWORK=musselnet yarn start:base",
"test": "react-scripts test",
"eject": "react-scripts eject"
},
Expand Down
1 change: 1 addition & 0 deletions public/_redirects
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/* /index.html 200
4 changes: 2 additions & 2 deletions src/App/components/HeightData.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ export function HeightData({ height }: HeightDataProps): JSX.Element {
<div className="m-2 ml-0">
<span className={style.subtitle}>Height</span>
<div className="flex flex-col">
<span>Version height: {height?.versionHeight?.toString(10) ?? "–"}</span>
<span>Version number: {height?.versionNumber?.toString(10) ?? "–"}</span>
<span>Version height: {height?.revisionHeight?.toString(10) ?? "–"}</span>
<span>Version number: {height?.revisionNumber?.toString(10) ?? "–"}</span>
</div>
</div>
);
Expand Down
49 changes: 37 additions & 12 deletions src/App/routes/Connections/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,19 @@ import { Navigation } from "../../components/Navigation";
import { pathConnections } from "../../paths";
import { style } from "../../style";

// orders strings like "07-tendermint-0" numerically
function compareClientIds(a: string, b: string): number {
const arrayA = a.split("-");
const arrayB = b.split("-");
arrayA.splice(1, 1);
arrayB.splice(1, 1);
const [firstNumberA, secondNumberA] = arrayA.map((stringNum) => Number.parseInt(stringNum, 10));
const [firstNumberB, secondNumberB] = arrayB.map((stringNum) => Number.parseInt(stringNum, 10));

if (firstNumberA > firstNumberB) return firstNumberA - firstNumberB;
return secondNumberA - secondNumberB;
}

export function Connections(): JSX.Element {
const { getClient } = useClient();

Expand All @@ -20,12 +33,15 @@ export function Connections(): JSX.Element {
const connectionsResponse = await getClient().ibc.unverified.connections();
setConnectionsResponse(connectionsResponse);

const clientIds =
const nonEmptyClientIds =
connectionsResponse.connections
?.map((connection) => connection.clientId ?? "")
.filter((clientId) => clientId !== "") ?? [];

setClientIds(clientIds.sort());
const nonDuplicateClientIds = [...new Set(nonEmptyClientIds)];
const orderedClientIds = nonDuplicateClientIds.sort(compareClientIds);

setClientIds(orderedClientIds);
})();
}, [getClient]);

Expand Down Expand Up @@ -54,7 +70,7 @@ export function Connections(): JSX.Element {
// must remove duplicate client ids
const mergedClientIds = [...oldClientIds, ...newClientIds];
const uniqueClientIds = [...new Set(mergedClientIds)];
const sortedClientIds = uniqueClientIds.sort();
const sortedClientIds = uniqueClientIds.sort(compareClientIds);

return sortedClientIds;
});
Expand All @@ -74,15 +90,24 @@ export function Connections(): JSX.Element {
{clientIds.map((clientId) => (
<div key={clientId} className="flex flex-col items-start">
<div className={style.subtitle}>Client {clientId}</div>
{connectionsResponse.connections?.map((connection) => (
<Link
to={`${pathConnections}/${connection.id}`}
key={connection.id}
className={`${style.link} mt-2 block`}
>
Connection {ellideMiddle(connection.id ?? "–", 20)}
</Link>
))}
{connectionsResponse.connections
?.filter((connection) => connection.clientId === clientId)
.sort((a, b) => {
// orders strings like "connection-6" numerically
const numberA = Number.parseInt(a.id?.split("-")[1] || "", 10);
const numberB = Number.parseInt(b.id?.split("-")[1] || "", 10);

return numberA - numberB;
})
.map((connection) => (
<Link
to={`${pathConnections}/${connection.id}`}
key={connection.id}
className={`${style.link} mt-2 block`}
>
Connection {ellideMiddle(connection.id ?? "–", 20)}
</Link>
))}
</div>
))}
</div>
Expand Down
2 changes: 1 addition & 1 deletion tailwind.config.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module.exports = {
purge: {
mode: "layers",
content: ["./src/**/*.tsx"],
content: ["./src/**/*.tsx", "./src/**/*.ts"],
},
};
Loading

0 comments on commit 6085a8e

Please sign in to comment.