Skip to content

Commit

Permalink
Fix tests and remove console logs
Browse files Browse the repository at this point in the history
  • Loading branch information
danielailie committed Nov 21, 2024
1 parent 74213b1 commit 2b68d3a
Show file tree
Hide file tree
Showing 9 changed files with 14 additions and 16 deletions.
1 change: 0 additions & 1 deletion src/delegation/delegationTransactionsFactory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,6 @@ export class DelegationTransactionsFactory {

createTransactionForStakingNodes(sender: IAddress, options: resources.ManageNodesInput): Transaction {
let dataParts = ["stakeNodes"];
console.log(options.publicKeys);

for (const key of options.publicKeys) {
dataParts = dataParts.concat(key.hex());
Expand Down
2 changes: 1 addition & 1 deletion src/delegation/delegationTransactionsOutcomeParser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export class DelegationTransactionsOutcomeParser {
return "";
}
const address = Buffer.from(event.topics[0]);
return Address.fromBuffer(address).bech32();
return new Address(address).bech32();
}

private decodeTopicAsString(topic: Uint8Array): string {
Expand Down
1 change: 0 additions & 1 deletion src/entrypoints/entrypoints.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ describe("TestEntrypoint", () => {
},
);

console.log({ transaction });
const txHash = await entrypoint.sendTransaction(transaction);
const outcome = await controller.awaitCompletedDeploy(txHash);

Expand Down
1 change: 0 additions & 1 deletion src/networkProviders/apiNetworkProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,6 @@ export class ApiNetworkProvider implements INetworkProvider {

async getTransaction(txHash: string): Promise<TransactionOnNetwork> {
const response = await this.doGetGeneric(`transactions/${txHash}`);
console.log({ response: JSON.stringify(response) });
const transaction = TransactionOnNetwork.fromApiHttpResponse(txHash, response);
return transaction;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,11 @@ describe("test smart contract transactions outcome parser", () => {
events: [
new TransactionEvent({
identifier: "SCDeploy",
topics: [contract.getPublicKey(), deployer.getPublicKey(), codeHash],
topics: [
new Uint8Array(Buffer.from(contract.getPublicKey().toString("base64"))),
new Uint8Array(Buffer.from(deployer.getPublicKey().toString("base64"))),
codeHash,
],
}),
],
}),
Expand Down Expand Up @@ -53,7 +57,10 @@ describe("test smart contract transactions outcome parser", () => {
events: [
new TransactionEvent({
identifier: "signalError",
topics: [deployer.getPublicKey(), new Uint8Array(Buffer.from("wrong number of arguments"))],
topics: [
new Uint8Array(Buffer.from(deployer.getPublicKey().toString("base64"))),
new Uint8Array(Buffer.from("wrong number of arguments")),
],
data: "@75736572206572726f72",
}),
],
Expand Down
5 changes: 2 additions & 3 deletions src/smartContracts/smartContractTransactionsOutcomeParser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,10 +85,9 @@ export class SmartContractTransactionsOutcomeParser {
ownerAddress: string;
codeHash: Uint8Array;
} {
const topicForAddress = Buffer.from(event.topics[0]);
const topicForOwnerAddress = event.topics[1];
const topicForAddress = Buffer.from(event.topics[0].toString(), "base64").toString("hex");
const topicForOwnerAddress = Buffer.from(event.topics[1].toString(), "base64").toString("hex");
const topicForCodeHash = event.topics[2];

const address = topicForAddress?.length ? new Address(topicForAddress).toBech32() : "";
const ownerAddress = topicForOwnerAddress?.length ? new Address(topicForOwnerAddress).toBech32() : "";
const codeHash = topicForCodeHash;
Expand Down
5 changes: 1 addition & 4 deletions src/transactionEvents.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,13 @@ export class TransactionEvent {
data: string;
additionalData?: string[];
}): TransactionEvent {
console.log({ responsePart });
let result = new TransactionEvent();
result.address = new Address(responsePart.address);
result.identifier = responsePart.identifier || "";
result.topics = (responsePart.topics || []).map((topic) => Buffer.from(topic));

console.log(22222, { responsePart }, 333, responsePart.additionalData);
result.dataPayload = Buffer.from(responsePart.data);
result.dataPayload = Buffer.from(responsePart.data ?? "");
result.additionalData = (responsePart.additionalData || []).map((data) => Buffer.from(data));
result.data = result.dataPayload?.toString();

return result;
}
Expand Down
1 change: 0 additions & 1 deletion src/transactionLogs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ export class TransactionLogs {
static fromHttpResponse(logs: any): TransactionLogs {
let result = new TransactionLogs();
result.address = new Address(logs.address);
console.log({ events: JSON.stringify(logs.events) });
result.events = (logs.events || []).map((event: any) => TransactionEvent.fromHttpResponse(event));

return result;
Expand Down
3 changes: 1 addition & 2 deletions src/transactions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ export class TransactionOnNetwork {

static fromApiHttpResponse(txHash: string, response: any): TransactionOnNetwork {
let result = TransactionOnNetwork.fromHttpResponse(txHash, response);
result.smartContractResults = response.results;
result.smartContractResults = response.results ?? [];
result.isCompleted = !result.status.isPending();
return result;
}
Expand All @@ -107,7 +107,6 @@ export class TransactionOnNetwork {
result.blockNonce = response.blockNonce || 0;
result.hyperblockNonce = response.hyperblockNonce || 0;
result.hyperblockHash = response.hyperblockHash || "";
console.log({ logs: JSON.stringify(response.logs) });
result.logs = TransactionLogs.fromHttpResponse(response.logs || {});

return result;
Expand Down

0 comments on commit 2b68d3a

Please sign in to comment.