State changes#1532
Conversation
Signed-off-by: GuticaStefan <stefan.gutica@gmail.com>
| imports: [ApiConfigModule], | ||
| inject: [ApiConfigService], | ||
| useFactory: (apiConfigService: ApiConfigService) => ({ | ||
| uri: apiConfigService.getDatabaseUrl().replace(":27017", ''), // TODO: remove this hack |
| import { DeepHistoryInterceptor } from 'src/interceptors/deep-history.interceptor'; | ||
| import { AccountFetchOptions } from './entities/account.fetch.options'; | ||
| import { NoCache } from '@multiversx/sdk-nestjs-cache'; | ||
| @Controller('') |
| const value = parseInt(hexStr, 16); | ||
| return { | ||
| // codeMetadata: hexStr, // TODO: debugging purpose, remove for production | ||
| isGuarded: (value & GUARDED) !== 0, |
|
|
||
| - run: npm ci | ||
| - run: npm run init | ||
| - run: cat src/common/indexer/entities/account.ts |
There was a problem hiding this comment.
this can be removed (only used for debugging)
| chunkSize: 16384 No newline at end of file | ||
| chunkSize: 16384 | ||
| pubSubListener: | ||
| enabled: true No newline at end of file |
There was a problem hiding this comment.
add empty line at the end of the file
| } | ||
|
|
||
| isStateChangesFeatureActive(): boolean { | ||
| const isStateChangesActive = this.configService.get<boolean>('features.stateChanges.enabled'); |
There was a problem hiding this comment.
can be simplified to
return this.configService.get<boolean>('features.stateChanges.enabled') ?? false;
| } | ||
|
|
||
| getStateChangesUrl(): string { | ||
| const url = this.configService.get<string>('features.stateChanges.url'); |
There was a problem hiding this comment.
maybe we should provide a better naming, such as features.stateChanges.rabbitUrl ? add a fallback to features.stateChanges.url as well
| imports: [ApiConfigModule], | ||
| inject: [ApiConfigService], | ||
| useFactory: (apiConfigService: ApiConfigService) => ({ | ||
| uri: apiConfigService.getDatabaseUrl().replace(":27017", ''), // TODO: remove this hack |
There was a problem hiding this comment.
we can keep this TODO for now, tested and working
| @Query('withScrCount', ParseBoolPipe) withScrCount?: boolean, | ||
| @Query('withTimestamp', ParseBoolPipe) withTimestamp?: boolean, | ||
| @Query('withAssets', ParseBoolPipe) withAssets?: boolean, | ||
| @Query('timestamp', ParseIntPipe) _timestamp?: number, |
There was a problem hiding this comment.
we can remove the timestamp parameter if we don't use it
| } | ||
| } | ||
|
|
||
| async getAccountRaw(address: string, withAssets?: boolean): Promise<AccountDetailed | null> { |
There was a problem hiding this comment.
this function seems to duplicate the logic of the "v1" account service. Why don't we import account service v1 and simply call it? or even simpler, in the controller, if we get null or undefined from v2 service, simply call the v1 service
| import { ApiProperty } from "@nestjs/swagger"; | ||
| import { AccountAssets } from "src/common/assets/entities/account.assets"; | ||
|
|
||
| export class Account { |
There was a problem hiding this comment.
all the entities seem to be duplicates of the v1 entities. or are there differences?
|
|
||
| @CompetingRabbitConsumer({ | ||
| exchange: 'state_accesses', | ||
| queueName: 'api_state_accesses_queue-test', |
There was a problem hiding this comment.
is there a way to provide these from config? not sure if the decorator supports variables
| const tokenKey = tokenKeyRaw.toString(); | ||
| const token = tokenKey; | ||
|
|
||
| const indexOfFirstHyphen = token.indexOf(this.separatorChar); |
There was a problem hiding this comment.
this will work differently for sovereign, where we have tokens like SOV-ABC-0011aa. maybe add a TODO
| }) | ||
| async consumeEvents(blockWithStateChanges: BlockWithStateChangesRaw) { | ||
| try { | ||
| if (blockWithStateChanges.shardID === 4294967295) { |
There was a problem hiding this comment.
use api config service -> getMetaChainShardId()
| enabled: false | ||
| port: 5675 | ||
| url: 'amqp://guest:guest@127.0.0.1:5672' | ||
| rabbitUrl: 'amqp://guest:guest@127.0.0.1:5672' |
There was a problem hiding this comment.
adapt the other config files as well (mainnet, testnet, etc)
f6e2d70 to
91ea6a0
Compare
No description provided.