-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Gas data in the dashboard (#203)
- Loading branch information
Ben
authored
Apr 14, 2022
1 parent
7feb3f3
commit bc4df66
Showing
9 changed files
with
371 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import { storiesOf } from '@storybook/vue'; | ||
import { BigNumber } from 'bignumber.js'; | ||
import faker from 'faker'; | ||
import GasTable from '~/components/GasTable'; | ||
import { generateFakeGasParameters, generateFakeTransactionFees } from '~/helpers/generateFakeGas'; | ||
|
||
const common = { | ||
components: { GasTable }, | ||
data: () => ({ | ||
baseFeePerGas: new BigNumber(faker.datatype.number()), | ||
gasParameters: generateFakeGasParameters(), | ||
transactionFees: generateFakeTransactionFees(), | ||
}), | ||
}; | ||
|
||
storiesOf('GasTable', module).add('Default', () => ({ | ||
...common, | ||
template: | ||
'<GasTable :baseFeePerGas="baseFeePerGas" :gasParameters="gasParameters" :transactionFees="transactionFees" />', | ||
})); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,190 @@ | ||
<template> | ||
<div> | ||
<table class="Table"> | ||
<tr> | ||
<th class="Heading">Fee Parameter</th> | ||
<th class="Heading">Value</th> | ||
<th class="Heading">Value in DAI</th> | ||
</tr> | ||
<tbody> | ||
<tr> | ||
<td class="Body"> | ||
<span> Gas Price </span> | ||
</td> | ||
<td class="Body"> | ||
<FormatCurrency | ||
v-if="gasParameters && gasParameters.gasPrice" | ||
:value="formatGasParameters(gasParameters.gasPrice)" | ||
currency="GWEI" | ||
/> | ||
<span v-else class="UnknownValue"> Unknown </span> | ||
</td> | ||
<td class="Body"> | ||
<span class="UnknownValue"> Unknown </span> | ||
</td> | ||
</tr> | ||
<tr> | ||
<td class="Body"> | ||
<span> Max Priority Fee Per Gas </span> | ||
</td> | ||
<td class="Body"> | ||
<FormatCurrency | ||
v-if="gasParameters && gasParameters.maxPriorityFeePerGas" | ||
:value="formatGasParameters(gasParameters.maxPriorityFeePerGas)" | ||
currency="GWEI" | ||
/> | ||
<span v-else class="UnknownValue"> Unknown </span> | ||
</td> | ||
<td class="Body"> | ||
<span class="UnknownValue"> Unknown </span> | ||
</td> | ||
</tr> | ||
<tr> | ||
<td class="Body"> | ||
<span> Max Fee Per Gas </span> | ||
</td> | ||
<td class="Body"> | ||
<FormatCurrency | ||
v-if="gasParameters && gasParameters.maxFeePerGas" | ||
:value="formatGasParameters(gasParameters.maxFeePerGas)" | ||
currency="GWEI" | ||
/> | ||
<span v-else class="UnknownValue"> Unknown </span> | ||
</td> | ||
<td class="Body"> | ||
<span class="UnknownValue"> Unknown </span> | ||
</td> | ||
</tr> | ||
<tr> | ||
<td class="Body"> | ||
<span> Base Fee Per Gas </span> | ||
</td> | ||
<td class="Body"> | ||
<FormatCurrency v-if="baseFeePerGas" :value="baseFeePerGas" currency="GWEI" /> | ||
<span v-else class="UnknownValue"> Unknown </span> | ||
</td> | ||
<td class="Body"> | ||
<span class="UnknownValue"> Unknown </span> | ||
</td> | ||
</tr> | ||
<tr> | ||
<td class="Body"> | ||
<span> Bidding Transaction Fee </span> | ||
</td> | ||
<td class="Body"> | ||
<FormatCurrency | ||
v-if="transactionFees" | ||
:value="transactionFees.biddingTransactionFeeETH" | ||
currency="ETH" | ||
/> | ||
<span v-else class="UnknownValue"> Unknown </span> | ||
</td> | ||
<td class="Body"> | ||
<FormatCurrency | ||
v-if="transactionFees" | ||
:value="transactionFees.biddingTransactionFeeDAI" | ||
currency="DAI" | ||
/> | ||
<span v-else class="UnknownValue"> Unknown </span> | ||
</td> | ||
</tr> | ||
<tr> | ||
<td class="Body"> | ||
<span> Auth Transaction Fee </span> | ||
</td> | ||
<td class="Body"> | ||
<FormatCurrency | ||
v-if="transactionFees" | ||
:value="transactionFees.authTransactionFeeETH" | ||
currency="ETH" | ||
/> | ||
<span v-else class="UnknownValue"> Unknown </span> | ||
</td> | ||
<td class="Body"> | ||
<FormatCurrency | ||
v-if="transactionFees" | ||
:value="transactionFees.authTransactionFeeDAI" | ||
currency="DAI" | ||
/> | ||
<span v-else class="UnknownValue"> Unknown </span> | ||
</td> | ||
</tr> | ||
<tr> | ||
<td class="Body"> | ||
<span> Restart Transaction Fee </span> | ||
</td> | ||
<td class="Body"> | ||
<FormatCurrency | ||
v-if="transactionFees" | ||
:value="transactionFees.restartTransactionFeeETH" | ||
currency="ETH" | ||
/> | ||
<span v-else class="UnknownValue"> Unknown </span> | ||
</td> | ||
<td class="Body"> | ||
<FormatCurrency | ||
v-if="transactionFees" | ||
:value="transactionFees.restartTransactionFeeDAI" | ||
currency="DAI" | ||
/> | ||
<span v-else class="UnknownValue"> Unknown </span> | ||
</td> | ||
</tr> | ||
</tbody> | ||
</table> | ||
</div> | ||
</template> | ||
|
||
<script lang="ts"> | ||
import Vue from 'vue'; | ||
import BigNumber from 'bignumber.js'; | ||
import type { GasParameters, TransactionFees } from 'auctions-core/src/types'; | ||
import { GWEI_NUMBER_OF_DIGITS } from 'auctions-core/dist/src/constants/UNITS'; | ||
import FormatCurrency from './utils/FormatCurrency.vue'; | ||
export default Vue.extend({ | ||
name: 'GasTable', | ||
components: { FormatCurrency }, | ||
props: { | ||
baseFeePerGas: { | ||
type: Object as Vue.PropType<BigNumber>, | ||
default: undefined, | ||
}, | ||
gasParameters: { | ||
type: Object as Vue.PropType<GasParameters>, | ||
default: undefined, | ||
}, | ||
transactionFees: { | ||
type: Object as Vue.PropType<TransactionFees>, | ||
default: undefined, | ||
}, | ||
}, | ||
methods: { | ||
formatGasParameters(value): BigNumber { | ||
return new BigNumber(value).shiftedBy(-GWEI_NUMBER_OF_DIGITS); | ||
}, | ||
}, | ||
}); | ||
</script> | ||
|
||
<style scoped> | ||
.Table { | ||
@apply w-full border-2 border-gray-300 dark:border-gray-600 bg-transparent; | ||
} | ||
.Element { | ||
@apply p-2 h-8 border-r-2 border-b-2 border-gray-300 dark:border-gray-600; | ||
} | ||
.Body { | ||
@apply Element text-gray-500 dark:text-gray-300; | ||
} | ||
.Heading { | ||
@apply Element text-gray-700 dark:text-gray-100; | ||
} | ||
.UnknownValue { | ||
@apply text-gray-400; | ||
} | ||
</style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import { GasParameters, TransactionFees } from 'auctions-core/src/types'; | ||
import faker from 'faker'; | ||
import BigNumber from 'bignumber.js'; | ||
|
||
export function generateFakeGasParameters(): GasParameters { | ||
return { | ||
maxFeePerGas: faker.datatype.number({ min: 1000000, max: 1000000000 }).toString(), | ||
maxPriorityFeePerGas: faker.datatype.number({ min: 1000000, max: 1000000000 }).toString(), | ||
gasPrice: faker.datatype.number({ min: 1000000, max: 1000000000 }).toString(), | ||
}; | ||
} | ||
|
||
export function generateFakeTransactionFees(): TransactionFees { | ||
const biddingTransactionFeeETH = new BigNumber(faker.datatype.float({ min: 0, max: 0.001, precision: 0.000001 })); | ||
const biddingTransactionFeeDAI = biddingTransactionFeeETH.multipliedBy(1000); | ||
const authTransactionFeeETH = new BigNumber(faker.datatype.float({ min: 0, max: 0.001, precision: 0.000001 })); | ||
const authTransactionFeeDAI = authTransactionFeeETH.multipliedBy(1000); | ||
const restartTransactionFeeETH = new BigNumber(faker.datatype.float({ min: 0, max: 0.001, precision: 0.000001 })); | ||
const restartTransactionFeeDAI = restartTransactionFeeETH.multipliedBy(1000); | ||
|
||
return { | ||
biddingTransactionFeeETH, | ||
biddingTransactionFeeDAI, | ||
authTransactionFeeETH, | ||
authTransactionFeeDAI, | ||
restartTransactionFeeETH, | ||
restartTransactionFeeDAI, | ||
}; | ||
} |
Oops, something went wrong.