Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expose entity_id in transactions REST API #1791

Merged
merged 3 commits into from Apr 3, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
57 changes: 28 additions & 29 deletions hedera-mirror-rest/__tests__/integrationDomainOps.js
Expand Up @@ -160,10 +160,9 @@ const addEntity = async (defaults, entity) => {
};

await sqlConnection.query(
`INSERT INTO t_entities (
id, fk_entity_type_id, entity_shard, entity_realm, entity_num, exp_time_ns, deleted, ed25519_public_key_hex,
auto_renew_period, key, memo)
VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11);`,
`INSERT INTO t_entities (id, fk_entity_type_id, entity_shard, entity_realm, entity_num, exp_time_ns, deleted,
ed25519_public_key_hex, auto_renew_period, key, memo)
VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11);`,
[
EntityId.of(entity.entity_shard, entity.entity_realm, entity.entity_num).getEncodedId(),
entity.entity_type,
Expand Down Expand Up @@ -195,7 +194,7 @@ const setAccountBalance = async (balance) => {
const accountId = EntityId.of(config.shard, balance.realm_num, balance.id).getEncodedId();
await sqlConnection.query(
`INSERT INTO account_balance (consensus_timestamp, account_id, balance)
VALUES ($1, $2, $3);`,
VALUES ($1, $2, $3);`,
[balance.timestamp, accountId, balance.balance]
);

Expand Down Expand Up @@ -226,6 +225,7 @@ const addTransaction = async (transaction) => {
transaction_hash: 'hash',
type: 14,
valid_duration_seconds: 11,
entity_id: null,
...transaction,
};

Expand All @@ -236,11 +236,11 @@ const addTransaction = async (transaction) => {

const payerAccount = EntityId.fromString(transaction.payerAccountId);
const nodeAccount = EntityId.fromString(transaction.nodeAccountId, 'nodeAccountId', true);
const entityId = EntityId.fromString(transaction.entity_id, 'entity_id', true);
await sqlConnection.query(
`INSERT INTO transaction (
consensus_ns, valid_start_ns, payer_account_id, node_account_id,
result, type, valid_duration_seconds, max_fee, charged_tx_fee, transaction_hash, scheduled)
VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11);`,
`INSERT INTO transaction (consensus_ns, valid_start_ns, payer_account_id, node_account_id, result, type,
valid_duration_seconds, max_fee, charged_tx_fee, transaction_hash, scheduled, entity_id)
VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12);`,
[
transaction.consensus_timestamp.toString(),
transaction.valid_start_timestamp.toString(),
Expand All @@ -253,6 +253,7 @@ const addTransaction = async (transaction) => {
transaction.charged_tx_fee,
transaction.transaction_hash,
transaction.scheduled,
entityId.getEncodedId(),
]
);
await insertTransfers('crypto_transfer', transaction.consensus_timestamp, transaction.transfers);
Expand Down Expand Up @@ -320,9 +321,9 @@ const addTopicMessage = async (message) => {
};

await sqlConnection.query(
`INSERT INTO topic_message (
consensus_timestamp, realm_num, topic_num, message, running_hash, sequence_number, running_hash_version)
VALUES ($1, $2, $3, $4, $5, $6, $7);`,
`INSERT INTO topic_message (consensus_timestamp, realm_num, topic_num, message, running_hash, sequence_number,
running_hash_version)
VALUES ($1, $2, $3, $4, $5, $6, $7);`,
[
message.timestamp,
message.realm_num,
Expand All @@ -344,14 +345,13 @@ const addSchedule = async (schedule) => {
};

await sqlConnection.query(
`INSERT INTO schedule (
consensus_timestamp,
creator_account_id,
executed_timestamp,
payer_account_id,
schedule_id,
transaction_body)
VALUES($1, $2, $3, $4, $5, $6)`,
`INSERT INTO schedule (consensus_timestamp,
creator_account_id,
executed_timestamp,
payer_account_id,
schedule_id,
transaction_body)
VALUES ($1, $2, $3, $4, $5, $6)`,
[
schedule.consensus_timestamp,
EntityId.fromString(schedule.creator_account_id).getEncodedId().toString(),
Expand All @@ -365,12 +365,11 @@ const addSchedule = async (schedule) => {

const addTransactionSignature = async (transactionSignature) => {
await sqlConnection.query(
`INSERT INTO transaction_signature (
consensus_timestamp,
public_key_prefix,
entity_id,
signature)
VALUES($1, $2, $3, $4)`,
`INSERT INTO transaction_signature (consensus_timestamp,
public_key_prefix,
entity_id,
signature)
VALUES ($1, $2, $3, $4)`,
[
transactionSignature.consensus_timestamp,
Buffer.from(transactionSignature.public_key_prefix),
Expand Down Expand Up @@ -465,9 +464,9 @@ const addTokenAccount = async (tokenAccount) => {
}

await sqlConnection.query(
`INSERT INTO token_account (
account_id, associated, created_timestamp, freeze_status, kyc_status, modified_timestamp, token_id)
VALUES ($1, $2, $3, $4, $5, $6, $7);`,
`INSERT INTO token_account (account_id, associated, created_timestamp, freeze_status, kyc_status,
modified_timestamp, token_id)
VALUES ($1, $2, $3, $4, $5, $6, $7);`,
[
EntityId.fromString(tokenAccount.account_id).getEncodedId(),
tokenAccount.associated,
Expand Down
1 change: 1 addition & 0 deletions hedera-mirror-rest/__tests__/mockpool.js
Expand Up @@ -199,6 +199,7 @@ class Pool {
row.charged_tx_fee = 100 + i;
row.transaction_hash = '';
row.scheduled = false;
row.entity_id = null;
rows.push(row);
}
if (['asc', 'ASC'].includes(order)) {
Expand Down
Expand Up @@ -66,7 +66,8 @@
"nodeAccountId": "0.0.3",
"consensus_timestamp": "1234567890000000006",
"name": "CRYPTOUPDATEACCOUNT",
"type": "15"
"type": "15",
"entity_id": "0.0.9"
}
],
"cryptotransfers": [
Expand Down Expand Up @@ -95,6 +96,7 @@
{
"charged_tx_fee": 0,
"consensus_timestamp": "1234567890.000000006",
"entity_id": "0.0.9",
"max_fee": "33",
"memo_base64": null,
"name": "CRYPTOUPDATEACCOUNT",
Expand All @@ -110,6 +112,7 @@
{
"charged_tx_fee": 7,
"consensus_timestamp": "1234567890.000000005",
"entity_id": null,
"max_fee": "33",
"memo_base64": null,
"name": "CRYPTOTRANSFER",
Expand Down Expand Up @@ -138,6 +141,7 @@
{
"charged_tx_fee": 7,
"consensus_timestamp": "1234567890.000000001",
"entity_id": null,
"max_fee": "33",
"memo_base64": null,
"name": "CRYPTOTRANSFER",
Expand Down
Expand Up @@ -65,22 +65,25 @@
"nodeAccountId": "0.0.3",
"consensus_timestamp": "1565779555711927001",
"name": "TOKENCREATION",
"type": "29"
"type": "29",
"entity_id": "0.0.90000"
},
{
"payerAccountId": "0.0.9",
"nodeAccountId": "0.0.3",
"consensus_timestamp": "1234567890000000005",
"name": "CRYPTODELETE",
"type": "12"
"type": "12",
"entity_id": "0.0.117"
},
{
"charged_tx_fee": 0,
"payerAccountId": "0.0.9",
"nodeAccountId": "0.0.3",
"consensus_timestamp": "1234567890000000015",
"name": "CRYPTOUPDATEACCOUNT",
"type": "15"
"type": "15",
"entity_id": "0.0.7"
}
],
"cryptotransfers": [
Expand Down Expand Up @@ -128,6 +131,7 @@
{
"charged_tx_fee": 0,
"consensus_timestamp": "1234567891.000000007",
"entity_id": null,
"max_fee": "33",
"memo_base64": null,
"name": "CRYPTOTRANSFER",
Expand All @@ -152,6 +156,7 @@
{
"charged_tx_fee": 7,
"consensus_timestamp": "1234567890.000000007",
"entity_id": null,
"max_fee": "33",
"memo_base64": null,
"name": "CRYPTOTRANSFER",
Expand Down
Expand Up @@ -71,7 +71,8 @@
"nodeAccountId": "0.0.3",
"consensus_timestamp": "1234567890000000031",
"name": "CRYPTOUPDATEACCOUNT",
"type": "15"
"type": "15",
"entity_id": "0.0.9"
}
],
"cryptotransfers": [
Expand Down Expand Up @@ -114,6 +115,7 @@
{
"charged_tx_fee": 0,
"consensus_timestamp": "1234567890.000000031",
"entity_id": "0.0.9",
"max_fee": "33",
"memo_base64": null,
"name": "CRYPTOUPDATEACCOUNT",
Expand All @@ -129,6 +131,7 @@
{
"charged_tx_fee": 7,
"consensus_timestamp": "1234567890.000000005",
"entity_id": null,
"max_fee": "33",
"memo_base64": null,
"name": "CRYPTOTRANSFER",
Expand Down Expand Up @@ -157,6 +160,7 @@
{
"charged_tx_fee": 7,
"consensus_timestamp": "1234567890.000000001",
"entity_id": null,
"max_fee": "33",
"memo_base64": null,
"name": "CRYPTOTRANSFER",
Expand Down
Expand Up @@ -65,22 +65,25 @@
"nodeAccountId": "0.0.3",
"consensus_timestamp": "1565779555711927001",
"name": "TOKENCREATION",
"type": "29"
"type": "29",
"entity_id": "0.0.90000"
},
{
"payerAccountId": "0.0.9",
"nodeAccountId": "0.0.3",
"consensus_timestamp": "1234567890000000005",
"name": "CRYPTODELETE",
"type": "12"
"type": "12",
"entity_id": "0.0.7"
},
{
"charged_tx_fee": 0,
"payerAccountId": "0.0.9",
"nodeAccountId": "0.0.3",
"consensus_timestamp": "1234567890000000015",
"name": "CRYPTOUPDATEACCOUNT",
"type": "15"
"type": "15",
"entity_id": "0.0.8"
}
],
"cryptotransfers": [
Expand Down Expand Up @@ -129,6 +132,7 @@
{
"charged_tx_fee": 7,
"consensus_timestamp": "1234567890.300000007",
"entity_id": null,
"max_fee": "33",
"memo_base64": null,
"name": "CRYPTOTRANSFER",
Expand Down Expand Up @@ -169,6 +173,7 @@
{
"charged_tx_fee": 7,
"consensus_timestamp": "1234567890.000000007",
"entity_id": null,
"max_fee": "33",
"memo_base64": null,
"name": "CRYPTOTRANSFER",
Expand Down
Expand Up @@ -26,7 +26,8 @@
"nodeAccountId": null,
"consensus_timestamp": "1234567800000000009",
"name": "CRYPTOUPDATEACCOUNT",
"type": "15"
"type": "15",
"entity_id": "0.0.10"
}
],
"cryptotransfers": [
Expand Down Expand Up @@ -90,6 +91,7 @@
{
"consensus_timestamp": "1234567890.000000005",
"valid_start_timestamp": "1234567890.000000004",
"entity_id": null,
"charged_tx_fee": 7,
"memo_base64": null,
"result": "SUCCESS",
Expand Down Expand Up @@ -118,6 +120,7 @@
{
"consensus_timestamp": "1234567890.000000004",
"valid_start_timestamp": "1234567890.000000003",
"entity_id": null,
"charged_tx_fee": 7,
"memo_base64": null,
"result": "SUCCESS",
Expand Down Expand Up @@ -158,6 +161,7 @@
{
"consensus_timestamp": "1234567890.000000003",
"valid_start_timestamp": "1234567890.000000002",
"entity_id": null,
"charged_tx_fee": 7,
"memo_base64": null,
"result": "SUCCESS",
Expand Down Expand Up @@ -186,6 +190,7 @@
{
"consensus_timestamp": "1234567890.000000002",
"valid_start_timestamp": "1234567890.000000001",
"entity_id": null,
"charged_tx_fee": 7,
"memo_base64": null,
"result": "SUCCESS",
Expand Down Expand Up @@ -214,6 +219,7 @@
{
"consensus_timestamp": "1234567890.000000001",
"valid_start_timestamp": "1234567890.000000000",
"entity_id": null,
"charged_tx_fee": 7,
"memo_base64": null,
"result": "SUCCESS",
Expand Down Expand Up @@ -242,6 +248,7 @@
{
"charged_tx_fee": 0,
"consensus_timestamp": "1234567800.000000009",
"entity_id": "0.0.10",
"max_fee": "33",
"memo_base64": null,
"name": "CRYPTOUPDATEACCOUNT",
Expand Down
Expand Up @@ -15,6 +15,15 @@
"entity_num": 98
}
],
"entities": [
{
"entity_num": 100,
"entity_type": 6,
"memo": "Created per council decision dated 02/01/21",
"public_key": "7a3c7a3c5477bdf4a63742647d7cfc4544acc1899d07141caf4cd9fea2f75b28a5cc",
"key": [1, 1, 1]
}
],
"balances": [],
"transactions": [
{
Expand All @@ -25,6 +34,7 @@
"valid_start_timestamp": "1234567890000000001",
"name": "SCHEDULECREATE",
"type": 42,
"entity_id": "0.0.100",
"transfers": [
{
"account": "0.0.9",
Expand Down Expand Up @@ -77,6 +87,7 @@
{
"consensus_timestamp": "1234567890.000000002",
"charged_tx_fee": 7,
"entity_id": "0.0.100",
"max_fee": "33",
"memo_base64": null,
"name": "SCHEDULECREATE",
Expand All @@ -101,6 +112,7 @@
{
"charged_tx_fee": 7,
"consensus_timestamp": "1234567890.000000003",
"entity_id": null,
"max_fee": "33",
"memo_base64": null,
"name": "CRYPTOTRANSFER",
Expand Down Expand Up @@ -129,6 +141,7 @@
{
"charged_tx_fee": 7,
"consensus_timestamp": "1234567890.000000040",
"entity_id": null,
"max_fee": "33",
"memo_base64": null,
"name": "CRYPTOTRANSFER",
Expand Down