@stakekit/widget 0.0.285 → 0.0.287

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.
@@ -30119,7 +30119,7 @@ var layer = /*#__PURE__*/ layerMergedContext(/*#__PURE__*/ succeed$4(/* @__PURE_
30119
30119
  })));
30120
30120
  //#endregion
30121
30121
  //#region package.json
30122
- var version$1 = "0.0.285";
30122
+ var version$1 = "0.0.287";
30123
30123
  //#endregion
30124
30124
  //#region src/generated/api/borrow-client.ts
30125
30125
  var make$2 = (httpClient, options = {}) => {
@@ -32037,6 +32037,7 @@ var toYieldDirectoryParams = (request) => ({
32037
32037
  limit: request.limit,
32038
32038
  ...request.network ? { network: request.network } : {},
32039
32039
  offset: request.offset,
32040
+ ...request.token ? { token: request.token } : {},
32040
32041
  ...request.types ? { types: [...request.types] } : {},
32041
32042
  ...request.yieldIds ? { yieldIds: [...request.yieldIds] } : {}
32042
32043
  });
@@ -57309,20 +57310,24 @@ var ExternalProvider = class {
57309
57310
  this.variantProvider = variantProvider;
57310
57311
  }
57311
57312
  sendTransaction(tx, txMeta) {
57312
- const sendTransaction = this.variantProvider.current.provider.sendTransaction;
57313
- if (!sendTransaction) return fail$4(new ExternalProviderError({
57314
- customMessage: null,
57315
- message: "Invalid provider type"
57316
- }));
57317
- return sendExternalTransaction(() => sendTransaction(tx, txMeta));
57313
+ return suspend$1(() => {
57314
+ const sendTransaction = this.variantProvider.current.provider.sendTransaction;
57315
+ if (!sendTransaction) return fail$4(new ExternalProviderError({
57316
+ customMessage: null,
57317
+ message: "Invalid provider type"
57318
+ }));
57319
+ return sendExternalTransaction(() => sendTransaction(tx, txMeta));
57320
+ });
57318
57321
  }
57319
57322
  sendBorrowTransaction(tx, txMeta) {
57320
- const config = this.variantProvider.current;
57321
- if (!isBorrowExternalProvider(config)) return fail$4(new ExternalProviderError({
57322
- customMessage: null,
57323
- message: "Borrow transaction capability is unavailable"
57324
- }));
57325
- return sendExternalTransaction(() => config.provider.sendBorrowTransaction(tx, txMeta));
57323
+ return suspend$1(() => {
57324
+ const config = this.variantProvider.current;
57325
+ if (!isBorrowExternalProvider(config)) return fail$4(new ExternalProviderError({
57326
+ customMessage: null,
57327
+ message: "Borrow transaction capability is unavailable"
57328
+ }));
57329
+ return sendExternalTransaction(() => config.provider.sendBorrowTransaction(tx, txMeta));
57330
+ });
57326
57331
  }
57327
57332
  switchChain({ chainId }) {
57328
57333
  return tryPromise({
@@ -57341,14 +57346,16 @@ var ExternalProvider = class {
57341
57346
  });
57342
57347
  }
57343
57348
  signTypedData(typedData) {
57344
- const signTypedData = this.variantProvider.current.provider.signTypedData;
57345
- if (!signTypedData) return fail$4(new ExternalProviderError({
57346
- customMessage: null,
57347
- message: "Typed-data signing capability is unavailable"
57348
- }));
57349
- return tryPromise({
57350
- try: () => signTypedData(typedData),
57351
- catch: toExternalProviderError
57349
+ return suspend$1(() => {
57350
+ const signTypedData = this.variantProvider.current.provider.signTypedData;
57351
+ if (!signTypedData) return fail$4(new ExternalProviderError({
57352
+ customMessage: null,
57353
+ message: "Typed-data signing capability is unavailable"
57354
+ }));
57355
+ return tryPromise({
57356
+ try: () => signTypedData(typedData),
57357
+ catch: toExternalProviderError
57358
+ });
57352
57359
  });
57353
57360
  }
57354
57361
  };
@@ -57397,15 +57404,21 @@ var externalProviderConnector = (variant, runWalletEffect) => ({
57397
57404
  iconUrl: config.appIcon
57398
57405
  },
57399
57406
  createConnector: () => createConnector((connectorConfig) => {
57400
- const filteredChains = makeCurrentValueStream(variant.current.supportedChainIds ? connectorConfig.chains.filter((chain) => new Set(variant.current.supportedChainIds).has(chain.id)) : connectorConfig.chains);
57401
- if (filteredChains.get().length === 0) throw new Error("No supported chains found!");
57407
+ const resolveSupportedChains = (supportedChainIds) => {
57408
+ const supported = supportedChainIds === void 0 ? null : new Set(supportedChainIds);
57409
+ const chains = supported ? connectorConfig.chains.filter((chain) => supported.has(chain.id)) : connectorConfig.chains;
57410
+ if (chains.length === 0) throw new WalletRuntimeInvariantError({ reason: "external-provider-no-supported-chains" });
57411
+ return chains;
57412
+ };
57413
+ const filteredChains = makeCurrentValueStream(resolveSupportedChains(variant.current.supportedChainIds));
57402
57414
  const provider = new ExternalProvider(variant);
57403
57415
  const getFirstFilteredChain = () => head(filteredChains.get()).pipe(getOrThrowWith(() => /* @__PURE__ */ new Error("No supported chains found!")));
57404
- const getAccounts = async () => [variant.current.currentAddress];
57405
- const getChainId = async () => getFirstFilteredChain().id;
57416
+ const getAccounts = async () => variant.current.currentAddress ? [variant.current.currentAddress] : [];
57417
+ const getChainId = async () => variant.current.currentChain ?? getFirstFilteredChain().id;
57406
57418
  const connect = async (args) => {
57407
57419
  connectorConfig.emitter.emit("message", { type: "connecting" });
57408
57420
  const [accounts, chainId] = await Promise.all([getAccounts(), getChainId()]);
57421
+ if (accounts.length === 0) throw new Error("External provider has no connected account");
57409
57422
  return wagmiConnectResult(args?.withCapabilities, accounts, chainId);
57410
57423
  };
57411
57424
  const switchChain = async ({ chainId }) => {
@@ -57417,7 +57430,7 @@ var externalProviderConnector = (variant, runWalletEffect) => ({
57417
57430
  };
57418
57431
  const disconnect = async () => {};
57419
57432
  const getProvider = async () => ({});
57420
- const isAuthorized = async () => true;
57433
+ const isAuthorized = async () => Boolean(variant.current.currentAddress);
57421
57434
  const onDisconnect = () => {
57422
57435
  connectorConfig.emitter.emit("disconnect");
57423
57436
  };
@@ -57425,11 +57438,16 @@ var externalProviderConnector = (variant, runWalletEffect) => ({
57425
57438
  connectorConfig.emitter.emit("change", { chainId: normalizeChainId(chainId) });
57426
57439
  };
57427
57440
  const onAccountsChanged = (accounts) => {
57428
- connectorConfig.emitter.emit("change", { accounts: accounts.filter((a) => !!a) });
57441
+ const connectedAccounts = accounts.filter((account) => !!account);
57442
+ if (connectedAccounts.length === 0) {
57443
+ onDisconnect();
57444
+ return;
57445
+ }
57446
+ connectorConfig.emitter.emit("change", { accounts: connectedAccounts });
57429
57447
  };
57430
57448
  const onSupportedChainsChanged = ({ currentChainId, supportedChainIds }) => {
57431
- filteredChains.set(supportedChainIds.length ? connectorConfig.chains.filter((chain) => new Set(supportedChainIds).has(chain.id)) : connectorConfig.chains);
57432
- if (filteredChains.get().every((c) => c.id !== currentChainId)) getChainId().then((chainId) => onChainChanged(chainId.toString()));
57449
+ filteredChains.set(resolveSupportedChains(supportedChainIds));
57450
+ if (variant.current.currentChain === void 0 && filteredChains.get().every((c) => c.id !== currentChainId)) onChainChanged(getFirstFilteredChain().id.toString());
57433
57451
  };
57434
57452
  return {
57435
57453
  id: configMeta.id,
@@ -57802,15 +57820,22 @@ var buildWagmiConfig = (opts, buildActions, stellarWalletsKitPlatform) => gen(fu
57802
57820
  const connectors = walletList.length > 0 ? connectorsForWallets(walletList, connectorOptions) : [];
57803
57821
  const queryNetwork = val.queryParams.network;
57804
57822
  const queryParamsInitChainId = queryNetwork ? (val.evmConfig.evmChainsMap[queryNetwork] ?? val.cosmosConfig.cosmosChainsMap[queryNetwork] ?? val.miscConfig.miscChainsMap[queryNetwork] ?? val.substrateConfig.substrateChainsMap[queryNetwork])?.wagmiChain.id : void 0;
57805
- const wagmiConfig = createConfig({
57806
- chains: wagmiChains,
57807
- client: ({ chain }) => createClient({
57808
- chain,
57809
- transport: http()
57823
+ const wagmiConfig = yield* try_$1({
57824
+ try: () => createConfig({
57825
+ chains: wagmiChains,
57826
+ client: ({ chain }) => createClient({
57827
+ chain,
57828
+ transport: http()
57829
+ }),
57830
+ multiInjectedProviderDiscovery: false,
57831
+ storage: opts.externalProviders ? null : void 0,
57832
+ connectors
57810
57833
  }),
57811
- multiInjectedProviderDiscovery: false,
57812
- storage: opts.externalProviders ? null : void 0,
57813
- connectors
57834
+ catch: (cause) => new WalletIntegrationError({
57835
+ cause,
57836
+ message: "Could not create wallet configuration",
57837
+ operation: "create-config"
57838
+ })
57814
57839
  });
57815
57840
  if (multiInjectedProviderDiscovery && evmConfig.evmChains.length > 0) {
57816
57841
  const mipdStore = createStore$2();
@@ -58369,18 +58394,22 @@ var installExternalProviderSynchronization = fn("installExternalProviderSynchron
58369
58394
  if (connection.connector && !isExternalProviderConnector(connection.connector)) return yield* failInvariant("external-provider-connector-mismatch");
58370
58395
  const snapshot = bootstrap.externalProviders.current;
58371
58396
  const currentChainId = snapshot.currentChain ?? connection.chainId ?? bootstrap.controller.wagmiConfig.state.chainId;
58372
- const supportedChainIds = snapshot.supportedChainIds ? [...snapshot.supportedChainIds] : [];
58397
+ const supportedChainIds = snapshot.supportedChainIds;
58373
58398
  const currentMemory = yield* get$5(memory);
58374
- const supportedChainsKey = `${connector.uid}:${currentChainId}:${supportedChainIds.join(",") || "all"}`;
58399
+ const supportedChainsKey = `${connector.uid}:${currentChainId}:${supportedChainIds?.join(",") ?? "all"}`;
58375
58400
  if (currentMemory.supportedChainsNotification !== supportedChainsKey) {
58376
58401
  yield* update(memory, (current) => ({
58377
58402
  ...current,
58378
58403
  supportedChainsNotification: supportedChainsKey
58379
58404
  }));
58380
- yield* runConnectorNotification(() => connector.onSupportedChainsChanged({
58405
+ const notification = yield* try_$1(() => connector.onSupportedChainsChanged({
58381
58406
  currentChainId,
58382
58407
  supportedChainIds
58383
- }));
58408
+ })).pipe(result$1);
58409
+ if (isFailure$1(notification)) {
58410
+ const cause = notification.failure.cause;
58411
+ return yield* failInvariant(cause instanceof WalletRuntimeInvariantError ? cause.reason : "external-provider-supported-chains-update-failed", { cause });
58412
+ }
58384
58413
  }
58385
58414
  if (connection.status === "disconnected" && snapshot.currentAddress && currentMemory.connecting === null) {
58386
58415
  const address = snapshot.currentAddress;
@@ -58476,7 +58505,7 @@ var makeWalletLifecyclePolicy = gen(function* () {
58476
58505
  }];
58477
58506
  }
58478
58507
  if (state.status === "connecting") return [null, current];
58479
- if (state.status !== "unsupported" || !state.connector || !state.chain) return [null, initialMemory];
58508
+ if (state.status !== "unsupported" || !state.connector || !state.chain || isExternalProviderConnector(state.connector)) return [null, initialMemory];
58480
58509
  const connectionKey = `${state.connector.uid}:${state.address}:${state.chain.id}`;
58481
58510
  if (current.unsupportedConnection === connectionKey) return [null, {
58482
58511
  ...current,
@@ -58981,14 +59010,16 @@ var decodeProjectionFacts = ({ additionalAddresses, connection, connectorChains,
58981
59010
  const rawAddress = forceAddress || connection.address || null;
58982
59011
  const address = rawAddress ? decodeSync(WalletAddress$1)(rawAddress) : null;
58983
59012
  const chain = connection.chain ?? null;
59013
+ const connector = connection.connector ?? null;
59014
+ const isChainExcluded = chain !== null && connector !== null && isExternalProviderConnector(connector) && !connectorChains.some((supportedChain) => supportedChain.id === chain.id);
58984
59015
  return {
58985
59016
  additionalAddresses,
58986
59017
  address,
58987
59018
  chain,
58988
59019
  common,
58989
- connector: connection.connector ?? null,
59020
+ connector,
58990
59021
  ledgerState,
58991
- network: chain ? wagmiNetworkToSKNetwork({
59022
+ network: chain && !isChainExcluded ? wagmiNetworkToSKNetwork({
58992
59023
  chain,
58993
59024
  cosmosChainsMap: controller.cosmosConfig.cosmosChainsMap,
58994
59025
  evmChainsMap: controller.evmConfig.evmChainsMap,
@@ -59030,11 +59061,22 @@ var connectingWalletState = (facts) => {
59030
59061
  status: "connecting"
59031
59062
  };
59032
59063
  }
59033
- if (previous?.address && previous.network && previous.chain && previous.connector && previous.ledgerAccounts) return {
59034
- ...previous,
59035
- ...common,
59036
- status: "connecting"
59037
- };
59064
+ if (previous?.address && previous.network && previous.chain && previous.connector && previous.ledgerAccounts) {
59065
+ if (isExternalProviderConnector(previous.connector) && !common.connectorChains.some((supportedChain) => supportedChain.id === previous.chain.id)) return {
59066
+ ...previous,
59067
+ ...common,
59068
+ additionalAddresses: null,
59069
+ isLedgerLiveAccountPlaceholder: false,
59070
+ ledgerAccounts: null,
59071
+ network: null,
59072
+ status: "unsupported"
59073
+ };
59074
+ return {
59075
+ ...previous,
59076
+ ...common,
59077
+ status: "connecting"
59078
+ };
59079
+ }
59038
59080
  return {
59039
59081
  ...disconnectedNormalizedWalletState,
59040
59082
  ...common,
@@ -59085,7 +59127,12 @@ var normalizeWalletState = (input) => {
59085
59127
  };
59086
59128
  var transitionalWalletState = (input) => {
59087
59129
  if (input.connection.status === "disconnected") return normalizeWalletState(input);
59088
- return connectingWalletState(decodeProjectionFacts(input));
59130
+ const previous = input.previous;
59131
+ const connectorChains = previous?.connector && isExternalProviderConnector(previous.connector) && (!input.connection.connector || previous.connector.uid === input.connection.connector.uid) ? previous.connectorChains : input.connectorChains;
59132
+ return connectingWalletState(decodeProjectionFacts({
59133
+ ...input,
59134
+ connectorChains
59135
+ }));
59089
59136
  };
59090
59137
  var makeConnectorChainsStream = ({ connector, defaultEvmChains }) => {
59091
59138
  if (!connector || !isConnectorWithFilteredChains(connector)) return succeed$6(defaultEvmChains);
@@ -61160,6 +61207,7 @@ var WagmiConfigProvider = (t0) => {
61160
61207
  const $ = (0, import_compiler_runtime.c)(5);
61161
61208
  const { children } = t0;
61162
61209
  const walletConfigResult = useWalletConfig();
61210
+ const walletStateResult = useAtomValue(currentWalletStateResultAtom);
61163
61211
  let t1;
61164
61212
  if ($[0] !== walletConfigResult) {
61165
61213
  t1 = walletConfigResult.pipe(value$2, getOrUndefined$1);
@@ -61168,9 +61216,11 @@ var WagmiConfigProvider = (t0) => {
61168
61216
  } else t1 = $[1];
61169
61217
  const walletConfig = t1;
61170
61218
  const walletConfigError = walletConfigResult.pipe(error, getOrUndefined$1);
61219
+ const walletStateError = walletStateResult.pipe(error, getOrUndefined$1);
61171
61220
  const [fallbackConfig] = useState(makeDefaultConfig);
61172
61221
  const geoBlock = useGeoBlock();
61173
61222
  if (walletConfigError && !geoBlock) throw walletConfigError;
61223
+ if (walletStateError && !geoBlock) throw walletStateError;
61174
61224
  const value = walletConfig ?? fallbackConfig;
61175
61225
  let t2;
61176
61226
  if ($[2] !== children || $[3] !== value) {
@@ -67943,15 +67993,16 @@ var YieldDirectoryKey = class extends TaggedClass("YieldDirectoryKey") {
67943
67993
  constructor(input) {
67944
67994
  super({
67945
67995
  network: input.network ?? null,
67996
+ token: input.token ?? null,
67946
67997
  types: [...new Set(input.types ?? [])].sort(),
67947
- yieldIds: [...new Set(input.yieldIds)].sort()
67998
+ yieldIds: [...new Set(input.yieldIds ?? [])].sort()
67948
67999
  });
67949
68000
  }
67950
68001
  };
67951
68002
  var YieldDirectoryError = class extends TaggedError("YieldDirectoryError") {};
67952
68003
  var directoryPolicy = withApiResourcePolicy({ staleTime: minutes(5) });
67953
68004
  var yieldDirectoryResourceAtom = makePresentableResourceFamily(family((key) => appRuntime.atom(() => gen(function* () {
67954
- if (key.yieldIds?.length === 0) return {
68005
+ if (!key.token && key.yieldIds?.length === 0) return {
67955
68006
  items: [],
67956
68007
  missingYieldIds: []
67957
68008
  };
@@ -67960,11 +68011,16 @@ var yieldDirectoryResourceAtom = makePresentableResourceFamily(family((key) => a
67960
68011
  limit: 100,
67961
68012
  offset,
67962
68013
  ...key.network ? { network: key.network } : {},
68014
+ ...key.token ? { token: key.token } : {},
67963
68015
  ...key.types.length > 0 ? { types: key.types } : {},
67964
- ...yieldIds ? { yieldIds } : {}
68016
+ ...yieldIds && yieldIds.length > 0 ? { yieldIds } : {}
67965
68017
  });
67966
- const items = yield* loadAllPagesByIdChunks({
67967
- chunkSize: 100,
68018
+ const items = key.token ? yield* loadAllPages({
68019
+ concurrency: CONCURRENCY$1,
68020
+ fetchPage: (offset) => fetchPage(offset),
68021
+ pageSize: 100
68022
+ }) : yield* loadAllPagesByIdChunks({
68023
+ chunkSize: 20,
67968
68024
  concurrency: CONCURRENCY$1,
67969
68025
  fetchPage: ({ ids, offset }) => fetchPage(offset, ids),
67970
68026
  getItemId: (yieldModel) => yieldModel.id,
@@ -70595,6 +70651,7 @@ var availableYieldCategoriesAtom = family((key) => make$11((get) => {
70595
70651
  var earnYieldCatalogAtom = family((key) => {
70596
70652
  const source = enrichedYieldDirectoryResourceAtom.foreground(new YieldDirectoryKey({
70597
70653
  network: key.network,
70654
+ token: key.token,
70598
70655
  types: void 0,
70599
70656
  yieldIds: key.yieldIds
70600
70657
  }));
@@ -70700,7 +70757,9 @@ var AvailableYieldCategoriesKey = class extends TaggedClass("AvailableYieldCateg
70700
70757
  var YieldCatalogKey = class extends TaggedClass("YieldCatalogKey") {
70701
70758
  constructor(input) {
70702
70759
  super({
70703
- ...input,
70760
+ category: input.category,
70761
+ network: input.network,
70762
+ token: input.token ?? null,
70704
70763
  yieldIds: [...new Set(input.yieldIds)].sort()
70705
70764
  });
70706
70765
  }
@@ -71154,6 +71213,7 @@ var readTokenOptions = (context, { category, entry }) => context.get(mergedToken
71154
71213
  var readYieldCatalog = (context, { selectedToken }) => context.get(earnYieldCatalogAtom(new YieldCatalogKey({
71155
71214
  category: null,
71156
71215
  network: selectedToken.token.network,
71216
+ token: selectedToken.token.address || selectedToken.token.symbol,
71157
71217
  yieldIds: selectedToken.availableYields
71158
71218
  })));
71159
71219
  var readValidators = (context, { selectedYield }) => {