@talismn/token-rates 3.0.1 → 3.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,7 +1 @@
|
|
1
|
-
|
2
|
-
import { DbTokenRates } from "./types";
|
3
|
-
export declare class TalismanTokenRatesDatabase extends Dexie {
|
4
|
-
tokenRates: Dexie.Table<DbTokenRates, string>;
|
5
|
-
constructor();
|
6
|
-
}
|
7
|
-
export declare const db: TalismanTokenRatesDatabase;
|
1
|
+
export declare const tryToDeleteOldTokenRatesDb: () => void;
|
@@ -85,16 +85,15 @@ export declare const SUPPORTED_CURRENCIES: {
|
|
85
85
|
readonly symbol: "S$";
|
86
86
|
};
|
87
87
|
};
|
88
|
-
export type
|
88
|
+
export type TokenRatesStorage = {
|
89
|
+
tokenRates: TokenRatesList;
|
90
|
+
};
|
91
|
+
export type TokenRatesList = Record<TokenId, TokenRates>;
|
92
|
+
export type TokenRates = Record<TokenRateCurrency, TokenRateData | null>;
|
89
93
|
export type TokenRateData = {
|
90
94
|
price: number;
|
91
95
|
marketCap?: number;
|
92
96
|
change24h?: number;
|
93
97
|
};
|
94
|
-
export type
|
95
|
-
export type TokenRatesList = Record<TokenId, TokenRates>;
|
96
|
-
export type DbTokenRates = {
|
97
|
-
tokenId: TokenId;
|
98
|
-
rates: TokenRates;
|
99
|
-
};
|
98
|
+
export type TokenRateCurrency = keyof typeof SUPPORTED_CURRENCIES;
|
100
99
|
export declare const newTokenRates: () => TokenRates;
|
@@ -1,25 +1,15 @@
|
|
1
1
|
'use strict';
|
2
2
|
|
3
|
-
var dexie = require('dexie');
|
4
3
|
var chaindataProvider = require('@talismn/chaindata-provider');
|
5
4
|
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
// You only need to specify properties that you wish to index.
|
13
|
-
// The object store will allow any properties on your stored objects but you can only query them by indexed properties
|
14
|
-
// https://dexie.org/docs/API-Reference#declare-database
|
15
|
-
//
|
16
|
-
// Never index properties containing images, movies or large (huge) strings. Store them in IndexedDB, yes! but just don’t index them!
|
17
|
-
// https://dexie.org/docs/Version/Version.stores()#warning
|
18
|
-
tokenRates: "tokenId"
|
19
|
-
});
|
5
|
+
const tryToDeleteOldTokenRatesDb = () => {
|
6
|
+
try {
|
7
|
+
// try and delete it if it's still there
|
8
|
+
indexedDB.deleteDatabase("TalismanTokenRates");
|
9
|
+
} catch {
|
10
|
+
// dont care if it fails
|
20
11
|
}
|
21
|
-
}
|
22
|
-
const db = new TalismanTokenRatesDatabase();
|
12
|
+
};
|
23
13
|
|
24
14
|
const SUPPORTED_CURRENCIES = {
|
25
15
|
btc: {
|
@@ -257,8 +247,7 @@ const parseTokenRatesFromApi = (rawTokenRates, coingeckoIds, currencyIds) => {
|
|
257
247
|
exports.ALL_CURRENCY_IDS = ALL_CURRENCY_IDS;
|
258
248
|
exports.DEFAULT_COINSAPI_CONFIG = DEFAULT_COINSAPI_CONFIG;
|
259
249
|
exports.SUPPORTED_CURRENCIES = SUPPORTED_CURRENCIES;
|
260
|
-
exports.TalismanTokenRatesDatabase = TalismanTokenRatesDatabase;
|
261
250
|
exports.TokenRatesError = TokenRatesError;
|
262
|
-
exports.db = db;
|
263
251
|
exports.fetchTokenRates = fetchTokenRates;
|
264
252
|
exports.newTokenRates = newTokenRates;
|
253
|
+
exports.tryToDeleteOldTokenRatesDb = tryToDeleteOldTokenRatesDb;
|
@@ -1,25 +1,15 @@
|
|
1
1
|
'use strict';
|
2
2
|
|
3
|
-
var dexie = require('dexie');
|
4
3
|
var chaindataProvider = require('@talismn/chaindata-provider');
|
5
4
|
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
// You only need to specify properties that you wish to index.
|
13
|
-
// The object store will allow any properties on your stored objects but you can only query them by indexed properties
|
14
|
-
// https://dexie.org/docs/API-Reference#declare-database
|
15
|
-
//
|
16
|
-
// Never index properties containing images, movies or large (huge) strings. Store them in IndexedDB, yes! but just don’t index them!
|
17
|
-
// https://dexie.org/docs/Version/Version.stores()#warning
|
18
|
-
tokenRates: "tokenId"
|
19
|
-
});
|
5
|
+
const tryToDeleteOldTokenRatesDb = () => {
|
6
|
+
try {
|
7
|
+
// try and delete it if it's still there
|
8
|
+
indexedDB.deleteDatabase("TalismanTokenRates");
|
9
|
+
} catch {
|
10
|
+
// dont care if it fails
|
20
11
|
}
|
21
|
-
}
|
22
|
-
const db = new TalismanTokenRatesDatabase();
|
12
|
+
};
|
23
13
|
|
24
14
|
const SUPPORTED_CURRENCIES = {
|
25
15
|
btc: {
|
@@ -257,8 +247,7 @@ const parseTokenRatesFromApi = (rawTokenRates, coingeckoIds, currencyIds) => {
|
|
257
247
|
exports.ALL_CURRENCY_IDS = ALL_CURRENCY_IDS;
|
258
248
|
exports.DEFAULT_COINSAPI_CONFIG = DEFAULT_COINSAPI_CONFIG;
|
259
249
|
exports.SUPPORTED_CURRENCIES = SUPPORTED_CURRENCIES;
|
260
|
-
exports.TalismanTokenRatesDatabase = TalismanTokenRatesDatabase;
|
261
250
|
exports.TokenRatesError = TokenRatesError;
|
262
|
-
exports.db = db;
|
263
251
|
exports.fetchTokenRates = fetchTokenRates;
|
264
252
|
exports.newTokenRates = newTokenRates;
|
253
|
+
exports.tryToDeleteOldTokenRatesDb = tryToDeleteOldTokenRatesDb;
|
@@ -1,23 +1,13 @@
|
|
1
|
-
import { Dexie } from 'dexie';
|
2
1
|
import { evmErc20TokenId } from '@talismn/chaindata-provider';
|
3
2
|
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
// You only need to specify properties that you wish to index.
|
11
|
-
// The object store will allow any properties on your stored objects but you can only query them by indexed properties
|
12
|
-
// https://dexie.org/docs/API-Reference#declare-database
|
13
|
-
//
|
14
|
-
// Never index properties containing images, movies or large (huge) strings. Store them in IndexedDB, yes! but just don’t index them!
|
15
|
-
// https://dexie.org/docs/Version/Version.stores()#warning
|
16
|
-
tokenRates: "tokenId"
|
17
|
-
});
|
3
|
+
const tryToDeleteOldTokenRatesDb = () => {
|
4
|
+
try {
|
5
|
+
// try and delete it if it's still there
|
6
|
+
indexedDB.deleteDatabase("TalismanTokenRates");
|
7
|
+
} catch {
|
8
|
+
// dont care if it fails
|
18
9
|
}
|
19
|
-
}
|
20
|
-
const db = new TalismanTokenRatesDatabase();
|
10
|
+
};
|
21
11
|
|
22
12
|
const SUPPORTED_CURRENCIES = {
|
23
13
|
btc: {
|
@@ -252,4 +242,4 @@ const parseTokenRatesFromApi = (rawTokenRates, coingeckoIds, currencyIds) => {
|
|
252
242
|
}));
|
253
243
|
};
|
254
244
|
|
255
|
-
export { ALL_CURRENCY_IDS, DEFAULT_COINSAPI_CONFIG, SUPPORTED_CURRENCIES,
|
245
|
+
export { ALL_CURRENCY_IDS, DEFAULT_COINSAPI_CONFIG, SUPPORTED_CURRENCIES, TokenRatesError, fetchTokenRates, newTokenRates, tryToDeleteOldTokenRatesDb };
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@talismn/token-rates",
|
3
|
-
"version": "3.0.
|
3
|
+
"version": "3.0.3",
|
4
4
|
"author": "Talisman",
|
5
5
|
"homepage": "https://talisman.xyz",
|
6
6
|
"license": "GPL-3.0-or-later",
|
@@ -21,8 +21,7 @@
|
|
21
21
|
"node": ">=18"
|
22
22
|
},
|
23
23
|
"dependencies": {
|
24
|
-
"
|
25
|
-
"@talismn/chaindata-provider": "1.0.1"
|
24
|
+
"@talismn/chaindata-provider": "1.1.0"
|
26
25
|
},
|
27
26
|
"devDependencies": {
|
28
27
|
"@types/jest": "^29.5.14",
|
@@ -30,8 +29,8 @@
|
|
30
29
|
"jest": "^29.7.0",
|
31
30
|
"ts-jest": "^29.2.5",
|
32
31
|
"typescript": "^5.6.3",
|
33
|
-
"@talismn/
|
34
|
-
"@talismn/
|
32
|
+
"@talismn/eslint-config": "0.0.3",
|
33
|
+
"@talismn/tsconfig": "0.0.2"
|
35
34
|
},
|
36
35
|
"eslintConfig": {
|
37
36
|
"root": true,
|