Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: remove duplicate TokenAmount type definition #424

Merged
Merged
Show file tree
Hide file tree
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
3 changes: 2 additions & 1 deletion src/lib/adapters/balance.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { balanceStore, type TokenAmount } from '$lib/stores/balances'
import { balanceStore } from '$lib/stores/balances'
import { defaultBlockchainNetwork, getBalance, getProvider } from '$lib/adapters/transaction'
import { Contract } from 'ethers'
import abi from '$lib/abis/erc20.json'
import type { TokenAmount } from '$lib/objects/schemas'

export async function fetchBalances(address: string): Promise<void> {
balanceStore.update((state) => ({
Expand Down
3 changes: 1 addition & 2 deletions src/lib/adapters/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import type { TokenAmount } from '$lib/stores/balances'
import WakuAdapter from '$lib/adapters/waku'
import type { BaseWallet } from 'ethers'
import type { User } from '$lib/objects/schemas'
import type { TokenAmount, User } from '$lib/objects/schemas'
import type { JSONSerializable } from '$lib/objects'

export interface Adapter {
Expand Down
2 changes: 1 addition & 1 deletion src/lib/adapters/waku/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ import type { BaseWallet, Wallet } from 'ethers'
import { get } from 'svelte/store'
import { objectStore, objectKey } from '$lib/stores/objects'
import { lookup } from '$lib/objects/lookup'
import type { TokenAmount } from '$lib/stores/balances'
import {
defaultBlockchainNetwork,
sendTransaction,
Expand All @@ -35,6 +34,7 @@ import { makeWakustore } from './wakustore'
import type { StorageChat, StorageChatEntry, StorageObjectEntry, StorageProfile } from './types'
import { walletStore } from '$lib/stores/wallet'
import { SafeWaku } from './safe-waku'
import type { TokenAmount } from '$lib/objects/schemas'

const MAX_MESSAGES = 100

Expand Down
3 changes: 1 addition & 2 deletions src/lib/objects/adapter.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import type { Adapter } from '$lib/adapters'
import { Contract, type BaseWallet, type TransactionReceipt, Interface } from 'ethers'
import type { WakuObjectAdapter } from '.'
import type { TokenAmount } from '$lib/stores/balances'
import {
defaultBlockchainNetwork,
getProvider,
Expand All @@ -10,7 +9,7 @@ import {
getTransactionTimestamp,
waitForTransaction,
} from '$lib/adapters/transaction'
import type { Transaction, TransactionState } from './schemas'
import type { TokenAmount, Transaction, TransactionState } from './schemas'
import { checkBalance } from '$lib/adapters/balance'
import abi from '$lib/abis/erc20.json'

Expand Down
3 changes: 2 additions & 1 deletion src/lib/objects/ui.svelte
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<script lang="ts">
import adapter from '$lib/adapters'
import { lookup } from './lookup'
import { balanceStore, type TokenAmount } from '$lib/stores/balances'
import { balanceStore } from '$lib/stores/balances'
import { chats, type Chat } from '$lib/stores/chat'
import type { JSONSerializable, WakuObjectArgs } from '.'
import { profile } from '$lib/stores/profile'
Expand All @@ -10,6 +10,7 @@
import { objectKey, objectStore } from '$lib/stores/objects'
import Container from '$lib/components/container.svelte'
import type { HDNodeWallet } from 'ethers/lib.commonjs'
import type { TokenAmount } from './schemas'

export let objectId: string
export let instanceId: string
Expand Down
10 changes: 1 addition & 9 deletions src/lib/stores/balances.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,7 @@
import type { TokenAmount } from '$lib/objects/schemas'
import { writable } from 'svelte/store'
import type { Writable } from 'svelte/store'

export interface TokenAmount {
name: string
symbol: string
amount: bigint
decimals: number
image?: string
address?: string // if not set, it is the native token
}

interface BalanceState {
balances: TokenAmount[]
loading: boolean
Expand Down