@@ -216,6 +216,33 @@ export type EdgeDenomination = {
216
216
symbol ?: string
217
217
}
218
218
219
+ /**
220
+ * Information used to display a token or currency to the user.
221
+ */
222
+ export type EdgeToken = {
223
+ // The short code used on exchanges, such as "BTC":
224
+ currencyCode : string ,
225
+
226
+ // How many decimal places to shift the native amount.
227
+ // The first item in this array is always the default for exchanges:
228
+ denominations : EdgeDenomination [ ] ,
229
+
230
+ // The full marketing name, such as "Bitcoin":
231
+ displayName : string ,
232
+
233
+ // Each currency plugin decides what this contains,
234
+ // such as a contract address.
235
+ // The primary currency for a network, such as BTC or ETH,
236
+ // will set this field to `undefined`:
237
+ networkLocation : JsonObject | void
238
+ }
239
+
240
+ export type EdgeTokenMap = {
241
+ // Each currency plugin decides how to generate this ID,
242
+ // such as by using the contract address:
243
+ [ tokenId : string ] : EdgeToken
244
+ }
245
+
219
246
/**
220
247
* Available tokens stored in the `EdgeCurrencyInfo`,
221
248
* or parsed out of URI's.
@@ -264,10 +291,10 @@ type EdgeObjectTemplate = Array<
264
291
export type EdgeCurrencyInfo = {
265
292
// Basic currency information:
266
293
+ pluginId : string ,
267
- displayName : string ,
294
+ displayName : string , // Name for the chain
268
295
walletType : string ,
269
296
270
- // Native token information:
297
+ // Native token information, Display only !!!! :
271
298
currencyCode : string ,
272
299
denominations : EdgeDenomination [ ] ,
273
300
@@ -281,19 +308,17 @@ export type EdgeCurrencyInfo = {
281
308
memoMaxValue ?: string , // Max numerical value, if supported
282
309
memoType ?: 'text' | 'number' | 'other' , // undefined means no memo support
283
310
284
- // Configuration options:
285
- defaultSettings : JsonObject ,
286
- metaTokens : EdgeMetaToken [ ] ,
287
-
288
311
// Explorers:
289
312
addressExplorer : string ,
290
313
blockExplorer ?: string ,
291
314
transactionExplorer : string ,
292
315
xpubExplorer ?: string ,
293
316
294
- // Images:
295
- symbolImage ?: string ,
296
- symbolImageDarkMono ?: string
317
+ // Deprecated:
318
+ defaultSettings : JsonObject , // The default user settings are `{}`
319
+ metaTokens : EdgeMetaToken [ ] , // Use `EdgeCurrencyPlugin.getBuiltinTokens`
320
+ symbolImage ?: string , // The GUI handles this now
321
+ symbolImageDarkMono ?: string // The GUI handles this now
297
322
}
298
323
299
324
// spending ------------------------------------------------------------
@@ -310,6 +335,7 @@ export type EdgeMetadata = {
310
335
}
311
336
312
337
export type EdgeNetworkFee = {
338
+ + tokenId : string , // The core can synthesize this?
313
339
+ currencyCode : string ,
314
340
+ nativeAmount : string
315
341
}
@@ -335,6 +361,8 @@ export type EdgeTxSwap = {
335
361
}
336
362
337
363
export type EdgeTransaction = {
364
+ tokenId : string , // The core can synthesize this?
365
+
338
366
// Amounts:
339
367
currencyCode : string ,
340
368
nativeAmount : string ,
@@ -395,7 +423,8 @@ export type EdgePaymentProtocolInfo = {
395
423
396
424
export type EdgeSpendInfo = {
397
425
// Basic information:
398
- currencyCode ?: string ,
426
+ currencyCode ?: string , // Deprecated
427
+ tokenId ?: string ,
399
428
privateKeys ?: string [ ] ,
400
429
spendTargets : EdgeSpendTarget [ ] ,
401
430
@@ -502,11 +531,13 @@ export type EdgeEncodeUri = {
502
531
// options -------------------------------------------------------------
503
532
504
533
export type EdgeCurrencyCodeOptions = {
505
- currencyCode ?: string
534
+ currencyCode ?: string , // Deprecated
535
+ tokenId ?: string
506
536
}
507
537
508
538
export type EdgeGetTransactionsOptions = {
509
- currencyCode ?: string ,
539
+ currencyCode ?: string , // Deprecated
540
+ tokenId ?: string ,
510
541
startIndex ?: number ,
511
542
startEntries ?: number ,
512
543
startDate ?: Date ,
@@ -522,19 +553,26 @@ export type EdgeGetTransactionsOptions = {
522
553
export type EdgeCurrencyEngineCallbacks = {
523
554
+ onAddressChanged : ( ) => void ,
524
555
+ onAddressesChecked : ( progressRatio : number ) = > void ,
525
- + onBalanceChanged : ( currencyCode : string , nativeBalance : string ) = > void ,
556
+ + onBalanceChanged : ( currencyCode : string , nativeBalance : string ) = > void , // Deprecated. Use onTokenBalanceChanged.
526
557
+ onBlockHeightChanged : ( blockHeight : number ) => void ,
527
558
+ onStakingStatusChanged : ( status : EdgeStakingStatus ) = > void ,
559
+ + onTokenBalanceChanged : ( tokenId : string , nativeBalance : string ) = > void ,
528
560
+ onTransactionsChanged : ( transactions : EdgeTransaction [ ] ) = > void ,
529
561
+ onTxidsChanged : ( txids : EdgeTxidMap ) = > void ,
530
562
+ onWcNewContractCall : ( payload : JsonObject ) = > void
531
563
}
532
564
533
565
export type EdgeCurrencyEngineOptions = {
534
566
callbacks : EdgeCurrencyEngineCallbacks ,
535
- log : EdgeLog , // Wallet-scoped logging
567
+
568
+ // Wallet-scoped IO objects:
569
+ log : EdgeLog ,
536
570
walletLocalDisklet : Disklet ,
537
571
walletLocalEncryptedDisklet : Disklet ,
572
+
573
+ // User settings:
574
+ customTokens : EdgeTokenMap ,
575
+ enabledTokenIds : string [ ] ,
538
576
userSettings : JsonObject | void
539
577
}
540
578
@@ -553,23 +591,20 @@ export type EdgeCurrencyEngine = {
553
591
554
592
// Chain state:
555
593
+ getBlockHeight : ( ) = > number ,
556
- + getBalance : ( opts : EdgeCurrencyCodeOptions ) => string ,
594
+ + getBalance : ( opts : EdgeCurrencyCodeOptions ) => string , // Deprecated, never used
557
595
+ getNumTransactions : ( opts : EdgeCurrencyCodeOptions ) => number ,
558
596
+ getTransactions : (
559
597
opts : EdgeGetTransactionsOptions
560
598
) => Promise < EdgeTransaction [ ] > ,
561
599
+ getTxids ? : ( ) => EdgeTxidMap ,
562
600
563
601
// Tokens:
564
- + enableTokens : ( tokens : string [ ] ) => Promise < void > ,
565
- + disableTokens : ( tokens : string [ ] ) = > Promise < void > ,
566
- + getEnabledTokens : ( ) = > Promise < string [ ] > ,
567
- + addCustomToken : ( token : EdgeTokenInfo ) = > Promise < void > ,
568
- + getTokenStatus : ( token : string ) = > boolean ,
602
+ + changeCustomTokens ?: ( tokens : EdgeTokenMap ) => Promise < void > ,
603
+ + changeEnabledTokenIds ?: ( tokenIds : string [ ] ) => Promise < void > ,
569
604
570
605
// Addresses:
571
606
+ getFreshAddress : (
572
- opts : EdgeCurrencyCodeOptions
607
+ opts : EdgeCurrencyCodeOptions // Does nothing
573
608
) = > Promise < EdgeFreshAddress > ,
574
609
+ addGapLimitAddresses : ( addresses : string [ ] ) = > Promise < void > ,
575
610
+ isAddressUsed : ( address : string ) = > Promise < boolean > ,
@@ -589,7 +624,14 @@ export type EdgeCurrencyEngine = {
589
624
+ getStakingStatus ?: ( ) => Promise < EdgeStakingStatus > ,
590
625
591
626
// Escape hatch:
592
- + otherMethods ?: EdgeOtherMethods
627
+ + otherMethods ?: EdgeOtherMethods ,
628
+
629
+ // Deprecated:
630
+ + enableTokens : ( tokens : string [ ] ) => Promise < void > ,
631
+ + disableTokens : ( tokens : string [ ] ) => Promise < void > ,
632
+ + getEnabledTokens : ( ) => Promise < string [ ] > ,
633
+ + addCustomToken : ( token : EdgeTokenInfo ) => Promise < void > ,
634
+ + getTokenStatus : ( token : string ) => boolean
593
635
}
594
636
595
637
// currency plugin -----------------------------------------------------
@@ -611,6 +653,9 @@ export type EdgeCurrencyTools = {
611
653
+ derivePublicKey : ( walletInfo : EdgeWalletInfo ) = > Promise < JsonObject > ,
612
654
+ getSplittableTypes ?: ( walletInfo : EdgeWalletInfo ) => string [ ] ,
613
655
656
+ // Derives a tokenId string from a token's network information:
657
+ + getTokenId ?: ( token : EdgeToken ) => Promise < string > ,
658
+
614
659
// URIs:
615
660
+ parseUri : (
616
661
uri : string ,
@@ -629,6 +674,7 @@ export type EdgeCurrencyTools = {
629
674
export type EdgeCurrencyPlugin = {
630
675
+ currencyInfo : EdgeCurrencyInfo ,
631
676
677
+ + getBuiltinTokens ?: ( ) => Promise < EdgeTokenMap > ,
632
678
+ makeCurrencyTools : ( ) => Promise < EdgeCurrencyTools > ,
633
679
+ makeCurrencyEngine : (
634
680
walletInfo : EdgeWalletInfo ,
@@ -693,8 +739,13 @@ export type EdgeCurrencyWallet = {
693
739
currencyCode : string
694
740
) = > Promise < string > ,
695
741
742
+ // Configuration:
743
+ // eslint-disable-next-line no-use-before-define
744
+ + config : EdgeCurrencyConfig ,
745
+
696
746
// Chain state:
697
- + balances : EdgeBalances ,
747
+ + balances : { [ currencyCode : string ] : string } , // Deprecated
748
+ + tokenBalances : { [ tokenId : string ] : string } ,
698
749
+ blockHeight : number ,
699
750
+ syncRatio : number ,
700
751
@@ -703,11 +754,10 @@ export type EdgeCurrencyWallet = {
703
754
+ changePaused : ( paused : boolean ) = > Promise < void > ,
704
755
705
756
// Token management:
706
- + changeEnabledTokens : ( currencyCodes : string [ ] ) = > Promise < void > ,
707
- + enableTokens : ( tokens : string [ ] ) = > Promise < void > ,
708
- + disableTokens : ( tokens : string [ ] ) = > Promise < void > ,
709
- + getEnabledTokens : ( ) = > Promise < string [ ] > ,
710
- + addCustomToken : ( token : EdgeTokenInfo ) = > Promise < void > ,
757
+ // Available tokens can be found in `EdgeCurrencyConfig`.
758
+ // This list is allowed to include missing or deleted `tokenIds`:
759
+ + enabledTokenIds : string [ ] ,
760
+ + changeEnabledTokenIds : ( tokenIds : string [ ] ) = > Promise < void > ,
711
761
712
762
// Transaction history:
713
763
+ getNumTransactions : ( opts ? : EdgeCurrencyCodeOptions ) = > Promise < number > ,
@@ -717,7 +767,7 @@ export type EdgeCurrencyWallet = {
717
767
718
768
// Addresses:
719
769
+ getReceiveAddress : (
720
- opts ? : EdgeCurrencyCodeOptions
770
+ opts ? : EdgeCurrencyCodeOptions // Does nothing
721
771
) = > Promise < EdgeReceiveAddress > ,
722
772
+ saveReceiveAddress : ( receiveAddress : EdgeReceiveAddress ) = > Promise < void > ,
723
773
+ lockReceiveAddress : ( receiveAddress : EdgeReceiveAddress ) = > Promise < void > ,
@@ -730,7 +780,7 @@ export type EdgeCurrencyWallet = {
730
780
+ sweepPrivateKeys : ( edgeSpendInfo : EdgeSpendInfo ) = > Promise < EdgeTransaction > ,
731
781
+ saveTxMetadata : (
732
782
txid : string ,
733
- currencyCode : string ,
783
+ currencyCode : string , // Does nothing
734
784
metadata : EdgeMetadata
735
785
) = > Promise < void > ,
736
786
+ getMaxSpendable : ( spendInfo : EdgeSpendInfo ) = > Promise < string > ,
@@ -749,7 +799,14 @@ export type EdgeCurrencyWallet = {
749
799
+ parseUri : ( uri : string , currencyCode ? : string ) = > Promise < EdgeParsedUri > ,
750
800
+ encodeUri : ( obj : EdgeEncodeUri ) = > Promise < string > ,
751
801
752
- + otherMethods : EdgeOtherMethods
802
+ + otherMethods : EdgeOtherMethods ,
803
+
804
+ // Deprecated:
805
+ + addCustomToken : ( token : EdgeTokenInfo ) = > Promise < void > ,
806
+ + changeEnabledTokens : ( currencyCodes : string [ ] ) = > Promise < void > ,
807
+ + disableTokens : ( tokens : string [ ] ) = > Promise < void > ,
808
+ + enableTokens : ( tokens : string [ ] ) = > Promise < void > ,
809
+ + getEnabledTokens : ( ) = > Promise < string [ ] >
753
810
}
754
811
755
812
// ---------------------------------------------------------------------
@@ -773,12 +830,16 @@ export type EdgeSwapRequest = {
773
830
toWallet : EdgeCurrencyWallet ,
774
831
775
832
// What?
776
- fromCurrencyCode : string ,
777
- toCurrencyCode : string ,
833
+ fromTokenId : string ,
834
+ toTokenId : string ,
778
835
779
836
// How much?
780
837
nativeAmount : string ,
781
- quoteFor : 'from' | 'max' | 'to'
838
+ quoteFor : 'from' | 'max' | 'to' ,
839
+
840
+ // Deprecated. Use CurrencyId:
841
+ fromCurrencyCode : string ,
842
+ toCurrencyCode : string
782
843
}
783
844
784
845
/**
@@ -892,6 +953,13 @@ export type EdgeCurrencyConfig = {
892
953
893
954
+ currencyInfo : EdgeCurrencyInfo ,
894
955
956
+ // Tokens:
957
+ + builtinTokens : EdgeTokenMap ,
958
+ + customTokens : EdgeTokenMap ,
959
+ + addCustomToken : ( token : EdgeToken ) => Promise < string > ,
960
+ + changeCustomToken : ( tokenId : string , token : EdgeToken ) = > Promise < void > ,
961
+ + removeCustomToken : ( tokenId : string ) = > Promise < void > ,
962
+
895
963
// User settings for this plugin:
896
964
+ userSettings : JsonObject | void ,
897
965
+ changeUserSettings : ( settings : JsonObject ) = > Promise < void > ,
0 commit comments