Skip to content

Commit

Permalink
Improved the reading of Transfer so that it can parse the MASP intern…
Browse files Browse the repository at this point in the history
…al address.
  • Loading branch information
murisi committed Feb 19, 2024
1 parent d01bf33 commit b5eb061
Show file tree
Hide file tree
Showing 5 changed files with 99 additions and 101 deletions.
6 changes: 2 additions & 4 deletions app/src/parser_impl_txn.c
Original file line number Diff line number Diff line change
Expand Up @@ -1400,12 +1400,10 @@ static parser_error_t readTransferTxn(const bytes_t *data, parser_tx_t *v) {
parser_context_t ctx = {.buffer = data->ptr, .bufferLen = data->len, .offset = 0, .tx_obj = NULL};

// Source
v->transfer.source_address.len = ADDRESS_LEN_BYTES;
CHECK_ERROR(readBytes(&ctx, &v->transfer.source_address.ptr, v->transfer.source_address.len))
CHECK_ERROR(readAddressAlt(&ctx, &v->transfer.source_address))

// Target
v->transfer.target_address.len = ADDRESS_LEN_BYTES;
CHECK_ERROR(readBytes(&ctx, &v->transfer.target_address.ptr, v->transfer.target_address.len))
CHECK_ERROR(readAddressAlt(&ctx, &v->transfer.target_address))

// Token
v->transfer.token.len = ADDRESS_LEN_BYTES;
Expand Down
4 changes: 2 additions & 2 deletions app/src/parser_print_txn.c
Original file line number Diff line number Diff line change
Expand Up @@ -145,11 +145,11 @@ static parser_error_t printTransferTxn( const parser_context_t *ctx,
break;
case 1:
snprintf(outKey, outKeyLen, "Sender");
CHECK_ERROR(printAddress(ctx->tx_obj->transfer.source_address, outVal, outValLen, pageIdx, pageCount))
//CHECK_ERROR(printAddress(ctx->tx_obj->transfer.source_address, outVal, outValLen, pageIdx, pageCount))
break;
case 2:
snprintf(outKey, outKeyLen, "Destination");
CHECK_ERROR(printAddress(ctx->tx_obj->transfer.target_address, outVal, outValLen, pageIdx, pageCount))
//CHECK_ERROR(printAddress(ctx->tx_obj->transfer.target_address, outVal, outValLen, pageIdx, pageCount))
break;
case 3:
if(ctx->tx_obj->transfer.symbol != NULL) {
Expand Down
92 changes: 0 additions & 92 deletions app/src/parser_txdef.h
Original file line number Diff line number Diff line change
Expand Up @@ -281,18 +281,6 @@ typedef struct {
Transaction data;
} masp_tx_section_t;

typedef struct {
uint8_t f0[20];
} IbcTokenHash;

typedef struct {
uint8_t f0[20];
} EthAddress;

typedef struct {
uint8_t f0[20];
} PublicKeyHash;

typedef struct {
uint8_t f0;
uint8_t f1[32];
Expand Down Expand Up @@ -469,86 +457,6 @@ typedef struct {
uint64_t *output_indices;
} SaplingMetadata;

typedef struct {
uint8_t hash[20];
} EstablishedAddress;

typedef struct {
EstablishedAddress f0;
} AddressEstablished;

typedef struct {
PublicKeyHash f0;
} ImplicitAddress;

typedef struct {
ImplicitAddress f0;
} AddressImplicit;

typedef struct {
EthAddress f0;
} InternalAddressErc20;

typedef struct {} InternalAddressEthBridge;

typedef struct {} InternalAddressEthBridgePool;

typedef struct {} InternalAddressGovernance;

typedef struct {} InternalAddressIbc;

typedef struct {
IbcTokenHash f0;
} InternalAddressIbcToken;

typedef struct {} InternalAddressMasp;

typedef struct {} InternalAddressMultitoken;

typedef struct {
EthAddress f0;
} InternalAddressNut;

typedef struct {} InternalAddressParameters;

typedef struct {} InternalAddressPgf;

typedef struct {} InternalAddressPoS;

typedef struct {} InternalAddressPosSlashPool;

typedef struct {
uint8_t tag;
union {
InternalAddressPoS PoS;
InternalAddressPosSlashPool PosSlashPool;
InternalAddressParameters Parameters;
InternalAddressIbc Ibc;
InternalAddressIbcToken IbcToken;
InternalAddressGovernance Governance;
InternalAddressEthBridge EthBridge;
InternalAddressEthBridgePool EthBridgePool;
InternalAddressErc20 Erc20;
InternalAddressNut Nut;
InternalAddressMultitoken Multitoken;
InternalAddressPgf Pgf;
InternalAddressMasp Masp;
};
} InternalAddress;

typedef struct {
InternalAddress f0;
} AddressInternal;

typedef struct {
uint8_t tag;
union {
AddressEstablished Established;
AddressImplicit Implicit;
AddressInternal Internal;
};
} AddressAlt;

typedef struct {
uint64_t f0;
} Epoch;
Expand Down
96 changes: 94 additions & 2 deletions app/src/parser_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -256,8 +256,100 @@ typedef struct {
} tx_update_vp_t;

typedef struct {
bytes_t source_address;
bytes_t target_address;
uint8_t f0[20];
} IbcTokenHash;

typedef struct {
uint8_t f0[20];
} EthAddress;

typedef struct {
uint8_t f0[20];
} PublicKeyHash;

typedef struct {
uint8_t hash[20];
} EstablishedAddress;

typedef struct {
EstablishedAddress f0;
} AddressEstablished;

typedef struct {
PublicKeyHash f0;
} ImplicitAddress;

typedef struct {
ImplicitAddress f0;
} AddressImplicit;

typedef struct {
EthAddress f0;
} InternalAddressErc20;

typedef struct {} InternalAddressEthBridge;

typedef struct {} InternalAddressEthBridgePool;

typedef struct {} InternalAddressGovernance;

typedef struct {} InternalAddressIbc;

typedef struct {
IbcTokenHash f0;
} InternalAddressIbcToken;

typedef struct {} InternalAddressMasp;

typedef struct {} InternalAddressMultitoken;

typedef struct {
EthAddress f0;
} InternalAddressNut;

typedef struct {} InternalAddressParameters;

typedef struct {} InternalAddressPgf;

typedef struct {} InternalAddressPoS;

typedef struct {} InternalAddressPosSlashPool;

typedef struct {
uint8_t tag;
union {
InternalAddressPoS PoS;
InternalAddressPosSlashPool PosSlashPool;
InternalAddressParameters Parameters;
InternalAddressIbc Ibc;
InternalAddressIbcToken IbcToken;
InternalAddressGovernance Governance;
InternalAddressEthBridge EthBridge;
InternalAddressEthBridgePool EthBridgePool;
InternalAddressErc20 Erc20;
InternalAddressNut Nut;
InternalAddressMultitoken Multitoken;
InternalAddressPgf Pgf;
InternalAddressMasp Masp;
};
} InternalAddress;

typedef struct {
InternalAddress f0;
} AddressInternal;

typedef struct {
uint8_t tag;
union {
AddressEstablished Established;
AddressImplicit Implicit;
AddressInternal Internal;
};
} AddressAlt;

typedef struct {
AddressAlt source_address;
AddressAlt target_address;
// Transferred token address
bytes_t token;
uint8_t has_sub_prefix;
Expand Down
2 changes: 1 addition & 1 deletion tests/testvectors.json

Large diffs are not rendered by default.

0 comments on commit b5eb061

Please sign in to comment.