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

Api based sdk #150

Open
wants to merge 22 commits into
base: api_based_sdk
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
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
25 changes: 8 additions & 17 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ module.exports = {
ecmaVersion: 2018,
sourceType: 'module',
project: './tsconfig.json',
tsconfigRootDir: __dirname,
extraFileExtensions: ['.json'],
},
plugins: [
'@typescript-eslint',
Expand All @@ -37,7 +39,7 @@ module.exports = {
devDependencies: [
'**/*.test.ts',
'**/*.spec.ts',
'**/__integrationtests__/*',
'tests/**/*',
'**/webpack.config.js',
],
},
Expand Down Expand Up @@ -141,7 +143,7 @@ module.exports = {
'jsdoc/check-tag-names': [
'warn',
{
definedTags: ['group', 'packageDocumentation'],
definedTags: ['packageDocumentation'],
},
],
'@typescript-eslint/no-var-requires': 'off',
Expand All @@ -151,31 +153,20 @@ module.exports = {
'no-console': 'off',
},
},
{
files: ['**/__integrationtests__/*.ts'],
rules: {
'import/extensions': 'off',
'jsdoc/require-jsdoc': 'off',
'no-console': 'off',
},
},
{
files: ['**/augment-api/src/interfaces/**/*.ts'],
rules: {
'license-header/header': 'off',
},
},
{
files: ['tests/*'],
files: ['tests/**/*'],
rules: {
'import/extensions': 'off',
'jsdoc/require-jsdoc': 'off',
'no-console': 'off',
'@typescript-eslint/explicit-function-return-type': 'off',
'import/no-extraneous-dependencies': [
'error',
{
devDependencies: ['tests/*', 'tests/bundle.spec.ts'],
},
],
'import/no-extraneous-dependencies': 'off',
},
},
],
Expand Down
4 changes: 3 additions & 1 deletion .prettierignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
jsonabc.js
jsonabc.d.ts
dist
lib
*.json
!package.json
jest.*
coverage
**/augment-api/src/interfaces/**/*.ts
**/augment-api/src/interfaces/**/*.ts
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,11 @@ yarn build
Once the build of the package is complete (with `yarn build`), one can try below methods to check
if methods are working.

Note:
Make sure that the cord instance in running locally by following the README.md under the CORD repo.
Follow the instructions under the topic - "Run the node"


```

$ yarn demo
Expand Down
24 changes: 12 additions & 12 deletions demo/src/demo-vc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,22 +33,20 @@ async function main() {
Cord.ConfigService.set({ submitTxResolveOn: Cord.Chain.IS_IN_BLOCK })
await Cord.connect(networkAddress)

// Step 1: Setup Authority
// Step 1: Setup Membership
// Setup transaction author account - CORD Account.

console.log(`\n❄️ New Authority`)
console.log(`\n❄️ New Network Member`)
const authorityAuthorIdentity = Crypto.makeKeypairFromUri(
'//Alice',
'sr25519'
)
// Setup author authority account.
// Setup network member account.
const { account: authorIdentity } = await createAccount()
console.log(`🏦 Author (${authorIdentity.type}): ${authorIdentity.address}`)
console.log(`🏦 Member (${authorIdentity.type}): ${authorIdentity.address}`)
await addAuthority(authorityAuthorIdentity, authorIdentity.address)
console.log(`🔏 Author permissions updated`)
await getChainCredits(authorityAuthorIdentity, authorIdentity.address, 5)
console.log(`💸 Author endowed with credits`)
console.log('✅ Authority created!')
console.log(`🔏 Member permissions updated`)
console.log('✅ Network Member added!')

// Step 2: Setup Identities
console.log(`\n❄️ Demo Identities (KeyRing)`)
Expand Down Expand Up @@ -91,23 +89,26 @@ async function main() {
await createDid(authorIdentity)
const delegateOneKeys = generateKeypairs(delegateOneMnemonic)
console.log(
`🏛 Delegate (${delegateOneDid?.assertionMethod![0].type}): ${delegateOneDid.uri
`🏛 Delegate (${delegateOneDid?.assertionMethod![0].type}): ${
delegateOneDid.uri
}`
)
// Create Delegate Two DID
const { mnemonic: delegateTwoMnemonic, document: delegateTwoDid } =
await createDid(authorIdentity)
const delegateTwoKeys = generateKeypairs(delegateTwoMnemonic)
console.log(
`🏛 Delegate (${delegateTwoDid?.assertionMethod![0].type}): ${delegateTwoDid.uri
`🏛 Delegate (${delegateTwoDid?.assertionMethod![0].type}): ${
delegateTwoDid.uri
}`
)
// Create Delegate 3 DID
const { mnemonic: delegate3Mnemonic, document: delegate3Did } =
await createDid(authorIdentity)
const delegate3Keys = generateKeypairs(delegate3Mnemonic)
console.log(
`🏛 Delegate (${delegate3Did?.assertionMethod![0].type}): ${delegate3Did.uri
`🏛 Delegate (${delegate3Did?.assertionMethod![0].type}): ${
delegate3Did.uri
}`
)
console.log('✅ Identities created!')
Expand Down Expand Up @@ -383,7 +384,6 @@ async function main() {
selfSignatureResult1['verified']
)
}

}

main()
Expand Down
Loading