-
Notifications
You must be signed in to change notification settings - Fork 217
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
Add collateral inputs to wallet types, DB, and API. #2817
Conversation
05b8429
to
55a7d0f
Compare
Tx
and UnsignedTx
.This commit performs the minimum amount of work necessary to add fields for collateral inputs to the following types: - `Tx` - `UnsignedTx` - `TransactionInfo`
55a7d0f
to
cd90151
Compare
@@ -1212,6 +1230,27 @@ x-transactionResolvedInputs: &transactionResolvedInputs | |||
type: integer | |||
minimum: 0 | |||
|
|||
x-transactionResolvedCollateral: &transactionResolvedCollateral | |||
description: A list of transaction inputs used for collateral |
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.
What does "resolved" here mean?
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.
What does "resolved" here mean?
Good question. I'm following the existing terminology for inputs, as much as possible.
For "resolved inputs": in addition to including the txId
and txIndex
(which is enough to uniquely identify an input), we also include the following information, which shows what this input "resolves", or "maps" to:
- the
address
- the
derivationPath
- the
amount
This commit replaces the use of named field puns with generic field accessors in order to make the function a bit more concise. In response to: https://github.com/input-output-hk/cardano-wallet/pull/2817/files#r687606529
This commit replaces the use of named field puns with generic field accessors in order to make the function a bit more concise. In response to: https://github.com/input-output-hk/cardano-wallet/pull/2817/files#r687606529
This commit uses named record fields rather than a positional style.
cfb159c
to
fd0c082
Compare
The subtleties are lost on me, but I've read through this carefully and it looks logical and consistent. By the subtleties, I just mean I'm not sure I can answer the questions of:
|
Thanks for looking through!
I think the main principle here is that "collateral inputs" should have a similar representation to ordinary inputs, in both the API and the DB. The primary differences (at the type-level) are:
So in the API, we have the following differences: - x-transactionResolvedInputs: &transactionResolvedInputs
+ x-transactionResolvedCollateral: &transactionResolvedCollateral
- description: A list of transaction inputs
+ description: A list of transaction inputs used for collateral
type: array
- minItems: 1
+ minItems: 0
items:
type: object
required:
- id
- index
- address
- amount
- derivation_path
properties:
address: *addressId
amount: *amount
- assets: *walletAssets
id: *transactionId
derivation_path: *derivationPath
index:
type: integer
minimum: 0 - x-transactionInputs: &transactionInputs
+ x-transactionCollateral: &transactionCollateral
description: |
- A list of transaction inputs.
+ A list of transaction inputs used for collateral.
type: array
minItems: 0
items:
type: object
required:
- id
- index
properties:
address: *addressId
amount: *amount
- assets: *walletAssets
id: *transactionId
index:
type: integer
minimum: 0 |
The schema for You might have wondered whether |
For brevity, use "collateral" rather than "collateralInputs" in record field names. This is consistent with the API naming.
fd0c082
to
73203d5
Compare
@@ -2856,7 +2856,7 @@ mkApiTransaction | |||
-> Lens' (ApiTransaction n) (Maybe ApiBlockReference) | |||
-> IO (ApiTransaction n) | |||
mkApiTransaction | |||
ti txid mfee ins cins outs ws (meta, timestamp) txMeta setTimeReference = do | |||
ti txid mfee cins ins outs ws (meta, timestamp) txMeta setTimeReference = do |
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.
Ooh, this looks like a very likely place to make a mistake, is there anyway we can distinguish between the two types of [(TxIn, Maybe TxOut)] that makes sense in this context?
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.
@sevanspowell I agree that it would be easy for a caller to get these arguments muddled up, especially given that the types are identical.
I've created a record type MkApiTransactionParams
, and altered mkApiTransaction
to take this record instead of all the positional parameters. Hopefully this should make it easier at call sites to determine which parameter is which.
Commit: c9bc8e6
Thanks for this! I've re-reviewed and added my ✔️ |
This change replaces the use of positional arguments with a record type in function `mkApiTransaction`, making it clearer at call sites which argument is which, and hopefully less likely for arguments with the same type to be supplied in the wrong order.
bors r+ |
Build succeeded: |
Issue Number
ADP-967 / ADP-1069 / ADP-1039
Overview
This PR adds all the boilerplate required for collateral inputs to:
This PR makes no attempt to manipulate collateral inputs in any way, other than to marshall data around from one layer to another. It also makes no attempt to parse collateral inputs from network blocks. Where necessary, future work has been marked with
TODO
comments. (With a link to ADP-957).Currently, all API calls returning collateral inputs will return the empty list.
API
This PR adds API entries and types for collateral inputs, with the following differences from ordinary inputs:
This is reflected in the following differences between types:
Database
This PR adds a
TxCollateral
table, with analagous fields to theTxIn
table.Primitive Types
This PR adds fields for collateral inputs to the following primitive types:
UnsignedTx
TransactionInfo
Tx