Skip to content

Commit

Permalink
Merge pull request #36 from AcalaNetwork/fix-infra
Browse files Browse the repository at this point in the history
updated infra
  • Loading branch information
shunjizhan authored Aug 30, 2023
2 parents be48201 + f3ea282 commit e3ede18
Show file tree
Hide file tree
Showing 46 changed files with 1,762 additions and 7,920 deletions.
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
**/build/*
**/dist/*
**/coverage/*
**/node_modules/*
**/configs/*
Expand Down
83 changes: 60 additions & 23 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,27 +1,64 @@
const base = require('@polkadot/dev/config/eslint.cjs');

module.exports = {
...base,
ignorePatterns: [
'.eslintrc.js',
'.github/**',
'.vscode/**',
'.yarn/**',
'**/build/*',
'**/coverage/*',
'**/node_modules/*'
root: true,
parser: '@typescript-eslint/parser',
plugins: ['@typescript-eslint', 'import', 'sort-imports-es6-autofix'],
extends: [
'eslint:recommended',
'plugin:@typescript-eslint/recommended',
'plugin:import/recommended',
'plugin:import/typescript',
],
parserOptions: {
project: ['./tsconfig.eslint.json']
},
rules: {
...base.rules,
'@typescript-eslint/no-explicit-any': 'off',
'import/extensions': 'off',
'header/header': 'off',
'sort-keys': 'off',
'@typescript-eslint/no-unsafe-assignment': 'off',
'@typescript-eslint/no-unsafe-member-access': 'off',
'@typescript-eslint/no-unsafe-return': 'off',
}
indent: [2, 2, { SwitchCase: 1 }],
quotes: [2, 'single'],
semi: [1, 'always'],
'no-trailing-spaces': [2],
'quote-props': [2, 'as-needed'],
'eol-last': [2, 'always'],
'object-curly-spacing': [2, 'always'],
'comma-dangle': [2, {
arrays: 'always-multiline',
objects: 'always-multiline',
imports: 'always-multiline',
exports: 'always-multiline',
functions: 'only-multiline',
}],

/* ---------- turn off ---------- */
'@typescript-eslint/no-extra-semi': 0,
'@typescript-eslint/no-use-before-define': 0,
'@typescript-eslint/explicit-member-accessibility': 0,
'@typescript-eslint/naming-convention': 0,
'@typescript-eslint/no-explicit-any': 0, // any is sometimes unavoidable
'@typescript-eslint/consistent-type-definitions': 0, // can use Type and Interface
'@typescript-eslint/explicit-function-return-type': 0, // type inference on return type is useful
'@typescript-eslint/no-parameter-properties': 0,
'@typescript-eslint/typedef': 0,
'no-unused-expressions': 0, // short ciucuit if
'max-lines': 0,
'@typescript-eslint/no-empty-function': 'off',
'@typescript-eslint/explicit-module-boundary-types': 'off',
'sort-imports-es6-autofix/sort-imports-es6': 'warn',
'@typescript-eslint/ban-ts-comment': 'off',
'no-useless-escape': 'off',
'@typescript-eslint/no-non-null-asserted-optional-chain': 'off',
'import/no-named-as-default-member': 'off',
'import/no-named-as-default': 'off',
'@typescript-eslint/no-non-null-assertion': 'off',
'@typescript-eslint/no-unused-vars': [
'warn',
{
argsIgnorePattern: '^_',
varsIgnorePattern: '^_',
caughtErrorsIgnorePattern: '^_',
},
],
},
settings: {
'import/resolver': {
typescript: {
project: './tsconfig.json',
},
},
},
};
2 changes: 1 addition & 1 deletion .github/workflows/checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,4 +55,4 @@ jobs:
- name: build
run: |
yarn install --immutable | grep -v 'YN0013'
yarn build:release
yarn build
3 changes: 2 additions & 1 deletion .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,6 @@ jobs:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
run: |
yarn install --immutable | grep -v 'YN0013'
yarn build:release
yarn build
yarn publish
19 changes: 10 additions & 9 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,22 +17,23 @@
],
"scripts": {
"build": "yarn workspaces foreach -pvit run build",
"build:release": "yarn workspaces foreach -pvit run build:release",
"check-deps": "./node_modules/@open-web3/util/scripts/check-deps.js yarn.lock @polkadot/ @open-web3/",
"clean": "polkadot-dev-clean-build",
"lint": "polkadot-dev-run-lint",
"postinstall": "polkadot-dev-yarn-only",
"lint": "eslint . --ext .ts",
"test": "echo noop",
"bump": "yarn workspaces foreach -vit version",
"publish:manual": "yarn workspaces foreach -vit run pub"
"publish": "yarn workspaces foreach -vit run publish:manual"
},
"devDependencies": {
"@polkadot/api": "^10.9.1",
"@polkadot/dev": "^0.73.11",
"@types/eslint": "^8",
"@types/node": "^20.4.9",
"@typescript-eslint/eslint-plugin": "^6.5.0",
"@typescript-eslint/parser": "^6.5.0",
"eslint": "^8.48.0",
"eslint-import-resolver-typescript": "^3.6.0",
"eslint-plugin-import": "^2.28.1",
"eslint-plugin-sort-imports-es6-autofix": "^0.6.0",
"ts-node": "^10.9.1",
"tsconfig-paths": "^4.2.0",
"typescript": "^5.0.4"
"typescript": "^5.2.2"
},
"packageManager": "[email protected]"
}
4 changes: 2 additions & 2 deletions packages/api-derive/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
},
"homepage": "https://github.com/AcalaNetwork/acala-types.js",
"scripts": {
"build:release": "rm -rf dist && tsc -b --verbose -f",
"pub": "npm publish --tolerate-republish --access public"
"build": "rm -rf dist && tsc -b --verbose -f",
"publish:manual": "npm publish --tolerate-republish --access public"
},
"files": [
"dist"
Expand Down
13 changes: 6 additions & 7 deletions packages/api-derive/src/dex/pool.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
import type { Observable } from 'rxjs';
import type { ApiInterfaceRx } from '@polkadot/api/types';
import type { AcalaPrimitivesCurrencyCurrencyId, AcalaPrimitivesTradingPair } from '@polkadot/types/lookup';
import type { DerivedDexPool } from '../types/dex';

import primitivesConfig from '@acala-network/types/interfaces/primitives/definitions';
import { map } from 'rxjs/operators';

import { memo } from '@polkadot/api-derive/util';
import primitivesConfig from '@acala-network/types/interfaces/primitives/definitions';
import type { AcalaPrimitivesCurrencyCurrencyId, AcalaPrimitivesTradingPair } from '@polkadot/types/lookup';
import type { ApiInterfaceRx } from '@polkadot/api/types';
import type { Observable } from 'rxjs';

import type { DerivedDexPool } from '../types/dex';

const TOKEN_SORT: Record<string, number> = primitivesConfig.types.TokenSymbol._enum;

Expand Down
14 changes: 7 additions & 7 deletions packages/api-derive/src/homa/staking-pool.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import type { BlockNumber, ExchangeRate } from '@acala-network/types/interfaces';
import type { Observable } from 'rxjs';
import type { ApiInterfaceRx } from '@polkadot/api/types';
import type { EraIndex } from '@polkadot/types/interfaces';
import type { AcalaPrimitivesCurrencyCurrencyId } from '@polkadot/types/lookup';
import type { ApiInterfaceRx } from '@polkadot/api/types';
import type { BlockNumber, ExchangeRate } from '@acala-network/types/interfaces';
import type { DerivedStakingPool, DerivedStakingPoolConstants } from '../types/staking-pool';
import type { EraIndex } from '@polkadot/types/interfaces';
import type { Observable } from 'rxjs';

import { combineLatest } from 'rxjs';
import { map } from 'rxjs/operators';
Expand All @@ -16,7 +16,7 @@ function getConstants (api: ApiInterfaceRx): DerivedStakingPoolConstants {
bondingDuration: api.consts.polkadotBridge.bondingDuration as EraIndex,
eraLength: api.consts.polkadotBridge.eraLength as BlockNumber,
stakingCurrency: api.consts.stakingPool.stakingCurrencyId as AcalaPrimitivesCurrencyCurrencyId,
liquidCurrency: api.consts.stakingPool.liquidCurrencyId as AcalaPrimitivesCurrencyCurrencyId
liquidCurrency: api.consts.stakingPool.liquidCurrencyId as AcalaPrimitivesCurrencyCurrencyId,
};
}

