Skip to content

Commit

Permalink
issue with db
Browse files Browse the repository at this point in the history
  • Loading branch information
Tbaut committed Apr 29, 2024
1 parent 3c73098 commit 78fca2a
Show file tree
Hide file tree
Showing 5 changed files with 122 additions and 3 deletions.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ package-lock.json
target/
dist/
src/types
project.yaml

# JetBrains IDE
.idea/
Expand Down
28 changes: 28 additions & 0 deletions polkadot.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,31 @@ dataSources:
filter:
module: proxy
method: AnonymousCreated
- handler: handleMultisigCall
kind: substrate/CallHandler
filter:
module: multisig
method: asMulti
success: true
isSigned: true
- handler: handleMultisigCall
kind: substrate/CallHandler
filter:
module: multisig
method: approveAsMulti
success: true
isSigned: true
- handler: handleMultisigCall
kind: substrate/CallHandler
filter:
module: multisig
method: cancelAsMulti
success: true
isSigned: true
- handler: handleMultisigCall
kind: substrate/CallHandler
filter:
module: multisig
method: asMultiThreshold1
success: true
isSigned: true
64 changes: 64 additions & 0 deletions project.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
specVersion: 1.0.0
name: subquery-spektr
version: 1.0.0
runner:
node:
name: "@subql/node"
version: "*"
query:
name: "@subql/query"
version: v1.5.0
description: Nova SubQuery project
repository: https://github.com/nova-wallet/subquery-proxy
schema:
file: ./schema.graphql
network:
chainId: "0x6408de7737c59c238890533af25896a2c20608d8b380bb01029acb392781063e"
endpoint: >-
wss://rococo-rpc.polkadot.io
dictionary: https://api.subquery.network/sq/subquery/rococo-dictionary
dataSources:
- name: main
kind: substrate/Runtime
startBlock: 3152590
mapping:
file: ./dist/index.js
handlers:
- handler: handleEvent
kind: substrate/EventHandler
filter:
module: proxy
method: PureCreated
- handler: handleEvent
kind: substrate/EventHandler
filter:
module: proxy
method: AnonymousCreated
- handler: handleMultisigCall
kind: substrate/CallHandler
filter:
module: multisig
method: asMulti
success: true
isSigned: true
- handler: handleMultisigCall
kind: substrate/CallHandler
filter:
module: multisig
method: approveAsMulti
success: true
isSigned: true
- handler: handleMultisigCall
kind: substrate/CallHandler
filter:
module: multisig
method: cancelAsMulti
success: true
isSigned: true
- handler: handleMultisigCall
kind: substrate/CallHandler
filter:
module: multisig
method: asMultiThreshold1
success: true
isSigned: true
20 changes: 20 additions & 0 deletions schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,23 @@ type PureProxy @entity {
blockNumber: Int!
extrinsicIndex: Int!
}

# An account can be a multisig, or a normal account (like a signatory)
type Account @entity {
id: ID!
address: String!
# if this account is the signatory on one or many multisigs, this will link to an array of multisigs
multisigs: [AccountMultisig] @derivedFrom(field: "signatory")
isMultisig: Boolean
# if this account is a multisig, this will link to an array of signatories
signatories: [AccountMultisig!] @derivedFrom(field: "multisig")
# this is only needed in the case of a multisig
threshold: Int
}

# entity for linking accounts and multisigs
type AccountMultisig @entity {
id: ID!
multisig: Account!
signatory: Account!
}
12 changes: 10 additions & 2 deletions src/mappings/mappingHandlers.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import assert from "assert";
import { SubstrateEvent } from "@subql/types";
import { SubstrateEvent, SubstrateExtrinsic } from "@subql/types";

import { PureProxy } from "../types";

Expand All @@ -26,3 +25,12 @@ function extrinsicIndex(event: SubstrateEvent): number {
function blockNumber(event: SubstrateEvent): number {
return event.block.block.header.number.toNumber();
}

export async function handleMultisigCall(
extrinsic: SubstrateExtrinsic
): Promise<void> {
console.log(extrinsic.block.toJSON());
// const record = new CallEntity(extrinsic.block.block.header.hash.toString());
// record.field4 = extrinsic.block.timestamp;
// await record.save();
}

0 comments on commit 78fca2a

Please sign in to comment.