Skip to content

Commit

Permalink
Merge pull request #396 from d-Bharti001/account-index-fix
Browse files Browse the repository at this point in the history
Account index and key index fix in MeshWallet
  • Loading branch information
jinglescode authored Nov 18, 2024
2 parents c177f7f + 55c86a6 commit 786f122
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions packages/mesh-wallet/src/mesh/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,11 @@ export class MeshWallet implements IInitiator, ISigner, ISubmitter {
constructor(options: CreateMeshWalletOptions) {
this._networkId = options.networkId;

if (options.fetcher) this._fetcher = options.fetcher;
if (options.submitter) this._submitter = options.submitter;
if (options.accountIndex) this._accountIndex = options.accountIndex;
if (options.keyIndex) this._keyIndex = options.keyIndex;

switch (options.key.type) {
case "root":
this._wallet = new EmbeddedWallet({
Expand Down Expand Up @@ -143,11 +148,6 @@ export class MeshWallet implements IInitiator, ISigner, ISubmitter {
this.buildAddressFromBech32Address(options.key.address);
break;
}

if (options.fetcher) this._fetcher = options.fetcher;
if (options.submitter) this._submitter = options.submitter;
if (options.accountIndex) this._accountIndex = options.accountIndex;
if (options.keyIndex) this._keyIndex = options.keyIndex;
}

/**
Expand Down Expand Up @@ -324,7 +324,12 @@ export class MeshWallet implements IInitiator, ISigner, ISubmitter {
if (address === undefined) {
address = this.getChangeAddress()!;
}
return this._wallet.signData(address, payload);
return this._wallet.signData(
address,
payload,
this._accountIndex,
this._keyIndex,
);
}

/**
Expand Down

0 comments on commit 786f122

Please sign in to comment.