Skip to content

Commit

Permalink
Added eslint. (#108)
Browse files Browse the repository at this point in the history
  • Loading branch information
Hathoriel authored Aug 12, 2021
1 parent 18313f0 commit 58b2e4a
Show file tree
Hide file tree
Showing 348 changed files with 8,116 additions and 7,621 deletions.
2 changes: 2 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
node_modules
dist
18 changes: 18 additions & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"root": true,
"parser": "@typescript-eslint/parser",
"plugins": [
"@typescript-eslint"
],
"extends": [
"eslint:recommended",
"plugin:@typescript-eslint/eslint-recommended",
"plugin:@typescript-eslint/recommended"
],
"rules": {
"semi": ["error", "never"],
"@typescript-eslint/ban-ts-comment": "off",
"@typescript-eslint/no-var-requires": "off",
"@typescript-eslint/explicit-module-boundary-types": "off"
}
}
7 changes: 7 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ jobs:
- run: yarn install

- run: yarn build

- run: yarn lint
docs:
name: πŸ“„ Generate and deploy docs
runs-on: ubuntu-latest
Expand All @@ -30,6 +32,9 @@ jobs:
- run: yarn install

- run: yarn build

- run: yarn lint

- run: yarn docs

- name: Deploy πŸš€
Expand All @@ -51,6 +56,8 @@ jobs:

- run: yarn build

- run: yarn lint

- run: yarn publish --access public
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
4 changes: 3 additions & 1 deletion .github/workflows/pull-request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,6 @@ jobs:

- run: yarn install

- run: yarn build
- run: yarn build

- run: yarn lint
10 changes: 6 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@tatumio/tatum",
"version": "1.19.8",
"version": "1.19.9",
"description": "",
"main": "dist/src/index.js",
"repository": "https://github.com/tatumio/tatum-js",
Expand All @@ -11,8 +11,8 @@
"clean": "rimraf dist/*",
"build": "tsc",
"prepublish": "npm run clean && npm run build",
"lint": "tslint -p tsconfig.json -c tslint.json --fix",
"docs": "typedoc"
"docs": "typedoc",
"lint": "eslint ./src --ext .ts --fix"
},
"types": "dist/src/index.d.ts",
"keywords": [
Expand Down Expand Up @@ -76,12 +76,14 @@
"@types/jest": "^26.0.4",
"@types/node": "^14.0.14",
"@types/validator": "^13.1.3",
"@typescript-eslint/eslint-plugin": "^4.29.1",
"@typescript-eslint/parser": "^4.29.1",
"dotenv": "^8.2.0",
"eslint": "^7.32.0",
"jest": "^26.6.3",
"rimraf": "^3.0.2",
"ts-jest": "^26.1.1",
"ts-node": "^8.10.2",
"tslint": "^6.1.2",
"typedoc": "^0.21.5",
"typescript": "^4.3.2"
},
Expand Down
16 changes: 8 additions & 8 deletions src/blockchain/ada.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {get, post} from '../connector/tatum';
import {AdaBlock, AdaBlockChainInfo, AdaTransaction, AdaUtxo, TransactionHash} from '../model';
import {get, post} from '../connector/tatum'
import {AdaBlock, AdaBlockChainInfo, AdaTransaction, AdaUtxo, TransactionHash} from '../model'

/**
* Broadcasts signed transaction to the Ada blockchain. <br>
Expand All @@ -9,25 +9,25 @@ import {AdaBlock, AdaBlockChainInfo, AdaTransaction, AdaUtxo, TransactionHash} f
* @param signatureId
*/
export const adaBroadcast = async (txData: string, signatureId?: string): Promise<TransactionHash> =>
post(`/v3/ada/broadcast`, {txData, signatureId});
post(`/v3/ada/broadcast`, {txData, signatureId})

