tempo.ts 0.0.6 → 0.1.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 (195) hide show
  1. package/dist/chains.d.ts +244 -541
  2. package/dist/chains.d.ts.map +1 -1
  3. package/dist/chains.js +10 -23
  4. package/dist/chains.js.map +1 -1
  5. package/dist/index.js.map +1 -1
  6. package/dist/ox/SignatureEnvelope.d.ts +245 -0
  7. package/dist/ox/SignatureEnvelope.d.ts.map +1 -0
  8. package/dist/ox/SignatureEnvelope.js +437 -0
  9. package/dist/ox/SignatureEnvelope.js.map +1 -0
  10. package/dist/ox/Transaction.d.ts +61 -24
  11. package/dist/ox/Transaction.d.ts.map +1 -1
  12. package/dist/ox/Transaction.js +63 -18
  13. package/dist/ox/Transaction.js.map +1 -1
  14. package/dist/ox/TransactionEnvelopeAA.d.ts +461 -0
  15. package/dist/ox/TransactionEnvelopeAA.d.ts.map +1 -0
  16. package/dist/ox/TransactionEnvelopeAA.js +528 -0
  17. package/dist/ox/TransactionEnvelopeAA.js.map +1 -0
  18. package/dist/ox/TransactionRequest.d.ts +7 -5
  19. package/dist/ox/TransactionRequest.d.ts.map +1 -1
  20. package/dist/ox/TransactionRequest.js +21 -12
  21. package/dist/ox/TransactionRequest.js.map +1 -1
  22. package/dist/ox/index.d.ts +5 -4
  23. package/dist/ox/index.d.ts.map +1 -1
  24. package/dist/ox/index.js +5 -4
  25. package/dist/ox/index.js.map +1 -1
  26. package/dist/prool/Instance.d.ts +0 -4
  27. package/dist/prool/Instance.d.ts.map +1 -1
  28. package/dist/prool/Instance.js +7 -7
  29. package/dist/prool/Instance.js.map +1 -1
  30. package/dist/prool/index.d.ts +1 -1
  31. package/dist/prool/index.d.ts.map +1 -1
  32. package/dist/prool/index.js +1 -1
  33. package/dist/prool/index.js.map +1 -1
  34. package/dist/viem/{abis.d.ts → Abis.d.ts} +523 -9
  35. package/dist/viem/Abis.d.ts.map +1 -0
  36. package/dist/viem/{abis.js → Abis.js} +321 -9
  37. package/dist/viem/Abis.js.map +1 -0
  38. package/dist/viem/{actions → Actions}/amm.d.ts +21 -21
  39. package/dist/viem/Actions/amm.d.ts.map +1 -0
  40. package/dist/viem/{actions → Actions}/amm.js +55 -43
  41. package/dist/viem/Actions/amm.js.map +1 -0
  42. package/dist/viem/Actions/dex.d.ts +3263 -0
  43. package/dist/viem/Actions/dex.d.ts.map +1 -0
  44. package/dist/viem/Actions/dex.js +1357 -0
  45. package/dist/viem/Actions/dex.js.map +1 -0
  46. package/dist/viem/{actions → Actions}/fee.d.ts +8 -8
  47. package/dist/viem/Actions/fee.d.ts.map +1 -0
  48. package/dist/viem/{actions → Actions}/fee.js +14 -13
  49. package/dist/viem/Actions/fee.js.map +1 -0
  50. package/dist/viem/Actions/index.d.ts +6 -0
  51. package/dist/viem/Actions/index.d.ts.map +1 -0
  52. package/dist/viem/Actions/index.js +6 -0
  53. package/dist/viem/Actions/index.js.map +1 -0
  54. package/dist/viem/{actions → Actions}/policy.d.ts +19 -19
  55. package/dist/viem/Actions/policy.d.ts.map +1 -0
  56. package/dist/viem/{actions → Actions}/policy.js +59 -46
  57. package/dist/viem/Actions/policy.js.map +1 -0
  58. package/dist/viem/{actions → Actions}/token.d.ts +3250 -700
  59. package/dist/viem/Actions/token.d.ts.map +1 -0
  60. package/dist/viem/{actions → Actions}/token.js +419 -83
  61. package/dist/viem/Actions/token.js.map +1 -0
  62. package/dist/viem/Addresses.d.ts +9 -0
  63. package/dist/viem/Addresses.d.ts.map +1 -0
  64. package/dist/viem/Addresses.js +9 -0
  65. package/dist/viem/Addresses.js.map +1 -0
  66. package/dist/viem/{chain.d.ts → Chain.d.ts} +81 -57
  67. package/dist/viem/Chain.d.ts.map +1 -0
  68. package/dist/viem/{chain.js → Chain.js} +7 -7
  69. package/dist/viem/Chain.js.map +1 -0
  70. package/dist/viem/{client.d.ts → Client.d.ts} +4 -4
  71. package/dist/viem/Client.d.ts.map +1 -0
  72. package/dist/viem/{client.js → Client.js} +3 -3
  73. package/dist/viem/Client.js.map +1 -0
  74. package/dist/viem/{decorator.d.ts → Decorator.d.ts} +507 -5
  75. package/dist/viem/Decorator.d.ts.map +1 -0
  76. package/dist/viem/{decorator.js → Decorator.js} +31 -5
  77. package/dist/viem/Decorator.js.map +1 -0
  78. package/dist/viem/{formatters.d.ts → Formatters.d.ts} +2 -2
  79. package/dist/viem/Formatters.d.ts.map +1 -0
  80. package/dist/viem/{formatters.js → Formatters.js} +24 -17
  81. package/dist/viem/Formatters.js.map +1 -0
  82. package/dist/viem/Tick.d.ts +111 -0
  83. package/dist/viem/Tick.d.ts.map +1 -0
  84. package/dist/viem/Tick.js +127 -0
  85. package/dist/viem/Tick.js.map +1 -0
  86. package/dist/viem/TokenIds.d.ts +3 -0
  87. package/dist/viem/TokenIds.d.ts.map +1 -0
  88. package/dist/viem/TokenIds.js +3 -0
  89. package/dist/viem/TokenIds.js.map +1 -0
  90. package/dist/viem/Transaction.d.ts +57 -0
  91. package/dist/viem/Transaction.d.ts.map +1 -0
  92. package/dist/viem/Transaction.js +137 -0
  93. package/dist/viem/Transaction.js.map +1 -0
  94. package/dist/viem/{transport.d.ts → Transport.d.ts} +3 -3
  95. package/dist/viem/Transport.d.ts.map +1 -0
  96. package/dist/viem/{transport.js → Transport.js} +3 -3
  97. package/dist/viem/Transport.js.map +1 -0
  98. package/dist/viem/index.d.ts +13 -9
  99. package/dist/viem/index.d.ts.map +1 -1
  100. package/dist/viem/index.js +13 -9
  101. package/dist/viem/index.js.map +1 -1
  102. package/dist/viem/{types.d.ts → internal/types.d.ts} +3 -3
  103. package/dist/viem/internal/types.d.ts.map +1 -0
  104. package/dist/viem/{types.js.map → internal/types.js.map} +1 -1
  105. package/dist/viem/internal/utils.d.ts.map +1 -0
  106. package/dist/viem/internal/utils.js.map +1 -0
  107. package/package.json +87 -101
  108. package/src/chains.ts +10 -24
  109. package/src/ox/SignatureEnvelope.test.ts +1252 -0
  110. package/src/ox/SignatureEnvelope.ts +709 -0
  111. package/src/ox/Transaction.test.ts +144 -89
  112. package/src/ox/Transaction.ts +104 -29
  113. package/src/ox/TransactionEnvelopeAA.test.ts +1533 -0
  114. package/src/ox/TransactionEnvelopeAA.ts +858 -0
  115. package/src/ox/TransactionRequest.ts +25 -17
  116. package/src/ox/index.ts +2 -1
  117. package/src/prool/Instance.ts +6 -14
  118. package/src/prool/internal/chain.json +101 -27
  119. package/src/viem/{abis.ts → Abis.ts} +322 -8
  120. package/src/viem/{actions → Actions}/amm.test.ts +65 -68
  121. package/src/viem/{actions → Actions}/amm.ts +72 -60
  122. package/src/viem/Actions/dex.test.ts +1608 -0
  123. package/src/viem/Actions/dex.ts +2026 -0
  124. package/src/viem/{actions → Actions}/fee.test.ts +34 -36
  125. package/src/viem/{actions → Actions}/fee.ts +18 -17
  126. package/src/viem/{actions → Actions}/index.ts +1 -0
  127. package/src/viem/{actions → Actions}/policy.test.ts +2 -2
  128. package/src/viem/{actions → Actions}/policy.ts +77 -64
  129. package/src/viem/{actions → Actions}/token.test.ts +403 -64
  130. package/src/viem/{actions → Actions}/token.ts +672 -133
  131. package/src/viem/Addresses.ts +9 -0
  132. package/src/viem/{chain.ts → Chain.ts} +6 -6
  133. package/src/viem/{client.bench-d.ts → Client.bench-d.ts} +2 -2
  134. package/src/viem/{client.test.ts → Client.test.ts} +31 -6
  135. package/src/viem/{client.ts → Client.ts} +1 -1
  136. package/src/viem/{decorator.bench-d.ts → Decorator.bench-d.ts} +2 -2
  137. package/src/viem/{decorator.test.ts → Decorator.test.ts} +1 -0
  138. package/src/viem/{decorator.ts → Decorator.ts} +586 -4
  139. package/src/viem/{formatters.ts → Formatters.ts} +31 -20
  140. package/src/viem/Tick.test.ts +281 -0
  141. package/src/viem/Tick.ts +176 -0
  142. package/src/viem/TokenIds.ts +2 -0
  143. package/src/viem/Transaction.ts +303 -0
  144. package/src/viem/{transport.ts → Transport.ts} +5 -5
  145. package/src/viem/e2e.test.ts +153 -78
  146. package/src/viem/index.ts +13 -9
  147. package/src/viem/{types.ts → internal/types.ts} +3 -3
  148. package/dist/ox/TransactionEnvelopeFeeToken.d.ts +0 -393
  149. package/dist/ox/TransactionEnvelopeFeeToken.d.ts.map +0 -1
  150. package/dist/ox/TransactionEnvelopeFeeToken.js +0 -452
  151. package/dist/ox/TransactionEnvelopeFeeToken.js.map +0 -1
  152. package/dist/viem/abis.d.ts.map +0 -1
  153. package/dist/viem/abis.js.map +0 -1
  154. package/dist/viem/actions/amm.d.ts.map +0 -1
  155. package/dist/viem/actions/amm.js.map +0 -1
  156. package/dist/viem/actions/fee.d.ts.map +0 -1
  157. package/dist/viem/actions/fee.js.map +0 -1
  158. package/dist/viem/actions/index.d.ts +0 -5
  159. package/dist/viem/actions/index.d.ts.map +0 -1
  160. package/dist/viem/actions/index.js +0 -5
  161. package/dist/viem/actions/index.js.map +0 -1
  162. package/dist/viem/actions/policy.d.ts.map +0 -1
  163. package/dist/viem/actions/policy.js.map +0 -1
  164. package/dist/viem/actions/token.d.ts.map +0 -1
  165. package/dist/viem/actions/token.js.map +0 -1
  166. package/dist/viem/addresses.d.ts +0 -8
  167. package/dist/viem/addresses.d.ts.map +0 -1
  168. package/dist/viem/addresses.js +0 -8
  169. package/dist/viem/addresses.js.map +0 -1
  170. package/dist/viem/chain.d.ts.map +0 -1
  171. package/dist/viem/chain.js.map +0 -1
  172. package/dist/viem/client.d.ts.map +0 -1
  173. package/dist/viem/client.js.map +0 -1
  174. package/dist/viem/decorator.d.ts.map +0 -1
  175. package/dist/viem/decorator.js.map +0 -1
  176. package/dist/viem/formatters.d.ts.map +0 -1
  177. package/dist/viem/formatters.js.map +0 -1
  178. package/dist/viem/transaction.d.ts +0 -54
  179. package/dist/viem/transaction.d.ts.map +0 -1
  180. package/dist/viem/transaction.js +0 -108
  181. package/dist/viem/transaction.js.map +0 -1
  182. package/dist/viem/transport.d.ts.map +0 -1
  183. package/dist/viem/transport.js.map +0 -1
  184. package/dist/viem/types.d.ts.map +0 -1
  185. package/dist/viem/utils.d.ts.map +0 -1
  186. package/dist/viem/utils.js.map +0 -1
  187. package/src/ox/TransactionEnvelopeFeeToken.test.ts +0 -1119
  188. package/src/ox/TransactionEnvelopeFeeToken.ts +0 -717
  189. package/src/prool/internal/consensus.toml +0 -32
  190. package/src/viem/addresses.ts +0 -10
  191. package/src/viem/transaction.ts +0 -253
  192. /package/dist/viem/{types.js → internal/types.js} +0 -0
  193. /package/dist/viem/{utils.d.ts → internal/utils.d.ts} +0 -0
  194. /package/dist/viem/{utils.js → internal/utils.js} +0 -0
  195. /package/src/viem/{utils.ts → internal/utils.ts} +0 -0
