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

asset: Updates to have a VC of Asset #196

Merged
merged 7 commits into from
Apr 8, 2024
Merged

Conversation

vatsa287
Copy link
Member

@vatsa287 vatsa287 commented Mar 25, 2024

  • Add dependency of temp-cord-vc to be able to issue VC of assets.
  • New schema for Asset.
  • Updates on asset tx script to demonstrate above.

@vatsa287 vatsa287 marked this pull request as draft March 25, 2024 17:50
@amarts
Copy link
Member

amarts commented Mar 25, 2024

Can you paste the output here ?

For the reviewers, this is not an ideal way to implement this. Also due to this, found an issue with the vc-export library, where we should instead of using Cord from import, should consider taking it through argument.

@vatsa287
Copy link
Member Author

O/P

❄️  VC Asset Creation 
VC asset creation complete {
  '@context': [
    'https://www.w3.org/2018/credentials/v1',
    'https://cord.network/2023/cred/v1'
  ],
  type: [ 'VerifiableCredential' ],
  issuer: 'did:cord:3yDjRBvxf1HPApfZc2zozZzeE9tejX8SEHCMWZiBkmjWShnL',
  issuanceDate: '2024-03-26T06:32:51.034Z',
  credentialSubject: {
    assetType: 'ART',
    assetDesc: 'Asset - fdf53016-08a3-4010-8706-8a532119ddc3',
    assetQty: 10000,
    assetValue: 100,
    assetTag: 'Tag - 0818dae1-0a35-4330-bff5-11fb20b311cc',
    assetMeta: 'Meta - 472ec18e-030d-4470-9a1a-2a083555dfbc',
    id: 'did:cord:3yDjRBvxf1HPApfZc2zozZzeE9tejX8SEHCMWZiBkmjWShnL'
  },
  validFrom: '2024-03-26T06:32:51.034Z',
  validUntil: '2025-03-26T06:32:51.035Z',
  metadata: { evidence: undefined, template: undefined, label: undefined },
  credentialSchema: {
    '$id': 'schema:cord:s32gjmr4yB77GCSe2KxRQQwDEL7yWh78Hd57SEuQgVztTYrtG',
    '$schema': 'http://cord.network/draft-01/schema#',
    '$metadata': { version: '1.0.0', slug: 'asset-demo-schema', discoverable: true },
    title: 'Asset Demo Schema v3:79ffb97c-def3-45bc-850f-da8f350c35c2',
    description: 'Asset Demo Schema',
    properties: {
      assetType: [Object],
      assetDesc: [Object],
      assetQty: [Object],
      assetValue: [Object],
      assetTag: [Object],
      assetMeta: [Object]
    },
    type: 'object',
    additionalProperties: false
  },
  credentialHash: '0xa945d6211890b39e2d5f596e3eb44b0548d8c435a0bbf51ffcfc58458449cb33'
}

But addProof fails with,

/Users/vatsa/cord.js/node_modules/@cord.network/vc-export/node_modules/@cord.network/config/lib/Service.js:51
                throw new utils_1.SDKErrors.BlockchainApiMissingError();
                      ^

BlockchainApiMissingError: The Chain API is not set. Did you forget to call `Cord.connect(…)` or `Cord.init(…)`?
    at Object.get (/Users/vatsa/cord.js/node_modules/@cord.network/vc-export/node_modules/@cord.network/config/lib/Service.js:51:23)
    at getUriForStatement (/Users/vatsa/cord.js/node_modules/@cord.network/vc-export/node_modules/@cord.network/statement/lib/cjs/Statement.chain.js:113:40)
    at Object.buildFromProperties (/Users/vatsa/cord.js/node_modules/@cord.network/vc-export/node_modules/@cord.network/statement/lib/cjs/Statement.js:115:65)
    at Object.addProof (/Users/vatsa/cord.js/node_modules/@cord.network/vc-export/lib/cjs/vc.js:47:43)
    at main (/Users/vatsa/cord.js/demo/src/asset-vc-tx.ts:203:12)

