@ethereumjs/evm
Version:
JavaScript Ethereum Virtual Machine (EVM) implementation
49 lines • 2.31 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.EIP7708_BURN_TOPIC = exports.EIP7708_TRANSFER_TOPIC = exports.EIP7708_SYSTEM_ADDRESS = void 0;
exports.createEIP7708TransferLog = createEIP7708TransferLog;
exports.createEIP7708BurnLog = createEIP7708BurnLog;
const util_1 = require("@ethereumjs/util");
/**
* EIP-7708 system address (canonical `SYSTEM_ADDRESS_BYTES` from `@ethereumjs/util`).
*
* @remarks Experimental (Amsterdam): may change on patch releases.
*/
exports.EIP7708_SYSTEM_ADDRESS = util_1.SYSTEM_ADDRESS_BYTES;
/**
* EIP-7708: `keccak256('Transfer(address,address,uint256)')`.
* Matches the ERC-20 Transfer event signature.
*
* @remarks Experimental (Amsterdam): may change on patch releases.
*/
exports.EIP7708_TRANSFER_TOPIC = (0, util_1.hexToBytes)('0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef');
/**
* EIP-7708: `keccak256('Burn(address,uint256)')`.
* LOG2 topic for burn logs on same-tx selfdestruct and account removal.
*
* @remarks Experimental (Amsterdam): may change on patch releases.
*/
exports.EIP7708_BURN_TOPIC = (0, util_1.hexToBytes)('0xcc16f5dbb4873280815c1ee09dbd06736cffcc184412cf7a71a0fdb75d397ca5');
/**
* Creates an EIP-7708 ETH transfer log (used for CALL/CREATE value transfers).
* Logs are emitted from the system address with `Transfer(address,address,uint256)` topics.
*
* @remarks Experimental (Amsterdam): may change on patch releases.
*/
function createEIP7708TransferLog(from, to, value) {
const fromTopic = (0, util_1.setLengthLeft)(from.bytes, 32);
const toTopic = (0, util_1.setLengthLeft)(to.bytes, 32);
const data = (0, util_1.setLengthLeft)((0, util_1.bigIntToBytes)(value), 32);
return [exports.EIP7708_SYSTEM_ADDRESS, [exports.EIP7708_TRANSFER_TOPIC, fromTopic, toTopic], data];
}
/**
* Creates an EIP-7708 burn log (LOG2) for a burned account balance.
*
* @remarks Experimental (Amsterdam): may change on patch releases.
*/
function createEIP7708BurnLog(account, value) {
const accountTopic = (0, util_1.setLengthLeft)(account.bytes, 32);
const data = (0, util_1.setLengthLeft)((0, util_1.bigIntToBytes)(value), 32);
return [exports.EIP7708_SYSTEM_ADDRESS, [exports.EIP7708_BURN_TOPIC, accountTopic], data];
}
//# sourceMappingURL=eip7708.js.map