Skip to content

Commit

Permalink
Fix qr code test
Browse files Browse the repository at this point in the history
  • Loading branch information
peterpolman committed May 19, 2024
1 parent 2fa53eb commit 631b7ba
Show file tree
Hide file tree
Showing 10 changed files with 13 additions and 24 deletions.
1 change: 1 addition & 0 deletions apps/api/src/app/controllers/qr-codes/qr-codes.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ describe('QR Codes', () => {
.query({ walletId: String(wallet._id) })
.set({ Authorization: widgetAccessToken })
.expect(({ body }: request.Response) => {
console.log(body);
expect(body.erc721).toBeDefined();
expect(body.entry).toBeDefined();
expect(body.payment).toBeDefined();
Expand Down
3 changes: 0 additions & 3 deletions apps/api/src/app/middlewares/errorOutput.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,7 @@ interface ErrorResponse {
// eslint-disable-next-line @typescript-eslint/no-unused-vars
export const errorOutput = (error: any, req: Request, res: Response, next: NextFunction) => {
let status = 500;
console.log(error);
const response: ErrorResponse = { error: { message: 'Unable to fulfill request' } };
console.log(error instanceof THXHttpError);
if (error instanceof THXHttpError || error.status) {
status = error.status;
response.error.message = error.message;
Expand All @@ -26,6 +24,5 @@ export const errorOutput = (error: any, req: Request, res: Response, next: NextF
response.error.stack = error.stack;
}

console.log(status, response);
res.status(status).json(response);
};
4 changes: 2 additions & 2 deletions apps/api/src/app/models/ERC721.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ const schema = new mongoose.Schema(

schema.virtual('contract').get(function () {
if (!this.address) return;
const { web3, defaultAccount } = getProvider(this.chainId);
const { web3 } = getProvider(this.chainId);
const { abi } = getArtifact('THXERC721');
return new web3.eth.Contract(abi, this.address, { from: defaultAccount });
return new web3.eth.Contract(abi, this.address);
});

export const ERC721 = mongoose.model<ERC721Document>('ERC721', schema, 'erc721');
4 changes: 2 additions & 2 deletions apps/api/src/app/services/ERC1155Service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ async function deploy(data: TERC1155, forceSync = true): Promise<ERC1155Document
}

async function deployCallback({ erc1155Id }: TERC1155DeployCallbackArgs, receipt: TransactionReceipt) {
const erc1155 = await ERC1155.findById(erc1155Id);
const events = parseLogs(erc1155.contract.options.jsonInterface, receipt.logs);
const { abi } = getArtifact(contractName);
const events = parseLogs(abi, receipt.logs);

if (!findEvent('OwnershipTransferred', events) && !findEvent('Transfer', events)) {
throw new ExpectedEventNotFound('Transfer or OwnershipTransferred');
Expand Down
5 changes: 1 addition & 4 deletions apps/api/src/app/services/ERC20Service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,11 +83,8 @@ export const deploy = async (params: Partial<TERC20>, forceSync = true) => {

export async function deployCallback({ erc20Id }: TERC20DeployCallbackArgs, receipt: TransactionReceipt) {
const erc20 = await ERC20.findById(erc20Id);
const { chainId } = erc20;
const { web3 } = getProvider(chainId);
const { abi } = getArtifact(erc20.contractName);
const contract = new web3.eth.Contract(abi);
const events = parseLogs(contract.options.jsonInterface, receipt.logs);
const events = parseLogs(abi, receipt.logs);

// Limited and unlimited tokes emit different events. Check if one of the two is emitted.
if (!findEvent('OwnershipTransferred', events) && !findEvent('Transfer', events)) {
Expand Down
6 changes: 3 additions & 3 deletions apps/api/src/app/services/ERC721Service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,12 @@ async function deploy(data: TERC721, forceSync = true): Promise<ERC721Document>
args: { erc721Id: String(erc721._id) },
});

return ERC721.findByIdAndUpdate(erc721._id, { transactions: [txId] }, { new: true });
return await ERC721.findByIdAndUpdate(erc721._id, { transactions: [txId] }, { new: true });
}

async function deployCallback({ erc721Id }: TERC721DeployCallbackArgs, receipt: TransactionReceipt) {
const erc721 = await ERC721.findById(erc721Id);
const events = parseLogs(erc721.contract.options.jsonInterface, receipt.logs);
const { abi } = getArtifact(contractName);
const events = parseLogs(abi, receipt.logs);

if (!findEvent('OwnershipTransferred', events) && !findEvent('Transfer', events)) {
throw new ExpectedEventNotFound('Transfer or OwnershipTransferred');
Expand Down
1 change: 0 additions & 1 deletion apps/api/src/app/services/RewardNFTService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,6 @@ export default class RewardNFTService implements IRewardService {
}

findTokenById(nft: TERC721 | TERC1155, tokenId: string) {
console.log(nft.variant, tokenId);
return this.services[nft.variant].findTokenById(tokenId);
}

Expand Down
2 changes: 1 addition & 1 deletion apps/api/src/app/services/RewardService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ export default class RewardService {
}
}

static async create(variant: RewardVariant, poolId: string, data: Partial<TReward>, file?: Express.Multer.File) {
static async create(variant: RewardVariant, poolId: string, data: Partial<TReward>, file: Express.Multer.File) {
if (file) {
data.image = await ImageService.upload(file);
}
Expand Down
2 changes: 1 addition & 1 deletion apps/api/src/app/services/TransactionService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ async function sendAsync(
from: defaultAccount,
to,
data,
gas: gas + 100000,
gas: gas + 100000, // This was originally added for relayed transactions, not sure if still needed
});

await transactionMined(tx, receipt);
Expand Down
9 changes: 2 additions & 7 deletions apps/api/tsconfig.spec.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,6 @@
// Custom
"allowJs": true
},
"include": [
"jest.config.ts",
"src/**/*.test.ts",
"src/**/*.spec.ts",
"**/*.d.ts",
"../../libs/common/src/lib/types/**/*"
]
"exclude": ["jest.config.ts", "src/**/*.test.ts", "../../libs/common/src/lib/scss/**/*"],
"include": ["src/**/*.ts", "../../libs/common/src/**/*", "../../libs/sdk/src/**/*", "src/app/hardhat/export/*.json"]
}

0 comments on commit 631b7ba

Please sign in to comment.