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 Stellar/soroban-futurenet-starter/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ The simplest way to run your project is by running `yarn dev` or `npm run-script

1. `yarn codegen` - Generates types from the GraphQL schema definition and contract ABIs and saves them in the `/src/types` directory. This must be done after each change to the `schema.graphql` file or the contract ABIs
2. `yarn build` - Builds and packages the SubQuery project into the `/dist` directory
3. `docker-compose pull && docker-compose up` - Runs a Docker container with an indexer, PostgeSQL DB, and a query service. This requires [Docker to be installed](https://docs.docker.com/engine/install) and running locally. The configuration for this container is set from your `docker-compose.yml`
3. `docker compose pull && docker compose up` - Runs a Docker container with an indexer, PostgeSQL DB, and a query service. This requires [Docker to be installed](https://docs.docker.com/engine/install) and running locally. The configuration for this container is set from your `docker-compose.yml`

You can observe the three services start, and once all are running (it may take a few minutes on your first start), please open your browser and head to [http://localhost:3000](http://localhost:3000) - you should see a GraphQL playground showing with the schemas ready to query. [Read the docs for more information](https://academy.subquery.network/run_publish/run.html) or [explore the possible service configuration for running SubQuery](https://academy.subquery.network/run_publish/references.html).

Expand Down
8 changes: 4 additions & 4 deletions Stellar/soroban-futurenet-starter/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
"scripts": {
"build": "subql build",
"codegen": "subql codegen",
"start:docker": "docker-compose pull && docker-compose up --remove-orphans",
"dev": "subql codegen && subql build && docker-compose pull && docker-compose up --remove-orphans",
"start:docker": "docker compose pull && docker compose up --remove-orphans",
"dev": "subql codegen && subql build && docker compose pull && docker compose up --remove-orphans",
"prepack": "rm -rf dist && npm run build",
"test": "subql build && subql-node-stellar test"
},
Expand All @@ -26,8 +26,8 @@
},
"devDependencies": {
"@subql/cli": "latest",
"@subql/types": "latest",
"@subql/testing": "latest",
"typescript": "latest"
"@subql/types": "latest",
"typescript": "^5.2.2"
}
}
2 changes: 1 addition & 1 deletion Stellar/soroban-futurenet-starter/project.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import {
StellarHandlerKind,
StellarProject,
} from "@subql/types-stellar";
import { Horizon } from "stellar-sdk";
import { Horizon } from "@stellar/stellar-sdk";
const project: StellarProject = {
specVersion: "1.0.0",
name: "soroban-futurenet-starter",
Expand Down
42 changes: 21 additions & 21 deletions Stellar/soroban-futurenet-starter/src/mappings/mappingHandlers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,17 @@ import {
import {
AccountCredited,
AccountDebited,
} from "stellar-sdk/lib/horizon/types/effects";
import { Horizon } from "stellar-sdk";
} from "@stellar/stellar-sdk/lib/horizon/types/effects";
import { Horizon } from "@stellar/stellar-sdk";
import { Address, xdr } from "soroban-client";

export async function handleOperation(
op: StellarOperation<Horizon.HorizonApi.PaymentOperationResponse>,
op: StellarOperation<Horizon.HorizonApi.PaymentOperationResponse>
): Promise<void> {
logger.info(`Indexing operation ${op.id}, type: ${op.type}`);

const fromAccount = await checkAndGetAccount(op.from, op.ledger.sequence);
const toAccount = await checkAndGetAccount(op.to, op.ledger.sequence);
const fromAccount = await checkAndGetAccount(op.from, op.ledger!.sequence);
const toAccount = await checkAndGetAccount(op.to, op.ledger!.sequence);

const payment = Payment.create({
id: op.id,
Expand All @@ -27,19 +27,19 @@ export async function handleOperation(
amount: op.amount,
});

fromAccount.lastSeenLedger = op.ledger.sequence;
toAccount.lastSeenLedger = op.ledger.sequence;
fromAccount.lastSeenLedger = op.ledger!.sequence;
toAccount.lastSeenLedger = op.ledger!.sequence;
await Promise.all([fromAccount.save(), toAccount.save(), payment.save()]);
}

export async function handleCredit(
effect: StellarEffect<AccountCredited>,
effect: StellarEffect<AccountCredited>
): Promise<void> {
logger.info(`Indexing effect ${effect.id}, type: ${effect.type}`);

const account = await checkAndGetAccount(
effect.account,
effect.ledger.sequence,
effect.ledger!.sequence
);

const credit = Credit.create({
Expand All @@ -48,18 +48,18 @@ export async function handleCredit(
amount: effect.amount,
});

account.lastSeenLedger = effect.ledger.sequence;
account.lastSeenLedger = effect.ledger!.sequence;
await Promise.all([account.save(), credit.save()]);
}

export async function handleDebit(
effect: StellarEffect<AccountDebited>,
effect: StellarEffect<AccountDebited>
): Promise<void> {
logger.info(`Indexing effect ${effect.id}, type: ${effect.type}`);

const account = await checkAndGetAccount(
effect.account,
effect.ledger.sequence,
effect.ledger!.sequence
);

const debit = Debit.create({
Expand All @@ -68,13 +68,13 @@ export async function handleDebit(
amount: effect.amount,
});

account.lastSeenLedger = effect.ledger.sequence;
account.lastSeenLedger = effect.ledger!.sequence;
await Promise.all([account.save(), debit.save()]);
}

export async function handleEvent(event: SorobanEvent): Promise<void> {
logger.info(
`New transfer event found at block ${event.ledger.sequence.toString()}`,
`New transfer event found at block ${event.ledger!.sequence.toString()}`
);

// Get data from the event
Expand All @@ -93,32 +93,32 @@ export async function handleEvent(event: SorobanEvent): Promise<void> {

const fromAccount = await checkAndGetAccount(
decodeAddress(from),
event.ledger.sequence,
event.ledger!.sequence
);
const toAccount = await checkAndGetAccount(
decodeAddress(to),
event.ledger.sequence,
event.ledger!.sequence
);

// Create the new transfer entity
const transfer = Transfer.create({
id: event.id,
ledger: event.ledger.sequence,
ledger: event.ledger!.sequence,
date: new Date(event.ledgerClosedAt),
contract: event.contractId?.contractId().toString()!,
fromId: fromAccount.id,
toId: toAccount.id,
value: BigInt(event.value.decoded!),
value: BigInt(event.value.i64().toString()),
});

fromAccount.lastSeenLedger = event.ledger.sequence;
toAccount.lastSeenLedger = event.ledger.sequence;
fromAccount.lastSeenLedger = event.ledger!.sequence;
toAccount.lastSeenLedger = event.ledger!.sequence;
await Promise.all([fromAccount.save(), toAccount.save(), transfer.save()]);
}

async function checkAndGetAccount(
id: string,
ledgerSequence: number,
ledgerSequence: number
): Promise<Account> {
let account = await Account.get(id.toLowerCase());
if (!account) {
Expand Down
2 changes: 1 addition & 1 deletion Stellar/soroban-greeter-contract/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ The simplest way to run your project is by running `yarn dev` or `npm run-script

1. `yarn codegen` - Generates types from the GraphQL schema definition and contract ABIs and saves them in the `/src/types` directory. This must be done after each change to the `schema.graphql` file or the contract ABIs
2. `yarn build` - Builds and packages the SubQuery project into the `/dist` directory
3. `docker-compose pull && docker-compose up` - Runs a Docker container with an indexer, PostgeSQL DB, and a query service. This requires [Docker to be installed](https://docs.docker.com/engine/install) and running locally. The configuration for this container is set from your `docker-compose.yml`
3. `docker compose pull && docker compose up` - Runs a Docker container with an indexer, PostgeSQL DB, and a query service. This requires [Docker to be installed](https://docs.docker.com/engine/install) and running locally. The configuration for this container is set from your `docker-compose.yml`

You can observe the three services start, and once all are running (it may take a few minutes on your first start), please open your browser and head to [http://localhost:3000](http://localhost:3000) - you should see a GraphQL playground showing with the schemas ready to query. [Read the docs for more information](https://academy.subquery.network/run_publish/run.html) or [explore the possible service configuration for running SubQuery](https://academy.subquery.network/run_publish/references.html).

Expand Down
4 changes: 2 additions & 2 deletions Stellar/soroban-greeter-contract/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
"scripts": {
"build": "subql build",
"codegen": "subql codegen",
"start:docker": "docker-compose pull && docker-compose up --remove-orphans",
"dev": "subql codegen && subql build && docker-compose pull && docker-compose up --remove-orphans",
"start:docker": "docker compose pull && docker compose up --remove-orphans",
"dev": "subql codegen && subql build && docker compose pull && docker compose up --remove-orphans",
"prepack": "rm -rf dist && npm run build",
"test": "subql build && subql-node-stellar test"
},
Expand Down
2 changes: 1 addition & 1 deletion Stellar/soroban-greeter-contract/project.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import {
StellarHandlerKind,
StellarProject,
} from "@subql/types-stellar";
import { Horizon } from "stellar-sdk";

const project: StellarProject = {
specVersion: "1.0.0",
name: "soroban-futurenet-starter",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ import { Increment } from "../types";
import { SorobanEvent } from "@subql/types-stellar";

export async function handleEvent(event: SorobanEvent): Promise<void> {
logger.info(`Transaction hash: ${event.transaction.hash.toString()}`);
logger.info(`Transaction hash: ${event.transaction!.hash.toString()}`);
if (event.type.toString() == "contract") {
logger.info(`Event value: ${JSON.stringify(event.value)}`);
const increment = Increment.create({
id: event.transaction.hash,
id: event.transaction!.hash,
newValue: BigInt(
JSON.parse(JSON.stringify(event.value))["_value"].toString(),
),
Expand Down
2 changes: 1 addition & 1 deletion Stellar/soroban-starter/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ The simplest way to run your project is by running `yarn dev` or `npm run-script

1. `yarn codegen` - Generates types from the GraphQL schema definition and contract ABIs and saves them in the `/src/types` directory. This must be done after each change to the `schema.graphql` file or the contract ABIs
2. `yarn build` - Builds and packages the SubQuery project into the `/dist` directory
3. `docker-compose pull && docker-compose up` - Runs a Docker container with an indexer, PostgeSQL DB, and a query service. This requires [Docker to be installed](https://docs.docker.com/engine/install) and running locally. The configuration for this container is set from your `docker-compose.yml`
3. `docker compose pull && docker compose up` - Runs a Docker container with an indexer, PostgeSQL DB, and a query service. This requires [Docker to be installed](https://docs.docker.com/engine/install) and running locally. The configuration for this container is set from your `docker-compose.yml`

You can observe the three services start, and once all are running (it may take a few minutes on your first start), please open your browser and head to [http://localhost:3000](http://localhost:3000) - you should see a GraphQL playground showing with the schemas ready to query. [Read the docs for more information](https://academy.subquery.network/run_publish/run.html) or [explore the possible service configuration for running SubQuery](https://academy.subquery.network/run_publish/references.html).

Expand Down
11 changes: 6 additions & 5 deletions Stellar/soroban-starter/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
"scripts": {
"build": "subql build",
"codegen": "subql codegen",
"start:docker": "docker-compose pull && docker-compose up --remove-orphans",
"dev": "subql codegen && subql build && docker-compose pull && docker-compose up --remove-orphans",
"start:docker": "docker compose pull && docker compose up --remove-orphans",
"dev": "subql codegen && subql build && docker compose pull && docker compose up --remove-orphans",
"prepack": "rm -rf dist && npm run build",
"test": "subql build && subql-node-stellar test"
},
Expand All @@ -22,12 +22,13 @@
"license": "MIT",
"dependencies": {
"@subql/common": "latest",
"@subql/types-stellar": "latest"
"@subql/types-stellar": "latest",
"soroban-client": "^1.0.1"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Soroban-client is deprecated. This should be under @stellar/stellar-sdk

},
"devDependencies": {
"@subql/cli": "latest",
"@subql/types": "latest",
"@subql/testing": "latest",
"typescript": "latest"
"@subql/types": "latest",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This can be removed, this is substrate types. The same applies to all starters

"typescript": "^5.2.2"
}
}
2 changes: 1 addition & 1 deletion Stellar/soroban-starter/project.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import {
StellarHandlerKind,
StellarProject,
} from "@subql/types-stellar";
import { Horizon } from "stellar-sdk";
import { Horizon } from "@stellar/stellar-sdk";

/* This is your project configuration */
const project: StellarProject = {
Expand Down
34 changes: 17 additions & 17 deletions Stellar/soroban-starter/src/mappings/mappingHandlers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,17 @@ import {
import {
AccountCredited,
AccountDebited,
} from "stellar-sdk/lib/horizon/types/effects";
import { Horizon } from "stellar-sdk";
} from "@stellar/stellar-sdk/lib/horizon/types/effects";
import { Horizon } from "@stellar/stellar-sdk";
import { Address, xdr } from "soroban-client";

export async function handleOperation(
op: StellarOperation<Horizon.HorizonApi.PaymentOperationResponse>,
): Promise<void> {
logger.info(`Indexing operation ${op.id}, type: ${op.type}`);

const fromAccount = await checkAndGetAccount(op.from, op.ledger.sequence);
const toAccount = await checkAndGetAccount(op.to, op.ledger.sequence);
const fromAccount = await checkAndGetAccount(op.from, op.ledger!.sequence);
const toAccount = await checkAndGetAccount(op.to, op.ledger!.sequence);

const payment = Payment.create({
id: op.id,
Expand All @@ -27,8 +27,8 @@ export async function handleOperation(
amount: op.amount,
});

fromAccount.lastSeenLedger = op.ledger.sequence;
toAccount.lastSeenLedger = op.ledger.sequence;
fromAccount.lastSeenLedger = op.ledger!.sequence;
toAccount.lastSeenLedger = op.ledger!.sequence;
await Promise.all([fromAccount.save(), toAccount.save(), payment.save()]);
}

Expand All @@ -39,7 +39,7 @@ export async function handleCredit(

const account = await checkAndGetAccount(
effect.account,
effect.ledger.sequence,
effect.ledger!.sequence
);

const credit = Credit.create({
Expand All @@ -48,7 +48,7 @@ export async function handleCredit(
amount: effect.amount,
});

account.lastSeenLedger = effect.ledger.sequence;
account.lastSeenLedger = effect.ledger!.sequence;
await Promise.all([account.save(), credit.save()]);
}

Expand All @@ -59,7 +59,7 @@ export async function handleDebit(

const account = await checkAndGetAccount(
effect.account,
effect.ledger.sequence,
effect.ledger!.sequence
);

const debit = Debit.create({
Expand All @@ -68,13 +68,13 @@ export async function handleDebit(
amount: effect.amount,
});

account.lastSeenLedger = effect.ledger.sequence;
account.lastSeenLedger = effect.ledger!.sequence;
await Promise.all([account.save(), debit.save()]);
}

export async function handleEvent(event: SorobanEvent): Promise<void> {
logger.info(
`New transfer event found at block ${event.ledger.sequence.toString()}`,
`New transfer event found at block ${event.ledger!.sequence.toString()}`
);

// Get data from the event
Expand All @@ -93,26 +93,26 @@ export async function handleEvent(event: SorobanEvent): Promise<void> {

const fromAccount = await checkAndGetAccount(
decodeAddress(from),
event.ledger.sequence,
event.ledger!.sequence
);
const toAccount = await checkAndGetAccount(
decodeAddress(to),
event.ledger.sequence,
event.ledger!.sequence
);

// Create the new transfer entity
const transfer = Transfer.create({
id: event.id,
ledger: event.ledger.sequence,
ledger: event.ledger!.sequence,
date: new Date(event.ledgerClosedAt),
contract: event.contractId?.contractId().toString()!,
fromId: fromAccount.id,
toId: toAccount.id,
value: BigInt(event.value.decoded!),
value: BigInt(event.value.i64().toString()),
});

fromAccount.lastSeenLedger = event.ledger.sequence;
toAccount.lastSeenLedger = event.ledger.sequence;
fromAccount.lastSeenLedger = event.ledger!.sequence;
toAccount.lastSeenLedger = event.ledger!.sequence;
await Promise.all([fromAccount.save(), toAccount.save(), transfer.save()]);
}

Expand Down
2 changes: 1 addition & 1 deletion Stellar/soroban-testnet-starter/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ The simplest way to run your project is by running `yarn dev` or `npm run-script

1. `yarn codegen` - Generates types from the GraphQL schema definition and contract ABIs and saves them in the `/src/types` directory. This must be done after each change to the `schema.graphql` file or the contract ABIs
2. `yarn build` - Builds and packages the SubQuery project into the `/dist` directory
3. `docker-compose pull && docker-compose up` - Runs a Docker container with an indexer, PostgeSQL DB, and a query service. This requires [Docker to be installed](https://docs.docker.com/engine/install) and running locally. The configuration for this container is set from your `docker-compose.yml`
3. `docker compose pull && docker compose up` - Runs a Docker container with an indexer, PostgeSQL DB, and a query service. This requires [Docker to be installed](https://docs.docker.com/engine/install) and running locally. The configuration for this container is set from your `docker-compose.yml`

You can observe the three services start, and once all are running (it may take a few minutes on your first start), please open your browser and head to [http://localhost:3000](http://localhost:3000) - you should see a GraphQL playground showing with the schemas ready to query. [Read the docs for more information](https://academy.subquery.network/run_publish/run.html) or [explore the possible service configuration for running SubQuery](https://academy.subquery.network/run_publish/references.html).

Expand Down
4 changes: 2 additions & 2 deletions Stellar/soroban-testnet-starter/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
"scripts": {
"build": "subql build",
"codegen": "subql codegen",
"start:docker": "docker-compose pull && docker-compose up --remove-orphans",
"dev": "subql codegen && subql build && docker-compose pull && docker-compose up --remove-orphans",
"start:docker": "docker compose pull && docker compose up --remove-orphans",
"dev": "subql codegen && subql build && docker compose pull && docker compose up --remove-orphans",
"prepack": "rm -rf dist && npm run build",
"test": "subql build && subql-node-stellar test"
},
Expand Down
2 changes: 1 addition & 1 deletion Stellar/soroban-testnet-starter/project.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import {
StellarHandlerKind,
StellarProject,
} from "@subql/types-stellar";
import { Horizon } from "stellar-sdk";
import { Horizon } from "@stellar/stellar-sdk";

/* This is your project configuration */
const project: StellarProject = {
Expand Down
Loading