Skip to content

Commit

Permalink
Merge branch 'ps/chore/added-on-before-send-hook' of github.com:FuelL…
Browse files Browse the repository at this point in the history
…abs/fuels-ts into ps/chore/added-on-before-send-hook
  • Loading branch information
petertonysmith94 committed Dec 16, 2024
2 parents 7269d45 + 2dbae8e commit de83c9f
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 6 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/pr-release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ jobs:
name: "Release PR to npm"
runs-on: ubuntu-latest
# comment out if:false to enable release PR to npm
if: false
# if: false
permissions: write-all
steps:
- name: Checkout
Expand Down
4 changes: 2 additions & 2 deletions packages/account/src/account.ts
Original file line number Diff line number Diff line change
Expand Up @@ -646,11 +646,11 @@ export class Account extends AbstractAccount {
*/
async sendTransaction(
transactionRequestLike: TransactionRequestLike,
{ estimateTxDependencies = true }: ProviderSendTxParams = {}
{ estimateTxDependencies = true, onBeforeSend }: ProviderSendTxParams = {}
): Promise<TransactionResponse> {
if (this._connector) {
return this.provider.getTransactionResponse(
await this._connector.sendTransaction(this.address.toString(), transactionRequestLike)
await this._connector.sendTransaction(this.address.toString(), transactionRequestLike, { onBeforeSend })
);
}
const transactionRequest = transactionRequestify(transactionRequestLike);
Expand Down
5 changes: 3 additions & 2 deletions packages/account/src/connectors/fuel-connector.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import type {
FuelEventArg,
Version,
SelectNetworkArguments,
SendTransactionParams,
} from './types';

interface Connector {
Expand Down Expand Up @@ -42,7 +43,7 @@ interface Connector {
signTransaction(address: string, transaction: TransactionRequestLike): Promise<string>;
// #endregion fuel-connector-method-signTransaction
// #region fuel-connector-method-sendTransaction
sendTransaction(address: string, transaction: TransactionRequestLike): Promise<string>;
sendTransaction(address: string, transaction: TransactionRequestLike, params?: SendTransactionParams): Promise<string>;
// #endregion fuel-connector-method-sendTransaction
// #region fuel-connector-method-currentAccount
currentAccount(): Promise<string | null>;
Expand Down Expand Up @@ -196,7 +197,7 @@ export abstract class FuelConnector extends EventEmitter implements Connector {
*
* @returns The transaction id
*/
async sendTransaction(_address: string, _transaction: TransactionRequestLike): Promise<string> {
async sendTransaction(_address: string, _transaction: TransactionRequestLike, params?: SendTransactionParams): Promise<string> {

Check warning on line 200 in packages/account/src/connectors/fuel-connector.ts

View workflow job for this annotation

GitHub Actions / Lint

'params' is defined but never used. Allowed unused args must match /^_/u
throw new FuelError(FuelError.CODES.NOT_IMPLEMENTED, 'Method not implemented.');
}

Expand Down
5 changes: 5 additions & 0 deletions packages/account/src/connectors/types/data-type.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import type { JsonAbi } from '@fuel-ts/abi-coder';
import type { RequireAtLeastOne } from 'type-fest';

Check failure on line 2 in packages/account/src/connectors/types/data-type.ts

View workflow job for this annotation

GitHub Actions / Lint

There should be at least one empty line between import groups
import type { TransactionRequest } from '../../providers';

/**
* @name Version
Expand Down Expand Up @@ -42,3 +43,7 @@ export type SelectNetworkArguments = RequireAtLeastOne<Network, 'chainId' | 'url
* Read more at: https://docs.fuel.network/docs/specs/abi/json-abi-format/
*/
export type FuelABI = JsonAbi;

export type SendTransactionParams = {
onBeforeSend?: (txRequest: TransactionRequest) => TransactionRequest;
}
4 changes: 3 additions & 1 deletion packages/account/src/providers/provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -363,7 +363,9 @@ export type ProviderCallParams = UTXOValidationParams & EstimateTransactionParam
/**
* Provider Send transaction params
*/
export type ProviderSendTxParams = EstimateTransactionParams;
export type ProviderSendTxParams = EstimateTransactionParams & {
onBeforeSend?: (txRequest: TransactionRequest) => TransactionRequest;
};

/**
* URL - Consensus Params mapping.
Expand Down

0 comments on commit de83c9f

Please sign in to comment.