@tabai/sdk 0.2.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 (204) hide show
  1. package/LICENSE +23 -0
  2. package/README.md +401 -0
  3. package/bin/tab.mjs +23 -0
  4. package/dist/_shared/abi.d.ts +150 -0
  5. package/dist/_shared/abi.d.ts.map +1 -0
  6. package/dist/_shared/abi.js +197 -0
  7. package/dist/_shared/abi.js.map +1 -0
  8. package/dist/_shared/chains.d.ts +118 -0
  9. package/dist/_shared/chains.d.ts.map +1 -0
  10. package/dist/_shared/chains.js +89 -0
  11. package/dist/_shared/chains.js.map +1 -0
  12. package/dist/_shared/hex.d.ts +35 -0
  13. package/dist/_shared/hex.d.ts.map +1 -0
  14. package/dist/_shared/hex.js +40 -0
  15. package/dist/_shared/hex.js.map +1 -0
  16. package/dist/_shared/index.d.ts +14 -0
  17. package/dist/_shared/index.d.ts.map +1 -0
  18. package/dist/_shared/index.js +14 -0
  19. package/dist/_shared/index.js.map +1 -0
  20. package/dist/_shared/keccak256.d.ts +29 -0
  21. package/dist/_shared/keccak256.d.ts.map +1 -0
  22. package/dist/_shared/keccak256.js +145 -0
  23. package/dist/_shared/keccak256.js.map +1 -0
  24. package/dist/_shared/result.d.ts +78 -0
  25. package/dist/_shared/result.d.ts.map +1 -0
  26. package/dist/_shared/result.js +61 -0
  27. package/dist/_shared/result.js.map +1 -0
  28. package/dist/cli/client-config.d.ts +155 -0
  29. package/dist/cli/client-config.d.ts.map +1 -0
  30. package/dist/cli/client-config.js +382 -0
  31. package/dist/cli/client-config.js.map +1 -0
  32. package/dist/cli/connect.d.ts +76 -0
  33. package/dist/cli/connect.d.ts.map +1 -0
  34. package/dist/cli/connect.js +158 -0
  35. package/dist/cli/connect.js.map +1 -0
  36. package/dist/cli/doctor.d.ts +57 -0
  37. package/dist/cli/doctor.d.ts.map +1 -0
  38. package/dist/cli/doctor.js +253 -0
  39. package/dist/cli/doctor.js.map +1 -0
  40. package/dist/cli/index.d.ts +13 -0
  41. package/dist/cli/index.d.ts.map +1 -0
  42. package/dist/cli/index.js +13 -0
  43. package/dist/cli/index.js.map +1 -0
  44. package/dist/cli/main.d.ts +45 -0
  45. package/dist/cli/main.d.ts.map +1 -0
  46. package/dist/cli/main.js +371 -0
  47. package/dist/cli/main.js.map +1 -0
  48. package/dist/errors.d.ts +29 -0
  49. package/dist/errors.d.ts.map +1 -0
  50. package/dist/errors.js +37 -0
  51. package/dist/errors.js.map +1 -0
  52. package/dist/http/client-402.d.ts +243 -0
  53. package/dist/http/client-402.d.ts.map +1 -0
  54. package/dist/http/client-402.js +515 -0
  55. package/dist/http/client-402.js.map +1 -0
  56. package/dist/http/headers.d.ts +173 -0
  57. package/dist/http/headers.d.ts.map +1 -0
  58. package/dist/http/headers.js +284 -0
  59. package/dist/http/headers.js.map +1 -0
  60. package/dist/http/index.d.ts +15 -0
  61. package/dist/http/index.d.ts.map +1 -0
  62. package/dist/http/index.js +15 -0
  63. package/dist/http/index.js.map +1 -0
  64. package/dist/http/metering-claim.d.ts +82 -0
  65. package/dist/http/metering-claim.d.ts.map +1 -0
  66. package/dist/http/metering-claim.js +99 -0
  67. package/dist/http/metering-claim.js.map +1 -0
  68. package/dist/index.d.ts +48 -0
  69. package/dist/index.d.ts.map +1 -0
  70. package/dist/index.js +51 -0
  71. package/dist/index.js.map +1 -0
  72. package/dist/logger.d.ts +40 -0
  73. package/dist/logger.d.ts.map +1 -0
  74. package/dist/logger.js +50 -0
  75. package/dist/logger.js.map +1 -0
  76. package/dist/mcp/assets.d.ts +31 -0
  77. package/dist/mcp/assets.d.ts.map +1 -0
  78. package/dist/mcp/assets.js +78 -0
  79. package/dist/mcp/assets.js.map +1 -0
  80. package/dist/mcp/index.d.ts +19 -0
  81. package/dist/mcp/index.d.ts.map +1 -0
  82. package/dist/mcp/index.js +19 -0
  83. package/dist/mcp/index.js.map +1 -0
  84. package/dist/mcp/json-schema.d.ts +86 -0
  85. package/dist/mcp/json-schema.d.ts.map +1 -0
  86. package/dist/mcp/json-schema.js +215 -0
  87. package/dist/mcp/json-schema.js.map +1 -0
  88. package/dist/mcp/json.d.ts +43 -0
  89. package/dist/mcp/json.d.ts.map +1 -0
  90. package/dist/mcp/json.js +69 -0
  91. package/dist/mcp/json.js.map +1 -0
  92. package/dist/mcp/registry-client.d.ts +88 -0
  93. package/dist/mcp/registry-client.d.ts.map +1 -0
  94. package/dist/mcp/registry-client.js +158 -0
  95. package/dist/mcp/registry-client.js.map +1 -0
  96. package/dist/mcp/schemas.d.ts +82 -0
  97. package/dist/mcp/schemas.d.ts.map +1 -0
  98. package/dist/mcp/schemas.js +493 -0
  99. package/dist/mcp/schemas.js.map +1 -0
  100. package/dist/mcp/server.d.ts +97 -0
  101. package/dist/mcp/server.d.ts.map +1 -0
  102. package/dist/mcp/server.js +285 -0
  103. package/dist/mcp/server.js.map +1 -0
  104. package/dist/mcp/settings.d.ts +90 -0
  105. package/dist/mcp/settings.d.ts.map +1 -0
  106. package/dist/mcp/settings.js +160 -0
  107. package/dist/mcp/settings.js.map +1 -0
  108. package/dist/mcp/toolset.d.ts +231 -0
  109. package/dist/mcp/toolset.d.ts.map +1 -0
  110. package/dist/mcp/toolset.js +760 -0
  111. package/dist/mcp/toolset.js.map +1 -0
  112. package/dist/payments/abi.d.ts +9 -0
  113. package/dist/payments/abi.d.ts.map +1 -0
  114. package/dist/payments/abi.js +17 -0
  115. package/dist/payments/abi.js.map +1 -0
  116. package/dist/payments/config.d.ts +199 -0
  117. package/dist/payments/config.d.ts.map +1 -0
  118. package/dist/payments/config.js +259 -0
  119. package/dist/payments/config.js.map +1 -0
  120. package/dist/payments/index.d.ts +13 -0
  121. package/dist/payments/index.d.ts.map +1 -0
  122. package/dist/payments/index.js +13 -0
  123. package/dist/payments/index.js.map +1 -0
  124. package/dist/payments/kuru.d.ts +191 -0
  125. package/dist/payments/kuru.d.ts.map +1 -0
  126. package/dist/payments/kuru.js +377 -0
  127. package/dist/payments/kuru.js.map +1 -0
  128. package/dist/payments/monad.d.ts +69 -0
  129. package/dist/payments/monad.d.ts.map +1 -0
  130. package/dist/payments/monad.js +306 -0
  131. package/dist/payments/monad.js.map +1 -0
  132. package/dist/payments/permit2.d.ts +118 -0
  133. package/dist/payments/permit2.d.ts.map +1 -0
  134. package/dist/payments/permit2.js +366 -0
  135. package/dist/payments/permit2.js.map +1 -0
  136. package/dist/payments/registry.d.ts +119 -0
  137. package/dist/payments/registry.d.ts.map +1 -0
  138. package/dist/payments/registry.js +199 -0
  139. package/dist/payments/registry.js.map +1 -0
  140. package/dist/payments/strategy.d.ts +80 -0
  141. package/dist/payments/strategy.d.ts.map +1 -0
  142. package/dist/payments/strategy.js +103 -0
  143. package/dist/payments/strategy.js.map +1 -0
  144. package/dist/proxy/hooks.d.ts +90 -0
  145. package/dist/proxy/hooks.d.ts.map +1 -0
  146. package/dist/proxy/hooks.js +35 -0
  147. package/dist/proxy/hooks.js.map +1 -0
  148. package/dist/proxy/index.d.ts +9 -0
  149. package/dist/proxy/index.d.ts.map +1 -0
  150. package/dist/proxy/index.js +9 -0
  151. package/dist/proxy/index.js.map +1 -0
  152. package/dist/proxy/proxy.d.ts +156 -0
  153. package/dist/proxy/proxy.d.ts.map +1 -0
  154. package/dist/proxy/proxy.js +366 -0
  155. package/dist/proxy/proxy.js.map +1 -0
  156. package/dist/server/adapters/express.d.ts +89 -0
  157. package/dist/server/adapters/express.d.ts.map +1 -0
  158. package/dist/server/adapters/express.js +215 -0
  159. package/dist/server/adapters/express.js.map +1 -0
  160. package/dist/server/adapters/hono.d.ts +52 -0
  161. package/dist/server/adapters/hono.d.ts.map +1 -0
  162. package/dist/server/adapters/hono.js +61 -0
  163. package/dist/server/adapters/hono.js.map +1 -0
  164. package/dist/server/adapters/next.d.ts +52 -0
  165. package/dist/server/adapters/next.d.ts.map +1 -0
  166. package/dist/server/adapters/next.js +56 -0
  167. package/dist/server/adapters/next.js.map +1 -0
  168. package/dist/server/index.d.ts +30 -0
  169. package/dist/server/index.d.ts.map +1 -0
  170. package/dist/server/index.js +30 -0
  171. package/dist/server/index.js.map +1 -0
  172. package/dist/server/metering.d.ts +209 -0
  173. package/dist/server/metering.d.ts.map +1 -0
  174. package/dist/server/metering.js +365 -0
  175. package/dist/server/metering.js.map +1 -0
  176. package/dist/server/post-paid.d.ts +355 -0
  177. package/dist/server/post-paid.d.ts.map +1 -0
  178. package/dist/server/post-paid.js +512 -0
  179. package/dist/server/post-paid.js.map +1 -0
  180. package/dist/x402/client.d.ts +203 -0
  181. package/dist/x402/client.d.ts.map +1 -0
  182. package/dist/x402/client.js +337 -0
  183. package/dist/x402/client.js.map +1 -0
  184. package/dist/x402/hub.d.ts +79 -0
  185. package/dist/x402/hub.d.ts.map +1 -0
  186. package/dist/x402/hub.js +164 -0
  187. package/dist/x402/hub.js.map +1 -0
  188. package/dist/x402/index.d.ts +27 -0
  189. package/dist/x402/index.d.ts.map +1 -0
  190. package/dist/x402/index.js +27 -0
  191. package/dist/x402/index.js.map +1 -0
  192. package/dist/x402/proxy.d.ts +162 -0
  193. package/dist/x402/proxy.d.ts.map +1 -0
  194. package/dist/x402/proxy.js +198 -0
  195. package/dist/x402/proxy.js.map +1 -0
  196. package/dist/x402/server.d.ts +162 -0
  197. package/dist/x402/server.d.ts.map +1 -0
  198. package/dist/x402/server.js +306 -0
  199. package/dist/x402/server.js.map +1 -0
  200. package/dist/x402/wire.d.ts +104 -0
  201. package/dist/x402/wire.d.ts.map +1 -0
  202. package/dist/x402/wire.js +265 -0
  203. package/dist/x402/wire.js.map +1 -0
  204. package/package.json +61 -0