/**
* Returns information about Ada blockchain. <br>
* For more details, see <a href="https://tatum.io/apidoc#operation/AdaGetBlockChainInfo" target="_blank">Tatum API documentation</a>
*/
export const adaGetBlockChainInfo = async (): Promise<AdaBlockChainInfo> => get(`/v3/ada/info`);
export const adaGetBlockChainInfo = async (): Promise<AdaBlockChainInfo> => get(`/v3/ada/info`)

/**
* Returns block by its hash from Ada blockchain. <br>
* For more details, see <a href="https://tatum.io/apidoc#operation/AdaGetBlock" target="_blank">Tatum API documentation</a>
*/
export const adaGetBlock = async (hash: string): Promise<AdaBlock> => get(`/v3/ada/block/${hash}`);
export const adaGetBlock = async (hash: string): Promise<AdaBlock> => get(`/v3/ada/block/${hash}`)

/**
* Returns transaction by hash from Ada blockchain. <br>
* For more details, see <a href="https://tatum.io/apidoc#operation/AdaGetRawTransaction" target="_blank">Tatum API documentation</a>
*/
export const adaGetTransaction = async (hash: string): Promise<AdaTransaction> => get(`/v3/ada/transaction/${hash}`);
export const adaGetTransaction = async (hash: string): Promise<AdaTransaction> => get(`/v3/ada/transaction/${hash}`)

/**
* Returns transactions by address from Ada blockchain. <br>
Expand All @@ -39,10 +39,10 @@ export const adaGetTransaction = async (hash: string): Promise<AdaTransaction> =
* For more details, see <a href="https://tatum.io/apidoc#operation/AdaGetTxByAddress" target="_blank">Tatum API documentation</a>
*/
export const adaGetTransactionsByAccount = async (address: string, limit: number, offset: number): Promise<AdaTransaction[]> =>
get(`/v3/ada/account/${address}/transactions?limit=${limit}?offset=${offset}`);
get(`/v3/ada/account/${address}/transactions?limit=${limit}?offset=${offset}`)

/**
* Returns UTXOs by address from Ada blockchain. <br>
* For more details, see <a href="https://tatum.io/apidoc#operation/AdaGetTxByAddress" target="_blank">Tatum API documentation</a>
*/
export const adaGetUtxos = async (address: string): Promise<AdaUtxo[]> => get(`/v3/ada/${address}/utxos`);
export const adaGetUtxos = async (address: string): Promise<AdaUtxo[]> => get(`/v3/ada/${address}/utxos`)
12 changes: 6 additions & 6 deletions src/blockchain/bcash.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { get, post } from '../connector/tatum'
import {BchBlock, BchInfo, BchTx, BlockHash, TransactionHash} from '../model';
import {BchBlock, BchInfo, BchTx, BlockHash, TransactionHash} from '../model'

/**
* Broadcasts signed transaction to the Bch blockchain. <br>
* For more details, see <a href="https://tatum.io/apidoc#operation/BchBroadcast" target="_blank">Tatum API documentation</a>
*/
export const bcashBroadcast = async (txData: string, signatureId?: string): Promise<TransactionHash> =>
post(`/v3/bcash/broadcast`, { txData, signatureId });
post(`/v3/bcash/broadcast`, { txData, signatureId })

/**
* Returns information about Bch blockchain. <br>
Expand All @@ -24,7 +24,7 @@ export const bcashGetBlock = async (hash: string): Promise<BchBlock> => get(`/v3
* Returns block hash by index from Bch blockchain. <br>
* For more details, see <a href="https://tatum.io/apidoc#operation/BchGetBlockHash" target="_blank">Tatum API documentation</a>
*/
export const bcashGetBlockHash = async (i: number): Promise<BlockHash> => get(`/v3/bcash/block/hash/${i}`);
export const bcashGetBlockHash = async (i: number): Promise<BlockHash> => get(`/v3/bcash/block/hash/${i}`)

