2018-12-28 15:24:46 -08:00
|
|
|
import type, { AddressCollection } from './types';
|
|
|
|
import { deriveTransparentAddress } from '../util';
|
|
|
|
import { getNetwork } from '../node';
|
2019-03-19 12:56:58 -07:00
|
|
|
import { getContributionAddress } from '../bitgo';
|
2018-12-28 15:24:46 -08:00
|
|
|
import env from '../env';
|
|
|
|
|
2019-01-21 09:51:49 -08:00
|
|
|
export function setStartingBlockHeight(height: string | number) {
|
|
|
|
return {
|
|
|
|
type: type.SET_STARTING_BLOCK_HEIGHT as type.SET_STARTING_BLOCK_HEIGHT,
|
|
|
|
payload: parseInt(height.toString(), 10),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-03-19 12:56:58 -07:00
|
|
|
export async function generateAddresses(contributionId: number) {
|
|
|
|
let transparent;
|
|
|
|
if (env.BITGO_WALLET_ID) {
|
|
|
|
transparent = await getContributionAddress(contributionId);
|
|
|
|
} else {
|
|
|
|
transparent = deriveTransparentAddress(contributionId, getNetwork());
|
|
|
|
}
|
|
|
|
|
2018-12-28 15:24:46 -08:00
|
|
|
const addresses: AddressCollection = {
|
2019-03-19 12:56:58 -07:00
|
|
|
transparent,
|
2018-12-28 15:24:46 -08:00
|
|
|
sprout: env.SPROUT_ADDRESS,
|
|
|
|
};
|
|
|
|
return {
|
|
|
|
type: type.GENERATE_ADDRESSES as type.GENERATE_ADDRESSES,
|
|
|
|
payload: {
|
|
|
|
addresses,
|
|
|
|
contributionId,
|
|
|
|
},
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
export function addPaymentDisclosure(contributionId: number, disclosure: string) {
|
|
|
|
return {
|
|
|
|
type: type.ADD_PAYMENT_DISCLOSURE as type.ADD_PAYMENT_DISCLOSURE,
|
|
|
|
payload: {
|
|
|
|
contributionId,
|
|
|
|
disclosure,
|
|
|
|
},
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
export function confirmPaymentDisclosure(contributionId: number, disclosure: string) {
|
|
|
|
return {
|
|
|
|
type: type.CONFIRM_PAYMENT_DISCLOSURE as type.CONFIRM_PAYMENT_DISCLOSURE,
|
|
|
|
payload: {
|
|
|
|
contributionId,
|
|
|
|
disclosure,
|
|
|
|
},
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
export type ActionTypes =
|
2019-01-21 09:51:49 -08:00
|
|
|
| ReturnType<typeof setStartingBlockHeight>
|
2018-12-28 15:24:46 -08:00
|
|
|
| ReturnType<typeof generateAddresses>
|
|
|
|
| ReturnType<typeof addPaymentDisclosure>
|
2019-01-21 09:51:49 -08:00
|
|
|
| ReturnType<typeof confirmPaymentDisclosure>;
|