@amarts

@vatsa287
Copy link
Member Author

@amarts, Full script o/p.

On-Chain Assets & Transactions

❄️  Identities
🏦  Member (ed25519): 3wTmud88TZkuvaTcFYipDMbKHe2eUkb1sGdhdDsiNSCCthZQ
🏛   Issuer (sr25519): did:cord:3vnM9ZE7dNo2L4gRffbRtX3cjy2GW8SD72SdE5LFtGdyNbah
🏛   Holder (sr25519): did:cord:3zUvwFLCPXqjhsnF8XZAThkubyUAxcaMPLHCno2T3F9xmCmU
🏛   Holder2 (sr25519): did:cord:3ukNKbqXdccaNjEyWbWEDWgouceNQSni1GDUujf2ZvKUBxzL
🏦  API Provider (ed25519): 3wevGHbpvrTfZ7hrBon7924LP48PTKN6qt1raUwiJDgcUkx9
✅ Identities created!

❄️  Chain Space Creation 
{
  uri: 'space:cord:c36XpPTMU5GXuuiyw5Qt11CBUuqe6xtXhNnpZNLo6VD4UG79f',
  desc: 'ChainSpace v1.9232190d-65c4-417a-9e4c-6eb4781884ee',
  digest: '0x07fb391bed661311cee3ab3a3be5fa4b9da579233344b456d676930934323ac0',
  creatorUri: 'did:cord:3vnM9ZE7dNo2L4gRffbRtX3cjy2GW8SD72SdE5LFtGdyNbah',
  authorizationUri: 'auth:cord:a3cS263L2EASyYgvW51b2s6X8gfRxMeJAWuJai8zQ85xqXWDy'
}

❄️  Chain Space Properties 
{
  uri: 'space:cord:c36XpPTMU5GXuuiyw5Qt11CBUuqe6xtXhNnpZNLo6VD4UG79f',
  authorization: 'auth:cord:a3cS263L2EASyYgvW51b2s6X8gfRxMeJAWuJai8zQ85xqXWDy'
}
✅ Chain Space created!

❄️  Chain Space Approval 
✅ Chain Space Approved
✅ Schema - schema:cord:s33Nf3d4MwDbiCVBFxFYYRXhEFLReud5QNGv9hjUxuVYfy4cv - added!

❄️  Asset Properties - Created by Issuer  
{
  assetType: 'ART',
  assetDesc: 'Asset - bfac4af3-1819-4142-b681-d3a89b5d4eb3',
  assetQty: 10000,
  assetValue: 100,
  assetTag: 'Tag - 628e0f1d-5267-4bc7-b54c-8144a94a8593',
  assetMeta: 'Meta - 1fa6b1d7-ad6a-4c12-aabe-bd4545248e9f'
}

❄️  VC Asset Creation 

❄️  Asset Verifiable Credential Document created 
 {
  '@context': [
    'https://www.w3.org/2018/credentials/v1',
    'https://cord.network/2023/cred/v1'
  ],
  type: [ 'VerifiableCredential' ],
  issuer: 'did:cord:3vnM9ZE7dNo2L4gRffbRtX3cjy2GW8SD72SdE5LFtGdyNbah',
  issuanceDate: '2024-03-26T13:14:21.027Z',
  credentialSubject: {
    assetType: 'ART',
    assetDesc: 'Asset - bfac4af3-1819-4142-b681-d3a89b5d4eb3',
    assetQty: 10000,
    assetValue: 100,
    assetTag: 'Tag - 628e0f1d-5267-4bc7-b54c-8144a94a8593',
    assetMeta: 'Meta - 1fa6b1d7-ad6a-4c12-aabe-bd4545248e9f',
    id: 'did:cord:3vnM9ZE7dNo2L4gRffbRtX3cjy2GW8SD72SdE5LFtGdyNbah'
  },
  validFrom: '2024-03-26T13:14:21.027Z',
  validUntil: '2025-03-26T13:14:21.028Z',
  metadata: { evidence: undefined, template: undefined, label: undefined },
  credentialSchema: {
    '$id': 'schema:cord:s33Nf3d4MwDbiCVBFxFYYRXhEFLReud5QNGv9hjUxuVYfy4cv',
    '$schema': 'http://cord.network/draft-01/schema#',
    '$metadata': { version: '1.0.0', slug: 'asset-demo-schema', discoverable: true },
    title: 'Asset Demo Schema v3:31026cbf-4410-48a9-bc82-75b3939700c1',
    description: 'Asset Demo Schema',
    properties: {
      assetType: [Object],
      assetDesc: [Object],
      assetQty: [Object],
      assetValue: [Object],
      assetTag: [Object],
      assetMeta: [Object]
    },
    type: 'object',
    additionalProperties: false
  },
  credentialHash: '0x9e1bcbeac28770d9147fbed11c04c4a06b6c440f476d80478be60c9a3a203d77'
}

