Skip to content

Commit

Permalink
feat: support indexer returning bigint (#1055)
Browse files Browse the repository at this point in the history
* feat: support indexer returning bigint

* up
  • Loading branch information
shamsartem authored Sep 23, 2024
1 parent 54ba2ea commit c71d0ba
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 28 deletions.
2 changes: 1 addition & 1 deletion cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
"@fluencelabs/air-beautify-wasm": "0.3.9",
"@fluencelabs/aqua-api": "0.14.10",
"@fluencelabs/aqua-to-js": "0.3.13",
"@fluencelabs/deal-ts-clients": "0.19.6",
"@fluencelabs/deal-ts-clients": "0.20.0",
"@fluencelabs/fluence-network-environment": "1.2.3",
"@fluencelabs/js-client": "0.9.0",
"@fluencelabs/npm-aqua-compiler": "0.0.3",
Expand Down
16 changes: 8 additions & 8 deletions cli/src/lib/chain/commitment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ import {
peerIdHexStringToBase58String,
peerIdBase58ToUint8Array,
} from "./conversions.js";
import { fltFormatWithSymbol, fltParse } from "./currencies.js";
import { fltFormatWithSymbol } from "./currencies.js";

const HUNDRED_PERCENT = 100;

Expand Down Expand Up @@ -780,7 +780,7 @@ export async function getCommitmentInfoString(
const { ethers } = await import("ethers");

const staker =
ccInfo.delegator ?? ccInfo.ccFromExplorer?.delegatorAddress ?? undefined;
ccInfo.delegator ?? ccInfo.ccFromExplorer?.stakerAddress ?? undefined;

const startEndCurrentEpoch =
ccInfo.startEpoch === undefined || ccInfo.endEpoch === undefined
Expand Down Expand Up @@ -821,7 +821,7 @@ export async function getCommitmentInfoString(
? {}
: {
"Total CC rewards over time": await fltFormatWithSymbol(
await fltParse(ccInfo.ccFromExplorer.rewards.total),
ccInfo.ccFromExplorer.rewards.total,
),
"In vesting / Available / Total claimed (Provider)": (
await Promise.all(
Expand All @@ -830,18 +830,18 @@ export async function getCommitmentInfoString(
ccInfo.ccFromExplorer.rewards.provider.availableToClaim,
ccInfo.ccFromExplorer.rewards.provider.claimed,
].map((val) => {
return fltFormatWithSymbol(BigInt(val));
return fltFormatWithSymbol(val);
}),
)
).join(" / "),
"In vesting / Available / Total claimed (Staker)": (
await Promise.all(
[
ccInfo.ccFromExplorer.rewards.delegator.inVesting,
ccInfo.ccFromExplorer.rewards.delegator.availableToClaim,
ccInfo.ccFromExplorer.rewards.delegator.claimed,
ccInfo.ccFromExplorer.rewards.staker.inVesting,
ccInfo.ccFromExplorer.rewards.staker.availableToClaim,
ccInfo.ccFromExplorer.rewards.staker.claimed,
].map((val) => {
return fltFormatWithSymbol(BigInt(val));
return fltFormatWithSymbol(val);
}),
)
).join(" / "),
Expand Down
9 changes: 3 additions & 6 deletions cli/src/lib/chain/offer/offer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ import {
import {
ALL_FLAG_VALUE,
CLI_NAME,
PT_SYMBOL,
OFFER_FLAG_NAME,
OFFER_IDS_FLAG_NAME,
PROVIDER_ARTIFACTS_CONFIG_FULL_FILE_NAME,
Expand Down Expand Up @@ -65,7 +64,7 @@ import {
peerIdHexStringToBase58String,
peerIdBase58ToUint8Array,
} from "../conversions.js";
import { ptParse } from "../currencies.js";
import { ptFormat, ptParse } from "../currencies.js";
import { assertProviderIsRegistered } from "../providerInfo.js";

const MARKET_OFFER_REGISTERED_EVENT_NAME = "MarketOfferRegistered";
Expand Down Expand Up @@ -465,7 +464,7 @@ async function formatOfferInfo(
"Last Updated At": new Date(
offerIndexerInfo.updatedAt * 1000,
).toISOString(),
"Price Per Epoch": `${offerIndexerInfo.pricePerEpoch} ${PT_SYMBOL}`,
"Price Per Epoch": await ptFormat(offerIndexerInfo.pricePerEpoch),
Effectors: await Promise.all(
offerIndexerInfo.effectors.map(({ cid }) => {
return cid;
Expand Down Expand Up @@ -543,9 +542,7 @@ export async function resolveOffersFromProviderConfig(
offerInfos.map(async ({ offerId, offerIndexerInfo }) => {
return {
offerName: `Offer ${offerId}`,
minPricePerCuPerEpochBigInt: await ptParse(
offerIndexerInfo.pricePerEpoch,
),
minPricePerCuPerEpochBigInt: offerIndexerInfo.pricePerEpoch,
effectorPrefixesAndHash: await Promise.all(
offerIndexerInfo.effectors.map(({ cid }) => {
return cidStringToCIDV1Struct(cid);
Expand Down
8 changes: 3 additions & 5 deletions cli/src/lib/chain/offer/updateOffers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ import { initNewProviderArtifactsConfig } from "../../configs/project/providerAr
import {
CLI_NAME,
PROVIDER_ARTIFACTS_CONFIG_FULL_FILE_NAME,
PT_SYMBOL,
} from "../../const.js";
import { getDealClient, signBatch, populateTx } from "../../dealClient.js";
import { numToStr } from "../../helpers/typesafeStringify.js";
Expand All @@ -35,7 +34,7 @@ import {
cidStringToCIDV1Struct,
peerIdHexStringToBase58String,
} from "../conversions.js";
import { ptParse, ptFormatWithSymbol } from "../currencies.js";
import { ptFormatWithSymbol } from "../currencies.js";
import { assertProviderIsRegistered } from "../providerInfo.js";

import {
Expand Down Expand Up @@ -346,13 +345,12 @@ async function populateMinPricePerCuPerEpochTx({
}: OnChainOffer) {
const { dealClient } = await getDealClient();
const market = dealClient.getMarket();
return (await ptParse(offerIndexerInfo.pricePerEpoch)) ===
minPricePerCuPerEpochBigInt
return offerIndexerInfo.pricePerEpoch === minPricePerCuPerEpochBigInt
? []
: [
{
description: `\nchanging minPricePerCuPerEpoch from ${color.yellow(
`${offerIndexerInfo.pricePerEpoch} ${PT_SYMBOL}`,
await ptFormatWithSymbol(offerIndexerInfo.pricePerEpoch),
)} to ${color.yellow(
await ptFormatWithSymbol(minPricePerCuPerEpochBigInt),
)}`,
Expand Down
6 changes: 3 additions & 3 deletions cli/src/versions.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{
"protocolVersion": 1,
"nox": "fluencelabs/nox:0.26.1",
"chain-rpc": "fluencelabs/chain-rpc:0.19.6",
"chain-deploy-script": "fluencelabs/chain-deploy-script:0.19.6",
"subgraph-deploy-script": "fluencelabs/subgraph-deploy-script:0.19.6",
"chain-rpc": "fluencelabs/chain-rpc:0.20.0",
"chain-deploy-script": "fluencelabs/chain-deploy-script:0.20.0",
"subgraph-deploy-script": "fluencelabs/subgraph-deploy-script:0.20.0",
"rust-toolchain": "nightly-2024-06-10",
"npm": {
"@fluencelabs/aqua-lib": "0.11.0",
Expand Down
10 changes: 5 additions & 5 deletions cli/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -436,7 +436,7 @@ __metadata:
"@fluencelabs/air-beautify-wasm": "npm:0.3.9"
"@fluencelabs/aqua-api": "npm:0.14.10"
"@fluencelabs/aqua-to-js": "npm:0.3.13"
"@fluencelabs/deal-ts-clients": "npm:0.19.6"
"@fluencelabs/deal-ts-clients": "npm:0.20.0"
"@fluencelabs/fluence-network-environment": "npm:1.2.3"
"@fluencelabs/js-client": "npm:0.9.0"
"@fluencelabs/npm-aqua-compiler": "npm:0.0.3"
Expand Down Expand Up @@ -510,9 +510,9 @@ __metadata:
languageName: unknown
linkType: soft

"@fluencelabs/deal-ts-clients@npm:0.19.6":
version: 0.19.6
resolution: "@fluencelabs/deal-ts-clients@npm:0.19.6"
"@fluencelabs/deal-ts-clients@npm:0.20.0":
version: 0.20.0
resolution: "@fluencelabs/deal-ts-clients@npm:0.20.0"
dependencies:
"@graphql-typed-document-node/core": "npm:^3.2.0"
debug: "npm:^4.3.4"
Expand All @@ -524,7 +524,7 @@ __metadata:
graphql-tag: "npm:^2.12.6"
ipfs-http-client: "npm:^60.0.1"
multiformats: "npm:^13.0.1"
checksum: 10c0/21a140ee5c0c7dbd006dcb775930db22d096de5b38304948a093cb3f74373dcb184822cc607bee8f7894edec3d469f0425f53a3c4e5f89981aa586619a3be908
checksum: 10c0/a652bd87b0508d8b7a7282938c1b441ebfc27be11b05f6079d3f80f607ff5ade769ee8713a88b573f8a9884393b2ce25f1e7fb3429c5aabfd4351dcf981d8d61
languageName: node
linkType: hard

Expand Down

0 comments on commit c71d0ba

Please sign in to comment.