Skip to content

Commit

Permalink
feat(cardano-services): implement provider selection based on env var…
Browse files Browse the repository at this point in the history
…iables and config
  • Loading branch information
ginnun committed Sep 10, 2024
1 parent 4466bed commit 6c8c97d
Show file tree
Hide file tree
Showing 6 changed files with 435 additions and 93 deletions.
1 change: 1 addition & 0 deletions packages/cardano-services/src/Program/options/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
export * from './providers';
export * from './common';
export * from './ogmios';
export * from './policyIds';
Expand Down
79 changes: 79 additions & 0 deletions packages/cardano-services/src/Program/options/providers.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
import { newOption } from './util';

export enum ProviderImplementation {
TYPEORM = 'typeorm',
BLOCKFROST = 'blockfrost',
DBSYNC = 'dbsync',
// Below ones are specific to TxSubmitProvider
SUBMIT_NODE = 'submit-node',
SUBMIT_API = 'submit-api'
}

export type ProviderImplementations = {
assetProvider?: ProviderImplementation;
rewardsProvider?: ProviderImplementation;
networkInfoProvider?: ProviderImplementation;
utxoProvider?: ProviderImplementation;
txSubmitProvider?: ProviderImplementation;
chainHistoryProvider?: ProviderImplementation;
stakePoolProvider?: ProviderImplementation;
};
export const ProviderImplementationDescription = 'Select one of the available provider implementations';
const argParser = (impl: string) => ProviderImplementation[impl.toUpperCase() as keyof typeof ProviderImplementation];
export const providerSelectionOptions = [
newOption(
'--asset-provider <implementation>',
ProviderImplementationDescription,
'ASSET_PROVIDER',
argParser,
ProviderImplementation.DBSYNC
)
.conflicts('useTypeormAssetProvider')
.choices([ProviderImplementation.BLOCKFROST, ProviderImplementation.DBSYNC, ProviderImplementation.TYPEORM]),
newOption(
'--stake-pool-provider <implementation>',
ProviderImplementationDescription,
'STAKE_POOL_PROVIDER',
argParser,
ProviderImplementation.DBSYNC
)
.conflicts('useTypeormStakePoolProvider')
.choices([ProviderImplementation.DBSYNC, ProviderImplementation.TYPEORM]),
newOption(
'--utxo-provider <implementation>',
ProviderImplementationDescription,
'UTXO_PROVIDER',
argParser,
ProviderImplementation.DBSYNC
).choices([ProviderImplementation.BLOCKFROST, ProviderImplementation.DBSYNC]),
newOption(
'--chain-history-provider <implementation>',
ProviderImplementationDescription,
'CHAIN_HISTORY_PROVIDER',
argParser,
ProviderImplementation.DBSYNC
).choices([ProviderImplementation.BLOCKFROST, ProviderImplementation.DBSYNC]),
newOption(
'--rewards-provider <implementation>',
ProviderImplementationDescription,
'REWARDS_PROVIDER',
argParser,
ProviderImplementation.DBSYNC
).choices([ProviderImplementation.BLOCKFROST, ProviderImplementation.DBSYNC]),
newOption(
'--network-info-provider <implementation>',
ProviderImplementationDescription,
'NETWORK_INFO_PROVIDER',
argParser,
ProviderImplementation.DBSYNC
).choices([ProviderImplementation.BLOCKFROST, ProviderImplementation.DBSYNC]),
newOption(
'--tx-submit-provider <implementation>',
ProviderImplementationDescription,
'TX_SUBMIT_PROVIDER',
argParser,
ProviderImplementation.SUBMIT_NODE
)
.conflicts('useSubmitApi')
.choices([ProviderImplementation.BLOCKFROST, ProviderImplementation.SUBMIT_API, ProviderImplementation.SUBMIT_NODE])
];
Loading

0 comments on commit 6c8c97d

Please sign in to comment.