Skip to content

Commit

Permalink
Merge pull request #598 from tronprotocol/release/6.0.1
Browse files Browse the repository at this point in the history
Release/6.0.1
  • Loading branch information
unicornonea authored Jan 17, 2025
2 parents 7055429 + 73fc6b3 commit 582e3a1
Show file tree
Hide file tree
Showing 21 changed files with 274 additions and 78 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
Change Log
=========

__6.0.1__
- Support deserialize TriggerSmartContract transaction by raw_data_hex.
- Replace `@tronweb3/google-protobuf` with `google-protobuf`.
- Fix some type errors and API return type compatibility issues.

__6.0.0__
- Fix [issue543](https://github.com/tronprotocol/tronweb/issues/543), replace type AxiosHeaders with InstanceType<typeof AxiosHeaders>.
- Add type for value field in the return of the creation by TransactionBuilder methods.
Expand Down
16 changes: 15 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ First of all, in your typescript file, define TronWeb:
import { TronWeb, utils as TronWebUtils, Trx, TransactionBuilder, Contract, Event, Plugin } from 'tronweb';
```

Please note that this is not the same as v5.x. If you want to dive into more differences, check out [migration guide](https://tronweb.network/docu/docs/6.0.0/Migrating%20from%20v5)
Please note that this is not the same as v5.x. If you want to dive into more differences, check out [migration guide](https://tronweb.network/docu/docs/Migrating%20from%20v5)

When you instantiate TronWeb you can define

Expand Down Expand Up @@ -170,6 +170,20 @@ const tronWeb = new TronWeb({
)
```

## FAQ

1. Cannot destructure property 'Transaction' of 'globalThis.TronWebProto' as it is undefined.

This is a problem caused by webpack as it doesn't load cjs file correctly. To solve this problem, you need to add a new rule like below:
```
{
test: /\.cjs$/,
type: 'javascript/auto'
}
```

For more questions, please refer to [TronWeb Doc](https://tronweb.network/docu/docs/Migrating%20from%20v5#faq).

## Integrity Check

The package files will be signed using a GPG key pair, and the correctness of the signature will be verified using the following public key:
Expand Down
86 changes: 47 additions & 39 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "tronweb",
"version": "6.0.0",
"version": "6.0.1",
"description": "JavaScript SDK that encapsulates the TRON HTTP API",
"main": "./lib/commonjs/index.js",
"module": "./lib/esm/index.js",
Expand Down Expand Up @@ -58,12 +58,12 @@
},
"dependencies": {
"@babel/runtime": "^7.0.0",
"@tronweb3/google-protobuf": "^3.21.2",
"axios": "^1.7.4",
"bignumber.js": "^9.0.1",
"ethereum-cryptography": "^2.1.3",
"ethers": "^6.13.1",
"ethers": "^6.13.4",
"eventemitter3": "^3.1.0",
"google-protobuf": "^3.21.4",
"semver": "^5.6.0",
"validator": "^13.7.0"
},
Expand Down
22 changes: 11 additions & 11 deletions src/lib/trx.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { ADDRESS_PREFIX } from '../utils/address.js';
import { Validator } from '../paramValidator/index.js';
import { txCheck } from '../utils/transaction.js';
import { ecRecover } from '../utils/crypto.js';
import { Block } from '../types/APIResponse.js';
import { Block, GetTransactionResponse } from '../types/APIResponse.js';
import {
Token,
Account,
Expand Down Expand Up @@ -145,7 +145,7 @@ export class Trx {
async getTransactionFromBlock(
block: 'earliest' | 'latest' | number | string | false = this.tronWeb.defaultBlock,
index: number
): Promise<Transaction> {
): Promise<GetTransactionResponse> {
const { transactions } = await this.getBlock(block);
if (!transactions) {
throw new Error('Transaction not found in block');
Expand All @@ -156,16 +156,16 @@ export class Trx {

async getTransactionsFromBlock(
block: 'earliest' | 'latest' | number | string | false = this.tronWeb.defaultBlock
): Promise<Transaction[]> {
): Promise<GetTransactionResponse[]> {
const { transactions } = await this.getBlock(block);
if (!transactions) {
throw new Error('Transaction not found in block');
}
return transactions;
}

async getTransaction(transactionID: string): Promise<Transaction> {
const transaction = await this.tronWeb.fullNode.request<Transaction>(
async getTransaction(transactionID: string): Promise<GetTransactionResponse> {
const transaction = await this.tronWeb.fullNode.request<GetTransactionResponse>(
'wallet/gettransactionbyid',
{
value: transactionID,
Expand All @@ -178,8 +178,8 @@ export class Trx {
return transaction;
}

async getConfirmedTransaction(transactionID: string): Promise<Transaction> {
const transaction = await this.tronWeb.solidityNode.request<Transaction>(
async getConfirmedTransaction(transactionID: string): Promise<GetTransactionResponse> {
const transaction = await this.tronWeb.solidityNode.request<GetTransactionResponse>(
'walletsolidity/gettransactionbyid',
{
value: transactionID,
Expand All @@ -200,11 +200,11 @@ export class Trx {
return this.tronWeb.solidityNode.request('walletsolidity/gettransactioninfobyid', { value: transactionID }, 'post');
}

getTransactionsToAddress(address = this.tronWeb.defaultAddress.hex, limit = 30, offset = 0): Promise<Transaction[]> {
getTransactionsToAddress(address = this.tronWeb.defaultAddress.hex, limit = 30, offset = 0): Promise<GetTransactionResponse[]> {
return this.getTransactionsRelated(this.tronWeb.address.toHex(address as string), 'to', limit, offset);
}

getTransactionsFromAddress(address = this.tronWeb.defaultAddress.hex, limit = 30, offset = 0): Promise<Transaction[]> {
getTransactionsFromAddress(address = this.tronWeb.defaultAddress.hex, limit = 30, offset = 0): Promise<GetTransactionResponse[]> {
return this.getTransactionsRelated(this.tronWeb.address.toHex(address as string), 'from', limit, offset);
}

Expand All @@ -213,7 +213,7 @@ export class Trx {
direction = 'all',
limit = 30,
offset = 0
): Promise<Transaction[]> {
): Promise<GetTransactionResponse[]> {
if (!['to', 'from', 'all'].includes(direction)) {
throw new Error('Invalid direction provided: Expected "to", "from" or "all"');
}
Expand Down Expand Up @@ -247,7 +247,7 @@ export class Trx {
address = this.tronWeb.address.toHex(address as string);

return this.tronWeb.solidityNode
.request<{ transaction: Transaction[] }>(
.request<{ transaction: GetTransactionResponse[] }>(
`walletextension/gettransactions${direction}this`,
{
account: {
Expand Down
4 changes: 2 additions & 2 deletions src/protocol/core/Tron_pb.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
/* eslint-disable */
// @ts-nocheck

var jspb = require('@tronweb3/google-protobuf');
var jspb = require('google-protobuf');
var goog = jspb;
var global =
(typeof globalThis !== 'undefined' && globalThis) ||
Expand All @@ -21,7 +21,7 @@ var global =
(function () { return this; }).call(null) ||
Function('return this')();

var google_protobuf_any_pb = require('@tronweb3/google-protobuf/google/protobuf/any_pb.js');
var google_protobuf_any_pb = require('google-protobuf/google/protobuf/any_pb.js');
goog.object.extend(proto, google_protobuf_any_pb);
goog.exportSymbol('TronWebProto.Account', null, global);
goog.exportSymbol('TronWebProto.Account.AccountResource', null, global);
Expand Down
2 changes: 1 addition & 1 deletion src/protocol/core/contract/account_contract_pb.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
/* eslint-disable */
// @ts-nocheck

var jspb = require('@tronweb3/google-protobuf');
var jspb = require('google-protobuf');
var goog = jspb;
var global =
(typeof globalThis !== 'undefined' && globalThis) ||
Expand Down
2 changes: 1 addition & 1 deletion src/protocol/core/contract/asset_issue_contract_pb.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
/* eslint-disable */
// @ts-nocheck

var jspb = require('@tronweb3/google-protobuf');
var jspb = require('google-protobuf');
var goog = jspb;
var global =
(typeof globalThis !== 'undefined' && globalThis) ||
Expand Down
2 changes: 1 addition & 1 deletion src/protocol/core/contract/balance_contract_pb.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
/* eslint-disable */
// @ts-nocheck

var jspb = require('@tronweb3/google-protobuf');
var jspb = require('google-protobuf');
var goog = jspb;
var global =
(typeof globalThis !== 'undefined' && globalThis) ||
Expand Down
Loading

0 comments on commit 582e3a1

Please sign in to comment.