@cityofzion/bs-multichain 3.0.6 → 3.1.1
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.
|
@@ -13,7 +13,7 @@ var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (
|
|
|
13
13
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
14
14
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
15
15
|
};
|
|
16
|
-
var _SimpleSwapApi_instances, _SimpleSwapApi_tickersBySimpleSwapBlockchain, _SimpleSwapApi_apiInstance, _SimpleSwapApi_allCurrenciesMap, _SimpleSwapApi_api_get, _SimpleSwapApi_createAddressTemplateUrl,
|
|
16
|
+
var _SimpleSwapApi_instances, _SimpleSwapApi_tickersBySimpleSwapBlockchain, _SimpleSwapApi_apiInstance, _SimpleSwapApi_allCurrenciesMap, _SimpleSwapApi_api_get, _SimpleSwapApi_createAddressTemplateUrl, _SimpleSwapApi_createTransactionTemplateUrl, _SimpleSwapApi_getTokenFromCurrency;
|
|
17
17
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
18
|
exports.SimpleSwapApi = void 0;
|
|
19
19
|
const axios_1 = __importDefault(require("axios"));
|
|
@@ -174,10 +174,10 @@ _SimpleSwapApi_tickersBySimpleSwapBlockchain = new WeakMap(), _SimpleSwapApi_api
|
|
|
174
174
|
if (blockchainService && (0, blockchain_service_1.hasExplorerService)(blockchainService))
|
|
175
175
|
return blockchainService.explorerService.getAddressTemplateUrl() || explorer;
|
|
176
176
|
return explorer;
|
|
177
|
-
},
|
|
177
|
+
}, _SimpleSwapApi_createTransactionTemplateUrl = function _SimpleSwapApi_createTransactionTemplateUrl(blockchainService, explorer) {
|
|
178
178
|
explorer = !explorer ? undefined : explorer.replace('{}', '{txId}');
|
|
179
179
|
if (blockchainService && (0, blockchain_service_1.hasExplorerService)(blockchainService))
|
|
180
|
-
return blockchainService.explorerService.
|
|
180
|
+
return blockchainService.explorerService.getTransactionTemplateUrl() ?? explorer;
|
|
181
181
|
return explorer;
|
|
182
182
|
}, _SimpleSwapApi_getTokenFromCurrency = function _SimpleSwapApi_getTokenFromCurrency(currency, options) {
|
|
183
183
|
const { network: simpleSwapBlockchain, ticker, precision } = currency;
|
|
@@ -226,7 +226,7 @@ _SimpleSwapApi_tickersBySimpleSwapBlockchain = new WeakMap(), _SimpleSwapApi_api
|
|
|
226
226
|
validationExtra: currency.validationExtra,
|
|
227
227
|
validationAddress: currency.validationAddress,
|
|
228
228
|
addressTemplateUrl: __classPrivateFieldGet(this, _SimpleSwapApi_instances, "m", _SimpleSwapApi_createAddressTemplateUrl).call(this, blockchainService, currency.addressExplorer),
|
|
229
|
-
txTemplateUrl: __classPrivateFieldGet(this, _SimpleSwapApi_instances, "m",
|
|
229
|
+
txTemplateUrl: __classPrivateFieldGet(this, _SimpleSwapApi_instances, "m", _SimpleSwapApi_createTransactionTemplateUrl).call(this, blockchainService, currency.txExplorer),
|
|
230
230
|
blockchain,
|
|
231
231
|
};
|
|
232
232
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type TBSAccount, type ISwapOrchestrator, type TSwapOrchestratorEvents, type
|
|
1
|
+
import { type TBSAccount, type ISwapOrchestrator, type TSwapOrchestratorEvents, type TSwapResponse, type TSwapToken } from '@cityofzion/blockchain-service';
|
|
2
2
|
import TypedEmitter from 'typed-emitter';
|
|
3
3
|
import type { TSimpleSwapOrchestratorInitParams } from './types';
|
|
4
4
|
export declare class SimpleSwapOrchestrator<N extends string = string> implements ISwapOrchestrator<N> {
|
|
@@ -12,6 +12,6 @@ export declare class SimpleSwapOrchestrator<N extends string = string> implement
|
|
|
12
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
|
-
swap(): Promise<
|
|
15
|
+
swap(): Promise<TSwapResponse<N>>;
|
|
16
16
|
calculateFee(): Promise<string>;
|
|
17
17
|
}
|
|
@@ -147,11 +147,11 @@ class SimpleSwapOrchestrator {
|
|
|
147
147
|
isNaN(__classPrivateFieldGet(this, _SimpleSwapOrchestrator_instances, "a", _SimpleSwapOrchestrator_tokenToUse_get).value.decimals) ||
|
|
148
148
|
(__classPrivateFieldGet(this, _SimpleSwapOrchestrator_instances, "a", _SimpleSwapOrchestrator_tokenToReceive_get).value.hasExtraId &&
|
|
149
149
|
(!__classPrivateFieldGet(this, _SimpleSwapOrchestrator_instances, "a", _SimpleSwapOrchestrator_extraIdToReceive_get).valid || !__classPrivateFieldGet(this, _SimpleSwapOrchestrator_instances, "a", _SimpleSwapOrchestrator_extraIdToReceive_get).value?.trim()))) {
|
|
150
|
-
throw new
|
|
150
|
+
throw new blockchain_service_1.BSError('Not all required fields are set', 'MISSING_REQUIRED_FIELDS');
|
|
151
151
|
}
|
|
152
|
-
const
|
|
152
|
+
const response = {
|
|
153
153
|
id: '',
|
|
154
|
-
|
|
154
|
+
transaction: undefined,
|
|
155
155
|
log: undefined,
|
|
156
156
|
};
|
|
157
157
|
try {
|
|
@@ -163,10 +163,11 @@ class SimpleSwapOrchestrator {
|
|
|
163
163
|
address: __classPrivateFieldGet(this, _SimpleSwapOrchestrator_instances, "a", _SimpleSwapOrchestrator_addressToReceive_get).value,
|
|
164
164
|
extraIdToReceive: __classPrivateFieldGet(this, _SimpleSwapOrchestrator_instances, "a", _SimpleSwapOrchestrator_extraIdToReceive_get).value,
|
|
165
165
|
});
|
|
166
|
-
|
|
167
|
-
|
|
166
|
+
response.id = id;
|
|
167
|
+
response.log = log;
|
|
168
168
|
const service = __classPrivateFieldGet(this, _SimpleSwapOrchestrator_blockchainServicesByName, "f")[__classPrivateFieldGet(this, _SimpleSwapOrchestrator_instances, "a", _SimpleSwapOrchestrator_accountToUse_get).value.blockchain];
|
|
169
|
-
|
|
169
|
+
// It'll always return one transaction because it has just one intent
|
|
170
|
+
const [transaction] = await service.transfer({
|
|
170
171
|
senderAccount: __classPrivateFieldGet(this, _SimpleSwapOrchestrator_instances, "a", _SimpleSwapOrchestrator_accountToUse_get).value,
|
|
171
172
|
intents: [
|
|
172
173
|
{
|
|
@@ -181,12 +182,12 @@ class SimpleSwapOrchestrator {
|
|
|
181
182
|
},
|
|
182
183
|
],
|
|
183
184
|
});
|
|
184
|
-
|
|
185
|
+
response.transaction = transaction;
|
|
185
186
|
}
|
|
186
187
|
catch {
|
|
187
188
|
// empty
|
|
188
189
|
}
|
|
189
|
-
return
|
|
190
|
+
return response;
|
|
190
191
|
}
|
|
191
192
|
async calculateFee() {
|
|
192
193
|
if (!__classPrivateFieldGet(this, _SimpleSwapOrchestrator_instances, "a", _SimpleSwapOrchestrator_tokenToUse_get).value ||
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { ISwapService, TSwapServiceStatusResponse } from '@cityofzion/blockchain-service';
|
|
2
|
-
export declare class SimpleSwapService<
|
|
2
|
+
export declare class SimpleSwapService<N extends string = string> implements ISwapService {
|
|
3
3
|
#private;
|
|
4
4
|
constructor();
|
|
5
5
|
getStatus(id: string): Promise<TSwapServiceStatusResponse>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cityofzion/bs-multichain",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.1.1",
|
|
4
4
|
"repository": "https://github.com/CityOfZion/blockchain-services",
|
|
5
5
|
"license": "GPL-3.0-only",
|
|
6
6
|
"author": "Coz",
|
|
@@ -13,19 +13,19 @@
|
|
|
13
13
|
"@walletconnect/utils": "~2.21.9",
|
|
14
14
|
"@walletconnect/jsonrpc-utils": "~1.0.8",
|
|
15
15
|
"axios": "~1.13.5",
|
|
16
|
-
"@cityofzion/blockchain-service": "3.
|
|
16
|
+
"@cityofzion/blockchain-service": "3.1.1"
|
|
17
17
|
},
|
|
18
18
|
"devDependencies": {
|
|
19
19
|
"@types/node": "~24.5.2",
|
|
20
20
|
"@walletconnect/types": "~2.21.9",
|
|
21
21
|
"dotenv": "~17.3.1",
|
|
22
|
-
"eslint": "~9.
|
|
22
|
+
"eslint": "~9.37.0",
|
|
23
23
|
"typed-emitter": "~2.1.0",
|
|
24
24
|
"typescript": "~5.9.2",
|
|
25
25
|
"vitest": "~4.0.18",
|
|
26
|
-
"@cityofzion/bs-
|
|
27
|
-
"@cityofzion/bs-neox": "3.
|
|
28
|
-
"@cityofzion/bs-
|
|
26
|
+
"@cityofzion/bs-ethereum": "3.1.1",
|
|
27
|
+
"@cityofzion/bs-neox": "3.1.1",
|
|
28
|
+
"@cityofzion/bs-neo3": "3.1.1"
|
|
29
29
|
},
|
|
30
30
|
"scripts": {
|
|
31
31
|
"build": "rm -rf ./dist && npm run typecheck && tsc --project tsconfig.build.json",
|