✅  VC Asset created on-chain!

❄️  Issue Asset to Holder - Issuer Action  
{
  entry: {
    assetId: 'a3gBEZdb64feZPCvZjH36ZWnLSbMmtRrDev3YWonjoVNG98mK',
    assetOwner: '3zUvwFLCPXqjhsnF8XZAThkubyUAxcaMPLHCno2T3F9xmCmU',
    assetIssuanceQty: 1
  },
  issuer: 'did:cord:3vnM9ZE7dNo2L4gRffbRtX3cjy2GW8SD72SdE5LFtGdyNbah',
  space: 'space:cord:c36XpPTMU5GXuuiyw5Qt11CBUuqe6xtXhNnpZNLo6VD4UG79f',
  digest: '0x19957c444036efbd3c60013c2df786c3a08185e56b2fe9cf2636db8f9b8831ef',
  uri: 'asset:cord:a3gBEZdb64feZPCvZjH36ZWnLSbMmtRrDev3YWonjoVNG98mK:i33pqDWr5PhM9bUTDrF9hKJgf67SZ3rBRvG2siRVVoFsFVrmm'
}

❄️  Transfer Asset to New Owner (Holder2) - Holder Action  
{
  entry: {
    assetId: 'a3gBEZdb64feZPCvZjH36ZWnLSbMmtRrDev3YWonjoVNG98mK',
    assetInstanceId: 'i33pqDWr5PhM9bUTDrF9hKJgf67SZ3rBRvG2siRVVoFsFVrmm',
    assetOwner: '3zUvwFLCPXqjhsnF8XZAThkubyUAxcaMPLHCno2T3F9xmCmU',
    newAssetOwner: '3ukNKbqXdccaNjEyWbWEDWgouceNQSni1GDUujf2ZvKUBxzL'
  },
  owner: 'did:cord:3zUvwFLCPXqjhsnF8XZAThkubyUAxcaMPLHCno2T3F9xmCmU',
  digest: '0x14aa8391f20fb5cdcd62cf078def396df94a736486bbc41157854c300bb63263'
}
✅  Asset transferred!

Bye! 👋 👋 👋 

@vatsa287 vatsa287 marked this pull request as ready for review March 26, 2024 13:17
Signed-off-by: Shreevatsa N <[email protected]>
@vatsa287
Copy link
Member Author

@smohan-dw @amarts, Updated to have VCs for asset issuance & transfer as well with ownership changes seen on VCs.

On-Chain Assets & Transactions

❄️  Identities
🏦  Member (ed25519): 3xAfdQ227FNhKe6f7p61C24yFLPrFqt6zbjRnvHKD2enKy7D
🏛   Issuer (sr25519): did:cord:3ucaChkzSxTbNvNykXq7LbGR8AgcujrjqgBvcGQPC4KiF8TQ
🏛   Holder (sr25519): did:cord:3vHZUZzWZUGWw2AM2gmaNnJqr3B9fx3q1BFRtiLsHnQZvh6R
🏛   Holder2 (sr25519): did:cord:3uw8zWdw9TFRjGi4wB3DuEabngmzKJvPuXrYGzbJZWUDgEAQ
🏦  API Provider (ed25519): 3yGXAs6wrwgoxk8Lk1zeNA9FpFi7aip1iEQE3iBRzSpaaBZp
✅ Identities created!

