From 9e1b4111f589e671476482301d199d33aeb34f7f Mon Sep 17 00:00:00 2001 From: Alessio Onori Date: Wed, 24 Apr 2024 10:16:14 +0200 Subject: [PATCH 1/3] fix runtime upgrade, bump polkadotjs api --- charts/polkadot-k8s-payouts/Chart.yaml | 4 +- package.json | 4 +- src/claimer.ts | 38 +-- src/utils.ts | 4 + yarn.lock | 310 ++++++++++++------------- 5 files changed, 186 insertions(+), 174 deletions(-) diff --git a/charts/polkadot-k8s-payouts/Chart.yaml b/charts/polkadot-k8s-payouts/Chart.yaml index b2321f0..7b57a41 100644 --- a/charts/polkadot-k8s-payouts/Chart.yaml +++ b/charts/polkadot-k8s-payouts/Chart.yaml @@ -1,5 +1,5 @@ description: Polkadot K8s Payouts name: polkadot-k8s-payouts -version: v1.2.8 -appVersion: v1.2.8 +version: v1.2.9 +appVersion: v1.2.9 apiVersion: v2 diff --git a/package.json b/package.json index 476953f..c283652 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "polkadot-payouts", - "version": "1.2.8", + "version": "1.2.9", "description": "Automated transfers among accounts", "repository": "git@github.com:w3f/accountant.git", "author": "W3F Infrastructure Team ", @@ -20,7 +20,7 @@ "start": "NODE_OPTIONS='--max-old-space-size=4096' node ./dist/index.js start" }, "dependencies": { - "@polkadot/api": "^10.13.1", + "@polkadot/api": "^11.0.1", "@w3f/config": "^0.1.1", "@w3f/logger": "^0.4.3", "async-wait-until": "^1.2.6", diff --git a/src/claimer.ts b/src/claimer.ts index 1bec3f3..368d715 100644 --- a/src/claimer.ts +++ b/src/claimer.ts @@ -1,11 +1,12 @@ import { ClaimerInputConfig, Target, GracePeriod, ValidatorInfo, ValidatorsMap, ClaimPool } from './types'; -import { getActiveEraIndex, initKey } from './utils'; +import { getActiveEraIndex, initKey, setDifference } from './utils'; import { Logger, LoggerSingleton } from './logger'; import { ApiPromise, Keyring } from '@polkadot/api'; import { KeyringPair } from '@polkadot/keyring/types'; import waitUntil from 'async-wait-until'; import { BN } from 'bn.js'; import { batchSize, claimAttempts, gracePeriod, isDeepCheckEnabled } from './constants'; +import { DeriveOwnExposure } from '@polkadot/api-derive/types'; export class Claimer { private isDeepCheckEnabled = isDeepCheckEnabled @@ -135,21 +136,28 @@ export class Claimer { private async gatherUnclaimedInfo(validatorAddress: string, validatorInfo: ValidatorInfo): Promise { + + const ownRewardsIdx: Set = new Set + const exposure: DeriveOwnExposure[] = await this.api.derive.staking.ownExposures(validatorAddress) + exposure.forEach(e=>{ + if(e.exposure.total.toBn().gt(new BN(0))) ownRewardsIdx.add(e.era.toNumber()) //legacy + if(e.exposureMeta?.value.total?.toBn().gt(new BN(0))) ownRewardsIdx.add(e.era.toNumber()) //new + }) - const lastReward = validatorInfo.lastReward - - const numOfPotentialUnclaimedPayouts = this.currentEraIndex - lastReward - 1; - const unclaimedPayouts: number[] = [] - for ( let i = 1; i <= numOfPotentialUnclaimedPayouts; i++) { - const idx = lastReward + i; - const exposure = await this.api.query.staking.erasStakers(idx, validatorAddress); - if (exposure.total.toBn().gt(new BN(0))) { - unclaimedPayouts.push(idx) - } - } - validatorInfo.unclaimedPayouts=unclaimedPayouts - - return unclaimedPayouts + const claimedIdx: Set = new Set + const stakingQuey = await this.api.derive.staking.query(validatorAddress,{withLedger:true, withClaimedRewardsEras: true}) + stakingQuey.stakingLedger.legacyClaimedRewards.forEach(r=>claimedIdx.add(r.toNumber())) + stakingQuey.claimedRewardsEras.forEach(r=>claimedIdx.add(r.toNumber())) + + const unclaimed: number[] = Array.from(setDifference(ownRewardsIdx,claimedIdx)) + this.logger.debug(unclaimed.toString()) + + //bugFix: https://github.com/polkadot-js/api/issues/5859 + //temporary solution + const unclaimedFixed = unclaimed.filter(x=>x>6513) + + validatorInfo.unclaimedPayouts=unclaimedFixed + return unclaimedFixed } private async buildClaimPool(validatorsMap: ValidatorsMap): Promise { diff --git a/src/utils.ts b/src/utils.ts index 6dbc9b6..8642bab 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -37,4 +37,8 @@ export const initKey = (keystoreFilePath: string, passwordFilePath): any =>{ //s logger.error(`problem unlocking the wallet, exiting ...`) process.exit(1) } else return keyPair +} + +export const setDifference = (setA: Set, setB: Set): Set => { + return new Set([...setA].filter(x=>!setB.has(x))) } \ No newline at end of file diff --git a/yarn.lock b/yarn.lock index 4990085..dd42e7b 100644 --- a/yarn.lock +++ b/yarn.lock @@ -859,64 +859,64 @@ resolved "https://registry.yarnpkg.com/@noble/secp256k1/-/secp256k1-1.7.1.tgz#b251c70f824ce3ca7f8dc3df08d58f005cc0507c" integrity sha512-hOUk6AyBFmqVrv7k5WAw/LpszxVbj9gGN4JRkIX52fdFAj1UA61KXmZDvqVEm+pOyec3+fIeZB02LYa/pWOArw== -"@polkadot-api/client@0.0.1-492c132563ea6b40ae1fc5470dec4cd18768d182.1.0": - version "0.0.1-492c132563ea6b40ae1fc5470dec4cd18768d182.1.0" - resolved "https://registry.yarnpkg.com/@polkadot-api/client/-/client-0.0.1-492c132563ea6b40ae1fc5470dec4cd18768d182.1.0.tgz#5d6b863f63f5c6ecd4183fcf0c5c84dd349f7627" - integrity sha512-0fqK6pUKcGHSG2pBvY+gfSS+1mMdjd/qRygAcKI5d05tKsnZLRnmhb9laDguKmGEIB0Bz9vQqNK3gIN/cfvVwg== - dependencies: - "@polkadot-api/metadata-builders" "0.0.1-492c132563ea6b40ae1fc5470dec4cd18768d182.1.0" - "@polkadot-api/substrate-bindings" "0.0.1-492c132563ea6b40ae1fc5470dec4cd18768d182.1.0" - "@polkadot-api/substrate-client" "0.0.1-492c132563ea6b40ae1fc5470dec4cd18768d182.1.0" - "@polkadot-api/utils" "0.0.1-492c132563ea6b40ae1fc5470dec4cd18768d182.1.0" - -"@polkadot-api/json-rpc-provider-proxy@0.0.1-492c132563ea6b40ae1fc5470dec4cd18768d182.1.0": - version "0.0.1-492c132563ea6b40ae1fc5470dec4cd18768d182.1.0" - resolved "https://registry.yarnpkg.com/@polkadot-api/json-rpc-provider-proxy/-/json-rpc-provider-proxy-0.0.1-492c132563ea6b40ae1fc5470dec4cd18768d182.1.0.tgz#cc28fb801db6a47824261a709ab924ec6951eb96" - integrity sha512-0hZ8vtjcsyCX8AyqP2sqUHa1TFFfxGWmlXJkit0Nqp9b32MwZqn5eaUAiV2rNuEpoglKOdKnkGtUF8t5MoodKw== - -"@polkadot-api/json-rpc-provider@0.0.1-492c132563ea6b40ae1fc5470dec4cd18768d182.1.0": - version "0.0.1-492c132563ea6b40ae1fc5470dec4cd18768d182.1.0" - resolved "https://registry.yarnpkg.com/@polkadot-api/json-rpc-provider/-/json-rpc-provider-0.0.1-492c132563ea6b40ae1fc5470dec4cd18768d182.1.0.tgz#2f71bfb192d28dd4c400ef8b1c5f934c676950f3" - integrity sha512-EaUS9Fc3wsiUr6ZS43PQqaRScW7kM6DYbuM/ou0aYjm8N9MBqgDbGm2oL6RE1vAVmOfEuHcXZuZkhzWtyvQUtA== - -"@polkadot-api/metadata-builders@0.0.1-492c132563ea6b40ae1fc5470dec4cd18768d182.1.0": - version "0.0.1-492c132563ea6b40ae1fc5470dec4cd18768d182.1.0" - resolved "https://registry.yarnpkg.com/@polkadot-api/metadata-builders/-/metadata-builders-0.0.1-492c132563ea6b40ae1fc5470dec4cd18768d182.1.0.tgz#085db2a3c7b100626b2fae3be35a32a24ea7714f" - integrity sha512-BD7rruxChL1VXt0icC2gD45OtT9ofJlql0qIllHSRYgama1CR2Owt+ApInQxB+lWqM+xNOznZRpj8CXNDvKIMg== - dependencies: - "@polkadot-api/substrate-bindings" "0.0.1-492c132563ea6b40ae1fc5470dec4cd18768d182.1.0" - "@polkadot-api/utils" "0.0.1-492c132563ea6b40ae1fc5470dec4cd18768d182.1.0" - -"@polkadot-api/substrate-bindings@0.0.1-492c132563ea6b40ae1fc5470dec4cd18768d182.1.0": - version "0.0.1-492c132563ea6b40ae1fc5470dec4cd18768d182.1.0" - resolved "https://registry.yarnpkg.com/@polkadot-api/substrate-bindings/-/substrate-bindings-0.0.1-492c132563ea6b40ae1fc5470dec4cd18768d182.1.0.tgz#f836a554a9ead6fb6356079c725cd53f87238932" - integrity sha512-N4vdrZopbsw8k57uG58ofO7nLXM4Ai7835XqakN27MkjXMp5H830A1KJE0L9sGQR7ukOCDEIHHcwXVrzmJ/PBg== +"@polkadot-api/json-rpc-provider-proxy@0.0.1": + version "0.0.1" + resolved "https://registry.yarnpkg.com/@polkadot-api/json-rpc-provider-proxy/-/json-rpc-provider-proxy-0.0.1.tgz#bb5c943642cdf0ec7bc48c0a2647558b9fcd7bdb" + integrity sha512-gmVDUP8LpCH0BXewbzqXF2sdHddq1H1q+XrAW2of+KZj4woQkIGBRGTJHeBEVHe30EB+UejR1N2dT4PO/RvDdg== + +"@polkadot-api/json-rpc-provider@0.0.1": + version "0.0.1" + resolved "https://registry.yarnpkg.com/@polkadot-api/json-rpc-provider/-/json-rpc-provider-0.0.1.tgz#333645d40ccd9bccfd1f32503f17e4e63e76e297" + integrity sha512-/SMC/l7foRjpykLTUTacIH05H3mr9ip8b5xxfwXlVezXrNVLp3Cv0GX6uItkKd+ZjzVPf3PFrDF2B2/HLSNESA== + +"@polkadot-api/metadata-builders@0.0.1": + version "0.0.1" + resolved "https://registry.yarnpkg.com/@polkadot-api/metadata-builders/-/metadata-builders-0.0.1.tgz#a76b48febef9ea72be8273d889e2677101045a05" + integrity sha512-GCI78BHDzXAF/L2pZD6Aod/yl82adqQ7ftNmKg51ixRL02JpWUA+SpUKTJE5MY1p8kiJJIo09P2um24SiJHxNA== + dependencies: + "@polkadot-api/substrate-bindings" "0.0.1" + "@polkadot-api/utils" "0.0.1" + +"@polkadot-api/observable-client@0.1.0": + version "0.1.0" + resolved "https://registry.yarnpkg.com/@polkadot-api/observable-client/-/observable-client-0.1.0.tgz#472045ea06a2bc4bccdc2db5c063eadcbf6f5351" + integrity sha512-GBCGDRztKorTLna/unjl/9SWZcRmvV58o9jwU2Y038VuPXZcr01jcw/1O3x+yeAuwyGzbucI/mLTDa1QoEml3A== + dependencies: + "@polkadot-api/metadata-builders" "0.0.1" + "@polkadot-api/substrate-bindings" "0.0.1" + "@polkadot-api/substrate-client" "0.0.1" + "@polkadot-api/utils" "0.0.1" + +"@polkadot-api/substrate-bindings@0.0.1": + version "0.0.1" + resolved "https://registry.yarnpkg.com/@polkadot-api/substrate-bindings/-/substrate-bindings-0.0.1.tgz#c4b7f4d6c3672d2c15cbc6c02964f014b73cbb0b" + integrity sha512-bAe7a5bOPnuFVmpv7y4BBMRpNTnMmE0jtTqRUw/+D8ZlEHNVEJQGr4wu3QQCl7k1GnSV1wfv3mzIbYjErEBocg== dependencies: "@noble/hashes" "^1.3.1" - "@polkadot-api/utils" "0.0.1-492c132563ea6b40ae1fc5470dec4cd18768d182.1.0" + "@polkadot-api/utils" "0.0.1" "@scure/base" "^1.1.1" scale-ts "^1.6.0" -"@polkadot-api/substrate-client@0.0.1-492c132563ea6b40ae1fc5470dec4cd18768d182.1.0": - version "0.0.1-492c132563ea6b40ae1fc5470dec4cd18768d182.1.0" - resolved "https://registry.yarnpkg.com/@polkadot-api/substrate-client/-/substrate-client-0.0.1-492c132563ea6b40ae1fc5470dec4cd18768d182.1.0.tgz#55ae463f4143495e328465dd16b03e71663ef4c4" - integrity sha512-lcdvd2ssUmB1CPzF8s2dnNOqbrDa+nxaaGbuts+Vo8yjgSKwds2Lo7Oq+imZN4VKW7t9+uaVcKFLMF7PdH0RWw== - -"@polkadot-api/utils@0.0.1-492c132563ea6b40ae1fc5470dec4cd18768d182.1.0": - version "0.0.1-492c132563ea6b40ae1fc5470dec4cd18768d182.1.0" - resolved "https://registry.yarnpkg.com/@polkadot-api/utils/-/utils-0.0.1-492c132563ea6b40ae1fc5470dec4cd18768d182.1.0.tgz#759698dcf948745ea37cc5ab6abd49a00f1b0c31" - integrity sha512-0CYaCjfLQJTCRCiYvZ81OncHXEKPzAexCMoVloR+v2nl/O2JRya/361MtPkeNLC6XBoaEgLAG9pWQpH3WePzsw== - -"@polkadot/api-augment@10.13.1": - version "10.13.1" - resolved "https://registry.yarnpkg.com/@polkadot/api-augment/-/api-augment-10.13.1.tgz#dd3670a2f1a581c38b857ad3b0805b6581099c63" - integrity sha512-IAKaCp19QxgOG4HKk9RAgUgC/VNVqymZ2GXfMNOZWImZhxRIbrK+raH5vN2MbWwtVHpjxyXvGsd1RRhnohI33A== - dependencies: - "@polkadot/api-base" "10.13.1" - "@polkadot/rpc-augment" "10.13.1" - "@polkadot/types" "10.13.1" - "@polkadot/types-augment" "10.13.1" - "@polkadot/types-codec" "10.13.1" +"@polkadot-api/substrate-client@0.0.1": + version "0.0.1" + resolved "https://registry.yarnpkg.com/@polkadot-api/substrate-client/-/substrate-client-0.0.1.tgz#0e8010a0abe2fb47d6fa7ab94e45e1d0de083314" + integrity sha512-9Bg9SGc3AwE+wXONQoW8GC00N3v6lCZLW74HQzqB6ROdcm5VAHM4CB/xRzWSUF9CXL78ugiwtHx3wBcpx4H4Wg== + +"@polkadot-api/utils@0.0.1": + version "0.0.1" + resolved "https://registry.yarnpkg.com/@polkadot-api/utils/-/utils-0.0.1.tgz#908b22becac705149d7cc946532143d0fb003bfc" + integrity sha512-3j+pRmlF9SgiYDabSdZsBSsN5XHbpXOAce1lWj56IEEaFZVjsiCaxDOA7C9nCcgfVXuvnbxqqEGQvnY+QfBAUw== + +"@polkadot/api-augment@11.0.1": + version "11.0.1" + resolved "https://registry.yarnpkg.com/@polkadot/api-augment/-/api-augment-11.0.1.tgz#a8d3df97aa66f4eff015618e33c32a37a463d7ed" + integrity sha512-C9qVeyglJH3cntwMPCWPMwt81GwDq3kqAknykjcXRJmub+ozSyn43dCvMrw3ZZPGDMxcc3jf3yUPYstvOODJLQ== + dependencies: + "@polkadot/api-base" "11.0.1" + "@polkadot/rpc-augment" "11.0.1" + "@polkadot/types" "11.0.1" + "@polkadot/types-augment" "11.0.1" + "@polkadot/types-codec" "11.0.1" "@polkadot/util" "^12.6.2" tslib "^2.6.2" @@ -933,13 +933,13 @@ "@polkadot/types-codec" "9.14.2" "@polkadot/util" "^10.4.2" -"@polkadot/api-base@10.13.1": - version "10.13.1" - resolved "https://registry.yarnpkg.com/@polkadot/api-base/-/api-base-10.13.1.tgz#efed5bb31e38244b6a68ce56138b97ad82101426" - integrity sha512-Okrw5hjtEjqSMOG08J6qqEwlUQujTVClvY1/eZkzKwNzPelWrtV6vqfyJklB7zVhenlxfxqhZKKcY7zWSW/q5Q== +"@polkadot/api-base@11.0.1": + version "11.0.1" + resolved "https://registry.yarnpkg.com/@polkadot/api-base/-/api-base-11.0.1.tgz#49ca4459c18244d1cae67bc55435ae0aa285fdd7" + integrity sha512-HyISsrG5STzp1V8uxzEC1gBKHGj/Fv0w+IzzP5bodt/8bTjTqyTIKY7DzjydXX/1hPItqbVb+G218oSnnoohqA== dependencies: - "@polkadot/rpc-core" "10.13.1" - "@polkadot/types" "10.13.1" + "@polkadot/rpc-core" "11.0.1" + "@polkadot/types" "11.0.1" "@polkadot/util" "^12.6.2" rxjs "^7.8.1" tslib "^2.6.2" @@ -955,17 +955,17 @@ "@polkadot/util" "^10.4.2" rxjs "^7.8.0" -"@polkadot/api-derive@10.13.1": - version "10.13.1" - resolved "https://registry.yarnpkg.com/@polkadot/api-derive/-/api-derive-10.13.1.tgz#d8827ee83124f3b3f664c415cdde9c6b909e5145" - integrity sha512-ef0H0GeCZ4q5Om+c61eLLLL29UxFC2/u/k8V1K2JOIU+2wD5LF7sjAoV09CBMKKHfkLenRckVk2ukm4rBqFRpg== - dependencies: - "@polkadot/api" "10.13.1" - "@polkadot/api-augment" "10.13.1" - "@polkadot/api-base" "10.13.1" - "@polkadot/rpc-core" "10.13.1" - "@polkadot/types" "10.13.1" - "@polkadot/types-codec" "10.13.1" +"@polkadot/api-derive@11.0.1": + version "11.0.1" + resolved "https://registry.yarnpkg.com/@polkadot/api-derive/-/api-derive-11.0.1.tgz#38a9d61517a891b7b435b6c624f63ad4d2c0cdfa" + integrity sha512-9oqlC7Ujw5vGaeAYyeMP5cFdf0+V2SjzW4yQ63n4XYViRMnCERv+qV9xmMhBGgetFYJtj2zbUDQV9vzkWOPDRg== + dependencies: + "@polkadot/api" "11.0.1" + "@polkadot/api-augment" "11.0.1" + "@polkadot/api-base" "11.0.1" + "@polkadot/rpc-core" "11.0.1" + "@polkadot/types" "11.0.1" + "@polkadot/types-codec" "11.0.1" "@polkadot/util" "^12.6.2" "@polkadot/util-crypto" "^12.6.2" rxjs "^7.8.1" @@ -987,23 +987,23 @@ "@polkadot/util-crypto" "^10.4.2" rxjs "^7.8.0" -"@polkadot/api@10.13.1", "@polkadot/api@^10.13.1": - version "10.13.1" - resolved "https://registry.yarnpkg.com/@polkadot/api/-/api-10.13.1.tgz#47586c070d3fe13a0acc93a8aa9c3a53791284fb" - integrity sha512-YrKWR4TQR5CDyGkF0mloEUo7OsUA+bdtENpJGOtNavzOQUDEbxFE0PVzokzZfVfHhHX2CojPVmtzmmLxztyJkg== +"@polkadot/api@11.0.1", "@polkadot/api@^11.0.1": + version "11.0.1" + resolved "https://registry.yarnpkg.com/@polkadot/api/-/api-11.0.1.tgz#b1b6798f838a1640c7b00e16d1a6c5526363b55a" + integrity sha512-0cE2Abe4Fk1UOkM7li+Of4t9ci7e8Ex7/EBDaawkbOeeDnmN28EqMGY/RTLIQaMVbvctLPgXNzyNLPJSbDfi1A== dependencies: - "@polkadot/api-augment" "10.13.1" - "@polkadot/api-base" "10.13.1" - "@polkadot/api-derive" "10.13.1" + "@polkadot/api-augment" "11.0.1" + "@polkadot/api-base" "11.0.1" + "@polkadot/api-derive" "11.0.1" "@polkadot/keyring" "^12.6.2" - "@polkadot/rpc-augment" "10.13.1" - "@polkadot/rpc-core" "10.13.1" - "@polkadot/rpc-provider" "10.13.1" - "@polkadot/types" "10.13.1" - "@polkadot/types-augment" "10.13.1" - "@polkadot/types-codec" "10.13.1" - "@polkadot/types-create" "10.13.1" - "@polkadot/types-known" "10.13.1" + "@polkadot/rpc-augment" "11.0.1" + "@polkadot/rpc-core" "11.0.1" + "@polkadot/rpc-provider" "11.0.1" + "@polkadot/types" "11.0.1" + "@polkadot/types-augment" "11.0.1" + "@polkadot/types-codec" "11.0.1" + "@polkadot/types-create" "11.0.1" + "@polkadot/types-known" "11.0.1" "@polkadot/util" "^12.6.2" "@polkadot/util-crypto" "^12.6.2" eventemitter3 "^5.0.1" @@ -1069,14 +1069,14 @@ "@substrate/ss58-registry" "^1.44.0" tslib "^2.6.2" -"@polkadot/rpc-augment@10.13.1": - version "10.13.1" - resolved "https://registry.yarnpkg.com/@polkadot/rpc-augment/-/rpc-augment-10.13.1.tgz#83317b46c5ab86104cca2bdc336199db0c25b798" - integrity sha512-iLsWUW4Jcx3DOdVrSHtN0biwxlHuTs4QN2hjJV0gd0jo7W08SXhWabZIf9mDmvUJIbR7Vk+9amzvegjRyIf5+A== +"@polkadot/rpc-augment@11.0.1": + version "11.0.1" + resolved "https://registry.yarnpkg.com/@polkadot/rpc-augment/-/rpc-augment-11.0.1.tgz#f789060f0673c5f4e9efb08fee005e9b4d81f7fb" + integrity sha512-bwBPOJjYoZ5W5yraIHY4aq6/YwomOCe1vXm/u4rXe2x4ksTlqOj6JjPmuRo9jU3ISZE2ZyOGlX4jrHOWIBbJlA== dependencies: - "@polkadot/rpc-core" "10.13.1" - "@polkadot/types" "10.13.1" - "@polkadot/types-codec" "10.13.1" + "@polkadot/rpc-core" "11.0.1" + "@polkadot/types" "11.0.1" + "@polkadot/types-codec" "11.0.1" "@polkadot/util" "^12.6.2" tslib "^2.6.2" @@ -1091,14 +1091,14 @@ "@polkadot/types-codec" "9.14.2" "@polkadot/util" "^10.4.2" -"@polkadot/rpc-core@10.13.1": - version "10.13.1" - resolved "https://registry.yarnpkg.com/@polkadot/rpc-core/-/rpc-core-10.13.1.tgz#a7ea9db8997b68aa6724f28ba76125a73e925575" - integrity sha512-eoejSHa+/tzHm0vwic62/aptTGbph8vaBpbvLIK7gd00+rT813ROz5ckB1CqQBFB23nHRLuzzX/toY8ID3xrKw== +"@polkadot/rpc-core@11.0.1": + version "11.0.1" + resolved "https://registry.yarnpkg.com/@polkadot/rpc-core/-/rpc-core-11.0.1.tgz#70caa5b4a0122dc1cfeffabe3dc47158af9faf34" + integrity sha512-jTnHPG811rSiq/aFypvwb6rWiVJqkJInSRWyBqllbBwuUVEevAc9oZWLx5hHcn+sYW8F6/mTc2hYme4NRoKiKw== dependencies: - "@polkadot/rpc-augment" "10.13.1" - "@polkadot/rpc-provider" "10.13.1" - "@polkadot/types" "10.13.1" + "@polkadot/rpc-augment" "11.0.1" + "@polkadot/rpc-provider" "11.0.1" + "@polkadot/types" "11.0.1" "@polkadot/util" "^12.6.2" rxjs "^7.8.1" tslib "^2.6.2" @@ -1115,14 +1115,14 @@ "@polkadot/util" "^10.4.2" rxjs "^7.8.0" -"@polkadot/rpc-provider@10.13.1": - version "10.13.1" - resolved "https://registry.yarnpkg.com/@polkadot/rpc-provider/-/rpc-provider-10.13.1.tgz#7e17f7be7d9a104b797d8f5aa8f1ed69f800f841" - integrity sha512-oJ7tatVXYJ0L7NpNiGd69D558HG5y5ZDmH2Bp9Dd4kFTQIiV8A39SlWwWUPCjSsen9lqSvvprNLnG/VHTpenbw== +"@polkadot/rpc-provider@11.0.1": + version "11.0.1" + resolved "https://registry.yarnpkg.com/@polkadot/rpc-provider/-/rpc-provider-11.0.1.tgz#f6a7f09cb87e1ed60773c3676bcd334feef08969" + integrity sha512-Cm6myXVbC5RKCKO1gUn/6zPZmAlDg3qaZ8wjiOOJVLIlJjmw4rZRFmc3PEGGDQ3FmFG13jg2hyuVVNzJINGH1w== dependencies: "@polkadot/keyring" "^12.6.2" - "@polkadot/types" "10.13.1" - "@polkadot/types-support" "10.13.1" + "@polkadot/types" "11.0.1" + "@polkadot/types-support" "11.0.1" "@polkadot/util" "^12.6.2" "@polkadot/util-crypto" "^12.6.2" "@polkadot/x-fetch" "^12.6.2" @@ -1133,7 +1133,7 @@ nock "^13.5.0" tslib "^2.6.2" optionalDependencies: - "@substrate/connect" "0.8.8" + "@substrate/connect" "0.8.10" "@polkadot/rpc-provider@9.14.2": version "9.14.2" @@ -1155,13 +1155,13 @@ optionalDependencies: "@substrate/connect" "0.7.19" -"@polkadot/types-augment@10.13.1": - version "10.13.1" - resolved "https://registry.yarnpkg.com/@polkadot/types-augment/-/types-augment-10.13.1.tgz#8f39a46a1a3e100be03cbae06f43a043cb25c337" - integrity sha512-TcrLhf95FNFin61qmVgOgayzQB/RqVsSg9thAso1Fh6pX4HSbvI35aGPBAn3SkA6R+9/TmtECirpSNLtIGFn0g== +"@polkadot/types-augment@11.0.1": + version "11.0.1" + resolved "https://registry.yarnpkg.com/@polkadot/types-augment/-/types-augment-11.0.1.tgz#579ac1ec05dc9ac4aac6f9341488fb4ca5aed966" + integrity sha512-+FTW620owT2VavdwkgwDQyFQwbkCTgF9OqwIOIx0BZ/isLxsoFuN3NJWHAbcFvAfREp0PeNkMUB5jYVu+2Duwg== dependencies: - "@polkadot/types" "10.13.1" - "@polkadot/types-codec" "10.13.1" + "@polkadot/types" "11.0.1" + "@polkadot/types-codec" "11.0.1" "@polkadot/util" "^12.6.2" tslib "^2.6.2" @@ -1175,10 +1175,10 @@ "@polkadot/types-codec" "9.14.2" "@polkadot/util" "^10.4.2" -"@polkadot/types-codec@10.13.1": - version "10.13.1" - resolved "https://registry.yarnpkg.com/@polkadot/types-codec/-/types-codec-10.13.1.tgz#f70cd617160b467685ef3ce5195a04142255ba7b" - integrity sha512-AiQ2Vv2lbZVxEdRCN8XSERiWlOWa2cTDLnpAId78EnCtx4HLKYQSd+Jk9Y4BgO35R79mchK4iG+w6gZ+ukG2bg== +"@polkadot/types-codec@11.0.1": + version "11.0.1" + resolved "https://registry.yarnpkg.com/@polkadot/types-codec/-/types-codec-11.0.1.tgz#56769d1667c7f211d116a12cd0cbb621b41b2dd2" + integrity sha512-kETfTzVEZIQadHRV2QaBc+s+FFiLQ5CCBByCQuo+KJz6S8I6Jz3dUfvyMv3RV58oquJqSDf6bEWo+fsTm7ATqQ== dependencies: "@polkadot/util" "^12.6.2" "@polkadot/x-bigint" "^12.6.2" @@ -1193,12 +1193,12 @@ "@polkadot/util" "^10.4.2" "@polkadot/x-bigint" "^10.4.2" -"@polkadot/types-create@10.13.1": - version "10.13.1" - resolved "https://registry.yarnpkg.com/@polkadot/types-create/-/types-create-10.13.1.tgz#99470816d0d2ca32a6a5ce6d701b4199e8700f66" - integrity sha512-Usn1jqrz35SXgCDAqSXy7mnD6j4RvB4wyzTAZipFA6DGmhwyxxIgOzlWQWDb+1PtPKo9vtMzen5IJ+7w5chIeA== +"@polkadot/types-create@11.0.1": + version "11.0.1" + resolved "https://registry.yarnpkg.com/@polkadot/types-create/-/types-create-11.0.1.tgz#2a69b2d9b8ad83fadecb65d5447f5f6b3e5f22b2" + integrity sha512-YJy/qlN1zmXbR36lhzKXSfFU2Iw1iD/g42HdUJ9jw9vXUyN6K0BVKiMSMXDXvwAEKV5QoUwaTWQRKQAjIjPxlw== dependencies: - "@polkadot/types-codec" "10.13.1" + "@polkadot/types-codec" "11.0.1" "@polkadot/util" "^12.6.2" tslib "^2.6.2" @@ -1211,15 +1211,15 @@ "@polkadot/types-codec" "9.14.2" "@polkadot/util" "^10.4.2" -"@polkadot/types-known@10.13.1": - version "10.13.1" - resolved "https://registry.yarnpkg.com/@polkadot/types-known/-/types-known-10.13.1.tgz#8cca2d3f2c4ef67849f66ba4a35856063ec61f5f" - integrity sha512-uHjDW05EavOT5JeU8RbiFWTgPilZ+odsCcuEYIJGmK+es3lk/Qsdns9Zb7U7NJl7eJ6OWmRtyrWsLs+bU+jjIQ== +"@polkadot/types-known@11.0.1": + version "11.0.1" + resolved "https://registry.yarnpkg.com/@polkadot/types-known/-/types-known-11.0.1.tgz#e0a4cf2a2b1b0796141ba966185bfa6ffc130c82" + integrity sha512-MOA4Dl3uql32ruq728aBkHFVj/WkCQL+FGYdNz3oJNx1A+x49g2AP2VUC5O/wSJAFT44KWRzvfPe94MOeXUh9Q== dependencies: "@polkadot/networks" "^12.6.2" - "@polkadot/types" "10.13.1" - "@polkadot/types-codec" "10.13.1" - "@polkadot/types-create" "10.13.1" + "@polkadot/types" "11.0.1" + "@polkadot/types-codec" "11.0.1" + "@polkadot/types-create" "11.0.1" "@polkadot/util" "^12.6.2" tslib "^2.6.2" @@ -1235,10 +1235,10 @@ "@polkadot/types-create" "9.14.2" "@polkadot/util" "^10.4.2" -"@polkadot/types-support@10.13.1": - version "10.13.1" - resolved "https://registry.yarnpkg.com/@polkadot/types-support/-/types-support-10.13.1.tgz#d4b58c8d9bcbb8e897a255d9a66c217dcaa6ead4" - integrity sha512-4gEPfz36XRQIY7inKq0HXNVVhR6HvXtm7yrEmuBuhM86LE0lQQBkISUSgR358bdn2OFSLMxMoRNoh3kcDvdGDQ== +"@polkadot/types-support@11.0.1": + version "11.0.1" + resolved "https://registry.yarnpkg.com/@polkadot/types-support/-/types-support-11.0.1.tgz#31a319a0abe2a3f9b8424ca84acf21c2d0303d13" + integrity sha512-/Vln4yC1PxorZe7s/NeZzfw7Ee/zEeeY/EQ7I/q5ACirurE0Y7vN/7UdX0SwsxdWuUayUZGs3mNosO6nT8TXRQ== dependencies: "@polkadot/util" "^12.6.2" tslib "^2.6.2" @@ -1251,15 +1251,15 @@ "@babel/runtime" "^7.20.13" "@polkadot/util" "^10.4.2" -"@polkadot/types@10.13.1": - version "10.13.1" - resolved "https://registry.yarnpkg.com/@polkadot/types/-/types-10.13.1.tgz#979d652dc11af9cb8b32e7a55839e9762532755d" - integrity sha512-Hfvg1ZgJlYyzGSAVrDIpp3vullgxrjOlh/CSThd/PI4TTN1qHoPSFm2hs77k3mKkOzg+LrWsLE0P/LP2XddYcw== +"@polkadot/types@11.0.1": + version "11.0.1" + resolved "https://registry.yarnpkg.com/@polkadot/types/-/types-11.0.1.tgz#9d3ab9aff79c9c3c6761c89be69b30318ec6495c" + integrity sha512-bl5UcCZkwFXYOOxuSJCHAHRiW/bGbNSL+7ekDhiBuR/GeVuTFo5n1Z0pVwTQPeKTw4YAW+k37nq0i3/FsltT/A== dependencies: "@polkadot/keyring" "^12.6.2" - "@polkadot/types-augment" "10.13.1" - "@polkadot/types-codec" "10.13.1" - "@polkadot/types-create" "10.13.1" + "@polkadot/types-augment" "11.0.1" + "@polkadot/types-codec" "11.0.1" + "@polkadot/types-create" "11.0.1" "@polkadot/util" "^12.6.2" "@polkadot/util-crypto" "^12.6.2" rxjs "^7.8.1" @@ -1621,7 +1621,7 @@ resolved "https://registry.yarnpkg.com/@substrate/connect-extension-protocol/-/connect-extension-protocol-2.0.0.tgz#badaa6e6b5f7c7d56987d778f4944ddb83cd9ea7" integrity sha512-nKu8pDrE3LNCEgJjZe1iGXzaD6OSIDD4Xzz/yo4KO9mQ6LBvf49BVrt4qxBFGL6++NneLiWUZGoh+VSd4PyVIg== -"@substrate/connect-known-chains@^1.1.1": +"@substrate/connect-known-chains@^1.1.4": version "1.1.4" resolved "https://registry.yarnpkg.com/@substrate/connect-known-chains/-/connect-known-chains-1.1.4.tgz#1b0b4b19c7bd0c1b3ed6f567a22e9fb9c42b8e64" integrity sha512-iT+BdKqvKl/uBLd8BAJysFM1BaMZXRkaXBP2B7V7ob/EyNs5h0EMhTVbO6MJxV/IEOg5OKsyl6FUqQK7pKnqyw== @@ -1635,27 +1635,27 @@ "@substrate/smoldot-light" "0.7.9" eventemitter3 "^4.0.7" -"@substrate/connect@0.8.8": - version "0.8.8" - resolved "https://registry.yarnpkg.com/@substrate/connect/-/connect-0.8.8.tgz#80879f2241e2bd4f24a9aa25d7997fd91a5e68e3" - integrity sha512-zwaxuNEVI9bGt0rT8PEJiXOyebLIo6QN1SyiAHRPBOl6g3Sy0KKdSN8Jmyn++oXhVRD8aIe75/V8ZkS81T+BPQ== +"@substrate/connect@0.8.10": + version "0.8.10" + resolved "https://registry.yarnpkg.com/@substrate/connect/-/connect-0.8.10.tgz#810b6589f848828aa840c731a1f36b84fe0e5956" + integrity sha512-DIyQ13DDlXqVFnLV+S6/JDgiGowVRRrh18kahieJxhgvzcWicw5eLc6jpfQ0moVVLBYkO7rctB5Wreldwpva8w== dependencies: "@substrate/connect-extension-protocol" "^2.0.0" - "@substrate/connect-known-chains" "^1.1.1" - "@substrate/light-client-extension-helpers" "^0.0.4" + "@substrate/connect-known-chains" "^1.1.4" + "@substrate/light-client-extension-helpers" "^0.0.6" smoldot "2.0.22" -"@substrate/light-client-extension-helpers@^0.0.4": - version "0.0.4" - resolved "https://registry.yarnpkg.com/@substrate/light-client-extension-helpers/-/light-client-extension-helpers-0.0.4.tgz#a5958d5c1aac7df69f55bd90991aa935500f8124" - integrity sha512-vfKcigzL0SpiK+u9sX6dq2lQSDtuFLOxIJx2CKPouPEHIs8C+fpsufn52r19GQn+qDhU8POMPHOVoqLktj8UEA== +"@substrate/light-client-extension-helpers@^0.0.6": + version "0.0.6" + resolved "https://registry.yarnpkg.com/@substrate/light-client-extension-helpers/-/light-client-extension-helpers-0.0.6.tgz#bec1c7997241226db50b44ad85a992b4348d21c3" + integrity sha512-girltEuxQ1BvkJWmc8JJlk4ZxnlGXc/wkLcNguhY+UoDEMBK0LsdtfzQKIfrIehi4QdeSBlFEFBoI4RqPmsZzA== dependencies: - "@polkadot-api/client" "0.0.1-492c132563ea6b40ae1fc5470dec4cd18768d182.1.0" - "@polkadot-api/json-rpc-provider" "0.0.1-492c132563ea6b40ae1fc5470dec4cd18768d182.1.0" - "@polkadot-api/json-rpc-provider-proxy" "0.0.1-492c132563ea6b40ae1fc5470dec4cd18768d182.1.0" - "@polkadot-api/substrate-client" "0.0.1-492c132563ea6b40ae1fc5470dec4cd18768d182.1.0" + "@polkadot-api/json-rpc-provider" "0.0.1" + "@polkadot-api/json-rpc-provider-proxy" "0.0.1" + "@polkadot-api/observable-client" "0.1.0" + "@polkadot-api/substrate-client" "0.0.1" "@substrate/connect-extension-protocol" "^2.0.0" - "@substrate/connect-known-chains" "^1.1.1" + "@substrate/connect-known-chains" "^1.1.4" rxjs "^7.8.1" "@substrate/smoldot-light@0.7.9": From f0576a7a4b1194d1fc9b7123d14190d93a61546e Mon Sep 17 00:00:00 2001 From: Alessio Onori Date: Wed, 24 Apr 2024 11:15:22 +0200 Subject: [PATCH 2/3] polkadot fix --- src/claimer.ts | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/claimer.ts b/src/claimer.ts index 368d715..7bca995 100644 --- a/src/claimer.ts +++ b/src/claimer.ts @@ -154,7 +154,17 @@ export class Claimer { //bugFix: https://github.com/polkadot-js/api/issues/5859 //temporary solution - const unclaimedFixed = unclaimed.filter(x=>x>6513) + const chainName = (await this.api.rpc.system.chain()).toString().toLowerCase() + const unclaimedFixed = unclaimed.filter(x => { + switch (chainName) { + case "kusama": + return x>6513 + case "polkadot": + return x>1419 + default: + return true + } + }) validatorInfo.unclaimedPayouts=unclaimedFixed return unclaimedFixed From 63e2d214c0337ab0f5c1bc18d9ab5c1a70e29214 Mon Sep 17 00:00:00 2001 From: Alessio Onori Date: Thu, 25 Apr 2024 07:24:19 +0200 Subject: [PATCH 3/3] typo --- src/claimer.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/claimer.ts b/src/claimer.ts index 7bca995..dc450f6 100644 --- a/src/claimer.ts +++ b/src/claimer.ts @@ -145,9 +145,9 @@ export class Claimer { }) const claimedIdx: Set = new Set - const stakingQuey = await this.api.derive.staking.query(validatorAddress,{withLedger:true, withClaimedRewardsEras: true}) - stakingQuey.stakingLedger.legacyClaimedRewards.forEach(r=>claimedIdx.add(r.toNumber())) - stakingQuey.claimedRewardsEras.forEach(r=>claimedIdx.add(r.toNumber())) + const stakingQuery = await this.api.derive.staking.query(validatorAddress,{withLedger:true, withClaimedRewardsEras: true}) + stakingQuery.stakingLedger.legacyClaimedRewards.forEach(r=>claimedIdx.add(r.toNumber())) + stakingQuery.claimedRewardsEras.forEach(r=>claimedIdx.add(r.toNumber())) const unclaimed: number[] = Array.from(setDifference(ownRewardsIdx,claimedIdx)) this.logger.debug(unclaimed.toString())