@ledgerhq/coin-hedera
Version:
Ledger Hedera Coin integration
105 lines • 3.73 kB
JavaScript
;
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.getMockedEnrichedERC20Transfer = exports.getMockERC20Fields = exports.getMockERC20Operation = exports.getMockResponse = void 0;
const bignumber_js_1 = __importDefault(require("bignumber.js"));
const mirror_fixture_1 = require("./mirror.fixture");
const thirdweb_fixture_1 = require("./thirdweb.fixture");
const getMockResponse = (data) => ({
data,
status: 200,
});
exports.getMockResponse = getMockResponse;
// TODO: remove once migration to new API is complete
const getMockERC20Operation = ({ hash, from, to, token, }) => ({
thirdwebTransaction: (0, thirdweb_fixture_1.getMockedThirdwebTransaction)({
transactionHash: hash,
blockHash: "0xBLOCK",
decoded: {
name: "Transfer",
signature: "Transfer(address,address,uint256)",
params: {
from,
to,
value: "1000000",
},
},
}),
mirrorTransaction: {
transaction_hash: hash,
consensus_timestamp: "1234567890.000000000",
transaction_id: "0.0.123@1234567890.000",
charged_tx_fee: 100000,
memo_base64: "",
},
contractCallResult: {
timestamp: "1234567890.000000000",
contract_id: "0.0.TOKEN",
gas_consumed: 50000,
gas_limit: 100000,
gas_used: 50000,
},
token,
});
exports.getMockERC20Operation = getMockERC20Operation;
// TODO: remove once migration to new API is complete
const getMockERC20Fields = (overrides) => ({
date: new Date("2024-01-15T10:00:00Z"),
type: "OUT",
fee: new bignumber_js_1.default(100000),
value: new bignumber_js_1.default(1000000),
senders: ["0.0.SENDER"],
recipients: ["0.0.RECIPIENT"],
blockHeight: 12345,
blockHash: "0xBLOCK",
extra: {
consensusTimestamp: "1234567890.000000000",
transactionId: "0.0.123@1234567890.000",
gasConsumed: 50000,
gasLimit: 100000,
gasUsed: 50000,
},
standard: "erc20",
contract: "0xca367694cdac8f152e33683bb36cc9d6a73f1ef2",
hasFailed: false,
...overrides,
});
exports.getMockERC20Fields = getMockERC20Fields;
const getMockedEnrichedERC20Transfer = (overrides) => {
const consensusTimestamp = overrides?.mirrorTransaction?.consensus_timestamp ?? "1625097600.000000000";
return {
transfers: [
{
token_id: 12345,
token_evm_address: "0x1234",
sender_account_id: 1234,
receiver_account_id: 5678,
sender_evm_address: "0x1234",
receiver_evm_address: "0x5678",
payer_account_id: 1234,
amount: 1000,
transaction_hash: `hash_erc20_${consensusTimestamp}`,
consensus_timestamp: Number(consensusTimestamp) * 10 ** 9,
transfer_type: "transfer",
},
],
contractCallResult: {
block_hash: "0xblock",
contract_id: "0.0.12345",
block_gas_used: 100000,
gas_consumed: 50000,
gas_limit: 100000,
gas_used: 50000,
timestamp: consensusTimestamp,
},
mirrorTransaction: (0, mirror_fixture_1.getMockedMirrorTransaction)({
consensus_timestamp: consensusTimestamp,
name: "CONTRACTCALL",
}),
...overrides,
};
};
exports.getMockedEnrichedERC20Transfer = getMockedEnrichedERC20Transfer;
//# sourceMappingURL=common.fixture.js.map