@pear-protocol/exchanges-sdk 0.17.0 → 0.17.1

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.
@@ -14,14 +14,21 @@ function createHyperliquidHelper(demo = false) {
14
14
  const role = await fetchUserRole(userAddress, demo);
15
15
  return role.role !== "missing";
16
16
  },
17
- /** Checks that the requested API wallet exists and has not expired. */
17
+ /** Checks ownership and expiry for named and unnamed API wallets. */
18
18
  async checkApiWallet(params) {
19
19
  const agents = await fetchInfo({
20
20
  type: "extraAgents",
21
21
  user: params.userAddress
22
22
  }, demo);
23
- const now = Date.now();
24
- return agents.some((agent) => agent.address.toLowerCase() === params.agentWalletAddress.toLowerCase() && (agent.validUntil === null || agent.validUntil > now));
23
+ const matchingAgent = agents.find((candidate) => candidate.address.toLowerCase() === params.agentWalletAddress.toLowerCase());
24
+ if (matchingAgent) {
25
+ return matchingAgent.validUntil === null || matchingAgent.validUntil > Date.now();
26
+ }
27
+ const { userState } = await fetchInfo({
28
+ type: "webData3",
29
+ user: params.userAddress
30
+ }, demo);
31
+ return userState.agentAddress?.toLowerCase() === params.agentWalletAddress.toLowerCase() && (userState.agentValidUntil === null || userState.agentValidUntil > Date.now());
25
32
  },
26
33
  /** Checks that the approval covers the exact builder fee requested by orders. */
27
34
  async checkBuilderFeeApproval(userAddress, builderAddress, requiredFeeTenthsBps) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pear-protocol/exchanges-sdk",
3
- "version": "0.17.0",
3
+ "version": "0.17.1",
4
4
  "description": "Pear Protocol Exchanges SDK",
5
5
  "private": false,
6
6
  "type": "module",