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: return deep clone on transaction request from method #3097

Merged
merged 8 commits into from
Sep 4, 2024
Merged
Show file tree
Hide file tree
Changes from 6 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
5 changes: 5 additions & 0 deletions .changeset/curvy-melons-itch.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@fuel-ts/account": patch
---

feat: return deep clone on transaction request `from` method
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import type { BN } from '@fuel-ts/math';
import type { TransactionBlob } from '@fuel-ts/transactions';
import { clone } from 'ramda';

import type { GasCosts } from '../provider';
import { calculateMetadataGasForTxBlob } from '../utils';
Expand All @@ -17,10 +18,7 @@ export interface BlobTransactionRequestLike extends BaseTransactionRequestLike {

export class BlobTransactionRequest extends BaseTransactionRequest {
static from(obj: BlobTransactionRequestLike) {
if (obj instanceof this) {
return obj;
}
return new this(obj);
return new this(clone(obj));
maschad marked this conversation as resolved.
Show resolved Hide resolved
}

/** Type of the transaction */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { bn, type BN } from '@fuel-ts/math';
import type { TransactionCreate } from '@fuel-ts/transactions';
import { TransactionType, OutputType } from '@fuel-ts/transactions';
import { arrayify, hexlify } from '@fuel-ts/utils';
import { clone } from 'ramda';

import type { GqlGasCosts } from '../__generated__/operations';
import { calculateMetadataGasForTxCreate } from '../utils/gas';
Expand Down Expand Up @@ -32,10 +33,7 @@ export interface CreateTransactionRequestLike extends BaseTransactionRequestLike
*/
export class CreateTransactionRequest extends BaseTransactionRequest {
static from(obj: CreateTransactionRequestLike) {
if (obj instanceof this) {
return obj;
}
return new this(obj);
return new this(clone(obj));
}

/** Type of the transaction */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import type { BN, BigNumberish } from '@fuel-ts/math';
import type { TransactionScript } from '@fuel-ts/transactions';
import { InputType, OutputType, TransactionType } from '@fuel-ts/transactions';
import { arrayify, hexlify } from '@fuel-ts/utils';
import { clone } from 'ramda';

import type { ChainInfo, GasCosts } from '../provider';
import { calculateMetadataGasForTxScript, getMaxGas } from '../utils/gas';
Expand Down Expand Up @@ -39,10 +40,7 @@ export interface ScriptTransactionRequestLike extends BaseTransactionRequestLike
*/
export class ScriptTransactionRequest extends BaseTransactionRequest {
static from(obj: ScriptTransactionRequestLike) {
if (obj instanceof this) {
return obj;
}
return new this(obj);
return new this(clone(obj));
maschad marked this conversation as resolved.
Show resolved Hide resolved
}

/** Type of the transaction */
Expand Down