You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* Updates for 2.2.0
* This is a simple smart contract used for testing.
* Updating for TN-2.2.0
* DG-943 (#5)
* Initial Browserify commit
* Initial JS-SDK file commit
* Auto-compile of DisJS, map file, minor bug fixes
* Browser examples output to document instead of console
* Update config to restore stage env
* DG-943 (JS files) (#6)
* Initial Browserify commit
* Initial JS-SDK file commit
* Auto-compile of DisJS, map file, minor bug fixes
* Browser examples output to document instead of console
* Update config to restore stage env
* Update JS files
* Align version number to disco version
var DisNodeSDK =require('@dispatchlabs/disnode-sdk');
15
+
```
16
+
17
+
JavaScript:
18
+
19
+
For JavaScript, the top-level object is `DisJS`. Any of the models and methods below (unless otherwise stated) can be used in the browser by replacing `DisNodeSDK` with `DisJS`. For example;
20
+
21
+
```js
22
+
// Create an empty account
23
+
var account =newDisJS.Account();
5
24
```
6
25
7
26
### Running examples
8
27
9
-
Examples are contained in the [examples folder](examples) and can be executed using:
28
+
Examples are contained in the [examples folder](examples) and can be executed in Node using:
10
29
11
30
```sh
12
31
$ npm install && npm run examples
13
32
```
14
33
34
+
To execute the JavaScript examples, open the `examples/js/index.html` file in a browser window.
Copy file name to clipboardExpand all lines: README.md
+59-33Lines changed: 59 additions & 33 deletions
Original file line number
Diff line number
Diff line change
@@ -1,6 +1,8 @@
1
-
# @dispatchlabs/disnode-sdk[](https://www.npmjs.com/package/@dispatchlabs/disnode-sdk)[](https://npmjs.org/package/@dispatchlabs/disnode-sdk)[](https://npmjs.org/package/@dispatchlabs/disnode-sdk)[](https://travis-ci.org/dispatchlabs/dispatchlabs)
1
+
# @dispatchlabs/disnode-sdk[](https://www.npmjs.com/package/@dispatchlabs/disnode-sdk)[](https://npmjs.org/package/@dispatchlabs/disnode-sdk)[](https://npmjs.org/package/@dispatchlabs/disnode-sdk)[](https://travis-ci.org/dispatchlabs/dispatchlabs)
2
2
3
-
> The Dispatch SDK for Node developers.
3
+
> The Dispatch SDK for Node and JavaScript developers.
4
+
5
+
Please consider following this project's author, [Dispatch Labs](https://github.com/David Hutchings), and consider starring the project to show your :heart: and support.
4
6
5
7
## Install
6
8
@@ -10,26 +12,41 @@ Install with [npm](https://www.npmjs.com/):
10
12
$ npm install --save @dispatchlabs/disnode-sdk
11
13
```
12
14
13
-
Install with [yarn](https://yarnpkg.com):
15
+
## CDN
14
16
15
-
```sh
16
-
$ yarn add @dispatchlabs/disnode-sdk
17
+
The JavaScript version of the SDK may be included on the pae with the following CDN location:
var DisNodeSDK =require('@dispatchlabs/disnode-sdk');
23
29
```
24
30
31
+
JavaScript:
32
+
33
+
For JavaScript, the top-level object is `DisJS`. Any of the models and methods below (unless otherwise stated) can be used in the browser by replacing `DisNodeSDK` with `DisJS`. For example;
34
+
35
+
```js
36
+
// Create an empty account
37
+
var account =newDisJS.Account();
38
+
```
39
+
25
40
### Running examples
26
41
27
-
Examples are contained in the [examples folder](examples) and can be executed using:
42
+
Examples are contained in the [examples folder](examples) and can be executed in Node using:
28
43
29
44
```sh
30
45
$ npm install && npm run examples
31
46
```
32
47
48
+
To execute the JavaScript examples, open the `examples/js/index.html` file in a browser window.
49
+
33
50
# Models
34
51
35
52
## Account
@@ -61,7 +78,7 @@ let account = new DisNodeSDK.Account({
61
78
});
62
79
```
63
80
64
-
### [refresh](lib/models/Account.js#L166)
81
+
### [refresh](lib/models/Account.js#L172)
65
82
66
83
Refreshes the account balance and access info (created and updated dates) from a delegate.
67
84
@@ -80,7 +97,7 @@ account.refresh()
80
97
});
81
98
```
82
99
83
-
### [init](lib/models/Account.js#L208)
100
+
### [init](lib/models/Account.js#L225)
84
101
85
102
Generaes a new private key for the account object (replacing one if present).
86
103
@@ -94,14 +111,14 @@ account.init();
94
111
console.log(account);
95
112
```
96
113
97
-
### [sendTokens](lib/models/Account.js#L237)
114
+
### [sendTokens](lib/models/Account.js#L254)
98
115
99
116
Creates and sends a transaction that will transfer tokens from the source account, to the target account.
100
117
101
118
**Params**
102
119
103
120
***{string|Account}**: to - The address or Account to send the tokens to.
104
-
***{number}**: tokens - The number of tokens to send.
121
+
***{number}**: value - The number of tokens to send.
105
122
*`returns`**{Transaction}**: Returns a transaction which has already been sent.
106
123
107
124
**Example**
@@ -112,15 +129,15 @@ let account = new DisNodeSDK.Account('fa61c18114f8ff8aafbeb5d32e1b108e3f6cf30d')
112
129
let tx =account.sendTokens(newDisNodeSDK.Account().init(), 1);
113
130
```
114
131
115
-
### [createContract](lib/models/Account.js#L272)
132
+
### [createContract](lib/models/Account.js#L293)
116
133
117
134
Creates and sends a transaction from the account that will create a new Smart Contract.
118
135
119
136
**Params**
120
137
121
138
***{string}**: code - Bytecode of a compiled contract.
122
139
***{string|array}**: code - The ABI of the contract.
123
-
***{number}**: tokens - The number of tokens to seed the contract with.
140
+
***{number}**: value - The number of tokens to seed the contract with.
124
141
*`returns`**{Transaction}**: Returns a transaction which has already been sent.
125
142
126
143
**Example**
@@ -131,7 +148,7 @@ let compiled = DisNodeSDK.Transaction.compileSource('contract x { function g() {
131
148
let contract =account.createContract(compiled.contracts[0].bytecode, compiled.contracts[0].abi, 5);
132
149
```
133
150
134
-
### [executeContract](lib/models/Account.js#L323)
151
+
### [executeContract](lib/models/Account.js#L343)
135
152
136
153
Creates and sends a transaction from the account that will execute a method on an existing Smart Contract.
137
154
@@ -140,8 +157,7 @@ Creates and sends a transaction from the account that will execute a method on a
140
157
***{string|Account|Transaction}**: to - The address of an existing contract, an Account representing the contract, or the contract creation Transaction.
141
158
***{string}**: method - The method in the contract to call.
142
159
***{array}**: params - The parameters to use during the method call.
143
-
***{string|array}**: code - The ABI of the contract being called.
144
-
***{number}**: tokens - The number of tokens to send to the contract for the method call.
160
+
***{number}**: value - The number of tokens to send to the contract for the method call.
145
161
*`returns`**{Transaction}**: Returns a transaction which has already been sent.
146
162
147
163
**Example**
@@ -175,7 +191,7 @@ let account = new DisNodeSDK.Account().init();
175
191
let tx =newDisNodeSDK.Transaction({from: account});
176
192
```
177
193
178
-
### [send](lib/models/Transaction.js#L272)
194
+
### [send](lib/models/Transaction.js#L316)
179
195
180
196
Sends the transaction to a delegate.
181
197
@@ -195,7 +211,7 @@ tx.send()
195
211
});
196
212
```
197
213
198
-
### [status](lib/models/Transaction.js#L308)
214
+
### [status](lib/models/Transaction.js#L357)
199
215
200
216
Requests the current status of the transaction from a delegate.
Waits until the status of the transaction matches the value provided, then resolves. Rejects after 5 seconds or when the transaction hits a non-matching final state.
@@ -267,51 +283,61 @@ if (compiled.errors.length > 0) {
267
283
}
268
284
```
269
285
270
-
### [compile](lib/models/Transaction.js#L484)
286
+
### [compile](lib/models/Transaction.js#L564)
271
287
272
288
Static method to compile complex Solidity JSON structures.
273
289
274
290
**Params**
275
291
276
-
***{object}**: input - Full Solidity JSON structure. See {@linkhttps://solidity.readthedocs.io/en/develop/using-the-compiler.html#compiler-input-and-output-json-description|Compiler Input and Output JSON Description}.
292
+
***{object}**: input - Full Solidity JSON structure. See [Compiler Input and Output JSON Description](https://solidity.readthedocs.io/en/develop/using-the-compiler.html#compiler-input-and-output-json-description).
277
293
*`returns`**{object}**: Compiled output JSON.
278
294
279
295
**Example**
280
296
281
297
```js
282
-
let compiled =DisNodeSDK.Transaction.compile({sources: { source:'contract x { function g() { } }' }});
298
+
let compiled =DisNodeSDK.Transaction.compile({language:'Solidity', sources: { source:{ content:'contract x { function g() { } }'}}});
283
299
```
284
300
285
301
## About
286
302
287
-
### Contributing
303
+
<details>
304
+
<summary><strong>Contributing</strong></summary>
288
305
289
306
Pull requests and stars are always welcome. For bugs and feature requests, [please create an issue](../../issues/new).
290
307
291
-
### Building docs
308
+
</details>
292
309
293
-
_(This project's readme.md is generated by [verb](https://github.com/verbose/verb-generate-readme), please don't edit the readme directly. Any changes to the readme must be made in the [.verb.md](.verb.md) readme template.)_
310
+
<details>
311
+
<summary><strong>Running Tests</strong></summary>
294
312
295
-
To generate the readme, run the following command:
313
+
Running and reviewing unit tests is a great way to get familiarized with a library and its API. You can install dependencies and run tests with the following command:
Running and reviewing unit tests is a great way to get familiarized with a library and its API. You can install dependencies and run tests with the following command:
321
+
<details>
322
+
<summary><strong>Building docs</strong></summary>
323
+
324
+
_(This project's readme.md is generated by [verb](https://github.com/verbose/verb-generate-readme), please don't edit the readme directly. Any changes to the readme must be made in the [.verb.md](.verb.md) readme template.)_
325
+
326
+
To generate the readme, run the following command:
0 commit comments