/**
* Returns transactions for address from Bch blockchain. <br>
Expand All @@ -34,11 +34,11 @@ export const bcashGetBlockHash = async (i: number): Promise<BlockHash> => get(`/
*
* For more details, see <a href="https://tatum.io/apidoc#operation/BchGetTxByAddress" target="_blank">Tatum API documentation</a>
*/
export const bcashGetTxForAccount = async (address: string, skip: number = 0): Promise<BchTx[]> =>
get(`/v3/bcash/transaction/address/${address}?skip=${skip}`);
export const bcashGetTxForAccount = async (address: string, skip = 0): Promise<BchTx[]> =>
get(`/v3/bcash/transaction/address/${address}?skip=${skip}`)

/**
* Returns transaction by hash from Bch blockchain. <br>
* For more details, see <a href="https://tatum.io/apidoc#operation/BchGetRawTransaction" target="_blank">Tatum API documentation</a>
*/
export const bcashGetTransaction = async (hash: string): Promise<BchTx> => get(`/v3/bcash/transaction/${hash}`);
export const bcashGetTransaction = async (hash: string): Promise<BchTx> => get(`/v3/bcash/transaction/${hash}`)
4 changes: 2 additions & 2 deletions src/blockchain/bitcoin.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@ describe('BTC connector', () => {
console.log(currentBlock)
expect(currentBlock).not.toBeNull()
expect(currentBlock).toHaveProperty('chain')
});
});
})
})
20 changes: 10 additions & 10 deletions src/blockchain/bitcoin.ts
Original file line number Diff line number Diff line change
@@ -1,36 +1,36 @@
import { get, post } from '../connector/tatum'
import {BlockHash, BtcBlock, BtcInfo, BtcTx, BtcUTXO, TransactionHash} from '../model';
import {BlockHash, BtcBlock, BtcInfo, BtcTx, BtcUTXO, TransactionHash} from '../model'

/**
* Broadcasts signed transaction to the Btc blockchain. <br>
* For more details, see <a href="https://tatum.io/apidoc#operation/BtcBroadcast" target="_blank">Tatum API documentation</a>
*/
export const btcBroadcast = async (txData: string, signatureId?: string): Promise<TransactionHash> =>
post(`/v3/bitcoin/broadcast`, { txData, signatureId });
post(`/v3/bitcoin/broadcast`, { txData, signatureId })

/**
* Returns information about Btc blockchain. <br>
* For more details, see <a href="https://tatum.io/apidoc#operation/BtcGetBlockChainInfo" target="_blank">Tatum API documentation</a>
*/
export const btcGetCurrentBlock = async (): Promise<BtcInfo> => get('/v3/bitcoin/info');
export const btcGetCurrentBlock = async (): Promise<BtcInfo> => get('/v3/bitcoin/info')

/**
* Returns balance on address from Btc blockchain. <br>
* For more details, see <a href="https://tatum.io/apidoc#operation/BtcGetBalanceOfAddress" target="_blank">Tatum API documentation</a>
*/
export const btcGetBalance = async (address: string): Promise<{ incoming: string, outgoing: string }> => get(`/v3/bitcoin/address/balance/${address}`);
export const btcGetBalance = async (address: string): Promise<{ incoming: string, outgoing: string }> => get(`/v3/bitcoin/address/balance/${address}`)

/**
* Returns block by its hash from Btc blockchain. <br>
* For more details, see <a href="https://tatum.io/apidoc#operation/BtcGetBlock" target="_blank">Tatum API documentation</a>
*/
export const btcGetBlock = async (hash: string): Promise<BtcBlock> => get(`/v3/bitcoin/block/${hash}`);
export const btcGetBlock = async (hash: string): Promise<BtcBlock> => get(`/v3/bitcoin/block/${hash}`)

/**
* Returns block hash by index from Btc blockchain. <br>
* For more details, see <a href="https://tatum.io/apidoc#operation/BtcGetBlockHash" target="_blank">Tatum API documentation</a>
*/
export const btcGetBlockHash = async (i: number): Promise<BlockHash> => get(`/v3/bitcoin/block/hash/${i}`);
export const btcGetBlockHash = async (i: number): Promise<BlockHash> => get(`/v3/bitcoin/block/hash/${i}`)

