Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions docs/src/lib/components/gas/Gas.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import anime from 'animejs'
import GasCard from './GasCard.svelte'
import gasModule from '@web3-onboard/gas'
import { onMount } from 'svelte'
import { onDestroy, onMount } from 'svelte'
import { ethers } from 'ethers'
import type { GasPrice, RPCGasPrice, GasData } from './types'

Expand All @@ -19,14 +19,15 @@
})
}
let ethMainnetGasBlockPrices
let gasSub
let rpcGasData: RPCGasPrice
onMount(() => {
ethMainnetGasBlockPrices = gasModule.stream({
chains: ['0x1'],
apiKey: 'da1b962d-314d-4903-bfe1-426821d14a35',
endpoint: 'blockPrices'
})
ethMainnetGasBlockPrices.subscribe(() => {
gasSub = ethMainnetGasBlockPrices.subscribe(() => {
async function getEtherGasFromRPC() {
const INFURA_ID = '8b60d52405694345a99bcb82e722e0af'
const infuraRPC = `https://mainnet.infura.io/v3/${INFURA_ID}`
Expand Down Expand Up @@ -62,6 +63,10 @@
estimatedTransactionCount: null,
seconds: null
}

onDestroy(() => {
gasSub && gasSub.unsubscribe()
})
</script>

<div class="Gas px-6 p-4">
Expand Down