@owney/sdk 0.7.25-beta.6 → 0.7.25-beta.7

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/README.md CHANGED
@@ -16,11 +16,7 @@ import { OwneySDK } from "@owney/sdk";
16
16
  // Create the SDK instance
17
17
  const sdk = new OwneySDK({
18
18
  apiKey: "your-owney-api-key",
19
- rpcUrls: {
20
- 1: "https://eth-mainnet.g.alchemy.com/v2/<key>",
21
- 8453: "https://base-mainnet.g.alchemy.com/v2/<key>",
22
- 42161: "https://arb-mainnet.g.alchemy.com/v2/<key>",
23
- },
19
+ routingApiBaseUrl: "https://your-routing-api.example",
24
20
  });
25
21
 
26
22
  // Connect with an EIP-1193 wallet provider
@@ -42,6 +38,7 @@ Create a new SDK instance.
42
38
  | Param | Type | Description |
43
39
  | --------------------------------------- | ----------------------------------------------------------- | ------------------------------------------------------------------------------------------------- |
44
40
  | `config.apiKey` | `string` | Your Owney API key, used to authenticate with the routing API and fetch agent-specific keys |
41
+ | `config.routingApiBaseUrl` | `string` (optional) | Routing API URL; required for proxy reads unless the SDK build has `OWNEY_ROUTING_API_BASE_URL` or all `rpcUrls` are set |
45
42
  | `config.rpcUrls` | `{ 1?: string; 8453?: string; 42161?: string }` (optional) | Per-chain RPC overrides used by agent reads and transaction-receipt polling |
46
43
  | `config.zyfaiRpcUrls` | Same as `rpcUrls` (deprecated) | Legacy Zyfai-only override; use `rpcUrls` for all application-owned reads |
47
44
 
@@ -50,11 +47,7 @@ import { OwneySDK } from "@owney/sdk";
50
47
 
51
48
  const sdk = new OwneySDK({
52
49
  apiKey: "your-owney-api-key",
53
- rpcUrls: {
54
- 1: "https://eth-mainnet.g.alchemy.com/v2/<key>",
55
- 8453: "https://base-mainnet.g.alchemy.com/v2/<key>",
56
- 42161: "https://arb-mainnet.g.alchemy.com/v2/<key>",
57
- },
50
+ routingApiBaseUrl: "https://your-routing-api.example",
58
51
  });
59
52
  ```
60
53
 
@@ -68,16 +61,18 @@ switching, signatures, and transaction submission.
68
61
  supported chain using this precedence:
69
62
 
70
63
  1. The caller-provided `rpcUrls[chainId]`, when present and non-empty.
71
- 2. The Owney SDK default URL for that chain.
64
+ 2. The Owney routing API read-only RPC proxy for that chain.
72
65
 
73
- The SDK defaults are Owney-managed Alchemy endpoints embedded in the SDK. They
74
- keep zero-configuration integrations working, but their capacity is shared by
75
- every consumer that does not provide an override.
66
+ The Alchemy credential stays on the routing API server. The SDK sends its
67
+ existing organization key to the proxy for per-organization rate limiting.
68
+ The proxy base URL must be provided through `routingApiBaseUrl` or the SDK
69
+ build's `OWNEY_ROUTING_API_BASE_URL`; there is no hardcoded production fallback.
76
70
 
77
71
  ```typescript
78
- // Zero configuration: all supported chains use Owney SDK defaults.
72
+ // All supported chains use the Owney routing API proxy.
79
73
  const sdk = new OwneySDK({
80
74
  apiKey: "your-owney-api-key",
75
+ routingApiBaseUrl: "https://your-routing-api.example",
81
76
  });
82
77
  ```
83
78
 
@@ -86,9 +81,10 @@ Overrides can be complete or partial:
86
81
  ```typescript
87
82
  const sdk = new OwneySDK({
88
83
  apiKey: "your-owney-api-key",
84
+ routingApiBaseUrl: "https://your-routing-api.example",
89
85
  rpcUrls: {
90
- // Ethereum and Arbitrum continue using Owney SDK defaults.
91
- 8453: "https://base-mainnet.g.alchemy.com/v2/<key>",
86
+ // Ethereum and Arbitrum continue using the routing API proxy.
87
+ 8453: "https://your-own-rpc.example/rpc",
92
88
  },
93
89
  });
