generated from metaplex-foundation/solana-project-template
-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' of github.com:blockiosaurus/blob-asset into main
- Loading branch information
Showing
14 changed files
with
168 additions
and
124 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,58 +1,67 @@ | ||
import { PublicKey, Umi, sol } from '@metaplex-foundation/umi'; | ||
import test from 'ava'; | ||
|
||
import { | ||
PluginType, | ||
addPlugin, | ||
plugin, | ||
removePlugin, | ||
} from '../src'; | ||
import { PluginType, addPlugin, plugin, removePlugin } from '../src'; | ||
import { createAsset, createUmi } from './_setup'; | ||
|
||
const hasCollectAmount = async (umi: Umi, address: PublicKey) => { | ||
const account = await umi.rpc.getAccount(address); | ||
if (account.exists) { | ||
const rent = await umi.rpc.getRent(account.data.length) | ||
const diff = account.lamports.basisPoints - rent.basisPoints | ||
return diff === sol(0.0015).basisPoints | ||
const rent = await umi.rpc.getRent(account.data.length); | ||
const diff = account.lamports.basisPoints - rent.basisPoints; | ||
return diff === sol(0.0015).basisPoints; | ||
} | ||
return false | ||
} | ||
return false; | ||
}; | ||
|
||
test('it can create a new asset with collect amount', async (t) => { | ||
// Given a Umi instance and a new signer. | ||
const umi = await createUmi(); | ||
const asset = await createAsset(umi, {}) | ||
const asset = await createAsset(umi, {}); | ||
|
||
t.assert(await hasCollectAmount(umi, asset.publicKey), 'Collect amount not found') | ||
t.assert( | ||
await hasCollectAmount(umi, asset.publicKey), | ||
'Collect amount not found' | ||
); | ||
}); | ||
|
||
test('it can add asset plugin with collect amount', async (t) => { | ||
// Given a Umi instance and a new signer. | ||
const umi = await createUmi(); | ||
const asset = await createAsset(umi, {}) | ||
const asset = await createAsset(umi, {}); | ||
|
||
await addPlugin(umi, { | ||
asset: asset.publicKey, | ||
plugin: plugin('Freeze', [{ frozen: true }]), | ||
initAuthority: null | ||
initAuthority: null, | ||
}).sendAndConfirm(umi); | ||
|
||
t.assert(await hasCollectAmount(umi, asset.publicKey), 'Collect amount not found') | ||
t.assert( | ||
await hasCollectAmount(umi, asset.publicKey), | ||
'Collect amount not found' | ||
); | ||
}); | ||
|
||
test('it can add remove asset plugin with collect amount', async (t) => { | ||
// Given a Umi instance and a new signer. | ||
const umi = await createUmi(); | ||
const asset = await createAsset(umi, { | ||
plugins: [{ plugin: plugin('Freeze', [{ frozen: true }]), authority: null }] | ||
}) | ||
plugins: [ | ||
{ plugin: plugin('Freeze', [{ frozen: true }]), authority: null }, | ||
], | ||
}); | ||
|
||
t.assert(await hasCollectAmount(umi, asset.publicKey), 'Collect amount not found') | ||
t.assert( | ||
await hasCollectAmount(umi, asset.publicKey), | ||
'Collect amount not found' | ||
); | ||
|
||
await removePlugin(umi, { | ||
asset: asset.publicKey, | ||
pluginType: PluginType.Freeze, | ||
}).sendAndConfirm(umi); | ||
t.assert(await hasCollectAmount(umi, asset.publicKey), 'Collect amount not found') | ||
}); | ||
t.assert( | ||
await hasCollectAmount(umi, asset.publicKey), | ||
'Collect amount not found' | ||
); | ||
}); |
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
Oops, something went wrong.