Skip to content

Conversation

1ksn1ks
Copy link

@1ksn1ks 1ksn1ks commented Mar 22, 2025

proposal to implement 2 new functions + fix little bug with freeze inside createTopic() functions

1ksn1ks added 7 commits March 22, 2025 14:12
proposal for new functions

 async generatePrivateAndPublicKey()

 async updateTopic(topicId, memo, adminKey)
import of new functions
@1ksn1ks
Copy link
Author

1ksn1ks commented Mar 22, 2025

still learning

@1ksn1ks 1ksn1ks closed this Mar 22, 2025
@1ksn1ks 1ksn1ks reopened this Mar 22, 2025
new pull
src/index.ts Outdated
publicKey: string;
}> {
this.ensureInitialized();
const privateKey = await PrivateKey.generateED25519Async();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: the spacing in this function is slightly off

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed?

src/index.ts Outdated
}

if (submitKey) {
transaction.setSubmitKey(PrivateKey.fromString(submitKey).publicKey);
}

const receipt = await this.executeTransaction(transaction);
const receipt = await this.executeTransaction(transaction, false); // Disable signing in executeTransaction
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The signing should only be disabled if there's an admin key since it'll already have signed the transaction. Otherwise this function won't execute for all other cases

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

understood

thanks

src/index.ts Outdated
const privateKey = PrivateKey.fromString(adminKey);
const signedTx = await transaction.sign(privateKey);

const receipt = await this.executeTransaction(signedTx);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since you're already signing the transaction, the signer should be disabled in executeTransaction

src/index.ts Outdated

if (adminKey) {
const adminWithPrivateKey = PrivateKey.fromString(adminKey);
transaction.setAdminKey(adminWithPrivateKey.publicKey);
transaction = await transaction.sign(adminWithPrivateKey);
transaction.freezeWith(client); // Freeze after setting the admin key
transaction = await transaction.sign(adminWithPrivateKey); // Then sign
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like you're not disabling the signing in executeTransaction, so ultimately this transaction will still fail because its already frozen

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants