File tree Expand file tree Collapse file tree 10 files changed +755
-1463
lines changed 
protocols/ethereum/scaffold Expand file tree Collapse file tree 10 files changed +755
-1463
lines changed Original file line number Diff line number Diff line change 1+ --- 
2+ ' @graphprotocol/graph-cli '  : patch 
3+ --- 
4+ 
5+ fix generated example entity id uniqueness
Original file line number Diff line number Diff line change @@ -8,3 +8,4 @@ packages/cli/tests/cli/add
88packages /cli /config /TheGraphNetworksRegistry.json 
99pnpm-lock.yaml 
1010website /src /graphql-env.d.ts 
11+ renovate.json 
Original file line number Diff line number Diff line change 2323    "lint:fix" : " pnpm lint:prettier:fix && pnpm lint:eslint:fix"  ,
2424    "lint:prettier" : " prettier -c ."  ,
2525    "lint:prettier:fix" : " prettier . --write"  ,
26+     "lint:renovate" : " npx --yes --package renovate -- renovate-config-validator"  ,
2627    "release" : " pnpm build && changeset publish"  ,
2728    "test:cli" : " pnpm --filter @graphprotocol/graph-cli test"  ,
2829    "test:ts" : " pnpm --filter @graphprotocol/graph-ts test"  ,
3233    "@changesets/changelog-github" : " ^0.5.0"  ,
3334    "@changesets/cli" : " ^2.27.10"  ,
3435    "@eslint/js" : " ^9.16.0"  ,
35-     "@theguild/eslint-config" : " 0.13.1 "  ,
36+     "@theguild/eslint-config" : " 0.13.2 "  ,
3637    "@theguild/prettier-config" : " 3.0.0"  ,
3738    "@types/node" : " ^22.10.1"  ,
3839    "eslint" : " 9.16.0"  ,
Original file line number Diff line number Diff line change 3939    "@whatwg-node/fetch" : " ^0.10.1"  ,
4040    "assemblyscript" : " 0.27.31"  ,
4141    "binary-install" : " ^1.1.0"  ,
42-     "chalk" : " 5.3.0"  ,
4342    "chokidar" : " 4.0.1"  ,
4443    "debug" : " 4.3.7"  ,
4544    "docker-compose" : " 1.1.0"  ,
5251    "js-yaml" : " 4.1.0"  ,
5352    "kubo-rpc-client" : " ^5.0.2"  ,
5453    "open" : " 10.1.0"  ,
55-     "prettier" : " 3.4.2"  ,
5654    "semver" : " 7.6.3"  ,
5755    "tmp-promise" : " 3.0.3"  ,
5856    "web3-eth-abi" : " 4.4.1"  ,
59-     "which" : " 5.0.0"  ,
6057    "yaml" : " 2.6.1" 
6158  },
6259  "devDependencies" : {
Original file line number Diff line number Diff line change 11import  crypto  from  'node:crypto' ; 
22import  path  from  'node:path' ; 
3- import  chalk  from  'chalk' ; 
43import  fs  from  'fs-extra' ; 
54import  *  as  toolbox  from  'gluegun' ; 
65import  immutable  from  'immutable' ; 
@@ -138,7 +137,7 @@ export default class Compiler {
138137
139138  completed ( ipfsHashOrPath : string )  { 
140139    toolbox . print . info ( '' ) ; 
141-     toolbox . print . success ( `Build completed: ${ chalk . blue ( ipfsHashOrPath ) }  ` ) ; 
140+     toolbox . print . success ( `Build completed: ${ toolbox . print . colors . blue ( ipfsHashOrPath ) }  ` ) ; 
142141    toolbox . print . info ( '' ) ; 
143142  } 
144143
Original file line number Diff line number Diff line change @@ -11,7 +11,7 @@ export const generatePlaceholderHandlers = ({
1111  contractName : string ; 
1212} )  => 
1313  ` 
14-   import { BigInt } from '@graphprotocol/graph-ts' 
14+   import { BigInt, Bytes  } from '@graphprotocol/graph-ts' 
1515  import { ${ contractName }  , ${ events . map ( event  =>  event . _alias ) }   } 
1616    from '../generated/${ contractName }  /${ contractName }  ' 
1717  import { ExampleEntity } from '../generated/schema' 
@@ -21,14 +21,15 @@ export const generatePlaceholderHandlers = ({
2121      index  ===  0  
2222        ? `  
2323    export function handle${ event . _alias }  (event: ${ event . _alias }  ): void { 
24-       // Entities can be loaded from the store using a string  ID; this ID 
24+       // Entities can be loaded from the store using an  ID; this ID 
2525      // needs to be unique across all entities of the same type 
26-       let entity = ExampleEntity.load(event.transaction.from) 
26+       const id = event.transaction.hash.concat(Bytes.fromByteArray(Bytes.fromBigInt(event.logIndex))); 
27+       let entity = ExampleEntity.load(id) 
2728
2829      // Entities only exist after they have been saved to the store; 
2930      // \`null\` checks allow to create entities on demand 
3031      if (!entity) { 
31-         entity = new ExampleEntity(event.transaction.from ) 
32+         entity = new ExampleEntity(id ) 
3233
3334        // Entity fields can be set using simple assignments 
3435        entity.count = BigInt.fromI32(0) 
Original file line number Diff line number Diff line change @@ -34,7 +34,7 @@ dataSources:
3434`  ;
3535
3636exports [` Ethereum subgraph scaffolding > Mapping (default) 1`  ] =  ` 
37- "import {  BigInt  }  from "@graphprotocol/graph-ts" 
37+ "import {  BigInt ,  Bytes  }  from "@graphprotocol/graph-ts" 
3838import {  
3939  Contract , 
4040  ExampleEvent , 
@@ -43,14 +43,17 @@ import {
4343import {  ExampleEntity  }  from "../generated/schema" 
4444
4545export function handleExampleEvent(event: ExampleEvent): void {  
46-   //  Entities can be loaded from the store using a string  ID; this ID 
46+   //  Entities can be loaded from the store using an  ID; this ID 
4747  //  needs to be unique across all entities of the same type 
48-   let  entity  =  ExampleEntity .load (event .transaction .from ) 
48+   const  id  =  event .transaction .hash .concat ( 
49+     Bytes .fromByteArray (Bytes .fromBigInt (event .logIndex )) 
50+   ) 
51+   let  entity  =  ExampleEntity .load (id ) 
4952
5053  //  Entities only exist after they have been saved to the store; 
5154  //  \`null\` checks allow to create entities on demand 
5255  if  (! entity ) { 
53-     entity = new ExampleEntity(event . transaction . from ) 
56+     entity = new ExampleEntity(id ) 
5457
5558    //  Entity fields can be set using simple assignments 
5659    entity.count = BigInt.fromI32(0) 
    
 
   
 
     
   
   
          
     
  
    
     
 
    
      
     
 
     
    You can’t perform that action at this time.
  
 
    
  
     
    
      
        
     
 
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments