|
13 | 13 | import { HttpClient, HttpClientResponse } from "@effect/platform" |
14 | 14 | import { BigDecimal, Data, Effect, pipe, Schema } from "effect" |
15 | 15 |
|
16 | | -const REST_BASE_URL = import.meta.env.DEV ? "/api/union" : "https://rest.union.build" |
| 16 | +const REST_BASE_URL = "https://rest.union.build" |
17 | 17 |
|
18 | 18 | export class IncentiveError extends Data.TaggedError("IncentiveError")<{ |
19 | 19 | message: string |
@@ -64,46 +64,70 @@ export const IncentiveResult = Schema.Struct({ |
64 | 64 | export type IncentiveResult = Schema.Schema.Type<typeof IncentiveResult> |
65 | 65 |
|
66 | 66 | const getInflation = pipe( |
67 | | - HttpClient.get(`${REST_BASE_URL}/cosmos/mint/v1beta1/inflation`), |
68 | | - Effect.flatMap(HttpClientResponse.schemaBodyJson(InflationResponse)), |
69 | | - Effect.mapError((cause) => |
70 | | - new IncentiveError({ |
71 | | - message: "Failed to fetch inflation rate", |
72 | | - cause, |
73 | | - }) |
| 67 | + HttpClient.HttpClient, |
| 68 | + Effect.map(HttpClient.withTracerDisabledWhen(() => true)), |
| 69 | + Effect.andThen((client) => |
| 70 | + pipe( |
| 71 | + client.get(`${REST_BASE_URL}/cosmos/mint/v1beta1/inflation`), |
| 72 | + Effect.flatMap(HttpClientResponse.schemaBodyJson(InflationResponse)), |
| 73 | + Effect.mapError((cause) => |
| 74 | + new IncentiveError({ |
| 75 | + message: "Failed to fetch inflation rate", |
| 76 | + cause, |
| 77 | + }) |
| 78 | + ), |
| 79 | + ) |
74 | 80 | ), |
75 | 81 | ) |
76 | 82 |
|
77 | 83 | const getStakingPool = pipe( |
78 | | - HttpClient.get(`${REST_BASE_URL}/cosmos/staking/v1beta1/pool`), |
79 | | - Effect.flatMap(HttpClientResponse.schemaBodyJson(StakingPoolResponse)), |
80 | | - Effect.mapError((cause) => |
81 | | - new IncentiveError({ |
82 | | - message: "Failed to fetch staking pool", |
83 | | - cause, |
84 | | - }) |
| 84 | + HttpClient.HttpClient, |
| 85 | + Effect.map(HttpClient.withTracerDisabledWhen(() => true)), |
| 86 | + Effect.andThen((client) => |
| 87 | + pipe( |
| 88 | + client.get(`${REST_BASE_URL}/cosmos/staking/v1beta1/pool`), |
| 89 | + Effect.flatMap(HttpClientResponse.schemaBodyJson(StakingPoolResponse)), |
| 90 | + Effect.mapError((cause) => |
| 91 | + new IncentiveError({ |
| 92 | + message: "Failed to fetch staking pool", |
| 93 | + cause, |
| 94 | + }) |
| 95 | + ), |
| 96 | + ) |
85 | 97 | ), |
86 | 98 | ) |
87 | 99 |
|
88 | 100 | const getDistributionParams = pipe( |
89 | | - HttpClient.get(`${REST_BASE_URL}/cosmos/distribution/v1beta1/params`), |
90 | | - Effect.flatMap(HttpClientResponse.schemaBodyJson(DistributionParamsResponse)), |
91 | | - Effect.mapError((cause) => |
92 | | - new IncentiveError({ |
93 | | - message: "Failed to fetch distribution params", |
94 | | - cause, |
95 | | - }) |
| 101 | + HttpClient.HttpClient, |
| 102 | + Effect.map(HttpClient.withTracerDisabledWhen(() => true)), |
| 103 | + Effect.andThen((client) => |
| 104 | + pipe( |
| 105 | + client.get(`${REST_BASE_URL}/cosmos/distribution/v1beta1/params`), |
| 106 | + Effect.flatMap(HttpClientResponse.schemaBodyJson(DistributionParamsResponse)), |
| 107 | + Effect.mapError((cause) => |
| 108 | + new IncentiveError({ |
| 109 | + message: "Failed to fetch distribution params", |
| 110 | + cause, |
| 111 | + }) |
| 112 | + ), |
| 113 | + ) |
96 | 114 | ), |
97 | 115 | ) |
98 | 116 |
|
99 | 117 | const getCirculatingSupply = pipe( |
100 | | - HttpClient.get(`${REST_BASE_URL}/cosmos/bank/v1beta1/supply/by_denom?denom=au`), |
101 | | - Effect.flatMap(HttpClientResponse.schemaBodyJson(CirculatingSupplyResponse)), |
102 | | - Effect.mapError((cause) => |
103 | | - new IncentiveError({ |
104 | | - message: "Failed to fetch circulating supply", |
105 | | - cause, |
106 | | - }) |
| 118 | + HttpClient.HttpClient, |
| 119 | + Effect.map(HttpClient.withTracerDisabledWhen(() => true)), |
| 120 | + Effect.andThen((client) => |
| 121 | + pipe( |
| 122 | + client.get(`${REST_BASE_URL}/cosmos/bank/v1beta1/supply/by_denom?denom=au`), |
| 123 | + Effect.flatMap(HttpClientResponse.schemaBodyJson(CirculatingSupplyResponse)), |
| 124 | + Effect.mapError((cause) => |
| 125 | + new IncentiveError({ |
| 126 | + message: "Failed to fetch circulating supply", |
| 127 | + cause, |
| 128 | + }) |
| 129 | + ), |
| 130 | + ) |
107 | 131 | ), |
108 | 132 | ) |
109 | 133 |
|
|
0 commit comments