mirror of https://github.com/qortal/qortal-ui
Browse Source
# Conflicts: # qortal-ui-plugins/plugins/core/qdn/browser/browser.src.js # qortal-ui-plugins/plugins/utils/publish-image.jspull/137/head
CalDescent
2 years ago
16 changed files with 2084 additions and 555 deletions
@ -1,5 +1,5 @@
|
||||
export { request } from './fetch-request.js' |
||||
export { transactionTypes as transactions } from './transactions/transactions.js' |
||||
export { processTransaction, createTransaction, computeChatNonce, signChatTransaction, signArbitraryTransaction } from './createTransaction.js' |
||||
export { processTransaction, processTransactionVersion2, createTransaction, computeChatNonce, signChatTransaction, signArbitraryTransaction } from './createTransaction.js' |
||||
export { tradeBotCreateRequest, tradeBotRespondRequest, signTradeBotTxn, deleteTradeOffer, sendBtc, sendLtc, sendDoge, sendDgb, sendRvn, sendArrr } from './tradeRequest.js' |
||||
export { cancelAllOffers } from './transactions/trade-portal/tradeoffer/cancelAllOffers.js' |
||||
|
@ -0,0 +1,91 @@
|
||||
'use strict' |
||||
import TransactionBase from './TransactionBase.js' |
||||
import { store } from '../../api.js' |
||||
|
||||
export default class DeployAtTransaction extends TransactionBase { |
||||
constructor() { |
||||
super() |
||||
this.type = 16 |
||||
} |
||||
|
||||
render(html) { |
||||
return html` |
||||
${this._groupdialog5} |
||||
<div style="background: #eee; padding: 8px; margin: 8px 0; border-radius: 5px;"> |
||||
<div>${this._atDeployDialog1}: <span style="color: #000;">${this._rName}</span></div> |
||||
<br> |
||||
<div>${this.atDeployDialog2}: <span style="color: #000;">${this._rDescription}</span></div> |
||||
<br> |
||||
</div> |
||||
</div> |
||||
${this._groupdialog6} |
||||
` |
||||
} |
||||
|
||||
set atDeployDialog1(atDeployDialog1) { |
||||
this._atDeployDialog1 = atDeployDialog1 |
||||
} |
||||
set atDeployDialog2(atDeployDialog2) { |
||||
this._atDeployDialog2 = atDeployDialog2 |
||||
} |
||||
|
||||
set fee(fee) { |
||||
this._fee = fee |
||||
this._feeBytes = this.constructor.utils.int64ToBytes(this._fee) |
||||
} |
||||
set rAmount(rAmount) { |
||||
this._rAmount = Math.round(rAmount * store.getState().config.coin.decimals) |
||||
this._rAmountBytes = this.constructor.utils.int64ToBytes(this._rAmount) |
||||
} |
||||
|
||||
set rName(rName) { |
||||
this._rName = rName |
||||
this._rNameBytes = this.constructor.utils.stringtoUTF8Array(this._rName.toLocaleLowerCase()) |
||||
this._rNameLength = this.constructor.utils.int32ToBytes(this._rNameBytes.length) |
||||
} |
||||
|
||||
set rDescription(rDescription) { |
||||
this._rDescription = rDescription |
||||
this._rDescriptionBytes = this.constructor.utils.stringtoUTF8Array(this._rDescription.toLocaleLowerCase()) |
||||
this._rDescriptionLength = this.constructor.utils.int32ToBytes(this._rDescriptionBytes.length) |
||||
} |
||||
set atType(atType) { |
||||
this._atType = atType |
||||
this._atTypeBytes = this.constructor.utils.stringtoUTF8Array(this._atType) |
||||
this._atTypeLength = this.constructor.utils.int32ToBytes(this._atTypeBytes.length) |
||||
} |
||||
set rTags(rTags) { |
||||
this._rTags = rTags |
||||
this._rTagsBytes = this.constructor.utils.stringtoUTF8Array(this._rTags.toLocaleLowerCase()) |
||||
this._rTagsLength = this.constructor.utils.int32ToBytes(this._rTagsBytes.length) |
||||
} |
||||
set rCreationBytes(rCreationBytes) { |
||||
const decode = this.constructor.Base58.decode(rCreationBytes) |
||||
this._rCreationBytes = this.constructor.utils.stringtoUTF8Array(decode) |
||||
this._rCreationBytesLength = this.constructor.utils.int32ToBytes(this._rCreationBytes.length) |
||||
} |
||||
set rAssetId(rAssetId) { |
||||
this._rAssetId = this.constructor.utils.int64ToBytes(rAssetId) |
||||
} |
||||
|
||||
|
||||
get params() { |
||||
const params = super.params |
||||
params.push( |
||||
this._rNameLength, |
||||
this._rNameBytes, |
||||
this._rDescriptionLength, |
||||
this._rDescriptionBytes, |
||||
this._atTypeLength, |
||||
this._atTypeBytes, |
||||
this._rTagsLength, |
||||
this._rTagsBytes, |
||||
this._rCreationBytesLength, |
||||
this._rCreationBytes, |
||||
this._rAmountBytes, |
||||
this._rAssetId, |
||||
this._feeBytes |
||||
) |
||||
return params |
||||
} |
||||
} |
@ -0,0 +1,26 @@
|
||||
// GET_USER_ACCOUNT action
|
||||
export const GET_USER_ACCOUNT = 'GET_USER_ACCOUNT'; |
||||
|
||||
// LINK_TO_QDN_RESOURCE action
|
||||
export const LINK_TO_QDN_RESOURCE = 'LINK_TO_QDN_RESOURCE'; |
||||
|
||||
// QDN_RESOURCE_DISPLAYED action
|
||||
export const QDN_RESOURCE_DISPLAYED = 'QDN_RESOURCE_DISPLAYED'; |
||||
|
||||
// PUBLISH_QDN_RESOURCE action
|
||||
export const PUBLISH_QDN_RESOURCE = 'PUBLISH_QDN_RESOURCE'; |
||||
|
||||
// SEND_CHAT_MESSAGE action
|
||||
export const SEND_CHAT_MESSAGE = 'SEND_CHAT_MESSAGE'; |
||||
|
||||
// JOIN_GROUP action
|
||||
export const JOIN_GROUP = 'JOIN_GROUP'; |
||||
|
||||
// DEPLOY_AT action
|
||||
export const DEPLOY_AT = 'DEPLOY_AT'; |
||||
|
||||
// GET_WALLET_BALANCE action
|
||||
export const GET_WALLET_BALANCE = 'GET_WALLET_BALANCE'; |
||||
|
||||
// SEND_COIN action
|
||||
export const SEND_COIN = 'SEND_COIN'; |
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,82 @@
|
||||
import { Sha256 } from 'asmcrypto.js' |
||||
|
||||
|
||||
function sbrk(size, heap){ |
||||
let brk = 512 * 1024 // stack top
|
||||
let old = brk |
||||
brk += size |
||||
|
||||
if (brk > heap.length) |
||||
throw new Error('heap exhausted') |
||||
|
||||
return old |
||||
} |
||||
|
||||
|
||||
|
||||
self.addEventListener('message', async e => { |
||||
const response = await computePow(e.data.chatBytes, e.data.path, e.data.difficulty) |
||||
postMessage(response) |
||||
|
||||
}) |
||||
|
||||
|
||||
const memory = new WebAssembly.Memory({ initial: 256, maximum: 256 }) |
||||
const heap = new Uint8Array(memory.buffer) |
||||
|
||||
|
||||
|
||||
const computePow = async (chatBytes, path, difficulty) => { |
||||
|
||||
let response = null |
||||
|
||||
await new Promise((resolve, reject)=> { |
||||
|
||||
const _chatBytesArray = Object.keys(chatBytes).map(function (key) { return chatBytes[key]; }); |
||||
const chatBytesArray = new Uint8Array(_chatBytesArray); |
||||
const chatBytesHash = new Sha256().process(chatBytesArray).finish().result; |
||||
const hashPtr = sbrk(32, heap); |
||||
const hashAry = new Uint8Array(memory.buffer, hashPtr, 32); |
||||
hashAry.set(chatBytesHash); |
||||
|
||||
|
||||
const workBufferLength = 8 * 1024 * 1024; |
||||
const workBufferPtr = sbrk(workBufferLength, heap); |
||||
|
||||
|
||||
|
||||
const importObject = { |
||||
env: { |
||||
memory: memory |
||||
}, |
||||
}; |
||||
|
||||
function loadWebAssembly(filename, imports) { |
||||
// Fetch the file and compile it
|
||||
return fetch(filename) |
||||
.then(response => response.arrayBuffer()) |
||||
.then(buffer => WebAssembly.compile(buffer)) |
||||
.then(module => { |
||||
|
||||
// Create the instance.
|
||||
return new WebAssembly.Instance(module, importObject); |
||||
}); |
||||
} |
||||
|
||||
|
||||
loadWebAssembly(path) |
||||
.then(wasmModule => { |
||||
response = { |
||||
nonce : wasmModule.exports.compute2(hashPtr, workBufferPtr, workBufferLength, difficulty), |
||||
chatBytesArray |
||||
} |
||||
|
||||
resolve() |
||||
|
||||
}); |
||||
|
||||
|
||||
})
|
||||
|
||||
return response |
||||
} |
@ -0,0 +1,92 @@
|
||||
import { Sha256 } from 'asmcrypto.js' |
||||
|
||||
|
||||
|
||||
function sbrk(size, heap){ |
||||
let brk = 512 * 1024 // stack top
|
||||
let old = brk |
||||
brk += size |
||||
|
||||
if (brk > heap.length) |
||||
throw new Error('heap exhausted') |
||||
|
||||
return old |
||||
} |
||||
|
||||
|
||||
|
||||
|
||||
self.addEventListener('message', async e => { |
||||
const response = await computePow(e.data.convertedBytes, e.data.path) |
||||
postMessage(response) |
||||
|
||||
}) |
||||
|
||||
|
||||
const memory = new WebAssembly.Memory({ initial: 256, maximum: 256 }) |
||||
const heap = new Uint8Array(memory.buffer) |
||||
|
||||
|
||||
|
||||
const computePow = async (convertedBytes, path) => { |
||||
|
||||
|
||||
let response = null |
||||
|
||||
await new Promise((resolve, reject)=> { |
||||
|
||||
const _convertedBytesArray = Object.keys(convertedBytes).map( |
||||
function (key) { |
||||
return convertedBytes[key] |
||||
} |
||||
) |
||||
const convertedBytesArray = new Uint8Array(_convertedBytesArray) |
||||
const convertedBytesHash = new Sha256() |
||||
.process(convertedBytesArray) |
||||
.finish().result |
||||
const hashPtr = sbrk(32, heap) |
||||
const hashAry = new Uint8Array( |
||||
memory.buffer, |
||||
hashPtr, |
||||
32 |
||||
) |
||||
|
||||
hashAry.set(convertedBytesHash) |
||||
const difficulty = 14 |
||||
const workBufferLength = 8 * 1024 * 1024 |
||||
const workBufferPtr = sbrk( |
||||
workBufferLength, |
||||
heap |
||||
) |
||||
|
||||
const importObject = { |
||||
env: { |
||||
memory: memory |
||||
}, |
||||
}; |
||||
|
||||
function loadWebAssembly(filename, imports) { |
||||
return fetch(filename) |
||||
.then(response => response.arrayBuffer()) |
||||
.then(buffer => WebAssembly.compile(buffer)) |
||||
.then(module => { |
||||
return new WebAssembly.Instance(module, importObject); |
||||
}); |
||||
} |
||||
|
||||
|
||||
loadWebAssembly(path) |
||||
.then(wasmModule => { |
||||
response = { |
||||
nonce : wasmModule.exports.compute2(hashPtr, workBufferPtr, workBufferLength, difficulty), |
||||
|
||||
} |
||||
resolve() |
||||
|
||||
}); |
||||
|
||||
|
||||
})
|
||||
|
||||
return response |
||||
} |
@ -0,0 +1,52 @@
|
||||
export class Loader { |
||||
constructor() { |
||||
this.loader = document.createElement("div"); |
||||
this.loader.className = "loader"; |
||||
this.loader.innerHTML = ` |
||||
<div class="loader-spinner"></div> |
||||
`;
|
||||
this.styles = document.createElement("style"); |
||||
this.styles.innerHTML = ` |
||||
.loader { |
||||
position: fixed; |
||||
top: 0; |
||||
left: 0; |
||||
right: 0; |
||||
bottom: 0; |
||||
background-color: rgba(0, 0, 0, 0.5); |
||||
display: flex; |
||||
justify-content: center; |
||||
align-items: center; |
||||
z-index: 1000001 |
||||
} |
||||
|
||||
.loader-spinner { |
||||
border: 4px solid #f3f3f3; |
||||
border-top: 4px solid #3498db; |
||||
border-radius: 50%; |
||||
width: 32px; |
||||
height: 32px; |
||||
animation: spin 1s linear infinite; |
||||
} |
||||
|
||||
@keyframes spin { |
||||
from { transform: rotate(0deg); } |
||||
to { transform: rotate(360deg); } |
||||
} |
||||
`;
|
||||
} |
||||
|
||||
show() { |
||||
document.head.appendChild(this.styles); |
||||
document.body.appendChild(this.loader); |
||||
} |
||||
|
||||
hide() { |
||||
if (this.loader.parentNode) { |
||||
this.loader.parentNode.removeChild(this.loader); |
||||
} |
||||
if (this.styles.parentNode) { |
||||
this.styles.parentNode.removeChild(this.styles); |
||||
} |
||||
} |
||||
} |
Loading…
Reference in new issue