generated from metaplex-foundation/solana-project-template
-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add ImmutableMetadata && AddBlocker plugins * Update autogenerated parts * add tests * change the order of enums * update generated part * added tests for ensuring that UA is the only one who can add the plugin * added tests for ensuring that UA is the only one who can add the plugin for collection and nested plugins * update tests * add audit details to readme (#103) * removed audit warning (#108) * regenerated clients * updated tests * updated rust clients
- Loading branch information
1 parent
e6a8331
commit 38774bf
Showing
24 changed files
with
958 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
/** | ||
* This code was AUTOGENERATED using the kinobi library. | ||
* Please DO NOT EDIT THIS FILE, instead use visitors | ||
* to add features, then rerun kinobi to update it. | ||
* | ||
* @see https://github.com/metaplex-foundation/kinobi | ||
*/ | ||
|
||
import { Serializer, struct } from '@metaplex-foundation/umi/serializers'; | ||
|
||
export type AddBlocker = {}; | ||
|
||
export type AddBlockerArgs = AddBlocker; | ||
|
||
export function getAddBlockerSerializer(): Serializer< | ||
AddBlockerArgs, | ||
AddBlocker | ||
> { | ||
return struct<AddBlocker>([], { description: 'AddBlocker' }) as Serializer< | ||
AddBlockerArgs, | ||
AddBlocker | ||
>; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
/** | ||
* This code was AUTOGENERATED using the kinobi library. | ||
* Please DO NOT EDIT THIS FILE, instead use visitors | ||
* to add features, then rerun kinobi to update it. | ||
* | ||
* @see https://github.com/metaplex-foundation/kinobi | ||
*/ | ||
|
||
import { Serializer, struct } from '@metaplex-foundation/umi/serializers'; | ||
|
||
export type ImmutableMetadata = {}; | ||
|
||
export type ImmutableMetadataArgs = ImmutableMetadata; | ||
|
||
export function getImmutableMetadataSerializer(): Serializer< | ||
ImmutableMetadataArgs, | ||
ImmutableMetadata | ||
> { | ||
return struct<ImmutableMetadata>([], { | ||
description: 'ImmutableMetadata', | ||
}) as Serializer<ImmutableMetadataArgs, ImmutableMetadata>; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,178 @@ | ||
import test from 'ava'; | ||
import { generateSigner } from '@metaplex-foundation/umi'; | ||
|
||
import { addPluginV1, createPlugin, pluginAuthorityPair } from '../../../src'; | ||
import { | ||
DEFAULT_ASSET, | ||
assertAsset, | ||
createAsset, | ||
createUmi, | ||
} from '../../_setup'; | ||
|
||
test('it cannot add UA-managed plugin if addBlocker had been added on creation', async (t) => { | ||
// Given a Umi instance and a new signer. | ||
const umi = await createUmi(); | ||
|
||
const asset = await createAsset(umi, { | ||
plugins: [ | ||
pluginAuthorityPair({ | ||
type: 'AddBlocker', | ||
}), | ||
], | ||
}); | ||
|
||
const result = addPluginV1(umi, { | ||
asset: asset.publicKey, | ||
plugin: createPlugin({ | ||
type: 'Attributes', | ||
data: { | ||
attributeList: [], | ||
}, | ||
}), | ||
}).sendAndConfirm(umi); | ||
|
||
await t.throwsAsync(result, { | ||
name: 'InvalidAuthority', | ||
}); | ||
}); | ||
|
||
test('it can add plugins unless AddBlocker is added', async (t) => { | ||
const umi = await createUmi(); | ||
const asset = await createAsset(umi); | ||
|
||
await addPluginV1(umi, { | ||
asset: asset.publicKey, | ||
plugin: createPlugin({ | ||
type: 'Attributes', | ||
data: { | ||
attributeList: [], | ||
}, | ||
}), | ||
}).sendAndConfirm(umi); | ||
|
||
await addPluginV1(umi, { | ||
asset: asset.publicKey, | ||
plugin: createPlugin({ | ||
type: 'AddBlocker', | ||
}), | ||
}).sendAndConfirm(umi); | ||
|
||
await assertAsset(t, umi, { | ||
...DEFAULT_ASSET, | ||
asset: asset.publicKey, | ||
owner: umi.identity.publicKey, | ||
attributes: { | ||
authority: { | ||
type: 'UpdateAuthority', | ||
}, | ||
attributeList: [], | ||
}, | ||
addBlocker: { | ||
authority: { | ||
type: 'UpdateAuthority', | ||
}, | ||
}, | ||
}); | ||
|
||
const result = addPluginV1(umi, { | ||
asset: asset.publicKey, | ||
plugin: createPlugin({ | ||
type: 'Attributes', | ||
data: { | ||
attributeList: [], | ||
}, | ||
}), | ||
}).sendAndConfirm(umi); | ||
|
||
await t.throwsAsync(result, { | ||
name: 'InvalidAuthority', | ||
}); | ||
}); | ||
|
||
test('it can add owner-managed plugins even if AddBlocker had been added', async (t) => { | ||
// Given a Umi instance and a new signer. | ||
const umi = await createUmi(); | ||
|
||
const asset = await createAsset(umi, { | ||
plugins: [ | ||
pluginAuthorityPair({ | ||
type: 'AddBlocker', | ||
}), | ||
], | ||
}); | ||
|
||
await addPluginV1(umi, { | ||
asset: asset.publicKey, | ||
plugin: createPlugin({ type: 'FreezeDelegate', data: { frozen: false } }), | ||
}).sendAndConfirm(umi); | ||
|
||
await assertAsset(t, umi, { | ||
...DEFAULT_ASSET, | ||
asset: asset.publicKey, | ||
owner: umi.identity.publicKey, | ||
freezeDelegate: { | ||
authority: { | ||
type: 'Owner', | ||
}, | ||
frozen: false, | ||
}, | ||
addBlocker: { | ||
authority: { | ||
type: 'UpdateAuthority', | ||
}, | ||
}, | ||
}); | ||
}); | ||
|
||
test('it states that UA is the only one who can add the AddBlocker', async (t) => { | ||
const umi = await createUmi(); | ||
const updateAuthority = generateSigner(umi); | ||
const randomUser = generateSigner(umi); | ||
const asset = await createAsset(umi, { | ||
updateAuthority: updateAuthority.publicKey, | ||
}); | ||
|
||
// random keypair can't add AddBlocker | ||
let result = addPluginV1(umi, { | ||
authority: randomUser, | ||
asset: asset.publicKey, | ||
plugin: createPlugin({ | ||
type: 'AddBlocker', | ||
}), | ||
}).sendAndConfirm(umi); | ||
|
||
await t.throwsAsync(result, { | ||
name: 'NoApprovals', | ||
}); | ||
|
||
// Owner can't add AddBlocker | ||
result = addPluginV1(umi, { | ||
authority: umi.identity, | ||
asset: asset.publicKey, | ||
plugin: createPlugin({ | ||
type: 'AddBlocker', | ||
}), | ||
}).sendAndConfirm(umi); | ||
|
||
await t.throwsAsync(result, { | ||
name: 'NoApprovals', | ||
}); | ||
|
||
// UA CAN add AddBlocker | ||
await addPluginV1(umi, { | ||
authority: updateAuthority, | ||
asset: asset.publicKey, | ||
plugin: createPlugin({ type: 'AddBlocker' }), | ||
}).sendAndConfirm(umi); | ||
|
||
await assertAsset(t, umi, { | ||
...DEFAULT_ASSET, | ||
asset: asset.publicKey, | ||
owner: umi.identity.publicKey, | ||
addBlocker: { | ||
authority: { | ||
type: 'UpdateAuthority', | ||
}, | ||
}, | ||
}); | ||
}); |
Oops, something went wrong.