Skip to content

Commit c0c7675

Browse files
committed
Meeting notes
1 parent 8e7c293 commit c0c7675

File tree

1 file changed

+94
-32
lines changed

1 file changed

+94
-32
lines changed

src/types/types.js

Lines changed: 94 additions & 32 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,36 +291,35 @@ 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

274301
// Chain information:
275302
canAdjustFees?: boolean, // Defaults to true
276303
canImportKeys?: boolean, // Defaults to false
304+
canReplaceByFee?: boolean, // Defaults to false
277305
customFeeTemplate?: EdgeObjectTemplate, // Indicates custom fee support
278306
customTokenTemplate?: EdgeObjectTemplate, // Indicates custom token support
279307
requiredConfirmations?: number,
280308
memoMaxLength?: number, // Max number of text characters, if supported
281309
memoMaxValue?: string, // Max numerical value, if supported
282310
memoType?: 'text' | 'number' | 'other', // undefined means no memo support
283311

284-
// Configuration options:
285-
defaultSettings: JsonObject,
286-
metaTokens: EdgeMetaToken[],
287-
288312
// Explorers:
289313
addressExplorer: string,
290314
blockExplorer?: string,
291315
transactionExplorer: string,
292316
xpubExplorer?: string,
293317

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
297323
}
298324

299325
// spending ------------------------------------------------------------
@@ -310,6 +336,7 @@ export type EdgeMetadata = {
310336
}
311337

312338
export type EdgeNetworkFee = {
339+
+tokenId: string, // The core can synthesize this?
313340
+currencyCode: string,
314341
+nativeAmount: string
315342
}
@@ -335,6 +362,8 @@ export type EdgeTxSwap = {
335362
}
336363

