@dynamic-labs/ethereum-core 5.4.1 → 5.5.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.
- package/CHANGELOG.md +15 -0
- package/package.cjs +1 -1
- package/package.js +1 -1
- package/package.json +8 -8
- package/src/connector/EthereumWalletConnector.cjs +2 -0
- package/src/connector/EthereumWalletConnector.js +2 -0
- package/src/index.cjs +2 -0
- package/src/index.js +1 -0
- package/src/utils/viem/ViemUiTransaction/ViemUiTransaction.cjs +2 -7
- package/src/utils/viem/ViemUiTransaction/ViemUiTransaction.d.ts +4 -4
- package/src/utils/viem/ViemUiTransaction/ViemUiTransaction.js +2 -7
- package/src/utils/viem/createViemUiTransaction/createViemUiTransaction.cjs +15 -1
- package/src/utils/viem/createViemUiTransaction/createViemUiTransaction.d.ts +3 -1
- package/src/utils/viem/createViemUiTransaction/createViemUiTransaction.js +15 -1
- package/src/utils/viem/index.d.ts +1 -0
- package/src/utils/viem/screenEvmTransaction/index.d.ts +1 -0
- package/src/utils/viem/screenEvmTransaction/screenEvmTransaction.cjs +20 -0
- package/src/utils/viem/screenEvmTransaction/screenEvmTransaction.d.ts +8 -0
- package/src/utils/viem/screenEvmTransaction/screenEvmTransaction.js +16 -0
- package/src/wallet/EthereumWallet.cjs +24 -30
- package/src/wallet/EthereumWallet.js +24 -30
package/CHANGELOG.md
CHANGED
|
@@ -1,4 +1,19 @@
|
|
|
1
1
|
|
|
2
|
+
## [5.5.0](https://github.com/dynamic-labs/dynamic-auth/compare/v5.4.1...v5.5.0) (2026-08-31)
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
### Features
|
|
6
|
+
|
|
7
|
+
* **waas-evm:** route embedded EVM sends through gas sponsorship when enabled ([#12306](https://github.com/dynamic-labs/dynamic-auth/issues/12306)) ([6046ff3](https://github.com/dynamic-labs/dynamic-auth/commit/6046ff362d8de9402793bdaa7319fda645ff4c04))
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
### Bug Fixes
|
|
11
|
+
|
|
12
|
+
* **bitcoin:** resolve the active BTC wallet and network correctly across the widget ([#12308](https://github.com/dynamic-labs/dynamic-auth/issues/12308)) ([13e9eae](https://github.com/dynamic-labs/dynamic-auth/commit/13e9eaec19b3925db507c878988cfd82da5a6de6))
|
|
13
|
+
* **btc:** unbreak BTC transaction confirmation, testnet balances and taproot testnet switching ([#12305](https://github.com/dynamic-labs/dynamic-auth/issues/12305)) ([5fd999c](https://github.com/dynamic-labs/dynamic-auth/commit/5fd999c4c819d3a74e967c0cfa77c5877a74906b))
|
|
14
|
+
* **react-native-extension:** stop leaking expo-secure-store into consumer autolinking ([#12296](https://github.com/dynamic-labs/dynamic-auth/issues/12296)) ([1e0396a](https://github.com/dynamic-labs/dynamic-auth/commit/1e0396ab00c79aa0b2f45b6d7b1d339c1dac1203)), closes [#12254](https://github.com/dynamic-labs/dynamic-auth/issues/12254)
|
|
15
|
+
* **screening:** wire connected-wallet screening into the Send Balance UI (DYNT-1663) ([#12303](https://github.com/dynamic-labs/dynamic-auth/issues/12303)) ([5d26ff3](https://github.com/dynamic-labs/dynamic-auth/commit/5d26ff375118302522c39bd2f1fa9e04f7378eaf))
|
|
16
|
+
|
|
2
17
|
### [5.4.1](https://github.com/dynamic-labs/dynamic-auth/compare/v5.4.0...v5.4.1) (2026-08-26)
|
|
3
18
|
|
|
4
19
|
|
package/package.cjs
CHANGED
package/package.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dynamic-labs/ethereum-core",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.5.0",
|
|
4
4
|
"description": "Core package for utilities and types for viem",
|
|
5
5
|
"author": "Dynamic Labs, Inc.",
|
|
6
6
|
"license": "MIT",
|
|
@@ -19,13 +19,13 @@
|
|
|
19
19
|
"homepage": "https://www.dynamic.xyz/",
|
|
20
20
|
"dependencies": {
|
|
21
21
|
"@dynamic-labs/sdk-api-core": "0.12.0",
|
|
22
|
-
"@dynamic-labs/assert-package-version": "5.
|
|
23
|
-
"@dynamic-labs/logger": "5.
|
|
24
|
-
"@dynamic-labs/rpc-providers": "5.
|
|
25
|
-
"@dynamic-labs/types": "5.
|
|
26
|
-
"@dynamic-labs/utils": "5.
|
|
27
|
-
"@dynamic-labs/wallet-book": "5.
|
|
28
|
-
"@dynamic-labs/wallet-connector-core": "5.
|
|
22
|
+
"@dynamic-labs/assert-package-version": "5.5.0",
|
|
23
|
+
"@dynamic-labs/logger": "5.5.0",
|
|
24
|
+
"@dynamic-labs/rpc-providers": "5.5.0",
|
|
25
|
+
"@dynamic-labs/types": "5.5.0",
|
|
26
|
+
"@dynamic-labs/utils": "5.5.0",
|
|
27
|
+
"@dynamic-labs/wallet-book": "5.5.0",
|
|
28
|
+
"@dynamic-labs/wallet-connector-core": "5.5.0"
|
|
29
29
|
},
|
|
30
30
|
"peerDependencies": {
|
|
31
31
|
"viem": "^2.45.3"
|
|
@@ -15,6 +15,7 @@ var createViemUiTransaction = require('../utils/viem/createViemUiTransaction/cre
|
|
|
15
15
|
var getOrMapViemChain = require('../utils/viem/getOrMapViemChain/getOrMapViemChain.cjs');
|
|
16
16
|
var hasAtomicStatusCapability = require('../utils/viem/hasAtomicStatusCapability/hasAtomicStatusCapability.cjs');
|
|
17
17
|
var hasPaymasterServiceCapability = require('../utils/viem/hasPaymasterServiceCapability/hasPaymasterServiceCapability.cjs');
|
|
18
|
+
require('@dynamic-labs/types');
|
|
18
19
|
var findEvmNetwork = require('../utils/findEvmNetwork/findEvmNetwork.cjs');
|
|
19
20
|
var getNameservice = require('../utils/getNameservice/getNameservice.cjs');
|
|
20
21
|
var EthereumWallet = require('../wallet/EthereumWallet.cjs');
|
|
@@ -307,6 +308,7 @@ class EthereumWalletConnector extends walletConnectorCore.WalletConnectorBase {
|
|
|
307
308
|
return createViemUiTransaction.createViemUiTransaction({
|
|
308
309
|
from,
|
|
309
310
|
publicClient,
|
|
311
|
+
transactionScreening: this.transactionScreening,
|
|
310
312
|
walletClient,
|
|
311
313
|
});
|
|
312
314
|
});
|
|
@@ -11,6 +11,7 @@ import { createViemUiTransaction } from '../utils/viem/createViemUiTransaction/c
|
|
|
11
11
|
import { getOrMapViemChain } from '../utils/viem/getOrMapViemChain/getOrMapViemChain.js';
|
|
12
12
|
import { hasAtomicStatusCapability } from '../utils/viem/hasAtomicStatusCapability/hasAtomicStatusCapability.js';
|
|
13
13
|
import { hasPaymasterServiceCapability } from '../utils/viem/hasPaymasterServiceCapability/hasPaymasterServiceCapability.js';
|
|
14
|
+
import '@dynamic-labs/types';
|
|
14
15
|
import { findEvmNetwork } from '../utils/findEvmNetwork/findEvmNetwork.js';
|
|
15
16
|
import { getNameservice } from '../utils/getNameservice/getNameservice.js';
|
|
16
17
|
import { EthereumWallet } from '../wallet/EthereumWallet.js';
|
|
@@ -303,6 +304,7 @@ class EthereumWalletConnector extends WalletConnectorBase {
|
|
|
303
304
|
return createViemUiTransaction({
|
|
304
305
|
from,
|
|
305
306
|
publicClient,
|
|
307
|
+
transactionScreening: this.transactionScreening,
|
|
306
308
|
walletClient,
|
|
307
309
|
});
|
|
308
310
|
});
|
package/src/index.cjs
CHANGED
|
@@ -24,6 +24,7 @@ var hasPaymasterServiceCapability = require('./utils/viem/hasPaymasterServiceCap
|
|
|
24
24
|
var unFormatTransaction = require('./utils/viem/unFormatTransaction/unFormatTransaction.cjs');
|
|
25
25
|
var abi = require('./utils/viem/erc20/abi.cjs');
|
|
26
26
|
var interceptTransport = require('./utils/viem/interceptTransport/interceptTransport.cjs');
|
|
27
|
+
var screenEvmTransaction = require('./utils/viem/screenEvmTransaction/screenEvmTransaction.cjs');
|
|
27
28
|
var findEvmNetwork = require('./utils/findEvmNetwork/findEvmNetwork.cjs');
|
|
28
29
|
var getNameservice = require('./utils/getNameservice/getNameservice.cjs');
|
|
29
30
|
var validateAddressFormat = require('./utils/validateAddressFormat/validateAddressFormat.cjs');
|
|
@@ -53,6 +54,7 @@ exports.hasPaymasterServiceCapability = hasPaymasterServiceCapability.hasPaymast
|
|
|
53
54
|
exports.unFormatTransaction = unFormatTransaction.unFormatTransaction;
|
|
54
55
|
exports.erc20Abi = abi.erc20Abi;
|
|
55
56
|
exports.interceptTransport = interceptTransport.interceptTransport;
|
|
57
|
+
exports.screenEvmTransaction = screenEvmTransaction.screenEvmTransaction;
|
|
56
58
|
exports.findEvmNetwork = findEvmNetwork.findEvmNetwork;
|
|
57
59
|
exports.getNameservice = getNameservice.getNameservice;
|
|
58
60
|
exports.validateAddressFormat = validateAddressFormat.validateAddressFormat;
|
package/src/index.js
CHANGED
|
@@ -20,6 +20,7 @@ export { hasPaymasterServiceCapability } from './utils/viem/hasPaymasterServiceC
|
|
|
20
20
|
export { unFormatTransaction } from './utils/viem/unFormatTransaction/unFormatTransaction.js';
|
|
21
21
|
export { erc20Abi } from './utils/viem/erc20/abi.js';
|
|
22
22
|
export { interceptTransport } from './utils/viem/interceptTransport/interceptTransport.js';
|
|
23
|
+
export { screenEvmTransaction } from './utils/viem/screenEvmTransaction/screenEvmTransaction.js';
|
|
23
24
|
export { findEvmNetwork } from './utils/findEvmNetwork/findEvmNetwork.js';
|
|
24
25
|
export { getNameservice } from './utils/getNameservice/getNameservice.js';
|
|
25
26
|
export { validateAddressFormat } from './utils/validateAddressFormat/validateAddressFormat.js';
|
|
@@ -14,7 +14,7 @@ var formatEther = require('../formatEther/formatEther.cjs');
|
|
|
14
14
|
var getTransactionRecipient = require('../getTransactionRecipient.cjs');
|
|
15
15
|
|
|
16
16
|
class ViemUiTransaction extends Eip1559FeeFeed.Eip1559FeeFeed {
|
|
17
|
-
constructor({ transaction, onSubmit, publicClient, account, }) {
|
|
17
|
+
constructor({ transaction, onSubmit, publicClient, account, isGasSponsored = false, }) {
|
|
18
18
|
super({
|
|
19
19
|
initialGasLimit: transaction.gas,
|
|
20
20
|
initialMaxFeePerGas: transaction.maxFeePerGas,
|
|
@@ -26,16 +26,11 @@ class ViemUiTransaction extends Eip1559FeeFeed.Eip1559FeeFeed {
|
|
|
26
26
|
this.parseNonNativeToken = (amount, decimals) => viem.parseUnits(amount, decimals);
|
|
27
27
|
this.format = formatEther.formatEther;
|
|
28
28
|
this.formatNonNativeToken = (value, decimals) => viem.formatUnits(value, decimals);
|
|
29
|
-
/**
|
|
30
|
-
* Whether the transaction is gas sponsored.
|
|
31
|
-
* Returns false by default for EVM transactions.
|
|
32
|
-
* Can be overridden for chains like Tempo where fees are paid differently.
|
|
33
|
-
*/
|
|
34
|
-
this.isGasSponsored = () => false;
|
|
35
29
|
this.transaction = transaction;
|
|
36
30
|
this.onSubmit = onSubmit;
|
|
37
31
|
this.publicClient = publicClient;
|
|
38
32
|
this.address = account;
|
|
33
|
+
this.isGasSponsored = () => isGasSponsored;
|
|
39
34
|
}
|
|
40
35
|
get to() {
|
|
41
36
|
return this.transaction.to || undefined;
|
|
@@ -13,6 +13,7 @@ type ViemUiTransactionProps = {
|
|
|
13
13
|
transaction: TransactionSerializable & NonNativeTransaction;
|
|
14
14
|
onSubmit: (transaction: TransactionSerializable & NonNativeTransaction) => Promise<string>;
|
|
15
15
|
publicClient: PublicClient<Transport, Chain>;
|
|
16
|
+
isGasSponsored?: boolean;
|
|
16
17
|
};
|
|
17
18
|
export interface IUIEvmTransaction {
|
|
18
19
|
nonNativeValue: bigint | undefined;
|
|
@@ -28,7 +29,7 @@ export declare class ViemUiTransaction extends Eip1559FeeFeed implements IUITran
|
|
|
28
29
|
private address;
|
|
29
30
|
protected publicClient: PublicClient<Transport, Chain>;
|
|
30
31
|
private onSubmit;
|
|
31
|
-
constructor({ transaction, onSubmit, publicClient, account, }: ViemUiTransactionProps);
|
|
32
|
+
constructor({ transaction, onSubmit, publicClient, account, isGasSponsored, }: ViemUiTransactionProps);
|
|
32
33
|
nativePrice?: number | undefined;
|
|
33
34
|
validateAddressFormat: (address: string) => boolean;
|
|
34
35
|
parse: (input: string) => bigint;
|
|
@@ -57,9 +58,8 @@ export declare class ViemUiTransaction extends Eip1559FeeFeed implements IUITran
|
|
|
57
58
|
private convertBigIntToHex;
|
|
58
59
|
getTransactionRecipient(): `0x${string}` | undefined;
|
|
59
60
|
/**
|
|
60
|
-
* Whether the transaction is gas sponsored.
|
|
61
|
-
*
|
|
62
|
-
* Can be overridden for chains like Tempo where fees are paid differently.
|
|
61
|
+
* Whether the transaction is gas sponsored. Sponsored transactions are
|
|
62
|
+
* excluded from the native balance checks in the confirmation UI.
|
|
63
63
|
*/
|
|
64
64
|
isGasSponsored: () => boolean;
|
|
65
65
|
estimateL1Fee(): Promise<bigint>;
|
|
@@ -10,7 +10,7 @@ import { formatEther } from '../formatEther/formatEther.js';
|
|
|
10
10
|
import { getTransactionRecipient } from '../getTransactionRecipient.js';
|
|
11
11
|
|
|
12
12
|
class ViemUiTransaction extends Eip1559FeeFeed {
|
|
13
|
-
constructor({ transaction, onSubmit, publicClient, account, }) {
|
|
13
|
+
constructor({ transaction, onSubmit, publicClient, account, isGasSponsored = false, }) {
|
|
14
14
|
super({
|
|
15
15
|
initialGasLimit: transaction.gas,
|
|
16
16
|
initialMaxFeePerGas: transaction.maxFeePerGas,
|
|
@@ -22,16 +22,11 @@ class ViemUiTransaction extends Eip1559FeeFeed {
|
|
|
22
22
|
this.parseNonNativeToken = (amount, decimals) => parseUnits(amount, decimals);
|
|
23
23
|
this.format = formatEther;
|
|
24
24
|
this.formatNonNativeToken = (value, decimals) => formatUnits(value, decimals);
|
|
25
|
-
/**
|
|
26
|
-
* Whether the transaction is gas sponsored.
|
|
27
|
-
* Returns false by default for EVM transactions.
|
|
28
|
-
* Can be overridden for chains like Tempo where fees are paid differently.
|
|
29
|
-
*/
|
|
30
|
-
this.isGasSponsored = () => false;
|
|
31
25
|
this.transaction = transaction;
|
|
32
26
|
this.onSubmit = onSubmit;
|
|
33
27
|
this.publicClient = publicClient;
|
|
34
28
|
this.address = account;
|
|
29
|
+
this.isGasSponsored = () => isGasSponsored;
|
|
35
30
|
}
|
|
36
31
|
get to() {
|
|
37
32
|
return this.transaction.to || undefined;
|
|
@@ -5,12 +5,26 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
5
5
|
|
|
6
6
|
var _tslib = require('../../../../_virtual/_tslib.cjs');
|
|
7
7
|
var abi = require('../erc20/abi.cjs');
|
|
8
|
+
var screenEvmTransaction = require('../screenEvmTransaction/screenEvmTransaction.cjs');
|
|
8
9
|
var ViemUiTransaction = require('../ViemUiTransaction/ViemUiTransaction.cjs');
|
|
9
10
|
|
|
10
|
-
const createViemUiTransaction = (_a) => _tslib.__awaiter(void 0, [_a], void 0, function* ({ from, publicClient, walletClient, }) {
|
|
11
|
+
const createViemUiTransaction = (_a) => _tslib.__awaiter(void 0, [_a], void 0, function* ({ from, publicClient, walletClient, transactionScreening, }) {
|
|
11
12
|
return new ViemUiTransaction.ViemUiTransaction({
|
|
12
13
|
account: from,
|
|
13
14
|
onSubmit: (transaction) => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
15
|
+
var _b, _c;
|
|
16
|
+
// Screened here, at submit time, rather than when the transaction is
|
|
17
|
+
// built: the UI mutates `to`/`value` after construction, so screening
|
|
18
|
+
// the live values is the only way to catch a destination the user
|
|
19
|
+
// edited in after the fact. `to` is the actual recipient in both
|
|
20
|
+
// branches below — for the non-native case `nonNativeAddress` is the
|
|
21
|
+
// token contract being called, not the destination.
|
|
22
|
+
yield screenEvmTransaction.screenEvmTransaction({
|
|
23
|
+
chainId: (_b = walletClient.chain) === null || _b === void 0 ? void 0 : _b.id,
|
|
24
|
+
senderAddress: from,
|
|
25
|
+
to: (_c = transaction.to) !== null && _c !== void 0 ? _c : undefined,
|
|
26
|
+
transactionScreening,
|
|
27
|
+
});
|
|
14
28
|
// Non native token
|
|
15
29
|
if (transaction.nonNativeAddress) {
|
|
16
30
|
return walletClient.writeContract({
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import { Chain, PublicClient, Transport, WalletClient } from 'viem';
|
|
2
|
+
import { TransactionScreeningService } from '@dynamic-labs/types';
|
|
2
3
|
import { ViemUiTransaction } from '../ViemUiTransaction';
|
|
3
4
|
type CreateViemUiTransactionProps = {
|
|
4
5
|
publicClient: PublicClient<Transport, Chain>;
|
|
5
6
|
walletClient: WalletClient<Transport, Chain>;
|
|
6
7
|
from: string;
|
|
8
|
+
transactionScreening?: TransactionScreeningService;
|
|
7
9
|
};
|
|
8
|
-
export declare const createViemUiTransaction: ({ from, publicClient, walletClient, }: CreateViemUiTransactionProps) => Promise<ViemUiTransaction>;
|
|
10
|
+
export declare const createViemUiTransaction: ({ from, publicClient, walletClient, transactionScreening, }: CreateViemUiTransactionProps) => Promise<ViemUiTransaction>;
|
|
9
11
|
export {};
|
|
@@ -1,12 +1,26 @@
|
|
|
1
1
|
'use client'
|
|
2
2
|
import { __awaiter } from '../../../../_virtual/_tslib.js';
|
|
3
3
|
import { erc20Abi } from '../erc20/abi.js';
|
|
4
|
+
import { screenEvmTransaction } from '../screenEvmTransaction/screenEvmTransaction.js';
|
|
4
5
|
import { ViemUiTransaction } from '../ViemUiTransaction/ViemUiTransaction.js';
|
|
5
6
|
|
|
6
|
-
const createViemUiTransaction = (_a) => __awaiter(void 0, [_a], void 0, function* ({ from, publicClient, walletClient, }) {
|
|
7
|
+
const createViemUiTransaction = (_a) => __awaiter(void 0, [_a], void 0, function* ({ from, publicClient, walletClient, transactionScreening, }) {
|
|
7
8
|
return new ViemUiTransaction({
|
|
8
9
|
account: from,
|
|
9
10
|
onSubmit: (transaction) => __awaiter(void 0, void 0, void 0, function* () {
|
|
11
|
+
var _b, _c;
|
|
12
|
+
// Screened here, at submit time, rather than when the transaction is
|
|
13
|
+
// built: the UI mutates `to`/`value` after construction, so screening
|
|
14
|
+
// the live values is the only way to catch a destination the user
|
|
15
|
+
// edited in after the fact. `to` is the actual recipient in both
|
|
16
|
+
// branches below — for the non-native case `nonNativeAddress` is the
|
|
17
|
+
// token contract being called, not the destination.
|
|
18
|
+
yield screenEvmTransaction({
|
|
19
|
+
chainId: (_b = walletClient.chain) === null || _b === void 0 ? void 0 : _b.id,
|
|
20
|
+
senderAddress: from,
|
|
21
|
+
to: (_c = transaction.to) !== null && _c !== void 0 ? _c : undefined,
|
|
22
|
+
transactionScreening,
|
|
23
|
+
});
|
|
10
24
|
// Non native token
|
|
11
25
|
if (transaction.nonNativeAddress) {
|
|
12
26
|
return walletClient.writeContract({
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './screenEvmTransaction';
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
5
|
+
|
|
6
|
+
var _tslib = require('../../../../_virtual/_tslib.cjs');
|
|
7
|
+
var types = require('@dynamic-labs/types');
|
|
8
|
+
|
|
9
|
+
const screenEvmTransaction = (_a) => _tslib.__awaiter(void 0, [_a], void 0, function* ({ transactionScreening, chainId, senderAddress, to, }) {
|
|
10
|
+
if (!transactionScreening)
|
|
11
|
+
return;
|
|
12
|
+
yield transactionScreening.screenTransaction({
|
|
13
|
+
chain: types.TransactionScreeningChain.EVM,
|
|
14
|
+
chainId: chainId === null || chainId === void 0 ? void 0 : chainId.toString(),
|
|
15
|
+
context: { evmTransaction: { to } },
|
|
16
|
+
senderAddress,
|
|
17
|
+
});
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
exports.screenEvmTransaction = screenEvmTransaction;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { TransactionScreeningService } from '@dynamic-labs/types';
|
|
2
|
+
export type ScreenEvmTransactionParams = {
|
|
3
|
+
transactionScreening: TransactionScreeningService | undefined;
|
|
4
|
+
chainId: number | string | undefined;
|
|
5
|
+
senderAddress: string | undefined;
|
|
6
|
+
to: string | undefined;
|
|
7
|
+
};
|
|
8
|
+
export declare const screenEvmTransaction: ({ transactionScreening, chainId, senderAddress, to, }: ScreenEvmTransactionParams) => Promise<void>;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
import { __awaiter } from '../../../../_virtual/_tslib.js';
|
|
3
|
+
import { TransactionScreeningChain } from '@dynamic-labs/types';
|
|
4
|
+
|
|
5
|
+
const screenEvmTransaction = (_a) => __awaiter(void 0, [_a], void 0, function* ({ transactionScreening, chainId, senderAddress, to, }) {
|
|
6
|
+
if (!transactionScreening)
|
|
7
|
+
return;
|
|
8
|
+
yield transactionScreening.screenTransaction({
|
|
9
|
+
chain: TransactionScreeningChain.EVM,
|
|
10
|
+
chainId: chainId === null || chainId === void 0 ? void 0 : chainId.toString(),
|
|
11
|
+
context: { evmTransaction: { to } },
|
|
12
|
+
senderAddress,
|
|
13
|
+
});
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
export { screenEvmTransaction };
|
|
@@ -5,7 +5,6 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
5
5
|
|
|
6
6
|
var _tslib = require('../../_virtual/_tslib.cjs');
|
|
7
7
|
var viem = require('viem');
|
|
8
|
-
var types = require('@dynamic-labs/types');
|
|
9
8
|
var walletConnectorCore = require('@dynamic-labs/wallet-connector-core');
|
|
10
9
|
require('@dynamic-labs/utils');
|
|
11
10
|
var logger = require('../utils/logger.cjs');
|
|
@@ -13,6 +12,7 @@ require('../utils/viem/estimateL1Fee/opStack/estimateL1Fee.cjs');
|
|
|
13
12
|
require('../utils/viem/chainsMap/chainsMap.cjs');
|
|
14
13
|
var interceptTransport = require('../utils/viem/interceptTransport/interceptTransport.cjs');
|
|
15
14
|
var abi = require('../utils/viem/erc20/abi.cjs');
|
|
15
|
+
var screenEvmTransaction = require('../utils/viem/screenEvmTransaction/screenEvmTransaction.cjs');
|
|
16
16
|
require('viem/accounts');
|
|
17
17
|
var getOrMapViemChain = require('../utils/viem/getOrMapViemChain/getOrMapViemChain.cjs');
|
|
18
18
|
var parseAddress = require('../utils/parseAddress/parseAddress.cjs');
|
|
@@ -115,41 +115,35 @@ class EthereumWallet extends walletConnectorCore.Wallet {
|
|
|
115
115
|
onSendCalls: (_b) => _tslib.__awaiter(this, [_b], void 0, function* ({ args, callParams, provider }) {
|
|
116
116
|
var _c;
|
|
117
117
|
yield this.sync();
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
senderAddress: this.address,
|
|
132
|
-
})));
|
|
133
|
-
}
|
|
118
|
+
// Nothing here may throw: a raw wallet_sendCalls can carry
|
|
119
|
+
// anything, and screening is fail-open by contract, so a malformed
|
|
120
|
+
// request must still reach the wallet and get its own RPC error.
|
|
121
|
+
const calls = Array.isArray(callParams === null || callParams === void 0 ? void 0 : callParams.calls)
|
|
122
|
+
? callParams.calls
|
|
123
|
+
: [];
|
|
124
|
+
const chainId = screeningChainId(callParams === null || callParams === void 0 ? void 0 : callParams.chainId, (_c = walletClient.chain) === null || _c === void 0 ? void 0 : _c.id);
|
|
125
|
+
yield Promise.all(calls.map((call) => screenEvmTransaction.screenEvmTransaction({
|
|
126
|
+
chainId,
|
|
127
|
+
senderAddress: this.address,
|
|
128
|
+
to: call === null || call === void 0 ? void 0 : call.to,
|
|
129
|
+
transactionScreening: this._connector.transactionScreening,
|
|
130
|
+
})));
|
|
134
131
|
return provider.request(args);
|
|
135
132
|
}),
|
|
136
133
|
onSendTransaction: (_d) => _tslib.__awaiter(this, [_d], void 0, function* ({ provider, args, transaction }) {
|
|
137
|
-
var _e, _f
|
|
134
|
+
var _e, _f;
|
|
138
135
|
yield this.sync();
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
senderAddress: transaction === null || transaction === void 0 ? void 0 : transaction.from,
|
|
148
|
-
});
|
|
149
|
-
}
|
|
136
|
+
// eth_sendTransaction carries no chain id: the wallet sends on the
|
|
137
|
+
// chain it is currently on, so the client's chain is the target.
|
|
138
|
+
yield screenEvmTransaction.screenEvmTransaction({
|
|
139
|
+
chainId: (_e = walletClient.chain) === null || _e === void 0 ? void 0 : _e.id,
|
|
140
|
+
senderAddress: transaction === null || transaction === void 0 ? void 0 : transaction.from,
|
|
141
|
+
to: (_f = transaction === null || transaction === void 0 ? void 0 : transaction.to) !== null && _f !== void 0 ? _f : undefined,
|
|
142
|
+
transactionScreening: this._connector.transactionScreening,
|
|
143
|
+
});
|
|
150
144
|
return provider.request(args);
|
|
151
145
|
}),
|
|
152
|
-
onSignTypedData: (
|
|
146
|
+
onSignTypedData: (_g) => _tslib.__awaiter(this, [_g], void 0, function* ({ provider, args }) {
|
|
153
147
|
yield this.sync();
|
|
154
148
|
return provider.request(args);
|
|
155
149
|
}),
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
'use client'
|
|
2
2
|
import { __awaiter } from '../../_virtual/_tslib.js';
|
|
3
3
|
import { getContract, parseUnits, parseEther, createWalletClient, custom, hexToNumber } from 'viem';
|
|
4
|
-
import { TransactionScreeningChain } from '@dynamic-labs/types';
|
|
5
4
|
import { Wallet } from '@dynamic-labs/wallet-connector-core';
|
|
6
5
|
import '@dynamic-labs/utils';
|
|
7
6
|
import { logger } from '../utils/logger.js';
|
|
@@ -9,6 +8,7 @@ import '../utils/viem/estimateL1Fee/opStack/estimateL1Fee.js';
|
|
|
9
8
|
import '../utils/viem/chainsMap/chainsMap.js';
|
|
10
9
|
import { interceptTransport } from '../utils/viem/interceptTransport/interceptTransport.js';
|
|
11
10
|
import { erc20Abi } from '../utils/viem/erc20/abi.js';
|
|
11
|
+
import { screenEvmTransaction } from '../utils/viem/screenEvmTransaction/screenEvmTransaction.js';
|
|
12
12
|
import 'viem/accounts';
|
|
13
13
|
import { getChain } from '../utils/viem/getOrMapViemChain/getOrMapViemChain.js';
|
|
14
14
|
import { parseAddress } from '../utils/parseAddress/parseAddress.js';
|
|
@@ -111,41 +111,35 @@ class EthereumWallet extends Wallet {
|
|
|
111
111
|
onSendCalls: (_b) => __awaiter(this, [_b], void 0, function* ({ args, callParams, provider }) {
|
|
112
112
|
var _c;
|
|
113
113
|
yield this.sync();
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
senderAddress: this.address,
|
|
128
|
-
})));
|
|
129
|
-
}
|
|
114
|
+
// Nothing here may throw: a raw wallet_sendCalls can carry
|
|
115
|
+
// anything, and screening is fail-open by contract, so a malformed
|
|
116
|
+
// request must still reach the wallet and get its own RPC error.
|
|
117
|
+
const calls = Array.isArray(callParams === null || callParams === void 0 ? void 0 : callParams.calls)
|
|
118
|
+
? callParams.calls
|
|
119
|
+
: [];
|
|
120
|
+
const chainId = screeningChainId(callParams === null || callParams === void 0 ? void 0 : callParams.chainId, (_c = walletClient.chain) === null || _c === void 0 ? void 0 : _c.id);
|
|
121
|
+
yield Promise.all(calls.map((call) => screenEvmTransaction({
|
|
122
|
+
chainId,
|
|
123
|
+
senderAddress: this.address,
|
|
124
|
+
to: call === null || call === void 0 ? void 0 : call.to,
|
|
125
|
+
transactionScreening: this._connector.transactionScreening,
|
|
126
|
+
})));
|
|
130
127
|
return provider.request(args);
|
|
131
128
|
}),
|
|
132
129
|
onSendTransaction: (_d) => __awaiter(this, [_d], void 0, function* ({ provider, args, transaction }) {
|
|
133
|
-
var _e, _f
|
|
130
|
+
var _e, _f;
|
|
134
131
|
yield this.sync();
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
senderAddress: transaction === null || transaction === void 0 ? void 0 : transaction.from,
|
|
144
|
-
});
|
|
145
|
-
}
|
|
132
|
+
// eth_sendTransaction carries no chain id: the wallet sends on the
|
|
133
|
+
// chain it is currently on, so the client's chain is the target.
|
|
134
|
+
yield screenEvmTransaction({
|
|
135
|
+
chainId: (_e = walletClient.chain) === null || _e === void 0 ? void 0 : _e.id,
|
|
136
|
+
senderAddress: transaction === null || transaction === void 0 ? void 0 : transaction.from,
|
|
137
|
+
to: (_f = transaction === null || transaction === void 0 ? void 0 : transaction.to) !== null && _f !== void 0 ? _f : undefined,
|
|
138
|
+
transactionScreening: this._connector.transactionScreening,
|
|
139
|
+
});
|
|
146
140
|
return provider.request(args);
|
|
147
141
|
}),
|
|
148
|
-
onSignTypedData: (
|
|
142
|
+
onSignTypedData: (_g) => __awaiter(this, [_g], void 0, function* ({ provider, args }) {
|
|
149
143
|
yield this.sync();
|
|
150
144
|
return provider.request(args);
|
|
151
145
|
}),
|