Skip to content
This repository has been archived by the owner on Dec 14, 2021. It is now read-only.

Replace local hubble-bls fork with bls-wallet-signer #55

Merged
merged 29 commits into from
Sep 6, 2021
Merged

Conversation

voltrevo
Copy link
Collaborator

Things removed:

  • 🔥 local hubble-bls fork
  • 🔥 ethers types workaround (replaced with vanilla import from esm.sh)
  • 🔥 duplicated bls stuff in test Fixture
  • 🔥 using js numbers for nonces (except localized within TxTable.ts)

Notable changes:

  • Now storing encodedFunctionData instead of split fields for consistency
  • We're now getting the TransactionData type from bls-wallet-signer which doesn't know about the txId field which is a database concern. So, now we have a distinguished type TxTableRow which is just TransactionData with an optional txId.
  • Because we're treating nonces and tokenRewardAmounts much more consistently as BigNumber now, there's a TransactionDataDTO type to support sending this as JSON by representing those fields as strings. The client still accepts a regular TransactionData, the DTO is internal and only needs to be handled by Client.ts, parsers.ts, and TxRouter.ts.
  • Added ./programs/premerge.ts which checks all the typescript code, does linting, runs tests in parallel, and checks for todos & fixmes

Sorry about the volume of superficial edits to accomplish the above. Most of it is in test code.

await parent.getChainId(),
this.#VerificationGateway(parent),
this.#Signer(secret),
static async connectOrCreate(privateKey: string, parent: ethers.Wallet) {
Copy link
Owner

Choose a reason for hiding this comment

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

Add comments for BLSWallet class, including params of functions when helpful for clarity, eg parent

Copy link
Owner

Choose a reason for hiding this comment

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

BLSWallet class could be used without bls private keys and signing. PKs and signing could be exposed/used specifically, namely for testing and -extension.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Add comments for BLSWallet class, including params of functions when helpful for clarity, eg parent

👍 Updated

BLSWallet class could be used without bls private keys and signing. PKs and signing could be exposed/used specifically, namely for testing and -extension.

Yeah I think there will be some more changes here and maybe in bls-wallet-signer. I figure they will be made as they are needed though. Do you have specific changes in mind for right now?

// This will cause problems from 2^31 because we're using 32 bit integers.
// It's also a problem from 2^53 for js numbers.
//
// More information: https://github.com/jzaki/aggregator/issues/36.
Copy link
Owner

Choose a reason for hiding this comment

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

Update to reference issue number #36

Copy link
Collaborator Author

@voltrevo voltrevo Sep 6, 2021

Choose a reason for hiding this comment

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

I'm confused, it does reference issue #36:

// More information: https://github.com/jzaki/aggregator/issues/36.

Could you clarify?

Copy link
Owner

Choose a reason for hiding this comment

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

This was a minor one, just the #36is required because the full link name has changed (although github does redirect successfully)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Oh I see. Updated.


import assertExists from "../helpers/assertExists.ts";
import nil from "../helpers/nil.ts";

export type TransactionData = {
type RawTxTableRow = {
Copy link
Owner

Choose a reason for hiding this comment

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

Consistency with transaction parameter order (outer-most to inner-most)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

👍 (pending update)
(+ discussed on Signal)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Updated

src/app/TxTable.ts Show resolved Hide resolved
[hubbleBls.mcl.loadG2(pubkey)],
));
}
import { TxTableRow } from "./TxTable.ts";
Copy link
Owner

Choose a reason for hiding this comment

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

Can use TransactionData instead of TxTableRow in WalletService? txIds only used for emitting events

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Hmm I don't think there is a nice way to do this. I'm not sure how 'only for events' helps. Did you have something other than casting in mind?

Copy link
Owner

Choose a reason for hiding this comment

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

TransactionData has txId added here. Should the wallet service only worry about TransactionData rather than table rows (TxTableRow)?

}

async find(pubKey: string, nonce: number): Promise<TransactionData | nil> {
async find(publicKey: string, nonce: BigNumber): Promise<TxTableRow | nil> {
Copy link
Owner

Choose a reason for hiding this comment

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

Consider renaming to findSingle (findFirst?) since results limited to 1

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

👍 (pending update)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Updated

import { TransactionData } from "./TxTable.ts";
import { BigNumber, TransactionData } from "../../deps.ts";

export type TransactionDataDTO = {
Copy link
Owner

Choose a reason for hiding this comment

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

What does DTO stand for?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Data Transfer Object

);

assertEquals(await fx.allTxs(txService), {
ready: [],
future: [],
});

console.log("here");
Copy link
Owner

Choose a reason for hiding this comment

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

"here"

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

👍 (pending update)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Haha, updated

@jzaki jzaki merged commit b62c7b2 into main Sep 6, 2021
@jzaki jzaki deleted the agg-52-use-signer branch September 6, 2021 23:27
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants