Skip to content

Commit

Permalink
[cli common] cli commitment parser considers solana config file
Browse files Browse the repository at this point in the history
  • Loading branch information
ochaloup committed Apr 12, 2024
1 parent 0fd5965 commit 25ae154
Showing 1 changed file with 15 additions and 9 deletions.
24 changes: 15 additions & 9 deletions packages/lib/cli-common/src/parsers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -276,23 +276,29 @@ export function parseClusterUrl(
return clusterUrl
}

export function parseCommitment(commitment: string): Commitment {
export function parseCommitment(commitment: string | undefined): Commitment {
let parsedCommitment: Commitment | undefined = undefined
if (commitment === 'processed') {
return 'processed'
parsedCommitment = 'processed'
} else if (commitment === 'confirmed') {
return 'confirmed'
parsedCommitment = 'confirmed'
} else if (commitment === 'finalized') {
return 'finalized'
parsedCommitment = 'finalized'
} else if (commitment === 'recent') {
return 'recent'
parsedCommitment = 'recent'
} else if (commitment === 'single') {
return 'single'
parsedCommitment = 'single'
} else if (commitment === 'singleGossip') {
return 'singleGossip'
parsedCommitment = 'singleGossip'
} else if (commitment === 'root') {
return 'root'
parsedCommitment = 'root'
} else if (commitment === 'max') {
return 'max'
parsedCommitment = 'max'
} else {
parsedCommitment = resolveSolanaConfig({}).commitment
}
if (parsedCommitment !== undefined) {
return parsedCommitment
} else {
throw new Error(
'Invalid value of --commitment: ' +
Expand Down

0 comments on commit 25ae154

Please sign in to comment.