Skip to content

Commit

Permalink
fix: replace missing variables and rename files
Browse files Browse the repository at this point in the history
  • Loading branch information
evavirseda committed Jan 4, 2024
1 parent be1278a commit 78863d8
Show file tree
Hide file tree
Showing 8 changed files with 16 additions and 13 deletions.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import BigInteger from 'big-integer'

export const GAS_FEE = BigInteger(500000)
2 changes: 1 addition & 1 deletion packages/shared/lib/core/layer-2/constants/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ export * from './empty-buffer.constants'
export * from './erc-20-token-address-length.constant'
export * from './externally-owned-account-type-id.constant'
export * from './externally-owned-account.constant'
export * from './gas-budget.constant'
export * from './gas-fee.constant'
export * from './gas-multiplier.constant'
export * from './isc-magic-contract-address.constant'
export * from './layer2-tokens-poll-interval.constant'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@ export interface ILayer2Parameters {
networkAddress: string
senderAddress: string
gasFee?: BigInteger
gasBudget?: BigInteger
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@ export interface ILayer2SmartContractCallData extends ILayer2AssetAllowance {
senderContract: string
targetContract: string
contractFunction: string
gasFee: string
gasFee?: string
gasBudget?: string
}
4 changes: 2 additions & 2 deletions packages/shared/lib/core/layer-2/utils/addGasFee.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { GAS_BUDGET } from '@core/layer-2/constants'
import { GAS_FEE } from '@core/layer-2/constants'
import BigInteger from 'big-integer'

export function addGasFee(rawAmount: string): string {
const bigAmount = BigInteger(rawAmount).add(GAS_BUDGET)
const bigAmount = BigInteger(rawAmount).add(GAS_FEE)
return bigAmount.toString()
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { activeProfileId } from '@core/profile/stores/active-profile-id.store'
import { NetworkId } from '@core/network/enums'

import { GAS_BUDGET } from '@core/layer-2/constants'
import { GAS_FEE } from '@core/layer-2/constants'

import { getOutputParameters } from '../utils'
import { ReturnStrategy, TokenStandard, VerifiedStatus } from '../enums'
Expand Down Expand Up @@ -78,7 +78,7 @@ jest.mock('../../profile/actions/active-profile/getCoinType', () => ({
}))

jest.mock('../../layer-2/utils/getEstimatedGasForTransferFromTransactionDetails', () => ({
getEstimatedGasForTransferFromTransactionDetails: jest.fn(() => GAS_BUDGET.toJSNumber()),
getEstimatedGasForTransferFromTransactionDetails: jest.fn(() => GAS_FEE.toJSNumber()),
}))

describe('File: getOutputParameters.ts', () => {
Expand Down Expand Up @@ -195,7 +195,7 @@ describe('File: getOutputParameters.ts', () => {

const expectedOutput = {
recipientAddress: layer2Parameters.networkAddress,
amount: (Number(GAS_BUDGET) + Number(amount)).toString(),
amount: (Number(GAS_FEE) + Number(amount)).toString(),
features: {
metadata:
'0x00025e4b3ca1e3f423a0c21e0101614003676642585b5148b14639782bf0c83960ff465b9aa7c161d5aad08910e310902000010000070c000c30680e00000090000f0ea000060009000d300000000000808094ebdc03',
Expand All @@ -218,7 +218,7 @@ describe('File: getOutputParameters.ts', () => {

const expectedOutput = {
recipientAddress: layer2Parameters.networkAddress,
amount: GAS_BUDGET.toString(),
amount: GAS_FEE.toString(),
assets: {
nativeTokens: [
{
Expand Down Expand Up @@ -249,7 +249,7 @@ describe('File: getOutputParameters.ts', () => {

const expectedOutput = {
recipientAddress: layer2Parameters.networkAddress,
amount: GAS_BUDGET.toString(),
amount: GAS_FEE.toString(),
assets: {
nftId,
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,12 @@ export async function generateSingleBasicActivity(
const asyncData = await getAsyncDataFromOutput(output, outputId, claimingData, account)
const { parsedLayer2Metadata, destinationNetwork } = getLayer2ActivityInformation(metadata, sendingInfo)
const layer2Allowance = Number(parsedLayer2Metadata?.baseTokens ?? '0')
const gasBudget = Number(parsedLayer2Metadata?.gasBudget ?? '0')
const gasFee = layer2Allowance > 0 ? amount - layer2Allowance : 0

let { storageDeposit, giftedStorageDeposit } = await getStorageDepositFromOutput(account, output)
giftedStorageDeposit = action === ActivityAction.Burn ? 0 : giftedStorageDeposit
giftedStorageDeposit = gasFee === 0 ? giftedStorageDeposit : 0
giftedStorageDeposit = gasBudget === 0 ? giftedStorageDeposit : 0

const baseTokenAmount = amount - storageDeposit - gasFee

Expand Down

0 comments on commit 78863d8

Please sign in to comment.