Skip to content

Commit

Permalink
Try fix query by owner on infinity-factory
Browse files Browse the repository at this point in the history
  • Loading branch information
tasiov committed Sep 25, 2023
1 parent c2b2d91 commit 1571485
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 7 deletions.
14 changes: 11 additions & 3 deletions contracts/infinity-factory/src/query.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,14 +70,22 @@ pub fn query_pairs_by_owner(
return Ok(vec![]);
}

let infinity_global = INFINITY_GLOBAL.load(deps.storage)?;
let global_config = load_global_config(&deps.querier, &infinity_global)?;

let range = index_range_from_query_options(num_pairs_option.unwrap(), query_options);

let mut retval: Vec<(u64, Addr)> = vec![];

let code_id = deps.querier.query_wasm_contract_info(&env.contract.address)?.code_id;

for idx in range {
let (pair, _) = generate_instantiate_2_addr(deps, &env, &owner, idx, code_id).unwrap();
let (pair, _) = generate_instantiate_2_addr(
deps,
&env,
&owner,
idx,
global_config.infinity_pair_code_id,
)
.unwrap();
retval.push((idx, pair));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,8 @@ describe('InfinityFactory', () => {

expect(pairsResponse.length).toEqual(2)
expect(pairsResponse[0][0]).toEqual(2)
expect(pairsResponse[0][1]).toEqual(pairs[2])
expect(pairsResponse[1][0]).toEqual(1)
expect(pairsResponse[1][1]).toEqual(pairs[1])
})
})
8 changes: 4 additions & 4 deletions typescript/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2093,10 +2093,10 @@
ts-node "^10.9.1"
typescript "^5.0.4"

"@stargazezone/infinity-types@0.6.0":
version "0.6.0"
resolved "https://registry.yarnpkg.com/@stargazezone/infinity-types/-/infinity-types-0.6.0.tgz#3bd028501e782b758ab9d89f13931fc335338128"
integrity sha512-bvb8dylCUF6P73TUWwDTXa3CUuJqXfcuOHZ58gnCFbnbIOTZkDjNY8bi9T6zf6qvy2xUWz8gdtWaMp0G2y/Taw==
"@stargazezone/infinity-types@0.7.0":
version "0.7.0"
resolved "https://registry.yarnpkg.com/@stargazezone/infinity-types/-/infinity-types-0.7.0.tgz#82a231f721f272a00d824b459bc60a370c69c4ed"
integrity sha512-JZxrw2A+ZsVhOWmUloPfxAnlVjS4TrPqR9mvlGudkx9eVKrZ4mEELllKZ6ln01Oxqt2zTbRxNuFsiZPLD1zpBQ==
dependencies:
"@cosmjs/amino" "^0.31.0"
"@cosmjs/cosmwasm-stargate" "^0.31.0"
Expand Down

0 comments on commit 1571485

Please sign in to comment.