Skip to content

Commit

Permalink
Move shared packages to using relative imports
Browse files Browse the repository at this point in the history
  • Loading branch information
sinzii committed Feb 21, 2023
1 parent eb9bff1 commit 038452d
Show file tree
Hide file tree
Showing 31 changed files with 76 additions and 57 deletions.
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
1 change: 1 addition & 0 deletions packages/base/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
8 changes: 4 additions & 4 deletions packages/base/src/index.ts
Original file line number Diff line number Diff line change
@@ -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';
2 changes: 1 addition & 1 deletion packages/base/src/networks.ts
Original file line number Diff line number Diff line change
@@ -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,
Expand Down
6 changes: 3 additions & 3 deletions packages/base/src/requests/EmbedHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion packages/base/src/requests/Handler.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import WalletState from 'requests/WalletState';
import WalletState from './WalletState';

export default abstract class Handler {
readonly #state: WalletState;
Expand Down
4 changes: 2 additions & 2 deletions packages/base/src/requests/TabHandler.ts
Original file line number Diff line number Diff line change
@@ -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<TRequestName extends RequestName>(
Expand Down
4 changes: 2 additions & 2 deletions packages/base/src/requests/WalletState.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,16 @@ 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,
RequestName,
WalletRequestMessage,
WalletRequestWithResolver,
WalletResponse,
} from 'types';
} from '../types';

export type AppId = string;
export interface AppInfo {
Expand Down
10 changes: 5 additions & 5 deletions packages/base/src/requests/index.ts
Original file line number Diff line number Diff line change
@@ -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);
Expand Down
4 changes: 2 additions & 2 deletions packages/base/src/utils/index.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
export * from 'utils/messageId';
export * from 'utils/walletMessage';
export * from './messageId';
export * from './walletMessage';
2 changes: 1 addition & 1 deletion packages/base/src/utils/messageId.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { MessageId } from 'types';
import { MessageId } from '../types';

let counter = 0;

Expand Down
4 changes: 2 additions & 2 deletions packages/base/src/utils/walletMessage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions packages/base/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{
"extends": "../../tsconfig.base.json",
"compilerOptions": {
"baseUrl": "src",
"baseUrl": "./",
"outDir": "dist",
"rootDir": "src"
"rootDir": "src",
},
"include": ["src/**/*"],
"references": [
Expand Down
2 changes: 1 addition & 1 deletion packages/keyring/src/Keyring.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand Down
2 changes: 1 addition & 1 deletion packages/keyring/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
import Keyring from 'Keyring';
import Keyring from './Keyring';

export default Keyring;
2 changes: 1 addition & 1 deletion packages/keyring/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"extends": "../../tsconfig.base.json",
"compilerOptions": {
"baseUrl": "src",
"baseUrl": "./",
"outDir": "dist",
"rootDir": "src"
},
Expand Down
6 changes: 3 additions & 3 deletions packages/sdk/src/CoongSdk.ts
Original file line number Diff line number Diff line change
@@ -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';

Expand Down
2 changes: 1 addition & 1 deletion packages/sdk/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
import CoongSdk from 'CoongSdk';
import CoongSdk from './CoongSdk';

export default CoongSdk;
2 changes: 1 addition & 1 deletion packages/sdk/src/injection/Accounts.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { InjectedAccount, InjectedAccounts, Unsubcall } from '@polkadot/extension-inject/types';
import { SendMessage } from 'types';
import { SendMessage } from '../types';

let sendMessage: SendMessage;

Expand Down
2 changes: 1 addition & 1 deletion packages/sdk/src/injection/CoongSigner.ts
Original file line number Diff line number Diff line change
@@ -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;

Expand Down
6 changes: 3 additions & 3 deletions packages/sdk/src/injection/Injected.ts
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
8 changes: 4 additions & 4 deletions packages/sdk/src/message.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {};

Expand Down
2 changes: 1 addition & 1 deletion packages/sdk/src/wallet/EmbedInstance.ts
Original file line number Diff line number Diff line change
@@ -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() {
Expand Down
2 changes: 1 addition & 1 deletion packages/sdk/src/wallet/TabInstance.ts
Original file line number Diff line number Diff line change
@@ -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<Window> {
Expand Down
2 changes: 1 addition & 1 deletion packages/sdk/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"extends": "../../tsconfig.base.json",
"compilerOptions": {
"baseUrl": "src",
"baseUrl": ".",
"outDir": "dist",
"rootDir": "src"
},
Expand Down
12 changes: 11 additions & 1 deletion packages/ui/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": [
Expand Down
2 changes: 1 addition & 1 deletion packages/utils/src/assert.ts
Original file line number Diff line number Diff line change
@@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion packages/utils/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export { CoongError, ErrorCode, StandardCoongError } from 'errors';
export { CoongError, ErrorCode, StandardCoongError } from './errors';

export { assert, assertFalse } from './assert';

Expand Down
2 changes: 1 addition & 1 deletion packages/utils/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"extends": "../../tsconfig.base.json",
"compilerOptions": {
"baseUrl": "src",
"baseUrl": "./",
"outDir": "dist",
"rootDir": "src"
},
Expand Down
16 changes: 8 additions & 8 deletions tsconfig.base.json
Original file line number Diff line number Diff line change
Expand Up @@ -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/*"]
}
}
}
7 changes: 7 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit 038452d

Please sign in to comment.