Skip to content

Commit 70072cd

Browse files
committed
chore: fix tests and eslint
1 parent a20604f commit 70072cd

File tree

12 files changed

+91
-359
lines changed

12 files changed

+91
-359
lines changed

tests/.eslintrc

Lines changed: 0 additions & 34 deletions
This file was deleted.

tests/.eslintrc.cjs

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
module.exports = {
2+
parser: '@typescript-eslint/parser',
3+
env: {
4+
browser: true,
5+
jest: true,
6+
node: true,
7+
es6: true,
8+
},
9+
rules: {
10+
'@typescript-eslint/indent': 'off',
11+
quotes: ['error', 'single', { avoidEscape: true }],
12+
'simple-import-sort/imports': 'error',
13+
'sort-imports': 'off',
14+
'import/order': 'off',
15+
'no-dupe-class-members': 'off',
16+
'no-shadow': 'off',
17+
'@typescript-eslint/no-shadow': ['error'],
18+
'arrow-parens': 'off',
19+
'no-useless-constructor': 'off',
20+
'@typescript-eslint/no-useless-constructor': 'error',
21+
'no-only-tests/no-only-tests': [
22+
'error',
23+
{
24+
focus: ['only', 'skip'],
25+
},
26+
],
27+
},
28+
plugins: [
29+
'@typescript-eslint',
30+
'simple-import-sort',
31+
'node',
32+
'import',
33+
'prettier',
34+
'promise',
35+
'no-only-tests',
36+
],
37+
parserOptions: {
38+
sourceType: 'module',
39+
project: './tsconfig.json',
40+
tsconfigRootDir: __dirname,
41+
extraFileExtensions: ['.cjs'],
42+
},
43+
extends: [
44+
'standard',
45+
'semistandard',
46+
'plugin:@typescript-eslint/recommended',
47+
'prettier',
48+
],
49+
ignorePatterns: ['src/polkadot/', 'src/middleware/', 'docs/*', '.eslintrc.cjs'],
50+
};

tests/package.json

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,21 @@
4646
},
4747
"dependencies": {
4848
"@polymeshassociation/local-signing-manager": "^3.5.2",
49-
"@polymeshassociation/polymesh-sdk": "29.0.0-next.4",
49+
"@polymeshassociation/polymesh-sdk": "29.1.0-beta.3",
5050
"cross-fetch": "^4.1.0",
5151
"dotenv": "^16.5.0"
5252
},
53+
"resolutions": {
54+
"@polkadot/api": "11.2.1",
55+
"@polkadot/api-augment": "11.2.1",
56+
"@polkadot/api-base": "11.2.1",
57+
"@polkadot/api-derive": "11.2.1",
58+
"@polkadot/rpc-augment": "11.2.1",
59+
"@polkadot/rpc-core": "11.2.1",
60+
"@polkadot/rpc-provider": "11.2.1",
61+
"@polkadot/types": "11.2.1",
62+
"@polkadot/types-augment": "11.2.1",
63+
"@polkadot/types-known": "11.2.1"
64+
},
5365
"packageManager": "[email protected]+sha512.1fc009bc09d13cfd0e19efa44cbfc2b9cf6ca61482725eb35bbc5e257e093ebf4130db6dfe15d604ff4b79efd8e1e8e99b25fa7d0a6197c9f9826358d4d65c3c"
5466
}

tests/src/__tests__/rest/corporate-actions/dividend-distributions.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,18 @@ import { TestFactory } from '~/helpers';
22
import { RestClient } from '~/rest';
33
import { createAssetParams } from '~/rest/assets/params';
44
import { ProcessMode } from '~/rest/common';
5-
import { Identity } from '~/rest/identities/interfaces';
6-
import { RestSuccessResult } from '~/rest/interfaces';
7-
import { fungibleInstructionParams } from '~/rest/settlements/params';
8-
9-
import { expectBasicTxInfo } from '../utils';
105
import {
11-
createDividendDistributionParams,
126
claimDividendDistributionParams,
7+
createDividendDistributionParams,
8+
modifyDistributionCheckpointParams,
139
payDividendDistributionParams,
1410
reclaimDividendDistributionParams,
15-
modifyDistributionCheckpointParams,
1611
} from '~/rest/corporate-actions/params';
12+
import { Identity } from '~/rest/identities/interfaces';
13+
import { RestSuccessResult } from '~/rest/interfaces';
14+
import { fungibleInstructionParams } from '~/rest/settlements/params';
15+
16+
import { expectBasicTxInfo } from '../utils';
1717

1818
const handles = ['issuer', 'holder'];
1919
let factory: TestFactory;

tests/src/__tests__/sdk/assets/controllerTransfer.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,12 @@
11
import { LocalSigningManager } from '@polymeshassociation/local-signing-manager';
22
import { Polymesh } from '@polymeshassociation/polymesh-sdk';
3-
import { FungibleAsset } from '@polymeshassociation/polymesh-sdk/types';
43

54
import { TestFactory } from '~/helpers';
65
import { fungibleAssetControllerTransfer } from '~/sdk/assets/controllerTransfer';
76

87
let factory: TestFactory;
98

