tempo.ts 0.0.0 → 0.0.1

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 (153) hide show
  1. package/README.md +92 -0
  2. package/dist/chains.d.ts +1477 -0
  3. package/dist/chains.d.ts.map +1 -0
  4. package/dist/chains.js +43 -0
  5. package/dist/chains.js.map +1 -0
  6. package/dist/index.d.ts +2 -0
  7. package/dist/index.d.ts.map +1 -0
  8. package/dist/index.js +2 -0
  9. package/dist/index.js.map +1 -0
  10. package/dist/internal/types.d.ts +284 -0
  11. package/dist/internal/types.d.ts.map +1 -0
  12. package/dist/internal/types.js +2 -0
  13. package/dist/internal/types.js.map +1 -0
  14. package/dist/ox/TokenId.d.ts +18 -0
  15. package/dist/ox/TokenId.d.ts.map +1 -0
  16. package/dist/ox/TokenId.js +29 -0
  17. package/dist/ox/TokenId.js.map +1 -0
  18. package/dist/ox/TokenRole.d.ts +11 -0
  19. package/dist/ox/TokenRole.d.ts.map +1 -0
  20. package/dist/ox/TokenRole.js +22 -0
  21. package/dist/ox/TokenRole.js.map +1 -0
  22. package/dist/ox/Transaction.d.ts +161 -0
  23. package/dist/ox/Transaction.d.ts.map +1 -0
  24. package/dist/ox/Transaction.js +117 -0
  25. package/dist/ox/Transaction.js.map +1 -0
  26. package/dist/ox/TransactionEnvelopeFeeToken.d.ts +393 -0
  27. package/dist/ox/TransactionEnvelopeFeeToken.d.ts.map +1 -0
  28. package/dist/ox/TransactionEnvelopeFeeToken.js +452 -0
  29. package/dist/ox/TransactionEnvelopeFeeToken.js.map +1 -0
  30. package/dist/ox/TransactionRequest.d.ts +62 -0
  31. package/dist/ox/TransactionRequest.d.ts.map +1 -0
  32. package/dist/ox/TransactionRequest.js +66 -0
  33. package/dist/ox/TransactionRequest.js.map +1 -0
  34. package/dist/ox/index.d.ts +5 -0
  35. package/dist/ox/index.d.ts.map +1 -0
  36. package/dist/ox/index.js +5 -0
  37. package/dist/ox/index.js.map +1 -0
  38. package/dist/prool/Instance.d.ts +92 -0
  39. package/dist/prool/Instance.d.ts.map +1 -0
  40. package/dist/prool/Instance.js +96 -0
  41. package/dist/prool/Instance.js.map +1 -0
  42. package/dist/prool/index.d.ts +2 -0
  43. package/dist/prool/index.d.ts.map +1 -0
  44. package/dist/prool/index.js +2 -0
  45. package/dist/prool/index.js.map +1 -0
  46. package/dist/viem/abis.d.ts +2058 -0
  47. package/dist/viem/abis.d.ts.map +1 -0
  48. package/dist/viem/abis.js +1599 -0
  49. package/dist/viem/abis.js.map +1 -0
  50. package/dist/viem/actions/amm.d.ts +2091 -0
  51. package/dist/viem/actions/amm.d.ts.map +1 -0
  52. package/dist/viem/actions/amm.js +876 -0
  53. package/dist/viem/actions/amm.js.map +1 -0
  54. package/dist/viem/actions/fee.d.ts +727 -0
  55. package/dist/viem/actions/fee.d.ts.map +1 -0
  56. package/dist/viem/actions/fee.js +230 -0
  57. package/dist/viem/actions/fee.js.map +1 -0
  58. package/dist/viem/actions/index.d.ts +5 -0
  59. package/dist/viem/actions/index.d.ts.map +1 -0
  60. package/dist/viem/actions/index.js +5 -0
  61. package/dist/viem/actions/index.js.map +1 -0
  62. package/dist/viem/actions/policy.d.ts +1900 -0
  63. package/dist/viem/actions/policy.d.ts.map +1 -0
  64. package/dist/viem/actions/policy.js +841 -0
  65. package/dist/viem/actions/policy.js.map +1 -0
  66. package/dist/viem/actions/token.d.ts +13759 -0
  67. package/dist/viem/actions/token.d.ts.map +1 -0
  68. package/dist/viem/actions/token.js +2579 -0
  69. package/dist/viem/actions/token.js.map +1 -0
  70. package/dist/viem/addresses.d.ts +8 -0
  71. package/dist/viem/addresses.d.ts.map +1 -0
  72. package/dist/viem/addresses.js +8 -0
  73. package/dist/viem/addresses.js.map +1 -0
  74. package/dist/viem/chain.d.ts +341 -0
  75. package/dist/viem/chain.d.ts.map +1 -0
  76. package/dist/viem/chain.js +22 -0
  77. package/dist/viem/chain.js.map +1 -0
  78. package/dist/viem/client.d.ts +27 -0
  79. package/dist/viem/client.d.ts.map +1 -0
  80. package/dist/viem/client.js +28 -0
  81. package/dist/viem/client.js.map +1 -0
  82. package/dist/viem/decorator.d.ts +1636 -0
  83. package/dist/viem/decorator.d.ts.map +1 -0
  84. package/dist/viem/decorator.js +95 -0
  85. package/dist/viem/decorator.js.map +1 -0
  86. package/dist/viem/formatters.d.ts +4 -0
  87. package/dist/viem/formatters.d.ts.map +1 -0
  88. package/dist/viem/formatters.js +69 -0
  89. package/dist/viem/formatters.js.map +1 -0
  90. package/dist/viem/index.d.ts +9 -0
  91. package/dist/viem/index.d.ts.map +1 -0
  92. package/dist/viem/index.js +9 -0
  93. package/dist/viem/index.js.map +1 -0
  94. package/dist/viem/transaction.d.ts +54 -0
  95. package/dist/viem/transaction.d.ts.map +1 -0
  96. package/dist/viem/transaction.js +108 -0
  97. package/dist/viem/transaction.js.map +1 -0
  98. package/dist/viem/transport.d.ts +16 -0
  99. package/dist/viem/transport.d.ts.map +1 -0
  100. package/dist/viem/transport.js +33 -0
  101. package/dist/viem/transport.js.map +1 -0
  102. package/dist/viem/types.d.ts +10 -0
  103. package/dist/viem/types.d.ts.map +1 -0
  104. package/dist/viem/types.js +2 -0
  105. package/dist/viem/types.js.map +1 -0
  106. package/dist/viem/utils.d.ts +8 -0
  107. package/dist/viem/utils.d.ts.map +1 -0
  108. package/dist/viem/utils.js +9 -0
  109. package/dist/viem/utils.js.map +1 -0
  110. package/package.json +100 -2
  111. package/src/chains.ts +46 -0
  112. package/src/index.ts +1 -0
  113. package/src/internal/types.ts +414 -0
  114. package/src/ox/TokenId.test.ts +29 -0
  115. package/src/ox/TokenId.ts +35 -0
  116. package/src/ox/TokenRole.test.ts +20 -0
  117. package/src/ox/TokenRole.ts +27 -0
  118. package/src/ox/Transaction.test.ts +257 -0
  119. package/src/ox/Transaction.ts +247 -0
  120. package/src/ox/TransactionEnvelopeFeeToken.test.ts +1215 -0
  121. package/src/ox/TransactionEnvelopeFeeToken.ts +717 -0
  122. package/src/ox/TransactionRequest.ts +100 -0
  123. package/src/ox/index.ts +4 -0
  124. package/src/prool/Instance.test.ts +43 -0
  125. package/src/prool/Instance.ts +190 -0
  126. package/src/prool/index.ts +1 -0
  127. package/src/prool/internal/chain.json +106 -0
  128. package/src/prool/internal/consensus.toml +32 -0
  129. package/src/viem/abis.ts +1606 -0
  130. package/src/viem/actions/amm.test.ts +425 -0
  131. package/src/viem/actions/amm.ts +1308 -0
  132. package/src/viem/actions/fee.test.ts +281 -0
  133. package/src/viem/actions/fee.ts +362 -0
  134. package/src/viem/actions/index.ts +4 -0
  135. package/src/viem/actions/policy.test.ts +514 -0
  136. package/src/viem/actions/policy.ts +1284 -0
  137. package/src/viem/actions/token.test.ts +2172 -0
  138. package/src/viem/actions/token.ts +3830 -0
  139. package/src/viem/addresses.ts +10 -0
  140. package/src/viem/chain.ts +27 -0
  141. package/src/viem/client.bench-d.ts +8 -0
  142. package/src/viem/client.test.ts +152 -0
  143. package/src/viem/client.ts +91 -0
  144. package/src/viem/decorator.bench-d.ts +11 -0
  145. package/src/viem/decorator.test.ts +35 -0
  146. package/src/viem/decorator.ts +1914 -0
  147. package/src/viem/e2e.test.ts +410 -0
  148. package/src/viem/formatters.ts +100 -0
  149. package/src/viem/index.ts +8 -0
  150. package/src/viem/transaction.ts +253 -0
  151. package/src/viem/transport.ts +47 -0
  152. package/src/viem/types.ts +55 -0
  153. package/src/viem/utils.ts +37 -0
