Add Select UI for account.

This commit is contained in:
muzam1l
2023-03-23 16:12:35 +05:30
parent 62d521b2cc
commit 025eff6cf2
3 changed files with 35 additions and 24 deletions

View File

@@ -10,7 +10,6 @@ interface TransactionOptions {
TransactionType: string
Account?: string
Fee?: string
Destination?: string
[index: string]: any
}
interface OtherOptions {

View File

@@ -130,7 +130,6 @@ export const modifyTxState = (
return tx.state
}
// state to tx options
export const prepareTransaction = (data: any) => {
let options = { ...data }
@@ -145,7 +144,6 @@ export const prepareTransaction = (data: any) => {
options[field] = undefined
}
}
// amount.token
if (_value.$type === 'amount.token') {
if (typeIs(_value.$value, 'string')) {
@@ -156,7 +154,10 @@ export const prepareTransaction = (data: any) => {
options[field] = undefined
}
}
// account
if (_value.$type === 'account') {
options[field] = _value.$value?.toString();
}
// json
if (_value.$type === 'json') {
const val = _value.$value;
@@ -181,7 +182,6 @@ export const prepareTransaction = (data: any) => {
return options
}
// editor value to state
export const prepareState = (value: string, transactionType?: string) => {
const options = parseJSON(value)
if (!options) {
@@ -252,19 +252,27 @@ export const prepareState = (value: string, transactionType?: string) => {
const isAmount = schemaVal &&
typeIs(schemaVal, "object") &&
schemaVal.$type.startsWith('amount.');
const isAccount = schemaVal &&
typeIs(schemaVal, "object") &&
schemaVal.$type.startsWith("account");
if (isAmount && ["number", "string"].includes(typeof value)) {
rest[field] = {
$type: 'amount.xrp', // TODO narrow typed $type.
$value: +value / 1000000 // ! maybe use bigint?
}
}
else if (isAmount && typeof value === 'object') {
} else if (isAmount && typeof value === 'object') {
rest[field] = {
$type: 'amount.token',
$value: value
}
} else if (typeof value === 'object') {
} else if (isAccount) {
rest[field] = {
$type: "account",
$value: value?.toString()
}
}
else if (typeof value === 'object') {
rest[field] = {
$type: 'json',
$value: value