Skip to content

Commit 842920f

Browse files
authored
yarn dedupe & general cleanup (#1392)
* add mayachain protobuf code to .eslintignore too MsgCompiled.js has been ruining eslint's day ever since 34eba6f * remove unmaintained eslint-plugin-ordered-imports * yarn dedupe everything except bignumber.js and bip174 * dedupe bignumber.js Going from 9.1.1 to 9.1.2 is a surprisingly big change in terms of TypeScript type-checking! * add 7 missing TypeScript annotations and correct documentation; getFee()'s alleged return type wasn't accurate. * turn const closures into function declarations TypeScript chokes and finds the type annotations deficient if these are closures, now that we updated bignumber.js. * patch update for 6 packages * patch release 3 more packages
1 parent 6b03221 commit 842920f

File tree

17 files changed

+120
-777
lines changed

17 files changed

+120
-777
lines changed

.changeset/lemon-bobcats-cry.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
---
2+
'@xchainjs/xchain-evm-providers': patch
3+
'@xchainjs/xchain-mayachain': patch
4+
'@xchainjs/xchain-cosmos': patch
5+
'@xchainjs/xchain-kujira': patch
6+
'@xchainjs/xchain-zcash': patch
7+
'@xchainjs/xchain-evm': patch
8+
---
9+
10+
add missing TypeScript annotations for functions using bignumber.js

.changeset/slimy-parrots-rest.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
'@xchainjs/xchain-thorchain-query': patch
3+
'@xchainjs/xchain-aggregator': patch
4+
'@xchainjs/xchain-radix': patch
5+
---
6+
7+
remove references to defunct eslint-plugin-ordered-imports

.eslintignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
**/node_modules/**
22
packages/**/lib/**
3-
packages/xchain-thorchain/src/types/proto/**
3+
packages/xchain-mayachain/src/types/proto/**
4+
packages/xchain-thorchain/src/types/proto/**

.eslintrc

Lines changed: 3 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,11 @@
44
"ecmaVersion": 2018,
55
"sourceType": "module"
66
},
7-
"plugins": ["prettier", "ordered-imports"],
7+
"plugins": ["prettier"],
88
"extends": [
99
"plugin:@typescript-eslint/recommended",
1010
"prettier",
11-
"plugin:prettier/recommended",
12-
"plugin:ordered-imports/recommended"
11+
"plugin:prettier/recommended"
1312
],
1413
"ignorePatterns": "**/*.d.ts",
1514
"rules": {
@@ -27,31 +26,6 @@
2726
],
2827
"@typescript-eslint/no-var-requires": "off",
2928
"@typescript-eslint/no-duplicate-imports": "error",
30-
"no-undef": "off",
31-
"ordered-imports/ordered-imports": [
32-
"error",
33-
{
34-
"symbols-first": false,
35-
"declaration-ordering": ["source", "lowercase-last"],
36-
"specifier-ordering": "lowercase-last",
37-
"group-ordering": [
38-
{
39-
"name": "parent directories",
40-
"match": "^\\.\\.",
41-
"order": 30
42-
},
43-
{
44-
"name": "current directory",
45-
"match": "^\\.",
46-
"order": 40
47-
},
48-
{
49-
"name": "third-party",
50-
"match": ".*",
51-
"order": 10
52-
}
53-
]
54-
}
55-
]
29+
"no-undef": "off"
5630
}
5731
}

package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,6 @@
5454
"dotenv": "^16.0.3",
5555
"eslint": "^8.31.0",
5656
"eslint-config-prettier": "^8.6.0",
57-
"eslint-plugin-ordered-imports": "^0.6.0",
5857
"eslint-plugin-prettier": "^4.2.1",
5958
"husky": "^8.0.0",
6059
"jest": "^29.3.1",

packages/xchain-aggregator/__tests__/mayachainProtocol.test.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
/* eslint-disable ordered-imports/ordered-imports */
21
import { AssetBTC } from '@xchainjs/xchain-bitcoin'
32
import { AssetCacao } from '@xchainjs/xchain-mayachain'
43
import { MayachainAMM } from '@xchainjs/xchain-mayachain-amm'