❄️  Chain Space Creation 
{
  uri: 'space:cord:c34LBVhcv9ha38Jn7uBTKVrrrtvu2fadT2fuAgPosPRqpv5Qq',
  desc: 'ChainSpace v1.d4e11e7c-db00-484f-a7cd-5b87178130be',
  digest: '0x6cf9e6655f6f92cedeeef7a92797d448a4487201498b95a2df185a447299f22b',
  creatorUri: 'did:cord:3ucaChkzSxTbNvNykXq7LbGR8AgcujrjqgBvcGQPC4KiF8TQ',
  authorizationUri: 'auth:cord:a3eDhaaYfYeCug6dws72aTxSL9u7ztNLWdLAqgQ3t4kmdBV7K'
}

❄️  Chain Space Properties 
{
  uri: 'space:cord:c34LBVhcv9ha38Jn7uBTKVrrrtvu2fadT2fuAgPosPRqpv5Qq',
  authorization: 'auth:cord:a3eDhaaYfYeCug6dws72aTxSL9u7ztNLWdLAqgQ3t4kmdBV7K'
}
✅ Chain Space created!

❄️  Chain Space Approval 
✅ Chain Space Approved
✅ Schema - schema:cord:s32HgEzyFRBvoGNVTuvpM2rBXNps4rNf4XfZkFtNtpqCpPu33 - added!

❄️  Asset Properties - Created by Issuer  
{
  assetType: 'ART',
  assetDesc: 'Asset - 1dc018f7-ecd4-4ac5-89fb-0a6a353d09c9',
  assetQty: 10000,
  assetValue: 100,
  assetTag: 'Tag - c8ff5997-7ec3-4a1f-acb6-a784eeaf859e',
  assetMeta: 'Meta - c18be8b9-c8df-471e-93cd-529f0be3b3d3'
}

❄️  VC Asset Creation 

❄️  Asset(create) Verifiable Credential Document created 
 {
  '@context': [
    'https://www.w3.org/2018/credentials/v1',
    'https://cord.network/2023/cred/v1'
  ],
  type: [ 'VerifiableCredential' ],
  issuer: 'did:cord:3ucaChkzSxTbNvNykXq7LbGR8AgcujrjqgBvcGQPC4KiF8TQ',
  issuanceDate: '2024-03-27T10:11:39.069Z',
  credentialSubject: {
    assetType: 'ART',
    assetDesc: 'Asset - 1dc018f7-ecd4-4ac5-89fb-0a6a353d09c9',
    assetQty: 10000,
    assetValue: 100,
    assetTag: 'Tag - c8ff5997-7ec3-4a1f-acb6-a784eeaf859e',
    assetMeta: 'Meta - c18be8b9-c8df-471e-93cd-529f0be3b3d3',
    id: 'did:cord:3ucaChkzSxTbNvNykXq7LbGR8AgcujrjqgBvcGQPC4KiF8TQ'
  },
  validFrom: '2024-03-27T10:11:39.069Z',
  validUntil: '2025-03-27T10:11:39.071Z',
  metadata: { evidence: undefined, template: undefined, label: undefined },
  credentialSchema: {
    '$id': 'schema:cord:s32HgEzyFRBvoGNVTuvpM2rBXNps4rNf4XfZkFtNtpqCpPu33',
    '$schema': 'http://cord.network/draft-01/schema#',
    '$metadata': { version: '1.0.0', slug: 'asset-demo-schema', discoverable: true },
    title: 'Asset Demo Schema v3:43d31782-0833-44e9-8307-623244e89ab5',
    description: 'Asset Demo Schema',
    properties: {
      assetType: [Object],
      assetDesc: [Object],
      assetQty: [Object],
      assetValue: [Object],
      assetTag: [Object],
      assetMeta: [Object]
    },
    type: 'object',
    additionalProperties: false
  },
  credentialHash: '0x0d603eb265c2aac39cae0e96b06305241b69334dc01743cf28cd537b0f48d11b',
  id: 'asset:cord:a3k48aFveArLdWxg39efVDaYPfqkFhjSor8NuJv5Sx1gvF5oy'
}

