Skip to content

Commit

Permalink
Merge branch 'development' into SERVICES-1785-transactions-relayed-v-…
Browse files Browse the repository at this point in the history
…2-filter
  • Loading branch information
cfaur09 committed Oct 26, 2023
2 parents 6c2627a + b49d38b commit 277369e
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 8 deletions.
7 changes: 4 additions & 3 deletions src/common/graphql/graphql.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,14 @@ export class GraphQlService {
private readonly apiConfigService: ApiConfigService
) { }

async getData(query: string, variables: any): Promise<any> {
async getData(query: string, variables?: any): Promise<any> {
const MAIAR_EXCHANGE_URL = this.apiConfigService.getExchangeServiceUrlMandatory();

const graphqlClient = new GraphQLClient(MAIAR_EXCHANGE_URL);

try {
const data = await graphqlClient.request(query, variables);
const data = variables
? await graphqlClient.request(query, variables)
: await graphqlClient.request(query);

if (!data) {
return null;
Expand Down
2 changes: 2 additions & 0 deletions src/common/indexer/entities/sc.deploy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ export interface ScDeploy {
address: string;
contract: string;
deployTxHash: string;
initialCodeHash: string;
deployer: string;
timestamp: number;
upgrades: ScDeployUpgrade[];
Expand All @@ -10,5 +11,6 @@ export interface ScDeploy {
export interface ScDeployUpgrade {
upgrader: string;
upgradeTxHash: string;
codeHash: string;
timestamp: number;
}
1 change: 1 addition & 0 deletions src/endpoints/accounts/account.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -585,6 +585,7 @@ export class AccountService {
const upgrades = details.upgrades.map(item => ApiUtils.mergeObjects(new ContractUpgrades(), {
address: item.upgrader,
txHash: item.upgradeTxHash,
codeHash: item.codeHash,
timestamp: item.timestamp,
})).sortedDescending(item => item.timestamp);

Expand Down
4 changes: 4 additions & 0 deletions src/endpoints/accounts/entities/contract.upgrades.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ export class ContractUpgrades {
@ApiProperty({ type: String, nullable: true, example: '1c8c6b2148f25621fa2c798a2c9a184df61fdd1991aa0af7ea01eb7b89025d2a' })
txHash: string = '';

@Field(() => String, { description: 'CodeHash details.' })
@ApiProperty({ type: String, nullable: true, example: '1c8c6b2148f25621fa2c798a2c9a184df61fdd1991aa0af7ea01eb7b89025d2a' })
codeHash: string = '';

@Field(() => Float, { description: 'Timestamp details.' })
@ApiProperty({ type: Number, nullable: true, example: '1638577452' })
timestamp: number = 0;
Expand Down
12 changes: 11 additions & 1 deletion src/endpoints/mex/mex.pair.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,19 @@ export class MexPairService {
throw new BadRequestException('Could not fetch MEX settings');
}

const pairsLimit = gql`
query PairCount {
factory {
pairCount
}
}`;

const pairsLimitResult: any = await this.graphQlService.getData(pairsLimit);
const totalPairs = pairsLimitResult?.factory?.pairCount;

const variables = {
"offset": 0,
"pairsLimit": 100,
"pairsLimit": totalPairs,
};

const query = gql`
Expand Down
20 changes: 16 additions & 4 deletions src/test/integration/services/accounts.e2e-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -376,7 +376,7 @@ describe('Account Service', () => {
const address = 'erd1qqqqqqqqqqqqqpgqa0fsfshnff4n76jhcye6k7uvd7qacsq42jpsp6shh2';

jest.spyOn(indexerService, 'getScDeploy').mockResolvedValue(
Promise.resolve({ deployTxHash: '', address: address, contract: address, deployer: address, timestamp: 1620000000, upgrades: [] }));
Promise.resolve({ deployTxHash: '', address: address, contract: address, initialCodeHash: '', deployer: address, timestamp: 1620000000, upgrades: [] }));

const result = await service.getAccountDeployedAtRaw(address);

Expand All @@ -390,7 +390,7 @@ describe('Account Service', () => {
const timestamp = 1620000000;

jest.spyOn(indexerService, 'getScDeploy').mockResolvedValue(
Promise.resolve({ deployTxHash: txHash, address: address, contract: address, deployer: address, timestamp: 1620000000, upgrades: [] }));
Promise.resolve({ deployTxHash: txHash, address: address, contract: address, initialCodeHash: 'kUVJtdwvHG2sCTi9l2uneSONUVonWfgHCK69gdB+52o=', deployer: address, timestamp: 1620000000, upgrades: [] }));

jest.spyOn(indexerService, 'getTransaction').mockResolvedValue({
hash: 'ca7acccc20a07695ba5657aac9c6e97b50fdcc9a77763447b9003721812271c7',
Expand Down Expand Up @@ -433,7 +433,7 @@ describe('Account Service', () => {
const txHash = "invalid-tx";

jest.spyOn(indexerService, 'getScDeploy').mockResolvedValue(
Promise.resolve({ deployTxHash: txHash, address: address, contract: address, deployer: address, timestamp: 1620000000, upgrades: [] }));
Promise.resolve({ deployTxHash: txHash, address: address, contract: address, initialCodeHash: '', deployer: address, timestamp: 1620000000, upgrades: [] }));
jest.spyOn(indexerService, 'getTransaction').mockResolvedValue(null);

const result = await service.getAccountDeployedAtRaw(address);
Expand Down Expand Up @@ -462,6 +462,7 @@ describe('Account Service', () => {
describe('getAccountDeployedTxHashRaw', () => {
const address = 'erd1qga7ze0l03chfgru0a32wxqf2226nzrxnyhzer9lmudqhjgy7ycqjjyknz';
const txHash = 'ca7acccc20a07695ba5657aac9c6e97b50fdcc9a77763447b9003721812271c7';
const initialCodeHash = 'kUVJtdwvHG2sCTi9l2uneSONUVonWfgHCK69gdB+52o=';

it('should return null if no scDeploy is found', async () => {
jest.spyOn(indexerService, 'getScDeploy').mockResolvedValue(undefined);
Expand All @@ -476,7 +477,7 @@ describe('Account Service', () => {
jest.spyOn(indexerService, 'getScDeploy').mockResolvedValue(
Promise.resolve({
deployTxHash: txHash,
address: address, contract: address, deployer: address, timestamp: 1620000000, upgrades: [],
address: address, contract: address, initialCodeHash: initialCodeHash, deployer: address, timestamp: 1620000000, upgrades: [],
}));

const result = await service.getAccountDeployedTxHashRaw(address);
Expand Down Expand Up @@ -668,26 +669,31 @@ describe('Account Service', () => {
address: 'erd1qqqqqqqqqqqqqpgqeel2kumf0r8ffyhth7pqdujjat9nx0862jpsg2pqaq',
deployTxHash: '32be840b215a7343ca7c0cbd35c517fd2c04aba22e4465ee1146d59dc7359cd3',
deployer: 'erd1qqqqqqqqqqqqqpgqq66xk9gfr4esuhem3jru86wg5hvp33a62jps2fy57p',
initialCodeHash: 'kUVJtdwvHG2sCTi9l2uneSONUVonWfgHCK69gdB',
timestamp: 1636895604,
contract: 'erd1qqqqqqqqqqqqqpgqeel2kumf0r8ffyhth7pqdujjat9nx0862jpsg2pqaq',
upgrades: [
{
upgrader: 'erd1qqqqqqqqqqqqqpgqq66xk9gfr4esuhem3jru86wg5hvp33a62jps2fy57p',
codeHash: 'WFdobEwmytuddWRc8yVm0Pm1AMwoES5n4yQ0WRjtG2g=',
upgradeTxHash: '1c8c6b2148f25621fa2c798a2c9a184df61fdd1991aa0af7ea01eb7b89025d2a',
timestamp: 1638577452,
},
{
upgrader: 'erd1qqqqqqqqqqqqqpgqq66xk9gfr4esuhem3jru86wg5hvp33a62jps2fy57p',
codeHash: 'WFdobEwmytuddWRc8yVm0Pm1AMwoES5n4yQ0WRjtG3g=',
upgradeTxHash: 'fb586bdbdeadab8e7a5d0cf6b4aa815e459614eea357b912de6a9087a7c00ab3',
timestamp: 1638577752,
},
{
upgrader: 'erd1qqqqqqqqqqqqqpgqq66xk9gfr4esuhem3jru86wg5hvp33a62jps2fy57p',
codeHash: 'WFdobEwmytuddWRc8yVm0Pm1AMwoES5n4yQ0WRjtG4g=',
upgradeTxHash: 'a0a94ee0e8f9c4de12fe35d849d81f7b0885eb203eca33275faf115536290af8',
timestamp: 1654616658,
},
{
upgradeTxHash: '7af97da5a00e9f927df7f19a095800f381c185a6a0a6d6bca46b3db6235ff1d2',
codeHash: 'WFdobEwmytuddWRc8yVm0Pm1AMwoES5n4yQ0WRjtG5g=',
upgrader: 'erd1qqqqqqqqqqqqqpgqq66xk9gfr4esuhem3jru86wg5hvp33a62jps2fy57p',
timestamp: 1670612868,
},
Expand All @@ -703,6 +709,7 @@ describe('Account Service', () => {

const upgrades = details.upgrades.map(item => ApiUtils.mergeObjects(new ContractUpgrades(), {
address: item.upgrader,
codeHash: item.codeHash,
txHash: item.upgradeTxHash,
timestamp: item.timestamp,
})).sortedDescending(item => item.timestamp);
Expand All @@ -729,26 +736,31 @@ describe('Account Service', () => {
address: 'erd1qqqqqqqqqqqqqpgqeel2kumf0r8ffyhth7pqdujjat9nx0862jpsg2pqaq',
deployTxHash: '32be840b215a7343ca7c0cbd35c517fd2c04aba22e4465ee1146d59dc7359cd3',
deployer: 'erd1qqqqqqqqqqqqqpgqq66xk9gfr4esuhem3jru86wg5hvp33a62jps2fy57p',
initialCodeHash: 'kUVJtdwvHG2sCTi9l2uneSONUVonWfgHCK69gdB',
timestamp: 1636895604,
contract: 'erd1qqqqqqqqqqqqqpgqeel2kumf0r8ffyhth7pqdujjat9nx0862jpsg2pqaq',
upgrades: [
{
upgrader: 'erd1qqqqqqqqqqqqqpgqq66xk9gfr4esuhem3jru86wg5hvp33a62jps2fy57p',
codeHash: 'WFdobEwmytuddWRc8yVm0Pm1AMwoES5n4yQ0WRjtG2g=',
upgradeTxHash: '1c8c6b2148f25621fa2c798a2c9a184df61fdd1991aa0af7ea01eb7b89025d2a',
timestamp: 1638577452,
},
{
upgrader: 'erd1qqqqqqqqqqqqqpgqq66xk9gfr4esuhem3jru86wg5hvp33a62jps2fy57p',
codeHash: 'WFdobEwmytuddWRc8yVm0Pm1AMwoES5n4yQ0WRjtG3g=',
upgradeTxHash: 'fb586bdbdeadab8e7a5d0cf6b4aa815e459614eea357b912de6a9087a7c00ab3',
timestamp: 1638577752,
},
{
upgrader: 'erd1qqqqqqqqqqqqqpgqq66xk9gfr4esuhem3jru86wg5hvp33a62jps2fy57p',
codeHash: 'WFdobEwmytuddWRc8yVm0Pm1AMwoES5n4yQ0WRjtG4g=',
upgradeTxHash: 'a0a94ee0e8f9c4de12fe35d849d81f7b0885eb203eca33275faf115536290af8',
timestamp: 1654616658,
},
{
upgradeTxHash: '7af97da5a00e9f927df7f19a095800f381c185a6a0a6d6bca46b3db6235ff1d2',
codeHash: 'WFdobEwmytuddWRc8yVm0Pm1AMwoES5n4yQ0WRjtG5g=',
upgrader: 'erd1qqqqqqqqqqqqqpgqq66xk9gfr4esuhem3jru86wg5hvp33a62jps2fy57p',
timestamp: 1670612868,
},
Expand Down

0 comments on commit 277369e

Please sign in to comment.