@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 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 { EIP1193Provider } from 'viem';
3
- import { InjectedPolkadotAccount, InjectedExtension, InjectedAccount, PolkadotSigner } from 'polkadot-api/pjs-signer';
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 WalletId = string;
6
-
7
- type AccountId = string;
8
+ type WalletAccountId = string;
8
9
 
9
- type PolkadotAccount = InjectedPolkadotAccount & {
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?: boolean;
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 PolkadotDisabledInjectedWallet = {
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
- isEnabled: false;
35
+ icon: string;
36
+ isConnected: boolean;
62
37
  connect: () => Promise<void>;
38
+ disconnect: () => void;
63
39
  };
64
- type PolkadotEnabledInjectedWallet = {
40
+ type PolkadotAppKitWallet = {
65
41
  id: WalletId;
66
42
  platform: "polkadot";
67
- extensionId: string;
68
- extension: InjectedExtension;
43
+ type: "appKit";
44
+ appKit: AppKit;
69
45
  name: string;
70
- isEnabled: true;
46
+ icon: string;
47
+ isConnected: boolean;
48
+ connect: () => Promise<void>;
71
49
  disconnect: () => void;
72
50
  };
73
- type PolkadotWallet = PolkadotDisabledInjectedWallet | PolkadotEnabledInjectedWallet;
74
- type EthereumWallet = {
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
- isEnabled: boolean;
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
- declare const getKheopskit$: (config: KheopskitConfig) => Observable<{
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 Account, type AccountStorage, type EthereumAccountStorage, type EthereumWallet, type KheopskitConfig, type KheopskitStoreData, type PlatformData, type PolkadotAccountStorage, type PolkadotDisabledInjectedWallet, type PolkadotEnabledInjectedWallet, type PolkadotWallet, type Wallet, type WalletAccount, type WalletPlatform, getKheopskit$ };
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 { EIP1193Provider } from 'viem';
3
- import { InjectedPolkadotAccount, InjectedExtension, InjectedAccount, PolkadotSigner } from 'polkadot-api/pjs-signer';
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 WalletId = string;
6
-
7
- type AccountId = string;
8
+ type WalletAccountId = string;
8
9
 
9
- type PolkadotAccount = InjectedPolkadotAccount & {
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?: boolean;
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 PolkadotDisabledInjectedWallet = {
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
- isEnabled: false;
35
+ icon: string;
36
+ isConnected: boolean;
62
37
  connect: () => Promise<void>;
38
+ disconnect: () => void;
63
39
  };
64
- type PolkadotEnabledInjectedWallet = {
40
+ type PolkadotAppKitWallet = {
65
41
  id: WalletId;
66
42
  platform: "polkadot";
67
- extensionId: string;
68
- extension: InjectedExtension;
43
+ type: "appKit";
44
+ appKit: AppKit;
69
45
  name: string;
70
- isEnabled: true;
46
+ icon: string;
47
+ isConnected: boolean;
48
+ connect: () => Promise<void>;
71
49
  disconnect: () => void;
72
50
  };
73
- type PolkadotWallet = PolkadotDisabledInjectedWallet | PolkadotEnabledInjectedWallet;
74
- type EthereumWallet = {
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
- isEnabled: boolean;
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
- declare const getKheopskit$: (config: KheopskitConfig) => Observable<{
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 Account, type AccountStorage, type EthereumAccountStorage, type EthereumWallet, type KheopskitConfig, type KheopskitStoreData, type PlatformData, type PolkadotAccountStorage, type PolkadotDisabledInjectedWallet, type PolkadotEnabledInjectedWallet, type PolkadotWallet, type Wallet, type WalletAccount, type WalletPlatform, getKheopskit$ };
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 };