ox 0.14.17 → 0.14.19
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 +12 -0
- package/_cjs/tempo/TxEnvelopeTempo.js.map +1 -1
- package/_cjs/tempo/VirtualAddress.js +70 -0
- package/_cjs/tempo/VirtualAddress.js.map +1 -0
- package/_cjs/tempo/VirtualMaster.js +278 -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/tempo/internal/mine.wasm.js +6 -0
- package/_cjs/tempo/internal/mine.wasm.js.map +1 -0
- package/_cjs/tempo/internal/virtualMasterPool.js +186 -0
- package/_cjs/tempo/internal/virtualMasterPool.js.map +1 -0
- package/_cjs/version.js +1 -1
- package/_esm/tempo/TxEnvelopeTempo.js +6 -3
- package/_esm/tempo/TxEnvelopeTempo.js.map +1 -1
- package/_esm/tempo/VirtualAddress.js +154 -0
- package/_esm/tempo/VirtualAddress.js.map +1 -0
- package/_esm/tempo/VirtualMaster.js +483 -0
- package/_esm/tempo/VirtualMaster.js.map +1 -0
- package/_esm/tempo/index.js +54 -0
- package/_esm/tempo/index.js.map +1 -1
- package/_esm/tempo/internal/mine.wasm.js +15 -0
- package/_esm/tempo/internal/mine.wasm.js.map +1 -0
- package/_esm/tempo/internal/virtualMasterPool.js +216 -0
- package/_esm/tempo/internal/virtualMasterPool.js.map +1 -0
- 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/TxEnvelopeTempo.d.ts +6 -3
- package/_types/tempo/TxEnvelopeTempo.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 +237 -0
- package/_types/tempo/VirtualMaster.d.ts.map +1 -0
- package/_types/tempo/index.d.ts +54 -0
- package/_types/tempo/index.d.ts.map +1 -1
- package/_types/tempo/internal/mine.wasm.d.ts +5 -0
- package/_types/tempo/internal/mine.wasm.d.ts.map +1 -0
- package/_types/tempo/internal/virtualMasterPool.d.ts +46 -0
- package/_types/tempo/internal/virtualMasterPool.d.ts.map +1 -0
- package/_types/version.d.ts +1 -1
- package/core/RpcSchema.ts +0 -2
- package/package.json +11 -1
- package/tempo/TxEnvelopeTempo.ts +6 -3
- 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 +204 -0
- package/tempo/VirtualMaster.ts +711 -0
- package/tempo/e2e.test.ts +0 -2
- package/tempo/index.ts +55 -0
- package/tempo/internal/mine.c +182 -0
- package/tempo/internal/mine.wasm.ts +17 -0
- package/tempo/internal/virtualMasterPool.ts +254 -0
- package/version.ts +1 -1
|
@@ -0,0 +1,237 @@
|
|
|
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 { Address, Hex } from 'ox'
|
|
23
|
+
* import { VirtualMaster } from 'ox/tempo'
|
|
24
|
+
*
|
|
25
|
+
* const hash = VirtualMaster.getRegistrationHash({
|
|
26
|
+
* address: Address.from('0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266'),
|
|
27
|
+
* salt: Hex.from('0x00000000000000000000000000000000000000000000000000000000abf52baf'),
|
|
28
|
+
* })
|
|
29
|
+
*
|
|
30
|
+
* hash
|
|
31
|
+
* // @log: '0x0000000058e21090d8f4bee424b90cddc2378aefa1bbbfa1443631a929ae966d'
|
|
32
|
+
* ```
|
|
33
|
+
*
|
|
34
|
+
* @param value - Master address and salt.
|
|
35
|
+
* @returns The registration hash.
|
|
36
|
+
*/
|
|
37
|
+
export declare function getRegistrationHash(value: getRegistrationHash.Value): Hex.Hex;
|
|
38
|
+
export declare namespace getRegistrationHash {
|
|
39
|
+
type Value = {
|
|
40
|
+
/** Master address. Accepts both hex and Tempo addresses. */
|
|
41
|
+
address: TempoAddress.Address;
|
|
42
|
+
/** 32-byte salt used for registration. */
|
|
43
|
+
salt: Salt;
|
|
44
|
+
};
|
|
45
|
+
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;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Derives the 4-byte TIP-1022 `masterId` from a master address and salt.
|
|
49
|
+
*
|
|
50
|
+
* [TIP-1022](https://docs.tempo.xyz/protocol/tips/tip-1022)
|
|
51
|
+
*
|
|
52
|
+
* This returns bytes `[4:8]` of the registration hash, regardless of whether the
|
|
53
|
+
* salt satisfies the proof-of-work requirement.
|
|
54
|
+
*
|
|
55
|
+
* Master addresses must satisfy TIP-1022 registration constraints: they cannot
|
|
56
|
+
* be the zero address, another virtual address, or a TIP-20 token address.
|
|
57
|
+
*
|
|
58
|
+
* @example
|
|
59
|
+
* ```ts twoslash
|
|
60
|
+
* import { Address, Hex } from 'ox'
|
|
61
|
+
* import { VirtualMaster } from 'ox/tempo'
|
|
62
|
+
*
|
|
63
|
+
* const masterId = VirtualMaster.getMasterId({
|
|
64
|
+
* address: Address.from('0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266'),
|
|
65
|
+
* salt: Hex.from('0x00000000000000000000000000000000000000000000000000000000abf52baf'),
|
|
66
|
+
* })
|
|
67
|
+
*
|
|
68
|
+
* masterId
|
|
69
|
+
* // @log: '0x58e21090'
|
|
70
|
+
* ```
|
|
71
|
+
*
|
|
72
|
+
* @param value - Master address and salt.
|
|
73
|
+
* @returns The derived master identifier.
|
|
74
|
+
*/
|
|
75
|
+
export declare function getMasterId(value: getMasterId.Value): Hex.Hex;
|
|
76
|
+
export declare namespace getMasterId {
|
|
77
|
+
type Value = getRegistrationHash.Value;
|
|
78
|
+
type ErrorType = getRegistrationHash.ErrorType | Errors.GlobalErrorType;
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Validates that a salt satisfies the TIP-1022 32-bit proof-of-work requirement.
|
|
82
|
+
*
|
|
83
|
+
* [TIP-1022](https://docs.tempo.xyz/protocol/tips/tip-1022)
|
|
84
|
+
*
|
|
85
|
+
* Returns `false` for invalid master addresses, including the zero address,
|
|
86
|
+
* virtual addresses, and TIP-20 token addresses.
|
|
87
|
+
*
|
|
88
|
+
* @example
|
|
89
|
+
* ```ts twoslash
|
|
90
|
+
* import { Address, Hex } from 'ox'
|
|
91
|
+
* import { VirtualMaster } from 'ox/tempo'
|
|
92
|
+
*
|
|
93
|
+
* const valid = VirtualMaster.validateSalt({
|
|
94
|
+
* address: Address.from('0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266'),
|
|
95
|
+
* salt: Hex.from('0x00000000000000000000000000000000000000000000000000000000abf52baf'),
|
|
96
|
+
* })
|
|
97
|
+
*
|
|
98
|
+
* valid
|
|
99
|
+
* // @log: true
|
|
100
|
+
* ```
|
|
101
|
+
*
|
|
102
|
+
* @param value - Master address and salt.
|
|
103
|
+
* @returns `true` if the first 4 bytes of the registration hash are zero.
|
|
104
|
+
*/
|
|
105
|
+
export declare function validateSalt(value: validateSalt.Value): boolean;
|
|
106
|
+
export declare namespace validateSalt {
|
|
107
|
+
type Value = getRegistrationHash.Value;
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* Searches a bounded range of salts for the first value that satisfies TIP-1022 PoW.
|
|
111
|
+
*
|
|
112
|
+
* [TIP-1022](https://tips.sh/1022)
|
|
113
|
+
*
|
|
114
|
+
* This is intentionally a small, deterministic primitive. It does not coordinate
|
|
115
|
+
* workers or async execution. Callers that need large searches can shard ranges
|
|
116
|
+
* externally.
|
|
117
|
+
*
|
|
118
|
+
* Master addresses must satisfy TIP-1022 registration constraints: they cannot
|
|
119
|
+
* be the zero address, another virtual address, or a TIP-20 token address.
|
|
120
|
+
*
|
|
121
|
+
* :::warning
|
|
122
|
+
*
|
|
123
|
+
* It is strongly recommended to use {@link ox#VirtualMaster.(mineSaltAsync:function)} instead of this
|
|
124
|
+
* function. `mineSaltAsync` uses WASM-accelerated keccak256 with parallel
|
|
125
|
+
* workers and is a lot faster than the pure JS implementation used here.
|
|
126
|
+
*
|
|
127
|
+
* :::
|
|
128
|
+
*
|
|
129
|
+
* @example
|
|
130
|
+
* ```ts twoslash
|
|
131
|
+
* import { Address } from 'ox'
|
|
132
|
+
* import { VirtualMaster } from 'ox/tempo'
|
|
133
|
+
*
|
|
134
|
+
* const result = VirtualMaster.mineSalt({
|
|
135
|
+
* address: '0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266',
|
|
136
|
+
* })
|
|
137
|
+
*
|
|
138
|
+
* result?.salt
|
|
139
|
+
* // @log: '0x00000000000000000000000000000000000000000000000000000000abf52baf'
|
|
140
|
+
* ```
|
|
141
|
+
*
|
|
142
|
+
* @param value - Search range parameters.
|
|
143
|
+
* @returns The first matching salt in the range, if any.
|
|
144
|
+
*/
|
|
145
|
+
export declare function mineSalt(value: mineSalt.Value): mineSalt.ReturnType | undefined;
|
|
146
|
+
export declare namespace mineSalt {
|
|
147
|
+
type Value = {
|
|
148
|
+
/** Master address. Accepts both hex and Tempo addresses. */
|
|
149
|
+
address: TempoAddress.Address;
|
|
150
|
+
/** Number of consecutive salts to try. */
|
|
151
|
+
count?: number | undefined;
|
|
152
|
+
/** Starting salt value. @default 0n */
|
|
153
|
+
start?: Salt | undefined;
|
|
154
|
+
};
|
|
155
|
+
type ReturnType = {
|
|
156
|
+
/** The 4-byte master identifier derived from the matching salt. */
|
|
157
|
+
masterId: Hex.Hex;
|
|
158
|
+
/** The matching registration hash. */
|
|
159
|
+
registrationHash: Hex.Hex;
|
|
160
|
+
/** The discovered 32-byte salt. */
|
|
161
|
+
salt: Hex.Hex;
|
|
162
|
+
};
|
|
163
|
+
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;
|
|
164
|
+
}
|
|
165
|
+
/**
|
|
166
|
+
* Searches for a salt that satisfies TIP-1022 PoW using parallel workers and
|
|
167
|
+
* WASM-accelerated keccak256.
|
|
168
|
+
*
|
|
169
|
+
* [TIP-1022](https://tips.sh/1022)
|
|
170
|
+
*
|
|
171
|
+
* Uses WASM-accelerated keccak256 with parallel
|
|
172
|
+
* workers when available. Falls back to chunked single-threaded mining in
|
|
173
|
+
* environments without worker support.
|
|
174
|
+
*
|
|
175
|
+
* - **Node.js / Bun / Deno**: Spawns `worker_threads` with inline WASM keccak256.
|
|
176
|
+
* - **Browsers**: Spawns Web Workers via Blob URLs with inline WASM keccak256.
|
|
177
|
+
*
|
|
178
|
+
* @example
|
|
179
|
+
* ```ts twoslash
|
|
180
|
+
* import { Address } from 'ox'
|
|
181
|
+
* import { VirtualMaster } from 'ox/tempo'
|
|
182
|
+
*
|
|
183
|
+
* const result = await VirtualMaster.mineSaltAsync({
|
|
184
|
+
* address: '0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266',
|
|
185
|
+
* })
|
|
186
|
+
* ```
|
|
187
|
+
*
|
|
188
|
+
* @param parameters - Search parameters.
|
|
189
|
+
* @returns The first matching salt, if any.
|
|
190
|
+
*/
|
|
191
|
+
export declare function mineSaltAsync(parameters: mineSaltAsync.Parameters): Promise<mineSalt.ReturnType | undefined>;
|
|
192
|
+
export declare namespace mineSaltAsync {
|
|
193
|
+
type Parameters = {
|
|
194
|
+
/** Master address. Accepts both hex and Tempo addresses. */
|
|
195
|
+
address: TempoAddress.Address;
|
|
196
|
+
/**
|
|
197
|
+
* Number of salts each worker processes before sending a progress update.
|
|
198
|
+
*
|
|
199
|
+
* @default 100_000
|
|
200
|
+
*/
|
|
201
|
+
chunkSize?: number | undefined;
|
|
202
|
+
/** Number of consecutive salts to try. @default 2 ** 32 */
|
|
203
|
+
count?: number | undefined;
|
|
204
|
+
/** Progress callback invoked after each completed chunk. */
|
|
205
|
+
onProgress?: ((progress: Progress) => void) | undefined;
|
|
206
|
+
/** AbortSignal for cancellation. */
|
|
207
|
+
signal?: AbortSignal | undefined;
|
|
208
|
+
/** Starting salt value. @default 0n */
|
|
209
|
+
start?: Salt | undefined;
|
|
210
|
+
/**
|
|
211
|
+
* Number of workers to use.
|
|
212
|
+
*
|
|
213
|
+
* Set to `0` or `1` to disable worker parallelism.
|
|
214
|
+
*
|
|
215
|
+
* @default os.availableParallelism() - 1
|
|
216
|
+
*/
|
|
217
|
+
workers?: number | undefined;
|
|
218
|
+
};
|
|
219
|
+
type Progress = {
|
|
220
|
+
/** Total attempts so far. */
|
|
221
|
+
attempts: number;
|
|
222
|
+
/** Configured chunk size. */
|
|
223
|
+
chunkSize: number;
|
|
224
|
+
/** Total count requested. */
|
|
225
|
+
count: number;
|
|
226
|
+
/** Elapsed time in milliseconds. */
|
|
227
|
+
elapsed: number;
|
|
228
|
+
/** Fraction complete (0–1). */
|
|
229
|
+
progress: number;
|
|
230
|
+
/** Hashes per second. */
|
|
231
|
+
rate: number;
|
|
232
|
+
/** Number of workers in use. */
|
|
233
|
+
workers: number;
|
|
234
|
+
};
|
|
235
|
+
type ErrorType = mineSalt.ErrorType | Errors.BaseError | Errors.GlobalErrorType;
|
|
236
|
+
}
|
|
237
|
+
//# sourceMappingURL=VirtualMaster.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"VirtualMaster.d.ts","sourceRoot":"","sources":["../../tempo/VirtualMaster.ts"],"names":[],"mappings":"AACA,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;AAErC,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;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;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,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AoC;QACpC,MAAM,CAAC,EAAE,WAAW,GAAG,SAAS,CAAA;QAChC,uCAAuC;QACvC,KAAK,CAAC,EAAE,IAAI,GAAG,SAAS,CAAA;QACxB;;;;;;WAMG;QACH,OAAO,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;KAC7B,CAAA;IAED,KAAK,QAAQ,GAAG;QACd,6BAA6B;QAC7B,QAAQ,EAAE,MAAM,CAAA;QAChB,6BAA6B;QAC7B,SAAS,EAAE,MAAM,CAAA;QACjB,6BAA6B;QAC7B,KAAK,EAAE,MAAM,CAAA;QACb,oCAAoC;QACpC,OAAO,EAAE,MAAM,CAAA;QACf,+BAA+B;QAC/B,QAAQ,EAAE,MAAM,CAAA;QAChB,yBAAyB;QACzB,IAAI,EAAE,MAAM,CAAA;QACZ,gCAAgC;QAChC,OAAO,EAAE,MAAM,CAAA;KAChB,CAAA;IAED,KAAK,SAAS,GACV,QAAQ,CAAC,SAAS,GAClB,MAAM,CAAC,SAAS,GAChB,MAAM,CAAC,eAAe,CAAA;CAC3B"}
|
package/_types/tempo/index.d.ts
CHANGED
|
@@ -128,6 +128,7 @@ export * as PoolId from './PoolId.js';
|
|
|
128
128
|
*
|
|
129
129
|
* @example
|
|
130
130
|
* ```ts twoslash
|
|
131
|
+
* import 'ox/window'
|
|
131
132
|
* import { Provider, RpcSchema } from 'ox'
|
|
132
133
|
* import { RpcSchemaTempo } from 'ox/tempo'
|
|
133
134
|
*
|
|
@@ -365,6 +366,59 @@ export * as TransactionRequest from './TransactionRequest.js';
|
|
|
365
366
|
* @category Reference
|
|
366
367
|
*/
|
|
367
368
|
export * as TxEnvelopeTempo from './TxEnvelopeTempo.js';
|
|
369
|
+
/**
|
|
370
|
+
* TIP-1022 virtual address encoding and parsing utilities.
|
|
371
|
+
*
|
|
372
|
+
* [TIP-1022](https://docs.tempo.xyz/protocol/tips/tip-1022)
|
|
373
|
+
*
|
|
374
|
+
* Virtual addresses reserve the following 20-byte layout:
|
|
375
|
+
* `[4-byte masterId][10-byte VIRTUAL_MAGIC][6-byte userTag]`.
|
|
376
|
+
* These helpers only operate on the reserved byte layout and do not query
|
|
377
|
+
* onchain registration state.
|
|
378
|
+
*
|
|
379
|
+
* @example
|
|
380
|
+
* ```ts twoslash
|
|
381
|
+
* import { TempoAddress, VirtualAddress } from 'ox/tempo'
|
|
382
|
+
*
|
|
383
|
+
* const masterId = '0x58e21090' // derived when the master registers
|
|
384
|
+
* const userTag = '0x010203040506' // operator-defined deposit identifier
|
|
385
|
+
*
|
|
386
|
+
* const address = VirtualAddress.from({
|
|
387
|
+
* masterId,
|
|
388
|
+
* userTag,
|
|
389
|
+
* })
|
|
390
|
+
*
|
|
391
|
+
* const tempoAddress = TempoAddress.format(address) // optional display format
|
|
392
|
+
* ```
|
|
393
|
+
*
|
|
394
|
+
* @category Reference
|
|
395
|
+
*/
|
|
396
|
+
export * as VirtualAddress from './VirtualAddress.js';
|
|
397
|
+
/**
|
|
398
|
+
* TIP-1022 master registration utilities.
|
|
399
|
+
*
|
|
400
|
+
* [TIP-1022](https://docs.tempo.xyz/protocol/tips/tip-1022)
|
|
401
|
+
*
|
|
402
|
+
* These utilities expose deterministic hashing and bounded salt mining helpers for
|
|
403
|
+
* `registerVirtualMaster(bytes32 salt)` without introducing any extra hashing dependency.
|
|
404
|
+
*
|
|
405
|
+
* @example
|
|
406
|
+
* ```ts twoslash
|
|
407
|
+
* import { Address, Hex } from 'ox'
|
|
408
|
+
* import { VirtualMaster } from 'ox/tempo'
|
|
409
|
+
*
|
|
410
|
+
* const registration = {
|
|
411
|
+
* address: Address.from('0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266'),
|
|
412
|
+
* salt: Hex.from('0x00000000000000000000000000000000000000000000000000000000abf52baf'),
|
|
413
|
+
* }
|
|
414
|
+
*
|
|
415
|
+
* const registrationHash = VirtualMaster.getRegistrationHash(registration) // keccak256(address || salt)
|
|
416
|
+
* const masterId = VirtualMaster.getMasterId(registration) // bytes [4:8] of the hash
|
|
417
|
+
* ```
|
|
418
|
+
*
|
|
419
|
+
* @category Reference
|
|
420
|
+
*/
|
|
421
|
+
export * as VirtualMaster from './VirtualMaster.js';
|
|
368
422
|
/**
|
|
369
423
|
* Zone ID utilities for converting between zone IDs and zone chain IDs.
|
|
370
424
|
*
|
|
@@ -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;AAC7D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsCG;AACH,OAAO,KAAK,gBAAgB,MAAM,uBAAuB,CAAA;AACzD;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,OAAO,KAAK,MAAM,MAAM,aAAa,CAAA;AAErC;;;;;;;;;;;;;;;;;;;GAmBG;AACH,OAAO,KAAK,MAAM,MAAM,aAAa,CAAA;AACrC
|
|
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;AAC7D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsCG;AACH,OAAO,KAAK,gBAAgB,MAAM,uBAAuB,CAAA;AACzD;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,OAAO,KAAK,MAAM,MAAM,aAAa,CAAA;AAErC;;;;;;;;;;;;;;;;;;;GAmBG;AACH,OAAO,KAAK,MAAM,MAAM,aAAa,CAAA;AACrC;;;;;;;;;;;;;;;;;;GAkBG;AACH,OAAO,KAAK,cAAc,MAAM,qBAAqB,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lbW9yeS1vcHQrFmNhbGwtaW5kaXJlY3Qtb3Zlcmxvbmc=";
|
|
3
|
+
/** Byte offset in WASM linear memory where mining I/O begins. */
|
|
4
|
+
export declare const dataOffset = 1024;
|
|
5
|
+
//# sourceMappingURL=mine.wasm.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mine.wasm.d.ts","sourceRoot":"","sources":["../../../tempo/internal/mine.wasm.ts"],"names":[],"mappings":"AAWA,8DAA8D;AAC9D,eAAO,MAAM,UAAU,iuGACysG,CAAA;AAEhuG,iEAAiE;AACjE,eAAO,MAAM,UAAU,OAAO,CAAA"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/** Message sent from a mining worker to the main thread. */
|
|
2
|
+
export type Message = {
|
|
3
|
+
type: 'done';
|
|
4
|
+
} | {
|
|
5
|
+
type: 'error';
|
|
6
|
+
message: string;
|
|
7
|
+
} | {
|
|
8
|
+
type: 'found';
|
|
9
|
+
result: {
|
|
10
|
+
/** The 4-byte master identifier. */
|
|
11
|
+
masterId: string;
|
|
12
|
+
/** The full 32-byte registration hash. */
|
|
13
|
+
registrationHash: string;
|
|
14
|
+
/** The discovered 32-byte salt. */
|
|
15
|
+
salt: string;
|
|
16
|
+
};
|
|
17
|
+
} | {
|
|
18
|
+
type: 'progress';
|
|
19
|
+
attempts: number;
|
|
20
|
+
};
|
|
21
|
+
/** A platform-agnostic worker pool for parallel salt mining. */
|
|
22
|
+
export type Pool = {
|
|
23
|
+
spawn(index: number, onMessage: (msg: Message) => void, onError: (err: unknown) => void): {
|
|
24
|
+
postMessage(data: unknown): void;
|
|
25
|
+
terminate(): void;
|
|
26
|
+
};
|
|
27
|
+
};
|
|
28
|
+
/**
|
|
29
|
+
* Resolves the best available worker pool for the current runtime.
|
|
30
|
+
*
|
|
31
|
+
* @internal
|
|
32
|
+
*/
|
|
33
|
+
export declare function resolve(): Promise<Pool | undefined>;
|
|
34
|
+
/**
|
|
35
|
+
* Creates a worker pool backed by Node.js `worker_threads`.
|
|
36
|
+
*
|
|
37
|
+
* @internal
|
|
38
|
+
*/
|
|
39
|
+
export declare function resolveNode(): Promise<Pool | undefined>;
|
|
40
|
+
/**
|
|
41
|
+
* Creates a worker pool backed by browser `Worker` with Blob URLs.
|
|
42
|
+
*
|
|
43
|
+
* @internal
|
|
44
|
+
*/
|
|
45
|
+
export declare function resolveBrowser(): Promise<Pool | undefined>;
|
|
46
|
+
//# sourceMappingURL=virtualMasterPool.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"virtualMasterPool.d.ts","sourceRoot":"","sources":["../../../tempo/internal/virtualMasterPool.ts"],"names":[],"mappings":"AAEA,4DAA4D;AAC5D,MAAM,MAAM,OAAO,GACf;IAAE,IAAI,EAAE,MAAM,CAAA;CAAE,GAChB;IAAE,IAAI,EAAE,OAAO,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,GAClC;IACE,IAAI,EAAE,OAAO,CAAA;IACb,MAAM,EAAE;QACN,oCAAoC;QACpC,QAAQ,EAAE,MAAM,CAAA;QAChB,0CAA0C;QAC1C,gBAAgB,EAAE,MAAM,CAAA;QACxB,mCAAmC;QACnC,IAAI,EAAE,MAAM,CAAA;KACb,CAAA;CACF,GACD;IAAE,IAAI,EAAE,UAAU,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAA;CAAE,CAAA;AAE1C,gEAAgE;AAChE,MAAM,MAAM,IAAI,GAAG;IACjB,KAAK,CACH,KAAK,EAAE,MAAM,EACb,SAAS,EAAE,CAAC,GAAG,EAAE,OAAO,KAAK,IAAI,EACjC,OAAO,EAAE,CAAC,GAAG,EAAE,OAAO,KAAK,IAAI,GAC9B;QAAE,WAAW,CAAC,IAAI,EAAE,OAAO,GAAG,IAAI,CAAC;QAAC,SAAS,IAAI,IAAI,CAAA;KAAE,CAAA;CAC3D,CAAA;AAaD;;;;GAIG;AACH,wBAAsB,OAAO,IAAI,OAAO,CAAC,IAAI,GAAG,SAAS,CAAC,CAIzD;AAED;;;;GAIG;AACH,wBAAsB,WAAW,IAAI,OAAO,CAAC,IAAI,GAAG,SAAS,CAAC,CAkC7D;AAED;;;;GAIG;AACH,wBAAsB,cAAc,IAAI,OAAO,CAAC,IAAI,GAAG,SAAS,CAAC,CAwBhE"}
|
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.19",
|
|
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",
|
package/tempo/TxEnvelopeTempo.ts
CHANGED
|
@@ -162,10 +162,11 @@ export type Type = typeof type
|
|
|
162
162
|
*
|
|
163
163
|
* @example
|
|
164
164
|
* ```ts twoslash
|
|
165
|
+
* import { Address } from 'ox'
|
|
165
166
|
* import { TxEnvelopeTempo } from 'ox/tempo'
|
|
166
167
|
*
|
|
167
168
|
* TxEnvelopeTempo.assert({
|
|
168
|
-
* calls: [{ to: '
|
|
169
|
+
* calls: [{ to: Address.from('0x0000000000000000000000000000000000000000'), value: 0n }],
|
|
169
170
|
* chainId: 1,
|
|
170
171
|
* maxFeePerGas: 1000000000n,
|
|
171
172
|
* })
|
|
@@ -1023,12 +1024,13 @@ export declare namespace getFeePayerSignPayload {
|
|
|
1023
1024
|
*
|
|
1024
1025
|
* @example
|
|
1025
1026
|
* ```ts twoslash
|
|
1027
|
+
* import { Address } from 'ox'
|
|
1026
1028
|
* import { TxEnvelopeTempo } from 'ox/tempo'
|
|
1027
1029
|
*
|
|
1028
1030
|
* const valid = TxEnvelopeTempo.validate({
|
|
1029
1031
|
* calls: [{
|
|
1030
1032
|
* data: '0xdeadbeef',
|
|
1031
|
-
* to: '
|
|
1033
|
+
* to: Address.from('0x0000000000000000000000000000000000000000'),
|
|
1032
1034
|
* }],
|
|
1033
1035
|
* chainId: 1,
|
|
1034
1036
|
* maxFeePerGas: 1000000000n,
|
|
@@ -1077,10 +1079,11 @@ export class CallsEmptyError extends Errors.BaseError {
|
|
|
1077
1079
|
*
|
|
1078
1080
|
* @example
|
|
1079
1081
|
* ```ts twoslash
|
|
1082
|
+
* import { Address } from 'ox'
|
|
1080
1083
|
* import { TxEnvelopeTempo } from 'ox/tempo'
|
|
1081
1084
|
*
|
|
1082
1085
|
* TxEnvelopeTempo.assert({
|
|
1083
|
-
* calls: [{ to: '
|
|
1086
|
+
* calls: [{ to: Address.from('0x0000000000000000000000000000000000000000') }],
|
|
1084
1087
|
* chainId: 1,
|
|
1085
1088
|
* validBefore: 100,
|
|
1086
1089
|
* validAfter: 200,
|
|
@@ -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
|
+
})
|