uvd-x402-sdk 2.69.0 → 2.70.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.
@@ -2608,6 +2608,20 @@ var ERC8004_CONTRACTS = {
2608
2608
  function wireNetwork(network) {
2609
2609
  return network === "base-mainnet" ? "base" : network;
2610
2610
  }
2611
+ var RELAYED_FEEDBACK_NETWORKS = [
2612
+ "base",
2613
+ "ethereum",
2614
+ "polygon",
2615
+ "arbitrum",
2616
+ "optimism",
2617
+ "celo",
2618
+ "bsc",
2619
+ "monad",
2620
+ "base-sepolia"
2621
+ ];
2622
+ function supportsRelayedFeedback(network) {
2623
+ return RELAYED_FEEDBACK_NETWORKS.includes(wireNetwork(network));
2624
+ }
2611
2625
  var Erc8004LookupError = class extends Error {
2612
2626
  /** HTTP status returned by the facilitator */
2613
2627
  status;
@@ -2805,6 +2819,14 @@ var Erc8004Client = class {
2805
2819
  *
2806
2820
  * Requires proof of payment for authorized feedback submission.
2807
2821
  *
2822
+ * @deprecated On this route the facilitator is the AUTHOR: the registry
2823
+ * records `msg.sender`, and that is the facilitator's wallet — which can also
2824
+ * revoke what it wrote. On the networks in {@link RELAYED_FEEDBACK_NETWORKS}
2825
+ * use {@link Erc8004Client.prepareRelayedFeedback} +
2826
+ * {@link Erc8004Client.submitRelayedFeedback} instead, which record the RATER
2827
+ * as author. This route still works and is not going away without notice: it
2828
+ * is the only one available where no `FeedbackDelegate` is deployed.
2829
+ *
2808
2830
  * @param request - Feedback request with agent ID, value, and proof
2809
2831
  * @returns Feedback response with transaction hash
2810
2832
  *
@@ -2864,6 +2886,132 @@ var Erc8004Client = class {
2864
2886
  };
2865
2887
  }
2866
2888
  }
2889
+ /**
2890
+ * Ask the facilitator what the rater must sign to author a rating.
2891
+ *
2892
+ * Step 1 of the rater-authored rail. Writes nothing on-chain and costs
2893
+ * nothing: it reads the delegate, the rater's delegation state and their
2894
+ * account nonce, then hands back a digest, a deadline and a single-use nonce.
2895
+ *
2896
+ * Why this exists: the ERC-8004 Reputation Registry records `msg.sender` as
2897
+ * the author, and the deployed implementation has no delegation path — no
2898
+ * `giveFeedbackWithSignature`, no ERC-2771 forwarder. So a rating the
2899
+ * facilitator relays the ordinary way is a rating attributed to the
2900
+ * FACILITATOR. EIP-7702 fixes it without touching the registry: the rater
2901
+ * delegates their own EOA to the `FeedbackDelegate` and the transaction is
2902
+ * sent TO THE RATER'S ADDRESS, so the registry sees the rater while the
2903
+ * facilitator pays.
2904
+ *
2905
+ * What to do with the answer:
2906
+ * 1. Sign `digest` with the rater's key (EIP-191 personal-sign).
2907
+ * 2. If `delegated` is `false`, also produce an EIP-7702 authorization over
2908
+ * `(chainId, delegate, accountNonce)`.
2909
+ * 3. Hand both to {@link submitRelayedFeedback} with the SAME feedback
2910
+ * parameters, `deadline` and `nonce`.
2911
+ *
2912
+ * @param request - Network, rater address and feedback parameters
2913
+ * @returns Everything needed to sign, including whether an EIP-7702
2914
+ * authorization is still required
2915
+ *
2916
+ * @example
2917
+ * ```ts
2918
+ * const prep = await erc8004.prepareRelayedFeedback({
2919
+ * x402Version: 1,
2920
+ * network: 'base',
2921
+ * feedback: { agentId: 18896, value: 95, tag1: 'quality', rater: raterAddress },
2922
+ * });
2923
+ * // prep.delegated === false -> an EIP-7702 authorization is required
2924
+ * ```
2925
+ */
2926
+ async prepareRelayedFeedback(request) {
2927
+ const url = `${this.baseUrl}/feedback/evm/prepare`;
2928
+ const controller = new AbortController();
2929
+ const timeoutId = setTimeout(() => controller.abort(), this.timeout);
2930
+ try {
2931
+ const response = await fetch(url, {
2932
+ method: "POST",
2933
+ headers: {
2934
+ "Content-Type": "application/json",
2935
+ "Accept": "application/json"
2936
+ },
2937
+ body: JSON.stringify({ ...request, network: wireNetwork(request.network) }),
2938
+ signal: controller.signal
2939
+ });
2940
+ clearTimeout(timeoutId);
2941
+ if (!response.ok) {
2942
+ const errorText = await response.text();
2943
+ return {
2944
+ success: false,
2945
+ delegated: false,
2946
+ chainId: 0,
2947
+ error: `Facilitator error: ${response.status} - ${errorText}`,
2948
+ network: request.network
2949
+ };
2950
+ }
2951
+ return await response.json();
2952
+ } catch (error) {
2953
+ clearTimeout(timeoutId);
2954
+ return {
2955
+ success: false,
2956
+ delegated: false,
2957
+ chainId: 0,
2958
+ error: error instanceof Error ? error.message : "Unknown error",
2959
+ network: request.network
2960
+ };
2961
+ }
2962
+ }
2963
+ /**
2964
+ * Relay a rater-authored rating; the facilitator pays the gas.
2965
+ *
2966
+ * Step 2 of the rater-authored rail. The on-chain record that comes out of it
2967
+ * has the RATER as `msg.sender`, so `getClients(agentId)` shows the rater
2968
+ * rather than the facilitator.
2969
+ *
2970
+ * Pass back the same feedback parameters, `deadline` and `nonce` that
2971
+ * {@link prepareRelayedFeedback} returned. They are not redundant: the
2972
+ * facilitator rebuilds the registry calldata from them and requires the
2973
+ * rater's signature to cover exactly that.
2974
+ *
2975
+ * `authorization` is required only when `prepare` answered
2976
+ * `delegated: false`. One that names a different delegate than the one
2977
+ * `prepare` offered is refused before any gas is spent.
2978
+ *
2979
+ * @param request - Feedback parameters plus the rater's signature
2980
+ * @returns Feedback response with the transaction hash
2981
+ */
2982
+ async submitRelayedFeedback(request) {
2983
+ const url = `${this.baseUrl}/feedback/evm/submit`;
2984
+ const controller = new AbortController();
2985
+ const timeoutId = setTimeout(() => controller.abort(), this.timeout);
2986
+ try {
2987
+ const response = await fetch(url, {
2988
+ method: "POST",
2989
+ headers: {
2990
+ "Content-Type": "application/json",
2991
+ "Accept": "application/json"
2992
+ },
2993
+ body: JSON.stringify({ ...request, network: wireNetwork(request.network) }),
2994
+ signal: controller.signal
2995
+ });
2996
+ clearTimeout(timeoutId);
2997
+ if (!response.ok) {
2998
+ const errorText = await response.text();
2999
+ return {
3000
+ success: false,
3001
+ error: `Facilitator error: ${response.status} - ${errorText}`,
3002
+ network: request.network
3003
+ };
3004
+ }
3005
+ return await response.json();
3006
+ } catch (error) {
3007
+ clearTimeout(timeoutId);
3008
+ return {
3009
+ success: false,
3010
+ error: error instanceof Error ? error.message : "Unknown error",
3011
+ network: request.network
3012
+ };
3013
+ }
3014
+ }
2867
3015
  /**
2868
3016
  * Revoke previously submitted feedback
2869
3017
  *
@@ -4250,6 +4398,7 @@ exports.MAX_SEARCH_LEN = MAX_SEARCH_LEN;
4250
4398
  exports.OPERATOR_ABI = OPERATOR_ABI;
4251
4399
  exports.OPERATOR_ABI_CREATE3 = OPERATOR_ABI_CREATE3;
4252
4400
  exports.PAYMENT_INFO_TYPEHASH = PAYMENT_INFO_TYPEHASH;
4401
+ exports.RELAYED_FEEDBACK_NETWORKS = RELAYED_FEEDBACK_NETWORKS;
4253
4402
  exports.RegistrationPendingError = RegistrationPendingError;
4254
4403
  exports.TIER_FILTERS = TIER_FILTERS;
4255
4404
  exports.TIER_TIMINGS = TIER_TIMINGS;
@@ -4279,6 +4428,7 @@ exports.isEscrowExpired = isEscrowExpired;
4279
4428
  exports.isEscrowSupportedOnChain = isEscrowSupportedOnChain;
4280
4429
  exports.isRegisterJobTerminal = isRegisterJobTerminal;
4281
4430
  exports.parsePaymentHeader = parsePaymentHeader;
4431
+ exports.supportsRelayedFeedback = supportsRelayedFeedback;
4282
4432
  exports.wireNetwork = wireNetwork;
4283
4433
  //# sourceMappingURL=index.js.map
4284
4434
  //# sourceMappingURL=index.js.map