diff --git a/Cargo.lock b/Cargo.lock index e0de8c48..1bc825c4 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2080,7 +2080,7 @@ dependencies = [ [[package]] name = "mpl-core" -version = "0.4.4" +version = "0.5.0" dependencies = [ "assert_matches", "base64 0.22.0", diff --git a/clients/js/package.json b/clients/js/package.json index d44fe580..4764839d 100644 --- a/clients/js/package.json +++ b/clients/js/package.json @@ -33,8 +33,8 @@ "devDependencies": { "@metaplex-foundation/mpl-toolbox": "^0.8.0", "@ava/typescript": "^3.0.1", - "@metaplex-foundation/umi": "^0.8.2", - "@metaplex-foundation/umi-bundle-tests": "^0.8.2", + "@metaplex-foundation/umi": "^0.8.10", + "@metaplex-foundation/umi-bundle-tests": "^0.8.10", "@solana/web3.js": "^1.73.0", "@typescript-eslint/eslint-plugin": "^5.0.0", "@typescript-eslint/parser": "^5.46.1", diff --git a/clients/js/pnpm-lock.yaml b/clients/js/pnpm-lock.yaml index 46938c41..211d6cd7 100644 --- a/clients/js/pnpm-lock.yaml +++ b/clients/js/pnpm-lock.yaml @@ -11,13 +11,13 @@ devDependencies: version: 3.0.1 '@metaplex-foundation/mpl-toolbox': specifier: ^0.8.0 - version: 0.8.0(@metaplex-foundation/umi@0.8.2) + version: 0.8.0(@metaplex-foundation/umi@0.8.10) '@metaplex-foundation/umi': - specifier: ^0.8.2 - version: 0.8.2 + specifier: ^0.8.10 + version: 0.8.10 '@metaplex-foundation/umi-bundle-tests': - specifier: ^0.8.2 - version: 0.8.2(@metaplex-foundation/umi@0.8.2)(@solana/web3.js@1.73.0) + specifier: ^0.8.10 + version: 0.8.10(@metaplex-foundation/umi@0.8.10)(@solana/web3.js@1.73.0) '@solana/web3.js': specifier: ^1.73.0 version: 1.73.0 @@ -1857,51 +1857,51 @@ packages: - supports-color dev: true - /@metaplex-foundation/mpl-toolbox@0.8.0(@metaplex-foundation/umi@0.8.2): + /@metaplex-foundation/mpl-toolbox@0.8.0(@metaplex-foundation/umi@0.8.10): resolution: {integrity: sha512-SK1VUPU4hCaL3sozgtoVjjbZxqx2gWiRt0YTFbwEt5LAHWOlCb7J7rcrrA5XwymX4iV2bIWygYs0yz7hYyx2rg==} peerDependencies: '@metaplex-foundation/umi': ^0.8.2 dependencies: - '@metaplex-foundation/umi': 0.8.2 + '@metaplex-foundation/umi': 0.8.10 dev: true - /@metaplex-foundation/umi-bundle-tests@0.8.2(@metaplex-foundation/umi@0.8.2)(@solana/web3.js@1.73.0): - resolution: {integrity: sha512-FO8rXJw3ZBKE8YHW+4zOodJmB+Lh50kCMtAA+DfZ9x6JKKMtk1kbmz2186Gclrx3/bl7Ep5FwokSAmoBiOys0A==} + /@metaplex-foundation/umi-bundle-tests@0.8.10(@metaplex-foundation/umi@0.8.10)(@solana/web3.js@1.73.0): + resolution: {integrity: sha512-12BLhBF5lXLG7K1m4J8mEArcc/l4a4iRCmZt2VKSD0tA+i+b3ou1RA+e+262nhrEZ/uhYx0ChUzrJlBk0a1aXQ==} peerDependencies: - '@metaplex-foundation/umi': ^0.8.2 + '@metaplex-foundation/umi': ^0.8.10 '@solana/web3.js': ^1.72.0 dependencies: - '@metaplex-foundation/umi': 0.8.2 - '@metaplex-foundation/umi-eddsa-web3js': 0.8.10(@metaplex-foundation/umi@0.8.2)(@solana/web3.js@1.73.0) - '@metaplex-foundation/umi-http-fetch': 0.8.10(@metaplex-foundation/umi@0.8.2) - '@metaplex-foundation/umi-program-repository': 0.8.10(@metaplex-foundation/umi@0.8.2) - '@metaplex-foundation/umi-rpc-web3js': 0.8.10(@metaplex-foundation/umi@0.8.2)(@solana/web3.js@1.73.0) - '@metaplex-foundation/umi-serializer-data-view': 0.8.10(@metaplex-foundation/umi@0.8.2) - '@metaplex-foundation/umi-storage-mock': 0.8.10(@metaplex-foundation/umi@0.8.2) - '@metaplex-foundation/umi-transaction-factory-web3js': 0.8.10(@metaplex-foundation/umi@0.8.2)(@solana/web3.js@1.73.0) + '@metaplex-foundation/umi': 0.8.10 + '@metaplex-foundation/umi-eddsa-web3js': 0.8.10(@metaplex-foundation/umi@0.8.10)(@solana/web3.js@1.73.0) + '@metaplex-foundation/umi-http-fetch': 0.8.10(@metaplex-foundation/umi@0.8.10) + '@metaplex-foundation/umi-program-repository': 0.8.10(@metaplex-foundation/umi@0.8.10) + '@metaplex-foundation/umi-rpc-web3js': 0.8.10(@metaplex-foundation/umi@0.8.10)(@solana/web3.js@1.73.0) + '@metaplex-foundation/umi-serializer-data-view': 0.8.10(@metaplex-foundation/umi@0.8.10) + '@metaplex-foundation/umi-storage-mock': 0.8.10(@metaplex-foundation/umi@0.8.10) + '@metaplex-foundation/umi-transaction-factory-web3js': 0.8.10(@metaplex-foundation/umi@0.8.10)(@solana/web3.js@1.73.0) '@solana/web3.js': 1.73.0 transitivePeerDependencies: - encoding dev: true - /@metaplex-foundation/umi-eddsa-web3js@0.8.10(@metaplex-foundation/umi@0.8.2)(@solana/web3.js@1.73.0): + /@metaplex-foundation/umi-eddsa-web3js@0.8.10(@metaplex-foundation/umi@0.8.10)(@solana/web3.js@1.73.0): resolution: {integrity: sha512-2CLsuQ67oPKczB7RuG07/Ro1rrW25vGZArren20/zBTgHubGIuFW7V8e9qZDqkHDt1nFecxrX55g0fNtQaU40g==} peerDependencies: '@metaplex-foundation/umi': ^0.8.10 '@solana/web3.js': ^1.72.0 dependencies: - '@metaplex-foundation/umi': 0.8.2 - '@metaplex-foundation/umi-web3js-adapters': 0.8.10(@metaplex-foundation/umi@0.8.2)(@solana/web3.js@1.73.0) + '@metaplex-foundation/umi': 0.8.10 + '@metaplex-foundation/umi-web3js-adapters': 0.8.10(@metaplex-foundation/umi@0.8.10)(@solana/web3.js@1.73.0) '@noble/curves': 1.4.0 '@solana/web3.js': 1.73.0 dev: true - /@metaplex-foundation/umi-http-fetch@0.8.10(@metaplex-foundation/umi@0.8.2): + /@metaplex-foundation/umi-http-fetch@0.8.10(@metaplex-foundation/umi@0.8.10): resolution: {integrity: sha512-9QkVMaM8A8JFaTSanVJT3R7IzeLn05xrK7fFnfCTASaTvk+7Dj8ZsgXQjuyCi1pXQrMN+EsREn2NE/tn48ffMQ==} peerDependencies: '@metaplex-foundation/umi': ^0.8.10 dependencies: - '@metaplex-foundation/umi': 0.8.2 + '@metaplex-foundation/umi': 0.8.10 node-fetch: 2.7.0 transitivePeerDependencies: - encoding @@ -1911,12 +1911,12 @@ packages: resolution: {integrity: sha512-jSQ61sZMPSAk/TXn8v8fPqtz3x8d0/blVZXLLbpVbo2/T5XobiI6/MfmlUosAjAUaQl6bHRF8aIIqZEFkJiy4A==} dev: true - /@metaplex-foundation/umi-program-repository@0.8.10(@metaplex-foundation/umi@0.8.2): + /@metaplex-foundation/umi-program-repository@0.8.10(@metaplex-foundation/umi@0.8.10): resolution: {integrity: sha512-zw+UMOg9z3xqqeosRfctmcnaDYkaoMMvqhu7Vpwt7K9tpVtMaMT5yei29ORvaYpiEVG5hZSbywr/vQsNY0EV9g==} peerDependencies: '@metaplex-foundation/umi': ^0.8.10 dependencies: - '@metaplex-foundation/umi': 0.8.2 + '@metaplex-foundation/umi': 0.8.10 dev: true /@metaplex-foundation/umi-public-keys@0.8.9: @@ -1925,23 +1925,23 @@ packages: '@metaplex-foundation/umi-serializers-encodings': 0.8.9 dev: true - /@metaplex-foundation/umi-rpc-web3js@0.8.10(@metaplex-foundation/umi@0.8.2)(@solana/web3.js@1.73.0): + /@metaplex-foundation/umi-rpc-web3js@0.8.10(@metaplex-foundation/umi@0.8.10)(@solana/web3.js@1.73.0): resolution: {integrity: sha512-+60uxlX1OcThL2UIW9dbcy0Ihr011ggxkQYSxc1qh4qitgD9wrZZ/v9nX4tzEN88a52UJGhH5G3SF6CNmqy4aw==} peerDependencies: '@metaplex-foundation/umi': ^0.8.10 '@solana/web3.js': ^1.72.0 dependencies: - '@metaplex-foundation/umi': 0.8.2 - '@metaplex-foundation/umi-web3js-adapters': 0.8.10(@metaplex-foundation/umi@0.8.2)(@solana/web3.js@1.73.0) + '@metaplex-foundation/umi': 0.8.10 + '@metaplex-foundation/umi-web3js-adapters': 0.8.10(@metaplex-foundation/umi@0.8.10)(@solana/web3.js@1.73.0) '@solana/web3.js': 1.73.0 dev: true - /@metaplex-foundation/umi-serializer-data-view@0.8.10(@metaplex-foundation/umi@0.8.2): + /@metaplex-foundation/umi-serializer-data-view@0.8.10(@metaplex-foundation/umi@0.8.10): resolution: {integrity: sha512-DVKUQw7FEfpRIE9RF4YU73Mwlaf42RAWDgcycNiYFWpj/FLRebNr+2NT3ALYlOqXsAchnCAYjlQVxCB0Sopn9Q==} peerDependencies: '@metaplex-foundation/umi': ^0.8.10 dependencies: - '@metaplex-foundation/umi': 0.8.2 + '@metaplex-foundation/umi': 0.8.10 dev: true /@metaplex-foundation/umi-serializers-core@0.8.9: @@ -1970,38 +1970,38 @@ packages: '@metaplex-foundation/umi-serializers-numbers': 0.8.9 dev: true - /@metaplex-foundation/umi-storage-mock@0.8.10(@metaplex-foundation/umi@0.8.2): + /@metaplex-foundation/umi-storage-mock@0.8.10(@metaplex-foundation/umi@0.8.10): resolution: {integrity: sha512-YOg/ZeeyZoD9vywumL8rpQmgcm4PcWAy1QpEx6Q7ocVqMBlbD08Hrn9/F0cjvjUHhy8NYG7QrbNXdGnklavtuw==} peerDependencies: '@metaplex-foundation/umi': ^0.8.10 dependencies: - '@metaplex-foundation/umi': 0.8.2 + '@metaplex-foundation/umi': 0.8.10 dev: true - /@metaplex-foundation/umi-transaction-factory-web3js@0.8.10(@metaplex-foundation/umi@0.8.2)(@solana/web3.js@1.73.0): + /@metaplex-foundation/umi-transaction-factory-web3js@0.8.10(@metaplex-foundation/umi@0.8.10)(@solana/web3.js@1.73.0): resolution: {integrity: sha512-hnkDKdtuZgY6DKH6aSEd6UrZGi5/WvfYqJUWeM8SVl1/8GhNypNKWvuppvFHpU9X2tLXuF4JSG4TVxAuIs9LBQ==} peerDependencies: '@metaplex-foundation/umi': ^0.8.10 '@solana/web3.js': ^1.72.0 dependencies: - '@metaplex-foundation/umi': 0.8.2 - '@metaplex-foundation/umi-web3js-adapters': 0.8.10(@metaplex-foundation/umi@0.8.2)(@solana/web3.js@1.73.0) + '@metaplex-foundation/umi': 0.8.10 + '@metaplex-foundation/umi-web3js-adapters': 0.8.10(@metaplex-foundation/umi@0.8.10)(@solana/web3.js@1.73.0) '@solana/web3.js': 1.73.0 dev: true - /@metaplex-foundation/umi-web3js-adapters@0.8.10(@metaplex-foundation/umi@0.8.2)(@solana/web3.js@1.73.0): + /@metaplex-foundation/umi-web3js-adapters@0.8.10(@metaplex-foundation/umi@0.8.10)(@solana/web3.js@1.73.0): resolution: {integrity: sha512-TGF+vzO/v0HMRM8sz1M1yh+wfZ5l4RCFm1Kkcy5MC9FrNDookPP6y9aYZ3R0QkEVVV3u+8QLptrTUrxr3EGmyQ==} peerDependencies: '@metaplex-foundation/umi': ^0.8.10 '@solana/web3.js': ^1.72.0 dependencies: - '@metaplex-foundation/umi': 0.8.2 + '@metaplex-foundation/umi': 0.8.10 '@solana/web3.js': 1.73.0 buffer: 6.0.3 dev: true - /@metaplex-foundation/umi@0.8.2: - resolution: {integrity: sha512-HfMcV9nILwavrS+Rv7FO5k7eRp4NMDxKAcx3ebeRF4fOvZ1rx5B/IthpN1G1frWkdqOOke1uWH112imEJHpqmQ==} + /@metaplex-foundation/umi@0.8.10: + resolution: {integrity: sha512-iGuGIfJh2+YFvUIkZ0nB/69EsQcaoq89DDPRPYvPBtOunfv8TH8SNrwcsXHlp9aBtn5FGKCPx3V3X/eurB32Fg==} dependencies: '@metaplex-foundation/umi-options': 0.8.9 '@metaplex-foundation/umi-public-keys': 0.8.9 diff --git a/clients/js/src/authority.ts b/clients/js/src/authority.ts index d38401d9..720c6762 100644 --- a/clients/js/src/authority.ts +++ b/clients/js/src/authority.ts @@ -1,9 +1,5 @@ import { PublicKey } from '@metaplex-foundation/umi'; -import { - PluginAuthority, - pluginAuthority, -} from './generated/types/pluginAuthority'; -import { BasePluginAuthority } from './types'; +import { pluginAuthority } from './plugins'; // Authorities data helpers export function nonePluginAuthority() { @@ -21,12 +17,3 @@ export function updatePluginAuthority() { export function addressPluginAuthority(address: PublicKey) { return pluginAuthority('Address', { address }); } - -export function mapPluginAuthority( - authority: PluginAuthority -): BasePluginAuthority { - return { - type: authority.__kind, - address: (authority as any).address, - }; -} diff --git a/clients/js/src/generated/accounts/assetV1.ts b/clients/js/src/generated/accounts/assetV1.ts index 3a1fc03a..67824c79 100644 --- a/clients/js/src/generated/accounts/assetV1.ts +++ b/clients/js/src/generated/accounts/assetV1.ts @@ -31,10 +31,10 @@ import { getAssetV1AccountDataSerializer, } from '../../hooked'; import { + BaseUpdateAuthorityArgs, KeyArgs, - UpdateAuthorityArgs, + getBaseUpdateAuthoritySerializer, getKeySerializer, - getUpdateAuthoritySerializer, } from '../types'; export type AssetV1 = Account; @@ -108,14 +108,14 @@ export function getAssetV1GpaBuilder( .registerFields<{ key: KeyArgs; owner: PublicKey; - updateAuthority: UpdateAuthorityArgs; + updateAuthority: BaseUpdateAuthorityArgs; name: string; uri: string; seq: OptionOrNullable; }>({ key: [0, getKeySerializer()], owner: [1, publicKeySerializer()], - updateAuthority: [33, getUpdateAuthoritySerializer()], + updateAuthority: [33, getBaseUpdateAuthoritySerializer()], name: [null, string()], uri: [null, string()], seq: [null, option(u64())], diff --git a/clients/js/src/generated/instructions/addCollectionExternalPluginV1.ts b/clients/js/src/generated/instructions/addCollectionExternalPluginV1.ts index 86b9dfe9..b81511a1 100644 --- a/clients/js/src/generated/instructions/addCollectionExternalPluginV1.ts +++ b/clients/js/src/generated/instructions/addCollectionExternalPluginV1.ts @@ -26,9 +26,9 @@ import { getAccountMetasAndSigners, } from '../shared'; import { - ExternalPluginInitInfo, - ExternalPluginInitInfoArgs, - getExternalPluginInitInfoSerializer, + BaseExternalPluginInitInfo, + BaseExternalPluginInitInfoArgs, + getBaseExternalPluginInitInfoSerializer, } from '../types'; // Accounts. @@ -48,11 +48,11 @@ export type AddCollectionExternalPluginV1InstructionAccounts = { // Data. export type AddCollectionExternalPluginV1InstructionData = { discriminator: number; - initInfo: ExternalPluginInitInfo; + initInfo: BaseExternalPluginInitInfo; }; export type AddCollectionExternalPluginV1InstructionDataArgs = { - initInfo: ExternalPluginInitInfoArgs; + initInfo: BaseExternalPluginInitInfoArgs; }; export function getAddCollectionExternalPluginV1InstructionDataSerializer(): Serializer< @@ -67,7 +67,7 @@ export function getAddCollectionExternalPluginV1InstructionDataSerializer(): Ser struct( [ ['discriminator', u8()], - ['initInfo', getExternalPluginInitInfoSerializer()], + ['initInfo', getBaseExternalPluginInitInfoSerializer()], ], { description: 'AddCollectionExternalPluginV1InstructionData' } ), diff --git a/clients/js/src/generated/instructions/addCollectionPluginV1.ts b/clients/js/src/generated/instructions/addCollectionPluginV1.ts index 099dc677..f612b44f 100644 --- a/clients/js/src/generated/instructions/addCollectionPluginV1.ts +++ b/clients/js/src/generated/instructions/addCollectionPluginV1.ts @@ -30,11 +30,11 @@ import { getAccountMetasAndSigners, } from '../shared'; import { + BasePluginAuthority, + BasePluginAuthorityArgs, Plugin, PluginArgs, - PluginAuthority, - PluginAuthorityArgs, - getPluginAuthoritySerializer, + getBasePluginAuthoritySerializer, getPluginSerializer, } from '../types'; @@ -56,12 +56,12 @@ export type AddCollectionPluginV1InstructionAccounts = { export type AddCollectionPluginV1InstructionData = { discriminator: number; plugin: Plugin; - initAuthority: Option; + initAuthority: Option; }; export type AddCollectionPluginV1InstructionDataArgs = { plugin: PluginArgs; - initAuthority?: OptionOrNullable; + initAuthority?: OptionOrNullable; }; export function getAddCollectionPluginV1InstructionDataSerializer(): Serializer< @@ -77,7 +77,7 @@ export function getAddCollectionPluginV1InstructionDataSerializer(): Serializer< [ ['discriminator', u8()], ['plugin', getPluginSerializer()], - ['initAuthority', option(getPluginAuthoritySerializer())], + ['initAuthority', option(getBasePluginAuthoritySerializer())], ], { description: 'AddCollectionPluginV1InstructionData' } ), diff --git a/clients/js/src/generated/instructions/addExternalPluginV1.ts b/clients/js/src/generated/instructions/addExternalPluginV1.ts index 6c1f9109..0028614f 100644 --- a/clients/js/src/generated/instructions/addExternalPluginV1.ts +++ b/clients/js/src/generated/instructions/addExternalPluginV1.ts @@ -26,9 +26,9 @@ import { getAccountMetasAndSigners, } from '../shared'; import { - ExternalPluginInitInfo, - ExternalPluginInitInfoArgs, - getExternalPluginInitInfoSerializer, + BaseExternalPluginInitInfo, + BaseExternalPluginInitInfoArgs, + getBaseExternalPluginInitInfoSerializer, } from '../types'; // Accounts. @@ -50,11 +50,11 @@ export type AddExternalPluginV1InstructionAccounts = { // Data. export type AddExternalPluginV1InstructionData = { discriminator: number; - initInfo: ExternalPluginInitInfo; + initInfo: BaseExternalPluginInitInfo; }; export type AddExternalPluginV1InstructionDataArgs = { - initInfo: ExternalPluginInitInfoArgs; + initInfo: BaseExternalPluginInitInfoArgs; }; export function getAddExternalPluginV1InstructionDataSerializer(): Serializer< @@ -69,7 +69,7 @@ export function getAddExternalPluginV1InstructionDataSerializer(): Serializer< struct( [ ['discriminator', u8()], - ['initInfo', getExternalPluginInitInfoSerializer()], + ['initInfo', getBaseExternalPluginInitInfoSerializer()], ], { description: 'AddExternalPluginV1InstructionData' } ), diff --git a/clients/js/src/generated/instructions/addPluginV1.ts b/clients/js/src/generated/instructions/addPluginV1.ts index 2c6bd77a..030a67f9 100644 --- a/clients/js/src/generated/instructions/addPluginV1.ts +++ b/clients/js/src/generated/instructions/addPluginV1.ts @@ -30,11 +30,11 @@ import { getAccountMetasAndSigners, } from '../shared'; import { + BasePluginAuthority, + BasePluginAuthorityArgs, Plugin, PluginArgs, - PluginAuthority, - PluginAuthorityArgs, - getPluginAuthoritySerializer, + getBasePluginAuthoritySerializer, getPluginSerializer, } from '../types'; @@ -58,12 +58,12 @@ export type AddPluginV1InstructionAccounts = { export type AddPluginV1InstructionData = { discriminator: number; plugin: Plugin; - initAuthority: Option; + initAuthority: Option; }; export type AddPluginV1InstructionDataArgs = { plugin: PluginArgs; - initAuthority?: OptionOrNullable; + initAuthority?: OptionOrNullable; }; export function getAddPluginV1InstructionDataSerializer(): Serializer< @@ -79,7 +79,7 @@ export function getAddPluginV1InstructionDataSerializer(): Serializer< [ ['discriminator', u8()], ['plugin', getPluginSerializer()], - ['initAuthority', option(getPluginAuthoritySerializer())], + ['initAuthority', option(getBasePluginAuthoritySerializer())], ], { description: 'AddPluginV1InstructionData' } ), diff --git a/clients/js/src/generated/instructions/approveCollectionPluginAuthorityV1.ts b/clients/js/src/generated/instructions/approveCollectionPluginAuthorityV1.ts index 0613bef2..340730fe 100644 --- a/clients/js/src/generated/instructions/approveCollectionPluginAuthorityV1.ts +++ b/clients/js/src/generated/instructions/approveCollectionPluginAuthorityV1.ts @@ -26,11 +26,11 @@ import { getAccountMetasAndSigners, } from '../shared'; import { - PluginAuthority, - PluginAuthorityArgs, + BasePluginAuthority, + BasePluginAuthorityArgs, PluginType, PluginTypeArgs, - getPluginAuthoritySerializer, + getBasePluginAuthoritySerializer, getPluginTypeSerializer, } from '../types'; @@ -52,12 +52,12 @@ export type ApproveCollectionPluginAuthorityV1InstructionAccounts = { export type ApproveCollectionPluginAuthorityV1InstructionData = { discriminator: number; pluginType: PluginType; - newAuthority: PluginAuthority; + newAuthority: BasePluginAuthority; }; export type ApproveCollectionPluginAuthorityV1InstructionDataArgs = { pluginType: PluginTypeArgs; - newAuthority: PluginAuthorityArgs; + newAuthority: BasePluginAuthorityArgs; }; export function getApproveCollectionPluginAuthorityV1InstructionDataSerializer(): Serializer< @@ -73,7 +73,7 @@ export function getApproveCollectionPluginAuthorityV1InstructionDataSerializer() [ ['discriminator', u8()], ['pluginType', getPluginTypeSerializer()], - ['newAuthority', getPluginAuthoritySerializer()], + ['newAuthority', getBasePluginAuthoritySerializer()], ], { description: 'ApproveCollectionPluginAuthorityV1InstructionData' } ), diff --git a/clients/js/src/generated/instructions/approvePluginAuthorityV1.ts b/clients/js/src/generated/instructions/approvePluginAuthorityV1.ts index 00bb4744..6d92528a 100644 --- a/clients/js/src/generated/instructions/approvePluginAuthorityV1.ts +++ b/clients/js/src/generated/instructions/approvePluginAuthorityV1.ts @@ -26,11 +26,11 @@ import { getAccountMetasAndSigners, } from '../shared'; import { - PluginAuthority, - PluginAuthorityArgs, + BasePluginAuthority, + BasePluginAuthorityArgs, PluginType, PluginTypeArgs, - getPluginAuthoritySerializer, + getBasePluginAuthoritySerializer, getPluginTypeSerializer, } from '../types'; @@ -54,12 +54,12 @@ export type ApprovePluginAuthorityV1InstructionAccounts = { export type ApprovePluginAuthorityV1InstructionData = { discriminator: number; pluginType: PluginType; - newAuthority: PluginAuthority; + newAuthority: BasePluginAuthority; }; export type ApprovePluginAuthorityV1InstructionDataArgs = { pluginType: PluginTypeArgs; - newAuthority: PluginAuthorityArgs; + newAuthority: BasePluginAuthorityArgs; }; export function getApprovePluginAuthorityV1InstructionDataSerializer(): Serializer< @@ -75,7 +75,7 @@ export function getApprovePluginAuthorityV1InstructionDataSerializer(): Serializ [ ['discriminator', u8()], ['pluginType', getPluginTypeSerializer()], - ['newAuthority', getPluginAuthoritySerializer()], + ['newAuthority', getBasePluginAuthoritySerializer()], ], { description: 'ApprovePluginAuthorityV1InstructionData' } ), diff --git a/clients/js/src/generated/instructions/createCollectionV2.ts b/clients/js/src/generated/instructions/createCollectionV2.ts index f3ee90ef..b37cdc22 100644 --- a/clients/js/src/generated/instructions/createCollectionV2.ts +++ b/clients/js/src/generated/instructions/createCollectionV2.ts @@ -14,6 +14,7 @@ import { PublicKey, Signer, TransactionBuilder, + none, transactionBuilder, } from '@metaplex-foundation/umi'; import { @@ -31,11 +32,11 @@ import { getAccountMetasAndSigners, } from '../shared'; import { - ExternalPluginInitInfo, - ExternalPluginInitInfoArgs, + BaseExternalPluginInitInfo, + BaseExternalPluginInitInfoArgs, PluginAuthorityPair, PluginAuthorityPairArgs, - getExternalPluginInitInfoSerializer, + getBaseExternalPluginInitInfoSerializer, getPluginAuthorityPairSerializer, } from '../types'; @@ -57,14 +58,14 @@ export type CreateCollectionV2InstructionData = { name: string; uri: string; plugins: Option>; - externalPlugins: Option>; + externalPlugins: Option>; }; export type CreateCollectionV2InstructionDataArgs = { name: string; uri: string; - plugins: OptionOrNullable>; - externalPlugins: OptionOrNullable>; + plugins?: OptionOrNullable>; + externalPlugins?: OptionOrNullable>; }; export function getCreateCollectionV2InstructionDataSerializer(): Serializer< @@ -84,12 +85,17 @@ export function getCreateCollectionV2InstructionDataSerializer(): Serializer< ['plugins', option(array(getPluginAuthorityPairSerializer()))], [ 'externalPlugins', - option(array(getExternalPluginInitInfoSerializer())), + option(array(getBaseExternalPluginInitInfoSerializer())), ], ], { description: 'CreateCollectionV2InstructionData' } ), - (value) => ({ ...value, discriminator: 21 }) + (value) => ({ + ...value, + discriminator: 21, + plugins: value.plugins ?? none(), + externalPlugins: value.externalPlugins ?? [], + }) ) as Serializer< CreateCollectionV2InstructionDataArgs, CreateCollectionV2InstructionData diff --git a/clients/js/src/generated/instructions/createV2.ts b/clients/js/src/generated/instructions/createV2.ts index 3b0fe01a..98c44296 100644 --- a/clients/js/src/generated/instructions/createV2.ts +++ b/clients/js/src/generated/instructions/createV2.ts @@ -31,14 +31,14 @@ import { getAccountMetasAndSigners, } from '../shared'; import { + BaseExternalPluginInitInfo, + BaseExternalPluginInitInfoArgs, DataState, DataStateArgs, - ExternalPluginInitInfo, - ExternalPluginInitInfoArgs, PluginAuthorityPair, PluginAuthorityPairArgs, + getBaseExternalPluginInitInfoSerializer, getDataStateSerializer, - getExternalPluginInitInfoSerializer, getPluginAuthorityPairSerializer, } from '../types'; @@ -69,15 +69,15 @@ export type CreateV2InstructionData = { name: string; uri: string; plugins: Option>; - externalPlugins: Option>; + externalPlugins: Option>; }; export type CreateV2InstructionDataArgs = { - dataState: DataStateArgs; + dataState?: DataStateArgs; name: string; uri: string; - plugins: OptionOrNullable>; - externalPlugins: OptionOrNullable>; + plugins?: OptionOrNullable>; + externalPlugins?: OptionOrNullable>; }; export function getCreateV2InstructionDataSerializer(): Serializer< @@ -98,12 +98,18 @@ export function getCreateV2InstructionDataSerializer(): Serializer< ['plugins', option(array(getPluginAuthorityPairSerializer()))], [ 'externalPlugins', - option(array(getExternalPluginInitInfoSerializer())), + option(array(getBaseExternalPluginInitInfoSerializer())), ], ], { description: 'CreateV2InstructionData' } ), - (value) => ({ ...value, discriminator: 20 }) + (value) => ({ + ...value, + discriminator: 20, + dataState: value.dataState ?? DataState.AccountState, + plugins: value.plugins ?? [], + externalPlugins: value.externalPlugins ?? [], + }) ) as Serializer; } diff --git a/clients/js/src/generated/instructions/removeCollectionExternalPluginV1.ts b/clients/js/src/generated/instructions/removeCollectionExternalPluginV1.ts index 2f0b6fde..22a74562 100644 --- a/clients/js/src/generated/instructions/removeCollectionExternalPluginV1.ts +++ b/clients/js/src/generated/instructions/removeCollectionExternalPluginV1.ts @@ -26,9 +26,9 @@ import { getAccountMetasAndSigners, } from '../shared'; import { - ExternalPluginKey, - ExternalPluginKeyArgs, - getExternalPluginKeySerializer, + BaseExternalPluginKey, + BaseExternalPluginKeyArgs, + getBaseExternalPluginKeySerializer, } from '../types'; // Accounts. @@ -48,11 +48,11 @@ export type RemoveCollectionExternalPluginV1InstructionAccounts = { // Data. export type RemoveCollectionExternalPluginV1InstructionData = { discriminator: number; - key: ExternalPluginKey; + key: BaseExternalPluginKey; }; export type RemoveCollectionExternalPluginV1InstructionDataArgs = { - key: ExternalPluginKeyArgs; + key: BaseExternalPluginKeyArgs; }; export function getRemoveCollectionExternalPluginV1InstructionDataSerializer(): Serializer< @@ -67,7 +67,7 @@ export function getRemoveCollectionExternalPluginV1InstructionDataSerializer(): struct( [ ['discriminator', u8()], - ['key', getExternalPluginKeySerializer()], + ['key', getBaseExternalPluginKeySerializer()], ], { description: 'RemoveCollectionExternalPluginV1InstructionData' } ), diff --git a/clients/js/src/generated/instructions/removeExternalPluginV1.ts b/clients/js/src/generated/instructions/removeExternalPluginV1.ts index b1117c33..58e2901c 100644 --- a/clients/js/src/generated/instructions/removeExternalPluginV1.ts +++ b/clients/js/src/generated/instructions/removeExternalPluginV1.ts @@ -26,9 +26,9 @@ import { getAccountMetasAndSigners, } from '../shared'; import { - ExternalPluginKey, - ExternalPluginKeyArgs, - getExternalPluginKeySerializer, + BaseExternalPluginKey, + BaseExternalPluginKeyArgs, + getBaseExternalPluginKeySerializer, } from '../types'; // Accounts. @@ -50,11 +50,11 @@ export type RemoveExternalPluginV1InstructionAccounts = { // Data. export type RemoveExternalPluginV1InstructionData = { discriminator: number; - key: ExternalPluginKey; + key: BaseExternalPluginKey; }; export type RemoveExternalPluginV1InstructionDataArgs = { - key: ExternalPluginKeyArgs; + key: BaseExternalPluginKeyArgs; }; export function getRemoveExternalPluginV1InstructionDataSerializer(): Serializer< @@ -69,7 +69,7 @@ export function getRemoveExternalPluginV1InstructionDataSerializer(): Serializer struct( [ ['discriminator', u8()], - ['key', getExternalPluginKeySerializer()], + ['key', getBaseExternalPluginKeySerializer()], ], { description: 'RemoveExternalPluginV1InstructionData' } ), diff --git a/clients/js/src/generated/instructions/updateCollectionExternalPluginV1.ts b/clients/js/src/generated/instructions/updateCollectionExternalPluginV1.ts index cfd4717d..401cb87b 100644 --- a/clients/js/src/generated/instructions/updateCollectionExternalPluginV1.ts +++ b/clients/js/src/generated/instructions/updateCollectionExternalPluginV1.ts @@ -26,12 +26,12 @@ import { getAccountMetasAndSigners, } from '../shared'; import { - ExternalPluginKey, - ExternalPluginKeyArgs, - ExternalPluginUpdateInfo, - ExternalPluginUpdateInfoArgs, - getExternalPluginKeySerializer, - getExternalPluginUpdateInfoSerializer, + BaseExternalPluginKey, + BaseExternalPluginKeyArgs, + BaseExternalPluginUpdateInfo, + BaseExternalPluginUpdateInfoArgs, + getBaseExternalPluginKeySerializer, + getBaseExternalPluginUpdateInfoSerializer, } from '../types'; // Accounts. @@ -51,13 +51,13 @@ export type UpdateCollectionExternalPluginV1InstructionAccounts = { // Data. export type UpdateCollectionExternalPluginV1InstructionData = { discriminator: number; - pluginKey: ExternalPluginKey; - updateInfo: ExternalPluginUpdateInfo; + pluginKey: BaseExternalPluginKey; + updateInfo: BaseExternalPluginUpdateInfo; }; export type UpdateCollectionExternalPluginV1InstructionDataArgs = { - pluginKey: ExternalPluginKeyArgs; - updateInfo: ExternalPluginUpdateInfoArgs; + pluginKey: BaseExternalPluginKeyArgs; + updateInfo: BaseExternalPluginUpdateInfoArgs; }; export function getUpdateCollectionExternalPluginV1InstructionDataSerializer(): Serializer< @@ -72,8 +72,8 @@ export function getUpdateCollectionExternalPluginV1InstructionDataSerializer(): struct( [ ['discriminator', u8()], - ['pluginKey', getExternalPluginKeySerializer()], - ['updateInfo', getExternalPluginUpdateInfoSerializer()], + ['pluginKey', getBaseExternalPluginKeySerializer()], + ['updateInfo', getBaseExternalPluginUpdateInfoSerializer()], ], { description: 'UpdateCollectionExternalPluginV1InstructionData' } ), diff --git a/clients/js/src/generated/instructions/updateCollectionV1.ts b/clients/js/src/generated/instructions/updateCollectionV1.ts index 6ac91f0d..e31cbee4 100644 --- a/clients/js/src/generated/instructions/updateCollectionV1.ts +++ b/clients/js/src/generated/instructions/updateCollectionV1.ts @@ -14,6 +14,7 @@ import { PublicKey, Signer, TransactionBuilder, + none, transactionBuilder, } from '@metaplex-foundation/umi'; import { @@ -54,8 +55,8 @@ export type UpdateCollectionV1InstructionData = { }; export type UpdateCollectionV1InstructionDataArgs = { - newName: OptionOrNullable; - newUri: OptionOrNullable; + newName?: OptionOrNullable; + newUri?: OptionOrNullable; }; export function getUpdateCollectionV1InstructionDataSerializer(): Serializer< @@ -75,7 +76,12 @@ export function getUpdateCollectionV1InstructionDataSerializer(): Serializer< ], { description: 'UpdateCollectionV1InstructionData' } ), - (value) => ({ ...value, discriminator: 16 }) + (value) => ({ + ...value, + discriminator: 16, + newName: value.newName ?? none(), + newUri: value.newUri ?? none(), + }) ) as Serializer< UpdateCollectionV1InstructionDataArgs, UpdateCollectionV1InstructionData diff --git a/clients/js/src/generated/instructions/updateExternalPluginV1.ts b/clients/js/src/generated/instructions/updateExternalPluginV1.ts index ae30faa0..e6958bfc 100644 --- a/clients/js/src/generated/instructions/updateExternalPluginV1.ts +++ b/clients/js/src/generated/instructions/updateExternalPluginV1.ts @@ -26,12 +26,12 @@ import { getAccountMetasAndSigners, } from '../shared'; import { - ExternalPluginKey, - ExternalPluginKeyArgs, - ExternalPluginUpdateInfo, - ExternalPluginUpdateInfoArgs, - getExternalPluginKeySerializer, - getExternalPluginUpdateInfoSerializer, + BaseExternalPluginKey, + BaseExternalPluginKeyArgs, + BaseExternalPluginUpdateInfo, + BaseExternalPluginUpdateInfoArgs, + getBaseExternalPluginKeySerializer, + getBaseExternalPluginUpdateInfoSerializer, } from '../types'; // Accounts. @@ -53,13 +53,13 @@ export type UpdateExternalPluginV1InstructionAccounts = { // Data. export type UpdateExternalPluginV1InstructionData = { discriminator: number; - key: ExternalPluginKey; - updateInfo: ExternalPluginUpdateInfo; + key: BaseExternalPluginKey; + updateInfo: BaseExternalPluginUpdateInfo; }; export type UpdateExternalPluginV1InstructionDataArgs = { - key: ExternalPluginKeyArgs; - updateInfo: ExternalPluginUpdateInfoArgs; + key: BaseExternalPluginKeyArgs; + updateInfo: BaseExternalPluginUpdateInfoArgs; }; export function getUpdateExternalPluginV1InstructionDataSerializer(): Serializer< @@ -74,8 +74,8 @@ export function getUpdateExternalPluginV1InstructionDataSerializer(): Serializer struct( [ ['discriminator', u8()], - ['key', getExternalPluginKeySerializer()], - ['updateInfo', getExternalPluginUpdateInfoSerializer()], + ['key', getBaseExternalPluginKeySerializer()], + ['updateInfo', getBaseExternalPluginUpdateInfoSerializer()], ], { description: 'UpdateExternalPluginV1InstructionData' } ), diff --git a/clients/js/src/generated/instructions/updateV1.ts b/clients/js/src/generated/instructions/updateV1.ts index 18db5c77..1be587a6 100644 --- a/clients/js/src/generated/instructions/updateV1.ts +++ b/clients/js/src/generated/instructions/updateV1.ts @@ -31,9 +31,9 @@ import { getAccountMetasAndSigners, } from '../shared'; import { - UpdateAuthority, - UpdateAuthorityArgs, - getUpdateAuthoritySerializer, + BaseUpdateAuthority, + BaseUpdateAuthorityArgs, + getBaseUpdateAuthoritySerializer, } from '../types'; // Accounts. @@ -57,13 +57,13 @@ export type UpdateV1InstructionData = { discriminator: number; newName: Option; newUri: Option; - newUpdateAuthority: Option; + newUpdateAuthority: Option; }; export type UpdateV1InstructionDataArgs = { - newName: OptionOrNullable; - newUri: OptionOrNullable; - newUpdateAuthority?: OptionOrNullable; + newName?: OptionOrNullable; + newUri?: OptionOrNullable; + newUpdateAuthority?: OptionOrNullable; }; export function getUpdateV1InstructionDataSerializer(): Serializer< @@ -80,13 +80,15 @@ export function getUpdateV1InstructionDataSerializer(): Serializer< ['discriminator', u8()], ['newName', option(string())], ['newUri', option(string())], - ['newUpdateAuthority', option(getUpdateAuthoritySerializer())], + ['newUpdateAuthority', option(getBaseUpdateAuthoritySerializer())], ], { description: 'UpdateV1InstructionData' } ), (value) => ({ ...value, discriminator: 15, + newName: value.newName ?? none(), + newUri: value.newUri ?? none(), newUpdateAuthority: value.newUpdateAuthority ?? none(), }) ) as Serializer; diff --git a/clients/js/src/generated/instructions/writeCollectionExternalPluginDataV1.ts b/clients/js/src/generated/instructions/writeCollectionExternalPluginDataV1.ts index 8e2bad38..21c4b141 100644 --- a/clients/js/src/generated/instructions/writeCollectionExternalPluginDataV1.ts +++ b/clients/js/src/generated/instructions/writeCollectionExternalPluginDataV1.ts @@ -28,9 +28,9 @@ import { getAccountMetasAndSigners, } from '../shared'; import { - ExternalPluginKey, - ExternalPluginKeyArgs, - getExternalPluginKeySerializer, + BaseExternalPluginKey, + BaseExternalPluginKeyArgs, + getBaseExternalPluginKeySerializer, } from '../types'; // Accounts. @@ -50,12 +50,12 @@ export type WriteCollectionExternalPluginDataV1InstructionAccounts = { // Data. export type WriteCollectionExternalPluginDataV1InstructionData = { discriminator: number; - key: ExternalPluginKey; + key: BaseExternalPluginKey; data: Uint8Array; }; export type WriteCollectionExternalPluginDataV1InstructionDataArgs = { - key: ExternalPluginKeyArgs; + key: BaseExternalPluginKeyArgs; data: Uint8Array; }; @@ -71,7 +71,7 @@ export function getWriteCollectionExternalPluginDataV1InstructionDataSerializer( struct( [ ['discriminator', u8()], - ['key', getExternalPluginKeySerializer()], + ['key', getBaseExternalPluginKeySerializer()], ['data', bytes({ size: u32() })], ], { description: 'WriteCollectionExternalPluginDataV1InstructionData' } diff --git a/clients/js/src/generated/instructions/writeExternalPluginDataV1.ts b/clients/js/src/generated/instructions/writeExternalPluginDataV1.ts index ba8781a1..76d0568e 100644 --- a/clients/js/src/generated/instructions/writeExternalPluginDataV1.ts +++ b/clients/js/src/generated/instructions/writeExternalPluginDataV1.ts @@ -28,9 +28,9 @@ import { getAccountMetasAndSigners, } from '../shared'; import { - ExternalPluginKey, - ExternalPluginKeyArgs, - getExternalPluginKeySerializer, + BaseExternalPluginKey, + BaseExternalPluginKeyArgs, + getBaseExternalPluginKeySerializer, } from '../types'; // Accounts. @@ -52,12 +52,12 @@ export type WriteExternalPluginDataV1InstructionAccounts = { // Data. export type WriteExternalPluginDataV1InstructionData = { discriminator: number; - key: ExternalPluginKey; + key: BaseExternalPluginKey; data: Uint8Array; }; export type WriteExternalPluginDataV1InstructionDataArgs = { - key: ExternalPluginKeyArgs; + key: BaseExternalPluginKeyArgs; data: Uint8Array; }; @@ -73,7 +73,7 @@ export function getWriteExternalPluginDataV1InstructionDataSerializer(): Seriali struct( [ ['discriminator', u8()], - ['key', getExternalPluginKeySerializer()], + ['key', getBaseExternalPluginKeySerializer()], ['data', bytes({ size: u32() })], ], { description: 'WriteExternalPluginDataV1InstructionData' } diff --git a/clients/js/src/generated/types/assetV1AccountData.ts b/clients/js/src/generated/types/assetV1AccountData.ts index 9f4ae127..b1a2dd48 100644 --- a/clients/js/src/generated/types/assetV1AccountData.ts +++ b/clients/js/src/generated/types/assetV1AccountData.ts @@ -16,18 +16,18 @@ import { u64, } from '@metaplex-foundation/umi/serializers'; import { + BaseUpdateAuthority, + BaseUpdateAuthorityArgs, Key, KeyArgs, - UpdateAuthority, - UpdateAuthorityArgs, + getBaseUpdateAuthoritySerializer, getKeySerializer, - getUpdateAuthoritySerializer, } from '.'; export type AssetV1AccountData = { key: Key; owner: PublicKey; - updateAuthority: UpdateAuthority; + updateAuthority: BaseUpdateAuthority; name: string; uri: string; seq: Option; @@ -36,7 +36,7 @@ export type AssetV1AccountData = { export type AssetV1AccountDataArgs = { key: KeyArgs; owner: PublicKey; - updateAuthority: UpdateAuthorityArgs; + updateAuthority: BaseUpdateAuthorityArgs; name: string; uri: string; seq: OptionOrNullable; @@ -50,7 +50,7 @@ export function getAssetV1AccountDataSerializer(): Serializer< [ ['key', getKeySerializer()], ['owner', publicKeySerializer()], - ['updateAuthority', getUpdateAuthoritySerializer()], + ['updateAuthority', getBaseUpdateAuthoritySerializer()], ['name', string()], ['uri', string()], ['seq', option(u64())], diff --git a/clients/js/src/generated/types/dataStore.ts b/clients/js/src/generated/types/baseDataStore.ts similarity index 58% rename from clients/js/src/generated/types/dataStore.ts rename to clients/js/src/generated/types/baseDataStore.ts index 7ec1331d..0f949d5b 100644 --- a/clients/js/src/generated/types/dataStore.ts +++ b/clients/js/src/generated/types/baseDataStore.ts @@ -8,36 +8,39 @@ import { Serializer, struct, u64 } from '@metaplex-foundation/umi/serializers'; import { + BasePluginAuthority, + BasePluginAuthorityArgs, ExternalPluginSchema, ExternalPluginSchemaArgs, - PluginAuthority, - PluginAuthorityArgs, + getBasePluginAuthoritySerializer, getExternalPluginSchemaSerializer, - getPluginAuthoritySerializer, } from '.'; -export type DataStore = { - dataAuthority: PluginAuthority; +export type BaseDataStore = { + dataAuthority: BasePluginAuthority; schema: ExternalPluginSchema; dataOffset: bigint; dataLen: bigint; }; -export type DataStoreArgs = { - dataAuthority: PluginAuthorityArgs; +export type BaseDataStoreArgs = { + dataAuthority: BasePluginAuthorityArgs; schema: ExternalPluginSchemaArgs; dataOffset: number | bigint; dataLen: number | bigint; }; -export function getDataStoreSerializer(): Serializer { - return struct( +export function getBaseDataStoreSerializer(): Serializer< + BaseDataStoreArgs, + BaseDataStore +> { + return struct( [ - ['dataAuthority', getPluginAuthoritySerializer()], + ['dataAuthority', getBasePluginAuthoritySerializer()], ['schema', getExternalPluginSchemaSerializer()], ['dataOffset', u64()], ['dataLen', u64()], ], - { description: 'DataStore' } - ) as Serializer; + { description: 'BaseDataStore' } + ) as Serializer; } diff --git a/clients/js/src/generated/types/baseDataStoreInitInfo.ts b/clients/js/src/generated/types/baseDataStoreInitInfo.ts new file mode 100644 index 00000000..30263140 --- /dev/null +++ b/clients/js/src/generated/types/baseDataStoreInitInfo.ts @@ -0,0 +1,48 @@ +/** + * 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 { Option, OptionOrNullable } from '@metaplex-foundation/umi'; +import { + Serializer, + option, + struct, +} from '@metaplex-foundation/umi/serializers'; +import { + BasePluginAuthority, + BasePluginAuthorityArgs, + ExternalPluginSchema, + ExternalPluginSchemaArgs, + getBasePluginAuthoritySerializer, + getExternalPluginSchemaSerializer, +} from '.'; + +export type BaseDataStoreInitInfo = { + dataAuthority: BasePluginAuthority; + initPluginAuthority: Option; + schema: Option; +}; + +export type BaseDataStoreInitInfoArgs = { + dataAuthority: BasePluginAuthorityArgs; + initPluginAuthority: OptionOrNullable; + schema: OptionOrNullable; +}; + +export function getBaseDataStoreInitInfoSerializer(): Serializer< + BaseDataStoreInitInfoArgs, + BaseDataStoreInitInfo +> { + return struct( + [ + ['dataAuthority', getBasePluginAuthoritySerializer()], + ['initPluginAuthority', option(getBasePluginAuthoritySerializer())], + ['schema', option(getExternalPluginSchemaSerializer())], + ], + { description: 'BaseDataStoreInitInfo' } + ) as Serializer; +} diff --git a/clients/js/src/generated/types/dataStoreUpdateInfo.ts b/clients/js/src/generated/types/baseDataStoreUpdateInfo.ts similarity index 60% rename from clients/js/src/generated/types/dataStoreUpdateInfo.ts rename to clients/js/src/generated/types/baseDataStoreUpdateInfo.ts index 40528495..e2202de7 100644 --- a/clients/js/src/generated/types/dataStoreUpdateInfo.ts +++ b/clients/js/src/generated/types/baseDataStoreUpdateInfo.ts @@ -18,18 +18,18 @@ import { getExternalPluginSchemaSerializer, } from '.'; -export type DataStoreUpdateInfo = { schema: Option }; +export type BaseDataStoreUpdateInfo = { schema: Option }; -export type DataStoreUpdateInfoArgs = { +export type BaseDataStoreUpdateInfoArgs = { schema: OptionOrNullable; }; -export function getDataStoreUpdateInfoSerializer(): Serializer< - DataStoreUpdateInfoArgs, - DataStoreUpdateInfo +export function getBaseDataStoreUpdateInfoSerializer(): Serializer< + BaseDataStoreUpdateInfoArgs, + BaseDataStoreUpdateInfo > { - return struct( + return struct( [['schema', option(getExternalPluginSchemaSerializer())]], - { description: 'DataStoreUpdateInfo' } - ) as Serializer; + { description: 'BaseDataStoreUpdateInfo' } + ) as Serializer; } diff --git a/clients/js/src/generated/types/baseExternalPluginInitInfo.ts b/clients/js/src/generated/types/baseExternalPluginInitInfo.ts new file mode 100644 index 00000000..6d93b748 --- /dev/null +++ b/clients/js/src/generated/types/baseExternalPluginInitInfo.ts @@ -0,0 +1,104 @@ +/** + * 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 { + GetDataEnumKind, + GetDataEnumKindContent, + Serializer, + dataEnum, + struct, + tuple, +} from '@metaplex-foundation/umi/serializers'; +import { + BaseDataStoreInitInfo, + BaseDataStoreInitInfoArgs, + BaseLifecycleHookInitInfo, + BaseLifecycleHookInitInfoArgs, + BaseOracleInitInfo, + BaseOracleInitInfoArgs, + getBaseDataStoreInitInfoSerializer, + getBaseLifecycleHookInitInfoSerializer, + getBaseOracleInitInfoSerializer, +} from '.'; + +export type BaseExternalPluginInitInfo = + | { __kind: 'LifecycleHook'; fields: [BaseLifecycleHookInitInfo] } + | { __kind: 'Oracle'; fields: [BaseOracleInitInfo] } + | { __kind: 'DataStore'; fields: [BaseDataStoreInitInfo] }; + +export type BaseExternalPluginInitInfoArgs = + | { __kind: 'LifecycleHook'; fields: [BaseLifecycleHookInitInfoArgs] } + | { __kind: 'Oracle'; fields: [BaseOracleInitInfoArgs] } + | { __kind: 'DataStore'; fields: [BaseDataStoreInitInfoArgs] }; + +export function getBaseExternalPluginInitInfoSerializer(): Serializer< + BaseExternalPluginInitInfoArgs, + BaseExternalPluginInitInfo +> { + return dataEnum( + [ + [ + 'LifecycleHook', + struct< + GetDataEnumKindContent + >([['fields', tuple([getBaseLifecycleHookInitInfoSerializer()])]]), + ], + [ + 'Oracle', + struct>([ + ['fields', tuple([getBaseOracleInitInfoSerializer()])], + ]), + ], + [ + 'DataStore', + struct>( + [['fields', tuple([getBaseDataStoreInitInfoSerializer()])]] + ), + ], + ], + { description: 'BaseExternalPluginInitInfo' } + ) as Serializer; +} + +// Data Enum Helpers. +export function baseExternalPluginInitInfo( + kind: 'LifecycleHook', + data: GetDataEnumKindContent< + BaseExternalPluginInitInfoArgs, + 'LifecycleHook' + >['fields'] +): GetDataEnumKind; +export function baseExternalPluginInitInfo( + kind: 'Oracle', + data: GetDataEnumKindContent< + BaseExternalPluginInitInfoArgs, + 'Oracle' + >['fields'] +): GetDataEnumKind; +export function baseExternalPluginInitInfo( + kind: 'DataStore', + data: GetDataEnumKindContent< + BaseExternalPluginInitInfoArgs, + 'DataStore' + >['fields'] +): GetDataEnumKind; +export function baseExternalPluginInitInfo< + K extends BaseExternalPluginInitInfoArgs['__kind'] +>(kind: K, data?: any): Extract { + return Array.isArray(data) + ? { __kind: kind, fields: data } + : { __kind: kind, ...(data ?? {}) }; +} +export function isBaseExternalPluginInitInfo< + K extends BaseExternalPluginInitInfo['__kind'] +>( + kind: K, + value: BaseExternalPluginInitInfo +): value is BaseExternalPluginInitInfo & { __kind: K } { + return value.__kind === kind; +} diff --git a/clients/js/src/generated/types/baseExternalPluginKey.ts b/clients/js/src/generated/types/baseExternalPluginKey.ts new file mode 100644 index 00000000..a9f34c10 --- /dev/null +++ b/clients/js/src/generated/types/baseExternalPluginKey.ts @@ -0,0 +1,94 @@ +/** + * 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 { PublicKey } from '@metaplex-foundation/umi'; +import { + GetDataEnumKind, + GetDataEnumKindContent, + Serializer, + dataEnum, + publicKey as publicKeySerializer, + struct, + tuple, +} from '@metaplex-foundation/umi/serializers'; +import { + BasePluginAuthority, + BasePluginAuthorityArgs, + getBasePluginAuthoritySerializer, +} from '.'; + +export type BaseExternalPluginKey = + | { __kind: 'LifecycleHook'; fields: [PublicKey] } + | { __kind: 'Oracle'; fields: [PublicKey] } + | { __kind: 'DataStore'; fields: [BasePluginAuthority] }; + +export type BaseExternalPluginKeyArgs = + | { __kind: 'LifecycleHook'; fields: [PublicKey] } + | { __kind: 'Oracle'; fields: [PublicKey] } + | { __kind: 'DataStore'; fields: [BasePluginAuthorityArgs] }; + +export function getBaseExternalPluginKeySerializer(): Serializer< + BaseExternalPluginKeyArgs, + BaseExternalPluginKey +> { + return dataEnum( + [ + [ + 'LifecycleHook', + struct>([ + ['fields', tuple([publicKeySerializer()])], + ]), + ], + [ + 'Oracle', + struct>([ + ['fields', tuple([publicKeySerializer()])], + ]), + ], + [ + 'DataStore', + struct>([ + ['fields', tuple([getBasePluginAuthoritySerializer()])], + ]), + ], + ], + { description: 'BaseExternalPluginKey' } + ) as Serializer; +} + +// Data Enum Helpers. +export function baseExternalPluginKey( + kind: 'LifecycleHook', + data: GetDataEnumKindContent< + BaseExternalPluginKeyArgs, + 'LifecycleHook' + >['fields'] +): GetDataEnumKind; +export function baseExternalPluginKey( + kind: 'Oracle', + data: GetDataEnumKindContent['fields'] +): GetDataEnumKind; +export function baseExternalPluginKey( + kind: 'DataStore', + data: GetDataEnumKindContent['fields'] +): GetDataEnumKind; +export function baseExternalPluginKey< + K extends BaseExternalPluginKeyArgs['__kind'] +>(kind: K, data?: any): Extract { + return Array.isArray(data) + ? { __kind: kind, fields: data } + : { __kind: kind, ...(data ?? {}) }; +} +export function isBaseExternalPluginKey< + K extends BaseExternalPluginKey['__kind'] +>( + kind: K, + value: BaseExternalPluginKey +): value is BaseExternalPluginKey & { __kind: K } { + return value.__kind === kind; +} diff --git a/clients/js/src/generated/types/baseExternalPluginUpdateInfo.ts b/clients/js/src/generated/types/baseExternalPluginUpdateInfo.ts new file mode 100644 index 00000000..c97eefbb --- /dev/null +++ b/clients/js/src/generated/types/baseExternalPluginUpdateInfo.ts @@ -0,0 +1,110 @@ +/** + * 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 { + GetDataEnumKind, + GetDataEnumKindContent, + Serializer, + dataEnum, + struct, + tuple, +} from '@metaplex-foundation/umi/serializers'; +import { + BaseDataStoreUpdateInfo, + BaseDataStoreUpdateInfoArgs, + BaseLifecycleHookUpdateInfo, + BaseLifecycleHookUpdateInfoArgs, + BaseOracleUpdateInfo, + BaseOracleUpdateInfoArgs, + getBaseDataStoreUpdateInfoSerializer, + getBaseLifecycleHookUpdateInfoSerializer, + getBaseOracleUpdateInfoSerializer, +} from '.'; + +export type BaseExternalPluginUpdateInfo = + | { __kind: 'LifecycleHook'; fields: [BaseLifecycleHookUpdateInfo] } + | { __kind: 'Oracle'; fields: [BaseOracleUpdateInfo] } + | { __kind: 'DataStore'; fields: [BaseDataStoreUpdateInfo] }; + +export type BaseExternalPluginUpdateInfoArgs = + | { __kind: 'LifecycleHook'; fields: [BaseLifecycleHookUpdateInfoArgs] } + | { __kind: 'Oracle'; fields: [BaseOracleUpdateInfoArgs] } + | { __kind: 'DataStore'; fields: [BaseDataStoreUpdateInfoArgs] }; + +export function getBaseExternalPluginUpdateInfoSerializer(): Serializer< + BaseExternalPluginUpdateInfoArgs, + BaseExternalPluginUpdateInfo +> { + return dataEnum( + [ + [ + 'LifecycleHook', + struct< + GetDataEnumKindContent + >([['fields', tuple([getBaseLifecycleHookUpdateInfoSerializer()])]]), + ], + [ + 'Oracle', + struct>([ + ['fields', tuple([getBaseOracleUpdateInfoSerializer()])], + ]), + ], + [ + 'DataStore', + struct< + GetDataEnumKindContent + >([['fields', tuple([getBaseDataStoreUpdateInfoSerializer()])]]), + ], + ], + { description: 'BaseExternalPluginUpdateInfo' } + ) as Serializer< + BaseExternalPluginUpdateInfoArgs, + BaseExternalPluginUpdateInfo + >; +} + +// Data Enum Helpers. +export function baseExternalPluginUpdateInfo( + kind: 'LifecycleHook', + data: GetDataEnumKindContent< + BaseExternalPluginUpdateInfoArgs, + 'LifecycleHook' + >['fields'] +): GetDataEnumKind; +export function baseExternalPluginUpdateInfo( + kind: 'Oracle', + data: GetDataEnumKindContent< + BaseExternalPluginUpdateInfoArgs, + 'Oracle' + >['fields'] +): GetDataEnumKind; +export function baseExternalPluginUpdateInfo( + kind: 'DataStore', + data: GetDataEnumKindContent< + BaseExternalPluginUpdateInfoArgs, + 'DataStore' + >['fields'] +): GetDataEnumKind; +export function baseExternalPluginUpdateInfo< + K extends BaseExternalPluginUpdateInfoArgs['__kind'] +>( + kind: K, + data?: any +): Extract { + return Array.isArray(data) + ? { __kind: kind, fields: data } + : { __kind: kind, ...(data ?? {}) }; +} +export function isBaseExternalPluginUpdateInfo< + K extends BaseExternalPluginUpdateInfo['__kind'] +>( + kind: K, + value: BaseExternalPluginUpdateInfo +): value is BaseExternalPluginUpdateInfo & { __kind: K } { + return value.__kind === kind; +} diff --git a/clients/js/src/generated/types/extraAccount.ts b/clients/js/src/generated/types/baseExtraAccount.ts similarity index 52% rename from clients/js/src/generated/types/extraAccount.ts rename to clients/js/src/generated/types/baseExtraAccount.ts index b1e36ba8..f9796ccf 100644 --- a/clients/js/src/generated/types/extraAccount.ts +++ b/clients/js/src/generated/types/baseExtraAccount.ts @@ -17,9 +17,9 @@ import { publicKey as publicKeySerializer, struct, } from '@metaplex-foundation/umi/serializers'; -import { Seed, SeedArgs, getSeedSerializer } from '.'; +import { BaseSeed, BaseSeedArgs, getBaseSeedSerializer } from '.'; -export type ExtraAccount = +export type BaseExtraAccount = | { __kind: 'PreconfiguredProgram'; isSigner: boolean; isWritable: boolean } | { __kind: 'PreconfiguredCollection'; @@ -31,7 +31,7 @@ export type ExtraAccount = | { __kind: 'PreconfiguredAsset'; isSigner: boolean; isWritable: boolean } | { __kind: 'CustomPda'; - seeds: Array; + seeds: Array; isSigner: boolean; isWritable: boolean; } @@ -42,7 +42,7 @@ export type ExtraAccount = isWritable: boolean; }; -export type ExtraAccountArgs = +export type BaseExtraAccountArgs = | { __kind: 'PreconfiguredProgram'; isSigner: boolean; isWritable: boolean } | { __kind: 'PreconfiguredCollection'; @@ -54,7 +54,7 @@ export type ExtraAccountArgs = | { __kind: 'PreconfiguredAsset'; isSigner: boolean; isWritable: boolean } | { __kind: 'CustomPda'; - seeds: Array; + seeds: Array; isSigner: boolean; isWritable: boolean; } @@ -65,110 +65,114 @@ export type ExtraAccountArgs = isWritable: boolean; }; -export function getExtraAccountSerializer(): Serializer< - ExtraAccountArgs, - ExtraAccount +export function getBaseExtraAccountSerializer(): Serializer< + BaseExtraAccountArgs, + BaseExtraAccount > { - return dataEnum( + return dataEnum( [ [ 'PreconfiguredProgram', - struct>([ + struct< + GetDataEnumKindContent + >([ ['isSigner', bool()], ['isWritable', bool()], ]), ], [ 'PreconfiguredCollection', - struct>( - [ - ['isSigner', bool()], - ['isWritable', bool()], - ] - ), + struct< + GetDataEnumKindContent + >([ + ['isSigner', bool()], + ['isWritable', bool()], + ]), ], [ 'PreconfiguredOwner', - struct>([ + struct>([ ['isSigner', bool()], ['isWritable', bool()], ]), ], [ 'PreconfiguredRecipient', - struct>([ + struct< + GetDataEnumKindContent + >([ ['isSigner', bool()], ['isWritable', bool()], ]), ], [ 'PreconfiguredAsset', - struct>([ + struct>([ ['isSigner', bool()], ['isWritable', bool()], ]), ], [ 'CustomPda', - struct>([ - ['seeds', array(getSeedSerializer())], + struct>([ + ['seeds', array(getBaseSeedSerializer())], ['isSigner', bool()], ['isWritable', bool()], ]), ], [ 'Address', - struct>([ + struct>([ ['address', publicKeySerializer()], ['isSigner', bool()], ['isWritable', bool()], ]), ], ], - { description: 'ExtraAccount' } - ) as Serializer; + { description: 'BaseExtraAccount' } + ) as Serializer; } // Data Enum Helpers. -export function extraAccount( +export function baseExtraAccount( kind: 'PreconfiguredProgram', - data: GetDataEnumKindContent -): GetDataEnumKind; -export function extraAccount( + data: GetDataEnumKindContent +): GetDataEnumKind; +export function baseExtraAccount( kind: 'PreconfiguredCollection', - data: GetDataEnumKindContent -): GetDataEnumKind; -export function extraAccount( + data: GetDataEnumKindContent +): GetDataEnumKind; +export function baseExtraAccount( kind: 'PreconfiguredOwner', - data: GetDataEnumKindContent -): GetDataEnumKind; -export function extraAccount( + data: GetDataEnumKindContent +): GetDataEnumKind; +export function baseExtraAccount( kind: 'PreconfiguredRecipient', - data: GetDataEnumKindContent -): GetDataEnumKind; -export function extraAccount( + data: GetDataEnumKindContent +): GetDataEnumKind; +export function baseExtraAccount( kind: 'PreconfiguredAsset', - data: GetDataEnumKindContent -): GetDataEnumKind; -export function extraAccount( + data: GetDataEnumKindContent +): GetDataEnumKind; +export function baseExtraAccount( kind: 'CustomPda', - data: GetDataEnumKindContent -): GetDataEnumKind; -export function extraAccount( + data: GetDataEnumKindContent +): GetDataEnumKind; +export function baseExtraAccount( kind: 'Address', - data: GetDataEnumKindContent -): GetDataEnumKind; -export function extraAccount( + data: GetDataEnumKindContent +): GetDataEnumKind; +export function baseExtraAccount( kind: K, data?: any -): Extract { +): Extract { return Array.isArray(data) ? { __kind: kind, fields: data } : { __kind: kind, ...(data ?? {}) }; } -export function isExtraAccount( +export function isBaseExtraAccount( kind: K, - value: ExtraAccount -): value is ExtraAccount & { __kind: K } { + value: BaseExtraAccount +): value is BaseExtraAccount & { __kind: K } { return value.__kind === kind; } diff --git a/clients/js/src/generated/types/lifecycleHook.ts b/clients/js/src/generated/types/baseLifecycleHook.ts similarity index 53% rename from clients/js/src/generated/types/lifecycleHook.ts rename to clients/js/src/generated/types/baseLifecycleHook.ts index 3689a806..8d469a2c 100644 --- a/clients/js/src/generated/types/lifecycleHook.ts +++ b/clients/js/src/generated/types/baseLifecycleHook.ts @@ -16,48 +16,48 @@ import { u64, } from '@metaplex-foundation/umi/serializers'; import { + BaseExtraAccount, + BaseExtraAccountArgs, + BasePluginAuthority, + BasePluginAuthorityArgs, ExternalPluginSchema, ExternalPluginSchemaArgs, - ExtraAccount, - ExtraAccountArgs, - PluginAuthority, - PluginAuthorityArgs, + getBaseExtraAccountSerializer, + getBasePluginAuthoritySerializer, getExternalPluginSchemaSerializer, - getExtraAccountSerializer, - getPluginAuthoritySerializer, } from '.'; -export type LifecycleHook = { +export type BaseLifecycleHook = { hookedProgram: PublicKey; - extraAccounts: Option>; - dataAuthority: Option; + extraAccounts: Option>; + dataAuthority: Option; schema: ExternalPluginSchema; dataOffset: bigint; dataLen: bigint; }; -export type LifecycleHookArgs = { +export type BaseLifecycleHookArgs = { hookedProgram: PublicKey; - extraAccounts: OptionOrNullable>; - dataAuthority: OptionOrNullable; + extraAccounts: OptionOrNullable>; + dataAuthority: OptionOrNullable; schema: ExternalPluginSchemaArgs; dataOffset: number | bigint; dataLen: number | bigint; }; -export function getLifecycleHookSerializer(): Serializer< - LifecycleHookArgs, - LifecycleHook +export function getBaseLifecycleHookSerializer(): Serializer< + BaseLifecycleHookArgs, + BaseLifecycleHook > { - return struct( + return struct( [ ['hookedProgram', publicKeySerializer()], - ['extraAccounts', option(array(getExtraAccountSerializer()))], - ['dataAuthority', option(getPluginAuthoritySerializer())], + ['extraAccounts', option(array(getBaseExtraAccountSerializer()))], + ['dataAuthority', option(getBasePluginAuthoritySerializer())], ['schema', getExternalPluginSchemaSerializer()], ['dataOffset', u64()], ['dataLen', u64()], ], - { description: 'LifecycleHook' } - ) as Serializer; + { description: 'BaseLifecycleHook' } + ) as Serializer; } diff --git a/clients/js/src/generated/types/lifecycleHookInitInfo.ts b/clients/js/src/generated/types/baseLifecycleHookInitInfo.ts similarity index 57% rename from clients/js/src/generated/types/lifecycleHookInitInfo.ts rename to clients/js/src/generated/types/baseLifecycleHookInitInfo.ts index 25b54483..dcd6669f 100644 --- a/clients/js/src/generated/types/lifecycleHookInitInfo.ts +++ b/clients/js/src/generated/types/baseLifecycleHookInitInfo.ts @@ -16,51 +16,51 @@ import { tuple, } from '@metaplex-foundation/umi/serializers'; import { + BaseExtraAccount, + BaseExtraAccountArgs, + BasePluginAuthority, + BasePluginAuthorityArgs, ExternalCheckResult, ExternalCheckResultArgs, ExternalPluginSchema, ExternalPluginSchemaArgs, - ExtraAccount, - ExtraAccountArgs, HookableLifecycleEvent, HookableLifecycleEventArgs, - PluginAuthority, - PluginAuthorityArgs, + getBaseExtraAccountSerializer, + getBasePluginAuthoritySerializer, getExternalCheckResultSerializer, getExternalPluginSchemaSerializer, - getExtraAccountSerializer, getHookableLifecycleEventSerializer, - getPluginAuthoritySerializer, } from '.'; -export type LifecycleHookInitInfo = { +export type BaseLifecycleHookInitInfo = { hookedProgram: PublicKey; - initPluginAuthority: Option; + initPluginAuthority: Option; lifecycleChecks: Option>; - extraAccounts: Option>; - dataAuthority: Option; + extraAccounts: Option>; + dataAuthority: Option; schema: Option; }; -export type LifecycleHookInitInfoArgs = { +export type BaseLifecycleHookInitInfoArgs = { hookedProgram: PublicKey; - initPluginAuthority: OptionOrNullable; + initPluginAuthority: OptionOrNullable; lifecycleChecks: OptionOrNullable< Array<[HookableLifecycleEventArgs, ExternalCheckResultArgs]> >; - extraAccounts: OptionOrNullable>; - dataAuthority: OptionOrNullable; + extraAccounts: OptionOrNullable>; + dataAuthority: OptionOrNullable; schema: OptionOrNullable; }; -export function getLifecycleHookInitInfoSerializer(): Serializer< - LifecycleHookInitInfoArgs, - LifecycleHookInitInfo +export function getBaseLifecycleHookInitInfoSerializer(): Serializer< + BaseLifecycleHookInitInfoArgs, + BaseLifecycleHookInitInfo > { - return struct( + return struct( [ ['hookedProgram', publicKeySerializer()], - ['initPluginAuthority', option(getPluginAuthoritySerializer())], + ['initPluginAuthority', option(getBasePluginAuthoritySerializer())], [ 'lifecycleChecks', option( @@ -72,10 +72,10 @@ export function getLifecycleHookInitInfoSerializer(): Serializer< ) ), ], - ['extraAccounts', option(array(getExtraAccountSerializer()))], - ['dataAuthority', option(getPluginAuthoritySerializer())], + ['extraAccounts', option(array(getBaseExtraAccountSerializer()))], + ['dataAuthority', option(getBasePluginAuthoritySerializer())], ['schema', option(getExternalPluginSchemaSerializer())], ], - { description: 'LifecycleHookInitInfo' } - ) as Serializer; + { description: 'BaseLifecycleHookInitInfo' } + ) as Serializer; } diff --git a/clients/js/src/generated/types/lifecycleHookUpdateInfo.ts b/clients/js/src/generated/types/baseLifecycleHookUpdateInfo.ts similarity index 66% rename from clients/js/src/generated/types/lifecycleHookUpdateInfo.ts rename to clients/js/src/generated/types/baseLifecycleHookUpdateInfo.ts index c1d0f456..68ba9e48 100644 --- a/clients/js/src/generated/types/lifecycleHookUpdateInfo.ts +++ b/clients/js/src/generated/types/baseLifecycleHookUpdateInfo.ts @@ -15,39 +15,39 @@ import { tuple, } from '@metaplex-foundation/umi/serializers'; import { + BaseExtraAccount, + BaseExtraAccountArgs, ExternalCheckResult, ExternalCheckResultArgs, ExternalPluginSchema, ExternalPluginSchemaArgs, - ExtraAccount, - ExtraAccountArgs, HookableLifecycleEvent, HookableLifecycleEventArgs, + getBaseExtraAccountSerializer, getExternalCheckResultSerializer, getExternalPluginSchemaSerializer, - getExtraAccountSerializer, getHookableLifecycleEventSerializer, } from '.'; -export type LifecycleHookUpdateInfo = { +export type BaseLifecycleHookUpdateInfo = { lifecycleChecks: Option>; - extraAccounts: Option>; + extraAccounts: Option>; schema: Option; }; -export type LifecycleHookUpdateInfoArgs = { +export type BaseLifecycleHookUpdateInfoArgs = { lifecycleChecks: OptionOrNullable< Array<[HookableLifecycleEventArgs, ExternalCheckResultArgs]> >; - extraAccounts: OptionOrNullable>; + extraAccounts: OptionOrNullable>; schema: OptionOrNullable; }; -export function getLifecycleHookUpdateInfoSerializer(): Serializer< - LifecycleHookUpdateInfoArgs, - LifecycleHookUpdateInfo +export function getBaseLifecycleHookUpdateInfoSerializer(): Serializer< + BaseLifecycleHookUpdateInfoArgs, + BaseLifecycleHookUpdateInfo > { - return struct( + return struct( [ [ 'lifecycleChecks', @@ -60,9 +60,9 @@ export function getLifecycleHookUpdateInfoSerializer(): Serializer< ) ), ], - ['extraAccounts', option(array(getExtraAccountSerializer()))], + ['extraAccounts', option(array(getBaseExtraAccountSerializer()))], ['schema', option(getExternalPluginSchemaSerializer())], ], - { description: 'LifecycleHookUpdateInfo' } - ) as Serializer; + { description: 'BaseLifecycleHookUpdateInfo' } + ) as Serializer; } diff --git a/clients/js/src/generated/types/baseOracle.ts b/clients/js/src/generated/types/baseOracle.ts new file mode 100644 index 00000000..933c4df4 --- /dev/null +++ b/clients/js/src/generated/types/baseOracle.ts @@ -0,0 +1,49 @@ +/** + * 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 { Option, OptionOrNullable, PublicKey } from '@metaplex-foundation/umi'; +import { + Serializer, + option, + publicKey as publicKeySerializer, + struct, +} from '@metaplex-foundation/umi/serializers'; +import { + BaseExtraAccount, + BaseExtraAccountArgs, + BaseValidationResultsOffset, + BaseValidationResultsOffsetArgs, + getBaseExtraAccountSerializer, + getBaseValidationResultsOffsetSerializer, +} from '.'; + +export type BaseOracle = { + baseAddress: PublicKey; + pda: Option; + resultsOffset: BaseValidationResultsOffset; +}; + +export type BaseOracleArgs = { + baseAddress: PublicKey; + pda: OptionOrNullable; + resultsOffset: BaseValidationResultsOffsetArgs; +}; + +export function getBaseOracleSerializer(): Serializer< + BaseOracleArgs, + BaseOracle +> { + return struct( + [ + ['baseAddress', publicKeySerializer()], + ['pda', option(getBaseExtraAccountSerializer())], + ['resultsOffset', getBaseValidationResultsOffsetSerializer()], + ], + { description: 'BaseOracle' } + ) as Serializer; +} diff --git a/clients/js/src/generated/types/oracleInitInfo.ts b/clients/js/src/generated/types/baseOracleInitInfo.ts similarity index 51% rename from clients/js/src/generated/types/oracleInitInfo.ts rename to clients/js/src/generated/types/baseOracleInitInfo.ts index ee693031..bdb8e30d 100644 --- a/clients/js/src/generated/types/oracleInitInfo.ts +++ b/clients/js/src/generated/types/baseOracleInitInfo.ts @@ -16,44 +16,49 @@ import { tuple, } from '@metaplex-foundation/umi/serializers'; import { + BaseExtraAccount, + BaseExtraAccountArgs, + BasePluginAuthority, + BasePluginAuthorityArgs, + BaseValidationResultsOffset, + BaseValidationResultsOffsetArgs, ExternalCheckResult, ExternalCheckResultArgs, - ExtraAccount, - ExtraAccountArgs, HookableLifecycleEvent, HookableLifecycleEventArgs, - PluginAuthority, - PluginAuthorityArgs, + getBaseExtraAccountSerializer, + getBasePluginAuthoritySerializer, + getBaseValidationResultsOffsetSerializer, getExternalCheckResultSerializer, - getExtraAccountSerializer, getHookableLifecycleEventSerializer, - getPluginAuthoritySerializer, } from '.'; -export type OracleInitInfo = { +export type BaseOracleInitInfo = { baseAddress: PublicKey; - initPluginAuthority: Option; + initPluginAuthority: Option; lifecycleChecks: Option>; - pda: Option; + pda: Option; + resultsOffset: Option; }; -export type OracleInitInfoArgs = { +export type BaseOracleInitInfoArgs = { baseAddress: PublicKey; - initPluginAuthority: OptionOrNullable; + initPluginAuthority: OptionOrNullable; lifecycleChecks: OptionOrNullable< Array<[HookableLifecycleEventArgs, ExternalCheckResultArgs]> >; - pda: OptionOrNullable; + pda: OptionOrNullable; + resultsOffset: OptionOrNullable; }; -export function getOracleInitInfoSerializer(): Serializer< - OracleInitInfoArgs, - OracleInitInfo +export function getBaseOracleInitInfoSerializer(): Serializer< + BaseOracleInitInfoArgs, + BaseOracleInitInfo > { - return struct( + return struct( [ ['baseAddress', publicKeySerializer()], - ['initPluginAuthority', option(getPluginAuthoritySerializer())], + ['initPluginAuthority', option(getBasePluginAuthoritySerializer())], [ 'lifecycleChecks', option( @@ -65,8 +70,9 @@ export function getOracleInitInfoSerializer(): Serializer< ) ), ], - ['pda', option(getExtraAccountSerializer())], + ['pda', option(getBaseExtraAccountSerializer())], + ['resultsOffset', option(getBaseValidationResultsOffsetSerializer())], ], - { description: 'OracleInitInfo' } - ) as Serializer; + { description: 'BaseOracleInitInfo' } + ) as Serializer; } diff --git a/clients/js/src/generated/types/oracleUpdateInfo.ts b/clients/js/src/generated/types/baseOracleUpdateInfo.ts similarity index 55% rename from clients/js/src/generated/types/oracleUpdateInfo.ts rename to clients/js/src/generated/types/baseOracleUpdateInfo.ts index bfd17258..ae97c039 100644 --- a/clients/js/src/generated/types/oracleUpdateInfo.ts +++ b/clients/js/src/generated/types/baseOracleUpdateInfo.ts @@ -15,34 +15,39 @@ import { tuple, } from '@metaplex-foundation/umi/serializers'; import { + BaseExtraAccount, + BaseExtraAccountArgs, + BaseValidationResultsOffset, + BaseValidationResultsOffsetArgs, ExternalCheckResult, ExternalCheckResultArgs, - ExtraAccount, - ExtraAccountArgs, HookableLifecycleEvent, HookableLifecycleEventArgs, + getBaseExtraAccountSerializer, + getBaseValidationResultsOffsetSerializer, getExternalCheckResultSerializer, - getExtraAccountSerializer, getHookableLifecycleEventSerializer, } from '.'; -export type OracleUpdateInfo = { +export type BaseOracleUpdateInfo = { lifecycleChecks: Option>; - pda: Option; + pda: Option; + resultsOffset: Option; }; -export type OracleUpdateInfoArgs = { +export type BaseOracleUpdateInfoArgs = { lifecycleChecks: OptionOrNullable< Array<[HookableLifecycleEventArgs, ExternalCheckResultArgs]> >; - pda: OptionOrNullable; + pda: OptionOrNullable; + resultsOffset: OptionOrNullable; }; -export function getOracleUpdateInfoSerializer(): Serializer< - OracleUpdateInfoArgs, - OracleUpdateInfo +export function getBaseOracleUpdateInfoSerializer(): Serializer< + BaseOracleUpdateInfoArgs, + BaseOracleUpdateInfo > { - return struct( + return struct( [ [ 'lifecycleChecks', @@ -55,8 +60,9 @@ export function getOracleUpdateInfoSerializer(): Serializer< ) ), ], - ['pda', option(getExtraAccountSerializer())], + ['pda', option(getBaseExtraAccountSerializer())], + ['resultsOffset', option(getBaseValidationResultsOffsetSerializer())], ], - { description: 'OracleUpdateInfo' } - ) as Serializer; + { description: 'BaseOracleUpdateInfo' } + ) as Serializer; } diff --git a/clients/js/src/generated/types/basePluginAuthority.ts b/clients/js/src/generated/types/basePluginAuthority.ts new file mode 100644 index 00000000..c9916538 --- /dev/null +++ b/clients/js/src/generated/types/basePluginAuthority.ts @@ -0,0 +1,74 @@ +/** + * 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 { PublicKey } from '@metaplex-foundation/umi'; +import { + GetDataEnumKind, + GetDataEnumKindContent, + Serializer, + dataEnum, + publicKey as publicKeySerializer, + struct, + unit, +} from '@metaplex-foundation/umi/serializers'; + +export type BasePluginAuthority = + | { __kind: 'None' } + | { __kind: 'Owner' } + | { __kind: 'UpdateAuthority' } + | { __kind: 'Address'; address: PublicKey }; + +export type BasePluginAuthorityArgs = BasePluginAuthority; + +export function getBasePluginAuthoritySerializer(): Serializer< + BasePluginAuthorityArgs, + BasePluginAuthority +> { + return dataEnum( + [ + ['None', unit()], + ['Owner', unit()], + ['UpdateAuthority', unit()], + [ + 'Address', + struct>([ + ['address', publicKeySerializer()], + ]), + ], + ], + { description: 'BasePluginAuthority' } + ) as Serializer; +} + +// Data Enum Helpers. +export function basePluginAuthority( + kind: 'None' +): GetDataEnumKind; +export function basePluginAuthority( + kind: 'Owner' +): GetDataEnumKind; +export function basePluginAuthority( + kind: 'UpdateAuthority' +): GetDataEnumKind; +export function basePluginAuthority( + kind: 'Address', + data: GetDataEnumKindContent +): GetDataEnumKind; +export function basePluginAuthority< + K extends BasePluginAuthorityArgs['__kind'] +>(kind: K, data?: any): Extract { + return Array.isArray(data) + ? { __kind: kind, fields: data } + : { __kind: kind, ...(data ?? {}) }; +} +export function isBasePluginAuthority( + kind: K, + value: BasePluginAuthority +): value is BasePluginAuthority & { __kind: K } { + return value.__kind === kind; +} diff --git a/clients/js/src/generated/types/royalties.ts b/clients/js/src/generated/types/baseRoyalties.ts similarity index 57% rename from clients/js/src/generated/types/royalties.ts rename to clients/js/src/generated/types/baseRoyalties.ts index 43fe449e..7cf71d9f 100644 --- a/clients/js/src/generated/types/royalties.ts +++ b/clients/js/src/generated/types/baseRoyalties.ts @@ -13,33 +13,36 @@ import { u16, } from '@metaplex-foundation/umi/serializers'; import { + BaseRuleSet, + BaseRuleSetArgs, Creator, CreatorArgs, - RuleSet, - RuleSetArgs, + getBaseRuleSetSerializer, getCreatorSerializer, - getRuleSetSerializer, } from '.'; -export type Royalties = { +export type BaseRoyalties = { basisPoints: number; creators: Array; - ruleSet: RuleSet; + ruleSet: BaseRuleSet; }; -export type RoyaltiesArgs = { +export type BaseRoyaltiesArgs = { basisPoints: number; creators: Array; - ruleSet: RuleSetArgs; + ruleSet: BaseRuleSetArgs; }; -export function getRoyaltiesSerializer(): Serializer { - return struct( +export function getBaseRoyaltiesSerializer(): Serializer< + BaseRoyaltiesArgs, + BaseRoyalties +> { + return struct( [ ['basisPoints', u16()], ['creators', array(getCreatorSerializer())], - ['ruleSet', getRuleSetSerializer()], + ['ruleSet', getBaseRuleSetSerializer()], ], - { description: 'Royalties' } - ) as Serializer; + { description: 'BaseRoyalties' } + ) as Serializer; } diff --git a/clients/js/src/generated/types/ruleSet.ts b/clients/js/src/generated/types/baseRuleSet.ts similarity index 51% rename from clients/js/src/generated/types/ruleSet.ts rename to clients/js/src/generated/types/baseRuleSet.ts index 3850fb1a..eded7d57 100644 --- a/clients/js/src/generated/types/ruleSet.ts +++ b/clients/js/src/generated/types/baseRuleSet.ts @@ -19,55 +19,60 @@ import { unit, } from '@metaplex-foundation/umi/serializers'; -export type RuleSet = +export type BaseRuleSet = | { __kind: 'None' } | { __kind: 'ProgramAllowList'; fields: [Array] } | { __kind: 'ProgramDenyList'; fields: [Array] }; -export type RuleSetArgs = RuleSet; +export type BaseRuleSetArgs = BaseRuleSet; -export function getRuleSetSerializer(): Serializer { - return dataEnum( +export function getBaseRuleSetSerializer(): Serializer< + BaseRuleSetArgs, + BaseRuleSet +> { + return dataEnum( [ ['None', unit()], [ 'ProgramAllowList', - struct>([ + struct>([ ['fields', tuple([array(publicKeySerializer())])], ]), ], [ 'ProgramDenyList', - struct>([ + struct>([ ['fields', tuple([array(publicKeySerializer())])], ]), ], ], - { description: 'RuleSet' } - ) as Serializer; + { description: 'BaseRuleSet' } + ) as Serializer; } // Data Enum Helpers. -export function ruleSet(kind: 'None'): GetDataEnumKind; -export function ruleSet( +export function baseRuleSet( + kind: 'None' +): GetDataEnumKind; +export function baseRuleSet( kind: 'ProgramAllowList', - data: GetDataEnumKindContent['fields'] -): GetDataEnumKind; -export function ruleSet( + data: GetDataEnumKindContent['fields'] +): GetDataEnumKind; +export function baseRuleSet( kind: 'ProgramDenyList', - data: GetDataEnumKindContent['fields'] -): GetDataEnumKind; -export function ruleSet( + data: GetDataEnumKindContent['fields'] +): GetDataEnumKind; +export function baseRuleSet( kind: K, data?: any -): Extract { +): Extract { return Array.isArray(data) ? { __kind: kind, fields: data } : { __kind: kind, ...(data ?? {}) }; } -export function isRuleSet( +export function isBaseRuleSet( kind: K, - value: RuleSet -): value is RuleSet & { __kind: K } { + value: BaseRuleSet +): value is BaseRuleSet & { __kind: K } { return value.__kind === kind; } diff --git a/clients/js/src/generated/types/seed.ts b/clients/js/src/generated/types/baseSeed.ts similarity index 50% rename from clients/js/src/generated/types/seed.ts rename to clients/js/src/generated/types/baseSeed.ts index 395db9d5..77a08634 100644 --- a/clients/js/src/generated/types/seed.ts +++ b/clients/js/src/generated/types/baseSeed.ts @@ -18,7 +18,7 @@ import { unit, } from '@metaplex-foundation/umi/serializers'; -export type Seed = +export type BaseSeed = | { __kind: 'Program' } | { __kind: 'Collection' } | { __kind: 'Owner' } @@ -26,10 +26,10 @@ export type Seed = | { __kind: 'Asset' } | { __kind: 'Bytes'; fields: [Uint8Array] }; -export type SeedArgs = Seed; +export type BaseSeedArgs = BaseSeed; -export function getSeedSerializer(): Serializer { - return dataEnum( +export function getBaseSeedSerializer(): Serializer { + return dataEnum( [ ['Program', unit()], ['Collection', unit()], @@ -38,38 +38,42 @@ export function getSeedSerializer(): Serializer { ['Asset', unit()], [ 'Bytes', - struct>([ + struct>([ ['fields', tuple([bytes({ size: u32() })])], ]), ], ], - { description: 'Seed' } - ) as Serializer; + { description: 'BaseSeed' } + ) as Serializer; } // Data Enum Helpers. -export function seed(kind: 'Program'): GetDataEnumKind; -export function seed( +export function baseSeed( + kind: 'Program' +): GetDataEnumKind; +export function baseSeed( kind: 'Collection' -): GetDataEnumKind; -export function seed(kind: 'Owner'): GetDataEnumKind; -export function seed(kind: 'Recipient'): GetDataEnumKind; -export function seed(kind: 'Asset'): GetDataEnumKind; -export function seed( +): GetDataEnumKind; +export function baseSeed(kind: 'Owner'): GetDataEnumKind; +export function baseSeed( + kind: 'Recipient' +): GetDataEnumKind; +export function baseSeed(kind: 'Asset'): GetDataEnumKind; +export function baseSeed( kind: 'Bytes', - data: GetDataEnumKindContent['fields'] -): GetDataEnumKind; -export function seed( + data: GetDataEnumKindContent['fields'] +): GetDataEnumKind; +export function baseSeed( kind: K, data?: any -): Extract { +): Extract { return Array.isArray(data) ? { __kind: kind, fields: data } : { __kind: kind, ...(data ?? {}) }; } -export function isSeed( +export function isBaseSeed( kind: K, - value: Seed -): value is Seed & { __kind: K } { + value: BaseSeed +): value is BaseSeed & { __kind: K } { return value.__kind === kind; } diff --git a/clients/js/src/generated/types/baseUpdateAuthority.ts b/clients/js/src/generated/types/baseUpdateAuthority.ts new file mode 100644 index 00000000..f32f22a3 --- /dev/null +++ b/clients/js/src/generated/types/baseUpdateAuthority.ts @@ -0,0 +1,76 @@ +/** + * 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 { PublicKey } from '@metaplex-foundation/umi'; +import { + GetDataEnumKind, + GetDataEnumKindContent, + Serializer, + dataEnum, + publicKey as publicKeySerializer, + struct, + tuple, + unit, +} from '@metaplex-foundation/umi/serializers'; + +export type BaseUpdateAuthority = + | { __kind: 'None' } + | { __kind: 'Address'; fields: [PublicKey] } + | { __kind: 'Collection'; fields: [PublicKey] }; + +export type BaseUpdateAuthorityArgs = BaseUpdateAuthority; + +export function getBaseUpdateAuthoritySerializer(): Serializer< + BaseUpdateAuthorityArgs, + BaseUpdateAuthority +> { + return dataEnum( + [ + ['None', unit()], + [ + 'Address', + struct>([ + ['fields', tuple([publicKeySerializer()])], + ]), + ], + [ + 'Collection', + struct>([ + ['fields', tuple([publicKeySerializer()])], + ]), + ], + ], + { description: 'BaseUpdateAuthority' } + ) as Serializer; +} + +// Data Enum Helpers. +export function baseUpdateAuthority( + kind: 'None' +): GetDataEnumKind; +export function baseUpdateAuthority( + kind: 'Address', + data: GetDataEnumKindContent['fields'] +): GetDataEnumKind; +export function baseUpdateAuthority( + kind: 'Collection', + data: GetDataEnumKindContent['fields'] +): GetDataEnumKind; +export function baseUpdateAuthority< + K extends BaseUpdateAuthorityArgs['__kind'] +>(kind: K, data?: any): Extract { + return Array.isArray(data) + ? { __kind: kind, fields: data } + : { __kind: kind, ...(data ?? {}) }; +} +export function isBaseUpdateAuthority( + kind: K, + value: BaseUpdateAuthority +): value is BaseUpdateAuthority & { __kind: K } { + return value.__kind === kind; +} diff --git a/clients/js/src/generated/types/baseValidationResultsOffset.ts b/clients/js/src/generated/types/baseValidationResultsOffset.ts new file mode 100644 index 00000000..8dc23a02 --- /dev/null +++ b/clients/js/src/generated/types/baseValidationResultsOffset.ts @@ -0,0 +1,80 @@ +/** + * 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 { + GetDataEnumKind, + GetDataEnumKindContent, + Serializer, + dataEnum, + struct, + tuple, + u64, + unit, +} from '@metaplex-foundation/umi/serializers'; + +export type BaseValidationResultsOffset = + | { __kind: 'NoOffset' } + | { __kind: 'Anchor' } + | { __kind: 'Custom'; fields: [bigint] }; + +export type BaseValidationResultsOffsetArgs = + | { __kind: 'NoOffset' } + | { __kind: 'Anchor' } + | { __kind: 'Custom'; fields: [number | bigint] }; + +export function getBaseValidationResultsOffsetSerializer(): Serializer< + BaseValidationResultsOffsetArgs, + BaseValidationResultsOffset +> { + return dataEnum( + [ + ['NoOffset', unit()], + ['Anchor', unit()], + [ + 'Custom', + struct>([ + ['fields', tuple([u64()])], + ]), + ], + ], + { description: 'BaseValidationResultsOffset' } + ) as Serializer; +} + +// Data Enum Helpers. +export function baseValidationResultsOffset( + kind: 'NoOffset' +): GetDataEnumKind; +export function baseValidationResultsOffset( + kind: 'Anchor' +): GetDataEnumKind; +export function baseValidationResultsOffset( + kind: 'Custom', + data: GetDataEnumKindContent< + BaseValidationResultsOffsetArgs, + 'Custom' + >['fields'] +): GetDataEnumKind; +export function baseValidationResultsOffset< + K extends BaseValidationResultsOffsetArgs['__kind'] +>( + kind: K, + data?: any +): Extract { + return Array.isArray(data) + ? { __kind: kind, fields: data } + : { __kind: kind, ...(data ?? {}) }; +} +export function isBaseValidationResultsOffset< + K extends BaseValidationResultsOffset['__kind'] +>( + kind: K, + value: BaseValidationResultsOffset +): value is BaseValidationResultsOffset & { __kind: K } { + return value.__kind === kind; +} diff --git a/clients/js/src/generated/types/compressionProof.ts b/clients/js/src/generated/types/compressionProof.ts index 13d12744..da22b58d 100644 --- a/clients/js/src/generated/types/compressionProof.ts +++ b/clients/js/src/generated/types/compressionProof.ts @@ -16,17 +16,17 @@ import { u64, } from '@metaplex-foundation/umi/serializers'; import { + BaseUpdateAuthority, + BaseUpdateAuthorityArgs, HashablePluginSchema, HashablePluginSchemaArgs, - UpdateAuthority, - UpdateAuthorityArgs, + getBaseUpdateAuthoritySerializer, getHashablePluginSchemaSerializer, - getUpdateAuthoritySerializer, } from '.'; export type CompressionProof = { owner: PublicKey; - updateAuthority: UpdateAuthority; + updateAuthority: BaseUpdateAuthority; name: string; uri: string; seq: bigint; @@ -35,7 +35,7 @@ export type CompressionProof = { export type CompressionProofArgs = { owner: PublicKey; - updateAuthority: UpdateAuthorityArgs; + updateAuthority: BaseUpdateAuthorityArgs; name: string; uri: string; seq: number | bigint; @@ -49,7 +49,7 @@ export function getCompressionProofSerializer(): Serializer< return struct( [ ['owner', publicKeySerializer()], - ['updateAuthority', getUpdateAuthoritySerializer()], + ['updateAuthority', getBaseUpdateAuthoritySerializer()], ['name', string()], ['uri', string()], ['seq', u64()], diff --git a/clients/js/src/generated/types/dataStoreInitInfo.ts b/clients/js/src/generated/types/dataStoreInitInfo.ts deleted file mode 100644 index cbcba417..00000000 --- a/clients/js/src/generated/types/dataStoreInitInfo.ts +++ /dev/null @@ -1,48 +0,0 @@ -/** - * 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 { Option, OptionOrNullable } from '@metaplex-foundation/umi'; -import { - Serializer, - option, - struct, -} from '@metaplex-foundation/umi/serializers'; -import { - ExternalPluginSchema, - ExternalPluginSchemaArgs, - PluginAuthority, - PluginAuthorityArgs, - getExternalPluginSchemaSerializer, - getPluginAuthoritySerializer, -} from '.'; - -export type DataStoreInitInfo = { - dataAuthority: PluginAuthority; - initPluginAuthority: Option; - schema: Option; -}; - -export type DataStoreInitInfoArgs = { - dataAuthority: PluginAuthorityArgs; - initPluginAuthority: OptionOrNullable; - schema: OptionOrNullable; -}; - -export function getDataStoreInitInfoSerializer(): Serializer< - DataStoreInitInfoArgs, - DataStoreInitInfo -> { - return struct( - [ - ['dataAuthority', getPluginAuthoritySerializer()], - ['initPluginAuthority', option(getPluginAuthoritySerializer())], - ['schema', option(getExternalPluginSchemaSerializer())], - ], - { description: 'DataStoreInitInfo' } - ) as Serializer; -} diff --git a/clients/js/src/generated/types/externalPlugin.ts b/clients/js/src/generated/types/externalPlugin.ts index 1d572236..3170b201 100644 --- a/clients/js/src/generated/types/externalPlugin.ts +++ b/clients/js/src/generated/types/externalPlugin.ts @@ -15,26 +15,26 @@ import { tuple, } from '@metaplex-foundation/umi/serializers'; import { - DataStore, - DataStoreArgs, - LifecycleHook, - LifecycleHookArgs, - Oracle, - OracleArgs, - getDataStoreSerializer, - getLifecycleHookSerializer, - getOracleSerializer, + BaseDataStore, + BaseDataStoreArgs, + BaseLifecycleHook, + BaseLifecycleHookArgs, + BaseOracle, + BaseOracleArgs, + getBaseDataStoreSerializer, + getBaseLifecycleHookSerializer, + getBaseOracleSerializer, } from '.'; export type ExternalPlugin = - | { __kind: 'LifecycleHook'; fields: [LifecycleHook] } - | { __kind: 'Oracle'; fields: [Oracle] } - | { __kind: 'DataStore'; fields: [DataStore] }; + | { __kind: 'LifecycleHook'; fields: [BaseLifecycleHook] } + | { __kind: 'Oracle'; fields: [BaseOracle] } + | { __kind: 'DataStore'; fields: [BaseDataStore] }; export type ExternalPluginArgs = - | { __kind: 'LifecycleHook'; fields: [LifecycleHookArgs] } - | { __kind: 'Oracle'; fields: [OracleArgs] } - | { __kind: 'DataStore'; fields: [DataStoreArgs] }; + | { __kind: 'LifecycleHook'; fields: [BaseLifecycleHookArgs] } + | { __kind: 'Oracle'; fields: [BaseOracleArgs] } + | { __kind: 'DataStore'; fields: [BaseDataStoreArgs] }; export function getExternalPluginSerializer(): Serializer< ExternalPluginArgs, @@ -45,19 +45,19 @@ export function getExternalPluginSerializer(): Serializer< [ 'LifecycleHook', struct>([ - ['fields', tuple([getLifecycleHookSerializer()])], + ['fields', tuple([getBaseLifecycleHookSerializer()])], ]), ], [ 'Oracle', struct>([ - ['fields', tuple([getOracleSerializer()])], + ['fields', tuple([getBaseOracleSerializer()])], ]), ], [ 'DataStore', struct>([ - ['fields', tuple([getDataStoreSerializer()])], + ['fields', tuple([getBaseDataStoreSerializer()])], ]), ], ], diff --git a/clients/js/src/generated/types/externalPluginInitInfo.ts b/clients/js/src/generated/types/externalPluginInitInfo.ts deleted file mode 100644 index 194ccfee..00000000 --- a/clients/js/src/generated/types/externalPluginInitInfo.ts +++ /dev/null @@ -1,101 +0,0 @@ -/** - * 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 { - GetDataEnumKind, - GetDataEnumKindContent, - Serializer, - dataEnum, - struct, - tuple, -} from '@metaplex-foundation/umi/serializers'; -import { - DataStoreInitInfo, - DataStoreInitInfoArgs, - LifecycleHookInitInfo, - LifecycleHookInitInfoArgs, - OracleInitInfo, - OracleInitInfoArgs, - getDataStoreInitInfoSerializer, - getLifecycleHookInitInfoSerializer, - getOracleInitInfoSerializer, -} from '.'; - -export type ExternalPluginInitInfo = - | { __kind: 'LifecycleHook'; fields: [LifecycleHookInitInfo] } - | { __kind: 'Oracle'; fields: [OracleInitInfo] } - | { __kind: 'DataStore'; fields: [DataStoreInitInfo] }; - -export type ExternalPluginInitInfoArgs = - | { __kind: 'LifecycleHook'; fields: [LifecycleHookInitInfoArgs] } - | { __kind: 'Oracle'; fields: [OracleInitInfoArgs] } - | { __kind: 'DataStore'; fields: [DataStoreInitInfoArgs] }; - -export function getExternalPluginInitInfoSerializer(): Serializer< - ExternalPluginInitInfoArgs, - ExternalPluginInitInfo -> { - return dataEnum( - [ - [ - 'LifecycleHook', - struct>( - [['fields', tuple([getLifecycleHookInitInfoSerializer()])]] - ), - ], - [ - 'Oracle', - struct>([ - ['fields', tuple([getOracleInitInfoSerializer()])], - ]), - ], - [ - 'DataStore', - struct>([ - ['fields', tuple([getDataStoreInitInfoSerializer()])], - ]), - ], - ], - { description: 'ExternalPluginInitInfo' } - ) as Serializer; -} - -// Data Enum Helpers. -export function externalPluginInitInfo( - kind: 'LifecycleHook', - data: GetDataEnumKindContent< - ExternalPluginInitInfoArgs, - 'LifecycleHook' - >['fields'] -): GetDataEnumKind; -export function externalPluginInitInfo( - kind: 'Oracle', - data: GetDataEnumKindContent['fields'] -): GetDataEnumKind; -export function externalPluginInitInfo( - kind: 'DataStore', - data: GetDataEnumKindContent< - ExternalPluginInitInfoArgs, - 'DataStore' - >['fields'] -): GetDataEnumKind; -export function externalPluginInitInfo< - K extends ExternalPluginInitInfoArgs['__kind'], ->(kind: K, data?: any): Extract { - return Array.isArray(data) - ? { __kind: kind, fields: data } - : { __kind: kind, ...(data ?? {}) }; -} -export function isExternalPluginInitInfo< - K extends ExternalPluginInitInfo['__kind'], ->( - kind: K, - value: ExternalPluginInitInfo -): value is ExternalPluginInitInfo & { __kind: K } { - return value.__kind === kind; -} diff --git a/clients/js/src/generated/types/externalPluginKey.ts b/clients/js/src/generated/types/externalPluginKey.ts deleted file mode 100644 index 76ae45c1..00000000 --- a/clients/js/src/generated/types/externalPluginKey.ts +++ /dev/null @@ -1,90 +0,0 @@ -/** - * 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 { PublicKey } from '@metaplex-foundation/umi'; -import { - GetDataEnumKind, - GetDataEnumKindContent, - Serializer, - dataEnum, - publicKey as publicKeySerializer, - struct, - tuple, -} from '@metaplex-foundation/umi/serializers'; -import { - PluginAuthority, - PluginAuthorityArgs, - getPluginAuthoritySerializer, -} from '.'; - -export type ExternalPluginKey = - | { __kind: 'LifecycleHook'; fields: [PublicKey] } - | { __kind: 'Oracle'; fields: [PublicKey] } - | { __kind: 'DataStore'; fields: [PluginAuthority] }; - -export type ExternalPluginKeyArgs = - | { __kind: 'LifecycleHook'; fields: [PublicKey] } - | { __kind: 'Oracle'; fields: [PublicKey] } - | { __kind: 'DataStore'; fields: [PluginAuthorityArgs] }; - -export function getExternalPluginKeySerializer(): Serializer< - ExternalPluginKeyArgs, - ExternalPluginKey -> { - return dataEnum( - [ - [ - 'LifecycleHook', - struct>([ - ['fields', tuple([publicKeySerializer()])], - ]), - ], - [ - 'Oracle', - struct>([ - ['fields', tuple([publicKeySerializer()])], - ]), - ], - [ - 'DataStore', - struct>([ - ['fields', tuple([getPluginAuthoritySerializer()])], - ]), - ], - ], - { description: 'ExternalPluginKey' } - ) as Serializer; -} - -// Data Enum Helpers. -export function externalPluginKey( - kind: 'LifecycleHook', - data: GetDataEnumKindContent['fields'] -): GetDataEnumKind; -export function externalPluginKey( - kind: 'Oracle', - data: GetDataEnumKindContent['fields'] -): GetDataEnumKind; -export function externalPluginKey( - kind: 'DataStore', - data: GetDataEnumKindContent['fields'] -): GetDataEnumKind; -export function externalPluginKey( - kind: K, - data?: any -): Extract { - return Array.isArray(data) - ? { __kind: kind, fields: data } - : { __kind: kind, ...(data ?? {}) }; -} -export function isExternalPluginKey( - kind: K, - value: ExternalPluginKey -): value is ExternalPluginKey & { __kind: K } { - return value.__kind === kind; -} diff --git a/clients/js/src/generated/types/externalPluginUpdateInfo.ts b/clients/js/src/generated/types/externalPluginUpdateInfo.ts deleted file mode 100644 index 93848277..00000000 --- a/clients/js/src/generated/types/externalPluginUpdateInfo.ts +++ /dev/null @@ -1,101 +0,0 @@ -/** - * 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 { - GetDataEnumKind, - GetDataEnumKindContent, - Serializer, - dataEnum, - struct, - tuple, -} from '@metaplex-foundation/umi/serializers'; -import { - DataStoreUpdateInfo, - DataStoreUpdateInfoArgs, - LifecycleHookUpdateInfo, - LifecycleHookUpdateInfoArgs, - OracleUpdateInfo, - OracleUpdateInfoArgs, - getDataStoreUpdateInfoSerializer, - getLifecycleHookUpdateInfoSerializer, - getOracleUpdateInfoSerializer, -} from '.'; - -export type ExternalPluginUpdateInfo = - | { __kind: 'LifecycleHook'; fields: [LifecycleHookUpdateInfo] } - | { __kind: 'Oracle'; fields: [OracleUpdateInfo] } - | { __kind: 'DataStore'; fields: [DataStoreUpdateInfo] }; - -export type ExternalPluginUpdateInfoArgs = - | { __kind: 'LifecycleHook'; fields: [LifecycleHookUpdateInfoArgs] } - | { __kind: 'Oracle'; fields: [OracleUpdateInfoArgs] } - | { __kind: 'DataStore'; fields: [DataStoreUpdateInfoArgs] }; - -export function getExternalPluginUpdateInfoSerializer(): Serializer< - ExternalPluginUpdateInfoArgs, - ExternalPluginUpdateInfo -> { - return dataEnum( - [ - [ - 'LifecycleHook', - struct< - GetDataEnumKindContent - >([['fields', tuple([getLifecycleHookUpdateInfoSerializer()])]]), - ], - [ - 'Oracle', - struct>([ - ['fields', tuple([getOracleUpdateInfoSerializer()])], - ]), - ], - [ - 'DataStore', - struct>([ - ['fields', tuple([getDataStoreUpdateInfoSerializer()])], - ]), - ], - ], - { description: 'ExternalPluginUpdateInfo' } - ) as Serializer; -} - -// Data Enum Helpers. -export function externalPluginUpdateInfo( - kind: 'LifecycleHook', - data: GetDataEnumKindContent< - ExternalPluginUpdateInfoArgs, - 'LifecycleHook' - >['fields'] -): GetDataEnumKind; -export function externalPluginUpdateInfo( - kind: 'Oracle', - data: GetDataEnumKindContent['fields'] -): GetDataEnumKind; -export function externalPluginUpdateInfo( - kind: 'DataStore', - data: GetDataEnumKindContent< - ExternalPluginUpdateInfoArgs, - 'DataStore' - >['fields'] -): GetDataEnumKind; -export function externalPluginUpdateInfo< - K extends ExternalPluginUpdateInfoArgs['__kind'], ->(kind: K, data?: any): Extract { - return Array.isArray(data) - ? { __kind: kind, fields: data } - : { __kind: kind, ...(data ?? {}) }; -} -export function isExternalPluginUpdateInfo< - K extends ExternalPluginUpdateInfo['__kind'], ->( - kind: K, - value: ExternalPluginUpdateInfo -): value is ExternalPluginUpdateInfo & { __kind: K } { - return value.__kind === kind; -} diff --git a/clients/js/src/generated/types/externalRegistryRecord.ts b/clients/js/src/generated/types/externalRegistryRecord.ts index e9bc9dec..3d840f94 100644 --- a/clients/js/src/generated/types/externalRegistryRecord.ts +++ b/clients/js/src/generated/types/externalRegistryRecord.ts @@ -16,30 +16,30 @@ import { u64, } from '@metaplex-foundation/umi/serializers'; import { + BasePluginAuthority, + BasePluginAuthorityArgs, ExternalCheckResult, ExternalCheckResultArgs, ExternalPluginType, ExternalPluginTypeArgs, HookableLifecycleEvent, HookableLifecycleEventArgs, - PluginAuthority, - PluginAuthorityArgs, + getBasePluginAuthoritySerializer, getExternalCheckResultSerializer, getExternalPluginTypeSerializer, getHookableLifecycleEventSerializer, - getPluginAuthoritySerializer, } from '.'; export type ExternalRegistryRecord = { pluginType: ExternalPluginType; - authority: PluginAuthority; + authority: BasePluginAuthority; lifecycleChecks: Option>; offset: bigint; }; export type ExternalRegistryRecordArgs = { pluginType: ExternalPluginTypeArgs; - authority: PluginAuthorityArgs; + authority: BasePluginAuthorityArgs; lifecycleChecks: OptionOrNullable< Array<[HookableLifecycleEventArgs, ExternalCheckResultArgs]> >; @@ -53,7 +53,7 @@ export function getExternalRegistryRecordSerializer(): Serializer< return struct( [ ['pluginType', getExternalPluginTypeSerializer()], - ['authority', getPluginAuthoritySerializer()], + ['authority', getBasePluginAuthoritySerializer()], [ 'lifecycleChecks', option( diff --git a/clients/js/src/generated/types/externalValidationResult.ts b/clients/js/src/generated/types/externalValidationResult.ts new file mode 100644 index 00000000..f60f5189 --- /dev/null +++ b/clients/js/src/generated/types/externalValidationResult.ts @@ -0,0 +1,26 @@ +/** + * 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, scalarEnum } from '@metaplex-foundation/umi/serializers'; + +export enum ExternalValidationResult { + Approved, + Rejected, + Pass, +} + +export type ExternalValidationResultArgs = ExternalValidationResult; + +export function getExternalValidationResultSerializer(): Serializer< + ExternalValidationResultArgs, + ExternalValidationResult +> { + return scalarEnum(ExternalValidationResult, { + description: 'ExternalValidationResult', + }) as Serializer; +} diff --git a/clients/js/src/generated/types/hashablePluginSchema.ts b/clients/js/src/generated/types/hashablePluginSchema.ts index 858226e7..6aeb83d6 100644 --- a/clients/js/src/generated/types/hashablePluginSchema.ts +++ b/clients/js/src/generated/types/hashablePluginSchema.ts @@ -8,23 +8,23 @@ import { Serializer, struct, u64 } from '@metaplex-foundation/umi/serializers'; import { + BasePluginAuthority, + BasePluginAuthorityArgs, Plugin, PluginArgs, - PluginAuthority, - PluginAuthorityArgs, - getPluginAuthoritySerializer, + getBasePluginAuthoritySerializer, getPluginSerializer, } from '.'; export type HashablePluginSchema = { index: bigint; - authority: PluginAuthority; + authority: BasePluginAuthority; plugin: Plugin; }; export type HashablePluginSchemaArgs = { index: number | bigint; - authority: PluginAuthorityArgs; + authority: BasePluginAuthorityArgs; plugin: PluginArgs; }; @@ -35,7 +35,7 @@ export function getHashablePluginSchemaSerializer(): Serializer< return struct( [ ['index', u64()], - ['authority', getPluginAuthoritySerializer()], + ['authority', getBasePluginAuthoritySerializer()], ['plugin', getPluginSerializer()], ], { description: 'HashablePluginSchema' } diff --git a/clients/js/src/generated/types/index.ts b/clients/js/src/generated/types/index.ts index d9cbd336..c9917c5e 100644 --- a/clients/js/src/generated/types/index.ts +++ b/clients/js/src/generated/types/index.ts @@ -8,46 +8,49 @@ export * from './attribute'; export * from './attributes'; +export * from './baseDataStore'; +export * from './baseDataStoreInitInfo'; +export * from './baseDataStoreUpdateInfo'; +export * from './baseExternalPluginInitInfo'; +export * from './baseExternalPluginKey'; +export * from './baseExternalPluginUpdateInfo'; +export * from './baseExtraAccount'; +export * from './baseLifecycleHook'; +export * from './baseLifecycleHookInitInfo'; +export * from './baseLifecycleHookUpdateInfo'; +export * from './baseOracle'; +export * from './baseOracleInitInfo'; +export * from './baseOracleUpdateInfo'; +export * from './basePluginAuthority'; +export * from './baseRoyalties'; +export * from './baseRuleSet'; +export * from './baseSeed'; +export * from './baseUpdateAuthority'; +export * from './baseValidationResultsOffset'; export * from './burnDelegate'; export * from './compressionProof'; export * from './creator'; export * from './dataState'; -export * from './dataStore'; -export * from './dataStoreInitInfo'; -export * from './dataStoreUpdateInfo'; export * from './edition'; export * from './externalCheckResult'; export * from './externalPlugin'; -export * from './externalPluginInitInfo'; -export * from './externalPluginKey'; export * from './externalPluginSchema'; export * from './externalPluginType'; -export * from './externalPluginUpdateInfo'; export * from './externalRegistryRecord'; -export * from './extraAccount'; +export * from './externalValidationResult'; export * from './freezeDelegate'; export * from './hashablePluginSchema'; export * from './hashedAssetSchema'; export * from './hookableLifecycleEvent'; export * from './key'; -export * from './lifecycleHook'; -export * from './lifecycleHookInitInfo'; -export * from './lifecycleHookUpdateInfo'; -export * from './oracle'; -export * from './oracleInitInfo'; -export * from './oracleUpdateInfo'; +export * from './oracleValidation'; export * from './permanentBurnDelegate'; export * from './permanentFreezeDelegate'; export * from './permanentTransferDelegate'; export * from './plugin'; -export * from './pluginAuthority'; export * from './pluginAuthorityPair'; export * from './pluginType'; export * from './registryRecord'; -export * from './royalties'; -export * from './ruleSet'; -export * from './seed'; export * from './transferDelegate'; -export * from './updateAuthority'; export * from './updateDelegate'; export * from './validationResult'; diff --git a/clients/js/src/generated/types/oracle.ts b/clients/js/src/generated/types/oracle.ts deleted file mode 100644 index 5275a5e6..00000000 --- a/clients/js/src/generated/types/oracle.ts +++ /dev/null @@ -1,33 +0,0 @@ -/** - * 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 { Option, OptionOrNullable, PublicKey } from '@metaplex-foundation/umi'; -import { - Serializer, - option, - publicKey as publicKeySerializer, - struct, -} from '@metaplex-foundation/umi/serializers'; -import { ExtraAccount, ExtraAccountArgs, getExtraAccountSerializer } from '.'; - -export type Oracle = { baseAddress: PublicKey; pda: Option }; - -export type OracleArgs = { - baseAddress: PublicKey; - pda: OptionOrNullable; -}; - -export function getOracleSerializer(): Serializer { - return struct( - [ - ['baseAddress', publicKeySerializer()], - ['pda', option(getExtraAccountSerializer())], - ], - { description: 'Oracle' } - ) as Serializer; -} diff --git a/clients/js/src/generated/types/oracleValidation.ts b/clients/js/src/generated/types/oracleValidation.ts new file mode 100644 index 00000000..16984db5 --- /dev/null +++ b/clients/js/src/generated/types/oracleValidation.ts @@ -0,0 +1,76 @@ +/** + * 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 { + GetDataEnumKind, + GetDataEnumKindContent, + Serializer, + dataEnum, + struct, +} from '@metaplex-foundation/umi/serializers'; +import { + ExternalValidationResult, + ExternalValidationResultArgs, + getExternalValidationResultSerializer, +} from '.'; + +export type OracleValidation = { + __kind: 'V1'; + create: ExternalValidationResult; + transfer: ExternalValidationResult; + burn: ExternalValidationResult; + update: ExternalValidationResult; +}; + +export type OracleValidationArgs = { + __kind: 'V1'; + create: ExternalValidationResultArgs; + transfer: ExternalValidationResultArgs; + burn: ExternalValidationResultArgs; + update: ExternalValidationResultArgs; +}; + +export function getOracleValidationSerializer(): Serializer< + OracleValidationArgs, + OracleValidation +> { + return dataEnum( + [ + [ + 'V1', + struct>([ + ['create', getExternalValidationResultSerializer()], + ['transfer', getExternalValidationResultSerializer()], + ['burn', getExternalValidationResultSerializer()], + ['update', getExternalValidationResultSerializer()], + ]), + ], + ], + { description: 'OracleValidation' } + ) as Serializer; +} + +// Data Enum Helpers. +export function oracleValidation( + kind: 'V1', + data: GetDataEnumKindContent +): GetDataEnumKind; +export function oracleValidation( + kind: K, + data?: any +): Extract { + return Array.isArray(data) + ? { __kind: kind, fields: data } + : { __kind: kind, ...(data ?? {}) }; +} +export function isOracleValidation( + kind: K, + value: OracleValidation +): value is OracleValidation & { __kind: K } { + return value.__kind === kind; +} diff --git a/clients/js/src/generated/types/plugin.ts b/clients/js/src/generated/types/plugin.ts index 26466b13..1b2292e8 100644 --- a/clients/js/src/generated/types/plugin.ts +++ b/clients/js/src/generated/types/plugin.ts @@ -17,6 +17,8 @@ import { import { Attributes, AttributesArgs, + BaseRoyalties, + BaseRoyaltiesArgs, BurnDelegate, BurnDelegateArgs, Edition, @@ -29,26 +31,24 @@ import { PermanentFreezeDelegateArgs, PermanentTransferDelegate, PermanentTransferDelegateArgs, - Royalties, - RoyaltiesArgs, TransferDelegate, TransferDelegateArgs, UpdateDelegate, UpdateDelegateArgs, getAttributesSerializer, + getBaseRoyaltiesSerializer, getBurnDelegateSerializer, getEditionSerializer, getFreezeDelegateSerializer, getPermanentBurnDelegateSerializer, getPermanentFreezeDelegateSerializer, getPermanentTransferDelegateSerializer, - getRoyaltiesSerializer, getTransferDelegateSerializer, getUpdateDelegateSerializer, } from '.'; export type Plugin = - | { __kind: 'Royalties'; fields: [Royalties] } + | { __kind: 'Royalties'; fields: [BaseRoyalties] } | { __kind: 'FreezeDelegate'; fields: [FreezeDelegate] } | { __kind: 'BurnDelegate'; fields: [BurnDelegate] } | { __kind: 'TransferDelegate'; fields: [TransferDelegate] } @@ -60,7 +60,7 @@ export type Plugin = | { __kind: 'Edition'; fields: [Edition] }; export type PluginArgs = - | { __kind: 'Royalties'; fields: [RoyaltiesArgs] } + | { __kind: 'Royalties'; fields: [BaseRoyaltiesArgs] } | { __kind: 'FreezeDelegate'; fields: [FreezeDelegateArgs] } | { __kind: 'BurnDelegate'; fields: [BurnDelegateArgs] } | { __kind: 'TransferDelegate'; fields: [TransferDelegateArgs] } @@ -80,7 +80,7 @@ export function getPluginSerializer(): Serializer { [ 'Royalties', struct>([ - ['fields', tuple([getRoyaltiesSerializer()])], + ['fields', tuple([getBaseRoyaltiesSerializer()])], ]), ], [ diff --git a/clients/js/src/generated/types/pluginAuthority.ts b/clients/js/src/generated/types/pluginAuthority.ts deleted file mode 100644 index 5f636870..00000000 --- a/clients/js/src/generated/types/pluginAuthority.ts +++ /dev/null @@ -1,75 +0,0 @@ -/** - * 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 { PublicKey } from '@metaplex-foundation/umi'; -import { - GetDataEnumKind, - GetDataEnumKindContent, - Serializer, - dataEnum, - publicKey as publicKeySerializer, - struct, - unit, -} from '@metaplex-foundation/umi/serializers'; - -export type PluginAuthority = - | { __kind: 'None' } - | { __kind: 'Owner' } - | { __kind: 'UpdateAuthority' } - | { __kind: 'Address'; address: PublicKey }; - -export type PluginAuthorityArgs = PluginAuthority; - -export function getPluginAuthoritySerializer(): Serializer< - PluginAuthorityArgs, - PluginAuthority -> { - return dataEnum( - [ - ['None', unit()], - ['Owner', unit()], - ['UpdateAuthority', unit()], - [ - 'Address', - struct>([ - ['address', publicKeySerializer()], - ]), - ], - ], - { description: 'PluginAuthority' } - ) as Serializer; -} - -// Data Enum Helpers. -export function pluginAuthority( - kind: 'None' -): GetDataEnumKind; -export function pluginAuthority( - kind: 'Owner' -): GetDataEnumKind; -export function pluginAuthority( - kind: 'UpdateAuthority' -): GetDataEnumKind; -export function pluginAuthority( - kind: 'Address', - data: GetDataEnumKindContent -): GetDataEnumKind; -export function pluginAuthority( - kind: K, - data?: any -): Extract { - return Array.isArray(data) - ? { __kind: kind, fields: data } - : { __kind: kind, ...(data ?? {}) }; -} -export function isPluginAuthority( - kind: K, - value: PluginAuthority -): value is PluginAuthority & { __kind: K } { - return value.__kind === kind; -} diff --git a/clients/js/src/generated/types/pluginAuthorityPair.ts b/clients/js/src/generated/types/pluginAuthorityPair.ts index 27558f36..b7deb46e 100644 --- a/clients/js/src/generated/types/pluginAuthorityPair.ts +++ b/clients/js/src/generated/types/pluginAuthorityPair.ts @@ -13,22 +13,22 @@ import { struct, } from '@metaplex-foundation/umi/serializers'; import { + BasePluginAuthority, + BasePluginAuthorityArgs, Plugin, PluginArgs, - PluginAuthority, - PluginAuthorityArgs, - getPluginAuthoritySerializer, + getBasePluginAuthoritySerializer, getPluginSerializer, } from '.'; export type PluginAuthorityPair = { plugin: Plugin; - authority: Option; + authority: Option; }; export type PluginAuthorityPairArgs = { plugin: PluginArgs; - authority: OptionOrNullable; + authority: OptionOrNullable; }; export function getPluginAuthorityPairSerializer(): Serializer< @@ -38,7 +38,7 @@ export function getPluginAuthorityPairSerializer(): Serializer< return struct( [ ['plugin', getPluginSerializer()], - ['authority', option(getPluginAuthoritySerializer())], + ['authority', option(getBasePluginAuthoritySerializer())], ], { description: 'PluginAuthorityPair' } ) as Serializer; diff --git a/clients/js/src/generated/types/registryRecord.ts b/clients/js/src/generated/types/registryRecord.ts index 77247d84..56581ec9 100644 --- a/clients/js/src/generated/types/registryRecord.ts +++ b/clients/js/src/generated/types/registryRecord.ts @@ -8,23 +8,23 @@ import { Serializer, struct, u64 } from '@metaplex-foundation/umi/serializers'; import { - PluginAuthority, - PluginAuthorityArgs, + BasePluginAuthority, + BasePluginAuthorityArgs, PluginType, PluginTypeArgs, - getPluginAuthoritySerializer, + getBasePluginAuthoritySerializer, getPluginTypeSerializer, } from '.'; export type RegistryRecord = { pluginType: PluginType; - authority: PluginAuthority; + authority: BasePluginAuthority; offset: bigint; }; export type RegistryRecordArgs = { pluginType: PluginTypeArgs; - authority: PluginAuthorityArgs; + authority: BasePluginAuthorityArgs; offset: number | bigint; }; @@ -35,7 +35,7 @@ export function getRegistryRecordSerializer(): Serializer< return struct( [ ['pluginType', getPluginTypeSerializer()], - ['authority', getPluginAuthoritySerializer()], + ['authority', getBasePluginAuthoritySerializer()], ['offset', u64()], ], { description: 'RegistryRecord' } diff --git a/clients/js/src/generated/types/updateAuthority.ts b/clients/js/src/generated/types/updateAuthority.ts deleted file mode 100644 index 38d010cd..00000000 --- a/clients/js/src/generated/types/updateAuthority.ts +++ /dev/null @@ -1,77 +0,0 @@ -/** - * 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 { PublicKey } from '@metaplex-foundation/umi'; -import { - GetDataEnumKind, - GetDataEnumKindContent, - Serializer, - dataEnum, - publicKey as publicKeySerializer, - struct, - tuple, - unit, -} from '@metaplex-foundation/umi/serializers'; - -export type UpdateAuthority = - | { __kind: 'None' } - | { __kind: 'Address'; fields: [PublicKey] } - | { __kind: 'Collection'; fields: [PublicKey] }; - -export type UpdateAuthorityArgs = UpdateAuthority; - -export function getUpdateAuthoritySerializer(): Serializer< - UpdateAuthorityArgs, - UpdateAuthority -> { - return dataEnum( - [ - ['None', unit()], - [ - 'Address', - struct>([ - ['fields', tuple([publicKeySerializer()])], - ]), - ], - [ - 'Collection', - struct>([ - ['fields', tuple([publicKeySerializer()])], - ]), - ], - ], - { description: 'UpdateAuthority' } - ) as Serializer; -} - -// Data Enum Helpers. -export function updateAuthority( - kind: 'None' -): GetDataEnumKind; -export function updateAuthority( - kind: 'Address', - data: GetDataEnumKindContent['fields'] -): GetDataEnumKind; -export function updateAuthority( - kind: 'Collection', - data: GetDataEnumKindContent['fields'] -): GetDataEnumKind; -export function updateAuthority( - kind: K, - data?: any -): Extract { - return Array.isArray(data) - ? { __kind: kind, fields: data } - : { __kind: kind, ...(data ?? {}) }; -} -export function isUpdateAuthority( - kind: K, - value: UpdateAuthority -): value is UpdateAuthority & { __kind: K } { - return value.__kind === kind; -} diff --git a/clients/js/src/helpers/authority.ts b/clients/js/src/helpers/authority.ts index 60f6c37f..2cd10c22 100644 --- a/clients/js/src/helpers/authority.ts +++ b/clients/js/src/helpers/authority.ts @@ -1,17 +1,17 @@ import { PublicKey, publicKey } from '@metaplex-foundation/umi'; import { AssetV1, CollectionV1 } from '../generated'; -import { BasePluginAuthority } from '../types'; import { deriveAssetPlugins, isAssetOwner } from './state'; +import { PluginAuthority } from '../plugins'; /** * Check if the given pubkey has the Address authority for the plugin. * @param {PublicKey | string} pubkey Pubkey - * @param {BasePluginAuthority} authority Plugin authority + * @param {PluginAuthority} authority Plugin authority * @returns {boolean} True if the pubkey has the authority */ export function hasPluginAddressAuthority( pubkey: PublicKey | string, - authority: BasePluginAuthority + authority: PluginAuthority ): boolean { return ( authority.type === 'Address' && authority.address === publicKey(pubkey) @@ -20,13 +20,13 @@ export function hasPluginAddressAuthority( /** * Check if the given pubkey has the Owner authority for the plugin. * @param {PublicKey | string} pubkey Pubkey - * @param {BasePluginAuthority} authority Plugin authority + * @param {PluginAuthority} authority Plugin authority * @param {AssetV1} asset Asset * @returns {boolean} True if the pubkey has the authority */ export function hasPluginOwnerAuthority( pubkey: PublicKey | string, - authority: BasePluginAuthority, + authority: PluginAuthority, asset: AssetV1 ): boolean { return authority.type === 'Owner' && isAssetOwner(pubkey, asset); @@ -34,14 +34,14 @@ export function hasPluginOwnerAuthority( /** * Check if the given pubkey has the UpdateAuthority authority for the plugin. * @param {PublicKey | string} pubkey Pubkey - * @param {BasePluginAuthority} authority Plugin authority + * @param {PluginAuthority} authority Plugin authority * @param {AssetV1} asset Asset * @param {CollectionV1 | undefined} collection Collection * @returns {boolean} True if the pubkey has the authority */ export function hasPluginUpdateAuthority( pubkey: PublicKey | string, - authority: BasePluginAuthority, + authority: PluginAuthority, asset: AssetV1, collection?: CollectionV1 ): boolean { diff --git a/clients/js/src/helpers/plugin.ts b/clients/js/src/helpers/plugin.ts index 979aacc4..f66c087a 100644 --- a/clients/js/src/helpers/plugin.ts +++ b/clients/js/src/helpers/plugin.ts @@ -1,5 +1,4 @@ import { PublicKey, publicKey } from '@metaplex-foundation/umi'; -import { PluginsList } from '../types'; import { capitalizeFirstLetter, lowercaseFirstLetter } from '../utils'; import { AssetV1, CollectionV1, PluginType } from '../generated'; import { collectionAddress, deriveAssetPlugins, isAssetOwner } from './state'; @@ -7,6 +6,7 @@ import { hasAssetUpdateAuthority, hasPluginAddressAuthority, } from './authority'; +import { PluginsList } from '../plugins'; export type AssetPluginKey = keyof PluginsList; diff --git a/clients/js/src/helpers/state.ts b/clients/js/src/helpers/state.ts index 27b628b7..926f3c4c 100644 --- a/clients/js/src/helpers/state.ts +++ b/clients/js/src/helpers/state.ts @@ -1,5 +1,12 @@ import { PublicKey, publicKey } from '@metaplex-foundation/umi'; import { AssetV1, CollectionV1 } from '../generated'; +import { ExternalPluginsList } from '../plugins'; +import { OracleInitInfoArgs, OraclePlugin } from '../plugins/oracle'; +import { DataStoreInitInfoArgs, DataStorePlugin } from '../plugins/dataStore'; +import { + LifecycleHookInitInfoArgs, + LifecycleHookPlugin, +} from '../plugins/lifecycleHook'; /** * Find the collection address for the given asset if it is part of a collection. @@ -14,6 +21,64 @@ export function collectionAddress(asset: AssetV1): PublicKey | undefined { return undefined; } +const externalPluginKeys: (keyof ExternalPluginsList)[] = [ + 'oracles', + 'dataStores', + 'lifecycleHooks', +]; +export const getExternalPluginKeyAsString = ( + plugin: + | OraclePlugin + | DataStorePlugin + | LifecycleHookPlugin + | OracleInitInfoArgs + | LifecycleHookInitInfoArgs + | DataStoreInitInfoArgs +) => { + switch (plugin.type) { + case 'Oracle': + return `${plugin.type}-${plugin.baseAddress}`; + case 'DataStore': + return `${plugin.type}-${plugin.dataAuthority.type}${ + plugin.dataAuthority.address ? `-${plugin.dataAuthority.address}` : '' + }`; + case 'LifecycleHook': + default: + return `${plugin.type}-${plugin.hookedProgram}`; + } +}; + +export const deriveExternalPlugins = ( + asset: ExternalPluginsList, + collection?: ExternalPluginsList +) => { + if (!collection) { + return asset; + } + const externalPlugins: ExternalPluginsList = {}; + externalPluginKeys.forEach((key) => { + const set = new Set(); + if (asset[key] || collection[key]) { + externalPlugins[key] = []; + } + asset[key]?.forEach( + (plugin: OraclePlugin | DataStorePlugin | LifecycleHookPlugin) => { + set.add(getExternalPluginKeyAsString(plugin)); + externalPlugins[key]?.push(plugin as any); + } + ); + + collection[key]?.forEach( + (plugin: OraclePlugin | DataStorePlugin | LifecycleHookPlugin) => { + if (!set.has(getExternalPluginKeyAsString(plugin))) { + externalPlugins[key]?.push(plugin as any); + } + } + ); + }); + + return externalPlugins; +}; /** * Derive the asset plugins from the asset and collection. Plugins on the asset take precedence over plugins on the collection. * @param {AssetV1} asset Asset @@ -27,10 +92,12 @@ export function deriveAssetPlugins( if (!collection) { return asset; } + const externalPlugins = deriveExternalPlugins(asset, collection); return { ...collection, ...asset, + ...externalPlugins, }; } diff --git a/clients/js/src/hooked/assetAccountData.ts b/clients/js/src/hooked/assetAccountData.ts index 24631e57..d3c9e267 100644 --- a/clients/js/src/hooked/assetAccountData.ts +++ b/clients/js/src/hooked/assetAccountData.ts @@ -11,20 +11,29 @@ import { AssetV1AccountDataArgs as GenAssetV1AccountDataArgs, getAssetV1AccountDataSerializer as genGetAssetV1AccountDataSerializer, } from '../generated/types/assetV1AccountData'; -import { BaseUpdateAuthority, PluginsList } from '../types'; -import { registryRecordsToPluginsList } from '../plugins'; + +import { + PluginsList, + registryRecordsToPluginsList, + UpdateAuthority, +} from '../plugins'; import { PluginRegistryV1AccountData, getPluginRegistryV1AccountDataSerializer, } from './pluginRegistryV1Data'; +import { + ExternalPluginsList, + externalRegistryRecordsToExternalPluginList, +} from '../plugins/externalPlugins'; export type AssetV1AccountData = Omit< GenAssetV1AccountData, 'updateAuthority' > & - PluginsList & { + PluginsList & + ExternalPluginsList & { pluginHeader?: Omit; - updateAuthority: BaseUpdateAuthority; + updateAuthority: UpdateAuthority; }; export type AssetV1AccountDataArgs = Omit< @@ -33,7 +42,7 @@ export type AssetV1AccountDataArgs = Omit< > & PluginsList & { pluginHeader?: Omit; - updateAuthority: BaseUpdateAuthority; + updateAuthority: UpdateAuthority; }; export const getAssetV1AccountDataSerializer = (): Serializer< @@ -60,6 +69,7 @@ export const getAssetV1AccountDataSerializer = (): Serializer< let pluginHeader: PluginHeaderV1AccountData | undefined; let pluginRegistry: PluginRegistryV1AccountData | undefined; let pluginsList: PluginsList | undefined; + let externalPluginsList: ExternalPluginsList | undefined; let finalOffset = assetOffset; if (buffer.length !== assetOffset) { @@ -78,6 +88,11 @@ export const getAssetV1AccountDataSerializer = (): Serializer< pluginRegistry.registry, buffer ); + + externalPluginsList = externalRegistryRecordsToExternalPluginList( + pluginRegistry.externalRegistry, + buffer + ); } const updateAuth = { type: asset.updateAuthority.__kind, @@ -91,6 +106,7 @@ export const getAssetV1AccountDataSerializer = (): Serializer< { pluginHeader, ...pluginsList, + ...externalPluginsList, ...asset, updateAuthority: updateAuth, }, diff --git a/clients/js/src/hooked/collectionAccountData.ts b/clients/js/src/hooked/collectionAccountData.ts index bb3bfb4d..d36e81cc 100644 --- a/clients/js/src/hooked/collectionAccountData.ts +++ b/clients/js/src/hooked/collectionAccountData.ts @@ -11,15 +11,20 @@ import { CollectionV1AccountDataArgs as GenCollectionV1AccountDataArgs, getCollectionV1AccountDataSerializer as genGetCollectionV1AccountDataSerializer, } from '../generated/types/collectionV1AccountData'; -import { PluginsList } from '../types'; -import { registryRecordsToPluginsList } from '../plugins'; +import { + ExternalPluginsList, + externalRegistryRecordsToExternalPluginList, + PluginsList, + registryRecordsToPluginsList, +} from '../plugins'; import { PluginRegistryV1AccountData, getPluginRegistryV1AccountDataSerializer, } from './pluginRegistryV1Data'; export type CollectionV1AccountData = GenCollectionV1AccountData & - PluginsList & { + PluginsList & + ExternalPluginsList & { pluginHeader?: Omit; }; @@ -57,6 +62,7 @@ export const getCollectionV1AccountDataSerializer = (): Serializer< let pluginHeader: PluginHeaderV1AccountData | undefined; let pluginRegistry: PluginRegistryV1AccountData | undefined; let pluginsList: PluginsList | undefined; + let externalPluginsList: ExternalPluginsList | undefined; let finalOffset = collectionOffset; if (buffer.length !== collectionOffset) { @@ -75,12 +81,18 @@ export const getCollectionV1AccountDataSerializer = (): Serializer< pluginRegistry.registry, buffer ); + + externalPluginsList = externalRegistryRecordsToExternalPluginList( + pluginRegistry.externalRegistry, + buffer + ); } return [ { pluginHeader, ...pluginsList, + ...externalPluginsList, ...collection, }, finalOffset, diff --git a/clients/js/src/hooked/pluginRegistryV1Data.ts b/clients/js/src/hooked/pluginRegistryV1Data.ts index d90a1310..f31ba2f8 100644 --- a/clients/js/src/hooked/pluginRegistryV1Data.ts +++ b/clients/js/src/hooked/pluginRegistryV1Data.ts @@ -1,12 +1,24 @@ -import { Serializer, array, u64 } from '@metaplex-foundation/umi/serializers'; +import { + Serializer, + array, + option, + tuple, + u64, +} from '@metaplex-foundation/umi/serializers'; import { Key, PluginType, RegistryRecord, RegistryRecordArgs, getKeySerializer, - getPluginAuthoritySerializer, + getBasePluginAuthoritySerializer, getPluginTypeSerializer, + ExternalRegistryRecordArgs, + ExternalRegistryRecord, + getExternalPluginTypeSerializer, + ExternalPluginType, + getHookableLifecycleEventSerializer, + getExternalCheckResultSerializer, } from '../generated'; import { PluginRegistryV1AccountData, @@ -19,6 +31,10 @@ export type RegistryRecordWithUnknown = RegistryRecord & { isUnknown?: boolean; }; +export type ExternalRegistryRecordWithUnknown = ExternalRegistryRecord & { + isUnknown?: boolean; +}; + export function getRegistryRecordSerializer(): Serializer< RegistryRecordArgs, RegistryRecordWithUnknown @@ -49,7 +65,10 @@ export function getRegistryRecordSerializer(): Serializer< // Do nothing, unknown plugin type } const [authority, authorityOffset] = - getPluginAuthoritySerializer().deserialize(buffer, pluginTypeOffset); + getBasePluginAuthoritySerializer().deserialize( + buffer, + pluginTypeOffset + ); const [pluginOffset, pluginOffsetOffset] = u64().deserialize( buffer, authorityOffset @@ -68,6 +87,66 @@ export function getRegistryRecordSerializer(): Serializer< }; } +export function getExternalRegistryRecordSerializer(): Serializer< + ExternalRegistryRecordArgs, + ExternalRegistryRecordWithUnknown +> { + return { + description: 'ExternalRegistryRecordWithUnknown', + fixedSize: null, + maxSize: null, + serialize: () => { + throw new Error('Operation not supported.'); + }, + deserialize: ( + buffer: Uint8Array, + offset = 0 + ): [ExternalRegistryRecordWithUnknown, number] => { + let [pluginType, pluginTypeOffset, isUnknown] = [ + ExternalPluginType.DataStore, + offset + 1, + true, + ]; + try { + [pluginType, pluginTypeOffset] = + getExternalPluginTypeSerializer().deserialize(buffer, offset); + isUnknown = false; + } catch (e) { + // do nothing + } + + const [authority, authorityOffset] = + getBasePluginAuthoritySerializer().deserialize( + buffer, + pluginTypeOffset + ); + const [lifecycleChecks, lifecycleChecksOffset] = option( + array( + tuple([ + getHookableLifecycleEventSerializer(), + getExternalCheckResultSerializer(), + ]) + ) + ).deserialize(buffer, authorityOffset); + + const [pluginOffset, pluginOffsetOffset] = u64().deserialize( + buffer, + lifecycleChecksOffset + ); + return [ + { + pluginType, + authority, + lifecycleChecks, + offset: pluginOffset, + isUnknown, + }, + pluginOffsetOffset, + ]; + }, + }; +} + export function getPluginRegistryV1AccountDataSerializer(): Serializer< PluginRegistryV1AccountDataArgs, PluginRegistryV1AccountData @@ -92,7 +171,9 @@ export function getPluginRegistryV1AccountDataSerializer(): Serializer< getRegistryRecordSerializer() ).deserialize(buffer, keyOffset); - // TODO deserialize externalRegistry of plugins once they are defined, purposefully ignore them now + const [externalRegistry, externalRegistryOffset] = array( + getExternalRegistryRecordSerializer() + ).deserialize(buffer, registryOffset); return [ { @@ -100,9 +181,11 @@ export function getPluginRegistryV1AccountDataSerializer(): Serializer< registry: registry.filter( (record: RegistryRecordWithUnknown) => !record.isUnknown ), - externalRegistry: [], + externalRegistry: externalRegistry.filter( + (record: ExternalRegistryRecordWithUnknown) => !record.isUnknown + ), }, - registryOffset, + externalRegistryOffset, ]; }, }; diff --git a/clients/js/src/index.ts b/clients/js/src/index.ts index 9dcf9a52..3b144dfb 100644 --- a/clients/js/src/index.ts +++ b/clients/js/src/index.ts @@ -1,7 +1,6 @@ export * from './generated'; export * from './plugin'; export * from './hash'; -export * from './types'; export * from './authority'; export * from './plugins'; export * from './helpers'; diff --git a/clients/js/src/instructions/addPlugin.ts b/clients/js/src/instructions/addPlugin.ts new file mode 100644 index 00000000..f07062be --- /dev/null +++ b/clients/js/src/instructions/addPlugin.ts @@ -0,0 +1,39 @@ +import { Context } from '@metaplex-foundation/umi'; +import { addPluginV1, addExternalPluginV1 } from '../generated'; +import { + AddablePluginAuthorityPairArgsV2, + ExternalPluginInitInfoArgs, + createExternalPluginInitInfo, + isExternalPluginType, + pluginAuthorityPairV2, +} from '../plugins'; + +export type AddPluginArgs = Omit< + Parameters[1], + 'plugin' +> & { + plugin: AddablePluginAuthorityPairArgsV2 | ExternalPluginInitInfoArgs; +}; + +export const addPlugin = ( + context: Pick, + { plugin, ...args }: AddPluginArgs +) => { + if (isExternalPluginType(plugin)) { + return addExternalPluginV1(context, { + ...args, + initInfo: createExternalPluginInitInfo( + plugin as ExternalPluginInitInfoArgs + ), + }); + } + + const pair = pluginAuthorityPairV2( + plugin as AddablePluginAuthorityPairArgsV2 + ); + return addPluginV1(context, { + ...args, + plugin: pair.plugin, + initAuthority: pair.authority, + }); +}; diff --git a/clients/js/src/instructions/approvePluginAuthority.ts b/clients/js/src/instructions/approvePluginAuthority.ts new file mode 100644 index 00000000..15bec496 --- /dev/null +++ b/clients/js/src/instructions/approvePluginAuthority.ts @@ -0,0 +1,39 @@ +import { Context } from '@metaplex-foundation/umi'; +import { approvePluginAuthorityV1, PluginType } from '../generated'; +import { + isExternalPluginType, + PluginAuthority, + pluginAuthorityToBase, +} from '../plugins'; +import { ExternalPluginKey } from '../plugins/externalPluginKey'; + +export type ApprovePluginAuthorityArgs = Omit< + Parameters[1], + 'pluginType' | 'newAuthority' +> & { + plugin: + | { + type: keyof typeof PluginType; + } + | ExternalPluginKey; + newAuthority: PluginAuthority; +}; + +export const approvePluginAuthority = ( + context: Pick, + { plugin, newAuthority, ...args }: ApprovePluginAuthorityArgs +) => { + if (isExternalPluginType(plugin)) { + // TODO implement this + // return approveExternalPluginAuthorityV1(context, { + // ...args, + // key: externalPluginKeyToBase(plugin as ExternalPluginKey), + // }); + } + + return approvePluginAuthorityV1(context, { + ...args, + pluginType: PluginType[plugin.type as keyof typeof PluginType], + newAuthority: pluginAuthorityToBase(newAuthority), + }); +}; diff --git a/clients/js/src/instructions/burn.ts b/clients/js/src/instructions/burn.ts new file mode 100644 index 00000000..a551928f --- /dev/null +++ b/clients/js/src/instructions/burn.ts @@ -0,0 +1,36 @@ +import { Context } from '@metaplex-foundation/umi'; +import { CollectionV1, burnV1, AssetV1 } from '../generated'; +import { findExtraAccounts } from '../plugins'; +import { deriveExternalPlugins } from '../helpers'; + +export type BurnArgs = Omit< + Parameters[1], + 'asset' | 'collection' +> & { + asset: AssetV1; + collection?: CollectionV1; +}; + +export const burn = ( + context: Pick, + { asset, collection, ...args }: BurnArgs +) => { + const derivedExternalPlugins = deriveExternalPlugins(asset, collection); + + const extraAccounts = findExtraAccounts( + context, + 'burn', + derivedExternalPlugins, + { + asset: asset.publicKey, + collection: collection?.publicKey, + owner: asset.owner, + } + ); + + return burnV1(context, { + ...args, + asset: asset.publicKey, + collection: collection?.publicKey, + }).addRemainingAccounts(extraAccounts); +}; diff --git a/clients/js/src/instructions/collection/addCollectionPlugin.ts b/clients/js/src/instructions/collection/addCollectionPlugin.ts new file mode 100644 index 00000000..ee5cb6e5 --- /dev/null +++ b/clients/js/src/instructions/collection/addCollectionPlugin.ts @@ -0,0 +1,42 @@ +import { Context } from '@metaplex-foundation/umi'; +import { + addCollectionExternalPluginV1, + addCollectionPluginV1, +} from '../../generated'; +import { AddablePluginArgsV2, pluginAuthorityPairV2 } from '../../plugins'; + +import { + createExternalPluginInitInfo, + ExternalPluginInitInfoArgs, + isExternalPluginType, +} from '../../plugins/externalPlugins'; + +export type AddCollectionPluginArgs = Omit< + Parameters[1], + 'plugin' +> & { + plugin: + | Exclude + | ExternalPluginInitInfoArgs; +}; + +export const addCollectionPlugin = ( + context: Pick, + { plugin, ...args }: AddCollectionPluginArgs +) => { + if (isExternalPluginType(plugin)) { + return addCollectionExternalPluginV1(context, { + ...args, + initInfo: createExternalPluginInitInfo( + plugin as ExternalPluginInitInfoArgs + ), + }); + } + + const pair = pluginAuthorityPairV2(plugin as AddablePluginArgsV2); + return addCollectionPluginV1(context, { + ...args, + plugin: pair.plugin, + initAuthority: pair.authority, + }); +}; diff --git a/clients/js/src/instructions/collection/approveCollectionPluginAuthority.ts b/clients/js/src/instructions/collection/approveCollectionPluginAuthority.ts new file mode 100644 index 00000000..01d47bf8 --- /dev/null +++ b/clients/js/src/instructions/collection/approveCollectionPluginAuthority.ts @@ -0,0 +1,42 @@ +import { Context } from '@metaplex-foundation/umi'; +import { + approveCollectionPluginAuthorityV1, + PluginType, +} from '../../generated'; +import { + isExternalPluginType, + PluginAuthority, + pluginAuthorityToBase, +} from '../../plugins'; +import { ExternalPluginKey } from '../../plugins/externalPluginKey'; + +export type ApproveCollectionPluginAuthorityArgs = Omit< + Parameters[1], + 'pluginType' | 'newAuthority' +> & { + plugin: + | { + type: keyof typeof PluginType; + } + | ExternalPluginKey; + newAuthority: PluginAuthority; +}; + +export const approveCollectionPluginAuthority = ( + context: Pick, + { plugin, newAuthority, ...args }: ApproveCollectionPluginAuthorityArgs +) => { + if (isExternalPluginType(plugin)) { + // TODO implement this + // return approveCollectionExternalPluginAuthorityV1(context, { + // ...args, + // key: externalPluginKeyToBase(plugin as ExternalPluginKey), + // }); + } + + return approveCollectionPluginAuthorityV1(context, { + ...args, + pluginType: PluginType[plugin.type as keyof typeof PluginType], + newAuthority: pluginAuthorityToBase(newAuthority), + }); +}; diff --git a/clients/js/src/instructions/collection/burnCollection.ts b/clients/js/src/instructions/collection/burnCollection.ts new file mode 100644 index 00000000..0d8a403d --- /dev/null +++ b/clients/js/src/instructions/collection/burnCollection.ts @@ -0,0 +1,3 @@ +import { burnCollectionV1 as burnCollection } from '../../generated'; + +export { burnCollection }; diff --git a/clients/js/src/instructions/collection/createCollection.ts b/clients/js/src/instructions/collection/createCollection.ts new file mode 100644 index 00000000..6528f190 --- /dev/null +++ b/clients/js/src/instructions/collection/createCollection.ts @@ -0,0 +1,41 @@ +import { Context } from '@metaplex-foundation/umi'; +import { createCollectionV2 } from '../../generated'; +import { + PluginAuthorityPairArgsV2, + createExternalPluginInitInfo, + pluginAuthorityPairV2, +} from '../../plugins'; + +import { + ExternalPluginInitInfoArgs, + isExternalPluginType, +} from '../../plugins/externalPlugins'; + +export type CreateCollectionArgs = Omit< + Parameters[1], + 'plugins' | 'externalPlugins' +> & { + plugins?: (PluginAuthorityPairArgsV2 | ExternalPluginInitInfoArgs)[]; +}; + +export const createCollection = ( + context: Pick, + { plugins, ...args }: CreateCollectionArgs +) => { + const firstPartyPlugins: PluginAuthorityPairArgsV2[] = []; + const externalPlugins: ExternalPluginInitInfoArgs[] = []; + + plugins?.forEach((plugin) => { + if (isExternalPluginType(plugin)) { + externalPlugins.push(plugin as ExternalPluginInitInfoArgs); + } else { + firstPartyPlugins.push(plugin as PluginAuthorityPairArgsV2); + } + }); + + return createCollectionV2(context, { + ...args, + plugins: firstPartyPlugins.map(pluginAuthorityPairV2), + externalPlugins: externalPlugins.map(createExternalPluginInitInfo), + }); +}; diff --git a/clients/js/src/instructions/collection/index.ts b/clients/js/src/instructions/collection/index.ts new file mode 100644 index 00000000..fbca7eba --- /dev/null +++ b/clients/js/src/instructions/collection/index.ts @@ -0,0 +1,8 @@ +export * from './addCollectionPlugin'; +export * from './approveCollectionPluginAuthority'; +export * from './burnCollection'; +export * from './createCollection'; +export * from './removeCollectionPlugin'; +export * from './revokeCollectionPluginAuthority'; +export * from './updateCollection'; +export * from './updateCollectionPlugin'; diff --git a/clients/js/src/instructions/collection/removeCollectionPlugin.ts b/clients/js/src/instructions/collection/removeCollectionPlugin.ts new file mode 100644 index 00000000..e7ba28d1 --- /dev/null +++ b/clients/js/src/instructions/collection/removeCollectionPlugin.ts @@ -0,0 +1,37 @@ +import { Context } from '@metaplex-foundation/umi'; +import { + PluginType, + removeCollectionExternalPluginV1, + removeCollectionPluginV1, +} from '../../generated'; +import { ExternalPluginKey, externalPluginKeyToBase } from '../../plugins'; + +import { isExternalPluginType } from '../../plugins/externalPlugins'; + +export type RemoveCollectionPluginArgs = Omit< + Parameters[1], + 'plugin' +> & { + plugin: + | { + type: Exclude; + } + | ExternalPluginKey; +}; + +export const removeCollectionPlugin = ( + context: Pick, + { plugin, ...args }: RemoveCollectionPluginArgs +) => { + if (isExternalPluginType(plugin)) { + return removeCollectionExternalPluginV1(context, { + ...args, + key: externalPluginKeyToBase(plugin as ExternalPluginKey), + }); + } + + return removeCollectionPluginV1(context, { + ...args, + pluginType: PluginType[plugin.type as keyof typeof PluginType], + }); +}; diff --git a/clients/js/src/instructions/collection/revokeCollectionPluginAuthority.ts b/clients/js/src/instructions/collection/revokeCollectionPluginAuthority.ts new file mode 100644 index 00000000..f732eb71 --- /dev/null +++ b/clients/js/src/instructions/collection/revokeCollectionPluginAuthority.ts @@ -0,0 +1,33 @@ +import { Context } from '@metaplex-foundation/umi'; +import { revokeCollectionPluginAuthorityV1, PluginType } from '../../generated'; +import { isExternalPluginType } from '../../plugins'; +import { ExternalPluginKey } from '../../plugins/externalPluginKey'; + +export type RevokeCollectionPluginAuthorityArgs = Omit< + Parameters[1], + 'pluginType' +> & { + plugin: + | { + type: keyof typeof PluginType; + } + | ExternalPluginKey; +}; + +export const revokeCollectionPluginAuthority = ( + context: Pick, + { plugin, ...args }: RevokeCollectionPluginAuthorityArgs +) => { + if (isExternalPluginType(plugin)) { + // TODO implement this + // return revokeCollectionExternalPluginAuthorityV1(context, { + // ...args, + // key: externalPluginKeyToBase(plugin as ExternalPluginKey), + // }); + } + + return revokeCollectionPluginAuthorityV1(context, { + ...args, + pluginType: PluginType[plugin.type as keyof typeof PluginType], + }); +}; diff --git a/clients/js/src/instructions/collection/updateCollection.ts b/clients/js/src/instructions/collection/updateCollection.ts new file mode 100644 index 00000000..dba052d9 --- /dev/null +++ b/clients/js/src/instructions/collection/updateCollection.ts @@ -0,0 +1,23 @@ +import { Context } from '@metaplex-foundation/umi'; +import { + updateCollectionV1, + UpdateCollectionV1InstructionDataArgs, +} from '../../generated'; + +export type UpdateCollectionArgs = Omit< + Parameters[1], + 'newName' | 'newUri' +> & { + name?: UpdateCollectionV1InstructionDataArgs['newName']; + uri?: UpdateCollectionV1InstructionDataArgs['newUri']; +}; + +export const updateCollection = ( + context: Pick, + { name, uri, ...args }: UpdateCollectionArgs +) => + updateCollectionV1(context, { + ...args, + newName: name, + newUri: uri, + }); diff --git a/clients/js/src/instructions/collection/updateCollectionPlugin.ts b/clients/js/src/instructions/collection/updateCollectionPlugin.ts new file mode 100644 index 00000000..ad4ee2b6 --- /dev/null +++ b/clients/js/src/instructions/collection/updateCollectionPlugin.ts @@ -0,0 +1,39 @@ +import { Context } from '@metaplex-foundation/umi'; +import { + updateCollectionPluginV1, + updateCollectionExternalPluginV1, +} from '../../generated'; +import { + createExternalPluginUpdateInfo, + PluginArgsV2, + createPluginV2, + externalPluginKeyToBase, + isExternalPluginType, +} from '../../plugins'; +import { ExternalPluginUpdateInfoArgs } from '../../plugins/externalPlugins'; + +export type UpdateCollectionPluginArgs = Omit< + Parameters[1], + 'plugin' +> & { + plugin: PluginArgsV2 | ExternalPluginUpdateInfoArgs; +}; + +export const updateCollectionPlugin = ( + context: Pick, + { plugin, ...args }: UpdateCollectionPluginArgs +) => { + if (isExternalPluginType(plugin)) { + const plug = plugin as ExternalPluginUpdateInfoArgs; + return updateCollectionExternalPluginV1(context, { + ...args, + updateInfo: createExternalPluginUpdateInfo(plug), + pluginKey: externalPluginKeyToBase(plug.key), + }); + } + + return updateCollectionPluginV1(context, { + ...args, + plugin: createPluginV2(plugin as PluginArgsV2), + }); +}; diff --git a/clients/js/src/instructions/create.ts b/clients/js/src/instructions/create.ts new file mode 100644 index 00000000..a72602dc --- /dev/null +++ b/clients/js/src/instructions/create.ts @@ -0,0 +1,101 @@ +import { Context, publicKey } from '@metaplex-foundation/umi'; +import { CollectionV1, createV2, ExternalPluginSchema } from '../generated'; +import { + createExternalPluginInitInfo, + findExtraAccounts, + PluginArgsV2, + pluginAuthorityPairV2, +} from '../plugins'; +import { deriveExternalPlugins } from '../helpers'; +import { + ExternalPluginInitInfoArgs, + ExternalPluginsList, + isExternalPluginType, +} from '../plugins/externalPlugins'; + +export type CreateArgs = Omit< + Parameters[1], + 'plugins' | 'externalPlugins' | 'collection' +> & { + collection?: CollectionV1; + plugins?: (PluginArgsV2 | ExternalPluginInitInfoArgs)[]; +}; + +export const create = ( + context: Pick, + { asset, plugins, collection, ...args }: CreateArgs +) => { + const owner = args.owner || args.updateAuthority || args.payer; + + const assetExternalPlugins: ExternalPluginsList = { + oracles: [], + lifecycleHooks: [], + }; + + const externalPlugins: ExternalPluginInitInfoArgs[] = []; + const firstPartyPlugins: PluginArgsV2[] = []; + + // Create dummy external plugins to resuse findExtraAccounts method + plugins?.forEach((plugin) => { + if (isExternalPluginType(plugin)) { + externalPlugins.push(plugin as ExternalPluginInitInfoArgs); + switch (plugin.type) { + case 'Oracle': + assetExternalPlugins.oracles?.push({ + ...plugin, + resultsOffset: plugin.resultsOffset || { type: 'NoOffset' }, + baseAddress: plugin.baseAddress, + authority: plugin.initPluginAuthority || { + type: 'UpdateAuthority', + }, + type: 'Oracle', + }); + break; + case 'DataStore': + // Do nothing, datastore has no extra accounts + break; + case 'LifecycleHook': + assetExternalPlugins.lifecycleHooks?.push({ + ...plugin, + hookedProgram: plugin.hookedProgram, + authority: plugin.initPluginAuthority || { + type: 'UpdateAuthority', + }, + dataLen: 0n, + dataOffset: 0n, + type: 'LifecycleHook', + schema: plugin.schema || ExternalPluginSchema.Binary, + }); + break; + default: + // Do nothing + } + } else { + firstPartyPlugins.push(plugin as PluginArgsV2); + } + }); + + const derivedExternalPlugins = deriveExternalPlugins( + assetExternalPlugins, + collection + ); + const extraAccounts = findExtraAccounts( + context, + 'create', + derivedExternalPlugins, + { + asset: asset.publicKey, + collection: collection ? collection.publicKey : undefined, + // need to replicate program behavior + owner: owner ? publicKey(owner) : context.identity.publicKey, + } + ); + + return createV2(context, { + ...args, + plugins: firstPartyPlugins.map(pluginAuthorityPairV2), + externalPlugins: externalPlugins.map(createExternalPluginInitInfo), + asset, + collection: collection ? collection.publicKey : undefined, + }).addRemainingAccounts(extraAccounts); +}; diff --git a/clients/js/src/instructions/index.ts b/clients/js/src/instructions/index.ts index ef5ef72c..49825646 100644 --- a/clients/js/src/instructions/index.ts +++ b/clients/js/src/instructions/index.ts @@ -1,3 +1,13 @@ export * from './legacyDelegate'; export * from './legacyRevoke'; export * from './freeze'; +export * from './create'; +export * from './update'; +export * from './transfer'; +export * from './burn'; +export * from './addPlugin'; +export * from './removePlugin'; +export * from './updatePlugin'; +export * from './approvePluginAuthority'; +export * from './revokePluginAuthority'; +export * from './collection'; diff --git a/clients/js/src/instructions/legacyDelegate.ts b/clients/js/src/instructions/legacyDelegate.ts index a61cae7c..308d3235 100644 --- a/clients/js/src/instructions/legacyDelegate.ts +++ b/clients/js/src/instructions/legacyDelegate.ts @@ -10,9 +10,8 @@ import { AssetV1, PluginType, } from '../generated'; -import { createPlugin, pluginKeyToPluginType } from '../plugins'; +import { createPlugin, pluginKeyToPluginType, PluginsList } from '../plugins'; import { addressPluginAuthority } from '../authority'; -import { PluginsList } from '../types'; export function legacyDelegate( context: Pick, diff --git a/clients/js/src/instructions/legacyRevoke.ts b/clients/js/src/instructions/legacyRevoke.ts index 6f3ec82f..efc9692f 100644 --- a/clients/js/src/instructions/legacyRevoke.ts +++ b/clients/js/src/instructions/legacyRevoke.ts @@ -1,8 +1,7 @@ import { Context, transactionBuilder } from '@metaplex-foundation/umi'; import { AssetV1, PluginType, revokePluginAuthorityV1 } from '../generated'; import { ERR_CANNOT_REVOKE } from './errors'; -import { pluginKeyToPluginType } from '../plugins'; -import { PluginsList } from '../types'; +import { pluginKeyToPluginType, PluginsList } from '../plugins'; export function legacyRevoke( context: Pick, diff --git a/clients/js/src/instructions/removePlugin.ts b/clients/js/src/instructions/removePlugin.ts new file mode 100644 index 00000000..6b07c8c8 --- /dev/null +++ b/clients/js/src/instructions/removePlugin.ts @@ -0,0 +1,39 @@ +import { Context } from '@metaplex-foundation/umi'; +import { + removePluginV1, + removeExternalPluginV1, + PluginType, +} from '../generated'; +import { isExternalPluginType } from '../plugins'; +import { + ExternalPluginKey, + externalPluginKeyToBase, +} from '../plugins/externalPluginKey'; + +export type RemovePluginArgs = Omit< + Parameters[1], + 'pluginType' +> & { + plugin: + | { + type: Exclude; + } + | ExternalPluginKey; +}; + +export const removePlugin = ( + context: Pick, + { plugin, ...args }: RemovePluginArgs +) => { + if (isExternalPluginType(plugin)) { + return removeExternalPluginV1(context, { + ...args, + key: externalPluginKeyToBase(plugin as ExternalPluginKey), + }); + } + + return removePluginV1(context, { + ...args, + pluginType: PluginType[plugin.type as keyof typeof PluginType], + }); +}; diff --git a/clients/js/src/instructions/revokePluginAuthority.ts b/clients/js/src/instructions/revokePluginAuthority.ts new file mode 100644 index 00000000..8ddf1a42 --- /dev/null +++ b/clients/js/src/instructions/revokePluginAuthority.ts @@ -0,0 +1,33 @@ +import { Context } from '@metaplex-foundation/umi'; +import { revokePluginAuthorityV1, PluginType } from '../generated'; +import { isExternalPluginType } from '../plugins'; +import { ExternalPluginKey } from '../plugins/externalPluginKey'; + +export type RevokePluginAuthorityArgs = Omit< + Parameters[1], + 'pluginType' +> & { + plugin: + | { + type: keyof typeof PluginType; + } + | ExternalPluginKey; +}; + +export const revokePluginAuthority = ( + context: Pick, + { plugin, ...args }: RevokePluginAuthorityArgs +) => { + if (isExternalPluginType(plugin)) { + // TODO implement this + // return revokeExternalPluginAuthorityV1(context, { + // ...args, + // key: externalPluginKeyToBase(plugin as ExternalPluginKey), + // }); + } + + return revokePluginAuthorityV1(context, { + ...args, + pluginType: PluginType[plugin.type as keyof typeof PluginType], + }); +}; diff --git a/clients/js/src/instructions/transfer.ts b/clients/js/src/instructions/transfer.ts new file mode 100644 index 00000000..7dd252e6 --- /dev/null +++ b/clients/js/src/instructions/transfer.ts @@ -0,0 +1,37 @@ +import { Context, publicKey } from '@metaplex-foundation/umi'; +import { CollectionV1, transferV1, AssetV1 } from '../generated'; +import { findExtraAccounts } from '../plugins'; +import { deriveExternalPlugins } from '../helpers'; + +export type TransferArgs = Omit< + Parameters[1], + 'asset' | 'collection' +> & { + asset: AssetV1; + collection?: CollectionV1; +}; + +export const transfer = ( + context: Pick, + { asset, collection, ...args }: TransferArgs +) => { + const derivedExternalPlugins = deriveExternalPlugins(asset, collection); + + const extraAccounts = findExtraAccounts( + context, + 'transfer', + derivedExternalPlugins, + { + asset: asset.publicKey, + collection: collection?.publicKey, + owner: asset.owner, + recipient: publicKey(args.newOwner), + } + ); + + return transferV1(context, { + ...args, + asset: asset.publicKey, + collection: collection?.publicKey, + }).addRemainingAccounts(extraAccounts); +}; diff --git a/clients/js/src/instructions/update.ts b/clients/js/src/instructions/update.ts new file mode 100644 index 00000000..8ad02cb5 --- /dev/null +++ b/clients/js/src/instructions/update.ts @@ -0,0 +1,45 @@ +import { Context } from '@metaplex-foundation/umi'; +import { + CollectionV1, + updateV1, + AssetV1, + UpdateV1InstructionDataArgs, +} from '../generated'; +import { findExtraAccounts } from '../plugins'; +import { deriveExternalPlugins } from '../helpers'; + +export type UpdateArgs = Omit< + Parameters[1], + 'asset' | 'collection' | 'newName' | 'newUri' +> & { + asset: AssetV1; + collection?: CollectionV1; + name?: UpdateV1InstructionDataArgs['newName']; + uri?: UpdateV1InstructionDataArgs['newUri']; +}; + +export const update = ( + context: Pick, + { asset, collection, name, uri, ...args }: UpdateArgs +) => { + const derivedExternalPlugins = deriveExternalPlugins(asset, collection); + + const extraAccounts = findExtraAccounts( + context, + 'update', + derivedExternalPlugins, + { + asset: asset.publicKey, + collection: collection?.publicKey, + owner: asset.owner, + } + ); + + return updateV1(context, { + ...args, + asset: asset.publicKey, + collection: collection?.publicKey, + newName: name, + newUri: uri, + }).addRemainingAccounts(extraAccounts); +}; diff --git a/clients/js/src/instructions/updatePlugin.ts b/clients/js/src/instructions/updatePlugin.ts new file mode 100644 index 00000000..a50b00f5 --- /dev/null +++ b/clients/js/src/instructions/updatePlugin.ts @@ -0,0 +1,36 @@ +import { Context } from '@metaplex-foundation/umi'; +import { updatePluginV1, updateExternalPluginV1 } from '../generated'; +import { + createExternalPluginUpdateInfo, + createPluginV2, + externalPluginKeyToBase, + isExternalPluginType, + PluginArgsV2, +} from '../plugins'; +import { ExternalPluginUpdateInfoArgs } from '../plugins/externalPlugins'; + +export type UpdatePluginArgs = Omit< + Parameters[1], + 'plugin' +> & { + plugin: PluginArgsV2 | ExternalPluginUpdateInfoArgs; +}; + +export const updatePlugin = ( + context: Pick, + { plugin, ...args }: UpdatePluginArgs +) => { + if (isExternalPluginType(plugin)) { + const plug = plugin as ExternalPluginUpdateInfoArgs; + return updateExternalPluginV1(context, { + ...args, + updateInfo: createExternalPluginUpdateInfo(plug), + key: externalPluginKeyToBase(plug.key), + }); + } + + return updatePluginV1(context, { + ...args, + plugin: createPluginV2(plugin as PluginArgsV2), + }); +}; diff --git a/clients/js/src/plugins/dataStore.ts b/clients/js/src/plugins/dataStore.ts new file mode 100644 index 00000000..a5b40527 --- /dev/null +++ b/clients/js/src/plugins/dataStore.ts @@ -0,0 +1,92 @@ +import { + BaseDataStore, + BaseDataStoreInitInfoArgs, + BaseDataStoreUpdateInfoArgs, + ExternalPluginSchema, +} from '../generated'; +import { ExternalPluginKey } from './externalPluginKey'; +import { ExternalPluginManifest } from './externalPluginManifest'; +import { BaseExternalPlugin, parseExternalPluginData } from './externalPlugins'; +import { LifecycleChecks } from './lifecycleChecks'; +import { + PluginAuthority, + pluginAuthorityFromBase, + pluginAuthorityToBase, +} from './pluginAuthority'; + +export type DataStore = Omit & { + dataAuthority: PluginAuthority; + data?: any; +}; + +export type DataStorePlugin = BaseExternalPlugin & + DataStore & { + type: 'DataStore'; + dataAuthority: PluginAuthority; + }; + +export type DataStoreInitInfoArgs = Omit< + BaseDataStoreInitInfoArgs, + 'initPluginAuthority' | 'lifecycleChecks' | 'dataAuthority' +> & { + type: 'DataStore'; + initPluginAuthority?: PluginAuthority; + lifecycleChecks?: LifecycleChecks; + schema?: ExternalPluginSchema; + dataAuthority: PluginAuthority; +}; + +export type DataStoreUpdateInfoArgs = Omit< + BaseDataStoreUpdateInfoArgs, + 'schema' +> & { + key: ExternalPluginKey; + schema?: ExternalPluginSchema; +}; + +export function dataStoreInitInfoArgsToBase( + d: DataStoreInitInfoArgs +): BaseDataStoreInitInfoArgs { + return { + dataAuthority: pluginAuthorityToBase(d.dataAuthority), + initPluginAuthority: d.initPluginAuthority + ? pluginAuthorityToBase(d.initPluginAuthority) + : null, + schema: d.schema ? d.schema : null, + }; +} + +export function dataStoreUpdateInfoArgsToBase( + d: DataStoreUpdateInfoArgs +): BaseDataStoreUpdateInfoArgs { + return { + schema: d.schema ? d.schema : null, + }; +} + +export function dataStoreFromBase( + s: BaseDataStore, + account: Uint8Array +): DataStore { + return { + ...s, + dataAuthority: pluginAuthorityFromBase(s.dataAuthority), + dataOffset: s.dataOffset, + dataLen: s.dataLen, + data: parseExternalPluginData(s, account), + }; +} + +export const dataStoreManifest: ExternalPluginManifest< + DataStore, + BaseDataStore, + DataStoreInitInfoArgs, + BaseDataStoreInitInfoArgs, + DataStoreUpdateInfoArgs, + BaseDataStoreUpdateInfoArgs +> = { + type: 'DataStore', + fromBase: dataStoreFromBase, + initToBase: dataStoreInitInfoArgsToBase, + updateToBase: dataStoreUpdateInfoArgsToBase, +}; diff --git a/clients/js/src/plugins/externalPluginKey.ts b/clients/js/src/plugins/externalPluginKey.ts new file mode 100644 index 00000000..dba3448a --- /dev/null +++ b/clients/js/src/plugins/externalPluginKey.ts @@ -0,0 +1,38 @@ +import { PublicKey } from '@metaplex-foundation/umi'; +import { BaseExternalPluginKey } from '../generated'; +import { PluginAuthority, pluginAuthorityToBase } from './pluginAuthority'; + +export type ExternalPluginKey = + | { + type: 'Oracle'; + baseAddress: PublicKey; + } + | { + type: 'DataStore'; + dataAuthority: PluginAuthority; + } + | { + type: 'LifecycleHook'; + hookedProgram: PublicKey; + }; + +export function externalPluginKeyToBase( + e: ExternalPluginKey +): BaseExternalPluginKey { + if (e.type === 'Oracle') { + return { + __kind: 'Oracle', + fields: [e.baseAddress], + }; + } + if (e.type === 'DataStore') { + return { + __kind: 'DataStore', + fields: [pluginAuthorityToBase(e.dataAuthority)], + }; + } + return { + __kind: 'LifecycleHook', + fields: [e.hookedProgram], + }; +} diff --git a/clients/js/src/plugins/externalPluginManifest.ts b/clients/js/src/plugins/externalPluginManifest.ts new file mode 100644 index 00000000..ed02f969 --- /dev/null +++ b/clients/js/src/plugins/externalPluginManifest.ts @@ -0,0 +1,15 @@ +import { ExternalPluginTypeString } from './externalPlugins'; + +export type ExternalPluginManifest< + T extends Object, + Base extends Object, + Init extends Object, + InitBase extends Object, + Update extends Object, + UpdateBase extends Object +> = { + type: ExternalPluginTypeString; + fromBase: (input: Base, account: Uint8Array) => T; + initToBase: (input: Init) => InitBase; + updateToBase: (input: Update) => UpdateBase; +}; diff --git a/clients/js/src/plugins/externalPlugins.ts b/clients/js/src/plugins/externalPlugins.ts new file mode 100644 index 00000000..20f1ade1 --- /dev/null +++ b/clients/js/src/plugins/externalPlugins.ts @@ -0,0 +1,258 @@ +import { AccountMeta, Context, PublicKey } from '@metaplex-foundation/umi'; +import { + lifecycleHookFromBase, + LifecycleHookInitInfoArgs, + lifecycleHookManifest, + LifecycleHookPlugin, + LifecycleHookUpdateInfoArgs, + pluginAuthorityFromBase, +} from '.'; +import { + BaseExternalPluginInitInfoArgs, + BaseExternalPluginKey, + BaseExternalPluginUpdateInfoArgs, + ExternalPluginSchema, + ExternalRegistryRecord, + getExternalPluginSerializer, +} from '../generated'; + +import { + dataStoreFromBase, + DataStoreInitInfoArgs, + dataStoreManifest, + DataStorePlugin, + DataStoreUpdateInfoArgs, +} from './dataStore'; +import { + LifecycleChecksContainer, + lifecycleChecksFromBase, + LifecycleEvent, +} from './lifecycleChecks'; +import { + oracleFromBase, + OracleInitInfoArgs, + oracleManifest, + OraclePlugin, + OracleUpdateInfoArgs, +} from './oracle'; +import { BasePlugin } from './types'; +import { extraAccountToAccountMeta } from './extraAccount'; + +export type ExternalPluginTypeString = BaseExternalPluginKey['__kind']; + +export type BaseExternalPlugin = BasePlugin & LifecycleChecksContainer; + +export type ExternalPluginsList = { + oracles?: OraclePlugin[]; + dataStores?: DataStorePlugin[]; + lifecycleHooks?: LifecycleHookPlugin[]; +}; + +export type ExternalPluginInitInfoArgs = + | ({ + type: 'Oracle'; + } & OracleInitInfoArgs) + | ({ + type: 'LifecycleHook'; + } & LifecycleHookInitInfoArgs) + | ({ + type: 'DataStore'; + } & DataStoreInitInfoArgs); + +export type ExternalPluginUpdateInfoArgs = + | ({ + type: 'Oracle'; + } & OracleUpdateInfoArgs) + | ({ + type: 'LifecycleHook'; + } & LifecycleHookUpdateInfoArgs) + | ({ + type: 'DataStore'; + } & DataStoreUpdateInfoArgs); + +export const externalPluginManifests = { + Oracle: oracleManifest, + DataStore: dataStoreManifest, + LifecycleHook: lifecycleHookManifest, +}; + +export type ExternalPluginData = { + dataLen: bigint; + dataOffset: bigint; +}; + +export function externalRegistryRecordsToExternalPluginList( + records: ExternalRegistryRecord[], + accountData: Uint8Array +): ExternalPluginsList { + const result: ExternalPluginsList = {}; + + records.forEach((record) => { + const deserializedPlugin = getExternalPluginSerializer().deserialize( + accountData, + Number(record.offset) + )[0]; + + const mappedPlugin: BaseExternalPlugin = { + lifecycleChecks: + record.lifecycleChecks.__option === 'Some' + ? lifecycleChecksFromBase(record.lifecycleChecks.value) + : undefined, + authority: pluginAuthorityFromBase(record.authority), + offset: record.offset, + }; + + if (deserializedPlugin.__kind === 'Oracle') { + if (!result.oracles) { + result.oracles = []; + } + + result.oracles.push({ + type: 'Oracle', + ...mappedPlugin, + ...oracleFromBase(deserializedPlugin.fields[0], accountData), + }); + } else if (deserializedPlugin.__kind === 'DataStore') { + if (!result.dataStores) { + result.dataStores = []; + } + result.dataStores.push({ + type: 'DataStore', + ...mappedPlugin, + ...dataStoreFromBase(deserializedPlugin.fields[0], accountData), + }); + } else if (deserializedPlugin.__kind === 'LifecycleHook') { + if (!result.lifecycleHooks) { + result.lifecycleHooks = []; + } + result.lifecycleHooks.push({ + type: 'LifecycleHook', + ...mappedPlugin, + ...lifecycleHookFromBase(deserializedPlugin.fields[0], accountData), + }); + } + }); + + return result; +} + +export const isExternalPluginType = (plugin: { type: string }) => { + if ( + plugin.type === 'Oracle' || + plugin.type === 'LifecycleHook' || + plugin.type === 'DataStore' + ) { + return true; + } + return false; +}; + +export function createExternalPluginInitInfo({ + type, + ...args +}: ExternalPluginInitInfoArgs): BaseExternalPluginInitInfoArgs { + const manifest = externalPluginManifests[type]; + return { + __kind: type, + fields: [manifest.initToBase(args as any)] as any, + }; +} + +export function createExternalPluginUpdateInfo({ + type, + ...args +}: ExternalPluginUpdateInfoArgs): BaseExternalPluginUpdateInfoArgs { + const manifest = externalPluginManifests[type]; + return { + __kind: type, + fields: [manifest.updateToBase(args as any)] as any, + }; +} + +export const findExtraAccounts = ( + context: Pick, + lifecycle: LifecycleEvent, + externalPlugins: ExternalPluginsList, + inputs: { + asset: PublicKey; + collection?: PublicKey; + owner: PublicKey; + recipient?: PublicKey; + } +): AccountMeta[] => { + const accounts: AccountMeta[] = []; + const { asset, collection, owner, recipient } = inputs; + + externalPlugins.oracles?.forEach((oracle) => { + if (oracle.lifecycleChecks?.[lifecycle]) { + if (oracle.pda) { + accounts.push( + extraAccountToAccountMeta(context, oracle.pda, { + program: oracle.baseAddress, + asset, + collection, + recipient, + }) + ); + } else { + accounts.push({ + pubkey: oracle.baseAddress, + isSigner: false, + isWritable: false, + }); + } + } + }); + + externalPlugins.lifecycleHooks?.forEach((hook) => { + if (hook.lifecycleChecks?.[lifecycle]) { + accounts.push({ + pubkey: hook.hookedProgram, + isSigner: false, + isWritable: false, + }); + + hook.extraAccounts?.forEach((extra) => { + accounts.push( + extraAccountToAccountMeta(context, extra, { + program: hook.hookedProgram, + asset, + collection, + recipient, + owner, + }) + ); + }); + } + }); + + return accounts; +}; + +export function parseExternalPluginData( + plugin: { + schema: ExternalPluginSchema; + dataLen: bigint | number; + dataOffset: bigint | number; + }, + account: Uint8Array +): any { + let data; + const dataSlice = account.slice( + Number(plugin.dataOffset), + Number(plugin.dataOffset) + Number(plugin.dataLen) + ); + + if (plugin.schema === ExternalPluginSchema.Binary) { + data = dataSlice; + } else if (plugin.schema === ExternalPluginSchema.Json) { + data = JSON.parse(new TextDecoder().decode(dataSlice)); + } else if (plugin.schema === ExternalPluginSchema.MsgPack) { + // eslint-disable-next-line no-console + console.warn( + 'MsgPack schema currently not supported, falling back to binary' + ); + data = dataSlice; + } + return data; +} diff --git a/clients/js/src/plugins/extraAccount.ts b/clients/js/src/plugins/extraAccount.ts new file mode 100644 index 00000000..276f90b9 --- /dev/null +++ b/clients/js/src/plugins/extraAccount.ts @@ -0,0 +1,194 @@ +import { AccountMeta, Context, PublicKey } from '@metaplex-foundation/umi'; +import { + string, + publicKey as publicKeySerializer, +} from '@metaplex-foundation/umi/serializers'; +import { BaseExtraAccount } from '../generated'; +import { Seed, seedFromBase, seedToBase } from './seed'; +import { RenameToType } from '../utils'; + +export const PRECONFIGURED_SEED = 'mpl-core'; + +export const findPreconfiguredPda = ( + context: Pick, + program: PublicKey, + key: PublicKey +) => + context.eddsa.findPda(program, [ + string({ size: 'variable' }).serialize(PRECONFIGURED_SEED), + publicKeySerializer().serialize(key), + ]); + +export type ExtraAccount = + | Exclude< + RenameToType, + { type: 'CustomPda' } | { type: 'Address' } + > + | { + type: 'CustomPda'; + seeds: Array; + isSigner: boolean; + isWritable: boolean; + } + | { + type: 'Address'; + address: PublicKey; + isSigner: boolean; + isWritable: boolean; + }; + +export function extraAccountToAccountMeta( + context: Pick, + e: ExtraAccount, + inputs: { + program?: PublicKey; + asset?: PublicKey; + collection?: PublicKey; + recipient?: PublicKey; + owner?: PublicKey; + } +): AccountMeta { + switch (e.type) { + case 'PreconfiguredProgram': + if (!inputs.program) throw new Error('Program address is required'); + return { + pubkey: context.eddsa.findPda(inputs.program, [ + string({ size: 'variable' }).serialize(PRECONFIGURED_SEED), + ])[0], + isSigner: e.isSigner, + isWritable: e.isWritable, + }; + case 'PreconfiguredCollection': + if (!inputs.program) throw new Error('Program address is required'); + if (!inputs.collection) throw new Error('Collection address is required'); + return { + pubkey: findPreconfiguredPda( + context, + inputs.program, + inputs.collection + )[0], + isSigner: e.isSigner, + isWritable: e.isWritable, + }; + case 'PreconfiguredOwner': + if (!inputs.program) throw new Error('Program address is required'); + if (!inputs.owner) throw new Error('Owner address is required'); + return { + pubkey: findPreconfiguredPda(context, inputs.program, inputs.owner)[0], + isSigner: e.isSigner, + isWritable: e.isWritable, + }; + case 'PreconfiguredRecipient': + if (!inputs.program) throw new Error('Program address is required'); + if (!inputs.recipient) throw new Error('Recipient address is required'); + return { + pubkey: findPreconfiguredPda( + context, + inputs.program, + inputs.recipient + )[0], + isSigner: e.isSigner, + isWritable: e.isWritable, + }; + case 'PreconfiguredAsset': + if (!inputs.program) throw new Error('Program address is required'); + if (!inputs.asset) throw new Error('Asset address is required'); + return { + pubkey: findPreconfiguredPda(context, inputs.program, inputs.asset)[0], + isSigner: e.isSigner, + isWritable: e.isWritable, + }; + case 'CustomPda': + if (!inputs.program) throw new Error('Program address is required'); + return { + pubkey: context.eddsa.findPda( + inputs.program, + e.seeds.map((seed) => { + switch (seed.type) { + case 'Collection': + if (!inputs.collection) + throw new Error('Collection address is required'); + return publicKeySerializer().serialize(inputs.collection); + case 'Owner': + if (!inputs.owner) throw new Error('Owner address is required'); + return publicKeySerializer().serialize(inputs.owner); + case 'Recipient': + if (!inputs.recipient) + throw new Error('Recipient address is required'); + return publicKeySerializer().serialize(inputs.recipient); + case 'Asset': + if (!inputs.asset) throw new Error('Asset address is required'); + return publicKeySerializer().serialize(inputs.asset); + case 'Bytes': + return seed.bytes; + case 'Program': + default: + if (!inputs.program) + throw new Error('Program address is required'); + return publicKeySerializer().serialize(inputs.program); + } + }) + )[0], + isSigner: e.isSigner, + isWritable: e.isWritable, + }; + case 'Address': + return { + pubkey: e.address, + isSigner: e.isSigner, + isWritable: e.isWritable, + }; + default: + throw new Error('Unknown extra account type'); + } +} + +export function extraAccountToBase(s: ExtraAccount): BaseExtraAccount { + if (s.type === 'CustomPda') { + return { + __kind: 'CustomPda', + isSigner: s.isSigner, + isWritable: s.isWritable, + seeds: s.seeds.map(seedToBase), + }; + } + if (s.type === 'Address') { + return { + __kind: 'Address', + isSigner: s.isSigner, + isWritable: s.isWritable, + address: s.address, + }; + } + + return { + __kind: s.type, + isSigner: s.isSigner, + isWritable: s.isWritable, + }; +} + +export function extraAccountFromBase(s: BaseExtraAccount): ExtraAccount { + if (s.__kind === 'CustomPda') { + return { + type: 'CustomPda', + isSigner: s.isSigner, + isWritable: s.isWritable, + seeds: s.seeds.map(seedFromBase), + }; + } + if (s.__kind === 'Address') { + return { + type: 'Address', + isSigner: s.isSigner, + isWritable: s.isWritable, + address: s.address, + }; + } + + return { + type: s.__kind, + isSigner: s.isSigner, + isWritable: s.isWritable, + }; +} diff --git a/clients/js/src/plugins/index.ts b/clients/js/src/plugins/index.ts new file mode 100644 index 00000000..83417e70 --- /dev/null +++ b/clients/js/src/plugins/index.ts @@ -0,0 +1,14 @@ +export * from './royalties'; +export * from './lib'; +export * from './dataStore'; +export * from './lifecycleChecks'; +export * from './lifecycleHook'; +export * from './oracle'; +export * from './externalPluginKey'; +export * from './externalPluginManifest'; +export * from './pluginAuthority'; +export * from './types'; +export * from './externalPlugins'; +export * from './updateAuthority'; +export * from './seed'; +export * from './extraAccount'; diff --git a/clients/js/src/plugins.ts b/clients/js/src/plugins/lib.ts similarity index 64% rename from clients/js/src/plugins.ts rename to clients/js/src/plugins/lib.ts index cdcc0e66..a26a5da2 100644 --- a/clients/js/src/plugins.ts +++ b/clients/js/src/plugins/lib.ts @@ -7,18 +7,23 @@ import { getPluginSerializer, RegistryRecord, PluginAuthorityPair, - PluginAuthority, - RoyaltiesArgs, - FreezeDelegateArgs, - AttributesArgs, - PermanentFreezeDelegateArgs, PluginType, - UpdateDelegateArgs, - EditionArgs, -} from './generated'; -import { BasePluginAuthority, PluginsList } from './types'; -import { mapPluginAuthority } from './authority'; -import { toWords } from './utils'; +} from '../generated'; + +import { toWords } from '../utils'; +import { + CreatePluginArgs, + PluginArgsV2, + PluginAuthorityPairHelperArgs, + PluginAuthorityPairArgsV2, + PluginsList, +} from './types'; +import { + PluginAuthority, + pluginAuthorityFromBase, + pluginAuthorityToBase, +} from './pluginAuthority'; +import { royaltiesFromBase, royaltiesToBase } from './royalties'; export function formPluginHeaderV1( pluginRegistryOffset: bigint @@ -29,48 +34,6 @@ export function formPluginHeaderV1( }; } -export type PluginAuthorityPairHelperArgs = CreatePluginArgs & { - authority?: PluginAuthority; -}; - -export type CreatePluginArgs = - | { - type: 'Royalties'; - data: RoyaltiesArgs; - } - | { - type: 'FreezeDelegate'; - data: FreezeDelegateArgs; - } - | { - type: 'BurnDelegate'; - } - | { - type: 'TransferDelegate'; - } - | { - type: 'UpdateDelegate'; - data?: UpdateDelegateArgs; - } - | { - type: 'Attributes'; - data: AttributesArgs; - } - | { - type: 'PermanentFreezeDelegate'; - data: PermanentFreezeDelegateArgs; - } - | { - type: 'PermanentTransferDelegate'; - } - | { - type: 'PermanentBurnDelegate'; - } - | { - type: 'Edition'; - data: EditionArgs; - }; - export function createPlugin(args: CreatePluginArgs): BasePlugin { // TODO refactor when there are more required empty fields in plugins if (args.type === 'UpdateDelegate') { @@ -88,28 +51,55 @@ export function createPlugin(args: CreatePluginArgs): BasePlugin { fields: [(args as any).data || {}], }; } - export function pluginAuthorityPair( args: PluginAuthorityPairHelperArgs ): PluginAuthorityPair { const { type, authority, data } = args as any; + return { + plugin: createPlugin({ + type, + data, + }), + authority: authority ? some(authority) : none(), + }; +} + +export function createPluginV2(args: PluginArgsV2): BasePlugin { // TODO refactor when there are more required empty fields in plugins + const { type } = args; if (type === 'UpdateDelegate') { return { - plugin: { - __kind: type, - fields: [ - data || { - additionalDelegates: [], - }, - ], - }, - authority: authority ? some(authority) : none(), + __kind: type, + fields: [ + (args as any) || { + additionalDelegates: [], + }, + ], + }; + } + if (type === 'Royalties') { + return { + __kind: type, + fields: [royaltiesToBase(args)], }; } return { - plugin: { __kind: type, fields: [data || {}] }, - authority: authority ? some(authority) : none(), + __kind: type, + fields: [(args as any) || {}], + }; +} + +export function pluginAuthorityPairV2({ + type, + authority, + ...args +}: PluginAuthorityPairArgsV2): PluginAuthorityPair { + return { + plugin: createPluginV2({ + type, + ...args, + } as any), + authority: authority ? some(pluginAuthorityToBase(authority)) : none(), }; } @@ -123,7 +113,7 @@ export function mapPlugin({ offset, }: { plugin: Exclude; - authority: BasePluginAuthority; + authority: PluginAuthority; offset: bigint; }): PluginsList { const pluginKey = toWords(plug.__kind) @@ -131,6 +121,16 @@ export function mapPlugin({ .split(' ') .reduce((s, c) => s + (c.charAt(0).toUpperCase() + c.slice(1))); + if (plug.__kind === 'Royalties') { + return { + [pluginKey]: { + authority, + offset, + ...royaltiesFromBase(plug.fields[0]), + }, + }; + } + return { [pluginKey]: { authority, @@ -145,7 +145,7 @@ export function registryRecordsToPluginsList( accountData: Uint8Array ) { return registryRecords.reduce((acc: PluginsList, record) => { - const mappedAuthority = mapPluginAuthority(record.authority); + const mappedAuthority = pluginAuthorityFromBase(record.authority); const deserializedPlugin = getPluginSerializer().deserialize( accountData, Number(record.offset) diff --git a/clients/js/src/plugins/lifecycleChecks.ts b/clients/js/src/plugins/lifecycleChecks.ts new file mode 100644 index 00000000..7be856a1 --- /dev/null +++ b/clients/js/src/plugins/lifecycleChecks.ts @@ -0,0 +1,91 @@ +/* eslint-disable no-bitwise */ +import { ExternalCheckResult, HookableLifecycleEvent } from '../generated'; +import { capitalizeFirstLetter } from '../utils'; + +export type LifecycleEvent = 'create' | 'update' | 'transfer' | 'burn'; + +// ExternalCheckResult is a bit array +export enum CheckResult { + CAN_LISTEN, + CAN_APPROVE, + CAN_DENY, +} + +export const externalCheckResultToCheckResults = ( + check: ExternalCheckResult +): CheckResult[] => { + const results: CheckResult[] = []; + if (check.flags & 1) { + results.push(CheckResult.CAN_LISTEN); + } + if (check.flags & 2) { + results.push(CheckResult.CAN_APPROVE); + } + if (check.flags & 4) { + results.push(CheckResult.CAN_DENY); + } + return results; +}; + +export const checkResultsToExternalCheckResult = ( + results: CheckResult[] +): ExternalCheckResult => { + let flags = 0; + results.forEach((result) => { + switch (result) { + case CheckResult.CAN_LISTEN: + flags |= 1; + break; + case CheckResult.CAN_APPROVE: + flags |= 2; + break; + case CheckResult.CAN_DENY: + flags |= 4; + break; + default: + // Do nothing + } + }); + return { flags }; +}; + +export type LifecycleChecks = { [key in LifecycleEvent]?: CheckResult[] }; +export type LifecycleChecksContainer = { + lifecycleChecks?: LifecycleChecks; +}; + +export function lifecycleCheckKeyToEnum( + key: keyof LifecycleChecks +): HookableLifecycleEvent { + return HookableLifecycleEvent[ + capitalizeFirstLetter(key) as keyof typeof HookableLifecycleEvent + ]; +} + +export function hookableLifecycleEventToLifecycleCheckKey( + event: HookableLifecycleEvent +): keyof LifecycleChecks { + return HookableLifecycleEvent[event].toLowerCase() as keyof LifecycleChecks; +} + +export function lifecycleChecksToBase( + l: LifecycleChecks +): [HookableLifecycleEvent, ExternalCheckResult][] { + return Object(l) + .keys() + .map((key: keyof LifecycleChecks) => [ + lifecycleCheckKeyToEnum(key), + l[key], + ]); +} + +export function lifecycleChecksFromBase( + l: [HookableLifecycleEvent, ExternalCheckResult][] +): LifecycleChecks { + const checks: LifecycleChecks = {}; + l.forEach(([event, check]) => { + checks[hookableLifecycleEventToLifecycleCheckKey(event)] = + externalCheckResultToCheckResults(check); + }); + return checks; +} diff --git a/clients/js/src/plugins/lifecycleHook.ts b/clients/js/src/plugins/lifecycleHook.ts new file mode 100644 index 00000000..2e9569c5 --- /dev/null +++ b/clients/js/src/plugins/lifecycleHook.ts @@ -0,0 +1,128 @@ +import { PublicKey } from '@metaplex-foundation/umi'; +import { + ExtraAccount, + extraAccountFromBase, + extraAccountToBase, +} from './extraAccount'; +import { + BaseLifecycleHook, + BaseLifecycleHookInitInfoArgs, + BaseLifecycleHookUpdateInfoArgs, + ExternalPluginSchema, +} from '../generated'; +import { LifecycleChecks, lifecycleChecksToBase } from './lifecycleChecks'; +import { + PluginAuthority, + pluginAuthorityFromBase, + pluginAuthorityToBase, +} from './pluginAuthority'; +import { BaseExternalPlugin, parseExternalPluginData } from './externalPlugins'; +import { ExternalPluginManifest } from './externalPluginManifest'; +import { ExternalPluginKey } from './externalPluginKey'; + +export type LifecycleHook = Omit< + BaseLifecycleHook, + 'extraAccounts' | 'dataAuthority' +> & { + extraAccounts?: Array; + dataAuthority?: PluginAuthority; + data?: any; +}; + +export type LifecycleHookPlugin = BaseExternalPlugin & + LifecycleHook & { + type: 'LifecycleHook'; + hookedProgram: PublicKey; + }; + +export type LifecycleHookInitInfoArgs = Omit< + BaseLifecycleHookInitInfoArgs, + 'initPluginAuthority' | 'lifecycleChecks' | 'schema' | 'dataAuthority' +> & { + type: 'LifecycleHook'; + initPluginAuthority?: PluginAuthority; + lifecycleChecks?: LifecycleChecks; + schema?: ExternalPluginSchema; + extraAccounts?: Array; + dataAuthority?: PluginAuthority; +}; + +export type LifecycleHookUpdateInfoArgs = Omit< + BaseLifecycleHookUpdateInfoArgs, + 'lifecycleChecks' | 'extraAccounts' | 'schema' +> & { + key: ExternalPluginKey; + lifecycleChecks?: LifecycleChecks; + extraAccounts?: Array; + schema?: ExternalPluginSchema; +}; + +export function lifecycleHookInitInfoArgsToBase( + l: LifecycleHookInitInfoArgs +): BaseLifecycleHookInitInfoArgs { + return { + extraAccounts: l.extraAccounts + ? l.extraAccounts.map(extraAccountToBase) + : null, + hookedProgram: l.hookedProgram, + initPluginAuthority: l.initPluginAuthority + ? pluginAuthorityToBase(l.initPluginAuthority) + : null, + lifecycleChecks: l.lifecycleChecks + ? lifecycleChecksToBase(l.lifecycleChecks) + : null, + schema: l.schema ? l.schema : null, + dataAuthority: l.dataAuthority + ? pluginAuthorityToBase(l.dataAuthority) + : null, + }; +} + +export function lifecycleHookUpdateInfoArgsToBase( + l: LifecycleHookUpdateInfoArgs +): BaseLifecycleHookUpdateInfoArgs { + return { + lifecycleChecks: l.lifecycleChecks + ? lifecycleChecksToBase(l.lifecycleChecks) + : null, + extraAccounts: l.extraAccounts + ? l.extraAccounts.map(extraAccountToBase) + : null, + schema: l.schema ? l.schema : null, + // TODO update dataAuthority? + }; +} + +export function lifecycleHookFromBase( + s: BaseLifecycleHook, + account: Uint8Array +): LifecycleHook { + return { + ...s, + dataOffset: s.dataOffset, + dataLen: s.dataLen, + extraAccounts: + s.extraAccounts.__option === 'Some' + ? s.extraAccounts.value.map(extraAccountFromBase) + : undefined, + data: parseExternalPluginData(s, account), + dataAuthority: + s.dataAuthority.__option === 'Some' + ? pluginAuthorityFromBase(s.dataAuthority.value) + : undefined, + }; +} + +export const lifecycleHookManifest: ExternalPluginManifest< + LifecycleHook, + BaseLifecycleHook, + LifecycleHookInitInfoArgs, + BaseLifecycleHookInitInfoArgs, + LifecycleHookUpdateInfoArgs, + BaseLifecycleHookUpdateInfoArgs +> = { + type: 'LifecycleHook', + fromBase: lifecycleHookFromBase, + initToBase: lifecycleHookInitInfoArgsToBase, + updateToBase: lifecycleHookUpdateInfoArgsToBase, +}; diff --git a/clients/js/src/plugins/oracle.ts b/clients/js/src/plugins/oracle.ts new file mode 100644 index 00000000..15e83479 --- /dev/null +++ b/clients/js/src/plugins/oracle.ts @@ -0,0 +1,106 @@ +import { + ExtraAccount, + extraAccountFromBase, + extraAccountToBase, +} from './extraAccount'; +import { + BaseOracle, + BaseOracleInitInfoArgs, + BaseOracleUpdateInfoArgs, +} from '../generated'; +import { LifecycleChecks, lifecycleChecksToBase } from './lifecycleChecks'; +import { PluginAuthority, pluginAuthorityToBase } from './pluginAuthority'; +import { ExternalPluginManifest } from './externalPluginManifest'; +import { BaseExternalPlugin } from './externalPlugins'; +import { ExternalPluginKey } from './externalPluginKey'; +import { + ValidationResultsOffset, + validationResultsOffsetFromBase, + validationResultsOffsetToBase, +} from './validationResultsOffset'; + +export type Oracle = Omit & { + pda?: ExtraAccount; + resultsOffset: ValidationResultsOffset; +}; + +export type OraclePlugin = BaseExternalPlugin & + Oracle & { + type: 'Oracle'; + }; + +export type OracleInitInfoArgs = Omit< + BaseOracleInitInfoArgs, + 'initPluginAuthority' | 'lifecycleChecks' | 'pda' | 'resultsOffset' +> & { + type: 'Oracle'; + initPluginAuthority?: PluginAuthority; + lifecycleChecks?: LifecycleChecks; + pda?: ExtraAccount; + resultsOffset?: ValidationResultsOffset; +}; + +export type OracleUpdateInfoArgs = Omit< + BaseOracleUpdateInfoArgs, + 'lifecycleChecks' | 'pda' | 'resultsOffset' +> & { + key: ExternalPluginKey; + lifecycleChecks?: LifecycleChecks; + pda?: ExtraAccount; + resultsOffset?: ValidationResultsOffset; +}; + +export function oracleInitInfoArgsToBase( + o: OracleInitInfoArgs +): BaseOracleInitInfoArgs { + return { + baseAddress: o.baseAddress, + pda: o.pda ? extraAccountToBase(o.pda) : null, + lifecycleChecks: o.lifecycleChecks + ? lifecycleChecksToBase(o.lifecycleChecks) + : null, + initPluginAuthority: o.initPluginAuthority + ? pluginAuthorityToBase(o.initPluginAuthority) + : null, + resultsOffset: o.resultsOffset + ? validationResultsOffsetToBase(o.resultsOffset) + : null, + }; +} + +export function oracleUpdateInfoArgsToBase( + o: OracleUpdateInfoArgs +): BaseOracleUpdateInfoArgs { + return { + pda: o.pda ? extraAccountToBase(o.pda) : null, + lifecycleChecks: o.lifecycleChecks + ? lifecycleChecksToBase(o.lifecycleChecks) + : null, + resultsOffset: o.resultsOffset + ? validationResultsOffsetToBase(o.resultsOffset) + : null, + }; +} + +export function oracleFromBase(s: BaseOracle, account: Uint8Array): Oracle { + return { + ...s, + pda: + s.pda.__option === 'Some' ? extraAccountFromBase(s.pda.value) : undefined, + resultsOffset: validationResultsOffsetFromBase(s.resultsOffset), + }; +} + +export const oracleManifest: ExternalPluginManifest< + Oracle, + BaseOracle, + OracleInitInfoArgs, + BaseOracleInitInfoArgs, + OracleUpdateInfoArgs, + BaseOracleUpdateInfoArgs +> = { + type: 'Oracle', + fromBase: oracleFromBase, + initToBase: oracleInitInfoArgsToBase, + updateToBase: oracleUpdateInfoArgsToBase, +}; diff --git a/clients/js/src/plugins/pluginAuthority.ts b/clients/js/src/plugins/pluginAuthority.ts new file mode 100644 index 00000000..b0a4f0b3 --- /dev/null +++ b/clients/js/src/plugins/pluginAuthority.ts @@ -0,0 +1,30 @@ +import { PublicKey } from '@metaplex-foundation/umi'; +import { BasePluginAuthority } from '../generated'; + +export type PluginAuthority = { + type: PluginAuthorityType; + address?: PublicKey; +}; + +export type PluginAuthorityType = BasePluginAuthority['__kind']; + +export function pluginAuthorityToBase(u: PluginAuthority): BasePluginAuthority { + if (u.type === 'Address') { + return { + __kind: 'Address', + address: u.address as PublicKey, + }; + } + return { + __kind: u.type, + }; +} + +export function pluginAuthorityFromBase( + authority: BasePluginAuthority +): PluginAuthority { + return { + type: authority.__kind, + address: (authority as any).address, + }; +} diff --git a/clients/js/src/plugins/royalties.ts b/clients/js/src/plugins/royalties.ts new file mode 100644 index 00000000..adb19770 --- /dev/null +++ b/clients/js/src/plugins/royalties.ts @@ -0,0 +1,79 @@ +import { PublicKey } from '@metaplex-foundation/umi'; +import { BaseRoyalties, BaseRuleSet } from '../generated'; +import { BasePlugin } from './types'; + +// do jank stuff for backwards compatibility +export type UnwrappedRuleSet = + | { + type: 'None'; + } + | { + type: 'ProgramAllowList'; + addresses: PublicKey[]; + } + | { + type: 'ProgramDenyList'; + addresses: PublicKey[]; + }; + +export type RuleSet = UnwrappedRuleSet | BaseRuleSet; + +export type Royalties = Omit & { + ruleSet: RuleSet; +}; + +export type RoyaltiesArgs = Royalties; + +export type RoyaltiesPlugin = BasePlugin & Royalties; + +export function ruleSetToBase(r: RuleSet): BaseRuleSet { + const base = r as BaseRuleSet; + if (base.__kind) { + return r as BaseRuleSet; + } + const ruleSet = r as UnwrappedRuleSet; + + if ( + ruleSet.type === 'ProgramAllowList' || + ruleSet.type === 'ProgramDenyList' + ) { + return { + __kind: ruleSet.type, + fields: [ruleSet.addresses], + }; + } + return { __kind: ruleSet.type }; +} + +export function royaltiesToBase(r: Royalties): BaseRoyalties { + return { + ...r, + ruleSet: ruleSetToBase(r.ruleSet), + }; +} + +export function royaltiesFromBase(r: BaseRoyalties): Royalties { + let ruleSet: RuleSet; + if (r.ruleSet.__kind === 'ProgramAllowList') { + ruleSet = { + ...r.ruleSet, + type: 'ProgramAllowList', + addresses: r.ruleSet.fields[0], + }; + } else if (r.ruleSet.__kind === 'ProgramDenyList') { + ruleSet = { + ...r.ruleSet, + type: 'ProgramDenyList', + addresses: r.ruleSet.fields[0], + }; + } else { + ruleSet = { + ...r.ruleSet, + type: r.ruleSet.__kind, + }; + } + return { + ...r, + ruleSet, + }; +} diff --git a/clients/js/src/plugins/seed.ts b/clients/js/src/plugins/seed.ts new file mode 100644 index 00000000..1af153c5 --- /dev/null +++ b/clients/js/src/plugins/seed.ts @@ -0,0 +1,33 @@ +import { BaseSeed } from '../generated'; +import { RenameToType } from '../utils'; + +export type Seed = + | Exclude, { type: 'Bytes' }> + | { + type: 'Bytes'; + bytes: Uint8Array; + }; + +export function seedToBase(s: Seed): BaseSeed { + if (s.type === 'Bytes') { + return { + __kind: 'Bytes', + fields: [s.bytes], + }; + } + return { + __kind: s.type, + }; +} + +export function seedFromBase(s: BaseSeed): Seed { + if (s.__kind === 'Bytes') { + return { + type: 'Bytes', + bytes: s.fields[0], + }; + } + return { + type: s.__kind, + }; +} diff --git a/clients/js/src/plugins/types.ts b/clients/js/src/plugins/types.ts new file mode 100644 index 00000000..12ad80df --- /dev/null +++ b/clients/js/src/plugins/types.ts @@ -0,0 +1,140 @@ +import { + BurnDelegate, + FreezeDelegate, + PermanentFreezeDelegate, + TransferDelegate, + UpdateDelegate, + Attributes, + PermanentTransferDelegate, + PermanentBurnDelegate, + Edition, + basePluginAuthority as pluginAuthority, + baseUpdateAuthority as updateAuthority, + baseRuleSet as ruleSet, + FreezeDelegateArgs, + UpdateDelegateArgs, + AttributesArgs, + PermanentFreezeDelegateArgs, + EditionArgs, + BasePluginAuthority, + BaseRoyaltiesArgs, +} from '../generated'; +import { RoyaltiesArgs, RoyaltiesPlugin } from './royalties'; +import { PluginAuthority } from './pluginAuthority'; + +// for backwards compatibility +export { pluginAuthority, updateAuthority, ruleSet }; + +export type BasePlugin = { + authority: PluginAuthority; + offset?: bigint; +}; + +export type PluginAuthorityPairHelperArgs = CreatePluginArgs & { + authority?: BasePluginAuthority; +}; + +export type CreatePluginArgs = + | { + type: 'Royalties'; + data: BaseRoyaltiesArgs; + } + | { + type: 'FreezeDelegate'; + data: FreezeDelegateArgs; + } + | { + type: 'BurnDelegate'; + } + | { + type: 'TransferDelegate'; + } + | { + type: 'UpdateDelegate'; + data?: UpdateDelegateArgs; + } + | { + type: 'Attributes'; + data: AttributesArgs; + } + | { + type: 'PermanentFreezeDelegate'; + data: PermanentFreezeDelegateArgs; + } + | { + type: 'PermanentTransferDelegate'; + } + | { + type: 'PermanentBurnDelegate'; + } + | { + type: 'Edition'; + data: EditionArgs; + }; + +export type AuthorityArgsV2 = { + authority?: PluginAuthority; +}; + +export type CreateOnlyPluginArgsV2 = + | ({ + type: 'PermanentFreezeDelegate'; + } & PermanentFreezeDelegateArgs) + | { + type: 'PermanentTransferDelegate'; + } + | { + type: 'PermanentBurnDelegate'; + } + | ({ + type: 'Edition'; + } & EditionArgs); + +export type AddablePluginArgsV2 = + | ({ + type: 'Royalties'; + } & RoyaltiesArgs) + | ({ + type: 'FreezeDelegate'; + } & FreezeDelegateArgs) + | { + type: 'BurnDelegate'; + } + | { + type: 'TransferDelegate'; + } + | ({ + type: 'UpdateDelegate'; + } & UpdateDelegateArgs) + | ({ + type: 'Attributes'; + } & AttributesArgs); +export type PluginArgsV2 = AddablePluginArgsV2 | CreateOnlyPluginArgsV2; +export type PluginAuthorityPairArgsV2 = PluginArgsV2 & AuthorityArgsV2; +export type AddablePluginAuthorityPairArgsV2 = AddablePluginArgsV2 & + AuthorityArgsV2; + +export type FreezeDelegatePlugin = BasePlugin & FreezeDelegate; +export type BurnDelegatePlugin = BasePlugin & BurnDelegate; +export type TransferDelegatePlugin = BasePlugin & TransferDelegate; +export type UpdateDelegatePlugin = BasePlugin & UpdateDelegate; +export type PermanentFreezeDelegatePlugin = BasePlugin & + PermanentFreezeDelegate; +export type AttributesPlugin = BasePlugin & Attributes; +export type PermanentTransferDelegatePlugin = BasePlugin & + PermanentTransferDelegate; +export type PermanentBurnDelegatePlugin = BasePlugin & PermanentBurnDelegate; +export type EditionPlugin = BasePlugin & Edition; + +export type PluginsList = { + royalties?: RoyaltiesPlugin; + freezeDelegate?: FreezeDelegatePlugin; + burnDelegate?: BurnDelegatePlugin; + transferDelegate?: TransferDelegatePlugin; + updateDelegate?: UpdateDelegatePlugin; + attributes?: AttributesPlugin; + permanentFreezeDelegate?: PermanentFreezeDelegatePlugin; + permanentTransferDelegate?: PermanentTransferDelegatePlugin; + permanentBurnDelegate?: PermanentBurnDelegatePlugin; + edition?: EditionPlugin; +}; diff --git a/clients/js/src/plugins/updateAuthority.ts b/clients/js/src/plugins/updateAuthority.ts new file mode 100644 index 00000000..0de3d5c0 --- /dev/null +++ b/clients/js/src/plugins/updateAuthority.ts @@ -0,0 +1,21 @@ +import { PublicKey } from '@metaplex-foundation/umi'; +import { BaseUpdateAuthority } from '../generated'; + +export type UpdateAuthorityType = BaseUpdateAuthority['__kind']; + +export type UpdateAuthority = { + type: UpdateAuthorityType; + address?: PublicKey; +}; + +export function updateAuthorityToBase(u: UpdateAuthority): BaseUpdateAuthority { + if (u.type === 'None') { + return { + __kind: 'None', + }; + } + return { + __kind: u.type, + fields: [u.address as PublicKey], + }; +} diff --git a/clients/js/src/plugins/validationResultsOffset.ts b/clients/js/src/plugins/validationResultsOffset.ts new file mode 100644 index 00000000..8e35eb2e --- /dev/null +++ b/clients/js/src/plugins/validationResultsOffset.ts @@ -0,0 +1,36 @@ +import { BaseValidationResultsOffset } from '../generated'; + +export type ValidationResultsOffset = + | { type: 'NoOffset' } + | { type: 'Anchor' } + | { type: 'Custom'; offset: bigint }; + +export function validationResultsOffsetToBase( + e: ValidationResultsOffset +): BaseValidationResultsOffset { + if (e.type === 'Custom') { + return { + __kind: 'Custom', + fields: [e.offset], + }; + } + + return { + __kind: e.type, + }; +} + +export function validationResultsOffsetFromBase( + e: BaseValidationResultsOffset +): ValidationResultsOffset { + if (e.__kind === 'Custom') { + return { + type: 'Custom', + offset: e.fields[0], + }; + } + + return { + type: e.__kind, + }; +} diff --git a/clients/js/src/types.ts b/clients/js/src/types.ts deleted file mode 100644 index 1d26922a..00000000 --- a/clients/js/src/types.ts +++ /dev/null @@ -1,59 +0,0 @@ -import { PublicKey } from '@metaplex-foundation/umi'; -import { - PluginAuthority, - BurnDelegate, - FreezeDelegate, - PermanentFreezeDelegate, - Royalties, - TransferDelegate, - UpdateDelegate, - Attributes, - PermanentTransferDelegate, - UpdateAuthority, - PermanentBurnDelegate, - Edition, -} from './generated'; - -export type BasePluginAuthority = { - type: PluginAuthorityType; - address?: PublicKey; -}; - -export type BaseUpdateAuthority = { - type: UpdateAuthorityType; - address?: PublicKey; -}; - -export type UpdateAuthorityType = UpdateAuthority['__kind']; -export type PluginAuthorityType = PluginAuthority['__kind']; - -export type BasePlugin = { - authority: BasePluginAuthority; - offset?: bigint; -}; - -export type RoyaltiesPlugin = BasePlugin & Royalties; -export type FreezeDelegatePlugin = BasePlugin & FreezeDelegate; -export type BurnDelegatePlugin = BasePlugin & BurnDelegate; -export type TransferDelegatePlugin = BasePlugin & TransferDelegate; -export type UpdateDelegatePlugin = BasePlugin & UpdateDelegate; -export type PermanentFreezeDelegatePlugin = BasePlugin & - PermanentFreezeDelegate; -export type AttributesPlugin = BasePlugin & Attributes; -export type PermanentTransferDelegatePlugin = BasePlugin & - PermanentTransferDelegate; -export type PermanentBurnDelegatePlugin = BasePlugin & PermanentBurnDelegate; -export type EditionPlugin = BasePlugin & Edition; - -export type PluginsList = { - royalties?: RoyaltiesPlugin; - freezeDelegate?: FreezeDelegatePlugin; - burnDelegate?: BurnDelegatePlugin; - transferDelegate?: TransferDelegatePlugin; - updateDelegate?: UpdateDelegatePlugin; - attributes?: AttributesPlugin; - permanentFreezeDelegate?: PermanentFreezeDelegatePlugin; - permanentTransferDelegate?: PermanentTransferDelegatePlugin; - permanentBurnDelegate?: PermanentBurnDelegatePlugin; - edition?: EditionPlugin; -}; diff --git a/clients/js/src/utils.ts b/clients/js/src/utils.ts index 20b0414c..f00695b6 100644 --- a/clients/js/src/utils.ts +++ b/clients/js/src/utils.ts @@ -1,3 +1,13 @@ +export type RenameField = Omit< + T, + K +> & + (undefined extends T[K] ? { [P in R]?: T[K] } : { [P in R]: T[K] }); + +export type RenameToType = T extends T + ? RenameField + : never; + export function toWords(str: string) { const camelCaseRegex = /([a-z0-9])([A-Z])/g; return str.replace(camelCaseRegex, '$1 $2'); diff --git a/clients/js/test/_setup.ts b/clients/js/test/_setupRaw.ts similarity index 98% rename from clients/js/test/_setup.ts rename to clients/js/test/_setupRaw.ts index d39db174..4b6bb075 100644 --- a/clients/js/test/_setup.ts +++ b/clients/js/test/_setupRaw.ts @@ -20,7 +20,7 @@ import { AssetV1, PluginsList, PluginAuthorityPairArgs, - BaseUpdateAuthority, + UpdateAuthority, } from '../src'; export const createUmi = async () => (await basecreateUmi()).use(mplCore()); @@ -59,7 +59,7 @@ export const createAsset = async ( const updateAuthority = input.updateAuthority ? publicKey(input.updateAuthority) : undefined; - // const tx = + await createV1(umi, { owner, payer, @@ -140,7 +140,7 @@ export const assertAsset = async ( input: { asset: PublicKey | Signer; owner: PublicKey | Signer; - updateAuthority?: BaseUpdateAuthority; + updateAuthority?: UpdateAuthority; name?: string | RegExp; uri?: string | RegExp; } & PluginsList diff --git a/clients/js/test/_setupSdk.ts b/clients/js/test/_setupSdk.ts new file mode 100644 index 00000000..343df0ae --- /dev/null +++ b/clients/js/test/_setupSdk.ts @@ -0,0 +1,118 @@ +/* eslint-disable import/no-extraneous-dependencies */ +import { + PublicKey, + Signer, + Umi, + generateSigner, + publicKey, +} from '@metaplex-foundation/umi'; +import { + DataState, + fetchAssetV1, + fetchCollectionV1, + CollectionV1, + AssetV1, + PluginAuthorityPairArgsV2, + ExternalPluginInitInfoArgs, + create, + createCollection as baseCreateCollection, +} from '../src'; +import { DEFAULT_ASSET, DEFAULT_COLLECTION } from './_setupRaw'; + +export type CreateAssetHelperArgs = { + owner?: PublicKey | Signer; + payer?: Signer; + asset?: Signer; + dataState?: DataState; + name?: string; + uri?: string; + authority?: Signer; + updateAuthority?: PublicKey | Signer; + collection?: PublicKey | CollectionV1; + plugins?: (ExternalPluginInitInfoArgs | PluginAuthorityPairArgsV2)[]; +}; +export const createAsset = async ( + umi: Umi, + input: CreateAssetHelperArgs = {} +) => { + const payer = input.payer || umi.identity; + const owner = publicKey(input.owner || input.payer || umi.identity); + const asset = input.asset || generateSigner(umi); + const updateAuthority = input.updateAuthority + ? publicKey(input.updateAuthority) + : undefined; + + const col = (input.collection as PublicKey)?.__publicKey + ? await fetchCollectionV1(umi, input.collection as PublicKey) + : (input.collection as CollectionV1 | undefined); + + await create(umi, { + owner, + payer, + dataState: input.dataState, + asset, + updateAuthority, + name: input.name || DEFAULT_ASSET.name, + uri: input.uri || DEFAULT_ASSET.uri, + plugins: input.plugins, + collection: col, + authority: input.authority, + }).sendAndConfirm(umi); + + return fetchAssetV1(umi, publicKey(asset)); +}; + +export type CreateCollectionHelperArgs = { + payer?: Signer; + collection?: Signer; + name?: string; + uri?: string; + updateAuthority?: PublicKey | Signer; + plugins?: (ExternalPluginInitInfoArgs | PluginAuthorityPairArgsV2)[]; +}; + +export const createCollection = async ( + umi: Umi, + input: CreateCollectionHelperArgs = {} +) => { + const payer = input.payer || umi.identity; + const collection = input.collection || generateSigner(umi); + const updateAuthority = publicKey(input.updateAuthority || payer); + await baseCreateCollection(umi, { + name: input.name || DEFAULT_COLLECTION.name, + uri: input.uri || DEFAULT_COLLECTION.uri, + collection, + payer, + updateAuthority, + plugins: input.plugins, + }).sendAndConfirm(umi); + + return fetchCollectionV1(umi, publicKey(collection)); +}; + +export const createAssetWithCollection: ( + umi: Umi, + assetInput: CreateAssetHelperArgs & { collection?: PublicKey | Signer }, + collectionInput?: CreateCollectionHelperArgs +) => Promise<{ + asset: AssetV1; + collection: CollectionV1; +}> = async (umi, assetInput, collectionInput = {}) => { + const collection = assetInput.collection + ? await fetchCollectionV1(umi, publicKey(assetInput.collection)) + : await createCollection(umi, { + payer: assetInput.payer, + updateAuthority: assetInput.updateAuthority, + ...collectionInput, + }); + + const asset = await createAsset(umi, { + ...assetInput, + collection, + }); + + return { + asset, + collection, + }; +}; diff --git a/clients/js/test/addPlugin.test.ts b/clients/js/test/addPlugin.test.ts index 8b1e150c..b9f125bf 100644 --- a/clients/js/test/addPlugin.test.ts +++ b/clients/js/test/addPlugin.test.ts @@ -18,7 +18,7 @@ import { createAssetWithCollection, createCollection, createUmi, -} from './_setup'; +} from './_setupRaw'; test('it can add a plugin to an asset', async (t) => { // Given a Umi instance and a new signer. diff --git a/clients/js/test/approveAuthority.test.ts b/clients/js/test/approveAuthority.test.ts index 76557266..3bf4ae13 100644 --- a/clients/js/test/approveAuthority.test.ts +++ b/clients/js/test/approveAuthority.test.ts @@ -18,7 +18,7 @@ import { createAsset, createCollection, createUmi, -} from './_setup'; +} from './_setupRaw'; test('it can add an authority to a plugin', async (t) => { // Given a Umi instance and a new signer. diff --git a/clients/js/test/asset.test.ts b/clients/js/test/asset.test.ts index 7f9f990c..da64b9bf 100644 --- a/clients/js/test/asset.test.ts +++ b/clients/js/test/asset.test.ts @@ -1,7 +1,7 @@ import { generateSigner } from '@metaplex-foundation/umi'; import test from 'ava'; import { Key, getAssetV1GpaBuilder, updateAuthority } from '../src'; -import { createAsset, createCollection, createUmi } from './_setup'; +import { createAsset, createCollection, createUmi } from './_setupRaw'; test('it can gpa fetch assets by owner', async (t) => { // Given a Umi instance and a new signer. diff --git a/clients/js/test/burn.test.ts b/clients/js/test/burn.test.ts index 4ddad4d9..df366d42 100644 --- a/clients/js/test/burn.test.ts +++ b/clients/js/test/burn.test.ts @@ -15,7 +15,7 @@ import { createAssetWithCollection, createCollection, createUmi, -} from './_setup'; +} from './_setupRaw'; test('it can burn an asset as the owner', async (t) => { // Given a Umi instance and a new signer. diff --git a/clients/js/test/collect.test.ts b/clients/js/test/collect.test.ts index e3496cc0..d57611a8 100644 --- a/clients/js/test/collect.test.ts +++ b/clients/js/test/collect.test.ts @@ -16,7 +16,7 @@ import { pluginAuthorityPair, removePluginV1, } from '../src'; -import { createAsset, createUmi } from './_setup'; +import { createAsset, createUmi } from './_setupRaw'; const recipient1 = publicKey('8AT6o8Qk5T9QnZvPThMrF9bcCQLTGkyGvVZZzHgCw11v'); const recipient2 = publicKey('MmHsqX4LxTfifxoH8BVRLUKrwDn1LPCac6YcCZTHhwt'); diff --git a/clients/js/test/collection.test.ts b/clients/js/test/collection.test.ts index 259baa9b..770e9133 100644 --- a/clients/js/test/collection.test.ts +++ b/clients/js/test/collection.test.ts @@ -1,7 +1,7 @@ import { generateSigner } from '@metaplex-foundation/umi'; import test from 'ava'; import { Key, getCollectionV1GpaBuilder } from '../src'; -import { createUmi, createCollection } from './_setup'; +import { createUmi, createCollection } from './_setupRaw'; test('it can gpa fetch collections by updateAuthority', async (t) => { // Given a Umi instance and a new signer. diff --git a/clients/js/test/collectionSize.test.ts b/clients/js/test/collectionSize.test.ts index 3d7c248e..c085009e 100644 --- a/clients/js/test/collectionSize.test.ts +++ b/clients/js/test/collectionSize.test.ts @@ -1,6 +1,6 @@ import test from 'ava'; import { burnV1, fetchCollectionV1 } from '../src'; -import { createUmi, createCollection, createAsset } from './_setup'; +import { createUmi, createCollection, createAsset } from './_setupRaw'; test('it can burn an asset which is the part of a collection', async (t) => { // Given a Umi instance and a new signer. diff --git a/clients/js/test/compress.test.ts b/clients/js/test/compress.test.ts index dcd58985..7715b8b4 100644 --- a/clients/js/test/compress.test.ts +++ b/clients/js/test/compress.test.ts @@ -13,7 +13,7 @@ import { HashedAssetSchema, } from '../src'; -import { createAsset, createUmi } from './_setup'; +import { createAsset, createUmi } from './_setupRaw'; test.skip('it can compress an asset without any plugins as the owner', async (t) => { // Given a Umi instance and a new signer. diff --git a/clients/js/test/create.test.ts b/clients/js/test/create.test.ts index 8dcf0832..becf2118 100644 --- a/clients/js/test/create.test.ts +++ b/clients/js/test/create.test.ts @@ -16,7 +16,7 @@ import { createCollection, createUmi, DEFAULT_ASSET, -} from './_setup'; +} from './_setupRaw'; test('it can create a new asset in account state', async (t) => { // Given an Umi instance and a new signer. @@ -139,7 +139,7 @@ test('it can create a new asset in account state with plugins', async (t) => { authority: { type: 'Owner', }, - offset: BigInt(119), + offset: 119n, frozen: false, }, }); diff --git a/clients/js/test/createCollection.test.ts b/clients/js/test/createCollection.test.ts index c1050d6f..15578446 100644 --- a/clients/js/test/createCollection.test.ts +++ b/clients/js/test/createCollection.test.ts @@ -16,7 +16,7 @@ import { createAssetWithCollection, createCollection, createUmi, -} from './_setup'; +} from './_setupRaw'; test('it can create a new collection', async (t) => { // Given a Umi instance and a new signer. diff --git a/clients/js/test/decompress.test.ts b/clients/js/test/decompress.test.ts index 63cdbcd6..055dafa1 100644 --- a/clients/js/test/decompress.test.ts +++ b/clients/js/test/decompress.test.ts @@ -14,7 +14,7 @@ import { HashedAssetSchema, updateAuthority, } from '../src'; -import { createUmi } from './_setup'; +import { createUmi } from './_setupRaw'; test.skip('it can decompress a previously compressed asset as the owner', async (t) => { // Given a Umi instance and a new signer. diff --git a/clients/js/test/getProgram.test.ts b/clients/js/test/getProgram.test.ts index 593c501e..8721654c 100644 --- a/clients/js/test/getProgram.test.ts +++ b/clients/js/test/getProgram.test.ts @@ -1,6 +1,6 @@ import test from 'ava'; import { MPL_CORE_PROGRAM_ID } from '../src'; -import { createUmi } from './_setup'; +import { createUmi } from './_setupRaw'; test('it registers the program', async (t) => { // Given a Umi instance using the project's plugin. diff --git a/clients/js/test/helps/authority.test.ts b/clients/js/test/helps/authority.test.ts index d7fd14bb..3aad723f 100644 --- a/clients/js/test/helps/authority.test.ts +++ b/clients/js/test/helps/authority.test.ts @@ -10,7 +10,7 @@ import { createAssetWithCollection, createCollection, createUmi, -} from '../_setup'; +} from '../_setupRaw'; test('it throws when not matching asset and collection', async (t) => { const umi = await createUmi(); diff --git a/clients/js/test/helps/lifecycle.test.ts b/clients/js/test/helps/lifecycle.test.ts index 1fc38975..3b42ed1b 100644 --- a/clients/js/test/helps/lifecycle.test.ts +++ b/clients/js/test/helps/lifecycle.test.ts @@ -6,7 +6,11 @@ import { canTransfer, pluginAuthorityPair, } from '../../src'; -import { createAsset, createAssetWithCollection, createUmi } from '../_setup'; +import { + createAsset, + createAssetWithCollection, + createUmi, +} from '../_setupRaw'; test('it can detect transferrable on basic asset', async (t) => { const umi = await createUmi(); diff --git a/clients/js/test/helps/plugin.test.ts b/clients/js/test/helps/plugin.test.ts index a430b54b..7e5601bf 100644 --- a/clients/js/test/helps/plugin.test.ts +++ b/clients/js/test/helps/plugin.test.ts @@ -10,7 +10,7 @@ import { pluginTypeFromAssetPluginKey, updatePluginAuthority, } from '../../src'; -import { createAssetWithCollection, createUmi } from '../_setup'; +import { createAssetWithCollection, createUmi } from '../_setupRaw'; test('it can convert plugin key to plugin type', async (t) => { const key: AssetPluginKey = 'royalties'; diff --git a/clients/js/test/helps/state.test.ts b/clients/js/test/helps/state.test.ts index 3fad7816..3f82c6bf 100644 --- a/clients/js/test/helps/state.test.ts +++ b/clients/js/test/helps/state.test.ts @@ -1,6 +1,10 @@ import test from 'ava'; import { isFrozen, pluginAuthorityPair } from '../../src'; -import { createAsset, createAssetWithCollection, createUmi } from '../_setup'; +import { + createAsset, + createAssetWithCollection, + createUmi, +} from '../_setupRaw'; test('it can detect frozen from freeze delegate', async (t) => { const umi = await createUmi(); diff --git a/clients/js/test/info.test.ts b/clients/js/test/info.test.ts index b72a8b9b..692eaca9 100644 --- a/clients/js/test/info.test.ts +++ b/clients/js/test/info.test.ts @@ -1,7 +1,7 @@ import { generateSigner, publicKey } from '@metaplex-foundation/umi'; import test from 'ava'; import { DataState, createV1 /* fetchAsset, fetchHashedAsset */ } from '../src'; -import { createUmi } from './_setup'; +import { createUmi } from './_setupRaw'; test('fetch account info for account state', async (t) => { // Given a Umi instance and a new signer. diff --git a/clients/js/test/instructions/freeze.test.ts b/clients/js/test/instructions/freeze.test.ts index e29ea6d7..fcd7a7a1 100644 --- a/clients/js/test/instructions/freeze.test.ts +++ b/clients/js/test/instructions/freeze.test.ts @@ -12,7 +12,7 @@ import { createAsset, createAssetWithCollection, createUmi, -} from '../_setup'; +} from '../_setupRaw'; test('it can use the freeze helper to freeze an asset', async (t) => { const umi = await createUmi(); diff --git a/clients/js/test/instructions/legacyDelegate.test.ts b/clients/js/test/instructions/legacyDelegate.test.ts index fe0af251..b97c10ed 100644 --- a/clients/js/test/instructions/legacyDelegate.test.ts +++ b/clients/js/test/instructions/legacyDelegate.test.ts @@ -1,6 +1,6 @@ import test from 'ava'; import { generateSigner } from '@metaplex-foundation/umi'; -import { assertAsset, createAsset, createUmi } from '../_setup'; +import { assertAsset, createAsset, createUmi } from '../_setupRaw'; import { addressPluginAuthority, pluginAuthorityPair, diff --git a/clients/js/test/instructions/legacyRevoke.test.ts b/clients/js/test/instructions/legacyRevoke.test.ts index 2aedc7f6..c98baa2d 100644 --- a/clients/js/test/instructions/legacyRevoke.test.ts +++ b/clients/js/test/instructions/legacyRevoke.test.ts @@ -1,6 +1,6 @@ import test from 'ava'; import { generateSigner } from '@metaplex-foundation/umi'; -import { assertAsset, createAsset, createUmi } from '../_setup'; +import { assertAsset, createAsset, createUmi } from '../_setupRaw'; import { pluginAuthorityPair, addressPluginAuthority, diff --git a/clients/js/test/plugins/asset/attributes.test.ts b/clients/js/test/plugins/asset/attributes.test.ts index 4a5aef3a..c8792a4d 100644 --- a/clients/js/test/plugins/asset/attributes.test.ts +++ b/clients/js/test/plugins/asset/attributes.test.ts @@ -9,7 +9,7 @@ import { assertAsset, createAsset, createUmi, -} from '../../_setup'; +} from '../../_setupRaw'; test('it can add attributes to an asset', async (t) => { // Given a Umi instance and a new signer. diff --git a/clients/js/test/plugins/asset/delegate.test.ts b/clients/js/test/plugins/asset/delegate.test.ts index 422a92d7..723cf735 100644 --- a/clients/js/test/plugins/asset/delegate.test.ts +++ b/clients/js/test/plugins/asset/delegate.test.ts @@ -13,7 +13,7 @@ import { assertAsset, createAsset, createUmi, -} from '../../_setup'; +} from '../../_setupRaw'; test('it can delegate a new authority', async (t) => { // Given a Umi instance and a new signer. diff --git a/clients/js/test/plugins/asset/delegateTransfer.test.ts b/clients/js/test/plugins/asset/delegateTransfer.test.ts index 99415273..42601f9b 100644 --- a/clients/js/test/plugins/asset/delegateTransfer.test.ts +++ b/clients/js/test/plugins/asset/delegateTransfer.test.ts @@ -13,7 +13,7 @@ import { assertAsset, createAsset, createUmi, -} from '../../_setup'; +} from '../../_setupRaw'; test('a delegate can transfer the asset', async (t) => { // Given a Umi instance and a new signer. diff --git a/clients/js/test/plugins/asset/edition.test.ts b/clients/js/test/plugins/asset/edition.test.ts index 382c9c9f..932acce7 100644 --- a/clients/js/test/plugins/asset/edition.test.ts +++ b/clients/js/test/plugins/asset/edition.test.ts @@ -17,7 +17,7 @@ import { createAsset, createCollection, createUmi, -} from '../../_setup'; +} from '../../_setupRaw'; test('it can create asset with edition plugin', async (t) => { const umi = await createUmi(); diff --git a/clients/js/test/plugins/asset/freeze.test.ts b/clients/js/test/plugins/asset/freeze.test.ts index ece446e1..fa6f0f7e 100644 --- a/clients/js/test/plugins/asset/freeze.test.ts +++ b/clients/js/test/plugins/asset/freeze.test.ts @@ -17,7 +17,7 @@ import { assertAsset, createAsset, createUmi, -} from '../../_setup'; +} from '../../_setupRaw'; test('it can freeze and unfreeze an asset', async (t) => { // Given a Umi instance and a new signer. diff --git a/clients/js/test/plugins/asset/permanentBurn.test.ts b/clients/js/test/plugins/asset/permanentBurn.test.ts index 536aa739..ec7b0ae4 100644 --- a/clients/js/test/plugins/asset/permanentBurn.test.ts +++ b/clients/js/test/plugins/asset/permanentBurn.test.ts @@ -20,7 +20,7 @@ import { createAsset, createCollection, createUmi, -} from '../../_setup'; +} from '../../_setupRaw'; test('it can burn an assets as an owner', async (t) => { // Given a Umi instance and a new signer. diff --git a/clients/js/test/plugins/asset/permanentFreeze.test.ts b/clients/js/test/plugins/asset/permanentFreeze.test.ts index 438b7ab8..62bcbd30 100644 --- a/clients/js/test/plugins/asset/permanentFreeze.test.ts +++ b/clients/js/test/plugins/asset/permanentFreeze.test.ts @@ -15,7 +15,7 @@ import { createAsset, createAssetWithCollection, createUmi, -} from '../../_setup'; +} from '../../_setupRaw'; test('it can freeze and unfreeze an asset', async (t) => { // Given a Umi instance and a new signer. diff --git a/clients/js/test/plugins/asset/permanentTransfer.test.ts b/clients/js/test/plugins/asset/permanentTransfer.test.ts index 1c8f2df3..fe5f817f 100644 --- a/clients/js/test/plugins/asset/permanentTransfer.test.ts +++ b/clients/js/test/plugins/asset/permanentTransfer.test.ts @@ -19,7 +19,7 @@ import { createAssetWithCollection, createCollection, createUmi, -} from '../../_setup'; +} from '../../_setupRaw'; test('it cannot add permanentTransfer after creation', async (t) => { // Given a Umi instance and a new signer. diff --git a/clients/js/test/plugins/asset/royalties.test.ts b/clients/js/test/plugins/asset/royalties.test.ts index 1b7cb0b7..7f134c9c 100644 --- a/clients/js/test/plugins/asset/royalties.test.ts +++ b/clients/js/test/plugins/asset/royalties.test.ts @@ -21,7 +21,7 @@ import { createAsset, createAssetWithCollection, createUmi, -} from '../../_setup'; +} from '../../_setupRaw'; test('it can transfer an asset with royalties', async (t) => { // Given a Umi instance and a new signer. diff --git a/clients/js/test/plugins/asset/updateDelegate.test.ts b/clients/js/test/plugins/asset/updateDelegate.test.ts index 53b32096..15a72822 100644 --- a/clients/js/test/plugins/asset/updateDelegate.test.ts +++ b/clients/js/test/plugins/asset/updateDelegate.test.ts @@ -15,7 +15,7 @@ import { assertAsset, createAsset, createUmi, -} from '../../_setup'; +} from '../../_setupRaw'; test('it can create an asset with updateDelegate', async (t) => { const umi = await createUmi(); diff --git a/clients/js/test/plugins/collection/permanentBurn.test.ts b/clients/js/test/plugins/collection/permanentBurn.test.ts index 59c4789f..96e68b60 100644 --- a/clients/js/test/plugins/collection/permanentBurn.test.ts +++ b/clients/js/test/plugins/collection/permanentBurn.test.ts @@ -12,7 +12,7 @@ import { assertCollection, createCollection, createUmi, -} from '../../_setup'; +} from '../../_setupRaw'; test('it can add permanentBurnDelegate to collection', async (t) => { const umi = await createUmi(); diff --git a/clients/js/test/plugins/collection/permanentFreeze.test.ts b/clients/js/test/plugins/collection/permanentFreeze.test.ts index 7439f631..8d2f32d0 100644 --- a/clients/js/test/plugins/collection/permanentFreeze.test.ts +++ b/clients/js/test/plugins/collection/permanentFreeze.test.ts @@ -12,7 +12,7 @@ import { assertCollection, createCollection, createUmi, -} from '../../_setup'; +} from '../../_setupRaw'; test('it can add permanentFreezeDelegate to collection', async (t) => { const umi = await createUmi(); diff --git a/clients/js/test/plugins/collection/permanentTransfer.test.ts b/clients/js/test/plugins/collection/permanentTransfer.test.ts index f464d969..9f859b6a 100644 --- a/clients/js/test/plugins/collection/permanentTransfer.test.ts +++ b/clients/js/test/plugins/collection/permanentTransfer.test.ts @@ -13,7 +13,7 @@ import { createCollection, createUmi, DEFAULT_COLLECTION, -} from '../../_setup'; +} from '../../_setupRaw'; test('it can add permanentTransferDelegate to collection', async (t) => { const umi = await createUmi(); diff --git a/clients/js/test/plugins/collection/updateDelegate.test.ts b/clients/js/test/plugins/collection/updateDelegate.test.ts index b7fed683..a4044136 100644 --- a/clients/js/test/plugins/collection/updateDelegate.test.ts +++ b/clients/js/test/plugins/collection/updateDelegate.test.ts @@ -20,7 +20,7 @@ import { createAsset, createCollection, createUmi, -} from '../../_setup'; +} from '../../_setupRaw'; test('it can create a new asset with a collection if it is the collection updateDelegate', async (t) => { // Given a Umi instance and a new signer. diff --git a/clients/js/test/removePlugin.test.ts b/clients/js/test/removePlugin.test.ts index 24dd43aa..2e74e930 100644 --- a/clients/js/test/removePlugin.test.ts +++ b/clients/js/test/removePlugin.test.ts @@ -20,7 +20,7 @@ import { createAssetWithCollection, createCollection, createUmi, -} from './_setup'; +} from './_setupRaw'; test('it can remove a plugin from an asset', async (t) => { // Given a Umi instance and a new signer. diff --git a/clients/js/test/revokeAuthority.test.ts b/clients/js/test/revokeAuthority.test.ts index 4484cfb3..76ef6136 100644 --- a/clients/js/test/revokeAuthority.test.ts +++ b/clients/js/test/revokeAuthority.test.ts @@ -17,7 +17,7 @@ import { createAsset, createCollection, createUmi, -} from './_setup'; +} from './_setupRaw'; test('it can remove an authority from a plugin', async (t) => { // Given a Umi instance and a new signer. diff --git a/clients/js/test/sdkv1.test.ts b/clients/js/test/sdkv1.test.ts new file mode 100644 index 00000000..0db0a8d0 --- /dev/null +++ b/clients/js/test/sdkv1.test.ts @@ -0,0 +1,904 @@ +import { assertAccountExists, generateSigner } from '@metaplex-foundation/umi'; +import test from 'ava'; +import { + AddablePluginAuthorityPairArgsV2, + addPlugin, + burn, + Key, + PluginArgsV2, + removePlugin, + transfer, + update, + updateCollection, + updateCollectionPlugin, + updatePlugin, +} from '../src'; +import { + createAsset, + createAssetWithCollection, + createCollection, +} from './_setupSdk'; +import { + assertAsset, + assertCollection, + createUmi, + DEFAULT_ASSET, + DEFAULT_COLLECTION, +} from './_setupRaw'; + +test('it can create asset and collection with all update auth managed party plugins', async (t) => { + const umi = await createUmi(); + const owner = generateSigner(umi); + + const collection = await createCollection(umi, { + plugins: [ + { + type: 'Royalties', + basisPoints: 500, + creators: [ + { + address: owner.publicKey, + percentage: 100, + }, + ], + ruleSet: { + type: 'ProgramDenyList', + addresses: [owner.publicKey], + }, + authority: { + type: 'Address', + address: owner.publicKey, + }, + }, + { + type: 'PermanentBurnDelegate', + authority: { + type: 'None', + }, + }, + { + type: 'PermanentFreezeDelegate', + frozen: false, + }, + { + type: 'PermanentTransferDelegate', + authority: { + type: 'UpdateAuthority', + }, + }, + { + type: 'Attributes', + attributeList: [ + { + key: '123', + value: '456', + }, + ], + }, + ], + }); + + await assertCollection(t, umi, { + ...DEFAULT_COLLECTION, + collection: collection.publicKey, + royalties: { + basisPoints: 500, + creators: [ + { + address: owner.publicKey, + percentage: 100, + }, + ], + ruleSet: { + type: 'ProgramDenyList', + addresses: [owner.publicKey], + }, + authority: { + type: 'Address', + address: owner.publicKey, + }, + }, + permanentBurnDelegate: { + authority: { + type: 'None', + }, + }, + permanentFreezeDelegate: { + frozen: false, + authority: { + type: 'UpdateAuthority', + }, + }, + permanentTransferDelegate: { + authority: { + type: 'UpdateAuthority', + }, + }, + attributes: { + attributeList: [ + { + key: '123', + value: '456', + }, + ], + authority: { + type: 'UpdateAuthority', + }, + }, + }); + + const asset = await createAsset(umi, { + owner, + collection, + plugins: [ + { + type: 'Edition', + authority: { + type: 'UpdateAuthority', + }, + number: 1, + }, + { + type: 'Royalties', + basisPoints: 500, + creators: [ + { + address: owner.publicKey, + percentage: 100, + }, + ], + ruleSet: { + type: 'ProgramDenyList', + addresses: [owner.publicKey], + }, + authority: { + type: 'Address', + address: owner.publicKey, + }, + }, + { + type: 'PermanentBurnDelegate', + authority: { + type: 'None', + }, + }, + { + type: 'PermanentFreezeDelegate', + frozen: false, + }, + { + type: 'PermanentTransferDelegate', + authority: { + type: 'UpdateAuthority', + }, + }, + { + type: 'Attributes', + attributeList: [ + { + key: '123', + value: '456', + }, + ], + }, + ], + }); + + await assertAsset(t, umi, { + asset: asset.publicKey, + owner: owner.publicKey, + updateAuthority: { + type: 'Collection', + address: collection.publicKey, + }, + edition: { + number: 1, + authority: { + type: 'UpdateAuthority', + }, + }, + royalties: { + basisPoints: 500, + creators: [ + { + address: owner.publicKey, + percentage: 100, + }, + ], + ruleSet: { + type: 'ProgramDenyList', + addresses: [owner.publicKey], + }, + authority: { + type: 'Address', + address: owner.publicKey, + }, + }, + permanentBurnDelegate: { + authority: { + type: 'None', + }, + }, + permanentFreezeDelegate: { + frozen: false, + authority: { + type: 'UpdateAuthority', + }, + }, + permanentTransferDelegate: { + authority: { + type: 'UpdateAuthority', + }, + }, + attributes: { + attributeList: [ + { + key: '123', + value: '456', + }, + ], + authority: { + type: 'UpdateAuthority', + }, + }, + }); +}); + +test('it can create all owner and update auth managed party plugins to asset', async (t) => { + const umi = await createUmi(); + + const asset = await createAsset(umi, { + plugins: [ + { + type: 'Royalties', + basisPoints: 500, + creators: [ + { + address: umi.identity.publicKey, + percentage: 100, + }, + ], + ruleSet: { + type: 'ProgramDenyList', + addresses: [umi.identity.publicKey], + }, + authority: { + type: 'Address', + address: umi.identity.publicKey, + }, + }, + { + type: 'PermanentBurnDelegate', + authority: { + type: 'None', + }, + }, + { + type: 'PermanentFreezeDelegate', + frozen: false, + }, + { + type: 'PermanentTransferDelegate', + authority: { + type: 'UpdateAuthority', + }, + }, + { + type: 'Attributes', + attributeList: [ + { + key: '123', + value: '456', + }, + ], + }, + { + type: 'Edition', + number: 1, + authority: { + type: 'UpdateAuthority', + }, + }, + { + type: 'FreezeDelegate', + frozen: false, + }, + { + type: 'BurnDelegate', + authority: { + type: 'None', + }, + }, + { + type: 'TransferDelegate', + authority: { + type: 'UpdateAuthority', + }, + }, + ], + }); + + await assertAsset(t, umi, { + asset: asset.publicKey, + owner: umi.identity.publicKey, + royalties: { + basisPoints: 500, + creators: [ + { + address: umi.identity.publicKey, + percentage: 100, + }, + ], + ruleSet: { + type: 'ProgramDenyList', + addresses: [umi.identity.publicKey], + }, + authority: { + type: 'Address', + address: umi.identity.publicKey, + }, + }, + permanentBurnDelegate: { + authority: { + type: 'None', + }, + }, + permanentFreezeDelegate: { + frozen: false, + authority: { + type: 'UpdateAuthority', + }, + }, + permanentTransferDelegate: { + authority: { + type: 'UpdateAuthority', + }, + }, + attributes: { + attributeList: [ + { + key: '123', + value: '456', + }, + ], + authority: { + type: 'UpdateAuthority', + }, + }, + edition: { + number: 1, + authority: { + type: 'UpdateAuthority', + }, + }, + freezeDelegate: { + frozen: false, + authority: { + type: 'Owner', + }, + }, + burnDelegate: { + authority: { + type: 'None', + }, + }, + transferDelegate: { + authority: { + type: 'UpdateAuthority', + }, + }, + }); +}); + +test('it can add and remove all owner and update auth managed party plugins to asset', async (t) => { + const umi = await createUmi(); + const asset = await createAsset(umi); + + const plugins: AddablePluginAuthorityPairArgsV2[] = [ + { + type: 'Royalties', + basisPoints: 500, + creators: [ + { + address: umi.identity.publicKey, + percentage: 100, + }, + ], + ruleSet: { + type: 'ProgramDenyList', + addresses: [umi.identity.publicKey], + }, + authority: { + type: 'Address', + address: umi.identity.publicKey, + }, + }, + { + type: 'Attributes', + attributeList: [ + { + key: '123', + value: '456', + }, + ], + }, + { + type: 'FreezeDelegate', + frozen: false, + }, + { + type: 'BurnDelegate', + authority: { + type: 'None', + }, + }, + { + type: 'TransferDelegate', + authority: { + type: 'UpdateAuthority', + }, + }, + ]; + + await Promise.all( + plugins.map(async (plugin) => + addPlugin(umi, { + asset: asset.publicKey, + plugin, + }).sendAndConfirm(umi) + ) + ); + + await assertAsset(t, umi, { + asset: asset.publicKey, + owner: umi.identity.publicKey, + royalties: { + basisPoints: 500, + creators: [ + { + address: umi.identity.publicKey, + percentage: 100, + }, + ], + ruleSet: { + type: 'ProgramDenyList', + addresses: [umi.identity.publicKey], + }, + authority: { + type: 'Address', + address: umi.identity.publicKey, + }, + }, + attributes: { + attributeList: [ + { + key: '123', + value: '456', + }, + ], + authority: { + type: 'UpdateAuthority', + }, + }, + freezeDelegate: { + frozen: false, + authority: { + type: 'Owner', + }, + }, + burnDelegate: { + authority: { + type: 'None', + }, + }, + transferDelegate: { + authority: { + type: 'UpdateAuthority', + }, + }, + }); + + await Promise.all( + plugins.map(async (plugin) => + removePlugin(umi, { + asset: asset.publicKey, + plugin, + }).sendAndConfirm(umi) + ) + ); + + await assertAsset(t, umi, { + ...DEFAULT_ASSET, + asset: asset.publicKey, + owner: umi.identity.publicKey, + attributes: undefined, + royalties: undefined, + freezeDelegate: undefined, + burnDelegate: undefined, + transferDelegate: undefined, + }); +}); + +test('it can update all updatable plugins on asset', async (t) => { + const umi = await createUmi(); + const asset = await createAsset(umi, { + plugins: [ + { + type: 'Royalties', + basisPoints: 500, + creators: [ + { + address: umi.identity.publicKey, + percentage: 100, + }, + ], + ruleSet: { + type: 'ProgramDenyList', + addresses: [umi.identity.publicKey], + }, + }, + { + type: 'Attributes', + attributeList: [ + { + key: '123', + value: '456', + }, + ], + }, + { + type: 'FreezeDelegate', + frozen: false, + }, + { + type: 'PermanentFreezeDelegate', + frozen: false, + }, + { + type: 'Edition', + number: 1, + }, + ], + }); + + const updates: PluginArgsV2[] = [ + { + type: 'Royalties', + basisPoints: 1000, + creators: [ + { + address: umi.identity.publicKey, + percentage: 100, + }, + ], + ruleSet: { + type: 'ProgramAllowList', + addresses: [umi.identity.publicKey], + }, + }, + { + type: 'Attributes', + attributeList: [ + { + key: 'abc', + value: 'xyz', + }, + ], + }, + { + type: 'FreezeDelegate', + frozen: true, + }, + { + type: 'PermanentFreezeDelegate', + frozen: true, + }, + { + type: 'Edition', + number: 2, + }, + ]; + + await Promise.all( + updates.map(async (plugin) => + updatePlugin(umi, { + asset: asset.publicKey, + plugin, + }).sendAndConfirm(umi) + ) + ); + + await assertAsset(t, umi, { + asset: asset.publicKey, + owner: umi.identity.publicKey, + royalties: { + basisPoints: 1000, + creators: [ + { + address: umi.identity.publicKey, + percentage: 100, + }, + ], + ruleSet: { + type: 'ProgramAllowList', + addresses: [umi.identity.publicKey], + }, + authority: { + type: 'UpdateAuthority', + }, + }, + attributes: { + attributeList: [ + { + key: 'abc', + value: 'xyz', + }, + ], + authority: { + type: 'UpdateAuthority', + }, + }, + freezeDelegate: { + frozen: true, + authority: { + type: 'Owner', + }, + }, + permanentFreezeDelegate: { + frozen: true, + authority: { + type: 'UpdateAuthority', + }, + }, + edition: { + number: 2, + authority: { + type: 'UpdateAuthority', + }, + }, + }); +}); + +test('it can update all updatable plugins on collection', async (t) => { + const umi = await createUmi(); + const collection = await createCollection(umi, { + plugins: [ + { + type: 'Royalties', + basisPoints: 500, + creators: [ + { + address: umi.identity.publicKey, + percentage: 100, + }, + ], + ruleSet: { + type: 'ProgramDenyList', + addresses: [umi.identity.publicKey], + }, + }, + { + type: 'Attributes', + attributeList: [ + { + key: '123', + value: '456', + }, + ], + }, + { + type: 'PermanentFreezeDelegate', + frozen: false, + }, + ], + }); + + const updates: PluginArgsV2[] = [ + { + type: 'Royalties', + basisPoints: 1000, + creators: [ + { + address: umi.identity.publicKey, + percentage: 100, + }, + ], + ruleSet: { + type: 'ProgramAllowList', + addresses: [umi.identity.publicKey], + }, + }, + { + type: 'Attributes', + attributeList: [ + { + key: 'abc', + value: 'xyz', + }, + ], + }, + { + type: 'PermanentFreezeDelegate', + frozen: true, + }, + ]; + + await Promise.all( + updates.map(async (plugin) => + updateCollectionPlugin(umi, { + collection: collection.publicKey, + plugin, + }).sendAndConfirm(umi) + ) + ); + + await assertCollection(t, umi, { + collection: collection.publicKey, + royalties: { + basisPoints: 1000, + creators: [ + { + address: umi.identity.publicKey, + percentage: 100, + }, + ], + ruleSet: { + type: 'ProgramAllowList', + addresses: [umi.identity.publicKey], + }, + authority: { + type: 'UpdateAuthority', + }, + }, + attributes: { + attributeList: [ + { + key: 'abc', + value: 'xyz', + }, + ], + authority: { + type: 'UpdateAuthority', + }, + }, + permanentFreezeDelegate: { + frozen: true, + authority: { + type: 'UpdateAuthority', + }, + }, + }); +}); + +test('it can transfer asset', async (t) => { + const umi = await createUmi(); + const owner = generateSigner(umi); + const newOwner = generateSigner(umi); + const asset = await createAsset(umi, { + owner, + plugins: [ + { + type: 'Edition', + number: 1, + }, + ], + }); + + await transfer(umi, { + asset, + newOwner: newOwner.publicKey, + authority: owner, + }).sendAndConfirm(umi); + + await assertAsset(t, umi, { + asset: asset.publicKey, + owner: newOwner.publicKey, + edition: { + number: 1, + authority: { + type: 'UpdateAuthority', + }, + }, + }); +}); + +test('it can transfer asset in collection', async (t) => { + const umi = await createUmi(); + const owner = generateSigner(umi); + const newOwner = generateSigner(umi); + const { asset, collection } = await createAssetWithCollection(umi, { + owner, + plugins: [ + { + type: 'Edition', + number: 1, + }, + ], + }); + + await transfer(umi, { + asset, + collection, + newOwner: newOwner.publicKey, + authority: owner, + }).sendAndConfirm(umi); + + await assertAsset(t, umi, { + asset: asset.publicKey, + owner: newOwner.publicKey, + updateAuthority: { + type: 'Collection', + address: collection.publicKey, + }, + edition: { + number: 1, + authority: { + type: 'UpdateAuthority', + }, + }, + }); +}); + +test('it can update asset', async (t) => { + const umi = await createUmi(); + const asset = await createAsset(umi, {}); + + await update(umi, { + asset, + name: 'bleh', + }).sendAndConfirm(umi); + + await assertAsset(t, umi, { + ...DEFAULT_ASSET, + asset: asset.publicKey, + owner: umi.identity.publicKey, + name: 'bleh', + }); +}); + +test('it can update collection', async (t) => { + const umi = await createUmi(); + const collection = await createCollection(umi, {}); + + await updateCollection(umi, { + collection: collection.publicKey, + name: 'bleh', + }).sendAndConfirm(umi); + + await assertCollection(t, umi, { + ...DEFAULT_COLLECTION, + collection: collection.publicKey, + name: 'bleh', + }); +}); + +test('it can burn asset', async (t) => { + const umi = await createUmi(); + const asset = await createAsset(umi, {}); + + await burn(umi, { + asset, + }).sendAndConfirm(umi); + + const afterAsset = await umi.rpc.getAccount(asset.publicKey); + t.true(afterAsset.exists); + assertAccountExists(afterAsset); + t.is(afterAsset.data.length, 1); + t.is(afterAsset.data[0], Key.Uninitialized); +}); + +test('it can burn asset in collection', async (t) => { + const umi = await createUmi(); + const { asset, collection } = await createAssetWithCollection(umi, {}); + + await burn(umi, { + asset, + collection, + }).sendAndConfirm(umi); + + const afterAsset = await umi.rpc.getAccount(asset.publicKey); + t.true(afterAsset.exists); + assertAccountExists(afterAsset); + t.is(afterAsset.data.length, 1); + t.is(afterAsset.data[0], Key.Uninitialized); +}); diff --git a/clients/js/test/signers/burn.test.ts b/clients/js/test/signers/burn.test.ts index dce4f0c5..abc016a4 100644 --- a/clients/js/test/signers/burn.test.ts +++ b/clients/js/test/signers/burn.test.ts @@ -6,7 +6,7 @@ import { } from '@metaplex-foundation/umi'; import { createUmi } from '@metaplex-foundation/umi-bundle-tests'; import test from 'ava'; -import { assertAsset, createAsset } from '../_setup'; +import { assertAsset, createAsset } from '../_setupRaw'; import { Key, burnV1 } from '../../src'; test('it can burn an asset as the owner', async (t) => { diff --git a/clients/js/test/signers/create.test.ts b/clients/js/test/signers/create.test.ts index a9b63b08..e3d61351 100644 --- a/clients/js/test/signers/create.test.ts +++ b/clients/js/test/signers/create.test.ts @@ -5,7 +5,7 @@ import { } from '@metaplex-foundation/umi'; import { createUmi } from '@metaplex-foundation/umi-bundle-tests'; import test from 'ava'; -import { DEFAULT_ASSET, assertAsset } from '../_setup'; +import { DEFAULT_ASSET, assertAsset } from '../_setupRaw'; import { createV1 } from '../../src'; test('it can create a new asset', async (t) => { diff --git a/clients/js/test/signers/createCollection.test.ts b/clients/js/test/signers/createCollection.test.ts index 1d6d4ff0..7d02ca6a 100644 --- a/clients/js/test/signers/createCollection.test.ts +++ b/clients/js/test/signers/createCollection.test.ts @@ -5,7 +5,7 @@ import { } from '@metaplex-foundation/umi'; import { createUmi } from '@metaplex-foundation/umi-bundle-tests'; import test from 'ava'; -import { DEFAULT_COLLECTION, assertCollection } from '../_setup'; +import { DEFAULT_COLLECTION, assertCollection } from '../_setupRaw'; import { createCollectionV1 } from '../../src'; test('it can create a new asset', async (t) => { diff --git a/clients/js/test/signers/transfer.test.ts b/clients/js/test/signers/transfer.test.ts index af7f87ad..f81cb64e 100644 --- a/clients/js/test/signers/transfer.test.ts +++ b/clients/js/test/signers/transfer.test.ts @@ -5,7 +5,7 @@ import { } from '@metaplex-foundation/umi'; import { createUmi } from '@metaplex-foundation/umi-bundle-tests'; import test from 'ava'; -import { assertAsset, createAsset } from '../_setup'; +import { assertAsset, createAsset } from '../_setupRaw'; import { transferV1 } from '../../src'; test('it can transfer an asset as the owner', async (t) => { diff --git a/clients/js/test/signers/update.test.ts b/clients/js/test/signers/update.test.ts index 07c34ab8..319b9488 100644 --- a/clients/js/test/signers/update.test.ts +++ b/clients/js/test/signers/update.test.ts @@ -6,7 +6,7 @@ import { } from '@metaplex-foundation/umi'; import { createUmi } from '@metaplex-foundation/umi-bundle-tests'; import test from 'ava'; -import { DEFAULT_ASSET, assertAsset, createAsset } from '../_setup'; +import { DEFAULT_ASSET, assertAsset, createAsset } from '../_setupRaw'; import { updateV1 } from '../../src'; test('it can update an asset as the update authority', async (t) => { diff --git a/clients/js/test/transfer.test.ts b/clients/js/test/transfer.test.ts index ecb3cfd8..02588e1f 100644 --- a/clients/js/test/transfer.test.ts +++ b/clients/js/test/transfer.test.ts @@ -8,7 +8,7 @@ import { createAssetWithCollection, createCollection, createUmi, -} from './_setup'; +} from './_setupRaw'; test('it can transfer an asset as the owner', async (t) => { // Given a Umi instance and a new signer. @@ -148,7 +148,7 @@ test('authorities on owner-managed plugins are reset on transfer', async (t) => type: 'Address', address: freezeDelegate.publicKey, }, - offset: BigInt(119), + offset: 119n, frozen: false, }, }); @@ -166,7 +166,7 @@ test('authorities on owner-managed plugins are reset on transfer', async (t) => authority: { type: 'Owner', }, - offset: BigInt(119), + offset: 119n, frozen: false, }, }); @@ -199,7 +199,7 @@ test('authorities on permanent plugins should not be reset on transfer', async ( type: 'Address', address: freezeDelegate.publicKey, }, - offset: BigInt(119), + offset: 119n, frozen: false, }, }); @@ -218,7 +218,7 @@ test('authorities on permanent plugins should not be reset on transfer', async ( type: 'Address', address: freezeDelegate.publicKey, }, - offset: BigInt(119), + offset: 119n, frozen: false, }, }); @@ -249,7 +249,7 @@ test('authorities on authority-managed plugin should not be reset on transfer', type: 'Address', address: delegate.publicKey, }, - offset: BigInt(119), + offset: 119n, attributeList: [], }, }); @@ -268,7 +268,7 @@ test('authorities on authority-managed plugin should not be reset on transfer', type: 'Address', address: delegate.publicKey, }, - offset: BigInt(119), + offset: 119n, attributeList: [], }, }); diff --git a/clients/js/test/update.test.ts b/clients/js/test/update.test.ts index 27f6aec3..506d823b 100644 --- a/clients/js/test/update.test.ts +++ b/clients/js/test/update.test.ts @@ -14,7 +14,7 @@ import { createCollection, createUmi, DEFAULT_ASSET, -} from './_setup'; +} from './_setupRaw'; test('it can update an asset to be larger', async (t) => { // Given a Umi instance and a new signer. diff --git a/clients/js/test/updatePlugin.test.ts b/clients/js/test/updatePlugin.test.ts index 7191964d..267b84a5 100644 --- a/clients/js/test/updatePlugin.test.ts +++ b/clients/js/test/updatePlugin.test.ts @@ -16,7 +16,7 @@ import { createAsset, createCollection, createUmi, -} from './_setup'; +} from './_setupRaw'; test('it cannot use an invalid system program for assets', async (t) => { // Given a Umi instance and a new signer. diff --git a/clients/rust/Cargo.toml b/clients/rust/Cargo.toml index b802a0a1..a0aa0f9b 100644 --- a/clients/rust/Cargo.toml +++ b/clients/rust/Cargo.toml @@ -2,7 +2,7 @@ name = "mpl-core" description = "A flexible digital asset standard for Solana" repository = "https://github.com/metaplex-foundation/mpl-core" -version = "0.4.4" +version = "0.5.0" edition = "2021" readme = "README.md" license-file = "../../LICENSE" diff --git a/clients/rust/src/generated/instructions/add_collection_external_plugin_v1.rs b/clients/rust/src/generated/instructions/add_collection_external_plugin_v1.rs index db365478..9fd37ae9 100644 --- a/clients/rust/src/generated/instructions/add_collection_external_plugin_v1.rs +++ b/clients/rust/src/generated/instructions/add_collection_external_plugin_v1.rs @@ -85,12 +85,12 @@ impl AddCollectionExternalPluginV1 { } #[derive(BorshDeserialize, BorshSerialize)] -struct AddCollectionExternalPluginV1InstructionData { +pub struct AddCollectionExternalPluginV1InstructionData { discriminator: u8, } impl AddCollectionExternalPluginV1InstructionData { - fn new() -> Self { + pub fn new() -> Self { Self { discriminator: 23 } } } diff --git a/clients/rust/src/generated/instructions/add_collection_plugin_v1.rs b/clients/rust/src/generated/instructions/add_collection_plugin_v1.rs index eef1af12..8ed472af 100644 --- a/clients/rust/src/generated/instructions/add_collection_plugin_v1.rs +++ b/clients/rust/src/generated/instructions/add_collection_plugin_v1.rs @@ -86,12 +86,12 @@ impl AddCollectionPluginV1 { } #[derive(BorshDeserialize, BorshSerialize)] -struct AddCollectionPluginV1InstructionData { +pub struct AddCollectionPluginV1InstructionData { discriminator: u8, } impl AddCollectionPluginV1InstructionData { - fn new() -> Self { + pub fn new() -> Self { Self { discriminator: 3 } } } diff --git a/clients/rust/src/generated/instructions/add_external_plugin_v1.rs b/clients/rust/src/generated/instructions/add_external_plugin_v1.rs index c70ce3eb..014b1f55 100644 --- a/clients/rust/src/generated/instructions/add_external_plugin_v1.rs +++ b/clients/rust/src/generated/instructions/add_external_plugin_v1.rs @@ -96,12 +96,12 @@ impl AddExternalPluginV1 { } #[derive(BorshDeserialize, BorshSerialize)] -struct AddExternalPluginV1InstructionData { +pub struct AddExternalPluginV1InstructionData { discriminator: u8, } impl AddExternalPluginV1InstructionData { - fn new() -> Self { + pub fn new() -> Self { Self { discriminator: 22 } } } diff --git a/clients/rust/src/generated/instructions/add_plugin_v1.rs b/clients/rust/src/generated/instructions/add_plugin_v1.rs index 14903cea..cdf2bb69 100644 --- a/clients/rust/src/generated/instructions/add_plugin_v1.rs +++ b/clients/rust/src/generated/instructions/add_plugin_v1.rs @@ -95,12 +95,12 @@ impl AddPluginV1 { } #[derive(BorshDeserialize, BorshSerialize)] -struct AddPluginV1InstructionData { +pub struct AddPluginV1InstructionData { discriminator: u8, } impl AddPluginV1InstructionData { - fn new() -> Self { + pub fn new() -> Self { Self { discriminator: 2 } } } diff --git a/clients/rust/src/generated/instructions/approve_collection_plugin_authority_v1.rs b/clients/rust/src/generated/instructions/approve_collection_plugin_authority_v1.rs index d8f83a21..0a117ef1 100644 --- a/clients/rust/src/generated/instructions/approve_collection_plugin_authority_v1.rs +++ b/clients/rust/src/generated/instructions/approve_collection_plugin_authority_v1.rs @@ -86,12 +86,12 @@ impl ApproveCollectionPluginAuthorityV1 { } #[derive(BorshDeserialize, BorshSerialize)] -struct ApproveCollectionPluginAuthorityV1InstructionData { +pub struct ApproveCollectionPluginAuthorityV1InstructionData { discriminator: u8, } impl ApproveCollectionPluginAuthorityV1InstructionData { - fn new() -> Self { + pub fn new() -> Self { Self { discriminator: 9 } } } diff --git a/clients/rust/src/generated/instructions/approve_plugin_authority_v1.rs b/clients/rust/src/generated/instructions/approve_plugin_authority_v1.rs index 1218bdbd..a259c598 100644 --- a/clients/rust/src/generated/instructions/approve_plugin_authority_v1.rs +++ b/clients/rust/src/generated/instructions/approve_plugin_authority_v1.rs @@ -97,12 +97,12 @@ impl ApprovePluginAuthorityV1 { } #[derive(BorshDeserialize, BorshSerialize)] -struct ApprovePluginAuthorityV1InstructionData { +pub struct ApprovePluginAuthorityV1InstructionData { discriminator: u8, } impl ApprovePluginAuthorityV1InstructionData { - fn new() -> Self { + pub fn new() -> Self { Self { discriminator: 8 } } } diff --git a/clients/rust/src/generated/instructions/burn_collection_v1.rs b/clients/rust/src/generated/instructions/burn_collection_v1.rs index 4ebebe30..6bcc5032 100644 --- a/clients/rust/src/generated/instructions/burn_collection_v1.rs +++ b/clients/rust/src/generated/instructions/burn_collection_v1.rs @@ -77,12 +77,12 @@ impl BurnCollectionV1 { } #[derive(BorshDeserialize, BorshSerialize)] -struct BurnCollectionV1InstructionData { +pub struct BurnCollectionV1InstructionData { discriminator: u8, } impl BurnCollectionV1InstructionData { - fn new() -> Self { + pub fn new() -> Self { Self { discriminator: 13 } } } diff --git a/clients/rust/src/generated/instructions/burn_v1.rs b/clients/rust/src/generated/instructions/burn_v1.rs index 8ee626fb..803c102e 100644 --- a/clients/rust/src/generated/instructions/burn_v1.rs +++ b/clients/rust/src/generated/instructions/burn_v1.rs @@ -101,12 +101,12 @@ impl BurnV1 { } #[derive(BorshDeserialize, BorshSerialize)] -struct BurnV1InstructionData { +pub struct BurnV1InstructionData { discriminator: u8, } impl BurnV1InstructionData { - fn new() -> Self { + pub fn new() -> Self { Self { discriminator: 12 } } } diff --git a/clients/rust/src/generated/instructions/collect.rs b/clients/rust/src/generated/instructions/collect.rs index 35ab6310..3593b4f1 100644 --- a/clients/rust/src/generated/instructions/collect.rs +++ b/clients/rust/src/generated/instructions/collect.rs @@ -46,12 +46,12 @@ impl Collect { } #[derive(BorshDeserialize, BorshSerialize)] -struct CollectInstructionData { +pub struct CollectInstructionData { discriminator: u8, } impl CollectInstructionData { - fn new() -> Self { + pub fn new() -> Self { Self { discriminator: 19 } } } diff --git a/clients/rust/src/generated/instructions/compress_v1.rs b/clients/rust/src/generated/instructions/compress_v1.rs index 0aad8809..ddee8f22 100644 --- a/clients/rust/src/generated/instructions/compress_v1.rs +++ b/clients/rust/src/generated/instructions/compress_v1.rs @@ -87,12 +87,12 @@ impl CompressV1 { } #[derive(BorshDeserialize, BorshSerialize)] -struct CompressV1InstructionData { +pub struct CompressV1InstructionData { discriminator: u8, } impl CompressV1InstructionData { - fn new() -> Self { + pub fn new() -> Self { Self { discriminator: 17 } } } diff --git a/clients/rust/src/generated/instructions/create_collection_v1.rs b/clients/rust/src/generated/instructions/create_collection_v1.rs index 64d5265a..7c6a08af 100644 --- a/clients/rust/src/generated/instructions/create_collection_v1.rs +++ b/clients/rust/src/generated/instructions/create_collection_v1.rs @@ -73,12 +73,12 @@ impl CreateCollectionV1 { } #[derive(BorshDeserialize, BorshSerialize)] -struct CreateCollectionV1InstructionData { +pub struct CreateCollectionV1InstructionData { discriminator: u8, } impl CreateCollectionV1InstructionData { - fn new() -> Self { + pub fn new() -> Self { Self { discriminator: 1 } } } diff --git a/clients/rust/src/generated/instructions/create_collection_v2.rs b/clients/rust/src/generated/instructions/create_collection_v2.rs index 623e7a03..ca98b331 100644 --- a/clients/rust/src/generated/instructions/create_collection_v2.rs +++ b/clients/rust/src/generated/instructions/create_collection_v2.rs @@ -74,12 +74,12 @@ impl CreateCollectionV2 { } #[derive(BorshDeserialize, BorshSerialize)] -struct CreateCollectionV2InstructionData { +pub struct CreateCollectionV2InstructionData { discriminator: u8, } impl CreateCollectionV2InstructionData { - fn new() -> Self { + pub fn new() -> Self { Self { discriminator: 21 } } } diff --git a/clients/rust/src/generated/instructions/create_v1.rs b/clients/rust/src/generated/instructions/create_v1.rs index 54ab43aa..ccbcd918 100644 --- a/clients/rust/src/generated/instructions/create_v1.rs +++ b/clients/rust/src/generated/instructions/create_v1.rs @@ -120,12 +120,12 @@ impl CreateV1 { } #[derive(BorshDeserialize, BorshSerialize)] -struct CreateV1InstructionData { +pub struct CreateV1InstructionData { discriminator: u8, } impl CreateV1InstructionData { - fn new() -> Self { + pub fn new() -> Self { Self { discriminator: 0 } } } diff --git a/clients/rust/src/generated/instructions/create_v2.rs b/clients/rust/src/generated/instructions/create_v2.rs index 6e31d24c..44eadb28 100644 --- a/clients/rust/src/generated/instructions/create_v2.rs +++ b/clients/rust/src/generated/instructions/create_v2.rs @@ -121,12 +121,12 @@ impl CreateV2 { } #[derive(BorshDeserialize, BorshSerialize)] -struct CreateV2InstructionData { +pub struct CreateV2InstructionData { discriminator: u8, } impl CreateV2InstructionData { - fn new() -> Self { + pub fn new() -> Self { Self { discriminator: 20 } } } @@ -235,6 +235,7 @@ impl CreateV2Builder { self.log_wrapper = log_wrapper; self } + /// `[optional argument, defaults to 'DataState::AccountState']` #[inline(always)] pub fn data_state(&mut self, data_state: DataState) -> &mut Self { self.data_state = Some(data_state); @@ -295,7 +296,7 @@ impl CreateV2Builder { log_wrapper: self.log_wrapper, }; let args = CreateV2InstructionArgs { - data_state: self.data_state.clone().expect("data_state is not set"), + data_state: self.data_state.clone().unwrap_or(DataState::AccountState), name: self.name.clone().expect("name is not set"), uri: self.uri.clone().expect("uri is not set"), plugins: self.plugins.clone(), @@ -625,6 +626,7 @@ impl<'a, 'b> CreateV2CpiBuilder<'a, 'b> { self.instruction.log_wrapper = log_wrapper; self } + /// `[optional argument, defaults to 'DataState::AccountState']` #[inline(always)] pub fn data_state(&mut self, data_state: DataState) -> &mut Self { self.instruction.data_state = Some(data_state); @@ -698,7 +700,7 @@ impl<'a, 'b> CreateV2CpiBuilder<'a, 'b> { .instruction .data_state .clone() - .expect("data_state is not set"), + .unwrap_or(DataState::AccountState), name: self.instruction.name.clone().expect("name is not set"), uri: self.instruction.uri.clone().expect("uri is not set"), plugins: self.instruction.plugins.clone(), diff --git a/clients/rust/src/generated/instructions/decompress_v1.rs b/clients/rust/src/generated/instructions/decompress_v1.rs index 945e15c6..c634069e 100644 --- a/clients/rust/src/generated/instructions/decompress_v1.rs +++ b/clients/rust/src/generated/instructions/decompress_v1.rs @@ -94,12 +94,12 @@ impl DecompressV1 { } #[derive(BorshDeserialize, BorshSerialize)] -struct DecompressV1InstructionData { +pub struct DecompressV1InstructionData { discriminator: u8, } impl DecompressV1InstructionData { - fn new() -> Self { + pub fn new() -> Self { Self { discriminator: 18 } } } diff --git a/clients/rust/src/generated/instructions/remove_collection_external_plugin_v1.rs b/clients/rust/src/generated/instructions/remove_collection_external_plugin_v1.rs index 950d2cb9..757e37ca 100644 --- a/clients/rust/src/generated/instructions/remove_collection_external_plugin_v1.rs +++ b/clients/rust/src/generated/instructions/remove_collection_external_plugin_v1.rs @@ -85,12 +85,12 @@ impl RemoveCollectionExternalPluginV1 { } #[derive(BorshDeserialize, BorshSerialize)] -struct RemoveCollectionExternalPluginV1InstructionData { +pub struct RemoveCollectionExternalPluginV1InstructionData { discriminator: u8, } impl RemoveCollectionExternalPluginV1InstructionData { - fn new() -> Self { + pub fn new() -> Self { Self { discriminator: 25 } } } diff --git a/clients/rust/src/generated/instructions/remove_collection_plugin_v1.rs b/clients/rust/src/generated/instructions/remove_collection_plugin_v1.rs index bed34644..036df350 100644 --- a/clients/rust/src/generated/instructions/remove_collection_plugin_v1.rs +++ b/clients/rust/src/generated/instructions/remove_collection_plugin_v1.rs @@ -85,12 +85,12 @@ impl RemoveCollectionPluginV1 { } #[derive(BorshDeserialize, BorshSerialize)] -struct RemoveCollectionPluginV1InstructionData { +pub struct RemoveCollectionPluginV1InstructionData { discriminator: u8, } impl RemoveCollectionPluginV1InstructionData { - fn new() -> Self { + pub fn new() -> Self { Self { discriminator: 5 } } } diff --git a/clients/rust/src/generated/instructions/remove_external_plugin_v1.rs b/clients/rust/src/generated/instructions/remove_external_plugin_v1.rs index 2be75cec..a6204334 100644 --- a/clients/rust/src/generated/instructions/remove_external_plugin_v1.rs +++ b/clients/rust/src/generated/instructions/remove_external_plugin_v1.rs @@ -96,12 +96,12 @@ impl RemoveExternalPluginV1 { } #[derive(BorshDeserialize, BorshSerialize)] -struct RemoveExternalPluginV1InstructionData { +pub struct RemoveExternalPluginV1InstructionData { discriminator: u8, } impl RemoveExternalPluginV1InstructionData { - fn new() -> Self { + pub fn new() -> Self { Self { discriminator: 24 } } } diff --git a/clients/rust/src/generated/instructions/remove_plugin_v1.rs b/clients/rust/src/generated/instructions/remove_plugin_v1.rs index df666098..82a7d727 100644 --- a/clients/rust/src/generated/instructions/remove_plugin_v1.rs +++ b/clients/rust/src/generated/instructions/remove_plugin_v1.rs @@ -94,12 +94,12 @@ impl RemovePluginV1 { } #[derive(BorshDeserialize, BorshSerialize)] -struct RemovePluginV1InstructionData { +pub struct RemovePluginV1InstructionData { discriminator: u8, } impl RemovePluginV1InstructionData { - fn new() -> Self { + pub fn new() -> Self { Self { discriminator: 4 } } } diff --git a/clients/rust/src/generated/instructions/revoke_collection_plugin_authority_v1.rs b/clients/rust/src/generated/instructions/revoke_collection_plugin_authority_v1.rs index 21cbf000..32c33832 100644 --- a/clients/rust/src/generated/instructions/revoke_collection_plugin_authority_v1.rs +++ b/clients/rust/src/generated/instructions/revoke_collection_plugin_authority_v1.rs @@ -85,12 +85,12 @@ impl RevokeCollectionPluginAuthorityV1 { } #[derive(BorshDeserialize, BorshSerialize)] -struct RevokeCollectionPluginAuthorityV1InstructionData { +pub struct RevokeCollectionPluginAuthorityV1InstructionData { discriminator: u8, } impl RevokeCollectionPluginAuthorityV1InstructionData { - fn new() -> Self { + pub fn new() -> Self { Self { discriminator: 11 } } } diff --git a/clients/rust/src/generated/instructions/revoke_plugin_authority_v1.rs b/clients/rust/src/generated/instructions/revoke_plugin_authority_v1.rs index 3fc7be43..bd6b1c2a 100644 --- a/clients/rust/src/generated/instructions/revoke_plugin_authority_v1.rs +++ b/clients/rust/src/generated/instructions/revoke_plugin_authority_v1.rs @@ -96,12 +96,12 @@ impl RevokePluginAuthorityV1 { } #[derive(BorshDeserialize, BorshSerialize)] -struct RevokePluginAuthorityV1InstructionData { +pub struct RevokePluginAuthorityV1InstructionData { discriminator: u8, } impl RevokePluginAuthorityV1InstructionData { - fn new() -> Self { + pub fn new() -> Self { Self { discriminator: 10 } } } diff --git a/clients/rust/src/generated/instructions/transfer_v1.rs b/clients/rust/src/generated/instructions/transfer_v1.rs index cba522f2..8fb04cdd 100644 --- a/clients/rust/src/generated/instructions/transfer_v1.rs +++ b/clients/rust/src/generated/instructions/transfer_v1.rs @@ -107,12 +107,12 @@ impl TransferV1 { } #[derive(BorshDeserialize, BorshSerialize)] -struct TransferV1InstructionData { +pub struct TransferV1InstructionData { discriminator: u8, } impl TransferV1InstructionData { - fn new() -> Self { + pub fn new() -> Self { Self { discriminator: 14 } } } diff --git a/clients/rust/src/generated/instructions/update_collection_external_plugin_v1.rs b/clients/rust/src/generated/instructions/update_collection_external_plugin_v1.rs index 1ca9ac71..52778a61 100644 --- a/clients/rust/src/generated/instructions/update_collection_external_plugin_v1.rs +++ b/clients/rust/src/generated/instructions/update_collection_external_plugin_v1.rs @@ -86,12 +86,12 @@ impl UpdateCollectionExternalPluginV1 { } #[derive(BorshDeserialize, BorshSerialize)] -struct UpdateCollectionExternalPluginV1InstructionData { +pub struct UpdateCollectionExternalPluginV1InstructionData { discriminator: u8, } impl UpdateCollectionExternalPluginV1InstructionData { - fn new() -> Self { + pub fn new() -> Self { Self { discriminator: 27 } } } diff --git a/clients/rust/src/generated/instructions/update_collection_plugin_v1.rs b/clients/rust/src/generated/instructions/update_collection_plugin_v1.rs index 2ca4788c..f5dbfe0f 100644 --- a/clients/rust/src/generated/instructions/update_collection_plugin_v1.rs +++ b/clients/rust/src/generated/instructions/update_collection_plugin_v1.rs @@ -85,12 +85,12 @@ impl UpdateCollectionPluginV1 { } #[derive(BorshDeserialize, BorshSerialize)] -struct UpdateCollectionPluginV1InstructionData { +pub struct UpdateCollectionPluginV1InstructionData { discriminator: u8, } impl UpdateCollectionPluginV1InstructionData { - fn new() -> Self { + pub fn new() -> Self { Self { discriminator: 7 } } } diff --git a/clients/rust/src/generated/instructions/update_collection_v1.rs b/clients/rust/src/generated/instructions/update_collection_v1.rs index 12f3e407..7ed50069 100644 --- a/clients/rust/src/generated/instructions/update_collection_v1.rs +++ b/clients/rust/src/generated/instructions/update_collection_v1.rs @@ -97,12 +97,12 @@ impl UpdateCollectionV1 { } #[derive(BorshDeserialize, BorshSerialize)] -struct UpdateCollectionV1InstructionData { +pub struct UpdateCollectionV1InstructionData { discriminator: u8, } impl UpdateCollectionV1InstructionData { - fn new() -> Self { + pub fn new() -> Self { Self { discriminator: 16 } } } diff --git a/clients/rust/src/generated/instructions/update_external_plugin_v1.rs b/clients/rust/src/generated/instructions/update_external_plugin_v1.rs index e4d63679..abca5489 100644 --- a/clients/rust/src/generated/instructions/update_external_plugin_v1.rs +++ b/clients/rust/src/generated/instructions/update_external_plugin_v1.rs @@ -97,12 +97,12 @@ impl UpdateExternalPluginV1 { } #[derive(BorshDeserialize, BorshSerialize)] -struct UpdateExternalPluginV1InstructionData { +pub struct UpdateExternalPluginV1InstructionData { discriminator: u8, } impl UpdateExternalPluginV1InstructionData { - fn new() -> Self { + pub fn new() -> Self { Self { discriminator: 26 } } } diff --git a/clients/rust/src/generated/instructions/update_plugin_v1.rs b/clients/rust/src/generated/instructions/update_plugin_v1.rs index 5baa6f50..8e894d08 100644 --- a/clients/rust/src/generated/instructions/update_plugin_v1.rs +++ b/clients/rust/src/generated/instructions/update_plugin_v1.rs @@ -94,12 +94,12 @@ impl UpdatePluginV1 { } #[derive(BorshDeserialize, BorshSerialize)] -struct UpdatePluginV1InstructionData { +pub struct UpdatePluginV1InstructionData { discriminator: u8, } impl UpdatePluginV1InstructionData { - fn new() -> Self { + pub fn new() -> Self { Self { discriminator: 6 } } } diff --git a/clients/rust/src/generated/instructions/update_v1.rs b/clients/rust/src/generated/instructions/update_v1.rs index 0b81ad7e..62ccd844 100644 --- a/clients/rust/src/generated/instructions/update_v1.rs +++ b/clients/rust/src/generated/instructions/update_v1.rs @@ -94,12 +94,12 @@ impl UpdateV1 { } #[derive(BorshDeserialize, BorshSerialize)] -struct UpdateV1InstructionData { +pub struct UpdateV1InstructionData { discriminator: u8, } impl UpdateV1InstructionData { - fn new() -> Self { + pub fn new() -> Self { Self { discriminator: 15 } } } diff --git a/clients/rust/src/generated/instructions/write_collection_external_plugin_data_v1.rs b/clients/rust/src/generated/instructions/write_collection_external_plugin_data_v1.rs index 5dcee063..cb65b31b 100644 --- a/clients/rust/src/generated/instructions/write_collection_external_plugin_data_v1.rs +++ b/clients/rust/src/generated/instructions/write_collection_external_plugin_data_v1.rs @@ -85,12 +85,12 @@ impl WriteCollectionExternalPluginDataV1 { } #[derive(BorshDeserialize, BorshSerialize)] -struct WriteCollectionExternalPluginDataV1InstructionData { +pub struct WriteCollectionExternalPluginDataV1InstructionData { discriminator: u8, } impl WriteCollectionExternalPluginDataV1InstructionData { - fn new() -> Self { + pub fn new() -> Self { Self { discriminator: 29 } } } diff --git a/clients/rust/src/generated/instructions/write_external_plugin_data_v1.rs b/clients/rust/src/generated/instructions/write_external_plugin_data_v1.rs index 541d9b25..023923f7 100644 --- a/clients/rust/src/generated/instructions/write_external_plugin_data_v1.rs +++ b/clients/rust/src/generated/instructions/write_external_plugin_data_v1.rs @@ -96,12 +96,12 @@ impl WriteExternalPluginDataV1 { } #[derive(BorshDeserialize, BorshSerialize)] -struct WriteExternalPluginDataV1InstructionData { +pub struct WriteExternalPluginDataV1InstructionData { discriminator: u8, } impl WriteExternalPluginDataV1InstructionData { - fn new() -> Self { + pub fn new() -> Self { Self { discriminator: 28 } } } diff --git a/clients/rust/src/generated/types/external_plugin_key.rs b/clients/rust/src/generated/types/external_plugin_key.rs index a7c2b0b3..1ad4c2c5 100644 --- a/clients/rust/src/generated/types/external_plugin_key.rs +++ b/clients/rust/src/generated/types/external_plugin_key.rs @@ -13,7 +13,15 @@ use solana_program::pubkey::Pubkey; #[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub enum ExternalPluginKey { + #[cfg_attr( + feature = "serde", + serde(with = "serde_with::As::") + )] LifecycleHook(Pubkey), + #[cfg_attr( + feature = "serde", + serde(with = "serde_with::As::") + )] Oracle(Pubkey), DataStore(PluginAuthority), } diff --git a/clients/rust/src/generated/types/external_validation_result.rs b/clients/rust/src/generated/types/external_validation_result.rs new file mode 100644 index 00000000..d24f011d --- /dev/null +++ b/clients/rust/src/generated/types/external_validation_result.rs @@ -0,0 +1,20 @@ +//! 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. +//! +//! [https://github.com/metaplex-foundation/kinobi] +//! + +use borsh::BorshDeserialize; +use borsh::BorshSerialize; +use num_derive::FromPrimitive; + +#[derive( + BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq, PartialOrd, Hash, FromPrimitive, +)] +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] +pub enum ExternalValidationResult { + Approved, + Rejected, + Pass, +} diff --git a/clients/rust/src/generated/types/mod.rs b/clients/rust/src/generated/types/mod.rs index d6c13756..d5503d6c 100644 --- a/clients/rust/src/generated/types/mod.rs +++ b/clients/rust/src/generated/types/mod.rs @@ -23,6 +23,7 @@ pub(crate) mod r#external_plugin_schema; pub(crate) mod r#external_plugin_type; pub(crate) mod r#external_plugin_update_info; pub(crate) mod r#external_registry_record; +pub(crate) mod r#external_validation_result; pub(crate) mod r#extra_account; pub(crate) mod r#freeze_delegate; pub(crate) mod r#hashable_plugin_schema; @@ -35,6 +36,7 @@ pub(crate) mod r#lifecycle_hook_update_info; pub(crate) mod r#oracle; pub(crate) mod r#oracle_init_info; pub(crate) mod r#oracle_update_info; +pub(crate) mod r#oracle_validation; pub(crate) mod r#permanent_burn_delegate; pub(crate) mod r#permanent_freeze_delegate; pub(crate) mod r#permanent_transfer_delegate; @@ -50,6 +52,7 @@ pub(crate) mod r#transfer_delegate; pub(crate) mod r#update_authority; pub(crate) mod r#update_delegate; pub(crate) mod r#validation_result; +pub(crate) mod r#validation_results_offset; pub use self::r#attribute::*; pub use self::r#attributes::*; @@ -69,6 +72,7 @@ pub use self::r#external_plugin_schema::*; pub use self::r#external_plugin_type::*; pub use self::r#external_plugin_update_info::*; pub use self::r#external_registry_record::*; +pub use self::r#external_validation_result::*; pub use self::r#extra_account::*; pub use self::r#freeze_delegate::*; pub use self::r#hashable_plugin_schema::*; @@ -81,6 +85,7 @@ pub use self::r#lifecycle_hook_update_info::*; pub use self::r#oracle::*; pub use self::r#oracle_init_info::*; pub use self::r#oracle_update_info::*; +pub use self::r#oracle_validation::*; pub use self::r#permanent_burn_delegate::*; pub use self::r#permanent_freeze_delegate::*; pub use self::r#permanent_transfer_delegate::*; @@ -96,3 +101,4 @@ pub use self::r#transfer_delegate::*; pub use self::r#update_authority::*; pub use self::r#update_delegate::*; pub use self::r#validation_result::*; +pub use self::r#validation_results_offset::*; diff --git a/clients/rust/src/generated/types/oracle.rs b/clients/rust/src/generated/types/oracle.rs index e14745b0..2a95fa48 100644 --- a/clients/rust/src/generated/types/oracle.rs +++ b/clients/rust/src/generated/types/oracle.rs @@ -6,6 +6,7 @@ //! use crate::generated::types::ExtraAccount; +use crate::generated::types::ValidationResultsOffset; use borsh::BorshDeserialize; use borsh::BorshSerialize; use solana_program::pubkey::Pubkey; @@ -19,4 +20,5 @@ pub struct Oracle { )] pub base_address: Pubkey, pub pda: Option, + pub results_offset: ValidationResultsOffset, } diff --git a/clients/rust/src/generated/types/oracle_init_info.rs b/clients/rust/src/generated/types/oracle_init_info.rs index 20b3b287..f96c00e1 100644 --- a/clients/rust/src/generated/types/oracle_init_info.rs +++ b/clients/rust/src/generated/types/oracle_init_info.rs @@ -9,6 +9,7 @@ use crate::generated::types::ExternalCheckResult; use crate::generated::types::ExtraAccount; use crate::generated::types::HookableLifecycleEvent; use crate::generated::types::PluginAuthority; +use crate::generated::types::ValidationResultsOffset; use borsh::BorshDeserialize; use borsh::BorshSerialize; use solana_program::pubkey::Pubkey; @@ -24,4 +25,5 @@ pub struct OracleInitInfo { pub init_plugin_authority: Option, pub lifecycle_checks: Option>, pub pda: Option, + pub results_offset: Option, } diff --git a/clients/rust/src/generated/types/oracle_update_info.rs b/clients/rust/src/generated/types/oracle_update_info.rs index 3cb3437a..9813f5a0 100644 --- a/clients/rust/src/generated/types/oracle_update_info.rs +++ b/clients/rust/src/generated/types/oracle_update_info.rs @@ -8,6 +8,7 @@ use crate::generated::types::ExternalCheckResult; use crate::generated::types::ExtraAccount; use crate::generated::types::HookableLifecycleEvent; +use crate::generated::types::ValidationResultsOffset; use borsh::BorshDeserialize; use borsh::BorshSerialize; @@ -16,4 +17,5 @@ use borsh::BorshSerialize; pub struct OracleUpdateInfo { pub lifecycle_checks: Option>, pub pda: Option, + pub results_offset: Option, } diff --git a/clients/rust/src/generated/types/oracle_validation.rs b/clients/rust/src/generated/types/oracle_validation.rs new file mode 100644 index 00000000..c971c96c --- /dev/null +++ b/clients/rust/src/generated/types/oracle_validation.rs @@ -0,0 +1,21 @@ +//! 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. +//! +//! [https://github.com/metaplex-foundation/kinobi] +//! + +use crate::generated::types::ExternalValidationResult; +use borsh::BorshDeserialize; +use borsh::BorshSerialize; + +#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] +pub enum OracleValidation { + V1 { + create: ExternalValidationResult, + transfer: ExternalValidationResult, + burn: ExternalValidationResult, + update: ExternalValidationResult, + }, +} diff --git a/clients/rust/src/generated/types/rule_set.rs b/clients/rust/src/generated/types/rule_set.rs index 1fd87934..dbe34b51 100644 --- a/clients/rust/src/generated/types/rule_set.rs +++ b/clients/rust/src/generated/types/rule_set.rs @@ -13,6 +13,14 @@ use solana_program::pubkey::Pubkey; #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub enum RuleSet { None, + #[cfg_attr( + feature = "serde", + serde(with = "serde_with::As::>") + )] ProgramAllowList(Vec), + #[cfg_attr( + feature = "serde", + serde(with = "serde_with::As::>") + )] ProgramDenyList(Vec), } diff --git a/clients/rust/src/generated/types/update_authority.rs b/clients/rust/src/generated/types/update_authority.rs index 4aa85693..4ede9d33 100644 --- a/clients/rust/src/generated/types/update_authority.rs +++ b/clients/rust/src/generated/types/update_authority.rs @@ -13,6 +13,14 @@ use solana_program::pubkey::Pubkey; #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub enum UpdateAuthority { None, + #[cfg_attr( + feature = "serde", + serde(with = "serde_with::As::") + )] Address(Pubkey), + #[cfg_attr( + feature = "serde", + serde(with = "serde_with::As::") + )] Collection(Pubkey), } diff --git a/clients/rust/src/generated/types/update_delegate.rs b/clients/rust/src/generated/types/update_delegate.rs index 243b0183..dedcb944 100644 --- a/clients/rust/src/generated/types/update_delegate.rs +++ b/clients/rust/src/generated/types/update_delegate.rs @@ -12,5 +12,9 @@ use solana_program::pubkey::Pubkey; #[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct UpdateDelegate { + #[cfg_attr( + feature = "serde", + serde(with = "serde_with::As::>") + )] pub additional_delegates: Vec, } diff --git a/clients/rust/src/generated/types/validation_results_offset.rs b/clients/rust/src/generated/types/validation_results_offset.rs new file mode 100644 index 00000000..15de75cb --- /dev/null +++ b/clients/rust/src/generated/types/validation_results_offset.rs @@ -0,0 +1,17 @@ +//! 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. +//! +//! [https://github.com/metaplex-foundation/kinobi] +//! + +use borsh::BorshDeserialize; +use borsh::BorshSerialize; + +#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] +pub enum ValidationResultsOffset { + NoOffset, + Anchor, + Custom(u64), +} diff --git a/clients/rust/tests/add_external_plugins.rs b/clients/rust/tests/add_external_plugins.rs index 0208d863..813c145d 100644 --- a/clients/rust/tests/add_external_plugins.rs +++ b/clients/rust/tests/add_external_plugins.rs @@ -154,6 +154,7 @@ async fn test_add_oracle() { ExternalCheckResult { flags: 1 }, )]), pda: None, + results_offset: None, })) .instruction(); diff --git a/clients/rust/tests/create_with_external_plugins.rs b/clients/rust/tests/create_with_external_plugins.rs index c5438a2f..4d24b353 100644 --- a/clients/rust/tests/create_with_external_plugins.rs +++ b/clients/rust/tests/create_with_external_plugins.rs @@ -97,6 +97,7 @@ async fn test_create_oracle() { ExternalCheckResult { flags: 1 }, )]), pda: None, + results_offset: None, })], }, ) diff --git a/configs/kinobi.cjs b/configs/kinobi.cjs index 930fd8de..99c8bd04 100755 --- a/configs/kinobi.cjs +++ b/configs/kinobi.cjs @@ -77,14 +77,36 @@ kinobi.update( } } }, + createV2: { + arguments: { + plugins: { + defaultValue: k.arrayValueNode([]) + }, + externalPlugins: { + defaultValue: k.arrayValueNode([]) + }, + dataState: { + defaultValue: k.enumValueNode('DataState', 'AccountState') + } + } + }, createCollectionV1: { arguments: { plugins: { defaultValue: k.noneValueNode() - } } }, + createCollectionV2: { + arguments: { + plugins: { + defaultValue: k.noneValueNode() + }, + externalPlugins: { + defaultValue: k.arrayValueNode([]) + }, + } + }, collect: { accounts: { recipient1: { @@ -99,7 +121,23 @@ kinobi.update( arguments: { newUpdateAuthority: { defaultValue: k.noneValueNode() - } + }, + newName: { + defaultValue: k.noneValueNode() + }, + newUri: { + defaultValue: k.noneValueNode() + }, + } + }, + updateCollectionV1: { + arguments: { + newName: { + defaultValue: k.noneValueNode() + }, + newUri: { + defaultValue: k.noneValueNode() + }, } } }) @@ -137,6 +175,68 @@ kinobi.update( }) ); +kinobi.update( + new k.updateDefinedTypesVisitor({ + ruleSet: { + name: "baseRuleSet" + }, + royalties: { + name: "baseRoyalties" + }, + pluginAuthority: { + name: "basePluginAuthority" + }, + updateAuthority: { + name: "baseUpdateAuthority" + }, + seed: { + name: "baseSeed" + }, + extraAccount: { + name: "baseExtraAccount" + }, + externalPluginKey: { + name: "baseExternalPluginKey" + }, + externalPluginInitInfo: { + name: "baseExternalPluginInitInfo" + }, + externalPluginUpdateInfo: { + name: "baseExternalPluginUpdateInfo" + }, + oracle: { + name: "baseOracle" + }, + oracleInitInfo: { + name: "baseOracleInitInfo" + }, + oracleUpdateInfo: { + name: "baseOracleUpdateInfo" + }, + lifecycleHook: { + name: "baseLifecycleHook" + }, + lifecycleHookInitInfo: { + name: "baseLifecycleHookInitInfo" + }, + lifecycleHookUpdateInfo: { + name: "baseLifecycleHookUpdateInfo" + }, + dataStore: { + name: "baseDataStore" + }, + dataStoreInitInfo: { + name: "baseDataStoreInitInfo" + }, + dataStoreUpdateInfo: { + name: "baseDataStoreUpdateInfo" + }, + validationResultsOffset: { + name: "baseValidationResultsOffset" + }, + }) +) + // Render JavaScript. const jsDir = path.join(clientDir, "js", "src", "generated"); const prettier = require(path.join(clientDir, "js", ".prettierrc.json")); diff --git a/idls/mpl_core.json b/idls/mpl_core.json index c0bb436e..d3d4e54f 100644 --- a/idls/mpl_core.json +++ b/idls/mpl_core.json @@ -2396,6 +2396,12 @@ "defined": "ExtraAccount" } } + }, + { + "name": "resultsOffset", + "type": { + "defined": "ValidationResultsOffset" + } } ] } @@ -2441,6 +2447,14 @@ "defined": "ExtraAccount" } } + }, + { + "name": "resultsOffset", + "type": { + "option": { + "defined": "ValidationResultsOffset" + } + } } ] } @@ -2474,6 +2488,14 @@ "defined": "ExtraAccount" } } + }, + { + "name": "resultsOffset", + "type": { + "option": { + "defined": "ValidationResultsOffset" + } + } } ] } @@ -3739,6 +3761,80 @@ ] } }, + { + "name": "ExternalValidationResult", + "type": { + "kind": "enum", + "variants": [ + { + "name": "Approved" + }, + { + "name": "Rejected" + }, + { + "name": "Pass" + } + ] + } + }, + { + "name": "ValidationResultsOffset", + "type": { + "kind": "enum", + "variants": [ + { + "name": "NoOffset" + }, + { + "name": "Anchor" + }, + { + "name": "Custom", + "fields": [ + "u64" + ] + } + ] + } + }, + { + "name": "OracleValidation", + "type": { + "kind": "enum", + "variants": [ + { + "name": "V1", + "fields": [ + { + "name": "create", + "type": { + "defined": "ExternalValidationResult" + } + }, + { + "name": "transfer", + "type": { + "defined": "ExternalValidationResult" + } + }, + { + "name": "burn", + "type": { + "defined": "ExternalValidationResult" + } + }, + { + "name": "update", + "type": { + "defined": "ExternalValidationResult" + } + } + ] + } + ] + } + }, { "name": "RuleSet", "type": { diff --git a/package.json b/package.json index ecfe3e28..3bf7441f 100644 --- a/package.json +++ b/package.json @@ -17,7 +17,7 @@ }, "devDependencies": { "@metaplex-foundation/amman": "^0.12.1", - "@metaplex-foundation/kinobi": "^0.18.3", + "@metaplex-foundation/kinobi": "^0.18.5", "@metaplex-foundation/shank-js": "^0.1.7", "typescript": "^4.9.4" }, diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 19fba33a..d2f6ea82 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -9,8 +9,8 @@ devDependencies: specifier: ^0.12.1 version: 0.12.1(typescript@4.9.4) '@metaplex-foundation/kinobi': - specifier: ^0.18.3 - version: 0.18.3(fastestsmallesttextencoderdecoder@1.0.22) + specifier: ^0.18.5 + version: 0.18.5(fastestsmallesttextencoderdecoder@1.0.22) '@metaplex-foundation/shank-js': specifier: ^0.1.7 version: 0.1.7 @@ -89,8 +89,8 @@ packages: resolution: {integrity: sha512-S9RulC2fFCFOQraz61bij+5YCHhSO9llJegK8c8Y6731fSi6snUSQJdCUqYS8AIgR0TKbQvdvgSyIIdbDFZbBA==} dev: true - /@metaplex-foundation/kinobi@0.18.3(fastestsmallesttextencoderdecoder@1.0.22): - resolution: {integrity: sha512-va8n1DVYlzhVA6xLpTgiUzxRUB3Dvo53pwDUYYEuKBX43zXKrgg5SWZ438UX23/5iFNv+6M01L+5/Z4oh43fAw==} + /@metaplex-foundation/kinobi@0.18.5(fastestsmallesttextencoderdecoder@1.0.22): + resolution: {integrity: sha512-qh4h4xGB+PHR5o4rcZki+wsIeZYi6R9SRV5UMqGi/rfDJXk0ckAZ+fxdam+mCc4N8HWLLWmEJbF5gx8E5K0fOA==} dependencies: '@noble/hashes': 1.4.0 '@prettier/sync': 0.5.1(prettier@3.2.5) diff --git a/programs/mpl-core/src/plugins/data_store.rs b/programs/mpl-core/src/plugins/data_store.rs index 4e3163bb..91fdf54f 100644 --- a/programs/mpl-core/src/plugins/data_store.rs +++ b/programs/mpl-core/src/plugins/data_store.rs @@ -23,6 +23,22 @@ pub struct DataStore { pub data_len: usize, } +impl PluginValidation for DataStore { + fn validate_add_external_plugin( + &self, + _ctx: &PluginValidationContext, + ) -> Result { + Ok(ValidationResult::Pass) + } + + fn validate_transfer( + &self, + _ctx: &PluginValidationContext, + ) -> Result { + Ok(ValidationResult::Pass) + } +} + impl From<&DataStoreInitInfo> for DataStore { fn from(init_info: &DataStoreInitInfo) -> Self { Self { @@ -46,15 +62,6 @@ pub struct DataStoreInitInfo { pub schema: Option, } -impl PluginValidation for DataStoreInitInfo { - fn validate_add_external_plugin( - &self, - _ctx: &PluginValidationContext, - ) -> Result { - Ok(ValidationResult::Pass) - } -} - /// Data store update info. #[derive(Clone, Debug, BorshSerialize, BorshDeserialize, Eq, PartialEq)] pub struct DataStoreUpdateInfo { diff --git a/programs/mpl-core/src/plugins/external_plugins.rs b/programs/mpl-core/src/plugins/external_plugins.rs index 77b65c06..fcfa98ec 100644 --- a/programs/mpl-core/src/plugins/external_plugins.rs +++ b/programs/mpl-core/src/plugins/external_plugins.rs @@ -103,31 +103,63 @@ impl ExternalPlugin { /// Validate the add external plugin lifecycle event. pub(crate) fn validate_create( - init_info: &ExternalPluginInitInfo, + external_plugin: &ExternalPlugin, ctx: &PluginValidationContext, ) -> Result { - match init_info { - ExternalPluginInitInfo::LifecycleHook(init_info) => init_info.validate_create(ctx), - ExternalPluginInitInfo::Oracle(init_info) => init_info.validate_create(ctx), - ExternalPluginInitInfo::DataStore(init_info) => init_info.validate_create(ctx), + match external_plugin { + ExternalPlugin::LifecycleHook(lifecycle_hook) => lifecycle_hook.validate_create(ctx), + ExternalPlugin::Oracle(oracle) => oracle.validate_create(ctx), + ExternalPlugin::DataStore(data_store) => data_store.validate_create(ctx), + } + } + + /// Route the validation of the update action to the appropriate plugin. + pub(crate) fn validate_update( + external_plugin: &ExternalPlugin, + ctx: &PluginValidationContext, + ) -> Result { + match external_plugin { + ExternalPlugin::LifecycleHook(lifecycle_hook) => lifecycle_hook.validate_update(ctx), + ExternalPlugin::Oracle(oracle) => oracle.validate_update(ctx), + ExternalPlugin::DataStore(data_store) => data_store.validate_update(ctx), + } + } + + /// Route the validation of the burn action to the appropriate plugin. + pub(crate) fn validate_burn( + external_plugin: &ExternalPlugin, + ctx: &PluginValidationContext, + ) -> Result { + match external_plugin { + ExternalPlugin::LifecycleHook(lifecycle_hook) => lifecycle_hook.validate_burn(ctx), + ExternalPlugin::Oracle(oracle) => oracle.validate_burn(ctx), + ExternalPlugin::DataStore(data_store) => data_store.validate_burn(ctx), + } + } + + /// Route the validation of the transfer action to the appropriate external plugin. + pub(crate) fn validate_transfer( + external_plugin: &ExternalPlugin, + ctx: &PluginValidationContext, + ) -> Result { + match external_plugin { + ExternalPlugin::LifecycleHook(lifecycle_hook) => lifecycle_hook.validate_transfer(ctx), + ExternalPlugin::Oracle(oracle) => oracle.validate_transfer(ctx), + ExternalPlugin::DataStore(data_store) => data_store.validate_transfer(ctx), } } /// Validate the add external plugin lifecycle event. pub(crate) fn validate_add_external_plugin( - init_info: &ExternalPluginInitInfo, + external_plugin: &ExternalPlugin, ctx: &PluginValidationContext, ) -> Result { - match init_info { - ExternalPluginInitInfo::LifecycleHook(init_info) => { - init_info.validate_add_external_plugin(ctx) - } - ExternalPluginInitInfo::Oracle(init_info) => { - init_info.validate_add_external_plugin(ctx) - } - ExternalPluginInitInfo::DataStore(init_info) => { - init_info.validate_add_external_plugin(ctx) + match external_plugin { + ExternalPlugin::LifecycleHook(lifecycle_hook) => { + lifecycle_hook.validate_add_external_plugin(ctx) } + ExternalPlugin::Oracle(oracle) => oracle.validate_add_external_plugin(ctx), + ExternalPlugin::DataStore(data_store) => data_store.validate_add_external_plugin(ctx), } } diff --git a/programs/mpl-core/src/plugins/lifecycle.rs b/programs/mpl-core/src/plugins/lifecycle.rs index 4a7ab1a0..28b2d34b 100644 --- a/programs/mpl-core/src/plugins/lifecycle.rs +++ b/programs/mpl-core/src/plugins/lifecycle.rs @@ -31,7 +31,7 @@ pub enum CheckResult { #[derive(BorshDeserialize, BorshSerialize, Eq, PartialEq, Copy, Clone, Debug)] pub struct ExternalCheckResult { /// Bitfield for external check results. - flags: u8, + pub flags: u8, } impl ExternalCheckResult { @@ -640,6 +640,18 @@ pub enum ValidationResult { ForceApproved, } +/// External plugins lifecycle validations +/// External plugins utilize this to indicate whether they approve or reject a lifecycle action. +#[derive(Eq, PartialEq, Debug, Clone, BorshDeserialize, BorshSerialize)] +pub enum ExternalValidationResult { + /// The plugin approves the lifecycle action. + Approved, + /// The plugin rejects the lifecycle action. + Rejected, + /// The plugin abstains from approving or rejecting the lifecycle action. + Pass, +} + /// The required context for a plugin validation. #[allow(dead_code)] pub(crate) struct PluginValidationContext<'a, 'b> { @@ -799,7 +811,10 @@ pub(crate) fn validate_plugin_checks<'a>( asset: Option<&AccountInfo<'a>>, collection: Option<&AccountInfo<'a>>, resolved_authorities: &[Authority], - validate_fp: fn(&Plugin, &PluginValidationContext) -> Result, + plugin_validate_fp: fn( + &Plugin, + &PluginValidationContext, + ) -> Result, ) -> Result { let mut approved = false; let mut rejected = false; @@ -824,7 +839,7 @@ pub(crate) fn validate_plugin_checks<'a>( target_plugin: new_plugin, }; - let result = validate_fp(&Plugin::load(account, registry_record.offset)?, &ctx)?; + let result = plugin_validate_fp(&Plugin::load(account, registry_record.offset)?, &ctx)?; match result { ValidationResult::Rejected => rejected = true, ValidationResult::Approved => approved = true, diff --git a/programs/mpl-core/src/plugins/lifecycle_hook.rs b/programs/mpl-core/src/plugins/lifecycle_hook.rs index 616c0bdc..870643df 100644 --- a/programs/mpl-core/src/plugins/lifecycle_hook.rs +++ b/programs/mpl-core/src/plugins/lifecycle_hook.rs @@ -30,6 +30,22 @@ pub struct LifecycleHook { pub data_len: usize, // 8 } +impl PluginValidation for LifecycleHook { + fn validate_add_external_plugin( + &self, + _ctx: &PluginValidationContext, + ) -> Result { + Ok(ValidationResult::Pass) + } + + fn validate_transfer( + &self, + _ctx: &PluginValidationContext, + ) -> Result { + Ok(ValidationResult::Pass) + } +} + impl From<&LifecycleHookInitInfo> for LifecycleHook { fn from(init_info: &LifecycleHookInitInfo) -> Self { Self { @@ -62,15 +78,6 @@ pub struct LifecycleHookInitInfo { pub schema: Option, } -impl PluginValidation for LifecycleHookInitInfo { - fn validate_add_external_plugin( - &self, - _ctx: &PluginValidationContext, - ) -> Result { - Ok(ValidationResult::Pass) - } -} - /// Lifecycle hook update info. #[derive(Clone, Debug, BorshSerialize, BorshDeserialize, Eq, PartialEq)] pub struct LifecycleHookUpdateInfo { diff --git a/programs/mpl-core/src/plugins/oracle.rs b/programs/mpl-core/src/plugins/oracle.rs index 8fed1205..f4f61d7f 100644 --- a/programs/mpl-core/src/plugins/oracle.rs +++ b/programs/mpl-core/src/plugins/oracle.rs @@ -2,8 +2,8 @@ use borsh::{BorshDeserialize, BorshSerialize}; use solana_program::{program_error::ProgramError, pubkey::Pubkey}; use super::{ - Authority, ExternalCheckResult, ExtraAccount, HookableLifecycleEvent, PluginValidation, - PluginValidationContext, ValidationResult, + Authority, ExternalCheckResult, ExternalValidationResult, ExtraAccount, HookableLifecycleEvent, + PluginValidation, PluginValidationContext, ValidationResult, }; /// Oracle plugin that allows getting a `ValidationResult` for a lifecycle event from an arbitrary @@ -16,6 +16,24 @@ pub struct Oracle { pub base_address: Pubkey, /// Optional PDA (derived from Pubkey attached to `ExternalPluginKey`). pub pda: Option, + /// Validation results offset in the Oracle account. Default is `ValidationResultsOffset::NoOffset`. + pub results_offset: ValidationResultsOffset, +} + +impl PluginValidation for Oracle { + fn validate_add_external_plugin( + &self, + _ctx: &PluginValidationContext, + ) -> Result { + Ok(ValidationResult::Pass) + } + + fn validate_transfer( + &self, + _ctx: &PluginValidationContext, + ) -> Result { + Ok(ValidationResult::Pass) + } } impl From<&OracleInitInfo> for Oracle { @@ -23,6 +41,10 @@ impl From<&OracleInitInfo> for Oracle { Self { base_address: init_info.base_address, pda: init_info.pda.clone(), + results_offset: init_info + .results_offset + .clone() + .unwrap_or(ValidationResultsOffset::NoOffset), } } } @@ -39,15 +61,9 @@ pub struct OracleInitInfo { pub lifecycle_checks: Option>, /// Optional PDA (derived from Pubkey attached to `ExternalPluginKey`). pub pda: Option, -} - -impl PluginValidation for OracleInitInfo { - fn validate_add_external_plugin( - &self, - _ctx: &PluginValidationContext, - ) -> Result { - Ok(ValidationResult::Pass) - } + /// Optional offset for validation results struct used in Oracle account. Default + /// is `ValidationResultsOffset::NoOffset`. + pub results_offset: Option, } /// Oracle update info. @@ -57,4 +73,35 @@ pub struct OracleUpdateInfo { pub lifecycle_checks: Option>, /// Optional PDA (derived from Pubkey attached to `ExternalPluginKey`). pub pda: Option, + /// Optional offset for validation results struct used in Oracle account. Default + /// is `ValidationResultsOffset::NoOffset`. + pub results_offset: Option, +} + +/// Offset to where the validation results struct is located in an Oracle account. +#[derive(Clone, Debug, BorshSerialize, BorshDeserialize, Eq, PartialEq)] +pub enum ValidationResultsOffset { + /// The validation struct is located at the beginning of the account. + NoOffset, + /// The Oracle is an Anchor account so the validation struct is located after an 8-byte + /// account discriminator. + Anchor, + /// The validation struct is located at the specified offset within the account. + Custom(usize), +} + +/// Validation results struct for an Oracle account. +#[derive(Clone, Debug, BorshSerialize, BorshDeserialize, Eq, PartialEq)] +pub enum OracleValidation { + /// Version 1 of the format. + V1 { + /// Validation for the the create lifecycle action. + create: ExternalValidationResult, + /// Validation for the transfer lifecycle action. + transfer: ExternalValidationResult, + /// Validation for the burn lifecycle action. + burn: ExternalValidationResult, + /// Validation for the update lifecycle action. + update: ExternalValidationResult, + }, } diff --git a/programs/mpl-core/src/processor/add_external_plugin.rs b/programs/mpl-core/src/processor/add_external_plugin.rs index 8a84b650..626d7ee3 100644 --- a/programs/mpl-core/src/processor/add_external_plugin.rs +++ b/programs/mpl-core/src/processor/add_external_plugin.rs @@ -55,8 +55,10 @@ pub(crate) fn add_external_plugin<'a>( target_plugin: None, }; - if ExternalPlugin::validate_add_external_plugin(&args.init_info, &validation_ctx)? - == ValidationResult::Rejected + if ExternalPlugin::validate_add_external_plugin( + &ExternalPlugin::from(&args.init_info), + &validation_ctx, + )? == ValidationResult::Rejected { return Err(MplCoreError::InvalidAuthority.into()); } @@ -77,6 +79,7 @@ pub(crate) fn add_external_plugin<'a>( AssetV1::validate_add_external_plugin, CollectionV1::validate_add_external_plugin, Plugin::validate_add_external_plugin, + Some(ExternalPlugin::validate_add_external_plugin), )?; // Increment sequence number and save only if it is `Some(_)`. @@ -125,8 +128,10 @@ pub(crate) fn add_collection_external_plugin<'a>( target_plugin: None, }; - if ExternalPlugin::validate_add_external_plugin(&args.init_info, &validation_ctx)? - == ValidationResult::Rejected + if ExternalPlugin::validate_add_external_plugin( + &ExternalPlugin::from(&args.init_info), + &validation_ctx, + )? == ValidationResult::Rejected { return Err(MplCoreError::InvalidAuthority.into()); } @@ -143,6 +148,7 @@ pub(crate) fn add_collection_external_plugin<'a>( PluginType::check_add_external_plugin, CollectionV1::validate_add_external_plugin, Plugin::validate_add_external_plugin, + Some(ExternalPlugin::validate_add_external_plugin), )?; process_add_external_plugin::( diff --git a/programs/mpl-core/src/processor/add_plugin.rs b/programs/mpl-core/src/processor/add_plugin.rs index 4f4581bd..c05bbda6 100644 --- a/programs/mpl-core/src/processor/add_plugin.rs +++ b/programs/mpl-core/src/processor/add_plugin.rs @@ -73,6 +73,7 @@ pub(crate) fn add_plugin<'a>( AssetV1::validate_add_plugin, CollectionV1::validate_add_plugin, Plugin::validate_add_plugin, + None, )?; // Increment sequence number and save only if it is `Some(_)`. @@ -141,6 +142,7 @@ pub(crate) fn add_collection_plugin<'a>( PluginType::check_add_plugin, CollectionV1::validate_add_plugin, Plugin::validate_add_plugin, + None, )?; process_add_plugin::( diff --git a/programs/mpl-core/src/processor/approve_plugin_authority.rs b/programs/mpl-core/src/processor/approve_plugin_authority.rs index 7e7d44fc..f1a82064 100644 --- a/programs/mpl-core/src/processor/approve_plugin_authority.rs +++ b/programs/mpl-core/src/processor/approve_plugin_authority.rs @@ -63,6 +63,7 @@ pub(crate) fn approve_plugin_authority<'a>( AssetV1::validate_approve_plugin_authority, CollectionV1::validate_approve_plugin_authority, Plugin::validate_approve_plugin_authority, + None, )?; // Increment sequence number and save only if it is `Some(_)`. @@ -117,6 +118,7 @@ pub(crate) fn approve_collection_plugin_authority<'a>( PluginType::check_approve_plugin_authority, CollectionV1::validate_approve_plugin_authority, Plugin::validate_approve_plugin_authority, + None, )?; process_approve_plugin_authority::( diff --git a/programs/mpl-core/src/processor/burn.rs b/programs/mpl-core/src/processor/burn.rs index 6987e23d..5159ae1b 100644 --- a/programs/mpl-core/src/processor/burn.rs +++ b/programs/mpl-core/src/processor/burn.rs @@ -5,7 +5,7 @@ use solana_program::{account_info::AccountInfo, entrypoint::ProgramResult, msg}; use crate::{ error::MplCoreError, instruction::accounts::{BurnCollectionV1Accounts, BurnV1Accounts}, - plugins::{Plugin, PluginType}, + plugins::{ExternalPlugin, Plugin, PluginType}, state::{AssetV1, CollectionV1, CompressionProof, Key, SolanaAccount, Wrappable}, utils::{ close_program_account, load_key, rebuild_account_state_from_proof_data, resolve_authority, @@ -96,6 +96,7 @@ pub(crate) fn burn<'a>(accounts: &'a [AccountInfo<'a>], args: BurnV1Args) -> Pro AssetV1::validate_burn, CollectionV1::validate_burn, Plugin::validate_burn, + Some(ExternalPlugin::validate_burn), )?; process_burn(ctx.accounts.asset, authority)?; @@ -138,6 +139,7 @@ pub(crate) fn burn_collection<'a>( PluginType::check_burn, CollectionV1::validate_burn, Plugin::validate_burn, + Some(ExternalPlugin::validate_burn), )?; process_burn(ctx.accounts.collection, authority) diff --git a/programs/mpl-core/src/processor/compress.rs b/programs/mpl-core/src/processor/compress.rs index fbbbbf2f..e45cc3b1 100644 --- a/programs/mpl-core/src/processor/compress.rs +++ b/programs/mpl-core/src/processor/compress.rs @@ -56,6 +56,7 @@ pub(crate) fn compress<'a>( AssetV1::validate_compress, CollectionV1::validate_compress, Plugin::validate_compress, + None, )?; // Compress the asset and plugin registry into account space. diff --git a/programs/mpl-core/src/processor/create.rs b/programs/mpl-core/src/processor/create.rs index 0fe139c2..19c886ed 100644 --- a/programs/mpl-core/src/processor/create.rs +++ b/programs/mpl-core/src/processor/create.rs @@ -209,8 +209,10 @@ pub(crate) fn process_create<'a>( new_owner: None, target_plugin: None, }; - if ExternalPlugin::validate_create(plugin_init_info, &validation_ctx)? - == ValidationResult::Rejected + if ExternalPlugin::validate_create( + &ExternalPlugin::from(plugin_init_info), + &validation_ctx, + )? == ValidationResult::Rejected { approved = false; } diff --git a/programs/mpl-core/src/processor/create_collection.rs b/programs/mpl-core/src/processor/create_collection.rs index c16020c2..460bc7f8 100644 --- a/programs/mpl-core/src/processor/create_collection.rs +++ b/programs/mpl-core/src/processor/create_collection.rs @@ -174,8 +174,10 @@ pub(crate) fn process_create_collection<'a>( new_owner: None, target_plugin: None, }; - if ExternalPlugin::validate_create(plugin_init_info, &validation_ctx)? - == ValidationResult::Rejected + if ExternalPlugin::validate_create( + &ExternalPlugin::from(plugin_init_info), + &validation_ctx, + )? == ValidationResult::Rejected { approved = false; }; diff --git a/programs/mpl-core/src/processor/decompress.rs b/programs/mpl-core/src/processor/decompress.rs index 212e9c0b..ae032d3c 100644 --- a/programs/mpl-core/src/processor/decompress.rs +++ b/programs/mpl-core/src/processor/decompress.rs @@ -72,6 +72,7 @@ pub(crate) fn decompress<'a>( AssetV1::validate_decompress, CollectionV1::validate_decompress, Plugin::validate_decompress, + None, )?; // TODO Enable compression. diff --git a/programs/mpl-core/src/processor/remove_plugin.rs b/programs/mpl-core/src/processor/remove_plugin.rs index 051cb355..73d42bed 100644 --- a/programs/mpl-core/src/processor/remove_plugin.rs +++ b/programs/mpl-core/src/processor/remove_plugin.rs @@ -69,6 +69,7 @@ pub(crate) fn remove_plugin<'a>( AssetV1::validate_remove_plugin, CollectionV1::validate_remove_plugin, Plugin::validate_remove_plugin, + None, )?; // Increment sequence number and save only if it is `Some(_)`. @@ -133,6 +134,7 @@ pub(crate) fn remove_collection_plugin<'a>( PluginType::check_remove_plugin, CollectionV1::validate_remove_plugin, Plugin::validate_remove_plugin, + None, )?; process_remove_plugin( diff --git a/programs/mpl-core/src/processor/revoke_plugin_authority.rs b/programs/mpl-core/src/processor/revoke_plugin_authority.rs index 3537fbfe..e94c9a67 100644 --- a/programs/mpl-core/src/processor/revoke_plugin_authority.rs +++ b/programs/mpl-core/src/processor/revoke_plugin_authority.rs @@ -70,6 +70,7 @@ pub(crate) fn revoke_plugin_authority<'a>( AssetV1::validate_revoke_plugin_authority, CollectionV1::validate_revoke_plugin_authority, Plugin::validate_revoke_plugin_authority, + None, )?; // Increment sequence number and save only if it is `Some(_)`. @@ -138,6 +139,7 @@ pub(crate) fn revoke_collection_plugin_authority<'a>( PluginType::check_revoke_plugin_authority, CollectionV1::validate_revoke_plugin_authority, Plugin::validate_revoke_plugin_authority, + None, )?; let resolved_authorities = diff --git a/programs/mpl-core/src/processor/transfer.rs b/programs/mpl-core/src/processor/transfer.rs index 197ad626..d3399c4a 100644 --- a/programs/mpl-core/src/processor/transfer.rs +++ b/programs/mpl-core/src/processor/transfer.rs @@ -5,7 +5,7 @@ use solana_program::{account_info::AccountInfo, entrypoint::ProgramResult, msg}; use crate::{ error::MplCoreError, instruction::accounts::TransferV1Accounts, - plugins::{Plugin, PluginType}, + plugins::{ExternalPlugin, Plugin, PluginType}, state::{AssetV1, Authority, CollectionV1, CompressionProof, Key, SolanaAccount, Wrappable}, utils::{ compress_into_account_space, load_key, rebuild_account_state_from_proof_data, @@ -89,6 +89,7 @@ pub(crate) fn transfer<'a>(accounts: &'a [AccountInfo<'a>], args: TransferV1Args AssetV1::validate_transfer, CollectionV1::validate_transfer, Plugin::validate_transfer, + Some(ExternalPlugin::validate_transfer), )?; // Reset every owner-managed plugin in the registry. diff --git a/programs/mpl-core/src/processor/update.rs b/programs/mpl-core/src/processor/update.rs index 315ec7b9..acac1236 100644 --- a/programs/mpl-core/src/processor/update.rs +++ b/programs/mpl-core/src/processor/update.rs @@ -7,7 +7,9 @@ use solana_program::{ use crate::{ error::MplCoreError, instruction::accounts::{UpdateCollectionV1Accounts, UpdateV1Accounts}, - plugins::{Plugin, PluginHeaderV1, PluginRegistryV1, PluginType, RegistryRecord}, + plugins::{ + ExternalPlugin, Plugin, PluginHeaderV1, PluginRegistryV1, PluginType, RegistryRecord, + }, state::{AssetV1, CollectionV1, DataBlob, Key, SolanaAccount, UpdateAuthority}, utils::{ load_key, resize_or_reallocate_account, resolve_authority, validate_asset_permissions, @@ -59,6 +61,7 @@ pub(crate) fn update<'a>(accounts: &'a [AccountInfo<'a>], args: UpdateV1Args) -> AssetV1::validate_update, CollectionV1::validate_update, Plugin::validate_update, + Some(ExternalPlugin::validate_update), )?; // Increment sequence number and save only if it is `Some(_)`. @@ -142,6 +145,7 @@ pub(crate) fn update_collection<'a>( PluginType::check_update, CollectionV1::validate_update, Plugin::validate_update, + Some(ExternalPlugin::validate_update), )?; let collection_size = collection.get_size() as isize; diff --git a/programs/mpl-core/src/processor/update_plugin.rs b/programs/mpl-core/src/processor/update_plugin.rs index 62100470..6e5fa353 100644 --- a/programs/mpl-core/src/processor/update_plugin.rs +++ b/programs/mpl-core/src/processor/update_plugin.rs @@ -60,6 +60,7 @@ pub(crate) fn update_plugin<'a>( AssetV1::validate_update_plugin, CollectionV1::validate_update_plugin, Plugin::validate_update_plugin, + None, )?; let mut plugin_registry = plugin_registry.ok_or(MplCoreError::PluginsNotInitialized)?; @@ -188,6 +189,7 @@ pub(crate) fn update_collection_plugin<'a>( PluginType::check_update_plugin, CollectionV1::validate_update_plugin, Plugin::validate_update_plugin, + None, )?; // let (collection, plugin_header, plugin_registry) = diff --git a/programs/mpl-core/src/utils.rs b/programs/mpl-core/src/utils.rs index 614163e8..256391d8 100644 --- a/programs/mpl-core/src/utils.rs +++ b/programs/mpl-core/src/utils.rs @@ -220,6 +220,9 @@ pub(crate) fn validate_asset_permissions<'a>( &Plugin, &PluginValidationContext, ) -> Result, + _external_plugin_validate_fp: Option< + fn(&ExternalPlugin, &PluginValidationContext) -> Result, + >, ) -> Result<(AssetV1, Option, Option), ProgramError> { let (deserialized_asset, plugin_header, plugin_registry) = fetch_core_data::(asset)?; let resolved_authorities = @@ -363,6 +366,9 @@ pub(crate) fn validate_collection_permissions<'a>( &Plugin, &PluginValidationContext, ) -> Result, + _external_plugin_validate_fp: Option< + fn(&ExternalPlugin, &PluginValidationContext) -> Result, + >, ) -> Result< ( CollectionV1,