Skip to content
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

/construction/derive staking support #198

Closed
5 tasks done
AlanVerbner opened this issue Nov 1, 2020 · 0 comments · Fixed by #207
Closed
5 tasks done

/construction/derive staking support #198

AlanVerbner opened this issue Nov 1, 2020 · 0 comments · Fixed by #207
Assignees
Labels
construction-api enhancement New feature or request
Projects
Milestone

Comments

@AlanVerbner
Copy link
Contributor

AlanVerbner commented Nov 1, 2020

Description

  • There are several addresses types in Cardano (for further info see the Ledger Spec - Section 4). Two of them are going to be supported by Cardano Rosetta:
    • Enterprise addresses: do not hold any delegation rights and will be created when no stake key is sent to the API
    • Base addresses: associated to a payment and a staking credential.

Enterprise addresses are already supported and the goal for this task is to let users to be able to create Base addresses as well, in order to do so, /construction/derive needs to be updated. A non exhaustive list of sub tasks can be defined as:

  • Update openApi.json to let ConstructionDeriveRequest to accept staking_credential: #/components/schemas/PublicKey as an optional parameter alongside with a new type AddressType = {Enterprise, Base, Reward} which is optional as well.
  • Regenerate the API ts types to include the new addition, yarn generate-rosetta-types
  • Modify construction-controller.ts to process the before mentioned parameter and forward it to cardano-service.ts
  • Add the proper logic in cardano-service.ts to generate:
    • A BaseAddress if both credentials are received and type is Base
    • A RewardAddress if type is Reward (only the required public key is used as the staking key)
    • An Enterprise address if a single key is received (i.e. no staking_credential) and type is Enterprise or empty
    • Error otherwise
  • Update the test to properly validate the new functionality. The tests should, at least, return ok results for the given test vectors.

Test Vector

  1. Base Address
cat addr.prv \
>   | ./cardano-address key public \
>   | ./cardano-address address payment  --network-tag 1 \
>   | ./cardano-address address delegation $(cat stake.prv | ./cardano-address key public)
addr1q9dhy809valxaer3nlvg2h5nudd62pxp6lu0cs36zczhfr98y6pah6lvppk8xft57nef6yexqh6rr204yemcmm3emhzsgg4fg0

stake.prv.txt
addr.prv.txt

Note: Uploaded as txt due to GH restrictions

public_key.hex_bytes: 159abeeecdf167ccc0ea60b30f9522154a0d74161aeb159fb43b6b0695f057b3
staking_key.hex_bytes: 964774728c8306a42252adbfb07ccd6ef42399f427ade25a5933ce190c5a8760

  1. Reward address

https://cardanoscan.io/address/015b721de5677e6ee4719fd8855e93e35ba504c1d7f8fc423a1605748ca72683dbebec086c732574f4f29d132605f431a9f526778dee39ddc5

keyhash: a72683dbebec086c732574f4f29d132605f431a9f526778dee39ddc5
BECH32 stake1uxnjdq7ma0kqsmrny460fu5azvnqtap3486jvaudacuam3g3yc4nu

staking_key.hex_bytes: 964774728c8306a42252adbfb07ccd6ef42399f427ade25a5933ce190c5a8760

References

@AlanVerbner AlanVerbner created this issue from a note in staking (To Do) Nov 1, 2020
@AlanVerbner AlanVerbner added construction-api enhancement New feature or request labels Nov 1, 2020
@tomasBustamante tomasBustamante self-assigned this Nov 3, 2020
@tomasBustamante tomasBustamante moved this from To Do to In Progress in staking Nov 3, 2020
tomasBustamante added a commit that referenced this issue Nov 4, 2020
tomasBustamante added a commit that referenced this issue Nov 5, 2020
tomasBustamante added a commit that referenced this issue Nov 5, 2020
staking credential and address type which are optional

Refs #198
tomasBustamante added a commit that referenced this issue Nov 6, 2020
tomasBustamante added a commit that referenced this issue Nov 6, 2020
tomasBustamante added a commit that referenced this issue Nov 6, 2020
staking credential and address type which are optional

Refs #198
tomasBustamante added a commit that referenced this issue Nov 11, 2020
tomasBustamante added a commit that referenced this issue Nov 11, 2020
staking credential and address type which are optional

Refs #198
tomasBustamante added a commit that referenced this issue Nov 11, 2020
Information to generate the base and reward addresses used for assertions

Refs #198
tomasBustamante added a commit that referenced this issue Nov 11, 2020
staking automation moved this from Review In Progress to Done Nov 11, 2020
tomasBustamante added a commit that referenced this issue Nov 11, 2020
* feat: add staking_credential and address_type in ConstructionDeriveRequest

* refactor: move staking_credential and address_type into metadata of ConstructionDeriveRequest

* feat: add invalid address type error

* feat: add metadata validation in construction derive controller

* refactor: generatePayload parameters in construction derive tests

* test: construction derive with invalid staking key

* refactor: exclude enum for address type in openApi

* test: construction derive with invalid address type

* test: construction derive for Base and Reward addresses

* feat: construction derive Base and Reward address support

* test: construction derive validation for staking key size

* test: construction derive reward address correct bech32 address

* fix: correct address prefix for reward address creation

* refactor: move UTxOAddressTypes enum to constants file

* refactor: rename UTxOAddressType and make Enterprise default value

* refactor: add comment for staking address prefix

* test: add comments to construction derive tests

* refactor: use proper error for invalid staking key

* test: construction derive error when no staking key for base address

* feat: missing staking key validation for base address generation

* refactor: rename AddressType

* refactor: address type description in openApi

Refs #198
AlanVerbner pushed a commit that referenced this issue Nov 28, 2020
* feat: add staking_credential and address_type in ConstructionDeriveRequest

* refactor: move staking_credential and address_type into metadata of ConstructionDeriveRequest

* feat: add invalid address type error

* feat: add metadata validation in construction derive controller

* refactor: generatePayload parameters in construction derive tests

* test: construction derive with invalid staking key

* refactor: exclude enum for address type in openApi

* test: construction derive with invalid address type

* test: construction derive for Base and Reward addresses

* feat: construction derive Base and Reward address support

* test: construction derive validation for staking key size

* test: construction derive reward address correct bech32 address

* fix: correct address prefix for reward address creation

* refactor: move UTxOAddressTypes enum to constants file

* refactor: rename UTxOAddressType and make Enterprise default value

* refactor: add comment for staking address prefix

* test: add comments to construction derive tests

* refactor: use proper error for invalid staking key

* test: construction derive error when no staking key for base address

* feat: missing staking key validation for base address generation

* refactor: rename AddressType

* refactor: address type description in openApi

Refs #198
AlanVerbner pushed a commit that referenced this issue Dec 2, 2020
* feat: add staking_credential and address_type in ConstructionDeriveRequest

* refactor: move staking_credential and address_type into metadata of ConstructionDeriveRequest

* feat: add invalid address type error

* feat: add metadata validation in construction derive controller

* refactor: generatePayload parameters in construction derive tests

* test: construction derive with invalid staking key

* refactor: exclude enum for address type in openApi

* test: construction derive with invalid address type

* test: construction derive for Base and Reward addresses

* feat: construction derive Base and Reward address support

* test: construction derive validation for staking key size

* test: construction derive reward address correct bech32 address

* fix: correct address prefix for reward address creation

* refactor: move UTxOAddressTypes enum to constants file

* refactor: rename UTxOAddressType and make Enterprise default value

* refactor: add comment for staking address prefix

* test: add comments to construction derive tests

* refactor: use proper error for invalid staking key

* test: construction derive error when no staking key for base address

* feat: missing staking key validation for base address generation

* refactor: rename AddressType

* refactor: address type description in openApi

Refs #198
rhyslbw pushed a commit that referenced this issue Dec 4, 2020
* feat: add staking_credential and address_type in ConstructionDeriveRequest

* refactor: move staking_credential and address_type into metadata of ConstructionDeriveRequest

* feat: add invalid address type error

* feat: add metadata validation in construction derive controller

* refactor: generatePayload parameters in construction derive tests

* test: construction derive with invalid staking key

* refactor: exclude enum for address type in openApi

* test: construction derive with invalid address type

* test: construction derive for Base and Reward addresses

* feat: construction derive Base and Reward address support

* test: construction derive validation for staking key size

* test: construction derive reward address correct bech32 address

* fix: correct address prefix for reward address creation

* refactor: move UTxOAddressTypes enum to constants file

* refactor: rename UTxOAddressType and make Enterprise default value

* refactor: add comment for staking address prefix

* test: add comments to construction derive tests

* refactor: use proper error for invalid staking key

* test: construction derive error when no staking key for base address

* feat: missing staking key validation for base address generation

* refactor: rename AddressType

* refactor: address type description in openApi

Refs #198
AlanVerbner pushed a commit that referenced this issue Dec 7, 2020
* feat: add staking_credential and address_type in ConstructionDeriveRequest

* refactor: move staking_credential and address_type into metadata of ConstructionDeriveRequest

* feat: add invalid address type error

* feat: add metadata validation in construction derive controller

* refactor: generatePayload parameters in construction derive tests

* test: construction derive with invalid staking key

* refactor: exclude enum for address type in openApi

* test: construction derive with invalid address type

* test: construction derive for Base and Reward addresses

* feat: construction derive Base and Reward address support

* test: construction derive validation for staking key size

* test: construction derive reward address correct bech32 address

* fix: correct address prefix for reward address creation

* refactor: move UTxOAddressTypes enum to constants file

* refactor: rename UTxOAddressType and make Enterprise default value

* refactor: add comment for staking address prefix

* test: add comments to construction derive tests

* refactor: use proper error for invalid staking key

* test: construction derive error when no staking key for base address

* feat: missing staking key validation for base address generation

* refactor: rename AddressType

* refactor: address type description in openApi

Refs #198
AlanVerbner pushed a commit that referenced this issue Dec 8, 2020
* feat: add staking_credential and address_type in ConstructionDeriveRequest

* refactor: move staking_credential and address_type into metadata of ConstructionDeriveRequest

* feat: add invalid address type error

* feat: add metadata validation in construction derive controller

* refactor: generatePayload parameters in construction derive tests

* test: construction derive with invalid staking key

* refactor: exclude enum for address type in openApi

* test: construction derive with invalid address type

* test: construction derive for Base and Reward addresses

* feat: construction derive Base and Reward address support

* test: construction derive validation for staking key size

* test: construction derive reward address correct bech32 address

* fix: correct address prefix for reward address creation

* refactor: move UTxOAddressTypes enum to constants file

* refactor: rename UTxOAddressType and make Enterprise default value

* refactor: add comment for staking address prefix

* test: add comments to construction derive tests

* refactor: use proper error for invalid staking key

* test: construction derive error when no staking key for base address

* feat: missing staking key validation for base address generation

* refactor: rename AddressType

* refactor: address type description in openApi

Refs #198
AlanVerbner pushed a commit that referenced this issue Dec 11, 2020
* feat: add staking_credential and address_type in ConstructionDeriveRequest

* refactor: move staking_credential and address_type into metadata of ConstructionDeriveRequest

* feat: add invalid address type error

* feat: add metadata validation in construction derive controller

* refactor: generatePayload parameters in construction derive tests

* test: construction derive with invalid staking key

* refactor: exclude enum for address type in openApi

* test: construction derive with invalid address type

* test: construction derive for Base and Reward addresses

* feat: construction derive Base and Reward address support

* test: construction derive validation for staking key size

* test: construction derive reward address correct bech32 address

* fix: correct address prefix for reward address creation

* refactor: move UTxOAddressTypes enum to constants file

* refactor: rename UTxOAddressType and make Enterprise default value

* refactor: add comment for staking address prefix

* test: add comments to construction derive tests

* refactor: use proper error for invalid staking key

* test: construction derive error when no staking key for base address

* feat: missing staking key validation for base address generation

* refactor: rename AddressType

* refactor: address type description in openApi

Refs #198
AlanVerbner pushed a commit that referenced this issue Dec 11, 2020
* feat: add staking_credential and address_type in ConstructionDeriveRequest

* refactor: move staking_credential and address_type into metadata of ConstructionDeriveRequest

* feat: add invalid address type error

* feat: add metadata validation in construction derive controller

* refactor: generatePayload parameters in construction derive tests

* test: construction derive with invalid staking key

* refactor: exclude enum for address type in openApi

* test: construction derive with invalid address type

* test: construction derive for Base and Reward addresses

* feat: construction derive Base and Reward address support

* test: construction derive validation for staking key size

* test: construction derive reward address correct bech32 address

* fix: correct address prefix for reward address creation

* refactor: move UTxOAddressTypes enum to constants file

* refactor: rename UTxOAddressType and make Enterprise default value

* refactor: add comment for staking address prefix

* test: add comments to construction derive tests

* refactor: use proper error for invalid staking key

* test: construction derive error when no staking key for base address

* feat: missing staking key validation for base address generation

* refactor: rename AddressType

* refactor: address type description in openApi

Refs #198
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
construction-api enhancement New feature or request
Projects
No open projects
Development

Successfully merging a pull request may close this issue.

2 participants