Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/core/transactionsFactoryConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,9 @@ export class TransactionsFactoryConfig {
this.gasLimitFreezing = 60000000n;
this.gasLimitWiping = 60000000n;
this.gasLimitEsdtNftCreate = 3000000n;
this.gasLimitEsdtNftUpdateAttributes = 1000000n;
this.gasLimitEsdtNftAddQuantity = 1000000n;
this.gasLimitEsdtNftBurn = 1000000n;
this.gasLimitEsdtNftUpdateAttributes = 50000n;
this.gasLimitEsdtNftAddQuantity = 50000n;
this.gasLimitEsdtNftBurn = 50000n;
this.gasLimitStorePerByte = 10000n;
this.issueCost = 50000000000000000n;
this.gasLimitEsdtModifyRoyalties = 60000000n;
Expand Down
3 changes: 1 addition & 2 deletions src/entrypoints/entrypoints.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { assert } from "chai";
import { readFileSync } from "fs";
import path from "path";
import { Account } from "../accounts/account";
import { Address } from "../core";
import { loadAbiRegistry } from "../testutils";
import { DevnetEntrypoint } from "./entrypoints";

Expand Down Expand Up @@ -82,7 +81,7 @@ describe("TestEntrypoint", function () {

assert.equal(outcome.contracts.length, 1);

const contractAddress = Address.newFromBech32(outcome.contracts[0].address);
const contractAddress = outcome.contracts[0].address;

const executeTransaction = await controller.createTransactionForExecute(
sender,
Expand Down
18 changes: 4 additions & 14 deletions src/smartContracts/resources.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,18 +34,8 @@ export type ParsedSmartContractCallOutcome = {
returnMessage: string;
};

export class DeployedSmartContract {
address: string;
ownerAddress: string;
export type DeployedSmartContract = {
address: Address;
ownerAddress: Address;
codeHash: Uint8Array;

constructor(address: string, ownerAddress: string, codeHash: Uint8Array) {
this.address = address;
this.ownerAddress = ownerAddress;
this.codeHash = codeHash;
}

toString(): string {
return `DeployedSmartContract(address=${this.address}, ownerAddress=${this.ownerAddress}, codeHash=${Buffer.from(this.codeHash).toString("hex")})`;
}
}
};
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { assert } from "chai";
import { Address } from "../core";
import { createDevnetProvider } from "../testutils/networkProviders";
import { SmartContractTransactionsOutcomeParser } from "./smartContractTransactionsOutcomeParser";

Expand All @@ -14,8 +15,8 @@ describe("test smart contract transactions outcome parser on devnet", () => {
assert.equal(parsedGivenTransactionOnNetwork.returnCode, "ok");
assert.deepEqual(parsedGivenTransactionOnNetwork.contracts, [
{
address: "erd1qqqqqqqqqqqqqpgqpayq2es08gq8798xhnpr0kzgn7495qt5q6uqd7lpwf",
ownerAddress: "erd1tn62hjp72rznp8vq0lplva5csav6rccpqqdungpxtqz0g2hcq6uq9k4cc6",
address: Address.newFromBech32("erd1qqqqqqqqqqqqqpgqpayq2es08gq8798xhnpr0kzgn7495qt5q6uqd7lpwf"),
ownerAddress: Address.newFromBech32("erd1tn62hjp72rznp8vq0lplva5csav6rccpqqdungpxtqz0g2hcq6uq9k4cc6"),
codeHash: Buffer.from("c876625ec34a04445cfd99067777ebe488afdbc6899cd958f4c1d36107ca02d9", "hex"),
},
]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ describe("test smart contract transactions outcome parser", () => {
assert.equal(parsed.returnMessage, "ok");
assert.deepEqual(parsed.contracts, [
{
address: contract.toBech32(),
ownerAddress: deployer.toBech32(),
address: contract,
ownerAddress: deployer,
codeHash: codeHash,
},
]);
Expand Down
30 changes: 8 additions & 22 deletions src/smartContracts/smartContractTransactionsOutcomeParser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,27 +20,13 @@ export class SmartContractTransactionsOutcomeParser {
this.abi = options?.abi;
}

parseDeploy(options: { transactionOnNetwork: TransactionOnNetwork }): {
returnCode: string;
returnMessage: string;
contracts: {
address: string;
ownerAddress: string;
codeHash: Uint8Array;
}[];
} {
parseDeploy(options: { transactionOnNetwork: TransactionOnNetwork }): resources.SmartContractDeployOutcome {
return this.parseDeployGivenTransactionOnNetwork(options.transactionOnNetwork);
}

protected parseDeployGivenTransactionOnNetwork(transactionOnNetwork: TransactionOnNetwork): {
returnCode: string;
returnMessage: string;
contracts: {
address: string;
ownerAddress: string;
codeHash: Uint8Array;
}[];
} {
protected parseDeployGivenTransactionOnNetwork(
transactionOnNetwork: TransactionOnNetwork,
): resources.SmartContractDeployOutcome {
const directCallOutcome = this.findDirectSmartContractCallOutcome(transactionOnNetwork);

const events = transactionOnNetwork.logs.events
Expand All @@ -61,15 +47,15 @@ export class SmartContractTransactionsOutcomeParser {
}

private parseScDeployEvent(event: { topics: Uint8Array[] }): {
address: string;
ownerAddress: string;
address: Address;
ownerAddress: Address;
codeHash: Uint8Array;
} {
const topicForAddress = Buffer.from(event.topics[0]).toString("hex");
const topicForOwnerAddress = Buffer.from(event.topics[1]).toString("hex");
const topicForCodeHash = Buffer.from(event.topics[2]);
const address = topicForAddress?.length ? new Address(topicForAddress).toBech32() : "";
const ownerAddress = topicForOwnerAddress?.length ? new Address(topicForOwnerAddress).toBech32() : "";
const address = topicForAddress?.length ? new Address(topicForAddress) : Address.empty();
const ownerAddress = topicForOwnerAddress?.length ? new Address(topicForOwnerAddress) : Address.empty();
const codeHash = topicForCodeHash;

return {
Expand Down
9 changes: 8 additions & 1 deletion src/tokenManagement/resources.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,14 @@ export type FungibleSpecialRoleInput = {
addRoleLocalBurn: boolean;
addRoleESDTTransferRole: boolean;
};
export type SemiFungibleSpecialRoleInput = SpecialRoleInput & { addRoleNFTAddQuantity: boolean };
export type SemiFungibleSpecialRoleInput = {
user: Address;
tokenIdentifier: string;
addRoleNFTCreate: boolean;
addRoleNFTBurn: boolean;
addRoleNFTAddQuantity: boolean;
addRoleESDTTransferRole: boolean;
};

export type SpecialRoleInput = {
user: Address;
Expand Down
3 changes: 1 addition & 2 deletions src/tokenManagement/tokenManagementTransactionsFactory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,6 @@ export class TokenManagementTransactionsFactory {
options.addRoleNFTBurn ? args.push(new StringValue("ESDTRoleNFTBurn")) : 0;
options.addRoleNFTAddQuantity ? args.push(new StringValue("ESDTRoleNFTAddQuantity")) : 0;
options.addRoleESDTTransferRole ? args.push(new StringValue("ESDTTransferRole")) : 0;
options.addRoleESDTModifyCreator ? args.push(new StringValue("ESDTRoleModifyCreator")) : 0;

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

Expand Down Expand Up @@ -346,7 +345,7 @@ export class TokenManagementTransactionsFactory {
"ESDTNFTCreate",
...this.argSerializer.valuesToStrings([
new StringValue(options.tokenIdentifier),
new BigUIntValue(options.initialQuantity),
new BigUIntValue(options.initialQuantity ?? 1n),
new StringValue(options.name),
new BigUIntValue(options.royalties),
new StringValue(options.hash),
Expand Down
Loading