From 59d6083dbc1c565498a8f61b26ddbc9fdb053ffc Mon Sep 17 00:00:00 2001 From: Rhys Bartels-Waller Date: Sat, 16 Nov 2024 19:31:46 +0000 Subject: [PATCH] refactor: move BlockfrostToCore into client package --- packages/cardano-services-client/package.json | 1 + .../src/blockfrost}/BlockfrostToCore.ts | 0 .../src/blockfrost/index.ts | 1 + packages/cardano-services-client/src/index.ts | 1 + .../BlockfrostChainHistoryProvider.ts | 15 +++++++-------- .../BlockfrostUtxoProvider.ts | 3 ++- .../src/util/BlockfrostProvider/index.ts | 1 - yarn.lock | 1 + 8 files changed, 13 insertions(+), 10 deletions(-) rename packages/{cardano-services/src/util/BlockfrostProvider => cardano-services-client/src/blockfrost}/BlockfrostToCore.ts (100%) diff --git a/packages/cardano-services-client/package.json b/packages/cardano-services-client/package.json index 8db35ffed36..1f541b9af7d 100644 --- a/packages/cardano-services-client/package.json +++ b/packages/cardano-services-client/package.json @@ -58,6 +58,7 @@ "dependencies": { "@blockfrost/blockfrost-js": "^5.7.0", "@cardano-sdk/core": "workspace:~", + "@cardano-sdk/crypto": "workspace:~", "@cardano-sdk/util": "workspace:~", "axios": "^1.7.4", "class-validator": "^0.14.0", diff --git a/packages/cardano-services/src/util/BlockfrostProvider/BlockfrostToCore.ts b/packages/cardano-services-client/src/blockfrost/BlockfrostToCore.ts similarity index 100% rename from packages/cardano-services/src/util/BlockfrostProvider/BlockfrostToCore.ts rename to packages/cardano-services-client/src/blockfrost/BlockfrostToCore.ts diff --git a/packages/cardano-services-client/src/blockfrost/index.ts b/packages/cardano-services-client/src/blockfrost/index.ts index aac30266f61..7efa82dd88d 100644 --- a/packages/cardano-services-client/src/blockfrost/index.ts +++ b/packages/cardano-services-client/src/blockfrost/index.ts @@ -1,3 +1,4 @@ export * from './BlockfrostProvider'; export * from './BlockfrostClient'; +export * from './BlockfrostToCore'; export * from './const'; diff --git a/packages/cardano-services-client/src/index.ts b/packages/cardano-services-client/src/index.ts index a7230d0fec0..3631157bb71 100644 --- a/packages/cardano-services-client/src/index.ts +++ b/packages/cardano-services-client/src/index.ts @@ -1,4 +1,5 @@ export * from './AssetInfoProvider'; +export * from './blockfrost/BlockfrostToCore'; export * from './HttpProvider'; export * from './TxSubmitProvider'; export * from './StakePoolProvider'; diff --git a/packages/cardano-services/src/ChainHistory/BlockrostChainHistoryProvider/BlockfrostChainHistoryProvider.ts b/packages/cardano-services/src/ChainHistory/BlockrostChainHistoryProvider/BlockfrostChainHistoryProvider.ts index bc75fee397f..c9fc7e284f3 100644 --- a/packages/cardano-services/src/ChainHistory/BlockrostChainHistoryProvider/BlockfrostChainHistoryProvider.ts +++ b/packages/cardano-services/src/ChainHistory/BlockrostChainHistoryProvider/BlockfrostChainHistoryProvider.ts @@ -1,14 +1,7 @@ // eslint-disable-next-line jsdoc/check-param-names import * as Crypto from '@cardano-sdk/crypto'; import { BlockfrostProvider, BlockfrostProviderDependencies } from '../../util/BlockfrostProvider/BlockfrostProvider'; -import { - BlockfrostToCore, - BlockfrostTransactionContent, - blockfrostMetadataToTxMetadata, - blockfrostToProviderError, - fetchByAddressSequentially, - isBlockfrostNotFoundError -} from '../../util'; +import { BlockfrostToCore, BlockfrostTransactionContent } from '@cardano-sdk/cardano-services-client'; import { BlocksByIdsArgs, Cardano, @@ -25,6 +18,12 @@ import { import { DB_MAX_SAFE_INTEGER } from '../DbSyncChainHistory/queries'; import { Responses } from '@blockfrost/blockfrost-js'; import { Schemas } from '@blockfrost/blockfrost-js/lib/types/open-api'; +import { + blockfrostMetadataToTxMetadata, + blockfrostToProviderError, + fetchByAddressSequentially, + isBlockfrostNotFoundError +} from '../../util'; import omit from 'lodash/omit.js'; type WithCertIndex = T & { cert_index: number }; diff --git a/packages/cardano-services/src/Utxo/BlockfrostUtxoProvider/BlockfrostUtxoProvider.ts b/packages/cardano-services/src/Utxo/BlockfrostUtxoProvider/BlockfrostUtxoProvider.ts index cdffc7f872b..c07237b9046 100644 --- a/packages/cardano-services/src/Utxo/BlockfrostUtxoProvider/BlockfrostUtxoProvider.ts +++ b/packages/cardano-services/src/Utxo/BlockfrostUtxoProvider/BlockfrostUtxoProvider.ts @@ -1,9 +1,10 @@ import { BlockfrostProvider } from '../../util/BlockfrostProvider/BlockfrostProvider'; -import { BlockfrostToCore, blockfrostToProviderError, fetchByAddressSequentially } from '../../util'; +import { BlockfrostToCore } from '@cardano-sdk/cardano-services-client'; import { Cardano, Serialization, UtxoByAddressesArgs, UtxoProvider } from '@cardano-sdk/core'; import { PaginationOptions } from '@blockfrost/blockfrost-js/lib/types'; import { Responses } from '@blockfrost/blockfrost-js'; import { Schemas } from '@blockfrost/blockfrost-js/lib/types/open-api'; +import { blockfrostToProviderError, fetchByAddressSequentially } from '../../util'; export class BlockfrostUtxoProvider extends BlockfrostProvider implements UtxoProvider { protected async fetchUtxos(addr: Cardano.PaymentAddress, pagination: PaginationOptions): Promise { diff --git a/packages/cardano-services/src/util/BlockfrostProvider/index.ts b/packages/cardano-services/src/util/BlockfrostProvider/index.ts index 0dac8bcb3d0..2695171bf0a 100644 --- a/packages/cardano-services/src/util/BlockfrostProvider/index.ts +++ b/packages/cardano-services/src/util/BlockfrostProvider/index.ts @@ -1,3 +1,2 @@ export * from './BlockfrostClientFactory'; -export * from './BlockfrostToCore'; export * from './blockfrostUtil'; diff --git a/yarn.lock b/yarn.lock index bdb0ade911f..facf4dba4eb 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3414,6 +3414,7 @@ __metadata: dependencies: "@blockfrost/blockfrost-js": ^5.7.0 "@cardano-sdk/core": "workspace:~" + "@cardano-sdk/crypto": "workspace:~" "@cardano-sdk/util": "workspace:~" "@cardano-sdk/util-dev": "workspace:~" "@types/lodash": ^4.14.182