diff --git a/bindings/nodejs/README.md b/bindings/nodejs/README.md index 006d0f572..4ec5808d3 100644 --- a/bindings/nodejs/README.md +++ b/bindings/nodejs/README.md @@ -339,6 +339,28 @@ Gets the utxo changes by the given milestone index. **Returns** a promise resolving to the [MilestoneUTXOChanges](#MilestoneUTXOChanges). +#### getReceipts(): Promise + +Get all receipts. + +**Returns** a promise resolving to the [Receipts](#Receipts). + +#### getReceiptsMigratedAt(index): Promise + +Get all receipts for a given milestone index + +| Param | Type | Description | +| ----- | ------------------- | -------------------------- | +| index | number | The index of the milestone | + +**Returns** a promise resolving to the [Receipts](#Receipts). + +#### getTreasury(): Promise + +Get the treasury amount. + +**Returns** a promise resolving to the [Treasury](#Treasury). + #### reattach(messageId): Promise Reattaches the message associated with the given id. @@ -730,12 +752,10 @@ Gets the metadata of the given message. - UnlockBlock -| Field | Type | Description | -| ----- | ------------------------------------------------------------------------------ | ----------------------------------------------------- | -| type | 'Signature' \| 'Reference' | Unlock block type identifier | -| data | WotsSignatureUnlockBlock \| Ed25519SignatureUnlockBlock \| number | Unlock block data (signature type or reference index) | - -- WotsSignatureUnlockBlock = number[] (WOTS signature) +| Field | Type | Description | +| ----- | -------------------------------------------------- | ----------------------------------------------------- | +| type | 'Signature' \| 'Reference' | Unlock block type identifier | +| data | Ed25519SignatureUnlockBlock \| number | Unlock block data (signature type or reference index) | - Ed25519SignatureUnlockBlock @@ -807,9 +827,7 @@ Gets the metadata of the given message. | Field | Type | Description | | ----- | ------------------------------------------------------------------------------------ | ----------------------------------------------------- | -| data | WotsSignatureUnlockBlockDto \| Ed25519SignatureUnlockBlockDto \| number | Unlock block data (signature type or reference index) | - -- WotsSignatureUnlockBlockDto = number[] (WOTS signature) +| data | Ed25519SignatureUnlockBlockDto \| number | Unlock block data (signature type or reference index) | - Ed25519SignatureUnlockBlockDto @@ -877,3 +895,17 @@ Gets the metadata of the given message. | index | number | Milestone index | | createdOutputs | string[] | OutputIds from new created outputs | | consumedOutputs | string[] | OutputIds from consumed outputs | + +### Receipts + +| Field | Type | Description | +| --------------- | -------------------- | --------------- | +| receipt | receipt | Receipt | +| milestone_index | number | Milestone index | + +### Treasury + +| Field | Type | Description | +| ------------- | ------------------- | ------------ | +| milestone_id | string | Milestone id | +| amount | number | Amount | diff --git a/bindings/nodejs/lib/index.d.ts b/bindings/nodejs/lib/index.d.ts index d92f09c80..72fba8d5b 100644 --- a/bindings/nodejs/lib/index.d.ts +++ b/bindings/nodejs/lib/index.d.ts @@ -96,6 +96,9 @@ export declare class Client { getAddressBalance(address: string): Promise getMilestone(index: number): Promise getMilestoneUTXOChanges(index: number): Promise + getReceipts(): Promise + getReceiptsMigratedAt(index: number): Promise + getTreasury(): Promise reattach(messageId: string): Promise promote(messageId: string): Promise } diff --git a/bindings/nodejs/lib/index.js b/bindings/nodejs/lib/index.js index 50e676b85..8867f05a6 100644 --- a/bindings/nodejs/lib/index.js +++ b/bindings/nodejs/lib/index.js @@ -93,6 +93,9 @@ Client.prototype.getAddressOutputs = function (address, options) { Client.prototype.getAddressBalance = promisify(Client.prototype.getAddressBalance) Client.prototype.getMilestone = promisify(Client.prototype.getMilestone) Client.prototype.getMilestoneUTXOChanges = promisify(Client.prototype.getMilestoneUTXOChanges) +Client.prototype.getReceipts = promisify(Client.prototype.getReceipts) +Client.prototype.getReceiptsMigratedAt = promisify(Client.prototype.getReceiptsMigratedAt) +Client.prototype.getTreasury = promisify(Client.prototype.getTreasury) Client.prototype.retry = promisify(Client.prototype.retry) Client.prototype.reattach = promisify(Client.prototype.reattach) Client.prototype.promote = promisify(Client.prototype.promote) diff --git a/bindings/nodejs/lib/types/message.d.ts b/bindings/nodejs/lib/types/message.d.ts index a785c2f80..952d78b15 100644 --- a/bindings/nodejs/lib/types/message.d.ts +++ b/bindings/nodejs/lib/types/message.d.ts @@ -27,7 +27,7 @@ export declare interface Ed25519SignatureUnlockBlock { export declare interface SignatureUnlockBlock { type: 'Signature' - data: WotsSignatureUnlockBlock | Ed25519SignatureUnlockBlock + data: Ed25519SignatureUnlockBlock } export declare interface ReferenceUnlockBlock { diff --git a/bindings/nodejs/native/src/classes/client/api.rs b/bindings/nodejs/native/src/classes/client/api.rs index bd7a530e5..19a880d62 100644 --- a/bindings/nodejs/native/src/classes/client/api.rs +++ b/bindings/nodejs/native/src/classes/client/api.rs @@ -63,6 +63,9 @@ pub(crate) enum Api { GetAddressOutputs(Bech32Address, AddressOutputsOptions), GetMilestone(u32), GetMilestoneUTXOChanges(u32), + GetReceipts(), + GetReceiptsMigratedAt(u32), + GetTreasury(), Retry(MessageId), Reattach(MessageId), Promote(MessageId), @@ -278,6 +281,18 @@ impl Task for ClientTask { let milestone_utxo_changes = client.get_milestone_utxo_changes(*index).await?; serde_json::to_string(&milestone_utxo_changes).unwrap() } + Api::GetReceipts() => { + let receipts = client.get_receipts().await?; + serde_json::to_string(&receipts).unwrap() + } + Api::GetReceiptsMigratedAt(index) => { + let receipts = client.get_receipts_migrated_at(*index).await?; + serde_json::to_string(&receipts).unwrap() + } + Api::GetTreasury() => { + let treasury = client.get_treasury().await?; + serde_json::to_string(&treasury).unwrap() + } Api::Retry(message_id) => { let message = client.retry(message_id).await?; serde_json::to_string(&MessageWrapper { diff --git a/bindings/nodejs/native/src/classes/client/mod.rs b/bindings/nodejs/native/src/classes/client/mod.rs index 01b8085fb..ca97afcd9 100644 --- a/bindings/nodejs/native/src/classes/client/mod.rs +++ b/bindings/nodejs/native/src/classes/client/mod.rs @@ -474,6 +474,58 @@ declare_types! { Ok(cx.undefined().upcast()) } + method getReceipts(mut cx) { + + let cb = cx.argument::(0)?; + { + let this = cx.this(); + let guard = cx.lock(); + let id = &this.borrow(&guard).0; + let client_task = ClientTask { + client_id: id.clone(), + api: Api::GetReceipts(), + }; + client_task.schedule(cb); + } + + Ok(cx.undefined().upcast()) + } + + method getReceiptsMigratedAt(mut cx) { + let milestone_index = cx.argument::(0)?.value() as u32; + + let cb = cx.argument::(1)?; + { + let this = cx.this(); + let guard = cx.lock(); + let id = &this.borrow(&guard).0; + let client_task = ClientTask { + client_id: id.clone(), + api: Api::GetReceiptsMigratedAt(milestone_index), + }; + client_task.schedule(cb); + } + + Ok(cx.undefined().upcast()) + } + + method getTreasury(mut cx) { + + let cb = cx.argument::(0)?; + { + let this = cx.this(); + let guard = cx.lock(); + let id = &this.borrow(&guard).0; + let client_task = ClientTask { + client_id: id.clone(), + api: Api::GetTreasury(), + }; + client_task.schedule(cb); + } + + Ok(cx.undefined().upcast()) + } + method reattach(mut cx) { let message_id = cx.argument::(0)?.value(); let message_id = MessageId::from_str(message_id.as_str()).expect("invalid message id"); diff --git a/bindings/python/README.md b/bindings/python/README.md index 8a29b0bee..b27bd659c 100644 --- a/bindings/python/README.md +++ b/bindings/python/README.md @@ -286,6 +286,28 @@ Gets the utxo changes by the given milestone index. **Returns** the [MilestoneUTXOChanges](#milestoneutxochanges). +#### get_receipts(): Vec + +Get all receipts. + +**Returns** the [ReceiptDto](#ReceiptDto). + +#### get_receipts_migrated_at(index): Vec + +Get all receipts for a given milestone index. + +| Param | Type | Default | Description | +| ------- | ---------------- | ---------------------- | -------------------------- | +| [index] | int | undefined | The index of the milestone | + +**Returns** the [ReceiptDto](#ReceiptDto). + +#### get_treasury(): TreasuryResponse + +Get the treasury amount. + +**Returns** the [TreasuryResponse](#TreasuryResponse). + ### High-Level APIs #### message(seed (optional), account_index (optional), initial_address_index (optional), inputs (optional), input_range_begin (optional), input_range_end (optional), outputs (optional), dust_allowance_outputs (optional), index (optional), index_raw (optional), data (optional), data_str (optional), parents (optional)): Message @@ -542,6 +564,28 @@ milestone_utxo_changes = { } ``` +#### ReceiptDto + +A dict with the following key/value pairs. + +```python +receiptDto = { + 'receipt': Receipt, + 'milestone_index': int, +} +``` + +#### TreasuryResponse + +A dict with the following key/value pairs. + +```python +treasuryResponse = { + 'milestone_id': str, + 'amount': int, +} +``` + #### UTXOInput A dict with the following key/value pairs. diff --git a/bindings/python/native/src/client/full_node_api.rs b/bindings/python/native/src/client/full_node_api.rs index ed6528f0c..8d26c38c2 100644 --- a/bindings/python/native/src/client/full_node_api.rs +++ b/bindings/python/native/src/client/full_node_api.rs @@ -3,7 +3,7 @@ use crate::client::{ error::Result, AddressOutputsOptions, BalanceForAddressResponse, Client, InfoResponse, Message, MilestoneDto, - MilestoneUTXOChanges, OutputResponse, PeerDto, UTXOInput, + MilestoneUTXOChanges, OutputResponse, PeerDto, ReceiptDto, TreasuryResponse, UTXOInput, }; use iota::{ Bech32Address as RustBech32Address, ClientMiner as RustClientMiner, MessageBuilder as RustMessageBuilder, @@ -127,4 +127,26 @@ impl Client { .block_on(async { self.client.get_milestone_utxo_changes(index).await })? .into()) } + fn get_receipts(&self) -> Result> { + let rt = tokio::runtime::Runtime::new()?; + let receipts: Vec = rt + .block_on(async { self.client.get_receipts().await })? + .into_iter() + .map(|r| r.into()) + .collect(); + Ok(receipts) + } + fn get_receipts_migrated_at(&self, index: u32) -> Result> { + let rt = tokio::runtime::Runtime::new()?; + let receipts: Vec = rt + .block_on(async { self.client.get_receipts_migrated_at(index).await })? + .into_iter() + .map(|r| r.into()) + .collect(); + Ok(receipts) + } + fn get_treasury(&self) -> Result { + let rt = tokio::runtime::Runtime::new()?; + Ok(rt.block_on(async { self.client.get_treasury().await })?.into()) + } } diff --git a/bindings/python/native/src/client/mod.rs b/bindings/python/native/src/client/mod.rs index 5765d6f3b..d9169c938 100644 --- a/bindings/python/native/src/client/mod.rs +++ b/bindings/python/native/src/client/mod.rs @@ -11,8 +11,8 @@ use pyo3::prelude::*; use std::{collections::HashMap, time::Duration}; use types::{ AddressBalancePair, AddressOutputsOptions, BalanceForAddressResponse, BrokerOptions, InfoResponse, Input, Message, - MessageMetadataResponse, MilestoneDto, MilestoneUTXOChanges, Output, OutputResponse, PeerDto, UTXOInput, - BECH32_HRP, + MessageMetadataResponse, MilestoneDto, MilestoneUTXOChanges, Output, OutputResponse, PeerDto, ReceiptDto, + TreasuryResponse, UTXOInput, BECH32_HRP, }; /// Client builder diff --git a/bindings/python/native/src/client/types.rs b/bindings/python/native/src/client/types.rs index dc0dd7d1f..2164c3a75 100644 --- a/bindings/python/native/src/client/types.rs +++ b/bindings/python/native/src/client/types.rs @@ -15,14 +15,18 @@ use iota::{ }, milestone_utxo_changes::MilestoneUtxoChanges as RustMilestoneUTXOChanges, output::OutputResponse as RustOutputResponse, + treasury::TreasuryResponse as RustTreasuryResponse, }, types::{ AddressDto as RustAddressDto, Ed25519AddressDto as RustEd25519AddressDto, GossipDto as RustgossipDto, - HeartbeatDto as RustheartbeatDto, MetricsDto as RustMetricsDto, OutputDto as RustOutputDto, - PeerDto as RustPeerDto, RelationDto as RustRelationDto, + HeartbeatDto as RustheartbeatDto, InputDto as RustInputDto, MetricsDto as RustMetricsDto, + MigratedFundsEntryDto as RustMigratedFundsEntryDto, OutputDto as RustOutputDto, + PayloadDto as RustPayloadDto, PeerDto as RustPeerDto, ReceiptDto as RustReceiptDto, + ReceiptPayloadDto as RustReceiptPayloadDto, RelationDto as RustRelationDto, SignatureLockedDustAllowanceOutputDto as RustSignatureLockedDustAllowanceOutputDto, SignatureLockedSingleOutputDto as RustSignatureLockedSingleOutputDto, TreasuryOutputDto as RustTreasuryOutputDto, + TreasuryTransactionPayloadDto as RustTreasuryTransactionPayloadDto, }, }, builder::NetworkInfo as RustNetworkInfo, @@ -92,11 +96,22 @@ pub struct MilestoneUTXOChanges { pub consumed_outputs: Vec, } +#[derive(Debug, Clone, DeriveFromPyObject, DeriveIntoPyObject)] +pub struct InputDto { + pub utxo: Option, + pub treasury: Option, +} + #[derive(Debug, Clone, DeriveFromPyObject, DeriveIntoPyObject)] pub struct UTXOInput { pub transaction_id: Vec, pub index: u16, } +#[derive(Debug, Clone, DeriveFromPyObject, DeriveIntoPyObject)] +pub struct TreasuryInput { + pub kind: u8, + pub message_id: String, +} #[derive(Debug, Clone, DeriveFromPyObject, DeriveIntoPyObject)] pub struct OutputResponse { @@ -109,9 +124,9 @@ pub struct OutputResponse { #[derive(Debug, Clone, DeriveFromPyObject, DeriveIntoPyObject)] pub struct OutputDto { - treasury: Option, - signature_locked_single: Option, - signature_locked_dust_allowance: Option, + pub treasury: Option, + pub signature_locked_single: Option, + pub signature_locked_dust_allowance: Option, } #[derive(Debug, Clone, DeriveFromPyObject, DeriveIntoPyObject)] @@ -190,6 +205,12 @@ pub struct Indexation { pub data: Vec, } +#[derive(Debug, DeriveFromPyObject, DeriveIntoPyObject)] +pub struct ReceiptDto { + pub receipt: Receipt, + pub milestone_index: u32, +} + #[derive(Debug, Clone, DeriveFromPyObject, DeriveIntoPyObject)] pub struct Receipt { pub kind: u32, @@ -201,15 +222,15 @@ pub struct Receipt { #[derive(Debug, Clone, DeriveFromPyObject, DeriveIntoPyObject)] pub struct MigratedFundsEntry { - tail_transaction_hash: Vec, - output: SignatureLockedSingleOutputDto, + pub tail_transaction_hash: Vec, + pub output: SignatureLockedSingleOutputDto, } #[derive(Debug, Clone, DeriveFromPyObject, DeriveIntoPyObject)] pub struct TreasuryTransaction { pub kind: u32, - pub input: Input, - pub output: Output, + pub input: InputDto, + pub output: OutputDto, } #[derive(Debug, Clone, DeriveFromPyObject, DeriveIntoPyObject)] @@ -333,6 +354,21 @@ pub struct MetricsDto { pub dropped_packets: u64, } +#[derive(Debug, DeriveFromPyObject, DeriveIntoPyObject)] +pub struct TreasuryResponse { + pub milestone_id: String, + pub amount: u64, +} + +impl From for TreasuryResponse { + fn from(treasury: RustTreasuryResponse) -> Self { + Self { + milestone_id: treasury.milestone_id, + amount: treasury.amount, + } + } +} + impl From for OutputResponse { fn from(output: RustOutputResponse) -> Self { Self { @@ -961,7 +997,7 @@ impl TryFrom for RustPayload { let unlock_blocks: Result> = unlock_blocks.to_vec().into_iter().map(|u| u.try_into()).collect(); - transaction = transaction.with_unlock_blocks(RustUnlockBlocks::new(unlock_blocks?.into())?); + transaction = transaction.with_unlock_blocks(RustUnlockBlocks::new(unlock_blocks?)?); Ok(RustPayload::Transaction(Box::new(transaction.finish()?))) } else { @@ -985,6 +1021,70 @@ impl TryFrom for RustPayload { } } +impl From for ReceiptDto { + fn from(receipt: RustReceiptDto) -> Self { + Self { + receipt: receipt.receipt.into(), + milestone_index: receipt.milestone_index, + } + } +} + +impl From for Receipt { + fn from(receipt: RustReceiptPayloadDto) -> Self { + let payload = match receipt.transaction { + RustPayloadDto::TreasuryTransaction(payload) => *payload, + _ => panic!("Invalid payload"), + }; + Self { + kind: receipt.kind, + index: receipt.index, + last: receipt.last, + funds: receipt.funds.into_iter().map(|r| r.into()).collect(), + transaction: Payload { + transaction: None, + milestone: None, + indexation: None, + receipt: None, + treasury_transaction: Some(vec![payload.into()]), + }, + } + } +} + +impl From for MigratedFundsEntry { + fn from(receipt: RustMigratedFundsEntryDto) -> Self { + Self { + tail_transaction_hash: receipt.tail_transaction_hash.to_vec(), + output: SignatureLockedSingleOutputDto { + kind: 0, + address: receipt.address.into(), + amount: receipt.amount, + }, + } + } +} + +impl From for TreasuryTransaction { + fn from(treasury: RustTreasuryTransactionPayloadDto) -> Self { + let treasury_input = match treasury.input { + RustInputDto::Treasury(t) => TreasuryInput { + kind: t.kind, + message_id: t.message_id, + }, + RustInputDto::UTXO(_) => panic!("Invalid type"), + }; + Self { + kind: treasury.kind, + input: InputDto { + utxo: None, + treasury: Some(treasury_input), + }, + output: treasury.output.into(), + } + } +} + #[derive(Debug, Clone, DeriveFromPyObject, DeriveIntoPyObject)] pub struct AddressOutputsOptions { include_spent: bool, diff --git a/iota-client/Cargo.toml b/iota-client/Cargo.toml index cedcdf645..096ac2b6e 100644 --- a/iota-client/Cargo.toml +++ b/iota-client/Cargo.toml @@ -18,9 +18,9 @@ name = "iota_client" # bee-pow = { git = "https://github.com/iotaledger/bee.git", branch = "chrysalis-pt-2" } # bee-common-derive = { git = "https://github.com/iotaledger/bee.git", branch = "dev" } # bee-crypto = { git = "https://github.com/iotaledger/bee.git", branch = "dev" } -bee-rest-api = { git = "https://github.com/iotaledger/bee.git", rev = "6a3ac5d7475a8f13289da4bdc8c920e4d4b97c04" } -bee-message = { git = "https://github.com/iotaledger/bee.git", rev = "6a3ac5d7475a8f13289da4bdc8c920e4d4b97c04" } -bee-pow = { git = "https://github.com/iotaledger/bee.git", rev = "6a3ac5d7475a8f13289da4bdc8c920e4d4b97c04" } +bee-rest-api = { git = "https://github.com/iotaledger/bee.git", rev = "7e0cbe4e06b655d8358f8b5a145b1b78a51fbca1" } +bee-message = { git = "https://github.com/iotaledger/bee.git", rev = "7e0cbe4e06b655d8358f8b5a145b1b78a51fbca1" } +bee-pow = { git = "https://github.com/iotaledger/bee.git", rev = "7e0cbe4e06b655d8358f8b5a145b1b78a51fbca1" } bee-common = { git = "https://github.com/iotaledger/bee.git", branch = "dev" } bee-crypto = { git = "https://github.com/iotaledger/bee.git", rev = "c42171ff33c80cc2efb183e244dc79b7f58d9ac4" } iota-crypto = { git = "https://github.com/iotaledger/crypto.rs.git", rev = "527392202e78fa35620a9b30061d5e231a046ea2", features = ["blake2b", "ed25519", "random", "slip10"]} diff --git a/iota-client/src/builder.rs b/iota-client/src/builder.rs index 81eabb53a..17ff54773 100644 --- a/iota-client/src/builder.rs +++ b/iota-client/src/builder.rs @@ -92,9 +92,9 @@ impl ClientBuilder { pub fn with_node_auth(mut self, url: &str, name: &str, password: &str) -> Result { let mut url = Url::parse(url)?; url.set_username(name) - .map_err(|_| crate::Error::UrlAuthError("username".into()))?; + .map_err(|_| crate::Error::UrlAuthError("username".to_string()))?; url.set_password(Some(password)) - .map_err(|_| crate::Error::UrlAuthError("password".into()))?; + .map_err(|_| crate::Error::UrlAuthError("password".to_string()))?; self.nodes.insert(url); Ok(self) } diff --git a/iota-client/src/client.rs b/iota-client/src/client.rs index ed68e408c..062dfe317 100644 --- a/iota-client/src/client.rs +++ b/iota-client/src/client.rs @@ -17,9 +17,9 @@ use bee_rest_api::{ balance_ed25519::BalanceForAddressResponse, info::InfoResponse as NodeInfo, milestone::MilestoneResponse as MilestoneResponseDto, milestone_utxo_changes::MilestoneUtxoChanges as MilestoneUTXOChanges, output::OutputResponse, - tips::TipsResponse, + receipt::ReceiptsResponse, tips::TipsResponse, treasury::TreasuryResponse, }, - types::{MessageDto, PeerDto}, + types::{MessageDto, PeerDto, ReceiptDto}, }; use crypto::{ hashes::{blake2b::Blake2b256, Digest}, @@ -716,6 +716,68 @@ impl Client { Ok(resp.data) } + /// GET /api/v1/receipts endpoint + /// Get all receipts. + pub async fn get_receipts(&self) -> Result> { + let mut url = self.get_node()?; + let path = &"api/v1/receipts"; + url.set_path(path); + #[derive(Debug, Serialize, Deserialize)] + struct ResponseWrapper { + data: ReceiptsResponseWrapper, + } + #[derive(Debug, Serialize, Deserialize)] + struct ReceiptsResponseWrapper { + receipts: ReceiptsResponse, + } + let resp: ResponseWrapper = get_ureq_agent(GET_API_TIMEOUT) + .get(&url.to_string()) + .call()? + .into_json()?; + + Ok(resp.data.receipts.0) + } + + /// GET /api/v1/receipts/{migratedAt} endpoint + /// Get the receipts by the given milestone index. + pub async fn get_receipts_migrated_at(&self, milestone_index: u32) -> Result> { + let mut url = self.get_node()?; + let path = &format!("api/v1/receipts/{}", milestone_index); + url.set_path(path); + #[derive(Debug, Serialize, Deserialize)] + struct ResponseWrapper { + data: ReceiptsResponseWrapper, + } + #[derive(Debug, Serialize, Deserialize)] + struct ReceiptsResponseWrapper { + receipts: ReceiptsResponse, + } + let resp: ResponseWrapper = get_ureq_agent(GET_API_TIMEOUT) + .get(&url.to_string()) + .call()? + .into_json()?; + + Ok(resp.data.receipts.0) + } + + /// GET /api/v1/treasury endpoint + /// Get the treasury output. + pub async fn get_treasury(&self) -> Result { + let mut url = self.get_node()?; + let path = "api/v1/treasury"; + url.set_path(path); + #[derive(Debug, Serialize, Deserialize)] + struct ResponseWrapper { + data: TreasuryResponse, + } + let resp: ResponseWrapper = get_ureq_agent(GET_API_TIMEOUT) + .get(&url.to_string()) + .call()? + .into_json()?; + + Ok(resp.data) + } + /// Reattaches messages for provided message id. Messages can be reattached only if they are valid and haven't been /// confirmed for a while. pub async fn reattach(&self, message_id: &MessageId) -> Result<(MessageId, Message)> { diff --git a/iota-client/src/lib.rs b/iota-client/src/lib.rs index 59cc07cd3..d57b90f75 100644 --- a/iota-client/src/lib.rs +++ b/iota-client/src/lib.rs @@ -59,18 +59,3 @@ mod async_runtime { runtime.lock().unwrap().spawn(future); } } - -/// Log info about the request and response. -#[macro_export] -macro_rules! log_request { - ($method: expr, $url: expr, $response:ident) => { - info!( - "Request method: {} - Request URL: {}", - // Response status: {}", - $method, - $url, - // $response.status().as_u16() - ); - }; -} diff --git a/iota-client/tests/node_api.rs b/iota-client/tests/node_api.rs index fb874d17a..4f578f78d 100644 --- a/iota-client/tests/node_api.rs +++ b/iota-client/tests/node_api.rs @@ -312,3 +312,51 @@ async fn test_get_milestone_utxo_changes() { println!("{:#?}", r); } + +#[tokio::test] +#[ignore] +async fn test_get_receipts() { + let r = iota_client::Client::builder() + .with_node(DEFAULT_NODE_URL) + .unwrap() + .finish() + .await + .unwrap() + .get_receipts() + .await + .unwrap(); + + println!("{:#?}", r); +} + +#[tokio::test] +#[ignore] +async fn get_receipts_migrated_at() { + let r = iota_client::Client::builder() + .with_node(DEFAULT_NODE_URL) + .unwrap() + .finish() + .await + .unwrap() + .get_receipts_migrated_at(3) + .await + .unwrap(); + + println!("{:#?}", r); +} + +#[tokio::test] +#[ignore] +async fn test_get_treasury() { + let r = iota_client::Client::builder() + .with_node(DEFAULT_NODE_URL) + .unwrap() + .finish() + .await + .unwrap() + .get_treasury() + .await + .unwrap(); + + println!("{:#?}", r); +} diff --git a/iota-core/Cargo.toml b/iota-core/Cargo.toml index 918016f1e..6cd1f3e54 100644 --- a/iota-core/Cargo.toml +++ b/iota-core/Cargo.toml @@ -12,8 +12,8 @@ homepage = "https://iota.org" name = "iota" [dependencies] -bee-message = { git = "https://github.com/iotaledger/bee.git", rev = "6a3ac5d7475a8f13289da4bdc8c920e4d4b97c04" } -bee-pow = { git = "https://github.com/iotaledger/bee.git", rev = "6a3ac5d7475a8f13289da4bdc8c920e4d4b97c04" } +bee-message = { git = "https://github.com/iotaledger/bee.git", rev = "7e0cbe4e06b655d8358f8b5a145b1b78a51fbca1" } +bee-pow = { git = "https://github.com/iotaledger/bee.git", rev = "7e0cbe4e06b655d8358f8b5a145b1b78a51fbca1" } bee-common = { git = "https://github.com/iotaledger/bee.git", rev = "c42171ff33c80cc2efb183e244dc79b7f58d9ac4" } # bee-common = { git = "https://github.com/iotaledger/bee.git", branch = "dev" } # bee-message = { git = "https://github.com/iotaledger/bee.git", branch = "chrysalis-pt-2" } diff --git a/specs/iota-rs-ENGINEERING-SPEC-0000.md b/specs/iota-rs-ENGINEERING-SPEC-0000.md index 19ec8ed9d..08edd93bb 100644 --- a/specs/iota-rs-ENGINEERING-SPEC-0000.md +++ b/specs/iota-rs-ENGINEERING-SPEC-0000.md @@ -29,6 +29,9 @@ * [`find_outputs`](#find_outputs) * [`get_milestone`](#get_milestone) * [`get_milestone_utxo_changes`](#get_milestone_utxo_changes) + * [`get_receipts`](#get_receipts) + * [`get_receipts_migrated_at`](#get_receipts_migrated_at) + * [`get_treasury`](#get_treasury) * [Objects](#Objects) * [Network] * [Seed] @@ -524,7 +527,47 @@ MilestoneUTXOChanges { created_outputs: [], consumed_outputs: [], } -```` +``` + +## `get_receipts()` + +(`GET /receipts`) + +Get all receipts. + +### Returns + +```Rust +Vec +``` + +## `get_receipts_migrated_at()` + +(`GET /receipts/{migratedAt}`) + +Get all receipts for a given milestone index. + +### Returns + +```Rust +Vec +``` + +## `get_treasury()` + +(`GET /treasury`) + +Get the treasury amount. + +### Returns + +```Rust +pub struct TreasuryResponse { + #[serde(rename = "milestoneId")] + milestone_id: String, + amount: u64, +} +``` # Objects