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

ton

Package Overview
Dependencies
Maintainers
2
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 13.4.1 to 13.5.0

dist/client/TonClient.spec.d.ts

506

dist/client/api/HttpApi.d.ts

@@ -0,1 +1,2 @@

/// <reference types="node" />
/**

@@ -8,86 +9,397 @@ * Copyright (c) Whales Corp.

*/
/// <reference types="node" />
import * as t from 'io-ts';
import { TonCache } from './TonCache';
import { AxiosAdapter } from 'axios';
import { Address, Cell, TupleItem } from 'ton-core';
declare const message: t.TypeC<{
source: t.StringC;
destination: t.StringC;
value: t.StringC;
fwd_fee: t.StringC;
ihr_fee: t.StringC;
created_lt: t.StringC;
body_hash: t.StringC;
msg_data: t.UnionC<[t.TypeC<{
'@type': t.LiteralC<"msg.dataRaw">;
body: t.StringC;
}>, t.TypeC<{
'@type': t.LiteralC<"msg.dataText">;
text: t.StringC;
}>, t.TypeC<{
'@type': t.LiteralC<"msg.dataDecryptedText">;
text: t.StringC;
}>, t.TypeC<{
'@type': t.LiteralC<"msg.dataEncryptedText">;
text: t.StringC;
import { z } from 'zod';
declare const message: z.ZodObject<{
source: z.ZodString;
destination: z.ZodString;
value: z.ZodString;
fwd_fee: z.ZodString;
ihr_fee: z.ZodString;
created_lt: z.ZodString;
body_hash: z.ZodString;
msg_data: z.ZodUnion<[z.ZodObject<{
'@type': z.ZodLiteral<"msg.dataRaw">;
body: z.ZodString;
}, "strip", z.ZodTypeAny, {
'@type': "msg.dataRaw";
body: string;
}, {
'@type': "msg.dataRaw";
body: string;
}>, z.ZodObject<{
'@type': z.ZodLiteral<"msg.dataText">;
text: z.ZodString;
}, "strip", z.ZodTypeAny, {
'@type': "msg.dataText";
text: string;
}, {
'@type': "msg.dataText";
text: string;
}>, z.ZodObject<{
'@type': z.ZodLiteral<"msg.dataDecryptedText">;
text: z.ZodString;
}, "strip", z.ZodTypeAny, {
'@type': "msg.dataDecryptedText";
text: string;
}, {
'@type': "msg.dataDecryptedText";
text: string;
}>, z.ZodObject<{
'@type': z.ZodLiteral<"msg.dataEncryptedText">;
text: z.ZodString;
}, "strip", z.ZodTypeAny, {
'@type': "msg.dataEncryptedText";
text: string;
}, {
'@type': "msg.dataEncryptedText";
text: string;
}>]>;
}, "strip", z.ZodTypeAny, {
value: string;
fwd_fee: string;
source: string;
destination: string;
ihr_fee: string;
created_lt: string;
body_hash: string;
msg_data: {
'@type': "msg.dataRaw";
body: string;
} | {
'@type': "msg.dataText";
text: string;
} | {
'@type': "msg.dataDecryptedText";
text: string;
} | {
'@type': "msg.dataEncryptedText";
text: string;
};
}, {
value: string;
fwd_fee: string;
source: string;
destination: string;
ihr_fee: string;
created_lt: string;
body_hash: string;
msg_data: {
'@type': "msg.dataRaw";
body: string;
} | {
'@type': "msg.dataText";
text: string;
} | {
'@type': "msg.dataDecryptedText";
text: string;
} | {
'@type': "msg.dataEncryptedText";
text: string;
};
}>;
declare const getTransactions: t.ArrayC<t.TypeC<{
data: t.StringC;
utime: t.NumberC;
transaction_id: t.TypeC<{
lt: t.StringC;
hash: t.StringC;
declare const getTransactions: z.ZodArray<z.ZodObject<{
data: z.ZodString;
utime: z.ZodNumber;
transaction_id: z.ZodObject<{
lt: z.ZodString;
hash: z.ZodString;
}, "strip", z.ZodTypeAny, {
lt: string;
hash: string;
}, {
lt: string;
hash: string;
}>;
fee: t.StringC;
storage_fee: t.StringC;
other_fee: t.StringC;
in_msg: t.UnionC<[t.UndefinedC, t.TypeC<{
source: t.StringC;
destination: t.StringC;
value: t.StringC;
fwd_fee: t.StringC;
ihr_fee: t.StringC;
created_lt: t.StringC;
body_hash: t.StringC;
msg_data: t.UnionC<[t.TypeC<{
'@type': t.LiteralC<"msg.dataRaw">;
body: t.StringC;
}>, t.TypeC<{
'@type': t.LiteralC<"msg.dataText">;
text: t.StringC;
}>, t.TypeC<{
'@type': t.LiteralC<"msg.dataDecryptedText">;
text: t.StringC;
}>, t.TypeC<{
'@type': t.LiteralC<"msg.dataEncryptedText">;
text: t.StringC;
fee: z.ZodString;
storage_fee: z.ZodString;
other_fee: z.ZodString;
in_msg: z.ZodUnion<[z.ZodUndefined, z.ZodObject<{
source: z.ZodString;
destination: z.ZodString;
value: z.ZodString;
fwd_fee: z.ZodString;
ihr_fee: z.ZodString;
created_lt: z.ZodString;
body_hash: z.ZodString;
msg_data: z.ZodUnion<[z.ZodObject<{
'@type': z.ZodLiteral<"msg.dataRaw">;
body: z.ZodString;
}, "strip", z.ZodTypeAny, {
'@type': "msg.dataRaw";
body: string;
}, {
'@type': "msg.dataRaw";
body: string;
}>, z.ZodObject<{
'@type': z.ZodLiteral<"msg.dataText">;
text: z.ZodString;
}, "strip", z.ZodTypeAny, {
'@type': "msg.dataText";
text: string;
}, {
'@type': "msg.dataText";
text: string;
}>, z.ZodObject<{
'@type': z.ZodLiteral<"msg.dataDecryptedText">;
text: z.ZodString;
}, "strip", z.ZodTypeAny, {
'@type': "msg.dataDecryptedText";
text: string;
}, {
'@type': "msg.dataDecryptedText";
text: string;
}>, z.ZodObject<{
'@type': z.ZodLiteral<"msg.dataEncryptedText">;
text: z.ZodString;
}, "strip", z.ZodTypeAny, {
'@type': "msg.dataEncryptedText";
text: string;
}, {
'@type': "msg.dataEncryptedText";
text: string;
}>]>;
}, "strip", z.ZodTypeAny, {
value: string;
fwd_fee: string;
source: string;
destination: string;
ihr_fee: string;
created_lt: string;
body_hash: string;
msg_data: {
'@type': "msg.dataRaw";
body: string;
} | {
'@type': "msg.dataText";
text: string;
} | {
'@type': "msg.dataDecryptedText";
text: string;
} | {
'@type': "msg.dataEncryptedText";
text: string;
};
}, {
value: string;
fwd_fee: string;
source: string;
destination: string;
ihr_fee: string;
created_lt: string;
body_hash: string;
msg_data: {
'@type': "msg.dataRaw";
body: string;
} | {
'@type': "msg.dataText";
text: string;
} | {
'@type': "msg.dataDecryptedText";
text: string;
} | {
'@type': "msg.dataEncryptedText";
text: string;
};
}>]>;
out_msgs: t.ArrayC<t.TypeC<{
source: t.StringC;
destination: t.StringC;
value: t.StringC;
fwd_fee: t.StringC;
ihr_fee: t.StringC;
created_lt: t.StringC;
body_hash: t.StringC;
msg_data: t.UnionC<[t.TypeC<{
'@type': t.LiteralC<"msg.dataRaw">;
body: t.StringC;
}>, t.TypeC<{
'@type': t.LiteralC<"msg.dataText">;
text: t.StringC;
}>, t.TypeC<{
'@type': t.LiteralC<"msg.dataDecryptedText">;
text: t.StringC;
}>, t.TypeC<{
'@type': t.LiteralC<"msg.dataEncryptedText">;
text: t.StringC;
out_msgs: z.ZodArray<z.ZodObject<{
source: z.ZodString;
destination: z.ZodString;
value: z.ZodString;
fwd_fee: z.ZodString;
ihr_fee: z.ZodString;
created_lt: z.ZodString;
body_hash: z.ZodString;
msg_data: z.ZodUnion<[z.ZodObject<{
'@type': z.ZodLiteral<"msg.dataRaw">;
body: z.ZodString;
}, "strip", z.ZodTypeAny, {
'@type': "msg.dataRaw";
body: string;
}, {
'@type': "msg.dataRaw";
body: string;
}>, z.ZodObject<{
'@type': z.ZodLiteral<"msg.dataText">;
text: z.ZodString;
}, "strip", z.ZodTypeAny, {
'@type': "msg.dataText";
text: string;
}, {
'@type': "msg.dataText";
text: string;
}>, z.ZodObject<{
'@type': z.ZodLiteral<"msg.dataDecryptedText">;
text: z.ZodString;
}, "strip", z.ZodTypeAny, {
'@type': "msg.dataDecryptedText";
text: string;
}, {
'@type': "msg.dataDecryptedText";
text: string;
}>, z.ZodObject<{
'@type': z.ZodLiteral<"msg.dataEncryptedText">;
text: z.ZodString;
}, "strip", z.ZodTypeAny, {
'@type': "msg.dataEncryptedText";
text: string;
}, {
'@type': "msg.dataEncryptedText";
text: string;
}>]>;
}>>;
}>>;
export declare type HTTPTransaction = t.TypeOf<typeof getTransactions>[number];
export declare type HTTPMessage = t.TypeOf<typeof message>;
}, "strip", z.ZodTypeAny, {
value: string;
fwd_fee: string;
source: string;
destination: string;
ihr_fee: string;
created_lt: string;
body_hash: string;
msg_data: {
'@type': "msg.dataRaw";
body: string;
} | {
'@type': "msg.dataText";
text: string;
} | {
'@type': "msg.dataDecryptedText";
text: string;
} | {
'@type': "msg.dataEncryptedText";
text: string;
};
}, {
value: string;
fwd_fee: string;
source: string;
destination: string;
ihr_fee: string;
created_lt: string;
body_hash: string;
msg_data: {
'@type': "msg.dataRaw";
body: string;
} | {
'@type': "msg.dataText";
text: string;
} | {
'@type': "msg.dataDecryptedText";
text: string;
} | {
'@type': "msg.dataEncryptedText";
text: string;
};
}>, "many">;
}, "strip", z.ZodTypeAny, {
data: string;
storage_fee: string;
utime: number;
transaction_id: {
lt: string;
hash: string;
};
fee: string;
other_fee: string;
out_msgs: {
value: string;
fwd_fee: string;
source: string;
destination: string;
ihr_fee: string;
created_lt: string;
body_hash: string;
msg_data: {
'@type': "msg.dataRaw";
body: string;
} | {
'@type': "msg.dataText";
text: string;
} | {
'@type': "msg.dataDecryptedText";
text: string;
} | {
'@type': "msg.dataEncryptedText";
text: string;
};
}[];
in_msg?: {
value: string;
fwd_fee: string;
source: string;
destination: string;
ihr_fee: string;
created_lt: string;
body_hash: string;
msg_data: {
'@type': "msg.dataRaw";
body: string;
} | {
'@type': "msg.dataText";
text: string;
} | {
'@type': "msg.dataDecryptedText";
text: string;
} | {
'@type': "msg.dataEncryptedText";
text: string;
};
} | undefined;
}, {
data: string;
storage_fee: string;
utime: number;
transaction_id: {
lt: string;
hash: string;
};
fee: string;
other_fee: string;
out_msgs: {
value: string;
fwd_fee: string;
source: string;
destination: string;
ihr_fee: string;
created_lt: string;
body_hash: string;
msg_data: {
'@type': "msg.dataRaw";
body: string;
} | {
'@type': "msg.dataText";
text: string;
} | {
'@type': "msg.dataDecryptedText";
text: string;
} | {
'@type': "msg.dataEncryptedText";
text: string;
};
}[];
in_msg?: {
value: string;
fwd_fee: string;
source: string;
destination: string;
ihr_fee: string;
created_lt: string;
body_hash: string;
msg_data: {
'@type': "msg.dataRaw";
body: string;
} | {
'@type': "msg.dataText";
text: string;
} | {
'@type': "msg.dataDecryptedText";
text: string;
} | {
'@type': "msg.dataEncryptedText";
text: string;
};
} | undefined;
}>, "many">;
export declare type HTTPTransaction = z.TypeOf<typeof getTransactions>[number];
export declare type HTTPMessage = z.TypeOf<typeof message>;
export interface HttpApiParameters {

@@ -117,6 +429,6 @@ /**

getAddressInformation(address: Address): Promise<{
data: string;
code: string;
balance: string | number;
state: "active" | "uninitialized" | "frozen";
data: string;
code: string;
last_transaction_id: {

@@ -145,2 +457,3 @@ '@type': "internal.transactionId";

data: string;
storage_fee: string;
utime: number;

@@ -152,9 +465,8 @@ transaction_id: {

fee: string;
storage_fee: string;
other_fee: string;
in_msg: {
out_msgs: {
value: string;
fwd_fee: string;
source: string;
destination: string;
value: string;
fwd_fee: string;
ihr_fee: string;

@@ -176,8 +488,8 @@ created_lt: string;

};
} | undefined;
out_msgs: {
}[];
in_msg?: {
value: string;
fwd_fee: string;
source: string;
destination: string;
value: string;
fwd_fee: string;
ihr_fee: string;

@@ -199,3 +511,3 @@ created_lt: string;

};
}[];
} | undefined;
}[]>;

@@ -242,6 +554,6 @@ getMasterchainInfo(): Promise<{

'@type': "blocks.shortTxId";
lt: string;
hash: string;
mode: number;
account: string;
lt: string;
hash: string;
}[];

@@ -251,2 +563,3 @@ }>;

data: string;
storage_fee: string;
utime: number;

@@ -258,9 +571,8 @@ transaction_id: {

fee: string;
storage_fee: string;
other_fee: string;
in_msg: {
out_msgs: {
value: string;
fwd_fee: string;
source: string;
destination: string;
value: string;
fwd_fee: string;
ihr_fee: string;

@@ -282,8 +594,8 @@ created_lt: string;

};
} | undefined;
out_msgs: {
}[];
in_msg?: {
value: string;
fwd_fee: string;
source: string;
destination: string;
value: string;
fwd_fee: string;
ihr_fee: string;

@@ -305,3 +617,3 @@ created_lt: string;

};
}[];
} | undefined;
} | null>;

@@ -308,0 +620,0 @@ callGetMethod(address: Address, method: string, stack: TupleItem[]): Promise<{

205

dist/client/api/HttpApi.js
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.HttpApi = void 0;
/**

@@ -9,134 +14,108 @@ * Copyright (c) Whales Corp.

*/
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
}) : (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 });
exports.HttpApi = void 0;
const t = __importStar(require("io-ts"));
const Either_1 = require("fp-ts/lib/Either");
const io_ts_reporters_1 = __importDefault(require("io-ts-reporters"));
const TonCache_1 = require("./TonCache");
const dataloader_1 = __importDefault(require("dataloader"));
const axios_1 = __importDefault(require("axios"));
const zod_1 = require("zod");
const version = require('../../../package.json').version;
const blockIdExt = t.type({
'@type': t.literal('ton.blockIdExt'),
workchain: t.number,
shard: t.string,
seqno: t.number,
root_hash: t.string,
file_hash: t.string
const blockIdExt = zod_1.z.object({
'@type': zod_1.z.literal('ton.blockIdExt'),
workchain: zod_1.z.number(),
shard: zod_1.z.string(),
seqno: zod_1.z.number(),
root_hash: zod_1.z.string(),
file_hash: zod_1.z.string()
});
const addressInformation = t.type({
balance: t.union([t.number, t.string]),
state: t.union([t.literal('active'), t.literal('uninitialized'), t.literal('frozen')]),
data: t.string,
code: t.string,
last_transaction_id: t.type({
'@type': t.literal('internal.transactionId'),
lt: t.string,
hash: t.string
const addressInformation = zod_1.z.object({
balance: zod_1.z.union([zod_1.z.number(), zod_1.z.string()]),
state: zod_1.z.union([zod_1.z.literal('active'), zod_1.z.literal('uninitialized'), zod_1.z.literal('frozen')]),
data: zod_1.z.string(),
code: zod_1.z.string(),
last_transaction_id: zod_1.z.object({
'@type': zod_1.z.literal('internal.transactionId'),
lt: zod_1.z.string(),
hash: zod_1.z.string()
}),
block_id: blockIdExt,
sync_utime: t.number
sync_utime: zod_1.z.number()
});
const bocResponse = t.type({
'@type': t.literal('ok')
const bocResponse = zod_1.z.object({
'@type': zod_1.z.literal('ok')
});
const feeResponse = t.type({
'@type': t.literal('query.fees'),
source_fees: t.type({
'@type': t.literal('fees'),
in_fwd_fee: t.number,
storage_fee: t.number,
gas_fee: t.number,
fwd_fee: t.number
const feeResponse = zod_1.z.object({
'@type': zod_1.z.literal('query.fees'),
source_fees: zod_1.z.object({
'@type': zod_1.z.literal('fees'),
in_fwd_fee: zod_1.z.number(),
storage_fee: zod_1.z.number(),
gas_fee: zod_1.z.number(),
fwd_fee: zod_1.z.number()
})
});
const callGetMethod = t.type({
gas_used: t.number,
exit_code: t.number,
stack: t.array(t.unknown)
const callGetMethod = zod_1.z.object({
gas_used: zod_1.z.number(),
exit_code: zod_1.z.number(),
stack: zod_1.z.array(zod_1.z.unknown())
});
const messageData = t.union([
t.type({
'@type': t.literal('msg.dataRaw'),
'body': t.string
const messageData = zod_1.z.union([
zod_1.z.object({
'@type': zod_1.z.literal('msg.dataRaw'),
'body': zod_1.z.string()
}),
t.type({
'@type': t.literal('msg.dataText'),
'text': t.string
zod_1.z.object({
'@type': zod_1.z.literal('msg.dataText'),
'text': zod_1.z.string()
}),
t.type({
'@type': t.literal('msg.dataDecryptedText'),
'text': t.string
zod_1.z.object({
'@type': zod_1.z.literal('msg.dataDecryptedText'),
'text': zod_1.z.string()
}),
t.type({
'@type': t.literal('msg.dataEncryptedText'),
'text': t.string
zod_1.z.object({
'@type': zod_1.z.literal('msg.dataEncryptedText'),
'text': zod_1.z.string()
})
]);
const message = t.type({
source: t.string,
destination: t.string,
value: t.string,
fwd_fee: t.string,
ihr_fee: t.string,
created_lt: t.string,
body_hash: t.string,
const message = zod_1.z.object({
source: zod_1.z.string(),
destination: zod_1.z.string(),
value: zod_1.z.string(),
fwd_fee: zod_1.z.string(),
ihr_fee: zod_1.z.string(),
created_lt: zod_1.z.string(),
body_hash: zod_1.z.string(),
msg_data: messageData
});
const transaction = t.type({
data: t.string,
utime: t.number,
transaction_id: t.type({
lt: t.string,
hash: t.string
const transaction = zod_1.z.object({
data: zod_1.z.string(),
utime: zod_1.z.number(),
transaction_id: zod_1.z.object({
lt: zod_1.z.string(),
hash: zod_1.z.string()
}),
fee: t.string,
storage_fee: t.string,
other_fee: t.string,
in_msg: t.union([t.undefined, message]),
out_msgs: t.array(message)
fee: zod_1.z.string(),
storage_fee: zod_1.z.string(),
other_fee: zod_1.z.string(),
in_msg: zod_1.z.union([zod_1.z.undefined(), message]),
out_msgs: zod_1.z.array(message)
});
const getTransactions = t.array(transaction);
const getMasterchain = t.type({
state_root_hash: t.string,
const getTransactions = zod_1.z.array(transaction);
const getMasterchain = zod_1.z.object({
state_root_hash: zod_1.z.string(),
last: blockIdExt,
init: blockIdExt
});
const getShards = t.type({
shards: t.array(blockIdExt)
const getShards = zod_1.z.object({
shards: zod_1.z.array(blockIdExt)
});
const blockShortTxt = t.type({
'@type': t.literal('blocks.shortTxId'),
mode: t.number,
account: t.string,
lt: t.string,
hash: t.string
const blockShortTxt = zod_1.z.object({
'@type': zod_1.z.literal('blocks.shortTxId'),
mode: zod_1.z.number(),
account: zod_1.z.string(),
lt: zod_1.z.string(),
hash: zod_1.z.string()
});
const getBlockTransactions = t.type({
const getBlockTransactions = zod_1.z.object({
id: blockIdExt,
req_count: t.number,
incomplete: t.boolean,
transactions: t.array(blockShortTxt)
req_count: zod_1.z.number(),
incomplete: zod_1.z.boolean(),
transactions: zod_1.z.array(blockShortTxt)
});

@@ -153,5 +132,5 @@ class TypedCache {

if (ex) {
let decoded = this.codec.decode(JSON.parse(ex));
if ((0, Either_1.isRight)(decoded)) {
return decoded.right;
let decoded = this.codec.safeParse(JSON.parse(ex));
if (decoded.success) {
return decoded.data;
}

@@ -179,3 +158,3 @@ }

// Shard
this.shardCache = new TypedCache('ton-shard', this.cache, t.array(blockIdExt), (src) => src + '');
this.shardCache = new TypedCache('ton-shard', this.cache, zod_1.z.array(blockIdExt), (src) => src + '');
this.shardLoader = new dataloader_1.default(async (src) => {

@@ -291,8 +270,8 @@ return await Promise.all(src.map(async (v) => {

}
let decoded = codec.decode(res.data.result);
if ((0, Either_1.isRight)(decoded)) {
return decoded.right;
let decoded = codec.safeParse(res.data.result);
if (decoded.success) {
return decoded.data;
}
else {
throw Error('Malformed response: ' + io_ts_reporters_1.default.report(decoded).join(', '));
throw Error('Malformed response: ' + decoded.error.format()._errors.join(', '));
}

@@ -299,0 +278,0 @@ }

@@ -34,5 +34,5 @@ /**

last: {
workchain: number;
shard: string;
seqno: number;
shard: string;
workchain: number;
fileHash: string;

@@ -56,11 +56,11 @@ rootHash: string;

workchain: number;
shard: string;
seqno: number;
shard: string;
rootHash: string;
fileHash: string;
transactions: {
lt: string;
hash: string;
account: string;
hash: string;
lt: string;
}[];
fileHash: string;
rootHash: string;
}[];

@@ -76,11 +76,11 @@ }>;

workchain: number;
shard: string;
seqno: number;
shard: string;
rootHash: string;
fileHash: string;
transactions: {
lt: string;
hash: string;
account: string;
hash: string;
lt: string;
}[];
fileHash: string;
rootHash: string;
}[];

@@ -96,8 +96,11 @@ }>;

account: {
balance: {
coins: string;
};
state: {
type: "uninit";
} | {
data: string | null;
code: string | null;
type: "active";
code: string | null;
data: string | null;
} | {

@@ -107,5 +110,2 @@ type: "frozen";

};
balance: {
coins: string;
};
last: {

@@ -127,6 +127,6 @@ lt: string;

workchain: number;
shard: string;
seqno: number;
shard: string;
fileHash: string;
rootHash: string;
fileHash: string;
};

@@ -142,2 +142,5 @@ }>;

account: {
balance: {
coins: string;
};
state: {

@@ -153,5 +156,2 @@ type: "uninit";

};
balance: {
coins: string;
};
last: {

@@ -186,42 +186,10 @@ lt: string;

isAccountChanged(seqno: number, address: Address, lt: bigint): Promise<{
changed: boolean;
block: {
workchain: number;
shard: string;
seqno: number;
shard: string;
rootHash: string;
fileHash: string;
};
}>;
/**
* Load one unparsed account transaction
* @param seqno block sequence number
* @param address account address
* @param lt account last transaction lt
* @returns one unparsed transaction
*/
getTransaction(seqno: number, address: Address, lt: bigint): Promise<{
block: {
workchain: number;
seqno: number;
shard: string;
rootHash: string;
};
boc: string;
proof: string;
tx: {
address: bigint;
lt: bigint;
prevTransactionHash: bigint;
prevTransactionLt: bigint;
now: number;
outMessagesCount: number;
oldStatus: import("ton-core").AccountStatus;
endStatus: import("ton-core").AccountStatus;
inMessage: import("ton-core").Message | undefined;
outMessages: import("ton-core").Dictionary<number, import("ton-core").Message>;
totalFees: import("ton-core").CurrencyCollection;
stateUpdate: import("ton-core").HashUpdate;
description: import("ton-core").TransactionDescription;
};
changed: boolean;
}>;

@@ -274,13 +242,13 @@ /**

workchain: number;
shard: string;
seqno: number;
shard: string;
fileHash: string;
rootHash: string;
fileHash: string;
};
shardBlock: {
workchain: number;
shard: string;
seqno: number;
shard: string;
fileHash: string;
rootHash: string;
fileHash: string;
};

@@ -295,3 +263,3 @@ reader: TupleReader;

sendMessage(message: Buffer): Promise<{
status: number;
status: any;
}>;

@@ -298,0 +266,0 @@ /**

@@ -9,21 +9,2 @@ "use strict";

*/
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
}) : (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 __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {

@@ -47,5 +28,5 @@ if (kind === "m") throw new TypeError("Private method is not writable");

const axios_1 = __importDefault(require("axios"));
const t = __importStar(require("io-ts"));
const ton_core_1 = require("ton-core");
const toUrlSafe_1 = require("../utils/toUrlSafe");
const zod_1 = require("zod");
class TonClient4 {

@@ -66,6 +47,7 @@ constructor(args) {

let res = await axios_1.default.get(__classPrivateFieldGet(this, _TonClient4_endpoint, "f") + '/block/latest', { adapter: __classPrivateFieldGet(this, _TonClient4_adapter, "f"), timeout: __classPrivateFieldGet(this, _TonClient4_timeout, "f") });
if (!lastBlockCodec.is(res.data)) {
throw Error('Mailformed response');
let lastBlock = lastBlockCodec.safeParse(res.data);
if (!lastBlock.success) {
throw Error('Mailformed response: ' + lastBlock.error.format()._errors.join(', '));
}
return res.data;
return lastBlock.data;
}

@@ -79,9 +61,10 @@ /**

let res = await axios_1.default.get(__classPrivateFieldGet(this, _TonClient4_endpoint, "f") + '/block/' + seqno, { adapter: __classPrivateFieldGet(this, _TonClient4_adapter, "f"), timeout: __classPrivateFieldGet(this, _TonClient4_timeout, "f") });
if (!blockCodec.is(res.data)) {
let block = blockCodec.safeParse(res.data);
if (!block.success) {
throw Error('Mailformed response');
}
if (!res.data.exist) {
if (!block.data.exist) {
throw Error('Block is out of scope');
}
return res.data.block;
return block.data.block;
}

@@ -95,9 +78,10 @@ /**

let res = await axios_1.default.get(__classPrivateFieldGet(this, _TonClient4_endpoint, "f") + '/block/utime/' + ts, { adapter: __classPrivateFieldGet(this, _TonClient4_adapter, "f"), timeout: __classPrivateFieldGet(this, _TonClient4_timeout, "f") });
if (!blockCodec.is(res.data)) {
let block = blockCodec.safeParse(res.data);
if (!block.success) {
throw Error('Mailformed response');
}
if (!res.data.exist) {
if (!block.data.exist) {
throw Error('Block is out of scope');
}
return res.data.block;
return block.data.block;
}

@@ -112,6 +96,7 @@ /**

let res = await axios_1.default.get(__classPrivateFieldGet(this, _TonClient4_endpoint, "f") + '/block/' + seqno + '/' + address.toString({ urlSafe: true }), { adapter: __classPrivateFieldGet(this, _TonClient4_adapter, "f"), timeout: __classPrivateFieldGet(this, _TonClient4_timeout, "f") });
if (!accountCodec.is(res.data)) {
let account = accountCodec.safeParse(res.data);
if (!account.success) {
throw Error('Mailformed response');
}
return res.data;
return account.data;
}

@@ -126,6 +111,7 @@ /**

let res = await axios_1.default.get(__classPrivateFieldGet(this, _TonClient4_endpoint, "f") + '/block/' + seqno + '/' + address.toString({ urlSafe: true }) + '/lite', { adapter: __classPrivateFieldGet(this, _TonClient4_adapter, "f"), timeout: __classPrivateFieldGet(this, _TonClient4_timeout, "f") });
if (!accountLiteCodec.is(res.data)) {
let account = accountLiteCodec.safeParse(res.data);
if (!account.success) {
throw Error('Mailformed response');
}
return res.data;
return account.data;
}

@@ -150,24 +136,9 @@ /**

let res = await axios_1.default.get(__classPrivateFieldGet(this, _TonClient4_endpoint, "f") + '/block/' + seqno + '/' + address.toString({ urlSafe: true }) + '/changed/' + lt.toString(10), { adapter: __classPrivateFieldGet(this, _TonClient4_adapter, "f"), timeout: __classPrivateFieldGet(this, _TonClient4_timeout, "f") });
if (!changedCodec.is(res.data)) {
let changed = changedCodec.safeParse(res.data);
if (!changed.success) {
throw Error('Mailformed response');
}
return res.data;
return changed.data;
}
/**
* Load one unparsed account transaction
* @param seqno block sequence number
* @param address account address
* @param lt account last transaction lt
* @returns one unparsed transaction
*/
async getTransaction(seqno, address, lt) {
const urladdr = address.toString({ urlSafe: true });
const urlpath = `/block/${seqno}/${urladdr}/tx/${lt.toString(10)}`;
const res = await axios_1.default.get(new URL(urlpath, __classPrivateFieldGet(this, _TonClient4_endpoint, "f")).href, { adapter: __classPrivateFieldGet(this, _TonClient4_adapter, "f"), timeout: __classPrivateFieldGet(this, _TonClient4_timeout, "f") });
if (!transactionCodec.is(res.data))
throw Error('Mailformed response');
const txcell = ton_core_1.Cell.fromBoc(Buffer.from(res.data.boc, 'base64'))[0];
return { tx: (0, ton_core_1.loadTransaction)(txcell.beginParse()), ...res.data };
}
/**
* Load unparsed account transactions

@@ -181,6 +152,7 @@ * @param address address

let res = await axios_1.default.get(__classPrivateFieldGet(this, _TonClient4_endpoint, "f") + '/account/' + address.toString({ urlSafe: true }) + '/tx/' + lt.toString(10) + '/' + (0, toUrlSafe_1.toUrlSafe)(hash.toString('base64')), { adapter: __classPrivateFieldGet(this, _TonClient4_adapter, "f"), timeout: __classPrivateFieldGet(this, _TonClient4_timeout, "f") });
if (!transactionsCodec.is(res.data)) {
let transactions = transactionsCodec.safeParse(res.data);
if (!transactions.success) {
throw Error('Mailformed response');
}
let data = res.data;
let data = transactions.data;
let tx = [];

@@ -208,6 +180,7 @@ let cells = ton_core_1.Cell.fromBoc(Buffer.from(data.boc, 'base64'));

let res = await axios_1.default.get(__classPrivateFieldGet(this, _TonClient4_endpoint, "f") + '/block/' + seqno + '/config' + tail, { adapter: __classPrivateFieldGet(this, _TonClient4_adapter, "f"), timeout: __classPrivateFieldGet(this, _TonClient4_timeout, "f") });
if (!configCodec.is(res.data)) {
let config = configCodec.safeParse(res.data);
if (!config.success) {
throw Error('Mailformed response');
}
return res.data;
return config.data;
}

@@ -226,12 +199,13 @@ /**

let res = await axios_1.default.get(url, { adapter: __classPrivateFieldGet(this, _TonClient4_adapter, "f"), timeout: __classPrivateFieldGet(this, _TonClient4_timeout, "f") });
if (!runMethodCodec.is(res.data)) {
let runMethod = runMethodCodec.safeParse(res.data);
if (!runMethod.success) {
throw Error('Mailformed response');
}
let resultTuple = res.data.resultRaw ? (0, ton_core_1.parseTuple)(ton_core_1.Cell.fromBoc(Buffer.from(res.data.resultRaw, 'base64'))[0]) : [];
let resultTuple = runMethod.data.resultRaw ? (0, ton_core_1.parseTuple)(ton_core_1.Cell.fromBoc(Buffer.from(runMethod.data.resultRaw, 'base64'))[0]) : [];
return {
exitCode: res.data.exitCode,
exitCode: runMethod.data.exitCode,
result: resultTuple,
resultRaw: res.data.resultRaw,
block: res.data.block,
shardBlock: res.data.shardBlock,
resultRaw: runMethod.data.resultRaw,
block: runMethod.data.block,
shardBlock: runMethod.data.shardBlock,
reader: new ton_core_1.TupleReader(resultTuple),

@@ -247,3 +221,4 @@ };

let res = await axios_1.default.post(__classPrivateFieldGet(this, _TonClient4_endpoint, "f") + '/send', { boc: message.toString('base64') }, { adapter: __classPrivateFieldGet(this, _TonClient4_adapter, "f"), timeout: __classPrivateFieldGet(this, _TonClient4_timeout, "f") });
if (!sendCodec.is(res.data)) {
let send = sendCodec.safeParse(res.data);
if (!send.success) {
throw Error('Mailformed response');

@@ -411,32 +386,32 @@ }

//
const lastBlockCodec = t.type({
last: t.type({
seqno: t.number,
shard: t.string,
workchain: t.number,
fileHash: t.string,
rootHash: t.string
const lastBlockCodec = zod_1.z.object({
last: zod_1.z.object({
seqno: zod_1.z.number(),
shard: zod_1.z.string(),
workchain: zod_1.z.number(),
fileHash: zod_1.z.string(),
rootHash: zod_1.z.string()
}),
init: t.type({
fileHash: t.string,
rootHash: t.string
init: zod_1.z.object({
fileHash: zod_1.z.string(),
rootHash: zod_1.z.string()
}),
stateRootHash: t.string,
now: t.number
stateRootHash: zod_1.z.string(),
now: zod_1.z.number()
});
const blockCodec = t.union([t.type({
exist: t.literal(false)
}), t.type({
exist: t.literal(true),
block: t.type({
shards: t.array(t.type({
workchain: t.number,
seqno: t.number,
shard: t.string,
rootHash: t.string,
fileHash: t.string,
transactions: t.array(t.type({
account: t.string,
hash: t.string,
lt: t.string
const blockCodec = zod_1.z.union([zod_1.z.object({
exist: zod_1.z.literal(false)
}), zod_1.z.object({
exist: zod_1.z.literal(true),
block: zod_1.z.object({
shards: zod_1.z.array(zod_1.z.object({
workchain: zod_1.z.number(),
seqno: zod_1.z.number(),
shard: zod_1.z.string(),
rootHash: zod_1.z.string(),
fileHash: zod_1.z.string(),
transactions: zod_1.z.array(zod_1.z.object({
account: zod_1.z.string(),
hash: zod_1.z.string(),
lt: zod_1.z.string()
}))

@@ -447,117 +422,107 @@ }))

// {"lastPaid":1653099243,"duePayment":null,"used":{"bits":119,"cells":1,"publicCells":0}}
const storageStatCodec = t.type({
lastPaid: t.number,
duePayment: t.union([t.null, t.string]),
used: t.type({
bits: t.number,
cells: t.number,
publicCells: t.number
const storageStatCodec = zod_1.z.object({
lastPaid: zod_1.z.number(),
duePayment: zod_1.z.union([zod_1.z.null(), zod_1.z.string()]),
used: zod_1.z.object({
bits: zod_1.z.number(),
cells: zod_1.z.number(),
publicCells: zod_1.z.number()
})
});
const accountCodec = t.type({
account: t.type({
state: t.union([
t.type({ type: t.literal('uninit') }),
t.type({ type: t.literal('active'), code: t.union([t.string, t.null]), data: t.union([t.string, t.null]) }),
t.type({ type: t.literal('frozen'), stateHash: t.string })
const accountCodec = zod_1.z.object({
account: zod_1.z.object({
state: zod_1.z.union([
zod_1.z.object({ type: zod_1.z.literal('uninit') }),
zod_1.z.object({ type: zod_1.z.literal('active'), code: zod_1.z.union([zod_1.z.string(), zod_1.z.null()]), data: zod_1.z.union([zod_1.z.string(), zod_1.z.null()]) }),
zod_1.z.object({ type: zod_1.z.literal('frozen'), stateHash: zod_1.z.string() })
]),
balance: t.type({
coins: t.string
balance: zod_1.z.object({
coins: zod_1.z.string()
}),
last: t.union([
t.null,
t.type({
lt: t.string,
hash: t.string
last: zod_1.z.union([
zod_1.z.null(),
zod_1.z.object({
lt: zod_1.z.string(),
hash: zod_1.z.string()
})
]),
storageStat: t.union([t.null, storageStatCodec])
storageStat: zod_1.z.union([zod_1.z.null(), storageStatCodec])
}),
block: t.type({
workchain: t.number,
seqno: t.number,
shard: t.string,
rootHash: t.string,
fileHash: t.string
block: zod_1.z.object({
workchain: zod_1.z.number(),
seqno: zod_1.z.number(),
shard: zod_1.z.string(),
rootHash: zod_1.z.string(),
fileHash: zod_1.z.string()
})
});
const accountLiteCodec = t.type({
account: t.type({
state: t.union([
t.type({ type: t.literal('uninit') }),
t.type({ type: t.literal('active'), codeHash: t.string, dataHash: t.string }),
t.type({ type: t.literal('frozen'), stateHash: t.string })
const accountLiteCodec = zod_1.z.object({
account: zod_1.z.object({
state: zod_1.z.union([
zod_1.z.object({ type: zod_1.z.literal('uninit') }),
zod_1.z.object({ type: zod_1.z.literal('active'), codeHash: zod_1.z.string(), dataHash: zod_1.z.string() }),
zod_1.z.object({ type: zod_1.z.literal('frozen'), stateHash: zod_1.z.string() })
]),
balance: t.type({
coins: t.string
balance: zod_1.z.object({
coins: zod_1.z.string()
}),
last: t.union([
t.null,
t.type({
lt: t.string,
hash: t.string
last: zod_1.z.union([
zod_1.z.null(),
zod_1.z.object({
lt: zod_1.z.string(),
hash: zod_1.z.string()
})
]),
storageStat: t.union([t.null, storageStatCodec])
storageStat: zod_1.z.union([zod_1.z.null(), storageStatCodec])
})
});
const changedCodec = t.type({
changed: t.boolean,
block: t.type({
workchain: t.number,
seqno: t.number,
shard: t.string,
rootHash: t.string,
fileHash: t.string
const changedCodec = zod_1.z.object({
changed: zod_1.z.boolean(),
block: zod_1.z.object({
workchain: zod_1.z.number(),
seqno: zod_1.z.number(),
shard: zod_1.z.string(),
rootHash: zod_1.z.string(),
fileHash: zod_1.z.string()
})
});
const runMethodCodec = t.type({
exitCode: t.number,
resultRaw: t.union([t.string, t.null]),
block: t.type({
workchain: t.number,
seqno: t.number,
shard: t.string,
rootHash: t.string,
fileHash: t.string
const runMethodCodec = zod_1.z.object({
exitCode: zod_1.z.number(),
resultRaw: zod_1.z.union([zod_1.z.string(), zod_1.z.null()]),
block: zod_1.z.object({
workchain: zod_1.z.number(),
seqno: zod_1.z.number(),
shard: zod_1.z.string(),
rootHash: zod_1.z.string(),
fileHash: zod_1.z.string()
}),
shardBlock: t.type({
workchain: t.number,
seqno: t.number,
shard: t.string,
rootHash: t.string,
fileHash: t.string
shardBlock: zod_1.z.object({
workchain: zod_1.z.number(),
seqno: zod_1.z.number(),
shard: zod_1.z.string(),
rootHash: zod_1.z.string(),
fileHash: zod_1.z.string()
})
});
const configCodec = t.type({
config: t.type({
cell: t.string,
address: t.string,
globalBalance: t.type({
coins: t.string
const configCodec = zod_1.z.object({
config: zod_1.z.object({
cell: zod_1.z.string(),
address: zod_1.z.string(),
globalBalance: zod_1.z.object({
coins: zod_1.z.string()
})
})
});
const sendCodec = t.type({
status: t.number
const sendCodec = zod_1.z.object({
status: zod_1.z.number()
});
const transactionsCodec = t.type({
blocks: t.array(t.type({
workchain: t.number,
seqno: t.number,
shard: t.string,
rootHash: t.string,
fileHash: t.string
const transactionsCodec = zod_1.z.object({
blocks: zod_1.z.array(zod_1.z.object({
workchain: zod_1.z.number(),
seqno: zod_1.z.number(),
shard: zod_1.z.string(),
rootHash: zod_1.z.string(),
fileHash: zod_1.z.string()
})),
boc: t.string
boc: zod_1.z.string()
});
const transactionCodec = t.type({
block: t.type({
workchain: t.number,
seqno: t.number,
shard: t.string,
rootHash: t.string,
}),
boc: t.string,
proof: t.string
});
{
"name": "ton",
"version": "13.4.1",
"version": "13.5.0",
"repository": "https://github.com/ton-core/ton.git",

@@ -45,7 +45,5 @@ "author": "Whales Corp. <developers@whalescorp.com>",

"dataloader": "^2.0.0",
"fp-ts": "^2.11.1",
"io-ts": "^2.2.16",
"io-ts-reporters": "^2.0.0",
"symbol.inspect": "1.0.1",
"teslabot": "^1.3.0"
"teslabot": "^1.3.0",
"zod": "^3.21.4"
},

@@ -52,0 +50,0 @@ "peerDependencies": {

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