Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix proposal review #24

Merged
merged 3 commits into from
Mar 6, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion components/currency.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ type AssetAmountProps = {
className?: string
}

const AssetAmount = ({quantity, decimals, symbol, className}: AssetAmountProps) => (
const AssetAmount = ({ quantity, decimals, symbol, className }: AssetAmountProps) => (
<NumberFormat
className={className}
value={toDecimal(quantity, decimals)}
Expand Down
12 changes: 5 additions & 7 deletions components/transaction.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,8 @@ const newRecipient = (): Recipient => {

const getPolicyId = (assetId: string) => assetId.slice(0, 56)
const getAssetName = (assetId: string) => assetId.slice(56)

const decodeASCII = (assetName: string): string => {
const buffer = Buffer.from(assetName, 'hex')
const decoder = new TextDecoder('ascii')
return decoder.decode(buffer)
return Buffer.from(assetName, 'hex').toString('ascii')
}

type LabeledCurrencyInputProps = {
Expand Down Expand Up @@ -75,7 +72,7 @@ type RecipientProps = {
}

const Recipient = ({ recipient, budget, onChange }: RecipientProps) => {
const [ config, _ ] = useContext(ConfigContext)
const [config, _] = useContext(ConfigContext)
const { address, value } = recipient
const setRecipient = (recipient: Recipient) => {
onChange(recipient)
Expand Down Expand Up @@ -387,12 +384,13 @@ const TransactionViewer = ({ txBody }: TransactionViewerProps) => {
const keys = multiAsset.keys()
Array.from({ length: keys.len() }, (_, i) => {
const policyId = keys.get(i)
const policyIdHex = Buffer.from(policyId.to_bytes()).toString('hex')
const _asset = multiAsset.get(policyId)
_asset && Array.from({ length: _asset.keys().len() }, (_, i) => {
const assetName = _asset.keys().get(i)
const assetNameHex = Buffer.from(assetName.name()).toString('hex')
const quantity = BigInt(multiAsset.get_asset(policyId, assetName).to_str())
const id = Buffer.from(policyId.to_bytes()).toString('hex') +
Buffer.from(assetName.to_bytes()).toString('hex')
const id = policyIdHex + assetNameHex
assets.set(id, (assets.get(id) || BigInt(0)) + quantity)
})
})
Expand Down