Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const { friend, amount, memo, currency, sendViaLink } = this.state
let success
if (sendViaLink) {
const { state: { user: { address } }, getUcacFromCurrency, sendEmailTx } = this.props
const ucac = getUcacFromCurrency(currency)
const inviteTx = new InviteTransaction({ address, amount, memo, ucac, direction, currency })
const buildLink = new firebase.links.DynamicLink(inviteTx.hash, 'lndr.page.link')
buildLink
.android.setPackageName('com.lndr')
.android.setFallbackUrl('https://play.google.com/store/apps/details?id=com.lndr')
.ios.setAppStoreId('1322487591')
.ios.setBundleId('io.lndr')
firebase.links().createDynamicLink(buildLink)
.then(url => {
Share.share({
message: `${splitExpense}: ${url}`,
url: url,
title: splitExpense
}, {
// Android only:
dialogTitle: splitExpense
})
.then( async() => {
console.log(3)
try {
console.log(4)
await submittingTransaction.wrap(sendEmailTx(inviteTx))
console.log(5)
this.clearAndGoHome(friend, { type: true })
const { friend, amount, memo, currency, nonFriend } = this.state
let success
if (nonFriend) {
try {
const { state: { user: { address } }, getUcacFromCurrency, sendEmailTx } = this.props
const ucac = getUcacFromCurrency(currency)
const inviteTx = new InviteTransaction({ address, amount, memo, ucac, direction, currency })
const buildLink = new firebase.links.DynamicLink('https://blockmason.io/lndr', 'lndr.page.link')
buildLink
.android.setPackageName('com.lndr')
.ios.setAppStoreId('1322487591')
.ios.setBundleId('io.lndr')
const url = await firebase.links().createShortDynamicLink(buildLink, "SHORT")
const { action } : any = await Share.share({
message: `${splitExpense}: ${url}?hash=${inviteTx.hash}`,
title: splitExpense
}, {
dialogTitle: splitExpense // Android only
})
if (action === Share.sharedAction) {
await submittingTransaction.wrap(sendEmailTx(inviteTx))
this.clearAndGoHome(friend, { type: true })
}
} catch(error) {
console.log('ERROR SENDING EMAIL TRANSACTION: ', error)
}
} else {
export async function dynamicLink(url: string): Promise {
try {
// TODO: Move 'celo.page.link' to celo-org-mobile firebase project and then flip this bool once
// that's done.
const useRNFirebase = false
if (useRNFirebase) {
const link = new firebase.links.DynamicLink(url, 'celo.page.link')
// TODO: Remove this ts ignore when we upgrade react-native-firebase
// @ts-ignore: Seems like RN Firebase has the incorrect type for this function call.
const shortUrl = await firebase.links().createShortDynamicLink(link, 'UNGUESSABLE')
return shortUrl
} else {
const longDynamicLink = `https://celo.page.link/?link=${encodeURIComponent(url)}`
const apiUrl = `https://firebasedynamiclinks.googleapis.com/v1/shortLinks?key=${FIREBASE_WEB_KEY}`
const response = await fetch(apiUrl, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({ longDynamicLink }),
})
if (response.status !== 200) {
return url
}
const json = await response.json()
return json.shortLink
export const shortenLink = async (linkIn) => {
try {
const domain = Platform.select({
ios: 'https://lanechange.page.link',
default: 'lanechange.page.link',
});
consolelog(`firebase shortenLink, shortening ${linkIn}, domain=${domain}`);
const link = new firebase.links.DynamicLink(linkIn, domain);
const retval = await firebase.links().createShortDynamicLink(link, 'UNGUESSABLE');
return retval;
} catch (e) {
consolelog('ERROR in firebase/shortenLink:');
consolelog(e);
return undefined;
}
};