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

Adding expiration for delegates #1063

Draft
wants to merge 13 commits into
base: master
Choose a base branch
from
131 changes: 128 additions & 3 deletions token-metadata/js/idl/mpl_token_metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -4671,7 +4671,7 @@
]
},
{
"name": "UpdateV1",
"name": "DataV1",
"fields": [
{
"name": "authorization_data",
Expand Down Expand Up @@ -4759,6 +4759,45 @@
}
}
]
},
{
"name": "AuthorityV1",
"fields": [
{
"name": "authorization_data",
"type": {
"option": {
"defined": "AuthorizationData"
}
}
}
]
},
{
"name": "CollectionItemV1",
"fields": [
{
"name": "authorization_data",
"type": {
"option": {
"defined": "AuthorizationData"
}
}
}
]
},
{
"name": "ProgrammableConfigItemV1",
"fields": [
{
"name": "authorization_data",
"type": {
"option": {
"defined": "AuthorizationData"
}
}
}
]
}
]
}
Expand All @@ -4778,7 +4817,7 @@
"name": "TransferV1"
},
{
"name": "UpdateV1"
"name": "DataV1"
},
{
"name": "UtilityV1"
Expand All @@ -4797,6 +4836,15 @@
},
{
"name": "MigrationV1"
},
{
"name": "AuthorityV1"
},
{
"name": "CollectionItemV1"
},
{
"name": "ProgrammableConfigItemV1"
}
]
}
Expand All @@ -4816,10 +4864,16 @@
"name": "Use"
},
{
"name": "Update"
"name": "Data"
},
{
"name": "ProgrammableConfig"
},
{
"name": "CollectionItem"
},
{
"name": "ProgrammableConfigItem"
}
]
}
Expand Down Expand Up @@ -4974,6 +5028,77 @@
}
}
]
},
{
"name": "V2",
"fields": [
{
"name": "new_update_authority",
"type": {
"option": "publicKey"
}
},
{
"name": "data",
"type": {
"option": {
"defined": "Data"
}
}
},
{
"name": "primary_sale_happened",
"type": {
"option": "bool"
}
},
{
"name": "is_mutable",
"type": {
"option": "bool"
}
},
{
"name": "collection",
"type": {
"defined": "CollectionToggle"
}
},
{
"name": "collection_details",
"type": {
"defined": "CollectionDetailsToggle"
}
},
{
"name": "uses",
"type": {
"defined": "UsesToggle"
}
},
{
"name": "rule_set",
"type": {
"defined": "RuleSetToggle"
}
},
{
"name": "token_standard",
"type": {
"option": {
"defined": "TokenStandard"
}
}
},
{
"name": "authorization_data",
"type": {
"option": {
"defined": "AuthorizationData"
}
}
}
]
}
]
}
Expand Down
50 changes: 43 additions & 7 deletions token-metadata/js/src/generated/types/DelegateArgs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export type DelegateArgsRecord = {
CollectionV1: { authorizationData: beet.COption<AuthorizationData> };
SaleV1: { amount: beet.bignum; authorizationData: beet.COption<AuthorizationData> };
TransferV1: { amount: beet.bignum; authorizationData: beet.COption<AuthorizationData> };
UpdateV1: { authorizationData: beet.COption<AuthorizationData> };
DataV1: { authorizationData: beet.COption<AuthorizationData> };
UtilityV1: { amount: beet.bignum; authorizationData: beet.COption<AuthorizationData> };
StakingV1: { amount: beet.bignum; authorizationData: beet.COption<AuthorizationData> };
StandardV1: { amount: beet.bignum };
Expand All @@ -32,6 +32,9 @@ export type DelegateArgsRecord = {
authorizationData: beet.COption<AuthorizationData>;
};
ProgrammableConfigV1: { authorizationData: beet.COption<AuthorizationData> };
AuthorityV1: { authorizationData: beet.COption<AuthorizationData> };
CollectionItemV1: { authorizationData: beet.COption<AuthorizationData> };
ProgrammableConfigItemV1: { authorizationData: beet.COption<AuthorizationData> };
};

