Skip to content

Commit

Permalink
Merge pull request #4442 from BitGo/BTC-1084-revert-clone
Browse files Browse the repository at this point in the history
Revert "feat: protect pass by value when sending data out"
  • Loading branch information
lcovar authored Apr 17, 2024
2 parents a8528d3 + ef1497f commit e9d620f
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 14 deletions.
4 changes: 2 additions & 2 deletions modules/sdk-api/src/bitgoAPI.ts
Original file line number Diff line number Diff line change
Expand Up @@ -683,12 +683,12 @@ export class BitGoAPI implements BitGoBase {
* Caution: contains sensitive data
*/
toJSON(): BitGoJson {
return structuredClone({
return {
user: this._user,
token: this._token,
extensionKey: this._extensionKey ? this._extensionKey.toWIF() : undefined,
ecdhXprv: this._ecdhXprv,
});
};
}

/**
Expand Down
2 changes: 1 addition & 1 deletion modules/sdk-coin-ada/src/lib/transactionBuilder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -503,6 +503,6 @@ export abstract class TransactionBuilder extends BaseTransactionBuilder {
}

private getAllSignatures(): Signature[] {
return structuredClone(this._initSignatures.concat(this._signatures));
return this._initSignatures.concat(this._signatures);
}
}
4 changes: 2 additions & 2 deletions modules/sdk-coin-algo/src/lib/transaction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -139,15 +139,15 @@ export class Transaction extends BaseTransaction {
}

get signers(): string[] {
return structuredClone(this._signers);
return this._signers;
}

set signedBy(signer: string[]) {
this._signedBy = signer;
}

get signedBy(): string[] {
return structuredClone(this._signedBy);
return this._signedBy;
}

/**
Expand Down
2 changes: 1 addition & 1 deletion modules/sdk-coin-xtz/src/lib/transaction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,7 @@ export class Transaction extends BaseTransaction {
}

get owners(): string[] {
return structuredClone(this._owners);
return this._owners;
}

/**
Expand Down
2 changes: 1 addition & 1 deletion modules/sdk-core/src/bitgo/address-book/address-book.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export class AddressBook implements IAddressBook {
* TODO(PX-2794): Move to structuredClone
* https://github.com/BitGo/BitGoJS/pull/4119
*/
return structuredClone(this._listing);
return JSON.parse(JSON.stringify(this._listing));
}

/**
Expand Down
14 changes: 7 additions & 7 deletions modules/sdk-core/src/bitgo/wallet/wallet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ export class Wallet implements IWallet {
}

public flags(): { name: string; value: string }[] {
return structuredClone(this._wallet.walletFlags ?? []);
return this._wallet.walletFlags ?? [];
}

public flag(name: string): string | undefined {
Expand All @@ -282,7 +282,7 @@ export class Wallet implements IWallet {
* Get the public object ids for the keychains on this wallet.
*/
public keyIds(): string[] {
return structuredClone(this._wallet.keys);
return this._wallet.keys;
}

/**
Expand Down Expand Up @@ -317,7 +317,7 @@ export class Wallet implements IWallet {
* Get wallet properties which are specific to certain coin implementations
*/
coinSpecific(): WalletCoinSpecific | undefined {
return structuredClone(this._wallet.coinSpecific);
return this._wallet.coinSpecific;
}

/**
Expand Down Expand Up @@ -831,7 +831,7 @@ export class Wallet implements IWallet {
}
const url = this.url(`/address/${encodeURIComponent(query)}/deployment`);
this._wallet = await this.bitgo.post(url).send(params).result();
return structuredClone(this._wallet);
return this._wallet;
}

/**
Expand All @@ -858,7 +858,7 @@ export class Wallet implements IWallet {
}
const url = this.url(`/address/${encodeURIComponent(query)}/tokenforward`);
this._wallet = await this.bitgo.post(url).send(params).result();
return structuredClone(this._wallet);
return this._wallet;
}

/**
Expand Down Expand Up @@ -2479,7 +2479,7 @@ export class Wallet implements IWallet {
* Extract a JSON representable version of this wallet
*/
toJSON(): WalletData {
return structuredClone(this._wallet);
return this._wallet;
}

/**
Expand Down Expand Up @@ -3335,7 +3335,7 @@ export class Wallet implements IWallet {
}
const url = this.url('/fundForwarder');
this._wallet = await this.bitgo.post(url).send(params).result();
return structuredClone(this._wallet);
return this._wallet;
}

/**
Expand Down

0 comments on commit e9d620f

Please sign in to comment.