Skip to content

Commit

Permalink
Merge pull request #411 from chain4travel/fix/update-msig-definition-…
Browse files Browse the repository at this point in the history
…login

fix(login): update outdated MSIG definition during login
  • Loading branch information
aeddaqqa authored Jul 5, 2024
2 parents 3fb1817 + 4887e32 commit 806ab95
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 14 deletions.
13 changes: 7 additions & 6 deletions src/js/wallets/MultisigWallet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,16 +104,17 @@ class MultisigWallet extends WalletCore implements AvaWalletCore {
return JSON.stringify(this.keyData)
}

setKey(key?: string, updatedValues?: { addresses: string[]; threshold: number }): void {
if (updatedValues) {
this.keyData.owner.addresses = updatedValues.addresses
this.keyData.owner.threshold = updatedValues.threshold
} else if (key) {
async setKey(key?: string): Promise<void> {
let hrp = ava.getHRP()
if (key) {
this.keyData = JSON.parse(key)
// The JSON buffer is not our "AvalancheBuffer"
this.keyData.alias = Buffer.from(this.keyData.alias)
this.ethAddress = this.keyData.alias.toString('hex')
}
let alias = bintools.addressToString(hrp, 'P', this.keyData.alias)
let values = await ava.PChain().getMultisigAlias(alias)
this.keyData.owner.addresses = values.addresses
this.keyData.owner.threshold = values.threshold
}

ownerAddresses(): Buffer[] {
Expand Down
2 changes: 1 addition & 1 deletion src/store/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,7 @@ export default new Vuex.Store({
const wallet = new MultisigWallet()
if (file.name) wallet.name = file.name
wallet.accountHash = createHash('sha256').update(file.key).digest()
wallet.setKey(file.key)
await wallet.setKey(file.key)
state.wallets = [...state.wallets, wallet]
state.volatileWallets = [...state.volatileWallets, wallet]
return [wallet]
Expand Down
11 changes: 4 additions & 7 deletions src/views/EditMultisigWallet.vue
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,8 @@ import Alert from '@/components/Alert.vue'
import CamBtn from '@/components/CamBtn.vue'
import CamInput from '@/components/CamInput.vue'
import CamTooltip from '@/components/misc/CamTooltip.vue'
import { getMultisigAliases } from '@/explorer_api'
import { isValidPChainAddress } from '@/helpers/address_helper'
import AvaAsset from '@/js/AvaAsset'
import { AvaNetwork } from '@/js/AvaNetwork'
import { MultisigWallet } from '@/js/wallets/MultisigWallet'
Expand All @@ -176,11 +178,9 @@ import { MultisigAliasTx } from '@c4tplatform/caminojs/dist/apis/platformvm/mult
import { SignatureError } from '@c4tplatform/caminojs/dist/common'
import { ONEAVAX } from '@c4tplatform/caminojs/dist/utils'
import { ModelMultisigTxOwner } from '@c4tplatform/signavaultjs'
import { TranslateResult } from 'vue-i18n'
import { Component, Vue, Watch } from 'vue-property-decorator'
import { WalletHelper } from '../helpers/wallet_helper'
import { TranslateResult } from 'vue-i18n'
import { isValidPChainAddress } from '@/helpers/address_helper'
import { getMultisigAliases } from '@/explorer_api'
const MAX_ADDRESS_COUNT = 128
const UPDATE_ALIAS_TIMEOUT = 3000
Expand Down Expand Up @@ -509,10 +509,7 @@ export default class EditMultisigWallet extends Vue {
this.loading = true
let values = await ava.PChain().getMultisigAlias(alias)
let wallet = this.activeWallet as MultisigWallet
wallet.setKey(undefined, {
addresses: values.addresses,
threshold: values.threshold,
})
await wallet.setKey()
const result = await WalletHelper.sendMultisigAliasTxUpdate(
this.activeWallet as MultisigWallet,
nonEmptyInitialAddresses,
Expand Down

0 comments on commit 806ab95

Please sign in to comment.