-
Notifications
You must be signed in to change notification settings - Fork 4
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
base: main
Are you sure you want to change the base?
Conversation
# 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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
開発優先のため一旦コメントアウト、、、
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"); | ||
} |
There was a problem hiding this comment.
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を実行する時点で発行できるか試験する。
import { Executed } from "../generated/BigBang/BigBang"; | ||
import { |
There was a problem hiding this comment.
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)
Issue
#233
Description
#242
の続きです!
Fixes # (issue)
Type of change
Please delete options that are not relevant.
Screenshots
If applicable, add screenshots to help explain your problem.