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.
- package/CHANGELOG.md +16 -0
- package/dist/Errors.d.ts +13 -0
- package/dist/Errors.d.ts.map +1 -1
- package/dist/Errors.js +12 -0
- package/dist/Errors.js.map +1 -1
- package/dist/cli/cli.d.ts +2 -1
- package/dist/cli/cli.d.ts.map +1 -1
- package/dist/cli/cli.js +35 -4
- package/dist/cli/cli.js.map +1 -1
- package/dist/cli/plugins/tempo.d.ts +15 -0
- package/dist/cli/plugins/tempo.d.ts.map +1 -1
- package/dist/cli/plugins/tempo.js +125 -14
- package/dist/cli/plugins/tempo.js.map +1 -1
- package/dist/cli/utils.d.ts +2 -2
- package/dist/cli/utils.d.ts.map +1 -1
- package/dist/cli/utils.js +7 -1
- package/dist/cli/utils.js.map +1 -1
- package/dist/client/Mppx.d.ts +2 -0
- package/dist/client/Mppx.d.ts.map +1 -1
- package/dist/client/Mppx.js +2 -1
- package/dist/client/Mppx.js.map +1 -1
- package/dist/client/Transport.d.ts.map +1 -1
- package/dist/client/Transport.js +11 -12
- package/dist/client/Transport.js.map +1 -1
- package/dist/client/internal/Fetch.d.ts +2 -0
- package/dist/client/internal/Fetch.d.ts.map +1 -1
- package/dist/client/internal/Fetch.js +55 -50
- package/dist/client/internal/Fetch.js.map +1 -1
- package/dist/client/internal/protocols/Mcp.d.ts +6 -0
- package/dist/client/internal/protocols/Mcp.d.ts.map +1 -1
- package/dist/client/internal/protocols/Mcp.js +28 -10
- package/dist/client/internal/protocols/Mcp.js.map +1 -1
- package/dist/client/internal/protocols/X402.d.ts.map +1 -1
- package/dist/client/internal/protocols/X402.js +18 -12
- package/dist/client/internal/protocols/X402.js.map +1 -1
- package/dist/stripe/server/internal/html.gen.d.ts +1 -1
- package/dist/stripe/server/internal/html.gen.js +1 -1
- package/dist/tempo/client/Charge.d.ts.map +1 -1
- package/dist/tempo/client/Charge.js +7 -1
- package/dist/tempo/client/Charge.js.map +1 -1
- package/dist/tempo/internal/auto-swap.d.ts.map +1 -1
- package/dist/tempo/internal/auto-swap.js +15 -5
- package/dist/tempo/internal/auto-swap.js.map +1 -1
- package/dist/tempo/internal/fee-payer.d.ts.map +1 -1
- package/dist/tempo/internal/fee-payer.js +57 -1
- package/dist/tempo/internal/fee-payer.js.map +1 -1
- package/dist/tempo/internal/fee-token.js +1 -1
- package/dist/tempo/internal/fee-token.js.map +1 -1
- package/dist/tempo/server/internal/html.gen.d.ts +1 -1
- package/dist/tempo/server/internal/html.gen.d.ts.map +1 -1
- package/dist/tempo/server/internal/html.gen.js +1 -1
- package/dist/tempo/server/internal/html.gen.js.map +1 -1
- package/dist/tempo/session/client/SessionManager.d.ts.map +1 -1
- package/dist/tempo/session/client/SessionManager.js +47 -5
- package/dist/tempo/session/client/SessionManager.js.map +1 -1
- package/dist/x402/Header.d.ts +10 -1
- package/dist/x402/Header.d.ts.map +1 -1
- package/dist/x402/Header.js +27 -1
- package/dist/x402/Header.js.map +1 -1
- package/package.json +4 -4
- package/src/Errors.test.ts +28 -0
- package/src/Errors.ts +19 -0
- package/src/cli/cli.test.ts +194 -0
- package/src/cli/cli.ts +43 -7
- package/src/cli/plugins/tempo.ts +161 -17
- package/src/cli/utils.ts +14 -2
- package/src/client/Mppx.test-d.ts +9 -0
- package/src/client/Mppx.test.ts +41 -0
- package/src/client/Mppx.ts +4 -0
- package/src/client/Transport.test.ts +124 -0
- package/src/client/Transport.ts +11 -9
- package/src/client/internal/Fetch.test-d.ts +9 -0
- package/src/client/internal/Fetch.test.ts +186 -4
- package/src/client/internal/Fetch.ts +85 -76
- package/src/client/internal/protocols/Mcp.ts +39 -15
- package/src/client/internal/protocols/X402.ts +9 -5
- package/src/mcp/client/McpClient.integration.test.ts +12 -1
- package/src/server/Mppx.test.ts +3 -0
- package/src/stripe/server/internal/html.gen.ts +1 -1
- package/src/tempo/client/Charge.test.ts +56 -0
- package/src/tempo/client/Charge.ts +20 -2
- package/src/tempo/internal/auto-swap.test.ts +68 -1
- package/src/tempo/internal/auto-swap.ts +38 -5
- package/src/tempo/internal/fee-payer.test.ts +106 -0
- package/src/tempo/internal/fee-payer.ts +71 -1
- package/src/tempo/internal/fee-token.ts +1 -1
- package/src/tempo/server/Charge.test.ts +31 -16
- package/src/tempo/server/internal/html/package.json +2 -2
- package/src/tempo/server/internal/html.gen.ts +1 -1
- package/src/tempo/session/client/SessionManager.test.ts +57 -4
- package/src/tempo/session/client/SessionManager.ts +50 -6
- 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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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 =
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
5329
|
+
tokenTransferCall({
|
|
5315
5330
|
amount: 1n,
|
|
5316
5331
|
memo: memoB as Hex.Hex,
|
|
5317
5332
|
to: accounts[2].address,
|