pinax-network / subgraph-antelope-transactions

Subgraph Antelope Transactions
https://thegraph.com/explorer/subgraphs/4bAe7NA8b6J14ZfZr3TXfzzjjSoGECTFuqv7CwnK1zzg?view=Query&chain=arbitrum-one
MIT License
0 stars 0 forks source link

issue with `Timestamp` Subgraph type using Substreams #2

Closed DenisCarriere closed 1 week ago

DenisCarriere commented 2 weeks ago

❌ Errors

the value 1528545390 for field time must have type Timestamp! but has type String the value 2018-06-09T11:56:30Z for field time must have type Timestamp! but has type String the value 1528545390000000 for field time must have type Timestamp! but has type BigInt the value 1528545390000000 for field timestamp must have type Timestamp! but has type String

GraphQL

type Block @entity {
  id:                                   ID!
  date:                                 String!
  time:                                 Timestamp!
  number:                               BigInt!
  hash:                                 String!
  previous:                             String!
  producer:                             String!
  transactions: [Transaction!]! @derivedFrom(field: "block")
}

Rust

    // timestamp
    let timestamp = clock.clone().timestamp.unwrap();
    let seconds = timestamp.seconds;
    let nanos = timestamp.nanos;
    let microseconds = seconds * 1_000_000 + i64::from(nanos) / 1_000;
    let block_date = block_time_to_date(timestamp.to_string().as_str());
    let block_time = timestamp.to_string();
    let block_number = clock.number.to_string();
    let block_hash = &clock.id;

    // TABLE::Block
    tables.create_row("Block", &block_hash)
        .set("hash", block_hash)
        .set("previous", previous)
        .set("producer", producer)
        .set("date", block_date)
        .set_bigint("time", &microseconds.to_string())
        .set_bigint("number", &block_number.to_string())
    ;

Also tried using String timestamp

.set("time", &timestamp.to_string())
DenisCarriere commented 1 week ago

Implemented https://github.com/pinax-network/subgraph-antelope-transactions/pull/4