Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 13 additions & 12 deletions backend/Cargo.lock

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

3 changes: 2 additions & 1 deletion backend/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ concordium-rwa-compliance = { path = "../contracts/compliance" }
concordium-rwa-market = { path = "../contracts/market" }
concordium-rwa-sponsor = { path = "../contracts/sponsor" }
concordium-rwa-utils = { path = "../contracts/utils" }
concordium-rust-sdk = "4.3.0"
concordium-rust-sdk = "6.0.0"
concordium-contracts-common = { version = "9.2.0" }
tokio = { version = "1.35.1", features = ["full"] }
anyhow = "1.0.79"
futures = "0.3"
Expand Down
1 change: 1 addition & 0 deletions backend/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"name": "backend",
"packageManager": "[email protected]",
"version": "1.0.0",
"scripts": {
"format": "cargo +nightly-2022-06-09 fmt",
"build": "cargo build --release",
Expand Down
13 changes: 5 additions & 8 deletions backend/src/verifier/api.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use super::{
db::{DbChallenge, VerifierDb},
identity_registry_client::{Error as IdentityRegistryError, IdentityRegistryClient},
identity_registry_client::{IdentityRegistryClient, IdentityRegistryClientError},
web3_id_utils::{
verify_presentation, CredStatement, GlobalContext, IdStatement, Presentation,
VerifyPresentationError,
Expand Down Expand Up @@ -41,17 +41,14 @@ impl From<anyhow::Error> for VerifierApiError {
impl From<AccountAddressParseError> for VerifierApiError {
fn from(_: AccountAddressParseError) -> Self { Self::BadRequest }
}
impl From<bson::ser::Error> for VerifierApiError {
fn from(_: bson::ser::Error) -> Self { Self::BadRequest }
}
impl From<QueryError> for VerifierApiError {
fn from(_: QueryError) -> Self { Self::InternalServer }
}
impl From<VerifyPresentationError> for VerifierApiError {
fn from(_: VerifyPresentationError) -> Self { VerifierApiError::BadRequest }
}
impl From<IdentityRegistryError> for VerifierApiError {
fn from(_: IdentityRegistryError) -> Self { VerifierApiError::InternalServer }
impl From<IdentityRegistryClientError> for VerifierApiError {
fn from(_: IdentityRegistryClientError) -> Self { VerifierApiError::InternalServer }
}
#[derive(Object)]
pub struct GenerateChallengeRequest {
Expand Down Expand Up @@ -185,7 +182,7 @@ impl VerifierApi {
&proof,
challenge,
)
.await?;
.await?/*Bad Request*/;
debug!("Revealed Id Attributes: {:?}", verification_response.revealed_attributes);
debug!("Credentials: {:?}", verification_response.credentials);

Expand Down Expand Up @@ -228,7 +225,7 @@ impl VerifierApi {
verification_response,
*max_energy,
)
.await?;
.await?/*Internal Server Error*/;

debug!("Register Identity Transaction Hash: {}", txn.to_string());
Ok(Json(RegisterIdentityResponse {
Expand Down
42 changes: 21 additions & 21 deletions backend/src/verifier/identity_registry_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ use super::web3_id_utils::VerifyPresentationResponse;

/// Errors that can occur when interacting with the Identity Registry contract.
#[derive(Debug)]
pub enum Error {
pub enum IdentityRegistryClientError {
ParamsSerialization,
AccountInfoQuery(v2::QueryError),
TransactionSend(v2::RPCError),
Expand All @@ -31,28 +31,28 @@ pub enum Error {
ExceedsParameterSize(ExceedsParameterSize),
}

impl From<v2::QueryError> for Error {
fn from(e: v2::QueryError) -> Self { Error::ClientQuery(e) }
impl From<v2::QueryError> for IdentityRegistryClientError {
fn from(e: v2::QueryError) -> Self { IdentityRegistryClientError::ClientQuery(e) }
}

impl From<NewReceiveNameError> for Error {
fn from(e: NewReceiveNameError) -> Self { Error::ReceiveName(e) }
impl From<NewReceiveNameError> for IdentityRegistryClientError {
fn from(e: NewReceiveNameError) -> Self { IdentityRegistryClientError::ReceiveName(e) }
}

impl From<RejectReason> for Error {
fn from(e: RejectReason) -> Self { Error::InvokeInstance(e) }
impl From<RejectReason> for IdentityRegistryClientError {
fn from(e: RejectReason) -> Self { IdentityRegistryClientError::InvokeInstance(e) }
}

impl From<ParseError> for Error {
fn from(e: ParseError) -> Self { Error::Parse(e) }
impl From<ParseError> for IdentityRegistryClientError {
fn from(e: ParseError) -> Self { IdentityRegistryClientError::Parse(e) }
}

impl From<v2::RPCError> for Error {
fn from(e: v2::RPCError) -> Self { Error::Rpc(e) }
impl From<v2::RPCError> for IdentityRegistryClientError {
fn from(e: v2::RPCError) -> Self { IdentityRegistryClientError::Rpc(e) }
}

impl From<ExceedsParameterSize> for Error {
fn from(e: ExceedsParameterSize) -> Self { Error::ExceedsParameterSize(e) }
impl From<ExceedsParameterSize> for IdentityRegistryClientError {
fn from(e: ExceedsParameterSize) -> Self { IdentityRegistryClientError::ExceedsParameterSize(e) }
}

/// A client for the Identity Registry contract.
Expand Down Expand Up @@ -82,10 +82,10 @@ impl IdentityRegistryClient {
}
}

pub async fn is_agent(&mut self, agent: &Address) -> Result<bool, Error> {
pub async fn is_agent(&mut self, agent: &Address) -> Result<bool, IdentityRegistryClientError> {
let res = self
.client
.view_raw::<bool, Error>(
.view_raw::<bool, IdentityRegistryClientError>(
"isAgent",
OwnedParameter::from_serial(agent).unwrap(),
BlockIdentifier::LastFinal,
Expand All @@ -103,10 +103,10 @@ impl IdentityRegistryClient {
///
/// * A Result containing a vector of `ContractAddress`es representing the
/// issuers, or an `Error`.
pub async fn issuers(&mut self) -> Result<Vec<ContractAddress>, Error> {
pub async fn issuers(&mut self) -> Result<Vec<ContractAddress>, IdentityRegistryClientError> {
let res = self
.client
.view_raw::<Vec<ContractAddress>, Error>(
.view_raw::<Vec<ContractAddress>, IdentityRegistryClientError>(
"issuers",
OwnedParameter::empty(),
BlockIdentifier::LastFinal,
Expand Down Expand Up @@ -135,7 +135,7 @@ impl IdentityRegistryClient {
address: Address,
verification_response: VerifyPresentationResponse,
energy: Energy,
) -> Result<TransactionHash, Error> {
) -> Result<TransactionHash, IdentityRegistryClientError> {
let AccountInfo {
account_nonce,
..
Expand All @@ -144,7 +144,7 @@ impl IdentityRegistryClient {
.client
.get_account_info(&agent.address.into(), BlockIdentifier::LastFinal)
.await
.map_err(Error::AccountInfoQuery)?
.map_err(IdentityRegistryClientError::AccountInfoQuery)?
.response;
let register_identity_payload = RegisterIdentityParams {
address,
Expand All @@ -158,7 +158,7 @@ impl IdentityRegistryClient {
value: value.to_string(),
})
})
.collect::<Result<Vec<_>, Error>>()?,
.collect::<Result<Vec<_>, IdentityRegistryClientError>>()?,
credentials: verification_response
.credentials
.iter()
Expand All @@ -171,7 +171,7 @@ impl IdentityRegistryClient {
};
let txn = self
.client
.update::<_, Error>(
.update::<_, IdentityRegistryClientError>(
&agent.keys,
&ContractTransactionMetadata {
nonce: account_nonce,
Expand Down
7 changes: 5 additions & 2 deletions backend/src/verifier/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ use concordium_rust_sdk::{
web3id::{did::Network, Web3IdAttribute},
};
use futures::{StreamExt, TryStreamExt};
use log::{debug, info};
use log::{debug, info, warn};
use poem::{
listener::TcpListener,
middleware::{AddData, Cors},
Expand Down Expand Up @@ -109,7 +109,10 @@ async fn create_server_routes(config: ApiConfig) -> anyhow::Result<impl poem::En
e
))
})?;
assert!(is_agent, "provided agent wallet is not an agent in identity registry");
// assert!(is_agent, "provided agent wallet is not an agent in identity registry");
if !is_agent {
warn!("provided agent wallet is not an agent in identity registry");
}

let now = chrono::Utc::now();
let year = u64::try_from(now.year()).ok().unwrap();
Expand Down
1 change: 1 addition & 0 deletions contracts/integration-tests/package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"name": "integration-tests",
"version": "1.0.0",
"packageManager": "[email protected]",
"scripts": {
"test": "cargo concordium test",
Expand Down
4 changes: 2 additions & 2 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ services:
- ./data:/data/db
ports:
- 27017:27017

mongo-express:
image: mongo-express
restart: always
Expand All @@ -18,4 +18,4 @@ services:
environment:
ME_CONFIG_MONGODB_ADMINUSERNAME: root
ME_CONFIG_MONGODB_ADMINPASSWORD: example
ME_CONFIG_MONGODB_URL: mongodb://root:example@mongo:27017/
ME_CONFIG_MONGODB_URL: mongodb://root:example@mongo:27017/
12 changes: 6 additions & 6 deletions docs/workflow.README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,14 @@ git clone [email protected]:chainorders/concordium-rwa.git
git submodule update --init --recursive
cd concordium-rwa
yarn
cp /home/parv0888/Downloads/3ab35yTaTTK8xr4jSBDBmMYAf9V8s5zVZAR86Rah1daX3uA39Q.export ./backend/verifier_wallet.export
cp /home/parv0888/Downloads/3ab35yTaTTK8xr4jSBDBmMYAf9V8s5zVZAR86Rah1daX3uA39Q.export ./backend/sponsor_wallet.export
cp /home/parv0888/Downloads/3ab35yTaTTK8xr4jSBDBmMYAf9V8s5zVZAR86Rah1daX3uA39Q.export ../backend/verifier_wallet.export
cp /home/parv0888/Downloads/3ab35yTaTTK8xr4jSBDBmMYAf9V8s5zVZAR86Rah1daX3uA39Q.export ../backend/sponsor_wallet.export
docker compose up -d
```

### VS Code

* Update Starting Block hash in the [backend env file](./backend/.env). *this is an optional step if not set the system would start from current consensus block*
* Update Starting Block hash in the [backend env file](../backend/.env). *this is an optional step if not set the system would start from current consensus block*
* `STARTING_BLOCK_HASH`=ebcb1b1a919b6ef55b707e6eb8b373f587869820f263d3ae3db9878b470bed84

* Generate Frontend Clients & Start the contract api
Expand All @@ -45,11 +45,11 @@ docker compose up -d

* Selected Account `47fb97YAZtEEYNpaWz3ccrUCwqEnNfm2qQXiUGHEJ52Fiu7AVi`
* Initialize Identity Registry : 8176
* Add Identity Registry Agent take account address from the [wallet file](./backend/agent_wallet.export)
* Add Identity Registry Agent take account address from the [wallet file](../backend/agent_wallet.export)

### VS Code

* Update env variables in [backend env file](./backend/.env)
* Update env variables in [backend env file](../backend/.env)
* `IDENTITY_REGISTRY`

### Terminal
Expand Down Expand Up @@ -95,7 +95,7 @@ docker compose up -d
* `VITE_NFT_SFT_CONTRACT_INDEX=8185`
* `VITE_MARKET_CONTRACT_INDEX=8186`
* `VITE_SPONSOR_CONTRACT_INDEX=8179`
* Update [backend env variables](./backend/.env)
* Update [backend env variables](../backend/.env)
* `SPONSOR_CONTRACT=<8179,0>`

### Terminal
Expand Down
Loading