From 1393e8b185d98b052c45b614bde90adf46983354 Mon Sep 17 00:00:00 2001 From: austbot Date: Mon, 3 Jan 2022 15:21:16 -0600 Subject: [PATCH] feat: adds a wip SDK structure --- package.json | 12 +++++- src/auctionHouse/index.ts | 71 ++++++++++++++++++++++++++++++++++++ src/auctionHouse/settings.ts | 4 ++ src/auctionHouse/stats.ts | 3 ++ src/client.ts | 24 ++++++++++++ src/index.ts | 3 ++ yarn.lock | 46 +++++++++++------------ 7 files changed, 137 insertions(+), 26 deletions(-) create mode 100644 src/auctionHouse/index.ts create mode 100644 src/auctionHouse/settings.ts create mode 100644 src/auctionHouse/stats.ts create mode 100644 src/client.ts diff --git a/package.json b/package.json index 0630a63..f288a4a 100644 --- a/package.json +++ b/package.json @@ -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", @@ -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" } -} \ No newline at end of file +} diff --git a/src/auctionHouse/index.ts b/src/auctionHouse/index.ts new file mode 100644 index 0000000..e7cdb14 --- /dev/null +++ b/src/auctionHouse/index.ts @@ -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 { + return new AuctionHouse({}).refresh(); + } + + createAuctionHouse(settings: AuctionHouseSettings): Promise { + return new AuctionHouse({}).refresh(); + } + + updateAuctionHouse(auctionHouseKey: PublicKey, settings: AuctionHouseSettings): Promise { + return new AuctionHouse({}).refresh(); + } +} + +export class AuctionHouse { + private settings: AuctionHouseSettings; + private stats: AuctionHouseStats; + constructor(settings?: AuctionHouseSettings) { + this.settings = settings; + } + private checkInitialized() { + return this.settings && this.stats; + } + + async refresh(): Promise { + //TODO: refresh stats and settings + return this; + } + + async show() { + + } + + async bid() { + + } + + async list() { + + } + + async buy() { + + } + + async sell() { + + } + + async execute_sale() { + + } + + async execute_sale_with_price() { + + } + + async deposit() { + + } +} \ No newline at end of file diff --git a/src/auctionHouse/settings.ts b/src/auctionHouse/settings.ts new file mode 100644 index 0000000..0e50801 --- /dev/null +++ b/src/auctionHouse/settings.ts @@ -0,0 +1,4 @@ +export type AuctionHouseSettings = { + + +}; \ No newline at end of file diff --git a/src/auctionHouse/stats.ts b/src/auctionHouse/stats.ts new file mode 100644 index 0000000..89a610e --- /dev/null +++ b/src/auctionHouse/stats.ts @@ -0,0 +1,3 @@ +export type AuctionHouseStats = { + +}; \ No newline at end of file diff --git a/src/client.ts b/src/client.ts new file mode 100644 index 0000000..7cf6534 --- /dev/null +++ b/src/client.ts @@ -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() { + 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 +}; \ No newline at end of file diff --git a/src/index.ts b/src/index.ts index 88ab965..5190362 100644 --- a/src/index.ts +++ b/src/index.ts @@ -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'; + diff --git a/yarn.lock b/yarn.lock index 5d7d408..28013f5 100644 --- a/yarn.lock +++ b/yarn.lock @@ -941,30 +941,28 @@ __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 @@ -972,31 +970,28 @@ __metadata: "@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 @@ -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