From d5fc9c00801a9ca87a2d05d25a6effc6f617f316 Mon Sep 17 00:00:00 2001 From: mrq Date: Thu, 18 Jan 2024 02:29:09 +0100 Subject: [PATCH] support for new native account format --- package.json | 2 +- patches/@galacticcouncil+sdk+0.3.0.patch | 10 ----- src/api/accountBalances.ts | 12 +++--- src/api/balances.ts | 4 +- .../table/data/WalletAssetsTableData.utils.ts | 4 +- yarn.lock | 42 ++++++++++++------- 6 files changed, 39 insertions(+), 35 deletions(-) delete mode 100644 patches/@galacticcouncil+sdk+0.3.0.patch diff --git a/package.json b/package.json index 0a9d4442..fb33ceef 100644 --- a/package.json +++ b/package.json @@ -31,7 +31,7 @@ "@galacticcouncil/math-lbp": "^0.1.3", "@galacticcouncil/math-liquidity-mining": "^0.1.3", "@galacticcouncil/math-xyk": "^0.1.3", - "@galacticcouncil/sdk": "^0.3.0", + "@galacticcouncil/sdk": "0.3.1", "@galacticcouncil/ui": "^1.2.12", "@lit-labs/react": "^1.1.0", "@polkadot/api": "10.9.1", diff --git a/patches/@galacticcouncil+sdk+0.3.0.patch b/patches/@galacticcouncil+sdk+0.3.0.patch deleted file mode 100644 index 7eb35957..00000000 --- a/patches/@galacticcouncil+sdk+0.3.0.patch +++ /dev/null @@ -1,10 +0,0 @@ -diff --git a/node_modules/@galacticcouncil/sdk/dist/types/client/PolkadotApi.d.ts b/node_modules/@galacticcouncil/sdk/dist/types/client/PolkadotApi.d.ts -index c9b72ae..9106edd 100644 ---- a/node_modules/@galacticcouncil/sdk/dist/types/client/PolkadotApi.d.ts -+++ b/node_modules/@galacticcouncil/sdk/dist/types/client/PolkadotApi.d.ts -@@ -1,5 +1,4 @@ - import { ApiPromise } from '@polkadot/api'; --import '@galacticcouncil/api-augment/hydradx'; - import '@galacticcouncil/api-augment/basilisk'; - export declare abstract class PolkadotApiClient { - protected readonly api: ApiPromise; diff --git a/src/api/accountBalances.ts b/src/api/accountBalances.ts index 4d1cfc7b..59cfc181 100644 --- a/src/api/accountBalances.ts +++ b/src/api/accountBalances.ts @@ -65,12 +65,14 @@ const getTokenAccountBalancesList = const [, assetId] = pairs[idx] if (assetId.toString() === NATIVE_ASSET_ID) { + let {data} = natives[nativeIdx] + const frozen = data.feeFrozen ? data.feeFrozen.add( + data.miscFrozen, + ) : data.frozen values.push({ - free: natives[nativeIdx].data.free, - reserved: natives[nativeIdx].data.reserved, - frozen: natives[nativeIdx].data.feeFrozen.add( - natives[nativeIdx].data.miscFrozen, - ), + free: data.free, + reserved: data.reserved, + frozen, }) nativeIdx += 1 diff --git a/src/api/balances.ts b/src/api/balances.ts index 8cbe5b82..6e60d5e2 100644 --- a/src/api/balances.ts +++ b/src/api/balances.ts @@ -16,8 +16,8 @@ export const getTokenBalance = if (id.toString() === NATIVE_ASSET_ID) { const res = await api.query.system.account(account) const freeBalance = new BigNumber(res.data.free.toHex()) - const miscFrozenBalance = new BigNumber(res.data.miscFrozen.toHex()) - const feeFrozenBalance = new BigNumber(res.data.feeFrozen.toHex()) + const miscFrozenBalance = new BigNumber(res.data.miscFrozen ? res.data.miscFrozen.toHex() : res.data.frozen.toHex()) + const feeFrozenBalance = new BigNumber(res.data.feeFrozen ? res.data.feeFrozen.toHex() : res.data.frozen.toHex()) const reservedBalance = new BigNumber(res.data.reserved.toHex()) const balance = new BigNumber( diff --git a/src/sections/wallet/assets/table/data/WalletAssetsTableData.utils.ts b/src/sections/wallet/assets/table/data/WalletAssetsTableData.utils.ts index 309e91d4..0f6a24f0 100644 --- a/src/sections/wallet/assets/table/data/WalletAssetsTableData.utils.ts +++ b/src/sections/wallet/assets/table/data/WalletAssetsTableData.utils.ts @@ -278,8 +278,8 @@ const getNativeBalances = ( const dp = BN_10.pow(decimals) const free = balance.free.toBigNumber() const reservedBN = balance.reserved.toBigNumber() - const feeFrozen = balance.feeFrozen.toBigNumber() - const miscFrozen = balance.miscFrozen.toBigNumber() + const feeFrozen = balance.feeFrozen ? balance.feeFrozen.toBigNumber() : balance.frozen.toBigNumber() + const miscFrozen = balance.miscFrozen ? balance.miscFrozen.toBigNumber() : balance.frozen.toBigNumber() const total = free.plus(reservedBN).div(dp) const totalUSD = total.times(spotPrice) diff --git a/yarn.lock b/yarn.lock index 35004d95..c18a35b3 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1984,19 +1984,19 @@ integrity sha512-PybIwxqrPHJm96z5GWQPxIZgq8pGcNpM9tTyorxeHGbn2rF54QTN01TQNitn/jIQoByjZggo8szqdO1AktZH9A== "@galacticcouncil/math-omnipool@^0.1.3": - version "0.1.3" - resolved "https://registry.yarnpkg.com/@galacticcouncil/math-omnipool/-/math-omnipool-0.1.3.tgz#45ccb95c8196768e8a96577f56f7f90d48dcb44b" - integrity sha512-uA0O+9KA+BlFeLyU7vhKKhJEiiKUwu5ozD14fhJ3vCm11XbGQPwEboChiICXAKysc8BMDejAqpKBmKOEjiRBaw== + version "0.1.4" + resolved "https://registry.yarnpkg.com/@galacticcouncil/math-omnipool/-/math-omnipool-0.1.4.tgz#4c7b29108e5e34cad35debc2a052e536ad9061eb" + integrity sha512-Hvkf+hGbzDvtRCTpp/x0aqaITy7ONLgajrVaSkV3bOeq1+q7gKRz+Lb0gxpwVwxp1DuzNqURi9C7uOfAwd2LTA== "@galacticcouncil/math-xyk@^0.1.3": version "0.1.3" resolved "https://registry.yarnpkg.com/@galacticcouncil/math-xyk/-/math-xyk-0.1.3.tgz#d729a50ae19a29413718c41e1991bdaac1a040ec" integrity sha512-tIXNOyBJO3eP4SDVuX4qtCk264cjba0dPi4aVGjinY5I6LtRYpOPt6zRypTaGiwHhfqOT6xWHiEHAa8jYhVU3A== -"@galacticcouncil/sdk@^0.3.0": - version "0.3.0" - resolved "https://registry.yarnpkg.com/@galacticcouncil/sdk/-/sdk-0.3.0.tgz#53c127096d834ef303248141170e7b7943bee722" - integrity sha512-besDXf9gLKooJh+Gdu2szka2WD12dguz2NzSo6GPw2Xa88larVDSt/E2xWq14QIU2/3XexLPRigaOsWgfxorGg== +"@galacticcouncil/sdk@0.3.1": + version "0.3.1" + resolved "https://registry.yarnpkg.com/@galacticcouncil/sdk/-/sdk-0.3.1.tgz#e87ab5e948f64b0b5edd3056b1f0664f83add7da" + integrity sha512-ed/mMJWD9iYFcG3hg5jGOHsL/KibjJJLrr15nBHR4lC61SiiktuQbCkfDQGmHDTJpiC5bJt4TYGIWnkqLGsYEw== dependencies: "@galacticcouncil/math-lbp" "^0.1.3" "@galacticcouncil/math-omnipool" "^0.1.3" @@ -6097,11 +6097,16 @@ ci-info@^2.0.0: resolved "https://registry.yarnpkg.com/ci-info/-/ci-info-2.0.0.tgz#67a9e964be31a51e15e5010d58e6f12834002f46" integrity sha512-5tK7EtrZ0N+OLFMthtqOj4fI2Jeb88C4CAZPu25LDVUgXJ0A3Js4PMGqrn0JU1W0Mh1/Z8wZzYPxqUrXeBboCQ== -ci-info@^3.2.0, ci-info@^3.7.0: +ci-info@^3.2.0: version "3.8.0" resolved "https://registry.yarnpkg.com/ci-info/-/ci-info-3.8.0.tgz#81408265a5380c929f0bc665d62256628ce9ef91" integrity sha512-eXTggHWSooYhq49F2opQhuHWgzucfF2YgODK4e1566GQs5BIfP30B0oenwBJHfWxAs2fyPB1s7Mg949zLf61Yw== +ci-info@^3.7.0: + version "3.9.0" + resolved "https://registry.yarnpkg.com/ci-info/-/ci-info-3.9.0.tgz#4279a62028a7b1f262f3473fc9605f5e218c59b4" + integrity sha512-NIxF55hv4nSqQswkAeiOi1r83xy8JldOFDTWiug55KBu9Jnblncd2U6ViHmYgHf01TPZS77NJBhBMKdWj9HQMQ== + classnames@^2.2.5: version "2.3.2" resolved "https://registry.yarnpkg.com/classnames/-/classnames-2.3.2.tgz#351d813bf0137fcc6a76a16b88208d2560a0d924" @@ -10029,9 +10034,9 @@ patch-package@^6.5.0: yaml "^1.10.2" patch-package@^7.0.0: - version "7.0.0" - resolved "https://registry.yarnpkg.com/patch-package/-/patch-package-7.0.0.tgz#5c646b6b4b4bf37e5184a6950777b21dea6bb66e" - integrity sha512-eYunHbnnB2ghjTNc5iL1Uo7TsGMuXk0vibX3RFcE/CdVdXzmdbMsG/4K4IgoSuIkLTI5oHrMQk4+NkFqSed0BQ== + version "7.0.2" + resolved "https://registry.yarnpkg.com/patch-package/-/patch-package-7.0.2.tgz#c01589bb6964854b5210506a5845d47900641f5a" + integrity sha512-PMYfL8LXxGIRmxXLqlEaBxzKPu7/SdP13ld6GSfAUJUZRmBDPp8chZs0dpzaAFn9TSPnFiMwkC6PJt6pBiAl8Q== dependencies: "@yarnpkg/lockfile" "^1.1.0" chalk "^4.1.2" @@ -10043,7 +10048,7 @@ patch-package@^7.0.0: minimist "^1.2.6" open "^7.4.2" rimraf "^2.6.3" - semver "^5.6.0" + semver "^7.5.3" slash "^2.0.0" tmp "^0.0.33" yaml "^2.2.2" @@ -11075,6 +11080,13 @@ semver@^7.3.7: dependencies: lru-cache "^6.0.0" +semver@^7.5.3: + version "7.5.4" + resolved "https://registry.yarnpkg.com/semver/-/semver-7.5.4.tgz#483986ec4ed38e1c6c48c34894a9182dbff68a6e" + integrity sha512-1bCSESV6Pv+i21Hvpxp3Dx+pSD8lIPt8uVjRrxAUt/nbswYc+tK6Y2btiULjd4+fnq15PX+nqQDC7Oft7WkwcA== + dependencies: + lru-cache "^6.0.0" + semver@~7.0.0: version "7.0.0" resolved "https://registry.yarnpkg.com/semver/-/semver-7.0.0.tgz#5f3ca35761e47e05b206c6daff2cf814f0316b8e" @@ -12487,9 +12499,9 @@ yaml@^1.10.0, yaml@^1.10.2: integrity sha512-r3vXyErRCYJ7wg28yvBY5VSoAF8ZvlcW9/BwUzEtUsjvX/DKs24dIkuwjtuprwJJHsbyUbLApepYTR1BN4uHrg== yaml@^2.2.2: - version "2.3.1" - resolved "https://registry.yarnpkg.com/yaml/-/yaml-2.3.1.tgz#02fe0975d23cd441242aa7204e09fc28ac2ac33b" - integrity sha512-2eHWfjaoXgTBC2jNM1LRef62VQa0umtvRiDSk6HSzW7RvS5YtkabJrwYLLEKWBc8a5U2PTSCs+dJjUTJdlHsWQ== + version "2.3.4" + resolved "https://registry.yarnpkg.com/yaml/-/yaml-2.3.4.tgz#53fc1d514be80aabf386dc6001eb29bf3b7523b2" + integrity sha512-8aAvwVUSHpfEqTQ4w/KMlf3HcRdt50E5ODIQJBw1fQ5RL34xabzxtUlzTXVqc4rkZsPbvrXKWnABCD7kWSmocA== yargs-parser@^13.1.2: version "13.1.2"