Skip to content

Commit

Permalink
update deps, restore @babel/runtime in deps, satisfy eslint
Browse files Browse the repository at this point in the history
  • Loading branch information
shrpne committed Mar 30, 2021
1 parent 1682d79 commit c544f28
Show file tree
Hide file tree
Showing 13 changed files with 2,274 additions and 875 deletions.
2 changes: 2 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,8 @@ module.exports = {
'unicorn/number-literal-case': 0,
// allow explicitly return undefined
'unicorn/no-useless-undefined': 0,
// allow forEach
'unicorn/no-array-for-each': 0,
'unicorn/prefer-optional-catch-binding': 0,
'unicorn/prefer-ternary': 0,
'unicorn/prevent-abbreviations': ['error', {
Expand Down
3,049 changes: 2,211 additions & 838 deletions package-lock.json

Large diffs are not rendered by default.

49 changes: 27 additions & 22 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "minter-js-sdk",
"version": "0.38.0-alpha.30",
"version": "0.38.0-alpha.31",
"description": "JS SDK for Minter Blockchain",
"main": "dist/cjs/index.js",
"module": "src/index.js",
Expand All @@ -17,18 +17,23 @@
"bundle": "rollup -c build/rollup.config.js",
"bundle:cjs": "rollup -c build/rollup.cjs.config.js",
"bundle:minify": "rollup -c build/rollup.uglify.config.js",
"prepublishOnly": "npm run lint && npm run jest && npm run build",
"prepublishOnly": "npm run lint && npm run test:src && npm run build && npm run jest:bundle-unit && npm run jest:bundle-cjs-unit",
"lint": "eslint --ext .js ./src ./test",
"lint:fix": "eslint --ext .js ./src ./test --fix",
"test": "npm run jest && npm run test:bundle && npm run test:bundle-cjs",
"test:src": "jest",
"test:src-unit": "jest --testPathIgnorePatterns='<rootDir>/test/api'",
"test:src-e2e": "jest --testPathPattern='api/'",
"test": "npm run test:src && npm run test:bundle && npm run test:bundle-cjs",
"test:light": "npm run test:src && npm run test:bundle-unit && npm run test:bundle-cjs-unit",
"test:src": "npm run jest:src",
"test:bundle": "npm run bundle && npm run jest:bundle",
"test:bundle-cjs": "npm run bundle:cjs && npm run jest:bundle-cjs",
"jest": "jest",
"test:bundle-unit": "npm run bundle && npm run jest:bundle-unit",
"test:bundle-cjs-unit": "npm run bundle:cjs && npm run jest:bundle-cjs-unit",
"jest:src": "jest",
"jest:src-unit": "jest --testPathIgnorePatterns='<rootDir>/test/api'",
"jest:src-e2e": "jest --testPathPattern='api/'",
"jest:bundle": "jest --config jest-bundle.config.js",
"jest:bundle-cjs": "jest --config jest-bundle-cjs.config.js",
"jest:bundle-unit": "jest --config jest-bundle.config.js --testPathIgnorePatterns='<rootDir>/test/api'",
"jest:bundle-cjs-unit": "jest --config jest-bundle-cjs.config.js --testPathIgnorePatterns='<rootDir>/test/api'",
"coverage": "jest --coverage",
"precommit": "echo 'Pre-commit checks...' && npm run lint"
},
Expand All @@ -51,14 +56,15 @@
},
"homepage": "https://github.com/MinterTeam/minter-js-sdk#readme",
"dependencies": {
"@babel/runtime": "^7.13.10",
"axios": "^0.21.1",
"big.js": "^6.0.3",
"bn.js": "^5.1.3",
"bn.js": "^5.2.0",
"buffer-es6": "github:shrpne/buffer-es6#fix-internal-is-buffer",
"ethereum-cryptography": "^0.1.3",
"ethereumjs-util": "^7.0.7",
"ethereumjs-util": "^7.0.9",
"ethjs-util": "^0.1.6",
"lodash-es": "^4.17.20",
"lodash-es": "^4.17.21",
"minterjs-tx": "^10.0.0-alpha.9",
"minterjs-util": "^0.21.0-aplha.12",
"minterjs-wallet": "^6.1.0",
Expand All @@ -67,30 +73,29 @@
"secp256k1": "^4.0.2"
},
"devDependencies": {
"@babel/cli": "^7.12.10",
"@babel/core": "^7.12.10",
"@babel/plugin-transform-runtime": "^7.12.10",
"@babel/preset-env": "^7.12.11",
"@babel/runtime": "^7.12.5",
"@rollup/plugin-babel": "^5.2.2",
"@rollup/plugin-commonjs": "^14",
"@babel/cli": "^7.13.14",
"@babel/core": "^7.13.14",
"@babel/plugin-transform-runtime": "^7.13.10",
"@babel/preset-env": "^7.13.12",
"@rollup/plugin-babel": "^5.3.0",
"@rollup/plugin-commonjs": "^14.0.0",
"@rollup/plugin-json": "^4.1.0",
"@rollup/plugin-node-resolve": "^11.0.1",
"@rollup/plugin-node-resolve": "^11.2.1",
"babel-eslint": "^10.1.0",
"babel-jest": "^26.6.3",
"coveralls": "^3.1.0",
"eslint": "^7.16.0",
"eslint": "^7.23.0",
"eslint-config-airbnb-base": "^14.2.1",
"eslint-import-resolver-alias": "^1.1.2",
"eslint-plugin-import": "^2.22.1",
"eslint-plugin-jest": "^24.1.3",
"eslint-plugin-jest": "^24.3.2",
"eslint-plugin-security": "^1.4.0",
"eslint-plugin-unicorn": "^25.0.1",
"eslint-plugin-unicorn": "^29.0.0",
"jest": "^26.6.3",
"jest-circus": "^26.6.3",
"jest-environment-jsdom": "^25",
"pre-commit": "^1.2.2",
"rollup": "^2.35.1",
"rollup": "^2.44.0",
"rollup-plugin-babel": "^4.4.0",
"rollup-plugin-delete": "^2.0.0",
"rollup-plugin-node-builtins": "^2.1.2",
Expand Down
2 changes: 2 additions & 0 deletions src/api/estimate-coin-buy.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,12 @@ export default function EstimateCoinBuy(apiInstance) {
function estimateCoinBuy(params, axiosOptions) {
if (params.coinIdToSell || params.coinIdToSell === 0) {
params.coinToSell = params.coinIdToSell;
// eslint-disable-next-line no-console
console.warn('coinIdToSell is deprecated, use coinToSell instead');
}
if (params.coinIdToBuy || params.coinIdToBuy === 0) {
params.coinToBuy = params.coinIdToBuy;
// eslint-disable-next-line no-console
console.warn('coinIdToSell is deprecated, use coinToSell instead');
}

Expand Down
2 changes: 2 additions & 0 deletions src/api/estimate-coin-sell-all.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,12 @@ export default function EstimateCoinSellAll(apiInstance) {
function estimateCoinSellAll(params, axiosOptions) {
if (params.coinIdToSell || params.coinIdToSell === 0) {
params.coinToSell = params.coinIdToSell;
// eslint-disable-next-line no-console
console.warn('coinIdToSell is deprecated, use coinToSell instead');
}
if (params.coinIdToBuy || params.coinIdToBuy === 0) {
params.coinToBuy = params.coinIdToBuy;
// eslint-disable-next-line no-console
console.warn('coinIdToSell is deprecated, use coinToSell instead');
}

Expand Down
2 changes: 2 additions & 0 deletions src/api/estimate-coin-sell.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,12 @@ export default function EstimateCoinSell(apiInstance) {
function estimateCoinSell(params, axiosOptions) {
if (params.coinIdToSell || params.coinIdToSell === 0) {
params.coinToSell = params.coinIdToSell;
// eslint-disable-next-line no-console
console.warn('coinIdToSell is deprecated, use coinToSell instead');
}
if (params.coinIdToBuy || params.coinIdToBuy === 0) {
params.coinToBuy = params.coinIdToBuy;
// eslint-disable-next-line no-console
console.warn('coinIdToSell is deprecated, use coinToSell instead');
}

Expand Down
2 changes: 1 addition & 1 deletion src/api/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import axios from 'axios';
// import createError from 'axios/lib/core/createError';
import {API_TYPE_GATE, API_TYPE_NODE} from '../variables.js';
import {API_TYPE_NODE} from '../variables.js';

/**
* @typedef {Object} MinterApiInstanceType
Expand Down
6 changes: 2 additions & 4 deletions src/api/replace-coin.js
Original file line number Diff line number Diff line change
Expand Up @@ -119,11 +119,9 @@ function getTxParamsPathList(txParams) {
if (txType === TX_TYPE.SEND || txType === TX_TYPE.DECLARE_CANDIDACY || txType === TX_TYPE.DELEGATE || txType === TX_TYPE.UNBOND || txType === TX_TYPE.MOVE_STAKE || txType === TX_TYPE.MINT_TOKEN || txType === TX_TYPE.BURN_TOKEN || txType === TX_TYPE.VOTE_COMMISSION) {
pathList.push('data.coin');
} else if (txType === TX_TYPE.SELL || txType === TX_TYPE.SELL_ALL || txType === TX_TYPE.BUY) {
pathList.push('data.coinToSell');
pathList.push('data.coinToBuy');
pathList.push('data.coinToSell', 'data.coinToBuy');
} else if (txType === TX_TYPE.CREATE_SWAP_POOL || txType === TX_TYPE.ADD_LIQUIDITY || txType === TX_TYPE.REMOVE_LIQUIDITY) {
pathList.push('data.coin0');
pathList.push('data.coin1');
pathList.push('data.coin0', 'data.coin1');
} else if (txType === TX_TYPE.MULTISEND) {
txParams.data.list.forEach((item, index) => {
pathList.push(`data.list[${index}].coin`);
Expand Down
3 changes: 2 additions & 1 deletion src/link.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ export function prepareLink(txParams = {}, linkHost = DEFAULT_LINK_HOST) {
data: ensureBufferData(data || txData, type || txType),
};

// eslint-disable-next-line unicorn/consistent-destructuring
let payload = txParams.message || txParams.payload;
if (payload) {
if (typeof payload === 'string') {
Expand Down Expand Up @@ -155,7 +156,7 @@ function base64urlEncode(byteArray) {
function base64urlDecode(base64urlString) {
const padModulus = base64urlString.length % 4;
const padLength = padModulus ? 4 - padModulus : 0;
const pad = new Array(padLength).fill('=').join('');
const pad = Array.from({length: padLength}, () => '=').join('');
return Buffer.from(base64urlString + pad, 'base64');
}

Expand Down
2 changes: 1 addition & 1 deletion src/tx-data/create-coin.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import {TxDataCreateCoin} from 'minterjs-tx';
// import TxDataCreateCoin from 'minterjs-tx/src/tx-data/create-coin.js';
// import {coinToBuffer} from 'minterjs-tx/src/helpers.js';
import {convertFromPip, convertToPip, toBuffer, coinToBuffer, bufferToCoin, COIN_MAX_MAX_SUPPLY, COIN_MIN_MAX_SUPPLY} from 'minterjs-util';
import {convertFromPip, convertToPip, toBuffer, coinToBuffer, bufferToCoin, COIN_MAX_MAX_SUPPLY} from 'minterjs-util';
// import {convertToPip} from 'minterjs-util/src/converter.js';
import {proxyNestedTxData, bufferToInteger, integerToHexString, validateAmount, validateTicker, validateMaxSupply} from '../utils.js';

Expand Down
14 changes: 7 additions & 7 deletions src/tx-decorator/index.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import {TX_TYPE, normalizeTxType} from 'minterjs-util';
import decorateSendTxParams from './send.js';
import decorateSellTxParams from './convert-sell.js';
import decorateBuyTxParams from './convert-buy.js';
import decorateSellAllTxParams from './convert-sell-all.js';
import decorateDeclareCandidacyTxParams from './candidacy-declare.js';
import decorateDelegateTxParams from './stake-delegate.js';
import decorateUnbondTxParams from './stake-unbond.js';
// import decorateSendTxParams from './send.js';
// import decorateSellTxParams from './convert-sell.js';
// import decorateBuyTxParams from './convert-buy.js';
// import decorateSellAllTxParams from './convert-sell-all.js';
// import decorateDeclareCandidacyTxParams from './candidacy-declare.js';
// import decorateDelegateTxParams from './stake-delegate.js';
// import decorateUnbondTxParams from './stake-unbond.js';
import decorateRedeemCheckTxParams from './redeem-check.js';

const noop = (x) => x;
Expand Down
5 changes: 4 additions & 1 deletion test/api/post-tx.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import {
makeSignature,
} from '~/src';
import {ENV_DATA, minterGate, minterNode} from './variables';
import {ensureCustomCoin, getValidatorMinStake, logError} from '~/test/utils.js';
import {ensureCustomCoin, getValidatorMinStake, logError, wait} from '~/test/utils.js';

function getRandomCoin() {
const digits = Math.random().toString().substring(2, 9 + 2);
Expand Down Expand Up @@ -1083,6 +1083,9 @@ describe('multisig', () => {
}
expect(txHash).toHaveLength(66);
expect(txHash.substr(0, 2)).toEqual('Mt');

// wait for tx to get into block
return wait(5000);
})
.catch((error) => {
logError(error);
Expand Down
11 changes: 11 additions & 0 deletions test/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,3 +100,14 @@ export function logError(error) {
console.log(cleanError);
console.log(error?.response?.data ? {data: error.response.data, errorData: error.response.data.error?.data, axiosRequest} : error);
}

/**
* Promisify setTimeout
* @param {number} time - milliseconds
* @return {Promise}
*/
export function wait(time) {
return new Promise((resolve) => {
setTimeout(resolve, time);
});
}

0 comments on commit c544f28

Please sign in to comment.