@@ -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,36 +291,35 @@ 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
274
301
// Chain information:
275
302
canAdjustFees ?: boolean , // Defaults to true
276
303
canImportKeys ?: boolean , // Defaults to false
304
+ canReplaceByFee ?: boolean , // Defaults to false
277
305
customFeeTemplate ?: EdgeObjectTemplate , // Indicates custom fee support
278
306
customTokenTemplate ?: EdgeObjectTemplate , // Indicates custom token support
279
307
requiredConfirmations ?: number ,
280
308
memoMaxLength ?: number , // Max number of text characters, if supported
281
309
memoMaxValue ?: string , // Max numerical value, if supported
282
310
memoType ?: 'text' | 'number' | 'other' , // undefined means no memo support
283
311
284
- // Configuration options:
285
- defaultSettings : JsonObject ,
286
- metaTokens : EdgeMetaToken [ ] ,
287
-
288
312
// Explorers:
289
313
addressExplorer : string ,
290
314
blockExplorer ?: string ,
291
315
transactionExplorer : string ,
292
316
xpubExplorer ?: string ,
293
317
294
- // Images:
295
- symbolImage ?: string ,
296
- symbolImageDarkMono ?: string
318
+ // Deprecated:
319
+ defaultSettings : JsonObject , // The default user settings are `{}`
320
+ metaTokens : EdgeMetaToken [ ] , // Use `EdgeCurrencyPlugins.getBuiltinTokens`
321
+ symbolImage ?: string , // The GUI handles this now
322
+ symbolImageDarkMono ?: string // The GUI handles this now
297
323
}
298
324
299
325
// spending ------------------------------------------------------------
@@ -310,6 +336,7 @@ export type EdgeMetadata = {
310
336
}
311
337
312
338
export type EdgeNetworkFee = {
339
+ + tokenId : string , // The core can synthesize this?
313
340
+ currencyCode : string ,
314
341
+ nativeAmount : string
315
342
}
@@ -335,6 +362,8 @@ export type EdgeTxSwap = {
335
362
}
336
363
337
364
export type EdgeTransaction = {
365
+ tokenId : string , // The core can synthesize this?
366
+
338
367
// Amounts:
339
368
currencyCode : string ,
340
369
nativeAmount : string ,
@@ -395,7 +424,8 @@ export type EdgePaymentProtocolInfo = {
395
424
396
425
export type EdgeSpendInfo = {
397
426
// Basic information:
398
- currencyCode ?: string ,
427
+ currencyCode ?: string , // Deprecated
428
+ tokenId ?: string ,
399
429
privateKeys ?: string [ ] ,
400
430
spendTargets : EdgeSpendTarget [ ] ,
401
431
@@ -502,11 +532,13 @@ export type EdgeEncodeUri = {
502
532
// options -------------------------------------------------------------
503
533
504
534
export type EdgeCurrencyCodeOptions = {
505
- currencyCode ?: string
535
+ currencyCode ?: string , // Deprecated
536
+ tokenId ?: string
506
537
}
507
538
508
539
export type EdgeGetTransactionsOptions = {
509
- currencyCode ?: string ,
540
+ currencyCode ?: string , // Deprecated
541
+ tokenId ?: string ,
510
542
startIndex ?: number ,
511
543
startEntries ?: number ,
512
544
startDate ?: Date ,
@@ -520,18 +552,20 @@ export type EdgeGetTransactionsOptions = {
520
552
// engine --------------------------------------------------------------
521
553
522
554
export type EdgeCurrencyEngineCallbacks = {
555
+ + onBlockHeightChanged : ( blockHeight : number ) => void ,
523
556
+ onAddressChanged : ( ) => void ,
524
557
+ onAddressesChecked : ( progressRatio : number ) => void ,
525
- + onBalanceChanged : ( currencyCode : string , nativeBalance : string ) = > void ,
526
- + onBlockHeightChanged : ( blockHeight : number ) = > void ,
558
+ + onBalanceChanged : ( currencyCode : string , nativeBalance : string ) => void , // Deprecated. Use onTokenBalanceChanged.
527
559
+ onStakingStatusChanged : ( status : EdgeStakingStatus ) => void ,
560
+ + onTokenBalanceChanged : ( tokenId : string , nativeBalance : string ) = > void ,
528
561
+ onTransactionsChanged : ( transactions : EdgeTransaction [ ] ) = > void ,
529
562
+ onTxidsChanged : ( txids : EdgeTxidMap ) = > void ,
530
563
+ onWcNewContractCall : ( payload : JsonObject ) = > void
531
564
}
532
565
533
566
export type EdgeCurrencyEngineOptions = {
534
567
callbacks : EdgeCurrencyEngineCallbacks ,
568
+ customTokens : EdgeTokenMap ,
535
569
log : EdgeLog , // Wallet-scoped logging
536
570
walletLocalDisklet : Disklet ,
537
571
walletLocalEncryptedDisklet : Disklet ,
@@ -553,23 +587,22 @@ export type EdgeCurrencyEngine = {
553
587
554
588
// Chain state:
555
589
+ getBlockHeight : ( ) = > number ,
556
- + getBalance : ( opts : EdgeCurrencyCodeOptions ) => string ,
590
+ + getBalance : ( opts : EdgeCurrencyCodeOptions ) => string , // Deprecated, never used
557
591
+ getNumTransactions : ( opts : EdgeCurrencyCodeOptions ) => number ,
558
592
+ getTransactions : (
559
593
opts : EdgeGetTransactionsOptions
560
594
) => Promise < EdgeTransaction [ ] > ,
561
595
+ getTxids ? : ( ) => EdgeTxidMap ,
562
596
563
597
// Tokens:
598
+ + changeCustomTokens ?: ( tokens : EdgeTokenMap ) => Promise < void > ,
564
599
+ enableTokens : ( tokens : string [ ] ) => Promise < void > ,
565
600
+ disableTokens : ( tokens : string [ ] ) = > Promise < void > ,
566
601
+ getEnabledTokens : ( ) = > Promise < string [ ] > ,
567
- + addCustomToken : ( token : EdgeTokenInfo ) = > Promise < void > ,
568
- + getTokenStatus : ( token : string ) = > boolean ,
569
602
570
603
// Addresses:
571
604
+ getFreshAddress : (
572
- opts : EdgeCurrencyCodeOptions
605
+ opts : EdgeCurrencyCodeOptions // Does nothing
573
606
) = > Promise < EdgeFreshAddress > ,
574
607
+ addGapLimitAddresses : ( addresses : string [ ] ) = > Promise < void > ,
575
608
+ isAddressUsed : ( address : string ) = > Promise < boolean > ,
@@ -589,7 +622,11 @@ export type EdgeCurrencyEngine = {
589
622
+ getStakingStatus ?: ( ) => Promise < EdgeStakingStatus > ,
590
623
591
624
// Escape hatch:
592
- + otherMethods ?: EdgeOtherMethods
625
+ + otherMethods ?: EdgeOtherMethods ,
626
+
627
+ // Deprecated:
628
+ + addCustomToken : ( token : EdgeTokenInfo & EdgeToken ) => Promise < void > ,
629
+ + getTokenStatus : ( token : string ) => boolean
593
630
}
594
631
595
632
// currency plugin -----------------------------------------------------
@@ -609,7 +646,12 @@ export type EdgeCurrencyTools = {
609
646
opts ? : JsonObject
610
647
) => Promise < JsonObject > ,
611
648
+ derivePublicKey : ( walletInfo : EdgeWalletInfo ) = > Promise < JsonObject > ,
612
- + getSplittableTypes ?: ( walletInfo : EdgeWalletInfo ) => string [ ] ,
649
+ + getSplittableTypes ?: (
650
+ walletInfo : EdgeWalletInfo
651
+ ) => string [ ] | Promise < string [ ] > ,
652
+
653
+ // Derives a tokenId string from a token's network information:
654
+ + getTokenId ?: ( token : EdgeToken ) => Promise < string > ,
613
655
614
656
// URIs:
615
657
+ parseUri : (
@@ -629,6 +671,7 @@ export type EdgeCurrencyTools = {
629
671
export type EdgeCurrencyPlugin = {
630
672
+ currencyInfo : EdgeCurrencyInfo ,
631
673
674
+ + getBuiltinTokens ?: ( ) => Promise < EdgeTokenMap > ,
632
675
+ makeCurrencyTools : ( ) => Promise < EdgeCurrencyTools > ,
633
676
+ makeCurrencyEngine : (
634
677
walletInfo : EdgeWalletInfo ,
@@ -694,7 +737,8 @@ export type EdgeCurrencyWallet = {
694
737
) = > Promise < string > ,
695
738
696
739
// Chain state:
697
- + balances : EdgeBalances ,
740
+ + balances : { [ currencyCode : string ] : string } , // Deprecated
741
+ + tokenBalances : { [ tokenId : string ] : string } ,
698
742
+ blockHeight : number ,
699
743
+ syncRatio : number ,
700
744
@@ -703,11 +747,11 @@ export type EdgeCurrencyWallet = {
703
747
+ changePaused : ( paused : boolean ) = > Promise < void > ,
704
748
705
749
// 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 > ,
750
+ // Available tokens can be found in `EdgeCurrencyConfig`.
751
+ // This list may include missing or deleted `tokenIds` ,
752
+ // so use `enabledTokens` if you just want the existing ones:
753
+ + enabledTokenIds : string [ ] ,
754
+ + changeEnabledTokenIds : ( tokenIds : string [ ] ) = > Promise < void > ,
711
755
712
756
// Transaction history:
713
757
+ getNumTransactions : ( opts ? : EdgeCurrencyCodeOptions ) = > Promise < number > ,
@@ -717,7 +761,7 @@ export type EdgeCurrencyWallet = {
717
761
718
762
// Addresses:
719
763
+ getReceiveAddress : (
720
- opts ? : EdgeCurrencyCodeOptions
764
+ opts ? : EdgeCurrencyCodeOptions // Does nothing
721
765
) = > Promise < EdgeReceiveAddress > ,
722
766
+ saveReceiveAddress : ( receiveAddress : EdgeReceiveAddress ) = > Promise < void > ,
723
767
+ lockReceiveAddress : ( receiveAddress : EdgeReceiveAddress ) = > Promise < void > ,
@@ -730,7 +774,7 @@ export type EdgeCurrencyWallet = {
730
774
+ sweepPrivateKeys : ( edgeSpendInfo : EdgeSpendInfo ) = > Promise < EdgeTransaction > ,
731
775
+ saveTxMetadata : (
732
776
txid : string ,
733
- currencyCode : string ,
777
+ currencyCode : string , // Does nothing
734
778
metadata : EdgeMetadata
735
779
) = > Promise < void > ,
736
780
+ getMaxSpendable : ( spendInfo : EdgeSpendInfo ) = > Promise < string > ,
@@ -749,7 +793,14 @@ export type EdgeCurrencyWallet = {
749
793
+ parseUri : ( uri : string , currencyCode ? : string ) = > Promise < EdgeParsedUri > ,
750
794
+ encodeUri : ( obj : EdgeEncodeUri ) = > Promise < string > ,
751
795
752
- + otherMethods : EdgeOtherMethods
796
+ + otherMethods : EdgeOtherMethods ,
797
+
798
+ // Deprecated:
799
+ + addCustomToken : ( token : EdgeTokenInfo ) = > Promise < void > ,
800
+ + changeEnabledTokens : ( currencyCodes : string [ ] ) = > Promise < void > ,
801
+ + disableTokens : ( tokens : string [ ] ) = > Promise < void > ,
802
+ + enableTokens : ( tokens : string [ ] ) = > Promise < void > ,
803
+ + getEnabledTokens : ( ) = > Promise < string [ ] >
753
804
}
754
805
755
806
// ---------------------------------------------------------------------
@@ -773,12 +824,16 @@ export type EdgeSwapRequest = {
773
824
toWallet : EdgeCurrencyWallet ,
774
825
775
826
// What?
776
- fromCurrencyCode : string ,
777
- toCurrencyCode : string ,
827
+ fromTokenId : string ,
828
+ toTokenId : string ,
778
829
779
830
// How much?
780
831
nativeAmount : string ,
781
- quoteFor : 'from' | 'max' | 'to'
832
+ quoteFor : 'from' | 'max' | 'to' ,
833
+
834
+ // Deprecated. Use CurrencyId:
835
+ fromCurrencyCode : string ,
836
+ toCurrencyCode : string
782
837
}
783
838
784
839
/**
@@ -892,6 +947,13 @@ export type EdgeCurrencyConfig = {
892
947
893
948
+ currencyInfo : EdgeCurrencyInfo ,
894
949
950
+ // Tokens:
951
+ + builtinTokens : EdgeTokenMap ,
952
+ + customTokens : EdgeTokenMap ,
953
+ + addCustomToken : ( token : EdgeToken ) => Promise < string > ,
954
+ + changeCustomToken : ( tokenId : string , token : EdgeToken ) = > Promise < void > ,
955
+ + removeCustomToken : ( tokenId : string ) = > Promise < void > ,
956
+
895
957
// User settings for this plugin:
896
958
+ userSettings : JsonObject | void ,
897
959
+ changeUserSettings : ( settings : JsonObject ) = > Promise < void > ,
0 commit comments