@cityofzion/bs-neox 1.2.4 → 1.2.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.
|
@@ -4,11 +4,11 @@ export declare class Neo3NeoXBridgeService<BSName extends string> implements INe
|
|
|
4
4
|
#private;
|
|
5
5
|
readonly BRIDGE_SCRIPT_HASH = "0x1212000000000000000000000000000000000004";
|
|
6
6
|
readonly BRIDGE_BASE_CONFIRMATION_URL = "https://xexplorer.neo.org:8877/api/v1/transactions/deposits";
|
|
7
|
-
tokens: TBridgeToken[];
|
|
7
|
+
tokens: TBridgeToken<BSName>[];
|
|
8
8
|
constructor(service: BSNeoX<BSName>);
|
|
9
|
-
getBridgeConstants(token: TBridgeToken): Promise<TNeo3NeoXBridgeServiceConstants>;
|
|
9
|
+
getBridgeConstants(token: TBridgeToken<BSName>): Promise<TNeo3NeoXBridgeServiceConstants>;
|
|
10
10
|
getApprovalFee(params: TNeo3NeoXBridgeServiceGetApprovalParam<BSName>): Promise<string>;
|
|
11
11
|
bridge(params: TNeo3NeoXBridgeServiceBridgeParam<BSName>): Promise<string>;
|
|
12
|
-
getNonce(params: TNeo3NeoXBridgeServiceGetNonceParams): Promise<string
|
|
13
|
-
getTransactionHashByNonce(params: TNeo3NeoXBridgeServiceGetTransactionHashByNonceParams): Promise<string
|
|
12
|
+
getNonce(params: TNeo3NeoXBridgeServiceGetNonceParams<BSName>): Promise<string>;
|
|
13
|
+
getTransactionHashByNonce(params: TNeo3NeoXBridgeServiceGetTransactionHashByNonceParams<BSName>): Promise<string>;
|
|
14
14
|
}
|
|
@@ -42,8 +42,8 @@ class Neo3NeoXBridgeService {
|
|
|
42
42
|
_Neo3NeoXBridgeService_service.set(this, void 0);
|
|
43
43
|
__classPrivateFieldSet(this, _Neo3NeoXBridgeService_service, service, "f");
|
|
44
44
|
this.tokens = [
|
|
45
|
-
Object.assign(Object.assign({}, BSNeoXConstants_1.BSNeoXConstants.NATIVE_ASSET), { multichainId: 'gas' }),
|
|
46
|
-
Object.assign(Object.assign({}, BSNeoXConstants_1.BSNeoXConstants.NEO_TOKEN), { multichainId: 'neo' }),
|
|
45
|
+
Object.assign(Object.assign({}, BSNeoXConstants_1.BSNeoXConstants.NATIVE_ASSET), { multichainId: 'gas', blockchain: service.name }),
|
|
46
|
+
Object.assign(Object.assign({}, BSNeoXConstants_1.BSNeoXConstants.NEO_TOKEN), { multichainId: 'neo', blockchain: service.name }),
|
|
47
47
|
];
|
|
48
48
|
}
|
|
49
49
|
getBridgeConstants(token) {
|
|
@@ -112,7 +112,7 @@ class Neo3NeoXBridgeService {
|
|
|
112
112
|
};
|
|
113
113
|
if (isNativeToken) {
|
|
114
114
|
const populatedTransaction = yield bridgeContract.populateTransaction.withdrawNative(to, bridgeFee);
|
|
115
|
-
bridgeTransactionParam = Object.assign(Object.assign(Object.assign({}, bridgeTransactionParam), populatedTransaction), { value: ethers_1.ethers.utils.parseUnits(params.amount, params.token.decimals) });
|
|
115
|
+
bridgeTransactionParam = Object.assign(Object.assign(Object.assign({}, bridgeTransactionParam), populatedTransaction), { value: ethers_1.ethers.utils.parseUnits(params.amount, params.token.decimals).add(bridgeFee) });
|
|
116
116
|
}
|
|
117
117
|
else {
|
|
118
118
|
const approveTransactionParam = yield __classPrivateFieldGet(this, _Neo3NeoXBridgeService_instances, "m", _Neo3NeoXBridgeService_buildApproveTransactionParam).call(this, params);
|
|
@@ -129,7 +129,7 @@ class Neo3NeoXBridgeService {
|
|
|
129
129
|
try {
|
|
130
130
|
gasLimit = yield signer.estimateGas(bridgeTransactionParam);
|
|
131
131
|
}
|
|
132
|
-
catch (
|
|
132
|
+
catch (error) {
|
|
133
133
|
gasLimit = bs_ethereum_1.BSEthereumConstants.DEFAULT_GAS_LIMIT;
|
|
134
134
|
}
|
|
135
135
|
const gasPrice = yield signer.getGasPrice();
|
|
@@ -146,30 +146,37 @@ class Neo3NeoXBridgeService {
|
|
|
146
146
|
data = response.data;
|
|
147
147
|
}
|
|
148
148
|
catch (error) {
|
|
149
|
-
throw new blockchain_service_1.BSError('
|
|
149
|
+
throw new blockchain_service_1.BSError('Failed to get nonce from transaction log', 'FAILED_TO_GET_NONCE', error);
|
|
150
150
|
}
|
|
151
151
|
if (!data.items || data.items.length === 0) {
|
|
152
|
-
throw new blockchain_service_1.BSError('Transaction
|
|
152
|
+
throw new blockchain_service_1.BSError('Transaction invalid', 'INVALID_TRANSACTION');
|
|
153
153
|
}
|
|
154
154
|
try {
|
|
155
155
|
const BridgeInterface = new ethers_1.ethers.utils.Interface(bridge_1.BRIDGE_ABI);
|
|
156
156
|
const isNativeToken = blockchain_service_1.BSTokenHelper.predicateByHash(params.token)(BSNeoXConstants_1.BSNeoXConstants.NATIVE_ASSET);
|
|
157
|
+
let nonce;
|
|
157
158
|
if (isNativeToken) {
|
|
158
159
|
const item = data.items[0];
|
|
159
160
|
const parsedLog = BridgeInterface.parseLog({ data: item.data, topics: item.topics.filter(Boolean) });
|
|
160
|
-
|
|
161
|
+
nonce = parsedLog.args.nonce ? parsedLog.args.nonce.toString() : undefined;
|
|
162
|
+
}
|
|
163
|
+
else {
|
|
164
|
+
const item = data.items[1];
|
|
165
|
+
const parsedLog = BridgeInterface.parseLog({ data: item.data, topics: item.topics.filter(Boolean) });
|
|
166
|
+
nonce = parsedLog.args.nonce ? parsedLog.args.nonce.toString() : undefined;
|
|
167
|
+
}
|
|
168
|
+
if (!nonce) {
|
|
169
|
+
throw new blockchain_service_1.BSError('Nonce not found in transaction log', 'NONCE_NOT_FOUND');
|
|
161
170
|
}
|
|
162
|
-
|
|
163
|
-
const parsedLog = BridgeInterface.parseLog({ data: item.data, topics: item.topics.filter(Boolean) });
|
|
164
|
-
return parsedLog.args.nonce ? parsedLog.args.nonce.toString() : null;
|
|
171
|
+
return nonce;
|
|
165
172
|
}
|
|
166
173
|
catch (error) {
|
|
167
|
-
|
|
174
|
+
throw new blockchain_service_1.BSError('Failed to get nonce from transaction log', 'FAILED_TO_GET_NONCE', error);
|
|
168
175
|
}
|
|
169
176
|
});
|
|
170
177
|
}
|
|
171
178
|
getTransactionHashByNonce(params) {
|
|
172
|
-
var _a
|
|
179
|
+
var _a;
|
|
173
180
|
return __awaiter(this, void 0, void 0, function* () {
|
|
174
181
|
try {
|
|
175
182
|
let url;
|
|
@@ -182,12 +189,12 @@ class Neo3NeoXBridgeService {
|
|
|
182
189
|
}
|
|
183
190
|
const response = yield axios_1.default.get(url);
|
|
184
191
|
if (!((_a = response.data) === null || _a === void 0 ? void 0 : _a.txid)) {
|
|
185
|
-
throw new blockchain_service_1.BSError('Transaction not found', '
|
|
192
|
+
throw new blockchain_service_1.BSError('Transaction ID not found in response', 'TXID_NOT_FOUND');
|
|
186
193
|
}
|
|
187
|
-
return
|
|
194
|
+
return response.data.txid;
|
|
188
195
|
}
|
|
189
196
|
catch (error) {
|
|
190
|
-
throw new blockchain_service_1.BSError('Transaction not found', '
|
|
197
|
+
throw new blockchain_service_1.BSError('Transaction ID not found in response', 'TXID_NOT_FOUND', error);
|
|
191
198
|
}
|
|
192
199
|
});
|
|
193
200
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cityofzion/bs-neox",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.5",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"types": "dist/index.d.ts",
|
|
6
6
|
"repository": "https://github.com/CityOfZion/blockchain-services",
|
|
@@ -16,8 +16,8 @@
|
|
|
16
16
|
"axios": "1.8.2",
|
|
17
17
|
"ethers": "5.7.2",
|
|
18
18
|
"date-fns": "~4.1.0",
|
|
19
|
-
"@cityofzion/blockchain-service": "1.19.
|
|
20
|
-
"@cityofzion/bs-ethereum": "2.12.
|
|
19
|
+
"@cityofzion/blockchain-service": "1.19.3",
|
|
20
|
+
"@cityofzion/bs-ethereum": "2.12.8"
|
|
21
21
|
},
|
|
22
22
|
"devDependencies": {
|
|
23
23
|
"@ledgerhq/hw-transport-node-hid": "~6.29.9",
|