-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from penumbra-zone/lp-current-state-asset-rende…
…rings LP Current Status Functionality
- Loading branch information
Showing
19 changed files
with
550 additions
and
40 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
export interface GrpcConfig { | ||
grpcEndpoint: string; | ||
} | ||
|
||
const defaultPenumbraGrpcEndpoint = "https://grpc.testnet.penumbra.zone"; | ||
|
||
export const testnetConstants: GrpcConfig = { | ||
grpcEndpoint: process.env.PENUMBRA_GRPC_ENDPOINT ? process.env.PENUMBRA_GRPC_ENDPOINT : defaultPenumbraGrpcEndpoint, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
export interface Token { | ||
decimals: number; | ||
symbol: string; | ||
inner: string; | ||
imagePath?: string; | ||
} | ||
|
||
export const tokenConfigMapOnInner: { [key: string]: Token } = { | ||
"KeqcLzNx9qSH5+lcJHBB9KNW+YPrBk5dKzvPMiypahA=": { | ||
decimals: 6, | ||
symbol: "penumbra", | ||
inner: "KeqcLzNx9qSH5+lcJHBB9KNW+YPrBk5dKzvPMiypahA=", | ||
imagePath: "/assets/icons/penumbra.png", | ||
}, | ||
}; | ||
|
||
// Recreate from tokenConfigMapOnInner to not have to redefine the same data | ||
export const tokenConfigMapOnSymbol: { [key: string]: Token } = | ||
Object.fromEntries( | ||
Object.entries(tokenConfigMapOnInner).map(([key, value]) => [ | ||
value.symbol.toLowerCase(), // Lowercase to help index if we have discrepancies | ||
value, | ||
]) | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import { validateSchema } from "./validation"; | ||
import { z } from "zod"; | ||
|
||
export const Base64StringSchema = z.string().refine( | ||
(str) => { | ||
// Regular expression that matches base64 strings | ||
const base64Regex = | ||
/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/; | ||
return base64Regex.test(str); | ||
}, | ||
{ | ||
message: "Invalid base64 string", | ||
} | ||
); | ||
|
||
export type Base64Str = z.infer<typeof Base64StringSchema>; | ||
|
||
export const InnerBase64Schema = z.object({ inner: Base64StringSchema }); | ||
|
||
export const base64ToUint8Array = (base64: string): Uint8Array => { | ||
const validated = validateSchema(Base64StringSchema, base64); | ||
const binString = atob(validated); | ||
return Uint8Array.from(binString, (byte) => byte.codePointAt(0)!); | ||
}; | ||
|
||
export const uint8ArrayToBase64 = (byteArray: Uint8Array): string => { | ||
const binString = String.fromCodePoint(...byteArray); | ||
return btoa(binString); | ||
}; |
Oops, something went wrong.