Skip to content

Commit

Permalink
feat: w5
Browse files Browse the repository at this point in the history
feat: toncenter as default provider
chore: updated deps
chore: removed tonhub connector
  • Loading branch information
krigga committed Sep 16, 2024
1 parent 09cbcc8 commit ca4dcdd
Show file tree
Hide file tree
Showing 8 changed files with 107 additions and 371 deletions.
15 changes: 15 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,21 @@ 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.24.0] - 2024-09-16

### Added

- Added support for wallet v5 in the Mnemonic provider

### Changed

- Changed the default API provider to Toncenter v2 (instead of Orbs TON Access). Rate limited requests are automatically retried
- Updated dependencies

### Removed

- Removed the specialized TonHub connector. Use TON Connect instead

## [0.23.0] - 2024-09-11

### Changed
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ Blueprint is an all-in-one development environment designed to enhance the proce
1. Compiling FunC with https://github.com/ton-community/func-js
2. Compiling Tact with https://github.com/tact-lang/tact
3. Testing smart contracts with https://github.com/ton-org/sandbox
4. Deploying smart contracts with [TON Connect 2](https://github.com/ton-connect), [Tonhub wallet](https://tonhub.com/) or a `ton://` deeplink
4. Deploying smart contracts with [TON Connect 2](https://github.com/ton-connect) or a `ton://` deeplink

### Requirements

Expand Down
15 changes: 7 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@ton/blueprint",
"version": "0.23.0",
"version": "0.24.0",
"description": "Framework for development of TON smart contracts",
"main": "dist/index.js",
"bin": "./dist/cli/cli.js",
Expand All @@ -19,19 +19,19 @@
"format": "prettier --write src"
},
"devDependencies": {
"@ton/core": "^0.56.0",
"@ton/crypto": "^3.2.0",
"@ton/ton": "^13.11.0",
"@ton/core": "^0.58.1",
"@ton/crypto": "^3.3.0",
"@ton/ton": "^15.0.0",
"@types/inquirer": "^8.2.6",
"@types/node": "^20.2.5",
"@types/qrcode-terminal": "^0.12.0",
"prettier": "^3.0.3",
"typescript": "^4.9.5"
},
"peerDependencies": {
"@ton/core": ">=0.56.0",
"@ton/crypto": ">=3.2.0",
"@ton/ton": ">=13.11.0"
"@ton/core": ">=0.58.1",
"@ton/crypto": ">=3.3.0",
"@ton/ton": ">=15.0.0"
},
"dependencies": {
"@tact-lang/compiler": "^1.4.0",
Expand All @@ -42,7 +42,6 @@
"dotenv": "^16.1.4",
"inquirer": "^8.2.5",
"qrcode-terminal": "^0.12.0",
"ton-x": "^2.1.0",
"ts-node": "^10.9.1"
},
"packageManager": "[email protected]"
Expand Down
2 changes: 1 addition & 1 deletion src/cli/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ Flags:
--custom-version - specifies the API version to use with the custom API. Options: v2 (defualt), v4.
--custom-key - specifies the API key to use with the custom API, can only be used with API v2.
--custom-type - specifies the network type to be indicated to scripts. Options: custom (default), mainnet, testnet.
--tonconnect, --tonhub, --deeplink, --mnemonic - specifies the deployer to use when running the script. If not specified on the command line, it will be asked interactively.
--tonconnect, --deeplink, --mnemonic - specifies the deployer to use when running the script. If not specified on the command line, it will be asked interactively.
--tonscan, --tonviewer, --toncx, --dton - specifies the network explorer to use when displaying links to the deployed contracts. Default: tonscan.`,
build: `Usage: blueprint build [contract name] [flags]
Expand Down
59 changes: 25 additions & 34 deletions src/network/createNetworkProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { oneOrZeroOf, sleep, getExplorerLink } from '../utils';
import arg from 'arg';
import { DeeplinkProvider } from './send/DeeplinkProvider';
import { TonConnectProvider } from './send/TonConnectProvider';
import { TonHubProvider } from './send/TonHubProvider';
import {
Address,
Cell,
Expand Down Expand Up @@ -30,7 +29,7 @@ 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';
import axios, { AxiosResponse, AxiosAdapter, InternalAxiosRequestConfig } from 'axios';

const INITIAL_DELAY = 400;
const MAX_ATTEMPTS = 4;
Expand All @@ -45,7 +44,6 @@ export const argSpec = {

'--tonconnect': Boolean,
'--deeplink': Boolean,
'--tonhub': Boolean,
'--mnemonic': Boolean,

'--tonscan': Boolean,
Expand Down Expand Up @@ -190,7 +188,7 @@ class NetworkProviderImpl implements NetworkProvider {
}
}

async waitForDeploy(address: Address, attempts: number = 10, sleepDuration: number = 2000) {
async waitForDeploy(address: Address, attempts: number = 20, sleepDuration: number = 2000) {
if (attempts <= 0) {
throw new Error('Attempt number must be positive');
}
Expand Down Expand Up @@ -316,7 +314,6 @@ class NetworkProviderBuilder {
let deployUsing = oneOrZeroOf({
tonconnect: this.args['--tonconnect'],
deeplink: this.args['--deeplink'],
tonhub: this.args['--tonhub'],
mnemonic: this.args['--mnemonic'],
});

Expand All @@ -333,10 +330,6 @@ class NetworkProviderBuilder {
name: 'Create a ton:// deep link',
value: 'deeplink',
},
{
name: 'Tonhub wallet',
value: 'tonhub',
},
{
name: 'Mnemonic',
value: 'mnemonic',
Expand All @@ -358,10 +351,6 @@ class NetworkProviderBuilder {
if (network === 'custom') throw new Error('Tonkeeper cannot work with custom network.');
provider = new TonConnectProvider(new FSStorage(storagePath), this.ui);
break;
case 'tonhub':
if (network === 'custom') throw new Error('TonHub cannot work with custom network.');
provider = new TonHubProvider(network, new FSStorage(storagePath), this.ui);
break;
case 'mnemonic':
provider = await createMnemonicProvider(client, this.ui);
break;
Expand Down Expand Up @@ -438,29 +427,31 @@ class NetworkProviderBuilder {
throw new Error('The usage of this network provider requires either mainnet or testnet');
}
} else {
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');
}
const httpAdapter: AxiosAdapter = async (config: InternalAxiosRequestConfig) => {
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');
}
}
};

tc = new TonClient({
endpoint: network === 'mainnet' ? 'https://toncenter.com/api/v2/jsonRPC' : 'https://testnet.toncenter.com/api/v2/jsonRPC',
httpAdapter,
});
}

Expand Down
7 changes: 5 additions & 2 deletions src/network/send/MnemonicProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {
WalletContractV3R1,
WalletContractV3R2,
WalletContractV4,
WalletContractV5R1,
} from '@ton/ton';
import {
Address,
Expand All @@ -34,7 +35,7 @@ interface WalletInstance extends Contract {
seqno: number;
secretKey: Buffer;
messages: MessageRelaxed[];
sendMode?: SendMode;
sendMode: SendMode;
timeout?: number;
},
): Promise<void>;
Expand All @@ -44,7 +45,7 @@ interface WalletClass {
create(args: { workchain: number; publicKey: Buffer }): WalletInstance;
}

export type WalletVersion = 'v1r1' | 'v1r2' | 'v1r3' | 'v2r1' | 'v2r2' | 'v3r1' | 'v3r2' | 'v4';
export type WalletVersion = 'v1r1' | 'v1r2' | 'v1r3' | 'v2r1' | 'v2r2' | 'v3r1' | 'v3r2' | 'v4' | 'v5r1';

const wallets: Record<WalletVersion, WalletClass> = {
v1r1: WalletContractV1R1,
Expand All @@ -55,6 +56,7 @@ const wallets: Record<WalletVersion, WalletClass> = {
v3r1: WalletContractV3R1,
v3r2: WalletContractV3R2,
v4: WalletContractV4,
v5r1: WalletContractV5R1,
};

export class MnemonicProvider implements SendProvider {
Expand Down Expand Up @@ -118,6 +120,7 @@ export class MnemonicProvider implements SendProvider {
},
},
],
sendMode: SendMode.PAY_GAS_SEPARATELY,
});

this.#ui.write('Sent transaction');
Expand Down
123 changes: 0 additions & 123 deletions src/network/send/TonHubProvider.ts

This file was deleted.

Loading

0 comments on commit ca4dcdd

Please sign in to comment.