Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions .github/workflows/pull-request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:

- run: yarn test

- run: npx github-actions-ctrf summary ctrf/ctrf-report.json --pull-request
- run: npx github-actions-ctrf@0.0.54 summary ctrf/ctrf-report.json --pull-request
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

Expand All @@ -37,4 +37,3 @@ jobs:

- name: smoke test image
run: docker run -i ${{secrets.DOCKER_USER}}/tatum-kms:latest --help

6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
## [8.0.1] - April 2025

### Added

- Filtering for "run once" mode, configuration of wallets and transaction ids to fetch and sign

## [8.0.0] - January 2025

### Updated
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@tatumio/tatum-kms",
"version": "8.0.0",
"version": "8.0.1",
"description": "Tatum KMS - Key Management System for Tatum-powered apps.",
"main": "dist/index.js",
"types": "./dist/index.d.ts",
Expand Down
16 changes: 12 additions & 4 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,8 @@ const optionsConst = `
--externalUrl Pass in external url to check valid transaction. This parameter is mandatory for mainnet (if testnet is false). Daemon mode only.
--externalUrlMethod Determine what http method to use when calling the url passed in the --externalUrl option. Accepts GET or POST. Defaults to GET method. Daemon mode only.
--runOnce Run the daemon command one time. Check for a new transactions to sign once, and then exit the process. Daemon mode only.
--wallets If runOnce enabled, fetch and sign only for these wallet ids.
--transactionIds If runOnce enabled, sign only transactions from defined comma-separated list.
`

const getPasswordType = (flags: Partial<{ aws: boolean; azure: boolean; vgs: boolean }>): PasswordType => {
Expand Down Expand Up @@ -141,11 +143,15 @@ const startup = async () => {
type: 'boolean',
default: false,
},
wallets: {
type: 'string'
},
transactionIds: {
type: 'string',
},
},
})



const envFilePath = (flags.envFile) ?? homedir() + '/.tatumrc/.env'
if (existsSync(envFilePath)) {
dotenv.config({ path: envFilePath })
Expand All @@ -170,6 +176,8 @@ const startup = async () => {
flags.externalUrlMethod as ExternalUrlMethod,
flags.period as number,
flags.runOnce as boolean,
(flags.wallets as string)?.split(','),
(flags.transactionIds as string)?.split(','),
)
break
}
Expand Down Expand Up @@ -232,8 +240,8 @@ const startup = async () => {
case 'report':
await report(
utils.csvToArray(command[1]),
getPasswordType(),
await getPassword(getPasswordType(), axiosInstance),
getPasswordType(flags),
await getPassword(getPasswordType(flags), axiosInstance),
flags.path,
)
break
Expand Down
18 changes: 15 additions & 3 deletions src/signatures.ts
Original file line number Diff line number Diff line change
Expand Up @@ -589,6 +589,8 @@ export const processSignatures = async (
externalUrlMethod?: ExternalUrlMethod,
period = 5,
runOnce?: boolean,
wallets?: string[],
transactionIds?: string[],
) => {
let running = false
const supportedChains = chains || [
Expand Down Expand Up @@ -617,7 +619,7 @@ export const processSignatures = async (
]

if (runOnce) {
await processPendingTransactions(supportedChains, pwd, testnet, path, axios, externalUrl, externalUrlMethod)
await processPendingTransactions(supportedChains, pwd, testnet, path, axios, externalUrl, externalUrlMethod, wallets, transactionIds)
return
}

Expand All @@ -641,19 +643,25 @@ async function processPendingTransactions(
axios: AxiosInstance,
externalUrl: string | undefined,
externalUrlMethod: ExternalUrlMethod | undefined,
wallets?: string[],
transactionIds?: string[],
) {
const transactions = []
try {
for (const supportedChain of supportedChains) {
const wallets = getManagedWallets(pwd, supportedChain, testnet, path)
transactions.push(...(await getPendingTransactions(axios, supportedChain, wallets)))
const walletsToProcess = wallets || getManagedWallets(pwd, supportedChain, testnet, path)
transactions.push(...(await getPendingTransactions(axios, supportedChain, walletsToProcess)))
}
} catch (e) {
console.error(e)
}
const data = []
for (const transaction of transactions) {
try {
if (isTransactionIdExcluded(transaction, transactionIds)) {
console.log(`${new Date().toISOString()} - Tx processing skipped: ${transaction.id}. Expected one of: ${transactionIds?.join(', ')}`);
continue;
}
await processTransaction(transaction, testnet, pwd, axios, path, externalUrl, externalUrlMethod)
console.log(`${new Date().toISOString()} - Tx was processed: ${transaction.id}`)
} catch (e) {
Expand All @@ -675,6 +683,10 @@ async function processPendingTransactions(
}
}

function isTransactionIdExcluded(transaction: TransactionKMS, transactionIds?: string[]) {
return transactionIds && !transactionIds.includes(transaction.id)
}

function isValidNumber(value: number | undefined): boolean {
return !_.isNil(value) && _.isNumber(value) && _.isFinite(value)
}
Expand Down