diff --git a/CHANGELOG.MD b/CHANGELOG.MD index a4330f25..d12e3a88 100644 --- a/CHANGELOG.MD +++ b/CHANGELOG.MD @@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [2.0.0] + +### ⚠️ Breaking change - Fix + +- sort response in `getAccount` + ## [1.3.0] ### Added diff --git a/docs/badge-coverage.svg b/docs/badge-coverage.svg index ac580053..377bab0a 100644 --- a/docs/badge-coverage.svg +++ b/docs/badge-coverage.svg @@ -1 +1 @@ -Coverage: 68.97%Coverage68.97% \ No newline at end of file +Coverage: 69.01%Coverage69.01% \ No newline at end of file diff --git a/package.json b/package.json index 77d60b65..3d67b5ab 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@blockfrost/blockfrost-js", - "version": "1.3.0", + "version": "2.0.0", "description": "A JavaScript/TypeScript SDK for interacting with the https://blockfrost.io API", "keywords": [ "blockfrost", diff --git a/src/account/index.ts b/src/account/index.ts index 0d825c67..4df04d2f 100644 --- a/src/account/index.ts +++ b/src/account/index.ts @@ -67,17 +67,12 @@ export async function getAccount( ); } - const sorted = result.sort((a, b) => { - if (a.path < b.path) { - return -1; - } - - if (a.path > b.path) { - return 1; - } + const sortedResult = result.sort((item1, item2) => { + const path1 = parseInt(item1.path.split('/').slice(-1)[0], 10); + const path2 = parseInt(item2.path.split('/').slice(-1)[0], 10); - return 0; + return path1 - path2; }); - return sorted; + return sortedResult; } diff --git a/src/types/OpenApi.ts b/src/types/OpenApi.ts index 1eac120e..149203c5 100644 --- a/src/types/OpenApi.ts +++ b/src/types/OpenApi.ts @@ -3258,8 +3258,8 @@ export interface components { | ({ /** Name of the asset */ name?: string; - /** URI of the associated asset */ - image?: string; + /** URI(s) of the associated asset */ + image?: string | any[]; } & { [key: string]: any }) | null; metadata: { diff --git a/test/fixtures/account/index.ts b/test/fixtures/account/index.ts index fde6eb53..ea338d8a 100644 --- a/test/fixtures/account/index.ts +++ b/test/fixtures/account/index.ts @@ -32,25 +32,22 @@ export const getAccountFixtures = [ { address: 'addr1q8u5ktsj5zsmhvwv0ep9zuhfu39x3wyt9wxjnsn3cagsyy59ckxhkvuc5xj49rw6zrp443wlygmhv8gwcu38jk6ms6usrmcafl', + path: "m/1852'/1815'/0'/0/0", data: { address: 'addr1q8u5ktsj5zsmhvwv0ep9zuhfu39x3wyt9wxjnsn3cagsyy59ckxhkvuc5xj49rw6zrp443wlygmhv8gwcu38jk6ms6usrmcafl', amount: [ + { unit: 'lovelace', quantity: '1518517' }, { - quantity: '1518517', - unit: 'lovelace', - }, - { - quantity: '1', unit: '2f712364ec46f0cf707d412106ce71ef3370f76e27fb56b6bb14708776657465726e696b4e657a6a6564656e79', + quantity: '1', }, ], - script: false, stake_address: 'stake1uxzutrtmxwv2rf2j3hdpps66ch0jydmkr58vwgnetddcdwg32u4rc', type: 'shelley', + script: false, }, - path: "m/1852'/1815'/0'/0/0", }, { address: @@ -58,6 +55,54 @@ export const getAccountFixtures = [ data: 'empty', path: "m/1852'/1815'/0'/0/1", }, + { + address: + 'addr1qyqe0pmj2wcz3x6ref4855wunf26fc4vx84tdxluxcu09459ckxhkvuc5xj49rw6zrp443wlygmhv8gwcu38jk6ms6ustfft9k', + data: 'empty', + path: "m/1852'/1815'/0'/0/2", + }, + { + address: + 'addr1qxp7mkumqsl4xpxlp7sz7jv6mwc90m4scwz5hg995m24ey59ckxhkvuc5xj49rw6zrp443wlygmhv8gwcu38jk6ms6uscpt2n8', + data: 'empty', + path: "m/1852'/1815'/0'/0/3", + }, + { + address: + 'addr1qx0n2np4cxx2wx2qdt0pl9n4zctj2e5j7gz70mlmkk88u859ckxhkvuc5xj49rw6zrp443wlygmhv8gwcu38jk6ms6us3mtqqn', + data: 'empty', + path: "m/1852'/1815'/0'/0/4", + }, + { + address: + 'addr1qxdr0k9nvqlycwkwtzcrtqc2v7zapncq6zhxsgsppcyvhf59ckxhkvuc5xj49rw6zrp443wlygmhv8gwcu38jk6ms6ushm8zc9', + data: 'empty', + path: "m/1852'/1815'/0'/0/5", + }, + { + address: + 'addr1q8agxy2xc2rwt0chvprvx7nxeh5tst3ekf24kggs9xuq7dv9ckxhkvuc5xj49rw6zrp443wlygmhv8gwcu38jk6ms6uslpypuu', + data: 'empty', + path: "m/1852'/1815'/0'/0/6", + }, + { + address: + 'addr1q9g27g8gq47aggv90ew8cdh2xnxp909pf5pqvvaun7t2pty9ckxhkvuc5xj49rw6zrp443wlygmhv8gwcu38jk6ms6uspjtj9g', + data: 'empty', + path: "m/1852'/1815'/0'/0/7", + }, + { + address: + 'addr1qx7cn3u8vd6fc2g3t4k7ntqap7mkw5httgdlq9aa06d2uey9ckxhkvuc5xj49rw6zrp443wlygmhv8gwcu38jk6ms6uswmwl2n', + data: 'empty', + path: "m/1852'/1815'/0'/0/8", + }, + { + address: + 'addr1qx2j2tsmqasn66nkqqcfvm328f7sxnujqklkx5uq0l224fu9ckxhkvuc5xj49rw6zrp443wlygmhv8gwcu38jk6ms6us63u6rn', + data: 'empty', + path: "m/1852'/1815'/0'/0/9", + }, { address: 'addr1q8qpqk43plruvyhz7ngsh508ensd2qq3xps6w69fsnfv0ly9ckxhkvuc5xj49rw6zrp443wlygmhv8gwcu38jk6ms6uszr3th7', @@ -118,12 +163,6 @@ export const getAccountFixtures = [ data: 'empty', path: "m/1852'/1815'/0'/0/19", }, - { - address: - 'addr1qyqe0pmj2wcz3x6ref4855wunf26fc4vx84tdxluxcu09459ckxhkvuc5xj49rw6zrp443wlygmhv8gwcu38jk6ms6ustfft9k', - data: 'empty', - path: "m/1852'/1815'/0'/0/2", - }, { address: 'addr1qx2tpuxgl2g9ang3e52j2eawryuradd6jf0thq9garl2utu9ckxhkvuc5xj49rw6zrp443wlygmhv8gwcu38jk6ms6usc8xjap', @@ -184,12 +223,6 @@ export const getAccountFixtures = [ data: 'empty', path: "m/1852'/1815'/0'/0/29", }, - { - address: - 'addr1qxp7mkumqsl4xpxlp7sz7jv6mwc90m4scwz5hg995m24ey59ckxhkvuc5xj49rw6zrp443wlygmhv8gwcu38jk6ms6uscpt2n8', - data: 'empty', - path: "m/1852'/1815'/0'/0/3", - }, { address: 'addr1q8p5w5tpkjyc43rr5xc4mtax33vr8lzk6g4s2fd7qaq5h8v9ckxhkvuc5xj49rw6zrp443wlygmhv8gwcu38jk6ms6usy6f404', @@ -250,42 +283,6 @@ export const getAccountFixtures = [ data: 'empty', path: "m/1852'/1815'/0'/0/39", }, - { - address: - 'addr1qx0n2np4cxx2wx2qdt0pl9n4zctj2e5j7gz70mlmkk88u859ckxhkvuc5xj49rw6zrp443wlygmhv8gwcu38jk6ms6us3mtqqn', - data: 'empty', - path: "m/1852'/1815'/0'/0/4", - }, - { - address: - 'addr1qxdr0k9nvqlycwkwtzcrtqc2v7zapncq6zhxsgsppcyvhf59ckxhkvuc5xj49rw6zrp443wlygmhv8gwcu38jk6ms6ushm8zc9', - data: 'empty', - path: "m/1852'/1815'/0'/0/5", - }, - { - address: - 'addr1q8agxy2xc2rwt0chvprvx7nxeh5tst3ekf24kggs9xuq7dv9ckxhkvuc5xj49rw6zrp443wlygmhv8gwcu38jk6ms6uslpypuu', - data: 'empty', - path: "m/1852'/1815'/0'/0/6", - }, - { - address: - 'addr1q9g27g8gq47aggv90ew8cdh2xnxp909pf5pqvvaun7t2pty9ckxhkvuc5xj49rw6zrp443wlygmhv8gwcu38jk6ms6uspjtj9g', - data: 'empty', - path: "m/1852'/1815'/0'/0/7", - }, - { - address: - 'addr1qx7cn3u8vd6fc2g3t4k7ntqap7mkw5httgdlq9aa06d2uey9ckxhkvuc5xj49rw6zrp443wlygmhv8gwcu38jk6ms6uswmwl2n', - data: 'empty', - path: "m/1852'/1815'/0'/0/8", - }, - { - address: - 'addr1qx2j2tsmqasn66nkqqcfvm328f7sxnujqklkx5uq0l224fu9ckxhkvuc5xj49rw6zrp443wlygmhv8gwcu38jk6ms6us63u6rn', - data: 'empty', - path: "m/1852'/1815'/0'/0/9", - }, ], }, { @@ -296,40 +293,86 @@ export const getAccountFixtures = [ { address: 'addr1q9f9jr6e48u63ym65esmrwgle84zspnrsew37gwe88e0zfy9ckxhkvuc5xj49rw6zrp443wlygmhv8gwcu38jk6ms6usxwwdwc', + path: "m/1852'/1815'/0'/1/0", data: { address: 'addr1q9f9jr6e48u63ym65esmrwgle84zspnrsew37gwe88e0zfy9ckxhkvuc5xj49rw6zrp443wlygmhv8gwcu38jk6ms6usxwwdwc', - amount: [ - { - quantity: expect.any(String), - unit: 'lovelace', - }, - ], - script: false, + amount: [{ unit: 'lovelace', quantity: '25737997' }], stake_address: 'stake1uxzutrtmxwv2rf2j3hdpps66ch0jydmkr58vwgnetddcdwg32u4rc', type: 'shelley', + script: false, }, - path: "m/1852'/1815'/0'/1/0", }, { address: 'addr1q99hnk2vnx708l86mujpfs9end50em9s95grhe3v4933m259ckxhkvuc5xj49rw6zrp443wlygmhv8gwcu38jk6ms6usr7qlze', + path: "m/1852'/1815'/0'/1/1", data: { address: 'addr1q99hnk2vnx708l86mujpfs9end50em9s95grhe3v4933m259ckxhkvuc5xj49rw6zrp443wlygmhv8gwcu38jk6ms6usr7qlze', - amount: [ - { - quantity: expect.any(String), - unit: 'lovelace', - }, - ], + amount: [{ unit: 'lovelace', quantity: '0' }], + stake_address: + 'stake1uxzutrtmxwv2rf2j3hdpps66ch0jydmkr58vwgnetddcdwg32u4rc', + type: 'shelley', script: false, + }, + }, + { + address: + 'addr1qxv0q8r02xlrea3nr3p0zthpg5slg2sk263rszm6cmgnx259ckxhkvuc5xj49rw6zrp443wlygmhv8gwcu38jk6ms6usyu5v2j', + path: "m/1852'/1815'/0'/1/2", + data: { + address: + 'addr1qxv0q8r02xlrea3nr3p0zthpg5slg2sk263rszm6cmgnx259ckxhkvuc5xj49rw6zrp443wlygmhv8gwcu38jk6ms6usyu5v2j', + amount: [{ unit: 'lovelace', quantity: '0' }], stake_address: 'stake1uxzutrtmxwv2rf2j3hdpps66ch0jydmkr58vwgnetddcdwg32u4rc', type: 'shelley', + script: false, }, - path: "m/1852'/1815'/0'/1/1", + }, + { + address: + 'addr1q93el09nevlnzm2td5e3g508lv9axhn2xzxevc9m6khfqny9ckxhkvuc5xj49rw6zrp443wlygmhv8gwcu38jk6ms6usq4u26u', + data: 'empty', + path: "m/1852'/1815'/0'/1/3", + }, + { + address: + 'addr1q8gs22r0m9se5zedcchgwu0udtakd9eh5m4fn54hte6wu0y9ckxhkvuc5xj49rw6zrp443wlygmhv8gwcu38jk6ms6us7v0s48', + data: 'empty', + path: "m/1852'/1815'/0'/1/4", + }, + { + address: + 'addr1q99ts5lj5wnx4lxh6varz0z2j705zwq8tpdwscjsqx9yvtu9ckxhkvuc5xj49rw6zrp443wlygmhv8gwcu38jk6ms6uskfn7lw', + data: 'empty', + path: "m/1852'/1815'/0'/1/5", + }, + { + address: + 'addr1qxl0h2f6v4fdsd97qdc44fuzwy045u52y73vzxh6tz94x8y9ckxhkvuc5xj49rw6zrp443wlygmhv8gwcu38jk6ms6usggqeu7', + data: 'empty', + path: "m/1852'/1815'/0'/1/6", + }, + { + address: + 'addr1q8rg26gtcv37mch828zsakry37e73uh9ghmfkpwugn9trau9ckxhkvuc5xj49rw6zrp443wlygmhv8gwcu38jk6ms6us5lecdu', + data: 'empty', + path: "m/1852'/1815'/0'/1/7", + }, + { + address: + 'addr1qywhamzedt87fw8wgj899mmttsha38hf2s80jfg5ge009gu9ckxhkvuc5xj49rw6zrp443wlygmhv8gwcu38jk6ms6usm38r9f', + data: 'empty', + path: "m/1852'/1815'/0'/1/8", + }, + { + address: + 'addr1q8q7000x9y0zhm39a2ctn6ggng3mna888d76kp6aeszw3dy9ckxhkvuc5xj49rw6zrp443wlygmhv8gwcu38jk6ms6us4azjjp', + data: 'empty', + path: "m/1852'/1815'/0'/1/9", }, { address: @@ -391,25 +434,6 @@ export const getAccountFixtures = [ data: 'empty', path: "m/1852'/1815'/0'/1/19", }, - { - address: - 'addr1qxv0q8r02xlrea3nr3p0zthpg5slg2sk263rszm6cmgnx259ckxhkvuc5xj49rw6zrp443wlygmhv8gwcu38jk6ms6usyu5v2j', - data: { - address: - 'addr1qxv0q8r02xlrea3nr3p0zthpg5slg2sk263rszm6cmgnx259ckxhkvuc5xj49rw6zrp443wlygmhv8gwcu38jk6ms6usyu5v2j', - amount: [ - { - quantity: '0', - unit: 'lovelace', - }, - ], - script: false, - stake_address: - 'stake1uxzutrtmxwv2rf2j3hdpps66ch0jydmkr58vwgnetddcdwg32u4rc', - type: 'shelley', - }, - path: "m/1852'/1815'/0'/1/2", - }, { address: 'addr1qxgkaygw54uf09xfdfjadcm25plaz0qlsdw9mcnyeurkwg59ckxhkvuc5xj49rw6zrp443wlygmhv8gwcu38jk6ms6usv59zgf', @@ -470,12 +494,6 @@ export const getAccountFixtures = [ data: 'empty', path: "m/1852'/1815'/0'/1/29", }, - { - address: - 'addr1q93el09nevlnzm2td5e3g508lv9axhn2xzxevc9m6khfqny9ckxhkvuc5xj49rw6zrp443wlygmhv8gwcu38jk6ms6usq4u26u', - data: 'empty', - path: "m/1852'/1815'/0'/1/3", - }, { address: 'addr1qxxgzx9mlu2gs0lht742mky08wa655sa63q84apw74wz8yy9ckxhkvuc5xj49rw6zrp443wlygmhv8gwcu38jk6ms6us37kn60', @@ -536,42 +554,6 @@ export const getAccountFixtures = [ data: 'empty', path: "m/1852'/1815'/0'/1/39", }, - { - address: - 'addr1q8gs22r0m9se5zedcchgwu0udtakd9eh5m4fn54hte6wu0y9ckxhkvuc5xj49rw6zrp443wlygmhv8gwcu38jk6ms6us7v0s48', - data: 'empty', - path: "m/1852'/1815'/0'/1/4", - }, - { - address: - 'addr1q99ts5lj5wnx4lxh6varz0z2j705zwq8tpdwscjsqx9yvtu9ckxhkvuc5xj49rw6zrp443wlygmhv8gwcu38jk6ms6uskfn7lw', - data: 'empty', - path: "m/1852'/1815'/0'/1/5", - }, - { - address: - 'addr1qxl0h2f6v4fdsd97qdc44fuzwy045u52y73vzxh6tz94x8y9ckxhkvuc5xj49rw6zrp443wlygmhv8gwcu38jk6ms6usggqeu7', - data: 'empty', - path: "m/1852'/1815'/0'/1/6", - }, - { - address: - 'addr1q8rg26gtcv37mch828zsakry37e73uh9ghmfkpwugn9trau9ckxhkvuc5xj49rw6zrp443wlygmhv8gwcu38jk6ms6us5lecdu', - data: 'empty', - path: "m/1852'/1815'/0'/1/7", - }, - { - address: - 'addr1qywhamzedt87fw8wgj899mmttsha38hf2s80jfg5ge009gu9ckxhkvuc5xj49rw6zrp443wlygmhv8gwcu38jk6ms6usm38r9f', - data: 'empty', - path: "m/1852'/1815'/0'/1/8", - }, - { - address: - 'addr1q8q7000x9y0zhm39a2ctn6ggng3mna888d76kp6aeszw3dy9ckxhkvuc5xj49rw6zrp443wlygmhv8gwcu38jk6ms6us4azjjp', - data: 'empty', - path: "m/1852'/1815'/0'/1/9", - }, ], }, ] as const;