From 90a5bc709833b14b9357e133fc3c6631b8fffe91 Mon Sep 17 00:00:00 2001 From: "Thang X. Vu" Date: Wed, 13 Aug 2025 13:30:22 +0700 Subject: [PATCH 1/5] good migration --- .github/workflows/run-tests.yml | 2 +- .prettierrc.js | 2 +- README.md | 94 +++++++++--------- package.json | 8 +- packages/base/README.md | 4 +- packages/base/package.json | 14 +-- packages/base/src/packageInfo.ts | 2 +- packages/base/src/requests/TabHandler.ts | 4 +- packages/base/src/requests/WalletState.ts | 18 ++-- .../src/requests/__tests__/TabHandler.spec.ts | 18 ++-- .../requests/__tests__/WalletState.spec.ts | 32 +++--- packages/base/src/requests/__tests__/setup.ts | 2 +- packages/base/src/types.ts | 2 +- packages/base/src/utils/messageId.ts | 4 +- packages/keyring/README.md | 4 +- packages/keyring/package.json | 12 +-- packages/keyring/src/Keyring.ts | 52 +++++----- .../keyring/src/__tests__/Keyring.spec.ts | 60 +++++------ packages/keyring/src/packageInfo.ts | 2 +- packages/sdk/README.md | 4 +- packages/sdk/package.json | 14 +-- packages/sdk/src/ConnectedAccounts.ts | 12 +-- .../src/{CoongSdk.ts => DedotSignerSdk.ts} | 46 ++++----- packages/sdk/src/index.ts | 4 +- packages/sdk/src/injection/Accounts.ts | 12 +-- .../{CoongSigner.ts => DedotSigner.ts} | 8 +- packages/sdk/src/injection/Injected.ts | 12 +-- packages/sdk/src/packageInfo.ts | 2 +- packages/sdk/src/types.ts | 4 +- packages/sdk/src/wallet/TabInstance.ts | 8 +- packages/sdk/src/wallet/WalletInstance.ts | 8 +- packages/ui/README.md | 4 +- packages/ui/index.html | 6 +- packages/ui/package.json | 14 +-- packages/ui/public/coong-inverted-logo.svg | 33 ------ .../ui/public/locales/en/translation.json | 22 ++-- packages/ui/public/wallet-info.json | 2 +- packages/ui/src/__tests__/testUtils.tsx | 4 +- packages/ui/src/assets/images/coong-logo.svg | 21 ---- .../ui/src/assets/images/coong-text-logo.svg | 31 ------ .../images/{coong-logo.png => dedot-logo.png} | Bin .../assets/images/dedot-logo.svg} | 0 .../assets/images/dedot-text-logo.svg} | 0 .../ui/src/components/layouts/MainFooter.tsx | 6 +- .../ui/src/components/layouts/MainHeader.tsx | 4 +- .../pages/Accounts/AccountAddress.tsx | 2 +- .../DappAccessToAccountItem.tsx | 2 +- .../DappsAccessToAccountDialog/index.tsx | 2 +- .../AccountControls/ExportAccountDialog.tsx | 2 +- .../__test__/AccountControls.spec.tsx | 12 +-- .../Accounts/__tests__/Accounts.spec.tsx | 4 +- .../__tests__/RequestAccess.spec.tsx | 8 +- .../pages/Request/RequestAccess/index.tsx | 4 +- .../pages/Request/RequestContent.tsx | 4 +- .../__tests__/RequestSigning.spec.tsx | 8 +- .../hooks/useRawMessageDetails.ts | 2 +- .../RequestSigning/hooks/useTargetAccount.ts | 2 +- .../hooks/useTransactionDetails.ts | 2 +- .../pages/Request/UpdateAccess/index.tsx | 2 +- .../pages/Request/__tests__/Request.spec.tsx | 2 +- .../ui/src/components/pages/Request/index.tsx | 10 +- .../ui/src/components/pages/Request/types.ts | 2 +- .../RestoreWallet/ImportJsonFile.tsx | 2 +- .../RestoreWallet/MethodSelection.tsx | 4 +- .../SetupWallet/RestoreWallet/ScanQrCode.tsx | 2 +- .../__tests__/RestoreWallet.spec.tsx | 2 +- packages/ui/src/components/pages/Welcome.tsx | 6 +- .../pages/__tests__/GuardScreen.spec.tsx | 8 +- .../components/shared/NetworksSelection.tsx | 4 +- .../components/shared/NewAccountButton.tsx | 2 +- .../__tests__/NewAccountButton.spec.tsx | 4 +- .../shared/accounts/SelectableAccountCard.tsx | 2 +- .../shared/buttons/ForgotPasswordButton.tsx | 2 +- .../src/components/shared/export/JsonFile.tsx | 8 +- .../src/components/shared/export/QrCode.tsx | 14 +-- .../components/shared/import/QrCodeReader.tsx | 2 +- .../shared/menu/ExportWalletDialog.tsx | 2 +- .../TransferAccountBackup.tsx | 2 +- .../shared/menu/ImportAccountDialog/index.tsx | 2 +- .../useAccountBackupValidation.ts | 2 +- .../shared/menu/__tests__/MenuButton.spec.tsx | 4 +- .../components/shared/misc/CoongTextLogo.tsx | 14 --- .../BackupSecretPhraseDialog.spec.tsx | 2 +- .../DappAccessDetailsDialog.tsx | 2 +- .../ManageDappAccessDialog/DappAccessItem.tsx | 2 +- .../RemoveDappAccessButton.tsx | 2 +- .../RemoveDappAccessDialog.tsx | 2 +- .../DappAccessDetailsDialog.spec.tsx | 2 +- .../__tests__/ManageDappAccessDialog.spec.tsx | 2 +- .../settings/ManageDappAccessDialog/index.tsx | 2 +- packages/ui/src/hooks/accounts/useAccounts.ts | 2 +- .../hooks/accounts/useHighlightNewAccount.ts | 2 +- .../messages/useCurrentRequestMessage.ts | 2 +- .../ui/src/hooks/wallet/useAuthorizedApps.ts | 2 +- .../ui/src/hooks/wallet/useSetupWallet.ts | 4 +- packages/ui/src/packageInfo.ts | 2 +- .../ui/src/providers/WalletStateProvider.tsx | 10 +- packages/ui/src/redux/slices/app.ts | 2 +- packages/ui/src/types.ts | 2 +- packages/ui/src/utils/misc.ts | 2 +- packages/ui/src/walletInfo.ts | 6 +- packages/ui/tsconfig.json | 12 +-- packages/utils/README.md | 4 +- packages/utils/package.json | 10 +- packages/utils/src/__tests__/assert.spec.ts | 18 ++-- packages/utils/src/assert.ts | 6 +- packages/utils/src/errors.ts | 14 +-- packages/utils/src/packageInfo.ts | 2 +- tsconfig.base.json | 16 +-- yarn.lock | 70 ++++++------- 110 files changed, 444 insertions(+), 535 deletions(-) rename packages/sdk/src/{CoongSdk.ts => DedotSignerSdk.ts} (84%) rename packages/sdk/src/injection/{CoongSigner.ts => DedotSigner.ts} (81%) delete mode 100644 packages/ui/public/coong-inverted-logo.svg delete mode 100644 packages/ui/src/assets/images/coong-logo.svg delete mode 100644 packages/ui/src/assets/images/coong-text-logo.svg rename packages/ui/src/assets/images/{coong-logo.png => dedot-logo.png} (100%) rename packages/ui/{public/coong-lined-logo.svg => src/assets/images/dedot-logo.svg} (100%) rename packages/ui/{public/coong-text-logo.svg => src/assets/images/dedot-text-logo.svg} (100%) delete mode 100644 packages/ui/src/components/shared/misc/CoongTextLogo.tsx diff --git a/.github/workflows/run-tests.yml b/.github/workflows/run-tests.yml index af9ce2d0..6e13d17d 100644 --- a/.github/workflows/run-tests.yml +++ b/.github/workflows/run-tests.yml @@ -5,7 +5,7 @@ name: Run tests on: push: - branches: [ "main", "w3f-*", "coong/*" ] + branches: [ "main", "w3f-*", "dedot/*" ] pull_request: branches: [ "main" ] diff --git a/.prettierrc.js b/.prettierrc.js index 8b625ac3..749b6c45 100644 --- a/.prettierrc.js +++ b/.prettierrc.js @@ -6,5 +6,5 @@ module.exports = { printWidth: 120, tabWidth: 2, bracketSameLine: true, - importOrder: ['.*react.*', '^@polkadot/(.*)$', '^@coong/(.*)$', '', '^[./]'], + importOrder: ['.*react.*', '^@polkadot/(.*)$', '^@dedot/(.*)$', '', '^[./]'], }; diff --git a/README.md b/README.md index c6faa997..6ce3ba68 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ > [!NOTE] -> We're in the process of rebranding Coong Wallet to Dedot Signer, information in this repo might be conflicted or confusing. +> We're in the process of rebranding Dedot Signer to Dedot Signer, information in this repo might be conflicted or confusing.

@@ -7,7 +7,7 @@

-Coong Wallet +Dedot Signer

@@ -15,23 +15,23 @@ A website-based multi-chain crypto wallet for -Coong Wallet WebsiteCoong Wallet AppExample Playground Dapp +Example Playground Dapp

- - - + + +

-## What to expect from Coong Wallet? -- No need for extra steps to install browser extensions or mobile apps, Coong Wallet is just a website running on your browser +## What to expect from Dedot Signer? +- No need for extra steps to install browser extensions or mobile apps, Dedot Signer is just a website running on your browser - Works on both desktop and mobile devices -- Compatible with [Polkadot.js extension](https://github.com/polkadot-js/extension) API, [integrate Coong Wallet](#integrate-coong-wallet-into-your-dapps) into your dapp within just a few steps +- Compatible with [Polkadot.js extension](https://github.com/polkadot-js/extension) API, [integrate Dedot Signer](#integrate-dedot-signer-into-your-dapps) into your dapp within just a few steps - One seed phrase to recover all created accounts (excluding imported accounts/private keys) - Private keys and seed phrase are encrypted with a user chosen wallet password @@ -39,12 +39,12 @@ A website-based multi-chain crypto wallet for ", + "description": "A website-based multi-chain wallet & signer for Polkadot", + "author": "Thang X. Vu ", "packageManager": "yarn@3.4.1", "workspaces": [ "packages/*" ], "scripts": { - "start": "yarn workspace @coong/ui start", + "start": "yarn workspace @dedot/signer-ui start", "build": "yarn clean && npx lerna run build", "clean": "npx lerna run clean", "test": "npx lerna run --no-bail --verbose test", diff --git a/packages/base/README.md b/packages/base/README.md index c6692d74..00f6bb75 100644 --- a/packages/base/README.md +++ b/packages/base/README.md @@ -1,3 +1,3 @@ -# @coong/base +# @dedot/signer-base -Shared functions & logic for Coong Wallet +Shared functions & logic for Dedot Signer diff --git a/packages/base/package.json b/packages/base/package.json index 30aaccc5..0d27433b 100644 --- a/packages/base/package.json +++ b/packages/base/package.json @@ -1,13 +1,13 @@ { - "name": "@coong/base", + "name": "@dedot/signer-base", "version": "0.0.23", - "description": "Shared functions, logics for Coong Wallet", - "author": "Thang X. Vu ", - "homepage": "https://github.com/CoongCrafts/coong-wallet/tree/main/packages/base#readme", + "description": "Shared functions, logics for Dedot Signer", + "author": "Thang X. Vu ", + "homepage": "https://github.com/dedotdev/dedot-web-signer/tree/main/packages/base#readme", "repository": { "directory": "packages/base", "type": "git", - "url": "https://github.com/CoongCrafts/coong-wallet.git" + "url": "https://github.com/dedotdev/dedot-web-signer.git" }, "scripts": { "build": "tsc --project tsconfig.build.json", @@ -16,8 +16,8 @@ }, "main": "src/index.ts", "dependencies": { - "@coong/keyring": "^0.0.23", - "@coong/utils": "^0.0.23", + "@dedot/signer-keyring": "^0.0.23", + "@dedot/signer-utils": "^0.0.23", "@polkadot/networks": "^13.5.5", "@polkadot/types": "^16.4.3", "@polkadot/util": "^13.5.5", diff --git a/packages/base/src/packageInfo.ts b/packages/base/src/packageInfo.ts index aade4a97..81209ef8 100644 --- a/packages/base/src/packageInfo.ts +++ b/packages/base/src/packageInfo.ts @@ -1,3 +1,3 @@ // THIS FILE IS AUTO-GENERATED, DO NOT EDIT! -export const packageInfo = { name: '@coong/base', version: '0.0.23' }; +export const packageInfo = { name: '@dedot/signer-base', version: '0.0.23' }; diff --git a/packages/base/src/requests/TabHandler.ts b/packages/base/src/requests/TabHandler.ts index 5da25ca0..3cf454de 100644 --- a/packages/base/src/requests/TabHandler.ts +++ b/packages/base/src/requests/TabHandler.ts @@ -1,5 +1,5 @@ import { SignerPayloadJSON, SignerPayloadRaw } from '@polkadot/types/types'; -import { CoongError, ErrorCode } from '@coong/utils'; +import { DedotSignerError, ErrorCode } from '@dedot/signer-utils'; import { RequestName, WalletRequestMessage, WalletResponse } from '../types'; import Handler from './Handler'; @@ -31,7 +31,7 @@ export default class TabHandler extends Handler { case 'tab/updateAccess': break; default: - throw new CoongError(ErrorCode.UnknownRequest); + throw new DedotSignerError(ErrorCode.UnknownRequest); } return this.state.newRequestMessage(message); diff --git a/packages/base/src/requests/WalletState.ts b/packages/base/src/requests/WalletState.ts index 421ca1c6..cf1fa803 100644 --- a/packages/base/src/requests/WalletState.ts +++ b/packages/base/src/requests/WalletState.ts @@ -4,8 +4,8 @@ import { SignerPayloadJSON, SignerPayloadRaw } from '@polkadot/types/types'; import { u8aToHex, u8aWrapBytes } from '@polkadot/util'; import { encodeAddress } from '@polkadot/util-crypto'; import { KeypairType } from '@polkadot/util-crypto/types'; -import Keyring from '@coong/keyring'; -import { assert, StandardCoongError, trimOffUrlProtocol } from '@coong/utils'; +import Keyring from '@dedot/signer-keyring'; +import { assert, StandardDedotSignerError, trimOffUrlProtocol } from '@dedot/signer-utils'; import { BehaviorSubject } from 'rxjs'; import { defaultNetwork } from '../networks'; import { @@ -223,7 +223,7 @@ export default class WalletState { /** * Get app information by an url * - * @throws {CoongError} if the app information is not found / has not been authorized yet + * @throws {DedotError} if the app information is not found / has not been authorized yet * @param url */ getAuthorizedApp(url: string): AppInfo { @@ -272,11 +272,11 @@ export default class WalletState { getCurrentRequestMessage = (requestName?: RequestName) => { const currentRequestMessage = this.#requestMessageSubject.value; if (!currentRequestMessage) { - throw new StandardCoongError('No request message available'); + throw new StandardDedotSignerError('No request message available'); } if (requestName && currentRequestMessage?.request.name !== requestName) { - throw new StandardCoongError('Invalid request name'); + throw new StandardDedotSignerError('Invalid request name'); } return currentRequestMessage; @@ -310,7 +310,7 @@ export default class WalletState { rejectRequestAccess = () => { const { reject } = this.getCurrentRequestMessage('tab/requestAccess'); - reject(new StandardCoongError(AccessStatus.DENIED)); + reject(new StandardDedotSignerError(AccessStatus.DENIED)); }; async approveUpdateAccess(authorizedAccounts: string[]) { @@ -337,7 +337,7 @@ export default class WalletState { rejectUpdateAccess = () => { const { reject } = this.getCurrentRequestMessage('tab/updateAccess'); - reject(new StandardCoongError(AccessStatus.DENIED)); + reject(new StandardDedotSignerError(AccessStatus.DENIED)); }; async approveSignExtrinsic(password: string) { @@ -368,7 +368,7 @@ export default class WalletState { cancelSignExtrinsic() { const currentMessage = this.getCurrentRequestMessage('tab/signExtrinsic'); - currentMessage.reject(new StandardCoongError('Cancelled')); + currentMessage.reject(new StandardDedotSignerError('Cancelled')); } async signRawMessage(password: string) { @@ -395,7 +395,7 @@ export default class WalletState { cancelSignRawMessage() { const currentMessage = this.getCurrentRequestMessage('tab/signRaw'); - currentMessage.reject(new StandardCoongError('Cancelled')); + currentMessage.reject(new StandardDedotSignerError('Cancelled')); } /** diff --git a/packages/base/src/requests/__tests__/TabHandler.spec.ts b/packages/base/src/requests/__tests__/TabHandler.spec.ts index 0a4a447f..2bb3b61f 100644 --- a/packages/base/src/requests/__tests__/TabHandler.spec.ts +++ b/packages/base/src/requests/__tests__/TabHandler.spec.ts @@ -1,7 +1,7 @@ -import { newWalletRequest } from '@coong/base'; -import { RequestName } from '@coong/base/types'; -import { AccountInfo } from '@coong/keyring/types'; -import { CoongError, ErrorCode, StandardCoongError } from '@coong/utils'; +import { newWalletRequest } from '@dedot/signer-base'; +import { RequestName } from '@dedot/signer-base/types'; +import { AccountInfo } from '@dedot/signer-keyring/types'; +import { DedotSignerError, ErrorCode, StandardDedotSignerError } from '@dedot/signer-utils'; import { beforeEach, describe, expect, it } from 'vitest'; import TabHandler from '../TabHandler'; import { newWalletState, PASSWORD, setupAuthorizedApps } from './setup'; @@ -36,7 +36,7 @@ describe('handle', () => { name: 'tab/unsupportedRequest', }), ), - ).rejects.toThrowError(new CoongError(ErrorCode.UnknownRequest)); + ).rejects.toThrowError(new DedotSignerError(ErrorCode.UnknownRequest)); }); it.each(['tab/signRaw', 'tab/signExtrinsic', 'tab/updateAccess'])( @@ -51,7 +51,9 @@ describe('handle', () => { }), origin: currentWindowOrigin, }), - ).rejects.toThrowError(new StandardCoongError(`The app at ${currentWindowOrigin} has not been authorized yet!`)); + ).rejects.toThrowError( + new StandardDedotSignerError(`The app at ${currentWindowOrigin} has not been authorized yet!`), + ); }, ); @@ -82,7 +84,7 @@ describe('handle', () => { origin: currentWindowOrigin, }), ).rejects.toThrowError( - new StandardCoongError(`The app at ${currentWindowOrigin} has not been authorized to access any accounts!`), + new StandardDedotSignerError(`The app at ${currentWindowOrigin} has not been authorized to access any accounts!`), ); }); @@ -125,7 +127,7 @@ describe('handle', () => { origin: currentWindowOrigin, }), ).rejects.toThrowError( - new StandardCoongError( + new StandardDedotSignerError( `The app at ${currentWindowOrigin} is not authorized to access account with address ${account02.address}!`, ), ); diff --git a/packages/base/src/requests/__tests__/WalletState.spec.ts b/packages/base/src/requests/__tests__/WalletState.spec.ts index 57f54bb3..816511dd 100644 --- a/packages/base/src/requests/__tests__/WalletState.spec.ts +++ b/packages/base/src/requests/__tests__/WalletState.spec.ts @@ -1,7 +1,7 @@ -import { newWalletRequest } from '@coong/base'; -import { AccessStatus, WalletRequestMessage, WalletResponse } from '@coong/base/types'; -import { AccountInfo } from '@coong/keyring/types'; -import { CoongError, ErrorCode, StandardCoongError, trimOffUrlProtocol } from '@coong/utils'; +import { newWalletRequest } from '@dedot/signer-base'; +import { AccessStatus, WalletRequestMessage, WalletResponse } from '@dedot/signer-base/types'; +import { AccountInfo } from '@dedot/signer-keyring/types'; +import { DedotSignerError, ErrorCode, StandardDedotSignerError, trimOffUrlProtocol } from '@dedot/signer-utils'; import { beforeEach, describe, expect, it, vi } from 'vitest'; import WalletState, { AppInfo, AUTHORIZED_ACCOUNTS_KEY, AuthorizedApps } from '../WalletState'; import { newWalletState, PASSWORD, pick, RANDOM_APP_URL, setupAuthorizedApps } from './setup'; @@ -46,7 +46,7 @@ describe('extractAppId', () => { describe('getAuthorizedApp', () => { it('should throw error if app has not been authorized', async () => { expect(() => state.getAuthorizedApp(RANDOM_APP_URL)).toThrowError( - new StandardCoongError(`The app at ${RANDOM_APP_URL} has not been authorized yet!`), + new StandardDedotSignerError(`The app at ${RANDOM_APP_URL} has not been authorized yet!`), ); }); @@ -128,7 +128,7 @@ describe('removeAuthorizedApp', () => { state.removeAuthorizedApp(state.extractAppId(RANDOM_APP_URL)); expect(() => state.getAuthorizedApp(RANDOM_APP_URL)).toThrowError( - new StandardCoongError(`The app at ${RANDOM_APP_URL} has not been authorized yet!`), + new StandardDedotSignerError(`The app at ${RANDOM_APP_URL} has not been authorized yet!`), ); expect(localStorage.getItem(AUTHORIZED_ACCOUNTS_KEY)).toEqual('{}'); }); @@ -208,7 +208,7 @@ describe('injectedAccounts', () => { describe('ensureAccountAuthorized', () => { it('should throw error if application is not authorized', async () => { expect(() => state.ensureAccountAuthorized(RANDOM_APP_URL, account01.address)).toThrowError( - new StandardCoongError(`The app at ${RANDOM_APP_URL} has not been authorized yet!`), + new StandardDedotSignerError(`The app at ${RANDOM_APP_URL} has not been authorized yet!`), ); }); @@ -216,7 +216,7 @@ describe('ensureAccountAuthorized', () => { const { randomAppUrl } = setupAuthorizedApps(state); expect(() => state.ensureAccountAuthorized(randomAppUrl, account01.address)).toThrowError( - new StandardCoongError( + new StandardDedotSignerError( `The app at ${randomAppUrl} is not authorized to access account with address ${account01.address}!`, ), ); @@ -231,7 +231,9 @@ describe('ensureAccountAuthorized', () => { describe('getCurrentRequestMessage', () => { it("should throw error if there's no current message", async () => { - expect(() => state.getCurrentRequestMessage()).toThrowError(new StandardCoongError('No request message available')); + expect(() => state.getCurrentRequestMessage()).toThrowError( + new StandardDedotSignerError('No request message available'), + ); }); describe('with current message', () => { @@ -248,7 +250,7 @@ describe('getCurrentRequestMessage', () => { it('should throw error if request name does not match current message', async () => { expect(() => state.getCurrentRequestMessage('tab/signExtrinsic')).toThrowError( - new StandardCoongError('Invalid request name'), + new StandardDedotSignerError('Invalid request name'), ); }); @@ -340,7 +342,7 @@ describe('rejectRequestAccess', () => { resolve(); }), ]), - ).rejects.toThrowError(new StandardCoongError(AccessStatus.DENIED)); + ).rejects.toThrowError(new StandardDedotSignerError(AccessStatus.DENIED)); }); }); @@ -428,7 +430,7 @@ describe('rejectUpdateAccess', () => { resolve(); }), ]), - ).rejects.toThrowError(new StandardCoongError(AccessStatus.DENIED)); + ).rejects.toThrowError(new StandardDedotSignerError(AccessStatus.DENIED)); }); }); @@ -497,7 +499,7 @@ describe('sign extrinsic', () => { it('should throw error if password is not correct', async () => { await expect(handleSignExtrinsicApproval(account01.address, 'incorrect-password')).rejects.toThrowError( - new CoongError(ErrorCode.PasswordIncorrect), + new DedotSignerError(ErrorCode.PasswordIncorrect), ); }); @@ -505,7 +507,7 @@ describe('sign extrinsic', () => { vi.spyOn(state, 'ensureAccountAuthorized').mockImplementation(() => true); await expect(handleSignExtrinsicApproval('0xNotExistedAddress', PASSWORD)).rejects.toThrowError( - new CoongError(ErrorCode.KeypairNotFound), + new DedotSignerError(ErrorCode.KeypairNotFound), ); }); @@ -527,7 +529,7 @@ describe('sign extrinsic', () => { resolve(); }), ]), - ).rejects.toThrowError(new StandardCoongError('Cancelled')); + ).rejects.toThrowError(new StandardDedotSignerError('Cancelled')); }); }); }); diff --git a/packages/base/src/requests/__tests__/setup.ts b/packages/base/src/requests/__tests__/setup.ts index 6e8f0fac..8bfa6535 100644 --- a/packages/base/src/requests/__tests__/setup.ts +++ b/packages/base/src/requests/__tests__/setup.ts @@ -1,5 +1,5 @@ import { generateMnemonic } from '@polkadot/util-crypto/mnemonic/bip39'; -import Keyring from '@coong/keyring'; +import Keyring from '@dedot/signer-keyring'; import WalletState, { AUTHORIZED_ACCOUNTS_KEY, AuthorizedApps } from '../WalletState'; export const PASSWORD = 'supersecretpassword'; diff --git a/packages/base/src/types.ts b/packages/base/src/types.ts index ab5ac4a9..6012fc99 100644 --- a/packages/base/src/types.ts +++ b/packages/base/src/types.ts @@ -2,7 +2,7 @@ import type { InjectedAccount } from '@polkadot/extension-inject/types'; import type { SignerPayloadJSON, SignerPayloadRaw } from '@polkadot/types/types'; import type { HexString } from '@polkadot/util/types'; -export type MessageId = `coong/${string}`; +export type MessageId = `dedot-signer/${string}`; export interface RequestAppRequestAccess { appName: string; diff --git a/packages/base/src/utils/messageId.ts b/packages/base/src/utils/messageId.ts index b77874ce..f414cb37 100644 --- a/packages/base/src/utils/messageId.ts +++ b/packages/base/src/utils/messageId.ts @@ -3,9 +3,9 @@ import { MessageId } from '../types'; let counter = 0; export const newMessageId = (): MessageId => { - return `coong/${Date.now()}/${counter++}`; + return `dedot-signer/${Date.now()}/${counter++}`; }; export const isMessageId = (id: string) => { - return id && id.startsWith('coong/'); + return id && id.startsWith('dedot-signer/'); }; diff --git a/packages/keyring/README.md b/packages/keyring/README.md index 134c2bd2..aeeec3d8 100644 --- a/packages/keyring/README.md +++ b/packages/keyring/README.md @@ -1,3 +1,3 @@ -# @coong/keyring +# @dedot/signer-keyring -Keyring for Coong Wallet +Keyring for Dedot Signer diff --git a/packages/keyring/package.json b/packages/keyring/package.json index 212b474a..bd6257e4 100644 --- a/packages/keyring/package.json +++ b/packages/keyring/package.json @@ -1,13 +1,13 @@ { - "name": "@coong/keyring", + "name": "@dedot/signer-keyring", "version": "0.0.23", - "description": "Keyring for Coong Wallet", - "author": "Thang X. Vu ", - "homepage": "https://github.com/CoongCrafts/coong-wallet/tree/main/packages/keyring#readme", + "description": "Keyring for Dedot Signer", + "author": "Thang X. Vu ", + "homepage": "https://github.com/dedotdev/dedot-web-signer/tree/main/packages/keyring#readme", "repository": { "directory": "packages/keyring", "type": "git", - "url": "https://github.com/CoongCrafts/coong-wallet.git" + "url": "https://github.com/dedotdev/dedot-web-signer.git" }, "scripts": { "build": "tsc --project tsconfig.build.json", @@ -16,7 +16,7 @@ }, "main": "src/index.ts", "dependencies": { - "@coong/utils": "^0.0.23", + "@dedot/signer-utils": "^0.0.23", "@polkadot/ui-keyring": "^3.15.3", "crypto-js": "^4.2.0" }, diff --git a/packages/keyring/src/Keyring.ts b/packages/keyring/src/Keyring.ts index 34b26c54..48181ddd 100644 --- a/packages/keyring/src/Keyring.ts +++ b/packages/keyring/src/Keyring.ts @@ -4,12 +4,12 @@ import { validateMnemonic } from '@polkadot/util-crypto/mnemonic/bip39'; import { assert, assertFalse, - CoongError, + DedotSignerError, ErrorCode, - isCoongError, - StandardCoongError, + isDedotError, + StandardDedotSignerError, sha256AsHex, -} from '@coong/utils'; +} from '@dedot/signer-utils'; import CryptoJS from 'crypto-js'; import { AccountBackup, AccountInfo, WalletBackup, WalletBackup$Json, WalletQrBackup } from './types'; @@ -24,7 +24,7 @@ const DERIVATION_PATH_PREFIX = '//'; * @name Keyring * @description Keyring management for user accounts * - * Coong Wallet is a hierarchical deterministic (HD) wallet following the idea of BIP-32, + * Dedot Signer is a hierarchical deterministic (HD) wallet following the idea of BIP-32, * which only requires users to back up only one seed phrase upon setting up the wallet. * * New accounts will be created by deriving from a mnemonic and an accountsIndex number @@ -83,7 +83,7 @@ export default class Keyring { async ensureWalletInitialized() { if (!(await this.initialized())) { - throw new CoongError(ErrorCode.KeyringNotInitialized); + throw new DedotSignerError(ErrorCode.KeyringNotInitialized); } } @@ -141,7 +141,7 @@ export default class Keyring { return raw; } catch (e: any) { - throw new CoongError(ErrorCode.PasswordIncorrect); + throw new DedotSignerError(ErrorCode.PasswordIncorrect); } } @@ -244,15 +244,15 @@ export default class Keyring { if (password) { await this.unlock(password); } else { - throw new CoongError(ErrorCode.PasswordRequired); + throw new DedotSignerError(ErrorCode.PasswordRequired); } if (!name) { - throw new CoongError(ErrorCode.AccountNameRequired); + throw new DedotSignerError(ErrorCode.AccountNameRequired); } if (await this.existsName(name)) { - throw new CoongError(ErrorCode.AccountNameUsed); + throw new DedotSignerError(ErrorCode.AccountNameUsed); } let derivationPath = path ?? this.#nextAccountPath(); @@ -288,7 +288,7 @@ export default class Keyring { try { return this.#keyring.getPair(address); } catch (e: any) { - throw new CoongError(ErrorCode.KeypairNotFound); + throw new DedotSignerError(ErrorCode.KeypairNotFound); } } @@ -331,7 +331,7 @@ export default class Keyring { */ async renameAccount(address: string, newName: string) { if (await this.existsName(newName)) { - throw new CoongError(ErrorCode.AccountNameUsed); + throw new DedotSignerError(ErrorCode.AccountNameUsed); } const account = await this.getSigningPair(address); @@ -343,7 +343,7 @@ export default class Keyring { const targetAccount = accounts.find(predicate); if (!targetAccount) { - throw new CoongError(ErrorCode.AccountNotFound); + throw new DedotSignerError(ErrorCode.AccountNotFound); } return targetAccount; @@ -360,8 +360,8 @@ export default class Keyring { return this.#getAccount((one) => one.address === pair.address); } catch (e: any) { - if (isCoongError(e)) { - throw new CoongError(ErrorCode.AccountNotFound); + if (isDedotError(e)) { + throw new DedotSignerError(ErrorCode.AccountNotFound); } throw e; @@ -372,7 +372,7 @@ export default class Keyring { try { return !!(await this.getAccount(address)); } catch (e: any) { - if (isCoongError(e) && e.code === ErrorCode.AccountNotFound) { + if (isDedotError(e) && e.code === ErrorCode.AccountNotFound) { return false; } @@ -398,7 +398,7 @@ export default class Keyring { try { return !!(await this.getAccountByName(name)); } catch (e: any) { - if (isCoongError(e) && e.code === ErrorCode.AccountNotFound) { + if (isDedotError(e) && e.code === ErrorCode.AccountNotFound) { return false; } @@ -449,13 +449,13 @@ export default class Keyring { const { address, meta } = backup; if (await this.existsAccount(address)) { - throw new CoongError(ErrorCode.AccountExisted); + throw new DedotSignerError(ErrorCode.AccountExisted); } if (!meta.name) { - throw new CoongError(ErrorCode.AccountNameRequired); + throw new DedotSignerError(ErrorCode.AccountNameRequired); } else if (await this.existsName(meta.name as string)) { - throw new CoongError(ErrorCode.AccountNameUsed); + throw new DedotSignerError(ErrorCode.AccountNameUsed); } if (this.isExternalAccount(meta.originalHash as string)) { @@ -505,7 +505,7 @@ export default class Keyring { const rawMnemonic = await this.#decryptMnemonic(password); if (!validateMnemonic(rawMnemonic)) { - throw new CoongError(ErrorCode.InvalidMnemonic); + throw new DedotSignerError(ErrorCode.InvalidMnemonic); } this.#generateOriginalHash(rawMnemonic); @@ -535,10 +535,10 @@ export default class Keyring { } catch (e: any) { await this.reset(); - if (e instanceof StandardCoongError) { + if (e instanceof StandardDedotSignerError) { throw e; } else { - throw new StandardCoongError(e.message); + throw new StandardDedotSignerError(e.message); } } } @@ -558,10 +558,10 @@ export default class Keyring { } catch (e: any) { await this.reset(); - if (e instanceof StandardCoongError) { + if (e instanceof StandardDedotSignerError) { throw e; } else { - throw new StandardCoongError(e.message); + throw new StandardDedotSignerError(e.message); } } } @@ -576,7 +576,7 @@ export default class Keyring { return pair; } catch (e: any) { if (e.message === 'Unable to decode using the supplied passphrase') { - throw new CoongError(ErrorCode.PasswordIncorrect); + throw new DedotSignerError(ErrorCode.PasswordIncorrect); } throw e; diff --git a/packages/keyring/src/__tests__/Keyring.spec.ts b/packages/keyring/src/__tests__/Keyring.spec.ts index bb083da7..6c5e91a7 100644 --- a/packages/keyring/src/__tests__/Keyring.spec.ts +++ b/packages/keyring/src/__tests__/Keyring.spec.ts @@ -1,9 +1,9 @@ import { Keyring as InnerKeyring } from '@polkadot/ui-keyring/Keyring'; import { encodeAddress } from '@polkadot/util-crypto'; import { generateMnemonic } from '@polkadot/util-crypto/mnemonic/bip39'; -import Keyring, { ACCOUNTS_INDEX, ENCRYPTED_MNEMONIC, ORIGINAL_HASH } from '@coong/keyring/Keyring'; -import { AccountBackup, AccountInfo, WalletBackup, WalletQrBackup } from '@coong/keyring/types'; -import { CoongError, ErrorCode, StandardCoongError, sha256AsHex } from '@coong/utils'; +import Keyring, { ACCOUNTS_INDEX, ENCRYPTED_MNEMONIC, ORIGINAL_HASH } from '@dedot/signer-keyring/Keyring'; +import { AccountBackup, AccountInfo, WalletBackup, WalletQrBackup } from '@dedot/signer-keyring/types'; +import { DedotSignerError, ErrorCode, StandardDedotSignerError, sha256AsHex } from '@dedot/signer-utils'; import CryptoJS from 'crypto-js'; import { beforeEach, describe, expect, it, vi } from 'vitest'; @@ -91,14 +91,16 @@ describe('verifyPassword', () => { const keyring = new Keyring(); await expect(keyring.verifyPassword(PASSWORD)).rejects.toThrowError( - new CoongError(ErrorCode.KeyringNotInitialized), + new DedotSignerError(ErrorCode.KeyringNotInitialized), ); }); it('should throw out error if password is not correct', async () => { await initializeNewKeyring(); - await expect(keyring.verifyPassword('incorrect')).rejects.toThrowError(new CoongError(ErrorCode.PasswordIncorrect)); + await expect(keyring.verifyPassword('incorrect')).rejects.toThrowError( + new DedotSignerError(ErrorCode.PasswordIncorrect), + ); }); it('should not throw out anything if password is correct', async () => { @@ -135,19 +137,19 @@ describe('createNewAccount', () => { it('should required account name to create new account', async () => { await expect(keyring.createNewAccount('', PASSWORD)).rejects.toThrowError( - new CoongError(ErrorCode.AccountNameRequired), + new DedotSignerError(ErrorCode.AccountNameRequired), ); }); it('should required password to create new account', async () => { await expect(keyring.createNewAccount('Account name', '')).rejects.toThrowError( - new CoongError(ErrorCode.PasswordRequired), + new DedotSignerError(ErrorCode.PasswordRequired), ); }); it('should throw out error if password is incorrect', async () => { await expect(keyring.createNewAccount('Account name', 'incorrect')).rejects.toThrowError( - new CoongError(ErrorCode.PasswordIncorrect), + new DedotSignerError(ErrorCode.PasswordIncorrect), ); }); @@ -155,7 +157,7 @@ describe('createNewAccount', () => { await keyring.createNewAccount('Account 01', PASSWORD); await expect(keyring.createNewAccount('Account 01', PASSWORD)).rejects.toThrowError( - new CoongError(ErrorCode.AccountNameUsed), + new DedotSignerError(ErrorCode.AccountNameUsed), ); }); @@ -194,7 +196,7 @@ describe('createNewAccount', () => { it('should throw out error', async () => { const keyring = new Keyring(); await expect(keyring.createNewAccount('Account name', PASSWORD)).rejects.toThrowError( - new CoongError(ErrorCode.KeyringNotInitialized), + new DedotSignerError(ErrorCode.KeyringNotInitialized), ); }); }); @@ -209,7 +211,7 @@ describe('getAccount', () => { it('should throw out error if account not found', async () => { await expect(keyring.getAccount('0xNotExistedAddress')).rejects.toThrowError( - new CoongError(ErrorCode.AccountNotFound), + new DedotSignerError(ErrorCode.AccountNotFound), ); }); @@ -235,7 +237,7 @@ describe('getAccountByName', () => { it('should throw out error if account not found', async () => { await expect(keyring.getAccountByName('NotExistedName')).rejects.toThrowError( - new CoongError(ErrorCode.AccountNotFound), + new DedotSignerError(ErrorCode.AccountNotFound), ); }); @@ -252,7 +254,9 @@ describe('getSigningPair', () => { }); it('should throw out error if keypair not found', () => { - expect(() => keyring.getSigningPair('0xNotExistedAddress')).toThrowError(new CoongError(ErrorCode.KeypairNotFound)); + expect(() => keyring.getSigningPair('0xNotExistedAddress')).toThrowError( + new DedotSignerError(ErrorCode.KeypairNotFound), + ); }); it('should return keypair for existed address', () => { @@ -299,7 +303,7 @@ describe('changePassword', () => { const keyring = new Keyring(); await expect(keyring.changePassword(PASSWORD, NEW_PASSWORD)).rejects.toThrowError( - new CoongError(ErrorCode.KeyringNotInitialized), + new DedotSignerError(ErrorCode.KeyringNotInitialized), ); }); @@ -307,7 +311,7 @@ describe('changePassword', () => { const keyring = await initializeNewKeyring(); await expect(keyring.changePassword('incorrect-password', NEW_PASSWORD)).rejects.toThrowError( - new CoongError(ErrorCode.PasswordIncorrect), + new DedotSignerError(ErrorCode.PasswordIncorrect), ); }); @@ -370,7 +374,7 @@ describe('removeAccount', () => { await keyring.removeAccount(testAccount.address); await expect(keyring.getAccountByName('test-account')).rejects.toThrowError( - new CoongError(ErrorCode.AccountNotFound), + new DedotSignerError(ErrorCode.AccountNotFound), ); }); }); @@ -384,7 +388,7 @@ describe('renameAccount', () => { it('should throw an error when the name already exists', async () => { await expect(keyring.renameAccount(address, 'test-account')).rejects.toThrowError( - new CoongError(ErrorCode.AccountNameUsed), + new DedotSignerError(ErrorCode.AccountNameUsed), ); }); @@ -400,7 +404,7 @@ describe('renameAccount', () => { await expect(keyring.getAccountByName('valid-name')).resolves; await expect(keyring.getAccountByName('test-account')).rejects.toThrowError( - new CoongError(ErrorCode.AccountNotFound), + new DedotSignerError(ErrorCode.AccountNotFound), ); }); }); @@ -447,7 +451,7 @@ describe('importQrBackup', () => { const keyring = await initializeNewKeyring(); await expect(keyring.importQrBackup(qrBackup, PASSWORD)).rejects.toThrowError( - new StandardCoongError('Wallet is already initialized'), + new StandardDedotSignerError('Wallet is already initialized'), ); }); @@ -472,7 +476,7 @@ describe('importQrBackup', () => { qrBackup.encryptedMnemonic = CryptoJS.AES.encrypt('a random invalid seed phrase', PASSWORD).toString(); await expect(keyring.importQrBackup(qrBackup, PASSWORD)).rejects.toThrowError( - new CoongError(ErrorCode.InvalidMnemonic), + new DedotSignerError(ErrorCode.InvalidMnemonic), ); }); @@ -554,7 +558,7 @@ describe('importAccount', () => { await keyring.importAccount(backup, BACKUP_PASSWORD, PASSWORD); await expect(keyring.importAccount(backup, BACKUP_PASSWORD, PASSWORD)).rejects.toThrowError( - new CoongError(ErrorCode.AccountExisted), + new DedotSignerError(ErrorCode.AccountExisted), ); }); @@ -562,14 +566,14 @@ describe('importAccount', () => { await keyring.createNewAccount('test-account', BACKUP_PASSWORD); await expect(keyring.importAccount(backup, BACKUP_PASSWORD, PASSWORD)).rejects.toThrowError( - new CoongError(ErrorCode.AccountNameUsed), + new DedotSignerError(ErrorCode.AccountNameUsed), ); }); it('should throw error if account name not found', async () => { await expect( keyring.importAccount({ ...backup, meta: { ...backup.meta, name: '' } }, BACKUP_PASSWORD, PASSWORD), - ).rejects.toThrowError(new CoongError(ErrorCode.AccountNameRequired)); + ).rejects.toThrowError(new DedotSignerError(ErrorCode.AccountNameRequired)); }); it('should found account after restoring account', async () => { @@ -580,7 +584,7 @@ describe('importAccount', () => { it('should throw error if password incorrect', async () => { await expect(keyring.importAccount(backup, 'incorrect-password', PASSWORD)).rejects.toThrowError( - new CoongError(ErrorCode.PasswordIncorrect), + new DedotSignerError(ErrorCode.PasswordIncorrect), ); }); @@ -600,7 +604,7 @@ describe('verifyAccountBackupPassword', () => { const backup = await keyring.exportAccount(address, PASSWORD); await expect(keyring.verifyAccountBackupPassword(backup, 'incorrect-password')).rejects.toThrowError( - new CoongError(ErrorCode.PasswordIncorrect), + new DedotSignerError(ErrorCode.PasswordIncorrect), ); }); }); @@ -620,7 +624,7 @@ describe('importBackup', () => { keyring = await initializeNewKeyring(); await expect(keyring.importBackup(backup, PASSWORD)).rejects.toThrowError( - new StandardCoongError('Wallet is already initialized'), + new StandardDedotSignerError('Wallet is already initialized'), ); }); @@ -655,13 +659,13 @@ describe('importBackup', () => { backup.encryptedMnemonic = CryptoJS.AES.encrypt('a random invalid seed phrase', PASSWORD).toString(); await expect(keyring.importBackup(backup, PASSWORD)).rejects.toThrowError( - new CoongError(ErrorCode.InvalidMnemonic), + new DedotSignerError(ErrorCode.InvalidMnemonic), ); }); it('should throw error if password incorrect', async () => { await expect(keyring.importBackup(backup, 'wrong-password')).rejects.toThrowError( - new CoongError(ErrorCode.PasswordIncorrect), + new DedotSignerError(ErrorCode.PasswordIncorrect), ); }); diff --git a/packages/keyring/src/packageInfo.ts b/packages/keyring/src/packageInfo.ts index e845ac29..069d6e26 100644 --- a/packages/keyring/src/packageInfo.ts +++ b/packages/keyring/src/packageInfo.ts @@ -1,3 +1,3 @@ // THIS FILE IS AUTO-GENERATED, DO NOT EDIT! -export const packageInfo = { name: '@coong/keyring', version: '0.0.23' }; +export const packageInfo = { name: '@dedot/signer-keyring', version: '0.0.23' }; diff --git a/packages/sdk/README.md b/packages/sdk/README.md index f909875f..02374156 100644 --- a/packages/sdk/README.md +++ b/packages/sdk/README.md @@ -1,3 +1,3 @@ -# @coong/sdk +# @dedot/signer-sdk -Coong SDK to help [integrate Coong Wallet into dapps](https://github.com/CoongCrafts/coong-wallet#integrate-coong-wallet-into-your-dapps) +Dedot Signer SDK to help [integrate Dedot Signer into your dapps](https://github.com/dedotdev/dedot-web-signer#integrate-dedot-signer-into-your-dapps) diff --git a/packages/sdk/package.json b/packages/sdk/package.json index cc9670b6..eb4342fc 100644 --- a/packages/sdk/package.json +++ b/packages/sdk/package.json @@ -1,13 +1,13 @@ { - "name": "@coong/sdk", + "name": "@dedot/signer-sdk", "version": "0.0.23", - "description": "Coong SDK to integrate Coong Wallet into dapps", - "author": "Thang X. Vu ", - "homepage": "https://github.com/CoongCrafts/coong-wallet/tree/main/packages/sdk#readme", + "description": "Dedot SDK to integrate Dedot Signer into dapps", + "author": "Thang X. Vu ", + "homepage": "https://github.com/dedotdev/dedot-web-signer/tree/main/packages/sdk#readme", "repository": { "directory": "packages/sdk", "type": "git", - "url": "https://github.com/CoongCrafts/coong-wallet.git" + "url": "https://github.com/dedotdev/dedot-web-signer.git" }, "main": "src/index.ts", "scripts": { @@ -15,8 +15,8 @@ "clean": "rm -rf ./dist && rm -rf ./tsconfig.tsbuildinfo ./tsconfig.build.tsbuildinfo" }, "dependencies": { - "@coong/base": "^0.0.23", - "@coong/utils": "^0.0.23", + "@dedot/signer-base": "^0.0.23", + "@dedot/signer-utils": "^0.0.23", "@polkadot/extension-inject": "^0.61.5", "rxjs": "^7.8.0" }, diff --git a/packages/sdk/src/ConnectedAccounts.ts b/packages/sdk/src/ConnectedAccounts.ts index 95dec922..df91717d 100644 --- a/packages/sdk/src/ConnectedAccounts.ts +++ b/packages/sdk/src/ConnectedAccounts.ts @@ -1,7 +1,7 @@ import { InjectedAccount } from '@polkadot/extension-inject/types'; -import { assert, trimOffUrlProtocol } from '@coong/utils'; +import { assert, trimOffUrlProtocol } from '@dedot/signer-utils'; import { BehaviorSubject, Subscription } from 'rxjs'; -import CoongSdk from './CoongSdk'; +import { DedotSignerSdk } from './DedotSignerSdk'; const CONNECTED_ACCOUNTS_KEY = 'CONNECTED_ACCOUNTS'; @@ -9,12 +9,12 @@ const CONNECTED_ACCOUNTS_KEY = 'CONNECTED_ACCOUNTS'; * @name ConnectedAccounts * @description Store & manage authorized/connected accounts from wallet for dapps */ -export default class ConnectedAccounts { - #sdk: CoongSdk; +export class ConnectedAccounts { + #sdk: DedotSignerSdk; #accounts: BehaviorSubject; - constructor(sdk: CoongSdk) { - assert(sdk, 'Coong SDK is required'); + constructor(sdk: DedotSignerSdk) { + assert(sdk, 'DedotSignerSdk is required'); this.#sdk = sdk; this.#accounts = new BehaviorSubject(this.#loadFromStorage()); diff --git a/packages/sdk/src/CoongSdk.ts b/packages/sdk/src/DedotSignerSdk.ts similarity index 84% rename from packages/sdk/src/CoongSdk.ts rename to packages/sdk/src/DedotSignerSdk.ts index 23e3bfba..459e4dd0 100644 --- a/packages/sdk/src/CoongSdk.ts +++ b/packages/sdk/src/DedotSignerSdk.ts @@ -1,5 +1,5 @@ import { injectExtension } from '@polkadot/extension-inject'; -import { isWalletResponse, newMessageId, newWalletRequest } from '@coong/base'; +import { isWalletResponse, newMessageId, newWalletRequest } from '@dedot/signer-base'; import { MessageId, MessageType, @@ -9,41 +9,41 @@ import { WalletRequestMessage, WalletResponse, WalletResponseMessage, -} from '@coong/base/types'; -import { assert, assertFalse, CoongError, ErrorCode, trimTrailingSlash } from '@coong/utils'; -import ConnectedAccounts from './ConnectedAccounts'; +} from '@dedot/signer-base/types'; +import { assert, assertFalse, DedotSignerError, ErrorCode, trimTrailingSlash } from '@dedot/signer-utils'; +import { ConnectedAccounts } from './ConnectedAccounts'; import SubstrateInjected from './injection/Injected'; -import { CoongSdkOptions, Handlers, InjectedWindow, UpdatableInjected } from './types'; +import { DedotSignerSdkOptions, Handlers, InjectedWindow, UpdatableInjected } from './types'; import TabInstance from './wallet/TabInstance'; -const DEFAULT_WALLET_URL = 'https://app.coongwallet.io'; +const DEFAULT_WALLET_URL = 'https://signer.dedot.dev'; /** - * @name CoongSdk - * @description A helper to initialize/inject Coong Wallet API + * @name DedotSignerSdk + * @description A helper to initialize/inject Dedot Signer API * and interact with wallet instances * - * ## Initialize & interact with Coong Wallet + * ## Initialize & interact with Dedot Signer * * ```typescript - * import CoongSdk from '@coong/sdk'; + * import { DedotSignerSdk } from '@dedot/signer-sdk'; * - * const initializeCoongWallet = async () => { - * // Inject Coong Wallet API - * const sdk = new CoongSdk() + * const initializeDedotSigner = async () => { + * // Inject Dedot Signer API + * const sdk = new DedotSignerSdk() * await sdk.initialize(); * * // We can now interact with the wallet using the similar Polkadot{.js} extension API - * const injected = await window['injectedWeb3']['coongwallet'].enable('Awesome Dapp'); + * const injected = await window['injectedWeb3']['dedot-signer'].enable('Awesome Dapp'); * const approvedAccounts = await injected.accounts.get(); * * return { sdk, injected, approvedAccounts } * } * - * await initializeCoongWallet(); + * await initializeDedotSigner(); * ``` */ -export default class CoongSdk { +export class DedotSignerSdk { #walletUrl: string; #initialized: boolean; #handlers: Handlers; @@ -51,7 +51,7 @@ export default class CoongSdk { #connectedAccounts?: ConnectedAccounts; #walletInstancesQueue: Window[]; - constructor(options?: CoongSdkOptions) { + constructor(options?: DedotSignerSdkOptions) { this.#initialized = false; this.#handlers = {}; @@ -65,8 +65,8 @@ export default class CoongSdk { * Initialize & inject wallet API */ async initialize() { - assert(typeof window !== 'undefined', 'Coong SDK only works in browser environment!'); - assertFalse(this.#initialized, 'Coong Sdk is already initialized!'); + assert(typeof window !== 'undefined', 'Dedot Signer SDK only works in browser environment!'); + assertFalse(this.#initialized, 'Dedot Signer SDK is already initialized!'); await this.#loadWalletInfo(); @@ -78,11 +78,11 @@ export default class CoongSdk { this.#initialized = true; - console.log('Coong SDK initialized!'); + console.log('Dedot Signer SDK initialized!'); } /** - * Destroy Coong Wallet initialization + * Destroy Dedot Signer initialization */ destroy() { if (!this.#initialized) { @@ -160,7 +160,7 @@ export default class CoongSdk { } else if (name.startsWith('tab/')) { await this.#sendMessageToTabInstance(message); } else { - throw new CoongError(ErrorCode.InvalidMessageFormat); + throw new DedotSignerError(ErrorCode.InvalidMessageFormat); } } @@ -168,7 +168,7 @@ export default class CoongSdk { * Making sure the wallet has been initialized, else an error will be thrown out */ ensureSdkInitialized() { - assert(this.#initialized, 'CoongSdk has not been initialized!'); + assert(this.#initialized, 'Dedot Signer SDK has not been initialized!'); } #walletMessageHandler(event: MessageEvent) { diff --git a/packages/sdk/src/index.ts b/packages/sdk/src/index.ts index ed92cdef..9a5d2de7 100644 --- a/packages/sdk/src/index.ts +++ b/packages/sdk/src/index.ts @@ -1,3 +1,3 @@ -import CoongSdk from './CoongSdk'; +import { DedotSignerSdk } from './DedotSignerSdk'; -export default CoongSdk; +export { DedotSignerSdk }; diff --git a/packages/sdk/src/injection/Accounts.ts b/packages/sdk/src/injection/Accounts.ts index 59d8fbac..3b4a4a77 100644 --- a/packages/sdk/src/injection/Accounts.ts +++ b/packages/sdk/src/injection/Accounts.ts @@ -1,13 +1,13 @@ import { InjectedAccount, Unsubcall } from '@polkadot/extension-inject/types'; -import { assert } from '@coong/utils'; -import ConnectedAccounts from '../ConnectedAccounts'; -import CoongSdk from '../CoongSdk'; +import { assert } from '@dedot/signer-utils'; +import { ConnectedAccounts } from '../ConnectedAccounts'; +import { DedotSignerSdk } from '../DedotSignerSdk'; import { UpdatableInjectedAccounts } from '../types'; -export default class Accounts implements UpdatableInjectedAccounts { - #sdk: CoongSdk; +export class Accounts implements UpdatableInjectedAccounts { + #sdk: DedotSignerSdk; - constructor(sdk: CoongSdk) { + constructor(sdk: DedotSignerSdk) { this.#sdk = sdk; } diff --git a/packages/sdk/src/injection/CoongSigner.ts b/packages/sdk/src/injection/DedotSigner.ts similarity index 81% rename from packages/sdk/src/injection/CoongSigner.ts rename to packages/sdk/src/injection/DedotSigner.ts index e1fe8baa..8af182fe 100644 --- a/packages/sdk/src/injection/CoongSigner.ts +++ b/packages/sdk/src/injection/DedotSigner.ts @@ -1,15 +1,15 @@ import type { Signer as SignerInterface, SignerResult } from '@polkadot/api/types'; import { SignerPayloadJSON, SignerPayloadRaw } from '@polkadot/types/types/extrinsic'; -import CoongSdk from '@coong/sdk'; +import { DedotSignerSdk } from '@dedot/signer-sdk'; const nextRequestId = (): number => { return Date.now(); }; -export default class CoongSigner implements SignerInterface { - #sdk: CoongSdk; +export class DedotSigner implements SignerInterface { + #sdk: DedotSignerSdk; - constructor(sdk: CoongSdk) { + constructor(sdk: DedotSignerSdk) { this.#sdk = sdk; } diff --git a/packages/sdk/src/injection/Injected.ts b/packages/sdk/src/injection/Injected.ts index 5d2a8c20..48682e8c 100644 --- a/packages/sdk/src/injection/Injected.ts +++ b/packages/sdk/src/injection/Injected.ts @@ -1,16 +1,16 @@ -import CoongSdk from '../CoongSdk'; +import { DedotSignerSdk } from '../DedotSignerSdk'; import { UpdatableInjected } from '../types'; -import Accounts from './Accounts'; -import CoongSigner from './CoongSigner'; +import { Accounts } from './Accounts'; +import { DedotSigner } from './DedotSigner'; export default class SubstrateInjected implements UpdatableInjected { public readonly accounts: Accounts; - public readonly signer: CoongSigner; + public readonly signer: DedotSigner; - constructor(sdk: CoongSdk) { + constructor(sdk: DedotSignerSdk) { sdk.ensureSdkInitialized(); this.accounts = new Accounts(sdk); - this.signer = new CoongSigner(sdk); + this.signer = new DedotSigner(sdk); } } diff --git a/packages/sdk/src/packageInfo.ts b/packages/sdk/src/packageInfo.ts index 93f21667..ad6b8ca9 100644 --- a/packages/sdk/src/packageInfo.ts +++ b/packages/sdk/src/packageInfo.ts @@ -1,3 +1,3 @@ // THIS FILE IS AUTO-GENERATED, DO NOT EDIT! -export const packageInfo = { name: '@coong/sdk', version: '0.0.23' }; +export const packageInfo = { name: '@dedot/signer-sdk', version: '0.0.23' }; diff --git a/packages/sdk/src/types.ts b/packages/sdk/src/types.ts index 4d3bb594..87305f27 100644 --- a/packages/sdk/src/types.ts +++ b/packages/sdk/src/types.ts @@ -4,7 +4,7 @@ import { InjectedAccounts, InjectedWindowProvider as DefaultInjectedWindowProvider, } from '@polkadot/extension-inject/types'; -import { MessageId, RequestName, WalletRequest, WalletResponse } from '@coong/base/types'; +import { MessageId, RequestName, WalletRequest, WalletResponse } from '@dedot/signer-base/types'; export interface Handler { resolve: (data: any) => void; @@ -13,7 +13,7 @@ export interface Handler { export type Handlers = Record; -export interface CoongSdkOptions { +export interface DedotSignerSdkOptions { walletUrl: string; } diff --git a/packages/sdk/src/wallet/TabInstance.ts b/packages/sdk/src/wallet/TabInstance.ts index be826769..ede7c821 100644 --- a/packages/sdk/src/wallet/TabInstance.ts +++ b/packages/sdk/src/wallet/TabInstance.ts @@ -1,6 +1,6 @@ -import { compareWalletInfo } from '@coong/base'; -import { WalletSignal, WalletSignalMessage } from '@coong/base/types'; -import { StandardCoongError } from '@coong/utils'; +import { compareWalletInfo } from '@dedot/signer-base'; +import { WalletSignal, WalletSignalMessage } from '@dedot/signer-base/types'; +import { StandardDedotSignerError } from '@dedot/signer-utils'; import WalletInstance from './WalletInstance'; const POPUP_WINDOW_FEATURES = `resizable=no,status=no,location=no,toolbar=no,menubar=no,width=620,height=700,left=150,top=150`; @@ -22,7 +22,7 @@ export default class TabInstance extends WalletInstance { const tabWalletWindow = window.open(`${this.walletUrl}${path}`, '_blank', POPUP_WINDOW_FEATURES); if (!tabWalletWindow) { - throw new StandardCoongError('Error open wallet tab'); + throw new StandardDedotSignerError('Error open wallet tab'); } await this.waitUntilWalletReady(); diff --git a/packages/sdk/src/wallet/WalletInstance.ts b/packages/sdk/src/wallet/WalletInstance.ts index 35cae50d..1ca40543 100644 --- a/packages/sdk/src/wallet/WalletInstance.ts +++ b/packages/sdk/src/wallet/WalletInstance.ts @@ -1,6 +1,6 @@ -import { isWalletSignal } from '@coong/base'; -import { WalletInfo, WalletSignalMessage } from '@coong/base/types'; -import { StandardCoongError } from '@coong/utils'; +import { isWalletSignal } from '@dedot/signer-base'; +import { WalletInfo, WalletSignalMessage } from '@dedot/signer-base/types'; +import { StandardDedotSignerError } from '@dedot/signer-utils'; export default abstract class WalletInstance { public readonly walletUrl: string; @@ -42,7 +42,7 @@ export default abstract class WalletInstance { } protected onSignal(message: WalletSignalMessage) { - throw new StandardCoongError('Implement this method'); + throw new StandardDedotSignerError('Implement this method'); } destroy() { diff --git a/packages/ui/README.md b/packages/ui/README.md index 0d9216a5..935dd580 100644 --- a/packages/ui/README.md +++ b/packages/ui/README.md @@ -1,3 +1,3 @@ -# @coong/ui +# @dedot/signer-ui -Coong Wallet application \ No newline at end of file +Dedot Signer Application \ No newline at end of file diff --git a/packages/ui/index.html b/packages/ui/index.html index 55741043..4f2b3368 100644 --- a/packages/ui/index.html +++ b/packages/ui/index.html @@ -2,15 +2,15 @@ - + - + - Coong Wallet - A multi-chain crypto wallet for Polkadot & Kusama ecosystem + Dedot Signer - A multi-chain crypto signer for Polkadot & Kusama ecosystem diff --git a/packages/ui/package.json b/packages/ui/package.json index e3b8b397..519ae81f 100644 --- a/packages/ui/package.json +++ b/packages/ui/package.json @@ -1,13 +1,13 @@ { - "name": "@coong/ui", + "name": "@dedot/signer-ui", "private": true, "version": "0.0.1", - "author": "Thang X. Vu ", - "homepage": "https://github.com/CoongCrafts/coong-wallet/tree/main/packages/ui#readme", + "author": "Thang X. Vu ", + "homepage": "https://github.com/dedotdev/dedot-web-signer/tree/main/packages/ui#readme", "repository": { "directory": "packages/ui", "type": "git", - "url": "https://github.com/CoongCrafts/coong-wallet.git" + "url": "https://github.com/dedotdev/dedot-web-signer.git" }, "scripts": { "start": "vite --port 3030 --host 0.0.0.0", @@ -17,9 +17,9 @@ "test": "npx vitest --watch=false" }, "dependencies": { - "@coong/base": "*", - "@coong/keyring": "*", - "@coong/utils": "*", + "@dedot/signer-base": "*", + "@dedot/signer-keyring": "*", + "@dedot/signer-utils": "*", "@emotion/react": "^11.10.5", "@emotion/styled": "^11.10.5", "@mui/icons-material": "^5.11.0", diff --git a/packages/ui/public/coong-inverted-logo.svg b/packages/ui/public/coong-inverted-logo.svg deleted file mode 100644 index 7f499f9a..00000000 --- a/packages/ui/public/coong-inverted-logo.svg +++ /dev/null @@ -1,33 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/packages/ui/public/locales/en/translation.json b/packages/ui/public/locales/en/translation.json index 93a5890b..c4a71641 100644 --- a/packages/ui/public/locales/en/translation.json +++ b/packages/ui/public/locales/en/translation.json @@ -3,7 +3,7 @@ "30 minutes": "", "5 minutes": "", "": "", - "A multichain crypto wallet for Polkadot & Kusama ecosystem": "A multichain crypto wallet
for Polkadot & Kusama ecosystem", + "A multichain crypto signer for Polkadot & Kusama ecosystem": "A multichain crypto signer
for Polkadot & Kusama ecosystem", "Account": "", "Account Address QR Code": "", "Account address": "", @@ -52,8 +52,8 @@ "Confirm wallet password": "", "Connect": "", "Continue": "", - "Coong Wallet cannot recover wallet password for you. If you have trouble unlocking your wallet, you will need to reset the wallet. Make sure you have your secret recovery phrase before proceed further.": "", - "Coong Wallet needs your permission to access the device camera to scan QR code. Please update the browser settings to allow camera access.": "", + "Dedot Signer cannot recover wallet password for you. If you have trouble unlocking your wallet, you will need to reset the wallet. Make sure you have your secret recovery phrase before proceed further.": "", + "Dedot Signer needs your permission to access the device camera to scan QR code. Please update the browser settings to allow camera access.": "", "Copied!": "", "Copy to Clipboard": "", "Create": "", @@ -75,8 +75,8 @@ "Enter your wallet password to continue": "", "Export Wallet": "", "Export account": "", - "Export this {{object}} to a JSON file and import it back to Coong Wallet on this or other devices later": "", - "Export your Coong Wallet on a different device and scan the QR code on the screen to transfer your wallet.": "", + "Export this {{object}} to a JSON file and import it back to Dedot Signer on this or other devices later": "", + "Export your Dedot Signer on a different device and scan the QR code on the screen to transfer your wallet.": "", "Export your {{object}} on a different device and scan the QR code on the screen to transfer your {{object}}.": "", "File reading was aborted!": "", "File reading was failed!": "", @@ -90,7 +90,7 @@ "IMPORTED": "", "If you open this page by accident, it's safe to close it now.": "", "Import Account": "", - "Import JSON backup file exported from Coong Wallet": "", + "Import JSON backup file exported from Dedot Signer": "", "Import wallet": "", "InternalError": "Internal error", "Invalid Request": "", @@ -124,7 +124,7 @@ "No dapps have access to this account": "", "No dapps meet search query:": "", "Only connect if you trust the application": "", - "Open Coong Wallet on another device and scan this QR Code to transfer your {{object}}.": "", + "Open Dedot Signer on another device and scan this QR Code to transfer your {{object}}.": "", "Open account controls": "", "Open settings": "", "OriginalHashNotFound": "Cannot check wallet origin, please lock and unlock the wallet again", @@ -151,7 +151,7 @@ "Reset wallet": "", "Restore Existing Wallet": "", "Scan QR Code": "", - "Scan QR Code from Coong Wallet on a different device": "", + "Scan QR Code from Dedot Signer on a different device": "", "Scan to import {{object}}": "", "Search by name": "", "Search by name or URL": "", @@ -163,8 +163,8 @@ "Select the accounts you'd like to connect": "", "Set up new wallet": "", "Set up wallet": "", - "Set up your Coong Wallet now": "", - "Set up your Coong Wallet now to connect": "", + "Set up your Dedot Signer now": "", + "Set up your Dedot Signer now to connect": "", "Settings": "", "Show Address QR Code": "", "Sign": "", @@ -199,7 +199,7 @@ "Wallet password of the account backup": "", "WalletLocked": "The wallet is locked, please unlock it first", "Welcome back": "", - "Welcome to Coong Wallet": "", + "Welcome to Dedot Signer": "" "Write down the below 12 words and keep it in a safe place.": "", "You are about to reveal the secret recovery phrase which give access to your accounts and funds. Make sure you are in a safe place.": "You are about to reveal the secret recovery phrase which give access to your accounts and funds. Make sure you are in a safe place.", "You are approving a transaction with account": "", diff --git a/packages/ui/public/wallet-info.json b/packages/ui/public/wallet-info.json index 232f0af6..d3f6359b 100644 --- a/packages/ui/public/wallet-info.json +++ b/packages/ui/public/wallet-info.json @@ -1,4 +1,4 @@ { - "name": "coongwallet", + "name": "dedotsigner", "version": "0.0.1" } diff --git a/packages/ui/src/__tests__/testUtils.tsx b/packages/ui/src/__tests__/testUtils.tsx index 65b23b86..e5a58559 100644 --- a/packages/ui/src/__tests__/testUtils.tsx +++ b/packages/ui/src/__tests__/testUtils.tsx @@ -4,8 +4,8 @@ import { Provider } from 'react-redux'; import { createMemoryRouter, RouterProvider } from 'react-router-dom'; import { ToastContainer } from 'react-toastify'; import { generateMnemonic } from '@polkadot/util-crypto/mnemonic/bip39'; -import WalletState, { AUTHORIZED_ACCOUNTS_KEY, AuthorizedApps } from '@coong/base/requests/WalletState'; -import Keyring from '@coong/keyring'; +import WalletState, { AUTHORIZED_ACCOUNTS_KEY, AuthorizedApps } from '@dedot/signer-base/requests/WalletState'; +import Keyring from '@dedot/signer-keyring'; import { PreloadedState } from '@reduxjs/toolkit'; import userEvent from '@testing-library/user-event'; import { Options } from '@testing-library/user-event/options'; diff --git a/packages/ui/src/assets/images/coong-logo.svg b/packages/ui/src/assets/images/coong-logo.svg deleted file mode 100644 index 8912b1ee..00000000 --- a/packages/ui/src/assets/images/coong-logo.svg +++ /dev/null @@ -1,21 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - diff --git a/packages/ui/src/assets/images/coong-text-logo.svg b/packages/ui/src/assets/images/coong-text-logo.svg deleted file mode 100644 index faffa84b..00000000 --- a/packages/ui/src/assets/images/coong-text-logo.svg +++ /dev/null @@ -1,31 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/packages/ui/src/assets/images/coong-logo.png b/packages/ui/src/assets/images/dedot-logo.png similarity index 100% rename from packages/ui/src/assets/images/coong-logo.png rename to packages/ui/src/assets/images/dedot-logo.png diff --git a/packages/ui/public/coong-lined-logo.svg b/packages/ui/src/assets/images/dedot-logo.svg similarity index 100% rename from packages/ui/public/coong-lined-logo.svg rename to packages/ui/src/assets/images/dedot-logo.svg diff --git a/packages/ui/public/coong-text-logo.svg b/packages/ui/src/assets/images/dedot-text-logo.svg similarity index 100% rename from packages/ui/public/coong-text-logo.svg rename to packages/ui/src/assets/images/dedot-text-logo.svg diff --git a/packages/ui/src/components/layouts/MainFooter.tsx b/packages/ui/src/components/layouts/MainFooter.tsx index db017185..d1dbd4c5 100644 --- a/packages/ui/src/components/layouts/MainFooter.tsx +++ b/packages/ui/src/components/layouts/MainFooter.tsx @@ -8,15 +8,15 @@ const MainFooter: FC = ({ className = '' }) => {