forked from Qortal/qortal-ui
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
38 lines
1.2 KiB
38 lines
1.2 KiB
import { transactionTypes as transactions } from './transactions/transactions.js' |
|
import Base58 from './deps/Base58.js' |
|
import { request } from './fetch-request' |
|
import signChat from './transactions/chat/signChat.js' |
|
import signArbitrary from './transactions/arbitrary/signArbitrary.js' |
|
|
|
|
|
export const createTransaction = (type, keyPair, params) => { |
|
const tx = new transactions[type]() |
|
tx.keyPair = keyPair |
|
Object.keys(params).forEach(param => { |
|
tx[param] = params[param] |
|
}) |
|
|
|
return tx |
|
} |
|
|
|
// Compute Chat Nonce |
|
export const computeChatNonce = bytes => request('/chat/compute', { |
|
method: 'POST', |
|
body: Base58.encode(bytes) |
|
}) |
|
|
|
// Sign Chat Transactions |
|
export const signChatTransaction = (chatBytes, nonce, keyPair) => { |
|
return signChat(chatBytes, nonce, keyPair) |
|
} |
|
|
|
// Sign Arbitrary Transactions |
|
export const signArbitraryTransaction = (arbitraryBytesBase58, arbitraryBytesForSigningBase58, nonce, keyPair) => { |
|
return signArbitrary(arbitraryBytesBase58, arbitraryBytesForSigningBase58, nonce, keyPair) |
|
} |
|
|
|
// Process Transactions |
|
export const processTransaction = bytes => request('/transactions/process', { |
|
method: 'POST', |
|
body: Base58.encode(bytes) |
|
})
|
|
|