diff --git a/src/utils/multisig/fetch.test.ts b/src/utils/multisig/fetch.test.ts index ecb1ccc190..a1d01d5538 100644 --- a/src/utils/multisig/fetch.test.ts +++ b/src/utils/multisig/fetch.test.ts @@ -76,6 +76,7 @@ describe("multisig fetch", () => { in: ["pkh1,pkh2,pkh3"], }, select: { fields: ["address"] }, + limit: 3, }, { baseUrl: network.tzktApiUrl } ); diff --git a/src/utils/multisig/fetch.ts b/src/utils/multisig/fetch.ts index 0a333017cc..d15382b2e4 100644 --- a/src/utils/multisig/fetch.ts +++ b/src/utils/multisig/fetch.ts @@ -35,6 +35,7 @@ export const getExistingContracts = (pkhs: RawPkh[], network: Network): Promise< { address: { in: [pkhs.join(",")] }, select: { fields: ["address"] }, + limit: Math.min(10000, pkhs.length), }, { baseUrl: network.tzktApiUrl, diff --git a/src/utils/multisig/helper.test.ts b/src/utils/multisig/helper.test.ts index dee67a9ac4..18d17b807d 100644 --- a/src/utils/multisig/helper.test.ts +++ b/src/utils/multisig/helper.test.ts @@ -118,6 +118,7 @@ describe("multisig helpers", () => { in: ["pkh1,pkh2,pkh3"], }, select: { fields: ["address"] }, + limit: 3, }, { baseUrl: MAINNET.tzktApiUrl } ); @@ -127,6 +128,7 @@ describe("multisig helpers", () => { in: ["pkh1,pkh2,pkh3"], }, select: { fields: ["address"] }, + limit: 3, }, { baseUrl: GHOSTNET.tzktApiUrl } ); @@ -151,5 +153,19 @@ describe("multisig helpers", () => { ]) ); }); + + it("returns empty map for empty contracts list", async () => { + mockedContractsGet.mockImplementation((...args) => { + if (args[1].baseUrl === MAINNET.tzktApiUrl) { + return Promise.resolve(["pkh1", "pkh3", "pkh4"] as any); + } else { + return Promise.resolve(["pkh2", "pkh5"] as any); + } + }); + + const result = await getNetworksForContracts([MAINNET, GHOSTNET], []); + + expect(result).toEqual(new Map()); + }); }); }); diff --git a/src/utils/multisig/helpers.ts b/src/utils/multisig/helpers.ts index 6dd6ebae08..9c651de25f 100644 --- a/src/utils/multisig/helpers.ts +++ b/src/utils/multisig/helpers.ts @@ -49,6 +49,10 @@ export const getNetworksForContracts = async ( ): Promise> => { const result = new Map(); + if (contractPkhs.length === 0) { + return result; + } + const accountsWithNetwork = await Promise.all( availableNetworks.map(async network => (await getExistingContracts(contractPkhs, network)).map(contractPkh => [ @@ -58,7 +62,6 @@ export const getNetworksForContracts = async ( ) ); accountsWithNetwork.flat().forEach(([pkh, network]) => result.set(pkh, network)); - return result; }; diff --git a/src/utils/redux/migrations.ts b/src/utils/redux/migrations.ts index 94aefc5dd4..ef991cc43b 100644 --- a/src/utils/redux/migrations.ts +++ b/src/utils/redux/migrations.ts @@ -84,4 +84,5 @@ export const accountsMigrations = { }); }), 5: identity, + 6: identity, } as any;