ox 0.14.16 → 0.14.18

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 (60) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/_cjs/tempo/TransactionRequest.js +10 -1
  3. package/_cjs/tempo/TransactionRequest.js.map +1 -1
  4. package/_cjs/tempo/VirtualAddress.js +70 -0
  5. package/_cjs/tempo/VirtualAddress.js.map +1 -0
  6. package/_cjs/tempo/VirtualMaster.js +99 -0
  7. package/_cjs/tempo/VirtualMaster.js.map +1 -0
  8. package/_cjs/tempo/ZoneId.js +13 -0
  9. package/_cjs/tempo/ZoneId.js.map +1 -0
  10. package/_cjs/tempo/ZoneRpcAuthentication.js +101 -0
  11. package/_cjs/tempo/ZoneRpcAuthentication.js.map +1 -0
  12. package/_cjs/tempo/index.js +5 -1
  13. package/_cjs/tempo/index.js.map +1 -1
  14. package/_cjs/version.js +1 -1
  15. package/_esm/tempo/TransactionRequest.js +10 -1
  16. package/_esm/tempo/TransactionRequest.js.map +1 -1
  17. package/_esm/tempo/VirtualAddress.js +154 -0
  18. package/_esm/tempo/VirtualAddress.js.map +1 -0
  19. package/_esm/tempo/VirtualMaster.js +200 -0
  20. package/_esm/tempo/VirtualMaster.js.map +1 -0
  21. package/_esm/tempo/ZoneId.js +47 -0
  22. package/_esm/tempo/ZoneId.js.map +1 -0
  23. package/_esm/tempo/ZoneRpcAuthentication.js +256 -0
  24. package/_esm/tempo/ZoneRpcAuthentication.js.map +1 -0
  25. package/_esm/tempo/index.js +107 -0
  26. package/_esm/tempo/index.js.map +1 -1
  27. package/_esm/version.js +1 -1
  28. package/_types/core/RpcSchema.d.ts +0 -2
  29. package/_types/core/RpcSchema.d.ts.map +1 -1
  30. package/_types/tempo/TransactionRequest.d.ts +6 -4
  31. package/_types/tempo/TransactionRequest.d.ts.map +1 -1
  32. package/_types/tempo/VirtualAddress.d.ts +129 -0
  33. package/_types/tempo/VirtualAddress.d.ts.map +1 -0
  34. package/_types/tempo/VirtualMaster.d.ts +155 -0
  35. package/_types/tempo/VirtualMaster.d.ts.map +1 -0
  36. package/_types/tempo/ZoneId.d.ts +50 -0
  37. package/_types/tempo/ZoneId.d.ts.map +1 -0
  38. package/_types/tempo/ZoneRpcAuthentication.d.ts +268 -0
  39. package/_types/tempo/ZoneRpcAuthentication.d.ts.map +1 -0
  40. package/_types/tempo/index.d.ts +107 -0
  41. package/_types/tempo/index.d.ts.map +1 -1
  42. package/_types/version.d.ts +1 -1
  43. package/core/RpcSchema.ts +0 -2
  44. package/package.json +21 -1
  45. package/tempo/TransactionRequest.test.ts +26 -2
  46. package/tempo/TransactionRequest.ts +17 -7
  47. package/tempo/VirtualAddress/package.json +6 -0
  48. package/tempo/VirtualAddress.test.ts +88 -0
  49. package/tempo/VirtualAddress.ts +201 -0
  50. package/tempo/VirtualMaster/package.json +6 -0
  51. package/tempo/VirtualMaster.test.ts +127 -0
  52. package/tempo/VirtualMaster.ts +303 -0
  53. package/tempo/ZoneId/package.json +6 -0
  54. package/tempo/ZoneId.test.ts +42 -0
  55. package/tempo/ZoneId.ts +58 -0
  56. package/tempo/ZoneRpcAuthentication/package.json +6 -0
  57. package/tempo/ZoneRpcAuthentication.test.ts +226 -0
  58. package/tempo/ZoneRpcAuthentication.ts +423 -0
  59. package/tempo/index.ts +107 -8
  60. package/version.ts +1 -1