94
90
  ```
@@ -106,12 +102,10 @@ The resolved URLs are shared across Owney-owned reads and agent integrations:
106
102
 
107
103
  Notes:
108
104
 
109
- - Owney mini-apps should continue passing explicit environment-specific URLs,
110
- even though the SDK defaults provide a fallback.
111
- - Production SDK consumers should provide their own endpoints for quota
112
- isolation, origin restrictions, and predictable capacity.
113
- - Partial maps override only the supplied chains; missing chains retain Owney
114
- SDK defaults.
105
+ - Owney mini-apps pass the same routing API proxy URLs to Wagmi and the SDK.
106
+ - SDK consumers may override endpoints if they operate their own RPC provider.
107
+ - Partial maps override only the supplied chains; missing chains use Owney's
108
+ routing API proxy.
115
109
  - HTTP reads use bounded retries and honor provider `Retry-After` responses.
116
110
  - `zyfaiRpcUrls` remains available for compatibility but applies only to Zyfai.
117
111
 
package/dist/index.cjs CHANGED
@@ -1133,21 +1133,32 @@ function protocolsPolicyNeedsUpdate(current, desiredProtocols, desiredAutoSelect
1133
1133
  var import_viem = require("viem");
1134
1134
  var PAID_RPC_RETRY_COUNT = 3;
1135
1135
  var PAID_RPC_RETRY_DELAY_MS = 1e3;
1136
- var DEFAULT_RPC_URLS = {
1137
- 1: "https://eth-mainnet.g.alchemy.com/v2/ZWyVU-9XfS3z8Rn-xkq7V",
1138
- 8453: "https://base-mainnet.g.alchemy.com/v2/ZWyVU-9XfS3z8Rn-xkq7V",
1139
- 42161: "https://arb-mainnet.g.alchemy.com/v2/ZWyVU-9XfS3z8Rn-xkq7V"
1140
- };
1141
- function resolveRpcUrl(rpcUrls, chainId) {
1136
+ function configuredRpcProxyBaseUrl(baseUrl) {
1137
+ const configured = (baseUrl ?? "")?.trim();
1138
+ if (!configured) {
1139
+ throw new Error(
1140
+ "OWNEY_ROUTING_API_BASE_URL is required for RPC proxy requests unless routingApiBaseUrl or all rpcUrls are configured."
1141
+ );
1142
+ }
1143
+ return configured;
1144
+ }
1145
+ function rpcProxyUrl(chainId, apiKey, baseUrl) {
1146
+ const url = new URL(
1147
+ `${configuredRpcProxyBaseUrl(baseUrl).replace(/\/$/, "")}/api/v1/rpc/${chainId}`
1148
+ );
1149
+ if (apiKey) url.searchParams.set("apiKey", apiKey);
1150
+ return url.toString();
1151
+ }
1152
+ function resolveRpcUrl(rpcUrls, chainId, apiKey = "", baseUrl) {
1142
1153
  const url = rpcUrls?.[chainId]?.trim();
1143
1154
  if (url) return url;
1144
- return DEFAULT_RPC_URLS[chainId];
1155
+ return rpcProxyUrl(chainId, apiKey, baseUrl);
1145
1156
  }
1146
- function resolveRpcUrls(rpcUrls) {
1157
+ function resolveRpcUrls(rpcUrls, apiKey = "", baseUrl) {
1147
1158
  return {
1148
- 1: resolveRpcUrl(rpcUrls, 1),
1149
- 8453: resolveRpcUrl(rpcUrls, 8453),
1150
- 42161: resolveRpcUrl(rpcUrls, 42161)
1159
+ 1: resolveRpcUrl(rpcUrls, 1, apiKey, baseUrl),
1160
+ 8453: resolveRpcUrl(rpcUrls, 8453, apiKey, baseUrl),
1161
+ 42161: resolveRpcUrl(rpcUrls, 42161, apiKey, baseUrl)
1151
1162
  };
1152
1163
  }
1153
1164
  function createPaidRpcClient(chain, rpcUrls) {
@@ -1173,7 +1184,13 @@ function headerValue(error, name) {
1173
1184
  seen.add(candidate);
1174
1185
  const record = candidate;
1175
1186
  const headers = record.headers;
1176
- const found = typeof headers?.get === "function" ? headers.get(name) : headers?.[name] ?? headers?.[name.toLowerCase()];
1187
+ let found;
1188
+ if (typeof headers?.get === "function") {
1189
+ found = headers.get(name);
1190
+ } else {
1191
+ const headerRecord = headers;
1192
+ found = headerRecord?.[name] ?? headerRecord?.[name.toLowerCase()];
1193
+ }
1177
1194
  if (typeof found === "string" && found) {
1178
1195
  value = found;
1179
1196
  return;
@@ -5137,8 +5154,12 @@ var OwneySDK = class {
5137
5154
  constructor(config) {
5138
5155
  this.apiKey = config.apiKey;
5139
5156
  if (config.debug) setOwneyDebug(true);
5140
- this.rpcUrls = config.rpcUrls;
5141
- this.zyfaiRpcUrls = config.zyfaiRpcUrls;
5157
+ this.rpcUrls = resolveRpcUrls(
5158
+ config.rpcUrls,
5159
+ config.apiKey,
5160
+ config.routingApiBaseUrl
5161
+ );
5162
+ this.zyfaiRpcUrls = config.rpcUrls ? void 0 : config.zyfaiRpcUrls;
5142
5163
  this.yieldseekerApiBaseUrl = config.yieldseekerApiBaseUrl;
5143
5164
  this.yieldseekerSiweOrigin = config.yieldseekerSiweOrigin;
5144
5165
  this.routingApiBaseUrl = config.routingApiBaseUrl;
@@ -5413,7 +5434,11 @@ var OwneySDK = class {
5413
5434
  if (!key2) return null;
5414
5435
  return new ZyfaiAgent(
5415
5436
  key2,
5416
- this.rpcUrls ?? this.zyfaiRpcUrls,
5437
+ this.zyfaiRpcUrls ? resolveRpcUrls(
5438
+ this.zyfaiRpcUrls,
5439
+ this.apiKey,
5440
+ this.routingApiBaseUrl
5441
+ ) : this.rpcUrls,
5417
5442
  this.referralSource
5418
5443
  );
5419
5444
  }
package/dist/index.d.cts CHANGED
@@ -8,7 +8,8 @@ interface OwneySDKConfig {
8
8
  apiKey: string;
9
9
  /**
10
10
  * Optional per-chain RPC overrides used for application-owned reads and
11
- * transaction receipt polling. Missing chains use Owney SDK defaults.
11
+ * transaction receipt polling. Missing chains use the Owney routing API's
12
+ * read-only RPC proxy. No upstream RPC credentials are included in the SDK.
12
13
  * Wallet providers remain responsible for account access, chain switching,
13
14
  * signatures, and transaction submission.
14
15
  */
@@ -25,9 +26,9 @@ interface OwneySDKConfig {
25
26
  yieldseekerSiweOrigin?: string;
26
27
  /**
27
28
  * Optional override for the Owney routing API base URL used by all routing
28
- * calls (defaults to the OWNEY_ROUTING_API_BASE_URL env var, then the
29
- * production URL). Set this to point at a local/staging routing API,
30
- * e.g. "http://localhost:3000", when testing sponsor changes.
29
+ * calls. RPC proxy requests use OWNEY_ROUTING_API_BASE_URL when this is
30
+ * omitted; without either value, all rpcUrls must be configured.
31
+ * Set this to a local/staging routing API when testing sponsor changes.
31
32
  */
32
33
  routingApiBaseUrl?: string;
33
34
  /**
package/dist/index.d.ts CHANGED
@@ -8,7 +8,8 @@ interface OwneySDKConfig {
8
8
  apiKey: string;
9
9
  /**
10
10
  * Optional per-chain RPC overrides used for application-owned reads and
11
- * transaction receipt polling. Missing chains use Owney SDK defaults.
11
+ * transaction receipt polling. Missing chains use the Owney routing API's
12
+ * read-only RPC proxy. No upstream RPC credentials are included in the SDK.
12
13
  * Wallet providers remain responsible for account access, chain switching,
13
14
  * signatures, and transaction submission.
14
15
  */
@@ -25,9 +26,9 @@ interface OwneySDKConfig {
25
26
  yieldseekerSiweOrigin?: string;
26
27
  /**
27
28
  * Optional override for the Owney routing API base URL used by all routing
28
- * calls (defaults to the OWNEY_ROUTING_API_BASE_URL env var, then the
29
- * production URL). Set this to point at a local/staging routing API,
30
- * e.g. "http://localhost:3000", when testing sponsor changes.
29
+ * calls. RPC proxy requests use OWNEY_ROUTING_API_BASE_URL when this is
30
+ * omitted; without either value, all rpcUrls must be configured.
31
+ * Set this to a local/staging routing API when testing sponsor changes.
31
32
  */
32
33
  routingApiBaseUrl?: string;
33
34
  /**
package/dist/index.js CHANGED
@@ -1102,21 +1102,32 @@ import {
1102
1102
  } from "viem";
1103
1103
  var PAID_RPC_RETRY_COUNT = 3;
1104
1104
  var PAID_RPC_RETRY_DELAY_MS = 1e3;
1105
- var DEFAULT_RPC_URLS = {
1106
- 1: "https://eth-mainnet.g.alchemy.com/v2/ZWyVU-9XfS3z8Rn-xkq7V",
1107
- 8453: "https://base-mainnet.g.alchemy.com/v2/ZWyVU-9XfS3z8Rn-xkq7V",
1108
- 42161: "https://arb-mainnet.g.alchemy.com/v2/ZWyVU-9XfS3z8Rn-xkq7V"
1109
- };
1110
- function resolveRpcUrl(rpcUrls, chainId) {
1105
+ function configuredRpcProxyBaseUrl(baseUrl) {
1106
+ const configured = (baseUrl ?? "")?.trim();
1107
+ if (!configured) {
1108
+ throw new Error(
1109
+ "OWNEY_ROUTING_API_BASE_URL is required for RPC proxy requests unless routingApiBaseUrl or all rpcUrls are configured."
1110
+ );
1111
+ }
1112
+ return configured;
1113
+ }
1114
+ function rpcProxyUrl(chainId, apiKey, baseUrl) {
1115
+ const url = new URL(
1116
+ `${configuredRpcProxyBaseUrl(baseUrl).replace(/\/$/, "")}/api/v1/rpc/${chainId}`
1117
+ );
1118
+ if (apiKey) url.searchParams.set("apiKey", apiKey);
1119
+ return url.toString();
1120
+ }
1121
+ function resolveRpcUrl(rpcUrls, chainId, apiKey = "", baseUrl) {
1111
1122
  const url = rpcUrls?.[chainId]?.trim();
1112
1123
  if (url) return url;
1113
- return DEFAULT_RPC_URLS[chainId];
1124
+ return rpcProxyUrl(chainId, apiKey, baseUrl);
1114
1125
  }
1115
- function resolveRpcUrls(rpcUrls) {
1126
+ function resolveRpcUrls(rpcUrls, apiKey = "", baseUrl) {
1116
1127
  return {
1117
- 1: resolveRpcUrl(rpcUrls, 1),
1118
- 8453: resolveRpcUrl(rpcUrls, 8453),
1119
- 42161: resolveRpcUrl(rpcUrls, 42161)
1128
+ 1: resolveRpcUrl(rpcUrls, 1, apiKey, baseUrl),
1129
+ 8453: resolveRpcUrl(rpcUrls, 8453, apiKey, baseUrl),
1130
+ 42161: resolveRpcUrl(rpcUrls, 42161, apiKey, baseUrl)
1120
1131
  };
1121
1132
  }
1122
1133
  function createPaidRpcClient(chain, rpcUrls) {
@@ -1142,7 +1153,13 @@ function headerValue(error, name) {
1142
1153
  seen.add(candidate);
1143
1154
  const record = candidate;
1144
1155
  const headers = record.headers;
1145
- const found = typeof headers?.get === "function" ? headers.get(name) : headers?.[name] ?? headers?.[name.toLowerCase()];
1156
+ let found;
1157
+ if (typeof headers?.get === "function") {
1158
+ found = headers.get(name);
1159
+ } else {
1160
+ const headerRecord = headers;
1161
+ found = headerRecord?.[name] ?? headerRecord?.[name.toLowerCase()];
1162
+ }
1146
1163
  if (typeof found === "string" && found) {
1147
1164
  value = found;
1148
1165
  return;
@@ -5127,8 +5144,12 @@ var OwneySDK = class {
5127
5144
  constructor(config) {
5128
5145
  this.apiKey = config.apiKey;
5129
5146
  if (config.debug) setOwneyDebug(true);
5130
- this.rpcUrls = config.rpcUrls;
5131
- this.zyfaiRpcUrls = config.zyfaiRpcUrls;
5147
+ this.rpcUrls = resolveRpcUrls(
5148
+ config.rpcUrls,
5149
+ config.apiKey,
5150
+ config.routingApiBaseUrl
5151
+ );
5152
+ this.zyfaiRpcUrls = config.rpcUrls ? void 0 : config.zyfaiRpcUrls;
5132
5153
  this.yieldseekerApiBaseUrl = config.yieldseekerApiBaseUrl;
5133
5154
  this.yieldseekerSiweOrigin = config.yieldseekerSiweOrigin;
5134
5155
  this.routingApiBaseUrl = config.routingApiBaseUrl;
@@ -5403,7 +5424,11 @@ var OwneySDK = class {
5403
5424
  if (!key2) return null;
5404
5425
  return new ZyfaiAgent(
5405
5426
  key2,
5406
- this.rpcUrls ?? this.zyfaiRpcUrls,
5427
+ this.zyfaiRpcUrls ? resolveRpcUrls(
5428
+ this.zyfaiRpcUrls,
5429
+ this.apiKey,
5430
+ this.routingApiBaseUrl
5431
+ ) : this.rpcUrls,
5407
5432
  this.referralSource
5408
5433
  );
5409
5434
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@owney/sdk",
3
- "version": "0.7.25-beta.6",
3
+ "version": "0.7.25-beta.7",
4
4
  "type": "module",
5
5
  "main": "dist/index.cjs",
6
6
  "module": "dist/index.js",