@cityofzion/bs-neo3 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/BSNeo3.d.ts +22 -23
- package/dist/BSNeo3.js +39 -48
- package/dist/helpers/BSNeo3Helper.d.ts +0 -2
- package/dist/helpers/BSNeo3Helper.js +0 -11
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/services/blockchain-data/DoraBDSNeo3.d.ts +5 -11
- package/dist/services/blockchain-data/DoraBDSNeo3.js +19 -53
- package/dist/services/blockchain-data/RpcBDSNeo3.d.ts +7 -12
- package/dist/services/blockchain-data/RpcBDSNeo3.js +71 -84
- package/dist/services/claim/ClaimServiceNeo3.d.ts +15 -0
- package/dist/services/claim/ClaimServiceNeo3.js +79 -0
- package/dist/services/exchange-data/FlamingoForthewinEDSNeo3.d.ts +3 -3
- package/dist/services/exchange-data/FlamingoForthewinEDSNeo3.js +2 -3
- package/dist/services/explorer/DoraESNeo3.d.ts +2 -2
- package/dist/services/explorer/DoraESNeo3.js +1 -2
- package/dist/services/full-transactions-data/DoraFullTransactionsDataServiceNeo3.d.ts +3 -3
- package/dist/services/full-transactions-data/DoraFullTransactionsDataServiceNeo3.js +38 -31
- package/dist/services/ledger/NeonDappKitLedgerServiceNeo3.d.ts +7 -7
- package/dist/services/neo3-neox-bridge/Neo3NeoXBridgeService.d.ts +13 -11
- package/dist/services/neo3-neox-bridge/Neo3NeoXBridgeService.js +43 -3
- package/dist/services/nft-data/GhostMarketNDSNeo3.d.ts +3 -3
- package/dist/services/token/TokenServiceNeo3.d.ts +2 -1
- package/dist/services/vote/VoteServiceNeo3.d.ts +14 -0
- package/dist/services/vote/{DoraVoteServiceNeo3.js → VoteServiceNeo3.js} +54 -44
- package/dist/services/wallet-connect/WalletConnectServiceNeo3.d.ts +15 -15
- package/dist/services/wallet-connect/WalletConnectServiceNeo3.js +3 -6
- package/dist/types.d.ts +20 -8
- package/package.json +3 -3
- package/dist/services/chaim-data/RpcCDSNeo3.d.ts +0 -7
- package/dist/services/chaim-data/RpcCDSNeo3.js +0 -16
- package/dist/services/vote/DoraVoteServiceNeo3.d.ts +0 -11
package/dist/BSNeo3.d.ts
CHANGED
|
@@ -1,37 +1,38 @@
|
|
|
1
|
-
import { type IBlockchainDataService, type
|
|
1
|
+
import { type IBlockchainDataService, type IExchangeDataService, type IExplorerService, type INftDataService, type ITokenService, type IWalletConnectService, type TBSAccount, type TBSNetwork, type TBSToken, type TGetLedgerTransport, type TPingNetworkResponse, type TTransferParams, type IFullTransactionsDataService, type TTransactionDefault } from '@cityofzion/blockchain-service';
|
|
2
2
|
import { NeonDappKitLedgerServiceNeo3 } from './services/ledger/NeonDappKitLedgerServiceNeo3';
|
|
3
|
-
import
|
|
3
|
+
import { Neo3NeoXBridgeService } from './services/neo3-neox-bridge/Neo3NeoXBridgeService';
|
|
4
|
+
import { VoteServiceNeo3 } from './services/vote/VoteServiceNeo3';
|
|
5
|
+
import type { IBSNeo3, TBSNeo3Name, TBSNeo3NetworkId } from './types';
|
|
4
6
|
import { api, wallet } from './helpers/BSNeo3NeonJsSingletonHelper';
|
|
5
|
-
|
|
7
|
+
import { ClaimServiceNeo3 } from './services/claim/ClaimServiceNeo3';
|
|
8
|
+
export declare class BSNeo3 implements IBSNeo3 {
|
|
6
9
|
#private;
|
|
7
|
-
readonly name
|
|
10
|
+
readonly name = "neo3";
|
|
8
11
|
readonly bipDerivationPath: string;
|
|
9
12
|
readonly isMultiTransferSupported = true;
|
|
10
13
|
readonly isCustomNetworkSupported = true;
|
|
11
14
|
tokens: TBSToken[];
|
|
12
15
|
readonly nativeTokens: TBSToken[];
|
|
13
16
|
readonly feeToken: TBSToken;
|
|
14
|
-
readonly claimToken: TBSToken;
|
|
15
|
-
readonly burnToken: TBSToken;
|
|
16
17
|
network: TBSNetwork<TBSNeo3NetworkId>;
|
|
17
18
|
networkUrls: string[];
|
|
18
19
|
readonly defaultNetwork: TBSNetwork<TBSNeo3NetworkId>;
|
|
19
20
|
readonly availableNetworks: TBSNetwork<TBSNeo3NetworkId>[];
|
|
20
|
-
blockchainDataService: IBlockchainDataService
|
|
21
|
+
blockchainDataService: IBlockchainDataService;
|
|
21
22
|
nftDataService: INftDataService;
|
|
22
|
-
ledgerService: NeonDappKitLedgerServiceNeo3
|
|
23
|
+
ledgerService: NeonDappKitLedgerServiceNeo3;
|
|
23
24
|
exchangeDataService: IExchangeDataService;
|
|
24
25
|
explorerService: IExplorerService;
|
|
25
|
-
voteService:
|
|
26
|
-
neo3NeoXBridgeService:
|
|
26
|
+
voteService: VoteServiceNeo3;
|
|
27
|
+
neo3NeoXBridgeService: Neo3NeoXBridgeService;
|
|
27
28
|
tokenService: ITokenService;
|
|
28
|
-
|
|
29
|
-
walletConnectService: IWalletConnectService<
|
|
30
|
-
fullTransactionsDataService: IFullTransactionsDataService
|
|
31
|
-
constructor(
|
|
29
|
+
claimService: ClaimServiceNeo3;
|
|
30
|
+
walletConnectService: IWalletConnectService<TBSNeo3Name>;
|
|
31
|
+
fullTransactionsDataService: IFullTransactionsDataService;
|
|
32
|
+
constructor(network?: TBSNetwork<TBSNeo3NetworkId>, getLedgerTransport?: TGetLedgerTransport<TBSNeo3Name>);
|
|
32
33
|
setNetwork(network: TBSNetwork<TBSNeo3NetworkId>): void;
|
|
33
34
|
pingNetwork(url: string): Promise<TPingNetworkResponse>;
|
|
34
|
-
|
|
35
|
+
_generateSigningCallback(account: TBSAccount<TBSNeo3Name>): Promise<{
|
|
35
36
|
neonJsAccount: wallet.Account;
|
|
36
37
|
signingCallback: api.SigningFunction;
|
|
37
38
|
}>;
|
|
@@ -39,14 +40,12 @@ export declare class BSNeo3<N extends string = string> implements IBSNeo3<N> {
|
|
|
39
40
|
validateEncrypted(encryptedKey: string): boolean;
|
|
40
41
|
validateKey(key: string): boolean;
|
|
41
42
|
validateNameServiceDomainFormat(domainName: string): boolean;
|
|
42
|
-
generateAccountFromMnemonic(mnemonic: string[] | string, index: number): Promise<TBSAccount<
|
|
43
|
-
generateAccountFromPublicKey(publicKey: string): Promise<TBSAccount<
|
|
44
|
-
generateAccountFromKey(key: string): Promise<TBSAccount<
|
|
45
|
-
decrypt(encryptedKey: string, password: string): Promise<TBSAccount<
|
|
43
|
+
generateAccountFromMnemonic(mnemonic: string[] | string, index: number): Promise<TBSAccount<TBSNeo3Name>>;
|
|
44
|
+
generateAccountFromPublicKey(publicKey: string): Promise<TBSAccount<TBSNeo3Name>>;
|
|
45
|
+
generateAccountFromKey(key: string): Promise<TBSAccount<TBSNeo3Name>>;
|
|
46
|
+
decrypt(encryptedKey: string, password: string): Promise<TBSAccount<TBSNeo3Name>>;
|
|
46
47
|
encrypt(key: string, password: string): Promise<string>;
|
|
47
|
-
calculateTransferFee(params: TTransferParams<
|
|
48
|
-
transfer(params: TTransferParams<
|
|
49
|
-
calculateClaimFee(senderAccount: TBSAccount<N>): Promise<string>;
|
|
50
|
-
claim(senderAccount: TBSAccount<N>): Promise<TTransactionDefault<N>>;
|
|
48
|
+
calculateTransferFee(params: TTransferParams<TBSNeo3Name>): Promise<string>;
|
|
49
|
+
transfer(params: TTransferParams<TBSNeo3Name>): Promise<TTransactionDefault[]>;
|
|
51
50
|
resolveNameServiceDomain(domainName: string): Promise<string>;
|
|
52
51
|
}
|
package/dist/BSNeo3.js
CHANGED
|
@@ -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 _BSNeo3_instances, _BSNeo3_setTokens, _BSNeo3_buildTransferInvocation
|
|
10
|
+
var _BSNeo3_instances, _BSNeo3_setTokens, _BSNeo3_buildTransferInvocation;
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
exports.BSNeo3 = void 0;
|
|
13
13
|
const blockchain_service_1 = require("@cityofzion/blockchain-service");
|
|
@@ -19,26 +19,24 @@ const NeonDappKitLedgerServiceNeo3_1 = require("./services/ledger/NeonDappKitLed
|
|
|
19
19
|
const GhostMarketNDSNeo3_1 = require("./services/nft-data/GhostMarketNDSNeo3");
|
|
20
20
|
const BSNeo3Constants_1 = require("./constants/BSNeo3Constants");
|
|
21
21
|
const Neo3NeoXBridgeService_1 = require("./services/neo3-neox-bridge/Neo3NeoXBridgeService");
|
|
22
|
-
const
|
|
22
|
+
const VoteServiceNeo3_1 = require("./services/vote/VoteServiceNeo3");
|
|
23
23
|
const TokenServiceNeo3_1 = require("./services/token/TokenServiceNeo3");
|
|
24
|
-
const RpcCDSNeo3_1 = require("./services/chaim-data/RpcCDSNeo3");
|
|
25
24
|
const BSNeo3NeonJsSingletonHelper_1 = require("./helpers/BSNeo3NeonJsSingletonHelper");
|
|
26
25
|
const BSNeo3NeonDappKitSingletonHelper_1 = require("./helpers/BSNeo3NeonDappKitSingletonHelper");
|
|
27
26
|
const axios_1 = __importDefault(require("axios"));
|
|
28
27
|
const WalletConnectServiceNeo3_1 = require("./services/wallet-connect/WalletConnectServiceNeo3");
|
|
29
28
|
const DoraFullTransactionsDataServiceNeo3_1 = require("./services/full-transactions-data/DoraFullTransactionsDataServiceNeo3");
|
|
29
|
+
const ClaimServiceNeo3_1 = require("./services/claim/ClaimServiceNeo3");
|
|
30
30
|
class BSNeo3 {
|
|
31
|
-
constructor(
|
|
31
|
+
constructor(network, getLedgerTransport) {
|
|
32
32
|
_BSNeo3_instances.add(this);
|
|
33
|
+
this.name = 'neo3';
|
|
33
34
|
this.isMultiTransferSupported = true;
|
|
34
35
|
this.isCustomNetworkSupported = true;
|
|
35
|
-
this.name = name;
|
|
36
36
|
this.ledgerService = new NeonDappKitLedgerServiceNeo3_1.NeonDappKitLedgerServiceNeo3(this, getLedgerTransport);
|
|
37
37
|
this.bipDerivationPath = BSNeo3Constants_1.BSNeo3Constants.DEFAULT_BIP_DERIVATION_PATH;
|
|
38
38
|
this.nativeTokens = BSNeo3Constants_1.BSNeo3Constants.NATIVE_ASSETS;
|
|
39
39
|
this.feeToken = BSNeo3Constants_1.BSNeo3Constants.GAS_TOKEN;
|
|
40
|
-
this.burnToken = BSNeo3Constants_1.BSNeo3Constants.NEO_TOKEN;
|
|
41
|
-
this.claimToken = BSNeo3Constants_1.BSNeo3Constants.GAS_TOKEN;
|
|
42
40
|
this.availableNetworks = BSNeo3Constants_1.BSNeo3Constants.ALL_NETWORKS;
|
|
43
41
|
this.defaultNetwork = BSNeo3Constants_1.BSNeo3Constants.MAINNET_NETWORK;
|
|
44
42
|
this.setNetwork(network ?? this.defaultNetwork);
|
|
@@ -59,14 +57,14 @@ class BSNeo3 {
|
|
|
59
57
|
__classPrivateFieldGet(this, _BSNeo3_instances, "m", _BSNeo3_setTokens).call(this, network);
|
|
60
58
|
this.network = network;
|
|
61
59
|
this.networkUrls = networkUrls;
|
|
62
|
-
this.tokenService = new TokenServiceNeo3_1.TokenServiceNeo3();
|
|
60
|
+
this.tokenService = new TokenServiceNeo3_1.TokenServiceNeo3(this);
|
|
63
61
|
this.nftDataService = new GhostMarketNDSNeo3_1.GhostMarketNDSNeo3(this);
|
|
64
62
|
this.explorerService = new DoraESNeo3_1.DoraESNeo3(this);
|
|
65
|
-
this.voteService = new
|
|
63
|
+
this.voteService = new VoteServiceNeo3_1.VoteServiceNeo3(this);
|
|
66
64
|
this.neo3NeoXBridgeService = new Neo3NeoXBridgeService_1.Neo3NeoXBridgeService(this);
|
|
67
65
|
this.blockchainDataService = new DoraBDSNeo3_1.DoraBDSNeo3(this);
|
|
68
66
|
this.exchangeDataService = new FlamingoForthewinEDSNeo3_1.FlamingoForthewinEDSNeo3(this);
|
|
69
|
-
this.
|
|
67
|
+
this.claimService = new ClaimServiceNeo3_1.ClaimServiceNeo3(this);
|
|
70
68
|
this.walletConnectService = new WalletConnectServiceNeo3_1.WalletConnectServiceNeo3(this);
|
|
71
69
|
this.fullTransactionsDataService = new DoraFullTransactionsDataServiceNeo3_1.DoraFullTransactionsDataServiceNeo3(this);
|
|
72
70
|
}
|
|
@@ -91,7 +89,7 @@ class BSNeo3 {
|
|
|
91
89
|
height: response.data.result,
|
|
92
90
|
};
|
|
93
91
|
}
|
|
94
|
-
async
|
|
92
|
+
async _generateSigningCallback(account) {
|
|
95
93
|
const { wallet, api } = BSNeo3NeonJsSingletonHelper_1.BSNeo3NeonJsSingletonHelper.getInstance();
|
|
96
94
|
const neonJsAccount = new wallet.Account(account.key);
|
|
97
95
|
if (account.isHardware) {
|
|
@@ -171,7 +169,7 @@ class BSNeo3 {
|
|
|
171
169
|
return await wallet.encrypt(key, password);
|
|
172
170
|
}
|
|
173
171
|
async calculateTransferFee(params) {
|
|
174
|
-
const { neonJsAccount } = await this.
|
|
172
|
+
const { neonJsAccount } = await this._generateSigningCallback(params.senderAccount);
|
|
175
173
|
const { NeonInvoker } = BSNeo3NeonDappKitSingletonHelper_1.BSNeo3NeonDappKitSingletonHelper.getInstance();
|
|
176
174
|
const invoker = await NeonInvoker.init({
|
|
177
175
|
rpcAddress: this.network.url,
|
|
@@ -186,19 +184,39 @@ class BSNeo3 {
|
|
|
186
184
|
}
|
|
187
185
|
async transfer(params) {
|
|
188
186
|
const { senderAccount } = params;
|
|
189
|
-
const { neonJsAccount, signingCallback } = await this.
|
|
187
|
+
const { neonJsAccount, signingCallback } = await this._generateSigningCallback(senderAccount);
|
|
190
188
|
const { NeonInvoker } = BSNeo3NeonDappKitSingletonHelper_1.BSNeo3NeonDappKitSingletonHelper.getInstance();
|
|
189
|
+
// Verify if the transfer includes any NEO token, if so the chain will automatically claim the GAS for the sender
|
|
190
|
+
let data;
|
|
191
|
+
let claimEvent = undefined;
|
|
192
|
+
if (params.intents.some(intent => this.tokenService.predicateByHash(intent.token.hash, BSNeo3Constants_1.BSNeo3Constants.NEO_TOKEN))) {
|
|
193
|
+
claimEvent = await this.claimService._buildTransactionEvent(senderAccount.address);
|
|
194
|
+
data = { isClaim: true };
|
|
195
|
+
}
|
|
196
|
+
const { address } = senderAccount;
|
|
197
|
+
const invocations = await __classPrivateFieldGet(this, _BSNeo3_instances, "m", _BSNeo3_buildTransferInvocation).call(this, params, neonJsAccount);
|
|
198
|
+
const invocationMulti = { invocations, signers: [] };
|
|
191
199
|
const invoker = await NeonInvoker.init({
|
|
192
200
|
rpcAddress: this.network.url,
|
|
193
201
|
account: neonJsAccount,
|
|
194
202
|
signingCallback: signingCallback,
|
|
195
203
|
});
|
|
196
|
-
const
|
|
197
|
-
const
|
|
198
|
-
const
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
204
|
+
const fees = await invoker.calculateFee(invocationMulti);
|
|
205
|
+
const txId = await invoker.invokeFunction(invocationMulti);
|
|
206
|
+
const events = params.intents.map(({ receiverAddress, amount, token }) => ({
|
|
207
|
+
eventType: 'token',
|
|
208
|
+
amount,
|
|
209
|
+
methodName: 'transfer',
|
|
210
|
+
from: address,
|
|
211
|
+
fromUrl: this.explorerService.buildAddressUrl(address),
|
|
212
|
+
to: receiverAddress,
|
|
213
|
+
toUrl: this.explorerService.buildAddressUrl(receiverAddress),
|
|
214
|
+
tokenUrl: this.explorerService.buildContractUrl(token.hash),
|
|
215
|
+
token,
|
|
216
|
+
}));
|
|
217
|
+
if (claimEvent) {
|
|
218
|
+
events.unshift(claimEvent);
|
|
219
|
+
}
|
|
202
220
|
return [
|
|
203
221
|
{
|
|
204
222
|
txId,
|
|
@@ -207,34 +225,12 @@ class BSNeo3 {
|
|
|
207
225
|
invocationCount: invocations.length,
|
|
208
226
|
networkFeeAmount: blockchain_service_1.BSBigNumberHelper.format(fees.networkFee, { decimals: this.feeToken.decimals }),
|
|
209
227
|
systemFeeAmount: blockchain_service_1.BSBigNumberHelper.format(fees.systemFee, { decimals: this.feeToken.decimals }),
|
|
210
|
-
type: 'default',
|
|
211
228
|
view: 'default',
|
|
212
|
-
events
|
|
213
|
-
|
|
214
|
-
return {
|
|
215
|
-
eventType: 'token',
|
|
216
|
-
amount,
|
|
217
|
-
methodName: 'transfer',
|
|
218
|
-
from: address,
|
|
219
|
-
fromUrl: addressUrl,
|
|
220
|
-
to: receiverAddress,
|
|
221
|
-
toUrl: this.explorerService.buildAddressUrl(receiverAddress),
|
|
222
|
-
tokenType: 'nep-17',
|
|
223
|
-
tokenUrl: this.explorerService.buildContractUrl(tokenHash),
|
|
224
|
-
token,
|
|
225
|
-
};
|
|
226
|
-
}),
|
|
229
|
+
events,
|
|
230
|
+
data,
|
|
227
231
|
},
|
|
228
232
|
];
|
|
229
233
|
}
|
|
230
|
-
async calculateClaimFee(senderAccount) {
|
|
231
|
-
return this.calculateTransferFee(__classPrivateFieldGet(this, _BSNeo3_instances, "m", _BSNeo3_buildClaimParams).call(this, senderAccount));
|
|
232
|
-
}
|
|
233
|
-
async claim(senderAccount) {
|
|
234
|
-
const [transaction] = await this.transfer(__classPrivateFieldGet(this, _BSNeo3_instances, "m", _BSNeo3_buildClaimParams).call(this, senderAccount));
|
|
235
|
-
transaction.type = 'claim';
|
|
236
|
-
return transaction;
|
|
237
|
-
}
|
|
238
234
|
async resolveNameServiceDomain(domainName) {
|
|
239
235
|
const { NeonParser, NeonInvoker } = BSNeo3NeonDappKitSingletonHelper_1.BSNeo3NeonDappKitSingletonHelper.getInstance();
|
|
240
236
|
const invoker = await NeonInvoker.init({ rpcAddress: this.network.url });
|
|
@@ -278,9 +274,4 @@ _BSNeo3_instances = new WeakSet(), _BSNeo3_setTokens = function _BSNeo3_setToken
|
|
|
278
274
|
});
|
|
279
275
|
}
|
|
280
276
|
return invocations;
|
|
281
|
-
}, _BSNeo3_buildClaimParams = function _BSNeo3_buildClaimParams(senderAccount) {
|
|
282
|
-
return {
|
|
283
|
-
senderAccount,
|
|
284
|
-
intents: [{ amount: '0', receiverAddress: senderAccount.address, token: this.burnToken }],
|
|
285
|
-
};
|
|
286
277
|
};
|
|
@@ -2,6 +2,4 @@ import type { TBSNetwork } from '@cityofzion/blockchain-service';
|
|
|
2
2
|
import type { TBSNeo3NetworkId } from '../types';
|
|
3
3
|
export declare class BSNeo3Helper {
|
|
4
4
|
static getTokens(network: TBSNetwork<TBSNeo3NetworkId>): import("@cityofzion/blockchain-service").TBSToken[];
|
|
5
|
-
static isCustomNetwork(network: TBSNetwork<TBSNeo3NetworkId>): boolean;
|
|
6
|
-
static isMainnetNetwork(network: TBSNetwork<TBSNeo3NetworkId>): boolean;
|
|
7
5
|
}
|
|
@@ -7,16 +7,5 @@ class BSNeo3Helper {
|
|
|
7
7
|
const extraTokens = BSNeo3Constants_1.BSNeo3Constants.EXTRA_TOKENS_BY_NETWORK_ID[network.id] ?? [];
|
|
8
8
|
return [...extraTokens, ...BSNeo3Constants_1.BSNeo3Constants.NATIVE_ASSETS];
|
|
9
9
|
}
|
|
10
|
-
static isCustomNetwork(network) {
|
|
11
|
-
if (network.type === 'custom')
|
|
12
|
-
return true;
|
|
13
|
-
const knownNetwork = BSNeo3Constants_1.BSNeo3Constants.ALL_NETWORKS.find(n => n.id === network.id);
|
|
14
|
-
if (!knownNetwork)
|
|
15
|
-
return true;
|
|
16
|
-
return false;
|
|
17
|
-
}
|
|
18
|
-
static isMainnetNetwork(network) {
|
|
19
|
-
return network.id === BSNeo3Constants_1.BSNeo3Constants.MAINNET_NETWORK.id && network.type === 'mainnet';
|
|
20
|
-
}
|
|
21
10
|
}
|
|
22
11
|
exports.BSNeo3Helper = BSNeo3Helper;
|
package/dist/index.d.ts
CHANGED
|
@@ -9,7 +9,7 @@ export * from './services/exchange-data/FlamingoForthewinEDSNeo3';
|
|
|
9
9
|
export * from './services/explorer/DoraESNeo3';
|
|
10
10
|
export * from './services/ledger/NeonDappKitLedgerServiceNeo3';
|
|
11
11
|
export * from './services/nft-data/GhostMarketNDSNeo3';
|
|
12
|
-
export * from './services/vote/
|
|
12
|
+
export * from './services/vote/VoteServiceNeo3';
|
|
13
13
|
export * from './services/neo3-neox-bridge/Neo3NeoXBridgeService';
|
|
14
14
|
export * from './services/token/TokenServiceNeo3';
|
|
15
15
|
export * from './services/wallet-connect/WalletConnectServiceNeo3';
|
package/dist/index.js
CHANGED
|
@@ -25,7 +25,7 @@ __exportStar(require("./services/exchange-data/FlamingoForthewinEDSNeo3"), expor
|
|
|
25
25
|
__exportStar(require("./services/explorer/DoraESNeo3"), exports);
|
|
26
26
|
__exportStar(require("./services/ledger/NeonDappKitLedgerServiceNeo3"), exports);
|
|
27
27
|
__exportStar(require("./services/nft-data/GhostMarketNDSNeo3"), exports);
|
|
28
|
-
__exportStar(require("./services/vote/
|
|
28
|
+
__exportStar(require("./services/vote/VoteServiceNeo3"), exports);
|
|
29
29
|
__exportStar(require("./services/neo3-neox-bridge/Neo3NeoXBridgeService"), exports);
|
|
30
30
|
__exportStar(require("./services/token/TokenServiceNeo3"), exports);
|
|
31
31
|
__exportStar(require("./services/wallet-connect/WalletConnectServiceNeo3"), exports);
|
|
@@ -1,19 +1,13 @@
|
|
|
1
|
-
import { type TBalanceResponse, type TBSToken, type
|
|
1
|
+
import { type TBalanceResponse, type TBSToken, type TGetTransactionsByAddressParams, type TGetTransactionsByAddressResponse, type TContractResponse, type TTransactionDefault } from '@cityofzion/blockchain-service';
|
|
2
2
|
import { api } from '@cityofzion/dora-ts';
|
|
3
3
|
import { RpcBDSNeo3 } from './RpcBDSNeo3';
|
|
4
4
|
import type { IBSNeo3 } from '../../types';
|
|
5
|
-
|
|
6
|
-
export declare class DoraBDSNeo3<N extends string> extends RpcBDSNeo3<N> {
|
|
5
|
+
export declare class DoraBDSNeo3 extends RpcBDSNeo3 {
|
|
7
6
|
#private;
|
|
8
7
|
static getClient(): api.NeoRESTApi;
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
receiverAddress: string;
|
|
13
|
-
} | undefined;
|
|
14
|
-
constructor(service: IBSNeo3<N>);
|
|
15
|
-
getTransaction(hash: string): Promise<TTransactionDefault<N>>;
|
|
16
|
-
getTransactionsByAddress({ address, nextPageParams, }: TGetTransactionsByAddressParams): Promise<TGetTransactionsByAddressResponse<N, TTransactionDefault<N>>>;
|
|
8
|
+
constructor(service: IBSNeo3);
|
|
9
|
+
getTransaction(hash: string): Promise<TTransactionDefault>;
|
|
10
|
+
getTransactionsByAddress({ address, nextPageParams, }: TGetTransactionsByAddressParams): Promise<TGetTransactionsByAddressResponse<TTransactionDefault>>;
|
|
17
11
|
getContract(contractHash: string): Promise<TContractResponse>;
|
|
18
12
|
getTokenInfo(tokenHash: string): Promise<TBSToken>;
|
|
19
13
|
getBalance(address: string): Promise<TBalanceResponse[]>;
|
|
@@ -16,53 +16,17 @@ exports.DoraBDSNeo3 = void 0;
|
|
|
16
16
|
const blockchain_service_1 = require("@cityofzion/blockchain-service");
|
|
17
17
|
const dora_ts_1 = require("@cityofzion/dora-ts");
|
|
18
18
|
const RpcBDSNeo3_1 = require("./RpcBDSNeo3");
|
|
19
|
-
const BSNeo3Helper_1 = require("../../helpers/BSNeo3Helper");
|
|
20
|
-
const BSNeo3NeonJsSingletonHelper_1 = require("../../helpers/BSNeo3NeonJsSingletonHelper");
|
|
21
19
|
class DoraBDSNeo3 extends RpcBDSNeo3_1.RpcBDSNeo3 {
|
|
22
20
|
static getClient() {
|
|
23
21
|
return new dora_ts_1.api.NeoRESTApi({ url: blockchain_service_1.BSCommonConstants.COZ_API_URL, endpoint: '/api/v2/neo3' });
|
|
24
22
|
}
|
|
25
|
-
static getBridgeNeo3NeoXDataByNotifications(notifications, service) {
|
|
26
|
-
const gasNotification = notifications.find(({ event_name }) => event_name === 'NativeDeposit');
|
|
27
|
-
const isNativeToken = !!gasNotification;
|
|
28
|
-
const neoNotification = !isNativeToken
|
|
29
|
-
? notifications.find(({ event_name }) => event_name === 'TokenDeposit')
|
|
30
|
-
: undefined;
|
|
31
|
-
const notification = isNativeToken ? gasNotification : neoNotification;
|
|
32
|
-
const notificationStateValue = notification?.state?.value;
|
|
33
|
-
if (!notificationStateValue)
|
|
34
|
-
return undefined;
|
|
35
|
-
let tokenToUse;
|
|
36
|
-
let amountInDecimals;
|
|
37
|
-
let byteStringReceiverAddress;
|
|
38
|
-
if (isNativeToken) {
|
|
39
|
-
tokenToUse = service.neo3NeoXBridgeService.gasToken;
|
|
40
|
-
amountInDecimals = notificationStateValue[2]?.value;
|
|
41
|
-
byteStringReceiverAddress = notificationStateValue[1]?.value;
|
|
42
|
-
}
|
|
43
|
-
else {
|
|
44
|
-
tokenToUse = service.neo3NeoXBridgeService.neoToken;
|
|
45
|
-
amountInDecimals = notificationStateValue[4]?.value;
|
|
46
|
-
byteStringReceiverAddress = notificationStateValue[3]?.value;
|
|
47
|
-
}
|
|
48
|
-
if (!tokenToUse || !amountInDecimals || !byteStringReceiverAddress)
|
|
49
|
-
return undefined;
|
|
50
|
-
const { u } = BSNeo3NeonJsSingletonHelper_1.BSNeo3NeonJsSingletonHelper.getInstance();
|
|
51
|
-
return {
|
|
52
|
-
amount: blockchain_service_1.BSBigNumberHelper.format(blockchain_service_1.BSBigNumberHelper.fromDecimals(amountInDecimals, tokenToUse.decimals), {
|
|
53
|
-
decimals: tokenToUse.decimals,
|
|
54
|
-
}),
|
|
55
|
-
tokenToUse,
|
|
56
|
-
receiverAddress: `0x${u.HexString.fromBase64(byteStringReceiverAddress).toLittleEndian()}`,
|
|
57
|
-
};
|
|
58
|
-
}
|
|
59
23
|
constructor(service) {
|
|
60
24
|
super(service);
|
|
61
25
|
_DoraBDSNeo3_instances.add(this);
|
|
62
26
|
_DoraBDSNeo3_apiInstance.set(this, void 0);
|
|
63
27
|
}
|
|
64
28
|
async getTransaction(hash) {
|
|
65
|
-
if (
|
|
29
|
+
if (this._service.network.type === 'custom') {
|
|
66
30
|
return await super.getTransaction(hash);
|
|
67
31
|
}
|
|
68
32
|
const response = await __classPrivateFieldGet(this, _DoraBDSNeo3_instances, "a", _DoraBDSNeo3_api_get).transaction(hash, this._service.network.id);
|
|
@@ -75,7 +39,12 @@ class DoraBDSNeo3 extends RpcBDSNeo3_1.RpcBDSNeo3 {
|
|
|
75
39
|
const txId = response.hash;
|
|
76
40
|
const txIdUrl = this._service.explorerService.buildTransactionUrl(txId);
|
|
77
41
|
const events = await this._extractEventsFromNotifications(notifications);
|
|
78
|
-
|
|
42
|
+
const data = {
|
|
43
|
+
...this._service.neo3NeoXBridgeService._getDataFromNotifications(notifications),
|
|
44
|
+
...this._service.claimService._getTransactionDataFromEvents(events),
|
|
45
|
+
...this._service.voteService._getTransactionDataFromEvents(events),
|
|
46
|
+
};
|
|
47
|
+
const transaction = {
|
|
79
48
|
txId,
|
|
80
49
|
txIdUrl,
|
|
81
50
|
block: response.block,
|
|
@@ -84,18 +53,14 @@ class DoraBDSNeo3 extends RpcBDSNeo3_1.RpcBDSNeo3 {
|
|
|
84
53
|
networkFeeAmount: blockchain_service_1.BSBigNumberHelper.format(blockchain_service_1.BSBigNumberHelper.fromDecimals(response.netfee ?? 0, this._service.feeToken.decimals), { decimals: this._service.feeToken.decimals }),
|
|
85
54
|
invocationCount: 0,
|
|
86
55
|
notificationCount: 0,
|
|
87
|
-
type: 'default',
|
|
88
56
|
view: 'default',
|
|
89
57
|
events,
|
|
58
|
+
data,
|
|
90
59
|
};
|
|
91
|
-
const bridgeNeo3NeoXData = this.getBridgeNeo3NeoXDataByNotifications(notifications);
|
|
92
|
-
if (bridgeNeo3NeoXData) {
|
|
93
|
-
transaction = { ...transaction, type: 'bridgeNeo3NeoX', data: bridgeNeo3NeoXData };
|
|
94
|
-
}
|
|
95
60
|
return transaction;
|
|
96
61
|
}
|
|
97
62
|
async getTransactionsByAddress({ address, nextPageParams = 1, }) {
|
|
98
|
-
if (
|
|
63
|
+
if (this._service.network.type === 'custom') {
|
|
99
64
|
return await super.getTransactionsByAddress({ address, nextPageParams });
|
|
100
65
|
}
|
|
101
66
|
const data = await __classPrivateFieldGet(this, _DoraBDSNeo3_instances, "a", _DoraBDSNeo3_api_get).addressTXFull(address, nextPageParams, this._service.network.id);
|
|
@@ -109,7 +74,12 @@ class DoraBDSNeo3 extends RpcBDSNeo3_1.RpcBDSNeo3 {
|
|
|
109
74
|
const events = await this._extractEventsFromNotifications(notifications);
|
|
110
75
|
const txId = item.hash;
|
|
111
76
|
const txIdUrl = this._service.explorerService.buildTransactionUrl(txId);
|
|
112
|
-
|
|
77
|
+
const data = {
|
|
78
|
+
...this._service.neo3NeoXBridgeService._getDataFromNotifications(notifications),
|
|
79
|
+
...this._service.claimService._getTransactionDataFromEvents(events),
|
|
80
|
+
...this._service.voteService._getTransactionDataFromEvents(events),
|
|
81
|
+
};
|
|
82
|
+
const transaction = {
|
|
113
83
|
txId,
|
|
114
84
|
txIdUrl,
|
|
115
85
|
block: item.block,
|
|
@@ -118,14 +88,10 @@ class DoraBDSNeo3 extends RpcBDSNeo3_1.RpcBDSNeo3 {
|
|
|
118
88
|
networkFeeAmount: blockchain_service_1.BSBigNumberHelper.format(blockchain_service_1.BSBigNumberHelper.fromDecimals(item.netfee ?? 0, this._service.feeToken.decimals), { decimals: this._service.feeToken.decimals }),
|
|
119
89
|
invocationCount: 0,
|
|
120
90
|
notificationCount: notifications?.length ?? 0,
|
|
121
|
-
type: 'default',
|
|
122
91
|
view: 'default',
|
|
123
92
|
events,
|
|
93
|
+
data,
|
|
124
94
|
};
|
|
125
|
-
const bridgeNeo3NeoXData = this.getBridgeNeo3NeoXDataByNotifications(notifications);
|
|
126
|
-
if (bridgeNeo3NeoXData) {
|
|
127
|
-
transaction = { ...transaction, type: 'bridgeNeo3NeoX', data: bridgeNeo3NeoXData };
|
|
128
|
-
}
|
|
129
95
|
transactions.splice(index, 0, transaction);
|
|
130
96
|
});
|
|
131
97
|
await Promise.allSettled(promises);
|
|
@@ -137,7 +103,7 @@ class DoraBDSNeo3 extends RpcBDSNeo3_1.RpcBDSNeo3 {
|
|
|
137
103
|
};
|
|
138
104
|
}
|
|
139
105
|
async getContract(contractHash) {
|
|
140
|
-
if (
|
|
106
|
+
if (this._service.network.type === 'custom') {
|
|
141
107
|
return await super.getContract(contractHash);
|
|
142
108
|
}
|
|
143
109
|
try {
|
|
@@ -153,7 +119,7 @@ class DoraBDSNeo3 extends RpcBDSNeo3_1.RpcBDSNeo3 {
|
|
|
153
119
|
}
|
|
154
120
|
}
|
|
155
121
|
async getTokenInfo(tokenHash) {
|
|
156
|
-
if (
|
|
122
|
+
if (this._service.network.type === 'custom') {
|
|
157
123
|
return await super.getTokenInfo(tokenHash);
|
|
158
124
|
}
|
|
159
125
|
try {
|
|
@@ -179,7 +145,7 @@ class DoraBDSNeo3 extends RpcBDSNeo3_1.RpcBDSNeo3 {
|
|
|
179
145
|
}
|
|
180
146
|
}
|
|
181
147
|
async getBalance(address) {
|
|
182
|
-
if (
|
|
148
|
+
if (this._service.network.type === 'custom') {
|
|
183
149
|
return await super.getBalance(address);
|
|
184
150
|
}
|
|
185
151
|
const response = await __classPrivateFieldGet(this, _DoraBDSNeo3_instances, "a", _DoraBDSNeo3_api_get).balance(address, this._service.network.id);
|
|
@@ -1,19 +1,14 @@
|
|
|
1
|
-
import { type TBalanceResponse, type IBlockchainDataService, type TBSToken, type TGetTransactionsByAddressParams, type TGetTransactionsByAddressResponse, type TContractResponse, type
|
|
1
|
+
import { type TBalanceResponse, type IBlockchainDataService, type TBSToken, type TGetTransactionsByAddressParams, type TGetTransactionsByAddressResponse, type TContractResponse, type TTransactionDefault, type TTransactionDefaultEvent } from '@cityofzion/blockchain-service';
|
|
2
2
|
import type { IBSNeo3, TRpcBDSNeo3Notification } from '../../types';
|
|
3
|
-
export declare class RpcBDSNeo3
|
|
3
|
+
export declare class RpcBDSNeo3 implements IBlockchainDataService {
|
|
4
4
|
#private;
|
|
5
5
|
readonly maxTimeToConfirmTransactionInMs: number;
|
|
6
6
|
readonly _tokenCache: Map<string, TBSToken>;
|
|
7
|
-
readonly _service: IBSNeo3
|
|
8
|
-
constructor(service: IBSNeo3
|
|
9
|
-
_extractEventsFromNotifications(notifications?: TRpcBDSNeo3Notification[]): Promise<
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
tokenToUse: TBridgeToken<N>;
|
|
13
|
-
receiverAddress: string;
|
|
14
|
-
} | undefined;
|
|
15
|
-
getTransaction(hash: string): Promise<TTransactionDefault<N>>;
|
|
16
|
-
getTransactionsByAddress(_params: TGetTransactionsByAddressParams): Promise<TGetTransactionsByAddressResponse<N, TTransactionDefault<N>>>;
|
|
7
|
+
readonly _service: IBSNeo3;
|
|
8
|
+
constructor(service: IBSNeo3);
|
|
9
|
+
_extractEventsFromNotifications(notifications?: TRpcBDSNeo3Notification[]): Promise<TTransactionDefaultEvent[]>;
|
|
10
|
+
getTransaction(hash: string): Promise<TTransactionDefault>;
|
|
11
|
+
getTransactionsByAddress(_params: TGetTransactionsByAddressParams): Promise<TGetTransactionsByAddressResponse<TTransactionDefault>>;
|
|
17
12
|
getContract(contractHash: string): Promise<TContractResponse>;
|
|
18
13
|
getTokenInfo(tokenHash: string): Promise<TBSToken>;
|
|
19
14
|
getBalance(address: string): Promise<TBalanceResponse[]>;
|