@@ -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,KAAK,IAAI,MAAM,iBAAiB,CAAA;AACvC,OAAO,KAAK,GAAG,MAAM,gBAAgB,CAAA;AACrC,OAAO,KAAK,EAAE,OAAO,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAA;AACnE,OAAO,KAAK,iBAAiB,MAAM,wBAAwB,CAAA;AAC3D,OAAO,K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,OAAO,WAAW,IAAI,CAAC;IAC5B,KAAK,SAAS,GACV,SAAS,CAAC,SAAS,GACnB,IAAI,CAAC,SAAS,CAAC,SAAS,GACxB,GAAG,CAAC,MAAM,CAAC,SAAS,GACpB,MAAM,CAAC,eAAe,CAAA;CAC3B;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,wBAAgB,SAAS,CACvB,cAAc,EAAE,SAAS,CAAC,qBAAqB,EAAE,SAAS,CAAC,EAC3D,OAAO,GAAE,SAAS,CAAC,OAAY,GAC9B,UAAU,CAQZ;AAED,MAAM,CAAC,OAAO,WAAW,SAAS,CAAC;IACjC,KAAK,OAAO,GAAG;QACb,kEAAkE;QAClE,SAAS,CAAC,EAAE,iBAAiB,CAAC,IAAI,CAAC,KAAK,GAAG,SAAS,CAAA;KACrD,CAAA;IAED,KAAK,SAAS,GACV,SAAS,CAAC,SAAS,GACnB,qBAAqB,GACrB,iBAAiB,CAAC,aAAa,GAC/B,MAAM,CAAC,eAAe,CAAA;CAC3B;AAED,kFAAkF;AAClF,qBAAa,sBAAuB,SAAQ,MAAM,CAAC,SAAS;IAC1D,SAAkB,IAAI,kDAAiD;gBAE3D,EAAE,MAAM,EAAE,UAAU,EAAE,EAAE;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,UAAU,EAAE,GAAG,CAAC,GAAG,CAAA;KAAE;CAK5E;AAED,iFAAiF;AACjF,qBAAa,qBAAsB,SAAQ,MAAM,CAAC,SAAS;IACzD,SAAkB,IAAI,iDAAgD;;CAKvE"}
@@ -365,4 +365,111 @@ export * as TransactionRequest from './TransactionRequest.js';
365
365
  * @category Reference
366
366
  */
367
367
  export * as TxEnvelopeTempo from './TxEnvelopeTempo.js';
368
+ /**
369
+ * TIP-1022 virtual address encoding and parsing utilities.
370
+ *
371
+ * [TIP-1022](https://docs.tempo.xyz/protocol/tips/tip-1022)
372
+ *
373
+ * Virtual addresses reserve the following 20-byte layout:
374
+ * `[4-byte masterId][10-byte VIRTUAL_MAGIC][6-byte userTag]`.
375
+ * These helpers only operate on the reserved byte layout and do not query
376
+ * onchain registration state.
377
+ *
378
+ * @example
379
+ * ```ts twoslash
380
+ * import { TempoAddress, VirtualAddress } from 'ox/tempo'
381
+ *
382
+ * const masterId = '0x58e21090' // derived when the master registers
383
+ * const userTag = '0x010203040506' // operator-defined deposit identifier
384
+ *
385
+ * const address = VirtualAddress.from({
386
+ * masterId,
387
+ * userTag,
388
+ * })
389
+ *
390
+ * const tempoAddress = TempoAddress.format(address) // optional display format
391
+ * ```
392
+ *
393
+ * @category Reference
394
+ */
395
+ export * as VirtualAddress from './VirtualAddress.js';
396
+ /**
397
+ * TIP-1022 master registration utilities.
398
+ *
399
+ * [TIP-1022](https://docs.tempo.xyz/protocol/tips/tip-1022)
400
+ *
401
+ * These utilities expose deterministic hashing and bounded salt mining helpers for
402
+ * `registerVirtualMaster(bytes32 salt)` without introducing any extra hashing dependency.
403
+ *
404
+ * @example
405
+ * ```ts twoslash
406
+ * import { VirtualMaster } from 'ox/tempo'
407
+ *
408
+ * const registration = {
409
+ * address: '0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266',
410
+ * salt: '0x00000000000000000000000000000000000000000000000000000000abf52baf',
411
+ * }
412
+ *
413
+ * const registrationHash = VirtualMaster.getRegistrationHash(registration) // keccak256(address || salt)
414
+ * const masterId = VirtualMaster.getMasterId(registration) // bytes [4:8] of the hash
415
+ * ```
416
+ *
417
+ * @category Reference
418
+ */
419
+ export * as VirtualMaster from './VirtualMaster.js';
420
+ /**
421
+ * Zone ID utilities for converting between zone IDs and zone chain IDs.
422
+ *
423
+ * Zone chain IDs are deterministically derived from zone IDs using the formula
424
+ * `421_700_000 + zoneId`. This module provides helpers to convert between them.
425
+ *
426
+ * @example
427
+ * ```ts twoslash
428
+ * import { ZoneId } from 'ox/tempo'
429
+ *
430
+ * const zoneId = ZoneId.fromChainId(421_700_026)
431
+ * // @log: 26
432
+ *
433
+ * const chainId = ZoneId.toChainId(26)
434
+ * // @log: 421700026
435
+ * ```
436
+ *
437
+ * @category Reference
438
+ */
439
+ export * as ZoneId from './ZoneId.js';
440
+ /**
441
+ * Zone RPC authentication token utilities for private zone RPC access.
442
+ *
443
+ * Zone RPC authentication tokens are short-lived, read-only credentials used in
444
+ * the `X-Authorization-Token` header when talking to private zone RPC endpoints.
445
+ * They reuse Tempo's multi-signature model, so secp256k1, P256, WebAuthn, and
446
+ * keychain access-key signatures all share the same wire format as Tempo
447
+ * transaction signatures.
448
+ *
449
+ * [Zone RPC Specification](https://docs.tempo.xyz/protocol/privacy/rpc#authorization-tokens)
450
+ *
451
+ * @example
452
+ * ```ts twoslash
453
+ * import { Secp256k1 } from 'ox'
454
+ * import { ZoneRpcAuthentication } from 'ox/tempo'
455
+ *
456
+ * const authentication = ZoneRpcAuthentication.from({
457
+ * chainId: 4217000026,
458
+ * expiresAt: 1711235160,
459
+ * issuedAt: 1711234560,
460
+ * zoneId: 26,
461
+ * zonePortal: 'tempox0x0f1b0cedd7e8226e39ecb161f522c8b1ac45e9c8',
462
+ * })
463
+ *
464
+ * const signature = Secp256k1.sign({
465
+ * payload: ZoneRpcAuthentication.getSignPayload(authentication),
466
+ * privateKey: '0x...',
467
+ * })
468
+ *
469
+ * const token = ZoneRpcAuthentication.serialize(authentication, { signature })
470
+ * ```
471
+ *
472
+ * @category Reference
473
+ */
474
+ export * as ZoneRpcAuthentication from './ZoneRpcAuthentication.js';
368
475
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../tempo/index.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAEhC,YAAY,EAAE,CAAA;AAEd;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,OAAO,KAAK,kBAAkB,MAAM,yBAAyB,CAAA;AAE7D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsCG;AACH,OAAO,KAAK,gBAAgB,MAAM,uB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AAoB,CAAA;AACnD;;;;;;;;;;;;;;;;;;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.18";
3
3
  //# sourceMappingURL=version.d.ts.map
package/core/RpcSchema.ts CHANGED
@@ -290,7 +290,6 @@ export type MethodNameGeneric<schema extends Generic = Generic> =
290
290
  * ReturnType: `0x${string}`
291
291
  * }
292
292
  * >
293
- * // ^? [{ Method: 'eth_blockNumber'; Parameters?: undefined; ReturnType: `0x${string}` }, ...]
294
293
  * ```
295
294
  */
296
295
  export type ToViem<schema extends Generic> = UnionToTuple<
@@ -315,7 +314,6 @@ export type ToViem<schema extends Generic> = UnionToTuple<
315
314
  * { Method: 'eth_blockNumber'; Parameters?: undefined; ReturnType: `0x${string}` },
316
315
  * { Method: 'eth_chainId'; Parameters?: undefined; ReturnType: `0x${string}` },
317
316
  * ]>
318
- * // ^? { Request: { method: 'eth_blockNumber'; params?: undefined }; ReturnType: `0x${string}` } | ...
319
317
  * ```
320
318
  */
