@daimo/pay
Version:
Seamless crypto payments. Onboard users from any chain, any coin into your app with one click.
21 lines (18 loc) • 760 B
JavaScript
import { waitForState, createStore } from '../stateStore.js';
import { paymentReducer, initialPaymentState } from './paymentFsm.js';
function createPaymentStore() {
const store = createStore(paymentReducer, initialPaymentState);
return store;
}
/**
* Wait for the `PaymentStore` to enter a state matching any of `validTypes`,
* or reject as soon as it hits the `"error"` state.
*
* @returns Promise<T> resolving with the first matching state or rejecting with
* the error message
*/
function waitForPaymentState(store, ...validTypes) {
return waitForState(store, (s) => validTypes.includes(s.type), (s) => s.type === "error", (s) => s.message);
}
export { createPaymentStore, waitForPaymentState };
//# sourceMappingURL=paymentStore.js.map