Skip to content

Commit

Permalink
fix: fixed #42
Browse files Browse the repository at this point in the history
  • Loading branch information
ohager committed Oct 6, 2022
1 parent 1ee3bc8 commit 8c9886e
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 6 deletions.
6 changes: 6 additions & 0 deletions public/_locales/en/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -1454,6 +1454,12 @@
"buyOrder": {
"message": "Buy"
},
"burn": {
"message": "Burn!"
},
"burnAddress": {
"message": "Burn Address"
},
"saleOrder": {
"message": "Sale"
},
Expand Down
5 changes: 4 additions & 1 deletion src/app/atoms/FormSubmitButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ type FormSubmitButtonProps = ButtonHTMLAttributes<HTMLButtonElement> &
TestIDProps & {
loading?: boolean;
small?: boolean;
danger?: boolean;
};

const FormSubmitButton: FC<FormSubmitButtonProps> = ({
Expand All @@ -19,6 +20,7 @@ const FormSubmitButton: FC<FormSubmitButtonProps> = ({
disabled,
className,
style,
danger = false,
children,
...rest
}) => (
Expand All @@ -27,7 +29,8 @@ const FormSubmitButton: FC<FormSubmitButtonProps> = ({
'relative',
small ? 'px-6' : 'px-8',
'rounded border-2',
disabled ? 'bg-gray-400 border-gray-400' : 'bg-primary-orange border-primary-orange',
danger ? 'bg-orange-600 border-orange-600' : 'bg-primary-orange border-primary-orange',
disabled ? 'bg-gray-400 border-gray-400' : '',
'flex items-center',
loading ? 'text-transparent' : 'text-primary-orange-lighter',
small ? 'text-sm' : 'text-base',
Expand Down
29 changes: 24 additions & 5 deletions src/app/templates/SignumSendForm/SendForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import { useFormAnalytics } from 'lib/analytics';
import { toLocalFixed } from 'lib/i18n/numbers';
import { T, t } from 'lib/i18n/react';
import {
BURN_ADDRESS,
isSignumAddress,
SIGNA_TOKEN_ID,
SMART_CONTRACT_PUBLIC_KEY,
Expand Down Expand Up @@ -98,6 +99,9 @@ export const SendForm: FC<FormProps> = ({ setOperation, onAddContactRequested, t
async (_k: string, address: string) => {
try {
const id = Address.create(address).getNumericId();
if (id === BURN_ADDRESS) {
return null;
}
const { publicKey } = await signum.account.getAccount({
accountId: id,
includeEstimatedCommitment: false,
Expand Down Expand Up @@ -390,9 +394,14 @@ export const SendForm: FC<FormProps> = ({ setOperation, onAddContactRequested, t
{toResolved && (
<div className={classNames('mb-4 -mt-3', 'text-xs font-light text-gray-600', 'flex flex-wrap items-center')}>
<span className="mr-1 whitespace-no-wrap">{t('resolvedAddress')}:</span>
{resolvedPublicKey === SMART_CONTRACT_PUBLIC_KEY ? (

{resolvedPublicKey === SMART_CONTRACT_PUBLIC_KEY && (
<span className="font-normal">🤖 {Address.create(toResolved, prefix).getReedSolomonAddress()}</span>
) : (
)}

{toResolved === BURN_ADDRESS && <span className="font-normal">🔥 {t('burnAddress')}</span>}

{resolvedPublicKey !== SMART_CONTRACT_PUBLIC_KEY && toResolved !== BURN_ADDRESS && (
<span className="font-normal">{Address.create(toResolved, prefix).getReedSolomonAddress()}</span>
)}
</div>
Expand Down Expand Up @@ -489,9 +498,19 @@ export const SendForm: FC<FormProps> = ({ setOperation, onAddContactRequested, t

{totalAmount && errors.amount === undefined && messageFormData.isValid && (
<div className={'flex flex-row items-center justify-center'}>
<T id="send">
{message => <FormSubmitButton loading={formState.isSubmitting}>{message}</FormSubmitButton>}
</T>
{toResolved === BURN_ADDRESS ? (
<T id="burn">
{message => (
<FormSubmitButton loading={formState.isSubmitting} danger>
{message}
</FormSubmitButton>
)}
</T>
) : (
<T id="send">
{message => <FormSubmitButton loading={formState.isSubmitting}>{message}</FormSubmitButton>}
</T>
)}
</div>
)}
</>
Expand Down
3 changes: 3 additions & 0 deletions src/lib/temple/front/aliases.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ export function useSignumAliasResolver() {
const resolveAliasToAccountPk = useCallback(
async aliasName => {
try {
if (aliasName.length < 2) {
return null;
}
const { account } = await signum.alias.getAliasByName(aliasName);
const acc = await signum.account.getAccount({
accountId: account,
Expand Down
1 change: 1 addition & 0 deletions src/lib/temple/metadata/defaults.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { browserInfo } from 'lib/browser-info';
import { AssetMetadata } from './types';

export const SMART_CONTRACT_PUBLIC_KEY = '0000000000000000000000000000000000000000000000000000000000000000';
export const BURN_ADDRESS = '0';
export const SIGNA_TOKEN_ID = '0';
export const TRT_TOKEN_ID = '12402415494995249540';
export const FEATURED_TOKEN_IDS: string[] = [];
Expand Down

0 comments on commit 8c9886e

Please sign in to comment.