321
319
  export type FromViem<schema extends readonly ViemSchemaItem[]> = {
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.18",
5
5
  "main": "./_cjs/index.js",
6
6
  "module": "./_esm/index.js",
7
7
  "types": "./_types/index.d.ts",
@@ -569,6 +569,26 @@
569
569
  "import": "./_esm/tempo/TxEnvelopeTempo.js",
570
570
  "default": "./_cjs/tempo/TxEnvelopeTempo.js"
571
571
  },
572
+ "./tempo/VirtualAddress": {
573
+ "types": "./_types/tempo/VirtualAddress.d.ts",
574
+ "import": "./_esm/tempo/VirtualAddress.js",
575
+ "default": "./_cjs/tempo/VirtualAddress.js"
576
+ },
577
+ "./tempo/VirtualMaster": {
578
+ "types": "./_types/tempo/VirtualMaster.d.ts",
579
+ "import": "./_esm/tempo/VirtualMaster.js",
580
+ "default": "./_cjs/tempo/VirtualMaster.js"
581
+ },
582
+ "./tempo/ZoneId": {
583
+ "types": "./_types/tempo/ZoneId.d.ts",
584
+ "import": "./_esm/tempo/ZoneId.js",
585
+ "default": "./_cjs/tempo/ZoneId.js"
586
+ },
587
+ "./tempo/ZoneRpcAuthentication": {
588
+ "types": "./_types/tempo/ZoneRpcAuthentication.d.ts",
589
+ "import": "./_esm/tempo/ZoneRpcAuthentication.js",
590
+ "default": "./_cjs/tempo/ZoneRpcAuthentication.js"
591
+ },
572
592
  "./tempo": {
573
593
  "types": "./_types/tempo/index.d.ts",
574
594
  "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/VirtualAddress.d.ts",
4
+ "main": "../../_cjs/tempo/VirtualAddress.js",
5
+ "module": "../../_esm/tempo/VirtualAddress.js"
6
+ }
@@ -0,0 +1,88 @@
1
+ import { TempoAddress, VirtualAddress } from 'ox/tempo'
2
+ import { describe, expect, test } from 'vitest'
3
+
4
+ const address = '0x58e21090fdfdfdfdfdfdfdfdfdfd010203040506'
5
+ const tempoAddress = TempoAddress.format(address)
6
+
7
+ describe('from', () => {
8
+ test('default', () => {
9
+ expect(
10
+ VirtualAddress.from({
11
+ masterId: '0x58e21090',
12
+ userTag: '0x010203040506',
13
+ }),
14
+ ).toMatchInlineSnapshot(`"0x58e21090fdfdfdfdfdfdfdfdfdfd010203040506"`)
15
+ })
16
+
17
+ test('pads number inputs', () => {
18
+ expect(
19
+ VirtualAddress.from({
20
+ masterId: 1,
21
+ userTag: 2,
22
+ }),
23
+ ).toMatchInlineSnapshot(`"0x00000001fdfdfdfdfdfdfdfdfdfd000000000002"`)
24
+ })
25
+ })
26
+
27
+ describe('parse', () => {
28
+ test('raw address', () => {
29
+ expect(VirtualAddress.parse(address)).toMatchInlineSnapshot(`
30
+ {
31
+ "masterId": "0x58e21090",
32
+ "userTag": "0x010203040506",
33
+ }
34
+ `)
35
+ })
36
+
37
+ test('tempo address', () => {
38
+ expect(VirtualAddress.parse(tempoAddress)).toMatchInlineSnapshot(`
39
+ {
40
+ "masterId": "0x58e21090",
41
+ "userTag": "0x010203040506",
42
+ }
43
+ `)
44
+ })
45
+
46
+ test('error: not virtual', () => {
47
+ expect(() =>
48
+ VirtualAddress.parse('0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266'),
49
+ ).toThrowErrorMatchingInlineSnapshot(
50
+ `[VirtualAddress.InvalidMagicError: Address "0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266" does not contain the TIP-1022 virtual address marker.]`,
51
+ )
52
+ })
53
+ })
54
+
55
+ describe('isVirtual', () => {
56
+ test('returns true for virtual address', () => {
57
+ expect(VirtualAddress.isVirtual(address)).toBe(true)
58
+ })
59
+
60
+ test('returns false for non-virtual address', () => {
61
+ expect(
62
+ VirtualAddress.isVirtual('0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266'),
63
+ ).toBe(false)
64
+ })
65
+ })
66
+
67
+ describe('validate', () => {
68
+ test('returns true for virtual address', () => {
69
+ expect(VirtualAddress.validate(tempoAddress)).toBe(true)
70
+ })
71
+
72
+ test('returns false for invalid value', () => {
73
+ expect(VirtualAddress.validate('invalid')).toBe(false)
74
+ })
75
+ })
76
+
77
+ test('exports', () => {
78
+ expect(Object.keys(VirtualAddress)).toMatchInlineSnapshot(`
79
+ [
80
+ "magic",
81
+ "from",
82
+ "isVirtual",
83
+ "parse",
84
+ "validate",
85
+ "InvalidMagicError",
86
+ ]
87
+ `)
88
+ })
@@ -0,0 +1,201 @@
1
+ import * as Address from '../core/Address.js'
2
+ import * as Bytes from '../core/Bytes.js'
3
+ import * as Errors from '../core/Errors.js'
4
+ import * as Hex from '../core/Hex.js'
5
+ import * as TempoAddress from './TempoAddress.js'
6
+
7
+ /** Fixed 10-byte marker used by TIP-1022 virtual addresses. */
8
+ export const magic = '0xfdfdfdfdfdfdfdfdfdfd' as const
9
+
10
+ /** A fixed-width virtual address component. */
11
+ export type Part = Hex.Hex | Bytes.Bytes | number | bigint
12
+
13
+ /**
14
+ * Builds a TIP-1022 virtual address from a `masterId` and `userTag`.
15
+ *
16
+ * [TIP-1022](https://docs.tempo.xyz/protocol/tips/tip-1022)
17
+ *
18
+ * TIP-1022 encodes virtual addresses as:
19
+ * `[4-byte masterId][10-byte VIRTUAL_MAGIC][6-byte userTag]`
20
+ *
21
+ * @example
22
+ * ```ts twoslash
23
+ * import { VirtualAddress } from 'ox/tempo'
24
+ *
25
+ * const address = VirtualAddress.from({
26
+ * masterId: '0x58e21090',
27
+ * userTag: '0x010203040506',
28
+ * })
29
+ *
30
+ * address
31
+ * // @log: '0x58e21090fdfdfdfdfdfdfdfdfdfd010203040506'
32
+ * ```
33
+ *
34
+ * @param value - The virtual address parts.
35
+ * @returns The virtual address.
36
+ */
37
+ export function from(value: from.Value): Address.Address {
38
+ return Address.from(
39
+ Hex.concat(
40
+ toFixedHex(value.masterId, 4),
41
+ magic,
42
+ toFixedHex(value.userTag, 6),
43
+ ),
44
+ )
45
+ }
46
+
47
+ export declare namespace from {
48
+ type Value = {
49
+ /** 4-byte master identifier. */
50
+ masterId: Part
51
+ /** 6-byte opaque user tag. */
52
+ userTag: Part
53
+ }
54
+
55
+ type ErrorType =
56
+ | Address.from.ErrorType
57
+ | Bytes.padLeft.ErrorType
58
+ | Hex.assert.ErrorType
59
+ | Hex.fromBytes.ErrorType
60
+ | Hex.fromNumber.ErrorType
61
+ | Hex.padLeft.ErrorType
62
+ | Errors.GlobalErrorType
63
+ }
64
+
65
+ /**
66
+ * Checks whether an address matches the TIP-1022 virtual address format.
67
+ *
68
+ * [TIP-1022](https://docs.tempo.xyz/protocol/tips/tip-1022)
69
+ *
70
+ * This only checks the reserved byte layout, not whether the `masterId`
71
+ * is registered onchain.
72
+ *
73
+ * @example
74
+ * ```ts twoslash
75
+ * import { VirtualAddress } from 'ox/tempo'
76
+ *
77
+ * const isVirtual = VirtualAddress.isVirtual(
78
+ * '0x58e21090fdfdfdfdfdfdfdfdfdfd010203040506',
79
+ * )
80
+ *
81
+ * isVirtual
82
+ * // @log: true
83
+ * ```
84
+ *
85
+ * @param address - Address to check.
86
+ * @returns `true` if the address matches the virtual-address layout.
87
+ */
88
+ export function isVirtual(address: string): boolean {
89
+ try {
90
+ const resolved = resolveAddress(address)
91
+ return Hex.slice(resolved, 4, 14).toLowerCase() === magic
92
+ } catch {
93
+ return false
94
+ }
95
+ }
96
+
97
+ /**
98
+ * Parses a TIP-1022 virtual address into its `masterId` and `userTag` parts.
99
+ *
100
+ * [TIP-1022](https://docs.tempo.xyz/protocol/tips/tip-1022)
101
+ *
102
+ * @example
103
+ * ```ts twoslash
104
+ * import { VirtualAddress } from 'ox/tempo'
105
+ *
106
+ * const parsed = VirtualAddress.parse(
107
+ * '0x58e21090fdfdfdfdfdfdfdfdfdfd010203040506',
108
+ * )
109
+ *
110
+ * parsed
111
+ * // @log: { masterId: '0x58e21090', userTag: '0x010203040506' }
112
+ * ```
113
+ *
114
+ * @param address - The virtual address to parse.
115
+ * @returns The decoded virtual address components.
116
+ */
117
+ export function parse(address: string): parse.ReturnType {
118
+ const resolved = resolveAddress(address)
119
+
120
+ if (Hex.slice(resolved, 4, 14).toLowerCase() !== magic)
121
+ throw new InvalidMagicError({ address: resolved })
122
+
123
+ return {
124
+ masterId: Hex.slice(resolved, 0, 4),
125
+ userTag: Hex.slice(resolved, 14, 20),
126
+ }
127
+ }
128
+
129
+ export declare namespace parse {
130
+ type ReturnType = {
131
+ /** 4-byte master identifier. */
132
+ masterId: Hex.Hex
133
+ /** 6-byte opaque user tag. */
134
+ userTag: Hex.Hex
135
+ }
136
+
137
+ type ErrorType =
138
+ | Address.assert.ErrorType
139
+ | InvalidMagicError
140
+ | TempoAddress.parse.ErrorType
141
+ | Errors.GlobalErrorType
142
+ }
143
+
144
+ /**
145
+ * Validates that an address matches the TIP-1022 virtual address format.
146
+ *
147
+ * [TIP-1022](https://docs.tempo.xyz/protocol/tips/tip-1022)
148
+ *
149
+ * This only validates the reserved byte layout, not whether the `masterId`
150
+ * resolves to a registered master onchain.
151
+ *
152
+ * @example
153
+ * ```ts twoslash
154
+ * import { VirtualAddress } from 'ox/tempo'
155
+ *
156
+ * const valid = VirtualAddress.validate(
157
+ * '0x58e21090fdfdfdfdfdfdfdfdfdfd010203040506',
158
+ * )
159
+ *
160
+ * valid
161
+ * // @log: true
162
+ * ```
163
+ *
164
+ * @param address - Address to validate.
165
+ * @returns `true` if the address has a valid virtual-address layout.
166
+ */
167
+ export function validate(address: string): boolean {
168
+ try {
169
+ parse(address)
170
+ return true
171
+ } catch {
172
+ return false
173
+ }
174
+ }
175
+
176
+ /** Thrown when an address does not contain the TIP-1022 virtual marker. */
177
+ export class InvalidMagicError extends Errors.BaseError {
178
+ override readonly name = 'VirtualAddress.InvalidMagicError'
179
+
180
+ constructor({ address }: { address: string }) {
181
+ super(
182
+ `Address "${address}" does not contain the TIP-1022 virtual address marker.`,
183
+ )
184
+ }
185
+ }
186
+
187
+ function resolveAddress(address: string): Address.Address {
188
+ const resolved = TempoAddress.resolve(address as TempoAddress.Address)
189
+ Address.assert(resolved, { strict: false })
190
+ return resolved
191
+ }
192
+
193
+ function toFixedHex(value: Part, size: number): Hex.Hex {
194
+ if (typeof value === 'number' || typeof value === 'bigint')
195
+ return Hex.fromNumber(value, { size })
196
+ if (typeof value === 'string') {
197
+ Hex.assert(value, { strict: true })
198
+ return Hex.padLeft(value, size)
199
+ }
200
+ return Hex.fromBytes(Bytes.padLeft(value, size))
201
+ }
@@ -0,0 +1,6 @@
1
+ {
2
+ "type": "module",
3
+ "types": "../../_types/tempo/VirtualMaster.d.ts",
4
+ "main": "../../_cjs/tempo/VirtualMaster.js",
5
+ "module": "../../_esm/tempo/VirtualMaster.js"
6
+ }