Skip to content

Commit 733cf15

Browse files
authored
Merge pull request #38 from EOSIO/develop
Release 3.1.0
2 parents c7e74f9 + b0985ff commit 733cf15

File tree

5 files changed

+67
-5
lines changed

5 files changed

+67
-5
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "demux-eos",
3-
"version": "3.0.1",
3+
"version": "3.1.0",
44
"description": "Demux-js Action Reader implementations for EOSIO blockchains",
55
"main": "dist/index.js",
66
"types": "dist/index.d.ts",

src/MongoBlock.test.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ describe("MongoBlock", () => {
2929
to: "bob",
3030
},
3131
name: "transfer",
32+
notifiedAccounts: ["bill", "bob"],
3233
transactionId: "051620080b3212292f56a836c6b2f294291f6e6793dc0f12ce6a886f83d97f83",
3334
},
3435
type: "eosio.token::transfer",
@@ -50,6 +51,7 @@ describe("MongoBlock", () => {
5051
to: "bob",
5152
},
5253
name: "transfer",
54+
notifiedAccounts: ["bill", "bob"],
5355
transactionId: "051620080b3212292f56a836c6b2f294291f6e6793dc0f12ce6a886f83d97f83",
5456
},
5557
type: "eosio.token::transfer",

src/MongoBlock.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,17 @@ export class MongoBlock implements Block {
1919
const eosActions = []
2020
let currentTx = ""
2121
let actionIndex = 0
22+
let currentActionDigest = ""
2223
for (const rawAction of rawActions) {
23-
if (rawAction.trx_id != currentTx) {
24+
if (rawAction.trx_id !== currentTx) {
2425
currentTx = rawAction.trx_id
2526
actionIndex = 0
2627
}
28+
if (rawAction.receipt.act_digest === currentActionDigest) {
29+
eosActions[eosActions.length - 1].payload.notifiedAccounts.push(rawAction.receipt.receiver)
30+
continue
31+
}
32+
currentActionDigest = rawAction.receipt.act_digest
2733
eosActions.push({
2834
type: `${rawAction.act.account}::${rawAction.act.name}`,
2935
payload: {
@@ -33,7 +39,8 @@ export class MongoBlock implements Block {
3339
data: rawAction.act.data,
3440
name: rawAction.act.name,
3541
transactionId: rawAction.trx_id,
36-
}
42+
notifiedAccounts: [rawAction.receipt.receiver],
43+
},
3744
})
3845
actionIndex += 1
3946
}

src/interfaces.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ export interface EosPayload {
1212
data: any
1313
name: string
1414
transactionId: string
15+
notifiedAccounts?: string[]
1516
}
1617

1718
export interface EosAction extends Action {

src/testHelpers/mongoObjectMocks.ts

Lines changed: 54 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,10 @@ export const mongoBlockState = {
3939
export const mongoRawActions = [
4040
{
4141
_id: "5c0fb6d93ffbf3000d484e23",
42-
receipt: {},
42+
receipt: {
43+
receiver: "bill",
44+
act_digest: "aaaa",
45+
},
4346
act: {
4447
account: "eosio.token",
4548
name: "transfer",
@@ -59,7 +62,56 @@ export const mongoRawActions = [
5962
},
6063
{
6164
_id: "5c0fb6d93ffbf3000d484e24",
62-
receipt: {},
65+
receipt: {
66+
receiver: "bob",
67+
act_digest: "aaaa",
68+
},
69+
act: {
70+
account: "eosio.token",
71+
name: "transfer",
72+
authorization: [{ actor: "bill", permission: "active" }],
73+
data: { from: "bill", to: "bob", quantity: "1.0000 EOS", memo: "m" },
74+
},
75+
elapsed: 6,
76+
console: "",
77+
trx_id: "051620080b3212292f56a836c6b2f294291f6e6793dc0f12ce6a886f83d97f83",
78+
block_num: 3,
79+
block_time: "2018-06-09T11:56:30.000",
80+
producer_block_id: "0001796719f9556dca4dce19f7d83e3c390d76783193d59123706b7741686bac",
81+
account_ram_deltas: [],
82+
except: null,
83+
trx_status: "executed",
84+
createdAt: "2018-12-11T13:08:41.509Z",
85+
},
86+
{
87+
_id: "5c0fb6d93ffbf3000d484e25",
88+
receipt: {
89+
receiver: "bill",
90+
act_digest: "bbbb",
91+
},
92+
act: {
93+
account: "eosio.token",
94+
name: "transfer",
95+
authorization: [{ actor: "bill", permission: "active" }],
96+
data: { from: "bill", to: "bob", quantity: "1.0000 EOS", memo: "m" },
97+
},
98+
elapsed: 6,
99+
console: "",
100+
trx_id: "051620080b3212292f56a836c6b2f294291f6e6793dc0f12ce6a886f83d97f83",
101+
block_num: 3,
102+
block_time: "2018-06-09T11:56:30.000",
103+
producer_block_id: "0001796719f9556dca4dce19f7d83e3c390d76783193d59123706b7741686bac",
104+
account_ram_deltas: [],
105+
except: null,
106+
trx_status: "executed",
107+
createdAt: "2018-12-11T13:08:41.509Z",
108+
},
109+
{
110+
_id: "5c0fb6d93ffbf3000d484e26",
111+
receipt: {
112+
receiver: "bob",
113+
act_digest: "bbbb",
114+
},
63115
act: {
64116
account: "eosio.token",
65117
name: "transfer",

0 commit comments

Comments
 (0)