UNPKG

@ton.js/core

Version:

TonWeb - JavaScript API for TON blockchain

63 lines 3.23 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.NftSale = void 0; const cell_1 = require("../../../boc/cell"); const contract_1 = require("../../contract"); const utils_1 = require("./utils"); const NFT_SALE_HEX_CODE = ('B5EE9C7241020A010001AB000114FF00F4A413F4BCF2C80B01020120020302014804050004F2300202CD0607002FA03859DA89A1F481F481F481F401A861A1F401F481F4006101F7D00E8698180B8D8492F82707D201876A2687D207D207D207D006A18116BA4E10159C71D991B1B2990E382C92F837028916382F970FA01698FC1080289C6C8895D7970FAE99F98FD2018201A642802E78B2801E78B00E78B00FD016664F6AA701363804C9B081B2299823878027003698FE99F9810E000C92F857010C0801F5D41081DCD650029285029185F7970E101E87D007D207D0018384008646582A804E78B28B9D090D0A85AD08A500AFD010AE5B564B8FD80384008646582AC678B2803FD010B65B564B8FD80384008646582A802E78B00FD0109E5B564B8FD80381041082FE61E8A10C00C646582A802E78B117D010A65B509E58F8A40900B6C0029A3110471036454012F004E03234343435C0038E3D82103B9ACA0013BEF2E1C9702082105FCC3D14218010C8CB055007CF1622FA0216CB6A15CB1F13CB3F21CF1601CF1612CA0021FA02CA00C98100A0FB00E05F04840FF2F0002ACB3F22CF1658CF16CA0021FA02CA00C98100A0FB000FEAA058'); /** * Work in progress, will be changed. */ class NftSale extends contract_1.Contract { constructor(provider, options) { options.wc = 0; options.code = (options.code || cell_1.Cell.oneFromBoc(NFT_SALE_HEX_CODE)); super(provider, options); this.methods.getData = () => this.getData(); } async getData() { const myAddress = await this.getAddress(); const result = await this.provider.call2(myAddress.toString(), 'get_sale_data'); const marketplaceAddress = (0, utils_1.parseAddress)(result[0]); const nftAddress = (0, utils_1.parseAddress)(result[1]); const nftOwnerAddress = (0, utils_1.parseAddress)(result[2]); const fullPrice = result[3]; const marketplaceFee = result[4]; const royaltyAddress = (0, utils_1.parseAddress)(result[5]); const royaltyAmount = result[6]; return { marketplaceAddress, nftAddress, nftOwnerAddress, fullPrice, marketplaceFee, royaltyAddress, royaltyAmount, }; } async createCancelBody(params) { const cell = new cell_1.Cell(); cell.bits.writeUint(3, 32); // cancel op cell.bits.writeUint(params.queryId || 0, 64); return cell; } /** * Returns cell that contains NFT sale data. */ createDataCell() { const cell = new cell_1.Cell(); cell.bits.writeAddress(this.options.marketplaceAddress); cell.bits.writeAddress(this.options.nftAddress); cell.bits.writeAddress(null); // nft_owner_address cell.bits.writeCoins(this.options.fullPrice); const feesCell = new cell_1.Cell(); feesCell.bits.writeCoins(this.options.marketplaceFee); feesCell.bits.writeAddress(this.options.royaltyAddress); feesCell.bits.writeCoins(this.options.royaltyAmount); cell.refs[0] = feesCell; return cell; } } exports.NftSale = NftSale; NftSale.codeHex = NFT_SALE_HEX_CODE; //# sourceMappingURL=nft-sale.js.map