-
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?
Changes from 8 commits
ba2d737
f9fa2b2
423d605
687e6ad
06b8fbc
9660fc9
0e5021d
59ceaac
69f13ca
00bee55
794a2c6
cc88a2d
4109155
f550b44
4073600
a44f76e
4f0d35b
2aed309
6663273
9570e61
af34f86
74047c0
ce2a2a0
4876cd1
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,6 +25,8 @@ import { | |
AccountUpdateTransaction, | ||
AccountAllowanceApproveTransaction, | ||
TokenId, | ||
client, | ||
TopicUpdateTransaction | ||
} from '@hashgraph/sdk'; | ||
import * as HashgraphSDK from '@hashgraph/sdk'; | ||
import { | ||
|
@@ -420,26 +422,55 @@ class HashinalsWalletConnectSDK { | |
}; | ||
} | ||
|
||
|
||
public async generatePrivateAndPublicKey(): Promise<{ | ||
privateKey: string; | ||
publicKey: string; | ||
}> { | ||
this.ensureInitialized(); | ||
const privateKey = await PrivateKey.generateED25519Async(); | ||
const publicKey = privateKey.publicKey; | ||
return { | ||
privateKey: privateKey.toString(), | ||
publicKey: publicKey.toString() | ||
}; | ||
} | ||
|
||
public async updateTopic(topicId: string, memo: string, adminKey: string): Promise<string> { | ||
this.ensureInitialized(); | ||
let transaction = new TopicUpdateTransaction() | ||
.setTopicId(TopicId.fromString(topicId)) | ||
.setTopicMemo(memo || "") | ||
.freezeWith(client); | ||
|
||
// Convert the adminKey string back to a PrivateKey object | ||
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 commentThe 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 |
||
return receipt.topicId!.toString(); | ||
} | ||
|
||
public async createTopic( | ||
memo?: string, | ||
adminKey?: string, | ||
submitKey?: string | ||
): Promise<string> { | ||
this.ensureInitialized(); | ||
|
||
let transaction = new TopicCreateTransaction().setTopicMemo(memo || ''); | ||
let transaction = new TopicCreateTransaction().setTopicMemo(memo || ""); | ||
|
||
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 commentThe reason will be displayed to describe this comment to others. Learn more. It looks like you're not disabling the signing in |
||
} | ||
|
||
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 commentThe 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 commentThe reason will be displayed to describe this comment to others. Learn more. understood thanks |
||
return receipt.topicId!.toString(); | ||
} | ||
|
||
|
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?