viem 2.56.1 → 2.56.3

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 (254) hide show
  1. package/CHANGELOG.md +18 -0
  2. package/_cjs/actions/wallet/sendTransaction.js +9 -1
  3. package/_cjs/actions/wallet/sendTransaction.js.map +1 -1
  4. package/_cjs/actions/wallet/sendTransactionSync.js +9 -1
  5. package/_cjs/actions/wallet/sendTransactionSync.js.map +1 -1
  6. package/_cjs/errors/version.js +1 -1
  7. package/_cjs/tempo/Abis.js +11 -23
  8. package/_cjs/tempo/Abis.js.map +1 -1
  9. package/_cjs/tempo/Account.js +66 -61
  10. package/_cjs/tempo/Account.js.map +1 -1
  11. package/_cjs/tempo/Client.js +10 -2
  12. package/_cjs/tempo/Client.js.map +1 -1
  13. package/_cjs/tempo/Decorator.js +2 -1
  14. package/_cjs/tempo/Decorator.js.map +1 -1
  15. package/_cjs/tempo/Formatters.js +29 -9
  16. package/_cjs/tempo/Formatters.js.map +1 -1
  17. package/_cjs/tempo/Multisig.js +1093 -0
  18. package/_cjs/tempo/Multisig.js.map +1 -0
  19. package/_cjs/tempo/Selectors.js +2 -3
  20. package/_cjs/tempo/Selectors.js.map +1 -1
  21. package/_cjs/tempo/{Storage.js → Store.js} +34 -9
  22. package/_cjs/tempo/Store.js.map +1 -0
  23. package/_cjs/tempo/Transaction.js +15 -30
  24. package/_cjs/tempo/Transaction.js.map +1 -1
  25. package/_cjs/tempo/Transport.js +51 -5
  26. package/_cjs/tempo/Transport.js.map +1 -1
  27. package/_cjs/tempo/Zone.js.map +1 -1
  28. package/_cjs/tempo/actions/accessKey.js +102 -8
  29. package/_cjs/tempo/actions/accessKey.js.map +1 -1
  30. package/_cjs/tempo/actions/amm.js +6 -0
  31. package/_cjs/tempo/actions/amm.js.map +1 -1
  32. package/_cjs/tempo/actions/channel.js +12 -0
  33. package/_cjs/tempo/actions/channel.js.map +1 -1
  34. package/_cjs/tempo/actions/dex.js +10 -0
  35. package/_cjs/tempo/actions/dex.js.map +1 -1
  36. package/_cjs/tempo/actions/earn/deployment.js +13 -1
  37. package/_cjs/tempo/actions/earn/deployment.js.map +1 -1
  38. package/_cjs/tempo/actions/earn.js +17 -0
  39. package/_cjs/tempo/actions/earn.js.map +1 -1
  40. package/_cjs/tempo/actions/fee.js +4 -0
  41. package/_cjs/tempo/actions/fee.js.map +1 -1
  42. package/_cjs/tempo/actions/multisig.js +86 -28
  43. package/_cjs/tempo/actions/multisig.js.map +1 -1
  44. package/_cjs/tempo/actions/policy.js +8 -0
  45. package/_cjs/tempo/actions/policy.js.map +1 -1
  46. package/_cjs/tempo/actions/receivePolicy.js +6 -0
  47. package/_cjs/tempo/actions/receivePolicy.js.map +1 -1
  48. package/_cjs/tempo/actions/reward.js +4 -0
  49. package/_cjs/tempo/actions/reward.js.map +1 -1
  50. package/_cjs/tempo/actions/token.js +32 -0
  51. package/_cjs/tempo/actions/token.js.map +1 -1
  52. package/_cjs/tempo/actions/virtualAddress.js +2 -0
  53. package/_cjs/tempo/actions/virtualAddress.js.map +1 -1
  54. package/_cjs/tempo/actions/zone.js +7 -5
  55. package/_cjs/tempo/actions/zone.js.map +1 -1
  56. package/_cjs/tempo/chainConfig.js +180 -69
  57. package/_cjs/tempo/chainConfig.js.map +1 -1
  58. package/_cjs/tempo/index.js +5 -2
  59. package/_cjs/tempo/index.js.map +1 -1
  60. package/_cjs/tempo/internal/utils.js +2 -1
  61. package/_cjs/tempo/internal/utils.js.map +1 -1
  62. package/_cjs/tempo/multisig/Config.js +80 -0
  63. package/_cjs/tempo/multisig/Config.js.map +1 -0
  64. package/_cjs/tempo/multisig/Operation.js +163 -0
  65. package/_cjs/tempo/multisig/Operation.js.map +1 -0
  66. package/_cjs/utils/encoding/fromHex.js +1 -1
  67. package/_cjs/utils/encoding/fromHex.js.map +1 -1
  68. package/_cjs/utils/hash/isHash.js +1 -2
  69. package/_cjs/utils/hash/isHash.js.map +1 -1
  70. package/_esm/actions/wallet/sendTransaction.js +9 -1
  71. package/_esm/actions/wallet/sendTransaction.js.map +1 -1
  72. package/_esm/actions/wallet/sendTransactionSync.js +9 -1
  73. package/_esm/actions/wallet/sendTransactionSync.js.map +1 -1
  74. package/_esm/errors/version.js +1 -1
  75. package/_esm/tempo/Abis.js +11 -23
  76. package/_esm/tempo/Abis.js.map +1 -1
  77. package/_esm/tempo/Account.js +66 -61
  78. package/_esm/tempo/Account.js.map +1 -1
  79. package/_esm/tempo/Client.js +22 -3
  80. package/_esm/tempo/Client.js.map +1 -1
  81. package/_esm/tempo/Decorator.js +2 -1
  82. package/_esm/tempo/Decorator.js.map +1 -1
  83. package/_esm/tempo/Formatters.js +32 -11
  84. package/_esm/tempo/Formatters.js.map +1 -1
  85. package/_esm/tempo/Multisig.js +1126 -0
  86. package/_esm/tempo/Multisig.js.map +1 -0
  87. package/_esm/tempo/Selectors.js +2 -3
  88. package/_esm/tempo/Selectors.js.map +1 -1
  89. package/_esm/tempo/{Storage.js → Store.js} +37 -26
  90. package/_esm/tempo/Store.js.map +1 -0
  91. package/_esm/tempo/Transaction.js +16 -31
  92. package/_esm/tempo/Transaction.js.map +1 -1
  93. package/_esm/tempo/Transport.js +71 -6
  94. package/_esm/tempo/Transport.js.map +1 -1
  95. package/_esm/tempo/Zone.js +1 -2
  96. package/_esm/tempo/Zone.js.map +1 -1
  97. package/_esm/tempo/actions/accessKey.js +104 -20
  98. package/_esm/tempo/actions/accessKey.js.map +1 -1
  99. package/_esm/tempo/actions/amm.js +6 -0
  100. package/_esm/tempo/actions/amm.js.map +1 -1
  101. package/_esm/tempo/actions/channel.js +12 -0
  102. package/_esm/tempo/actions/channel.js.map +1 -1
  103. package/_esm/tempo/actions/dex.js +10 -0
  104. package/_esm/tempo/actions/dex.js.map +1 -1
  105. package/_esm/tempo/actions/earn/deployment.js +13 -1
  106. package/_esm/tempo/actions/earn/deployment.js.map +1 -1
  107. package/_esm/tempo/actions/earn.js +17 -0
  108. package/_esm/tempo/actions/earn.js.map +1 -1
  109. package/_esm/tempo/actions/fee.js +4 -0
  110. package/_esm/tempo/actions/fee.js.map +1 -1
  111. package/_esm/tempo/actions/multisig.js +129 -63
  112. package/_esm/tempo/actions/multisig.js.map +1 -1
  113. package/_esm/tempo/actions/policy.js +8 -0
  114. package/_esm/tempo/actions/policy.js.map +1 -1
  115. package/_esm/tempo/actions/receivePolicy.js +6 -0
  116. package/_esm/tempo/actions/receivePolicy.js.map +1 -1
  117. package/_esm/tempo/actions/reward.js +4 -0
  118. package/_esm/tempo/actions/reward.js.map +1 -1
  119. package/_esm/tempo/actions/token.js +32 -0
  120. package/_esm/tempo/actions/token.js.map +1 -1
  121. package/_esm/tempo/actions/virtualAddress.js +2 -0
  122. package/_esm/tempo/actions/virtualAddress.js.map +1 -1
  123. package/_esm/tempo/actions/zone.js +8 -6
  124. package/_esm/tempo/actions/zone.js.map +1 -1
  125. package/_esm/tempo/chainConfig.js +188 -86
  126. package/_esm/tempo/chainConfig.js.map +1 -1
  127. package/_esm/tempo/index.js +5 -3
  128. package/_esm/tempo/index.js.map +1 -1
  129. package/_esm/tempo/internal/utils.js +2 -1
  130. package/_esm/tempo/internal/utils.js.map +1 -1
  131. package/_esm/tempo/multisig/Config.js +84 -0
  132. package/_esm/tempo/multisig/Config.js.map +1 -0
  133. package/_esm/tempo/multisig/Operation.js +170 -0
  134. package/_esm/tempo/multisig/Operation.js.map +1 -0
  135. package/_esm/utils/encoding/fromHex.js +1 -1
  136. package/_esm/utils/encoding/fromHex.js.map +1 -1
  137. package/_esm/utils/hash/isHash.js +1 -2
  138. package/_esm/utils/hash/isHash.js.map +1 -1
  139. package/_types/actions/wallet/sendTransaction.d.ts.map +1 -1
  140. package/_types/actions/wallet/sendTransactionSync.d.ts.map +1 -1
  141. package/_types/chains/definitions/tempo.d.ts +72 -92
  142. package/_types/chains/definitions/tempo.d.ts.map +1 -1
  143. package/_types/chains/definitions/tempoDevnet.d.ts +72 -92
  144. package/_types/chains/definitions/tempoDevnet.d.ts.map +1 -1
  145. package/_types/chains/definitions/tempoLocalnet.d.ts +72 -92
  146. package/_types/chains/definitions/tempoLocalnet.d.ts.map +1 -1
  147. package/_types/chains/definitions/tempoModerato.d.ts +72 -92
  148. package/_types/chains/definitions/tempoModerato.d.ts.map +1 -1
  149. package/_types/errors/version.d.ts +1 -1
  150. package/_types/tempo/Abis.d.ts +54 -108
  151. package/_types/tempo/Abis.d.ts.map +1 -1
  152. package/_types/tempo/Account.d.ts +47 -20
  153. package/_types/tempo/Account.d.ts.map +1 -1
  154. package/_types/tempo/Client.d.ts +23 -1
  155. package/_types/tempo/Client.d.ts.map +1 -1
  156. package/_types/tempo/Decorator.d.ts +30 -5
  157. package/_types/tempo/Decorator.d.ts.map +1 -1
  158. package/_types/tempo/Formatters.d.ts.map +1 -1
  159. package/_types/tempo/Multisig.d.ts +37 -0
  160. package/_types/tempo/Multisig.d.ts.map +1 -0
  161. package/_types/tempo/Selectors.d.ts +2 -3
  162. package/_types/tempo/Selectors.d.ts.map +1 -1
  163. package/_types/tempo/Store.d.ts +62 -0
  164. package/_types/tempo/Store.d.ts.map +1 -0
  165. package/_types/tempo/Transaction.d.ts +12 -31
  166. package/_types/tempo/Transaction.d.ts.map +1 -1
  167. package/_types/tempo/Transport.d.ts +37 -5
  168. package/_types/tempo/Transport.d.ts.map +1 -1
  169. package/_types/tempo/Zone.d.ts +35 -6799
  170. package/_types/tempo/Zone.d.ts.map +1 -1
  171. package/_types/tempo/actions/accessKey.d.ts +38 -8
  172. package/_types/tempo/actions/accessKey.d.ts.map +1 -1
  173. package/_types/tempo/actions/amm.d.ts.map +1 -1
  174. package/_types/tempo/actions/channel.d.ts.map +1 -1
  175. package/_types/tempo/actions/dex.d.ts.map +1 -1
  176. package/_types/tempo/actions/earn/deployment.d.ts +3 -3
  177. package/_types/tempo/actions/earn/deployment.d.ts.map +1 -1
  178. package/_types/tempo/actions/earn.d.ts.map +1 -1
  179. package/_types/tempo/actions/fee.d.ts.map +1 -1
  180. package/_types/tempo/actions/multisig.d.ts +139 -136
  181. package/_types/tempo/actions/multisig.d.ts.map +1 -1
  182. package/_types/tempo/actions/policy.d.ts.map +1 -1
  183. package/_types/tempo/actions/receivePolicy.d.ts.map +1 -1
  184. package/_types/tempo/actions/reward.d.ts.map +1 -1
  185. package/_types/tempo/actions/token.d.ts.map +1 -1
  186. package/_types/tempo/actions/virtualAddress.d.ts.map +1 -1
  187. package/_types/tempo/actions/zone.d.ts +4 -4
  188. package/_types/tempo/actions/zone.d.ts.map +1 -1
  189. package/_types/tempo/chainConfig.d.ts +38 -48
  190. package/_types/tempo/chainConfig.d.ts.map +1 -1
  191. package/_types/tempo/index.d.ts +5 -5
  192. package/_types/tempo/index.d.ts.map +1 -1
  193. package/_types/tempo/internal/types.d.ts +1 -1
  194. package/_types/tempo/internal/types.d.ts.map +1 -1
  195. package/_types/tempo/internal/utils.d.ts +1 -0
  196. package/_types/tempo/internal/utils.d.ts.map +1 -1
  197. package/_types/tempo/multisig/Config.d.ts +42 -0
  198. package/_types/tempo/multisig/Config.d.ts.map +1 -0
  199. package/_types/tempo/multisig/Operation.d.ts +32 -0
  200. package/_types/tempo/multisig/Operation.d.ts.map +1 -0
  201. package/_types/types/chain.d.ts +10 -0
  202. package/_types/types/chain.d.ts.map +1 -1
  203. package/_types/utils/hash/isHash.d.ts +1 -2
  204. package/_types/utils/hash/isHash.d.ts.map +1 -1
  205. package/actions/wallet/sendTransaction.ts +9 -1
  206. package/actions/wallet/sendTransactionSync.ts +9 -1
  207. package/errors/version.ts +1 -1
  208. package/package.json +2 -2
  209. package/tempo/Abis.ts +11 -23
  210. package/tempo/Account.ts +136 -105
  211. package/tempo/Client.ts +46 -3
  212. package/tempo/Decorator.ts +40 -8
  213. package/tempo/Formatters.ts +39 -21
  214. package/tempo/Multisig.ts +1490 -0
  215. package/tempo/Selectors.ts +2 -3
  216. package/tempo/Store.ts +170 -0
  217. package/tempo/Transaction.ts +39 -64
  218. package/tempo/Transport.ts +125 -10
  219. package/tempo/Zone.ts +30 -4
  220. package/tempo/actions/accessKey.ts +210 -23
  221. package/tempo/actions/amm.ts +7 -0
  222. package/tempo/actions/channel.ts +12 -0
  223. package/tempo/actions/dex.ts +10 -0
  224. package/tempo/actions/earn/deployment.ts +16 -3
  225. package/tempo/actions/earn.ts +19 -0
  226. package/tempo/actions/fee.ts +4 -0
  227. package/tempo/actions/multisig.ts +192 -94
  228. package/tempo/actions/policy.ts +8 -0
  229. package/tempo/actions/receivePolicy.ts +6 -0
  230. package/tempo/actions/reward.ts +5 -0
  231. package/tempo/actions/token.ts +33 -0
  232. package/tempo/actions/virtualAddress.ts +2 -0
  233. package/tempo/actions/zone.ts +10 -8
  234. package/tempo/chainConfig.ts +259 -100
  235. package/tempo/index.ts +5 -4
  236. package/tempo/internal/types.ts +3 -2
  237. package/tempo/internal/utils.ts +2 -0
  238. package/tempo/multisig/Config.ts +131 -0
  239. package/tempo/multisig/Operation.ts +211 -0
  240. package/types/chain.ts +14 -0
  241. package/utils/encoding/fromHex.ts +1 -1
  242. package/utils/hash/isHash.ts +2 -3
  243. package/_cjs/tempo/Storage.js.map +0 -1
  244. package/_cjs/tempo/internal/multisig.js +0 -56
  245. package/_cjs/tempo/internal/multisig.js.map +0 -1
  246. package/_esm/tempo/Storage.js.map +0 -1
  247. package/_esm/tempo/internal/multisig.js +0 -56
  248. package/_esm/tempo/internal/multisig.js.map +0 -1
  249. package/_types/tempo/Storage.d.ts +0 -42
  250. package/_types/tempo/Storage.d.ts.map +0 -1
  251. package/_types/tempo/internal/multisig.d.ts +0 -13
  252. package/_types/tempo/internal/multisig.d.ts.map +0 -1
  253. package/tempo/Storage.ts +0 -115
  254. package/tempo/internal/multisig.ts +0 -72
@@ -0,0 +1,131 @@
1
+ import * as Address from 'ox/Address'
2
+ import * as Hash from 'ox/Hash'
3
+ import type * as Hex from 'ox/Hex'
4
+ import * as Json from 'ox/Json'
5
+ import { MultisigConfig } from 'ox/tempo'
6
+ import { BaseError } from '../../errors/base.js'
7
+ import type * as Store from '../Store.js'
8
+
9
+ /** A valid 48-owner config is much smaller; 64 KiB bounds hostile store parsing work. */
10
+ const maxStoredValueLength = 65_536
11
+
12
+ /** Zero commitment used before an account records its first config update. */
13
+ const zeroCommitment = `0x${'00'.repeat(32)}` as const
14
+
15
+ /** Reads a cached multisig config. */
16
+ export async function read(
17
+ store: Store.Store,
18
+ options: read.Options,
19
+ ): Promise<MultisigConfig.Config | null> {
20
+ const { address, commitment } = options
21
+ const value = await store.getItem(key({ address, commitment }))
22
+ if (value === null || value === undefined) return null
23
+ const config = deserialize(value)
24
+ assertKey({ address, commitment, config })
25
+ return config
26
+ }
27
+
28
+ export declare namespace read {
29
+ /** Parameters for {@link read}. */
30
+ export type Options = {
31
+ /** Multisig account address. */
32
+ address: Address.Address
33
+ /** Config commitment observed onchain. */
34
+ commitment: Hex.Hex
35
+ }
36
+ }
37
+
38
+ /** Writes a validated multisig config. */
39
+ export async function write(
40
+ store: Store.Store,
41
+ options: write.Options,
42
+ ): Promise<void> {
43
+ const { address, commitment } = options
44
+ const config = MultisigConfig.from(options.config)
45
+ assertKey({ address, commitment, config })
46
+ await store.setItem(key({ address, commitment }), serialize(config))
47
+ }
48
+
49
+ export declare namespace write {
50
+ /** Parameters for {@link write}. */
51
+ export type Options = {
52
+ /** Multisig account address. */
53
+ address: Address.Address
54
+ /** Config commitment used for lookup. */
55
+ commitment: Hex.Hex
56
+ /** Complete config. */
57
+ config: MultisigConfig.Config
58
+ }
59
+ }
60
+
61
+ /** Verifies that a config matches its account-and-commitment key. */
62
+ function assertKey(options: {
63
+ address: Address.Address
64
+ commitment: Hex.Hex
65
+ config: MultisigConfig.Config
66
+ }) {
67
+ const { address, commitment, config } = options
68
+ if (!Address.validate(address) || !Hash.validate(commitment))
69
+ throw new InvalidStoreValueError()
70
+ if (config.version === 0n) {
71
+ if (
72
+ commitment.toLowerCase() !== zeroCommitment ||
73
+ !Address.isEqual(MultisigConfig.getAddress(config), address)
74
+ )
75
+ throw new InvalidStoreValueError()
76
+ return
77
+ }
78
+ if (
79
+ MultisigConfig.getCommitment(config).toLowerCase() !==
80
+ commitment.toLowerCase()
81
+ )
82
+ throw new InvalidStoreValueError()
83
+ }
84
+
85
+ /** Deserializes a multisig config from storage. */
86
+ function deserialize(value: string): MultisigConfig.Config {
87
+ try {
88
+ if (value.length > maxStoredValueLength) throw new InvalidStoreValueError()
89
+ return MultisigConfig.fromRpc(Json.parse(value) as never)
90
+ } catch (cause) {
91
+ if (cause instanceof InvalidStoreValueError) throw cause
92
+ throw new InvalidStoreValueError({ cause })
93
+ }
94
+ }
95
+
96
+ /** Returns the store key for an account and config commitment. */
97
+ function key(options: { address: Address.Address; commitment: Hex.Hex }) {
98
+ const { address, commitment } = options
99
+ return `multisig:config:${address.toLowerCase()}:${commitment.toLowerCase()}`
100
+ }
101
+
102
+ /** Serializes a multisig config for storage. */
103
+ function serialize(config: MultisigConfig.Config): string {
104
+ try {
105
+ const value = Json.stringify(MultisigConfig.toRpc(config))
106
+ if (value.length > maxStoredValueLength) throw new InvalidStoreValueError()
107
+ return value
108
+ } catch (cause) {
109
+ if (cause instanceof InvalidStoreValueError) throw cause
110
+ throw new InvalidStoreValueError({ cause })
111
+ }
112
+ }
113
+
114
+ /** Thrown when a stored multisig config is malformed or mismatched. */
115
+ export class InvalidStoreValueError extends BaseError {
116
+ /** Creates an invalid store value error. */
117
+ constructor(options: InvalidStoreValueError.Options = {}) {
118
+ super('Stored multisig config is malformed or mismatched.', {
119
+ cause: options.cause as Error | undefined,
120
+ name: 'Multisig.Config.InvalidStoreValueError',
121
+ })
122
+ }
123
+ }
124
+
125
+ export declare namespace InvalidStoreValueError {
126
+ /** Error construction options. */
127
+ export type Options = {
128
+ /** Underlying error. */
129
+ cause?: unknown | undefined
130
+ }
131
+ }
@@ -0,0 +1,211 @@
1
+ import type * as Hex from 'ox/Hex'
2
+ import * as Json from 'ox/Json'
3
+ import { MultisigOperation, SignatureEnvelope, TxEnvelopeTempo } from 'ox/tempo'
4
+ import { BaseError } from '../../errors/base.js'
5
+ import type * as Store from '../Store.js'
6
+
7
+ /** Bounds parsing and serialization work if a store returns unexpectedly large data. */
8
+ const maxStoredValueLength = 1_048_576
9
+
10
+ /** Prevents sustained compare-and-set contention from retrying indefinitely. */
11
+ const maxUpdateAttempts = 32
12
+
13
+ /** Bounds abandoned operation state while allowing long-lived approval ceremonies. */
14
+ const pendingOperationTtl = 30 * 24 * 60 * 60 * 1_000
15
+
16
+ /** Reads a persisted multisig operation. */
17
+ export async function read(
18
+ store: Store.Store,
19
+ hash: Hex.Hex,
20
+ ): Promise<MultisigOperation.Operation | null> {
21
+ const value = await store.getItem(operationKey(hash))
22
+ if (value === null || value === undefined) return null
23
+ const operation = deserialize(value)
24
+ if (operation.hash.toLowerCase() !== hash.toLowerCase())
25
+ throw new InvalidStoreValueError()
26
+ return operation
27
+ }
28
+
29
+ /** Atomically updates a multisig operation. */
30
+ export async function update(
31
+ store: Store.Atomic,
32
+ hash: Hex.Hex,
33
+ update: (
34
+ operation: MultisigOperation.Operation | null,
35
+ ) => MultisigOperation.Operation | Promise<MultisigOperation.Operation>,
36
+ ): Promise<MultisigOperation.Operation> {
37
+ const key = operationKey(hash)
38
+ for (let attempt = 0; attempt < maxUpdateAttempts; attempt++) {
39
+ const value = (await store.getItem(key)) ?? null
40
+ const current = value === null ? null : deserialize(value)
41
+ if (current && current.hash.toLowerCase() !== hash.toLowerCase())
42
+ throw new InvalidStoreValueError()
43
+ const value_ = await update(current)
44
+ let next: MultisigOperation.Operation
45
+ try {
46
+ next = MultisigOperation.from(value_)
47
+ } catch (cause) {
48
+ throw new InvalidStoreValueError({ cause })
49
+ }
50
+ if (next.hash.toLowerCase() !== hash.toLowerCase())
51
+ throw new InvalidStoreValueError()
52
+ const serialized = serialize(next)
53
+ const options =
54
+ next.status === 'success'
55
+ ? undefined
56
+ : { expiresAt: Date.now() + pendingOperationTtl }
57
+ if (await store.compareAndSet(key, value, serialized, options)) return next
58
+ }
59
+ throw new StoreConflictError()
60
+ }
61
+
62
+ /** Reads a submission hash without rebuilding its envelope from mutable configurations. */
63
+ export async function readSubmission(
64
+ store: Store.Store,
65
+ operation: MultisigOperation.TransactionOperation,
66
+ submissionId: Hex.Hex,
67
+ ): Promise<Hex.Hex | null> {
68
+ const value = await store.getItem(submissionKey(operation.hash, submissionId))
69
+ if (value === null || value === undefined) return null
70
+ try {
71
+ if (value.length > maxStoredValueLength) throw new InvalidStoreValueError()
72
+ const transaction = TxEnvelopeTempo.deserialize(
73
+ value as TxEnvelopeTempo.Serialized,
74
+ )
75
+ if (transaction.signature?.type !== 'multisig')
76
+ throw new InvalidStoreValueError()
77
+ const serialized = MultisigOperation.serializeTransaction(operation, {
78
+ approvals: transaction.signature.signatures.map((signature) =>
79
+ SignatureEnvelope.serialize(signature),
80
+ ),
81
+ })
82
+ if (serialized.toLowerCase() !== value.toLowerCase())
83
+ throw new InvalidStoreValueError()
84
+ return TxEnvelopeTempo.hash(transaction as TxEnvelopeTempo.Signed)
85
+ } catch (cause) {
86
+ if (cause instanceof InvalidStoreValueError) throw cause
87
+ throw new InvalidStoreValueError({ cause })
88
+ }
89
+ }
90
+
91
+ /** Removes a persisted final envelope after its submission is settled. */
92
+ export async function removeSubmission(
93
+ store: Store.Store,
94
+ hash: Hex.Hex,
95
+ submissionId: Hex.Hex,
96
+ ): Promise<void> {
97
+ await store.removeItem(submissionKey(hash, submissionId))
98
+ }
99
+
100
+ /** Persists the final envelope before broadcast so recovery uses the exact transaction. */
101
+ export async function writeSubmission(
102
+ store: Store.Atomic,
103
+ hash: Hex.Hex,
104
+ submissionId: Hex.Hex,
105
+ transaction: TxEnvelopeTempo.Serialized,
106
+ ): Promise<void> {
107
+ try {
108
+ if (transaction.length > maxStoredValueLength)
109
+ throw new InvalidStoreValueError()
110
+ const envelope = TxEnvelopeTempo.deserialize(transaction)
111
+ if (!envelope.signature) throw new InvalidStoreValueError()
112
+ TxEnvelopeTempo.hash(envelope as TxEnvelopeTempo.Signed)
113
+ const written = await store.compareAndSet(
114
+ submissionKey(hash, submissionId),
115
+ null,
116
+ transaction,
117
+ { expiresAt: Date.now() + pendingOperationTtl },
118
+ )
119
+ if (!written) throw new InvalidStoreValueError()
120
+ } catch (cause) {
121
+ if (cause instanceof InvalidStoreValueError) throw cause
122
+ throw new InvalidStoreValueError({ cause })
123
+ }
124
+ }
125
+
126
+ /** Deserializes a multisig operation from storage. */
127
+ function deserialize(value: string): MultisigOperation.Operation {
128
+ try {
129
+ if (value.length > maxStoredValueLength) throw new InvalidStoreValueError()
130
+ const operation = MultisigOperation.from(Json.parse(value) as never)
131
+ assertHash(operation)
132
+ return operation
133
+ } catch (cause) {
134
+ if (cause instanceof InvalidStoreValueError) throw cause
135
+ throw new InvalidStoreValueError({ cause })
136
+ }
137
+ }
138
+
139
+ /** Serializes a multisig operation for storage. */
140
+ function serialize(operation: MultisigOperation.Operation): string {
141
+ try {
142
+ const operation_ = MultisigOperation.from(operation)
143
+ assertHash(operation_)
144
+ const value = Json.stringify(operation_)
145
+ if (value.length > maxStoredValueLength) throw new InvalidStoreValueError()
146
+ return value
147
+ } catch (cause) {
148
+ if (cause instanceof InvalidStoreValueError) throw cause
149
+ throw new InvalidStoreValueError({ cause })
150
+ }
151
+ }
152
+
153
+ /** Verifies that the operation hash commits to its stored payload. */
154
+ function assertHash(operation: MultisigOperation.Operation) {
155
+ const hash = MultisigOperation.getHash(
156
+ operation.type === 'transaction'
157
+ ? {
158
+ account: operation.account,
159
+ config: operation.config,
160
+ transaction: operation.transaction,
161
+ type: operation.type,
162
+ }
163
+ : {
164
+ account: operation.account,
165
+ config: operation.config,
166
+ keyAuthorization: operation.keyAuthorization,
167
+ type: operation.type,
168
+ },
169
+ )
170
+ if (hash.toLowerCase() !== operation.hash.toLowerCase())
171
+ throw new InvalidStoreValueError()
172
+ }
173
+
174
+ /** Returns the store key for an operation hash. */
175
+ function operationKey(hash: Hex.Hex) {
176
+ return `multisig:operation:${hash.toLowerCase()}`
177
+ }
178
+
179
+ /** Returns the store key for a submission attempt. */
180
+ function submissionKey(hash: Hex.Hex, submissionId: Hex.Hex) {
181
+ return `multisig:submission:${hash.toLowerCase()}:${submissionId.toLowerCase()}`
182
+ }
183
+
184
+ /** Thrown when a stored multisig operation is malformed or unsupported. */
185
+ export class InvalidStoreValueError extends BaseError {
186
+ /** Creates an invalid store value error. */
187
+ constructor(options: InvalidStoreValueError.Options = {}) {
188
+ super('Stored multisig operation is malformed or unsupported.', {
189
+ cause: options.cause as Error | undefined,
190
+ name: 'Multisig.Operation.InvalidStoreValueError',
191
+ })
192
+ }
193
+ }
194
+
195
+ export declare namespace InvalidStoreValueError {
196
+ /** Error construction options. */
197
+ export type Options = {
198
+ /** Underlying error. */
199
+ cause?: unknown | undefined
200
+ }
201
+ }
202
+
203
+ /** Thrown when a multisig operation cannot be updated due to contention. */
204
+ export class StoreConflictError extends BaseError {
205
+ /** Creates a store conflict error. */
206
+ constructor() {
207
+ super('Multisig operation could not be updated after repeated conflicts.', {
208
+ name: 'Multisig.Operation.StoreConflictError',
209
+ })
210
+ }
211
+ }
package/types/chain.ts CHANGED
@@ -250,8 +250,22 @@ export type ChainSerializers<
250
250
  transaction?:
