tempo.ts 0.10.5 → 0.11.0

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 (224) hide show
  1. package/CHANGELOG.md +30 -0
  2. package/README.md +0 -41
  3. package/dist/viem/Account.d.ts +8 -3
  4. package/dist/viem/Account.d.ts.map +1 -1
  5. package/dist/viem/Account.js +9 -2
  6. package/dist/viem/Account.js.map +1 -1
  7. package/dist/viem/Actions/amm.d.ts +1 -1
  8. package/dist/viem/Actions/amm.d.ts.map +1 -1
  9. package/dist/viem/Actions/amm.js +1 -2
  10. package/dist/viem/Actions/amm.js.map +1 -1
  11. package/dist/viem/Actions/dex.d.ts +0 -35
  12. package/dist/viem/Actions/dex.d.ts.map +1 -1
  13. package/dist/viem/Actions/dex.js +0 -43
  14. package/dist/viem/Actions/dex.js.map +1 -1
  15. package/dist/viem/Actions/fee.d.ts +1 -1
  16. package/dist/viem/Actions/fee.d.ts.map +1 -1
  17. package/dist/viem/Actions/fee.js +1 -1
  18. package/dist/viem/Actions/fee.js.map +1 -1
  19. package/dist/viem/Actions/nonce.d.ts.map +1 -1
  20. package/dist/viem/Actions/nonce.js +6 -4
  21. package/dist/viem/Actions/nonce.js.map +1 -1
  22. package/dist/viem/Actions/token.d.ts +1 -2
  23. package/dist/viem/Actions/token.d.ts.map +1 -1
  24. package/dist/viem/Actions/token.js +1 -2
  25. package/dist/viem/Actions/token.js.map +1 -1
  26. package/dist/viem/Chain.d.ts +34 -34
  27. package/dist/viem/Chain.d.ts.map +1 -1
  28. package/dist/viem/Chain.js +2 -0
  29. package/dist/viem/Chain.js.map +1 -1
  30. package/dist/viem/Formatters.d.ts.map +1 -1
  31. package/dist/viem/Formatters.js +5 -3
  32. package/dist/viem/Formatters.js.map +1 -1
  33. package/dist/viem/Transaction.d.ts +8 -5
  34. package/dist/viem/Transaction.d.ts.map +1 -1
  35. package/dist/viem/Transaction.js +13 -3
  36. package/dist/viem/Transaction.js.map +1 -1
  37. package/dist/viem/internal/types.d.ts +1 -1
  38. package/dist/viem/internal/types.d.ts.map +1 -1
  39. package/dist/wagmi/Actions/dex.d.ts +1 -45
  40. package/dist/wagmi/Actions/dex.d.ts.map +1 -1
  41. package/dist/wagmi/Actions/dex.js +0 -55
  42. package/dist/wagmi/Actions/dex.js.map +1 -1
  43. package/dist/wagmi/Connector.d.ts +1 -1
  44. package/dist/wagmi/Connector.d.ts.map +1 -1
  45. package/dist/wagmi/Connector.js +1 -2
  46. package/dist/wagmi/Connector.js.map +1 -1
  47. package/dist/wagmi/Hooks/dex.d.ts +3 -46
  48. package/dist/wagmi/Hooks/dex.d.ts.map +1 -1
  49. package/dist/wagmi/Hooks/dex.js +2 -54
  50. package/dist/wagmi/Hooks/dex.js.map +1 -1
  51. package/dist/wagmi/index.d.ts +1 -1
  52. package/dist/wagmi/index.d.ts.map +1 -1
  53. package/dist/wagmi/index.js +1 -1
  54. package/dist/wagmi/index.js.map +1 -1
  55. package/package.json +5 -23
  56. package/src/viem/Account.test.ts +1 -1
  57. package/src/viem/Account.ts +11 -2
  58. package/src/viem/Actions/account.ts +1 -1
  59. package/src/viem/Actions/amm.ts +1 -2
  60. package/src/viem/Actions/dex.test.ts +1 -195
  61. package/src/viem/Actions/dex.ts +0 -53
  62. package/src/viem/Actions/fee.test.ts +2 -2
  63. package/src/viem/Actions/fee.ts +1 -1
  64. package/src/viem/Actions/nonce.test.ts +27 -14
  65. package/src/viem/Actions/nonce.ts +6 -4
  66. package/src/viem/Actions/token.test.ts +18 -52
  67. package/src/viem/Actions/token.ts +1 -2
  68. package/src/viem/Chain.ts +3 -1
  69. package/src/viem/Decorator.ts +0 -30
  70. package/src/viem/Formatters.ts +9 -3
  71. package/src/viem/Transaction.ts +23 -7
  72. package/src/viem/e2e.test.ts +19 -0
  73. package/src/viem/index.ts +12 -1
  74. package/src/viem/internal/types.ts +1 -1
  75. package/src/wagmi/Actions/dex.test.ts +0 -26
  76. package/src/wagmi/Actions/dex.ts +1 -111
  77. package/src/wagmi/Actions/nonce.test.ts +8 -4
  78. package/src/wagmi/Actions/token.test.ts +2 -2
  79. package/src/wagmi/Connector.ts +1 -2
  80. package/src/wagmi/Hooks/dex.test.ts +0 -26
  81. package/src/wagmi/Hooks/dex.ts +1 -88
  82. package/src/wagmi/Hooks/nonce.test.ts +3 -3
  83. package/src/wagmi/index.ts +4 -1
  84. package/dist/chains.d.ts +0 -73
  85. package/dist/chains.d.ts.map +0 -1
  86. package/dist/chains.js +0 -51
  87. package/dist/chains.js.map +0 -1
  88. package/dist/ox/AuthorizationTempo.d.ts +0 -450
  89. package/dist/ox/AuthorizationTempo.d.ts.map +0 -1
  90. package/dist/ox/AuthorizationTempo.js +0 -433
  91. package/dist/ox/AuthorizationTempo.js.map +0 -1
  92. package/dist/ox/KeyAuthorization.d.ts +0 -356
  93. package/dist/ox/KeyAuthorization.d.ts.map +0 -1
  94. package/dist/ox/KeyAuthorization.js +0 -359
  95. package/dist/ox/KeyAuthorization.js.map +0 -1
  96. package/dist/ox/Order.d.ts +0 -92
  97. package/dist/ox/Order.d.ts.map +0 -1
  98. package/dist/ox/Order.js +0 -88
  99. package/dist/ox/Order.js.map +0 -1
  100. package/dist/ox/OrdersFilters.d.ts +0 -72
  101. package/dist/ox/OrdersFilters.d.ts.map +0 -1
  102. package/dist/ox/OrdersFilters.js +0 -100
  103. package/dist/ox/OrdersFilters.js.map +0 -1
  104. package/dist/ox/Pagination.d.ts +0 -128
  105. package/dist/ox/Pagination.d.ts.map +0 -1
  106. package/dist/ox/Pagination.js +0 -78
  107. package/dist/ox/Pagination.js.map +0 -1
  108. package/dist/ox/PoolId.d.ts +0 -18
  109. package/dist/ox/PoolId.d.ts.map +0 -1
  110. package/dist/ox/PoolId.js +0 -13
  111. package/dist/ox/PoolId.js.map +0 -1
  112. package/dist/ox/RpcSchema.d.ts +0 -32
  113. package/dist/ox/RpcSchema.d.ts.map +0 -1
  114. package/dist/ox/RpcSchema.js +0 -2
  115. package/dist/ox/RpcSchema.js.map +0 -1
  116. package/dist/ox/SignatureEnvelope.d.ts +0 -260
  117. package/dist/ox/SignatureEnvelope.d.ts.map +0 -1
  118. package/dist/ox/SignatureEnvelope.js +0 -477
  119. package/dist/ox/SignatureEnvelope.js.map +0 -1
  120. package/dist/ox/Tick.d.ts +0 -115
  121. package/dist/ox/Tick.d.ts.map +0 -1
  122. package/dist/ox/Tick.js +0 -127
  123. package/dist/ox/Tick.js.map +0 -1
  124. package/dist/ox/TokenId.d.ts +0 -25
  125. package/dist/ox/TokenId.d.ts.map +0 -1
  126. package/dist/ox/TokenId.js +0 -41
  127. package/dist/ox/TokenId.js.map +0 -1
  128. package/dist/ox/TokenRole.d.ts +0 -11
  129. package/dist/ox/TokenRole.d.ts.map +0 -1
  130. package/dist/ox/TokenRole.js +0 -22
  131. package/dist/ox/TokenRole.js.map +0 -1
  132. package/dist/ox/Transaction.d.ts +0 -201
  133. package/dist/ox/Transaction.d.ts.map +0 -1
  134. package/dist/ox/Transaction.js +0 -167
  135. package/dist/ox/Transaction.js.map +0 -1
  136. package/dist/ox/TransactionEnvelopeTempo.d.ts +0 -470
  137. package/dist/ox/TransactionEnvelopeTempo.d.ts.map +0 -1
  138. package/dist/ox/TransactionEnvelopeTempo.js +0 -547
  139. package/dist/ox/TransactionEnvelopeTempo.js.map +0 -1
  140. package/dist/ox/TransactionReceipt.d.ts +0 -155
  141. package/dist/ox/TransactionReceipt.d.ts.map +0 -1
  142. package/dist/ox/TransactionReceipt.js +0 -136
  143. package/dist/ox/TransactionReceipt.js.map +0 -1
  144. package/dist/ox/TransactionRequest.d.ts +0 -76
  145. package/dist/ox/TransactionRequest.d.ts.map +0 -1
  146. package/dist/ox/TransactionRequest.js +0 -93
  147. package/dist/ox/TransactionRequest.js.map +0 -1
  148. package/dist/ox/index.d.ts +0 -14
  149. package/dist/ox/index.d.ts.map +0 -1
  150. package/dist/ox/index.js +0 -14
  151. package/dist/ox/index.js.map +0 -1
  152. package/dist/prool/Instance.d.ts +0 -101
  153. package/dist/prool/Instance.d.ts.map +0 -1
  154. package/dist/prool/Instance.js +0 -136
  155. package/dist/prool/Instance.js.map +0 -1
  156. package/dist/prool/chain.json +0 -238
  157. package/dist/prool/index.d.ts +0 -2
  158. package/dist/prool/index.d.ts.map +0 -1
  159. package/dist/prool/index.js +0 -2
  160. package/dist/prool/index.js.map +0 -1
  161. package/dist/viem/Actions/account.d.ts +0 -40
  162. package/dist/viem/Actions/account.d.ts.map +0 -1
  163. package/dist/viem/Actions/account.js +0 -86
  164. package/dist/viem/Actions/account.js.map +0 -1
  165. package/dist/viem/Actions/index.d.ts +0 -10
  166. package/dist/viem/Actions/index.d.ts.map +0 -1
  167. package/dist/viem/Actions/index.js +0 -10
  168. package/dist/viem/Actions/index.js.map +0 -1
  169. package/dist/viem/Decorator.d.ts +0 -2810
  170. package/dist/viem/Decorator.d.ts.map +0 -1
  171. package/dist/viem/Decorator.js +0 -138
  172. package/dist/viem/Decorator.js.map +0 -1
  173. package/dist/viem/P256.d.ts +0 -2
  174. package/dist/viem/P256.d.ts.map +0 -1
  175. package/dist/viem/P256.js +0 -2
  176. package/dist/viem/P256.js.map +0 -1
  177. package/dist/viem/Secp256k1.d.ts +0 -2
  178. package/dist/viem/Secp256k1.d.ts.map +0 -1
  179. package/dist/viem/Secp256k1.js +0 -2
  180. package/dist/viem/Secp256k1.js.map +0 -1
  181. package/dist/viem/TokenIds.d.ts +0 -2
  182. package/dist/viem/TokenIds.d.ts.map +0 -1
  183. package/dist/viem/TokenIds.js +0 -2
  184. package/dist/viem/TokenIds.js.map +0 -1
  185. package/dist/viem/index.d.ts +0 -17
  186. package/dist/viem/index.d.ts.map +0 -1
  187. package/dist/viem/index.js +0 -17
  188. package/dist/viem/index.js.map +0 -1
  189. package/src/ox/AuthorizationTempo.test.ts +0 -1256
  190. package/src/ox/AuthorizationTempo.ts +0 -648
  191. package/src/ox/KeyAuthorization.test.ts +0 -1332
  192. package/src/ox/KeyAuthorization.ts +0 -540
  193. package/src/ox/Order.test.ts +0 -78
  194. package/src/ox/Order.ts +0 -125
  195. package/src/ox/OrdersFilters.test.ts +0 -182
  196. package/src/ox/OrdersFilters.ts +0 -125
  197. package/src/ox/Pagination.test.ts +0 -162
  198. package/src/ox/Pagination.ts +0 -164
  199. package/src/ox/PoolId.test.ts +0 -33
  200. package/src/ox/PoolId.ts +0 -27
  201. package/src/ox/RpcSchema.ts +0 -35
  202. package/src/ox/SignatureEnvelope.test.ts +0 -1876
  203. package/src/ox/SignatureEnvelope.ts +0 -791
  204. package/src/ox/Tick.test.ts +0 -281
  205. package/src/ox/Tick.ts +0 -181
  206. package/src/ox/TokenId.test.ts +0 -40
  207. package/src/ox/TokenId.ts +0 -50
  208. package/src/ox/TokenRole.test.ts +0 -16
  209. package/src/ox/TokenRole.ts +0 -27
  210. package/src/ox/Transaction.test.ts +0 -523
  211. package/src/ox/Transaction.ts +0 -332
  212. package/src/ox/TransactionEnvelopeTempo.test.ts +0 -1352
  213. package/src/ox/TransactionEnvelopeTempo.ts +0 -905
  214. package/src/ox/TransactionReceipt.ts +0 -190
  215. package/src/ox/TransactionRequest.ts +0 -147
  216. package/src/ox/e2e.test.ts +0 -1393
  217. package/src/ox/index.ts +0 -13
  218. package/src/prool/Instance.test.ts +0 -43
  219. package/src/prool/Instance.ts +0 -247
  220. package/src/prool/chain.json +0 -238
  221. package/src/prool/index.ts +0 -1
  222. package/src/viem/Actions/__snapshots__/dex.test.ts.snap +0 -850
  223. package/src/wagmi/Actions/__snapshots__/dex.test.ts.snap +0 -310
  224. package/src/wagmi/Hooks/__snapshots__/dex.test.ts.snap +0 -457
