1717#include "support/BRAddress.h"
1818#include "bitcoin/BRWallet.h"
1919#include "bitcoin/BRTransaction.h"
20- #include "ethereum/util/BRUtil.h"
2120#include "ethereum/BREthereum.h"
22- #include "ethereum/ewm/BREthereumTransfer.h"
2321
2422/**
2523 *
@@ -46,6 +44,7 @@ struct BRCryptoTransferRecord {
4644 uint64_t recv ;
4745 } btc ;
4846 struct {
47+ BREthereumEWM ewm ;
4948 BREthereumTransfer tid ;
5049 BREthereumAddress accountAddress ;
5150 } eth ;
@@ -199,10 +198,11 @@ cryptoTransferCreateAsETH (BRCryptoUnit unit,
199198 BREthereumTransfer tid ,
200199 BRCryptoFeeBasis feeBasisEstimated ) {
201200 BRCryptoTransfer transfer = cryptoTransferCreateInternal (BLOCK_CHAIN_TYPE_ETH , unit , unitForFee );
201+ transfer -> u .eth .ewm = ewm ;
202202 transfer -> u .eth .tid = tid ;
203203
204- transfer -> sourceAddress = cryptoAddressCreateAsETH (transferGetSourceAddress ( tid ));
205- transfer -> targetAddress = cryptoAddressCreateAsETH (transferGetTargetAddress ( tid ));
204+ transfer -> sourceAddress = cryptoAddressCreateAsETH (ewmTransferGetSource ( ewm , tid ));
205+ transfer -> targetAddress = cryptoAddressCreateAsETH (ewmTransferGetTarget ( ewm , tid ));
206206
207207 // cache the values that require the ewm
208208 BREthereumAccount account = ewmGetAccount (ewm );
@@ -234,7 +234,7 @@ cryptoTransferCreateAsETH (BRCryptoUnit unit,
234234 // Thus: if `feeBasisEstimated` is NULL, we'll take the ETH fee basis (as the best we have).
235235
236236 // Get the ETH feeBasis, in the event that we need it.
237- BREthereumFeeBasis ethFeeBasis = transferGetFeeBasis ( tid );
237+ BREthereumFeeBasis ethFeeBasis = ewmTransferGetFeeBasis ( ewm , tid );
238238
239239 transfer -> feeBasisEstimated = (NULL == feeBasisEstimated
240240 ? cryptoFeeBasisCreateAsETH (unitForFee ,
@@ -328,7 +328,8 @@ cryptoTransferGetAmountAsSign (BRCryptoTransfer transfer, BRCryptoBoolean isNega
328328 }
329329
330330 case BLOCK_CHAIN_TYPE_ETH : {
331- BREthereumAmount ethAmount = transferGetAmount (transfer -> u .eth .tid );
331+ BREthereumAmount ethAmount = ewmTransferGetAmount (transfer -> u .eth .ewm ,
332+ transfer -> u .eth .tid );
332333 switch (amountGetType (ethAmount )) {
333334 case AMOUNT_ETHER :
334335 amount = cryptoAmountCreate (transfer -> unit ,
@@ -509,10 +510,11 @@ cryptoTransferGetDirection (BRCryptoTransfer transfer) {
509510 return CRYPTO_TRANSFER_RECEIVED ;
510511 }
511512 case BLOCK_CHAIN_TYPE_ETH : {
512- BREthereumTransfer tid = transfer -> u .eth .tid ;
513+ BREthereumEWM ewm = transfer -> u .eth .ewm ;
514+ BREthereumTransfer tid = transfer -> u .eth .tid ;
513515
514- BREthereumAddress source = transferGetSourceAddress ( tid );
515- BREthereumAddress target = transferGetTargetAddress ( tid );
516+ BREthereumAddress source = ewmTransferGetSource ( ewm , tid );
517+ BREthereumAddress target = ewmTransferGetTarget ( ewm , tid );
516518
517519 BREthereumBoolean accountIsSource = addressEqual (source , transfer -> u .eth .accountAddress );
518520 BREthereumBoolean accountIsTarget = addressEqual (target , transfer -> u .eth .accountAddress );
@@ -563,9 +565,10 @@ cryptoTransferGetHash (BRCryptoTransfer transfer) {
563565 : cryptoHashCreateAsBTC (hash ));
564566 }
565567 case BLOCK_CHAIN_TYPE_ETH : {
566- BREthereumTransfer tid = transfer -> u .eth .tid ;
568+ BREthereumEWM ewm = transfer -> u .eth .ewm ;
569+ BREthereumTransfer tid = transfer -> u .eth .tid ;
567570
568- BREthereumHash hash = transferGetOriginatingTransactionHash ( tid );
571+ BREthereumHash hash = ewmTransferGetOriginatingTransactionHash ( ewm , tid );
569572 return (ETHEREUM_BOOLEAN_TRUE == hashEqual (hash , hashCreateEmpty ())
570573 ? NULL
571574 : cryptoHashCreateAsETH (hash ));
0 commit comments