251
251
  | SerializeTransactionFn<transaction, TransactionSerializedGeneric>
252
252
  | undefined
253
+ /** Modifies how signed Transactions are serialized into an envelope. */
254
+ transactionEnvelope?: ChainTransactionEnvelopeFn<transaction> | undefined
253
255
  }
254
256
 
257
+ // Method extraction preserves assignability between generic Chain variants.
258
+ type ChainTransactionEnvelopeFn<
259
+ transaction extends TransactionSerializableGeneric,
260
+ > = {
261
+ fn(parameters: {
262
+ /** Serialized signed transaction. */
263
+ serializedTransaction: TransactionSerializedGeneric
264
+ /** Transaction before envelope serialization. */
265
+ transaction: transaction
266
+ }): TransactionSerializedGeneric | Promise<TransactionSerializedGeneric>
267
+ }['fn']
268
+
255
269
  /////////////////////////////////////////////////////////////////////
256
270
  // Utils
257
271
  /////////////////////////////////////////////////////////////////////
@@ -137,7 +137,7 @@ export function hexToBigInt(hex: Hex, opts: HexToBigIntOpts = {}): bigint {
137
137
  const value = BigInt(hex)
138
138
  if (!signed) return value
139
139
 
140
- const size = (hex.length - 2) / 2
140
+ const size = Math.ceil((hex.length - 2) / 2)
141
141
  const max = (1n << (BigInt(size) * 8n - 1n)) - 1n
142
142
  if (value <= max) return value
143
143
 
@@ -1,10 +1,9 @@
1
1
  import type { ErrorType } from '../../errors/utils.js'
2
2
  import type { Hex } from '../../types/misc.js'
3
3
  import { type IsHexErrorType, isHex } from '../data/isHex.js'
4
- import { type SizeErrorType, size } from '../data/size.js'
5
4
 
6
- export type IsHashErrorType = IsHexErrorType | SizeErrorType | ErrorType
5
+ export type IsHashErrorType = IsHexErrorType | ErrorType
7
6
 
8
7
  export function isHash(hash: string): hash is Hex {
9
- return isHex(hash) && size(hash) === 32
8
+ return isHex(hash) && hash.length === 66
10
9
  }
@@ -1 +0,0 @@
1
- {"version":3,"file":"Storage.js","sourceRoot":"","sources":["../../tempo/Storage.ts"],"names":[],"mappings":";;AAsBA,oBA0BC;AAUD,wBAgBC;AAGD,0BAiBC;AAaD,wCAOC;AA5FD,SAAgB,IAAI,CAAC,OAAgB,EAAE,UAAwB,EAAE;IAC/D,MAAM,EAAE,GAAG,EAAE,GAAG,OAAO,CAAA;IACvB,MAAM,MAAM,GAAG,GAAG,CAAC,CAAC,CAAC,GAAG,GAAG,GAAG,CAAC,CAAC,CAAC,EAAE,CAAA;IACnC,MAAM,QAAQ,GAAG,IAAI,GAAG,EAA8C,CAAA;IACtE,OAAO;QACL,OAAO,CAAC,CAAC;YACP,MAAM,OAAO,GAAG,GAAG,MAAM,GAAG,CAAC,EAAE,CAAA;YAC/B,MAAM,QAAQ,GAAG,QAAQ,CAAC,GAAG,CAAC,OAAO,CAAC,CAAA;YACtC,IAAI,QAAQ;gBAAE,OAAO,QAAQ,CAAA;YAC7B,MAAM,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,OAAO,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c,CAAC,OAAO,CAAC,GAAG,CAAC,CAAA;QAC/C,CAAC;QACD,OAAO,CAAC,GAAG,EAAE,KAAK;YAChB,IAAI,CAAC;gBACH,UAAU,CAAC,cAAc,CAAC,OAAO,CAAC,GAAG,EAAE,KAAK,CAAC,CAAA;YAC/C,CAAC;YAAC,MAAM,CAAC,CAAA,CAAC;QACZ,CAAC;QACD,UAAU,CAAC,GAAG;YACZ,UAAU,CAAC,cAAc,CAAC,UAAU,CAAC,GAAG,CAAC,CAAA;QAC3C,CAAC;KACF,EACD,OAAO,CACR,CAAA;AACH,CAAC;AAED,IAAI,QAA6B,CAAA;AAWjC,SAAgB,cAAc;IAC5B,IAAI,QAAQ;QAAE,OAAO,QAAQ,CAAA;IAC7B,IAAI,CAAC;QACH,IAAI,UAAU,CAAC,cAAc;YAAE,QAAQ,GAAG,OAAO,EAAE,CAAA;IACrD,CAAC;IAAC,MAAM,CAAC,CAAA,CAAC;IACV,QAAQ,KAAK,MAAM,EAAE,CAAA;IACrB,OAAO,QAAQ,CAAA;AACjB,CAAC"}
@@ -1,56 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.createMultisigStateResolver = createMultisigStateResolver;
4
- exports.getMultisigOwnerStates = getMultisigOwnerStates;
5
- const base_js_1 = require("../../errors/base.js");
6
- const contract_js_1 = require("../../errors/contract.js");
7
- function createMultisigStateResolver(getConfig) {
8
- const cache = new Map();
9
- return (account) => {
10
- const address = account.toLowerCase();
11
- const cached = cache.get(address);
12
- if (cached)
13
- return cached;
14
- const state = (async () => {
15
- try {
16
- const config = await getConfig(account);
17
- return {
18
- account,
19
- config: { owners: config.owners, threshold: config.threshold },
20
- initialized: true,
21
- version: config.version,
22
- };
23
- }
24
- catch (error) {
25
- const cause = error instanceof base_js_1.BaseError
26
- ? error.walk((error) => error instanceof contract_js_1.ContractFunctionRevertedError)
27
- : undefined;
28
- if (!(cause instanceof contract_js_1.ContractFunctionRevertedError) ||
29
- cause.data?.errorName !== 'NotMultisigAccount')
30
- throw error;
31
- return { account, initialized: false, version: 0n };
32
- }
33
- })();
34
- cache.set(address, state);
35
- return state;
36
- };
37
- }
38
- function getMultisigOwnerStates(account, getState) {
39
- const owners = [account];
40
- const seen = new Set([account.address.toLowerCase()]);
41
- const visit = (account) => {
42
- for (const owner of account.owners) {
43
- if (owner.source !== 'multisig')
44
- continue;
45
- const address = owner.address.toLowerCase();
46
- if (seen.has(address))
47
- continue;
48
- seen.add(address);
49
- owners.push(owner);
50
- visit(owner);
51
- }
52
- };
53
- visit(account);
54
- return Promise.all(owners.map((owner) => getState(owner.address)));
55
- }
56
- //# sourceMappingURL=multisig.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"multisig.js","sourceRoot":"","sources":["../../../tempo/internal/multisig.ts"],"names":[],"mappings":";;AAQA,kEAyCC;AAGD,wDAmBC;AArED,kDAAgD;AAChD,0DAAwE;AAKxE,SAAgB,2BAA2B,CACzC,SAIE;IAGF,MAAM,KAAK,GAAG,IAAI,GAAG,EAAwC,CAAA;IAC7D,OAAO,CAAC,OAAgB,EAA+B,EAAE;QACvD,MAAM,OAAO,GAAG,OAAO,CAAC,WAAW,EAAa,CAAA;QAChD,MAAM,MAAM,GAAG,KAAK,CAAC,GAAG,CAAC,OAAO,CAAC,CAAA;QACjC,IAAI,MAAM;YAAE,OAAO,MAAM,CAAA;QAEzB,MAAM,KAAK,GAAG,CAAC,KAAK,IAAI,EAAE;YACxB,IAAI,CAAC;gBACH,MAAM,MAAM,GAAG,MAAM,SAAS,CAAC,OAAO,CAAC,CAAA;gBACvC,OAAO;oBACL,OAAO;oBACP,MAAM,EAAE,EAAE,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,SAAS,EAAE,MAAM,CAAC,SAAS,EAAE;oBAC9D,WAAW,EAAE,IAAI;oBACjB,OAAO,EAAE,MAAM,CAAC,OAAO;iBACxB,CAAA;YACH,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBACf,MAAM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AAM,UAAU,cAAc;IAC5B,IAAI,QAAQ;QAAE,OAAO,QAAQ,CAAA;IAC7B,IAAI,CAAC;QACH,IAAI,UAAU,CAAC,cAAc;YAAE,QAAQ,GAAG,OAAO,EAAE,CAAA;IACrD,CAAC;IAAC,MAAM,CAAC,CAAA,CAAC;IACV,QAAQ,KAAK,MAAM,EAAE,CAAA;IACrB,OAAO,QAAQ,CAAA;AACjB,CAAC"}
@@ -1,56 +0,0 @@
1
- import { BaseError } from '../../errors/base.js';
2
- import { ContractFunctionRevertedError } from '../../errors/contract.js';
3
- /** @internal */
4
- export function createMultisigStateResolver(getConfig) {
5
- // Cache only within one operation because config versions can change between requests.
6
- const cache = new Map();
7
- return (account) => {
8
- const address = account.toLowerCase();
9
- const cached = cache.get(address);
10
- if (cached)
11
- return cached;
12
- const state = (async () => {
13
- try {
14
- const config = await getConfig(account);
15
- return {
16
- account,
17
- config: { owners: config.owners, threshold: config.threshold },
18
- initialized: true,
19
- version: config.version,
20
- };
21
- }
22
- catch (error) {
23
- const cause = error instanceof BaseError
24
- ? error.walk((error) => error instanceof ContractFunctionRevertedError)
25
- : undefined;
26
- if (!(cause instanceof ContractFunctionRevertedError) ||
27
- cause.data?.errorName !== 'NotMultisigAccount')
28
- throw error;
29
- return { account, initialized: false, version: 0n };
30
- }
31
- })();
32
- cache.set(address, state);
33
- return state;
34
- };
35
- }
36
- /** @internal */
37
- export function getMultisigOwnerStates(account, getState) {
38
- // Collect locally first so all config reads start in one latency wave.
39
- const owners = [account];
40
- const seen = new Set([account.address.toLowerCase()]);
41
- const visit = (account) => {
42
- for (const owner of account.owners) {
43
- if (owner.source !== 'multisig')
44
- continue;
45
- const address = owner.address.toLowerCase();
46
- if (seen.has(address))
47
- continue;
48
- seen.add(address);
49
- owners.push(owner);
50
- visit(owner);
51
- }
52
- };
53
- visit(account);
54
- return Promise.all(owners.map((owner) => getState(owner.address)));
55
- }
56
- //# sourceMappingURL=multisig.js.map
@@ -1 +0,0 @@
1
- {"version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,CAAA;YACrD,CAAC;QACH,CAAC,CAAC,EAAE,CAAA;QACJ,KAAK,CAAC,GAAG,CAAC,OAAO,EAAE,KAAK,CAAC,CAAA;QACzB,OAAO,KAAK,CAAA;IACd,CAAC,CAAA;AACH,CAAC;AAED,gBAAgB;AAChB,MAAM,UAAU,sBAAsB,CACpC,OAAwB,EACxB,QAA2D;IAE3D,uEAAuE;IACvE,MAAM,MAAM,GAAsB,CAAC,OAAO,CAAC,CAAA;IAC3C,MAAM,IAAI,GAAG,IAAI,GAAG,CAAU,CAAC,OAAO,CAAC,OAAO,CAAC,WAAW,EAAa,CAAC,CAAC,CAAA;IACzE,MAAM,KAAK,GAAG,CAAC,OAAwB,EAAE,EAAE;QACzC,KAAK,MAAM,KAAK,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC;YACnC,IAAI,KAAK,CAAC,MAAM,KAAK,UAAU;gBAAE,SAAQ;YACzC,MAAM,OAAO,GAAG,KAAK,CAAC,OAAO,CAAC,WAAW,EAAa,CAAA;YACtD,IAAI,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC;gBAAE,SAAQ;YAC/B,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,CAAA;YACjB,MAAM,CAAC,IAAI,CAAC,KAAwB,CAAC,CAAA;YACrC,KAAK,CAAC,KAAwB,CAAC,CAAA;QACjC,CAAC;IACH,CAAC,CAAA;IACD,KAAK,CAAC,OAAO,CAAC,CAAA;IACd,OAAO,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,QAAQ,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,CAAA;AACpE,CAAC"}
@@ -1,42 +0,0 @@
1
- import type { MaybePromise } from '../types/utils.js';
2
- export type Storage = {
3
- getItem(key: string): MaybePromise<string | null | undefined>;
4
- setItem(key: string, value: string): MaybePromise<void>;
5
- removeItem(key: string): MaybePromise<void>;
6
- };
7
- /**
8
- * Wraps a base storage with an optional key prefix and request
9
- * deduplication — concurrent `getItem` calls for the same key share
10
- * a single in-flight promise.
11
- *
12
- * @example
13
- * ```ts
14
- * import { Storage } from 'viem/tempo'
15
- *
16
- * const storage = Storage.from(Storage.memory(), { key: 'tempo' })
17
- * await storage.setItem('foo', 'bar')
18
- * // stored under "tempo:foo"
19
- * ```
20
- */
21
- export declare function from(storage: Storage, options?: from.Options): Storage;
22
- export declare namespace from {
23
- type Options = {
24
- /** Key prefix prepended to all storage keys. */
25
- key?: string | undefined;
26
- };
27
- }
28
- /** Creates an in-memory storage backed by a `Map`. */
29
- export declare function memory(options?: from.Options): Storage;
30
- /** Creates a storage backed by `globalThis.sessionStorage`. */
31
- export declare function session(options?: from.Options): Storage;
32
- /**
33
- * Returns the default storage for the current environment.
34
- *
35
- * Returns a singleton so that the zone transport and actions share the
36
- * same instance without requiring explicit plumbing.
37
- *
38
- * - Browser: `sessionStorage`
39
- * - Server/unsupported: in-memory `Map`-based storage
40
- */
41
- export declare function defaultStorage(): Storage;
42
- //# sourceMappingURL=Storage.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"Storage.d.ts","sourceRoot":"","sources":["../../tempo/Storage.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAA;AAErD,MAAM,MAAM,OAAO,GAAG;IACpB,OAAO,CAAC,GAAG,EAAE,MAAM,GAAG,YAAY,CAAC,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC,CAAA;IAC7D,OAAO,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,YAAY,CAAC,IAAI,CAAC,CAAA;IACvD,UAAU,CAAC,GAAG,EAAE,MAAM,GAAG,YAAY,CAAC,IAAI,CAAC,CAAA;CAC5C,CAAA;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,IAAI,CAAC,OAAO,EAAE,OAAO,EAAE,OAAO,GAAE,IAAI,CAAC,OAAY,GAAG,OAAO,CA0B1E;AAED,MAAM,CAAC,OAAO,WAAW,IAAI,CAAC;IAC5B,KAAK,OAAO,GAAG;QACb,gDAAgD;QAChD,GAAG,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;KACzB,CAAA;CACF;AAED,sDAAsD;AACtD,wBAAgB,MAAM,CAAC,OAAO,GAAE,IAAI,CAAC,OAAY,GAAG,OAAO,CAgB1D;AAED,+DAA+D;AAC/D,wBAAgB,OAAO,CAAC,OAAO,GAAE,IAAI,CAAC,OAAY,GAAG,OAAO,CAiB3D;AAID;;;;;;;;GAQG;AACH,wBAAgB,cAAc,IAAI,OAAO,CAOxC"}
@@ -1,13 +0,0 @@
1
- import type { Address } from 'abitype';
2
- import type { MultisigConfig } from 'ox/tempo';
3
- import type { MultisigAccount } from '../Account.js';
4
- import type { MultisigOwnerState } from '../Transaction.js';
5
- /** @internal */
6
- export declare function createMultisigStateResolver(getConfig: (account: Address) => Promise<{
7
- owners: MultisigConfig.Config['owners'];
8
- threshold: MultisigConfig.Config['threshold'];
9
- version: bigint;
10
- }>): (account: Address) => Promise<MultisigOwnerState>;
11
- /** @internal */
12
- export declare function getMultisigOwnerStates(account: MultisigAccount, getState: (account: Address) => Promise<MultisigOwnerState>): Promise<readonly MultisigOwnerState[]>;
13
- //# sourceMappingURL=multisig.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"multisig.d.ts","sourceRoot":"","sources":["../../../tempo/internal/multisig.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,SAAS,CAAA;AACtC,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,UAAU,CAAA;AAG9C,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,eAAe,CAAA;AACpD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAA;AAE3D,gBAAgB;AAChB,wBAAgB,2BAA2B,CACzC,SAAS,EAAE,CAAC,OAAO,EAAE,OAAO,KAAK,OAAO,CAAC;IACvC,MAAM,EAAE,cAAc,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAA;IACvC,SAAS,EAAE,cAAc,CAAC,MAAM,CAAC,WAAW,CAAC,CAAA;IAC7C,OAAO,EAAE,MAAM,CAAA;CAChB,CAAC,IAIM,SAAS,OAAO,KAAG,OAAO,CAAC,kBAAkB,CAAC,CAgCvD;AAED,gBAAgB;AAChB,wBAAgB,sBAAsB,CACpC,OAAO,EAAE,eAAe,EACxB,QAAQ,EAAE,CAAC,OAAO,EAAE,OAAO,KAAK,OAAO,CAAC,kBAAkB,CAAC,GAC1D,OAAO,CAAC,SAAS,kBAAkB,EAAE,CAAC,CAgBxC"}