@@ -1,100 +0,0 @@
1
- import * as Hex from 'ox/Hex';
2
- /**
3
- * Converts RPC-formatted orders filters to internal representation.
4
- *
5
- * @example
6
- * ```ts twoslash
7
- * import { OrdersRequest } from 'tempo.ts/ox'
8
- *
9
- * const filters = OrdersRequest.fromRpc({
10
- * baseToken: '0x20c0000000000000000000000000000000000001',
11
- * isBid: true,
12
- * remaining: {
13
- * min: '0x64',
14
- * max: '0x3e8',
15
- * },
16
- * })
17
- * // @log: { baseToken: '0x20c0...', isBid: true, remaining: { min: 100n, max: 1000n } }
18
- * ```
19
- *
20
- * @param filters - RPC-formatted filters.
21
- * @returns Internal filters representation.
22
- */
23
- export function fromRpc(filters) {
24
- const result = {};
25
- if (filters.baseToken !== undefined)
26
- result.baseToken = filters.baseToken;
27
- if (filters.isBid !== undefined)
28
- result.isBid = filters.isBid;
29
- if (filters.isFlip !== undefined)
30
- result.isFlip = filters.isFlip;
31
- if (filters.maker !== undefined)
32
- result.maker = filters.maker;
33
- if (filters.quoteToken !== undefined)
34
- result.quoteToken = filters.quoteToken;
35
- if (filters.remaining !== undefined) {
36
- const remaining = {};
37
- remaining.min =
38
- typeof filters.remaining.min === 'string'
39
- ? Hex.toBigInt(filters.remaining.min)
40
- : null;
41
- remaining.max =
42
- typeof filters.remaining.max === 'string'
43
- ? Hex.toBigInt(filters.remaining.max)
44
- : null;
45
- result.remaining = remaining;
46
- }
47
- if (filters.tick !== undefined)
48
- result.tick = filters.tick;
49
- return result;
50
- }
51
- /**
52
- * Converts internal orders filters to RPC format.
53
- *
54
- * @example
55
- * ```ts twoslash
56
- * import { OrdersRequest } from 'tempo.ts/ox'
57
- *
58
- * const rpcFilters = OrdersRequest.toRpc({
59
- * baseToken: '0x20c0000000000000000000000000000000000001',
60
- * isBid: true,
61
- * remaining: {
62
- * min: 100n,
63
- * max: 1000n,
64
- * },
65
- * })
66
- * // @log: { baseToken: '0x20c0...', isBid: true, remaining: { min: '0x64', max: '0x3e8' } }
67
- * ```
68
- *
69
- * @param filters - Internal filters representation.
70
- * @returns RPC-formatted filters.
71
- */
72
- export function toRpc(filters) {
73
- const result = {};
74
- if (filters.baseToken !== undefined)
75
- result.baseToken = filters.baseToken;
76
- if (filters.isBid !== undefined)
77
- result.isBid = filters.isBid;
78
- if (filters.isFlip !== undefined)
79
- result.isFlip = filters.isFlip;
80
- if (filters.maker !== undefined)
81
- result.maker = filters.maker;
82
- if (filters.quoteToken !== undefined)
83
- result.quoteToken = filters.quoteToken;
84
- if (filters.remaining !== undefined) {
85
- const remaining = {};
86
- remaining.min =
87
- typeof filters.remaining.min === 'bigint'
88
- ? Hex.fromNumber(filters.remaining.min)
89
- : null;
90
- remaining.max =
91
- typeof filters.remaining.max === 'bigint'
92
- ? Hex.fromNumber(filters.remaining.max)
93
- : null;
94
- result.remaining = remaining;
95
- }
96
- if (filters.tick !== undefined)
97
- result.tick = filters.tick;
98
- return result;
99
- }
100
- //# sourceMappingURL=OrdersFilters.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"OrdersFilters.js","sourceRoot":"","sources":["../../src/ox/OrdersFilters.ts"],"names":[],"mappings":"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"}
@@ -1,128 +0,0 @@
1
- import type * as Hex from 'ox/Hex';
2
- /**
3
- * Filter range for numeric values.
4
- */
5
- export type FilterRange<type> = {
6
- /** Maximum value (inclusive). */
7
- max?: type | null | undefined;
8
- /** Minimum value (inclusive). */
9
- min?: type | null | undefined;
10
- };
11
- /**
12
- * Sort order direction.
13
- */
14
- export type SortOrder = 'asc' | 'desc';
15
- /**
16
- * Sort configuration.
17
- */
18
- export type Sort<on extends string = string> = {
19
- /** A field the items are compared with. */
20
- on: on;
21
- /** An ordering direction. */
22
- order: SortOrder;
23
- };
24
- /**
25
- * Pagination parameters.
26
- */
27
- export type Params<filters extends Record<string, unknown> = Record<string, unknown>, cursor = Hex.Hex, sortOn extends string = string> = {
28
- /**
29
- * Cursor for pagination.
30
- *
31
- * Defaults to first entry based on the sort and filter configuration.
32
- * Use the `nextCursor` in response to get the next set of results.
33
- */
34
- cursor?: cursor | undefined;
35
- /** Determines which items should be yielded in the response. */
36
- filters?: filters | undefined;
37
- /**
38
- * Maximum number of items to return.
39
- *
40
- * Defaults to 10.
41
- * Maximum is 100.
42
- */
43
- limit?: number | undefined;
44
- /** Determines the order of the items yielded in the response. */
45
- sort?: Sort<sortOn> | undefined;
46
- };
47
- /**
48
- * Pagination response.
49
- */
50
- export type Response<key extends string, type, cursor = Hex.Hex> = {
51
- /** Cursor for next page, null if no more results. */
52
- nextCursor: cursor | null;
53
- } & {
54
- [K in key]: readonly type[];
55
- };
56
- /**
57
- * Converts internal pagination parameters to RPC format.
58
- *
59
- * @example
60
- * ```ts twoslash
61
- * import { OrdersFilters, Pagination } from 'tempo.ts/ox'
62
- *
63
- * const rpcParameters = Pagination.toRpcParameters({
64
- * cursor: '0x123',
65
- * limit: 50,
66
- * filters: {
67
- * baseToken: '0x20c0000000000000000000000000000000000001',
68
- * remaining: {
69
- * min: 100n,
70
- * max: 1000n,
71
- * },
72
- * },
73
- * }, {
74
- * toRpcFilters: OrdersFilters.toRpc,
75
- * })
76
- * // @log: { cursor: '0x123', limit: 50, filters: { baseToken: '0x20c0...', remaining: { min: '0x64', max: '0x3e8' } } }
77
- * ```
78
- *
79
- * @param request - Internal request representation.
80
- * @returns RPC-formatted request.
81
- */
82
- export declare function toRpcParameters<toRpcFilters extends (args: any) => any>(request: Params<Parameters<toRpcFilters>[0]>, options: toRpcParameters.Options<toRpcFilters>): Params<ReturnType<toRpcFilters>>;
83
- export declare namespace toRpcParameters {
84
- type Options<toRpcFilters extends (args: any) => any> = {
85
- toRpcFilters: toRpcFilters;
86
- };
87
- }
88
- /**
89
- * Converts RPC-formatted pagination response to internal representation.
90
- *
91
- * @example
92
- * ```ts twoslash
93
- * import { Order, Pagination } from 'tempo.ts/ox'
94
- *
95
- * const response = Pagination.fromRpcResponse({
96
- * nextCursor: '0x123',
97
- * items: [{
98
- * amount: '0x64',
99
- * baseToken: '0x20c0000000000000000000000000000000000001',
100
- * flipTick: 0,
101
- * isBid: true,
102
- * isFlip: false,
103
- * maker: '0x742d35Cc6634C0532925a3b844Bc9e7595f0bEb',
104
- * next: '0x0',
105
- * orderId: '0x1',
106
- * quoteToken: '0x20c0000000000000000000000000000000000002',
107
- * prev: '0x0',
108
- * remaining: '0x64',
109
- * tick: 100,
110
- * }],
111
- * }, {
112
- * fromRpc: Order.fromRpc,
113
- * })
114
- * // @log: { nextCursor: '0x123', items: [{ amount: 100n, orderId: 1n, ... }] }
115
- * ```
116
- *
117
- * @param response - RPC-formatted response.
118
- * @param options - Conversion options.
119
- * @returns Internal response representation.
120
- */
121
- export declare function fromRpcResponse<key extends string, fromRpc extends (args: any) => any>(response: Response<key, Parameters<fromRpc>[0]>, options: fromRpcResponse.Options<key, fromRpc>): Response<key, ReturnType<fromRpc>>;
122
- export declare namespace fromRpcResponse {
123
- type Options<key extends string, fromRpc extends (args: any) => any> = {
124
- key: key;
125
- fromRpc: fromRpc;
126
- };
127
- }
128
- //# sourceMappingURL=Pagination.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"Pagination.d.ts","sourceRoot":"","sources":["../../src/ox/Pagination.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,GAAG,MAAM,QAAQ,CAAA;AAElC;;GAEG;AACH,MAAM,MAAM,WAAW,CAAC,IAAI,IAAI;IAC9B,iCAAiC;IACjC,GAAG,CAAC,EAAE,IAAI,GAAG,IAAI,GAAG,SAAS,CAAA;IAC7B,iCAAiC;IACjC,GAAG,CAAC,EAAE,IAAI,GAAG,IAAI,GAAG,SAAS,CAAA;CAC9B,CAAA;AAED;;GAEG;AACH,MAAM,MAAM,SAAS,GAAG,KAAK,GAAG,MAAM,CAAA;AAEtC;;GAEG;AACH,MAAM,MAAM,IAAI,CAAC,EAAE,SAAS,MAAM,GAAG,MAAM,IAAI;IAC7C,2CAA2C;IAC3C,EAAE,EAAE,EAAE,CAAA;IACN,6BAA6B;IAC7B,KAAK,EAAE,SAAS,CAAA;CACjB,CAAA;AAED;;GAEG;AACH,MAAM,MAAM,MAAM,CAChB,OAAO,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EACjE,MAAM,GAAG,GAAG,CAAC,GAAG,EAChB,MAAM,SAAS,MAAM,GAAG,MAAM,IAC5B;IACF;;;;;OAKG;IACH,MAAM,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;IAC3B,gEAAgE;IAChE,OAAO,CAAC,EAAE,OAAO,GAAG,SAAS,CAAA;IAC7B;;;;;OAKG;IACH,KAAK,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;IAC1B,iEAAiE;IACjE,IAAI,CAAC,EAAE,IAAI,CAAC,MAAM,CAAC,GAAG,SAAS,CAAA;CAChC,CAAA;AAED;;GAEG;AACH,MAAM,MAAM,QAAQ,CAAC,GAAG,SAAS,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,GAAG,CAAC,GAAG,IAAI;IACjE,qDAAqD;IACrD,UAAU,EAAE,MAAM,GAAG,IAAI,CAAA;CAC1B,GAAG;KACD,CAAC,IAAI,GAAG,GAAG,SAAS,IAAI,EAAE;CAC5B,CAAA;AAED;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,wBAAgB,eAAe,CAAC,YAAY,SAAS,CAAC,IAAI,EAAE,GAAG,KAAK,GAAG,EACrE,OAAO,EAAE,MAAM,CAAC,UAAU,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,CAAC,EAC5C,OAAO,EAAE,eAAe,CAAC,OAAO,CAAC,YAAY,CAAC,GAC7C,MAAM,CAAC,UAAU,CAAC,YAAY,CAAC,CAAC,CAUlC;AAED,MAAM,CAAC,OAAO,WAAW,eAAe,CAAC;IACvC,KAAK,OAAO,CAAC,YAAY,SAAS,CAAC,IAAI,EAAE,GAAG,KAAK,GAAG,IAAI;QACtD,YAAY,EAAE,YAAY,CAAA;KAC3B,CAAA;CACF;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AACH,wBAAgB,eAAe,CAC7B,GAAG,SAAS,MAAM,EAClB,OAAO,SAAS,CAAC,IAAI,EAAE,GAAG,KAAK,GAAG,EAElC,QAAQ,EAAE,QAAQ,CAAC,GAAG,EAAE,UAAU,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,EAC/C,OAAO,EAAE,eAAe,CAAC,OAAO,CAAC,GAAG,EAAE,OAAO,CAAC,GAC7C,QAAQ,CAAC,GAAG,EAAE,UAAU,CAAC,OAAO,CAAC,CAAC,CAKpC;AAED,MAAM,CAAC,OAAO,WAAW,eAAe,CAAC;IACvC,KAAK,OAAO,CAAC,GAAG,SAAS,MAAM,EAAE,OAAO,SAAS,CAAC,IAAI,EAAE,GAAG,KAAK,GAAG,IAAI;QACrE,GAAG,EAAE,GAAG,CAAA;QACR,OAAO,EAAE,OAAO,CAAA;KACjB,CAAA;CACF"}
@@ -1,78 +0,0 @@
1
- /**
2
- * Converts internal pagination parameters to RPC format.
3
- *
4
- * @example
5
- * ```ts twoslash
6
- * import { OrdersFilters, Pagination } from 'tempo.ts/ox'
7
- *
8
- * const rpcParameters = Pagination.toRpcParameters({
9
- * cursor: '0x123',
10
- * limit: 50,
11
- * filters: {
12
- * baseToken: '0x20c0000000000000000000000000000000000001',
13
- * remaining: {
14
- * min: 100n,
15
- * max: 1000n,
16
- * },
17
- * },
18
- * }, {
19
- * toRpcFilters: OrdersFilters.toRpc,
20
- * })
21
- * // @log: { cursor: '0x123', limit: 50, filters: { baseToken: '0x20c0...', remaining: { min: '0x64', max: '0x3e8' } } }
22
- * ```
23
- *
24
- * @param request - Internal request representation.
25
- * @returns RPC-formatted request.
26
- */
27
- export function toRpcParameters(request, options) {
28
- const result = {};
29
- if (request.cursor !== undefined)
30
- result.cursor = request.cursor;
31
- if (request.limit !== undefined)
32
- result.limit = request.limit;
33
- if (request.sort !== undefined)
34
- result.sort = request.sort;
35
- if (request.filters !== undefined)
36
- result.filters = options.toRpcFilters(request.filters);
37
- return result;
38
- }
39
- /**
40
- * Converts RPC-formatted pagination response to internal representation.
41
- *
42
- * @example
43
- * ```ts twoslash
44
- * import { Order, Pagination } from 'tempo.ts/ox'
45
- *
46
- * const response = Pagination.fromRpcResponse({
47
- * nextCursor: '0x123',
48
- * items: [{
49
- * amount: '0x64',
50
- * baseToken: '0x20c0000000000000000000000000000000000001',
51
- * flipTick: 0,
52
- * isBid: true,
53
- * isFlip: false,
54
- * maker: '0x742d35Cc6634C0532925a3b844Bc9e7595f0bEb',
55
- * next: '0x0',
56
- * orderId: '0x1',
57
- * quoteToken: '0x20c0000000000000000000000000000000000002',
58
- * prev: '0x0',
59
- * remaining: '0x64',
60
- * tick: 100,
61
- * }],
62
- * }, {
63
- * fromRpc: Order.fromRpc,
64
- * })
65
- * // @log: { nextCursor: '0x123', items: [{ amount: 100n, orderId: 1n, ... }] }
66
- * ```
67
- *
68
- * @param response - RPC-formatted response.
69
- * @param options - Conversion options.
70
- * @returns Internal response representation.
71
- */
72
- export function fromRpcResponse(response, options) {
73
- return {
74
- nextCursor: response.nextCursor,
75
- [options.key]: response[options.key].map(options.fromRpc),
76
- };
77
- }
78
- //# sourceMappingURL=Pagination.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"Pagination.js","sourceRoot":"","sources":["../../src/ox/Pagination.ts"],"names":[],"mappings":"AAiEA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,MAAM,UAAU,eAAe,CAC7B,OAA4C,EAC5C,OAA8C;IAE9C,MAAM,MAAM,GAAqC,EAAE,CAAA;IAEnD,IAAI,OAAO,CAAC,MAAM,KAAK,SAAS;QAAE,MAAM,CAAC,MAAM,GAAG,OAAO,CAAC,MAAM,CAAA;IAChE,IAAI,OAAO,CAAC,KAAK,KAAK,SAAS;QAAE,MAAM,CAAC,KAAK,GAAG,OAAO,CAAC,KAAK,CAAA;IAC7D,IAAI,OAAO,CAAC,IAAI,KAAK,SAAS;QAAE,MAAM,CAAC,IAAI,GAAG,OAAO,CAAC,IAAI,CAAA;IAC1D,IAAI,OAAO,CAAC,OAAO,KAAK,SAAS;QAC/B,MAAM,CAAC,OAAO,GAAG,OAAO,CAAC,YAAY,CAAC,OAAO,CAAC,OAAO,CAAC,CAAA;IAExD,OAAO,MAAM,CAAA;AACf,CAAC;AAQD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AACH,MAAM,UAAU,eAAe,CAI7B,QAA+C,EAC/C,OAA8C;IAE9C,OAAO;QACL,UAAU,EAAE,QAAQ,CAAC,UAAU;QAC/B,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE,QAAQ,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,OAAO,CAAC;KACjD,CAAA;AACZ,CAAC"}
@@ -1,18 +0,0 @@
1
- import * as Hex from 'ox/Hex';
2
- import * as TokenId from './TokenId.js';
3
- /**
4
- * Converts a user token and validator token to a pool ID.
5
- *
6
- * @param value - User token and validator token.
7
- * @returns The pool ID.
8
- */
9
- export declare function from(value: from.Value): Hex.Hex;
10
- export declare namespace from {
11
- type Value = {
12
- /** User token. */
13
- userToken: TokenId.TokenIdOrAddress;
14
- /** Validator token. */
15
- validatorToken: TokenId.TokenIdOrAddress;
16
- };
17
- }
18
- //# sourceMappingURL=PoolId.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"PoolId.d.ts","sourceRoot":"","sources":["../../src/ox/PoolId.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,GAAG,MAAM,QAAQ,CAAA;AAC7B,OAAO,KAAK,OAAO,MAAM,cAAc,CAAA;AAEvC;;;;;GAKG;AACH,wBAAgB,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC,KAAK,GAAG,GAAG,CAAC,GAAG,CAO/C;AAED,MAAM,CAAC,OAAO,WAAW,IAAI,CAAC;IAC5B,KAAY,KAAK,GAAG;QAClB,kBAAkB;QAClB,SAAS,EAAE,OAAO,CAAC,gBAAgB,CAAA;QACnC,uBAAuB;QACvB,cAAc,EAAE,OAAO,CAAC,gBAAgB,CAAA;KACzC,CAAA;CACF"}
package/dist/ox/PoolId.js DELETED
@@ -1,13 +0,0 @@
1
- import * as Hash from 'ox/Hash';
2
- import * as Hex from 'ox/Hex';
3
- import * as TokenId from './TokenId.js';
4
- /**
5
- * Converts a user token and validator token to a pool ID.
6
- *
7
- * @param value - User token and validator token.
8
- * @returns The pool ID.
9
- */
10
- export function from(value) {
11
- return Hash.keccak256(Hex.concat(Hex.padLeft(TokenId.toAddress(value.userToken), 32), Hex.padLeft(TokenId.toAddress(value.validatorToken), 32)));
12
- }
13
- //# sourceMappingURL=PoolId.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"PoolId.js","sourceRoot":"","sources":["../../src/ox/PoolId.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,IAAI,MAAM,SAAS,CAAA;AAC/B,OAAO,KAAK,GAAG,MAAM,QAAQ,CAAA;AAC7B,OAAO,KAAK,OAAO,MAAM,cAAc,CAAA;AAEvC;;;;;GAKG;AACH,MAAM,UAAU,IAAI,CAAC,KAAiB;IACpC,OAAO,IAAI,CAAC,SAAS,CACnB,GAAG,CAAC,MAAM,CACR,GAAG,CAAC,OAAO,CAAC,OAAO,CAAC,SAAS,CAAC,KAAK,CAAC,SAAS,CAAC,EAAE,EAAE,CAAC,EACnD,GAAG,CAAC,OAAO,CAAC,OAAO,CAAC,SAAS,CAAC,KAAK,CAAC,cAAc,CAAC,EAAE,EAAE,CAAC,CACzD,CACF,CAAA;AACH,CAAC"}
@@ -1,32 +0,0 @@
1
- import type * as RpcSchema from 'ox/RpcSchema';
2
- import type { UnionToTuple } from '../internal/types.js';
3
- import type * as Order from './Order.js';
4
- import type * as OrdersFilters from './OrdersFilters.js';
5
- import type * as Pagination from './Pagination.js';
6
- /**
7
- * Union of all JSON-RPC Methods for the `dex_` namespace.
8
- */
9
- export type Dex = RpcSchema.From<{
10
- Request: {
11
- method: 'dex_getOrders';
12
- params: Pagination.Params<OrdersFilters.Rpc>;
13
- };
14
- ReturnType: Pagination.Response<'orders', Order.Rpc>;
15
- }>;
16
- /**
17
- * Viem-compatible RPC schema for the `dex_` namespace.
18
- */
19
- export type DexViem = ToViem<Dex>;
20
- type ToViem<schema extends RpcSchema.Generic> = UnionToTuple<schema> extends [
21
- infer head extends RpcSchema.Generic,
22
- ...infer tail extends RpcSchema.Generic[]
23
- ] ? [
24
- {
25
- Method: head['Request']['method'];
26
- Parameters: head['Request']['params'];
27
- ReturnType: head['ReturnType'];
28
- },
29
- ...ToViem<tail[number]>
30
- ] : [];
31
- export {};
32
- //# sourceMappingURL=RpcSchema.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"RpcSchema.d.ts","sourceRoot":"","sources":["../../src/ox/RpcSchema.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,SAAS,MAAM,cAAc,CAAA;AAC9C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAA;AACxD,OAAO,KAAK,KAAK,KAAK,MAAM,YAAY,CAAA;AACxC,OAAO,KAAK,KAAK,aAAa,MAAM,oBAAoB,CAAA;AACxD,OAAO,KAAK,KAAK,UAAU,MAAM,iBAAiB,CAAA;AAElD;;GAEG;AACH,MAAM,MAAM,GAAG,GAAG,SAAS,CAAC,IAAI,CAAC;IAC/B,OAAO,EAAE;QACP,MAAM,EAAE,eAAe,CAAA;QACvB,MAAM,EAAE,UAAU,CAAC,MAAM,CAAC,aAAa,CAAC,GAAG,CAAC,CAAA;KAC7C,CAAA;IACD,UAAU,EAAE,UAAU,CAAC,QAAQ,CAAC,QAAQ,EAAE,KAAK,CAAC,GAAG,CAAC,CAAA;CACrD,CAAC,CAAA;AAEF;;GAEG;AACH,MAAM,MAAM,OAAO,GAAG,MAAM,CAAC,GAAG,CAAC,CAAA;AAEjC,KAAK,MAAM,CAAC,MAAM,SAAS,SAAS,CAAC,OAAO,IAAI,YAAY,CAAC,MAAM,CAAC,SAAS;IAC3E,MAAM,IAAI,SAAS,SAAS,CAAC,OAAO;IACpC,GAAG,MAAM,IAAI,SAAS,SAAS,CAAC,OAAO,EAAE;CAC1C,GACG;IACE;QACE,MAAM,EAAE,IAAI,CAAC,SAAS,CAAC,CAAC,QAAQ,CAAC,CAAA;QACjC,UAAU,EAAE,IAAI,CAAC,SAAS,CAAC,CAAC,QAAQ,CAAC,CAAA;QACrC,UAAU,EAAE,IAAI,CAAC,YAAY,CAAC,CAAA;KAC/B;IACD,GAAG,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;CACxB,GACD,EAAE,CAAA"}
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=RpcSchema.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"RpcSchema.js","sourceRoot":"","sources":["../../src/ox/RpcSchema.ts"],"names":[],"mappings":""}
@@ -1,260 +0,0 @@
1
- import type * as Address from 'ox/Address';
2
- import * as Errors from 'ox/Errors';
3
- import * as Hex from 'ox/Hex';
4
- import type * as PublicKey from 'ox/PublicKey';
5
- import * as Signature from 'ox/Signature';
6
- import type * as WebAuthnP256 from 'ox/WebAuthnP256';
7
- import type { Assign, Compute, IsNarrowable, OneOf, PartialBy, UnionPartialBy } from '../internal/types.js';
8
- /**
9
- * Statically determines the signature type of an envelope at compile time.
10
- *
11
- * @example
12
- * ```ts twoslash
13
- * import type { SignatureEnvelope } from 'tempo.ts/ox'
14
- *
15
- * type Type = SignatureEnvelope.GetType<{ r: bigint; s: bigint; yParity: number }>
16
- * // @log: 'secp256k1'
17
- * ```
18
- */
19
- export type GetType<envelope extends PartialBy<SignatureEnvelope, 'type'> | unknown> = unknown extends envelope ? envelope extends unknown ? Type : never : envelope extends {
20
- type: infer T extends Type;
21
- } ? T : envelope extends {
22
- signature: {
23
- r: bigint;
24
- s: bigint;
25
- };
26
- prehash: boolean;
27
- publicKey: PublicKey.PublicKey;
28
- } ? 'p256' : envelope extends {
29
- signature: {
30
- r: bigint;
31
- s: bigint;
32
- };
33
- metadata: any;
34
- publicKey: PublicKey.PublicKey;
35
- } ? 'webAuthn' : envelope extends {
36
- r: bigint;
37
- s: bigint;
38
- yParity: number;
39
- } ? 'secp256k1' : envelope extends {
40
- signature: {
41
- r: bigint;
42
- s: bigint;
43
- yParity: number;
44
- };
45
- } ? 'secp256k1' : envelope extends {
46
- userAddress: Address.Address;
47
- } ? 'keychain' : never;
48
- /**
49
- * Represents a signature envelope that can contain different signature types.
50
- *
51
- * Supports:
52
- * - secp256k1: Standard ECDSA signature (65 bytes)
53
- * - p256: P256 signature with embedded public key and prehash flag (130 bytes)
54
- * - webAuthn: WebAuthn signature with variable-length authenticator data
55
- */
56
- export type SignatureEnvelope<bigintType = bigint, numberType = number> = OneOf<Secp256k1<bigintType, numberType> | P256<bigintType, numberType> | WebAuthn<bigintType, numberType> | Keychain<bigintType, numberType>>;
57
- /**
58
- * RPC-formatted signature envelope.
59
- */
60
- export type SignatureEnvelopeRpc = OneOf<Secp256k1Rpc | P256Rpc | WebAuthnRpc | KeychainRpc>;
61
- export type Keychain<bigintType = bigint, numberType = number> = {
62
- /** Root account address that this transaction is being executed for */
63
- userAddress: Address.Address;
64
- /** The actual signature from the access key (can be Secp256k1, P256, or WebAuthn) */
65
- inner: SignatureEnvelope<bigintType, numberType>;
66
- type: 'keychain';
67
- };
68
- export type KeychainRpc = {
69
- type: 'keychain';
70
- userAddress: Address.Address;
71
- signature: SignatureEnvelopeRpc;
72
- };
73
- export type P256<bigintType = bigint, numberType = number> = {
74
- prehash: boolean;
75
- publicKey: PublicKey.PublicKey;
76
- signature: Signature.Signature<false, bigintType, numberType>;
77
- type: 'p256';
78
- };
79
- export type P256Rpc = {
80
- prehash: boolean;
81
- pubKeyX: Hex.Hex;
82
- pubKeyY: Hex.Hex;
83
- r: Hex.Hex;
84
- s: Hex.Hex;
85
- type: 'p256';
86
- };
87
- export type Secp256k1<bigintType = bigint, numberType = number> = {
88
- signature: Signature.Signature<true, bigintType, numberType>;
89
- type: 'secp256k1';
90
- };
91
- export type Secp256k1Rpc = Compute<Signature.Rpc<true> & {
92
- v?: Hex.Hex | undefined;
93
- type: 'secp256k1';
94
- }>;
95
- export type Secp256k1Flat<bigintType = bigint, numberType = number> = Signature.Signature<true, bigintType, numberType> & {
96
- type?: 'secp256k1' | undefined;
97
- };
98
- export type WebAuthn<bigintType = bigint, numberType = number> = {
99
- metadata: Pick<WebAuthnP256.SignMetadata, 'authenticatorData' | 'clientDataJSON'>;
100
- signature: Signature.Signature<false, bigintType, numberType>;
101
- publicKey: PublicKey.PublicKey;
102
- type: 'webAuthn';
103
- };
104
- export type WebAuthnRpc = {
105
- pubKeyX: Hex.Hex;
106
- pubKeyY: Hex.Hex;
107
- r: Hex.Hex;
108
- s: Hex.Hex;
109
- type: 'webAuthn';
110
- webauthnData: Hex.Hex;
111
- };
112
- /** Hex-encoded serialized signature envelope. */
113
- export type Serialized = Hex.Hex;
114
- /** List of supported signature types. */
115
- export declare const types: readonly ["secp256k1", "p256", "webAuthn"];
116
- /** Union type of supported signature types. */
117
- export type Type = (typeof types)[number];
118
- /**
119
- * Asserts that a {@link SignatureEnvelope} is valid.
120
- *
121
- * @example
122
- * ```ts twoslash
123
- * import { SignatureEnvelope } from 'tempo.ts/ox'
124
- *
125
- * SignatureEnvelope.assert({
126
- * r: 0n,
127
- * s: 0n,
128
- * yParity: 0,
129
- * type: 'secp256k1',
130
- * })
131
- * ```
132
- *
133
- * @param envelope - The signature envelope to assert.
134
- * @throws {CoercionError} If the envelope type cannot be determined.
135
- */
136
- export declare function assert(envelope: PartialBy<SignatureEnvelope, 'type'>): void;
137
- export declare namespace assert {
138
- type ErrorType = CoercionError | MissingPropertiesError | Signature.assert.ErrorType | Errors.GlobalErrorType;
139
- }
140
- /**
141
- * Deserializes a hex-encoded signature envelope into a typed signature object.
142
- *
143
- * For backward compatibility:
144
- * - 65 bytes: secp256k1 signature (no type identifier)
145
- * - 130 bytes: P256 signature (1 byte type + 129 bytes data)
146
- * - 129+ bytes: WebAuthn signature (1 byte type + variable data)
147
- *
148
- * @param serialized - The hex-encoded signature envelope to deserialize.
149
- * @returns The deserialized signature envelope.
150
- * @throws {CoercionError} If the serialized value cannot be coerced to a valid signature envelope.
151
- */
152
- export declare function deserialize(serialized: Serialized): SignatureEnvelope;
153
- /**
154
- * Coerces a value to a signature envelope.
155
- *
156
- * Accepts either a serialized hex string or an existing signature envelope object.
157
- *
158
- * @param value - The value to coerce (either a hex string or signature envelope).
159
- * @returns The signature envelope.
160
- */
161
- export declare function from<const value extends from.Value>(value: value | from.Value): from.ReturnValue<value>;
162
- export declare namespace from {
163
- type Value = UnionPartialBy<SignatureEnvelope, 'type'> | Secp256k1Flat | Serialized;
164
- type ReturnValue<value extends Value> = Compute<OneOf<value extends Serialized ? SignatureEnvelope : value extends Secp256k1Flat ? Secp256k1 : IsNarrowable<value, SignatureEnvelope> extends true ? SignatureEnvelope : Assign<value, {
165
- readonly type: GetType<value>;
166
- }>>>;
167
- }
168
- /**
169
- * Converts an {@link SignatureEnvelopeRpc} to a {@link SignatureEnvelope}.
170
- *
171
- * @param envelope - The RPC signature envelope to convert.
172
- * @returns The signature envelope with bigint values.
173
- */
174
- export declare function fromRpc(envelope: SignatureEnvelopeRpc): SignatureEnvelope;
175
- export declare namespace fromRpc {
176
- type ErrorType = CoercionError | InvalidSerializedError | Signature.fromRpc.ErrorType | Errors.GlobalErrorType;
177
- }
178
- /**
179
- * Determines the signature type of an envelope.
180
- *
181
- * @param envelope - The signature envelope to inspect.
182
- * @returns The signature type ('secp256k1', 'p256', or 'webAuthn').
183
- * @throws {CoercionError} If the envelope type cannot be determined.
184
- */
185
- export declare function getType<envelope extends PartialBy<SignatureEnvelope, 'type'> | Secp256k1Flat | unknown>(envelope: envelope): GetType<envelope>;
186
- /**
187
- * Serializes a signature envelope to a hex-encoded string.
188
- *
189
- * For backward compatibility:
190
- * - secp256k1: encoded WITHOUT type identifier (65 bytes)
191
- * - P256: encoded WITH type identifier prefix (130 bytes)
192
- * - WebAuthn: encoded WITH type identifier prefix (variable length)
193
- *
194
- * @param envelope - The signature envelope to serialize.
195
- * @returns The hex-encoded serialized signature.
196
- * @throws {CoercionError} If the envelope cannot be serialized.
197
- */
198
- export declare function serialize(envelope: UnionPartialBy<SignatureEnvelope, 'prehash'>): Serialized;
199
- /**
200
- * Converts a {@link SignatureEnvelope} to an {@link SignatureEnvelopeRpc}.
201
- *
202
- * @param envelope - The signature envelope to convert.
203
- * @returns The RPC signature envelope with hex values.
204
- */
205
- export declare function toRpc(envelope: SignatureEnvelope): SignatureEnvelopeRpc;
206
- export declare namespace toRpc {
207
- type ErrorType = CoercionError | Signature.toRpc.ErrorType | Errors.GlobalErrorType;
208
- }
209
- /**
210
- * Validates a {@link SignatureEnvelope}. Returns `true` if the envelope is valid, `false` otherwise.
211
- *
212
- * @example
213
- * ```ts twoslash
214
- * import { SignatureEnvelope } from 'tempo.ts/ox'
215
- *
216
- * const valid = SignatureEnvelope.validate({
217
- * signature: { r: 0n, s: 0n, yParity: 0 },
218
- * type: 'secp256k1',
219
- * })
220
- * // @log: true
221
- * ```
222
- *
223
- * @param envelope - The signature envelope to validate.
224
- * @returns `true` if valid, `false` otherwise.
225
- */
226
- export declare function validate(envelope: PartialBy<SignatureEnvelope, 'type'>): boolean;
227
- export declare namespace validate {
228
- type ErrorType = Errors.GlobalErrorType;
229
- }
230
- /**
231
- * Error thrown when a signature envelope cannot be coerced to a valid type.
232
- */
233
- export declare class CoercionError extends Errors.BaseError {
234
- readonly name = "SignatureEnvelope.CoercionError";
235
- constructor({ envelope }: {
236
- envelope: unknown;
237
- });
238
- }
239
- /**
240
- * Error thrown when a signature envelope is missing required properties.
241
- */
242
- export declare class MissingPropertiesError extends Errors.BaseError {
243
- readonly name = "SignatureEnvelope.MissingPropertiesError";
244
- constructor({ envelope, missing, type, }: {
245
- envelope: unknown;
246
- missing: string[];
247
- type: Type;
248
- });
249
- }
250
- /**
251
- * Error thrown when a serialized signature envelope cannot be deserialized.
252
- */
253
- export declare class InvalidSerializedError extends Errors.BaseError {
254
- readonly name = "SignatureEnvelope.InvalidSerializedError";
255
- constructor({ reason, serialized, }: {
256
- reason: string;
257
- serialized: Hex.Hex;
258
- });
259
- }
260
- //# sourceMappingURL=SignatureEnvelope.d.ts.map