Skip to content

Commit

Permalink
chore: fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
cor committed Mar 9, 2025
1 parent 8cf441e commit 02e1d1d
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 16 deletions.
15 changes: 9 additions & 6 deletions app2/src/lib/schema/chain.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,9 @@ export class Chain extends Schema.Class<Chain>("Chain")({
return Option.fromNullable(VIEM_CHAINS.find(vc => `${vc.id}` === this.chain_id))
}

toCosmosDisplay(address: AddressCosmosCanonical): Effect.Effect<AddressCosmosDisplay, NotACosmosChainError | CosmosAddressEncodeError> {
toCosmosDisplay(
address: AddressCosmosCanonical
): Effect.Effect<AddressCosmosDisplay, NotACosmosChainError | CosmosAddressEncodeError> {
if (this.rpc_type !== "cosmos") {
return Effect.fail(new NotACosmosChainError({ chain: this }))
}
Expand All @@ -91,11 +93,12 @@ export class Chain extends Schema.Class<Chain>("Chain")({
const encoded = bech32.encode(this.addr_prefix, words)
return encoded as AddressCosmosDisplay
},
catch: error => new CosmosAddressEncodeError({
cause: error,
address: address,
prefix: this.addr_prefix
})
catch: error =>
new CosmosAddressEncodeError({
cause: error,
address: address,
prefix: this.addr_prefix
})
})
}

Expand Down
2 changes: 1 addition & 1 deletion app2/src/lib/schema/hex.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Data, Schema } from "effect"
import { Schema } from "effect"

export const Hex = Schema.TemplateLiteral("0x", Schema.String).pipe(Schema.pattern(/^0x[0-9a-f]+$/))

Expand Down
18 changes: 9 additions & 9 deletions app2/src/lib/services/evm/balances.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Schedule, Data, Effect, Option, Schema } from "effect"
import { erc20Abi, fromHex, type PublicClient } from "viem"
import { erc20Abi, type PublicClient } from "viem"
import type { TimeoutException } from "effect/Cause"
import type { DurationInput } from "effect/Duration"
import type { GetBalanceErrorType, ReadContractErrorType } from "viem"
Expand All @@ -9,7 +9,7 @@ import type { NoViemChainError } from "$lib/services/evm/clients"
import type { AddressEvmCanonical } from "$lib/schema/address"
import type { Chain } from "$lib/schema/chain"
import type { CreatePublicClientError } from "$lib/services/transfer"
import { fromHexString, FromHexError } from "$lib/utils/hex"
import { fromHexString, type FromHexError } from "$lib/utils/hex"
import { evmBalanceRetrySchedule } from "$lib/constants/schedules"

export type FetchEvmBalanceError =
Expand Down Expand Up @@ -83,23 +83,23 @@ export const createEvmBalanceQuery = ({
}) => {
const fetcherPipeline = Effect.gen(function* (_) {
const client = yield* getPublicClient(chain)
const decodedDenom = yield* fromHexString(tokenAddress)
const decodedDenom = yield* fromHexString(tokenAddress)

yield* Effect.log(`starting balances fetcher for ${chain.universal_chain_id}:${walletAddress}:${tokenAddress}`)
yield* Effect.log(
`starting balances fetcher for ${chain.universal_chain_id}:${walletAddress}:${tokenAddress}`
)

const fetchBalance = decodedDenom === "native"
const fetchBalance =
decodedDenom === "native"
? fetchEvmGasBalance({ client, walletAddress })
: fetchEvmErc20Balance({ client, tokenAddress, walletAddress })


const balance = yield* Effect.retry(fetchBalance, evmBalanceRetrySchedule)

writeData(RawTokenBalance.make(Option.some(TokenRawAmount.make(balance))))
writeError(Option.none())
}).pipe(
Effect.tapError(error =>
Effect.sync(() => writeError(Option.some(error)) )
),
Effect.tapError(error => Effect.sync(() => writeError(Option.some(error)))),
Effect.catchAll(_ => Effect.succeed(null))
)

Expand Down

0 comments on commit 02e1d1d

Please sign in to comment.