Add mapping with additional blockchain info to instance API response
This commit is contained in:
parent
6172d309bc
commit
6b06d6d18e
5 changed files with 15 additions and 0 deletions
|
@ -13,6 +13,7 @@ registrations_open: true
|
|||
blockchain:
|
||||
# Parameters for hardhat local node
|
||||
chain_id: eip155:31337
|
||||
chain_info: null
|
||||
contract_address: '0xDc64a140Aa3E981100a9becA4E685f962f0cF6C9'
|
||||
contract_dir: contracts
|
||||
api_url: 'http://127.0.0.1:8546'
|
||||
|
|
|
@ -27,8 +27,10 @@ registrations_open: false
|
|||
#blocked_instances: []
|
||||
|
||||
# Blockchain integration
|
||||
# Signing key for ethereum integration can be generated with `mitractl generate-ethereum-address`
|
||||
#blockchain:
|
||||
# chain_id: eip155:31337
|
||||
# chain_info: null
|
||||
# contract_address: '0xDc64a140Aa3E981100a9becA4E685f962f0cF6C9'
|
||||
# contract_dir: /usr/share/mitra/contracts
|
||||
# api_url: 'http://127.0.0.1:8545'
|
||||
|
|
|
@ -775,6 +775,10 @@ components:
|
|||
description: Blockchain contract address.
|
||||
type: string
|
||||
nullable: true
|
||||
blockchain_info:
|
||||
description: Additional information about blockchain
|
||||
type: object
|
||||
nullable: true
|
||||
ipfs_gateway_url:
|
||||
description: IPFS gateway URL.
|
||||
type: string
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
use std::collections::HashMap;
|
||||
use std::path::{Path, PathBuf};
|
||||
use std::str::FromStr;
|
||||
|
||||
|
@ -82,6 +83,8 @@ fn default_post_character_limit() -> usize { 2000 }
|
|||
pub struct BlockchainConfig {
|
||||
// CAIP-2 chain ID (https://github.com/ChainAgnostic/CAIPs/blob/master/CAIPs/caip-2.md)
|
||||
pub chain_id: String,
|
||||
// Additional information for clients
|
||||
pub chain_info: Option<HashMap<String, String>>,
|
||||
pub contract_address: String,
|
||||
pub contract_dir: PathBuf,
|
||||
pub api_url: String,
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
use std::collections::HashMap;
|
||||
|
||||
use serde::Serialize;
|
||||
|
||||
use crate::config::Config;
|
||||
|
@ -17,6 +19,7 @@ pub struct InstanceInfo {
|
|||
blockchain_id: Option<String>,
|
||||
blockchain_explorer_url: Option<String>,
|
||||
blockchain_contract_address: Option<String>,
|
||||
blockchain_info: Option<HashMap<String, String>>,
|
||||
ipfs_gateway_url: Option<String>,
|
||||
}
|
||||
|
||||
|
@ -45,6 +48,8 @@ impl From<&Config> for InstanceInfo {
|
|||
.and_then(|val| val.explorer_url.clone()),
|
||||
blockchain_contract_address: config.blockchain.as_ref()
|
||||
.map(|val| val.contract_address.clone()),
|
||||
blockchain_info: config.blockchain.as_ref()
|
||||
.and_then(|val| val.chain_info.clone()),
|
||||
ipfs_gateway_url: config.ipfs_gateway_url.clone(),
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue