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

TON Community Update: v4.1.0 #3

Open
wants to merge 11 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
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
54 changes: 53 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,61 @@ 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.7.1] - 2024-01-17

### Fixed

- Fixed incorrect VarUInt encoding of 0 (0 nanoTON, 0 jetton units, etc)

## [0.7.0] - 2023-09-15

### Changed

- Switched `ton-core` and `ton-crypto` to `@ton/core` and `@ton/crypto`

## [6.0.0] - 2023-07-11

### Removed

- Removed `unsafe` payload format

## [5.0.0] - 2023-06-29

### Removed

- Removed `decimals` and `ticker` from `jetton-transfer` request

## [4.1.0] - 2023-06-16

### Added

- Added `signData` method along with `SignDataRequest` type

## [4.0.1] - 2023-06-16

### Fixed

- Fixed the address flags communication

## [4.0.0] - 2023-06-09

### Added

- Added payload types for NFT and Jetton transfers
- Added TON Connect 2.0 address proof request

### Removed

- Removed old payload types except for comment and unsafe

### Changed

- Updated dependencies
- Changed APDU format to be the same as the latest embedded app version (breaking change)

## [3.0.0] - 2023-01-08

## Changed
### Changed

- Migration to `ton-core`

Expand Down
40 changes: 27 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ This library allows you to connect to a ledger device and with with TON from bro
To add library to your project execute:

```bash
yarn add ton-ledger
yarn add @ton-community/ton-ledger
```

## Connecting to a Device
Expand All @@ -29,7 +29,7 @@ React Native:

After connecting to a device create a TonTransport instance:
```typescript
import { TonTransport } from 'ton-ledger';
import { TonTransport } from '@ton-community/ton-ledger';
let transport = new TonTransport(device);
```

Expand Down Expand Up @@ -83,7 +83,7 @@ Ledger Nanoapp works with Wallet v4 for now, we recommend you to continue to use

```typescript
import { WalletV4Contract, WalletV4Source } from 'ton';
import { TonPayloadFormat } from 'ton-ledger';
import { TonPayloadFormat } from '@ton-community/ton-ledger';
import { TonClient, Address, SendMode, toNano } from 'ton-core';

let client = new TonClient({ endpoint: 'https://toncenter.com/api/v2/jsonRPC' });
Expand Down Expand Up @@ -118,28 +118,42 @@ await c.sendExternalMessage(contract, signed);

## Payload formats

Usually you want to perform transactions with some payload. Ledger's NanoApp currently supports 2 stable commands, all other are outdated or unstable:

### Transaction with a comment
Comments are limited to ASCII-only symbols and 127 letters. Anything above would be automatically downgraded to Blind Signing Mode that you want to avoid at all cost.

```typescript
let payload: TonPayloadFormat = {
const payload: TonPayloadFormat = {
type: 'comment',
text: 'Deposit'
};
```

### Unsafe with custom payload
### Jetton transfer

```typescript
const payload: TonPayloadFormat = {
type: 'jetton-transfer',
queryId: null, // null will be replaced with 0; you can pass any value of the BigInt type
amount: 1n,
destination: Address.parse('EQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAM9c'),
responseDestination: Address.parse('EQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAM9c'),
customPayload: null, // you can pass any value of the Cell type
forwardAmount: 0n,
forwardPayload: null // you can pass any value of the Cell type
};
```

This payload allows you to send arbitrary message, this is considered as Blind Signing Mode and only hash of your transaction would be shown to a user.
### NFT transfer

```typescript
let cell: Cell = ...
let message = new CellMessage(cell);
let payload: TonPayloadFormat = {
type: 'unsafe',
message
const payload: TonPayloadFormat = {
type: 'nft-transfer',
queryId: null, // null will be replaced with 0; you can pass any value of the BigInt type
newOwner: Address.parse('EQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAM9c'),
responseDestination: Address.parse('EQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAM9c'),
customPayload: null, // you can pass any value of the Cell type
forwardAmount: 0n,
forwardPayload: null // you can pass any value of the Cell type
};
```

Expand Down
32 changes: 16 additions & 16 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "ton-ledger",
"version": "3.0.0",
"repository": "https://github.com/ton-foundation/ton-ledger-ts.git",
"name": "@ton-community/ton-ledger",
"version": "7.0.1",
"repository": "https://github.com/ton-community/ton-ledger-ts",
"author": "Steve Korshakov <[email protected]>",
"license": "MIT",
"main": "dist/index.js",
Expand All @@ -15,24 +15,24 @@
"dev": "ts-node ./test/index.ts"
},
"peerDependencies": {
"ton-core": ">=0.44.0"
"@ton/core": ">=0.52.2"
},
"devDependencies": {
"@ledgerhq/hw-transport-node-hid": "^6.27.15",
"@release-it/keep-a-changelog": "^3.1.0",
"@ledgerhq/hw-transport-node-hid": "^6.27.1",
"@types/jest": "^29.2.4",
"@types/node": "^17.0.36",
"jest": "^29.3.1",
"release-it": "^15.5.1",
"ton-core": "^0.44.0",
"ts-jest": "^29.0.3",
"ts-node": "^10.8.0",
"typescript": "^4.7.2"
"@ton/core": "^0.52.2",
"@types/jest": "^29.5.2",
"@types/node": "^20.2.5",
"jest": "^29.5.0",
"release-it": "^15.11.0",
"ts-jest": "^29.1.0",
"ts-node": "^10.9.1",
"typescript": "^4.9.5"
},
"dependencies": {
"@ledgerhq/hw-transport": "^6.27.1",
"teslabot": "^1.5.0",
"ton-crypto": "^3.2.0"
"@ledgerhq/hw-transport": "^6.28.4",
"@ton/crypto": "^3.2.0",
"teslabot": "^1.5.0"
},
"publishConfig": {
"access": "public",
Expand Down
Loading