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

Refactor ledger-related logic #229

Merged
merged 27 commits into from
Sep 28, 2023

Conversation

dhriaznov
Copy link
Contributor

@dhriaznov dhriaznov commented Aug 29, 2023

🔘 PR Type

  • Refactoring (no functional changes, no api changes)
  • Documentation content changes

📜 Background

We'd like to refactor the ledger-related code to get rid of some tech debt.

Issue Link: #[ENG-2537]
Context Link (if applicable):

🔄 Changes

Does this PR introduce a breaking change?

  • Yes, Incompatible API changes
  • No, Adds functionality (backwards compatible)
  • No, Bug fixes (backwards compatible)

Changes:

  • Moved btc and stx ledger functions to separate files inside ledger folder
  • Changed the function params to use object named params
  • Added more usage of constants instead of hardcoded values
  • Added more code description

Impact:

  • This PR doesn't change the code logic but improves the code readability and quality across ledger-related functions

✅ Review checklist

Please ensure the following are true before merging:

  • Code Style is consistent with the project guidelines.
  • Code is readable and well-commented.
  • No unnecessary or debugging code has been added.
  • Security considerations have been taken into account.
  • The change has been manually tested and works as expected.
  • Breaking changes and their impacts have been considered and documented.
  • Code does not introduce new technical debt or issues.

@dhriaznov dhriaznov self-assigned this Aug 29, 2023
@dhriaznov dhriaznov marked this pull request as ready for review September 4, 2023 20:15
Base automatically changed from denys/eng-2499-add-stx-support-for-ledger-accounts to develop September 7, 2023 09:40
@teebszet
Copy link
Member

reminder: breaking changes in this, so the web-extension PR will have to be released along with this one

@github-actions
Copy link
Contributor

Test this PR with npm i @secretkeylabs/[email protected]

@yknl yknl merged commit 13f301b into develop Sep 28, 2023
3 checks passed
@yknl yknl mentioned this pull request Sep 28, 2023
8 tasks
@victorkirov victorkirov deleted the denys/eng-2537-refactor-ledger-related-logic branch October 31, 2023 06:59
victorkirov added a commit that referenced this pull request Dec 11, 2023
* Include new collecitbles endpoints

* Update name

