-
-
Notifications
You must be signed in to change notification settings - Fork 59
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Integration with ADAMANT Notification Service #658
Open
bludnic
wants to merge
5
commits into
dev
Choose a base branch
from
feat/push
base: dev
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+3,414
−967
Open
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
3731048
feat: testing Web Push
bludnic 7362299
chore: separate onMessage and onBackgroundMessage handlers
bludnic a399c4c
fix(signalAsset): fix provider enum
bludnic 25ccefc
feat: add deviceId
bludnic 05b6bcf
push service (web) draft commit
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
/** | ||
* AIP 12: Non-ADM crypto transfer messages | ||
* @see https://aips.adamant.im/AIPS/aip-12 | ||
*/ | ||
export interface CryptoTransferAsset { | ||
/** | ||
* Represents token's network and looks like `tickerSymbol_transaction`, | ||
* e.g. `eth_transaction`. Ticker symbol must be in lower case, but apps | ||
* must process it in any case for backwards compatibility. | ||
*/ | ||
type: string | ||
/** | ||
* Transferred value in tokens of its network. Decimal separator is `.` | ||
*/ | ||
amount: string | ||
/** | ||
* Transaction id in token's network. Used to check transaction status | ||
*/ | ||
hash: string | ||
/** | ||
* May include comment for this transfer, shown to both recipient and sender | ||
*/ | ||
comments?: string | ||
/** | ||
* Can be added to show explanation text messages on client apps that doesn't | ||
* support specified `type` | ||
*/ | ||
text_fallback?: string | ||
} | ||
|
||
/** | ||
* Reply to a message | ||
* | ||
* @see https://aips.adamant.im/AIPS/aip-16 | ||
*/ | ||
export interface ReplyMessageAsset { | ||
/** | ||
* ADM transaction ID of a message which a user replies to | ||
*/ | ||
replyto_id: string | ||
/** | ||
* Text of a reply | ||
*/ | ||
reply_message: string | ||
} | ||
|
||
/** | ||
* Reply to a message with a crypto transfer | ||
* | ||
* @see https://aips.adamant.im/AIPS/aip-16 | ||
*/ | ||
export interface ReplyWithCryptoTransferAsset { | ||
/** | ||
* ADM transaction ID of a message which a user replies to | ||
*/ | ||
replyto_id: string | ||
/** | ||
* Text of a reply | ||
*/ | ||
reply_message: CryptoTransferAsset | ||
} | ||
|
||
interface CryptoTransferPayload { | ||
cryptoSymbol: string | ||
amount: string | ||
hash: string | ||
comments: string | ||
} | ||
|
||
export function cryptoTransferAsset(payload: CryptoTransferPayload): CryptoTransferAsset | ||
|
||
interface ReplyMessagePayload { | ||
replyToId: string | ||
replyMessage: string | ||
} | ||
|
||
export function replyMessageAsset(payload: ReplyMessagePayload): ReplyMessageAsset | ||
|
||
export function replyWithCryptoTransferAsset( | ||
replyToId: string, | ||
transferPayload: CryptoTransferPayload | ||
): ReplyWithCryptoTransferAsset | ||
|
||
export interface ReactionAsset { | ||
/** | ||
* ADM transaction ID of the message to which the user is reacting | ||
*/ | ||
reactto_id: string | ||
/** | ||
* Represents the emoji-based reaction | ||
*/ | ||
react_message: string | ||
} | ||
|
||
export function reactionAsset(reactToId: string, reactMessage: string): ReactionAsset | ||
|
||
export function signalAsset( | ||
deviceId: string, | ||
token: string, | ||
provider: 'APNS' | 'FCM', | ||
action: 'add' | 'remove' | ||
): SignalMessagePayload |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
import { MessageType } from '@/lib/constants' | ||
|
||
export function cryptoTransferAsset({ cryptoSymbol, amount, hash, comments, text_fallback }) { | ||
const asset = { | ||
type: MessageType.cryptoTransferMessage(cryptoSymbol), | ||
amount, | ||
hash, | ||
comments | ||
} | ||
|
||
if (text_fallback) { | ||
asset.text_fallback = text_fallback | ||
} | ||
|
||
return asset | ||
} | ||
|
||
export function replyMessageAsset({ replyToId, replyMessage }) { | ||
return { | ||
replyto_id: replyToId, | ||
reply_message: replyMessage | ||
} | ||
} | ||
|
||
export function replyWithCryptoTransferAsset(replyToId, transferPayload) { | ||
return { | ||
replyto_id: replyToId, | ||
reply_message: cryptoTransferAsset(transferPayload) | ||
} | ||
} | ||
|
||
export function reactionAsset(reactToId, reactMessage) { | ||
return { | ||
reactto_id: reactToId, | ||
react_message: reactMessage | ||
} | ||
} | ||
|
||
export function signalAsset(deviceId, token, provider, action) { | ||
return { | ||
deviceId, | ||
token, | ||
provider, | ||
action | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,186 @@ | ||
import { Store } from 'vuex' | ||
|
||
import { Transactions } from '@/lib/constants' | ||
import { CryptoSymbol } from '@/lib/constants/cryptos' | ||
import { | ||
AccountDto, | ||
AnyTransaction, | ||
BaseTransaction, | ||
ChatMessageTransaction, | ||
ChatsApiGetChatroomMessagesRequest, | ||
ChatsApiGetChatRoomsRequest, | ||
CreateNewChatMessageResponseDto, | ||
GetAccountVotesResponseDto, | ||
GetBlocksResponseDto, | ||
GetDelegatesCountResponseDto, | ||
GetDelegatesResponseDto, | ||
GetDelegateStatsResponseDto, | ||
GetNextForgersResponseDto, | ||
GetTransactionsResponseDto, | ||
GetUnconfirmedTransactionsResponseDto, | ||
QueuedTransaction, | ||
RegisterAnyTransaction, | ||
RegisterChatMessageTransaction, | ||
RegisterKVSTransaction, | ||
RegisterNewDelegateTransaction, | ||
RegisterTokenTransferTransaction, | ||
RegisterVoteForDelegateTransaction, | ||
SetKVSResponseDto, | ||
TransactionsApiGetTransactionsRequest, | ||
TransferTokenResponseDto | ||
} from '@/lib/schema/client/api' | ||
import { RootState } from '@/store/types' | ||
|
||
export declare const TX_CHUNK_SIZE: number | ||
|
||
export type UnsignedNewTransaction = Pick< | ||
BaseTransaction, | ||
'type' | 'amount' | 'senderId' | 'senderPublicKey' | ||
> | ||
|
||
export type RegisterChatMessageTransactionUnsigned = Omit< | ||
RegisterChatMessageTransaction, | ||
'signature' | 'timestamp' | ||
> | ||
export type RegisterTokenTransferTransactionUnsigned = Omit< | ||
RegisterTokenTransferTransaction, | ||
'signature' | 'timestamp' | ||
> | ||
export type RegisterKVSTransactionUnsigned = Omit<RegisterKVSTransaction, 'signature' | 'timestamp'> | ||
export type RegisterVoteForDelegateTransactionUnsigned = Omit< | ||
RegisterVoteForDelegateTransaction, | ||
'signature' | 'timestamp' | ||
> | ||
export type RegisterNewDelegateTransactionUnsigned = Omit< | ||
RegisterNewDelegateTransaction, | ||
'signature' | 'timestamp' | ||
> | ||
|
||
export type RegisterAnyTransactionUnsigned = | ||
| RegisterChatMessageTransactionUnsigned | ||
| RegisterTokenTransferTransactionUnsigned | ||
| RegisterKVSTransactionUnsigned | ||
| RegisterVoteForDelegateTransactionUnsigned | ||
| RegisterNewDelegateTransactionUnsigned | ||
|
||
export function newTransaction(type: number): UnsignedNewTransaction | ||
|
||
export function signTransaction( | ||
transaction: RegisterAnyTransactionUnsigned, | ||
timeDelta: number | ||
): RegisterAnyTransaction | ||
|
||
export function unlock(passphrase: string): string | ||
|
||
export type CurrentAccount = Omit<AccountDto, 'balance' | 'unconfirmedBalance'> & { | ||
balance: number // string balance was normalized into ADM units | ||
unconfirmedBalance: number // string balance was normalized into ADM units | ||
} | ||
export function getCurrentAccount(): Promise<CurrentAccount> | ||
|
||
export function isReady(): boolean | ||
|
||
export function getPublicKey(address: string): Promise<string> | ||
|
||
export type SendMessageParams = { | ||
to: string // address | ||
message?: string | object | ||
type?: typeof Transactions.SEND | typeof Transactions.CHAT_MESSAGE | ||
amount?: number | ||
} | ||
export function sendMessage(params: SendMessageParams): Promise<CreateNewChatMessageResponseDto> | ||
|
||
export function sendSpecialMessage( | ||
to: string, | ||
message: SendMessageParams['message'] | ||
): ReturnType<typeof sendMessage> | ||
|
||
export function storeValue( | ||
key: string, | ||
value: string | object, | ||
encode?: boolean | ||
): Promise<SetKVSResponseDto> | ||
|
||
export function getStored(key: string, ownerAddress: string, records?: number): Promise<unknown> | ||
|
||
export function sendTokens(to: string, amount: number): Promise<TransferTokenResponseDto> | ||
export function getDelegates(limit: number, offset: number): Promise<GetDelegatesResponseDto> | ||
export function getDelegatesWithVotes(address: string): Promise<GetAccountVotesResponseDto> | ||
export function getDelegatesCount(): Promise<GetDelegatesCountResponseDto> | ||
export function checkUnconfirmedTransactions(): Promise<GetUnconfirmedTransactionsResponseDto> | ||
|
||
export function voteForDelegates(votes: string[]): Promise<RegisterVoteForDelegateTransaction> | ||
export function getNextForgers(): Promise<GetNextForgersResponseDto> | ||
export function getBlocks(): Promise<GetBlocksResponseDto> | ||
export function getForgedByAccount(): Promise<GetDelegateStatsResponseDto> | ||
|
||
export function storeCryptoAddress(crypto: CryptoSymbol, address: string): Promise<boolean> | ||
|
||
type GetTransactionsOptions = Pick< | ||
TransactionsApiGetTransactionsRequest, | ||
'minAmount' | 'toHeight' | 'fromHeight' | 'type' | 'orderBy' | ||
> | ||
export function getTransactions( | ||
options: GetTransactionsOptions | ||
): Promise<GetTransactionsResponseDto> | ||
|
||
export function getTransaction( | ||
id: string, | ||
returnAsset?: 0 | 1 | ||
): Promise<AnyTransaction | QueuedTransaction | null> | ||
|
||
export function getChats( | ||
from?: number, | ||
offset?: number, | ||
orderBy?: 'asc' | 'desc' | ||
): Promise<{ | ||
count: number | ||
transactions: Array<DecodedChatMessageTransaction> | ||
}> | ||
|
||
type DecodedChatMessageTransaction = ChatMessageTransaction & { | ||
message: string | object | ||
i18n: boolean | ||
} | ||
|
||
export function decodeChat( | ||
transaction: ChatMessageTransaction, | ||
key: string | ||
): DecodedChatMessageTransaction | ||
|
||
export function decodeTransaction( | ||
transaction: AnyTransaction | QueuedTransaction, | ||
address: string | ||
): DecodedChatMessageTransaction | ||
|
||
export function getI18nMessage(message: string, senderId: string): string | ||
|
||
export function loginOrRegister(): Promise<ReturnType<typeof getCurrentAccount>> | ||
|
||
export type CurrentAccountWithPassphrase = CurrentAccount & { | ||
passphrase: string | ||
} | ||
|
||
export function loginViaPassword( | ||
password: string, | ||
store: Store<RootState> | ||
): Promise<CurrentAccountWithPassphrase> | ||
|
||
type GetChatRoomsParams = Pick<ChatsApiGetChatRoomsRequest, 'offset' | 'limit' | 'orderBy'> | ||
|
||
export function getChatRooms( | ||
address: string, | ||
params: GetChatRoomsParams | ||
): Promise<Array<ReturnType<typeof decodeChat>>> | ||
|
||
type GetChatRoomMessagesParams = Pick< | ||
ChatsApiGetChatroomMessagesRequest, | ||
'offset' | 'limit' | 'orderBy' | ||
> | ||
|
||
export function getChatRoomMessages( | ||
address1: string, | ||
address2: string, | ||
params: GetChatRoomMessagesParams, | ||
recursive: boolean = false | ||
): Promise<Array<ReturnType<typeof decodeChat>>> |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
adamant-api
files should not be in /public dir. Did you accidentally copy them while resolving the conflicts? @NikIvvThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
However, the conflicts are still not resolved. Please fix it.