Skip to content

Commit

Permalink
Feat/mpl core alpha (#5)
Browse files Browse the repository at this point in the history
* feat(mpl-core): update to mpl-core alpha
  • Loading branch information
shotgunofdeath committed May 21, 2024
1 parent b87ec5e commit ef9de9f
Show file tree
Hide file tree
Showing 7 changed files with 211 additions and 139 deletions.
2 changes: 1 addition & 1 deletion .github/file-filters.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ js_client: &js_client
- ".github/test-js-client.yml"
- ".github/file-filters.yml"
- ".github/.env"
- "**/"
- "/**"
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
},
"peerDependencies": {
"@metaplex-foundation/digital-asset-standard-api": "^1.0.3",
"@metaplex-foundation/mpl-core": "^0.4.7",
"@metaplex-foundation/mpl-core": "1.0.0-alpha.6",
"@metaplex-foundation/umi": ">=0.8.2 < 1"
},
"devDependencies": {
Expand Down
75 changes: 40 additions & 35 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

31 changes: 22 additions & 9 deletions src/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
AddBlocker,
AssetV1,
Attributes,
BaseUpdateAuthority,
UpdateAuthority,
BurnDelegate,
CollectionV1,
Edition,
Expand All @@ -17,7 +17,7 @@ import {
ImmutableMetadata,
Key,
mapPlugin,
MasterEdition,
BaseMasterEdition,
MPL_CORE_PROGRAM_ID,
PermanentBurnDelegate,
PermanentFreezeDelegate,
Expand Down Expand Up @@ -60,8 +60,8 @@ function base64ToUInt8Array(base64: string) {
function getUpdateAuthority(
groupingItem: DasApiAssetGrouping | undefined,
authority: DasApiAssetAuthority
): Record<'updateAuthority', BaseUpdateAuthority> {
const result: { updateAuthority: BaseUpdateAuthority } = {
): Record<'updateAuthority', UpdateAuthority> {
const result: { updateAuthority: UpdateAuthority } = {
updateAuthority: { type: 'None' },
};

Expand All @@ -84,13 +84,14 @@ function getAccountHeader(
executable?: boolean,
lamps?: BigIntInput,
rentEpoch?: number
): Record<'header', AccountHeader> {
): Record<'header', AccountHeader & { exists: boolean }> {
return {
header: {
executable: executable ?? false,
owner: MPL_CORE_PROGRAM_ID,
lamports: lamports(lamps ?? -1),
...(rentEpoch !== undefined ? { rentEpoch: BigInt(rentEpoch) } : {}),
exists: true,
},
};
}
Expand All @@ -105,15 +106,27 @@ function getRuleSet(dasRuleSet: string | Record<string, any>): RuleSet {
)
: [];

// RuleSet has both __kind and type for backwards compatibility
if (ruleSetKind === 'program_allow_list') {
return ruleSet('ProgramAllowList', [ruleSetData]);
return {
...ruleSet('ProgramAllowList', [ruleSetData]),
type: 'ProgramAllowList',
addresses: ruleSetData,
};
}

if (ruleSetKind === 'program_deny_list') {
return ruleSet('ProgramDenyList', [ruleSetData]);
return {
...ruleSet('ProgramDenyList', [ruleSetData]),
type: 'ProgramDenyList',
addresses: ruleSetData,
};
}

return ruleSet('None');
return {
...ruleSet('None'),
type: 'None',
};
}

function dasPluginDataToCorePluginData(
Expand All @@ -129,7 +142,7 @@ function dasPluginDataToCorePluginData(
| PermanentTransferDelegate
| PermanentBurnDelegate
| Edition
| MasterEdition
| BaseMasterEdition
| AddBlocker
| ImmutableMetadata {
// TODO: Refactor when DAS types are defined
Expand Down
Loading

0 comments on commit ef9de9f

Please sign in to comment.