✅  VC Asset created on-chain!

❄️  Issue Asset to Holder - Issuer Action  
{
  entry: {
    assetId: 'a3k48aFveArLdWxg39efVDaYPfqkFhjSor8NuJv5Sx1gvF5oy',
    assetOwner: '3vHZUZzWZUGWw2AM2gmaNnJqr3B9fx3q1BFRtiLsHnQZvh6R',
    assetIssuanceQty: 1
  },
  issuer: 'did:cord:3ucaChkzSxTbNvNykXq7LbGR8AgcujrjqgBvcGQPC4KiF8TQ',
  space: 'space:cord:c34LBVhcv9ha38Jn7uBTKVrrrtvu2fadT2fuAgPosPRqpv5Qq',
  digest: '0x0355d3f77447133983f36603128db2e6a7e606f70fa1b860df7f3ea8d57a5f3f',
  uri: 'asset:cord:a3k48aFveArLdWxg39efVDaYPfqkFhjSor8NuJv5Sx1gvF5oy:i33VxEgTs4Mce6dUFK2icUqy7UK2PMBX9wsrEQbuC2rbtUV7G'
}

❄️  Asset(issue) Verifiable Credential Document created 
 {
  '@context': [
    'https://www.w3.org/2018/credentials/v1',
    'https://cord.network/2023/cred/v1'
  ],
  type: [ 'VerifiableCredential' ],
  issuer: 'did:cord:3ucaChkzSxTbNvNykXq7LbGR8AgcujrjqgBvcGQPC4KiF8TQ',
  issuanceDate: '2024-03-27T10:11:42.053Z',
  credentialSubject: {
    assetType: 'ART',
    assetDesc: 'Asset - 1dc018f7-ecd4-4ac5-89fb-0a6a353d09c9',
    assetQty: 1,
    assetValue: 100,
    assetTag: 'Tag - c8ff5997-7ec3-4a1f-acb6-a784eeaf859e',
    assetMeta: 'Meta - c18be8b9-c8df-471e-93cd-529f0be3b3d3',
    id: 'did:cord:3vHZUZzWZUGWw2AM2gmaNnJqr3B9fx3q1BFRtiLsHnQZvh6R'
  },
  validFrom: '2024-03-27T10:11:42.053Z',
  validUntil: '2025-03-27T10:11:42.053Z',
  metadata: { evidence: undefined, template: undefined, label: undefined },
  credentialSchema: {
    '$id': 'schema:cord:s32HgEzyFRBvoGNVTuvpM2rBXNps4rNf4XfZkFtNtpqCpPu33',
    '$schema': 'http://cord.network/draft-01/schema#',
    '$metadata': { version: '1.0.0', slug: 'asset-demo-schema', discoverable: true },
    title: 'Asset Demo Schema v3:43d31782-0833-44e9-8307-623244e89ab5',
    description: 'Asset Demo Schema',
    properties: {
      assetType: [Object],
      assetDesc: [Object],
      assetQty: [Object],
      assetValue: [Object],
      assetTag: [Object],
      assetMeta: [Object]
    },
    type: 'object',
    additionalProperties: false
  },
  credentialHash: '0x4f2a4588e2858245791db8ed3c9679d76871e51b8986dc46975cb53639a0bb20',
  id: 'asset:cord:a3k48aFveArLdWxg39efVDaYPfqkFhjSor8NuJv5Sx1gvF5oy:i33VxEgTs4Mce6dUFK2icUqy7UK2PMBX9wsrEQbuC2rbtUV7G'
}

