Skip to content

Commit

Permalink
Merge pull request #38 from EOSIO/develop
Browse files Browse the repository at this point in the history
Release 3.1.0
  • Loading branch information
flux627 authored Jan 3, 2019
2 parents c7e74f9 + b0985ff commit 733cf15
Show file tree
Hide file tree
Showing 5 changed files with 67 additions and 5 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "demux-eos",
"version": "3.0.1",
"version": "3.1.0",
"description": "Demux-js Action Reader implementations for EOSIO blockchains",
"main": "dist/index.js",
"types": "dist/index.d.ts",
Expand Down
2 changes: 2 additions & 0 deletions src/MongoBlock.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ describe("MongoBlock", () => {
to: "bob",
},
name: "transfer",
notifiedAccounts: ["bill", "bob"],
transactionId: "051620080b3212292f56a836c6b2f294291f6e6793dc0f12ce6a886f83d97f83",
},
type: "eosio.token::transfer",
Expand All @@ -50,6 +51,7 @@ describe("MongoBlock", () => {
to: "bob",
},
name: "transfer",
notifiedAccounts: ["bill", "bob"],
transactionId: "051620080b3212292f56a836c6b2f294291f6e6793dc0f12ce6a886f83d97f83",
},
type: "eosio.token::transfer",
Expand Down
11 changes: 9 additions & 2 deletions src/MongoBlock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,17 @@ export class MongoBlock implements Block {
const eosActions = []
let currentTx = ""
let actionIndex = 0
let currentActionDigest = ""
for (const rawAction of rawActions) {
if (rawAction.trx_id != currentTx) {
if (rawAction.trx_id !== currentTx) {
currentTx = rawAction.trx_id
actionIndex = 0
}
if (rawAction.receipt.act_digest === currentActionDigest) {
eosActions[eosActions.length - 1].payload.notifiedAccounts.push(rawAction.receipt.receiver)
continue
}
currentActionDigest = rawAction.receipt.act_digest
eosActions.push({
type: `${rawAction.act.account}::${rawAction.act.name}`,
payload: {
Expand All @@ -33,7 +39,8 @@ export class MongoBlock implements Block {
data: rawAction.act.data,
name: rawAction.act.name,
transactionId: rawAction.trx_id,
}
notifiedAccounts: [rawAction.receipt.receiver],
},
})
actionIndex += 1
}
Expand Down
1 change: 1 addition & 0 deletions src/interfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ export interface EosPayload {
data: any
name: string
transactionId: string
notifiedAccounts?: string[]
}

export interface EosAction extends Action {
Expand Down
56 changes: 54 additions & 2 deletions src/testHelpers/mongoObjectMocks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,10 @@ export const mongoBlockState = {
export const mongoRawActions = [
{
_id: "5c0fb6d93ffbf3000d484e23",
receipt: {},
receipt: {
receiver: "bill",
act_digest: "aaaa",
},
act: {
account: "eosio.token",
name: "transfer",
Expand All @@ -59,7 +62,56 @@ export const mongoRawActions = [
},
{
_id: "5c0fb6d93ffbf3000d484e24",
receipt: {},
receipt: {
receiver: "bob",
act_digest: "aaaa",
},
act: {
account: "eosio.token",
name: "transfer",
authorization: [{ actor: "bill", permission: "active" }],
data: { from: "bill", to: "bob", quantity: "1.0000 EOS", memo: "m" },
},
elapsed: 6,
console: "",
trx_id: "051620080b3212292f56a836c6b2f294291f6e6793dc0f12ce6a886f83d97f83",
block_num: 3,
block_time: "2018-06-09T11:56:30.000",
producer_block_id: "0001796719f9556dca4dce19f7d83e3c390d76783193d59123706b7741686bac",
account_ram_deltas: [],
except: null,
trx_status: "executed",
createdAt: "2018-12-11T13:08:41.509Z",
},
{
_id: "5c0fb6d93ffbf3000d484e25",
receipt: {
receiver: "bill",
act_digest: "bbbb",
},
act: {
account: "eosio.token",
name: "transfer",
authorization: [{ actor: "bill", permission: "active" }],
data: { from: "bill", to: "bob", quantity: "1.0000 EOS", memo: "m" },
},
elapsed: 6,
console: "",
trx_id: "051620080b3212292f56a836c6b2f294291f6e6793dc0f12ce6a886f83d97f83",
block_num: 3,
block_time: "2018-06-09T11:56:30.000",
producer_block_id: "0001796719f9556dca4dce19f7d83e3c390d76783193d59123706b7741686bac",
account_ram_deltas: [],
except: null,
trx_status: "executed",
createdAt: "2018-12-11T13:08:41.509Z",
},
{
_id: "5c0fb6d93ffbf3000d484e26",
receipt: {
receiver: "bob",
act_digest: "bbbb",
},
act: {
account: "eosio.token",
name: "transfer",
Expand Down

0 comments on commit 733cf15

Please sign in to comment.