-
Notifications
You must be signed in to change notification settings - Fork 46
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Error in Running the subgraph locally #836
Comments
@expandboard do you get any error when running this command? cd subgraph
pnpm asc src/BoldToken.mapping.ts |
Thanks @bpierre . i ran and got this:
do you use Mac or Linux? |
@expandboard I am using Linux. This is weird, Could you please paste your |
@bpierre the new run is same error. I tried to run pnpm install in root, contract and subgraph directories. asc package can not be find too. i used a new linux image. import { Address, BigInt, DataSourceContext } from "@graphprotocol/graph-ts";
import {
CollateralRegistryAddressChanged as CollateralRegistryAddressChangedEvent,
} from "../generated/BoldToken/BoldToken";
import { BorrowerOperations as BorrowerOperationsContract } from "../generated/BoldToken/BorrowerOperations";
import { CollateralRegistry as CollateralRegistryContract } from "../generated/BoldToken/CollateralRegistry";
import { ERC20 as ERC20Contract } from "../generated/BoldToken/ERC20";
import { TroveManager as TroveManagerContract } from "../generated/BoldToken/TroveManager";
import { Collateral, CollateralAddresses, StabilityPoolEpochScale, Token } from "../generated/schema";
import {
StabilityPool as StabilityPoolTemplate,
TroveManager as TroveManagerTemplate,
TroveNFT as TroveNFTTemplate,
} from "../generated/templates";
function addCollateral(
collIndex: i32,
totalCollaterals: i32,
tokenAddress: Address,
troveManagerAddress: Address,
): void {
let collId = collIndex.toString();
let collateral = new Collateral(collId);
collateral.collIndex = collIndex;
collateral.token = collId;
let token = new Token(collId);
let tokenContract = ERC20Contract.bind(tokenAddress);
token.collateral = collId;
token.name = tokenContract.name();
token.symbol = tokenContract.symbol();
token.decimals = tokenContract.decimals();
let troveManagerContract = TroveManagerContract.bind(troveManagerAddress);
let addresses = new CollateralAddresses(collId);
addresses.collateral = collId;
addresses.borrowerOperations = troveManagerContract.borrowerOperations();
addresses.sortedTroves = troveManagerContract.sortedTroves();
addresses.stabilityPool = troveManagerContract.stabilityPool();
addresses.token = tokenAddress;
addresses.troveManager = troveManagerAddress;
addresses.troveNft = troveManagerContract.troveNFT();
collateral.minCollRatio = BorrowerOperationsContract.bind(
Address.fromBytes(addresses.borrowerOperations),
).MCR();
// initial collId + epoch + scale => S
let spEpochScale = new StabilityPoolEpochScale(collId + ":0:0");
spEpochScale.B = BigInt.fromI32(0);
spEpochScale.S = BigInt.fromI32(0);
collateral.save();
token.save();
addresses.save();
spEpochScale.save();
let context = new DataSourceContext();
context.setBytes("address:borrowerOperations", addresses.borrowerOperations);
context.setBytes("address:sortedTroves", addresses.sortedTroves);
context.setBytes("address:stabilityPool", addresses.stabilityPool);
context.setBytes("address:token", addresses.token);
context.setBytes("address:troveManager", addresses.troveManager);
context.setBytes("address:troveNft", addresses.troveNft);
context.setString("collId", collId);
context.setI32("collIndex", collIndex);
context.setI32("totalCollaterals", totalCollaterals);
TroveManagerTemplate.createWithContext(troveManagerAddress, context);
TroveNFTTemplate.createWithContext(Address.fromBytes(addresses.troveNft), context);
StabilityPoolTemplate.createWithContext(Address.fromBytes(addresses.stabilityPool), context);
}
export function handleCollateralRegistryAddressChanged(event: CollateralRegistryAddressChangedEvent): void {
let registry = CollateralRegistryContract.bind(event.params._newCollateralRegistryAddress);
let totalCollaterals = registry.totalCollaterals().toI32();
for (let index = 0; index < totalCollaterals; index++) {
let tokenAddress = Address.fromBytes(registry.getToken(BigInt.fromI32(index)));
let troveManagerAddress = Address.fromBytes(registry.getTroveManager(BigInt.fromI32(index)));
if (tokenAddress.toHex() === Address.zero().toHex() || troveManagerAddress.toHex() === Address.zero().toHex()) {
break;
}
// we use the token address as the id for the collateral
if (!Collateral.load(tokenAddress.toHexString())) {
addCollateral(
index,
totalCollaterals,
tokenAddress,
troveManagerAddress,
);
}
}
} |
@expandboard Could you please try to run this in the subgraph/ directory? pnpm why assemblyscript --long |
This error be arisen when the subgraph is ran locally
1. Run anvil
anvil --host 0.0.0.0 --gas-limit 100000000000 --base-fee 1
2. Deploy the contracts
cd contracts
./deploy local
3. Run the graph node
cd subgraph
./start-graph
4. Deploy the subgraph
cd subgraph
./deploy-subgraph local --version v1 --create
Hardware
The text was updated successfully, but these errors were encountered: