Skip to content

Commit 4d7e366

Browse files
Copilottamirms
andcommitted
Complete RPC migration: update package imports and add notes for unsupported features
Co-authored-by: tamirms <1445829+tamirms@users.noreply.github.com>
1 parent d510b36 commit 4d7e366

File tree

2 files changed

+51
-36
lines changed

2 files changed

+51
-36
lines changed

docs/build/apps/example-application-tutorial/manage-trust.mdx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -146,8 +146,8 @@ import {
146146
Networks,
147147
Operation,
148148
Asset,
149-
} from "stellar-sdk";
150-
import { Server } from "stellar-sdk/rpc";
149+
} from "@stellar/stellar-sdk";
150+
import { Server } from "@stellar/stellar-sdk/rpc";
151151
import { error } from "@sveltejs/kit";
152152
153153
// We are setting a very high maximum fee, which increases our transaction's

docs/build/apps/example-application-tutorial/querying-data.mdx

Lines changed: 49 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ import {
2222
Networks,
2323
StrKey,
2424
Asset,
25-
} from "stellar-sdk";
26-
import { Server } from "stellar-sdk/rpc";
25+
} from "@stellar/stellar-sdk";
26+
import { Server } from "@stellar/stellar-sdk/rpc";
2727

2828
const rpcUrl = "https://soroban-testnet.stellar.org";
2929
const server = new Server(rpcUrl);
@@ -38,11 +38,11 @@ const server = new Server(rpcUrl);
3838

3939
// We'll import some type definitions that already exists within the
4040
// We'll import some type definitions that already exists within the
41-
// `stellar-sdk` package, so our functions will know what to expect.
42-
/** @typedef {import('stellar-sdk').ServerApi.AccountRecord} AccountRecord */
43-
/** @typedef {import('stellar-sdk').ServerApi.PaymentOperationRecord} PaymentOperationRecord */
44-
/** @typedef {import('stellar-sdk').Transaction} Transaction */
45-
/** @typedef {import('stellar-sdk').ServerApi.PaymentPathRecord} PaymentPathRecord */
41+
// `@stellar/stellar-sdk` package, so our functions will know what to expect.
42+
/** @typedef {import('@stellar/stellar-sdk').ServerApi.AccountRecord} AccountRecord */
43+
/** @typedef {import('@stellar/stellar-sdk').ServerApi.PaymentOperationRecord} PaymentOperationRecord */
44+
/** @typedef {import('@stellar/stellar-sdk').Transaction} Transaction */
45+
/** @typedef {import('@stellar/stellar-sdk').ServerApi.PaymentPathRecord} PaymentPathRecord */
4646
```
4747

4848
**Source:** https://github.com/stellar/basic-payment-app/blob/main/src/lib/stellar/rpcQueries.js
@@ -254,23 +254,37 @@ export async function findStrictSendPaths({
254254
sourceAmount,
255255
destinationPublicKey,
256256
}) {
257-
let asset =
258-
sourceAsset === "native"
259-
? Asset.native()
260-
: new Asset(sourceAsset.split(":")[0], sourceAsset.split(":")[1]);
261-
let response = await server
262-
.strictSendPaths(asset, sourceAmount.toString(), destinationPublicKey)
263-
.call();
264-
if (response.records.length > 0) {
265-
return response.records;
266-
} else {
267-
throw error(400, { message: "no strict send paths available" });
268-
}
257+
// Note: RPC does not provide direct path finding endpoints like Horizon.
258+
// For production applications, consider using:
259+
// 1. External indexing services that provide path finding
260+
// 2. Stellar DEX aggregators
261+
// 3. Build your own path finding using getLedgerEntries to query offers
262+
263+
throw error(501, {
264+
message: "Path finding not directly available in RPC. Consider using external indexing services or DEX aggregators."
265+
});
266+
267+
// Alternative: You could implement basic path finding by querying offers:
268+
// const offers = await server.getLedgerEntries({
269+
// keys: [/* offer keys */]
270+
// });
271+
// // Then process offers to find paths
269272
}
270273
```
271274
272275
**Source:** https://github.com/stellar/basic-payment-app/blob/main/src/lib/stellar/rpcQueries.js
273276
277+
:::note
278+
279+
RPC does not provide direct path finding capabilities like Horizon's `strictSendPaths` and `strictReceivePaths`. For production applications requiring path finding, consider:
280+
281+
- Using external indexing services
282+
- Integrating with DEX aggregators
283+
- Building custom path finding logic using `getLedgerEntries` to query offers
284+
- Using [Hubble](../../../data/analytics/hubble/README.mdx) for DEX analytics
285+
286+
:::
287+
274288
## findStrictReceivePaths
275289
276290
Find the available strict receive paths between a source account and receiving asset/amount.
@@ -292,23 +306,24 @@ export async function findStrictReceivePaths({
292306
destinationAsset,
293307
destinationAmount,
294308
}) {
295-
let asset =
296-
destinationAsset === "native"
297-
? Asset.native()
298-
: new Asset(
299-
destinationAsset.split(":")[0],
300-
destinationAsset.split(":")[1],
301-
);
302-
let response = await server
303-
.strictReceivePaths(sourcePublicKey, asset, destinationAmount.toString())
304-
.call();
305-
if (response.records.length > 0) {
306-
return response.records;
307-
} else {
308-
throw error(400, { message: "no strict receive paths available" });
309-
}
309+
// Note: RPC does not provide direct path finding endpoints like Horizon.
310+
// For production applications, consider using:
311+
// 1. External indexing services that provide path finding
312+
// 2. Stellar DEX aggregators
313+
// 3. Build your own path finding using getLedgerEntries to query offers
314+
315+
throw error(501, {
316+
message: "Path finding not directly available in RPC. Consider using external indexing services or DEX aggregators."
317+
});
318+
319+
// Alternative: You could implement basic path finding by querying offers:
320+
// const offers = await server.getLedgerEntries({
321+
// keys: [/* offer keys */]
322+
// });
323+
// // Then process offers to find paths
310324
}
311325
```
326+
```
312327
313328
**Source:** https://github.com/stellar/basic-payment-app/blob/main/src/lib/stellar/rpcQueries.js
314329

0 commit comments

Comments
 (0)