Skip to content

Commit 921def0

Browse files
committed
Update example evm and js
1 parent ae783da commit 921def0

File tree

4 files changed

+14
-4
lines changed

4 files changed

+14
-4
lines changed

lazer/evm/src/ExampleReceiver.sol

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,14 @@ contract ExampleReceiver {
5555
uint64 _price;
5656
(_price, pos) = PythLazerLib.parseFeedValueUint64(payload, pos);
5757
console.log("best ask price %d", _price);
58+
} else if (property == PythLazerLib.PriceFeedProperty.Exponent) {
59+
int16 _exponent;
60+
(_exponent, pos) = PythLazerLib.parseFeedValueInt16(payload, pos);
61+
console.log("exponent %d", _exponent);
62+
} else if (property == PythLazerLib.PriceFeedProperty.PublisherCount) {
63+
int16 _publisher_count;
64+
(_publisher_count, pos) = PythLazerLib.parseFeedValueUint16(payload, pos);
65+
console.log("publisher count %d", _publisher_count);
5866
} else {
5967
revert("unknown property");
6068
}

lazer/evm/test/ExampleReceiver.t.sol

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,16 @@ contract ExampleReceiverTest is Test {
2525

2626
ExampleReceiver receiver = new ExampleReceiver(address(pythLazer));
2727
bytes memory update =
28-
hex"2a22999a577d3cc0202197939d736bc0dcf71b9dde7b9470e4d16fa8e2120c0787a1c0d744d0c39cc372af4d1ecf2d09e84160ca905f3f597d20e2eec144a446a0459ad600001c93c7d3750006240af373971c01010000000201000000000005f5e100";
28+
hex"2a22999a9ee4e2a3df5affd0ad8c7c46c96d3b5ef197dd653bedd8f44a4b6b69b767fbc66341e80b80acb09ead98c60d169b9a99657ebada101f447378f227bffbc69d3d01003493c7d37500062cf28659c1e801010000000605000000000005f5e10002000000000000000001000000000000000003000104fff8";
2929
console.logBytes(update);
3030

3131
vm.prank(consumer);
3232
receiver.updatePrice{value: 5 * fee}(update);
3333

34+
assertEq(receiver.timestamp(), 1738270008001000);
3435
assertEq(receiver.price(), 100000000);
35-
assertEq(receiver.timestamp(), 1728479312975644);
36+
assertEq(receiver.exponent(), -8);
37+
assertEq(receiver.publisherCount(), 1);
3638

3739
assertEq(address(pythLazer).balance, fee);
3840
assertEq(address(receiver).balance, 0);

lazer/js/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
"author": "",
1717
"license": "Apache-2.0",
1818
"dependencies": {
19-
"@pythnetwork/pyth-lazer-sdk": "^0.3.1",
19+
"@pythnetwork/pyth-lazer-sdk": "^0.4.0",
2020
"@solana/web3.js": "^1.98.0"
2121
},
2222
"devDependencies": {

lazer/js/src/publish.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ const main = async () => {
168168
properties: ["price"],
169169
chains: ["solana"],
170170
deliveryFormat: "json",
171-
channel: "real_time",
171+
channel: "fixed_rate@1ms",
172172
jsonBinaryEncoding: "hex",
173173
});
174174
};

0 commit comments

Comments
 (0)