Skip to content

Commit

Permalink
Merge branch 'master' into s/rust-tw-error
Browse files Browse the repository at this point in the history
  • Loading branch information
satoshiotomakan committed Apr 22, 2024
2 parents d7150cc + cd212c9 commit d34e26a
Show file tree
Hide file tree
Showing 19 changed files with 461 additions and 32 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ class CoinAddressDerivationTests {
FANTOM, CELO, CRONOSCHAIN, SMARTBITCOINCASH, KUCOINCOMMUNITYCHAIN, BOBA, METIS,
AURORA, EVMOS, MOONRIVER, MOONBEAM, KAVAEVM, KLAYTN, METER, OKXCHAIN, POLYGONZKEVM, SCROLL,
CONFLUXESPACE, ACALAEVM, OPBNB, NEON, BASE, LINEA, GREENFIELD, MANTLE, ZENEON, MANTAPACIFIC,
ZETAEVM, MERLIN, LIGHTLINK, BLAST,
ZETAEVM, MERLIN, LIGHTLINK, BLAST, BOUNCEBIT,
-> assertEquals("0x8f348F300873Fd5DA36950B2aC75a26584584feE", address)

RONIN -> assertEquals("ronin:8f348F300873Fd5DA36950B2aC75a26584584feE", address)
Expand Down
1 change: 1 addition & 0 deletions docs/registry.md
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ This list is generated from [./registry.json](../registry.json)
| 4200 | Merlin | BTC | <img src="https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/merlin/info/logo.png" width="32" /> | <https://merlinchain.io> |
| 5000 | Mantle | MNT | <img src="https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/mantle/info/logo.png" width="32" /> | <https://www.mantle.xyz> |
| 5600 | BNB Greenfield | BNB | <img src="https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/greenfield/info/logo.png" width="32" /> | <https://greenfield.bnbchain.org> |
| 6001 | BounceBit | BB | <img src="https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/bouncebit/info/logo.png" width="32" /> | <https://bouncebit.io> |
| 6060 | GoChain | GO | <img src="https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/gochain/info/logo.png" width="32" /> | <https://gochain.io> |
| 7332 | Zen EON | ZEN | <img src="https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/zeneon/info/logo.png" width="32" /> | <https://eon.horizen.io> |
| 8453 | Base | ETH | <img src="https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/base/info/logo.png" width="32" /> | <https://base.mirror.xyz/> |
Expand Down
1 change: 1 addition & 0 deletions include/TrustWalletCore/TWCoinType.h
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,7 @@ enum TWCoinType {
TWCoinTypeMerlin = 4200,
TWCoinTypeLightlink = 1890,
TWCoinTypeBlast = 81457,
TWCoinTypeBounceBit = 6001,
// end_of_tw_coin_type_marker_do_not_modify
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class CoinAddressDerivationTests {
Fantom, Celo, CronosChain, SmartBitcoinCash, KuCoinCommunityChain, Boba, Metis,
Aurora, Evmos, Moonriver, Moonbeam, KavaEvm, Klaytn, Meter, OKXChain, PolygonzkEVM, Scroll,
ConfluxeSpace, AcalaEVM, OpBNB, Neon, Base, Linea, Greenfield, Mantle, ZenEON, MantaPacific,
ZetaEVM, Merlin, Lightlink, Blast,
ZetaEVM, Merlin, Lightlink, Blast, BounceBit,
-> "0x8f348F300873Fd5DA36950B2aC75a26584584feE"

Ronin -> "ronin:8f348F300873Fd5DA36950B2aC75a26584584feE"
Expand Down
30 changes: 30 additions & 0 deletions registry.json
Original file line number Diff line number Diff line change
Expand Up @@ -4719,5 +4719,35 @@
"rpc": "https://rpc.blast.io",
"documentation": "https://docs.blast.io"
}
},
{
"id": "bouncebit",
"name": "BounceBit",
"coinId": 6001,
"symbol": "BB",
"decimals": 18,
"blockchain": "Ethereum",
"derivation": [
{
"path": "m/44'/60'/0'/0/0"
}
],
"curve": "secp256k1",
"publicKeyType": "secp256k1Extended",
"chainId": "6001",
"addressHasher": "keccak256",
"explorer": {
"url": "https://bbscan.io",
"txPath": "/tx/",
"accountPath": "/address/",
"sampleTx": "0x52558f4143d058d942e3b73414090266ae3ffce1fe8c25fe86896e2c8e5ef932",
"sampleAccount": "0xf4aa7349a9ccca4609943955b5ddc7bd9278c223"
},
"info": {
"url": "https://bouncebit.io",
"source": "https://github.com/BounceBit-Labs",
"rpc": "https://fullnode-mainnet.bouncebitapi.com",
"documentation": "https://docs.bouncebit.io"
}
}
]
1 change: 1 addition & 0 deletions rust/tw_any_coin/tests/coin_address_derivation_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ fn test_coin_address_derivation() {
| CoinType::Merlin
| CoinType::Lightlink
| CoinType::Blast
| CoinType::BounceBit
// end_of_evm_address_derivation_tests_marker_do_not_modify
=> "0xAc1ec44E4f0ca7D172B7803f6836De87Fb72b309",
CoinType::Bitcoin
Expand Down
17 changes: 16 additions & 1 deletion src/FIO/Action.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,21 @@ void Action::serialize(Data& out) const {
append(out, 0); // 00
}

void AddPubAddressData::serialize(Data& out) const {
void PubAddressActionData::serialize(Data& out) const {
encodeString(fioAddress, out);
addresses.serialize(out);
encode64LE(fee, out);
EOS::Name(actor).serialize(out);
encodeString(tpid, out);
}

void RemoveAllPubAddressActionData::serialize(Data& out) const {
encodeString(fioAddress, out);
encode64LE(fee, out);
EOS::Name(actor).serialize(out);
encodeString(tpid, out);
}

void RegisterFioAddressData::serialize(Data& out) const {
encodeString(fioAddress, out);
encodeString(ownerPublicKey, out);
Expand Down Expand Up @@ -81,4 +88,12 @@ void NewFundsRequestData::serialize(Data& out) const {
encodeString(tpid, out);
}

void AddBundledTransactionsActionData::serialize(Data& out) const {
encodeString(fioAddress, out);
encode64LE(bundledSets, out);
encode64LE(fee, out);
encodeString(tpid, out);
EOS::Name(actor).serialize(out);
}

} // namespace TW::FIO
38 changes: 35 additions & 3 deletions src/FIO/Action.h
Original file line number Diff line number Diff line change
Expand Up @@ -81,22 +81,39 @@ class Action {
void serialize(Data& out) const;
};

/// AddPubAddress action data part.
class AddPubAddressData {
/// A public address action data part.
/// Can be used for `addaddress`, `remaddress`, `remalladdr` (addresses must be empty) actions.
/// https://dev.fio.net/reference/add_pub_address
/// https://dev.fio.net/reference/remove_pub_address
class PubAddressActionData {
public:
std::string fioAddress;
PublicAddresses addresses;
uint64_t fee;
std::string tpid;
std::string actor;

AddPubAddressData(const std::string& fioAddress, const std::vector<PublicAddress>& addresses,
PubAddressActionData(const std::string& fioAddress, const std::vector<PublicAddress>& addresses,
uint64_t fee, const std::string& tpid, const std::string& actor) :
fioAddress(fioAddress), addresses(addresses),
fee(fee), tpid(tpid), actor(actor) {}
void serialize(Data& out) const;
};

/// RemoveAllPubAddress action data part.
/// https://dev.fio.net/reference/remove_all_pub_address
class RemoveAllPubAddressActionData {
public:
std::string fioAddress;
uint64_t fee;
std::string tpid;
std::string actor;

RemoveAllPubAddressActionData(const std::string& fioAddress, uint64_t fee, const std::string& tpid, const std::string& actor) :
fioAddress(fioAddress), fee(fee), tpid(tpid), actor(actor) {}
void serialize(Data& out) const;
};

/// RegisterFioAddress action data part.
class RegisterFioAddressData {
public:
Expand Down Expand Up @@ -155,4 +172,19 @@ class NewFundsRequestData {
void serialize(Data& out) const;
};

/// AddBundledTransactions action data part.
/// https://dev.fio.net/reference/add_bundled_transactions
class AddBundledTransactionsActionData {
public:
std::string fioAddress;
uint64_t bundledSets;
uint64_t fee;
std::string tpid;
std::string actor;

AddBundledTransactionsActionData(const std::string& fioAddress, uint64_t bundledSets, uint64_t fee, const std::string& tpid, const std::string& actor) :
fioAddress(fioAddress), bundledSets(bundledSets), fee(fee), tpid(tpid), actor(actor) {}
void serialize(Data& out) const;
};

} // namespace TW::FIO
4 changes: 3 additions & 1 deletion src/FIO/Signer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,11 @@ using namespace std;

Proto::SigningOutput Signer::sign(const Proto::SigningInput& input) noexcept {
FIO::Proto::SigningOutput output;
try {
try {
const string actionName = TransactionBuilder::actionName(input);
const string json = TransactionBuilder::sign(input);
output.set_json(json);
output.set_action_name(actionName);
} catch(const std::exception& e) {
output.set_error(Common::Proto::Error_internal);
}
Expand Down
Loading

0 comments on commit d34e26a

Please sign in to comment.