diff --git a/clients/js/src/hooked/fetchAssetWithPlugins.ts b/clients/js/src/hooked/fetchAssetWithPlugins.ts index f62ca00b..77b84e80 100644 --- a/clients/js/src/hooked/fetchAssetWithPlugins.ts +++ b/clients/js/src/hooked/fetchAssetWithPlugins.ts @@ -1,40 +1,70 @@ -import { Context, Pda, PublicKey, RpcGetAccountOptions, assertAccountExists, publicKey as toPublicKey } from "@metaplex-foundation/umi"; -import { Asset, Authority, Plugin, PluginHeader, PluginRegistry, deserializeAsset, getAssetAccountDataSerializer, getPluginHeaderAccountDataSerializer, getPluginRegistryAccountDataSerializer, getPluginSerializer } from "../generated"; +import { + Context, + Pda, + PublicKey, + RpcGetAccountOptions, + assertAccountExists, + publicKey as toPublicKey, +} from '@metaplex-foundation/umi'; +import { + Asset, + Authority, + Plugin, + PluginHeader, + PluginRegistry, + deserializeAsset, + getAssetAccountDataSerializer, + getPluginHeaderAccountDataSerializer, + getPluginRegistryAccountDataSerializer, + getPluginSerializer, +} from '../generated'; -export type PluginWithAuthorities = { plugin: Plugin, authorities: Authority[] }; +export type PluginWithAuthorities = { + plugin: Plugin; + authorities: Authority[]; +}; export type PluginList = { - pluginHeader: Omit, - plugins: PluginWithAuthorities[], - pluginRegistry: Omit, + pluginHeader: Omit; + plugins: PluginWithAuthorities[]; + pluginRegistry: Omit; }; export type AssetWithPlugins = Asset & PluginList; export async function fetchAssetWithPlugins( - context: Pick, - publicKey: PublicKey | Pda, - options?: RpcGetAccountOptions + context: Pick, + publicKey: PublicKey | Pda, + options?: RpcGetAccountOptions ): Promise { - const maybeAccount = await context.rpc.getAccount( - toPublicKey(publicKey, false), - options - ); - assertAccountExists(maybeAccount, 'Asset'); - const asset = deserializeAsset(maybeAccount); - const assetData = getAssetAccountDataSerializer().serialize(asset); - const pluginHeader = getPluginHeaderAccountDataSerializer().deserialize(maybeAccount.data, assetData.length)[0]; - const pluginRegistry = getPluginRegistryAccountDataSerializer().deserialize(maybeAccount.data, Number(pluginHeader.pluginRegistryOffset))[0]; - const plugins = pluginRegistry.registry.map((record) => ({ - plugin: getPluginSerializer().deserialize(maybeAccount.data, Number(record.data.offset))[0], - authorities: record.data.authorities, - })); + const maybeAccount = await context.rpc.getAccount( + toPublicKey(publicKey, false), + options + ); + assertAccountExists(maybeAccount, 'Asset'); + const asset = deserializeAsset(maybeAccount); + const assetData = getAssetAccountDataSerializer().serialize(asset); + const pluginHeader = getPluginHeaderAccountDataSerializer().deserialize( + maybeAccount.data, + assetData.length + )[0]; + const pluginRegistry = getPluginRegistryAccountDataSerializer().deserialize( + maybeAccount.data, + Number(pluginHeader.pluginRegistryOffset) + )[0]; + const plugins = pluginRegistry.registry.map((record) => ({ + plugin: getPluginSerializer().deserialize( + maybeAccount.data, + Number(record.data.offset) + )[0], + authorities: record.data.authorities, + })); - const assetWithPlugins: AssetWithPlugins = { - pluginHeader, - plugins, - pluginRegistry, - ...asset - }; + const assetWithPlugins: AssetWithPlugins = { + pluginHeader, + plugins, + pluginRegistry, + ...asset, + }; - return assetWithPlugins; -} \ No newline at end of file + return assetWithPlugins; +} diff --git a/clients/js/src/hooked/index.ts b/clients/js/src/hooked/index.ts index 406ca66e..9ef22b6a 100644 --- a/clients/js/src/hooked/index.ts +++ b/clients/js/src/hooked/index.ts @@ -1 +1 @@ -export * from './fetchAssetWithPlugins'; \ No newline at end of file +export * from './fetchAssetWithPlugins'; diff --git a/clients/js/test/_setup.ts b/clients/js/test/_setup.ts index b4a8a069..65b959c7 100644 --- a/clients/js/test/_setup.ts +++ b/clients/js/test/_setup.ts @@ -2,5 +2,4 @@ import { createUmi as basecreateUmi } from '@metaplex-foundation/umi-bundle-tests'; import { mplAsset } from '../src'; -export const createUmi = async () => - (await basecreateUmi()).use(mplAsset()); +export const createUmi = async () => (await basecreateUmi()).use(mplAsset()); diff --git a/clients/js/test/addAuthority.test.ts b/clients/js/test/addAuthority.test.ts index 83db1c12..637d5374 100644 --- a/clients/js/test/addAuthority.test.ts +++ b/clients/js/test/addAuthority.test.ts @@ -1,7 +1,17 @@ import { generateSigner } from '@metaplex-foundation/umi'; import test from 'ava'; // import { base58 } from '@metaplex-foundation/umi/serializers'; -import { Asset, AssetWithPlugins, DataState, PluginType, addAuthority, addPlugin, create, fetchAsset, fetchAssetWithPlugins } from '../src'; +import { + Asset, + AssetWithPlugins, + DataState, + PluginType, + addAuthority, + addPlugin, + create, + fetchAsset, + fetchAssetWithPlugins, +} from '../src'; import { createUmi } from './_setup'; test('it can add an authority to a plugin', async (t) => { @@ -34,17 +44,19 @@ test('it can add an authority to a plugin', async (t) => { plugin: { __kind: 'Freeze', fields: [{ frozen: false }], - } - }).append( - addAuthority(umi, { - assetAddress: assetAddress.publicKey, - pluginType: PluginType.Freeze, - newAuthority: { - __kind: 'Pubkey', - address: delegateAddress.publicKey, - } - }) - ).sendAndConfirm(umi); + }, + }) + .append( + addAuthority(umi, { + assetAddress: assetAddress.publicKey, + pluginType: PluginType.Freeze, + newAuthority: { + __kind: 'Pubkey', + address: delegateAddress.publicKey, + }, + }) + ) + .sendAndConfirm(umi); const asset1 = await fetchAssetWithPlugins(umi, assetAddress.publicKey); // console.log(JSON.stringify(asset1, (_, v) => typeof v === 'bigint' ? v.toString() : v, 2)); @@ -60,26 +72,30 @@ test('it can add an authority to a plugin', async (t) => { }, pluginRegistry: { key: 4, - registry: [{ - pluginType: 2, - data: { - offset: BigInt(117), - authorities: [ - { __kind: "Owner" }, - { __kind: "Pubkey", address: delegateAddress.publicKey } - ] - } - }], - }, - plugins: [{ - authorities: [ - { __kind: "Owner" }, - { __kind: "Pubkey", address: delegateAddress.publicKey } + registry: [ + { + pluginType: 2, + data: { + offset: BigInt(117), + authorities: [ + { __kind: 'Owner' }, + { __kind: 'Pubkey', address: delegateAddress.publicKey }, + ], + }, + }, ], - plugin: { - __kind: 'Freeze', - fields: [{ frozen: false }], + }, + plugins: [ + { + authorities: [ + { __kind: 'Owner' }, + { __kind: 'Pubkey', address: delegateAddress.publicKey }, + ], + plugin: { + __kind: 'Freeze', + fields: [{ frozen: false }], + }, }, - }], + ], }); }); diff --git a/clients/js/test/addPlugin.test.ts b/clients/js/test/addPlugin.test.ts index c748474b..837fc958 100644 --- a/clients/js/test/addPlugin.test.ts +++ b/clients/js/test/addPlugin.test.ts @@ -1,7 +1,15 @@ import { generateSigner } from '@metaplex-foundation/umi'; import test from 'ava'; // import { base58 } from '@metaplex-foundation/umi/serializers'; -import { Asset, AssetWithPlugins, DataState, addPlugin, create, fetchAsset, fetchAssetWithPlugins } from '../src'; +import { + Asset, + AssetWithPlugins, + DataState, + addPlugin, + create, + fetchAsset, + fetchAssetWithPlugins, +} from '../src'; import { createUmi } from './_setup'; test('it can add a plugin to an asset', async (t) => { @@ -33,7 +41,7 @@ test('it can add a plugin to an asset', async (t) => { plugin: { __kind: 'Freeze', fields: [{ frozen: false }], - } + }, }).sendAndConfirm(umi); const asset1 = await fetchAssetWithPlugins(umi, assetAddress.publicKey); @@ -50,20 +58,24 @@ test('it can add a plugin to an asset', async (t) => { }, pluginRegistry: { key: 4, - registry: [{ - pluginType: 2, - data: { - offset: BigInt(117), - authorities: [{ __kind: "Owner" }] - } - }], + registry: [ + { + pluginType: 2, + data: { + offset: BigInt(117), + authorities: [{ __kind: 'Owner' }], + }, + }, + ], }, - plugins: [{ - authorities: [{ __kind: "Owner" }], - plugin: { - __kind: 'Freeze', - fields: [{ frozen: false }], + plugins: [ + { + authorities: [{ __kind: 'Owner' }], + plugin: { + __kind: 'Freeze', + fields: [{ frozen: false }], + }, }, - }], + ], }); }); diff --git a/clients/js/test/burn.test.ts b/clients/js/test/burn.test.ts index 34348f63..e2cedb6e 100644 --- a/clients/js/test/burn.test.ts +++ b/clients/js/test/burn.test.ts @@ -1,4 +1,8 @@ -import { assertAccountExists, generateSigner, sol} from '@metaplex-foundation/umi'; +import { + assertAccountExists, + generateSigner, + sol, +} from '@metaplex-foundation/umi'; import test from 'ava'; // import { base58 } from '@metaplex-foundation/umi/serializers'; import { Asset, DataState, create, fetchAsset, burn, Key } from '../src'; @@ -30,7 +34,7 @@ test('it can burn an asset as the owner', async (t) => { await burn(umi, { assetAddress: assetAddress.publicKey, - compressionProof: null + compressionProof: null, }).sendAndConfirm(umi); // And the asset address still exists but was resized to 1. @@ -73,7 +77,7 @@ test('it cannot burn an asset if not the owner', async (t) => { authority: attacker, }).sendAndConfirm(umi); - await t.throwsAsync(result, { name: 'InvalidAuthority' }) + await t.throwsAsync(result, { name: 'InvalidAuthority' }); const afterAsset = await fetchAsset(umi, assetAddress.publicKey); // console.log("Account State:", afterAsset); diff --git a/clients/js/test/create.test.ts b/clients/js/test/create.test.ts index 5e10edc2..552edce4 100644 --- a/clients/js/test/create.test.ts +++ b/clients/js/test/create.test.ts @@ -1,7 +1,14 @@ import { generateSigner, publicKey } from '@metaplex-foundation/umi'; import test from 'ava'; // import { base58 } from '@metaplex-foundation/umi/serializers'; -import { Asset, DataState, create, fetchAsset, fetchHashedAsset, getAssetAccountDataSerializer } from '../src'; +import { + Asset, + DataState, + create, + fetchAsset, + fetchHashedAsset, + getAssetAccountDataSerializer, +} from '../src'; import { createUmi } from './_setup'; test('it can create a new asset in account state', async (t) => { @@ -40,7 +47,7 @@ test('it can create a new asset in ledger state', async (t) => { assetAddress, name: 'Test Bread', uri: 'https://example.com/bread', - logWrapper: publicKey("noopb9bkMVfRPU8AsbpTUg8AQkHtKwMYZiFUjNRtMmV") + logWrapper: publicKey('noopb9bkMVfRPU8AsbpTUg8AQkHtKwMYZiFUjNRtMmV'), }).sendAndConfirm(umi); // Then an account was created with the correct data. @@ -64,5 +71,4 @@ test('it can create a new asset in ledger state', async (t) => { uri: 'https://example.com/bread', }); } - }); diff --git a/clients/js/test/delegate.test.ts b/clients/js/test/delegate.test.ts index 9ae02d49..944f78de 100644 --- a/clients/js/test/delegate.test.ts +++ b/clients/js/test/delegate.test.ts @@ -32,7 +32,7 @@ test('it can delegate a new authority', async (t) => { plugin: { __kind: 'Freeze', fields: [{ frozen: false }], - } + }, }).sendAndConfirm(umi); await addAuthority(umi, { @@ -41,7 +41,7 @@ test('it can delegate a new authority', async (t) => { newAuthority: { __kind: 'Pubkey', address: delegateAddress.publicKey, - } + }, }).sendAndConfirm(umi); const asset = await fetchAssetWithPlugins(umi, assetAddress.publicKey); @@ -58,31 +58,34 @@ test('it can delegate a new authority', async (t) => { }, pluginRegistry: { key: 4, - registry: [{ - pluginType: 2, - data: { - offset: BigInt(117), - authorities: [ - { __kind: "Owner" }, - { __kind: "Pubkey", address: delegateAddress.publicKey } - ] - } - }], - }, - plugins: [{ - authorities: [ - { __kind: "Owner" }, - { __kind: "Pubkey", address: delegateAddress.publicKey } + registry: [ + { + pluginType: 2, + data: { + offset: BigInt(117), + authorities: [ + { __kind: 'Owner' }, + { __kind: 'Pubkey', address: delegateAddress.publicKey }, + ], + }, + }, ], - plugin: { - __kind: 'Freeze', - fields: [{ frozen: false }], + }, + plugins: [ + { + authorities: [ + { __kind: 'Owner' }, + { __kind: 'Pubkey', address: delegateAddress.publicKey }, + ], + plugin: { + __kind: 'Freeze', + fields: [{ frozen: false }], + }, }, - }], + ], }); }); - test('a delegate can freeze the token', async (t) => { // Given a Umi instance and a new signer. const umi = await createUmi(); @@ -102,7 +105,7 @@ test('a delegate can freeze the token', async (t) => { plugin: { __kind: 'Freeze', fields: [{ frozen: false }], - } + }, }).sendAndConfirm(umi); await addAuthority(umi, { @@ -111,7 +114,7 @@ test('a delegate can freeze the token', async (t) => { newAuthority: { __kind: 'Pubkey', address: delegateAddress.publicKey, - } + }, }).sendAndConfirm(umi); await updatePlugin(umi, { @@ -119,7 +122,7 @@ test('a delegate can freeze the token', async (t) => { plugin: { __kind: 'Freeze', fields: [{ frozen: true }], - } + }, }).sendAndConfirm(umi); const asset = await fetchAssetWithPlugins(umi, assetAddress.publicKey); @@ -136,26 +139,30 @@ test('a delegate can freeze the token', async (t) => { }, pluginRegistry: { key: 4, - registry: [{ - pluginType: 2, - data: { - offset: BigInt(117), - authorities: [ - { __kind: "Owner" }, - { __kind: "Pubkey", address: delegateAddress.publicKey } - ] - } - }], - }, - plugins: [{ - authorities: [ - { __kind: "Owner" }, - { __kind: "Pubkey", address: delegateAddress.publicKey } + registry: [ + { + pluginType: 2, + data: { + offset: BigInt(117), + authorities: [ + { __kind: 'Owner' }, + { __kind: 'Pubkey', address: delegateAddress.publicKey }, + ], + }, + }, ], - plugin: { - __kind: 'Freeze', - fields: [{ frozen: true }], + }, + plugins: [ + { + authorities: [ + { __kind: 'Owner' }, + { __kind: 'Pubkey', address: delegateAddress.publicKey }, + ], + plugin: { + __kind: 'Freeze', + fields: [{ frozen: true }], + }, }, - }], + ], }); -}); \ No newline at end of file +}); diff --git a/clients/js/test/delegateTransfer.test.ts b/clients/js/test/delegateTransfer.test.ts index 40855456..f4a1615f 100644 --- a/clients/js/test/delegateTransfer.test.ts +++ b/clients/js/test/delegateTransfer.test.ts @@ -1,6 +1,15 @@ import { generateSigner } from '@metaplex-foundation/umi'; import test from 'ava'; -import { AssetWithPlugins, DataState, PluginType, addAuthority, addPlugin, create, fetchAssetWithPlugins, transfer } from '../src'; +import { + AssetWithPlugins, + DataState, + PluginType, + addAuthority, + addPlugin, + create, + fetchAssetWithPlugins, + transfer, +} from '../src'; import { createUmi } from './_setup'; test('a delegate can transfer the asset', async (t) => { @@ -23,7 +32,7 @@ test('a delegate can transfer the asset', async (t) => { plugin: { __kind: 'Transfer', fields: [{}], - } + }, }).sendAndConfirm(umi); await addAuthority(umi, { @@ -32,14 +41,14 @@ test('a delegate can transfer the asset', async (t) => { newAuthority: { __kind: 'Pubkey', address: delegateAddress.publicKey, - } + }, }).sendAndConfirm(umi); await transfer(umi, { assetAddress: assetAddress.publicKey, newOwner: newOwnerAddress.publicKey, authority: delegateAddress, - compressionProof: null + compressionProof: null, }).sendAndConfirm(umi); const asset = await fetchAssetWithPlugins(umi, assetAddress.publicKey); @@ -56,26 +65,30 @@ test('a delegate can transfer the asset', async (t) => { }, pluginRegistry: { key: 4, - registry: [{ - pluginType: PluginType.Transfer, - data: { - offset: BigInt(117), - authorities: [ - { __kind: "Owner" }, - { __kind: "Pubkey", address: delegateAddress.publicKey } - ] - } - }], - }, - plugins: [{ - authorities: [ - { __kind: "Owner" }, - { __kind: "Pubkey", address: delegateAddress.publicKey } + registry: [ + { + pluginType: PluginType.Transfer, + data: { + offset: BigInt(117), + authorities: [ + { __kind: 'Owner' }, + { __kind: 'Pubkey', address: delegateAddress.publicKey }, + ], + }, + }, ], - plugin: { - __kind: 'Transfer', - fields: [{}], + }, + plugins: [ + { + authorities: [ + { __kind: 'Owner' }, + { __kind: 'Pubkey', address: delegateAddress.publicKey }, + ], + plugin: { + __kind: 'Transfer', + fields: [{}], + }, }, - }], + ], }); -}); \ No newline at end of file +}); diff --git a/clients/js/test/info.test.ts b/clients/js/test/info.test.ts index d27c9991..a1a222c5 100644 --- a/clients/js/test/info.test.ts +++ b/clients/js/test/info.test.ts @@ -1,6 +1,6 @@ import { generateSigner, publicKey } from '@metaplex-foundation/umi'; import test from 'ava'; -import { DataState, create, /* fetchAsset, fetchHashedAsset */ } from '../src'; +import { DataState, create /* fetchAsset, fetchHashedAsset */ } from '../src'; import { createUmi } from './_setup'; test('fetch account info for account state', async (t) => { @@ -40,7 +40,7 @@ test('fetch account info for ledger state', async (t) => { assetAddress, name: 'Test Bread', uri: 'https://example.com/bread', - logWrapper: publicKey("noopb9bkMVfRPU8AsbpTUg8AQkHtKwMYZiFUjNRtMmV"), + logWrapper: publicKey('noopb9bkMVfRPU8AsbpTUg8AQkHtKwMYZiFUjNRtMmV'), }).sendAndConfirm(umi); // Print the size of the account. diff --git a/clients/js/test/removeAuthority.test.ts b/clients/js/test/removeAuthority.test.ts index ca1666e9..d7092f82 100644 --- a/clients/js/test/removeAuthority.test.ts +++ b/clients/js/test/removeAuthority.test.ts @@ -1,7 +1,18 @@ import { generateSigner } from '@metaplex-foundation/umi'; import test from 'ava'; // import { base58 } from '@metaplex-foundation/umi/serializers'; -import { Asset, AssetWithPlugins, DataState, PluginType, addAuthority, addPlugin, create, fetchAsset, fetchAssetWithPlugins, removeAuthority } from '../src'; +import { + Asset, + AssetWithPlugins, + DataState, + PluginType, + addAuthority, + addPlugin, + create, + fetchAsset, + fetchAssetWithPlugins, + removeAuthority, +} from '../src'; import { createUmi } from './_setup'; test('it can remove an authority from a plugin', async (t) => { @@ -34,17 +45,19 @@ test('it can remove an authority from a plugin', async (t) => { plugin: { __kind: 'Freeze', fields: [{ frozen: false }], - } - }).append( - addAuthority(umi, { - assetAddress: assetAddress.publicKey, - pluginType: PluginType.Freeze, - newAuthority: { - __kind: 'Pubkey', - address: delegateAddress.publicKey, - } - }) - ).sendAndConfirm(umi); + }, + }) + .append( + addAuthority(umi, { + assetAddress: assetAddress.publicKey, + pluginType: PluginType.Freeze, + newAuthority: { + __kind: 'Pubkey', + address: delegateAddress.publicKey, + }, + }) + ) + .sendAndConfirm(umi); const asset1 = await fetchAssetWithPlugins(umi, assetAddress.publicKey); // console.log(JSON.stringify(asset1, (_, v) => typeof v === 'bigint' ? v.toString() : v, 2)); @@ -60,27 +73,31 @@ test('it can remove an authority from a plugin', async (t) => { }, pluginRegistry: { key: 4, - registry: [{ - pluginType: 2, - data: { - offset: BigInt(117), - authorities: [ - { __kind: "Owner" }, - { __kind: "Pubkey", address: delegateAddress.publicKey } - ] - } - }], - }, - plugins: [{ - authorities: [ - { __kind: "Owner" }, - { __kind: "Pubkey", address: delegateAddress.publicKey } + registry: [ + { + pluginType: 2, + data: { + offset: BigInt(117), + authorities: [ + { __kind: 'Owner' }, + { __kind: 'Pubkey', address: delegateAddress.publicKey }, + ], + }, + }, ], - plugin: { - __kind: 'Freeze', - fields: [{ frozen: false }], + }, + plugins: [ + { + authorities: [ + { __kind: 'Owner' }, + { __kind: 'Pubkey', address: delegateAddress.publicKey }, + ], + plugin: { + __kind: 'Freeze', + fields: [{ frozen: false }], + }, }, - }], + ], }); await removeAuthority(umi, { @@ -89,7 +106,7 @@ test('it can remove an authority from a plugin', async (t) => { authorityToRemove: { __kind: 'Pubkey', address: delegateAddress.publicKey, - } + }, }).sendAndConfirm(umi); const asset2 = await fetchAssetWithPlugins(umi, assetAddress.publicKey); @@ -106,25 +123,25 @@ test('it can remove an authority from a plugin', async (t) => { }, pluginRegistry: { key: 4, - registry: [{ - pluginType: 2, - data: { - offset: BigInt(117), - authorities: [ - { __kind: "Owner" }, - ] - } - }], - }, - plugins: [{ - authorities: [ - { __kind: "Owner" }, + registry: [ + { + pluginType: 2, + data: { + offset: BigInt(117), + authorities: [{ __kind: 'Owner' }], + }, + }, ], - plugin: { - __kind: 'Freeze', - fields: [{ frozen: false }], + }, + plugins: [ + { + authorities: [{ __kind: 'Owner' }], + plugin: { + __kind: 'Freeze', + fields: [{ frozen: false }], + }, }, - }], + ], }); }); @@ -157,7 +174,7 @@ test('it can remove the default authority from a plugin to make it immutable', a plugin: { __kind: 'Freeze', fields: [{ frozen: false }], - } + }, }).sendAndConfirm(umi); await removeAuthority(umi, { @@ -165,7 +182,7 @@ test('it can remove the default authority from a plugin to make it immutable', a pluginType: PluginType.Freeze, authorityToRemove: { __kind: 'Owner', - } + }, }).sendAndConfirm(umi); const asset1 = await fetchAssetWithPlugins(umi, assetAddress.publicKey); @@ -182,24 +199,24 @@ test('it can remove the default authority from a plugin to make it immutable', a }, pluginRegistry: { key: 4, - registry: [{ - pluginType: 2, - data: { - offset: BigInt(117), - authorities: [ - { __kind: "None" }, - ] - } - }], - }, - plugins: [{ - authorities: [ - { __kind: "None" }, + registry: [ + { + pluginType: 2, + data: { + offset: BigInt(117), + authorities: [{ __kind: 'None' }], + }, + }, ], - plugin: { - __kind: 'Freeze', - fields: [{ frozen: false }], + }, + plugins: [ + { + authorities: [{ __kind: 'None' }], + plugin: { + __kind: 'Freeze', + fields: [{ frozen: false }], + }, }, - }], + ], }); }); diff --git a/clients/js/test/removePlugin.test.ts b/clients/js/test/removePlugin.test.ts index 5f2a9792..c707ee5e 100644 --- a/clients/js/test/removePlugin.test.ts +++ b/clients/js/test/removePlugin.test.ts @@ -1,7 +1,17 @@ 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 } from '../src'; +import { + Asset, + AssetWithPlugins, + DataState, + PluginType, + addPlugin, + create, + fetchAsset, + fetchAssetWithPlugins, + removePlugin, +} from '../src'; import { createUmi } from './_setup'; test('it can remove a plugin from an asset', async (t) => { @@ -33,7 +43,7 @@ test('it can remove a plugin from an asset', async (t) => { plugin: { __kind: 'Freeze', fields: [{ frozen: false }], - } + }, }).sendAndConfirm(umi); const asset1 = await fetchAssetWithPlugins(umi, assetAddress.publicKey); @@ -50,21 +60,25 @@ test('it can remove a plugin from an asset', async (t) => { }, pluginRegistry: { key: 4, - registry: [{ - pluginType: 2, - data: { - offset: BigInt(117), - authorities: [{ __kind: "Owner" }] - } - }], + registry: [ + { + pluginType: 2, + data: { + offset: BigInt(117), + authorities: [{ __kind: 'Owner' }], + }, + }, + ], }, - plugins: [{ - authorities: [{ __kind: "Owner" }], - plugin: { - __kind: 'Freeze', - fields: [{ frozen: false }], + plugins: [ + { + authorities: [{ __kind: 'Owner' }], + plugin: { + __kind: 'Freeze', + fields: [{ frozen: false }], + }, }, - }], + ], }); await removePlugin(umi, { @@ -74,7 +88,7 @@ test('it can remove a plugin from an asset', async (t) => { const asset2 = await fetchAssetWithPlugins(umi, assetAddress.publicKey); // console.log(JSON.stringify(asset2, (_, v) => typeof v === 'bigint' ? v.toString() : v, 2)); - t.like(asset2, { + t.like(asset2, ({ publicKey: assetAddress.publicKey, updateAuthority: umi.identity.publicKey, owner: umi.identity.publicKey, @@ -89,5 +103,5 @@ test('it can remove a plugin from an asset', async (t) => { registry: [], }, plugins: [], - }); + })); }); diff --git a/clients/js/test/transfer.test.ts b/clients/js/test/transfer.test.ts index 40802ca3..6d7ed984 100644 --- a/clients/js/test/transfer.test.ts +++ b/clients/js/test/transfer.test.ts @@ -32,7 +32,7 @@ test('it can transfer an asset as the owner', async (t) => { await transfer(umi, { assetAddress: assetAddress.publicKey, newOwner: newOwner.publicKey, - compressionProof: null + compressionProof: null, }).sendAndConfirm(umi); const afterAsset = await fetchAsset(umi, assetAddress.publicKey); @@ -79,7 +79,7 @@ test('it cannot transfer an asset if not the owner', async (t) => { authority: attacker, }).sendAndConfirm(umi); - await t.throwsAsync(result, { name: 'InvalidAuthority' }) + await t.throwsAsync(result, { name: 'InvalidAuthority' }); const afterAsset = await fetchAsset(umi, assetAddress.publicKey); // console.log("Account State:", afterAsset);