@lemmaoracle/x402 0.1.1 → 0.1.3

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 (146) hide show
  1. package/dist/advanced/index.d.ts +14 -0
  2. package/dist/advanced/index.d.ts.map +1 -0
  3. package/dist/advanced/index.js +14 -0
  4. package/dist/advanced/index.js.map +1 -0
  5. package/dist/index.d.ts +25 -42
  6. package/dist/index.d.ts.map +1 -1
  7. package/dist/index.js +25 -77
  8. package/dist/index.js.map +1 -1
  9. package/dist/lemma-config.d.ts +41 -0
  10. package/dist/lemma-config.d.ts.map +1 -0
  11. package/dist/lemma-config.js +12 -0
  12. package/dist/lemma-config.js.map +1 -0
  13. package/dist/lemma-discovery.d.ts +37 -0
  14. package/dist/lemma-discovery.d.ts.map +1 -0
  15. package/dist/lemma-discovery.js +104 -0
  16. package/dist/lemma-discovery.js.map +1 -0
  17. package/dist/lemma-server.d.ts +30 -0
  18. package/dist/lemma-server.d.ts.map +1 -0
  19. package/dist/lemma-server.js +169 -0
  20. package/dist/lemma-server.js.map +1 -0
  21. package/dist/lemma-submission.d.ts +44 -0
  22. package/dist/lemma-submission.d.ts.map +1 -0
  23. package/dist/lemma-submission.js +81 -0
  24. package/dist/lemma-submission.js.map +1 -0
  25. package/package.json +14 -14
  26. package/broadcast/DeployPaymentVerifier.s.sol/10143/run-1775996174982.json +0 -34
  27. package/broadcast/DeployPaymentVerifier.s.sol/10143/run-1775996423983.json +0 -51
  28. package/broadcast/DeployPaymentVerifier.s.sol/10143/run-1775996907850.json +0 -51
  29. package/broadcast/DeployPaymentVerifier.s.sol/10143/run-latest.json +0 -51
  30. package/cache/DeployPaymentVerifier.s.sol/10143/run-1775996174982.json +0 -7
  31. package/cache/DeployPaymentVerifier.s.sol/10143/run-1775996423983.json +0 -7
  32. package/cache/DeployPaymentVerifier.s.sol/10143/run-1775996907850.json +0 -7
  33. package/cache/DeployPaymentVerifier.s.sol/10143/run-latest.json +0 -7
  34. package/cache/solidity-files-cache.json +0 -1
  35. package/circuits/README.md +0 -78
  36. package/circuits/payment-comprehensive.test.mjs +0 -272
  37. package/circuits/payment.circom +0 -89
  38. package/circuits/payment.test.mjs +0 -173
  39. package/dist/proof-generator.d.ts +0 -26
  40. package/dist/proof-generator.d.ts.map +0 -1
  41. package/dist/proof-generator.js +0 -154
  42. package/dist/proof-generator.js.map +0 -1
  43. package/dist/proof-generator.test.d.ts +0 -7
  44. package/dist/proof-generator.test.d.ts.map +0 -1
  45. package/dist/proof-generator.test.js +0 -121
  46. package/dist/proof-generator.test.js.map +0 -1
  47. package/dist/transaction-watcher.d.ts +0 -42
  48. package/dist/transaction-watcher.d.ts.map +0 -1
  49. package/dist/transaction-watcher.js +0 -88
  50. package/dist/transaction-watcher.js.map +0 -1
  51. package/dist/transaction-watcher.test.d.ts +0 -7
  52. package/dist/transaction-watcher.test.d.ts.map +0 -1
  53. package/dist/transaction-watcher.test.js +0 -111
  54. package/dist/transaction-watcher.test.js.map +0 -1
  55. package/dist/types.d.ts +0 -76
  56. package/dist/types.d.ts.map +0 -1
  57. package/dist/types.js +0 -2
  58. package/dist/types.js.map +0 -1
  59. package/foundry.lock +0 -11
  60. package/foundry.toml +0 -16
  61. package/lib/forge-std/.gitattributes +0 -1
  62. package/lib/forge-std/.github/CODEOWNERS +0 -1
  63. package/lib/forge-std/.github/dependabot.yml +0 -6
  64. package/lib/forge-std/.github/workflows/ci.yml +0 -161
  65. package/lib/forge-std/.github/workflows/sync.yml +0 -36
  66. package/lib/forge-std/CONTRIBUTING.md +0 -193
  67. package/lib/forge-std/LICENSE-APACHE +0 -203
  68. package/lib/forge-std/LICENSE-MIT +0 -25
  69. package/lib/forge-std/README.md +0 -314
  70. package/lib/forge-std/RELEASE_CHECKLIST.md +0 -12
  71. package/lib/forge-std/foundry.toml +0 -18
  72. package/lib/forge-std/package.json +0 -16
  73. package/lib/forge-std/scripts/vm.py +0 -636
  74. package/lib/forge-std/src/Base.sol +0 -48
  75. package/lib/forge-std/src/Config.sol +0 -60
  76. package/lib/forge-std/src/LibVariable.sol +0 -477
  77. package/lib/forge-std/src/Script.sol +0 -28
  78. package/lib/forge-std/src/StdAssertions.sol +0 -1300
  79. package/lib/forge-std/src/StdChains.sol +0 -303
  80. package/lib/forge-std/src/StdCheats.sol +0 -825
  81. package/lib/forge-std/src/StdConfig.sol +0 -632
  82. package/lib/forge-std/src/StdConstants.sol +0 -30
  83. package/lib/forge-std/src/StdError.sol +0 -15
  84. package/lib/forge-std/src/StdInvariant.sol +0 -161
  85. package/lib/forge-std/src/StdJson.sol +0 -275
  86. package/lib/forge-std/src/StdMath.sol +0 -47
  87. package/lib/forge-std/src/StdStorage.sol +0 -476
  88. package/lib/forge-std/src/StdStyle.sol +0 -333
  89. package/lib/forge-std/src/StdToml.sol +0 -275
  90. package/lib/forge-std/src/StdUtils.sol +0 -200
  91. package/lib/forge-std/src/Test.sol +0 -32
  92. package/lib/forge-std/src/Vm.sol +0 -2533
  93. package/lib/forge-std/src/console.sol +0 -1551
  94. package/lib/forge-std/src/console2.sol +0 -4
  95. package/lib/forge-std/src/interfaces/IERC1155.sol +0 -105
  96. package/lib/forge-std/src/interfaces/IERC165.sol +0 -12
  97. package/lib/forge-std/src/interfaces/IERC20.sol +0 -43
  98. package/lib/forge-std/src/interfaces/IERC4626.sol +0 -190
  99. package/lib/forge-std/src/interfaces/IERC6909.sol +0 -72
  100. package/lib/forge-std/src/interfaces/IERC721.sol +0 -164
  101. package/lib/forge-std/src/interfaces/IERC7540.sol +0 -145
  102. package/lib/forge-std/src/interfaces/IERC7575.sol +0 -241
  103. package/lib/forge-std/src/interfaces/IMulticall3.sol +0 -68
  104. package/lib/forge-std/src/safeconsole.sol +0 -13248
  105. package/lib/forge-std/test/CommonBase.t.sol +0 -44
  106. package/lib/forge-std/test/Config.t.sol +0 -381
  107. package/lib/forge-std/test/LibVariable.t.sol +0 -452
  108. package/lib/forge-std/test/StdAssertions.t.sol +0 -141
  109. package/lib/forge-std/test/StdChains.t.sol +0 -227
  110. package/lib/forge-std/test/StdCheats.t.sol +0 -638
  111. package/lib/forge-std/test/StdConstants.t.sol +0 -38
  112. package/lib/forge-std/test/StdError.t.sol +0 -119
  113. package/lib/forge-std/test/StdJson.t.sol +0 -49
  114. package/lib/forge-std/test/StdMath.t.sol +0 -202
  115. package/lib/forge-std/test/StdStorage.t.sol +0 -532
  116. package/lib/forge-std/test/StdStyle.t.sol +0 -110
  117. package/lib/forge-std/test/StdToml.t.sol +0 -49
  118. package/lib/forge-std/test/StdUtils.t.sol +0 -342
  119. package/lib/forge-std/test/Vm.t.sol +0 -18
  120. package/lib/forge-std/test/compilation/CompilationScript.sol +0 -8
  121. package/lib/forge-std/test/compilation/CompilationScriptBase.sol +0 -8
  122. package/lib/forge-std/test/compilation/CompilationTest.sol +0 -8
  123. package/lib/forge-std/test/compilation/CompilationTestBase.sol +0 -8
  124. package/lib/forge-std/test/fixtures/broadcast.log.json +0 -187
  125. package/lib/forge-std/test/fixtures/config.toml +0 -81
  126. package/lib/forge-std/test/fixtures/test.json +0 -8
  127. package/lib/forge-std/test/fixtures/test.toml +0 -6
  128. package/package.json.backup +0 -55
  129. package/scripts/DeployPaymentVerifier.s.sol +0 -18
  130. package/scripts/build.sh +0 -61
  131. package/scripts/deploy.sh +0 -65
  132. package/scripts/fix-verifier.mjs +0 -64
  133. package/scripts/register-circuit.ts +0 -213
  134. package/scripts/test-with-circuit.mjs +0 -88
  135. package/src/index.ts +0 -115
  136. package/src/proof-generator.test.ts +0 -139
  137. package/src/proof-generator.ts +0 -220
  138. package/src/transaction-watcher.test.ts +0 -153
  139. package/src/transaction-watcher.ts +0 -154
  140. package/src/types.ts +0 -110
  141. package/tsconfig.json +0 -14
  142. package/tsconfig.tsbuildinfo +0 -1
  143. package/vitest.config.ts +0 -18
  144. package/workers/x402-facilitator/src/index.ts +0 -582
  145. package/workers/x402-facilitator/src/x402-env.d.ts +0 -25
  146. package/workers/x402-facilitator/wrangler.toml +0 -19
