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

Sol Balance VC with an abort strategy example implementation #2572

Merged
merged 5 commits into from
Mar 19, 2024

Conversation

higherordertech
Copy link
Contributor

@higherordertech higherordertech commented Mar 13, 2024

Context

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

{
  "@context": [
    "https://www.w3.org/2018/credentials/v1",
    "https://w3id.org/security/suites/ed25519-2020/v1"
  ],
  "id": "0x972899b24a5989a3ae77e5b438ba6f7c2cebe2af15ccb32900d48145eb30250b",
  "type": [
    "VerifiableCredential"
  ],
  "credentialSubject": {
    "id": "did:litentry:substrate:0xd4e35b16ec6b417386b948e7eaf5cc642a243096cecf366e6313689b90969f42",
    "description": "The amount of a particular token you are holding",
    "type": "Token Holding Amount",
    "assertionText": "TokenHoldingAmount(Sol)",
    "assertions": [
      {
        "and": [
          {
            "src": "$token",
            "op": "==",
            "dst": "SOL"
          },
          {
            "or": [
              {
                "and": [
                  {
                    "src": "$network",
                    "op": "==",
                    "dst": "bsc"
                  },
                  {
                    "src": "$address",
                    "op": "==",
                    "dst": "0x570a5d26f7765ecb712c0924e4de545b89fd43df"
                  }
                ]
              },
              {
                "and": [
                  {
                    "src": "$network",
                    "op": "==",
                    "dst": "ethereum"
                  },
                  {
                    "src": "$address",
                    "op": "==",
                    "dst": "0x5288738df1aeb0894713de903e1d0c001eeb7644"
                  }
                ]
              },
              {
                "and": [
                  {
                    "src": "$network",
                    "op": "==",
                    "dst": "solana"
                  }
                ]
              }
            ]
          },
          {
            "src": "$holding_amount",
            "op": ">=",
            "dst": "1"
          },
          {
            "src": "$holding_amount",
            "op": "<",
            "dst": "50"
          }
        ]
      }
    ],
    "values": [
      true
    ],
    "endpoint": "http://localhost:9933"
  },
  "issuer": {
    "id": "did:litentry:substrate:0xefe8ed375ee8dde2cbc6fe63b39fbf0beca657e263d35db84c2c62a970e6897e",
    "name": "Litentry TEE Worker",
    "mrenclave": "FeWRdXbXksaPWP6cpptyv9kuCHLyixpv3v7muhEFtK6A"
  },
  "issuanceDate": "2024-03-06T13:50:46.233886365+00:00",
  "parachainBlockNumber": 87,
  "sidechainBlockNumber": 163,
  "proof": {
    "created": "2024-03-06T13:50:46.235452419+00:00",
    "type": "Ed25519Signature2020",
    "proofPurpose": "assertionMethod",
    "proofValue": "c5a7155e52f066bbfaf48f1b0fc9e6c5dcc2684b84a30990c12692a84fb5036820a8fefd20aff6d341b2945fd1cff378b8d627aa0d2924e1d2b6d3c09755ab00",
    "verificationMethod": "0xefe8ed375ee8dde2cbc6fe63b39fbf0beca657e263d35db84c2c62a970e6897e"
  },
  "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 Mar 13, 2024

P-583 Solana credentials

@higherordertech higherordertech added the C1-noteworthy Non-breaking change but is worth noticing for client label Mar 13, 2024
@Kailai-Wang Kailai-Wang requested a review from a team March 13, 2024 10:31
@higherordertech higherordertech requested review from BillyWooo and felixfaisal and removed request for a team March 13, 2024 10:37
result = *item;

if *item == "item4" {
return Ok(false)
Copy link
Contributor

Choose a reason for hiding this comment

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

nitpick: should we pass an optional named struct for better readability? i.e. return Ok(LoopControls.Break)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

resolved now

Copy link
Collaborator

@BillyWooo BillyWooo left a comment

Choose a reason for hiding this comment

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

In general, it looks very good. I left two small comments. The main idea is to introduce the less env variable the better.

@@ -130,6 +130,7 @@ services:
- SORA_QUIZ_MASTER_ID=SORA_QUIZ_MASTER_ID
- SORA_QUIZ_ATTENDEE_ID=SORA_QUIZ_ATTENDEE_ID
- MORALIS_API_URL=http://localhost:19527
- MORALIS_SOLANA_API_URL=http://localhost:19527/moralis_solana/
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can we just use MORALIS_API_URL ? Add the extra part with code?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

moralis_api_url is totally different from moralis_solana_api_url, I think this way is better than merging them together
moralis_api_url: "https://deep-index.moralis.io/api/v2.2/".to_string(),
moralis_solana_api_url: "https://solana-gateway.moralis.io/".to_string(),

@@ -308,6 +310,9 @@ impl DataProviderConfig {
if let Ok(v) = env::var("MORALIS_API_URL") {
config.set_moralis_api_url(v)?;
}
if let Ok(v) = env::var("MORALIS_SOLANA_API_URL") {
Copy link
Collaborator

Choose a reason for hiding this comment

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

These two branches can be merged together.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

same as above, not worth merging them

@Kailai-Wang Kailai-Wang requested a review from a team March 14, 2024 23:34
Copy link
Collaborator

@Kailai-Wang Kailai-Wang left a comment

Choose a reason for hiding this comment

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

I only checked the AbortStrategy impl part, looks good!

Copy link
Collaborator

@BillyWooo BillyWooo left a comment

Choose a reason for hiding this comment

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

If there is no strong reason, I still insist to MORALIS_SOLANA_API_URL.

@higherordertech higherordertech merged commit e8a94de into dev Mar 19, 2024
25 of 26 checks passed
@BillyWooo BillyWooo deleted the P-583 branch March 19, 2024 08:19
silva-fj pushed a commit that referenced this pull request Mar 19, 2024
* P-583: add sol token balance

* P-298: add abort strategy for calling dp with multiple account

* fix clippy

* optimize morails_api_url mock config, add enum LoopControls for the loop_with_abort_strategy

* add missed batch vc config

---------

Co-authored-by: higherordertech <higherordertech>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C1-noteworthy Non-breaking change but is worth noticing for client
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants