Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

nodejs: add multi and empty unlock classes #1627

Merged
merged 9 commits into from
Nov 20, 2023
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,14 @@ enum UnlockType {
* An NFT unlock.
*/
Nft = 4,
/**
* A multi unlock.
*/
Multi = 5,
/**
* An empty unlock.
*/
Empty = 6,
}

/**
Expand Down Expand Up @@ -139,6 +147,33 @@ class NftUnlock extends Unlock {
}
}

/**
* Unlocks a MultiAddress with a list of other unlocks.
*/
class MultiUnlock extends Unlock {
/**
* The inner unlocks.
*/
readonly unlocks: Unlock[];
thibault-martinez marked this conversation as resolved.
Show resolved Hide resolved

/**
* @param unlocks The inner unlocks.
*/
constructor(unlocks: Unlock[]) {
super(UnlockType.Multi);
this.unlocks = unlocks;
}
}

/**
* 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: [
Expand All @@ -162,6 +197,14 @@ const UnlockDiscriminator = {
value: NftUnlock,
name: UnlockType.Nft as any,
},
{
value: MultiUnlock,
name: UnlockType.Multi as any,
},
{
value: EmptyUnlock,
name: UnlockType.Empty as any,
},
],
};

Expand All @@ -173,5 +216,7 @@ export {
AccountUnlock,
AnchorUnlock,
NftUnlock,
MultiUnlock,
EmptyUnlock,
UnlockDiscriminator,
};
Loading