Skip to content

Commit 36249c2

Browse files
fix: remove axios (#2304)
Co-authored-by: neocybereth <[email protected]>
1 parent a62f281 commit 36249c2

File tree

19 files changed

+111
-204
lines changed

19 files changed

+111
-204
lines changed

apps/extension/.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,5 @@
22
.env
33
/node_modules
44
/build
5+
.yalc
6+
yalc.lock

apps/extension/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
"@dao-xyz/borsh": "^5.1.5",
3636
"@ledgerhq/hw-transport": "^6.31.4",
3737
"@ledgerhq/hw-transport-webusb": "^6.29.4",
38-
"@namada/sdk": "^0.20.7",
38+
"@namada/sdk": "0.22.0",
3939
"@zondax/ledger-namada": "^2.0.0",
4040
"bignumber.js": "^9.1.1",
4141
"buffer": "^6.0.3",
@@ -54,7 +54,7 @@
5454
},
5555
"devDependencies": {
5656
"@babel/plugin-transform-modules-commonjs": "^7.20.11",
57-
"@namada/sdk-node": "^0.20.7",
57+
"@namada/sdk-node": "^0.22.0",
5858
"@svgr/webpack": "^6.3.1",
5959
"@types/chrome": "^0.0.237",
6060
"@types/firefox-webext-browser": "^94.0.1",

apps/namadillo/.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,5 @@
99
/playwright-report/
1010
/playwright/.cache/
1111
/public/localnet-config.toml
12+
.yalc
13+
yalc.lock

apps/namadillo/package.json

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@
1010
"@chain-registry/client": "^1.53.5",
1111
"@cosmjs/encoding": "^0.32.3",
1212
"@keplr-wallet/types": "^0.12.136",
13-
"@namada/chain-registry": "^1.3.0",
14-
"@namada/indexer-client": "4.0.3",
15-
"@namada/sdk-multicore": "^0.20.8",
13+
"@namada/chain-registry": "^1.5.0",
14+
"@namada/indexer-client": "4.0.5",
15+
"@namada/sdk-multicore": "0.22.0",
1616
"@tailwindcss/container-queries": "^0.1.1",
1717
"@tanstack/query-core": "^5.40.0",
1818
"@tanstack/react-query": "^5.40.0",
@@ -79,7 +79,7 @@
7979
},
8080
"devDependencies": {
8181
"@eslint/js": "^9.9.1",
82-
"@namada/sdk-node": "^0.20.8",
82+
"@namada/sdk-node": "^0.22.0",
8383
"@namada/vite-esbuild-plugin": "^1.0.1",
8484
"@playwright/test": "^1.24.1",
8585
"@svgr/webpack": "^6.5.1",
@@ -102,7 +102,6 @@
102102
"@types/w3c-web-usb": "^1.0.10",
103103
"@vitejs/plugin-react": "^4.3.1",
104104
"autoprefixer": "^10.4.16",
105-
"axios": "^1.8.2",
106105
"dotenv": "^16.0.3",
107106
"eslint": "^8.57.0",
108107
"eslint-config-prettier": "^9.1.0",

apps/namadillo/src/App/Common/GasFeeModal.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,7 @@ export const GasFeeModal = ({
252252
totalInDollars,
253253
unitValueInDollars,
254254
} = buildGasOption({
255-
gasPriceInMinDenom: item.gasPriceInMinDenom,
255+
gasPriceInMinDenom: item.gasPrice,
256256
gasToken: item.token.address,
257257
});
258258

apps/namadillo/src/App/Staking/UnstakeBondingTable.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ export const UnstakeBondingTable = ({
8888
className="relative"
8989
>
9090
<AmountField
91-
placeholder="Select to increase stake"
91+
placeholder="Select to decrease stake"
9292
value={amountToUnstake.eq(0) ? undefined : amountToUnstake}
9393
updated={hasNewAmounts}
9494
forceActive={true}

apps/namadillo/src/App/Transfer/TransferSource.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@ import { SelectedChain } from "./SelectedChain";
1212
import { SelectedWallet } from "./SelectedWallet";
1313
import { TokenAmountCard } from "./TokenAmountCard";
1414

15+
export const isNamada = (chain: Chain): boolean => {
16+
return ["namada", "namadahousefire"].includes(chain.chain_name);
17+
};
18+
1519
export type TransferSourceProps = {
1620
isConnected: boolean;
1721
wallet?: WalletProvider;
@@ -64,7 +68,7 @@ export const TransferSource = ({
6468
return (
6569
<div className="relative bg-neutral-800 rounded-lg px-4 py-5">
6670
{/** Intro header - Ex: "IBC To Namada" */}
67-
{onChangeShielded && chain?.chain_name === "namada" && !isSubmitting && (
71+
{onChangeShielded && chain && isNamada(chain) && !isSubmitting && (
6872
<nav className="relative z-10 mb-6">
6973
<TabSelector
7074
active={isShieldedAddress ? "shielded" : "transparent"}

apps/namadillo/src/atoms/balance/atoms.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ import { namadaRegistryChainAssetsMapAtom } from "atoms/integrations";
1818
import { tokenPricesFamily } from "atoms/prices/atoms";
1919
import { maspIndexerUrlAtom, rpcUrlAtom } from "atoms/settings";
2020
import { queryDependentFn } from "atoms/utils";
21-
import { isAxiosError } from "axios";
2221
import BigNumber from "bignumber.js";
2322
import { sequenceT } from "fp-ts/lib/Apply";
2423
import { pipe } from "fp-ts/lib/function";
@@ -29,6 +28,7 @@ import { atomWithQuery } from "jotai-tanstack-query";
2928
import { atomWithStorage } from "jotai/utils";
3029
import { Address, TokenBalance } from "types";
3130
import { namadaAsset, toDisplayAmount } from "utils";
31+
import { isError404 } from "utils/http";
3232
import {
3333
mapNamadaAddressesToAssets,
3434
mapNamadaAssetsToTokenBalances,
@@ -59,7 +59,7 @@ const toDatedKeypair = async (
5959
try {
6060
height = await fetchBlockHeightByTimestamp(api, timestamp);
6161
} catch (e) {
62-
if (isAxiosError(e) && e.status === 404) {
62+
if (isError404(e)) {
6363
console.warn(
6464
"Failed to fetch block height by timestamp, falling back to height 0",
6565
e

apps/namadillo/src/atoms/balance/functions.ts

Lines changed: 3 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -17,43 +17,24 @@ export const getTotalDollar = (list?: TokenBalance[]): BigNumber =>
1717
export const getTotalNam = (list?: TokenBalance[]): BigNumber =>
1818
list?.find((i) => isNamadaAsset(i.asset))?.amount ?? new BigNumber(0);
1919

20-
// Type to handle both balance data structures
21-
type BalanceItem = Balance | { tokenAddress: string; minDenomAmount: string };
22-
2320
export const mapNamadaAddressesToAssets = ({
2421
balances,
2522
assets,
2623
}: {
27-
balances: BalanceItem[];
24+
balances: Balance[];
2825
assets: NamadaAsset[];
2926
}): Record<Address, NamadaAssetWithAmount> => {
3027
const map: Record<Address, NamadaAssetWithAmount> = {};
3128
balances.forEach((item) => {
32-
// Handle both data structures temporarily:
33-
// 1. {token: {address: '...'}, minDenomAmount: '...'}
34-
// 2. {tokenAddress: '...', minDenomAmount: '...'}
35-
let tokenAddress: string | undefined;
36-
37-
if ("token" in item && item.token?.address) {
38-
tokenAddress = item.token.address;
39-
} else if ("tokenAddress" in item) {
40-
tokenAddress = item.tokenAddress;
41-
}
42-
43-
if (!tokenAddress) {
44-
return;
45-
}
46-
47-
const asset = assets.find((asset) => asset.address === tokenAddress);
29+
const asset = assets.find((asset) => asset.address === item.token.address);
4830

4931
if (asset) {
50-
map[tokenAddress] = {
32+
map[item.token.address] = {
5133
amount: toDisplayAmount(asset, BigNumber(item.minDenomAmount)),
5234
asset,
5335
};
5436
}
5537
});
56-
5738
return map;
5839
};
5940

apps/namadillo/src/atoms/fees/atoms.ts

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,12 @@ import { atomFamily } from "jotai/utils";
1313
import { isPublicKeyRevealed } from "lib/query";
1414
import isEqual from "lodash.isequal";
1515
import { TxKind } from "types/txKind";
16+
import { isNamadaAsset, toDisplayAmount } from "utils";
1617
import { fetchGasEstimate, fetchTokensGasPrice } from "./services";
1718

1819
export type GasPriceTableItem = {
1920
token: ApiV1ChainTokenGet200ResponseInner;
21+
gasPrice: BigNumber;
2022
gasPriceInMinDenom: BigNumber;
2123
};
2224

@@ -68,12 +70,16 @@ export const gasPriceTableAtom = atomWithQuery<GasPriceTable>((get) => {
6870
return (
6971
response
7072
// filter only tokens that exists on the chain
71-
.filter(({ token }) => Boolean(chainAssetsMap.data[token]))
73+
.filter(({ token }) => Boolean(chainAssetsMap.data[token.address]))
7274
.map(({ token, minDenomAmount }) => {
75+
const asset = chainAssetsMap.data[token.address];
7376
const baseAmount = BigNumber(minDenomAmount);
74-
// Transform string address to token object format
7577
return {
76-
token: { address: token } as ApiV1ChainTokenGet200ResponseInner,
78+
token,
79+
gasPrice:
80+
asset && isNamadaAsset(asset) ?
81+
toDisplayAmount(asset, baseAmount)
82+
: baseAmount,
7783
gasPriceInMinDenom: baseAmount,
7884
};
7985
})

0 commit comments

Comments
 (0)