Skip to content

Commit

Permalink
Merge pull request #437 from multiversx/add-missing-role
Browse files Browse the repository at this point in the history
Added missing role(ESDTTransferRole) on fungible token
  • Loading branch information
popenta authored Apr 16, 2024
2 parents 23fc1f4 + bf6a29b commit 2d55650
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,48 @@ describe("test token management transactions factory", () => {
assert.deepEqual(transaction.value, config.issueCost);
});

it("should create 'Transaction' for setting spcial role on non-fungible token", () => {
it("should create 'Transaction' for setting special role on fungible token", () => {
const transaction = tokenManagementFactory.createTransactionForSettingSpecialRoleOnFungibleToken({
sender: frank.address,
user: grace.address,
tokenIdentifier: "FRANK-11ce3e",
addRoleLocalMint: true,
addRoleLocalBurn: false,
});

assert.deepEqual(
transaction.data,
Buffer.from(
"setSpecialRole@4652414e4b2d313163653365@1e8a8b6b49de5b7be10aaa158a5a6a4abb4b56cc08f524bb5e6cd5f211ad3e13@45534454526f6c654c6f63616c4d696e74",
),
);
assert.equal(transaction.sender, frank.address.toString());
assert.equal(transaction.receiver, ESDT_CONTRACT_ADDRESS);
assert.equal(transaction.value, 0n);
});

it("should create 'Transaction' for setting all special roles on fungible token", () => {
const transaction = tokenManagementFactory.createTransactionForSettingSpecialRoleOnFungibleToken({
sender: frank.address,
user: grace.address,
tokenIdentifier: "FRANK-11ce3e",
addRoleLocalMint: true,
addRoleLocalBurn: true,
addRoleESDTTransferRole: true,
});

assert.deepEqual(
transaction.data,
Buffer.from(
"setSpecialRole@4652414e4b2d313163653365@1e8a8b6b49de5b7be10aaa158a5a6a4abb4b56cc08f524bb5e6cd5f211ad3e13@45534454526f6c654c6f63616c4d696e74@45534454526f6c654c6f63616c4275726e@455344545472616e73666572526f6c65",
),
);
assert.equal(transaction.sender, frank.address.toString());
assert.equal(transaction.receiver, ESDT_CONTRACT_ADDRESS);
assert.equal(transaction.value, 0n);
});

it("should create 'Transaction' for setting special role on non-fungible token", () => {
const transaction = tokenManagementFactory.createTransactionForSettingSpecialRoleOnNonFungibleToken({
sender: frank.address,
user: grace.address,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -299,11 +299,13 @@ export class TokenManagementTransactionsFactory {
tokenIdentifier: string;
addRoleLocalMint: boolean;
addRoleLocalBurn: boolean;
addRoleESDTTransferRole?: boolean;
}): Transaction {
const args = [new StringValue(options.tokenIdentifier), new AddressValue(options.user)];

options.addRoleLocalMint ? args.push(new StringValue("ESDTRoleLocalMint")) : 0;
options.addRoleLocalBurn ? args.push(new StringValue("ESDTRoleLocalBurn")) : 0;
options.addRoleESDTTransferRole ? args.push(new StringValue("ESDTTransferRole")) : 0;

const dataParts = ["setSpecialRole", ...this.argSerializer.valuesToStrings(args)];

Expand Down

0 comments on commit 2d55650

Please sign in to comment.