redstone-finance / redstone-oracles-monorepo

Other
93 stars 49 forks source link

error with useing @redstone-finance/ton-connector #5

Closed 523753042 closed 4 months ago

523753042 commented 4 months ago
env
    "vite": "^5.3.1"
    "typescript": "^5.2.2",
    "react": "^18.3.1",

when i use the package,aim to get token price and get feeddata,

import { TonPricesContractConnector, BlueprintTonNetwork } from "@redstone-finance/ton-connector";
import { ContractParamsProvider } from '@redstone-finance/sdk';

  const blueprintNetwork = new BlueprintTonNetwork(client, { endpoint: 'https://testnet.toncenter.com/api/v2/jsonRPC' });
    const price = new TonPricesContractConnector(blueprintNetwork, 'EQBP4yZgqut-1JsfRB8PNZqFnr5VzvWXBqX2BppTnS6IAHkk');
    const paramsProvider = new ContractParamsProvider({
      dataServiceId: "redstone-main-demo",
      uniqueSignersCount: 1,
      dataFeeds: ["TON"]
    });

error

[ERROR] Could not resolve "../wrappers/TonPriceFeed"

    node_modules/@redstone-finance/ton-connector/dist/src/index.js:18:29:
      18 │ var TonPriceFeed_1 = require("../wrappers/TonPriceFeed");
         ╵                              ~~~~~~~~~~~~~~~~~~~~~~~~~~

✘ [ERROR] Could not resolve "../wrappers/TonPriceManager"

    node_modules/@redstone-finance/ton-connector/dist/src/index.js:20:32:
      20 │ var TonPriceManager_1 = require("../wrappers/TonPriceManager");
         ╵                                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

✘ [ERROR] Could not resolve "./TonContractConnector"

    node_modules/@redstone-finance/ton-connector/dist/src/index.js:22:37:
      22 │ var TonContractConnector_1 = require("./TonContractConnector");
         ╵                                      ~~~~~~~~~~~~~~~~~~~~~~~~

✘ [ERROR] Could not resolve "./network/BlueprintTonNetwork"

    node_modules/@redstone-finance/ton-connector/dist/src/index.js:24:36:
      24 │ var BlueprintTonNetwork_1 = require("./network/BlueprintTonNetwork");
         ╵                                     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

✘ [ERROR] Could not resolve "./network/CustomTonNetwork"

    node_modules/@redstone-finance/ton-connector/dist/src/index.js:26:33:
      26 │ var CustomTonNetwork_1 = require("./network/CustomTonNetwork");
         ╵                                  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~

✘ [ERROR] Could not resolve "./network/TonNetwork"

    node_modules/@redstone-finance/ton-connector/dist/src/index.js:28:21:
      28 │ __exportStar(require("./network/TonNetwork"), exports);
         ╵                      ~~~~~~~~~~~~~~~~~~~~~~

✘ [ERROR] Could not resolve "./price-feed/TonPriceFeedContractAdapter"

    node_modules/@redstone-finance/ton-connector/dist/src/index.js:29:44:
      29 │ var TonPriceFeedContractAdapter_1 = require("./price-feed/TonPriceFeedContractAdapter");
         ╵                                             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

✘ [ERROR] Could not resolve "./price-feed/TonPriceFeedContractConnector"

    node_modules/@redstone-finance/ton-connector/dist/src/index.js:31:46:
      31 │ var TonPriceFeedContractConnector_1 = require("./price-feed/TonPriceFeedContractConnector");
         ╵                                               ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

✘ [ERROR] Could not resolve "./price-manager/TonPriceManagerContractAdapter"

    node_modules/@redstone-finance/ton-connector/dist/src/index.js:33:47:
      33 │ var TonPriceManagerContractAdapter_1 = require("./price-manager/TonPriceManagerContractAdapter");
         ╵                                                ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

✘ [ERROR] Could not resolve "./price-manager/TonPriceManagerContractConnector"

    node_modules/@redstone-finance/ton-connector/dist/src/index.js:35:49:
      35 │ var TonPriceManagerContractConnector_1 = require("./price-manager/TonPriceManagerContractConnector");
         ╵                                                  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

