@quantovainc/qcore 0.1.27 → 0.1.29
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +31 -2
- package/package.json +1 -1
- package/pkg/package.json +1 -1
- package/pkg-node/package.json +1 -1
- package/shared.js +1 -1
package/README.md
CHANGED
|
@@ -18,6 +18,8 @@ npm install @quantovainc/qcore
|
|
|
18
18
|
```js
|
|
19
19
|
const { Client, core, generateSeed } = require('@quantovainc/qcore');
|
|
20
20
|
|
|
21
|
+
const GATEWAY = 'https://rpc-testnet.quantova.org';
|
|
22
|
+
|
|
21
23
|
async function main() {
|
|
22
24
|
// Create an account. The seed is the only backup and it never leaves the device.
|
|
23
25
|
const seed = generateSeed();
|
|
@@ -28,12 +30,39 @@ async function main() {
|
|
|
28
30
|
const to = core.address(seed, 1n);
|
|
29
31
|
console.log('from', from);
|
|
30
32
|
|
|
31
|
-
// Open a client against a node you trust.
|
|
32
|
-
|
|
33
|
+
// Open a client against a node you trust. The address above is the public testnet
|
|
34
|
+
// gateway. A remote gateway must be https, plaintext http is allowed only to a loopback node.
|
|
35
|
+
const client = new Client(GATEWAY);
|
|
33
36
|
|
|
34
37
|
// A fixed ceiling your app is willing to pay in fees, chosen here and never read back from the gateway.
|
|
35
38
|
const MAX_FEE_QUON = '2000';
|
|
36
39
|
|
|
40
|
+
// A new account holds nothing, so take testnet funds before anything else.
|
|
41
|
+
// The faucet sends 10, 50 or 100 TQTOV to one address at a time.
|
|
42
|
+
await fetch(GATEWAY + '/faucet/api/claim', {
|
|
43
|
+
method: 'POST',
|
|
44
|
+
headers: { 'content-type': 'application/json' },
|
|
45
|
+
body: JSON.stringify({ address: from, amount: 10 }),
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
// The faucet pays you with a transaction, so wait for the balance to arrive before spending it.
|
|
49
|
+
for (let i = 0; i < 40; i += 1) {
|
|
50
|
+
const funded = await client.account(from).catch(() => null);
|
|
51
|
+
if (funded && BigInt(funded.balance || 0) > 0n) break;
|
|
52
|
+
await new Promise((wake) => setTimeout(wake, 1500));
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
// An account publishes its key once before it is allowed to send. This happens a single
|
|
56
|
+
// time for each account and it pays a fee like any other transaction.
|
|
57
|
+
await client.register(seed, 0, MAX_FEE_QUON);
|
|
58
|
+
|
|
59
|
+
// Registration is itself a transaction, so wait for the key to be on chain.
|
|
60
|
+
for (let i = 0; i < 30; i += 1) {
|
|
61
|
+
const ready = await client.account(from).catch(() => null);
|
|
62
|
+
if (ready && ready.has_key) break;
|
|
63
|
+
await new Promise((wake) => setTimeout(wake, 1500));
|
|
64
|
+
}
|
|
65
|
+
|
|
37
66
|
// Amounts and the ceiling are decimal strings or BigInt values, never JavaScript numbers.
|
|
38
67
|
const { signed, outcome } = await client.transfer(seed, 0, to, '1000', MAX_FEE_QUON);
|
|
39
68
|
console.log('submitted', signed.tx_id, outcome.verdict);
|
package/package.json
CHANGED
package/pkg/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "qcore-js",
|
|
3
3
|
"type": "module",
|
|
4
4
|
"description": "The JavaScript binding for the Quantova client core, generated over QCore with wasm-bindgen. The core does the key derivation, the post quantum signing, and the wire, the page does the fetch.",
|
|
5
|
-
"version": "0.1.
|
|
5
|
+
"version": "0.1.29",
|
|
6
6
|
"license": "Apache-2.0 OR MIT",
|
|
7
7
|
"repository": {
|
|
8
8
|
"type": "git",
|
package/pkg-node/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "qcore-js",
|
|
3
3
|
"description": "The JavaScript binding for the Quantova client core, generated over QCore with wasm-bindgen. The core does the key derivation, the post quantum signing, and the wire, the page does the fetch.",
|
|
4
|
-
"version": "0.1.
|
|
4
|
+
"version": "0.1.29",
|
|
5
5
|
"license": "Apache-2.0 OR MIT",
|
|
6
6
|
"repository": {
|
|
7
7
|
"type": "git",
|
package/shared.js
CHANGED