@@ -0,0 +1,10 @@
1
+ export const accountImplementationAddress =
2
+ '0x7702c00000000000000000000000000000000000'
3
+ export const accountRegistrarAddress =
4
+ '0x7702ac0000000000000000000000000000000000'
5
+ export const feeManagerAddress = '0xfeec000000000000000000000000000000000000'
6
+ export const tip20FactoryAddress = '0x20fc000000000000000000000000000000000000'
7
+ export const tip403RegistryAddress =
8
+ '0x403c000000000000000000000000000000000000'
9
+ export const usdAddress = '0x20c0000000000000000000000000000000000000'
10
+ export const usdId = 0n
@@ -0,0 +1,27 @@
1
+ import {
2
+ type Chain,
3
+ type ChainConfig,
4
+ defineTransaction,
5
+ defineTransactionRequest,
6
+ } from 'viem'
7
+ import { formatTransaction, formatTransactionRequest } from './formatters.js'
8
+ import { serializeTransaction } from './transaction.js'
9
+
10
+ export const chainConfig = {
11
+ blockTime: 1_000,
12
+ contracts: {
13
+ multicall3: {
14
+ address: '0xca11bde05977b3631167028862be2a173976ca11',
15
+ blockCreated: 0,
16
+ },
17
+ },
18
+ formatters: {
19
+ transaction: defineTransaction({ format: formatTransaction }),
20
+ transactionRequest: defineTransactionRequest({
21
+ format: formatTransactionRequest,
22
+ }),
23
+ },
24
+ serializers: {
25
+ transaction: serializeTransaction,
26
+ },
27
+ } satisfies Pick<Chain, 'blockTime' | 'contracts'> & ChainConfig
@@ -0,0 +1,8 @@
1
+ import { attest } from '@ark/attest'
2
+ import { test } from 'vitest'
3
+ import { createTempoClient } from './client.js'
4
+
5
+ test('createTempoClient', () => {
6
+ createTempoClient()
7
+ attest.instantiations([45545, 'instantiations'])
8
+ })
@@ -0,0 +1,152 @@
1
+ import { expect, test } from 'vitest'
2
+ import { createTempoClient } from './client.js'
3
+
4
+ test('createTempoClient', () => {
5
+ const client = createTempoClient()
6
+ expect({ ...client, uid: null }).toMatchInlineSnapshot(`
7
+ {
8
+ "account": undefined,
9
+ "amm": {
10
+ "burn": [Function],
11
+ "burnSync": [Function],
12
+ "getLiquidityBalance": [Function],
13
+ "getPool": [Function],
14
+ "getPoolId": [Function],
15
+ "getTotalSupply": [Function],
16
+ "mint": [Function],
17
+ "mintSync": [Function],
18
+ "rebalanceSwap": [Function],
19
+ "rebalanceSwapSync": [Function],
20
+ "watchBurn": [Function],
21
+ "watchFeeSwap": [Function],
22
+ "watchMint": [Function],
23
+ "watchRebalanceSwap": [Function],
24
+ },
25
+ "batch": undefined,
26
+ "cacheTime": 500,
27
+ "ccipRead": undefined,
28
+ "chain": {
29
+ "blockTime": 1000,
30
+ "contracts": {
31
+ "multicall3": {
32
+ "address": "0xca11bde05977b3631167028862be2a173976ca11",
33
+ "blockCreated": 0,
34
+ },
35
+ },
36
+ "fees": undefined,
37
+ "formatters": {
38
+ "transaction": {
39
+ "exclude": undefined,
40
+ "format": [Function],
41
+ "type": "transaction",
42
+ },
43
+ "transactionRequest": {
44
+ "exclude": undefined,
45
+ "format": [Function],
46
+ "type": "transactionRequest",
47
+ },
48
+ },
49
+ "id": 4246,
50
+ "name": "Tempo",
51
+ "nativeCurrency": {
52
+ "decimals": 18,
53
+ "name": "USD",
54
+ "symbol": "USD",
55
+ },
56
+ "rpcUrls": {
57
+ "default": {
58
+ "http": [
59
+ "https://rpc-lento.tempoxyz.dev",
60
+ ],
61
+ },
62
+ },
63
+ "serializers": {
64
+ "transaction": [Function],
65
+ },
66
+ },
67
+ "extend": [Function],
68
+ "fee": {
69
+ "getUserToken": [Function],
70
+ "setUserToken": [Function],
71
+ "setUserTokenSync": [Function],
72
+ "watchSetUserToken": [Function],
73
+ },
74
+ "key": "base",
75
+ "name": "Base Client",
76
+ "policy": {
77
+ "create": [Function],
78
+ "createSync": [Function],
79
+ "getData": [Function],
80
+ "isAuthorized": [Function],
81
+ "modifyBlacklist": [Function],
82
+ "modifyBlacklistSync": [Function],
83
+ "modifyWhitelist": [Function],
84
+ "modifyWhitelistSync": [Function],
85
+ "setAdmin": [Function],
86
+ "setAdminSync": [Function],
87
+ "watchAdminUpdated": [Function],
88
+ "watchBlacklistUpdated": [Function],
89
+ "watchCreate": [Function],
90
+ "watchWhitelistUpdated": [Function],
91
+ },
92
+ "pollingInterval": 500,
93
+ "request": [Function],
94
+ "token": {
95
+ "approve": [Function],
96
+ "approveSync": [Function],
97
+ "burn": [Function],
98
+ "burnBlocked": [Function],
99
+ "burnBlockedSync": [Function],
100
+ "burnSync": [Function],
101
+ "changeTransferPolicy": [Function],
102
+ "changeTransferPolicySync": [Function],
103
+ "create": [Function],
104
+ "createSync": [Function],
105
+ "getAllowance": [Function],
106
+ "getBalance": [Function],
107
+ "getMetadata": [Function],
108
+ "grantRoles": [Function],
109
+ "grantRolesSync": [Function],
110
+ "mint": [Function],
111
+ "mintSync": [Function],
112
+ "pause": [Function],
113
+ "pauseSync": [Function],
114
+ "permit": [Function],
115
+ "permitSync": [Function],
116
+ "renounceRoles": [Function],
117
+ "renounceRolesSync": [Function],
118
+ "revokeRoles": [Function],
119
+ "revokeRolesSync": [Function],
120
+ "setRoleAdmin": [Function],
121
+ "setRoleAdminSync": [Function],
122
+ "setSupplyCap": [Function],
123
+ "setSupplyCapSync": [Function],
124
+ "transfer": [Function],
125
+ "transferSync": [Function],
126
+ "unpause": [Function],
127
+ "unpauseSync": [Function],
128
+ "watchAdminRole": [Function],
129
+ "watchApprove": [Function],
130
+ "watchBurn": [Function],
131
+ "watchCreate": [Function],
132
+ "watchMint": [Function],
133
+ "watchRole": [Function],
134
+ "watchTransfer": [Function],
135
+ },
136
+ "transport": {
137
+ "fetchOptions": undefined,
138
+ "key": "http",
139
+ "methods": undefined,
140
+ "name": "HTTP JSON-RPC",
141
+ "request": [Function],
142
+ "retryCount": 3,
143
+ "retryDelay": 150,
144
+ "timeout": 10000,
145
+ "type": "http",
146
+ "url": "https://rpc-lento.tempoxyz.dev",
147
+ },
148
+ "type": "base",
149
+ "uid": null,
150
+ }
151
+ `)
152
+ })
@@ -0,0 +1,91 @@
1
+ import {
2
+ type Account,
3
+ type Address,
4
+ type Chain,
5
+ type ClientConfig,
6
+ createClient,
7
+ http,
8
+ type JsonRpcAccount,
9
+ type RpcSchema,
10
+ type Transport,
11
+ type Client as viem_Client,
12
+ } from 'viem'
13
+ import { tempo } from '../chains.js'
14
+ import type { PartialBy } from '../internal/types.js'
15
+ import * as actions from './decorator.js'
16
+
17
+ export type Client<
18
+ transport extends Transport = Transport,
19
+ chain extends Chain | undefined = Chain | undefined,
20
+ account extends Account | undefined = undefined,
21
+ > = viem_Client<
22
+ transport,
23
+ chain,
24
+ account,
25
+ undefined,
26
+ actions.Decorator<chain, account>
27
+ >
28
+
29
+ /**
30
+ * Instantiates a default Tempo client.
31
+ *
32
+ * @example
33
+ * ```ts
34
+ * import { createTempoClient } from 'tempo.ts/viem'
35
+ * import { privateKeyToAccount } from 'viem/accounts'
36
+ *
37
+ * const client = createTempoClient({
38
+ * account: privateKeyToAccount('0x...')
39
+ * })
40
+ * ```
41
+ *
42
+ * @param parameters - The parameters for the client.
43
+ * @returns A Tempo client.
44
+ */
45
+ export function createTempoClient<
46
+ transport extends Transport,
47
+ chain extends Chain | undefined = typeof tempo,
48
+ accountOrAddress extends Account | Address | undefined = undefined,
49
+ rpcSchema extends RpcSchema | undefined = undefined,
50
+ >(
51
+ parameters: createTempoClient.Parameters<
52
+ transport,
53
+ chain,
54
+ accountOrAddress,
55
+ rpcSchema
56
+ > = {},
57
+ ): createTempoClient.ReturnValue<
58
+ transport,
59
+ chain,
60
+ accountOrAddress extends Address
61
+ ? JsonRpcAccount<accountOrAddress>
62
+ : accountOrAddress
63
+ > {
64
+ const { chain = tempo, transport = http(), ...rest } = parameters
65
+ return createClient({
66
+ ...rest,
67
+ chain,
68
+ transport,
69
+ }).extend(actions.decorator()) as never
70
+ }
71
+
72
+ export declare namespace createTempoClient {
73
+ export type Parameters<
74
+ transport extends Transport = Transport,
75
+ chain extends Chain | undefined = Chain | undefined,
76
+ accountOrAddress extends Account | Address | undefined =
77
+ | Account
78
+ | Address
79
+ | undefined,
80
+ rpcSchema extends RpcSchema | undefined = undefined,
81
+ > = PartialBy<
82
+ ClientConfig<transport, chain, accountOrAddress, rpcSchema>,
83
+ 'transport'
84
+ >
85
+
86
+ export type ReturnValue<
87
+ transport extends Transport = Transport,
88
+ chain extends Chain | undefined = Chain | undefined,
89
+ account extends Account | undefined = undefined,
90
+ > = Client<transport, chain, account>
91
+ }
@@ -0,0 +1,11 @@
1
+ import { attest } from '@ark/attest'
2
+ import { createClient, http } from 'viem'
3
+ import { test } from 'vitest'
4
+ import { decorator } from './decorator.js'
5
+
6
+ test('decorator', () => {
7
+ createClient({
8
+ transport: http('https://cloudflare-eth.com'),
9
+ }).extend(decorator())
10
+ attest.instantiations([27597, 'instantiations'])
11
+ })
@@ -0,0 +1,35 @@
1
+ import { tempoLocal } from 'tempo.ts/chains'
2
+ import { tempoActions } from 'tempo.ts/viem'
3
+ import { createClient, http } from 'viem'
4
+ import { describe, expect, test } from 'vitest'
5
+
6
+ describe('decorator', () => {
7
+ const client2 = createClient({
8
+ chain: tempoLocal,
9
+ transport: http(),
10
+ }).extend(tempoActions())
11
+
12
+ test('default', async () => {
13
+ expect(Object.keys(client2)).toMatchInlineSnapshot(`
14
+ [
15
+ "account",
16
+ "batch",
17
+ "cacheTime",
18
+ "ccipRead",
19
+ "chain",
20
+ "key",
21
+ "name",
22
+ "pollingInterval",
23
+ "request",
24
+ "transport",
25
+ "type",
26
+ "uid",
27
+ "extend",
28
+ "amm",
29
+ "fee",
30
+ "policy",
31
+ "token",
32
+ ]
33
+ `)
34
+ })
35
+ })