@@ -0,0 +1,197 @@
1
+ /**
2
+ * Contract interface constants shared by the SDK, the gateway, the registry
3
+ * indexer, and the dashboard.
4
+ *
5
+ * Only what is fixed and independently checkable lives here: canonical event
6
+ * signatures and the topic hashes derived from them. Full ABI arrays come from
7
+ * the Foundry artefacts in `packages/contracts/out`, never from a hand
8
+ * transcription, so there is one source of truth for every selector.
9
+ */
10
+ import { keccak256Ascii } from "./keccak256.js";
11
+ /**
12
+ * Canonical event signatures, the exact strings the topic hash is taken over.
13
+ * No spaces, no parameter names, canonical types.
14
+ */
15
+ export const EVENT_SIGNATURES = {
16
+ /** `TabBook.SettlementApplied`: a Settlement lowered an Open Tab. `topics[1]` is the settlement id. */
17
+ SettlementApplied: "SettlementApplied(bytes32,address,bytes32,address,uint256,uint256,uint128)",
18
+ /** `TabBook.DeliveryRecorded`: a Service metered usage into an Open Tab. `topics[1]` is the Agent. */
19
+ DeliveryRecorded: "DeliveryRecorded(address,bytes32,address,bytes32,uint32,uint256,uint64)",
20
+ /** `TabBook.HistoryExtended`: the Agent's history commitment advanced by one record. */
21
+ HistoryExtended: "HistoryExtended(address,address,bytes32,uint32,(bytes32,address,uint128,uint64,uint64,bool,bool))",
22
+ /** `TabBook.TabDelinquent`: a Settlement Window closed with the tab still open. */
23
+ TabDelinquent: "TabDelinquent(bytes32,address,bytes32,address,uint128,uint64)",
24
+ /** `TabBook.TabDelinquencyCleared`: the delinquent tab settled to zero. */
25
+ TabDelinquencyCleared: "TabDelinquencyCleared(bytes32,address,address)",
26
+ /** `TabSettlement.Settled`: the Asset moved from the Agent to the Service's Collection address. */
27
+ Settled: "Settled(bytes32,address,bytes32,address,uint128,uint128,uint128,address)",
28
+ /**
29
+ * `TabSettlement.SettledGasless`: the Settlement arrived on the Agent's Permit2 signature and
30
+ * `topics[2]` is the relayer that paid for it. Always follows a `Settled` with the same id.
31
+ */
32
+ SettledGasless: "SettledGasless(bytes32,address)",
33
+ /** `Bond.BondFunded`: stake entered the escrow. */
34
+ BondFunded: "BondFunded(bytes32,address,uint128,address)",
35
+ /** `Bond.BondWithdrawn`: stake left the escrow. */
36
+ BondWithdrawn: "BondWithdrawn(bytes32,address,uint128,address)",
37
+ /** ERC-20 `Transfer`, for reading balances and payouts off the Asset contract. */
38
+ Transfer: "Transfer(address,address,uint256)",
39
+ };
40
+ /**
41
+ * `topics[0]` for each pinned event: the Keccak-256 hash of its canonical
42
+ * signature. Derived rather than transcribed, so a signature edit cannot leave a
43
+ * stale hash behind.
44
+ */
45
+ export const EVENT_TOPIC0 = Object.fromEntries(Object.entries(EVENT_SIGNATURES).map(([name, signature]) => [name, keccak256Ascii(signature)]));
46
+ /** `topics[0]` for a pinned event. */
47
+ export const eventTopic0 = (name) => EVENT_TOPIC0[name];
48
+ // ---------------------------------------------------------------------------
49
+ // Gasless Settlement through Permit2
50
+ //
51
+ // `TabSettlement.settleWithPermit2` verifies an EIP-712 signature the Agent
52
+ // made under Permit2's domain, over Permit2's `PermitWitnessTransferFrom` with
53
+ // a Tab-specific witness. Everything a signer needs is pinned here so the SDK
54
+ // cannot drift from the contract: the witness type, the string the contract
55
+ // hands Permit2, and the typed-data layout for `signTypedData`.
56
+ // ---------------------------------------------------------------------------
57
+ /**
58
+ * The witness struct, exactly as `TabSettlement.WITNESS_TYPE` declares it.
59
+ * `surface` is the `TabSettlement` address and `chainId` the chain it lives on.
60
+ */
61
+ export const TAB_SETTLEMENT_WITNESS_TYPE = "TabSettlement(bytes32 serviceId,address asset,uint128 amount,address surface,uint256 chainId)";
62
+ /** `keccak256(TAB_SETTLEMENT_WITNESS_TYPE)`, the same value as `TabSettlement.WITNESS_TYPEHASH`. */
63
+ export const TAB_SETTLEMENT_WITNESS_TYPEHASH = keccak256Ascii(TAB_SETTLEMENT_WITNESS_TYPE);
64
+ /**
65
+ * What the contract passes Permit2 as `witnessTypeString`, exactly as
66
+ * `TabSettlement.WITNESS_TYPE_STRING` declares it. Permit2 appends it to
67
+ * `PERMIT2_WITNESS_TRANSFER_FROM_STUB`.
68
+ */
69
+ export const PERMIT2_WITNESS_TYPE_STRING = `TabSettlement witness)${TAB_SETTLEMENT_WITNESS_TYPE}TokenPermissions(address token,uint256 amount)`;
70
+ /** Permit2's own `_PERMIT_TRANSFER_FROM_WITNESS_TYPEHASH_STUB`. */
71
+ export const PERMIT2_WITNESS_TRANSFER_FROM_STUB = "PermitWitnessTransferFrom(TokenPermissions permitted,address spender,uint256 nonce,uint256 deadline,";
72
+ /** The full primary type Permit2 hashes, and its typehash. */
73
+ export const PERMIT2_WITNESS_TRANSFER_FROM_TYPE = `${PERMIT2_WITNESS_TRANSFER_FROM_STUB}${PERMIT2_WITNESS_TYPE_STRING}`;
74
+ export const PERMIT2_WITNESS_TRANSFER_FROM_TYPEHASH = keccak256Ascii(PERMIT2_WITNESS_TRANSFER_FROM_TYPE);
75
+ /** Permit2's EIP-712 domain name. Its domain has no `version`. */
76
+ export const PERMIT2_DOMAIN_NAME = "Permit2";
77
+ /**
78
+ * The EIP-712 domain an Agent signs a gasless Settlement under: Permit2's, on
79
+ * the chain the Settlement happens on.
80
+ */
81
+ export function permit2Domain(chainId, permit2) {
82
+ return {
83
+ name: PERMIT2_DOMAIN_NAME,
84
+ chainId: typeof chainId === "bigint" ? chainId : BigInt(chainId),
85
+ verifyingContract: permit2,
86
+ };
87
+ }
88
+ /**
89
+ * The typed-data types for `signTypedData`, primary type
90
+ * `PermitWitnessTransferFrom`. Field order matches Permit2's stub and the
91
+ * witness type above; the referenced structs are what the type string names.
92
+ */
93
+ export const PERMIT2_WITNESS_TRANSFER_FROM_TYPES = {
94
+ PermitWitnessTransferFrom: [
95
+ { name: "permitted", type: "TokenPermissions" },
96
+ { name: "spender", type: "address" },
97
+ { name: "nonce", type: "uint256" },
98
+ { name: "deadline", type: "uint256" },
99
+ { name: "witness", type: "TabSettlement" },
100
+ ],
101
+ TokenPermissions: [
102
+ { name: "token", type: "address" },
103
+ { name: "amount", type: "uint256" },
104
+ ],
105
+ TabSettlement: [
106
+ { name: "serviceId", type: "bytes32" },
107
+ { name: "asset", type: "address" },
108
+ { name: "amount", type: "uint128" },
109
+ { name: "surface", type: "address" },
110
+ { name: "chainId", type: "uint256" },
111
+ ],
112
+ };
113
+ export const PERMIT2_WITNESS_TRANSFER_FROM_PRIMARY_TYPE = "PermitWitnessTransferFrom";
114
+ /**
115
+ * The gasless entry point on `TabSettlement`, as a human-readable ABI fragment.
116
+ * `spender` in the signed message is the `TabSettlement` address and `witness`
117
+ * is `TabSettlement.witnessHash(serviceId, asset, amount)`.
118
+ */
119
+ export const TAB_SETTLEMENT_PERMIT2_ABI = [
120
+ "function settleWithPermit2(address agent, bytes32 serviceId, address asset, uint128 amount, uint256 nonce, uint256 deadline, bytes signature) returns (bytes32 settlementId, uint128 applied, uint128 toPrepaid)",
121
+ "function witnessHash(bytes32 serviceId, address asset, uint128 amount) view returns (bytes32)",
122
+ "function WITNESS_TYPE_STRING() view returns (string)",
123
+ "function WITNESS_TYPEHASH() view returns (bytes32)",
124
+ "function PERMIT2() view returns (address)",
125
+ "event SettledGasless(bytes32 indexed settlementId, address indexed relayer)",
126
+ ];
127
+ /** The slice of Permit2 a signer or relayer touches, as human-readable ABI. */
128
+ export const PERMIT2_ABI = [
129
+ "function DOMAIN_SEPARATOR() view returns (bytes32)",
130
+ "function nonceBitmap(address owner, uint256 wordPosition) view returns (uint256)",
131
+ "function invalidateUnorderedNonces(uint256 wordPos, uint256 mask)",
132
+ "event UnorderedNonceInvalidation(address indexed owner, uint256 word, uint256 mask)",
133
+ ];
134
+ // ---------------------------------------------------------------------------
135
+ // ERC-8004
136
+ //
137
+ // Human-readable fragments copied from `IdentityRegistryUpgradeable` and
138
+ // `ReputationRegistryUpgradeable` in erc-8004/erc-8004-contracts, the
139
+ // implementations behind the canonical proxies (`getVersion()` reports 2.0.0).
140
+ // Only what Tab reads and writes; the ERC-721 and UUPS surface is omitted.
141
+ // ---------------------------------------------------------------------------
142
+ /**
143
+ * The Identity Registry: an ERC-721 whose token id is the agentId, whose
144
+ * `tokenURI` is the agent's registration file, and whose `agentWallet`
145
+ * metadata is the account acting for the agent. `register` mints to the
146
+ * caller and records it as the wallet; ids are sequential from zero.
147
+ */
148
+ export const ERC8004_IDENTITY_REGISTRY_ABI = [
149
+ "function register() returns (uint256 agentId)",
150
+ "function register(string agentURI) returns (uint256 agentId)",
151
+ "function register(string agentURI, (string metadataKey, bytes metadataValue)[] metadata) returns (uint256 agentId)",
152
+ "function setAgentURI(uint256 agentId, string newURI)",
153
+ "function tokenURI(uint256 tokenId) view returns (string)",
154
+ "function ownerOf(uint256 tokenId) view returns (address)",
155
+ "function balanceOf(address owner) view returns (uint256)",
156
+ "function getAgentWallet(uint256 agentId) view returns (address)",
157
+ "function getMetadata(uint256 agentId, string metadataKey) view returns (bytes)",
158
+ "function setMetadata(uint256 agentId, string metadataKey, bytes metadataValue)",
159
+ "function isAuthorizedOrOwner(address spender, uint256 agentId) view returns (bool)",
160
+ "function getVersion() pure returns (string)",
161
+ "event Registered(uint256 indexed agentId, string agentURI, address indexed owner)",
162
+ "event URIUpdated(uint256 indexed agentId, string newURI, address indexed updatedBy)",
163
+ "event MetadataSet(uint256 indexed agentId, string indexed indexedMetadataKey, string metadataKey, bytes metadataValue)",
164
+ "event Transfer(address indexed from, address indexed to, uint256 indexed tokenId)",
165
+ ];
166
+ /**
167
+ * The Reputation Registry: feedback about an agent, keyed by agentId and the
168
+ * client that gave it, 1-indexed per client. An agent's owner or operator
169
+ * cannot give feedback about it.
170
+ */
171
+ export const ERC8004_REPUTATION_REGISTRY_ABI = [
172
+ "function giveFeedback(uint256 agentId, int128 value, uint8 valueDecimals, string tag1, string tag2, string endpoint, string feedbackURI, bytes32 feedbackHash)",
173
+ "function revokeFeedback(uint256 agentId, uint64 feedbackIndex)",
174
+ "function appendResponse(uint256 agentId, address clientAddress, uint64 feedbackIndex, string responseURI, bytes32 responseHash)",
175
+ "function getSummary(uint256 agentId, address[] clientAddresses, string tag1, string tag2) view returns (uint64 count, int128 summaryValue, uint8 summaryValueDecimals)",
176
+ "function readFeedback(uint256 agentId, address clientAddress, uint64 feedbackIndex) view returns (int128 value, uint8 valueDecimals, string tag1, string tag2, bool isRevoked)",
177
+ "function readAllFeedback(uint256 agentId, address[] clientAddresses, string tag1, string tag2, bool includeRevoked) view returns (address[] clients, uint64[] feedbackIndexes, int128[] values, uint8[] valueDecimals, string[] tag1s, string[] tag2s, bool[] revokedStatuses)",
178
+ "function getLastIndex(uint256 agentId, address clientAddress) view returns (uint64)",
179
+ "function getClients(uint256 agentId) view returns (address[])",
180
+ "function getIdentityRegistry() view returns (address)",
181
+ "function getVersion() pure returns (string)",
182
+ "event NewFeedback(uint256 indexed agentId, address indexed clientAddress, uint64 feedbackIndex, int128 value, uint8 valueDecimals, string indexed indexedTag1, string tag1, string tag2, string endpoint, string feedbackURI, bytes32 feedbackHash)",
183
+ "event FeedbackRevoked(uint256 indexed agentId, address indexed clientAddress, uint64 indexed feedbackIndex)",
184
+ "event ResponseAppended(uint256 indexed agentId, address indexed clientAddress, uint64 feedbackIndex, address indexed responder, string responseURI, bytes32 responseHash)",
185
+ ];
186
+ /** Canonical ERC-8004 event signatures, for topic filters. */
187
+ export const ERC8004_EVENT_SIGNATURES = {
188
+ Registered: "Registered(uint256,string,address)",
189
+ URIUpdated: "URIUpdated(uint256,string,address)",
190
+ MetadataSet: "MetadataSet(uint256,string,string,bytes)",
191
+ NewFeedback: "NewFeedback(uint256,address,uint64,int128,uint8,string,string,string,string,string,bytes32)",
192
+ FeedbackRevoked: "FeedbackRevoked(uint256,address,uint64)",
193
+ ResponseAppended: "ResponseAppended(uint256,address,uint64,address,string,bytes32)",
194
+ };
195
+ /** `topics[0]` for each ERC-8004 event, derived from its canonical signature. */
196
+ export const ERC8004_EVENT_TOPIC0 = Object.fromEntries(Object.entries(ERC8004_EVENT_SIGNATURES).map(([name, signature]) => [name, keccak256Ascii(signature)]));
197
+ //# sourceMappingURL=abi.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"abi.js","sourceRoot":"","sources":["../src/abi.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAGhD;;;GAGG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG;IAC9B,uGAAuG;IACvG,iBAAiB,EAAE,4EAA4E;IAC/F,sGAAsG;IACtG,gB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FAA6F;IAC1G,eAAe,EAAE,yCAAyC;IAC1D,gBAAgB,EAAE,iEAAiE;CAC3E,CAAC;AAIX,iFAAiF;AACjF,MAAM,CAAC,MAAM,oBAAoB,GAAgD,MAAM,CAAC,WAAW,CACjG,MAAM,CAAC,OAAO,CAAC,wBAAwB,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,EAAE,SAAS,CAAC,EAAE,EAAE,CAAC,CAAC,IAAI,EAAE,cAAc,CAAC,SAAS,CAAC,CAAC,CAAC,CAClE,CAAC","sourcesContent":["/**\n * Contract interface constants shared by the SDK, the gateway, the registry\n * indexer, and the dashboard.\n *\n * Only what is fixed and independently checkable lives here: canonical event\n * signatures and the topic hashes derived from them. Full ABI arrays come from\n * the Foundry artefacts in `packages/contracts/out`, never from a hand\n * transcription, so there is one source of truth for every selector.\n */\nimport { keccak256Ascii } from \"./keccak256.js\";\nimport type { Bytes32 } from \"./hex.js\";\n\n/**\n * Canonical event signatures, the exact strings the topic hash is taken over.\n * No spaces, no parameter names, canonical types.\n */\nexport const EVENT_SIGNATURES = {\n /** `TabBook.SettlementApplied`: a Settlement lowered an Open Tab. `topics[1]` is the settlement id. */\n SettlementApplied: \"SettlementApplied(bytes32,address,bytes32,address,uint256,uint256,uint128)\",\n /** `TabBook.DeliveryRecorded`: a Service metered usage into an Open Tab. `topics[1]` is the Agent. */\n DeliveryRecorded: \"DeliveryRecorded(address,bytes32,address,bytes32,uint32,uint256,uint64)\",\n /** `TabBook.HistoryExtended`: the Agent's history commitment advanced by one record. */\n HistoryExtended:\n \"HistoryExtended(address,address,bytes32,uint32,(bytes32,address,uint128,uint64,uint64,bool,bool))\",\n /** `TabBook.TabDelinquent`: a Settlement Window closed with the tab still open. */\n TabDelinquent: \"TabDelinquent(bytes32,address,bytes32,address,uint128,uint64)\",\n /** `TabBook.TabDelinquencyCleared`: the delinquent tab settled to zero. */\n TabDelinquencyCleared: \"TabDelinquencyCleared(bytes32,address,address)\",\n /** `TabSettlement.Settled`: the Asset moved from the Agent to the Service's Collection address. */\n Settled: \"Settled(bytes32,address,bytes32,address,uint128,uint128,uint128,address)\",\n /**\n * `TabSettlement.SettledGasless`: the Settlement arrived on the Agent's Permit2 signature and\n * `topics[2]` is the relayer that paid for it. Always follows a `Settled` with the same id.\n */\n SettledGasless: \"SettledGasless(bytes32,address)\",\n /** `Bond.BondFunded`: stake entered the escrow. */\n BondFunded: \"BondFunded(bytes32,address,uint128,address)\",\n /** `Bond.BondWithdrawn`: stake left the escrow. */\n BondWithdrawn: \"BondWithdrawn(bytes32,address,uint128,address)\",\n /** ERC-20 `Transfer`, for reading balances and payouts off the Asset contract. */\n Transfer: \"Transfer(address,address,uint256)\",\n} as const;\n\n/** Name of an event whose signature this module pins. */\nexport type EventName = keyof typeof EVENT_SIGNATURES;\n\n/**\n * `topics[0]` for each pinned event: the Keccak-256 hash of its canonical\n * signature. Derived rather than transcribed, so a signature edit cannot leave a\n * stale hash behind.\n */\nexport const EVENT_TOPIC0: Readonly<Record<EventName, Bytes32>> = Object.fromEntries(\n Object.entries(EVENT_SIGNATURES).map(([name, signature]) => [name, keccak256Ascii(signature)]),\n) as Record<EventName, Bytes32>;\n\n/** `topics[0]` for a pinned event. */\nexport const eventTopic0 = (name: EventName): Bytes32 => EVENT_TOPIC0[name];\n\n// ---------------------------------------------------------------------------\n// Gasless Settlement through Permit2\n//\n// `TabSettlement.settleWithPermit2` verifies an EIP-712 signature the Agent\n// made under Permit2's domain, over Permit2's `PermitWitnessTransferFrom` with\n// a Tab-specific witness. Everything a signer needs is pinned here so the SDK\n// cannot drift from the contract: the witness type, the string the contract\n// hands Permit2, and the typed-data layout for `signTypedData`.\n// ---------------------------------------------------------------------------\n\n/**\n * The witness struct, exactly as `TabSettlement.WITNESS_TYPE` declares it.\n * `surface` is the `TabSettlement` address and `chainId` the chain it lives on.\n */\nexport const TAB_SETTLEMENT_WITNESS_TYPE =\n \"TabSettlement(bytes32 serviceId,address asset,uint128 amount,address surface,uint256 chainId)\" as const;\n\n/** `keccak256(TAB_SETTLEMENT_WITNESS_TYPE)`, the same value as `TabSettlement.WITNESS_TYPEHASH`. */\nexport const TAB_SETTLEMENT_WITNESS_TYPEHASH: Bytes32 = keccak256Ascii(TAB_SETTLEMENT_WITNESS_TYPE);\n\n/**\n * What the contract passes Permit2 as `witnessTypeString`, exactly as\n * `TabSettlement.WITNESS_TYPE_STRING` declares it. Permit2 appends it to\n * `PERMIT2_WITNESS_TRANSFER_FROM_STUB`.\n */\nexport const PERMIT2_WITNESS_TYPE_STRING =\n `TabSettlement witness)${TAB_SETTLEMENT_WITNESS_TYPE}TokenPermissions(address token,uint256 amount)` as const;\n\n/** Permit2's own `_PERMIT_TRANSFER_FROM_WITNESS_TYPEHASH_STUB`. */\nexport const PERMIT2_WITNESS_TRANSFER_FROM_STUB =\n \"PermitWitnessTransferFrom(TokenPermissions permitted,address spender,uint256 nonce,uint256 deadline,\" as const;\n\n/** The full primary type Permit2 hashes, and its typehash. */\nexport const PERMIT2_WITNESS_TRANSFER_FROM_TYPE =\n `${PERMIT2_WITNESS_TRANSFER_FROM_STUB}${PERMIT2_WITNESS_TYPE_STRING}` as const;\nexport const PERMIT2_WITNESS_TRANSFER_FROM_TYPEHASH: Bytes32 = keccak256Ascii(\n PERMIT2_WITNESS_TRANSFER_FROM_TYPE,\n);\n\n/** Permit2's EIP-712 domain name. Its domain has no `version`. */\nexport const PERMIT2_DOMAIN_NAME = \"Permit2\" as const;\n\n/**\n * The EIP-712 domain an Agent signs a gasless Settlement under: Permit2's, on\n * the chain the Settlement happens on.\n */\nexport function permit2Domain(chainId: number | bigint, permit2: `0x${string}`) {\n return {\n name: PERMIT2_DOMAIN_NAME,\n chainId: typeof chainId === \"bigint\" ? chainId : BigInt(chainId),\n verifyingContract: permit2,\n } as const;\n}\n\n/**\n * The typed-data types for `signTypedData`, primary type\n * `PermitWitnessTransferFrom`. Field order matches Permit2's stub and the\n * witness type above; the referenced structs are what the type string names.\n */\nexport const PERMIT2_WITNESS_TRANSFER_FROM_TYPES = {\n PermitWitnessTransferFrom: [\n { name: \"permitted\", type: \"TokenPermissions\" },\n { name: \"spender\", type: \"address\" },\n { name: \"nonce\", type: \"uint256\" },\n { name: \"deadline\", type: \"uint256\" },\n { name: \"witness\", type: \"TabSettlement\" },\n ],\n TokenPermissions: [\n { name: \"token\", type: \"address\" },\n { name: \"amount\", type: \"uint256\" },\n ],\n TabSettlement: [\n { name: \"serviceId\", type: \"bytes32\" },\n { name: \"asset\", type: \"address\" },\n { name: \"amount\", type: \"uint128\" },\n { name: \"surface\", type: \"address\" },\n { name: \"chainId\", type: \"uint256\" },\n ],\n} as const;\n\nexport const PERMIT2_WITNESS_TRANSFER_FROM_PRIMARY_TYPE = \"PermitWitnessTransferFrom\" as const;\n\n/**\n * The gasless entry point on `TabSettlement`, as a human-readable ABI fragment.\n * `spender` in the signed message is the `TabSettlement` address and `witness`\n * is `TabSettlement.witnessHash(serviceId, asset, amount)`.\n */\nexport const TAB_SETTLEMENT_PERMIT2_ABI = [\n \"function settleWithPermit2(address agent, bytes32 serviceId, address asset, uint128 amount, uint256 nonce, uint256 deadline, bytes signature) returns (bytes32 settlementId, uint128 applied, uint128 toPrepaid)\",\n \"function witnessHash(bytes32 serviceId, address asset, uint128 amount) view returns (bytes32)\",\n \"function WITNESS_TYPE_STRING() view returns (string)\",\n \"function WITNESS_TYPEHASH() view returns (bytes32)\",\n \"function PERMIT2() view returns (address)\",\n \"event SettledGasless(bytes32 indexed settlementId, address indexed relayer)\",\n] as const;\n\n/** The slice of Permit2 a signer or relayer touches, as human-readable ABI. */\nexport const PERMIT2_ABI = [\n \"function DOMAIN_SEPARATOR() view returns (bytes32)\",\n \"function nonceBitmap(address owner, uint256 wordPosition) view returns (uint256)\",\n \"function invalidateUnorderedNonces(uint256 wordPos, uint256 mask)\",\n \"event UnorderedNonceInvalidation(address indexed owner, uint256 word, uint256 mask)\",\n] as const;\n\n// ---------------------------------------------------------------------------\n// ERC-8004\n//\n// Human-readable fragments copied from `IdentityRegistryUpgradeable` and\n// `ReputationRegistryUpgradeable` in erc-8004/erc-8004-contracts, the\n// implementations behind the canonical proxies (`getVersion()` reports 2.0.0).\n// Only what Tab reads and writes; the ERC-721 and UUPS surface is omitted.\n// ---------------------------------------------------------------------------\n\n/**\n * The Identity Registry: an ERC-721 whose token id is the agentId, whose\n * `tokenURI` is the agent's registration file, and whose `agentWallet`\n * metadata is the account acting for the agent. `register` mints to the\n * caller and records it as the wallet; ids are sequential from zero.\n */\nexport const ERC8004_IDENTITY_REGISTRY_ABI = [\n \"function register() returns (uint256 agentId)\",\n \"function register(string agentURI) returns (uint256 agentId)\",\n \"function register(string agentURI, (string metadataKey, bytes metadataValue)[] metadata) returns (uint256 agentId)\",\n \"function setAgentURI(uint256 agentId, string newURI)\",\n \"function tokenURI(uint256 tokenId) view returns (string)\",\n \"function ownerOf(uint256 tokenId) view returns (address)\",\n \"function balanceOf(address owner) view returns (uint256)\",\n \"function getAgentWallet(uint256 agentId) view returns (address)\",\n \"function getMetadata(uint256 agentId, string metadataKey) view returns (bytes)\",\n \"function setMetadata(uint256 agentId, string metadataKey, bytes metadataValue)\",\n \"function isAuthorizedOrOwner(address spender, uint256 agentId) view returns (bool)\",\n \"function getVersion() pure returns (string)\",\n \"event Registered(uint256 indexed agentId, string agentURI, address indexed owner)\",\n \"event URIUpdated(uint256 indexed agentId, string newURI, address indexed updatedBy)\",\n \"event MetadataSet(uint256 indexed agentId, string indexed indexedMetadataKey, string metadataKey, bytes metadataValue)\",\n \"event Transfer(address indexed from, address indexed to, uint256 indexed tokenId)\",\n] as const;\n\n/**\n * The Reputation Registry: feedback about an agent, keyed by agentId and the\n * client that gave it, 1-indexed per client. An agent's owner or operator\n * cannot give feedback about it.\n */\nexport const ERC8004_REPUTATION_REGISTRY_ABI = [\n \"function giveFeedback(uint256 agentId, int128 value, uint8 valueDecimals, string tag1, string tag2, string endpoint, string feedbackURI, bytes32 feedbackHash)\",\n \"function revokeFeedback(uint256 agentId, uint64 feedbackIndex)\",\n \"function appendResponse(uint256 agentId, address clientAddress, uint64 feedbackIndex, string responseURI, bytes32 responseHash)\",\n \"function getSummary(uint256 agentId, address[] clientAddresses, string tag1, string tag2) view returns (uint64 count, int128 summaryValue, uint8 summaryValueDecimals)\",\n \"function readFeedback(uint256 agentId, address clientAddress, uint64 feedbackIndex) view returns (int128 value, uint8 valueDecimals, string tag1, string tag2, bool isRevoked)\",\n \"function readAllFeedback(uint256 agentId, address[] clientAddresses, string tag1, string tag2, bool includeRevoked) view returns (address[] clients, uint64[] feedbackIndexes, int128[] values, uint8[] valueDecimals, string[] tag1s, string[] tag2s, bool[] revokedStatuses)\",\n \"function getLastIndex(uint256 agentId, address clientAddress) view returns (uint64)\",\n \"function getClients(uint256 agentId) view returns (address[])\",\n \"function getIdentityRegistry() view returns (address)\",\n \"function getVersion() pure returns (string)\",\n \"event NewFeedback(uint256 indexed agentId, address indexed clientAddress, uint64 feedbackIndex, int128 value, uint8 valueDecimals, string indexed indexedTag1, string tag1, string tag2, string endpoint, string feedbackURI, bytes32 feedbackHash)\",\n \"event FeedbackRevoked(uint256 indexed agentId, address indexed clientAddress, uint64 indexed feedbackIndex)\",\n \"event ResponseAppended(uint256 indexed agentId, address indexed clientAddress, uint64 feedbackIndex, address indexed responder, string responseURI, bytes32 responseHash)\",\n] as const;\n\n/** Canonical ERC-8004 event signatures, for topic filters. */\nexport const ERC8004_EVENT_SIGNATURES = {\n Registered: \"Registered(uint256,string,address)\",\n URIUpdated: \"URIUpdated(uint256,string,address)\",\n MetadataSet: \"MetadataSet(uint256,string,string,bytes)\",\n NewFeedback: \"NewFeedback(uint256,address,uint64,int128,uint8,string,string,string,string,string,bytes32)\",\n FeedbackRevoked: \"FeedbackRevoked(uint256,address,uint64)\",\n ResponseAppended: \"ResponseAppended(uint256,address,uint64,address,string,bytes32)\",\n} as const;\n\nexport type Erc8004EventName = keyof typeof ERC8004_EVENT_SIGNATURES;\n\n/** `topics[0]` for each ERC-8004 event, derived from its canonical signature. */\nexport const ERC8004_EVENT_TOPIC0: Readonly<Record<Erc8004EventName, Bytes32>> = Object.fromEntries(\n Object.entries(ERC8004_EVENT_SIGNATURES).map(([name, signature]) => [name, keccak256Ascii(signature)]),\n) as Record<Erc8004EventName, Bytes32>;\n"]}
@@ -0,0 +1,118 @@
1
+ /**
2
+ * Chain and Asset constants for Tab on Monad.
3
+ *
4
+ * Tab runs on one chain. The Agent's payment and the ledger entry happen in the
5
+ * same Monad transaction, so nothing in the system refers to any other chain.
6
+ * What this module carries is which Monad network a deployment targets and
7
+ * which Assets it settles in.
8
+ *
9
+ * Addresses of Tab's own contracts are deployment output and live in
10
+ * `deployments.json`, never here.
11
+ */
12
+ import type { Address } from "./hex.js";
13
+ /** A Monad network a Tab deployment can target. */
14
+ export interface ChainDescriptor {
15
+ readonly name: string;
16
+ readonly chainId: number;
17
+ readonly rpcUrl: string;
18
+ readonly explorerUrl: string;
19
+ /** The MON faucet, testnet only. */
20
+ readonly faucetUrl?: string;
21
+ }
22
+ export declare const MONAD_MAINNET: {
23
+ readonly name: "Monad Mainnet";
24
+ readonly chainId: 143;
25
+ readonly rpcUrl: "https://rpc.monad.xyz";
26
+ readonly explorerUrl: "https://monadvision.com";
27
+ };
28
+ export declare const MONAD_TESTNET: {
29
+ readonly name: "Monad Testnet";
30
+ readonly chainId: 10143;
31
+ readonly rpcUrl: "https://testnet-rpc.monad.xyz";
32
+ readonly explorerUrl: "https://testnet.monadvision.com";
33
+ readonly faucetUrl: "https://faucet.monad.xyz";
34
+ };
35
+ export declare const CHAINS: {
36
+ readonly 143: {
37
+ readonly name: "Monad Mainnet";
38
+ readonly chainId: 143;
39
+ readonly rpcUrl: "https://rpc.monad.xyz";
40
+ readonly explorerUrl: "https://monadvision.com";
41
+ };
42
+ readonly 10143: {
43
+ readonly name: "Monad Testnet";
44
+ readonly chainId: 10143;
45
+ readonly rpcUrl: "https://testnet-rpc.monad.xyz";
46
+ readonly explorerUrl: "https://testnet.monadvision.com";
47
+ readonly faucetUrl: "https://faucet.monad.xyz";
48
+ };
49
+ };
50
+ export type MonadChainId = keyof typeof CHAINS;
51
+ export declare function isMonadChainId(value: unknown): value is MonadChainId;
52
+ export declare function chainFor(chainId: number | bigint): ChainDescriptor | undefined;
53
+ /** Link to an address or a transaction on the explorer for a chain. */
54
+ export declare function explorerLink(chain: ChainDescriptor, kind: "address" | "tx", hash: string): string;
55
+ /** A stablecoin Tab settles in. Amounts everywhere are integer base units. */
56
+ export interface AssetDescriptor {
57
+ readonly symbol: string;
58
+ readonly decimals: number;
59
+ readonly address: Address;
60
+ }
61
+ /** Canonical stablecoins on Monad Mainnet. */
62
+ export declare const MAINNET_ASSETS: {
63
+ readonly USDC: {
64
+ readonly symbol: "USDC";
65
+ readonly decimals: 6;
66
+ readonly address: "0x754704Bc059F8C67012fEd69BC8A327a5aafb603";
67
+ };
68
+ readonly AUSD: {
69
+ readonly symbol: "AUSD";
70
+ readonly decimals: 6;
71
+ readonly address: "0x00000000eFE302BEAA2b3e6e1b18d08D69a9012a";
72
+ };
73
+ };
74
+ /**
75
+ * Stablecoins on Monad Testnet. `USDC` is Circle's own testnet deployment
76
+ * (`name` "USDC", EIP-712 version "2", 20 USDC per address every two hours from
77
+ * https://faucet.circle.com). `MockUsdc`, the mintable test double the deploy
78
+ * script ships, is a deployment output and lives in `deployments.json`.
79
+ */
80
+ export declare const TESTNET_ASSETS: {
81
+ readonly USDC: {
82
+ readonly symbol: "USDC";
83
+ readonly decimals: 6;
84
+ readonly address: "0x534b2f3A21130d7a60830c2Df862319e593943A3";
85
+ };
86
+ };
87
+ /**
88
+ * Uniswap's Permit2, at its canonical address on every chain it was deployed
89
+ * to, Monad Mainnet and Testnet included. `TabSettlement.settleWithPermit2`
90
+ * verifies an Agent's signature against it, so an Agent approves Permit2 once
91
+ * and signs thereafter.
92
+ */
93
+ export declare const PERMIT2_ADDRESS: "0x000000000022D473030F116dDEE9F6B43aC78BA3";
94
+ /** The x402 facilitator that verifies and settles `exact` payments on Monad. */
95
+ export declare const X402_FACILITATOR_URL: "https://x402-facilitator.molandak.org";
96
+ /** The two ERC-8004 registries a Tab deployment reads and writes. */
97
+ export interface Erc8004Registries {
98
+ /** Agent identities: an ERC-721 whose token id is the agentId and whose URI is the registration file. */
99
+ readonly identity: Address;
100
+ /** Feedback about agents, keyed by agentId and client. */
101
+ readonly reputation: Address;
102
+ }
103
+ /** The canonical ERC-8004 registries, keyed by chain id. */
104
+ export declare const ERC8004_REGISTRIES: {
105
+ readonly 143: {
106
+ readonly identity: "0x8004A169FB4a3325136EB29fA0ceB6D2e539a432";
107
+ readonly reputation: "0x8004BAa17C55a88189AE136b182e5fdA19dE9b63";
108
+ };
109
+ readonly 10143: {
110
+ readonly identity: "0x8004A818BFB912233c491871b3d84c89A494BD9e";
111
+ readonly reputation: "0x8004B663056A597Dffe9eCcC1965A193B7388713";
112
+ };
113
+ };
114
+ export declare function erc8004RegistriesFor(chainId: number | bigint): Erc8004Registries | undefined;
115
+ export declare const PLACEHOLDER_ADDRESS: "0x0000000000000000000000000000000000000000";
116
+ /** Formats base units of a six-decimal Asset for display, without floating point. */
117
+ export declare function formatBaseUnits(amount: bigint, decimals: number): string;
118
+ //# sourceMappingURL=chains.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"chains.d.ts","sourceRoot":"","sources":["../src/chains.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,UAAU,CAAC;AAExC,mDAAmD;AACnD,MAAM,WAAW,eAAe;IAC9B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,oCAAoC;IACpC,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;CAC7B;AAED,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ED,eAAO,MAAM,mBAAmB,EAAG,4CAAqD,CAAC;AAEzF,qFAAqF;AACrF,wBAAgB,eAAe,CAAC,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,CAOxE"}
@@ -0,0 +1,89 @@
1
+ export const MONAD_MAINNET = {
2
+ name: "Monad Mainnet",
3
+ chainId: 143,
4
+ rpcUrl: "https://rpc.monad.xyz",
5
+ explorerUrl: "https://monadvision.com",
6
+ };
7
+ export const MONAD_TESTNET = {
8
+ name: "Monad Testnet",
9
+ chainId: 10143,
10
+ rpcUrl: "https://testnet-rpc.monad.xyz",
11
+ explorerUrl: "https://testnet.monadvision.com",
12
+ faucetUrl: "https://faucet.monad.xyz",
13
+ };
14
+ export const CHAINS = {
15
+ [MONAD_MAINNET.chainId]: MONAD_MAINNET,
16
+ [MONAD_TESTNET.chainId]: MONAD_TESTNET,
17
+ };
18
+ export function isMonadChainId(value) {
19
+ return value === MONAD_MAINNET.chainId || value === MONAD_TESTNET.chainId;
20
+ }
21
+ export function chainFor(chainId) {
22
+ const narrowed = typeof chainId === "bigint" ? Number(chainId) : chainId;
23
+ return isMonadChainId(narrowed) ? CHAINS[narrowed] : undefined;
24
+ }
25
+ /** Link to an address or a transaction on the explorer for a chain. */
26
+ export function explorerLink(chain, kind, hash) {
27
+ return `${chain.explorerUrl}/${kind}/${hash}`;
28
+ }
29
+ /** Canonical stablecoins on Monad Mainnet. */
30
+ export const MAINNET_ASSETS = {
31
+ USDC: {
32
+ symbol: "USDC",
33
+ decimals: 6,
34
+ address: "0x754704Bc059F8C67012fEd69BC8A327a5aafb603",
35
+ },
36
+ AUSD: {
37
+ symbol: "AUSD",
38
+ decimals: 6,
39
+ address: "0x00000000eFE302BEAA2b3e6e1b18d08D69a9012a",
40
+ },
41
+ };
42
+ /**
43
+ * Stablecoins on Monad Testnet. `USDC` is Circle's own testnet deployment
44
+ * (`name` "USDC", EIP-712 version "2", 20 USDC per address every two hours from
45
+ * https://faucet.circle.com). `MockUsdc`, the mintable test double the deploy
46
+ * script ships, is a deployment output and lives in `deployments.json`.
47
+ */
48
+ export const TESTNET_ASSETS = {
49
+ USDC: {
50
+ symbol: "USDC",
51
+ decimals: 6,
52
+ address: "0x534b2f3A21130d7a60830c2Df862319e593943A3",
53
+ },
54
+ };
55
+ /**
56
+ * Uniswap's Permit2, at its canonical address on every chain it was deployed
57
+ * to, Monad Mainnet and Testnet included. `TabSettlement.settleWithPermit2`
58
+ * verifies an Agent's signature against it, so an Agent approves Permit2 once
59
+ * and signs thereafter.
60
+ */
61
+ export const PERMIT2_ADDRESS = "0x000000000022D473030F116dDEE9F6B43aC78BA3";
62
+ /** The x402 facilitator that verifies and settles `exact` payments on Monad. */
63
+ export const X402_FACILITATOR_URL = "https://x402-facilitator.molandak.org";
64
+ /** The canonical ERC-8004 registries, keyed by chain id. */
65
+ export const ERC8004_REGISTRIES = {
66
+ [MONAD_MAINNET.chainId]: {
67
+ identity: "0x8004A169FB4a3325136EB29fA0ceB6D2e539a432",
68
+ reputation: "0x8004BAa17C55a88189AE136b182e5fdA19dE9b63",
69
+ },
70
+ [MONAD_TESTNET.chainId]: {
71
+ identity: "0x8004A818BFB912233c491871b3d84c89A494BD9e",
72
+ reputation: "0x8004B663056A597Dffe9eCcC1965A193B7388713",
73
+ },
74
+ };
75
+ export function erc8004RegistriesFor(chainId) {
76
+ const narrowed = typeof chainId === "bigint" ? Number(chainId) : chainId;
77
+ return isMonadChainId(narrowed) ? ERC8004_REGISTRIES[narrowed] : undefined;
78
+ }
79
+ export const PLACEHOLDER_ADDRESS = "0x0000000000000000000000000000000000000000";
80
+ /** Formats base units of a six-decimal Asset for display, without floating point. */
81
+ export function formatBaseUnits(amount, decimals) {
82
+ const negative = amount < 0n;
83
+ const abs = negative ? -amount : amount;
84
+ const scale = 10n ** BigInt(decimals);
85
+ const whole = abs / scale;
86
+ const fraction = (abs % scale).toString().padStart(decimals, "0").replace(/0+$/, "");
87
+ return `${negative ? "-" : ""}${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M,GAAG,EAAE,CAAC;IAC7B,MAAM,GAAG,GAAG,QAAQ,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC;IACxC,MAAM,KAAK,GAAG,GAAG,IAAI,MAAM,CAAC,QAAQ,CAAC,CAAC;IACtC,MAAM,KAAK,GAAG,GAAG,GAAG,KAAK,CAAC;IAC1B,MAAM,QAAQ,GAAG,CAAC,GAAG,GAAG,KAAK,CAAC,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,QAAQ,EAAE,GAAG,CAAC,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;IACrF,OAAO,GAAG,QAAQ,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,GAAG,KAAK,GAAG,QAAQ,CAAC,CAAC,CAAC,IAAI,QAAQ,EAAE,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC;AAC3E,CAAC","sourcesContent":["/**\n * Chain and Asset constants for Tab on Monad.\n *\n * Tab runs on one chain. The Agent's payment and the ledger entry happen in the\n * same Monad transaction, so nothing in the system refers to any other chain.\n * What this module carries is which Monad network a deployment targets and\n * which Assets it settles in.\n *\n * Addresses of Tab's own contracts are deployment output and live in\n * `deployments.json`, never here.\n */\nimport type { Address } from \"./hex.js\";\n\n/** A Monad network a Tab deployment can target. */\nexport interface ChainDescriptor {\n readonly name: string;\n readonly chainId: number;\n readonly rpcUrl: string;\n readonly explorerUrl: string;\n /** The MON faucet, testnet only. */\n readonly faucetUrl?: string;\n}\n\nexport const MONAD_MAINNET = {\n name: \"Monad Mainnet\",\n chainId: 143,\n rpcUrl: \"https://rpc.monad.xyz\",\n explorerUrl: \"https://monadvision.com\",\n} as const satisfies ChainDescriptor;\n\nexport const MONAD_TESTNET = {\n name: \"Monad Testnet\",\n chainId: 10143,\n rpcUrl: \"https://testnet-rpc.monad.xyz\",\n explorerUrl: \"https://testnet.monadvision.com\",\n faucetUrl: \"https://faucet.monad.xyz\",\n} as const satisfies ChainDescriptor;\n\nexport const CHAINS = {\n [MONAD_MAINNET.chainId]: MONAD_MAINNET,\n [MONAD_TESTNET.chainId]: MONAD_TESTNET,\n} as const;\n\nexport type MonadChainId = keyof typeof CHAINS;\n\nexport function isMonadChainId(value: unknown): value is MonadChainId {\n return value === MONAD_MAINNET.chainId || value === MONAD_TESTNET.chainId;\n}\n\nexport function chainFor(chainId: number | bigint): ChainDescriptor | undefined {\n const narrowed = typeof chainId === \"bigint\" ? Number(chainId) : chainId;\n return isMonadChainId(narrowed) ? CHAINS[narrowed] : undefined;\n}\n\n/** Link to an address or a transaction on the explorer for a chain. */\nexport function explorerLink(chain: ChainDescriptor, kind: \"address\" | \"tx\", hash: string): string {\n return `${chain.explorerUrl}/${kind}/${hash}`;\n}\n\n/** A stablecoin Tab settles in. Amounts everywhere are integer base units. */\nexport interface AssetDescriptor {\n readonly symbol: string;\n readonly decimals: number;\n readonly address: Address;\n}\n\n/** Canonical stablecoins on Monad Mainnet. */\nexport const MAINNET_ASSETS = {\n USDC: {\n symbol: \"USDC\",\n decimals: 6,\n address: \"0x754704Bc059F8C67012fEd69BC8A327a5aafb603\",\n },\n AUSD: {\n symbol: \"AUSD\",\n decimals: 6,\n address: \"0x00000000eFE302BEAA2b3e6e1b18d08D69a9012a\",\n },\n} as const satisfies Readonly<Record<string, AssetDescriptor>>;\n\n/**\n * Stablecoins on Monad Testnet. `USDC` is Circle's own testnet deployment\n * (`name` \"USDC\", EIP-712 version \"2\", 20 USDC per address every two hours from\n * https://faucet.circle.com). `MockUsdc`, the mintable test double the deploy\n * script ships, is a deployment output and lives in `deployments.json`.\n */\nexport const TESTNET_ASSETS = {\n USDC: {\n symbol: \"USDC\",\n decimals: 6,\n address: \"0x534b2f3A21130d7a60830c2Df862319e593943A3\",\n },\n} as const satisfies Readonly<Record<string, AssetDescriptor>>;\n\n/**\n * Uniswap's Permit2, at its canonical address on every chain it was deployed\n * to, Monad Mainnet and Testnet included. `TabSettlement.settleWithPermit2`\n * verifies an Agent's signature against it, so an Agent approves Permit2 once\n * and signs thereafter.\n */\nexport const PERMIT2_ADDRESS = \"0x000000000022D473030F116dDEE9F6B43aC78BA3\" as const satisfies Address;\n\n/** The x402 facilitator that verifies and settles `exact` payments on Monad. */\nexport const X402_FACILITATOR_URL = \"https://x402-facilitator.molandak.org\" as const;\n\n/** The two ERC-8004 registries a Tab deployment reads and writes. */\nexport interface Erc8004Registries {\n /** Agent identities: an ERC-721 whose token id is the agentId and whose URI is the registration file. */\n readonly identity: Address;\n /** Feedback about agents, keyed by agentId and client. */\n readonly reputation: Address;\n}\n\n/** The canonical ERC-8004 registries, keyed by chain id. */\nexport const ERC8004_REGISTRIES = {\n [MONAD_MAINNET.chainId]: {\n identity: \"0x8004A169FB4a3325136EB29fA0ceB6D2e539a432\",\n reputation: \"0x8004BAa17C55a88189AE136b182e5fdA19dE9b63\",\n },\n [MONAD_TESTNET.chainId]: {\n identity: \"0x8004A818BFB912233c491871b3d84c89A494BD9e\",\n reputation: \"0x8004B663056A597Dffe9eCcC1965A193B7388713\",\n },\n} as const satisfies Readonly<Record<MonadChainId, Erc8004Registries>>;\n\nexport function erc8004RegistriesFor(chainId: number | bigint): Erc8004Registries | undefined {\n const narrowed = typeof chainId === \"bigint\" ? Number(chainId) : chainId;\n return isMonadChainId(narrowed) ? ERC8004_REGISTRIES[narrowed] : undefined;\n}\n\nexport const PLACEHOLDER_ADDRESS = \"0x0000000000000000000000000000000000000000\" as const;\n\n/** Formats base units of a six-decimal Asset for display, without floating point. */\nexport function formatBaseUnits(amount: bigint, decimals: number): string {\n const negative = amount < 0n;\n const abs = negative ? -amount : amount;\n const scale = 10n ** BigInt(decimals);\n const whole = abs / scale;\n const fraction = (abs % scale).toString().padStart(decimals, \"0\").replace(/0+$/, \"\");\n return `${negative ? \"-\" : \"\"}${whole}${fraction ? `.${fraction}` : \"\"}`;\n}\n"]}
@@ -0,0 +1,35 @@
1
+ /**
2
+ * Minimal hexadecimal primitives.
3
+ *
4
+ * `@tabai/shared` carries no runtime dependency, so the few byte-level helpers the
5
+ * chain constants and the event topics need are written here against native
6
+ * `bigint`. Nothing in this file allocates a buffer or touches the network.
7
+ */
8
+ /** A `0x`-prefixed hexadecimal string of any length. */
9
+ export type Hex = `0x${string}`;
10
+ /** A `0x`-prefixed 32-byte word: exactly 64 hexadecimal digits. */
11
+ export type Bytes32 = Hex;
12
+ /** A `0x`-prefixed 20-byte address: exactly 40 hexadecimal digits. */
13
+ export type Address = Hex;
14
+ /** Largest value a `uint64` field can hold: `2^64 - 1`. */
15
+ export declare const UINT64_MAX = 18446744073709551615n;
16
+ /** One past the largest `uint64` value: `2^64`. */
17
+ export declare const UINT64_CEILING = 18446744073709551616n;
18
+ /** Largest value a 32-byte word can hold: `2^256 - 1`. */
19
+ export declare const UINT256_MAX = 115792089237316195423570985008687907853269984665640564039457584007913129639935n;
20
+ export declare const isHex: (value: unknown) => value is Hex;
21
+ export declare const isBytes32: (value: unknown) => value is Bytes32;
22
+ export declare const isAddress: (value: unknown) => value is Address;
23
+ /**
24
+ * Renders an unsigned integer as a lower-case 32-byte word.
25
+ *
26
+ * @throws RangeError when `value` is negative or exceeds `2^256 - 1`.
27
+ */
28
+ export declare function toBytes32(value: bigint): Bytes32;
29
+ /**
30
+ * Reads a 32-byte word back into an unsigned integer.
31
+ *
32
+ * @throws TypeError when `value` is not exactly 64 hexadecimal digits behind `0x`.
33
+ */
34
+ export declare function fromBytes32(value: string): bigint;
35
+ //# sourceMappingURL=hex.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hex.d.ts","sourceRoot":"","sources":["../src/hex.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,wDAAwD;AACxD,MAAM,MAAM,GAAG,GAAG,KAAK,MAAM,EAAE,CAAC;AAEhC,mEAAmE;AACnE,MAAM,MAAM,OAAO,GAAG,GAAG,CAAC;AAE1B,sEAAsE;AACtE,MAAM,MAAM,OAAO,GAAG,GAAG,CAAC;AAI1B,2DAA2D;AAC3D,eAAO,MAAM,UAAU,wBAA8B,CAAC;AAEtD,mDAAmD;AACnD,eAAO,MAAM,cAAc,wBAA8B,CAAC;AAE1D,0DAA0D;AAC1D,eAAO,MAAM,WAAW,kFACkF,CAAC;AAE3G,eAAO,MAAM,KAAK,GAAI,OAAO,OAAO,KAAG,KAAK,IAAI,GACI,CAAC;AAErD,eAAO,MAAM,SAAS,GAAI,OAAO,OAAO,KAAG,KAAK,IAAI,OAA8C,CAAC;AAEnG,eAAO,MAAM,SAAS,GAAI,OAAO,OAAO,KAAG,KAAK,IAAI,OAA8C,CAAC;AAEnG;;;;GAIG;AACH,wBAAgB,SAAS,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAKhD;AAED;;;;GAIG;AACH,wBAAgB,WAAW,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAOjD"}
@@ -0,0 +1,40 @@
1
+ /**
2
+ * Minimal hexadecimal primitives.
3
+ *
4
+ * `@tabai/shared` carries no runtime dependency, so the few byte-level helpers the
5
+ * chain constants and the event topics need are written here against native
6
+ * `bigint`. Nothing in this file allocates a buffer or touches the network.
7
+ */
8
+ const HEX_SHAPE = /^0x[0-9a-fA-F]*$/;
9
+ /** Largest value a `uint64` field can hold: `2^64 - 1`. */
10
+ export const UINT64_MAX = 18446744073709551615n;
11
+ /** One past the largest `uint64` value: `2^64`. */
12
+ export const UINT64_CEILING = 18446744073709551616n;
13
+ /** Largest value a 32-byte word can hold: `2^256 - 1`. */
14
+ export const UINT256_MAX = 115792089237316195423570985008687907853269984665640564039457584007913129639935n;
15
+ export const isHex = (value) => typeof value === "string" && HEX_SHAPE.test(value);
16
+ export const isBytes32 = (value) => isHex(value) && value.length === 66;
17
+ export const isAddress = (value) => isHex(value) && value.length === 42;
18
+ /**
19
+ * Renders an unsigned integer as a lower-case 32-byte word.
20
+ *
21
+ * @throws RangeError when `value` is negative or exceeds `2^256 - 1`.
22
+ */
23
+ export function toBytes32(value) {
24
+ if (value < 0n || value > UINT256_MAX) {
25
+ throw new RangeError(`toBytes32: value must be in [0, 2^256 - 1], received ${value}`);
26
+ }
27
+ return `0x${value.toString(16).padStart(64, "0")}`;
28
+ }
29
+ /**
30
+ * Reads a 32-byte word back into an unsigned integer.
31
+ *
32
+ * @throws TypeError when `value` is not exactly 64 hexadecimal digits behind `0x`.
33
+ */
34
+ export function fromBytes32(value) {
35
+ if (!isBytes32(value)) {
36
+ throw new TypeError(`fromBytes32: expected a 0x-prefixed 32-byte word (66 characters), received ${JSON.stringify(value)}`);
37
+ }
38
+ return BigInt(value);
39
+ }
40
+ //# sourceMappingURL=hex.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hex.js","sourceRoot":"","sources":["../src/hex.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAWH,MAAM,SAAS,GAAG,kBAAkB,CAAC;AAErC,2DAA2D;AAC3D,MAAM,CAAC,MAAM,UAAU,GAAG,qBAA2B,CAAC;AAEtD,mDAAmD;AACnD,MAAM,CAAC,MAAM,cAAc,GAAG,qBAA2B,CAAC;AAE1D,0DAA0D;AAC1D,MAAM,CAAC,MAAM,WAAW,GACtB,+EAAwG,CAAC;AAE3G,MAAM,CAAC,MAAM,KAAK,GAAG,CAAC,KAAc,EAAgB,EAAE,CACpD,OAAO,KAAK,KAAK,QAAQ,IAAI,SAAS,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;AAErD,MAAM,CAAC,MAAM,SAAS,GAAG,CAAC,KAAc,EAAoB,EAAE,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,KAAK,CAAC,MAAM,KAAK,EAAE,CAAC;AAEnG,MAAM,CAAC,MAAM,SAAS,GAAG,CAAC,KAAc,EAAoB,EAAE,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,KAAK,CAAC,MAAM,KAAK,EAAE,CAAC;AAEnG;;;;GAIG;AACH,MAAM,UAAU,SAAS,CAAC,KAAa;IACrC,IAAI,KAAK,GAAG,EAAE,IAAI,KAAK,GAAG,WAAW,EAAE,CAAC;QACtC,MAAM,IAAI,UAAU,CAAC,wDAAwD,KAAK,EAAE,CAAC,CAAC;IACxF,CAAC;IACD,OAAO,KAAK,KAAK,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,QAAQ,CAAC,EAAE,EAAE,GAAG,CAAC,EAAE,CAAC;AACrD,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,WAAW,CAAC,KAAa;IACvC,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,EAAE,CAAC;QACtB,MAAM,IAAI,SAAS,CACjB,8EAA8E,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,EAAE,CACtG,CAAC;IACJ,CAAC;IACD,OAAO,MAAM,CAAC,KAAK,CAAC,CAAC;AACvB,CAAC","sourcesContent":["/**\n * Minimal hexadecimal primitives.\n *\n * `@tabai/shared` carries no runtime dependency, so the few byte-level helpers the\n * chain constants and the event topics need are written here against native\n * `bigint`. Nothing in this file allocates a buffer or touches the network.\n */\n\n/** A `0x`-prefixed hexadecimal string of any length. */\nexport type Hex = `0x${string}`;\n\n/** A `0x`-prefixed 32-byte word: exactly 64 hexadecimal digits. */\nexport type Bytes32 = Hex;\n\n/** A `0x`-prefixed 20-byte address: exactly 40 hexadecimal digits. */\nexport type Address = Hex;\n\nconst HEX_SHAPE = /^0x[0-9a-fA-F]*$/;\n\n/** Largest value a `uint64` field can hold: `2^64 - 1`. */\nexport const UINT64_MAX = 18_446_744_073_709_551_615n;\n\n/** One past the largest `uint64` value: `2^64`. */\nexport const UINT64_CEILING = 18_446_744_073_709_551_616n;\n\n/** Largest value a 32-byte word can hold: `2^256 - 1`. */\nexport const UINT256_MAX =\n 115_792_089_237_316_195_423_570_985_008_687_907_853_269_984_665_640_564_039_457_584_007_913_129_639_935n;\n\nexport const isHex = (value: unknown): value is Hex =>\n typeof value === \"string\" && HEX_SHAPE.test(value);\n\nexport const isBytes32 = (value: unknown): value is Bytes32 => isHex(value) && value.length === 66;\n\nexport const isAddress = (value: unknown): value is Address => isHex(value) && value.length === 42;\n\n/**\n * Renders an unsigned integer as a lower-case 32-byte word.\n *\n * @throws RangeError when `value` is negative or exceeds `2^256 - 1`.\n */\nexport function toBytes32(value: bigint): Bytes32 {\n if (value < 0n || value > UINT256_MAX) {\n throw new RangeError(`toBytes32: value must be in [0, 2^256 - 1], received ${value}`);\n }\n return `0x${value.toString(16).padStart(64, \"0\")}`;\n}\n\n/**\n * Reads a 32-byte word back into an unsigned integer.\n *\n * @throws TypeError when `value` is not exactly 64 hexadecimal digits behind `0x`.\n */\nexport function fromBytes32(value: string): bigint {\n if (!isBytes32(value)) {\n throw new TypeError(\n `fromBytes32: expected a 0x-prefixed 32-byte word (66 characters), received ${JSON.stringify(value)}`,\n );\n }\n return BigInt(value);\n}\n"]}
@@ -0,0 +1,14 @@
1
+ /**
2
+ * `@tabai/shared` is the single source of the chain constants and the contract
3
+ * interface constants, so the SDK, the gateway, the registry indexer, and the
4
+ * dashboard cannot drift apart on any of them.
5
+ *
6
+ * The package has no internal dependency and no runtime dependency at all.
7
+ */
8
+ export declare const WORKSPACE_ID: "@tabai/shared";
9
+ export * from "./hex.js";
10
+ export * from "./keccak256.js";
11
+ export * from "./result.js";
12
+ export * from "./chains.js";
13
+ export * from "./abi.js";
14
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,eAAO,MAAM,YAAY,EAAG,eAAwB,CAAC;AAErD,cAAc,UAAU,CAAC;AACzB,cAAc,gBAAgB,CAAC;AAC/B,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,UAAU,CAAC"}
@@ -0,0 +1,14 @@
1
+ /**
2
+ * `@tabai/shared` is the single source of the chain constants and the contract
3
+ * interface constants, so the SDK, the gateway, the registry indexer, and the
4
+ * dashboard cannot drift apart on any of them.
5
+ *
6
+ * The package has no internal dependency and no runtime dependency at all.
7
+ */
8
+ export const WORKSPACE_ID = "@tabai/shared";
9
+ export * from "./hex.js";
10
+ export * from "./keccak256.js";
11
+ export * from "./result.js";
12
+ export * from "./chains.js";
13
+ export * from "./abi.js";
14
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG,eAAwB,CAAC;AAErD,cAAc,UAAU,CAAC;AACzB,cAAc,gBAAgB,CAAC;AAC/B,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,UAAU,CAAC","sourcesContent":["/**\n * `@tabai/shared` is the single source of the chain constants and the contract\n * interface constants, so the SDK, the gateway, the registry indexer, and the\n * dashboard cannot drift apart on any of them.\n *\n * The package has no internal dependency and no runtime dependency at all.\n */\nexport const WORKSPACE_ID = \"@tabai/shared\" as const;\n\nexport * from \"./hex.js\";\nexport * from \"./keccak256.js\";\nexport * from \"./result.js\";\nexport * from \"./chains.js\";\nexport * from \"./abi.js\";\n"]}
@@ -0,0 +1,29 @@
1
+ /**
2
+ * Keccak-256, written against native `bigint`.
3
+ *
4
+ * `@tabai/shared` carries zero runtime dependencies, and Keccak-256 is not
5
+ * SHA3-256, the two differ in their padding byte, so the platform hash
6
+ * primitives cannot stand in for it. The permutation below is therefore
7
+ * implemented here: 24 rounds of Keccak-f[1600] over 25 64-bit lanes, rate 136
8
+ * bytes, capacity 64 bytes, `0x01` domain padding.
9
+ *
10
+ * Correctness is pinned by published digests in `test/keccak256.test.mjs`: the
11
+ * empty-input digest, the `abc` digest, and the ERC-20 `Transfer` and `Approval`
12
+ * event topics any chain explorer shows. The permutation was additionally
13
+ * cross-checked against the platform SHA3-256, same permutation, same rate,
14
+ * different padding byte, at input lengths spanning the 136-byte block
15
+ * boundary. It is used only to derive a handful of event topic hashes at module
16
+ * load, so the `bigint` lane representation costs nothing that matters.
17
+ */
18
+ import type { Bytes32 } from "./hex.js";
19
+ /** Hashes raw bytes and renders the digest as a 32-byte word. */
20
+ export declare function keccak256(data: Uint8Array): Bytes32;
21
+ /**
22
+ * Hashes an ASCII string. Event and function signatures are ASCII by
23
+ * construction, so refusing anything above `0x7f` keeps encoding out of the
24
+ * picture entirely.
25
+ *
26
+ * @throws RangeError when `text` carries a non-ASCII code unit.
27
+ */
28
+ export declare function keccak256Ascii(text: string): Bytes32;
29
+ //# sourceMappingURL=keccak256.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"keccak256.d.ts","sourceRoot":"","sources":["../src/keccak256.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,UAAU,CAAC;AA6FxC,iEAAiE;AACjE,wBAAgB,SAAS,CAAC,IAAI,EAAE,UAAU,GAAG,OAAO,CA6BnD;AAED;;;;;;GAMG;AACH,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAYpD"}