Skip to content

Commit

Permalink
fix: update polkadot-js deps, and fix tests, and types for assets (#777)
Browse files Browse the repository at this point in the history
* fix: update polkadot-js deps

* fix: change with PalletsPalletAssetsBalance as u128, instead of TAssetBalance u64

* fix pallet assets

* lint
  • Loading branch information
TarikGul committed Nov 29, 2021
1 parent 5bf57b4 commit 51eaa91
Show file tree
Hide file tree
Showing 6 changed files with 149 additions and 250 deletions.
18 changes: 9 additions & 9 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,9 @@
"test:test-release": "yarn start:test-release"
},
"dependencies": {
"@polkadot/api": "^6.9.2",
"@polkadot/api": "^6.10.1",
"@polkadot/apps-config": "0.98.2-94",
"@polkadot/util-crypto": "^7.9.2",
"@polkadot/util-crypto": "^8.0.2",
"@polkadot/x-rxjs": "^6.11.1",
"@substrate/calc": "^0.2.6",
"argparse": "^2.0.1",
Expand All @@ -78,13 +78,13 @@
"tsc-watch": "^4.4.0"
},
"resolutions": {
"@polkadot/api": "6.9.2",
"@polkadot/keyring": "7.9.2",
"@polkadot/networks": "7.9.2",
"@polkadot/types": "6.9.2",
"@polkadot/types-known": "6.9.2",
"@polkadot/util": "7.9.2",
"@polkadot/util-crypto": "7.9.2",
"@polkadot/api": "6.10.1",
"@polkadot/keyring": "8.0.2",
"@polkadot/networks": "8.0.2",
"@polkadot/types": "6.10.1",
"@polkadot/types-known": "6.10.1",
"@polkadot/util": "8.0.2",
"@polkadot/util-crypto": "8.0.2",
"@polkadot/wasm-crypto": "4.4.1",
"node-forge": ">=0.10.0",
"node-fetch": ">=2.6.1",
Expand Down
9 changes: 5 additions & 4 deletions src/services/accounts/AccountsAssetsService.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,9 @@ const assetBalanceObjThree = {
};

const assetBalanceFactory = {
'10': assetBalanceObjOne as PalletAssetsAssetBalance,
'20': assetBalanceObjTwo as PalletAssetsAssetBalance,
'30': assetBalanceObjThree as PalletAssetsAssetBalance,
'10': assetBalanceObjOne as unknown as PalletAssetsAssetBalance,
'20': assetBalanceObjTwo as unknown as PalletAssetsAssetBalance,
'30': assetBalanceObjThree as unknown as PalletAssetsAssetBalance,
};

const assetStorageKeyOne = statemintTypeFactory.storageKey(
Expand Down Expand Up @@ -120,7 +120,8 @@ Object.assign(assetsInfo, {
* @param assetId options are 10, 20, 30
*/
const assetsAccount = (assetId: number | AssetId, _address: string) => {
const id = typeof assetId === 'number' ? assetId : assetId.toNumber();
const id =
typeof assetId === 'number' ? assetId : parseInt(assetId.toString());

switch (id) {
case 10:
Expand Down
9 changes: 5 additions & 4 deletions src/services/pallets/PalletsAssetsService.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,9 @@ const assetBalanceObjThree = {
};

const assetBalanceFactory = {
'10': assetBalanceObjOne as PalletAssetsAssetBalance,
'20': assetBalanceObjTwo as PalletAssetsAssetBalance,
'30': assetBalanceObjThree as PalletAssetsAssetBalance,
'10': assetBalanceObjOne as unknown as PalletAssetsAssetBalance,
'20': assetBalanceObjTwo as unknown as PalletAssetsAssetBalance,
'30': assetBalanceObjThree as unknown as PalletAssetsAssetBalance,
};

const assetStorageKeyOne = statemintTypeFactory.storageKey(
Expand Down Expand Up @@ -125,7 +125,8 @@ Object.assign(assetsInfo, {
* @param assetId options are 10, 20, 30
*/
const assetsAccount = (assetId: number | AssetId, _address: string) => {
const id = typeof assetId === 'number' ? assetId : assetId.toNumber();
const id =
typeof assetId === 'number' ? assetId : parseInt(assetId.toString());

switch (id) {
case 10:
Expand Down
12 changes: 5 additions & 7 deletions src/types/responses/AccountAssets.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
import {
TAssetBalance,
TAssetDepositBalance,
} from '@polkadot/types/interfaces';
import {} from '@polkadot/types';
import { TAssetDepositBalance } from '@polkadot/types/interfaces';
import { AssetId } from '@polkadot/types/interfaces/runtime';
import { bool } from '@polkadot/types/primitive';
import { bool, u128 } from '@polkadot/types/primitive';

import { IAt } from '.';

Expand All @@ -15,7 +13,7 @@ export interface IAssetBalance {
/**
* The units in which substrate records balances.
*/
balance: TAssetBalance;
balance: u128;
/**
* Whether this asset class is frozen except for permissioned/admin instructions.
*/
Expand Down Expand Up @@ -45,6 +43,6 @@ export interface IAccountAssetsBalances {
*/
export interface IAccountAssetApproval {
at: IAt;
amount: TAssetBalance | null;
amount: u128 | null;
deposit: TAssetDepositBalance | null;
}
5 changes: 3 additions & 2 deletions src/types/responses/Assets.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import { Option } from '@polkadot/types/codec';
import { AssetDetails, AssetMetadata } from '@polkadot/types/interfaces/';
import { AssetMetadata } from '@polkadot/types/interfaces';
import { PalletAssetsAssetDetails } from '@polkadot/types/lookup';

import { IAt } from '.';

export interface IAssetInfo {
at: IAt;
assetInfo: Option<AssetDetails>;
assetInfo: Option<PalletAssetsAssetDetails>;
assetMetaData: AssetMetadata;
}
Loading

0 comments on commit 51eaa91

Please sign in to comment.