Skip to content

Commit

Permalink
Merge branch 'main' into dependabot/npm_and_yarn/follow-redirects-1.15.4
Browse files Browse the repository at this point in the history
  • Loading branch information
davidecarpini authored Jan 29, 2024
2 parents a40788c + abd2bb3 commit bc1270d
Show file tree
Hide file tree
Showing 160 changed files with 1,025 additions and 518 deletions.
11 changes: 5 additions & 6 deletions .github/workflows/deploy-gh-pages.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -40,19 +40,18 @@ jobs:
- name: Build React App
run: |
yarn install:all
yarn build:packages
yarn build:apps
yarn build
- name: Setup Pages
uses: actions/configure-pages@v2

- name: Copy Builds
run: |
mkdir build
cp -r apps/sample-vue-app/dist build/vue
cp -r apps/sample-react-app/dist build/react
cp -r apps/sample-vanilla-app/dist build/vanilla
cp -r apps/sample-angular-app/dist/easy-angular build/angular
cp -r examples/sample-vue-app/dist build/vue
cp -r examples/sample-react-app/dist build/react
cp -r examples/sample-vanilla-app/dist build/vanilla
cp -r examples/sample-angular-app/dist/easy-angular build/angular
- name: Upload artifact
uses: actions/upload-pages-artifact@v1
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Publish NPM package
name: Publish GitHub NPM Packages

on:
push:
Expand Down
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# vechain-dapp-kit

