Skip to content

Commit

Permalink
Companion for 0.7.4 update (dhiway#20)
Browse files Browse the repository at this point in the history
* Companion for 0.7.4 update
* update dependencies
  • Loading branch information
smohan-dw authored Jul 15, 2022
1 parent 62b24b0 commit a1627e3
Show file tree
Hide file tree
Showing 23 changed files with 1,589 additions and 1,912 deletions.
5 changes: 2 additions & 3 deletions demo/src/demo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,14 +70,13 @@ async function main() {
employeeIdentity,
newSpace.identifier
)

let schemaCreationExtrinsic = await Cord.Schema.create(newSchema)

console.dir(newSchema, {
depth: null,
colors: true,
})

let schemaCreationExtrinsic = await Cord.Schema.create(newSchema)

try {
await Cord.Chain.signAndSubmitTx(schemaCreationExtrinsic, entityIdentity, {
resolveOn: Cord.Chain.IS_IN_BLOCK,
Expand Down
6 changes: 4 additions & 2 deletions jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module.exports = {
testEnvironment: 'node',
clearMocks: true,
runner: 'groups',
testTimeout: 10000,
testTimeout: 6000,
setupFilesAfterEnv: ['../testingTools/setup.js'],
transformIgnorePatterns:['/node_modules/(?!@polkadot|@babel/runtime/helpers/esm/)'],
coverageThreshold: {
Expand All @@ -22,11 +22,13 @@ module.exports = {
'!**/__tests__/**',
'!**/lib/**',
'!**/test/**',
'!**/cord/*',
'!**/cordconfig/*',
'!**/chainApiConnection/*',
'!**/types/**/*',
'!**/SDKErrors.ts',
'!utils/src/json-schema/*',
'!testing/**',
'!**/*.chain.ts',
],
resolver: "ts-jest-resolver",
rootDir: 'packages',
Expand Down
11 changes: 2 additions & 9 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,8 @@
"commit-msg": "commitlint -E HUSKY_GIT_PARAMS"
}
},
"commitlint": {
"extends": [
"@commitlint/config-conventional"
]
},
"devDependencies": {
"@commitlint/cli": "^9.0.1",
"@commitlint/config-conventional": "^9.0.1",
"@playwright/test": "^1.15.2",
"@types/jest": "^27.4.0",
"@typescript-eslint/eslint-plugin": "^5.7.0",
"@typescript-eslint/parser": "^5.7.0",
Expand All @@ -50,16 +44,15 @@
"eslint-plugin-import": "^2.25.3",
"eslint-plugin-jsdoc": "^37.2.0",
"eslint-plugin-license-header": "^0.2.1",
"eslint-plugin-node": "^11.1.0",
"eslint-plugin-prettier": "^4.0.0",
"husky": "^7.0.0",
"jest": "^27.4.7",
"jest-docblock": "^27.4.0",
"jest-runner": "^27.4.6",
"jest-runner-groups": "^2.1.0",
"moment": "^2.29.1",
"prettier": "^2.4.1",
"rimraf": "^3.0.2",
"testcontainers": "^8.6.1",
"ts-jest": "^27.1.2",
"ts-jest-resolver": "^2.0.0",
"tsx": "^3.4.3",
Expand Down
2 changes: 1 addition & 1 deletion packages/config/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
},
"dependencies": {
"@cord.network/utils": "workspace:*",
"@polkadot/api-augment": "^8.0.0",
"@polkadot/api-augment": "^8.12.0",
"typescript-logging": "^0.6.4"
}
}
4 changes: 2 additions & 2 deletions packages/messaging/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
"@cord.network/modules": "workspace:*",
"@cord.network/types": "workspace:*",
"@cord.network/utils": "workspace:*",
"@polkadot/api-augment": "^8.0.0",
"@polkadot/util": "^9.0.0"
"@polkadot/api-augment": "^8.12.0",
"@polkadot/util": "^10.0.0"
}
}
15 changes: 6 additions & 9 deletions packages/modules/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,11 @@
"@cord.network/network": "workspace:*",
"@cord.network/types": "workspace:*",
"@cord.network/utils": "workspace:*",
"@polkadot/api": "^8.0.0",
"@polkadot/api-augment": "^8.0.0",
"@polkadot/keyring": "^9.0.0",
"@polkadot/types": "^8.0.0",
"@polkadot/types-known": "^8.0.0",
"@polkadot/util": "^9.0.0",
"@polkadot/util-crypto": "^9.0.0",
"tweetnacl": "^1.0.3",
"typescript-logging": "^0.6.4"
"@polkadot/api": "^8.12.0",
"@polkadot/api-augment": "^8.12.0",
"@polkadot/keyring": "^10.0.0",
"@polkadot/types": "^8.12.0",
"@polkadot/util": "^10.0.0",
"tweetnacl": "^1.0.3"
}
}
51 changes: 28 additions & 23 deletions packages/modules/src/schema/Schema.chain.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,14 @@ const log = ConfigService.LoggingFactory.getLogger('Schema')
export async function create(schema: ISchema): Promise<SubmittableExtrinsic> {
const api = await ChainApiConnection.getConnectionOrConnect()
log.debug(() => `Create tx for 'schema'`)
return api.tx.schema.create(
schema.controller,
schema.schemaHash,
Identifier.getIdentifierKey(schema.space, SPACE_PREFIX),
schema.controllerSignature
)

const schemaParams = {
digest: schema.schemaHash,
author: schema.controller,
space: Identifier.getIdentifierKey(schema.space, SPACE_PREFIX),
}

return api.tx.schema.create(schemaParams, schema.controllerSignature)
}

