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

P 948 added more networks dataprovider for erc20 amount VC #2990

Merged

Conversation

higherordertech
Copy link
Contributor

@higherordertech higherordertech commented Aug 14, 2024

Context

1 Mainly support network arbitrum, polygon and combo for erc20 token
with below refactoring too:
2 combine all token config to one mapping variable
3 add token config rangeDecimals instead of global decimals_factor
4 use maxDecimals from all networks of token as range decimals factor
5 add unit test for sol libraries: StringCleaner, StringComparison

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

Atom from Polygon
./bin/litentry-cli trusted -d request-vc did:litentry:evm:0xac51C4c48Dc3116487eD4BC16542e27B5694Da1b -a "dynamic 6f57ad167c42951657685a5d9a874f02f9e96976 0000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000461746f6d00000000000000000000000000000000000000000000000000000000"

identity: Evm(Address20)
nonce: 0
assertions: [Dynamic(DynamicParams { smart_contract_id: 0x6f57ad167c42951657685a5d9a874f02f9e96976, smart_contract_params: Some(BoundedVec([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 32, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4, 97, 116, 111, 109, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], 1024)), return_log: false })]
----Generated VC-----
{"@context":["https://www.w3.org/2018/credentials/v1","https://w3id.org/security/suites/ed25519-2020/v1"],"id":"0x34ee470c6981191a4c04762db72ad5754325bd62d568a43872b35626d24b8f3c","type":["VerifiableCredential"],"credentialSubject":{"id":"did:litentry:evm:0xac51c4c48dc3116487ed4bc16542e27b5694da1b","description":"The amount of a particular token you are holding","type":"Token Holding Amount","assertionText":"","assertions":[{"and":[{"src":"$token","op":"==","dst":"atom"},{"src":"$holding_amount","op":">=","dst":"1"},{"src":"$holding_amount","op":"<","dst":"5"}]}],"values":[true],"endpoint":"http://localhost:9933"},"issuer":{"id":"did:litentry:substrate:0x0b9df679f406a51a2e53b87d8e3fc86e792e277fe932d9535b40692bec9e3789","name":"Litentry TEE Worker","mrenclave":"J8azBS97su2y9J9sUZGTgi6MAcvXR1GwVDeGCN5KagUQ","runtimeVersion":{"parachain":9192,"sidechain":109}},"issuanceDate":"2024-08-14T08:49:26.427469683+00:00","parachainBlockNumber":19,"sidechainBlockNumber":29,"proof":{"created":"2024-08-14T08:49:26.427661864+00:00","type":"Ed25519Signature2020","proofPurpose":"assertionMethod","proofValue":"d789b2592d8d836903ea8ec2163f05b78aba0652f92065ab84e835ab812de99d9777238b97e83b7e6a7b3c20414749f8b1e3e79ec1216945bdd0906ed5e0ae06","verificationMethod":"0x44da3459814cb003846aece78984e0d064f6b7c1b4c3e4c7bf03b598ea550ba4"},"credentialSchema":{"id":"https://raw.githubusercontent.com/litentry/vc-jsonschema/main/dist/schemas/25-token-holding-amount/1-1-4.json","type":"JsonSchemaValidator2018"}}

Bean from Combo
./bin/litentry-cli trusted -d request-vc did:litentry:evm:0x6955512E5374D8fbD3ACF072e40bD4682ab2630a -a "dynamic 6f57ad167c42951657685a5d9a874f02f9e96976 000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000046265616e00000000000000000000000000000000000000000000000000000000"

identity: Evm(Address20)
nonce: 0
assertions: [Dynamic(DynamicParams { smart_contract_id: 0x6f57ad167c42951657685a5d9a874f02f9e96976, smart_contract_params: Some(BoundedVec([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 32, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4, 98, 101, 97, 110, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], 1024)), return_log: false })]
----Generated VC-----
{"@context":["https://www.w3.org/2018/credentials/v1","https://w3id.org/security/suites/ed25519-2020/v1"],"id":"0x4a5b09f24b4c87068e0267ceed81d34e819102bff0e57309916243f752c850ac","type":["VerifiableCredential"],"credentialSubject":{"id":"did:litentry:evm:0x6955512e5374d8fbd3acf072e40bd4682ab2630a","description":"The amount of a particular token you are holding","type":"Token Holding Amount","assertionText":"","assertions":[{"and":[{"src":"$token","op":"==","dst":"bean"},{"src":"$holding_amount","op":">","dst":"0"},{"src":"$holding_amount","op":"<","dst":"1500"}]}],"values":[true],"endpoint":"http://localhost:9933"},"issuer":{"id":"did:litentry:substrate:0x0b9df679f406a51a2e53b87d8e3fc86e792e277fe932d9535b40692bec9e3789","name":"Litentry TEE Worker","mrenclave":"J8azBS97su2y9J9sUZGTgi6MAcvXR1GwVDeGCN5KagUQ","runtimeVersion":{"parachain":9192,"sidechain":109}},"issuanceDate":"2024-08-14T08:54:37.515141848+00:00","parachainBlockNumber":45,"sidechainBlockNumber":80,"proof":{"created":"2024-08-14T08:54:37.515337340+00:00","type":"Ed25519Signature2020","proofPurpose":"assertionMethod","proofValue":"d7e8bca09a197a0d331a44938a48cc7958ab512c28fb714fd553704529a66e256829ff1b8d21fad694ee6aad1ce88483dc2bec5f70dba397d76e128238c4bd09","verificationMethod":"0x44da3459814cb003846aece78984e0d064f6b7c1b4c3e4c7bf03b598ea550ba4"},"credentialSchema":{"id":"https://raw.githubusercontent.com/litentry/vc-jsonschema/main/dist/schemas/25-token-holding-amount/1-1-4.json","type":"JsonSchemaValidator2018"}}

