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
// Function to generate AccountSalt | |
import { buildPoseidon } from 'circomlibjs'; | |
/** | |
* Attempt at reproducing the account salt generation that zkemail does on the backend at -> | |
* https://github.com/zkemail/relayer-utils/blob/aefb00fdcfbfde7fced50e5a0b086e5cc2ff64cd/src/cryptos.rs#L198 | |
* @param email | |
* @param accountCode | |
*/ | |
export async function generateAccountSalt(email: string, accountCode: bigint): Promise<string> { |
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
open class BaseViewModel<T : Any, R : Any>( | |
initialState: T | |
) : CoroutineScope { | |
private val job = Job() | |
override val coroutineContext: CoroutineContext = Dispatchers.Main + job | |
protected val _state = ConflatedBroadcastChannel<T>(initialState) | |
val state = _state.asFlow() | |
val cState = state.wrap() |
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
/** | |
* An http client to use until ktor works with multithreaded coroutines. | |
* This goes in a common module that ios and android clients depend on. | |
* We just return a string as shared components can use kotlinx serialization | |
* thereafter to handle response parsing. | |
*/ | |
interface IPlainClient { | |
fun get( | |
baseUrl: String, | |
path: String, |
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
import com.basebeta.utility.logging.kprint | |
import kotlinx.atomicfu.atomic | |
import kotlinx.coroutines.* | |
import kotlinx.coroutines.channels.BroadcastChannel | |
import kotlinx.coroutines.channels.Channel | |
import kotlinx.coroutines.flow.* | |
/** | |
* Only can use with coroutines 1.3.6-native-mt. See alternative implementation at the bottom for 1.3.5 and under. | |
* |
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
/** | |
* RangeBar is a bar that allows a user to define a range of values by moving two thumbs. | |
* | |
* Normalized value refers to a number as it exists in a range from [min, max] | |
* Px value refers to a number as it exists in a range from [startX, endX] | |
*/ | |
class RangeBar : View { | |
companion object { | |
// The diameter of the circle |
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
/** | |
* Need to return true here to continue hearing updates from the child | |
* for the duration of the scroll | |
*/ | |
public boolean onStartNestedScroll(View child, View target, int nestedScrollAxes) { | |
return true; | |
} | |
@Override | |
public void onNestedPreScroll(View target, int dx, int dy, int[] consumed) { |
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
public interface NestedScrollingParent { | |
public boolean onStartNestedScroll(View child, View target, int nestedScrollAxes); | |
public void onNestedScrollAccepted(View child, View target, int nestedScrollAxes); | |
public void onStopNestedScroll(View target); | |
public void onNestedScroll(View target, int dxConsumed, int dyConsumed, | |
int dxUnconsumed, int dyUnconsumed); | |
public void onNestedPreScroll(View target, int dx, int dy, int[] consumed); | |
public boolean onNestedFling(View target, float velocityX, float velocityY, boolean consumed); | |
public boolean onNestedPreFling(View target, float velocityX, float velocityY); | |
public int getNestedScrollAxes(); |
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
headerTrackScrollListener = new RecyclerView.OnScrollListener() { | |
@Override | |
public void onScrolled(RecyclerView recyclerView, int dx, int dy) { | |
super.onScrolled(recyclerView, dx, dy); | |
float sentinelYPos = adapter.getSentinelViewYPos(); | |
if (sentinelYPos >= Utility.getScreenHeight(getContext()) || !areAuxiliaryTouchEventsEnabled) { | |
return; | |
} | |
float topOfListScrollY = sentinelYPos - headerHeight; |
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
/** | |
* An RxJava-backed EventBus class that can support sending and receiving multiple event types. | |
* | |
* Based on https://gist.github.com/benjchristensen/04eef9ca0851f3a5d7bf | |
*/ | |
public class EventBus<T> { | |
private static EventBus<Object> INSTANCE; | |
private List<T> events; |
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
import android.support.v4.view.ViewPager; | |
import android.view.ViewTreeObserver; | |
/** | |
* A class that can be added to a viewTreeObserver for ViewPager's in order to determine | |
* when a smoothScroll transition is completed by viewPager.setCurrentItem(); | |
*/ | |
public class PagerScrollListener implements ViewTreeObserver.OnScrollChangedListener { | |
private int scrollX; | |
private int totalChange = 0; |
NewerOlder