|
|
@@ -2,7 +2,6 @@ import React from "react";
|
|
|
import logo from "./logo.svg";
|
|
|
import "./App.css";
|
|
|
import { Price, PriceFeed } from "@pythnetwork/pyth-common-js";
|
|
|
-import { AptosClient } from "aptos";
|
|
|
import { AptosPriceServiceConnection } from "@pythnetwork/pyth-aptos-js";
|
|
|
|
|
|
// Please read https://docs.pyth.network/consume-data before building on Pyth
|
|
|
@@ -16,11 +15,11 @@ const testnetConnection = new AptosPriceServiceConnection(
|
|
|
); // Price service client used to retrieve the offchain VAAs to update the onchain price
|
|
|
|
|
|
// Price id : this is not an aptos account but instead an opaque identifier for each price https://pyth.network/developers/price-feed-ids/#pyth-cross-chain-testnet
|
|
|
-const ETH_USD_TESTNET_PRICE_ID =
|
|
|
- "0xca80ba6dc32e08d06f1aa886011eed1d77c77be9eb761cc10d72b7d0a2fd57a6";
|
|
|
+const APT_USD_TESTNET_PRICE_ID =
|
|
|
+ "0x44a93dddd8effa54ea51076c4e851b6cbbfd938e82eb90197de38fe8876bb66e";
|
|
|
|
|
|
// Aptos modules : These are testnet addresses https://docs.pyth.network/consume-data/aptos#addresses
|
|
|
-const MINT_NFT_MODULE = "_";
|
|
|
+const MINT_NFT_MODULE = "0x19f8503273cdb5aa93ffe4539277684615242127aa2e65ef91424136a316c9c7";
|
|
|
|
|
|
/// React component that shows the offchain price and confidence interval
|
|
|
function PriceText(props: { price: Price | undefined }) {
|
|
|
@@ -31,7 +30,7 @@ function PriceText(props: { price: Price | undefined }) {
|
|
|
{" "}
|
|
|
<p>
|
|
|
{" "}
|
|
|
- Current ETH/USD price:{" "}
|
|
|
+ Current APT/USD price:{" "}
|
|
|
<span style={{ color: "green" }}>
|
|
|
{" "}
|
|
|
{price.getPriceAsNumberUnchecked().toFixed(3) +
|
|
|
@@ -44,7 +43,7 @@ function PriceText(props: { price: Price | undefined }) {
|
|
|
Current NFT price:{" "}
|
|
|
<span style={{ color: "green" }}>
|
|
|
{" "}
|
|
|
- {(100 / price.getPriceAsNumberUnchecked()).toFixed(5)} APT{" "}
|
|
|
+ {(1 / price.getPriceAsNumberUnchecked()).toFixed(5)} APT{" "}
|
|
|
</span>{" "}
|
|
|
</p>{" "}
|
|
|
</div>
|
|
|
@@ -68,7 +67,7 @@ function App() {
|
|
|
|
|
|
// Subscribe to offchain prices. These are the prices that a typical frontend will want to show.
|
|
|
testnetConnection.subscribePriceFeedUpdates(
|
|
|
- [ETH_USD_TESTNET_PRICE_ID],
|
|
|
+ [APT_USD_TESTNET_PRICE_ID],
|
|
|
(priceFeed: PriceFeed) => {
|
|
|
const price = priceFeed.getPriceUnchecked(); // Fine to use unchecked (not checking for staleness) because this must be a recent price given that it comes from a websocket subscription.
|
|
|
setPythOffChainPrice(price);
|
|
|
@@ -120,7 +119,7 @@ function App() {
|
|
|
|
|
|
async function sendMintTransaction() {
|
|
|
const priceFeedUpdateData = await testnetConnection.getPriceFeedsUpdateData([
|
|
|
- ETH_USD_TESTNET_PRICE_ID,
|
|
|
+ APT_USD_TESTNET_PRICE_ID,
|
|
|
]);
|
|
|
const mintTransaction = {
|
|
|
type: "entry_function_payload",
|