also ,when use CRA ,error is still exist

Sotatek-MinhTran3 commented 4 months ago

Hi @523753042, I have a problem when using @redstone-finance/ton-connector, too.

When I imported it into a TypeScript file, it said that it could not find the declaration file. Then I tried to install npm i --save-dev @types/redstone-finance__ton-connector but it did not exist.

Did you handle this issue or you are using JS? Many thanks.

Lukasz2891 commented 4 months ago

Hi :)

Thanks for the issue. We'll check, maybe sth is missing in the published package.

Sotatek-MinhTran3 commented 4 months ago

Hi @Lukasz2891,

Thanks for your response. I have a question that who can I ask for supporting when using Redstone as price oracle for my smart contracts on TON?

Many thanks,

Lukasz2891 commented 4 months ago

I confirm, that's sth wrong with the package's configuration. We'll prepare a patch soon.

Lukasz2891 commented 4 months ago

Hi @Lukasz2891,

Thanks for your response. I have a question that who can I ask for supporting when using Redstone as price oracle for my smart contracts on TON?

Many thanks,

Hey @Sotatek-MinhTran3, for support with the RedStone feeds can you please specify your needs and questions and send them to marcin@redstone.finance?

I'll notify all people following this thread once we update the patch

Lukasz2891 commented 4 months ago

I've created a patch version 0.6.0-1 and the sample repository using the library:

https://github.com/redstone-finance/redstone-ton-sample

Note: when you need to use Blueprint env, you need to add it to the project because @ton/blueprint is not a dependency of the package - but the package includes a support for connecting to the Blueprint env.

Fill the WALLET_MNEMONIC in the .env file and enjoy :)

Thanks for the issue.

Sotatek-MinhTran3 commented 4 months ago

Hi @Lukasz2891,

Thanks for your response.

I see that there's an address you provided in the test scripts. Is it the address of the consumer contract?

If we want to deploy our own consumer contract, do we have to implement the price-feed.fc and price-manager.fc, too?

Many thanks!

Lukasz2891 commented 4 months ago

That's an address of sample price-manager.fc.

If you want to store prices in the storage and/or have updated it regularly, it's better to create your own price-manager (or use single-feed-man when you expect to store only one feed). You also can extend/copy one of contracts defined here:

https://github.com/redstone-finance/redstone-oracles-monorepo/tree/main/packages/ton-connector/contracts

so price-manager is an adapter/storage to be updated (by your system, but see also ton-relayer, that's a simple example) You also would need probably another contract when you plan to use your own data packages signer.

You can write your own price-feed, or use the example one - that's just a simple "proxy" for reading the prices. Also, there's sample price-feed consumer there, which consumes the data read by the price-feed.

So the whole infrastructure is generally up to you - we provide the library as defined here https://github.com/redstone-finance/redstone-oracles-monorepo/tree/main/packages/ton-connector/contracts/redstone and the price-manager/price-feed are simple examples, similar to the ones we use for evm-compatible networks (but a bit simplier)

Sotatek-MinhTran3 commented 4 months ago

Hi @Lukasz2891, As I understand, you mean that we have to implement our own price-manager.fc and update the data by ourselves. It is correct? Are there any existing price feeds that we can use it right away?

Many thanks,

Lukasz2891 commented 4 months ago

You can reuse the existing price_manager.fc, deploy (and parametrize it).

For now we don't support free updates, so it's better to have it updated by your relayer - or to talk with Marcin@RedStone about a contract with us.

There exist sample feeds, built on price_feed.fc, the sample addresses of the feed and consumers are saved here: https://github.com/redstone-finance/redstone-oracles-monorepo/blob/main/packages/ton-connector/deploy

I recommend to read the whole ton-*-package code ;)

Sotatek-MinhTran3 commented 4 months ago

Hi @Lukasz2891,

Thank you for your response.

Now I understand that I have to deploy my own price manager contract and update it by myself.

I have another question is that I see that I can read data packages from the cache layer (Data Distribution Layer). Do I have to run my own relayer or I can use the data from the DDL directly?

Many thanks,