facinet 2.0.3 → 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 +49 -40
- package/dist/browser.js.map +3 -3
- package/dist/sdk/Facinet.d.ts.map +1 -1
- package/dist/sdk/Facinet.js +47 -41
- package/dist/sdk/Facinet.js.map +1 -1
- package/dist/sdk.mjs +49 -40
- package/dist/sdk.mjs.map +3 -3
- package/package.json +1 -1
package/dist/browser.js
CHANGED
|
@@ -22657,26 +22657,27 @@ 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
|
-
|
|
22662
|
-
|
|
22663
|
-
|
|
22664
|
-
|
|
22665
|
-
|
|
22666
|
-
|
|
22667
|
-
|
|
22660
|
+
const typedData = {
|
|
22661
|
+
domain,
|
|
22662
|
+
types,
|
|
22663
|
+
primaryType: "TransferWithAuthorization",
|
|
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
|
+
}
|
|
22668
22673
|
};
|
|
22674
|
+
const jsonMessage = JSON.stringify(
|
|
22675
|
+
typedData,
|
|
22676
|
+
(_key, value2) => typeof value2 === "bigint" ? value2.toString() : value2
|
|
22677
|
+
);
|
|
22669
22678
|
signature = await window.ethereum.request({
|
|
22670
22679
|
method: "eth_signTypedData_v4",
|
|
22671
|
-
params: [
|
|
22672
|
-
payerAddress,
|
|
22673
|
-
JSON.stringify({
|
|
22674
|
-
domain,
|
|
22675
|
-
types,
|
|
22676
|
-
primaryType: "TransferWithAuthorization",
|
|
22677
|
-
message: messageForBrowser
|
|
22678
|
-
})
|
|
22679
|
-
]
|
|
22680
|
+
params: [payerAddress, jsonMessage]
|
|
22680
22681
|
});
|
|
22681
22682
|
} else {
|
|
22682
22683
|
throw new Error("No signing method available");
|
|
@@ -22692,31 +22693,39 @@ var Facinet = class _Facinet {
|
|
|
22692
22693
|
nonce
|
|
22693
22694
|
}
|
|
22694
22695
|
};
|
|
22695
|
-
|
|
22696
|
-
|
|
22697
|
-
|
|
22698
|
-
|
|
22699
|
-
|
|
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");
|
|
22700
22706
|
}
|
|
22701
|
-
|
|
22702
|
-
|
|
22703
|
-
|
|
22704
|
-
|
|
22705
|
-
|
|
22706
|
-
|
|
22707
|
-
|
|
22708
|
-
|
|
22709
|
-
|
|
22710
|
-
|
|
22711
|
-
|
|
22712
|
-
|
|
22713
|
-
|
|
22714
|
-
|
|
22715
|
-
|
|
22716
|
-
|
|
22717
|
-
|
|
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}`);
|
|
22718
22726
|
}
|
|
22719
|
-
|
|
22727
|
+
throw error;
|
|
22728
|
+
}
|
|
22720
22729
|
}
|
|
22721
22730
|
/**
|
|
22722
22731
|
* Get all active facilitators
|