New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

ton

Package Overview
Dependencies
Maintainers
3
Versions
179
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ton - npm Package Compare versions

Comparing version 1.2.1 to 1.3.0

dist/client/api/HttpApi.d.ts

2

dist/client/TonClient.d.ts

@@ -46,3 +46,3 @@ /// <reference types="node" />

*/
openWallet(publicKey: Buffer): Promise<TonWallet>;
openWallet(source: Buffer | Address): Promise<TonWallet>;
/**

@@ -49,0 +49,0 @@ * Securely creates new wallet

@@ -9,5 +9,10 @@ "use strict";

const convert_1 = require("../utils/convert");
// import { BN } from "bn.js";
// import { TonMessage, TonTransaction } from "./TonTransaction";
// import { Maybe } from "../types";
const HttpApi_1 = require("./api/HttpApi");
const TonWeb = require('tonweb');
class TonClient {
parameters;
#api;
#client;

@@ -17,2 +22,3 @@ constructor(parameters) {

this.#client = new TonWeb(new TonWeb.HttpProvider(parameters.endpoint));
this.#api = new HttpApi_1.HttpApi(parameters.endpoint);
}

@@ -25,11 +31,48 @@ /**

async getBalance(address) {
let balance;
if (typeof address === 'string') {
balance = await this.#client.getBalance(address);
}
else {
balance = await this.#client.getBalance(address.toString());
}
let balance = await this.#client.getBalance(address.toString());
return (0, convert_1.fromNano)(balance);
}
// async getTransactions(opts: { address: Address, limit?: Maybe<number>, before?: Maybe<{ lt: string, hash: string }> }): Promise<TonTransaction[]> {
// let limit = 100;
// if (opts.limit !== null && opts.limit !== undefined) {
// limit = opts.limit;
// }
// let result: TonTransaction[] = [];
// let res = await this.#client.provider.send('getTransactions', opts.before ? {
// address: opts.address.toString(),
// limit,
// hash: opts.before.hash,
// lt: opts.before.lt
// } : {
// address: opts.address.toString(),
// limit,
// });
// function parseMessage(src: any): TonMessage {
// return {
// source: !!src.source ? src.source : null,
// destination: !!src.destination ? src.destination : null,
// value: new BN(src.value),
// ihrFee: new BN(src.ihr_fee),
// forwardFee: new BN(src.fwd_fee),
// createdLt: src.created_lt,
// message: !!src.message ? src.message : null
// };
// }
// for (let r of res) {
// let trans: TonTransaction = {
// id: {
// lt: r.transaction_id.lt,
// hash: r.transaction_id.hash
// },
// data: r.data,
// fee: new BN(r.fee),
// storageFee: new BN(r.storage_fee),
// otherFee: new BN(r.other_fee),
// inMessage: parseMessage(r.in_msg),
// outMessages: r.out_msgs.map(parseMessage)
// };
// result.push(trans);
// }
// return result;
// }
/**

@@ -76,9 +119,14 @@ * Invoke get method

*/
async openWallet(publicKey) {
let walletContract = this.#client.wallet.create({
publicKey: publicKey,
wc: 0
});
const address = Address_1.Address.parseRaw((await walletContract.getAddress()).toString(false));
return new TonWallet_1.TonWallet(this, address, walletContract);
async openWallet(source) {
if (Buffer.isBuffer(source)) {
let walletContract = this.#client.wallet.create({
publicKey: source,
wc: 0
});
const address = Address_1.Address.parseRaw((await walletContract.getAddress()).toString(false));
return new TonWallet_1.TonWallet(this, address);
}
else {
return new TonWallet_1.TonWallet(this, source);
}
}

@@ -85,0 +133,0 @@ /**

@@ -7,2 +7,3 @@ "use strict";

const TonClient_1 = require("./TonClient");
// import { TonTransaction } from "./TonTransaction";
describe('TonClient', () => {

@@ -48,2 +49,21 @@ it('should read balance', async () => {

});
// it('should being able to read all transactions', async () => {
// const client = await createTestClient();
// const address = Address.parseFriendly('EQDR4neQzqkfEz0oR3hXBcJph64d5NddP8H8wfN0thQIAqDH').address;
// const limit = 10;
// let offset: { lt: string, hash: string } | null = null;
// let txs: TonTransaction[] = [];
// while (true) {
// let tx2 = await client.getTransactions({ address, limit, before: offset });
// for (let t of tx2) {
// txs.push(t);
// }
// if (tx2.length === 0) {
// break;
// }
// offset = tx2[tx2.length - 1].id as any;
// console.log(offset);
// }
// console.warn(txs);
// });
});

@@ -17,3 +17,3 @@ /// <reference types="node" />

readonly address: Address;
constructor(client: TonClient, address: Address, contract: any);
constructor(client: TonClient, address: Address);
/**

@@ -30,6 +30,2 @@ * Returns balance of wallet

/**
* Deploy Wallet Contract
*/
deploy(): Promise<void>;
/**
* Transfer TON Coins

@@ -36,0 +32,0 @@ */

@@ -19,7 +19,5 @@ "use strict";

#client;
#contract;
constructor(client, address, contract) {
constructor(client, address) {
this.#client = client;
this.address = address;
this.#contract = contract;
}

@@ -42,8 +40,2 @@ /**

/**
* Deploy Wallet Contract
*/
async deploy() {
await this.#contract.methods.deploy().send();
}
/**
* Transfer TON Coins

@@ -50,0 +42,0 @@ */

@@ -6,4 +6,4 @@ "use strict";

async function createTestClient() {
return new __1.TonClient({ endpoint: 'https://testnet.toncenter.com/api/v2/jsonRPC ' });
return new __1.TonClient({ endpoint: 'https://testnet.toncenter.com/api/v2/jsonRPC' });
}
exports.createTestClient = createTestClient;
{
"name": "ton",
"version": "1.2.1",
"version": "1.3.0",
"repository": "https://github.com/ex3ndr/ton.git",

@@ -36,2 +36,3 @@ "author": "Steve Korshakov <steve@korshakov.com>",

"bn.js": "^5.2.0",
"isomorphic-unfetch": "^3.1.0",
"ton-crypto": "^1.1.0",

@@ -38,0 +39,0 @@ "tonweb": "^0.0.18"

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc