Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Release/4.0.0 #757

Open
wants to merge 9 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,17 @@
- Fix XRP incremental synchronization
- Improve runtime performances by splitting db connections between Write pool and Read pool
- use of tx "id" field (if present) instead of "hash" for btc explorers
## 3.5.2

> 2021/02/03

- Add AddERC20Accounts API

## 3.5.1

> 2021/01/29

- Remove ERC20 balance check on libcore side

## 3.5.0

Expand Down
4 changes: 4 additions & 0 deletions core/idl/wallet/ethereum/ethereum_like_wallet.djinni
Original file line number Diff line number Diff line change
Expand Up @@ -182,4 +182,8 @@ EthereumLikeAccount = interface +c {
# The passed addresses are ERC20 accounts
# Note: same note as above
getERC20Balances(erc20Addresses: list<string>, callback: ListCallback<BigInt>);
# Add ERC20 accounts
# The passed addresses are ERC20 accounts
# Note: same note as above
addERC20Accounts(erc20Addresses: list<string>);
}
7 changes: 7 additions & 0 deletions core/src/api/EthereumLikeAccount.hpp

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions core/src/jni/jni/EthereumLikeAccount.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -116,4 +116,13 @@ CJNIEXPORT void JNICALL Java_co_ledger_core_EthereumLikeAccount_00024CppProxy_na
} JNI_TRANSLATE_EXCEPTIONS_RETURN(jniEnv, )
}

