mppx 0.8.5 → 0.8.6

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 (38) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/dist/Receipt.d.ts +20 -2
  3. package/dist/Receipt.d.ts.map +1 -1
  4. package/dist/Receipt.js +19 -12
  5. package/dist/Receipt.js.map +1 -1
  6. package/dist/cli/cli.d.ts.map +1 -1
  7. package/dist/cli/cli.js +6 -4
  8. package/dist/cli/cli.js.map +1 -1
  9. package/dist/cli/plugins/tempo.d.ts.map +1 -1
  10. package/dist/cli/plugins/tempo.js +4 -2
  11. package/dist/cli/plugins/tempo.js.map +1 -1
  12. package/dist/client/internal/Fetch.d.ts.map +1 -1
  13. package/dist/client/internal/Fetch.js +6 -1
  14. package/dist/client/internal/Fetch.js.map +1 -1
  15. package/dist/tempo/client/Charge.d.ts.map +1 -1
  16. package/dist/tempo/client/Charge.js +6 -2
  17. package/dist/tempo/client/Charge.js.map +1 -1
  18. package/dist/tempo/server/internal/html.gen.d.ts +1 -1
  19. package/dist/tempo/server/internal/html.gen.d.ts.map +1 -1
  20. package/dist/tempo/server/internal/html.gen.js +1 -1
  21. package/dist/tempo/server/internal/html.gen.js.map +1 -1
  22. package/dist/tempo/session/precompile/Chain.d.ts +26 -2
  23. package/dist/tempo/session/precompile/Chain.d.ts.map +1 -1
  24. package/dist/tempo/session/precompile/Chain.js +38 -5
  25. package/dist/tempo/session/precompile/Chain.js.map +1 -1
  26. package/package.json +1 -1
  27. package/src/Receipt.test.ts +53 -0
  28. package/src/Receipt.ts +26 -13
  29. package/src/cli/cli.test.ts +41 -5
  30. package/src/cli/cli.ts +7 -4
  31. package/src/cli/plugins/tempo.ts +6 -2
  32. package/src/client/internal/Fetch.test.ts +44 -0
  33. package/src/client/internal/Fetch.ts +5 -1
  34. package/src/tempo/client/Charge.test.ts +61 -0
  35. package/src/tempo/client/Charge.ts +6 -1
  36. package/src/tempo/server/internal/html.gen.ts +1 -1
  37. package/src/tempo/session/precompile/Chain.test.ts +121 -2
  38. package/src/tempo/session/precompile/Chain.ts +56 -6
@@ -353,6 +353,67 @@ describe('tempo.charge client', () => {
353
353
  }
354
354
  })
355
355
 
356
+ test('normalizes sponsored pull transactions before signing', async () => {
357
+ vi.resetModules()
358
+ const prepared = {
359
+ feePayerSignature: { r: '0x1', s: '0x2', yParity: 0 },
360
+ feeToken: currency,
361
+ gas: 100n,
362
+ }
363
+ const prepareTransactionRequest = vi.fn(async () => prepared)
364
+ const signTransaction = vi.fn(
365
+ async (_client: unknown, _transaction: Record<string, unknown>) => '0xdeadbeef',
366
+ )
367
+ vi.doMock('viem/actions', () => ({
368
+ prepareTransactionRequest,
369
+ sendCallsSync: vi.fn(),
370
+ signTransaction,
371
+ signTypedData: vi.fn(),
372
+ }))
373
+
374
+ try {
375
+ const { charge: chargeWithMockedActions } = await import('./Charge.js')
376
+ const chainId = 42431
377
+ const client = createClient({
378
+ account,
379
+ chain: tempoLocalnet,
380
+ transport: http('http://127.0.0.1'),
381
+ })
382
+ const method = chargeWithMockedActions({
383
+ account,
384
+ getClient: () => client,
385
+ })
386
+
387
+ await method.createCredential({
388
+ challenge: createChallenge({
389
+ amount: '1',
390
+ chainId,
391
+ feePayer: true,
392
+ supportedModes: ['pull'],
393
+ }),
394
+ context: {},
395
+ })
396
+
397
+ expect(prepareTransactionRequest).toHaveBeenCalledWith(
398
+ client,
399
+ expect.not.objectContaining({ feePayer: true }),
400
+ )
401
+ expect(signTransaction).toHaveBeenCalledWith(
402
+ client,
403
+ expect.objectContaining({
404
+ feePayer: true,
405
+ gas: 5_100n,
406
+ }),
407
+ )
408
+ const signed = signTransaction.mock.calls[0]?.[1] as Record<string, unknown>
409
+ expect(signed).not.toHaveProperty('feePayerSignature')
410
+ expect(signed).not.toHaveProperty('feeToken')
411
+ } finally {
412
+ vi.doUnmock('viem/actions')
413
+ vi.resetModules()
414
+ }
415
+ })
416
+
356
417
  describe('chain pinning', () => {
357
418
  const client = createClient({
358
419
  account,
@@ -226,7 +226,12 @@ export function charge(parameters: charge.Parameters = {}) {
226
226
  // Estimate before enabling fee-payer mode so Tempo includes sender
227
227
  // signature and access-key verification costs in the gas budget.
228
228
  prepared.gas = (prepared.gas ?? 0n) + 5_000n
229
- if (methodDetails?.feePayer) (prepared as Record<string, unknown>).feePayer = true
229
+ if (methodDetails?.feePayer) {
230
+ const sponsored = prepared as Record<string, unknown>
231
+ delete sponsored.feePayerSignature
232
+ delete sponsored.feeToken
233
+ sponsored.feePayer = true
234
+ }
230
235
  const signature = await signTransaction(client, prepared as never)
231
236
 
232
237
  return Credential.serialize({