Dai from Arbitrum
./bin/litentry-cli trusted -d request-vc did:litentry:evm:0xd85E038593d7A098614721EaE955EC2022B9B91B -a "dynamic 6f57ad167c42951657685a5d9a874f02f9e96976 000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000036461690000000000000000000000000000000000000000000000000000000000"

identity: Evm(Address20)
nonce: 0
assertions: [Dynamic(DynamicParams { smart_contract_id: 0x6f57ad167c42951657685a5d9a874f02f9e96976, smart_contract_params: Some(BoundedVec([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 32, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 100, 97, 105, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], 1024)), return_log: false })]
----Generated VC-----
{"@context":["https://www.w3.org/2018/credentials/v1","https://w3id.org/security/suites/ed25519-2020/v1"],"id":"0x8f0a92182fb5ce2a723bb6001f123a9c18a104e645b1a0dbcbd6dd6e16194ba0","type":["VerifiableCredential"],"credentialSubject":{"id":"did:litentry:evm:0xd85e038593d7a098614721eae955ec2022b9b91b","description":"The amount of a particular token you are holding","type":"Token Holding Amount","assertionText":"","assertions":[{"and":[{"src":"$token","op":"==","dst":"dai"},{"src":"$holding_amount","op":">=","dst":"5000"}]}],"values":[true],"endpoint":"http://localhost:9933"},"issuer":{"id":"did:litentry:substrate:0x0b9df679f406a51a2e53b87d8e3fc86e792e277fe932d9535b40692bec9e3789","name":"Litentry TEE Worker","mrenclave":"6XVje1eZ1EpZg1RLb8TSrRotyPGrvrzBmnEnbAb8Ab68","runtimeVersion":{"parachain":9192,"sidechain":109}},"issuanceDate":"2024-08-14T08:32:49.655676395+00:00","parachainBlockNumber":18,"sidechainBlockNumber":27,"proof":{"created":"2024-08-14T08:32:49.655876494+00:00","type":"Ed25519Signature2020","proofPurpose":"assertionMethod","proofValue":"eb706d6c41f50112fafaf2f427e68558594bfacf8d20a18afb41224752727000b61f10cff6e9d1ae9cfb555edb320dbfce345c75379b636e22f07f51abf00507","verificationMethod":"0x44da3459814cb003846aece78984e0d064f6b7c1b4c3e4c7bf03b598ea550ba4"},"credentialSchema":{"id":"https://raw.githubusercontent.com/litentry/vc-jsonschema/main/dist/schemas/25-token-holding-amount/1-1-4.json","type":"JsonSchemaValidator2018"}}

higherordertech added 2 commits August 14, 2024 18:56
…en config rangeDecimals instead of global decimals_factor, use maxDecimals from all networks of token as range decimals factor, support network arbitrum, polygon and combo for erc20 token
Copy link

linear bot commented Aug 14, 2024

@higherordertech higherordertech requested review from 0xverin, kziemianek and a team August 14, 2024 09:18
@higherordertech higherordertech changed the title P 948 added more networks for sol erc20 amount vc P 948 added more networks dataprovider for erc20 amount VC Aug 14, 2024
@higherordertech higherordertech marked this pull request as ready for review August 14, 2024 09:18
@higherordertech higherordertech enabled auto-merge (squash) August 14, 2024 13:10
Copy link
Contributor

@0xverin 0xverin left a comment

Choose a reason for hiding this comment

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

Overall, it looks fine.

stringCleaner = await StringCleaner.deploy()
})

it('should correctly identify visible and invisible characters', async () => {
Copy link
Contributor

Choose a reason for hiding this comment

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

Nicely Done!

@higherordertech higherordertech merged commit 5d8cd11 into dev Aug 15, 2024
51 checks passed
@0xverin 0xverin deleted the P-948-added-more-networks-for-sol-erc20-amount-vc branch August 15, 2024 07:08
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