MCPcopy Create free account
hub / github.com/Modulus-Labs/RockyBot / loadActionData

Function loadActionData

front-end/src/App.tsx:135–163  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

133 }
134
135 const loadActionData = () => {
136 if (firebaseDbRef.current != null) {
137 getDocs(collection(firebaseDbRef.current, "rocky_trades"))
138 .then((result) => {
139 // --- Read in all donations and process each one ---
140 let loadedTradesList: ActionContributionListData[] = [];
141 result.forEach((doc) => {
142 const rawTradeEntry: RockyTradesDocument = (doc.data() as RockyTradesDocument);
143 const actionText = rawTradeEntry.action_type === "HOLD" ? `HOLD position` : `${rawTradeEntry.action_type} $${roundNumber(parseFloat(rawTradeEntry.amount), 2)} worth of WETH`;
144 const tradeEntry: ActionContributionListData = {
145 actionText: actionText,
146 dataText: getShorthandTimeIntervalString(rawTradeEntry.timestamp.toDate(), false),
147 isAction: true,
148 timestamp: rawTradeEntry.timestamp.toDate(),
149 }
150 loadedTradesList.push(tradeEntry);
151 });
152 // --- Sort + set current list ---
153 loadedTradesList.sort((a, b) => { return a.timestamp > b.timestamp ? -1 : 1 });
154 setActionListData(loadedTradesList);
155 })
156 .catch((error) => {
157 console.error("Error in getting rocky_trades collection");
158 console.error(error);
159 });
160 } else {
161 console.error("Couldn\'t connect to firebase");
162 }
163 }
164
165 const loadNetWorth = () => {
166 if (firebaseDbRef.current != null) {

Callers 1

AppFunction · 0.85

Calls 2

roundNumberFunction · 0.90

Tested by

no test coverage detected