@dynamic-labs-wallet/svm 0.0.33 → 0.0.35
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/index.cjs.js +28 -11
- package/index.esm.js +29 -12
- package/package.json +3 -3
- package/src/svm/svm.d.ts +15 -7
- package/src/svm/svm.d.ts.map +1 -1
package/index.cjs.js
CHANGED
|
@@ -29,7 +29,7 @@ class DynamicSvmWalletClient extends browser.DynamicWalletClient {
|
|
|
29
29
|
*
|
|
30
30
|
* @param thresholdSignatureScheme The threshold signature scheme to use
|
|
31
31
|
* @returns The account address, public key hex, raw public key, and client key shares
|
|
32
|
-
*/ async createWalletAccount({ thresholdSignatureScheme }) {
|
|
32
|
+
*/ async createWalletAccount({ thresholdSignatureScheme, password = undefined }) {
|
|
33
33
|
try {
|
|
34
34
|
const { rawPublicKey, clientKeyShares } = await this.keyGen({
|
|
35
35
|
chainName: this.chainName,
|
|
@@ -57,7 +57,7 @@ class DynamicSvmWalletClient extends browser.DynamicWalletClient {
|
|
|
57
57
|
};
|
|
58
58
|
await this.storeEncryptedBackupByWallet({
|
|
59
59
|
accountAddress,
|
|
60
|
-
password
|
|
60
|
+
password
|
|
61
61
|
});
|
|
62
62
|
return {
|
|
63
63
|
accountAddress,
|
|
@@ -80,8 +80,14 @@ class DynamicSvmWalletClient extends browser.DynamicWalletClient {
|
|
|
80
80
|
* This function takes a message and returns it after being signed with MPC
|
|
81
81
|
*
|
|
82
82
|
* @param message The message to sign (Uint8Array)
|
|
83
|
-
* @param
|
|
84
|
-
|
|
83
|
+
* @param accountAddress Solana address (base58 encoded)
|
|
84
|
+
* @param password The password for encrypted backup shares
|
|
85
|
+
*/ async signMessage({ message, accountAddress, password = undefined }) {
|
|
86
|
+
await this.verifyPassword({
|
|
87
|
+
accountAddress,
|
|
88
|
+
password,
|
|
89
|
+
walletOperation: browser.WalletOperation.SIGN_MESSAGE
|
|
90
|
+
});
|
|
85
91
|
if (!accountAddress) {
|
|
86
92
|
throw new Error('Account address is required');
|
|
87
93
|
}
|
|
@@ -89,7 +95,8 @@ class DynamicSvmWalletClient extends browser.DynamicWalletClient {
|
|
|
89
95
|
const signatureEd25519 = await this.sign({
|
|
90
96
|
message,
|
|
91
97
|
accountAddress: accountAddress,
|
|
92
|
-
chainName: this.chainName
|
|
98
|
+
chainName: this.chainName,
|
|
99
|
+
password
|
|
93
100
|
});
|
|
94
101
|
const base58Signature = bs58.encode(signatureEd25519);
|
|
95
102
|
return base58Signature;
|
|
@@ -118,7 +125,12 @@ class DynamicSvmWalletClient extends browser.DynamicWalletClient {
|
|
|
118
125
|
// console.log('verified', verified);
|
|
119
126
|
// return verified;
|
|
120
127
|
// }
|
|
121
|
-
async signTransaction({ senderAddress, transaction }) {
|
|
128
|
+
async signTransaction({ senderAddress, transaction, password = undefined }) {
|
|
129
|
+
await this.verifyPassword({
|
|
130
|
+
accountAddress: senderAddress,
|
|
131
|
+
password,
|
|
132
|
+
walletOperation: browser.WalletOperation.SIGN_TRANSACTION
|
|
133
|
+
});
|
|
122
134
|
try {
|
|
123
135
|
let messageToSign;
|
|
124
136
|
if (transaction instanceof web3_js.VersionedTransaction) {
|
|
@@ -133,7 +145,8 @@ class DynamicSvmWalletClient extends browser.DynamicWalletClient {
|
|
|
133
145
|
const signatureEd25519 = await this.sign({
|
|
134
146
|
message: messageToSign,
|
|
135
147
|
accountAddress: senderAddress,
|
|
136
|
-
chainName: this.chainName
|
|
148
|
+
chainName: this.chainName,
|
|
149
|
+
password
|
|
137
150
|
});
|
|
138
151
|
if (!signatureEd25519) {
|
|
139
152
|
throw new Error('Signature is undefined');
|
|
@@ -155,11 +168,13 @@ class DynamicSvmWalletClient extends browser.DynamicWalletClient {
|
|
|
155
168
|
* Exports the private key for a given account address
|
|
156
169
|
*
|
|
157
170
|
* @param accountAddress The account address to export the private key for
|
|
171
|
+
* @param password The password for encrypted backup shares
|
|
158
172
|
* @returns The private key
|
|
159
|
-
*/ async exportPrivateKey({ accountAddress }) {
|
|
173
|
+
*/ async exportPrivateKey({ accountAddress, password = undefined }) {
|
|
160
174
|
const { derivedPrivateKey } = await this.exportKey({
|
|
161
175
|
accountAddress,
|
|
162
|
-
chainName: this.chainName
|
|
176
|
+
chainName: this.chainName,
|
|
177
|
+
password
|
|
163
178
|
});
|
|
164
179
|
if (!derivedPrivateKey) {
|
|
165
180
|
throw new Error('Derived private key is undefined');
|
|
@@ -209,8 +224,9 @@ class DynamicSvmWalletClient extends browser.DynamicWalletClient {
|
|
|
209
224
|
* @param privateKey The private key to import
|
|
210
225
|
* @param chainName The chain name to import the private key for
|
|
211
226
|
* @param thresholdSignatureScheme The threshold signature scheme to use
|
|
227
|
+
* @param password The password for encrypted backup shares
|
|
212
228
|
* @returns The account address, raw public key, and client key shares
|
|
213
|
-
*/ async importPrivateKey({ privateKey, chainName, thresholdSignatureScheme }) {
|
|
229
|
+
*/ async importPrivateKey({ privateKey, chainName, thresholdSignatureScheme, password = undefined }) {
|
|
214
230
|
//get public key from private key
|
|
215
231
|
const publicKey = this.getPublicKeyFromPrivateKey(privateKey);
|
|
216
232
|
const formattedPrivateKey = await this.decodePrivateKeyForSolana(privateKey);
|
|
@@ -238,7 +254,8 @@ class DynamicSvmWalletClient extends browser.DynamicWalletClient {
|
|
|
238
254
|
clientKeySharesBackupInfo: browser.getClientKeyShareBackupInfo()
|
|
239
255
|
};
|
|
240
256
|
await this.storeEncryptedBackupByWallet({
|
|
241
|
-
accountAddress
|
|
257
|
+
accountAddress,
|
|
258
|
+
password
|
|
242
259
|
});
|
|
243
260
|
return {
|
|
244
261
|
accountAddress,
|
package/index.esm.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { DynamicWalletClient, getClientKeyShareBackupInfo } from '@dynamic-labs-wallet/browser';
|
|
1
|
+
import { DynamicWalletClient, getClientKeyShareBackupInfo, WalletOperation } from '@dynamic-labs-wallet/browser';
|
|
2
2
|
import bs58 from 'bs58';
|
|
3
3
|
import { Transaction, VersionedTransaction, Keypair } from '@solana/web3.js';
|
|
4
4
|
import '@dynamic-labs-wallet/core';
|
|
@@ -27,7 +27,7 @@ class DynamicSvmWalletClient extends DynamicWalletClient {
|
|
|
27
27
|
*
|
|
28
28
|
* @param thresholdSignatureScheme The threshold signature scheme to use
|
|
29
29
|
* @returns The account address, public key hex, raw public key, and client key shares
|
|
30
|
-
*/ async createWalletAccount({ thresholdSignatureScheme }) {
|
|
30
|
+
*/ async createWalletAccount({ thresholdSignatureScheme, password = undefined }) {
|
|
31
31
|
try {
|
|
32
32
|
const { rawPublicKey, clientKeyShares } = await this.keyGen({
|
|
33
33
|
chainName: this.chainName,
|
|
@@ -55,7 +55,7 @@ class DynamicSvmWalletClient extends DynamicWalletClient {
|
|
|
55
55
|
};
|
|
56
56
|
await this.storeEncryptedBackupByWallet({
|
|
57
57
|
accountAddress,
|
|
58
|
-
password
|
|
58
|
+
password
|
|
59
59
|
});
|
|
60
60
|
return {
|
|
61
61
|
accountAddress,
|
|
@@ -78,8 +78,14 @@ class DynamicSvmWalletClient extends DynamicWalletClient {
|
|
|
78
78
|
* This function takes a message and returns it after being signed with MPC
|
|
79
79
|
*
|
|
80
80
|
* @param message The message to sign (Uint8Array)
|
|
81
|
-
* @param
|
|
82
|
-
|
|
81
|
+
* @param accountAddress Solana address (base58 encoded)
|
|
82
|
+
* @param password The password for encrypted backup shares
|
|
83
|
+
*/ async signMessage({ message, accountAddress, password = undefined }) {
|
|
84
|
+
await this.verifyPassword({
|
|
85
|
+
accountAddress,
|
|
86
|
+
password,
|
|
87
|
+
walletOperation: WalletOperation.SIGN_MESSAGE
|
|
88
|
+
});
|
|
83
89
|
if (!accountAddress) {
|
|
84
90
|
throw new Error('Account address is required');
|
|
85
91
|
}
|
|
@@ -87,7 +93,8 @@ class DynamicSvmWalletClient extends DynamicWalletClient {
|
|
|
87
93
|
const signatureEd25519 = await this.sign({
|
|
88
94
|
message,
|
|
89
95
|
accountAddress: accountAddress,
|
|
90
|
-
chainName: this.chainName
|
|
96
|
+
chainName: this.chainName,
|
|
97
|
+
password
|
|
91
98
|
});
|
|
92
99
|
const base58Signature = bs58.encode(signatureEd25519);
|
|
93
100
|
return base58Signature;
|
|
@@ -116,7 +123,12 @@ class DynamicSvmWalletClient extends DynamicWalletClient {
|
|
|
116
123
|
// console.log('verified', verified);
|
|
117
124
|
// return verified;
|
|
118
125
|
// }
|
|
119
|
-
async signTransaction({ senderAddress, transaction }) {
|
|
126
|
+
async signTransaction({ senderAddress, transaction, password = undefined }) {
|
|
127
|
+
await this.verifyPassword({
|
|
128
|
+
accountAddress: senderAddress,
|
|
129
|
+
password,
|
|
130
|
+
walletOperation: WalletOperation.SIGN_TRANSACTION
|
|
131
|
+
});
|
|
120
132
|
try {
|
|
121
133
|
let messageToSign;
|
|
122
134
|
if (transaction instanceof VersionedTransaction) {
|
|
@@ -131,7 +143,8 @@ class DynamicSvmWalletClient extends DynamicWalletClient {
|
|
|
131
143
|
const signatureEd25519 = await this.sign({
|
|
132
144
|
message: messageToSign,
|
|
133
145
|
accountAddress: senderAddress,
|
|
134
|
-
chainName: this.chainName
|
|
146
|
+
chainName: this.chainName,
|
|
147
|
+
password
|
|
135
148
|
});
|
|
136
149
|
if (!signatureEd25519) {
|
|
137
150
|
throw new Error('Signature is undefined');
|
|
@@ -153,11 +166,13 @@ class DynamicSvmWalletClient extends DynamicWalletClient {
|
|
|
153
166
|
* Exports the private key for a given account address
|
|
154
167
|
*
|
|
155
168
|
* @param accountAddress The account address to export the private key for
|
|
169
|
+
* @param password The password for encrypted backup shares
|
|
156
170
|
* @returns The private key
|
|
157
|
-
*/ async exportPrivateKey({ accountAddress }) {
|
|
171
|
+
*/ async exportPrivateKey({ accountAddress, password = undefined }) {
|
|
158
172
|
const { derivedPrivateKey } = await this.exportKey({
|
|
159
173
|
accountAddress,
|
|
160
|
-
chainName: this.chainName
|
|
174
|
+
chainName: this.chainName,
|
|
175
|
+
password
|
|
161
176
|
});
|
|
162
177
|
if (!derivedPrivateKey) {
|
|
163
178
|
throw new Error('Derived private key is undefined');
|
|
@@ -207,8 +222,9 @@ class DynamicSvmWalletClient extends DynamicWalletClient {
|
|
|
207
222
|
* @param privateKey The private key to import
|
|
208
223
|
* @param chainName The chain name to import the private key for
|
|
209
224
|
* @param thresholdSignatureScheme The threshold signature scheme to use
|
|
225
|
+
* @param password The password for encrypted backup shares
|
|
210
226
|
* @returns The account address, raw public key, and client key shares
|
|
211
|
-
*/ async importPrivateKey({ privateKey, chainName, thresholdSignatureScheme }) {
|
|
227
|
+
*/ async importPrivateKey({ privateKey, chainName, thresholdSignatureScheme, password = undefined }) {
|
|
212
228
|
//get public key from private key
|
|
213
229
|
const publicKey = this.getPublicKeyFromPrivateKey(privateKey);
|
|
214
230
|
const formattedPrivateKey = await this.decodePrivateKeyForSolana(privateKey);
|
|
@@ -236,7 +252,8 @@ class DynamicSvmWalletClient extends DynamicWalletClient {
|
|
|
236
252
|
clientKeySharesBackupInfo: getClientKeyShareBackupInfo()
|
|
237
253
|
};
|
|
238
254
|
await this.storeEncryptedBackupByWallet({
|
|
239
|
-
accountAddress
|
|
255
|
+
accountAddress,
|
|
256
|
+
password
|
|
240
257
|
});
|
|
241
258
|
return {
|
|
242
259
|
accountAddress,
|
package/package.json
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dynamic-labs-wallet/svm",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.35",
|
|
4
4
|
"dependencies": {
|
|
5
|
-
"@dynamic-labs-wallet/browser": "0.0.
|
|
6
|
-
"@dynamic-labs-wallet/core": "0.0.
|
|
5
|
+
"@dynamic-labs-wallet/browser": "0.0.35",
|
|
6
|
+
"@dynamic-labs-wallet/core": "0.0.35",
|
|
7
7
|
"@solana/web3.js": "^1.98.0",
|
|
8
8
|
"bs58": "^6.0.0"
|
|
9
9
|
},
|
package/src/svm/svm.d.ts
CHANGED
|
@@ -15,8 +15,9 @@ export declare class DynamicSvmWalletClient extends DynamicWalletClient {
|
|
|
15
15
|
* @param thresholdSignatureScheme The threshold signature scheme to use
|
|
16
16
|
* @returns The account address, public key hex, raw public key, and client key shares
|
|
17
17
|
*/
|
|
18
|
-
createWalletAccount({ thresholdSignatureScheme, }: {
|
|
18
|
+
createWalletAccount({ thresholdSignatureScheme, password, }: {
|
|
19
19
|
thresholdSignatureScheme: ThresholdSignatureScheme;
|
|
20
|
+
password?: string;
|
|
20
21
|
}): Promise<{
|
|
21
22
|
accountAddress: string;
|
|
22
23
|
rawPublicKey: Uint8Array;
|
|
@@ -29,24 +30,29 @@ export declare class DynamicSvmWalletClient extends DynamicWalletClient {
|
|
|
29
30
|
* This function takes a message and returns it after being signed with MPC
|
|
30
31
|
*
|
|
31
32
|
* @param message The message to sign (Uint8Array)
|
|
32
|
-
* @param
|
|
33
|
+
* @param accountAddress Solana address (base58 encoded)
|
|
34
|
+
* @param password The password for encrypted backup shares
|
|
33
35
|
*/
|
|
34
|
-
signMessage({ message, accountAddress, }: {
|
|
36
|
+
signMessage({ message, accountAddress, password, }: {
|
|
35
37
|
message: string;
|
|
36
|
-
accountAddress
|
|
38
|
+
accountAddress: string;
|
|
39
|
+
password?: string;
|
|
37
40
|
}): Promise<string>;
|
|
38
|
-
signTransaction({ senderAddress, transaction, }: {
|
|
41
|
+
signTransaction({ senderAddress, transaction, password, }: {
|
|
39
42
|
senderAddress: string;
|
|
40
43
|
transaction: VersionedTransaction | Transaction;
|
|
44
|
+
password?: string;
|
|
41
45
|
}): Promise<VersionedTransaction | Transaction>;
|
|
42
46
|
/**
|
|
43
47
|
* Exports the private key for a given account address
|
|
44
48
|
*
|
|
45
49
|
* @param accountAddress The account address to export the private key for
|
|
50
|
+
* @param password The password for encrypted backup shares
|
|
46
51
|
* @returns The private key
|
|
47
52
|
*/
|
|
48
|
-
exportPrivateKey({ accountAddress }: {
|
|
53
|
+
exportPrivateKey({ accountAddress, password, }: {
|
|
49
54
|
accountAddress: string;
|
|
55
|
+
password?: string;
|
|
50
56
|
}): Promise<{
|
|
51
57
|
derivedPrivateKey: string;
|
|
52
58
|
}>;
|
|
@@ -77,12 +83,14 @@ export declare class DynamicSvmWalletClient extends DynamicWalletClient {
|
|
|
77
83
|
* @param privateKey The private key to import
|
|
78
84
|
* @param chainName The chain name to import the private key for
|
|
79
85
|
* @param thresholdSignatureScheme The threshold signature scheme to use
|
|
86
|
+
* @param password The password for encrypted backup shares
|
|
80
87
|
* @returns The account address, raw public key, and client key shares
|
|
81
88
|
*/
|
|
82
|
-
importPrivateKey({ privateKey, chainName, thresholdSignatureScheme, }: {
|
|
89
|
+
importPrivateKey({ privateKey, chainName, thresholdSignatureScheme, password, }: {
|
|
83
90
|
privateKey: string;
|
|
84
91
|
chainName: string;
|
|
85
92
|
thresholdSignatureScheme: ThresholdSignatureScheme;
|
|
93
|
+
password?: string;
|
|
86
94
|
}): Promise<{
|
|
87
95
|
accountAddress: string;
|
|
88
96
|
rawPublicKey: Uint8Array | undefined;
|
package/src/svm/svm.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"svm.d.ts","sourceRoot":"","sources":["../../src/svm/svm.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,cAAc,EACd,mBAAmB,EACnB,mBAAmB,EACnB,wBAAwB,
|
|
1
|
+
{"version":3,"file":"svm.d.ts","sourceRoot":"","sources":["../../src/svm/svm.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,cAAc,EACd,mBAAmB,EACnB,mBAAmB,EACnB,wBAAwB,EAGzB,MAAM,8BAA8B,CAAC;AAEtC,OAAO,EAAW,WAAW,EAAE,oBAAoB,EAAE,MAAM,iBAAiB,CAAC;AAG7E,qBAAa,sBAAuB,SAAQ,mBAAmB;IAC7D,QAAQ,CAAC,SAAS,SAAS;IAC3B,cAAc,CAAC,EAAE,MAAM,CAAC;gBAEZ,EACV,aAAa,EACb,SAAS,EACT,UAAU,EACV,kBAAkB,GACnB,EAAE;QACD,aA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