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

Feature/trcl 2812 optimization #51

Merged
merged 10 commits into from
Oct 10, 2023
Merged

Feature/trcl 2812 optimization #51

merged 10 commits into from
Oct 10, 2023

Conversation

johnqh
Copy link
Contributor

@johnqh johnqh commented Oct 6, 2023

Optimized by

  1. Take optional marketInfo payload (passed from Abacus)
  2. Take optional currentHeight payload (passed from Abacus)
  3. Cache Account info
  4. For SHORT_TERM order, used cached Account. The sequence is not used. For LONG_TERM order, still need to query current Account
  5. If marketInfo and currentHeight are not passed in, do the round trips (get market info from Indexer, get height from node, and get account from node) in parallel.

Tested by plugging in the v4-native-client.js into iOS app, and monitored network traffic with Charles.

# Conflicts:
#	v4-client-js/__native__/__ios__/v4-native-client.js
#	v4-client-js/__native__/__ios__/v4-native-client.js.map
#	v4-client-js/package.json
@@ -159,11 +182,11 @@ export class Post {
private async signTransaction(
wallet: LocalWallet,
messages: EncodeObject[],
account: Account,
Copy link
Contributor

Choose a reason for hiding this comment

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

I wonder if we can make the account param optional.
and we can fallback to:
const account = await this.account(wallet.address, undefined);

That way we won't break existing integrations either.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Changed

@@ -76,12 +79,22 @@ export class Post {
async simulate(
wallet: LocalWallet,
messaging: () => Promise<EncodeObject[]>,
account: () => Promise<Account>,
Copy link
Contributor

Choose a reason for hiding this comment

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

Same question here

Copy link
Contributor

@rosepuppy rosepuppy left a comment

Choose a reason for hiding this comment

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

Just comment about unnecessary await

Comment on lines +116 to +117
const msgsPromise = await messaging();
const accountPromise = account ? (await account()) : this.account(wallet.address!);
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
const msgsPromise = await messaging();
const accountPromise = account ? (await account()) : this.account(wallet.address!);
const msgsPromise = messaging();
const accountPromise = account ? account() : this.account(wallet.address!);

Since we are using promise.all later, we do not need to await here, since the await will unravel the promise.

Comment on lines +86 to +87
const msgsPromise = messaging();
const accountPromise = account ? (await account()) : this.account(wallet.address!);
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
const msgsPromise = messaging();
const accountPromise = account ? (await account()) : this.account(wallet.address!);
const msgsPromise = messaging();
const accountPromise = account ? account() : this.account(wallet.address!);

Since we are using promise.all later, we do not need to await here, since the await will unravel the promise.

@johnqh johnqh merged commit 8bde4f4 into main Oct 10, 2023
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants