@kheopskit/core 0.0.1-alpha.0 → 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 +14 -0
- package/dist/index.d.mts +70 -60
- package/dist/index.d.ts +70 -60
- package/dist/index.js +574 -227
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +613 -244
- 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 +183 -62
- package/src/api/ethereum/wallets.ts +38 -24
- package/src/api/index.ts +1 -0
- package/src/api/kheopskit.ts +35 -13
- package/src/api/polkadot/accounts.ts +117 -29
- package/src/api/polkadot/wallets.ts +88 -68
- package/src/api/store.ts +6 -3
- package/src/api/types.ts +71 -54
- package/src/api/wallets.ts +16 -14
- package/src/index.ts +0 -2
- package/src/utils/{AccountId.ts → WalletAccountId.ts} +5 -5
- 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,19 @@
|
|
|
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
|
+
|
|
11
|
+
## 0.0.1-alpha.1
|
|
12
|
+
|
|
13
|
+
### Patch Changes
|
|
14
|
+
|
|
15
|
+
- [`4f378f9`](https://github.com/0xKheops/kheopskit-alpha/commit/4f378f9b61e555b7b66ef3bfaf107ab8e6ac62b1) Thanks [@0xKheops](https://github.com/0xKheops)! - refactor property names
|
|
16
|
+
|
|
3
17
|
## 0.0.1-alpha.0
|
|
4
18
|
|
|
5
19
|
### Patch Changes
|
package/dist/index.d.mts
CHANGED
|
@@ -1,94 +1,104 @@
|
|
|
1
1
|
import { Observable } from 'rxjs';
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
2
|
+
import { AppKit } from '@reown/appkit/core';
|
|
3
|
+
import { AppKitNetwork } from '@reown/appkit/networks';
|
|
4
|
+
import { Metadata } from '@walletconnect/universal-provider';
|
|
5
|
+
import { InjectedExtension, InjectedPolkadotAccount } from 'polkadot-api/pjs-signer';
|
|
6
|
+
import { EIP1193Provider, WalletClient, CustomTransport, Account } from 'viem';
|
|
4
7
|
|
|
5
|
-
type
|
|
6
|
-
|
|
7
|
-
type AccountId = string;
|
|
8
|
+
type WalletAccountId = string;
|
|
8
9
|
|
|
9
|
-
type
|
|
10
|
-
id: AccountId;
|
|
11
|
-
platform: "polkadot";
|
|
12
|
-
walletName: string;
|
|
13
|
-
walletId: string;
|
|
14
|
-
};
|
|
15
|
-
|
|
16
|
-
type EthereumAccount = {
|
|
17
|
-
id: AccountId;
|
|
18
|
-
platform: "ethereum";
|
|
19
|
-
provider: EIP1193Provider;
|
|
20
|
-
address: `0x${string}`;
|
|
21
|
-
walletName: string;
|
|
22
|
-
walletId: string;
|
|
23
|
-
isWalletDefault: boolean;
|
|
24
|
-
};
|
|
10
|
+
type WalletId = string;
|
|
25
11
|
|
|
26
|
-
type AccountStorageBase = {
|
|
27
|
-
wallet: string;
|
|
28
|
-
address: string;
|
|
29
|
-
};
|
|
30
|
-
type EthereumAccountStorage = AccountStorageBase & {
|
|
31
|
-
platform: "ethereum";
|
|
32
|
-
};
|
|
33
|
-
type PolkadotAccountStorage = AccountStorageBase & {
|
|
34
|
-
platform: "polkadot";
|
|
35
|
-
name: InjectedAccount["name"];
|
|
36
|
-
type: InjectedAccount["type"];
|
|
37
|
-
genesisHash: InjectedAccount["genesisHash"];
|
|
38
|
-
};
|
|
39
|
-
type AccountStorage = PolkadotAccountStorage | EthereumAccountStorage;
|
|
40
|
-
type Account<T extends AccountStorage> = T & {
|
|
41
|
-
id: string;
|
|
42
|
-
signer: T extends PolkadotAccountStorage ? PolkadotSigner : null;
|
|
43
|
-
};
|
|
44
|
-
type PlatformData<T extends AccountStorageBase> = {
|
|
45
|
-
enabledExtensionIds: string[];
|
|
46
|
-
accounts: T[];
|
|
47
|
-
defaultAccountId: string | null;
|
|
48
|
-
};
|
|
49
|
-
type KheopskitStoreData = {
|
|
50
|
-
autoReconnect?: WalletId[];
|
|
51
|
-
};
|
|
52
12
|
type KheopskitConfig = {
|
|
53
|
-
autoReconnect
|
|
13
|
+
autoReconnect: boolean;
|
|
54
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;
|
|
55
27
|
};
|
|
56
|
-
type
|
|
28
|
+
type PolkadotInjectedWallet = {
|
|
57
29
|
id: WalletId;
|
|
58
30
|
platform: "polkadot";
|
|
31
|
+
type: "injected";
|
|
59
32
|
extensionId: string;
|
|
33
|
+
extension: InjectedExtension | undefined;
|
|
60
34
|
name: string;
|
|
61
|
-
|
|
35
|
+
icon: string;
|
|
36
|
+
isConnected: boolean;
|
|
62
37
|
connect: () => Promise<void>;
|
|
38
|
+
disconnect: () => void;
|
|
63
39
|
};
|
|
64
|
-
type
|
|
40
|
+
type PolkadotAppKitWallet = {
|
|
65
41
|
id: WalletId;
|
|
66
42
|
platform: "polkadot";
|
|
67
|
-
|
|
68
|
-
|
|
43
|
+
type: "appKit";
|
|
44
|
+
appKit: AppKit;
|
|
69
45
|
name: string;
|
|
70
|
-
|
|
46
|
+
icon: string;
|
|
47
|
+
isConnected: boolean;
|
|
48
|
+
connect: () => Promise<void>;
|
|
71
49
|
disconnect: () => void;
|
|
72
50
|
};
|
|
73
|
-
type PolkadotWallet =
|
|
74
|
-
type
|
|
51
|
+
type PolkadotWallet = PolkadotInjectedWallet | PolkadotAppKitWallet;
|
|
52
|
+
type EthereumInjectedWallet = {
|
|
75
53
|
platform: "ethereum";
|
|
54
|
+
type: "injected";
|
|
76
55
|
id: WalletId;
|
|
77
56
|
providerId: string;
|
|
78
57
|
provider: EIP1193Provider;
|
|
79
58
|
name: string;
|
|
80
59
|
icon: string;
|
|
81
|
-
|
|
60
|
+
isConnected: boolean;
|
|
82
61
|
connect: () => Promise<void>;
|
|
83
62
|
disconnect: () => void;
|
|
84
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;
|
|
85
76
|
type Wallet = PolkadotWallet | EthereumWallet;
|
|
86
77
|
type WalletPlatform = Wallet["platform"];
|
|
78
|
+
type PolkadotAccount = InjectedPolkadotAccount & {
|
|
79
|
+
id: WalletAccountId;
|
|
80
|
+
platform: "polkadot";
|
|
81
|
+
walletName: string;
|
|
82
|
+
walletId: string;
|
|
83
|
+
};
|
|
84
|
+
type EthereumAccount = {
|
|
85
|
+
id: WalletAccountId;
|
|
86
|
+
platform: "ethereum";
|
|
87
|
+
client: WalletClient<CustomTransport, undefined, Account, undefined>;
|
|
88
|
+
address: `0x${string}`;
|
|
89
|
+
walletName: string;
|
|
90
|
+
walletId: string;
|
|
91
|
+
isWalletDefault: boolean;
|
|
92
|
+
};
|
|
87
93
|
type WalletAccount = PolkadotAccount | EthereumAccount;
|
|
88
94
|
|
|
89
|
-
|
|
95
|
+
type KheopskitState = {
|
|
90
96
|
wallets: Wallet[];
|
|
91
97
|
accounts: WalletAccount[];
|
|
92
|
-
|
|
98
|
+
config: KheopskitConfig;
|
|
99
|
+
};
|
|
100
|
+
declare const getKheopskit$: (config?: Partial<KheopskitConfig>) => Observable<KheopskitState>;
|
|
101
|
+
|
|
102
|
+
declare const resolveConfig: (config: Partial<KheopskitConfig> | undefined) => KheopskitConfig;
|
|
93
103
|
|
|
94
|
-
export { 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,94 +1,104 @@
|
|
|
1
1
|
import { Observable } from 'rxjs';
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
2
|
+
import { AppKit } from '@reown/appkit/core';
|
|
3
|
+
import { AppKitNetwork } from '@reown/appkit/networks';
|
|
4
|
+
import { Metadata } from '@walletconnect/universal-provider';
|
|
5
|
+
import { InjectedExtension, InjectedPolkadotAccount } from 'polkadot-api/pjs-signer';
|
|
6
|
+
import { EIP1193Provider, WalletClient, CustomTransport, Account } from 'viem';
|
|
4
7
|
|
|
5
|
-
type
|
|
6
|
-
|
|
7
|
-
type AccountId = string;
|
|
8
|
+
type WalletAccountId = string;
|
|
8
9
|
|
|
9
|
-
type
|
|
10
|
-
id: AccountId;
|
|
11
|
-
platform: "polkadot";
|
|
12
|
-
walletName: string;
|
|
13
|
-
walletId: string;
|
|
14
|
-
};
|
|
15
|
-
|
|
16
|
-
type EthereumAccount = {
|
|
17
|
-
id: AccountId;
|
|
18
|
-
platform: "ethereum";
|
|
19
|
-
provider: EIP1193Provider;
|
|
20
|
-
address: `0x${string}`;
|
|
21
|
-
walletName: string;
|
|
22
|
-
walletId: string;
|
|
23
|
-
isWalletDefault: boolean;
|
|
24
|
-
};
|
|
10
|
+
type WalletId = string;
|
|
25
11
|
|
|
26
|
-
type AccountStorageBase = {
|
|
27
|
-
wallet: string;
|
|
28
|
-
address: string;
|
|
29
|
-
};
|
|
30
|
-
type EthereumAccountStorage = AccountStorageBase & {
|
|
31
|
-
platform: "ethereum";
|
|
32
|
-
};
|
|
33
|
-
type PolkadotAccountStorage = AccountStorageBase & {
|
|
34
|
-
platform: "polkadot";
|
|
35
|
-
name: InjectedAccount["name"];
|
|
36
|
-
type: InjectedAccount["type"];
|
|
37
|
-
genesisHash: InjectedAccount["genesisHash"];
|
|
38
|
-
};
|
|
39
|
-
type AccountStorage = PolkadotAccountStorage | EthereumAccountStorage;
|
|
40
|
-
type Account<T extends AccountStorage> = T & {
|
|
41
|
-
id: string;
|
|
42
|
-
signer: T extends PolkadotAccountStorage ? PolkadotSigner : null;
|
|
43
|
-
};
|
|
44
|
-
type PlatformData<T extends AccountStorageBase> = {
|
|
45
|
-
enabledExtensionIds: string[];
|
|
46
|
-
accounts: T[];
|
|
47
|
-
defaultAccountId: string | null;
|
|
48
|
-
};
|
|
49
|
-
type KheopskitStoreData = {
|
|
50
|
-
autoReconnect?: WalletId[];
|
|
51
|
-
};
|
|
52
12
|
type KheopskitConfig = {
|
|
53
|
-
autoReconnect
|
|
13
|
+
autoReconnect: boolean;
|
|
54
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;
|
|
55
27
|
};
|
|
56
|
-
type
|
|
28
|
+
type PolkadotInjectedWallet = {
|
|
57
29
|
id: WalletId;
|
|
58
30
|
platform: "polkadot";
|
|
31
|
+
type: "injected";
|
|
59
32
|
extensionId: string;
|
|
33
|
+
extension: InjectedExtension | undefined;
|
|
60
34
|
name: string;
|
|
61
|
-
|
|
35
|
+
icon: string;
|
|
36
|
+
isConnected: boolean;
|
|
62
37
|
connect: () => Promise<void>;
|
|
38
|
+
disconnect: () => void;
|
|
63
39
|
};
|
|
64
|
-
type
|
|
40
|
+
type PolkadotAppKitWallet = {
|
|
65
41
|
id: WalletId;
|
|
66
42
|
platform: "polkadot";
|
|
67
|
-
|
|
68
|
-
|
|
43
|
+
type: "appKit";
|
|
44
|
+
appKit: AppKit;
|
|
69
45
|
name: string;
|
|
70
|
-
|
|
46
|
+
icon: string;
|
|
47
|
+
isConnected: boolean;
|
|
48
|
+
connect: () => Promise<void>;
|
|
71
49
|
disconnect: () => void;
|
|
72
50
|
};
|
|
73
|
-
type PolkadotWallet =
|
|
74
|
-
type
|
|
51
|
+
type PolkadotWallet = PolkadotInjectedWallet | PolkadotAppKitWallet;
|
|
52
|
+
type EthereumInjectedWallet = {
|
|
75
53
|
platform: "ethereum";
|
|
54
|
+
type: "injected";
|
|
76
55
|
id: WalletId;
|
|
77
56
|
providerId: string;
|
|
78
57
|
provider: EIP1193Provider;
|
|
79
58
|
name: string;
|
|
80
59
|
icon: string;
|
|
81
|
-
|
|
60
|
+
isConnected: boolean;
|
|
82
61
|
connect: () => Promise<void>;
|
|
83
62
|
disconnect: () => void;
|
|
84
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;
|
|
85
76
|
type Wallet = PolkadotWallet | EthereumWallet;
|
|
86
77
|
type WalletPlatform = Wallet["platform"];
|
|
78
|
+
type PolkadotAccount = InjectedPolkadotAccount & {
|
|
79
|
+
id: WalletAccountId;
|
|
80
|
+
platform: "polkadot";
|
|
81
|
+
walletName: string;
|
|
82
|
+
walletId: string;
|
|
83
|
+
};
|
|
84
|
+
type EthereumAccount = {
|
|
85
|
+
id: WalletAccountId;
|
|
86
|
+
platform: "ethereum";
|
|
87
|
+
client: WalletClient<CustomTransport, undefined, Account, undefined>;
|
|
88
|
+
address: `0x${string}`;
|
|
89
|
+
walletName: string;
|
|
90
|
+
walletId: string;
|
|
91
|
+
isWalletDefault: boolean;
|
|
92
|
+
};
|
|
87
93
|
type WalletAccount = PolkadotAccount | EthereumAccount;
|
|
88
94
|
|
|
89
|
-
|
|
95
|
+
type KheopskitState = {
|
|
90
96
|
wallets: Wallet[];
|
|
91
97
|
accounts: WalletAccount[];
|
|
92
|
-
|
|
98
|
+
config: KheopskitConfig;
|
|
99
|
+
};
|
|
100
|
+
declare const getKheopskit$: (config?: Partial<KheopskitConfig>) => Observable<KheopskitState>;
|
|
101
|
+
|
|
102
|
+
declare const resolveConfig: (config: Partial<KheopskitConfig> | undefined) => KheopskitConfig;
|
|
93
103
|
|
|
94
|
-
export { 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 };
|