edge-core-js 2.43.6 → 2.45.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/lib/node/index.js CHANGED
@@ -294,7 +294,6 @@ const asLoginRequestBody = cleaners.asObject({
294
294
  lra1: cleaners.asOptional(asBase64),
295
295
  recoveryAuth: cleaners.asOptional(asBase64) // lra1
296
296
  });
297
-
298
297
  const asLoginResponseBody = cleaners.asObject({
299
298
  // The response payload:
300
299
  results: cleaners.asOptional(cleaners.asUnknown),
@@ -626,6 +625,7 @@ function validateServer(server) {
626
625
  * and the GUI should just show them with a stack trace & generic message,
627
626
  * since the program has basically crashed at that point.
628
627
  */
628
+
629
629
  /**
630
630
  * Thrown when the login server requires a CAPTCHA.
631
631
  *
@@ -859,19 +859,19 @@ function PinDisabledError(message) {
859
859
  */
860
860
  function PendingFundsError(message = 'Not enough confirmed funds') {
861
861
  if (!(this instanceof PendingFundsError)) throw new TypeError("Class constructor PendingFundsError cannot be invoked without 'new'");
862
- var _this10;
863
- function _super10(message) {
864
- _this10 = new Error(message);
865
- Object.defineProperty(_this10, "constructor", {
862
+ var _this0;
863
+ function _super0(message) {
864
+ _this0 = new Error(message);
865
+ Object.defineProperty(_this0, "constructor", {
866
866
  value: PendingFundsError,
867
867
  configurable: true,
868
868
  writable: true
869
869
  });
870
- return _this10;
870
+ return _this0;
871
871
  }
872
- _super10(message);
873
- _this10.name = 'PendingFundsError';
874
- return _this10;
872
+ _super0(message);
873
+ _this0.name = 'PendingFundsError';
874
+ return _this0;
875
875
  }
876
876
 
877
877
  /**
@@ -879,19 +879,19 @@ function PendingFundsError(message = 'Not enough confirmed funds') {
879
879
  */
880
880
  function SameCurrencyError(message = 'Wallets can not be the same currency') {
881
881
  if (!(this instanceof SameCurrencyError)) throw new TypeError("Class constructor SameCurrencyError cannot be invoked without 'new'");
882
- var _this11;
883
- function _super11(message) {
884
- _this11 = new Error(message);
885
- Object.defineProperty(_this11, "constructor", {
882
+ var _this1;
883
+ function _super1(message) {
884
+ _this1 = new Error(message);
885
+ Object.defineProperty(_this1, "constructor", {
886
886
  value: SameCurrencyError,
887
887
  configurable: true,
888
888
  writable: true
889
889
  });
890
- return _this11;
890
+ return _this1;
891
891
  }
892
- _super11(message);
893
- _this11.name = 'SameCurrencyError';
894
- return _this11;
892
+ _super1(message);
893
+ _this1.name = 'SameCurrencyError';
894
+ return _this1;
895
895
  }
896
896
 
897
897
  /**
@@ -899,19 +899,19 @@ function SameCurrencyError(message = 'Wallets can not be the same currency') {
899
899
  */
900
900
  function SpendToSelfError(message = 'Spending to self') {
901
901
  if (!(this instanceof SpendToSelfError)) throw new TypeError("Class constructor SpendToSelfError cannot be invoked without 'new'");
902
- var _this12;
903
- function _super12(message) {
904
- _this12 = new Error(message);
905
- Object.defineProperty(_this12, "constructor", {
902
+ var _this10;
903
+ function _super10(message) {
904
+ _this10 = new Error(message);
905
+ Object.defineProperty(_this10, "constructor", {
906
906
  value: SpendToSelfError,
907
907
  configurable: true,
908
908
  writable: true
909
909
  });
910
- return _this12;
910
+ return _this10;
911
911
  }
912
- _super12(message);
913
- _this12.name = 'SpendToSelfError';
914
- return _this12;
912
+ _super10(message);
913
+ _this10.name = 'SpendToSelfError';
914
+ return _this10;
915
915
  }
916
916
 
917
917
  /**
@@ -921,23 +921,23 @@ function SpendToSelfError(message = 'Spending to self') {
921
921
  */
922
922
  function SwapAboveLimitError(swapInfo, nativeMax, direction = 'from') {
923
923
  if (!(this instanceof SwapAboveLimitError)) throw new TypeError("Class constructor SwapAboveLimitError cannot be invoked without 'new'");
924
- var _this13;
925
- function _super13(message) {
926
- _this13 = new Error(message);
927
- Object.defineProperty(_this13, "constructor", {
924
+ var _this11;
925
+ function _super11(message) {
926
+ _this11 = new Error(message);
927
+ Object.defineProperty(_this11, "constructor", {
928
928
  value: SwapAboveLimitError,
929
929
  configurable: true,
930
930
  writable: true
931
931
  });
932
- return _this13;
932
+ return _this11;
933
933
  }
934
- _super13('Amount is too high');
935
- _this13.name = 'SwapAboveLimitError';
936
- _this13.pluginId = swapInfo.pluginId;
937
- _this13.swapPluginId = swapInfo.pluginId;
938
- _this13.nativeMax = nativeMax ?? '';
939
- _this13.direction = direction;
940
- return _this13;
934
+ _super11('Amount is too high');
935
+ _this11.name = 'SwapAboveLimitError';
936
+ _this11.pluginId = swapInfo.pluginId;
937
+ _this11.swapPluginId = swapInfo.pluginId;
938
+ _this11.nativeMax = nativeMax ?? '';
939
+ _this11.direction = direction;
940
+ return _this11;
941
941
  }
942
942
 
943
943
  /**
@@ -947,23 +947,23 @@ function SwapAboveLimitError(swapInfo, nativeMax, direction = 'from') {
947
947
  */
948
948
  function SwapBelowLimitError(swapInfo, nativeMin, direction = 'from') {
949
949
  if (!(this instanceof SwapBelowLimitError)) throw new TypeError("Class constructor SwapBelowLimitError cannot be invoked without 'new'");
950
- var _this14;
951
- function _super14(message) {
952
- _this14 = new Error(message);
953
- Object.defineProperty(_this14, "constructor", {
950
+ var _this12;
951
+ function _super12(message) {
952
+ _this12 = new Error(message);
953
+ Object.defineProperty(_this12, "constructor", {
954
954
  value: SwapBelowLimitError,
955
955
  configurable: true,
956
956
  writable: true
957
957
  });
958
- return _this14;
958
+ return _this12;
959
959
  }
960
- _super14('Amount is too low');
961
- _this14.name = 'SwapBelowLimitError';
962
- _this14.pluginId = swapInfo.pluginId;
963
- _this14.swapPluginId = swapInfo.pluginId;
964
- _this14.nativeMin = nativeMin ?? '';
965
- _this14.direction = direction;
966
- return _this14;
960
+ _super12('Amount is too low');
961
+ _this12.name = 'SwapBelowLimitError';
962
+ _this12.pluginId = swapInfo.pluginId;
963
+ _this12.swapPluginId = swapInfo.pluginId;
964
+ _this12.nativeMin = nativeMin ?? '';
965
+ _this12.direction = direction;
966
+ return _this12;
967
967
  }
968
968
 
969
969
  /**
@@ -971,15 +971,15 @@ function SwapBelowLimitError(swapInfo, nativeMin, direction = 'from') {
971
971
  */
972
972
  function SwapCurrencyError(swapInfo, request) {
973
973
  if (!(this instanceof SwapCurrencyError)) throw new TypeError("Class constructor SwapCurrencyError cannot be invoked without 'new'");
974
- var _this15;
975
- function _super15(message) {
976
- _this15 = new Error(message);
977
- Object.defineProperty(_this15, "constructor", {
974
+ var _this13;
975
+ function _super13(message) {
976
+ _this13 = new Error(message);
977
+ Object.defineProperty(_this13, "constructor", {
978
978
  value: SwapCurrencyError,
979
979
  configurable: true,
980
980
  writable: true
981
981
  });
982
- return _this15;
982
+ return _this13;
983
983
  }
984
984
  const {
985
985
  fromWallet,
@@ -991,12 +991,12 @@ function SwapCurrencyError(swapInfo, request) {
991
991
  const toPluginId = toWallet.currencyConfig.currencyInfo.pluginId;
992
992
  const fromString = `${fromPluginId}:${String(fromTokenId)}`;
993
993
  const toString = `${toPluginId}:${String(toTokenId)}`;
994
- _super15(`${swapInfo.displayName} does not support ${fromString} to ${toString}`);
995
- _this15.name = 'SwapCurrencyError';
996
- _this15.pluginId = swapInfo.pluginId;
997
- _this15.fromTokenId = fromTokenId ?? null;
998
- _this15.toTokenId = toTokenId ?? null;
999
- return _this15;
994
+ _super13(`${swapInfo.displayName} does not support ${fromString} to ${toString}`);
995
+ _this13.name = 'SwapCurrencyError';
996
+ _this13.pluginId = swapInfo.pluginId;
997
+ _this13.fromTokenId = fromTokenId ?? null;
998
+ _this13.toTokenId = toTokenId ?? null;
999
+ return _this13;
1000
1000
  }
1001
1001
  /**
1002
1002
  * The user is not allowed to swap these coins for some reason
@@ -1008,54 +1008,54 @@ function SwapCurrencyError(swapInfo, request) {
1008
1008
  */
1009
1009
  function SwapPermissionError(swapInfo, reason) {
1010
1010
  if (!(this instanceof SwapPermissionError)) throw new TypeError("Class constructor SwapPermissionError cannot be invoked without 'new'");
1011
- var _this16;
1012
- function _super16(message) {
1013
- _this16 = new Error(message);
1014
- Object.defineProperty(_this16, "constructor", {
1011
+ var _this14;
1012
+ function _super14(message) {
1013
+ _this14 = new Error(message);
1014
+ Object.defineProperty(_this14, "constructor", {
1015
1015
  value: SwapPermissionError,
1016
1016
  configurable: true,
1017
1017
  writable: true
1018
1018
  });
1019
- return _this16;
1019
+ return _this14;
1020
1020
  }
1021
- if (reason != null) _super16(reason);else _super16('You are not allowed to make this trade');
1022
- _this16.name = 'SwapPermissionError';
1023
- _this16.pluginId = swapInfo.pluginId;
1024
- _this16.reason = reason;
1025
- return _this16;
1021
+ if (reason != null) _super14(reason);else _super14('You are not allowed to make this trade');
1022
+ _this14.name = 'SwapPermissionError';
1023
+ _this14.pluginId = swapInfo.pluginId;
1024
+ _this14.reason = reason;
1025
+ return _this14;
1026
1026
  }
1027
1027
 
1028
1028
  // Address requirements for certain swap flows (extend as needed):
1029
1029
 
1030
1030
  function SwapAddressError(swapInfo, opts) {
1031
1031
  if (!(this instanceof SwapAddressError)) throw new TypeError("Class constructor SwapAddressError cannot be invoked without 'new'");
1032
- var _this17;
1033
- function _super17(message) {
1034
- _this17 = new Error(message);
1035
- Object.defineProperty(_this17, "constructor", {
1032
+ var _this15;
1033
+ function _super15(message) {
1034
+ _this15 = new Error(message);
1035
+ Object.defineProperty(_this15, "constructor", {
1036
1036
  value: SwapAddressError,
1037
1037
  configurable: true,
1038
1038
  writable: true
1039
1039
  });
1040
- return _this17;
1040
+ return _this15;
1041
1041
  }
1042
1042
  const {
1043
1043
  reason
1044
1044
  } = opts;
1045
1045
  switch (reason) {
1046
1046
  case 'mustMatch':
1047
- _super17('This swap requires from and to wallets to have the same address');
1047
+ _super15('This swap requires from and to wallets to have the same address');
1048
1048
  break;
1049
1049
  case 'mustBeActivated':
1050
- _super17('The destination wallet must be activated to receive this swap.');
1050
+ _super15('The destination wallet must be activated to receive this swap.');
1051
1051
  break;
1052
1052
  default:
1053
- _super17('Invalid swap address');
1053
+ _super15('Invalid swap address');
1054
1054
  }
1055
- _this17.name = 'SwapAddressError';
1056
- _this17.swapPluginId = swapInfo.pluginId;
1057
- _this17.reason = reason;
1058
- return _this17;
1055
+ _this15.name = 'SwapAddressError';
1056
+ _this15.swapPluginId = swapInfo.pluginId;
1057
+ _this15.reason = reason;
1058
+ return _this15;
1059
1059
  }
1060
1060
 
1061
1061
  /**
@@ -1068,19 +1068,19 @@ function SwapAddressError(swapInfo, opts) {
1068
1068
  */
1069
1069
  function UsernameError(message = 'Invalid username') {
1070
1070
  if (!(this instanceof UsernameError)) throw new TypeError("Class constructor UsernameError cannot be invoked without 'new'");
1071
- var _this18;
1072
- function _super18(message) {
1073
- _this18 = new Error(message);
1074
- Object.defineProperty(_this18, "constructor", {
1071
+ var _this16;
1072
+ function _super16(message) {
1073
+ _this16 = new Error(message);
1074
+ Object.defineProperty(_this16, "constructor", {
1075
1075
  value: UsernameError,
1076
1076
  configurable: true,
1077
1077
  writable: true
1078
1078
  });
1079
- return _this18;
1079
+ return _this16;
1080
1080
  }
1081
- _super18(message);
1082
- _this18.name = 'UsernameError';
1083
- return _this18;
1081
+ _super16(message);
1082
+ _this16.name = 'UsernameError';
1083
+ return _this16;
1084
1084
  }
1085
1085
  function asMaybeError(name) {
1086
1086
  return function asError(raw) {
@@ -2638,7 +2638,6 @@ const carePackageFile = makeJsonFile(cleaners.asObject({
2638
2638
  // questionKeySnrp
2639
2639
  ERQ: cleaners.asOptional(asEdgeBox) // questionBox
2640
2640
  }));
2641
-
2642
2641
  const loginPackageFile = makeJsonFile(cleaners.asObject({
2643
2642
  EMK_LP2: asEdgeBox,
2644
2643
  // passwordBox
@@ -2649,7 +2648,6 @@ const loginPackageFile = makeJsonFile(cleaners.asObject({
2649
2648
  // syncKeyBox
2650
2649
  ELP1: asEdgeBox // passwordAuthBox
2651
2650
  }));
2652
-
2653
2651
  const otpFile = makeJsonFile(cleaners.asObject({
2654
2652
  TOTP: asBase32
2655
2653
  }));
@@ -3169,6 +3167,7 @@ function hashStorageWalletFilename(state, walletId, data) {
3169
3167
  // ---------------------------------------------------------------------
3170
3168
  // building-block types
3171
3169
  // ---------------------------------------------------------------------
3170
+
3172
3171
  const asEdgeDenomination = cleaners.asObject({
3173
3172
  multiplier: cleaners.asString,
3174
3173
  name: cleaners.asString,
@@ -4738,6 +4737,7 @@ const asDiskMetadata = cleaners.asObject({
4738
4737
  // ---------------------------------------------------------------------
4739
4738
  // building-block cleaners
4740
4739
  // ---------------------------------------------------------------------
4740
+
4741
4741
  const asEdgeTokenId = cleaners.asEither(cleaners.asString, cleaners.asNull);
4742
4742
  const asFeeRate = cleaners.asValue('high', 'standard', 'low');
4743
4743
  const asEdgeTxSwap = cleaners.asObject({
@@ -5519,7 +5519,6 @@ async function getQuestions2(ai, recovery2Key, username) {
5519
5519
  recovery2Id: makeRecovery2Id(recovery2Key, username)
5520
5520
  // "otp": null
5521
5521
  };
5522
-
5523
5522
  const reply = await loginFetch(ai, 'POST', '/v2/login', request);
5524
5523
  const {
5525
5524
  question2Box
@@ -9143,7 +9142,6 @@ const walletPixie = reduxPixies.combinePixies({
9143
9142
  });
9144
9143
  await snooze(100); // Rate limiting
9145
9144
  }
9146
-
9147
9145
  lastEnabledTokenIds = enabledTokenIds;
9148
9146
  };
9149
9147
  },
@@ -9200,7 +9198,6 @@ const walletPixie = reduxPixies.combinePixies({
9200
9198
  }
9201
9199
  } // else { no token support }
9202
9200
  }
9203
-
9204
9201
  lastTokens = customTokens;
9205
9202
 
9206
9203
  // Update enabled tokens:
@@ -9217,7 +9214,6 @@ const walletPixie = reduxPixies.combinePixies({
9217
9214
  await engine.enableTokens(added).catch(error => input.props.onError(error));
9218
9215
  } // else { no token support }
9219
9216
  }
9220
-
9221
9217
  lastEnabledTokenIds = allEnabledTokenIds;
9222
9218
  };
9223
9219
  }
@@ -9731,6 +9727,22 @@ const makeMemoryWalletInner = async (ai, config, walletType, opts = {}) => {
9731
9727
  wait: false
9732
9728
  });
9733
9729
  }
9730
+ const otherMethods = {};
9731
+ if (engine.otherMethods != null) {
9732
+ for (const name of Object.keys(engine.otherMethods)) {
9733
+ const method = engine.otherMethods[name];
9734
+ if (typeof method !== 'function') continue;
9735
+ otherMethods[name] = method;
9736
+ }
9737
+ }
9738
+ if (engine.otherMethodsWithKeys != null) {
9739
+ for (const name of Object.keys(engine.otherMethodsWithKeys)) {
9740
+ const method = engine.otherMethodsWithKeys[name];
9741
+ if (typeof method !== 'function') continue;
9742
+ otherMethods[name] = (...args) => method(walletInfo.keys, ...args);
9743
+ }
9744
+ }
9745
+ yaob.bridgifyObject(otherMethods);
9734
9746
  const out = yaob.bridgifyObject({
9735
9747
  watch: yaob.watchMethod,
9736
9748
  get balanceMap() {
@@ -9769,6 +9781,7 @@ const makeMemoryWalletInner = async (ai, config, walletType, opts = {}) => {
9769
9781
  return await engine.broadcastTx(tx, unsafeBroadcastTx ? privateKeys : undefined);
9770
9782
  },
9771
9783
  async saveTx() {},
9784
+ otherMethods,
9772
9785
  async close() {
9773
9786
  log.warn('killing memory wallet');
9774
9787
  syncNetworkTask?.stop();
@@ -11134,7 +11147,6 @@ const accountPixie = reduxPixies.combinePixies({
11134
11147
  await saveCustomTokens(toApiInput(input), accountId).catch(error => input.props.onError(error));
11135
11148
  await snooze(100); // Rate limiting
11136
11149
  }
11137
-
11138
11150
  lastTokens = customTokens;
11139
11151
  };
11140
11152
  },
@@ -11182,7 +11194,6 @@ const accountPixie = reduxPixies.combinePixies({
11182
11194
  // }
11183
11195
  };
11184
11196
  },
11185
-
11186
11197
  currencyWallets(input) {
11187
11198
  let lastActiveWalletIds;
11188
11199
  return () => {
@@ -12092,8 +12103,7 @@ cleaners.asString,
12092
12103
  // address
12093
12104
  cleaners.asOptional(cleaners.asString) // checkpoint
12094
12105
  );
12095
-
12096
- const asSubscribeResult = cleaners.asValue( /** Subscribe failed; not supported */
12106
+ const asSubscribeResult = cleaners.asValue(/** Subscribe failed; not supported */
12097
12107
  -1, /** Subscribe failed; some thing went wrong */
12098
12108
  0, /** Subscribe succeeded, no changes */
12099
12109
  1, /** Subscribed succeeded, changes present */
@@ -2235,5 +2235,6 @@ export * from './server-types'
2235
2235
 
2236
2236
 
2237
2237
 
2238
+
2238
2239
 
2239
2240
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "edge-core-js",
3
- "version": "2.43.6",
3
+ "version": "2.45.0",
4
4
  "description": "Edge account & wallet management library",
5
5
  "keywords": [
6
6
  "bitcoin",
@@ -82,7 +82,7 @@
82
82
  "dependencies": {
83
83
  "@nymproject/mix-fetch": "^1.4.4",
84
84
  "aes-js": "^3.1.0",
85
- "base-x": "^4.0.0",
85
+ "base-x": "^4.0.1",
86
86
  "biggystring": "^4.2.3",
87
87
  "cleaners": "^0.3.17",
88
88
  "currency-codes": "^1.5.1",
@@ -107,7 +107,7 @@
107
107
  "@babel/preset-env": "^7.0.0",
108
108
  "@babel/preset-react": "^7.0.0",
109
109
  "@babel/preset-typescript": "^7.18.6",
110
- "@babel/runtime": "^7.0.0",
110
+ "@babel/runtime": "^7.26.10",
111
111
  "@rollup/plugin-babel": "^5.3.0",
112
112
  "@rollup/plugin-node-resolve": "^15.0.1",
113
113
  "@sucrase/webpack-loader": "^2.0.0",
@@ -139,18 +139,18 @@
139
139
  "flow-bin": "^0.89.0",
140
140
  "husky": "^7.0.0",
141
141
  "lint-staged": "^10.2.11",
142
- "mocha": "^10.1.0",
142
+ "mocha": "^10.6.0",
143
143
  "npm-run-all": "^4.1.5",
144
144
  "prettier": "^3.0.3",
145
145
  "process": "^0.11.10",
146
146
  "rimraf": "^3.0.2",
147
- "rollup": "^2.44.0",
147
+ "rollup": "^2.80.0",
148
148
  "rollup-plugin-flow-entry": "^0.3.6",
149
149
  "rollup-plugin-mjs-entry": "^0.1.1",
150
150
  "stream-browserify": "^3.0.0",
151
151
  "sucrase": "^3.20.0",
152
152
  "typescript": "~4.4.4",
153
- "webpack": "^5.89.0",
153
+ "webpack": "^5.104.1",
154
154
  "webpack-cli": "^5.1.4",
155
155
  "webpack-dev-server": "^4.15.1"
156
156
  },
@@ -1473,6 +1473,7 @@ export interface EdgeMemoryWallet {
1473
1473
  readonly signTx: (tx: EdgeTransaction) => Promise<EdgeTransaction>
1474
1474
  readonly broadcastTx: (tx: EdgeTransaction) => Promise<EdgeTransaction>
1475
1475
  readonly saveTx: (tx: EdgeTransaction) => Promise<void>
1476
+ readonly otherMethods: EdgeOtherMethods
1476
1477
  readonly close: () => Promise<void>
1477
1478
 
1478
1479
  /** @deprecated Use syncStatus */