Skip to content

Commit

Permalink
Added chainspace method based on working-score (#30)
Browse files Browse the repository at this point in the history
* feat: Added chainspace method based on working-score

* chore: removed github actions
  • Loading branch information
ujjwal6792 authored Feb 5, 2024
1 parent fee816d commit 84832f8
Show file tree
Hide file tree
Showing 3 changed files with 101 additions and 4 deletions.
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();
}

0 comments on commit 84832f8

Please sign in to comment.