@cityofzion/bs-multichain 1.0.14 → 1.1.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/dist/BSAggregator.d.ts +9 -9
- package/dist/BSAggregator.js +9 -25
- package/dist/features/bridge/Neo3NeoXBridgeOrchestrator.d.ts +10 -10
- package/dist/features/bridge/Neo3NeoXBridgeOrchestrator.js +8 -7
- package/dist/features/bridge/types.d.ts +9 -9
- package/dist/features/swap/SimpleSwapApi.d.ts +3 -4
- package/dist/features/swap/SimpleSwapApi.js +37 -33
- package/dist/features/swap/SimpleSwapOrchestrator.d.ts +7 -7
- package/dist/features/swap/SimpleSwapOrchestrator.js +4 -4
- package/dist/features/swap/types.d.ts +5 -5
- package/dist/features/wallet-connect/WalletKitHelper.d.ts +17 -0
- package/dist/features/wallet-connect/WalletKitHelper.js +106 -0
- package/dist/features/wallet-connect/index.d.ts +2 -0
- package/dist/features/wallet-connect/index.js +18 -0
- package/dist/features/wallet-connect/types.d.ts +32 -0
- package/dist/features/wallet-connect/types.js +2 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/package.json +21 -21
package/dist/BSAggregator.d.ts
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export declare class BSAggregator<
|
|
3
|
-
|
|
4
|
-
readonly
|
|
5
|
-
constructor(blockchainServices:
|
|
1
|
+
import { TBSAccount, IBlockchainService, TUntilIndexRecord } from '@cityofzion/blockchain-service';
|
|
2
|
+
export declare class BSAggregator<N extends string> {
|
|
3
|
+
readonly blockchainServicesByName: Record<N, IBlockchainService<N>>;
|
|
4
|
+
readonly blockchainServices: 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):
|
|
11
|
-
getBlockchainNameByKey(wif: string):
|
|
12
|
-
getBlockchainNameByEncrypted(keyOrJson: string):
|
|
13
|
-
generateAccountsFromMnemonic(mnemonic: string, untilIndexByBlockchainService?:
|
|
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
|
}
|
package/dist/BSAggregator.js
CHANGED
|
@@ -8,60 +8,44 @@ 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 __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
|
12
|
-
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
13
|
-
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
14
|
-
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
|
-
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
16
|
-
};
|
|
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
|
-
var _BSAggregator_blockchainServices;
|
|
23
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
24
12
|
exports.BSAggregator = void 0;
|
|
25
13
|
const blockchain_service_1 = require("@cityofzion/blockchain-service");
|
|
26
14
|
class BSAggregator {
|
|
27
15
|
constructor(blockchainServices) {
|
|
28
|
-
|
|
29
|
-
__classPrivateFieldSet(this, _BSAggregator_blockchainServices, blockchainServices, "f");
|
|
16
|
+
this.blockchainServices = blockchainServices;
|
|
30
17
|
this.blockchainServicesByName = blockchainServices.reduce((acc, service) => {
|
|
31
18
|
acc[service.name] = service;
|
|
32
19
|
return acc;
|
|
33
20
|
}, {});
|
|
34
21
|
}
|
|
35
22
|
validateAddressAllBlockchains(address) {
|
|
36
|
-
return
|
|
23
|
+
return this.blockchainServices.some(bs => bs.validateAddress(address));
|
|
37
24
|
}
|
|
38
25
|
validateTextAllBlockchains(text) {
|
|
39
|
-
return
|
|
26
|
+
return this.blockchainServices.some(bs => [bs.validateAddress(text), (0, blockchain_service_1.hasEncryption)(bs) && bs.validateEncrypted(text), bs.validateKey(text)].some(it => it === true));
|
|
40
27
|
}
|
|
41
28
|
validateKeyAllBlockchains(wif) {
|
|
42
|
-
return
|
|
29
|
+
return this.blockchainServices.some(bs => bs.validateKey(wif));
|
|
43
30
|
}
|
|
44
31
|
validateEncryptedAllBlockchains(keyOrJson) {
|
|
45
|
-
return
|
|
32
|
+
return this.blockchainServices.some(bs => (0, blockchain_service_1.hasEncryption)(bs) && bs.validateEncrypted(keyOrJson));
|
|
46
33
|
}
|
|
47
34
|
getBlockchainNameByAddress(address) {
|
|
48
|
-
return
|
|
35
|
+
return this.blockchainServices.filter(bs => bs.validateAddress(address)).map(bs => bs.name);
|
|
49
36
|
}
|
|
50
37
|
getBlockchainNameByKey(wif) {
|
|
51
|
-
return
|
|
38
|
+
return this.blockchainServices.filter(bs => bs.validateKey(wif)).map(bs => bs.name);
|
|
52
39
|
}
|
|
53
40
|
getBlockchainNameByEncrypted(keyOrJson) {
|
|
54
|
-
return
|
|
55
|
-
.filter(bs => (0, blockchain_service_1.hasEncryption)(bs) && bs.validateEncrypted(keyOrJson))
|
|
56
|
-
.map(bs => bs.name);
|
|
41
|
+
return this.blockchainServices.filter(bs => (0, blockchain_service_1.hasEncryption)(bs) && bs.validateEncrypted(keyOrJson)).map(bs => bs.name);
|
|
57
42
|
}
|
|
58
43
|
generateAccountsFromMnemonic(mnemonic, untilIndexByBlockchainService) {
|
|
59
44
|
return __awaiter(this, void 0, void 0, function* () {
|
|
60
|
-
return (0, blockchain_service_1.generateAccountForBlockchainService)(
|
|
45
|
+
return (0, blockchain_service_1.generateAccountForBlockchainService)(this.blockchainServices, (service, index) => __awaiter(this, void 0, void 0, function* () {
|
|
61
46
|
return service.generateAccountFromMnemonic(mnemonic, index);
|
|
62
47
|
}), untilIndexByBlockchainService);
|
|
63
48
|
});
|
|
64
49
|
}
|
|
65
50
|
}
|
|
66
51
|
exports.BSAggregator = BSAggregator;
|
|
67
|
-
_BSAggregator_blockchainServices = new WeakMap();
|
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
import {
|
|
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<
|
|
6
|
+
export declare class Neo3NeoXBridgeOrchestrator<N extends string> implements IBridgeOrchestrator<N> {
|
|
7
7
|
#private;
|
|
8
|
-
eventEmitter: TypedEmitter<TBridgeOrchestratorEvents<
|
|
9
|
-
fromService: BSNeo3<
|
|
10
|
-
toService: BSNeo3<
|
|
11
|
-
constructor(params: TNeo3NeoXBridgeOrchestratorInitParams<
|
|
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<
|
|
15
|
-
setAccountToUse(account:
|
|
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:
|
|
17
|
+
setBalances(balances: TBalanceResponse[] | null): Promise<void>;
|
|
18
18
|
setAmountToUse(amount: string | null): Promise<void>;
|
|
19
19
|
bridge(): Promise<string>;
|
|
20
|
-
static wait<
|
|
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.
|
|
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
|
-
|
|
95
|
-
|
|
96
|
-
|
|
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(
|
|
280
|
-
return __awaiter(this,
|
|
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<
|
|
5
|
-
neo3Service: BSNeo3<
|
|
6
|
-
neoXService: BSNeoX<
|
|
7
|
-
initialFromServiceName?:
|
|
4
|
+
export type TNeo3NeoXBridgeOrchestratorInitParams<N extends string> = {
|
|
5
|
+
neo3Service: BSNeo3<N>;
|
|
6
|
+
neoXService: BSNeoX<N>;
|
|
7
|
+
initialFromServiceName?: N;
|
|
8
8
|
};
|
|
9
|
-
export type TNeo3NeoXBridgeOrchestratorWaitParams<
|
|
10
|
-
neo3Service: BSNeo3<
|
|
11
|
-
neoXService: BSNeoX<
|
|
9
|
+
export type TNeo3NeoXBridgeOrchestratorWaitParams<N extends string = string> = {
|
|
10
|
+
neo3Service: BSNeo3<N>;
|
|
11
|
+
neoXService: BSNeoX<N>;
|
|
12
12
|
transactionHash: string;
|
|
13
|
-
tokenToUse: TBridgeToken<
|
|
14
|
-
tokenToReceive: TBridgeToken<
|
|
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<
|
|
2
|
+
export declare class SimpleSwapApi<N extends string> {
|
|
3
3
|
#private;
|
|
4
|
-
|
|
5
|
-
|
|
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,
|
|
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
|
-
|
|
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,
|
|
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,
|
|
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,
|
|
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,
|
|
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(
|
|
146
|
-
|
|
147
|
-
|
|
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,
|
|
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: (
|
|
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) && ((
|
|
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,
|
|
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(),
|
|
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 {
|
|
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<
|
|
4
|
+
export declare class SimpleSwapOrchestrator<N extends string = string> implements ISwapOrchestrator<N> {
|
|
5
5
|
#private;
|
|
6
|
-
eventEmitter: TypedEmitter<TSwapOrchestratorEvents<
|
|
7
|
-
constructor(params: TSimpleSwapOrchestratorInitParams<
|
|
6
|
+
eventEmitter: TypedEmitter<TSwapOrchestratorEvents<N>>;
|
|
7
|
+
constructor(params: TSimpleSwapOrchestratorInitParams<N>);
|
|
8
8
|
init(): Promise<void>;
|
|
9
|
-
setTokenToUse(token: TSwapToken<
|
|
10
|
-
setAccountToUse(account:
|
|
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<
|
|
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 {
|
|
2
|
-
export type TSimpleSwapOrchestratorInitParams<
|
|
3
|
-
blockchainServicesByName: Record<
|
|
4
|
-
chainsByServiceName: Partial<Record<
|
|
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<
|
|
6
|
+
export type TSimpleSwapApiCurrency<N extends string = string> = TSwapToken<N> & {
|
|
7
7
|
network: string;
|
|
8
8
|
ticker: string;
|
|
9
9
|
hasExtraId: boolean;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { ErrorResponse } from '@walletconnect/jsonrpc-utils';
|
|
2
|
+
import type { PendingRequestTypes, SessionTypes } from '@walletconnect/types';
|
|
3
|
+
import { SdkErrorKey } from '@walletconnect/utils';
|
|
4
|
+
import { TWalletKitHelperFilterSessionsParams, TWalletKitHelperGetProposalDetailsParams, TWalletKitHelperGetSessionDetailsParams, TWalletKitHelperProcessRequestParams, TWalletKitHelperProposalDetails, TWalletKitHelperSessionDetails } from './types';
|
|
5
|
+
export declare class WalletKitHelper {
|
|
6
|
+
static getProposalDetails<N extends string>({ address, proposal, services, }: TWalletKitHelperGetProposalDetailsParams<N>): TWalletKitHelperProposalDetails<N>;
|
|
7
|
+
static getSessionDetails<N extends string>({ session, services, }: TWalletKitHelperGetSessionDetailsParams<N>): TWalletKitHelperSessionDetails<N>;
|
|
8
|
+
static getError(key: SdkErrorKey): {
|
|
9
|
+
message: string;
|
|
10
|
+
code: number;
|
|
11
|
+
};
|
|
12
|
+
static formatRequestResult(request: PendingRequestTypes.Struct, response: any): import("@walletconnect/jsonrpc-utils").JsonRpcResult<any>;
|
|
13
|
+
static formatRequestError(request: PendingRequestTypes.Struct, reason: ErrorResponse): import("@walletconnect/jsonrpc-utils").JsonRpcError;
|
|
14
|
+
static processRequest<N extends string>({ sessionDetails, account, request, }: TWalletKitHelperProcessRequestParams<N>): Promise<any>;
|
|
15
|
+
static filterSessions(sessions: SessionTypes.Struct[], filters: TWalletKitHelperFilterSessionsParams): SessionTypes.Struct[];
|
|
16
|
+
static isValidURI(uri: string): boolean;
|
|
17
|
+
}
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.WalletKitHelper = void 0;
|
|
13
|
+
const blockchain_service_1 = require("@cityofzion/blockchain-service");
|
|
14
|
+
const jsonrpc_utils_1 = require("@walletconnect/jsonrpc-utils");
|
|
15
|
+
const utils_1 = require("@walletconnect/utils");
|
|
16
|
+
class WalletKitHelper {
|
|
17
|
+
static getProposalDetails({ address, proposal, services, }) {
|
|
18
|
+
const mergedNamespacesObject = (0, utils_1.mergeRequiredAndOptionalNamespaces)(proposal.requiredNamespaces, proposal.optionalNamespaces);
|
|
19
|
+
const allChains = new Set((0, utils_1.getChainsFromRequiredNamespaces)(mergedNamespacesObject));
|
|
20
|
+
const service = services.find((service) => (0, blockchain_service_1.hasWalletConnect)(service) && allChains.has(service.walletConnectService.chain));
|
|
21
|
+
if (!service)
|
|
22
|
+
throw new blockchain_service_1.BSError('Requested chain(s) not supported by any service', 'NO_SERVICE');
|
|
23
|
+
const namespaceObject = mergedNamespacesObject[service.walletConnectService.namespace];
|
|
24
|
+
if (!namespaceObject)
|
|
25
|
+
throw new blockchain_service_1.BSError('Requested namespace not supported by any service', 'NO_SERVICE');
|
|
26
|
+
const approvedNamespaces = (0, utils_1.buildApprovedNamespaces)({
|
|
27
|
+
proposal: proposal,
|
|
28
|
+
supportedNamespaces: {
|
|
29
|
+
[service.walletConnectService.namespace]: {
|
|
30
|
+
chains: [service.walletConnectService.chain],
|
|
31
|
+
methods: service.walletConnectService.supportedMethods,
|
|
32
|
+
events: service.walletConnectService.supportedEvents,
|
|
33
|
+
accounts: [`${service.walletConnectService.chain}:${address}`],
|
|
34
|
+
},
|
|
35
|
+
},
|
|
36
|
+
});
|
|
37
|
+
const methods = namespaceObject.methods;
|
|
38
|
+
return { approvedNamespaces, methods, service, blockchain: service.name };
|
|
39
|
+
}
|
|
40
|
+
static getSessionDetails({ session, services, }) {
|
|
41
|
+
const sessionAccounts = (0, utils_1.getAccountsFromNamespaces)(session.namespaces);
|
|
42
|
+
const [sessionAddress] = (0, utils_1.getAddressesFromAccounts)(sessionAccounts);
|
|
43
|
+
if (!sessionAddress)
|
|
44
|
+
throw new blockchain_service_1.BSError('No accounts found in session', 'NO_ACCOUNTS');
|
|
45
|
+
const chains = (0, utils_1.getChainsFromNamespaces)(session.namespaces);
|
|
46
|
+
const service = services.find((service) => (0, blockchain_service_1.hasWalletConnect)(service) && chains.includes(service.walletConnectService.chain));
|
|
47
|
+
if (!service)
|
|
48
|
+
throw new blockchain_service_1.BSError('Requested chain not supported by any service', 'NO_SERVICE');
|
|
49
|
+
const methods = (0, utils_1.getNamespacesMethodsForChainId)(session.namespaces, service.walletConnectService.chain);
|
|
50
|
+
return { service, address: sessionAddress, methods, blockchain: service.name };
|
|
51
|
+
}
|
|
52
|
+
static getError(key) {
|
|
53
|
+
return (0, utils_1.getSdkError)(key);
|
|
54
|
+
}
|
|
55
|
+
static formatRequestResult(request, response) {
|
|
56
|
+
return (0, jsonrpc_utils_1.formatJsonRpcResult)(request.id, response);
|
|
57
|
+
}
|
|
58
|
+
static formatRequestError(request, reason) {
|
|
59
|
+
return (0, jsonrpc_utils_1.formatJsonRpcError)(request.id, reason !== null && reason !== void 0 ? reason : (0, utils_1.getSdkError)('USER_REJECTED'));
|
|
60
|
+
}
|
|
61
|
+
static processRequest(_a) {
|
|
62
|
+
return __awaiter(this, arguments, void 0, function* ({ sessionDetails, account, request, }) {
|
|
63
|
+
if (account.address !== sessionDetails.address) {
|
|
64
|
+
throw new blockchain_service_1.BSError('Account address does not match session address', 'INVALID_ACCOUNT');
|
|
65
|
+
}
|
|
66
|
+
const method = request.params.request.method;
|
|
67
|
+
if (!sessionDetails.methods.includes(method)) {
|
|
68
|
+
throw new blockchain_service_1.BSError('Method not supported by session', 'UNSUPPORTED_METHOD');
|
|
69
|
+
}
|
|
70
|
+
const serviceMethod = sessionDetails.service.walletConnectService[method];
|
|
71
|
+
if (!serviceMethod || typeof serviceMethod !== 'function')
|
|
72
|
+
throw new blockchain_service_1.BSError('Method not supported', 'UNSUPPORTED_METHOD');
|
|
73
|
+
const response = yield serviceMethod.apply(sessionDetails.service.walletConnectService, [
|
|
74
|
+
{ account, params: request.params.request.params },
|
|
75
|
+
]);
|
|
76
|
+
return response;
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
static filterSessions(sessions, filters) {
|
|
80
|
+
let filteredSessions = sessions;
|
|
81
|
+
if (filters === null || filters === void 0 ? void 0 : filters.addresses) {
|
|
82
|
+
filteredSessions = filteredSessions.filter(session => {
|
|
83
|
+
let matched = false;
|
|
84
|
+
if (filters.addresses) {
|
|
85
|
+
const sessionAccounts = (0, utils_1.getAccountsFromNamespaces)(session.namespaces);
|
|
86
|
+
const [address] = (0, utils_1.getAddressesFromAccounts)(sessionAccounts);
|
|
87
|
+
if (address && filters.addresses.includes(address)) {
|
|
88
|
+
matched = true;
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
if (filters.chains && !matched) {
|
|
92
|
+
const chains = (0, utils_1.getChainsFromNamespaces)(session.namespaces);
|
|
93
|
+
if (chains.some(namespace => { var _a; return (_a = filters.chains) === null || _a === void 0 ? void 0 : _a.includes(namespace); })) {
|
|
94
|
+
matched = true;
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
return matched;
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
return filteredSessions;
|
|
101
|
+
}
|
|
102
|
+
static isValidURI(uri) {
|
|
103
|
+
return /^wc:.+@\d.*$/g.test(uri);
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
exports.WalletKitHelper = WalletKitHelper;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./WalletKitHelper"), exports);
|
|
18
|
+
__exportStar(require("./types"), exports);
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { IBlockchainService, IBSWithWalletConnect, TBSAccount } from '@cityofzion/blockchain-service';
|
|
2
|
+
import { PendingRequestTypes, ProposalTypes, SessionTypes } from '@walletconnect/types';
|
|
3
|
+
export type TWalletKitHelperGetProposalDetailsParams<N extends string = string> = {
|
|
4
|
+
proposal: ProposalTypes.Struct;
|
|
5
|
+
address: string;
|
|
6
|
+
services: IBlockchainService<N>[];
|
|
7
|
+
};
|
|
8
|
+
export type TWalletKitHelperProposalDetails<N extends string = string> = {
|
|
9
|
+
methods: string[];
|
|
10
|
+
approvedNamespaces: SessionTypes.Namespaces;
|
|
11
|
+
service: IBlockchainService<N> & IBSWithWalletConnect;
|
|
12
|
+
blockchain: N;
|
|
13
|
+
};
|
|
14
|
+
export type TWalletKitHelperGetSessionDetailsParams<N extends string = string> = {
|
|
15
|
+
session: SessionTypes.Struct;
|
|
16
|
+
services: IBlockchainService<N>[];
|
|
17
|
+
};
|
|
18
|
+
export type TWalletKitHelperSessionDetails<N extends string = string> = {
|
|
19
|
+
address: string;
|
|
20
|
+
methods: string[];
|
|
21
|
+
service: IBlockchainService<N> & IBSWithWalletConnect;
|
|
22
|
+
blockchain: N;
|
|
23
|
+
};
|
|
24
|
+
export type TWalletKitHelperProcessRequestParams<N extends string = string> = {
|
|
25
|
+
request: PendingRequestTypes.Struct;
|
|
26
|
+
sessionDetails: TWalletKitHelperSessionDetails<N>;
|
|
27
|
+
account: TBSAccount<N>;
|
|
28
|
+
};
|
|
29
|
+
export type TWalletKitHelperFilterSessionsParams = {
|
|
30
|
+
addresses?: string[];
|
|
31
|
+
chains?: string[];
|
|
32
|
+
};
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -16,4 +16,5 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
__exportStar(require("./features/swap"), exports);
|
|
18
18
|
__exportStar(require("./features/bridge"), exports);
|
|
19
|
+
__exportStar(require("./features/wallet-connect"), exports);
|
|
19
20
|
__exportStar(require("./BSAggregator"), exports);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cityofzion/bs-multichain",
|
|
3
|
-
"version": "1.0
|
|
3
|
+
"version": "1.1.0",
|
|
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,32 @@
|
|
|
10
10
|
"/dist"
|
|
11
11
|
],
|
|
12
12
|
"dependencies": {
|
|
13
|
-
"axios": "~1.
|
|
14
|
-
"
|
|
15
|
-
"@
|
|
13
|
+
"axios": "~1.12.2",
|
|
14
|
+
"@walletconnect/utils": "~2.21.9",
|
|
15
|
+
"@walletconnect/jsonrpc-utils": "~1.0.8",
|
|
16
|
+
"@cityofzion/blockchain-service": "1.22.0"
|
|
16
17
|
},
|
|
17
18
|
"devDependencies": {
|
|
18
|
-
"@types/
|
|
19
|
-
"
|
|
20
|
-
"
|
|
21
|
-
"
|
|
22
|
-
"
|
|
19
|
+
"@types/node": "~24.5.2",
|
|
20
|
+
"@types/jest": "~30.0.0",
|
|
21
|
+
"@walletconnect/types": "~2.21.9",
|
|
22
|
+
"dotenv": "~17.2.2",
|
|
23
|
+
"eslint": "~9.36.0",
|
|
24
|
+
"jest": "~30.1.3",
|
|
25
|
+
"ts-jest": "~29.4.4",
|
|
23
26
|
"ts-node": "~10.9.2",
|
|
24
|
-
"typescript": "
|
|
27
|
+
"typescript": "~5.9.2",
|
|
25
28
|
"typed-emitter": "~2.1.0",
|
|
26
|
-
"@
|
|
27
|
-
"@
|
|
28
|
-
"@
|
|
29
|
-
"@
|
|
30
|
-
"@cityofzion/bs-neo3": "1.16.3",
|
|
31
|
-
"@cityofzion/bs-neo-legacy": "1.13.4",
|
|
32
|
-
"@cityofzion/bs-neox": "1.3.5",
|
|
33
|
-
"@cityofzion/bs-ethereum": "2.13.4"
|
|
29
|
+
"@cityofzion/bs-ethereum": "2.14.0",
|
|
30
|
+
"@cityofzion/bs-neo3": "1.17.0",
|
|
31
|
+
"@cityofzion/bs-neo-legacy": "1.13.5",
|
|
32
|
+
"@cityofzion/bs-neox": "1.4.0"
|
|
34
33
|
},
|
|
35
34
|
"scripts": {
|
|
36
|
-
"build": "tsc --project tsconfig.build.json",
|
|
37
|
-
"test": "jest --config jest.config.ts",
|
|
35
|
+
"build": "rm -rf ./dist && tsc --project tsconfig.build.json",
|
|
36
|
+
"test": "jest -i --config jest.config.ts",
|
|
38
37
|
"lint": "eslint .",
|
|
39
|
-
"format": "eslint --fix"
|
|
38
|
+
"format": "eslint --fix",
|
|
39
|
+
"package": "npm run build && npm pack"
|
|
40
40
|
}
|
|
41
41
|
}
|