Skip to content

Commit 836ad62

Browse files
committed
Saved changeds.
1 parent 31d808a commit 836ad62

File tree

6 files changed

+483
-455
lines changed

6 files changed

+483
-455
lines changed

core/api/full_node/make.cpp

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -747,6 +747,27 @@ namespace fc::api {
747747
}));
748748
return map;
749749
};
750+
751+
api->MarketAddBalance = [=](auto &address, auto &wallet, auto &amount)
752+
-> outcome::result<boost::optional<CID>> {
753+
OUTCOME_TRY(
754+
encoded_params,
755+
codec::cbor::encode(
756+
vm::actor::builtin::v0::market::AddBalance::Params{address}));
757+
OUTCOME_TRY(signed_message,
758+
api->MpoolPushMessage(
759+
vm::message::UnsignedMessage(
760+
kStorageMarketAddress,
761+
wallet,
762+
0,
763+
amount,
764+
0,
765+
0,
766+
vm::actor::builtin::v0::market::AddBalance::Number,
767+
encoded_params),
768+
api::kPushNoSpec));
769+
return signed_message.getCid();
770+
};
750771
api->StateLookupID = [=](auto &address,
751772
auto &tipset_key) -> outcome::result<Address> {
752773
OUTCOME_TRY(context, tipsetContext(tipset_key, false));

core/api/wallet/local_wallet.cpp

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,9 @@ namespace fc::api {
7474
std::vector<Address> out;
7575
out.reserve(all.size());
7676

77-
std::string k_name_prefix = "wallet-";
77+
std::string k_name_prefix = "wallet-"; // TODO not needed
7878
for (auto &a : all) {
79+
fmt::print(encodeToString(a));
7980
if (encodeToString(a).substr(0, k_name_prefix.size())
8081
== k_name_prefix) {
8182
std::string name = encodeToString(a).erase(0, k_name_prefix.size());
@@ -113,6 +114,14 @@ namespace fc::api {
113114
}
114115
return key_store->verify(address, data, signature);
115116
};
117+
api->WalletDelete = [=](auto &address) -> outcome::result<void> {
118+
OUTCOME_TRY(has, key_store->has(address));
119+
if (has) {
120+
OUTCOME_TRY(key_store->remove(address));
121+
return outcome::success();
122+
}
123+
return ERROR_TEXT("WalletDelete: Address does not exist");
124+
};
116125
}
117126

118127
} // namespace fc::api

core/cli/cli.hpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -174,21 +174,21 @@ namespace fc::cli {
174174
int pad = colLenghts[i] - e.size() + 2;
175175
if (not column.separate_line && column.lines > 0) {
176176
e += std::string(pad, ' ');
177-
std::cout << e;
177+
fmt::print(e);
178178
}
179179

180180
cols.push_back(e);
181181
}
182182

183-
std::cout << '\n';
183+
fmt::print("\n");
184184

185185
for (int i = 0; i < columns.size(); ++i) {
186186
Column &column = columns[i];
187187
if (not column.separate_line || cols[i].size() == 0) {
188188
continue;
189189
}
190190

191-
std::cout << " " << column.name << ": " << cols[i] << '\n';
191+
fmt::print(" {}: {}\n", column.name, cols[i]);
192192
}
193193
}
194194
}

core/cli/example/CMakeLists.txt

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#
2+
# Copyright Soramitsu Co., Ltd. All Rights Reserved.
3+
# SPDX-License-Identifier: Apache-2.0
4+
#
5+
6+
add_executable(cli_example main.cpp)
7+
target_link_libraries(cli_example
8+
cli
9+
rpc
10+
api_ipfs_datastore
11+
)

0 commit comments

Comments
 (0)