Skip to content

Commit

Permalink
updated to latest testnet deployment
Browse files Browse the repository at this point in the history
  • Loading branch information
mpsc0x committed Dec 19, 2024
1 parent dbe7cc1 commit 1892c98
Show file tree
Hide file tree
Showing 6 changed files with 125 additions and 204 deletions.
24 changes: 3 additions & 21 deletions examples/quiries/getAssetPrice.ts
Original file line number Diff line number Diff line change
@@ -1,37 +1,19 @@
import { Account, AccountAddress, Ed25519PrivateKey } from "@aptos-labs/ts-sdk";
import { AccountAddress } from "@aptos-labs/ts-sdk";
import { OracleClient } from "../../src/clients/oracleClient";
import { AptosProvider } from "../../src/clients/aptosProvider";
import { DEFAULT_TESTNET_CONFIG } from "../../src/configs/testnet";
import { priceFeeds } from "../../src/helpers/priceFeeds";

const ASSET_ADDRESS = AccountAddress.fromString(
"0xcd560b2ff2f35be40437bca2b6c8ee881cff44b7040df75d83e5e69ac4da928c",
"0xa613047dbb9ee69a7a1c84eaf4b31ed877a3eb2afd918a7cb015fc8fe2aab116",
);

(async () => {
// global aptos provider
const aptosProvider = AptosProvider.fromConfig(DEFAULT_TESTNET_CONFIG);
const oracleClient = new OracleClient(aptosProvider);

// oracle manager
const aptosPrivateKey = new Ed25519PrivateKey(
"0x1abea38f5d3507f87abb85a9e54b59f64662e65a84a40d16ba6c8a18ad9a7353",
);
const oracleManagerAccount = Account.fromPrivateKey({
privateKey: aptosPrivateKey,
});

try {
// const ra = await oracleClient.getOracleResourceAccount();
// console.log(ra.toString());
// const oa = await oracleClient.getOracleAddress();
// console.log(oa.toString());

// const tx = await oracleClient.withSigner(oracleManagerAccount).setAssetFeedId(ASSET_ADDRESS, priceFeeds.get("DAI") as Uint8Array);
// console.log(
// `Set price feed id with hash = ${tx.hash}`,
// );

// // get asset price
const assetPrice = await oracleClient.getAssetPrice(ASSET_ADDRESS);
console.log(
`Got Price for asset ${ASSET_ADDRESS.toString()} = ${assetPrice.toString()}`,
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@
"@types/node": "^22.10.2",
"@typescript-eslint/eslint-plugin": "^8.18.1",
"@typescript-eslint/parser": "^8.18.1",
"chalk": "^5.3.0",
"chalk": "^5.4.0",
"eslint": "^9.17.0",
"eslint-config-airbnb-base": "^15.0.0",
"eslint-config-airbnb-typescript": "^18.0.0",
Expand Down
Loading

0 comments on commit 1892c98

Please sign in to comment.