mppx 0.3.11 → 0.3.13
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/dist/client/Mppx.d.ts +1 -1
- package/dist/client/Mppx.d.ts.map +1 -1
- package/dist/client/internal/Fetch.d.ts +1 -1
- package/dist/client/internal/Fetch.d.ts.map +1 -1
- package/dist/client/internal/Fetch.js +76 -11
- package/dist/client/internal/Fetch.js.map +1 -1
- package/dist/internal/constantTimeEqual.d.ts.map +1 -1
- package/dist/internal/constantTimeEqual.js +7 -4
- package/dist/internal/constantTimeEqual.js.map +1 -1
- package/dist/tempo/client/Charge.d.ts +10 -0
- package/dist/tempo/client/Charge.d.ts.map +1 -1
- package/dist/tempo/client/Charge.js +23 -9
- package/dist/tempo/client/Charge.js.map +1 -1
- package/dist/tempo/client/Methods.d.ts +1 -0
- package/dist/tempo/client/Methods.d.ts.map +1 -1
- package/dist/tempo/internal/auto-swap.d.ts +49 -0
- package/dist/tempo/internal/auto-swap.d.ts.map +1 -0
- package/dist/tempo/internal/auto-swap.js +89 -0
- package/dist/tempo/internal/auto-swap.js.map +1 -0
- package/dist/tempo/internal/fee-payer.d.ts +15 -0
- package/dist/tempo/internal/fee-payer.d.ts.map +1 -0
- package/dist/tempo/internal/fee-payer.js +41 -0
- package/dist/tempo/internal/fee-payer.js.map +1 -0
- package/dist/tempo/internal/selectors.d.ts +5 -0
- package/dist/tempo/internal/selectors.d.ts.map +1 -0
- package/dist/tempo/internal/selectors.js +7 -0
- package/dist/tempo/internal/selectors.js.map +1 -0
- package/dist/tempo/server/Charge.d.ts.map +1 -1
- package/dist/tempo/server/Charge.js +8 -6
- package/dist/tempo/server/Charge.js.map +1 -1
- package/package.json +1 -1
- package/src/client/Mppx.test-d.ts +28 -0
- package/src/client/Mppx.ts +3 -3
- package/src/client/internal/Fetch.test.ts +454 -0
- package/src/client/internal/Fetch.ts +89 -14
- package/src/internal/constantTimeEqual.ts +6 -4
- package/src/tempo/client/Charge.ts +40 -9
- package/src/tempo/internal/auto-swap.test.ts +113 -0
- package/src/tempo/internal/auto-swap.ts +141 -0
- package/src/tempo/internal/fee-payer.test.ts +223 -0
- package/src/tempo/internal/fee-payer.ts +53 -0
- package/src/tempo/internal/selectors.ts +10 -0
- package/src/tempo/server/Charge.test.ts +374 -3
- package/src/tempo/server/Charge.ts +9 -18
|
@@ -1,10 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
decodeFunctionData,
|
|
3
|
-
isAddressEqual,
|
|
4
|
-
parseEventLogs,
|
|
5
|
-
type TransactionReceipt,
|
|
6
|
-
toFunctionSelector,
|
|
7
|
-
} from 'viem'
|
|
1
|
+
import { decodeFunctionData, isAddressEqual, parseEventLogs, type TransactionReceipt } from 'viem'
|
|
8
2
|
import {
|
|
9
3
|
getTransactionReceipt,
|
|
10
4
|
sendRawTransaction,
|
|
@@ -19,18 +13,12 @@ import * as Method from '../../Method.js'
|
|
|
19
13
|
import * as Client from '../../viem/Client.js'
|
|
20
14
|
import * as Account from '../internal/account.js'
|
|
21
15
|
import * as defaults from '../internal/defaults.js'
|
|
16
|
+
import * as FeePayer from '../internal/fee-payer.js'
|
|
17
|
+
import * as Selectors from '../internal/selectors.js'
|
|
22
18
|
import { simulateTransaction } from '../internal/simulate.js'
|
|
23
19
|
import type * as types from '../internal/types.js'
|
|
24
20
|
import * as Methods from '../Methods.js'
|
|
25
21
|
|
|
26
|
-
const transferSelector = /*#__PURE__*/ toFunctionSelector(
|
|
27
|
-
'function transfer(address to, uint256 amount)',
|
|
28
|
-
)
|
|
29
|
-
|
|
30
|
-
const transferWithMemoSelector = /*#__PURE__*/ toFunctionSelector(
|
|
31
|
-
'function transferWithMemo(address to, uint256 amount, bytes32 memo)',
|
|
32
|
-
)
|
|
33
|
-
|
|
34
22
|
/**
|
|
35
23
|
* Creates a Tempo charge method intent for usage on the server.
|
|
36
24
|
*
|
|
@@ -202,7 +190,7 @@ export function charge<const parameters extends charge.Parameters>(
|
|
|
202
190
|
const selector = call.data.slice(0, 10)
|
|
203
191
|
|
|
204
192
|
if (memo) {
|
|
205
|
-
if (selector !==
|
|
193
|
+
if (selector !== Selectors.transferWithMemo) return false
|
|
206
194
|
try {
|
|
207
195
|
const { args } = decodeFunctionData({ abi: Abis.tip20, data: call.data })
|
|
208
196
|
const [to, amount_, memo_] = args as [`0x${string}`, bigint, `0x${string}`]
|
|
@@ -216,7 +204,7 @@ export function charge<const parameters extends charge.Parameters>(
|
|
|
216
204
|
}
|
|
217
205
|
}
|
|
218
206
|
|
|
219
|
-
if (selector ===
|
|
207
|
+
if (selector === Selectors.transfer) {
|
|
220
208
|
try {
|
|
221
209
|
const { args } = decodeFunctionData({ abi: Abis.tip20, data: call.data })
|
|
222
210
|
const [to, amount_] = args as [`0x${string}`, bigint]
|
|
@@ -226,7 +214,7 @@ export function charge<const parameters extends charge.Parameters>(
|
|
|
226
214
|
}
|
|
227
215
|
}
|
|
228
216
|
|
|
229
|
-
if (selector ===
|
|
217
|
+
if (selector === Selectors.transferWithMemo) {
|
|
230
218
|
try {
|
|
231
219
|
const { args } = decodeFunctionData({ abi: Abis.tip20, data: call.data })
|
|
232
220
|
const [to, amount_] = args as [`0x${string}`, bigint, `0x${string}`]
|
|
@@ -246,6 +234,9 @@ export function charge<const parameters extends charge.Parameters>(
|
|
|
246
234
|
recipient,
|
|
247
235
|
})
|
|
248
236
|
|
|
237
|
+
if (feePayer && methodDetails?.feePayer !== false)
|
|
238
|
+
FeePayer.validateCalls(calls, { amount, currency, recipient })
|
|
239
|
+
|
|
249
240
|
const serializedTransaction_final = await (async () => {
|
|
250
241
|
if (feePayer && methodDetails?.feePayer !== false) {
|
|
251
242
|
return signTransaction(client, {
|