Skip to content

Commit 0a705e2

Browse files
author
Jakub Ner
committed
[1] Update demo to ledgers.js 4.0.0
[2] document usage of tokens [3] update links for overhide.io
1 parent 24fc037 commit 0a705e2

File tree

8 files changed

+2424
-72917
lines changed

8 files changed

+2424
-72917
lines changed

README.md

Lines changed: 37 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ This [demo](https://overhide.github.io/ledgers.js-demo/demo/login.html) ([source
4646
The respective API instances used by the [demo](https://overhide.github.io/ledgers.js-demo/demo/login.html) are the following test network nodes:
4747

4848
* ether: [*overhide* Remuneration API for Ethereum](https://rinkeby.ethereum.overhide.io/swagger.html)
49-
* dollars: [*overhide-ledger*--the renmuneration provider for US dollars](https://test.ohledger.com/swagger.html)
49+
* dollars: [*overhide-ledger*--the renmuneration provider for US dollars](https://test.ledger.overhide.io/swagger.html)
5050

5151
Use a [Rinkeby](https://faucet.rinkeby.io/) faucet to get "test" Ether for playing around with Ethereum in the [demo](https://overhide.github.io/ledgers.js-demo/demo/login.html) ([source](https://github.com/overhide/ledgers.js/blob/master/demo/login.html)).
5252

@@ -147,11 +147,27 @@ We need it in the front-end to tell the user what our prices for each tier are.
147147

148148
We need it in the service to know what payment amounts constitute authorizations to which tier.
149149

150+
**( o_o) Take note of the `"[...] (login.html) :: successfuly retrieved token : {"` trace.**
151+
152+
The [ledgers.js library requires an authorization token](https://overhide.io//2021/03/21/tokens.html).
153+
154+
The asynchronous token retrieval starts earlier with the trace:
155+
156+
```
157+
[...] (login.html) :: retrieving token on load : {
158+
```
159+
160+
Once it's available, it's provided to the library:
161+
162+
```
163+
oh$.enable(token);
164+
```
165+
150166
**( o_o) Take note of the `"appAddress": "0x046c88317b23dc57F6945Bf4140140f73c8FC80F"`.**
151167

152168
All the ledgers enumerated in our *payment schedule* list the application as having the address *0x046c88317b23dc57F6945Bf4140140f73c8FC80F*.
153169

154-
This is the application's Ethereum address on the [rinkeby testnet](https://rinkeby.etherscan.io/address/0x046c88317b23dc57f6945bf4140140f73c8fc80f) and on the [test *overhide-ledger*](https://test.ohledger.com/).
170+
This is the application's Ethereum address on the [rinkeby testnet](https://rinkeby.etherscan.io/address/0x046c88317b23dc57f6945bf4140140f73c8fc80f) and on the [test *overhide-ledger*](https://test.ledger.overhide.io/).
155171

156172
This is the address receiving (make-pretend) payments from the game's players.
157173

@@ -223,7 +239,7 @@ Our clicking of the "Generate" button caused the `ui.onGenerate` callback to run
223239

224240
The logging pane shows the UI's *onGenerate* function where our first interaction with the [*ledgers.js*](https://overhide.github.io/ledgers.js/ledgers.js-rendered-docs/index.html) occurs.
225241

226-
We see `ui.onGenerate` call [oh$.generateCredentials](https://overhide.github.io/ledgers.js/ledgers.js-rendered-docs/index.html#generatecredentials), passing in the "ohledger" imparter tag, indicating the [ledger](https://test.ohledger.com/swagger.html) we're working with.
242+
We see `ui.onGenerate` call [oh$.generateCredentials](https://overhide.github.io/ledgers.js/ledgers.js-rendered-docs/index.html#generatecredentials), passing in the "ohledger" imparter tag, indicating the [ledger](https://test.ledger.overhide.io/swagger.html) we're working with.
227243

228244
**( o_o) Notice the `[...] (https://overhide.github.io/ledgers.js-demo/demo/login.html) :: OH >> onCredentialsUpdate :: wallet callback called--address updated : {..}` log.**
229245

@@ -245,7 +261,7 @@ Following along--in the code pane--we see that the [oh$.onCredentialsUpdate call
245261

246262
The `gatherData()` function call (at the end of the [callback](https://overhide.github.io/ledgers.js/ledgers.js-rendered-docs/index.html#oncredentialsupdate)) triggers [*ledgers.js*](https://overhide.github.io/ledgers.js/ledgers.js-rendered-docs/index.html) getters to update payment amounts via the "ohledger" imparter--the currently selected ledger--and compare it to the pre-configured payment schedule ([config.js](https://github.com/overhide/ledgers.js/blob/master/demo/config.js)).
247263

248-
This stack of functions make several calls to the [ledger](https://test.ohledger.com/swagger.html) abstracted via [*ledgers.js*](https://overhide.github.io/ledgers.js/ledgers.js-rendered-docs/index.html):
264+
This stack of functions make several calls to the [ledger](https://test.ledger.overhide.io/swagger.html) abstracted via [*ledgers.js*](https://overhide.github.io/ledgers.js/ledgers.js-rendered-docs/index.html):
249265

250266
* [oh$.getTally](https://overhide.github.io/ledgers.js/ledgers.js-rendered-docs/index.html#gettally)
251267
* [oh$.getTransactions](https://overhide.github.io/ledgers.js/ledgers.js-rendered-docs/index.html#gettransactions)
@@ -303,6 +319,23 @@ The *service* is configured with the same schedule so as to be on the same page
303319

304320
Whereby *login.html* ([source](https://github.com/overhide/ledgers.js/blob/master/demo/login.html)) needs the *payment schedule* to aid the user in paying, *service.html* ([source](https://github.com/overhide/ledgers.js/blob/master/demo/service.html)) needs it to validate payment before allowing asked-for authorizations.
305321

322+
**( o_o) Take note of the `"[...] (service.html) :: successfuly retrieved token for APIs : {"` trace.**
323+
324+
On the back-end, our remuneration API calls also require a token.
325+
326+
The token is retrieved using the `getToken()` function and passed into the various `fetch` commands:
327+
328+
```
329+
fetch(..., {
330+
...
331+
headers: {
332+
"Authorization": `Bearer ${token}`
333+
}
334+
})
335+
```
336+
337+
338+
306339
**(¬-_-)¬ Click the `[...] (service.html) :: remunaration API >> isValidOnLedger call` log.**
307340

308341
Take note that the *service* no longer uses [*ledgers.js*](https://overhide.github.io/ledgers.js/ledgers.js-rendered-docs/index.html) API.

demo/ignore/logging.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,5 +42,5 @@ function setCodeToMessage(file, message) {
4242
$('#codeframe').attr('src', null);
4343
setTimeout(function () {
4444
$('#codeframe').attr('src', 'ignore/code.html#../' + file + '/' + encodeURI(message));
45-
}, 0);
45+
}, 100);
4646
}

demo/ignore/login.ui.html

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ <h4>Login With</h4>
111111
<div class="header">
112112
Background Info
113113
</div>
114-
<p>For <b>dollars</b> our make-believe "cake game" developer previously <a href="https://test.ledger.overhide.io" target="_blank">registered</a> with the <a href="https://test.ledger.overhide.io" target="_blank">overhide-ledger test network</a> using their <code>0x046c88317b23dc57F6945Bf4140140f73c8FC80F</code> ledger address.</p>
114+
<p>For <b>dollars</b> our make-believe "cake game" developer previously <a href="https://test.ledger.overhide.io/onboard" target="_blank">registered</a> with the <a href="https://test.ledger.overhide.io" target="_blank">overhide-ledger test network</a> using their <code>0x046c88317b23dc57F6945Bf4140140f73c8FC80F</code> ledger address.</p>
115115
<hr/>
116116
<p>For <b>ethers</b> our make-believe "cake game" developer uses the same <code>0x046c88317b23dc57F6945Bf4140140f73c8FC80F</code> <em>ledger address</em> with the <a href="https://rinkeby.etherscan.io/address/0x046c88317b23dc57f6945bf4140140f73c8fc80f" target="_blank">Rinkeby testnet</a>.</p>
117117
</div>
@@ -175,14 +175,14 @@ <h4>
175175
<div class="content">
176176
<div class="ui basic segment">
177177
<p>There is no concept of resetting passwords with blockchain ledgers. We cannot generate new secret keys for existing addresses. Should users forgot their secret keys, they cannot proove they own their addresses.</p>
178-
<p>But when using <a href="https://test.ohledger.com/pay" target="_blank">overhide-ledger</a> payments are made with <a href="https://stripe.com" target="_blank">Stripe.com</a>. Every <a href="https://stripe.com" target="_blank">Stripe.com</a> payment involves email or SMS verification. If email verification occured, that email address can be provided to <b>re-target</b> <a href="https://test.ohledger.com/pay" target="_blank">overhide-ledger</a> transactions as if they come from a new address.</p>
179-
<p>Since <a href="https://test.ohledger.com/pay" target="_blank">overhide-ledger</a> is not a blockchain, we can rewrite ledger entries in the database.</p>
180-
<p>Check out this feature by clicking the blue button and visiting the <a href="https://test.ohledger.com/pay" target="_blank">overhide-ledger</a> site.</p>
178+
<p>But when using <a href="https://test.ledger.overhide.io/pay" target="_blank">overhide-ledger</a> payments are made with <a href="https://stripe.com" target="_blank">Stripe.com</a>. Every <a href="https://stripe.com" target="_blank">Stripe.com</a> payment involves email or SMS verification. If email verification occured, that email address can be provided to <b>re-target</b> <a href="https://test.ledger.overhide.io/pay" target="_blank">overhide-ledger</a> transactions as if they come from a new address.</p>
179+
<p>Since <a href="https://test.ledger.overhide.io/pay" target="_blank">overhide-ledger</a> is not a blockchain, we can rewrite ledger entries in the database.</p>
180+
<p>Check out this feature by clicking the blue button and visiting the <a href="https://test.ledger.overhide.io/pay" target="_blank">overhide-ledger</a> site.</p>
181181
<p>You can think of <b>re-targeting</b> as a blockchain on-boarding feature. It isn't a password reset. But it's not as painful as loosing your secret key to an address on a blockchain.</p>
182-
<p>Of course this isn't available for any blockchain ledgers supported by <em>overhide</em>, it's only available for the centralized <a href="https://test.ohledger.com/pay" target="_blank">overhide-ledger</a>.</p>
182+
<p>Of course this isn't available for any blockchain ledgers supported by <em>overhide</em>, it's only available for the centralized <a href="https://test.ledger.overhide.io/pay" target="_blank">overhide-ledger</a>.</p>
183183
</div>
184184
<div class="ui basic center aligned segment">
185-
<a class="ui primary submit button" href="https://test.ohledger.com/pay" target="_blank">Let's Go</a>
185+
<a class="ui primary submit button" href="https://test.ledger.overhide.io/pay" target="_blank">Let's Go</a>
186186
</div>
187187
</div>
188188
</div>

0 commit comments

Comments
 (0)