@owney/sdk 0.8.1 → 0.8.2
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/index.cjs +47 -9
- package/dist/index.d.cts +9 -0
- package/dist/index.d.ts +9 -0
- package/dist/index.js +47 -9
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -1027,15 +1027,36 @@ function buildAutoSelectUpdate(current, asset, chainId) {
|
|
|
1027
1027
|
}
|
|
1028
1028
|
|
|
1029
1029
|
// src/agents/zyfai/protocol-merge.ts
|
|
1030
|
-
function
|
|
1030
|
+
function isExcludedProtocol(protocol, excluded) {
|
|
1031
|
+
if (excluded.length === 0) return false;
|
|
1032
|
+
const wanted = new Set(excluded.map((entry) => entry.toLowerCase()));
|
|
1033
|
+
return wanted.has(protocol.id.toLowerCase()) || protocol.name !== void 0 && wanted.has(protocol.name.toLowerCase());
|
|
1034
|
+
}
|
|
1035
|
+
function buildProtocolMergeUpdate(available, current, asset, excluded = []) {
|
|
1036
|
+
const excludedIds = /* @__PURE__ */ new Set([
|
|
1037
|
+
...excluded.map((entry) => entry.toLowerCase()),
|
|
1038
|
+
...available.filter((p) => isExcludedProtocol(p, excluded)).map((p) => p.id.toLowerCase())
|
|
1039
|
+
]);
|
|
1040
|
+
const isExcludedId = (id) => excluded.length > 0 && excludedIds.has(id.toLowerCase());
|
|
1031
1041
|
const enabled = current.protocols ?? [];
|
|
1032
|
-
const
|
|
1033
|
-
const
|
|
1034
|
-
|
|
1042
|
+
const kept = enabled.filter((id) => !isExcludedId(id));
|
|
1043
|
+
const keptSet = new Set(kept);
|
|
1044
|
+
const missing = available.filter(
|
|
1045
|
+
(p) => !keptSet.has(p.id) && !isExcluded(p)
|
|
1046
|
+
);
|
|
1047
|
+
const fixAutoSelect = excluded.length > 0 && current.autoSelectProtocols !== false;
|
|
1048
|
+
const removedAny = kept.length !== enabled.length;
|
|
1049
|
+
if (missing.length === 0 && !removedAny && !fixAutoSelect) return null;
|
|
1050
|
+
const protocols = [.../* @__PURE__ */ new Set([...kept, ...missing.map((p) => p.id)])];
|
|
1051
|
+
if (protocols.length === 0) return null;
|
|
1035
1052
|
return {
|
|
1036
1053
|
asset,
|
|
1037
|
-
protocols
|
|
1054
|
+
protocols,
|
|
1055
|
+
...excluded.length > 0 ? { autoSelectProtocols: false } : {}
|
|
1038
1056
|
};
|
|
1057
|
+
function isExcluded(p) {
|
|
1058
|
+
return isExcludedProtocol(p, excluded);
|
|
1059
|
+
}
|
|
1039
1060
|
}
|
|
1040
1061
|
|
|
1041
1062
|
// src/agents/zyfai/splitting.ts
|
|
@@ -1299,8 +1320,11 @@ var ZyfaiAgent = class _ZyfaiAgent {
|
|
|
1299
1320
|
earningsSnapshot = null;
|
|
1300
1321
|
earningsGeneration = 0;
|
|
1301
1322
|
sessionStore;
|
|
1302
|
-
|
|
1323
|
+
/** Protocols this app bars (id or name); see OwneySDKConfig.excludedProtocols. */
|
|
1324
|
+
excludedProtocols;
|
|
1325
|
+
constructor(apiKey, rpcUrls, referralSource, sessionStore = new BrowserSessionStore(), excludedProtocols = []) {
|
|
1303
1326
|
this.sessionStore = sessionStore;
|
|
1327
|
+
this.excludedProtocols = excludedProtocols;
|
|
1304
1328
|
this.rpcUrls = rpcUrls ?? DEFAULT_ZYFAI_RPC_URLS;
|
|
1305
1329
|
this.sdk = new import_sdk.ZyfaiSDK({
|
|
1306
1330
|
apiKey,
|
|
@@ -1557,7 +1581,12 @@ var ZyfaiAgent = class _ZyfaiAgent {
|
|
|
1557
1581
|
);
|
|
1558
1582
|
return;
|
|
1559
1583
|
}
|
|
1560
|
-
const update = buildProtocolMergeUpdate(
|
|
1584
|
+
const update = buildProtocolMergeUpdate(
|
|
1585
|
+
available,
|
|
1586
|
+
current,
|
|
1587
|
+
asset,
|
|
1588
|
+
this.excludedProtocols
|
|
1589
|
+
);
|
|
1561
1590
|
if (!update) return;
|
|
1562
1591
|
await this.sdk.updateUserProfile(update);
|
|
1563
1592
|
debugLog("zyfai:protocol-sync", `${asset}: wrote profile update`, update);
|
|
@@ -1809,9 +1838,12 @@ var ZyfaiAgent = class _ZyfaiAgent {
|
|
|
1809
1838
|
* lookup fails is skipped rather than failing the whole catalogue.
|
|
1810
1839
|
*/
|
|
1811
1840
|
async getPoolCatalog(params) {
|
|
1812
|
-
const { protocols:
|
|
1841
|
+
const { protocols: allProtocols } = await this.sdk.getAvailableProtocols(
|
|
1813
1842
|
this.supportedChainIds[0]
|
|
1814
1843
|
);
|
|
1844
|
+
const universe = allProtocols.filter(
|
|
1845
|
+
(protocol) => !isExcludedProtocol(protocol, this.excludedProtocols)
|
|
1846
|
+
);
|
|
1815
1847
|
const poolResults = await Promise.all(
|
|
1816
1848
|
universe.map(async (protocol) => {
|
|
1817
1849
|
try {
|
|
@@ -2248,6 +2280,9 @@ var ZyfaiAgent = class _ZyfaiAgent {
|
|
|
2248
2280
|
requestedStrategy: "aggressive",
|
|
2249
2281
|
setupResult
|
|
2250
2282
|
});
|
|
2283
|
+
if (this.excludedProtocols.length > 0) {
|
|
2284
|
+
await this.ensureProtocolsSynced(validChainId, asset);
|
|
2285
|
+
}
|
|
2251
2286
|
if (isOwneyDebug()) {
|
|
2252
2287
|
try {
|
|
2253
2288
|
const profileAfterSetup = await this.sdk.getUserDetails(
|
|
@@ -5114,6 +5149,7 @@ var OwneySDK = class {
|
|
|
5114
5149
|
orgAgentConfigPromise = null;
|
|
5115
5150
|
zyfaiRpcUrls;
|
|
5116
5151
|
userPoolCustomization = false;
|
|
5152
|
+
excludedProtocols = [];
|
|
5117
5153
|
routingApiBaseUrl;
|
|
5118
5154
|
referralSource;
|
|
5119
5155
|
sessionStore;
|
|
@@ -5142,6 +5178,7 @@ var OwneySDK = class {
|
|
|
5142
5178
|
this.referralSource = config.referralSource;
|
|
5143
5179
|
this.sessionStore = config.sessionStore;
|
|
5144
5180
|
this.userPoolCustomization = config.userPoolCustomization ?? false;
|
|
5181
|
+
this.excludedProtocols = config.excludedProtocols ?? [];
|
|
5145
5182
|
}
|
|
5146
5183
|
/**
|
|
5147
5184
|
* Establish connection state for all subsequent SDK calls.
|
|
@@ -5418,7 +5455,8 @@ var OwneySDK = class {
|
|
|
5418
5455
|
key2,
|
|
5419
5456
|
this.zyfaiRpcUrls,
|
|
5420
5457
|
this.referralSource,
|
|
5421
|
-
this.sessionStore
|
|
5458
|
+
this.sessionStore,
|
|
5459
|
+
this.excludedProtocols
|
|
5422
5460
|
);
|
|
5423
5461
|
}
|
|
5424
5462
|
return null;
|
package/dist/index.d.cts
CHANGED
|
@@ -309,6 +309,14 @@ interface OwneySDKConfig {
|
|
|
309
309
|
* pool customization is the source of truth.
|
|
310
310
|
*/
|
|
311
311
|
userPoolCustomization?: boolean;
|
|
312
|
+
/**
|
|
313
|
+
* Protocols this app never lets users allocate to, by Zyfai protocol id or
|
|
314
|
+
* name (case-insensitive), e.g. `["superform"]`. On every wallet connect the
|
|
315
|
+
* SDK removes them from the user's protocol list and turns Zyfai's protocol
|
|
316
|
+
* auto-select off (auto-select would bypass the list). They are also left
|
|
317
|
+
* out of the pool catalogue and never added back by the protocol sync.
|
|
318
|
+
*/
|
|
319
|
+
excludedProtocols?: string[];
|
|
312
320
|
/**
|
|
313
321
|
* Absolute URL of an ERC-7677 paymaster service. When set, deposits go out as
|
|
314
322
|
* an EIP-5792 `wallet_sendCalls` with `capabilities.paymasterService`, so a
|
|
@@ -1222,6 +1230,7 @@ declare class OwneySDK {
|
|
|
1222
1230
|
private orgAgentConfigPromise;
|
|
1223
1231
|
private zyfaiRpcUrls?;
|
|
1224
1232
|
private userPoolCustomization;
|
|
1233
|
+
private excludedProtocols;
|
|
1225
1234
|
private routingApiBaseUrl?;
|
|
1226
1235
|
private referralSource?;
|
|
1227
1236
|
private sessionStore?;
|
package/dist/index.d.ts
CHANGED
|
@@ -309,6 +309,14 @@ interface OwneySDKConfig {
|
|
|
309
309
|
* pool customization is the source of truth.
|
|
310
310
|
*/
|
|
311
311
|
userPoolCustomization?: boolean;
|
|
312
|
+
/**
|
|
313
|
+
* Protocols this app never lets users allocate to, by Zyfai protocol id or
|
|
314
|
+
* name (case-insensitive), e.g. `["superform"]`. On every wallet connect the
|
|
315
|
+
* SDK removes them from the user's protocol list and turns Zyfai's protocol
|
|
316
|
+
* auto-select off (auto-select would bypass the list). They are also left
|
|
317
|
+
* out of the pool catalogue and never added back by the protocol sync.
|
|
318
|
+
*/
|
|
319
|
+
excludedProtocols?: string[];
|
|
312
320
|
/**
|
|
313
321
|
* Absolute URL of an ERC-7677 paymaster service. When set, deposits go out as
|
|
314
322
|
* an EIP-5792 `wallet_sendCalls` with `capabilities.paymasterService`, so a
|
|
@@ -1222,6 +1230,7 @@ declare class OwneySDK {
|
|
|
1222
1230
|
private orgAgentConfigPromise;
|
|
1223
1231
|
private zyfaiRpcUrls?;
|
|
1224
1232
|
private userPoolCustomization;
|
|
1233
|
+
private excludedProtocols;
|
|
1225
1234
|
private routingApiBaseUrl?;
|
|
1226
1235
|
private referralSource?;
|
|
1227
1236
|
private sessionStore?;
|
package/dist/index.js
CHANGED
|
@@ -986,15 +986,36 @@ function buildAutoSelectUpdate(current, asset, chainId) {
|
|
|
986
986
|
}
|
|
987
987
|
|
|
988
988
|
// src/agents/zyfai/protocol-merge.ts
|
|
989
|
-
function
|
|
989
|
+
function isExcludedProtocol(protocol, excluded) {
|
|
990
|
+
if (excluded.length === 0) return false;
|
|
991
|
+
const wanted = new Set(excluded.map((entry) => entry.toLowerCase()));
|
|
992
|
+
return wanted.has(protocol.id.toLowerCase()) || protocol.name !== void 0 && wanted.has(protocol.name.toLowerCase());
|
|
993
|
+
}
|
|
994
|
+
function buildProtocolMergeUpdate(available, current, asset, excluded = []) {
|
|
995
|
+
const excludedIds = /* @__PURE__ */ new Set([
|
|
996
|
+
...excluded.map((entry) => entry.toLowerCase()),
|
|
997
|
+
...available.filter((p) => isExcludedProtocol(p, excluded)).map((p) => p.id.toLowerCase())
|
|
998
|
+
]);
|
|
999
|
+
const isExcludedId = (id) => excluded.length > 0 && excludedIds.has(id.toLowerCase());
|
|
990
1000
|
const enabled = current.protocols ?? [];
|
|
991
|
-
const
|
|
992
|
-
const
|
|
993
|
-
|
|
1001
|
+
const kept = enabled.filter((id) => !isExcludedId(id));
|
|
1002
|
+
const keptSet = new Set(kept);
|
|
1003
|
+
const missing = available.filter(
|
|
1004
|
+
(p) => !keptSet.has(p.id) && !isExcluded(p)
|
|
1005
|
+
);
|
|
1006
|
+
const fixAutoSelect = excluded.length > 0 && current.autoSelectProtocols !== false;
|
|
1007
|
+
const removedAny = kept.length !== enabled.length;
|
|
1008
|
+
if (missing.length === 0 && !removedAny && !fixAutoSelect) return null;
|
|
1009
|
+
const protocols = [.../* @__PURE__ */ new Set([...kept, ...missing.map((p) => p.id)])];
|
|
1010
|
+
if (protocols.length === 0) return null;
|
|
994
1011
|
return {
|
|
995
1012
|
asset,
|
|
996
|
-
protocols
|
|
1013
|
+
protocols,
|
|
1014
|
+
...excluded.length > 0 ? { autoSelectProtocols: false } : {}
|
|
997
1015
|
};
|
|
1016
|
+
function isExcluded(p) {
|
|
1017
|
+
return isExcludedProtocol(p, excluded);
|
|
1018
|
+
}
|
|
998
1019
|
}
|
|
999
1020
|
|
|
1000
1021
|
// src/agents/zyfai/splitting.ts
|
|
@@ -1258,8 +1279,11 @@ var ZyfaiAgent = class _ZyfaiAgent {
|
|
|
1258
1279
|
earningsSnapshot = null;
|
|
1259
1280
|
earningsGeneration = 0;
|
|
1260
1281
|
sessionStore;
|
|
1261
|
-
|
|
1282
|
+
/** Protocols this app bars (id or name); see OwneySDKConfig.excludedProtocols. */
|
|
1283
|
+
excludedProtocols;
|
|
1284
|
+
constructor(apiKey, rpcUrls, referralSource, sessionStore = new BrowserSessionStore(), excludedProtocols = []) {
|
|
1262
1285
|
this.sessionStore = sessionStore;
|
|
1286
|
+
this.excludedProtocols = excludedProtocols;
|
|
1263
1287
|
this.rpcUrls = rpcUrls ?? DEFAULT_ZYFAI_RPC_URLS;
|
|
1264
1288
|
this.sdk = new ZyfaiSDK({
|
|
1265
1289
|
apiKey,
|
|
@@ -1516,7 +1540,12 @@ var ZyfaiAgent = class _ZyfaiAgent {
|
|
|
1516
1540
|
);
|
|
1517
1541
|
return;
|
|
1518
1542
|
}
|
|
1519
|
-
const update = buildProtocolMergeUpdate(
|
|
1543
|
+
const update = buildProtocolMergeUpdate(
|
|
1544
|
+
available,
|
|
1545
|
+
current,
|
|
1546
|
+
asset,
|
|
1547
|
+
this.excludedProtocols
|
|
1548
|
+
);
|
|
1520
1549
|
if (!update) return;
|
|
1521
1550
|
await this.sdk.updateUserProfile(update);
|
|
1522
1551
|
debugLog("zyfai:protocol-sync", `${asset}: wrote profile update`, update);
|
|
@@ -1768,9 +1797,12 @@ var ZyfaiAgent = class _ZyfaiAgent {
|
|
|
1768
1797
|
* lookup fails is skipped rather than failing the whole catalogue.
|
|
1769
1798
|
*/
|
|
1770
1799
|
async getPoolCatalog(params) {
|
|
1771
|
-
const { protocols:
|
|
1800
|
+
const { protocols: allProtocols } = await this.sdk.getAvailableProtocols(
|
|
1772
1801
|
this.supportedChainIds[0]
|
|
1773
1802
|
);
|
|
1803
|
+
const universe = allProtocols.filter(
|
|
1804
|
+
(protocol) => !isExcludedProtocol(protocol, this.excludedProtocols)
|
|
1805
|
+
);
|
|
1774
1806
|
const poolResults = await Promise.all(
|
|
1775
1807
|
universe.map(async (protocol) => {
|
|
1776
1808
|
try {
|
|
@@ -2207,6 +2239,9 @@ var ZyfaiAgent = class _ZyfaiAgent {
|
|
|
2207
2239
|
requestedStrategy: "aggressive",
|
|
2208
2240
|
setupResult
|
|
2209
2241
|
});
|
|
2242
|
+
if (this.excludedProtocols.length > 0) {
|
|
2243
|
+
await this.ensureProtocolsSynced(validChainId, asset);
|
|
2244
|
+
}
|
|
2210
2245
|
if (isOwneyDebug()) {
|
|
2211
2246
|
try {
|
|
2212
2247
|
const profileAfterSetup = await this.sdk.getUserDetails(
|
|
@@ -5094,6 +5129,7 @@ var OwneySDK = class {
|
|
|
5094
5129
|
orgAgentConfigPromise = null;
|
|
5095
5130
|
zyfaiRpcUrls;
|
|
5096
5131
|
userPoolCustomization = false;
|
|
5132
|
+
excludedProtocols = [];
|
|
5097
5133
|
routingApiBaseUrl;
|
|
5098
5134
|
referralSource;
|
|
5099
5135
|
sessionStore;
|
|
@@ -5122,6 +5158,7 @@ var OwneySDK = class {
|
|
|
5122
5158
|
this.referralSource = config.referralSource;
|
|
5123
5159
|
this.sessionStore = config.sessionStore;
|
|
5124
5160
|
this.userPoolCustomization = config.userPoolCustomization ?? false;
|
|
5161
|
+
this.excludedProtocols = config.excludedProtocols ?? [];
|
|
5125
5162
|
}
|
|
5126
5163
|
/**
|
|
5127
5164
|
* Establish connection state for all subsequent SDK calls.
|
|
@@ -5398,7 +5435,8 @@ var OwneySDK = class {
|
|
|
5398
5435
|
key2,
|
|
5399
5436
|
this.zyfaiRpcUrls,
|
|
5400
5437
|
this.referralSource,
|
|
5401
|
-
this.sessionStore
|
|
5438
|
+
this.sessionStore,
|
|
5439
|
+
this.excludedProtocols
|
|
5402
5440
|
);
|
|
5403
5441
|
}
|
|
5404
5442
|
return null;
|