Skip to content

Commit 2df536f

Browse files
committed
Meeting notes
1 parent 8e7c293 commit 2df536f

File tree

1 file changed

+102
-34
lines changed

1 file changed

+102
-34
lines changed

src/types/types.js

Lines changed: 102 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,33 @@ export type EdgeDenomination = {
216216
symbol?: string
217217
}
218218

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+
219246
/**
220247
* Available tokens stored in the `EdgeCurrencyInfo`,
221248
* or parsed out of URI's.
@@ -264,10 +291,10 @@ type EdgeObjectTemplate = Array<
264291
export type EdgeCurrencyInfo = {
265292
// Basic currency information:
266293
+pluginId: string,
267-
displayName: string,
294+
displayName: string, // Name for the chain
268295
walletType: string,
269296

270-
// Native token information:
297+
// Native token information, Display only !!!!:
271298
currencyCode: string,
272299
denominations: EdgeDenomination[],
273300

@@ -281,19 +308,17 @@ export type EdgeCurrencyInfo = {
281308
memoMaxValue?: string, // Max numerical value, if supported
282309
memoType?: 'text' | 'number' | 'other', // undefined means no memo support
283310

284-
// Configuration options:
285-
defaultSettings: JsonObject,
286-
metaTokens: EdgeMetaToken[],
287-
288311
// Explorers:
289312
addressExplorer: string,
290313
blockExplorer?: string,
291314
transactionExplorer: string,
292315
xpubExplorer?: string,
293316

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
297322
}
298323

299324
// spending ------------------------------------------------------------
@@ -310,6 +335,7 @@ export type EdgeMetadata = {
310335
}
311336

312337
export type EdgeNetworkFee = {
338+
+tokenId: string, // The core can synthesize this?
313339
+currencyCode: string,
314340
+nativeAmount: string
315341
}
@@ -335,6 +361,8 @@ export type EdgeTxSwap = {
335361
}
336362

337363
export type EdgeTransaction = {
364+
tokenId: string, // The core can synthesize this?
365+
338366
// Amounts:
339367
currencyCode: string,
340368
nativeAmount: string,
@@ -395,7 +423,8 @@ export type EdgePaymentProtocolInfo = {
395423

396424
export type EdgeSpendInfo = {
397425
// Basic information:
398-
currencyCode?: string,
426+
currencyCode?: string, // Deprecated
427+
tokenId?: string,
399428
privateKeys?: string[],
400429
spendTargets: EdgeSpendTarget[],
401430

@@ -502,11 +531,13 @@ export type EdgeEncodeUri = {
502531
// options -------------------------------------------------------------
503532

504533
export type EdgeCurrencyCodeOptions = {
505-
currencyCode?: string
534+
currencyCode?: string, // Deprecated
535+
tokenId?: string
506536
}
507537

508538
export type EdgeGetTransactionsOptions = {
509-
currencyCode?: string,
539+
currencyCode?: string, // Deprecated
540+
tokenId?: string,
510541
startIndex?: number,
511542
startEntries?: number,
512543
startDate?: Date,
@@ -522,19 +553,26 @@ export type EdgeGetTransactionsOptions = {
522553
export type EdgeCurrencyEngineCallbacks = {
523554
+onAddressChanged: () => void,
524555
+onAddressesChecked: (progressRatio: number) => void,
525-
+onBalanceChanged: (currencyCode: string, nativeBalance: string) => void,
556+
+onBalanceChanged: (currencyCode: string, nativeBalance: string) => void, // Deprecated. Use onTokenBalanceChanged.
526557
+onBlockHeightChanged: (blockHeight: number) => void,
527558
+onStakingStatusChanged: (status: EdgeStakingStatus) => void,
559+
+onTokenBalanceChanged: (tokenId: string, nativeBalance: string) => void,
528560
+onTransactionsChanged: (transactions: EdgeTransaction[]) => void,
529561
+onTxidsChanged: (txids: EdgeTxidMap) => void,
530562
+onWcNewContractCall: (payload: JsonObject) => void
531563
}
532564

533565
export type EdgeCurrencyEngineOptions = {
534566
callbacks: EdgeCurrencyEngineCallbacks,
535-
log: EdgeLog, // Wallet-scoped logging
567+
568+
// Wallet-scoped IO objects:
569+
log: EdgeLog,
536570
walletLocalDisklet: Disklet,
537571
walletLocalEncryptedDisklet: Disklet,
572+
573+
// User settings:
574+
customTokens: EdgeTokenMap,
575+
enabledTokenIds: string[],
538576
userSettings: JsonObject | void
539577
}
540578

@@ -553,23 +591,20 @@ export type EdgeCurrencyEngine = {
553591

554592
// Chain state:
555593
+getBlockHeight: () => number,
556-
+getBalance: (opts: EdgeCurrencyCodeOptions) => string,
594+
+getBalance: (opts: EdgeCurrencyCodeOptions) => string, // Deprecated, never used
557595
+getNumTransactions: (opts: EdgeCurrencyCodeOptions) => number,
558596
+getTransactions: (
559597
opts: EdgeGetTransactionsOptions
560598
) => Promise<EdgeTransaction[]>,
561599
+getTxids?: () => EdgeTxidMap,
562600

563601
// 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>,
569604

570605
// Addresses:
571606
+getFreshAddress: (
572-
opts: EdgeCurrencyCodeOptions
607+
opts: EdgeCurrencyCodeOptions // Does nothing
573608
) => Promise<EdgeFreshAddress>,
574609
+addGapLimitAddresses: (addresses: string[]) => Promise<void>,
575610
+isAddressUsed: (address: string) => Promise<boolean>,
@@ -589,7 +624,14 @@ export type EdgeCurrencyEngine = {
589624
+getStakingStatus?: () => Promise<EdgeStakingStatus>,
590625

591626
// 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
593635
}
594636

595637
// currency plugin -----------------------------------------------------
@@ -611,6 +653,9 @@ export type EdgeCurrencyTools = {
611653
+derivePublicKey: (walletInfo: EdgeWalletInfo) => Promise<JsonObject>,
612654
+getSplittableTypes?: (walletInfo: EdgeWalletInfo) => string[],
613655

656+
// Derives a tokenId string from a token's network information:
657+
+getTokenId?: (token: EdgeToken) => Promise<string>,
658+
614659
// URIs:
615660
+parseUri: (
616661
uri: string,
@@ -629,6 +674,7 @@ export type EdgeCurrencyTools = {
629674
export type EdgeCurrencyPlugin = {
630675
+currencyInfo: EdgeCurrencyInfo,
631676

677+
+getBuiltinTokens?: () => Promise<EdgeTokenMap>,
632678
+makeCurrencyTools: () => Promise<EdgeCurrencyTools>,
633679
+makeCurrencyEngine: (
634680
walletInfo: EdgeWalletInfo,
@@ -693,8 +739,13 @@ export type EdgeCurrencyWallet = {
693739
currencyCode: string
694740
) => Promise<string>,
695741

742+
// Configuration:
743+
// eslint-disable-next-line no-use-before-define
744+
+config: EdgeCurrencyConfig,
745+
696746
// Chain state:
697-
+balances: EdgeBalances,
747+
+balances: { [currencyCode: string]: string }, // Deprecated
748+
+tokenBalances: { [tokenId: string]: string },
698749
+blockHeight: number,
699750
+syncRatio: number,
700751

@@ -703,11 +754,10 @@ export type EdgeCurrencyWallet = {
703754
+changePaused: (paused: boolean) => Promise<void>,
704755

705756
// 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>,
711761

712762
// Transaction history:
713763
+getNumTransactions: (opts?: EdgeCurrencyCodeOptions) => Promise<number>,
@@ -717,7 +767,7 @@ export type EdgeCurrencyWallet = {
717767

718768
// Addresses:
719769
+getReceiveAddress: (
720-
opts?: EdgeCurrencyCodeOptions
770+
opts?: EdgeCurrencyCodeOptions // Does nothing
721771
) => Promise<EdgeReceiveAddress>,
722772
+saveReceiveAddress: (receiveAddress: EdgeReceiveAddress) => Promise<void>,
723773
+lockReceiveAddress: (receiveAddress: EdgeReceiveAddress) => Promise<void>,
@@ -730,7 +780,7 @@ export type EdgeCurrencyWallet = {
730780
+sweepPrivateKeys: (edgeSpendInfo: EdgeSpendInfo) => Promise<EdgeTransaction>,
731781
+saveTxMetadata: (
732782
txid: string,
733-
currencyCode: string,
783+
currencyCode: string, // Does nothing
734784
metadata: EdgeMetadata
735785
) => Promise<void>,
736786
+getMaxSpendable: (spendInfo: EdgeSpendInfo) => Promise<string>,
@@ -749,7 +799,14 @@ export type EdgeCurrencyWallet = {
749799
+parseUri: (uri: string, currencyCode?: string) => Promise<EdgeParsedUri>,
750800
+encodeUri: (obj: EdgeEncodeUri) => Promise<string>,
751801

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[]>
753810
}
754811

755812
// ---------------------------------------------------------------------
@@ -773,12 +830,16 @@ export type EdgeSwapRequest = {
773830
toWallet: EdgeCurrencyWallet,
774831

775832
// What?
776-
fromCurrencyCode: string,
777-
toCurrencyCode: string,
833+
fromTokenId: string,
834+
toTokenId: string,
778835

779836
// How much?
780837
nativeAmount: string,
781-
quoteFor: 'from' | 'max' | 'to'
838+
quoteFor: 'from' | 'max' | 'to',
839+
840+
// Deprecated. Use CurrencyId:
841+
fromCurrencyCode: string,
842+
toCurrencyCode: string
782843
}
783844

784845
/**
@@ -892,6 +953,13 @@ export type EdgeCurrencyConfig = {
892953

893954
+currencyInfo: EdgeCurrencyInfo,
894955

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+
895963
// User settings for this plugin:
896964
+userSettings: JsonObject | void,
897965
+changeUserSettings: (settings: JsonObject) => Promise<void>,

0 commit comments

Comments
 (0)