diff --git a/bindings/nodejs/lib/types/block/payload/signed_transaction/unlock.ts b/bindings/nodejs/lib/types/block/payload/signed_transaction/unlock.ts index de2107e7d2..b9e73199db 100644 --- a/bindings/nodejs/lib/types/block/payload/signed_transaction/unlock.ts +++ b/bindings/nodejs/lib/types/block/payload/signed_transaction/unlock.ts @@ -28,6 +28,14 @@ enum UnlockType { * An NFT unlock. */ Nft = 4, + /** + * A multi unlock. + */ + Multi = 5, + /** + * An empty unlock. + */ + Empty = 6, } /** @@ -139,6 +147,64 @@ 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. + */ +class MultiUnlock extends Unlock { + /** + * The inner unlocks. + */ + @Type(() => Unlock, { + 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[]; + + /** + * @param unlocks The inner unlocks. + */ + constructor(unlocks: Unlock[]) { + super(UnlockType.Multi); + this.unlocks = unlocks; + } +} + const UnlockDiscriminator = { property: 'type', subTypes: [ @@ -162,6 +228,14 @@ const UnlockDiscriminator = { value: NftUnlock, name: UnlockType.Nft as any, }, + { + value: MultiUnlock, + name: UnlockType.Multi as any, + }, + { + value: EmptyUnlock, + name: UnlockType.Empty as any, + }, ], }; @@ -173,5 +247,7 @@ export { AccountUnlock, AnchorUnlock, NftUnlock, + MultiUnlock, + EmptyUnlock, UnlockDiscriminator, };