109
describe('controllerTransfer', () => {
11-
let asset: FungibleAsset;
1210
let sdk: Polymesh;
1311
let targetDid: string;
1412

tests/src/rest/client.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ import { Assets } from '~/rest/assets';
55
import { Claims } from '~/rest/claims/client';
66
import { TxBase } from '~/rest/common';
77
import { Compliance } from '~/rest/compliance';
8-
import { Identities } from '~/rest/identities';
98
import { CorporateActions } from '~/rest/corporate-actions';
9+
import { Identities } from '~/rest/identities';
1010
import { Network } from '~/rest/network';
1111
import { Nfts } from '~/rest/nfts';
1212
import { Portfolios } from '~/rest/portfolios';

tests/src/rest/corporate-actions/client.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { RestClient } from '~/rest/client';
22
import { PostResult, RestSuccessResult, ResultSet } from '~/rest/interfaces';
3+
34
import {
45
claimDividendDistributionParams,
56
createDividendDistributionParams,

tests/src/rest/corporate-actions/params.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { BigNumber } from '@polymeshassociation/polymesh-sdk';
22
import { TargetTreatment } from '@polymeshassociation/polymesh-sdk/types';
3+
34
import { TxBase, TxExtras } from '~/rest/common';
45

56
// Shape is intentionally flexible to allow tests to pass specific values

tests/src/sdk/assets/controllerTransfer.ts

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -22,15 +22,16 @@ export const fungibleAssetControllerTransfer = async (
2222

2323
assert(asset);
2424

25-
const [identity, counterParty] = await Promise.all([
25+
const [signerIdentity, counterParty] = await Promise.all([
2626
sdk.getSigningIdentity(),
2727
sdk.identities.getIdentity({ did: targetDid }),
2828
]);
29-
assert(identity);
29+
assert(signerIdentity);
3030
const { account: counterPartyAccount } = await counterParty.getPrimaryAccount();
3131

3232
const transferTx = await sdk.settlements.addInstruction({
33-
legs: [{ asset, from: identity, to: targetDid, amount: new BigNumber(1000) }],
33+
legs: [{ asset, from: signerIdentity, to: targetDid, amount: new BigNumber(1000) }],
34+
venueId: undefined,
3435
});
3536
const instruction = await transferTx.run();
3637
assert(transferTx.isSuccess);
@@ -54,7 +55,7 @@ export const fungibleAssetControllerTransfer = async (
5455

5556
const assetHolders = await asset.assetHolders.get();
5657

57-
const heldByIssuer = assetHolders.data.find(({ identity }) => identity.isEqual(identity));
58+
const heldByIssuer = assetHolders.data.find(({ identity }) => identity.isEqual(signerIdentity));
5859
assert(heldByIssuer);
5960
expect(heldByIssuer.balance.eq(new BigNumber(1100)));
6061

@@ -82,11 +83,11 @@ export const nonFungibleAssetControllerTransfer = async (
8283

8384
assert(collection);
8485

85-
const [identity, counterParty] = await Promise.all([
86+
const [signerIdentity, counterParty] = await Promise.all([
8687
sdk.getSigningIdentity(),
8788
sdk.identities.getIdentity({ did: targetDid }),
8889
]);
89-
assert(identity);
90+
assert(signerIdentity);
9091
assert(counterParty);
9192

9293
const { account: counterPartyAccount } = await counterParty.getPrimaryAccount();
@@ -128,7 +129,8 @@ export const nonFungibleAssetControllerTransfer = async (
128129
const nft2 = await issueTx2.run();
129130

130131
const transferTx = await sdk.settlements.addInstruction({
131-
legs: [{ asset: collection, nfts: [nft, nft2], from: identity, to: targetDid }],
132+
legs: [{ asset: collection, nfts: [nft, nft2], from: signerIdentity, to: targetDid }],
133+
venueId: undefined,
132134
});
133135
const instruction = await transferTx.run();
134136
assert(transferTx.isSuccess);
@@ -152,7 +154,7 @@ export const nonFungibleAssetControllerTransfer = async (
152154

153155
const assetHolders = await collection.assetHolders.get({});
154156

155-
let heldByIssuer = assetHolders.data.find(({ identity }) => identity.isEqual(identity));
157+
let heldByIssuer = assetHolders.data.find(({ identity }) => identity.isEqual(signerIdentity));
156158
assert(heldByIssuer);
157159
expect(heldByIssuer.nfts.length).toEqual(1);
158160
expect(heldByIssuer.nfts[0].id.eq(nft.id));
@@ -169,7 +171,7 @@ export const nonFungibleAssetControllerTransfer = async (
169171
assert(createPortfolioTx.isSuccess);
170172

171173
const controllerTransferTx2 = await collection.controllerTransfer({
172-
originPortfolio: { identity, id: portfolio.id },
174+
originPortfolio: { identity: signerIdentity, id: portfolio.id },
173175
nfts: [nft2],
174176
});
175177
await controllerTransferTx2.run();
@@ -178,7 +180,7 @@ export const nonFungibleAssetControllerTransfer = async (
178180

179181
const assetHolders2 = await collection.assetHolders.get({});
180182

181-
heldByIssuer = assetHolders2.data.find(({ identity }) => identity.isEqual(identity));
183+
heldByIssuer = assetHolders2.data.find(({ identity }) => identity.isEqual(signerIdentity));
182184
assert(heldByIssuer);
183185
expect(heldByIssuer.nfts.length).toEqual(2);
184186

tests/src/sdk/assets/venueFiltering.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { BigNumber, Polymesh } from '@polymeshassociation/polymesh-sdk';
2-
import { FungibleAsset, Identity, VenueType } from '@polymeshassociation/polymesh-sdk/types';
2+
import { FungibleAsset, VenueType } from '@polymeshassociation/polymesh-sdk/types';
33
import assert from 'node:assert';
44

55
/*

0 commit comments

Comments
 (0)