packages/xchain-aggregator/__tests__/thorhainProtocol.test.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
/* eslint-disable ordered-imports/ordered-imports */
21
import { AssetBTC } from '@xchainjs/xchain-bitcoin'
32
import { AssetCacao } from '@xchainjs/xchain-mayachain'
43
import { AssetRuneNative } from '@xchainjs/xchain-thorchain'

packages/xchain-cosmos/src/const.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { Network } from '@xchainjs/xchain-client/lib'
22
import { CosmosSdkClientParams } from '@xchainjs/xchain-cosmos-sdk'
3-
import { Asset, AssetType, baseAmount } from '@xchainjs/xchain-util'
3+
import { Asset, AssetType, baseAmount, BaseAmount } from '@xchainjs/xchain-util'
44

55
import { getDefaultClientUrls, getDefaultRootDerivationPaths } from './utils'
66

@@ -21,7 +21,7 @@ export const DEFAULT_GAS_LIMIT = '200000'
2121
* As defined in Cosmosstation's web wallet.
2222
* @see https://github.com/cosmostation/web-wallet-ts-react/blob/4d78718b613defbd6c92079b33aa8ce9f86d597c/src/constants/chain.ts#L66
2323
*/
24-
export const DEFAULT_FEE = baseAmount(5000, COSMOS_DECIMAL)
24+
export const DEFAULT_FEE: BaseAmount = baseAmount(5000, COSMOS_DECIMAL)
2525

2626
/**
2727
* Chain identifier for the Cosmos network.

packages/xchain-evm-providers/src/providers/etherscan-v2/utils.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ export const validateSymbol = (symbol?: string | null): boolean => (symbol ? sym
4646
/**
4747
* Calculate fees by multiplying .
4848
*
49-
* @returns {Fees} The default gas price.
49+
* @returns {BaseAmount} The default gas price.
5050
*/
5151
export const getFee = ({
5252
gasPrice,
@@ -56,7 +56,7 @@ export const getFee = ({
5656
gasPrice: BaseAmount
5757
gasLimit: ethers.BigNumber
5858
decimals: number
59-
}) => baseAmount(gasPrice.amount().multipliedBy(gasLimit.toString()), decimals)
59+
}): BaseAmount => baseAmount(gasPrice.amount().multipliedBy(gasLimit.toString()), decimals)
6060

