FT4 Library: Asset and Account Management for Chromia's Rell and TypeScript Environments
Introduction
The FT4 Library functions as a comprehensive toolkit engineered for both Rell and TypeScript modules in the Chromia blockchain ecosystem. Specialising in asset and account management, the library provides a suite of operations including asset issuance, allocation, and transfers, extending even to cross-chain capabilities. Furthermore, it establishes foundational data structures for account management, designed to operate independently of asset-related activities.
Features
- Asset Management: Facilitate the creation, allocation, and management of assets. Asset Allocation and Transfers: Perform secure and efficient asset transfers.
- Cross-Chain Transfers: Enable the movement of assets between distinct blockchains.
- Account Management: Oversee user accounts independently of asset activities.
Repository Overview
This repository contains the FT4 library and a comprehensive suite of tests written in Node.js and Jest. The current testing setup serves as a temporary measure, as a Rell-based testing suite is in development.
Getting Started
Prerequisites
- Node.js
- Docker
- [Optional] PostgreSQL for database sessions
Installation
Clone the repository and install the dependencies:
git clone git@bitbucket.org:chromawallet/ft3-lib.git
cd ft3-lib
npm install
Build
Build TypeScript library into dist/
:
npm run build
How to Run Tests
Comprehensive Test Suite
Run the complete set of Rell and TypeScript tests:
npm run test
Run only Rell or TypeScript tests:
npm run test:rell
npm run test:js
Running Specific Rell Tests
To execute particular tests in Rell, use the --tests
or -t
option:
npm run test:rell -- --tests=test1,test2
npm run test:rell -- -t=test1,test2
Running Specific Jest Tests
Execute specific Jest tests by string matching:
npm run test:js 'string matching test(s)'
Examples:
npm run test:js 'user'
npm run test:js 'rate|sso'
Running End-to-End Tests with Cypress
Interactive Mode
Run e2e tests interactively:
npm run test:e2e
Headless Mode
Run e2e tests in headless mode:
npm run test:e2e:headless
How to Run the Blockchain
For running different blockchain configurations, you can use the following npm commands:
- Test Environment:
npm run postchain:test
- Demo Environment:
npm run postchain:demo
To stop these environments:
- Test:
npm run stop-postchain:jest
- Demo:
npm run stop-postchain:demo
Changelog
Update changelog in doc/release-notes/
, then run ./compile-changelog.sh
script to assemble
changelog.md
and rell-changelog.md
. Do not update changelog.md
or rell-changelog.md
directly.
License
This project is licensed under the Apache License, Version 2.0. For more details, see the LICENSE file in the repository or visit Apache License, Version 2.0.
[0.4.0] - 2024-02-15
Changed 🪙
authenticator.getKeyHandlerForOperation
will not return auth descriptors whose rules don't allow them to be used.AuthDataService.getAllowedAuthDescriptors
now accepts Buffer | string
instead of Buffer
only- Auth descriptor queries updated to include
account_id
in response. - Limit how many auth descriptors can be added to an account. Default value is 10 and maximum is 200.
Added ✅
-
AuthDescriptorValidator
with hasExpired
and isActive
methods to check whether the auth descriptor is expired or active. An inactive auth descriptor is one that will be valid in the future, an expired one was valid in the past.
-
createAuthDescriptorValidator(authDataService, useCache)
to use the above mentioned validator. If it uses cache, it will cache op_count
of each auth descriptor and block_height
as soon as it needs to query them.
-
Do not allow TransactionBuilder.build() or TransactionBuilder.buildUnsigned() if there are OnAnchoredHandlers
-
Default value for paginated queries has been changed from the previous 100, to instead use the value configured as default in the dApp on rell side
-
Upgrade postchain-client to 1.9.0
-
Added support for rules or TTL in login manager.
-
account registration with following strategies
Bugfixes 🐛
- Orchestrator and transaction builder waits until transaction is anchored in SAC before moving to next step
Breaking 💔
-
Removed pagination from auth descriptor queries
-
Change assetData
to asset
in TransferHistoryEntry
.
-
Update addAuthDescriptor
signature
Old:
addAuthDescriptor(authDescriptor: AnyAuthDescriptorRegistration, newSigner: SignatureProvider | KeyPair)
New:
addAuthDescriptor(authDescriptor: AnyAuthDescriptorRegistration, keyStore: FtKeyStore)
- Update LoginKeyStore interface
Old:
interface LoginKeyStore {
clear(accountId: Buffer);
getKeyPair(accountId: Buffer): Promise<KeyPair | null>;
createKeyPair(accountId: Buffer): Promise<KeyPair>;
}
New:
interface LoginKeyStore {
clear(accountId: Buffer): Promise<void>;
getKeyStore(accountId: Buffer): Promise<FtKeyStore | null>;
generateKey(accountId: Buffer): Promise<FtKeyStore>;
}