Skip to content

Commit

Permalink
fix: merge with main
Browse files Browse the repository at this point in the history
  • Loading branch information
rodolfopietro97 committed Aug 19, 2024
2 parents 47913b4 + 50d86fc commit c38f4ef
Show file tree
Hide file tree
Showing 32 changed files with 2,635 additions and 2,626 deletions.
27 changes: 27 additions & 0 deletions .github/workflows/sonar-scan.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: PR Sonar Scan

on:
push:
branches:
- main
pull_request:

jobs:
sonar-scan:
name: Sonar Scan
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
with:
fetch-depth: 0

- name: SonarCloud Scan
uses: sonarsource/sonarcloud-github-action@master
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
with:
args: >
-Dsonar.verbose=false
-Dsonar.branch.name=${{ github.head_ref || github.ref_name }}
3 changes: 1 addition & 2 deletions examples/sample-angular-app/src/app/app-routing.module.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// Angular modules
import { NgModule } from '@angular/core';
import { Routes } from '@angular/router';
import { RouterModule } from '@angular/router';
import { type Routes, RouterModule } from '@angular/router';

const routes: Routes = [];

Expand Down
9 changes: 2 additions & 7 deletions examples/sample-angular-app/src/app/app.module.ts
Original file line number Diff line number Diff line change
@@ -1,20 +1,15 @@
// Angular modules
import { HttpClient } from '@angular/common/http';
import { HttpClientModule } from '@angular/common/http';
import { HttpClient, HttpClientModule } from '@angular/common/http';
import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { DatePipe } from '@angular/common';
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';

// External modules
import { TranslateModule } from '@ngx-translate/core';
import { TranslateLoader } from '@ngx-translate/core';
import { TranslateModule, TranslateLoader } from '@ngx-translate/core';
import { TranslateHttpLoader } from '@ngx-translate/http-loader';
import { AngularSvgIconModule } from 'angular-svg-icon';

// Internal modules
import { AppRoutingModule } from './app-routing.module';

// Components
import { AppComponent } from './app.component';

