sCrypt-Inc/boilerplate

refactor

Closed this issue · 0 comments

xhliu commented

Put these in a struct

ExchangeRate {
  timestamp
  price
  symbol
}

so we can wrap into a function parseExchangeRate()

// 4 bytes timestamp (LE) + 8 bytes rate (LE) + 1 byte decimal + 16 bytes symbol
const timestamp = Utils.fromLEUnsigned(msg.slice(0, 8))
const price = Utils.fromLEUnsigned(msg.slice(8, 24))
const symbol: ByteString = msg.slice(26, 58)

Update doc afterwards https://scrypt.io/docs/tutorials/oracle/#public-method---unlock