/**
Expand All @@ -48,15 +50,17 @@ export async function revoke(

const api = await ChainApiConnection.getConnectionOrConnect()
log.debug(() => `Revoking a schema with ID ${schema.identifier}`)
const space = Identifier.getIdentifierKey(schema.space, SPACE_PREFIX) || null

return api.tx.schema.revoke(
controller,
Identifier.getIdentifierKey(schema.identifier, SCHEMA_PREFIX),
txHash,
space,
txSignature
)
const schemaParams = {
identifier: Identifier.getIdentifierKey(schema.identifier, SCHEMA_PREFIX),
schema: {
digest: txHash,
author: controller.address,
space: Identifier.getIdentifierKey(schema.space, SPACE_PREFIX) || null
}
}

return api.tx.schema.revoke(schemaParams, txSignature)
}

/**
Expand All @@ -71,16 +75,17 @@ export async function authorise(

const api = await ChainApiConnection.getConnectionOrConnect()
log.debug(() => `Adding a delagate to ${schema.identifier}`)
const space = Identifier.getIdentifierKey(schema.space, SPACE_PREFIX) || null

return api.tx.schema.authorise(
controller,
Identifier.getIdentifierKey(schema.identifier, SCHEMA_PREFIX),
txHash,
delegates,
space,
txSignature
)
const schemaParams = {
identifier: Identifier.getIdentifierKey(schema.identifier, SCHEMA_PREFIX),
schema: {
digest: txHash,
author: controller.address,
space: Identifier.getIdentifierKey(schema.space, SPACE_PREFIX) || null
}
}

return api.tx.schema.authorise(schemaParams, txSignature)
}

/**
Expand Down
4 changes: 2 additions & 2 deletions packages/modules/src/schema/Schema.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export const SchemaModel: JsonSchema.Schema = {
$id: {
type: 'string',
format: 'uri',
pattern: '^schema:cord:4[0-9a-zA-Z]+$',
pattern: '^schema:cord:5[0-9a-zA-Z]+$',
},
$schema: {
type: 'string',
Expand Down Expand Up @@ -83,7 +83,7 @@ export const SchemaWrapperModel = {
identifier: {
type: 'string',
format: 'uri',
pattern: '^schema:cord:4[0-9a-zA-Z]+$',
pattern: '^schema:cord:5[0-9a-zA-Z]+$',
},
schemaHash: {
type: 'string',
Expand Down
71 changes: 32 additions & 39 deletions packages/modules/src/space/Space.chain.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,8 @@ const log = ConfigService.LoggingFactory.getLogger('Schema')
export async function create(space: ISpace): Promise<SubmittableExtrinsic> {
const api = await ChainApiConnection.getConnectionOrConnect()
log.debug(() => `Create tx for 'space'`)
return api.tx.space.create(
space.controller,
space.spaceHash,
space.controllerSignature
)
const spaceParams = { digest: space.spaceHash, controller: space.controller }
return api.tx.space.create(spaceParams, space.controllerSignature)
}

/**
Expand All @@ -44,14 +41,13 @@ export async function archive(
controller: Identity
): Promise<SubmittableExtrinsic> {
const { txSignature, txHash } = controller.signTx(space.spaceHash)

const api = await ChainApiConnection.getConnectionOrConnect()
return api.tx.space.archive(
controller,
Identifier.getIdentifierKey(space.identifier, SPACE_PREFIX),
txHash,
txSignature
)
const spaceParams = {
identifier: Identifier.getIdentifierKey(space.identifier, SPACE_PREFIX),
digest: txHash,
controller: controller.address,
}
return api.tx.space.archive(spaceParams, txSignature)
}

/**
Expand All @@ -64,12 +60,12 @@ export async function restore(
const { txSignature, txHash } = controller.signTx(space.spaceHash)

const api = await ChainApiConnection.getConnectionOrConnect()
return api.tx.space.restore(
controller,
Identifier.getIdentifierKey(space.identifier, SPACE_PREFIX),
txHash,
txSignature
)
const spaceParams = {
identifier: Identifier.getIdentifierKey(space.identifier, SPACE_PREFIX),
digest: txHash,
controller: controller.address,
}
return api.tx.space.restore(spaceParams, txSignature)
}

/**
Expand All @@ -83,13 +79,12 @@ export async function authorise(
const { txSignature, txHash } = controller.signTx(space.spaceHash)

const api = await ChainApiConnection.getConnectionOrConnect()
return api.tx.space.authorise(
controller,
Identifier.getIdentifierKey(space.identifier, SPACE_PREFIX),
txHash,
delegates,
txSignature
)
const spaceParams = {
identifier: Identifier.getIdentifierKey(space.identifier, SPACE_PREFIX),
digest: txHash,
controller: controller.address,
}
return api.tx.space.authorise(spaceParams, delegates, txSignature)
}

/**
Expand All @@ -103,13 +98,12 @@ export async function deauthorise(
const { txSignature, txHash } = controller.signTx(space.spaceHash)

const api = await ChainApiConnection.getConnectionOrConnect()
return api.tx.space.deauthorise(
controller,
Identifier.getIdentifierKey(space.identifier, SPACE_PREFIX),
txHash,
delegates,
txSignature
)
const spaceParams = {
identifier: Identifier.getIdentifierKey(space.identifier, SPACE_PREFIX),
digest: txHash,
controller: controller.address,
}
return api.tx.space.deauthorise(spaceParams, delegates, txSignature)
}

/**
Expand All @@ -123,13 +117,12 @@ export async function transfer(
const { txSignature, txHash } = controller.signTx(space.spaceHash)

const api = await ChainApiConnection.getConnectionOrConnect()
return api.tx.space.transfer(
controller,
Identifier.getIdentifierKey(space.identifier, SPACE_PREFIX),
transfer,
txHash,
txSignature
)
const spaceParams = {
identifier: Identifier.getIdentifierKey(space.identifier, SPACE_PREFIX),
digest: txHash,
controller: space.controller,
}
return api.tx.space.transfer(spaceParams, transfer, txSignature)
}

export interface AnchoredSpaceDetails extends Struct {
Expand Down
Loading

0 comments on commit a1627e3

Please sign in to comment.