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

feat: P-693 add MCRT token holding amount VC #2673

Merged
merged 1 commit into from
Apr 24, 2024

Conversation

higherordertech
Copy link
Contributor

@higherordertech higherordertech commented Apr 18, 2024

Context

As title.
Also refactored test cases and supported customized assertion ranges
Used abort strategy for token holding amount assertion.

Labels

Please apply following PR-related labels when appropriate:

  • C0-breaking: if your change could break the existing client, e.g. API change, critical logic change
  • C1-noteworthy: if your change is non-breaking, but is still worth noticing for the client, e.g. reference code improvement

How (Optional)

Testing Evidences

Please attach any relevant evidences if applicable

e2e testing scripts

cargo run --bin litentry-cli --features development -- trusted -d link-identity did:litentry:substrate:0xd4e35b16ec6b417386b948e7eaf5cc642a243096cecf366e6313689b90969f42 did:litentry:solana:B4oMp9JyHK9EVWjbAhi9SRyjdXT7VEs3RyFuy2bPnwzT solana
cargo run --bin litentry-cli  --features development -- trusted -d request-vc did:litentry:substrate:0xd4e35b16ec6b417386b948e7eaf5cc642a243096cecf366e6313689b90969f42 -a "token-holding-amount mcrt"

vc result:

{
   "@context":[
      "https://www.w3.org/2018/credentials/v1",
      "https://w3id.org/security/suites/ed25519-2020/v1"
   ],
   "id":"0x8f5e6320072f1141823f51bfa4d2462d526216ba23aa326cd808b54507a2f2d5",
   "type":[
      "VerifiableCredential"
   ],
   "credentialSubject":{
      "id":"did:litentry:substrate:0xd4e35b16ec6b417386b948e7eaf5cc642a243096cecf366e6313689b90969f42",
      "description":"The amount of a particular token you are holding",
      "type":"Token Holding Amount",
      "assertionText":"TokenHoldingAmount(Mcrt)",
      "assertions":[
         {
            "and":[
               {
                  "src":"$token",
                  "op":"==",
                  "dst":"MCRT"
               },
               {
                  "or":[
                     {
                        "and":[
                           {
                              "src":"$network",
                              "op":"==",
                              "dst":"bsc"
                           },
                           {
                              "src":"$address",
                              "op":"==",
                              "dst":"0x4b8285aB433D8f69CB48d5Ad62b415ed1a221e4f"
                           }
                        ]
                     },
                     {
                        "and":[
                           {
                              "src":"$network",
                              "op":"==",
                              "dst":"ethereum"
                           },
                           {
                              "src":"$address",
                              "op":"==",
                              "dst":"0xde16ce60804a881e9f8c4ebb3824646edecd478d"
                           }
                        ]
                     },
                     {
                        "and":[
                           {
                              "src":"$network",
                              "op":"==",
                              "dst":"solana"
                           },
                           {
                              "src":"$address",
                              "op":"==",
                              "dst":"FADm4QuSUF1K526LvTjvbJjKzeeipP6bj5bSzp3r6ipq"
                           }
                        ]
                     }
                  ]
               },
               {
                  "src":"$holding_amount",
                  "op":">=",
                  "dst":"150000"
               },
               {
                  "src":"$holding_amount",
                  "op":"<",
                  "dst":"500000"
               }
            ]
         }
      ],
      "values":[
         true
      ],
      "endpoint":"http://localhost:9933/"
   },
   "issuer":{
      "id":"did:litentry:substrate:0xbcbc6dc9fc214b1d9bca7fa35b86a009c9ffb8c1520c479750884a72a7d71e96",
      "name":"Litentry TEE Worker",
      "mrenclave":"6pzQr2CX6hdeLuVN3RGUHd3d1hyki8MUeed79G7hJRq4"
   },
   "issuanceDate":"2024-04-17T13:50:50.586937488+00:00",
   "parachainBlockNumber":44,
   "sidechainBlockNumber":74,
   "proof":{
      "created":"2024-04-17T13:50:50.587887707+00:00",
      "type":"Ed25519Signature2020",
      "proofPurpose":"assertionMethod",
      "proofValue":"fbc15b6206be280c2beda17035a45a1d62ad0403663132cfbf4ef3912f628bb46065c0f44efd4de8bb62c4af8dff344452c45cf1dcaa28e7f85d4559d00f720c",
      "verificationMethod":"0xbcbc6dc9fc214b1d9bca7fa35b86a009c9ffb8c1520c479750884a72a7d71e96"
   },
   "credentialSchema":{
      "id":"https://raw.githubusercontent.com/litentry/vc-jsonschema/main/dist/schemas/21-evm-holding-amount/1-0-0.json",
      "type":"JsonSchemaValidator2018"
   }
}

Copy link

linear bot commented Apr 18, 2024

@jonalvarezz
Copy link
Contributor

@higherordertech anything holding us from merging in?

@kziemianek
Copy link
Member

Hi @higherordertech , what do you think about writing ts-test for this new assertion?

Copy link
Contributor

@jonalvarezz jonalvarezz left a comment

Choose a reason for hiding this comment

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

lgtm

@higherordertech higherordertech merged commit 22f3547 into dev Apr 24, 2024
31 checks passed
Copy link

linear bot commented Apr 24, 2024

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.

3 participants