Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

patch to handle v1 chains that return nextKey as string #6611

Merged
merged 1 commit into from
Feb 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -28,17 +28,23 @@ export const fetchProposalsByStatusV1 = async (
});

let nextKey = pagination?.next_key;

while (nextKey?.length > 0) {
// console.log(nextKey);
// TODO: temp fix to handle chains that return nextKey as a string instead of Uint8Array
// Our v1 API needs to handle this better. To be addressed in #6610
if (typeof nextKey === 'string') {
nextKey = new Uint8Array(Buffer.from(nextKey, 'base64'));
}

const { proposals, pagination: nextPage } =
await lcd.cosmos.gov.v1.proposals({
proposalStatus: status,
voter: '',
depositor: '',
pagination: {
key: nextKey,
limit: null,
offset: null,
limit: undefined,
offset: undefined,
countTotal: true,
reverse: true,
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,12 @@ export async function fetchLatestCosmosProposalV1(
}
} else nextKey = pagination.next_key;
}

// TODO: temp fix to handle chains that return nextKey as a string instead of Uint8Array
// Our v1 API needs to handle this better. To be addressed in #6610
if (typeof nextKey === 'string') {
nextKey = new Uint8Array(Buffer.from(nextKey, 'base64'));
}
} while (uint8ArrayToNumberBE(nextKey) > 0);

if (finalProposalsPage.length > 0) {
Expand Down
Loading