diff --git a/apps/wallet-mobile/package.json b/apps/wallet-mobile/package.json index 07f5c995ad..aa724435f6 100644 --- a/apps/wallet-mobile/package.json +++ b/apps/wallet-mobile/package.json @@ -124,19 +124,19 @@ "@shopify/flash-list": "^1.4.1", "@types/bip39": "^3.0.0", "@types/pbkdf2": "^3.1.2", - "@yoroi/api": "1.5.1", - "@yoroi/common": "1.5.3", - "@yoroi/exchange": "2.1.0", - "@yoroi/explorers": "1.0.1", - "@yoroi/identicon": "1.0.0", - "@yoroi/links": "1.5.6", - "@yoroi/portfolio": "1.0.1", - "@yoroi/resolver": "2.0.5", - "@yoroi/setup-wallet": "1.0.0", - "@yoroi/staking": "1.5.1", - "@yoroi/swap": "2.0.0", + "@yoroi/api": "^1.5.2", + "@yoroi/common": "^1.5.4", + "@yoroi/exchange": "^2.1.1", + "@yoroi/explorers": "^1.0.2", + "@yoroi/identicon": "^1.0.1", + "@yoroi/links": "^1.5.7", + "@yoroi/portfolio": "^1.0.2", + "@yoroi/resolver": "^2.0.6", + "@yoroi/setup-wallet": "^1.0.1", + "@yoroi/staking": "^1.5.2", + "@yoroi/swap": "^2.0.1", "@yoroi/theme": "^1.0.0", - "@yoroi/transfer": "1.0.0", + "@yoroi/transfer": "^1.0.1", "add": "2.0.6", "assert": "^2.0.0", "axios": "^1.5.0", @@ -257,7 +257,7 @@ "@types/uuid": "^8.3.4", "@typescript-eslint/eslint-plugin": "^5.0.0", "@typescript-eslint/parser": "^5.32.0", - "@yoroi/types": "1.5.6", + "@yoroi/types": "^1.5.7", "babel-eslint": "^10.1.0", "babel-jest": "^29.2.1", "babel-loader": "8.2.2", @@ -303,7 +303,7 @@ }, "engineStrict": true, "engine": { - "node": "~16.19.0", + "node": "~18.00.0", "npm": "~7.19.1" }, "ts-node": { diff --git a/packages/api/package.json b/packages/api/package.json index 2f759b830e..90b030fd08 100644 --- a/packages/api/package.json +++ b/packages/api/package.json @@ -1,6 +1,6 @@ { "name": "@yoroi/api", - "version": "1.5.1", + "version": "1.5.2", "description": "The API package of Yoroi SDK", "keywords": [ "yoroi", @@ -133,9 +133,7 @@ ] }, "dependencies": { - "@emurgo/cip14-js": "^3.0.1", - "@yoroi/common": "1.5.3", - "@yoroi/types": "1.5.6" + "@emurgo/cip14-js": "^3.0.1" }, "devDependencies": { "@commitlint/config-conventional": "^17.0.2", @@ -150,6 +148,7 @@ "@types/jest": "^29.5.12", "@types/react": "^18.2.55", "@types/react-test-renderer": "^18.0.7", + "@yoroi/types": "^1.5.7", "axios": "^1.5.0", "axios-mock-adapter": "^1.21.5", "commitlint": "^17.0.2", @@ -173,6 +172,7 @@ "zod": "^3.22.1" }, "peerDependencies": { + "@yoroi/common": "^1.5.4", "axios": "^1.5.0", "react": ">= 16.8.0 <= 19.0.0", "react-query": "^3.39.3", diff --git a/packages/common/package.json b/packages/common/package.json index f239f1d84b..ceaa1c8f3f 100644 --- a/packages/common/package.json +++ b/packages/common/package.json @@ -1,6 +1,6 @@ { "name": "@yoroi/common", - "version": "1.5.3", + "version": "1.5.4", "description": "The Common package of Yoroi SDK", "keywords": [ "yoroi", @@ -146,6 +146,7 @@ "@types/jest": "^29.5.12", "@types/react": "^18.2.55", "@types/react-test-renderer": "^18.0.7", + "@yoroi/types": "^1.5.7", "axios": "^1.5.0", "axios-mock-adapter": "^1.21.5", "bignumber.js": "^9.0.1", @@ -172,9 +173,6 @@ "typescript": "^5.3.3", "zod": "^3.22.1" }, - "dependencies": { - "@yoroi/types": "1.5.6" - }, "peerDependencies": { "@react-native-async-storage/async-storage": ">= 1.19.3 <= 1.20.0", "axios": "^1.5.0", diff --git a/packages/dapp-connector/package.json b/packages/dapp-connector/package.json index 9d17ff9b98..b0b46474fb 100644 --- a/packages/dapp-connector/package.json +++ b/packages/dapp-connector/package.json @@ -1,6 +1,6 @@ { "name": "@yoroi/dapp-connector", - "version": "1.0.0", + "version": "1.0.1", "description": "The Dapp Connector package of Yoroi SDK", "keywords": [ "yoroi", @@ -155,7 +155,7 @@ "@types/jest": "^29.5.12", "@types/react": "^18.2.55", "@types/react-test-renderer": "^18.0.7", - "@yoroi/types": "1.5.6", + "@yoroi/types": "^1.5.7", "axios-mock-adapter": "^1.21.5", "bignumber.js": "^9.0.1", "commitlint": "^17.0.2", diff --git a/packages/exchange/package.json b/packages/exchange/package.json index 3bd1213d48..dd60c789aa 100644 --- a/packages/exchange/package.json +++ b/packages/exchange/package.json @@ -1,6 +1,6 @@ { "name": "@yoroi/exchange", - "version": "2.1.0", + "version": "2.1.1", "description": "The Exchange package of Yoroi SDK", "keywords": [ "yoroi", @@ -128,10 +128,6 @@ "/jest.setup.js" ] }, - "dependencies": { - "@yoroi/common": "1.5.3", - "@yoroi/types": "1.5.6" - }, "devDependencies": { "@commitlint/config-conventional": "^17.0.2", "@react-native-async-storage/async-storage": "^1.19.3", @@ -143,6 +139,7 @@ "@types/jest": "^29.5.12", "@types/react": "^18.2.55", "@types/react-test-renderer": "^18.0.7", + "@yoroi/types": "^1.5.7", "axios": "^1.5.0", "commitlint": "^17.0.2", "del-cli": "^5.0.0", @@ -167,6 +164,7 @@ }, "peerDependencies": { "@react-native-async-storage/async-storage": ">= 1.19.3 <= 1.20.0", + "@yoroi/common": "^1.5.4", "axios": "^1.5.0", "immer": "^10.0.2", "react": ">= 16.8.0 <= 19.0.0", diff --git a/packages/explorers/package.json b/packages/explorers/package.json index ab4ae19393..0a3a1a651d 100644 --- a/packages/explorers/package.json +++ b/packages/explorers/package.json @@ -1,6 +1,6 @@ { "name": "@yoroi/explorers", - "version": "1.0.1", + "version": "1.0.2", "description": "The Explorers package of Yoroi SDK", "keywords": [ "yoroi", @@ -144,7 +144,7 @@ "@types/jest": "^29.5.12", "@types/react": "^18.2.55", "@types/react-test-renderer": "^18.0.7", - "@yoroi/types": "1.5.6", + "@yoroi/types": "^1.5.7", "bignumber.js": "^9.0.1", "commitlint": "^17.0.2", "del-cli": "^5.0.0", @@ -168,7 +168,7 @@ "typescript": "^5.3.3" }, "peerDependencies": { - "@yoroi/common": "1.5.3", + "@yoroi/common": "1.5.4", "immer": "^10.0.3", "react": ">= 16.8.0 <= 19.0.0", "react-native-mmkv": "^2.11.0", diff --git a/packages/identicon/package.json b/packages/identicon/package.json index c9deed5fe6..47d0c79e4a 100644 --- a/packages/identicon/package.json +++ b/packages/identicon/package.json @@ -1,6 +1,6 @@ { "name": "@yoroi/identicon", - "version": "1.0.0", + "version": "1.0.1", "description": "The package to create wallet identicons of Yoroi SDK", "keywords": [ "yoroi", diff --git a/packages/links/package.json b/packages/links/package.json index c42243bce0..f617329f7c 100644 --- a/packages/links/package.json +++ b/packages/links/package.json @@ -1,6 +1,6 @@ { "name": "@yoroi/links", - "version": "1.5.6", + "version": "1.5.7", "description": "The package for managing links of Yoroi SDK", "keywords": [ "yoroi", @@ -136,10 +136,6 @@ "/jest.setup.js" ] }, - "dependencies": { - "@yoroi/common": "1.5.3", - "@yoroi/types": "1.5.6" - }, "devDependencies": { "@commitlint/config-conventional": "^17.0.2", "@react-native-async-storage/async-storage": "^1.19.3", @@ -151,6 +147,7 @@ "@types/jest": "^29.5.12", "@types/react": "^18.2.55", "@types/react-test-renderer": "^18.0.7", + "@yoroi/types": "^1.5.7", "commitlint": "^17.0.2", "del-cli": "^5.0.0", "dependency-cruiser": "^13.1.1", @@ -173,6 +170,7 @@ "zod": "^3.22.2" }, "peerDependencies": { + "@yoroi/common": "^1.5.4", "immer": "^10.0.2", "react": ">= 16.8.0 <= 19.0.0", "zod": "^3.22.2" diff --git a/packages/portfolio/README.md b/packages/portfolio/README.md index 06cfef0f74..75cf6f8753 100644 --- a/packages/portfolio/README.md +++ b/packages/portfolio/README.md @@ -1 +1,108 @@ -# Portfolio package for Yoroi +# @yoroi/portfolio + +The `@yoroi/portfolio` package is an all-in-one solution for managing token portfolios, images, prices, balances, and token information within the Yoroi wallet ecosystem. Designed with modern web and mobile applications in mind, this package not only handles token data but also offers integrated CDN support for images, ensuring smooth and efficient loading, especially on mobile devices. + +By leveraging CDN, it avoids the "lag" associated with directly using IPFS, specially in cases where the images are not pinned to any service. + +Additionally, `@yoroi/portfolio` comes with built-in support for DeFi prices, allowing to fetch and manage the latest token prices with ease. + +- [Installation](#installation) +- [Overview](#overview) +- [API Reference](#api-reference) + - [PortfolioTokenManager](#portfolio-token-manager-maker) + - [PortfolioBalanceManager](#portfolio-balance-manager-maker) +- [Features](#features) +- [Contributing](#contributing) + +## Installation + +You can install the package through: + +```bash +// npm +npm install @yoroi/portfolio + +// yarn +yarn add @yoroi/portfolio + +// workspace +yarn workspace add @yoroi/portfolio +``` + +## Overview + +The `@yoroi/portfolio` package provides two primary factory functions, and one goal which is to facilitate dealing with tokens on web3. +Dealing with Cardano native assets presents unique challenges due to the platform's design and its UTxO model, which differs from the account-based models used by other blockchains like Ethereum. Unlike traditional blockchains where tokens are treated as simple balances, Cardano’s native assets (secondary tokens) are handled in the same way as ADA (primary token), the network’s native currency, and are tied to specific UTxOs. + +This requires developers to manage multiple inputs and outputs meticulously, which complicates token transactions, especially when interacting with multiple tokens simultaneously. Additionally, the lack of standardized token behavior—since each token can have its own set of rules and characteristics—adds another layer of complexity. Managing token metadata, ensuring compatibility with wallets, and handling the intricacies of multi-asset transactions make working with Cardano tokens a demanding task, requiring a deep understanding of the platform’s architecture. + +Therefore this package was broken into two main factory functions: + +`portfolioTokenManagerMaker`: Manages token information, including caching and synchronization with external APIs, the token manager was design to aggregate information per network. +`portfolioBalanceManagerMaker`: Manages token balances, including primary and secondary tokens, and synchronizes these balances based on wallet information, its primary dependency is the UTxOs, most of the information is derived from it. It also takes that token manager as dependency to identify token info properties. + +## API Reference + +### Portfolio Token Manager Maker + +Description + +The `portfolioTokenManagerMaker` factory function creates a token manager that leverages the Yoroi CDN to get information about the tokens and also provide details about the traits and the discovery process of a token it handles the following: + +- Hydration: Loads cached token information from storage. +- Synchronization: Synchronizes token information with external APIs, handling unknown tokens and invalidated caches. +- Clearing: Clears token information from storage and cache. +- Observation: Notifies observers about changes in the token information. + +Dependencies + +- `api`: An object that provides methods to fetch token information from an external API. +- `storage`: An object that provides methods to store and retrieve token information locally. +- `observer` (optional): An observer manager to handle events related to token information changes. + +Returns + +A frozen object containing methods to `hydrate`, `sync`hronize, `clear`, and `destroy` the token manager. + +### Portfolio Balance Manager Maker + +Description + +The `portfolioBalanceManagerMaker` factory function creates a balance manager to manage token balances and prices it handles the following: + +- Hydration: Loads token balances from storage, including primary and secondary tokens. +- Synchronization: Synchronizes token balances based on UTxOs updates (new transactions). +- Primary Balance Management: Manages the primary token's balance, including breakdown into different parts. +- Observation: Notifies observers about changes in token balances. + +Dependencies + +- `tokenManager`: An instance of `Portfolio.Manager.Token` created by `portfolioTokenManagerMaker`. +- `primaryTokenInfo`: Information about the primary token (e.g., ADA) in the portfolio. +- `storage`: An object that provides methods to store and retrieve balance information locally. +- `sourceId`: A unique identifier for the source of events. +- `observer` (optional): An observer manager to handle events related to balance changes. +- `queue` (optional): A task queue manager to handle asynchronous operations in sequence. + +Returns + +A frozen object containing methods to `hydrate`, `refresh`, `syncBalances`, `synchBalances`, `destroy`, `clear` and many more to manage the balances and prices of the primary token and secondary token. + +## Features + +- Caching: Efficiently cache token information and balances for quick access, it leverages the `cache-control` and `eTag` from the backend to avoid hitting the API constantly. +- Synchronization: Keep token information and balances up-to-date with external sources ([`CIP68`](https://cips.cardano.org/cip/CIP-68), Token Registry the off-chain token record [`CIP26`](https://cips.cardano.org/cip/CIP-26)). +- Event Observation: Allows client to subscribe to handle events related to tokens and balances. (check the `Token.Event` for all options) +- Primary Token Management: Special handling for primary tokens, including detailed breakdowns of balances (rewards, locked deposit - cost to keep UTxOs). +- Customization: Extensible with custom observers and task queues (it manages concurrency automatically, therefore many wallets can synchronize at the same time, it ensures the persisted and cached state are atomic). +- Loose Checking: There are some loose checks to list tokens that were minted with wrong metadata (not following the specs, [`CIP25`](https://cips.cardano.org/cip/CIP-25)). +- DeFi: Support token activity and price history, for now the supported protocols are: + - Cardano + - [MinSwap v1 & v2](https://minswap.org) + - [SundaeSwap (**comming soon**)](https://sundae.fi) + +If you are looking for more information about the APIs, events and types please check [here](https://github.com/Emurgo/yoroi/tree/develop/packages/types/src/portfolio) + +## Contributing + +Contributions are welcome! Please feel free to submit a pull request or open an issue to discuss any changes or improvements. diff --git a/packages/portfolio/package.json b/packages/portfolio/package.json index bbc737ae6b..35e34582e1 100644 --- a/packages/portfolio/package.json +++ b/packages/portfolio/package.json @@ -1,6 +1,6 @@ { "name": "@yoroi/portfolio", - "version": "1.0.1", + "version": "1.0.2", "description": "The Portfolio package of Yoroi SDK", "keywords": [ "yoroi", @@ -145,7 +145,7 @@ "@types/jest": "^29.5.12", "@types/react": "^18.2.55", "@types/react-test-renderer": "^18.0.7", - "@yoroi/types": "1.5.6", + "@yoroi/types": "^1.5.7", "bignumber.js": "^9.0.1", "commitlint": "^17.0.2", "del-cli": "^5.0.0", @@ -170,8 +170,8 @@ }, "peerDependencies": { "@react-native-async-storage/async-storage": "^1.19.3", - "@yoroi/api": "1.5.1", - "@yoroi/common": "1.5.3", + "@yoroi/api": "1.5.2", + "@yoroi/common": "1.5.4", "bignumber.js": "^9.0.1", "immer": "^10.0.3", "react": ">= 16.8.0 <= 19.0.0", diff --git a/packages/resolver/package.json b/packages/resolver/package.json index addc2f32bf..01ccc97864 100644 --- a/packages/resolver/package.json +++ b/packages/resolver/package.json @@ -1,6 +1,6 @@ { "name": "@yoroi/resolver", - "version": "2.0.5", + "version": "2.0.6", "description": "Yoroi domain resolver", "keywords": [ "yoroi", @@ -137,11 +137,6 @@ "/jest.setup.js" ] }, - "dependencies": { - "@yoroi/api": "1.5.1", - "@yoroi/common": "1.5.3", - "@yoroi/types": "1.5.6" - }, "devDependencies": { "@commitlint/config-conventional": "^17.0.2", "@react-native-async-storage/async-storage": "^1.19.3", @@ -153,6 +148,7 @@ "@types/jest": "^29.5.12", "@types/react": "^18.2.55", "@types/react-test-renderer": "^18.0.7", + "@yoroi/types": "^1.5.7", "axios": "^1.5.0", "commitlint": "^17.0.2", "del-cli": "^5.0.0", @@ -176,6 +172,8 @@ }, "peerDependencies": { "@react-native-async-storage/async-storage": ">= 1.19.3 <= 1.20.0", + "@yoroi/api": "^1.5.2", + "@yoroi/common": "^1.5.4", "axios": "^1.5.0", "react": ">= 16.8.0 <= 19.0.0", "react-query": "^3.39.3", diff --git a/packages/setup-wallet/package.json b/packages/setup-wallet/package.json index 382ab3f97f..4ea2348960 100644 --- a/packages/setup-wallet/package.json +++ b/packages/setup-wallet/package.json @@ -1,6 +1,6 @@ { "name": "@yoroi/setup-wallet", - "version": "1.0.0", + "version": "1.0.1", "description": "The Wallet Setup package of Yoroi SDK", "keywords": [ "yoroi", @@ -129,8 +129,7 @@ ] }, "dependencies": { - "@yoroi/resolver": "2.0.5", - "@yoroi/types": "1.5.6" + "@yoroi/resolver": "^2.0.6" }, "devDependencies": { "@commitlint/config-conventional": "^17.0.2", @@ -141,6 +140,7 @@ "@types/jest": "^29.5.12", "@types/react": "^18.2.55", "@types/react-test-renderer": "^18.0.7", + "@yoroi/types": "^1.5.7", "commitlint": "^17.0.2", "del-cli": "^5.0.0", "dependency-cruiser": "^13.1.1", @@ -162,6 +162,7 @@ "typescript": "^5.3.3" }, "peerDependencies": { + "@yoroi/types": "^1.5.7", "immer": "^10.0.2", "react": ">= 16.8.0 <= 19.0.0", "react-query": "^3.39.3" diff --git a/packages/staking/package.json b/packages/staking/package.json index 8ba5fa9d02..38c1dd3281 100644 --- a/packages/staking/package.json +++ b/packages/staking/package.json @@ -1,6 +1,6 @@ { "name": "@yoroi/staking", - "version": "1.5.1", + "version": "1.5.2", "description": "The Staking package of Yoroi SDK", "keywords": [ "yoroi", @@ -148,7 +148,8 @@ "@types/jest": "^29.5.12", "@types/react": "^18.2.55", "@types/react-test-renderer": "^18.0.7", - "@yoroi/types": "1.5.6", + "@yoroi/common": "1.5.4", + "@yoroi/types": "^1.5.7", "axios": "^1.5.0", "axios-mock-adapter": "^1.21.5", "commitlint": "^17.0.2", @@ -173,7 +174,7 @@ }, "peerDependencies": { "@react-native-async-storage/async-storage": ">= 1.19.3 <= 1.20.0", - "@yoroi/common": "1.5.3", + "@yoroi/common": "1.5.4", "immer": "^10.0.2", "react": ">= 16.8.0 <= 19.0.0", "react-query": "^3.39.3", diff --git a/packages/swap/package.json b/packages/swap/package.json index 4335d6f216..c284286aa1 100644 --- a/packages/swap/package.json +++ b/packages/swap/package.json @@ -1,6 +1,6 @@ { "name": "@yoroi/swap", - "version": "2.0.0", + "version": "2.0.1", "description": "The Swap package of Yoroi SDK", "keywords": [ "yoroi", @@ -149,10 +149,10 @@ "@types/jest": "^29.5.12", "@types/react": "^18.2.55", "@types/react-test-renderer": "^18.0.7", - "@yoroi/api": "1.5.1", - "@yoroi/common": "1.5.3", - "@yoroi/portfolio": "1.0.1", - "@yoroi/types": "1.5.6", + "@yoroi/api": "^1.5.2", + "@yoroi/common": "^1.5.4", + "@yoroi/portfolio": "^1.0.2", + "@yoroi/types": "^1.5.7", "bignumber.js": "^9.0.1", "commitlint": "^17.0.2", "del-cli": "^5.0.0", @@ -177,9 +177,9 @@ "peerDependencies": { "@emurgo/yoroi-lib": "^1.0.1", "@react-native-async-storage/async-storage": ">= 1.19.3 <= 1.20.0", - "@yoroi/api": "1.5.1", - "@yoroi/common": "1.5.3", - "@yoroi/portfolio": "1.0.1", + "@yoroi/api": "1.5.2", + "@yoroi/common": "1.5.4", + "@yoroi/portfolio": "1.0.2", "bignumber.js": "^9.0.1", "immer": "^10.0.2", "react": ">= 16.8.0 <= 19.0.0", diff --git a/packages/theme/package.json b/packages/theme/package.json index 59b1adf8df..a57f31b9ad 100644 --- a/packages/theme/package.json +++ b/packages/theme/package.json @@ -140,8 +140,8 @@ "@types/jest": "^29.5.12", "@types/react": "^18.2.55", "@types/react-test-renderer": "^18.0.7", - "@yoroi/common": "^1.5.2", - "@yoroi/types": "^1.5.3", + "@yoroi/common": "^1.5.4", + "@yoroi/types": "^1.5.7", "axios-mock-adapter": "^1.21.5", "commitlint": "^17.0.2", "del-cli": "^5.0.0", @@ -163,7 +163,7 @@ "typescript": "^5.3.3" }, "peerDependencies": { - "@yoroi/common": "^1.5.2", + "@yoroi/common": "^1.5.4", "react": ">= 16.8.0 <= 19.0.0" }, "packageManager": "yarn@1.22.21", diff --git a/packages/transfer/package.json b/packages/transfer/package.json index 89fda15808..4179456abf 100644 --- a/packages/transfer/package.json +++ b/packages/transfer/package.json @@ -1,6 +1,6 @@ { "name": "@yoroi/transfer", - "version": "1.0.0", + "version": "1.0.1", "description": "The Transfer package of Yoroi SDK", "keywords": [ "yoroi", @@ -138,7 +138,7 @@ "@types/jest": "^29.5.12", "@types/react": "^18.2.55", "@types/react-test-renderer": "^18.0.7", - "@yoroi/types": "1.5.6", + "@yoroi/types": "^1.5.7", "commitlint": "^17.0.2", "del-cli": "^5.0.0", "dependency-cruiser": "^13.1.1", @@ -161,8 +161,8 @@ }, "peerDependencies": { "@tanstack/react-query": "4.36.1", - "@yoroi/portfolio": "1.0.1", - "@yoroi/resolver": "2.0.5", + "@yoroi/portfolio": "1.0.2", + "@yoroi/resolver": "2.0.6", "immer": "^10.0.2", "react": ">= 16.8.0 <= 19.0.0", "react-query": "^3.39.3" diff --git a/packages/types/package.json b/packages/types/package.json index 02c1671d27..87dd0fb26b 100644 --- a/packages/types/package.json +++ b/packages/types/package.json @@ -1,6 +1,6 @@ { "name": "@yoroi/types", - "version": "1.5.6", + "version": "1.5.7", "description": "The Yoroi Types package of Yoroi SDK", "keywords": [ "yoroi",