-
Notifications
You must be signed in to change notification settings - Fork 327
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5809 from techiast/feat/integrate-icon-network-wi…
…th-basic-functions Feat/integrate icon network with basic functions
- Loading branch information
Showing
79 changed files
with
4,081 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
--- | ||
"@ledgerhq/live-cli": minor | ||
"ledger-live-desktop": minor | ||
"live-mobile": minor | ||
"@ledgerhq/live-common": minor | ||
"@ledgerhq/cryptoassets": minor | ||
"@ledgerhq/hw-app-icon": minor | ||
--- | ||
|
||
Integrate Sync, Send, Receive, Create Account for Icon network |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
93 changes: 93 additions & 0 deletions
93
apps/ledger-live-desktop/src/renderer/families/icon/AccountBalanceSummaryFooter.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
import React from "react"; | ||
import styled from "styled-components"; | ||
import { useSelector } from "react-redux"; | ||
import { Trans } from "react-i18next"; | ||
import { formatCurrencyUnit } from "@ledgerhq/live-common/currencies/index"; | ||
import Discreet, { useDiscreetMode } from "~/renderer/components/Discreet"; | ||
import { IconAccount } from "@ledgerhq/live-common/families/icon/types"; | ||
|
||
import Box from "~/renderer/components/Box/Box"; | ||
import Text from "~/renderer/components/Text"; | ||
import InfoCircle from "~/renderer/icons/InfoCircle"; | ||
import ToolTip from "~/renderer/components/Tooltip"; | ||
import { localeSelector } from "~/renderer/reducers/settings"; | ||
import { SubAccount } from "@ledgerhq/types-live"; | ||
import { useAccountUnit } from "~/renderer/hooks/useAccountUnit"; | ||
|
||
const Wrapper = styled(Box).attrs(() => ({ | ||
horizontal: true, | ||
mt: 4, | ||
p: 5, | ||
pb: 0, | ||
}))` | ||
border-top: 1px solid ${p => p.theme.colors.palette.text.shade10}; | ||
`; | ||
|
||
const BalanceDetail = styled(Box).attrs(() => ({ | ||
flex: 1.25, | ||
vertical: true, | ||
alignItems: "start", | ||
}))` | ||
&:nth-child(n + 3) { | ||
flex: 0.75; | ||
} | ||
`; | ||
|
||
const TitleWrapper = styled(Box).attrs(() => ({ horizontal: true, alignItems: "center", mb: 1 }))``; | ||
|
||
const Title = styled(Text).attrs(() => ({ | ||
fontSize: 4, | ||
ff: "Inter|Medium", | ||
color: "palette.text.shade60", | ||
}))` | ||
line-height: ${p => p.theme.space[4]}px; | ||
margin-right: ${p => p.theme.space[1]}px; | ||
`; | ||
|
||
const AmountValue = styled(Text).attrs(() => ({ | ||
fontSize: 6, | ||
ff: "Inter|SemiBold", | ||
color: "palette.text.shade100", | ||
}))``; | ||
|
||
type Props = { | ||
account: IconAccount | SubAccount; | ||
}; | ||
|
||
const AccountBalanceSummaryFooter = ({ account }: Props) => { | ||
const discreet = useDiscreetMode(); | ||
const locale = useSelector(localeSelector); | ||
const unit = useAccountUnit(account); | ||
|
||
if (account.type !== "Account") return null; | ||
|
||
const formatConfig = { | ||
disableRounding: false, | ||
alwaysShowSign: false, | ||
showCode: true, | ||
discreet, | ||
locale, | ||
}; | ||
|
||
const spendableBalance = formatCurrencyUnit(unit, account.spendableBalance, formatConfig); | ||
|
||
return ( | ||
<Wrapper> | ||
<BalanceDetail> | ||
<ToolTip content={<Trans i18nKey="account.availableBalanceTooltip" />}> | ||
<TitleWrapper> | ||
<Title> | ||
<Trans i18nKey="account.availableBalance" /> | ||
</Title> | ||
<InfoCircle size={13} /> | ||
</TitleWrapper> | ||
</ToolTip> | ||
<AmountValue> | ||
<Discreet>{spendableBalance} </Discreet> | ||
</AmountValue> | ||
</BalanceDetail> | ||
</Wrapper> | ||
); | ||
}; | ||
|
||
export default AccountBalanceSummaryFooter; |
6 changes: 6 additions & 0 deletions
6
apps/ledger-live-desktop/src/renderer/families/icon/AccountSubHeader.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import React from "react"; | ||
import AccountSubHeader from "../../components/AccountSubHeader"; | ||
|
||
export default function IconAccountSubHeader() { | ||
return <AccountSubHeader family="Icon" team="Techiast" />; | ||
} |
64 changes: 64 additions & 0 deletions
64
apps/ledger-live-desktop/src/renderer/families/icon/StepSummaryNetworkFeesRow.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
import React from "react"; | ||
import { Trans } from "react-i18next"; | ||
import Box from "~/renderer/components/Box"; | ||
import CounterValue from "~/renderer/components/CounterValue"; | ||
import FormattedVal from "~/renderer/components/FormattedVal"; | ||
import Text from "~/renderer/components/Text"; | ||
import IconExclamationCircle from "~/renderer/icons/ExclamationCircle"; | ||
import TranslatedError from "~/renderer/components/TranslatedError"; | ||
import { SummaryNetworkFeesRowProps } from "../types"; | ||
|
||
const StepSummaryNetworkFeesRow = ({ | ||
feeTooHigh, | ||
feesUnit, | ||
estimatedFees, | ||
feesCurrency, | ||
}: SummaryNetworkFeesRowProps) => { | ||
return ( | ||
<> | ||
<Box horizontal justifyContent="space-between"> | ||
<Text ff="Inter|Medium" color="palette.text.shade40" fontSize={4}> | ||
<Trans i18nKey="send.steps.details.fees" />{" "} | ||
</Text> | ||
<Box> | ||
<FormattedVal | ||
color={feeTooHigh ? "warning" : "palette.text.shade80"} | ||
disableRounding | ||
unit={feesUnit} | ||
alwaysShowValue | ||
val={estimatedFees} | ||
fontSize={4} | ||
inline | ||
showCode | ||
/> | ||
<Box textAlign="right"> | ||
<CounterValue | ||
color={feeTooHigh ? "warning" : "palette.text.shade60"} | ||
fontSize={3} | ||
currency={feesCurrency} | ||
value={estimatedFees} | ||
alwaysShowSign={false} | ||
alwaysShowValue | ||
/> | ||
</Box> | ||
</Box> | ||
</Box> | ||
{feeTooHigh ? ( | ||
<Box horizontal justifyContent="flex-end" alignItems="center" color="warning"> | ||
<IconExclamationCircle size={10} /> | ||
<Text | ||
ff="Inter|Medium" | ||
fontSize={2} | ||
style={{ | ||
marginLeft: "5px", | ||
}} | ||
> | ||
<TranslatedError error={feeTooHigh} /> | ||
</Text> | ||
</Box> | ||
) : null} | ||
</> | ||
); | ||
}; | ||
|
||
export default StepSummaryNetworkFeesRow; |
101 changes: 101 additions & 0 deletions
101
apps/ledger-live-desktop/src/renderer/families/icon/TransactionConfirmFields.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
import invariant from "invariant"; | ||
import React from "react"; | ||
import styled from "styled-components"; | ||
import { Trans } from "react-i18next"; | ||
import TransactionConfirmField from "~/renderer/components/TransactionConfirm/TransactionConfirmField"; | ||
import WarnBox from "~/renderer/components/WarnBox"; | ||
import Box from "~/renderer/components/Box"; | ||
import FormattedVal from "~/renderer/components/FormattedVal"; | ||
import Alert from "~/renderer/components/Alert"; | ||
import { FieldComponentProps } from "../types"; | ||
import { getMainAccount } from "@ledgerhq/live-common/account/index"; | ||
import type { | ||
IconAccount, | ||
Transaction, | ||
TransactionStatus, | ||
} from "@ledgerhq/live-common/families/icon/types"; | ||
import { useAccountUnit } from "~/renderer/hooks/useAccountUnit"; | ||
|
||
const Info = styled(Box).attrs(() => ({ | ||
ff: "Inter|SemiBold", | ||
color: "palette.text.shade100", | ||
mt: 6, | ||
mb: 4, | ||
px: 5, | ||
}))` | ||
text-align: center; | ||
`; | ||
|
||
const IconFreesField = ({ | ||
account, | ||
parentAccount, | ||
transaction, | ||
field, | ||
}: FieldComponentProps<IconAccount, Transaction, TransactionStatus>) => { | ||
const mainAccount = getMainAccount(account, parentAccount); | ||
invariant(transaction.family === "icon", "icon transaction"); | ||
const unit = useAccountUnit(mainAccount); | ||
|
||
const { fees } = transaction; | ||
return ( | ||
<Box horizontal justifyContent="space-between" mb={2}> | ||
<TransactionConfirmField label={field.label} /> | ||
<FormattedVal | ||
color={"palette.text.shade80"} | ||
unit={unit} | ||
val={fees || 0} | ||
fontSize={3} | ||
inline | ||
showCode | ||
alwaysShowValue | ||
subMagnitude={5} | ||
/> | ||
</Box> | ||
); | ||
}; | ||
|
||
const Warning = ({ | ||
transaction, | ||
recipientWording, | ||
}: { | ||
transaction: Transaction; | ||
recipientWording: string; | ||
}) => { | ||
invariant(transaction.family === "icon", "icon transaction"); | ||
return ( | ||
<WarnBox> | ||
<Trans i18nKey="TransactionConfirm.warning" values={{ recipientWording }} /> | ||
</WarnBox> | ||
); | ||
}; | ||
|
||
const Title = ({ transaction }: { transaction: Transaction }) => { | ||
invariant(transaction.family === "icon", "icon transaction"); | ||
|
||
return ( | ||
<Info> | ||
<Trans i18nKey={`TransactionConfirm.titleWording.${transaction.mode}`} /> | ||
</Info> | ||
); | ||
}; | ||
|
||
const Footer = ({ transaction }: { transaction: Transaction }) => { | ||
invariant(transaction.family === "icon", "icon transaction"); | ||
return ( | ||
<Alert type="secondary"> | ||
<Trans i18nKey={`icon.networkFees`} /> | ||
</Alert> | ||
); | ||
}; | ||
|
||
const fieldComponents = { | ||
"icon.fees": IconFreesField, | ||
}; | ||
|
||
export default { | ||
fieldComponents, | ||
warning: Warning, | ||
title: Title, | ||
footer: Footer, | ||
disableFees: () => true, | ||
}; |
20 changes: 20 additions & 0 deletions
20
apps/ledger-live-desktop/src/renderer/families/icon/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import AccountSubHeader from "./AccountSubHeader"; | ||
import transactionConfirmFields from "./TransactionConfirmFields"; | ||
import AccountBalanceSummaryFooter from "./AccountBalanceSummaryFooter"; | ||
import StepSummaryNetworkFeesRow from "./StepSummaryNetworkFeesRow"; | ||
import { | ||
IconAccount, | ||
Transaction, | ||
TransactionStatus, | ||
IconOperation, | ||
} from "@ledgerhq/live-common/families/icon/types"; | ||
import { LLDCoinFamily } from "../types"; | ||
|
||
const family: LLDCoinFamily<IconAccount, Transaction, TransactionStatus, IconOperation> = { | ||
AccountSubHeader, | ||
transactionConfirmFields, | ||
StepSummaryNetworkFeesRow, | ||
AccountBalanceSummaryFooter, | ||
}; | ||
|
||
export default family; |
8 changes: 8 additions & 0 deletions
8
apps/ledger-live-mobile/src/families/icon/AccountSubHeader.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import React from "react"; | ||
import AccountSubHeader from "../../components/AccountSubHeader"; | ||
|
||
function IconAccountSubHeader() { | ||
return <AccountSubHeader family="ICON" team="Techiast" />; | ||
} | ||
|
||
export default IconAccountSubHeader; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
module.exports = { | ||
env: { | ||
browser: true, | ||
es6: true, | ||
}, | ||
overrides: [ | ||
{ | ||
files: ["src/**/*.test.{ts,tsx}"], | ||
env: { | ||
"jest/globals": true, | ||
}, | ||
plugins: ["jest"], | ||
}, | ||
], | ||
rules: { | ||
"no-console": ["error", { allow: ["warn", "error"] }], | ||
"@typescript-eslint/no-empty-function": "off", | ||
"@typescript-eslint/no-explicit-any": "warn", | ||
}, | ||
}; |
Oops, something went wrong.
a32c5a2
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[Bot] Testing with 'Nitrogen' ✅ 2 txs ($0.72) ⏲ 35.7s
Please increase the account target to at least 3 accounts
Details of the 2 mutations
Spec Icon (2)
Portfolio ($0.72) – Details of the 1 currencies
hxdd614da5f057ce32185619f98edd81445a946ea5
Performance ⏲ 35.7s
Time spent for each spec: (total across mutations)
a32c5a2
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[Bot] Testing with 'Nitrogen' ✅ 2 txs ($1.44) ⏲ 37.3s
Details of the 2 mutations
Spec Icon (3)
Portfolio ($1.44) – Details of the 1 currencies
hxdd614da5f057ce32185619f98edd81445a946ea5
Performance ⏲ 37.3s
Time spent for each spec: (total across mutations)
a32c5a2
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[Bot] Testing with 'Nitrogen' ✅ 2 txs ($0.72) ⏲ 35.9s
Details of the 2 mutations
Spec Icon (3)
Portfolio ($0.72) – Details of the 1 currencies
hxdd614da5f057ce32185619f98edd81445a946ea5
Performance ⏲ 35.9s
Time spent for each spec: (total across mutations)