Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expose helper functions #38

Merged
merged 1 commit into from
May 22, 2024
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
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@coinbase/staking-client-library-ts",
"version": "0.8.1",
"version": "0.8.2",
"description": "Coinbase Staking API Typescript Library",
"repository": "https://github.com/coinbase/staking-client-library-ts.git",
"license": "Apache-2.0",
Expand All @@ -10,8 +10,8 @@
"clean-gen": "rm -rf src/gen/*",
"build": "npm run clean && tsc",
"prepare": "npm run build",
"lint": "eslint . --ext .ts --ignore-pattern '/dist/*/*' --ignore-pattern '/src/gen/*/*'",
"lint-fix": "eslint . --ext .ts --fix --ignore-pattern '/dist/*/*' --ignore-pattern '/src/gen/*/*'"
"lint": "eslint . --ext .ts --ignore-pattern 'dist/**/*' --ignore-pattern 'src/gen/**/*'",
"lint-fix": "eslint . --ext .ts --fix --ignore-pattern 'dist/**/*' --ignore-pattern 'src/gen/**/*'"
},
"publishConfig": {
"access": "public",
Expand Down
20 changes: 20 additions & 0 deletions src/client/staking-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -337,6 +337,26 @@ export function isWaitStepOutput(
return (step as WorkflowStep).waitStepOutput !== undefined;
}

export function getUnsignedTx(workflow: Workflow): string {
if (workflow.steps === undefined) {
throw new Error('No steps found in workflow');
}

if (workflow.currentStepId === undefined) {
throw new Error('No current step found in workflow');
}

if (workflow.steps[workflow.currentStepId].txStepOutput === undefined) {
throw new Error(
`No txStepOutput found in workflow step ${workflow.currentStepId}`,
);
}

return <string>(
workflow.steps[workflow.currentStepId].txStepOutput?.unsignedTx
);
}

async function getAuthDetails(
url: string,
path: string,
Expand Down
11 changes: 10 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,13 @@ import * as Utils from './utils/date';

export { Utils };

export { StakingClient } from './client/staking-client';
export {
StakingClient,
workflowHasFinished,
workflowWaitingForExternalBroadcast,
isTxStepOutput,
isWaitStepOutput,
getUnsignedTx,
} from './client/staking-client';

export { TxSignerFactory } from './signers';
Loading