Skip to content

Commit

Permalink
fix(signer): add support for zks RPC methods in Signer
Browse files Browse the repository at this point in the history
  • Loading branch information
danijelTxFusion committed Apr 4, 2024
1 parent a395dae commit c63faea
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/signer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -171,13 +171,14 @@ export class EIP712Signer {
export class Signer extends AdapterL2(ethers.JsonRpcSigner) {
public override provider!: Provider;
public eip712!: EIP712Signer;
protected providerL2?: Provider;

override _signerL2() {
return this;
}

override _providerL2() {
return this.provider;
return this.providerL2!;
}

/**
Expand Down Expand Up @@ -379,6 +380,8 @@ export class Signer extends AdapterL2(ethers.JsonRpcSigner) {
*
* @param signer The signer from browser wallet.
* @param chainId The chain ID of the network.
* @param [zksyncProvider] The provider instance for connecting to a L2 network. If not provided,
* the methods from the `zks` namespace are not supported, and interaction with them will result in an error.
*
* @example
*
Expand All @@ -392,10 +395,12 @@ export class Signer extends AdapterL2(ethers.JsonRpcSigner) {
*/
static from(
signer: ethers.JsonRpcSigner & {provider: Provider},
chainId: number
chainId: number,
zksyncProvider?: Provider
): Signer {
const newSigner: Signer = Object.setPrototypeOf(signer, Signer.prototype);
newSigner.eip712 = new EIP712Signer(newSigner, chainId);
newSigner.providerL2 = zksyncProvider;
return newSigner;
}

Expand Down

0 comments on commit c63faea

Please sign in to comment.