* Refactor ledger-related logic (#229)

* Add STX support for Ledger accounts

* Update `signLedgerStxTransaction` method to use `transactionBuffer` instead of `transaction`

* Update package-lock.json

* Fix typo in `addSignatureToStxTransaction` method

* Update package-lock.json

* Refactor ledger-related logic

* Add more code description

* Add `StacksRecipient` type to `transactions/stx.ts`

* Use more constants instead of hardcoded values for ledger logic

* Move `btc` and `stx` ledger functions to separate files inside `ledger` folder

* Add `LedgerErrors` enum and throw an error when user rejects stx address

* feat: add Ordinal UTXO from Xverse API functions (#246)

* feat: add Ordinal UTXO from Xverse API functions

* Add epic rarity

* Release/v1.8.0 (#249)

* release v1.8.0

* package-lock

---------

Co-authored-by: Tim Man <[email protected]>

* release: 1.8.1 (#250)

* fix: update scure/btc to 1.1.0 to fix bip322 message signing (#251)

* fix: update scure/btc to 1.1.0 to fix bip322 message signing

* fix: pass tests

* 1.8.2 (#252)

---------

Co-authored-by: Den <[email protected]>
Co-authored-by: Victor Kirov <[email protected]>
Co-authored-by: Ken Liao <[email protected]>
Co-authored-by: Tim Man <[email protected]>
victorkirov added a commit that referenced this pull request Dec 13, 2023
* init seed vault

* updated seed vault utils

* update seed vault storage impl

* init aes gcm impl

* move wallet encryption utils to seed vault

* fix encryptDecryptMnemonic tests

* updated lock file

* moved tests to seed vault and added changePassword methods

* code improvements

* fix tests

* general refactor

* added unlock vault method and tests

* store seed vault version

* init

* Add transaction actions and solvers

* Move to different dir and add signing

* fix types imports

* fix some testnet issues

* Add native segwit support

* Add compilation options

* Start on split

* Add some more comments

* savepoint

* update  crypto adapter interface

* Simplify and implement split action

* implement publish method

* Add fee estimate in utxo selection logic

* Refactor context addresses into payments and ordinals

* added clearVault and isUnlocked util

* Don't spend dust UTXOs

* Split inscription ids into returned, sent and fees

* Only fetch inscriptions on demand

* only overwrite the stored seed when changing password

* Add send and extract ordinals methods

* Fetch ordinal IDs in batch

* clean comments

* update store seed methods and tests

* Fix a few minor bugs from testing

* expose overwrite seed flag

* Revert "expose overwrite seed flag"

This reverts commit a56fbd4.

* feat: add Ordinal UTXO from Xverse API functions

* init utxo cache

* update cache with new utxo if missing in cache

* updated utxo cache implementation

* Get Ordinal collectible data from API (#3)

* Include new collecitbles endpoints

* Update name

* Refactor ledger-related logic (#229)

* Add STX support for Ledger accounts

* Update `signLedgerStxTransaction` method to use `transactionBuffer` instead of `transaction`

* Update package-lock.json

* Fix typo in `addSignatureToStxTransaction` method

* Update package-lock.json

* Refactor ledger-related logic

* Add more code description

* Add `StacksRecipient` type to `transactions/stx.ts`

* Use more constants instead of hardcoded values for ledger logic

* Move `btc` and `stx` ledger functions to separate files inside `ledger` folder

* Add `LedgerErrors` enum and throw an error when user rejects stx address

* feat: add Ordinal UTXO from Xverse API functions (#246)

* feat: add Ordinal UTXO from Xverse API functions

* Add epic rarity

* Release/v1.8.0 (#249)

* release v1.8.0

* package-lock

---------

Co-authored-by: Tim Man <[email protected]>

* release: 1.8.1 (#250)

* fix: update scure/btc to 1.1.0 to fix bip322 message signing (#251)

* fix: update scure/btc to 1.1.0 to fix bip322 message signing

* fix: pass tests

* 1.8.2 (#252)

---------

Co-authored-by: Den <[email protected]>
Co-authored-by: Victor Kirov <[email protected]>
Co-authored-by: Ken Liao <[email protected]>
Co-authored-by: Tim Man <[email protected]>

* integrate seed vault

* Fix error msg

* add todos

* merge with public

* integrate with utxo cache and use bundle schema

* export UTXO cache

* fix some bugs

* Add send max btc function

* Add combine UTXOs and improve recoverOrdinal

* Refactor outputs to be post computed

* fix output calc

* Add fee output breakdown

* fix txn signing on address class

* Fix derivation for taproot

* some bug fixes and functions

* Add context tests

* Change btc export name

* add ledger support and simplify signing

* Remove broken tests

* Add dummy sign

* Fix issues with change calculation

* Fix dummy p2tr script

* Fix cache set method

* Fix issue with large change changing the vsize

* Txn Context tests

* Fix utxo cache tests

* Add context tests

* enhanced txn tests

* add excludeOutpointList option

* Add utils tests

* add send utxo and split utxo tests

* Added split utxo test and fixed bug

* Add action processor tests

* Add UTXO cache versioning and TTL

* only sign dummy txn if inputs

* Add missing await

* remove duplicate export

* Make output insc and satributes not optional

* Switch wallet context to account type

* inject esplora api provider

* Expect ledger transport only on sign

* remove unused function

* Use wallet derivation path methods

* Extract context create function to a factory file

* Clean up exports

* Rename satributes on outputs

* default to software account

* Fix export issue

* Fix exports

* Update axios

* set axios version

* Parse PSBTs (#315)

* Add PSBT parsing

* change from wallet bool to from address string

* fix tests

* Fix storage adapter export

* fix fee rate calc and test import

* Fix export of OrdinalsApi

* Revert outspend changes

* Update axios and move satribute identification to cache

* Merge branch 'develop' of https://github.com/secretkeylabs/xverse-core into vic/psbt-parse

* Remove type casting

* Add PSBT types

* PR review fixes

* extract common PSBT and txn code to utils

* Export enhanced PSBT types

* Export transaction output types

* Align txn and psbt return types

* Fix limit in ordinals provider

---------

Co-authored-by: Mahmoud <[email protected]>
Co-authored-by: Imamah-Zafar <[email protected]>
Co-authored-by: Den <[email protected]>
Co-authored-by: Ken Liao <[email protected]>
Co-authored-by: Tim Man <[email protected]>
teebszet pushed a commit that referenced this pull request Nov 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants