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

solution: unify create tx ui #1344

Merged
merged 6 commits into from
Nov 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ module.exports = {
},
],
'unused-imports/no-unused-imports': 'warn',
'unused-imports/no-unused-vars': 'warn',
'unused-imports/no-unused-vars': ['warn', { args: 'after-used' }],
},
settings: {
'import/parsers': {
Expand Down
15 changes: 8 additions & 7 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,25 +26,26 @@ jobs:
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.7'
python-version: '3.10'

- name: Auth GCP
uses: google-github-actions/auth@v1
with:
credentials_json: ${{ secrets.GCP_ARTIFACTS_KEY }}

# on Windows GCP Actions needs path to Python, see https://github.com/GoogleCloudPlatform/github-actions/issues/100
- name: Setup GCP (Windows)
uses: google-github-actions/setup-gcloud@v0
uses: google-github-actions/setup-gcloud@v1
env:
CLOUDSDK_PYTHON: ${{env.pythonLocation}}\python.exe
with:
project_id: ${{ secrets.GCP_PROJECT_ID }}
service_account_key: ${{ secrets.GCP_ARTIFACTS_KEY }}
export_default_credentials: true
if: runner.os == 'Windows'

- name: Setup GCP (non Windows)
uses: google-github-actions/setup-gcloud@v0
uses: google-github-actions/setup-gcloud@v1
with:
project_id: ${{ secrets.GCP_PROJECT_ID }}
service_account_key: ${{ secrets.GCP_ARTIFACTS_KEY }}
export_default_credentials: true
if: runner.os != 'Windows'

- name: Update apt index (Linux)
Expand Down
2 changes: 2 additions & 0 deletions .vscode/emerald-wallet.code-workspace
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,9 @@
"search.exclude": {
"**/.emerald-dev": true,
"**/.tests": true,
"**/.yarn": true,
"**/app": true,
"**/coverage": true,
"**/lib": true,
"**/node_modules": true,
"**/target": true,
Expand Down
15 changes: 15 additions & 0 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,21 @@
{
"type": "npm",
"group": "build",
"label": "clean",
"script": "clean"
},
{
"type": "npm",
"group": "build",
"label": "build:native",
"script": "build:native"
},
{
"type": "npm",
"group": {
"isDefault": true,
"kind": "build"
},
"label": "build:dev",
"script": "build:dev"
},
Expand Down
5 changes: 3 additions & 2 deletions packages/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,15 @@
"test:coverage": "jest --coverage"
},
"dependencies": {
"@emeraldpay/bigamount": "^0.4.1",
"@emeraldpay/bigamount-crypto": "^0.4.1",
"@emeraldpay/bigamount": "^0.4.2",
"@emeraldpay/bigamount-crypto": "^0.4.2",
"@emeraldpay/emerald-vault-core": "^0.12.0",
"@ethereumjs/common": "^3.1.2",
"@ethereumjs/tx": "^4.1.2",
"@ethersproject/abi": "^5.7.0",
"@ethersproject/bignumber": "^5.7.0",
"bignumber.js": "8.0.2",
"bitcoinjs-lib": "^6.1.0",
"ethereumjs-util": "^7.1.5",
"jsonschema": "^1.4.1"
},
Expand Down
12 changes: 9 additions & 3 deletions packages/core/src/blockchains/blockchains.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { BigAmount, CreateAmount, Unit, Units } from '@emeraldpay/bigamount';
import { Satoshi, Wei, WeiAny, WeiEtc } from '@emeraldpay/bigamount-crypto';
import { Satoshi, SatoshiAny, Wei, WeiAny, WeiEtc } from '@emeraldpay/bigamount-crypto';
import { LedgerApp } from '@emeraldpay/emerald-vault-core';
import { Bitcoin } from './Bitcoin';
import { Coin } from './coin';
Expand Down Expand Up @@ -165,7 +165,13 @@
new Unit(18, 'Goerli Ether', 'ETG'),
]);

export const SATOSHIS_TEST = new Units([new Unit(0, 'Test Satoshi', 'tsat'), new Unit(8, 'Test Bitcoin', 'TESTBTC')]);
export const SATOSHIS_TEST = new Units([
new Unit(0, 'Test Satoshi', 'tsat'),
new Unit(1, 'Test Finney', 'tfin'),
new Unit(2, 'Test bit', 'tμBTC'),
new Unit(5, 'Test millibit', 'tmBTC'),
new Unit(8, 'Test Bitcoin', 'TestBTC'),
]);

export function amountFactory(code: BlockchainCode): CreateAmount<BigAmount> {
switch (code) {
Expand All @@ -178,7 +184,7 @@
case BlockchainCode.Goerli:
return (value) => new WeiAny(value, WEIS_GOERLI);
case BlockchainCode.TestBTC:
return (value) => new BigAmount(value, SATOSHIS_TEST);
return (value) => new SatoshiAny(value, SATOSHIS_TEST);

Check warning on line 187 in packages/core/src/blockchains/blockchains.ts

View check run for this annotation

Codecov / codecov/patch

packages/core/src/blockchains/blockchains.ts#L187

Added line #L187 was not covered by tests
default:
throw new Error(`Unsupported blockchain: ${code}`);
}
Expand Down
7 changes: 0 additions & 7 deletions packages/core/src/currency.spec.ts

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

return [
{
address: this.changeAddress,
address: this.changeAddress ?? '',
amount: totalChange.number.toNumber(),
entryId: this.entryId,
},
Expand All @@ -33,6 +33,10 @@
return ValidationResult.INSUFFICIENT_FEE_PRICE;
}

if (this.changeAddress == null) {
return ValidationResult.NO_CHANGE_ADDRESS;

Check warning on line 37 in packages/core/src/workflow/CreateBitcoinCancelTx.ts

View check run for this annotation

Codecov / codecov/patch

packages/core/src/workflow/CreateBitcoinCancelTx.ts#L37

Added line #L37 was not covered by tests
}

if (this.tx.from.length === 0) {
return ValidationResult.NO_FROM;
}
Expand Down
Loading
Loading