Expand Down
2 changes: 1 addition & 1 deletion examples/sample-react-app/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export default defineConfig(({ mode }) => {
//vitest
test: {
globals: true,
environment: 'jsdom',
environment: 'happy-dom',
setupFiles: [
resolve(__dirname, 'test/setup/setup.ts'),
resolve(__dirname, 'test/setup/resizeObserverMock.ts'),
Expand Down
10 changes: 5 additions & 5 deletions packages/dapp-kit-react/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@vechain/dapp-kit-react",
"version": "2.0.0",
"version": "1.0.11",
"private": false,
"homepage": "https://github.com/vechain/vechain-dapp-kit",
"repository": "github:vechain/vechain-dapp-kit",
Expand All @@ -27,20 +27,20 @@
"@lit/react": "^1.0.1",
"@vechain/dapp-kit": "*",
"@vechain/dapp-kit-ui": "*",
"@vechain/sdk-core": "1.0.0-beta.13",
"@vechain/sdk-network": "1.0.0-beta.13",
"@vechain/sdk-core": "1.0.0-beta.24",
"@vechain/sdk-network": "1.0.0-beta.24",
"valtio": "1.11.2"
},
"devDependencies": {
"@testing-library/react": "^14.1.2",
"@types/react": "^18.2.28",
"@types/react-dom": "^18.2.13",
"@vechain/repo-config": "https://github.com/vechain/repo-config#v0.0.1",
"eslint": "*",
"eslint": "^8.15.0",
"react": "^18.2.0",
"tsup": "*",
"typescript": "*",
"vite": "^4.5.2",
"vitest": "1.5.3"
"vitest": "^0.34.6"
}
}
2 changes: 1 addition & 1 deletion packages/dapp-kit-react/src/DAppKitProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ import React, {
import type { WalletSource } from '@vechain/dapp-kit';
import { DAppKitUI } from '@vechain/dapp-kit-ui';
import { subscribeKey } from 'valtio/vanilla/utils';
import { type Certificate } from '@vechain/sdk-core';
import type { DAppKitProviderOptions, DAppKitContext } from './types';
import { Certificate } from '@vechain/sdk-core';

/**
* Context
Expand Down
2 changes: 1 addition & 1 deletion packages/dapp-kit-react/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ import type {
CertMessage,
CertOptions,
ConnectResponse,
EthersProvider,
ExtendedClause,
SendTxOptions,
TransactionResponse,
WalletSource,
} from '@vechain/dapp-kit';
import { EthersProvider } from '@vechain/dapp-kit';
import { type DAppKitUIOptions } from '@vechain/dapp-kit-ui';
import type { Certificate } from '@vechain/sdk-core';
import type { ThorClient } from '@vechain/sdk-network';
Expand Down
28 changes: 18 additions & 10 deletions packages/dapp-kit-react/test/helpers/mocked-signer.ts
Original file line number Diff line number Diff line change
@@ -1,23 +1,31 @@
/// <reference types="@vechain/connex" />
import { blake2b256, Certificate, HDNode, secp256k1 } from 'thor-devkit';
import {
addressUtils,
blake2b256,
Certificate,
HDNode,
secp256k1,
certificate,
Hex0x,
} from '@vechain/sdk-core';

const mnemonicWords =
'denial kitchen pet squirrel other broom bar gas better priority spoil cross';

const hdNode = HDNode.fromMnemonic(mnemonicWords.split(' '));

const firstAccount = hdNode.derive(0);
const firstAccount = hdNode.deriveChild(0);

const privateKey: Buffer = firstAccount.privateKey!;
const address = firstAccount.address;
const privateKey = firstAccount.privateKey!;
const address = addressUtils.fromPrivateKey(privateKey);

const mockedConnexSigner: Connex.Signer = {
signTx() {
return Promise.resolve({ txid: '0x1234', signer: address });
},

signCert(msg) {
const certificate: Certificate = {
const newCertificate: Certificate = {
domain: ' localhost:3000',
timestamp: 12341234,
signer: address,
Expand All @@ -26,17 +34,17 @@ const mockedConnexSigner: Connex.Signer = {
};

const signature = secp256k1.sign(
blake2b256(Certificate.encode(certificate)),
blake2b256(certificate.encode(newCertificate)),
privateKey,
);

return Promise.resolve({
annex: {
domain: certificate.domain,
timestamp: certificate.timestamp,
signer: certificate.signer,
domain: newCertificate.domain,
timestamp: newCertificate.timestamp,
signer: newCertificate.signer,
},
signature: `0x${signature.toString('hex')}`,
signature: Hex0x.of(signature),
});
},
};
Expand Down
2 changes: 1 addition & 1 deletion packages/dapp-kit-react/test/useWallet.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ describe('useWallet', () => {
await waitFor(() => {
expect(result.current.source).toBe('sync2');
expect(result.current.account).toBe(
'0xf077b491b355e64048ce21e3a6fc4751eeea77fa',
'0xf077b491b355E64048cE21E3A6Fc4751eEeA77fa',
);
});

Expand Down
2 changes: 1 addition & 1 deletion packages/dapp-kit-react/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { defineConfig } from 'vitest/config';
export default defineConfig({
test: {
include: ['test/**/*.test.ts', 'test/**/*.test.tsx'],
environment: 'jsdom',
environment: 'happy-dom',
reporters: 'dot',
setupFiles: [resolve(__dirname, 'test/setup/setup.ts')],
coverage: {
Expand Down
2 changes: 1 addition & 1 deletion packages/dapp-kit-ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
"@vechain/picasso": "2.1.1",
"@vechain/sdk-core": "1.0.0-beta.13",
"@vechain/sdk-logging": "^1.0.0-beta.13",
"@vechain/sdk-network": "1.0.0-beta.13",
"@vechain/sdk-network": "1.0.0-beta.24",
"@wagmi/core": "^1.4.5",
"@web3modal/ethereum": "^2.7.1",
"@web3modal/html": "^2.7.1",
Expand Down
30 changes: 14 additions & 16 deletions packages/dapp-kit-ui/src/components/buttons/button.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,22 +76,20 @@ export class Button extends LitElement {
mobile = false;

override render(): TemplateResult {
return html`
${this.address
? html`<vdk-address-button
.mode=${this.mode}
.address=${this.address}
.disabled=${this.disabled}
.mobile=${this.mobile}
></vdk-address-button>`
: html`<vdk-connect-button
.mode=${this.mode}
.i18n=${this.i18n}
.language=${this.language}
.disabled=${this.disabled}
.mobile=${this.mobile}
></vdk-connect-button>`}
`;
return this.address
? html`<vdk-address-button
.mode=${this.mode}
.address=${this.address}
.disabled=${this.disabled}
.mobile=${this.mobile}
></vdk-address-button>`
: html`<vdk-connect-button
.mode=${this.mode}
.i18n=${this.i18n}
.language=${this.language}
.disabled=${this.disabled}
.mobile=${this.mobile}
></vdk-connect-button>`;
}
}

Expand Down
2 changes: 1 addition & 1 deletion packages/dapp-kit-ui/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { resolve } from 'node:path'; // eslint-disable-next-line import/no-defau
export default defineConfig({
test: {
include: ['test/**/*.test.ts'],
environment: 'jsdom',
environment: 'happy-dom',
reporters: 'dot',
setupFiles: [resolve(__dirname, 'test/setup/setup.ts')],
coverage: {
Expand Down
24 changes: 13 additions & 11 deletions packages/dapp-kit/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@vechain/dapp-kit",
"version": "2.0.0",
"version": "1.0.11",
"private": false,
"homepage": "https://github.com/vechain/vechain-dapp-kit",
"repository": "github:vechain/vechain-dapp-kit",
Expand All @@ -10,7 +10,6 @@
"types": "./dist/index.d.ts",
"files": [
"dist",
"src",
"package.json",
"README.md",
"LICENSE"
Expand All @@ -24,29 +23,32 @@
"watch": "yarn build --watch"
},
"dependencies": {
"@noble/curves": "^1.4.0",
"@vechain/sdk-core": "1.0.0-beta.13",
"@vechain/sdk-errors": "^1.0.0-beta.13",
"@vechain/sdk-network": "1.0.0-beta.13",
"@vechain/connex": "2.1.0",
"@vechain/connex-driver": "2.1.0",
"@vechain/connex-framework": "2.1.0",
"@vechain/connex-types": "^2.1.0",
"@vechain/sdk-core": "1.0.0-beta.24",
"@walletconnect/modal": "2.6.2",
"@walletconnect/sign-client": "2.10.2",
"@walletconnect/utils": "2.10.2",
"events": "^3.3.0",
"randombytes": "^2.1.0",
"valtio": "1.11.2"
"valtio": "1.11.2",
"@noble/curves": "^1.4.0",
"@vechain/sdk-network": "1.0.0-beta.24",
"randombytes": "^2.1.0"
},
"devDependencies": {
"@types/react": "^18.2.28",
"@types/react-dom": "^18.2.13",
"@vechain/repo-config": "https://github.com/vechain/repo-config#v0.0.1",
"@vitest/coverage-v8": "^0.34.6",
"@walletconnect/types": "2.10.2",
"eslint": "*",
"happy-dom": "^12.10.3",
"eslint": "^8.15.0",
"happy-dom": "^14.12.3",
"lokijs": "^1.5.12",
"tsup": "*",
"typescript": "*",
"vite": "^4.5.2",
"vitest": "1.5.3"
"vitest": "^0.34.6"
}
}
6 changes: 3 additions & 3 deletions packages/dapp-kit/src/classes/certificate-wallet.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
import { certificate } from '@vechain/sdk-core';
import {certificate} from '@vechain/sdk-core';
import type {
BaseWallet,
CertificateResponse,
CertMessage,
CertOptions,
ConnectResponse,
RemoteWallet,
ExtendedClause,
RemoteWallet,
SendTxOptions,
WalletTransactionResponse,
} from '../types';
import { DEFAULT_CONNECT_CERT_MESSAGE } from '../constants';
import {DEFAULT_CONNECT_CERT_MESSAGE} from '../constants';

/**
* A `RemoteWallet` for wallet's that use a certificate connection
Expand Down
4 changes: 2 additions & 2 deletions packages/dapp-kit/src/constants/genesis-blocks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export const genesisBlocks: Record<NetworkType, CompressedBlockDetail> = {
signer: '0x0000000000000000000000000000000000000000',
isTrunk: true,
transactions: [],
},
} as CompressedBlockDetail,
test: {
number: 0,
id: '0x000000000b2bce3c70bc649a02749e8687721b09ed2e15997f466536b20bb127',
Expand All @@ -46,5 +46,5 @@ export const genesisBlocks: Record<NetworkType, CompressedBlockDetail> = {
signer: '0x0000000000000000000000000000000000000000',
isTrunk: true,
transactions: [],
},
} as CompressedBlockDetail,
};
13 changes: 2 additions & 11 deletions packages/dapp-kit/src/types/types.d.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,6 @@
import { type Certificate } from '@vechain/sdk-core';
import type { WalletConnectOptions } from '@vechain/dapp-kit';
import type { LogLevel } from '../utils/logger';
import type { Certificate } from '@vechain/sdk-core';
import type {
CertificateResponse,
CertMessage,
CertOptions,
ExtendedClause,
SendTxOptions,
WalletTransactionResponse,
} from './signer';
import { CompressedBlockDetail } from '@vechain/sdk-network';
import type { LogLevel } from '../utils';

declare global {
interface Window {
Expand Down
2 changes: 1 addition & 1 deletion packages/dapp-kit/src/utils/create-wc-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import type {
ResolvedSignClient,
WalletConnectOptions,
WCClient,
} from '../types/wc-types';
} from '../types';

const _cachedClients: Record<string, WCClient | undefined> = {};

Expand Down
2 changes: 1 addition & 1 deletion packages/dapp-kit/src/utils/create-wc-modal.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { WalletConnectModal } from '@walletconnect/modal';
import type { WCModal } from '../types/wc-types';
import type { WCModal } from '../types';

const _cachedModals: Record<string, WalletConnectModal | undefined> = {};

Expand Down
Loading

0 comments on commit c38f4ef

Please sign in to comment.