Skip to content

Commit

Permalink
Add 'override' modifier to the overrided methods
Browse files Browse the repository at this point in the history
  • Loading branch information
popzxc committed Jan 27, 2022
1 parent cb360f8 commit adf2254
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 37 deletions.
2 changes: 1 addition & 1 deletion sdk/zksync.js/src/abstract-wallet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ export abstract class AbstractWallet {
}

async getAccountState(): Promise<AccountState> {
return this.provider.getState(this.address());
return await this.provider.getState(this.address());
}

async resolveAccountId(): Promise<number> {
Expand Down
2 changes: 1 addition & 1 deletion sdk/zksync.js/src/provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,7 @@ export class Provider extends SyncProvider {
return await this.transport.request('get_nft_id_by_tx_hash', [txHash]);
}

async disconnect() {
override async disconnect() {
return await this.transport.disconnect();
}
}
Expand Down
9 changes: 7 additions & 2 deletions sdk/zksync.js/src/transport.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,11 +106,16 @@ export class WSTransport extends AbstractJSONRPCTransport {
return transport;
}

subscriptionsSupported(): boolean {
override subscriptionsSupported(): boolean {
return true;
}

async subscribe(subMethod: string, subParams, unsubMethod: string, cb: (data: any) => void): Promise<Subscription> {
override async subscribe(
subMethod: string,
subParams,
unsubMethod: string,
cb: (data: any) => void
): Promise<Subscription> {
const req = { jsonrpc: '2.0', method: subMethod, params: subParams };
const sub = await this.ws.sendRequest(req);

Expand Down
66 changes: 33 additions & 33 deletions sdk/zksync.js/src/wallet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,9 @@ export class Wallet extends AbstractWallet {
private constructor(
public _ethSigner: ethers.Signer,
public _ethMessageSigner: EthMessageSigner,
public cachedAddress: Address,
cachedAddress: Address,
public signer?: Signer,
public accountId?: number,
accountId?: number,
public ethSignerType?: EthSignerType
) {
super(cachedAddress, accountId);
Expand Down Expand Up @@ -130,27 +130,27 @@ export class Wallet extends AbstractWallet {
// Abstract getters
//

ethSigner(): ethers.Signer {
override ethSigner(): ethers.Signer {
return this._ethSigner;
}

ethMessageSigner(): EthMessageSigner {
override ethMessageSigner(): EthMessageSigner {
return this._ethMessageSigner;
}

syncSignerConnected(): boolean {
override syncSignerConnected(): boolean {
return this.signer !== null;
}

async syncSignerPubKeyHash(): Promise<PubKeyHash> {
override async syncSignerPubKeyHash(): Promise<PubKeyHash> {
return await this.signer.pubKeyHash();
}

// *********************
// Batch builder methods
//

async processBatchBuilderTransactions(
override async processBatchBuilderTransactions(
startNonce: Nonce,
txs: BatchBuilderInternalTx[]
): Promise<{ txs: SignedTransaction[]; signature?: TxEthSignature }> {
Expand Down Expand Up @@ -233,7 +233,7 @@ export class Wallet extends AbstractWallet {
// L2 operations
//

async getTransfer(transfer: {
override async getTransfer(transfer: {
to: Address;
token: TokenLike;
amount: BigNumberish;
Expand Down Expand Up @@ -265,7 +265,7 @@ export class Wallet extends AbstractWallet {
return this.signer.signSyncTransfer(transactionData);
}

async signSyncTransfer(transfer: {
override async signSyncTransfer(transfer: {
to: Address;
token: TokenLike;
amount: BigNumberish;
Expand Down Expand Up @@ -301,7 +301,7 @@ export class Wallet extends AbstractWallet {
};
}

async syncTransfer(transfer: {
override async syncTransfer(transfer: {
to: Address;
token: TokenLike;
amount: BigNumberish;
Expand All @@ -322,7 +322,7 @@ export class Wallet extends AbstractWallet {

// ChangePubKey part

async getChangePubKey(changePubKey: {
override async getChangePubKey(changePubKey: {
feeToken: TokenLike;
fee: BigNumberish;
nonce: number;
Expand Down Expand Up @@ -356,7 +356,7 @@ export class Wallet extends AbstractWallet {
return changePubKeyTx;
}

async signSetSigningKey(changePubKey: {
override async signSetSigningKey(changePubKey: {
feeToken: TokenLike;
fee: BigNumberish;
nonce: number;
Expand Down Expand Up @@ -418,7 +418,7 @@ export class Wallet extends AbstractWallet {
};
}

async setSigningKey(changePubKey: {
override async setSigningKey(changePubKey: {
feeToken: TokenLike;
ethAuthType: ChangePubkeyTypes;
fee?: BigNumberish;
Expand Down Expand Up @@ -461,7 +461,7 @@ export class Wallet extends AbstractWallet {

// Withdraw part

async getWithdrawFromSyncToEthereum(withdraw: {
override async getWithdrawFromSyncToEthereum(withdraw: {
ethAddress: string;
token: TokenLike;
amount: BigNumberish;
Expand Down Expand Up @@ -491,7 +491,7 @@ export class Wallet extends AbstractWallet {
return await this.signer.signSyncWithdraw(transactionData);
}

async signWithdrawFromSyncToEthereum(withdraw: {
override async signWithdrawFromSyncToEthereum(withdraw: {
ethAddress: string;
token: TokenLike;
amount: BigNumberish;
Expand Down Expand Up @@ -528,7 +528,7 @@ export class Wallet extends AbstractWallet {
};
}

async withdrawFromSyncToEthereum(withdraw: {
override async withdrawFromSyncToEthereum(withdraw: {
ethAddress: string;
token: TokenLike;
amount: BigNumberish;
Expand All @@ -554,7 +554,7 @@ export class Wallet extends AbstractWallet {

// Forced exit part

async getForcedExit(forcedExit: {
override async getForcedExit(forcedExit: {
target: Address;
token: TokenLike;
fee: BigNumberish;
Expand Down Expand Up @@ -582,7 +582,7 @@ export class Wallet extends AbstractWallet {
return await this.signer.signSyncForcedExit(transactionData);
}

async signSyncForcedExit(forcedExit: {
override async signSyncForcedExit(forcedExit: {
target: Address;
token: TokenLike;
fee: BigNumberish;
Expand Down Expand Up @@ -611,7 +611,7 @@ export class Wallet extends AbstractWallet {
};
}

async syncForcedExit(forcedExit: {
override async syncForcedExit(forcedExit: {
target: Address;
token: TokenLike;
fee?: BigNumberish;
Expand All @@ -631,7 +631,7 @@ export class Wallet extends AbstractWallet {

// Swap part

async getLimitOrder(order: {
override async getLimitOrder(order: {
tokenSell: TokenLike;
tokenBuy: TokenLike;
ratio: TokenRatio | WeiRatio;
Expand All @@ -646,7 +646,7 @@ export class Wallet extends AbstractWallet {
});
}

async getOrder(order: {
override async getOrder(order: {
tokenSell: TokenLike;
tokenBuy: TokenLike;
ratio: TokenRatio | WeiRatio;
Expand Down Expand Up @@ -695,7 +695,7 @@ export class Wallet extends AbstractWallet {
return this.signOrder(signedOrder);
}

async signOrder(order: Order): Promise<Order> {
override async signOrder(order: Order): Promise<Order> {
const stringAmount = BigNumber.from(order.amount).isZero()
? null
: this.provider.tokenSet.formatToken(order.tokenSell, order.amount);
Expand All @@ -715,7 +715,7 @@ export class Wallet extends AbstractWallet {
return order;
}

async getSwap(swap: {
override async getSwap(swap: {
orders: [Order, Order];
feeToken: number;
amounts: [BigNumberish, BigNumberish];
Expand All @@ -736,7 +736,7 @@ export class Wallet extends AbstractWallet {
});
}

async signSyncSwap(swap: {
override async signSyncSwap(swap: {
orders: [Order, Order];
feeToken: number;
amounts: [BigNumberish, BigNumberish];
Expand Down Expand Up @@ -766,7 +766,7 @@ export class Wallet extends AbstractWallet {
};
}

async syncSwap(swap: {
override async syncSwap(swap: {
orders: [Order, Order];
feeToken: TokenLike;
amounts?: [BigNumberish, BigNumberish];
Expand Down Expand Up @@ -795,7 +795,7 @@ export class Wallet extends AbstractWallet {

// Mint NFT part

async getMintNFT(mintNFT: {
override async getMintNFT(mintNFT: {
recipient: string;
contentHash: string;
feeToken: TokenLike;
Expand All @@ -821,7 +821,7 @@ export class Wallet extends AbstractWallet {
return await this.signer.signMintNFT(transactionData);
}

async signMintNFT(mintNFT: {
override async signMintNFT(mintNFT: {
recipient: string;
contentHash: string;
feeToken: TokenLike;
Expand Down Expand Up @@ -850,7 +850,7 @@ export class Wallet extends AbstractWallet {
};
}

async mintNFT(mintNFT: {
override async mintNFT(mintNFT: {
recipient: Address;
contentHash: ethers.BytesLike;
feeToken: TokenLike;
Expand All @@ -871,7 +871,7 @@ export class Wallet extends AbstractWallet {
}

// Withdraw NFT part
async getWithdrawNFT(withdrawNFT: {
override async getWithdrawNFT(withdrawNFT: {
to: string;
token: TokenLike;
feeToken: TokenLike;
Expand Down Expand Up @@ -902,7 +902,7 @@ export class Wallet extends AbstractWallet {
return await this.signer.signWithdrawNFT(transactionData);
}

async signWithdrawNFT(withdrawNFT: {
override async signWithdrawNFT(withdrawNFT: {
to: string;
token: number;
feeToken: TokenLike;
Expand Down Expand Up @@ -935,7 +935,7 @@ export class Wallet extends AbstractWallet {
};
}

async withdrawNFT(withdrawNFT: {
override async withdrawNFT(withdrawNFT: {
to: string;
token: number;
feeToken: TokenLike;
Expand Down Expand Up @@ -964,7 +964,7 @@ export class Wallet extends AbstractWallet {

// Transfer NFT part

async syncTransferNFT(transfer: {
override async syncTransferNFT(transfer: {
to: Address;
token: NFT;
feeToken: TokenLike;
Expand Down Expand Up @@ -1006,7 +1006,7 @@ export class Wallet extends AbstractWallet {

// Note: this method signature requires to specify fee in each transaction.
// For details, see the comment on this method in `AbstractWallet` class.
async syncMultiTransfer(
override async syncMultiTransfer(
transfers: {
to: Address;
token: TokenLike;
Expand Down

0 comments on commit adf2254

Please sign in to comment.