Giter Club home page Giter Club logo

ton's Introduction

💎 ton-core

🚨 Repository Deprecated and Moved! 🚨

This repository has been deprecated and is no longer actively maintained. We have moved our project to a new repository, which you can find here: ton-org/ton-core. The new NPM package is available here: @ton/core

Please make sure to update your bookmarks and star the new repository to stay up-to-date with the latest developments and updates. This repository will be archived and eventually removed.

Thank you for your continued support!


Core library that implements low level primitives of TON blockchain.

How to install

yarn add ton-core

Reference Documentation

Documentation

Acknowledgements

This library is developed by the Whales Corp. and maintained by Dan Volkov.

License

MIT

ton's People

Contributors

brucx avatar coalus avatar daeren avatar dvlkv avatar ex3ndr avatar gusarich avatar howardpen9 avatar irgc avatar kardanovir avatar krigga avatar kuznetsovnikita avatar miandic avatar rustairov avatar shaharyakir avatar siandreev avatar slavafomin avatar talkol avatar ton-gambling avatar vzhovnitsky avatar xssnick avatar yma-het avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

ton's Issues

Build Optimization Error with ton Package in Angular Dapp

Description:
I am encountering an issue with the ton package when building my Angular Dapp for production with build optimization enabled. The package works perfectly in the development environment, but the following error occurs during the production build:

Cell.js:107 Uncaught TypeError: Cannot read properties of undefined (reading 'Ordinary')
    at new ie (Cell.js:107:40)
    at 9786 (Cell.js:207:14)
    at r (bootstrap:19:1)
    at 121 (Builder.js:12:16)
    at r (bootstrap:19:1)
    at 1665 (contractAddress.js:11:19)
    at r (bootstrap:19:1)
    at 5230 (index.js:33:25)
    at r (bootstrap:19:1)
    at 2971 (index.js:25:14)

Steps to Reproduce:

Integrate the ton package into an Angular project.
Ensure everything works correctly in the development environment.
Build the project for production with build optimization enabled using the Angular CLI command: ng build --prod --optimization.
Expected Behavior:
The project should build successfully without any errors and work as expected in the production environment.

Actual Behavior:

The build process fails with the above-mentioned error, indicating an issue related to undefined properties in Cell.js.

Environment:

Angular version: 14.2.12
ton package version: 13.11.1
Node.js version: 18
OS: MacOs
Additional Information:
Any other relevant information or configurations that might help in diagnosing the issue.

Request:

I would appreciate any guidance or fixes to resolve this issue so that the ton package works seamlessly with Angular's production build optimizations.

Thank you!

TonClient4 - call get method changes

  1. Change to callGetMethod (or change TonClient to runMethod), if there's no good reason for them to be different.
  2. Response should return a TupleReader, similar to TonClient

Unable to Retrieve USDT Balance from TON Mainnet

Description

I attempted to retrieve the USDT balance from the TON mainnet using the master contract address EQCxE6mUtQJKFnGfaROTKOt1lZbDiiX1kCixRv7Nw2Id_sDs. I confirmed that I obtained the correct jetton wallet address. However, I encountered the following error:

async getBalance(provider: ContractProvider) {
    const { stack } = await provider.get("get_wallet_data", []);
    console.log(stack);

    return fromNano(stack.readBigNumber());
}
image

When using the same method to connect to the testnet wallet and the testnet token address, I can successfully retrieve the balance without any errors.

Expected Behavior

The balance should be successfully retrieved from the TON mainnet without any errors, similar to how it works with the testnet.

Actual Behavior

An error occurs when attempting to retrieve the balance from the TON mainnet.

Additional Information

  • The testnet wallet and token address work correctly with the same method.
  • The mainnet setup has been verified to use the correct jetton wallet address.

Environment

  • TON mainnet
  • Master contract address: EQCxE6mUtQJKFnGfaROTKOt1lZbDiiX1kCixRv7Nw2Id_sDs
  • Relevant code snippet provided

Please let me know if you need any additional information or have any suggestions for troubleshooting this issue.

Bug with parse admin address of jetton master


Description:

I got an error when trying to get jetton data with this function:

    async getJettonData(provider: ContractProvider) {
        let res = await provider.get('get_jetton_data', []);
        let totalSupply = res.stack.readBigNumber();
        let mintable = res.stack.readBoolean();
        let adminAddress = res.stack.readAddress();
        let content = res.stack.readCell();
        let walletCode = res.stack.readCell();
        return {
            totalSupply,
            mintable,
            adminAddress,
            content,
            walletCode
        };
    }

The problem is that the proxy ton (EQCM3B12QK1e4yZSf8GtBRT0aLMNyEsBc_DhVfRRtOEffLez) does not have an admin address, so I encounter the error:

Error: Invalid address: 0

Steps to Reproduce:
Call the function with the jetton address EQCM3B12QK1e4yZSf8GtBRT0aLMNyEsBc_DhVfRRtOEffLez.

Solution:
Use let adminAddress = res.stack.readAddressOpt(); instead.

Transaction Hash after TonClient.send()

Hello,

I would like to retrieve my transaction Hash after sending a Cell to the network using
TonClient.send(...)

I saw something in Ton Cookbook using getTransaction and a retry mechanism but TonClient.send(...) returns a void promise so I don't know how they got their example to work.

Ideally, it would be easier to know how the transaction Hash is calculated knowing the Cell we are sending

Transaction hash

Transaction does not contain its own hash, only hash of previous transaction. It’s quite inconvenient, e.g in scenarios when one wants to persist transactions in database. Also toncenter’s response has it, though it’s not encoded in “data” field. Could you please add it?

no support for AxiosAdapter

Is there any plan to support "injecting" different network adapter to the TonClient constructer
as it seems it's not implemented

adapter?: AxiosAdapter; - is never used

Public Archive

It would be useful if the status repo changed.
This can be stronger redirection in contrast to readme.
I see some who made a mistake

Vue.js TypeError: Cannot read private member from an object whose class did not declare it

I'm getting following error, when I am using get methods in the contracts in Vue.js app:

Uncaught (in promise) TypeError: Cannot read private member from an object whose class did not declare it
    at __classPrivateFieldGet (TonClient.js:17:94)
    at Proxy.runMethod (TonClient.js:53:25)
    at Proxy.callGetMethod (TonClient.js:68:21)
    at Object.get (TonClient.js:329:39)
    at DSocialNetworkMaster.getGetBlogsCount (tact_DSocialNetworkMaster.ts:1750:38)
    at Proxy.<anonymous> (openContract.js:38:47)
    at getLastBlogAddress (CreateBlog.vue:87:52)
    at goToNewBlogAddress (CreateBlog.vue:72:25)
    at callWithErrorHandling (runtime-core.esm-bundler.js:158:18)
    at callWithAsyncErrorHandling (runtime-core.esm-bundler.js:166:17)

Possibly, it also can be the case in other frameworks, but as far as I know Vue and JS private hash fields (TonClient.#api) have difficult relationships because of Proxies used by Vue. It might resolve the error, if we replace all hash fields with just private TS properties.

Bug with parsing tuple of cells returned from get-method

Line with bug:
https://github.com/ton-org/ton/blob/master/src/client/TonClient.ts#L346
Fix: add .bytes to be Cell.fromBase64(s.cell.bytes).
I have a getter which looks like this:

[cell, cell] get_foo() method_id {...}

And it always fails with error stack:

TypeError: The first argument must be of type string or an instance of Buffer, ArrayBuffer, or Array or an Array-like Object. Received an instance of Object
    at Function.from (node:buffer:324:9)
    at Function.fromBase64 (/node_modules/@ton/core/dist/boc/Cell.js:41:42)
    at parseStackEntry (/node_modules/@ton/ton/dist/client/TonClient.js:277:54)
    at Array.map (<anonymous>)
    at parseStackItem (/node_modules/@ton/ton/dist/client/TonClient.js:313:34)
    at parseStack (/node_modules/@ton/ton/dist/client/TonClient.js:323:20)
    at TonClient.runMethod (/node_modules/@ton/ton/dist/client/TonClient.js:44:49)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.