From e1c0bd731f975fad996d8f4c0c63479da1b6bd42 Mon Sep 17 00:00:00 2001 From: Darren Kelly Date: Wed, 8 Nov 2023 11:14:23 +0000 Subject: [PATCH 1/8] feat: publish to internal NPM --- .github/workflows/publish-wallet-kit.yaml | 34 +++++++++++++++++++++++ packages/react-wallet-kit/package.json | 2 +- packages/vanilla-wallet-kit/package.json | 4 +-- packages/wallet-connect/package.json | 2 +- packages/wallet-kit/package.json | 2 +- 5 files changed, 39 insertions(+), 5 deletions(-) create mode 100644 .github/workflows/publish-wallet-kit.yaml diff --git a/.github/workflows/publish-wallet-kit.yaml b/.github/workflows/publish-wallet-kit.yaml new file mode 100644 index 00000000..dc34c83b --- /dev/null +++ b/.github/workflows/publish-wallet-kit.yaml @@ -0,0 +1,34 @@ +name: Publish NPM package + +on: + push: + branches: + - test-publishing + +permissions: + contents: read + packages: write + +jobs: + publish: + runs-on: ubuntu-latest + permissions: + contents: read + packages: write + strategy: + matrix: + package: [ wallet-kit,react-wallet-kit,wallet-connect,vanilla-wallet-kit ] + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-node@v3 + with: + node-version: 16 + registry-url: https://npm.pkg.github.com/ + - run: yarn install:all + - run: yarn build + - run: | + cd packages/${{ matrix.package }} + yarn version --no-git-tag-version --new-version 0.0.1-beta + yarn publish + env: + NODE_AUTH_TOKEN: ${{secrets.GITHUB_TOKEN}} diff --git a/packages/react-wallet-kit/package.json b/packages/react-wallet-kit/package.json index 9eb81aef..5da1b5f8 100644 --- a/packages/react-wallet-kit/package.json +++ b/packages/react-wallet-kit/package.json @@ -1,5 +1,5 @@ { - "name": "@vechain/react-wallet-kit", + "name": "@vechainfoundation/react-wallet-kit", "version": "0.0.0", "private": true, "license": "MIT", diff --git a/packages/vanilla-wallet-kit/package.json b/packages/vanilla-wallet-kit/package.json index 3f1e7fa2..9500fb50 100644 --- a/packages/vanilla-wallet-kit/package.json +++ b/packages/vanilla-wallet-kit/package.json @@ -1,6 +1,6 @@ { - "name": "@vechain/vanilla-wallet-kit", - "version": "2.0.0", + "name": "@vechainfoundation/vanilla-wallet-kit", + "version": "0.0.0", "private": true, "description": "Vanilla js wallet kit", "keywords": [ diff --git a/packages/wallet-connect/package.json b/packages/wallet-connect/package.json index 51476ed1..84f4077f 100644 --- a/packages/wallet-connect/package.json +++ b/packages/wallet-connect/package.json @@ -1,5 +1,5 @@ { - "name": "@vechain/wallet-connect", + "name": "@vechainfoundation/wallet-connect", "version": "0.0.0", "private": true, "license": "MIT", diff --git a/packages/wallet-kit/package.json b/packages/wallet-kit/package.json index 2d8e3677..594834f7 100644 --- a/packages/wallet-kit/package.json +++ b/packages/wallet-kit/package.json @@ -1,5 +1,5 @@ { - "name": "@vechain/wallet-kit", + "name": "@vechainfoundation/wallet-kit", "version": "0.0.0", "private": true, "main": "./dist/index.js", From a1b88846d01daf399eabbe6c6204d243399fe076 Mon Sep 17 00:00:00 2001 From: Darren Kelly Date: Wed, 8 Nov 2023 11:18:05 +0000 Subject: [PATCH 2/8] fix: change to @vechainfoundation --- apps/sample-react-app/package.json | 8 ++++---- apps/sample-react-app/src/App.tsx | 4 ++-- .../sample-react-app/src/Components/AccountDetailBody.tsx | 2 +- .../src/Components/AccountDetailModal.tsx | 4 ++-- .../src/Components/SwitchWalletButton.tsx | 5 ++++- apps/sample-react-app/src/Components/layout/NavBar.tsx | 2 +- apps/sample-react-app/src/Constants/Constants.ts | 2 +- apps/sample-react-app/src/Hooks/useCounter.ts | 2 +- apps/sample-react-app/src/Logos/Logo.tsx | 2 +- apps/sample-react-app/src/Screens/components/Counter.tsx | 2 +- apps/sample-vanilla-app/index.js | 2 +- apps/sample-vanilla-app/package.json | 2 +- apps/sample-vue-app/package.json | 4 ++-- apps/sample-vue-app/src/connex/ConnexProvider.vue | 6 +++--- apps/sample-vue-app/src/connex/types.d.ts | 2 +- apps/sample-vue-app/src/main.ts | 2 +- package.json | 4 ++-- packages/react-wallet-kit/package.json | 6 +++--- .../ConnectWalletButton/Components/WalletSourceRadio.tsx | 2 +- .../src/ConnectWalletButton/Constants/Constants.ts | 4 ++-- packages/react-wallet-kit/src/ConnexProvider.tsx | 6 +++--- packages/react-wallet-kit/src/types.ts | 7 +++++-- packages/vanilla-wallet-kit/package.json | 2 +- packages/vanilla-wallet-kit/src/client.ts | 6 +++--- .../src/components/base/vwk-base-modal/index.ts | 2 +- .../src/components/vwk-connect-button-with-modal/index.ts | 2 +- .../src/components/vwk-connect-button/index.ts | 2 +- .../src/components/vwk-connect-modal/index.ts | 2 +- .../src/components/vwk-source-card/index.ts | 2 +- packages/wallet-kit/README.md | 2 +- packages/wallet-kit/package.json | 2 +- packages/wallet-kit/src/create-wallet.ts | 2 +- packages/wallet-kit/src/types.d.ts | 2 +- packages/wallet-kit/src/wallets/wc-wallet.ts | 2 +- 34 files changed, 57 insertions(+), 51 deletions(-) diff --git a/apps/sample-react-app/package.json b/apps/sample-react-app/package.json index 9e5cb767..7615fe61 100644 --- a/apps/sample-react-app/package.json +++ b/apps/sample-react-app/package.json @@ -43,11 +43,11 @@ "@vechain/hardhat-vechain": "^0.1.4", "@vechain/hardhat-web3": "^0.1.4", "@vechain/picasso": "^2.1.1", - "@vechain/react-wallet-kit": "*", - "@vechain/vanilla-wallet-kit": "*", - "@vechain/wallet-connect": "*", - "@vechain/wallet-kit": "*", "@vechain/web3-providers-connex": "^1.1.2", + "@vechainfoundation/react-wallet-kit": "*", + "@vechainfoundation/vanilla-wallet-kit": "*", + "@vechainfoundation/wallet-connect": "*", + "@vechainfoundation/wallet-kit": "*", "buffer": "^6.0.3", "crypto-browserify": "^3.12.0", "framer-motion": "3.10.6", diff --git a/apps/sample-react-app/src/App.tsx b/apps/sample-react-app/src/App.tsx index bee5c233..e001d0c9 100644 --- a/apps/sample-react-app/src/App.tsx +++ b/apps/sample-react-app/src/App.tsx @@ -1,8 +1,8 @@ import type { JSX } from 'react'; import React from 'react'; import type { Options } from '@vechain/connex'; -import type { WalletConnectOptions } from '@vechain/wallet-connect'; -import { ConnexProvider } from '@vechain/react-wallet-kit'; +import type { WalletConnectOptions } from '@vechainfoundation/wallet-connect'; +import { ConnexProvider } from '@vechainfoundation/react-wallet-kit'; import { ChakraProvider } from '@chakra-ui/react'; import { NavBar, StyledContainer } from './Components/layout'; import { Homepage } from './Screens/Homepage'; diff --git a/apps/sample-react-app/src/Components/AccountDetailBody.tsx b/apps/sample-react-app/src/Components/AccountDetailBody.tsx index b97b5708..bd761de8 100644 --- a/apps/sample-react-app/src/Components/AccountDetailBody.tsx +++ b/apps/sample-react-app/src/Components/AccountDetailBody.tsx @@ -1,6 +1,6 @@ import { Button, HStack, Image, Text, VStack } from '@chakra-ui/react'; import React, { useMemo } from 'react'; -import type { WalletSource } from '@vechain/wallet-kit'; +import type { WalletSource } from '@vechainfoundation/wallet-kit'; import { WalletSources } from '../Constants'; import { AddressButton } from './AddressButton'; diff --git a/apps/sample-react-app/src/Components/AccountDetailModal.tsx b/apps/sample-react-app/src/Components/AccountDetailModal.tsx index 91a7bc27..1055c61e 100644 --- a/apps/sample-react-app/src/Components/AccountDetailModal.tsx +++ b/apps/sample-react-app/src/Components/AccountDetailModal.tsx @@ -1,6 +1,6 @@ import { HStack, Text } from '@chakra-ui/react'; -import type { WalletSource } from '@vechain/wallet-kit'; -import { useWallet } from '@vechain/react-wallet-kit'; +import type { WalletSource } from '@vechainfoundation/wallet-kit'; +import { useWallet } from '@vechainfoundation/react-wallet-kit'; import React, { useCallback } from 'react'; import { getPicassoImgSrc } from '../Utils/AccountUtils'; import { Dialog } from './shared'; diff --git a/apps/sample-react-app/src/Components/SwitchWalletButton.tsx b/apps/sample-react-app/src/Components/SwitchWalletButton.tsx index ea0a034f..39bd163e 100644 --- a/apps/sample-react-app/src/Components/SwitchWalletButton.tsx +++ b/apps/sample-react-app/src/Components/SwitchWalletButton.tsx @@ -1,7 +1,10 @@ import type { HTMLChakraProps } from '@chakra-ui/react'; import { useDisclosure } from '@chakra-ui/react'; import React from 'react'; -import { ConnectWalletButton, useWallet } from '@vechain/react-wallet-kit'; +import { + ConnectWalletButton, + useWallet, +} from '@vechainfoundation/react-wallet-kit'; import { AccountDetailModal } from './AccountDetailModal'; import { AddressButton } from './AddressButton'; diff --git a/apps/sample-react-app/src/Components/layout/NavBar.tsx b/apps/sample-react-app/src/Components/layout/NavBar.tsx index 432bf320..ef178b5d 100644 --- a/apps/sample-react-app/src/Components/layout/NavBar.tsx +++ b/apps/sample-react-app/src/Components/layout/NavBar.tsx @@ -17,7 +17,7 @@ import { import type { JSX } from 'react'; import React from 'react'; import { Bars3Icon } from '@heroicons/react/24/solid'; -import { useWallet } from '@vechain/react-wallet-kit'; +import { useWallet } from '@vechainfoundation/react-wallet-kit'; import { AccountDetailBody } from '../AccountDetailBody'; import { SwitchWalletButton } from '../SwitchWalletButton'; diff --git a/apps/sample-react-app/src/Constants/Constants.ts b/apps/sample-react-app/src/Constants/Constants.ts index 601e2a47..ec293611 100644 --- a/apps/sample-react-app/src/Constants/Constants.ts +++ b/apps/sample-react-app/src/Constants/Constants.ts @@ -1,4 +1,4 @@ -import type { WalletSource } from '@vechain/wallet-kit'; +import type { WalletSource } from '@vechainfoundation/wallet-kit'; export const NODE_URL = 'https://testnet.vechain.org/'; export const NODE_NETWORK = 'test'; diff --git a/apps/sample-react-app/src/Hooks/useCounter.ts b/apps/sample-react-app/src/Hooks/useCounter.ts index f4f8708b..6a9cec50 100644 --- a/apps/sample-react-app/src/Hooks/useCounter.ts +++ b/apps/sample-react-app/src/Hooks/useCounter.ts @@ -1,5 +1,5 @@ import { useCallback, useEffect, useMemo, useState } from 'react'; -import { useConnex } from '@vechain/react-wallet-kit'; +import { useConnex } from '@vechainfoundation/react-wallet-kit'; import type { abi } from 'thor-devkit'; const _counter: abi.Function.Definition = { diff --git a/apps/sample-react-app/src/Logos/Logo.tsx b/apps/sample-react-app/src/Logos/Logo.tsx index 9304e678..16ff5eb5 100644 --- a/apps/sample-react-app/src/Logos/Logo.tsx +++ b/apps/sample-react-app/src/Logos/Logo.tsx @@ -1,7 +1,7 @@ import type { HTMLChakraProps } from '@chakra-ui/react'; import { Image } from '@chakra-ui/react'; import React from 'react'; -import { VeWorldLogo as VWLogo } from '@vechain/vanilla-wallet-kit'; +import { VeWorldLogo as VWLogo } from '@vechainfoundation/vanilla-wallet-kit'; type IIMage = HTMLChakraProps<'img'>; diff --git a/apps/sample-react-app/src/Screens/components/Counter.tsx b/apps/sample-react-app/src/Screens/components/Counter.tsx index adc696fd..0d40fdf3 100644 --- a/apps/sample-react-app/src/Screens/components/Counter.tsx +++ b/apps/sample-react-app/src/Screens/components/Counter.tsx @@ -12,7 +12,7 @@ import { import type { JSX } from 'react'; import React, { useCallback, useMemo } from 'react'; import { ArrowUpIcon } from '@heroicons/react/24/solid'; -import { useWallet } from '@vechain/react-wallet-kit'; +import { useWallet } from '@vechainfoundation/react-wallet-kit'; import { StyledCard } from '../../Components/shared'; import { useCounter } from '../../Hooks/useCounter'; import { AddressButton } from '../../Components'; diff --git a/apps/sample-vanilla-app/index.js b/apps/sample-vanilla-app/index.js index f7071248..903e15db 100644 --- a/apps/sample-vanilla-app/index.js +++ b/apps/sample-vanilla-app/index.js @@ -1,6 +1,6 @@ // eslint-disable-next-line eslint-comments/disable-enable-pair /* eslint-disable no-undef */ -import { configureThorModal } from '@vechain/vanilla-wallet-kit'; +import { configureThorModal } from '@vechainfoundation/vanilla-wallet-kit'; const walletConnectOptions = { projectId: 'a0b855ceaf109dbc8426479a4c3d38d8', diff --git a/apps/sample-vanilla-app/package.json b/apps/sample-vanilla-app/package.json index 450c30aa..78ac02e2 100644 --- a/apps/sample-vanilla-app/package.json +++ b/apps/sample-vanilla-app/package.json @@ -13,7 +13,7 @@ "test": "echo \"Error: no test specified\" && exit 1" }, "dependencies": { - "@vechain/vanilla-wallet-kit": "*" + "@vechainfoundation/vanilla-wallet-kit": "*" }, "devDependencies": { "parcel": "^2.10.2" diff --git a/apps/sample-vue-app/package.json b/apps/sample-vue-app/package.json index a08417c0..cf47339b 100644 --- a/apps/sample-vue-app/package.json +++ b/apps/sample-vue-app/package.json @@ -31,8 +31,8 @@ "root": true }, "dependencies": { - "@vechain/vanilla-wallet-kit": "*", - "@vechain/wallet-kit": "*", + "@vechainfoundation/vanilla-wallet-kit": "*", + "@vechainfoundation/wallet-kit": "*", "core-js": "^3.8.3", "node-polyfill-webpack-plugin": "^2.0.1", "vue": "^3.2.13", diff --git a/apps/sample-vue-app/src/connex/ConnexProvider.vue b/apps/sample-vue-app/src/connex/ConnexProvider.vue index 08590563..e5cae1fc 100644 --- a/apps/sample-vue-app/src/connex/ConnexProvider.vue +++ b/apps/sample-vue-app/src/connex/ConnexProvider.vue @@ -4,7 +4,7 @@ import { ConnectResponse, MultiWalletConnex, WalletSource, -} from '@vechain/wallet-kit'; +} from '@vechainfoundation/wallet-kit'; import type Connex from '@vechain/connex'; import { ConnexSymbol, @@ -12,8 +12,8 @@ import { WalletStateSymbol, } from '@/connex/keys'; import { WalletActions, WalletState } from '@/connex/types'; -import { WalletConnectOptions } from '@vechain/wallet-connect'; -import { configureThorModal } from '@vechain/vanilla-wallet-kit'; +import { WalletConnectOptions } from '@vechainfoundation/wallet-connect'; +import { configureThorModal } from '@vechainfoundation/vanilla-wallet-kit'; const initWallets = (hasWcOptions: boolean) => { const wallets: WalletSource[] = ['sync2']; diff --git a/apps/sample-vue-app/src/connex/types.d.ts b/apps/sample-vue-app/src/connex/types.d.ts index bfad5e71..f25581dd 100644 --- a/apps/sample-vue-app/src/connex/types.d.ts +++ b/apps/sample-vue-app/src/connex/types.d.ts @@ -1,4 +1,4 @@ -import { ConnectResponse, WalletSource } from '@vechain/wallet-kit'; +import { ConnectResponse, WalletSource } from '@vechainfoundation/wallet-kit'; type WalletState = { availableWallets: WalletSource[]; diff --git a/apps/sample-vue-app/src/main.ts b/apps/sample-vue-app/src/main.ts index a9434a40..1c2a07e5 100644 --- a/apps/sample-vue-app/src/main.ts +++ b/apps/sample-vue-app/src/main.ts @@ -1,5 +1,5 @@ import { createApp } from 'vue'; import App from './App.vue'; -import '@vechain/vanilla-wallet-kit'; +import '@vechainfoundation/vanilla-wallet-kit'; createApp(App).mount('#app'); diff --git a/package.json b/package.json index db9e140d..4831797f 100755 --- a/package.json +++ b/package.json @@ -6,8 +6,8 @@ ], "scripts": { "build": "turbo run build", - "build-react-kit": "turbo run build --filter='@vechain/react-wallet-kit'", - "build:deps": "turbo build --no-daemon --filter='@vechain/*'", + "build-react-kit": "turbo run build --filter='@vechainfoundation/react-wallet-kit'", + "build:deps": "turbo build --no-daemon --filter='@vechainfoundation/*'", "clean": "rm -rf .turbo .parcel-cache build && npx turbo@latest run clean", "cucumber": "yarn && cucumber-js", "dev": "turbo run dev --no-daemon", diff --git a/packages/react-wallet-kit/package.json b/packages/react-wallet-kit/package.json index 5da1b5f8..838931db 100644 --- a/packages/react-wallet-kit/package.json +++ b/packages/react-wallet-kit/package.json @@ -19,9 +19,9 @@ "@vechain/connex": "2.1.0", "@vechain/connex-framework": "2.1.0", "@vechain/picasso": "^2.1.1", - "@vechain/vanilla-wallet-kit": "*", - "@vechain/wallet-connect": "*", - "@vechain/wallet-kit": "*", + "@vechainfoundation/vanilla-wallet-kit": "*", + "@vechainfoundation/wallet-connect": "*", + "@vechainfoundation/wallet-kit": "*", "thor-devkit": "^2.0.9" }, "devDependencies": { diff --git a/packages/react-wallet-kit/src/ConnectWalletButton/Components/WalletSourceRadio.tsx b/packages/react-wallet-kit/src/ConnectWalletButton/Components/WalletSourceRadio.tsx index 00e8e625..e2dd5053 100644 --- a/packages/react-wallet-kit/src/ConnectWalletButton/Components/WalletSourceRadio.tsx +++ b/packages/react-wallet-kit/src/ConnectWalletButton/Components/WalletSourceRadio.tsx @@ -1,6 +1,6 @@ import { HStack, Image, Text, VStack } from '@chakra-ui/react'; import React, { useCallback } from 'react'; -import type { WalletSource } from '@vechain/wallet-kit'; +import type { WalletSource } from '@vechainfoundation/wallet-kit'; import { useWallet } from '../../ConnexProvider'; import { WalletSources } from '../Constants'; import { RadioCard } from './RadioCard'; diff --git a/packages/react-wallet-kit/src/ConnectWalletButton/Constants/Constants.ts b/packages/react-wallet-kit/src/ConnectWalletButton/Constants/Constants.ts index 0e4729db..6c4fa820 100644 --- a/packages/react-wallet-kit/src/ConnectWalletButton/Constants/Constants.ts +++ b/packages/react-wallet-kit/src/ConnectWalletButton/Constants/Constants.ts @@ -1,10 +1,10 @@ -import type { WalletSource } from '@vechain/wallet-kit'; +import type { WalletSource } from '@vechainfoundation/wallet-kit'; import { Sync2Logo, SyncLogo, VeWorldLogo, WalletConnectLogo, -} from '@vechain/vanilla-wallet-kit'; +} from '@vechainfoundation/vanilla-wallet-kit'; interface SourceInfo { name: string; diff --git a/packages/react-wallet-kit/src/ConnexProvider.tsx b/packages/react-wallet-kit/src/ConnexProvider.tsx index 03b6edcd..d700b26b 100644 --- a/packages/react-wallet-kit/src/ConnexProvider.tsx +++ b/packages/react-wallet-kit/src/ConnexProvider.tsx @@ -6,11 +6,11 @@ import React, { useMemo, useState, } from 'react'; -import type { WalletSource } from '@vechain/wallet-kit'; -import { MultiWalletConnex } from '@vechain/wallet-kit'; +import type { WalletSource } from '@vechainfoundation/wallet-kit'; +import { MultiWalletConnex } from '@vechainfoundation/wallet-kit'; import type { ConnexContext, ConnexProviderOptions } from './types'; -const STORAGE_PREFIX = '@vechain/wallet-kit'; +const STORAGE_PREFIX = '@vechainfoundation/wallet-kit'; const persist = (key: 'source' | 'account', value: string): void => { localStorage.setItem(`${STORAGE_PREFIX}${key}`, value); }; diff --git a/packages/react-wallet-kit/src/types.ts b/packages/react-wallet-kit/src/types.ts index 4fe591b3..319cf6ec 100644 --- a/packages/react-wallet-kit/src/types.ts +++ b/packages/react-wallet-kit/src/types.ts @@ -1,7 +1,10 @@ import type { Options } from '@vechain/connex'; import type React from 'react'; -import type { WalletConnectOptions } from '@vechain/wallet-connect'; -import type { ConnectResponse, WalletSource } from '@vechain/wallet-kit'; +import type { WalletConnectOptions } from '@vechainfoundation/wallet-connect'; +import type { + ConnectResponse, + WalletSource, +} from '@vechainfoundation/wallet-kit'; export interface AccountState { address: string | null; diff --git a/packages/vanilla-wallet-kit/package.json b/packages/vanilla-wallet-kit/package.json index 9500fb50..c766b07e 100644 --- a/packages/vanilla-wallet-kit/package.json +++ b/packages/vanilla-wallet-kit/package.json @@ -24,7 +24,7 @@ "watch": "tsup --watch" }, "dependencies": { - "@vechain/wallet-kit": "*", + "@vechainfoundation/wallet-kit": "*", "@wagmi/core": "^1.4.5", "@web3modal/ethereum": "^2.7.1", "@web3modal/html": "^2.7.1", diff --git a/packages/vanilla-wallet-kit/src/client.ts b/packages/vanilla-wallet-kit/src/client.ts index a3deaa94..1dd14090 100644 --- a/packages/vanilla-wallet-kit/src/client.ts +++ b/packages/vanilla-wallet-kit/src/client.ts @@ -1,6 +1,6 @@ -import type { WalletSource } from '@vechain/wallet-kit'; -import { MultiWalletConnex } from '@vechain/wallet-kit'; -import type { ConnexOptions } from '@vechain/wallet-kit/src'; +import type { WalletSource } from '@vechainfoundation/wallet-kit'; +import { MultiWalletConnex } from '@vechainfoundation/wallet-kit'; +import type { ConnexOptions } from '@vechainfoundation/wallet-kit/src'; import type { SourceInfo } from './constants'; import './components'; diff --git a/packages/vanilla-wallet-kit/src/components/base/vwk-base-modal/index.ts b/packages/vanilla-wallet-kit/src/components/base/vwk-base-modal/index.ts index 72712b62..f5916c95 100644 --- a/packages/vanilla-wallet-kit/src/components/base/vwk-base-modal/index.ts +++ b/packages/vanilla-wallet-kit/src/components/base/vwk-base-modal/index.ts @@ -1,7 +1,7 @@ import type { TemplateResult } from 'lit'; import { css, html, LitElement } from 'lit'; import { customElement, property } from 'lit/decorators.js'; -import { Theme, ThemeMode } from '@vechain/wallet-kit'; +import { Theme, ThemeMode } from '@vechainfoundation/wallet-kit'; import { Colors } from '../../../constants'; @customElement('vwk-base-modal') diff --git a/packages/vanilla-wallet-kit/src/components/vwk-connect-button-with-modal/index.ts b/packages/vanilla-wallet-kit/src/components/vwk-connect-button-with-modal/index.ts index 0367155d..de921064 100644 --- a/packages/vanilla-wallet-kit/src/components/vwk-connect-button-with-modal/index.ts +++ b/packages/vanilla-wallet-kit/src/components/vwk-connect-button-with-modal/index.ts @@ -1,7 +1,7 @@ import type { TemplateResult } from 'lit'; import { html, LitElement } from 'lit'; import { customElement, property } from 'lit/decorators.js'; -import { Theme, ThemeMode } from '@vechain/wallet-kit'; +import { Theme, ThemeMode } from '@vechainfoundation/wallet-kit'; @customElement('vwk-connect-button-with-modal') export class ConnectButtonWithModal extends LitElement { diff --git a/packages/vanilla-wallet-kit/src/components/vwk-connect-button/index.ts b/packages/vanilla-wallet-kit/src/components/vwk-connect-button/index.ts index 7a4bea13..4173035e 100644 --- a/packages/vanilla-wallet-kit/src/components/vwk-connect-button/index.ts +++ b/packages/vanilla-wallet-kit/src/components/vwk-connect-button/index.ts @@ -1,7 +1,7 @@ import type { TemplateResult } from 'lit'; import { css, html, LitElement } from 'lit'; import { customElement, property } from 'lit/decorators.js'; -import { Theme, ThemeMode } from '@vechain/wallet-kit'; +import { Theme, ThemeMode } from '@vechainfoundation/wallet-kit'; import { Colors } from '../../constants'; @customElement('vwk-connect-button') diff --git a/packages/vanilla-wallet-kit/src/components/vwk-connect-modal/index.ts b/packages/vanilla-wallet-kit/src/components/vwk-connect-modal/index.ts index 8a5b5c3a..c68ba001 100644 --- a/packages/vanilla-wallet-kit/src/components/vwk-connect-modal/index.ts +++ b/packages/vanilla-wallet-kit/src/components/vwk-connect-modal/index.ts @@ -1,7 +1,7 @@ import type { TemplateResult } from 'lit'; import { css, html, LitElement, nothing } from 'lit'; import { customElement, property } from 'lit/decorators.js'; -import { Theme, ThemeMode } from '@vechain/wallet-kit'; +import { Theme, ThemeMode } from '@vechainfoundation/wallet-kit'; import { DarkCloseSvg, LightCloseSvg } from '../../assets'; import type { SourceInfo } from '../../constants'; import { WalletSources } from '../../constants'; diff --git a/packages/vanilla-wallet-kit/src/components/vwk-source-card/index.ts b/packages/vanilla-wallet-kit/src/components/vwk-source-card/index.ts index a5cf923b..4b962c7b 100644 --- a/packages/vanilla-wallet-kit/src/components/vwk-source-card/index.ts +++ b/packages/vanilla-wallet-kit/src/components/vwk-source-card/index.ts @@ -1,7 +1,7 @@ import type { TemplateResult } from 'lit'; import { css, html, LitElement } from 'lit'; import { customElement, property } from 'lit/decorators.js'; -import { Theme, ThemeMode } from '@vechain/wallet-kit'; +import { Theme, ThemeMode } from '@vechainfoundation/wallet-kit'; import type { SourceInfo } from '../../constants'; import { Colors } from '../../constants'; diff --git a/packages/wallet-kit/README.md b/packages/wallet-kit/README.md index 6571e2db..95524b54 100644 --- a/packages/wallet-kit/README.md +++ b/packages/wallet-kit/README.md @@ -35,7 +35,7 @@ const onDisconnected = () => { - Optional: Configure wallet connect options ```typescript -import type { WalletConnectOptions } from '@vechain/wallet-connect'; +import type { WalletConnectOptions } from '@vechainfoundation/wallet-connect'; const walletConnectOptions: WalletConnectOptions = { projectId: '', // Create your project here: https://cloud.walletconnect.com/sign-up diff --git a/packages/wallet-kit/package.json b/packages/wallet-kit/package.json index 594834f7..358f06e5 100644 --- a/packages/wallet-kit/package.json +++ b/packages/wallet-kit/package.json @@ -15,7 +15,7 @@ "@vechain/connex": "2.1.0", "@vechain/connex-driver": "2.1.0", "@vechain/connex-framework": "2.1.0", - "@vechain/wallet-connect": "*", + "@vechainfoundation/wallet-connect": "*", "events": "^3.3.0", "thor-devkit": "^2.0.9" }, diff --git a/packages/wallet-kit/src/create-wallet.ts b/packages/wallet-kit/src/create-wallet.ts index 7d1901d5..f3a09a65 100644 --- a/packages/wallet-kit/src/create-wallet.ts +++ b/packages/wallet-kit/src/create-wallet.ts @@ -2,7 +2,7 @@ import { newWcClient, newWcSigner, newWeb3Modal, -} from '@vechain/wallet-connect/dist'; +} from '@vechainfoundation/wallet-connect/dist'; import { createSync, createSync2 } from '@vechain/connex/esm/signer'; import type { ConnexOptions, ConnexWallet, WalletSource } from './types'; import { CertificateBasedWallet } from './wallets/certificate-wallet'; diff --git a/packages/wallet-kit/src/types.d.ts b/packages/wallet-kit/src/types.d.ts index a4a1c20b..e4970009 100644 --- a/packages/wallet-kit/src/types.d.ts +++ b/packages/wallet-kit/src/types.d.ts @@ -1,5 +1,5 @@ import type { Connex1 } from '@vechain/connex/esm/signer'; -import type { WalletConnectOptions } from '@vechain/wallet-connect'; +import type { WalletConnectOptions } from '@vechainfoundation/wallet-connect'; declare global { interface Window { diff --git a/packages/wallet-kit/src/wallets/wc-wallet.ts b/packages/wallet-kit/src/wallets/wc-wallet.ts index 9e4f728a..0524eee0 100644 --- a/packages/wallet-kit/src/wallets/wc-wallet.ts +++ b/packages/wallet-kit/src/wallets/wc-wallet.ts @@ -1,4 +1,4 @@ -import type { WCSigner } from '@vechain/wallet-connect'; +import type { WCSigner } from '@vechainfoundation/wallet-connect'; import type { ConnectResponse, ConnexWallet } from '../types'; class WCWallet implements ConnexWallet { From d3d47c59cb469186009831085928c4bb6d579537 Mon Sep 17 00:00:00 2001 From: Darren Kelly Date: Wed, 8 Nov 2023 11:19:55 +0000 Subject: [PATCH 3/8] fix: change node to 18 --- .github/workflows/publish-wallet-kit.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/publish-wallet-kit.yaml b/.github/workflows/publish-wallet-kit.yaml index dc34c83b..808b484d 100644 --- a/.github/workflows/publish-wallet-kit.yaml +++ b/.github/workflows/publish-wallet-kit.yaml @@ -22,7 +22,7 @@ jobs: - uses: actions/checkout@v3 - uses: actions/setup-node@v3 with: - node-version: 16 + node-version: 18 registry-url: https://npm.pkg.github.com/ - run: yarn install:all - run: yarn build From 2bd73b40a63b240f5f6acac186fb4acb4b0064b2 Mon Sep 17 00:00:00 2001 From: Darren Kelly Date: Wed, 8 Nov 2023 11:24:50 +0000 Subject: [PATCH 4/8] fix: change package to 'private: false' --- packages/react-wallet-kit/package.json | 2 +- packages/vanilla-wallet-kit/package.json | 2 +- packages/wallet-connect/package.json | 2 +- packages/wallet-kit/package.json | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/react-wallet-kit/package.json b/packages/react-wallet-kit/package.json index 838931db..246a7d8a 100644 --- a/packages/react-wallet-kit/package.json +++ b/packages/react-wallet-kit/package.json @@ -1,7 +1,7 @@ { "name": "@vechainfoundation/react-wallet-kit", "version": "0.0.0", - "private": true, + "private": false, "license": "MIT", "sideEffects": false, "main": "./dist/index.js", diff --git a/packages/vanilla-wallet-kit/package.json b/packages/vanilla-wallet-kit/package.json index c766b07e..d71d9a1c 100644 --- a/packages/vanilla-wallet-kit/package.json +++ b/packages/vanilla-wallet-kit/package.json @@ -1,7 +1,7 @@ { "name": "@vechainfoundation/vanilla-wallet-kit", "version": "0.0.0", - "private": true, + "private": false, "description": "Vanilla js wallet kit", "keywords": [ "web-components", diff --git a/packages/wallet-connect/package.json b/packages/wallet-connect/package.json index 84f4077f..91a44dcb 100644 --- a/packages/wallet-connect/package.json +++ b/packages/wallet-connect/package.json @@ -1,7 +1,7 @@ { "name": "@vechainfoundation/wallet-connect", "version": "0.0.0", - "private": true, + "private": false, "license": "MIT", "main": "./dist/index.js", "types": "./dist/index.d.ts", diff --git a/packages/wallet-kit/package.json b/packages/wallet-kit/package.json index 358f06e5..a1ee622d 100644 --- a/packages/wallet-kit/package.json +++ b/packages/wallet-kit/package.json @@ -1,7 +1,7 @@ { "name": "@vechainfoundation/wallet-kit", "version": "0.0.0", - "private": true, + "private": false, "main": "./dist/index.js", "types": "./dist/index.d.ts", "scripts": { From fa6b0854ab0df66b154897e2f5b0e16f37658e58 Mon Sep 17 00:00:00 2001 From: Darren Kelly Date: Wed, 8 Nov 2023 11:45:46 +0000 Subject: [PATCH 5/8] chore: document react --- packages/react-wallet-kit/README.md | 93 ++++++++++++++++++++++++++++- packages/wallet-kit/README.md | 26 ++++---- 2 files changed, 102 insertions(+), 17 deletions(-) diff --git a/packages/react-wallet-kit/README.md b/packages/react-wallet-kit/README.md index 282d241a..ad6a09ca 100644 --- a/packages/react-wallet-kit/README.md +++ b/packages/react-wallet-kit/README.md @@ -1 +1,92 @@ -# React Vendor +# `@vechainfoundation/react-wallet-kit` + +## 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. +- Create your own + +## Installation + +- See the parent [README](../../README.md) for installation instructions. + +### Build + +```bash +yarn build +``` + +## Usage + +```bash +yarn add @vechainfoundation/react-wallet-kit +``` + +- Create the node options + +```typescript +import type { Options } from '@vechain/connex'; + +const nodeOptions: Omit = { + node: 'https://testnet.vechain.org/', + network: 'test', +}; +``` + +- Optional: Configure wallet connect options + +```typescript +import type { WalletConnectOptions } from '@vechainfoundation/wallet-connect'; + +const walletConnectOptions: WalletConnectOptions = { + projectId: '', // Create your project here: https://cloud.walletconnect.com/sign-up + metadata: { + name: 'My dApp', + description: 'My dApp description', + url: window.location.origin, // Your app URL + icons: [`${window.location.origin}/images/my-dapp-icon.png`], // Your app Icon + }, +}; +``` + +- Initialise the `ConnexVendor` + +```typescript jsx +import { ConnexProvider } from '@vechainfoundation/react-wallet-kit'; + +export const App = (): JSX.Element => { + return ( + <> + + + + + ); +}; +``` + +- Use the + +```typescript jsx +import { useWallet, useConnex } from '@vechainfoundation/react-wallet-kit'; +import type { WalletSource } from '@vechainfoundation/wallet-kit'; + +// type WalletSource = 'wallet-connect' | 'veworld-extension' | 'sync2' | 'sync'; +const mySource: WalletSource = 'veworld-extension'; + +const { connect, setSource } = useWallet(); + +setSource(mySource); + +const { account } = await connect(); + +//Start using Connex thor/ vendor +const { vendor, thor } = useConnex(); +``` diff --git a/packages/wallet-kit/README.md b/packages/wallet-kit/README.md index 95524b54..6a532c67 100644 --- a/packages/wallet-kit/README.md +++ b/packages/wallet-kit/README.md @@ -1,4 +1,4 @@ -# `@vecahin/dapp-kit` +# `@vechainfoundation/wallet-kit` ## Why ? @@ -21,15 +21,7 @@ yarn build ## Usage ```bash -yarn add @vechain/dapp-kit -``` - -- Create a function to handle remote wallet disconnections. Some wallets can disconnect remotely (eg. Wallet Connect) - -```typescript -const onDisconnected = () => { - //TODO: handle disconnect -}; +yarn add @vechainfoundation/wallet-kit ``` - Optional: Configure wallet connect options @@ -56,8 +48,7 @@ const walletConnectOptions: WalletConnectOptions = { const { thor, vendor, wallet } = new MultiWalletConnex({ nodeUrl: 'https://sync-testnet.vechain.org/', //Required genesis: 'main', //Optional - "main" | "test" | Connex.Thor.Block - walletConnectOptions, - onDisconnected, + walletConnectOptions, //Optional }); ``` @@ -65,6 +56,11 @@ const { thor, vendor, wallet } = new MultiWalletConnex({ - Connex is ready to use as normal ```typescript +import type { WalletSource } from '@vechainfoundation/wallet-kit'; + +// type WalletSource = 'wallet-connect' | 'veworld-extension' | 'sync2' | 'sync'; +const mySource: WalletSource = 'veworld-extension'; + wallet.setSource('veworld-extension'); ``` @@ -73,10 +69,8 @@ wallet.setSource('veworld-extension'); verified, you should request a subsequent certificate sign in ```typescript -const { account, verified } = await wallet.connect(); -``` +const {account, verified} = await wallet.connect(); -```typescript -const tx = await thor.account("0x...123").method(...).transact().request(); +const tx = await thor.account("0x...123").method(...).transact().signer(account).request(); const certRes = await vendor.sign("cert", {...}).requset(); ``` From 647ea74a8ef531c71306549ca6c96b317ca9f71a Mon Sep 17 00:00:00 2001 From: Darren Kelly Date: Wed, 8 Nov 2023 11:46:25 +0000 Subject: [PATCH 6/8] chore: update GH actions --- .github/workflows/publish-wallet-kit.yaml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/publish-wallet-kit.yaml b/.github/workflows/publish-wallet-kit.yaml index 808b484d..257fc4bb 100644 --- a/.github/workflows/publish-wallet-kit.yaml +++ b/.github/workflows/publish-wallet-kit.yaml @@ -2,8 +2,8 @@ name: Publish NPM package on: push: - branches: - - test-publishing + tags: + - '*' permissions: contents: read @@ -28,7 +28,7 @@ jobs: - run: yarn build - run: | cd packages/${{ matrix.package }} - yarn version --no-git-tag-version --new-version 0.0.1-beta + yarn version --no-git-tag-version --new-version ${{ github.ref_name }} yarn publish env: NODE_AUTH_TOKEN: ${{secrets.GITHUB_TOKEN}} From 5a8452e5a0aa1122a9a6012540fb2d32c67c73bd Mon Sep 17 00:00:00 2001 From: Darren Kelly Date: Wed, 8 Nov 2023 12:05:18 +0000 Subject: [PATCH 7/8] fix: update readme --- packages/react-wallet-kit/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/react-wallet-kit/README.md b/packages/react-wallet-kit/README.md index ad6a09ca..b878b1dd 100644 --- a/packages/react-wallet-kit/README.md +++ b/packages/react-wallet-kit/README.md @@ -72,7 +72,7 @@ export const App = (): JSX.Element => { }; ``` -- Use the +- Use the hooks provided by the `ConnexProvider` ```typescript jsx import { useWallet, useConnex } from '@vechainfoundation/react-wallet-kit'; From becbef60edb5fe12b51369ee99e72859d20c79f3 Mon Sep 17 00:00:00 2001 From: Darren Kelly Date: Wed, 8 Nov 2023 13:58:30 +0000 Subject: [PATCH 8/8] feat: allow interface for custom modal --- apps/sample-vanilla-app/package.json | 2 +- packages/vanilla-wallet-kit/package.json | 2 +- packages/wallet-connect/src/index.ts | 1 + packages/wallet-connect/src/signer.ts | 4 ++-- packages/wallet-connect/src/types.d.ts | 19 +++++++++++++++++-- packages/wallet-connect/src/web3-modal.ts | 13 ++++++++++++- packages/wallet-kit/src/create-wallet.ts | 5 ++++- packages/wallet-kit/src/types.d.ts | 2 ++ 8 files changed, 40 insertions(+), 8 deletions(-) diff --git a/apps/sample-vanilla-app/package.json b/apps/sample-vanilla-app/package.json index 78ac02e2..cec15176 100644 --- a/apps/sample-vanilla-app/package.json +++ b/apps/sample-vanilla-app/package.json @@ -8,7 +8,7 @@ "scripts": { "build": "parcel build index.html --public-url /vechain-dapp-kit/vanilla", "clean": "rm -rf dist", - "dev": "parcel index.html --open", + "dev": "parcel index.html --open --port 3001", "purge": "yarn clean && rm -rf node_modules", "test": "echo \"Error: no test specified\" && exit 1" }, diff --git a/packages/vanilla-wallet-kit/package.json b/packages/vanilla-wallet-kit/package.json index d71d9a1c..6d872dd6 100644 --- a/packages/vanilla-wallet-kit/package.json +++ b/packages/vanilla-wallet-kit/package.json @@ -17,7 +17,7 @@ "scripts": { "build": "tsup", "clean": "rm -rf dist .turbo", - "dev": "parcel index.html --open", + "dev": "parcel index.html --open --port 1234", "format": "prettier \"**/*.{cjs,html,js,json,md,ts}\" --ignore-path ./.eslintignore --write", "lint": "eslint 'src/**/*.ts'", "purge": "yarn clean && rm -rf node_modules", diff --git a/packages/wallet-connect/src/index.ts b/packages/wallet-connect/src/index.ts index 7f010b93..5a8e5ff0 100644 --- a/packages/wallet-connect/src/index.ts +++ b/packages/wallet-connect/src/index.ts @@ -8,6 +8,7 @@ export type { WalletConnectOptions, ResolvedSignClient, WCClient, + WCModal, } from './types'; export { newWcSigner, newWeb3Modal, newWcClient }; diff --git a/packages/wallet-connect/src/signer.ts b/packages/wallet-connect/src/signer.ts index f1c4df77..9a8ea997 100644 --- a/packages/wallet-connect/src/signer.ts +++ b/packages/wallet-connect/src/signer.ts @@ -152,11 +152,11 @@ export const newWcSigner = ({ }); if (uri) { - await web3Modal.openModal({ uri, chains: namespace.chains }); + await web3Modal.openModal({ uri }); } return await new Promise((resolve, reject) => { - web3Modal.subscribeModal((ev: { open: boolean }) => { + web3Modal.subscribeModal((ev) => { if (!ev.open) { reject(new Error('User closed modal')); } diff --git a/packages/wallet-connect/src/types.d.ts b/packages/wallet-connect/src/types.d.ts index c0cb58a4..18bd1218 100644 --- a/packages/wallet-connect/src/types.d.ts +++ b/packages/wallet-connect/src/types.d.ts @@ -1,4 +1,3 @@ -import type { WalletConnectModal } from '@walletconnect/modal'; import type { SignClientTypes } from '@walletconnect/types'; import type { SignClient } from '@walletconnect/sign-client'; @@ -44,6 +43,22 @@ export interface WalletConnectOptions { metadata: SignClientTypes.Options['metadata']; } +interface SubscribeModalState { + open: boolean; +} + +interface OpenOptions { + uri: string; +} + +export interface WCModal { + openModal: (options: OpenOptions) => Promise; + closeModal: () => void; + subscribeModal: ( + callback: (newState: SubscribeModalState) => void, + ) => () => void; +} + /** * Options for the {@link WCSigner} * @param wcClient - A function to get the initialized WalletConnect SignClient @@ -53,7 +68,7 @@ export interface WalletConnectOptions { */ export interface WCSignerOptions { wcClient: WCClient; - web3Modal: WalletConnectModal; + web3Modal: WCModal; onDisconnected?: () => void; genesisId: string; } diff --git a/packages/wallet-connect/src/web3-modal.ts b/packages/wallet-connect/src/web3-modal.ts index 4f9072f9..e364d5e7 100644 --- a/packages/wallet-connect/src/web3-modal.ts +++ b/packages/wallet-connect/src/web3-modal.ts @@ -1,12 +1,22 @@ import { WalletConnectModal } from '@walletconnect/modal'; +import type { WCModal } from './types'; const _cachedModals: Record = {}; +const genesisIds = [ + '0x00000000851caf3cfdb6e899cf5958bfb1ac3413d346d43539627e6be7ec1b4a', + '0x000000000b2bce3c70bc649a02749e8687721b09ed2e15997f466536b20bb127', +]; + +const chains = genesisIds.map((id) => { + return id.slice(-32); +}); + /** * Creates a new WalletConnectModal instance * @param projectId - Your WalletConnect project ID */ -export const newWeb3Modal = (projectId: string): WalletConnectModal => { +export const newWeb3Modal = (projectId: string): WCModal => { const cached = _cachedModals[projectId]; if (cached) { @@ -26,6 +36,7 @@ export const newWeb3Modal = (projectId: string): WalletConnectModal => { }, }, ], + chains, themeVariables: { '--wcm-z-index': '99999999', }, diff --git a/packages/wallet-kit/src/create-wallet.ts b/packages/wallet-kit/src/create-wallet.ts index f3a09a65..a7f9db32 100644 --- a/packages/wallet-kit/src/create-wallet.ts +++ b/packages/wallet-kit/src/create-wallet.ts @@ -19,6 +19,7 @@ export const createWallet = ({ genesis, walletConnectOptions, onDisconnected, + customWcModal, }: ICreateWallet): ConnexWallet => { const genesisId = normalizeGenesisId(genesis); @@ -58,7 +59,9 @@ export const createWallet = ({ metadata, }); - const web3Modal = newWeb3Modal(projectId); + const web3Modal = customWcModal + ? customWcModal + : newWeb3Modal(projectId); const wallet = newWcSigner({ genesisId, diff --git a/packages/wallet-kit/src/types.d.ts b/packages/wallet-kit/src/types.d.ts index e4970009..062bf304 100644 --- a/packages/wallet-kit/src/types.d.ts +++ b/packages/wallet-kit/src/types.d.ts @@ -1,5 +1,6 @@ import type { Connex1 } from '@vechain/connex/esm/signer'; import type { WalletConnectOptions } from '@vechainfoundation/wallet-connect'; +import type { WCModal } from '@vechainfoundation/wallet-connect/src'; declare global { interface Window { @@ -29,6 +30,7 @@ interface ConnexOptions { nodeUrl: string; genesis?: Genesis; walletConnectOptions?: WalletConnectOptions; + customWcModal?: WCModal; } type BaseWallet = Connex.Signer & {