facinet 2.0.4 → 2.1.0
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/browser.js +46 -35
- package/dist/browser.js.map +3 -3
- package/dist/sdk/Facinet.d.ts.map +1 -1
- package/dist/sdk/Facinet.js +44 -37
- package/dist/sdk/Facinet.js.map +1 -1
- package/dist/sdk.mjs +46 -35
- package/dist/sdk.mjs.map +3 -3
- package/package.json +1 -1
package/dist/browser.js
CHANGED
|
@@ -22657,21 +22657,24 @@ var Facinet = class _Facinet {
|
|
|
22657
22657
|
if (this.wallet) {
|
|
22658
22658
|
signature = await this.wallet.signTypedData(domain, types, value);
|
|
22659
22659
|
} else if (typeof window !== "undefined" && window.ethereum) {
|
|
22660
|
-
const
|
|
22661
|
-
from: payerAddress,
|
|
22662
|
-
to: params.recipient,
|
|
22663
|
-
value: "0x" + amount.toString(16),
|
|
22664
|
-
// BigInt to hex string
|
|
22665
|
-
validAfter,
|
|
22666
|
-
validBefore,
|
|
22667
|
-
nonce
|
|
22668
|
-
};
|
|
22669
|
-
const jsonMessage = JSON.stringify({
|
|
22660
|
+
const typedData = {
|
|
22670
22661
|
domain,
|
|
22671
22662
|
types,
|
|
22672
22663
|
primaryType: "TransferWithAuthorization",
|
|
22673
|
-
message:
|
|
22674
|
-
|
|
22664
|
+
message: {
|
|
22665
|
+
from: payerAddress,
|
|
22666
|
+
to: params.recipient,
|
|
22667
|
+
value: amount.toString(),
|
|
22668
|
+
// BigInt to decimal string
|
|
22669
|
+
validAfter: validAfter.toString(),
|
|
22670
|
+
validBefore: validBefore.toString(),
|
|
22671
|
+
nonce
|
|
22672
|
+
}
|
|
22673
|
+
};
|
|
22674
|
+
const jsonMessage = JSON.stringify(
|
|
22675
|
+
typedData,
|
|
22676
|
+
(_key, value2) => typeof value2 === "bigint" ? value2.toString() : value2
|
|
22677
|
+
);
|
|
22675
22678
|
signature = await window.ethereum.request({
|
|
22676
22679
|
method: "eth_signTypedData_v4",
|
|
22677
22680
|
params: [payerAddress, jsonMessage]
|
|
@@ -22690,31 +22693,39 @@ var Facinet = class _Facinet {
|
|
|
22690
22693
|
nonce
|
|
22691
22694
|
}
|
|
22692
22695
|
};
|
|
22693
|
-
|
|
22694
|
-
|
|
22695
|
-
|
|
22696
|
-
|
|
22697
|
-
|
|
22696
|
+
try {
|
|
22697
|
+
const response = await axios_default.post(
|
|
22698
|
+
`${this.config.apiUrl}/api/x402/settle-custom`,
|
|
22699
|
+
{
|
|
22700
|
+
facilitatorId: facilitator.id,
|
|
22701
|
+
paymentPayload
|
|
22702
|
+
}
|
|
22703
|
+
);
|
|
22704
|
+
if (!response.data.success) {
|
|
22705
|
+
throw new Error(response.data.error || response.data.message || "Payment failed");
|
|
22698
22706
|
}
|
|
22699
|
-
|
|
22700
|
-
|
|
22701
|
-
|
|
22702
|
-
|
|
22703
|
-
|
|
22704
|
-
|
|
22705
|
-
|
|
22706
|
-
|
|
22707
|
-
|
|
22708
|
-
|
|
22709
|
-
|
|
22710
|
-
|
|
22711
|
-
|
|
22712
|
-
|
|
22713
|
-
|
|
22714
|
-
|
|
22715
|
-
|
|
22707
|
+
return {
|
|
22708
|
+
success: true,
|
|
22709
|
+
txHash: response.data.txHash,
|
|
22710
|
+
facilitator: {
|
|
22711
|
+
id: facilitator.id,
|
|
22712
|
+
name: facilitator.name,
|
|
22713
|
+
wallet: facilitator.facilitatorWallet
|
|
22714
|
+
},
|
|
22715
|
+
payment: {
|
|
22716
|
+
from: payerAddress,
|
|
22717
|
+
to: params.recipient,
|
|
22718
|
+
amount: params.amount,
|
|
22719
|
+
network: this.config.network
|
|
22720
|
+
}
|
|
22721
|
+
};
|
|
22722
|
+
} catch (error) {
|
|
22723
|
+
if (error.response?.data) {
|
|
22724
|
+
const backendError = error.response.data.message || error.response.data.error;
|
|
22725
|
+
throw new Error(`Payment failed: ${backendError}`);
|
|
22716
22726
|
}
|
|
22717
|
-
|
|
22727
|
+
throw error;
|
|
22728
|
+
}
|
|
22718
22729
|
}
|
|
22719
22730
|
/**
|
|
22720
22731
|
* Get all active facilitators
|