[CodeHealth] Various brave_wallet base::Value modernisations
This change modernises the use of base::Value in the components/ path, removing the use of all deprecated methods from base::Value.
This commit is contained in:
committed by
cdesouza-chromium
parent
aa5bc0aca5
commit
df0eafcd91
@@ -301,14 +301,14 @@ std::string eth_compileSerpent(const std::string& source_code) {
|
||||
std::string eth_newFilter(const std::string& from_block_quantity_tag,
|
||||
const std::string& to_block_quantity_tag,
|
||||
const std::string& address,
|
||||
base::Value* topics) {
|
||||
base::Value::List topics) {
|
||||
base::Value::List params;
|
||||
base::Value::Dict filter_options;
|
||||
AddKeyIfNotEmpty(&filter_options, "address", address);
|
||||
AddKeyIfNotEmpty(&filter_options, "fromBlock", from_block_quantity_tag);
|
||||
AddKeyIfNotEmpty(&filter_options, "toBlock", to_block_quantity_tag);
|
||||
if (!topics->GetList().empty()) {
|
||||
filter_options.Set("topics", std::move(*topics));
|
||||
if (!topics.empty()) {
|
||||
filter_options.Set("topics", std::move(topics));
|
||||
}
|
||||
params.Append(std::move(filter_options));
|
||||
base::Value::Dict dictionary =
|
||||
@@ -339,15 +339,15 @@ std::string eth_getFilterLogs(const std::string& filter_id) {
|
||||
std::string eth_getLogs(const std::string& from_block_quantity_tag,
|
||||
const std::string& to_block_quantity_tag,
|
||||
const std::string& address,
|
||||
base::Value* topics,
|
||||
base::Value::List topics,
|
||||
const std::string& block_hash) {
|
||||
base::Value::List params;
|
||||
base::Value::Dict filter_options;
|
||||
AddKeyIfNotEmpty(&filter_options, "address", address);
|
||||
AddKeyIfNotEmpty(&filter_options, "fromBlock", from_block_quantity_tag);
|
||||
AddKeyIfNotEmpty(&filter_options, "toBlock", to_block_quantity_tag);
|
||||
if (!topics->GetList().empty()) {
|
||||
filter_options.Set("topics", std::move(*topics));
|
||||
if (!topics.empty()) {
|
||||
filter_options.Set("topics", std::move(topics));
|
||||
}
|
||||
AddKeyIfNotEmpty(&filter_options, "blockhash", block_hash);
|
||||
params.Append(std::move(filter_options));
|
||||
|
||||
@@ -175,7 +175,7 @@ std::string eth_compileSerpent(const std::string& source_code);
|
||||
std::string eth_newFilter(const std::string& from_block_quantity_tag,
|
||||
const std::string& to_block_quantity_tag,
|
||||
const std::string& address,
|
||||
base::Value* topics);
|
||||
base::Value::List topics);
|
||||
// Creates a filter in the node, to notify when a new block arrives.
|
||||
std::string eth_newBlockFilter();
|
||||
// Creates a filter in the node, to notify when new pending transactions arrive.
|
||||
@@ -193,7 +193,7 @@ std::string eth_getFilterLogs(const std::string& filter_id);
|
||||
std::string eth_getLogs(const std::string& from_block_quantity_tag,
|
||||
const std::string& to_block_quantity_tag,
|
||||
const std::string& address,
|
||||
base::Value* topics,
|
||||
base::Value::List topics,
|
||||
const std::string& block_hash);
|
||||
// Returns the hash of the current block, the seedHash, and the boundary
|
||||
// condition to be met (“target”).
|
||||
|
||||
@@ -279,18 +279,18 @@ TEST(EthRequestUnitTest, eth_compileSerpent) {
|
||||
}
|
||||
|
||||
TEST(EthRequestUnitTest, eth_newFilter) {
|
||||
base::Value topics(base::Value::Type::LIST);
|
||||
topics.Append(base::Value(
|
||||
"0x000000000000000000000000a94f5374fce5edbc8e2a8697c15331677e6ebf0b"));
|
||||
base::Value sub_topics(base::Value::Type::LIST);
|
||||
sub_topics.Append(base::Value(
|
||||
"0x000000000000000000000000a94f5374fce5edbc8e2a8697c15331677e6ebf0b"));
|
||||
sub_topics.Append(base::Value(
|
||||
"0x0000000000000000000000000aff3454fce5edbc8cca8697c15331677e6ebccc"));
|
||||
base::Value::List topics;
|
||||
topics.Append(
|
||||
"0x000000000000000000000000a94f5374fce5edbc8e2a8697c15331677e6ebf0b");
|
||||
base::Value::List sub_topics;
|
||||
sub_topics.Append(
|
||||
"0x000000000000000000000000a94f5374fce5edbc8e2a8697c15331677e6ebf0b");
|
||||
sub_topics.Append(
|
||||
"0x0000000000000000000000000aff3454fce5edbc8cca8697c15331677e6ebccc");
|
||||
topics.Append(std::move(sub_topics));
|
||||
ASSERT_EQ(
|
||||
eth_newFilter("0x1", "0x2", "0x8888f1f195afa192cfee860698584c030f4c9db1",
|
||||
&topics),
|
||||
std::move(topics)),
|
||||
R"({"id":1,"jsonrpc":"2.0","method":"eth_newFilter","params":[{"address":"0x8888f1f195afa192cfee860698584c030f4c9db1","fromBlock":"0x1","toBlock":"0x2","topics":["0x000000000000000000000000a94f5374fce5edbc8e2a8697c15331677e6ebf0b",["0x000000000000000000000000a94f5374fce5edbc8e2a8697c15331677e6ebf0b","0x0000000000000000000000000aff3454fce5edbc8cca8697c15331677e6ebccc"]]}]})"); // NOLINT
|
||||
}
|
||||
|
||||
@@ -325,18 +325,19 @@ TEST(EthRequestUnitTest, eth_getFilterLogs) {
|
||||
}
|
||||
|
||||
TEST(EthRequestUnitTest, eth_getLogs) {
|
||||
base::Value topics(base::Value::Type::LIST);
|
||||
topics.Append(base::Value(
|
||||
"0x000000000000000000000000a94f5374fce5edbc8e2a8697c15331677e6ebf0b"));
|
||||
base::Value sub_topics(base::Value::Type::LIST);
|
||||
sub_topics.Append(base::Value(
|
||||
"0x000000000000000000000000a94f5374fce5edbc8e2a8697c15331677e6ebf0b"));
|
||||
sub_topics.Append(base::Value(
|
||||
"0x0000000000000000000000000aff3454fce5edbc8cca8697c15331677e6ebccc"));
|
||||
base::Value::List topics;
|
||||
topics.Append(
|
||||
"0x000000000000000000000000a94f5374fce5edbc8e2a8697c15331677e6ebf0b");
|
||||
base::Value::List sub_topics;
|
||||
sub_topics.Append(
|
||||
"0x000000000000000000000000a94f5374fce5edbc8e2a8697c15331677e6ebf0b");
|
||||
sub_topics.Append(
|
||||
"0x0000000000000000000000000aff3454fce5edbc8cca8697c15331677e6ebccc");
|
||||
topics.Append(std::move(sub_topics));
|
||||
ASSERT_EQ(
|
||||
eth_getLogs(
|
||||
"0x1", "0x2", "0x8888f1f195afa192cfee860698584c030f4c9db1", &topics,
|
||||
"0x1", "0x2", "0x8888f1f195afa192cfee860698584c030f4c9db1",
|
||||
std::move(topics),
|
||||
"0xb903239f8543d04b5dc1ba6579132b143087c68db1b2168786408fcbce568238"),
|
||||
R"({"id":1,"jsonrpc":"2.0","method":"eth_getLogs","params":[{"address":"0x8888f1f195afa192cfee860698584c030f4c9db1","blockhash":"0xb903239f8543d04b5dc1ba6579132b143087c68db1b2168786408fcbce568238","fromBlock":"0x1","toBlock":"0x2","topics":["0x000000000000000000000000a94f5374fce5edbc8e2a8697c15331677e6ebf0b",["0x000000000000000000000000a94f5374fce5edbc8e2a8697c15331677e6ebf0b","0x0000000000000000000000000aff3454fce5edbc8cca8697c15331677e6ebccc"]]}]})"); // NOLINT
|
||||
}
|
||||
|
||||
@@ -733,7 +733,7 @@ void SolanaProviderImpl::OnRequestSignAllTransactions(
|
||||
const std::vector<std::vector<uint8_t>>& serialized_txs) {
|
||||
base::Value::Dict result;
|
||||
if (error == mojom::SolanaProviderError::kSuccess) {
|
||||
base::Value signatures(base::Value::Type::LIST);
|
||||
base::Value::List signatures;
|
||||
for (const auto& serialized_tx : serialized_txs) {
|
||||
auto tx = SolanaTransaction::FromSignedTransactionBytes(serialized_tx);
|
||||
DCHECK(tx);
|
||||
|
||||
Reference in New Issue
Block a user