-
Notifications
You must be signed in to change notification settings - Fork 58
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(cardano-services): implement provider selection based on env var…
…iables and config
- Loading branch information
Showing
6 changed files
with
435 additions
and
93 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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'; | ||
|
79 changes: 79 additions & 0 deletions
79
packages/cardano-services/src/Program/options/providers.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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]) | ||
]; |
Oops, something went wrong.