edge-core-js 2.1.0 → 2.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +8 -0
- package/android/src/main/assets/edge-core-js/edge-core.js +1 -1
- package/lib/core/account/account-api.js +18 -4
- package/lib/core/login/keys.js +4 -1
- package/lib/flow/types.js +1 -0
- package/lib/node/index.js +22 -6
- package/lib/types/types.js +1 -0
- package/package.json +1 -1
- package/src/types/types.ts +1 -0
|
@@ -517,7 +517,7 @@ export function makeAccountApi(ai, accountId) {
|
|
|
517
517
|
return await Promise.all(
|
|
518
518
|
walletInfos.map(
|
|
519
519
|
async (info, i) =>
|
|
520
|
-
await
|
|
520
|
+
await makeEdgeResult(
|
|
521
521
|
finishWalletCreation(ai, accountId, info.id, createWallets[i])
|
|
522
522
|
)
|
|
523
523
|
)
|
|
@@ -596,10 +596,14 @@ export function makeAccountApi(ai, accountId) {
|
|
|
596
596
|
`getActivationAssets unsupported by walletId ${activateWalletId}`
|
|
597
597
|
)
|
|
598
598
|
|
|
599
|
-
|
|
599
|
+
const out = await engine.engineGetActivationAssets({
|
|
600
600
|
currencyWallets,
|
|
601
601
|
activateTokenIds
|
|
602
602
|
})
|
|
603
|
+
|
|
604
|
+
// Added for backward compatibility for plugins using core 1.x
|
|
605
|
+
out.assetOptions.forEach(asset => (asset.tokenId = _nullishCoalesce(asset.tokenId, () => ( null))))
|
|
606
|
+
return out
|
|
603
607
|
},
|
|
604
608
|
|
|
605
609
|
async activateWallet(
|
|
@@ -632,8 +636,18 @@ export function makeAccountApi(ai, accountId) {
|
|
|
632
636
|
wallet,
|
|
633
637
|
tokenId: paymentInfo.tokenId
|
|
634
638
|
}
|
|
635
|
-
: undefined
|
|
639
|
+
: undefined,
|
|
640
|
+
|
|
641
|
+
// Added for backward compatibility for plugins using core 1.x
|
|
642
|
+
// @ts-expect-error
|
|
643
|
+
paymentTokenId: _optionalChain([paymentInfo, 'optionalAccess', _2 => _2.tokenId]),
|
|
644
|
+
paymentWallet: wallet
|
|
636
645
|
})
|
|
646
|
+
|
|
647
|
+
// Added for backward compatibility for plugins using core 1.x
|
|
648
|
+
// @ts-expect-error
|
|
649
|
+
if (out.networkFee.tokenId === undefined) out.networkFee.tokenId = null
|
|
650
|
+
|
|
637
651
|
return bridgifyObject(out)
|
|
638
652
|
},
|
|
639
653
|
|
|
@@ -687,7 +701,7 @@ function getRawPrivateKey(
|
|
|
687
701
|
return info
|
|
688
702
|
}
|
|
689
703
|
|
|
690
|
-
async function
|
|
704
|
+
async function makeEdgeResult(promise) {
|
|
691
705
|
try {
|
|
692
706
|
return { ok: true, result: await promise }
|
|
693
707
|
} catch (error) {
|
package/lib/core/login/keys.js
CHANGED
|
@@ -287,7 +287,7 @@ export async function finishWalletCreation(
|
|
|
287
287
|
walletId,
|
|
288
288
|
opts
|
|
289
289
|
) {
|
|
290
|
-
const { migratedFromWalletId, name
|
|
290
|
+
const { enabledTokenIds, fiatCurrencyCode, migratedFromWalletId, name } = opts
|
|
291
291
|
const wallet = await waitForCurrencyWallet(ai, walletId)
|
|
292
292
|
|
|
293
293
|
// Write ancillary files to disk:
|
|
@@ -302,6 +302,9 @@ export async function finishWalletCreation(
|
|
|
302
302
|
if (fiatCurrencyCode != null) {
|
|
303
303
|
await wallet.setFiatCurrencyCode(fiatCurrencyCode)
|
|
304
304
|
}
|
|
305
|
+
if (enabledTokenIds != null && enabledTokenIds.length > 0) {
|
|
306
|
+
await wallet.changeEnabledTokenIds(enabledTokenIds)
|
|
307
|
+
}
|
|
305
308
|
|
|
306
309
|
return wallet
|
|
307
310
|
}
|
package/lib/flow/types.js
CHANGED
|
@@ -1384,6 +1384,7 @@ export type ChangeUsernameOptions = {
|
|
|
1384
1384
|
// currencies ----------------------------------------------------------
|
|
1385
1385
|
|
|
1386
1386
|
export type EdgeCreateCurrencyWalletOptions = {
|
|
1387
|
+
enabledTokenIds?: string[];
|
|
1387
1388
|
fiatCurrencyCode?: string;
|
|
1388
1389
|
name?: string;
|
|
1389
1390
|
|
package/lib/node/index.js
CHANGED
|
@@ -2171,9 +2171,10 @@ async function makeCurrencyWalletKeys(ai, walletType, opts) {
|
|
|
2171
2171
|
}
|
|
2172
2172
|
async function finishWalletCreation(ai, accountId, walletId, opts) {
|
|
2173
2173
|
const {
|
|
2174
|
+
enabledTokenIds,
|
|
2175
|
+
fiatCurrencyCode,
|
|
2174
2176
|
migratedFromWalletId,
|
|
2175
|
-
name
|
|
2176
|
-
fiatCurrencyCode
|
|
2177
|
+
name
|
|
2177
2178
|
} = opts;
|
|
2178
2179
|
const wallet = await waitForCurrencyWallet(ai, walletId);
|
|
2179
2180
|
|
|
@@ -2191,6 +2192,9 @@ async function finishWalletCreation(ai, accountId, walletId, opts) {
|
|
|
2191
2192
|
if (fiatCurrencyCode != null) {
|
|
2192
2193
|
await wallet.setFiatCurrencyCode(fiatCurrencyCode);
|
|
2193
2194
|
}
|
|
2195
|
+
if (enabledTokenIds != null && enabledTokenIds.length > 0) {
|
|
2196
|
+
await wallet.changeEnabledTokenIds(enabledTokenIds);
|
|
2197
|
+
}
|
|
2194
2198
|
return wallet;
|
|
2195
2199
|
}
|
|
2196
2200
|
|
|
@@ -9160,7 +9164,7 @@ function makeAccountApi(ai, accountId) {
|
|
|
9160
9164
|
await applyKit(ai, loginTree, makeKeysKit(ai, login, walletInfos));
|
|
9161
9165
|
|
|
9162
9166
|
// Set up options:
|
|
9163
|
-
return await Promise.all(walletInfos.map(async (info, i) => await
|
|
9167
|
+
return await Promise.all(walletInfos.map(async (info, i) => await makeEdgeResult(finishWalletCreation(ai, accountId, info.id, createWallets[i]))));
|
|
9164
9168
|
},
|
|
9165
9169
|
async waitForCurrencyWallet(walletId) {
|
|
9166
9170
|
return await new Promise((resolve, reject) => {
|
|
@@ -9213,10 +9217,14 @@ function makeAccountApi(ai, accountId) {
|
|
|
9213
9217
|
} = walletOutput;
|
|
9214
9218
|
if (engine == null) throw new Error(`Invalid wallet: ${activateWalletId} not found`);
|
|
9215
9219
|
if (engine.engineGetActivationAssets == null) throw new Error(`getActivationAssets unsupported by walletId ${activateWalletId}`);
|
|
9216
|
-
|
|
9220
|
+
const out = await engine.engineGetActivationAssets({
|
|
9217
9221
|
currencyWallets,
|
|
9218
9222
|
activateTokenIds
|
|
9219
9223
|
});
|
|
9224
|
+
|
|
9225
|
+
// Added for backward compatibility for plugins using core 1.x
|
|
9226
|
+
out.assetOptions.forEach(asset => asset.tokenId = asset.tokenId ?? null);
|
|
9227
|
+
return out;
|
|
9220
9228
|
},
|
|
9221
9229
|
async activateWallet(opts) {
|
|
9222
9230
|
const {
|
|
@@ -9243,8 +9251,16 @@ function makeAccountApi(ai, accountId) {
|
|
|
9243
9251
|
paymentInfo: paymentInfo != null ? {
|
|
9244
9252
|
wallet,
|
|
9245
9253
|
tokenId: paymentInfo.tokenId
|
|
9246
|
-
} : undefined
|
|
9254
|
+
} : undefined,
|
|
9255
|
+
// Added for backward compatibility for plugins using core 1.x
|
|
9256
|
+
// @ts-expect-error
|
|
9257
|
+
paymentTokenId: paymentInfo?.tokenId,
|
|
9258
|
+
paymentWallet: wallet
|
|
9247
9259
|
});
|
|
9260
|
+
|
|
9261
|
+
// Added for backward compatibility for plugins using core 1.x
|
|
9262
|
+
// @ts-expect-error
|
|
9263
|
+
if (out.networkFee.tokenId === undefined) out.networkFee.tokenId = null;
|
|
9248
9264
|
return yaob.bridgifyObject(out);
|
|
9249
9265
|
},
|
|
9250
9266
|
// ----------------------------------------------------------------
|
|
@@ -9278,7 +9294,7 @@ function getRawPrivateKey(ai, accountId, walletId) {
|
|
|
9278
9294
|
}
|
|
9279
9295
|
return info;
|
|
9280
9296
|
}
|
|
9281
|
-
async function
|
|
9297
|
+
async function makeEdgeResult(promise) {
|
|
9282
9298
|
try {
|
|
9283
9299
|
return {
|
|
9284
9300
|
ok: true,
|
package/lib/types/types.js
CHANGED
package/package.json
CHANGED
package/src/types/types.ts
CHANGED
|
@@ -1378,6 +1378,7 @@ export interface ChangeUsernameOptions {
|
|
|
1378
1378
|
// currencies ----------------------------------------------------------
|
|
1379
1379
|
|
|
1380
1380
|
export interface EdgeCreateCurrencyWalletOptions {
|
|
1381
|
+
enabledTokenIds?: string[]
|
|
1381
1382
|
fiatCurrencyCode?: string
|
|
1382
1383
|
name?: string
|
|
1383
1384
|
|