Skip to content

Commit

Permalink
problem: parallel set of components for different types of ethereum t…
Browse files Browse the repository at this point in the history
…ransaction

solution: unify in one set of components
  • Loading branch information
BOOMER74 authored Nov 14, 2023
1 parent 1495237 commit ff97d20
Show file tree
Hide file tree
Showing 154 changed files with 4,713 additions and 6,200 deletions.
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 @@ export const WEIS_GOERLI = new Units([
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 @@ export function amountFactory(code: BlockchainCode): CreateAmount<BigAmount> {
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);
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 @@ export class CreateBitcoinCancelTx extends CreateBitcoinTx {

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

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

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

0 comments on commit ff97d20

Please sign in to comment.