Skip to content

Commit

Permalink
Merge pull request #123 from Concordium/reading-writing-features
Browse files Browse the repository at this point in the history
Reading/Writing Features
  • Loading branch information
DOBEN authored Nov 10, 2023
2 parents 26b3ed0 + 4ef17b4 commit 0d601b2
Show file tree
Hide file tree
Showing 17 changed files with 3,020 additions and 1,153 deletions.
4 changes: 4 additions & 0 deletions front-end-tools/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
## Unreleased changes

## 3.0.0

- Add reading from smart contract and writing to smart contract feature

## 2.2.0

- Add warning box if module references in step 1 and step 2 are not the same. Add warning box if embedded schema indicates an input parameter but no input parameter is provided.
Expand Down
4 changes: 3 additions & 1 deletion front-end-tools/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "front-end-tools",
"packageManager": "yarn@3.2.0",
"version": "2.2.0",
"version": "3.0.0",
"license": "Apache-2.0",
"engines": {
"node": ">=16.x"
Expand All @@ -15,6 +15,8 @@
"react": "^18.1.0",
"react-bootstrap": "^2.7.4",
"react-dom": "^18.1.0",
"react-hook-form": "^7.47.0",
"react-select": "^5.7.7",
"react-switch": "^7.0.0"
},
"devDependencies": {
Expand Down
1,104 changes: 86 additions & 1,018 deletions front-end-tools/src/Main.tsx

Large diffs are not rendered by default.

16 changes: 12 additions & 4 deletions front-end-tools/src/Root.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import Main from './Main';
import { version } from '../package.json';

/**
* Connect to wallet, setup application state context, and render children when the wallet API is ready for use.
* Select mainnet/testnet and display WithWalletConnector component for respective network.
*/
export default function Root() {
const [isTestnet, setIsTestnet] = useState(true);
Expand Down Expand Up @@ -34,9 +34,17 @@ export default function Root() {
<div>Mainnet</div>
</div>
<br />
<WithWalletConnector network={isTestnet ? TESTNET : MAINNET}>
{(props) => <Main walletConnectionProps={props} isTestnet={isTestnet} />}
</WithWalletConnector>
{/* Changes to the network value will remove the activeConnector. We switch between components here without changing the network value. */}
{isTestnet && (
<WithWalletConnector network={TESTNET}>
{(props) => <Main walletConnectionProps={props} isTestnet={isTestnet} />}
</WithWalletConnector>
)}
{!isTestnet && (
<WithWalletConnector network={MAINNET}>
{(props) => <Main walletConnectionProps={props} isTestnet={isTestnet} />}
</WithWalletConnector>
)}
</main>
</div>
);
Expand Down
48 changes: 0 additions & 48 deletions front-end-tools/src/WalletConnectorTypeButton.tsx

This file was deleted.

20 changes: 20 additions & 0 deletions front-end-tools/src/components/Box.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import React, { PropsWithChildren } from 'react';

type BoxProps = PropsWithChildren<{
header: string;
}>;

/**
* A component that creates a box with a header and background/borderLine styling.
*/
export default function Box(props: BoxProps) {
const { children, header } = props;

return (
<fieldset className="box">
<legend>{header}</legend>
<div className="boxFields">{children}</div>
<br />
</fieldset>
);
}
69 changes: 69 additions & 0 deletions front-end-tools/src/components/CCDScanLinks.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
import React from 'react';

function ccdScanUrl(isTestnet: boolean): string {
return `https://${isTestnet ? `testnet.` : ``}ccdscan.io`;
}

interface TxHashLinkProps {
isTestnet: boolean;
txHash: string;
message: string;
}

/**
* A component that displays the CCDScan link of a transaction hash.
* A message at the bottom can be used to add some custom description to the link.
* If `isTestnet` is true, the testnet CCDScan link is displayed.
* If `isTestnet` is false, the mainnet CCDScan link is displayed.
*/
export const TxHashLink = function TxHashLink(props: TxHashLinkProps) {
const { isTestnet, txHash, message } = props;

return (
<>
<div>
Transaction hash:{' '}
<a
className="link"
target="_blank"
rel="noreferrer"
href={`${ccdScanUrl(isTestnet)}/?dcount=1&dentity=transaction&dhash=${txHash}`}
>
{txHash}
</a>
</div>
<br />
<div>
CCDScan will take a moment to pick up the above transaction, hence the above link will work in a bit.
</div>
<div>{message}</div>
</>
);
};

interface AccountLinkProps {
isTestnet: boolean;
account: string;
}

/**
* A component that displays the CCDScan link to an account address.
* If `isTestnet` is true, the testnet CCDScan link is displayed.
* If `isTestnet` is false, the mainnet CCDScan link is displayed.
*/
export const AccountLink = function AccountLink(props: AccountLinkProps) {
const { isTestnet, account } = props;

return (
<div>
<a
className="link"
href={`${ccdScanUrl(isTestnet)}/?dcount=1&dentity=account&daddress=${account}`}
target="_blank"
rel="noreferrer"
>
{account}
</a>
</div>
);
};
Loading

0 comments on commit 0d601b2

Please sign in to comment.