Skip to content

Commit

Permalink
refactor: use new api client
Browse files Browse the repository at this point in the history
  • Loading branch information
mateuszjasiuk committed Aug 29, 2024
1 parent 96860cd commit 4ff950d
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 16 deletions.
2 changes: 1 addition & 1 deletion apps/namadillo/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"license": "MIT",
"private": true,
"dependencies": {
"@anomaorg/namada-indexer-client": "0.0.21",
"@anomaorg/namada-indexer-client": "../../../namada-indexer-client",
"@cosmjs/encoding": "^0.32.3",
"@tailwindcss/container-queries": "^0.1.1",
"@tanstack/react-query": "^5.40.0",
Expand Down
6 changes: 4 additions & 2 deletions apps/namadillo/src/atoms/api.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { DefaultApi } from "@anomaorg/namada-indexer-client";
import { Configuration, DefaultApi } from "@anomaorg/namada-indexer-client";
import { Atom, atom, getDefaultStore } from "jotai";
import { indexerUrlAtom } from "./settings";

Expand All @@ -14,5 +14,7 @@ export const getIndexerApi = (): DefaultApi => {
// Helper function to use outside of hooks
const getApi = (get: <Value>(atom: Atom<Value>) => Value): DefaultApi => {
const indexerUrl = get(indexerUrlAtom);
return new DefaultApi({ basePath: indexerUrl });
const configuration = new Configuration({ basePath: indexerUrl });

return new DefaultApi(configuration);
};
11 changes: 6 additions & 5 deletions apps/namadillo/src/atoms/proposals/functions.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import {
ApiV1GovProposalGetStatusEnum as ApiIndexerProposalStatusEnum,
DefaultApi,
Proposal as IndexerProposal,
ProposalStatusEnum as IndexerProposalStatusEnum,
Expand Down Expand Up @@ -257,16 +258,16 @@ const fromIndexerStatus = (

const toIndexerStatus = (
proposalStatus: ProposalStatus
): IndexerProposalStatusEnum => {
): ApiIndexerProposalStatusEnum => {
switch (proposalStatus) {
case "pending":
return IndexerProposalStatusEnum.Pending;
return ApiIndexerProposalStatusEnum.Pending;
case "ongoing":
return IndexerProposalStatusEnum.Voting;
return ApiIndexerProposalStatusEnum.VotingPeriod;
case "passed":
return IndexerProposalStatusEnum.Passed;
return ApiIndexerProposalStatusEnum.Passed;
case "rejected":
return IndexerProposalStatusEnum.Rejected;
return ApiIndexerProposalStatusEnum.Rejected;
default:
return assertNever(proposalStatus);
}
Expand Down
5 changes: 3 additions & 2 deletions apps/namadillo/src/atoms/settings/services.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { DefaultApi } from "@anomaorg/namada-indexer-client";
import { Configuration, DefaultApi } from "@anomaorg/namada-indexer-client";
import { isUrlValid } from "@namada/utils";
import toml from "toml";
import { SettingsTomlOptions } from "types";
Expand All @@ -8,7 +8,8 @@ export const isIndexerAlive = async (url: string): Promise<boolean> => {
return false;
}
try {
const api = new DefaultApi({ basePath: url });
const configuration = new Configuration({ basePath: url });
const api = new DefaultApi(configuration);
const response = await api.healthGet();
return response.status === 200;
} catch {
Expand Down
33 changes: 27 additions & 6 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,12 @@ __metadata:
languageName: node
linkType: hard

"@anomaorg/namada-indexer-client@npm:0.0.21":
version: 0.0.21
resolution: "@anomaorg/namada-indexer-client@npm:0.0.21"
"@anomaorg/namada-indexer-client@file:../../../namada-indexer-client::locator=%40namada%2Fnamadillo%40workspace%3Aapps%2Fnamadillo":
version: 0.0.22
resolution: "@anomaorg/namada-indexer-client@file:../../../namada-indexer-client#../../../namada-indexer-client::hash=3a5fbb&locator=%40namada%2Fnamadillo%40workspace%3Aapps%2Fnamadillo"
dependencies:
axios: "npm:^0.21.1"
checksum: 4b9632145eee1d20672ad65eef447ed90e3abfc2fee09a5c3e40fc5fd9321ff83aff03acf4be75abe1c74c83fc635216f46f5c58155c11a291656bb822f05465
axios: "npm:^1.6.1"
checksum: 812376e1e7591f5f8f6a4a28c237797bf58aa7cf956f2a4cc373ad2bc4d270da5ec3c80b617a20d5e9c40a949a2d5f73873a08f410607caa426666d6418b3682
languageName: node
linkType: hard

Expand Down Expand Up @@ -8448,7 +8448,7 @@ __metadata:
version: 0.0.0-use.local
resolution: "@namada/namadillo@workspace:apps/namadillo"
dependencies:
"@anomaorg/namada-indexer-client": "npm:0.0.21"
"@anomaorg/namada-indexer-client": ../../../namada-indexer-client
"@cosmjs/encoding": "npm:^0.32.3"
"@playwright/test": "npm:^1.24.1"
"@release-it/keep-a-changelog": "npm:^5.0.0"
Expand Down Expand Up @@ -12954,6 +12954,17 @@ __metadata:
languageName: node
linkType: hard

"axios@npm:^1.6.1":
version: 1.7.4
resolution: "axios@npm:1.7.4"
dependencies:
follow-redirects: "npm:^1.15.6"
form-data: "npm:^4.0.0"
proxy-from-env: "npm:^1.1.0"
checksum: 5ea1a93140ca1d49db25ef8e1bd8cfc59da6f9220159a944168860ad15a2743ea21c5df2967795acb15cbe81362f5b157fdebbea39d53117ca27658bab9f7f17
languageName: node
linkType: hard

"axobject-query@npm:^2.2.0":
version: 2.2.0
resolution: "axobject-query@npm:2.2.0"
Expand Down Expand Up @@ -19364,6 +19375,16 @@ __metadata:
languageName: node
linkType: hard

"follow-redirects@npm:^1.15.6":
version: 1.15.6
resolution: "follow-redirects@npm:1.15.6"
peerDependenciesMeta:
debug:
optional: true
checksum: 9ff767f0d7be6aa6870c82ac79cf0368cd73e01bbc00e9eb1c2a16fbb198ec105e3c9b6628bb98e9f3ac66fe29a957b9645bcb9a490bb7aa0d35f908b6b85071
languageName: node
linkType: hard

"for-each@npm:^0.3.3":
version: 0.3.3
resolution: "for-each@npm:0.3.3"
Expand Down

0 comments on commit 4ff950d

Please sign in to comment.