@cityofzion/bs-neox 3.1.3 → 3.1.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.
- package/dist/BSNeoX.d.ts +8 -7
- package/dist/BSNeoX.js +23 -27
- package/dist/constants/BSNeoXConstants.js +1 -1
- package/dist/helpers/BSNeoXHelper.d.ts +0 -1
- package/dist/helpers/BSNeoXHelper.js +0 -4
- package/dist/services/blockchain-data/BlockscoutBDSNeoX.d.ts +5 -5
- package/dist/services/blockchain-data/BlockscoutBDSNeoX.js +7 -50
- package/dist/services/exchange-data/FlamingoForthewinEDSNeoX.d.ts +3 -3
- package/dist/services/exchange-data/FlamingoForthewinEDSNeoX.js +2 -3
- package/dist/services/explorer/BlockscoutESNeoX.d.ts +3 -3
- package/dist/services/full-transactions-data/BlockscoutFullTransactionsDataService.d.ts +3 -4
- package/dist/services/full-transactions-data/BlockscoutFullTransactionsDataService.js +5 -9
- package/dist/services/neo3-neox-bridge/Neo3NeoXBridgeService.d.ts +14 -12
- package/dist/services/neo3-neox-bridge/Neo3NeoXBridgeService.js +38 -6
- package/dist/services/nft-data/GhostMarketNDSNeoX.d.ts +3 -3
- package/dist/services/wallet-connect/WalletConnectServiceNeoX.d.ts +8 -7
- package/dist/services/wallet-connect/WalletConnectServiceNeoX.js +2 -2
- package/dist/types.d.ts +5 -2
- package/package.json +5 -5
package/dist/BSNeoX.d.ts
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import { BSEthereum } from '@cityofzion/bs-ethereum';
|
|
2
|
-
import { type
|
|
3
|
-
import
|
|
4
|
-
|
|
5
|
-
|
|
2
|
+
import { type TBSNetwork, type TGetLedgerTransport, type TTransactionDefault, type TTransferParams } from '@cityofzion/blockchain-service';
|
|
3
|
+
import { Neo3NeoXBridgeService } from './services/neo3-neox-bridge/Neo3NeoXBridgeService';
|
|
4
|
+
import type { IBSNeoX, TBSNeoXName, TBSNeoXNetworkId, TSendTransactionParams, TSendTransactionResponse } from './types';
|
|
5
|
+
export declare class BSNeoX extends BSEthereum<TBSNeoXName, TBSNeoXNetworkId> implements IBSNeoX {
|
|
6
|
+
neo3NeoXBridgeService: Neo3NeoXBridgeService;
|
|
6
7
|
readonly defaultNetwork: TBSNetwork<TBSNeoXNetworkId>;
|
|
7
8
|
readonly availableNetworks: TBSNetwork<TBSNeoXNetworkId>[];
|
|
8
|
-
constructor(
|
|
9
|
+
constructor(network?: TBSNetwork<TBSNeoXNetworkId>, getLedgerTransport?: TGetLedgerTransport<TBSNeoXName>);
|
|
10
|
+
_sendTransaction({ signer, gasPrice, params }: TSendTransactionParams): Promise<TSendTransactionResponse>;
|
|
9
11
|
setNetwork(network: TBSNetwork<TBSNeoXNetworkId>): void;
|
|
10
|
-
|
|
11
|
-
transfer({ senderAccount, intents }: TTransferParams<N>): Promise<TTransactionDefault<N>[]>;
|
|
12
|
+
transfer({ senderAccount, intents }: TTransferParams<TBSNeoXName>): Promise<TTransactionDefault[]>;
|
|
12
13
|
}
|
package/dist/BSNeoX.js
CHANGED
|
@@ -22,33 +22,15 @@ const viem_1 = require("viem");
|
|
|
22
22
|
const BlockscoutFullTransactionsDataService_1 = require("./services/full-transactions-data/BlockscoutFullTransactionsDataService");
|
|
23
23
|
const BSNeoXHelper_1 = require("./helpers/BSNeoXHelper");
|
|
24
24
|
class BSNeoX extends bs_ethereum_1.BSEthereum {
|
|
25
|
-
constructor(
|
|
26
|
-
super(
|
|
25
|
+
constructor(network, getLedgerTransport) {
|
|
26
|
+
super('neox', undefined, getLedgerTransport);
|
|
27
27
|
this.nativeTokens = [BSNeoXConstants_1.BSNeoXConstants.NATIVE_ASSET];
|
|
28
28
|
this.feeToken = BSNeoXConstants_1.BSNeoXConstants.NATIVE_ASSET;
|
|
29
29
|
this.availableNetworks = BSNeoXConstants_1.BSNeoXConstants.ALL_NETWORKS;
|
|
30
30
|
this.defaultNetwork = BSNeoXConstants_1.BSNeoXConstants.MAINNET_NETWORK;
|
|
31
31
|
this.setNetwork(network || this.defaultNetwork);
|
|
32
32
|
}
|
|
33
|
-
|
|
34
|
-
const networkUrls = BSNeoXConstants_1.BSNeoXConstants.RPC_LIST_BY_NETWORK_ID[network.id] || [];
|
|
35
|
-
const isValidNetwork = blockchain_service_1.BSUtilsHelper.validateNetwork(network, this.availableNetworks, networkUrls);
|
|
36
|
-
if (!isValidNetwork) {
|
|
37
|
-
throw new blockchain_service_1.BSError(`Network with id ${network.id} is not available for ${this.name}`, 'INVALID_NETWORK');
|
|
38
|
-
}
|
|
39
|
-
this.network = network;
|
|
40
|
-
this.networkUrls = networkUrls;
|
|
41
|
-
this.tokens = [BSNeoXConstants_1.BSNeoXConstants.NATIVE_ASSET, BSNeoXHelper_1.BSNeoXHelper.getNeoToken(this.network)];
|
|
42
|
-
this.nftDataService = new GhostMarketNDSNeoX_1.GhostMarketNDSNeoX(this);
|
|
43
|
-
this.explorerService = new BlockscoutESNeoX_1.BlockscoutESNeoX(this);
|
|
44
|
-
this.exchangeDataService = new FlamingoForthewinEDSNeoX_1.FlamingoForthewinEDSNeoX(this);
|
|
45
|
-
this.neo3NeoXBridgeService = new Neo3NeoXBridgeService_1.Neo3NeoXBridgeService(this);
|
|
46
|
-
this.blockchainDataService = new BlockscoutBDSNeoX_1.BlockscoutBDSNeoX(this);
|
|
47
|
-
this.tokenService = new bs_ethereum_1.TokenServiceEthereum();
|
|
48
|
-
this.walletConnectService = new WalletConnectServiceNeoX_1.WalletConnectServiceNeoX(this);
|
|
49
|
-
this.fullTransactionsDataService = new BlockscoutFullTransactionsDataService_1.BlockscoutFullTransactionsDataService(this);
|
|
50
|
-
}
|
|
51
|
-
async sendTransaction({ signer, gasPrice, params }) {
|
|
33
|
+
async _sendTransaction({ signer, gasPrice, params }) {
|
|
52
34
|
const chainId = parseInt(this.network.id);
|
|
53
35
|
if (isNaN(chainId)) {
|
|
54
36
|
throw new Error('Invalid chainId');
|
|
@@ -130,27 +112,42 @@ class BSNeoX extends bs_ethereum_1.BSEthereum {
|
|
|
130
112
|
throw secondTransactionError || new Error('Transaction error');
|
|
131
113
|
return { transactionHash, fee };
|
|
132
114
|
}
|
|
115
|
+
setNetwork(network) {
|
|
116
|
+
const networkUrls = BSNeoXConstants_1.BSNeoXConstants.RPC_LIST_BY_NETWORK_ID[network.id] || [];
|
|
117
|
+
const isValidNetwork = blockchain_service_1.BSUtilsHelper.validateNetwork(network, this.availableNetworks, networkUrls);
|
|
118
|
+
if (!isValidNetwork) {
|
|
119
|
+
throw new blockchain_service_1.BSError(`Network with id ${network.id} is not available for ${this.name}`, 'INVALID_NETWORK');
|
|
120
|
+
}
|
|
121
|
+
this.network = network;
|
|
122
|
+
this.networkUrls = networkUrls;
|
|
123
|
+
this.tokens = [BSNeoXConstants_1.BSNeoXConstants.NATIVE_ASSET, BSNeoXHelper_1.BSNeoXHelper.getNeoToken(this.network)];
|
|
124
|
+
this.nftDataService = new GhostMarketNDSNeoX_1.GhostMarketNDSNeoX(this);
|
|
125
|
+
this.explorerService = new BlockscoutESNeoX_1.BlockscoutESNeoX(this);
|
|
126
|
+
this.exchangeDataService = new FlamingoForthewinEDSNeoX_1.FlamingoForthewinEDSNeoX(this);
|
|
127
|
+
this.neo3NeoXBridgeService = new Neo3NeoXBridgeService_1.Neo3NeoXBridgeService(this);
|
|
128
|
+
this.blockchainDataService = new BlockscoutBDSNeoX_1.BlockscoutBDSNeoX(this);
|
|
129
|
+
this.tokenService = new bs_ethereum_1.TokenServiceEthereum(this);
|
|
130
|
+
this.walletConnectService = new WalletConnectServiceNeoX_1.WalletConnectServiceNeoX(this);
|
|
131
|
+
this.fullTransactionsDataService = new BlockscoutFullTransactionsDataService_1.BlockscoutFullTransactionsDataService(this);
|
|
132
|
+
}
|
|
133
133
|
async transfer({ senderAccount, intents }) {
|
|
134
|
-
const signer = await this.
|
|
134
|
+
const signer = await this._generateSigner(senderAccount);
|
|
135
135
|
const { address } = senderAccount;
|
|
136
136
|
const addressUrl = this.explorerService.buildAddressUrl(address);
|
|
137
|
-
const nativeTokenHash = BSNeoXConstants_1.BSNeoXConstants.NATIVE_ASSET.hash;
|
|
138
137
|
const transactions = [];
|
|
139
138
|
let error;
|
|
140
139
|
for (const intent of intents) {
|
|
141
140
|
try {
|
|
142
141
|
const { transactionParams, gasPrice } = await this._buildTransferParams(intent);
|
|
143
|
-
const { transactionHash, fee } = await this.
|
|
142
|
+
const { transactionHash, fee } = await this._sendTransaction({ signer, gasPrice, params: transactionParams });
|
|
144
143
|
if (transactionHash) {
|
|
145
144
|
const { receiverAddress, token } = intent;
|
|
146
145
|
const tokenHash = token.hash;
|
|
147
|
-
const isNativeToken = this.tokenService.predicateByHash(nativeTokenHash, tokenHash);
|
|
148
146
|
transactions.push({
|
|
149
147
|
txId: transactionHash,
|
|
150
148
|
txIdUrl: this.explorerService.buildTransactionUrl(transactionHash),
|
|
151
149
|
date: new Date().toJSON(),
|
|
152
150
|
networkFeeAmount: fee,
|
|
153
|
-
type: 'default',
|
|
154
151
|
view: 'default',
|
|
155
152
|
events: [
|
|
156
153
|
{
|
|
@@ -161,7 +158,6 @@ class BSNeoX extends bs_ethereum_1.BSEthereum {
|
|
|
161
158
|
fromUrl: addressUrl,
|
|
162
159
|
to: receiverAddress,
|
|
163
160
|
toUrl: this.explorerService.buildAddressUrl(receiverAddress),
|
|
164
|
-
tokenType: isNativeToken ? 'native' : 'erc-20',
|
|
165
161
|
tokenUrl: this.explorerService.buildContractUrl(tokenHash),
|
|
166
162
|
token,
|
|
167
163
|
},
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { TBSNetwork } from '@cityofzion/blockchain-service';
|
|
2
2
|
import type { TBSNeoXNetworkId } from '../types';
|
|
3
3
|
export declare class BSNeoXHelper {
|
|
4
|
-
static isMainnetNetwork(network: TBSNetwork<TBSNeoXNetworkId>): boolean;
|
|
5
4
|
static getNeoToken(network: TBSNetwork<TBSNeoXNetworkId>): {
|
|
6
5
|
name: string;
|
|
7
6
|
symbol: string;
|
|
@@ -2,11 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.BSNeoXHelper = void 0;
|
|
4
4
|
const blockchain_service_1 = require("@cityofzion/blockchain-service");
|
|
5
|
-
const BSNeoXConstants_1 = require("../constants/BSNeoXConstants");
|
|
6
5
|
class BSNeoXHelper {
|
|
7
|
-
static isMainnetNetwork(network) {
|
|
8
|
-
return network.id === BSNeoXConstants_1.BSNeoXConstants.MAINNET_NETWORK.id && network.type === 'mainnet';
|
|
9
|
-
}
|
|
10
6
|
static getNeoToken(network) {
|
|
11
7
|
if (network.type === 'custom') {
|
|
12
8
|
throw new blockchain_service_1.BSError('Invalid network', 'INVALID_NETWORK');
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import { type TBalanceResponse, type TBSNetwork, type TBSToken, type TGetTransactionsByAddressParams, type TGetTransactionsByAddressResponse, type TContractResponse, type TTransactionDefault } from '@cityofzion/blockchain-service';
|
|
2
2
|
import axios from 'axios';
|
|
3
3
|
import { RpcBDSEthereum } from '@cityofzion/bs-ethereum';
|
|
4
|
-
import type { IBSNeoX, TBSNeoXNetworkId } from '../../types';
|
|
5
|
-
export declare class BlockscoutBDSNeoX
|
|
4
|
+
import type { IBSNeoX, TBSNeoXName, TBSNeoXNetworkId } from '../../types';
|
|
5
|
+
export declare class BlockscoutBDSNeoX extends RpcBDSEthereum<TBSNeoXName, TBSNeoXNetworkId, IBSNeoX> {
|
|
6
6
|
#private;
|
|
7
7
|
static readonly BASE_URL_BY_CHAIN_ID: Partial<Record<TBSNeoXNetworkId, string>>;
|
|
8
8
|
static getClient(network: TBSNetwork<TBSNeoXNetworkId>): axios.AxiosInstance;
|
|
9
9
|
readonly maxTimeToConfirmTransactionInMs: number;
|
|
10
|
-
constructor(service: IBSNeoX
|
|
11
|
-
getTransaction(txid: string): Promise<TTransactionDefault
|
|
12
|
-
getTransactionsByAddress(params: TGetTransactionsByAddressParams): Promise<TGetTransactionsByAddressResponse<
|
|
10
|
+
constructor(service: IBSNeoX);
|
|
11
|
+
getTransaction(txid: string): Promise<TTransactionDefault>;
|
|
12
|
+
getTransactionsByAddress(params: TGetTransactionsByAddressParams): Promise<TGetTransactionsByAddressResponse<TTransactionDefault>>;
|
|
13
13
|
getContract(contractHash: string): Promise<TContractResponse>;
|
|
14
14
|
getTokenInfo(tokenHash: string): Promise<TBSToken>;
|
|
15
15
|
getBalance(address: string): Promise<TBalanceResponse[]>;
|
|
@@ -7,7 +7,7 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
|
|
|
7
7
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
8
8
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
9
9
|
};
|
|
10
|
-
var _BlockscoutBDSNeoX_instances, _a, _BlockscoutBDSNeoX_apiInstance, _BlockscoutBDSNeoX_api_get
|
|
10
|
+
var _BlockscoutBDSNeoX_instances, _a, _BlockscoutBDSNeoX_apiInstance, _BlockscoutBDSNeoX_api_get;
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
exports.BlockscoutBDSNeoX = void 0;
|
|
13
13
|
const blockchain_service_1 = require("@cityofzion/blockchain-service");
|
|
@@ -15,9 +15,6 @@ const axios_1 = __importDefault(require("axios"));
|
|
|
15
15
|
const ethers_1 = require("ethers");
|
|
16
16
|
const bs_ethereum_1 = require("@cityofzion/bs-ethereum");
|
|
17
17
|
const BSNeoXConstants_1 = require("../../constants/BSNeoXConstants");
|
|
18
|
-
const bridge_1 = require("../../assets/abis/bridge");
|
|
19
|
-
const Neo3NeoXBridgeService_1 = require("../neo3-neox-bridge/Neo3NeoXBridgeService");
|
|
20
|
-
const bs_neo3_1 = require("@cityofzion/bs-neo3");
|
|
21
18
|
class BlockscoutBDSNeoX extends bs_ethereum_1.RpcBDSEthereum {
|
|
22
19
|
static getClient(network) {
|
|
23
20
|
const baseURL = _a.BASE_URL_BY_CHAIN_ID[network.id];
|
|
@@ -37,7 +34,6 @@ class BlockscoutBDSNeoX extends bs_ethereum_1.RpcBDSEthereum {
|
|
|
37
34
|
throw new Error('Transaction not found');
|
|
38
35
|
}
|
|
39
36
|
const nativeToken = BSNeoXConstants_1.BSNeoXConstants.NATIVE_ASSET;
|
|
40
|
-
const to = response.to?.hash;
|
|
41
37
|
const events = [];
|
|
42
38
|
const hasNativeTokenBeingTransferred = response.value !== '0';
|
|
43
39
|
if (hasNativeTokenBeingTransferred) {
|
|
@@ -55,7 +51,6 @@ class BlockscoutBDSNeoX extends bs_ethereum_1.RpcBDSEthereum {
|
|
|
55
51
|
fromUrl,
|
|
56
52
|
to,
|
|
57
53
|
toUrl,
|
|
58
|
-
tokenType: 'native',
|
|
59
54
|
tokenUrl: this._service.explorerService.buildContractUrl(nativeToken.hash),
|
|
60
55
|
token: nativeToken,
|
|
61
56
|
});
|
|
@@ -86,7 +81,6 @@ class BlockscoutBDSNeoX extends bs_ethereum_1.RpcBDSEthereum {
|
|
|
86
81
|
fromUrl,
|
|
87
82
|
to,
|
|
88
83
|
toUrl,
|
|
89
|
-
tokenType: 'erc-20',
|
|
90
84
|
tokenUrl: this._service.explorerService.buildContractUrl(token.hash),
|
|
91
85
|
token,
|
|
92
86
|
});
|
|
@@ -103,15 +97,15 @@ class BlockscoutBDSNeoX extends bs_ethereum_1.RpcBDSEthereum {
|
|
|
103
97
|
fromUrl,
|
|
104
98
|
to,
|
|
105
99
|
toUrl,
|
|
106
|
-
tokenType: 'erc-721',
|
|
107
100
|
nft,
|
|
108
101
|
});
|
|
109
102
|
}
|
|
110
103
|
});
|
|
111
104
|
await Promise.allSettled(promises);
|
|
112
105
|
}
|
|
106
|
+
const data = this._service.neo3NeoXBridgeService._getDataFromBlockscoutTransaction(response);
|
|
113
107
|
const txId = response.hash;
|
|
114
|
-
|
|
108
|
+
const transaction = {
|
|
115
109
|
txId,
|
|
116
110
|
txIdUrl: this._service.explorerService.buildTransactionUrl(txId),
|
|
117
111
|
block: response.block,
|
|
@@ -119,16 +113,10 @@ class BlockscoutBDSNeoX extends bs_ethereum_1.RpcBDSEthereum {
|
|
|
119
113
|
networkFeeAmount: blockchain_service_1.BSBigNumberHelper.format(blockchain_service_1.BSBigNumberHelper.fromDecimals(response.fee.value, this._service.feeToken.decimals), {
|
|
120
114
|
decimals: this._service.feeToken.decimals,
|
|
121
115
|
}),
|
|
122
|
-
type: 'default',
|
|
123
116
|
view: 'default',
|
|
124
117
|
events,
|
|
118
|
+
data,
|
|
125
119
|
};
|
|
126
|
-
if (to === Neo3NeoXBridgeService_1.Neo3NeoXBridgeService.BRIDGE_SCRIPT_HASH) {
|
|
127
|
-
const [bridgeNeo3NeoXData] = blockchain_service_1.BSUtilsHelper.tryCatch(() => __classPrivateFieldGet(this, _BlockscoutBDSNeoX_instances, "m", _BlockscoutBDSNeoX_getBridgeNeo3NeoXDataByBlockscoutTransaction).call(this, response));
|
|
128
|
-
if (bridgeNeo3NeoXData) {
|
|
129
|
-
transaction = { ...transaction, type: 'bridgeNeo3NeoX', data: bridgeNeo3NeoXData };
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
120
|
return transaction;
|
|
133
121
|
}
|
|
134
122
|
async getTransactionsByAddress(params) {
|
|
@@ -160,7 +148,6 @@ class BlockscoutBDSNeoX extends bs_ethereum_1.RpcBDSEthereum {
|
|
|
160
148
|
fromUrl,
|
|
161
149
|
to,
|
|
162
150
|
toUrl,
|
|
163
|
-
tokenType: 'native',
|
|
164
151
|
tokenUrl: this._service.explorerService.buildContractUrl(nativeToken.hash),
|
|
165
152
|
token: nativeToken,
|
|
166
153
|
});
|
|
@@ -189,7 +176,6 @@ class BlockscoutBDSNeoX extends bs_ethereum_1.RpcBDSEthereum {
|
|
|
189
176
|
fromUrl,
|
|
190
177
|
to,
|
|
191
178
|
toUrl,
|
|
192
|
-
tokenType: 'erc-20',
|
|
193
179
|
tokenUrl: this._service.explorerService.buildContractUrl(token.hash),
|
|
194
180
|
token,
|
|
195
181
|
});
|
|
@@ -201,8 +187,9 @@ class BlockscoutBDSNeoX extends bs_ethereum_1.RpcBDSEthereum {
|
|
|
201
187
|
if (events.length === 0) {
|
|
202
188
|
return;
|
|
203
189
|
}
|
|
190
|
+
const data = this._service.neo3NeoXBridgeService._getDataFromBlockscoutTransaction(item);
|
|
204
191
|
const txId = item.hash;
|
|
205
|
-
|
|
192
|
+
const transaction = {
|
|
206
193
|
txId,
|
|
207
194
|
txIdUrl: this._service.explorerService.buildTransactionUrl(txId),
|
|
208
195
|
block: item.block,
|
|
@@ -210,17 +197,10 @@ class BlockscoutBDSNeoX extends bs_ethereum_1.RpcBDSEthereum {
|
|
|
210
197
|
networkFeeAmount: blockchain_service_1.BSBigNumberHelper.format(blockchain_service_1.BSBigNumberHelper.fromDecimals(item.fee.value, this._service.feeToken.decimals), {
|
|
211
198
|
decimals: this._service.feeToken.decimals,
|
|
212
199
|
}),
|
|
213
|
-
type: 'default',
|
|
214
200
|
view: 'default',
|
|
215
201
|
events,
|
|
202
|
+
data,
|
|
216
203
|
};
|
|
217
|
-
const hasBridgeNeo3NeoXEvent = events.some(event => event.to === Neo3NeoXBridgeService_1.Neo3NeoXBridgeService.BRIDGE_SCRIPT_HASH);
|
|
218
|
-
if (hasBridgeNeo3NeoXEvent) {
|
|
219
|
-
const [bridgeNeo3NeoXData] = blockchain_service_1.BSUtilsHelper.tryCatch(() => __classPrivateFieldGet(this, _BlockscoutBDSNeoX_instances, "m", _BlockscoutBDSNeoX_getBridgeNeo3NeoXDataByBlockscoutTransaction).call(this, item));
|
|
220
|
-
if (bridgeNeo3NeoXData) {
|
|
221
|
-
transaction = { ...transaction, type: 'bridgeNeo3NeoX', data: bridgeNeo3NeoXData };
|
|
222
|
-
}
|
|
223
|
-
}
|
|
224
204
|
transactions.splice(index, 0, transaction);
|
|
225
205
|
});
|
|
226
206
|
await Promise.allSettled(promises);
|
|
@@ -337,29 +317,6 @@ _a = BlockscoutBDSNeoX, _BlockscoutBDSNeoX_apiInstance = new WeakMap(), _Blocksc
|
|
|
337
317
|
return _a.getClient(this._service.network);
|
|
338
318
|
}
|
|
339
319
|
return __classPrivateFieldGet(this, _BlockscoutBDSNeoX_apiInstance, "f");
|
|
340
|
-
}, _BlockscoutBDSNeoX_getBridgeNeo3NeoXDataByBlockscoutTransaction = function _BlockscoutBDSNeoX_getBridgeNeo3NeoXDataByBlockscoutTransaction(transactionResponse) {
|
|
341
|
-
const BridgeInterface = new ethers_1.ethers.utils.Interface(bridge_1.BRIDGE_ABI);
|
|
342
|
-
const input = BridgeInterface.parseTransaction({ data: transactionResponse.raw_input });
|
|
343
|
-
const { wallet } = bs_neo3_1.BSNeo3NeonJsSingletonHelper.getInstance();
|
|
344
|
-
const to = input.args._to;
|
|
345
|
-
const receiverAddress = wallet.getAddressFromScriptHash(to.startsWith('0x') ? to.slice(2) : to);
|
|
346
|
-
let tokenToUse;
|
|
347
|
-
let amountBn;
|
|
348
|
-
if (input.name === 'withdrawNative') {
|
|
349
|
-
tokenToUse = this._service.neo3NeoXBridgeService.gasToken;
|
|
350
|
-
amountBn = blockchain_service_1.BSBigNumberHelper.fromDecimals(transactionResponse.value, tokenToUse.decimals).minus(Neo3NeoXBridgeService_1.Neo3NeoXBridgeService.BRIDGE_FEE);
|
|
351
|
-
}
|
|
352
|
-
else if (input.name === 'withdrawToken') {
|
|
353
|
-
tokenToUse = this._service.neo3NeoXBridgeService.neoToken;
|
|
354
|
-
amountBn = blockchain_service_1.BSBigNumberHelper.fromDecimals(input.args._amount.toString(), tokenToUse.decimals);
|
|
355
|
-
}
|
|
356
|
-
if (!tokenToUse || !amountBn)
|
|
357
|
-
return undefined;
|
|
358
|
-
return {
|
|
359
|
-
tokenToUse,
|
|
360
|
-
receiverAddress,
|
|
361
|
-
amount: blockchain_service_1.BSBigNumberHelper.format(amountBn, { decimals: tokenToUse.decimals }),
|
|
362
|
-
};
|
|
363
320
|
};
|
|
364
321
|
BlockscoutBDSNeoX.BASE_URL_BY_CHAIN_ID = {
|
|
365
322
|
'47763': `${blockchain_service_1.BSCommonConstants.COZ_API_URL}/api/neox/mainnet`,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { FlamingoForthewinEDS, type TGetTokenPriceHistoryParams, type TGetTokenPricesParams, type TTokenPricesResponse } from '@cityofzion/blockchain-service';
|
|
2
|
-
import type { IBSNeoX } from '../../types';
|
|
3
|
-
export declare class FlamingoForthewinEDSNeoX
|
|
4
|
-
constructor(service: IBSNeoX
|
|
2
|
+
import type { IBSNeoX, TBSNeoXName, TBSNeoXNetworkId } from '../../types';
|
|
3
|
+
export declare class FlamingoForthewinEDSNeoX extends FlamingoForthewinEDS<TBSNeoXName, TBSNeoXNetworkId> {
|
|
4
|
+
constructor(service: IBSNeoX);
|
|
5
5
|
getTokenPrices({ tokens }: TGetTokenPricesParams): Promise<TTokenPricesResponse[]>;
|
|
6
6
|
getTokenPriceHistory(params: TGetTokenPriceHistoryParams): Promise<import("@cityofzion/blockchain-service").TTokenPricesHistoryResponse[]>;
|
|
7
7
|
}
|
|
@@ -2,13 +2,12 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.FlamingoForthewinEDSNeoX = void 0;
|
|
4
4
|
const blockchain_service_1 = require("@cityofzion/blockchain-service");
|
|
5
|
-
const BSNeoXHelper_1 = require("../../helpers/BSNeoXHelper");
|
|
6
5
|
class FlamingoForthewinEDSNeoX extends blockchain_service_1.FlamingoForthewinEDS {
|
|
7
6
|
constructor(service) {
|
|
8
7
|
super(service);
|
|
9
8
|
}
|
|
10
9
|
async getTokenPrices({ tokens }) {
|
|
11
|
-
if (
|
|
10
|
+
if (this._service.network.type !== 'mainnet')
|
|
12
11
|
throw new Error('Exchange is only available on Neo X Mainnet');
|
|
13
12
|
const gasToken = tokens.find(({ symbol }) => symbol === 'GAS');
|
|
14
13
|
const neoToken = tokens.find(({ symbol }) => symbol === 'NEO');
|
|
@@ -19,7 +18,7 @@ class FlamingoForthewinEDSNeoX extends blockchain_service_1.FlamingoForthewinEDS
|
|
|
19
18
|
});
|
|
20
19
|
}
|
|
21
20
|
async getTokenPriceHistory(params) {
|
|
22
|
-
if (
|
|
21
|
+
if (this._service.network.type !== 'mainnet')
|
|
23
22
|
throw new Error('Exchange is only available on Neo X Mainnet');
|
|
24
23
|
const { symbol } = params.token;
|
|
25
24
|
if (symbol !== 'GAS' && symbol !== 'NEO')
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { BlockscoutESEthereum } from '@cityofzion/bs-ethereum';
|
|
2
|
-
import type { IBSNeoX, TBSNeoXNetworkId } from '../../types';
|
|
3
|
-
export declare class BlockscoutESNeoX
|
|
2
|
+
import type { IBSNeoX, TBSNeoXName, TBSNeoXNetworkId } from '../../types';
|
|
3
|
+
export declare class BlockscoutESNeoX extends BlockscoutESEthereum<TBSNeoXName, TBSNeoXNetworkId> {
|
|
4
4
|
static readonly DEFAULT_BASE_URL_BY_NETWORK_ID: Record<TBSNeoXNetworkId, string>;
|
|
5
|
-
constructor(service: IBSNeoX
|
|
5
|
+
constructor(service: IBSNeoX);
|
|
6
6
|
}
|
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
import { type IFullTransactionsDataService, type TExportFullTransactionsByAddressParams, type TGetFullTransactionsByAddressParams, type TGetTransactionsByAddressResponse, type TTransactionDefault } from '@cityofzion/blockchain-service';
|
|
2
2
|
import type { IBSNeoX, TBSNeoXNetworkId } from '../../types';
|
|
3
|
-
export declare class BlockscoutFullTransactionsDataService
|
|
3
|
+
export declare class BlockscoutFullTransactionsDataService implements IFullTransactionsDataService {
|
|
4
4
|
#private;
|
|
5
5
|
static readonly SUPPORTED_NETWORKS_IDS: TBSNeoXNetworkId[];
|
|
6
6
|
static readonly ERC721_STANDARDS: string[];
|
|
7
7
|
static readonly ERC1155_STANDARDS: string[];
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
getFullTransactionsByAddress({ nextPageParams, ...params }: TGetFullTransactionsByAddressParams): Promise<TGetTransactionsByAddressResponse<N, TTransactionDefault<N>>>;
|
|
8
|
+
constructor(service: IBSNeoX);
|
|
9
|
+
getFullTransactionsByAddress({ nextPageParams, ...params }: TGetFullTransactionsByAddressParams): Promise<TGetTransactionsByAddressResponse<TTransactionDefault>>;
|
|
11
10
|
exportFullTransactionsByAddress(params: TExportFullTransactionsByAddressParams): Promise<string>;
|
|
12
11
|
}
|
|
@@ -48,7 +48,6 @@ class BlockscoutFullTransactionsDataService {
|
|
|
48
48
|
networkFeeAmount: networkFeeAmount
|
|
49
49
|
? blockchain_service_1.BSBigNumberHelper.format(networkFeeAmount, { decimals: BSNeoXConstants_1.BSNeoXConstants.NATIVE_ASSET.decimals })
|
|
50
50
|
: undefined,
|
|
51
|
-
type: 'default',
|
|
52
51
|
view: 'default',
|
|
53
52
|
events: [],
|
|
54
53
|
};
|
|
@@ -57,7 +56,6 @@ class BlockscoutFullTransactionsDataService {
|
|
|
57
56
|
const standard = event.supportedStandards?.[0]?.toLowerCase() ?? '';
|
|
58
57
|
const isErc1155 = BlockscoutFullTransactionsDataService.ERC1155_STANDARDS.includes(standard);
|
|
59
58
|
const isErc721 = BlockscoutFullTransactionsDataService.ERC721_STANDARDS.includes(standard);
|
|
60
|
-
const isErc20 = BlockscoutFullTransactionsDataService.ERC20_STANDARDS.includes(standard);
|
|
61
59
|
const isNft = (isErc1155 || isErc721) && !!tokenHash;
|
|
62
60
|
const from = event.from ?? undefined;
|
|
63
61
|
const fromUrl = from ? __classPrivateFieldGet(this, _BlockscoutFullTransactionsDataService_service, "f").explorerService.buildAddressUrl(from) : undefined;
|
|
@@ -73,7 +71,6 @@ class BlockscoutFullTransactionsDataService {
|
|
|
73
71
|
fromUrl,
|
|
74
72
|
to,
|
|
75
73
|
toUrl,
|
|
76
|
-
tokenType: isErc1155 ? 'erc-1155' : 'erc-721',
|
|
77
74
|
nft,
|
|
78
75
|
});
|
|
79
76
|
return;
|
|
@@ -89,7 +86,6 @@ class BlockscoutFullTransactionsDataService {
|
|
|
89
86
|
fromUrl,
|
|
90
87
|
to,
|
|
91
88
|
toUrl,
|
|
92
|
-
tokenType: isErc20 ? 'erc-20' : 'generic',
|
|
93
89
|
tokenUrl: token ? __classPrivateFieldGet(this, _BlockscoutFullTransactionsDataService_service, "f").explorerService.buildContractUrl(token.hash) : undefined,
|
|
94
90
|
token,
|
|
95
91
|
});
|
|
@@ -101,11 +97,12 @@ class BlockscoutFullTransactionsDataService {
|
|
|
101
97
|
: __classPrivateFieldGet(this, _BlockscoutFullTransactionsDataService_service, "f").neo3NeoXBridgeService.neoToken;
|
|
102
98
|
newItem = {
|
|
103
99
|
...newItem,
|
|
104
|
-
type: 'bridgeNeo3NeoX',
|
|
105
100
|
data: {
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
101
|
+
neo3NeoxBridge: {
|
|
102
|
+
amount: blockchain_service_1.BSBigNumberHelper.format(bridgeData.amount, { decimals: tokenToUse.decimals }),
|
|
103
|
+
tokenToUse,
|
|
104
|
+
receiverAddress: bridgeData.receiverBridgeAddress,
|
|
105
|
+
},
|
|
109
106
|
},
|
|
110
107
|
};
|
|
111
108
|
}
|
|
@@ -135,4 +132,3 @@ _BlockscoutFullTransactionsDataService_service = new WeakMap();
|
|
|
135
132
|
BlockscoutFullTransactionsDataService.SUPPORTED_NETWORKS_IDS = ['47763', '12227332'];
|
|
136
133
|
BlockscoutFullTransactionsDataService.ERC721_STANDARDS = ['erc721', 'erc-721'];
|
|
137
134
|
BlockscoutFullTransactionsDataService.ERC1155_STANDARDS = ['erc1155', 'erc-1155'];
|
|
138
|
-
BlockscoutFullTransactionsDataService.ERC20_STANDARDS = ['erc20', 'erc-20'];
|
|
@@ -1,17 +1,19 @@
|
|
|
1
|
-
import { INeo3NeoXBridgeService, TBridgeToken, TNeo3NeoXBridgeServiceBridgeParam, TNeo3NeoXBridgeServiceConstants, TNeo3NeoXBridgeServiceGetApprovalParam, TNeo3NeoXBridgeServiceGetNonceParams, TNeo3NeoXBridgeServiceGetTransactionHashByNonceParams } from '@cityofzion/blockchain-service';
|
|
2
|
-
import type { IBSNeoX } from '../../types';
|
|
3
|
-
export declare class Neo3NeoXBridgeService
|
|
1
|
+
import { INeo3NeoXBridgeService, TBridgeToken, TNeo3NeoXBridgeServiceBridgeParam, TNeo3NeoXBridgeServiceConstants, TNeo3NeoXBridgeServiceGetApprovalParam, TNeo3NeoXBridgeServiceGetNonceParams, TNeo3NeoXBridgeServiceGetTransactionHashByNonceParams, type TNeo3NeoXBridgeTransactionData, type TTransaction } from '@cityofzion/blockchain-service';
|
|
2
|
+
import type { IBSNeoX, TBSNeoXName, TBlockscoutBDSNeoXTransactionApiResponse } from '../../types';
|
|
3
|
+
export declare class Neo3NeoXBridgeService implements INeo3NeoXBridgeService<TBSNeoXName> {
|
|
4
4
|
#private;
|
|
5
5
|
static readonly BRIDGE_SCRIPT_HASH = "0x1212000000000000000000000000000000000004";
|
|
6
6
|
static readonly BRIDGE_FEE = 0.1;
|
|
7
7
|
static readonly BRIDGE_BASE_CONFIRMATION_URL = "https://xexplorer.neo.org:8877/api/v1/transactions/deposits";
|
|
8
|
-
readonly gasToken: TBridgeToken<
|
|
9
|
-
readonly neoToken: TBridgeToken<
|
|
10
|
-
constructor(service: IBSNeoX
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
8
|
+
readonly gasToken: TBridgeToken<TBSNeoXName>;
|
|
9
|
+
readonly neoToken: TBridgeToken<TBSNeoXName>;
|
|
10
|
+
constructor(service: IBSNeoX);
|
|
11
|
+
_getDataFromBlockscoutTransaction(response: TBlockscoutBDSNeoXTransactionApiResponse): TNeo3NeoXBridgeTransactionData<TBSNeoXName> | undefined;
|
|
12
|
+
getBridgeConstants(token: TBridgeToken<TBSNeoXName>): Promise<TNeo3NeoXBridgeServiceConstants>;
|
|
13
|
+
getApprovalFee(params: TNeo3NeoXBridgeServiceGetApprovalParam<TBSNeoXName>): Promise<string>;
|
|
14
|
+
bridge(params: TNeo3NeoXBridgeServiceBridgeParam<TBSNeoXName>): Promise<string>;
|
|
15
|
+
getNonce(params: TNeo3NeoXBridgeServiceGetNonceParams<TBSNeoXName>): Promise<string>;
|
|
16
|
+
getTransactionHashByNonce(params: TNeo3NeoXBridgeServiceGetTransactionHashByNonceParams<TBSNeoXName>): Promise<string>;
|
|
17
|
+
getTokenByMultichainId(multichainId: string): TBridgeToken<TBSNeoXName> | undefined;
|
|
18
|
+
getTransactionData(transaction: TTransaction): TNeo3NeoXBridgeTransactionData<TBSNeoXName> | undefined;
|
|
17
19
|
}
|
|
@@ -23,8 +23,8 @@ const bridge_1 = require("../../assets/abis/bridge");
|
|
|
23
23
|
const bs_ethereum_1 = require("@cityofzion/bs-ethereum");
|
|
24
24
|
const axios_1 = __importDefault(require("axios"));
|
|
25
25
|
const BlockscoutBDSNeoX_1 = require("../blockchain-data/BlockscoutBDSNeoX");
|
|
26
|
-
const BSNeoXHelper_1 = require("../../helpers/BSNeoXHelper");
|
|
27
26
|
const bs_neo3_1 = require("@cityofzion/bs-neo3");
|
|
27
|
+
const BSNeoXHelper_1 = require("../../helpers/BSNeoXHelper");
|
|
28
28
|
class Neo3NeoXBridgeService {
|
|
29
29
|
constructor(service) {
|
|
30
30
|
_Neo3NeoXBridgeService_instances.add(this);
|
|
@@ -34,6 +34,35 @@ class Neo3NeoXBridgeService {
|
|
|
34
34
|
this.gasToken = { ...BSNeoXConstants_1.BSNeoXConstants.NATIVE_ASSET, blockchain: service.name, multichainId: 'gas' };
|
|
35
35
|
this.neoToken = { ...neoToken, blockchain: service.name, multichainId: 'neo' };
|
|
36
36
|
}
|
|
37
|
+
_getDataFromBlockscoutTransaction(response) {
|
|
38
|
+
if (response.to.hash.toLowerCase() !== _a.BRIDGE_SCRIPT_HASH.toLowerCase()) {
|
|
39
|
+
return undefined;
|
|
40
|
+
}
|
|
41
|
+
const BridgeInterface = new ethers_1.ethers.utils.Interface(bridge_1.BRIDGE_ABI);
|
|
42
|
+
const input = BridgeInterface.parseTransaction({ data: response.raw_input });
|
|
43
|
+
const { wallet } = bs_neo3_1.BSNeo3NeonJsSingletonHelper.getInstance();
|
|
44
|
+
const to = input.args._to;
|
|
45
|
+
const receiverAddress = wallet.getAddressFromScriptHash(to.startsWith('0x') ? to.slice(2) : to);
|
|
46
|
+
let tokenToUse;
|
|
47
|
+
let amountBn;
|
|
48
|
+
if (input.name === 'withdrawNative') {
|
|
49
|
+
tokenToUse = this.gasToken;
|
|
50
|
+
amountBn = blockchain_service_1.BSBigNumberHelper.fromDecimals(response.value, tokenToUse.decimals).minus(_a.BRIDGE_FEE);
|
|
51
|
+
}
|
|
52
|
+
else if (input.name === 'withdrawToken') {
|
|
53
|
+
tokenToUse = this.neoToken;
|
|
54
|
+
amountBn = blockchain_service_1.BSBigNumberHelper.fromDecimals(input.args._amount.toString(), tokenToUse.decimals);
|
|
55
|
+
}
|
|
56
|
+
if (!tokenToUse || !amountBn)
|
|
57
|
+
return undefined;
|
|
58
|
+
return {
|
|
59
|
+
neo3NeoxBridge: {
|
|
60
|
+
tokenToUse,
|
|
61
|
+
receiverAddress,
|
|
62
|
+
amount: blockchain_service_1.BSBigNumberHelper.format(amountBn, { decimals: tokenToUse.decimals }),
|
|
63
|
+
},
|
|
64
|
+
};
|
|
65
|
+
}
|
|
37
66
|
async getBridgeConstants(token) {
|
|
38
67
|
try {
|
|
39
68
|
const provider = new ethers_1.ethers.providers.JsonRpcProvider(__classPrivateFieldGet(this, _Neo3NeoXBridgeService_service, "f").network.url);
|
|
@@ -72,7 +101,7 @@ class Neo3NeoXBridgeService {
|
|
|
72
101
|
if (isNaN(chainId)) {
|
|
73
102
|
throw new Error('Invalid chainId');
|
|
74
103
|
}
|
|
75
|
-
const signer = await __classPrivateFieldGet(this, _Neo3NeoXBridgeService_service, "f").
|
|
104
|
+
const signer = await __classPrivateFieldGet(this, _Neo3NeoXBridgeService_service, "f")._generateSigner(params.account);
|
|
76
105
|
const nonce = await signer.getTransactionCount('pending');
|
|
77
106
|
if (isNaN(nonce)) {
|
|
78
107
|
throw new Error('Invalid nonce');
|
|
@@ -90,10 +119,10 @@ class Neo3NeoXBridgeService {
|
|
|
90
119
|
}
|
|
91
120
|
}
|
|
92
121
|
async bridge(params) {
|
|
93
|
-
if (
|
|
122
|
+
if (__classPrivateFieldGet(this, _Neo3NeoXBridgeService_service, "f").network.type !== 'mainnet') {
|
|
94
123
|
throw new blockchain_service_1.BSError('Bridging to Neo3 is only supported on mainnet', 'UNSUPPORTED_NETWORK');
|
|
95
124
|
}
|
|
96
|
-
const signer = await __classPrivateFieldGet(this, _Neo3NeoXBridgeService_service, "f").
|
|
125
|
+
const signer = await __classPrivateFieldGet(this, _Neo3NeoXBridgeService_service, "f")._generateSigner(params.account);
|
|
97
126
|
const bridgeContract = new ethers_1.ethers.Contract(_a.BRIDGE_SCRIPT_HASH, bridge_1.BRIDGE_ABI);
|
|
98
127
|
const { wallet } = bs_neo3_1.BSNeo3NeonJsSingletonHelper.getInstance();
|
|
99
128
|
const to = `0x${wallet.getScriptHashFromAddress(params.receiverAddress)}`;
|
|
@@ -110,7 +139,7 @@ class Neo3NeoXBridgeService {
|
|
|
110
139
|
else {
|
|
111
140
|
const approveTransactionParam = await __classPrivateFieldGet(this, _Neo3NeoXBridgeService_instances, "m", _Neo3NeoXBridgeService_buildApproveTransactionParam).call(this, params);
|
|
112
141
|
if (approveTransactionParam) {
|
|
113
|
-
const { transactionHash } = await __classPrivateFieldGet(this, _Neo3NeoXBridgeService_service, "f").
|
|
142
|
+
const { transactionHash } = await __classPrivateFieldGet(this, _Neo3NeoXBridgeService_service, "f")._sendTransaction({
|
|
114
143
|
signer,
|
|
115
144
|
gasPrice,
|
|
116
145
|
params: approveTransactionParam,
|
|
@@ -123,7 +152,7 @@ class Neo3NeoXBridgeService {
|
|
|
123
152
|
const populatedTransactionParams = await bridgeContract.populateTransaction.withdrawToken(params.token.hash, to, amount);
|
|
124
153
|
Object.assign(transactionParams, populatedTransactionParams, { value: bridgeFee });
|
|
125
154
|
}
|
|
126
|
-
const { transactionHash } = await __classPrivateFieldGet(this, _Neo3NeoXBridgeService_service, "f").
|
|
155
|
+
const { transactionHash } = await __classPrivateFieldGet(this, _Neo3NeoXBridgeService_service, "f")._sendTransaction({ signer, gasPrice, params: transactionParams });
|
|
127
156
|
return transactionHash;
|
|
128
157
|
}
|
|
129
158
|
async getNonce(params) {
|
|
@@ -173,6 +202,9 @@ class Neo3NeoXBridgeService {
|
|
|
173
202
|
const tokens = [this.gasToken, this.neoToken];
|
|
174
203
|
return tokens.find(token => token.multichainId === multichainId);
|
|
175
204
|
}
|
|
205
|
+
getTransactionData(transaction) {
|
|
206
|
+
return transaction.data?.neo3NeoxBridge ? transaction.data : undefined;
|
|
207
|
+
}
|
|
176
208
|
}
|
|
177
209
|
exports.Neo3NeoXBridgeService = Neo3NeoXBridgeService;
|
|
178
210
|
_a = Neo3NeoXBridgeService, _Neo3NeoXBridgeService_service = new WeakMap(), _Neo3NeoXBridgeService_instances = new WeakSet(), _Neo3NeoXBridgeService_buildApproveTransactionParam = async function _Neo3NeoXBridgeService_buildApproveTransactionParam(params) {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { GhostMarketNDSEthereum } from '@cityofzion/bs-ethereum';
|
|
2
|
-
import type { IBSNeoX, TBSNeoXNetworkId } from '../../types';
|
|
3
|
-
export declare class GhostMarketNDSNeoX
|
|
2
|
+
import type { IBSNeoX, TBSNeoXName, TBSNeoXNetworkId } from '../../types';
|
|
3
|
+
export declare class GhostMarketNDSNeoX extends GhostMarketNDSEthereum<TBSNeoXName, TBSNeoXNetworkId> {
|
|
4
4
|
static readonly CHAIN_BY_NETWORK_ID: Partial<Record<TBSNeoXNetworkId, string>>;
|
|
5
|
-
constructor(service: IBSNeoX
|
|
5
|
+
constructor(service: IBSNeoX);
|
|
6
6
|
getChain(): string;
|
|
7
7
|
}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import { type
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
import { type TWalletConnectServiceRequestMethodParams, type THexString } from '@cityofzion/blockchain-service';
|
|
2
|
+
import { WalletConnectServiceEthereum } from '@cityofzion/bs-ethereum';
|
|
3
|
+
import type { IBSNeoX, TBSNeoXName, TBSNeoXNetworkId } from '../../types';
|
|
4
|
+
export declare class WalletConnectServiceNeoX extends WalletConnectServiceEthereum<TBSNeoXName, TBSNeoXNetworkId> {
|
|
5
|
+
constructor(service: IBSNeoX);
|
|
6
|
+
eth_getTransactionCount(args: TWalletConnectServiceRequestMethodParams<TBSNeoXName>): Promise<number>;
|
|
7
|
+
eth_getCachedTransaction(args: TWalletConnectServiceRequestMethodParams<TBSNeoXName>): Promise<THexString>;
|
|
8
|
+
eth_sendTransaction(args: TWalletConnectServiceRequestMethodParams<TBSNeoXName>): Promise<string>;
|
|
8
9
|
}
|
|
@@ -15,14 +15,14 @@ class WalletConnectServiceNeoX extends bs_ethereum_1.WalletConnectServiceEthereu
|
|
|
15
15
|
this.supportedMethods.push('eth_getTransactionCount', 'eth_getCachedTransaction');
|
|
16
16
|
}
|
|
17
17
|
async eth_getTransactionCount(args) {
|
|
18
|
-
const wallet = await this._service.
|
|
18
|
+
const wallet = await this._service._generateSigner(args.account);
|
|
19
19
|
const provider = new ethers_1.ethers.providers.JsonRpcProvider(this._service.network.url);
|
|
20
20
|
const connectedWallet = wallet.connect(provider);
|
|
21
21
|
return await connectedWallet.getTransactionCount('pending');
|
|
22
22
|
}
|
|
23
23
|
async eth_getCachedTransaction(args) {
|
|
24
24
|
const url = this._service.network.url;
|
|
25
|
-
const wallet = await this._service.
|
|
25
|
+
const wallet = await this._service._generateSigner(args.account);
|
|
26
26
|
const provider = new ethers_1.ethers.providers.JsonRpcProvider(url);
|
|
27
27
|
const connectedWallet = wallet.connect(provider);
|
|
28
28
|
const nonce = args.params[0];
|
package/dist/types.d.ts
CHANGED
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
import type { IBSWithNeo3NeoXBridge, TBSNetworkId } from '@cityofzion/blockchain-service';
|
|
2
2
|
import { ERC20_ABI, IBSEthereum } from '@cityofzion/bs-ethereum';
|
|
3
3
|
import { ethers, Signer } from 'ethers';
|
|
4
|
+
import type { Neo3NeoXBridgeService } from './services/neo3-neox-bridge/Neo3NeoXBridgeService';
|
|
4
5
|
export type TBSNeoXNetworkId = TBSNetworkId<'47763' | '12227332'>;
|
|
5
|
-
export
|
|
6
|
-
|
|
6
|
+
export type TBSNeoXName = 'neox';
|
|
7
|
+
export interface IBSNeoX extends IBSEthereum<TBSNeoXName, TBSNeoXNetworkId>, IBSWithNeo3NeoXBridge<TBSNeoXName> {
|
|
8
|
+
neo3NeoXBridgeService: Neo3NeoXBridgeService;
|
|
9
|
+
_sendTransaction(params: TSendTransactionParams): Promise<TSendTransactionResponse>;
|
|
7
10
|
}
|
|
8
11
|
export type TBlockscoutBDSNeoXTransactionApiResponse = {
|
|
9
12
|
fee: {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cityofzion/bs-neox",
|
|
3
|
-
"version": "3.1.
|
|
3
|
+
"version": "3.1.5",
|
|
4
4
|
"repository": "https://github.com/CityOfZion/blockchain-services",
|
|
5
5
|
"license": "GPL-3.0-only",
|
|
6
6
|
"author": "Coz",
|
|
@@ -15,9 +15,9 @@
|
|
|
15
15
|
"ethers": "~5.7.2",
|
|
16
16
|
"neox-tpke": "~1.0.5",
|
|
17
17
|
"viem": "~2.38.5",
|
|
18
|
-
"@cityofzion/
|
|
19
|
-
"@cityofzion/bs-neo3": "3.1.
|
|
20
|
-
"@cityofzion/
|
|
18
|
+
"@cityofzion/blockchain-service": "3.1.5",
|
|
19
|
+
"@cityofzion/bs-neo3": "3.1.5",
|
|
20
|
+
"@cityofzion/bs-ethereum": "3.1.5"
|
|
21
21
|
},
|
|
22
22
|
"devDependencies": {
|
|
23
23
|
"@ledgerhq/hw-transport": "~6.32.0",
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
"vitest": "~4.0.18"
|
|
30
30
|
},
|
|
31
31
|
"scripts": {
|
|
32
|
-
"build": "rm -rf ./dist && npm run typecheck && tsc --project tsconfig.build.json",
|
|
32
|
+
"build": "rm -rf ./dist && rm -f *.tgz && npm run typecheck && tsc --project tsconfig.build.json",
|
|
33
33
|
"format": "eslint --fix",
|
|
34
34
|
"lint": "eslint .",
|
|
35
35
|
"package": "npm run build && npm pack",
|