@cityofzion/bs-ethereum 1.4.3 → 2.0.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.
- package/dist/BSEthereum.d.ts +10 -8
- package/dist/BSEthereum.js +26 -23
- package/dist/BSEthereumHelper.d.ts +22 -0
- package/dist/BSEthereumHelper.js +236 -0
- package/dist/BitqueryBDSEthereum.d.ts +5 -1
- package/dist/BitqueryBDSEthereum.js +46 -25
- package/dist/BitqueryEDSEthereum.d.ts +3 -2
- package/dist/BitqueryEDSEthereum.js +10 -11
- package/dist/{LedgerServiceEthereum.d.ts → EthersLedgerServiceEthereum.d.ts} +4 -4
- package/dist/{LedgerServiceEthereum.js → EthersLedgerServiceEthereum.js} +39 -39
- package/dist/GhostMarketNDSEthereum.d.ts +6 -1
- package/dist/GhostMarketNDSEthereum.js +15 -7
- package/dist/RpcBDSEthereum.d.ts +2 -1
- package/dist/RpcBDSEthereum.js +22 -11
- package/dist/assets/abis/ERC20.d.ts +38 -0
- package/dist/assets/abis/ERC20.js +225 -0
- package/dist/index.d.ts +4 -3
- package/dist/index.js +4 -3
- package/package.json +3 -3
- package/dist/assets/tokens/common.json +0 -8
- package/dist/constants.d.ts +0 -17
- package/dist/constants.js +0 -52
|
@@ -45,40 +45,40 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
|
|
|
45
45
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
46
46
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
47
47
|
};
|
|
48
|
-
var
|
|
48
|
+
var _EthersLedgerSigner_instances, _EthersLedgerSigner_transport, _EthersLedgerSigner_emitter, _EthersLedgerSigner_path, _EthersLedgerSigner_retry;
|
|
49
49
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
50
|
-
exports.
|
|
50
|
+
exports.EthersLedgerServiceEthereum = exports.EthersLedgerSigner = void 0;
|
|
51
51
|
const hw_app_eth_1 = __importStar(require("@ledgerhq/hw-app-eth"));
|
|
52
52
|
const ethers_1 = require("ethers");
|
|
53
53
|
const properties_1 = require("@ethersproject/properties");
|
|
54
|
-
const constants_1 = require("./constants");
|
|
55
54
|
const events_1 = __importDefault(require("events"));
|
|
56
|
-
|
|
55
|
+
const BSEthereumHelper_1 = require("./BSEthereumHelper");
|
|
56
|
+
class EthersLedgerSigner extends ethers_1.Signer {
|
|
57
57
|
constructor(transport, provider, emitter) {
|
|
58
58
|
super();
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
__classPrivateFieldSet(this,
|
|
64
|
-
__classPrivateFieldSet(this,
|
|
65
|
-
__classPrivateFieldSet(this,
|
|
59
|
+
_EthersLedgerSigner_instances.add(this);
|
|
60
|
+
_EthersLedgerSigner_transport.set(this, void 0);
|
|
61
|
+
_EthersLedgerSigner_emitter.set(this, void 0);
|
|
62
|
+
_EthersLedgerSigner_path.set(this, void 0);
|
|
63
|
+
__classPrivateFieldSet(this, _EthersLedgerSigner_path, BSEthereumHelper_1.BSEthereumHelper.DEFAULT_PATH, "f");
|
|
64
|
+
__classPrivateFieldSet(this, _EthersLedgerSigner_transport, transport, "f");
|
|
65
|
+
__classPrivateFieldSet(this, _EthersLedgerSigner_emitter, emitter, "f");
|
|
66
66
|
(0, properties_1.defineReadOnly)(this, 'provider', provider);
|
|
67
67
|
}
|
|
68
68
|
connect(provider) {
|
|
69
|
-
return new
|
|
69
|
+
return new EthersLedgerSigner(__classPrivateFieldGet(this, _EthersLedgerSigner_transport, "f"), provider, __classPrivateFieldGet(this, _EthersLedgerSigner_emitter, "f"));
|
|
70
70
|
}
|
|
71
71
|
getAddress() {
|
|
72
72
|
return __awaiter(this, void 0, void 0, function* () {
|
|
73
|
-
const ledgerApp = new hw_app_eth_1.default(__classPrivateFieldGet(this,
|
|
74
|
-
const { address } = yield __classPrivateFieldGet(this,
|
|
73
|
+
const ledgerApp = new hw_app_eth_1.default(__classPrivateFieldGet(this, _EthersLedgerSigner_transport, "f"));
|
|
74
|
+
const { address } = yield __classPrivateFieldGet(this, _EthersLedgerSigner_instances, "m", _EthersLedgerSigner_retry).call(this, () => ledgerApp.getAddress(__classPrivateFieldGet(this, _EthersLedgerSigner_path, "f")));
|
|
75
75
|
return ethers_1.ethers.utils.getAddress(address);
|
|
76
76
|
});
|
|
77
77
|
}
|
|
78
78
|
getPublicKey() {
|
|
79
79
|
return __awaiter(this, void 0, void 0, function* () {
|
|
80
|
-
const ledgerApp = new hw_app_eth_1.default(__classPrivateFieldGet(this,
|
|
81
|
-
const { publicKey } = yield __classPrivateFieldGet(this,
|
|
80
|
+
const ledgerApp = new hw_app_eth_1.default(__classPrivateFieldGet(this, _EthersLedgerSigner_transport, "f"));
|
|
81
|
+
const { publicKey } = yield __classPrivateFieldGet(this, _EthersLedgerSigner_instances, "m", _EthersLedgerSigner_retry).call(this, () => ledgerApp.getAddress(__classPrivateFieldGet(this, _EthersLedgerSigner_path, "f")));
|
|
82
82
|
return '0x' + publicKey;
|
|
83
83
|
});
|
|
84
84
|
}
|
|
@@ -89,17 +89,17 @@ class LedgerSigner extends ethers_1.Signer {
|
|
|
89
89
|
if (typeof message === 'string') {
|
|
90
90
|
message = ethers_1.ethers.utils.toUtf8Bytes(message);
|
|
91
91
|
}
|
|
92
|
-
const ledgerApp = new hw_app_eth_1.default(__classPrivateFieldGet(this,
|
|
93
|
-
(_a = __classPrivateFieldGet(this,
|
|
94
|
-
const obj = yield __classPrivateFieldGet(this,
|
|
95
|
-
(_b = __classPrivateFieldGet(this,
|
|
92
|
+
const ledgerApp = new hw_app_eth_1.default(__classPrivateFieldGet(this, _EthersLedgerSigner_transport, "f"));
|
|
93
|
+
(_a = __classPrivateFieldGet(this, _EthersLedgerSigner_emitter, "f")) === null || _a === void 0 ? void 0 : _a.emit('getSignatureStart');
|
|
94
|
+
const obj = yield __classPrivateFieldGet(this, _EthersLedgerSigner_instances, "m", _EthersLedgerSigner_retry).call(this, () => ledgerApp.signPersonalMessage(__classPrivateFieldGet(this, _EthersLedgerSigner_path, "f"), ethers_1.ethers.utils.hexlify(message).substring(2)));
|
|
95
|
+
(_b = __classPrivateFieldGet(this, _EthersLedgerSigner_emitter, "f")) === null || _b === void 0 ? void 0 : _b.emit('getSignatureEnd');
|
|
96
96
|
// Normalize the signature for Ethers
|
|
97
97
|
obj.r = '0x' + obj.r;
|
|
98
98
|
obj.s = '0x' + obj.s;
|
|
99
99
|
return ethers_1.ethers.utils.joinSignature(obj);
|
|
100
100
|
}
|
|
101
101
|
catch (error) {
|
|
102
|
-
(_c = __classPrivateFieldGet(this,
|
|
102
|
+
(_c = __classPrivateFieldGet(this, _EthersLedgerSigner_emitter, "f")) === null || _c === void 0 ? void 0 : _c.emit('getSignatureEnd');
|
|
103
103
|
throw error;
|
|
104
104
|
}
|
|
105
105
|
});
|
|
@@ -108,7 +108,7 @@ class LedgerSigner extends ethers_1.Signer {
|
|
|
108
108
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
|
109
109
|
return __awaiter(this, void 0, void 0, function* () {
|
|
110
110
|
try {
|
|
111
|
-
const ledgerApp = new hw_app_eth_1.default(__classPrivateFieldGet(this,
|
|
111
|
+
const ledgerApp = new hw_app_eth_1.default(__classPrivateFieldGet(this, _EthersLedgerSigner_transport, "f"));
|
|
112
112
|
const tx = yield ethers_1.ethers.utils.resolveProperties(transaction);
|
|
113
113
|
const unsignedTransaction = {
|
|
114
114
|
chainId: (_a = tx.chainId) !== null && _a !== void 0 ? _a : undefined,
|
|
@@ -121,9 +121,9 @@ class LedgerSigner extends ethers_1.Signer {
|
|
|
121
121
|
};
|
|
122
122
|
const serializedUnsignedTransaction = ethers_1.ethers.utils.serializeTransaction(unsignedTransaction).substring(2);
|
|
123
123
|
const resolution = yield hw_app_eth_1.ledgerService.resolveTransaction(serializedUnsignedTransaction, {}, {});
|
|
124
|
-
(_g = __classPrivateFieldGet(this,
|
|
125
|
-
const signature = yield __classPrivateFieldGet(this,
|
|
126
|
-
(_h = __classPrivateFieldGet(this,
|
|
124
|
+
(_g = __classPrivateFieldGet(this, _EthersLedgerSigner_emitter, "f")) === null || _g === void 0 ? void 0 : _g.emit('getSignatureStart');
|
|
125
|
+
const signature = yield __classPrivateFieldGet(this, _EthersLedgerSigner_instances, "m", _EthersLedgerSigner_retry).call(this, () => ledgerApp.signTransaction(__classPrivateFieldGet(this, _EthersLedgerSigner_path, "f"), serializedUnsignedTransaction, resolution));
|
|
126
|
+
(_h = __classPrivateFieldGet(this, _EthersLedgerSigner_emitter, "f")) === null || _h === void 0 ? void 0 : _h.emit('getSignatureEnd');
|
|
127
127
|
return ethers_1.ethers.utils.serializeTransaction(unsignedTransaction, {
|
|
128
128
|
v: ethers_1.ethers.BigNumber.from('0x' + signature.v).toNumber(),
|
|
129
129
|
r: '0x' + signature.r,
|
|
@@ -131,7 +131,7 @@ class LedgerSigner extends ethers_1.Signer {
|
|
|
131
131
|
});
|
|
132
132
|
}
|
|
133
133
|
catch (error) {
|
|
134
|
-
(_j = __classPrivateFieldGet(this,
|
|
134
|
+
(_j = __classPrivateFieldGet(this, _EthersLedgerSigner_emitter, "f")) === null || _j === void 0 ? void 0 : _j.emit('getSignatureEnd');
|
|
135
135
|
throw error;
|
|
136
136
|
}
|
|
137
137
|
});
|
|
@@ -149,32 +149,32 @@ class LedgerSigner extends ethers_1.Signer {
|
|
|
149
149
|
return resolved;
|
|
150
150
|
}));
|
|
151
151
|
const payload = ethers_1.ethers.utils._TypedDataEncoder.getPayload(populated.domain, types, populated.value);
|
|
152
|
-
const ledgerApp = new hw_app_eth_1.default(__classPrivateFieldGet(this,
|
|
153
|
-
(_a = __classPrivateFieldGet(this,
|
|
152
|
+
const ledgerApp = new hw_app_eth_1.default(__classPrivateFieldGet(this, _EthersLedgerSigner_transport, "f"));
|
|
153
|
+
(_a = __classPrivateFieldGet(this, _EthersLedgerSigner_emitter, "f")) === null || _a === void 0 ? void 0 : _a.emit('getSignatureStart');
|
|
154
154
|
let obj;
|
|
155
155
|
try {
|
|
156
|
-
obj = yield __classPrivateFieldGet(this,
|
|
156
|
+
obj = yield __classPrivateFieldGet(this, _EthersLedgerSigner_instances, "m", _EthersLedgerSigner_retry).call(this, () => ledgerApp.signEIP712Message(__classPrivateFieldGet(this, _EthersLedgerSigner_path, "f"), payload));
|
|
157
157
|
}
|
|
158
158
|
catch (_d) {
|
|
159
159
|
const domainSeparatorHex = ethers_1.ethers.utils._TypedDataEncoder.hashDomain(payload.domain);
|
|
160
160
|
const hashStructMessageHex = ethers_1.ethers.utils._TypedDataEncoder.hashStruct(payload.primaryType, types, payload.message);
|
|
161
|
-
obj = yield __classPrivateFieldGet(this,
|
|
161
|
+
obj = yield __classPrivateFieldGet(this, _EthersLedgerSigner_instances, "m", _EthersLedgerSigner_retry).call(this, () => ledgerApp.signEIP712HashedMessage(__classPrivateFieldGet(this, _EthersLedgerSigner_path, "f"), domainSeparatorHex, hashStructMessageHex));
|
|
162
162
|
}
|
|
163
|
-
(_b = __classPrivateFieldGet(this,
|
|
163
|
+
(_b = __classPrivateFieldGet(this, _EthersLedgerSigner_emitter, "f")) === null || _b === void 0 ? void 0 : _b.emit('getSignatureEnd');
|
|
164
164
|
// Normalize the signature for Ethers
|
|
165
165
|
obj.r = '0x' + obj.r;
|
|
166
166
|
obj.s = '0x' + obj.s;
|
|
167
167
|
return ethers_1.ethers.utils.joinSignature(obj);
|
|
168
168
|
}
|
|
169
169
|
catch (error) {
|
|
170
|
-
(_c = __classPrivateFieldGet(this,
|
|
170
|
+
(_c = __classPrivateFieldGet(this, _EthersLedgerSigner_emitter, "f")) === null || _c === void 0 ? void 0 : _c.emit('getSignatureEnd');
|
|
171
171
|
throw error;
|
|
172
172
|
}
|
|
173
173
|
});
|
|
174
174
|
}
|
|
175
175
|
}
|
|
176
|
-
exports.
|
|
177
|
-
|
|
176
|
+
exports.EthersLedgerSigner = EthersLedgerSigner;
|
|
177
|
+
_EthersLedgerSigner_transport = new WeakMap(), _EthersLedgerSigner_emitter = new WeakMap(), _EthersLedgerSigner_path = new WeakMap(), _EthersLedgerSigner_instances = new WeakSet(), _EthersLedgerSigner_retry = function _EthersLedgerSigner_retry(callback) {
|
|
178
178
|
// eslint-disable-next-line no-async-promise-executor
|
|
179
179
|
return new Promise((resolve, reject) => __awaiter(this, void 0, void 0, function* () {
|
|
180
180
|
// Wait up to 5 seconds
|
|
@@ -193,28 +193,28 @@ _LedgerSigner_transport = new WeakMap(), _LedgerSigner_emitter = new WeakMap(),
|
|
|
193
193
|
return reject(new Error('timeout'));
|
|
194
194
|
}));
|
|
195
195
|
};
|
|
196
|
-
class
|
|
196
|
+
class EthersLedgerServiceEthereum {
|
|
197
197
|
constructor(getLedgerTransport) {
|
|
198
198
|
this.getLedgerTransport = getLedgerTransport;
|
|
199
199
|
this.emitter = new events_1.default();
|
|
200
200
|
}
|
|
201
201
|
getAddress(transport) {
|
|
202
202
|
return __awaiter(this, void 0, void 0, function* () {
|
|
203
|
-
const signer = new
|
|
203
|
+
const signer = new EthersLedgerSigner(transport);
|
|
204
204
|
return yield signer.getAddress();
|
|
205
205
|
});
|
|
206
206
|
}
|
|
207
207
|
getPublicKey(transport) {
|
|
208
208
|
return __awaiter(this, void 0, void 0, function* () {
|
|
209
|
-
const signer = new
|
|
209
|
+
const signer = new EthersLedgerSigner(transport);
|
|
210
210
|
return yield signer.getPublicKey();
|
|
211
211
|
});
|
|
212
212
|
}
|
|
213
213
|
getSigner(transport) {
|
|
214
|
-
return new
|
|
214
|
+
return new EthersLedgerSigner(transport, undefined, this.emitter);
|
|
215
215
|
}
|
|
216
216
|
}
|
|
217
|
-
exports.
|
|
217
|
+
exports.EthersLedgerServiceEthereum = EthersLedgerServiceEthereum;
|
|
218
218
|
function wait(duration) {
|
|
219
219
|
return new Promise(resolve => {
|
|
220
220
|
setTimeout(resolve, duration);
|
|
@@ -1,8 +1,13 @@
|
|
|
1
1
|
import { NftResponse, NftsResponse, GetNftParam, GetNftsByAddressParams, Network } from '@cityofzion/blockchain-service';
|
|
2
2
|
import { RpcNDSEthereum } from './RpcNDSEthereum';
|
|
3
|
+
import { AvailableNetworkIds } from './BSEthereumHelper';
|
|
3
4
|
export declare class GhostMarketNDSEthereum extends RpcNDSEthereum {
|
|
4
5
|
#private;
|
|
5
|
-
|
|
6
|
+
static CONFIG_BY_NETWORK_ID: Partial<Record<AvailableNetworkIds, {
|
|
7
|
+
url: string;
|
|
8
|
+
chain: string;
|
|
9
|
+
}>>;
|
|
10
|
+
constructor(network: Network<AvailableNetworkIds>);
|
|
6
11
|
getNftsByAddress({ address, size, cursor }: GetNftsByAddressParams): Promise<NftsResponse>;
|
|
7
12
|
getNft({ contractHash, tokenId }: GetNftParam): Promise<NftResponse>;
|
|
8
13
|
private treatGhostMarketImage;
|
|
@@ -22,18 +22,17 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
|
|
|
22
22
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
23
23
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
24
24
|
};
|
|
25
|
-
var
|
|
25
|
+
var _GhostMarketNDSEthereum_network;
|
|
26
26
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
27
27
|
exports.GhostMarketNDSEthereum = void 0;
|
|
28
28
|
const query_string_1 = __importDefault(require("query-string"));
|
|
29
29
|
const axios_1 = __importDefault(require("axios"));
|
|
30
|
-
const constants_1 = require("./constants");
|
|
31
30
|
const RpcNDSEthereum_1 = require("./RpcNDSEthereum");
|
|
32
31
|
class GhostMarketNDSEthereum extends RpcNDSEthereum_1.RpcNDSEthereum {
|
|
33
32
|
constructor(network) {
|
|
34
33
|
super(network);
|
|
35
|
-
|
|
36
|
-
__classPrivateFieldSet(this,
|
|
34
|
+
_GhostMarketNDSEthereum_network.set(this, void 0);
|
|
35
|
+
__classPrivateFieldSet(this, _GhostMarketNDSEthereum_network, network, "f");
|
|
37
36
|
}
|
|
38
37
|
getNftsByAddress({ address, size = 18, cursor }) {
|
|
39
38
|
var _a;
|
|
@@ -69,8 +68,11 @@ class GhostMarketNDSEthereum extends RpcNDSEthereum_1.RpcNDSEthereum {
|
|
|
69
68
|
return srcImage;
|
|
70
69
|
}
|
|
71
70
|
getUrlWithParams(params) {
|
|
72
|
-
const
|
|
73
|
-
|
|
71
|
+
const config = GhostMarketNDSEthereum.CONFIG_BY_NETWORK_ID[__classPrivateFieldGet(this, _GhostMarketNDSEthereum_network, "f").id];
|
|
72
|
+
if (!config)
|
|
73
|
+
throw new Error('Unsupported network');
|
|
74
|
+
const parameters = query_string_1.default.stringify(Object.assign({ chain: config.chain }, params), { arrayFormat: 'bracket' });
|
|
75
|
+
return `${config.url}/assets?${parameters}`;
|
|
74
76
|
}
|
|
75
77
|
parse(data) {
|
|
76
78
|
var _a, _b;
|
|
@@ -92,4 +94,10 @@ class GhostMarketNDSEthereum extends RpcNDSEthereum_1.RpcNDSEthereum {
|
|
|
92
94
|
}
|
|
93
95
|
}
|
|
94
96
|
exports.GhostMarketNDSEthereum = GhostMarketNDSEthereum;
|
|
95
|
-
|
|
97
|
+
_GhostMarketNDSEthereum_network = new WeakMap();
|
|
98
|
+
GhostMarketNDSEthereum.CONFIG_BY_NETWORK_ID = {
|
|
99
|
+
'1': {
|
|
100
|
+
url: 'https://api.ghostmarket.io/api/v2',
|
|
101
|
+
chain: 'eth',
|
|
102
|
+
},
|
|
103
|
+
};
|
package/dist/RpcBDSEthereum.d.ts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { BalanceResponse, BlockchainDataService, ContractResponse, Network, RpcResponse, Token, TransactionResponse, TransactionsByAddressParams, TransactionsByAddressResponse } from '@cityofzion/blockchain-service';
|
|
2
|
+
import { AvailableNetworkIds } from './BSEthereumHelper';
|
|
2
3
|
export declare class RpcBDSEthereum implements BlockchainDataService {
|
|
3
4
|
#private;
|
|
4
5
|
maxTimeToConfirmTransactionInMs: number;
|
|
5
|
-
constructor(network: Network);
|
|
6
|
+
constructor(network: Network<AvailableNetworkIds>);
|
|
6
7
|
getTransaction(hash: string): Promise<TransactionResponse>;
|
|
7
8
|
getTransactionsByAddress(_params: TransactionsByAddressParams): Promise<TransactionsByAddressResponse>;
|
|
8
9
|
getContract(): Promise<ContractResponse>;
|
package/dist/RpcBDSEthereum.js
CHANGED
|
@@ -23,7 +23,8 @@ var _RpcBDSEthereum_network;
|
|
|
23
23
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
24
24
|
exports.RpcBDSEthereum = void 0;
|
|
25
25
|
const ethers_1 = require("ethers");
|
|
26
|
-
const
|
|
26
|
+
const ERC20_1 = require("./assets/abis/ERC20");
|
|
27
|
+
const BSEthereumHelper_1 = require("./BSEthereumHelper");
|
|
27
28
|
class RpcBDSEthereum {
|
|
28
29
|
constructor(network) {
|
|
29
30
|
_RpcBDSEthereum_network.set(this, void 0);
|
|
@@ -39,8 +40,7 @@ class RpcBDSEthereum {
|
|
|
39
40
|
const block = yield provider.getBlock(transaction.blockHash);
|
|
40
41
|
if (!block)
|
|
41
42
|
throw new Error('Block not found');
|
|
42
|
-
const
|
|
43
|
-
const token = tokens.find(token => token.symbol === 'ETH');
|
|
43
|
+
const token = BSEthereumHelper_1.BSEthereumHelper.getNativeAsset(__classPrivateFieldGet(this, _RpcBDSEthereum_network, "f"));
|
|
44
44
|
return {
|
|
45
45
|
block: block.number,
|
|
46
46
|
time: block.timestamp,
|
|
@@ -71,19 +71,26 @@ class RpcBDSEthereum {
|
|
|
71
71
|
}
|
|
72
72
|
getTokenInfo(hash) {
|
|
73
73
|
return __awaiter(this, void 0, void 0, function* () {
|
|
74
|
-
const
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
74
|
+
const nativeAsset = BSEthereumHelper_1.BSEthereumHelper.getNativeAsset(__classPrivateFieldGet(this, _RpcBDSEthereum_network, "f"));
|
|
75
|
+
if (nativeAsset.hash === hash)
|
|
76
|
+
return nativeAsset;
|
|
77
|
+
const provider = new ethers_1.ethers.providers.JsonRpcProvider(__classPrivateFieldGet(this, _RpcBDSEthereum_network, "f").url);
|
|
78
|
+
const contract = new ethers_1.ethers.Contract(hash, ERC20_1.ERC20_ABI, provider);
|
|
79
|
+
const decimals = yield contract.decimals();
|
|
80
|
+
const symbol = yield contract.symbol();
|
|
81
|
+
return {
|
|
82
|
+
decimals,
|
|
83
|
+
symbol,
|
|
84
|
+
hash,
|
|
85
|
+
name: symbol,
|
|
86
|
+
};
|
|
79
87
|
});
|
|
80
88
|
}
|
|
81
89
|
getBalance(address) {
|
|
82
90
|
return __awaiter(this, void 0, void 0, function* () {
|
|
83
91
|
const provider = new ethers_1.ethers.providers.JsonRpcProvider(__classPrivateFieldGet(this, _RpcBDSEthereum_network, "f").url);
|
|
84
92
|
const balance = yield provider.getBalance(address);
|
|
85
|
-
const
|
|
86
|
-
const token = tokens.find(token => token.symbol === 'ETH');
|
|
93
|
+
const token = BSEthereumHelper_1.BSEthereumHelper.getNativeAsset(__classPrivateFieldGet(this, _RpcBDSEthereum_network, "f"));
|
|
87
94
|
return [
|
|
88
95
|
{
|
|
89
96
|
amount: ethers_1.ethers.utils.formatEther(balance),
|
|
@@ -101,7 +108,8 @@ class RpcBDSEthereum {
|
|
|
101
108
|
getRpcList() {
|
|
102
109
|
return __awaiter(this, void 0, void 0, function* () {
|
|
103
110
|
const list = [];
|
|
104
|
-
const
|
|
111
|
+
const urls = BSEthereumHelper_1.BSEthereumHelper.getRpcList(__classPrivateFieldGet(this, _RpcBDSEthereum_network, "f"));
|
|
112
|
+
const promises = urls.map(url => {
|
|
105
113
|
// eslint-disable-next-line no-async-promise-executor
|
|
106
114
|
return new Promise((resolve) => __awaiter(this, void 0, void 0, function* () {
|
|
107
115
|
const timeout = setTimeout(() => {
|
|
@@ -118,6 +126,9 @@ class RpcBDSEthereum {
|
|
|
118
126
|
latency,
|
|
119
127
|
});
|
|
120
128
|
}
|
|
129
|
+
catch (_a) {
|
|
130
|
+
/* empty */
|
|
131
|
+
}
|
|
121
132
|
finally {
|
|
122
133
|
resolve();
|
|
123
134
|
clearTimeout(timeout);
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
export declare const ERC20_ABI: ({
|
|
2
|
+
constant: boolean;
|
|
3
|
+
inputs: {
|
|
4
|
+
name: string;
|
|
5
|
+
type: string;
|
|
6
|
+
}[];
|
|
7
|
+
name: string;
|
|
8
|
+
outputs: {
|
|
9
|
+
name: string;
|
|
10
|
+
type: string;
|
|
11
|
+
}[];
|
|
12
|
+
payable: boolean;
|
|
13
|
+
stateMutability: string;
|
|
14
|
+
type: string;
|
|
15
|
+
anonymous?: undefined;
|
|
16
|
+
} | {
|
|
17
|
+
payable: boolean;
|
|
18
|
+
stateMutability: string;
|
|
19
|
+
type: string;
|
|
20
|
+
constant?: undefined;
|
|
21
|
+
inputs?: undefined;
|
|
22
|
+
name?: undefined;
|
|
23
|
+
outputs?: undefined;
|
|
24
|
+
anonymous?: undefined;
|
|
25
|
+
} | {
|
|
26
|
+
anonymous: boolean;
|
|
27
|
+
inputs: {
|
|
28
|
+
indexed: boolean;
|
|
29
|
+
name: string;
|
|
30
|
+
type: string;
|
|
31
|
+
}[];
|
|
32
|
+
name: string;
|
|
33
|
+
type: string;
|
|
34
|
+
constant?: undefined;
|
|
35
|
+
outputs?: undefined;
|
|
36
|
+
payable?: undefined;
|
|
37
|
+
stateMutability?: undefined;
|
|
38
|
+
})[];
|
|
@@ -0,0 +1,225 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ERC20_ABI = void 0;
|
|
4
|
+
exports.ERC20_ABI = [
|
|
5
|
+
{
|
|
6
|
+
constant: true,
|
|
7
|
+
inputs: [],
|
|
8
|
+
name: 'name',
|
|
9
|
+
outputs: [
|
|
10
|
+
{
|
|
11
|
+
name: '',
|
|
12
|
+
type: 'string',
|
|
13
|
+
},
|
|
14
|
+
],
|
|
15
|
+
payable: false,
|
|
16
|
+
stateMutability: 'view',
|
|
17
|
+
type: 'function',
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
constant: false,
|
|
21
|
+
inputs: [
|
|
22
|
+
{
|
|
23
|
+
name: '_spender',
|
|
24
|
+
type: 'address',
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
name: '_value',
|
|
28
|
+
type: 'uint256',
|
|
29
|
+
},
|
|
30
|
+
],
|
|
31
|
+
name: 'approve',
|
|
32
|
+
outputs: [
|
|
33
|
+
{
|
|
34
|
+
name: '',
|
|
35
|
+
type: 'bool',
|
|
36
|
+
},
|
|
37
|
+
],
|
|
38
|
+
payable: false,
|
|
39
|
+
stateMutability: 'nonpayable',
|
|
40
|
+
type: 'function',
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
constant: true,
|
|
44
|
+
inputs: [],
|
|
45
|
+
name: 'totalSupply',
|
|
46
|
+
outputs: [
|
|
47
|
+
{
|
|
48
|
+
name: '',
|
|
49
|
+
type: 'uint256',
|
|
50
|
+
},
|
|
51
|
+
],
|
|
52
|
+
payable: false,
|
|
53
|
+
stateMutability: 'view',
|
|
54
|
+
type: 'function',
|
|
55
|
+
},
|
|
56
|
+
{
|
|
57
|
+
constant: false,
|
|
58
|
+
inputs: [
|
|
59
|
+
{
|
|
60
|
+
name: '_from',
|
|
61
|
+
type: 'address',
|
|
62
|
+
},
|
|
63
|
+
{
|
|
64
|
+
name: '_to',
|
|
65
|
+
type: 'address',
|
|
66
|
+
},
|
|
67
|
+
{
|
|
68
|
+
name: '_value',
|
|
69
|
+
type: 'uint256',
|
|
70
|
+
},
|
|
71
|
+
],
|
|
72
|
+
name: 'transferFrom',
|
|
73
|
+
outputs: [
|
|
74
|
+
{
|
|
75
|
+
name: '',
|
|
76
|
+
type: 'bool',
|
|
77
|
+
},
|
|
78
|
+
],
|
|
79
|
+
payable: false,
|
|
80
|
+
stateMutability: 'nonpayable',
|
|
81
|
+
type: 'function',
|
|
82
|
+
},
|
|
83
|
+
{
|
|
84
|
+
constant: true,
|
|
85
|
+
inputs: [],
|
|
86
|
+
name: 'decimals',
|
|
87
|
+
outputs: [
|
|
88
|
+
{
|
|
89
|
+
name: '',
|
|
90
|
+
type: 'uint8',
|
|
91
|
+
},
|
|
92
|
+
],
|
|
93
|
+
payable: false,
|
|
94
|
+
stateMutability: 'view',
|
|
95
|
+
type: 'function',
|
|
96
|
+
},
|
|
97
|
+
{
|
|
98
|
+
constant: true,
|
|
99
|
+
inputs: [
|
|
100
|
+
{
|
|
101
|
+
name: '_owner',
|
|
102
|
+
type: 'address',
|
|
103
|
+
},
|
|
104
|
+
],
|
|
105
|
+
name: 'balanceOf',
|
|
106
|
+
outputs: [
|
|
107
|
+
{
|
|
108
|
+
name: 'balance',
|
|
109
|
+
type: 'uint256',
|
|
110
|
+
},
|
|
111
|
+
],
|
|
112
|
+
payable: false,
|
|
113
|
+
stateMutability: 'view',
|
|
114
|
+
type: 'function',
|
|
115
|
+
},
|
|
116
|
+
{
|
|
117
|
+
constant: true,
|
|
118
|
+
inputs: [],
|
|
119
|
+
name: 'symbol',
|
|
120
|
+
outputs: [
|
|
121
|
+
{
|
|
122
|
+
name: '',
|
|
123
|
+
type: 'string',
|
|
124
|
+
},
|
|
125
|
+
],
|
|
126
|
+
payable: false,
|
|
127
|
+
stateMutability: 'view',
|
|
128
|
+
type: 'function',
|
|
129
|
+
},
|
|
130
|
+
{
|
|
131
|
+
constant: false,
|
|
132
|
+
inputs: [
|
|
133
|
+
{
|
|
134
|
+
name: '_to',
|
|
135
|
+
type: 'address',
|
|
136
|
+
},
|
|
137
|
+
{
|
|
138
|
+
name: '_value',
|
|
139
|
+
type: 'uint256',
|
|
140
|
+
},
|
|
141
|
+
],
|
|
142
|
+
name: 'transfer',
|
|
143
|
+
outputs: [
|
|
144
|
+
{
|
|
145
|
+
name: '',
|
|
146
|
+
type: 'bool',
|
|
147
|
+
},
|
|
148
|
+
],
|
|
149
|
+
payable: false,
|
|
150
|
+
stateMutability: 'nonpayable',
|
|
151
|
+
type: 'function',
|
|
152
|
+
},
|
|
153
|
+
{
|
|
154
|
+
constant: true,
|
|
155
|
+
inputs: [
|
|
156
|
+
{
|
|
157
|
+
name: '_owner',
|
|
158
|
+
type: 'address',
|
|
159
|
+
},
|
|
160
|
+
{
|
|
161
|
+
name: '_spender',
|
|
162
|
+
type: 'address',
|
|
163
|
+
},
|
|
164
|
+
],
|
|
165
|
+
name: 'allowance',
|
|
166
|
+
outputs: [
|
|
167
|
+
{
|
|
168
|
+
name: '',
|
|
169
|
+
type: 'uint256',
|
|
170
|
+
},
|
|
171
|
+
],
|
|
172
|
+
payable: false,
|
|
173
|
+
stateMutability: 'view',
|
|
174
|
+
type: 'function',
|
|
175
|
+
},
|
|
176
|
+
{
|
|
177
|
+
payable: true,
|
|
178
|
+
stateMutability: 'payable',
|
|
179
|
+
type: 'fallback',
|
|
180
|
+
},
|
|
181
|
+
{
|
|
182
|
+
anonymous: false,
|
|
183
|
+
inputs: [
|
|
184
|
+
{
|
|
185
|
+
indexed: true,
|
|
186
|
+
name: 'owner',
|
|
187
|
+
type: 'address',
|
|
188
|
+
},
|
|
189
|
+
{
|
|
190
|
+
indexed: true,
|
|
191
|
+
name: 'spender',
|
|
192
|
+
type: 'address',
|
|
193
|
+
},
|
|
194
|
+
{
|
|
195
|
+
indexed: false,
|
|
196
|
+
name: 'value',
|
|
197
|
+
type: 'uint256',
|
|
198
|
+
},
|
|
199
|
+
],
|
|
200
|
+
name: 'Approval',
|
|
201
|
+
type: 'event',
|
|
202
|
+
},
|
|
203
|
+
{
|
|
204
|
+
anonymous: false,
|
|
205
|
+
inputs: [
|
|
206
|
+
{
|
|
207
|
+
indexed: true,
|
|
208
|
+
name: 'from',
|
|
209
|
+
type: 'address',
|
|
210
|
+
},
|
|
211
|
+
{
|
|
212
|
+
indexed: true,
|
|
213
|
+
name: 'to',
|
|
214
|
+
type: 'address',
|
|
215
|
+
},
|
|
216
|
+
{
|
|
217
|
+
indexed: false,
|
|
218
|
+
name: 'value',
|
|
219
|
+
type: 'uint256',
|
|
220
|
+
},
|
|
221
|
+
],
|
|
222
|
+
name: 'Transfer',
|
|
223
|
+
type: 'event',
|
|
224
|
+
},
|
|
225
|
+
];
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
export * from './BSEthereum';
|
|
2
2
|
export * from './GhostMarketNDSEthereum';
|
|
3
|
-
export * from './
|
|
3
|
+
export * from './RpcNDSEthereum';
|
|
4
|
+
export * from './BSEthereumHelper';
|
|
4
5
|
export * from './BitqueryBDSEthereum';
|
|
5
|
-
export * from './BitqueryEDSEthereum';
|
|
6
6
|
export * from './RpcBDSEthereum';
|
|
7
|
-
export * from './
|
|
7
|
+
export * from './BitqueryEDSEthereum';
|
|
8
|
+
export * from './EthersLedgerServiceEthereum';
|
package/dist/index.js
CHANGED
|
@@ -16,8 +16,9 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
__exportStar(require("./BSEthereum"), exports);
|
|
18
18
|
__exportStar(require("./GhostMarketNDSEthereum"), exports);
|
|
19
|
-
__exportStar(require("./
|
|
19
|
+
__exportStar(require("./RpcNDSEthereum"), exports);
|
|
20
|
+
__exportStar(require("./BSEthereumHelper"), exports);
|
|
20
21
|
__exportStar(require("./BitqueryBDSEthereum"), exports);
|
|
21
|
-
__exportStar(require("./BitqueryEDSEthereum"), exports);
|
|
22
22
|
__exportStar(require("./RpcBDSEthereum"), exports);
|
|
23
|
-
__exportStar(require("./
|
|
23
|
+
__exportStar(require("./BitqueryEDSEthereum"), exports);
|
|
24
|
+
__exportStar(require("./EthersLedgerServiceEthereum"), exports);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cityofzion/bs-ethereum",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.1",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"types": "dist/index.d.ts",
|
|
6
6
|
"repository": "https://github.com/CityOfZion/blockchain-services",
|
|
@@ -18,14 +18,14 @@
|
|
|
18
18
|
"@ethersproject/json-wallets": "5.7.0",
|
|
19
19
|
"@ethersproject/bytes": "5.7.0",
|
|
20
20
|
"@ethersproject/bignumber": "5.7.0",
|
|
21
|
-
"@ledgerhq/hw-transport-node-hid": "~6.28.5",
|
|
22
21
|
"@ledgerhq/hw-transport": "~6.30.5",
|
|
23
22
|
"@ledgerhq/hw-app-eth": "~6.35.7",
|
|
24
23
|
"@ethersproject/abstract-signer": "~5.7.0",
|
|
25
24
|
"@ethersproject/properties": "~5.7.0",
|
|
26
|
-
"@cityofzion/blockchain-service": "0.
|
|
25
|
+
"@cityofzion/blockchain-service": "1.0.1"
|
|
27
26
|
},
|
|
28
27
|
"devDependencies": {
|
|
28
|
+
"@ledgerhq/hw-transport-node-hid": "~6.28.5",
|
|
29
29
|
"@types/jest": "29.5.3",
|
|
30
30
|
"@typescript-eslint/eslint-plugin": "^6.5.0",
|
|
31
31
|
"@typescript-eslint/parser": "^6.5.0",
|