Skip to content

Commit

Permalink
Merge pull request #36 from MHaris-Ferrum/develop
Browse files Browse the repository at this point in the history
txtype and smartContract api integrated
  • Loading branch information
AbdulAhadArain authored Aug 29, 2024
2 parents 9a5c535 + 9529426 commit b21d66a
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/controllers/contract.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,19 @@ export const registerContract = async (
next(error);
}
};

export const getContract = async (
req: Request,
res: Response,
next: NextFunction,
): Promise<void> => {
try {
console.log(req.params);
const contract = await contractService.getSmartContract(
req.params.contractAddress,
);
res.send(contract);
} catch (error) {
next(error);
}
};
1 change: 1 addition & 0 deletions src/models/quantumPortalTransaction.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import mongoose, { Schema } from 'mongoose';
const quantumPortalTransactionSchema = new Schema({
hash: String,
type: Number,
txType: [String],
block: Number,
nonce: Number,
status: String,
Expand Down
2 changes: 2 additions & 0 deletions src/routes/contract.route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,6 @@ router.post(
contractController.registerContract,
);

router.get('/:contractAddress', contractController.getContract);

export default router;
8 changes: 8 additions & 0 deletions src/services/contract.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,14 @@ export const registerContract = async (
return newAccount;
};

export const getSmartContract = async (contractAddress: string) => {
const contract = await axios.get(
`${config.explorerUrl}/api/v2/smart-contracts/${contractAddress}`,
);
console.log('contract', contract);
return contract?.data;
};

export function sha256sync(hexData: string): string {
const dataWa = encHex.parse(hexData);
const hash: WordArray = SHA256(dataWa);
Expand Down
1 change: 1 addition & 0 deletions src/services/node.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ export const processBlockAndTransaction = async (
const saved = await transactionsService.saveTransaction({
hash: tx.hash,
type: tx.type,
txType: tx.tx_types,
blockNumber: tx.block,
status: tx.status,
method: tx.method,
Expand Down

0 comments on commit b21d66a

Please sign in to comment.