@wagmi/core 2.1.1 → 2.1.2

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.
@@ -1,2 +1,2 @@
1
- export const version = '2.1.1';
1
+ export const version = '2.1.2';
2
2
  //# sourceMappingURL=version.js.map
@@ -1,4 +1,4 @@
1
- import type { Account, Address, Chain, SendTransactionErrorType as viem_SendTransactionErrorType, SendTransactionParameters as viem_SendTransactionParameters, SendTransactionReturnType as viem_SendTransactionReturnType } from 'viem';
1
+ import type { Account, Address, Chain, SendTransactionErrorType as viem_SendTransactionErrorType, SendTransactionParameters as viem_SendTransactionParameters, SendTransactionReturnType as viem_SendTransactionReturnType, TransactionRequest } from 'viem';
2
2
  import { type Config } from '../createConfig.js';
3
3
  import type { BaseErrorType, ErrorType } from '../errors/base.js';
4
4
  import type { SelectChains } from '../types/chain.js';
@@ -6,10 +6,13 @@ import type { ChainIdParameter, ConnectorParameter } from '../types/properties.j
6
6
  import { type Evaluate } from '../types/utils.js';
7
7
  import { type GetConnectorClientErrorType } from './getConnectorClient.js';
8
8
  export type SendTransactionParameters<config extends Config = Config, chainId extends config['chains'][number]['id'] = config['chains'][number]['id'], chains extends readonly Chain[] = SelectChains<config, chainId>> = {
9
- [key in keyof chains]: Evaluate<Omit<viem_SendTransactionParameters<chains[key], Account, chains[key]>, 'chain'> & ChainIdParameter<config, chainId> & ConnectorParameter & {
9
+ [key in keyof chains]: Evaluate<Omit<viem_SendTransactionParameters<chains[key], Account, chains[key]>, 'chain' | 'gas'> & ChainIdParameter<config, chainId> & ConnectorParameter & {
10
10
  to: Address;
11
11
  }>;
12
- }[number];
12
+ }[number] & {
13
+ /** Gas provided for transaction execution, or `null` to skip the prelude gas estimation. */
14
+ gas?: TransactionRequest['gas'] | null;
15
+ };
13
16
  export type SendTransactionReturnType = viem_SendTransactionReturnType;
14
17
  export type SendTransactionErrorType = GetConnectorClientErrorType | BaseErrorType | ErrorType | viem_SendTransactionErrorType;
15
18
  /** https://wagmi.sh/core/api/actions/sendTransaction */
@@ -1 +1 @@
1
- {"version":3,"file":"sendTransaction.d.ts","sourceRoot":"","sources":["../../../src/actions/sendTransaction.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,OAAO,EACP,OAAO,EACP,KAAK,EACL,wBAAwB,IAAI,6BAA6B,EACzD,yBAAyB,IAAI,8BAA8B,EAC3D,yBAAyB,IAAI,8BAA8B,EAC5D,MAAM,MAAM,CAAA;AAGb,OAAO,EAAE,KAAK,MAAM,EAAE,MAAM,oBAAoB,CAAA;AAChD,OAAO,KAAK,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAA;AACjE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAA;AACrD,OAAO,KAAK,EACV,gBAAgB,EAChB,kBAAkB,EACnB,MAAM,wBAAwB,CAAA;AAC/B,OAAO,EAAE,KAAK,QAAQ,EAAE,MAAM,mBAAmB,CAAA;AACjD,OAAO,EACL,KAAK,2BAA2B,EAEjC,MAAM,yBAAyB,CAAA;AAEhC,MAAM,MAAM,yBAAyB,CACnC,MAAM,SAAS,MAAM,GAAG,MAAM,EAC9B,OAAO,SAAS,MAAM,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,GAAG,MAAM,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,EAE/E,MAAM,SAAS,SAAS,KAAK,EAAE,GAAG,YAAY,CAAC,MAAM,EAAE,OAAO,CAAC,IAC7D;KACD,GAAG,IAAI,MAAM,MAAM,GAAG,QAAQ,CAC7B,IAAI,CACF,8BAA8B,CAAC,MAAM,CAAC,GAAG,CAAC,EAAE,OAAO,EAAE,MAAM,CAAC,GAAG,CAAC,CAAC,EACjE,OAAO,CACR,GACC,gBAAgB,CAAC,MAAM,EAAE,OAAO,CAAC,GACjC,kBAAkB,GAAG;QACnB,EAAE,EAAE,OAAO,CAAA;KACZ,C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C,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,EAE/E,MAAM,SAAS,SAAS,KAAK,EAAE,GAAG,YAAY,CAAC,MAAM,EAAE,OAAO,CAAC,IAC7D;KACD,GAAG,IAAI,MAAM,MAAM,GAAG,QAAQ,CAC7B,IAAI,CACF,8BAA8B,CAAC,MAAM,CAAC,GAAG,CAAC,EAAE,OAAO,EAAE,MAAM,CAAC,GAAG,CAAC,CAAC,EACjE,OAAO,GAAG,KAAK,CAChB,GACC,gBAAgB,CAAC,MAAM,EAAE,OAAO,CAAC,GACjC,kBAAkB,GAAG;QACnB,EAAE,EAAE,OAAO,CAAA;KACZ,CACJ;CACF,CAAC,MAAM,CAAC,GAAG;IACV,4FAA4F;IAC5F,GAAG,CAAC,EAAE,kBAAkB,CAAC,KAAK,CAAC,GAAG,IAAI,CAAA;CACvC,CAAA;AAED,MAAM,MAAM,yBAAyB,GAAG,8BAA8B,CAAA;AAEtE,MAAM,MAAM,wBAAwB,GAEhC,2BAA2B,GAE3B,aAAa,GACb,SAAS,GAET,6BAA6B,CAAA;AAEjC,wDAAwD;AACxD,wBAAsB,eAAe,CACnC,MAAM,SAAS,MAAM,EACrB,OAAO,SAAS,MAAM,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,EAE9C,MAAM,EAAE,MAAM,EACd,UAAU,EAAE,yBAAyB,CAAC,MAAM,EAAE,OAAO,CAAC,GACrD,OAAO,CAAC,yBAAyB,CAAC,CA+BpC"}
@@ -1,2 +1,2 @@
1
- export declare const version = "2.1.1";
1
+ export declare const version = "2.1.2";
2
2
  //# sourceMappingURL=version.d.ts.map
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@wagmi/core",
3
3
  "description": "VanillaJS library for Ethereum",
4
- "version": "2.1.1",
4
+ "version": "2.1.2",
5
5
  "license": "MIT",
6
6
  "repository": {
7
7
  "type": "git",
@@ -5,8 +5,12 @@ import type {
5
5
  SendTransactionErrorType as viem_SendTransactionErrorType,
6
6
  SendTransactionParameters as viem_SendTransactionParameters,
7
7
  SendTransactionReturnType as viem_SendTransactionReturnType,
8
+ TransactionRequest,
8
9
  } from 'viem'
9
- import { sendTransaction as viem_sendTransaction } from 'viem/actions'
10
+ import {
11
+ estimateGas as viem_estimateGas,
12
+ sendTransaction as viem_sendTransaction,
13
+ } from 'viem/actions'
10
14
 
11
15
  import { type Config } from '../createConfig.js'
12
16
  import type { BaseErrorType, ErrorType } from '../errors/base.js'
@@ -30,14 +34,17 @@ export type SendTransactionParameters<
30
34
  [key in keyof chains]: Evaluate<
31
35
  Omit<
32
36
  viem_SendTransactionParameters<chains[key], Account, chains[key]>,
33
- 'chain'
37
+ 'chain' | 'gas'
34
38
  > &
35
39
  ChainIdParameter<config, chainId> &
36
40
  ConnectorParameter & {
37
41
  to: Address
38
42
  }
39
43
  >
40
- }[number]
44
+ }[number] & {
45
+ /** Gas provided for transaction execution, or `null` to skip the prelude gas estimation. */
46
+ gas?: TransactionRequest['gas'] | null
47
+ }
41
48
 
42
49
  export type SendTransactionReturnType = viem_SendTransactionReturnType
43
50
 
@@ -58,7 +65,7 @@ export async function sendTransaction<
58
65
  config: config,
59
66
  parameters: SendTransactionParameters<config, chainId>,
60
67
  ): Promise<SendTransactionReturnType> {
61
- const { account, chainId, connector, ...rest } = parameters
68
+ const { account, chainId, connector, gas: gas_, ...rest } = parameters
62
69
 
63
70
  const client = await getConnectorClient(config, {
64
71
  account,
@@ -66,8 +73,24 @@ export async function sendTransaction<
66
73
  connector,
67
74
  })
68
75
 
76
+ const gas = await (async () => {
77
+ // Skip gas estimation if `null` is provided.
78
+ if (gas_ === null) return undefined
79
+
80
+ // Run gas estimation if no value is provided.
81
+ if (gas_ === undefined)
82
+ return viem_estimateGas(client, {
83
+ ...(rest as any),
84
+ chain: chainId ? { id: chainId } : null,
85
+ })
86
+
87
+ // Use provided gas value.
88
+ return gas_
89
+ })()
90
+
69
91
  const hash = await viem_sendTransaction(client, {
70
92
  ...(rest as any),
93
+ gas,
71
94
  chain: chainId ? { id: chainId } : null,
72
95
  })
73
96
 
@@ -310,7 +310,7 @@ export function injected(parameters: InjectedParameters = {}) {
310
310
  throw new ProviderNotFoundError()
311
311
  }
312
312
 
313
- // We are applying a retry & timeout strategy here as some injected wallets (ie. MetaMask) fail to
313
+ // We are applying a retry & timeout strategy here as some injected wallets (e.g. MetaMask) fail to
314
314
  // immediately resolve a JSON-RPC request on page load.
315
315
  const accounts = await withRetry(() =>
316
316
  withTimeout(() => this.getAccounts(), {
@@ -55,7 +55,7 @@ export function unstable_connector(
55
55
  new Error('Provider is disconnected.'),
56
56
  )
57
57
 
58
- // We are applying a retry & timeout strategy here as some injected wallets (ie. MetaMask) fail to
58
+ // We are applying a retry & timeout strategy here as some injected wallets (e.g. MetaMask) fail to
59
59
  // immediately resolve a JSON-RPC request on page load.
60
60
  const chainId = hexToNumber(
61
61
  await withRetry(() =>
package/src/version.ts CHANGED
@@ -1 +1 @@
1
- export const version = '2.1.1'
1
+ export const version = '2.1.2'