Skip to content

Commit

Permalink
Merge pull request #601 from z3us-dapps/develop
Browse files Browse the repository at this point in the history
v2.0.44+ext
  • Loading branch information
heathsnee authored Jun 13, 2024
2 parents 75bf7a5 + c1a5c7c commit e9262d7
Show file tree
Hide file tree
Showing 39 changed files with 200 additions and 111 deletions.
2 changes: 1 addition & 1 deletion .node-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v20.3.0
v20.5.0
4 changes: 2 additions & 2 deletions apps/extension/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "z3us-extension",
"version": "2.0.43",
"version": "2.0.44",
"type": "module",
"scripts": {
"clean": "rm -rf .turbo && rm -rf node_modules && rm -rf dist",
Expand Down Expand Up @@ -48,7 +48,7 @@
"react-intl": "^6.4.7",
"react-router-dom": "^6.14.2",
"react-test-renderer": "^18.2.0",
"react-virtuoso": "^4.3.11",
"react-virtuoso": "^4.7.11",
"readable-stream": "^4.3.0",
"recharts": "^2.8.0",
"simple-zustand-devtools": "^1.1.0",
Expand Down
3 changes: 2 additions & 1 deletion apps/extension/src/locales/ar.json
Original file line number Diff line number Diff line change
Expand Up @@ -433,5 +433,6 @@
"pOyrg7": "فتح في اللوحة الجانبية",
"tLyIg5": "قم بتسجيل الدخول باستخدام المصادقة بدون كلمة مرور",
"Ft5lhW": "فشل تمكين المصادقة بدون كلمة مرور",
"5q3qC0": "تحميل"
"5q3qC0": "تحميل",
"Gzq2CU": "حاول {button} الرسوم عن طريق زيادة قيمة الحشو"
}
3 changes: 2 additions & 1 deletion apps/extension/src/locales/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -434,5 +434,6 @@
"pOyrg7": "Im Seitenbereich öffnen",
"tLyIg5": "Anmeldung mit passwortloser Authentifizierung",
"Ft5lhW": "Passwortlose Authentifizierung konnte nicht aktiviert werden",
"5q3qC0": "Herunterladen"
"5q3qC0": "Herunterladen",
"Gzq2CU": "Versuchen Sie, die Gebühren durch Erhöhung des Füllwerts zu {button}"
}
1 change: 1 addition & 0 deletions apps/extension/src/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@
"GtxE3T": "Internal error{hasMessage, select, true {: {message}} other {, please try again} }",
"GufXy5": "Value",
"Gvxoji": "Name is required",
"Gzq2CU": "Try to {button} fees by increasing padding value",
"H5+NAX": "Balance",
"HAlOn1": "Name",
"HMBkUU": "To confirm ownership, sign challenge with persona {label}",
Expand Down
3 changes: 2 additions & 1 deletion apps/extension/src/locales/es.json
Original file line number Diff line number Diff line change
Expand Up @@ -434,5 +434,6 @@
"pOyrg7": "Abrir en el panel lateral",
"tLyIg5": "Iniciar sesión usando autenticación sin contraseña",
"Ft5lhW": "Error al habilitar la autenticación sin contraseña",
"5q3qC0": "Descargar"
"5q3qC0": "Descargar",
"Gzq2CU": "Intente {button} las tarifas aumentando el valor del relleno"
}
3 changes: 2 additions & 1 deletion apps/extension/src/locales/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -434,5 +434,6 @@
"pOyrg7": "Ouvrir dans le panneau latéral",
"tLyIg5": "Connexion avec authentification sans mot de passe",
"Ft5lhW": "Échec de l'activation de l'authentification sans mot de passe",
"5q3qC0": "Télécharger"
"5q3qC0": "Télécharger",
"Gzq2CU": "Essayez de {button} les frais en augmentant la valeur de remplissage"
}
3 changes: 2 additions & 1 deletion apps/extension/src/locales/it.json
Original file line number Diff line number Diff line change
Expand Up @@ -434,5 +434,6 @@
"pOyrg7": "Apri nel pannello laterale",
"tLyIg5": "Accedi utilizzando l'autenticazione senza password",
"Ft5lhW": "Impossibile abilitare l'autenticazione senza password",
"5q3qC0": "Scaricamento"
"5q3qC0": "Scaricamento",
"Gzq2CU": "Prova a {button} commissioni aumentando il valore di riempimento"
}
3 changes: 2 additions & 1 deletion apps/extension/src/locales/jp.json
Original file line number Diff line number Diff line change
Expand Up @@ -434,5 +434,6 @@
"pOyrg7": "サイドパネルで開く",
"tLyIg5": "パスワードなしの認証を使用してログイン",
"Ft5lhW": "パスワードなしの認証を有効にできませんでした",
"5q3qC0": "ダウンロード"
"5q3qC0": "ダウンロード",
"Gzq2CU": "パディング値を増やして手数料を{button}してみてください"
}
3 changes: 2 additions & 1 deletion apps/extension/src/locales/pl.json
Original file line number Diff line number Diff line change
Expand Up @@ -434,5 +434,6 @@
"pOyrg7": "Otwórz w panelu bocznym",
"tLyIg5": "Zaloguj się przy użyciu uwierzytelniania bez hasła",
"Ft5lhW": "Nie udało się włączyć uwierzytelniania bez hasła",
"5q3qC0": "Ściągnij"
"5q3qC0": "Ściągnij",
"Gzq2CU": "Spróbuj {button} opłat, zwiększając wartość dopełnienia"
}
3 changes: 2 additions & 1 deletion apps/extension/src/locales/pt.json
Original file line number Diff line number Diff line change
Expand Up @@ -433,5 +433,6 @@
"pOyrg7": "Abrir no painel lateral",
"tLyIg5": "Login usando autenticação sem senha",
"Ft5lhW": "Falha ao ativar a autenticação sem senha",
"5q3qC0": "Download"
"5q3qC0": "Download",
"Gzq2CU": "Tente {button} taxas aumentando o valor do preenchimento"
}
3 changes: 2 additions & 1 deletion apps/extension/src/locales/ru.json
Original file line number Diff line number Diff line change
Expand Up @@ -432,5 +432,6 @@
"pOyrg7": "Открыть на боковой панели",
"tLyIg5": "Вход с использованием аутентификации без пароля",
"Ft5lhW": "Не удалось включить аутентификацию без пароля",
"5q3qC0": "Скачать"
"5q3qC0": "Скачать",
"Gzq2CU": "Попробуйте {button} комиссионные, увеличив значение заполнения."
}
3 changes: 2 additions & 1 deletion apps/extension/src/locales/zh.json
Original file line number Diff line number Diff line change
Expand Up @@ -434,5 +434,6 @@
"pOyrg7": "在侧面板中打开",
"tLyIg5": "使用无密码身份验证登录",
"Ft5lhW": "启用无密码身份验证失败",
"5q3qC0": "下载"
"5q3qC0": "下载",
"Gzq2CU": "尝试通过增加填充值来{button}费用"
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import { ResourceSnippet } from 'ui/src/components/snippet/resource'
import * as plainButtonStyles from 'ui/src/components/styles/plain-button-styles.css'
import { ToolTip } from 'ui/src/components/tool-tip'
import { RedGreenText, Text } from 'ui/src/components/typography'
import type { TextProps } from 'ui/src/components/typography/text'
import { ValidationErrorMessage } from 'ui/src/components/validation-error-message'
import { DAPP_ADDRESS } from 'ui/src/constants/dapp'
import { CURRENCY_STYLES, DECIMAL_STYLES } from 'ui/src/constants/number'
Expand Down Expand Up @@ -114,6 +115,10 @@ const messages = defineMessages({
id: 'T7Ry38',
defaultMessage: 'Message',
},
fee_reserve_error: {
id: 'Gzq2CU',
defaultMessage: 'Try to {button} fees by increasing padding value',
},
})

function getType(account: string, amount: number): string {
Expand Down Expand Up @@ -165,15 +170,43 @@ function aggregateChanges(resourceChanges: TransactionPreviewResponse['resource_
}, [])
}

function isInsufficientBalanceFeeReserveError(error_message?: string): boolean {
// SystemModuleError(CostingError(FeeReserveError(InsufficientBalance { required: 0.0050005, remaining: 0.0033562161779997 })))
return ['FeeReserveError', 'InsufficientBalance'].every(substring => error_message.includes(substring))
}

function isFeeReserveError(error_message?: string): boolean {
return error_message.includes('FeeReserveError')
}

function extractFeeReserveInsufficientBalanceValues(message: string): { required: number; remaining: number } | null {
const regex = /required:\s*([\d.]+),\s*remaining:\s*([\d.]+)/
const match = message.match(regex)

if (match) {
return {
required: parseFloat(match[1]),
remaining: parseFloat(match[2]),
}
}
return null
}

function getFeePaddingAmount(paddingCalculation: number, receipt: TransactionReceipt, walletCost: number): number {
return (
const padding =
FEE_PADDING_MARGIN *
(1 + paddingCalculation * FEE_PADDING_MARGIN_INCREMENT) *
(Number.parseFloat(receipt.fee_summary.xrd_total_execution_cost) +
Number.parseFloat(receipt.fee_summary.xrd_total_finalization_cost) +
Number.parseFloat(receipt.fee_summary.xrd_total_storage_cost) +
walletCost)
)
return 0.01
if (isInsufficientBalanceFeeReserveError(receipt.error_message)) {
const insufficientBalance = extractFeeReserveInsufficientBalanceValues(receipt.error_message)
if (insufficientBalance.required > padding) return insufficientBalance.required
return padding + (insufficientBalance.required - insufficientBalance.remaining)
}
return padding
}