Expand All @@ -32,7 +32,7 @@ export function stakingPool (instanceId: string, api: ApiInterfaceRx): () => Obs
api.query.stakingPool.currentEra(),
api.query.stakingPool.stakingPoolLedger(),
api.query.stakingPool.stakingPoolParams(),
api.query.tokens.totalIssuance(constants.liquidCurrency)
api.query.tokens.totalIssuance(constants.liquidCurrency),
]).pipe(
map((result) => {
const [currentEra, ledger, params, liquidIssuance] = result;
Expand All @@ -42,7 +42,7 @@ export function stakingPool (instanceId: string, api: ApiInterfaceRx): () => Obs
ledger,
params,
liquidIssuance,
...constants
...constants,
} as unknown as DerivedStakingPool;
})
);
Expand Down
2 changes: 1 addition & 1 deletion packages/api-derive/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import * as loan from './loan';
export const acalaDerives: DeriveCustom = {
loan: loan as unknown as DeriveCustom[string],
dex: dex as unknown as DeriveCustom[string],
homa: homa as unknown as DeriveCustom[string]
homa: homa as unknown as DeriveCustom[string],
};

export * from './types';
14 changes: 7 additions & 7 deletions packages/api-derive/src/loan/loan-type.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import type { Balance, ExchangeRate, Rate, Ratio } from '@acala-network/types/interfaces';
import type { Observable } from 'rxjs';
import type { ApiInterfaceRx } from '@polkadot/api/types';
import type { AcalaPrimitivesCurrencyCurrencyId, ModuleCdpEngineRiskManagementParams } from '@polkadot/types/lookup';
import type { ApiInterfaceRx } from '@polkadot/api/types';
import type { Balance, ExchangeRate, Rate, Ratio } from '@acala-network/types/interfaces';
import type { DerivedLoanConstants, DerivedLoanOverView, DerivedLoanType } from '../types/loan';
import type { Observable } from 'rxjs';

