Skip to content

Commit

Permalink
get subgraph sellers from cli view-sellers
Browse files Browse the repository at this point in the history
  • Loading branch information
levalleux-ludo committed Sep 23, 2024
1 parent 93b20e3 commit 7a38e0e
Showing 1 changed file with 21 additions and 2 deletions.
23 changes: 21 additions & 2 deletions scripts/view-sellers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,14 @@ import {
} from "@bosonprotocol/common/src/types/configs";
import { providers, Contract } from "ethers";
import { abis } from "@bosonprotocol/common";
import { extractSellerData } from "./utils/account";
import { extractSellerData, SellerData } from "./utils/account";
import { getEnvConfigById } from "@bosonprotocol/common/src/configs";
import { EthersAdapter } from "../packages/ethers-sdk/src";
import { CoreSDK } from "../packages/core-sdk/src";

async function main() {
const envName: EnvironmentType = "staging";
const configId: ConfigId = "staging-80002-0";
const configId: ConfigId = "staging-11155111-0";
const defaultConfig = getEnvConfigById(envName, configId);
const web3Provider = new providers.JsonRpcProvider(defaultConfig.jsonRpcUrl);

Expand All @@ -21,14 +23,31 @@ async function main() {
);
console.log("environment: " + envName);
const lastSellerId = 100;
const sellerDatas: SellerData[] = [];
for (let i = 1; i < lastSellerId; i++) {
const sellerDataRaw = await accountHandler.getSeller(i);
if (!sellerDataRaw.exists) {
continue;
}
const sellerData = extractSellerData(sellerDataRaw);
sellerDatas.push(sellerData);
console.log(`${i} - current Seller data`, JSON.stringify(sellerData));
}
const coreSDK = CoreSDK.fromDefaultConfig({
web3Lib: new EthersAdapter(
new providers.JsonRpcProvider(defaultConfig.jsonRpcUrl)
),
envName,
configId
});
for (const sellerData of sellerDatas) {
try {
const seller = await coreSDK.getSellerById(sellerData.seller.id);
console.log(`${JSON.stringify(seller)}`);
} catch (e) {
console.error(e);
}
}
}

main()
Expand Down

0 comments on commit 7a38e0e

Please sign in to comment.