Skip to content

Commit 6965f15

Browse files
authored
Merge pull request #108 from bengriffin1/bengriffin1-removing-nft
[FIX]: removing unneeded NFT module and related code
2 parents 445a1f3 + 1e6365b commit 6965f15

File tree

11 files changed

+2
-296
lines changed

11 files changed

+2
-296
lines changed

src/core/sdk-exceptions.ts

-7
Original file line numberDiff line numberDiff line change
@@ -63,10 +63,3 @@ export function createExpectedBearerStringError() {
6363
'Expected argument to be a string in the `Bearer {token}` format.',
6464
);
6565
}
66-
67-
export function mintingError() {
68-
return new MagicAdminSDKError(
69-
ErrorCode.MintingError,
70-
'There was an error while minting. Check your contract ID, and token ID if using ERC1155',
71-
);
72-
}

src/core/sdk.ts

-7
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import '../utils/shim';
22
import { TokenModule } from '../modules/token';
33
import { UsersModule } from '../modules/users';
44
import { UtilsModule } from '../modules/utils';
5-
import { NFTModule } from '../modules/nft';
65
import { MagicAdminSDKAdditionalConfiguration } from '../types';
76

87
export class MagicAdminSDK {
@@ -25,11 +24,6 @@ export class MagicAdminSDK {
2524
*/
2625
public readonly utils: UtilsModule;
2726

28-
/**
29-
* Contains utilities for Minting and Delivery of NFTs.
30-
*/
31-
public readonly nft: NFTModule;
32-
3327
constructor(public readonly secretApiKey?: string, options?: MagicAdminSDKAdditionalConfiguration) {
3428
const endpoint = options?.endpoint ?? 'https://api.magic.link';
3529
this.apiBaseUrl = endpoint.replace(/\/+$/, '');
@@ -38,6 +32,5 @@ export class MagicAdminSDK {
3832
this.token = new TokenModule(this);
3933
this.users = new UsersModule(this);
4034
this.utils = new UtilsModule(this);
41-
this.nft = new NFTModule(this);
4235
}
4336
}

src/modules/nft/index.ts

-48
This file was deleted.

src/types/exception-types.ts

-1
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,4 @@ export enum ErrorCode {
88
MalformedTokenError = 'ERROR_MALFORMED_TOKEN',
99
ServiceError = 'SERVICE_ERROR',
1010
ExpectedBearerString = 'EXPECTED_BEARER_STRING',
11-
MintingError = 'MINTING_ERROR',
1211
}

src/types/index.ts

-1
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,3 @@ export * from './didt-types';
22
export * from './exception-types';
33
export * from './sdk-types';
44
export * from './wallet-types';
5-
export * from './nft-types';

src/types/nft-types.ts

-10
This file was deleted.

src/utils/rest.ts

+1-10
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,6 @@ interface MagicAPIResponse<TData = {}> {
99
status?: string | number;
1010
}
1111

12-
interface Headers {
13-
[key: string]: any;
14-
}
15-
1612
/**
1713
* Performs a `fetch` to the given URL with the configured `init` object.
1814
*/
@@ -49,15 +45,10 @@ export function post<TBody extends Record<string, string | number | boolean> = {
4945
url: string,
5046
secretApiKey: string,
5147
body: TBody,
52-
additionalHeaders?: Headers,
5348
) {
54-
let headers: Headers = { 'X-Magic-Secret-key': secretApiKey };
55-
if (additionalHeaders) {
56-
headers = { ...headers, ...additionalHeaders };
57-
}
5849
return emitRequest<TResponse>(url, {
5950
method: 'POST',
60-
headers,
51+
headers: { 'X-Magic-Secret-key': secretApiKey },
6152
body: JSON.stringify(body),
6253
});
6354
}

src/utils/type-guards.ts

+1-13
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
https://www.typescriptlang.org/docs/handbook/advanced-types.html#type-guards-and-differentiating-types
99
*/
1010

11-
import { Claim, MintRequest } from '../types';
11+
import { Claim } from '../types';
1212

1313
/** Assert `value` is `undefined`. */
1414
function isUndefined(value: any): value is undefined {
@@ -39,15 +39,3 @@ export function isDIDTClaim(value: any): value is Claim {
3939
!isNil(value.add)
4040
);
4141
}
42-
43-
/** Assert `value` contains all required MintRequest members */
44-
export function isMintRequest(value: any): value is MintRequest {
45-
return (
46-
!isNil(value) &&
47-
!isNil(value.data) &&
48-
!isNil(value.error_code) &&
49-
!isNil(value.message) &&
50-
!isNil(value.status) &&
51-
!isNil(value.data.request_id)
52-
);
53-
}

test/spec/modules/nft/mint1155.spec.ts

-86
This file was deleted.

test/spec/modules/nft/mint721.spec.ts

-86
This file was deleted.

test/spec/utils/rest/post.spec.ts

-27
Original file line numberDiff line numberDiff line change
@@ -28,30 +28,3 @@ test('Successfully POSTs to the given endpoint & stringifies body', async () =>
2828
},
2929
]);
3030
});
31-
32-
test('Successfully POSTs to the given endpoint and adds JSON header', async () => {
33-
const fetchStub = jest.fn().mockImplementation(() => successRes);
34-
(fetch as any) = fetchStub;
35-
36-
await expect(
37-
post(
38-
'https://example.com/hello/world',
39-
API_KEY,
40-
{ public_address: '0x0123' },
41-
{ 'Content-Type': 'application/json' },
42-
),
43-
).resolves.toBe('hello world');
44-
45-
const fetchArguments = fetchStub.mock.calls[0];
46-
expect(fetchArguments).toEqual([
47-
'https://example.com/hello/world',
48-
{
49-
method: 'POST',
50-
headers: {
51-
'X-Magic-Secret-key': API_KEY,
52-
'Content-Type': 'application/json',
53-
},
54-
body: '{"public_address":"0x0123"}',
55-
},
56-
]);
57-
});

0 commit comments

Comments
 (0)