Skip to content

Commit 901954c

Browse files
committed
fixes after review
1 parent 4ddc2d8 commit 901954c

File tree

14 files changed

+2445
-2423
lines changed

14 files changed

+2445
-2423
lines changed

config/config.devnet.yaml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,10 @@ features:
2626
stateChanges:
2727
enabled: false
2828
port: 5675
29-
url: 'amqp://guest:[email protected]:5672'
29+
rabbitUrl: 'amqp://guest:[email protected]:5672'
3030
exchange: 'state_accesses'
31+
queueName: 'api_state_accesses_queue-test'
32+
deadLetterExchange: 'api_state_accesses_queue_dlx'
3133
eventsNotifier:
3234
enabled: false
3335
port: 5674
@@ -194,4 +196,5 @@ compression:
194196
threshold: 1024
195197
chunkSize: 16384
196198
pubSubListener:
197-
enabled: true
199+
enabled: true
200+

src/common/api-config/api.config.service.ts

Lines changed: 25 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -978,12 +978,7 @@ export class ApiConfigService {
978978
}
979979

980980
isStateChangesFeatureActive(): boolean {
981-
const isStateChangesActive = this.configService.get<boolean>('features.stateChanges.enabled');
982-
if (isStateChangesActive === undefined) {
983-
return false;
984-
}
985-
986-
return isStateChangesActive;
981+
return this.configService.get<boolean>('features.stateChanges.enabled') ?? false;
987982
}
988983

989984
getStateChangesFeaturePort(): number {
@@ -995,10 +990,13 @@ export class ApiConfigService {
995990
return stateChangesPort;
996991
}
997992

998-
getStateChangesUrl(): string {
999-
const url = this.configService.get<string>('features.stateChanges.url');
993+
getStateChangesRabbitUrl(): string {
994+
let url = this.configService.get<string>('features.stateChanges.rabbitUrl');
1000995
if (!url) {
1001-
throw new Error('No state changes url present');
996+
url = this.configService.get<string>('features.stateChanges.url');
997+
if (!url) {
998+
throw new Error('No state changes rabbit url present');
999+
}
10021000
}
10031001

10041002
return url;
@@ -1013,6 +1011,24 @@ export class ApiConfigService {
10131011
return exchange;
10141012
}
10151013

1014+
getStateChangesQueueName(): string {
1015+
const queueName = this.configService.get<string>('features.stateChanges.queueName');
1016+
if (!queueName) {
1017+
throw new Error('No state changes queue name present');
1018+
}
1019+
1020+
return queueName;
1021+
}
1022+
1023+
getStateChangesDeadLetterExchange(): string {
1024+
const deadLetterExchange = this.configService.get<string>('features.stateChanges.deadLetterExchange');
1025+
if (!deadLetterExchange) {
1026+
throw new Error('No state changes dead letter exchange present');
1027+
}
1028+
1029+
return deadLetterExchange;
1030+
}
1031+
10161032
isPubSubListenerEnabled(): boolean {
10171033
const isPubSubListenerEnabled = this.configService.get<boolean>('pubSubListener.enabled');
10181034
if (isPubSubListenerEnabled == null) {

src/endpoints/accounts-v2/account.controller.v2.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import { ParseAddressPipe, ParseBoolPipe, ParseIntPipe } from '@multiversx/sdk-n
66
import { DeepHistoryInterceptor } from 'src/interceptors/deep-history.interceptor';
77
import { AccountFetchOptions } from './entities/account.fetch.options';
88
import { NoCache } from '@multiversx/sdk-nestjs-cache';
9+
910
@Controller('')
1011
@ApiTags('accounts')
1112
export class AccountControllerV2 {
Lines changed: 113 additions & 113 deletions
Original file line numberDiff line numberDiff line change
@@ -1,145 +1,145 @@
11
export class AccountChanges {
2-
nonceChanged!: boolean;
3-
balanceChanged!: boolean;
4-
codeHashChanged!: boolean;
5-
rootHashChanged!: boolean;
6-
developerRewardChanged!: boolean;
7-
ownerAddressChanged!: boolean;
8-
userNameChanged!: boolean;
9-
codeMetadataChanged!: boolean;
10-
11-
constructor(init?: Partial<AccountChanges>) {
12-
Object.assign(this, init);
13-
}
2+
nonceChanged!: boolean;
3+
balanceChanged!: boolean;
4+
codeHashChanged!: boolean;
5+
rootHashChanged!: boolean;
6+
developerRewardChanged!: boolean;
7+
ownerAddressChanged!: boolean;
8+
userNameChanged!: boolean;
9+
codeMetadataChanged!: boolean;
10+
11+
constructor(init?: Partial<AccountChanges>) {
12+
Object.assign(this, init);
13+
}
1414
}
1515

1616
export class StateAccessPerAccountRaw {
17-
type!: number;
18-
index!: number;
19-
txHash!: string;
20-
mainTrieKey!: string;
21-
mainTrieVal!: string;
22-
operation!: number;
23-
dataTrieChanges?: DataTrieChange[];
24-
accountChanges?: number;
25-
26-
constructor(init?: Partial<StateAccessPerAccountRaw>) {
27-
Object.assign(this, init);
28-
}
17+
type!: number;
18+
index!: number;
19+
txHash!: string;
20+
mainTrieKey!: string;
21+
mainTrieVal!: string;
22+
operation!: number;
23+
dataTrieChanges?: DataTrieChange[];
24+
accountChanges?: number;
25+
26+
constructor(init?: Partial<StateAccessPerAccountRaw>) {
27+
Object.assign(this, init);
28+
}
2929
}
3030

3131
export class DataTrieChange {
32-
type!: number;
33-
key!: string;
34-
val!: any;
35-
version!: number;
36-
operation!: DataTrieChangeOperation;
32+
type!: number;
33+
key!: string;
34+
val!: any;
35+
version!: number;
36+
operation!: DataTrieChangeOperation;
3737
}
3838

3939
export class BlockWithStateChangesRaw {
40-
hash!: string;
41-
shardID!: number;
42-
nonce!: number;
43-
timestampMs!: number;
44-
stateAccessesPerAccounts!: Record<string, { stateAccess: StateAccessPerAccountRaw[] }>;
45-
46-
constructor(init?: Partial<BlockWithStateChangesRaw>) {
47-
Object.assign(this, init);
48-
}
40+
hash!: string;
41+
shardID!: number;
42+
nonce!: number;
43+
timestampMs!: number;
44+
stateAccessesPerAccounts!: Record<string, { stateAccess: StateAccessPerAccountRaw[] }>;
45+
46+
constructor(init?: Partial<BlockWithStateChangesRaw>) {
47+
Object.assign(this, init);
48+
}
4949
}
5050

5151
export class AccountState {
52-
nonce!: number;
53-
balance!: string;
54-
developerReward!: string;
55-
address!: string;
56-
codeHash?: string;
57-
rootHash!: string;
58-
ownerAddress?: string;
59-
username?: string;
60-
codeMetadata?: string;
61-
62-
constructor(init?: Partial<AccountState>) {
63-
Object.assign(this, init);
64-
}
52+
nonce!: number;
53+
balance!: string;
54+
developerReward!: string;
55+
address!: string;
56+
codeHash?: string;
57+
rootHash!: string;
58+
ownerAddress?: string;
59+
username?: string;
60+
codeMetadata?: string;
61+
62+
constructor(init?: Partial<AccountState>) {
63+
Object.assign(this, init);
64+
}
6565
}
6666

6767
export class EsdtState {
68-
identifier!: string;
69-
nonce!: string;
70-
type!: ESDTType;
71-
value!: string;
72-
propertiesHex!: string;
73-
reservedHex!: string;
74-
tokenMetaData!: any;
75-
76-
constructor(init?: Partial<EsdtState>) {
77-
Object.assign(this, init);
78-
}
68+
identifier!: string;
69+
nonce!: string;
70+
type!: ESDTType;
71+
value!: string;
72+
propertiesHex!: string;
73+
reservedHex!: string;
74+
tokenMetaData!: any;
75+
76+
constructor(init?: Partial<EsdtState>) {
77+
Object.assign(this, init);
78+
}
7979
}
8080

8181
export enum ESDTType {
82-
// 0
83-
Fungible,
84-
// 1
85-
NonFungible,
86-
// 2
87-
NonFungibleV2,
88-
// 3
89-
SemiFungible,
90-
// 4
91-
MetaFungible,
92-
// 5
93-
DynamicNFT,
94-
// 6
95-
DynamicSFT,
96-
// 7
97-
DynamicMeta,
82+
// 0
83+
Fungible,
84+
// 1
85+
NonFungible,
86+
// 2
87+
NonFungibleV2,
88+
// 3
89+
SemiFungible,
90+
// 4
91+
MetaFungible,
92+
// 5
93+
DynamicNFT,
94+
// 6
95+
DynamicSFT,
96+
// 7
97+
DynamicMeta,
9898
}
9999

100100
export class StateChanges {
101-
accountState!: AccountState | undefined;
102-
esdtState!: {
103-
'Fungible': EsdtState[],
104-
'NonFungible': EsdtState[],
105-
'NonFungibleV2': EsdtState[],
106-
'SemiFungible': EsdtState[],
107-
'MetaFungible': EsdtState[],
108-
'DynamicNFT': EsdtState[],
109-
'DynamicSFT': EsdtState[],
110-
'DynamicMeta': EsdtState[],
111-
};
112-
accountChanges!: AccountChanges;
113-
isNewAccount!: boolean;
114-
115-
constructor(init?: Partial<StateChanges>) {
116-
Object.assign(this, init);
117-
}
101+
accountState!: AccountState | undefined;
102+
esdtState!: {
103+
'Fungible': EsdtState[],
104+
'NonFungible': EsdtState[],
105+
'NonFungibleV2': EsdtState[],
106+
'SemiFungible': EsdtState[],
107+
'MetaFungible': EsdtState[],
108+
'DynamicNFT': EsdtState[],
109+
'DynamicSFT': EsdtState[],
110+
'DynamicMeta': EsdtState[],
111+
};
112+
accountChanges!: AccountChanges;
113+
isNewAccount!: boolean;
114+
115+
constructor(init?: Partial<StateChanges>) {
116+
Object.assign(this, init);
117+
}
118118
}
119119

120120
export enum AccountChangesRaw {
121-
NoChange = 0,
122-
NonceChanged = 1 << 0, // 1
123-
BalanceChanged = 1 << 1, // 2
124-
CodeHashChanged = 1 << 2, // 4
125-
RootHashChanged = 1 << 3, // 8
126-
DeveloperRewardChanged = 1 << 4, // 16
127-
OwnerAddressChanged = 1 << 5, // 32
128-
UserNameChanged = 1 << 6, // 64
129-
CodeMetadataChanged = 1 << 7 // 128
121+
NoChange = 0,
122+
NonceChanged = 1 << 0, // 1
123+
BalanceChanged = 1 << 1, // 2
124+
CodeHashChanged = 1 << 2, // 4
125+
RootHashChanged = 1 << 3, // 8
126+
DeveloperRewardChanged = 1 << 4, // 16
127+
OwnerAddressChanged = 1 << 5, // 32
128+
UserNameChanged = 1 << 6, // 64
129+
CodeMetadataChanged = 1 << 7 // 128
130130
}
131131

132132
export enum StateAccessOperation {
133-
NotSet = 0,
134-
GetCode = 1 << 0,
135-
SaveAccount = 1 << 1,
136-
GetAccount = 1 << 2,
137-
WriteCode = 1 << 3,
138-
RemoveDataTrie = 1 << 4,
139-
GetDataTrieValue = 1 << 5,
133+
NotSet = 0,
134+
GetCode = 1 << 0,
135+
SaveAccount = 1 << 1,
136+
GetAccount = 1 << 2,
137+
WriteCode = 1 << 3,
138+
RemoveDataTrie = 1 << 4,
139+
GetDataTrieValue = 1 << 5,
140140
}
141141

142142
export enum DataTrieChangeOperation {
143-
NotDelete = 0,
144-
Delete = 1,
143+
NotDelete = 0,
144+
Delete = 1,
145145
}

0 commit comments

Comments
 (0)