-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Adi Bhagavath <[email protected]>
- Loading branch information
Showing
5 changed files
with
203 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
{ | ||
"workbench.colorCustomizations": { | ||
"activityBar.activeBackground": "#ffb733", | ||
"activityBar.background": "#ffb733", | ||
"activityBar.foreground": "#15202b", | ||
"activityBar.inactiveForeground": "#15202b99", | ||
"activityBarBadge.background": "#008053", | ||
"activityBarBadge.foreground": "#e7e7e7", | ||
"commandCenter.border": "#15202b99", | ||
"sash.hoverBorder": "#ffb733", | ||
"statusBar.background": "#ffa500", | ||
"statusBar.foreground": "#15202b", | ||
"statusBarItem.hoverBackground": "#cc8400", | ||
"statusBarItem.remoteBackground": "#ffa500", | ||
"statusBarItem.remoteForeground": "#15202b", | ||
"titleBar.activeBackground": "#ffa500", | ||
"titleBar.activeForeground": "#15202b", | ||
"titleBar.inactiveBackground": "#ffa50099", | ||
"titleBar.inactiveForeground": "#15202b99" | ||
}, | ||
"peacock.color": "orange" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
import { SubstrateExtrinsic } from "@subql/types"; | ||
import { Did, DidSubmitCall } from "../types"; | ||
|
||
export async function indexDidCall( | ||
extrinsic: SubstrateExtrinsic, | ||
id: string, | ||
method: string | ||
): Promise<void> { | ||
const data = extrinsic.extrinsic.method; | ||
|
||
if (method === "create") { | ||
let arrayed = JSON.parse(JSON.stringify(data)); | ||
let serviceDetailsFromChain = arrayed.args.details.newServiceDetails; | ||
let serviceDetails: string[] = []; | ||
|
||
await serviceDetailsFromChain.forEach((item: any) => { | ||
let serviceDetail = { | ||
id: item.id, | ||
serviceTypes: item.serviceTypes, | ||
urls: item.urls, | ||
}; | ||
|
||
serviceDetails.push(JSON.stringify(serviceDetail)); | ||
}); | ||
|
||
let did = new Did(id); | ||
did.method = method; | ||
did.blockNumber = extrinsic.block.block.header.number.toBigInt(); | ||
did.identifier = arrayed.args.details.did; | ||
did.submitter = arrayed.args.details.submitter; | ||
did.signature = JSON.stringify(arrayed.args.signature); | ||
|
||
did.keyAgreementKeys = JSON.stringify( | ||
arrayed.args.details.newKeyAgreementKeys | ||
); | ||
did.assertionKey = JSON.stringify(arrayed.args.details.newAssertionKey); | ||
did.delegationKey = JSON.stringify(arrayed.args.details.newDelegationKey); | ||
did.serviceDetails = serviceDetails; | ||
await did.save(); | ||
} | ||
if (method === "update") { | ||
// 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 === "delete") { | ||
// 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 === "submitDidCall") { | ||
let arrayed = JSON.parse(JSON.stringify(data)); | ||
let didSubmitCall = new DidSubmitCall(id); | ||
didSubmitCall.blockNumber = extrinsic.block.block.header.number.toBigInt(); | ||
didSubmitCall.didUri = arrayed.args.did_call.did; | ||
didSubmitCall.callIndex = arrayed.args.did_call.call.callIndex; | ||
didSubmitCall.txCounter = arrayed.args.did_call.txCounter; | ||
didSubmitCall.submitter = arrayed.args.did_call.submitter; | ||
didSubmitCall.signature = JSON.stringify(arrayed.args.signature); | ||
await didSubmitCall.save(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
import { SubstrateExtrinsic } from "@subql/types"; | ||
import { Statement } from "../types"; | ||
|
||
export async function createStatement( | ||
extrinsic: SubstrateExtrinsic, | ||
id: string, | ||
method: string | ||
): Promise<void> { | ||
const data = extrinsic.extrinsic.method; | ||
let arrayed = JSON.parse(JSON.stringify(data)); | ||
if (method === "register") { | ||
let arrayed = JSON.parse(JSON.stringify(data)); | ||
let statementId = JSON.parse(JSON.stringify(extrinsic.events))[0].event | ||
.data[0]; | ||
let statement = new Statement(id); | ||
statement.method = method; | ||
statement.callIndex = arrayed.args.did_call.call.callIndex | ||
statement.blockNumber = extrinsic.block.block.header.number.toBigInt(); | ||
statement.submitter = arrayed.args.did_call.submitter; | ||
statement.signature = JSON.stringify(arrayed.args.signature); | ||
statement.statement_id = statementId; | ||
statement.authorization = arrayed.args.did_call.call.args.authorization; | ||
statement.schema_id = arrayed.args.did_call.call.args.schema_id; | ||
statement.digest = arrayed.args.did_call.call.args.digest; | ||
await statement.save(); | ||
} | ||
if (method === "update") { | ||
let arrayed = JSON.parse(JSON.stringify(data)); | ||
let statement = new Statement(id); | ||
statement.method = method; | ||
statement.callIndex = arrayed.args.did_call.call.callIndex | ||
statement.blockNumber = extrinsic.block.block.header.number.toBigInt(); | ||
statement.submitter = arrayed.args.did_call.submitter; | ||
statement.signature = JSON.stringify(arrayed.args.signature); | ||
statement.statement_id = arrayed.args.did_call.call.args.statement_id; | ||
statement.digest = arrayed.args.did_call.call.args.digest; | ||
statement.authorization = arrayed.args.did_call.call.args.authorization; | ||
await statement.save(); | ||
} | ||
if (method === "revoke") { | ||
let arrayed = JSON.parse(JSON.stringify(data)); | ||
let statement = new Statement(id); | ||
statement.method = method; | ||
statement.callIndex = arrayed.args.did_call.call.callIndex | ||
statement.blockNumber = extrinsic.block.block.header.number.toBigInt(); | ||
statement.submitter = arrayed.args.did_call.submitter; | ||
statement.signature = JSON.stringify(arrayed.args.signature); | ||
statement.statement_id = arrayed.args.did_call.call.args.statement_id; | ||
statement.authorization = arrayed.args.did_call.call.args.authorization; | ||
await statement.save(); | ||
} | ||
if (method === "restore") { | ||
let arrayed = JSON.parse(JSON.stringify(data)); | ||
let statement = new Statement(id); | ||
statement.method = method; | ||
statement.callIndex = arrayed.args.did_call.call.callIndex | ||
statement.blockNumber = extrinsic.block.block.header.number.toBigInt(); | ||
statement.submitter = arrayed.args.did_call.submitter; | ||
statement.signature = JSON.stringify(arrayed.args.signature); | ||
statement.statement_id = arrayed.args.did_call.call.args.statement_id; | ||
statement.authorization = arrayed.args.did_call.call.args.authorization; | ||
await statement.save(); | ||
} | ||
} |