viem 2.21.26 → 2.21.27

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.
Files changed (55) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/_cjs/chains/definitions/chang.js +25 -0
  3. package/_cjs/chains/definitions/chang.js.map +1 -0
  4. package/_cjs/chains/definitions/hela.js +26 -0
  5. package/_cjs/chains/definitions/hela.js.map +1 -0
  6. package/_cjs/chains/definitions/ql1.js +31 -0
  7. package/_cjs/chains/definitions/ql1.js.map +1 -0
  8. package/_cjs/chains/index.js +14 -7
  9. package/_cjs/chains/index.js.map +1 -1
  10. package/_cjs/errors/version.js +1 -1
  11. package/_cjs/experimental/eip7702/actions/signAuthorization.js +9 -2
  12. package/_cjs/experimental/eip7702/actions/signAuthorization.js.map +1 -1
  13. package/_cjs/utils/formatters/transaction.js +3 -9
  14. package/_cjs/utils/formatters/transaction.js.map +1 -1
  15. package/_esm/chains/definitions/chang.js +22 -0
  16. package/_esm/chains/definitions/chang.js.map +1 -0
  17. package/_esm/chains/definitions/hela.js +23 -0
  18. package/_esm/chains/definitions/hela.js.map +1 -0
  19. package/_esm/chains/definitions/ql1.js +28 -0
  20. package/_esm/chains/definitions/ql1.js.map +1 -0
  21. package/_esm/chains/index.js +3 -0
  22. package/_esm/chains/index.js.map +1 -1
  23. package/_esm/errors/version.js +1 -1
  24. package/_esm/experimental/eip7702/actions/signAuthorization.js +9 -2
  25. package/_esm/experimental/eip7702/actions/signAuthorization.js.map +1 -1
  26. package/_esm/utils/formatters/transaction.js +3 -9
  27. package/_esm/utils/formatters/transaction.js.map +1 -1
  28. package/_types/chains/definitions/chang.d.ts +37 -0
  29. package/_types/chains/definitions/chang.d.ts.map +1 -0
  30. package/_types/chains/definitions/hela.d.ts +37 -0
  31. package/_types/chains/definitions/hela.d.ts.map +1 -0
  32. package/_types/chains/definitions/ql1.d.ts +32 -0
  33. package/_types/chains/definitions/ql1.d.ts.map +1 -0
  34. package/_types/chains/index.d.ts +3 -0
  35. package/_types/chains/index.d.ts.map +1 -1
  36. package/_types/errors/version.d.ts +1 -1
  37. package/_types/experimental/eip7702/actions/signAuthorization.d.ts +7 -2
  38. package/_types/experimental/eip7702/actions/signAuthorization.d.ts.map +1 -1
  39. package/_types/experimental/eip7702/types/rpc.d.ts +8 -2
  40. package/_types/experimental/eip7702/types/rpc.d.ts.map +1 -1
  41. package/_types/types/eip1193.d.ts +12 -0
  42. package/_types/types/eip1193.d.ts.map +1 -1
  43. package/_types/types/transaction.d.ts +1 -1
  44. package/_types/types/transaction.d.ts.map +1 -1
  45. package/chains/definitions/chang.ts +22 -0
  46. package/chains/definitions/hela.ts +23 -0
  47. package/chains/definitions/ql1.ts +28 -0
  48. package/chains/index.ts +3 -0
  49. package/errors/version.ts +1 -1
  50. package/experimental/eip7702/actions/signAuthorization.ts +16 -4
  51. package/experimental/eip7702/types/rpc.ts +8 -2
  52. package/package.json +1 -1
  53. package/types/eip1193.ts +12 -0
  54. package/types/transaction.ts +1 -1
  55. package/utils/formatters/transaction.ts +8 -17
