Skip to content

Commit

Permalink
(fix) CJS distribution for wallet-zilliqa (#242)
Browse files Browse the repository at this point in the history
(fix) CJS distribution of objects with an initializer and a constructor appears to be broken, so initialize chainId in the constructor.
  • Loading branch information
rrw-zilliqa authored Jan 19, 2025
1 parent 3ac0fe1 commit 63bd28b
Showing 1 changed file with 6 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,15 @@ export abstract class ZilliqaWalletClient extends WalletClientBase {
export class ZilliqaJSViemWalletClient extends ZilliqaWalletClient {
zilliqa: Zilliqa;
viem: ViemEVMWalletClient;
chainId = 0;
// This was originally a static assignment; however, this causes
// typescript to emit invalid JS when compiling the CJS version of
// the distribution package, so it is now initialized in the
// constructor.
chainId;

constructor(client: ViemWalletClient, node: string, account: Account, chainId: number, options?: ViemOptions) {
super();
this.chainId = 0;
this.viem = new ViemEVMWalletClient(client, options);
this.zilliqa = new Zilliqa(node);
this.zilliqa.wallet.addByPrivateKey(account.privateKey);
Expand Down

0 comments on commit 63bd28b

Please sign in to comment.