Skip to content

Commit

Permalink
fix msig signer
Browse files Browse the repository at this point in the history
  • Loading branch information
scholtz committed Oct 20, 2024
1 parent 16c4ad0 commit 0b6df08
Showing 1 changed file with 33 additions and 8 deletions.
41 changes: 33 additions & 8 deletions src/store/signer.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,19 @@ const actions = {
if (!fromAccount) {
throw new Error("The from address is not in the list of accounts.");
}
if (!this.state.config.env) {
throw new Error(
"Environment is not properly configured. Please switch to another network and select your network again."
);
}

if (fromAccount.rekeyedTo && fromAccount.rekeyedTo != from) {
if (
fromAccount.data[this.state.config.env] &&
fromAccount.data[this.state.config.env].rekeyedTo &&
fromAccount.data[this.state.config.env].rekeyedTo != from
) {
fromAccount = this.state.wallet.privateAccounts.find(
(a) => a.addr == fromAccount.rekeyedTo
(a) => a.addr == fromAccount.data[this.state.config.env].rekeyedTo
);
if (!fromAccount) {
throw new Error(
Expand Down Expand Up @@ -134,10 +143,19 @@ const actions = {
if (!fromAccount) {
return "?";
}
if (!this.state.config.env) {
throw new Error(
"Environment is not properly configured. Please switch to another network and select your network again."
);
}

if (fromAccount.rekeyedTo && fromAccount.rekeyedTo != from) {
if (
fromAccount.data[this.state.config.env] &&
fromAccount.data[this.state.config.env].rekeyedTo &&
fromAccount.data[this.state.config.env].rekeyedTo != from
) {
fromAccount = this.state.wallet.privateAccounts.find(
(a) => a.addr == fromAccount.rekeyedTo
(a) => a.addr == fromAccount.data[this.state.config.env].rekeyedTo
);
if (!fromAccount) {
throw new Error(
Expand Down Expand Up @@ -324,22 +342,29 @@ const actions = {
if (!txn || !txn.from || !txn.from.publicKey) {
throw new Error("Transaction object is not correct");
}
if (!this.state.config.env) {
throw new Error(
"Environment is not properly configured. Please switch to another network and select your network again."
);
}
const from = algosdk.encodeAddress(txn.from.publicKey);
let fromAccount = this.state.wallet.privateAccounts.find(
(a) => a.addr == from
);

if (fromAccount.rekeyedTo && fromAccount.rekeyedTo != from) {
if (
fromAccount.data[this.state.config.env] &&
fromAccount.data[this.state.config.env].rekeyedTo &&
fromAccount.data[this.state.config.env].rekeyedTo != from
) {
fromAccount = this.state.wallet.privateAccounts.find(
(a) => a.addr == fromAccount.rekeyedTo
(a) => a.addr == fromAccount.data[this.state.config.env].rekeyedTo
);
if (!fromAccount) {
throw new Error(
"The rekeyed signator address from is not in the list of accounts."
);
}
}

if (!fromAccount.params) {
throw new Error(`Address is not multisig: ${fromAccount.addr}`);
}
Expand Down

0 comments on commit 0b6df08

Please sign in to comment.