import { combineLatest } from 'rxjs';
import { map, switchMap } from 'rxjs/operators';
Expand All @@ -20,7 +20,7 @@ function loanConstants (api: ApiInterfaceRx): DerivedLoanConstants {
minimumDebitValue: api.consts.cdpEngine.minimumDebitValue as Balance,
defaultDebitExchangeRate: api.consts.cdpEngine.defaultDebitExchangeRate as ExchangeRate,
defaultLiquidationRatio: api.consts.cdpEngine.defaultLiquidationRatio as Ratio,
defaultLiquidationPenalty: api.consts.cdpEngine.defaultLiquidationPenalty as Rate
defaultLiquidationPenalty: api.consts.cdpEngine.defaultLiquidationPenalty as Rate,
};
}

Expand All @@ -36,7 +36,7 @@ export function loanType (
return memo(instanceId, (currency: AcalaPrimitivesCurrencyCurrencyId) => {
return combineLatest([
api.query.cdpEngine.debitExchangeRate(currency),
api.query.cdpEngine.collateralParams(currency)
api.query.cdpEngine.collateralParams(currency),
]).pipe(
map((result) => {
const constants = loanConstants(api);
Expand All @@ -57,7 +57,7 @@ export function loanType (
requiredCollateralRatio: collateralParams.requiredCollateralRatio,
interestRatePerSec: collateralParams.interestRatePerSec,
maximumTotalDebitValue: collateralParams.maximumTotalDebitValue,
minimumDebitValue: constants.minimumDebitValue
minimumDebitValue: constants.minimumDebitValue,
};
})
);
Expand Down Expand Up @@ -97,7 +97,7 @@ export function loanOverview (
return {
currency,
totalDebit: debit,
totalCollateral: collateral
totalCollateral: collateral,
};
})
)
Expand Down
6 changes: 3 additions & 3 deletions packages/api-derive/src/loan/loan.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import type { AcalaPrimitivesCurrencyCurrencyId } from '@polkadot/types/lookup';
import type { AccountId } from '@acala-network/types/interfaces';
import type { Observable } from 'rxjs';
import type { ApiInterfaceRx } from '@polkadot/api/types';
import type { AcalaPrimitivesCurrencyCurrencyId } from '@polkadot/types/lookup';
import type { DerivedUserLoan } from '../types/loan';
import type { Observable } from 'rxjs';

import { combineLatest } from 'rxjs';
import { map, switchMap } from 'rxjs/operators';
Expand Down Expand Up @@ -30,7 +30,7 @@ export function loan (
account,
currency,
debit,
collateral
collateral,
};
})
)
Expand Down
2 changes: 1 addition & 1 deletion packages/api-derive/src/types/balance.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { Balance } from '@acala-network/types/interfaces';
import type { AcalaPrimitivesCurrencyCurrencyId } from '@polkadot/types/lookup';
import type { Balance } from '@acala-network/types/interfaces';

