This repository has been archived by the owner on May 30, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 27
/
ledgercore_doc.js
4465 lines (4464 loc) · 184 KB
/
ledgercore_doc.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
// AUTOGENERATED FILE - DO NOT MODIFY!
// This file generated by Djinni
/**Class representing a Tezos transaction */
declare class NJSTezosLikeTransaction
{
/** Get type of operation (transaction, reveal ... cf TezosOperationTag) */
declare function getType(): TezosOperationTag;
/** Get the hash of the transaction. */
declare function getHash(): string;
/**
* Get Fees (in drop)
* It returns the sum of transaction fees and reveal fees (if it exists)
*/
declare function getFees(): NJSAmount;
/** get transaction fees (without reveal cost) */
declare function getTransactionFees(): NJSAmount;
/** get reveal fees if the sender envolved is not revealed, else 0 */
declare function getRevealFees(): NJSAmount;
/** Get destination XTZ. address */
declare function getReceiver(): ?NJSTezosLikeAddress;
/** Get XTZ. sender address */
declare function getSender(): NJSTezosLikeAddress;
/** Get amount of XTZ to send */
declare function getValue(): ?NJSAmount;
/** Serialize the transaction to its raw format. */
declare function serialize(): String;
/** Set signature of transaction, when a signature is set serialize method gives back serialized Tx */
declare function setSignature(signature: String);
/**
* Get the time when the transaction was issued or the time of the block including
* this transaction
*/
declare function getDate(): Date;
/** Get Signing public Key */
declare function getSigningPubKey(): String;
declare function getCounter(): NJSBigInt;
declare function getGasLimit(): NJSAmount;
declare function getStorageLimit(): NJSBigInt;
/** Get hash of block in which tx is included */
declare function getBlockHash(): ?string;
/** Get status of transaction: equals to 1 if succeeded, 0 otherwise */
declare function getStatus(): number;
}
/**Class representing a Tezos Operation */
declare class NJSTezosLikeOperation
{
/**
*Get operation's transaction
*@return TezosLikeTransaction object
*/
declare function getTransaction(): NJSTezosLikeTransaction;
}
/**Class representing Bitcoin block */
declare class NJSTezosLikeBlock
{
/**
*Hash of block
*@return string representing hash of this block
*/
declare function getHash(): string;
/**
*Height of block in blockchain
*@return 64 bits integer, height of block
*/
declare function getHeight(): number;
/**
*Timestamp when block was mined
*@return Date object, date when block was appended to blockchain
*/
declare function getTime(): Date;
}
declare class NJSTezosLikeTransactionBuilder
{
/**
* Set type of operation (transaction, origination, reveal ...)
* Default operation is "transaction" type
*/
declare function setType(type: TezosOperationTag): NJSTezosLikeTransactionBuilder;
/**
* Send funds to the given address. This method can be called multiple times to send to multiple addresses.
* @param amount The value to send
* @param address Address of the recipient
* @return A reference on the same builder in order to chain calls.
*/
declare function sendToAddress(amount: NJSAmount, address: string): NJSTezosLikeTransactionBuilder;
/**
* Send all available funds to the given address.
* @param address Address of the recipient
* @return A reference on the same builder in order to chain calls.
*/
declare function wipeToAddress(address: string): NJSTezosLikeTransactionBuilder;
/**
* Set fees (in drop) the originator is willing to pay
* Set transaction and (if needed) reveal fees with 'fees'
* equivalent to call both functions setTransactionFees(fees) and setRevealFees(fees)
* @return A reference on the same builder in order to chain calls.
*/
declare function setFees(fees: NJSAmount): NJSTezosLikeTransactionBuilder;
/**
* Set transaction fees (in drop) the originator is willing to pay (reveal is not included)
* @return A reference on the same builder in order to chain calls.
*/
declare function setTransactionFees(transactionFees: NJSAmount): NJSTezosLikeTransactionBuilder;
/**
* Set reveal fees (in drop) the originator is willing to pay
* @return A reference on the same builder in order to chain calls.
*/
declare function setRevealFees(revealFees: NJSAmount): NJSTezosLikeTransactionBuilder;
/**
* Set gas limit the originator is not willing to exceed.
* @return A reference on the same builder in order to chain calls.
*/
declare function setGasLimit(gasLimit: NJSAmount): NJSTezosLikeTransactionBuilder;
/**
* Set storage limit the originator is not willing to exceed.
* Reference : https://tezos.gitlab.io/zeronet/whitedoc/michelson.html
* @return A reference on the same builder in order to chain calls.
*/
declare function setStorageLimit(storageLimit: NJSBigInt): NJSTezosLikeTransactionBuilder;
/** Build a transaction from the given builder parameters. */
declare function build(callback: NJSTezosLikeTransactionCallback);
/**
* Creates a clone of this builder.
* @return A copy of the current builder instance.
*/
declare function clone(): NJSTezosLikeTransactionBuilder;
/** Reset the current instance to its initial state */
declare function reset();
static declare function parseRawUnsignedTransaction(currency: Currency, rawTransaction: String, protocolUpdate: string): NJSTezosLikeTransaction;
static declare function parseRawSignedTransaction(currency: Currency, rawTransaction: String, protocolUpdate: string): NJSTezosLikeTransaction;
}
/** Callback triggered by main completed task, returning optional result of template type T. */
declare class NJSTezosLikeTransactionCallback
{
/**
* Method triggered when main task complete.
* @params result optional of type T, non null if main task failed
* @params error optional of type Error, non null if main task succeeded
*/
declare function onCallback(result: ?NJSTezosLikeTransaction, error: ?Error);
}
/**Class representing a Tezos account */
declare class NJSTezosLikeAccount
{
declare function broadcastRawTransaction(transaction: String, callback: NJSStringCallback);
declare function broadcastTransaction(transaction: NJSTezosLikeTransaction, callback: NJSStringCallback);
declare function buildTransaction(): NJSTezosLikeTransactionBuilder;
/**
* Get needed storage to proceed a tx
* @param address to which we want to send tx
* @return needed storage to interact with address/contract
* Note: same note as for getGasPrice method on EthereumLikeAccount
*/
declare function getStorage(address: string, callback: NJSBigIntCallback);
/**
* Get estimated gas limit to set so the transaction will succeed
* The passed address could be implicit address or contract
* This estimation is based on X last incoming txs (to address) that succeeded
* Note: same note as for getFees method on BitcoinLikeAccount
*/
declare function getEstimatedGasLimit(address: string, callback: NJSBigIntCallback);
/** Get fees from network */
declare function getFees(callback: NJSBigIntCallback);
/** Get gas price from network */
declare function getGasPrice(callback: NJSBigIntCallback);
/** Get originated accounts by current account */
declare function getOriginatedAccounts(): Array<NJSTezosLikeOriginatedAccount>;
/** Get current delegate */
declare function getCurrentDelegate(callback: NJSStringCallback);
/**
* Get the balance of the account for a given token
* @param tokenAddress Address of the contract
*/
declare function getTokenBalance(tokenAddress: string, callback: NJSBigIntCallback);
}
/** Callback triggered by main completed task, returning optional result of template type T. */
declare class NJSStringCallback
{
/**
* Method triggered when main task complete.
* @params result optional of type T, non null if main task failed
* @params error optional of type Error, non null if main task succeeded
*/
declare function onCallback(result: ?string, error: ?Error);
}
/** Callback triggered by main completed task, returning optional result of template type T. */
declare class NJSBigIntCallback
{
/**
* Method triggered when main task complete.
* @params result optional of type T, non null if main task failed
* @params error optional of type Error, non null if main task succeeded
*/
declare function onCallback(result: ?NJSBigInt, error: ?Error);
}
/** Class representing originated accounts */
declare class NJSTezosLikeOriginatedAccount
{
/** Get address of originated account (prefixed with KT) */
declare function getAddress(): string;
/**
* Get publicKey of originated account
* Could be empty if not yet revealed
*/
declare function getPublicKey(): ?string;
/** Get balance of originated account */
declare function getBalance(callback: NJSAmountCallback);
/** Get balance history of originated account */
declare function getBalanceHistory(start: Date, end: Date, period: TimePeriod, callback: NJSAmountListCallback);
/**
* Know if possible to spend from this account
* By default originations from libcore set it to true
*/
declare function isSpendable(): boolean;
/**
* Know if possible to delegate from this account
* By default originations from libcore set it to true
*/
declare function isDelegatable(): boolean;
/** Get related operations to account */
declare function queryOperations(): NJSOperationQuery;
/** Get builder to construct transaction on originated account */
declare function buildTransaction(): NJSTezosLikeTransactionBuilder;
}
/** Callback triggered by main completed task, returning optional result of template type T. */
declare class NJSAmountCallback
{
/**
* Method triggered when main task complete.
* @params result optional of type T, non null if main task failed
* @params error optional of type Error, non null if main task succeeded
*/
declare function onCallback(result: ?NJSAmount, error: ?Error);
}
/** Callback triggered by main completed task, returning optional result as list of template type T. */
declare class NJSAmountListCallback
{
/**
* Method triggered when main task complete.
* @params result optional of type list<T>, non null if main task failed
* @params error optional of type Error, non null if main task succeeded
*/
declare function onCallback(result: ?Array<NJSAmount>, error: ?Error);
}
declare class NJSTezosConfiguration
{
}
declare class NJSTezosConfigurationDefaults
{
}
declare class NJSTezosLikeWallet
{
declare function isDelegate(address: string, callback: NJSBoolCallback);
}
/** Callback triggered by main completed task, returning optional result of template type T. */
declare class NJSBoolCallback
{
/**
* Method triggered when main task complete.
* @params result optional of type T, non null if main task failed
* @params error optional of type Error, non null if main task succeeded
*/
declare function onCallback(result: ?boolean, error: ?Error);
}
/**
* TODO: to be more accurate, all RippleLikeBlock classes should be renamed as RippleLikeLedger,
* since there is an analogy between block and ledger concepts it's ok for the moment ...
*Class representing a Ripple transaction
*/
declare class NJSRippleLikeTransaction
{
/** Get the hash of the transaction. */
declare function getHash(): string;
/** Get Fees (in drop) */
declare function getFees(): NJSAmount;
/** Get destination XRP address */
declare function getReceiver(): NJSRippleLikeAddress;
/** Get XRP sender address */
declare function getSender(): NJSRippleLikeAddress;
/** Get amount of XRP to send */
declare function getValue(): NJSAmount;
/** Serialize the transaction to its raw format. */
declare function serialize(): String;
/** Set signature of transaction, when a signature is set serialize method gives back serialized Tx */
declare function setSignature(rSignature: String, sSignature: String);
declare function setDERSignature(signature: String);
/**
* Get the time when the transaction was issued or the time of the block including
* this transaction
*/
declare function getDate(): Date;
/**
* Get block to which transaction belongs (was mined in)
*getBlock(): optional<RippleLikeBlock>;
* Get sequence of an account when tx was built (number of sent transactions from an account)
*/
declare function getSequence(): NJSBigInt;
/** Get Ledger's sequence in which the tx was included */
declare function getLedgerSequence(): NJSBigInt;
/** Get Signing public Key */
declare function getSigningPubKey(): String;
/** Get all memos associated with the transaction. */
declare function getMemos(): Array<RippleLikeMemo>;
/** Add a memo to a transaction. */
declare function addMemo(memo: RippleLikeMemo);
/** An arbitrary unsigned 32-bit integer that identifies a reason for payment or a non-Ripple account */
declare function getDestinationTag(): ?number;
/** Status of the transaction. */
declare function getStatus(): number;
}
/**Class representing a Ripple Operation */
declare class NJSRippleLikeOperation
{
/**
*Get operation's transaction
*@return RippleLikeTransaction object
*/
declare function getTransaction(): NJSRippleLikeTransaction;
}
/**Class representing Ripple block */
declare class NJSRippleLikeBlock
{
/**
*Hash of block
*@return string representing hash of this block
*/
declare function getHash(): string;
/**
*Height of block in blockchain
*@return 64 bits integer, height of block
*/
declare function getHeight(): number;
/**
*Timestamp when block was mined
*@return Date object, date when block was appended to blockchain
*/
declare function getTime(): Date;
}
declare class NJSRippleLikeTransactionBuilder
{
/**
* Send funds to the given address. This method can be called multiple times to send to multiple addresses.
* @param amount The value to send
* @param address Address of the recipient
* @return A reference on the same builder in order to chain calls.
*/
declare function sendToAddress(amount: NJSAmount, address: string): NJSRippleLikeTransactionBuilder;
/**
* Send all available funds to the given address.
* @param address Address of the recipient
* @return A reference on the same builder in order to chain calls.
*/
declare function wipeToAddress(address: string): NJSRippleLikeTransactionBuilder;
/**
* Set fees (in drop) the originator is willing to pay
* @return A reference on the same builder in order to chain calls.
*/
declare function setFees(fees: NJSAmount): NJSRippleLikeTransactionBuilder;
/**
* Add a memo.
* @return A reference on the same builder in order to chain calls.
*/
declare function addMemo(memo: RippleLikeMemo): NJSRippleLikeTransactionBuilder;
/** An arbitrary unsigned 32-bit integer that identifies a reason for payment or a non-Ripple account */
declare function setDestinationTag(tag: number): NJSRippleLikeTransactionBuilder;
/** Build a transaction from the given builder parameters. */
declare function build(callback: NJSRippleLikeTransactionCallback);
/**
* Creates a clone of this builder.
* @return A copy of the current builder instance.
*/
declare function clone(): NJSRippleLikeTransactionBuilder;
/** Reset the current instance to its initial state */
declare function reset();
static declare function parseRawUnsignedTransaction(currency: Currency, rawTransaction: String): NJSRippleLikeTransaction;
static declare function parseRawSignedTransaction(currency: Currency, rawTransaction: String): NJSRippleLikeTransaction;
}
/** Callback triggered by main completed task, returning optional result of template type T. */
declare class NJSRippleLikeTransactionCallback
{
/**
* Method triggered when main task complete.
* @params result optional of type T, non null if main task failed
* @params error optional of type Error, non null if main task succeeded
*/
declare function onCallback(result: ?NJSRippleLikeTransaction, error: ?Error);
}
/**Class representing a Ripple account */
declare class NJSRippleLikeAccount
{
declare function broadcastRawTransaction(transaction: String, callback: NJSStringCallback);
declare function broadcastTransaction(transaction: NJSRippleLikeTransaction, callback: NJSStringCallback);
declare function buildTransaction(): NJSRippleLikeTransactionBuilder;
/**
* Get fees from network
* Note: it would have been better to have this method on RippleLikeWallet
* but since RippleLikeWallet is not used anywhere, it's better to keep all
* specific methods under the same specific class so it will be easy to segratate
* when the right time comes !
*/
declare function getFees(callback: NJSAmountCallback);
/**
* Get base reserve (dust to leave on an XRP account) from network
* Note: same note as above
*/
declare function getBaseReserve(callback: NJSAmountCallback);
/**
* Check whether an account has been activated or not
* Here activation, means that the XRP account received a first transaction with a minimum amount
* greater or equal to XRP base reserve
* @param: address to check
* @return: true if valid address and has been activated, false otherwise
*/
declare function isAddressActivated(address: string, isActivated: NJSBoolCallback);
}
declare class NJSRippleConfiguration
{
}
declare class NJSRippleConfigurationDefaults
{
}
/**Class implementing secp256k1 used in Bitcoin. */
declare class NJSSecp256k1
{
/**
* Create an instance of Secp256k1.
* @return Secp256k1 instance
*/
static declare function createInstance(): NJSSecp256k1;
/**
* Generates public key from private key.
* @param privKey 32 byte private key
* @param compress get compressed (35 bytes) or uncompressed (65 bytes)
* @return public key can be compressed (35 bytes starting with 02 or 03) or un compressed (65 bytes starting with 04)
*/
declare function computePubKey(privKey: String, compress: boolean): String;
/**
* Generates uncompressed public key from compressed public key.
* @param pubKey 33 byte private key (starting with 02 or 03)
* @return uncompressed public key (65 bytes starting with 04)
*/
declare function computeUncompressedPubKey(pubKey: String): String;
/**
* Signs message using a given private key.
* @param privKey 32 bytes private key
* @param data 32 bytes message to sign
* @return 32 bytes signed message
*/
declare function sign(privKey: String, data: String): String;
/**
* Check if message was signed with given signature and public key.
* @param data 32 bytes signed message
* @param signature 32 bytes signature (generated from private key)
* @param oubkey 32 bytes public key
* @return true if message was signed with signature and public key (both issued from same private key)
*/
declare function verify(data: String, signature: String, pubKey: String): boolean;
static declare function newInstance(): NJSSecp256k1;
}
/** All available blockchain networks parameters. */
declare class NJSNetworks
{
/** The Bitcoin network parameters. */
static declare function bitcoin(): BitcoinLikeNetworkParameters;
/** The Cosmos network parameters. */
static declare function cosmos(chainID: string): CosmosLikeNetworkParameters;
/** The Ethereum network parameters. */
static declare function ethereum(): EthereumLikeNetworkParameters;
/** The Ripple network parameters. */
static declare function ripple(): RippleLikeNetworkParameters;
/** The Tezos network parameters. */
static declare function tezos(): TezosLikeNetworkParameters;
}
/** Helper class for commonly used crypto algorithms. */
declare class NJSHashAlgorithmHelper
{
/**
* RACE Integrity Primitives Evaluation Message Digest (used in Bitcoin).
* @param data in bytes, message to hash
* @return 160 bits hashed message
*/
declare function ripemd160(data: String): String;
/**
* Secure Hash Algorithm (used in Bitcoin).
* @param data in bytes, message to hash
* @return 256 bits hashed message
*/
declare function sha256(data: String): String;
/**
* Hash algorithm used in ethereum.
* @param data in bytes, message to hash
* @return 256 bits hashed message
*/
declare function keccak256(data: String): String;
}
declare class NJSStellarLikeBlock
{
}
declare class NJSStellarLikeMemo
{
declare function getMemoType(): StellarLikeMemoType;
/** Get the value of the memo as string. Fail if the memo is not with type MEMO_TEXT */
declare function getMemoText(): string;
/** Get the value of the memo as BigInt. Fail if the memo is not with type MEMO_ID */
declare function getMemoId(): NJSBigInt;
/** Get the value of the memo as byte array. Fail if the memo is not with type MEMO_HASH */
declare function getMemoHash(): String;
/** Get the value of the memo as byte array. Fail if the memo is not with type MEMO_RETURN */
declare function getMemoReturn(): String;
/**
* Create a string version of the memo, no matter which underlying type it holds.
* For MEMO_TEXT returns memo value.
* For MEMO_ID, return a uint64 as string (base 10).
* For MEMO_HASH, MEMO_RETURN, returns a hex encoded string.
* For MEMO_NONE, returns an empty string
*/
declare function memoValuetoString(): string;
}
declare class NJSStellarLikeTransaction
{
declare function toRawTransaction(): String;
/** Returns the payload which should be signed by the user in order to send the transaction. */
declare function toSignatureBase(): String;
/** Add a new signature to the transaction envelope */
declare function putSignature(signature: String, address: NJSAddress);
/** Returns the author of the transaction */
declare function getSourceAccount(): NJSAddress;
/** Returns the sequence of the source account used for this transaction */
declare function getSourceAccountSequence(): NJSBigInt;
/** Returns the fee paid for this transaction to be validated */
declare function getFee(): NJSAmount;
/** Returns the transaction memo */
declare function getMemo(): NJSStellarLikeMemo;
}
declare class NJSStellarLikeTransactionBuilder
{
declare function addNativePayment(address: string, amount: NJSAmount): NJSStellarLikeTransactionBuilder;
declare function addCreateAccount(address: string, amount: NJSAmount): NJSStellarLikeTransactionBuilder;
declare function setBaseFee(baseFee: NJSAmount): NJSStellarLikeTransactionBuilder;
declare function setTextMemo(text: string): NJSStellarLikeTransactionBuilder;
declare function setNumberMemo(number: NJSBigInt): NJSStellarLikeTransactionBuilder;
declare function setHashMemo(hash: String): NJSStellarLikeTransactionBuilder;
declare function setReturnMemo(value: String): NJSStellarLikeTransactionBuilder;
declare function setSequence(sequence: NJSBigInt): NJSStellarLikeTransactionBuilder;
declare function build(callback: NJSStellarLikeTransactionCallback);
static declare function parseRawTransaction(currency: Currency, rawTransaction: String): NJSStellarLikeTransaction;
static declare function parseSignatureBase(currency: Currency, rawTransaction: String): NJSStellarLikeTransaction;
}
/** Callback triggered by main completed task, returning optional result of template type T. */
declare class NJSStellarLikeTransactionCallback
{
/**
* Method triggered when main task complete.
* @params result optional of type T, non null if main task failed
* @params error optional of type Error, non null if main task succeeded
*/
declare function onCallback(result: ?NJSStellarLikeTransaction, error: ?Error);
}
declare class NJSStellarLikeOperation
{
/** Get the underlying operation information */
declare function getRecord(): StellarLikeOperationRecord;
/** Get the underlying transaction in which this operation can be found. */
declare function getTransaction(): NJSStellarLikeTransaction;
}
declare class NJSStellarLikeAccount
{
/**
* Checks if the current account exists on the stellar Network. If it doesn't the account needs to be activated by
* sending an account creation operation with an amount of at least the base reserve.
* @return Callback with a boolean indicating if the account exists on the Stellar network or not.
*/
declare function exists(callback: NJSBoolCallback);
/**
* Create a new transaction builder to create new transaction
* @return The transaction builder
*/
declare function buildTransaction(): NJSStellarLikeTransactionBuilder;
/** Broadcast the given raw transaction to the network. */
declare function broadcastRawTransaction(tx: String, callback: NJSStringCallback);
/** Get base reserve of the network */
declare function getBaseReserve(callback: NJSAmountCallback);
/** Get sequence number to be used in the next transaction */
declare function getSequence(callback: NJSBigIntCallback);
/** Get recommended fee */
declare function getFeeStats(callback: NJSStellarLikeFeeStatsCallback);
/** Get signers for this account */
declare function getSigners(callback: NJSStellarLikeAccountSignerListCallback);
}
/** Callback triggered by main completed task, returning optional result of template type T. */
declare class NJSStellarLikeFeeStatsCallback
{
/**
* Method triggered when main task complete.
* @params result optional of type T, non null if main task failed
* @params error optional of type Error, non null if main task succeeded
*/
declare function onCallback(result: ?StellarLikeFeeStats, error: ?Error);
}
/** Callback triggered by main completed task, returning optional result as list of template type T. */
declare class NJSStellarLikeAccountSignerListCallback
{
/**
* Method triggered when main task complete.
* @params result optional of type list<T>, non null if main task failed
* @params error optional of type Error, non null if main task succeeded
*/
declare function onCallback(result: ?Array<StellarLikeAccountSigner>, error: ?Error);
}
declare class NJSStellarLikeWallet
{
declare function exists(address: string, callback: NJSBoolCallback);
}
declare class NJSStellarLikeAddress
{
}
declare class NJSAlgorandBlockchainExplorerEngines
{
}
declare class NJSAlgorandTransaction
{
declare function getId(): string;
declare function getType(): string;
declare function getSender(): string;
declare function getFee(): string;
declare function getNote(): string;
declare function getRound(): string;
declare function getSenderRewards(): string;
declare function getReceiverRewards(): string;
declare function getCloseRewards(): string;
declare function setSender(sender: string);
declare function setFee(fee: string);
declare function setNote(note: string);
declare function setPaymentInfo(info: AlgorandPaymentInfo);
declare function getPaymentInfo(): AlgorandPaymentInfo;
declare function setParticipationInfo(info: AlgorandParticipationInfo);
declare function getParticipationInfo(): AlgorandParticipationInfo;
declare function setAssetConfigurationInfo(info: AlgorandAssetConfigurationInfo);
declare function getAssetConfigurationInfo(): AlgorandAssetConfigurationInfo;
declare function setAssetTransferInfo(info: AlgorandAssetTransferInfo);
declare function getAssetTransferInfo(): AlgorandAssetTransferInfo;
declare function setAssetFreezeInfo(info: AlgorandAssetFreezeInfo);
declare function getAssetFreezeInfo(): AlgorandAssetFreezeInfo;
/** Serialize the transaction in MsgPack format */
declare function serialize(): String;
declare function setSignature(signature: String);
}
declare class NJSAlgorandOperation
{
declare function getTransaction(): NJSAlgorandTransaction;
declare function getAlgorandOperationType(): AlgorandOperationType;
declare function getRewards(): string;
declare function getAssetAmount(): string;
}
declare class NJSAlgorandAddress
{
static declare function fromPublicKey(pubkey: String): string;
static declare function toPublicKey(address: string): String;
}
declare class NJSAlgorandAccount
{
/**
* Get the maximum amount spendable in one transaction
* @param callback, Callback returning the maximum amount spendable
* @param operationType, the type of the operation
*/
declare function getSpendableBalance(operationType: AlgorandOperationType, callback: NJSAmountCallback);
/**
* Get information about a specific asset
* @param assetId, the unique identifier of the asset to look for
* @param callback, Callback returning the information about the queried asset
*/
declare function getAsset(assetId: string, callback: NJSAlgorandAssetParamsCallback);
/**
* Check if address has a specific asset
* @param address, the address to check
* @param assetId, the unique identifier of the asset to look for
* @param callback, Callback returning the true if the address hold the asset
*/
declare function hasAsset(address: string, assetId: string, callback: NJSBoolCallback);
/**
* Check if address can receive the given amount:
* it may not be enough to reach the minimum balance, if the account has 0 ALGO
* @param address, the address to check
* @param amount, the amount to test
* @param callback, Callback returning the true if the address hold the asset
*/
declare function isAmountValid(address: string, amount: string, callback: NJSBoolCallback);
/**
* Get balance of account for a particular asset.
* @param assetId, the unique identifier of the asset on the algorand network
* @param callback, if getAssetBalance succeeds, Callback returning an Amount object which represents account's balance
*/
declare function getAssetBalance(assetId: string, callback: NJSAlgorandAssetAmountCallback);
/**
* Get balance of account for a particular asset at a precise interval with a certain granularity
* @param assetId, the unique identifier of the asset on the algorand network
* @param start, lower bound of search range
* @param end, upper bound of search range
* @param precision, granularity at which we want results
* @param callback, ListCallback returning a list of Amount objects which represents account's balance
*/
declare function getAssetBalanceHistory(assetId: string, start: string, end: string, period: TimePeriod, callback: NJSAlgorandAssetAmountListCallback);
/**
* Get balances of all assets to which account is registered
* @param callback, ListCallback returning a list of AlgorandAssetAmount objects representing the different balances
*/
declare function getAssetsBalances(callback: NJSAlgorandAssetAmountListCallback);
/**
* Get information about the assets created by account
* @param callback, ListCallback returning a list of AlgorandAssetParams objects representing the assets created by account
*/
declare function getCreatedAssets(callback: NJSAlgorandAssetParamsListCallback);
/**
* Get the pending rewards for account
* @param callback, Callback returning the amount of pending rewards in MicroAlgos
*/
declare function getPendingRewards(callback: NJSAmountCallback);
/**
* Get the total rewards of MicroAlgos account has received, including pending rewards.
* @param callback, Callback returning the total rewards in MicroAlgos.
*/
declare function getTotalRewards(callback: NJSAmountCallback);
/**
* Get an estimation (in MicroAlgos) of the fees needed to broadcast a given transaction to the algorand network
* @param transaction, the transaction for which fees are estimated
* @param callback, Callback returning the fees in MicroAlgos for the specified transaction
*/
declare function getFeeEstimate(transaction: NJSAlgorandTransaction, callback: NJSAmountCallback);
/**
* Build a raw signed transaction from a raw unsigned transaction and the signature
* @param rawUnsignedTransaction, the msgpack-encoded unsigned transaction
* @param signature, the signature of the transaction
* @return binary, the msgpack-encoded signed transaction
*/
declare function buildRawSignedTransaction(rawUnsignedTransaction: String, signature: String): String;
/**
* Broadcast a raw transaction to the algorand network
* @param transaction, the msgpack-encoded transaction
* @param callback, Callback returning the id of the transaction in case of success, an error message otherwise
*/
declare function broadcastRawTransaction(transaction: String, callback: NJSStringCallback);
/**
* Broadcast an AlgorandTransaction object to the algorand network
* @param transaction, the transaction to broadcast
* @param callback, Callback returning the fees in MicroAlgos for the specified transaction
*/
declare function broadcastTransaction(transaction: NJSAlgorandTransaction, callback: NJSStringCallback);
/**
* Create a new transaction
* @param callback, The new transaction
*/
declare function createTransaction(callback: NJSAlgorandTransactionCallback);
}
/** Callback triggered by main completed task, returning optional result of template type T. */
declare class NJSAlgorandAssetParamsCallback
{
/**
* Method triggered when main task complete.
* @params result optional of type T, non null if main task failed
* @params error optional of type Error, non null if main task succeeded
*/
declare function onCallback(result: ?AlgorandAssetParams, error: ?Error);
}
/** Callback triggered by main completed task, returning optional result of template type T. */
declare class NJSAlgorandAssetAmountCallback
{
/**
* Method triggered when main task complete.
* @params result optional of type T, non null if main task failed
* @params error optional of type Error, non null if main task succeeded
*/
declare function onCallback(result: ?AlgorandAssetAmount, error: ?Error);
}
/** Callback triggered by main completed task, returning optional result as list of template type T. */
declare class NJSAlgorandAssetAmountListCallback
{
/**
* Method triggered when main task complete.
* @params result optional of type list<T>, non null if main task failed
* @params error optional of type Error, non null if main task succeeded
*/
declare function onCallback(result: ?Array<AlgorandAssetAmount>, error: ?Error);
}
/** Callback triggered by main completed task, returning optional result as list of template type T. */
declare class NJSAlgorandAssetParamsListCallback
{
/**
* Method triggered when main task complete.
* @params result optional of type list<T>, non null if main task failed
* @params error optional of type Error, non null if main task succeeded
*/
declare function onCallback(result: ?Array<AlgorandAssetParams>, error: ?Error);
}
/** Callback triggered by main completed task, returning optional result of template type T. */
declare class NJSAlgorandTransactionCallback
{
/**
* Method triggered when main task complete.
* @params result optional of type T, non null if main task failed
* @params error optional of type Error, non null if main task succeeded
*/
declare function onCallback(result: ?NJSAlgorandTransaction, error: ?Error);
}
declare class NJSAlgorandWallet
{
}
/** Class representing an event. */
declare class NJSEvent
{
/**
* Get event code (for more details, please refer to EventCode enum).
* @return EventCode enum entry
*/
declare function getCode(): EventCode;
/**
* Get payload of event.
* @return DynamicObject object
*/
declare function getPayload(): NJSDynamicObject;
/**
* Tell whether the event is a sticky one.
* @return bool
*/
declare function isSticky(): boolean;
/**
* If event is sticky, return sticky tag.
* @return 32 bits integer
*/
declare function getStickyTag(): number;
/**
* Create a new instance of Event class.
* @param code, EventCode enum entry
* @param payload, DynamicObject object
* @return Event instance
*/
static declare function newInstance(code: EventCode, payload: NJSDynamicObject): NJSEvent;
}
/** Class respresenting an event receiver. */
declare class NJSEventReceiver
{
/**
* Method triggered when an event occurs.
* @param event, Event object that triggers this method
*/
declare function onEvent(event: NJSEvent);
}
/** Class representing an event bus through which a receiver gets notified. */
declare class NJSEventBus
{
/**
* Subscribe an event receiver to the event bus.
* @param context, ExecutionContext object, execution context in which receiver will be notified
* @param reveiver, EventReceiver object, receiver that event bu will notify
*/
declare function subscribe(context: NJSExecutionContext, receiver: NJSEventReceiver);
/**
* Unsubscribe an event receiver from the event bus.
* @param receiver, EventReceiver object, receiver to unsubscribe
*/
declare function unsubscribe(receiver: NJSEventReceiver);
}
/** Class representing an event publisher. */
declare class NJSEventPublisher
{
/**
* Get event bus through which publisher broadcast its events.
* @return EventBus object
*/
declare function getEventBus(): NJSEventBus;
/**
* Broadcast an event through eventbus (to all subscribed receivers to this EventBus).
* @param event, Event object
*/
declare function post(event: NJSEvent);
/**
* Same as post method but with an sticky event.
* @param event, Event object
* @param tag, 32 bits integer, tag of sticky event
*/
declare function postSticky(event: NJSEvent, tag: number);
/**
* Relay an event to another EventBus (other than EventPublisher's event bus).
* @param bus, EventBus object, through which we want to broadcast EventPublisher's event to EventPublisher's receiver
*/
declare function relay(bus: NJSEventBus);
/**
* Create a new instance of EventPublisher class.
* @param context, executionContext object, context in which event publisher broadcast its events
*/
static declare function newInstance(context: NJSExecutionContext): NJSEventPublisher;
}
/** Class of synchronization status constants. */
declare class NJSSynchronizationStatus
{
}
declare class NJSDerivationPath
{
/** Get the number of element in this path. */
declare function getDepth(): number;
/** Get the child num at the given index in the path. */
declare function getChildNum(index: number): number;
/**
* Get the child num at the given index in the path. If the child num is hardened, returns it
* without the hardened marker bit.
*/
declare function getUnhardenedChildNum(index: number): number;
/** Return true if the given index in the path is an hardened child num. */
declare function isHardened(index: number): boolean;
/** Serialize the given path to a human readable string like "44'/0'/0'/0/0". */
declare function toString(): string;
/**
* Return a derivation path without the last element, e.g. the parent of "44'/0'/0'/0/0" is
* "44'/0'/0'/0".
*/
declare function getParent(): NJSDerivationPath;
/** Return an array where which item is a child num of the path. */
declare function toArray(): Array<number>;
static declare function parse(path: string): NJSDerivationPath;
}
/** The trust indicator of an operation. */
declare class NJSTrustIndicator
{
declare function getTrustWeight(): number;
declare function getTrustLevel(): TrustLevel;
declare function getConflictingOperationUids(): Array<string>;
declare function getOrigin(): string;
}
/** Class representing an operation. */
declare class NJSOperation
{
/**
* Get id's operation.
* @return string
*/
declare function getUid(): string;
/**
* Get account's index in user's wallet.
* @return 32-bit integer
*/
declare function getAccountIndex(): number;
/**
* Get type of operation.
* @return OperationType object (for more details refer to OperationType)
*/
declare function getOperationType(): OperationType;
/**
* Return date on which operation was issued.
* @return date object
*/
declare function getDate(): Date;
/**
* Get senders of operation.
* @return List of string, list of all senders
*/
declare function getSenders(): Array<string>;
/**
* Get recipients of operation.
* @return List of string, list of all recipients
*/
declare function getRecipients(): Array<string>;
/**
* Get account-filtered recipients list associated with the operation.
*
* This function will filter recipients to retain only the ones that are owned by the current
* account.
*/
declare function getSelfRecipients(): Array<string>;
/**
* Get amount of operation.
* @return Amount object
*/
declare function getAmount(): NJSAmount;
/**
* Get fees of operation.
* @return Optional Amount object
*/
declare function getFees(): ?NJSAmount;
/**
* Get preferences of operation.
* @return Prefences object
*/
declare function getPreferences(): NJSPreferences;
/**
* Get trust indicator of operation.
* @return TrustIndicator object
*/
declare function getTrust(): NJSTrustIndicator;
/**
* Get block height on which operation was included.
* @return Optional 64-bit integer, height of block in which operation was validated
*/
declare function getBlockHeight(): ?number;
/**
* Convert operation as Bitcoin operation.
* @return BitcoinLikeOperation object
*/
declare function asBitcoinLikeOperation(): NJSBitcoinLikeOperation;
/**