generated from metaplex-foundation/solana-project-template
-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor plugin authoirty mapping, refactor revoke, remove plugin tests
- Loading branch information
Showing
15 changed files
with
89 additions
and
314 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
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
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 |
---|---|---|
@@ -1,84 +1,38 @@ | ||
import { generateSigner } from '@metaplex-foundation/umi'; | ||
import test from 'ava'; | ||
// import { base58 } from '@metaplex-foundation/umi/serializers'; | ||
|
||
import { | ||
Asset, | ||
AssetWithPlugins, | ||
DataState, | ||
PluginType, | ||
addPlugin, | ||
create, | ||
fetchAsset, | ||
fetchAssetWithPlugins, | ||
removePlugin, | ||
updateAuthority, | ||
formPluginHeader, | ||
plugin, | ||
} from '../src'; | ||
import { createUmi } from './_setup'; | ||
import { assertAsset, createAsset, createUmi } from './_setup'; | ||
|
||
test('it can remove a plugin from an asset', async (t) => { | ||
// Given a Umi instance and a new signer. | ||
const umi = await createUmi(); | ||
const assetAddress = generateSigner(umi); | ||
|
||
// When we create a new account. | ||
await create(umi, { | ||
dataState: DataState.AccountState, | ||
asset: assetAddress, | ||
name: 'Test Bread', | ||
uri: 'https://example.com/bread', | ||
plugins: [], | ||
}).sendAndConfirm(umi); | ||
|
||
// Then an account was created with the correct data. | ||
const asset = await fetchAsset(umi, assetAddress.publicKey); | ||
// console.log("Account State:", asset); | ||
t.like(asset, <Asset>{ | ||
publicKey: assetAddress.publicKey, | ||
updateAuthority: updateAuthority('Address', [umi.identity.publicKey]), | ||
owner: umi.identity.publicKey, | ||
name: 'Test Bread', | ||
uri: 'https://example.com/bread', | ||
const asset = await createAsset(umi, { | ||
plugins: [plugin('Freeze', [{ frozen: false }])], | ||
}); | ||
|
||
await addPlugin(umi, { | ||
asset: assetAddress.publicKey, | ||
plugin: plugin('Freeze', [{ frozen: false }]), | ||
initAuthority: null, | ||
}).sendAndConfirm(umi); | ||
|
||
const asset1 = await fetchAssetWithPlugins(umi, assetAddress.publicKey); | ||
// console.log(JSON.stringify(asset1, (_, v) => typeof v === 'bigint' ? v.toString() : v, 2)); | ||
t.like(asset1, <AssetWithPlugins>{ | ||
publicKey: assetAddress.publicKey, | ||
updateAuthority: updateAuthority('Address', [umi.identity.publicKey]), | ||
await assertAsset(t, umi, { | ||
asset: asset.publicKey, | ||
owner: umi.identity.publicKey, | ||
name: 'Test Bread', | ||
uri: 'https://example.com/bread', | ||
pluginHeader: formPluginHeader(BigInt(120)), | ||
freeze: { | ||
authority: { | ||
owner: true, | ||
type: 'Owner', | ||
}, | ||
offset: BigInt(118), | ||
frozen: false, | ||
}, | ||
}); | ||
}) | ||
|
||
await removePlugin(umi, { | ||
asset: assetAddress.publicKey, | ||
asset: asset.publicKey, | ||
pluginType: PluginType.Freeze, | ||
}).sendAndConfirm(umi); | ||
|
||
const asset2 = await fetchAssetWithPlugins(umi, assetAddress.publicKey); | ||
// console.log(JSON.stringify(asset2, (_, v) => typeof v === 'bigint' ? v.toString() : v, 2)); | ||
t.like(asset2, <AssetWithPlugins>(<unknown>{ | ||
publicKey: assetAddress.publicKey, | ||
updateAuthority: updateAuthority('Address', [umi.identity.publicKey]), | ||
owner: umi.identity.publicKey, | ||
name: 'Test Bread', | ||
uri: 'https://example.com/bread', | ||
pluginHeader: formPluginHeader(BigInt(118)), | ||
})); | ||
const asset2 = await fetchAssetWithPlugins(umi, asset.publicKey); | ||
|
||
t.is(asset2.freeze, undefined); | ||
}); |
Oops, something went wrong.