Skip to content

Wrong getTxTimestamp #400

@mbwhite

Description

@mbwhite

[copied from https://github.com/hyperledger/fabric/issues/4219]

Description

I get the wrong format timestamp
node_modules/fabric-shim-api/types/index.d.ts

getTxTimestamp(): Timestamp;
/* ---- */
interface Timestamp {
  seconds: Long;
  nanos: number;
}

dependencies

"dependencies": {
    "fabric-contract-api": "^2.0.0",
    "fabric-shim": "^2.0.0"
},

Versions

fabric-ca-client:
Version: 1.5.5
Go version: go1.18.2
OS/Arch: linux/amd64

fabric-ca-server:
Version: 1.5.5
Go version: go1.18.2
OS/Arch: linux/amd64

Steps to reproduce

My code in contract emit the History event

const action = { action: 'deposit', amount, userId, timestamp: ctx.stub.getTxTimestamp()};
ctx.stub.setEvent('Balance:History', Buffer.from(JSON.stringify(action)));

My listener

let listener;
try {
    listener = async (event) => {
        const payload = JSON.parse(event.payload.toString());
        console.log(`*** Event: ${event.eventName}`);
        console.log(payload);
    };
    await contract.addContractListener(listener);
} catch (eventError) {
    console.log(`<-- Failed: Setup contract events - ${eventError}`);
}

I see in the console

*** Event: Balance:History
{
  action: 'deposit',
  amount: '100',
  userId: 'fedor',
  timestamp: {
    wrappers_: null,
    arrayIndexOffset_: -1,
    array: [ 1684164619, 536000000 ],
    pivot_: 1.7976931348623157e+308,
    convertedPrimitiveFields_: {}
  }
}

Bad format field timestamp

Metadata

Metadata

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions