@dynamic-labs/tempo 0.0.0 → 4.72.0

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.
@@ -0,0 +1,548 @@
1
+ 'use client'
2
+ import { __awaiter } from '../../../_virtual/_tslib.js';
3
+ import { http, serializeTransaction, createPublicClient, encodeFunctionData, erc20Abi } from 'viem';
4
+ import { toAccount } from 'viem/accounts';
5
+ import { createWalletClientWithUiConfirmation, getOrMapViemChain, ViemUiTransaction } from '@dynamic-labs/ethereum-core';
6
+ import { Logger } from '@dynamic-labs/logger';
7
+ import { MFAAction } from '@dynamic-labs/sdk-api-core';
8
+ import { DynamicError } from '@dynamic-labs/utils';
9
+ import { withDynamicWaas, WaasExportHandler } from '@dynamic-labs/waas';
10
+ import { isSameAddress } from '@dynamic-labs/wallet-connector-core';
11
+ import { TempoWalletConnector } from '../TempoWalletConnector/TempoWalletConnector.js';
12
+
13
+ const logger = new Logger('DynamicWaasTempoConnector');
14
+ // Error message constants
15
+ const ERROR_SIGNED_SESSION_ID_REQUIRED = 'Signed session ID is required';
16
+ const ERROR_TEMPO_NETWORK_NOT_FOUND = 'Tempo network not found';
17
+ class DynamicWaasTempoConnector extends withDynamicWaas(TempoWalletConnector) {
18
+ constructor(props) {
19
+ super(props);
20
+ this.name = 'Dynamic Waas';
21
+ this.logger = logger;
22
+ this.overrideKey = 'dynamicwaas';
23
+ this.isEmbeddedWallet = true;
24
+ this._selectedChainId = this.getLastUsedChainId();
25
+ this.__exportHandler = new WaasExportHandler();
26
+ }
27
+ getLastUsedChainId() {
28
+ var _a;
29
+ logger.logVerboseTroubleshootingMessage('[DynamicWaasTempoConnector] getLastUsedChainId', {
30
+ evmNetworks: this.evmNetworks,
31
+ lastUsedChainId: this.lastUsedChainId,
32
+ });
33
+ if (this.lastUsedChainId) {
34
+ return this.lastUsedChainId;
35
+ }
36
+ if (!((_a = this.evmNetworks) === null || _a === void 0 ? void 0 : _a.length)) {
37
+ return undefined;
38
+ }
39
+ return this.evmNetworks[0].chainId;
40
+ }
41
+ set verifiedCredentials(verifiedCredentials) {
42
+ this._verifiedCredentials = verifiedCredentials;
43
+ }
44
+ get verifiedCredentials() {
45
+ return this._verifiedCredentials;
46
+ }
47
+ set verifiedCredential(verifiedCredential) {
48
+ this._verifiedCredential = verifiedCredential;
49
+ }
50
+ get verifiedCredential() {
51
+ return this._verifiedCredential;
52
+ }
53
+ setVerifiedCredentials(verifiedCredentials) {
54
+ // Filter for Tempo WaaS credentials
55
+ const tempoWaasVerifiedCredentials = verifiedCredentials === null || verifiedCredentials === void 0 ? void 0 : verifiedCredentials.filter((vc) => vc.walletName === 'dynamicwaas' && vc.chain === 'tempo');
56
+ const [tempoWaasVerifiedCredential] = tempoWaasVerifiedCredentials;
57
+ const didTempoWaasVerifiedCredentialsChanged = JSON.stringify(this.verifiedCredentials) !==
58
+ JSON.stringify(tempoWaasVerifiedCredentials);
59
+ if (!didTempoWaasVerifiedCredentialsChanged) {
60
+ return;
61
+ }
62
+ this.verifiedCredential = tempoWaasVerifiedCredential;
63
+ this.verifiedCredentials = tempoWaasVerifiedCredentials;
64
+ }
65
+ set lastUsedChainId(chainId) {
66
+ if (chainId === undefined) {
67
+ localStorage.removeItem(DynamicWaasTempoConnector.lastUsedChainIdStorageKey);
68
+ }
69
+ else {
70
+ localStorage.setItem(DynamicWaasTempoConnector.lastUsedChainIdStorageKey, chainId.toString());
71
+ }
72
+ this._selectedChainId = chainId;
73
+ }
74
+ get lastUsedChainId() {
75
+ var _a;
76
+ const lastUsedChainIdLS = localStorage.getItem(DynamicWaasTempoConnector.lastUsedChainIdStorageKey);
77
+ if (!lastUsedChainIdLS)
78
+ return undefined;
79
+ try {
80
+ const chainId = parseInt(lastUsedChainIdLS);
81
+ if (isNaN(chainId)) {
82
+ return undefined;
83
+ }
84
+ const isChainCurrentlyEnabled = this.evmNetworks.some((network) => network.chainId === chainId);
85
+ if (!isChainCurrentlyEnabled) {
86
+ if (!((_a = this.evmNetworks) === null || _a === void 0 ? void 0 : _a.length)) {
87
+ return undefined;
88
+ }
89
+ const lastUsedChainId = this.evmNetworks[0].chainId;
90
+ this.lastUsedChainId = lastUsedChainId;
91
+ return lastUsedChainId;
92
+ }
93
+ return chainId;
94
+ }
95
+ catch (err) {
96
+ logger.error(err);
97
+ return undefined;
98
+ }
99
+ }
100
+ get currentChainId() {
101
+ var _a, _b, _c;
102
+ return (_a = this._selectedChainId) !== null && _a !== void 0 ? _a : (_c = (_b = this.evmNetworks) === null || _b === void 0 ? void 0 : _b[0]) === null || _c === void 0 ? void 0 : _c.chainId;
103
+ }
104
+ getNetwork() {
105
+ return __awaiter(this, void 0, void 0, function* () {
106
+ return this.currentChainId;
107
+ });
108
+ }
109
+ getEvmNetworkByChainId(chainId) {
110
+ return this.evmNetworks.find((network) => network.chainId === chainId);
111
+ }
112
+ currentEvmNetwork() {
113
+ const chainId = this.currentChainId;
114
+ if (!chainId) {
115
+ return undefined;
116
+ }
117
+ return this.getEvmNetworkByChainId(chainId);
118
+ }
119
+ switchNetwork(_a) {
120
+ return __awaiter(this, arguments, void 0, function* ({ networkChainId, }) {
121
+ if (!networkChainId) {
122
+ return;
123
+ }
124
+ let networkChainIdInt = networkChainId;
125
+ if (typeof networkChainId === 'string') {
126
+ networkChainIdInt = parseInt(networkChainId);
127
+ }
128
+ this.lastUsedChainId = networkChainIdInt;
129
+ this._selectedChainId = networkChainIdInt;
130
+ this.emit('chainChange', {
131
+ chain: networkChainIdInt.toString(),
132
+ });
133
+ });
134
+ }
135
+ getRpcUrl() {
136
+ var _a;
137
+ const evmNetwork = this.currentEvmNetwork();
138
+ if (!evmNetwork) {
139
+ throw new Error(ERROR_TEMPO_NETWORK_NOT_FOUND);
140
+ }
141
+ return ((_a = evmNetwork === null || evmNetwork === void 0 ? void 0 : evmNetwork.privateCustomerRpcUrls) === null || _a === void 0 ? void 0 : _a[0]) || (evmNetwork === null || evmNetwork === void 0 ? void 0 : evmNetwork.rpcUrls[0]);
142
+ }
143
+ validateActiveWallet(expectedAddress) {
144
+ return __awaiter(this, void 0, void 0, function* () {
145
+ var _a, _b;
146
+ const walletClient = yield this.getWaasWalletClient();
147
+ const targetWallet = yield walletClient.getWallet({
148
+ accountAddress: expectedAddress,
149
+ authToken: (_a = this.getAuthToken) === null || _a === void 0 ? void 0 : _a.call(this),
150
+ signedSessionId: '',
151
+ });
152
+ if (!targetWallet) {
153
+ throw new DynamicError('Account not found');
154
+ }
155
+ const isWalletActive = isSameAddress(targetWallet.accountAddress, ((_b = this.getActiveAccount()) === null || _b === void 0 ? void 0 : _b.address) || '', this.connectedChain);
156
+ if (!isWalletActive) {
157
+ this.setActiveAccount(targetWallet.accountAddress);
158
+ }
159
+ });
160
+ }
161
+ getActiveAccountAddress() {
162
+ return __awaiter(this, void 0, void 0, function* () {
163
+ var _a;
164
+ return (_a = this.getActiveAccount()) === null || _a === void 0 ? void 0 : _a.address;
165
+ });
166
+ }
167
+ getViemAccountCustomSource(_a) {
168
+ return __awaiter(this, arguments, void 0, function* ({ accountAddress, }) {
169
+ var _b;
170
+ const client = yield this.getWaasWalletClient();
171
+ const signedSessionId = yield ((_b = this.getSignedSessionId) === null || _b === void 0 ? void 0 : _b.call(this));
172
+ if (!signedSessionId) {
173
+ throw new DynamicError(ERROR_SIGNED_SESSION_ID_REQUIRED);
174
+ }
175
+ return {
176
+ address: accountAddress,
177
+ signMessage: (_c) => __awaiter(this, [_c], void 0, function* ({ message, }) {
178
+ var _d;
179
+ const traceId = this.generateTraceId();
180
+ const startTime = Date.now();
181
+ this.instrument('[signMessage] start', {
182
+ accountAddress,
183
+ chainName: 'TEMPO',
184
+ key: 'signMessage-start',
185
+ startTime,
186
+ time: 0,
187
+ traceId,
188
+ });
189
+ const mfaToken = yield ((_d = this.getMfaToken) === null || _d === void 0 ? void 0 : _d.call(this, {
190
+ mfaAction: MFAAction.WalletWaasSign,
191
+ }));
192
+ const password = yield this.getPasswordIfNeeded({
193
+ accountAddress,
194
+ });
195
+ const signature = yield this.instrumentAsync({
196
+ context: { chainName: 'TEMPO', startTime, traceId },
197
+ fn: () => __awaiter(this, void 0, void 0, function* () {
198
+ var _e;
199
+ return client.signMessage({
200
+ accountAddress,
201
+ authToken: (_e = this.getAuthToken) === null || _e === void 0 ? void 0 : _e.call(this),
202
+ message: message,
203
+ mfaToken,
204
+ password,
205
+ signedSessionId,
206
+ traceContext: {
207
+ startTime,
208
+ traceId,
209
+ },
210
+ });
211
+ }),
212
+ operation: 'signMessage',
213
+ resource: 'client.signMessage',
214
+ });
215
+ return signature;
216
+ }),
217
+ signTransaction: (transaction) => __awaiter(this, void 0, void 0, function* () {
218
+ var _f;
219
+ const traceId = this.generateTraceId();
220
+ const startTime = Date.now();
221
+ this.instrument('[signTransaction] start', {
222
+ accountAddress,
223
+ chainName: 'TEMPO',
224
+ key: 'signTransaction-start',
225
+ startTime,
226
+ time: 0,
227
+ traceId,
228
+ });
229
+ const mfaToken = yield ((_f = this.getMfaToken) === null || _f === void 0 ? void 0 : _f.call(this, {
230
+ mfaAction: MFAAction.WalletWaasSign,
231
+ }));
232
+ const password = yield this.getPasswordIfNeeded({ accountAddress });
233
+ // Ensure chainId is set so the signed transaction matches the RPC's chain (EIP-155).
234
+ // Wrong chainId causes "invalid signature: Failed to recover the signer" on broadcast.
235
+ const { currentChainId } = this;
236
+ const transactionWithChainId = currentChainId !== undefined
237
+ ? Object.assign(Object.assign({}, transaction), { chainId: currentChainId }) : transaction;
238
+ const tx = yield this.instrumentAsync({
239
+ context: { chainName: 'TEMPO', startTime, traceId },
240
+ fn: () => __awaiter(this, void 0, void 0, function* () {
241
+ var _g;
242
+ return client.signTransaction(Object.assign(Object.assign({ authToken: (_g = this.getAuthToken) === null || _g === void 0 ? void 0 : _g.call(this) }, (currentChainId !== undefined && {
243
+ chainId: currentChainId.toString(),
244
+ })), { mfaToken,
245
+ password, senderAddress: accountAddress, signedSessionId, traceContext: {
246
+ startTime,
247
+ traceId,
248
+ }, transaction: serializeTransaction(transactionWithChainId) }));
249
+ }),
250
+ operation: 'signTransaction',
251
+ resource: 'client.signTransaction',
252
+ });
253
+ return tx;
254
+ }),
255
+ signTypedData: (typedData) => __awaiter(this, void 0, void 0, function* () {
256
+ var _h;
257
+ const traceId = this.generateTraceId();
258
+ const startTime = Date.now();
259
+ this.instrument('[signTypedData] start', {
260
+ accountAddress,
261
+ chainName: 'TEMPO',
262
+ key: 'signTypedData-start',
263
+ startTime,
264
+ time: 0,
265
+ traceId,
266
+ });
267
+ const mfaToken = yield ((_h = this.getMfaToken) === null || _h === void 0 ? void 0 : _h.call(this, {
268
+ mfaAction: MFAAction.WalletWaasSign,
269
+ }));
270
+ const password = yield this.getPasswordIfNeeded({ accountAddress });
271
+ const signature = yield this.instrumentAsync({
272
+ context: { chainName: 'TEMPO', startTime, traceId },
273
+ fn: () => __awaiter(this, void 0, void 0, function* () {
274
+ var _j;
275
+ return client.signTypedData({
276
+ accountAddress,
277
+ authToken: (_j = this.getAuthToken) === null || _j === void 0 ? void 0 : _j.call(this),
278
+ mfaToken,
279
+ password,
280
+ signedSessionId,
281
+ traceContext: {
282
+ startTime,
283
+ traceId,
284
+ },
285
+ typedData: typedData,
286
+ });
287
+ }),
288
+ operation: 'signTypedData',
289
+ resource: 'client.signTypedData',
290
+ });
291
+ return signature;
292
+ }),
293
+ };
294
+ });
295
+ }
296
+ getViemAccount(_a) {
297
+ return __awaiter(this, arguments, void 0, function* ({ accountAddress, }) {
298
+ const accountSource = yield this.getViemAccountCustomSource({
299
+ accountAddress,
300
+ });
301
+ return toAccount(accountSource);
302
+ });
303
+ }
304
+ getWalletClient(chainId) {
305
+ var _a, _b;
306
+ const targetAccountAddress = (_a = this.getActiveAccount()) === null || _a === void 0 ? void 0 : _a.address;
307
+ if (!targetAccountAddress) {
308
+ return undefined;
309
+ }
310
+ // Resolve the network first, then get RPC URL from that network
311
+ // This ensures the RPC URL matches the resolved chain when chainId is provided
312
+ const evmNetwork = chainId
313
+ ? this.getEvmNetworkByChainId(parseInt(chainId))
314
+ : this.currentEvmNetwork();
315
+ if (!evmNetwork) {
316
+ throw new Error(ERROR_TEMPO_NETWORK_NOT_FOUND);
317
+ }
318
+ const rpcUrl = ((_b = evmNetwork.privateCustomerRpcUrls) === null || _b === void 0 ? void 0 : _b[0]) || evmNetwork.rpcUrls[0];
319
+ return createWalletClientWithUiConfirmation({
320
+ account: () => __awaiter(this, void 0, void 0, function* () {
321
+ return this.getViemAccount({
322
+ accountAddress: targetAccountAddress,
323
+ });
324
+ }),
325
+ address: targetAccountAddress,
326
+ chain: getOrMapViemChain(evmNetwork),
327
+ transport: http(rpcUrl, this.providersConfig.httpTransportConfig),
328
+ walletConnector: this,
329
+ walletUiUtils: this.walletUiUtils,
330
+ });
331
+ }
332
+ getPublicClient() {
333
+ return __awaiter(this, void 0, void 0, function* () {
334
+ var _a;
335
+ const evmNetwork = this.currentEvmNetwork();
336
+ if (!evmNetwork) {
337
+ throw new DynamicError(ERROR_TEMPO_NETWORK_NOT_FOUND);
338
+ }
339
+ const rpcUrl = ((_a = evmNetwork.privateCustomerRpcUrls) === null || _a === void 0 ? void 0 : _a[0]) || evmNetwork.rpcUrls[0];
340
+ return createPublicClient({
341
+ chain: getOrMapViemChain(evmNetwork),
342
+ transport: http(rpcUrl, this.providersConfig.httpTransportConfig),
343
+ });
344
+ });
345
+ }
346
+ signMessage(message) {
347
+ var _a;
348
+ return (_a = this.getWalletClient()) === null || _a === void 0 ? void 0 : _a.signMessage({ message });
349
+ }
350
+ signMessageWithContext(_a) {
351
+ return __awaiter(this, arguments, void 0, function* ({ message, context, }) {
352
+ var _b, _c, _d, _e;
353
+ const walletClient = yield this.getWaasWalletClient();
354
+ const signedSessionId = yield ((_b = this.getSignedSessionId) === null || _b === void 0 ? void 0 : _b.call(this));
355
+ if (!signedSessionId) {
356
+ throw new DynamicError(ERROR_SIGNED_SESSION_ID_REQUIRED);
357
+ }
358
+ const accountAddress = (_c = this.getActiveAccount()) === null || _c === void 0 ? void 0 : _c.address;
359
+ const mfaToken = yield ((_d = this.getMfaToken) === null || _d === void 0 ? void 0 : _d.call(this, {
360
+ mfaAction: MFAAction.WalletWaasSign,
361
+ }));
362
+ const password = yield this.getPasswordIfNeeded({ accountAddress });
363
+ const traceId = this.generateTraceId();
364
+ const startTime = Date.now();
365
+ this.instrument('[signMessageWithContext] start', {
366
+ key: 'signMessageWithContext-start',
367
+ startTime,
368
+ time: 0,
369
+ traceId,
370
+ });
371
+ return walletClient.signMessage({
372
+ accountAddress,
373
+ authToken: (_e = this.getAuthToken) === null || _e === void 0 ? void 0 : _e.call(this),
374
+ context,
375
+ message,
376
+ mfaToken,
377
+ password,
378
+ signedSessionId,
379
+ traceContext: {
380
+ startTime,
381
+ traceId,
382
+ },
383
+ });
384
+ });
385
+ }
386
+ getSigner() {
387
+ return __awaiter(this, void 0, void 0, function* () {
388
+ return this.getWalletClient();
389
+ });
390
+ }
391
+ getWalletClientByAddress({ accountAddress, }) {
392
+ this.setActiveAccount(accountAddress);
393
+ return this.getWalletClient();
394
+ }
395
+ createUiTransaction(from) {
396
+ return __awaiter(this, void 0, void 0, function* () {
397
+ yield this.validateActiveWallet(from);
398
+ const walletClient = this.getWalletClient();
399
+ const publicClient = yield this.getPublicClient();
400
+ if (!publicClient || !walletClient) {
401
+ throw new DynamicError('No public client available');
402
+ }
403
+ const uiTransaction = new ViemUiTransaction({
404
+ account: from,
405
+ onSubmit: (transaction) => __awaiter(this, void 0, void 0, function* () {
406
+ var _a, _b, _c;
407
+ // Build native Tempo type 118 transaction with fee token support
408
+ const chainId = yield this.getNetwork();
409
+ if (!chainId) {
410
+ throw new DynamicError('No chain ID available');
411
+ }
412
+ // Build the call data for the transaction
413
+ const callData = transaction.nonNativeAddress
414
+ ? {
415
+ // TIP-20/ERC-20 transfer - encode the transfer call
416
+ data: encodeFunctionData({
417
+ abi: erc20Abi,
418
+ args: [
419
+ transaction.to,
420
+ transaction.nonNativeValue,
421
+ ],
422
+ functionName: 'transfer',
423
+ }),
424
+ to: transaction.nonNativeAddress,
425
+ value: BigInt(0),
426
+ }
427
+ : {
428
+ // Native transfer (Tempo has no native token, but handle for compatibility)
429
+ data: '0x',
430
+ to: (transaction.to || ''),
431
+ value: (_a = transaction.value) !== null && _a !== void 0 ? _a : BigInt(0),
432
+ };
433
+ // Get standard sequential nonce
434
+ const nonce = yield publicClient.getTransactionCount({
435
+ address: from,
436
+ });
437
+ // Estimate gas for the call
438
+ const gasEstimate = yield publicClient.estimateGas({
439
+ account: from,
440
+ data: callData.data,
441
+ to: callData.to,
442
+ value: callData.value,
443
+ });
444
+ // Add 30% buffer for Tempo AA overhead + 300k minimum floor for nonce lane init
445
+ const gasWithBuffer = (gasEstimate * BigInt(130)) / BigInt(100);
446
+ const minGas = BigInt(300000);
447
+ const gas = gasWithBuffer > minGas ? gasWithBuffer : minGas;
448
+ // Get gas price
449
+ const gasPrice = yield publicClient.getGasPrice();
450
+ // Build Tempo transaction with proper types (BigInt values)
451
+ const tempoTx = Object.assign({ calls: [callData], chainId,
452
+ gas, maxFeePerGas: gasPrice, maxPriorityFeePerGas: gasPrice / BigInt(10), nonce }, (transaction.feeTokenAddress && {
453
+ feeToken: transaction.feeTokenAddress,
454
+ }));
455
+ // Get WaaS client and sign the native Tempo transaction
456
+ const waasClient = yield this.getWaasWalletClient();
457
+ const signedSessionId = yield ((_b = this.getSignedSessionId) === null || _b === void 0 ? void 0 : _b.call(this));
458
+ if (!signedSessionId) {
459
+ throw new DynamicError(ERROR_SIGNED_SESSION_ID_REQUIRED);
460
+ }
461
+ const mfaToken = yield ((_c = this.getMfaToken) === null || _c === void 0 ? void 0 : _c.call(this, {
462
+ mfaAction: MFAAction.WalletWaasSign,
463
+ }));
464
+ const password = yield this.getPasswordIfNeeded({
465
+ accountAddress: from,
466
+ });
467
+ const traceId = this.generateTraceId();
468
+ const startTime = Date.now();
469
+ // Sign the Tempo transaction
470
+ const signature = yield this.instrumentAsync({
471
+ context: { chainName: 'TEMPO', startTime, traceId },
472
+ fn: () => __awaiter(this, void 0, void 0, function* () {
473
+ var _d;
474
+ return waasClient.signTransaction({
475
+ authToken: (_d = this.getAuthToken) === null || _d === void 0 ? void 0 : _d.call(this),
476
+ mfaToken,
477
+ password,
478
+ senderAddress: from,
479
+ signedSessionId,
480
+ traceContext: {
481
+ startTime,
482
+ traceId,
483
+ },
484
+ // Use replacer to convert BigInt to string for JSON serialization
485
+ transaction: JSON.stringify(tempoTx, (_, v) => typeof v === 'bigint' ? v.toString() : v),
486
+ });
487
+ }),
488
+ operation: 'signTempoTransaction',
489
+ resource: 'waasClient.signTransaction',
490
+ });
491
+ // Broadcast using sendRawTransaction
492
+ const hash = yield publicClient.sendRawTransaction({
493
+ serializedTransaction: signature,
494
+ });
495
+ return hash;
496
+ }),
497
+ publicClient,
498
+ transaction: {},
499
+ });
500
+ uiTransaction.chain = 'TEMPO';
501
+ uiTransaction.getBalance = () => Promise.resolve(BigInt(0));
502
+ // Mark as "gas sponsored" so insufficient funds check doesn't compare
503
+ // native balance (0) vs gas fees - Tempo fees are paid in TIP-20 tokens
504
+ uiTransaction.isGasSponsored = () => true;
505
+ return uiTransaction;
506
+ });
507
+ }
508
+ getConnectedAccounts() {
509
+ return __awaiter(this, void 0, void 0, function* () {
510
+ var _a;
511
+ const verifiedCredentials = this.verifiedCredentials || [];
512
+ const addresses = verifiedCredentials
513
+ .map((vc) => vc === null || vc === void 0 ? void 0 : vc.address)
514
+ .filter((a) => typeof a === 'string');
515
+ if (addresses.length > 0 && ((_a = this.verifiedCredential) === null || _a === void 0 ? void 0 : _a.address)) {
516
+ this.setActiveAccount(this.verifiedCredential.address);
517
+ }
518
+ return addresses;
519
+ });
520
+ }
521
+ getAddress() {
522
+ return __awaiter(this, void 0, void 0, function* () {
523
+ var _a;
524
+ const activeAccount = this.getActiveAccount();
525
+ if (!activeAccount || !activeAccount.address) {
526
+ // If no active account, try to get one from verified credentials
527
+ if ((_a = this.verifiedCredential) === null || _a === void 0 ? void 0 : _a.address) {
528
+ const { address } = this.verifiedCredential;
529
+ this.setActiveAccount(address);
530
+ return address;
531
+ }
532
+ throw new DynamicError('No active wallet address found');
533
+ }
534
+ return activeAccount.address;
535
+ });
536
+ }
537
+ endSession() {
538
+ const _super = Object.create(null, {
539
+ endSession: { get: () => super.endSession }
540
+ });
541
+ return __awaiter(this, void 0, void 0, function* () {
542
+ yield _super.endSession.call(this);
543
+ });
544
+ }
545
+ }
546
+ DynamicWaasTempoConnector.lastUsedChainIdStorageKey = 'dynamic-waas-tempo-last-used-chain-id';
547
+
548
+ export { DynamicWaasTempoConnector };
@@ -0,0 +1,13 @@
1
+ 'use client'
2
+ 'use strict';
3
+
4
+ Object.defineProperty(exports, '__esModule', { value: true });
5
+
6
+ var DynamicWaasTempoConnector = require('./DynamicWaasTempoConnector.cjs');
7
+
8
+ const DynamicWaasTempoConnectors = () => [
9
+ DynamicWaasTempoConnector.DynamicWaasTempoConnector,
10
+ ];
11
+
12
+ exports.DynamicWaasTempoConnector = DynamicWaasTempoConnector.DynamicWaasTempoConnector;
13
+ exports.DynamicWaasTempoConnectors = DynamicWaasTempoConnectors;
@@ -0,0 +1,3 @@
1
+ import { WalletConnectorConstructor } from '@dynamic-labs/wallet-connector-core';
2
+ export * from './DynamicWaasTempoConnector';
3
+ export declare const DynamicWaasTempoConnectors: () => WalletConnectorConstructor[];
@@ -0,0 +1,9 @@
1
+ 'use client'
2
+ import { DynamicWaasTempoConnector } from './DynamicWaasTempoConnector.js';
3
+ export { DynamicWaasTempoConnector } from './DynamicWaasTempoConnector.js';
4
+
5
+ const DynamicWaasTempoConnectors = () => [
6
+ DynamicWaasTempoConnector,
7
+ ];
8
+
9
+ export { DynamicWaasTempoConnectors };
@@ -0,0 +1,35 @@
1
+ 'use client'
2
+ 'use strict';
3
+
4
+ Object.defineProperty(exports, '__esModule', { value: true });
5
+
6
+ var _tslib = require('../../../_virtual/_tslib.cjs');
7
+ var ethereumCore = require('@dynamic-labs/ethereum-core');
8
+
9
+ /**
10
+ * Base wallet connector for Tempo chain.
11
+ * Extends EthereumWalletConnector since Tempo is EVM-compatible,
12
+ * but sets connectedChain to 'TEMPO' for proper routing to the Tempo wallet client.
13
+ * Uses tempoNetworks instead of evmNetworks for proper network display.
14
+ */
15
+ class TempoWalletConnector extends ethereumCore.EthereumWalletConnector {
16
+ constructor(props) {
17
+ // Pass tempoNetworks as evmNetworks to parent since EthereumWalletConnector expects evmNetworks
18
+ super(Object.assign(Object.assign({}, props), { evmNetworks: props.tempoNetworks }));
19
+ this.supportedChains = ['TEMPO'];
20
+ this.connectedChain = 'TEMPO';
21
+ }
22
+ /**
23
+ * Override getBalance to return '0' for Tempo networks.
24
+ * Tempo is an EVM-compatible chain with no native token - fees are paid in TIP-20 stablecoins.
25
+ * Calling eth_getBalance returns garbage data, so we return '0' instead.
26
+ */
27
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
28
+ getBalance(address) {
29
+ return _tslib.__awaiter(this, void 0, void 0, function* () {
30
+ return '0';
31
+ });
32
+ }
33
+ }
34
+
35
+ exports.TempoWalletConnector = TempoWalletConnector;
@@ -0,0 +1,23 @@
1
+ import { EthereumWalletConnector, EthereumWalletConnectorOpts } from '@dynamic-labs/ethereum-core';
2
+ import { GenericNetwork } from '@dynamic-labs/types';
3
+ import { Chain } from '@dynamic-labs/wallet-connector-core';
4
+ export type TempoWalletConnectorOpts = Omit<EthereumWalletConnectorOpts, 'evmNetworks'> & {
5
+ tempoNetworks: GenericNetwork[];
6
+ };
7
+ /**
8
+ * Base wallet connector for Tempo chain.
9
+ * Extends EthereumWalletConnector since Tempo is EVM-compatible,
10
+ * but sets connectedChain to 'TEMPO' for proper routing to the Tempo wallet client.
11
+ * Uses tempoNetworks instead of evmNetworks for proper network display.
12
+ */
13
+ export declare abstract class TempoWalletConnector extends EthereumWalletConnector {
14
+ supportedChains: Chain[];
15
+ connectedChain: Chain;
16
+ constructor(props: TempoWalletConnectorOpts);
17
+ /**
18
+ * Override getBalance to return '0' for Tempo networks.
19
+ * Tempo is an EVM-compatible chain with no native token - fees are paid in TIP-20 stablecoins.
20
+ * Calling eth_getBalance returns garbage data, so we return '0' instead.
21
+ */
22
+ getBalance(address: string): Promise<string>;
23
+ }
@@ -0,0 +1,31 @@
1
+ 'use client'
2
+ import { __awaiter } from '../../../_virtual/_tslib.js';
3
+ import { EthereumWalletConnector } from '@dynamic-labs/ethereum-core';
4
+
5
+ /**
6
+ * Base wallet connector for Tempo chain.
7
+ * Extends EthereumWalletConnector since Tempo is EVM-compatible,
8
+ * but sets connectedChain to 'TEMPO' for proper routing to the Tempo wallet client.
9
+ * Uses tempoNetworks instead of evmNetworks for proper network display.
10
+ */
11
+ class TempoWalletConnector extends EthereumWalletConnector {
12
+ constructor(props) {
13
+ // Pass tempoNetworks as evmNetworks to parent since EthereumWalletConnector expects evmNetworks
14
+ super(Object.assign(Object.assign({}, props), { evmNetworks: props.tempoNetworks }));
15
+ this.supportedChains = ['TEMPO'];
16
+ this.connectedChain = 'TEMPO';
17
+ }
18
+ /**
19
+ * Override getBalance to return '0' for Tempo networks.
20
+ * Tempo is an EVM-compatible chain with no native token - fees are paid in TIP-20 stablecoins.
21
+ * Calling eth_getBalance returns garbage data, so we return '0' instead.
22
+ */
23
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
24
+ getBalance(address) {
25
+ return __awaiter(this, void 0, void 0, function* () {
26
+ return '0';
27
+ });
28
+ }
29
+ }
30
+
31
+ export { TempoWalletConnector };
@@ -0,0 +1,2 @@
1
+ export { TempoWalletConnector } from './TempoWalletConnector';
2
+ export type { TempoWalletConnectorOpts } from './TempoWalletConnector';