6161
/**
6262
* Get address prefix based on the network.
@@ -166,7 +166,7 @@ export const call = async <T>({
166166
*
167167
* @returns {BigNumber} Estimated gas
168168
*/
169-
export const estimateApprove = async ({
169+
export async function estimateApprove({
170170
provider,
171171
contractAddress,
172172
spenderAddress,
@@ -180,7 +180,7 @@ export const estimateApprove = async ({
180180
fromAddress: Address
181181
abi: ethers.ContractInterface
182182
amount?: BaseAmount
183-
}): Promise<ethers.BigNumber> => {
183+
}): Promise<ethers.BigNumber> {
184184
const txAmount = getApprovalAmount(amount)
185185
return await estimateCall({
186186
provider,
@@ -202,7 +202,7 @@ export const estimateApprove = async ({
202202
* @param {number} walletIndex (optional) HD wallet index
203203
* @returns {boolean} `true` or `false`.
204204
*/
205-
export const isApproved = async ({
205+
export async function isApproved({
206206
provider,
207207
contractAddress,
208208
spenderAddress,
@@ -214,7 +214,7 @@ export const isApproved = async ({
214214
spenderAddress: Address
215215
fromAddress: Address
216216
amount?: BaseAmount
217-
}): Promise<boolean> => {
217+
}): Promise<boolean> {
218218
const txAmount = ethers.BigNumber.from(amount?.amount().toFixed() ?? 1)
219219
const contract: ethers.Contract = new ethers.Contract(contractAddress, erc20ABI, provider)
220220
const allowance: ethers.BigNumberish = await contract.allowance(fromAddress, spenderAddress)

packages/xchain-evm-providers/src/providers/etherscan/utils.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ export const validateSymbol = (symbol?: string | null): boolean => (symbol ? sym
4646
/**
4747
* Calculate fees by multiplying .
4848
*
49-
* @returns {Fees} The default gas price.
49+
* @returns {BaseAmount} The default gas price.
5050
*/
5151
export const getFee = ({
5252
gasPrice,
@@ -56,7 +56,7 @@ export const getFee = ({
5656
gasPrice: BaseAmount
5757
gasLimit: ethers.BigNumber
5858
decimals: number
59-
}) => baseAmount(gasPrice.amount().multipliedBy(gasLimit.toString()), decimals)
59+
}): BaseAmount => baseAmount(gasPrice.amount().multipliedBy(gasLimit.toString()), decimals)
6060

6161
/**
6262
* Get address prefix based on the network.
@@ -166,7 +166,7 @@ export const call = async <T>({
166166
*
167167
* @returns {BigNumber} Estimated gas
168168
*/
169-
export const estimateApprove = async ({
169+
export async function estimateApprove({
170170
provider,
171171
contractAddress,
172172
spenderAddress,
@@ -180,7 +180,7 @@ export const estimateApprove = async ({
180180
fromAddress: Address
181181
abi: ethers.ContractInterface
182182
amount?: BaseAmount
183-
}): Promise<ethers.BigNumber> => {
183+
}): Promise<ethers.BigNumber> {
184184
const txAmount = getApprovalAmount(amount)
185185
return await estimateCall({
186186
provider,
@@ -202,7 +202,7 @@ export const estimateApprove = async ({
202202
* @param {number} walletIndex (optional) HD wallet index
203203
* @returns {boolean} `true` or `false`.
204204
*/
205-
export const isApproved = async ({
205+
export async function isApproved({
206206
provider,
207207
contractAddress,
208208
spenderAddress,
@@ -214,7 +214,7 @@ export const isApproved = async ({
214214
spenderAddress: Address
215215
fromAddress: Address
216216
amount?: BaseAmount
217-
}): Promise<boolean> => {
217+
}): Promise<boolean> {
218218
const txAmount = ethers.BigNumber.from(amount?.amount().toFixed() ?? 1)
219219
const contract: ethers.Contract = new ethers.Contract(contractAddress, erc20ABI, provider)
220220
const allowance: ethers.BigNumberish = await contract.allowance(fromAddress, spenderAddress)

packages/xchain-evm/src/utils.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ export const getFee = ({
5858
gasPrice: BaseAmount
5959
gasLimit: ethers.BigNumber
6060
decimals: number
61-
}) => baseAmount(gasPrice.amount().multipliedBy(gasLimit.toString()), decimals)
61+
}): BaseAmount => baseAmount(gasPrice.amount().multipliedBy(gasLimit.toString()), decimals)
6262

6363
/**
6464
* Get address prefix based on the network.
@@ -186,7 +186,7 @@ export const getContract = async ({
186186
* @param {BaseAmount} amount (optional) The amount of token. By default, it will be unlimited token allowance.
187187
* @returns {Promise<ethers.BigNumber>} The estimated gas.
188188
*/
189-
export const estimateApprove = async ({
189+
export async function estimateApprove({
190190
provider,
191191
contractAddress,
192192
spenderAddress,
@@ -200,7 +200,7 @@ export const estimateApprove = async ({
200200
fromAddress: Address
201201
abi: ethers.ContractInterface
202202
amount?: BaseAmount
203-
}): Promise<ethers.BigNumber> => {
203+
}): Promise<ethers.BigNumber> {
204204
const txAmount = getApprovalAmount(amount)
205205
return await estimateCall({
206206
provider,
@@ -222,7 +222,7 @@ export const estimateApprove = async ({
222222
* @param {number} walletIndex (optional) HD wallet index
223223
* @returns {Promise<boolean>} `true` if the spender is allowed to spend the specified amount, `false` otherwise.
224224
*/
225-
export const isApproved = async ({
225+
export async function isApproved({
226226
provider,
227227
contractAddress,
228228
spenderAddress,
@@ -234,7 +234,7 @@ export const isApproved = async ({
234234
spenderAddress: Address
235235
fromAddress: Address
236236
amount?: BaseAmount
237-
}): Promise<boolean> => {
237+
}): Promise<boolean> {
238238
const txAmount = ethers.BigNumber.from(amount?.amount().toFixed() ?? 1)
239239
const contract: ethers.Contract = new ethers.Contract(contractAddress, erc20ABI, provider)
240240
const allowance: ethers.BigNumberish = await contract.allowance(fromAddress, spenderAddress)

packages/xchain-kujira/src/const.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Asset, AssetType, TokenAsset, baseAmount } from '@xchainjs/xchain-util'
1+
import { Asset, AssetType, TokenAsset, baseAmount, BaseAmount } from '@xchainjs/xchain-util'
22
/**
33
* Decimal places for KUJI asset.
44
*/
@@ -12,7 +12,7 @@ export const DEFAULT_GAS_LIMIT = '200000'
1212
/**
1313
* Default fee for transactions, represented as a base amount.
1414
*/
15-
export const DEFAULT_FEE = baseAmount(5000, KUJI_DECIMAL)
15+
export const DEFAULT_FEE: BaseAmount = baseAmount(5000, KUJI_DECIMAL)
1616

1717
/**
1818
* Chain identifier for KUJI.

packages/xchain-mayachain/src/const.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { Network } from '@xchainjs/xchain-client'
22
import { CosmosSdkClientParams } from '@xchainjs/xchain-cosmos-sdk'
3-
import { Asset, AssetType, TokenAsset, baseAmount } from '@xchainjs/xchain-util'
3+
import { Asset, AssetType, TokenAsset, baseAmount, BaseAmount } from '@xchainjs/xchain-util'
44

55
import types from './types/proto/MsgCompiled'
66
import { getDefaultClientUrls, getDefaultRootDerivationPaths } from './utils'
@@ -48,7 +48,7 @@ export const MAYAChain = 'MAYA' as const
4848
/**
4949
* Default fee for MayaChain transactions.
5050
*/
51-
export const DEFAULT_FEE = baseAmount(2000000000, CACAO_DECIMAL)
51+
export const DEFAULT_FEE: BaseAmount = baseAmount(2000000000, CACAO_DECIMAL)
5252

5353
/**
5454
* Base "chain" asset on MayaChain main net.

packages/xchain-radix/__tests__/client.test.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ import { Convert, Instruction, RadixEngineToolkit } from '@radixdlt/radix-engine
99
import { Balance, Fees, Network, XChainClientParams } from '@xchainjs/xchain-client'
1010
import { AssetType, baseAmount } from '@xchainjs/xchain-util'
1111

12-
// eslint-disable-next-line ordered-imports/ordered-imports
1312
import { generateMnemonic } from 'bip39'
1413

1514
import {

packages/xchain-thorchain-query/src/utils/utils.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ import {
1111
import { BigNumber } from 'bignumber.js'
1212

1313
import { CompatibleAsset, InboundDetail } from '../types'
14-
// eslint-disable-next-line ordered-imports/ordered-imports
1514
import {
1615
AVAXChain,
1716
AssetATOM,

packages/xchain-zcash/src/client.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import {
55
FeeRate,
66
FeeRates,
77
FeeType,
8+
Fees,
89
FeesWithRates,
910
Network,
1011
} from '@xchainjs/xchain-client'
@@ -124,7 +125,7 @@ abstract class Client extends UTXOClient {
124125
throw Error('Error Zcash has flat fee. Fee rates not supported')
125126
}
126127

127-
async getFees(options?: FeeEstimateOptions) {
128+
async getFees(options?: FeeEstimateOptions): Promise<Fees> {
128129
let utxoNumber = 2 // By default pro rought estimation to display on interface
129130
if (options?.sender) {
130131
const utxo = await this.scanUTXOs(options?.sender, false)

0 commit comments

Comments
 (0)