From e999515945397517ac3e6af8e34a173aa24282d4 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 16 Aug 2023 07:51:37 -0400 Subject: [PATCH] fix upload, contract --- .../MusicPlayer/UploadAlbumModal.tsx | 7 +- .../TeritoriMusicPlayer.client.ts | 305 ++++++------------ .../TeritoriMusicPlayer.types.ts | 82 ++--- .../screens/MusicPlayer/MusicPlayerScreen.tsx | 1 - packages/utils/backend.ts | 4 +- 5 files changed, 151 insertions(+), 248 deletions(-) diff --git a/packages/components/MusicPlayer/UploadAlbumModal.tsx b/packages/components/MusicPlayer/UploadAlbumModal.tsx index 15c57be921..4adf0e7849 100644 --- a/packages/components/MusicPlayer/UploadAlbumModal.tsx +++ b/packages/components/MusicPlayer/UploadAlbumModal.tsx @@ -90,11 +90,6 @@ export const UploadAlbumModal: React.FC = ({ image: albumInfo.image, audios, }; - console.log("---------metadata"); - console.log({ - metadata: JSON.stringify(metadata), - identifier: uuidv4(), - }); try { const res = await client.createMusicAlbum( @@ -240,7 +235,7 @@ const Step1Component: React.FC<{ ...uploadFiles1, { name: file.file.name, - ipfs: "ipfs1", //pinataRes.IpfsHash, + ipfs: pinataRes.IpfsHash, duration: audio.duration, }, ]); diff --git a/packages/contracts-clients/teritori-musicplayer/TeritoriMusicPlayer.client.ts b/packages/contracts-clients/teritori-musicplayer/TeritoriMusicPlayer.client.ts index d85c325052..01d92c46df 100644 --- a/packages/contracts-clients/teritori-musicplayer/TeritoriMusicPlayer.client.ts +++ b/packages/contracts-clients/teritori-musicplayer/TeritoriMusicPlayer.client.ts @@ -1,29 +1,22 @@ -//@ts-nocheck - /** - * This file was automatically generated by @cosmwasm/ts-codegen@0.25.0. - * DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file, - * and run the @cosmwasm/ts-codegen generate command to regenerate this file. - */ +* This file was automatically generated by @cosmwasm/ts-codegen@0.33.0. +* DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file, +* and run the @cosmwasm/ts-codegen generate command to regenerate this file. +*/ -import { - CosmWasmClient, - SigningCosmWasmClient, - ExecuteResult, -} from "@cosmjs/cosmwasm-stargate"; +import { CosmWasmClient, SigningCosmWasmClient, ExecuteResult } from "@cosmjs/cosmwasm-stargate"; import { Coin, StdFee } from "@cosmjs/amino"; +import { ConfigResponse, Addr, Config, ExecuteMsg, InstantiateMsg, MusicAlbumResponse, MusicAlbum, QueryMsg } from "./TeritoriMusicPlayer.types"; export interface TeritoriMusicPlayerReadOnlyInterface { contractAddress: string; config: () => Promise; - queryMusicAlbum: ({ - identifier, + musicAlbum: ({ + identifier }: { identifier: string; - }) => Promise; + }) => Promise; } -export class TeritoriMusicPlayerQueryClient - implements TeritoriMusicPlayerReadOnlyInterface -{ +export class TeritoriMusicPlayerQueryClient implements TeritoriMusicPlayerReadOnlyInterface { client: CosmWasmClient; contractAddress: string; @@ -31,98 +24,63 @@ export class TeritoriMusicPlayerQueryClient this.client = client; this.contractAddress = contractAddress; this.config = this.config.bind(this); - this.queryMusicAlbum = this.queryMusicAlbum.bind(this); + this.musicAlbum = this.musicAlbum.bind(this); } config = async (): Promise => { return this.client.queryContractSmart(this.contractAddress, { - config: {}, + config: {} }); }; - queryMusicAlbum = async ({ - identifier, + musicAlbum = async ({ + identifier }: { identifier: string; - }): Promise => { + }): Promise => { return this.client.queryContractSmart(this.contractAddress, { - query_music_album: { - identifier, - }, + music_album: { + identifier + } }); }; } -export interface TeritoriMusicPlayerInterface - extends TeritoriMusicPlayerReadOnlyInterface { +export interface TeritoriMusicPlayerInterface extends TeritoriMusicPlayerReadOnlyInterface { contractAddress: string; sender: string; - updateConfig: ( - { - owner, - }: { - owner?: string; - }, - fee?: number | StdFee | "auto", - memo?: string, - funds?: Coin[] - ) => Promise; - createMusicAlbum: ( - { - category, - identifier, - metadata, - }: { - category: number; - identifier: string; - metadata: string; - }, - fee?: number | StdFee | "auto", - memo?: string, - funds?: Coin[] - ) => Promise; - deleteMusicAlbum: ( - { - identifier, - }: { - identifier: string; - }, - fee?: number | StdFee | "auto", - memo?: string, - funds?: Coin[] - ) => Promise; - addToLibrary: ( - { - identifier, - }: { - identifier: string; - }, - fee?: number | StdFee | "auto", - memo?: string, - funds?: Coin[] - ) => Promise; - removeFromLibrary: ( - { - identifier, - }: { - identifier: string; - }, - fee?: number | StdFee | "auto", - memo?: string, - funds?: Coin[] - ) => Promise; + updateConfig: ({ + owner + }: { + owner?: string; + }, fee?: number | StdFee | "auto", memo?: string, _funds?: Coin[]) => Promise; + createMusicAlbum: ({ + identifier, + metadata + }: { + identifier: string; + metadata: string; + }, fee?: number | StdFee | "auto", memo?: string, _funds?: Coin[]) => Promise; + deleteMusicAlbum: ({ + identifier + }: { + identifier: string; + }, fee?: number | StdFee | "auto", memo?: string, _funds?: Coin[]) => Promise; + addToLibrary: ({ + identifier + }: { + identifier: string; + }, fee?: number | StdFee | "auto", memo?: string, _funds?: Coin[]) => Promise; + removeFromLibrary: ({ + identifier + }: { + identifier: string; + }, fee?: number | StdFee | "auto", memo?: string, _funds?: Coin[]) => Promise; } -export class TeritoriMusicPlayerClient - extends TeritoriMusicPlayerQueryClient - implements TeritoriMusicPlayerInterface -{ +export class TeritoriMusicPlayerClient extends TeritoriMusicPlayerQueryClient implements TeritoriMusicPlayerInterface { client: SigningCosmWasmClient; sender: string; contractAddress: string; - constructor( - client: SigningCosmWasmClient, - sender: string, - contractAddress: string - ) { + constructor(client: SigningCosmWasmClient, sender: string, contractAddress: string) { super(client, contractAddress); this.client = client; this.sender = sender; @@ -133,122 +91,63 @@ export class TeritoriMusicPlayerClient this.addToLibrary = this.addToLibrary.bind(this); this.removeFromLibrary = this.removeFromLibrary.bind(this); } - updateConfig = async ( - { - owner, - }: { - owner?: string; - }, - fee: number | StdFee | "auto" = "auto", - memo?: string, - funds?: Coin[] - ): Promise => { - return await this.client.execute( - this.sender, - this.contractAddress, - { - update_config: { - owner, - }, - }, - fee, - memo, - funds - ); + + updateConfig = async ({ + owner + }: { + owner?: string; + }, fee: number | StdFee | "auto" = "auto", memo?: string, _funds?: Coin[]): Promise => { + return await this.client.execute(this.sender, this.contractAddress, { + update_config: { + owner + } + }, fee, memo, _funds); }; - createMusicAlbum = async ( - { - identifier, - metadata, - }: { - identifier: string; - metadata: string; - }, - fee: number | StdFee | "auto" = "auto", - memo?: string, - funds?: Coin[] - ): Promise => { - return await this.client.execute( - this.sender, - this.contractAddress, - { - create_music_album: { - identifier, - metadata, - }, - }, - fee, - memo, - funds - ); + createMusicAlbum = async ({ + identifier, + metadata + }: { + identifier: string; + metadata: string; + }, fee: number | StdFee | "auto" = "auto", memo?: string, _funds?: Coin[]): Promise => { + return await this.client.execute(this.sender, this.contractAddress, { + create_music_album: { + identifier, + metadata + } + }, fee, memo, _funds); }; - deleteMusicAlbum = async ( - { - identifier, - }: { - identifier: string; - }, - fee: number | StdFee | "auto" = "auto", - memo?: string, - funds?: Coin[] - ): Promise => { - return await this.client.execute( - this.sender, - this.contractAddress, - { - delete_music_album: { - identifier, - }, - }, - fee, - memo, - funds - ); + deleteMusicAlbum = async ({ + identifier + }: { + identifier: string; + }, fee: number | StdFee | "auto" = "auto", memo?: string, _funds?: Coin[]): Promise => { + return await this.client.execute(this.sender, this.contractAddress, { + delete_music_album: { + identifier + } + }, fee, memo, _funds); }; - addToLibrary = async ( - { - identifier, - }: { - identifier: string; - }, - fee: number | StdFee | "auto" = "auto", - memo?: string, - funds?: Coin[] - ): Promise => { - return await this.client.execute( - this.sender, - this.contractAddress, - { - add_to_library: { - identifier, - }, - }, - fee, - memo, - funds - ); + addToLibrary = async ({ + identifier + }: { + identifier: string; + }, fee: number | StdFee | "auto" = "auto", memo?: string, _funds?: Coin[]): Promise => { + return await this.client.execute(this.sender, this.contractAddress, { + add_to_library: { + identifier + } + }, fee, memo, _funds); }; - removeFromLibrary = async ( - { - identifier, - }: { - identifier: string; - }, - fee: number | StdFee | "auto" = "auto", - memo?: string, - funds?: Coin[] - ): Promise => { - return await this.client.execute( - this.sender, - this.contractAddress, - { - remove_from_library: { - identifier, - }, - }, - fee, - memo, - funds - ); + removeFromLibrary = async ({ + identifier + }: { + identifier: string; + }, fee: number | StdFee | "auto" = "auto", memo?: string, _funds?: Coin[]): Promise => { + return await this.client.execute(this.sender, this.contractAddress, { + remove_from_library: { + identifier + } + }, fee, memo, _funds); }; } diff --git a/packages/contracts-clients/teritori-musicplayer/TeritoriMusicPlayer.types.ts b/packages/contracts-clients/teritori-musicplayer/TeritoriMusicPlayer.types.ts index 1ff7ed507a..aa3c31072d 100644 --- a/packages/contracts-clients/teritori-musicplayer/TeritoriMusicPlayer.types.ts +++ b/packages/contracts-clients/teritori-musicplayer/TeritoriMusicPlayer.types.ts @@ -1,37 +1,49 @@ -//@ts-nocheck - /** - * This file was automatically generated by @cosmwasm/ts-codegen@0.25.0. - * DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file, - * and run the @cosmwasm/ts-codegen generate command to regenerate this file. - */ +* This file was automatically generated by @cosmwasm/ts-codegen@0.33.0. +* DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file, +* and run the @cosmwasm/ts-codegen generate command to regenerate this file. +*/ +export interface ConfigResponse { + owner: string; + [k: string]: unknown; +} export type Addr = string; export interface Config { owner: Addr; [k: string]: unknown; } -export type ExecuteMsg = - | { - update_config: { - owner?: string | null; - [k: string]: unknown; - }; - } - | { - create_music_album: { - category: number; - identifier: string; - metadata: string; - [k: string]: unknown; - }; - }; -export type Uint128 = string; +export type ExecuteMsg = { + update_config: { + owner?: string | null; + [k: string]: unknown; + }; +} | { + create_music_album: { + identifier: string; + metadata: string; + [k: string]: unknown; + }; +} | { + delete_music_album: { + identifier: string; + [k: string]: unknown; + }; +} | { + add_to_library: { + identifier: string; + [k: string]: unknown; + }; +} | { + remove_from_library: { + identifier: string; + [k: string]: unknown; + }; +}; export interface InstantiateMsg { [k: string]: unknown; } -export type MusicAlbumCategory = | "Normal"; -export interface MusicAlbumResult { +export interface MusicAlbumResponse { deleted: boolean; identifier: string; metadata: string; @@ -45,15 +57,13 @@ export interface MusicAlbum { post_by: Addr; [k: string]: unknown; } -export type QueryMsg = - | { - config: { - [k: string]: unknown; - }; - } - | { - query_music_album: { - identifier: string; - [k: string]: unknown; - }; - }; +export type QueryMsg = { + config: { + [k: string]: unknown; + }; +} | { + music_album: { + identifier: string; + [k: string]: unknown; + }; +}; diff --git a/packages/screens/MusicPlayer/MusicPlayerScreen.tsx b/packages/screens/MusicPlayer/MusicPlayerScreen.tsx index 9770e4888d..d4f0ddc8bf 100644 --- a/packages/screens/MusicPlayer/MusicPlayerScreen.tsx +++ b/packages/screens/MusicPlayer/MusicPlayerScreen.tsx @@ -29,7 +29,6 @@ export const MusicPlayerScreen: ScreenFC<"MusicPlayer"> = () => { Music Player} fullWidth - footerChildren={<>} > diff --git a/packages/utils/backend.ts b/packages/utils/backend.ts index 43a4966c96..c97d8ee153 100644 --- a/packages/utils/backend.ts +++ b/packages/utils/backend.ts @@ -130,9 +130,9 @@ export const getMusicplayerClient = (networkId: string | undefined) => { return undefined; } if (!musicplayerClients[network.id]) { - const backendEndpoint = network.backendEndpoint; + // const backendEndpoint = network.backendEndpoint; //test - // const backendEndpoint = "http://localhost:9090"; + const backendEndpoint = "http://localhost:9090"; const rpc = new MusicplayerGrpcWebImpl(backendEndpoint, { debug: false,