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

feat: Sync 20240612 #26

Closed
wants to merge 72 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
72 commits
Select commit Hold shift + click to select a range
3361e8f
feat: implement ADR-036
HoangVD2 Apr 23, 2024
42bf0b1
base: update x add unit test
HoangVD2 Apr 23, 2024
4ba8e1c
chore: update
HoangVD2 Apr 23, 2024
7b603a5
chore
HoangVD2 Apr 23, 2024
6d5cd60
chore: add changeset
HoangVD2 Apr 24, 2024
b8f7891
base: add verifyMessage for ledger
HoangVD2 May 2, 2024
06d45f9
feat: prepare setup for reproduce solana metaplex issue on mobile device
danilxdefi Apr 23, 2024
3afb259
fix: solana lib mobile errors
Apr 25, 2024
13dfd97
fix: solana lib mobile errors
Apr 26, 2024
9409231
fix: clean code
May 2, 2024
c12b8f0
fix: clean code
May 2, 2024
e1e9fb0
fix: update test env node version
danilxdefi May 2, 2024
acb0c9a
fix: clean code, lint
danilxdefi May 2, 2024
64c560a
bump: version
danilxdefi May 2, 2024
ab76f06
Version packages
xdefi-bot May 2, 2024
8b0b227
base: implement getBalances for for maya
HoangVD2 Apr 17, 2024
968d881
base: remove @xchain packages
HoangVD2 Apr 17, 2024
e2457af
chore: fix for mayachain
HoangVD2 Apr 19, 2024
7025114
chore: update LedgerSigner for Thor/Maya chain
HoangVD2 Apr 19, 2024
451eeea
chore: update
HoangVD2 Apr 19, 2024
9d92f5b
chore: update addressRegex
HoangVD2 Apr 19, 2024
3c0d445
fix: verifyAddress with bech32
HoangVD2 Apr 19, 2024
8d60eea
chore: add new case
HoangVD2 Apr 22, 2024
05e1cc2
chore: update
HoangVD2 Apr 22, 2024
4f24f10
chore: chore: pin deps bech32
HoangVD2 Apr 22, 2024
5cc1e68
chore: update
HoangVD2 Apr 24, 2024
423aa00
chore: update testcase
HoangVD2 Apr 24, 2024
8bc4494
chore: update testcase
HoangVD2 Apr 24, 2024
47837f6
chore: add changeset
HoangVD2 Apr 24, 2024
60a20a2
chore: fix comment
HoangVD2 May 2, 2024
2588d5e
Version packages
xdefi-bot May 3, 2024
833063d
Version packages
xdefi-bot May 7, 2024
f4c8912
fix(XDEFI-7720): axelar bech32 fix (#207)
davidp94 May 7, 2024
1c85483
Version packages
xdefi-bot May 7, 2024
ffff6b4
chore: update default rpc optimism url (#208)
davidp94 May 7, 2024
ea421fc
Version packages
xdefi-bot May 7, 2024
652c097
feat: Expose provider so that Extension can calls `send()` for RPC da…
sotatek-tyler-nguyen4 May 8, 2024
c311d9a
feat: Ordinals (BTC) Integration (#191)
sotatek-tyler-nguyen4 May 8, 2024
f7a4443
Version packages
xdefi-bot May 8, 2024
5281b8c
feat: add osmojs lib to cosmos chain (#206)
JamesNguyen5 May 8, 2024
3f75704
Version packages
xdefi-bot May 8, 2024
4b717c2
feat: update legacyNFTs query (#209)
danilxdefi May 9, 2024
08d1711
Version packages
xdefi-bot May 9, 2024
5aac54d
feat: add missing methods EVM signers (XDEFI-7373) (#177)
HoangVD2 May 13, 2024
ee4cadf
Version packages
xdefi-bot May 13, 2024
765899b
feat: add price.dayPriceChange field for get balances (#216)
danilxdefi May 14, 2024
3497f6d
Version packages
xdefi-bot May 14, 2024
1e3d64f
feat: update legacyNFT fragment for core lib (#217)
danilxdefi May 15, 2024
ccf740c
Version packages
xdefi-bot May 15, 2024
0e081b7
fix: getBalance calculating amount for solana and evm chains (#218)
danilxdefi May 16, 2024
d7f8b07
Version packages
xdefi-bot May 16, 2024
11fea14
feat: add chains-lib Contributing Guide (XDEFI-7567) (#205)
HoangVD2 May 17, 2024
f0a7bd0
feat: add private key and seed phrase test cases (#221)
danilxdefi May 22, 2024
b5f6fed
Version packages
xdefi-bot May 22, 2024
110ee6c
feat: add getMaxAmountToSend method (XDEFI-6902) (#200)
HoangVD2 May 23, 2024
977e117
Version packages
xdefi-bot May 23, 2024
334c512
feat: add test coverage to chain controller utility package (#215)
danilxdefi May 23, 2024
53b9c7a
Version packages
xdefi-bot May 23, 2024
6ad4517
chore: add trivy secret scanning (#151)
abhishekgotoadmin May 23, 2024
cb909b9
fix: update endpoint for estimateFee on Thorchain (XDEFI-7997) (#222)
HoangVD2 May 23, 2024
f0c18ef
updated EVM fee type to include baseFee & small calculation update (#…
liammcaweeney May 23, 2024
01d307b
feat: add baseFeePerGas, fix updateEVMFee branch (#225)
danilxdefi May 23, 2024
031af17
fix: add private key signer to export from thor chain (#226)
danilxdefi May 24, 2024
020cf3b
feat: update signers for swap transactions on solana, update test cas…
danilxdefi May 27, 2024
1cb3f83
feat: implement signTypedData method (v4) on EVM (#228)
HoangVD2 May 31, 2024
3f0681a
feat: Add IBC transfer transactions (#213)
sotatek-tyler-nguyen4 May 31, 2024
47d985b
base: add missing jest test (#235)
HoangVD2 Jun 7, 2024
53d4b53
feat: xdefi-7902 evm cache (#233)
danilxdefi Jun 7, 2024
d059e2f
fix: changeset file (#240)
danilxdefi Jun 11, 2024
20a15ba
Version packages
xdefi-bot Jun 11, 2024
57f625d
chore: remove @swc/core library (#239)
sotatek-tyler-nguyen4 Jun 11, 2024
c874d48
Version packages
Jun 11, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions .github/workflows/secret_scan.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: SecretScan
on:
push:
branches:
- develop
pull_request:
jobs:
build:
name: Build
runs-on: ubuntu-20.04
steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Run Trivy vulnerability scanner in repo mode
uses: aquasecurity/trivy-action@master
with:
scan-type: 'fs'
ignore-unfixed: true
format: 'table'
output: 'trivy-results.sarif'
severity: 'CRITICAL'

- name: scan
env:
GITHUB_TOKEN: ${{ secrets.GIT_TOKEN }}
run: |
sudo apt-get install wget apt-transport-https gnupg lsb-release
wget -qO - https://aquasecurity.github.io/trivy-repo/deb/public.key | sudo apt-key add -
echo deb https://aquasecurity.github.io/trivy-repo/deb $(lsb_release -sc) main | sudo tee -a /etc/apt/sources.list.d/trivy.list
sudo apt-get update
sudo apt-get install trivy -y
trivy fs .

34 changes: 34 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: Test Package

on: pull_request

jobs:
build-and-test:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
with:
token: ${{ secrets.GIT_TOKEN }}

- name: Enable node
uses: actions/setup-node@v3
with:
node-version: 20

- name: Install dependencies
run: yarn

- name: Setup Python for Deps
run: sudo apt-get update && sudo apt-get install python3-dev -y

- name: Build
run: yarn build --concurrency 2

- name: Run tests
run: yarn test --concurrency 2
- name: Upload coverage reports to Codecov
uses: codecov/[email protected]
env:
token: ${{ secrets.CODECOV_TOKEN }}
slug: XDeFi-tech/chains
215 changes: 215 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,215 @@
# chains-lib Contributing Guide

## Introduction

This document is a set of guidelines for contributing to this project. These are guidelines, not rules. This guide is meant to make it easy for you to get involved.

First off, thank you for considering contributing to this project. It's people like you that make this documentation better for everyone.

Following these guidelines helps to communicate that you respect the time of the developers managing and developing this open-source project. In return, they should reciprocate that respect in addressing your issue, assessing changes, and helping you finalize your pull requests.

chains-lib is a community-driven project, and we welcome contributions from the community. Whether you're fixing a typo, adding a new feature, or changing the documentation, we'd love to have your contributions.

Please, don't use the issue tracker for personal support requests. Instead, use the [XDEFI Discord](https://discord.gg/xdefi) for support.

## Project structure

The project is divided into the following directories:

```
📦 chains-lib
├─ .changeset
│  └─ ...
├─ .github
│  └─ workflows
│     ├─ tests.yml
│     └─ release.yml
├─ .husky
│  └─ ...
├─ packages
│  ├─ core
│  │  ├─ src
│  │  │  ├─ index.ts
│  │  │  ├─ core
│  │  │  │  └─ ...
│  │  │  └─ common
│  │  │     └─ ...
│  │  └─ ...
│  ├─ binance
│  │  ├─ src
│  │  │  ├─ datasource
│  │  │  │  ├─ index.ts
│  │  │  │  └─ indexer
│  │  │  │     ├─ queries
│  │  │  │     │  ├─ index.ts
│  │  │  │     │  └─ ....query.ts
│  │  │  │     ├─ indexer.data-source.ts
│  │  │  │     └─ operations.graphql
│  │  │  ├─ signers
│  │  │  │  ├─ ledger.signer.ts
│  │  │  │  ├─ ledger.signer.spec.ts
│  │  │  │  ├─ private-key.signer.ts
│  │  │  │  ├─ private-key.signer.spec.ts
│  │  │  │  ├─ seed-phrase.signer.ts
│  │  │  │  ├─ seed-phrase.signer.spec.ts
│  │  │  │  ├─ trezor.signer.ts
│  │  │  │  ├─ trezor.signer.spec.ts
│  │  │  │  ├─ react-native.ts
│  │  │  │  └─ web.ts
│  │  │  ├─ chain.provider.ts
│  │  │  ├─ index.ts
│  │  │  ├─ manifests.ts
│  │  │  └─ msg.ts
│  │  └─ ...
│  ├─ bitcoin
│  │  └─ ...
│  ├─ bitcoincash
│  │  └─ ...
│  ├─ cosmos
│  │  └─ ...
│  ├─ dogecoin
│  │  └─ ...
│  ├─ evm
│  │  └─ ...
│  ├─ litecoin
│  │  └─ ...
│  ├─ solana
│  │  └─ ...
│  ├─ thor
│  │  └─ ...
│  ├─ tron
│  │  └─ ...
│  ├─ utxo
│  │  └─ ...
│  └─ ...
├─ templates
│  └─ ...
├─ examples
│  └─ ...
├─ utility-packages
│  └─ ...
├─ .gitignore
├─ .prettierrc
├─ coverage.js
├─ turbo.json
├─ yarn.lock
├─ package.jon
├─ CONTRIBUTING.md
└─ README.md
```

The project is a monorepo that contains multiple packages and we mainly work on the `packages` directory. Each package is a separate module that can be used independently. The `core` package is the main package that contains the core logic of the library. The `utxo` package contains the UTXO chain-specific logic and only supports UTXO-based chains. The `binance`, `bitcoin`, `bitcoincash`, `cosmos`, `dogecoin`, `evm`, `litecoin`, `solana`, `thor` and `tron` packages are chain-specific packages that contain chain-specific logic. The `utility-packages` directory contains utility packages that are used across multiple packages. With each package, we have a `src` directory that contains the source code of the package. The `index.ts` file is the entry point of the package. The `core` package contains the core logic of the library. The `common` directory contains common types and interfaces that are used across multiple packages.

## How to contribute?

Below are some frequently asked questions about concepts in the project and how to contribute to the project:

### How to integrate a new blockchain provider?

To integrate a new blockchain provider, you need to create a new package in the `packages` directory. The package should contain a `src` directory that contains the source code of the package. The `index.ts` file should be the entry point of the package. The package should contain chain-specific logic, such as chain-specific types, interfaces, and functions. `datasources`, `signers`, and `chain.providers` should be implemented in the package. The package should also contain chain-specific `manifests` and `messages`.

### What is a signer?

A signer is a class that is used to sign transactions. A signer should implement the `Signer` interface. The `Signer` interface has a `sign` method that takes a `SignMessage` object as an argument and returns a `Signature` object. The `SignMessage` object contains the message to sign, and the `Signature` object contains the signature of the message.

In addition to signing transactions, each signer should also implement methods such as `verifyAddress`, `getAddress`, and `getPublicKey`. The `verifyAddress` method takes an address as an argument and returns a boolean value indicating whether the address is valid. The `getPublicKey` method is used to get the public key of the signer, and the `getAddress` method is used to get the address of the signer. Some methods may not be implemented/supported by all signers as well as some signers may have additional methods.

Currently, the library supports the following signers:

- `LedgerSigner`: Ledger hardware wallet signer.
- `PrivateKeySigner`: Private key signer.
- `SeedPhraseSigner`: Seed phrase signer.
- `TrezorSigner`: Trezor hardware wallet signer.

### How to implement a new signer?

To implement a new signer, you need to create a new file in the `signers` directory of the chain-specific package. The file should contain a class that implements the `Signer` interface. The class should implement the `sign` method, which takes a `SignMessage` object as an argument and returns a `Signature` object. The `SignMessage` object contains the message to sign, and the `Signature` object contains the signature of the message.

### What is a datasource?

A datasource is a class that is used to interact with the blockchain. A datasource should implement the `DataSource` interface. The `DataSource` interface has a `query` method that takes a `Query` object as an argument and returns a `QueryResult` object. The `Query` object contains the query to execute, and the `QueryResult` object contains the result of the query.

Basically only indexer datasource has `query`, chain datasource get's information directly from blockchain and have no GQL queries (except additional metadata via `cryptoAsset` query)

### How to implement a new datasource?

To implement a new datasource, the only requirement is create "proxy" to interact with the blockchain and implement DataSource class from core library, you need to create a new file in the `datasources` directory of the chain-specific package. The file should contain a class that implements the `DataSource` interface. The class should implement the `query` method, which takes a `Query` object as an argument and returns a `QueryResult` object. The `Query` object contains the query to execute, and the `QueryResult` object contains the result of the query.

## Development setup

You will need to have [Node.js](https://nodejs.org/) vesion 18 or higher. We recommend using Yarn as the package manager.

After cloning the repository, run the following commands:

```bash
yarn # install dependencies of the project
```

To build the project, run:

```bash
yarn build
```

## Pull Requests guidelines

- chains-lib core has 2 main branches: `main` and `develop`. All development should be done in the `develop` branch. The `main` branch is only updated when a new release is made, the `develop` branch is merged into the `main` branch when a new release is made, and the `main` branch is tagged with the release version.
- Pull requests should be made to the `develop` branch.
- If adding a new feature or fixing a bug:
- Add accurate tests and ensure they pass.
- Run `npx changeset` to reflect and generate a [changeset](https://github.com/changesets/changesets) for the PR.
- Provide a detailed description of the bug in the PR.
- It's OK to have multiple small commits as you work on the PR - we will squash them before merging.
- Make sure your code lints. Run `yarn lint` to check your code. You can also run `yarn lint:fix` to automatically fix some issues.
- Make sure your code is well-tested. Run `yarn test` to run the test suite. Better to use `yarn test --concurrency=2`, otherwise your system can be crashed.
- Commit messages must follow the conventional commit format: `type(scope): message`. Types include `feat`, `fix`, `docs`, `style`, `refactor`, `perf`, `test`, `chore`, and `revert`. For example, `feat: add new feature` or `fix: correct typo`.

## Contribution workflow

1. Search for an existing issue or create a new one to start a discussion around your idea or bug. Make sure no one else is already working on it, and assign yourself to the issue if you plan to work on it. If you don't have permissions to assign yourself, leave a comment asking for it.
2. Clone the repository to your local machine.
3. Create and checkout a new branch for your work, naming it relevantly. We recommend naming your branch with the issue number and a short description of the issue (e.g., `fix:issue-123-fix-typo`), which is a reminder to fix only one issue in a PR.
4. Open the project in your favorite editor and start making your changes.
5. Commit your changes, briefly describing what you did in the commit message. Push your changes to your branch.
6. On this repository, navigate to the "Pull Requests" tab and click on "New Pull Request". Describe your changes in detail, including the issue number you're addressing. If you're not ready for a review yet, you can open a draft pull request.
7. Specific reviewers will be assigned to your pull request. If you don't get a response within a week, feel free to ask for a review in the Discord channel.
8. Make changes to your pull request if the reviewer asks for them. Once the reviewer approves your changes, the pull request will be merged.

## Code review process

The core team looks at Pull Requests on a regular basis in a weekly triage meeting that we hold in Discord. The meeting is used to discuss Pull Requests and Issues. The meeting is open to the public, and you are welcome to join.

After feedback has been given, the Pull Request author should respond within a week. After a week with no response, the Pull Request may be closed.

## How to report a bug

If you find a security vulnerability, do NOT open an issue. Email [[email protected]](mailto:[email protected]) instead.

When filling an issue, make sure to answer these five questions:

1. What release version are you using?
2. What is issue you faced, steps to reproduce it?
3. What did you do?
4. What did you expect to see?
5. What did you see instead?
6. What operating system are you using?

## How to suggest a feature or enhancement

If you find yourself wishing for a feature that doesn't exist in the documentation, you are probably not alone. There are bound to be others out there with similar needs. Many of the features that exist in the documentation started as a pull request from a single contributor.

When suggesting a feature, please provide as much detail as possible. Explain what the feature would do and how it would be useful to other users.

## Community

Discussions about the documentation take place on the [XDEFI Discord](https://discord.gg/xdefi).

We also available on [X](https://twitter.com/xdefi_wallet) and [Telegram](https://t.me/xdefi_announcements).

## Code of Conduct

Please note that this project is released with a Contributor Code of Conduct. By participating in this project, you agree to abide by its terms.

## Credits

Thank you to all the people who have already contributed to the project!
Loading
Loading