Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: adds a wip SDK structure #130

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@
},
"peerDependencies": {
"@metaplex-foundation/mpl-auction": "^0.0.2",
"@metaplex-foundation/mpl-auction-house": "^0.0.2",
"@metaplex-foundation/mpl-core": "^0.0.2",
"@metaplex-foundation/mpl-metaplex": "^0.0.5",
"@metaplex-foundation/mpl-token-metadata": "^0.0.2",
Expand Down Expand Up @@ -115,5 +116,14 @@
"extends": [
"@commitlint/config-conventional"
]
},
"resolutions": {
"@metaplex-foundation/metaplex-program-library": "portal:../metaplex-program-library",
"@metaplex-foundation/mpl-auction-house": "portal:../metaplex-program-library/auction-house/js",
"@metaplex-foundation/mpl-auction": "portal:../metaplex-program-library/auction/js",
"@metaplex-foundation/mpl-core": "portal:../metaplex-program-library/core/js",
"@metaplex-foundation/mpl-metaplex": "portal:../metaplex-program-library/metaplex/js",
"@metaplex-foundation/mpl-token-metadata": "portal:../metaplex-program-library/token-metadata/js",
"@metaplex-foundation/mpl-token-vault": "portal:../metaplex-program-library/token-vault/js"
}
}
}
71 changes: 71 additions & 0 deletions src/auctionHouse/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
import { Connection, PublicKey } from "@solana/web3.js";
import { AuctionHouseSettings } from "./settings";
import { AuctionHouseStats } from "./stats";

export class AuctionHouseClient {
private connection: Connection;

constructor(connection: Connection) {
this.connection = connection;
}

loadAuctionHouse(auctionHouseKey: PublicKey): Promise<AuctionHouse> {
return new AuctionHouse({}).refresh();
}

createAuctionHouse(settings: AuctionHouseSettings): Promise<AuctionHouse> {
return new AuctionHouse({}).refresh();
}

updateAuctionHouse(auctionHouseKey: PublicKey, settings: AuctionHouseSettings): Promise<AuctionHouse> {
return new AuctionHouse({}).refresh();
}
}

export class AuctionHouse {
private settings: AuctionHouseSettings;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd call those args or config. It's not exactly settings that are stored in a file or something.

private stats: AuctionHouseStats;
constructor(settings?: AuctionHouseSettings) {
this.settings = settings;
}
private checkInitialized() {
return this.settings && this.stats;
}

async refresh(): Promise<AuctionHouse> {
//TODO: refresh stats and settings
return this;
}

async show() {

}

async bid() {

}

async list() {

}

async buy() {

}

async sell() {

}

async execute_sale() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we use camel case?


}

async execute_sale_with_price() {

}

async deposit() {

}
}
4 changes: 4 additions & 0 deletions src/auctionHouse/settings.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export type AuctionHouseSettings = {


};
3 changes: 3 additions & 0 deletions src/auctionHouse/stats.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export type AuctionHouseStats = {

};
24 changes: 24 additions & 0 deletions src/client.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import { Connection } from "./Connection";
import { AuctionHouseClient } from "./auctionHouse";

export class MetaplexClient {
private auctionHouseClient: AuctionHouseClient;
// private metadataClient: MetadataClient; EXAMPLE OF OTHER FEATURES

constructor(private connection: Connection) { }

get AuctionHouse() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why does this have to live on the client instead of just being returned?
i.e. if I'm done with it the GC cannot collect it now because it's still referenced.
Incurring that memory overhead only makes sense if creating it is expensive (which I don't think it is given you're just calling a constructor).

this.auctionHouseClient = this.auctionHouseClient || new AuctionHouseClient(this.connection);
return this.auctionHouseClient
}

// get Metadata() {
// this.metadataClient = this.metadataClient || new MetadataClient(this.connection); EXAMPLE OF OTHER FEATURES
// return this.metadataClient;
// }

}
export const Metaplex = {
AuctionHouse: AuctionHouseClient,
// Metadata: MetadataClient, EXAMPLE OF OTHER FEATURES
};
3 changes: 3 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,6 @@ export * from './wallet';
export * as utils from './utils';
export * as actions from './actions';
export * as programs from './programs';

export * from './auctionHouse';

46 changes: 21 additions & 25 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -941,62 +941,57 @@ __metadata:
languageName: node
linkType: hard

"@metaplex-foundation/mpl-auction@npm:^0.0.2":
version: 0.0.2
resolution: "@metaplex-foundation/mpl-auction@npm:0.0.2"
"@metaplex-foundation/mpl-auction@portal:../metaplex-program-library/auction/js::locator=%40metaplex%2Fjs%40workspace%3A.":
version: 0.0.0-use.local
resolution: "@metaplex-foundation/mpl-auction@portal:../metaplex-program-library/auction/js::locator=%40metaplex%2Fjs%40workspace%3A."
dependencies:
"@metaplex-foundation/mpl-core": ^0.0.2
"@solana/spl-token": ^0.1.8
"@solana/web3.js": ^1.31.0
checksum: bb8844835a6fc4313c77ea744c7a1feaa732c134098433d34f37ef5de76ea7717a710d03d6b4bdb3ab33a25b31b081ec1a6e54cef8c669c4cf0ae6208334e960
languageName: node
linkType: hard
linkType: soft

