-
Notifications
You must be signed in to change notification settings - Fork 58
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor!: makeTxIn.address required, add NewTxIn that has no address
refactor NewTxAlonzo to use NewTxBodyAlonzo that uses NewTxIn
- Loading branch information
1 parent
a2b45db
commit 83cd354
Showing
35 changed files
with
167 additions
and
112 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 14 additions & 12 deletions
26
packages/wallet/src/KeyManagement/util/ownSignatureKeyPaths.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,29 @@ | ||
import { AccountKeyDerivationPath, GroupedAddress, InputAddressResolver, KeyRole } from '../types'; | ||
import { Cardano, util } from '@cardano-sdk/core'; | ||
import { GroupedAddress, KeyType } from '../types'; | ||
import { uniq } from 'lodash-es'; | ||
|
||
export interface PartialDerivationPath { | ||
role: KeyType; | ||
index: number; | ||
} | ||
|
||
/** | ||
* Assumes that a single staking key is used for all addresses (index=0) | ||
* | ||
* @returns {PartialDerivationPath[]} derivation paths for keys to sign transaction with | ||
* @returns {AccountKeyDerivationPath[]} derivation paths for keys to sign transaction with | ||
*/ | ||
export const ownSignatureKeyPaths = ( | ||
txBody: Cardano.TxBodyAlonzo, | ||
knownAddresses: GroupedAddress[] | ||
): PartialDerivationPath[] => { | ||
txBody: Cardano.NewTxBodyAlonzo, | ||
knownAddresses: GroupedAddress[], | ||
resolveInputAddress: InputAddressResolver | ||
): AccountKeyDerivationPath[] => { | ||
const paymentKeyPaths = uniq( | ||
txBody.inputs.map((input) => knownAddresses.find(({ address }) => address === input.address)).filter(util.isNotNil) | ||
txBody.inputs | ||
.map((input) => { | ||
const ownAddress = resolveInputAddress(input); | ||
if (!ownAddress) return null; | ||
return knownAddresses.find(({ address }) => address === ownAddress); | ||
}) | ||
.filter(util.isNotNil) | ||
).map(({ type, index }) => ({ index, role: Number(type) })); | ||
const isStakingKeySignatureRequired = txBody.certificates?.length; | ||
if (isStakingKeySignatureRequired) { | ||
return [...paymentKeyPaths, { index: 0, role: KeyType.Stake }]; | ||
return [...paymentKeyPaths, { index: 0, role: KeyRole.Stake }]; | ||
} | ||
return paymentKeyPaths; | ||
}; |
9 changes: 5 additions & 4 deletions
9
packages/wallet/src/KeyManagement/util/stubSignTransaction.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.