Skip to content

Commit

Permalink
feat: use toncenter instead of orbs
Browse files Browse the repository at this point in the history
  • Loading branch information
krigga committed Sep 11, 2024
1 parent 9b1c238 commit 09cbcc8
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 32 deletions.
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,16 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [0.23.0] - 2024-09-11

### Changed

- Toncenter v2 is now used by default instead of orbs access. Rate limited API requests are automatically retried

### Removed

- Removed `@orbs-network/ton-access` dependency

## [0.22.0] - 2024-07-08

### Added
Expand Down
3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@ton/blueprint",
"version": "0.22.0",
"version": "0.23.0",
"description": "Framework for development of TON smart contracts",
"main": "dist/index.js",
"bin": "./dist/cli/cli.js",
Expand Down Expand Up @@ -34,7 +34,6 @@
"@ton/ton": ">=13.11.0"
},
"dependencies": {
"@orbs-network/ton-access": "^2.3.3",
"@tact-lang/compiler": "^1.4.0",
"@ton-community/func-js": "^0.7.0",
"@tonconnect/sdk": "^2.2.0",
Expand Down
30 changes: 27 additions & 3 deletions src/network/createNetworkProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import {
TupleItem,
} from '@ton/core';
import { TonClient, TonClient4 } from '@ton/ton';
import { getHttpV4Endpoint } from '@orbs-network/ton-access';
import { UIProvider } from '../ui/UIProvider';
import { NetworkProvider } from './NetworkProvider';
import { SendProvider } from './send/SendProvider';
Expand All @@ -31,6 +30,10 @@ import { mnemonicToPrivateKey } from '@ton/crypto';
import { MnemonicProvider, WalletVersion } from './send/MnemonicProvider';
import { Config } from '../config/Config';
import { CustomNetwork } from '../config/CustomNetwork';
import axios, { AxiosRequestConfig, AxiosResponse } from 'axios';

const INITIAL_DELAY = 400;
const MAX_ATTEMPTS = 4;

export const argSpec = {
'--mainnet': Boolean,
Expand Down Expand Up @@ -435,8 +438,29 @@ class NetworkProviderBuilder {
throw new Error('The usage of this network provider requires either mainnet or testnet');
}
} else {
tc = new TonClient4({
endpoint: await getHttpV4Endpoint({ network }),
tc = new TonClient({
endpoint: network === 'mainnet' ? 'https://toncenter.com/api/v2/jsonRPC' : 'https://testnet.toncenter.com/api/v2/jsonRPC',
httpAdapter: async (config: AxiosRequestConfig) => {
let r: AxiosResponse;
let delay = INITIAL_DELAY;
let attempts = 0;
while (true) {
r = await axios({
...config,
adapter: undefined,
validateStatus: (status: number) => (status >= 200 && status < 300) || status === 429,
});
if (r.status !== 429) {
return r;
}
await sleep(delay);
delay *= 2;
attempts++;
if (attempts >= MAX_ATTEMPTS) {
throw new Error('Max attempts reached');
}
}
}
});
}

Expand Down
27 changes: 0 additions & 27 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -64,15 +64,6 @@ __metadata:
languageName: node
linkType: hard

"@orbs-network/ton-access@npm:^2.3.3":
version: 2.3.3
resolution: "@orbs-network/ton-access@npm:2.3.3"
dependencies:
isomorphic-fetch: "npm:^3.0.0"
checksum: 10/bdd314cd8e39ed5ab2a425a076d798a731437a622e376bd46ff499fe83cac8858727db6af2e66bd23c98613dfab51384e07ee694bb43d851ca6bc8061f803d30
languageName: node
linkType: hard

"@protobufjs/aspromise@npm:^1.1.1, @protobufjs/aspromise@npm:^1.1.2":
version: 1.1.2
resolution: "@protobufjs/aspromise@npm:1.1.2"
Expand Down Expand Up @@ -211,7 +202,6 @@ __metadata:
version: 0.0.0-use.local
resolution: "@ton/blueprint@workspace:."
dependencies:
"@orbs-network/ton-access": "npm:^2.3.3"
"@tact-lang/compiler": "npm:^1.4.0"
"@ton-community/func-js": "npm:^0.7.0"
"@ton/core": "npm:^0.56.0"
Expand Down Expand Up @@ -1136,16 +1126,6 @@ __metadata:
languageName: node
linkType: hard

"isomorphic-fetch@npm:^3.0.0":
version: 3.0.0
resolution: "isomorphic-fetch@npm:3.0.0"
dependencies:
node-fetch: "npm:^2.6.1"
whatwg-fetch: "npm:^3.4.1"
checksum: 10/568fe0307528c63405c44dd3873b7b6c96c0d19ff795cb15846e728b6823bdbc68cc8c97ac23324509661316f12f551e43dac2929bc7030b8bc4d6aa1158b857
languageName: node
linkType: hard

"it-all@npm:^1.0.4, it-all@npm:^1.0.5":
version: 1.0.6
resolution: "it-all@npm:1.0.6"
Expand Down Expand Up @@ -1931,13 +1911,6 @@ __metadata:
languageName: node
linkType: hard

"whatwg-fetch@npm:^3.4.1":
version: 3.6.17
resolution: "whatwg-fetch@npm:3.6.17"
checksum: 10/27c9930b82c6cae976c3b3bee232d2318cd20ff63e956c80cece6e86088318869196523ece4ce5973a7569725f06987ae33e6ea23dca0154b984d0ac96923904
languageName: node
linkType: hard

"whatwg-url@npm:^5.0.0":
version: 5.0.0
resolution: "whatwg-url@npm:5.0.0"
Expand Down

0 comments on commit 09cbcc8

Please sign in to comment.