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

Tool 393 add relayer v 3 support #543

Merged
merged 6 commits into from
Dec 12, 2024
Merged

Conversation

danielailie
Copy link
Contributor

No description provided.

@danielailie danielailie self-assigned this Dec 12, 2024
Comment on lines 63 to 66
if (transaction.relayer && !transaction.relayer.isEmpty()) {
protoTransaction.Relayer = transaction.relayer.getPublicKey();
protoTransaction.RelayerSignature = transaction.relayerSignature;
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Let's extract to a function similar to the guardian check above, and also check if relayer signature is set.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

we discussed about this internally and said it is not needed

it("should serialize transaction with relayer", async () => {
const transaction = new Transaction({
chainID: networkConfig.ChainID,
sender: wallets.alice.address.bech32(),
Copy link
Contributor

Choose a reason for hiding this comment

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

use toBech32(), here and bellow.

/**
* The relayer, in address format, next version all the other addresses will not be string anymore.
*/
public relayer?: Address;
Copy link
Contributor

Choose a reason for hiding this comment

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

maybe this doesn't need to be optional. Make it optional on the constructor and if not provided, set to Address.empty()?

Comment on lines 98 to 100
applyRelayer(transaction: ITransaction, relayer: Address) {
transaction.relayer = relayer;
}
Copy link
Contributor

Choose a reason for hiding this comment

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

this is kind of useless since one can simply do:

transaction.relayer = relayerAddress;

@@ -25,9 +26,11 @@ export class TransactionsConverter {
chainID: transaction.chainID.valueOf(),
version: transaction.version,
options: transaction.options == 0 ? undefined : transaction.options,
relayer: !transaction.relayer || transaction.relayer.isEmpty() ? undefined : transaction.relayer.toBech32(),
Copy link
Contributor

Choose a reason for hiding this comment

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

We should have relayer and guardian done in the same way. Which way should we choose?

Copy link
Contributor

Choose a reason for hiding this comment

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

Oh, now I see, cannot be same as guardian, since that's a string 👍

@@ -46,6 +49,7 @@ export class TransactionsConverter {
nonce: BigInt(object.nonce),
value: BigInt(object.value || ""),
receiver: object.receiver,
relayer: object.relayer ? Address.newFromBech32(object.relayer) : Address.empty(),
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we have it the same as guardian? If so, which way?

Copy link
Contributor

Choose a reason for hiding this comment

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

Oh, now I see, cannot be same as guardian, since that's a string 👍

@@ -60,6 +60,11 @@ export class ProtoSerializer {
protoTransaction.GuardianSignature = transaction.guardianSignature;
}

if (transaction.relayer && !transaction.relayer.isEmpty()) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Can refactor to have a mini private function isRelayedTransaction (for symmetry) .

@@ -92,6 +91,11 @@ export class Transaction {
*/
public guardian: string;

/**
* The relayer, in address format, next version all the other addresses will not be string anymore.
Copy link
Contributor

Choose a reason for hiding this comment

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

Can be rephrased.

The relayer address.
Note: in the next major version, `sender`, `receiver` and `guardian` will also have the type `Address`, instead of `string`.

@@ -137,9 +148,11 @@ export class Transaction {
this.version = Number(options.version?.valueOf() || TRANSACTION_VERSION_DEFAULT);
this.options = Number(options.options?.valueOf() || TRANSACTION_OPTIONS_DEFAULT);
this.guardian = options.guardian ? this.addressAsBech32(options.guardian) : "";
this.relayer = options.relayer?.isEmpty() ? undefined : options.relayer;
Copy link
Contributor

Choose a reason for hiding this comment

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

Oh, now I see, cannot be same as guardian, since that's a string 👍

@@ -94,6 +95,17 @@ export class TransactionComputer {
transaction.guardian = guardian;
}

applyRelayer(transaction: ITransaction, relayer: Address) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Contributor

Choose a reason for hiding this comment

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

I suggest we delete it from specs, as well. It is useless.

}

isRelayedV3Transaction(transaction: ITransaction) {
if (transaction.relayer && !transaction.relayer.isEmpty()) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Can use a one-line return (can also stay as it is).

/**
* The relayer, in address format, next version all the other addresses will not be string anymore.
*/
public relayer?: Address;
Copy link
Contributor

Choose a reason for hiding this comment

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

@danielailie danielailie merged commit 9bc160b into main Dec 12, 2024
4 checks passed
@danielailie danielailie deleted the TOOL-393-add-relayer-v-3-support branch December 12, 2024 11:28
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.

3 participants