@cityofzion/bs-neo3 3.1.2 → 3.1.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.
Files changed (32) hide show
  1. package/dist/BSNeo3.d.ts +22 -23
  2. package/dist/BSNeo3.js +39 -48
  3. package/dist/helpers/BSNeo3Helper.d.ts +0 -2
  4. package/dist/helpers/BSNeo3Helper.js +0 -11
  5. package/dist/index.d.ts +1 -1
  6. package/dist/index.js +1 -1
  7. package/dist/services/blockchain-data/DoraBDSNeo3.d.ts +5 -11
  8. package/dist/services/blockchain-data/DoraBDSNeo3.js +19 -53
  9. package/dist/services/blockchain-data/RpcBDSNeo3.d.ts +7 -12
  10. package/dist/services/blockchain-data/RpcBDSNeo3.js +71 -84
  11. package/dist/services/claim/ClaimServiceNeo3.d.ts +15 -0
  12. package/dist/services/claim/ClaimServiceNeo3.js +79 -0
  13. package/dist/services/exchange-data/FlamingoForthewinEDSNeo3.d.ts +3 -3
  14. package/dist/services/exchange-data/FlamingoForthewinEDSNeo3.js +2 -3
  15. package/dist/services/explorer/DoraESNeo3.d.ts +2 -2
  16. package/dist/services/explorer/DoraESNeo3.js +1 -2
  17. package/dist/services/full-transactions-data/DoraFullTransactionsDataServiceNeo3.d.ts +3 -3
  18. package/dist/services/full-transactions-data/DoraFullTransactionsDataServiceNeo3.js +38 -31
  19. package/dist/services/ledger/NeonDappKitLedgerServiceNeo3.d.ts +7 -7
  20. package/dist/services/neo3-neox-bridge/Neo3NeoXBridgeService.d.ts +13 -11
  21. package/dist/services/neo3-neox-bridge/Neo3NeoXBridgeService.js +43 -3
  22. package/dist/services/nft-data/GhostMarketNDSNeo3.d.ts +3 -3
  23. package/dist/services/token/TokenServiceNeo3.d.ts +2 -1
  24. package/dist/services/vote/VoteServiceNeo3.d.ts +14 -0
  25. package/dist/services/vote/{DoraVoteServiceNeo3.js → VoteServiceNeo3.js} +54 -44
  26. package/dist/services/wallet-connect/WalletConnectServiceNeo3.d.ts +15 -15
  27. package/dist/services/wallet-connect/WalletConnectServiceNeo3.js +3 -6
  28. package/dist/types.d.ts +20 -8
  29. package/package.json +3 -3
  30. package/dist/services/chaim-data/RpcCDSNeo3.d.ts +0 -7
  31. package/dist/services/chaim-data/RpcCDSNeo3.js +0 -16
  32. package/dist/services/vote/DoraVoteServiceNeo3.d.ts +0 -11
@@ -4,7 +4,7 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
4
4
  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");
5
5
  return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
6
6
  };
7
- var _RpcBDSNeo3_instances, _RpcBDSNeo3_convertByteStringToAddress;
7
+ var _RpcBDSNeo3_instances, _RpcBDSNeo3_convertByteStringToAddress, _RpcBDSNeo3_parseTransferNotification, _RpcBDSNeo3_parseVoteNotification;
8
8
  Object.defineProperty(exports, "__esModule", { value: true });
9
9
  exports.RpcBDSNeo3 = void 0;
10
10
  const blockchain_service_1 = require("@cityofzion/blockchain-service");
@@ -19,88 +19,24 @@ class RpcBDSNeo3 {
19
19
  }
