Fixes and testing scripts.
This commit is contained in:
parent
0d38aca492
commit
221d577244
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,18 @@
|
|||
{
|
||||
"name": "pyth-exp",
|
||||
"version": "1.0.0",
|
||||
"description": "Experimentation with pyth",
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
"test": "mocha"
|
||||
},
|
||||
"author": "",
|
||||
"license": "ISC",
|
||||
"dependencies": {
|
||||
"@pythnetwork/client": "^2.3.1",
|
||||
"algosdk": "^1.11.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"mocha": "^9.1.2"
|
||||
}
|
||||
}
|
|
@ -0,0 +1,3 @@
|
|||
goal clerk compile teal\pricedata.teal.tmpl -o teal\pricedata.teal.bin
|
||||
goal app create --out create-app.txn --creator OPDM7ACAW64Q4VBWAL77Z5SHSJVZZ44V3BAN7W44U43SUXEOUENZMZYOQU --local-byteslices 0 --local-ints 0 --global-byteslices 3 --global-ints 2 --approval-prog-raw teal\pricedata.teal.bin --clear-prog teal\clearstate.teal
|
||||
algokey sign -t create-app.txn -m "assault approve result rare float sugar power float soul kind galaxy edit unusual pretty tone tilt net range pelican avoid unhappy amused recycle abstract master" -o create-app.stxn
|
|
@ -0,0 +1,39 @@
|
|||
import algosdk, { signBytes } from 'algosdk'
|
||||
import { Buffer } from 'buffer'
|
||||
import { writeFileSync } from 'fs'
|
||||
|
||||
// OPDM7ACAW64Q4VBWAL77Z5SHSJVZZ44V3BAN7W44U43SUXEOUENZMZYOQU
|
||||
const mnemo = 'assault approve result rare float sugar power float soul kind galaxy edit unusual pretty tone tilt net range pelican avoid unhappy amused recycle abstract master'
|
||||
|
||||
const appId = BigInt(0x123456789)
|
||||
const nonce = BigInt(0x1000)
|
||||
const symbol = "BTC/USD "
|
||||
const price = 45278.65
|
||||
const sd = 8.00000000004
|
||||
|
||||
// Create message
|
||||
const buf = Buffer.alloc(131)
|
||||
buf.write('PRICEDATA',0)
|
||||
// v
|
||||
buf.writeInt8(1, 9)
|
||||
// dest
|
||||
buf.writeBigUInt64BE(appId, 10)
|
||||
// nonce
|
||||
buf.writeBigUInt64BE(nonce, 18)
|
||||
// symbol
|
||||
buf.write(symbol, 26)
|
||||
// price
|
||||
buf.writeDoubleBE(price, 42)
|
||||
// sd
|
||||
buf.writeDoubleBE(sd, 50)
|
||||
// ts
|
||||
buf.writeBigUInt64BE(BigInt(Date.now()), 58)
|
||||
|
||||
const signature = Buffer.from(algosdk.signBytes(buf, algosdk.mnemonicToSecretKey(mnemo).sk))
|
||||
signature.copy(buf, 66)
|
||||
|
||||
// v-component (ignored in Algorand it seems)
|
||||
buf.writeInt8(1, 130)
|
||||
|
||||
writeFileSync('msg.bin', buf)
|
||||
writeFileSync('msg.b64', buf.toString('base64'))
|
|
@ -0,0 +1,3 @@
|
|||
#pragma version 5
|
||||
int 1
|
||||
return
|
|
@ -1,6 +1,6 @@
|
|||
#pragma version 5
|
||||
// ================================================================================================
|
||||
// Price-Reference Program
|
||||
// Pricecaster Program
|
||||
// ================================================================================================
|
||||
//
|
||||
// This contract has the following invariants at
|
||||
|
@ -9,11 +9,11 @@
|
|||
// TMPL_VALIDATOR Unique data validator address that signs and sends the incoming message
|
||||
//
|
||||
// App-globals:
|
||||
// symbol : pair supported by this app.
|
||||
// nonce : last sequence ID
|
||||
// price : current price
|
||||
// stdev : current confidence (standard deviation)
|
||||
// ts : timestamp
|
||||
// symbol : byte[] pair supported by this app.
|
||||
// nonce : uint64 last sequence ID
|
||||
// price : byte[] current price
|
||||
// stdev : byte[] current confidence (standard deviation)
|
||||
// ts : uint64 timestamp
|
||||
//
|
||||
// Slots:
|
||||
// 0 Input message block
|
||||
|
@ -22,17 +22,17 @@
|
|||
// The Message format must have the packed fields:
|
||||
//
|
||||
// Field size
|
||||
// 10 header Literal "PRICE_DATA"
|
||||
// 9 header Literal "PRICEDATA"
|
||||
// 1 version int8 (Must be 1)
|
||||
// 8 dest This appId
|
||||
// 8 nonce uint64 Sequence identifier
|
||||
// 16 symbol String filled with spaces e.g ("ALGO/USD ")
|
||||
// 8 price uint64 encoded price
|
||||
// 8 conf uint64 encoded confidence (kind of SD)
|
||||
// 8 price Price. 64bit float encoded as big-endian.
|
||||
// 8 conf Confidence (standard-deviation?). 64bit float encoded as big-endian.
|
||||
// 8 ts timestamp of this price
|
||||
// 32 r Signature r-component
|
||||
// 32 s Signature s-component
|
||||
// 1 v Signature v-component
|
||||
// 32 s Signature s-component
|
||||
// 32 r Signature r-component
|
||||
// 1 v Signature v-component (ignored)
|
||||
//
|
||||
// Size: 131 bytes.
|
||||
//
|
||||
|
|
Loading…
Reference in New Issue