Skip to content
This repository was archived by the owner on Oct 30, 2024. It is now read-only.

Commit 85514b2

Browse files
authored
fix: changed function name of getting pending rewards (#48)
* fix: changed function name of getting pending rewards * fix: updated yarn.lock
1 parent f3ce669 commit 85514b2

8 files changed

Lines changed: 26 additions & 21 deletions

File tree

‎package.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
"url": "https://github.com/AstarNetwork/astar.js.git"
1313
},
1414
"sideEffects": false,
15-
"version": "0.2.2",
15+
"version": "0.2.3",
1616
"workspaces": [
1717
"packages/*",
1818
"examples/*"

‎packages/api-derive/package.json‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@astar-network/astar-api-derive",
3-
"version": "0.2.2",
3+
"version": "0.2.3",
44
"description": "Astar JS API",
55
"main": "index.js",
66
"author": "Astar Network <info@astar.network>",
@@ -19,7 +19,7 @@
1919
},
2020
"homepage": "https://github.com/AstarNetwork/astar.js",
2121
"dependencies": {
22-
"@astar-network/astar-types": "0.2.2",
22+
"@astar-network/astar-types": "0.2.3",
2323
"@babel/runtime": "^7.10.2",
2424
"@open-web3/orml-types": "^1.0.2-0",
2525
"@polkadot/api-derive": "9.14.2"

‎packages/api/package.json‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@astar-network/astar-api",
3-
"version": "0.2.2",
3+
"version": "0.2.3",
44
"description": "Astar JS API",
55
"main": "index.js",
66
"author": "Astar Network <info@astar.network>",
@@ -19,8 +19,8 @@
1919
},
2020
"homepage": "https://github.com/AstarNetwork/astar.js",
2121
"dependencies": {
22-
"@astar-network/astar-api-derive": "0.2.2",
23-
"@astar-network/astar-types": "0.2.2",
22+
"@astar-network/astar-api-derive": "0.2.3",
23+
"@astar-network/astar-types": "0.2.3",
2424
"@babel/runtime": "^7.10.2",
2525
"@open-web3/orml-api-derive": "^1.0.2-0",
2626
"@polkadot/api": "9.14.2"

‎packages/sdk-core/package.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@astar-network/astar-sdk-core",
3-
"version": "0.2.2",
3+
"version": "0.2.3",
44
"description": "the core for astar SDK",
55
"main": "index.js",
66
"author": "Astar Network <info@astar.network>",

‎packages/sdk-core/src/modules/dapp-staking/pending-rewards/index.ts‎

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -192,16 +192,21 @@ const formatStakerPendingRewards = ({ stakerInfo,
192192
});
193193
};
194194