"@metaplex-foundation/mpl-core@npm:^0.0.2":
version: 0.0.2
resolution: "@metaplex-foundation/mpl-core@npm:0.0.2"
"@metaplex-foundation/mpl-core@portal:../metaplex-program-library/core/js::locator=%40metaplex%2Fjs%40workspace%3A.":
version: 0.0.0-use.local
resolution: "@metaplex-foundation/mpl-core@portal:../metaplex-program-library/core/js::locator=%40metaplex%2Fjs%40workspace%3A."
dependencies:
"@solana/web3.js": ^1.31.0
bs58: ^4.0.1
checksum: f74ad09538dbd8b567c349724310ed3ca1e3c9d7e65992ea32077294b09791cd246ab2ac0c29c0a8ed00aaccb6858dbb0fffc55e7e788da7c418f2ed094a1d9a
languageName: node
linkType: hard
linkType: soft

"@metaplex-foundation/mpl-metaplex@npm:^0.0.5":
version: 0.0.5
resolution: "@metaplex-foundation/mpl-metaplex@npm:0.0.5"
"@metaplex-foundation/mpl-metaplex@portal:../metaplex-program-library/metaplex/js::locator=%40metaplex%2Fjs%40workspace%3A.":
version: 0.0.0-use.local
resolution: "@metaplex-foundation/mpl-metaplex@portal:../metaplex-program-library/metaplex/js::locator=%40metaplex%2Fjs%40workspace%3A."
dependencies:
"@metaplex-foundation/mpl-auction": ^0.0.2
"@metaplex-foundation/mpl-core": ^0.0.2
"@metaplex-foundation/mpl-token-metadata": ^0.0.2
"@metaplex-foundation/mpl-token-vault": ^0.0.2
"@solana/spl-token": ^0.1.8
"@solana/web3.js": ^1.31.0
checksum: 749be4932dcfe3f5c48cc1ac194e1ee92ee92f01359699d53abf755937ab3e10026a06c68ae76924bfb4828ae24c8f378ea9fffabe98a39df353289cd6e5c3d6
languageName: node
linkType: hard
linkType: soft

"@metaplex-foundation/mpl-token-metadata@npm:^0.0.2":
version: 0.0.2
resolution: "@metaplex-foundation/mpl-token-metadata@npm:0.0.2"
"@metaplex-foundation/mpl-token-metadata@portal:../metaplex-program-library/token-metadata/js::locator=%40metaplex%2Fjs%40workspace%3A.":
version: 0.0.0-use.local
resolution: "@metaplex-foundation/mpl-token-metadata@portal:../metaplex-program-library/token-metadata/js::locator=%40metaplex%2Fjs%40workspace%3A."
dependencies:
"@metaplex-foundation/mpl-core": ^0.0.2
"@solana/spl-token": ^0.1.8
"@solana/web3.js": ^1.31.0
checksum: 03064927d289cd3de12b238c233cb06ce7476338b7bf203e5c02828048d0e51c438ba90c9151d24c379618270cfcd05cee327ca9dc7b100d1108c4301ad3388b
languageName: node
linkType: hard
linkType: soft

"@metaplex-foundation/mpl-token-vault@npm:^0.0.2":
version: 0.0.2
resolution: "@metaplex-foundation/mpl-token-vault@npm:0.0.2"
"@metaplex-foundation/mpl-token-vault@portal:../metaplex-program-library/token-vault/js::locator=%40metaplex%2Fjs%40workspace%3A.":
version: 0.0.0-use.local
resolution: "@metaplex-foundation/mpl-token-vault@portal:../metaplex-program-library/token-vault/js::locator=%40metaplex%2Fjs%40workspace%3A."
dependencies:
"@metaplex-foundation/mpl-core": ^0.0.2
"@solana/spl-token": ^0.1.8
"@solana/web3.js": ^1.31.0
checksum: 4543fc4142f59f447a19b26162d22c8547cb9b94cf2cc386f0d33db85fb06777d19d34792f7d63e0a9f4bb5549b2819e1f1b9cc2420af5effcdb84799dfe6616
languageName: node
linkType: hard
linkType: soft

"@metaplex/js@workspace:.":
version: 0.0.0-use.local
Expand Down Expand Up @@ -1054,6 +1049,7 @@ __metadata:
typescript: ^4.4.3
peerDependencies:
"@metaplex-foundation/mpl-auction": ^0.0.2
"@metaplex-foundation/mpl-auction-house": ^0.0.2
"@metaplex-foundation/mpl-core": ^0.0.2
"@metaplex-foundation/mpl-metaplex": ^0.0.5
"@metaplex-foundation/mpl-token-metadata": ^0.0.2
Expand Down