@metaplex-foundation/mpl-core
Advanced tools
Comparing version 1.1.0-alpha.1 to 1.1.0
@@ -261,2 +261,8 @@ /** | ||
} | ||
/** CollectionMustBeEmpty: Collection must be empty to be burned */ | ||
export declare class CollectionMustBeEmptyError extends ProgramError { | ||
readonly name: string; | ||
readonly code: number; | ||
constructor(program: Program, cause?: Error); | ||
} | ||
/** TwoDataSources: Two data sources provided, only one is allowed */ | ||
@@ -263,0 +269,0 @@ export declare class TwoDataSourcesError extends ProgramError { |
@@ -10,3 +10,3 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.getMplCoreErrorFromName = exports.getMplCoreErrorFromCode = exports.CannotAddDataSectionError = exports.InvalidPluginAdapterTargetError = exports.NoDataSourcesError = exports.UnsupportedOperationError = exports.TwoDataSourcesError = exports.InvalidPluginOperationError = exports.MissingSignerError = exports.UninitializedOracleAccountError = exports.InvalidOracleAccountDataError = exports.DuplicateLifecycleChecksError = exports.RequiresLifecycleCheckError = exports.OracleCanRejectOnlyError = exports.MissingExternalPluginAdapterAccountError = exports.MissingAssetError = exports.ExternalPluginAdapterAlreadyExistsError = exports.ExternalPluginAdapterNotFoundError = exports.InvalidLogWrapperProgramError = exports.ConflictingAuthorityError = exports.InvalidPluginSettingError = exports.CannotRedelegateError = exports.NoApprovalsError = exports.MissingCollectionError = exports.InvalidAssetError = exports.NotAvailableError = exports.MissingSystemProgramError = exports.MissingNewOwnerError = exports.MissingUpdateAuthorityError = exports.InvalidCollectionError = exports.AlreadyDecompressedError = exports.AlreadyCompressedError = exports.NumericalOverflowErrorError = exports.PluginAlreadyExistsError = exports.CannotBurnCollectionError = exports.CannotMigratePrintsError = exports.CannotMigrateMasterWithSupplyError = exports.MissingCompressionProofError = exports.AssetIsFrozenError = exports.InvalidAuthorityError = exports.InvalidPluginError = exports.IncorrectAssetHashError = exports.IncorrectAccountError = exports.NumericalOverflowError = exports.PluginNotFoundError = exports.PluginsNotInitializedError = exports.SerializationErrorError = exports.DeserializationErrorError = exports.InvalidSystemProgramError = void 0; | ||
exports.getMplCoreErrorFromName = exports.getMplCoreErrorFromCode = exports.CannotAddDataSectionError = exports.InvalidPluginAdapterTargetError = exports.NoDataSourcesError = exports.UnsupportedOperationError = exports.TwoDataSourcesError = exports.CollectionMustBeEmptyError = exports.InvalidPluginOperationError = exports.MissingSignerError = exports.UninitializedOracleAccountError = exports.InvalidOracleAccountDataError = exports.DuplicateLifecycleChecksError = exports.RequiresLifecycleCheckError = exports.OracleCanRejectOnlyError = exports.MissingExternalPluginAdapterAccountError = exports.MissingAssetError = exports.ExternalPluginAdapterAlreadyExistsError = exports.ExternalPluginAdapterNotFoundError = exports.InvalidLogWrapperProgramError = exports.ConflictingAuthorityError = exports.InvalidPluginSettingError = exports.CannotRedelegateError = exports.NoApprovalsError = exports.MissingCollectionError = exports.InvalidAssetError = exports.NotAvailableError = exports.MissingSystemProgramError = exports.MissingNewOwnerError = exports.MissingUpdateAuthorityError = exports.InvalidCollectionError = exports.AlreadyDecompressedError = exports.AlreadyCompressedError = exports.NumericalOverflowErrorError = exports.PluginAlreadyExistsError = exports.CannotBurnCollectionError = exports.CannotMigratePrintsError = exports.CannotMigrateMasterWithSupplyError = exports.MissingCompressionProofError = exports.AssetIsFrozenError = exports.InvalidAuthorityError = exports.InvalidPluginError = exports.IncorrectAssetHashError = exports.IncorrectAccountError = exports.NumericalOverflowError = exports.PluginNotFoundError = exports.PluginsNotInitializedError = exports.SerializationErrorError = exports.DeserializationErrorError = exports.InvalidSystemProgramError = void 0; | ||
const umi_1 = require("@metaplex-foundation/umi"); | ||
@@ -477,2 +477,13 @@ const codeToErrorMap = new Map(); | ||
nameToErrorMap.set('InvalidPluginOperation', InvalidPluginOperationError); | ||
/** CollectionMustBeEmpty: Collection must be empty to be burned */ | ||
class CollectionMustBeEmptyError extends umi_1.ProgramError { | ||
constructor(program, cause) { | ||
super('Collection must be empty to be burned', program, cause); | ||
this.name = 'CollectionMustBeEmpty'; | ||
this.code = 0x2a; // 42 | ||
} | ||
} | ||
exports.CollectionMustBeEmptyError = CollectionMustBeEmptyError; | ||
codeToErrorMap.set(0x2a, CollectionMustBeEmptyError); | ||
nameToErrorMap.set('CollectionMustBeEmpty', CollectionMustBeEmptyError); | ||
/** TwoDataSources: Two data sources provided, only one is allowed */ | ||
@@ -483,7 +494,7 @@ class TwoDataSourcesError extends umi_1.ProgramError { | ||
this.name = 'TwoDataSources'; | ||
this.code = 0x2a; // 42 | ||
this.code = 0x2b; // 43 | ||
} | ||
} | ||
exports.TwoDataSourcesError = TwoDataSourcesError; | ||
codeToErrorMap.set(0x2a, TwoDataSourcesError); | ||
codeToErrorMap.set(0x2b, TwoDataSourcesError); | ||
nameToErrorMap.set('TwoDataSources', TwoDataSourcesError); | ||
@@ -495,7 +506,7 @@ /** UnsupportedOperation: External Plugin does not support this operation */ | ||
this.name = 'UnsupportedOperation'; | ||
this.code = 0x2b; // 43 | ||
this.code = 0x2c; // 44 | ||
} | ||
} | ||
exports.UnsupportedOperationError = UnsupportedOperationError; | ||
codeToErrorMap.set(0x2b, UnsupportedOperationError); | ||
codeToErrorMap.set(0x2c, UnsupportedOperationError); | ||
nameToErrorMap.set('UnsupportedOperation', UnsupportedOperationError); | ||
@@ -507,7 +518,7 @@ /** NoDataSources: No data sources provided, one is required */ | ||
this.name = 'NoDataSources'; | ||
this.code = 0x2c; // 44 | ||
this.code = 0x2d; // 45 | ||
} | ||
} | ||
exports.NoDataSourcesError = NoDataSourcesError; | ||
codeToErrorMap.set(0x2c, NoDataSourcesError); | ||
codeToErrorMap.set(0x2d, NoDataSourcesError); | ||
nameToErrorMap.set('NoDataSources', NoDataSourcesError); | ||
@@ -519,7 +530,7 @@ /** InvalidPluginAdapterTarget: This plugin adapter cannot be added to an Asset */ | ||
this.name = 'InvalidPluginAdapterTarget'; | ||
this.code = 0x2d; // 45 | ||
this.code = 0x2e; // 46 | ||
} | ||
} | ||
exports.InvalidPluginAdapterTargetError = InvalidPluginAdapterTargetError; | ||
codeToErrorMap.set(0x2d, InvalidPluginAdapterTargetError); | ||
codeToErrorMap.set(0x2e, InvalidPluginAdapterTargetError); | ||
nameToErrorMap.set('InvalidPluginAdapterTarget', InvalidPluginAdapterTargetError); | ||
@@ -531,7 +542,7 @@ /** CannotAddDataSection: Cannot add a Data Section without a linked external plugin */ | ||
this.name = 'CannotAddDataSection'; | ||
this.code = 0x2e; // 46 | ||
this.code = 0x2f; // 47 | ||
} | ||
} | ||
exports.CannotAddDataSectionError = CannotAddDataSectionError; | ||
codeToErrorMap.set(0x2e, CannotAddDataSectionError); | ||
codeToErrorMap.set(0x2f, CannotAddDataSectionError); | ||
nameToErrorMap.set('CannotAddDataSection', CannotAddDataSectionError); | ||
@@ -538,0 +549,0 @@ /** |
@@ -12,3 +12,3 @@ "use strict"; | ||
: null, | ||
schema: d.schema ? d.schema : null, | ||
schema: d.schema ?? null, | ||
}; | ||
@@ -19,3 +19,3 @@ } | ||
return { | ||
schema: d.schema ? d.schema : null, | ||
schema: d.schema ?? null, | ||
}; | ||
@@ -22,0 +22,0 @@ } |
@@ -5,2 +5,3 @@ "use strict"; | ||
const umi_1 = require("@metaplex-foundation/umi"); | ||
const msgpack_1 = require("@msgpack/msgpack"); | ||
const generated_1 = require("../generated"); | ||
@@ -180,5 +181,8 @@ const utils_1 = require("../utils"); | ||
else if (plugin.schema === generated_1.ExternalPluginAdapterSchema.MsgPack) { | ||
// eslint-disable-next-line no-console | ||
console.warn('MsgPack schema currently not supported, falling back to binary'); | ||
data = dataSlice; | ||
if (dataSlice.length === 0) { | ||
data = null; | ||
} | ||
else { | ||
data = (0, msgpack_1.decode)(dataSlice); | ||
} | ||
} | ||
@@ -185,0 +189,0 @@ return data; |
@@ -18,3 +18,3 @@ "use strict"; | ||
lifecycleChecks: (0, lifecycleChecks_1.lifecycleChecksToBase)(l.lifecycleChecks), | ||
schema: l.schema ? l.schema : null, | ||
schema: l.schema ?? null, | ||
dataAuthority: l.dataAuthority | ||
@@ -34,3 +34,3 @@ ? (0, pluginAuthority_1.pluginAuthorityToBase)(l.dataAuthority) | ||
: null, | ||
schema: l.schema ? l.schema : null, | ||
schema: l.schema ?? null, | ||
// TODO update dataAuthority? | ||
@@ -37,0 +37,0 @@ }; |
@@ -11,3 +11,3 @@ "use strict"; | ||
: null, | ||
schema: d.schema ? d.schema : null, | ||
schema: d.schema ?? null, | ||
}; | ||
@@ -18,3 +18,3 @@ } | ||
return { | ||
schema: d.schema ? d.schema : null, | ||
schema: d.schema ?? null, | ||
}; | ||
@@ -21,0 +21,0 @@ } |
@@ -32,3 +32,3 @@ "use strict"; | ||
: null, | ||
schema: l.schema ? l.schema : null, | ||
schema: l.schema ?? null, | ||
}; | ||
@@ -35,0 +35,0 @@ } |
{ | ||
"name": "@metaplex-foundation/mpl-core", | ||
"version": "1.1.0-alpha.1", | ||
"version": "1.1.0", | ||
"description": "Digital Assets", | ||
@@ -22,2 +22,5 @@ "main": "dist/src/index.js", | ||
}, | ||
"dependencies": { | ||
"@msgpack/msgpack": "^3.0.0-beta2" | ||
}, | ||
"devDependencies": { | ||
@@ -24,0 +27,0 @@ "@ava/typescript": "^5.0.0", |
239
README.md
@@ -14,3 +14,3 @@ # JavaScript client for Mpl Core | ||
```ts | ||
import { createUmi } from '@metaplex-foundation/umi'; | ||
import { createUmi } from '@metaplex-foundation/umi-bundle-defaults'; | ||
import { mplCore } from '@metaplex-foundation/mpl-core'; | ||
@@ -42,69 +42,68 @@ | ||
// Create an asset | ||
const assetAddress = generateSigner(umi); | ||
const owner = generateSigner(umi); | ||
const assetAddress = generateSigner(umi); | ||
const owner = generateSigner(umi); | ||
await create(umi, { | ||
name: 'Test Asset', | ||
uri: 'https://example.com/asset.json', | ||
asset: assetAddress, | ||
owner: owner.publicKey, // optional, will default to payer | ||
}).sendAndConfirm(umi); | ||
await create(umi, { | ||
name: 'Test Asset', | ||
uri: 'https://example.com/asset.json', | ||
asset: assetAddress, | ||
owner: owner.publicKey, // optional, will default to payer | ||
}).sendAndConfirm(umi); | ||
// Fetch an asset | ||
const asset = await fetchAssetV1(umi, assetAddress.publicKey); | ||
// Fetch an asset | ||
const asset = await fetchAssetV1(umi, assetAddress.publicKey); | ||
// Create a collection | ||
const collectionUpdateAuthority = generateSigner(umi); | ||
const collectionAddress = generateSigner(umi); | ||
await createCollection(umi, { | ||
name: 'Test Collection', | ||
uri: 'https://example.com/collection.json', | ||
collection: collectionAddress, | ||
updateAuthority: collectionUpdateAuthority.publicKey, // optional, defaults to payer | ||
}).sendAndConfirm(umi); | ||
// Create a collection | ||
const collectionUpdateAuthority = generateSigner(umi); | ||
const collectionAddress = generateSigner(umi); | ||
await createCollection(umi, { | ||
name: 'Test Collection', | ||
uri: 'https://example.com/collection.json', | ||
collection: collectionAddress, | ||
updateAuthority: collectionUpdateAuthority.publicKey, // optional, defaults to payer | ||
}).sendAndConfirm(umi); | ||
// Fetch a collection | ||
const collection = await fetchCollectionV1(umi, collectionAddress.publicKey); | ||
// Fetch a collection | ||
const collection = await fetchCollectionV1(umi, collectionAddress.publicKey); | ||
// Create an asset in a collection, the authority must be the updateAuthority of the collection | ||
await create(umi, { | ||
name: 'Test Asset', | ||
uri: 'https://example.com/asset.json', | ||
asset: assetAddress, | ||
collection, | ||
authority: collectionUpdateAuthority, // optional, defaults to payer | ||
}).sendAndConfirm(umi); | ||
// Create an asset in a collection, the authority must be the updateAuthority of the collection | ||
await create(umi, { | ||
name: 'Test Asset', | ||
uri: 'https://example.com/asset.json', | ||
asset: assetAddress, | ||
collection, | ||
authority: collectionUpdateAuthority, // optional, defaults to payer | ||
}).sendAndConfirm(umi); | ||
// Transfer an asset | ||
const recipient = generateSigner(umi); | ||
await transfer(umi, { | ||
asset, | ||
newOwner: recipient.publicKey, | ||
}).sendAndConfirm(umi); | ||
// Transfer an asset | ||
const recipient = generateSigner(umi); | ||
await transfer(umi, { | ||
asset, | ||
newOwner: recipient.publicKey, | ||
}).sendAndConfirm(umi); | ||
// Transfer an asset in a collection | ||
await transfer(umi, { | ||
asset, | ||
newOwner: recipient.publicKey, | ||
collection, | ||
}).sendAndConfirm(umi); | ||
// Transfer an asset in a collection | ||
await transfer(umi, { | ||
asset, | ||
newOwner: recipient.publicKey, | ||
collection, | ||
}).sendAndConfirm(umi); | ||
// GPA fetch assets by owner | ||
const assetsByOwner = await getAssetV1GpaBuilder(umi) | ||
.whereField('key', Key.AssetV1) | ||
.whereField('owner', owner.publicKey) | ||
.getDeserialized(); | ||
// GPA fetch assets by owner | ||
const assetsByOwner = await getAssetV1GpaBuilder(umi) | ||
.whereField('key', Key.AssetV1) | ||
.whereField('owner', owner.publicKey) | ||
.getDeserialized(); | ||
// GPA fetch assets by collection | ||
const assetsByCollection = await getAssetV1GpaBuilder(umi) | ||
.whereField('key', Key.AssetV1) | ||
.whereField( | ||
'updateAuthority', | ||
updateAuthority('Collection', [collectionAddress.publicKey]) | ||
) | ||
.getDeserialized(); | ||
// GPA fetch assets by collection | ||
const assetsByCollection = await getAssetV1GpaBuilder(umi) | ||
.whereField('key', Key.AssetV1) | ||
.whereField( | ||
'updateAuthority', | ||
updateAuthority('Collection', [collectionAddress.publicKey]) | ||
) | ||
.getDeserialized(); | ||
// DAS API (RPC based indexing) fetch assets by owner/collection | ||
// Coming soon | ||
// DAS API (RPC based indexing) fetch assets by owner/collection | ||
// Coming soon | ||
``` | ||
@@ -115,70 +114,70 @@ 5. Some advanced examples | ||
// Freezing an asset | ||
const assetAddress = generateSigner(umi); | ||
const freezeDelegate = generateSigner(umi); | ||
// Freezing an asset | ||
const assetAddress = generateSigner(umi); | ||
const freezeDelegate = generateSigner(umi); | ||
await addPlugin(umi, { | ||
asset: assetAddress.publicKey, | ||
// adds the owner-managed freeze plugin to the asset | ||
plugin: { | ||
type: 'FreezeDelegate', | ||
frozen: true, | ||
// Optionally set the authority to a delegate who can unfreeze. If unset, this will be the Owner | ||
// This is functionally the same as calling addPlugin and approvePluginAuthority separately. | ||
// Freezing with a delegate is commonly used for escrowless staking programs. | ||
authority: { | ||
type: 'Address', | ||
address: freezeDelegate.publicKey, | ||
}, | ||
} | ||
}).sendAndConfirm(umi); | ||
await addPlugin(umi, { | ||
asset: assetAddress.publicKey, | ||
// adds the owner-managed freeze plugin to the asset | ||
plugin: { | ||
type: 'FreezeDelegate', | ||
frozen: true, | ||
// Optionally set the authority to a delegate who can unfreeze. If unset, this will be the Owner | ||
// This is functionally the same as calling addPlugin and approvePluginAuthority separately. | ||
// Freezing with a delegate is commonly used for escrowless staking programs. | ||
authority: { | ||
type: 'Address', | ||
address: freezeDelegate.publicKey, | ||
}, | ||
} | ||
}).sendAndConfirm(umi); | ||
// Unfreezing an asset with a delegate | ||
// Revoking an authority will revert the authority back to the owner for owner-managed plugins | ||
await revokePluginAuthority(umi, { | ||
asset: assetAddress.publicKey, | ||
plugin: { | ||
type: 'FreezeDelegate', | ||
}, | ||
authority: freezeDelegate, | ||
}).sendAndConfirm(umi); | ||
// Unfreezing an asset with a delegate | ||
// Revoking an authority will revert the authority back to the owner for owner-managed plugins | ||
await revokePluginAuthority(umi, { | ||
asset: assetAddress.publicKey, | ||
plugin: { | ||
type: 'FreezeDelegate', | ||
}, | ||
authority: freezeDelegate, | ||
}).sendAndConfirm(umi); | ||
// Create a collection with royalties | ||
const collectionAddress = generateSigner(umi); | ||
const creator1 = generateSigner(umi); | ||
const creator2 = generateSigner(umi); | ||
// Create a collection with royalties | ||
const collectionAddress = generateSigner(umi); | ||
const creator1 = generateSigner(umi); | ||
const creator2 = generateSigner(umi); | ||
await createCollection(umi, { | ||
name: 'Test Collection', | ||
uri: 'https://example.com/collection.json', | ||
collection: collectionAddress, | ||
plugins: [ | ||
{ | ||
type: 'Royalties', | ||
basisPoints: 500, | ||
creators: [ | ||
{ | ||
address: creator1.publicKey, | ||
percentage: 20, | ||
}, | ||
{ | ||
address: creator2.publicKey, | ||
percentage: 80, | ||
}, | ||
], | ||
ruleSet: ruleSet('None'), // Compatibility rule set | ||
await createCollection(umi, { | ||
name: 'Test Collection', | ||
uri: 'https://example.com/collection.json', | ||
collection: collectionAddress, | ||
plugins: [ | ||
{ | ||
type: 'Royalties', | ||
basisPoints: 500, | ||
creators: [ | ||
{ | ||
address: creator1.publicKey, | ||
percentage: 20, | ||
}, | ||
{ | ||
address: creator2.publicKey, | ||
percentage: 80, | ||
}, | ||
], | ||
ruleSet: ruleSet('None'), // Compatibility rule set | ||
}, | ||
], | ||
}).sendAndConfirm(umi); | ||
}, | ||
], | ||
}).sendAndConfirm(umi); | ||
// Create an asset in a collection. | ||
// Assets in a collection will inherit the collection's authority-managed plugins, in this case the royalties plugin | ||
await create(umi, { | ||
name: 'Test Asset', | ||
uri: 'https://example.com/asset.json', | ||
asset: assetAddress, | ||
collection: await fetchCollectionV1(umi, collectionAddress.publicKey), | ||
}).sendAndConfirm(umi); | ||
// Create an asset in a collection. | ||
// Assets in a collection will inherit the collection's authority-managed plugins, in this case the royalties plugin | ||
await create(umi, { | ||
name: 'Test Asset', | ||
uri: 'https://example.com/asset.json', | ||
asset: assetAddress, | ||
collection: await fetchCollectionV1(umi, collectionAddress.publicKey), | ||
}).sendAndConfirm(umi); | ||
``` | ||
@@ -185,0 +184,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
812610
13054
0
3
187
+ Added@msgpack/msgpack@3.0.0-beta2(transitive)