Skip to content

Commit

Permalink
Merge pull request #360 from multiversx/deprecate-old-stuff
Browse files Browse the repository at this point in the history
Mark old stuff as deprecated
  • Loading branch information
popenta authored Dec 13, 2023
2 parents c1bc71b + 5228b88 commit 09133bf
Show file tree
Hide file tree
Showing 5 changed files with 80 additions and 79 deletions.
107 changes: 49 additions & 58 deletions src/tokenOperations/tokenOperationsFactory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,7 @@ interface IIssueSemiFungibleArgs extends IBaseArgs {
canAddSpecialRoles: boolean;
}

interface IIssueNonFungibleArgs extends IIssueSemiFungibleArgs {
}
interface IIssueNonFungibleArgs extends IIssueSemiFungibleArgs {}

interface IRegisterMetaESDT extends IIssueSemiFungibleArgs {
numDecimals: number;
Expand Down Expand Up @@ -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 {
Expand All @@ -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;
Expand Down Expand Up @@ -211,7 +213,7 @@ export class TokenOperationsFactory {
gasPrice: args.gasPrice,
gasLimitHint: args.gasLimit,
executionGasLimit: this.config.gasLimitIssue,
dataParts: parts
dataParts: parts,
});
}

Expand Down Expand Up @@ -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,
});
}

Expand Down Expand Up @@ -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,
});
}

Expand Down Expand Up @@ -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,
});
}

Expand All @@ -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({
Expand All @@ -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,
Expand All @@ -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,
Expand All @@ -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,
});
}

Expand All @@ -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,
});
}

Expand All @@ -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,
});
}

Expand All @@ -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,
});
}

Expand All @@ -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,
Expand All @@ -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,
Expand All @@ -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,
Expand All @@ -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,
});
}

Expand All @@ -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,
});
}

Expand All @@ -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,
});
}

Expand All @@ -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,
Expand All @@ -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,
});
}

Expand All @@ -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,
});
}

Expand All @@ -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({
Expand All @@ -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,
});
}

Expand All @@ -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({
Expand All @@ -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;
Expand All @@ -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,
});
}

Expand Down
7 changes: 6 additions & 1 deletion src/tokenOperations/tokenOperationsFactoryConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions src/transactionsFactories/transferTransactionsFactory.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down
2 changes: 1 addition & 1 deletion src/transactionsFactories/transferTransactionsFactory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Loading

0 comments on commit 09133bf

Please sign in to comment.