From 4d4f5b24cccf420d8acf6d5859b02edc82814476 Mon Sep 17 00:00:00 2001 From: Tate Date: Wed, 15 Jan 2025 03:44:40 +0000 Subject: [PATCH 01/10] fix readme.md --- Stellar/soroban-futurenet-starter/README.md | 2 +- Stellar/soroban-greeter-contract/README.md | 2 +- Stellar/soroban-starter/README.md | 2 +- Stellar/soroban-testnet-starter/README.md | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Stellar/soroban-futurenet-starter/README.md b/Stellar/soroban-futurenet-starter/README.md index 2ebec03..ab0943f 100644 --- a/Stellar/soroban-futurenet-starter/README.md +++ b/Stellar/soroban-futurenet-starter/README.md @@ -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). diff --git a/Stellar/soroban-greeter-contract/README.md b/Stellar/soroban-greeter-contract/README.md index b8eadd0..a728179 100644 --- a/Stellar/soroban-greeter-contract/README.md +++ b/Stellar/soroban-greeter-contract/README.md @@ -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). diff --git a/Stellar/soroban-starter/README.md b/Stellar/soroban-starter/README.md index ca91901..f8ffe6b 100644 --- a/Stellar/soroban-starter/README.md +++ b/Stellar/soroban-starter/README.md @@ -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). diff --git a/Stellar/soroban-testnet-starter/README.md b/Stellar/soroban-testnet-starter/README.md index 375516e..a73c3ed 100644 --- a/Stellar/soroban-testnet-starter/README.md +++ b/Stellar/soroban-testnet-starter/README.md @@ -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). From 63830ef41703aa800d7d4d89356b7f4c09d8af58 Mon Sep 17 00:00:00 2001 From: Tate Date: Wed, 15 Jan 2025 03:47:44 +0000 Subject: [PATCH 02/10] fix some bug --- .../soroban-futurenet-starter/package.json | 8 ++--- Stellar/soroban-greeter-contract/package.json | 4 +-- .../src/mappings/mappingHandlers.ts | 4 +-- Stellar/soroban-starter/docker-compose.yml | 1 + Stellar/soroban-starter/package.json | 11 +++--- Stellar/soroban-starter/project.ts | 2 +- .../src/mappings/mappingHandlers.ts | 34 +++++++++---------- Stellar/soroban-testnet-starter/package.json | 4 +-- 8 files changed, 35 insertions(+), 33 deletions(-) diff --git a/Stellar/soroban-futurenet-starter/package.json b/Stellar/soroban-futurenet-starter/package.json index 13b541f..5e6c8ad 100644 --- a/Stellar/soroban-futurenet-starter/package.json +++ b/Stellar/soroban-futurenet-starter/package.json @@ -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" }, @@ -26,8 +26,8 @@ }, "devDependencies": { "@subql/cli": "latest", - "@subql/types": "latest", "@subql/testing": "latest", - "typescript": "latest" + "@subql/types": "latest", + "typescript": "^5.2.2" } } diff --git a/Stellar/soroban-greeter-contract/package.json b/Stellar/soroban-greeter-contract/package.json index 0a84a79..a8f4407 100644 --- a/Stellar/soroban-greeter-contract/package.json +++ b/Stellar/soroban-greeter-contract/package.json @@ -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" }, diff --git a/Stellar/soroban-greeter-contract/src/mappings/mappingHandlers.ts b/Stellar/soroban-greeter-contract/src/mappings/mappingHandlers.ts index eb2489d..52dad9b 100644 --- a/Stellar/soroban-greeter-contract/src/mappings/mappingHandlers.ts +++ b/Stellar/soroban-greeter-contract/src/mappings/mappingHandlers.ts @@ -2,11 +2,11 @@ import { Increment } from "../types"; import { SorobanEvent } from "@subql/types-stellar"; export async function handleEvent(event: SorobanEvent): Promise { - 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(), ), diff --git a/Stellar/soroban-starter/docker-compose.yml b/Stellar/soroban-starter/docker-compose.yml index 31f9912..769eab5 100644 --- a/Stellar/soroban-starter/docker-compose.yml +++ b/Stellar/soroban-starter/docker-compose.yml @@ -35,6 +35,7 @@ services: - ${SUB_COMMAND:-} # set SUB_COMMAND env variable to "test" to run tests - -f=/app - --db-schema=app + - --unsafe - --workers=1 # The more the faster - --batch-size=5 # The higher the faster, set low to avoid rate limit on SDF endpoint healthcheck: diff --git a/Stellar/soroban-starter/package.json b/Stellar/soroban-starter/package.json index ce2a16d..01d3a3b 100644 --- a/Stellar/soroban-starter/package.json +++ b/Stellar/soroban-starter/package.json @@ -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" }, @@ -22,12 +22,13 @@ "license": "MIT", "dependencies": { "@subql/common": "latest", - "@subql/types-stellar": "latest" + "@subql/types-stellar": "latest", + "soroban-client": "^1.0.1" }, "devDependencies": { "@subql/cli": "latest", - "@subql/types": "latest", "@subql/testing": "latest", - "typescript": "latest" + "@subql/types": "latest", + "typescript": "^5.2.2" } } diff --git a/Stellar/soroban-starter/project.ts b/Stellar/soroban-starter/project.ts index a48efa2..6fb3b67 100644 --- a/Stellar/soroban-starter/project.ts +++ b/Stellar/soroban-starter/project.ts @@ -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 = { diff --git a/Stellar/soroban-starter/src/mappings/mappingHandlers.ts b/Stellar/soroban-starter/src/mappings/mappingHandlers.ts index 638a289..8bd330c 100644 --- a/Stellar/soroban-starter/src/mappings/mappingHandlers.ts +++ b/Stellar/soroban-starter/src/mappings/mappingHandlers.ts @@ -7,8 +7,8 @@ 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( @@ -16,8 +16,8 @@ export async function handleOperation( ): Promise { 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, @@ -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()]); } @@ -39,7 +39,7 @@ export async function handleCredit( const account = await checkAndGetAccount( effect.account, - effect.ledger.sequence, + effect.ledger!.sequence ); const credit = Credit.create({ @@ -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()]); } @@ -59,7 +59,7 @@ export async function handleDebit( const account = await checkAndGetAccount( effect.account, - effect.ledger.sequence, + effect.ledger!.sequence ); const debit = Debit.create({ @@ -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 { 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 @@ -93,26 +93,26 @@ export async function handleEvent(event: SorobanEvent): Promise { 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()]); } diff --git a/Stellar/soroban-testnet-starter/package.json b/Stellar/soroban-testnet-starter/package.json index 890a4a7..312a6be 100644 --- a/Stellar/soroban-testnet-starter/package.json +++ b/Stellar/soroban-testnet-starter/package.json @@ -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" }, From 1ec05e97f761734180e705eeb16a1da7ecfd86b8 Mon Sep 17 00:00:00 2001 From: Tate Date: Wed, 12 Feb 2025 01:41:08 +0000 Subject: [PATCH 03/10] remove unsafe flag --- Stellar/soroban-starter/docker-compose.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/Stellar/soroban-starter/docker-compose.yml b/Stellar/soroban-starter/docker-compose.yml index 769eab5..31f9912 100644 --- a/Stellar/soroban-starter/docker-compose.yml +++ b/Stellar/soroban-starter/docker-compose.yml @@ -35,7 +35,6 @@ services: - ${SUB_COMMAND:-} # set SUB_COMMAND env variable to "test" to run tests - -f=/app - --db-schema=app - - --unsafe - --workers=1 # The more the faster - --batch-size=5 # The higher the faster, set low to avoid rate limit on SDF endpoint healthcheck: From 43780a3f115222a11284434339f176fed8fec533 Mon Sep 17 00:00:00 2001 From: Tate Date: Wed, 12 Feb 2025 02:06:53 +0000 Subject: [PATCH 04/10] some change --- Stellar/soroban-greeter-contract/project.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Stellar/soroban-greeter-contract/project.ts b/Stellar/soroban-greeter-contract/project.ts index 7647f28..4e23907 100644 --- a/Stellar/soroban-greeter-contract/project.ts +++ b/Stellar/soroban-greeter-contract/project.ts @@ -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", From ab2e468af1b465c63a9059e64818a10c77f80a54 Mon Sep 17 00:00:00 2001 From: Tate Date: Wed, 12 Feb 2025 02:19:21 +0000 Subject: [PATCH 05/10] fix import --- Stellar/soroban-futurenet-starter/project.ts | 2 +- .../src/mappings/mappingHandlers.ts | 20 +++++++++---------- Stellar/soroban-testnet-starter/project.ts | 2 +- .../src/mappings/mappingHandlers.ts | 20 +++++++++---------- 4 files changed, 22 insertions(+), 22 deletions(-) diff --git a/Stellar/soroban-futurenet-starter/project.ts b/Stellar/soroban-futurenet-starter/project.ts index 3ff275c..034362f 100644 --- a/Stellar/soroban-futurenet-starter/project.ts +++ b/Stellar/soroban-futurenet-starter/project.ts @@ -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", diff --git a/Stellar/soroban-futurenet-starter/src/mappings/mappingHandlers.ts b/Stellar/soroban-futurenet-starter/src/mappings/mappingHandlers.ts index 638a289..ba4456b 100644 --- a/Stellar/soroban-futurenet-starter/src/mappings/mappingHandlers.ts +++ b/Stellar/soroban-futurenet-starter/src/mappings/mappingHandlers.ts @@ -8,11 +8,11 @@ import { AccountCredited, AccountDebited, } from "stellar-sdk/lib/horizon/types/effects"; -import { Horizon } from "stellar-sdk"; +import { Horizon } from "@stellar/stellar-sdk"; import { Address, xdr } from "soroban-client"; export async function handleOperation( - op: StellarOperation, + op: StellarOperation ): Promise { logger.info(`Indexing operation ${op.id}, type: ${op.type}`); @@ -33,13 +33,13 @@ export async function handleOperation( } export async function handleCredit( - effect: StellarEffect, + effect: StellarEffect ): Promise { 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({ @@ -53,13 +53,13 @@ export async function handleCredit( } export async function handleDebit( - effect: StellarEffect, + effect: StellarEffect ): Promise { 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({ @@ -74,7 +74,7 @@ export async function handleDebit( export async function handleEvent(event: SorobanEvent): Promise { 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 @@ -93,11 +93,11 @@ export async function handleEvent(event: SorobanEvent): Promise { 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 @@ -118,7 +118,7 @@ export async function handleEvent(event: SorobanEvent): Promise { async function checkAndGetAccount( id: string, - ledgerSequence: number, + ledgerSequence: number ): Promise { let account = await Account.get(id.toLowerCase()); if (!account) { diff --git a/Stellar/soroban-testnet-starter/project.ts b/Stellar/soroban-testnet-starter/project.ts index 5ff97fb..43e9b7f 100644 --- a/Stellar/soroban-testnet-starter/project.ts +++ b/Stellar/soroban-testnet-starter/project.ts @@ -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 = { diff --git a/Stellar/soroban-testnet-starter/src/mappings/mappingHandlers.ts b/Stellar/soroban-testnet-starter/src/mappings/mappingHandlers.ts index 638a289..ba4456b 100644 --- a/Stellar/soroban-testnet-starter/src/mappings/mappingHandlers.ts +++ b/Stellar/soroban-testnet-starter/src/mappings/mappingHandlers.ts @@ -8,11 +8,11 @@ import { AccountCredited, AccountDebited, } from "stellar-sdk/lib/horizon/types/effects"; -import { Horizon } from "stellar-sdk"; +import { Horizon } from "@stellar/stellar-sdk"; import { Address, xdr } from "soroban-client"; export async function handleOperation( - op: StellarOperation, + op: StellarOperation ): Promise { logger.info(`Indexing operation ${op.id}, type: ${op.type}`); @@ -33,13 +33,13 @@ export async function handleOperation( } export async function handleCredit( - effect: StellarEffect, + effect: StellarEffect ): Promise { 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({ @@ -53,13 +53,13 @@ export async function handleCredit( } export async function handleDebit( - effect: StellarEffect, + effect: StellarEffect ): Promise { 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({ @@ -74,7 +74,7 @@ export async function handleDebit( export async function handleEvent(event: SorobanEvent): Promise { 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 @@ -93,11 +93,11 @@ export async function handleEvent(event: SorobanEvent): Promise { 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 @@ -118,7 +118,7 @@ export async function handleEvent(event: SorobanEvent): Promise { async function checkAndGetAccount( id: string, - ledgerSequence: number, + ledgerSequence: number ): Promise { let account = await Account.get(id.toLowerCase()); if (!account) { From 32448b1f314c60cd96917fc275ebdc0d88f7aecc Mon Sep 17 00:00:00 2001 From: Tate Date: Wed, 12 Feb 2025 02:28:13 +0000 Subject: [PATCH 06/10] fix import --- .../soroban-futurenet-starter/src/mappings/mappingHandlers.ts | 2 +- Stellar/soroban-testnet-starter/src/mappings/mappingHandlers.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Stellar/soroban-futurenet-starter/src/mappings/mappingHandlers.ts b/Stellar/soroban-futurenet-starter/src/mappings/mappingHandlers.ts index ba4456b..ff2483b 100644 --- a/Stellar/soroban-futurenet-starter/src/mappings/mappingHandlers.ts +++ b/Stellar/soroban-futurenet-starter/src/mappings/mappingHandlers.ts @@ -7,7 +7,7 @@ import { import { AccountCredited, AccountDebited, -} from "stellar-sdk/lib/horizon/types/effects"; +} from "@stellar/stellar-sdk/lib/horizon/types/effects"; import { Horizon } from "@stellar/stellar-sdk"; import { Address, xdr } from "soroban-client"; diff --git a/Stellar/soroban-testnet-starter/src/mappings/mappingHandlers.ts b/Stellar/soroban-testnet-starter/src/mappings/mappingHandlers.ts index ba4456b..ff2483b 100644 --- a/Stellar/soroban-testnet-starter/src/mappings/mappingHandlers.ts +++ b/Stellar/soroban-testnet-starter/src/mappings/mappingHandlers.ts @@ -7,7 +7,7 @@ import { import { AccountCredited, AccountDebited, -} from "stellar-sdk/lib/horizon/types/effects"; +} from "@stellar/stellar-sdk/lib/horizon/types/effects"; import { Horizon } from "@stellar/stellar-sdk"; import { Address, xdr } from "soroban-client"; From 916a760c8974108ab60c6f3ad8e213544e1b6824 Mon Sep 17 00:00:00 2001 From: Tate Date: Wed, 12 Feb 2025 02:30:29 +0000 Subject: [PATCH 07/10] fix 'op.ledger' is possibly 'null'. --- .../src/mappings/mappingHandlers.ts | 8 ++++---- .../src/mappings/mappingHandlers.ts | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/Stellar/soroban-futurenet-starter/src/mappings/mappingHandlers.ts b/Stellar/soroban-futurenet-starter/src/mappings/mappingHandlers.ts index ff2483b..5b36716 100644 --- a/Stellar/soroban-futurenet-starter/src/mappings/mappingHandlers.ts +++ b/Stellar/soroban-futurenet-starter/src/mappings/mappingHandlers.ts @@ -16,8 +16,8 @@ export async function handleOperation( ): Promise { 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, @@ -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()]); } diff --git a/Stellar/soroban-testnet-starter/src/mappings/mappingHandlers.ts b/Stellar/soroban-testnet-starter/src/mappings/mappingHandlers.ts index ff2483b..5b36716 100644 --- a/Stellar/soroban-testnet-starter/src/mappings/mappingHandlers.ts +++ b/Stellar/soroban-testnet-starter/src/mappings/mappingHandlers.ts @@ -16,8 +16,8 @@ export async function handleOperation( ): Promise { 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, @@ -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()]); } From 4f767e14f4f36ebe5776e352042ef523fb354239 Mon Sep 17 00:00:00 2001 From: Tate Date: Wed, 12 Feb 2025 02:31:23 +0000 Subject: [PATCH 08/10] fix value is null --- .../src/mappings/mappingHandlers.ts | 8 ++++---- .../src/mappings/mappingHandlers.ts | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/Stellar/soroban-futurenet-starter/src/mappings/mappingHandlers.ts b/Stellar/soroban-futurenet-starter/src/mappings/mappingHandlers.ts index 5b36716..3bcdd51 100644 --- a/Stellar/soroban-futurenet-starter/src/mappings/mappingHandlers.ts +++ b/Stellar/soroban-futurenet-starter/src/mappings/mappingHandlers.ts @@ -39,7 +39,7 @@ export async function handleCredit( const account = await checkAndGetAccount( effect.account, - effect.ledger.sequence + effect.ledger!.sequence ); const credit = Credit.create({ @@ -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()]); } @@ -59,7 +59,7 @@ export async function handleDebit( const account = await checkAndGetAccount( effect.account, - effect.ledger.sequence + effect.ledger!.sequence ); const debit = Debit.create({ @@ -68,7 +68,7 @@ export async function handleDebit( amount: effect.amount, }); - account.lastSeenLedger = effect.ledger.sequence; + account.lastSeenLedger = effect.ledger!.sequence; await Promise.all([account.save(), debit.save()]); } diff --git a/Stellar/soroban-testnet-starter/src/mappings/mappingHandlers.ts b/Stellar/soroban-testnet-starter/src/mappings/mappingHandlers.ts index 5b36716..3bcdd51 100644 --- a/Stellar/soroban-testnet-starter/src/mappings/mappingHandlers.ts +++ b/Stellar/soroban-testnet-starter/src/mappings/mappingHandlers.ts @@ -39,7 +39,7 @@ export async function handleCredit( const account = await checkAndGetAccount( effect.account, - effect.ledger.sequence + effect.ledger!.sequence ); const credit = Credit.create({ @@ -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()]); } @@ -59,7 +59,7 @@ export async function handleDebit( const account = await checkAndGetAccount( effect.account, - effect.ledger.sequence + effect.ledger!.sequence ); const debit = Debit.create({ @@ -68,7 +68,7 @@ export async function handleDebit( amount: effect.amount, }); - account.lastSeenLedger = effect.ledger.sequence; + account.lastSeenLedger = effect.ledger!.sequence; await Promise.all([account.save(), debit.save()]); } From 03df35123c01e4c00d9b38b4ddaac7590c2b9b47 Mon Sep 17 00:00:00 2001 From: Tate Date: Wed, 12 Feb 2025 02:32:50 +0000 Subject: [PATCH 09/10] fix value is null --- .../src/mappings/mappingHandlers.ts | 12 ++++++------ .../src/mappings/mappingHandlers.ts | 12 ++++++------ 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/Stellar/soroban-futurenet-starter/src/mappings/mappingHandlers.ts b/Stellar/soroban-futurenet-starter/src/mappings/mappingHandlers.ts index 3bcdd51..70c9900 100644 --- a/Stellar/soroban-futurenet-starter/src/mappings/mappingHandlers.ts +++ b/Stellar/soroban-futurenet-starter/src/mappings/mappingHandlers.ts @@ -74,7 +74,7 @@ export async function handleDebit( export async function handleEvent(event: SorobanEvent): Promise { 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 @@ -93,17 +93,17 @@ export async function handleEvent(event: SorobanEvent): Promise { 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, @@ -111,8 +111,8 @@ export async function handleEvent(event: SorobanEvent): Promise { value: BigInt(event.value.decoded!), }); - 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()]); } diff --git a/Stellar/soroban-testnet-starter/src/mappings/mappingHandlers.ts b/Stellar/soroban-testnet-starter/src/mappings/mappingHandlers.ts index 3bcdd51..70c9900 100644 --- a/Stellar/soroban-testnet-starter/src/mappings/mappingHandlers.ts +++ b/Stellar/soroban-testnet-starter/src/mappings/mappingHandlers.ts @@ -74,7 +74,7 @@ export async function handleDebit( export async function handleEvent(event: SorobanEvent): Promise { 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 @@ -93,17 +93,17 @@ export async function handleEvent(event: SorobanEvent): Promise { 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, @@ -111,8 +111,8 @@ export async function handleEvent(event: SorobanEvent): Promise { value: BigInt(event.value.decoded!), }); - 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()]); } From efbe2eaca8253a546d8911b4bd4711f588859a3c Mon Sep 17 00:00:00 2001 From: Tate Date: Wed, 12 Feb 2025 02:35:28 +0000 Subject: [PATCH 10/10] fix some --- .../soroban-futurenet-starter/src/mappings/mappingHandlers.ts | 2 +- Stellar/soroban-testnet-starter/src/mappings/mappingHandlers.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Stellar/soroban-futurenet-starter/src/mappings/mappingHandlers.ts b/Stellar/soroban-futurenet-starter/src/mappings/mappingHandlers.ts index 70c9900..93c459d 100644 --- a/Stellar/soroban-futurenet-starter/src/mappings/mappingHandlers.ts +++ b/Stellar/soroban-futurenet-starter/src/mappings/mappingHandlers.ts @@ -108,7 +108,7 @@ export async function handleEvent(event: SorobanEvent): Promise { 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; diff --git a/Stellar/soroban-testnet-starter/src/mappings/mappingHandlers.ts b/Stellar/soroban-testnet-starter/src/mappings/mappingHandlers.ts index 70c9900..93c459d 100644 --- a/Stellar/soroban-testnet-starter/src/mappings/mappingHandlers.ts +++ b/Stellar/soroban-testnet-starter/src/mappings/mappingHandlers.ts @@ -108,7 +108,7 @@ export async function handleEvent(event: SorobanEvent): Promise { 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;