use of com.esaulpaugh.headlong.abi.Tuple in project hedera-services by hashgraph.
the class DecodingFacade method decodeTransferToken.
public List<TokenTransferWrapper> decodeTransferToken(final Bytes input, final UnaryOperator<byte[]> aliasResolver) {
final Tuple decodedArguments = decodeFunctionCall(input, TRANSFER_TOKEN_SELECTOR, TRANSFER_TOKEN_DECODER);
final var tokenID = convertAddressBytesToTokenID((byte[]) decodedArguments.get(0));
final var sender = convertLeftPaddedAddressToAccountId((byte[]) decodedArguments.get(1), aliasResolver);
final var receiver = convertLeftPaddedAddressToAccountId((byte[]) decodedArguments.get(2), aliasResolver);
final var amount = (long) decodedArguments.get(3);
return Collections.singletonList(new TokenTransferWrapper(NO_NFT_EXCHANGES, List.of(new SyntheticTxnFactory.FungibleTokenTransfer(amount, tokenID, sender, receiver))));
}
use of com.esaulpaugh.headlong.abi.Tuple in project hedera-services by hashgraph.
the class DecodingFacade method decodeMultipleAssociations.
public Association decodeMultipleAssociations(final Bytes input, final UnaryOperator<byte[]> aliasResolver) {
final Tuple decodedArguments = decodeFunctionCall(input, ASSOCIATE_TOKENS_SELECTOR, ASSOCIATE_TOKENS_DECODER);
final var accountID = convertLeftPaddedAddressToAccountId((byte[]) decodedArguments.get(0), aliasResolver);
final var tokenIDs = decodeTokenIDsFromBytesArray((byte[][]) decodedArguments.get(1));
return Association.multiAssociation(accountID, tokenIDs);
}
use of com.esaulpaugh.headlong.abi.Tuple in project hedera-services by hashgraph.
the class DecodingFacade method decodeMultipleDissociations.
public Dissociation decodeMultipleDissociations(final Bytes input, final UnaryOperator<byte[]> aliasResolver) {
final Tuple decodedArguments = decodeFunctionCall(input, DISSOCIATE_TOKENS_SELECTOR, DISSOCIATE_TOKENS_DECODER);
final var accountID = convertLeftPaddedAddressToAccountId((byte[]) decodedArguments.get(0), aliasResolver);
final var tokenIDs = decodeTokenIDsFromBytesArray((byte[][]) decodedArguments.get(1));
return Dissociation.multiDissociation(accountID, tokenIDs);
}
use of com.esaulpaugh.headlong.abi.Tuple in project hedera-services by hashgraph.
the class DecodingFacade method decodeErcTransfer.
public List<TokenTransferWrapper> decodeErcTransfer(final Bytes input, final TokenID token, final AccountID caller, final UnaryOperator<byte[]> aliasResolver) {
final Tuple decodedArguments = decodeFunctionCall(input, ERC_TRANSFER_SELECTOR, ERC_TRANSFER_DECODER);
final var recipient = convertLeftPaddedAddressToAccountId((byte[]) decodedArguments.get(0), aliasResolver);
final var amount = (BigInteger) decodedArguments.get(1);
final List<SyntheticTxnFactory.FungibleTokenTransfer> fungibleTransfers = new ArrayList<>();
addAdjustmentAsTransfer(fungibleTransfers, token, recipient, amount.longValue());
addAdjustmentAsTransfer(fungibleTransfers, token, caller, -amount.longValue());
return Collections.singletonList(new TokenTransferWrapper(NO_NFT_EXCHANGES, fungibleTransfers));
}
use of com.esaulpaugh.headlong.abi.Tuple in project hedera-services by hashgraph.
the class DecodingFacade method decodeMint.
public MintWrapper decodeMint(final Bytes input) {
final Tuple decodedArguments = decodeFunctionCall(input, MINT_TOKEN_SELECTOR, MINT_TOKEN_DECODER);
final var tokenID = convertAddressBytesToTokenID((byte[]) decodedArguments.get(0));
final var fungibleAmount = (long) decodedArguments.get(1);
final var metadataList = (byte[][]) decodedArguments.get(2);
final List<ByteString> metadata = Arrays.stream(metadataList).map(ByteString::copyFrom).toList();
if (fungibleAmount > 0) {
return MintWrapper.forFungible(tokenID, fungibleAmount);
} else {
return MintWrapper.forNonFungible(tokenID, metadata);
}
}
Aggregations