From 5228b88849b285661ce90fc16c26ef992555c1ef Mon Sep 17 00:00:00 2001 From: Alexandru Popenta Date: Tue, 12 Dec 2023 18:19:12 +0200 Subject: [PATCH] mark old stuff as deprecated --- src/tokenOperations/tokenOperationsFactory.ts | 107 ++++++++---------- .../tokenOperationsFactoryConfig.ts | 7 +- .../transferTransactionsFactory.spec.ts | 4 +- .../transferTransactionsFactory.ts | 2 +- src/transferTransactionsFactory.ts | 39 ++++--- 5 files changed, 80 insertions(+), 79 deletions(-) diff --git a/src/tokenOperations/tokenOperationsFactory.ts b/src/tokenOperations/tokenOperationsFactory.ts index dfc02b5d..3d93592d 100644 --- a/src/tokenOperations/tokenOperationsFactory.ts +++ b/src/tokenOperations/tokenOperationsFactory.ts @@ -63,8 +63,7 @@ interface IIssueSemiFungibleArgs extends IBaseArgs { canAddSpecialRoles: boolean; } -interface IIssueNonFungibleArgs extends IIssueSemiFungibleArgs { -} +interface IIssueNonFungibleArgs extends IIssueSemiFungibleArgs {} interface IRegisterMetaESDT extends IIssueSemiFungibleArgs { numDecimals: number; @@ -146,14 +145,14 @@ interface ILocalMintArgs extends IBaseArgs { manager: IAddress; user: IAddress; tokenIdentifier: string; - supplyToMint: BigNumber.Value + supplyToMint: BigNumber.Value; } interface ILocalBurnArgs extends IBaseArgs { manager: IAddress; user: IAddress; tokenIdentifier: string; - supplyToBurn: BigNumber.Value + supplyToBurn: BigNumber.Value; } interface IUpdateAttributesArgs extends IBaseArgs { @@ -167,16 +166,19 @@ interface IAddQuantityArgs extends IBaseArgs { manager: IAddress; tokenIdentifier: string; tokenNonce: BigNumber.Value; - quantityToAdd: BigNumber.Value + quantityToAdd: BigNumber.Value; } interface IBurnQuantityArgs extends IBaseArgs { manager: IAddress; tokenIdentifier: string; tokenNonce: BigNumber.Value; - quantityToBurn: BigNumber.Value + quantityToBurn: BigNumber.Value; } +/** + * @deprecated Use {@link TokenManagementTransactionsFactory} instead. + */ export class TokenOperationsFactory { private readonly config: IConfig; private readonly trueAsHex; @@ -211,7 +213,7 @@ export class TokenOperationsFactory { gasPrice: args.gasPrice, gasLimitHint: args.gasLimit, executionGasLimit: this.config.gasLimitIssue, - dataParts: parts + dataParts: parts, }); } @@ -248,7 +250,7 @@ Once the token is registered, you can unset this role by calling "unsetBurnRoleG gasPrice: args.gasPrice, gasLimitHint: args.gasLimit, executionGasLimit: this.config.gasLimitIssue, - dataParts: parts + dataParts: parts, }); } @@ -276,7 +278,7 @@ Once the token is registered, you can unset this role by calling "unsetBurnRoleG gasPrice: args.gasPrice, gasLimitHint: args.gasLimit, executionGasLimit: this.config.gasLimitIssue, - dataParts: parts + dataParts: parts, }); } @@ -305,7 +307,7 @@ Once the token is registered, you can unset this role by calling "unsetBurnRoleG gasPrice: args.gasPrice, gasLimitHint: args.gasLimit, executionGasLimit: this.config.gasLimitIssue, - dataParts: parts + dataParts: parts, }); } @@ -317,7 +319,7 @@ Once the token is registered, you can unset this role by calling "unsetBurnRoleG utf8ToHex(args.tokenName), utf8ToHex(args.tokenTicker), utf8ToHex(args.tokenType), - bigIntToHex(args.numDecimals) + bigIntToHex(args.numDecimals), ]; return this.createTransaction({ @@ -328,15 +330,12 @@ Once the token is registered, you can unset this role by calling "unsetBurnRoleG gasPrice: args.gasPrice, gasLimitHint: args.gasLimit, executionGasLimit: this.config.gasLimitIssue, - dataParts: parts + dataParts: parts, }); } setBurnRoleGlobally(args: IToggleBurnRoleGloballyArgs): Transaction { - const parts = [ - "setBurnRoleGlobally", - utf8ToHex(args.tokenIdentifier) - ]; + const parts = ["setBurnRoleGlobally", utf8ToHex(args.tokenIdentifier)]; return this.createTransaction({ sender: args.manager, @@ -345,15 +344,12 @@ Once the token is registered, you can unset this role by calling "unsetBurnRoleG gasPrice: args.gasPrice, gasLimitHint: args.gasLimit, executionGasLimit: this.config.gasLimitToggleBurnRoleGlobally, - dataParts: parts + dataParts: parts, }); } unsetBurnRoleGlobally(args: IToggleBurnRoleGloballyArgs): Transaction { - const parts = [ - "unsetBurnRoleGlobally", - utf8ToHex(args.tokenIdentifier) - ]; + const parts = ["unsetBurnRoleGlobally", utf8ToHex(args.tokenIdentifier)]; return this.createTransaction({ sender: args.manager, @@ -362,7 +358,7 @@ Once the token is registered, you can unset this role by calling "unsetBurnRoleG gasPrice: args.gasPrice, gasLimitHint: args.gasLimit, executionGasLimit: this.config.gasLimitToggleBurnRoleGlobally, - dataParts: parts + dataParts: parts, }); } @@ -382,7 +378,7 @@ Once the token is registered, you can unset this role by calling "unsetBurnRoleG gasPrice: args.gasPrice, gasLimitHint: args.gasLimit, executionGasLimit: this.config.gasLimitSetSpecialRole, - dataParts: parts + dataParts: parts, }); } @@ -404,7 +400,7 @@ Once the token is registered, you can unset this role by calling "unsetBurnRoleG gasPrice: args.gasPrice, gasLimitHint: args.gasLimit, executionGasLimit: this.config.gasLimitSetSpecialRole, - dataParts: parts + dataParts: parts, }); } @@ -431,7 +427,7 @@ Once the token is registered, you can unset this role by calling "unsetBurnRoleG gasPrice: args.gasPrice, gasLimitHint: args.gasLimit, executionGasLimit: this.config.gasLimitSetSpecialRole, - dataParts: parts + dataParts: parts, }); } @@ -458,15 +454,12 @@ Once the token is registered, you can unset this role by calling "unsetBurnRoleG gasPrice: args.gasPrice, gasLimitHint: args.gasLimit, executionGasLimit: this.config.gasLimitESDTNFTCreate.valueOf() + storageGasLimit.valueOf(), - dataParts: parts + dataParts: parts, }); } pause(args: IPausingArgs): Transaction { - const parts = [ - "pause", - utf8ToHex(args.tokenIdentifier) - ]; + const parts = ["pause", utf8ToHex(args.tokenIdentifier)]; return this.createTransaction({ sender: args.manager, @@ -475,15 +468,12 @@ Once the token is registered, you can unset this role by calling "unsetBurnRoleG gasPrice: args.gasPrice, gasLimitHint: args.gasLimit, executionGasLimit: this.config.gasLimitPausing, - dataParts: parts + dataParts: parts, }); } unpause(args: IPausingArgs): Transaction { - const parts = [ - "unPause", - utf8ToHex(args.tokenIdentifier) - ]; + const parts = ["unPause", utf8ToHex(args.tokenIdentifier)]; return this.createTransaction({ sender: args.manager, @@ -492,16 +482,12 @@ Once the token is registered, you can unset this role by calling "unsetBurnRoleG gasPrice: args.gasPrice, gasLimitHint: args.gasLimit, executionGasLimit: this.config.gasLimitPausing, - dataParts: parts + dataParts: parts, }); } freeze(args: IFreezingArgs): Transaction { - const parts = [ - "freeze", - utf8ToHex(args.tokenIdentifier), - addressToHex(args.user) - ]; + const parts = ["freeze", utf8ToHex(args.tokenIdentifier), addressToHex(args.user)]; return this.createTransaction({ sender: args.manager, @@ -510,7 +496,7 @@ Once the token is registered, you can unset this role by calling "unsetBurnRoleG gasPrice: args.gasPrice, gasLimitHint: args.gasLimit, executionGasLimit: this.config.gasLimitFreezing, - dataParts: parts + dataParts: parts, }); } @@ -528,7 +514,7 @@ Once the token is registered, you can unset this role by calling "unsetBurnRoleG gasPrice: args.gasPrice, gasLimitHint: args.gasLimit, executionGasLimit: this.config.gasLimitFreezing, - dataParts: parts + dataParts: parts, }); } @@ -546,7 +532,7 @@ Once the token is registered, you can unset this role by calling "unsetBurnRoleG gasPrice: args.gasPrice, gasLimitHint: args.gasLimit, executionGasLimit: this.config.gasLimitWiping, - dataParts: parts + dataParts: parts, }); } @@ -564,16 +550,12 @@ Once the token is registered, you can unset this role by calling "unsetBurnRoleG gasPrice: args.gasPrice, gasLimitHint: args.gasLimit, executionGasLimit: this.config.gasLimitESDTLocalMint, - dataParts: parts + dataParts: parts, }); } localBurn(args: ILocalBurnArgs): Transaction { - const parts = [ - "ESDTLocalBurn", - utf8ToHex(args.tokenIdentifier), - bigIntToHex(args.supplyToBurn), - ]; + const parts = ["ESDTLocalBurn", utf8ToHex(args.tokenIdentifier), bigIntToHex(args.supplyToBurn)]; return this.createTransaction({ sender: args.manager, @@ -582,7 +564,7 @@ Once the token is registered, you can unset this role by calling "unsetBurnRoleG gasPrice: args.gasPrice, gasLimitHint: args.gasLimit, executionGasLimit: this.config.gasLimitESDTLocalBurn, - dataParts: parts + dataParts: parts, }); } @@ -601,7 +583,7 @@ Once the token is registered, you can unset this role by calling "unsetBurnRoleG gasPrice: args.gasPrice, gasLimitHint: args.gasLimit, executionGasLimit: this.config.gasLimitESDTNFTUpdateAttributes, - dataParts: parts + dataParts: parts, }); } @@ -610,7 +592,7 @@ Once the token is registered, you can unset this role by calling "unsetBurnRoleG "ESDTNFTAddQuantity", utf8ToHex(args.tokenIdentifier), bigIntToHex(args.tokenNonce), - bigIntToHex(args.quantityToAdd) + bigIntToHex(args.quantityToAdd), ]; return this.createTransaction({ @@ -620,7 +602,7 @@ Once the token is registered, you can unset this role by calling "unsetBurnRoleG gasPrice: args.gasPrice, gasLimitHint: args.gasLimit, executionGasLimit: this.config.gasLimitESDTNFTAddQuantity, - dataParts: parts + dataParts: parts, }); } @@ -629,7 +611,7 @@ Once the token is registered, you can unset this role by calling "unsetBurnRoleG "ESDTNFTBurn", utf8ToHex(args.tokenIdentifier), bigIntToHex(args.tokenNonce), - bigIntToHex(args.quantityToBurn) + bigIntToHex(args.quantityToBurn), ]; return this.createTransaction({ @@ -639,11 +621,20 @@ Once the token is registered, you can unset this role by calling "unsetBurnRoleG gasPrice: args.gasPrice, gasLimitHint: args.gasLimit, executionGasLimit: this.config.gasLimitESDTNFTBurn, - dataParts: parts + dataParts: parts, }); } - private createTransaction({ sender, receiver, nonce, value, gasPrice, gasLimitHint, executionGasLimit, dataParts }: { + private createTransaction({ + sender, + receiver, + nonce, + value, + gasPrice, + gasLimitHint, + executionGasLimit, + dataParts, + }: { sender: IAddress; receiver: IAddress; nonce?: INonce; @@ -668,7 +659,7 @@ Once the token is registered, you can unset this role by calling "unsetBurnRoleG value: value || 0, data: payload, version: version, - options: options + options: options, }); } diff --git a/src/tokenOperations/tokenOperationsFactoryConfig.ts b/src/tokenOperations/tokenOperationsFactoryConfig.ts index ef9731bf..e1ebb54d 100644 --- a/src/tokenOperations/tokenOperationsFactoryConfig.ts +++ b/src/tokenOperations/tokenOperationsFactoryConfig.ts @@ -2,6 +2,9 @@ import BigNumber from "bignumber.js"; import { Address } from "../address"; import { IAddress, IChainID, IGasLimit, IGasPrice } from "../interface"; +/** + * @deprecated Use {@link TransactionsFactoryConfig} instead. + */ export class TokenOperationsFactoryConfig { chainID: IChainID; minGasPrice: IGasPrice = 1000000000; @@ -21,7 +24,9 @@ export class TokenOperationsFactoryConfig { gasLimitESDTNFTBurn: IGasLimit = 1000000; gasLimitStorePerByte: IGasLimit = 50000; issueCost: BigNumber.Value = "50000000000000000"; - esdtContractAddress: IAddress = Address.fromBech32("erd1qqqqqqqqqqqqqqqpqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqzllls8a5w6u"); + esdtContractAddress: IAddress = Address.fromBech32( + "erd1qqqqqqqqqqqqqqqpqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqzllls8a5w6u" + ); constructor(chainID: IChainID) { this.chainID = chainID; diff --git a/src/transactionsFactories/transferTransactionsFactory.spec.ts b/src/transactionsFactories/transferTransactionsFactory.spec.ts index 1f3b21de..b4b06da3 100644 --- a/src/transactionsFactories/transferTransactionsFactory.spec.ts +++ b/src/transactionsFactories/transferTransactionsFactory.spec.ts @@ -2,12 +2,12 @@ import { assert } from "chai"; import { Address } from "../address"; import { Token, NextTokenTransfer, TokenComputer } from "../tokens"; import { TransactionsFactoryConfig } from "./transactionsFactoryConfig"; -import { TransferTransactionsFactory } from "./transferTransactionsFactory"; +import { NextTransferTransactionsFactory } from "./transferTransactionsFactory"; import { ErrBadUsage } from "../errors"; describe("test transfer transcations factory", function () { const config = new TransactionsFactoryConfig("D"); - const factory = new TransferTransactionsFactory(config, new TokenComputer()); + const factory = new NextTransferTransactionsFactory(config, new TokenComputer()); const alice = Address.fromBech32("erd1qyu5wthldzr8wx5c9ucg8kjagg0jfs53s8nr3zpz3hypefsdd8ssycr6th"); const bob = Address.fromBech32("erd1spyavw0956vq68xj8y4tenjpq2wd5a9p2c6j8gsz7ztyrnpxrruqzu66jx"); diff --git a/src/transactionsFactories/transferTransactionsFactory.ts b/src/transactionsFactories/transferTransactionsFactory.ts index 588c740e..3f52930b 100644 --- a/src/transactionsFactories/transferTransactionsFactory.ts +++ b/src/transactionsFactories/transferTransactionsFactory.ts @@ -22,7 +22,7 @@ interface TokenComputer { isFungible(token: Token): boolean; } -export class TransferTransactionsFactory { +export class NextTransferTransactionsFactory { private readonly config: IConfig; private readonly dataArgsBuilder: TokenTransfersDataBuilder; private readonly tokenComputer: TokenComputer; diff --git a/src/transferTransactionsFactory.ts b/src/transferTransactionsFactory.ts index 7444bfde..3e312df9 100644 --- a/src/transferTransactionsFactory.ts +++ b/src/transferTransactionsFactory.ts @@ -11,6 +11,9 @@ interface IGasEstimator { forMultiESDTNFTTransfer(dataLength: number, numTransfers: number): number; } +/** + * @deprecated Use {@link NextTransferTransactionsFactory} instead. + */ export class TransferTransactionsFactory { private readonly gasEstimator; @@ -39,12 +42,12 @@ export class TransferTransactionsFactory { gasPrice: args.gasPrice, gasLimit: args.gasLimit || estimatedGasLimit, data: args.data, - chainID: args.chainID + chainID: args.chainID, }); } createESDTTransfer(args: { - tokenTransfer: ITokenTransfer, + tokenTransfer: ITokenTransfer; nonce?: INonce; receiver: IAddress; sender: IAddress; @@ -71,12 +74,12 @@ export class TransferTransactionsFactory { gasPrice: args.gasPrice, gasLimit: args.gasLimit || estimatedGasLimit, data: transactionPayload, - chainID: args.chainID + chainID: args.chainID, }); } createESDTNFTTransfer(args: { - tokenTransfer: ITokenTransfer, + tokenTransfer: ITokenTransfer; nonce?: INonce; destination: IAddress; sender: IAddress; @@ -92,7 +95,7 @@ export class TransferTransactionsFactory { // The transferred quantity new BigUIntValue(args.tokenTransfer.valueOf()), // The destination address - new AddressValue(args.destination) + new AddressValue(args.destination), ]); const data = `ESDTNFTTransfer@${argumentsString}`; @@ -107,12 +110,12 @@ export class TransferTransactionsFactory { gasPrice: args.gasPrice, gasLimit: args.gasLimit || estimatedGasLimit, data: transactionPayload, - chainID: args.chainID + chainID: args.chainID, }); } createMultiESDTNFTTransfer(args: { - tokenTransfers: ITokenTransfer[], + tokenTransfers: ITokenTransfer[]; nonce?: INonce; destination: IAddress; sender: IAddress; @@ -124,18 +127,20 @@ export class TransferTransactionsFactory { // The destination address new AddressValue(args.destination), // Number of tokens - new U16Value(args.tokenTransfers.length) + new U16Value(args.tokenTransfers.length), ]; for (const payment of args.tokenTransfers) { - parts.push(...[ - // The token identifier - BytesValue.fromUTF8(payment.tokenIdentifier), - // The nonce of the token - new U64Value(payment.nonce), - // The transfered quantity - new BigUIntValue(payment.valueOf()) - ]); + parts.push( + ...[ + // The token identifier + BytesValue.fromUTF8(payment.tokenIdentifier), + // The nonce of the token + new U64Value(payment.nonce), + // The transfered quantity + new BigUIntValue(payment.valueOf()), + ] + ); } const { argumentsString } = new ArgSerializer().valuesToString(parts); @@ -151,7 +156,7 @@ export class TransferTransactionsFactory { gasPrice: args.gasPrice, gasLimit: args.gasLimit || estimatedGasLimit, data: transactionPayload, - chainID: args.chainID + chainID: args.chainID, }); } }