Tags: coinbase/staking-client-library-ts
Tags
Add Test Suite, Achieve 80% Coverage (#41) ## Description Of Change This PR adds a testing suite to this repository, achieving 80%+ test coverage of all relevant client files. While working on the test suite, I ran across an old method on the client `performWorkflowStep` which was broken. As far as we can tell, no one uses this method and it doens't fit into the API surface of our Staking API anymore. So I've gone ahead and removed it. This makes this PR a breaking change. I attempted to modify as little actual client code as possible while making these changes, focusing only on the testing and the appropriate coverage. Slight alterations were made, where necessary, to achieve maximal coverage (ex: exporting a method). As you can see in the image attached in a comment, we've achieved 80%+ on statements and lines. We can still improve coverage for branches and funcs. But considering we started at 0 across the board, this is a huge improvement. The coverage image I posted can be regenerated via `npm run coverage`. ## Testing Procedure Added dozens of tests and achieved 80%+ test coverage :)
Expose helper functions (#38) ## Description Of Change As I work on enhancing our [QuickStart guide](https://docs.cdp.coinbase.com/staking/docs/welcome) to add a concrete example to do a e2e stake tx, I realized that having helper functions around reading unsigned txs given a workflow and then ability to sign unsigned txs given wallet's private key would be very helpful. ## Testing Procedure Created a demo app to import the newly exported functions and get a signed staking tx. This is the example that will go into our Quickstart guide. ``` import { StakingClient, TxSignerFactory, getUnsignedTx } from '@coinbase/staking-client-library-ts'; // Set your api key name and private key here. Get your keys from here: https://portal.cdp.coinbase.com/access/api const apiKeyName: string = 'YOUR_API_KEY_NAME'; const apiPrivateKey: string = 'YOUR_API_PRIVATE_KEY'; // Set your wallet details const walletAddress: string = 'YOUR_WALLET_ADDRESS'; const walletPrivateKey: string = 'YOUR_WALLET_PRIVATE_KEY'; const client = new StakingClient(apiKeyName, apiPrivateKey); async function stake() { // Step 1 - Get an unsigned tx corresponding to a // stake of 11 wei ETH from your wallet on network Holesky. let workflow = await client.Ethereum.stake('holesky', walletAddress, '11'); let unsignedTx = getUnsignedTx(workflow); console.log('Unsigned tx %s', unsignedTx); // Step 2 - Sign the unsigned tx with your wallet's private key. // Note: In production, this part would be performed via a wallet-sdk of your choice. const signer = TxSignerFactory.getSigner('ethereum'); const signedTx = await signer.signTransaction(walletPrivateKey, unsignedTx); console.log('Signed tx %s', signedTx); console.log('You can use this UI https://holesky.etherscan.io/pushTx or ' + 'APIs you are familiar with to help broadcast the signed tx on Holesky.'); } stake().catch((error) => { console.error(error); }); ```
Client interface updates (#31) ## Description Of Change The ts client currently has an interface where for APIs like `getWorkflow` and `performWorkflowStep` it expects the user to pass a workflow id. This forces a user to parse out the workflow.name and get it from there. Instead what's easier is, the client interface takes the workflow name as input. One less thing the caller needs to worry about. ## Testing Procedure <!-- Describe how this change has been verified. Either via new automated tests or manual testing --> Ran `ts-node examples/solana/create-and-process-workflow.ts` with appropriate input, to verify if all works.
Prep 0.7.1 release (#22) This is a dummy PR to just bump a patch version to get a clean GH tag, release and npm pkg published. Previous PR to automate GH release process mistakenly published the npm pkg. I have since removed the 0.7.0 tags, release and npm version but the mainline build still fails at re-publishing the 0.7.0 npm pkg. This is to help get a clean start.
PreviousNext