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

Added chainspace method based on working-score #30

Merged
merged 3 commits into from
Feb 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 18 additions & 4 deletions schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,21 @@ type Schema @entity {
schema_id: String
}

type ChainSpace @entity {
id: ID!

callIndex: String
method: String
blockNumber: BigInt
submitter: String
signature: String
chainspace_id: String
authorization: String
space_code: String
space_id: String
delegate: String
}

type SetIdentity @entity {
id: ID!

Expand All @@ -188,10 +203,9 @@ type SetIdentity @entity {
web: String
email: String
additional: String

}

type ProvidedJudgement @entity{
type ProvidedJudgement @entity {
id: ID!

method: String
Expand All @@ -203,7 +217,7 @@ type ProvidedJudgement @entity{
digest: String
}

type JudgementRequest @entity{
type JudgementRequest @entity {
id: ID!

method: String
Expand All @@ -224,4 +238,4 @@ type DidName @entity {

did: String
name: String
}
}
7 changes: 7 additions & 0 deletions src/handlers/call.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { indexAssetCall } from "./asset";
import { indexIdentityCall } from "./identity";
import { handleDidNameCall } from "./didName";
import { createSchema } from "./schema";
import { createChainSpace } from "./chainSpace";

async function traverExtrinsic(
extrinsic: Extrinsic,
Expand Down Expand Up @@ -88,10 +89,16 @@ async function traverExtrinsic(
await createSchema(raw, call, id as string, data.method);
}

if (call.section === "chainSpace") {
logger.info("ChainSpace call");
await createChainSpace(raw, call, id as string, data.method);
}

if (call.section === "identity") {
logger.info(`${data.method}`);
await indexIdentityCall(raw, id as string, data.method);
}

if (call.section === "didName") {
logger.info(`${data.method}`);
await handleDidNameCall(raw, id as string, data.method);
Expand Down
76 changes: 76 additions & 0 deletions src/handlers/chainSpace.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
import { SubstrateExtrinsic } from "@subql/types";
import { ChainSpace, Call } from "../types";

export async function createChainSpace(
extrinsic: SubstrateExtrinsic,
call: Call,
id: string,
method: string
): Promise<void> {
const data = extrinsic.extrinsic.method;

let arrayed = JSON.parse(JSON.stringify(data));
let chainSpaceId = JSON.parse(JSON.stringify(extrinsic.events))[0].event
.data[0];
let chainspace = new ChainSpace(id);

chainspace.method = method;
chainspace.callIndex = arrayed.args.did_call.call.callIndex;
chainspace.chainspace_id = chainSpaceId;
chainspace.blockNumber = extrinsic.block.block.header.number.toBigInt();
chainspace.signature = JSON.stringify(arrayed.args.signature);

if (method === "create") {
chainspace.space_code = arrayed.args.did_call.call.args.space_code;
}

if (method === "addDelegate") {
chainspace.space_id = arrayed.args.did_call.call.args.space_id;
chainspace.delegate = arrayed.args.did_call.call.args.delegate;
chainspace.authorization = arrayed.args.did_call.call.args.authorization;
chainspace.submitter = arrayed.args.did_call.submitter;
}

if (method === "approve") {
// ToDo:
// Develop a demo script within the GitHub repository at github.com/dhiway/cord.js which
// calls this method. Execute the script to capture the extrinsic information, analyze the obtained data,
// and complete the implementation.
}

if (method === "archive") {
// ToDo:
// Develop a demo script within the GitHub repository at github.com/dhiway/cord.js which
// calls this method. Execute the script to capture the extrinsic information, analyze the obtained data,
// and complete the implementation.
}

if (method === "restore") {
// ToDo:
// Develop a demo script within the GitHub repository at github.com/dhiway/cord.js which
// calls this method. Execute the script to capture the extrinsic information, analyze the obtained data,
// and complete the implementation.
}

if (method === "addAdminDelegate") {
// ToDo:
// Develop a demo script within the GitHub repository at github.com/dhiway/cord.js which
// calls this method. Execute the script to capture the extrinsic information, analyze the obtained data,
// and complete the implementation.
}

if (method === "addAuditDelegate") {
// ToDo:
// Develop a demo script within the GitHub repository at github.com/dhiway/cord.js which
// calls this method. Execute the script to capture the extrinsic information, analyze the obtained data,
// and complete the implementation.
}

if (method === "removeDelegate") {
// ToDo:
// Develop a demo script within the GitHub repository at github.com/dhiway/cord.js which
// calls this method. Execute the script to capture the extrinsic information, analyze the obtained data,
// and complete the implementation.
}
await chainspace.save();
}