@@ -1,227 +0,0 @@
1
- // SPDX-License-Identifier: MIT OR Apache-2.0
2
- pragma solidity >=0.8.13 <0.9.0;
3
-
4
- import {Test} from "../src/Test.sol";
5
-
6
- contract StdChainsMock is Test {
7
- function exposedGetChain(string memory chainAlias) public returns (Chain memory) {
8
- return getChain(chainAlias);
9
- }
10
-
11
- function exposedGetChain(uint256 chainId) public returns (Chain memory) {
12
- return getChain(chainId);
13
- }
14
-
15
- function exposedSetChain(string memory chainAlias, ChainData memory chainData) public {
16
- setChain(chainAlias, chainData);
17
- }
18
-
19
- function exposedSetFallbackToDefaultRpcUrls(bool useDefault) public {
20
- setFallbackToDefaultRpcUrls(useDefault);
21
- }
22
- }
23
-
24
- contract StdChainsTest is Test {
25
- function test_ChainRpcInitialization() public {
26
- // RPCs specified in `foundry.toml` should be updated.
27
- assertEq(getChain(1).rpcUrl, "https://ethereum.reth.rs/rpc");
28
- assertEq(getChain("optimism_sepolia").rpcUrl, "https://sepolia.optimism.io/");
29
- assertEq(getChain("arbitrum_one_sepolia").rpcUrl, "https://sepolia-rollup.arbitrum.io/rpc/");
30
-
31
- // Environment variables should be the next fallback
32
- assertEq(getChain("arbitrum_nova").rpcUrl, "https://nova.arbitrum.io/rpc");
33
- vm.setEnv("ARBITRUM_NOVA_RPC_URL", "myoverride");
34
- assertEq(getChain("arbitrum_nova").rpcUrl, "myoverride");
35
- vm.setEnv("ARBITRUM_NOVA_RPC_URL", "https://nova.arbitrum.io/rpc");
36
-
37
- // Cannot override RPCs defined in `foundry.toml`
38
- vm.setEnv("MAINNET_RPC_URL", "myoverride2");
39
- assertEq(getChain("mainnet").rpcUrl, "https://ethereum.reth.rs/rpc");
40
-
41
- // Other RPCs should remain unchanged.
42
- assertEq(getChain(31337).rpcUrl, "http://127.0.0.1:8545");
43
- assertEq(getChain("sepolia").rpcUrl, "https://sepolia.infura.io/v3/b9794ad1ddf84dfb8c34d6bb5dca2001");
44
- }
45
-
46
- // Named with a leading underscore to clarify this is not intended to be run as a normal test,
47
- // and is intended to be used in the below `test_Rpcs` test.
48
- function _testRpc(string memory rpcAlias) internal {
49
- string memory rpcUrl = getChain(rpcAlias).rpcUrl;
50
- vm.createSelectFork(rpcUrl);
51
- }
52
-
53
- // Ensure we can connect to the default RPC URL for each chain.
54
- // Currently commented out since this is slow and public RPCs are flaky, often resulting in failing CI.
55
- // function test_Rpcs() public {
56
- // _testRpc("mainnet");
57
- // _testRpc("sepolia");
58
- // _testRpc("holesky");
59
- // _testRpc("optimism");
60
- // _testRpc("optimism_sepolia");
61
- // _testRpc("arbitrum_one");
62
- // _testRpc("arbitrum_one_sepolia");
63
- // _testRpc("arbitrum_nova");
64
- // _testRpc("polygon");
65
- // _testRpc("polygon_amoy");
66
- // _testRpc("avalanche");
67
- // _testRpc("avalanche_fuji");
68
- // _testRpc("bnb_smart_chain");
69
- // _testRpc("bnb_smart_chain_testnet");
70
- // _testRpc("gnosis_chain");
71
- // _testRpc("moonbeam");
72
- // _testRpc("moonriver");
73
- // _testRpc("moonbase");
74
- // _testRpc("base_sepolia");
75
- // _testRpc("base");
76
- // _testRpc("blast_sepolia");
77
- // _testRpc("blast");
78
- // _testRpc("fantom_opera");
79
- // _testRpc("fantom_opera_testnet");
80
- // _testRpc("fraxtal");
81
- // _testRpc("fraxtal_testnet");
82
- // _testRpc("berachain_bartio_testnet");
83
- // _testRpc("flare");
84
- // _testRpc("flare_coston2");
85
- // }
86
-
87
- function test_RevertIf_ChainNotFound() public {
88
- // We deploy a mock to properly test the revert.
89
- StdChainsMock stdChainsMock = new StdChainsMock();
90
-
91
- vm.expectRevert("StdChains getChain(string): Chain with alias \"does_not_exist\" not found.");
92
- stdChainsMock.exposedGetChain("does_not_exist");
93
- }
94
-
95
- function test_RevertIf_SetChain_ChainIdExist_FirstTest() public {
96
- // We deploy a mock to properly test the revert.
97
- StdChainsMock stdChainsMock = new StdChainsMock();
98
-
99
- vm.expectRevert("StdChains setChain(string,ChainData): Chain ID 31337 already used by \"anvil\".");
100
- stdChainsMock.exposedSetChain("anvil2", ChainData("Anvil", 31337, "URL"));
101
- }
102
-
103
- function test_RevertIf_ChainBubbleUp() public {
104
- // We deploy a mock to properly test the revert.
105
- StdChainsMock stdChainsMock = new StdChainsMock();
106
-
107
- stdChainsMock.exposedSetChain("needs_undefined_env_var", ChainData("", 123456789, ""));
108
- // Forge environment variable error.
109
- vm.expectRevert();
110
- stdChainsMock.exposedGetChain("needs_undefined_env_var");
111
- }
112
-
113
- function test_RevertIf_SetChain_ChainIdExists_SecondTest() public {
114
- // We deploy a mock to properly test the revert.
115
- StdChainsMock stdChainsMock = new StdChainsMock();
116
-
117
- stdChainsMock.exposedSetChain("custom_chain", ChainData("Custom Chain", 123456789, "https://custom.chain/"));
118
-
119
- vm.expectRevert('StdChains setChain(string,ChainData): Chain ID 123456789 already used by "custom_chain".');
120
-
121
- stdChainsMock.exposedSetChain("another_custom_chain", ChainData("", 123456789, ""));
122
- }
123
-
124
- function test_SetChain() public {
125
- setChain("custom_chain", ChainData("Custom Chain", 123456789, "https://custom.chain/"));
126
- Chain memory customChain = getChain("custom_chain");
127
- assertEq(customChain.name, "Custom Chain");
128
- assertEq(customChain.chainId, 123456789);
129
- assertEq(customChain.chainAlias, "custom_chain");
130
- assertEq(customChain.rpcUrl, "https://custom.chain/");
131
- Chain memory chainById = getChain(123456789);
132
- assertEq(chainById.name, customChain.name);
133
- assertEq(chainById.chainId, customChain.chainId);
134
- assertEq(chainById.chainAlias, customChain.chainAlias);
135
- assertEq(chainById.rpcUrl, customChain.rpcUrl);
136
- customChain.name = "Another Custom Chain";
137
- customChain.chainId = 987654321;
138
- setChain("another_custom_chain", customChain);
139
- Chain memory anotherCustomChain = getChain("another_custom_chain");
140
- assertEq(anotherCustomChain.name, "Another Custom Chain");
141
- assertEq(anotherCustomChain.chainId, 987654321);
142
- assertEq(anotherCustomChain.chainAlias, "another_custom_chain");
143
- assertEq(anotherCustomChain.rpcUrl, "https://custom.chain/");
144
- // Verify the first chain data was not overwritten
145
- chainById = getChain(123456789);
146
- assertEq(chainById.name, "Custom Chain");
147
- assertEq(chainById.chainId, 123456789);
148
- }
149
-
150
- function test_RevertIf_SetEmptyAlias() public {
151
- // We deploy a mock to properly test the revert.
152
- StdChainsMock stdChainsMock = new StdChainsMock();
153
-
154
- vm.expectRevert("StdChains setChain(string,ChainData): Chain alias cannot be the empty string.");
155
- stdChainsMock.exposedSetChain("", ChainData("", 123456789, ""));
156
- }
157
-
158
- function test_RevertIf_SetNoChainId0() public {
159
- // We deploy a mock to properly test the revert.
160
- StdChainsMock stdChainsMock = new StdChainsMock();
161
-
162
- vm.expectRevert("StdChains setChain(string,ChainData): Chain ID cannot be 0.");
163
- stdChainsMock.exposedSetChain("alias", ChainData("", 0, ""));
164
- }
165
-
166
- function test_RevertIf_GetNoChainId0() public {
167
- // We deploy a mock to properly test the revert.
168
- StdChainsMock stdChainsMock = new StdChainsMock();
169
-
170
- vm.expectRevert("StdChains getChain(uint256): Chain ID cannot be 0.");
171
- stdChainsMock.exposedGetChain(0);
172
- }
173
-
174
- function test_RevertIf_GetNoEmptyAlias() public {
175
- // We deploy a mock to properly test the revert.
176
- StdChainsMock stdChainsMock = new StdChainsMock();
177
-
178
- vm.expectRevert("StdChains getChain(string): Chain alias cannot be the empty string.");
179
- stdChainsMock.exposedGetChain("");
180
- }
181
-
182
- function test_RevertIf_ChainNotInitialized() public {
183
- // We deploy a mock to properly test the revert.
184
- StdChainsMock stdChainsMock = new StdChainsMock();
185
-
186
- vm.expectRevert("StdChains getChain(string): Chain with alias \"no_such_alias\" not found.");
187
- stdChainsMock.exposedGetChain("no_such_alias");
188
- }
189
-
190
- function test_RevertIf_ChainAliasNotFound() public {
191
- // We deploy a mock to properly test the revert.
192
- StdChainsMock stdChainsMock = new StdChainsMock();
193
-
194
- vm.expectRevert("StdChains getChain(uint256): Chain with ID 321 not found.");
195
-
196
- stdChainsMock.exposedGetChain(321);
197
- }
198
-
199
- function test_SetChain_ExistingOne() public {
200
- // We deploy a mock to properly test the revert.
201
- StdChainsMock stdChainsMock = new StdChainsMock();
202
-
203
- setChain("custom_chain", ChainData("Custom Chain", 123456789, "https://custom.chain/"));
204
- assertEq(getChain(123456789).chainId, 123456789);
205
-
206
- setChain("custom_chain", ChainData("Modified Chain", 9999999999999999999, "https://modified.chain/"));
207
- vm.expectRevert("StdChains getChain(uint256): Chain with ID 123456789 not found.");
208
- stdChainsMock.exposedGetChain(123456789);
209
-
210
- Chain memory modifiedChain = getChain(9999999999999999999);
211
- assertEq(modifiedChain.name, "Modified Chain");
212
- assertEq(modifiedChain.chainId, 9999999999999999999);
213
- assertEq(modifiedChain.rpcUrl, "https://modified.chain/");
214
- }
215
-
216
- function test_RevertIf_DontUseDefaultRpcUrl() public {
217
- // We deploy a mock to properly test the revert.
218
- StdChainsMock stdChainsMock = new StdChainsMock();
219
-
220
- // Should error if default RPCs flag is set to false.
221
- stdChainsMock.exposedSetFallbackToDefaultRpcUrls(false);
222
- vm.expectRevert();
223
- stdChainsMock.exposedGetChain(31337);
224
- vm.expectRevert();
225
- stdChainsMock.exposedGetChain("sepolia");
226
- }
227
- }