Skip to content

Commit

Permalink
Return address params only in ordinary txs
Browse files Browse the repository at this point in the history
  • Loading branch information
davidmisiak committed Oct 28, 2021
1 parent e30e6b7 commit 6d42857
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
11 changes: 6 additions & 5 deletions src/crypto-providers/ledgerCryptoProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -169,16 +169,17 @@ export const LedgerCryptoProvider: () => Promise<CryptoProvider> = async () => {

const prepareOutput = (
output: _Output,
changeOutputFiles: HwSigningData[],
network: Network,
changeOutputFiles: HwSigningData[],
signingMode: SigningMode,
): LedgerTypes.TxOutput => {
const changeAddressParams = getAddressParameters(changeOutputFiles, output.address, network)
const amount = output.coins
const tokenBundle = prepareTokenBundle(output.tokenBundle)

if (changeAddressParams) {
return prepareChangeOutput(amount, changeAddressParams, tokenBundle)
if (changeAddressParams && signingMode === SigningMode.ORDINARY_TRANSACTION) {
return prepareChangeOutput(output.coins, changeAddressParams, tokenBundle)
}

return {
destination: {
type: LedgerTypes.TxOutputDestinationType.THIRD_PARTY,
Expand Down Expand Up @@ -526,7 +527,7 @@ export const LedgerCryptoProvider: () => Promise<CryptoProvider> = async () => {
(input, i) => prepareInput(signingMode, input, getSigningPath(paymentSigningFiles, i)),
)
const outputs = unsignedTxParsed.outputs.map(
(output) => prepareOutput(output, changeOutputFiles, network),
(output) => prepareOutput(output, network, changeOutputFiles, signingMode),
)
const certificates = unsignedTxParsed.certificates.map(
(certificate) => prepareCertificate(
Expand Down
5 changes: 3 additions & 2 deletions src/crypto-providers/trezorCryptoProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -211,11 +211,12 @@ const TrezorCryptoProvider: () => Promise<CryptoProvider> = async () => {
output: _Output,
network: Network,
changeOutputFiles: HwSigningData[],
signingMode: SigningMode,
): TrezorTypes.CardanoOutput => {
const changeAddressParams = getAddressParameters(changeOutputFiles, output.address, network)
const tokenBundle = prepareTokenBundle(output.tokenBundle, false)

if (changeAddressParams) {
if (changeAddressParams && signingMode === SigningMode.ORDINARY_TRANSACTION) {
return prepareChangeOutput(output.coins, changeAddressParams, tokenBundle)
}

Expand Down Expand Up @@ -472,7 +473,7 @@ const TrezorCryptoProvider: () => Promise<CryptoProvider> = async () => {
(input: _Input, i: number) => prepareInput(input, getSigningPath(paymentSigningFiles, i)),
)
const outputs = unsignedTxParsed.outputs.map(
(output: _Output) => prepareOutput(output, network, changeOutputFiles),
(output: _Output) => prepareOutput(output, network, changeOutputFiles, signingMode),
)
const certificates = unsignedTxParsed.certificates.map(
(certificate: _Certificate) => prepareCertificate(certificate, stakeSigningFiles),
Expand Down

0 comments on commit 6d42857

Please sign in to comment.