Skip to content

Commit

Permalink
(core) Fixed canTransfer checks
Browse files Browse the repository at this point in the history
  • Loading branch information
VladyslavKhymenkoDevPro committed Oct 28, 2023
1 parent 4c33e2a commit c291399
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
1 change: 1 addition & 0 deletions packages/@erc-3643/core/src/transfer-compliance.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ const isEnoughSpendableBalance: any = jest.fn();
const implToken = {
identityRegistry: jest.fn(),
compliance: jest.fn(),
decimals: jest.fn(),
areTransferPartiesFrozen,
isEnoughSpendableBalance
};
Expand Down
9 changes: 8 additions & 1 deletion packages/@erc-3643/core/src/transfer-compliance.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,13 @@ export class TransferCompliance {
const compliance = this.complianceContract.init(complianceContractAddress, signerOrProvider as Signer);
const errors = [];

const decimals = await token.decimals();
let amountWithRegardsToDecimals = amount;

if (decimals) {
amountWithRegardsToDecimals = amount / 10 ** Number(decimals);
}

// Sender & Receiver wallets must not be frozen
try {
await token.areTransferPartiesFrozen(from, to);
Expand Down Expand Up @@ -68,7 +75,7 @@ export class TransferCompliance {

// Sender & Receiver must be compliant
try {
await compliance.canTransferWithReasons(from, to, amount);
await compliance.canTransferWithReasons(from, to, amountWithRegardsToDecimals);
} catch (error) {
if (Array.isArray((error as Error).cause)) {
errors.push(((error as Error).cause as string[]).join());
Expand Down

0 comments on commit c291399

Please sign in to comment.