Skip to content

Commit

Permalink
feat: checks is the returned value of onERC1155Received is 0xf23a6e61
Browse files Browse the repository at this point in the history
  • Loading branch information
0xtekgrinder committed Apr 30, 2024
1 parent a31758d commit e44bf29
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions assembly/contracts/token-internal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import {
call,
Address,
} from '@massalabs/massa-as-sdk';
import { Bytes4 } from '@massalabs/massa-as-sdk/assembly/std/solidity_compat';

import { u256 } from 'as-bignum/assembly';

Expand Down Expand Up @@ -248,7 +249,7 @@ export function _updateWithAcceptanceCheck(
to.startsWith('AS') &&
functionExists(toAddress, 'onERC1155Received')
) {
call(
const output = call(
toAddress,
'onERC1155Received',
new Args()
Expand All @@ -259,13 +260,15 @@ export function _updateWithAcceptanceCheck(
.add(data),
0,
);
// Check if the returned value is bytes4(keccak256("onERC1155Received(address,address,uint256,uint256,bytes)"))
assert(output == new Bytes4().add("0xf23a6e61").serialize());
}
} else {
if (
to.startsWith('AS') &&
functionExists(toAddress, 'onERC1155BatchReceived')
) {
call(
const output = call(
toAddress,
'onERC1155BatchReceived',
new Args()
Expand All @@ -276,6 +279,8 @@ export function _updateWithAcceptanceCheck(
.add(data),
0,
);
// Check if the returned value is bytes4(keccak256("onERC1155Received(address,address,uint256,uint256,bytes)"))
assert(output == new Bytes4().add("0xf23a6e61").serialize());
}
}
}
Expand Down

0 comments on commit e44bf29

Please sign in to comment.