# SPK Network Client Side Package We're looking for a better name than spk-js. Let us know if you have any suggestions. It should generally serve the same purpose as hive-js or dhive as an allegory. In meat space it would be closest to an advocate: breaking down complex rules and requirements into simple documents the the end user can sign to manage their affairs.  ## Account Management The code to deconstruct accounts has been set up and the code for using Hive Keychain to sign has also been set up. There is a function that allows you (the developer) to BYO Signing mechanism to support the many multitude of ways to get your users to sign and broadcast transactions. `<script type="module" src="/js/spk-js.js"></script>` Is the only thing on the window currently, this module returns a default export so it's named whatever you name your script. in this case spk-js => spkJs ## Sign / Broadcast You can specify equivalent functions as below, taking a three part [account, op/buffer, key_choice] argument and returning the broadcast txid or signature. ```js sign: function (op) { return new Promise((res, rej) => { window.hive_keychain.requestSignBuffer( op[0], `${op[0]}:${op[1]}`, op[2], (sig) => { if (sig.error) rej(sig); else res(sig.result); } ); }); } ``` `spkJs.api.setSignFunction(newFunc)` ``` broadcast: function (op) { return new Promise((resolve, reject) => { if (window.hive_keychain) { if(typeof op[1] == "string") op[1] = JSON.parse(op[1]) try { window.hive_keychain.requestBroadcast( op[0], op[1], op[2], function (response) { resolve(response); } ); } catch (e) { reject(e); } } else { reject({ error: "Hive Keychain is not installed." }); } }); }, ``` `spkJs.api.setBroadcastFunction(newFunc)` So, for example: ``` function newFunc (op){ return promise if(user_opt.hive_keychain){ forward_toHKC(op).then resolve return } else if (user_opt.hive_auth){ forwardtoHive_Auth(op).then resolve return } //etc } ``` ## Account Constructor You can: `spkJs.account.setAccount('dlux-io')` Which returns a promise. It consumes the getAccount and getStats API, and uses a few helpers to construct meaningful account data: ``` balance: 122548 behind: 1 broca: "2605365,4Uc4d" broca_now: 2611261 channels: {} claim: 0 contracts: [] down: {} drop: {availible: {…}, last_claim: 0, total_claims: 0} file_contracts: {} gov: 0 gov_downs: {} granted: {} granting: {} head_block: 75245832 heldCollateral: 0 node: "spk-test" power_downs: {} poweredUp: 0 pubKey: "STM765pPE6tnKYqEr2Y4khRhZwauoZMyQSs1CvXhgLGtgMhuVxY53" spk: 0 spk_block: 73431764 spk_power: 2850 spk_vote: {} storage: "12D3KooWMJQEzggotBCznPM1cVohMQx2puLuKTgLU8z9SzKLG6fa" tick: "0.015000" up: {} ``` This includes pending upload contracts, finalized upload contracts, current balances, power down information, the current price of larynx, (the price of spk will be included in the future), the validators you vote for, etc. Things like `broca: "2605365,4Uc4d" ` have been deconstructed into live `broca_now: 2611261`... which should be easier for a developer to plug directly into the UI. ## File Still porting the vue.dlux.io implementation. Missing is a generalized way to petition for a contract from a provider list, or building your own contract. This is informing some work on SPK Network APIs as well. What is written is selecting an existing contract, dynamically setting the upload API address, and the client side code to handle resumable uploads. The functions should perform the following: * Build a Storage Contract * Choose IPFS upload agent * Get a list of API to contact to get a storage contract, with the terms of each contract * Attach fileReader logic to a file input element * Set the user up to sign their file choice * Trigger the upload process * Perform management functions for the files These functions are all written on our test front end and generalizing them hopefully to work within this self-contained file has been... fun. Hoping to get this out to you all very soon.
author | disregardfiat |
---|---|
permlink | spk-client-side-package |
category | spk |
json_metadata | "{"app":"peakd/2023.5.1","format":"markdown","description":"Further Progress on spk network client side package","tags":["spk","dlux","dev"],"users":[],"image":["https://files.peakd.com/file/peakd-hive/disregardfiat/AJkRoL2K7hVzpMdtyPDSMMPodVX37BqhtUmjswzxVH6gWq68k3ChjmzW9zMKE2f.png"]}" |
created | 2023-05-27 22:22:15 |
last_update | 2023-05-27 22:22:15 |
depth | 0 |
children | 2 |
last_payout | 2023-06-03 22:22:15 |
cashout_time | 1969-12-31 23:59:59 |
total_payout_value | 9.382 HBD |
curator_payout_value | 9.367 HBD |
pending_payout_value | 0.000 HBD |
promoted | 0.000 HBD |
body_length | 4,413 |
author_reputation | 345,191,366,639,512 |
root_title | "SPK Client Side Package" |
beneficiaries | [] |
max_accepted_payout | 1,000,000.000 HBD |
percent_hbd | 10,000 |
post_id | 123,899,714 |
net_rshares | 40,646,748,426,393 |
author_curate_reward | "" |
voter | weight | wgt% | rshares | pct | time |
---|---|---|---|---|---|
kendewitt | 0 | 417,192,535,925 | 100% | ||
arcange | 0 | 1,062,271,595,291 | 5% | ||
disregardfiat | 0 | 800,410,078,946 | 100% | ||
ancolie | 0 | 1,347,315,793 | 1.13% | ||
walterjay | 0 | 17,491,150,170 | 1.62% | ||
v4vapid | 0 | 5,118,338,508,643 | 33% | ||
steemitboard | 0 | 23,285,236,056 | 5% | ||
diggndeeper.com | 0 | 6,211,984,220,179 | 100% | ||
humoalex | 0 | 1,041,459,133 | 100% | ||
preparedwombat | 0 | 338,035,583,521 | 30% | ||
dune69 | 0 | 19,714,842,984 | 100% | ||
josequintana | 0 | 5,436,348,669 | 100% | ||
iansart | 0 | 205,313,279,068 | 50% | ||
uruiamme | 0 | 6,459,856,643 | 60% | ||
newsflash | 0 | 27,667,669,872 | 8.25% | ||
ambar | 0 | 1,267,833,019 | 100% | ||
joeyarnoldvn | 0 | 587,679,364 | 1.76% | ||
unyimeetuk | 0 | 1,189,621,117 | 50% | ||
drorion | 0 | 416,567,426,203 | 45% | ||
twoitguys | 0 | 7,069,220,369 | 50% | ||
aidefr | 0 | 511,116,596 | 2.6% | ||
taskmaster4450 | 0 | 2,652,566,178,725 | 100% | ||
fatman | 0 | 9,008,745,117 | 2% | ||
b00m | 0 | 776,594,041 | 5% | ||
robotics101 | 0 | 899,058,680 | 3.25% | ||
vempromundo | 0 | 4,540,778,420 | 100% | ||
californiacrypto | 0 | 868,885,519 | 50% | ||
edicted | 0 | 7,506,902,337,039 | 100% | ||
nathansenn | 0 | 13,745,024,278 | 50% | ||
erikah | 0 | 235,502,334,672 | 10% | ||
manniman | 0 | 421,348,749,392 | 100% | ||
franciscopr | 0 | 16,144,543,265 | 100% | ||
racibo | 0 | 1,804,687,999 | 5% | ||
m2nnari | 0 | 2,529,930,904 | 100% | ||
tsnaks | 0 | 24,914,288,606 | 100% | ||
achimmertens | 0 | 1,618,899,001 | 2.5% | ||
we-are | 0 | 21,911,493,505 | 100% | ||
dlux-io | 0 | 1,584,325,007,906 | 100% | ||
fw206 | 0 | 3,549,375,112,482 | 70% | ||
techcoderx | 0 | 65,839,905,128 | 100% | ||
steem-tube | 0 | 6,795,472,264 | 100% | ||
spamfarmer | 0 | 871,323,425 | 10% | ||
the.rocket.panda | 0 | 10,712,555,220 | 100% | ||
ua-promoter | 0 | 2,491,636,483,646 | 50% | ||
digital.mine | 0 | 55,302,217,216 | 60% | ||
smartvote | 0 | 66,623,506,968 | 2.6% | ||
pboulet | 0 | 4,009,116,240 | 2.6% | ||
chrisrice | 0 | 3,660,978,500 | 50% | ||
piensocrates | 0 | 11,219,497,402 | 100% | ||
pocketjs | 0 | 12,134,374 | 7.73% | ||
bluerobo | 0 | 383,871,906,620 | 100% | ||
shainemata | 0 | 11,899,535,971 | 5% | ||
primeradue | 0 | 522,145,320 | 33% | ||
anonsteve | 0 | 36,741,162,256 | 50% | ||
steemitmonsters | 0 | 1,026,097,156 | 100% | ||
javiersebastian | 0 | 6,279,778,700 | 100% | ||
philnews.xyz | 0 | 1,027,937,921 | 50% | ||
tiffin | 0 | 15,378,779,600 | 100% | ||
shtup | 0 | 157,733,086,741 | 50% | ||
therealyme | 0 | 543,509,989,600 | 15% | ||
hive-120257 | 0 | 911,250,259 | 50% | ||
gloriaolar | 0 | 30,110,517,229 | 30% | ||
mehmetfix | 0 | 641,545,347 | 15% | ||
blue-witness | 0 | 988,265,979 | 100% | ||
laruche | 0 | 140,312,632,312 | 3.25% | ||
dbuzz | 0 | 470,156,978,132 | 100% | ||
danishcrypto | 0 | 758,458,919 | 15% | ||
ykroys | 0 | 1,506,920,329 | 100% | ||
elricmoonslayer | 0 | 1,303,005,755 | 50% | ||
rohansuares | 0 | 10,300,979,347 | 100% | ||
rbhayes | 0 | 9,856,681,512 | 50% | ||
specific | 0 | 185,880,538,225 | 50% | ||
trostparadox | 0 | 4,171,478,664,874 | 100% | ||
firinmahlazer | 0 | 492,583,857 | 100% | ||
xyba | 0 | 48,870,074,506 | 100% | ||
todkrank | 0 | 986,905,301 | 50% | ||
primalamusica | 0 | 286,252,887,521 | 50% | ||
rpren | 0 | 722,326,009 | 50% | ||
lordb | 0 | 20,981,535,778 | 100% | ||
dubble | 0 | 47,403,143,268 | 100% | ||
pishio | 0 | 544,535,584,046 | 10% | ||
magnacarta.buzz | 0 | 2,018,428,327 | 50% | ||
michupa | 0 | 2,701,010,874 | 2.5% | ||
meveronicas | 0 | 44,509,525,826 | 100% | ||
rafzat | 0 | 6,382,459,105 | 100% | ||
loving-kindness | 0 | 2,118,072,880 | 50% | ||
zehn34 | 0 | 520,207,349 | 50% | ||
daniellef | 0 | 2,211,994,661 | 100% | ||
gunting | 0 | 852,681,884 | 50% | ||
rokasimir | 0 | 909,661,969 | 100% | ||
i-test-stuff | 0 | 3,434,067,633 | 100% |
spkd (?)
author | crrdlx |
---|---|
permlink | re-disregardfiat-rvdsk8 |
category | spk |
json_metadata | {"tags":["spk"],"app":"peakd/2023.5.1"} |
created | 2023-05-28 18:26:33 |
last_update | 2023-05-28 18:26:33 |
depth | 1 |
children | 0 |
last_payout | 2023-06-04 18:26:33 |
cashout_time | 1969-12-31 23:59:59 |
total_payout_value | 0.000 HBD |
curator_payout_value | 0.000 HBD |
pending_payout_value | 0.000 HBD |
promoted | 0.000 HBD |
body_length | 8 |
author_reputation | 66,353,892,476,578 |
root_title | "SPK Client Side Package" |
beneficiaries | [] |
max_accepted_payout | 1,000,000.000 HBD |
percent_hbd | 10,000 |
post_id | 123,925,961 |
net_rshares | 0 |
This seem to be a very good one Thumbs up!!
author | rafzat |
---|---|
permlink | rvdfqw |
category | spk |
json_metadata | {"app":"hiveblog/0.1"} |
created | 2023-05-28 13:50:30 |
last_update | 2023-05-28 13:50:30 |
depth | 1 |
children | 0 |
last_payout | 2023-06-04 13:50:30 |
cashout_time | 1969-12-31 23:59:59 |
total_payout_value | 0.000 HBD |
curator_payout_value | 0.000 HBD |
pending_payout_value | 0.000 HBD |
promoted | 0.000 HBD |
body_length | 43 |
author_reputation | 183,560,271,702,716 |
root_title | "SPK Client Side Package" |
beneficiaries | [] |
max_accepted_payout | 1,000,000.000 HBD |
percent_hbd | 10,000 |
post_id | 123,917,149 |
net_rshares | 0 |