195-
export const getPendingRewards = async ({ api,
196-
currentAccount }: {
195+
// Memo:
196+
// The amount of each era’s token issuance is used to calculate the total amount of estimated rewards.
197+
// In order to minimize fetching of this value from on-chain, this function assumes the amount of 1 era’s issuance by taking the average of 7 eras.
198+
// Hence, the amount of estimated rewards is slightly different from the actual amount.
199+
// In other words, as the number of unclaimed eras increases, the difference increases (but it shouldn't be too far away).
200+
export const estimatePendingRewards = async ({ api,
201+
walletAddress }: {
197202
api: ApiPromise;
198-
currentAccount: string;
203+
walletAddress: string;
199204
}): Promise<{ stakerPendingRewards: number }> => {
200205
try {
201206
const [eraInfo, generalStakerInfo, blockHeight, blocksPerEra, rawBlockRewards, rewardsDistributionConfig] =
202207
await Promise.all([
203208
api.query.dappsStaking.generalEraInfo.entries(),
204-
api.query.dappsStaking.generalStakerInfo.entries(currentAccount),
209+
api.query.dappsStaking.generalStakerInfo.entries(walletAddress),
205210
api.query.system.number(),
206211
Number(api.consts.dappsStaking.blockPerEra),
207212
String(api.consts.blockReward.rewardAmount),

‎packages/type-definitions/package.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@astar-network/astar-type-definitions",
3-
"version": "0.2.2",
3+
"version": "0.2.3",
44
"description": "Polkadot.js type definations for astar Network",
55
"main": "index.js",
66
"author": "Astar Network <info@astar.network>",

‎packages/types/package.json‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@astar-network/astar-types",
3-
"version": "0.2.2",
3+
"version": "0.2.3",
44
"description": "Polkadot.js type definations for Astar Network",
55
"main": "index.js",
66
"author": "Astar Network <info@astar.network>",
@@ -19,7 +19,7 @@
1919
},
2020
"homepage": "https://github.com/AstarNetwork/astar.js",
2121
"dependencies": {
22-
"@astar-network/astar-type-definitions": "0.2.2",
22+
"@astar-network/astar-type-definitions": "0.2.3",
2323
"@babel/runtime": "^7.10.2",
2424
"@open-web3/api-mobx": "^1.0.2-0",
2525
"@open-web3/orml-types": "^1.0.2-0",

‎yarn.lock‎

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,11 @@ __metadata:
1515
languageName: node
1616
linkType: hard
1717

18-
"@astar-network/astar-api-derive@0.2.2, @astar-network/astar-api-derive@workspace:packages/api-derive":
18+
"@astar-network/astar-api-derive@0.2.3, @astar-network/astar-api-derive@workspace:packages/api-derive":
1919
version: 0.0.0-use.local
2020
resolution: "@astar-network/astar-api-derive@workspace:packages/api-derive"
2121
dependencies:
22-
"@astar-network/astar-types": 0.2.2
22+
"@astar-network/astar-types": 0.2.3
2323
"@babel/runtime": ^7.10.2
2424
"@open-web3/orml-types": ^1.0.2-0
2525
"@polkadot/api-derive": 9.14.2
@@ -30,8 +30,8 @@ __metadata:
3030
version: 0.0.0-use.local
3131
resolution: "@astar-network/astar-api@workspace:packages/api"
3232
dependencies:
33-
"@astar-network/astar-api-derive": 0.2.2
34-
"@astar-network/astar-types": 0.2.2
33+
"@astar-network/astar-api-derive": 0.2.3
34+
"@astar-network/astar-types": 0.2.3
3535
"@babel/runtime": ^7.10.2
3636
"@open-web3/orml-api-derive": ^1.0.2-0
3737
"@polkadot/api": 9.14.2
@@ -59,7 +59,7 @@ __metadata:
5959
languageName: unknown
6060
linkType: soft
6161

62-
"@astar-network/astar-type-definitions@0.2.2, @astar-network/astar-type-definitions@workspace:packages/type-definitions":
62+
"@astar-network/astar-type-definitions@0.2.3, @astar-network/astar-type-definitions@workspace:packages/type-definitions":
6363
version: 0.0.0-use.local
6464
resolution: "@astar-network/astar-type-definitions@workspace:packages/type-definitions"
6565
dependencies:
@@ -68,11 +68,11 @@ __metadata:
6868
languageName: unknown
6969
linkType: soft
7070

71-
"@astar-network/astar-types@0.2.2, @astar-network/astar-types@workspace:packages/types":
71+
"@astar-network/astar-types@0.2.3, @astar-network/astar-types@workspace:packages/types":
7272
version: 0.0.0-use.local
7373
resolution: "@astar-network/astar-types@workspace:packages/types"
7474
dependencies:
75-
"@astar-network/astar-type-definitions": 0.2.2
75+
"@astar-network/astar-type-definitions": 0.2.3
7676
"@babel/runtime": ^7.10.2
7777
"@open-web3/api-mobx": ^1.0.2-0
7878
"@open-web3/orml-types": ^1.0.2-0

0 commit comments

Comments
 (0)