Skip to content

Commit

Permalink
fix: big endian
Browse files Browse the repository at this point in the history
  • Loading branch information
lermchair committed Nov 4, 2024
1 parent d34b463 commit 359e389
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 8 deletions.
2 changes: 1 addition & 1 deletion apps/api/src/cyberfrogs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export interface CyberfrogData {
*/
export const parseCyberfrogData = (
signature: string,
nonce: number
nonce: number,
): CyberfrogData => {
try {
const recoveryBit = parseInt(signature.slice(-1));
Expand Down
14 changes: 7 additions & 7 deletions apps/api/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export interface UserFeedState {

export function computeUserFeedState(
state: Pick<UserFeed, "lastFetchedAt"> | undefined,
feed: Feed
feed: Feed,
): UserFeedState {
const lastFetchedAt = state?.lastFetchedAt?.getTime() ?? 0;
const nextFetchAt = lastFetchedAt + feed.cooldown * 1000;
Expand All @@ -38,11 +38,11 @@ export function computeUserFeedState(
export function sampleFrogAttribute(
min?: number,
max?: number,
rarity?: Rarity
rarity?: Rarity,
): number {
return _.random(
Math.round(min ?? 0),
Math.round(max ?? (rarity === Rarity.Common ? 7 : 15))
Math.round(max ?? (rarity === Rarity.Common ? 7 : 15)),
);
}

Expand Down Expand Up @@ -74,10 +74,10 @@ export function compareIds(id1: string, id2: string): number {

export function numberToUint8Array(num: number): Uint8Array {
const arr = new Uint8Array(4);
for (let i = 0; i < 4; i++) {
arr[3 - i] = num & 0xff;
num = num >> 8;
}
arr[0] = (num >> 24) & 0xff;
arr[1] = (num >> 16) & 0xff;
arr[2] = (num >> 8) & 0xff;
arr[3] = num & 0xff;
return arr;
}

Expand Down
1 change: 1 addition & 0 deletions apps/pond/src/components/CyberFrog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ function CyberFrog() {
}, [setSearchParams]);

const z = useParcnetClient();

const { mutateAsync: getCyberFrog } = trpc.feeds.getCyberFrog.useMutation({
onSuccess: (data) => {
// FIXME: upstream bug where insert doesn't resolve
Expand Down

0 comments on commit 359e389

Please sign in to comment.