Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/develop' into ruslan/swap-fixes2
Browse files Browse the repository at this point in the history
  • Loading branch information
vsubhuman committed Apr 29, 2024
2 parents e517394 + fc27d20 commit 502c85d
Show file tree
Hide file tree
Showing 11 changed files with 20 additions and 95 deletions.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ import styles from './DelegationSendForm.scss';
import globalMessages from '../../../i18n/global-messages';
import WarningBox from '../../widgets/WarningBox';
import type { $npm$ReactIntl$IntlFormat, } from 'react-intl';
import isHexadecimal from 'validator/lib/isHexadecimal';
import LocalizableError from '../../../i18n/LocalizableError';
import { bech32, } from 'bech32';
import { isHex } from '@emurgo/yoroi-lib/dist/internals/utils/index';

const messages = defineMessages({
invalidPoolId: {
Expand All @@ -39,7 +39,7 @@ function validateAndSetPool(
if (id.length !== 56) {
return false;
}
return isHexadecimal(id);
return isHex(id);
}
try {
const payload = Buffer.from(
Expand Down

This file was deleted.

4 changes: 2 additions & 2 deletions packages/yoroi-extension/app/stores/stateless/tokenHelpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ import type {
TokenLookupKey, TokenEntry,
} from '../../api/common/lib/MultiToken';
import type { TokenRow, TokenMetadata } from '../../api/ada/lib/storage/database/primitives/tables';
import { isHexadecimal } from 'validator';
import AssetFingerprint from '@emurgo/cip14-js';
import { AssetNameUtils } from '@emurgo/yoroi-lib/dist/internals/utils/assets';
import type { RemoteTokenInfo } from '../../api/ada/lib/state-fetch/types';
import { isHex } from '@emurgo/yoroi-lib/dist/internals/utils/index';

export function getTokenName(
tokenRow: $ReadOnly<{
Expand All @@ -27,7 +27,7 @@ export function getTokenName(
}

function resolveNameProperties(name: ?string): {| name: string, cip67Tag: ?string |} {
if (name == null || name.length === 0 || !isHexadecimal(name)) {
if (name == null || name.length === 0 || !isHex(name)) {
return { name: '', cip67Tag: null };
}
const { asciiName, hexName, cip67Tag } =
Expand Down
11 changes: 5 additions & 6 deletions packages/yoroi-extension/app/utils/nftMetadata.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
//@flow
import { isArray } from 'util';

import type {
CardanoAssetMintMetadata,
Expand Down Expand Up @@ -41,7 +40,7 @@ export function find721metadata(
}
if (
typeof asset.image === 'string' || (
isArray(asset.image) && asset.image.every(i => typeof i === 'string')
Array.isArray(asset.image) && asset.image.every(i => typeof i === 'string')
)
) {
ret.image = asset.image;
Expand All @@ -51,19 +50,19 @@ export function find721metadata(
}
if (
typeof asset.description === 'string' || (
isArray(asset.description) && asset.description.every(i => typeof i === 'string')
Array.isArray(asset.description) && asset.description.every(i => typeof i === 'string')
)
) {
ret.description = asset.description;
}
if (
isArray(asset.files) &&
Array.isArray(asset.files) &&
asset.files.every(({ name, mediaType, src }) => (
typeof name === 'string' &&
typeof mediaType === 'string' &&
(
typeof src === 'string' ||
(isArray(src) && src.every(s => typeof s === 'string'))
(Array.isArray(src) && src.every(s => typeof s === 'string'))
)
))
) {
Expand Down Expand Up @@ -97,7 +96,7 @@ export function getImageFromTokenMetadata(
return nftMetadata.image;
}
if (
isArray(nftMetadata.image) &&
Array.isArray(nftMetadata.image) &&
nftMetadata.image.every(s => typeof s === 'string')
) {
return nftMetadata.image.join('');
Expand Down
11 changes: 4 additions & 7 deletions packages/yoroi-extension/app/utils/validations.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
// @flow
import BigNumber from 'bignumber.js';
import isInt from 'validator/lib/isInt';
import { MAX_MEMO_SIZE } from '../config/externalStorageConfig';
import type { $npm$ReactIntl$IntlFormat, } from 'react-intl';
import { defineMessages, } from 'react-intl';
import type { NetworkRow, TokenRow } from '../api/ada/lib/storage/database/primitives/tables';
import { isCardanoHaskell, getCardanoHaskellBaseConfig } from '../api/ada/lib/storage/database/prepackaged/networks';
import { getCardanoHaskellBaseConfig, isCardanoHaskell } from '../api/ada/lib/storage/database/prepackaged/networks';
import { getTokenName } from '../stores/stateless/tokenHelpers';
import { truncateToken } from './formatters';

Expand Down Expand Up @@ -50,12 +49,10 @@ export const isValidMemoOptional: string => boolean = (memo) => (
);

export const isWithinSupply: (string, BigNumber) => boolean = (value, totalSupply) => {
const isNumeric = isInt(value, { allow_leading_zeroes: false });
if (!isNumeric) return false;
const numericValue = new BigNumber(value);
const minValue = new BigNumber(1);
const isValid = numericValue.gte(minValue) && numericValue.lte(totalSupply);
return isValid;
return numericValue.isFinite()
&& numericValue.gte(1)
&& numericValue.lte(totalSupply);
};

export async function validateAmount(
Expand Down
4 changes: 3 additions & 1 deletion packages/yoroi-extension/ledger/stores/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ import { SUPPORTED_LOCALS } from '../i18n/translations';
import type { URLParams } from '../types/cmn';
import type { TransportIdType } from '../types/enum';
import { TRANSPORT_ID } from '../types/enum';
import { version as appVersion } from '../../package.json';
import packageInfo from '../../package.json';

const appVersion = packageInfo.version;

/**
* This is the RootStore, RootStore is responsible for creating all store
Expand Down
11 changes: 1 addition & 10 deletions packages/yoroi-extension/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions packages/yoroi-extension/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -221,8 +221,7 @@
"trezor-connect-flow": "Emurgo/trezor-connect-flow#92d6d8c8faef25c0ea1d481aa1ecb4ba77ce539c",
"ua-parser-js": "0.7.24",
"unorm": "1.6.0",
"util": "0.12.5",
"validator": "13.5.2"
"util": "0.12.5"
},
"engineStrict": true,
"engine": {
Expand Down
1 change: 1 addition & 0 deletions packages/yoroi-extension/webpack-mv2/commonConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,7 @@ const optimization = {
const resolve = () /*: * */ => ({
extensions: ['*', '.js', '.wasm'],
fallback: {
vm: false,
fs: false,
path: require.resolve('path-browserify'),
stream: require.resolve('stream-browserify'),
Expand Down
1 change: 1 addition & 0 deletions packages/yoroi-extension/webpack/commonConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,7 @@ const optimization = {
const resolve = () /*: * */ => ({
extensions: ['*', '.js', '.wasm'],
fallback: {
vm: false,
fs: false,
path: require.resolve('path-browserify'),
stream: require.resolve('stream-browserify'),
Expand Down

0 comments on commit 502c85d

Please sign in to comment.