Skip to content

Commit

Permalink
Unique compliance query format (#95)
Browse files Browse the repository at this point in the history
* Unique structure format of querying states

* Generated ffi

* Add verification type in details

* Update ComplianceProxy contract for debug deployment
  • Loading branch information
deep-quality-dev authored May 29, 2024
1 parent 43ef1bf commit a4370d0
Show file tree
Hide file tree
Showing 16 changed files with 1,655 additions and 808 deletions.
378 changes: 201 additions & 177 deletions go-sgxvm/types/ffi.pb.go

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion go-sgxvm/types/node.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 10 additions & 8 deletions proto/swisstronik/compliance/entities.proto
Original file line number Diff line number Diff line change
Expand Up @@ -74,20 +74,22 @@ message Verification {
// VerificationDetails must have same members with VerificationDetails in "proto/swisstronik/compliance/entities.proto"
// But the member types can be different, such as string(address) to bytes
message VerificationDetails {
// Verification type
VerificationType type = 1;
// Verification issuer address
string issuer_address = 1;
string issuer_address = 2;
// From which chain proof was transferred
string origin_chain = 2;
string origin_chain = 3;
// Original issuance timestamp
uint32 issuance_timestamp = 3;
uint32 issuance_timestamp = 4;
// Original expiration timestamp
uint32 expiration_timestamp = 4;
uint32 expiration_timestamp = 5;
// Original proof data (ZK-proof)
bytes original_data = 5;
bytes original_data = 6;
// ZK-proof original schema
string schema = 6;
string schema = 7;
// Verification id for checking(KYC/KYB/AML etc) from issuer side
string issuer_verification_id = 7;
string issuer_verification_id = 8;
// Version
uint32 version = 8;
uint32 version = 9;
}
40 changes: 30 additions & 10 deletions proto/swisstronik/compliance/query.proto
Original file line number Diff line number Diff line change
Expand Up @@ -83,13 +83,17 @@ message QueryAddressesDetailsRequest {

// QueryAddressesDetailsResponse is response type for the Query/AddressesDetails RPC method.
message QueryAddressesDetailsResponse {
message AddressDetailsWithKey {
// MergedAddressDetails is merged structure of iterating key and `AddressDetails` in `entities.proto`.
// `address` is an iterating key, and the following items should be same with `AddressDetails`.
message MergedAddressDetails {
string address = 1;
AddressDetails addressDetails = 2;
bool is_verified = 2;
bool is_revoked = 3;
repeated Verification verifications = 4;
}

// addresses is a slice of registered addresses for the compliance module
repeated AddressDetailsWithKey addresses = 1 [(gogoproto.nullable) = false];
repeated MergedAddressDetails addresses = 1 [(gogoproto.nullable) = false];
// pagination defines the pagination in the response.
cosmos.base.query.v1beta1.PageResponse pagination = 2;
}
Expand All @@ -112,13 +116,19 @@ message QueryIssuersDetailsRequest {

// QueryIssuersDetailsResponse is response type for the Query/IssuersDetails RPC method.
message QueryIssuersDetailsResponse {
message IssuerDetailsWithKey {
// MergedIssuerDetails is merged structure of iterating key and `IssuerDetails` in `entities.proto`.
// `issuerAddress` is an iterating key, and the following items should be same with `IssuerDetails`.
message MergedIssuerDetails {
string issuerAddress = 1;
IssuerDetails issuerDetails = 2;
string name = 2;
string description = 3;
string url = 4;
string logo = 5;
string legalEntity = 6;
}

// issuers is a slice of registered issuers for the compliance module
repeated IssuerDetailsWithKey issuers = 1 [(gogoproto.nullable) = false];
repeated MergedIssuerDetails issuers = 1 [(gogoproto.nullable) = false];
// pagination defines the pagination in the response.
cosmos.base.query.v1beta1.PageResponse pagination = 2;
}
Expand All @@ -141,13 +151,23 @@ message QueryVerificationsDetailsRequest {

// QueryVerificationsDetailsResponse is response type for the Query/VerificationsDetails RPC method.
message QueryVerificationsDetailsResponse {
message VerificationDetailsWithKey {
bytes verificationID = 1;
VerificationDetails verificationDetails = 2;
// MergedVerificationDetails is merged structure of iterating key and `VerificationDetails` in `entities.proto`.
// `verification_type` and `verification_id` are iterating keys, and the following items should be same with `VerificationDetails`.
message MergedVerificationDetails {
VerificationType verificationType = 1;
bytes verificationID = 2;
string issuer_address = 3;
string origin_chain = 4;
uint32 issuance_timestamp = 5;
uint32 expiration_timestamp = 6;
bytes original_data = 7;
string schema = 8;
string issuer_verification_id = 9;
uint32 version = 10;
}

// verifications is a slice of registered verifications for the compliance module
repeated VerificationDetailsWithKey verifications = 1 [(gogoproto.nullable) = false];
repeated MergedVerificationDetails verifications = 1 [(gogoproto.nullable) = false];
// pagination defines the pagination in the response.
cosmos.base.query.v1beta1.PageResponse pagination = 2;
}
4 changes: 2 additions & 2 deletions scripts/debug/debug-precompile.sh

Large diffs are not rendered by default.

21 changes: 13 additions & 8 deletions sgxvm/proto/ffi.proto
Original file line number Diff line number Diff line change
Expand Up @@ -167,24 +167,29 @@ message QueryGetVerificationData {
bytes issuerAddress = 2;
}
// VerificationDetails must have same members with VerificationDetails in "sgxvm/proto/ffi.proto"
// including verification type and verification id as key.
// But the member types can be different, such as string(address) to bytes
message VerificationDetails {
// Verification type
uint32 verificationType = 1;
// Verification Id
bytes verificationID = 2;
// Verification issuer address
bytes issuerAddress = 1;
bytes issuerAddress = 3;
// From which chain proof was transferred
string originChain = 2;
string originChain = 4;
// Original issuance timestamp
uint32 issuanceTimestamp = 3;
uint32 issuanceTimestamp = 5;
// Original expiration timestamp
uint32 expirationTimestamp = 4;
uint32 expirationTimestamp = 6;
// Original proof data (ZK-proof)
bytes originalData = 5;
bytes originalData = 7;
// ZK-proof original schema
string schema = 6;
string schema = 8;
// Verification id for checking(KYC/KYB/AML etc) from issuer side
string issuerVerificationId = 7;
string issuerVerificationId = 9;
// Version
uint32 version = 8;
uint32 version = 10;
}
message QueryGetVerificationDataResponse {
repeated VerificationDetails data = 1;
Expand Down
2 changes: 2 additions & 0 deletions sgxvm/src/precompiles/compliance_bridge.rs
Original file line number Diff line number Diff line change
Expand Up @@ -415,6 +415,8 @@ fn route(
.flat_map(|log| {
let issuer_address = Address::from_slice(&log.issuerAddress);
let tokens = vec![AbiToken::Tuple(vec![
AbiToken::Uint(log.verificationType.into()),
AbiToken::Bytes(log.verificationID.clone().into()),
AbiToken::Address(issuer_address.clone()),
AbiToken::String(log.originChain.clone()),
AbiToken::Uint(log.issuanceTimestamp.into()),
Expand Down
Loading

0 comments on commit a4370d0

Please sign in to comment.