@yoroi/portfolio
Version:
The Portfolio package of Yoroi SDK
160 lines (158 loc) • 5.31 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.tokenInfoMocks = void 0;
var _types = require("@yoroi/types");
var _common = require("@yoroi/common");
var _immer = require("immer");
var _constants = require("../constants");
const primaryETH = {
decimals: 18,
ticker: 'ETH',
name: 'Ethereum',
symbol: 'Ξ',
status: _types.Portfolio.Token.Status.Valid,
application: _types.Portfolio.Token.Application.General,
tag: '',
reference: '0x1234567890abcdef.eth',
fingerprint: '0x1234567890abcdef',
website: 'https://ethereum.org',
originalImage: 'https://cdn.example.com/eth-original.png',
id: _constants.primaryTokenId,
nature: _types.Portfolio.Token.Nature.Primary,
type: _types.Portfolio.Token.Type.FT,
description: ''
};
const nftCryptoKitty = {
decimals: 0,
ticker: 'CryptoKitty',
name: 'CryptoKitty #1234',
symbol: 'CK',
status: _types.Portfolio.Token.Status.Valid,
application: _types.Portfolio.Token.Application.General,
tag: '',
reference: '0xabcdef1234567890.cryptokitty1234',
website: 'https://www.cryptokitties.co',
originalImage: 'https://cdn.example.com/ck-original1234.png',
id: '14696a4676909f4e3cb1f2e60e2e08e5abed70caf5c02699be971139.43554259',
fingerprint: 'asset1s7nlt45cc82upqewvjtgu7g97l7eg483c6wu75',
nature: _types.Portfolio.Token.Nature.Secondary,
type: _types.Portfolio.Token.Type.NFT,
description: ''
};
const rnftWhatever = {
decimals: 0,
ticker: 'Whatever',
name: 'Whatever #42',
symbol: 'WTH',
status: _types.Portfolio.Token.Status.Valid,
application: _types.Portfolio.Token.Application.Music,
tag: '222',
reference: 'transactionId#1',
website: 'https://www.whaha.co',
originalImage: 'https://cdn.whatha.com/ck-original1234.png',
id: '14696a4676909f4e3cb1f2e60e2e08e5abed70caf5c02699be971139.3031',
fingerprint: 'asset1s7nlt45cc82upqewvjtgu7g97l7eg483c6wu75',
nature: _types.Portfolio.Token.Nature.Secondary,
type: _types.Portfolio.Token.Type.NFT,
description: ''
};
const ftNoTicker = {
decimals: 0,
ticker: '',
name: 'ZZZZZ',
symbol: 'WTH',
status: _types.Portfolio.Token.Status.Valid,
application: _types.Portfolio.Token.Application.Music,
tag: '222',
reference: 'transactionId#1',
website: 'https://www.whaha.co',
originalImage: 'https://cdn.whatha.com/ck-original1234.png',
id: '14696a4676909f4e3cb1f2e60e2e08e5abed70caf5c02699be971139.3032',
fingerprint: 'asset1s7nlt45cc82upqewvjtgu7g97l7eg483c6wu75',
nature: _types.Portfolio.Token.Nature.Secondary,
type: _types.Portfolio.Token.Type.FT,
description: ''
};
const ftNameless = {
decimals: 0,
ticker: 'zz',
name: '',
symbol: 'WTH',
status: _types.Portfolio.Token.Status.Valid,
application: _types.Portfolio.Token.Application.Music,
tag: '222',
reference: 'transactionId#1',
website: 'https://www.whaha.co',
originalImage: 'https://cdn.whatha.com/ck-original1234.png',
id: '14696a4676909f4e3cb1f2e60e2e08e5abed70caf5c02699be971139.3033',
fingerprint: 'asset1s7nlt45cc82upqewvjtgu7g97l7eg483c6wu75',
nature: _types.Portfolio.Token.Nature.Secondary,
type: _types.Portfolio.Token.Type.FT,
description: ''
};
// NOTE: If you marked a record as not modified 304, remember to add to the intiial state
// otherwise the tests will throw cuz it will be expected the record to exist in the cache
const apiResponseTokenInfos = {
[nftCryptoKitty.id]: [_types.Api.HttpStatusCode.Ok, nftCryptoKitty, 'hash2-1', 3600],
[rnftWhatever.id]: [_types.Api.HttpStatusCode.NotModified, 3600],
[ftNoTicker.id]: [_types.Api.HttpStatusCode.Ok, ftNoTicker, 'hash4-1', 3600],
[ftNameless.id]: [_types.Api.HttpStatusCode.Ok, ftNameless, 'hash5', 3600]
};
const apiRequestTokenInfos = [[nftCryptoKitty.id, 'hash2'], [rnftWhatever.id, 'hash3'], [ftNoTicker.id, 'hash4'], [ftNameless.id, 'hash5']];
const storage = {
notModified: [[rnftWhatever.id, (0, _common.cacheRecordMaker)({
expires: Date.now() - 3_600_000,
hash: 'hash3'
}, rnftWhatever)]],
cached: [[rnftWhatever.id, (0, _common.cacheRecordMaker)({
expires: Date.now() + 3_600_000,
hash: 'hash3'
}, rnftWhatever)]],
entries1: [[nftCryptoKitty.id, (0, _common.cacheRecordMaker)({
expires: Date.now() - 3_600_000,
hash: 'hash2'
}, nftCryptoKitty)], [rnftWhatever.id, (0, _common.cacheRecordMaker)({
expires: Date.now() + 3_600_000,
hash: 'hash3'
}, rnftWhatever)], [ftNoTicker.id, (0, _common.cacheRecordMaker)({
expires: Date.now() - 3_600_000,
hash: 'hash4'
}, ftNoTicker)], [ftNameless.id, (0, _common.cacheRecordMaker)({
expires: Date.now() + 3_600_000,
hash: 'hash5'
}, ftNameless)]]
};
const apiResponseTokenInfo = (0, _immer.freeze)({
success: {
tag: 'right',
value: {
status: 200,
data: nftCryptoKitty
}
},
error: {
tag: 'left',
error: {
status: 404,
responseData: null,
message: 'Not found'
}
}
}, true);
const tokenInfoMocks = (0, _immer.freeze)({
primaryETH,
nftCryptoKitty,
rnftWhatever,
ftNoTicker,
ftNameless,
storage,
apiResponseResult: apiResponseTokenInfos,
apiRequestArgs: apiRequestTokenInfos,
apiReponse: {
nftCryptoKitty: apiResponseTokenInfo
}
});
exports.tokenInfoMocks = tokenInfoMocks;
//# sourceMappingURL=token-info.mocks.js.map