Skip to content

Commit f2ae7d9

Browse files
committed
remove mintbase-js deps
1 parent 5dae7a6 commit f2ae7d9

File tree

11 files changed

+88
-428
lines changed

11 files changed

+88
-428
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
node_modules
2+
dist

dist/index.d.mts

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,5 +34,18 @@ type UseNearPriceReturn = {
3434
error: string | null;
3535
};
3636
declare const useNearPrice: () => UseNearPriceReturn;
37+
interface ParsedDataReturn<T> {
38+
error?: null | string;
39+
data?: T | null;
40+
}
41+
interface NearPriceData {
42+
price?: string;
43+
}
44+
interface CoinGeckoNearPriceData {
45+
near?: {
46+
usd: string;
47+
};
48+
}
49+
declare const nearPrice: () => Promise<ParsedDataReturn<string>>;
3750

38-
export { BitteWalletContext, BitteWalletContextProvider, useBitteWallet, useNearPrice };
51+
export { BitteWalletContext, BitteWalletContextProvider, type CoinGeckoNearPriceData, type NearPriceData, type ParsedDataReturn, nearPrice, useBitteWallet, useNearPrice };

dist/index.d.ts

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,5 +34,18 @@ type UseNearPriceReturn = {
3434
error: string | null;
3535
};
3636
declare const useNearPrice: () => UseNearPriceReturn;
37+
interface ParsedDataReturn<T> {
38+
error?: null | string;
39+
data?: T | null;
40+
}
41+
interface NearPriceData {
42+
price?: string;
43+
}
44+
interface CoinGeckoNearPriceData {
45+
near?: {
46+
usd: string;
47+
};
48+
}
49+
declare const nearPrice: () => Promise<ParsedDataReturn<string>>;
3750

38-
export { BitteWalletContext, BitteWalletContextProvider, useBitteWallet, useNearPrice };
51+
export { BitteWalletContext, BitteWalletContextProvider, type CoinGeckoNearPriceData, type NearPriceData, type ParsedDataReturn, nearPrice, useBitteWallet, useNearPrice };

dist/index.js

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/index.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/index.mjs

Lines changed: 3 additions & 3 deletions
Large diffs are not rendered by default.

dist/index.mjs.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,6 @@
4444
},
4545
"dependencies": {
4646
"@bitte-ai/wallet": "0.8.2",
47-
"@mintbase-js/data": "^0.6.6",
48-
"@mintbase-js/sdk": "^0.6.6",
4947
"@near-wallet-selector/core": "^9.5.1",
5048
"@near-wallet-selector/here-wallet": "^9.5.1",
5149
"@near-wallet-selector/meteor-wallet": "^9.5.1",

pnpm-lock.yaml

Lines changed: 20 additions & 413 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/hooks/useNearPrice.ts

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import { useEffect, useState } from 'react';
2-
import { nearPrice } from '@mintbase-js/data';
32

43
type UseNearPriceReturn = {
54
nearPrice: number;
@@ -27,3 +26,34 @@ export const useNearPrice = (): UseNearPriceReturn => {
2726
error,
2827
};
2928
};
29+
30+
// Coppied from archived repo: https://github.com/Mintbase/mintbase-js/blob/1661bb879eae3ae4f3e525e69bb2c1aeed1ef77f/packages/data/src/api/nearPrice/nearPrice.ts#L17
31+
const BINANCE_API = 'https://api.binance.com/api/v3/ticker/price?symbol=NEARUSDT';
32+
33+
export interface ParsedDataReturn<T> {
34+
error?: null | string;
35+
data?: T | null;
36+
}
37+
38+
export interface NearPriceData {
39+
price?: string;
40+
}
41+
export interface CoinGeckoNearPriceData {
42+
near?: {
43+
usd: string;
44+
};
45+
}
46+
47+
48+
export const nearPrice = async (): Promise<ParsedDataReturn<string>> => {
49+
try {
50+
const req = await fetch(BINANCE_API);
51+
const data: NearPriceData = await req.json();
52+
return {data: data.price || "0"};
53+
} catch (err: unknown) {
54+
console.error(
55+
`Failed to retrieve near price ${err}`,
56+
);
57+
return {data: "0"};
58+
}
59+
};

0 commit comments

Comments
 (0)