/**
* Returns the UTXO of given transaction and output index from Btc blockchain. <br>
Expand All @@ -44,7 +44,7 @@ export const btcGetBlockHash = async (i: number): Promise<BlockHash> => get(`/v3
* @param i Index of tx output to check if it has been spent or not.
* For more details, see <a href="https://tatum.io/apidoc#operation/BtcGetUTXO" target="_blank">Tatum API documentation</a>
*/
export const btcGetUTXO = async (hash: string, i: number): Promise<BtcUTXO> => get(`/v3/bitcoin/utxo/${hash}/${i}`);
export const btcGetUTXO = async (hash: string, i: number): Promise<BtcUTXO> => get(`/v3/bitcoin/utxo/${hash}/${i}`)

/**
* Returns transactions by address from Btc blockchain. <br>
Expand All @@ -55,11 +55,11 @@ export const btcGetUTXO = async (hash: string, i: number): Promise<BtcUTXO> => g
*
* For more details, see <a href="https://tatum.io/apidoc#operation/BtcGetTxByAddress" target="_blank">Tatum API documentation</a>
*/
export const btcGetTxForAccount = async (address: string, pageSize: number = 50, offset: number = 0): Promise<BtcTx[]> =>
get(`/v3/bitcoin/transaction/address/${address}?pageSize=${pageSize}&offset=${offset}`);
export const btcGetTxForAccount = async (address: string, pageSize = 50, offset = 0): Promise<BtcTx[]> =>
get(`/v3/bitcoin/transaction/address/${address}?pageSize=${pageSize}&offset=${offset}`)

/**
* Returns transaction by hash from Btc blockchain. <br>
* For more details, see <a href="https://tatum.io/apidoc#operation/BtcGetRawTransaction" target="_blank">Tatum API documentation</a>
*/
export const btcGetTransaction = async (hash: string): Promise<BtcTx> => get(`/v3/bitcoin/transaction/${hash}`);
export const btcGetTransaction = async (hash: string): Promise<BtcTx> => get(`/v3/bitcoin/transaction/${hash}`)
8 changes: 4 additions & 4 deletions src/blockchain/bnb.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import {get, post} from '../connector/tatum';
import {TransactionHash} from '../model';
import {get, post} from '../connector/tatum'
import {TransactionHash} from '../model'

/**
* Broadcasts signed transaction to the Bnb blockchain. <br>
* For more details, see <a href="https://tatum.io/apidoc#operation/BnbBroadcast" target="_blank">Tatum API documentation</a>
*/
export const bnbBroadcast = async (txData: string, signatureId?: string): Promise<TransactionHash> =>
post(`/v3/bnb/broadcast`, {txData, signatureId});
post(`/v3/bnb/broadcast`, {txData, signatureId})

/**
* Returns account by address from Bnb blockchain. <br>
* For more details, see <a href="https://tatum.io/apidoc#operation/BnbGetAccount" target="_blank">Tatum API documentation</a>
*/
export const bnbGetAccount = async (address: string): Promise<{ account_number: number, address: string, sequence: number }> => get(`/v3/bnb/account/${address}`);
export const bnbGetAccount = async (address: string): Promise<{ account_number: number, address: string, sequence: number }> => get(`/v3/bnb/account/${address}`)
22 changes: 11 additions & 11 deletions src/blockchain/bsc.ts
Original file line number Diff line number Diff line change
@@ -1,56 +1,56 @@
import BigNumber from 'bignumber.js';
import {get, post} from '../connector/tatum';
import {EstimateGasEth, EthBlock, EthEstimateGas, EthTx, TransactionHash} from '../model';
import BigNumber from 'bignumber.js'
import {get, post} from '../connector/tatum'
import {EstimateGasEth, EthBlock, EthEstimateGas, EthTx, TransactionHash} from '../model'

