Skip to content

Commit

Permalink
fix: error normalize address
Browse files Browse the repository at this point in the history
  • Loading branch information
abdulgalimov committed May 23, 2024
1 parent 6e34bf1 commit 3698877
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 5 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "unique-marketplace-backend",
"version": "3.0.260",
"version": "3.0.261",
"description": "Backend project for unique marketplace",
"author": "Unique Network",
"private": true,
Expand Down
3 changes: 2 additions & 1 deletion packages/common/modules/database/services/offer.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { ContractEntity, OfferEntity } from '../entities';
import { OfferStatus } from '../../types';
import { ChainPropertiesResponse } from '@unique-nft/sdk/full';
import { Market } from '../../../../contracts/assemblies/3/market';
import { formatCrossAccount } from '../../../src/lib/utils';

interface FindOptions {
contract?: ContractEntity;
Expand Down Expand Up @@ -49,7 +50,7 @@ export class OfferService {
offer.orderId = Number(order.id);
offer.collectionId = Number(order.collectionId);
offer.tokenId = Number(order.tokenId);
offer.seller = Address.extract.addressNormalized(order.seller);
offer.seller = Address.extract.addressNormalized(formatCrossAccount(order.seller));
}
const priceOrder = BigInt(order.price);
const priceDir = parseFloat(priceOrder.toString()) / 10 ** 18;
Expand Down
6 changes: 6 additions & 0 deletions packages/common/src/lib/utils.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
export const formatCrossAccount = (address: [string, bigint]): { sub: string; eth: string } => {
return {
eth: address[0],
sub: `0x${address[1].toString(16)}`,
};
};
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import { Sdk, SocketClient } from '@unique-nft/sdk/full';
import { Address } from '@unique-nft/utils';
import { CollectionsService } from '../../../collections/collections.service';
import { TokensService } from '../../../collections/tokens.service';
import { formatCrossAccount } from '@app/common/src/lib/utils';

type LogEventHandler = (
extrinsic: Extrinsic,
Expand Down Expand Up @@ -148,7 +149,7 @@ export class ContractEventsHandler {
// @ts-ignore
const blockId = extrinsic.blockId || extrinsic.block?.id || 0;

const address = crossAddress ? Address.extract.addressNormalized(crossAddress) : null;
const address = crossAddress ? Address.extract.addressNormalized(formatCrossAccount(crossAddress)) : null;

// todo fix double events error
const foundEvent = await this.offerEventService.find(offer, eventType, blockId, address);
Expand Down

0 comments on commit 3698877

Please sign in to comment.