Skip to content
This repository has been archived by the owner on Jun 16, 2022. It is now read-only.

Commit

Permalink
Support filecoin (#4589)
Browse files Browse the repository at this point in the history
* add jetbrains folder

* add jetbrains to gitignore file

* add check to avoid exception on objects inside extra field

* add transaction confirm fields for filecoin

* remove duplicated line

* fix error on line
  • Loading branch information
emmanuelm41 authored May 10, 2022
1 parent b7373e8 commit 22a5616
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 11 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -128,4 +128,5 @@ ui-lib/lib
ui-lib/storybook-static/*

# IDE
.vscode/*
.vscode/*
.idea
1 change: 1 addition & 0 deletions src/live-common-set-supported-currencies.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,5 @@ setSupportedCurrencies([
"ethereum_ropsten",
"ethereum_goerli",
"cosmos_testnet",
"filecoin",
]);
23 changes: 13 additions & 10 deletions src/renderer/drawers/OperationDetails/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -641,16 +641,19 @@ type OperationDetailsExtraProps = {
};

const OperationDetailsExtra = ({ extra }: OperationDetailsExtraProps) => {
return Object.entries(extra).map(([key, value]) => (
<OpDetailsSection key={key}>
<OpDetailsTitle>
<Trans i18nKey={`operationDetails.extra.${key}`} defaults={key} />
</OpDetailsTitle>
<OpDetailsData>
<Ellipsis>{value}</Ellipsis>
</OpDetailsData>
</OpDetailsSection>
));
return Object.entries(extra).map(([key, value]) => {
if( typeof value == "object" || typeof value == "function") return null;
return (
<OpDetailsSection key={key}>
<OpDetailsTitle>
<Trans i18nKey={`operationDetails.extra.${key}`} defaults={key} />
</OpDetailsTitle>
<OpDetailsData>
<Ellipsis>{value}</Ellipsis>
</OpDetailsData>
</OpDetailsSection>
);
});
};

const More = styled(Text).attrs(p => ({
Expand Down
37 changes: 37 additions & 0 deletions src/renderer/families/filecoin/TransactionConfirmFields.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
// @flow

import invariant from "invariant";
import React from "react";
import TransactionConfirmField from "~/renderer/components/TransactionConfirm/TransactionConfirmField";
import Text from "~/renderer/components/Text";
import { DeviceTransactionField } from "@ledgerhq/live-common/lib/transaction";


const addressStyle = {
wordBreak: "break-all",
textAlign: "right",
maxWidth: "70%",
};

const FilecoinField = ({ transaction, field }: { transaction: Transaction, field: DeviceTransactionField }) => {
invariant(transaction.family === "filecoin", "filecoin transaction");

return (
<TransactionConfirmField label={field.label}>
<Text style={addressStyle} ml={1} ff="Inter|Medium" color="palette.text.shade80" fontSize={3}>
{field.value}
</Text>
</TransactionConfirmField>
);
};

const fieldComponents = {
"filecoin.gasFeeCap": FilecoinField,
"filecoin.gasPremium": FilecoinField,
"filecoin.gasLimit": FilecoinField,
"filecoin.method": FilecoinField,
};

export default {
fieldComponents,
};

0 comments on commit 22a5616

Please sign in to comment.