Skip to content
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

v2: Simplify setup (no more transactionFactory / messageFactory). #2

Merged
merged 11 commits into from
May 2, 2022

Conversation

andreibancioiu
Copy link
Contributor

@andreibancioiu andreibancioiu commented Apr 26, 2022

@andreibancioiu andreibancioiu self-assigned this Apr 26, 2022
@andreibancioiu andreibancioiu marked this pull request as draft April 26, 2022 08:30
@andreibancioiu andreibancioiu marked this pull request as ready for review April 26, 2022 12:07
bogdan-rosianu
bogdan-rosianu previously approved these changes Apr 26, 2022
arhtudormorar
arhtudormorar previously approved these changes Apr 27, 2022
examples/app.js Outdated
console.log(messageSigned);
}

class DummyTransaction {
Copy link
Contributor

Choose a reason for hiding this comment

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

Oare clasa asta nu ar merge extrasa intr-un fisier separat?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed.

examples/app.js Outdated Show resolved Hide resolved

return this.getTransactionFactory().fromPlainObject(txResponse[0]);
async signTransaction<T extends ITransaction>(transaction: T): Promise<T> {
let response = await this.signTransactions([transaction]);
Copy link
Contributor

Choose a reason for hiding this comment

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

maybe we should check for nulls here, to not throw an unhandled, we could throw a custom message if the user forgot to include the transaction

Copy link
Contributor Author

@andreibancioiu andreibancioiu Apr 29, 2022

Choose a reason for hiding this comment

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

The input parameter is not optional. In case of TypeScript code, the user should not be able to compile without passing a transaction.

But you are right about adding improving the error handling / throwing, overall. Is it OK to postpone that to a separate PR?

async signTransaction(transaction: ITransaction): Promise<ISignedTransaction> {
const txResponse = await this.startBgrMsgChannel("signTransactions", {
async signTransactions<T extends ITransaction>(transactions: Array<T>): Promise<Array<T>> {
let extensionResponse = await this.startBgrMsgChannel("signTransactions", {
Copy link
Contributor

Choose a reason for hiding this comment

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

this looks like a const, as it's not reassigned anywhere

Copy link
Contributor

Choose a reason for hiding this comment

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

as regarding the startBgrMsgChannel(string), this looks error-prone, maybe we should move these to a constants file and use variables that have strings as values, it's much safer

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed.

Fixed, added an enum.

});

return signedMsg;
const extensionResponse = await this.startBgrMsgChannel("signMessage", data);
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we wrap this in a try catch, to avoid throwing back at the user any unhandled exceptions?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Indeed, we should. Is is OK to postpone the improved error handling mechanism to a separate PR?

bogdan-rosianu
bogdan-rosianu previously approved these changes Apr 29, 2022
@andreibancioiu andreibancioiu merged commit f5f3993 into main May 2, 2022
@andreibancioiu andreibancioiu deleted the simplify-setup branch May 2, 2022 12:45
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.

4 participants