|
|
@@ -31,15 +31,15 @@ pub trait RpcClient {
|
|
|
|
|
|
/// transfer
|
|
|
#[rpc(name = "transfer")]
|
|
|
- fn transfer(&self, pub_key: Vec<u8>, amount: f64) -> BoxFuture<Result<String>>;
|
|
|
+ fn transfer(&self, asset_id: u64, pub_key: Vec<u8>, amount: f64) -> BoxFuture<Result<String>>;
|
|
|
|
|
|
/// withdraw
|
|
|
#[rpc(name = "withdraw")]
|
|
|
- fn withdraw(&self, pub_key: Vec<u8>, amount: f64) -> BoxFuture<Result<String>>;
|
|
|
+ fn withdraw(&self, asset_id: u64, pub_key: Vec<u8>, amount: f64) -> BoxFuture<Result<String>>;
|
|
|
|
|
|
/// deposit
|
|
|
#[rpc(name = "deposit")]
|
|
|
- fn deposit(&self) -> BoxFuture<Result<String>>;
|
|
|
+ fn deposit(&self, asset_id: u64) -> BoxFuture<Result<String>>;
|
|
|
}
|
|
|
|
|
|
pub struct RpcClientAdapter {
|
|
|
@@ -75,6 +75,7 @@ impl RpcClientAdapter {
|
|
|
|
|
|
async fn transfer_process(
|
|
|
client: Arc<Mutex<Client>>,
|
|
|
+ asset_id: u64,
|
|
|
address: Vec<u8>,
|
|
|
amount: f64,
|
|
|
) -> Result<String> {
|
|
|
@@ -89,7 +90,7 @@ impl RpcClientAdapter {
|
|
|
client
|
|
|
.lock()
|
|
|
.await
|
|
|
- .transfer(address.clone(), amount)
|
|
|
+ .transfer(asset_id, address.clone(), amount)
|
|
|
.await?;
|
|
|
|
|
|
Ok(format!("transfered {} DRK to {}", amount, address))
|
|
|
@@ -98,13 +99,14 @@ impl RpcClientAdapter {
|
|
|
async fn withdraw_process(
|
|
|
client: Arc<Mutex<Client>>,
|
|
|
cashier_client: Arc<Mutex<CashierClient>>,
|
|
|
+ asset_id: u64,
|
|
|
address: Vec<u8>,
|
|
|
amount: f64,
|
|
|
) -> Result<String> {
|
|
|
let drk_public = cashier_client
|
|
|
.lock()
|
|
|
.await
|
|
|
- .withdraw(1, address)
|
|
|
+ .withdraw(asset_id, address)
|
|
|
.await
|
|
|
.map_err(|err| ClientFailed::from(err))?;
|
|
|
|
|
|
@@ -112,7 +114,7 @@ impl RpcClientAdapter {
|
|
|
client
|
|
|
.lock()
|
|
|
.await
|
|
|
- .transfer(drk_addr.clone(), amount)
|
|
|
+ .transfer(asset_id, drk_addr.clone(), amount)
|
|
|
.await?;
|
|
|
|
|
|
return Ok(format!(
|
|
|
@@ -127,6 +129,7 @@ impl RpcClientAdapter {
|
|
|
async fn deposit_process<T>(
|
|
|
client: Arc<Mutex<Client>>,
|
|
|
cashier_client: Arc<Mutex<CashierClient>>,
|
|
|
+ asset_id: u64,
|
|
|
) -> Result<String>
|
|
|
where
|
|
|
T: Decodable + ToString,
|
|
|
@@ -135,7 +138,7 @@ impl RpcClientAdapter {
|
|
|
let coin_public = cashier_client
|
|
|
.lock()
|
|
|
.await
|
|
|
- .get_address(1, deposit_addr)
|
|
|
+ .get_address(asset_id, deposit_addr)
|
|
|
.await
|
|
|
.map_err(|err| ClientFailed::from(err))?;
|
|
|
|
|
|
@@ -169,28 +172,30 @@ impl RpcClient for RpcClientAdapter {
|
|
|
Self::key_gen_process(self.client.clone()).boxed()
|
|
|
}
|
|
|
|
|
|
- fn transfer(&self, pub_key: Vec<u8>, amount: f64) -> BoxFuture<Result<String>> {
|
|
|
+ fn transfer(&self, asset_id: u64, pub_key: Vec<u8>, amount: f64) -> BoxFuture<Result<String>> {
|
|
|
debug!(target: "RPC USER ADAPTER", "transfer() [START]");
|
|
|
- Self::transfer_process(self.client.clone(), pub_key, amount).boxed()
|
|
|
+ Self::transfer_process(self.client.clone(), asset_id, pub_key, amount).boxed()
|
|
|
}
|
|
|
|
|
|
- fn withdraw(&self, pub_key: Vec<u8>, amount: f64) -> BoxFuture<Result<String>> {
|
|
|
+ fn withdraw(&self, asset_id: u64, pub_key: Vec<u8>, amount: f64) -> BoxFuture<Result<String>> {
|
|
|
debug!(target: "RPC USER ADAPTER", "withdraw() [START]");
|
|
|
Self::withdraw_process(
|
|
|
self.client.clone(),
|
|
|
self.cashier_client.clone(),
|
|
|
+ asset_id,
|
|
|
pub_key,
|
|
|
amount,
|
|
|
)
|
|
|
.boxed()
|
|
|
}
|
|
|
|
|
|
- fn deposit(&self) -> BoxFuture<Result<String>> {
|
|
|
+ fn deposit(&self, asset_id: u64) -> BoxFuture<Result<String>> {
|
|
|
debug!(target: "RPC USER ADAPTER", "deposit() [START]");
|
|
|
#[cfg(feature = "default")]
|
|
|
Self::deposit_process::<bitcoin::PublicKey>(
|
|
|
self.client.clone(),
|
|
|
self.cashier_client.clone(),
|
|
|
+ asset_id,
|
|
|
)
|
|
|
.boxed()
|
|
|
}
|