Skip to content

Commit

Permalink
Code review follow up
Browse files Browse the repository at this point in the history
  • Loading branch information
danielailie committed Dec 18, 2024
1 parent f20e9d4 commit ede0df6
Show file tree
Hide file tree
Showing 6 changed files with 6 additions and 14 deletions.
2 changes: 1 addition & 1 deletion src/abi/interaction.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ describe("test smart contract interactor", function () {
const hexBar = "4241522d356263303866";
const hexLKMEX = "4c4b4d45582d616162393130";
const hexNFT = "4d4f532d623962346232";
const hexContractAddress = new Address(contract.getAddress().toBech32()).toHex();
const hexContractAddress = contract.getAddress().toHex();
const hexDummyFunction = "64756d6d79";

// ESDT, single
Expand Down
3 changes: 1 addition & 2 deletions src/abi/smartContract.ts
Original file line number Diff line number Diff line change
Expand Up @@ -288,8 +288,7 @@ export class SmartContract implements ISmartContract {
* @param nonce The owner nonce used for the deployment transaction
*/
static computeAddress(owner: Address, nonce: bigint): Address {
const deployer = Address.newFromBech32(owner.toBech32());
const addressComputer = new AddressComputer();
return addressComputer.computeContractAddress(deployer, BigInt(nonce.valueOf()));
return addressComputer.computeContractAddress(owner, BigInt(nonce.valueOf()));
}
}
2 changes: 1 addition & 1 deletion src/accountManagement/accountTransactionsFactory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ export class AccountTransactionsFactory {
createTransactionForSettingGuardian(sender: Address, options: SetGuardianInput): Transaction {
const dataParts = [
"SetGuardian",
Address.newFromBech32(options.guardianAddress.toBech32()).toHex(),
options.guardianAddress.toHex(),
Buffer.from(options.serviceID).toString("hex"),
];

Expand Down
5 changes: 2 additions & 3 deletions src/entrypoints/entrypoints.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,7 @@ describe("TestEntrypoint", () => {
this.timeout(30000);
const abi = await loadAbiRegistry("src/testdata/adder.abi.json");
const sender = Account.newFromPem(alicePem.pemFileText);
const accountAddress = new Address(sender.address);
sender.nonce = await entrypoint.recallAccountNonce(accountAddress);
sender.nonce = await entrypoint.recallAccountNonce(sender.address);

const controller = entrypoint.createSmartContractController(abi);
const bytecode = readFileSync("src/testdata/adder.wasm");
Expand All @@ -63,7 +62,7 @@ describe("TestEntrypoint", () => {

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

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

const executeTransaction = await controller.createTransactionForExecute(
sender,
Expand Down
2 changes: 1 addition & 1 deletion src/smartContracts/smartContractTransactionsFactory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ export class SmartContractTransactionsFactory {
contract: Address;
newOwner: Address;
}): Transaction {
const dataParts = ["ChangeOwnerAddress", Address.newFromBech32(options.newOwner.toBech32()).toHex()];
const dataParts = ["ChangeOwnerAddress", options.newOwner.toHex()];

return new TransactionBuilder({
config: this.config,
Expand Down
6 changes: 0 additions & 6 deletions src/utils.codec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import BigNumber from "bignumber.js";
import * as contractsCodecUtils from "./abi/codec/utils";
import { Address } from "./address";

export function numberToPaddedHex(value: bigint | number | BigNumber.Value) {
let hexableNumber: { toString(radix?: number): string };
Expand Down Expand Up @@ -52,8 +51,3 @@ export function bigIntToHex(value: BigNumber.Value): string {

return contractsCodecUtils.getHexMagnitudeOfBigInt(value);
}

export function addressToHex(address: Address): string {
const buffer = Address.newFromBech32(address.toString()).getPublicKey();
return buffer.toString("hex");
}

0 comments on commit ede0df6

Please sign in to comment.