ox 0.14.16 → 0.14.17

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 (40) hide show
  1. package/CHANGELOG.md +10 -0
  2. package/_cjs/tempo/TransactionRequest.js +10 -1
  3. package/_cjs/tempo/TransactionRequest.js.map +1 -1
  4. package/_cjs/tempo/ZoneId.js +13 -0
  5. package/_cjs/tempo/ZoneId.js.map +1 -0
  6. package/_cjs/tempo/ZoneRpcAuthentication.js +101 -0
  7. package/_cjs/tempo/ZoneRpcAuthentication.js.map +1 -0
  8. package/_cjs/tempo/index.js +3 -1
  9. package/_cjs/tempo/index.js.map +1 -1
  10. package/_cjs/version.js +1 -1
  11. package/_esm/tempo/TransactionRequest.js +10 -1
  12. package/_esm/tempo/TransactionRequest.js.map +1 -1
  13. package/_esm/tempo/ZoneId.js +47 -0
  14. package/_esm/tempo/ZoneId.js.map +1 -0
  15. package/_esm/tempo/ZoneRpcAuthentication.js +256 -0
  16. package/_esm/tempo/ZoneRpcAuthentication.js.map +1 -0
  17. package/_esm/tempo/index.js +55 -0
  18. package/_esm/tempo/index.js.map +1 -1
  19. package/_esm/version.js +1 -1
  20. package/_types/tempo/TransactionRequest.d.ts +6 -4
  21. package/_types/tempo/TransactionRequest.d.ts.map +1 -1
  22. package/_types/tempo/ZoneId.d.ts +50 -0
  23. package/_types/tempo/ZoneId.d.ts.map +1 -0
  24. package/_types/tempo/ZoneRpcAuthentication.d.ts +268 -0
  25. package/_types/tempo/ZoneRpcAuthentication.d.ts.map +1 -0
  26. package/_types/tempo/index.d.ts +55 -0
  27. package/_types/tempo/index.d.ts.map +1 -1
  28. package/_types/version.d.ts +1 -1
  29. package/package.json +11 -1
  30. package/tempo/TransactionRequest.test.ts +26 -2
  31. package/tempo/TransactionRequest.ts +17 -7
  32. package/tempo/ZoneId/package.json +6 -0
  33. package/tempo/ZoneId.test.ts +42 -0
  34. package/tempo/ZoneId.ts +58 -0
  35. package/tempo/ZoneRpcAuthentication/package.json +6 -0
  36. package/tempo/ZoneRpcAuthentication.test.ts +226 -0
  37. package/tempo/ZoneRpcAuthentication.ts +423 -0
  38. package/tempo/e2e.test.ts +2 -0
  39. package/tempo/index.ts +55 -8
  40. package/version.ts +1 -1
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../tempo/index.ts"],"names":[],"mappings":"AAIA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,OAAO,KAAK,kBAAkB,MAAM,yBAAyB,CAAA;AAE7D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsCG;AACH,OAAO,KAAK,gBAAgB,MAAM,uBAAuB,CAAA;AAEzD;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,OAAO,KAAK,MAAM,MAAM,aAAa,CAAA;AAErC;;;;;;;;;;;;;;;;;;;GAmBG;AACH,OAAO,KAAK,MAAM,MAAM,aAAa,CAAA;AAErC;;;;;;;;;;;;;;;;;GAiBG;AACH,OAAO,KAAK,cAAc,MAAM,qBAAqB,CAAA;AAErD;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,OAAO,KAAK,iBAAiB,MAAM,wBAAwB,CAAA;AAE3D;;;;;;;;;;;;;;;;;GAiBG;AACH,OAAO,KAAK,YAAY,MAAM,mBAAmB,CAAA;AAEjD;;;;;;;;;;;;;;;;;;GAkBG;AACH,OAAO,KAAK,IAAI,MAAM,WAAW,CAAA;AAEjC;;;;;;;;;;;;;;;;;;;GAmBG;AACH,OAAO,KAAK,OAAO,MAAM,cAAc,CAAA;AAEvC;;;;;;;;;;;;;;;;GAgBG;AACH,OAAO,KAAK,SAAS,MAAM,gBAAgB,CAAA;AAE3C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgDG;AACH,OAAO,KAAK,WAAW,MAAM,kBAAkB,CAAA;AAC/C;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,OA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;;;;;;;;;GAqBG;AACH,OAAO,KAAK,kBAAkB,MAAM,yBAAyB,CAAA;AAC7D;;;;;;;;;;;;;;;;;;;GAmBG;AACH,OAAO,KAAK,kBAAkB,MAAM,yBAAyB,CAAA;AAC7D;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,OAAO,KAAK,eAAe,MAAM,sBAAsB,CAAA;AACvD;;;;;;;;;;;;;;;;;;GAkBG;AACH,OAAO,KAAK,MAAM,MAAM,aAAa,CAAA;AACrC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AACH,OAAO,KAAK,qBAAqB,MAAM,4BAA4B,CAAA"}
package/_esm/version.js CHANGED
@@ -1,3 +1,3 @@
1
1
  /** @internal */
2
- export const version = '0.14.16';
2
+ export const version = '0.14.17';
3
3
  //# sourceMappingURL=version.js.map
@@ -16,20 +16,22 @@ type KeyType = 'secp256k1' | 'p256' | 'webAuthn';
16
16
  *
17
17
  * @see {@link https://docs.tempo.xyz/protocol/transactions}
18
18
  */
19
- export type TransactionRequest<bigintType = bigint, numberType = number, type extends string = string> = Compute<Omit<ox_TransactionRequest.TransactionRequest<bigintType, numberType, type>, 'authorizationList'> & {
19
+ export type TransactionRequest<bigintType = bigint, numberType = number, type extends string = string, addressType = TempoAddress.Address> = Compute<Omit<ox_TransactionRequest.TransactionRequest<bigintType, numberType, type>, 'authorizationList'> & {
20
20
  authorizationList?: AuthorizationTempo.ListSigned<bigintType, numberType> | undefined;
21
- calls?: readonly Call<bigintType, TempoAddress.Address>[] | undefined;
21
+ calls?: readonly Call<bigintType, addressType>[] | undefined;
22
22
  keyAuthorization?: KeyAuthorization.KeyAuthorization<true> | undefined;
23
23
  keyData?: Hex.Hex | undefined;
24
24
  keyType?: KeyType | undefined;
25
- feeToken?: TokenId.TokenIdOrAddress<TempoAddress.Address> | undefined;
25
+ feePayer?: boolean | undefined;
26
+ feeToken?: TokenId.TokenIdOrAddress<addressType> | undefined;
26
27
  nonceKey?: 'random' | bigintType | undefined;
27
28
  validBefore?: numberType | undefined;
28
29
  validAfter?: numberType | undefined;
29
30
  }>;
30
31
  /** RPC representation of a {@link ox#TransactionRequest.TransactionRequest}. */
31
- export type Rpc = Omit<TransactionRequest<Hex.Hex, Hex.Hex, string>, 'authorizationList' | 'keyAuthorization'> & {
32
+ export type Rpc = Omit<TransactionRequest<Hex.Hex, Hex.Hex, string, Hex.Hex>, 'authorizationList' | 'feeToken' | 'keyAuthorization'> & {
32
33
  authorizationList?: AuthorizationTempo.ListRpc | undefined;
34
+ feeToken?: Hex.Hex | undefined;
33
35
  keyAuthorization?: KeyAuthorization.Rpc | undefined;
34
36
  nonceKey?: Hex.Hex | undefined;
35
37
  };
@@ -1 +1 @@
1
- {"version":3,"file":"TransactionRequest.d.ts","sourceRoot":"","sources":["../../tempo/TransactionRequest.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,MAAM,mBAAmB,CAAA;AAChD,OAAO,KAAK,GAAG,MAAM,gBAAgB,CAAA;AACrC,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,2BAA2B,CAAA;AACxD,OAAO,KAAK,qBAAqB,MAAM,+BAA+B,CAAA;AACtE,OAAO,KAAK,kBAAkB,MAAM,yBAAyB,CAAA;AAC7D,OAAO,KAAK,gBAAgB,MAAM,uBAAuB,CAAA;AACzD,OAAO,KAAK,YAAY,MAAM,mBAAmB,CAAA;AACjD,OAAO,KAAK,OAAO,MAAM,cAAc,CAAA;AAEvC,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,sBAAsB,CAAA;AAEhD,KAAK,OAAO,GAAG,WAAW,GAAG,MAAM,GAAG,UAAU,CAAA;AAEhD;;;;;;;GAOG;AACH,MAAM,MAAM,kBAAkB,CAC5B,UAAU,GAAG,MAAM,EACnB,UAAU,GAAG,MAAM,EACnB,IAAI,SAAS,MAAM,GAAG,MAAM,IAC1B,OAAO,CACT,IAAI,CACF,qBAAqB,CAAC,kBAAkB,CAAC,UAAU,EAA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AG,CAAC,GAAG,GAAG,SAAS,CAAA;CAC/B,CAAA;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,OAAO,CAAC,OAAO,EAAE,GAAG,GAAG,kBAAkB,CAwCxD;AAED,MAAM,CAAC,OAAO,WAAW,OAAO,CAAC;IAC/B,KAAY,SAAS,GACjB,kBAAkB,CAAC,WAAW,CAAC,SAAS,GACxC,GAAG,CAAC,QAAQ,CAAC,SAAS,GACtB,GAAG,CAAC,QAAQ,CAAC,SAAS,GACtB,MAAM,CAAC,eAAe,CAAA;CAC3B;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgDG;AACH,wBAAgB,KAAK,CAAC,OAAO,EAAE,kBAAkB,GAAG,GAAG,CA6DtD;AAED,MAAM,CAAC,OAAO,WAAW,KAAK,CAAC;IAC7B,KAAY,SAAS,GACjB,kBAAkB,CAAC,SAAS,CAAC,SAAS,GACtC,GAAG,CAAC,UAAU,CAAC,SAAS,GACxB,MAAM,CAAC,eAAe,CAAA;CAC3B"}
@@ -0,0 +1,50 @@
1
+ import type * as Errors from '../core/Errors.js';
2
+ /**
3
+ * Base offset for deriving zone chain IDs.
4
+ *
5
+ * Zone chain IDs are computed as `chainIdBase + zoneId`.
6
+ */
7
+ export declare const chainIdBase: 4217000000;
8
+ /**
9
+ * Derives a zone ID from a zone chain ID.
10
+ *
11
+ * Zone chain IDs follow the formula `4_217_000_000 + zoneId`, so a chain ID
12
+ * of `4217000006` corresponds to zone ID `6`.
13
+ *
14
+ * @example
15
+ * ```ts twoslash
16
+ * import { ZoneId } from 'ox/tempo'
17
+ *
18
+ * const zoneId = ZoneId.fromChainId(4_217_000_006)
19
+ * // @log: 6
20
+ * ```
21
+ *
22
+ * @param chainId - The zone chain ID.
23
+ * @returns The zone ID.
24
+ */
25
+ export declare function fromChainId(chainId: number): number;
26
+ export declare namespace fromChainId {
27
+ type ErrorType = Errors.GlobalErrorType;
28
+ }
29
+ /**
30
+ * Derives a zone chain ID from a zone ID.
31
+ *
32
+ * Zone chain IDs follow the formula `4_217_000_000 + zoneId`, so zone ID
33
+ * `6` corresponds to chain ID `4217000006`.
34
+ *
35
+ * @example
36
+ * ```ts twoslash
37
+ * import { ZoneId } from 'ox/tempo'
38
+ *
39
+ * const chainId = ZoneId.toChainId(6)
40
+ * // @log: 4217000006
41
+ * ```
42
+ *
43
+ * @param zoneId - The zone ID.
44
+ * @returns The zone chain ID.
45
+ */
46
+ export declare function toChainId(zoneId: number): number;
47
+ export declare namespace toChainId {
48
+ type ErrorType = Errors.GlobalErrorType;
49
+ }
50
+ //# sourceMappingURL=ZoneId.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ZoneId.d.ts","sourceRoot":"","sources":["../../tempo/ZoneId.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,MAAM,mBAAmB,CAAA;AAEhD;;;;GAIG;AACH,eAAO,MAAM,WAAW,YAAyB,CAAA;AAEjD;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,WAAW,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAEnD;AAED,MAAM,CAAC,OAAO,WAAW,WAAW,CAAC;IACnC,KAAK,SAAS,GAAG,MAAM,CAAC,eAAe,CAAA;CACxC;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,SAAS,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAEhD;AAED,MAAM,CAAC,OAAO,WAAW,SAAS,CAAC;IACjC,KAAK,SAAS,GAAG,MAAM,CAAC,eAAe,CAAA;CACxC"}
@@ -0,0 +1,268 @@
1
+ import * as Errors from '../core/Errors.js';
2
+ import * as Hash from '../core/Hash.js';
3
+ import * as Hex from '../core/Hex.js';
4
+ import type { Compute, PartialBy } from '../core/internal/types.js';
5
+ import * as SignatureEnvelope from './SignatureEnvelope.js';
6
+ import * as TempoAddress from './TempoAddress.js';
7
+ /**
8
+ * Header name used to transport Zone RPC authentication tokens.
9
+ */
10
+ export declare const headerName: "X-Authorization-Token";
11
+ /**
12
+ * 32-byte domain separator used when hashing Zone RPC authentication tokens.
13
+ */
14
+ export declare const magicBytes: "0x54656d706f5a6f6e655250430000000000000000000000000000000000000000";
15
+ /**
16
+ * Size, in bytes, of the fixed Zone RPC authentication fields.
17
+ */
18
+ export declare const fieldsSize: 29;
19
+ /** Current Zone RPC authentication version. */
20
+ export declare const version: 0;
21
+ /** Current Zone RPC authentication version. */
22
+ export type Version = typeof version;
23
+ /**
24
+ * Root type for a Tempo Zone RPC authentication token.
25
+ *
26
+ * Zone RPC authentication tokens are short-lived, read-only credentials used to
27
+ * authenticate requests to Tempo private zone RPC endpoints.
28
+ *
29
+ * [Zone RPC Specification](https://docs.tempo.xyz/protocol/privacy/rpc#authorization-tokens)
30
+ */
31
+ export type ZoneRpcAuthentication<signed extends boolean = boolean, bigintType = bigint, numberType = number> = Compute<{
32
+ /** Zone chain ID for replay protection. */
33
+ chainId: numberType;
34
+ /** Unix timestamp when the token expires. */
35
+ expiresAt: numberType;
36
+ /** Unix timestamp when the token was issued. */
37
+ issuedAt: numberType;
38
+ /** Zone RPC authentication version. Always `0` for the current spec. */
39
+ version: Version;
40
+ /** Numeric zone identifier. */
41
+ zoneId: numberType;
42
+ } & (signed extends true ? {
43
+ signature: SignatureEnvelope.SignatureEnvelope<bigintType, numberType>;
44
+ } : {
45
+ signature?: SignatureEnvelope.SignatureEnvelope<bigintType, numberType> | undefined;
46
+ })>;
47
+ /** Input type for a Zone RPC authentication token. */
48
+ export type Input = PartialBy<ZoneRpcAuthentication<false>, 'version'>;
49
+ /** 29-byte fixed Zone RPC authentication field suffix. */
50
+ export type Fields = Hex.Hex;
51
+ /** Hex-encoded serialized Zone RPC authentication token. */
52
+ export type Serialized = Hex.Hex;
53
+ /** Signed Zone RPC authentication token. */
54
+ export type Signed<bigintType = bigint, numberType = number> = ZoneRpcAuthentication<true, bigintType, numberType>;
55
+ /**
56
+ * Instantiates a typed Zone RPC authentication token.
57
+ *
58
+ * @example
59
+ * ```ts twoslash
60
+ * import { ZoneRpcAuthentication } from 'ox/tempo'
61
+ *
62
+ * const authentication = ZoneRpcAuthentication.from({
63
+ * chainId: 4217000026,
64
+ * expiresAt: 1711235160,
65
+ * issuedAt: 1711234560,
66
+ * zoneId: 26,
67
+ * })
68
+ * ```
69
+ *
70
+ * @example
71
+ * ### Attaching Signatures
72
+ *
73
+ * ```ts twoslash
74
+ * import { Secp256k1 } from 'ox'
75
+ * import { ZoneRpcAuthentication } from 'ox/tempo'
76
+ *
77
+ * const authentication = ZoneRpcAuthentication.from({
78
+ * chainId: 4217000026,
79
+ * expiresAt: 1711235160,
80
+ * issuedAt: 1711234560,
81
+ * zoneId: 26,
82
+ * })
83
+ *
84
+ * const signature = Secp256k1.sign({
85
+ * payload: ZoneRpcAuthentication.getSignPayload(authentication),
86
+ * privateKey: '0x...',
87
+ * })
88
+ *
89
+ * const authentication_signed = ZoneRpcAuthentication.from(authentication, {
90
+ * signature,
91
+ * })
92
+ * ```
93
+ *
94
+ * @param authentication - Zone RPC authentication token fields.
95
+ * @param options - Zone RPC authentication options.
96
+ * @returns The instantiated Zone RPC authentication token.
97
+ */
98
+ export declare function from<const authentication extends Input | ZoneRpcAuthentication, const signature extends SignatureEnvelope.from.Value | undefined = undefined>(authentication: authentication | ZoneRpcAuthentication, options?: from.Options<signature>): from.ReturnType<authentication, signature>;
99
+ export declare namespace from {
100
+ type Options<signature extends SignatureEnvelope.from.Value | undefined = SignatureEnvelope.from.Value | undefined> = {
101
+ /** The signature to attach to the authentication token. */
102
+ signature?: signature | SignatureEnvelope.SignatureEnvelope | undefined;
103
+ };
104
+ type ReturnType<authentication extends ZoneRpcAuthentication | Input = ZoneRpcAuthentication, signature extends SignatureEnvelope.from.Value | undefined = SignatureEnvelope.from.Value | undefined> = Compute<authentication & {
105
+ readonly version: Version;
106
+ } & (signature extends SignatureEnvelope.from.Value ? {
107
+ signature: SignatureEnvelope.from.ReturnValue<signature>;
108
+ } : {})>;
109
+ type ErrorType = Errors.GlobalErrorType;
110
+ }
111
+ /**
112
+ * Parses a serialized Zone RPC authentication token.
113
+ *
114
+ * The serialized format is `<signature><29-byte fields>`. The signature is parsed
115
+ * from the prefix and the fixed-length fields are parsed from the suffix.
116
+ *
117
+ * @example
118
+ * ```ts twoslash
119
+ * import { ZoneRpcAuthentication } from 'ox/tempo'
120
+ *
121
+ * const authentication = ZoneRpcAuthentication.deserialize('0x...')
122
+ * ```
123
+ *
124
+ * @param serialized - The serialized Zone RPC authentication token.
125
+ * @returns The parsed Zone RPC authentication token.
126
+ */
127
+ export declare function deserialize(serialized: Serialized): Signed;
128
+ export declare namespace deserialize {
129
+ type ErrorType = InvalidSerializedError | SignatureEnvelope.CoercionError | SignatureEnvelope.InvalidSerializedError | Hex.size.ErrorType | Hex.slice.ErrorType | Hex.toNumber.ErrorType | Errors.GlobalErrorType;
130
+ }
131
+ /**
132
+ * Returns the 29-byte fixed field suffix for a Zone RPC authentication token.
133
+ *
134
+ * @example
135
+ * ```ts twoslash
136
+ * import { ZoneRpcAuthentication } from 'ox/tempo'
137
+ *
138
+ * const fields = ZoneRpcAuthentication.getFields({
139
+ * chainId: 4217000026,
140
+ * expiresAt: 1711235160,
141
+ * issuedAt: 1711234560,
142
+ * zoneId: 26,
143
+ * })
144
+ * ```
145
+ *
146
+ * @param authentication - The Zone RPC authentication token.
147
+ * @returns The fixed 29-byte field suffix.
148
+ */
149
+ export declare function getFields(authentication: PartialBy<ZoneRpcAuthentication, 'version'>): Fields;
150
+ export declare namespace getFields {
151
+ type ErrorType = Hex.concat.ErrorType | Hex.fromNumber.ErrorType | Errors.GlobalErrorType;
152
+ }
153
+ /**
154
+ * Computes the sign payload for a Zone RPC authentication token.
155
+ *
156
+ * When `userAddress` is provided, the payload is wrapped as
157
+ * `keccak256(0x04 || authHash || userAddress)` to match V2 keychain signing.
158
+ *
159
+ * @example
160
+ * ```ts twoslash
161
+ * import { ZoneRpcAuthentication } from 'ox/tempo'
162
+ *
163
+ * const authentication = ZoneRpcAuthentication.from({
164
+ * chainId: 4217000026,
165
+ * expiresAt: 1711235160,
166
+ * issuedAt: 1711234560,
167
+ * zoneId: 26,
168
+ * })
169
+ *
170
+ * const payload = ZoneRpcAuthentication.getSignPayload(authentication)
171
+ * ```
172
+ *
173
+ * @param authentication - The Zone RPC authentication token.
174
+ * @param options - Options.
175
+ * @returns The sign payload.
176
+ */
177
+ export declare function getSignPayload(authentication: PartialBy<ZoneRpcAuthentication, 'version'>, options?: getSignPayload.Options): Hex.Hex;
178
+ export declare namespace getSignPayload {
179
+ type Options = {
180
+ /**
181
+ * Root account address for keychain access-key signing.
182
+ *
183
+ * When provided, computes `keccak256(0x04 || authHash || userAddress)`
184
+ * instead of the raw `authHash`.
185
+ */
186
+ userAddress?: TempoAddress.Address | undefined;
187
+ };
188
+ type ErrorType = hash.ErrorType | Errors.GlobalErrorType;
189
+ }
190
+ /**
191
+ * Computes the raw authorization hash for a Zone RPC authentication token.
192
+ *
193
+ * The hash is `keccak256(magicBytes || fields)`.
194
+ *
195
+ * @example
196
+ * ```ts twoslash
197
+ * import { ZoneRpcAuthentication } from 'ox/tempo'
198
+ *
199
+ * const authentication = ZoneRpcAuthentication.from({
200
+ * chainId: 4217000026,
201
+ * expiresAt: 1711235160,
202
+ * issuedAt: 1711234560,
203
+ * zoneId: 26,
204
+ * })
205
+ *
206
+ * const hash = ZoneRpcAuthentication.hash(authentication)
207
+ * ```
208
+ *
209
+ * @param authentication - The Zone RPC authentication token.
210
+ * @returns The authorization hash.
211
+ */
212
+ export declare function hash(authentication: PartialBy<ZoneRpcAuthentication, 'version'>): Hex.Hex;
213
+ export declare namespace hash {
214
+ type ErrorType = getFields.ErrorType | Hash.keccak256.ErrorType | Hex.concat.ErrorType | Errors.GlobalErrorType;
215
+ }
216
+ /**
217
+ * Serializes a Zone RPC authentication token to hex.
218
+ *
219
+ * The serialized format is `<signature><29-byte fields>`.
220
+ *
221
+ * @example
222
+ * ```ts twoslash
223
+ * import { Secp256k1 } from 'ox'
224
+ * import { ZoneRpcAuthentication } from 'ox/tempo'
225
+ *
226
+ * const authentication = ZoneRpcAuthentication.from({
227
+ * chainId: 4217000026,
228
+ * expiresAt: 1711235160,
229
+ * issuedAt: 1711234560,
230
+ * zoneId: 26,
231
+ * })
232
+ *
233
+ * const signature = Secp256k1.sign({
234
+ * payload: ZoneRpcAuthentication.getSignPayload(authentication),
235
+ * privateKey: '0x...',
236
+ * })
237
+ *
238
+ * const serialized = ZoneRpcAuthentication.serialize(authentication, {
239
+ * signature,
240
+ * })
241
+ * ```
242
+ *
243
+ * @param authentication - The Zone RPC authentication token.
244
+ * @param options - Serialization options.
245
+ * @returns The serialized authentication token.
246
+ */
247
+ export declare function serialize(authentication: PartialBy<ZoneRpcAuthentication, 'version'>, options?: serialize.Options): Serialized;
248
+ export declare namespace serialize {
249
+ type Options = {
250
+ /** Signature to attach to the serialized authentication token. */
251
+ signature?: SignatureEnvelope.from.Value | undefined;
252
+ };
253
+ type ErrorType = getFields.ErrorType | MissingSignatureError | SignatureEnvelope.CoercionError | Errors.GlobalErrorType;
254
+ }
255
+ /** Error thrown when a serialized authentication token cannot be deserialized. */
256
+ export declare class InvalidSerializedError extends Errors.BaseError {
257
+ readonly name = "ZoneRpcAuthentication.InvalidSerializedError";
258
+ constructor({ reason, serialized }: {
259
+ reason: string;
260
+ serialized: Hex.Hex;
261
+ });
262
+ }
263
+ /** Error thrown when serializing an authentication token without a signature. */
264
+ export declare class MissingSignatureError extends Errors.BaseError {
265
+ readonly name = "ZoneRpcAuthentication.MissingSignatureError";
266
+ constructor();
267
+ }
268
+ //# sourceMappingURL=ZoneRpcAuthentication.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ZoneRpcAuthentication.d.ts","sourceRoot":"","sources":["../../tempo/ZoneRpcAuthentication.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,mBAAmB,CAAA;AAC3C,OAAO,KA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
367
367
  export * as TxEnvelopeTempo from './TxEnvelopeTempo.js';
368
+ /**
369
+ * Zone ID utilities for converting between zone IDs and zone chain IDs.
370
+ *
371
+ * Zone chain IDs are deterministically derived from zone IDs using the formula
372
+ * `421_700_000 + zoneId`. This module provides helpers to convert between them.
373
+ *
374
+ * @example
375
+ * ```ts twoslash
376
+ * import { ZoneId } from 'ox/tempo'
377
+ *
378
+ * const zoneId = ZoneId.fromChainId(421_700_026)
379
+ * // @log: 26
380
+ *
381
+ * const chainId = ZoneId.toChainId(26)
382
+ * // @log: 421700026
383
+ * ```
384
+ *
385
+ * @category Reference
386
+ */
387
+ export * as ZoneId from './ZoneId.js';
388
+ /**
389
+ * Zone RPC authentication token utilities for private zone RPC access.
390
+ *
391
+ * Zone RPC authentication tokens are short-lived, read-only credentials used in
392
+ * the `X-Authorization-Token` header when talking to private zone RPC endpoints.
393
+ * They reuse Tempo's multi-signature model, so secp256k1, P256, WebAuthn, and
394
+ * keychain access-key signatures all share the same wire format as Tempo
395
+ * transaction signatures.
396
+ *
397
+ * [Zone RPC Specification](https://docs.tempo.xyz/protocol/privacy/rpc#authorization-tokens)
398
+ *
399
+ * @example
400
+ * ```ts twoslash
401
+ * import { Secp256k1 } from 'ox'
402
+ * import { ZoneRpcAuthentication } from 'ox/tempo'
403
+ *
404
+ * const authentication = ZoneRpcAuthentication.from({
405
+ * chainId: 4217000026,
406
+ * expiresAt: 1711235160,
407
+ * issuedAt: 1711234560,
408
+ * zoneId: 26,
409
+ * zonePortal: 'tempox0x0f1b0cedd7e8226e39ecb161f522c8b1ac45e9c8',
410
+ * })
411
+ *
412
+ * const signature = Secp256k1.sign({
413
+ * payload: ZoneRpcAuthentication.getSignPayload(authentication),
414
+ * privateKey: '0x...',
415
+ * })
416
+ *
417
+ * const token = ZoneRpcAuthentication.serialize(authentication, { signature })
418
+ * ```
419
+ *
420
+ * @category Reference
421
+ */
422
+ export * as ZoneRpcAuthentication from './ZoneRpcAuthentication.js';
368
423
  //# source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AAC7D;;;;;;;;;;;;;;;;;;;GAmBG;AACH,OAAO,KAAK,kBAAkB,MAAM,yBAAyB,CAAA;AAC7D;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,OAAO,KAAK,eAAe,MAAM,sBAAsB,CAAA;AACvD;;;;;;;;;;;;;;;;;;GAkBG;AACH,OAAO,KAAK,MAAM,MAAM,aAAa,CAAA;AACrC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AACH,OAAO,KAAK,qBAAqB,MAAM,4BAA4B,CAAA"}
@@ -1,3 +1,3 @@
1
1
  /** @internal */
2
- export declare const version = "0.14.16";
2
+ export declare const version = "0.14.17";
3
3
  //# sourceMappingURL=version.d.ts.map
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "ox",
3
3
  "description": "Ethereum Standard Library",
4
- "version": "0.14.16",
4
+ "version": "0.14.17",
5
5
  "main": "./_cjs/index.js",
6
6
  "module": "./_esm/index.js",
7
7
  "types": "./_types/index.d.ts",
@@ -569,6 +569,16 @@
569
569
  "import": "./_esm/tempo/TxEnvelopeTempo.js",
570
570
  "default": "./_cjs/tempo/TxEnvelopeTempo.js"
571
571
  },
572
+ "./tempo/ZoneId": {
573
+ "types": "./_types/tempo/ZoneId.d.ts",
574
+ "import": "./_esm/tempo/ZoneId.js",
575
+ "default": "./_cjs/tempo/ZoneId.js"
576
+ },
577
+ "./tempo/ZoneRpcAuthentication": {
578
+ "types": "./_types/tempo/ZoneRpcAuthentication.d.ts",
579
+ "import": "./_esm/tempo/ZoneRpcAuthentication.js",
580
+ "default": "./_cjs/tempo/ZoneRpcAuthentication.js"
581
+ },
572
582
  "./tempo": {
573
583
  "types": "./_types/tempo/index.d.ts",
574
584
  "import": "./_esm/tempo/index.js",
@@ -21,7 +21,7 @@ describe('fromRpc', () => {
21
21
  "to": "0xcafebabecafebabecafebabecafebabecafebabe",
22
22
  },
23
23
  ],
24
- "feeToken": 0n,
24
+ "feeToken": "0x20c0000000000000000000000000000000000000",
25
25
  "type": "tempo",
26
26
  }
27
27
  `)
@@ -100,6 +100,28 @@ describe('toRpc', () => {
100
100
  }
101
101
  `)
102
102
  })
103
+
104
+ test('behavior: to/data/value folded into calls', () => {
105
+ const request = TransactionRequest.toRpc({
106
+ to: '0xcafebabecafebabecafebabecafebabecafebabe',
107
+ data: '0xdeadbeef',
108
+ value: 1000n,
109
+ feeToken: '0x20c0000000000000000000000000000000000000',
110
+ })
111
+ expect(request).toMatchInlineSnapshot(`
112
+ {
113
+ "calls": [
114
+ {
115
+ "data": "0xdeadbeef",
116
+ "to": "0xcafebabecafebabecafebabecafebabecafebabe",
117
+ "value": "0x3e8",
118
+ },
119
+ ],
120
+ "feeToken": "0x20c0000000000000000000000000000000000000",
121
+ "type": "0x76",
122
+ }
123
+ `)
124
+ })
103
125
  })
104
126
 
105
127
  describe('roundtrip', () => {
@@ -134,7 +156,9 @@ describe('roundtrip', () => {
134
156
  value: call.value,
135
157
  })),
136
158
  )
137
- expect(converted.feeToken).toEqual(1n)
159
+ expect(converted.feeToken).toEqual(
160
+ '0x20c0000000000000000000000000000000000001',
161
+ )
138
162
  expect(converted.validBefore).toBe(original.validBefore)
139
163
  expect(converted.validAfter).toBe(original.validAfter)
140
164
  expect(converted.nonceKey).toBe(original.nonceKey)
@@ -23,6 +23,7 @@ export type TransactionRequest<
23
23
  bigintType = bigint,
24
24
  numberType = number,
25
25
  type extends string = string,
26
+ addressType = TempoAddress.Address,
26
27
  > = Compute<
27
28
  Omit<
28
29
  ox_TransactionRequest.TransactionRequest<bigintType, numberType, type>,
@@ -31,11 +32,12 @@ export type TransactionRequest<
31
32
  authorizationList?:
32
33
  | AuthorizationTempo.ListSigned<bigintType, numberType>
33
34
  | undefined
34
- calls?: readonly Call<bigintType, TempoAddress.Address>[] | undefined
35
+ calls?: readonly Call<bigintType, addressType>[] | undefined
35
36
  keyAuthorization?: KeyAuthorization.KeyAuthorization<true> | undefined
36
37
  keyData?: Hex.Hex | undefined
37
38
  keyType?: KeyType | undefined
38
- feeToken?: TokenId.TokenIdOrAddress<TempoAddress.Address> | undefined
39
+ feePayer?: boolean | undefined
40
+ feeToken?: TokenId.TokenIdOrAddress<addressType> | undefined
39
41
  nonceKey?: 'random' | bigintType | undefined
40
42
  validBefore?: numberType | undefined
41
43
  validAfter?: numberType | undefined
@@ -44,10 +46,11 @@ export type TransactionRequest<
44
46
 
45
47
  /** RPC representation of a {@link ox#TransactionRequest.TransactionRequest}. */
46
48
  export type Rpc = Omit<
47
- TransactionRequest<Hex.Hex, Hex.Hex, string>,
48
- 'authorizationList' | 'keyAuthorization'
49
+ TransactionRequest<Hex.Hex, Hex.Hex, string, Hex.Hex>,
50
+ 'authorizationList' | 'feeToken' | 'keyAuthorization'
49
51
  > & {
50
52
  authorizationList?: AuthorizationTempo.ListRpc | undefined
53
+ feeToken?: Hex.Hex | undefined
51
54
  keyAuthorization?: KeyAuthorization.Rpc | undefined
52
55
  nonceKey?: Hex.Hex | undefined
53
56
  }
@@ -99,9 +102,7 @@ export function fromRpc(request: Rpc): TransactionRequest {
99
102
  return mapped
100
103
  })
101
104
  if (typeof request.feeToken !== 'undefined')
102
- request_.feeToken = TokenId.fromAddress(
103
- request.feeToken as TempoAddress.Address,
104
- )
105
+ request_.feeToken = request.feeToken
105
106
  if (request.keyAuthorization)
106
107
  request_.keyAuthorization = KeyAuthorization.fromRpc(
107
108
  request.keyAuthorization,
@@ -189,6 +190,14 @@ export function toRpc(request: TransactionRequest): Rpc {
189
190
  value: call.value ? Hex.fromNumber(call.value) : '0x',
190
191
  data: call.data ?? '0x',
191
192
  }))
193
+ else if (request.to || request.data || request.value)
194
+ request_rpc.calls = [
195
+ {
196
+ to: request.to ? TempoAddress.resolve(request.to) : undefined,
197
+ value: request.value ? Hex.fromNumber(request.value) : '0x',
198
+ data: request.data ?? '0x',
199
+ },
200
+ ]
192
201
  if (typeof request.feeToken !== 'undefined')
193
202
  request_rpc.feeToken = TokenId.toAddress(request.feeToken)
194
203
  if (request.keyAuthorization)
@@ -210,6 +219,7 @@ export function toRpc(request: TransactionRequest): Rpc {
210
219
 
211
220
  if (
212
221
  typeof request.calls !== 'undefined' ||
222
+ typeof request.feePayer !== 'undefined' ||
213
223
  typeof request.feeToken !== 'undefined' ||
214
224
  typeof request.keyAuthorization !== 'undefined' ||
215
225
  typeof request.nonceKey !== 'undefined' ||
@@ -0,0 +1,6 @@
1
+ {
2
+ "type": "module",
3
+ "types": "../../_types/tempo/ZoneId.d.ts",
4
+ "main": "../../_cjs/tempo/ZoneId.js",
5
+ "module": "../../_esm/tempo/ZoneId.js"
6
+ }
@@ -0,0 +1,42 @@
1
+ import { describe, expect, test } from 'vitest'
2
+ import * as ZoneId from './ZoneId.js'
3
+
4
+ describe('fromChainId', () => {
5
+ test('default', () => {
6
+ expect(ZoneId.fromChainId(4_217_000_006)).toBe(6)
7
+ })
8
+
9
+ test('zone 1', () => {
10
+ expect(ZoneId.fromChainId(4_217_000_001)).toBe(1)
11
+ })
12
+
13
+ test('zone 28', () => {
14
+ expect(ZoneId.fromChainId(4_217_000_028)).toBe(28)
15
+ })
16
+ })
17
+
18
+ describe('toChainId', () => {
19
+ test('default', () => {
20
+ expect(ZoneId.toChainId(6)).toBe(4_217_000_006)
21
+ })
22
+
23
+ test('zone 1', () => {
24
+ expect(ZoneId.toChainId(1)).toBe(4_217_000_001)
25
+ })
26
+
27
+ test('zone 28', () => {
28
+ expect(ZoneId.toChainId(28)).toBe(4_217_000_028)
29
+ })
30
+ })
31
+
32
+ describe('roundtrip', () => {
33
+ test('fromChainId → toChainId', () => {
34
+ const chainId = 4_217_000_006
35
+ expect(ZoneId.toChainId(ZoneId.fromChainId(chainId))).toBe(chainId)
36
+ })
37
+
38
+ test('toChainId → fromChainId', () => {
39
+ const zoneId = 42
40
+ expect(ZoneId.fromChainId(ZoneId.toChainId(zoneId))).toBe(zoneId)
41
+ })
42
+ })