@dynamic-labs-wallet/node-evm 0.0.0-beta.319 → 0.0.0-beta.321
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 +36 -0
- package/index.esm.js +36 -0
- package/package.json +2 -2
- package/src/client/client.d.ts +9 -2
- package/src/client/client.d.ts.map +1 -1
package/index.cjs.js
CHANGED
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
var node = require('@dynamic-labs-wallet/node');
|
|
4
4
|
var viem = require('viem');
|
|
5
5
|
var chains = require('viem/chains');
|
|
6
|
+
var utils = require('viem/utils');
|
|
6
7
|
|
|
7
8
|
function _extends() {
|
|
8
9
|
_extends = Object.assign || function assign(target) {
|
|
@@ -160,6 +161,41 @@ class DynamicEvmWalletClient extends node.DynamicWalletClient {
|
|
|
160
161
|
throw new Error(ERROR_SIGN_MESSAGE);
|
|
161
162
|
}
|
|
162
163
|
}
|
|
164
|
+
async signAuthorization({ authorization, accountAddress, password = undefined, externalServerKeyShares, onError }) {
|
|
165
|
+
try {
|
|
166
|
+
if (!accountAddress) {
|
|
167
|
+
throw new Error(ERROR_ACCOUNT_ADDRESS_REQUIRED);
|
|
168
|
+
}
|
|
169
|
+
console.log('authorization', authorization);
|
|
170
|
+
const digest = utils.hashAuthorization(authorization);
|
|
171
|
+
console.log('digest', digest);
|
|
172
|
+
const prehashed = digest.startsWith('0x') ? digest.slice(2) : digest;
|
|
173
|
+
const signatureEcdsa = await this.sign({
|
|
174
|
+
message: prehashed,
|
|
175
|
+
accountAddress: accountAddress,
|
|
176
|
+
chainName: this.chainName,
|
|
177
|
+
password,
|
|
178
|
+
externalServerKeyShares,
|
|
179
|
+
isFormatted: true,
|
|
180
|
+
context: {
|
|
181
|
+
eip7702Auth: authorization
|
|
182
|
+
},
|
|
183
|
+
onError
|
|
184
|
+
});
|
|
185
|
+
console.log('signatureEcdsa', signatureEcdsa);
|
|
186
|
+
const serializedSignature = serializeECDSASignature(signatureEcdsa);
|
|
187
|
+
const isVerified = await utils.verifyAuthorization({
|
|
188
|
+
address: accountAddress,
|
|
189
|
+
authorization,
|
|
190
|
+
signature: serializedSignature
|
|
191
|
+
});
|
|
192
|
+
console.log('isVerified', isVerified);
|
|
193
|
+
return serializedSignature;
|
|
194
|
+
} catch (error) {
|
|
195
|
+
this.logger.error(ERROR_SIGN_MESSAGE, error);
|
|
196
|
+
throw new Error(ERROR_SIGN_MESSAGE);
|
|
197
|
+
}
|
|
198
|
+
}
|
|
163
199
|
async verifyMessageSignature({ accountAddress, message, signature }) {
|
|
164
200
|
try {
|
|
165
201
|
// Verify the signature using the public client
|
package/index.esm.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { MessageHash, DynamicWalletClient, getMPCChainConfig, getExternalServerKeyShareBackupInfo, WalletOperation, createDelegatedWalletClient, delegatedSignMessage as delegatedSignMessage$1, revokeDelegation as revokeDelegation$1 } from '@dynamic-labs-wallet/node';
|
|
2
2
|
import { stringToHex, bytesToHex, size, concat, serializeSignature, getAddress, createPublicClient, http, serializeTransaction } from 'viem';
|
|
3
3
|
import { mainnet } from 'viem/chains';
|
|
4
|
+
import { hashAuthorization, verifyAuthorization } from 'viem/utils';
|
|
4
5
|
|
|
5
6
|
function _extends() {
|
|
6
7
|
_extends = Object.assign || function assign(target) {
|
|
@@ -158,6 +159,41 @@ class DynamicEvmWalletClient extends DynamicWalletClient {
|
|
|
158
159
|
throw new Error(ERROR_SIGN_MESSAGE);
|
|
159
160
|
}
|
|
160
161
|
}
|
|
162
|
+
async signAuthorization({ authorization, accountAddress, password = undefined, externalServerKeyShares, onError }) {
|
|
163
|
+
try {
|
|
164
|
+
if (!accountAddress) {
|
|
165
|
+
throw new Error(ERROR_ACCOUNT_ADDRESS_REQUIRED);
|
|
166
|
+
}
|
|
167
|
+
console.log('authorization', authorization);
|
|
168
|
+
const digest = hashAuthorization(authorization);
|
|
169
|
+
console.log('digest', digest);
|
|
170
|
+
const prehashed = digest.startsWith('0x') ? digest.slice(2) : digest;
|
|
171
|
+
const signatureEcdsa = await this.sign({
|
|
172
|
+
message: prehashed,
|
|
173
|
+
accountAddress: accountAddress,
|
|
174
|
+
chainName: this.chainName,
|
|
175
|
+
password,
|
|
176
|
+
externalServerKeyShares,
|
|
177
|
+
isFormatted: true,
|
|
178
|
+
context: {
|
|
179
|
+
eip7702Auth: authorization
|
|
180
|
+
},
|
|
181
|
+
onError
|
|
182
|
+
});
|
|
183
|
+
console.log('signatureEcdsa', signatureEcdsa);
|
|
184
|
+
const serializedSignature = serializeECDSASignature(signatureEcdsa);
|
|
185
|
+
const isVerified = await verifyAuthorization({
|
|
186
|
+
address: accountAddress,
|
|
187
|
+
authorization,
|
|
188
|
+
signature: serializedSignature
|
|
189
|
+
});
|
|
190
|
+
console.log('isVerified', isVerified);
|
|
191
|
+
return serializedSignature;
|
|
192
|
+
} catch (error) {
|
|
193
|
+
this.logger.error(ERROR_SIGN_MESSAGE, error);
|
|
194
|
+
throw new Error(ERROR_SIGN_MESSAGE);
|
|
195
|
+
}
|
|
196
|
+
}
|
|
161
197
|
async verifyMessageSignature({ accountAddress, message, signature }) {
|
|
162
198
|
try {
|
|
163
199
|
// Verify the signature using the public client
|
package/package.json
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dynamic-labs-wallet/node-evm",
|
|
3
|
-
"version": "0.0.0-beta.
|
|
3
|
+
"version": "0.0.0-beta.321",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"dependencies": {
|
|
7
|
-
"@dynamic-labs-wallet/node": "0.0.0-beta.
|
|
7
|
+
"@dynamic-labs-wallet/node": "0.0.0-beta.321",
|
|
8
8
|
"@dynamic-labs/sdk-api-core": "^0.0.801"
|
|
9
9
|
},
|
|
10
10
|
"publishConfig": {
|
package/src/client/client.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { type
|
|
2
|
-
import { type PublicClient, type Chain, type SignableMessage, type TransactionSerializable } from 'viem';
|
|
1
|
+
import { DynamicWalletClient, type DynamicWalletClientProps, type EcdsaKeygenResult, type EcdsaPublicKey, type Ed25519KeygenResult, type ServerKeyShare, type ThresholdSignatureScheme } from '@dynamic-labs-wallet/node';
|
|
3
2
|
import type { SignMessageContext } from '@dynamic-labs/sdk-api-core';
|
|
3
|
+
import { type Chain, type PublicClient, type SignableMessage, type TransactionSerializable } from 'viem';
|
|
4
4
|
export declare class DynamicEvmWalletClient extends DynamicWalletClient {
|
|
5
5
|
readonly chainName = "EVM";
|
|
6
6
|
constructor({ environmentId, baseApiUrl, baseMPCRelayApiUrl, debug, }: DynamicWalletClientProps);
|
|
@@ -36,6 +36,13 @@ export declare class DynamicEvmWalletClient extends DynamicWalletClient {
|
|
|
36
36
|
context?: SignMessageContext;
|
|
37
37
|
onError?: (error: Error) => void;
|
|
38
38
|
}): Promise<`0x${string}`>;
|
|
39
|
+
signAuthorization({ authorization, accountAddress, password, externalServerKeyShares, onError, }: {
|
|
40
|
+
authorization: any;
|
|
41
|
+
accountAddress: string;
|
|
42
|
+
password?: string;
|
|
43
|
+
externalServerKeyShares?: ServerKeyShare[];
|
|
44
|
+
onError?: (error: Error) => void;
|
|
45
|
+
}): Promise<`0x${string}`>;
|
|
39
46
|
verifyMessageSignature({ accountAddress, message, signature, }: {
|
|
40
47
|
accountAddress: string;
|
|
41
48
|
message: SignableMessage;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/client/client.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/client/client.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,mBAAmB,EACnB,KAAK,wBAAwB,EAC7B,KAAK,iBAAiB,EACtB,KAAK,cAAc,EAEnB,KAAK,mBAAmB,EAGxB,KAAK,cAAc,EACnB,KAAK,wBA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