Skip to content

Commit

Permalink
Merge pull request #606 from magiclabs/jayhwang-type-issues
Browse files Browse the repository at this point in the history
Jayhwang type issues
  • Loading branch information
octave08 committed Aug 11, 2023
2 parents 2ba02a3 + 9608d6c commit 8534da4
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 18 deletions.
5 changes: 3 additions & 2 deletions packages/@magic-sdk/provider/src/modules/nft.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {
NFTCheckoutRequest,
NFTCheckoutResponse,
NFTTransferResponse,
NFTTransferRequest,
} from '@magic-sdk/types';
import { BaseModule } from './base-module';
import { createJsonRpcRequestPayload } from '../core/json-rpc';
Expand All @@ -17,13 +18,13 @@ export class NFTModule extends BaseModule {
}

/* Start an NFT Checkout flow with Paypal */
public async checkout(options: NFTCheckoutRequest) {
public checkout(options: NFTCheckoutRequest) {
const requestPayload = createJsonRpcRequestPayload(MagicPayloadMethod.NFTCheckout, [options]);
return this.request<NFTCheckoutResponse>(requestPayload);
}

/* Start an NFT Transfer flow */
public async transfer(options: NFTCheckoutRequest) {
public transfer(options: NFTTransferRequest) {
const requestPayload = createJsonRpcRequestPayload(MagicPayloadMethod.NFTTransfer, [options]);
return this.request<NFTTransferResponse>(requestPayload);
}
Expand Down
25 changes: 9 additions & 16 deletions packages/@magic-sdk/types/src/core/json-rpc-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,12 @@ export interface RequestUserInfoScope {
};
}

export type NFTResponseStatus = 'cancelled' | 'processed' | 'declined' | 'expired';

export type NFTResponse = {
status: NFTResponseStatus;
};

export interface NFTPurchaseRequest {
nft: {
name: string;
Expand Down Expand Up @@ -75,11 +81,7 @@ export interface NFTPurchaseRequest {
};
}

export type NFTPurchaseStatus = 'processed' | 'declined' | 'expired';

export interface NFTPurchaseResponse {
status: NFTPurchaseStatus;
}
export type NFTPurchaseResponse = NFTResponse;

export interface NFTCheckoutRequest {
// given by magic / found in the developer dashboard in future
Expand All @@ -94,12 +96,7 @@ export interface NFTCheckoutRequest {
walletAddress?: string;
}

export type NFTCheckoutStatus = 'processed' | 'declined' | 'expired';

export interface NFTCheckoutResponse {
status: NFTCheckoutStatus;
viewInWallet?: boolean;
}
export type NFTCheckoutResponse = NFTResponse;

export interface NFTTransferRequest {
tokenId: string;
Expand All @@ -108,11 +105,7 @@ export interface NFTTransferRequest {
recipient?: string;
}

export type NFTTransferStatus = 'canceled' | 'success';

export interface NFTTransferResponse {
status: NFTCheckoutStatus;
}
export type NFTTransferResponse = NFTResponse;

export enum Wallets {
MetaMask = 'metamask',
Expand Down

0 comments on commit 8534da4

Please sign in to comment.