Skip to content

Commit

Permalink
feat: depreciate format() methods. (#1120)
Browse files Browse the repository at this point in the history
feat: depreciate format methods.
  • Loading branch information
b4rtaz authored May 10, 2023
1 parent 06a3fb1 commit 833feaf
Show file tree
Hide file tree
Showing 38 changed files with 48 additions and 124 deletions.
9 changes: 9 additions & 0 deletions .changeset/mighty-carrots-tickle.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
'@moralisweb3/common-streams-utils': minor
'@moralisweb3/common-aptos-utils': minor
'@moralisweb3/common-evm-utils': minor
'@moralisweb3/common-sol-utils': minor
'moralis': minor
---

**Breaking change**: All `format()` methods are deprecated now.
Original file line number Diff line number Diff line change
Expand Up @@ -60,12 +60,9 @@ export class AptosAddress implements MoralisData {
public constructor(public readonly address: string) {}

/**
* Formats the address to hex format.
* Currently returns a string representing the address.
* @example address.format(); // "0x54ad3d30af77b60d939ae356e6606de9a4da67583f02b962d2d3f2e481484e90"
* @deprecated This method will be removed soon. To format the value, use one of the properties.
*/
public format(): MoralisDataFormatted {
// TODO: add `format` argument
return this.address;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,12 +102,9 @@ export class AptosNative implements MoralisData {
}

/**
* Converts the AptosNative to a string.
* @returns the value of the AptosNative as a string
* @example `native.format()`
* @deprecated This method will be removed soon. To format the value, use one of the properties.
*/
public format(): MoralisDataFormatted {
// TODO: add `format` argument
return this.octas;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,12 +97,9 @@ export class AptosNetwork implements MoralisData {
private constructor(public readonly network: AptosNetworkName) {}

/**
* Formats the network to a specific format.
* Currently returns a string representing the network.
* @example network.format(); // "mainnet"
* @deprecated This method will be removed soon. To format the value, use one of the properties.
*/
public format(): MoralisDataFormatted {
// TODO: add `format` argument
return this.network;
}

Expand Down
8 changes: 1 addition & 7 deletions packages/common/evmUtils/src/dataTypes/Erc20/Erc20.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,13 +108,7 @@ export class Erc20Token implements MoralisDataObject {
}

/**
* Returns the token as JSON
*
* @returns the Erc20Token as a JSON object
* @example
* ```ts
* token.format();
* ```
* @deprecated This method will be removed soon. To format the value, use one of the properties.
*/
format() {
return this.toJSON();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,7 @@ export class Erc20Approval implements MoralisDataObject {
}

/**
* @returns a JSON representation of the approval.
* @example approval.format()
* @deprecated This method will be removed soon. To format the value, use one of the properties.
*/
format() {
return this.toJSON();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,7 @@ export class Erc20Burn implements MoralisDataObject {
}

/**
* @returns a JSON representation of the burn.
* @example burn.format()
* @deprecated This method will be removed soon. To format the value, use one of the properties.
*/
format() {
return this.toJSON();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,7 @@ export class Erc20Mint implements MoralisDataObject {
}

/**
* @returns a JSON representation of the mint.
* @example mint.format()
* @deprecated This method will be removed soon. To format the value, use one of the properties.
*/
format() {
return this.toJSON();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,7 @@ export class Erc20Transfer implements MoralisDataObject {
}

/**
* @returns a JSON represention of the transfer.
* @example transfer.format()
* @deprecated This method will be removed soon. To format the value, use one of the properties.
*/
format() {
return this.toJSON();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -156,9 +156,7 @@ export class Erc20Value implements MoralisData {
};

/**
* Convert the value to a string
* @returns the value in string format
* @example value.format();
* @deprecated This method will be removed soon. To format the value, use one of the properties.
*/
format(): string {
return this.toString();
Expand Down
6 changes: 1 addition & 5 deletions packages/common/evmUtils/src/dataTypes/EvmBlock/EvmBlock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,11 +107,7 @@ export class EvmBlock implements MoralisDataObject {
}

/**
* @returns a JSON represention of the block.
* @example
* ```
* block.format()
* ```
* @deprecated This method will be removed soon. To format the value, use one of the properties.
*/
format() {
return this.toJSON();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,11 +94,7 @@ export class EvmSimpleBlock implements MoralisDataObject {
}

/**
* @returns a JSON represention of the block.
* @example
* ```
* block.format()
* ```
* @deprecated This method will be removed soon. To format the value, use one of the properties.
*/
format() {
return this.toJSON();
Expand Down
3 changes: 1 addition & 2 deletions packages/common/evmUtils/src/dataTypes/EvmEvent/EvmEvent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,8 +117,7 @@ export class EvmEvent implements MoralisDataObject {
}

/**
* @returns a JSON represention of the event.
* @example event.format()
* @deprecated This method will be removed soon. To format the value, use one of the properties.
*/
format() {
return this.toJSON();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,11 +104,7 @@ export class EvmInternalTransaction implements MoralisDataObject {
}

/**
* @returns a JSON represention of the transaction.
* @example
* ```
* transaction.format()
* ```
* @deprecated This method will be removed soon. To format the value, use one of the properties.
*/
format() {
return this.toJSON();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,9 +153,7 @@ export class EvmNative implements MoralisData {
}

/**
* Converts the EvmNative to a string.
* @returns the value of the EvmNative as a string
* @example `native.format()`
* @deprecated This method will be removed soon. To format the value, use one of the properties.
*/
public format(): string {
return this.toString();
Expand Down
4 changes: 1 addition & 3 deletions packages/common/evmUtils/src/dataTypes/EvmNft/EvmNft.ts
Original file line number Diff line number Diff line change
Expand Up @@ -153,9 +153,7 @@ export class EvmNft implements MoralisDataObject {
}

/**
* Converts the EvmNft instance to a JSON object.
* @returns JSON object of the EvmNft instance
* @example `nft.format()`
* @deprecated This method will be removed soon. To format the value, use one of the properties.
*/
format() {
return this.toJSON();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,11 +90,7 @@ export class EvmNftCollection implements MoralisDataObject {
}

/**
* @returns a JSON represention of the collection.
* @example
* ```
* collection.format()
* ```
* @deprecated This method will be removed soon. To format the value, use one of the properties.
*/
format() {
return this.toJSON();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,7 @@ export class EvmNftMedia implements MoralisDataObject {
}

/**
* @returns a JSON representation of the media.
* @example media.format()
* @deprecated This method will be removed soon. To format the value, use one of the properties.
*/
format() {
return this.toJSON();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,7 @@ export class EvmNftMetadata implements MoralisDataObject {
}

/**
* @returns the data as JSON.
* @example metadata.format();
* @deprecated This method will be removed soon. To format the value, use one of the properties.
*/
format() {
return this.toJSON();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,9 @@ export class EvmSignature implements MoralisDataObject {
};
}

/**
* @deprecated This method will be removed soon. To format the value, use one of the properties.
*/
format() {
return this.serialized;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,11 +135,7 @@ export class EvmTransaction implements MoralisDataObject {
}

/**
* @returns a JSON represention of the transaction.
* @example
* ```
* transaction.format()
* ```
* @deprecated This method will be removed soon. To format the value, use one of the properties.
*/
format() {
return this.toJSON();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,13 +93,7 @@ export class EvmTransactionLog implements MoralisDataObject {
}

/**
* Converts the log to a JSON object.
*
* @returns the EvmTransactionLog as a JSON object
* @example
* ```ts
* log.format();
* ```
* @deprecated This method will be removed soon. To format the value, use one of the properties.
*/
format() {
return this.toJSON();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,9 @@ export class SolAddress implements MoralisData {
public constructor(public readonly address: string) {}

/**
* Formats the address to a specific format.
* Currently returns a string representing the address.
* @example address.format(); // "9WzDXwBbmkg8ZTbNMqUxvQRAyrZzDsGYdLVL9zYtAWWM"
* @deprecated This method will be removed soon. To format the value, use one of the properties.
*/
public format(): MoralisDataFormatted {
// TODO: add `format` argument
return this.address;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,7 @@ export class SolNative implements MoralisData {
}

/**
* Converts the SolNative to a string.
* @returns the value of the SolNative as a string
* @example `native.format()`
* @deprecated This method will be removed soon. To format the value, use one of the properties.
*/
public format(): MoralisDataFormatted {
// TODO: add `format` argument
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,12 +77,9 @@ export class SolNetwork implements MoralisData {
private constructor(public readonly network: SolNetworkName) {}

/**
* Formats the network to a specific format.
* Currently returns a string representing the network.
* @example network.format(); // "mainnet"
* @deprecated This method will be removed soon. To format the value, use one of the properties.
*/
public format(): MoralisDataFormatted {
// TODO: add `format` argument
return this.network;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,9 +108,7 @@ export class EvmStream implements MoralisDataObject {
}

/**
* Converts the EvmStream instance to a JSON object.
* @returns JSON object of the EvmStream instance
* @example `evmStream.format()`
* @deprecated This method will be removed soon. To format the value, use one of the properties.
*/
format() {
return this.toJSON();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,9 +101,7 @@ export class EvmStreamResult implements MoralisDataObject {
}

/**
* Converts the EvmStreamResult instance to a JSON object.
* @returns JSON object of the EvmStreamResult instance
* @example `evmStreamResult.format()`
* @deprecated This method will be removed soon. To format the value, use one of the properties.
*/
format() {
return this.toJSON();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,9 +119,7 @@ export class StreamErc20Approval implements MoralisDataObject {
}

/**
* Converts the StreamErc20Approval instance to a JSON object.
* @returns JSON object of the StreamErc20Approval instance
* @example `erc20Approval.format()`
* @deprecated This method will be removed soon. To format the value, use one of the properties.
*/
format() {
return this.toJSON();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,9 +119,7 @@ export class StreamErc20Transfer implements MoralisDataObject {
}

/**
* Converts the StreamErc20Transfer instance to a JSON object.
* @returns JSON object of the StreamErc20Transfer instance
* @example `erc20Transfer.format()`
* @deprecated This method will be removed soon. To format the value, use one of the properties.
*/
format() {
return this.toJSON();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,9 +128,7 @@ export class StreamErc721Approval implements MoralisDataObject {
}

/**
* Converts the StreamErc721Approval instance to a JSON object.
* @returns JSON object of the StreamErc721Approval instance
* @example `evmNftApproval.format()`
* @deprecated This method will be removed soon. To format the value, use one of the properties.
*/
format() {
return this.toJSON();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,9 +112,7 @@ export class StreamEvmInternalTransaction implements MoralisDataObject {
}

/**
* Converts the StreamEvmInternalTransaction instance to a JSON object.
* @returns JSON object of the StreamEvmInternalTransaction instance
* @example `evmInternalTransaction.format()`
* @deprecated This method will be removed soon. To format the value, use one of the properties.
*/
format() {
return this.toJSON();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,9 +128,7 @@ export class StreamEvmNftTransfer implements MoralisDataObject {
}

/**
* Converts the StreamEvmNftTransfer instance to a JSON object.
* @returns JSON object of the StreamEvmNftTransfer instance
* @example `transfer.toJSON()`
* @deprecated This method will be removed soon. To format the value, use one of the properties.
*/
format() {
return this.toJSON();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -149,9 +149,7 @@ export class StreamEvmTransaction implements MoralisDataObject {
}

/**
* Converts the StreamEvmTransaction instance to a JSON object.
* @returns JSON object of the StreamEvmTransaction instance
* @example `transaction.toJSON()`
* @deprecated This method will be removed soon. To format the value, use one of the properties.
*/
format() {
return this.toJSON();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,9 +114,7 @@ export class StreamEvmTransactionLog implements MoralisDataObject {
}

/**
* Converts the StreamEvmTransactionLog instance to a JSON object.
* @returns JSON object of the StreamEvmTransactionLog instance
* @example `transactionLog.toJSON()`
* @deprecated This method will be removed soon. To format the value, use one of the properties.
*/
format() {
return this.toJSON();
Expand Down
Loading

1 comment on commit 833feaf

@github-actions
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Test coverage

Title Lines Statements Branches Functions
api-utils Coverage: 20%
20.6% (61/296) 20.48% (17/83) 19.04% (12/63)
auth Coverage: 89%
92.45% (98/106) 83.33% (20/24) 86.66% (26/30)
evm-api Coverage: 96%
96.84% (92/95) 66.66% (6/9) 95.16% (59/62)
common-aptos-utils Coverage: 4%
4.56% (151/3307) 4.64% (25/538) 5.52% (45/814)
common-evm-utils Coverage: 66%
66.74% (1435/2150) 28.03% (256/913) 45.54% (394/865)
sol-api Coverage: 96%
97.5% (39/40) 66.66% (6/9) 93.33% (14/15)
common-sol-utils Coverage: 74%
74.55% (167/224) 66.66% (18/27) 65.38% (51/78)
common-streams-utils Coverage: 90%
90.73% (1204/1327) 73.63% (363/493) 82.07% (444/541)
streams Coverage: 88%
88.2% (576/653) 68.81% (64/93) 88.02% (125/142)

Please sign in to comment.