UNPKG

@ton.js/core

Version:

TonWeb - JavaScript API for TON blockchain

229 lines 8.36 kB
"use strict"; /** * This is a single-entry point of the library. * All the public runtime symbols as well as types that should * be available to the library users must be exported from here. * We do not support importing symbols from deep inside the * library. * * All the symbols and their structure that are exported * from this file must be 100% compatible with the code * in the "master" branch of the library, because, we are * using this file to generate typing declarations for the * vanilla version of the tonweb. * * We are importing concrete implementation (runtime symbols) * with the dollar prefix (like $BN below), this essentially * allows us to use the name w/o prefix to export the types * with the same name. We can't just export the runtime symbols * directly, because they are not available in the vanilla * version of the library — this will lead to incorrect typings. * So we have to use this workaround for now. After migrating to * TypeScript version completely, we would be able to export all * the symbols and their types directly under the same name. */ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { if (k2 === undefined) k2 = k; var desc = Object.getOwnPropertyDescriptor(m, k); if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { desc = { enumerable: true, get: function() { return m[k]; } }; } Object.defineProperty(o, k2, desc); }) : (function(o, m, k, k2) { if (k2 === undefined) k2 = k; o[k2] = m[k]; })); var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { Object.defineProperty(o, "default", { enumerable: true, value: v }); }) : function(o, v) { o["default"] = v; }); var __importStar = (this && this.__importStar) || function (mod) { if (mod && mod.__esModule) return mod; var result = {}; if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); __setModuleDefault(result, mod); return result; }; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); const bn_js_1 = __importDefault(require("bn.js")); const tweetnacl_1 = __importDefault(require("tweetnacl")); const hw_transport_web_ble_1 = __importDefault(require("@ledgerhq/hw-transport-web-ble")); const hw_transport_webhid_1 = __importDefault(require("@ledgerhq/hw-transport-webhid")); const hw_transport_webusb_1 = __importDefault(require("@ledgerhq/hw-transport-webusb")); //===============// // HTTP PROVIDER // //===============// const http_provider_1 = require("./providers/http-provider"); //====================// // BLOCK SUBSCRIPTION // //====================// const block_subscription_1 = require("./providers/block-subscription/block-subscription"); const in_memory_block_storage_1 = require("./providers/block-subscription/in-memory-block-storage"); //=======// // UTILS // //=======// const address_1 = require("./utils/address"); const commonUtilsExports = __importStar(require("./utils/common")); const base64_1 = require("./utils/base64"); const transfer_url_1 = require("./utils/transfer-url"); const utils = Object.assign(Object.assign({}, commonUtilsExports), { base64ToBytes: base64_1.base64ToBytes, bytesToBase64: base64_1.bytesToBase64, base64toString: base64_1.base64toString, stringToBase64: base64_1.stringToBase64, BN: bn_js_1.default, nacl: tweetnacl_1.default, Address: address_1.Address, formatTransferUrl: transfer_url_1.formatTransferUrl, parseTransferUrl: transfer_url_1.parseTransferUrl }); //=====// // BOC // //=====// const bit_string_1 = require("./boc/bit-string"); const cell_1 = require("./boc/cell"); const boc = { BitString: bit_string_1.BitString, Cell: cell_1.Cell, }; //==========// // CONTRACT // //==========// const contract_1 = require("./contract/contract"); //=========// // WALLETS // //=========// const wallets_1 = require("./contract/wallet/wallets"); //==============// // SUBSCRIPTION // //==============// const subscription_contract_1 = require("./contract/subscription-contract"); //========// // LOCKUP // //========// const lockup_wallet_v1_1 = require("./contract/lockup/lockup-wallet-v1"); const lockup = __importStar(require("./contract/lockup")); const LockupWallets = { LockupWalletV1: lockup_wallet_v1_1.LockupWalletV1, all: lockup.all, list: lockup.list, }; //========// // LEDGER // //========// const app_ton_1 = require("./ledger/app-ton"); //========// // JETTON // //========// const jetton_wallet_1 = require("./contract/token/ft/jetton-wallet"); const jetton_minter_1 = require("./contract/token/ft/jetton-minter"); const JETTON = { JettonWallet: jetton_wallet_1.JettonWallet, JettonMinter: jetton_minter_1.JettonMinter, }; //=================// // NFT: COLLECTION // //=================// const nft_collection_1 = require("./contract/token/nft/nft-collection"); //===========// // NFT: ITEM // //===========// const nft_item_1 = require("./contract/token/nft/nft-item"); //==================// // NFT: MARKETPLACE // //==================// const nft_marketplace_1 = require("./contract/token/nft/nft-marketplace"); //===========// // NFT: SALE // //===========// const nft_sale_1 = require("./contract/token/nft/nft-sale"); //=====// // NFT // //=====// const NFT = { NftCollection: nft_collection_1.NftCollection, NftItem: nft_item_1.NftItem, NftMarketplace: nft_marketplace_1.NftMarketplace, NftSale: nft_sale_1.NftSale, }; // ----- // This version is updated by build script automatically, // do not edit it or change the expression format. const version = '0.0.35-beta.3'; class TonWeb { constructor(provider = new http_provider_1.HttpProvider()) { this.provider = provider; this.version = version; this.utils = utils; this.Address = address_1.Address; this.boc = boc; this.Contract = contract_1.Contract; this.BlockSubscription = block_subscription_1.BlockSubscription; this.InMemoryBlockStorage = in_memory_block_storage_1.InMemoryBlockStorage; this.wallet = new wallets_1.Wallets(this.provider); this.lockupWallet = LockupWallets; } /** * Use this method to get transaction history of a given address. * Returns array of transaction objects. */ async getTransactions(address, limit = 20, lt, txhash, to_lt) { return this.provider.getTransactions(address.toString(), limit, lt, txhash, to_lt); } ; /** * Returns current balance for the given address in nanograms. */ async getBalance(address) { return this.provider.getBalance(address.toString()); } /** * Use this method to send serialized boc file: * fully packed and serialized external message. */ async sendBoc(bytes) { return this.provider.sendBoc(utils.bytesToBase64(bytes)); } /** * Invoke get-method of smart contract. */ async call( /** * Contract address. */ address, /** * Method name or method ID. */ method, /** * Array of stack elements. */ params = []) { // @todo: type return value return this.provider.call(address.toString(), method, params); } } exports.default = TonWeb; TonWeb.version = version; TonWeb.utils = utils; TonWeb.Address = address_1.Address; TonWeb.boc = boc; TonWeb.HttpProvider = http_provider_1.HttpProvider; TonWeb.Contract = contract_1.Contract; TonWeb.Wallets = wallets_1.Wallets; TonWeb.LockupWallets = LockupWallets; TonWeb.SubscriptionContract = subscription_contract_1.SubscriptionContract; TonWeb.BlockSubscription = block_subscription_1.BlockSubscription; TonWeb.InMemoryBlockStorage = in_memory_block_storage_1.InMemoryBlockStorage; TonWeb.ledger = { TransportWebUSB: hw_transport_webusb_1.default, TransportWebHID: hw_transport_webhid_1.default, BluetoothTransport: hw_transport_web_ble_1.default, AppTon: app_ton_1.AppTon, }; TonWeb.token = { nft: NFT, ft: JETTON, jetton: JETTON, }; // @todo: set window.TonWeb = TonWeb via webpack //# sourceMappingURL=index.js.map