-
Notifications
You must be signed in to change notification settings - Fork 2
new functions proposal #1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
proposal for new functions async generatePrivateAndPublicKey() async updateTopic(topicId, memo, adminKey)
import of new functions
still learning |
src/index.ts
Outdated
publicKey: string; | ||
}> { | ||
this.ensureInitialized(); | ||
const privateKey = await PrivateKey.generateED25519Async(); |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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
update topic memo and create topic with memo works + randomly generated public+privatekey also works
with custom fee
proposal to implement 2 new functions + fix little bug with freeze inside createTopic() functions