Skip to content

Commit

Permalink
Rename variable
Browse files Browse the repository at this point in the history
  • Loading branch information
matjazv committed Nov 8, 2024
1 parent 8cb269b commit 3d3fef6
Showing 1 changed file with 10 additions and 11 deletions.
21 changes: 10 additions & 11 deletions web3-functions/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,10 @@ Web3Function.onRun(async (context: Web3FunctionContext) => {
debugLog("Data feed ids: ", dataFeedIds);

// Wrap contract with redstone data service
let wrappedOraclePrimaryProd;
let wrappedOracle;
switch (dataServiceId) {
case "redstone-primary-prod":
wrappedOraclePrimaryProd = WrapperBuilder.wrap(oracle).usingDataService(
wrappedOracle = WrapperBuilder.wrap(oracle).usingDataService(
{
dataServiceId: "redstone-primary-prod",
uniqueSignersCount: 2,
Expand All @@ -71,7 +71,7 @@ Web3Function.onRun(async (context: Web3FunctionContext) => {
);
break;
case "redstone-main-demo":
wrappedOraclePrimaryProd = WrapperBuilder.wrap(oracle).usingDataService(
wrappedOracle = WrapperBuilder.wrap(oracle).usingDataService(
{
dataServiceId: "redstone-main-demo",
uniqueSignersCount: 1,
Expand All @@ -88,9 +88,9 @@ Web3Function.onRun(async (context: Web3FunctionContext) => {
};
}

// Retrieve stored & live prices
// Retrieve live prices
const { data: livePriceData } =
await wrappedOraclePrimaryProd.populateTransaction.getLivePricesAndTimestamp(
await wrappedOracle.populateTransaction.getLivePricesAndTimestamp(
dataFeedIdsBytes32
);
const txCalldataBytes = arrayify(String(livePriceData));
Expand Down Expand Up @@ -135,12 +135,11 @@ Web3Function.onRun(async (context: Web3FunctionContext) => {
}
debugLog(getDashLine());

// Get stored prices and timestamps from the blockchain
// Retrieve stored prices and timestamps from the blockchain
for (const dataFeed of dataFeedIds.values()) {
[dataFeed.storedTimestamp, , dataFeed.storedPrice] =
await wrappedOraclePrimaryProd
.getLastUpdateDetails(dataFeed.id)
.catch(() => [BigNumber.from(0), 0, 0]);
[dataFeed.storedTimestamp, , dataFeed.storedPrice] = await wrappedOracle
.getLastUpdateDetails(dataFeed.id)
.catch(() => [BigNumber.from(0), 0, 0]);
}
// And print them out
debugLog("Stored prices and timestamps:");
Expand Down Expand Up @@ -191,7 +190,7 @@ Web3Function.onRun(async (context: Web3FunctionContext) => {
// Craft transaction to update the price on-chain
console.log("Updating price feeds...");
const { data: updateDataFeedsPartialData } =
await wrappedOraclePrimaryProd.populateTransaction.updateDataFeedsValuesPartial(
await wrappedOracle.populateTransaction.updateDataFeedsValuesPartial(
priceFeedIdsToUpdate
);
console.log(`Data received: ${updateDataFeedsPartialData}`);
Expand Down

0 comments on commit 3d3fef6

Please sign in to comment.