Skip to content
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

Add function to get balance in mapping.ts #270

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

ikmzkro
Copy link
Collaborator

@ikmzkro ikmzkro commented Jan 18, 2025

Issue

#233

Description

#242
の続きです!

Fixes # (issue)

Type of change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

Screenshots

If applicable, add screenshots to help explain your problem.

Comment on lines +1 to +5
# pre-commit:
# commands:
# check:
# glob: "*.{js,ts,cjs,mjs,d.cts,d.mts,jsx,tsx,json,jsonc}"
# run: npx biome check --apply --no-errors-on-unmatched --files-ignore-unknown=true . && git update-index --again
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

開発優先のため一旦コメントアウト、、、

@ikmzkro ikmzkro changed the title Update lefthook.yaml for biome check command Add function to get balance in mapping.ts Jan 18, 2025
Comment on lines +83 to +99
export function getBalance(ev: TransferSingle): GraphBigInt {
const id =
ev.transaction.hash.toHex() +
ev.params.id.toHex() +
ev.params.from.toHex() +
ev.params.to.toHex();

const balance = new FractionTokenBalance(id);
balance.workspaceId = "";
balance.holderAddress = ev.params.from.toHex();
balance.hatId = GraphBigInt.fromString("0");
balance.wearer = "";
balance.tokenId = ev.params.id;
balance.balance = GraphBigInt.fromString("0");
balance.updatedAt = ev.block.timestamp;
return balance ? balance.balance : GraphBigInt.fromString("0");
}
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

スマコンからイベント発行されたものをキャッチして実行されるhookは /src/mapping.ts に書いていく。
TransferSingleを実行する時点で発行できるか試験する。

Comment on lines +2 to +3
import { Executed } from "../generated/BigBang/BigBang";
import {
Copy link
Collaborator Author

@ikmzkro ikmzkro Jan 18, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yarn buildがこけるのでtypeを削除する暫定対応。

ikmz@KoichirizunoMBP subgraph % yarn build
yarn run v1.22.19
$ graph build
  Skip migration: Bump mapping apiVersion from 0.0.1 to 0.0.2
  Skip migration: Bump mapping apiVersion from 0.0.2 to 0.0.3
  Skip migration: Bump mapping apiVersion from 0.0.3 to 0.0.4
  Skip migration: Bump mapping apiVersion from 0.0.4 to 0.0.5
  Skip migration: Bump mapping apiVersion from 0.0.5 to 0.0.6
  Skip migration: Bump manifest specVersion from 0.0.1 to 0.0.2
  Skip migration: Bump manifest specVersion from 0.0.2 to 0.0.4
✔ Apply migrations
✔ Load subgraph from subgraph.yaml
  Compile data source: BigBang => build/BigBang/BigBang.wasm
⠋ Compile subgraphERROR TS1005: 'from' expected.

 import type { Executed } from "../generated/BigBang/BigBang";
        ~~~~
 in src/mapping.ts(2,8)

ERROR TS1005: 'from' expected.

 import type {
        ~~~~
 in src/mapping.ts(3,8)

✖ Failed to compile subgraph: Failed to compile data source mapping: 2 parse error(s)
Error: Failed to compile data source mapping: 2 parse error(s)
    at Compiler._compileDataSourceMapping (/Users/ikmz/toban/node_modules/@graphprotocol/graph-cli/dist/compiler/index.js:297:19)
    at /Users/ikmz/toban/node_modules/@graphprotocol/graph-cli/dist/compiler/index.js:201:167
    at updateInDeeply (/Users/ikmz/toban/node_modules/immutable/dist/immutable.js:2121:22)
    at updateInDeeply (/Users/ikmz/toban/node_modules/immutable/dist/immutable.js:2134:23)
    at updateInDeeply (/Users/ikmz/toban/node_modules/immutable/dist/immutable.js:2134:23)
    at updateIn$1 (/Users/ikmz/toban/node_modules/immutable/dist/immutable.js:2099:24)
    at Map.updateIn (/Users/ikmz/toban/node_modules/immutable/dist/immutable.js:2180:12)
    at /Users/ikmz/toban/node_modules/@graphprotocol/graph-cli/dist/compiler/index.js:201:115
    at /Users/ikmz/toban/node_modules/immutable/dist/immutable.js:3321:30
    at List.withMutations (/Users/ikmz/toban/node_modules/immutable/dist/immutable.js:2367:5)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant