@dynamic-labs-wallet/evm 0.0.0-beta.146.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/index.cjs.d.ts ADDED
@@ -0,0 +1 @@
1
+ export * from "./src/index";
package/index.cjs.js ADDED
@@ -0,0 +1,285 @@
1
+ 'use strict';
2
+
3
+ var browser = require('@dynamic-labs-wallet/browser');
4
+ var viem = require('viem');
5
+ var chains = require('viem/chains');
6
+
7
+ function _extends() {
8
+ _extends = Object.assign || function assign(target) {
9
+ for(var i = 1; i < arguments.length; i++){
10
+ var source = arguments[i];
11
+ for(var key in source)if (Object.prototype.hasOwnProperty.call(source, key)) target[key] = source[key];
12
+ }
13
+ return target;
14
+ };
15
+ return _extends.apply(this, arguments);
16
+ }
17
+
18
+ const EVM_SIGN_MESSAGE_PREFIX = `\x19Ethereum Signed Message:\n`;
19
+ // Error messages
20
+ const ERROR_KEYGEN_FAILED = 'Error with keygen';
21
+ const ERROR_CREATE_WALLET_ACCOUNT = 'Error creating evm wallet account';
22
+ const ERROR_SIGN_MESSAGE = 'Error signing message';
23
+ const ERROR_ACCOUNT_ADDRESS_REQUIRED = 'Account address is required';
24
+ const ERROR_VERIFY_MESSAGE_SIGNATURE = 'Error verifying message signature';
25
+
26
+ const formatEVMMessage = (message_)=>{
27
+ const message = (()=>{
28
+ if (typeof message_ === 'string') return viem.stringToHex(message_);
29
+ if (typeof message_.raw === 'string') return message_.raw;
30
+ return viem.bytesToHex(message_.raw);
31
+ })();
32
+ const prefix = viem.stringToHex(`${EVM_SIGN_MESSAGE_PREFIX}${viem.size(message)}`);
33
+ return viem.concat([
34
+ prefix,
35
+ message
36
+ ]);
37
+ };
38
+ const serializeECDSASignature = (signature)=>{
39
+ return viem.serializeSignature({
40
+ r: `0x${Buffer.from(signature.r).toString('hex')}`,
41
+ s: `0x${Buffer.from(signature.s).toString('hex')}`,
42
+ v: BigInt(signature.v)
43
+ });
44
+ };
45
+
46
+ class DynamicEvmWalletClient extends browser.DynamicWalletClient {
47
+ createViemPublicClient({ chain, rpcUrl }) {
48
+ return viem.createPublicClient({
49
+ chain,
50
+ transport: viem.http(rpcUrl)
51
+ });
52
+ }
53
+ async createWalletAccount({ thresholdSignatureScheme, password = undefined, onError }) {
54
+ try {
55
+ // Create a promise that will resolve when the ceremony is complete
56
+ let ceremonyCeremonyCompleteResolver;
57
+ const ceremonyCompletePromise = new Promise((resolve)=>{
58
+ ceremonyCeremonyCompleteResolver = resolve;
59
+ });
60
+ // Generate key shares for given threshold signature scheme (TSS)
61
+ const { rawPublicKey, clientKeyShares } = await this.keyGen({
62
+ chainName: this.chainName,
63
+ thresholdSignatureScheme,
64
+ onError,
65
+ onCeremonyComplete: (accountAddress, walletId)=>{
66
+ // update wallet map
67
+ const checksumAddress = viem.getAddress(accountAddress);
68
+ this.walletMap[checksumAddress] = _extends({}, this.walletMap[checksumAddress] || {}, {
69
+ accountAddress: checksumAddress,
70
+ walletId,
71
+ chainName: this.chainName,
72
+ thresholdSignatureScheme,
73
+ clientKeySharesBackupInfo: browser.getClientKeyShareBackupInfo()
74
+ });
75
+ // Resolve the promise when ceremony is complete
76
+ ceremonyCeremonyCompleteResolver(undefined);
77
+ }
78
+ });
79
+ // Wait for the ceremony to complete before proceeding
80
+ await ceremonyCompletePromise;
81
+ if (!rawPublicKey || !clientKeyShares) {
82
+ throw new Error(ERROR_KEYGEN_FAILED);
83
+ }
84
+ const { accountAddress, publicKeyHex } = await this.deriveAccountAddress({
85
+ rawPublicKey: rawPublicKey
86
+ });
87
+ // Update client key shares in wallet map
88
+ await this.setClientKeySharesToLocalStorage({
89
+ accountAddress,
90
+ clientKeyShares,
91
+ overwriteOrMerge: 'overwrite'
92
+ });
93
+ // Backup the new wallet without waiting for the promise to resolve
94
+ void this.storeEncryptedBackupByWalletWithRetry({
95
+ accountAddress,
96
+ clientKeyShares,
97
+ password
98
+ });
99
+ return {
100
+ accountAddress,
101
+ rawPublicKey,
102
+ publicKeyHex
103
+ };
104
+ } catch (error) {
105
+ this.logger.error(ERROR_CREATE_WALLET_ACCOUNT, error);
106
+ throw new Error(ERROR_CREATE_WALLET_ACCOUNT);
107
+ }
108
+ }
109
+ async signMessage({ message, accountAddress, password = undefined }) {
110
+ await this.verifyPassword({
111
+ accountAddress,
112
+ password,
113
+ walletOperation: browser.WalletOperation.SIGN_MESSAGE
114
+ });
115
+ try {
116
+ if (!accountAddress) {
117
+ throw new Error(ERROR_ACCOUNT_ADDRESS_REQUIRED);
118
+ }
119
+ // Format the message for EVM signing
120
+ const formattedMessage = formatEVMMessage(message);
121
+ // Sign the message using MPC
122
+ const signatureEcdsa = await this.sign({
123
+ message: formattedMessage,
124
+ accountAddress: accountAddress,
125
+ chainName: this.chainName,
126
+ password
127
+ });
128
+ // Serialize the signature
129
+ const serializedSignature = serializeECDSASignature(signatureEcdsa);
130
+ return serializedSignature;
131
+ } catch (error) {
132
+ this.logger.error(ERROR_SIGN_MESSAGE, error);
133
+ throw new Error(ERROR_SIGN_MESSAGE);
134
+ }
135
+ }
136
+ async verifyMessageSignature({ accountAddress, message, signature }) {
137
+ try {
138
+ // Verify the signature using the public client
139
+ const publicClient = this.createViemPublicClient({
140
+ chain: chains.mainnet
141
+ });
142
+ const verified = await publicClient.verifyMessage({
143
+ address: accountAddress,
144
+ message,
145
+ signature: signature
146
+ });
147
+ return verified;
148
+ } catch (error) {
149
+ this.logger.error(ERROR_VERIFY_MESSAGE_SIGNATURE, error);
150
+ throw new Error(ERROR_VERIFY_MESSAGE_SIGNATURE);
151
+ }
152
+ }
153
+ async signTransaction({ senderAddress, transaction, password = undefined }) {
154
+ await this.verifyPassword({
155
+ accountAddress: senderAddress,
156
+ password,
157
+ walletOperation: browser.WalletOperation.SIGN_TRANSACTION
158
+ });
159
+ const serializedTx = viem.serializeTransaction(transaction);
160
+ const serializedTxBytes = Uint8Array.from(Buffer.from(serializedTx.slice(2), 'hex'));
161
+ if (!(serializedTxBytes instanceof Uint8Array)) {
162
+ throw new Error('Invalid serializedTxBytes');
163
+ }
164
+ // Get signature using MPC (this will coordinate with server party)
165
+ const signatureEcdsa = await this.sign({
166
+ message: serializedTxBytes,
167
+ accountAddress: senderAddress,
168
+ chainName: this.chainName,
169
+ password
170
+ });
171
+ if (!('r' in signatureEcdsa && 's' in signatureEcdsa && 'v' in signatureEcdsa)) {
172
+ throw new Error('Invalid signature format returned from MPC signing');
173
+ }
174
+ try {
175
+ const r = `0x${Buffer.from(signatureEcdsa.r).toString('hex')}`;
176
+ const s = `0x${Buffer.from(signatureEcdsa.s).toString('hex')}`;
177
+ const v = BigInt(signatureEcdsa.v);
178
+ const signedTx = _extends({}, transaction, {
179
+ r: r,
180
+ s: s,
181
+ v: v
182
+ });
183
+ const serializedSignedTx = viem.serializeTransaction(signedTx);
184
+ return serializedSignedTx;
185
+ } catch (error) {
186
+ this.logger.error('Error signing transaction:', error);
187
+ throw error;
188
+ }
189
+ }
190
+ deriveAccountAddress({ rawPublicKey }) {
191
+ const serializedUncompressed = rawPublicKey.serializeUncompressed();
192
+ const firstByteRemoved = serializedUncompressed.slice(1);
193
+ const hashed = browser.MessageHash.keccak256(firstByteRemoved).bytes;
194
+ const lastTwentyBytes = hashed.slice(-20);
195
+ const accountAddress = '0x' + Buffer.from(lastTwentyBytes).toString('hex');
196
+ const publicKeyHex = rawPublicKey.pubKeyAsHex();
197
+ return {
198
+ accountAddress: viem.getAddress(accountAddress),
199
+ publicKeyHex
200
+ };
201
+ }
202
+ async exportPrivateKey({ accountAddress, password = undefined }) {
203
+ await this.verifyPassword({
204
+ accountAddress,
205
+ password,
206
+ walletOperation: browser.WalletOperation.EXPORT_PRIVATE_KEY
207
+ });
208
+ const { derivedPrivateKey } = await this.exportKey({
209
+ accountAddress,
210
+ chainName: this.chainName,
211
+ password
212
+ });
213
+ return derivedPrivateKey;
214
+ }
215
+ async offlineExportPrivateKey({ keyShares, derivationPath }) {
216
+ const { derivedPrivateKey } = await this.offlineExportKey({
217
+ chainName: this.chainName,
218
+ keyShares,
219
+ derivationPath
220
+ });
221
+ return {
222
+ derivedPrivateKey
223
+ };
224
+ }
225
+ async importPrivateKey({ privateKey, chainName, thresholdSignatureScheme, password = undefined, onError }) {
226
+ // TODO: validate private key for EVM
227
+ const { rawPublicKey, clientKeyShares } = await this.importRawPrivateKey({
228
+ chainName,
229
+ privateKey,
230
+ thresholdSignatureScheme,
231
+ onError,
232
+ onCeremonyComplete: (accountAddress, walletId)=>{
233
+ // update wallet map
234
+ const checksumAddress = viem.getAddress(accountAddress);
235
+ this.walletMap[checksumAddress] = _extends({}, this.walletMap[checksumAddress] || {}, {
236
+ accountAddress: checksumAddress,
237
+ walletId,
238
+ chainName: this.chainName,
239
+ thresholdSignatureScheme,
240
+ clientKeySharesBackupInfo: browser.getClientKeyShareBackupInfo()
241
+ });
242
+ }
243
+ });
244
+ if (!rawPublicKey || !clientKeyShares) {
245
+ throw new Error('Error creating wallet account');
246
+ }
247
+ const { accountAddress, publicKeyHex } = await this.deriveAccountAddress({
248
+ rawPublicKey: rawPublicKey
249
+ });
250
+ // Update client key shares in wallet map
251
+ await this.setClientKeySharesToLocalStorage({
252
+ accountAddress,
253
+ clientKeyShares,
254
+ overwriteOrMerge: 'overwrite'
255
+ });
256
+ // Backup the new wallet without waiting for the promise to resolve
257
+ void this.storeEncryptedBackupByWalletWithRetry({
258
+ accountAddress,
259
+ clientKeyShares,
260
+ password
261
+ });
262
+ return {
263
+ accountAddress,
264
+ rawPublicKey,
265
+ publicKeyHex
266
+ };
267
+ }
268
+ async getEvmWallets() {
269
+ const wallets = await this.getWallets();
270
+ const evmWallets = wallets.filter((wallet)=>wallet.chainName === 'eip155');
271
+ return evmWallets;
272
+ }
273
+ constructor({ environmentId, authToken, baseApiUrl, baseMPCRelayApiUrl, storageKey, debug }){
274
+ super({
275
+ environmentId,
276
+ authToken,
277
+ baseApiUrl,
278
+ baseMPCRelayApiUrl,
279
+ storageKey,
280
+ debug
281
+ }), this.chainName = 'EVM';
282
+ }
283
+ }
284
+
285
+ exports.DynamicEvmWalletClient = DynamicEvmWalletClient;
package/index.esm.d.ts ADDED
@@ -0,0 +1 @@
1
+ export * from "./src/index";
package/index.esm.js ADDED
@@ -0,0 +1,283 @@
1
+ import { DynamicWalletClient, getClientKeyShareBackupInfo, WalletOperation, MessageHash } from '@dynamic-labs-wallet/browser';
2
+ import { stringToHex, bytesToHex, size, concat, serializeSignature, createPublicClient, http, getAddress, serializeTransaction } from 'viem';
3
+ import { mainnet } from 'viem/chains';
4
+
5
+ function _extends() {
6
+ _extends = Object.assign || function assign(target) {
7
+ for(var i = 1; i < arguments.length; i++){
8
+ var source = arguments[i];
9
+ for(var key in source)if (Object.prototype.hasOwnProperty.call(source, key)) target[key] = source[key];
10
+ }
11
+ return target;
12
+ };
13
+ return _extends.apply(this, arguments);
14
+ }
15
+
16
+ const EVM_SIGN_MESSAGE_PREFIX = `\x19Ethereum Signed Message:\n`;
17
+ // Error messages
18
+ const ERROR_KEYGEN_FAILED = 'Error with keygen';
19
+ const ERROR_CREATE_WALLET_ACCOUNT = 'Error creating evm wallet account';
20
+ const ERROR_SIGN_MESSAGE = 'Error signing message';
21
+ const ERROR_ACCOUNT_ADDRESS_REQUIRED = 'Account address is required';
22
+ const ERROR_VERIFY_MESSAGE_SIGNATURE = 'Error verifying message signature';
23
+
24
+ const formatEVMMessage = (message_)=>{
25
+ const message = (()=>{
26
+ if (typeof message_ === 'string') return stringToHex(message_);
27
+ if (typeof message_.raw === 'string') return message_.raw;
28
+ return bytesToHex(message_.raw);
29
+ })();
30
+ const prefix = stringToHex(`${EVM_SIGN_MESSAGE_PREFIX}${size(message)}`);
31
+ return concat([
32
+ prefix,
33
+ message
34
+ ]);
35
+ };
36
+ const serializeECDSASignature = (signature)=>{
37
+ return serializeSignature({
38
+ r: `0x${Buffer.from(signature.r).toString('hex')}`,
39
+ s: `0x${Buffer.from(signature.s).toString('hex')}`,
40
+ v: BigInt(signature.v)
41
+ });
42
+ };
43
+
44
+ class DynamicEvmWalletClient extends DynamicWalletClient {
45
+ createViemPublicClient({ chain, rpcUrl }) {
46
+ return createPublicClient({
47
+ chain,
48
+ transport: http(rpcUrl)
49
+ });
50
+ }
51
+ async createWalletAccount({ thresholdSignatureScheme, password = undefined, onError }) {
52
+ try {
53
+ // Create a promise that will resolve when the ceremony is complete
54
+ let ceremonyCeremonyCompleteResolver;
55
+ const ceremonyCompletePromise = new Promise((resolve)=>{
56
+ ceremonyCeremonyCompleteResolver = resolve;
57
+ });
58
+ // Generate key shares for given threshold signature scheme (TSS)
59
+ const { rawPublicKey, clientKeyShares } = await this.keyGen({
60
+ chainName: this.chainName,
61
+ thresholdSignatureScheme,
62
+ onError,
63
+ onCeremonyComplete: (accountAddress, walletId)=>{
64
+ // update wallet map
65
+ const checksumAddress = getAddress(accountAddress);
66
+ this.walletMap[checksumAddress] = _extends({}, this.walletMap[checksumAddress] || {}, {
67
+ accountAddress: checksumAddress,
68
+ walletId,
69
+ chainName: this.chainName,
70
+ thresholdSignatureScheme,
71
+ clientKeySharesBackupInfo: getClientKeyShareBackupInfo()
72
+ });
73
+ // Resolve the promise when ceremony is complete
74
+ ceremonyCeremonyCompleteResolver(undefined);
75
+ }
76
+ });
77
+ // Wait for the ceremony to complete before proceeding
78
+ await ceremonyCompletePromise;
79
+ if (!rawPublicKey || !clientKeyShares) {
80
+ throw new Error(ERROR_KEYGEN_FAILED);
81
+ }
82
+ const { accountAddress, publicKeyHex } = await this.deriveAccountAddress({
83
+ rawPublicKey: rawPublicKey
84
+ });
85
+ // Update client key shares in wallet map
86
+ await this.setClientKeySharesToLocalStorage({
87
+ accountAddress,
88
+ clientKeyShares,
89
+ overwriteOrMerge: 'overwrite'
90
+ });
91
+ // Backup the new wallet without waiting for the promise to resolve
92
+ void this.storeEncryptedBackupByWalletWithRetry({
93
+ accountAddress,
94
+ clientKeyShares,
95
+ password
96
+ });
97
+ return {
98
+ accountAddress,
99
+ rawPublicKey,
100
+ publicKeyHex
101
+ };
102
+ } catch (error) {
103
+ this.logger.error(ERROR_CREATE_WALLET_ACCOUNT, error);
104
+ throw new Error(ERROR_CREATE_WALLET_ACCOUNT);
105
+ }
106
+ }
107
+ async signMessage({ message, accountAddress, password = undefined }) {
108
+ await this.verifyPassword({
109
+ accountAddress,
110
+ password,
111
+ walletOperation: WalletOperation.SIGN_MESSAGE
112
+ });
113
+ try {
114
+ if (!accountAddress) {
115
+ throw new Error(ERROR_ACCOUNT_ADDRESS_REQUIRED);
116
+ }
117
+ // Format the message for EVM signing
118
+ const formattedMessage = formatEVMMessage(message);
119
+ // Sign the message using MPC
120
+ const signatureEcdsa = await this.sign({
121
+ message: formattedMessage,
122
+ accountAddress: accountAddress,
123
+ chainName: this.chainName,
124
+ password
125
+ });
126
+ // Serialize the signature
127
+ const serializedSignature = serializeECDSASignature(signatureEcdsa);
128
+ return serializedSignature;
129
+ } catch (error) {
130
+ this.logger.error(ERROR_SIGN_MESSAGE, error);
131
+ throw new Error(ERROR_SIGN_MESSAGE);
132
+ }
133
+ }
134
+ async verifyMessageSignature({ accountAddress, message, signature }) {
135
+ try {
136
+ // Verify the signature using the public client
137
+ const publicClient = this.createViemPublicClient({
138
+ chain: mainnet
139
+ });
140
+ const verified = await publicClient.verifyMessage({
141
+ address: accountAddress,
142
+ message,
143
+ signature: signature
144
+ });
145
+ return verified;
146
+ } catch (error) {
147
+ this.logger.error(ERROR_VERIFY_MESSAGE_SIGNATURE, error);
148
+ throw new Error(ERROR_VERIFY_MESSAGE_SIGNATURE);
149
+ }
150
+ }
151
+ async signTransaction({ senderAddress, transaction, password = undefined }) {
152
+ await this.verifyPassword({
153
+ accountAddress: senderAddress,
154
+ password,
155
+ walletOperation: WalletOperation.SIGN_TRANSACTION
156
+ });
157
+ const serializedTx = serializeTransaction(transaction);
158
+ const serializedTxBytes = Uint8Array.from(Buffer.from(serializedTx.slice(2), 'hex'));
159
+ if (!(serializedTxBytes instanceof Uint8Array)) {
160
+ throw new Error('Invalid serializedTxBytes');
161
+ }
162
+ // Get signature using MPC (this will coordinate with server party)
163
+ const signatureEcdsa = await this.sign({
164
+ message: serializedTxBytes,
165
+ accountAddress: senderAddress,
166
+ chainName: this.chainName,
167
+ password
168
+ });
169
+ if (!('r' in signatureEcdsa && 's' in signatureEcdsa && 'v' in signatureEcdsa)) {
170
+ throw new Error('Invalid signature format returned from MPC signing');
171
+ }
172
+ try {
173
+ const r = `0x${Buffer.from(signatureEcdsa.r).toString('hex')}`;
174
+ const s = `0x${Buffer.from(signatureEcdsa.s).toString('hex')}`;
175
+ const v = BigInt(signatureEcdsa.v);
176
+ const signedTx = _extends({}, transaction, {
177
+ r: r,
178
+ s: s,
179
+ v: v
180
+ });
181
+ const serializedSignedTx = serializeTransaction(signedTx);
182
+ return serializedSignedTx;
183
+ } catch (error) {
184
+ this.logger.error('Error signing transaction:', error);
185
+ throw error;
186
+ }
187
+ }
188
+ deriveAccountAddress({ rawPublicKey }) {
189
+ const serializedUncompressed = rawPublicKey.serializeUncompressed();
190
+ const firstByteRemoved = serializedUncompressed.slice(1);
191
+ const hashed = MessageHash.keccak256(firstByteRemoved).bytes;
192
+ const lastTwentyBytes = hashed.slice(-20);
193
+ const accountAddress = '0x' + Buffer.from(lastTwentyBytes).toString('hex');
194
+ const publicKeyHex = rawPublicKey.pubKeyAsHex();
195
+ return {
196
+ accountAddress: getAddress(accountAddress),
197
+ publicKeyHex
198
+ };
199
+ }
200
+ async exportPrivateKey({ accountAddress, password = undefined }) {
201
+ await this.verifyPassword({
202
+ accountAddress,
203
+ password,
204
+ walletOperation: WalletOperation.EXPORT_PRIVATE_KEY
205
+ });
206
+ const { derivedPrivateKey } = await this.exportKey({
207
+ accountAddress,
208
+ chainName: this.chainName,
209
+ password
210
+ });
211
+ return derivedPrivateKey;
212
+ }
213
+ async offlineExportPrivateKey({ keyShares, derivationPath }) {
214
+ const { derivedPrivateKey } = await this.offlineExportKey({
215
+ chainName: this.chainName,
216
+ keyShares,
217
+ derivationPath
218
+ });
219
+ return {
220
+ derivedPrivateKey
221
+ };
222
+ }
223
+ async importPrivateKey({ privateKey, chainName, thresholdSignatureScheme, password = undefined, onError }) {
224
+ // TODO: validate private key for EVM
225
+ const { rawPublicKey, clientKeyShares } = await this.importRawPrivateKey({
226
+ chainName,
227
+ privateKey,
228
+ thresholdSignatureScheme,
229
+ onError,
230
+ onCeremonyComplete: (accountAddress, walletId)=>{
231
+ // update wallet map
232
+ const checksumAddress = getAddress(accountAddress);
233
+ this.walletMap[checksumAddress] = _extends({}, this.walletMap[checksumAddress] || {}, {
234
+ accountAddress: checksumAddress,
235
+ walletId,
236
+ chainName: this.chainName,
237
+ thresholdSignatureScheme,
238
+ clientKeySharesBackupInfo: getClientKeyShareBackupInfo()
239
+ });
240
+ }
241
+ });
242
+ if (!rawPublicKey || !clientKeyShares) {
243
+ throw new Error('Error creating wallet account');
244
+ }
245
+ const { accountAddress, publicKeyHex } = await this.deriveAccountAddress({
246
+ rawPublicKey: rawPublicKey
247
+ });
248
+ // Update client key shares in wallet map
249
+ await this.setClientKeySharesToLocalStorage({
250
+ accountAddress,
251
+ clientKeyShares,
252
+ overwriteOrMerge: 'overwrite'
253
+ });
254
+ // Backup the new wallet without waiting for the promise to resolve
255
+ void this.storeEncryptedBackupByWalletWithRetry({
256
+ accountAddress,
257
+ clientKeyShares,
258
+ password
259
+ });
260
+ return {
261
+ accountAddress,
262
+ rawPublicKey,
263
+ publicKeyHex
264
+ };
265
+ }
266
+ async getEvmWallets() {
267
+ const wallets = await this.getWallets();
268
+ const evmWallets = wallets.filter((wallet)=>wallet.chainName === 'eip155');
269
+ return evmWallets;
270
+ }
271
+ constructor({ environmentId, authToken, baseApiUrl, baseMPCRelayApiUrl, storageKey, debug }){
272
+ super({
273
+ environmentId,
274
+ authToken,
275
+ baseApiUrl,
276
+ baseMPCRelayApiUrl,
277
+ storageKey,
278
+ debug
279
+ }), this.chainName = 'EVM';
280
+ }
281
+ }
282
+
283
+ export { DynamicEvmWalletClient };
package/package.json ADDED
@@ -0,0 +1,31 @@
1
+ {
2
+ "name": "@dynamic-labs-wallet/evm",
3
+ "version": "0.0.0-beta.146.1",
4
+ "license": "MIT",
5
+ "dependencies": {
6
+ "@dynamic-labs-wallet/browser": "0.0.0-beta.146.1"
7
+ },
8
+ "peerDependencies": {
9
+ "viem": "^2.22.1"
10
+ },
11
+ "nx": {
12
+ "sourceRoot": "packages/evm/src",
13
+ "projectType": "library",
14
+ "name": "evm",
15
+ "targets": {
16
+ "build": {}
17
+ }
18
+ },
19
+ "main": "./index.cjs.js",
20
+ "module": "./index.esm.js",
21
+ "types": "./index.esm.d.ts",
22
+ "exports": {
23
+ "./package.json": "./package.json",
24
+ ".": {
25
+ "types": "./index.esm.d.ts",
26
+ "import": "./index.esm.js",
27
+ "require": "./index.cjs.js",
28
+ "default": "./index.cjs.js"
29
+ }
30
+ }
31
+ }
@@ -0,0 +1,63 @@
1
+ import { DynamicWalletClient, EcdsaKeygenResult, EcdsaPublicKey, Ed25519KeygenResult, ThresholdSignatureScheme, DynamicWalletClientProps } from '@dynamic-labs-wallet/browser';
2
+ import { type PublicClient, type Chain, type SignableMessage, type TransactionSerializable } from 'viem';
3
+ export declare class DynamicEvmWalletClient extends DynamicWalletClient {
4
+ readonly chainName = "EVM";
5
+ constructor({ environmentId, authToken, baseApiUrl, baseMPCRelayApiUrl, storageKey, debug, }: DynamicWalletClientProps);
6
+ createViemPublicClient({ chain, rpcUrl, }: {
7
+ chain: Chain;
8
+ rpcUrl?: string;
9
+ }): PublicClient;
10
+ createWalletAccount({ thresholdSignatureScheme, password, onError, }: {
11
+ thresholdSignatureScheme: ThresholdSignatureScheme;
12
+ password?: string;
13
+ onError?: (error: Error) => void;
14
+ }): Promise<{
15
+ accountAddress: string;
16
+ publicKeyHex: string;
17
+ rawPublicKey: EcdsaPublicKey | Uint8Array | undefined;
18
+ }>;
19
+ signMessage({ message, accountAddress, password, }: {
20
+ message: string;
21
+ accountAddress: string;
22
+ password?: string;
23
+ }): Promise<`0x${string}`>;
24
+ verifyMessageSignature({ accountAddress, message, signature, }: {
25
+ accountAddress: string;
26
+ message: SignableMessage;
27
+ signature: any;
28
+ }): Promise<boolean>;
29
+ signTransaction({ senderAddress, transaction, password, }: {
30
+ senderAddress: string;
31
+ transaction: TransactionSerializable;
32
+ password?: string;
33
+ }): Promise<string>;
34
+ deriveAccountAddress({ rawPublicKey }: {
35
+ rawPublicKey: EcdsaPublicKey;
36
+ }): {
37
+ accountAddress: `0x${string}`;
38
+ publicKeyHex: any;
39
+ };
40
+ exportPrivateKey({ accountAddress, password, }: {
41
+ accountAddress: string;
42
+ password?: string;
43
+ }): Promise<string | undefined>;
44
+ offlineExportPrivateKey({ keyShares, derivationPath, }: {
45
+ keyShares: (EcdsaKeygenResult | Ed25519KeygenResult)[];
46
+ derivationPath?: string;
47
+ }): Promise<{
48
+ derivedPrivateKey: string | undefined;
49
+ }>;
50
+ importPrivateKey({ privateKey, chainName, thresholdSignatureScheme, password, onError, }: {
51
+ privateKey: string;
52
+ chainName: string;
53
+ thresholdSignatureScheme: ThresholdSignatureScheme;
54
+ password?: string;
55
+ onError?: (error: Error) => void;
56
+ }): Promise<{
57
+ accountAddress: string;
58
+ publicKeyHex: string;
59
+ rawPublicKey: EcdsaPublicKey | Uint8Array | undefined;
60
+ }>;
61
+ getEvmWallets(): Promise<any>;
62
+ }
63
+ //# sourceMappingURL=client.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/client/client.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,mBAAmB,EACnB,iBAAiB,EACjB,cAAc,EAEd,mBAAmB,EACnB,wBAAwB,EACxB,wBAAwB,EAIzB,MAAM,8BAA8B,CAAC;AACtC,OAAO,EAGL,KAAK,YAAY,EACjB,KAAK,KAAK,EAEV,KAAK,eAAe,EACpB,KAAK,uBAAuB,EAE7B,MAAM,MAAM,CAAC;AAWd,qBAAa,sBAAuB,SAAQ,mBAAmB;IAC7D,QAAQ,CAAC,SAAS,SAAS;gBAEf,EACV,aAAa,EACb,SAAS,EACT,UAAU,EACV,kBAAkB,EAClB,UAAU,EACV,KAAK,GACN,EAAE,wBAAwB;IAW3B,sBAAsB,CAAC,EACrB,KAAK,EACL,MAAM,GACP,EAAE;QACD,KAAK,EAAE,KAAK,CAAC;QACb,MAAM,CAAC,EAAE,MAAM,CAAC;KACjB,GAAG,YAAY;IAOV,mBAAmB,CAAC,EACxB,wBAAwB,EACxB,QAAoB,EACpB,OAAO,GACR,EAAE;QACD,wBAAwB,EAAE,wBAAwB,CAAC;QACnD,QAAQ,CAAC,EAAE,MAAM,CAAC;QAClB,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,CAAC;KAClC,GAAG,OAAO,CAAC;QACV,cAAc,EAAE,MAAM,CAAC;QACvB,YAAY,EAAE,MAAM,CAAC;QACrB,YAAY,EAAE,cAAc,GAAG,UAAU,GAAG,SAAS,CAAC;KACvD,CAAC;IAiEI,WAAW,CAAC,EAChB,OAAO,EACP,cAAc,EACd,QAAoB,GACrB,EAAE;QACD,OAAO,EAAE,MAAM,CAAC;QAChB,cAAc,EAAE,MAAM,CAAC;QACvB,QAAQ,CAAC,EAAE,MAAM,CAAC;KACnB;IAiCK,sBAAsB,CAAC,EAC3B,cAAc,EACd,OAAO,EACP,SAAS,GACV,EAAE;QACD,cAAc,EAAE,MAAM,CAAC;QACvB,OAAO,EAAE,eAAe,CAAC;QACzB,SAAS,EAAE,GAAG,CAAC;KAChB;IAmBK,eAAe,CAAC,EACpB,aAAa,EACb,WAAW,EACX,QAAoB,GACrB,EAAE;QACD,aAAa,EAAE,MAAM,CAAC;QACtB,WAAW,EAAE,uBAAuB,CAAC;QACrC,QAAQ,CAAC,EAAE,MAAM,CAAC;KACnB,GAAG,OAAO,CAAC,MAAM,CAAC;IAmDnB,oBAAoB,CAAC,EAAE,YAAY,EAAE,EAAE;QAAE,YAAY,EAAE,cAAc,CAAA;KAAE;;;;IAUjE,gBAAgB,CAAC,EACrB,cAAc,EACd,QAAoB,GACrB,EAAE;QACD,cAAc,EAAE,MAAM,CAAC;QACvB,QAAQ,CAAC,EAAE,MAAM,CAAC;KACnB,GAAG,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC;IAgBzB,uBAAuB,CAAC,EAC5B,SAAS,EACT,cAAc,GACf,EAAE;QACD,SAAS,EAAE,CAAC,iBAAiB,GAAG,mBAAmB,CAAC,EAAE,CAAC;QACvD,cAAc,CAAC,EAAE,MAAM,CAAC;KACzB;;;IAUK,gBAAgB,CAAC,EACrB,UAAU,EACV,SAAS,EACT,wBAAwB,EACxB,QAAoB,EACpB,OAAO,GACR,EAAE;QACD,UAAU,EAAE,MAAM,CAAC;QACnB,SAAS,EAAE,MAAM,CAAC;QAClB,wBAAwB,EAAE,wBAAwB,CAAC;QACnD,QAAQ,CAAC,EAAE,MAAM,CAAC;QAClB,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,CAAC;KAClC,GAAG,OAAO,CAAC;QACV,cAAc,EAAE,MAAM,CAAC;QACvB,YAAY,EAAE,MAAM,CAAC;QACrB,YAAY,EAAE,cAAc,GAAG,UAAU,GAAG,SAAS,CAAC;KACvD,CAAC;IAiDI,aAAa;CAOpB"}
@@ -0,0 +1,7 @@
1
+ export declare const EVM_SIGN_MESSAGE_PREFIX = "\u0019Ethereum Signed Message:\n";
2
+ export declare const ERROR_KEYGEN_FAILED = "Error with keygen";
3
+ export declare const ERROR_CREATE_WALLET_ACCOUNT = "Error creating evm wallet account";
4
+ export declare const ERROR_SIGN_MESSAGE = "Error signing message";
5
+ export declare const ERROR_ACCOUNT_ADDRESS_REQUIRED = "Account address is required";
6
+ export declare const ERROR_VERIFY_MESSAGE_SIGNATURE = "Error verifying message signature";
7
+ //# sourceMappingURL=constants.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../src/client/constants.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,uBAAuB,qCAAmC,CAAC;AAGxE,eAAO,MAAM,mBAAmB,sBAAsB,CAAC;AAEvD,eAAO,MAAM,2BAA2B,sCAAsC,CAAC;AAE/E,eAAO,MAAM,kBAAkB,0BAA0B,CAAC;AAE1D,eAAO,MAAM,8BAA8B,gCAAgC,CAAC;AAE5E,eAAO,MAAM,8BAA8B,sCACN,CAAC"}
@@ -0,0 +1,2 @@
1
+ export * from './client';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/client/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC"}
package/src/index.d.ts ADDED
@@ -0,0 +1,2 @@
1
+ export * from './client';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../packages/src/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC"}
package/src/utils.d.ts ADDED
@@ -0,0 +1,6 @@
1
+ import type { EcdsaSignature } from '@dynamic-labs-wallet/browser';
2
+ export declare const formatEVMMessage: (message_: string | {
3
+ raw: string | Uint8Array;
4
+ }) => `0x${string}`;
5
+ export declare const serializeECDSASignature: (signature: EcdsaSignature) => `0x${string}`;
6
+ //# sourceMappingURL=utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../packages/src/utils.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAEnE,eAAO,MAAM,gBAAgB,aACjB,MAAM,GAAG;IAAE,GAAG,EAAE,MAAM,GAAG,UAAU,CAAA;CAAE,kBAUhD,CAAC;AAEF,eAAO,MAAM,uBAAuB,cAAe,cAAc,kBAMhE,CAAC"}