New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weβll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Coin Modularization] Cardano #6812
base: develop
Are you sure you want to change the base?
Conversation
The latest updates on your projects. Learn more about Vercel for Git βοΈ
3 Ignored Deployments
|
00de9c9
to
5b48fc3
Compare
New dependencies detected. Learn more about Socket for GitHub βοΈ
|
Signed-off-by: StΓ©phane Prohaszka <stephane.prohaszka@ledger.fr>
Signed-off-by: StΓ©phane Prohaszka <stephane.prohaszka@ledger.fr>
Signed-off-by: StΓ©phane Prohaszka <stephane.prohaszka@ledger.fr>
5b48fc3
to
db91ef9
Compare
Signed-off-by: StΓ©phane Prohaszka <stephane.prohaszka@ledger.fr>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, but a few questions because I might have missed some of the explanations for some logic in LLC π
return { | ||
getAddress: async ({ | ||
path, | ||
stakingPathString, | ||
networkParams, | ||
verify, | ||
}: GetAddressRequest): Promise<CardanoAddress> => { | ||
const network = | ||
networkParams.networkId === Networks.Mainnet.networkId | ||
? Networks.Mainnet | ||
: Networks.Testnet; | ||
|
||
const r = await ada.deriveAddress({ | ||
network, | ||
address: { | ||
type: AddressType.BASE_PAYMENT_KEY_STAKE_KEY, | ||
params: { | ||
spendingPath: str_to_path(path), | ||
stakingPath: str_to_path(stakingPathString), | ||
}, | ||
}, | ||
}); | ||
if (verify) { | ||
await ada.showAddress({ | ||
network, | ||
address: { | ||
type: AddressType.BASE_PAYMENT_KEY_STAKE_KEY, | ||
params: { | ||
spendingPath: str_to_path(path), | ||
stakingPath: str_to_path(stakingPathString), | ||
}, | ||
}, | ||
}); | ||
} | ||
const address = TyphonUtils.getAddressFromHex(r.addressHex) as TyphonAddress.BaseAddress; | ||
return { | ||
address: address.getBech32(), | ||
// Here, we use publicKey hash, as cardano app doesn't export the public key | ||
publicKey: address.paymentCredential.hash, | ||
}; | ||
}, | ||
getPublicKey: async (accountPath: string): Promise<CardanoExtendedPublicKey> => { | ||
return ada.getExtendedPublicKey({ | ||
path: str_to_path(accountPath), | ||
}); | ||
}, | ||
sign: async ({ | ||
unsignedTransaction, | ||
accountPubKey, | ||
accountIndex, | ||
networkParams, | ||
}: CardanoSignRequest): Promise<CardanoSignature> => { | ||
const rawInputs = unsignedTransaction.getInputs(); | ||
const ledgerAppInputs = rawInputs.map(i => prepareLedgerInput(i, accountIndex)); | ||
|
||
const rawOutptus = unsignedTransaction.getOutputs(); | ||
const ledgerAppOutputs = rawOutptus.map(o => prepareLedgerOutput(o, accountIndex)); | ||
|
||
const rawCertificates = unsignedTransaction.getCertificates(); | ||
const ledgerCertificates = rawCertificates.map(prepareCertificate); | ||
|
||
const rawWithdrawals = unsignedTransaction.getWithdrawals(); | ||
const ledgerWithdrawals = rawWithdrawals.map(prepareWithdrawal); | ||
|
||
const auxiliaryDataHashHex = unsignedTransaction.getAuxiliaryDataHashHex(); | ||
|
||
const network = | ||
networkParams.networkId === Networks.Mainnet.networkId | ||
? Networks.Mainnet | ||
: Networks.Testnet; | ||
|
||
const trxOptions: SignTransactionRequest = { | ||
signingMode: TransactionSigningMode.ORDINARY_TRANSACTION, | ||
tx: { | ||
network, | ||
inputs: ledgerAppInputs, | ||
outputs: ledgerAppOutputs, | ||
certificates: ledgerCertificates, | ||
withdrawals: ledgerWithdrawals, | ||
fee: unsignedTransaction.getFee().toString(), | ||
ttl: unsignedTransaction.getTTL()?.toString(), | ||
validityIntervalStart: null, | ||
auxiliaryData: auxiliaryDataHashHex | ||
? { | ||
type: TxAuxiliaryDataType.ARBITRARY_HASH, | ||
params: { | ||
hashHex: auxiliaryDataHashHex, | ||
}, | ||
} | ||
: null, | ||
}, | ||
additionalWitnessPaths: [], | ||
}; | ||
|
||
const r = await ada.signTransaction(trxOptions); | ||
return signTx(unsignedTransaction, accountPubKey, r.witnesses); | ||
}, | ||
}; | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Feels kinda wrong to have that much coin logic into LLC don't you think ? π€
Really feels like the coin-module would be unusable without LLC here π«€
export type { APIGetPoolsDetail, StakePool } from "@ledgerhq/coin-cardano/api/api-types"; | ||
export { fetchPoolDetails } from "@ledgerhq/coin-cardano/api/getPools"; | ||
export { LEDGER_POOL_IDS } from "@ledgerhq/coin-cardano/utils"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this necessary ? Can't UI specific to Cardano simply get the types from @ledgerhq/coin-cardano
directly ? Or do you specifically want that to be an entrypoint for those types & constants ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same thing here I'm not quite sure to get why this should continue to live in LLC ?
β Checklist
npx changeset
was attached.π Description
Move Cardano...
β Context
π§ Checklist for the PR Reviewers