@@ -0,0 +1,28 @@
1
+ import { defineChain } from '../../utils/chain/defineChain.js'
2
+
3
+ export const ql1 = /*#__PURE__*/ defineChain({
4
+ id: 766,
5
+ name: 'QL1',
6
+ nativeCurrency: {
7
+ decimals: 18,
8
+ name: 'QOM',
9
+ symbol: 'QOM',
10
+ },
11
+ rpcUrls: {
12
+ default: {
13
+ http: ['https://rpc.qom.one'],
14
+ },
15
+ },
16
+ blockExplorers: {
17
+ default: {
18
+ name: 'Ql1 Explorer',
19
+ url: 'https://scan.qom.one',
20
+ },
21
+ },
22
+ contracts: {
23
+ multicall3: {
24
+ address: '0x7A52370716ea730585884F5BDB0f6E60C39b8C64',
25
+ },
26
+ },
27
+ testnet: false,
28
+ })
package/chains/index.ts CHANGED
@@ -70,6 +70,7 @@ export { cannon } from './definitions/cannon.js'
70
70
  export { canto } from './definitions/canto.js'
71
71
  export { celo } from './definitions/celo.js'
72
72
  export { celoAlfajores } from './definitions/celoAlfajores.js'
73
+ export { chang } from './definitions/chang.js'
73
74
  export { chiliz } from './definitions/chiliz.js'
74
75
  export { chips } from './definitions/chips.js'
75
76
  export { classic } from './definitions/classic.js'
@@ -165,6 +166,7 @@ export { haqqTestedge2 } from './definitions/haqqTestedge2.js'
165
166
  export { hedera } from './definitions/hedera.js'
166
167
  export { hederaTestnet } from './definitions/hederaTestnet.js'
167
168
  export { hederaPreviewnet } from './definitions/hederaPreviewnet.js'
169
+ export { hela } from './definitions/hela.js'
168
170
  export { hemiSepolia } from './definitions/hemiSepolia.js'
169
171
  export { holesky } from './definitions/holesky.js'
170
172
  export { hychain } from './definitions/hychain.js'
@@ -274,6 +276,7 @@ export { polygonZkEvmCardona } from './definitions/polygonZkEvmCardona.js'
274
276
  export { polygonZkEvmTestnet } from './definitions/polygonZkEvmTestnet.js'
275
277
  export { pulsechain } from './definitions/pulsechain.js'
276
278
  export { pulsechainV4 } from './definitions/pulsechainV4.js'
279
+ export { ql1 } from './definitions/ql1.js'
277
280
  export { qMainnet } from './definitions/qMainnet.js'
278
281
  export { qTestnet } from './definitions/qTestnet.js'
279
282
  export { real } from './definitions/real.js'
package/errors/version.ts CHANGED
@@ -1 +1 @@
1
- export const version = '2.21.26'
1
+ export const version = '2.21.27'
@@ -31,8 +31,13 @@ export type SignAuthorizationParameters<
31
31
  account extends Account | undefined = Account | undefined,
32
32
  > = GetAccountParameter<account> &
33
33
  PartialBy<Authorization, 'chainId' | 'nonce'> & {
34
- /** Delegate of the EIP-7702 Authorization Transaction. @default `account` */
35
- delegate?: Address | Account | undefined
34
+ /**
35
+ * Whether the EIP-7702 Transaction will be executed by another Account.
36
+ *
37
+ * If not specified, it will be assumed that the EIP-7702 Transaction will
38
+ * be executed by the Account that signed the Authorization.
39
+ */
40
+ delegate?: true | Address | Account | undefined
36
41
  }
37
42
 
38
43
  export type SignAuthorizationReturnType = SignAuthorizationReturnType_account
@@ -108,7 +113,11 @@ export async function signAuthorization<
108
113
  })
109
114
  const account = parseAccount(account_)
110
115
 
111
- const delegate = delegate_ ? parseAccount(delegate_) : undefined
116
+ const delegate = (() => {
117
+ if (typeof delegate_ === 'boolean') return delegate_
118
+ if (delegate_) return parseAccount(delegate_)
119
+ return undefined
120
+ })()
112
121
 
113
122
  if (!account.experimental_signAuthorization)
114
123
  throw new AccountTypeNotSupportedError({
@@ -139,7 +148,10 @@ export async function signAuthorization<
139
148
  address: account.address,
140
149
  blockTag: 'pending',
141
150
  })
142
- if (!delegate || isAddressEqual(account.address, delegate.address))
151
+ if (
152
+ !delegate ||
153
+ (delegate !== true && isAddressEqual(account.address, delegate.address))
154
+ )
143
155
  authorization.nonce += 1
144
156
  }
145
157
 
@@ -1,5 +1,5 @@
1
1
  import type { Address } from 'abitype'
2
- import type { Hex, Signature } from '../../../types/misc.js'
2
+ import type { Hex } from '../../../types/misc.js'
3
3
 
4
4
  export type RpcAuthorization = {
5
5
  /** Address of the contract to set as code for the Authority. */
@@ -8,5 +8,11 @@ export type RpcAuthorization = {
8
8
  chainId: Hex
9
9
  /** Nonce of the Authority to authorize. */
10
10
  nonce: Hex
11
- } & Signature
11
+ /** ECDSA r value. */
12
+ r: Hex
13
+ /** ECDSA s value. */
14
+ s: Hex
15
+ /** y parity. */
16
+ yParity: Hex
17
+ }
12
18
  export type RpcAuthorizationList = readonly RpcAuthorization[]
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "viem",
3
3
  "description": "TypeScript Interface for Ethereum",
4
- "version": "2.21.26",
4
+ "version": "2.21.27",
5
5
  "main": "./_cjs/index.js",
6
6
  "module": "./_esm/index.js",
7
7
  "types": "./_types/index.d.ts",
package/types/eip1193.ts CHANGED
@@ -1780,6 +1780,18 @@ export type WalletRpcSchema = [
1780
1780
  Parameters?: WalletSendCallsParameters
1781
1781
  ReturnType: string
1782
1782
  },
1783
+ /**
1784
+ * @description Creates, signs, and sends a new transaction to the network
1785
+ * @link https://eips.ethereum.org/EIPS/eip-1474
1786
+ * @example
1787
+ * provider.request({ method: 'wallet_sendTransaction', params: [{ from: '0x...', to: '0x...', value: '0x...' }] })
1788
+ * // => '0x...'
1789
+ */
1790
+ {
1791
+ Method: 'wallet_sendTransaction'
1792
+ Parameters: [transaction: TransactionRequest]
1793
+ ReturnType: Hash
1794
+ },
1783
1795
  /**
1784
1796
  * @description Requests for the wallet to show information about a call batch
1785
1797
  * that was sent via `wallet_sendCalls`.
@@ -275,7 +275,7 @@ export type TransactionRequestEIP7702<
275
275
  > = TransactionRequestBase<quantity, index, type> &
276
276
  ExactPartial<FeeValuesEIP1559<quantity>> & {
277
277
  accessList?: AccessList | undefined
278
- authorizationList: AuthorizationList<index, boolean>
278
+ authorizationList?: AuthorizationList<index, boolean> | undefined
279
279
  }
280
280
 
281
281
  export type TransactionRequest<quantity = bigint, index = number> = OneOf<
@@ -127,21 +127,12 @@ export const defineTransaction = /*#__PURE__*/ defineFormatter(
127
127
  function formatAuthorizationList(
128
128
  authorizationList: RpcAuthorizationList,
129
129
  ): SignedAuthorizationList {
130
- return authorizationList.map(
131
- (authorization) =>
132
- ({
133
- contractAddress: (authorization as any).address,
134
- r: authorization.r,
135
- s: authorization.s,
136
- chainId: Number(authorization.chainId),
137
- nonce: Number(authorization.nonce),
138
- ...(typeof authorization.yParity !== 'undefined'
139
- ? { yParity: Number(authorization.yParity) }
140
- : {}),
141
- ...(typeof authorization.v !== 'undefined' &&
142
- typeof authorization.yParity === 'undefined'
143
- ? { v: Number(authorization.v) }
144
- : {}),
145
- }) as any,
146
- ) as SignedAuthorizationList
130
+ return authorizationList.map((authorization) => ({
131
+ contractAddress: (authorization as any).address,
132
+ chainId: Number(authorization.chainId),
133
+ nonce: Number(authorization.nonce),
134
+ r: authorization.r,
135
+ s: authorization.s,
136
+ yParity: Number(authorization.yParity),
137
+ })) as SignedAuthorizationList
147
138
  }