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: extend expiration time of tron transaction #3783

Merged
3 commits merged into from
Jul 7, 2023
Merged
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
12 changes: 12 additions & 0 deletions .pnpmfile.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,18 @@ function readPackage(pkg, context) {
addDependencies("documentation", {
micromark: "*",
}),
// TODO:
// Tron missing deps
// They are also added to live-common dependencies
// Is there another way without adding them explicitly ?
addDependencies("tronweb", {
"@ethersproject/bytes": "*",
"@ethersproject/bignumber": "*",
"@ethersproject/keccak256": "*",
"@ethersproject/properties": "*",
"@ethersproject/strings": "*",
"@ethersproject/logger": "*",
}),
],
pkg,
context,
Expand Down
7 changes: 7 additions & 0 deletions libs/ledger-live-common/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,12 @@
"@elrondnetwork/erdjs-network-providers": "^1.1.2",
"@ethereumjs/common": "^2.6.2",
"@ethereumjs/tx": "^3.5.0",
"@ethersproject/bignumber": "^5.7.0",
"@ethersproject/bytes": "^5.7.0",
"@ethersproject/keccak256": "^5.7.0",
"@ethersproject/logger": "^5.7.0",
"@ethersproject/properties": "^5.7.0",
"@ethersproject/strings": "^5.7.0",
This conversation was marked as resolved.
Show resolved Hide resolved
"@hashgraph/sdk": "^2.10.1",
"@keplr-wallet/cosmos": "^0.9.16",
"@keplr-wallet/proto-types": "^0.10.4",
Expand Down Expand Up @@ -235,6 +241,7 @@
"superstruct": "0.14.2",
"tiny-secp256k1": "^1.1.6",
"triple-beam": "^1.3.0",
"tronweb": "^5.2.0",
"utility-types": "^3.10.0",
"varuint-bitcoin": "1.1.2",
"winston": "^3.4.0",
Expand Down
16 changes: 15 additions & 1 deletion libs/ledger-live-common/src/families/tron/api/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import drop from "lodash/drop";
import get from "lodash/get";
import sumBy from "lodash/sumBy";
import take from "lodash/take";
import TronWeb from "tronweb";
import { getEnv } from "../../../env";
import { TronTransactionExpired } from "../../../errors";
import { promiseAllBatched } from "../../../promise";
Expand Down Expand Up @@ -140,10 +141,23 @@ export const createTronTransaction = async (
? `${getBaseApiUrl()}/wallet/transferasset`
: `${getBaseApiUrl()}/wallet/createtransaction`;
const preparedTransaction = await post(url, txData);
return preparedTransaction;
// for the ledger Vault we need to increase the expiration
return extendTronTxExpirationTimeBy10mn(preparedTransaction);
}
};

function extendTronTxExpirationTimeBy10mn(
preparedTransaction,
): Promise<SendTransactionDataSuccess> {
const VAULT_EXPIRATION_TIME = 600;
const HttpProvider = TronWeb.providers.HttpProvider;
const fullNode = new HttpProvider(getBaseApiUrl());
const solidityNode = new HttpProvider(getBaseApiUrl());
const eventServer = new HttpProvider(getBaseApiUrl());
const tronWeb = new TronWeb(fullNode, solidityNode, eventServer);
return tronWeb.transactionBuilder.extendExpiration(preparedTransaction, VAULT_EXPIRATION_TIME);
This conversation was marked as resolved.
Show resolved Hide resolved
}

export const broadcastTron = async (trxTransaction: SendTransactionDataSuccess) => {
const result = await post(`${getBaseApiUrl()}/wallet/broadcasttransaction`, trxTransaction);

Expand Down
Loading
Loading