Skip to content

Commit 40c0b33

Browse files
firmianavanlin.fan
andauthored
chore: refactor Signer for convenient overwriting (#941)
Co-authored-by: lin.fan <lin.fan@flashdot.com>
1 parent a4e5e33 commit 40c0b33

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

src/signer/default.ts

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ export class Signer implements SignerInterface {
4040

4141
public async signMessage(typedData: TypedData, accountAddress: string): Promise<Signature> {
4242
const msgHash = getMessageHash(typedData, accountAddress);
43-
return starkCurve.sign(msgHash, this.pk);
43+
return this.signRaw(msgHash);
4444
}
4545

4646
public async signTransaction(
@@ -73,7 +73,7 @@ export class Signer implements SignerInterface {
7373
throw Error('unsupported signTransaction version');
7474
}
7575

76-
return starkCurve.sign(msgHash as string, this.pk);
76+
return this.signRaw(msgHash as string);
7777
}
7878

7979
public async signDeployAccountTransaction(
@@ -105,7 +105,7 @@ export class Signer implements SignerInterface {
105105
throw Error('unsupported signDeployAccountTransaction version');
106106
}
107107

108-
return starkCurve.sign(msgHash as string, this.pk);
108+
return this.signRaw(msgHash as string);
109109
}
110110

111111
public async signDeclareTransaction(
@@ -132,6 +132,10 @@ export class Signer implements SignerInterface {
132132
throw Error('unsupported signDeclareTransaction version');
133133
}
134134

135-
return starkCurve.sign(msgHash as string, this.pk);
135+
return this.signRaw(msgHash as string);
136+
}
137+
138+
protected async signRaw(msgHash: string): Promise<Signature> {
139+
return starkCurve.sign(msgHash, this.pk);
136140
}
137141
}

0 commit comments

Comments
 (0)