Skip to content

Commit

Permalink
feat: add time expiration unlock condition for l1-l2 txs (#7719)
Browse files Browse the repository at this point in the history
* feat: add time expiration unlock condition for l1-l2 txs

* enhancement: improve code readability
  • Loading branch information
begonaalvarezd authored Nov 16, 2023
1 parent 1ac4367 commit 9528333
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,9 @@
transactionDetails.type === NewTransactionType.TokenTransfer &&
transactionDetails.asset?.metadata?.standard === TokenStandard.BaseToken
$: isInternal = recipient.type === 'account'
$: isLayer2Transaction = !!layer2Parameters
$: isTransferring = $selectedAccount.isTransferring
$: hideGiftToggle = isBaseTokenTransfer || !!layer2Parameters || (disableToggleGift && !giftStorageDeposit)
$: hideGiftToggle = isBaseTokenTransfer || isLayer2Transaction || (disableToggleGift && !giftStorageDeposit)
$: if (!isSendAndClosePopup) expirationDate, giftStorageDeposit, void rebuildTransactionOutput()
Expand All @@ -84,7 +85,12 @@
if (isSendAndClosePopup) {
// Needed after 'return from stronghold' to SHOW to correct expiration date before output is sent
initialExpirationDate = getInitialExpirationDate(expirationDate, storageDeposit, giftStorageDeposit)
initialExpirationDate = getInitialExpirationDate(
expirationDate,
storageDeposit,
giftStorageDeposit,
isLayer2Transaction
)
try {
await _onMount()
Expand All @@ -111,7 +117,12 @@
// as it updates expiration date through the ExpirationTimePicker bind
// Could be avoided with a rework of ExpirationTimePicker
if (transactionDetails.expirationDate === undefined) {
initialExpirationDate = getInitialExpirationDate(expirationDate, storageDeposit, giftStorageDeposit)
initialExpirationDate = getInitialExpirationDate(
expirationDate,
storageDeposit,
giftStorageDeposit,
isLayer2Transaction
)
}
} catch (err) {
handleError(err)
Expand Down
5 changes: 3 additions & 2 deletions packages/shared/lib/core/wallet/utils/send/sendUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,12 @@ export enum OptionalInputType {
export function getInitialExpirationDate(
expirationDate: Date,
storageDeposit: number,
giftStorageDeposit: boolean
giftStorageDeposit: boolean,
isLayer2: boolean
): TimePeriod {
if (expirationDate) {
return TimePeriod.Custom
} else if (storageDeposit && !giftStorageDeposit) {
} else if ((storageDeposit && !giftStorageDeposit) || isLayer2) {
return TimePeriod.OneDay
} else {
return TimePeriod.None
Expand Down

0 comments on commit 9528333

Please sign in to comment.