export interface DerivedBalance {
currency: AcalaPrimitivesCurrencyCurrencyId;
Expand Down
2 changes: 1 addition & 1 deletion packages/api-derive/src/types/loan.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { AccountId, Balance, ExchangeRate, OptionRate, OptionRatio, Rate } from '@acala-network/types/interfaces';
import type { AcalaPrimitivesCurrencyCurrencyId } from '@polkadot/types/lookup';
import type { AccountId, Balance, ExchangeRate, OptionRate, OptionRatio, Rate } from '@acala-network/types/interfaces';

export interface DerivedLoanConstants {
minimumDebitValue: Balance;
Expand Down
2 changes: 1 addition & 1 deletion packages/api-derive/src/types/staking-pool.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { AcalaPrimitivesCurrencyCurrencyId } from '@polkadot/types/lookup';
import type { Balance, BlockNumber, ExchangeRate, Ledger, Params } from '@acala-network/types/interfaces';
import type { EraIndex } from '@polkadot/types/interfaces';
import type { AcalaPrimitivesCurrencyCurrencyId } from '@polkadot/types/lookup';

export interface DerivedStakingPoolConstants {
defaultExchangeRate: ExchangeRate;
Expand Down
4 changes: 2 additions & 2 deletions packages/api-derive/src/utils/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { Observable } from 'rxjs';
import type { ApiInterfaceRx } from '@polkadot/api/types';
import type { AcalaPrimitivesCurrencyCurrencyId } from '@polkadot/types/lookup';
import type { ApiInterfaceRx } from '@polkadot/api/types';
import type { Observable } from 'rxjs';

import { map } from 'rxjs/operators';

Expand Down
4 changes: 2 additions & 2 deletions packages/api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@
"main": "./dist/index.js",
"types": "./dist/index.d.ts",
"scripts": {
"build:release": "rm -rf dist && tsc -b --verbose -f",
"pub": "npm publish --tolerate-republish --access public"
"build": "rm -rf dist && tsc -b --verbose -f",
"publish:manual": "npm publish --tolerate-republish --access public"
},
"dependencies": {
"@acala-network/api-derive": "6.0.0-34",
Expand Down
Loading

0 comments on commit e3ede18

Please sign in to comment.