@dynamic-labs/embedded-wallet-evm 4.6.3 → 4.7.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 +21 -0
- package/package.cjs +1 -1
- package/package.js +1 -1
- package/package.json +9 -9
- package/src/lib/TurnkeyEVMWalletConnector/TurnkeyEVMWalletConnector.cjs +66 -0
- package/src/lib/TurnkeyEVMWalletConnector/TurnkeyEVMWalletConnector.d.ts +3 -1
- package/src/lib/TurnkeyEVMWalletConnector/TurnkeyEVMWalletConnector.js +66 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,4 +1,25 @@
|
|
|
1
1
|
|
|
2
|
+
### [4.7.1](https://github.com/dynamic-labs/dynamic-auth/compare/v4.7.0...v4.7.1) (2025-02-20)
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
### Bug Fixes
|
|
6
|
+
|
|
7
|
+
* remove user logout when sdk version change ([#8112](https://github.com/dynamic-labs/dynamic-auth/issues/8112)) ([b1a321f](https://github.com/dynamic-labs/dynamic-auth/commit/b1a321f18231f083aeb365d4dc92e992897a7e1b))
|
|
8
|
+
|
|
9
|
+
## [4.7.0](https://github.com/dynamic-labs/dynamic-auth/compare/v4.6.3...v4.7.0) (2025-02-20)
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
### Features
|
|
13
|
+
|
|
14
|
+
* 7702 support ([14ee3cd](https://github.com/dynamic-labs/dynamic-auth/commit/14ee3cd3513ac8b3e8e866cc2026b042c706b7e6))
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
### Bug Fixes
|
|
18
|
+
|
|
19
|
+
* fallback to empty array when token balances is called with an invalid chain ID ([#8108](https://github.com/dynamic-labs/dynamic-auth/issues/8108)) ([7d14ded](https://github.com/dynamic-labs/dynamic-auth/commit/7d14ded6afa0de604901bbc8bc13620d03dc2e8c))
|
|
20
|
+
* improve global connectivity sign typed data reliability ([#8103](https://github.com/dynamic-labs/dynamic-auth/issues/8103)) ([8b0d2dd](https://github.com/dynamic-labs/dynamic-auth/commit/8b0d2ddbeb62a11732a9d59bc6cd4b72d82b9855))
|
|
21
|
+
* **QNTM-2902:** ensure react updates icons ([#8105](https://github.com/dynamic-labs/dynamic-auth/issues/8105)) ([1182c4c](https://github.com/dynamic-labs/dynamic-auth/commit/1182c4cc103c599e6bbff89af9b1312fb96b6d05))
|
|
22
|
+
|
|
2
23
|
### [4.6.3](https://github.com/dynamic-labs/dynamic-auth/compare/v4.6.2...v4.6.3) (2025-02-14)
|
|
3
24
|
|
|
4
25
|
|
package/package.cjs
CHANGED
package/package.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dynamic-labs/embedded-wallet-evm",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.7.1",
|
|
4
4
|
"description": "A React SDK for implementing wallet web3 authentication and authorization to your website.",
|
|
5
5
|
"author": "Dynamic Labs, Inc.",
|
|
6
6
|
"license": "MIT",
|
|
@@ -23,14 +23,14 @@
|
|
|
23
23
|
"@turnkey/iframe-stamper": "2.0.0",
|
|
24
24
|
"@turnkey/viem": "0.6.2",
|
|
25
25
|
"@turnkey/webauthn-stamper": "0.5.0",
|
|
26
|
-
"@dynamic-labs/assert-package-version": "4.
|
|
27
|
-
"@dynamic-labs/embedded-wallet": "4.
|
|
28
|
-
"@dynamic-labs/ethereum-core": "4.
|
|
29
|
-
"@dynamic-labs/types": "4.
|
|
30
|
-
"@dynamic-labs/utils": "4.
|
|
31
|
-
"@dynamic-labs/wallet-book": "4.
|
|
32
|
-
"@dynamic-labs/wallet-connector-core": "4.
|
|
33
|
-
"@dynamic-labs/webauthn": "4.
|
|
26
|
+
"@dynamic-labs/assert-package-version": "4.7.1",
|
|
27
|
+
"@dynamic-labs/embedded-wallet": "4.7.1",
|
|
28
|
+
"@dynamic-labs/ethereum-core": "4.7.1",
|
|
29
|
+
"@dynamic-labs/types": "4.7.1",
|
|
30
|
+
"@dynamic-labs/utils": "4.7.1",
|
|
31
|
+
"@dynamic-labs/wallet-book": "4.7.1",
|
|
32
|
+
"@dynamic-labs/wallet-connector-core": "4.7.1",
|
|
33
|
+
"@dynamic-labs/webauthn": "4.7.1"
|
|
34
34
|
},
|
|
35
35
|
"peerDependencies": {
|
|
36
36
|
"viem": "^2.21.55"
|
|
@@ -10,6 +10,7 @@ var viem$1 = require('@turnkey/viem');
|
|
|
10
10
|
var webauthnStamper = require('@turnkey/webauthn-stamper');
|
|
11
11
|
var viem = require('viem');
|
|
12
12
|
var accounts = require('viem/accounts');
|
|
13
|
+
var experimental = require('viem/experimental');
|
|
13
14
|
var utils = require('@dynamic-labs/utils');
|
|
14
15
|
var ethereumCore = require('@dynamic-labs/ethereum-core');
|
|
15
16
|
var walletConnectorCore = require('@dynamic-labs/wallet-connector-core');
|
|
@@ -102,6 +103,44 @@ class TurnkeyEVMWalletConnector extends embeddedWallet.TurnkeyWalletConnectorBas
|
|
|
102
103
|
}
|
|
103
104
|
});
|
|
104
105
|
}
|
|
106
|
+
experimental_signAuthorization(parameters) {
|
|
107
|
+
return _tslib.__awaiter(this, void 0, void 0, function* () {
|
|
108
|
+
var _a;
|
|
109
|
+
const { contractAddress } = parameters;
|
|
110
|
+
const chainId = this.currentChainId;
|
|
111
|
+
yield this.createOrRestoreSession();
|
|
112
|
+
if (!chainId) {
|
|
113
|
+
throw new Error('Chain id not found');
|
|
114
|
+
}
|
|
115
|
+
const [signer, publicClient] = yield Promise.all([
|
|
116
|
+
this.getSigner(),
|
|
117
|
+
this.getPublicClient(),
|
|
118
|
+
]);
|
|
119
|
+
if (!signer || !publicClient) {
|
|
120
|
+
throw new Error('Required clients not found');
|
|
121
|
+
}
|
|
122
|
+
const { turnkeySubOrganizationId } = (_a = this.walletProperties) !== null && _a !== void 0 ? _a : {};
|
|
123
|
+
if (!turnkeySubOrganizationId) {
|
|
124
|
+
throw new Error('Turnkey sub organization id not found');
|
|
125
|
+
}
|
|
126
|
+
const { address } = signer.account;
|
|
127
|
+
const nonce = yield publicClient.getTransactionCount({ address });
|
|
128
|
+
const signature = yield this.internalSign({
|
|
129
|
+
address,
|
|
130
|
+
hash: experimental.hashAuthorization({ chainId, contractAddress, nonce }),
|
|
131
|
+
turnkeySubOrganizationId,
|
|
132
|
+
});
|
|
133
|
+
return {
|
|
134
|
+
chainId,
|
|
135
|
+
contractAddress,
|
|
136
|
+
nonce,
|
|
137
|
+
r: signature.r,
|
|
138
|
+
s: signature.s,
|
|
139
|
+
v: BigInt(signature.v),
|
|
140
|
+
yParity: signature.yParity,
|
|
141
|
+
};
|
|
142
|
+
});
|
|
143
|
+
}
|
|
105
144
|
getBalance(address) {
|
|
106
145
|
return _tslib.__awaiter(this, void 0, void 0, function* () {
|
|
107
146
|
const client = yield this.getPublicClient();
|
|
@@ -236,6 +275,33 @@ class TurnkeyEVMWalletConnector extends embeddedWallet.TurnkeyWalletConnectorBas
|
|
|
236
275
|
const chainId = this.currentChainId;
|
|
237
276
|
return this.evmNetworks.find((network) => network.chainId === chainId);
|
|
238
277
|
}
|
|
278
|
+
internalSign(_a) {
|
|
279
|
+
return _tslib.__awaiter(this, arguments, void 0, function* ({ hash, address, turnkeySubOrganizationId, }) {
|
|
280
|
+
var _b;
|
|
281
|
+
const client = this.getTurnkeyClient();
|
|
282
|
+
const { activity } = yield client.signRawPayload({
|
|
283
|
+
organizationId: turnkeySubOrganizationId,
|
|
284
|
+
parameters: {
|
|
285
|
+
encoding: 'PAYLOAD_ENCODING_HEXADECIMAL',
|
|
286
|
+
hashFunction: 'HASH_FUNCTION_NO_OP',
|
|
287
|
+
payload: hash,
|
|
288
|
+
signWith: address,
|
|
289
|
+
},
|
|
290
|
+
timestampMs: Date.now().toString(),
|
|
291
|
+
type: 'ACTIVITY_TYPE_SIGN_RAW_PAYLOAD_V2',
|
|
292
|
+
});
|
|
293
|
+
const result = (_b = activity === null || activity === void 0 ? void 0 : activity.result) === null || _b === void 0 ? void 0 : _b.signRawPayloadResult;
|
|
294
|
+
if (!result) {
|
|
295
|
+
throw new Error('Sign raw payload result not found');
|
|
296
|
+
}
|
|
297
|
+
return {
|
|
298
|
+
r: `0x${result.r}`,
|
|
299
|
+
s: `0x${result.s}`,
|
|
300
|
+
v: result.v,
|
|
301
|
+
yParity: Number(result.v) % 2,
|
|
302
|
+
};
|
|
303
|
+
});
|
|
304
|
+
}
|
|
239
305
|
internalSignTransaction(_a) {
|
|
240
306
|
return _tslib.__awaiter(this, arguments, void 0, function* ({ transaction, args, address, turnkeySubOrganizationId, }) {
|
|
241
307
|
return this.doRetryableTurnkeyAction({
|
|
@@ -3,7 +3,7 @@ import { JwtVerifiedCredential } from '@dynamic-labs/sdk-api-core';
|
|
|
3
3
|
import { EvmNetwork, GenericNetwork, IUITransaction, WalletUiUtils } from '@dynamic-labs/types';
|
|
4
4
|
import { IChainRpcProviders, EthereumWallet, RegisterEvmProvidersConfig } from '@dynamic-labs/ethereum-core';
|
|
5
5
|
import { WalletBookSchema } from '@dynamic-labs/wallet-book';
|
|
6
|
-
import type { Chain, ISendBalanceWalletConnector, InternalWalletConnector } from '@dynamic-labs/wallet-connector-core';
|
|
6
|
+
import type { Chain, EVMAuthorizationParameters, EVMAuthorizationResult, ISendBalanceWalletConnector, InternalWalletConnector } from '@dynamic-labs/wallet-connector-core';
|
|
7
7
|
import { TurnkeyWalletConnectorNameAndKey, TurnkeyWalletConnectorBase } from '@dynamic-labs/embedded-wallet';
|
|
8
8
|
export type TurnkeyEVMConnectorProps = {
|
|
9
9
|
walletUiUtils: WalletUiUtils<InternalWalletConnector>;
|
|
@@ -39,6 +39,7 @@ export declare class TurnkeyEVMWalletConnector extends TurnkeyWalletConnectorBas
|
|
|
39
39
|
}): Promise<void>;
|
|
40
40
|
setVerifiedCredentials(verifiedCredentials: JwtVerifiedCredential[]): void;
|
|
41
41
|
validateActiveWallet(expectedAddress: string): Promise<void>;
|
|
42
|
+
experimental_signAuthorization(parameters: EVMAuthorizationParameters): Promise<EVMAuthorizationResult>;
|
|
42
43
|
getBalance(address: string): Promise<string | undefined>;
|
|
43
44
|
signMessage(messageToSign: string): Promise<string | undefined>;
|
|
44
45
|
getPublicClient(): Promise<void | PublicClient<Transport, ViemChain> | undefined>;
|
|
@@ -50,6 +51,7 @@ export declare class TurnkeyEVMWalletConnector extends TurnkeyWalletConnectorBas
|
|
|
50
51
|
set lastUsedChainId(chainId: number | undefined);
|
|
51
52
|
private get networkRpcUrl();
|
|
52
53
|
private get currentEvmNetwork();
|
|
54
|
+
private internalSign;
|
|
53
55
|
private internalSignTransaction;
|
|
54
56
|
private internalSignTypedData;
|
|
55
57
|
private internalSignMessage;
|
|
@@ -6,6 +6,7 @@ import { createAccount } from '@turnkey/viem';
|
|
|
6
6
|
import { WebauthnStamper } from '@turnkey/webauthn-stamper';
|
|
7
7
|
import { http, formatEther } from 'viem';
|
|
8
8
|
import { toAccount } from 'viem/accounts';
|
|
9
|
+
import { hashAuthorization } from 'viem/experimental';
|
|
9
10
|
import { parseEvmNetworks, DynamicError } from '@dynamic-labs/utils';
|
|
10
11
|
import { EthereumWallet, createWalletClientWithUiConfirmation, getOrMapViemChain, createViemUiTransaction } from '@dynamic-labs/ethereum-core';
|
|
11
12
|
import { getRpcUrlForChain, isSameAddress } from '@dynamic-labs/wallet-connector-core';
|
|
@@ -98,6 +99,44 @@ class TurnkeyEVMWalletConnector extends TurnkeyWalletConnectorBase {
|
|
|
98
99
|
}
|
|
99
100
|
});
|
|
100
101
|
}
|
|
102
|
+
experimental_signAuthorization(parameters) {
|
|
103
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
104
|
+
var _a;
|
|
105
|
+
const { contractAddress } = parameters;
|
|
106
|
+
const chainId = this.currentChainId;
|
|
107
|
+
yield this.createOrRestoreSession();
|
|
108
|
+
if (!chainId) {
|
|
109
|
+
throw new Error('Chain id not found');
|
|
110
|
+
}
|
|
111
|
+
const [signer, publicClient] = yield Promise.all([
|
|
112
|
+
this.getSigner(),
|
|
113
|
+
this.getPublicClient(),
|
|
114
|
+
]);
|
|
115
|
+
if (!signer || !publicClient) {
|
|
116
|
+
throw new Error('Required clients not found');
|
|
117
|
+
}
|
|
118
|
+
const { turnkeySubOrganizationId } = (_a = this.walletProperties) !== null && _a !== void 0 ? _a : {};
|
|
119
|
+
if (!turnkeySubOrganizationId) {
|
|
120
|
+
throw new Error('Turnkey sub organization id not found');
|
|
121
|
+
}
|
|
122
|
+
const { address } = signer.account;
|
|
123
|
+
const nonce = yield publicClient.getTransactionCount({ address });
|
|
124
|
+
const signature = yield this.internalSign({
|
|
125
|
+
address,
|
|
126
|
+
hash: hashAuthorization({ chainId, contractAddress, nonce }),
|
|
127
|
+
turnkeySubOrganizationId,
|
|
128
|
+
});
|
|
129
|
+
return {
|
|
130
|
+
chainId,
|
|
131
|
+
contractAddress,
|
|
132
|
+
nonce,
|
|
133
|
+
r: signature.r,
|
|
134
|
+
s: signature.s,
|
|
135
|
+
v: BigInt(signature.v),
|
|
136
|
+
yParity: signature.yParity,
|
|
137
|
+
};
|
|
138
|
+
});
|
|
139
|
+
}
|
|
101
140
|
getBalance(address) {
|
|
102
141
|
return __awaiter(this, void 0, void 0, function* () {
|
|
103
142
|
const client = yield this.getPublicClient();
|
|
@@ -232,6 +271,33 @@ class TurnkeyEVMWalletConnector extends TurnkeyWalletConnectorBase {
|
|
|
232
271
|
const chainId = this.currentChainId;
|
|
233
272
|
return this.evmNetworks.find((network) => network.chainId === chainId);
|
|
234
273
|
}
|
|
274
|
+
internalSign(_a) {
|
|
275
|
+
return __awaiter(this, arguments, void 0, function* ({ hash, address, turnkeySubOrganizationId, }) {
|
|
276
|
+
var _b;
|
|
277
|
+
const client = this.getTurnkeyClient();
|
|
278
|
+
const { activity } = yield client.signRawPayload({
|
|
279
|
+
organizationId: turnkeySubOrganizationId,
|
|
280
|
+
parameters: {
|
|
281
|
+
encoding: 'PAYLOAD_ENCODING_HEXADECIMAL',
|
|
282
|
+
hashFunction: 'HASH_FUNCTION_NO_OP',
|
|
283
|
+
payload: hash,
|
|
284
|
+
signWith: address,
|
|
285
|
+
},
|
|
286
|
+
timestampMs: Date.now().toString(),
|
|
287
|
+
type: 'ACTIVITY_TYPE_SIGN_RAW_PAYLOAD_V2',
|
|
288
|
+
});
|
|
289
|
+
const result = (_b = activity === null || activity === void 0 ? void 0 : activity.result) === null || _b === void 0 ? void 0 : _b.signRawPayloadResult;
|
|
290
|
+
if (!result) {
|
|
291
|
+
throw new Error('Sign raw payload result not found');
|
|
292
|
+
}
|
|
293
|
+
return {
|
|
294
|
+
r: `0x${result.r}`,
|
|
295
|
+
s: `0x${result.s}`,
|
|
296
|
+
v: result.v,
|
|
297
|
+
yParity: Number(result.v) % 2,
|
|
298
|
+
};
|
|
299
|
+
});
|
|
300
|
+
}
|
|
235
301
|
internalSignTransaction(_a) {
|
|
236
302
|
return __awaiter(this, arguments, void 0, function* ({ transaction, args, address, turnkeySubOrganizationId, }) {
|
|
237
303
|
return this.doRetryableTurnkeyAction({
|