@cityofzion/bs-ethereum 2.13.3 → 2.13.5

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.
@@ -15,13 +15,23 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
15
15
  }) : function(o, v) {
16
16
  o["default"] = v;
17
17
  });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
25
35
  var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
26
36
  function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
27
37
  return new (P || (P = Promise))(function (resolve, reject) {
@@ -53,9 +63,6 @@ const hw_app_eth_1 = __importStar(require("@ledgerhq/hw-app-eth"));
53
63
  const ethers_1 = require("ethers");
54
64
  const properties_1 = require("@ethersproject/properties");
55
65
  const events_1 = __importDefault(require("events"));
56
- const shouldRetry = (error) => {
57
- return (error === null || error === void 0 ? void 0 : error.id) === 'TransportLocked';
58
- };
59
66
  class EthersLedgerSigner extends ethers_1.Signer {
60
67
  constructor(transport, bip44Path, provider, emitter) {
61
68
  super();
@@ -74,19 +81,21 @@ class EthersLedgerSigner extends ethers_1.Signer {
74
81
  }
75
82
  getAddress() {
76
83
  return __awaiter(this, void 0, void 0, function* () {
77
- const { address } = yield blockchain_service_1.BSUtilsHelper.retry(() => __classPrivateFieldGet(this, _EthersLedgerSigner_ledgerApp, "f").getAddress(__classPrivateFieldGet(this, _EthersLedgerSigner_bip44Path, "f")), { shouldRetry });
84
+ const { address } = yield blockchain_service_1.BSUtilsHelper.retry(() => __classPrivateFieldGet(this, _EthersLedgerSigner_ledgerApp, "f").getAddress(__classPrivateFieldGet(this, _EthersLedgerSigner_bip44Path, "f")), {
85
+ shouldRetry: EthersLedgerSigner.shouldRetry,
86
+ });
78
87
  return address;
79
88
  });
80
89
  }
81
90
  signMessage(message) {
82
- var _a, _b, _c;
83
91
  return __awaiter(this, void 0, void 0, function* () {
92
+ var _a, _b, _c;
84
93
  try {
85
94
  if (typeof message === 'string') {
86
95
  message = ethers_1.ethers.utils.toUtf8Bytes(message);
87
96
  }
88
97
  (_a = __classPrivateFieldGet(this, _EthersLedgerSigner_emitter, "f")) === null || _a === void 0 ? void 0 : _a.emit('getSignatureStart');
89
- const obj = yield blockchain_service_1.BSUtilsHelper.retry(() => __classPrivateFieldGet(this, _EthersLedgerSigner_ledgerApp, "f").signPersonalMessage(__classPrivateFieldGet(this, _EthersLedgerSigner_bip44Path, "f"), ethers_1.ethers.utils.hexlify(message).substring(2)), { shouldRetry });
98
+ const obj = yield blockchain_service_1.BSUtilsHelper.retry(() => __classPrivateFieldGet(this, _EthersLedgerSigner_ledgerApp, "f").signPersonalMessage(__classPrivateFieldGet(this, _EthersLedgerSigner_bip44Path, "f"), ethers_1.ethers.utils.hexlify(message).substring(2)), { shouldRetry: EthersLedgerSigner.shouldRetry });
90
99
  (_b = __classPrivateFieldGet(this, _EthersLedgerSigner_emitter, "f")) === null || _b === void 0 ? void 0 : _b.emit('getSignatureEnd');
91
100
  // Normalize the signature for Ethers
92
101
  obj.r = '0x' + obj.r;
@@ -100,8 +109,8 @@ class EthersLedgerSigner extends ethers_1.Signer {
100
109
  });
101
110
  }
102
111
  signTransaction(transaction) {
103
- var _a, _b, _c;
104
112
  return __awaiter(this, void 0, void 0, function* () {
113
+ var _a, _b, _c;
105
114
  try {
106
115
  const tx = yield ethers_1.ethers.utils.resolveProperties(transaction);
107
116
  const serializedUnsignedTransaction = ethers_1.ethers.utils
@@ -109,7 +118,7 @@ class EthersLedgerSigner extends ethers_1.Signer {
109
118
  .substring(2);
110
119
  const resolution = yield hw_app_eth_1.ledgerService.resolveTransaction(serializedUnsignedTransaction, {}, {});
111
120
  (_a = __classPrivateFieldGet(this, _EthersLedgerSigner_emitter, "f")) === null || _a === void 0 ? void 0 : _a.emit('getSignatureStart');
112
- const signature = yield blockchain_service_1.BSUtilsHelper.retry(() => __classPrivateFieldGet(this, _EthersLedgerSigner_ledgerApp, "f").signTransaction(__classPrivateFieldGet(this, _EthersLedgerSigner_bip44Path, "f"), serializedUnsignedTransaction, resolution), { shouldRetry });
121
+ const signature = yield blockchain_service_1.BSUtilsHelper.retry(() => __classPrivateFieldGet(this, _EthersLedgerSigner_ledgerApp, "f").signTransaction(__classPrivateFieldGet(this, _EthersLedgerSigner_bip44Path, "f"), serializedUnsignedTransaction, resolution), { shouldRetry: EthersLedgerSigner.shouldRetry });
113
122
  (_b = __classPrivateFieldGet(this, _EthersLedgerSigner_emitter, "f")) === null || _b === void 0 ? void 0 : _b.emit('getSignatureEnd');
114
123
  return ethers_1.ethers.utils.serializeTransaction(tx, {
115
124
  v: ethers_1.ethers.BigNumber.from('0x' + signature.v).toNumber(),
@@ -124,8 +133,8 @@ class EthersLedgerSigner extends ethers_1.Signer {
124
133
  });
125
134
  }
126
135
  _signTypedData(domain, types, value) {
127
- var _a, _b, _c;
128
136
  return __awaiter(this, void 0, void 0, function* () {
137
+ var _a, _b, _c;
129
138
  try {
130
139
  const populated = yield ethers_1.ethers.utils._TypedDataEncoder.resolveNames(domain, types, value, (name) => __awaiter(this, void 0, void 0, function* () {
131
140
  if (!this.provider)
@@ -140,13 +149,13 @@ class EthersLedgerSigner extends ethers_1.Signer {
140
149
  let obj;
141
150
  try {
142
151
  obj = yield blockchain_service_1.BSUtilsHelper.retry(() => __classPrivateFieldGet(this, _EthersLedgerSigner_ledgerApp, "f").signEIP712Message(__classPrivateFieldGet(this, _EthersLedgerSigner_bip44Path, "f"), payload), {
143
- shouldRetry,
152
+ shouldRetry: EthersLedgerSigner.shouldRetry,
144
153
  });
145
154
  }
146
155
  catch (_d) {
147
156
  const domainSeparatorHex = ethers_1.ethers.utils._TypedDataEncoder.hashDomain(payload.domain);
148
157
  const hashStructMessageHex = ethers_1.ethers.utils._TypedDataEncoder.hashStruct(payload.primaryType, types, payload.message);
149
- obj = yield blockchain_service_1.BSUtilsHelper.retry(() => __classPrivateFieldGet(this, _EthersLedgerSigner_ledgerApp, "f").signEIP712HashedMessage(__classPrivateFieldGet(this, _EthersLedgerSigner_bip44Path, "f"), domainSeparatorHex, hashStructMessageHex), { shouldRetry });
158
+ obj = yield blockchain_service_1.BSUtilsHelper.retry(() => __classPrivateFieldGet(this, _EthersLedgerSigner_ledgerApp, "f").signEIP712HashedMessage(__classPrivateFieldGet(this, _EthersLedgerSigner_bip44Path, "f"), domainSeparatorHex, hashStructMessageHex), { shouldRetry: EthersLedgerSigner.shouldRetry });
150
159
  }
151
160
  (_b = __classPrivateFieldGet(this, _EthersLedgerSigner_emitter, "f")) === null || _b === void 0 ? void 0 : _b.emit('getSignatureEnd');
152
161
  // Normalize the signature for Ethers
@@ -163,6 +172,9 @@ class EthersLedgerSigner extends ethers_1.Signer {
163
172
  }
164
173
  exports.EthersLedgerSigner = EthersLedgerSigner;
165
174
  _EthersLedgerSigner_transport = new WeakMap(), _EthersLedgerSigner_emitter = new WeakMap(), _EthersLedgerSigner_bip44Path = new WeakMap(), _EthersLedgerSigner_ledgerApp = new WeakMap();
175
+ EthersLedgerSigner.shouldRetry = (error) => {
176
+ return (error === null || error === void 0 ? void 0 : error.id) === 'TransportLocked';
177
+ };
166
178
  class EthersLedgerServiceEthereum {
167
179
  constructor(blockchainService, getLedgerTransport) {
168
180
  _EthersLedgerServiceEthereum_blockchainService.set(this, void 0);
@@ -183,7 +195,9 @@ class EthersLedgerServiceEthereum {
183
195
  return __awaiter(this, void 0, void 0, function* () {
184
196
  const ledgerApp = new hw_app_eth_1.default(transport);
185
197
  const bip44Path = __classPrivateFieldGet(this, _EthersLedgerServiceEthereum_blockchainService, "f").bip44DerivationPath.replace('?', index.toString());
186
- const { publicKey, address } = yield blockchain_service_1.BSUtilsHelper.retry(() => ledgerApp.getAddress(bip44Path), { shouldRetry });
198
+ const { publicKey, address } = yield blockchain_service_1.BSUtilsHelper.retry(() => ledgerApp.getAddress(bip44Path), {
199
+ shouldRetry: EthersLedgerSigner.shouldRetry,
200
+ });
187
201
  const publicKeyWithPrefix = '0x' + publicKey;
188
202
  return {
189
203
  address,
@@ -1,12 +1,9 @@
1
- import { NftResponse, NftsResponse, GetNftParam, GetNftsByAddressParams, Network, NetworkId } from '@cityofzion/blockchain-service';
2
- import { RpcNDSEthereum } from './RpcNDSEthereum';
3
- import { BSEthereumNetworkId } from '../../constants/BSEthereumConstants';
4
- export declare class GhostMarketNDSEthereum<BSNetworkId extends NetworkId = BSEthereumNetworkId> extends RpcNDSEthereum {
5
- #private;
6
- constructor(network: Network<BSNetworkId>, ghostMarketChainByNetworkId?: Partial<Record<BSNetworkId, string>>);
7
- getNftsByAddress({ address, size, cursor }: GetNftsByAddressParams): Promise<NftsResponse>;
8
- getNft({ collectionHash, tokenHash }: GetNftParam): Promise<NftResponse>;
9
- private treatGhostMarketImage;
10
- private getUrlWithParams;
11
- private parse;
1
+ import { TBSNetworkId, GhostMarketNDS, THasTokenParam } from '@cityofzion/blockchain-service';
2
+ import { IBSEthereum, TBSEthereumNetworkId } from '../../types';
3
+ export declare class GhostMarketNDSEthereum<N extends string, A extends TBSNetworkId> extends GhostMarketNDS {
4
+ static readonly CHAIN_BY_NETWORK_ID: Partial<Record<TBSEthereumNetworkId, string>>;
5
+ _service: IBSEthereum<N, A>;
6
+ constructor(service: IBSEthereum<N, A>);
7
+ hasToken({ collectionHash, address }: THasTokenParam): Promise<boolean>;
8
+ getChain(): string;
12
9
  }
@@ -8,104 +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 __importDefault = (this && this.__importDefault) || function (mod) {
23
- return (mod && mod.__esModule) ? mod : { "default": mod };
24
- };
25
- var _GhostMarketNDSEthereum_network, _GhostMarketNDSEthereum_ghostMarketChainByNetworkId;
26
11
  Object.defineProperty(exports, "__esModule", { value: true });
27
12
  exports.GhostMarketNDSEthereum = void 0;
28
- const query_string_1 = __importDefault(require("query-string"));
29
- const axios_1 = __importDefault(require("axios"));
30
- const RpcNDSEthereum_1 = require("./RpcNDSEthereum");
31
- const BSEthereumConstants_1 = require("../../constants/BSEthereumConstants");
32
- const BASE_URL = 'https://api.ghostmarket.io/api/v2';
33
- const GHOSTMARKET_CHAIN_BY_NETWORK_ID = {
34
- [BSEthereumConstants_1.BSEthereumConstants.ETHEREUM_MAINNET_NETWORK_ID]: 'eth',
35
- '56': 'bsc',
36
- [BSEthereumConstants_1.BSEthereumConstants.POLYGON_MAINNET_NETWORK_ID]: 'polygon',
37
- '43114': 'avalanche',
38
- [BSEthereumConstants_1.BSEthereumConstants.BASE_MAINNET_NETWORK_ID]: 'base',
39
- };
40
- class GhostMarketNDSEthereum extends RpcNDSEthereum_1.RpcNDSEthereum {
41
- constructor(network, ghostMarketChainByNetworkId) {
42
- super(network);
43
- _GhostMarketNDSEthereum_network.set(this, void 0);
44
- _GhostMarketNDSEthereum_ghostMarketChainByNetworkId.set(this, void 0);
45
- __classPrivateFieldSet(this, _GhostMarketNDSEthereum_network, network, "f");
46
- __classPrivateFieldSet(this, _GhostMarketNDSEthereum_ghostMarketChainByNetworkId, ghostMarketChainByNetworkId !== null && ghostMarketChainByNetworkId !== void 0 ? ghostMarketChainByNetworkId : GHOSTMARKET_CHAIN_BY_NETWORK_ID, "f");
13
+ const blockchain_service_1 = require("@cityofzion/blockchain-service");
14
+ const ethers_1 = require("ethers");
15
+ const ERC20_1 = require("../../assets/abis/ERC20");
16
+ class GhostMarketNDSEthereum extends blockchain_service_1.GhostMarketNDS {
17
+ constructor(service) {
18
+ super();
19
+ this._service = service;
47
20
  }
48
- getNftsByAddress({ address, size = 18, cursor }) {
49
- var _a;
50
- return __awaiter(this, void 0, void 0, function* () {
51
- const url = this.getUrlWithParams({
52
- size,
53
- owners: [address],
54
- cursor: cursor,
55
- });
56
- const request = yield axios_1.default.get(url);
57
- const nfts = (_a = request.data.assets) !== null && _a !== void 0 ? _a : [];
58
- return { nextCursor: request.data.next, items: nfts.map(this.parse.bind(this)) };
21
+ hasToken(_a) {
22
+ return __awaiter(this, arguments, void 0, function* ({ collectionHash, address }) {
23
+ try {
24
+ const provider = new ethers_1.ethers.providers.JsonRpcProvider(this._service.network.url);
25
+ const contract = new ethers_1.ethers.Contract(collectionHash, ERC20_1.ERC20_ABI, provider);
26
+ const response = yield contract.balanceOf(address);
27
+ if (!response)
28
+ throw new Error();
29
+ const parsedResponse = response;
30
+ return parsedResponse.gt(0);
31
+ }
32
+ catch (_b) {
33
+ throw new Error(`Token not found: ${collectionHash}`);
34
+ }
59
35
  });
60
36
  }
61
- getNft({ collectionHash, tokenHash }) {
62
- return __awaiter(this, void 0, void 0, function* () {
63
- const url = this.getUrlWithParams({
64
- contract: collectionHash,
65
- tokenIds: [tokenHash],
66
- });
67
- const request = yield axios_1.default.get(url);
68
- return this.parse(request.data.assets[0]);
69
- });
70
- }
71
- treatGhostMarketImage(srcImage) {
72
- if (!srcImage) {
73
- return;
74
- }
75
- if (srcImage.startsWith('ipfs://')) {
76
- const splitImage = srcImage.split('/');
77
- const imageId = splitImage.slice(-2).filter(Boolean).join('/');
78
- return `https://ghostmarket.mypinata.cloud/ipfs/${imageId}`;
79
- }
80
- return srcImage;
81
- }
82
- getUrlWithParams(params) {
83
- const chain = __classPrivateFieldGet(this, _GhostMarketNDSEthereum_ghostMarketChainByNetworkId, "f")[__classPrivateFieldGet(this, _GhostMarketNDSEthereum_network, "f").id];
37
+ getChain() {
38
+ const chain = GhostMarketNDSEthereum.CHAIN_BY_NETWORK_ID[this._service.network.id];
84
39
  if (!chain)
85
- throw new Error('Unsupported network');
86
- const parameters = query_string_1.default.stringify(Object.assign({ chain, ownersChains: [chain] }, params), { arrayFormat: 'bracket' });
87
- return `${BASE_URL}/assets?${parameters}`;
88
- }
89
- parse(data) {
90
- var _a, _b;
91
- const nftResponse = {
92
- hash: data.tokenId,
93
- collection: {
94
- hash: data.contract.hash,
95
- name: (_a = data.collection) === null || _a === void 0 ? void 0 : _a.name,
96
- image: this.treatGhostMarketImage((_b = data.collection) === null || _b === void 0 ? void 0 : _b.logoUrl),
97
- },
98
- symbol: data.contract.symbol,
99
- image: this.treatGhostMarketImage(data.metadata.mediaUri),
100
- isSVG: String(data.metadata.mediaType).includes('svg+xml'),
101
- name: data.metadata.name,
102
- creator: {
103
- address: data.creator.address,
104
- name: data.creator.offchainName,
105
- },
106
- };
107
- return nftResponse;
40
+ throw new Error('Network not supported');
41
+ return chain;
108
42
  }
109
43
  }
110
44
  exports.GhostMarketNDSEthereum = GhostMarketNDSEthereum;
111
- _GhostMarketNDSEthereum_network = new WeakMap(), _GhostMarketNDSEthereum_ghostMarketChainByNetworkId = new WeakMap();
45
+ GhostMarketNDSEthereum.CHAIN_BY_NETWORK_ID = {
46
+ '1': 'eth',
47
+ '56': 'bsc',
48
+ '137': 'polygon',
49
+ '43114': 'avalanche',
50
+ '8453': 'base',
51
+ };
@@ -0,0 +1,83 @@
1
+ import { IBlockchainService, IBSWithEncryption, IBSWithExplorer, IBSWithFee, IBSWithLedger, IBSWithNameService, IBSWithNft, TBSNetworkId } from '@cityofzion/blockchain-service';
2
+ export type TBSEthereumNetworkId = TBSNetworkId<'1' | '10' | '25' | '56' | '137' | '250' | '1101' | '8453' | '80002' | '42161' | '42220' | '43114' | '59144' | '11155111'>;
3
+ export type TSupportedEVM = 'ethereum' | 'polygon' | 'base' | 'arbitrum';
4
+ export interface IBSEthereum<N extends string = string, A extends string = TBSEthereumNetworkId> extends IBlockchainService<N, A>, IBSWithNft, IBSWithNameService, IBSWithFee<N>, IBSWithLedger<N>, IBSWithExplorer, IBSWithEncryption<N> {
5
+ }
6
+ export type TMoralisBDSEthereumNativeBalanceApiResponse = {
7
+ balance: string;
8
+ };
9
+ export type TMoralisBDSEthereumERC20BalanceApiResponse = {
10
+ token_address: string;
11
+ name: string;
12
+ symbol: string;
13
+ decimals: number;
14
+ balance: string;
15
+ possible_spam: boolean;
16
+ };
17
+ export type TMoralisBDSEthereumERC20MetadataApiResponse = {
18
+ name: string;
19
+ symbol: string;
20
+ decimals: string;
21
+ };
22
+ export type TMoralisBDSEthereumTransactionApiResponse = {
23
+ from_address: string;
24
+ to_address: string;
25
+ value: string;
26
+ transaction_fee: string;
27
+ block_timestamp: string;
28
+ block_number: string;
29
+ logs: {
30
+ address: string;
31
+ decoded_event: {
32
+ label: string;
33
+ params: {
34
+ name: string;
35
+ value: string;
36
+ type: string;
37
+ }[];
38
+ };
39
+ }[];
40
+ };
41
+ export type TMoralisWalletHistoryApiResponse = {
42
+ cursor?: string;
43
+ result: {
44
+ hash: string;
45
+ transaction_fee: string;
46
+ block_timestamp: string;
47
+ block_number: string;
48
+ nft_transfers: {
49
+ token_address: string;
50
+ token_id: string;
51
+ from_address: string;
52
+ to_address: string;
53
+ possible_spam: boolean;
54
+ }[];
55
+ erc20_transfers: {
56
+ token_name: string;
57
+ token_symbol: string;
58
+ token_decimals: string;
59
+ address: string;
60
+ to_address: string;
61
+ from_address: string;
62
+ value: string;
63
+ possible_spam: boolean;
64
+ verified_contract: boolean;
65
+ }[];
66
+ native_transfers: {
67
+ from_address: string;
68
+ to_address: string;
69
+ value: string;
70
+ }[];
71
+ }[];
72
+ };
73
+ export type TMoralisTokenMetadataApiResponse = {
74
+ name: string;
75
+ };
76
+ export type TMoralisEDSEthereumERC20PriceApiResponse = {
77
+ tokenName: string;
78
+ tokenSymbol: string;
79
+ tokenDecimals: string;
80
+ usdPrice: number;
81
+ tokenAddress: string;
82
+ blockTimestamp: string;
83
+ };
package/dist/types.js ADDED
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cityofzion/bs-ethereum",
3
- "version": "2.13.3",
3
+ "version": "2.13.5",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "repository": "https://github.com/CityOfZion/blockchain-services",
@@ -10,36 +10,34 @@
10
10
  "/dist"
11
11
  ],
12
12
  "dependencies": {
13
- "axios": "1.8.2",
13
+ "axios": "~1.12.2",
14
14
  "ethers": "5.7.2",
15
- "query-string": "7.1.3",
16
15
  "@ethersproject/json-wallets": "5.7.0",
17
16
  "@ethersproject/bytes": "5.7.0",
18
17
  "@ethersproject/bignumber": "5.7.0",
19
- "@ledgerhq/hw-transport": "~6.31.8",
20
- "@ledgerhq/hw-app-eth": "~6.45.14",
21
- "@ethersproject/abstract-signer": "~5.7.0",
22
- "@ethersproject/properties": "~5.7.0",
23
- "@cityofzion/dora-ts": "0.5.1",
24
- "date-fns": "~4.1.0",
25
- "@cityofzion/blockchain-service": "1.21.2"
18
+ "@ledgerhq/hw-app-eth": "~6.45.19",
19
+ "@ethersproject/abstract-signer": "5.7.0",
20
+ "@ethersproject/properties": "5.7.0",
21
+ "@cityofzion/dora-ts": "~0.5.1",
22
+ "@cityofzion/blockchain-service": "1.21.3"
26
23
  },
27
24
  "devDependencies": {
28
- "@ledgerhq/hw-transport-node-hid": "~6.28.5",
29
- "@types/jest": "29.5.3",
30
- "@typescript-eslint/eslint-plugin": "^6.5.0",
31
- "@typescript-eslint/parser": "^6.5.0",
32
- "dotenv": "16.3.1",
33
- "eslint": "^8.48.0",
34
- "jest": "29.6.2",
35
- "ts-jest": "~29.4.0",
25
+ "@ledgerhq/hw-transport": "~6.31.11",
26
+ "@ledgerhq/hw-transport-node-hid": "~6.29.12",
27
+ "@types/jest": "~30.0.0",
28
+ "date-fns": "~4.1.0",
29
+ "dotenv": "~17.2.2",
30
+ "eslint": "~9.36.0",
31
+ "jest": "~30.1.3",
32
+ "ts-jest": "~29.4.4",
36
33
  "ts-node": "~10.9.2",
37
- "typescript": "4.9.5"
34
+ "typescript": "~5.9.2"
38
35
  },
39
36
  "scripts": {
40
- "build": "tsc --project tsconfig.build.json",
41
- "test": "jest --config jest.config.ts",
37
+ "build": "rm -rf ./dist && tsc --project tsconfig.build.json",
38
+ "test": "jest -i --config jest.config.ts",
42
39
  "lint": "eslint .",
43
- "format": "eslint --fix"
40
+ "format": "eslint --fix",
41
+ "package": "npm run build && npm pack"
44
42
  }
45
43
  }
@@ -1,12 +0,0 @@
1
- import { RpcBDSEthereum } from './RpcBDSEthereum';
2
- import { FullTransactionsByAddressParams, Network, NetworkId, TokenService } from '@cityofzion/blockchain-service';
3
- import { BSEthereumNetworkId } from '../../constants/BSEthereumConstants';
4
- export declare class DoraBDSEthereum<BSNetworkId extends NetworkId = BSEthereumNetworkId> extends RpcBDSEthereum {
5
- readonly _supportedErc721Standards: string[];
6
- readonly _supportedErc1155Standards: string[];
7
- readonly _supportedErc20Standards: string[];
8
- readonly _supportedFullTransactionsByAddressNetworks: BSNetworkId[];
9
- constructor(network: Network<BSNetworkId>, supportedFullTransactionsByAddressNetworks: BSNetworkId[], tokenService: TokenService);
10
- _validateFullTransactionsByAddressParams(params: Pick<FullTransactionsByAddressParams, 'address' | 'dateFrom' | 'dateTo'>): void;
11
- _validateGetFullTransactionsByAddressParams({ pageSize, ...params }: Pick<FullTransactionsByAddressParams, 'address' | 'dateFrom' | 'dateTo' | 'pageSize'>): void;
12
- }
@@ -1,40 +0,0 @@
1
- "use strict";
2
- var __rest = (this && this.__rest) || function (s, e) {
3
- var t = {};
4
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
5
- t[p] = s[p];
6
- if (s != null && typeof Object.getOwnPropertySymbols === "function")
7
- for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
8
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
9
- t[p[i]] = s[p[i]];
10
- }
11
- return t;
12
- };
13
- Object.defineProperty(exports, "__esModule", { value: true });
14
- exports.DoraBDSEthereum = void 0;
15
- const RpcBDSEthereum_1 = require("./RpcBDSEthereum");
16
- const blockchain_service_1 = require("@cityofzion/blockchain-service");
17
- const ethers_1 = require("ethers");
18
- class DoraBDSEthereum extends RpcBDSEthereum_1.RpcBDSEthereum {
19
- constructor(network, supportedFullTransactionsByAddressNetworks, tokenService) {
20
- super(network, tokenService);
21
- this._supportedErc721Standards = ['erc721', 'erc-721'];
22
- this._supportedErc1155Standards = ['erc1155', 'erc-1155'];
23
- this._supportedErc20Standards = ['erc20', 'erc-20'];
24
- this._supportedFullTransactionsByAddressNetworks = supportedFullTransactionsByAddressNetworks;
25
- }
26
- _validateFullTransactionsByAddressParams(params) {
27
- if (!this._supportedFullTransactionsByAddressNetworks.includes(this._network.id))
28
- throw new Error('This network is not supported');
29
- blockchain_service_1.BSFullTransactionsByAddressHelper.validateFullTransactionsByAddressParams(params);
30
- if (!ethers_1.ethers.utils.isAddress(params.address))
31
- throw new Error('Invalid address param');
32
- }
33
- _validateGetFullTransactionsByAddressParams(_a) {
34
- var { pageSize } = _a, params = __rest(_a, ["pageSize"]);
35
- if (typeof pageSize === 'number' && (isNaN(pageSize) || pageSize < 1 || pageSize > 500))
36
- throw new Error('Page size should be between 1 and 500');
37
- this._validateFullTransactionsByAddressParams(params);
38
- }
39
- }
40
- exports.DoraBDSEthereum = DoraBDSEthereum;
@@ -1,8 +0,0 @@
1
- import { GetNftParam, GetNftsByAddressParams, HasTokenParam, Network, NftDataService, NftResponse, NftsResponse } from '@cityofzion/blockchain-service';
2
- export declare abstract class RpcNDSEthereum implements NftDataService {
3
- #private;
4
- protected constructor(network: Network);
5
- abstract getNftsByAddress(params: GetNftsByAddressParams): Promise<NftsResponse>;
6
- abstract getNft(params: GetNftParam): Promise<NftResponse>;
7
- hasToken({ collectionHash, address }: HasTokenParam): Promise<boolean>;
8
- }
@@ -1,50 +0,0 @@
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
- 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 _RpcNDSEthereum_network;
23
- Object.defineProperty(exports, "__esModule", { value: true });
24
- exports.RpcNDSEthereum = void 0;
25
- const ethers_1 = require("ethers");
26
- const ERC20_1 = require("../../assets/abis/ERC20");
27
- class RpcNDSEthereum {
28
- constructor(network) {
29
- _RpcNDSEthereum_network.set(this, void 0);
30
- __classPrivateFieldSet(this, _RpcNDSEthereum_network, network, "f");
31
- }
32
- hasToken({ collectionHash, address }) {
33
- return __awaiter(this, void 0, void 0, function* () {
34
- try {
35
- const provider = new ethers_1.ethers.providers.JsonRpcProvider(__classPrivateFieldGet(this, _RpcNDSEthereum_network, "f").url);
36
- const contract = new ethers_1.ethers.Contract(collectionHash, ERC20_1.ERC20_ABI, provider);
37
- const response = yield contract.balanceOf(address);
38
- if (!response)
39
- throw new Error();
40
- const parsedResponse = response;
41
- return parsedResponse.gt(0);
42
- }
43
- catch (_a) {
44
- throw new Error(`Token not found: ${collectionHash}`);
45
- }
46
- });
47
- }
48
- }
49
- exports.RpcNDSEthereum = RpcNDSEthereum;
50
- _RpcNDSEthereum_network = new WeakMap();