ox 0.14.17 → 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.
- package/CHANGELOG.md +6 -0
- package/_cjs/tempo/VirtualAddress.js +70 -0
- package/_cjs/tempo/VirtualAddress.js.map +1 -0
- package/_cjs/tempo/VirtualMaster.js +99 -0
- package/_cjs/tempo/VirtualMaster.js.map +1 -0
- package/_cjs/tempo/index.js +3 -1
- package/_cjs/tempo/index.js.map +1 -1
- package/_cjs/version.js +1 -1
- package/_esm/tempo/VirtualAddress.js +154 -0
- package/_esm/tempo/VirtualAddress.js.map +1 -0
- package/_esm/tempo/VirtualMaster.js +200 -0
- package/_esm/tempo/VirtualMaster.js.map +1 -0
- package/_esm/tempo/index.js +52 -0
- package/_esm/tempo/index.js.map +1 -1
- package/_esm/version.js +1 -1
- package/_types/core/RpcSchema.d.ts +0 -2
- package/_types/core/RpcSchema.d.ts.map +1 -1
- package/_types/tempo/VirtualAddress.d.ts +129 -0
- package/_types/tempo/VirtualAddress.d.ts.map +1 -0
- package/_types/tempo/VirtualMaster.d.ts +155 -0
- package/_types/tempo/VirtualMaster.d.ts.map +1 -0
- package/_types/tempo/index.d.ts +52 -0
- package/_types/tempo/index.d.ts.map +1 -1
- package/_types/version.d.ts +1 -1
- package/core/RpcSchema.ts +0 -2
- package/package.json +11 -1
- package/tempo/VirtualAddress/package.json +6 -0
- package/tempo/VirtualAddress.test.ts +88 -0
- package/tempo/VirtualAddress.ts +201 -0
- package/tempo/VirtualMaster/package.json +6 -0
- package/tempo/VirtualMaster.test.ts +127 -0
- package/tempo/VirtualMaster.ts +303 -0
- package/tempo/e2e.test.ts +0 -2
- package/tempo/index.ts +52 -0
- package/version.ts +1 -1
package/_esm/version.js
CHANGED
|
@@ -263,7 +263,6 @@ export type MethodNameGeneric<schema extends Generic = Generic> = schema['Reques
|
|
|
263
263
|
* ReturnType: `0x${string}`
|
|
264
264
|
* }
|
|
265
265
|
* >
|
|
266
|
-
* // ^? [{ Method: 'eth_blockNumber'; Parameters?: undefined; ReturnType: `0x${string}` }, ...]
|
|
267
266
|
* ```
|
|
268
267
|
*/
|
|
269
268
|
export type ToViem<schema extends Generic> = UnionToTuple<schema extends schema ? {
|
|
@@ -285,7 +284,6 @@ export type ToViem<schema extends Generic> = UnionToTuple<schema extends schema
|
|
|
285
284
|
* { Method: 'eth_blockNumber'; Parameters?: undefined; ReturnType: `0x${string}` },
|
|
286
285
|
* { Method: 'eth_chainId'; Parameters?: undefined; ReturnType: `0x${string}` },
|
|
287
286
|
* ]>
|
|
288
|
-
* // ^? { Request: { method: 'eth_blockNumber'; params?: undefined }; ReturnType: `0x${string}` } | ...
|
|
289
287
|
* ```
|
|
290
288
|
*/
|
|
291
289
|
export type FromViem<schema extends readonly ViemSchemaItem[]> = {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RpcSchema.d.ts","sourceRoot":"","sources":["../../core/RpcSchema.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAA;AAC9D,OAAO,KAAK,EAAE,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAA;AAEhE,YAAY,EAAE,GAAG,EAAE,MAAM,8BAA8B,CAAA;AACvD,YAAY,EAAE,MAAM,EAAE,MAAM,iCAAiC,CAAA;AAE7D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyCG;AACH,wBAAgB,IAAI,CAAC,MAAM,SAAS,OAAO,KAAK,MAAM,CAErD;AAED;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,MAAM,MAAM,WAAW,CACrB,MAAM,SAAS,OAAO,EACtB,UAAU,SAAS,iBAAiB,CAAC,MAAM,CAAC,GAAG,iBAAiB,CAAC,MAAM,CAAC,IACtE,OAAO,CAAC;IACV,OAAO,EAAE,cAAc,CAAC,MAAM,EAAE,UAAU,CAAC,CAAA;IAC3C,UAAU,EAAE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C,CAAC,YAAY,CAAC,CAAA;SAChC,CAAA;QACD,UAAU,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC,YAAY,CAAC,CAAA;KACpC,GACD,KAAK;CACV,CAAC,MAAM,CAAC,CAAA;AAET,gBAAgB;AAChB,KAAK,cAAc,GAAG;IACpB,MAAM,EAAE,MAAM,CAAA;IACd,UAAU,CAAC,EAAE,OAAO,CAAA;IACpB,UAAU,CAAC,EAAE,OAAO,CAAA;CACrB,CAAA;AAGD,gBAAgB;AAChB,KAAK,mBAAmB,CAAC,KAAK,IAAI,CAChC,KAAK,SAAS,OAAO,GACjB,CAAC,GAAG,EAAE,MAAM,KAAK,KAAK,IAAI,GAC1B,KAAK,CACV,SAAS,CAAC,GAAG,EAAE,MAAM,YAAY,KAAK,IAAI,GACvC,YAAY,GACZ,KAAK,CAAA;AAET,gBAAgB;AAChB,KAAK,SAAS,CAAC,KAAK,IAAI,mBAAmB,CAAC,KAAK,CAAC,SAAS,MAAM,MAAM,IAAI,GACvE,IAAI,GACJ,KAAK,CAAA;AAET,gBAAgB;AAChB,KAAK,YAAY,CAAC,KAAK,EAAE,IAAI,GAAG,SAAS,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC,KAAK,CAAC,GACvE,EAAE,GACF,CAAC,GAAG,YAAY,CAAC,OAAO,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC,EAAE,IAAI,CAAC,CAAA"}
|
|
@@ -0,0 +1,129 @@
|
|
|
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
|
+
/** Fixed 10-byte marker used by TIP-1022 virtual addresses. */
|
|
7
|
+
export declare const magic: "0xfdfdfdfdfdfdfdfdfdfd";
|
|
8
|
+
/** A fixed-width virtual address component. */
|
|
9
|
+
export type Part = Hex.Hex | Bytes.Bytes | number | bigint;
|
|
10
|
+
/**
|
|
11
|
+
* Builds a TIP-1022 virtual address from a `masterId` and `userTag`.
|
|
12
|
+
*
|
|
13
|
+
* [TIP-1022](https://docs.tempo.xyz/protocol/tips/tip-1022)
|
|
14
|
+
*
|
|
15
|
+
* TIP-1022 encodes virtual addresses as:
|
|
16
|
+
* `[4-byte masterId][10-byte VIRTUAL_MAGIC][6-byte userTag]`
|
|
17
|
+
*
|
|
18
|
+
* @example
|
|
19
|
+
* ```ts twoslash
|
|
20
|
+
* import { VirtualAddress } from 'ox/tempo'
|
|
21
|
+
*
|
|
22
|
+
* const address = VirtualAddress.from({
|
|
23
|
+
* masterId: '0x58e21090',
|
|
24
|
+
* userTag: '0x010203040506',
|
|
25
|
+
* })
|
|
26
|
+
*
|
|
27
|
+
* address
|
|
28
|
+
* // @log: '0x58e21090fdfdfdfdfdfdfdfdfdfd010203040506'
|
|
29
|
+
* ```
|
|
30
|
+
*
|
|
31
|
+
* @param value - The virtual address parts.
|
|
32
|
+
* @returns The virtual address.
|
|
33
|
+
*/
|
|
34
|
+
export declare function from(value: from.Value): Address.Address;
|
|
35
|
+
export declare namespace from {
|
|
36
|
+
type Value = {
|
|
37
|
+
/** 4-byte master identifier. */
|
|
38
|
+
masterId: Part;
|
|
39
|
+
/** 6-byte opaque user tag. */
|
|
40
|
+
userTag: Part;
|
|
41
|
+
};
|
|
42
|
+
type ErrorType = Address.from.ErrorType | Bytes.padLeft.ErrorType | Hex.assert.ErrorType | Hex.fromBytes.ErrorType | Hex.fromNumber.ErrorType | Hex.padLeft.ErrorType | Errors.GlobalErrorType;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Checks whether an address matches the TIP-1022 virtual address format.
|
|
46
|
+
*
|
|
47
|
+
* [TIP-1022](https://docs.tempo.xyz/protocol/tips/tip-1022)
|
|
48
|
+
*
|
|
49
|
+
* This only checks the reserved byte layout, not whether the `masterId`
|
|
50
|
+
* is registered onchain.
|
|
51
|
+
*
|
|
52
|
+
* @example
|
|
53
|
+
* ```ts twoslash
|
|
54
|
+
* import { VirtualAddress } from 'ox/tempo'
|
|
55
|
+
*
|
|
56
|
+
* const isVirtual = VirtualAddress.isVirtual(
|
|
57
|
+
* '0x58e21090fdfdfdfdfdfdfdfdfdfd010203040506',
|
|
58
|
+
* )
|
|
59
|
+
*
|
|
60
|
+
* isVirtual
|
|
61
|
+
* // @log: true
|
|
62
|
+
* ```
|
|
63
|
+
*
|
|
64
|
+
* @param address - Address to check.
|
|
65
|
+
* @returns `true` if the address matches the virtual-address layout.
|
|
66
|
+
*/
|
|
67
|
+
export declare function isVirtual(address: string): boolean;
|
|
68
|
+
/**
|
|
69
|
+
* Parses a TIP-1022 virtual address into its `masterId` and `userTag` parts.
|
|
70
|
+
*
|
|
71
|
+
* [TIP-1022](https://docs.tempo.xyz/protocol/tips/tip-1022)
|
|
72
|
+
*
|
|
73
|
+
* @example
|
|
74
|
+
* ```ts twoslash
|
|
75
|
+
* import { VirtualAddress } from 'ox/tempo'
|
|
76
|
+
*
|
|
77
|
+
* const parsed = VirtualAddress.parse(
|
|
78
|
+
* '0x58e21090fdfdfdfdfdfdfdfdfdfd010203040506',
|
|
79
|
+
* )
|
|
80
|
+
*
|
|
81
|
+
* parsed
|
|
82
|
+
* // @log: { masterId: '0x58e21090', userTag: '0x010203040506' }
|
|
83
|
+
* ```
|
|
84
|
+
*
|
|
85
|
+
* @param address - The virtual address to parse.
|
|
86
|
+
* @returns The decoded virtual address components.
|
|
87
|
+
*/
|
|
88
|
+
export declare function parse(address: string): parse.ReturnType;
|
|
89
|
+
export declare namespace parse {
|
|
90
|
+
type ReturnType = {
|
|
91
|
+
/** 4-byte master identifier. */
|
|
92
|
+
masterId: Hex.Hex;
|
|
93
|
+
/** 6-byte opaque user tag. */
|
|
94
|
+
userTag: Hex.Hex;
|
|
95
|
+
};
|
|
96
|
+
type ErrorType = Address.assert.ErrorType | InvalidMagicError | TempoAddress.parse.ErrorType | Errors.GlobalErrorType;
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* Validates that an address matches the TIP-1022 virtual address format.
|
|
100
|
+
*
|
|
101
|
+
* [TIP-1022](https://docs.tempo.xyz/protocol/tips/tip-1022)
|
|
102
|
+
*
|
|
103
|
+
* This only validates the reserved byte layout, not whether the `masterId`
|
|
104
|
+
* resolves to a registered master onchain.
|
|
105
|
+
*
|
|
106
|
+
* @example
|
|
107
|
+
* ```ts twoslash
|
|
108
|
+
* import { VirtualAddress } from 'ox/tempo'
|
|
109
|
+
*
|
|
110
|
+
* const valid = VirtualAddress.validate(
|
|
111
|
+
* '0x58e21090fdfdfdfdfdfdfdfdfdfd010203040506',
|
|
112
|
+
* )
|
|
113
|
+
*
|
|
114
|
+
* valid
|
|
115
|
+
* // @log: true
|
|
116
|
+
* ```
|
|
117
|
+
*
|
|
118
|
+
* @param address - Address to validate.
|
|
119
|
+
* @returns `true` if the address has a valid virtual-address layout.
|
|
120
|
+
*/
|
|
121
|
+
export declare function validate(address: string): boolean;
|
|
122
|
+
/** Thrown when an address does not contain the TIP-1022 virtual marker. */
|
|
123
|
+
export declare class InvalidMagicError extends Errors.BaseError {
|
|
124
|
+
readonly name = "VirtualAddress.InvalidMagicError";
|
|
125
|
+
constructor({ address }: {
|
|
126
|
+
address: string;
|
|
127
|
+
});
|
|
128
|
+
}
|
|
129
|
+
//# sourceMappingURL=VirtualAddress.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"VirtualAddress.d.ts","sourceRoot":"","sources":["../../tempo/VirtualAddress.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,OAAO,MAAM,oBAAoB,CAAA;AAC7C,OAAO,KAAK,KAAK,MAAM,kBAAkB,CAAA;AACzC,OAAO,KAAK,MAAM,MAAM,mBAAmB,CAAA;AAC3C,OAAO,KAAK,GAAG,MAAM,gBAAgB,CAAA;AACrC,OAAO,KAAK,YAAY,MAAM,mBA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C,KAAK,CAAC,SAAS,GAC5B,MAAM,CAAC,eAAe,CAAA;CAC3B;AAED;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAgB,QAAQ,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAOjD;AAED,2EAA2E;AAC3E,qBAAa,iBAAkB,SAAQ,MAAM,CAAC,SAAS;IACrD,SAAkB,IAAI,sCAAqC;gBAE/C,EAAE,OAAO,EAAE,EAAE;QAAE,OAAO,EAAE,MAAM,CAAA;KAAE;CAK7C"}
|
|
@@ -0,0 +1,155 @@
|
|
|
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 Hash from '../core/Hash.js';
|
|
5
|
+
import * as Hex from '../core/Hex.js';
|
|
6
|
+
import * as TempoAddress from './TempoAddress.js';
|
|
7
|
+
/** A valid salt input for TIP-1022 master registration. */
|
|
8
|
+
export type Salt = Hex.Hex | Bytes.Bytes | number | bigint;
|
|
9
|
+
/**
|
|
10
|
+
* Computes the TIP-1022 registration hash for a master address and salt.
|
|
11
|
+
*
|
|
12
|
+
* [TIP-1022](https://docs.tempo.xyz/protocol/tips/tip-1022)
|
|
13
|
+
*
|
|
14
|
+
* The registration hash is `keccak256(masterAddress || salt)` where `salt`
|
|
15
|
+
* is encoded as a 32-byte value.
|
|
16
|
+
*
|
|
17
|
+
* Master addresses must satisfy TIP-1022 registration constraints: they cannot
|
|
18
|
+
* be the zero address, another virtual address, or a TIP-20 token address.
|
|
19
|
+
*
|
|
20
|
+
* @example
|
|
21
|
+
* ```ts twoslash
|
|
22
|
+
* import { VirtualMaster } from 'ox/tempo'
|
|
23
|
+
*
|
|
24
|
+
* const hash = VirtualMaster.getRegistrationHash({
|
|
25
|
+
* address: '0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266',
|
|
26
|
+
* salt: '0x00000000000000000000000000000000000000000000000000000000abf52baf',
|
|
27
|
+
* })
|
|
28
|
+
*
|
|
29
|
+
* hash
|
|
30
|
+
* // @log: '0x0000000058e21090d8f4bee424b90cddc2378aefa1bbbfa1443631a929ae966d'
|
|
31
|
+
* ```
|
|
32
|
+
*
|
|
33
|
+
* @param value - Master address and salt.
|
|
34
|
+
* @returns The registration hash.
|
|
35
|
+
*/
|
|
36
|
+
export declare function getRegistrationHash(value: getRegistrationHash.Value): Hex.Hex;
|
|
37
|
+
export declare namespace getRegistrationHash {
|
|
38
|
+
type Value = {
|
|
39
|
+
/** Master address. Accepts both hex and Tempo addresses. */
|
|
40
|
+
address: TempoAddress.Address;
|
|
41
|
+
/** 32-byte salt used for registration. */
|
|
42
|
+
salt: Salt;
|
|
43
|
+
};
|
|
44
|
+
type ErrorType = Address.assert.ErrorType | Bytes.padLeft.ErrorType | Errors.BaseError | Hash.keccak256.ErrorType | Hex.assert.ErrorType | Hex.fromBytes.ErrorType | Hex.fromNumber.ErrorType | Hex.padLeft.ErrorType | TempoAddress.parse.ErrorType | Errors.GlobalErrorType;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Derives the 4-byte TIP-1022 `masterId` from a master address and salt.
|
|
48
|
+
*
|
|
49
|
+
* [TIP-1022](https://docs.tempo.xyz/protocol/tips/tip-1022)
|
|
50
|
+
*
|
|
51
|
+
* This returns bytes `[4:8]` of the registration hash, regardless of whether the
|
|
52
|
+
* salt satisfies the proof-of-work requirement.
|
|
53
|
+
*
|
|
54
|
+
* Master addresses must satisfy TIP-1022 registration constraints: they cannot
|
|
55
|
+
* be the zero address, another virtual address, or a TIP-20 token address.
|
|
56
|
+
*
|
|
57
|
+
* @example
|
|
58
|
+
* ```ts twoslash
|
|
59
|
+
* import { VirtualMaster } from 'ox/tempo'
|
|
60
|
+
*
|
|
61
|
+
* const masterId = VirtualMaster.getMasterId({
|
|
62
|
+
* address: '0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266',
|
|
63
|
+
* salt: '0x00000000000000000000000000000000000000000000000000000000abf52baf',
|
|
64
|
+
* })
|
|
65
|
+
*
|
|
66
|
+
* masterId
|
|
67
|
+
* // @log: '0x58e21090'
|
|
68
|
+
* ```
|
|
69
|
+
*
|
|
70
|
+
* @param value - Master address and salt.
|
|
71
|
+
* @returns The derived master identifier.
|
|
72
|
+
*/
|
|
73
|
+
export declare function getMasterId(value: getMasterId.Value): Hex.Hex;
|
|
74
|
+
export declare namespace getMasterId {
|
|
75
|
+
type Value = getRegistrationHash.Value;
|
|
76
|
+
type ErrorType = getRegistrationHash.ErrorType | Errors.GlobalErrorType;
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Validates that a salt satisfies the TIP-1022 32-bit proof-of-work requirement.
|
|
80
|
+
*
|
|
81
|
+
* [TIP-1022](https://docs.tempo.xyz/protocol/tips/tip-1022)
|
|
82
|
+
*
|
|
83
|
+
* Returns `false` for invalid master addresses, including the zero address,
|
|
84
|
+
* virtual addresses, and TIP-20 token addresses.
|
|
85
|
+
*
|
|
86
|
+
* @example
|
|
87
|
+
* ```ts twoslash
|
|
88
|
+
* import { VirtualMaster } from 'ox/tempo'
|
|
89
|
+
*
|
|
90
|
+
* const valid = VirtualMaster.validateSalt({
|
|
91
|
+
* address: '0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266',
|
|
92
|
+
* salt: '0x00000000000000000000000000000000000000000000000000000000abf52baf',
|
|
93
|
+
* })
|
|
94
|
+
*
|
|
95
|
+
* valid
|
|
96
|
+
* // @log: true
|
|
97
|
+
* ```
|
|
98
|
+
*
|
|
99
|
+
* @param value - Master address and salt.
|
|
100
|
+
* @returns `true` if the first 4 bytes of the registration hash are zero.
|
|
101
|
+
*/
|
|
102
|
+
export declare function validateSalt(value: validateSalt.Value): boolean;
|
|
103
|
+
export declare namespace validateSalt {
|
|
104
|
+
type Value = getRegistrationHash.Value;
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* Searches a bounded range of salts for the first value that satisfies TIP-1022 PoW.
|
|
108
|
+
*
|
|
109
|
+
* [TIP-1022](https://docs.tempo.xyz/protocol/tips/tip-1022)
|
|
110
|
+
*
|
|
111
|
+
* This is intentionally a small, deterministic primitive. It does not coordinate
|
|
112
|
+
* workers or async execution. Callers that need large searches can shard ranges
|
|
113
|
+
* externally.
|
|
114
|
+
*
|
|
115
|
+
* Master addresses must satisfy TIP-1022 registration constraints: they cannot
|
|
116
|
+
* be the zero address, another virtual address, or a TIP-20 token address.
|
|
117
|
+
*
|
|
118
|
+
* @example
|
|
119
|
+
* ```ts twoslash
|
|
120
|
+
* import { VirtualMaster } from 'ox/tempo'
|
|
121
|
+
*
|
|
122
|
+
* const result = VirtualMaster.mineSalt({
|
|
123
|
+
* address: '0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266',
|
|
124
|
+
* start: 0xabf52ba0n,
|
|
125
|
+
* count: 16,
|
|
126
|
+
* })
|
|
127
|
+
*
|
|
128
|
+
* result?.salt
|
|
129
|
+
* // @log: '0x00000000000000000000000000000000000000000000000000000000abf52baf'
|
|
130
|
+
* ```
|
|
131
|
+
*
|
|
132
|
+
* @param value - Search range parameters.
|
|
133
|
+
* @returns The first matching salt in the range, if any.
|
|
134
|
+
*/
|
|
135
|
+
export declare function mineSalt(value: mineSalt.Value): mineSalt.ReturnType | undefined;
|
|
136
|
+
export declare namespace mineSalt {
|
|
137
|
+
type Value = {
|
|
138
|
+
/** Master address. Accepts both hex and Tempo addresses. */
|
|
139
|
+
address: TempoAddress.Address;
|
|
140
|
+
/** Number of consecutive salts to try. */
|
|
141
|
+
count: number;
|
|
142
|
+
/** Starting salt value. @default 0n */
|
|
143
|
+
start?: Salt | undefined;
|
|
144
|
+
};
|
|
145
|
+
type ReturnType = {
|
|
146
|
+
/** The 4-byte master identifier derived from the matching salt. */
|
|
147
|
+
masterId: Hex.Hex;
|
|
148
|
+
/** The matching registration hash. */
|
|
149
|
+
registrationHash: Hex.Hex;
|
|
150
|
+
/** The discovered 32-byte salt. */
|
|
151
|
+
salt: Hex.Hex;
|
|
152
|
+
};
|
|
153
|
+
type ErrorType = Address.assert.ErrorType | Bytes.fromHex.ErrorType | Bytes.padLeft.ErrorType | Errors.BaseError | Hash.keccak256.ErrorType | Hex.assert.ErrorType | Hex.fromBytes.ErrorType | Hex.fromNumber.ErrorType | Hex.padLeft.ErrorType | TempoAddress.parse.ErrorType | Errors.GlobalErrorType;
|
|
154
|
+
}
|
|
155
|
+
//# sourceMappingURL=VirtualMaster.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"VirtualMaster.d.ts","sourceRoot":"","sources":["../../tempo/VirtualMaster.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,OAAO,MAAM,oBAAoB,CAAA;AAC7C,OAAO,KAAK,KAAK,MAAM,kBAAkB,CAAA;AACzC,OAAO,KAAK,MAAM,MAAM,mBAAmB,CAAA;AAC3C,OAAO,KAAK,IAAI,MAAM,iBAAiB,CAAA;AACvC,OAAO,KAAK,GAAG,MAAM,gBAAgB,CAAA;AACrC,OAAO,KAAK,YAAY,MAAM,mBAAmB,CAAA;AAMjD,2DAA2D;AAC3D,MAAM,MAAM,IAAI,GAAG,GAAG,CAAC,GAAG,GAAG,KAAK,CAAC,KAAK,GAAG,MAAM,GAAG,MAAM,CAAA;AAE1D;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,mBAAmB,CAAC,KAAK,GAAG,GAAG,CAAC,GAAG,CAI7E;AAED,MAAM,CAAC,OAAO,WAAW,mBAAmB,CAAC;IAC3C,KAAK,KAAK,GAAG;QACX,4DAA4D;QAC5D,OAAO,EAAE,YAAY,CAAC,OAAO,CAAA;QAC7B,0CAA0C;QAC1C,IAAI,EAAE,IAAI,CAAA;KACX,CAAA;IAED,KAAK,SAAS,GACV,OAAO,CAAC,MAAM,CAAC,SAAS,GACxB,KAAK,CAAC,OAAO,CAAC,SAAS,GACvB,MAAM,CAAC,SAAS,G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AAA;QACjB,sCAAsC;QACtC,gBAAgB,EAAE,GAAG,CAAC,GAAG,CAAA;QACzB,mCAAmC;QACnC,IAAI,EAAE,GAAG,CAAC,GAAG,CAAA;KACd,CAAA;IAED,KAAK,SAAS,GACV,OAAO,CAAC,MAAM,CAAC,SAAS,GACxB,KAAK,CAAC,OAAO,CAAC,SAAS,GACvB,KAAK,CAAC,OAAO,CAAC,SAAS,GACvB,MAAM,CAAC,SAAS,GAChB,IAAI,CAAC,SAAS,CAAC,SAAS,GACxB,GAAG,CAAC,MAAM,CAAC,SAAS,GACpB,GAAG,CAAC,SAAS,CAAC,SAAS,GACvB,GAAG,CAAC,UAAU,CAAC,SAAS,GACxB,GAAG,CAAC,OAAO,CAAC,SAAS,GACrB,YAAY,CAAC,KAAK,CAAC,SAAS,GAC5B,MAAM,CAAC,eAAe,CAAA;CAC3B"}
|
package/_types/tempo/index.d.ts
CHANGED
|
@@ -365,6 +365,58 @@ 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';
|
|
368
420
|
/**
|
|
369
421
|
* Zone ID utilities for converting between zone IDs and zone chain IDs.
|
|
370
422
|
*
|
|
@@ -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,K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;;GAmBG;AACH,OAAO,KAAK,kBAAkB,MAAM,yBAAyB,CAAA;AAC7D;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,OAAO,KAAK,eAAe,MAAM,sBAAsB,CAAA;AACvD;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,OAAO,KAAK,cAAc,MAAM,qBAAqB,CAAA;AACrD;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,OAAO,KAAK,aAAa,MAAM,oBAAoB,CAAA;AACnD;;;;;;;;;;;;;;;;;;GAkBG;AACH,OAAO,KAAK,MAAM,MAAM,aAAa,CAAA;AACrC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AACH,OAAO,KAAK,qBAAqB,MAAM,4BAA4B,CAAA"}
|
package/_types/version.d.ts
CHANGED
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.
|
|
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,16 @@
|
|
|
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
|
+
},
|
|
572
582
|
"./tempo/ZoneId": {
|
|
573
583
|
"types": "./_types/tempo/ZoneId.d.ts",
|
|
574
584
|
"import": "./_esm/tempo/ZoneId.js",
|
|
@@ -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
|
+
})
|