@@ -1,17 +1,17 @@
1
1
  import * as Hex from 'ox/Hex';
2
2
  import { formatTransaction as viem_formatTransaction, formatTransactionRequest as viem_formatTransactionRequest, } from 'viem';
3
3
  import { parseAccount } from 'viem/accounts';
4
- import * as ox_Transaction from "../ox/Transaction.js";
5
- import * as ox_TransactionRequest from "../ox/TransactionRequest.js";
6
- import { isTempoTransaction, } from "./transaction.js";
4
+ import * as ox_Transaction from '../ox/Transaction.js';
5
+ import * as ox_TransactionRequest from '../ox/TransactionRequest.js';
6
+ import { isTempo, } from './Transaction.js';
7
7
  export const formatTransaction = (transaction) => {
8
- if (!isTempoTransaction(transaction))
8
+ if (!isTempo(transaction))
9
9
  return viem_formatTransaction(transaction);
10
10
  const { feePayerSignature, gasPrice: _, nonce, ...tx } = ox_Transaction.fromRpc(transaction);
11
11
  return {
12
12
  ...tx,
13
13
  accessList: tx.accessList,
14
- authorizationList: tx.authorizationList.map((auth) => ({
14
+ authorizationList: tx.authorizationList?.map((auth) => ({
15
15
  ...auth,
16
16
  nonce: Number(auth.nonce),
17
17
  r: Hex.fromNumber(auth.r, { size: 32 }),
@@ -28,15 +28,20 @@ export const formatTransaction = (transaction) => {
28
28
  nonce: Number(nonce),
29
29
  typeHex: ox_Transaction.toRpcType[tx.type],
30
30
  type: tx.type,
31
- r: Hex.fromNumber(tx.r, { size: 32 }),
32
- s: Hex.fromNumber(tx.s, { size: 32 }),
33
- v: BigInt(tx.v ?? 27),
34
31
  };
35
32
  };
36
33
  export const formatTransactionRequest = (r, action) => {
37
34
  const request = r;
38
- if (!isTempoTransaction(request))
35
+ if (!isTempo(request))
39
36
  return viem_formatTransactionRequest(r, action);
37
+ if (action)
38
+ request.calls = request.calls ?? [
39
+ {
40
+ to: r.to || undefined,
41
+ value: r.value,
42
+ data: r.data,
43
+ },
44
+ ];
40
45
  const rpc = ox_TransactionRequest.toRpc({
41
46
  ...request,
42
47
  authorizationList: request.authorizationList?.map((auth) => ({
@@ -47,8 +52,16 @@ export const formatTransactionRequest = (r, action) => {
47
52
  yParity: Number(auth.yParity),
48
53
  })),
49
54
  nonce: request.nonce ? BigInt(request.nonce) : undefined,
50
- type: 'feeToken',
55
+ type: 'aa',
51
56
  });
57
+ if (action === 'estimateGas') {
58
+ rpc.maxFeePerGas = undefined;
59
+ rpc.maxPriorityFeePerGas = undefined;
60
+ }
61
+ // We rely on `calls` for AA transactions.
62
+ rpc.to = undefined;
63
+ rpc.data = undefined;
64
+ rpc.value = undefined;
52
65
  return {
53
66
  ...rpc,
54
67
  ...(request.feePayer
@@ -58,12 +71,6 @@ export const formatTransactionRequest = (r, action) => {
58
71
  : request.feePayer,
59
72
  }
60
73
  : {}),
61
- ...(action === 'estimateGas'
62
- ? {
63
- maxFeePerGas: undefined,
64
- maxPriorityFeePerGas: undefined,
65
- }
66
- : {}),
67
74
  };
68
75
  };
69
- //# sourceMappingURL=formatters.js.map
76
+ //# sourceMappingURL=Formatters.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Formatters.js","sourceRoot":"","sources":["../../src/viem/Formatters.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,GAAG,MAAM,QAAQ,CAAA;AAC7B,OAAO,EACL,iBAAiB,IAAI,sBAAsB,EAC3C,wBAAwB,IAAI,6BAA6B,GAC1D,MAAM,MAAM,CAAA;AACb,OAAO,EAAE,YAAY,EAAE,MAAM,eAA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AAI,MAAM,KAAK,aAAa,EAAE,CAAC;QAC7B,GAAG,CAAC,YAAY,GAAG,SAAS,CAAA;QAC5B,GAAG,CAAC,oBAAoB,GAAG,SAAS,CAAA;IACtC,CAAC;IAED,0CAA0C;IAC1C,GAAG,CAAC,EAAE,GAAG,SAAS,CAAA;IAClB,GAAG,CAAC,IAAI,GAAG,SAAS,CAAA;IACpB,GAAG,CAAC,KAAK,GAAG,SAAS,CAAA;IAErB,OAAO;QACL,GAAG,GAAG;QACN,GAAG,CAAC,OAAO,CAAC,QAAQ;YAClB,CAAC,CAAC;gBACE,QAAQ,EACN,OAAO,OAAO,CAAC,QAAQ,KAAK,QAAQ;oBAClC,CAAC,CAAC,YAAY,CAAC,OAAO,CAAC,QAAQ,CAAC;oBAChC,CAAC,CAAC,OAAO,CAAC,QAAQ;aACvB;YACH,CAAC,CAAC,EAAE,CAAC;KACC,CAAA;AACZ,CAAC,CAAA"}
@@ -0,0 +1,111 @@
1
+ import * as Errors from 'ox/Errors';
2
+ /**
3
+ * Minimum allowed tick value.
4
+ */
5
+ export declare const minTick = -2000;
6
+ /**
7
+ * Maximum allowed tick value.
8
+ */
9
+ export declare const maxTick = 2000;
10
+ /**
11
+ * Price scaling factor (5 decimal places for 0.1 bps precision).
12
+ *
13
+ * @description
14
+ * The DEX uses a tick-based pricing system where:
15
+ * - Tick size: 0.1 bps (basis points)
16
+ * - Price range: ±2% from 1.0 (ticks from -2000 to +2000)
17
+ */
18
+ export declare const priceScale = 100000;
19
+ /**
20
+ * Converts a tick to a price string.
21
+ *
22
+ * @example
23
+ * ```ts
24
+ * import { Tick } from 'tempo.ts/viem'
25
+ *
26
+ * // Tick 0 = price of 1.0
27
+ * const price1 = Tick.toPrice(0) // "1"
28
+ *
29
+ * // Tick 100 = price of 1.001 (0.1% higher)
30
+ * const price2 = Tick.toPrice(100) // "1.001"
31
+ *
32
+ * // Tick -100 = price of 0.999 (0.1% lower)
33
+ * const price3 = Tick.toPrice(-100) // "0.999"
34
+ * ```
35
+ *
36
+ * @param tick - The tick value (range: -2000 to +2000).
37
+ * @returns The price as a string with exact decimal representation.
38
+ * @throws {TickOutOfBoundsError} If tick is out of bounds.
39
+ */
40
+ export declare function toPrice(tick: toPrice.Tick): toPrice.ReturnType;
41
+ export declare namespace toPrice {
42
+ type Tick = number;
43
+ type ReturnType = string;
44
+ }
45
+ /**
46
+ * Converts a price string to a tick.
47
+ *
48
+ * @example
49
+ * ```ts
50
+ * import { Tick } from 'tempo.ts/viem'
51
+ *
52
+ * // Price of 1.0 = tick 0
53
+ * const tick1 = Tick.fromPrice('1.0') // 0
54
+ * const tick2 = Tick.fromPrice('1.00000') // 0
55
+ *
56
+ * // Price of 1.001 = tick 100
57
+ * const tick3 = Tick.fromPrice('1.001') // 100
58
+ *
59
+ * // Price of 0.999 = tick -100
60
+ * const tick4 = Tick.fromPrice('0.999') // -100
61
+ * ```
62
+ *
63
+ * @param price - The price as a string (e.g., "1.001", "0.999").
64
+ * @returns The tick value.
65
+ * @throws {InvalidPriceTypeError} If the price is not a string.
66
+ * @throws {InvalidPriceFormatError} If the price format is invalid.
67
+ * @throws {PriceOutOfBoundsError} If the resulting tick is out of bounds.
68
+ */
69
+ export declare function fromPrice(price: fromPrice.Price): fromPrice.ReturnType;
70
+ export declare namespace fromPrice {
71
+ type Price = string;
72
+ type ReturnType = number;
73
+ }
74
+ /**
75
+ * Error thrown when a tick value is out of the allowed bounds.
76
+ */
77
+ export declare class TickOutOfBoundsError extends Errors.BaseError {
78
+ readonly name = "Tick.TickOutOfBoundsError";
79
+ constructor(options: TickOutOfBoundsError.Options);
80
+ }
81
+ export declare namespace TickOutOfBoundsError {
82
+ type Options = {
83
+ tick: number;
84
+ };
85
+ }
86
+ /**
87
+ * Error thrown when a price string has an invalid format.
88
+ */
89
+ export declare class InvalidPriceFormatError extends Errors.BaseError {
90
+ readonly name = "Tick.InvalidPriceFormatError";
91
+ constructor(options: InvalidPriceFormatError.Options);
92
+ }
93
+ export declare namespace InvalidPriceFormatError {
94
+ type Options = {
95
+ price: string;
96
+ };
97
+ }
98
+ /**
99
+ * Error thrown when a price string results in an out-of-bounds tick.
100
+ */
101
+ export declare class PriceOutOfBoundsError extends Errors.BaseError {
102
+ readonly name = "Tick.PriceOutOfBoundsError";
103
+ constructor(options: PriceOutOfBoundsError.Options);
104
+ }
105
+ export declare namespace PriceOutOfBoundsError {
106
+ type Options = {
107
+ price: string;
108
+ tick: number;
109
+ };
110
+ }
111
+ //# sourceMappingURL=Tick.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Tick.d.ts","sourceRoot":"","sources":["../../src/viem/Tick.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,WAAW,CAAA;AAEnC;;GAEG;AACH,eAAO,MAAM,OAAO,QAAQ,CAAA;AAE5B;;GAEG;AACH,eAAO,MAAM,OAAO,OAAO,CAAA;AAE3B;;;;;;;GAOG;AACH,eAAO,MAAM,UAAU,SAAU,CAAA;AAEjC;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,OAAO,CAAC,IAAI,EAAE,OAAO,CAAC,IAAI,GAAG,OAAO,CAAC,UAAU,CAa9D;AAED,MAAM,CAAC,OAAO,WAAW,OAAO,CAAC;IAC/B,KAAY,IAAI,GAAG,MAAM,CAAA;IACzB,KAAY,UAAU,GAAG,MAAM,CAAA;CAChC;AAED;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,wBAAgB,SAAS,CAAC,KAAK,EAAE,SAAS,CAAC,KAAK,GAAG,SAAS,CAAC,UAAU,CAsBtE;AAED,MAAM,CAAC,OAAO,WAAW,SAAS,CAAC;IACjC,KAAY,KAAK,GAAG,MAAM,CAAA;IAC1B,KAAY,UAAU,GAAG,MAAM,CAAA;CAChC;AAED;;GAEG;AACH,qBAAa,oBAAqB,SAAQ,MAAM,CAAC,SAAS;IACxD,SAAkB,IAAI,+BAA8B;gBAExC,OAAO,EAAE,oBAAoB,CAAC,OAAO;CAKlD;AAED,MAAM,CAAC,OAAO,WAAW,oBAAoB,CAAC;IAC5C,KAAY,OAAO,GAAG;QACpB,IAAI,EAAE,MAAM,CAAA;KACb,CAAA;CACF;AAED;;GAEG;AACH,qBAAa,uBAAwB,SAAQ,MAAM,CAAC,SAAS;IAC3D,SAAkB,IAAI,kCAAiC;gBAE3C,OAAO,EAAE,uBAAuB,CAAC,OAAO;CAKrD;AAED,MAAM,CAAC,OAAO,WAAW,uBAAuB,CAAC;IAC/C,KAAY,OAAO,GAAG;QACpB,KAAK,EAAE,MAAM,CAAA;KACd,CAAA;CACF;AAED;;GAEG;AACH,qBAAa,qBAAsB,SAAQ,MAAM,CAAC,SAAS;IACzD,SAAkB,IAAI,gCAA+B;gBAEzC,OAAO,EAAE,qBAAqB,CAAC,OAAO;CAQnD;AAED,MAAM,CAAC,OAAO,WAAW,qBAAqB,CAAC;IAC7C,KAAY,OAAO,GAAG;QACpB,KAAK,EAAE,MAAM,CAAA;QACb,IAAI,EAAE,MAAM,CAAA;KACb,CAAA;CACF"}
@@ -0,0 +1,127 @@
1
+ import * as Errors from 'ox/Errors';
2
+ /**
3
+ * Minimum allowed tick value.
4
+ */
5
+ export const minTick = -2000;
6
+ /**
7
+ * Maximum allowed tick value.
8
+ */
9
+ export const maxTick = 2000;
10
+ /**
11
+ * Price scaling factor (5 decimal places for 0.1 bps precision).
12
+ *
13
+ * @description
14
+ * The DEX uses a tick-based pricing system where:
15
+ * - Tick size: 0.1 bps (basis points)
16
+ * - Price range: ±2% from 1.0 (ticks from -2000 to +2000)
17
+ */
18
+ export const priceScale = 100_000;
19
+ /**
20
+ * Converts a tick to a price string.
21
+ *
22
+ * @example
23
+ * ```ts
24
+ * import { Tick } from 'tempo.ts/viem'
25
+ *
26
+ * // Tick 0 = price of 1.0
27
+ * const price1 = Tick.toPrice(0) // "1"
28
+ *
29
+ * // Tick 100 = price of 1.001 (0.1% higher)
30
+ * const price2 = Tick.toPrice(100) // "1.001"
31
+ *
32
+ * // Tick -100 = price of 0.999 (0.1% lower)
33
+ * const price3 = Tick.toPrice(-100) // "0.999"
34
+ * ```
35
+ *
36
+ * @param tick - The tick value (range: -2000 to +2000).
37
+ * @returns The price as a string with exact decimal representation.
38
+ * @throws {TickOutOfBoundsError} If tick is out of bounds.
39
+ */
40
+ export function toPrice(tick) {
41
+ if (tick < minTick || tick > maxTick) {
42
+ throw new TickOutOfBoundsError({ tick });
43
+ }
44
+ // Use integer arithmetic to avoid floating point errors
45
+ const price = priceScale + tick;
46
+ const whole = Math.floor(price / priceScale);
47
+ let decimal = (price % priceScale).toString().padStart(5, '0');
48
+ decimal = decimal.replace(/0+$/, '');
49
+ if (decimal.length === 0)
50
+ return whole.toString();
51
+ return `${whole}.${decimal}`;
52
+ }
53
+ /**
54
+ * Converts a price string to a tick.
55
+ *
56
+ * @example
57
+ * ```ts
58
+ * import { Tick } from 'tempo.ts/viem'
59
+ *
60
+ * // Price of 1.0 = tick 0
61
+ * const tick1 = Tick.fromPrice('1.0') // 0
62
+ * const tick2 = Tick.fromPrice('1.00000') // 0
63
+ *
64
+ * // Price of 1.001 = tick 100
65
+ * const tick3 = Tick.fromPrice('1.001') // 100
66
+ *
67
+ * // Price of 0.999 = tick -100
68
+ * const tick4 = Tick.fromPrice('0.999') // -100
69
+ * ```
70
+ *
71
+ * @param price - The price as a string (e.g., "1.001", "0.999").
72
+ * @returns The tick value.
73
+ * @throws {InvalidPriceTypeError} If the price is not a string.
74
+ * @throws {InvalidPriceFormatError} If the price format is invalid.
75
+ * @throws {PriceOutOfBoundsError} If the resulting tick is out of bounds.
76
+ */
77
+ export function fromPrice(price) {
78
+ const priceStr = price.trim();
79
+ if (!/^-?\d+(\.\d+)?$/.test(priceStr))
80
+ throw new InvalidPriceFormatError({ price });
81
+ // Parse price using string manipulation to avoid float precision issues
82
+ const [w, d = '0'] = priceStr.split('.');
83
+ const whole = BigInt(w);
84
+ // Pad or truncate decimal to exactly 5 digits
85
+ const decimal = BigInt(d.padEnd(5, '0').slice(0, 5));
86
+ // Calculate price
87
+ const priceInt = whole * BigInt(priceScale) + decimal;
88
+ // Calculate tick
89
+ const tick = Number(priceInt - BigInt(priceScale));
90
+ if (tick < minTick || tick > maxTick)
91
+ throw new PriceOutOfBoundsError({ price, tick });
92
+ return tick;
93
+ }
94
+ /**
95
+ * Error thrown when a tick value is out of the allowed bounds.
96
+ */
97
+ export class TickOutOfBoundsError extends Errors.BaseError {
98
+ name = 'Tick.TickOutOfBoundsError';
99
+ constructor(options) {
100
+ super(`Tick ${options.tick} is out of bounds.`, {
101
+ metaMessages: [`Tick must be between ${minTick} and ${maxTick}.`],
102
+ });
103
+ }
104
+ }
105
+ /**
106
+ * Error thrown when a price string has an invalid format.
107
+ */
108
+ export class InvalidPriceFormatError extends Errors.BaseError {
109
+ name = 'Tick.InvalidPriceFormatError';
110
+ constructor(options) {
111
+ super(`Invalid price format: "${options.price}".`, {
112
+ metaMessages: ['Price must be a decimal number string (e.g., "1.001").'],
113
+ });
114
+ }
115
+ }
116
+ /**
117
+ * Error thrown when a price string results in an out-of-bounds tick.
118
+ */
119
+ export class PriceOutOfBoundsError extends Errors.BaseError {
120
+ name = 'Tick.PriceOutOfBoundsError';
121
+ constructor(options) {
122
+ super(`Price "${options.price}" results in tick ${options.tick} which is out of bounds.`, {
123
+ metaMessages: [`Tick must be between ${minTick} and ${maxTick}.`],
124
+ });
125
+ }
126
+ }
127
+ //# sourceMappingURL=Tick.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Tick.js","sourceRoot":"","sources":["../../src/viem/Tick.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,WAAW,CAAA;AAEnC;;GAEG;AACH,MAAM,CAAC,MAAM,OAAO,GAAG,CAAC,IAAI,CAAA;AAE5B;;GAEG;AACH,MAAM,CAAC,MAAM,OAAO,GAAG,IAAI,CAAA;AAE3B;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,UAAU,GAAG,OAAO,CAAA;AAEjC;;;;;;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1
+ export declare const defaultFeeToken = 1n;
2
+ export declare const defaultQuoteToken = 0n;
3
+ //# sourceMappingURL=TokenIds.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TokenIds.d.ts","sourceRoot":"","sources":["../../src/viem/TokenIds.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,eAAe,KAAK,CAAA;AACjC,eAAO,MAAM,iBAAiB,KAAK,CAAA"}
@@ -0,0 +1,3 @@
1
+ export const defaultFeeToken = 1n;
2
+ export const defaultQuoteToken = 0n;
3
+ //# sourceMappingURL=TokenIds.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TokenIds.js","sourceRoot":"","sources":["../../src/viem/TokenIds.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,eAAe,GAAG,EAAE,CAAA;AACjC,MAAM,CAAC,MAAM,iBAAiB,GAAG,EAAE,CAAA"}
@@ -0,0 +1,57 @@
1
+ import * as Hex from 'ox/Hex';
2
+ import { type AccessList, type Account, type Address, type AuthorizationList, type FeeValuesEIP1559, type ParseTransactionReturnType, type SignedAuthorizationList, type TransactionBase, type TransactionRequestBase, type TransactionSerializableBase, type TransactionSerializedGeneric, type RpcTransaction as viem_RpcTransaction, type RpcTransactionRequest as viem_RpcTransactionRequest, type Signature as viem_Signature, type Transaction as viem_Transaction, type TransactionRequest as viem_TransactionRequest, type TransactionSerializable as viem_TransactionSerializable, type TransactionSerialized as viem_TransactionSerialized, type TransactionType as viem_TransactionType } from 'viem';
3
+ import type { ExactPartial, OneOf, PartialBy } from '../internal/types.js';
4
+ import * as SignatureEnvelope from '../ox/SignatureEnvelope.js';
5
+ import * as TxAA from '../ox/TransactionEnvelopeAA.js';
6
+ export type Transaction<bigintType = bigint, numberType = number, pending extends boolean = false> = OneOf<viem_Transaction<bigintType, numberType, pending> | TransactionAA<bigintType, numberType, pending>>;
7
+ export type TransactionRpc<pending extends boolean = false> = OneOf<viem_RpcTransaction<pending> | TransactionAA<Hex.Hex, Hex.Hex, pending, '0x76'>>;
8
+ export type TransactionAA<quantity = bigint, index = number, isPending extends boolean = boolean, type = 'aa'> = PartialBy<Omit<TransactionBase<quantity, index, isPending>, 'data' | 'input' | 'value' | 'to'>, 'r' | 's' | 'v' | 'yParity'> & {
9
+ accessList: AccessList;
10
+ authorizationList?: SignedAuthorizationList | undefined;
11
+ calls: readonly TxAA.Call<quantity>[];
12
+ chainId: index;
13
+ feeToken?: Address | undefined;
14
+ feePayer?: Address | undefined;
15
+ feePayerSignature?: viem_Signature | undefined;
16
+ nonceKey?: quantity | undefined;
17
+ type: type;
18
+ validBefore?: index | undefined;
19
+ validAfter?: index | undefined;
20
+ } & FeeValuesEIP1559<quantity>;
21
+ export type TransactionRequest<bigintType = bigint, numberType = number> = OneOf<viem_TransactionRequest<bigintType, numberType> | TransactionRequestAA<bigintType, numberType>>;
22
+ export type TransactionRequestRpc = OneOf<viem_RpcTransactionRequest | TransactionRequestAA<Hex.Hex, Hex.Hex, '0x76'>>;
23
+ export type TransactionRequestAA<quantity = bigint, index = number, type = 'aa'> = TransactionRequestBase<quantity, index, type> & ExactPartial<FeeValuesEIP1559<quantity>> & {
24
+ accessList?: AccessList | undefined;
25
+ authorizationList?: AuthorizationList<index, boolean> | undefined;
26
+ calls?: readonly TxAA.Call<quantity>[] | undefined;
27
+ feePayer?: Account | true | undefined;
28
+ feeToken?: Address | bigint | undefined;
29
+ };
30
+ export type TransactionSerializable = OneOf<viem_TransactionSerializable | TransactionSerializableAA>;
31
+ export type TransactionSerializableAA<quantity = bigint, index = number> = TransactionSerializableBase<quantity, index> & ExactPartial<FeeValuesEIP1559<quantity>> & {
32
+ accessList?: AccessList | undefined;
33
+ authorizationList?: SignedAuthorizationList | undefined;
34
+ calls: readonly TxAA.Call<quantity>[];
35
+ chainId: number;
36
+ feeToken?: Address | bigint | undefined;
37
+ feePayerSignature?: viem_Signature | null | undefined;
38
+ nonceKey?: quantity | undefined;
39
+ signature?: SignatureEnvelope.SignatureEnvelope<quantity, index> | undefined;
40
+ validBefore?: index | undefined;
41
+ validAfter?: index | undefined;
42
+ type?: 'aa' | undefined;
43
+ };
44
+ export type TransactionSerialized<type extends TransactionType = TransactionType> = viem_TransactionSerialized<type> | TransactionSerializedAA;
45
+ export type TransactionSerializedAA = `0x76${string}`;
46
+ export type TransactionType = viem_TransactionType | 'aa';
47
+ export declare function getType(transaction: Record<string, unknown>): Transaction['type'];
48
+ export declare function isTempo(transaction: Record<string, unknown>): boolean;
49
+ export declare function deserialize<const serialized extends TransactionSerializedGeneric>(serializedTransaction: serialized): deserialize.ReturnValue<serialized>;
50
+ export declare namespace deserialize {
51
+ type ReturnValue<serialized extends TransactionSerializedGeneric = TransactionSerializedGeneric> = serialized extends TransactionSerializedAA ? TransactionSerializableAA : ParseTransactionReturnType<serialized>;
52
+ }
53
+ export declare function serialize(transaction: TransactionSerializable & {
54
+ feePayer?: Account | true | undefined;
55
+ from?: Address | undefined;
56
+ }, signature?: viem_Signature | undefined): Promise<`0x${string}`>;
57
+ //# sourceMappingURL=Transaction.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Transaction.d.ts","sourceRoot":"","sources":["../../src/viem/Transaction.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,GAAG,MAAM,QAAQ,CAAA;AAG7B,OAAO,EACL,KAAK,UAAU,EACf,KAAK,OAAO,EACZ,KAAK,OAAO,EACZ,KAAK,iBAAiB,EACtB,KAAK,gBAAgB,EACrB,KAAK,0BAA0B,EAC/B,KAAK,uBAAuB,EAC5B,KAAK,eAAe,EACpB,KAAK,sBAAsB,EAC3B,KAAK,2BAA2B,EAChC,KAAK,4BAA4B,EAGjC,KAAK,cAAc,IAAI,mBAAmB,EAC1C,KAAK,qBAAqB,IAAI,0BAA0B,EACxD,KAAK,SAAS,IAAI,cAAc,EAEhC,KAAK,WAAW,IAAI,gBAAgB,EACpC,KAAK,kBAAkB,IAAI,uBAAuB,EAClD,KAAK,uBAAuB,IAAI,4BAA4B,EAC5D,KAA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,CAAC,GACnC,WAAW,CAAC,MAAM,CAAC,CAYrB;AAED,wBAAgB,OAAO,CAAC,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,WAO3D;AAED,wBAAgB,WAAW,CACzB,KAAK,CAAC,UAAU,SAAS,4BAA4B,EACrD,qBAAqB,EAAE,UAAU,GAAG,WAAW,CAAC,WAAW,CAAC,UAAU,CAAC,CAKxE;AAED,MAAM,CAAC,OAAO,WAAW,WAAW,CAAC;IACnC,KAAY,WAAW,CACrB,UAAU,SACR,4BAA4B,GAAG,4BAA4B,IAC3D,UAAU,SAAS,uBAAuB,GAC1C,yBAAyB,GACzB,0BAA0B,CAAC,UAAU,CAAC,CAAA;CAC3C;AAED,wBAAsB,SAAS,CAC7B,WAAW,EAAE,uBAAuB,GAAG;IACrC,QAAQ,CAAC,EAAE,OAAO,GAAG,IAAI,GAAG,SAAS,CAAA;IACrC,IAAI,CAAC,EAAE,OAAO,GAAG,SAAS,CAAA;CAC3B,EACD,SAAS,CAAC,EAAE,cAAc,GAAG,SAAS,0BAUvC"}
@@ -0,0 +1,137 @@
1
+ import * as Hex from 'ox/Hex';
2
+ import * as Secp256k1 from 'ox/Secp256k1';
3
+ import * as Signature from 'ox/Signature';
4
+ import { getTransactionType as viem_getTransactionType, parseTransaction as viem_parseTransaction, serializeTransaction as viem_serializeTransaction, } from 'viem';
5
+ import * as SignatureEnvelope from '../ox/SignatureEnvelope.js';
6
+ import * as TxAA from '../ox/TransactionEnvelopeAA.js';
7
+ export function getType(transaction) {
8
+ if (typeof transaction.calls !== 'undefined' ||
9
+ typeof transaction.feePayer !== 'undefined' ||
10
+ typeof transaction.feeToken !== 'undefined' ||
11
+ typeof transaction.signature !== 'undefined' ||
12
+ typeof transaction.validBefore !== 'undefined' ||
13
+ typeof transaction.validAfter !== 'undefined')
14
+ return 'aa';
15
+ if (transaction.type)
16
+ return transaction.type;
17
+ return viem_getTransactionType(transaction);
18
+ }
19
+ export function isTempo(transaction) {
20
+ try {
21
+ const type = getType(transaction);
22
+ return type === 'aa';
23
+ }
24
+ catch {
25
+ return false;
26
+ }
27
+ }
28
+ export function deserialize(serializedTransaction) {
29
+ const type = Hex.slice(serializedTransaction, 0, 1);
30
+ if (type === '0x76')
31
+ return deserializeAA(serializedTransaction);
32
+ return viem_parseTransaction(serializedTransaction);
33
+ }
34
+ export async function serialize(transaction, signature) {
35
+ if (!isTempo(transaction))
36
+ return viem_serializeTransaction(transaction, signature);
37
+ const type = getType(transaction);
38
+ if (type === 'aa')
39
+ return serializeAA(transaction, signature);
40
+ throw new Error('Unsupported transaction type');
41
+ }
42
+ ////////////////////////////////////////////////////////////////////////////////////
43
+ // Internal
44
+ /** @internal */
45
+ function deserializeAA(serializedTransaction) {
46
+ const { authorizationList, feePayerSignature, nonce, ...tx } = TxAA.deserialize(serializedTransaction);
47
+ return {
48
+ ...tx,
49
+ authorizationList: authorizationList?.map((auth) => ({
50
+ ...auth,
51
+ nonce: Number(auth.nonce ?? 0n),
52
+ r: Hex.fromNumber(auth.r, { size: 32 }),
53
+ s: Hex.fromNumber(auth.s, { size: 32 }),
54
+ })),
55
+ nonce: Number(nonce ?? 0n),
56
+ feePayerSignature: feePayerSignature
57
+ ? {
58
+ r: Hex.fromNumber(feePayerSignature.r, { size: 32 }),
59
+ s: Hex.fromNumber(feePayerSignature.s, { size: 32 }),
60
+ yParity: feePayerSignature.yParity,
61
+ }
62
+ : feePayerSignature,
63
+ };
64
+ }
65
+ /** @internal */
66
+ async function serializeAA(transaction, sig) {
67
+ const signature = (() => {
68
+ if (transaction.signature)
69
+ return transaction.signature;
70
+ if (sig)
71
+ return SignatureEnvelope.from({
72
+ r: BigInt(sig.r),
73
+ s: BigInt(sig.s),
74
+ yParity: Number(sig.yParity),
75
+ });
76
+ return undefined;
77
+ })();
78
+ const { authorizationList, chainId, feePayer, feePayerSignature, nonce, ...rest } = transaction;
79
+ const transaction_ox = {
80
+ ...rest,
81
+ authorizationList: authorizationList?.map((auth) => ({
82
+ ...auth,
83
+ nonce: BigInt(auth.nonce),
84
+ r: BigInt(auth.r),
85
+ s: BigInt(auth.s),
86
+ yParity: Number(auth.yParity),
87
+ })),
88
+ calls: rest.calls?.length
89
+ ? rest.calls
90
+ : [
91
+ {
92
+ to: rest.to || undefined,
93
+ value: rest.value,
94
+ data: rest.data,
95
+ },
96
+ ],
97
+ chainId: Number(chainId),
98
+ feePayerSignature: feePayerSignature
99
+ ? {
100
+ r: BigInt(feePayerSignature.r),
101
+ s: BigInt(feePayerSignature.s),
102
+ yParity: Number(feePayerSignature.yParity),
103
+ }
104
+ : feePayer
105
+ ? null
106
+ : undefined,
107
+ type: 'aa',
108
+ ...(nonce ? { nonce: BigInt(nonce) } : {}),
109
+ };
110
+ if (signature && typeof transaction.feePayer === 'object') {
111
+ const tx = TxAA.from(transaction_ox, {
112
+ signature,
113
+ });
114
+ const sender = (() => {
115
+ if (signature.type === 'secp256k1')
116
+ return Secp256k1.recoverAddress({
117
+ payload: TxAA.getSignPayload(tx),
118
+ signature: signature.signature,
119
+ });
120
+ throw new Error('Unsupported signature type');
121
+ })();
122
+ const hash = TxAA.getFeePayerSignPayload(tx, {
123
+ sender,
124
+ });
125
+ const feePayerSignature = await transaction.feePayer.sign({
126
+ hash,
127
+ });
128
+ return TxAA.serialize(tx, {
129
+ feePayerSignature: Signature.from(feePayerSignature),
130
+ });
131
+ }
132
+ return TxAA.serialize(transaction_ox, {
133
+ feePayerSignature: feePayer === true ? null : undefined,
134
+ signature,
135
+ });
136
+ }
137
+ //# sourceMappingURL=Transaction.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Transaction.js","sourceRoot":"","sources":["../../src/viem/Transaction.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,GAAG,MAAM,QAAQ,CAAA;AAC7B,OAAO,KAAK,SAAS,MAAM,cAAc,CAAA;AACzC,OAAO,KAAK,SAAS,MAAM,cAAc,CAAA;AACzC,OAAO,EAYL,kBAAkB,IAAI,uBAAuB,EA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ACxB,iBAAiB,EAAE,SAAS,CAAC,IAAI,CAAC,iBAAiB,CAAC;SACrD,CAAC,CAAA;IACJ,CAAC;IAED,OAAO,IAAI,CAAC,SAAS,CAAC,cAAc,EAAE;QACpC,iBAAiB,EAAE,QAAQ,KAAK,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,SAAS;QACvD,SAAS;KACV,CAAC,CAAA;AACJ,CAAC"}
@@ -1,5 +1,5 @@
1
1
  import { type Transport } from 'viem';
2
- export type Relay = Transport<typeof withFeePayer.type>;
2
+ export type FeePayer = Transport<typeof withFeePayer.type>;
3
3
  /**
4
4
  * Creates a fee payer transport that routes requests between
5
5
  * the default transport or the fee payer transport.
@@ -11,6 +11,6 @@ export type Relay = Transport<typeof withFeePayer.type>;
11
11
  export declare function withFeePayer(defaultTransport: Transport, relayTransport: Transport): withFeePayer.ReturnValue;
12
12
  export declare namespace withFeePayer {
13
13
  const type = "feePayer";
14
- type ReturnValue = Relay;
14
+ type ReturnValue = FeePayer;
15
15
  }
16
- //# sourceMappingURL=transport.d.ts.map
16
+ //# sourceMappingURL=Transport.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Transport.d.ts","sourceRoot":"","sources":["../../src/viem/Transport.ts"],"names":[],"mappings":"AAAA,OAAO,EAAmB,KAAK,SAAS,EAAE,MAAM,MAAM,CAAA;AAGtD,MAAM,MAAM,QAAQ,GAAG,SAAS,CAAC,OAAO,YAAY,CAAC,IAAI,CAAC,CAAA;AAE1D;;;;;;;GAOG;AACH,wBAAgB,YAAY,CAC1B,gBAAgB,EAAE,SAAS,EAC3B,cAAc,EAAE,SAAS,GACxB,YAAY,CAAC,WAAW,CAwB1B;AAED,MAAM,CAAC,OAAO,WAAW,YAAY,CAAC;IAC7B,MAAM,IAAI,aAAa,CAAA;IAE9B,KAAY,WAAW,GAAG,QAAQ,CAAA;CACnC"}
@@ -1,5 +1,5 @@
1
1
  import { createTransport } from 'viem';
2
- import { parseTransaction } from "./transaction.js";
2
+ import * as Transaction from './Transaction.js';
3
3
  /**
4
4
  * Creates a fee payer transport that routes requests between
5
5
  * the default transport or the fee payer transport.
@@ -19,7 +19,7 @@ export function withFeePayer(defaultTransport, relayTransport) {
19
19
  if (method === 'eth_sendRawTransactionSync' ||
20
20
  method === 'eth_sendRawTransaction') {
21
21
  const serialized = params[0];
22
- const transaction = parseTransaction(serialized);
22
+ const transaction = Transaction.deserialize(serialized);
23
23
  // If the transaction is intended to be sponsored, forward it to the relay.
24
24
  if (transaction.feePayerSignature === null)
25
25
  return transport_relay.request({ method, params }, options);
@@ -30,4 +30,4 @@ export function withFeePayer(defaultTransport, relayTransport) {
30
30
  });
31
31
  };
32
32
  }
33
- //# sourceMappingURL=transport.js.map
33
+ //# sourceMappingURL=Transport.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Transport.js","sourceRoot":"","sources":["../../src/viem/Transport.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAkB,MAAM,MAAM,CAAA;AACtD,OAAO,KAAK,WAAW,MAAM,kBAAkB,CAAA;AAI/C;;;;;;;GAOG;AACH,MAAM,UAAU,YAAY,CAC1B,gBAA2B,EAC3B,cAAyB;IAEzB,OAAO,CAAC,MAAM,EAAE,EAAE;QAChB,MAAM,iBAAiB,GAAG,gBAAgB,CAAC,MAAM,CAAC,CAAA;QAClD,MAAM,eAAe,GAAG,cAAc,CAAC,MAAM,CAAC,CAAA;QAE9C,OAAO,eAAe,CAAC;YACrB,GAAG,EAAE,YAAY,CAAC,IAAI;YACtB,IAAI,EAAE,aAAa;YACnB,KAAK,CAAC,OAAO,CAAC,EAAE,MAAM,EAAE,MAAM,EAAE,EAAE,OAAO;gBACvC,IACE,MAAM,KAAK,4BAA4B;oBACvC,MAAM,KAAK,wBAAwB,EACnC,CAAC;oBACD,MAAM,UAAU,GAAI,MAAc,CAAC,CAAC,CAAoB,CAAA;oBACxD,MAAM,WAAW,GAAG,WAAW,CAAC,WAAW,CAAC,UAAU,CAAC,CAAA;oBACvD,2EAA2E;oBAC3E,IAAI,WAAW,CAAC,iBAAiB,KAAK,IAAI;wBACxC,OAAO,eAAe,CAAC,OAAO,CAAC,EAAE,MAAM,EAAE,MAAM,EAAE,EAAE,OAAO,CAAU,CAAA;gBACxE,CAAC;gBACD,OAAO,iBAAiB,CAAC,OAAO,CAAC,EAAE,MAAM,EAAE,MAAM,EAAE,EAAE,OAAO,CAAU,CAAA;YACxE,CAAC;YACD,IAAI,EAAE,YAAY,CAAC,IAAI;SACxB,CAAC,CAAA;IACJ,CAAC,CAAA;AACH,CAAC"}
@@ -1,10 +1,14 @@
1
- export * from "./abis.js";
2
- export * as actions from "./actions/index.js";
3
- export * from "./addresses.js";
4
- export * from "./chain.js";
5
- export * from "./client.js";
6
- export { decorator as tempoActions } from "./decorator.js";
7
- export * from "./formatters.js";
8
- export * from "./transaction.js";
9
- export * from "./transport.js";
1
+ export * as Abis from './Abis.js';
2
+ export * as Actions from './Actions/index.js';
3
+ export * as Addresses from './Addresses.js';
4
+ export * as Chain from './Chain.js';
5
+ export * as Client from './Client.js';
6
+ export { createTempoClient } from './Client.js';
7
+ export { decorator as tempoActions } from './Decorator.js';
8
+ export * as Formatters from './Formatters.js';
9
+ export * as Tick from './Tick.js';
10
+ export * as TokenIds from './TokenIds.js';
11
+ export * as Transaction from './Transaction.js';
12
+ export * as Transport from './Transport.js';
13
+ export { withFeePayer } from './Transport.js';
10
14
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/viem/index.ts"],"names":[],"mappings":"AAAA,0BAAyB;AACzB,OAAO,KAAK,OAAO,2BAA0B;AAC7C,+BAA8B;AAC9B,2BAA0B;AAC1B,4BAA2B;AAC3B,OAAO,EAAE,SAAS,IAAI,YAAY,EAAE,uBAAsB;AAC1D,gCAA+B;AAC/B,iCAAgC;AAChC,+BAA8B"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/viem/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,IAAI,MAAM,WAAW,CAAA;AACjC,OAAO,KAAK,OAAO,MAAM,oBAAoB,CAAA;AAC7C,OAAO,KAAK,SAAS,MAAM,gBAAgB,CAAA;AAC3C,OAAO,KAAK,KAAK,MAAM,YAAY,CAAA;AACnC,OAAO,KAAK,MAAM,MAAM,aAAa,CAAA;AACrC,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAA;AAC/C,OAAO,EAAE,SAAS,IAAI,YAAY,EAAE,MAAM,gBAAgB,CAAA;AAC1D,OAAO,KAAK,UAAU,MAAM,iBAAiB,CAAA;AAC7C,OAAO,KAAK,IAAI,MAAM,WAAW,CAAA;AACjC,OAAO,KAAK,QAAQ,MAAM,eAAe,CAAA;AACzC,OAAO,KAAK,WAAW,MAAM,kBAAkB,CAAA;AAC/C,OAAO,KAAK,SAAS,MAAM,gBAAgB,CAAA;AAC3C,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAA"}