@cityofzion/bs-neo3 1.15.3 → 1.15.4
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.
|
@@ -3,11 +3,11 @@ import { BSNeo3 } from '../../BSNeo3';
|
|
|
3
3
|
export declare class Neo3NeoXBridgeService<BSName extends string = string> implements INeo3NeoXBridgeService<BSName> {
|
|
4
4
|
#private;
|
|
5
5
|
readonly BRIDGE_SCRIPT_HASH = "0xbb19cfc864b73159277e1fd39694b3fd5fc613d2";
|
|
6
|
-
tokens: TBridgeToken[];
|
|
6
|
+
tokens: TBridgeToken<BSName>[];
|
|
7
7
|
constructor(service: BSNeo3<BSName>);
|
|
8
8
|
getApprovalFee(): Promise<string>;
|
|
9
|
-
getBridgeConstants(token: TBridgeToken): Promise<TNeo3NeoXBridgeServiceConstants>;
|
|
9
|
+
getBridgeConstants(token: TBridgeToken<BSName>): Promise<TNeo3NeoXBridgeServiceConstants>;
|
|
10
10
|
bridge(params: TNeo3NeoXBridgeServiceBridgeParam<BSName>): Promise<string>;
|
|
11
|
-
getNonce(params: TNeo3NeoXBridgeServiceGetNonceParams): Promise<string
|
|
12
|
-
getTransactionHashByNonce(params: TNeo3NeoXBridgeServiceGetTransactionHashByNonceParams): Promise<string
|
|
11
|
+
getNonce(params: TNeo3NeoXBridgeServiceGetNonceParams<BSName>): Promise<string>;
|
|
12
|
+
getTransactionHashByNonce(params: TNeo3NeoXBridgeServiceGetTransactionHashByNonceParams<BSName>): Promise<string>;
|
|
13
13
|
}
|
|
@@ -37,8 +37,8 @@ class Neo3NeoXBridgeService {
|
|
|
37
37
|
_Neo3NeoXBridgeService_service.set(this, void 0);
|
|
38
38
|
__classPrivateFieldSet(this, _Neo3NeoXBridgeService_service, service, "f");
|
|
39
39
|
this.tokens = [
|
|
40
|
-
Object.assign(Object.assign({}, BSNeo3Constants_1.BSNeo3Constants.GAS_TOKEN), { multichainId: 'gas' }),
|
|
41
|
-
Object.assign(Object.assign({}, BSNeo3Constants_1.BSNeo3Constants.NEO_TOKEN), { multichainId: 'neo' }),
|
|
40
|
+
Object.assign(Object.assign({}, BSNeo3Constants_1.BSNeo3Constants.GAS_TOKEN), { multichainId: 'gas', blockchain: service.name }),
|
|
41
|
+
Object.assign(Object.assign({}, BSNeo3Constants_1.BSNeo3Constants.NEO_TOKEN), { multichainId: 'neo', blockchain: service.name }),
|
|
42
42
|
];
|
|
43
43
|
}
|
|
44
44
|
getApprovalFee() {
|
|
@@ -147,37 +147,62 @@ class Neo3NeoXBridgeService {
|
|
|
147
147
|
getNonce(params) {
|
|
148
148
|
var _a, _b;
|
|
149
149
|
return __awaiter(this, void 0, void 0, function* () {
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
150
|
+
let log;
|
|
151
|
+
try {
|
|
152
|
+
log = yield DoraBDSNeo3_1.DoraNeoRest.log(params.transactionHash, __classPrivateFieldGet(this, _Neo3NeoXBridgeService_service, "f").network.id);
|
|
153
|
+
}
|
|
154
|
+
catch (error) {
|
|
155
|
+
throw new blockchain_service_1.BSError('Failed to get nonce from transaction log', 'FAILED_TO_GET_NONCE', error);
|
|
156
|
+
}
|
|
157
|
+
if ((log === null || log === void 0 ? void 0 : log.vmstate) !== 'HALT') {
|
|
158
|
+
throw new blockchain_service_1.BSError('Transaction invalid', 'INVALID_TRANSACTION');
|
|
153
159
|
}
|
|
154
160
|
const isNativeToken = blockchain_service_1.BSTokenHelper.predicateByHash(params.token)(BSNeo3Constants_1.BSNeo3Constants.GAS_TOKEN);
|
|
161
|
+
let nonce = null;
|
|
155
162
|
if (isNativeToken) {
|
|
156
163
|
const notification = log.notifications.find(item => item.event_name === 'NativeDeposit');
|
|
157
|
-
|
|
164
|
+
nonce = (_a = notification === null || notification === void 0 ? void 0 : notification.state.value[0].value) !== null && _a !== void 0 ? _a : null;
|
|
165
|
+
}
|
|
166
|
+
else {
|
|
167
|
+
const notification = log.notifications.find(item => item.event_name === 'TokenDeposit');
|
|
168
|
+
nonce = (_b = notification === null || notification === void 0 ? void 0 : notification.state.value[2].value) !== null && _b !== void 0 ? _b : null;
|
|
169
|
+
}
|
|
170
|
+
if (!nonce) {
|
|
171
|
+
throw new blockchain_service_1.BSError('Nonce not found in transaction log', 'NONCE_NOT_FOUND');
|
|
158
172
|
}
|
|
159
|
-
|
|
160
|
-
return (_b = notification === null || notification === void 0 ? void 0 : notification.state.value[2].value) !== null && _b !== void 0 ? _b : null;
|
|
173
|
+
return nonce;
|
|
161
174
|
});
|
|
162
175
|
}
|
|
163
176
|
getTransactionHashByNonce(params) {
|
|
164
|
-
var _a;
|
|
165
177
|
return __awaiter(this, void 0, void 0, function* () {
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
178
|
+
let data;
|
|
179
|
+
try {
|
|
180
|
+
const isNativeToken = blockchain_service_1.BSTokenHelper.predicateByHash(params.token)(BSNeo3Constants_1.BSNeo3Constants.GAS_TOKEN);
|
|
181
|
+
const response = yield axios_1.default.post('https://neofura.ngd.network', {
|
|
182
|
+
jsonrpc: '2.0',
|
|
183
|
+
method: 'GetBridgeTxByNonce',
|
|
184
|
+
params: {
|
|
185
|
+
ContractHash: this.BRIDGE_SCRIPT_HASH,
|
|
186
|
+
TokenHash: isNativeToken ? '' : BSNeo3Constants_1.BSNeo3Constants.NEO_TOKEN.hash,
|
|
187
|
+
Nonce: Number(params.nonce),
|
|
188
|
+
},
|
|
189
|
+
id: 1,
|
|
190
|
+
});
|
|
191
|
+
data = response.data;
|
|
192
|
+
}
|
|
193
|
+
catch (error) {
|
|
194
|
+
throw new blockchain_service_1.BSError('Failed to get transaction by nonce', 'FAILED_TO_GET_TRANSACTION_BY_NONCE', error);
|
|
195
|
+
}
|
|
177
196
|
if (!(data === null || data === void 0 ? void 0 : data.result)) {
|
|
178
|
-
throw new blockchain_service_1.BSError('
|
|
197
|
+
throw new blockchain_service_1.BSError('Failed to get transaction by nonce', 'FAILED_TO_GET_TRANSACTION_BY_NONCE');
|
|
198
|
+
}
|
|
199
|
+
if (data.result.Vmstate !== 'HALT') {
|
|
200
|
+
throw new blockchain_service_1.BSError('Transaction invalid', 'INVALID_TRANSACTION');
|
|
201
|
+
}
|
|
202
|
+
if (!data.result.txid) {
|
|
203
|
+
throw new blockchain_service_1.BSError('Transaction ID not found in response', 'TXID_NOT_FOUND');
|
|
179
204
|
}
|
|
180
|
-
return data.result.
|
|
205
|
+
return data.result.txid;
|
|
181
206
|
});
|
|
182
207
|
}
|
|
183
208
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cityofzion/bs-neo3",
|
|
3
|
-
"version": "1.15.
|
|
3
|
+
"version": "1.15.4",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"types": "dist/index.d.ts",
|
|
6
6
|
"repository": "https://github.com/CityOfZion/blockchain-services",
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
"isomorphic-ws": "^5.0.0",
|
|
22
22
|
"lodash.clonedeep": "^4.5.0",
|
|
23
23
|
"date-fns": "~4.1.0",
|
|
24
|
-
"@cityofzion/blockchain-service": "1.19.
|
|
24
|
+
"@cityofzion/blockchain-service": "1.19.3",
|
|
25
25
|
"@cityofzion/bs-asteroid-sdk": "0.9.1"
|
|
26
26
|
},
|
|
27
27
|
"devDependencies": {
|