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

feat: drepId in GET_ACCOUNT_INFO #239

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
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
2 changes: 2 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
"cbor",
"cbors",
"compat",
"drep",
"dreps",
"emurgo",
"from",
"HEALTHCHECK",
Expand Down
Binary file not shown.
Binary file not shown.
Binary file not shown.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

### Added

- DRep data in `GET_ACCOUNT_INFO` method

### Changed

- more verbose healthcheck error log
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
"type-check": "tsc --project tsconfig.json"
},
"dependencies": {
"@blockfrost/blockfrost-js": "5.6.0",
"@emurgo/cardano-serialization-lib-nodejs": "^11.5.0",
"@blockfrost/blockfrost-js": "5.7.0-beta.0",
"@emurgo/cardano-serialization-lib-nodejs": "^12.1.1",
"@sentry/integrations": "^7.85.0",
"@sentry/node": "^7.85.0",
"@sentry/tracing": "^7.85.0",
Expand Down
1 change: 1 addition & 0 deletions src/methods/get-account-info.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ export const getAccountInfo = async (
rewards: stakingData.rewards,
isActive: stakingData.isActive,
poolId: stakingData.poolId,
drep: stakingData.drep,
},
},
};
Expand Down
1 change: 1 addition & 0 deletions src/types/address.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,4 +78,5 @@ export type StakingData = {
rewards: string;
isActive: boolean;
poolId: string | null;
drep: Responses['drep'] | null;
};
8 changes: 8 additions & 0 deletions src/types/response.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,14 @@ export interface AccountInfo {
isActive: boolean;
rewards: string;
poolId: string | null;
drep: {
drep_id: string;
hex: string;
amount: string;
active: boolean;
active_epoch: number | null;
has_script: boolean;
} | null;
};
};
}
Expand Down
5 changes: 5 additions & 0 deletions src/utils/address.ts
Original file line number Diff line number Diff line change
Expand Up @@ -282,11 +282,15 @@ export const getAddressesData = async (
export const getStakingData = async (stakeAddress: string): Promise<Addresses.StakingData> => {
try {
const stakeAddressData = await blockfrostAPI.accounts(stakeAddress);
const drepData = stakeAddressData.drep_id
? await blockfrostAPI.governance.drepsById(stakeAddressData.drep_id)
: null;

return {
rewards: stakeAddressData.withdrawable_amount,
isActive: stakeAddressData.active,
poolId: stakeAddressData.pool_id,
drep: drepData,
};
} catch (error) {
if (error instanceof BlockfrostServerError && error.status_code === 404) {
Expand All @@ -295,6 +299,7 @@ export const getStakingData = async (stakeAddress: string): Promise<Addresses.St
isActive: false,

poolId: null,
drep: null,
};
}
throw error;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ exports[`getAccountInfo > getAccountInfo basic 1`] = `
"misc": {
"staking": {
"address": "stake1uxzutrtmxwv2rf2j3hdpps66ch0jydmkr58vwgnetddcdwg32u4rc",
"drep": null,
"isActive": true,
"poolId": "pool1pu5jlj4q9w9jlxeu370a3c9myx47md5j5m2str0naunn2q3lkdy",
"rewards": "372864",
Expand Down Expand Up @@ -1145,6 +1146,7 @@ exports[`getAccountInfo > getAccountInfo txs 1`] = `
"misc": {
"staking": {
"address": "stake1uxzutrtmxwv2rf2j3hdpps66ch0jydmkr58vwgnetddcdwg32u4rc",
"drep": null,
"isActive": true,
"poolId": "pool1pu5jlj4q9w9jlxeu370a3c9myx47md5j5m2str0naunn2q3lkdy",
"rewards": "372864",
Expand Down
3 changes: 2 additions & 1 deletion yarn-project.nix
Original file line number Diff line number Diff line change
Expand Up @@ -167,9 +167,10 @@ cacheEntries = {
"@babel/highlight@npm:7.18.6" = { filename = "@babel-highlight-npm-7.18.6-9d35ad2e27-92d8ee6154.zip"; sha512 = "92d8ee61549de5ff5120e945e774728e5ccd57fd3b2ed6eace020ec744823d4a98e242be1453d21764a30a14769ecd62170fba28539b211799bbaf232bbb2789"; };
"@babel/runtime@npm:7.22.6" = { filename = "@babel-runtime-npm-7.22.6-493f6b7ad0-1d2f56797f.zip"; sha512 = "1d2f56797f548b009910bddf3dc04f980a9701193233145dc923f3ea87c8f88121a3c3ef1d449e9cb52a370d7d025a2243c748882d5546ff079ddf5ffe29f240"; };
"@bcoe/v8-coverage@npm:0.2.3" = { filename = "@bcoe-v8-coverage-npm-0.2.3-9e27b3c57e-1a1f0e356a.zip"; sha512 = "1a1f0e356a3bb30b5f1ced6f79c413e6ebacf130421f15fac5fcd8be5ddf98aedb4404d7f5624e3285b700e041f9ef938321f3ca4d359d5b716f96afa120d88d"; };
"@blockfrost/blockfrost-js@npm:5.6.0" = { filename = "@blockfrost-blockfrost-js-npm-5.6.0-bfa2188d90-7c409c8f91.zip"; sha512 = "7c409c8f91d388876cfc69006965a9c57137e970b97f0d44073cf40292f4c69412308a10ef5db9ac4e285015be2362ffd98e662e6460571192ba2b20f3c59a53"; };
"@blockfrost/blockfrost-js@npm:5.7.0-beta.0" = { filename = "@blockfrost-blockfrost-js-npm-5.7.0-beta.0-7c06a0465b-3da04b69c0.zip"; sha512 = "3da04b69c0d468ee30d79a15cfd31bbde895b87e07d8e493fad01031a14206d80a4fae5ec1ca6771d6c89cde6657bf24c33f4584497cc8a01bba6ea6160a8aa3"; };
"@blockfrost/openapi@npm:0.1.67" = { filename = "@blockfrost-openapi-npm-0.1.67-188356f956-464cfa9ae4.zip"; sha512 = "464cfa9ae4d7911ed963f559c95e97b68763466276d5663596028038faa53c8c1ef415855c6de7b6ff363f3a9576ebcad8d374a1684549096019255cdc1c501f"; };
"@emurgo/cardano-serialization-lib-nodejs@npm:11.5.0" = { filename = "@emurgo-cardano-serialization-lib-nodejs-npm-11.5.0-8c2e047031-3fff844800.zip"; sha512 = "3fff8448001c6d70807ef8e1a80a663ef60381e55bfd26c0f1b644e096895da7298fb991ac86670d4c5aee2e3e417e44ac80ab59080f7af107d8fa89906f9075"; };
"@emurgo/cardano-serialization-lib-nodejs@npm:12.1.1" = { filename = "@emurgo-cardano-serialization-lib-nodejs-npm-12.1.1-b2f1c5eb20-a165613d69.zip"; sha512 = "a165613d695b9c10084be2784cdcdebc26ac7415025497f9c17ef08f7d7f786cb7b8318b32a0282261683b240e162c4916ec7a1470590265b2aad8b7d4ea2e5e"; };
"@emurgo/cip14-js@npm:3.0.1" = { filename = "@emurgo-cip14-js-npm-3.0.1-6011030ea2-9eaf312410.zip"; sha512 = "9eaf3124108e8c252a745de9ef1f334ab26a32271077b00fe0ea2a06e40838dd435165dac523ebd4d851ae7a94d8c56766dabc372aabffedd36551c798c607c5"; };
"@esbuild/darwin-arm64@npm:0.19.8" = { filename = "@esbuild-darwin-arm64-npm-0.19.8-b1920f84ba-869c5ded22.zip"; sha512 = "869c5ded228fe18c5d1790672336ff7cabd20aff5af98b6ce5461048d063a28bd2c89ff495b349ce044628f829836fde6cbbdb00a39d663099f5675f78be2a2d"; };
"@esbuild/darwin-x64@npm:0.19.8" = { filename = "@esbuild-darwin-x64-npm-0.19.8-36f500fc51-10.zip"; sha512 = "00cc81d47552ec955de047f29a844b39dd03cbf12cd0f08d01e5e5f808a53ef0838777f9a96a0cfcc8e160a6feb3e8a2af7775b39ee585c3555af0ea01c07065"; };
Expand Down
19 changes: 13 additions & 6 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,9 @@ __metadata:
languageName: node
linkType: hard

"@blockfrost/blockfrost-js@npm:5.6.0":
version: 5.6.0
resolution: "@blockfrost/blockfrost-js@npm:5.6.0"
"@blockfrost/blockfrost-js@npm:5.7.0-beta.0":
version: 5.7.0-beta.0
resolution: "@blockfrost/blockfrost-js@npm:5.7.0-beta.0"
dependencies:
"@blockfrost/openapi": "npm:0.1.67"
"@emurgo/cardano-serialization-lib-nodejs": "npm:^11.5.0"
Expand All @@ -73,16 +73,16 @@ __metadata:
form-data: "npm:^4.0.0"
got: "npm:^11.8.6"
json-bigint: "npm:^1.0.0"
checksum: 7c409c8f91d388876cfc69006965a9c57137e970b97f0d44073cf40292f4c69412308a10ef5db9ac4e285015be2362ffd98e662e6460571192ba2b20f3c59a53
checksum: 3da04b69c0d468ee30d79a15cfd31bbde895b87e07d8e493fad01031a14206d80a4fae5ec1ca6771d6c89cde6657bf24c33f4584497cc8a01bba6ea6160a8aa3
languageName: node
linkType: hard

"@blockfrost/blockfrost-websocket-link@workspace:.":
version: 0.0.0-use.local
resolution: "@blockfrost/blockfrost-websocket-link@workspace:."
dependencies:
"@blockfrost/blockfrost-js": "npm:5.6.0"
"@emurgo/cardano-serialization-lib-nodejs": "npm:^11.5.0"
"@blockfrost/blockfrost-js": "npm:5.7.0-beta.0"
"@emurgo/cardano-serialization-lib-nodejs": "npm:^12.1.1"
"@esbuild/darwin-arm64": "npm:0.19.8"
"@esbuild/linux-x64": "npm:0.19.8"
"@eslint/compat": "npm:^1.2.1"
Expand Down Expand Up @@ -146,6 +146,13 @@ __metadata:
languageName: node
linkType: hard

"@emurgo/cardano-serialization-lib-nodejs@npm:^12.1.1":
version: 12.1.1
resolution: "@emurgo/cardano-serialization-lib-nodejs@npm:12.1.1"
checksum: a165613d695b9c10084be2784cdcdebc26ac7415025497f9c17ef08f7d7f786cb7b8318b32a0282261683b240e162c4916ec7a1470590265b2aad8b7d4ea2e5e
languageName: node
linkType: hard

"@emurgo/cip14-js@npm:3.0.1":
version: 3.0.1
resolution: "@emurgo/cip14-js@npm:3.0.1"
Expand Down
Loading