viem 2.52.0 → 2.53.1

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 (149) hide show
  1. package/CHANGELOG.md +44 -0
  2. package/_cjs/account-abstraction/actions/bundler/estimateUserOperationGas.js +2 -0
  3. package/_cjs/account-abstraction/actions/bundler/estimateUserOperationGas.js.map +1 -1
  4. package/_cjs/actions/wallet/prepareTransactionRequest.js.map +1 -1
  5. package/_cjs/chains/definitions/citrate.js +17 -0
  6. package/_cjs/chains/definitions/citrate.js.map +1 -0
  7. package/_cjs/chains/definitions/grav.js +24 -0
  8. package/_cjs/chains/definitions/grav.js.map +1 -0
  9. package/_cjs/chains/definitions/ladyChain.js +22 -0
  10. package/_cjs/chains/definitions/ladyChain.js.map +1 -0
  11. package/_cjs/chains/definitions/monad.js +5 -5
  12. package/_cjs/chains/definitions/monad.js.map +1 -1
  13. package/_cjs/chains/definitions/tempoModerato.js +1 -0
  14. package/_cjs/chains/definitions/tempoModerato.js.map +1 -1
  15. package/_cjs/chains/definitions/valygoNft.js +37 -0
  16. package/_cjs/chains/definitions/valygoNft.js.map +1 -0
  17. package/_cjs/chains/definitions/valygoSmartchain.js +37 -0
  18. package/_cjs/chains/definitions/valygoSmartchain.js.map +1 -0
  19. package/_cjs/chains/definitions/whitechainSepolia.js +31 -0
  20. package/_cjs/chains/definitions/whitechainSepolia.js.map +1 -0
  21. package/_cjs/chains/index.js +25 -13
  22. package/_cjs/chains/index.js.map +1 -1
  23. package/_cjs/errors/version.js +1 -1
  24. package/_cjs/tempo/Abis.js +1866 -1866
  25. package/_cjs/tempo/Abis.js.map +1 -1
  26. package/_cjs/tempo/Account.js +35 -3
  27. package/_cjs/tempo/Account.js.map +1 -1
  28. package/_cjs/tempo/Client.js +27 -0
  29. package/_cjs/tempo/Client.js.map +1 -0
  30. package/_cjs/tempo/Formatters.js +2 -1
  31. package/_cjs/tempo/Formatters.js.map +1 -1
  32. package/_cjs/tempo/Scopes.js +39 -0
  33. package/_cjs/tempo/Scopes.js.map +1 -0
  34. package/_cjs/tempo/Selectors.js +226 -0
  35. package/_cjs/tempo/Selectors.js.map +1 -0
  36. package/_cjs/tempo/Transaction.js +22 -0
  37. package/_cjs/tempo/Transaction.js.map +1 -1
  38. package/_cjs/tempo/chainConfig.js +10 -0
  39. package/_cjs/tempo/chainConfig.js.map +1 -1
  40. package/_cjs/tempo/index.js +14 -1
  41. package/_cjs/tempo/index.js.map +1 -1
  42. package/_esm/account-abstraction/actions/bundler/estimateUserOperationGas.js +2 -0
  43. package/_esm/account-abstraction/actions/bundler/estimateUserOperationGas.js.map +1 -1
  44. package/_esm/actions/wallet/prepareTransactionRequest.js.map +1 -1
  45. package/_esm/chains/definitions/citrate.js +14 -0
  46. package/_esm/chains/definitions/citrate.js.map +1 -0
  47. package/_esm/chains/definitions/grav.js +21 -0
  48. package/_esm/chains/definitions/grav.js.map +1 -0
  49. package/_esm/chains/definitions/ladyChain.js +19 -0
  50. package/_esm/chains/definitions/ladyChain.js.map +1 -0
  51. package/_esm/chains/definitions/monad.js +5 -5
  52. package/_esm/chains/definitions/monad.js.map +1 -1
  53. package/_esm/chains/definitions/tempoModerato.js +1 -0
  54. package/_esm/chains/definitions/tempoModerato.js.map +1 -1
  55. package/_esm/chains/definitions/valygoNft.js +34 -0
  56. package/_esm/chains/definitions/valygoNft.js.map +1 -0
  57. package/_esm/chains/definitions/valygoSmartchain.js +34 -0
  58. package/_esm/chains/definitions/valygoSmartchain.js.map +1 -0
  59. package/_esm/chains/definitions/whitechainSepolia.js +28 -0
  60. package/_esm/chains/definitions/whitechainSepolia.js.map +1 -0
  61. package/_esm/chains/index.js +6 -0
  62. package/_esm/chains/index.js.map +1 -1
  63. package/_esm/errors/version.js +1 -1
  64. package/_esm/tempo/Abis.js +1865 -1865
  65. package/_esm/tempo/Abis.js.map +1 -1
  66. package/_esm/tempo/Account.js +81 -4
  67. package/_esm/tempo/Account.js.map +1 -1
  68. package/_esm/tempo/Client.js +66 -0
  69. package/_esm/tempo/Client.js.map +1 -0
  70. package/_esm/tempo/Formatters.js +5 -1
  71. package/_esm/tempo/Formatters.js.map +1 -1
  72. package/_esm/tempo/Scopes.js +49 -0
  73. package/_esm/tempo/Scopes.js.map +1 -0
  74. package/_esm/tempo/Selectors.js +224 -0
  75. package/_esm/tempo/Selectors.js.map +1 -0
  76. package/_esm/tempo/Transaction.js +34 -0
  77. package/_esm/tempo/Transaction.js.map +1 -1
  78. package/_esm/tempo/chainConfig.js +24 -1
  79. package/_esm/tempo/chainConfig.js.map +1 -1
  80. package/_esm/tempo/index.js +10 -1
  81. package/_esm/tempo/index.js.map +1 -1
  82. package/_types/account-abstraction/actions/bundler/estimateUserOperationGas.d.ts.map +1 -1
  83. package/_types/actions/wallet/prepareTransactionRequest.d.ts +12 -1
  84. package/_types/actions/wallet/prepareTransactionRequest.d.ts.map +1 -1
  85. package/_types/chains/definitions/citrate.d.ts +57 -0
  86. package/_types/chains/definitions/citrate.d.ts.map +1 -0
  87. package/_types/chains/definitions/grav.d.ts +43 -0
  88. package/_types/chains/definitions/grav.d.ts.map +1 -0
  89. package/_types/chains/definitions/ladyChain.d.ts +50 -0
  90. package/_types/chains/definitions/ladyChain.d.ts.map +1 -0
  91. package/_types/chains/definitions/monad.d.ts +5 -5
  92. package/_types/chains/definitions/tempo.d.ts +36 -0
  93. package/_types/chains/definitions/tempo.d.ts.map +1 -1
  94. package/_types/chains/definitions/tempoDevnet.d.ts +36 -0
  95. package/_types/chains/definitions/tempoDevnet.d.ts.map +1 -1
  96. package/_types/chains/definitions/tempoLocalnet.d.ts +36 -0
  97. package/_types/chains/definitions/tempoLocalnet.d.ts.map +1 -1
  98. package/_types/chains/definitions/tempoModerato.d.ts +38 -0
  99. package/_types/chains/definitions/tempoModerato.d.ts.map +1 -1
  100. package/_types/chains/definitions/valygoNft.d.ts +48 -0
  101. package/_types/chains/definitions/valygoNft.d.ts.map +1 -0
  102. package/_types/chains/definitions/valygoSmartchain.d.ts +48 -0
  103. package/_types/chains/definitions/valygoSmartchain.d.ts.map +1 -0
  104. package/_types/chains/definitions/whitechainSepolia.d.ts +46 -0
  105. package/_types/chains/definitions/whitechainSepolia.d.ts.map +1 -0
  106. package/_types/chains/index.d.ts +6 -0
  107. package/_types/chains/index.d.ts.map +1 -1
  108. package/_types/errors/version.d.ts +1 -1
  109. package/_types/tempo/Abis.d.ts +5816 -5816
  110. package/_types/tempo/Abis.d.ts.map +1 -1
  111. package/_types/tempo/Account.d.ts +48 -1
  112. package/_types/tempo/Account.d.ts.map +1 -1
  113. package/_types/tempo/Client.d.ts +98 -0
  114. package/_types/tempo/Client.d.ts.map +1 -0
  115. package/_types/tempo/Formatters.d.ts.map +1 -1
  116. package/_types/tempo/Scopes.d.ts +48 -0
  117. package/_types/tempo/Scopes.d.ts.map +1 -0
  118. package/_types/tempo/Selectors.d.ts +223 -0
  119. package/_types/tempo/Selectors.d.ts.map +1 -0
  120. package/_types/tempo/Transaction.d.ts +5 -1
  121. package/_types/tempo/Transaction.d.ts.map +1 -1
  122. package/_types/tempo/chainConfig.d.ts +34 -15
  123. package/_types/tempo/chainConfig.d.ts.map +1 -1
  124. package/_types/tempo/index.d.ts +10 -1
  125. package/_types/tempo/index.d.ts.map +1 -1
  126. package/_types/tempo/zones/zone.d.ts +108 -0
  127. package/_types/tempo/zones/zone.d.ts.map +1 -1
  128. package/account-abstraction/actions/bundler/estimateUserOperationGas.ts +2 -0
  129. package/actions/wallet/prepareTransactionRequest.ts +40 -5
  130. package/chains/definitions/citrate.ts +14 -0
  131. package/chains/definitions/grav.ts +21 -0
  132. package/chains/definitions/ladyChain.ts +19 -0
  133. package/chains/definitions/monad.ts +5 -5
  134. package/chains/definitions/tempoModerato.ts +1 -0
  135. package/chains/definitions/valygoNft.ts +34 -0
  136. package/chains/definitions/valygoSmartchain.ts +34 -0
  137. package/chains/definitions/whitechainSepolia.ts +28 -0
  138. package/chains/index.ts +6 -0
  139. package/errors/version.ts +1 -1
  140. package/package.json +3 -4
  141. package/tempo/Abis.ts +1869 -1869
  142. package/tempo/Account.ts +97 -4
  143. package/tempo/Client.ts +172 -0
  144. package/tempo/Formatters.ts +12 -1
  145. package/tempo/Scopes.ts +124 -0
  146. package/tempo/Selectors.ts +260 -0
  147. package/tempo/Transaction.ts +42 -0
  148. package/tempo/chainConfig.ts +32 -3
  149. package/tempo/index.ts +35 -0
package/tempo/Account.ts CHANGED
@@ -4,7 +4,12 @@ import * as P256 from 'ox/P256'
4
4
  import * as PublicKey from 'ox/PublicKey'
5
5
  import * as Secp256k1 from 'ox/Secp256k1'
6
6
  import * as Signature from 'ox/Signature'
7
- import { Channel, KeyAuthorization, SignatureEnvelope } from 'ox/tempo'
7
+ import {
8
+ Channel,
9
+ KeyAuthorization,
10
+ MultisigConfig,
11
+ SignatureEnvelope,
12
+ } from 'ox/tempo'
8
13
  import * as WebAuthnP256 from 'ox/WebAuthnP256'
9
14
  import * as WebCryptoP256 from 'ox/WebCryptoP256'
10
15
  import type {
@@ -269,6 +274,78 @@ export declare namespace fromSecp256k1 {
269
274
  from.ReturnValue<options>
270
275
  }
271
276
 
277
+ /**
278
+ * Instantiates a synthetic Account for a native multisig (TIP-1061) config.
279
+ *
280
+ * The returned account does not hold a key. It is used purely to drive the
281
+ * standard `sendTransaction` flow: it derives the multisig address from the
282
+ * config and passes the prepared request (carrying the collected owner
283
+ * `signatures`) through to the chain serializer, which combines the approvals
284
+ * into the multisig signature envelope.
285
+ *
286
+ * Owner approvals are produced separately by signing with `multisig` request
287
+ * metadata (see `signTransaction`), and provided here via `signatures`.
288
+ *
289
+ * Accepts a raw config and normalizes it internally (via `MultisigConfig.from`),
290
+ * so callers don't need to call `MultisigConfig.from` themselves.
291
+ *
292
+ * @example
293
+ * ```ts
294
+ * import { Account } from 'viem/tempo'
295
+ *
296
+ * const account = Account.fromMultisig({
297
+ * threshold: 2,
298
+ * owners: [
299
+ * { owner: owner_1.address, weight: 1 },
300
+ * { owner: owner_2.address, weight: 1 },
301
+ * ],
302
+ * })
303
+ *
304
+ * // Pass the account to `prepareTransactionRequest` — the multisig config is
305
+ * // inferred from it, so no `multisig` field is needed.
306
+ * const request = await client.prepareTransactionRequest({ account, ...rest })
307
+ *
308
+ * // The prepared request carries the multisig account as sender, so it doesn't
309
+ * // need to be re-passed to `sendTransaction`.
310
+ * const transaction = await client.sendTransaction({
311
+ * ...request,
312
+ * signatures: [signature_1, signature_2],
313
+ * })
314
+ * ```
315
+ *
316
+ * @param config Multisig config (raw or from `MultisigConfig.from`).
317
+ * @returns Multisig account.
318
+ */
319
+ export function fromMultisig(config: MultisigConfig.Config): MultisigAccount {
320
+ const normalized = MultisigConfig.from(config)
321
+ const address = Address.checksum(MultisigConfig.getAddress(normalized))
322
+ return {
323
+ address,
324
+ config: normalized,
325
+ publicKey: '0x',
326
+ source: 'multisig',
327
+ type: 'local',
328
+ async sign() {
329
+ throw new Error('`sign` is not supported for multisig accounts.')
330
+ },
331
+ async signMessage() {
332
+ throw new Error('`signMessage` is not supported for multisig accounts.')
333
+ },
334
+ async signTransaction(transaction, options) {
335
+ const { serializer = Transaction.serialize } = options ?? {}
336
+ return (await serializer(transaction as never)) as Hex.Hex
337
+ },
338
+ async signTypedData() {
339
+ throw new Error('`signTypedData` is not supported for multisig accounts.')
340
+ },
341
+ }
342
+ }
343
+
344
+ export type MultisigAccount = LocalAccount<'multisig'> & {
345
+ /** Multisig config (from `MultisigConfig.from`). */
346
+ config: MultisigConfig.Config
347
+ }
348
+
272
349
  /**
273
350
  * Instantiates an Account from a WebAuthn credential.
274
351
  *
@@ -594,9 +671,25 @@ function fromBase(parameters: fromBase.Parameters): Account_base {
594
671
  return { ...transaction, feePayerSignature: null }
595
672
  return transaction
596
673
  })()
597
- const signature = await sign({
598
- hash: keccak256(await serializer(presign)),
599
- })
674
+
675
+ const payload = keccak256(await serializer(presign))
676
+
677
+ // Native multisig (TIP-1061): return this owner's approval — a serialized
678
+ // primitive signature over the multisig owner approval digest — instead of
679
+ // a full serialized transaction. Approvals are combined later in
680
+ // `sendTransaction({ signatures })`.
681
+ const multisig = (
682
+ transaction as { multisig?: MultisigConfig.Config | undefined }
683
+ ).multisig
684
+ if (multisig) {
685
+ const digest = MultisigConfig.getSignPayload({
686
+ payload,
687
+ genesisConfig: multisig,
688
+ })
689
+ return await sign({ hash: digest, raw: true })
690
+ }
691
+
692
+ const signature = await sign({ hash: payload })
600
693
  const envelope = SignatureEnvelope.from(signature)
601
694
  return await serializer(transaction, envelope as never)
602
695
  },
@@ -0,0 +1,172 @@
1
+ import type { Address } from 'abitype'
2
+ import type { TokenId } from 'ox/tempo'
3
+
4
+ import type { JsonRpcAccount } from '../accounts/types.js'
5
+ import {
6
+ type Client as Client_,
7
+ type ClientConfig as ClientConfig_,
8
+ createClient as createClient_,
9
+ } from '../clients/createClient.js'
10
+ import {
11
+ type PublicActions,
12
+ publicActions,
13
+ } from '../clients/decorators/public.js'
14
+ import {
15
+ type WalletActions,
16
+ walletActions,
17
+ } from '../clients/decorators/wallet.js'
18
+ import type { Transport } from '../clients/transports/createTransport.js'
19
+ import { http } from '../clients/transports/http.js'
20
+ import type { ErrorType } from '../errors/utils.js'
21
+ import type { Account } from '../types/account.js'
22
+ import type { Chain } from '../types/chain.js'
23
+ import type { RpcSchema } from '../types/eip1193.js'
24
+ import type { Prettify } from '../types/utils.js'
25
+ import { tempo, tempoTestnet } from './Chain.js'
26
+ import { type Decorator, decorator as tempoActions } from './Decorator.js'
27
+
28
+ /**
29
+ * Configuration for a Tempo {@link Client}.
30
+ *
31
+ * Extends Viem's {@link ClientConfig} with Tempo-specific defaults: `chain`
32
+ * and `transport` become optional, and a `testnet` flag is added to select
33
+ * the Tempo testnet chain.
34
+ */
35
+ export type ClientConfig<
36
+ transport extends Transport = Transport,
37
+ chain extends Chain | undefined = Chain | undefined,
38
+ accountOrAddress extends Account | Address | undefined =
39
+ | Account
40
+ | Address
41
+ | undefined,
42
+ rpcSchema extends RpcSchema | undefined = undefined,
43
+ > = Prettify<
44
+ Omit<
45
+ ClientConfig_<transport, chain, accountOrAddress, rpcSchema>,
46
+ 'chain' | 'transport'
47
+ > & {
48
+ /**
49
+ * Chain for the Client.
50
+ *
51
+ * @default tempo (or `tempoTestnet` when `testnet` is truthy)
52
+ */
53
+ chain?: chain | Chain | undefined
54
+ /**
55
+ * Default fee token for the Client. Extended onto the chain so it applies
56
+ * to every transaction sent with the Client.
57
+ */
58
+ feeToken?: TokenId.TokenIdOrAddress | undefined
59
+ /**
60
+ * Whether to use the Tempo testnet chain.
61
+ *
62
+ * Ignored when `chain` is provided.
63
+ *
64
+ * @default false
65
+ */
66
+ testnet?: boolean | undefined
67
+ /**
68
+ * The RPC transport.
69
+ *
70
+ * @default http()
71
+ */
72
+ transport?: transport | Transport | undefined
73
+ }
74
+ >
75
+
76
+ /**
77
+ * A Tempo {@link Client}: Viem's base Client decorated with
78
+ * `publicActions`, `walletActions`, and `tempoActions`.
79
+ */
80
+ export type Client<
81
+ transport extends Transport = Transport,
82
+ chain extends Chain | undefined = Chain | undefined,
83
+ account extends Account | undefined = Account | undefined,
84
+ rpcSchema extends RpcSchema | undefined = undefined,
85
+ > = Prettify<
86
+ Client_<
87
+ transport,
88
+ chain,
89
+ account,
90
+ rpcSchema,
91
+ PublicActions<transport, chain, account> &
92
+ WalletActions<chain, account> &
93
+ Decorator<chain, account>
94
+ >
95
+ >
96
+
97
+ export type CreateClientErrorType = ErrorType
98
+
99
+ /**
100
+ * Creates a Tempo {@link Client}: an extension of Viem's `createClient`
101
+ * decorated with `publicActions`, `walletActions`, and `tempoActions`.
102
+ *
103
+ * Defaults to the `tempo` mainnet chain and `http` transport, so a minimal
104
+ * client can be created with `createClient()`. Pass `testnet` to use the
105
+ * Tempo testnet, or `chain` to override the chain entirely. Pass `feeToken`
106
+ * to set a default fee token for every transaction.
107
+ *
108
+ * @example
109
+ * ```ts
110
+ * import { createClient } from 'viem/tempo'
111
+ *
112
+ * // Minimal client (tempo mainnet, http transport).
113
+ * const client = createClient()
114
+ * ```
115
+ *
116
+ * @example
117
+ * ```ts
118
+ * import { Account, createClient, http } from 'viem/tempo'
119
+ *
120
+ * // Testnet client with an account and custom transport.
121
+ * const client = createClient({
122
+ * account: Account.fromSecp256k1('0x...'),
123
+ * testnet: true,
124
+ * transport: http('https://rpc.example.com'),
125
+ * })
126
+ * ```
127
+ *
128
+ * @example
129
+ * ```ts
130
+ * import { createClient } from 'viem/tempo'
131
+ *
132
+ * // Client with a default fee token.
133
+ * const client = createClient({
134
+ * feeToken: '0x20c0000000000000000000000000000000000001',
135
+ * })
136
+ * ```
137
+ *
138
+ * @param parameters - Parameters.
139
+ * @returns The Tempo Client.
140
+ */
141
+ export function createClient<
142
+ transport extends Transport = Transport,
143
+ chain extends Chain | undefined = typeof tempo,
144
+ accountOrAddress extends Account | Address | undefined = undefined,
145
+ rpcSchema extends RpcSchema | undefined = undefined,
146
+ >(
147
+ parameters: ClientConfig<transport, chain, accountOrAddress, rpcSchema> = {},
148
+ ): Client<
149
+ transport,
150
+ chain,
151
+ accountOrAddress extends Address
152
+ ? Prettify<JsonRpcAccount<accountOrAddress>>
153
+ : accountOrAddress,
154
+ rpcSchema
155
+ > {
156
+ const { chain, feeToken, testnet, transport, ...rest } = parameters
157
+ const baseChain = chain ?? (testnet ? tempoTestnet : tempo)
158
+ const resolvedChain =
159
+ feeToken && typeof (baseChain as { extend?: unknown }).extend === 'function'
160
+ ? (baseChain as { extend: (e: { feeToken: unknown }) => Chain }).extend({
161
+ feeToken,
162
+ })
163
+ : baseChain
164
+ return createClient_({
165
+ ...rest,
166
+ chain: resolvedChain,
167
+ transport: transport ?? http(),
168
+ } as ClientConfig_)
169
+ .extend(publicActions)
170
+ .extend(walletActions)
171
+ .extend(tempoActions()) as never
172
+ }
@@ -79,6 +79,8 @@ export function formatTransactionRequest(
79
79
  keyData?: Hex.Hex | undefined
80
80
  keyId?: Address | undefined
81
81
  keyType?: 'p256' | 'secp256k1' | 'webAuthn' | undefined
82
+ multisig?: unknown
83
+ signatures?: unknown
82
84
  }
83
85
  const account = request.account
84
86
  ? parseAccount<Account | viem_Account | Address>(request.account)
@@ -116,8 +118,17 @@ export function formatTransactionRequest(
116
118
  if (request.feePayer === true && !request.feePayerSignature)
117
119
  delete request.feeToken
118
120
 
121
+ // `multisig` / `signatures` are client-side only (TIP-1061). They drive
122
+ // sender derivation, owner signing, and final envelope assembly, but are
123
+ // never sent as raw RPC fields — the wire payload is the serialized tx.
124
+ const {
125
+ multisig: _multisig,
126
+ signatures: _signatures,
127
+ ...rpcRequest
128
+ } = request
129
+
119
130
  const rpc = ox_TransactionRequest.toRpc({
120
- ...request,
131
+ ...rpcRequest,
121
132
  type: 'tempo',
122
133
  } as never)
123
134
 
@@ -0,0 +1,124 @@
1
+ import type { Address } from 'abitype'
2
+ import type { KeyAuthorization } from 'ox/tempo'
3
+ import * as Selectors from './Selectors.js'
4
+
5
+ export type Selector = NonNullable<KeyAuthorization.Scope['selector']>
6
+
7
+ export type Options = {
8
+ /** Recipient allowlist for selectors that support recipient restrictions. */
9
+ recipients?: readonly Address[] | undefined
10
+ }
11
+
12
+ export type Scope<
13
+ address extends Address = Address,
14
+ selector extends Selector | undefined = Selector | undefined,
15
+ > = Omit<KeyAuthorization.Scope, 'address' | 'recipients' | 'selector'> & {
16
+ address: address
17
+ recipients?: readonly Address[] | undefined
18
+ selector?: selector | undefined
19
+ }
20
+
21
+ export type Target<address extends Address = Address> = {
22
+ /** Allows any selector on the target. */
23
+ any: () => Scope<address, undefined>
24
+ /** Allows calls matching the selector on the target. */
25
+ selector: <selector extends Selector>(
26
+ selector: selector,
27
+ options?: Options | undefined,
28
+ ) => Scope<address, selector>
29
+ }
30
+
31
+ export type SelectorMap = Record<string, Selector | Record<string, Selector>>
32
+
33
+ export type Contract<
34
+ address extends Address = Address,
35
+ selectors extends SelectorMap = SelectorMap,
36
+ > = Target<address> & {
37
+ readonly [name in keyof selectors]: selectors[name] extends Selector
38
+ ? (options?: Options | undefined) => Scope<address, selectors[name]>
39
+ : selectors[name] extends Record<string, Selector>
40
+ ? OverloadedSelector<address, selectors[name]>
41
+ : never
42
+ }
43
+
44
+ export type OverloadedSelector<
45
+ address extends Address = Address,
46
+ selectors extends Record<string, Selector> = Record<string, Selector>,
47
+ > = {
48
+ readonly [signature in keyof selectors]: (
49
+ options?: Options | undefined,
50
+ ) => Scope<address, selectors[signature]>
51
+ } & {
52
+ selector: <signature extends keyof selectors>(
53
+ signature: signature,
54
+ options?: Options | undefined,
55
+ ) => Scope<address, selectors[signature]>
56
+ }
57
+
58
+ export type Tip20<address extends Address = Address> = Contract<
59
+ address,
60
+ typeof Selectors.tip20
61
+ >
62
+
63
+ /**
64
+ * Creates a call scope builder for an arbitrary target.
65
+ *
66
+ * @experimental
67
+ */
68
+ export function target<address extends Address>(
69
+ address: address,
70
+ ): Target<address> {
71
+ return {
72
+ any: () => ({ address }),
73
+ selector: (selector, options) => ({
74
+ address,
75
+ ...(options && 'recipients' in options
76
+ ? { recipients: options.recipients }
77
+ : {}),
78
+ selector,
79
+ }),
80
+ }
81
+ }
82
+
83
+ /**
84
+ * Creates a typed call scope builder from a selector map.
85
+ *
86
+ * @experimental
87
+ */
88
+ export function contract<
89
+ address extends Address,
90
+ selectors extends SelectorMap,
91
+ >(address: address, selectors: selectors): Contract<address, selectors> {
92
+ const target_ = target(address)
93
+ const result: Record<string, unknown> = { ...target_ }
94
+
95
+ for (const [name, selector] of Object.entries(selectors)) {
96
+ if (typeof selector === 'string') {
97
+ result[name] = (options?: Options | undefined) =>
98
+ target_.selector(selector, options)
99
+ continue
100
+ }
101
+
102
+ const overloads: Record<string, unknown> = {}
103
+ for (const [signature, overloadSelector] of Object.entries(selector)) {
104
+ overloads[signature] = (options?: Options | undefined) =>
105
+ target_.selector(overloadSelector, options)
106
+ }
107
+ overloads.selector = (signature: string, options?: Options | undefined) =>
108
+ target_.selector(selector[signature]!, options)
109
+ result[name] = overloads
110
+ }
111
+
112
+ return result as Contract<address, selectors>
113
+ }
114
+
115
+ /**
116
+ * Creates a call scope builder for a TIP-20 token.
117
+ *
118
+ * @experimental
119
+ */
120
+ export function tip20<address extends Address>(
121
+ address: address,
122
+ ): Tip20<address> {
123
+ return contract(address, Selectors.tip20)
124
+ }
@@ -0,0 +1,260 @@
1
+ // Generated with `pnpm gen:abis`. Do not modify manually.
2
+
3
+ import type { Abi, ExtractAbiFunctionNames } from 'abitype'
4
+ import type { Hex } from '../types/misc.js'
5
+ import type * as Abis from './Abis.js'
6
+
7
+ type FunctionSelectors<abi extends Abi, excluded extends string = never> = {
8
+ readonly [name in Exclude<ExtractAbiFunctionNames<abi>, excluded>]: Hex
9
+ }
10
+
11
+ type OverloadedFunctionSelectors<names extends string> = {
12
+ readonly [name in names]: Record<string, Hex>
13
+ }
14
+
15
+ export const accountKeychain = {
16
+ authorizeAdminKey: '0x9a424307',
17
+ authorizeKey: {
18
+ 'authorizeKey(address,uint8,(uint64,bool,(address,uint256,uint64)[],bool,(address,(bytes4,address[])[])[]))':
19
+ '0x980a6025',
20
+ 'authorizeKey(address,uint8,(uint64,bool,(address,uint256,uint64)[],bool,(address,(bytes4,address[])[])[]),bytes32)':
21
+ '0xe3c154d2',
22
+ 'authorizeKey(address,uint8,uint64,bool,(address,uint256)[])': '0x54063a55',
23
+ },
24
+ burnKeyAuthorizationWitness: '0xcff31c46',
25
+ getAllowedCalls: '0x0163e7ec',
26
+ getKey: '0xbc298553',
27
+ getRemainingLimit: '0x63b4290d',
28
+ getRemainingLimitWithPeriod: '0xa7f72cab',
29
+ getTransactionKey: '0xb07fbc1a',
30
+ isAdminKey: '0x9009a18d',
31
+ isKeyAuthorizationWitnessBurned: '0x8e6c7e11',
32
+ removeAllowedCalls: '0xf3941811',
33
+ revokeKey: '0x5ae7ab32',
34
+ setAllowedCalls: '0xf5456703',
35
+ updateSpendingLimit: '0xcbbb4480',
36
+ } as const satisfies FunctionSelectors<
37
+ typeof Abis.accountKeychain,
38
+ 'authorizeKey'
39
+ > &
40
+ OverloadedFunctionSelectors<'authorizeKey'>
41
+
42
+ export const addressRegistry = {
43
+ decodeVirtualAddress: '0xb35d6fb9',
44
+ getMaster: '0xd84ab166',
45
+ isImplicitlyApproved: '0xa8da6aa7',
46
+ isVirtualAddress: '0xd501235a',
47
+ registerVirtualMaster: '0x5c559d20',
48
+ resolveRecipient: '0xfbea9d67',
49
+ resolveVirtualAddress: '0xe2fc56ef',
50
+ } as const satisfies FunctionSelectors<typeof Abis.addressRegistry>
51
+
52
+ export const nonce = {
53
+ getNonce: '0x89535803',
54
+ } as const satisfies FunctionSelectors<typeof Abis.nonce>
55
+
56
+ export const receivePolicyGuard = {
57
+ balanceOf: '0x78415365',
58
+ burnBlockedReceipt: '0x96c1264c',
59
+ claim: '0xbb1757cf',
60
+ } as const satisfies FunctionSelectors<typeof Abis.receivePolicyGuard>
61
+
62
+ export const signatureVerifier = {
63
+ recover: '0x19045a25',
64
+ verify: '0x1a86b550',
65
+ verifyKeychain: '0x6c0c731e',
66
+ verifyKeychainAdmin: '0x5f6fc5b7',
67
+ } as const satisfies FunctionSelectors<typeof Abis.signatureVerifier>
68
+
69
+ export const stablecoinDex = {
70
+ MAX_PRICE: '0x01c11d96',
71
+ MAX_TICK: '0x6882a888',
72
+ MIN_ORDER_AMOUNT: '0x40bf2aa4',
73
+ MIN_PRICE: '0xad9f20a6',
74
+ MIN_TICK: '0xa1634b14',
75
+ PRICE_SCALE: '0xc33f59d3',
76
+ TICK_SPACING: '0x46ca626b',
77
+ balanceOf: '0xf7888aec',
78
+ books: '0x0c0dee70',
79
+ cancel: '0x81649d06',
80
+ cancelStaleOrder: '0x928b0e7f',
81
+ createPair: '0x9ccb0744',
82
+ getOrder: '0x117d4128',
83
+ getTickLevel: '0x949bc662',
84
+ nextOrderId: '0x2a58b330',
85
+ pairKey: '0xcd27ca82',
86
+ place: '0x63813125',
87
+ placeFlip: '0x922828f1',
88
+ priceToTick: '0x87b4e352',
89
+ quoteSwapExactAmountIn: '0xe7c98f1a',
90
+ quoteSwapExactAmountOut: '0x1576fa0e',
91
+ swapExactAmountIn: '0xf8856c0f',
92
+ swapExactAmountOut: '0xf0122b75',
93
+ tickToPrice: '0x269a311d',
94
+ withdraw: '0x08fab167',
95
+ } as const satisfies FunctionSelectors<typeof Abis.stablecoinDex>
96
+
97
+ export const tip20 = {
98
+ BURN_BLOCKED_ROLE: '0x32ad9be8',
99
+ DOMAIN_SEPARATOR: '0x3644e515',
100
+ ISSUER_ROLE: '0x82aefa24',
101
+ PAUSE_ROLE: '0x389ed267',
102
+ UNPAUSE_ROLE: '0x309756fb',
103
+ allowance: '0xdd62ed3e',
104
+ approve: '0x095ea7b3',
105
+ balanceOf: '0x70a08231',
106
+ burn: '0x42966c68',
107
+ burnBlocked: '0xec0cf3dc',
108
+ burnWithMemo: '0x38f23b0b',
109
+ changeTransferPolicyId: '0xfd5e9420',
110
+ claimRewards: '0x372500ab',
111
+ completeQuoteTokenUpdate: '0x638bc4a3',
112
+ currency: '0xe5a6b10f',
113
+ decimals: '0x313ce567',
114
+ distributeReward: '0x940a4e45',
115
+ getPendingRewards: '0xf6ed2017',
116
+ getRoleAdmin: '0x248a9ca3',
117
+ globalRewardPerToken: '0x726ce324',
118
+ grantRole: '0x2f2ff15d',
119
+ hasRole: '0xac4ab3fb',
120
+ logoURI: '0x6bb38b28',
121
+ mint: '0x40c10f19',
122
+ mintWithMemo: '0xe44f0b12',
123
+ name: '0x06fdde03',
124
+ nextQuoteToken: '0x7d0819b7',
125
+ nonces: '0x7ecebe00',
126
+ optedInSupply: '0x8ef39dce',
127
+ pause: '0x8456cb59',
128
+ paused: '0x5c975abb',
129
+ permit: '0xd505accf',
130
+ quoteToken: '0x217a4b70',
131
+ renounceRole: '0x8bb9c5bf',
132
+ revokeRole: '0xd547741f',
133
+ setLogoURI: '0xc30ff6df',
134
+ setNextQuoteToken: '0x4593223f',
135
+ setRewardRecipient: '0xe521136f',
136
+ setRoleAdmin: '0x1e4e0091',
137
+ setSupplyCap: '0xb6a3f59a',
138
+ supplyCap: '0x8f770ad0',
139
+ symbol: '0x95d89b41',
140
+ totalSupply: '0x18160ddd',
141
+ transfer: '0xa9059cbb',
142
+ transferFrom: '0x23b872dd',
143
+ transferFromWithMemo: '0x929c2539',
144
+ transferPolicyId: '0x9c4bad29',
145
+ transferWithMemo: '0x95777d59',
146
+ unpause: '0x3f4ba83a',
147
+ userRewardInfo: '0x360b8ed9',
148
+ } as const satisfies FunctionSelectors<typeof Abis.tip20>
149
+
150
+ export const tip20ChannelReserve = {
151
+ CLOSE_GRACE_PERIOD: '0x956c8327',
152
+ VOUCHER_TYPEHASH: '0x94739e87',
153
+ close: '0x73b57f74',
154
+ computeChannelId: '0x185eeeac',
155
+ domainSeparator: '0xf698da25',
156
+ getChannel: '0xeef95313',
157
+ getChannelState: '0xd18da8b1',
158
+ getChannelStatesBatch: '0xd1f4cda2',
159
+ getVoucherDigest: '0xf3b349e8',
160
+ open: '0xedc53b00',
161
+ requestClose: '0x675402e5',
162
+ settle: '0x97fb5104',
163
+ topUp: '0xdc48471e',
164
+ withdraw: '0x41e2c664',
165
+ } as const satisfies FunctionSelectors<typeof Abis.tip20ChannelReserve>
166
+
167
+ export const tip20Factory = {
168
+ createToken: {
169
+ 'createToken(string,string,string,address,address,bytes32)': '0x68130445',
170
+ 'createToken(string,string,string,address,address,bytes32,string)':
171
+ '0x5323d222',
172
+ },
173
+ getTokenAddress: '0x9ed7cd64',
174
+ isTIP20: '0x35ec42c9',
175
+ } as const satisfies FunctionSelectors<
176
+ typeof Abis.tip20Factory,
177
+ 'createToken'
178
+ > &
179
+ OverloadedFunctionSelectors<'createToken'>
180
+
181
+ export const tip403Registry = {
182
+ compoundPolicyData: '0xb6266019',
183
+ createCompoundPolicy: '0x5da414ee',
184
+ createPolicy: '0xca5d55f6',
185
+ createPolicyWithAccounts: '0xa2d3044f',
186
+ isAuthorized: '0x55a1179e',
187
+ isAuthorizedMintRecipient: '0xb389e305',
188
+ isAuthorizedRecipient: '0x6fbc13d6',
189
+ isAuthorizedSender: '0x14abd81d',
190
+ modifyPolicyBlacklist: '0xc62b27d4',
191
+ modifyPolicyWhitelist: '0x71ec67a3',
192
+ policyData: '0x50214329',
193
+ policyExists: '0x330f5637',
194
+ policyIdCounter: '0x3cc32f9c',
195
+ receivePolicy: '0xe111e611',
196
+ setPolicyAdmin: '0x25f7d376',
197
+ setReceivePolicy: '0xdda03d86',
198
+ validateReceivePolicy: '0xb72b0c59',
199
+ } as const satisfies FunctionSelectors<typeof Abis.tip403Registry>
200
+
201
+ export const feeManager = {
202
+ collectedFees: '0x4c97f766',
203
+ distributeFees: '0xa6c07924',
204
+ setUserToken: '0xe7897444',
205
+ setValidatorToken: '0xb60d2ddb',
206
+ userTokens: '0xed498fa8',
207
+ validatorTokens: '0x6dc54a7a',
208
+ } as const satisfies FunctionSelectors<typeof Abis.feeManager>
209
+
210
+ export const feeAmm = {
211
+ M: '0x693f917e',
212
+ MIN_LIQUIDITY: '0x21b77d63',
213
+ N: '0xc9e525df',
214
+ SCALE: '0xeced5526',
215
+ burn: '0xfa291e53',
216
+ getPool: '0x531aa03e',
217
+ getPoolId: '0x2ef61c21',
218
+ liquidityBalances: '0x4fb5bf7f',
219
+ mint: '0xf1aa8cb8',
220
+ pools: '0xb5217bb4',
221
+ rebalanceSwap: '0x1bd94ac7',
222
+ totalSupply: '0xb524abcf',
223
+ } as const satisfies FunctionSelectors<typeof Abis.feeAmm>
224
+
225
+ export const validatorConfig = {
226
+ addValidator: '0xffb4822e',
227
+ changeOwner: '0xa6f9dae1',
228
+ changeValidatorStatus: '0xa1b3f4a9',
229
+ changeValidatorStatusByIndex: '0x5aa3d0e1',
230
+ getNextFullDkgCeremony: '0x281a69ec',
231
+ getValidators: '0xb7ab4db5',
232
+ owner: '0x8da5cb5b',
233
+ setNextFullDkgCeremony: '0xc3576d46',
234
+ updateValidator: '0x09970c76',
235
+ validatorCount: '0x0f43a677',
236
+ validators: '0xfa52c7d8',
237
+ validatorsArray: '0x031fadbd',
238
+ } as const satisfies FunctionSelectors<typeof Abis.validatorConfig>
239
+
240
+ export const validatorConfigV2 = {
241
+ addValidator: '0x6dcf616a',
242
+ deactivateValidator: '0x8f289544',
243
+ getActiveValidators: '0x9de70258',
244
+ getInitializedAtHeight: '0xf926b083',
245
+ getNextNetworkIdentityRotationEpoch: '0x42739f79',
246
+ initializeIfMigrated: '0x2f88bb4f',
247
+ isInitialized: '0x392e53cd',
248
+ migrateValidator: '0xc8e73200',
249
+ owner: '0x8da5cb5b',
250
+ rotateValidator: '0x82f20dbe',
251
+ setFeeRecipient: '0x572e4068',
252
+ setIpAddresses: '0x55f25dc6',
253
+ setNetworkIdentityRotationEpoch: '0xcb8425d2',
254
+ transferOwnership: '0xf2fde38b',
255
+ transferValidatorOwnership: '0x9e38a5f1',
256
+ validatorByAddress: '0x1a6dda94',
257
+ validatorByIndex: '0xecb14a34',
258
+ validatorByPublicKey: '0x1b425d5e',
259
+ validatorCount: '0x0f43a677',
260
+ } as const satisfies FunctionSelectors<typeof Abis.validatorConfigV2>