/**
Expand All @@ -55,9 +58,8 @@ export const isDelegateArgsSaleV1 = (x: DelegateArgs): x is DelegateArgs & { __k
export const isDelegateArgsTransferV1 = (
x: DelegateArgs,
): x is DelegateArgs & { __kind: 'TransferV1' } => x.__kind === 'TransferV1';
export const isDelegateArgsUpdateV1 = (
x: DelegateArgs,
): x is DelegateArgs & { __kind: 'UpdateV1' } => x.__kind === 'UpdateV1';
export const isDelegateArgsDataV1 = (x: DelegateArgs): x is DelegateArgs & { __kind: 'DataV1' } =>
x.__kind === 'DataV1';
export const isDelegateArgsUtilityV1 = (
x: DelegateArgs,
): x is DelegateArgs & { __kind: 'UtilityV1' } => x.__kind === 'UtilityV1';
Expand All @@ -73,6 +75,16 @@ export const isDelegateArgsLockedTransferV1 = (
export const isDelegateArgsProgrammableConfigV1 = (
x: DelegateArgs,
): x is DelegateArgs & { __kind: 'ProgrammableConfigV1' } => x.__kind === 'ProgrammableConfigV1';
export const isDelegateArgsAuthorityV1 = (
x: DelegateArgs,
): x is DelegateArgs & { __kind: 'AuthorityV1' } => x.__kind === 'AuthorityV1';
export const isDelegateArgsCollectionItemV1 = (
x: DelegateArgs,
): x is DelegateArgs & { __kind: 'CollectionItemV1' } => x.__kind === 'CollectionItemV1';
export const isDelegateArgsProgrammableConfigItemV1 = (
x: DelegateArgs,
): x is DelegateArgs & { __kind: 'ProgrammableConfigItemV1' } =>
x.__kind === 'ProgrammableConfigItemV1';

/**
* @category userTypes
Expand Down Expand Up @@ -110,10 +122,10 @@ export const delegateArgsBeet = beet.dataEnum<DelegateArgsRecord>([
],

[
'UpdateV1',
new beet.FixableBeetArgsStruct<DelegateArgsRecord['UpdateV1']>(
'DataV1',
new beet.FixableBeetArgsStruct<DelegateArgsRecord['DataV1']>(
[['authorizationData', beet.coption(authorizationDataBeet)]],
'DelegateArgsRecord["UpdateV1"]',
'DelegateArgsRecord["DataV1"]',
),
],

Expand Down Expand Up @@ -166,4 +178,28 @@ export const delegateArgsBeet = beet.dataEnum<DelegateArgsRecord>([
'DelegateArgsRecord["ProgrammableConfigV1"]',
),
],

[
'AuthorityV1',
new beet.FixableBeetArgsStruct<DelegateArgsRecord['AuthorityV1']>(
[['authorizationData', beet.coption(authorizationDataBeet)]],
'DelegateArgsRecord["AuthorityV1"]',
),
],

[
'CollectionItemV1',
new beet.FixableBeetArgsStruct<DelegateArgsRecord['CollectionItemV1']>(
[['authorizationData', beet.coption(authorizationDataBeet)]],
'DelegateArgsRecord["CollectionItemV1"]',
),
],

[
'ProgrammableConfigItemV1',
new beet.FixableBeetArgsStruct<DelegateArgsRecord['ProgrammableConfigItemV1']>(
[['authorizationData', beet.coption(authorizationDataBeet)]],
'DelegateArgsRecord["ProgrammableConfigItemV1"]',
),
],
]) as beet.FixableBeet<DelegateArgs, DelegateArgs>;
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,10 @@ export enum MetadataDelegateRole {
Authority,
Collection,
Use,
Update,
Data,
ProgrammableConfig,
CollectionItem,
ProgrammableConfigItem,
}

/**
Expand Down
5 changes: 4 additions & 1 deletion token-metadata/js/src/generated/types/RevokeArgs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,16 @@ export enum RevokeArgs {
CollectionV1,
SaleV1,
TransferV1,
UpdateV1,
DataV1,
UtilityV1,
StakingV1,
StandardV1,
LockedTransferV1,
ProgrammableConfigV1,
MigrationV1,
AuthorityV1,
CollectionItemV1,
ProgrammableConfigItemV1,
}

/**
Expand Down
34 changes: 34 additions & 0 deletions token-metadata/js/src/generated/types/UpdateArgs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import { CollectionDetailsToggle, collectionDetailsToggleBeet } from './Collecti
import { UsesToggle, usesToggleBeet } from './UsesToggle';
import { RuleSetToggle, ruleSetToggleBeet } from './RuleSetToggle';
import { AuthorizationData, authorizationDataBeet } from './AuthorizationData';
import { TokenStandard, tokenStandardBeet } from './TokenStandard';
/**
* This type is used to derive the {@link UpdateArgs} type as well as the de/serializer.
* However don't refer to it in your code but use the {@link UpdateArgs} type instead.
Expand All @@ -35,6 +36,18 @@ export type UpdateArgsRecord = {
ruleSet: RuleSetToggle;
authorizationData: beet.COption<AuthorizationData>;
};
V2: {
newUpdateAuthority: beet.COption<web3.PublicKey>;
data: beet.COption<Data>;
primarySaleHappened: beet.COption<boolean>;
isMutable: beet.COption<boolean>;
collection: CollectionToggle;
collectionDetails: CollectionDetailsToggle;
uses: UsesToggle;
ruleSet: RuleSetToggle;
tokenStandard: beet.COption<TokenStandard>;
authorizationData: beet.COption<AuthorizationData>;
};
};

/**
Expand All @@ -52,6 +65,8 @@ export type UpdateArgs = beet.DataEnumKeyAsKind<UpdateArgsRecord>;

export const isUpdateArgsV1 = (x: UpdateArgs): x is UpdateArgs & { __kind: 'V1' } =>
x.__kind === 'V1';
export const isUpdateArgsV2 = (x: UpdateArgs): x is UpdateArgs & { __kind: 'V2' } =>
x.__kind === 'V2';

/**
* @category userTypes
Expand All @@ -75,4 +90,23 @@ export const updateArgsBeet = beet.dataEnum<UpdateArgsRecord>([
'UpdateArgsRecord["V1"]',
),
],

[
'V2',
new beet.FixableBeetArgsStruct<UpdateArgsRecord['V2']>(
[
['newUpdateAuthority', beet.coption(beetSolana.publicKey)],
['data', beet.coption(dataBeet)],
['primarySaleHappened', beet.coption(beet.bool)],
['isMutable', beet.coption(beet.bool)],
['collection', collectionToggleBeet],
['collectionDetails', collectionDetailsToggleBeet],
['uses', usesToggleBeet],
['ruleSet', ruleSetToggleBeet],
['tokenStandard', beet.coption(tokenStandardBeet)],
['authorizationData', beet.coption(authorizationDataBeet)],
],
'UpdateArgsRecord["V2"]',
),
],
]) as beet.FixableBeet<UpdateArgs, UpdateArgs>;
Loading