├── .gitignore
├── CONTRIBUTING.md
├── LICENSE
├── README.md
├── circle.yml
├── docs
└── README.template.md
├── ilp_logo.png
├── npmrc-env
├── package.json
└── src
├── index.js
└── payment.js
/.gitignore:
--------------------------------------------------------------------------------
1 | /node_modules/
2 | docs/*.intermediate.md
3 |
4 |
--------------------------------------------------------------------------------
/CONTRIBUTING.md:
--------------------------------------------------------------------------------
1 | # Contributing to Interledger.js Repositories
2 |
3 | ## Getting Involved
4 |
5 | Detailed contribution guidelines are coming soon...
6 |
7 | ## Contributor License Agreement
8 |
9 | This project uses the [JS Foundation](https://js.foundation) CLA for licensing contributions.
10 |
11 | Please submit your pull request as you would with any other open source project on GitHub and our CLA Assistant bot will guide you through the signing process.
12 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | Copyright 2016 JS Foundation and contributors
2 | Copyright 2015-2016 Ripple, Inc. and contributors
3 |
4 | Licensed under the Apache License, Version 2.0 (the "License"); you may not use
5 | this file except in compliance with the License. You may obtain a copy of the
6 | License at
7 |
8 | http://www.apache.org/licenses/LICENSE-2.0
9 |
10 | Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
11 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # DEPRECATED - Use the [`ilp` module](https://github.com/interledgerjs/ilp) instead
2 |
3 |
4 |
5 |
6 | Five Bells Wallet Client
7 |
8 |
9 |
10 | A high-level JS library for sending and receiving Interledger payments.
11 |
12 |
13 |
14 |
15 | [![npm][npm-image]][npm-url] [![standard][standard-image]][standard-url] [![circle][circle-image]][circle-url]
16 |
17 | [npm-image]: https://img.shields.io/npm/v/five-bells-wallet-client.svg?style=flat
18 | [npm-url]: https://npmjs.org/package/five-bells-wallet-client
19 | [standard-image]: https://img.shields.io/badge/code%20style-standard-brightgreen.svg?style=flat
20 | [standard-url]: http://standardjs.com/
21 | [circle-image]: https://img.shields.io/circleci/project/interledgerjs/five-bells-wallet-client/master.svg?style=flat
22 | [circle-url]: https://circleci.com/gh/interledgerjs/five-bells-wallet-client
23 |
24 | ## Installation
25 |
26 | `npm install five-bells-wallet-client --save`
27 |
28 | ## Usage
29 |
30 | This is a client for the [`five-bells-wallet`](https://github.com/interledgerjs/five-bells-wallet).
31 |
32 | To use it with a hosted demo wallet, create an account on [red.ilpdemo.org](https://red.ilpdemo.org) or [blue.ilpdemo.org](https://blue.ilpdemo.org) (it doesn't matter which because they're connected via the [Interledger Protocol](https://interledger.org)!).
33 |
34 |
35 | ### Sending
36 |
37 | ```js
38 | const WalletClient = require('five-bells-wallet-client')
39 |
40 | const sender = new WalletClient({
41 | address: 'alice@red.ilpdemo.org',
42 | password: 'alice'
43 | })
44 |
45 | sender.on('connect', () => {
46 | console.log('Sender connected')
47 | })
48 |
49 | sender.send({
50 | destination: 'bob@blue.ilpdemo.org',
51 | destinationAmount: '0.01',
52 | message: 'Still love you!',
53 | onQuote: (payment) => {
54 | console.log('Received a quote; this will cost us: ' + payment.sourceAmount)
55 | }
56 | }).then((payment) => {
57 | console.log('Sent payment:', payment)
58 | console.log('')
59 | }).catch((err) => {
60 | console.error(err.stack)
61 | })
62 | ```
63 |
64 | ### Receiving
65 |
66 | ```js
67 | const WalletClient = require('five-bells-wallet-client')
68 |
69 | const receiver = new WalletClient({
70 | address: 'bob@blue.ilpdemo.org',
71 | password: 'bobbob'
72 | })
73 |
74 | receiver.on('connect', () => {
75 | console.log('Receiver connected')
76 | })
77 |
78 | receiver.on('incoming', (payment) => {
79 | console.log('Received ' + payment.destinationAmount + ' bucks!')
80 | console.log(payment.sourceAccount + ' says: ' + payment.message)
81 | })
82 | ```
83 |
84 | ### Combined Example
85 |
86 | ```js
87 | const WalletClient = require('five-bells-wallet-client')
88 |
89 | const sender = new WalletClient({
90 | address: 'alice@red.ilpdemo.org',
91 | password: 'alice'
92 | })
93 |
94 | const receiver = new WalletClient({
95 | address: 'bob@blue.ilpdemo.org',
96 | password: 'bobbob'
97 | })
98 |
99 | sender.on('connect', () => {
100 | console.log('Sender connected')
101 | })
102 |
103 | receiver.on('connect', () => {
104 | console.log('Receiver connected')
105 | })
106 |
107 | receiver.on('incoming', (payment) => {
108 | console.log('Received ' + payment.destinationAmount + ' bucks!')
109 | console.log(payment.sourceAccount + ' says: ' + payment.message)
110 | })
111 |
112 | sender.send({
113 | destination: 'bob@blue.ilpdemo.org',
114 | destinationAmount: '0.01',
115 | message: 'Still love you!',
116 | onQuote: (payment) => {
117 | console.log('Received a quote; this will cost us: ' + payment.sourceAmount)
118 | }
119 | }).then((payment) => {
120 | console.log('Sent payment:', payment)
121 | console.log('')
122 | }).catch((err) => {
123 | console.error(err.stack)
124 | })
125 | ```
126 |
127 | ## API Reference
128 |
129 | Client for connecting to the five-bells-wallet
130 |
131 |
132 |
133 | ### WalletClient~WalletClient
134 | **Kind**: inner class of [WalletClient](#module_WalletClient)
135 |
136 | * [~WalletClient](#module_WalletClient..WalletClient)
137 | * [new WalletClient(opts)](#new_module_WalletClient..WalletClient_new)
138 | * [.connect()](#module_WalletClient..WalletClient+connect) ⇒ Promise.<null>
139 | * [.isConnected()](#module_WalletClient..WalletClient+isConnected) ⇒ Boolean
140 | * [.getAccount()](#module_WalletClient..WalletClient+getAccount) ⇒ Promise.<String>
141 | * [.disconnect()](#module_WalletClient..WalletClient+disconnect) ⇒ null
142 | * [.payment(params)](#module_WalletClient..WalletClient+payment) ⇒ [Payment](#module_Payment..Payment)
143 | * [.send(params)](#module_WalletClient..WalletClient+send) ⇒ Promise.<Object>
144 | * [.convertAmount()](#module_WalletClient..WalletClient+convertAmount) ⇒ Promise.<BigNumber>
145 |
146 |
147 |
148 | #### new WalletClient(opts)
149 |
150 | | Param | Type | Default | Description |
151 | | --- | --- | --- | --- |
152 | | opts | Object | | WalletClient options |
153 | | opts.address | String | | Account at five-bells-wallet in the form user@wallet-url.example |
154 | | opts.password | String | | Account password for five-bells-wallet |
155 | | [opts.autoConnect] | Boolean | true | Subscribe to WebSocket notifications automatically when new event listeners are added |
156 |
157 |
158 |
159 | #### walletClient.connect() ⇒ Promise.<null>
160 | Login to wallet and subscribe to WebSocket notifications
161 |
162 | **Kind**: instance method of [WalletClient](#module_WalletClient..WalletClient)
163 | **Returns**: Promise.<null> - Resolves once client is subscribed
164 |
165 |
166 | #### walletClient.isConnected() ⇒ Boolean
167 | Check if the client is currently subscribed to wallet notifications
168 |
169 | **Kind**: instance method of [WalletClient](#module_WalletClient..WalletClient)
170 |
171 |
172 | #### walletClient.getAccount() ⇒ Promise.<String>
173 | Get the ledger account URI corresponding to the user's address
174 |
175 | **Kind**: instance method of [WalletClient](#module_WalletClient..WalletClient)
176 |
177 |
178 | #### walletClient.disconnect() ⇒ null
179 | Unsubscribe from wallet notifications
180 |
181 | **Kind**: instance method of [WalletClient](#module_WalletClient..WalletClient)
182 |
183 |
184 | #### walletClient.payment(params) ⇒ [Payment](#module_Payment..Payment)
185 | Create a new Payment object
186 |
187 | **Kind**: instance method of [WalletClient](#module_WalletClient..WalletClient)
188 |
189 | | Param | Type | Description |
190 | | --- | --- | --- |
191 | | params | [PaymentParams](#module_Payment..PaymentParams) | Payment parameters |
192 |
193 |
194 |
195 | #### walletClient.send(params) ⇒ Promise.<Object>
196 | Create a new Payment object, get a quote, and send the payment. Resolves when the payment is complete.
197 |
198 | **Kind**: instance method of [WalletClient](#module_WalletClient..WalletClient)
199 | **Returns**: Promise.<Object> - Payment result
200 |
201 | | Param | Type | Description |
202 | | --- | --- | --- |
203 | | params | [PaymentParams](#module_Payment..PaymentParams) | Payment parameters |
204 | | [params.onQuote] | function | Function to call when a quote is received |
205 | | [params.onSent] | function | Function to call when payment is sent (before it is complete) |
206 |
207 |
208 |
209 | #### walletClient.convertAmount() ⇒ Promise.<BigNumber>
210 | Convert the given destination amount into the local asset
211 |
212 | **Kind**: instance method of [WalletClient](#module_WalletClient..WalletClient)
213 | **Returns**: Promise.<BigNumber> - Source amount as a [BigNumber](https://mikemcl.github.io/bignumber.js/)
214 |
215 | | Param | Type | Description |
216 | | --- | --- | --- |
217 | | params.destinationAmount | String | Number | The destination amount to convert |
218 | | params.destinationAccount | String | Destination account to convert amount for |
219 |
220 |
221 | Class for quoting and sending payments
222 |
223 |
224 |
225 | ### Payment~Payment
226 | **Kind**: inner class of [Payment](#module_Payment)
227 |
228 | * [~Payment](#module_Payment..Payment)
229 | * [new Payment(walletClient, params)](#new_module_Payment..Payment_new)
230 | * [.quote()](#module_Payment..Payment+quote) ⇒ [Promise.<PaymentParams>](#module_Payment..PaymentParams)
231 | * [.send()](#module_Payment..Payment+send) ⇒ Promise.<Object>
232 |
233 |
234 |
235 | #### new Payment(walletClient, params)
236 |
237 | | Param | Type | Description |
238 | | --- | --- | --- |
239 | | walletClient | WalletClient | WalletClient instance used for quoting and sending |
240 | | params | [PaymentParams](#module_Payment..PaymentParams) | Payment parameters |
241 |
242 |
243 |
244 | #### payment.quote() ⇒ [Promise.<PaymentParams>](#module_Payment..PaymentParams)
245 | Get a quote to fill in either the sourceAmount or destinationAmount, whichever was not given.
246 |
247 | **Kind**: instance method of [Payment](#module_Payment..Payment)
248 | **Returns**: [Promise.<PaymentParams>](#module_Payment..PaymentParams) - Original payment params with sourceAmount or destinationAmount filled in
249 | **Emits**: [quote](#Payment+event_quote)
250 |
251 |
252 | #### payment.send() ⇒ Promise.<Object>
253 | Execute the payment
254 |
255 | **Kind**: instance method of [Payment](#module_Payment..Payment)
256 | **Returns**: Promise.<Object> - Resolves when the payment is complete
257 | **Emits**: [sent](#Payment+event_sent)
258 |
259 |
260 | ### Payment~PaymentParams : Object
261 | **Kind**: inner typedef of [Payment](#module_Payment)
262 |
263 | | Param | Type | Default | Description |
264 | | --- | --- | --- | --- |
265 | | destinationAccount | String | | Receiver account URI |
266 | | [sourceAmount] | String | Number | BigNumber | (quoted from destinationAmount) | Either sourceAmount or destinationAmount must be supplied |
267 | | [destinationAmount] | String | Number | BigNumber | (quoted from sourceAmount) | Either sourceAmount or destinationAmount must be supplied |
268 | | [message] | String | "" | Message to send to recipient |
269 |
--------------------------------------------------------------------------------
/circle.yml:
--------------------------------------------------------------------------------
1 | machine:
2 | node:
3 | version: 4.4.0
4 | deployment:
5 | production:
6 | branch: master
7 | commands:
8 | # Push NPM package if not yet published
9 | - mv npmrc-env .npmrc
10 | - if [ -z "$(npm info $(npm ls --depth=-1 2>/dev/null | head -1 | cut -f 1 -d " ") 2>/dev/null)" ] ; then npm publish ; fi
11 |
--------------------------------------------------------------------------------
/docs/README.template.md:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Five Bells Wallet Client
5 |
6 |
7 |
8 | A high-level JS library for sending and receiving Interledger payments.
9 |