Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix Cannot access 'UnlockDiscriminator' before initialization
Browse files Browse the repository at this point in the history
Thoralf-M committed Nov 17, 2023
1 parent 5e29239 commit 3d589f8
Showing 1 changed file with 38 additions and 11 deletions.
Original file line number Diff line number Diff line change
@@ -147,6 +147,15 @@ class NftUnlock extends Unlock {
}
}

/**
* Used to maintain correct index relationship between addresses and signatures when unlocking a MultiUnlock where not all addresses are unlocked.
*/
class EmptyUnlock extends Unlock {
constructor() {
super(UnlockType.Empty);
}
}

/**
* Unlocks a MultiAddress with a list of other unlocks.
*/
@@ -155,8 +164,35 @@ class MultiUnlock extends Unlock {
* The inner unlocks.
*/
@Type(() => Unlock, {
// @ts-ignore:next-line: no-use-before-declare
discriminator: UnlockDiscriminator,
discriminator: {
property: 'type',
subTypes: [
{
value: SignatureUnlock,
name: UnlockType.Signature as any,
},
{
value: ReferenceUnlock,
name: UnlockType.Reference as any,
},
{
value: AccountUnlock,
name: UnlockType.Account as any,
},
{
value: AnchorUnlock,
name: UnlockType.Anchor as any,
},
{
value: NftUnlock,
name: UnlockType.Nft as any,
},
{
value: EmptyUnlock,
name: UnlockType.Empty as any,
},
],
},
})
readonly unlocks: Unlock[];

@@ -169,15 +205,6 @@ class MultiUnlock extends Unlock {
}
}

/**
* Used to maintain correct index relationship between addresses and signatures when unlocking a MultiUnlock where not all addresses are unlocked.
*/
class EmptyUnlock extends Unlock {
constructor() {
super(UnlockType.Empty);
}
}

const UnlockDiscriminator = {
property: 'type',
subTypes: [

0 comments on commit 3d589f8

Please sign in to comment.