@attocash/commons-js 6.3.1 → 6.5.0
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 +267 -0
- package/commons-commons-js.d.mts +32 -20
- package/commons-commons-js.mjs +30738 -28967
- package/commons-commons-js.mjs.map +1 -1
- package/package.json +6 -2
package/README.md
ADDED
|
@@ -0,0 +1,267 @@
|
|
|
1
|
+
# @attocash/commons-js
|
|
2
|
+
|
|
3
|
+
[](https://www.npmjs.com/package/@attocash/commons-js)
|
|
4
|
+
[](https://github.com/attocash/commons/blob/main/LICENSE)
|
|
5
|
+
|
|
6
|
+
JavaScript and TypeScript bindings for Atto, instant and feeless digital cash for everyday payments.
|
|
7
|
+
|
|
8
|
+
`@attocash/commons-js` packages the Atto Commons protocol types and client helpers for JavaScript applications. Use it to work with Atto addresses, mnemonics, amounts, wallets, node clients, work servers, monitors, blocks, signatures, and transactions.
|
|
9
|
+
|
|
10
|
+
## Install
|
|
11
|
+
|
|
12
|
+
```sh
|
|
13
|
+
npm install @attocash/commons-js
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
This package is published as ESM and includes TypeScript declarations.
|
|
17
|
+
|
|
18
|
+
```js
|
|
19
|
+
import { AttoAddress, AttoAmount, AttoUnit } from '@attocash/commons-js'
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
## Try It Live
|
|
23
|
+
|
|
24
|
+
The [Atto interactive playground](https://atto.cash/docs/integration/advanced/interactive-playground) lets you experiment with `@attocash/commons-js` directly in the browser. It includes seed generation and public-key/address conversion examples.
|
|
25
|
+
|
|
26
|
+
Do not use mnemonics, private keys, or addresses generated by a website for real funds. Treat the playground as an educational tool.
|
|
27
|
+
|
|
28
|
+
## What You Can Build
|
|
29
|
+
|
|
30
|
+
- Wallet flows: derive accounts, open accounts, send funds, receive pending funds, and change representatives.
|
|
31
|
+
- Service integrations: connect to an Atto node and a Work Server from a backend or tool.
|
|
32
|
+
- Monitoring: subscribe to account, transaction, receivable, and account-entry updates.
|
|
33
|
+
- Protocol tooling: parse and format addresses, amounts, blocks, transactions, hashes, and JSON payloads.
|
|
34
|
+
- Tests and demos: pair with `@attocash/commons-test` to run local mock node and worker services.
|
|
35
|
+
|
|
36
|
+
## Requirements
|
|
37
|
+
|
|
38
|
+
- Node.js 18 or newer is recommended.
|
|
39
|
+
- Use ESM imports. In Node.js files, use `.mjs` or set `"type": "module"`.
|
|
40
|
+
- For live transactions, provide access to an Atto node and a Work Server.
|
|
41
|
+
- Keep production mnemonics and private keys outside browser code, logs, source control, and analytics.
|
|
42
|
+
|
|
43
|
+
Node.js examples that use the remote node/worker clients should expose `require` for the underlying runtime:
|
|
44
|
+
|
|
45
|
+
```js
|
|
46
|
+
import { createRequire } from 'node:module'
|
|
47
|
+
|
|
48
|
+
globalThis.require = createRequire(import.meta.url)
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
## Generate an Account
|
|
52
|
+
|
|
53
|
+
```js
|
|
54
|
+
import {
|
|
55
|
+
AttoAddress,
|
|
56
|
+
AttoAlgorithm,
|
|
57
|
+
AttoMnemonic,
|
|
58
|
+
toAttoIndex,
|
|
59
|
+
toPrivateKey,
|
|
60
|
+
toPublicKey,
|
|
61
|
+
toSeedAsync,
|
|
62
|
+
} from '@attocash/commons-js'
|
|
63
|
+
|
|
64
|
+
const mnemonic = AttoMnemonic.generate()
|
|
65
|
+
const seed = await toSeedAsync(mnemonic)
|
|
66
|
+
|
|
67
|
+
const accountIndex = toAttoIndex(0)
|
|
68
|
+
const privateKey = toPrivateKey(seed, accountIndex)
|
|
69
|
+
const publicKey = toPublicKey(privateKey)
|
|
70
|
+
const address = new AttoAddress(AttoAlgorithm.V1, publicKey)
|
|
71
|
+
|
|
72
|
+
console.log(address.toString())
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
Store the mnemonic securely. Anyone with the mnemonic can derive the private keys for the wallet.
|
|
76
|
+
|
|
77
|
+
## Connect to a Node and Work Server
|
|
78
|
+
|
|
79
|
+
```js
|
|
80
|
+
import { createRequire } from 'node:module'
|
|
81
|
+
import {
|
|
82
|
+
AttoNodeClientAsyncBuilder,
|
|
83
|
+
AttoWorkerAsyncBuilder,
|
|
84
|
+
} from '@attocash/commons-js'
|
|
85
|
+
|
|
86
|
+
globalThis.require = createRequire(import.meta.url)
|
|
87
|
+
|
|
88
|
+
const nodeClient = new AttoNodeClientAsyncBuilder('http://localhost:8080').build()
|
|
89
|
+
const worker = new AttoWorkerAsyncBuilder('http://localhost:8085').build()
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
The node provides ledger data and publishes transactions. The Work Server computes the small proof-of-work required for spam prevention.
|
|
93
|
+
|
|
94
|
+
## Open an Account and Send ATTO
|
|
95
|
+
|
|
96
|
+
```js
|
|
97
|
+
import { createRequire } from 'node:module'
|
|
98
|
+
import {
|
|
99
|
+
AttoAddress,
|
|
100
|
+
AttoAmount,
|
|
101
|
+
AttoMnemonic,
|
|
102
|
+
AttoNodeClientAsyncBuilder,
|
|
103
|
+
AttoUnit,
|
|
104
|
+
AttoWalletAsyncBuilder,
|
|
105
|
+
AttoWorkerAsyncBuilder,
|
|
106
|
+
toAttoIndex,
|
|
107
|
+
toSeedAsync,
|
|
108
|
+
} from '@attocash/commons-js'
|
|
109
|
+
|
|
110
|
+
globalThis.require = createRequire(import.meta.url)
|
|
111
|
+
|
|
112
|
+
const mnemonic = AttoMnemonic.fromPhrase(process.env.ATTO_MNEMONIC)
|
|
113
|
+
const seed = await toSeedAsync(mnemonic)
|
|
114
|
+
|
|
115
|
+
const nodeClient = new AttoNodeClientAsyncBuilder(process.env.ATTO_NODE_URL).build()
|
|
116
|
+
const worker = new AttoWorkerAsyncBuilder(process.env.ATTO_WORKER_URL).build()
|
|
117
|
+
|
|
118
|
+
const wallet = new AttoWalletAsyncBuilder(nodeClient, worker)
|
|
119
|
+
.signerProviderSeed(seed)
|
|
120
|
+
.build()
|
|
121
|
+
|
|
122
|
+
const senderIndex = toAttoIndex(0)
|
|
123
|
+
await wallet.openAccount(senderIndex)
|
|
124
|
+
|
|
125
|
+
const receiver = AttoAddress.parse(process.env.ATTO_RECEIVER_ADDRESS)
|
|
126
|
+
const amount = AttoAmount.from(AttoUnit.ATTO, '1')
|
|
127
|
+
|
|
128
|
+
const transaction = await wallet.sendByIndex(senderIndex, receiver, amount, null)
|
|
129
|
+
|
|
130
|
+
console.log(`Published ${transaction.hash}`)
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
Atto transfers are asynchronous. A sender publishes a send block, and the receiver claims the pending receivable with an open or receive block.
|
|
134
|
+
|
|
135
|
+
## Enable Auto Receive
|
|
136
|
+
|
|
137
|
+
```js
|
|
138
|
+
import {
|
|
139
|
+
AttoAccountMonitorAsyncBuilder,
|
|
140
|
+
AttoAddress,
|
|
141
|
+
AttoWalletAsyncBuilder,
|
|
142
|
+
toAttoIndex,
|
|
143
|
+
} from '@attocash/commons-js'
|
|
144
|
+
|
|
145
|
+
const accountMonitor = new AttoAccountMonitorAsyncBuilder(nodeClient).build()
|
|
146
|
+
const representative = AttoAddress.parse(process.env.ATTO_REPRESENTATIVE_ADDRESS)
|
|
147
|
+
|
|
148
|
+
const wallet = new AttoWalletAsyncBuilder(nodeClient, worker)
|
|
149
|
+
.signerProviderSeed(seed)
|
|
150
|
+
.enableAutoReceiver(
|
|
151
|
+
accountMonitor,
|
|
152
|
+
undefined,
|
|
153
|
+
10,
|
|
154
|
+
() => representative,
|
|
155
|
+
)
|
|
156
|
+
.build()
|
|
157
|
+
|
|
158
|
+
const address = await wallet.getAddress(toAttoIndex(0))
|
|
159
|
+
await accountMonitor.monitorAddress(address)
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
Passing `undefined` as the minimum amount receives every pending receivable. Use an `AttoAmount` value if your application should ignore tiny receivables.
|
|
163
|
+
|
|
164
|
+
## Monitor Transactions
|
|
165
|
+
|
|
166
|
+
```js
|
|
167
|
+
import {
|
|
168
|
+
AttoAddress,
|
|
169
|
+
AttoAccountMonitorAsyncBuilder,
|
|
170
|
+
AttoTransactionMonitorAsyncBuilder,
|
|
171
|
+
transactionToJson,
|
|
172
|
+
} from '@attocash/commons-js'
|
|
173
|
+
|
|
174
|
+
const accountMonitor = new AttoAccountMonitorAsyncBuilder(nodeClient).build()
|
|
175
|
+
const transactionMonitor = new AttoTransactionMonitorAsyncBuilder(nodeClient, accountMonitor).build()
|
|
176
|
+
|
|
177
|
+
transactionMonitor.onTransaction(
|
|
178
|
+
async (transaction) => {
|
|
179
|
+
console.log(transactionToJson(transaction))
|
|
180
|
+
},
|
|
181
|
+
async (error) => {
|
|
182
|
+
if (error) {
|
|
183
|
+
console.error(error)
|
|
184
|
+
}
|
|
185
|
+
},
|
|
186
|
+
)
|
|
187
|
+
|
|
188
|
+
await accountMonitor.monitorAddress(AttoAddress.parse(process.env.ATTO_ADDRESS))
|
|
189
|
+
```
|
|
190
|
+
|
|
191
|
+
Use account-entry monitors when you need ledger entries rather than full transactions.
|
|
192
|
+
|
|
193
|
+
## Build, Sign, Work, and Publish Manually
|
|
194
|
+
|
|
195
|
+
The wallet helper is the usual integration path, but lower-level APIs are available when you need direct control over a transaction.
|
|
196
|
+
|
|
197
|
+
```js
|
|
198
|
+
import {
|
|
199
|
+
AttoAddress,
|
|
200
|
+
AttoAmount,
|
|
201
|
+
AttoTransaction,
|
|
202
|
+
AttoUnit,
|
|
203
|
+
attoAccountSend,
|
|
204
|
+
privateKeyToSigner,
|
|
205
|
+
} from '@attocash/commons-js'
|
|
206
|
+
|
|
207
|
+
const signer = privateKeyToSigner(privateKey)
|
|
208
|
+
const account = await nodeClient.accountByPublicKey(signer.publicKey)
|
|
209
|
+
|
|
210
|
+
if (!account) {
|
|
211
|
+
throw new Error('Sender account is not open')
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
const update = attoAccountSend(
|
|
215
|
+
account,
|
|
216
|
+
AttoAddress.parse(process.env.ATTO_RECEIVER_ADDRESS),
|
|
217
|
+
AttoAmount.from(AttoUnit.ATTO, '1'),
|
|
218
|
+
null,
|
|
219
|
+
)
|
|
220
|
+
|
|
221
|
+
const signature = await signer.signBlock(update.block)
|
|
222
|
+
const work = await worker.workBlock(update.block)
|
|
223
|
+
const transaction = new AttoTransaction(update.block, signature, work)
|
|
224
|
+
|
|
225
|
+
await nodeClient.publish(transaction)
|
|
226
|
+
```
|
|
227
|
+
|
|
228
|
+
This is useful for signing services, audits, custom queues, and offline-signing flows.
|
|
229
|
+
|
|
230
|
+
## Local Mock Example
|
|
231
|
+
|
|
232
|
+
For tests and demos, install the companion test package:
|
|
233
|
+
|
|
234
|
+
```sh
|
|
235
|
+
npm install --save-dev @attocash/commons-test
|
|
236
|
+
```
|
|
237
|
+
|
|
238
|
+
The repository includes a runnable JavaScript example that starts mock node and worker services, creates a wallet, opens accounts, sends transactions, and listens to monitors:
|
|
239
|
+
|
|
240
|
+
- [examples/js-client](https://github.com/attocash/commons/tree/main/examples/js-client)
|
|
241
|
+
|
|
242
|
+
## API Areas
|
|
243
|
+
|
|
244
|
+
| Area | Common exports |
|
|
245
|
+
| --- | --- |
|
|
246
|
+
| Keys and addresses | `AttoMnemonic`, `toSeedAsync`, `toPrivateKey`, `toPublicKey`, `AttoAddress`, `AttoPublicKey` |
|
|
247
|
+
| Amounts | `AttoAmount`, `AttoUnit` |
|
|
248
|
+
| Node access | `AttoNodeClientAsyncBuilder` |
|
|
249
|
+
| Work server | `AttoWorkerAsyncBuilder` |
|
|
250
|
+
| Wallets | `AttoWalletAsyncBuilder`, `sendByIndex`, `receive`, `change` |
|
|
251
|
+
| Monitors | `AttoAccountMonitorAsyncBuilder`, `AttoTransactionMonitorAsyncBuilder`, `AttoAccountEntryMonitorAsyncBuilder` |
|
|
252
|
+
| Serialization | `transactionToJson`, `transactionFromJson`, `blockToJson`, `blockFromJson`, `fromHexToByteArray`, `toHex` |
|
|
253
|
+
| Low-level transactions | `attoAccountSend`, `AttoTransaction`, `privateKeyToSigner` |
|
|
254
|
+
|
|
255
|
+
## Documentation
|
|
256
|
+
|
|
257
|
+
- [Atto documentation](https://atto.cash/docs)
|
|
258
|
+
- [Integration overview](https://atto.cash/docs/integration)
|
|
259
|
+
- [Node integration](https://atto.cash/docs/integration/node)
|
|
260
|
+
- [Work Server integration](https://atto.cash/docs/integration/work-server)
|
|
261
|
+
- [Wallet Server integration](https://atto.cash/docs/integration/wallet-server)
|
|
262
|
+
- [Offline signing with Atto Commons](https://atto.cash/docs/integration/advanced/offline-signing-with-atto-commons)
|
|
263
|
+
- [Protocol-level offline-signing reference](https://atto.cash/docs/integration/advanced/protocol-offline-signing-reference)
|
|
264
|
+
|
|
265
|
+
## License
|
|
266
|
+
|
|
267
|
+
[BSD 3-Clause](https://github.com/attocash/commons/blob/main/LICENSE)
|
package/commons-commons-js.d.mts
CHANGED
|
@@ -27,7 +27,7 @@ export declare class AttoAccount implements HeightSupport, AddressSupport {
|
|
|
27
27
|
toString(): string;
|
|
28
28
|
hashCode(): number;
|
|
29
29
|
equals(other: Nullable<any>): boolean;
|
|
30
|
-
readonly __doNotUseOrImplementIt:
|
|
30
|
+
readonly __doNotUseOrImplementIt: AddressSupport["__doNotUseOrImplementIt"] & HeightSupport["__doNotUseOrImplementIt"];
|
|
31
31
|
}
|
|
32
32
|
export declare namespace AttoAccount {
|
|
33
33
|
/** @deprecated $metadata$ is used for internal purposes, please don't use it in your code, because it can be removed at any moment */
|
|
@@ -64,7 +64,7 @@ export declare class AttoAccountEntry implements HeightSupport, AddressSupport {
|
|
|
64
64
|
toString(): string;
|
|
65
65
|
hashCode(): number;
|
|
66
66
|
equals(other: Nullable<any>): boolean;
|
|
67
|
-
readonly __doNotUseOrImplementIt:
|
|
67
|
+
readonly __doNotUseOrImplementIt: AddressSupport["__doNotUseOrImplementIt"] & HeightSupport["__doNotUseOrImplementIt"];
|
|
68
68
|
}
|
|
69
69
|
export declare namespace AttoAccountEntry {
|
|
70
70
|
/** @deprecated $metadata$ is used for internal purposes, please don't use it in your code, because it can be removed at any moment */
|
|
@@ -115,14 +115,14 @@ export declare abstract class AttoAlgorithm {
|
|
|
115
115
|
get name(): "V1";
|
|
116
116
|
get ordinal(): 0;
|
|
117
117
|
};
|
|
118
|
+
static values(): [typeof AttoAlgorithm.V1];
|
|
119
|
+
static valueOf(value: string): AttoAlgorithm;
|
|
118
120
|
get name(): "V1";
|
|
119
121
|
get ordinal(): 0;
|
|
120
122
|
get code(): any/* UByte */;
|
|
121
123
|
get privateKeySize(): number;
|
|
122
124
|
get publicKeySize(): number;
|
|
123
125
|
get hashSize(): number;
|
|
124
|
-
static values(): Array<AttoAlgorithm>;
|
|
125
|
-
static valueOf(value: string): AttoAlgorithm;
|
|
126
126
|
}
|
|
127
127
|
export declare namespace AttoAlgorithm {
|
|
128
128
|
/** @deprecated $metadata$ is used for internal purposes, please don't use it in your code, because it can be removed at any moment */
|
|
@@ -151,11 +151,11 @@ export declare abstract class AttoUnit {
|
|
|
151
151
|
get name(): "RAW";
|
|
152
152
|
get ordinal(): 1;
|
|
153
153
|
};
|
|
154
|
+
static values(): [typeof AttoUnit.ATTO, typeof AttoUnit.RAW];
|
|
155
|
+
static valueOf(value: string): AttoUnit;
|
|
154
156
|
get name(): "ATTO" | "RAW";
|
|
155
157
|
get ordinal(): 0 | 1;
|
|
156
158
|
get prefix(): string;
|
|
157
|
-
static values(): Array<AttoUnit>;
|
|
158
|
-
static valueOf(value: string): AttoUnit;
|
|
159
159
|
}
|
|
160
160
|
export declare namespace AttoUnit {
|
|
161
161
|
/** @deprecated $metadata$ is used for internal purposes, please don't use it in your code, because it can be removed at any moment */
|
|
@@ -216,10 +216,10 @@ export declare abstract class AttoBlockType {
|
|
|
216
216
|
get name(): "CHANGE";
|
|
217
217
|
get ordinal(): 4;
|
|
218
218
|
};
|
|
219
|
+
static values(): [typeof AttoBlockType.UNKNOWN, typeof AttoBlockType.OPEN, typeof AttoBlockType.RECEIVE, typeof AttoBlockType.SEND, typeof AttoBlockType.CHANGE];
|
|
220
|
+
static valueOf(value: string): AttoBlockType;
|
|
219
221
|
get name(): "UNKNOWN" | "OPEN" | "RECEIVE" | "SEND" | "CHANGE";
|
|
220
222
|
get ordinal(): 0 | 1 | 2 | 3 | 4;
|
|
221
|
-
static values(): Array<AttoBlockType>;
|
|
222
|
-
static valueOf(value: string): AttoBlockType;
|
|
223
223
|
}
|
|
224
224
|
export declare namespace AttoBlockType {
|
|
225
225
|
/** @deprecated $metadata$ is used for internal purposes, please don't use it in your code, because it can be removed at any moment */
|
|
@@ -264,7 +264,7 @@ export declare interface AttoBlock extends HeightSupport, AddressSupport, AttoHa
|
|
|
264
264
|
isValid(): boolean;
|
|
265
265
|
readonly __doNotUseOrImplementIt: {
|
|
266
266
|
readonly "cash.atto.commons.AttoBlock": unique symbol;
|
|
267
|
-
} &
|
|
267
|
+
} & AttoSerializable["__doNotUseOrImplementIt"] & AttoHashable["__doNotUseOrImplementIt"] & AddressSupport["__doNotUseOrImplementIt"] & HeightSupport["__doNotUseOrImplementIt"];
|
|
268
268
|
}
|
|
269
269
|
export declare namespace AttoBlock {
|
|
270
270
|
abstract class Companion extends KtSingleton<Companion.$metadata$.constructor>() {
|
|
@@ -324,7 +324,7 @@ export declare class AttoSendBlock implements AttoBlock, PreviousSupport {
|
|
|
324
324
|
equals(other: Nullable<any>): boolean;
|
|
325
325
|
isValid(): boolean;
|
|
326
326
|
toByteArray(): Int8Array;
|
|
327
|
-
readonly __doNotUseOrImplementIt:
|
|
327
|
+
readonly __doNotUseOrImplementIt: PreviousSupport["__doNotUseOrImplementIt"] & AttoBlock["__doNotUseOrImplementIt"];
|
|
328
328
|
}
|
|
329
329
|
export declare namespace AttoSendBlock {
|
|
330
330
|
/** @deprecated $metadata$ is used for internal purposes, please don't use it in your code, because it can be removed at any moment */
|
|
@@ -365,7 +365,7 @@ export declare class AttoReceiveBlock implements AttoBlock, PreviousSupport, Rec
|
|
|
365
365
|
validate(): AttoValidation;
|
|
366
366
|
isValid(): boolean;
|
|
367
367
|
toByteArray(): Int8Array;
|
|
368
|
-
readonly __doNotUseOrImplementIt:
|
|
368
|
+
readonly __doNotUseOrImplementIt: ReceiveSupport["__doNotUseOrImplementIt"] & PreviousSupport["__doNotUseOrImplementIt"] & AttoBlock["__doNotUseOrImplementIt"];
|
|
369
369
|
}
|
|
370
370
|
export declare namespace AttoReceiveBlock {
|
|
371
371
|
/** @deprecated $metadata$ is used for internal purposes, please don't use it in your code, because it can be removed at any moment */
|
|
@@ -408,7 +408,7 @@ export declare class AttoOpenBlock implements AttoBlock, ReceiveSupport, Represe
|
|
|
408
408
|
validate(): AttoValidation;
|
|
409
409
|
isValid(): boolean;
|
|
410
410
|
toByteArray(): Int8Array;
|
|
411
|
-
readonly __doNotUseOrImplementIt:
|
|
411
|
+
readonly __doNotUseOrImplementIt: RepresentativeSupport["__doNotUseOrImplementIt"] & ReceiveSupport["__doNotUseOrImplementIt"] & AttoBlock["__doNotUseOrImplementIt"];
|
|
412
412
|
}
|
|
413
413
|
export declare namespace AttoOpenBlock {
|
|
414
414
|
/** @deprecated $metadata$ is used for internal purposes, please don't use it in your code, because it can be removed at any moment */
|
|
@@ -450,7 +450,7 @@ export declare class AttoChangeBlock implements AttoBlock, PreviousSupport, Repr
|
|
|
450
450
|
validate(): AttoValidation;
|
|
451
451
|
isValid(): boolean;
|
|
452
452
|
toByteArray(): Int8Array;
|
|
453
|
-
readonly __doNotUseOrImplementIt:
|
|
453
|
+
readonly __doNotUseOrImplementIt: RepresentativeSupport["__doNotUseOrImplementIt"] & PreviousSupport["__doNotUseOrImplementIt"] & AttoBlock["__doNotUseOrImplementIt"];
|
|
454
454
|
}
|
|
455
455
|
export declare namespace AttoChangeBlock {
|
|
456
456
|
/** @deprecated $metadata$ is used for internal purposes, please don't use it in your code, because it can be removed at any moment */
|
|
@@ -655,12 +655,12 @@ export declare abstract class AttoNetwork {
|
|
|
655
655
|
get name(): "UNKNOWN";
|
|
656
656
|
get ordinal(): 4;
|
|
657
657
|
};
|
|
658
|
+
static values(): [typeof AttoNetwork.LIVE, typeof AttoNetwork.BETA, typeof AttoNetwork.DEV, typeof AttoNetwork.LOCAL, typeof AttoNetwork.UNKNOWN];
|
|
659
|
+
static valueOf(value: string): AttoNetwork;
|
|
658
660
|
get name(): "LIVE" | "BETA" | "DEV" | "LOCAL" | "UNKNOWN";
|
|
659
661
|
get ordinal(): 0 | 1 | 2 | 3 | 4;
|
|
660
662
|
get code(): any/* UByte */;
|
|
661
663
|
get thresholdIncreaseFactor(): bigint;
|
|
662
|
-
static values(): Array<AttoNetwork>;
|
|
663
|
-
static valueOf(value: string): AttoNetwork;
|
|
664
664
|
}
|
|
665
665
|
export declare namespace AttoNetwork {
|
|
666
666
|
/** @deprecated $metadata$ is used for internal purposes, please don't use it in your code, because it can be removed at any moment */
|
|
@@ -827,6 +827,7 @@ export declare namespace AttoSigner {
|
|
|
827
827
|
}
|
|
828
828
|
}
|
|
829
829
|
}
|
|
830
|
+
export declare function privateKeyToSigner(_this_: AttoPrivateKey): AttoSigner;
|
|
830
831
|
export declare class AttoTransaction implements HeightSupport, AddressSupport, AttoSerializable {
|
|
831
832
|
constructor(block: AttoBlock, signature: AttoSignature, work: AttoWork);
|
|
832
833
|
get block(): AttoBlock;
|
|
@@ -843,7 +844,7 @@ export declare class AttoTransaction implements HeightSupport, AddressSupport, A
|
|
|
843
844
|
hashCode(): number;
|
|
844
845
|
equals(other: Nullable<any>): boolean;
|
|
845
846
|
toByteArray(): Int8Array;
|
|
846
|
-
readonly __doNotUseOrImplementIt:
|
|
847
|
+
readonly __doNotUseOrImplementIt: AttoSerializable["__doNotUseOrImplementIt"] & AddressSupport["__doNotUseOrImplementIt"] & HeightSupport["__doNotUseOrImplementIt"];
|
|
847
848
|
}
|
|
848
849
|
export declare namespace AttoTransaction {
|
|
849
850
|
/** @deprecated $metadata$ is used for internal purposes, please don't use it in your code, because it can be removed at any moment */
|
|
@@ -900,7 +901,7 @@ export declare class AttoVote implements AttoHashable, AttoSerializable {
|
|
|
900
901
|
hashCode(): number;
|
|
901
902
|
equals(other: Nullable<any>): boolean;
|
|
902
903
|
toByteArray(): Int8Array;
|
|
903
|
-
readonly __doNotUseOrImplementIt:
|
|
904
|
+
readonly __doNotUseOrImplementIt: AttoSerializable["__doNotUseOrImplementIt"] & AttoHashable["__doNotUseOrImplementIt"];
|
|
904
905
|
}
|
|
905
906
|
export declare namespace AttoVote {
|
|
906
907
|
/** @deprecated $metadata$ is used for internal purposes, please don't use it in your code, because it can be removed at any moment */
|
|
@@ -1043,6 +1044,8 @@ export declare namespace HeightSearch {
|
|
|
1043
1044
|
}
|
|
1044
1045
|
}
|
|
1045
1046
|
}
|
|
1047
|
+
export declare function accountToJson(_this_: AttoAccount): string;
|
|
1048
|
+
export declare function accountFromJson(_this_: string): AttoAccount;
|
|
1046
1049
|
export declare function receivableToJson(_this_: AttoReceivable): string;
|
|
1047
1050
|
export declare function receivableFromJson(_this_: string): AttoReceivable;
|
|
1048
1051
|
export declare function transactionToJson(_this_: AttoTransaction): string;
|
|
@@ -1080,18 +1083,24 @@ export declare class AttoNodeClientAsync /* implements AutoCloseable */ {
|
|
|
1080
1083
|
get client(): any/* AttoNodeClient */;
|
|
1081
1084
|
accountByPublicKey(publicKey: AttoPublicKey): Promise<Nullable<AttoAccount>>;
|
|
1082
1085
|
accountByAddresses(addresses: Array<AttoAddress>): Promise<Array<AttoAccount>>;
|
|
1086
|
+
onAccountAll(onAccount: (p0: AttoAccount) => any, onCancel: (p0: Nullable<Error>/* Nullable<Exception> */) => any): any/* AttoJob */;
|
|
1083
1087
|
onAccountByPublicKey(publicKey: AttoPublicKey, onAccount: (p0: AttoAccount) => any, onCancel: (p0: Nullable<Error>/* Nullable<Exception> */) => any): any/* AttoJob */;
|
|
1084
1088
|
onAccountByAddresses(addresses: Array<AttoAddress>, onAccount: (p0: AttoAccount) => void, onCancel: (p0: Nullable<Error>/* Nullable<Exception> */) => any): any/* AttoJob */;
|
|
1085
1089
|
onReceivableByPublicKey(publicKey: AttoPublicKey, minAmount: AttoAmount | undefined, onReceivable: (p0: AttoReceivable) => any, onCancel: (p0: Nullable<Error>/* Nullable<Exception> */) => any): any/* AttoJob */;
|
|
1086
1090
|
onReceivableByAddresses(addresses: Array<AttoAddress>, minAmount: AttoAmount | undefined, onReceivable: (p0: AttoReceivable) => any, onCancel: (p0: Nullable<Error>/* Nullable<Exception> */) => any): any/* AttoJob */;
|
|
1087
1091
|
accountEntry(hash: AttoHash): Promise<AttoAccountEntry>;
|
|
1092
|
+
onAccountEntryAll(onAccountEntry: (p0: AttoAccountEntry) => any, onCancel: (p0: Nullable<Error>/* Nullable<Exception> */) => any): any/* AttoJob */;
|
|
1093
|
+
onAccountEntryByHash(hash: AttoHash, onAccountEntry: (p0: AttoAccountEntry) => any, onCancel: (p0: Nullable<Error>/* Nullable<Exception> */) => any): any/* AttoJob */;
|
|
1088
1094
|
onAccountEntryByPublicKey(publicKey: AttoPublicKey, fromHeight: AttoHeight | undefined, toHeight: Nullable<AttoHeight> | undefined, onAccountEntry: (p0: AttoAccountEntry) => any, onCancel: (p0: Nullable<Error>/* Nullable<Exception> */) => any): any/* AttoJob */;
|
|
1089
1095
|
onAccountEntryByHeightSearch(heightSearch: HeightSearch, onAccountEntry: (p0: AttoAccountEntry) => any, onCancel: (p0: Nullable<Error>/* Nullable<Exception> */) => any): any/* AttoJob */;
|
|
1090
1096
|
transaction(hash: AttoHash): Promise<AttoTransaction>;
|
|
1097
|
+
onTransactionAll(onTransaction: (p0: AttoTransaction) => any, onCancel: (p0: Nullable<Error>/* Nullable<Exception> */) => any): any/* AttoJob */;
|
|
1098
|
+
onTransactionByHash(hash: AttoHash, onTransaction: (p0: AttoTransaction) => any, onCancel: (p0: Nullable<Error>/* Nullable<Exception> */) => any): any/* AttoJob */;
|
|
1091
1099
|
onTransactionByPublicKey(publicKey: AttoPublicKey, fromHeight: AttoHeight | undefined, toHeight: Nullable<AttoHeight> | undefined, onTransaction: (p0: AttoTransaction) => any, onCancel: (p0: Nullable<Error>/* Nullable<Exception> */) => any): any/* AttoJob */;
|
|
1092
1100
|
onTransactionByHeightSearch(heightSearch: HeightSearch, onTransaction: (p0: AttoTransaction) => any, onCancel: (p0: Nullable<Error>/* Nullable<Exception> */) => any): any/* AttoJob */;
|
|
1093
1101
|
now(): Promise<AttoInstant>;
|
|
1094
1102
|
publish(transaction: AttoTransaction): Promise<void>;
|
|
1103
|
+
voterWeight(address: AttoAddress): Promise<any/* AttoVoterWeight */>;
|
|
1095
1104
|
}
|
|
1096
1105
|
export declare namespace AttoNodeClientAsync {
|
|
1097
1106
|
/** @deprecated $metadata$ is used for internal purposes, please don't use it in your code, because it can be removed at any moment */
|
|
@@ -1113,9 +1122,10 @@ export declare namespace AttoAccountEntryMonitorAsync {
|
|
|
1113
1122
|
export declare class AttoAccountMonitorAsync /* implements AutoCloseable */ {
|
|
1114
1123
|
private constructor();
|
|
1115
1124
|
get accountMonitor(): any/* AttoAccountMonitor */;
|
|
1116
|
-
|
|
1125
|
+
monitorAddressArray(addresses: Array<AttoAddress>): Promise<void>;
|
|
1117
1126
|
monitorAddress(address: AttoAddress): Promise<void>;
|
|
1118
|
-
getAccounts(): Promise<
|
|
1127
|
+
getAccounts(): Promise<Array<AttoAccount>>;
|
|
1128
|
+
onAccount(onAccount: (p0: AttoAccount) => any, onCancel: (p0: Nullable<Error>/* Nullable<Exception> */) => any): any/* AttoJob */;
|
|
1119
1129
|
onReceivable(minAmount: AttoAmount | undefined, onReceivable: (p0: AttoReceivable) => any, onCancel: (p0: Nullable<Error>/* Nullable<Exception> */) => any): any/* AttoJob */;
|
|
1120
1130
|
}
|
|
1121
1131
|
export declare namespace AttoAccountMonitorAsync {
|
|
@@ -1214,7 +1224,9 @@ export declare interface AttoSignerProvider {
|
|
|
1214
1224
|
};
|
|
1215
1225
|
}
|
|
1216
1226
|
/** @deprecated */
|
|
1217
|
-
export declare const initHook: {
|
|
1227
|
+
export declare const initHook: {
|
|
1228
|
+
get(): any;
|
|
1229
|
+
};
|
|
1218
1230
|
export declare class AttoNodeClientAsyncBuilder {
|
|
1219
1231
|
constructor(url: string);
|
|
1220
1232
|
headers(value: KtMap<string, string>): AttoNodeClientAsyncBuilder;
|