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: add Predicate.getTransferTxId helper #1467

Merged
merged 5 commits into from
Nov 30, 2023
Merged
Changes from 1 commit
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
Prev Previous commit
Next Next commit
refactor
Dhaiwat10 committed Nov 29, 2023
commit 3e34b3c8cf764a07b5d595085c89503526a231ad
7 changes: 1 addition & 6 deletions packages/predicate/src/predicate.ts
Original file line number Diff line number Diff line change
@@ -115,12 +115,7 @@ export class Predicate<ARGS extends InputValue[]> extends Account implements Abs
/** Tx Params */
txParams: TxParamsType = {}
): Promise<string> {
const request = await super.prepareTransferTxRequestForIdCalculation(
destination,
amount,
assetId,
txParams
);
const request = await super.prepareTransferTxRequest(destination, amount, assetId, txParams);
const populatedRequest = this.populateTransactionPredicateData(request);
return hashTransaction(populatedRequest, this.provider.getChainId());
}
11 changes: 2 additions & 9 deletions packages/wallet/src/account.ts
Original file line number Diff line number Diff line change
@@ -239,14 +239,7 @@ export class Account extends AbstractAccount {
/** Tx Params */
txParams: TxParamsType = {}
): Promise<TransactionResponse> {
const { maxGasPerTx } = this.provider.getGasConfig();
const params: TxParamsType = { gasLimit: maxGasPerTx, ...txParams };
const request = new ScriptTransactionRequest(params);
request.addCoinOutput(destination, amount, assetId);
const { maxFee, requiredQuantities } = await this.provider.getTransactionCost(request);

await this.fund(request, requiredQuantities, maxFee);

const request = await this.prepareTransferTxRequest(destination, amount, assetId, txParams);
return this.sendTransaction(request);
}

@@ -259,7 +252,7 @@ export class Account extends AbstractAccount {
* @param txParams - The transaction parameters (gasLimit, gasPrice, maturity).
* @returns A promise that resolves to the prepared transaction request.
*/
protected async prepareTransferTxRequestForIdCalculation(
protected async prepareTransferTxRequest(
/** Address of the destination */
destination: AbstractAddress,
/** Amount of coins */