20
20
  async _extractEventsFromNotifications(notifications = []) {
21
21
  const events = [];
22
- const promises = notifications.map(async ({ contract: contractHash, state, eventname }, index) => {
23
- const properties = (Array.isArray(state) ? state : (state?.value ?? []));
24
- if (eventname !== 'Transfer' || (properties.length !== 3 && properties.length !== 4))
25
- return;
26
- const isAsset = properties.length === 3;
27
- const from = properties[0].value;
28
- const to = properties[1].value;
29
- const convertedFrom = from ? __classPrivateFieldGet(this, _RpcBDSNeo3_instances, "m", _RpcBDSNeo3_convertByteStringToAddress).call(this, from) : 'Mint';
30
- const convertedTo = to ? __classPrivateFieldGet(this, _RpcBDSNeo3_instances, "m", _RpcBDSNeo3_convertByteStringToAddress).call(this, to) : 'Burn';
31
- const fromUrl = from ? this._service.explorerService.buildAddressUrl(convertedFrom) : undefined;
32
- const toUrl = to ? this._service.explorerService.buildAddressUrl(convertedTo) : undefined;
33
- if (isAsset) {
34
- const token = await this.getTokenInfo(contractHash);
35
- const amount = properties[2].value || '0';
36
- events.splice(index, 0, {
37
- eventType: 'token',
38
- amount: blockchain_service_1.BSBigNumberHelper.format(blockchain_service_1.BSBigNumberHelper.fromDecimals(amount, token.decimals), {
39
- decimals: token.decimals,
40
- }),
41
- methodName: 'transfer',
42
- from: convertedFrom,
43
- fromUrl,
44
- to: convertedTo,
45
- toUrl,
46
- tokenType: 'nep-17',
47
- tokenUrl: this._service.explorerService.buildContractUrl(token.hash),
48
- token,
49
- });
50
- return;
22
+ const promises = notifications.map(async (notification, index) => {
23
+ const eventName = notification.eventname.toLowerCase();
24
+ if (eventName === 'transfer') {
25
+ const transferEvent = await __classPrivateFieldGet(this, _RpcBDSNeo3_instances, "m", _RpcBDSNeo3_parseTransferNotification).call(this, notification);
26
+ if (transferEvent) {
27
+ events.splice(index, 0, transferEvent);
28
+ }
29
+ }
30
+ if (eventName === 'vote') {
31
+ const voteEvent = __classPrivateFieldGet(this, _RpcBDSNeo3_instances, "m", _RpcBDSNeo3_parseVoteNotification).call(this, notification);
32
+ if (voteEvent) {
33
+ events.splice(index, 0, voteEvent);
34
+ }
51
35
  }
52
- const tokenHash = properties[3].value;
53
- const [nft] = await blockchain_service_1.BSUtilsHelper.tryCatch(() => this._service.nftDataService.getNft({ collectionHash: contractHash, tokenHash }));
54
- events.splice(index, 0, {
55
- eventType: 'nft',
56
- amount: '1',
57
- methodName: 'transfer',
58
- from: convertedFrom,
59
- fromUrl,
60
- to: convertedTo,
61
- toUrl,
62
- tokenType: 'nep-11',
63
- nft,
64
- });
65
36
  });
66
37
  await Promise.allSettled(promises);
67
38
  return events;
68
39
  }
69
- getBridgeNeo3NeoXDataByNotifications(notifications) {
70
- const gasNotification = notifications.find(({ eventname }) => eventname === 'NativeDeposit');
71
- const isNativeToken = !!gasNotification;
72
- const neoNotification = !isNativeToken
73
- ? notifications.find(({ eventname }) => eventname === 'TokenDeposit')
74
- : undefined;
75
- const notification = isNativeToken ? gasNotification : neoNotification;
76
- const notificationStateValue = notification?.state
77
- ?.value;
78
- if (!notificationStateValue)
79
- return undefined;
80
- let tokenToUse;
81
- let amountInDecimals;
82
- let byteStringReceiverAddress;
83
- if (isNativeToken) {
84
- tokenToUse = this._service.neo3NeoXBridgeService.gasToken;
85
- amountInDecimals = notificationStateValue[2]?.value;
86
- byteStringReceiverAddress = notificationStateValue[1]?.value;
87
- }
88
- else {
89
- tokenToUse = this._service.neo3NeoXBridgeService.neoToken;
90
- amountInDecimals = notificationStateValue[4]?.value;
91
- byteStringReceiverAddress = notificationStateValue[3]?.value;
92
- }
93
- if (!tokenToUse || !amountInDecimals || !byteStringReceiverAddress)
94
- return undefined;
95
- const { u } = BSNeo3NeonJsSingletonHelper_1.BSNeo3NeonJsSingletonHelper.getInstance();
96
- return {
97
- amount: blockchain_service_1.BSBigNumberHelper.format(blockchain_service_1.BSBigNumberHelper.fromDecimals(amountInDecimals, tokenToUse.decimals), {
98
- decimals: tokenToUse.decimals,
99
- }),
100
- tokenToUse,
101
- receiverAddress: `0x${u.HexString.fromBase64(byteStringReceiverAddress).toLittleEndian()}`,
102
- };
103
- }
104
40
  async getTransaction(hash) {
105
41
  try {
106
42
  const { rpc } = BSNeo3NeonJsSingletonHelper_1.BSNeo3NeonJsSingletonHelper.getInstance();
@@ -111,7 +47,12 @@ class RpcBDSNeo3 {
111
47
  const events = await this._extractEventsFromNotifications(notifications);
112
48
  const txId = response.hash;
113
49
  const txIdUrl = this._service.explorerService.buildTransactionUrl(txId);
114
- let transaction = {
50
+ const data = {
51
+ ...this._service.neo3NeoXBridgeService._getDataFromNotifications(notifications),
52
+ ...this._service.claimService._getTransactionDataFromEvents(events),
53
+ ...this._service.voteService._getTransactionDataFromEvents(events),
54
+ };
55
+ const transaction = {
115
56
  txId,
116
57
  txIdUrl,
117
58
  block: response.validuntilblock,
@@ -124,14 +65,10 @@ class RpcBDSNeo3 {
124
65
  }),
125
66
  invocationCount: 0,
126
67
  notificationCount: notifications.length,
127
- type: 'default',
128
68
  view: 'default',
129
69
  events,
70
+ data,
130
71
  };
131
- const bridgeNeo3NeoXData = this.getBridgeNeo3NeoXDataByNotifications(notifications);
132
- if (bridgeNeo3NeoXData) {
133
- transaction = { ...transaction, type: 'bridgeNeo3NeoX', data: bridgeNeo3NeoXData };
134
- }
135
72
  return transaction;
136
73
  }
137
74
  catch {
@@ -245,4 +182,54 @@ _RpcBDSNeo3_instances = new WeakSet(), _RpcBDSNeo3_convertByteStringToAddress =
245
182
  const { wallet, u } = BSNeo3NeonJsSingletonHelper_1.BSNeo3NeonJsSingletonHelper.getInstance();
246
183
  const account = new wallet.Account(u.reverseHex(u.HexString.fromBase64(byteString).toString()));
247
184
  return account.address;
185
+ }, _RpcBDSNeo3_parseTransferNotification = async function _RpcBDSNeo3_parseTransferNotification({ contract: contractHash, state, }) {
186
+ const properties = (Array.isArray(state) ? state : (state?.value ?? []));
187
+ if (properties.length !== 3 && properties.length !== 4)
188
+ return;
189
+ const isAsset = properties.length === 3;
190
+ const from = properties[0].value;
191
+ const to = properties[1].value;
192
+ const convertedFrom = from ? __classPrivateFieldGet(this, _RpcBDSNeo3_instances, "m", _RpcBDSNeo3_convertByteStringToAddress).call(this, from) : undefined;
193
+ const convertedTo = to ? __classPrivateFieldGet(this, _RpcBDSNeo3_instances, "m", _RpcBDSNeo3_convertByteStringToAddress).call(this, to) : undefined;
194
+ const fromUrl = convertedFrom ? this._service.explorerService.buildAddressUrl(convertedFrom) : undefined;
195
+ const toUrl = convertedTo ? this._service.explorerService.buildAddressUrl(convertedTo) : undefined;
196
+ if (isAsset) {
197
+ const token = await this.getTokenInfo(contractHash);
198
+ const amount = properties[2].value || '0';
199
+ return {
200
+ eventType: 'token',
201
+ amount: blockchain_service_1.BSBigNumberHelper.format(blockchain_service_1.BSBigNumberHelper.fromDecimals(amount, token.decimals), {
202
+ decimals: token.decimals,
203
+ }),
204
+ methodName: 'transfer',
205
+ from: convertedFrom,
206
+ fromUrl,
207
+ to: convertedTo,
208
+ toUrl,
209
+ tokenUrl: this._service.explorerService.buildContractUrl(contractHash),
210
+ token,
211
+ };
212
+ }
213
+ const tokenHash = properties[3].value;
214
+ const [nft] = await blockchain_service_1.BSUtilsHelper.tryCatch(() => this._service.nftDataService.getNft({ collectionHash: contractHash, tokenHash }));
215
+ return {
216
+ eventType: 'nft',
217
+ amount: '1',
218
+ methodName: 'transfer',
219
+ from: convertedFrom,
220
+ fromUrl,
221
+ to: convertedTo,
222
+ toUrl,
223
+ nft,
224
+ };
225
+ }, _RpcBDSNeo3_parseVoteNotification = function _RpcBDSNeo3_parseVoteNotification({ state }) {
226
+ const properties = (Array.isArray(state) ? state : (state?.value ?? []));
227
+ if (properties.length !== 4)
228
+ return;
229
+ const from = properties[0].value;
230
+ const convertedFrom = __classPrivateFieldGet(this, _RpcBDSNeo3_instances, "m", _RpcBDSNeo3_convertByteStringToAddress).call(this, from);
231
+ const candidatePubKeyBase64 = properties[2].value;
232
+ const { u } = BSNeo3NeonJsSingletonHelper_1.BSNeo3NeonJsSingletonHelper.getInstance();
233
+ const candidate = u.HexString.fromBase64(candidatePubKeyBase64).toString();
234
+ return this._service.voteService._buildTransactionEvent(convertedFrom, candidate);
248
235
  };
@@ -0,0 +1,15 @@
1
+ import type { IBSNeo3, TBSNeo3Name } from '../../types';
2
+ import type { IClaimService, TBSAccount, TClaimServiceTransactionData, TTransaction, TTransactionDefault, TTransactionDefaultEvent, TTransactionDefaultTokenEvent } from '@cityofzion/blockchain-service';
3
+ export declare class ClaimServiceNeo3 implements IClaimService<TBSNeo3Name> {
4
+ #private;
5
+ readonly _service: IBSNeo3;
6
+ claimToken: import("@cityofzion/blockchain-service").TBSToken;
7
+ burnToken: import("@cityofzion/blockchain-service").TBSToken;
8
+ constructor(service: IBSNeo3);
9
+ _getTransactionDataFromEvents(events: TTransactionDefaultEvent[]): TClaimServiceTransactionData | undefined;
10
+ _buildTransactionEvent(address: string): Promise<TTransactionDefaultTokenEvent>;
11
+ getUnclaimed(address: string): Promise<string>;
12
+ calculateFee(senderAccount: TBSAccount<TBSNeo3Name>): Promise<string>;
13
+ claim(senderAccount: TBSAccount<TBSNeo3Name>): Promise<TTransactionDefault>;
14
+ getTransactionData(transaction: TTransaction): TClaimServiceTransactionData | undefined;
15
+ }
@@ -0,0 +1,79 @@
1
+ "use strict";
2
+ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
3
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
4
+ 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");
5
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
6
+ };
7
+ var _ClaimServiceNeo3_instances, _ClaimServiceNeo3_buildClaimParams;
8
+ Object.defineProperty(exports, "__esModule", { value: true });
9
+ exports.ClaimServiceNeo3 = void 0;
10
+ const BSNeo3NeonJsSingletonHelper_1 = require("../../helpers/BSNeo3NeonJsSingletonHelper");
11
+ const BSNeo3Constants_1 = require("../../constants/BSNeo3Constants");
12
+ class ClaimServiceNeo3 {
13
+ constructor(service) {
14
+ _ClaimServiceNeo3_instances.add(this);
15
+ this.claimToken = BSNeo3Constants_1.BSNeo3Constants.GAS_TOKEN;
16
+ this.burnToken = BSNeo3Constants_1.BSNeo3Constants.NEO_TOKEN;
17
+ this._service = service;
18
+ }
19
+ _getTransactionDataFromEvents(events) {
20
+ if (!events?.length)
21
+ return;
22
+ const claimEvent = events.find(event => {
23
+ return (event.eventType === 'token' &&
24
+ event.token?.hash === this.claimToken.hash &&
25
+ event.methodName === 'transfer' &&
26
+ !event.from);
27
+ });
28
+ if (!claimEvent || !claimEvent.amount)
29
+ return;
30
+ const hasBurnEvent = events.some(event => event.eventType === 'token' &&
31
+ event.token?.hash === this.burnToken.hash &&
32
+ event.methodName === 'transfer' &&
33
+ event.from === claimEvent.to);
34
+ if (!hasBurnEvent)
35
+ return;
36
+ return { isClaim: true };
37
+ }
38
+ async _buildTransactionEvent(address) {
39
+ const amount = await this.getUnclaimed(address);
40
+ return {
41
+ eventType: 'token',
42
+ amount,
43
+ methodName: 'transfer',
44
+ to: address,
45
+ toUrl: this._service.explorerService.buildAddressUrl(address),
46
+ tokenUrl: this._service.explorerService.buildContractUrl(this.claimToken.hash),
47
+ token: this.claimToken,
48
+ };
49
+ }
50
+ async getUnclaimed(address) {
51
+ const { rpc, u } = BSNeo3NeonJsSingletonHelper_1.BSNeo3NeonJsSingletonHelper.getInstance();
52
+ const rpcClient = new rpc.RPCClient(this._service.network.url);
53
+ const response = await rpcClient.getUnclaimedGas(address);
54
+ return u.BigInteger.fromNumber(response).toDecimal(this.claimToken.decimals);
55
+ }
56
+ async calculateFee(senderAccount) {
57
+ const claimParams = __classPrivateFieldGet(this, _ClaimServiceNeo3_instances, "m", _ClaimServiceNeo3_buildClaimParams).call(this, senderAccount);
58
+ return this._service.calculateTransferFee(claimParams);
59
+ }
60
+ async claim(senderAccount) {
61
+ const claimParams = __classPrivateFieldGet(this, _ClaimServiceNeo3_instances, "m", _ClaimServiceNeo3_buildClaimParams).call(this, senderAccount);
62
+ const claimEvent = await this._buildTransactionEvent(senderAccount.address);
63
+ const [transaction] = await this._service.transfer(claimParams);
64
+ transaction.events.push(claimEvent);
65
+ const data = { isClaim: true };
66
+ transaction.data = data;
67
+ return transaction;
68
+ }
69
+ getTransactionData(transaction) {
70
+ return transaction.data?.isClaim === true ? transaction.data : undefined;
71
+ }
72
+ }
73
+ exports.ClaimServiceNeo3 = ClaimServiceNeo3;
74
+ _ClaimServiceNeo3_instances = new WeakSet(), _ClaimServiceNeo3_buildClaimParams = function _ClaimServiceNeo3_buildClaimParams(senderAccount) {
75
+ return {
76
+ senderAccount,
77
+ intents: [{ amount: '0', receiverAddress: senderAccount.address, token: this.burnToken }],
78
+ };
79
+ };
@@ -1,7 +1,7 @@
1
1
  import { FlamingoForthewinEDS, type TGetTokenPriceHistoryParams, type TGetTokenPricesParams, type TTokenPricesHistoryResponse, type TTokenPricesResponse } from '@cityofzion/blockchain-service';
2
- import type { IBSNeo3 } from '../../types';
3
- export declare class FlamingoForthewinEDSNeo3<N extends string> extends FlamingoForthewinEDS<N> {
4
- constructor(service: IBSNeo3<N>);
2
+ import type { IBSNeo3, TBSNeo3Name, TBSNeo3NetworkId } from '../../types';
3
+ export declare class FlamingoForthewinEDSNeo3 extends FlamingoForthewinEDS<TBSNeo3Name, TBSNeo3NetworkId> {
4
+ constructor(service: IBSNeo3);
5
5
  getTokenPrices(params: TGetTokenPricesParams): Promise<TTokenPricesResponse[]>;
6
6
  getTokenPriceHistory(params: TGetTokenPriceHistoryParams): Promise<TTokenPricesHistoryResponse[]>;
7
7
  }
@@ -2,18 +2,17 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.FlamingoForthewinEDSNeo3 = void 0;
4
4
  const blockchain_service_1 = require("@cityofzion/blockchain-service");
5
- const BSNeo3Helper_1 = require("../../helpers/BSNeo3Helper");
6
5
  class FlamingoForthewinEDSNeo3 extends blockchain_service_1.FlamingoForthewinEDS {
7
6
  constructor(service) {
8
7
  super(service);
9
8
  }
10
9
  async getTokenPrices(params) {
11
- if (!BSNeo3Helper_1.BSNeo3Helper.isMainnetNetwork(this._service.network))
10
+ if (this._service.network.type !== 'mainnet')
12
11
  throw new Error('Exchange is only available on Mainnet');
13
12
  return await super.getTokenPrices(params);
14
13
  }
15
14
  async getTokenPriceHistory(params) {
16
- if (!BSNeo3Helper_1.BSNeo3Helper.isMainnetNetwork(this._service.network))
15
+ if (this._service.network.type !== 'mainnet')
17
16
  throw new Error('Exchange is only available on Mainnet');
18
17
  return await super.getTokenPriceHistory(params);
19
18
  }
@@ -1,8 +1,8 @@
1
1
  import { type TBuildNftUrlParams, type IExplorerService } from '@cityofzion/blockchain-service';
2
2
  import type { IBSNeo3 } from '../../types';
3
- export declare class DoraESNeo3<N extends string> implements IExplorerService {
3
+ export declare class DoraESNeo3 implements IExplorerService {
4
4
  #private;
5
- constructor(service: IBSNeo3<N>);
5
+ constructor(service: IBSNeo3);
6
6
  buildTransactionUrl(transactionId: string): string | undefined;
7
7
  buildContractUrl(contractHash: string): string | undefined;
8
8
  buildNftUrl({ tokenHash, collectionHash }: TBuildNftUrlParams): string | undefined;
@@ -14,14 +14,13 @@ var _DoraESNeo3_instances, _DoraESNeo3_service, _DoraESNeo3_baseUrl, _DoraESNeo3
14
14
  Object.defineProperty(exports, "__esModule", { value: true });
15
15
  exports.DoraESNeo3 = void 0;
16
16
  const blockchain_service_1 = require("@cityofzion/blockchain-service");
17
- const BSNeo3Helper_1 = require("../../helpers/BSNeo3Helper");
18
17
  class DoraESNeo3 {
19
18
  constructor(service) {
20
19
  _DoraESNeo3_instances.add(this);
21
20
  _DoraESNeo3_service.set(this, void 0);
22
21
  _DoraESNeo3_baseUrl.set(this, void 0);
23
22
  __classPrivateFieldSet(this, _DoraESNeo3_service, service, "f");
24
- if (!BSNeo3Helper_1.BSNeo3Helper.isCustomNetwork(__classPrivateFieldGet(this, _DoraESNeo3_service, "f").network)) {
23
+ if (service.network.type !== 'custom') {
25
24
  __classPrivateFieldSet(this, _DoraESNeo3_baseUrl, blockchain_service_1.BSCommonConstants.DORA_URL, "f");
26
25
  }
27
26
  }
@@ -1,10 +1,10 @@
1
1
  import { type IFullTransactionsDataService, type TExportFullTransactionsByAddressParams, type TGetFullTransactionsByAddressParams, type TGetTransactionsByAddressResponse, type TTransactionDefault } from '@cityofzion/blockchain-service';
2
2
  import type { IBSNeo3, TBSNeo3NetworkId } from '../../types';
3
- export declare class DoraFullTransactionsDataServiceNeo3<N extends string> implements IFullTransactionsDataService<N> {
3
+ export declare class DoraFullTransactionsDataServiceNeo3 implements IFullTransactionsDataService {
4
4
  #private;
5
5
  static readonly SUPPORTED_NEP11_STANDARDS: string[];
6
6
  static readonly SUPPORTED_NETWORKS_IDS: TBSNeo3NetworkId[];
7
- constructor(service: IBSNeo3<N>);
8
- getFullTransactionsByAddress({ nextPageParams, ...params }: TGetFullTransactionsByAddressParams): Promise<TGetTransactionsByAddressResponse<N, TTransactionDefault<N>>>;
7
+ constructor(service: IBSNeo3);
8
+ getFullTransactionsByAddress({ nextPageParams, ...params }: TGetFullTransactionsByAddressParams): Promise<TGetTransactionsByAddressResponse<TTransactionDefault>>;
9
9
  exportFullTransactionsByAddress(params: TExportFullTransactionsByAddressParams): Promise<string>;
10
10
  }
@@ -41,25 +41,9 @@ class DoraFullTransactionsDataServiceNeo3 {
41
41
  const itemPromises = items.map(async ({ networkFeeAmount, systemFeeAmount, ...item }, index) => {
42
42
  const txId = item.transactionID;
43
43
  const txIdUrl = __classPrivateFieldGet(this, _DoraFullTransactionsDataServiceNeo3_service, "f").explorerService.buildTransactionUrl(txId);
44
- let newItem = {
45
- txId,
46
- txIdUrl,
47
- block: item.block,
48
- date: item.date,
49
- invocationCount: item.invocationCount,
50
- notificationCount: item.notificationCount,
51
- networkFeeAmount: networkFeeAmount
52
- ? blockchain_service_1.BSBigNumberHelper.format(networkFeeAmount, { decimals: __classPrivateFieldGet(this, _DoraFullTransactionsDataServiceNeo3_service, "f").feeToken.decimals })
53
- : undefined,
54
- systemFeeAmount: systemFeeAmount
55
- ? blockchain_service_1.BSBigNumberHelper.format(systemFeeAmount, { decimals: __classPrivateFieldGet(this, _DoraFullTransactionsDataServiceNeo3_service, "f").feeToken.decimals })
56
- : undefined,
57
- type: 'default',
58
- view: 'default',
59
- events: [],
60
- };
44
+ const events = [];
61
45
  const eventPromises = item.events.map(async (event, eventIndex) => {
62
- const { methodName, tokenID: tokenHash, contractHash, contractName } = event;
46
+ const { methodName, tokenID: tokenHash, contractHash } = event;
63
47
  const from = event.from || undefined;
64
48
  const to = event.to || undefined;
65
49
  const fromUrl = from ? __classPrivateFieldGet(this, _DoraFullTransactionsDataServiceNeo3_service, "f").explorerService.buildAddressUrl(from) : undefined;
@@ -68,7 +52,7 @@ class DoraFullTransactionsDataServiceNeo3 {
68
52
  const isNft = DoraFullTransactionsDataServiceNeo3.SUPPORTED_NEP11_STANDARDS.includes(standard) && !!tokenHash;
69
53
  if (isNft) {
70
54
  const [nft] = await blockchain_service_1.BSUtilsHelper.tryCatch(() => __classPrivateFieldGet(this, _DoraFullTransactionsDataServiceNeo3_service, "f").nftDataService.getNft({ collectionHash: contractHash, tokenHash }));
71
- newItem.events.splice(eventIndex, 0, {
55
+ events.splice(eventIndex, 0, {
72
56
  eventType: 'nft',
73
57
  amount: '1',
74
58
  methodName,
@@ -76,13 +60,12 @@ class DoraFullTransactionsDataServiceNeo3 {
76
60
  fromUrl,
77
61
  to,
78
62
  toUrl,
79
- tokenType: 'nep-11',
80
63
  nft,
81
64
  });
82
65
  return;
83
66
  }
84
67
  const [token] = await blockchain_service_1.BSUtilsHelper.tryCatch(() => __classPrivateFieldGet(this, _DoraFullTransactionsDataServiceNeo3_service, "f").blockchainDataService.getTokenInfo(contractHash));
85
- newItem.events.splice(eventIndex, 0, {
68
+ events.splice(eventIndex, 0, {
86
69
  eventType: 'token',
87
70
  amount: event.amount
88
71
  ? blockchain_service_1.BSBigNumberHelper.format(event.amount, { decimals: token?.decimals ?? event.tokenDecimals })
@@ -92,21 +75,45 @@ class DoraFullTransactionsDataServiceNeo3 {
92
75
  fromUrl,
93
76
  to,
94
77
  toUrl,
95
- tokenType: 'nep-17',
96
78
  tokenUrl: token ? __classPrivateFieldGet(this, _DoraFullTransactionsDataServiceNeo3_service, "f").explorerService.buildContractUrl(token.hash) : undefined,
97
79
  token,
98
80
  });
99
- if (newItem.type === 'default' && contractName === 'NeoXBridge') {
100
- const [log] = await blockchain_service_1.BSUtilsHelper.tryCatch(() => __classPrivateFieldGet(this, _DoraFullTransactionsDataServiceNeo3_instances, "a", _DoraFullTransactionsDataServiceNeo3_api_get).log(txId, __classPrivateFieldGet(this, _DoraFullTransactionsDataServiceNeo3_service, "f").network.id));
101
- if (!!log && log.vmstate === 'HALT') {
102
- const notifications = log.notifications;
103
- const data = DoraBDSNeo3_1.DoraBDSNeo3.getBridgeNeo3NeoXDataByNotifications(notifications ?? [], __classPrivateFieldGet(this, _DoraFullTransactionsDataServiceNeo3_service, "f"));
104
- if (data)
105
- newItem = { ...newItem, type: 'bridgeNeo3NeoX', data };
106
- }
107
- }
108
81
  });
109
82
  await Promise.allSettled(eventPromises);
83
+ let data = {
84
+ ...__classPrivateFieldGet(this, _DoraFullTransactionsDataServiceNeo3_service, "f").claimService._getTransactionDataFromEvents(events),
85
+ ...__classPrivateFieldGet(this, _DoraFullTransactionsDataServiceNeo3_service, "f").voteService._getTransactionDataFromEvents(events),
86
+ };
87
+ if (item.events.some(event => event.contractName === 'NeoXBridge')) {
88
+ const [log] = await blockchain_service_1.BSUtilsHelper.tryCatch(() => __classPrivateFieldGet(this, _DoraFullTransactionsDataServiceNeo3_instances, "a", _DoraFullTransactionsDataServiceNeo3_api_get).log(txId, __classPrivateFieldGet(this, _DoraFullTransactionsDataServiceNeo3_service, "f").network.id));
89
+ if (log) {
90
+ data = {
91
+ ...data,
92
+ ...__classPrivateFieldGet(this, _DoraFullTransactionsDataServiceNeo3_service, "f").neo3NeoXBridgeService._getDataFromNotifications(log.notifications.map((notification) => ({
93
+ contract: notification.contract,
94
+ eventname: notification.event_name,
95
+ state: notification.state,
96
+ }))),
97
+ };
98
+ }
99
+ }
100
+ const newItem = {
101
+ txId,
102
+ txIdUrl,
103
+ block: item.block,
104
+ date: item.date,
105
+ invocationCount: item.invocationCount,
106
+ notificationCount: item.notificationCount,
107
+ networkFeeAmount: networkFeeAmount
108
+ ? blockchain_service_1.BSBigNumberHelper.format(networkFeeAmount, { decimals: __classPrivateFieldGet(this, _DoraFullTransactionsDataServiceNeo3_service, "f").feeToken.decimals })
109
+ : undefined,
110
+ systemFeeAmount: systemFeeAmount
111
+ ? blockchain_service_1.BSBigNumberHelper.format(systemFeeAmount, { decimals: __classPrivateFieldGet(this, _DoraFullTransactionsDataServiceNeo3_service, "f").feeToken.decimals })
112
+ : undefined,
113
+ view: 'default',
114
+ events,
115
+ data,
116
+ };
110
117
  transactions.splice(index, 0, newItem);
111
118
  });
112
119
  await Promise.allSettled(itemPromises);
@@ -1,14 +1,14 @@
1
1
  import { type TBSAccount, type TGetLedgerTransport, type ILedgerService, type TLedgerServiceEmitter, type TUntilIndexRecord } from '@cityofzion/blockchain-service';
2
2
  import Transport from '@ledgerhq/hw-transport';
3
- import { type IBSNeo3 } from '../../types';
3
+ import { type IBSNeo3, type TBSNeo3Name } from '../../types';
4
4
  import { api } from '../../helpers/BSNeo3NeonJsSingletonHelper';
5
- export declare class NeonDappKitLedgerServiceNeo3<N extends string = string> implements ILedgerService<N> {
5
+ export declare class NeonDappKitLedgerServiceNeo3 implements ILedgerService<TBSNeo3Name> {
6
6
  #private;
7
- readonly getLedgerTransport?: TGetLedgerTransport<N>;
7
+ readonly getLedgerTransport?: TGetLedgerTransport<TBSNeo3Name>;
8
8
  emitter: TLedgerServiceEmitter;
9
- constructor(blockchainService: IBSNeo3<N>, getLedgerTransport?: TGetLedgerTransport<N>);
9
+ constructor(blockchainService: IBSNeo3, getLedgerTransport?: TGetLedgerTransport<TBSNeo3Name>);
10
10
  verifyAppName(transport: Transport): Promise<boolean>;
11
- getAccount(transport: Transport, index: number): Promise<TBSAccount<N>>;
12
- getAccounts(transport: Transport, untilIndexByBlockchainService?: TUntilIndexRecord<N>): Promise<TBSAccount<N>[]>;
13
- getSigningCallback(transport: Transport, account: TBSAccount<N>): api.SigningFunction;
11
+ getAccount(transport: Transport, index: number): Promise<TBSAccount<TBSNeo3Name>>;
12
+ getAccounts(transport: Transport, untilIndexByBlockchainService?: TUntilIndexRecord<TBSNeo3Name>): Promise<TBSAccount<TBSNeo3Name>[]>;
13
+ getSigningCallback(transport: Transport, account: TBSAccount<TBSNeo3Name>): api.SigningFunction;
14
14
  }
@@ -1,15 +1,17 @@
1
- import { INeo3NeoXBridgeService, TBridgeToken, TNeo3NeoXBridgeServiceBridgeParam, TNeo3NeoXBridgeServiceConstants, TNeo3NeoXBridgeServiceGetNonceParams, TNeo3NeoXBridgeServiceGetTransactionHashByNonceParams } from '@cityofzion/blockchain-service';
2
- import type { IBSNeo3 } from '../../types';
3
- export declare class Neo3NeoXBridgeService<N extends string> implements INeo3NeoXBridgeService<N> {
1
+ import { INeo3NeoXBridgeService, TBridgeToken, TNeo3NeoXBridgeServiceBridgeParam, TNeo3NeoXBridgeServiceConstants, TNeo3NeoXBridgeServiceGetNonceParams, TNeo3NeoXBridgeServiceGetTransactionHashByNonceParams, type TNeo3NeoXBridgeTransactionData, type TTransaction } from '@cityofzion/blockchain-service';
2
+ import type { IBSNeo3, TBSNeo3Name, TRpcBDSNeo3Notification } from '../../types';
3
+ export declare class Neo3NeoXBridgeService implements INeo3NeoXBridgeService<TBSNeo3Name> {
4
4
  #private;
5
5
  static readonly BRIDGE_SCRIPT_HASH: string;
6
- readonly gasToken: TBridgeToken<N>;
7
- readonly neoToken: TBridgeToken<N>;
8
- constructor(service: IBSNeo3<N>);
6
+ readonly gasToken: TBridgeToken<TBSNeo3Name>;
7
+ readonly neoToken: TBridgeToken<TBSNeo3Name>;
8
+ constructor(service: IBSNeo3);
9
+ _getDataFromNotifications(notifications: TRpcBDSNeo3Notification[]): TNeo3NeoXBridgeTransactionData<TBSNeo3Name> | undefined;
9
10
  getApprovalFee(): Promise<string>;
10
- getBridgeConstants(token: TBridgeToken<N>): Promise<TNeo3NeoXBridgeServiceConstants>;
11
- bridge(params: TNeo3NeoXBridgeServiceBridgeParam<N>): Promise<string>;
12
- getNonce(params: TNeo3NeoXBridgeServiceGetNonceParams<N>): Promise<string>;
13
- getTransactionHashByNonce(params: TNeo3NeoXBridgeServiceGetTransactionHashByNonceParams<N>): Promise<string>;
14
- getTokenByMultichainId(multichainId: string): TBridgeToken<N> | undefined;
11
+ getBridgeConstants(token: TBridgeToken<TBSNeo3Name>): Promise<TNeo3NeoXBridgeServiceConstants>;
12
+ bridge(params: TNeo3NeoXBridgeServiceBridgeParam<TBSNeo3Name>): Promise<string>;
13
+ getNonce(params: TNeo3NeoXBridgeServiceGetNonceParams<TBSNeo3Name>): Promise<string>;
14
+ getTransactionHashByNonce(params: TNeo3NeoXBridgeServiceGetTransactionHashByNonceParams<TBSNeo3Name>): Promise<string>;
15
+ getTokenByMultichainId(multichainId: string): TBridgeToken<TBSNeo3Name> | undefined;
16
+ getTransactionData(transaction: TTransaction): TNeo3NeoXBridgeTransactionData<TBSNeo3Name> | undefined;
15
17
  }
@@ -19,9 +19,9 @@ exports.Neo3NeoXBridgeService = void 0;
19
19
  const blockchain_service_1 = require("@cityofzion/blockchain-service");
20
20
  const BSNeo3Constants_1 = require("../../constants/BSNeo3Constants");
21
21
  const axios_1 = __importDefault(require("axios"));
22
- const BSNeo3Helper_1 = require("../../helpers/BSNeo3Helper");
23
22
  const DoraBDSNeo3_1 = require("../blockchain-data/DoraBDSNeo3");
24
23
  const BSNeo3NeonDappKitSingletonHelper_1 = require("../../helpers/BSNeo3NeonDappKitSingletonHelper");
24
+ const BSNeo3NeonJsSingletonHelper_1 = require("../../helpers/BSNeo3NeonJsSingletonHelper");
25
25
  class Neo3NeoXBridgeService {
26
26
  constructor(service) {
27
27
  _Neo3NeoXBridgeService_service.set(this, void 0);
@@ -29,6 +29,43 @@ class Neo3NeoXBridgeService {
29
29
  this.gasToken = { ...BSNeo3Constants_1.BSNeo3Constants.GAS_TOKEN, blockchain: service.name, multichainId: 'gas' };
30
30
  this.neoToken = { ...BSNeo3Constants_1.BSNeo3Constants.NEO_TOKEN, blockchain: service.name, multichainId: 'neo' };
31
31
  }
32
+ _getDataFromNotifications(notifications) {
33
+ const gasNotification = notifications.find(({ eventname }) => eventname === 'NativeDeposit');
34
+ const isNativeToken = !!gasNotification;
35
+ const neoNotification = !isNativeToken
36
+ ? notifications.find(({ eventname }) => eventname === 'TokenDeposit')
37
+ : undefined;
38
+ const notification = isNativeToken ? gasNotification : neoNotification;
39
+ const notificationStateValue = notification?.state
40
+ ?.value;
41
+ if (!notificationStateValue)
42
+ return undefined;
43
+ let tokenToUse;
44
+ let amountInDecimals;
45
+ let byteStringReceiverAddress;
46
+ if (isNativeToken) {
47
+ tokenToUse = this.gasToken;
48
+ amountInDecimals = notificationStateValue[2]?.value;
49
+ byteStringReceiverAddress = notificationStateValue[1]?.value;
50
+ }
51
+ else {
52
+ tokenToUse = this.neoToken;
53
+ amountInDecimals = notificationStateValue[4]?.value;
54
+ byteStringReceiverAddress = notificationStateValue[3]?.value;
55
+ }
56
+ if (!tokenToUse || !amountInDecimals || !byteStringReceiverAddress)
57
+ return undefined;
58
+ const { u } = BSNeo3NeonJsSingletonHelper_1.BSNeo3NeonJsSingletonHelper.getInstance();
59
+ return {
60
+ neo3NeoxBridge: {
61
+ amount: blockchain_service_1.BSBigNumberHelper.format(blockchain_service_1.BSBigNumberHelper.fromDecimals(amountInDecimals, tokenToUse.decimals), {
62
+ decimals: tokenToUse.decimals,
63
+ }),
64
+ tokenToUse,
65
+ receiverAddress: `0x${u.HexString.fromBase64(byteStringReceiverAddress).toLittleEndian()}`,
66
+ },
67
+ };
68
+ }
32
69
  async getApprovalFee() {
33
70
  throw new blockchain_service_1.BSError('Neo3 does not require approval', 'APPROVAl_NOT_NEEDED');
34
71
  }
@@ -86,11 +123,11 @@ class Neo3NeoXBridgeService {
86
123
  };
87
124
  }
88
125
  async bridge(params) {
89
- if (!BSNeo3Helper_1.BSNeo3Helper.isMainnetNetwork(__classPrivateFieldGet(this, _Neo3NeoXBridgeService_service, "f").network)) {
126
+ if (__classPrivateFieldGet(this, _Neo3NeoXBridgeService_service, "f").network.type !== 'mainnet') {
90
127
  throw new blockchain_service_1.BSError('Bridging to NeoX is only supported on mainnet', 'UNSUPPORTED_NETWORK');
91
128
  }
92
129
  const { account } = params;
93
- const { neonJsAccount, signingCallback } = await __classPrivateFieldGet(this, _Neo3NeoXBridgeService_service, "f").generateSigningCallback(account);
130
+ const { neonJsAccount, signingCallback } = await __classPrivateFieldGet(this, _Neo3NeoXBridgeService_service, "f")._generateSigningCallback(account);
94
131
  const { NeonInvoker } = BSNeo3NeonDappKitSingletonHelper_1.BSNeo3NeonDappKitSingletonHelper.getInstance();
95
132
  const invoker = await NeonInvoker.init({
96
133
  rpcAddress: __classPrivateFieldGet(this, _Neo3NeoXBridgeService_service, "f").network.url,
@@ -194,6 +231,9 @@ class Neo3NeoXBridgeService {
194
231
  const tokens = [this.gasToken, this.neoToken];
195
232
  return tokens.find(token => token.multichainId === multichainId);
196
233
  }
234
+ getTransactionData(transaction) {
235
+ return transaction.data?.neo3NeoxBridge ? transaction.data : undefined;
236
+ }
197
237
  }
198
238
  exports.Neo3NeoXBridgeService = Neo3NeoXBridgeService;
199
239
  _Neo3NeoXBridgeService_service = new WeakMap();
@@ -1,8 +1,8 @@
1
1
  import { GhostMarketNDS, type THasTokenParams } from '@cityofzion/blockchain-service';
2
- import type { IBSNeo3, TBSNeo3NetworkId } from '../../types';
3
- export declare class GhostMarketNDSNeo3<N extends string> extends GhostMarketNDS<N, TBSNeo3NetworkId, IBSNeo3<N>> {
2
+ import type { IBSNeo3, TBSNeo3Name, TBSNeo3NetworkId } from '../../types';
3
+ export declare class GhostMarketNDSNeo3 extends GhostMarketNDS<TBSNeo3Name, TBSNeo3NetworkId, IBSNeo3> {
4
4
  static readonly CHAIN_BY_NETWORK_ID: Record<TBSNeo3NetworkId, string>;
5
- constructor(service: IBSNeo3<N>);
5
+ constructor(service: IBSNeo3);
6
6
  hasToken({ address, collectionHash }: THasTokenParams): Promise<boolean>;
7
7
  getChain(): string;
8
8
  }
@@ -1,4 +1,5 @@
1
1
  import { TokenService } from '@cityofzion/blockchain-service';
2
- export declare class TokenServiceNeo3 extends TokenService {
2
+ import type { TBSNeo3Name, TBSNeo3NetworkId } from '../../types';
3
+ export declare class TokenServiceNeo3 extends TokenService<TBSNeo3Name, TBSNeo3NetworkId> {
3
4
  normalizeHash(hash: string): string;
4
5
  }