❄️  Transfer Asset to New Owner (Holder2) - Holder Action  

❄️  Asset(transfer) Verifiable Credential Document created 
 {
  '@context': [
    'https://www.w3.org/2018/credentials/v1',
    'https://cord.network/2023/cred/v1'
  ],
  type: [ 'VerifiableCredential' ],
  issuer: 'did:cord:3vHZUZzWZUGWw2AM2gmaNnJqr3B9fx3q1BFRtiLsHnQZvh6R',
  issuanceDate: '2024-03-27T10:11:45.041Z',
  credentialSubject: {
    assetType: 'ART',
    assetDesc: 'Asset - 1dc018f7-ecd4-4ac5-89fb-0a6a353d09c9',
    assetQty: 1,
    assetValue: 100,
    assetTag: 'Tag - c8ff5997-7ec3-4a1f-acb6-a784eeaf859e',
    assetMeta: 'Meta - c18be8b9-c8df-471e-93cd-529f0be3b3d3',
    id: 'did:cord:3uw8zWdw9TFRjGi4wB3DuEabngmzKJvPuXrYGzbJZWUDgEAQ'
  },
  validFrom: '2024-03-27T10:11:45.041Z',
  validUntil: '2025-03-27T10:11:45.041Z',
  metadata: { evidence: undefined, template: undefined, label: undefined },
  credentialSchema: {
    '$id': 'schema:cord:s32HgEzyFRBvoGNVTuvpM2rBXNps4rNf4XfZkFtNtpqCpPu33',
    '$schema': 'http://cord.network/draft-01/schema#',
    '$metadata': { version: '1.0.0', slug: 'asset-demo-schema', discoverable: true },
    title: 'Asset Demo Schema v3:43d31782-0833-44e9-8307-623244e89ab5',
    description: 'Asset Demo Schema',
    properties: {
      assetType: [Object],
      assetDesc: [Object],
      assetQty: [Object],
      assetValue: [Object],
      assetTag: [Object],
      assetMeta: [Object]
    },
    type: 'object',
    additionalProperties: false
  },
  credentialHash: '0xac31ce663092a5e4066733b7d2414a4e7b69cde5a3f885849f2b726098df30d4',
  id: 'asset:cord:a3k48aFveArLdWxg39efVDaYPfqkFhjSor8NuJv5Sx1gvF5oy:i33VxEgTs4Mce6dUFK2icUqy7UK2PMBX9wsrEQbuC2rbtUV7G'
}
{
  entry: {
    assetId: 'a3k48aFveArLdWxg39efVDaYPfqkFhjSor8NuJv5Sx1gvF5oy',
    assetInstanceId: 'i33VxEgTs4Mce6dUFK2icUqy7UK2PMBX9wsrEQbuC2rbtUV7G',
    assetOwner: '3vHZUZzWZUGWw2AM2gmaNnJqr3B9fx3q1BFRtiLsHnQZvh6R',
    newAssetOwner: '3uw8zWdw9TFRjGi4wB3DuEabngmzKJvPuXrYGzbJZWUDgEAQ'
  },
  owner: 'did:cord:3vHZUZzWZUGWw2AM2gmaNnJqr3B9fx3q1BFRtiLsHnQZvh6R',
  digest: '0x71fa6b5546640a814281232948dfcb9a78e3f9d49bf6b77cfd81e328e95873ee'
}
✅  Asset transferred!

Bye! 👋 👋 👋 

Copy link
Member

@amarts amarts left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please remove package.json and yarn.lock and only keep the demo files.

Signed-off-by: Shreevatsa N <[email protected]>
Signed-off-by: Shreevatsa N <[email protected]>
@vatsa287 vatsa287 requested a review from amarts April 2, 2024 10:36
@amarts amarts merged commit 321a684 into dhiway:develop Apr 8, 2024
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants