@kheopskit/core 0.0.1-alpha.1 → 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +8 -0
- package/dist/index.d.mts +54 -19
- package/dist/index.d.ts +54 -19
- package/dist/index.js +571 -224
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +610 -241
- package/dist/index.mjs.map +1 -1
- package/package.json +14 -6
- package/src/api/accounts.ts +25 -12
- package/src/api/appKit.ts +122 -0
- package/src/api/config.ts +5 -4
- package/src/api/ethereum/accounts.ts +179 -48
- package/src/api/ethereum/wallets.ts +37 -23
- package/src/api/index.ts +1 -0
- package/src/api/kheopskit.ts +35 -13
- package/src/api/polkadot/accounts.ts +113 -18
- package/src/api/polkadot/wallets.ts +88 -68
- package/src/api/store.ts +6 -3
- package/src/api/types.ts +53 -20
- package/src/api/wallets.ts +15 -13
- package/src/index.ts +0 -2
- package/src/utils/{AccountId.ts → WalletAccountId.ts} +1 -1
- package/src/utils/WalletId.ts +1 -1
- package/src/utils/createStore.ts +1 -1
- package/src/utils/getAccountAddressType.ts +2 -1
- package/src/utils/getCachedObservable.ts +12 -0
- package/src/utils/getQuery.ts +72 -0
- package/src/utils/index.ts +1 -3
- package/src/utils/isEthereumAddress.ts +3 -1
- package/src/utils/isSs58Address.ts +2 -2
- package/src/utils/isWalletPlatform.ts +1 -1
- package/src/utils/logObservable.ts +21 -0
- package/src/utils/polkadotExtensions.ts +21 -0
- package/src/utils/sortAccounts.ts +36 -0
- package/src/utils/sortWallets.ts +14 -0
- package/src/utils/isTruthy.ts +0 -3
- package/src/utils/types.ts +0 -5
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
# @kheopskit/core
|
|
2
2
|
|
|
3
|
+
## 0.0.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [`e1cebed`](https://github.com/kheopskit/kheopskit/commit/e1cebed92d303f041070e0ae146ee34d9eb717bd) Thanks [@0xKheops](https://github.com/0xKheops)! - refactor property names
|
|
8
|
+
|
|
9
|
+
- [`e1cebed`](https://github.com/kheopskit/kheopskit/commit/e1cebed92d303f041070e0ae146ee34d9eb717bd) Thanks [@0xKheops](https://github.com/0xKheops)! - initial alpha release
|
|
10
|
+
|
|
3
11
|
## 0.0.1-alpha.1
|
|
4
12
|
|
|
5
13
|
### Patch Changes
|
package/dist/index.d.mts
CHANGED
|
@@ -1,38 +1,57 @@
|
|
|
1
1
|
import { Observable } from 'rxjs';
|
|
2
|
-
import {
|
|
2
|
+
import { AppKit } from '@reown/appkit/core';
|
|
3
|
+
import { AppKitNetwork } from '@reown/appkit/networks';
|
|
4
|
+
import { Metadata } from '@walletconnect/universal-provider';
|
|
3
5
|
import { InjectedExtension, InjectedPolkadotAccount } from 'polkadot-api/pjs-signer';
|
|
4
|
-
|
|
5
|
-
type WalletId = string;
|
|
6
|
+
import { EIP1193Provider, WalletClient, CustomTransport, Account } from 'viem';
|
|
6
7
|
|
|
7
8
|
type WalletAccountId = string;
|
|
8
9
|
|
|
9
|
-
type
|
|
10
|
-
|
|
11
|
-
};
|
|
10
|
+
type WalletId = string;
|
|
11
|
+
|
|
12
12
|
type KheopskitConfig = {
|
|
13
|
-
autoReconnect
|
|
13
|
+
autoReconnect: boolean;
|
|
14
14
|
platforms: WalletPlatform[];
|
|
15
|
+
walletConnect?: {
|
|
16
|
+
projectId: string;
|
|
17
|
+
metadata: Metadata;
|
|
18
|
+
/** Defaults to wss://relay.walletconnect.com */
|
|
19
|
+
relayUrl?: string;
|
|
20
|
+
/**
|
|
21
|
+
* list of CAIP-13 ids of polkadot-sdk chains
|
|
22
|
+
* see https://docs.reown.com/advanced/multichain/polkadot/dapp-integration-guide#walletconnect-code%2Fcomponent-setup
|
|
23
|
+
*/
|
|
24
|
+
networks: [AppKitNetwork, ...AppKitNetwork[]];
|
|
25
|
+
};
|
|
26
|
+
debug: boolean;
|
|
15
27
|
};
|
|
16
|
-
type
|
|
28
|
+
type PolkadotInjectedWallet = {
|
|
17
29
|
id: WalletId;
|
|
18
30
|
platform: "polkadot";
|
|
31
|
+
type: "injected";
|
|
19
32
|
extensionId: string;
|
|
33
|
+
extension: InjectedExtension | undefined;
|
|
20
34
|
name: string;
|
|
21
|
-
|
|
35
|
+
icon: string;
|
|
36
|
+
isConnected: boolean;
|
|
22
37
|
connect: () => Promise<void>;
|
|
38
|
+
disconnect: () => void;
|
|
23
39
|
};
|
|
24
|
-
type
|
|
40
|
+
type PolkadotAppKitWallet = {
|
|
25
41
|
id: WalletId;
|
|
26
42
|
platform: "polkadot";
|
|
27
|
-
|
|
28
|
-
|
|
43
|
+
type: "appKit";
|
|
44
|
+
appKit: AppKit;
|
|
29
45
|
name: string;
|
|
30
|
-
|
|
46
|
+
icon: string;
|
|
47
|
+
isConnected: boolean;
|
|
48
|
+
connect: () => Promise<void>;
|
|
31
49
|
disconnect: () => void;
|
|
32
50
|
};
|
|
33
|
-
type PolkadotWallet =
|
|
34
|
-
type
|
|
51
|
+
type PolkadotWallet = PolkadotInjectedWallet | PolkadotAppKitWallet;
|
|
52
|
+
type EthereumInjectedWallet = {
|
|
35
53
|
platform: "ethereum";
|
|
54
|
+
type: "injected";
|
|
36
55
|
id: WalletId;
|
|
37
56
|
providerId: string;
|
|
38
57
|
provider: EIP1193Provider;
|
|
@@ -42,6 +61,18 @@ type EthereumWallet = {
|
|
|
42
61
|
connect: () => Promise<void>;
|
|
43
62
|
disconnect: () => void;
|
|
44
63
|
};
|
|
64
|
+
type EthereumAppKitWallet = {
|
|
65
|
+
platform: "ethereum";
|
|
66
|
+
type: "appKit";
|
|
67
|
+
id: WalletId;
|
|
68
|
+
appKit: AppKit;
|
|
69
|
+
name: string;
|
|
70
|
+
icon: string;
|
|
71
|
+
isConnected: boolean;
|
|
72
|
+
connect: () => Promise<void>;
|
|
73
|
+
disconnect: () => void;
|
|
74
|
+
};
|
|
75
|
+
type EthereumWallet = EthereumInjectedWallet | EthereumAppKitWallet;
|
|
45
76
|
type Wallet = PolkadotWallet | EthereumWallet;
|
|
46
77
|
type WalletPlatform = Wallet["platform"];
|
|
47
78
|
type PolkadotAccount = InjectedPolkadotAccount & {
|
|
@@ -53,7 +84,7 @@ type PolkadotAccount = InjectedPolkadotAccount & {
|
|
|
53
84
|
type EthereumAccount = {
|
|
54
85
|
id: WalletAccountId;
|
|
55
86
|
platform: "ethereum";
|
|
56
|
-
|
|
87
|
+
client: WalletClient<CustomTransport, undefined, Account, undefined>;
|
|
57
88
|
address: `0x${string}`;
|
|
58
89
|
walletName: string;
|
|
59
90
|
walletId: string;
|
|
@@ -61,9 +92,13 @@ type EthereumAccount = {
|
|
|
61
92
|
};
|
|
62
93
|
type WalletAccount = PolkadotAccount | EthereumAccount;
|
|
63
94
|
|
|
64
|
-
|
|
95
|
+
type KheopskitState = {
|
|
65
96
|
wallets: Wallet[];
|
|
66
97
|
accounts: WalletAccount[];
|
|
67
|
-
|
|
98
|
+
config: KheopskitConfig;
|
|
99
|
+
};
|
|
100
|
+
declare const getKheopskit$: (config?: Partial<KheopskitConfig>) => Observable<KheopskitState>;
|
|
101
|
+
|
|
102
|
+
declare const resolveConfig: (config: Partial<KheopskitConfig> | undefined) => KheopskitConfig;
|
|
68
103
|
|
|
69
|
-
export { type EthereumAccount, type EthereumWallet, type KheopskitConfig, type
|
|
104
|
+
export { type EthereumAccount, type EthereumAppKitWallet, type EthereumInjectedWallet, type EthereumWallet, type KheopskitConfig, type KheopskitState, type PolkadotAccount, type PolkadotAppKitWallet, type PolkadotInjectedWallet, type PolkadotWallet, type Wallet, type WalletAccount, type WalletPlatform, getKheopskit$, resolveConfig };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,38 +1,57 @@
|
|
|
1
1
|
import { Observable } from 'rxjs';
|
|
2
|
-
import {
|
|
2
|
+
import { AppKit } from '@reown/appkit/core';
|
|
3
|
+
import { AppKitNetwork } from '@reown/appkit/networks';
|
|
4
|
+
import { Metadata } from '@walletconnect/universal-provider';
|
|
3
5
|
import { InjectedExtension, InjectedPolkadotAccount } from 'polkadot-api/pjs-signer';
|
|
4
|
-
|
|
5
|
-
type WalletId = string;
|
|
6
|
+
import { EIP1193Provider, WalletClient, CustomTransport, Account } from 'viem';
|
|
6
7
|
|
|
7
8
|
type WalletAccountId = string;
|
|
8
9
|
|
|
9
|
-
type
|
|
10
|
-
|
|
11
|
-
};
|
|
10
|
+
type WalletId = string;
|
|
11
|
+
|
|
12
12
|
type KheopskitConfig = {
|
|
13
|
-
autoReconnect
|
|
13
|
+
autoReconnect: boolean;
|
|
14
14
|
platforms: WalletPlatform[];
|
|
15
|
+
walletConnect?: {
|
|
16
|
+
projectId: string;
|
|
17
|
+
metadata: Metadata;
|
|
18
|
+
/** Defaults to wss://relay.walletconnect.com */
|
|
19
|
+
relayUrl?: string;
|
|
20
|
+
/**
|
|
21
|
+
* list of CAIP-13 ids of polkadot-sdk chains
|
|
22
|
+
* see https://docs.reown.com/advanced/multichain/polkadot/dapp-integration-guide#walletconnect-code%2Fcomponent-setup
|
|
23
|
+
*/
|
|
24
|
+
networks: [AppKitNetwork, ...AppKitNetwork[]];
|
|
25
|
+
};
|
|
26
|
+
debug: boolean;
|
|
15
27
|
};
|
|
16
|
-
type
|
|
28
|
+
type PolkadotInjectedWallet = {
|
|
17
29
|
id: WalletId;
|
|
18
30
|
platform: "polkadot";
|
|
31
|
+
type: "injected";
|
|
19
32
|
extensionId: string;
|
|
33
|
+
extension: InjectedExtension | undefined;
|
|
20
34
|
name: string;
|
|
21
|
-
|
|
35
|
+
icon: string;
|
|
36
|
+
isConnected: boolean;
|
|
22
37
|
connect: () => Promise<void>;
|
|
38
|
+
disconnect: () => void;
|
|
23
39
|
};
|
|
24
|
-
type
|
|
40
|
+
type PolkadotAppKitWallet = {
|
|
25
41
|
id: WalletId;
|
|
26
42
|
platform: "polkadot";
|
|
27
|
-
|
|
28
|
-
|
|
43
|
+
type: "appKit";
|
|
44
|
+
appKit: AppKit;
|
|
29
45
|
name: string;
|
|
30
|
-
|
|
46
|
+
icon: string;
|
|
47
|
+
isConnected: boolean;
|
|
48
|
+
connect: () => Promise<void>;
|
|
31
49
|
disconnect: () => void;
|
|
32
50
|
};
|
|
33
|
-
type PolkadotWallet =
|
|
34
|
-
type
|
|
51
|
+
type PolkadotWallet = PolkadotInjectedWallet | PolkadotAppKitWallet;
|
|
52
|
+
type EthereumInjectedWallet = {
|
|
35
53
|
platform: "ethereum";
|
|
54
|
+
type: "injected";
|
|
36
55
|
id: WalletId;
|
|
37
56
|
providerId: string;
|
|
38
57
|
provider: EIP1193Provider;
|
|
@@ -42,6 +61,18 @@ type EthereumWallet = {
|
|
|
42
61
|
connect: () => Promise<void>;
|
|
43
62
|
disconnect: () => void;
|
|
44
63
|
};
|
|
64
|
+
type EthereumAppKitWallet = {
|
|
65
|
+
platform: "ethereum";
|
|
66
|
+
type: "appKit";
|
|
67
|
+
id: WalletId;
|
|
68
|
+
appKit: AppKit;
|
|
69
|
+
name: string;
|
|
70
|
+
icon: string;
|
|
71
|
+
isConnected: boolean;
|
|
72
|
+
connect: () => Promise<void>;
|
|
73
|
+
disconnect: () => void;
|
|
74
|
+
};
|
|
75
|
+
type EthereumWallet = EthereumInjectedWallet | EthereumAppKitWallet;
|
|
45
76
|
type Wallet = PolkadotWallet | EthereumWallet;
|
|
46
77
|
type WalletPlatform = Wallet["platform"];
|
|
47
78
|
type PolkadotAccount = InjectedPolkadotAccount & {
|
|
@@ -53,7 +84,7 @@ type PolkadotAccount = InjectedPolkadotAccount & {
|
|
|
53
84
|
type EthereumAccount = {
|
|
54
85
|
id: WalletAccountId;
|
|
55
86
|
platform: "ethereum";
|
|
56
|
-
|
|
87
|
+
client: WalletClient<CustomTransport, undefined, Account, undefined>;
|
|
57
88
|
address: `0x${string}`;
|
|
58
89
|
walletName: string;
|
|
59
90
|
walletId: string;
|
|
@@ -61,9 +92,13 @@ type EthereumAccount = {
|
|
|
61
92
|
};
|
|
62
93
|
type WalletAccount = PolkadotAccount | EthereumAccount;
|
|
63
94
|
|
|
64
|
-
|
|
95
|
+
type KheopskitState = {
|
|
65
96
|
wallets: Wallet[];
|
|
66
97
|
accounts: WalletAccount[];
|
|
67
|
-
|
|
98
|
+
config: KheopskitConfig;
|
|
99
|
+
};
|
|
100
|
+
declare const getKheopskit$: (config?: Partial<KheopskitConfig>) => Observable<KheopskitState>;
|
|
101
|
+
|
|
102
|
+
declare const resolveConfig: (config: Partial<KheopskitConfig> | undefined) => KheopskitConfig;
|
|
68
103
|
|
|
69
|
-
export { type EthereumAccount, type EthereumWallet, type KheopskitConfig, type
|
|
104
|
+
export { type EthereumAccount, type EthereumAppKitWallet, type EthereumInjectedWallet, type EthereumWallet, type KheopskitConfig, type KheopskitState, type PolkadotAccount, type PolkadotAppKitWallet, type PolkadotInjectedWallet, type PolkadotWallet, type Wallet, type WalletAccount, type WalletPlatform, getKheopskit$, resolveConfig };
|