VeWorld DAppKit is a TypeScript library that facilitates seamless interaction between vechain wallets (veworld, sync2)
and dApps, enhancing user experience and developer convenience.
The Vechain DAppKit is a TypeScript library that facilitates seamless interaction between vechain wallets (veworld, sync2)
and dApps, enhancing user experience and developer convenience. Please refer to [Vechain Docs](https://docs.vechain.org/developer-resources/sdks-and-providers/dapp-kit) for full documentation and usage.

## Table of Contents

Expand Down Expand Up @@ -52,7 +52,7 @@ Key Features a.k.a scope

## Sample Projects

- Please refer to the [apps](./apps) folder for sample projects.
- Please refer to the [apps](./examples) folder for sample projects.

---

Expand Down Expand Up @@ -144,6 +144,6 @@ git clone [email protected]:vechainfoundation/vechain-dapp-kit.git
cd vechain-dapp-kit
git checkout X.Y.Z
yarn install:all
yarn build
yarn build:release X.Y.Z
yarn changeset publish
```
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export class AppComponent implements OnInit {

handleConnected(DAppKitUI.wallet.state.address);

DAppKitUI.modal.onConnected(handleConnected);
DAppKitUI.modal.onConnectionStatusChange(handleConnected);
}
}

Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes
File renamed without changes
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import type { WalletConnectOptions } from '@vechain/dapp-kit';

const Button = (): ReactElement => {
const { account } = useWallet();
const { open, onConnected } = useWalletModal();
const { open, onConnectionStatusChange } = useWalletModal();
const [buttonText, setButtonText] = useState('Connect Custom Button');

useEffect(() => {
Expand All @@ -29,8 +29,8 @@ const Button = (): ReactElement => {

handleConnected(account);

onConnected(handleConnected);
}, [account, onConnected]);
onConnectionStatusChange(handleConnected);
}, [account, onConnectionStatusChange]);

return (
<div className="container">
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { useEffect, useState } from 'react';

function App() {
const { account } = useWallet();
const { open, onConnected } = useWalletModal();
const { open, onConnectionStatusChange } = useWalletModal();
const [buttonText, setButtonText] = useState('Connect Custom Button');

useEffect(() => {
Expand All @@ -25,8 +25,8 @@ function App() {

handleConnected(account);

onConnected(handleConnected);
}, [account, onConnected]);
onConnectionStatusChange(handleConnected);
}, [account, onConnectionStatusChange]);

return (
<div className="container">
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@ import { nodePolyfills } from 'vite-plugin-node-polyfills';

export default defineConfig({
plugins: [nodePolyfills(), react()],
build: {
commonjsOptions: {
transformMixedEsModules: true,
},
},
base:
process.env.NODE_ENV === 'production'
? '/vechain-dapp-kit/react/'
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,6 @@ setTimeout(() => {

handleConnected(DAppKitUI.wallet.state.address);

DAppKitUI.modal.onConnected(handleConnected);
DAppKitUI.modal.onConnectionStatusChange(handleConnected);
}
}, 100);
File renamed without changes
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,4 @@ const handleConnected = (address) => {

handleConnected(DAppKitUI.wallet.state.address);

DAppKitUI.modal.onConnected(handleConnected);
DAppKitUI.modal.onConnectionStatusChange(handleConnected);
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ setTimeout(() => {
handleConnected(DAppKitUI.wallet.state.address);
DAppKitUI.modal.onConnected(handleConnected);
DAppKitUI.modal.onConnectionStatusChange(handleConnected);
}
}, 100);
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
7 changes: 4 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
{
"private": true,
"name": "vechain-dapp-kit",
"private": true,
"description": "A TypeScript library that facilitates seamless interaction between vechain wallets (veworld, sync2) and dApps.",
"workspaces": [
"apps/*",
"packages/*"
"examples/*",
"packages/*",
"tests/*"
],
"scripts": {
"build": "turbo run build",
Expand Down
15 changes: 1 addition & 14 deletions packages/dapp-kit-react/README.md
Original file line number Diff line number Diff line change
@@ -1,22 +1,9 @@
# `@vechain/dapp-kit-react`

## Why ?

- Allow easy interaction with all wallets.
- Connex is designed to play nice with one wallet at a time, this library provides a layer on top of Connex to easily
allow interaction with all wallets.
- Easy setup for wallet connect
The Vechain DApp Kit serves as a sophisticated layer built upon @vechain/connex, providing a simplified and efficient avenue for engaging with a multitude of Vechain wallets. This innovative toolkit enhances the ease of interaction, offering developers a seamless bridge to connect with diverse Vechain wallet functionalities. For more information, please refer to the official [Vechain Docs](https://docs.vechain.org/developer-resources/sdks-and-providers/dapp-kit)

## Installation

### Build

```bash
yarn build
```

## Usage

```bash
yarn add @vechain/dapp-kit-react
```
Expand Down
2 changes: 2 additions & 0 deletions packages/dapp-kit-react/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
"name": "@vechain/dapp-kit-react",
"version": "1.0.0",
"private": false,
"homepage": "https://github.com/vechainfoundation/vechain-dapp-kit",
"repository": "github:vechain/vechain-dapp-kit",
"license": "MIT",
"sideEffects": false,
"type": "module",
Expand Down
29 changes: 26 additions & 3 deletions packages/dapp-kit-react/src/DAppKitProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import type { WalletSource } from '@vechain/dapp-kit';
import { DAppKitUI } from '@vechain/dapp-kit-ui';
import { subscribeKey } from 'valtio/vanilla/utils';
import type { DAppKitProviderOptions, DAppKitContext } from './types';
import { Certificate } from 'thor-devkit';

/**
* Context
Expand All @@ -23,6 +24,7 @@ export const DAppKitProvider: React.FC<DAppKitProviderOptions> = ({
walletConnectOptions,
usePersistence = false,
logLevel,
requireCertificate,
themeMode,
themeVariables,
i18n,
Expand All @@ -38,6 +40,7 @@ export const DAppKitProvider: React.FC<DAppKitProviderOptions> = ({
walletConnectOptions,
usePersistence,
logLevel,
requireCertificate,
themeVariables,
themeMode,
i18n,
Expand All @@ -51,6 +54,7 @@ export const DAppKitProvider: React.FC<DAppKitProviderOptions> = ({
walletConnectOptions,
usePersistence,
logLevel,
requireCertificate,
themeVariables,
themeMode,
i18n,
Expand All @@ -66,6 +70,8 @@ export const DAppKitProvider: React.FC<DAppKitProviderOptions> = ({
const [source, setSource] = useState<WalletSource | null>(
connex.wallet.state.source,
);
const [connectionCertificate, setConnectionCertificate] =
useState<Certificate | null>(connex.wallet.state.connectionCertificate);

useEffect(() => {
const addressSub = subscribeKey(connex.wallet.state, 'address', (v) => {
Expand All @@ -74,10 +80,18 @@ export const DAppKitProvider: React.FC<DAppKitProviderOptions> = ({
const sourceSub = subscribeKey(connex.wallet.state, 'source', (v) => {
setSource(v);
});
const certificateSub = subscribeKey(
connex.wallet.state,
'connectionCertificate',
(v) => {
setConnectionCertificate(v);
},
);

return () => {
addressSub();
sourceSub();
certificateSub();
};
}, [connex.wallet.state]);

Expand All @@ -90,7 +104,7 @@ export const DAppKitProvider: React.FC<DAppKitProviderOptions> = ({
}, []);
const onModalConnected = useCallback(
(callback: (address: string | null) => void) =>
DAppKitUI.modal.onConnected(callback),
DAppKitUI.modal.onConnectionStatusChange(callback),
[],
);

Expand All @@ -107,14 +121,23 @@ export const DAppKitProvider: React.FC<DAppKitProviderOptions> = ({
availableWallets: connex.wallet.state.availableSources,
account,
source,
connectionCertificate,
},
modal: {
open: openModal,
close: closeModal,
onConnected: onModalConnected,
onConnectionStatusChange: onModalConnected,
},
};
}, [connex, account, source, closeModal, openModal, onModalConnected]);
}, [
connex,
account,
source,
closeModal,
openModal,
onModalConnected,
connectionCertificate,
]);

return <Context.Provider value={context}>{children}</Context.Provider>;
};
Expand Down
6 changes: 5 additions & 1 deletion packages/dapp-kit-react/src/types.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/// <reference types="@vechain/connex" />
import type React from 'react';
import type { Certificate } from 'thor-devkit';
import type { ConnectResponse, WalletSource } from '@vechain/dapp-kit';
import { type DAppKitUIOptions } from '@vechain/dapp-kit-ui';

Expand Down Expand Up @@ -34,10 +35,13 @@ export interface DAppKitContext {
connect: () => Promise<ConnectResponse>;
account: string | null;
source: WalletSource | null;
connectionCertificate: Certificate | null;
};
modal: {
open: () => void;
close: () => void;
onConnected: (callback: (address: string | null) => void) => void;
onConnectionStatusChange: (
callback: (address: string | null) => void,
) => void;
};
}
16 changes: 1 addition & 15 deletions packages/dapp-kit-ui/README.md
Original file line number Diff line number Diff line change
@@ -1,20 +1,6 @@
# `@vechain/dapp-kit-ui`

## Why ?

- Creating some reusable UI components for connecting wallets
- Allow easy interaction with all wallets.
- Connex is designed to play nice with one wallet at a time, this library provides a layer on top of Connex to easily
allow interaction with all wallets.
- Easy setup for wallet connect.

## Installation

### Build

```bash
yarn build
```
The Vechain DApp Kit serves as a sophisticated layer built upon @vechain/connex, providing a simplified and efficient avenue for engaging with a multitude of Vechain wallets. This innovative toolkit enhances the ease of interaction, offering developers a seamless bridge to connect with diverse Vechain wallet functionalities. For more information, please refer to the official [Vechain Docs](https://docs.vechain.org/developer-resources/sdks-and-providers/dapp-kit)

## Usage

Expand Down
2 changes: 1 addition & 1 deletion packages/dapp-kit-ui/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,4 @@ const handleConnected = (address) => {

handleConnected(DAppKitUI.wallet.state.address);

DAppKitUI.modal.onConnected(handleConnected);
DAppKitUI.modal.onConnectionStatusChange(handleConnected);
2 changes: 2 additions & 0 deletions packages/dapp-kit-ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
"typescript",
"lit"
],
"homepage": "https://github.com/vechainfoundation/vechain-dapp-kit",
"repository": "github:vechain/vechain-dapp-kit",
"license": "MIT",
"author": "Davide Carpini",
"type": "module",
Expand Down
19 changes: 15 additions & 4 deletions packages/dapp-kit-ui/src/assets/styles/button.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,35 +22,42 @@ export const buttonStyle = css`
background: var(--vdk-color-light-primary, ${Colors.Light.Primary});
color: var(--vdk-color-light-tertiary, ${Colors.Light.Tertiary});
}
button.LIGHT:hover {
button.LIGHT:hover:not(:disabled) {
background: var(
--vdk-color-light-primary-hover,
${Colors.Light.PrimaryHover}
);
}
button.LIGHT:active {
button.LIGHT:active:not(:disabled) {
background: var(
--vdk-color-light-primary-active,
${Colors.Light.PrimaryActive}
);
}
button.LIGHT:disabled {
opacity: 0.8;
}
button.DARK {
background: var(--vdk-color-dark-primary, ${Colors.Dark.Primary});
color: var(--vdk-color-dark-tertiary, ${Colors.Dark.Tertiary});
}
button.DARK:hover {
button.DARK:hover:not(:disabled) {
background: var(
--vdk-color-dark-primary-hover,
${Colors.Dark.PrimaryHover}
);
}
button.DARK:active {
button.DARK:active:not(:disabled) {
background: var(
--vdk-color-dark-primary-active,
${Colors.Dark.PrimaryActive}
);
}
button.DARK:disabled {
opacity: 0.8;
}
`;

export const iconButtonStyle = css`
Expand Down Expand Up @@ -83,4 +90,8 @@ export const iconButtonStyle = css`
.icon-button.DARK:active {
background: var(--vdk-color-dark-primary, ${Colors.Dark.PrimaryActive});
}
button:disabled {
opacity: 0.8;
}
`;
Loading

0 comments on commit bc1270d

Please sign in to comment.