Skip to content

Commit

Permalink
fix: linting issues
Browse files Browse the repository at this point in the history
  • Loading branch information
darrenvechain committed Nov 13, 2024
1 parent 89f8a54 commit bbf4cba
Show file tree
Hide file tree
Showing 8 changed files with 282 additions and 73 deletions.
Binary file modified .yarn/install-state.gz
Binary file not shown.
4 changes: 2 additions & 2 deletions packages/dapp-kit/src/classes/certificate-wallet.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Certificate } from '@vechain/sdk-core';
import type { ConnectResponse, VechainWallet } from '../types';
import type { ConnectResponse, VeChainWallet } from '../types';
import { DEFAULT_CONNECT_CERT_MESSAGE } from '../constants';
import type {
CertificateMessage,
Expand All @@ -14,7 +14,7 @@ import type { WalletSigner } from '../types/types';
/**
* A `VechainWallet` for wallet's that use a certificate connection
*/
class CertificateBasedWallet implements VechainWallet {
class CertificateBasedWallet implements VeChainWallet {
constructor(
private readonly wallet: Promise<WalletSigner>,
private readonly connectionCertificateData?: {
Expand Down
10 changes: 5 additions & 5 deletions packages/dapp-kit/src/classes/wallet-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import type { ThorClient } from '@vechain/sdk-network';
import type {
ConnectResponse,
DAppKitOptions,
VechainWallet,
VeChainWallet,
WalletManagerState,
WalletSource,
} from '../types';
Expand All @@ -22,7 +22,7 @@ import type {

class WalletManager {
public readonly state: WalletManagerState;
private wallets: Record<string, VechainWallet | undefined> = {};
private wallets: Record<string, VeChainWallet | undefined> = {};

constructor(
private readonly options: DAppKitOptions,
Expand All @@ -39,7 +39,7 @@ class WalletManager {
}
}

private get wallet(): VechainWallet {
private get wallet(): VeChainWallet {
const source = this.state.source;

DAppKitLogger.debug(
Expand Down Expand Up @@ -177,7 +177,7 @@ class WalletManager {

signTx = (
msg: TransactionMessage[],
options: TransactionOptions,
options: TransactionOptions = {},
): Promise<TransactionResponse> =>
this.wallet
.signTx(msg, options)
Expand All @@ -193,7 +193,7 @@ class WalletManager {

signCert = (
msg: CertificateMessage,
options: CertificateOptions,
options: CertificateOptions = {},
): Promise<CertificateResponse> =>
this.wallet
.signCert(msg, options)
Expand Down
3 changes: 1 addition & 2 deletions packages/dapp-kit/src/types/index.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
export type {
DAppKitOptions,
VechainWallet,
VeChainWallet,
WalletSource,
ConnectResponse,
WalletConfig,
BaseWallet,
WalletManagerState,
Genesis,
} from './types';
Expand Down
10 changes: 3 additions & 7 deletions packages/dapp-kit/src/types/types.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,15 +67,12 @@ interface WalletSigner {
) => Promise<CertificateResponse>;
}

type BaseWallet = WalletSigner & {
disconnect?: () => Promise<void> | void;
};

/**
* Modifies the WalletSigner interface to include a disconnect method
*/
type VechainWallet = BaseWallet & {
type VeChainWallet = WalletSigner & {
connect: () => Promise<ConnectResponse>;
disconnect?: () => void | Promise<void>;
};

interface ConnectResponse {
Expand All @@ -92,9 +89,8 @@ interface WalletManagerState {
}

export type {
BaseWallet,
DAppKitOptions,
VechainWallet,
VeChainWallet,
WalletConfig,
WalletSource,
WalletManagerState,
Expand Down
13 changes: 8 additions & 5 deletions packages/dapp-kit/src/utils/create-wallet.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
import type { ThorClient } from '@vechain/sdk-network';
import type {
DAppKitOptions,
VechainWallet,
VeChainWallet,
WalletSource,
WCClient,
WCModal,
} from '../types';
import { CertificateBasedWallet } from '../classes/certificate-wallet';
import type { WalletSigner } from '../types/types';
import { createWcClient } from './create-wc-client';
import { createWcModal } from './create-wc-modal';
import { createWcSigner } from './create-wc-signer';
Expand All @@ -26,7 +25,7 @@ export const createWallet = ({
walletConnectOptions,
onDisconnected,
connectionCertificate,
}: ICreateWallet): VechainWallet => {
}: ICreateWallet): VeChainWallet => {
DAppKitLogger.debug('createWallet', source);

const genesisId = thor.blocks.getGenesisBlock().then((block) => {
Expand Down Expand Up @@ -54,13 +53,17 @@ export const createWallet = ({
throw new Error('VeWorld Extension is not installed');
}

const signer: Promise<WalletSigner> = genesisId
const signer: Promise<VeChainWallet> = genesisId
.then((genesis) => {
if (!window.vechain) {
throw new Error('VeWorld Extension is not installed');
}

return window.vechain.newConnexSigner(genesis);
const veworld = window.vechain.newConnexSigner(genesis);
return new CertificateBasedWallet(
Promise.resolve(veworld),
connectionCertificate,
);
})
.catch((e) => {
DAppKitLogger.error('createWallet', 'veworld', e);
Expand Down
8 changes: 6 additions & 2 deletions scripts/prepare-packages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,11 @@ const updatePackageVersions = (version: string) => {
const preparePackages = async () => {
const version = process.argv[2];

if (!version || !version.match(/^\d+\.\d+\.\d+$/)) {
if (
!version ||
(!version.match(/^\d+\.\d+\.\d+$/) &&
!version.match(/^\d+\.\d+\.\d+(-rc\.\d+)?$/))
) {
console.error(
`🚨 You must specify a semantic version as the first argument 🚨`,
);
Expand All @@ -86,7 +90,7 @@ const preparePackages = async () => {

console.log(' Build:');
console.log(' - 📦 Building packages...');
await exec('yarn install:all');
await exec('yarn install && yarn install:all');
console.log(' - ✅ Built!');

console.log(' Test:');
Expand Down
Loading

0 comments on commit bbf4cba

Please sign in to comment.