@aioha/tx-digest 2.0.0 → 2.0.1
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 +48 -0
- package/helpers/serializer.js +7 -6
- package/index.d.ts +1 -0
- package/package.json +1 -1
package/README.md
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
# @aioha/tx-digest
|
|
2
|
+
|
|
3
|
+
Hive transaction serializer and digest. Useful for generating ID for a transaction. Serializers extracted from hive-tx and adapted for HF26 serialization. Intended for browser use as it uses `window.crypto` for sha256.
|
|
4
|
+
|
|
5
|
+
## Usage
|
|
6
|
+
|
|
7
|
+
```js
|
|
8
|
+
import { transactionDigest } from '@aioha/tx-digest'
|
|
9
|
+
|
|
10
|
+
// https://hafscan.techcoderx.com/tx/543058b4465cd93132b2843b751d5dcdd8efd341
|
|
11
|
+
const recurrent_transfer = {
|
|
12
|
+
ref_block_num: 23679,
|
|
13
|
+
ref_block_prefix: 291568045,
|
|
14
|
+
expiration: '2025-11-20T07:59:08',
|
|
15
|
+
operations: [
|
|
16
|
+
{
|
|
17
|
+
type: 'recurrent_transfer_operation',
|
|
18
|
+
value: {
|
|
19
|
+
to: 'techcoderx.vsc',
|
|
20
|
+
from: 'techcoderx',
|
|
21
|
+
memo: '',
|
|
22
|
+
amount: {
|
|
23
|
+
nai: '@@000000021',
|
|
24
|
+
amount: '2',
|
|
25
|
+
precision: 3
|
|
26
|
+
},
|
|
27
|
+
executions: 5,
|
|
28
|
+
extensions: [
|
|
29
|
+
{
|
|
30
|
+
type: 'recurrent_transfer_pair_id',
|
|
31
|
+
value: {
|
|
32
|
+
pair_id: 1
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
],
|
|
36
|
+
recurrence: 48
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
],
|
|
40
|
+
signatures: [
|
|
41
|
+
'1f3f2ddfc755936e0b998c78a1aec35a9663d1d9011cd4a83be84c6340f1b8689826fbd0e32c918afca38ab1e6ec44eac85a0e281c39bf1400f5e53c8b810a3bf5'
|
|
42
|
+
],
|
|
43
|
+
extensions: []
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
const serialized = await transactionDigest(recurrent_transfer)
|
|
47
|
+
console.log(serialized.txId) // 85db372428a47aba8aeb154df8650a900c612fa5
|
|
48
|
+
```
|
package/helpers/serializer.js
CHANGED
|
@@ -3,7 +3,8 @@ import { HexBuffer } from './HexBuffer.js'
|
|
|
3
3
|
|
|
4
4
|
const Extensions = {
|
|
5
5
|
comment_payout_beneficiaries: 0,
|
|
6
|
-
update_proposal_end_date: 1
|
|
6
|
+
update_proposal_end_date: 1,
|
|
7
|
+
recurrent_transfer_pair_id: 1
|
|
7
8
|
}
|
|
8
9
|
|
|
9
10
|
const NaiUint32 = (nai) => {
|
|
@@ -369,14 +370,14 @@ OperationSerializers.escrow_release_operation = OperationDataSerializer(29, [
|
|
|
369
370
|
OperationSerializers.escrow_transfer_operation = OperationDataSerializer(27, [
|
|
370
371
|
['from', StringSerializer],
|
|
371
372
|
['to', StringSerializer],
|
|
372
|
-
['agent', StringSerializer],
|
|
373
|
-
['escrow_id', UInt32Serializer],
|
|
374
373
|
['hbd_amount', AssetSerializer],
|
|
375
374
|
['hive_amount', AssetSerializer],
|
|
375
|
+
['escrow_id', UInt32Serializer],
|
|
376
|
+
['agent', StringSerializer],
|
|
376
377
|
['fee', AssetSerializer],
|
|
378
|
+
['json_meta', StringSerializer],
|
|
377
379
|
['ratification_deadline', DateSerializer],
|
|
378
|
-
['escrow_expiration', DateSerializer]
|
|
379
|
-
['json_meta', StringSerializer]
|
|
380
|
+
['escrow_expiration', DateSerializer]
|
|
380
381
|
])
|
|
381
382
|
|
|
382
383
|
OperationSerializers.feed_publish_operation = OperationDataSerializer(7, [
|
|
@@ -559,7 +560,7 @@ OperationSerializers.recurrent_transfer_operation = OperationDataSerializer(49,
|
|
|
559
560
|
['memo', StringSerializer],
|
|
560
561
|
['recurrence', UInt16Serializer],
|
|
561
562
|
['executions', UInt16Serializer],
|
|
562
|
-
['extensions', ArraySerializer(
|
|
563
|
+
['extensions', ArraySerializer(ExtensionSerializer(ObjectSerializer([['pair_id', UInt8Serializer]])))]
|
|
563
564
|
])
|
|
564
565
|
|
|
565
566
|
const OperationSerializer = (buffer, operation) => {
|
package/index.d.ts
CHANGED