-
Notifications
You must be signed in to change notification settings - Fork 19
Feat/optional sender #491
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
base: main
Are you sure you want to change the base?
Feat/optional sender #491
Changes from 19 commits
c92354e
80ec848
2c8d8fb
9130179
5b5ad14
13011ab
d4c3f71
681f3bd
2eb565d
35f8ec5
78fb4a5
6f0be92
7a29bab
60930a8
39ed51a
6b170e0
3a0c3b7
09acee5
c715c55
829589b
1c9d7e5
0c29eaf
bbee3ec
920f098
80de8e7
0d069a1
1d255a3
d69ea30
877dcd3
f8f5b31
206971b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
@@ -0,0 +1,46 @@ | ||||||
import { Nfd } from '@/features/nfd/data/types' | ||||||
|
||||||
import { PropsWithChildren } from 'react' | ||||||
import { AddressOrNfdLink } from './address-or-nfd-link' | ||||||
import { Address } from '../data/types' | ||||||
import { cn } from '@/features/common/utils' | ||||||
|
||||||
export type AddressOrNfdLinkProps = PropsWithChildren<{ | ||||||
|
export type AddressOrNfdLinkProps = PropsWithChildren<{ | |
type Props = PropsWithChildren<{ |
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove this empty line
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the className
prop needs to be passed in here too, I think this would become something like
className={cn(className, autoPopulated && 'text-yellow-500')}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you can rewrite this bit to
export default function TransactionSenderLink(props: Props) {
const { autoPopulated, className, ...rest } = props
return (
<div className="flex items-center">
<AddressOrNfdLink className={cn(className, autoPopulated && 'text-yellow-500')} {...rest} />
...
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -30,14 +30,16 @@ export const allWalletProviderNames: Record<WalletId, string> = { | |
pera: 'Pera', | ||
exodus: 'Exodus', | ||
lute: 'Lute', | ||
// The below providers aren't used | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think we should still keep this comment |
||
custom: 'Custom', | ||
kibisis: 'Kibisis', | ||
walletconnect: 'Wallet Connect', | ||
magic: 'Magic', | ||
biatec: 'Biatec', | ||
} | ||
|
||
export const MAINNET_FEE_SINK_ADDRESS = 'Y76M3MSY6DKBRHBL7C3NNDXGS5IIMQVQVUAB6MP4XEMMGVF2QWNPL226CA' | ||
export const TESTNET_FEE_SINK_ADDRESS = 'A7NMWS3NT3IUDMLVO26ULGXGIIOUQ3ND2TXSER6EBGRZNOBOUIQXHIBGDE' | ||
|
||
export const defaultNetworkConfigs: Record<NetworkId, NetworkConfig> = { | ||
[localnetId]: { | ||
name: 'LocalNet', | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,10 @@ | ||
import { numberSchema } from '@/features/forms/data/common' | ||
import { addressFieldSchema, commonSchema, optionalAddressFieldSchema, senderFieldSchema } from '../data/common' | ||
import { | ||
addressFieldSchema, | ||
commonSchema, | ||
optionalAddressFieldSchema, | ||
optionalSenderFieldShape, | ||
} from '@/features/transaction-wizard/data/common' | ||
import { z } from 'zod' | ||
import { useCallback, useMemo } from 'react' | ||
import { zfd } from 'zod-form-data' | ||
|
@@ -18,14 +23,16 @@ import { TransactionBuilderNoteField } from './transaction-builder-note-field' | |
import { asAddressOrNfd, asOptionalAddressOrNfd } from '../mappers/as-address-or-nfd' | ||
import { ActiveWalletAccount } from '@/features/wallet/types/active-wallet' | ||
|
||
import defineSenderAddress from '../utils/define-sender-address' | ||
|
||
|
||
const senderLabel = 'Sender' | ||
const receiverLabel = 'Receiver' | ||
const closeRemainderToLabel = 'Close remainder to' | ||
|
||
const formSchema = z | ||
.object({ | ||
...commonSchema, | ||
...senderFieldSchema, | ||
...optionalSenderFieldShape, | ||
closeRemainderTo: addressFieldSchema, | ||
receiver: optionalAddressFieldSchema, | ||
amount: numberSchema(z.number({ required_error: 'Required', invalid_type_error: 'Required' }).min(0).optional()), | ||
|
@@ -63,7 +70,7 @@ export function AccountCloseTransactionBuilder({ mode, transaction, activeAccoun | |
onSubmit({ | ||
id: transaction?.id ?? randomGuid(), | ||
type: BuildableTransactionType.AccountClose, | ||
sender: data.sender, | ||
sender: await defineSenderAddress(data.sender), | ||
closeRemainderTo: data.closeRemainderTo, | ||
receiver: asOptionalAddressOrNfd(data.receiver), | ||
amount: data.amount, | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,10 @@ | ||
import algosdk from 'algosdk' | ||
import { numberSchema } from '@/features/forms/data/common' | ||
import { | ||
senderFieldSchema, | ||
commonSchema, | ||
onCompleteOptionsForAppCreate, | ||
onCompleteForAppCreateFieldSchema, | ||
optionalSenderFieldShape, | ||
} from '@/features/transaction-wizard/data/common' | ||
import { z } from 'zod' | ||
import { zfd } from 'zod-form-data' | ||
|
@@ -22,9 +22,11 @@ import { TransactionBuilderNoteField } from './transaction-builder-note-field' | |
import { asAddressOrNfd } from '../mappers/as-address-or-nfd' | ||
import { ActiveWalletAccount } from '@/features/wallet/types/active-wallet' | ||
|
||
|
||
import defineSenderAddress from '../utils/define-sender-address' | ||
|
||
const formData = zfd.formData({ | ||
...commonSchema, | ||
...senderFieldSchema, | ||
...optionalSenderFieldShape, | ||
...onCompleteForAppCreateFieldSchema, | ||
approvalProgram: zfd.text(z.string({ required_error: 'Required', invalid_type_error: 'Required' })), | ||
clearStateProgram: zfd.text(z.string({ required_error: 'Required', invalid_type_error: 'Required' })), | ||
|
@@ -57,7 +59,7 @@ export function ApplicationCreateTransactionBuilder({ mode, transaction, activeA | |
type: BuildableTransactionType.ApplicationCreate, | ||
approvalProgram: values.approvalProgram, | ||
clearStateProgram: values.clearStateProgram, | ||
sender: values.sender, | ||
sender: await defineSenderAddress(values.sender!), | ||
onComplete: Number(values.onComplete), | ||
extraProgramPages: values.extraProgramPages, | ||
globalInts: values.globalInts, | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
import { bigIntSchema } from '@/features/forms/data/common' | ||
import { addressFieldSchema, commonSchema, senderFieldSchema } from '../data/common' | ||
import { addressFieldSchema, commonSchema, optionalSenderFieldShape } from '../data/common' | ||
import { z } from 'zod' | ||
import { useCallback, useEffect, useMemo, useState } from 'react' | ||
import { zfd } from 'zod-form-data' | ||
|
@@ -23,10 +23,11 @@ import { TransactionBuilderMode } from '../data' | |
import { TransactionBuilderNoteField } from './transaction-builder-note-field' | ||
import { asAddressOrNfd } from '../mappers/as-address-or-nfd' | ||
import { ActiveWalletAccount } from '@/features/wallet/types/active-wallet' | ||
import defineSenderAddress from '../utils/define-sender-address' | ||
|
||
export const assetOptOutFormSchema = z.object({ | ||
...commonSchema, | ||
...senderFieldSchema, | ||
...optionalSenderFieldShape, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think you can skip the
directly. It's just 1 line of code and it will make reading a lot easier |
||
closeRemainderTo: addressFieldSchema, | ||
asset: z | ||
.object({ | ||
|
@@ -150,7 +151,7 @@ export function AssetOptOutTransactionBuilder({ mode, transaction, activeAccount | |
id: transaction?.id ?? randomGuid(), | ||
type: BuildableTransactionType.AssetOptOut, | ||
asset: data.asset, | ||
sender: data.sender, | ||
sender: await defineSenderAddress(data.sender), | ||
closeRemainderTo: data.closeRemainderTo, | ||
fee: data.fee, | ||
validRounds: data.validRounds, | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nitpick: no need this newline