diff --git a/docs/openapi/orchestration.swagger.json b/docs/openapi/orchestration.swagger.json index 39d3a86..a7e0b19 100644 --- a/docs/openapi/orchestration.swagger.json +++ b/docs/openapi/orchestration.swagger.json @@ -1283,18 +1283,17 @@ "STATE_UNSPECIFIED", "STATE_NOT_CONSTRUCTED", "STATE_CONSTRUCTED", - "STATE_PENDING_SIGNING", + "STATE_PENDING_EXT_BROADCAST", "STATE_SIGNED", "STATE_BROADCASTING", "STATE_CONFIRMING", "STATE_CONFIRMED", "STATE_FINALIZED", "STATE_FAILED", - "STATE_SUCCESS", - "STATE_PENDING_EXT_BROADCAST" + "STATE_SUCCESS" ], "default": "STATE_UNSPECIFIED", - "description": "State defines an enumeration of states for a staking transaction.\n\n - STATE_UNSPECIFIED: Unspecified transaction state, this is for backwards compatibility.\n - STATE_NOT_CONSTRUCTED: Tx has not yet been constructed in the backend.\n - STATE_CONSTRUCTED: Tx construction is over in the backend.\n - STATE_PENDING_SIGNING: Tx is waiting to be signed.\n - STATE_SIGNED: Tx has been signed and returned to the backend.\n - STATE_BROADCASTING: Tx is being broadcasted to the network.\n - STATE_CONFIRMING: Tx is waiting for confirmation.\n - STATE_CONFIRMED: Tx has been confirmed to be included in a block.\n - STATE_FINALIZED: Tx has been finalized.\n - STATE_FAILED: Tx construction or broadcasting failed.\n - STATE_SUCCESS: Tx has been successfully executed.\n - STATE_PENDING_EXT_BROADCAST: Tx is waiting to be externally broadcasted by the customer." + "description": "State defines an enumeration of states for a staking transaction.\n\n - STATE_UNSPECIFIED: Unspecified transaction state, this is for backwards compatibility.\n - STATE_NOT_CONSTRUCTED: Tx has not yet been constructed in the backend.\n - STATE_CONSTRUCTED: Tx construction is over in the backend.\n - STATE_PENDING_EXT_BROADCAST: Tx is waiting to be externally broadcasted by the customer.\n - STATE_SIGNED: Tx has been signed and returned to the backend.\n - STATE_BROADCASTING: Tx is being broadcasted to the network.\n - STATE_CONFIRMING: Tx is waiting for confirmation.\n - STATE_CONFIRMED: Tx has been confirmed to be included in a block.\n - STATE_FINALIZED: Tx has been finalized.\n - STATE_FAILED: Tx construction or broadcasting failed.\n - STATE_SUCCESS: Tx has been successfully executed." }, "v1Validator": { "type": "object", @@ -1435,10 +1434,6 @@ "description": "The timestamp the workflow was last updated.", "readOnly": true }, - "skipBroadcast": { - "type": "boolean", - "description": "Flag to skip tx broadcast to network on behalf of the user. Use this flag if you instead prefer to broadcast signed txs on your own." - }, "completeTime": { "type": "string", "format": "date-time", @@ -1458,13 +1453,12 @@ "enum": [ "STATE_UNSPECIFIED", "STATE_IN_PROGRESS", - "STATE_WAITING_FOR_SIGNING", + "STATE_WAITING_FOR_EXT_BROADCAST", "STATE_COMPLETED", - "STATE_FAILED", - "STATE_WAITING_FOR_EXT_BROADCAST" + "STATE_FAILED" ], "default": "STATE_UNSPECIFIED", - "description": "Example flow: A workflow with skip_broadcast = true leading to a successful completion.\n IN_PROGRESS -\u003e WAITING_FOR_EXT_BROADCAST -\u003e IN_PROGRESS -\u003e COMPLETED\n Example flow: A workflow with skip_broadcast = false leading to a successful completion.\n IN_PROGRESS -\u003e WAITING_FOR_SIGNING -\u003e IN_PROGRESS -\u003e COMPLETED\n Example flow: A workflow with skip_broadcast = false leading to a failure.\n IN_PROGRESS -\u003e WAITING_FOR_SIGNING -\u003e IN_PROGRESS -\u003e FAILED\n\n - STATE_UNSPECIFIED: Unspecified workflow state, this is for backwards compatibility.\n - STATE_IN_PROGRESS: In Progress represents a workflow that is currently in progress.\n - STATE_WAITING_FOR_SIGNING: Waiting for signing represents the workflow is waiting on the consumer to sign and return the corresponding signed tx.\n - STATE_COMPLETED: Completed represents the workflow has completed.\n - STATE_FAILED: Failed represents the workflow has failed.\n - STATE_WAITING_FOR_EXT_BROADCAST: Waiting for external broadcast represents the workflow is waiting for the customer to broadcast a tx and return its corresponding tx hash.", + "description": "Example flows:\n A workflow leading to a successful completion.\n IN_PROGRESS -\u003e WAITING_FOR_EXT_BROADCAST -\u003e IN_PROGRESS -\u003e COMPLETED\n A workflow leading to a failure.\n IN_PROGRESS -\u003e WAITING_FOR_EXT_BROADCAST -\u003e IN_PROGRESS -\u003e FAILED\n\n - STATE_UNSPECIFIED: Unspecified workflow state, this is for backwards compatibility.\n - STATE_IN_PROGRESS: In Progress represents a workflow that is currently in progress.\n - STATE_WAITING_FOR_EXT_BROADCAST: Waiting for external broadcast represents the workflow is waiting for the customer to broadcast a tx and return its corresponding tx hash.\n - STATE_COMPLETED: Completed represents the workflow has completed.\n - STATE_FAILED: Failed represents the workflow has failed.", "title": "The state of a workflow" }, "v1WorkflowStep": { diff --git a/examples/ethereum/create-and-process-workflow.ts b/examples/ethereum/create-and-process-workflow.ts index d5a671f..f81ad87 100644 --- a/examples/ethereum/create-and-process-workflow.ts +++ b/examples/ethereum/create-and-process-workflow.ts @@ -2,7 +2,6 @@ import { TxSignerFactory } from '../../src/signers'; import { StakingClient, workflowHasFinished, - workflowWaitingForSigning, workflowWaitingForExternalBroadcast, isTxStepOutput, isWaitStepOutput, @@ -38,7 +37,6 @@ async function stakePartialEth(): Promise { workflow = await client.Ethereum.stake( projectId, network, - false, stakerAddress, integrationAddress, amount, @@ -80,7 +78,7 @@ async function stakePartialEth(): Promise { await printWorkflowProgressDetails(workflow); - if (workflowWaitingForSigning(workflow)) { + if (workflowWaitingForExternalBroadcast(workflow)) { unsignedTx = workflow.steps![currentStepId].txStepOutput?.unsignedTx || ''; if (unsignedTx === '') { @@ -92,18 +90,9 @@ async function stakePartialEth(): Promise { console.log('Signing unsigned tx %s ...', unsignedTx); const signedTx = await signer.signTransaction(privateKey, unsignedTx); - console.log('Returning back signed tx %s ...', signedTx); - - workflow = await client.performWorkflowStep( - projectId, - workflowId, - currentStepId, - signedTx, - ); - } else if (workflowWaitingForExternalBroadcast(workflow)) { console.log( - 'Please sign and broadcast this unsigned tx %s externally and return back the tx hash via the PerformWorkflowStep API ...', - unsignedTx, + 'Please broadcast this signed tx %s externally and return back the tx hash via the PerformWorkflowStep API ...', + signedTx, ); break; } else if (workflowHasFinished(workflow)) { diff --git a/examples/ethereum/create-workflow.ts b/examples/ethereum/create-workflow.ts index d1595d0..60704f3 100644 --- a/examples/ethereum/create-workflow.ts +++ b/examples/ethereum/create-workflow.ts @@ -23,7 +23,6 @@ async function stakePartialEth(): Promise { workflow = await client.Ethereum.stake( projectId, network, - true, stakerAddress, integrationAddress, amount, diff --git a/examples/solana/create-and-process-workflow.ts b/examples/solana/create-and-process-workflow.ts index 31632a1..a88dba4 100644 --- a/examples/solana/create-and-process-workflow.ts +++ b/examples/solana/create-and-process-workflow.ts @@ -2,7 +2,6 @@ import { TxSignerFactory } from '../../src/signers'; import { StakingClient, workflowHasFinished, - workflowWaitingForSigning, workflowWaitingForExternalBroadcast, isTxStepOutput, isWaitStepOutput, @@ -38,7 +37,6 @@ async function stakeSolana(): Promise { workflow = await client.Solana.stake( projectId, network, - true, walletAddress, validatorAddress, amount, @@ -83,7 +81,7 @@ async function stakeSolana(): Promise { await printWorkflowProgressDetails(workflow); - if (workflowWaitingForSigning(workflow)) { + if (workflowWaitingForExternalBroadcast(workflow)) { unsignedTx = workflow.steps![currentStepId].txStepOutput?.unsignedTx || ''; if (unsignedTx === '') { @@ -95,27 +93,6 @@ async function stakeSolana(): Promise { console.log('Signing unsigned tx %s ...', unsignedTx); const signedTx = await signer.signTransaction(privateKey, unsignedTx); - console.log('Returning back signed tx %s ...', signedTx); - - workflow = await client.performWorkflowStep( - projectId, - workflowId, - currentStepId, - signedTx, - ); - } else if (workflowWaitingForExternalBroadcast(workflow)) { - unsignedTx = - workflow.steps![currentStepId].txStepOutput?.unsignedTx || ''; - if (unsignedTx === '') { - console.log('Waiting for unsigned tx to be available ...'); - await new Promise((resolve) => setTimeout(resolve, 1000)); // sleep for 1 second - continue; - } - - console.log('Signing unsigned tx %s ...', unsignedTx); - - const signedTx = await signer.signTransaction(privateKey, unsignedTx); - console.log( 'Please broadcast this signed tx %s externally and return back the tx hash via the PerformWorkflowStep API ...', signedTx, diff --git a/examples/solana/create-workflow.ts b/examples/solana/create-workflow.ts index d38d807..5a4da2f 100644 --- a/examples/solana/create-workflow.ts +++ b/examples/solana/create-workflow.ts @@ -23,7 +23,6 @@ async function stakeSolana(): Promise { workflow = await client.Solana.stake( projectId, network, - true, walletAddress, validatorAddress, amount, diff --git a/package-lock.json b/package-lock.json index 079e0be..9102749 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@coinbase/staking-client-library-ts", - "version": "0.5.1", + "version": "0.6.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@coinbase/staking-client-library-ts", - "version": "0.5.1", + "version": "0.6.0", "license": "Apache-2.0", "dependencies": { "@ethereumjs/tx": "^5.1.0", diff --git a/package.json b/package.json index cd46379..8ebc89e 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@coinbase/staking-client-library-ts", - "version": "0.5.1", + "version": "0.6.0", "description": "Coinbase Staking API Typescript Library", "repository": "https://github.com/coinbase/staking-client-library-ts.git", "license": "Apache-2.0", diff --git a/src/client/protocols/ethereum-kiln-staking.ts b/src/client/protocols/ethereum-kiln-staking.ts index 5ca7f65..e6cb0d6 100644 --- a/src/client/protocols/ethereum-kiln-staking.ts +++ b/src/client/protocols/ethereum-kiln-staking.ts @@ -26,7 +26,6 @@ export class Ethereum { async stake( projectId: string, network: string, - skipBroadcast: boolean = false, stakerAddress: string, integratorContractAddress: string, amount: string, @@ -35,7 +34,6 @@ export class Ethereum { parent: `projects/${projectId}`, workflow: { action: `protocols/ethereum_kiln/networks/${network}/actions/stake`, - skipBroadcast: skipBroadcast, ethereumKilnStakingParameters: { stakeParameters: { stakerAddress: stakerAddress, @@ -55,7 +53,6 @@ export class Ethereum { async unstake( projectId: string, network: string, - skipBroadcast: boolean = false, stakerAddress: string, integratorContractAddress: string, amount: string, @@ -64,7 +61,6 @@ export class Ethereum { parent: `projects/${projectId}`, workflow: { action: `protocols/ethereum_kiln/networks/${network}/actions/unstake`, - skipBroadcast: skipBroadcast, ethereumKilnStakingParameters: { unstakeParameters: { stakerAddress: stakerAddress, @@ -84,7 +80,6 @@ export class Ethereum { async claimStake( projectId: string, network: string, - skipBroadcast: boolean = false, stakerAddress: string, integratorContractAddress: string, ): Promise { @@ -92,7 +87,6 @@ export class Ethereum { parent: `projects/${projectId}`, workflow: { action: `protocols/ethereum_kiln/networks/${network}/actions/claim_stake`, - skipBroadcast: skipBroadcast, ethereumKilnStakingParameters: { claimStakeParameters: { stakerAddress: stakerAddress, diff --git a/src/client/protocols/solana-staking.ts b/src/client/protocols/solana-staking.ts index ca2dfc9..cf6bda9 100644 --- a/src/client/protocols/solana-staking.ts +++ b/src/client/protocols/solana-staking.ts @@ -26,7 +26,6 @@ export class Solana { async stake( projectId: string, network: string, - skipBroadcast: boolean = false, walletAddress: string, validatorAddress: string, amount: string, @@ -35,7 +34,6 @@ export class Solana { parent: `projects/${projectId}`, workflow: { action: `protocols/solana/networks/${network}/actions/stake`, - skipBroadcast: skipBroadcast, solanaStakingParameters: { stakeParameters: { walletAddress: walletAddress, @@ -55,7 +53,6 @@ export class Solana { async unstake( projectId: string, network: string, - skipBroadcast: boolean = false, walletAddress: string, stakeAccountAddress: string, amount: string, @@ -64,7 +61,6 @@ export class Solana { parent: `projects/${projectId}`, workflow: { action: `protocols/solana/networks/${network}/actions/unstake`, - skipBroadcast: skipBroadcast, solanaStakingParameters: { unstakeParameters: { walletAddress: walletAddress, @@ -84,7 +80,6 @@ export class Solana { async claimStake( projectId: string, network: string, - skipBroadcast: boolean = false, walletAddress: string, stakeAccountAddress: string, ): Promise { @@ -92,7 +87,6 @@ export class Solana { parent: `projects/${projectId}`, workflow: { action: `protocols/solana/networks/${network}/actions/claim_stake`, - skipBroadcast: skipBroadcast, solanaStakingParameters: { claimStakeParameters: { walletAddress: walletAddress, diff --git a/src/client/staking-client.ts b/src/client/staking-client.ts index b5579e0..3506abc 100644 --- a/src/client/staking-client.ts +++ b/src/client/staking-client.ts @@ -253,10 +253,6 @@ export function workflowHasFinished(workflow: Workflow): boolean { ); } -export function workflowWaitingForSigning(workflow: Workflow): boolean { - return workflow.state === WorkflowState.STATE_WAITING_FOR_SIGNING; -} - export function workflowWaitingForExternalBroadcast( workflow: Workflow, ): boolean { diff --git a/src/gen/coinbase/staking/orchestration/v1/workflow.pb.ts b/src/gen/coinbase/staking/orchestration/v1/workflow.pb.ts index cc6549e..03f5d4d 100644 --- a/src/gen/coinbase/staking/orchestration/v1/workflow.pb.ts +++ b/src/gen/coinbase/staking/orchestration/v1/workflow.pb.ts @@ -21,7 +21,7 @@ export enum TxStepOutputState { STATE_UNSPECIFIED = "STATE_UNSPECIFIED", STATE_NOT_CONSTRUCTED = "STATE_NOT_CONSTRUCTED", STATE_CONSTRUCTED = "STATE_CONSTRUCTED", - STATE_PENDING_SIGNING = "STATE_PENDING_SIGNING", + STATE_PENDING_EXT_BROADCAST = "STATE_PENDING_EXT_BROADCAST", STATE_SIGNED = "STATE_SIGNED", STATE_BROADCASTING = "STATE_BROADCASTING", STATE_CONFIRMING = "STATE_CONFIRMING", @@ -29,7 +29,6 @@ export enum TxStepOutputState { STATE_FINALIZED = "STATE_FINALIZED", STATE_FAILED = "STATE_FAILED", STATE_SUCCESS = "STATE_SUCCESS", - STATE_PENDING_EXT_BROADCAST = "STATE_PENDING_EXT_BROADCAST", } export enum WaitStepOutputWaitUnit { @@ -50,10 +49,9 @@ export enum WaitStepOutputState { export enum WorkflowState { STATE_UNSPECIFIED = "STATE_UNSPECIFIED", STATE_IN_PROGRESS = "STATE_IN_PROGRESS", - STATE_WAITING_FOR_SIGNING = "STATE_WAITING_FOR_SIGNING", + STATE_WAITING_FOR_EXT_BROADCAST = "STATE_WAITING_FOR_EXT_BROADCAST", STATE_COMPLETED = "STATE_COMPLETED", STATE_FAILED = "STATE_FAILED", - STATE_WAITING_FOR_EXT_BROADCAST = "STATE_WAITING_FOR_EXT_BROADCAST", } export type TxStepOutput = { @@ -89,7 +87,6 @@ type BaseWorkflow = { steps?: WorkflowStep[] createTime?: GoogleProtobufTimestamp.Timestamp updateTime?: GoogleProtobufTimestamp.Timestamp - skipBroadcast?: boolean completeTime?: GoogleProtobufTimestamp.Timestamp }