Skip to content

Commit

Permalink
Merge branch 'main' into fix/mana-calculator/add-input-validation
Browse files Browse the repository at this point in the history
  • Loading branch information
VmMad committed Dec 8, 2023
2 parents d4fa7b7 + aae6af2 commit f5fd225
Show file tree
Hide file tree
Showing 17 changed files with 676 additions and 121 deletions.
32 changes: 32 additions & 0 deletions .github/ISSUE_TEMPLATE/image-request.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
---
name: Image/Diagram/Flowchart/UML Request
about: Request images diagrams, flowcharts, or UMLs for the IOTA Wiki.
title: "[Diagram/Flowchart/UML Request]"
labels: 'diagram-request, flowchart-request, uml-request'
assignees: ''

---

## Description

***Provide a detailed description of the image, diagram, flowchart, or UML you're requesting. Include information like the specific elements to be included, the overall layout, and any text or labels that should be part of the image.***

## Context and Usage

***Explain why this image is important. Provide context or links to where the image will be used within the Wiki.***

## URL of Page

***Specify the URL of the Wiki page where this image will be used.***

## Technical Requirements

***Specify any technical requirements or preferences.***

## Additional Information

***Add any other details, sketches, or references for the requested image here.***

## Contact Person

***Who should be contacted for further information or clarification regarding this request?***
6 changes: 3 additions & 3 deletions cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
"@babel/parser": "^7.23.0",
"@babel/types": "^7.21.5",
"@iota-wiki/core": "workspace:^",
"@yarnpkg/shell": "^3.2.0",
"@yarnpkg/shell": "^3.3.0",
"axios": "^1.6.0",
"clipanion": "^3.2.0-rc.10",
"ink": "^3.2.0",
Expand All @@ -45,12 +45,12 @@
"devDependencies": {
"@types/babel__generator": "^7",
"@types/copyfiles": "^2",
"@types/node": "^16.18.60",
"@types/node": "^16.18.66",
"@types/prettier": "^2",
"copyfiles": "^2.4.1",
"nodemon": "^2.0.16",
"raw-loader": "^4.0.2",
"tsc-alias": "^1.8.6",
"tsc-alias": "^1.8.8",
"typescript-plugin-css-modules": "^4.1.1"
},
"peerDependencies": {
Expand Down
5 changes: 3 additions & 2 deletions docs/build/getting-started/networks-endpoints.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ keywords:
---

import { AddToMetaMaskButton, EVMNetworks } from '@theme/AddToMetaMaskButton';
import { ChainId } from '@theme/ChainId';

# Networks & Endpoints

Expand Down Expand Up @@ -57,7 +58,7 @@ Mainnet.

| Base Token | Protocol | Chain ID | RPC URL | Explorer |
| ------------- | --------- | -------- | ----------------------------------------------------------------------------- | ------------------------------------ |
| Shimmer Token | ISC / EVM | 148 | https://json-rpc.evm.shimmer.network or wss://ws.json-rpc.evm.shimmer.network | https://explorer.evm.shimmer.network |
| Shimmer Token | ISC / EVM | <ChainId url='https://json-rpc.evm.shimmer.network'/> | https://json-rpc.evm.shimmer.network or wss://ws.json-rpc.evm.shimmer.network | https://explorer.evm.shimmer.network |

## Public Testnet

Expand Down Expand Up @@ -86,7 +87,7 @@ This network is subject to occasional resets (no data retention) which are usual

| Base Token | Protocol | Chain ID | RPC URL | Faucet | Explorer |
| ------------------------- | --------- | -------- | -------------------------------------------- | ------------------------------------------ | -------------------------------------------- |
| Testnet Tokens (no value) | ISC / EVM | 1073 | https://json-rpc.evm.testnet.shimmer.network | https://evm-faucet.testnet.shimmer.network | https://explorer.evm.testnet.shimmer.network |
| Testnet Tokens (no value) | ISC / EVM | <ChainId url='https://json-rpc.evm.testnet.shimmer.network'/> | https://json-rpc.evm.testnet.shimmer.network | https://evm-faucet.testnet.shimmer.network | https://explorer.evm.testnet.shimmer.network |

## DevNet

Expand Down
1 change: 1 addition & 0 deletions docs/get-started/introduction/iota/iota-token.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,3 +80,4 @@ IOTA is listed on most major _cryptocurrency_ exchanges:
- [Upbit](https://upbit.com/)
- [Bitvavo](https://bitvavo.com)
- [Indodax](https://indodax.com/)
- [Viviswap](https://viviswap.com/)
1 change: 1 addition & 0 deletions docs/get-started/sidebars.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ module.exports = {
},
items: [
'wallets/firefly',
'wallets/bloom',
{
type: 'link',
label: 'TanglePay',
Expand Down
19 changes: 19 additions & 0 deletions docs/get-started/wallets/bloom.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
---
title: Bloom Wallet
description: A feature-laden Shimmer wallet.
keywords:
- Bloom Wallet
- Shimmer Wallet
- IOTA Wallet
- Software Wallet
- EVM
- DLT
- Cryptocurrency
---
Bloom is a desktop wallet with first-class security developed by former members of the Firefly team. Bloom includes both Shimmer L1 and ShimmerEVM L2 in the same application, so you can seamlessly transfer assets back and forth between Shimmer and ShimmerEVM without the need for other tooling. Over time, Bloom will support the entirety of the IOTA ecosystem, integrating both Shimmer and IOTA networks in a single app experience.


Find more information on the official website and download the Bloom wallet exclusively from:

- [**Bloom**](https://bloomwallet.io/)**:** Official Website
- [**Bloom GitHub Releases**](https://github.com/bloomwalletio/bloom/releases): Official Bloom GitHub Repo
4 changes: 2 additions & 2 deletions docs/learn/protocols/introduction.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
description: Get an overview around IOTA's different protocol versions.
description: Get an overview of IOTA's different protocol versions.
keywords: [
IOTA,
Stardust,
Expand All @@ -15,7 +15,7 @@ keywords: [

# Introduction

This page provides an overview around the different protocol versions within the IOTA ecosystem.
This page provides an overview of the different IOTA protocol versions.

| Name | Release Date | Description | Consensus | Features | Networks |
| ------------------------------------------------------------ | ----------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------- | ------------------------------------------------------------------------------------------------------ | ---------------------------------------------------------------------------------------------------------------------------------------------------------------- |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ To understand how IOTA 2.0 works, one must first understand the vision conceived

:::tip

For more background, three peer-reviewed research papers underpin the theoretical foundation of IOTA 2.0. The Ledger Paper introduces an innovative transaction approach rooted in real-world data, the Networking Paper introduces ‘pre-consensus’ through the IOTA Congestion Control Algorithm (ICCA) to enhance _throughput_ and manage congestion efficiently, and the Consensus Paper guarantees well-informed decision-making by employing the ‘heaviest DAG’ method. Find out more about these papers [in this blog post](htttps://blog.iota.org/solid-foundation-iota20).
For more background, three peer-reviewed research papers underpin the theoretical foundation of IOTA 2.0. The Ledger Paper introduces an innovative transaction approach rooted in real-world data, the Networking Paper introduces ‘pre-consensus’ through the IOTA Congestion Control Algorithm (ICCA) to enhance _throughput_ and manage congestion efficiently, and the Consensus Paper guarantees well-informed decision-making by employing the ‘heaviest DAG’ method. Find out more about these papers [in this blog post](https://blog.iota.org/solid-foundation-iota20/).

:::

Expand Down
8 changes: 8 additions & 0 deletions docs/maintain/hornet/2.0/docs/how_tos/post_installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,3 +71,11 @@ When using our [recommended setup](using_docker.md) this is done for you automat
### Other

You can find all the HTTP REST API related options in the [`config.json` reference](../references/configuration.md#restapi)

## Update to 2.x.x

You can update HORNET to the latest stable version with no breaking updates by running the following command:

```sh
docker compose down && docker compose pull && docker compose up -d
```
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@
"remark-math": "^3.0.1",
"remark-remove-comments": "^0.2.0",
"url-loader": "^4.1.1",
"webpack": "^5.81.0"
"webpack": "^5.89.0"
},
"resolutions": {
"@types/react": "18.2.24",
Expand Down
4 changes: 2 additions & 2 deletions src/components/ManaCalculator/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export const IOTA_SUPPLY = 4600000000000000;
export const IOTA_CONGESTION = {
[CongestionType.HIGH]: 350000000,
[CongestionType.MEDIUM]: 0, // Dynamic
[CongestionType.LOW]: 500000,
[CongestionType.LOW]: 1000,
};

export const IOTA_GENERATION_PER_SLOT = Math.pow(2, -17);
Expand All @@ -39,7 +39,7 @@ export const SHIMMER_SUPPLY = 1813620509000000;
export const SHIMMER_CONGESTION = {
[CongestionType.HIGH]: 275000000,
[CongestionType.MEDIUM]: 0, // Dynamic
[CongestionType.LOW]: 500000,
[CongestionType.LOW]: 1000,
};

export const SHIMMER_GENERATION_PER_SLOT = Math.pow(2, -16);
Expand Down
55 changes: 48 additions & 7 deletions src/components/ManaCalculator/hooks/useManaState.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,20 @@ export function useGivenManaState(

function handleStakeChange(value: string, id: number) {
const stakedTokens = getValidInputValue(value, toMicro);
setState({

const newStateWithValidators = {
...state,
validators: state.validators.map((validator, i) => {
return {
...validator,
lockedStake: i === id ? stakedTokens : validator.lockedStake,
};
}),
};

setState({
...newStateWithValidators,
...getDerivedRoleValues(newStateWithValidators, stakedTokens),
});
}

Expand Down Expand Up @@ -95,9 +101,15 @@ export function useGivenManaState(

function handleOwnStakeChange(value: string) {
const stakedTokens = getValidInputValue(value, toMicro);
setState({

const newState: ManaCalculatorProps = {
...state,
[getStakedOrDelegated(state.userType)]: stakedTokens,
}

setState({
...newState,
...getDerivedRoleValues(newState, stakedTokens),
});
}

Expand Down Expand Up @@ -132,7 +144,7 @@ export function useGivenManaState(
}

function handleAttractedNewDelegatedStakeChange(value: string) {
const attractedNewDelegatedStake = getValidInputValue(value);
const attractedNewDelegatedStake = getValidInputValue(value, toMicro);
setState({
...state,
validator: { ...state.validator, attractedNewDelegatedStake },
Expand Down Expand Up @@ -161,10 +173,12 @@ export function useGivenManaState(
});
}

function handleUserChange(value: UserType) {
function handleUserChange(newUserType: UserType) {
setState({
...state,
userType: value,
userType: newUserType,
[getStakedOrDelegated(newUserType)]: state.heldTokens,
...getDerivedRoleValues(state, state.heldTokens, newUserType),
});
}

Expand All @@ -175,10 +189,19 @@ export function useGivenManaState(

function handleOwnHoldChange(value: string) {
const heldTokens = getValidInputValue(value, toMicro);
setState({

let newState = {
...state,
heldTokens,
});
[getStakedOrDelegated(state.userType)]: heldTokens,
};

newState = {
...newState,
...getDerivedRoleValues(newState, heldTokens),
}

setState(newState);
}

const congestionAmount = getNetworkCongestion(
Expand Down Expand Up @@ -280,6 +303,24 @@ export function getDefaultParameters(
} as ManaCalculatorProps;
}

function getDerivedRoleValues(
state: ManaCalculatorProps,
stakedTokens: number,
userType: UserType = state.userType,
) {
return userType === UserType.VALIDATOR
? {
validator: {
...state.validator,
attractedNewDelegatedStake:
(stakedTokens *
state.validators.reduce((a, b) => a + b.delegatedStake, 0)) /
state.validators.reduce((a, b) => a + b.lockedStake, 0),
},
}
: {};
}

export function getValidators(network: NetworkType): ValidatorProps[] {
const supply = getNetworkSupply(network);

Expand Down
4 changes: 4 additions & 0 deletions src/components/ValidatedInput/ValidatedInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@ export function ValidatedInput({
}
}, [min, max]);

useEffect(() => {
setInputValue(value);
}, [value]);

function verifyMinAndMax(value: string | number) {
let message = '';

Expand Down
5 changes: 3 additions & 2 deletions theme/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,9 @@
"@iota-wiki/plugin-docs": "workspace:^",
"@metamask/providers": "^10.2.1",
"clsx": "^1.2.1",
"html-react-parser": "^4.2.2",
"react-markdown": "6"
"html-react-parser": "^4.2.10",
"react-markdown": "6",
"web3": "^4.2.2"
},
"devDependencies": {
"@docusaurus/types": "2.4.1",
Expand Down
20 changes: 20 additions & 0 deletions theme/src/theme/ChainId/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import { useEffect, useState } from 'react';
import { Web3 } from 'web3';

interface ChainIdProps {
url: string;
}

export function ChainId(props: ChainIdProps) {
const [value, setValue] = useState<string | null>(null);

useEffect(() => {
const web3 = new Web3(props.url);
web3.eth
.getChainId()
.then((chainId) => setValue(chainId.toString()))
.catch((error) => setValue(`Error: ${error.message}`));
}, []);

return value;
}
Loading

0 comments on commit f5fd225

Please sign in to comment.