Skip to content

Commit

Permalink
Use das api package (#56)
Browse files Browse the repository at this point in the history
* Use das api package

* Fix linting
  • Loading branch information
febo authored Oct 13, 2023
1 parent cf7d749 commit d474244
Show file tree
Hide file tree
Showing 9 changed files with 38 additions and 283 deletions.
3 changes: 2 additions & 1 deletion clients/js/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,13 @@
"license": "Apache-2.0",
"dependencies": {
"@metaplex-foundation/mpl-token-metadata": "3.0.0-alpha.27",
"@metaplex-foundation/digital-asset-standard-api": "^1.0.0-alpha.0",
"@metaplex-foundation/mpl-toolbox": "^0.9.0",
"@noble/hashes": "^1.3.1",
"merkletreejs": "^0.3.9"
},
"peerDependencies": {
"@metaplex-foundation/umi": "^0.8.2"
"@metaplex-foundation/umi": "^0.8.9"
},
"devDependencies": {
"@ava/typescript": "^3.0.1",
Expand Down
11 changes: 11 additions & 0 deletions clients/js/pnpm-lock.yaml

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

11 changes: 7 additions & 4 deletions clients/js/src/getAssetWithProof.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,12 @@ import {
some,
wrapNullable,
} from '@metaplex-foundation/umi';
import {
DasApiAsset,
DasApiInterface,
GetAssetProofRpcResponse,
} from '@metaplex-foundation/digital-asset-standard-api';
import { MetadataArgs, TokenProgramVersion, TokenStandard } from './generated';
import { ReadApiInterface } from './readApiDecorator';
import { GetAssetProofRpcResponse, ReadApiAsset } from './readApiTypes';

export type AssetWithProof = {
leafOwner: PublicKey;
Expand All @@ -22,12 +25,12 @@ export type AssetWithProof = {
index: number;
proof: PublicKey[];
metadata: MetadataArgs;
rpcAsset: ReadApiAsset;
rpcAsset: DasApiAsset;
rpcAssetProof: GetAssetProofRpcResponse;
};

export const getAssetWithProof = async (
context: Pick<Context, 'rpc'> & { rpc: ReadApiInterface },
context: Pick<Context, 'rpc'> & { rpc: DasApiInterface },
assetId: PublicKey
): Promise<AssetWithProof> => {
const [rpcAsset, rpcAssetProof] = await Promise.all([
Expand Down
2 changes: 0 additions & 2 deletions clients/js/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,3 @@ export * from './hooked';
export * from './leafAssetId';
export * from './merkle';
export * from './plugin';
export * from './readApiDecorator';
export * from './readApiTypes';
18 changes: 3 additions & 15 deletions clients/js/src/plugin.ts
Original file line number Diff line number Diff line change
@@ -1,28 +1,16 @@
import { RpcInterface, UmiPlugin } from '@metaplex-foundation/umi';
import { UmiPlugin } from '@metaplex-foundation/umi';
import { dasApi } from '@metaplex-foundation/digital-asset-standard-api';
import {
createMplBubblegumProgram,
createSplAccountCompressionProgram,
createSplNoopProgram,
} from './generated';
import { ReadApiInterface, createReadApiDecorator } from './readApiDecorator';

export const mplBubblegum = (): UmiPlugin => ({
install(umi) {
umi.use(readApi());
umi.use(dasApi());
umi.programs.add(createMplBubblegumProgram(), false);
umi.programs.add(createSplAccountCompressionProgram(), false);
umi.programs.add(createSplNoopProgram(), false);
},
});

export const readApi = (): UmiPlugin => ({
install(umi) {
umi.rpc = createReadApiDecorator(umi.rpc);
},
});

declare module '@metaplex-foundation/umi' {
interface Umi {
rpc: RpcInterface & ReadApiInterface;
}
}
82 changes: 0 additions & 82 deletions clients/js/src/readApiDecorator.ts

This file was deleted.

166 changes: 0 additions & 166 deletions clients/js/src/readApiTypes.ts

This file was deleted.

Loading

0 comments on commit d474244

Please sign in to comment.