Comparing version
@@ -16,3 +16,3 @@ "use strict"; | ||
let request = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : _common.fetcher; | ||
return tokenIds => { | ||
return (tokenIds, fetcherConfig) => { | ||
if (tokenIds.length === 0) { | ||
@@ -32,2 +32,3 @@ return Promise.resolve({}); | ||
return request({ | ||
...fetcherConfig, | ||
url: `${baseUrl}/multiAsset/metadata`, | ||
@@ -34,0 +35,0 @@ method: 'POST', |
@@ -30,3 +30,3 @@ "use strict"; | ||
return request({ | ||
url: `${baseUrl}/multiAsset/supply`, | ||
url: `${baseUrl}/multiAsset/supply?numberFormat=string`, | ||
data: payload, | ||
@@ -56,3 +56,3 @@ method: 'POST', | ||
const TokenSupplySchema = _zod.z.object({ | ||
supplies: _zod.z.record(_zod.z.number().nullable()) | ||
supplies: _zod.z.record(_zod.z.string().nullable()) | ||
}); | ||
@@ -59,0 +59,0 @@ const isTokenSupplyResponse = (0, _common.createTypeGuardFromSchema)(TokenSupplySchema); |
@@ -37,3 +37,3 @@ "use strict"; | ||
supplies: { | ||
a: 1 | ||
a: '1' | ||
} | ||
@@ -48,3 +48,3 @@ })).toEqual(true); | ||
supplies: { | ||
a: '1' | ||
a: 1 | ||
} | ||
@@ -63,3 +63,3 @@ })).toEqual(false); | ||
supplies: { | ||
'1f7a58a1aa1e6b047a42109ade331ce26c9c2cce027d043ff264fb1f.0': 1, | ||
'1f7a58a1aa1e6b047a42109ade331ce26c9c2cce027d043ff264fb1f.0': '1', | ||
'1f7a58a1aa1e6b047a42109ade331ce26c9c2cce027d043ff264fb1f.1': null | ||
@@ -71,3 +71,3 @@ } | ||
expect(result).toEqual({ | ||
'1f7a58a1aa1e6b047a42109ade331ce26c9c2cce027d043ff264fb1f.30': 1, | ||
'1f7a58a1aa1e6b047a42109ade331ce26c9c2cce027d043ff264fb1f.30': '1', | ||
'1f7a58a1aa1e6b047a42109ade331ce26c9c2cce027d043ff264fb1f.31': null | ||
@@ -74,0 +74,0 @@ }); |
@@ -7,3 +7,3 @@ import { fetcher, isArray, isRecord } from '@yoroi/common'; | ||
let request = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : fetcher; | ||
return tokenIds => { | ||
return (tokenIds, fetcherConfig) => { | ||
if (tokenIds.length === 0) { | ||
@@ -23,2 +23,3 @@ return Promise.resolve({}); | ||
return request({ | ||
...fetcherConfig, | ||
url: `${baseUrl}/multiAsset/metadata`, | ||
@@ -25,0 +26,0 @@ method: 'POST', |
@@ -24,3 +24,3 @@ import { z } from 'zod'; | ||
return request({ | ||
url: `${baseUrl}/multiAsset/supply`, | ||
url: `${baseUrl}/multiAsset/supply?numberFormat=string`, | ||
data: payload, | ||
@@ -49,3 +49,3 @@ method: 'POST', | ||
const TokenSupplySchema = z.object({ | ||
supplies: z.record(z.number().nullable()) | ||
supplies: z.record(z.string().nullable()) | ||
}); | ||
@@ -52,0 +52,0 @@ export const isTokenSupplyResponse = createTypeGuardFromSchema(TokenSupplySchema); |
@@ -35,3 +35,3 @@ import { getTokenSupply, isTokenSupplyResponse } from './token-supply'; | ||
supplies: { | ||
a: 1 | ||
a: '1' | ||
} | ||
@@ -46,3 +46,3 @@ })).toEqual(true); | ||
supplies: { | ||
a: '1' | ||
a: 1 | ||
} | ||
@@ -61,3 +61,3 @@ })).toEqual(false); | ||
supplies: { | ||
'1f7a58a1aa1e6b047a42109ade331ce26c9c2cce027d043ff264fb1f.0': 1, | ||
'1f7a58a1aa1e6b047a42109ade331ce26c9c2cce027d043ff264fb1f.0': '1', | ||
'1f7a58a1aa1e6b047a42109ade331ce26c9c2cce027d043ff264fb1f.1': null | ||
@@ -69,3 +69,3 @@ } | ||
expect(result).toEqual({ | ||
'1f7a58a1aa1e6b047a42109ade331ce26c9c2cce027d043ff264fb1f.30': 1, | ||
'1f7a58a1aa1e6b047a42109ade331ce26c9c2cce027d043ff264fb1f.30': '1', | ||
'1f7a58a1aa1e6b047a42109ade331ce26c9c2cce027d043ff264fb1f.31': null | ||
@@ -72,0 +72,0 @@ }); |
import { Fetcher } from '@yoroi/common'; | ||
import { Api } from '@yoroi/types'; | ||
export declare const getOnChainMetadatas: (baseUrl: string, request?: Fetcher) => (tokenIds: import("@yoroi/types").ApiOnChainMetadataRequest) => Promise<Api.Cardano.OnChainMetadataResponse>; | ||
import { AxiosRequestConfig } from 'axios'; | ||
export declare const getOnChainMetadatas: (baseUrl: string, request?: Fetcher) => (tokenIds: import("@yoroi/types").ApiOnChainMetadataRequest, fetcherConfig?: AxiosRequestConfig) => Promise<Api.Cardano.OnChainMetadataResponse>; | ||
export declare function getMetadataResult(records: Readonly<Array<unknown>>, tokenIdentity: Readonly<Api.Cardano.TokenIdentity>): Api.Cardano.OnChainMetadataRecord; | ||
@@ -5,0 +6,0 @@ export declare function findMetadataRecord(possibleMetadataRecord: Readonly<Record<string, unknown>>, tokenIdentity: Readonly<Api.Cardano.TokenIdentity>): import("@yoroi/types").ApiNftMetadata | import("@yoroi/types").ApiFtMetadata | undefined; |
@@ -93,3 +93,3 @@ import { isFtMetadata, isMetadataFile, isNftMetadata } from './cardano/api/parsers'; | ||
readonly getOffChainMetadata: (baseUrl: string, request?: import("@yoroi/common").Fetcher) => (tokenIds: import("@yoroi/types").ApiOffChainMetadataRequest) => Promise<import("@yoroi/types").ApiOffChainMetadataResponse>; | ||
readonly getOnChainMetadatas: (baseUrl: string, request?: import("@yoroi/common").Fetcher) => (tokenIds: import("@yoroi/types").ApiOnChainMetadataRequest) => Promise<import("@yoroi/types").ApiOnChainMetadataResponse>; | ||
readonly getOnChainMetadatas: (baseUrl: string, request?: import("@yoroi/common").Fetcher) => (tokenIds: import("@yoroi/types").ApiOnChainMetadataRequest, fetcherConfig?: import("axios").AxiosRequestConfig<any> | undefined) => Promise<import("@yoroi/types").ApiOnChainMetadataResponse>; | ||
readonly getTokenSupply: (baseUrl: string, request?: import("@yoroi/common").Fetcher) => (tokenIds: import("@yoroi/types").ApiTokeSupplyRequest) => Promise<import("@yoroi/types").ApiTokenSupplyResponse>; | ||
@@ -96,0 +96,0 @@ readonly getProtocolParams: (baseUrl: string, request?: import("@yoroi/common").Fetcher) => () => Promise<Readonly<{ |
{ | ||
"name": "@yoroi/api", | ||
"version": "1.4.0", | ||
"version": "1.5.0", | ||
"description": "The API package of Yoroi SDK", | ||
@@ -136,3 +136,3 @@ "keywords": [ | ||
"@emurgo/cip14-js": "^3.0.1", | ||
"@yoroi/common": "1.4.0", | ||
"@yoroi/common": "1.5.0", | ||
"axios": "^1.5.0", | ||
@@ -153,3 +153,3 @@ "zod": "^3.22.1" | ||
"@types/react-native": "0.71.6", | ||
"@yoroi/types": "1.4.0", | ||
"@yoroi/types": "1.5.0", | ||
"axios-mock-adapter": "^1.21.5", | ||
@@ -156,0 +156,0 @@ "commitlint": "^17.0.2", |
@@ -12,2 +12,3 @@ import {Fetcher, fetcher, isArray, isRecord} from '@yoroi/common' | ||
} from '@yoroi/types' | ||
import {AxiosRequestConfig} from 'axios' | ||
@@ -20,2 +21,3 @@ export const getOnChainMetadatas = ( | ||
tokenIds: Api.Cardano.OnChainMetadataRequest, | ||
fetcherConfig?: AxiosRequestConfig, | ||
): Promise<Api.Cardano.OnChainMetadataResponse> => { | ||
@@ -34,2 +36,3 @@ if (tokenIds.length === 0) { | ||
return request<Api.Cardano.OnChainMetadataResponse>({ | ||
...fetcherConfig, | ||
url: `${baseUrl}/multiAsset/metadata`, | ||
@@ -36,0 +39,0 @@ method: 'POST', |
@@ -24,5 +24,5 @@ import {getTokenSupply, isTokenSupplyResponse} from './token-supply' | ||
it('requires supply value to be a number or null', () => { | ||
expect(isTokenSupplyResponse({supplies: {a: 1}})).toEqual(true) | ||
expect(isTokenSupplyResponse({supplies: {a: '1'}})).toEqual(true) | ||
expect(isTokenSupplyResponse({supplies: {a: null}})).toEqual(true) | ||
expect(isTokenSupplyResponse({supplies: {a: '1'}})).toEqual(false) | ||
expect(isTokenSupplyResponse({supplies: {a: 1}})).toEqual(false) | ||
expect(isTokenSupplyResponse({supplies: {a: true}})).toEqual(false) | ||
@@ -36,3 +36,3 @@ }) | ||
supplies: { | ||
'1f7a58a1aa1e6b047a42109ade331ce26c9c2cce027d043ff264fb1f.0': 1, | ||
'1f7a58a1aa1e6b047a42109ade331ce26c9c2cce027d043ff264fb1f.0': '1', | ||
'1f7a58a1aa1e6b047a42109ade331ce26c9c2cce027d043ff264fb1f.1': null, | ||
@@ -47,3 +47,3 @@ }, | ||
expect(result).toEqual({ | ||
'1f7a58a1aa1e6b047a42109ade331ce26c9c2cce027d043ff264fb1f.30': 1, | ||
'1f7a58a1aa1e6b047a42109ade331ce26c9c2cce027d043ff264fb1f.30': '1', | ||
'1f7a58a1aa1e6b047a42109ade331ce26c9c2cce027d043ff264fb1f.31': null, | ||
@@ -50,0 +50,0 @@ }) |
@@ -29,3 +29,3 @@ import {z} from 'zod' | ||
return request<Api.Cardano.TokenSupplyResponse>({ | ||
url: `${baseUrl}/multiAsset/supply`, | ||
url: `${baseUrl}/multiAsset/supply?numberFormat=string`, | ||
data: payload, | ||
@@ -60,3 +60,3 @@ method: 'POST', | ||
const TokenSupplySchema: z.ZodSchema<TokenSupplyResponse> = z.object({ | ||
supplies: z.record(z.number().nullable()), | ||
supplies: z.record(z.string().nullable()), | ||
}) | ||
@@ -63,0 +63,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
574655
0.13%8789
0.08%+ Added
+ Added
+ Added
- Removed
- Removed
- Removed
Updated