From 0b8dbac7e8b3c4e88b7f6fd429a68ac4702f3654 Mon Sep 17 00:00:00 2001 From: Marcin Lenczewski Date: Thu, 16 May 2024 17:55:56 -0400 Subject: [PATCH] README fixes for PES rewards --- README.md | 4 ++-- examples/ethereum/list-rewards/partial-eth.ts | 20 +++++++++++++++++++ .../validator.ts} | 17 ++-------------- 3 files changed, 24 insertions(+), 17 deletions(-) create mode 100644 examples/ethereum/list-rewards/partial-eth.ts rename examples/ethereum/{list-rewards.ts => list-rewards/validator.ts} (54%) diff --git a/README.md b/README.md index a56d6c3..45ef180 100644 --- a/README.md +++ b/README.md @@ -172,12 +172,12 @@ client.Solana.stake('devnet', '8rMGARtkJY5QygP1mgvBFLsE9JrvXByARJiyNfcSE5Z', '10 ### View Partial ETH Rewards :moneybag: -This code sample helps view rewards for an Ethereum address. View the full source [here](examples/ethereum/list-rewards.ts). +This code sample helps view rewards for an Ethereum address. View the full source [here](examples/ethereum/list-rewards/partial-eth.ts).
```typescript -// examples/ethereum/list-rewards.ts +// examples/ethereum/list-rewards/partial-eth.ts import { StakingClient } 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 diff --git a/examples/ethereum/list-rewards/partial-eth.ts b/examples/ethereum/list-rewards/partial-eth.ts new file mode 100644 index 0000000..d8f3f1f --- /dev/null +++ b/examples/ethereum/list-rewards/partial-eth.ts @@ -0,0 +1,20 @@ +import { StakingClient } from '../../../src/client/staking-client'; + +// 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'; + +const client = new StakingClient(apiKeyName, apiPrivateKey); + +// Defines which partial eth address and rewards we want to see. +const partialETHAddress: string = '0x60c7e246344ae3856cf9abe3a2e258d495fc39e0'; +const partialETHFilter: string = `address='${partialETHAddress}' AND period_end_time > '2024-05-01T00:00:00Z' AND period_end_time < '2024-05-03T00:00:00Z'`; + +// Loops through partial eth rewards array and prints each reward. +(async (): Promise => { + const resp = await client.Ethereum.listRewards(partialETHFilter); + // eslint-disable-next-line @typescript-eslint/padding-line-between-statements + resp.rewards!.forEach((reward) => { + console.log(JSON.stringify(reward, null, 2)); + }); +})(); diff --git a/examples/ethereum/list-rewards.ts b/examples/ethereum/list-rewards/validator.ts similarity index 54% rename from examples/ethereum/list-rewards.ts rename to examples/ethereum/list-rewards/validator.ts index 4239248..5c96d53 100644 --- a/examples/ethereum/list-rewards.ts +++ b/examples/ethereum/list-rewards/validator.ts @@ -1,4 +1,4 @@ -import { StakingClient } from '../../src/client/staking-client'; +import { StakingClient } from '../../../src/client/staking-client'; // 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'; @@ -6,25 +6,12 @@ const apiPrivateKey: string = 'your-api-private-key'; const client = new StakingClient(apiKeyName, apiPrivateKey); -// Defines which partial eth address and rewards we want to see. -const partialETHAddress: string = '0x60c7e246344ae3856cf9abe3a2e258d495fc39e0'; -const partialETHFilter: string = `address='${partialETHAddress}' AND period_end_time > '2024-05-01T00:00:00Z' AND period_end_time < '2024-05-02T00:00:00Z'`; - // Defines which validator address and rewards we want to see. const validatorAddress: string = '0xac53512c39d0081ca4437c285305eb423f474e6153693c12fbba4a3df78bcaa3422b31d800c5bea71c1b017168a60474'; const validatorFilter: string = `address='${validatorAddress}' AND period_end_time > '2024-02-25T00:00:00Z' AND period_end_time < '2024-02-27T00:00:00Z'`; -// Loops through partial eth rewards array and prints each reward -(async (): Promise => { - const resp = await client.Ethereum.listRewards(partialETHFilter); - // eslint-disable-next-line @typescript-eslint/padding-line-between-statements - resp.rewards!.forEach((reward) => { - console.log(JSON.stringify(reward, null, 2)); - }); -})(); - -// Loops through validator rewards array and prints each reward +// Loops through validator rewards array and prints each reward. (async (): Promise => { const resp = await client.Ethereum.listRewards(validatorFilter); // eslint-disable-next-line @typescript-eslint/padding-line-between-statements