@cityofzion/bs-ethereum 2.3.0 → 2.5.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/BSEthereum.d.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import { Account, BSCalculableFee, BSWithExplorerService, BSWithLedger, BSWithNameService, BSWithNft, BlockchainDataService, BlockchainService, ExchangeDataService, ExplorerService, Network, NftDataService, Token, TransferParam } from '@cityofzion/blockchain-service';
|
|
1
|
+
import { Account, BSCalculableFee, BSWithExplorerService, BSWithLedger, BSWithNameService, BSWithNft, BlockchainDataService, BlockchainService, ExchangeDataService, ExplorerService, Network, NftDataService, Token, TransferParam, GetLedgerTransport } from '@cityofzion/blockchain-service';
|
|
2
2
|
import { BSEthereumNetworkId } from './constants/BSEthereumConstants';
|
|
3
3
|
import { EthersLedgerServiceEthereum } from './services/ledger/EthersLedgerServiceEthereum';
|
|
4
|
-
import Transport from '@ledgerhq/hw-transport';
|
|
5
4
|
export declare class BSEthereum<BSCustomName extends string = string> implements BlockchainService<BSCustomName, BSEthereumNetworkId>, BSWithNft, BSWithNameService, BSCalculableFee, BSWithLedger, BSWithExplorerService {
|
|
6
5
|
#private;
|
|
7
6
|
readonly blockchainName: BSCustomName;
|
|
@@ -14,7 +13,8 @@ export declare class BSEthereum<BSCustomName extends string = string> implements
|
|
|
14
13
|
nftDataService: NftDataService;
|
|
15
14
|
network: Network<BSEthereumNetworkId>;
|
|
16
15
|
explorerService: ExplorerService;
|
|
17
|
-
constructor(blockchainName: BSCustomName, network?: Network<BSEthereumNetworkId>, getLedgerTransport?:
|
|
16
|
+
constructor(blockchainName: BSCustomName, network?: Network<BSEthereumNetworkId>, getLedgerTransport?: GetLedgerTransport);
|
|
17
|
+
testNetwork(network: Network<BSEthereumNetworkId>): Promise<void>;
|
|
18
18
|
setNetwork(network: Network<BSEthereumNetworkId>): void;
|
|
19
19
|
validateAddress(address: string): boolean;
|
|
20
20
|
validateEncrypted(json: string): boolean;
|
package/dist/BSEthereum.js
CHANGED
|
@@ -31,12 +31,18 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
31
31
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
32
32
|
});
|
|
33
33
|
};
|
|
34
|
+
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
|
35
|
+
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
36
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
37
|
+
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");
|
|
38
|
+
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
39
|
+
};
|
|
34
40
|
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
35
41
|
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
36
42
|
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");
|
|
37
43
|
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
38
44
|
};
|
|
39
|
-
var _BSEthereum_instances, _BSEthereum_generateSigner, _BSEthereum_buildTransferParams, _BSEthereum_setTokens;
|
|
45
|
+
var _BSEthereum_instances, _BSEthereum_getLedgerTransport, _BSEthereum_generateSigner, _BSEthereum_buildTransferParams, _BSEthereum_setTokens;
|
|
40
46
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
41
47
|
exports.BSEthereum = void 0;
|
|
42
48
|
const ethers_1 = require("ethers");
|
|
@@ -52,15 +58,24 @@ const MoralisBDSEthereum_1 = require("./services/blockchain-data/MoralisBDSEther
|
|
|
52
58
|
const MoralisEDSEthereum_1 = require("./services/exchange-data/MoralisEDSEthereum");
|
|
53
59
|
const GhostMarketNDSEthereum_1 = require("./services/nft-data/GhostMarketNDSEthereum");
|
|
54
60
|
const BlockscoutESEthereum_1 = require("./services/explorer/BlockscoutESEthereum");
|
|
61
|
+
const RpcBDSEthereum_1 = require("./services/blockchain-data/RpcBDSEthereum");
|
|
55
62
|
class BSEthereum {
|
|
56
63
|
constructor(blockchainName, network, getLedgerTransport) {
|
|
57
64
|
_BSEthereum_instances.add(this);
|
|
65
|
+
_BSEthereum_getLedgerTransport.set(this, void 0);
|
|
58
66
|
network = network !== null && network !== void 0 ? network : BSEthereumConstants_1.BSEthereumConstants.DEFAULT_NETWORK;
|
|
59
67
|
this.blockchainName = blockchainName;
|
|
60
68
|
this.ledgerService = new EthersLedgerServiceEthereum_1.EthersLedgerServiceEthereum(this, getLedgerTransport);
|
|
69
|
+
__classPrivateFieldSet(this, _BSEthereum_getLedgerTransport, getLedgerTransport, "f");
|
|
61
70
|
this.bip44DerivationPath = BSEthereumConstants_1.BSEthereumConstants.DEFAULT_BIP44_DERIVATION_PATH;
|
|
62
71
|
this.setNetwork(network);
|
|
63
72
|
}
|
|
73
|
+
testNetwork(network) {
|
|
74
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
75
|
+
const blockchainDataServiceClone = new RpcBDSEthereum_1.RpcBDSEthereum(network);
|
|
76
|
+
yield blockchainDataServiceClone.getBlockHeight();
|
|
77
|
+
});
|
|
78
|
+
}
|
|
64
79
|
setNetwork(network) {
|
|
65
80
|
__classPrivateFieldGet(this, _BSEthereum_instances, "m", _BSEthereum_setTokens).call(this, network);
|
|
66
81
|
this.network = network;
|
|
@@ -86,18 +101,14 @@ class BSEthereum {
|
|
|
86
101
|
if (!key.startsWith('0x')) {
|
|
87
102
|
key = '0x' + key;
|
|
88
103
|
}
|
|
89
|
-
|
|
90
|
-
return false;
|
|
91
|
-
return true;
|
|
104
|
+
return ethersBytes.hexDataLength(key) === 32;
|
|
92
105
|
}
|
|
93
106
|
catch (error) {
|
|
94
107
|
return false;
|
|
95
108
|
}
|
|
96
109
|
}
|
|
97
110
|
validateNameServiceDomainFormat(domainName) {
|
|
98
|
-
|
|
99
|
-
return false;
|
|
100
|
-
return true;
|
|
111
|
+
return domainName.endsWith('.eth');
|
|
101
112
|
}
|
|
102
113
|
generateAccountFromMnemonic(mnemonic, index) {
|
|
103
114
|
const bip44Path = this.bip44DerivationPath.replace('?', index.toString());
|
|
@@ -146,6 +157,7 @@ class BSEthereum {
|
|
|
146
157
|
const signer = yield __classPrivateFieldGet(this, _BSEthereum_instances, "m", _BSEthereum_generateSigner).call(this, param.senderAccount, param.isLedger);
|
|
147
158
|
const sentTransactionHashes = [];
|
|
148
159
|
for (const intent of param.intents) {
|
|
160
|
+
let transactionHash = '';
|
|
149
161
|
try {
|
|
150
162
|
const { transactionParams, gasPrice } = yield __classPrivateFieldGet(this, _BSEthereum_instances, "m", _BSEthereum_buildTransferParams).call(this, intent);
|
|
151
163
|
let gasLimit;
|
|
@@ -156,11 +168,12 @@ class BSEthereum {
|
|
|
156
168
|
gasLimit = BSEthereumConstants_1.BSEthereumConstants.DEFAULT_GAS_LIMIT;
|
|
157
169
|
}
|
|
158
170
|
const transaction = yield signer.sendTransaction(Object.assign(Object.assign({}, transactionParams), { gasLimit, maxPriorityFeePerGas: gasPrice, maxFeePerGas: gasPrice }));
|
|
159
|
-
|
|
171
|
+
transactionHash = transaction.hash;
|
|
160
172
|
}
|
|
161
173
|
catch (_b) {
|
|
162
174
|
/* empty */
|
|
163
175
|
}
|
|
176
|
+
sentTransactionHashes.push(transactionHash);
|
|
164
177
|
}
|
|
165
178
|
return sentTransactionHashes;
|
|
166
179
|
});
|
|
@@ -189,7 +202,7 @@ class BSEthereum {
|
|
|
189
202
|
}
|
|
190
203
|
}
|
|
191
204
|
exports.BSEthereum = BSEthereum;
|
|
192
|
-
_BSEthereum_instances = new WeakSet(), _BSEthereum_generateSigner = function _BSEthereum_generateSigner(account, isLedger) {
|
|
205
|
+
_BSEthereum_getLedgerTransport = new WeakMap(), _BSEthereum_instances = new WeakSet(), _BSEthereum_generateSigner = function _BSEthereum_generateSigner(account, isLedger) {
|
|
193
206
|
return __awaiter(this, void 0, void 0, function* () {
|
|
194
207
|
const provider = new ethers_1.ethers.providers.JsonRpcProvider(this.network.url);
|
|
195
208
|
if (isLedger) {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Account, LedgerService, LedgerServiceEmitter } from '@cityofzion/blockchain-service';
|
|
1
|
+
import { Account, LedgerService, LedgerServiceEmitter, GetLedgerTransport } from '@cityofzion/blockchain-service';
|
|
2
2
|
import Transport from '@ledgerhq/hw-transport';
|
|
3
3
|
import { ethers, Signer } from 'ethers';
|
|
4
4
|
import { TypedDataSigner } from '@ethersproject/abstract-signer';
|
|
@@ -15,8 +15,8 @@ export declare class EthersLedgerSigner extends Signer implements TypedDataSigne
|
|
|
15
15
|
export declare class EthersLedgerServiceEthereum implements LedgerService {
|
|
16
16
|
#private;
|
|
17
17
|
emitter: LedgerServiceEmitter;
|
|
18
|
-
getLedgerTransport?:
|
|
19
|
-
constructor(blockchainService: BSEthereum, getLedgerTransport?:
|
|
18
|
+
getLedgerTransport?: GetLedgerTransport;
|
|
19
|
+
constructor(blockchainService: BSEthereum, getLedgerTransport?: GetLedgerTransport);
|
|
20
20
|
getAccounts(transport: Transport): Promise<Account[]>;
|
|
21
21
|
getAccount(transport: Transport, index: number): Promise<Account>;
|
|
22
22
|
getSigner(transport: Transport, path: string, provider?: ethers.providers.Provider): EthersLedgerSigner;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cityofzion/bs-ethereum",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.5.0",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"types": "dist/index.d.ts",
|
|
6
6
|
"repository": "https://github.com/CityOfZion/blockchain-services",
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
"@ledgerhq/hw-app-eth": "~6.35.7",
|
|
21
21
|
"@ethersproject/abstract-signer": "~5.7.0",
|
|
22
22
|
"@ethersproject/properties": "~5.7.0",
|
|
23
|
-
"@cityofzion/blockchain-service": "1.
|
|
23
|
+
"@cityofzion/blockchain-service": "1.6.0"
|
|
24
24
|
},
|
|
25
25
|
"devDependencies": {
|
|
26
26
|
"@ledgerhq/hw-transport-node-hid": "~6.28.5",
|