@vaultkeepr/smart-account 0.1.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/LICENSE +21 -0
- package/dist/index.d.mts +159 -0
- package/dist/index.d.ts +159 -0
- package/dist/index.js +684 -0
- package/dist/index.mjs +635 -0
- package/package.json +41 -0
- package/src/index.ts +73 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 VaultKeepR
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
import { LocalAccount, Address, Chain } from 'viem';
|
|
2
|
+
import { createBundlerClient } from 'viem/account-abstraction';
|
|
3
|
+
|
|
4
|
+
interface VaultSmartAccount {
|
|
5
|
+
address: Address;
|
|
6
|
+
ownerAddress: Address;
|
|
7
|
+
ownerAccount: LocalAccount;
|
|
8
|
+
client: ReturnType<typeof createBundlerClient>;
|
|
9
|
+
chain: Chain;
|
|
10
|
+
mode: "passkey" | "password" | "biometric";
|
|
11
|
+
}
|
|
12
|
+
interface CreateSmartAccountParams {
|
|
13
|
+
ownerAccount: LocalAccount;
|
|
14
|
+
mode: "passkey" | "password" | "biometric";
|
|
15
|
+
}
|
|
16
|
+
declare function computeSmartAccountAddress(ownerAccount: LocalAccount): Promise<Address>;
|
|
17
|
+
declare function createVaultSmartAccount(params: CreateSmartAccountParams): Promise<VaultSmartAccount>;
|
|
18
|
+
declare function getCachedSmartAccountAddress(): Address | null;
|
|
19
|
+
declare function getCachedSmartAccountMode(): VaultSmartAccount["mode"] | null;
|
|
20
|
+
declare function clearSmartAccountCache(): void;
|
|
21
|
+
|
|
22
|
+
declare function getOwnerFromPassword(password: string, secretKey?: string): Promise<LocalAccount>;
|
|
23
|
+
|
|
24
|
+
declare const CID_REGISTRY_ABI: readonly [{
|
|
25
|
+
readonly name: "setCid";
|
|
26
|
+
readonly type: "function";
|
|
27
|
+
readonly stateMutability: "nonpayable";
|
|
28
|
+
readonly inputs: readonly [{
|
|
29
|
+
readonly name: "cid";
|
|
30
|
+
readonly type: "string";
|
|
31
|
+
}];
|
|
32
|
+
readonly outputs: readonly [];
|
|
33
|
+
}, {
|
|
34
|
+
readonly name: "deleteCid";
|
|
35
|
+
readonly type: "function";
|
|
36
|
+
readonly stateMutability: "nonpayable";
|
|
37
|
+
readonly inputs: readonly [];
|
|
38
|
+
readonly outputs: readonly [];
|
|
39
|
+
}, {
|
|
40
|
+
readonly name: "getCid";
|
|
41
|
+
readonly type: "function";
|
|
42
|
+
readonly stateMutability: "view";
|
|
43
|
+
readonly inputs: readonly [{
|
|
44
|
+
readonly name: "account";
|
|
45
|
+
readonly type: "address";
|
|
46
|
+
}];
|
|
47
|
+
readonly outputs: readonly [{
|
|
48
|
+
readonly name: "";
|
|
49
|
+
readonly type: "string";
|
|
50
|
+
}];
|
|
51
|
+
}, {
|
|
52
|
+
readonly name: "hasCid";
|
|
53
|
+
readonly type: "function";
|
|
54
|
+
readonly stateMutability: "view";
|
|
55
|
+
readonly inputs: readonly [{
|
|
56
|
+
readonly name: "account";
|
|
57
|
+
readonly type: "address";
|
|
58
|
+
}];
|
|
59
|
+
readonly outputs: readonly [{
|
|
60
|
+
readonly name: "";
|
|
61
|
+
readonly type: "bool";
|
|
62
|
+
}];
|
|
63
|
+
}, {
|
|
64
|
+
readonly name: "getUpdatedAt";
|
|
65
|
+
readonly type: "function";
|
|
66
|
+
readonly stateMutability: "view";
|
|
67
|
+
readonly inputs: readonly [{
|
|
68
|
+
readonly name: "account";
|
|
69
|
+
readonly type: "address";
|
|
70
|
+
}];
|
|
71
|
+
readonly outputs: readonly [{
|
|
72
|
+
readonly name: "";
|
|
73
|
+
readonly type: "uint256";
|
|
74
|
+
}];
|
|
75
|
+
}, {
|
|
76
|
+
readonly name: "nextAllowedUpdate";
|
|
77
|
+
readonly type: "function";
|
|
78
|
+
readonly stateMutability: "view";
|
|
79
|
+
readonly inputs: readonly [{
|
|
80
|
+
readonly name: "account";
|
|
81
|
+
readonly type: "address";
|
|
82
|
+
}];
|
|
83
|
+
readonly outputs: readonly [{
|
|
84
|
+
readonly name: "";
|
|
85
|
+
readonly type: "uint256";
|
|
86
|
+
}];
|
|
87
|
+
}, {
|
|
88
|
+
readonly name: "cooldownSeconds";
|
|
89
|
+
readonly type: "function";
|
|
90
|
+
readonly stateMutability: "view";
|
|
91
|
+
readonly inputs: readonly [];
|
|
92
|
+
readonly outputs: readonly [{
|
|
93
|
+
readonly name: "";
|
|
94
|
+
readonly type: "uint256";
|
|
95
|
+
}];
|
|
96
|
+
}];
|
|
97
|
+
declare function isCidRegistryConfigured(): boolean;
|
|
98
|
+
declare function publishCidOnChain(smartAccount: VaultSmartAccount, cid: string): Promise<`0x${string}` | null>;
|
|
99
|
+
declare function readCidOnChain(smartAccountAddress: Address): Promise<string | null>;
|
|
100
|
+
|
|
101
|
+
declare function getPimlicoApiKey(): string;
|
|
102
|
+
declare function isSmartAccountConfigured(): boolean;
|
|
103
|
+
declare function getTargetChain(): Chain;
|
|
104
|
+
|
|
105
|
+
declare function scheduleCidOnChainSync(smartAccount: VaultSmartAccount | null, cid: string, debounceMs?: number): void;
|
|
106
|
+
declare function flushCidOnChainSync(): Promise<boolean>;
|
|
107
|
+
declare function getOnChainSyncStatus(): {
|
|
108
|
+
hasPending: boolean;
|
|
109
|
+
pendingCid: string | null;
|
|
110
|
+
lastPublishedCid: string | null;
|
|
111
|
+
lastPublishTime: number;
|
|
112
|
+
isPublishing: boolean;
|
|
113
|
+
};
|
|
114
|
+
declare function resetOnChainSync(): void;
|
|
115
|
+
|
|
116
|
+
interface IdentityState {
|
|
117
|
+
owner: LocalAccount | null;
|
|
118
|
+
smartAccount: VaultSmartAccount | null;
|
|
119
|
+
mode: "password" | "passkey" | "biometric" | null;
|
|
120
|
+
initialized: boolean;
|
|
121
|
+
}
|
|
122
|
+
type IdentityListener = (state: IdentityState) => void;
|
|
123
|
+
declare function initIdentityFromPassword(password: string, secretKey?: string): Promise<{
|
|
124
|
+
address: Address;
|
|
125
|
+
smartAccountAddress: Address | null;
|
|
126
|
+
}>;
|
|
127
|
+
declare function initIdentityFromSigner(signer: LocalAccount, mode?: "passkey" | "biometric"): Promise<{
|
|
128
|
+
address: Address;
|
|
129
|
+
smartAccountAddress: Address | null;
|
|
130
|
+
}>;
|
|
131
|
+
declare function clearIdentity(): void;
|
|
132
|
+
declare function getIdentityAddress(): Address | null;
|
|
133
|
+
declare function isIdentityConnected(): boolean;
|
|
134
|
+
declare function getIdentityOwner(): LocalAccount | null;
|
|
135
|
+
declare function getIdentitySmartAccount(): VaultSmartAccount | null;
|
|
136
|
+
declare function getIdentityMode(): IdentityState["mode"];
|
|
137
|
+
declare function signMessageWithIdentity(message: string): Promise<`0x${string}`>;
|
|
138
|
+
declare function subscribeIdentity(listener: IdentityListener): () => void;
|
|
139
|
+
declare function getIdentitySnapshot(): IdentityState;
|
|
140
|
+
|
|
141
|
+
interface UseIdentityReturn {
|
|
142
|
+
address: Address | null;
|
|
143
|
+
isConnected: boolean;
|
|
144
|
+
mode: "password" | "passkey" | "biometric" | null;
|
|
145
|
+
smartAccountAddress: Address | null;
|
|
146
|
+
signMessage: (message: string) => Promise<`0x${string}`>;
|
|
147
|
+
disconnect: () => void;
|
|
148
|
+
notifyOnChainSync: (cid: string) => void;
|
|
149
|
+
cleanupOnLock: () => Promise<void>;
|
|
150
|
+
flushOnChainSync: () => Promise<void>;
|
|
151
|
+
}
|
|
152
|
+
declare function useIdentity(): UseIdentityReturn;
|
|
153
|
+
|
|
154
|
+
declare function generateSecretKey(): string;
|
|
155
|
+
declare function isValidSecretKey(key: string): boolean;
|
|
156
|
+
declare function formatSecretKeyForDisplay(key: string): string;
|
|
157
|
+
declare function parseSecretKeyInput(input: string): string;
|
|
158
|
+
|
|
159
|
+
export { CID_REGISTRY_ABI, type CreateSmartAccountParams, type UseIdentityReturn, type VaultSmartAccount, clearIdentity, clearSmartAccountCache, computeSmartAccountAddress, createVaultSmartAccount, flushCidOnChainSync, formatSecretKeyForDisplay, generateSecretKey, getCachedSmartAccountAddress, getCachedSmartAccountMode, getIdentityAddress, getIdentityMode, getIdentityOwner, getIdentitySmartAccount, getIdentitySnapshot, getOnChainSyncStatus, getOwnerFromPassword, getPimlicoApiKey, getTargetChain, initIdentityFromPassword, initIdentityFromSigner, isCidRegistryConfigured, isIdentityConnected, isSmartAccountConfigured, isValidSecretKey, parseSecretKeyInput, publishCidOnChain, readCidOnChain, resetOnChainSync, scheduleCidOnChainSync, signMessageWithIdentity, subscribeIdentity, useIdentity };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
import { LocalAccount, Address, Chain } from 'viem';
|
|
2
|
+
import { createBundlerClient } from 'viem/account-abstraction';
|
|
3
|
+
|
|
4
|
+
interface VaultSmartAccount {
|
|
5
|
+
address: Address;
|
|
6
|
+
ownerAddress: Address;
|
|
7
|
+
ownerAccount: LocalAccount;
|
|
8
|
+
client: ReturnType<typeof createBundlerClient>;
|
|
9
|
+
chain: Chain;
|
|
10
|
+
mode: "passkey" | "password" | "biometric";
|
|
11
|
+
}
|
|
12
|
+
interface CreateSmartAccountParams {
|
|
13
|
+
ownerAccount: LocalAccount;
|
|
14
|
+
mode: "passkey" | "password" | "biometric";
|
|
15
|
+
}
|
|
16
|
+
declare function computeSmartAccountAddress(ownerAccount: LocalAccount): Promise<Address>;
|
|
17
|
+
declare function createVaultSmartAccount(params: CreateSmartAccountParams): Promise<VaultSmartAccount>;
|
|
18
|
+
declare function getCachedSmartAccountAddress(): Address | null;
|
|
19
|
+
declare function getCachedSmartAccountMode(): VaultSmartAccount["mode"] | null;
|
|
20
|
+
declare function clearSmartAccountCache(): void;
|
|
21
|
+
|
|
22
|
+
declare function getOwnerFromPassword(password: string, secretKey?: string): Promise<LocalAccount>;
|
|
23
|
+
|
|
24
|
+
declare const CID_REGISTRY_ABI: readonly [{
|
|
25
|
+
readonly name: "setCid";
|
|
26
|
+
readonly type: "function";
|
|
27
|
+
readonly stateMutability: "nonpayable";
|
|
28
|
+
readonly inputs: readonly [{
|
|
29
|
+
readonly name: "cid";
|
|
30
|
+
readonly type: "string";
|
|
31
|
+
}];
|
|
32
|
+
readonly outputs: readonly [];
|
|
33
|
+
}, {
|
|
34
|
+
readonly name: "deleteCid";
|
|
35
|
+
readonly type: "function";
|
|
36
|
+
readonly stateMutability: "nonpayable";
|
|
37
|
+
readonly inputs: readonly [];
|
|
38
|
+
readonly outputs: readonly [];
|
|
39
|
+
}, {
|
|
40
|
+
readonly name: "getCid";
|
|
41
|
+
readonly type: "function";
|
|
42
|
+
readonly stateMutability: "view";
|
|
43
|
+
readonly inputs: readonly [{
|
|
44
|
+
readonly name: "account";
|
|
45
|
+
readonly type: "address";
|
|
46
|
+
}];
|
|
47
|
+
readonly outputs: readonly [{
|
|
48
|
+
readonly name: "";
|
|
49
|
+
readonly type: "string";
|
|
50
|
+
}];
|
|
51
|
+
}, {
|
|
52
|
+
readonly name: "hasCid";
|
|
53
|
+
readonly type: "function";
|
|
54
|
+
readonly stateMutability: "view";
|
|
55
|
+
readonly inputs: readonly [{
|
|
56
|
+
readonly name: "account";
|
|
57
|
+
readonly type: "address";
|
|
58
|
+
}];
|
|
59
|
+
readonly outputs: readonly [{
|
|
60
|
+
readonly name: "";
|
|
61
|
+
readonly type: "bool";
|
|
62
|
+
}];
|
|
63
|
+
}, {
|
|
64
|
+
readonly name: "getUpdatedAt";
|
|
65
|
+
readonly type: "function";
|
|
66
|
+
readonly stateMutability: "view";
|
|
67
|
+
readonly inputs: readonly [{
|
|
68
|
+
readonly name: "account";
|
|
69
|
+
readonly type: "address";
|
|
70
|
+
}];
|
|
71
|
+
readonly outputs: readonly [{
|
|
72
|
+
readonly name: "";
|
|
73
|
+
readonly type: "uint256";
|
|
74
|
+
}];
|
|
75
|
+
}, {
|
|
76
|
+
readonly name: "nextAllowedUpdate";
|
|
77
|
+
readonly type: "function";
|
|
78
|
+
readonly stateMutability: "view";
|
|
79
|
+
readonly inputs: readonly [{
|
|
80
|
+
readonly name: "account";
|
|
81
|
+
readonly type: "address";
|
|
82
|
+
}];
|
|
83
|
+
readonly outputs: readonly [{
|
|
84
|
+
readonly name: "";
|
|
85
|
+
readonly type: "uint256";
|
|
86
|
+
}];
|
|
87
|
+
}, {
|
|
88
|
+
readonly name: "cooldownSeconds";
|
|
89
|
+
readonly type: "function";
|
|
90
|
+
readonly stateMutability: "view";
|
|
91
|
+
readonly inputs: readonly [];
|
|
92
|
+
readonly outputs: readonly [{
|
|
93
|
+
readonly name: "";
|
|
94
|
+
readonly type: "uint256";
|
|
95
|
+
}];
|
|
96
|
+
}];
|
|
97
|
+
declare function isCidRegistryConfigured(): boolean;
|
|
98
|
+
declare function publishCidOnChain(smartAccount: VaultSmartAccount, cid: string): Promise<`0x${string}` | null>;
|
|
99
|
+
declare function readCidOnChain(smartAccountAddress: Address): Promise<string | null>;
|
|
100
|
+
|
|
101
|
+
declare function getPimlicoApiKey(): string;
|
|
102
|
+
declare function isSmartAccountConfigured(): boolean;
|
|
103
|
+
declare function getTargetChain(): Chain;
|
|
104
|
+
|
|
105
|
+
declare function scheduleCidOnChainSync(smartAccount: VaultSmartAccount | null, cid: string, debounceMs?: number): void;
|
|
106
|
+
declare function flushCidOnChainSync(): Promise<boolean>;
|
|
107
|
+
declare function getOnChainSyncStatus(): {
|
|
108
|
+
hasPending: boolean;
|
|
109
|
+
pendingCid: string | null;
|
|
110
|
+
lastPublishedCid: string | null;
|
|
111
|
+
lastPublishTime: number;
|
|
112
|
+
isPublishing: boolean;
|
|
113
|
+
};
|
|
114
|
+
declare function resetOnChainSync(): void;
|
|
115
|
+
|
|
116
|
+
interface IdentityState {
|
|
117
|
+
owner: LocalAccount | null;
|
|
118
|
+
smartAccount: VaultSmartAccount | null;
|
|
119
|
+
mode: "password" | "passkey" | "biometric" | null;
|
|
120
|
+
initialized: boolean;
|
|
121
|
+
}
|
|
122
|
+
type IdentityListener = (state: IdentityState) => void;
|
|
123
|
+
declare function initIdentityFromPassword(password: string, secretKey?: string): Promise<{
|
|
124
|
+
address: Address;
|
|
125
|
+
smartAccountAddress: Address | null;
|
|
126
|
+
}>;
|
|
127
|
+
declare function initIdentityFromSigner(signer: LocalAccount, mode?: "passkey" | "biometric"): Promise<{
|
|
128
|
+
address: Address;
|
|
129
|
+
smartAccountAddress: Address | null;
|
|
130
|
+
}>;
|
|
131
|
+
declare function clearIdentity(): void;
|
|
132
|
+
declare function getIdentityAddress(): Address | null;
|
|
133
|
+
declare function isIdentityConnected(): boolean;
|
|
134
|
+
declare function getIdentityOwner(): LocalAccount | null;
|
|
135
|
+
declare function getIdentitySmartAccount(): VaultSmartAccount | null;
|
|
136
|
+
declare function getIdentityMode(): IdentityState["mode"];
|
|
137
|
+
declare function signMessageWithIdentity(message: string): Promise<`0x${string}`>;
|
|
138
|
+
declare function subscribeIdentity(listener: IdentityListener): () => void;
|
|
139
|
+
declare function getIdentitySnapshot(): IdentityState;
|
|
140
|
+
|
|
141
|
+
interface UseIdentityReturn {
|
|
142
|
+
address: Address | null;
|
|
143
|
+
isConnected: boolean;
|
|
144
|
+
mode: "password" | "passkey" | "biometric" | null;
|
|
145
|
+
smartAccountAddress: Address | null;
|
|
146
|
+
signMessage: (message: string) => Promise<`0x${string}`>;
|
|
147
|
+
disconnect: () => void;
|
|
148
|
+
notifyOnChainSync: (cid: string) => void;
|
|
149
|
+
cleanupOnLock: () => Promise<void>;
|
|
150
|
+
flushOnChainSync: () => Promise<void>;
|
|
151
|
+
}
|
|
152
|
+
declare function useIdentity(): UseIdentityReturn;
|
|
153
|
+
|
|
154
|
+
declare function generateSecretKey(): string;
|
|
155
|
+
declare function isValidSecretKey(key: string): boolean;
|
|
156
|
+
declare function formatSecretKeyForDisplay(key: string): string;
|
|
157
|
+
declare function parseSecretKeyInput(input: string): string;
|
|
158
|
+
|
|
159
|
+
export { CID_REGISTRY_ABI, type CreateSmartAccountParams, type UseIdentityReturn, type VaultSmartAccount, clearIdentity, clearSmartAccountCache, computeSmartAccountAddress, createVaultSmartAccount, flushCidOnChainSync, formatSecretKeyForDisplay, generateSecretKey, getCachedSmartAccountAddress, getCachedSmartAccountMode, getIdentityAddress, getIdentityMode, getIdentityOwner, getIdentitySmartAccount, getIdentitySnapshot, getOnChainSyncStatus, getOwnerFromPassword, getPimlicoApiKey, getTargetChain, initIdentityFromPassword, initIdentityFromSigner, isCidRegistryConfigured, isIdentityConnected, isSmartAccountConfigured, isValidSecretKey, parseSecretKeyInput, publishCidOnChain, readCidOnChain, resetOnChainSync, scheduleCidOnChainSync, signMessageWithIdentity, subscribeIdentity, useIdentity };
|