Skip to content

Commit

Permalink
Expose helper functions to help get an e2e stake tx done very easily
Browse files Browse the repository at this point in the history
  • Loading branch information
drohit-cb committed May 21, 2024
1 parent 3749194 commit 186e170
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 4 deletions.
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.

2 changes: 1 addition & 1 deletion 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 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';

0 comments on commit 186e170

Please sign in to comment.