Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
glevco committed Nov 29, 2024
1 parent 2a2eee6 commit c8323ae
Show file tree
Hide file tree
Showing 27 changed files with 43 additions and 48 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
runs-on: ubuntu-20.04
strategy:
matrix:
node-version: [20.x, 22.x]
node-version: [22.x]
steps:
- name: Checkout
# https://github.com/actions/checkout/releases/tag/v4.1.7
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
timeout-minutes: 40 # default is 360
strategy:
matrix:
node-version: [20.x, 22.x]
node-version: [22.x]
steps:
# https://github.com/actions/checkout/releases/tag/v4.1.7
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332
Expand Down
2 changes: 1 addition & 1 deletion package-lock.json

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

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"author": "Hathor Labs <[email protected]> (https://hathor.network/)",
"version": "0.30.1",
"engines": {
"node": ">=20.0.0",
"node": ">=22.0.0",
"npm": ">=10.0.0"
},
"private": true,
Expand Down
4 changes: 2 additions & 2 deletions src/components/ModalAddManyTokens.js
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,8 @@ class ModalAddManyTokens extends React.Component {
for (const config of toAdd) {
const tokenUid = config.uid;
const { available, locked } = get(tokensBalance, `${tokenUid}.data`, {
available: 0,
locked: 0,
available: 0n,
locked: 0n,
});
const tokenHasZeroBalance = (available + locked) === 0;

Expand Down
2 changes: 1 addition & 1 deletion src/components/ModalUnregisteredTokenInfo.js
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ ModalUnregisteredTokenInfo.propTypes = {
canMint: PropTypes.bool,
transactionsCount: PropTypes.number,
tokenMetadata: PropTypes.object,
totalSupply: PropTypes.number,
totalSupply: PropTypes.bigint,
};

export default ModalUnregisteredTokenInfo;
4 changes: 2 additions & 2 deletions src/components/SendTokensOne.js
Original file line number Diff line number Diff line change
Expand Up @@ -209,8 +209,8 @@ class SendTokensOne extends React.Component {
const tokenBalance = get(this.props.tokensBalance, this.state.selected.uid, {
status: TOKEN_DOWNLOAD_STATUS.LOADING,
data: {
available: 0,
locked: 0,
available: 0n,
locked: 0n,
},
});

Expand Down
8 changes: 4 additions & 4 deletions src/components/TokenAdministrative.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import LOCAL_STORE from '../storage';

const mapStateToProps = (state) => {
const HTR_UID = hathorLib.constants.NATIVE_TOKEN_UID;
const htrBalance = get(state.tokensBalance, `${HTR_UID}.data.available`, 0);
const htrBalance = get(state.tokensBalance, `${HTR_UID}.data.available`, 0n);

return {
htrBalance,
Expand Down Expand Up @@ -53,7 +53,7 @@ class TokenAdministrative extends React.Component {
* action {String} selected action (mint, melt, delegate-mint, delegate-melt, destroy-mint, destroy-melt)
* successMessage {String} success message to show
* errorMessage {String} Message to show in case of error getting token info
* totalSupply {Number} Token total supply
* totalSupply {bigint} Token total supply
* balance.status {String} The current status of the token balance download
* balance.data.available {Number} Amount available of the current token
* balance.data.locked {Number} Amount locked of the current token
Expand All @@ -68,8 +68,8 @@ class TokenAdministrative extends React.Component {
balance: {
status: TOKEN_DOWNLOAD_STATUS.LOADING,
data: {
available: 0,
locked: 0,
available: 0n,
locked: 0n,
},
},
};
Expand Down
10 changes: 5 additions & 5 deletions src/components/TokenBar.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,12 +92,12 @@ export default function TokenBar () {
* Gets the balance of one token
*
* @param {string} uid UID to get balance from
* @return {number} Total token balance
* @return {bigint} Total token balance
*/
const getTokenBalance = (uid) => {
const { available, locked } = get(tokensBalance, `${uid}.data`, {
available: 0,
locked: 0,
available: 0n,
locked: 0n,
});

return available + locked;
Expand Down Expand Up @@ -146,8 +146,8 @@ export default function TokenBar () {
const tokenBalance = get(tokensBalance, `${token.uid}`, {
status: TOKEN_DOWNLOAD_STATUS.LOADING,
data: {
locked: 0,
available: 0
locked: 0n,
available: 0n
}
});

Expand Down
2 changes: 1 addition & 1 deletion src/components/TokenGeneralInfo.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import { useSelector } from 'react-redux';

/**
* @property {string} errorMessage Message to show in case of error getting token info
* @property {number} totalSupply Token total supply
* @property {bigint} totalSupply Token total supply
* @property {boolean} canMint If this token can still be minted
* @property {boolean} canMelt If this token can still be melted
* @property {number} transactionsCount Total number of transactions of this token
Expand Down
2 changes: 1 addition & 1 deletion src/components/WalletBalance.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class WalletBalance extends React.Component {
const token = this.props.tokens.find((token) => token.uid === this.props.selectedToken);
const symbol = token ? token.symbol : '';

const tokenBalance = get(this.props.tokensBalance, `${token.uid}.data`, { available: 0, locked: 0 });
const tokenBalance = get(this.props.tokensBalance, `${token.uid}.data`, { available: 0n, locked: 0n });
const balance = {
available: tokenBalance.available,
locked: tokenBalance.locked,
Expand Down
2 changes: 1 addition & 1 deletion src/components/atomic-swap/ModalAtomicReceive.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export function ModalAtomicReceive ({ sendClickHandler, receivableTokens, manage
const wallet = getGlobalWallet();
const [selectedToken, setSelectedToken] = useState(receivableTokens[0]);
const [address, setAddress] = useState('');
const [amount, setAmount] = useState(0);
const [amount, setAmount] = useState(0n);
const [errMessage, setErrMessage] = useState('');
const modalDomId = 'atomicReceiveModal';
const decimalPlaces = useSelector(state => state.serverInfo.decimalPlaces);
Expand Down
8 changes: 4 additions & 4 deletions src/components/atomic-swap/ModalAtomicSend.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ function UtxoRow ({ wallet, utxo, token, utxoChanged, showAddButton, addButtonHa
setAmount('');
setIsInvalid(true);
setErrMessage(t`Invalid input for this token`)
utxoChanged({ txId, index: outputIndex, amount: 0, tokenId: '' });
utxoChanged({ txId, index: outputIndex, amount: 0n, tokenId: '' });
}

const localDataChanged = async () => {
Expand Down Expand Up @@ -130,7 +130,7 @@ function UtxoSelection ({ wallet, utxos, token, utxosChanged, setErrMessage }) {
export function ModalAtomicSend ({ sendClickHandler, sendableTokens, tokenBalances, manageDomLifecycle, onClose, wallet }) {
const [selectedToken, setSelectedToken] = useState(sendableTokens.length && sendableTokens[0]);
const [changeAddress, setChangeAddress] = useState('');
const [amount, setAmount] = useState(0);
const [amount, setAmount] = useState(0n);
const [errMessage, setErrMessage] = useState('');
const modalDomId = 'atomicSendModal';
const decimalPlaces = useSelector(state => state.serverInfo.decimalPlaces);
Expand All @@ -145,8 +145,8 @@ export function ModalAtomicSend ({ sendClickHandler, sendableTokens, tokenBalanc
{
status: TOKEN_DOWNLOAD_STATUS.LOADING,
data: {
available: 0,
locked: 0,
available: 0n,
locked: 0n,
},
}
);
Expand Down
1 change: 0 additions & 1 deletion src/components/nano-contract/ModalRegisterNanoContract.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import { cleanNanoContractRegisterMetadata, registerNanoContract } from '../../a
import { getGlobalWallet } from "../../modules/wallet";
import { NANOCONTRACT_REGISTER_STATUS } from '../../sagas/nanoContract';
import { colors } from '../../constants';
import hathorLib from '@hathor/wallet-lib';
import ReactLoading from 'react-loading';

/**
Expand Down
2 changes: 0 additions & 2 deletions src/components/nano-contract/NanoContractHistory.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@
import React, { useEffect, useState } from 'react';
import { Link } from 'react-router-dom';
import { t } from 'ttag'
import ReactLoading from 'react-loading';
import colors from '../../index.module.scss';
import hathorLib from '@hathor/wallet-lib';
import { useDispatch } from 'react-redux';
import { NANO_CONTRACT_HISTORY_COUNT } from '../../constants';
Expand Down
2 changes: 1 addition & 1 deletion src/components/tokens/TokenMelt.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class TokenMelt extends React.Component {
/**
* amount {number} Amount of tokens to melt
*/
state = { amount: 0 };
state = { amount: 0n };

constructor(props) {
super(props);
Expand Down
6 changes: 3 additions & 3 deletions src/reducers/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -554,7 +554,7 @@ const removeTokenMetadata = (state, action) => {
const newBalance = Object.assign({}, state.tokensBalance);
if (uid in newBalance && (!!newBalance[uid].data)) {
const balance = newBalance[uid].data;
if ((balance.unlocked + balance.locked) === 0) {
if ((balance.unlocked + balance.locked) === 0n) {
delete newBalance[uid];
}
}
Expand Down Expand Up @@ -627,8 +627,8 @@ export const resetSelectedTokenIfNeeded = (state, action) => {
const tokensBalance = state.tokensBalance;
const selectedToken = state.selectedToken;

const balance = tokensBalance[selectedToken] || { available: 0, locked: 0 };
const hasZeroBalance = (balance.available + balance.locked) === 0;
const balance = tokensBalance[selectedToken] || { available: 0n, locked: 0n };
const hasZeroBalance = (balance.available + balance.locked) === 0n;

if (hasZeroBalance) {
return {
Expand Down
4 changes: 2 additions & 2 deletions src/sagas/tokens.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,8 @@ function* fetchTokenBalance(action) {
const response = yield call(wallet.getBalance.bind(wallet), tokenId);
const token = get(response, 0, {
balance: {
unlocked: 0,
locked: 0,
unlocked: 0n,
locked: 0n,
}
});

Expand Down
3 changes: 1 addition & 2 deletions src/sagas/wallet.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import {
transactionUtils,
errors as hathorErrors,
cryptoUtils,
versionApi,
} from '@hathor/wallet-lib';
import {
takeLatest,
Expand Down Expand Up @@ -596,7 +595,7 @@ export function* handleUpdateTx(action) {

// Always reload balance
yield put(tokenFetchBalanceRequested(tokenUid, true));
yield put(updateTxHistory(tx, tokenUid, txbalance[tokenUid] || 0));
yield put(updateTxHistory(tx, tokenUid, txbalance[tokenUid] || 0n));
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/screens/CreateNFT.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ function CreateNFT() {

const { htrBalance, useWalletService, decimalPlaces } = useSelector((state) => {
const HTR_UID = hathorLib.constants.NATIVE_TOKEN_UID;
const htrBalance = get(state.tokensBalance, `${HTR_UID}.data.available`, 0);
const htrBalance = get(state.tokensBalance, `${HTR_UID}.data.available`, 0n);

return {
htrBalance,
Expand Down
2 changes: 1 addition & 1 deletion src/screens/CreateToken.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ import { getGlobalWallet } from "../modules/wallet";
function CreateToken() {

const { htrBalance, useWalletService, decimalPlaces } = useSelector(state => ({
htrBalance: get(state.tokensBalance, `${hathorLib.constants.NATIVE_TOKEN_UID}.data.available`, 0),
htrBalance: get(state.tokensBalance, `${hathorLib.constants.NATIVE_TOKEN_UID}.data.available`, 0n),
useWalletService: state.useWalletService,
decimalPlaces: state.serverInfo.decimalPlaces,
}));
Expand Down
4 changes: 2 additions & 2 deletions src/screens/NFTList.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ function retrieveNftDataFromState(state) {
const tokenBalance = get(state.tokensBalance, meta.id, {
status: TOKEN_DOWNLOAD_STATUS.LOADING,
data: {
available: 0,
locked: 0,
available: 0n,
locked: 0n,
},
});

Expand Down
4 changes: 2 additions & 2 deletions src/screens/Wallet.js
Original file line number Diff line number Diff line change
Expand Up @@ -315,8 +315,8 @@ function Wallet() {
const tokenBalance = get(tokensBalance, selectedToken, {
status: TOKEN_DOWNLOAD_STATUS.LOADING,
data: {
available: 0,
locked: 0,
available: 0n,
locked: 0n,
},
});

Expand Down
2 changes: 1 addition & 1 deletion src/screens/nano-contract/NanoContractExecuteMethod.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* LICENSE file in the root directory of this source tree.
*/

import React, { useContext, useEffect, useRef, useState } from 'react';
import React, { useContext, useRef, useState } from 'react';
import { t } from 'ttag'
import BackButton from '../../components/BackButton';
import InputNumber from '../../components/InputNumber';
Expand Down
1 change: 0 additions & 1 deletion src/screens/nano-contract/NanoContractList.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
*/

import React, { useContext } from 'react';
import $ from 'jquery';
import { t } from 'ttag'
import { Link } from 'react-router-dom'
import hathorLib from '@hathor/wallet-lib';
Expand Down
2 changes: 1 addition & 1 deletion src/utils/atomicSwap.js
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,7 @@ export const translateTxToProposalUtxo = async (txId, index, wallet) => {
const addressIndex = addressInfo.bip32AddressIndex;

const addressPath = addressIndex ? await wallet.getAddressPathForIndex(addressIndex) : '';
let authorities = 0;
let authorities = 0n;
if (transactionUtils.isMint(txout)) {
authorities += TOKEN_MINT_MASK;
}
Expand Down
6 changes: 3 additions & 3 deletions src/utils/wallet.js
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ const wallet = {
if (registeredTokens.find((x) => x.uid === tokenUid)) {
continue;
}
const balance = tokensBalance[tokenUid] || { available: 0, locked: 0 };
const balance = tokensBalance[tokenUid] || { available: 0n, locked: 0n };
const tokenData = {
uid: tokenUid,
balance: balance,
Expand Down Expand Up @@ -280,7 +280,7 @@ const wallet = {
const tokenUid = registeredObject.uid;

// If there is no entry for this token on tokensBalance, generate an empty balance object.
const balance = get(tokensBalance, `${tokenUid}.data`, { available: 0, locked: 0 });
const balance = get(tokensBalance, `${tokenUid}.data`, { available: 0n, locked: 0n });
const tokenData = {
...registeredObject,
balance: balance,
Expand Down Expand Up @@ -610,7 +610,7 @@ const wallet = {
* @returns {string[]}
*/
listTokensAlwaysShow() {
const alwaysShowMap = LOCAL_STORE.getItem(storageKeys.alwaysShowTokens) || {};;
const alwaysShowMap = LOCAL_STORE.getItem(storageKeys.alwaysShowTokens) || {};
return Object.keys(alwaysShowMap);
},

Expand Down

0 comments on commit c8323ae

Please sign in to comment.