CJNIEXPORT void JNICALL Java_co_ledger_core_EthereumLikeAccount_00024CppProxy_native_1addERC20Accounts(JNIEnv* jniEnv, jobject /*this*/, jlong nativeRef, jobject j_erc20Addresses)
{
try {
DJINNI_FUNCTION_PROLOGUE1(jniEnv, nativeRef);
const auto& ref = ::djinni::objectFromHandleAddress<::ledger::core::api::EthereumLikeAccount>(nativeRef);
ref->addERC20Accounts(::djinni::List<::djinni::String>::toCpp(jniEnv, j_erc20Addresses));
} JNI_TRANSLATE_EXCEPTIONS_RETURN(jniEnv, )
}

} // namespace djinni_generated
1 change: 0 additions & 1 deletion core/src/wallet/ethereum/ERC20/ERC20LikeAccount.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,6 @@ namespace ledger {
throw Exception(api::ErrorCode::INVALID_EIP55_FORMAT, "Invalid address : Invalid EIP55 format");
}
return getBalance().map<std::vector<uint8_t>>(getContext(), [amount, address] (const std::shared_ptr<api::BigInt> &balance) {

BytesWriter writer;
writer.writeByteArray(hex::toByteArray(erc20Tokens::ERC20MethodsID.at("transfer")));

Expand Down
25 changes: 25 additions & 0 deletions core/src/wallet/ethereum/EthereumLikeAccount.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -654,6 +654,31 @@ namespace ledger {
}
}

void EthereumLikeAccount::addERC20Accounts(const std::vector<std::string> &erc20Addresses) {
auto self = std::dynamic_pointer_cast<EthereumLikeAccount>(shared_from_this());
const auto &accountUid = self->getAccountUid();

for (auto add:erc20Addresses){
soci::session sql(self->getWallet()->getDatabase()->getPool());

auto erc20AccountUid = AccountDatabaseHelper::createERC20AccountUid(accountUid, add);
//Persist erc20 account
int erc20AccountCount = 0;
sql << "SELECT COUNT(*) FROM erc20_accounts WHERE uid = :uid", soci::use(erc20AccountUid), soci::into(erc20AccountCount);
if (erc20AccountCount == 0) {
EthereumLikeAccountDatabaseHelper::createERC20Account(sql, accountUid, erc20AccountUid, add);
}

auto erc20Token = EthereumLikeAccountDatabaseHelper::getOrCreateERC20Token(sql, add);
auto newERC20Account = std::make_shared<ERC20LikeAccount>(erc20AccountUid,
erc20Token,
self->getKeychain()->getAddress()->toEIP55(),
self->getWallet()->getCurrency(),
self);
_erc20LikeAccounts.push_back(newERC20Account);
}
}

std::shared_ptr<api::EthereumLikeTransactionBuilder> EthereumLikeAccount::buildTransaction() {
auto self = std::dynamic_pointer_cast<EthereumLikeAccount>(shared_from_this());
auto buildFunction = [self] (const EthereumLikeTransactionBuildRequest& request, const std::shared_ptr<EthereumLikeBlockchainExplorer> &explorer) -> Future<std::shared_ptr<api::EthereumLikeTransaction>> {
Expand Down
2 changes: 2 additions & 0 deletions core/src/wallet/ethereum/EthereumLikeAccount.h
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,8 @@ namespace ledger {
void addERC20Accounts(soci::session &sql,
const std::vector<ERC20LikeAccountDatabaseEntry> &erc20Entries);

void addERC20Accounts(const std::vector<std::string> &erc20Addresses) override;

std::shared_ptr<api::Keychain> getAccountKeychain() override;
void emitEventsNow() override;

Expand Down
2 changes: 1 addition & 1 deletion core/test/algorand/AlgorandAccountTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,7 @@ TEST_F(AlgorandAccountTest, assetBalanceHistory)
}
}

TEST_F(AlgorandAccountTest, validAmount)
TEST_F(AlgorandAccountTest, DISABLED_validAmount)
{
const auto valid = uv::wait(account->isAmountValid(EMPTY_ADDR, "100000"));
EXPECT_TRUE(valid);
Expand Down
8 changes: 4 additions & 4 deletions core/test/algorand/AlgorandExplorerTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ class AlgorandExplorerTest : public BaseFixture {
std::shared_ptr<BlockchainExplorer> explorer;
};

TEST_F(AlgorandExplorerTest, GetBlock) {
TEST_F(AlgorandExplorerTest, DISABLED_GetBlock) {

uint64_t blockHeight = 6000000; // Some arbitrary block
std::chrono::system_clock::time_point blockTime(std::chrono::seconds(1586345796));
Expand All @@ -76,7 +76,7 @@ TEST_F(AlgorandExplorerTest, GetBlock) {
EXPECT_EQ(block.time, blockTime);
}

TEST_F(AlgorandExplorerTest, GetLatestBlock) {
TEST_F(AlgorandExplorerTest, DISABLED_GetLatestBlock) {

api::Block block = uv::wait(explorer->getLatestBlock());

Expand All @@ -85,7 +85,7 @@ TEST_F(AlgorandExplorerTest, GetLatestBlock) {
//EXPECT_GT(block.time.time_since_epoch().count(), 1593455156000000000); // Fails on CI with different system clock
}

TEST_F(AlgorandExplorerTest, GetAccount) {
TEST_F(AlgorandExplorerTest, DISABLED_GetAccount) {

auto address = ::algorand::Address(OBELIX_ADDRESS);
model::Account account = uv::wait(explorer->getAccount(address.toString()));
Expand All @@ -107,7 +107,7 @@ TEST_F(AlgorandExplorerTest, GetAccount) {
assertSameAssetParams(testAsset(), account.createdAssets.at(342836));
}

TEST_F(AlgorandExplorerTest, GetPaymentTransaction) {
TEST_F(AlgorandExplorerTest, DISABLED_GetPaymentTransaction) {
auto txRef = paymentTransaction();
model::Transaction tx = uv::wait(explorer->getTransactionById(*txRef.header.id));
assertSameTransaction(txRef, tx);
Expand Down
26 changes: 13 additions & 13 deletions core/test/integration/synchronization/cosmos_synchronization.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ class CosmosLikeWalletSynchronization : public BaseFixture {
std::shared_ptr<GaiaCosmosLikeBlockchainExplorer> explorer;
};

TEST_F(CosmosLikeWalletSynchronization, GetAccountWithExplorer) {
TEST_F(CosmosLikeWalletSynchronization, DISABLED_GetAccountWithExplorer) {

auto account = uv::wait(explorer->getAccount(DEFAULT_ADDRESS));
EXPECT_EQ(account->address, DEFAULT_ADDRESS);
Expand All @@ -147,7 +147,7 @@ TEST_F(CosmosLikeWalletSynchronization, GetAccountWithExplorer) {
}


TEST_F(CosmosLikeWalletSynchronization, InternalFeesMessageInTransaction) {
TEST_F(CosmosLikeWalletSynchronization, DISABLED_InternalFeesMessageInTransaction) {
/// This transaction contains 2 messages. One internal message to store fees
/// is added after the transaction is retrieved from the network, hence the
/// transaction should contain 3 messages, the last one being the one added
Expand Down Expand Up @@ -181,7 +181,7 @@ TEST_F(CosmosLikeWalletSynchronization, InternalFeesMessageInTransaction) {
}


TEST_F(CosmosLikeWalletSynchronization, GetWithdrawDelegationRewardWithExplorer) {
TEST_F(CosmosLikeWalletSynchronization, DISABLED_GetWithdrawDelegationRewardWithExplorer) {

auto filter = GaiaCosmosLikeBlockchainExplorer::fuseFilters({
GaiaCosmosLikeBlockchainExplorer::filterWithAttribute(
Expand Down Expand Up @@ -223,7 +223,7 @@ TEST_F(CosmosLikeWalletSynchronization, GetWithdrawDelegationRewardWithExplorer)
}


TEST_F(CosmosLikeWalletSynchronization, GetErrorTransaction) {
TEST_F(CosmosLikeWalletSynchronization, DISABLED_GetErrorTransaction) {
auto tx_hash = "4A7823F0F2899AA6EC1DCB2E242C541EDAF90419A3DE03ED885E438FEDB779D4";
auto validator = "cosmosvaloper1clpqr4nrk4khgkxj78fcwwh6dl3uw4epsluffn";
auto delegator = "cosmos1k3kg9w60dd5x56vve2s28v3xjp7fp2vn2hjjsa";
Expand Down Expand Up @@ -251,7 +251,7 @@ TEST_F(CosmosLikeWalletSynchronization, GetErrorTransaction) {
}


TEST_F(CosmosLikeWalletSynchronization, GetSendWithExplorer) {
TEST_F(CosmosLikeWalletSynchronization, DISABLED_GetSendWithExplorer) {
auto tx_hash = "F4B8CB550B498F744CCC420907B80D0B068250972F975354A873CD1CCF9B000A";
auto receiver = "cosmos1xxkueklal9vejv9unqu80w9vptyepfa95pd53u";
// Note : the sender of the message is also the sender of the funds in this transaction.
Expand All @@ -275,7 +275,7 @@ TEST_F(CosmosLikeWalletSynchronization, GetSendWithExplorer) {
EXPECT_EQ(tx->gasUsed, Option<std::string>("41014"));
}

TEST_F(CosmosLikeWalletSynchronization, GetDelegateWithExplorer) {
TEST_F(CosmosLikeWalletSynchronization, DISABLED_GetDelegateWithExplorer) {
auto delegator = "cosmos1ytpz9gt59hssp5m5sknuzrwse88glqhgcrypxj";
auto validator = "cosmosvaloper1ey69r37gfxvxg62sh4r0ktpuc46pzjrm873ae8";

Expand Down Expand Up @@ -315,7 +315,7 @@ TEST_F(CosmosLikeWalletSynchronization, GetDelegateWithExplorer) {
ASSERT_TRUE(foundTx);
}

TEST_F(CosmosLikeWalletSynchronization, GetCurrentBlockWithExplorer) {
TEST_F(CosmosLikeWalletSynchronization, DISABLED_GetCurrentBlockWithExplorer) {
std::string address = "cosmos16xkkyj97z7r83sx45xwk9uwq0mj0zszlf6c6mq";

auto block = uv::wait(explorer->getCurrentBlock());
Expand Down Expand Up @@ -521,7 +521,7 @@ TEST_F(CosmosLikeWalletSynchronization, DISABLED_AllTransactionsSynchronization)
// EXPECT_TRUE(foundMsgUnjail);
}

TEST_F(CosmosLikeWalletSynchronization, ValidatorSet) {
TEST_F(CosmosLikeWalletSynchronization, DISABLED_ValidatorSet) {
// This test assumes that HuobiPool and BinanceStaking are always in the validator set
const auto huobi_pool_address = "cosmosvaloper1kn3wugetjuy4zetlq6wadchfhvu3x740ae6z6x";
bool foundHuobi = false;
Expand Down Expand Up @@ -676,7 +676,7 @@ void GenericGasLimitEstimationTest(const std::string& strTx, CosmosLikeWalletSyn

} // namespace

TEST_F(CosmosLikeWalletSynchronization, GasLimitEstimationForTransfer) {
TEST_F(CosmosLikeWalletSynchronization, DISABLED_GasLimitEstimationForTransfer) {
const auto strTx = "{\"account_number\":\"6571\","
"\"chain_id\":\"cosmoshub-3\","
"\"fee\":{\"amount\":[{\"amount\":\"5000\",\"denom\":\"uatom\"}],\"gas\":\"200000\"},"
Expand All @@ -692,7 +692,7 @@ TEST_F(CosmosLikeWalletSynchronization, GasLimitEstimationForTransfer) {
GenericGasLimitEstimationTest(strTx, *this);
}

TEST_F(CosmosLikeWalletSynchronization, GasLimitEstimationForWithdrawingRewards) {
TEST_F(CosmosLikeWalletSynchronization, DISABLED_GasLimitEstimationForWithdrawingRewards) {
const auto strTx = "{\"account_number\":\"6571\","
"\"chain_id\":\"cosmoshub-3\","
"\"fee\":{\"amount\":[{\"amount\":\"5001\",\"denom\":\"uatom\"}],\"gas\":\"200020\"},"
Expand All @@ -707,7 +707,7 @@ TEST_F(CosmosLikeWalletSynchronization, GasLimitEstimationForWithdrawingRewards)
GenericGasLimitEstimationTest(strTx, *this);
}

TEST_F(CosmosLikeWalletSynchronization, GasLimitEstimationForDelegation) {
TEST_F(CosmosLikeWalletSynchronization, DISABLED_GasLimitEstimationForDelegation) {
const auto strTx = "{\"account_number\":\"6571\","
"\"chain_id\":\"cosmoshub-3\","
"\"fee\":{\"amount\":[{\"amount\":\"5000\",\"denom\":\"uatom\"}],\"gas\":\"200000\"},"
Expand All @@ -723,7 +723,7 @@ TEST_F(CosmosLikeWalletSynchronization, GasLimitEstimationForDelegation) {
GenericGasLimitEstimationTest(strTx, *this);
}

TEST_F(CosmosLikeWalletSynchronization, GasLimitEstimationForUnDelegation) {
TEST_F(CosmosLikeWalletSynchronization, DISABLED_GasLimitEstimationForUnDelegation) {
const auto strTx = "{\"account_number\":\"6571\","
"\"chain_id\":\"cosmoshub-3\","
"\"fee\":{\"amount\":[{\"amount\":\"5000\",\"denom\":\"uatom\"}],\"gas\":\"200000\"},"
Expand All @@ -739,7 +739,7 @@ TEST_F(CosmosLikeWalletSynchronization, GasLimitEstimationForUnDelegation) {
GenericGasLimitEstimationTest(strTx, *this);
}

TEST_F(CosmosLikeWalletSynchronization, GasLimitEstimationForRedelegation) {
TEST_F(CosmosLikeWalletSynchronization, DISABLED_GasLimitEstimationForRedelegation) {
const auto strTx = "{\"account_number\":\"6571\","
"\"chain_id\":\"cosmoshub-3\","
"\"fee\":{\"amount\":[{\"amount\":\"5000\",\"denom\":\"uatom\"}],\"gas\":\"200000\"},"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ class BitcoinLikeWalletP2SHSynchronization : public BaseFixture {

};

TEST_F(BitcoinLikeWalletP2SHSynchronization, MediumXpubSynchronization) {
TEST_F(BitcoinLikeWalletP2SHSynchronization, DISABLED_MediumXpubSynchronization) {
auto pool = newDefaultPool();
{
auto configuration = DynamicObject::newInstance();
Expand Down Expand Up @@ -76,7 +76,7 @@ TEST_F(BitcoinLikeWalletP2SHSynchronization, MediumXpubSynchronization) {
}
}

TEST_F(BitcoinLikeWalletP2SHSynchronization, SynchronizeOnceAtATime) {
TEST_F(BitcoinLikeWalletP2SHSynchronization, DISABLED_SynchronizeOnceAtATime) {
auto pool = newDefaultPool();
{
auto configuration = DynamicObject::newInstance();
Expand Down Expand Up @@ -110,7 +110,7 @@ TEST_F(BitcoinLikeWalletP2SHSynchronization, SynchronizeOnceAtATime) {
}
}

TEST_F(BitcoinLikeWalletP2SHSynchronization, SynchronizeFromLastBlock) {
TEST_F(BitcoinLikeWalletP2SHSynchronization, DISABLED_SynchronizeFromLastBlock) {
auto pool = newDefaultPool();
{
auto configuration = DynamicObject::newInstance();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ TEST_F(BitcoinMakeP2PKHTransaction, CreateStandardP2PKHWithMultipleInputs) {
// );
}

TEST_F(BitcoinMakeP2PKHTransaction, Toto) {
TEST_F(BitcoinMakeP2PKHTransaction, DISABLED_Toto) {
std::shared_ptr<AbstractWallet> w = uv::wait(pool->createWallet("my_btc_wallet", "bitcoin_testnet", DynamicObject::newInstance()));
api::ExtendedKeyAccountCreationInfo info = uv::wait(w->getNextExtendedKeyAccountCreationInfo());
info.extendedKeys.push_back("tpubDCJarhe7f951cUufTWeGKh1w6hDgdBcJfvQgyMczbxWvwvLdryxZuchuNK3KmTKXwBNH6Ze6tHGrUqvKGJd1VvSZUhTVx58DrLn9hR16DVr");
Expand Down