edge-core-js
Advanced tools
Comparing version 1.5.0 to 1.6.0
# edge-core-js | ||
## v1.6.0 (2023-09-11) | ||
- added: Currency-info support for multiple memos per transaction. | ||
- added: `EdgeCurrencyInfo.memoOptions`, lists acceptable memo types. | ||
- added: `EdgeCurrencyInfo.multipleMemos`, set if a currency supports multiple memos in the same transaction. | ||
- deprecated: `EdgeCurrencyInfo.memoMaxLength` | ||
- deprecated: `EdgeCurrencyInfo.memoMaxValue` | ||
- deprecated: `EdgeCurrencyInfo.memoType`. Note: If it is not set correctly, legacy plugins will no longer receive memos. Some buggy plugins forgot to do this, so those plugins will stop receiving memos. This is not a breaking change, though, since this field was always mandatory. | ||
- added: Spending support for multiple memos. | ||
- added: `EdgeSpendInfo.memos` | ||
- deprecated: `EdgeSpendTarget.memo` | ||
- added: Transaction history support for on-chain memos. | ||
- added: `EdgeTransaction.memos` | ||
- deprecated: `EdgeTransaction.spendTargets.memo` | ||
## v1.5.0 (2023-09-06) | ||
@@ -4,0 +19,0 @@ |
@@ -25,3 +25,5 @@ function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } }import { Bridgeable, bridgifyObject } from 'yaob' | ||
*/ | ||
export class CurrencyConfig extends Bridgeable { | ||
export class CurrencyConfig | ||
extends Bridgeable | ||
{ | ||
@@ -28,0 +30,0 @@ |
@@ -59,2 +59,3 @@ function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }import { add, div, lte, mul, sub } from 'biggystring' | ||
import { tokenIdsToCurrencyCodes, uniqueStrings } from './enabled-tokens' | ||
import { upgradeMemos } from './upgrade-memos' | ||
@@ -404,2 +405,3 @@ const fakeMetadata = { | ||
async getMaxSpendable(spendInfo) { | ||
spendInfo = upgradeMemos(spendInfo, plugin.currencyInfo) | ||
if (typeof engine.getMaxSpendable === 'function') { | ||
@@ -461,2 +463,3 @@ // Only provide wallet info if currency requires it: | ||
async makeSpend(spendInfo) { | ||
spendInfo = upgradeMemos(spendInfo, plugin.currencyInfo) | ||
const { | ||
@@ -487,16 +490,10 @@ skipChecks, | ||
for (const target of spendTargets) { | ||
const { publicAddress, nativeAmount = '0', otherParams = {} } = target | ||
const { | ||
memo, | ||
publicAddress, | ||
nativeAmount = '0', | ||
otherParams = {} | ||
} = target | ||
if (publicAddress == null) continue | ||
// Handle legacy spenders: | ||
let { memo = target.uniqueIdentifier } = target | ||
if (memo == null && typeof otherParams.uniqueIdentifier === 'string') { | ||
memo = otherParams.uniqueIdentifier | ||
} | ||
// Support legacy currency plugins: | ||
if (memo != null) { | ||
otherParams.uniqueIdentifier = memo | ||
} | ||
cleanTargets.push({ | ||
@@ -657,4 +654,5 @@ memo, | ||
date: tx.date, | ||
isSend: tx.isSend, | ||
memos: tx.memos, | ||
metadata: {}, | ||
isSend: tx.isSend, | ||
nativeAmount: _nullishCoalesce(tx.nativeAmount[currencyCode], () => ( '0')), | ||
@@ -661,0 +659,0 @@ networkFee: _nullishCoalesce(tx.networkFee[currencyCode], () => ( '0')), |
@@ -13,2 +13,3 @@ function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } }import { lt } from 'biggystring' | ||
import { compare } from '../../../util/compare' | ||
@@ -94,2 +95,3 @@ | ||
export const initialEnabledTokens = [] | ||
@@ -402,2 +404,3 @@ | ||
isSend: false, | ||
memos: [], | ||
ourReceiveAddresses: [], | ||
@@ -420,3 +423,4 @@ signedTx: '', | ||
currencyCode = defaultCurrency, | ||
isSend = lt(tx.nativeAmount, '0') | ||
isSend = lt(tx.nativeAmount, '0'), | ||
memos | ||
} = tx | ||
@@ -429,2 +433,3 @@ | ||
date: tx.date, | ||
memos, | ||
otherParams: tx.otherParams, | ||
@@ -431,0 +436,0 @@ ourReceiveAddresses: tx.ourReceiveAddresses, |
@@ -205,2 +205,48 @@ // @flow | ||
/** | ||
* Different currencies support different types of on-chain memos, | ||
* so this structure describes the options that are available, | ||
* along with the applicable limits. | ||
*/ | ||
export type EdgeMemoOption = | ||
| { | ||
type: "text"; | ||
hidden?: boolean; | ||
memoName?: string; | ||
/** Maximum number of text characters */ | ||
maxLength?: number; | ||
} | ||
| { | ||
type: "number"; | ||
hidden?: boolean; | ||
memoName?: string; | ||
/** | ||
* Maximum numerical value. | ||
* Numbers are passed as decimal strings. | ||
*/ | ||
maxValue?: string; | ||
} | ||
| { | ||
type: "hex"; | ||
hidden?: boolean; | ||
memoName?: string; | ||
/** Number of hexadecimal bytes. */ | ||
maxBytes?: number; | ||
minBytes?: number; | ||
}; | ||
export type EdgeMemo = { | ||
type: "text" | "number" | "hex"; | ||
value: string; | ||
/** Should we hide this from the user, such as for OP_RETURN? */ | ||
hidden?: boolean; | ||
/** What does the chain call this? Defaults to "memo". */ | ||
memoName?: string; | ||
} | ||
// token info ---------------------------------------------------------- | ||
@@ -309,6 +355,12 @@ | ||
requiredConfirmations?: number; // Block confirmations required for a tx | ||
memoMaxLength?: number; // Max number of text characters, if supported | ||
memoMaxValue?: string; // Max numerical value, if supported | ||
memoType?: "text" | "number" | "hex" | "other"; // undefined means no memo support | ||
/** | ||
* Lists the types of memos this chain supports. | ||
* A missing or empty list means no memo support. | ||
*/ | ||
memoOptions?: EdgeMemoOption[]; | ||
/** True if the transaction can have multiple memos at once: */ | ||
multipleMemos?: boolean; | ||
// Explorers: | ||
@@ -336,2 +388,11 @@ addressExplorer: string; | ||
symbolImageDarkMono?: string; | ||
/** @deprecated Use memoOptions instead. */ | ||
memoMaxLength?: number; // Max number of text characters, if supported | ||
/** @deprecated Use memoOptions instead. */ | ||
memoMaxValue?: string; // Max numerical value, if supported | ||
/** @deprecated Use memoOptions instead. */ | ||
memoType?: "text" | "number" | "hex" | "other"; // undefined means no memo support | ||
} | ||
@@ -410,2 +471,3 @@ | ||
signedTx: string; | ||
memos: EdgeMemo[]; | ||
ourReceiveAddresses: string[]; | ||
@@ -420,8 +482,10 @@ | ||
+currencyCode: string; | ||
+memo: string | void; | ||
+nativeAmount: string; | ||
+publicAddress: string; | ||
/** @deprecated Use memo instead */ | ||
uniqueIdentifier: string | void; | ||
/** @deprecated Use `EdgeTransaction.memos` instead */ | ||
+memo: string | void; | ||
/** @deprecated Use `EdgeTransaction.memos` instead */ | ||
+uniqueIdentifier: string | void; | ||
}>; | ||
@@ -446,3 +510,2 @@ swapData?: EdgeTxSwap; | ||
export type EdgeSpendTarget = { | ||
memo?: string; | ||
nativeAmount?: string; | ||
@@ -452,3 +515,6 @@ otherParams?: JsonObject; | ||
/** @deprecated Use memo instead */ | ||
/** @deprecated. Use `EdgeSpendInfo.memos` instead. */ | ||
memo?: string; | ||
/** @deprecated. Use `EdgeSpendInfo.memos` instead. */ | ||
uniqueIdentifier?: string; // Use memo instead. | ||
@@ -470,2 +536,3 @@ } | ||
spendTargets: EdgeSpendTarget[]; | ||
memos?: EdgeMemo[]; | ||
@@ -807,2 +874,3 @@ // Options: | ||
/** @deprecated Use EdgeCurrencyInfo.memoOptions instead */ | ||
export type EdgeMemoRules = { | ||
@@ -853,3 +921,3 @@ passed: boolean; | ||
// Transaction memos: | ||
/** @deprecated Use EdgeCurrencyInfo.memoOptions instead */ | ||
+validateMemo?: (memo: string) => Promise<EdgeMemoRules>; | ||
@@ -967,3 +1035,2 @@ } | ||
) => Promise<string>; | ||
+validateMemo: (memo: string) => Promise<EdgeMemoRules>; | ||
@@ -1051,2 +1118,5 @@ // Chain state: | ||
+otherMethods: EdgeOtherMethods; | ||
/** @deprecated Use EdgeCurrencyInfo.memoOptions instead */ | ||
+validateMemo: (memo: string) => Promise<EdgeMemoRules>; | ||
} | ||
@@ -1053,0 +1123,0 @@ |
@@ -1745,1 +1745,71 @@ | ||
{ | ||
"name": "edge-core-js", | ||
"version": "1.5.0", | ||
"version": "1.6.0", | ||
"description": "Edge account & wallet management library", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
@@ -203,2 +203,48 @@ import type { Disklet } from 'disklet' | ||
/** | ||
* Different currencies support different types of on-chain memos, | ||
* so this structure describes the options that are available, | ||
* along with the applicable limits. | ||
*/ | ||
export type EdgeMemoOption = | ||
| { | ||
type: 'text' | ||
hidden?: boolean | ||
memoName?: string | ||
/** Maximum number of text characters */ | ||
maxLength?: number | ||
} | ||
| { | ||
type: 'number' | ||
hidden?: boolean | ||
memoName?: string | ||
/** | ||
* Maximum numerical value. | ||
* Numbers are passed as decimal strings. | ||
*/ | ||
maxValue?: string | ||
} | ||
| { | ||
type: 'hex' | ||
hidden?: boolean | ||
memoName?: string | ||
/** Number of hexadecimal bytes. */ | ||
maxBytes?: number | ||
minBytes?: number | ||
} | ||
export interface EdgeMemo { | ||
type: 'text' | 'number' | 'hex' | ||
value: string | ||
/** Should we hide this from the user, such as for OP_RETURN? */ | ||
hidden?: boolean | ||
/** What does the chain call this? Defaults to "memo". */ | ||
memoName?: string | ||
} | ||
// token info ---------------------------------------------------------- | ||
@@ -307,6 +353,12 @@ | ||
requiredConfirmations?: number // Block confirmations required for a tx | ||
memoMaxLength?: number // Max number of text characters, if supported | ||
memoMaxValue?: string // Max numerical value, if supported | ||
memoType?: 'text' | 'number' | 'hex' | 'other' // undefined means no memo support | ||
/** | ||
* Lists the types of memos this chain supports. | ||
* A missing or empty list means no memo support. | ||
*/ | ||
memoOptions?: EdgeMemoOption[] | ||
/** True if the transaction can have multiple memos at once: */ | ||
multipleMemos?: boolean | ||
// Explorers: | ||
@@ -334,2 +386,11 @@ addressExplorer: string | ||
symbolImageDarkMono?: string | ||
/** @deprecated Use memoOptions instead. */ | ||
memoMaxLength?: number // Max number of text characters, if supported | ||
/** @deprecated Use memoOptions instead. */ | ||
memoMaxValue?: string // Max numerical value, if supported | ||
/** @deprecated Use memoOptions instead. */ | ||
memoType?: 'text' | 'number' | 'hex' | 'other' // undefined means no memo support | ||
} | ||
@@ -408,2 +469,3 @@ | ||
signedTx: string | ||
memos: EdgeMemo[] | ||
ourReceiveAddresses: string[] | ||
@@ -418,8 +480,10 @@ | ||
readonly currencyCode: string | ||
readonly memo: string | undefined | ||
readonly nativeAmount: string | ||
readonly publicAddress: string | ||
/** @deprecated Use memo instead */ | ||
uniqueIdentifier: string | undefined | ||
/** @deprecated Use `EdgeTransaction.memos` instead */ | ||
readonly memo: string | undefined | ||
/** @deprecated Use `EdgeTransaction.memos` instead */ | ||
readonly uniqueIdentifier: string | undefined | ||
}> | ||
@@ -444,3 +508,2 @@ swapData?: EdgeTxSwap | ||
export interface EdgeSpendTarget { | ||
memo?: string | ||
nativeAmount?: string | ||
@@ -450,3 +513,6 @@ otherParams?: JsonObject | ||
/** @deprecated Use memo instead */ | ||
/** @deprecated. Use `EdgeSpendInfo.memos` instead. */ | ||
memo?: string | ||
/** @deprecated. Use `EdgeSpendInfo.memos` instead. */ | ||
uniqueIdentifier?: string // Use memo instead. | ||
@@ -468,2 +534,3 @@ } | ||
spendTargets: EdgeSpendTarget[] | ||
memos?: EdgeMemo[] | ||
@@ -801,2 +868,3 @@ // Options: | ||
/** @deprecated Use EdgeCurrencyInfo.memoOptions instead */ | ||
export interface EdgeMemoRules { | ||
@@ -847,3 +915,3 @@ passed: boolean | ||
// Transaction memos: | ||
/** @deprecated Use EdgeCurrencyInfo.memoOptions instead */ | ||
readonly validateMemo?: (memo: string) => Promise<EdgeMemoRules> | ||
@@ -961,3 +1029,2 @@ } | ||
) => Promise<string> | ||
readonly validateMemo: (memo: string) => Promise<EdgeMemoRules> | ||
@@ -1045,2 +1112,5 @@ // Chain state: | ||
readonly otherMethods: EdgeOtherMethods | ||
/** @deprecated Use EdgeCurrencyInfo.memoOptions instead */ | ||
readonly validateMemo: (memo: string) => Promise<EdgeMemoRules> | ||
} | ||
@@ -1047,0 +1117,0 @@ |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
32799
3405610