Skip to content

Release-candidate: v0.31.0-rc.1 #482

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

Merged
merged 13 commits into from
Sep 11, 2024
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
12 changes: 12 additions & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,18 @@
},
"ignorePatterns": [ "src/config.js", "src/config.*.js", "dist/*" ],
"overrides": [
{
"files": [ "src/**" ],
"rules": {
"no-console": "error"
}
},
{
"files": [ "src/plugins/**" ],
"rules": {
"no-console": "off"
}
},
{
"files": [
"**/*.js"
Expand Down
16 changes: 8 additions & 8 deletions .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,22 +23,22 @@ jobs:

steps:
- name: Checkout
# https://github.com/actions/checkout/releases/tag/v3.5.0
uses: actions/checkout@8f4b7f84864484a7bf31766abe9204da3cbe65b3
# https://github.com/actions/checkout/releases/tag/v4.1.7
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332

- name: Initialize CodeQL
# https://github.com/github/codeql-action/releases/tag/codeql-bundle-v2.15.0
uses: github/codeql-action/init@517782a2a0dd93543ea4f12f41006cf70ddca135
# https://github.com/github/codeql-action/tree/v3.26.3
uses: github/codeql-action/init@883d8588e56d1753a8a58c1c86e88976f0c23449
with:
languages: ${{ matrix.language }}
queries: +security-and-quality

- name: Autobuild
# https://github.com/github/codeql-action/releases/tag/codeql-bundle-v2.15.0
uses: github/codeql-action/autobuild@517782a2a0dd93543ea4f12f41006cf70ddca135
# https://github.com/github/codeql-action/tree/v3.26.3
uses: github/codeql-action/autobuild@883d8588e56d1753a8a58c1c86e88976f0c23449

- name: Perform CodeQL Analysis
# https://github.com/github/codeql-action/releases/tag/codeql-bundle-v2.15.0
uses: github/codeql-action/analyze@517782a2a0dd93543ea4f12f41006cf70ddca135
# https://github.com/github/codeql-action/tree/v3.26.3
uses: github/codeql-action/analyze@883d8588e56d1753a8a58c1c86e88976f0c23449
with:
category: "/language:${{ matrix.language }}"
24 changes: 12 additions & 12 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout
# https://github.com/actions/checkout/releases/tag/v3.5.0
uses: actions/checkout@8f4b7f84864484a7bf31766abe9204da3cbe65b3
# https://github.com/actions/checkout/releases/tag/v4.1.7
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332
- name: Prepare tags
id: tags
run: |
Expand All @@ -21,27 +21,27 @@ jobs:

python scripts/github/docker.py
- name: Set up QEMU
# https://github.com/docker/setup-qemu-action/releases/tag/v2.2.0
uses: docker/setup-qemu-action@2b82ce82d56a2a04d2637cd93a637ae1b359c0a7
# https://github.com/docker/setup-qemu-action/releases/tag/v3.2.0
uses: docker/setup-qemu-action@49b3bc8e6bdd4a60e6116a5414239cba5943d3cf
- name: Set up Docker Buildx
# https://github.com/docker/setup-buildx-action/releases/tag/v2.10.0
uses: docker/setup-buildx-action@885d1462b80bc1c1c7f0b00334ad271f09369c55
# https://github.com/docker/setup-buildx-action/releases/tag/v3.6.1
uses: docker/setup-buildx-action@988b5a0280414f521da01fcc63a27aeeb4b104db
- name: Login to DockerHub
# https://github.com/docker/login-action/releases/tag/v2.2.0
uses: docker/login-action@465a07811f14bebb1938fbed4728c6a1ff8901fc
# https://github.com/docker/login-action/releases/tag/v3.3.0
uses: docker/login-action@9780b0c442fbb1117ed29e0efdff1e18412f7567
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Login to AWS ECR
# https://github.com/docker/login-action/releases/tag/v2.2.0
uses: docker/login-action@465a07811f14bebb1938fbed4728c6a1ff8901fc
# https://github.com/docker/login-action/releases/tag/v3.3.0
uses: docker/login-action@9780b0c442fbb1117ed29e0efdff1e18412f7567
with:
registry: ${{ secrets.AWS_ECR_URL}}
username: ${{ secrets.AWS_ACCESS_KEY_ID }}
password: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
- name: Build and push
# https://github.com/docker/build-push-action/releases/tag/v3.3.1
uses: docker/build-push-action@1104d471370f9806843c095c1db02b5a90c5f8b6
# https://github.com/docker/build-push-action/releases/tag/v6.7.0
uses: docker/build-push-action@5cd11c3a4ced054e52742c5fd54dca954e0edd85
with:
push: true
tags: ${{ steps.tags.outputs.tags }}
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/integration-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@ jobs:

- name: Upload debug transaction logs
if: always()
# https://github.com/actions/upload-artifact/releases/tag/v2.3.1
uses: actions/upload-artifact@82c141cc518b40d92cc801eee768e7aafc9c2fa2
# https://github.com/actions/upload-artifact/releases/tag/v4.3.6
uses: actions/upload-artifact@834a144ee995460fba8ed112a2fc961b36a5ec5a
with:
name: test-transacion-logs
path: tmp
Expand All @@ -72,8 +72,8 @@ jobs:

- name: Upload logs to GitHub
if: failure()
# https://github.com/actions/upload-artifact/releases/tag/v2.3.1
uses: actions/upload-artifact@82c141cc518b40d92cc801eee768e7aafc9c2fa2
# https://github.com/actions/upload-artifact/releases/tag/v4.3.6
uses: actions/upload-artifact@834a144ee995460fba8ed112a2fc961b36a5ec5a
with:
name: logs.tgz
path: ./docker-logs.tgz
8 changes: 4 additions & 4 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@ jobs:
matrix:
node-version: [20.x]
steps:
# https://github.com/actions/checkout/releases/tag/v2.7.0
- uses: actions/checkout@ee0669bd1cc54295c223e0bb666b733df41de1c5
# https://github.com/actions/checkout/releases/tag/v4.1.7
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332
- name: Use Node.js ${{ matrix.node-version }}
# https://github.com/actions/setup-node/releases/tag/v1.4.6
uses: actions/setup-node@f1f314fca9dfce2769ece7d933488f076716723e
# https://github.com/actions/setup-node/releases/tag/v4.0.3
uses: actions/setup-node@1e60f620b9541d16bece96c5465dc8ee9832be0b
with:
node-version: ${{ matrix.node-version }}

Expand Down
2 changes: 1 addition & 1 deletion __tests__/__fixtures__/http-fixtures.js
Original file line number Diff line number Diff line change
Expand Up @@ -1072,7 +1072,7 @@ export default {
nc_pubkey: '033f5d238afaa9e2218d05dd7fa50eb6f9e55431e6359e04b861cd991ae24dc655'
}]
},
'/nano_contract/blueprint': {
'/nano_contract/blueprint/info': {
id: '3cb032600bdf7db784800e4ea911b10676fa2f67591f82bb62628c234e771595',
name: 'Test',
public_methods: {
Expand Down
2 changes: 1 addition & 1 deletion __tests__/integration/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ services:

fullnode:
image:
${HATHOR_LIB_INTEGRATION_TESTS_FULLNODE_IMAGE:-hathornetwork/hathor-core:experimental-nano-sdk-v1.1}
${HATHOR_LIB_INTEGRATION_TESTS_FULLNODE_IMAGE:-hathornetwork/hathor-core:experimental-nano-sdk-v1.5-rc4}
command: [
"run_node",
"--listen", "tcp:40404",
Expand Down
14 changes: 6 additions & 8 deletions __tests__/integration/nano-contracts.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,6 @@ describe('nano contract routes', () => {

// Bet 100 to address 2
const address2 = await wallet.getAddressAt(2);
const address2Obj = new Address(address2, { network });
const responseBet = await TestUtils.request
.post('/wallet/nano-contracts/execute')
.send({
Expand All @@ -86,7 +85,7 @@ describe('nano contract routes', () => {
method: 'bet',
data: {
args: [
bufferUtils.bufferToHex(address2Obj.decode()),
address2,
'1x0'
],
actions: [
Expand All @@ -106,7 +105,6 @@ describe('nano contract routes', () => {

// Bet 200 to address 3
const address3 = await wallet.getAddressAt(3);
const address3Obj = new Address(address3, { network });
const responseBet2 = await TestUtils.request
.post('/wallet/nano-contracts/execute')
.send({
Expand All @@ -115,7 +113,7 @@ describe('nano contract routes', () => {
method: 'bet',
data: {
args: [
bufferUtils.bufferToHex(address3Obj.decode()),
address3,
'2x0'
],
actions: [
Expand Down Expand Up @@ -153,7 +151,7 @@ describe('nano contract routes', () => {
'total',
'final_result',
'oracle_script',
'date_last_offer',
'date_last_bet',
`address_details.a'${address2}'`,
`withdrawals.a'${address2}'`,
`address_details.a'${address3}'`,
Expand All @@ -166,7 +164,7 @@ describe('nano contract routes', () => {
const outputScriptBuffer1 = outputScriptObj1.createScript();

expect(ncState.fields.token_uid.value).toBe(HATHOR_TOKEN_ID);
expect(ncState.fields.date_last_offer.value).toBe(dateLastBet);
expect(ncState.fields.date_last_bet.value).toBe(dateLastBet);
expect(ncState.fields.oracle_script.value).toBe(bufferUtils.bufferToHex(outputScriptBuffer1));
expect(ncState.fields.final_result.value).toBeNull();
expect(ncState.fields.total.value).toBe(300);
Expand Down Expand Up @@ -230,7 +228,7 @@ describe('nano contract routes', () => {
'total',
'final_result',
'oracle_script',
'date_last_offer',
'date_last_bet',
`address_details.a'${address2}'`,
`withdrawals.a'${address2}'`,
`address_details.a'${address3}'`,
Expand All @@ -239,7 +237,7 @@ describe('nano contract routes', () => {
.set({ 'x-wallet-id': wallet.walletId });
const ncState2 = responseState2.body.state;
expect(ncState2.fields.token_uid.value).toBe(HATHOR_TOKEN_ID);
expect(ncState2.fields.date_last_offer.value).toBe(dateLastBet);
expect(ncState2.fields.date_last_bet.value).toBe(dateLastBet);
expect(ncState2.fields.oracle_script.value).toBe(bufferUtils.bufferToHex(outputScriptBuffer1));
expect(ncState2.fields.final_result.value).toBe('1x0');
expect(ncState2.fields.total.value).toBe(300);
Expand Down
71 changes: 71 additions & 0 deletions __tests__/stop.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
import { HathorWallet } from '@hathor/wallet-lib';
import TestUtils from './test-utils';
import { initializedWallets } from '../src/services/wallets.service';

const walletId = 'stub_stop';

describe('addresses api', () => {
beforeEach(async () => {
await TestUtils.startWallet({ walletId });
});

afterEach(async () => {
/** @type {HathorWallet} */
const wallet = initializedWallets.get(walletId);
if (!wallet) {
return;
}
wallet.setState(HathorWallet.ERROR);
await TestUtils.request
.post('/wallet/stop')
.set({ 'x-wallet-id': walletId });
});

it('should stop a wallet that has entered the ERROR state', async () => {
/** @type {HathorWallet} */
const wallet = initializedWallets.get(walletId);
wallet.setState(HathorWallet.ERROR);

const response = await TestUtils.request
.post('/wallet/stop')
.set({ 'x-wallet-id': walletId });
expect(response.status).toBe(200);
expect(response.body.success).toBe(true);
});

it('should not stop a wallet that is SYNCING', async () => {
/** @type {HathorWallet} */
const wallet = initializedWallets.get(walletId);
wallet.setState(HathorWallet.SYNCING);

const response = await TestUtils.request
.post('/wallet/stop')
.set({ 'x-wallet-id': walletId });
expect(response.status).toBe(200);
expect(response.body.success).toBe(false);
});

it('should not stop a wallet that is CONNECTING', async () => {
/** @type {HathorWallet} */
const wallet = initializedWallets.get(walletId);
wallet.setState(HathorWallet.CONNECTING);

const response = await TestUtils.request
.post('/wallet/stop')
.set({ 'x-wallet-id': walletId });
expect(response.status).toBe(200);
expect(response.body.success).toBe(false);
});

it('should not stop a wallet that is CLOSED', async () => {
/** @type {HathorWallet} */
const wallet = initializedWallets.get(walletId);
wallet.setState(HathorWallet.CLOSED);

const response = await TestUtils.request
.post('/wallet/stop')
.set({ 'x-wallet-id': walletId });
expect(response.status).toBe(200);
expect(response.body.success).toBe(false);
});
});
2 changes: 1 addition & 1 deletion __tests__/test-utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ class TestUtils {
httpMock.onGet('http://fake.txmining:8084/health').reply(200, httpFixtures['http://fake.txmining:8084/health']);
httpMock.onGet('/nano_contract/state').reply(200, httpFixtures['/nano_contract/state']);
httpMock.onGet('/nano_contract/history').reply(200, httpFixtures['/nano_contract/history']);
httpMock.onGet('/nano_contract/blueprint').reply(200, httpFixtures['/nano_contract/blueprint']);
httpMock.onGet('/nano_contract/blueprint/info').reply(200, httpFixtures['/nano_contract/blueprint/info']);

// Fireblocks mock
httpMock.onGet(/http:\/\/fake-fireblocks-url\/v1\/transactions\/external_tx_id\/*/).reply(fireblocksFixtures.transaction_status);
Expand Down
4 changes: 2 additions & 2 deletions config.js.docker
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,8 @@ for (const x of seeds) {
// Multisig configuration and validation
const multisigPubkeys = getParam(`multisig_seed_${x}_pubkeys`);
const multisig = {
total: getParam(`multisig_seed_${x}_max_signatures`),
numSignatures: getParam(`multisig_seed_${x}_num_signatures`),
total: getIntParam(`multisig_seed_${x}_max_signatures`),
numSignatures: getIntParam(`multisig_seed_${x}_num_signatures`),
};
if (!(multisigPubkeys || multisig.total || multisig.numSignatures)) {
// No multisig parameters means this is not a multisig.
Expand Down
23 changes: 17 additions & 6 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "hathor-wallet-headless",
"version": "0.30.0-rc.1",
"version": "0.30.0",
"description": "Hathor Wallet Headless, i.e., without graphical user interface",
"main": "index.js",
"engines": {
Expand All @@ -10,7 +10,7 @@
"dependencies": {
"@dinamonetworks/hsm-dinamo": "4.9.1",
"@hathor/healthcheck-lib": "0.1.0",
"@hathor/wallet-lib": "1.9.0",
"@hathor/wallet-lib": "1.12.1",
"axios": "1.7.2",
"express": "4.18.2",
"express-validator": "6.10.0",
Expand Down
Loading
Loading