function walletExecutionCost(meta: TransactionMeta): number {
Expand All @@ -187,15 +220,15 @@ function walletExecutionCost(meta: TransactionMeta): number {
}

function getFeeToLockAmount(receipt: TransactionReceipt, padding: number, walletCost: number): number {
return (
const lock =
Number.parseFloat(receipt.fee_summary.xrd_total_execution_cost) +
Number.parseFloat(receipt.fee_summary.xrd_total_finalization_cost) +
Number.parseFloat(receipt.fee_summary.xrd_total_royalty_cost) +
Number.parseFloat(receipt.fee_summary.xrd_total_storage_cost) +
Number.parseFloat(receipt.fee_summary.xrd_total_tipping_cost) +
walletCost +
padding
)
return lock
}

interface ICostProps {
Expand Down Expand Up @@ -227,6 +260,28 @@ export const Cost: React.FC<ICostProps> = ({ value, xrdPrice, format, currency }
)
}

interface ICustomizeFeeButtonProps extends TextProps {
onClick: () => void
}

const CustomizeFeeButton: React.FC<ICustomizeFeeButtonProps> = ({ onClick, ...props }) => {
const intl = useIntl()

return (
<Box
component="button"
display="inline-flex"
alignItems="center"
onClick={onClick}
className={clsx(plainButtonStyles.plainButtonHoverWrapper, plainButtonStyles.plainButtonHoverUnderlineWrapper)}
>
<Text color="inherit" size="xsmall" {...props}>
{intl.formatMessage(messages.customize_fee_button_title)}
</Text>
</Box>
)
}

interface IProps {
intent: Intent
settings: TransactionSettings
Expand Down Expand Up @@ -278,9 +333,8 @@ export const Preview: React.FC<IProps> = ({ intent, settings, meta, onSettingsCh
if (
newReceipt?.error_message &&
state.paddingCalculationRetry < MAX_PADDING_CALCULATION_RETRY &&
['FeeReserveError', 'InsufficientBalance'].every(substring => newReceipt?.error_message.includes(substring))
isInsufficientBalanceFeeReserveError(newReceipt?.error_message)
) {
// SystemModuleError(CostingError(FeeReserveError(InsufficientBalance { required: 0.0050005, remaining: 0.0033562161779997 })))
draft.paddingCalculationRetry += 1
draft.isLoading = true
} else {
Expand Down Expand Up @@ -350,6 +404,13 @@ export const Preview: React.FC<IProps> = ({ intent, settings, meta, onSettingsCh
<ValidationErrorMessage align="center" message={receipt?.error_message} />
</Box>
)}
{isFeeReserveError(receipt.error_message) && (
<Text align="center" color="strong">
{intl.formatMessage(messages.fee_reserve_error, {
button: <CustomizeFeeButton color="strong" onClick={handleClickCustomize} />,
})}
</Text>
)}
</Box>
)}

Expand Down Expand Up @@ -432,20 +493,7 @@ export const Preview: React.FC<IProps> = ({ intent, settings, meta, onSettingsCh
{intl.formatMessage(messages.fee_summary)}
</Text>
<Box className={styles.transactionPreviewFeeLinks}>
<Box
component="button"
display="inline-flex"
alignItems="center"
onClick={handleClickCustomize}
className={clsx(
plainButtonStyles.plainButtonHoverWrapper,
plainButtonStyles.plainButtonHoverUnderlineWrapper,
)}
>
<Text color="inherit" size="xsmall">
{intl.formatMessage(messages.customize_fee_button_title)}
</Text>
</Box>
<CustomizeFeeButton onClick={handleClickCustomize} />
<Box className={styles.transactionPreviewLinSeparator} />
<Box
component="button"
Expand Down
8 changes: 2 additions & 6 deletions apps/extension/src/radix/transaction.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
import type { Instruction, Instructions } from '@radixdlt/radix-engine-toolkit'
import { ValueKind, decimal } from '@radixdlt/radix-engine-toolkit'

export const appendLockFeeInstruction = (
instructions: Instructions,
feePayer: string,
padding: number,
): Instructions => {
export const appendLockFeeInstruction = (instructions: Instructions, feePayer: string, value: number): Instructions => {
instructions.value = [
{
kind: 'CallMethod',
Expand All @@ -16,7 +12,7 @@ export const appendLockFeeInstruction = (
methodName: 'lock_fee',
args: {
kind: ValueKind.Tuple,
fields: [decimal(padding)],
fields: [decimal(value)],
},
},
...(instructions.value as Instruction[]).filter(
Expand Down
4 changes: 3 additions & 1 deletion apps/website/src/components/layouts/app-page/locales/ar.json
Original file line number Diff line number Diff line change
Expand Up @@ -432,5 +432,7 @@
"nxazlA": "تفضيل المصادقة عبر الأنظمة الأساسية (YubiKey)",
"pOyrg7": "فتح في اللوحة الجانبية",
"tLyIg5": "قم بتسجيل الدخول باستخدام المصادقة بدون كلمة مرور",
"Ft5lhW": "فشل تمكين المصادقة بدون كلمة مرور"
"Ft5lhW": "فشل تمكين المصادقة بدون كلمة مرور",
"5q3qC0": "تحميل",
"Gzq2CU": "حاول {button} الرسوم عن طريق زيادة قيمة الحشو"
}
4 changes: 3 additions & 1 deletion apps/website/src/components/layouts/app-page/locales/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -433,5 +433,7 @@
"nxazlA": "Plattformübergreifende Authentifizierung (YubiKey) bevorzugen",
"pOyrg7": "Im Seitenbereich öffnen",
"tLyIg5": "Anmeldung mit passwortloser Authentifizierung",
"Ft5lhW": "Passwortlose Authentifizierung konnte nicht aktiviert werden"
"Ft5lhW": "Passwortlose Authentifizierung konnte nicht aktiviert werden",
"5q3qC0": "Herunterladen",
"Gzq2CU": "Versuchen Sie, die Gebühren durch Erhöhung des Füllwerts zu {button}"
}
4 changes: 3 additions & 1 deletion apps/website/src/components/layouts/app-page/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@
"5ZxAiY": "Token",
"5b2WMl": "Could not find any liquidity pool tokens in this account",
"5jeq8P": "Unknown",
"5q3qC0": "Download",
"5qaD7s": "Rejected",
"5sg7KC": "Password",
"5zZZ90": "Address book",
Expand Down Expand Up @@ -127,6 +128,7 @@
"GtxE3T": "Internal error{hasMessage, select, true {: {message}} other {, please try again} }",
"GufXy5": "Value",
"Gvxoji": "Name is required",
"Gzq2CU": "Try to {button} fees by increasing padding value",
"H5+NAX": "Balance",
"HAlOn1": "Name",
"HMBkUU": "To confirm ownership, sign challenge with persona {label}",
Expand Down Expand Up @@ -435,4 +437,4 @@
"zlB8/W": "Deny all third-party deposits",
"zspeCR": "LSUs",
"zuNWCA": "Blueprint version"
}
}
4 changes: 3 additions & 1 deletion apps/website/src/components/layouts/app-page/locales/es.json
Original file line number Diff line number Diff line change
Expand Up @@ -433,5 +433,7 @@
"nxazlA": "Prefiere autenticación multiplataforma (YubiKey)",
"pOyrg7": "Abrir en el panel lateral",
"tLyIg5": "Iniciar sesión usando autenticación sin contraseña",
"Ft5lhW": "Error al habilitar la autenticación sin contraseña"
"Ft5lhW": "Error al habilitar la autenticación sin contraseña",
"5q3qC0": "Descargar",
"Gzq2CU": "Intente {button} las tarifas aumentando el valor del relleno"
}
4 changes: 3 additions & 1 deletion apps/website/src/components/layouts/app-page/locales/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -433,5 +433,7 @@
"nxazlA": "Préférer l'authentification multiplateforme (YubiKey)",
"pOyrg7": "Ouvrir dans le panneau latéral",
"tLyIg5": "Connexion avec authentification sans mot de passe",
"Ft5lhW": "Échec de l'activation de l'authentification sans mot de passe"
"Ft5lhW": "Échec de l'activation de l'authentification sans mot de passe",
"5q3qC0": "Télécharger",
"Gzq2CU": "Essayez de {button} les frais en augmentant la valeur de remplissage"
}
4 changes: 3 additions & 1 deletion apps/website/src/components/layouts/app-page/locales/it.json
Original file line number Diff line number Diff line change
Expand Up @@ -433,5 +433,7 @@
"nxazlA": "Preferisci l'autenticazione multipiattaforma (YubiKey)",
"pOyrg7": "Apri nel pannello laterale",
"tLyIg5": "Accedi utilizzando l'autenticazione senza password",
"Ft5lhW": "Impossibile abilitare l'autenticazione senza password"
"Ft5lhW": "Impossibile abilitare l'autenticazione senza password",
"5q3qC0": "Scaricamento",
"Gzq2CU": "Prova a {button} commissioni aumentando il valore di riempimento"
}
4 changes: 3 additions & 1 deletion apps/website/src/components/layouts/app-page/locales/jp.json
Original file line number Diff line number Diff line change
Expand Up @@ -433,5 +433,7 @@
"nxazlA": "クロスプラットフォーム認証 (YubiKey) を優先します",
"pOyrg7": "サイドパネルで開く",
"tLyIg5": "パスワードなしの認証を使用してログイン",
"Ft5lhW": "パスワードなしの認証を有効にできませんでした"
"Ft5lhW": "パスワードなしの認証を有効にできませんでした",
"5q3qC0": "ダウンロード",
"Gzq2CU": "パディング値を増やして手数料を{button}してみてください"
}
4 changes: 3 additions & 1 deletion apps/website/src/components/layouts/app-page/locales/pl.json
Original file line number Diff line number Diff line change
Expand Up @@ -433,5 +433,7 @@
"nxazlA": "Preferuj uwierzytelnianie międzyplatformowe (YubiKey)",
"pOyrg7": "Otwórz w panelu bocznym",
"tLyIg5": "Zaloguj się przy użyciu uwierzytelniania bez hasła",
"Ft5lhW": "Nie udało się włączyć uwierzytelniania bez hasła"
"Ft5lhW": "Nie udało się włączyć uwierzytelniania bez hasła",
"5q3qC0": "Ściągnij",
"Gzq2CU": "Spróbuj {button} opłat, zwiększając wartość dopełnienia"
}
Loading

0 comments on commit e9262d7

Please sign in to comment.