Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Change api attributes from private to protected #14

Merged
merged 2 commits into from
Feb 6, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 14 additions & 14 deletions src/client/TonClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,13 @@ export type TonClientParameters = {
export class TonClient {
readonly parameters: TonClientParameters;

#api: HttpApi;
protected api: HttpApi;

constructor(parameters: TonClientParameters) {
this.parameters = {
endpoint: parameters.endpoint
};
this.#api = new HttpApi(this.parameters.endpoint, {
this.api = new HttpApi(this.parameters.endpoint, {
timeout: parameters.timeout,
apiKey: parameters.apiKey,
adapter: parameters.httpAdapter
Expand All @@ -66,7 +66,7 @@ export class TonClient {
* @returns stack and gas_used field
*/
async runMethod(address: Address, name: string, stack: TupleItem[] = []): Promise<{ gas_used: number, stack: TupleReader }> {
let res = await this.#api.callGetMethod(address, name, stack);
let res = await this.api.callGetMethod(address, name, stack);
if (res.exit_code !== 0) {
throw Error('Unable to execute get method. Got exit_code: ' + res.exit_code);
}
Expand All @@ -93,7 +93,7 @@ export class TonClient {
* @returns stack and gas_used field
*/
async runMethodWithError(address: Address, name: string, params: any[] = []): Promise<{ gas_used: number, stack: TupleReader, exit_code: number }> {
let res = await this.#api.callGetMethod(address, name, params);
let res = await this.api.callGetMethod(address, name, params);
return { gas_used: res.gas_used, stack: parseStack(res.stack), exit_code: res.exit_code };
}

Expand All @@ -115,7 +115,7 @@ export class TonClient {
*/
async getTransactions(address: Address, opts: { limit: number, lt?: string, hash?: string, to_lt?: string, inclusive?: boolean }) {
// Fetch transactions
let tx = await this.#api.getTransactions(address, opts);
let tx = await this.api.getTransactions(address, opts);
let res: Transaction[] = [];
for (let r of tx) {
res.push(loadTransaction(Cell.fromBoc(Buffer.from(r.data, 'base64'))[0].beginParse()));
Expand All @@ -131,7 +131,7 @@ export class TonClient {
* @returns transaction or null if not exist
*/
async getTransaction(address: Address, lt: string, hash: string) {
let res = await this.#api.getTransaction(address, lt, hash);
let res = await this.api.getTransaction(address, lt, hash);
if (res) {
return loadTransaction(Cell.fromBoc(Buffer.from(res.data, 'base64'))[0].beginParse());
} else {
Expand All @@ -144,7 +144,7 @@ export class TonClient {
* @returns masterchain info
*/
async getMasterchainInfo() {
let r = await this.#api.getMasterchainInfo();
let r = await this.api.getMasterchainInfo();
return {
workchain: r.init.workchain,
shard: r.last.shard,
Expand All @@ -158,7 +158,7 @@ export class TonClient {
* @param seqno masterchain seqno
*/
async getWorkchainShards(seqno: number) {
let r = await this.#api.getShards(seqno);
let r = await this.api.getShards(seqno);
return r.map((m) => ({
workchain: m.workchain,
shard: m.shard,
Expand All @@ -173,7 +173,7 @@ export class TonClient {
* @param shard
*/
async getShardTransactions(workchain: number, seqno: number, shard: string) {
let tx = await this.#api.getBlockTransactions(workchain, seqno, shard);
let tx = await this.api.getBlockTransactions(workchain, seqno, shard);
if (tx.incomplete) {
throw Error('Unsupported');
}
Expand All @@ -193,15 +193,15 @@ export class TonClient {
.store(storeMessage(src))
.endCell()
.toBoc();
await this.#api.sendBoc(boc);
await this.api.sendBoc(boc);
}

/**
* Send file to a network
* @param src source file
*/
async sendFile(src: Buffer) {
await this.#api.sendBoc(src);
await this.api.sendBoc(src);
}

/**
Expand All @@ -215,7 +215,7 @@ export class TonClient {
initData: Cell | null,
ignoreSignature: boolean
}) {
return await this.#api.estimateFee(address, { body: args.body, initCode: args.initCode, initData: args.initData, ignoreSignature: args.ignoreSignature });
return await this.api.estimateFee(address, { body: args.body, initCode: args.initCode, initData: args.initData, ignoreSignature: args.ignoreSignature });
}

/**
Expand Down Expand Up @@ -254,7 +254,7 @@ export class TonClient {
* @param address contract address
*/
async getContractState(address: Address) {
let info = await this.#api.getAddressInformation(address);
let info = await this.api.getAddressInformation(address);
let balance = BigInt(info.balance);
let state = info.state as 'frozen' | 'active' | 'uninitialized';
return {
Expand Down Expand Up @@ -459,4 +459,4 @@ function createProvider(client: TonClient, address: Address, init: { code: Cell
});
}
}
}
}