viem 2.21.29 → 2.21.31

Sign up to get free protection for your applications and to get access to all the features.
Files changed (83) hide show
  1. package/CHANGELOG.md +24 -0
  2. package/_cjs/chains/definitions/apeChain.js +35 -0
  3. package/_cjs/chains/definitions/apeChain.js.map +1 -0
  4. package/_cjs/chains/definitions/excelonMainnet.js +26 -0
  5. package/_cjs/chains/definitions/excelonMainnet.js.map +1 -0
  6. package/_cjs/chains/definitions/sanko.js +22 -0
  7. package/_cjs/chains/definitions/sanko.js.map +1 -0
  8. package/_cjs/chains/definitions/step.js +22 -0
  9. package/_cjs/chains/definitions/step.js.map +1 -0
  10. package/_cjs/chains/definitions/thunderCore.js +22 -0
  11. package/_cjs/chains/definitions/thunderCore.js.map +1 -0
  12. package/_cjs/chains/definitions/tiktrixTestnet.js +26 -0
  13. package/_cjs/chains/definitions/tiktrixTestnet.js.map +1 -0
  14. package/_cjs/chains/index.js +21 -9
  15. package/_cjs/chains/index.js.map +1 -1
  16. package/_cjs/errors/typedData.js +14 -0
  17. package/_cjs/errors/typedData.js.map +1 -0
  18. package/_cjs/errors/version.js +1 -1
  19. package/_cjs/index.js +11 -9
  20. package/_cjs/index.js.map +1 -1
  21. package/_cjs/op-stack/actions/getWithdrawalStatus.js +2 -2
  22. package/_cjs/op-stack/actions/getWithdrawalStatus.js.map +1 -1
  23. package/_cjs/utils/typedData.js +13 -1
  24. package/_cjs/utils/typedData.js.map +1 -1
  25. package/_esm/chains/definitions/apeChain.js +32 -0
  26. package/_esm/chains/definitions/apeChain.js.map +1 -0
  27. package/_esm/chains/definitions/excelonMainnet.js +23 -0
  28. package/_esm/chains/definitions/excelonMainnet.js.map +1 -0
  29. package/_esm/chains/definitions/sanko.js +19 -0
  30. package/_esm/chains/definitions/sanko.js.map +1 -0
  31. package/_esm/chains/definitions/step.js +19 -0
  32. package/_esm/chains/definitions/step.js.map +1 -0
  33. package/_esm/chains/definitions/thunderCore.js +19 -0
  34. package/_esm/chains/definitions/thunderCore.js.map +1 -0
  35. package/_esm/chains/definitions/tiktrixTestnet.js +23 -0
  36. package/_esm/chains/definitions/tiktrixTestnet.js.map +1 -0
  37. package/_esm/chains/index.js +6 -0
  38. package/_esm/chains/index.js.map +1 -1
  39. package/_esm/errors/typedData.js +10 -0
  40. package/_esm/errors/typedData.js.map +1 -0
  41. package/_esm/errors/version.js +1 -1
  42. package/_esm/index.js +1 -0
  43. package/_esm/index.js.map +1 -1
  44. package/_esm/op-stack/actions/getWithdrawalStatus.js +2 -2
  45. package/_esm/op-stack/actions/getWithdrawalStatus.js.map +1 -1
  46. package/_esm/utils/typedData.js +15 -1
  47. package/_esm/utils/typedData.js.map +1 -1
  48. package/_types/chains/definitions/apeChain.d.ts +35 -0
  49. package/_types/chains/definitions/apeChain.d.ts.map +1 -0
  50. package/_types/chains/definitions/excelonMainnet.d.ts +38 -0
  51. package/_types/chains/definitions/excelonMainnet.d.ts.map +1 -0
  52. package/_types/chains/definitions/sanko.d.ts +37 -0
  53. package/_types/chains/definitions/sanko.d.ts.map +1 -0
  54. package/_types/chains/definitions/step.d.ts +37 -0
  55. package/_types/chains/definitions/step.d.ts.map +1 -0
  56. package/_types/chains/definitions/thunderCore.d.ts +37 -0
  57. package/_types/chains/definitions/thunderCore.d.ts.map +1 -0
  58. package/_types/chains/definitions/tiktrixTestnet.d.ts +37 -0
  59. package/_types/chains/definitions/tiktrixTestnet.d.ts.map +1 -0
  60. package/_types/chains/index.d.ts +6 -0
  61. package/_types/chains/index.d.ts.map +1 -1
  62. package/_types/errors/typedData.d.ts +10 -0
  63. package/_types/errors/typedData.d.ts.map +1 -0
  64. package/_types/errors/version.d.ts +1 -1
  65. package/_types/index.d.ts +1 -0
  66. package/_types/index.d.ts.map +1 -1
  67. package/_types/op-stack/actions/getWithdrawalStatus.d.ts +5 -0
  68. package/_types/op-stack/actions/getWithdrawalStatus.d.ts.map +1 -1
  69. package/_types/utils/typedData.d.ts +1 -1
  70. package/_types/utils/typedData.d.ts.map +1 -1
  71. package/chains/definitions/apeChain.ts +33 -0
  72. package/chains/definitions/excelonMainnet.ts +23 -0
  73. package/chains/definitions/sanko.ts +19 -0
  74. package/chains/definitions/step.ts +19 -0
  75. package/chains/definitions/thunderCore.ts +19 -0
  76. package/chains/definitions/tiktrixTestnet.ts +23 -0
  77. package/chains/index.ts +6 -0
  78. package/errors/typedData.ts +13 -0
  79. package/errors/version.ts +1 -1
  80. package/index.ts +4 -0
  81. package/op-stack/actions/getWithdrawalStatus.ts +7 -1
  82. package/package.json +1 -1
  83. package/utils/typedData.ts +20 -3
@@ -0,0 +1,19 @@
1
+ import { defineChain } from '../../utils/chain/defineChain.js'
2
+
3
+ export const thunderCore = /*#__PURE__*/ defineChain({
4
+ id: 108,
5
+ name: 'ThunderCore Mainnet',
6
+ nativeCurrency: { name: 'TT', symbol: 'TT', decimals: 18 },
7
+ rpcUrls: {
8
+ default: {
9
+ http: ['https://mainnet-rpc.thundercore.com'],
10
+ },
11
+ },
12
+ blockExplorers: {
13
+ default: {
14
+ name: 'ThunderCore Explorer',
15
+ url: 'https://viewblock.io/thundercore',
16
+ },
17
+ },
18
+ testnet: false,
19
+ })
@@ -0,0 +1,23 @@
1
+ import { defineChain } from '../../utils/chain/defineChain.js'
2
+
3
+ export const tiktrixTestnet = /*#__PURE__*/ defineChain({
4
+ id: 62092,
5
+ name: 'TikTrix Testnet',
6
+ nativeCurrency: {
7
+ name: 'tTTX',
8
+ symbol: 'tTTX',
9
+ decimals: 18,
10
+ },
11
+ rpcUrls: {
12
+ default: {
13
+ http: ['https://tiktrix-rpc.xyz'],
14
+ },
15
+ },
16
+ blockExplorers: {
17
+ default: {
18
+ name: 'TikTrix Testnet Explorer',
19
+ url: 'https://tiktrix.xyz',
20
+ },
21
+ },
22
+ testnet: true,
23
+ })
package/chains/index.ts CHANGED
@@ -8,6 +8,7 @@ export { alienxHalTestnet } from './definitions/alienXHalTestnet.js'
8
8
  export { ancient8 } from './definitions/ancient8.js'
9
9
  export { ancient8Sepolia } from './definitions/ancient8Sepolia.js'
10
10
  export { anvil } from './definitions/anvil.js'
11
+ export { apeChain } from './definitions/apeChain.js'
11
12
  export { apexTestnet } from './definitions/apexTestnet.js'
12
13
  export { arbitrum } from './definitions/arbitrum.js'
13
14
  export { arbitrumGoerli } from './definitions/arbitrumGoerli.js'
@@ -119,6 +120,7 @@ export { elastos } from './definitions/elastos.js'
119
120
  export { elastosTestnet } from './definitions/elastosTestnet.js'
120
121
  export { electroneum } from './definitions/electroneum.js'
121
122
  export { electroneumTestnet } from './definitions/electroneumTestnet.js'
123
+ export { excelonMainnet } from './definitions/excelonMainnet.js'
122
124
  export { fantom } from './definitions/fantom.js'
123
125
  export { fantomSonicTestnet } from './definitions/fantomSonicTestnet.js'
124
126
  export { fantomTestnet } from './definitions/fantomTestnet.js'
@@ -296,6 +298,7 @@ export { rootstockTestnet } from './definitions/rootstockTestnet.js'
296
298
  export { rss3 } from './definitions/rss3.js'
297
299
  export { rss3Sepolia } from './definitions/rss3Sepolia.js'
298
300
  export { saigon } from './definitions/saigon.js'
301
+ export { sanko } from './definitions/sanko.js'
299
302
  export { sapphire } from './definitions/sapphire.js'
300
303
  export { sapphireTestnet } from './definitions/sapphireTestnet.js'
301
304
  export { satoshiVM } from './definitions/satoshivm.js'
@@ -336,6 +339,7 @@ export { shardeumSphinx } from './definitions/shardeumSphinx.js'
336
339
  export { shibarium } from './definitions/shibarium.js'
337
340
  export { shibariumTestnet } from './definitions/shibariumTestnet.js'
338
341
  export { shiden } from './definitions/shiden.js'
342
+ export { step } from './definitions/step.js'
339
343
  export { storyTestnet } from './definitions/storyTestnet.js'
340
344
  export { silicon } from './definitions/silicon.js'
341
345
  export { siliconSepolia } from './definitions/siliconSepolia.js'
@@ -359,7 +363,9 @@ export { telos } from './definitions/telos.js'
359
363
  export { telosTestnet } from './definitions/telosTestnet.js'
360
364
  export { tenet } from './definitions/tenet.js'
361
365
  export { thaiChain } from './definitions/thaiChain.js'
366
+ export { thunderCore } from './definitions/thunderCore.js'
362
367
  export { thunderTestnet } from './definitions/thunderTestnet.js'
368
+ export { tiktrixTestnet } from './definitions/tiktrixTestnet.js'
363
369
  export { tron } from './definitions/tron.js'
364
370
  export { ultron } from './definitions/ultron.js'
365
371
  export { ultronTestnet } from './definitions/ultronTestnet.js'
@@ -0,0 +1,13 @@
1
+ import { BaseError } from './base.js'
2
+
3
+ export type InvalidStructTypeErrorType = InvalidStructTypeError & {
4
+ name: 'InvalidStructTypeError'
5
+ }
6
+ export class InvalidStructTypeError extends BaseError {
7
+ constructor({ type }: { type: string }) {
8
+ super(`Struct type "${type}" is invalid.`, {
9
+ metaMessages: ['Struct type must not be a Solidity type.'],
10
+ name: 'InvalidStructTypeError',
11
+ })
12
+ }
13
+ }
package/errors/version.ts CHANGED
@@ -1 +1 @@
1
- export const version = '2.21.29'
1
+ export const version = '2.21.31'
package/index.ts CHANGED
@@ -917,6 +917,10 @@ export {
917
917
  StateAssignmentConflictError,
918
918
  type StateAssignmentConflictErrorType,
919
919
  } from './errors/stateOverride.js'
920
+ export {
921
+ type InvalidStructTypeErrorType,
922
+ InvalidStructTypeError,
923
+ } from './errors/typedData.js'
920
924
  export type {
921
925
  AbiEventParameterToPrimitiveType,
922
926
  AbiEventParametersToPrimitiveTypes,
@@ -62,6 +62,11 @@ export type GetWithdrawalStatusParameters<
62
62
  * @default 100
63
63
  */
64
64
  gameLimit?: number
65
+ /**
66
+ * The relative index of the withdrawal in the transaction receipt logs.
67
+ * @default 0
68
+ */
69
+ logIndex?: number
65
70
  receipt: TransactionReceipt
66
71
  }
67
72
  export type GetWithdrawalStatusReturnType =
@@ -122,6 +127,7 @@ export async function getWithdrawalStatus<
122
127
  gameLimit = 100,
123
128
  receipt,
124
129
  targetChain: targetChain_,
130
+ logIndex = 0,
125
131
  } = parameters
126
132
 
127
133
  const targetChain = targetChain_ as unknown as TargetChain
@@ -132,7 +138,7 @@ export async function getWithdrawalStatus<
132
138
  return Object.values(targetChain.contracts.portal)[0].address
133
139
  })()
134
140
 
135
- const [withdrawal] = getWithdrawals(receipt)
141
+ const withdrawal = getWithdrawals(receipt)[logIndex]
136
142
 
137
143
  if (!withdrawal)
138
144
  throw new ReceiptContainsNoWithdrawalsError({
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.29",
4
+ "version": "2.21.31",
5
5
  "main": "./_cjs/index.js",
6
6
  "module": "./_esm/index.js",
7
7
  "types": "./_types/index.d.ts",
@@ -2,10 +2,10 @@ import type { TypedData, TypedDataDomain, TypedDataParameter } from 'abitype'
2
2
 
3
3
  import { BytesSizeMismatchError } from '../errors/abi.js'
4
4
  import { InvalidAddressError } from '../errors/address.js'
5
+ import { InvalidStructTypeError } from '../errors/typedData.js'
6
+ import type { ErrorType } from '../errors/utils.js'
5
7
  import type { Hex } from '../types/misc.js'
6
8
  import type { TypedDataDefinition } from '../types/typedData.js'
7
-
8
- import type { ErrorType } from '../errors/utils.js'
9
9
  import { type IsAddressErrorType, isAddress } from './address/isAddress.js'
10
10
  import { type SizeErrorType, size } from './data/size.js'
11
11
  import { type NumberToHexErrorType, numberToHex } from './encoding/toHex.js'
@@ -110,7 +110,10 @@ export function validateTypedData<
110
110
  }
111
111
 
112
112
  const struct = types[type]
113
- if (struct) validateData(struct, value as Record<string, unknown>)
113
+ if (struct) {
114
+ validateReference(type)
115
+ validateData(struct, value as Record<string, unknown>)
116
+ }
114
117
  }
115
118
  }
116
119
 
@@ -154,3 +157,17 @@ export function domainSeparator({ domain }: { domain: TypedDataDomain }): Hex {
154
157
  },
155
158
  })
156
159
  }
160
+
161
+ /** @internal */
162
+ function validateReference(type: string) {
163
+ // Struct type must not be a Solidity type.
164
+ if (
165
+ type === 'address' ||
166
+ type === 'bool' ||
167
+ type === 'string' ||
168
+ type.startsWith('bytes') ||
169
+ type.startsWith('uint') ||
170
+ type.startsWith('int')
171
+ )
172
+ throw new InvalidStructTypeError({ type })
173
+ }