diff --git a/package.json b/package.json index c12a097a..d82568ba 100644 --- a/package.json +++ b/package.json @@ -17,7 +17,8 @@ "@trivago/prettier-plugin-sort-imports": "^4.0.0", "lerna": "^6.5.1", "prettier": "^2.8.4", - "prettier-plugin-organize-imports": "^3.2.2" + "prettier-plugin-organize-imports": "^3.2.2", + "typescript": "^4.9.3" }, "resolutions": { "@polkadot/types": "^9.14.1", diff --git a/packages/base/package.json b/packages/base/package.json index 4458b8fd..884637cb 100644 --- a/packages/base/package.json +++ b/packages/base/package.json @@ -10,6 +10,7 @@ "main": "dist/index.js", "dependencies": { "@coong/keyring": "^0.0.3", + "@coong/utils": "^0.0.3", "@polkadot/networks": "^10.4.1", "@polkadot/types": "^9.14.1", "rxjs": "^7.8.0" diff --git a/packages/base/src/index.ts b/packages/base/src/index.ts index 3f95aa2c..69f923cc 100644 --- a/packages/base/src/index.ts +++ b/packages/base/src/index.ts @@ -1,6 +1,6 @@ -import keyring from 'keyring'; +import keyring from './keyring'; export { keyring }; -export { handleWalletRequest, state, embedHandler, tabHandler } from 'requests'; -export * from 'utils'; -export * from 'networks'; +export { handleWalletRequest, state, embedHandler, tabHandler } from './requests'; +export * from './utils'; +export * from './networks'; diff --git a/packages/base/src/networks.ts b/packages/base/src/networks.ts index 7550a8a0..59952916 100644 --- a/packages/base/src/networks.ts +++ b/packages/base/src/networks.ts @@ -1,5 +1,5 @@ import { availableNetworks } from '@polkadot/networks'; -import { NetworkInfo } from 'types'; +import { NetworkInfo } from './types'; export const networks: NetworkInfo[] = availableNetworks.map(({ prefix, displayName, network }) => ({ displayName, diff --git a/packages/base/src/requests/EmbedHandler.ts b/packages/base/src/requests/EmbedHandler.ts index c61a3be0..3b51df64 100644 --- a/packages/base/src/requests/EmbedHandler.ts +++ b/packages/base/src/requests/EmbedHandler.ts @@ -2,9 +2,9 @@ import { InjectedAccount } from '@polkadot/extension-inject/types'; import { SingleAddress, SubjectInfo } from '@polkadot/ui-keyring/observable/types'; import { KeypairType } from '@polkadot/util-crypto/types'; import { CoongError, ErrorCode } from '@coong/utils'; -import keyring from 'keyring'; -import Handler from 'requests/Handler'; -import { RequestAuthorizedAccounts, RequestName, WalletRequestMessage, WalletResponse } from 'types'; +import keyring from '../keyring'; +import { RequestAuthorizedAccounts, RequestName, WalletRequestMessage, WalletResponse } from '../types'; +import Handler from './Handler'; const sortOldestFirst = (a: SingleAddress, b: SingleAddress) => { return (a.json.meta.whenCreated || 0) - (b.json.meta.whenCreated || 0); diff --git a/packages/base/src/requests/Handler.ts b/packages/base/src/requests/Handler.ts index 17cd2f0f..fb2b485b 100644 --- a/packages/base/src/requests/Handler.ts +++ b/packages/base/src/requests/Handler.ts @@ -1,4 +1,4 @@ -import WalletState from 'requests/WalletState'; +import WalletState from './WalletState'; export default abstract class Handler { readonly #state: WalletState; diff --git a/packages/base/src/requests/TabHandler.ts b/packages/base/src/requests/TabHandler.ts index fe9769f4..3492eccb 100644 --- a/packages/base/src/requests/TabHandler.ts +++ b/packages/base/src/requests/TabHandler.ts @@ -1,7 +1,7 @@ import { SignerPayloadJSON, SignerPayloadRaw } from '@polkadot/types/types'; -import { RequestName, WalletRequestMessage, WalletResponse } from '@coong/base/types'; import { CoongError, ErrorCode } from '@coong/utils'; -import Handler from 'requests/Handler'; +import { RequestName, WalletRequestMessage, WalletResponse } from '../types'; +import Handler from './Handler'; export default class TabHandler extends Handler { async handle( diff --git a/packages/base/src/requests/WalletState.ts b/packages/base/src/requests/WalletState.ts index 76feac48..f0908106 100644 --- a/packages/base/src/requests/WalletState.ts +++ b/packages/base/src/requests/WalletState.ts @@ -3,8 +3,8 @@ import { SignerPayloadJSON } from '@polkadot/types/types'; import { encodeAddress } from '@polkadot/util-crypto'; import { defaultNetwork } from '@coong/base'; import { assert, StandardCoongError } from '@coong/utils'; -import keyring from 'keyring'; import { BehaviorSubject } from 'rxjs'; +import keyring from '../keyring'; import { AccessStatus, RequestAppRequestAccess, @@ -12,7 +12,7 @@ import { WalletRequestMessage, WalletRequestWithResolver, WalletResponse, -} from 'types'; +} from '../types'; export type AppId = string; export interface AppInfo { diff --git a/packages/base/src/requests/index.ts b/packages/base/src/requests/index.ts index 4c2305e9..2d47c9f1 100644 --- a/packages/base/src/requests/index.ts +++ b/packages/base/src/requests/index.ts @@ -1,9 +1,9 @@ import { CoongError, ErrorCode } from '@coong/utils'; -import { EmbedHandler } from 'requests/EmbedHandler'; -import TabHandler from 'requests/TabHandler'; -import WalletState from 'requests/WalletState'; -import { RequestName, WalletRequestMessage, WalletResponse } from 'types'; -import { isMessageId } from 'utils/messageId'; +import { RequestName, WalletRequestMessage, WalletResponse } from '../types'; +import { isMessageId } from '../utils'; +import { EmbedHandler } from './EmbedHandler'; +import TabHandler from './TabHandler'; +import WalletState from './WalletState'; export const state = new WalletState(); export const embedHandler = new EmbedHandler(state); diff --git a/packages/base/src/utils/index.ts b/packages/base/src/utils/index.ts index c14c01cd..440bc65f 100644 --- a/packages/base/src/utils/index.ts +++ b/packages/base/src/utils/index.ts @@ -1,2 +1,2 @@ -export * from 'utils/messageId'; -export * from 'utils/walletMessage'; +export * from './messageId'; +export * from './walletMessage'; diff --git a/packages/base/src/utils/messageId.ts b/packages/base/src/utils/messageId.ts index f7a124c4..b77874ce 100644 --- a/packages/base/src/utils/messageId.ts +++ b/packages/base/src/utils/messageId.ts @@ -1,4 +1,4 @@ -import { MessageId } from 'types'; +import { MessageId } from '../types'; let counter = 0; diff --git a/packages/base/src/utils/walletMessage.ts b/packages/base/src/utils/walletMessage.ts index b48662e2..27e980a4 100644 --- a/packages/base/src/utils/walletMessage.ts +++ b/packages/base/src/utils/walletMessage.ts @@ -9,8 +9,8 @@ import { WalletSignal, WalletSignalMessage, WalletSignals, -} from 'types'; -import { isMessageId, newMessageId } from 'utils/messageId'; +} from '../types'; +import { isMessageId, newMessageId } from '../utils'; export const currentOrigin = () => { return window.location.origin; diff --git a/packages/base/tsconfig.json b/packages/base/tsconfig.json index f98584e0..17a19c7d 100644 --- a/packages/base/tsconfig.json +++ b/packages/base/tsconfig.json @@ -1,9 +1,9 @@ { "extends": "../../tsconfig.base.json", "compilerOptions": { - "baseUrl": "src", + "baseUrl": "./", "outDir": "dist", - "rootDir": "src" + "rootDir": "src", }, "include": ["src/**/*"], "references": [ diff --git a/packages/keyring/src/Keyring.ts b/packages/keyring/src/Keyring.ts index b1be78de..4c5c72e6 100644 --- a/packages/keyring/src/Keyring.ts +++ b/packages/keyring/src/Keyring.ts @@ -1,8 +1,8 @@ import { KeyringPair } from '@polkadot/keyring/types'; import { Keyring as InnerKeyring } from '@polkadot/ui-keyring/Keyring'; -import { AccountInfo } from '@coong/keyring/types'; import { assert, CoongError, ErrorCode } from '@coong/utils'; import CryptoJS from 'crypto-js'; +import { AccountInfo } from './types'; const ENCRYPTED_MNEMONIC = 'ENCRYPTED_MNEMONIC'; const ACCOUNTS_INDEX = 'ACCOUNTS_INDEX'; diff --git a/packages/keyring/src/index.ts b/packages/keyring/src/index.ts index bf453ef4..ab702e78 100644 --- a/packages/keyring/src/index.ts +++ b/packages/keyring/src/index.ts @@ -1,3 +1,3 @@ -import Keyring from 'Keyring'; +import Keyring from './Keyring'; export default Keyring; diff --git a/packages/keyring/tsconfig.json b/packages/keyring/tsconfig.json index 2f01198f..4112d7ed 100644 --- a/packages/keyring/tsconfig.json +++ b/packages/keyring/tsconfig.json @@ -1,7 +1,7 @@ { "extends": "../../tsconfig.base.json", "compilerOptions": { - "baseUrl": "src", + "baseUrl": "./", "outDir": "dist", "rootDir": "src" }, diff --git a/packages/sdk/src/CoongSdk.ts b/packages/sdk/src/CoongSdk.ts index f60dc722..eb72886e 100644 --- a/packages/sdk/src/CoongSdk.ts +++ b/packages/sdk/src/CoongSdk.ts @@ -1,8 +1,8 @@ import { MessageType, WalletRequestMessage } from '@coong/base/types'; import { assert, assertFalse, CoongError, ErrorCode } from '@coong/utils'; -import { injectWalletAPI, setupWalletMessageHandler } from 'message'; -import EmbedInstance from 'wallet/EmbedInstance'; -import TabInstance from 'wallet/TabInstance'; +import { injectWalletAPI, setupWalletMessageHandler } from './message'; +import EmbedInstance from './wallet/EmbedInstance'; +import TabInstance from './wallet/TabInstance'; const DEFAULT_WALLET_URL = 'https://coongwallet.io'; diff --git a/packages/sdk/src/index.ts b/packages/sdk/src/index.ts index a4905ce1..ed92cdef 100644 --- a/packages/sdk/src/index.ts +++ b/packages/sdk/src/index.ts @@ -1,3 +1,3 @@ -import CoongSdk from 'CoongSdk'; +import CoongSdk from './CoongSdk'; export default CoongSdk; diff --git a/packages/sdk/src/injection/Accounts.ts b/packages/sdk/src/injection/Accounts.ts index 7d38d0f8..05e85a83 100644 --- a/packages/sdk/src/injection/Accounts.ts +++ b/packages/sdk/src/injection/Accounts.ts @@ -1,5 +1,5 @@ import { InjectedAccount, InjectedAccounts, Unsubcall } from '@polkadot/extension-inject/types'; -import { SendMessage } from 'types'; +import { SendMessage } from '../types'; let sendMessage: SendMessage; diff --git a/packages/sdk/src/injection/CoongSigner.ts b/packages/sdk/src/injection/CoongSigner.ts index 1fe6defe..aaac1ae5 100644 --- a/packages/sdk/src/injection/CoongSigner.ts +++ b/packages/sdk/src/injection/CoongSigner.ts @@ -1,6 +1,6 @@ import type { Signer as SignerInterface, SignerResult } from '@polkadot/api/types'; import { SignerPayloadJSON, SignerPayloadRaw } from '@polkadot/types/types/extrinsic'; -import { SendMessage } from 'types'; +import { SendMessage } from '../types'; let sendMessage: SendMessage; diff --git a/packages/sdk/src/injection/Injected.ts b/packages/sdk/src/injection/Injected.ts index b0e248f3..98368cd9 100644 --- a/packages/sdk/src/injection/Injected.ts +++ b/packages/sdk/src/injection/Injected.ts @@ -1,7 +1,7 @@ import { Injected } from '@polkadot/extension-inject/types'; -import Accounts from 'injection/Accounts'; -import CoongSigner from 'injection/CoongSigner'; -import { SendMessage } from 'types'; +import { SendMessage } from '../types'; +import Accounts from './Accounts'; +import CoongSigner from './CoongSigner'; export default class SubstrateInjected implements Injected { public readonly accounts: Accounts; diff --git a/packages/sdk/src/message.ts b/packages/sdk/src/message.ts index 9e35cfcd..d03fb228 100644 --- a/packages/sdk/src/message.ts +++ b/packages/sdk/src/message.ts @@ -3,10 +3,10 @@ import { Injected } from '@polkadot/extension-inject/types'; import { isWalletResponse, newMessageId, newWalletRequest } from '@coong/base'; import { RequestName, WalletRequest, WalletResponse, WalletResponseMessage } from '@coong/base/types'; import { assert } from '@coong/utils'; -import CoongSdk from 'CoongSdk'; -import SubstrateInjected from 'injection/Injected'; -import { Handlers } from 'types'; -import WalletInstance from 'wallet/WalletInstance'; +import CoongSdk from './CoongSdk'; +import SubstrateInjected from './injection/Injected'; +import { Handlers } from './types'; +import WalletInstance from './wallet/WalletInstance'; const handlers: Handlers = {}; diff --git a/packages/sdk/src/wallet/EmbedInstance.ts b/packages/sdk/src/wallet/EmbedInstance.ts index 6efa2f48..dc75a4ba 100644 --- a/packages/sdk/src/wallet/EmbedInstance.ts +++ b/packages/sdk/src/wallet/EmbedInstance.ts @@ -1,6 +1,6 @@ import { compareWalletInfo } from '@coong/base'; import { WalletSignal, WalletSignalMessage } from '@coong/base/types'; -import WalletInstance from 'wallet/WalletInstance'; +import WalletInstance from './WalletInstance'; export default class EmbedInstance extends WalletInstance { async initialize() { diff --git a/packages/sdk/src/wallet/TabInstance.ts b/packages/sdk/src/wallet/TabInstance.ts index 4cb8530a..a166e0a6 100644 --- a/packages/sdk/src/wallet/TabInstance.ts +++ b/packages/sdk/src/wallet/TabInstance.ts @@ -1,7 +1,7 @@ import { compareWalletInfo } from '@coong/base'; import { WalletSignal, WalletSignalMessage } from '@coong/base/types'; import { StandardCoongError } from '@coong/utils'; -import WalletInstance from 'wallet/WalletInstance'; +import WalletInstance from './WalletInstance'; export default class TabInstance extends WalletInstance { async openWalletWindow(path = ''): Promise { diff --git a/packages/sdk/tsconfig.json b/packages/sdk/tsconfig.json index ae641400..40320f0d 100644 --- a/packages/sdk/tsconfig.json +++ b/packages/sdk/tsconfig.json @@ -1,7 +1,7 @@ { "extends": "../../tsconfig.base.json", "compilerOptions": { - "baseUrl": "src", + "baseUrl": ".", "outDir": "dist", "rootDir": "src" }, diff --git a/packages/ui/tsconfig.json b/packages/ui/tsconfig.json index 4b656e79..42b401f5 100644 --- a/packages/ui/tsconfig.json +++ b/packages/ui/tsconfig.json @@ -4,7 +4,17 @@ "baseUrl": "src", "lib": ["DOM", "DOM.Iterable", "ESNext"], "jsx": "react-jsx", - "noEmit": true + "noEmit": true, + "paths": { + "@coong/base": ["../../base/src"], + "@coong/base/*": ["../../base/src/*"], + "@coong/keyring": ["../../keyring/src"], + "@coong/keyring/*": ["../../keyring/src/*"], + "@coong/utils": ["../../utils/src"], + "@coong/utils/*": ["../../utils/src/*"], + "@coong/sdk": ["../../sdk/src"], + "@coong/sdk/*": ["../../sdk/src/*"] + } }, "include": ["src/**/*"], "references": [ diff --git a/packages/utils/src/assert.ts b/packages/utils/src/assert.ts index 8956f648..6ea29443 100644 --- a/packages/utils/src/assert.ts +++ b/packages/utils/src/assert.ts @@ -1,4 +1,4 @@ -import { CoongError, ErrorCode, ErrorCodes } from 'errors'; +import { CoongError, ErrorCode, ErrorCodes } from './errors'; export function assert(condition: unknown, message?: string) { if (condition) { diff --git a/packages/utils/src/index.ts b/packages/utils/src/index.ts index 2b002b91..a8a5ddff 100644 --- a/packages/utils/src/index.ts +++ b/packages/utils/src/index.ts @@ -1,4 +1,4 @@ -export { CoongError, ErrorCode, StandardCoongError } from 'errors'; +export { CoongError, ErrorCode, StandardCoongError } from './errors'; export { assert, assertFalse } from './assert'; diff --git a/packages/utils/tsconfig.json b/packages/utils/tsconfig.json index 8fd0796f..3e47b094 100644 --- a/packages/utils/tsconfig.json +++ b/packages/utils/tsconfig.json @@ -1,7 +1,7 @@ { "extends": "../../tsconfig.base.json", "compilerOptions": { - "baseUrl": "src", + "baseUrl": "./", "outDir": "dist", "rootDir": "src" }, diff --git a/tsconfig.base.json b/tsconfig.base.json index 4dccb174..89ad2ee4 100644 --- a/tsconfig.base.json +++ b/tsconfig.base.json @@ -16,14 +16,14 @@ "declaration": true, "composite": true, "paths": { - "@coong/base": ["../../base/src"], - "@coong/base/*": ["../../base/src/*"], - "@coong/keyring": ["../../keyring/src"], - "@coong/keyring/*": ["../../keyring/src/*"], - "@coong/utils": ["../../utils/src"], - "@coong/utils/*": ["../../utils/src/*"], - "@coong/sdk": ["../../sdk/src"], - "@coong/sdk/*": ["../../sdk/src/*"] + "@coong/base": ["../base/src"], + "@coong/base/*": ["../base/src/*"], + "@coong/keyring": ["../keyring/src"], + "@coong/keyring/*": ["../keyring/src/*"], + "@coong/utils": ["../utils/src"], + "@coong/utils/*": ["../utils/src/*"], + "@coong/sdk": ["../sdk/src"], + "@coong/sdk/*": ["../sdk/src/*"] } } } diff --git a/yarn.lock b/yarn.lock index b229b2c3..48ab29fa 100644 --- a/yarn.lock +++ b/yarn.lock @@ -5971,6 +5971,13 @@ typedarray@^0.0.6: resolved "https://registry.yarnpkg.com/typedarray/-/typedarray-0.0.6.tgz#867ac74e3864187b1d3d47d996a78ec5c8830777" integrity sha512-/aCDEGatGvZ2BIk+HmLf4ifCJFwvKFNb9/JeZPMulfgFracn9QFcAf5GO8B/mweUjSoblS5In0cWhqpfs/5PQA== +typescript-transform-paths@^3.4.6: + version "3.4.6" + resolved "https://registry.yarnpkg.com/typescript-transform-paths/-/typescript-transform-paths-3.4.6.tgz#28e6b24eb17a34116484a4b7af7323b8bb756db6" + integrity sha512-qdgpCk9oRHkIBhznxaHAapCFapJt5e4FbFik7Y4qdqtp6VyC3smAIPoDEIkjZ2eiF7x5+QxUPYNwJAtw0thsTw== + dependencies: + minimatch "^3.0.4" + "typescript@^3 || ^4", typescript@^4.9.3: version "4.9.5" resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.9.5.tgz#095979f9bcc0d09da324d58d03ce8f8374cbe65a"