337364
export type EdgeTransaction = {
365+
tokenId: string, // The core can synthesize this?
366+
338367
// Amounts:
339368
currencyCode: string,
340369
nativeAmount: string,
@@ -395,7 +424,8 @@ export type EdgePaymentProtocolInfo = {
395424

396425
export type EdgeSpendInfo = {
397426
// Basic information:
398-
currencyCode?: string,
427+
currencyCode?: string, // Deprecated
428+
tokenId?: string,
399429
privateKeys?: string[],
400430
spendTargets: EdgeSpendTarget[],
401431

@@ -502,11 +532,13 @@ export type EdgeEncodeUri = {
502532
// options -------------------------------------------------------------
503533

504534
export type EdgeCurrencyCodeOptions = {
505-
currencyCode?: string
535+
currencyCode?: string, // Deprecated
536+
tokenId?: string
506537
}
507538

508539
export type EdgeGetTransactionsOptions = {
509-
currencyCode?: string,
540+
currencyCode?: string, // Deprecated
541+
tokenId?: string,
510542
startIndex?: number,
511543
startEntries?: number,
512544
startDate?: Date,
@@ -520,18 +552,20 @@ export type EdgeGetTransactionsOptions = {
520552
// engine --------------------------------------------------------------
521553

522554
export type EdgeCurrencyEngineCallbacks = {
555+
+onBlockHeightChanged: (blockHeight: number) => void,
523556
+onAddressChanged: () => void,
524557
+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.
527559
+onStakingStatusChanged: (status: EdgeStakingStatus) => void,
560+
+onTokenBalanceChanged: (tokenId: string, nativeBalance: string) => void,
528561
+onTransactionsChanged: (transactions: EdgeTransaction[]) => void,
529562
+onTxidsChanged: (txids: EdgeTxidMap) => void,
530563
+onWcNewContractCall: (payload: JsonObject) => void
531564
}
532565

533566
export type EdgeCurrencyEngineOptions = {
534567
callbacks: EdgeCurrencyEngineCallbacks,
568+
customTokens: EdgeTokenMap,
535569
log: EdgeLog, // Wallet-scoped logging
536570
walletLocalDisklet: Disklet,
537571
walletLocalEncryptedDisklet: Disklet,
@@ -553,23 +587,22 @@ export type EdgeCurrencyEngine = {
553587

554588
// Chain state:
555589
+getBlockHeight: () => number,
556-
+getBalance: (opts: EdgeCurrencyCodeOptions) => string,
590+
+getBalance: (opts: EdgeCurrencyCodeOptions) => string, // Deprecated, never used
557591
+getNumTransactions: (opts: EdgeCurrencyCodeOptions) => number,
558592
+getTransactions: (
559593
opts: EdgeGetTransactionsOptions
560594
) => Promise<EdgeTransaction[]>,
561595
+getTxids?: () => EdgeTxidMap,
562596

563597
// Tokens:
598+
+changeCustomTokens?: (tokens: EdgeTokenMap) => Promise<void>,
564599
+enableTokens: (tokens: string[]) => Promise<void>,
565600
+disableTokens: (tokens: string[]) => Promise<void>,
566601
+getEnabledTokens: () => Promise<string[]>,
567-
+addCustomToken: (token: EdgeTokenInfo) => Promise<void>,
568-
+getTokenStatus: (token: string) => boolean,
569602

570603
// Addresses:
571604
+getFreshAddress: (
572-
opts: EdgeCurrencyCodeOptions
605+
opts: EdgeCurrencyCodeOptions // Does nothing
573606
) => Promise<EdgeFreshAddress>,
574607
+addGapLimitAddresses: (addresses: string[]) => Promise<void>,
575608
+isAddressUsed: (address: string) => Promise<boolean>,
@@ -589,7 +622,11 @@ export type EdgeCurrencyEngine = {
589622
+getStakingStatus?: () => Promise<EdgeStakingStatus>,
590623

591624
// Escape hatch:
592-
+otherMethods?: EdgeOtherMethods
625+
+otherMethods?: EdgeOtherMethods,
626+
627+
// Deprecated:
628+
+addCustomToken: (token: EdgeTokenInfo & EdgeToken) => Promise<void>,
629+
+getTokenStatus: (token: string) => boolean
593630
}
594631

595632
// currency plugin -----------------------------------------------------
@@ -609,7 +646,12 @@ export type EdgeCurrencyTools = {
609646
opts?: JsonObject
610647
) => Promise<JsonObject>,
611648
+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>,
613655

614656
// URIs:
615657
+parseUri: (
@@ -629,6 +671,7 @@ export type EdgeCurrencyTools = {
629671
export type EdgeCurrencyPlugin = {
630672
+currencyInfo: EdgeCurrencyInfo,
631673

674+
+getBuiltinTokens?: () => Promise<EdgeTokenMap>,
632675
+makeCurrencyTools: () => Promise<EdgeCurrencyTools>,
633676
+makeCurrencyEngine: (
634677
walletInfo: EdgeWalletInfo,
@@ -694,7 +737,8 @@ export type EdgeCurrencyWallet = {
694737
) => Promise<string>,
695738

696739
// Chain state:
697-
+balances: EdgeBalances,
740+
+balances: { [currencyCode: string]: string }, // Deprecated
741+
+tokenBalances: { [tokenId: string]: string },
698742
+blockHeight: number,
699743
+syncRatio: number,
700744

@@ -703,11 +747,11 @@ export type EdgeCurrencyWallet = {
703747
+changePaused: (paused: boolean) => Promise<void>,
704748

705749
// 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>,
711755

712756
// Transaction history:
713757
+getNumTransactions: (opts?: EdgeCurrencyCodeOptions) => Promise<number>,
@@ -717,7 +761,7 @@ export type EdgeCurrencyWallet = {
717761

718762
// Addresses:
719763
+getReceiveAddress: (
720-
opts?: EdgeCurrencyCodeOptions
764+
opts?: EdgeCurrencyCodeOptions // Does nothing
721765
) => Promise<EdgeReceiveAddress>,
722766
+saveReceiveAddress: (receiveAddress: EdgeReceiveAddress) => Promise<void>,
723767
+lockReceiveAddress: (receiveAddress: EdgeReceiveAddress) => Promise<void>,
@@ -730,7 +774,7 @@ export type EdgeCurrencyWallet = {
730774
+sweepPrivateKeys: (edgeSpendInfo: EdgeSpendInfo) => Promise<EdgeTransaction>,
731775
+saveTxMetadata: (
732776
txid: string,
733-
currencyCode: string,
777+
currencyCode: string, // Does nothing
734778
metadata: EdgeMetadata
735779
) => Promise<void>,
736780
+getMaxSpendable: (spendInfo: EdgeSpendInfo) => Promise<string>,
@@ -749,7 +793,14 @@ export type EdgeCurrencyWallet = {
749793
+parseUri: (uri: string, currencyCode?: string) => Promise<EdgeParsedUri>,
750794
+encodeUri: (obj: EdgeEncodeUri) => Promise<string>,
751795

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[]>
753804
}
754805

755806
// ---------------------------------------------------------------------
@@ -773,12 +824,16 @@ export type EdgeSwapRequest = {
773824
toWallet: EdgeCurrencyWallet,
774825

775826
// What?
776-
fromCurrencyCode: string,
777-
toCurrencyCode: string,
827+
fromTokenId: string,
828+
toTokenId: string,
778829

779830
// How much?
780831
nativeAmount: string,
781-
quoteFor: 'from' | 'max' | 'to'
832+
quoteFor: 'from' | 'max' | 'to',
833+
834+
// Deprecated. Use CurrencyId:
835+
fromCurrencyCode: string,
836+
toCurrencyCode: string
782837
}
783838

784839
/**
@@ -892,6 +947,13 @@ export type EdgeCurrencyConfig = {
892947

893948
+currencyInfo: EdgeCurrencyInfo,
894949

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

0 commit comments

Comments
 (0)