@owney/sdk 0.8.1 → 0.8.3
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 +45 -9
- package/dist/index.d.cts +9 -0
- package/dist/index.d.ts +9 -0
- package/dist/index.js +45 -9
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -1027,15 +1027,34 @@ 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 = current.autoSelectProtocols === false ? [] : available.filter((p) => !keptSet.has(p.id) && !isExcluded(p));
|
|
1045
|
+
const fixAutoSelect = excluded.length > 0 && current.autoSelectProtocols !== false;
|
|
1046
|
+
const removedAny = kept.length !== enabled.length;
|
|
1047
|
+
if (missing.length === 0 && !removedAny && !fixAutoSelect) return null;
|
|
1048
|
+
const protocols = [.../* @__PURE__ */ new Set([...kept, ...missing.map((p) => p.id)])];
|
|
1049
|
+
if (protocols.length === 0) return null;
|
|
1035
1050
|
return {
|
|
1036
1051
|
asset,
|
|
1037
|
-
protocols
|
|
1052
|
+
protocols,
|
|
1053
|
+
...excluded.length > 0 ? { autoSelectProtocols: false } : {}
|
|
1038
1054
|
};
|
|
1055
|
+
function isExcluded(p) {
|
|
1056
|
+
return isExcludedProtocol(p, excluded);
|
|
1057
|
+
}
|
|
1039
1058
|
}
|
|
1040
1059
|
|
|
1041
1060
|
// src/agents/zyfai/splitting.ts
|
|
@@ -1299,8 +1318,11 @@ var ZyfaiAgent = class _ZyfaiAgent {
|
|
|
1299
1318
|
earningsSnapshot = null;
|
|
1300
1319
|
earningsGeneration = 0;
|
|
1301
1320
|
sessionStore;
|
|
1302
|
-
|
|
1321
|
+
/** Protocols this app bars (id or name); see OwneySDKConfig.excludedProtocols. */
|
|
1322
|
+
excludedProtocols;
|
|
1323
|
+
constructor(apiKey, rpcUrls, referralSource, sessionStore = new BrowserSessionStore(), excludedProtocols = []) {
|
|
1303
1324
|
this.sessionStore = sessionStore;
|
|
1325
|
+
this.excludedProtocols = excludedProtocols;
|
|
1304
1326
|
this.rpcUrls = rpcUrls ?? DEFAULT_ZYFAI_RPC_URLS;
|
|
1305
1327
|
this.sdk = new import_sdk.ZyfaiSDK({
|
|
1306
1328
|
apiKey,
|
|
@@ -1557,7 +1579,12 @@ var ZyfaiAgent = class _ZyfaiAgent {
|
|
|
1557
1579
|
);
|
|
1558
1580
|
return;
|
|
1559
1581
|
}
|
|
1560
|
-
const update = buildProtocolMergeUpdate(
|
|
1582
|
+
const update = buildProtocolMergeUpdate(
|
|
1583
|
+
available,
|
|
1584
|
+
current,
|
|
1585
|
+
asset,
|
|
1586
|
+
this.excludedProtocols
|
|
1587
|
+
);
|
|
1561
1588
|
if (!update) return;
|
|
1562
1589
|
await this.sdk.updateUserProfile(update);
|
|
1563
1590
|
debugLog("zyfai:protocol-sync", `${asset}: wrote profile update`, update);
|
|
@@ -1809,9 +1836,12 @@ var ZyfaiAgent = class _ZyfaiAgent {
|
|
|
1809
1836
|
* lookup fails is skipped rather than failing the whole catalogue.
|
|
1810
1837
|
*/
|
|
1811
1838
|
async getPoolCatalog(params) {
|
|
1812
|
-
const { protocols:
|
|
1839
|
+
const { protocols: allProtocols } = await this.sdk.getAvailableProtocols(
|
|
1813
1840
|
this.supportedChainIds[0]
|
|
1814
1841
|
);
|
|
1842
|
+
const universe = allProtocols.filter(
|
|
1843
|
+
(protocol) => !isExcludedProtocol(protocol, this.excludedProtocols)
|
|
1844
|
+
);
|
|
1815
1845
|
const poolResults = await Promise.all(
|
|
1816
1846
|
universe.map(async (protocol) => {
|
|
1817
1847
|
try {
|
|
@@ -2248,6 +2278,9 @@ var ZyfaiAgent = class _ZyfaiAgent {
|
|
|
2248
2278
|
requestedStrategy: "aggressive",
|
|
2249
2279
|
setupResult
|
|
2250
2280
|
});
|
|
2281
|
+
if (this.excludedProtocols.length > 0) {
|
|
2282
|
+
await this.ensureProtocolsSynced(validChainId, asset);
|
|
2283
|
+
}
|
|
2251
2284
|
if (isOwneyDebug()) {
|
|
2252
2285
|
try {
|
|
2253
2286
|
const profileAfterSetup = await this.sdk.getUserDetails(
|
|
@@ -5114,6 +5147,7 @@ var OwneySDK = class {
|
|
|
5114
5147
|
orgAgentConfigPromise = null;
|
|
5115
5148
|
zyfaiRpcUrls;
|
|
5116
5149
|
userPoolCustomization = false;
|
|
5150
|
+
excludedProtocols = [];
|
|
5117
5151
|
routingApiBaseUrl;
|
|
5118
5152
|
referralSource;
|
|
5119
5153
|
sessionStore;
|
|
@@ -5142,6 +5176,7 @@ var OwneySDK = class {
|
|
|
5142
5176
|
this.referralSource = config.referralSource;
|
|
5143
5177
|
this.sessionStore = config.sessionStore;
|
|
5144
5178
|
this.userPoolCustomization = config.userPoolCustomization ?? false;
|
|
5179
|
+
this.excludedProtocols = config.excludedProtocols ?? [];
|
|
5145
5180
|
}
|
|
5146
5181
|
/**
|
|
5147
5182
|
* Establish connection state for all subsequent SDK calls.
|
|
@@ -5418,7 +5453,8 @@ var OwneySDK = class {
|
|
|
5418
5453
|
key2,
|
|
5419
5454
|
this.zyfaiRpcUrls,
|
|
5420
5455
|
this.referralSource,
|
|
5421
|
-
this.sessionStore
|
|
5456
|
+
this.sessionStore,
|
|
5457
|
+
this.excludedProtocols
|
|
5422
5458
|
);
|
|
5423
5459
|
}
|
|
5424
5460
|
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,34 @@ 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 = current.autoSelectProtocols === false ? [] : available.filter((p) => !keptSet.has(p.id) && !isExcluded(p));
|
|
1004
|
+
const fixAutoSelect = excluded.length > 0 && current.autoSelectProtocols !== false;
|
|
1005
|
+
const removedAny = kept.length !== enabled.length;
|
|
1006
|
+
if (missing.length === 0 && !removedAny && !fixAutoSelect) return null;
|
|
1007
|
+
const protocols = [.../* @__PURE__ */ new Set([...kept, ...missing.map((p) => p.id)])];
|
|
1008
|
+
if (protocols.length === 0) return null;
|
|
994
1009
|
return {
|
|
995
1010
|
asset,
|
|
996
|
-
protocols
|
|
1011
|
+
protocols,
|
|
1012
|
+
...excluded.length > 0 ? { autoSelectProtocols: false } : {}
|
|
997
1013
|
};
|
|
1014
|
+
function isExcluded(p) {
|
|
1015
|
+
return isExcludedProtocol(p, excluded);
|
|
1016
|
+
}
|
|
998
1017
|
}
|
|
999
1018
|
|
|
1000
1019
|
// src/agents/zyfai/splitting.ts
|
|
@@ -1258,8 +1277,11 @@ var ZyfaiAgent = class _ZyfaiAgent {
|
|
|
1258
1277
|
earningsSnapshot = null;
|
|
1259
1278
|
earningsGeneration = 0;
|
|
1260
1279
|
sessionStore;
|
|
1261
|
-
|
|
1280
|
+
/** Protocols this app bars (id or name); see OwneySDKConfig.excludedProtocols. */
|
|
1281
|
+
excludedProtocols;
|
|
1282
|
+
constructor(apiKey, rpcUrls, referralSource, sessionStore = new BrowserSessionStore(), excludedProtocols = []) {
|
|
1262
1283
|
this.sessionStore = sessionStore;
|
|
1284
|
+
this.excludedProtocols = excludedProtocols;
|
|
1263
1285
|
this.rpcUrls = rpcUrls ?? DEFAULT_ZYFAI_RPC_URLS;
|
|
1264
1286
|
this.sdk = new ZyfaiSDK({
|
|
1265
1287
|
apiKey,
|
|
@@ -1516,7 +1538,12 @@ var ZyfaiAgent = class _ZyfaiAgent {
|
|
|
1516
1538
|
);
|
|
1517
1539
|
return;
|
|
1518
1540
|
}
|
|
1519
|
-
const update = buildProtocolMergeUpdate(
|
|
1541
|
+
const update = buildProtocolMergeUpdate(
|
|
1542
|
+
available,
|
|
1543
|
+
current,
|
|
1544
|
+
asset,
|
|
1545
|
+
this.excludedProtocols
|
|
1546
|
+
);
|
|
1520
1547
|
if (!update) return;
|
|
1521
1548
|
await this.sdk.updateUserProfile(update);
|
|
1522
1549
|
debugLog("zyfai:protocol-sync", `${asset}: wrote profile update`, update);
|
|
@@ -1768,9 +1795,12 @@ var ZyfaiAgent = class _ZyfaiAgent {
|
|
|
1768
1795
|
* lookup fails is skipped rather than failing the whole catalogue.
|
|
1769
1796
|
*/
|
|
1770
1797
|
async getPoolCatalog(params) {
|
|
1771
|
-
const { protocols:
|
|
1798
|
+
const { protocols: allProtocols } = await this.sdk.getAvailableProtocols(
|
|
1772
1799
|
this.supportedChainIds[0]
|
|
1773
1800
|
);
|
|
1801
|
+
const universe = allProtocols.filter(
|
|
1802
|
+
(protocol) => !isExcludedProtocol(protocol, this.excludedProtocols)
|
|
1803
|
+
);
|
|
1774
1804
|
const poolResults = await Promise.all(
|
|
1775
1805
|
universe.map(async (protocol) => {
|
|
1776
1806
|
try {
|
|
@@ -2207,6 +2237,9 @@ var ZyfaiAgent = class _ZyfaiAgent {
|
|
|
2207
2237
|
requestedStrategy: "aggressive",
|
|
2208
2238
|
setupResult
|
|
2209
2239
|
});
|
|
2240
|
+
if (this.excludedProtocols.length > 0) {
|
|
2241
|
+
await this.ensureProtocolsSynced(validChainId, asset);
|
|
2242
|
+
}
|
|
2210
2243
|
if (isOwneyDebug()) {
|
|
2211
2244
|
try {
|
|
2212
2245
|
const profileAfterSetup = await this.sdk.getUserDetails(
|
|
@@ -5094,6 +5127,7 @@ var OwneySDK = class {
|
|
|
5094
5127
|
orgAgentConfigPromise = null;
|
|
5095
5128
|
zyfaiRpcUrls;
|
|
5096
5129
|
userPoolCustomization = false;
|
|
5130
|
+
excludedProtocols = [];
|
|
5097
5131
|
routingApiBaseUrl;
|
|
5098
5132
|
referralSource;
|
|
5099
5133
|
sessionStore;
|
|
@@ -5122,6 +5156,7 @@ var OwneySDK = class {
|
|
|
5122
5156
|
this.referralSource = config.referralSource;
|
|
5123
5157
|
this.sessionStore = config.sessionStore;
|
|
5124
5158
|
this.userPoolCustomization = config.userPoolCustomization ?? false;
|
|
5159
|
+
this.excludedProtocols = config.excludedProtocols ?? [];
|
|
5125
5160
|
}
|
|
5126
5161
|
/**
|
|
5127
5162
|
* Establish connection state for all subsequent SDK calls.
|
|
@@ -5398,7 +5433,8 @@ var OwneySDK = class {
|
|
|
5398
5433
|
key2,
|
|
5399
5434
|
this.zyfaiRpcUrls,
|
|
5400
5435
|
this.referralSource,
|
|
5401
|
-
this.sessionStore
|
|
5436
|
+
this.sessionStore,
|
|
5437
|
+
this.excludedProtocols
|
|
5402
5438
|
);
|
|
5403
5439
|
}
|
|
5404
5440
|
return null;
|