mppx 0.8.1 → 0.8.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 (92) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/dist/Errors.d.ts +13 -0
  3. package/dist/Errors.d.ts.map +1 -1
  4. package/dist/Errors.js +12 -0
  5. package/dist/Errors.js.map +1 -1
  6. package/dist/cli/cli.d.ts +2 -1
  7. package/dist/cli/cli.d.ts.map +1 -1
  8. package/dist/cli/cli.js +35 -4
  9. package/dist/cli/cli.js.map +1 -1
  10. package/dist/cli/plugins/tempo.d.ts +15 -0
  11. package/dist/cli/plugins/tempo.d.ts.map +1 -1
  12. package/dist/cli/plugins/tempo.js +125 -14
  13. package/dist/cli/plugins/tempo.js.map +1 -1
  14. package/dist/cli/utils.d.ts +2 -2
  15. package/dist/cli/utils.d.ts.map +1 -1
  16. package/dist/cli/utils.js +7 -1
  17. package/dist/cli/utils.js.map +1 -1
  18. package/dist/client/Mppx.d.ts +2 -0
  19. package/dist/client/Mppx.d.ts.map +1 -1
  20. package/dist/client/Mppx.js +2 -1
  21. package/dist/client/Mppx.js.map +1 -1
  22. package/dist/client/Transport.d.ts.map +1 -1
  23. package/dist/client/Transport.js +11 -12
  24. package/dist/client/Transport.js.map +1 -1
  25. package/dist/client/internal/Fetch.d.ts +2 -0
  26. package/dist/client/internal/Fetch.d.ts.map +1 -1
  27. package/dist/client/internal/Fetch.js +55 -50
  28. package/dist/client/internal/Fetch.js.map +1 -1
  29. package/dist/client/internal/protocols/Mcp.d.ts +6 -0
  30. package/dist/client/internal/protocols/Mcp.d.ts.map +1 -1
  31. package/dist/client/internal/protocols/Mcp.js +28 -10
  32. package/dist/client/internal/protocols/Mcp.js.map +1 -1
  33. package/dist/client/internal/protocols/X402.d.ts.map +1 -1
  34. package/dist/client/internal/protocols/X402.js +18 -12
  35. package/dist/client/internal/protocols/X402.js.map +1 -1
  36. package/dist/stripe/server/internal/html.gen.d.ts +1 -1
  37. package/dist/stripe/server/internal/html.gen.js +1 -1
  38. package/dist/tempo/client/Charge.d.ts.map +1 -1
  39. package/dist/tempo/client/Charge.js +7 -1
  40. package/dist/tempo/client/Charge.js.map +1 -1
  41. package/dist/tempo/internal/auto-swap.d.ts.map +1 -1
  42. package/dist/tempo/internal/auto-swap.js +15 -5
  43. package/dist/tempo/internal/auto-swap.js.map +1 -1
  44. package/dist/tempo/internal/fee-payer.d.ts.map +1 -1
  45. package/dist/tempo/internal/fee-payer.js +57 -1
  46. package/dist/tempo/internal/fee-payer.js.map +1 -1
  47. package/dist/tempo/internal/fee-token.js +1 -1
  48. package/dist/tempo/internal/fee-token.js.map +1 -1
  49. package/dist/tempo/server/internal/html.gen.d.ts +1 -1
  50. package/dist/tempo/server/internal/html.gen.d.ts.map +1 -1
  51. package/dist/tempo/server/internal/html.gen.js +1 -1
  52. package/dist/tempo/server/internal/html.gen.js.map +1 -1
  53. package/dist/tempo/session/client/SessionManager.d.ts.map +1 -1
  54. package/dist/tempo/session/client/SessionManager.js +47 -5
  55. package/dist/tempo/session/client/SessionManager.js.map +1 -1
  56. package/dist/x402/Header.d.ts +10 -1
  57. package/dist/x402/Header.d.ts.map +1 -1
  58. package/dist/x402/Header.js +27 -1
  59. package/dist/x402/Header.js.map +1 -1
  60. package/package.json +4 -4
  61. package/src/Errors.test.ts +28 -0
  62. package/src/Errors.ts +19 -0
  63. package/src/cli/cli.test.ts +194 -0
  64. package/src/cli/cli.ts +43 -7
  65. package/src/cli/plugins/tempo.ts +161 -17
  66. package/src/cli/utils.ts +14 -2
  67. package/src/client/Mppx.test-d.ts +9 -0
  68. package/src/client/Mppx.test.ts +41 -0
  69. package/src/client/Mppx.ts +4 -0
  70. package/src/client/Transport.test.ts +124 -0
  71. package/src/client/Transport.ts +11 -9
  72. package/src/client/internal/Fetch.test-d.ts +9 -0
  73. package/src/client/internal/Fetch.test.ts +186 -4
  74. package/src/client/internal/Fetch.ts +85 -76
  75. package/src/client/internal/protocols/Mcp.ts +39 -15
  76. package/src/client/internal/protocols/X402.ts +9 -5
  77. package/src/mcp/client/McpClient.integration.test.ts +12 -1
  78. package/src/server/Mppx.test.ts +3 -0
  79. package/src/stripe/server/internal/html.gen.ts +1 -1
  80. package/src/tempo/client/Charge.test.ts +56 -0
  81. package/src/tempo/client/Charge.ts +20 -2
  82. package/src/tempo/internal/auto-swap.test.ts +68 -1
  83. package/src/tempo/internal/auto-swap.ts +38 -5
  84. package/src/tempo/internal/fee-payer.test.ts +106 -0
  85. package/src/tempo/internal/fee-payer.ts +71 -1
  86. package/src/tempo/internal/fee-token.ts +1 -1
  87. package/src/tempo/server/Charge.test.ts +31 -16
  88. package/src/tempo/server/internal/html/package.json +2 -2
  89. package/src/tempo/server/internal/html.gen.ts +1 -1
  90. package/src/tempo/session/client/SessionManager.test.ts +57 -4
  91. package/src/tempo/session/client/SessionManager.ts +50 -6
  92. package/src/x402/Header.ts +45 -0
