This file contains hidden or 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 { makeExecutableSchema } from 'graphql-tools'; | |
import merge = require('lodash/merge'); | |
import Scalars from './scalars'; | |
// Modules | |
import Messages from './resolvers/Messages'; | |
import Device from './resolvers/Device'; | |
const Modules = { | |
typeDefs: [ |
This file contains hidden or 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 Expo, { ExpoPushMessage } from 'expo-server-sdk'; | |
import DeviceTokenModel from '../models/DeviceTokenModel'; | |
const expo = new Expo(); | |
interface SendPushNotificationArgs { | |
user_id?: string; | |
title: string; | |
body: string; | |
payload?: { [key: string]: any }; |
This file contains hidden or 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
[...] | |
const MessagesMutation: MessagesMutationResolvers = { | |
async send(_, { input }) { | |
const message = new MessageModel(input); | |
await message.save(); | |
pubsub.publish(NEW_MESSAGE_EVENT, { message }); | |
sendPushNotification({ | |
title: input.senderName, |
This file contains hidden or 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 { gql } from '@apollo/client'; | |
export const RegisterDeviceMutation = gql` | |
mutation RegisterDevice($input: DeviceRegisterInput!) { | |
device { | |
register(input: $input) | |
} | |
} | |
`; |
This file contains hidden or 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 { Platform, AsyncStorage } from 'react-native'; | |
import { Notifications } from 'expo'; | |
import Constants from 'expo-constants'; | |
import * as Permissions from 'expo-permissions'; | |
import * as Types from '../graphql/generated'; | |
import { RegisterDeviceMutation, UnregisterDeviceMutation } from '../graphql/queries/Device'; | |
import { client } from '../graphql/client'; | |
export const RegisterPushNotifications = async (user_id: string) => { | |
const { status: existingStatus } = await Permissions.getAsync(Permissions.NOTIFICATIONS); |
This file contains hidden or 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 React from 'react'; | |
import { createStackNavigator } from '@react-navigation/stack'; | |
import { MainStackParams } from './types/MainStackParams'; | |
import { ConversationScreen } from '../screens/ConversationScreen'; | |
import { RegisterPushNotifications } from '../utils/Notifications'; | |
import { useUser } from '../contexts/AuthContext'; | |
const MainStack = createStackNavigator<MainStackParams>(); | |
export const MainStackScreens: React.FC = () => ( |
This file contains hidden or 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 React from 'react'; | |
import { AsyncStorage } from 'react-native'; | |
import UUID from 'uuid-random'; | |
import { useApolloClient } from '@apollo/client'; | |
import { useUnregisterDeviceMutation } from '../graphql/generated'; | |
[...] | |
export const AuthProvider: React.FC = ({ children }) => { | |
const [userState, setUserState] = React.useState<User>(); |
This file contains hidden or 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
{ | |
"version": "0", | |
"body": { | |
"type": "nft-transfer", | |
"params": { | |
"newOwnerAddress": "EQAn7UgXbrjmgAApFV5FzuVX4P2adn_S3O3gwFpxgi2yf_Cy", | |
"nftItemAddress": "EQBWPunGskn1VravuYLccv1Hn4hnTThBmMl01KFaCKk9Vn3j", | |
"amount": "100000000", | |
"forwardAmount": "20000000", | |
}, |
This file contains hidden or 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
// в компоненте | |
const walletStore = useWallet(); | |
const unlockVault = useUnlockVault(); | |
// в коллбеке | |
const wallet = walletStore.vault.tonWallet; | |
const vault = await unlockVault(); // Показываем ввод пина и ждем анлока | |
const secretKey = await vault.getTonPrivateKey(); // достаем приватный ключ |
This file contains hidden or 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 getTimeSec() { | |
return Math.floor(Date.now() / 1000); | |
} | |
const sec = getTimeSec(); | |
console.log(sec); |