@cityofzion/bs-neox 3.1.16 → 3.1.17
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/constants/BSNeoXConstants.d.ts +1 -0
- package/dist/constants/BSNeoXConstants.js +6 -0
- package/dist/helpers/BSNeoXHelper.d.ts +1 -0
- package/dist/helpers/BSNeoXHelper.js +7 -0
- package/dist/services/blockchain-data/BlockscoutBDSNeoX.js +0 -4
- package/dist/services/full-transactions-data/BlockscoutFullTransactionsDataService.js +13 -9
- package/dist/services/neo3-neox-bridge/Neo3NeoXBridgeService.d.ts +3 -2
- package/dist/services/neo3-neox-bridge/Neo3NeoXBridgeService.js +23 -42
- package/package.json +4 -4
|
@@ -2,6 +2,7 @@ import type { TBSNetwork, TBSToken } from '@cityofzion/blockchain-service';
|
|
|
2
2
|
import type { TBSNeoXNetworkId } from '../types';
|
|
3
3
|
export declare class BSNeoXConstants {
|
|
4
4
|
static readonly NATIVE_ASSET: TBSToken;
|
|
5
|
+
static readonly NDMEME_TOKEN: TBSToken;
|
|
5
6
|
static readonly ANTI_MEV_RPC_LIST_BY_NETWORK_ID: Record<TBSNeoXNetworkId, string[]>;
|
|
6
7
|
static readonly RPC_LIST_BY_NETWORK_ID: Record<TBSNeoXNetworkId, string[]>;
|
|
7
8
|
static readonly MAINNET_NETWORK: TBSNetwork<TBSNeoXNetworkId>;
|
|
@@ -12,6 +12,12 @@ BSNeoXConstants.NATIVE_ASSET = {
|
|
|
12
12
|
decimals: 18,
|
|
13
13
|
hash: '-',
|
|
14
14
|
};
|
|
15
|
+
BSNeoXConstants.NDMEME_TOKEN = {
|
|
16
|
+
symbol: 'NDMEME',
|
|
17
|
+
name: 'NDMEME',
|
|
18
|
+
hash: '0xe816dee05cf6d0f2a57eb4c489241d8326b5d106',
|
|
19
|
+
decimals: 18,
|
|
20
|
+
};
|
|
15
21
|
BSNeoXConstants.ANTI_MEV_RPC_LIST_BY_NETWORK_ID = {
|
|
16
22
|
'47763': ['https://mainnet-5.rpc.banelabs.org'],
|
|
17
23
|
'12227332': ['https://neoxt4seed5.ngd.network'],
|
|
@@ -2,6 +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");
|
|
5
6
|
class BSNeoXHelper {
|
|
6
7
|
static getNeoToken(network) {
|
|
7
8
|
if (network.type === 'custom') {
|
|
@@ -13,5 +14,11 @@ class BSNeoXHelper {
|
|
|
13
14
|
}
|
|
14
15
|
return { name: 'NEO', symbol: 'NEO', decimals: 18, hash };
|
|
15
16
|
}
|
|
17
|
+
static getNdmemeToken(network) {
|
|
18
|
+
if (network.type !== 'mainnet') {
|
|
19
|
+
return { ...BSNeoXConstants_1.BSNeoXConstants.NDMEME_TOKEN, hash: '-' };
|
|
20
|
+
}
|
|
21
|
+
return BSNeoXConstants_1.BSNeoXConstants.NDMEME_TOKEN;
|
|
22
|
+
}
|
|
16
23
|
}
|
|
17
24
|
exports.BSNeoXHelper = BSNeoXHelper;
|
|
@@ -101,7 +101,6 @@ class BlockscoutBDSNeoX extends bs_ethereum_1.RpcBDSEthereum {
|
|
|
101
101
|
});
|
|
102
102
|
await Promise.allSettled(promises);
|
|
103
103
|
}
|
|
104
|
-
const data = this._service.neo3NeoXBridgeService._getDataFromBlockscoutTransaction(response);
|
|
105
104
|
const txId = response.hash;
|
|
106
105
|
return {
|
|
107
106
|
blockchain: this._service.name,
|
|
@@ -115,7 +114,6 @@ class BlockscoutBDSNeoX extends bs_ethereum_1.RpcBDSEthereum {
|
|
|
115
114
|
.toFormatted(),
|
|
116
115
|
view: 'default',
|
|
117
116
|
events,
|
|
118
|
-
data,
|
|
119
117
|
};
|
|
120
118
|
}
|
|
121
119
|
async getTransactionsByAddress(params) {
|
|
@@ -179,7 +177,6 @@ class BlockscoutBDSNeoX extends bs_ethereum_1.RpcBDSEthereum {
|
|
|
179
177
|
/* empty */
|
|
180
178
|
}
|
|
181
179
|
}
|
|
182
|
-
const data = this._service.neo3NeoXBridgeService._getDataFromBlockscoutTransaction(item);
|
|
183
180
|
const txId = item.hash;
|
|
184
181
|
const transaction = {
|
|
185
182
|
blockchain: this._service.name,
|
|
@@ -192,7 +189,6 @@ class BlockscoutBDSNeoX extends bs_ethereum_1.RpcBDSEthereum {
|
|
|
192
189
|
networkFeeAmount: new blockchain_service_1.BSBigUnitAmount(item.fee.value, this._service.feeToken.decimals).toHuman().toFormatted(),
|
|
193
190
|
view: 'default',
|
|
194
191
|
events,
|
|
195
|
-
data,
|
|
196
192
|
};
|
|
197
193
|
transactions.splice(index, 0, transaction);
|
|
198
194
|
});
|
|
@@ -92,25 +92,29 @@ class BlockscoutFullTransactionsDataService {
|
|
|
92
92
|
tokenUrl: token ? __classPrivateFieldGet(this, _BlockscoutFullTransactionsDataService_service, "f").explorerService.buildContractUrl(token.hash) : undefined,
|
|
93
93
|
token,
|
|
94
94
|
});
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
95
|
+
});
|
|
96
|
+
await Promise.allSettled(eventPromises);
|
|
97
|
+
const itemData = 'data' in item ? item.data : undefined;
|
|
98
|
+
const bridgeData = itemData?.bridgeData;
|
|
99
|
+
if (bridgeData) {
|
|
100
|
+
const bridgeService = __classPrivateFieldGet(this, _BlockscoutFullTransactionsDataService_service, "f").neo3NeoXBridgeService;
|
|
101
|
+
const tokenService = __classPrivateFieldGet(this, _BlockscoutFullTransactionsDataService_service, "f").tokenService;
|
|
102
|
+
const tokenToUse = !bridgeData.neoXTokenHash
|
|
103
|
+
? bridgeService.gasToken
|
|
104
|
+
: bridgeService.tokens.find(token => tokenService.predicateByHash(bridgeData.neoXTokenHash, token));
|
|
105
|
+
if (tokenToUse) {
|
|
101
106
|
newItem = {
|
|
102
107
|
...newItem,
|
|
103
108
|
data: {
|
|
104
109
|
neo3NeoxBridge: {
|
|
105
110
|
amount: new blockchain_service_1.BSBigHumanAmount(bridgeData.amount, tokenToUse.decimals).toFormatted(),
|
|
106
111
|
tokenToUse,
|
|
107
|
-
receiverAddress: bridgeData.
|
|
112
|
+
receiverAddress: bridgeData.receiverAddress,
|
|
108
113
|
},
|
|
109
114
|
},
|
|
110
115
|
};
|
|
111
116
|
}
|
|
112
|
-
}
|
|
113
|
-
await Promise.allSettled(eventPromises);
|
|
117
|
+
}
|
|
114
118
|
transactions.splice(index, 0, newItem);
|
|
115
119
|
});
|
|
116
120
|
await Promise.allSettled(itemPromises);
|
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import { INeo3NeoXBridgeService, TBridgeToken, TNeo3NeoXBridgeServiceBridgeParam, TNeo3NeoXBridgeServiceConstants, TNeo3NeoXBridgeServiceGetApprovalParam, TNeo3NeoXBridgeServiceGetNonceParams, TNeo3NeoXBridgeServiceGetTransactionHashByNonceParams, type TNeo3NeoXBridgeTransactionData, type TTransactionBase } from '@cityofzion/blockchain-service';
|
|
2
|
-
import type { IBSNeoX, TBSNeoXName
|
|
2
|
+
import type { IBSNeoX, TBSNeoXName } from '../../types';
|
|
3
3
|
export declare class Neo3NeoXBridgeService implements INeo3NeoXBridgeService<TBSNeoXName> {
|
|
4
4
|
#private;
|
|
5
5
|
static readonly BRIDGE_SCRIPT_HASH = "0x1212000000000000000000000000000000000004";
|
|
6
6
|
static readonly BRIDGE_BASE_CONFIRMATION_URL = "https://xexplorer.neo.org:8877/api/v1/transactions/deposits";
|
|
7
7
|
readonly gasToken: TBridgeToken<TBSNeoXName>;
|
|
8
8
|
readonly neoToken: TBridgeToken<TBSNeoXName>;
|
|
9
|
+
readonly ndmemeToken: TBridgeToken<TBSNeoXName>;
|
|
10
|
+
readonly tokens: TBridgeToken<TBSNeoXName>[];
|
|
9
11
|
constructor(service: IBSNeoX);
|
|
10
|
-
_getDataFromBlockscoutTransaction(response: TBlockscoutBDSNeoXTransactionApiResponse): TNeo3NeoXBridgeTransactionData<TBSNeoXName> | undefined;
|
|
11
12
|
getBridgeConstants(token: TBridgeToken<TBSNeoXName>): Promise<TNeo3NeoXBridgeServiceConstants>;
|
|
12
13
|
getApprovalFee(params: TNeo3NeoXBridgeServiceGetApprovalParam<TBSNeoXName>): Promise<string>;
|
|
13
14
|
bridge(params: TNeo3NeoXBridgeServiceBridgeParam<TBSNeoXName>): Promise<string>;
|
|
@@ -31,34 +31,15 @@ class Neo3NeoXBridgeService {
|
|
|
31
31
|
_Neo3NeoXBridgeService_service.set(this, void 0);
|
|
32
32
|
__classPrivateFieldSet(this, _Neo3NeoXBridgeService_service, service, "f");
|
|
33
33
|
const neoToken = BSNeoXHelper_1.BSNeoXHelper.getNeoToken(__classPrivateFieldGet(this, _Neo3NeoXBridgeService_service, "f").network);
|
|
34
|
+
const ndmemeToken = BSNeoXHelper_1.BSNeoXHelper.getNdmemeToken(__classPrivateFieldGet(this, _Neo3NeoXBridgeService_service, "f").network);
|
|
34
35
|
this.gasToken = { ...BSNeoXConstants_1.BSNeoXConstants.NATIVE_ASSET, blockchain: service.name, multichainId: 'gas' };
|
|
35
36
|
this.neoToken = { ...neoToken, blockchain: service.name, multichainId: 'neo' };
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
}
|
|
41
|
-
|
|
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 amount;
|
|
48
|
-
if (input.name === 'withdrawNative') {
|
|
49
|
-
tokenToUse = this.gasToken;
|
|
50
|
-
amount = new blockchain_service_1.BSBigUnitAmount(response.value, tokenToUse.decimals)
|
|
51
|
-
.minus(input.args._maxFee.toString())
|
|
52
|
-
.toHuman()
|
|
53
|
-
.toFormatted();
|
|
54
|
-
}
|
|
55
|
-
else if (input.name === 'withdrawToken') {
|
|
56
|
-
tokenToUse = this.neoToken;
|
|
57
|
-
amount = new blockchain_service_1.BSBigUnitAmount(input.args._amount.toString(), tokenToUse.decimals).toHuman().toFormatted();
|
|
58
|
-
}
|
|
59
|
-
if (!tokenToUse || !amount)
|
|
60
|
-
return undefined;
|
|
61
|
-
return { neo3NeoxBridge: { tokenToUse, receiverAddress, amount } };
|
|
37
|
+
this.ndmemeToken = {
|
|
38
|
+
...ndmemeToken,
|
|
39
|
+
blockchain: service.name,
|
|
40
|
+
multichainId: 'ndmeme',
|
|
41
|
+
};
|
|
42
|
+
this.tokens = [this.gasToken, this.neoToken, this.ndmemeToken];
|
|
62
43
|
}
|
|
63
44
|
async getBridgeConstants(token) {
|
|
64
45
|
try {
|
|
@@ -129,14 +110,14 @@ class Neo3NeoXBridgeService {
|
|
|
129
110
|
const bridgeContract = new ethers_1.ethers.Contract(_a.BRIDGE_SCRIPT_HASH, bridge_1.BRIDGE_ABI);
|
|
130
111
|
const { wallet } = bs_neo3_1.BSNeo3NeonJsSingletonHelper.getInstance();
|
|
131
112
|
const to = `0x${wallet.getScriptHashFromAddress(params.receiverAddress)}`;
|
|
132
|
-
const bridgeFee = new blockchain_service_1.BSBigHumanAmount(params.bridgeFee, BSNeoXConstants_1.BSNeoXConstants.NATIVE_ASSET.decimals).toUnit().
|
|
113
|
+
const bridgeFee = new blockchain_service_1.BSBigHumanAmount(params.bridgeFee, BSNeoXConstants_1.BSNeoXConstants.NATIVE_ASSET.decimals).toUnit().toFixed();
|
|
133
114
|
const isNativeToken = __classPrivateFieldGet(this, _Neo3NeoXBridgeService_service, "f").tokenService.predicateByHash(params.token, BSNeoXConstants_1.BSNeoXConstants.NATIVE_ASSET);
|
|
134
115
|
const gasPrice = await signer.getGasPrice();
|
|
135
116
|
const gasPriceBn = new blockchain_service_1.BSBigUnitAmount(gasPrice.toString(), bs_ethereum_1.BSEthereumConstants.DEFAULT_DECIMALS);
|
|
136
117
|
const transactionParams = { type: 2 };
|
|
137
118
|
if (isNativeToken) {
|
|
138
119
|
const populatedTransactionParams = await bridgeContract.populateTransaction.withdrawNative(to, bridgeFee);
|
|
139
|
-
const value = new blockchain_service_1.BSBigHumanAmount(params.amount, params.token.decimals).toUnit().plus(bridgeFee).
|
|
120
|
+
const value = new blockchain_service_1.BSBigHumanAmount(params.amount, params.token.decimals).toUnit().plus(bridgeFee).toFixed();
|
|
140
121
|
Object.assign(transactionParams, populatedTransactionParams, { value });
|
|
141
122
|
}
|
|
142
123
|
else {
|
|
@@ -151,7 +132,7 @@ class Neo3NeoXBridgeService {
|
|
|
151
132
|
await provider.waitForTransaction(transactionHash);
|
|
152
133
|
}
|
|
153
134
|
const fixedAmount = new blockchain_service_1.BSBigHumanAmount(params.amount, 0).toFormatted();
|
|
154
|
-
const amount = new blockchain_service_1.BSBigHumanAmount(fixedAmount, params.token.decimals).toUnit().
|
|
135
|
+
const amount = new blockchain_service_1.BSBigHumanAmount(fixedAmount, params.token.decimals).toUnit().toFixed();
|
|
155
136
|
const populatedTransactionParams = await bridgeContract.populateTransaction.withdrawToken(params.token.hash, to, amount);
|
|
156
137
|
Object.assign(transactionParams, populatedTransactionParams, { value: bridgeFee });
|
|
157
138
|
}
|
|
@@ -165,16 +146,17 @@ class Neo3NeoXBridgeService {
|
|
|
165
146
|
});
|
|
166
147
|
if (!transactionLogsResponse)
|
|
167
148
|
throw new blockchain_service_1.BSError('Failed to get nonce from transaction log', 'FAILED_TO_GET_NONCE', transactionLogsResponseError);
|
|
168
|
-
const [nonce, nonceError] = await blockchain_service_1.BSUtilsHelper.tryCatch(() => {
|
|
149
|
+
const [nonce, nonceError] = await blockchain_service_1.BSUtilsHelper.tryCatch(async () => {
|
|
169
150
|
const BridgeInterface = new ethers_1.ethers.utils.Interface(bridge_1.BRIDGE_ABI);
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
151
|
+
for (const log of transactionLogsResponse.data.items) {
|
|
152
|
+
const [parsedNonce] = await blockchain_service_1.BSUtilsHelper.tryCatch(() => {
|
|
153
|
+
const parsedLog = BridgeInterface.parseLog({ data: log.data, topics: log.topics.filter(Boolean) });
|
|
154
|
+
return parsedLog.args.nonce ? parsedLog.args.nonce.toString() : undefined;
|
|
155
|
+
});
|
|
156
|
+
if (parsedNonce)
|
|
157
|
+
return parsedNonce;
|
|
158
|
+
}
|
|
159
|
+
return undefined;
|
|
178
160
|
});
|
|
179
161
|
if (!nonce) {
|
|
180
162
|
throw new blockchain_service_1.BSError('Failed to get nonce from transaction log', 'FAILED_TO_GET_NONCE', nonceError);
|
|
@@ -189,7 +171,7 @@ class Neo3NeoXBridgeService {
|
|
|
189
171
|
url = `${_a.BRIDGE_BASE_CONFIRMATION_URL}/${params.nonce}`;
|
|
190
172
|
}
|
|
191
173
|
else {
|
|
192
|
-
url = `${_a.BRIDGE_BASE_CONFIRMATION_URL}/${
|
|
174
|
+
url = `${_a.BRIDGE_BASE_CONFIRMATION_URL}/${params.token.hash}/${params.nonce}`;
|
|
193
175
|
}
|
|
194
176
|
const response = await axios_1.default.get(url);
|
|
195
177
|
if (!response.data?.txid) {
|
|
@@ -202,8 +184,7 @@ class Neo3NeoXBridgeService {
|
|
|
202
184
|
}
|
|
203
185
|
}
|
|
204
186
|
getTokenByMultichainId(multichainId) {
|
|
205
|
-
|
|
206
|
-
return tokens.find(token => token.multichainId === multichainId);
|
|
187
|
+
return this.tokens.find(token => token.multichainId === multichainId);
|
|
207
188
|
}
|
|
208
189
|
getTransactionData(transaction) {
|
|
209
190
|
return transaction.data?.neo3NeoxBridge ? transaction.data : undefined;
|
|
@@ -217,7 +198,7 @@ _a = Neo3NeoXBridgeService, _Neo3NeoXBridgeService_service = new WeakMap(), _Neo
|
|
|
217
198
|
const allowanceNumber = new blockchain_service_1.BSBigUnitAmount(allowance.toString(), this.neoToken.decimals);
|
|
218
199
|
// We are using 0 as the decimals because the NEO token in Neo3 has 0 decimals
|
|
219
200
|
const fixedAmount = new blockchain_service_1.BSBigHumanAmount(params.amount, 0).toFormatted();
|
|
220
|
-
const amount = new blockchain_service_1.BSBigHumanAmount(fixedAmount, params.token.decimals).toUnit().
|
|
201
|
+
const amount = new blockchain_service_1.BSBigHumanAmount(fixedAmount, params.token.decimals).toUnit().toFixed();
|
|
221
202
|
if (allowanceNumber.isGreaterThanOrEqualTo(amount)) {
|
|
222
203
|
return null;
|
|
223
204
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cityofzion/bs-neox",
|
|
3
|
-
"version": "3.1.
|
|
3
|
+
"version": "3.1.17",
|
|
4
4
|
"repository": "https://github.com/CityOfZion/blockchain-services",
|
|
5
5
|
"license": "GPL-3.0-only",
|
|
6
6
|
"author": "Coz",
|
|
@@ -16,9 +16,9 @@
|
|
|
16
16
|
"neox-tpke": "~1.0.5",
|
|
17
17
|
"viem": "~2.38.5",
|
|
18
18
|
"zod": "~4.3.6",
|
|
19
|
-
"@cityofzion/
|
|
20
|
-
"@cityofzion/bs-neo3": "3.1.
|
|
21
|
-
"@cityofzion/
|
|
19
|
+
"@cityofzion/blockchain-service": "3.1.17",
|
|
20
|
+
"@cityofzion/bs-neo3": "3.1.17",
|
|
21
|
+
"@cityofzion/bs-ethereum": "3.1.17"
|
|
22
22
|
},
|
|
23
23
|
"devDependencies": {
|
|
24
24
|
"@ledgerhq/hw-transport": "~6.32.0",
|