@@ -13,6 +13,7 @@ import {
13
13
  signTransaction,
14
14
  } from 'viem/actions'
15
15
  import { Abis, Account, Actions, Addresses, Secp256k1, Tick, Transaction } from 'viem/tempo'
16
+ import type { token as viem_token } from 'viem/tempo/actions'
16
17
  import { beforeAll, describe, expect, test } from 'vp/test'
17
18
  import * as Http from '~test/Http.js'
18
19
  import {
@@ -46,6 +47,20 @@ function testAccount() {
46
47
  return privateKeyToAccount(generatePrivateKey())
47
48
  }
48
49
 
50
+ // TODO: Remove once the minimum viem version is >=2.54.0, which uses client-first Tempo call builders.
51
+ function tokenTransferCall(parameters: viem_token.transfer.Args) {
52
+ const call = Actions.token.transfer.call as unknown as {
53
+ length: number
54
+ (parameters: viem_token.transfer.Args): ReturnType<typeof viem_token.transfer.call>
55
+ (
56
+ client: unknown,
57
+ parameters: viem_token.transfer.Args,
58
+ ): ReturnType<typeof viem_token.transfer.call>
59
+ }
60
+ if (call.length >= 2) return call(client, parameters)
61
+ return call(parameters)
62
+ }
63
+
49
64
  type ProofAccessKeyContext = {
50
65
  accessKey: ReturnType<typeof Account.fromSecp256k1>
51
66
  rootAccount: (typeof accounts)[number]
@@ -278,7 +293,7 @@ describe('tempo', () => {
278
293
  const prepared = await prepareTransactionRequest(client, {
279
294
  account: accounts[1]!,
280
295
  calls: [
281
- Actions.token.transfer.call({
296
+ tokenTransferCall({
282
297
  amount: BigInt(challenge.request.amount),
283
298
  to: challenge.request.recipient as Hex.Hex,
284
299
  token: challenge.request.currency as Hex.Hex,
@@ -920,18 +935,18 @@ describe('tempo', () => {
920
935
  const prepared = await prepareTransactionRequest(client, {
921
936
  account: accounts[1]!,
922
937
  calls: [
923
- Actions.token.transfer.call({
938
+ tokenTransferCall({
924
939
  amount: BigInt(splits[1]!.amount),
925
940
  to: splits[1]!.recipient as Hex.Hex,
926
941
  token: challenge.request.currency as Hex.Hex,
927
942
  }),
928
- Actions.token.transfer.call({
943
+ tokenTransferCall({
929
944
  amount: primaryAmount,
930
945
  memo: memo as Hex.Hex,
931
946
  to: challenge.request.recipient as Hex.Hex,
932
947
  token: challenge.request.currency as Hex.Hex,
933
948
  }),
934
- Actions.token.transfer.call({
949
+ tokenTransferCall({
935
950
  amount: BigInt(splits[0]!.amount),
936
951
  to: splits[0]!.recipient as Hex.Hex,
937
952
  token: challenge.request.currency as Hex.Hex,
@@ -2299,7 +2314,7 @@ describe('tempo', () => {
2299
2314
  const memo = Attribution.encode({ challengeId: challenge.id, serverId: challenge.realm })
2300
2315
 
2301
2316
  // Build a transaction with the valid transfer + a rogue extra call
2302
- const transferCall = Actions.token.transfer.call({
2317
+ const transferCall = tokenTransferCall({
2303
2318
  amount: BigInt(request.amount),
2304
2319
  memo,
2305
2320
  to: request.recipient as Hex.Hex,
@@ -2556,18 +2571,18 @@ describe('tempo', () => {
2556
2571
  const prepared = await prepareTransactionRequest(client, {
2557
2572
  account: accounts[1]!,
2558
2573
  calls: [
2559
- Actions.token.transfer.call({
2574
+ tokenTransferCall({
2560
2575
  amount: BigInt(splits[0]!.amount),
2561
2576
  to: splits[0]!.recipient as Hex.Hex,
2562
2577
  token: challenge.request.currency as Hex.Hex,
2563
2578
  }),
2564
- Actions.token.transfer.call({
2579
+ tokenTransferCall({
2565
2580
  amount: primaryAmount,
2566
2581
  memo: memo as Hex.Hex,
2567
2582
  to: challenge.request.recipient as Hex.Hex,
2568
2583
  token: challenge.request.currency as Hex.Hex,
2569
2584
  }),
2570
- Actions.token.transfer.call({
2585
+ tokenTransferCall({
2571
2586
  amount: BigInt(splits[1]!.amount),
2572
2587
  to: splits[1]!.recipient as Hex.Hex,
2573
2588
  token: challenge.request.currency as Hex.Hex,
@@ -4776,18 +4791,18 @@ describe('tempo', () => {
4776
4791
  const prepared = await prepareTransactionRequest(client, {
4777
4792
  account: accounts[1]!,
4778
4793
  calls: [
4779
- Actions.token.transfer.call({
4794
+ tokenTransferCall({
4780
4795
  amount: BigInt(splits[0]!.amount),
4781
4796
  to: splits[0]!.recipient as Hex.Hex,
4782
4797
  token: challenge.request.currency as Hex.Hex,
4783
4798
  }),
4784
- Actions.token.transfer.call({
4799
+ tokenTransferCall({
4785
4800
  amount: primaryAmount,
4786
4801
  memo: memo as Hex.Hex,
4787
4802
  to: challenge.request.recipient as Hex.Hex,
4788
4803
  token: challenge.request.currency as Hex.Hex,
4789
4804
  }),
4790
- Actions.token.transfer.call({
4805
+ tokenTransferCall({
4791
4806
  amount: BigInt(splits[1]!.amount),
4792
4807
  to: splits[1]!.recipient as Hex.Hex,
4793
4808
  token: challenge.request.currency as Hex.Hex,
@@ -4846,18 +4861,18 @@ describe('tempo', () => {
4846
4861
  const prepared = await prepareTransactionRequest(client, {
4847
4862
  account: accounts[1]!,
4848
4863
  calls: [
4849
- Actions.token.transfer.call({
4864
+ tokenTransferCall({
4850
4865
  amount: BigInt(splits[0]!.amount),
4851
4866
  to: splits[0]!.recipient as Hex.Hex,
4852
4867
  token: challenge.request.currency as Hex.Hex,
4853
4868
  }),
4854
- Actions.token.transfer.call({
4869
+ tokenTransferCall({
4855
4870
  amount: primaryAmount,
4856
4871
  memo: memo as Hex.Hex,
4857
4872
  to: challenge.request.recipient as Hex.Hex,
4858
4873
  token: challenge.request.currency as Hex.Hex,
4859
4874
  }),
4860
- Actions.token.transfer.call({
4875
+ tokenTransferCall({
4861
4876
  amount: BigInt(splits[1]!.amount),
4862
4877
  to: splits[1]!.recipient as Hex.Hex,
4863
4878
  token: challenge.request.currency as Hex.Hex,
@@ -5304,14 +5319,14 @@ describe('tempo', () => {
5304
5319
  const prepared = await prepareTransactionRequest(client, {
5305
5320
  account: accounts[1]!,
5306
5321
  calls: [
5307
- Actions.token.transfer.call({
5322
+ tokenTransferCall({
5308
5323
  amount: BigInt(challengeA.request.amount),
5309
5324
  memo: memoA as Hex.Hex,
5310
5325
  to: challengeA.request.recipient as Hex.Hex,
5311
5326
  token: challengeA.request.currency as Hex.Hex,
5312
5327
  }),
5313
5328
  // Dust transfer with challengeB's nonce — the exploit vector
5314
- Actions.token.transfer.call({
5329
+ tokenTransferCall({
5315
5330
  amount: 1n,
5316
5331
  memo: memoB as Hex.Hex,
5317
5332
  to: accounts[2].address,
@@ -3,8 +3,8 @@
3
3
  "private": true,
4
4
  "type": "module",
5
5
  "dependencies": {
6
- "accounts": "0.14.9",
6
+ "accounts": "0.14.11",
7
7
  "mppx": "workspace:*",
8
- "viem": "2.52.2"
8
+ "viem": "2.54.1"
9
9
  }
10
10
  }