@cityofzion/bs-multichain 1.0.13 → 1.0.15

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.
@@ -1,14 +1,14 @@
1
- import { Account, BlockchainService, UntilIndexRecord } from '@cityofzion/blockchain-service';
2
- export declare class BSAggregator<BSName extends string> {
1
+ import { TBSAccount, IBlockchainService, TUntilIndexRecord } from '@cityofzion/blockchain-service';
2
+ export declare class BSAggregator<N extends string> {
3
3
  #private;
4
- readonly blockchainServicesByName: Record<BSName, BlockchainService<BSName>>;
5
- constructor(blockchainServices: BlockchainService<BSName>[]);
4
+ readonly blockchainServicesByName: Record<N, IBlockchainService<N>>;
5
+ constructor(blockchainServices: IBlockchainService<N>[]);
6
6
  validateAddressAllBlockchains(address: string): boolean;
7
7
  validateTextAllBlockchains(text: string): boolean;
8
8
  validateKeyAllBlockchains(wif: string): boolean;
9
9
  validateEncryptedAllBlockchains(keyOrJson: string): boolean;
10
- getBlockchainNameByAddress(address: string): BSName[];
11
- getBlockchainNameByKey(wif: string): BSName[];
12
- getBlockchainNameByEncrypted(keyOrJson: string): BSName[];
13
- generateAccountsFromMnemonic(mnemonic: string, untilIndexByBlockchainService?: UntilIndexRecord<BSName>): Promise<Map<BSName, Account<BSName>[]>>;
10
+ getBlockchainNameByAddress(address: string): N[];
11
+ getBlockchainNameByKey(wif: string): N[];
12
+ getBlockchainNameByEncrypted(keyOrJson: string): N[];
13
+ generateAccountsFromMnemonic(mnemonic: string, untilIndexByBlockchainService?: TUntilIndexRecord<N>): Promise<Map<N, TBSAccount<N>[]>>;
14
14
  }
@@ -1,21 +1,21 @@
1
- import { Account, BalanceResponse, IBridgeOrchestrator, TBridgeOrchestratorEvents, TBridgeToken } from '@cityofzion/blockchain-service';
1
+ import { TBSAccount, TBalanceResponse, IBridgeOrchestrator, TBridgeOrchestratorEvents, TBridgeToken } from '@cityofzion/blockchain-service';
2
2
  import { BSNeo3 } from '@cityofzion/bs-neo3';
3
3
  import { BSNeoX } from '@cityofzion/bs-neox';
4
4
  import TypedEmitter from 'typed-emitter';
5
5
  import { TNeo3NeoXBridgeOrchestratorInitParams, TNeo3NeoXBridgeOrchestratorWaitParams } from './types';
6
- export declare class Neo3NeoXBridgeOrchestrator<BSName extends string> implements IBridgeOrchestrator<BSName> {
6
+ export declare class Neo3NeoXBridgeOrchestrator<N extends string> implements IBridgeOrchestrator<N> {
7
7
  #private;
8
- eventEmitter: TypedEmitter<TBridgeOrchestratorEvents<BSName>>;
9
- fromService: BSNeo3<BSName> | BSNeoX<BSName>;
10
- toService: BSNeo3<BSName> | BSNeoX<BSName>;
11
- constructor(params: TNeo3NeoXBridgeOrchestratorInitParams<BSName>);
8
+ eventEmitter: TypedEmitter<TBridgeOrchestratorEvents<N>>;
9
+ fromService: BSNeo3<N> | BSNeoX<N>;
10
+ toService: BSNeo3<N> | BSNeoX<N>;
11
+ constructor(params: TNeo3NeoXBridgeOrchestratorInitParams<N>);
12
12
  init(): Promise<void>;
13
13
  switchTokens(): Promise<void>;
14
- setTokenToUse(token: TBridgeToken<BSName> | null): Promise<void>;
15
- setAccountToUse(account: Account<BSName> | null): Promise<void>;
14
+ setTokenToUse(token: TBridgeToken<N> | null): Promise<void>;
15
+ setAccountToUse(account: TBSAccount<N> | null): Promise<void>;
16
16
  setAddressToReceive(address: string | null): Promise<void>;
17
- setBalances(balances: BalanceResponse[] | null): Promise<void>;
17
+ setBalances(balances: TBalanceResponse[] | null): Promise<void>;
18
18
  setAmountToUse(amount: string | null): Promise<void>;
19
19
  bridge(): Promise<string>;
20
- static wait<BSName extends string = string>({ tokenToUse, tokenToReceive, transactionHash, neo3Service, neoXService, }: TNeo3NeoXBridgeOrchestratorWaitParams<BSName>): Promise<void>;
20
+ static wait<N extends string = string>({ tokenToUse, tokenToReceive, transactionHash, neo3Service, neoXService, }: TNeo3NeoXBridgeOrchestratorWaitParams<N>): Promise<void>;
21
21
  }
@@ -53,7 +53,7 @@ class Neo3NeoXBridgeOrchestrator {
53
53
  init() {
54
54
  return __awaiter(this, void 0, void 0, function* () {
55
55
  __classPrivateFieldSet(this, _Neo3NeoXBridgeOrchestrator_instances, {
56
- value: this.fromService.neo3NeoXBridgeService.tokens,
56
+ value: [this.fromService.neo3NeoXBridgeService.gasToken, this.fromService.neo3NeoXBridgeService.neoToken],
57
57
  }, "a", _Neo3NeoXBridgeOrchestrator_availableTokensToUse_set);
58
58
  __classPrivateFieldSet(this, _Neo3NeoXBridgeOrchestrator_instances, { value: null, loading: false }, "a", _Neo3NeoXBridgeOrchestrator_accountToUse_set);
59
59
  __classPrivateFieldSet(this, _Neo3NeoXBridgeOrchestrator_instances, { value: null, valid: null, loading: false }, "a", _Neo3NeoXBridgeOrchestrator_addressToReceive_set);
@@ -91,9 +91,10 @@ class Neo3NeoXBridgeOrchestrator {
91
91
  return;
92
92
  if (!__classPrivateFieldGet(this, _Neo3NeoXBridgeOrchestrator_instances, "a", _Neo3NeoXBridgeOrchestrator_availableTokensToUse_get).value.some(currentToken => this.fromService.tokenService.predicate(token, currentToken)))
93
93
  throw new blockchain_service_1.BSError('You are trying to use a token that is not available', 'TOKEN_NOT_AVAILABLE');
94
- tokenToReceive = this.toService.neo3NeoXBridgeService.tokens.find(item => token.multichainId === item.multichainId);
95
- if (!tokenToReceive)
96
- throw new blockchain_service_1.BSError('Pair token not found', 'PAIR_TOKEN_NOT_FOUND');
94
+ const isGasToken = this.fromService.tokenService.predicateByHash(token, this.fromService.neo3NeoXBridgeService.gasToken);
95
+ tokenToReceive = isGasToken
96
+ ? this.toService.neo3NeoXBridgeService.gasToken
97
+ : this.toService.neo3NeoXBridgeService.neoToken;
97
98
  }
98
99
  __classPrivateFieldSet(this, _Neo3NeoXBridgeOrchestrator_instances, { value: tokenToReceive !== null && tokenToReceive !== void 0 ? tokenToReceive : null, error: null }, "a", _Neo3NeoXBridgeOrchestrator_tokenToReceive_set);
99
100
  __classPrivateFieldSet(this, _Neo3NeoXBridgeOrchestrator_instances, { value: token, error: null }, "a", _Neo3NeoXBridgeOrchestrator_tokenToUse_set);
@@ -146,8 +147,8 @@ class Neo3NeoXBridgeOrchestrator {
146
147
  });
147
148
  }
148
149
  setBalances(balances) {
149
- var _a;
150
150
  return __awaiter(this, void 0, void 0, function* () {
151
+ var _a;
151
152
  __classPrivateFieldSet(this, _Neo3NeoXBridgeOrchestrator_balances, balances, "f");
152
153
  const tokenToUseBalance = __classPrivateFieldGet(this, _Neo3NeoXBridgeOrchestrator_instances, "a", _Neo3NeoXBridgeOrchestrator_tokenToUse_get).value && balances
153
154
  ? balances === null || balances === void 0 ? void 0 : balances.find(item => this.fromService.tokenService.predicateByHash(__classPrivateFieldGet(this, _Neo3NeoXBridgeOrchestrator_instances, "a", _Neo3NeoXBridgeOrchestrator_tokenToUse_get).value, item.token))
@@ -276,8 +277,8 @@ class Neo3NeoXBridgeOrchestrator {
276
277
  });
277
278
  });
278
279
  }
279
- static wait({ tokenToUse, tokenToReceive, transactionHash, neo3Service, neoXService, }) {
280
- return __awaiter(this, void 0, void 0, function* () {
280
+ static wait(_a) {
281
+ return __awaiter(this, arguments, void 0, function* ({ tokenToUse, tokenToReceive, transactionHash, neo3Service, neoXService, }) {
281
282
  const isNeo3Service = tokenToUse.blockchain === neo3Service.name;
282
283
  const fromService = isNeo3Service ? neo3Service : neoXService;
283
284
  const toService = isNeo3Service ? neoXService : neo3Service;
@@ -1,15 +1,15 @@
1
1
  import { TBridgeToken } from '@cityofzion/blockchain-service';
2
2
  import { BSNeo3 } from '@cityofzion/bs-neo3';
3
3
  import { BSNeoX } from '@cityofzion/bs-neox';
4
- export type TNeo3NeoXBridgeOrchestratorInitParams<BSName extends string> = {
5
- neo3Service: BSNeo3<BSName>;
6
- neoXService: BSNeoX<BSName>;
7
- initialFromServiceName?: BSName;
4
+ export type TNeo3NeoXBridgeOrchestratorInitParams<N extends string> = {
5
+ neo3Service: BSNeo3<N>;
6
+ neoXService: BSNeoX<N>;
7
+ initialFromServiceName?: N;
8
8
  };
9
- export type TNeo3NeoXBridgeOrchestratorWaitParams<BSName extends string = string> = {
10
- neo3Service: BSNeo3<BSName>;
11
- neoXService: BSNeoX<BSName>;
9
+ export type TNeo3NeoXBridgeOrchestratorWaitParams<N extends string = string> = {
10
+ neo3Service: BSNeo3<N>;
11
+ neoXService: BSNeoX<N>;
12
12
  transactionHash: string;
13
- tokenToUse: TBridgeToken<BSName>;
14
- tokenToReceive: TBridgeToken<BSName>;
13
+ tokenToUse: TBridgeToken<N>;
14
+ tokenToReceive: TBridgeToken<N>;
15
15
  };
@@ -1,9 +1,8 @@
1
1
  import { TSimpleSwapApiCreateExchangeParams, TSimpleSwapApiCurrency, TSimpleSwapOrchestratorInitParams } from './types';
2
- export declare class SimpleSwapApi<BSName extends string = string> {
2
+ export declare class SimpleSwapApi<N extends string> {
3
3
  #private;
4
- constructor();
5
- getCurrencies(options: TSimpleSwapOrchestratorInitParams<BSName>): Promise<TSimpleSwapApiCurrency<BSName>[]>;
6
- getPairs(ticker: string, network: string): Promise<TSimpleSwapApiCurrency<BSName>[]>;
4
+ getCurrencies(options: TSimpleSwapOrchestratorInitParams<N>): Promise<TSimpleSwapApiCurrency<N>[]>;
5
+ getPairs(ticker: string, network: string): Promise<TSimpleSwapApiCurrency<N>[]>;
7
6
  getRange(currencyFrom: TSimpleSwapApiCurrency, currencyTo: TSimpleSwapApiCurrency): Promise<{
8
7
  min: string;
9
8
  max: string | null;
@@ -8,21 +8,21 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
8
8
  step((generator = generator.apply(thisArg, _arguments || [])).next());
9
9
  });
10
10
  };
11
+ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
12
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
13
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
14
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
15
+ };
11
16
  var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
12
17
  if (kind === "m") throw new TypeError("Private method is not writable");
13
18
  if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
14
19
  if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
15
20
  return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
16
21
  };
17
- var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
18
- if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
19
- if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
20
- return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
21
- };
22
22
  var __importDefault = (this && this.__importDefault) || function (mod) {
23
23
  return (mod && mod.__esModule) ? mod : { "default": mod };
24
24
  };
25
- var _SimpleSwapApi_instances, _SimpleSwapApi_tickersBySimpleSwapBlockchain, _SimpleSwapApi_axios, _SimpleSwapApi_allCurrenciesMap, _SimpleSwapApi_createAddressTemplateUrl, _SimpleSwapApi_createTxTemplateUrl, _SimpleSwapApi_getTokenFromCurrency;
25
+ var _SimpleSwapApi_instances, _SimpleSwapApi_tickersBySimpleSwapBlockchain, _SimpleSwapApi_apiInstance, _SimpleSwapApi_allCurrenciesMap, _SimpleSwapApi_api_get, _SimpleSwapApi_createAddressTemplateUrl, _SimpleSwapApi_createTxTemplateUrl, _SimpleSwapApi_getTokenFromCurrency;
26
26
  Object.defineProperty(exports, "__esModule", { value: true });
27
27
  exports.SimpleSwapApi = void 0;
28
28
  const axios_1 = __importDefault(require("axios"));
@@ -36,25 +36,17 @@ class SimpleSwapApi {
36
36
  gasn3: 'gas',
37
37
  },
38
38
  });
39
- _SimpleSwapApi_axios.set(this, void 0);
39
+ _SimpleSwapApi_apiInstance.set(this, void 0);
40
40
  _SimpleSwapApi_allCurrenciesMap.set(this, new Map());
41
- __classPrivateFieldSet(this, _SimpleSwapApi_axios, axios_1.default.create({
42
- baseURL: `${blockchain_service_1.BSCommonConstants.DORA_URL}/api/v2/swap`,
43
- headers: {
44
- 'Cache-Control': 'no-cache',
45
- Pragma: 'no-cache',
46
- Expires: '0',
47
- },
48
- }), "f");
49
41
  }
50
42
  getCurrencies(options) {
51
- var _a;
52
43
  return __awaiter(this, void 0, void 0, function* () {
44
+ var _a;
53
45
  try {
54
46
  if (__classPrivateFieldGet(this, _SimpleSwapApi_allCurrenciesMap, "f").size) {
55
47
  return Array.from(__classPrivateFieldGet(this, _SimpleSwapApi_allCurrenciesMap, "f").values());
56
48
  }
57
- const response = yield __classPrivateFieldGet(this, _SimpleSwapApi_axios, "f").get('/currencies');
49
+ const response = yield __classPrivateFieldGet(this, _SimpleSwapApi_instances, "a", _SimpleSwapApi_api_get).get('/currencies');
58
50
  const tokens = [];
59
51
  response.data.result.forEach(currency => {
60
52
  const token = __classPrivateFieldGet(this, _SimpleSwapApi_instances, "m", _SimpleSwapApi_getTokenFromCurrency).call(this, currency, options);
@@ -76,10 +68,10 @@ class SimpleSwapApi {
76
68
  });
77
69
  }
78
70
  getPairs(ticker, network) {
79
- var _a, _b;
80
71
  return __awaiter(this, void 0, void 0, function* () {
72
+ var _a, _b;
81
73
  try {
82
- const response = yield __classPrivateFieldGet(this, _SimpleSwapApi_axios, "f").get(`/pairs/${ticker}/${network}`);
74
+ const response = yield __classPrivateFieldGet(this, _SimpleSwapApi_instances, "a", _SimpleSwapApi_api_get).get(`/pairs/${ticker}/${network}`);
83
75
  const pairs = (_a = response.data.result[`${ticker}:${network}`]) !== null && _a !== void 0 ? _a : [];
84
76
  const tokens = [];
85
77
  pairs.forEach(pair => {
@@ -98,10 +90,10 @@ class SimpleSwapApi {
98
90
  });
99
91
  }
100
92
  getRange(currencyFrom, currencyTo) {
101
- var _a;
102
93
  return __awaiter(this, void 0, void 0, function* () {
94
+ var _a;
103
95
  try {
104
- const response = yield __classPrivateFieldGet(this, _SimpleSwapApi_axios, "f").get('/ranges', {
96
+ const response = yield __classPrivateFieldGet(this, _SimpleSwapApi_instances, "a", _SimpleSwapApi_api_get).get('/ranges', {
105
97
  params: {
106
98
  tickerFrom: currencyFrom.ticker,
107
99
  tickerTo: currencyTo.ticker,
@@ -120,10 +112,10 @@ class SimpleSwapApi {
120
112
  });
121
113
  }
122
114
  getEstimate(currencyFrom, currencyTo, amount) {
123
- var _a;
124
115
  return __awaiter(this, void 0, void 0, function* () {
116
+ var _a;
125
117
  try {
126
- const response = yield __classPrivateFieldGet(this, _SimpleSwapApi_axios, "f").get('/estimates', {
118
+ const response = yield __classPrivateFieldGet(this, _SimpleSwapApi_instances, "a", _SimpleSwapApi_api_get).get('/estimates', {
127
119
  params: {
128
120
  tickerFrom: currencyFrom.ticker,
129
121
  tickerTo: currencyTo.ticker,
@@ -142,11 +134,11 @@ class SimpleSwapApi {
142
134
  }
143
135
  });
144
136
  }
145
- createExchange({ currencyFrom, currencyTo, amount, refundAddress, address, extraIdToReceive, }) {
146
- var _a, _b;
147
- return __awaiter(this, void 0, void 0, function* () {
137
+ createExchange(_a) {
138
+ return __awaiter(this, arguments, void 0, function* ({ currencyFrom, currencyTo, amount, refundAddress, address, extraIdToReceive, }) {
139
+ var _b, _c;
148
140
  try {
149
- const { data: { result }, } = yield __classPrivateFieldGet(this, _SimpleSwapApi_axios, "f").post('/exchanges', {
141
+ const { data: { result }, } = yield __classPrivateFieldGet(this, _SimpleSwapApi_instances, "a", _SimpleSwapApi_api_get).post('/exchanges', {
150
142
  tickerFrom: currencyFrom.ticker,
151
143
  networkFrom: currencyFrom.network,
152
144
  tickerTo: currencyTo.ticker,
@@ -154,7 +146,7 @@ class SimpleSwapApi {
154
146
  amount,
155
147
  userRefundAddress: refundAddress,
156
148
  addressTo: address,
157
- extraIdTo: (_a = extraIdToReceive === null || extraIdToReceive === void 0 ? void 0 : extraIdToReceive.trim()) !== null && _a !== void 0 ? _a : null,
149
+ extraIdTo: (_b = extraIdToReceive === null || extraIdToReceive === void 0 ? void 0 : extraIdToReceive.trim()) !== null && _b !== void 0 ? _b : null,
158
150
  });
159
151
  return {
160
152
  id: result.id,
@@ -163,7 +155,7 @@ class SimpleSwapApi {
163
155
  };
164
156
  }
165
157
  catch (error) {
166
- if (axios_1.default.isAxiosError(error) && ((_b = error.response) === null || _b === void 0 ? void 0 : _b.data.message)) {
158
+ if (axios_1.default.isAxiosError(error) && ((_c = error.response) === null || _c === void 0 ? void 0 : _c.data.message)) {
167
159
  throw new Error(error.response.data.message);
168
160
  }
169
161
  throw error;
@@ -171,10 +163,10 @@ class SimpleSwapApi {
171
163
  });
172
164
  }
173
165
  getExchange(id) {
174
- var _a;
175
166
  return __awaiter(this, void 0, void 0, function* () {
167
+ var _a;
176
168
  try {
177
- const { data: { result }, } = yield __classPrivateFieldGet(this, _SimpleSwapApi_axios, "f").get(`/exchanges/${id}`);
169
+ const { data: { result }, } = yield __classPrivateFieldGet(this, _SimpleSwapApi_instances, "a", _SimpleSwapApi_api_get).get(`/exchanges/${id}`);
178
170
  return {
179
171
  status: result.status,
180
172
  txFrom: result.txFrom,
@@ -192,7 +184,19 @@ class SimpleSwapApi {
192
184
  }
193
185
  }
194
186
  exports.SimpleSwapApi = SimpleSwapApi;
195
- _SimpleSwapApi_tickersBySimpleSwapBlockchain = new WeakMap(), _SimpleSwapApi_axios = new WeakMap(), _SimpleSwapApi_allCurrenciesMap = new WeakMap(), _SimpleSwapApi_instances = new WeakSet(), _SimpleSwapApi_createAddressTemplateUrl = function _SimpleSwapApi_createAddressTemplateUrl(blockchainService, explorer) {
187
+ _SimpleSwapApi_tickersBySimpleSwapBlockchain = new WeakMap(), _SimpleSwapApi_apiInstance = new WeakMap(), _SimpleSwapApi_allCurrenciesMap = new WeakMap(), _SimpleSwapApi_instances = new WeakSet(), _SimpleSwapApi_api_get = function _SimpleSwapApi_api_get() {
188
+ if (!__classPrivateFieldGet(this, _SimpleSwapApi_apiInstance, "f")) {
189
+ __classPrivateFieldSet(this, _SimpleSwapApi_apiInstance, axios_1.default.create({
190
+ baseURL: `${blockchain_service_1.BSCommonConstants.DORA_URL}/api/v2/swap`,
191
+ headers: {
192
+ 'Cache-Control': 'no-cache',
193
+ Pragma: 'no-cache',
194
+ Expires: '0',
195
+ },
196
+ }), "f");
197
+ }
198
+ return __classPrivateFieldGet(this, _SimpleSwapApi_apiInstance, "f");
199
+ }, _SimpleSwapApi_createAddressTemplateUrl = function _SimpleSwapApi_createAddressTemplateUrl(blockchainService, explorer) {
196
200
  var _a;
197
201
  explorer = !explorer ? undefined : explorer.replace('{}', '{address}');
198
202
  if (blockchainService && (0, blockchain_service_1.hasExplorerService)(blockchainService))
@@ -223,7 +227,7 @@ _SimpleSwapApi_tickersBySimpleSwapBlockchain = new WeakMap(), _SimpleSwapApi_axi
223
227
  blockchain = chainsByServiceNameEntry[0];
224
228
  blockchainService = options.blockchainServicesByName[blockchain];
225
229
  const normalizedHash = hash && blockchainService ? blockchainService.tokenService.normalizeHash(hash) : '';
226
- const token = blockchainService.tokens.find(item => {
230
+ const token = blockchainService === null || blockchainService === void 0 ? void 0 : blockchainService.tokens.find(item => {
227
231
  if (normalizedHash && blockchainService && blockchainService.tokenService.predicateByHash(item, normalizedHash))
228
232
  return true;
229
233
  const currentLowerCaseSymbol = item.symbol.toLowerCase();
@@ -1,15 +1,15 @@
1
- import { Account, ISwapOrchestrator, TSwapOrchestratorEvents, TSwapResult, TSwapToken } from '@cityofzion/blockchain-service';
1
+ import { TBSAccount, ISwapOrchestrator, TSwapOrchestratorEvents, TSwapResult, TSwapToken } from '@cityofzion/blockchain-service';
2
2
  import TypedEmitter from 'typed-emitter';
3
3
  import { TSimpleSwapOrchestratorInitParams } from './types';
4
- export declare class SimpleSwapOrchestrator<BSName extends string = string> implements ISwapOrchestrator<BSName> {
4
+ export declare class SimpleSwapOrchestrator<N extends string = string> implements ISwapOrchestrator<N> {
5
5
  #private;
6
- eventEmitter: TypedEmitter<TSwapOrchestratorEvents<BSName>>;
7
- constructor(params: TSimpleSwapOrchestratorInitParams<BSName>);
6
+ eventEmitter: TypedEmitter<TSwapOrchestratorEvents<N>>;
7
+ constructor(params: TSimpleSwapOrchestratorInitParams<N>);
8
8
  init(): Promise<void>;
9
- setTokenToUse(token: TSwapToken<BSName> | null): Promise<void>;
10
- setAccountToUse(account: Account<BSName> | null): Promise<void>;
9
+ setTokenToUse(token: TSwapToken<N> | null): Promise<void>;
10
+ setAccountToUse(account: TBSAccount<N> | null): Promise<void>;
11
11
  setAmountToUse(amount: string | null): Promise<void>;
12
- setTokenToReceive(token: TSwapToken<BSName> | null): Promise<void>;
12
+ setTokenToReceive(token: TSwapToken<N> | null): Promise<void>;
13
13
  setAddressToReceive(address: string | null): Promise<void>;
14
14
  setExtraIdToReceive(extraIdToReceive: string | null): Promise<void>;
15
15
  swap(): Promise<TSwapResult>;
@@ -75,8 +75,8 @@ class SimpleSwapOrchestrator {
75
75
  });
76
76
  }
77
77
  setTokenToUse(token) {
78
- var _a, _b;
79
78
  return __awaiter(this, void 0, void 0, function* () {
79
+ var _a, _b;
80
80
  __classPrivateFieldSet(this, _SimpleSwapOrchestrator_instances, { loading: false, value: null }, "a", _SimpleSwapOrchestrator_amountToReceive_set);
81
81
  __classPrivateFieldSet(this, _SimpleSwapOrchestrator_instances, { loading: false, value: null }, "a", _SimpleSwapOrchestrator_amountToUseMinMax_set);
82
82
  __classPrivateFieldSet(this, _SimpleSwapOrchestrator_instances, { loading: true }, "a", _SimpleSwapOrchestrator_tokenToUse_set);
@@ -124,8 +124,8 @@ class SimpleSwapOrchestrator {
124
124
  });
125
125
  }
126
126
  setTokenToReceive(token) {
127
- var _a;
128
127
  return __awaiter(this, void 0, void 0, function* () {
128
+ var _a;
129
129
  __classPrivateFieldSet(this, _SimpleSwapOrchestrator_instances, { value: null, valid: null }, "a", _SimpleSwapOrchestrator_extraIdToReceive_set);
130
130
  __classPrivateFieldSet(this, _SimpleSwapOrchestrator_instances, { loading: false, value: null }, "a", _SimpleSwapOrchestrator_amountToReceive_set);
131
131
  __classPrivateFieldSet(this, _SimpleSwapOrchestrator_instances, { loading: false, value: null }, "a", _SimpleSwapOrchestrator_amountToUseMinMax_set);
@@ -153,8 +153,8 @@ class SimpleSwapOrchestrator {
153
153
  });
154
154
  }
155
155
  setExtraIdToReceive(extraIdToReceive) {
156
- var _a;
157
156
  return __awaiter(this, void 0, void 0, function* () {
157
+ var _a;
158
158
  if (!((_a = __classPrivateFieldGet(this, _SimpleSwapOrchestrator_instances, "a", _SimpleSwapOrchestrator_tokenToReceive_get).value) === null || _a === void 0 ? void 0 : _a.hasExtraId))
159
159
  return;
160
160
  __classPrivateFieldSet(this, _SimpleSwapOrchestrator_instances, { value: extraIdToReceive, valid: null }, "a", _SimpleSwapOrchestrator_extraIdToReceive_set);
@@ -162,8 +162,8 @@ class SimpleSwapOrchestrator {
162
162
  });
163
163
  }
164
164
  swap() {
165
- var _a;
166
165
  return __awaiter(this, void 0, void 0, function* () {
166
+ var _a;
167
167
  if (!__classPrivateFieldGet(this, _SimpleSwapOrchestrator_instances, "a", _SimpleSwapOrchestrator_tokenToUse_get).value ||
168
168
  !__classPrivateFieldGet(this, _SimpleSwapOrchestrator_instances, "a", _SimpleSwapOrchestrator_tokenToReceive_get).value ||
169
169
  !__classPrivateFieldGet(this, _SimpleSwapOrchestrator_instances, "a", _SimpleSwapOrchestrator_accountToUse_get).value ||
@@ -1,9 +1,9 @@
1
- import { BlockchainService, TSwapToken } from '@cityofzion/blockchain-service';
2
- export type TSimpleSwapOrchestratorInitParams<BSName extends string = string> = {
3
- blockchainServicesByName: Record<BSName, BlockchainService<BSName>>;
4
- chainsByServiceName: Partial<Record<BSName, string[]>>;
1
+ import { IBlockchainService, TSwapToken } from '@cityofzion/blockchain-service';
2
+ export type TSimpleSwapOrchestratorInitParams<N extends string = string> = {
3
+ blockchainServicesByName: Record<N, IBlockchainService<N>>;
4
+ chainsByServiceName: Partial<Record<N, string[]>>;
5
5
  };
6
- export type TSimpleSwapApiCurrency<BSName extends string = string> = TSwapToken<BSName> & {
6
+ export type TSimpleSwapApiCurrency<N extends string = string> = TSwapToken<N> & {
7
7
  network: string;
8
8
  ticker: string;
9
9
  hasExtraId: boolean;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cityofzion/bs-multichain",
3
- "version": "1.0.13",
3
+ "version": "1.0.15",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "repository": "https://github.com/CityOfZion/blockchain-services",
@@ -10,32 +10,29 @@
10
10
  "/dist"
11
11
  ],
12
12
  "dependencies": {
13
- "axios": "~1.8.2",
14
- "lodash": "~4.17.21",
15
- "@cityofzion/blockchain-service": "1.21.2"
13
+ "axios": "~1.12.2",
14
+ "@cityofzion/blockchain-service": "1.21.3"
16
15
  },
17
16
  "devDependencies": {
18
- "@types/jest": "29.5.3",
19
- "dotenv": "16.3.1",
20
- "eslint": "^8.48.0",
21
- "jest": "29.6.2",
22
- "ts-jest": "29.1.1",
17
+ "@types/node": "~24.5.2",
18
+ "@types/jest": "~30.0.0",
19
+ "dotenv": "~17.2.2",
20
+ "eslint": "~9.36.0",
21
+ "jest": "~30.1.3",
22
+ "ts-jest": "~29.4.4",
23
23
  "ts-node": "~10.9.2",
24
- "typescript": "4.9.5",
24
+ "typescript": "~5.9.2",
25
25
  "typed-emitter": "~2.1.0",
26
- "@types/lodash": "~4.17.12",
27
- "@types/node": "~22.8.6",
28
- "@typescript-eslint/eslint-plugin": "~8.12.2",
29
- "@typescript-eslint/parser": "~8.12.2",
30
- "@cityofzion/bs-neo3": "1.16.3",
31
- "@cityofzion/bs-ethereum": "2.13.3",
32
- "@cityofzion/bs-neo-legacy": "1.13.4",
33
- "@cityofzion/bs-neox": "1.3.4"
26
+ "@cityofzion/bs-ethereum": "2.13.5",
27
+ "@cityofzion/bs-neo-legacy": "1.13.5",
28
+ "@cityofzion/bs-neox": "1.3.6",
29
+ "@cityofzion/bs-neo3": "1.16.4"
34
30
  },
35
31
  "scripts": {
36
- "build": "tsc --project tsconfig.build.json",
37
- "test": "jest --config jest.config.ts",
32
+ "build": "rm -rf ./dist && tsc --project tsconfig.build.json",
33
+ "test": "jest -i --config jest.config.ts",
38
34
  "lint": "eslint .",
39
- "format": "eslint --fix"
35
+ "format": "eslint --fix",
36
+ "package": "npm run build && npm pack"
40
37
  }
41
38
  }