/**
* Broadcasts signed transaction to the Bsc blockchain. <br>
* For more details, see <a href="https://tatum.io/apidoc#operation/BscBroadcast" target="_blank">Tatum API documentation</a>
*/
export const bscBroadcast = async (txData: string, signatureId?: string): Promise<TransactionHash> =>
post(`/v3/bsc/broadcast`, {txData, signatureId});
post(`/v3/bsc/broadcast`, {txData, signatureId})

/**
* Returns a number of outgoing BSC transactions for the address from Bsc blockchain. <br>
* When a transaction is sent, there can be multiple outgoing transactions, which are not yet processed by the blockchain.
* To distinguish between them, there is a counter called a nonce, which represents the order of the transaction in the list of outgoing transactions. <br>
* For more details, see <a href="https://tatum.io/apidoc#operation/BscGetTransactionCount" target="_blank">Tatum API documentation</a>
*/
export const bscGetTransactionsCount = async (address: string): Promise<number> => get(`/v3/bsc/transaction/count/${address}`);
export const bscGetTransactionsCount = async (address: string): Promise<number> => get(`/v3/bsc/transaction/count/${address}`)

/**
* Returns information about Bsc blockchain. <br>
* For more details, see <a href="https://tatum.io/apidoc#operation/BscGetCurrentBlock" target="_blank">Tatum API documentation</a>
*/
export const bscGetCurrentBlock = async (): Promise<number> => get(`/v3/bsc/block/current`);
export const bscGetCurrentBlock = async (): Promise<number> => get(`/v3/bsc/block/current`)

/**
* Returns block by its hash from Bsc blockchain. <br>
* For more details, see <a href="https://tatum.io/apidoc#operation/BscGetBlock" target="_blank">Tatum API documentation</a>
*/
export const bscGetBlock = async (hash: string): Promise<EthBlock> => get(`/v3/bsc/block/${hash}`);
export const bscGetBlock = async (hash: string): Promise<EthBlock> => get(`/v3/bsc/block/${hash}`)

/**
* Returns balance on address from Bsc blockchain. <br>
* For more details, see <a href="https://tatum.io/apidoc#operation/BscGetBalance" target="_blank">Tatum API documentation</a>
*/
export const bscGetAccountBalance = async (address: string): Promise<BigNumber> => get(`/v3/bsc/account/balance/${address}`);
export const bscGetAccountBalance = async (address: string): Promise<BigNumber> => get(`/v3/bsc/account/balance/${address}`)

/**
* TODO: This endpoint dont exists? @SamuelSramko
* For more details, see <a href="https://tatum.io/apidoc#operation/BscBep20GetBalance" target="_blank">Tatum API documentation</a>
*/
export const bscGetAccountBep20Address = async (address: string, contractAddress: string): Promise<number> =>
get(`/v3/bsc/account/balance/bep20/${address}?contractAddress=${contractAddress}`);
get(`/v3/bsc/account/balance/bep20/${address}?contractAddress=${contractAddress}`)

/**
* Returns transaction by hash from Bsc blockchain. <br>
* For more details, see <a href="https://tatum.io/apidoc#operation/BscGetTransaction" target="_blank">Tatum API documentation</a>
*/
export const bscGetTransaction = async (hash: string): Promise<EthTx> => get(`/v3/bsc/transaction/${hash}`);
export const bscGetTransaction = async (hash: string): Promise<EthTx> => get(`/v3/bsc/transaction/${hash}`)

/**
* Returns gasLimit and gasPrice estimation of the transaction from Bsc blockchain. <br>
* Gas price is obtained from https://explorer.bitquery.io/bsc/gas. <br>
* For more details, see <a href="https://tatum.io/apidoc#operation/BscEstimateGas" target="_blank">Tatum API documentation</a>
*/
export const bscEstimateGas = (body: EstimateGasEth): Promise<EthEstimateGas> => post('/v3/bsc/gas', body, EstimateGasEth);
export const bscEstimateGas = (body: EstimateGasEth): Promise<EthEstimateGas> => post('/v3/bsc/gas', body, EstimateGasEth)
Loading

0 comments on commit 58b2e4a

Please sign in to comment.