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

Add initial methods #3

Merged
merged 16 commits into from
Sep 9, 2021
Merged

Add initial methods #3

merged 16 commits into from
Sep 9, 2021

Conversation

wachunei
Copy link
Member

@wachunei wachunei commented Sep 8, 2021

No description provided.

@wachunei wachunei changed the title Add initial SmartTransactionsController Add initial methods Sep 8, 2021
@@ -20,36 +20,37 @@ describe('SmartTransactionsController', () => {
await smartTransactionsController.stop();
});

it('should initialize with default config', () => {
it('initializes with default config', () => {
Copy link
Collaborator

Choose a reason for hiding this comment

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

+1

APIType,
SmartTransaction,
SignedTransaction,
SignedCancellation,
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit: Is that signed canceled transaction? If yes, we could maybe call it: SignedCanceledTransaction

this.update({
smartTransactions: {
...this.state.smartTransactions,
[chainId]: [
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit: For updating a smart transaction in the array we could also use array.map, which is a recommended way on the Redux website: https://redux.js.org/usage/structuring-reducers/immutable-update-patterns#updating-an-item-in-an-array


setOptInState(state: boolean | undefined): void {
this.update({ userOptIn: state });
this.poll();
Copy link
Collaborator

Choose a reason for hiding this comment

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

If we have more than 1 polling here, do we want to be more specific? E.g. pollSmartTransactionsStatus, which would allow us to check multiple smart transactions at the same request.

//
const { smartTransactions } = this.state;
const { chainId } = this.config;
const currentChainIdSmartTransactions = smartTransactions[chainId];
Copy link
Collaborator

Choose a reason for hiding this comment

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

What will be the structure of the smartTransactions object? [chainId] as a key and a value will be an array of smart transactions?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes

const currentChainIdSmartTransactions = smartTransactions[chainId];

const transactionsToUpdate: string[] = [];
currentChainIdSmartTransactions.forEach((smartTransaction) => {
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit: I usually prefer that when I iterate, I like to use plural and then a singular version. In this case it would be:
currentChainIdSmartTransactions.forEach((currentChainIdSmartTransaction => {

I'm wondering if we could maybe rename this.state.smartTransactions to something else (e.g.this.state.chainIdsSmartTransactions) and then this one could be just simply:
smartTransactions.forEach((smartTransaction => {

}
}

// ! Ask backend API to accept list of UUIDs as params
Copy link
Collaborator

Choose a reason for hiding this comment

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

+1

@wachunei wachunei marked this pull request as ready for review September 9, 2021 17:03
@wachunei wachunei requested a review from a team as a code owner September 9, 2021 17:03
@wachunei wachunei merged commit 03f1a34 into main Sep 9, 2021
@wachunei wachunei deleted the feature/initial-methods branch September 9, 2021 17:03
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