Skip to content

Commit

Permalink
refactor: bump cardano-js-sdk versions and utilize it's BlockfrostAss…
Browse files Browse the repository at this point in the history
…etProvder (#1539)

lace implementation was hoisted to cardano-js-sdk for some free test coverage
  • Loading branch information
mkazlauskas authored Nov 14, 2024
1 parent 1267f50 commit 953b087
Show file tree
Hide file tree
Showing 15 changed files with 74 additions and 394 deletions.
6 changes: 3 additions & 3 deletions apps/browser-extension-wallet/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,15 +41,15 @@
},
"dependencies": {
"@ant-design/icons": "^4.7.0",
"@cardano-sdk/cardano-services-client": "0.21.7",
"@cardano-sdk/cardano-services-client": "0.22.0",
"@cardano-sdk/core": "0.41.2",
"@cardano-sdk/dapp-connector": "0.12.42",
"@cardano-sdk/input-selection": "0.13.25",
"@cardano-sdk/tx-construction": "0.21.10",
"@cardano-sdk/util": "0.15.5",
"@cardano-sdk/util-rxjs": "0.7.38",
"@cardano-sdk/wallet": "0.44.17",
"@cardano-sdk/web-extension": "0.34.16",
"@cardano-sdk/wallet": "0.44.18",
"@cardano-sdk/web-extension": "0.34.17",
"@emurgo/cip14-js": "~3.0.1",
"@input-output-hk/lace-ui-toolkit": "1.21.0",
"@lace/cardano": "0.1.0",
Expand Down
7 changes: 5 additions & 2 deletions apps/browser-extension-wallet/src/config.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/* eslint-disable no-magic-numbers */
import { BlockfrostClientConfig } from '@cardano-sdk/cardano-services-client';
import { Milliseconds } from '@cardano-sdk/core';
import { Wallet } from '@lace/cardano';
import { EnvironmentTypes } from '@stores';
Expand All @@ -13,14 +14,16 @@ type CExplorerUrlPaths = {
Policy: string;
};

type BlockfrostEndpoint = Omit<BlockfrostClientConfig, 'apiVersion'>;

export type Config = {
TOAST_DURATION: number;
CHAIN: Wallet.ChainName;
MNEMONIC_LENGTH: number;
WALLET_SYNC_TIMEOUT: number;
WALLET_INTERVAL: number;
CARDANO_SERVICES_URLS: ByNetwork<string>;
BLOCKFROST_CONFIGS: ByNetwork<Wallet.BlockfrostClientConfig>;
BLOCKFROST_CONFIGS: ByNetwork<BlockfrostEndpoint>;
BLOCKFROST_RATE_LIMIT_CONFIG: Wallet.RateLimiterConfig;
ADA_PRICE_CHECK_INTERVAL: number;
TOKEN_PRICE_CHECK_INTERVAL: number;
Expand Down Expand Up @@ -64,7 +67,7 @@ const envChecks = (chosenChain: Wallet.ChainName): void => {
}
};

const getBlockfrostConfigs = (): ByNetwork<Wallet.BlockfrostClientConfig> => ({
const getBlockfrostConfigs = (): ByNetwork<BlockfrostEndpoint> => ({
Mainnet: {
baseUrl: process.env.BLOCKFROST_URL_MAINNET,
projectId: process.env.BLOCKFROST_PROJECT_ID_MAINNET
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { ExperimentName } from '@providers/ExperimentsProvider/types';
import { logger } from '@lace/common';
import { config } from '@src/config';
import Bottleneck from 'bottleneck';
import { RateLimiter } from '@cardano-sdk/cardano-services-client';

export const backgroundServiceProperties: RemoteApiProperties<BackgroundService> = {
requestMessage$: RemoteApiPropertyType.HotObservable,
Expand All @@ -31,7 +32,7 @@ export const backgroundServiceProperties: RemoteApiProperties<BackgroundService>
const { BLOCKFROST_CONFIGS, BLOCKFROST_RATE_LIMIT_CONFIG } = config();
// Important to use the same rateLimiter object for all networks,
// because Blockfrost rate limit is per IP address, not per project id
const rateLimiter: Wallet.RateLimiter = new Bottleneck({
const rateLimiter: RateLimiter = new Bottleneck({
reservoir: BLOCKFROST_RATE_LIMIT_CONFIG.size,
reservoirIncreaseAmount: BLOCKFROST_RATE_LIMIT_CONFIG.increaseAmount,
reservoirIncreaseInterval: BLOCKFROST_RATE_LIMIT_CONFIG.increaseInterval,
Expand All @@ -52,7 +53,8 @@ export const getProviders = async (chainName: Wallet.ChainName): Promise<Wallet.
customSubmitTxUrl,
blockfrostConfig: {
...BLOCKFROST_CONFIGS[chainName],
rateLimiter
rateLimiter,
apiVersion: 'v0'
}
},
logger,
Expand Down
8 changes: 4 additions & 4 deletions packages/cardano/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,16 +40,16 @@
"watch": "yarn build --watch"
},
"dependencies": {
"@cardano-sdk/cardano-services-client": "0.21.7",
"@cardano-sdk/cardano-services-client": "0.22.0",
"@cardano-sdk/core": "0.41.2",
"@cardano-sdk/crypto": "0.1.30",
"@cardano-sdk/hardware-ledger": "0.12.10",
"@cardano-sdk/hardware-trezor": "0.6.9",
"@cardano-sdk/key-management": "0.24.8",
"@cardano-sdk/tx-construction": "0.21.10",
"@cardano-sdk/util": "0.15.5",
"@cardano-sdk/wallet": "0.44.17",
"@cardano-sdk/web-extension": "0.34.16",
"@cardano-sdk/wallet": "0.44.18",
"@cardano-sdk/web-extension": "0.34.17",
"@lace/common": "0.1.0",
"@ledgerhq/devices": "^8.2.1",
"@stablelib/chacha20poly1305": "1.0.1",
Expand All @@ -73,7 +73,7 @@
},
"devDependencies": {
"@blockfrost/blockfrost-js": "^5.5.0",
"@cardano-sdk/util-dev": "0.23.9",
"@cardano-sdk/util-dev": "0.23.10",
"@emurgo/cardano-message-signing-browser": "1.0.1",
"@types/webextension-polyfill": "0.10.0",
"axios": "^1.7.4",
Expand Down
1 change: 0 additions & 1 deletion packages/cardano/src/wallet/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,6 @@ export * from '@wallet/lib/get-auxiliary-data';
export * as util from '@wallet/util';
export * from '@wallet/lib/providers';
export * from '@wallet/lib/config';
export type { BlockfrostClientConfig, RateLimiter } from '@wallet/lib/blockfrost';

export * as mockUtils from '@wallet/test/mocks';
export * from '@wallet/types';

This file was deleted.

75 changes: 0 additions & 75 deletions packages/cardano/src/wallet/lib/blockfrost/blockfrost-client.ts

This file was deleted.

Loading

0 comments on commit 953b087

Please sign in to comment.