-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: update dialogs to JSX and some minor improvements to the UI
- Loading branch information
1 parent
ca2bb6d
commit 18dd299
Showing
11 changed files
with
272 additions
and
201 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
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,50 @@ | ||
import { | ||
Bold, | ||
Box, | ||
Copyable, | ||
Heading, | ||
Row, | ||
type SnapComponent, | ||
Text, | ||
} from '@metamask/snaps-sdk/jsx' | ||
import type { SnapConfig } from '../types' | ||
|
||
type ConfigureProps = { | ||
origin: string | ||
address: string | ||
accountNumber: number | ||
config: SnapConfig | ||
} | ||
|
||
export const Configure: SnapComponent<ConfigureProps> = ({ | ||
address, | ||
origin, | ||
accountNumber, | ||
config, | ||
}) => { | ||
return ( | ||
<Box> | ||
<Heading>Connection request</Heading> | ||
<Text> | ||
<Bold>{origin}</Bold> wants to connect with your Filecoin account. | ||
</Text> | ||
<Text>Account {accountNumber.toString()}</Text> | ||
<Copyable value={address} /> | ||
<Row label="Derivation Path:"> | ||
<Text>{config.derivationPath}</Text> | ||
</Row> | ||
<Row label="API:"> | ||
<Text>{config.rpc.url}</Text> | ||
</Row> | ||
<Row label="Network:"> | ||
<Text>{config.network}</Text> | ||
</Row> | ||
<Row label="Unit Decimals:"> | ||
<Text>{config.unit?.decimals.toString() ?? 'N/A'}</Text> | ||
</Row> | ||
<Row label="Unit Symbol:"> | ||
<Text>{config.unit?.symbol ?? 'N/A'}</Text> | ||
</Row> | ||
</Box> | ||
) | ||
} |
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,45 @@ | ||
import { | ||
Bold, | ||
Box, | ||
Copyable, | ||
Heading, | ||
type SnapComponent, | ||
Text, | ||
} from '@metamask/snaps-sdk/jsx' | ||
|
||
type ExportConfirmProps = { | ||
address: string | ||
accountNumber: number | ||
} | ||
|
||
export const ExportConfirm: SnapComponent<ExportConfirmProps> = ({ | ||
address, | ||
accountNumber, | ||
}) => { | ||
return ( | ||
<Box> | ||
<Heading>Private Key Export Request</Heading> | ||
<Text> | ||
Do you want to export <Bold>Account {accountNumber.toString()}</Bold>{' '} | ||
private key ? | ||
</Text> | ||
<Text>Address:</Text> | ||
<Copyable value={address} /> | ||
</Box> | ||
) | ||
} | ||
|
||
type PrivateKeyExportProps = { | ||
privateKey: string | ||
} | ||
|
||
export const PrivateKeyExport: SnapComponent<PrivateKeyExportProps> = ({ | ||
privateKey, | ||
}) => { | ||
return ( | ||
<Box> | ||
<Heading>Private Key</Heading> | ||
<Copyable value={privateKey} /> | ||
</Box> | ||
) | ||
} |
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,89 @@ | ||
import { | ||
Bold, | ||
Box, | ||
Copyable, | ||
Heading, | ||
Row, | ||
type SnapComponent, | ||
Text, | ||
} from '@metamask/snaps-sdk/jsx' | ||
import type { Message } from 'iso-filecoin/message' | ||
import { Token } from 'iso-filecoin/token' | ||
import type { Jsonify } from 'type-fest' | ||
import type { SnapConfig } from '../types' | ||
import { formatFIL } from '../utils' | ||
|
||
type SignMessageDialogProps = { | ||
origin: string | ||
accountNumber: number | ||
message: Jsonify<Message> | ||
config: SnapConfig | ||
} | ||
|
||
export const SignMessageDialog: SnapComponent<SignMessageDialogProps> = ({ | ||
accountNumber, | ||
message, | ||
config, | ||
origin, | ||
}) => { | ||
const gas = Token.fromAttoFIL(message.gasPremium).mul(message.gasLimit) | ||
const total = Token.fromAttoFIL(message.value).add(gas) | ||
|
||
return ( | ||
<Box> | ||
<Heading>Signature Request from {origin}</Heading> | ||
<Row label="Send"> | ||
<Text> | ||
<Bold>{formatFIL(message.value, config)}</Bold> | ||
</Text> | ||
</Row> | ||
<Row | ||
label="From" | ||
tooltip={`Account | ||
${accountNumber.toString()}`} | ||
> | ||
<Text>{message.from}</Text> | ||
</Row> | ||
<Row label="To"> | ||
<Text>{message.to}</Text> | ||
</Row> | ||
<Heading>Details</Heading> | ||
<Row label="Gas" tooltip="Estimated gas"> | ||
<Text>{formatFIL(gas, config)}</Text> | ||
</Row> | ||
|
||
<Row label="Total" tooltip="Estimated total (amount + gas)"> | ||
<Text>{formatFIL(total, config)}</Text> | ||
</Row> | ||
<Row label="API"> | ||
<Text> {config.rpc.url}</Text> | ||
</Row> | ||
<Row label="Network"> | ||
<Text> {config.network}</Text> | ||
</Row> | ||
</Box> | ||
) | ||
} | ||
|
||
type SignRawDialogProps = { | ||
origin: string | ||
accountNumber: number | ||
message: string | ||
} | ||
|
||
export const SignRawDialog: SnapComponent<SignRawDialogProps> = ({ | ||
accountNumber, | ||
origin, | ||
message, | ||
}) => { | ||
return ( | ||
<Box> | ||
<Heading>Signature Request from {origin}</Heading> | ||
<Text> | ||
Do you want to sign the message below with{' '} | ||
<Bold>Account {accountNumber.toString()}</Bold>? | ||
</Text> | ||
<Copyable value={message} /> | ||
</Box> | ||
) | ||
} |
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
Oops, something went wrong.