Skip to content

Commit 1057bda

Browse files
authored
[LW-11739] feat: blockfrost asset provider experiment (#1482)
* feat: direct to blockfrost asset provider experiment add new 'blockfrost-asset-provider' PostHog feature flag that replaces cardano-services asset provider with a new one that makes requests directly to Blockfrost. Lace use the original cardano-services provider as a fallback (if Blockfrost provider fails). Lace will still (regardless of feature flags) use the original cardano-services asset provider in dapp connector * chore: replace imports from @lace/cardano/dist with main package export
1 parent fc48338 commit 1057bda

File tree

30 files changed

+610
-34
lines changed

30 files changed

+610
-34
lines changed

.github/actions/build/app/action.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,15 @@ name: buildapp
22
description: Build app
33

44
inputs:
5+
BLOCKFROST_PROJECT_ID_MAINNET:
6+
description: 'MainNet Project ID for Blockfrost API usage'
7+
required: true
8+
BLOCKFROST_PROJECT_ID_PREPROD:
9+
description: 'PreProd Project ID for Blockfrost API usage'
10+
required: true
11+
BLOCKFROST_PROJECT_ID_PREVIEW:
12+
description: 'Preview Project ID for Blockfrost API usage'
13+
required: true
514
DIR:
615
description: 'app directory'
716
required: true
@@ -42,6 +51,9 @@ runs:
4251
shell: bash
4352
working-directory: ${{ inputs.DIR }}
4453
env:
54+
BLOCKFROST_PROJECT_ID_MAINNET: ${{ inputs.BLOCKFROST_PROJECT_ID_MAINNET }}
55+
BLOCKFROST_PROJECT_ID_PREPROD: ${{ inputs.BLOCKFROST_PROJECT_ID_PREPROD }}
56+
BLOCKFROST_PROJECT_ID_PREVIEW: ${{ inputs.BLOCKFROST_PROJECT_ID_PREVIEW }}
4557
LACE_EXTENSION_KEY: ${{ inputs.LACE_EXTENSION_KEY }}
4658
BUILD_DEV_PREVIEW: ${{ inputs.BUILD_DEV_PREVIEW }}
4759
POSTHOG_PRODUCTION_TOKEN: ${{ inputs.POSTHOG_PRODUCTION_TOKEN }}

.github/shared/build/action.yml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,18 @@ inputs:
2323
description: 'Banxa`s integration URL'
2424
required: false
2525
default: 'https://lacewallet.banxa-sandbox.com/'
26+
BLOCKFROST_PROJECT_ID_MAINNET:
27+
description: 'MainNet Project ID for Blockfrost API usage'
28+
required: true
29+
BLOCKFROST_PROJECT_ID_PREPROD:
30+
description: 'PreProd Project ID for Blockfrost API usage'
31+
required: true
32+
BLOCKFROST_PROJECT_ID_PREVIEW:
33+
description: 'Preview Project ID for Blockfrost API usage'
34+
required: true
35+
BLOCKFROST_PROJECT_ID_SANCHONET:
36+
description: 'SanchoNet Project ID for Blockfrost API usage'
37+
required: true
2638
CARDANO_SERVICES_URL_MAINNET:
2739
description: 'Url for mainnet env'
2840
required: false
@@ -107,6 +119,10 @@ runs:
107119
POSTHOG_PRODUCTION_TOKEN: ${{ inputs.POSTHOG_PRODUCTION_TOKEN }}
108120
PRODUCTION_MODE_TRACKING: ${{ inputs.PRODUCTION_MODE_TRACKING }}
109121
BANXA_LACE_URL: ${{ inputs.BANXA_LACE_URL }}
122+
BLOCKFROST_PROJECT_ID_MAINNET: ${{ inputs.BLOCKFROST_PROJECT_ID_MAINNET }}
123+
BLOCKFROST_PROJECT_ID_PREPROD: ${{ inputs.BLOCKFROST_PROJECT_ID_PREPROD }}
124+
BLOCKFROST_PROJECT_ID_PREVIEW: ${{ inputs.BLOCKFROST_PROJECT_ID_PREVIEW }}
125+
BLOCKFROST_PROJECT_ID_SANCHONET: ${{ inputs.BLOCKFROST_PROJECT_ID_SANCHONET }}
110126
CARDANO_SERVICES_URL_MAINNET: ${{ inputs.CARDANO_SERVICES_URL_MAINNET }}
111127
CARDANO_SERVICES_URL_PREPROD: ${{ inputs.CARDANO_SERVICES_URL_PREPROD }}
112128
CARDANO_SERVICES_URL_PREVIEW: ${{ inputs.CARDANO_SERVICES_URL_PREVIEW }}

.github/workflows/build-dev-preview.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,10 @@ jobs:
2222
- name: Build dev preview version of Lace
2323
uses: ./.github/shared/build
2424
with:
25+
BLOCKFROST_PROJECT_ID_MAINNET: ${{ secrets.BLOCKFROST_PROJECT_ID_MAINNET }}
26+
BLOCKFROST_PROJECT_ID_PREPROD: ${{ secrets.BLOCKFROST_PROJECT_ID_PREPROD }}
27+
BLOCKFROST_PROJECT_ID_PREVIEW: ${{ secrets.BLOCKFROST_PROJECT_ID_PREVIEW }}
28+
BLOCKFROST_PROJECT_ID_SANCHONET: ${{ secrets.BLOCKFROST_PROJECT_ID_SANCHONET }}
2529
BUILD_DEV_PREVIEW: 'true'
2630
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
2731
LACE_EXTENSION_KEY: ${{ secrets.DEV_PREVIEW_MANIFEST_PUBLIC_KEY }}

.github/workflows/ci.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,9 @@ jobs:
195195
- name: Build Lace browser extension
196196
uses: ./.github/actions/build/app
197197
with:
198+
BLOCKFROST_PROJECT_ID_MAINNET: ${{ secrets.BLOCKFROST_PROJECT_ID_MAINNET }}
199+
BLOCKFROST_PROJECT_ID_PREPROD: ${{ secrets.BLOCKFROST_PROJECT_ID_PREPROD }}
200+
BLOCKFROST_PROJECT_ID_PREVIEW: ${{ secrets.BLOCKFROST_PROJECT_ID_PREVIEW }}
198201
DIR: apps/browser-extension-wallet
199202
NAME: lace-browser-extension
200203
LACE_EXTENSION_KEY: ${{ secrets.MANIFEST_PUBLIC_KEY }}
@@ -215,6 +218,9 @@ jobs:
215218
with:
216219
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
217220
LACE_EXTENSION_KEY: ${{ secrets.MANIFEST_PUBLIC_KEY }}
221+
BLOCKFROST_PROJECT_ID_MAINNET: ${{ secrets.BLOCKFROST_PROJECT_ID_MAINNET }}
222+
BLOCKFROST_PROJECT_ID_PREPROD: ${{ secrets.BLOCKFROST_PROJECT_ID_PREPROD }}
223+
BLOCKFROST_PROJECT_ID_PREVIEW: ${{ secrets.BLOCKFROST_PROJECT_ID_PREVIEW }}
218224

219225
- name: Upload build artifact
220226
uses: actions/upload-artifact@v4

.github/workflows/e2e-tests-linux-split.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,9 @@ jobs:
176176
CARDANO_WS_SERVER_URL_MAINNET: 'wss://${{ env.CARDANO_MAINNET_URL }}'
177177
CARDANO_WS_SERVER_URL_PREPROD: 'wss://${{ env.CARDANO_PREPROD_URL }}'
178178
CARDANO_WS_SERVER_URL_PREVIEW: 'wss://${{ env.CARDANO_PREVIEW_URL }}'
179+
BLOCKFROST_PROJECT_ID_MAINNET: ${{ secrets.BLOCKFROST_PROJECT_ID_MAINNET }}
180+
BLOCKFROST_PROJECT_ID_PREPROD: ${{ secrets.BLOCKFROST_PROJECT_ID_PREPROD }}
181+
BLOCKFROST_PROJECT_ID_PREVIEW: ${{ secrets.BLOCKFROST_PROJECT_ID_PREVIEW }}
179182
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
180183
LACE_EXTENSION_KEY: ${{ secrets.MANIFEST_PUBLIC_KEY }}
181184

@@ -228,7 +231,7 @@ jobs:
228231
name: Process e2e test reports
229232
needs: [setup, tests]
230233
runs-on: ${{ needs.setup.outputs.runner }}
231-
# when cancelling job always() will prevent step from being cancelled and we don't want process results in this case
234+
# when cancelling job always() will prevent step from being cancelled and we don't want process results in this case
232235
if: ${{ success() || failure() }}
233236
steps:
234237
- name: Download all artifacts

apps/browser-extension-wallet/.env.defaults

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,13 +66,23 @@ CARDANO_SERVICES_URL_MAINNET=https://dev-mainnet.lw.iog.io
6666
CARDANO_SERVICES_URL_PREPROD=https://dev-preprod.lw.iog.io
6767
CARDANO_SERVICES_URL_PREVIEW=https://dev-preview.lw.iog.io
6868
CARDANO_SERVICES_URL_SANCHONET=https://dev-sanchonet.lw.iog.io
69+
BLOCKFROST_PROJECT_ID_MAINNET=mainnetprojectid
70+
BLOCKFROST_PROJECT_ID_PREPROD=preprodprojectid
71+
BLOCKFROST_PROJECT_ID_PREVIEW=previewprojectid
72+
BLOCKFROST_PROJECT_ID_SANCHONET=sanchonetprojectid
6973

7074
# Cardano WS Services
7175
CARDANO_WS_SERVER_URL_MAINNET=wss://dev-mainnet.lw.iog.io
7276
CARDANO_WS_SERVER_URL_PREPROD=wss://dev-preprod.lw.iog.io
7377
CARDANO_WS_SERVER_URL_PREVIEW=wss://dev-preview.lw.iog.io
7478
CARDANO_WS_SERVER_URL_SANCHONET=wss://dev-sanchonet.lw.iog.io
7579

80+
# Blockfrost
81+
BLOCKFROST_URL_MAINNET=https://cardano-mainnet.blockfrost.io
82+
BLOCKFROST_URL_PREPROD=https://cardano-preprod.blockfrost.io
83+
BLOCKFROST_URL_PREVIEW=https://cardano-preview.blockfrost.io
84+
BLOCKFROST_URL_SANCHONET=https://cardano-sanchonet.blockfrost.io
85+
7686
# Explorer URLs
7787
CEXPLORER_URL_MAINNET=https://cexplorer.io
7888
CEXPLORER_URL_PREVIEW=https://preview.cexplorer.io

apps/browser-extension-wallet/.env.example

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,9 @@ POSTHOG_PRODUCTION_TOKEN='production-token'
6060
POSTHOG_DEV_TOKEN='dev-token'
6161

6262
# Cardano Services
63-
CARDANO_SERVICES_URL_MAINNET=https://backend.live-mainnet.eks.lw.iog.io
64-
CARDANO_SERVICES_URL_PREPROD=https://backend.live-preprod.eks.lw.iog.io
65-
CARDANO_SERVICES_URL_PREVIEW=https://backend.live-preview.eks.lw.iog.io
63+
CARDANO_SERVICES_URL_MAINNET=https://dev-mainnet.lw.iog.io
64+
CARDANO_SERVICES_URL_PREPROD=https://dev-preprod.lw.iog.io
65+
CARDANO_SERVICES_URL_PREVIEW=https://dev-preview.lw.iog.io
6666
CARDANO_SERVICES_URL_SANCHONET=https://dev-sanchonet.lw.iog.io
6767

6868
# Cardano WS Services
@@ -71,6 +71,16 @@ CARDANO_WS_SERVER_URL_PREPROD=wss://dev-preprod.lw.iog.io
7171
CARDANO_WS_SERVER_URL_PREVIEW=wss://dev-preview.lw.iog.io
7272
CARDANO_WS_SERVER_URL_SANCHONET=wss://dev-sanchonet.lw.iog.io
7373

74+
# Blockfrost
75+
BLOCKFROST_URL_MAINNET=https://cardano-mainnet.blockfrost.io
76+
BLOCKFROST_URL_PREPROD=https://cardano-preprod.blockfrost.io
77+
BLOCKFROST_URL_PREVIEW=https://cardano-preview.blockfrost.io
78+
BLOCKFROST_URL_SANCHONET=https://cardano-sanchonet.blockfrost.io
79+
BLOCKFROST_PROJECT_ID_MAINNET=mainnet...TODO
80+
BLOCKFROST_PROJECT_ID_PREPROD=preprod...TODO
81+
BLOCKFROST_PROJECT_ID_PREVIEW=preview...TODO
82+
BLOCKFROST_PROJECT_ID_SANCHONET=sanchonet...TODO
83+
7484
# Explorer URLs
7585
CEXPLORER_URL_MAINNET=https://cexplorer.io
7686
CEXPLORER_URL_PREVIEW=https://preview.cexplorer.io

apps/browser-extension-wallet/manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
"permissions": ["webRequest", "storage", "tabs", "unlimitedStorage"],
2020
"host_permissions": ["<all_urls>"],
2121
"content_security_policy": {
22-
"extension_pages": "default-src 'self' $LOCALHOST_DEFAULT_SRC; frame-src https://connect.trezor.io/ https://www.youtube-nocookie.com; script-src 'self' 'wasm-unsafe-eval' $LOCALHOST_SCRIPT_SRC; font-src 'self' https://use.typekit.net; object-src 'self'; connect-src $CARDANO_SERVICES_URLS $CARDANO_WS_SERVER_URLS https://coingecko.live-mainnet.eks.lw.iog.io https://muesliswap.live-mainnet.eks.lw.iog.io $LOCALHOST_CONNECT_SRC $POSTHOG_HOST https://use.typekit.net data:; style-src * 'unsafe-inline'; img-src * data:;"
22+
"extension_pages": "default-src 'self' $LOCALHOST_DEFAULT_SRC; frame-src https://connect.trezor.io/ https://www.youtube-nocookie.com; script-src 'self' 'wasm-unsafe-eval' $LOCALHOST_SCRIPT_SRC; font-src 'self' https://use.typekit.net; object-src 'self'; connect-src $BLOCKFROST_URLS $CARDANO_SERVICES_URLS $CARDANO_WS_SERVER_URLS https://coingecko.live-mainnet.eks.lw.iog.io https://muesliswap.live-mainnet.eks.lw.iog.io $LOCALHOST_CONNECT_SRC $POSTHOG_HOST https://use.typekit.net data:; style-src * 'unsafe-inline'; img-src * data:;"
2323
},
2424
"content_scripts": [
2525
{

apps/browser-extension-wallet/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@
6767
"bignumber.js": "9.0.1",
6868
"bip39": "^3.0.4",
6969
"blake2b-no-wasm": "2.1.4",
70+
"bottleneck": "^2.19.5",
7071
"buffer": "6.0.3",
7172
"classnames": "2.3.1",
7273
"dayjs": "1.10.7",

apps/browser-extension-wallet/src/config.ts

Lines changed: 39 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
/* eslint-disable no-magic-numbers */
2+
import { Milliseconds } from '@cardano-sdk/core';
23
import { Wallet } from '@lace/cardano';
34
import { EnvironmentTypes } from '@stores';
45

5-
type CardanoServiceUrls = {
6-
[key in Wallet.ChainName]: string;
6+
type ByNetwork<T> = {
7+
[key in Wallet.ChainName]: T;
78
};
89

910
type CExplorerUrlPaths = {
@@ -18,7 +19,9 @@ export type Config = {
1819
MNEMONIC_LENGTH: number;
1920
WALLET_SYNC_TIMEOUT: number;
2021
WALLET_INTERVAL: number;
21-
CARDANO_SERVICES_URLS: CardanoServiceUrls;
22+
CARDANO_SERVICES_URLS: ByNetwork<string>;
23+
BLOCKFROST_CONFIGS: ByNetwork<Wallet.BlockfrostClientConfig>;
24+
BLOCKFROST_RATE_LIMIT_CONFIG: Wallet.RateLimiterConfig;
2225
ADA_PRICE_CHECK_INTERVAL: number;
2326
TOKEN_PRICE_CHECK_INTERVAL: number;
2427
AVAILABLE_CHAINS: Wallet.ChainName[];
@@ -33,7 +36,13 @@ const envChecks = (chosenChain: Wallet.ChainName): void => {
3336
if (
3437
!process.env.CARDANO_SERVICES_URL_MAINNET ||
3538
!process.env.CARDANO_SERVICES_URL_PREPROD ||
36-
!process.env.CARDANO_SERVICES_URL_PREVIEW
39+
!process.env.CARDANO_SERVICES_URL_PREVIEW ||
40+
!process.env.BLOCKFROST_URL_MAINNET ||
41+
!process.env.BLOCKFROST_URL_PREPROD ||
42+
!process.env.BLOCKFROST_URL_PREVIEW ||
43+
!process.env.BLOCKFROST_PROJECT_ID_MAINNET ||
44+
!process.env.BLOCKFROST_PROJECT_ID_PREPROD ||
45+
!process.env.BLOCKFROST_PROJECT_ID_PREVIEW
3746
) {
3847
throw new Error('env vars not complete');
3948
}
@@ -55,6 +64,25 @@ const envChecks = (chosenChain: Wallet.ChainName): void => {
5564
}
5665
};
5766

67+
const getBlockfrostConfigs = (): ByNetwork<Wallet.BlockfrostClientConfig> => ({
68+
Mainnet: {
69+
baseUrl: process.env.BLOCKFROST_URL_MAINNET,
70+
projectId: process.env.BLOCKFROST_PROJECT_ID_MAINNET
71+
},
72+
Preprod: {
73+
baseUrl: process.env.BLOCKFROST_URL_PREPROD,
74+
projectId: process.env.BLOCKFROST_PROJECT_ID_PREPROD
75+
},
76+
Preview: {
77+
baseUrl: process.env.BLOCKFROST_URL_PREVIEW,
78+
projectId: process.env.BLOCKFROST_PROJECT_ID_PREVIEW
79+
},
80+
Sanchonet: {
81+
baseUrl: process.env.BLOCKFROST_URL_SANCHONET,
82+
projectId: process.env.BLOCKFROST_PROJECT_ID_SANCHONET
83+
}
84+
});
85+
5886
export const config = (): Config => {
5987
const chosenChain = (process.env.DEFAULT_CHAIN || 'Mainnet') as Wallet.ChainName;
6088
if (process.env.BUILD_DEV_PREVIEW !== 'true') envChecks(chosenChain);
@@ -76,6 +104,13 @@ export const config = (): Config => {
76104
TOKEN_PRICE_CHECK_INTERVAL: !Number.isNaN(Number(process.env.TOKEN_PRICE_POLLING_IN_SEC))
77105
? Number(process.env.TOKEN_PRICE_POLLING_IN_SEC) * 1000
78106
: 300 * 1000,
107+
BLOCKFROST_CONFIGS: getBlockfrostConfigs(),
108+
BLOCKFROST_RATE_LIMIT_CONFIG: {
109+
size: 500,
110+
increaseAmount: 10,
111+
// eslint-disable-next-line new-cap
112+
increaseInterval: Milliseconds(1000)
113+
},
79114
CARDANO_SERVICES_URLS: {
80115
Mainnet: process.env.CARDANO_SERVICES_URL_MAINNET,
81116
Preprod: process.env.CARDANO_SERVICES_URL_PREPROD,

apps/browser-extension-wallet/src/lib/scripts/background/config.ts

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ import { BackgroundService, UserIdService as UserIdServiceInterface } from '../t
66
import { getBackgroundStorage } from '@lib/scripts/background/storage';
77
import { ExperimentName } from '@providers/ExperimentsProvider/types';
88
import { logger } from '@lace/common';
9+
import { config } from '@src/config';
10+
import Bottleneck from 'bottleneck';
911

1012
export const backgroundServiceProperties: RemoteApiProperties<BackgroundService> = {
1113
requestMessage$: RemoteApiPropertyType.HotObservable,
@@ -26,18 +28,35 @@ export const backgroundServiceProperties: RemoteApiProperties<BackgroundService>
2628
backendFailures$: RemoteApiPropertyType.HotObservable
2729
};
2830

31+
const { BLOCKFROST_CONFIGS, BLOCKFROST_RATE_LIMIT_CONFIG } = config();
32+
// Important to use the same rateLimiter object for all networks,
33+
// because Blockfrost rate limit is per IP address, not per project id
34+
const rateLimiter: Wallet.RateLimiter = new Bottleneck({
35+
reservoir: BLOCKFROST_RATE_LIMIT_CONFIG.size,
36+
reservoirIncreaseAmount: BLOCKFROST_RATE_LIMIT_CONFIG.increaseAmount,
37+
reservoirIncreaseInterval: BLOCKFROST_RATE_LIMIT_CONFIG.increaseInterval,
38+
reservoirIncreaseMaximum: BLOCKFROST_RATE_LIMIT_CONFIG.size
39+
});
40+
2941
export const getProviders = async (chainName: Wallet.ChainName): Promise<Wallet.WalletProvidersDependencies> => {
3042
const baseCardanoServicesUrl = getBaseUrlForChain(chainName);
3143
const magic = getMagicForChain(chainName);
3244
const { customSubmitTxUrl, featureFlags } = await getBackgroundStorage();
3345
const useWebSocket = !!(featureFlags?.[magic]?.[ExperimentName.WEBSOCKET_API] ?? false);
46+
const useBlockfrostAssetProvider = !!(featureFlags?.[magic]?.[ExperimentName.BLOCKFROST_ASSET_PROVIDER] ?? false);
3447

3548
return Wallet.createProviders({
3649
axiosAdapter: axiosFetchAdapter,
37-
baseUrl: baseCardanoServicesUrl,
38-
customSubmitTxUrl,
50+
env: {
51+
baseCardanoServicesUrl,
52+
customSubmitTxUrl,
53+
blockfrostConfig: {
54+
...BLOCKFROST_CONFIGS[chainName],
55+
rateLimiter
56+
}
57+
},
3958
logger,
40-
useWebSocket
59+
experiments: { useWebSocket, useBlockfrostAssetProvider }
4160
});
4261
};
4362

apps/browser-extension-wallet/src/providers/ExperimentsProvider/config.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@ export const getDefaultFeatureFlags = (): FallbackConfiguration => ({
55
[ExperimentName.RESTORE_PAPER_WALLET]: false,
66
[ExperimentName.USE_SWITCH_TO_NAMI_MODE]: false,
77
[ExperimentName.SHARED_WALLETS]: false,
8-
[ExperimentName.WEBSOCKET_API]: false
8+
[ExperimentName.WEBSOCKET_API]: false,
9+
[ExperimentName.BLOCKFROST_ASSET_PROVIDER]: false
910
});
1011

1112
export const experiments: ExperimentsConfig = {
@@ -28,5 +29,9 @@ export const experiments: ExperimentsConfig = {
2829
[ExperimentName.WEBSOCKET_API]: {
2930
value: false,
3031
default: false
32+
},
33+
[ExperimentName.BLOCKFROST_ASSET_PROVIDER]: {
34+
value: false,
35+
default: false
3136
}
3237
};

apps/browser-extension-wallet/src/providers/ExperimentsProvider/types.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@ export enum ExperimentName {
1010
RESTORE_PAPER_WALLET = 'restore-paper-wallet',
1111
USE_SWITCH_TO_NAMI_MODE = 'use-switch-to-nami-mode',
1212
SHARED_WALLETS = 'shared-wallets',
13-
WEBSOCKET_API = 'websocket-api'
13+
WEBSOCKET_API = 'websocket-api',
14+
BLOCKFROST_ASSET_PROVIDER = 'blockfrost-asset-provider'
1415
}
1516

1617
interface FeatureFlag {

apps/browser-extension-wallet/src/providers/PostHogClientProvider/client/PostHogClient.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,8 @@ type FeatureFlag =
3030
| 'restore-paper-wallet'
3131
| 'shared-wallets'
3232
| 'use-switch-to-nami-mode'
33-
| 'websocket-api';
33+
| 'websocket-api'
34+
| ExperimentName.BLOCKFROST_ASSET_PROVIDER;
3435

3536
type FeatureFlags = {
3637
[key in FeatureFlag]: boolean;

apps/browser-extension-wallet/src/stores/slices/blockchain-provider-slice.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,15 @@ export const IBlockchainProvider = {
4242
export const getProviderByChain: BlockchainProviderFactory = (chain = CHAIN) => {
4343
const baseCardanoServicesUrl = getBaseUrlForChain(chain);
4444

45+
// TODO: LW-11761 reuse providers that are running in SW instead
4546
const providers = Wallet.createProviders({
4647
axiosAdapter: axiosFetchAdapter,
47-
baseUrl: baseCardanoServicesUrl
48+
env: {
49+
baseCardanoServicesUrl,
50+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
51+
blockfrostConfig: {} as any
52+
},
53+
experiments: {}
4854
});
4955

5056
return IBlockchainProvider.fromWalletProviders(providers);

apps/browser-extension-wallet/src/views/browser-view/features/multi-wallet/restore-wallet/context.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,13 @@ import { deleteFromLocalStorage } from '@utils/local-storage';
1111
import { RecoveryMethod } from '../types';
1212
import { usePostHogClientContext } from '@providers/PostHogClientProvider';
1313
import { ShieldedPgpKeyData } from '@src/types';
14-
import { ChainName } from '@lace/cardano/dist/wallet';
14+
import { Wallet } from '@lace/cardano';
1515

1616
type OnNameChange = (state: { name: string }) => void;
1717
type OnRecoveryPhraseLengthChange = (length: RecoveryPhraseLength) => void;
1818
type WalletSummaryInfo = {
1919
address: string;
20-
chain: ChainName;
20+
chain: Wallet.ChainName;
2121
};
2222

2323
interface State {

0 commit comments

Comments
 (0)