Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ Have a look at `environments.toml` for more fined-grained control.
npm run dev
```

Open the server URL in your web browser.
Open the server URL in your web browser.

4. For testnet/mainnet deployment:

Expand Down
1,589 changes: 753 additions & 836 deletions package-lock.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
},
"devDependencies": {
"@eslint/js": "^9.36.0",
"@types/lodash": "^4.17.20",
"@types/react": "^19.1.16",
"@types/react-dom": "^19.1.9",
"@types/react-router-dom": "^5.3.3",
Expand Down
23 changes: 23 additions & 0 deletions src/contracts/guess_the_number.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
// This is a stub file for the GuessTheNumber contract client.
// The actual contract client is generated at runtime by the Scaffold Stellar CLI.
// This stub allows the build to succeed when the contract hasn't been generated yet.

type Result<T, E> = {
isOk: () => boolean;
isErr: () => boolean;
unwrap: () => T;
unwrapErr: () => E;
};

const game = {
guess: async (_args: {
a_number: bigint;
guesser: string;
}): Promise<{ result: Result<boolean, unknown> }> => {
throw new Error(
"Contract client not initialized. Run 'stellar scaffold watch --build-clients' to generate contract clients.",
);
},
};

export default game;
3 changes: 3 additions & 0 deletions src/debug/components/PrettyJson.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,7 @@ export const PrettyJson = ({
if (v === null) {
return (
<div
// eslint-disable-next-line react-x/no-array-index-key -- No stable ID available for JSON values
key={`${keyProp}-${index}`}
style={styles.nested}
>
Expand All @@ -293,6 +294,7 @@ export const PrettyJson = ({
if (Array.isArray(v)) {
return (
<Collapsible
// eslint-disable-next-line react-x/no-array-index-key -- No stable ID available for JSON values
key={`${keyProp}-${index}`}
itemList={Object.keys(v)}
char="["
Expand All @@ -305,6 +307,7 @@ export const PrettyJson = ({
}
return (
<Collapsible
// eslint-disable-next-line react-x/no-array-index-key -- No stable ID available for JSON values
key={`${keyProp}-${index}`}
itemList={Object.keys(v as AnyObject)}
char="{"
Expand Down
1 change: 1 addition & 0 deletions src/debug/components/RenderOneOf.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ export const renderOneOf = ({
<option
id={oneOf?.title}
value={oneOf?.title}
// eslint-disable-next-line react-x/no-array-index-key -- Schema items may have duplicate titles
key={`${oneOf?.title}-${index}`}
>
{oneOf?.title}
Expand Down
1 change: 0 additions & 1 deletion src/debug/components/RenderPrimitivesType.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* eslint-disable react-x/jsx-key-before-spread */
import React from "react";
import { Badge, Icon, Input, Select, Text } from "@stellar/design-system";
import type { JSONSchema7 } from "json-schema";
Expand Down
5 changes: 1 addition & 4 deletions src/debug/util/getWasmContractData.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
/* eslint-disable @typescript-eslint/no-unsafe-member-access */
/* eslint-disable @typescript-eslint/no-unsafe-call */
/* eslint-disable @typescript-eslint/no-unsafe-assignment */
/* eslint-disable @typescript-eslint/no-unused-vars */
import * as StellarXdr from "./StellarXdr";
import { prettifyJsonString } from "./prettifyJsonString";
Expand All @@ -12,7 +9,7 @@ import {

export const getWasmContractData = async (wasmBytes: Buffer) => {
try {
const mod = await WebAssembly.compile(wasmBytes);
const mod = await WebAssembly.compile(wasmBytes as BufferSource);

const result: Record<ContractSectionName, ContractData> = {
contractmetav0: {},
Expand Down
2 changes: 1 addition & 1 deletion src/debug/util/loadContractMetada.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ const loadWasmBinary = async (wasmHash: string) => {

export const getWasmContractData = async (wasmBytes: Buffer) => {
try {
const mod = await WebAssembly.compile(wasmBytes);
const mod = await WebAssembly.compile(wasmBytes as BufferSource);
const result: Record<ContractSectionName, ContractData> = {
contractmetav0: {},
contractenvmetav0: {},
Expand Down
51 changes: 34 additions & 17 deletions src/hooks/useSubscription.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,26 +49,41 @@ export function useSubscription(
paging[id].lastLedgerStart = latestLedgerState.sequence;
}

const response = await server.getEvents({
startLedger: !paging[id].pagingToken
? paging[id].lastLedgerStart
: undefined,
cursor: paging[id].pagingToken,
filters: [
{
contractIds: [contractId],
topics: [[xdr.ScVal.scvSymbol(topic).toXDR("base64")]],
type: "contract",
},
],
limit: 10,
});
// lastLedgerStart is now guaranteed to be a number
const lastLedger = paging[id].lastLedgerStart;

const response = await server.getEvents(
paging[id].pagingToken
? {
cursor: paging[id].pagingToken,
filters: [
{
contractIds: [contractId],
topics: [[xdr.ScVal.scvSymbol(topic).toXDR("base64")]],
type: "contract",
},
],
limit: 10,
}
: {
startLedger: lastLedger,
endLedger: lastLedger + 100,
filters: [
{
contractIds: [contractId],
topics: [[xdr.ScVal.scvSymbol(topic).toXDR("base64")]],
type: "contract",
},
],
limit: 10,
},
);

paging[id].pagingToken = undefined;
if (response.latestLedger) {
paging[id].lastLedgerStart = response.latestLedger;
}
if (response.events) {
if (response.events && response.events.length > 0) {
response.events.forEach((event) => {
try {
onEvent(event);
Expand All @@ -77,10 +92,12 @@ export function useSubscription(
"Poll Events: subscription callback had error: ",
error,
);
} finally {
paging[id].pagingToken = event.pagingToken;
}
});
// Store the cursor from the response for pagination
if (response.cursor) {
paging[id].pagingToken = response.cursor;
}
}
} catch (error) {
console.error("Poll Events: error: ", error);
Expand Down
2 changes: 1 addition & 1 deletion src/pages/Debugger.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ const Debugger: React.FC = () => {
setSelectedContract(contractName);
} else if (!contractName) {
// Redirect to the first contract if no contractName in URL
navigate(`/debug/${contractKeys[0]}`, { replace: true });
void navigate(`/debug/${contractKeys[0]}`, { replace: true });
} else {
setSelectedContract(contractKeys[0]);
}
Expand Down