Correctly handle states in pairDevice()
This commit is contained in:
parent
62ccfec315
commit
18d46531a0
@ -686,7 +686,19 @@ export default class Services {
|
||||
|
||||
let spAddressList: string[] = [];
|
||||
try {
|
||||
const encodedSpAddressList = process.states[0].public_data['pairedAddresses'];
|
||||
let encodedSpAddressList: number[] = [];
|
||||
if (this.stateId) {
|
||||
const state = process.states.find(state => state.state_id === this.stateId);
|
||||
if (state) {
|
||||
encodedSpAddressList = state.public_data['pairedAddresses'];
|
||||
}
|
||||
} else {
|
||||
// We assume it's the last commited state
|
||||
const lastCommitedState = this.getLastCommitedState(process);
|
||||
if (lastCommitedState) {
|
||||
encodedSpAddressList = lastCommitedState.public_data['pairedAddresses'];
|
||||
}
|
||||
}
|
||||
spAddressList = this.sdkClient.decode_value(encodedSpAddressList);
|
||||
if (!spAddressList || spAddressList.length == 0) {
|
||||
throw new Error('Empty pairedAddresses');
|
||||
|
Loading…
x
Reference in New Issue
Block a user