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

Add DASH support #25

Draft
wants to merge 14 commits into
base: main
Choose a base branch
from
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ This library currently supports the following blockchain networks:
| Chain | Provider | Datasources | Signers | Custom chain |
| --------------- | ------------------------------------------------------------------------------- | -------------- | -------------------------------------- | ------------ |
| Bitcoin | [Bitcoin](https://github.com/XDeFi-tech/chains/pkgs/npm/chains-bitcoin) | Indexer, Chain | SeedPhrase, PrivateKey, Ledger, Trezor | No |
| Dash | [Dash](https://github.com/XDeFi-tech/chains/pkgs/npm/chains-dash) | Chain | SeedPhrase, PrivateKey, Trezor | No |
| Ethereum | [EVM](https://github.com/XDeFi-tech/chains/pkgs/npm/chains-evm) | Indexer, Chain | SeedPhrase, PrivateKey, Ledger, Trezor | Yes |
| BNB Smart Chain | [EVM](https://github.com/XDeFi-tech/chains/pkgs/npm/chains-evm) | Indexer, Chain | SeedPhrase, PrivateKey, Ledger, Trezor | Yes |
| Polygon | [EVM](https://github.com/XDeFi-tech/chains/pkgs/npm/chains-evm) | Indexer, Chain | SeedPhrase, PrivateKey, Ledger, Trezor | Yes |
Expand Down
9 changes: 9 additions & 0 deletions examples/react/context/chains.context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { BINANCE_MANIFEST, BinanceProvider } from '@xdefi-tech/chains-binance';
import { SOLANA_MANIFEST, SolanaProvider } from '@xdefi-tech/chains-solana';
import { THORCHAIN_MANIFESTS, ThorProvider } from '@xdefi-tech/chains-thor';
import { BITCOIN_MANIFEST, BitcoinProvider } from '@xdefi-tech/chains-bitcoin';
import { DASH_MANIFEST, DashProvider } from '@xdefi-tech/chains-dash';
import {
LITECOIN_MANIFEST,
LitecoinProvider,
Expand Down Expand Up @@ -219,6 +220,14 @@ export const initDefaultProviders = () => {
}
)
);
ChainsContextDefaultValue.addProvider(
new DashProvider(
new DashProvider.dataSourceList.ChainDataSource(DASH_MANIFEST),
{
providerId: 'dash',
}
)
);
ChainsContextDefaultValue.addProvider(
new LitecoinProvider(
new LitecoinProvider.dataSourceList.IndexerDataSource(LITECOIN_MANIFEST),
Expand Down
1 change: 1 addition & 0 deletions examples/react/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
"@mui/material": "5.11.12",
"@xdefi-tech/chains-binance": "*",
"@xdefi-tech/chains-bitcoin": "*",
"@xdefi-tech/chains-dash": "*",
"@xdefi-tech/chains-bitcoincash": "*",
"@xdefi-tech/chains-dogecoin": "*",
"@xdefi-tech/chains-litecoin": "*",
Expand Down
1 change: 0 additions & 1 deletion packages/bitcoin/src/signers/private-key.signer.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/*eslint import/namespace: [2, { allowComputed: true }]*/
import { Signer, SignerDecorator } from '@xdefi-tech/chains-core';
import { secp256k1 } from '@noble/curves/secp256k1';
import * as btc from '@scure/btc-signer';
Expand Down
3 changes: 3 additions & 0 deletions packages/dash/.eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.eslintrc.js
webpack*
jest-setup-file.ts
13 changes: 13 additions & 0 deletions packages/dash/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
module.exports = {
root: true,
extends: ['custom'],
settings: {
'import/resolver': {
typescript: {},
},
},
parserOptions: {
project: './tsconfig.json',
tsconfigRootDir: __dirname,
},
};
7 changes: 7 additions & 0 deletions packages/dash/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# @xdefi-tech/chains-dash

## 1.0.0

### Major Changes

- f7d5fa77: Add Dash chain initial commit
29 changes: 29 additions & 0 deletions packages/dash/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
## Manifest

```typescript
const dashManifest = {
name: 'Dash',
description: '',
rpcURL: 'https://explorer.dash.org/insight-api',
chainSymbol: 'DASH',
blockExplorerURL: 'https://blockchair.com/dash',
chainId: 'dash',
chain: 'dash',
decimals: 8,
feeGasStep: {
high: 1,
medium: 1,
low: 1,
},
};
```

- `name`: The name of the blockchain network, in this case, Dash. Uses only for display name to user
- `description`: A brief description or additional information about the blockchain network.
- `rpcURL`: The URL of the RPC (Remote Procedure Call) endpoint used to interact with the Dash blockchain network.
- `chainSymbol`: The symbol or ticker representing the Dash blockchain network, which is "DASH".
- `blockExplorerURL`: The URL of the block explorer for the Dash blockchain network. Block explorers allow users to view details about blocks, transactions, addresses, and other blockchain-related data.
- `chainId`: The unique identifier for the Dash blockchain network, often referred to as the chain ID. In this example, it is "dash".
- `chain`: The name of the blockchain network. If you are using IndexerDataSource, it must be obtained from the [registry](https://github.com/XDeFi-tech/xdefi-registry/blob/main/chains.json).
- `decimals`: The number of decimal places used for representing token amounts on the Dash blockchain. In this case, it is set to 8.
- `feeGasStep`: An object specifying the gas steps for different fee levels (high, medium, and low) used for transactions on the Dash blockchain network. In this example, all fee levels are set to 1.
3 changes: 3 additions & 0 deletions packages/dash/jest-setup-file.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import 'reflect-metadata';
import { TextEncoder, TextDecoder } from 'util';
Object.assign(global, { TextDecoder, TextEncoder });
89 changes: 89 additions & 0 deletions packages/dash/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
{
"name": "@xdefi-tech/chains-dash",
"version": "1.0.0",
"main": "dist/index.js",
"types": "dist/index.d.ts",
"repository": "https://github.com/XDeFi-tech/chains/",
"license": "MIT",
"files": [
"dist",
"CHANGELOG.md",
"README.md"
],
"devDependencies": {
"jest": "27.5.1",
"jest-environment-jsdom": "27.5.1",
"jest-watch-typeahead": "1.0.0",
"ts-jest": "27.1.4",
"tsup": "6.6.3",
"typescript": "4.8.3"
},
"dependencies": {
"@trezor/connect-web": "9.1.4",
"@xdefi-tech/chains-core": "*",
"@xdefi-tech/chains-graphql": "*",
"@xdefi-tech/chains-utxo": "*",
"axios": "1.3.4",
"bignumber.js": "^9.1.2",
"bip32": "2.0.4",
"bip39": "3.1.0",
"coinselect": "3.1.13",
"dashcore-lib": "^8.2.3",
"eslint-config-custom": "*",
"reflect-metadata": "0.1.13",
"rimraf": "4.4.0",
"rxjs": "7.8.0",
"ts-node": "10.7.0"
},
"scripts": {
"build": "tsup --minify --clean",
"publish:packages": "npm publish --tag $GITHUB_REF",
"watch": "tsup --watch",
"coverage": "jest --coverageReporters='json-summary' --coverage",
"test": "jest",
"test:watch": "jest --watch",
"lint": "eslint .",
"lint:fix": "eslint . --fix",
"clean": "rimraf dist .turbo node_modules"
},
"type": "commonjs",
"tsup": {
"entry": [
"src/signers/web.ts",
"src/signers/react-native.ts",
"src/index.ts"
],
"format": "cjs",
"splitting": false,
"dts": true,
"shims": true,
"types": [
"./dist/signers/web.d.ts",
"./dist/signers/react-native.d.ts",
"./dist/index.d.ts"
],
"platform": "browser",
"target": "ES6"
},
"jest": {
"setupFiles": [
"./jest-setup-file.ts"
],
"preset": "ts-jest/presets/js-with-ts",
"transform": {
".+\\.(t|j)s$": "ts-jest"
},
"modulePathIgnorePatterns": [
"<rootDir>/dist/"
],
"watchPlugins": [
"jest-watch-typeahead/filename",
"jest-watch-typeahead/testname"
],
"testEnvironment": "jsdom",
"moduleNameMapper": {
"axios": "axios/dist/node/axios.cjs"
},
"testTimeout": 15000
}
}
Loading