@cityofzion/bs-neo-legacy 1.13.8 → 1.14.0
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/BSNeoLegacy.d.ts +0 -2
- package/dist/BSNeoLegacy.js +0 -2
- package/dist/constants/BSNeoLegacyConstants.d.ts +0 -6
- package/dist/constants/BSNeoLegacyConstants.js +2 -16
- package/dist/services/claim-data/DoraCDSNeoLegacy.js +2 -4
- package/dist/types.d.ts +1 -24
- package/package.json +2 -2
- package/dist/services/migration/Neo3NeoLegacyMigrationService.d.ts +0 -16
- package/dist/services/migration/Neo3NeoLegacyMigrationService.js +0 -173
package/dist/BSNeoLegacy.d.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { TBSAccount, TBSToken, TTransferParam, TGetLedgerTransport, ITokenService, TBSNetwork, IClaimDataService, IBlockchainDataService, IExchangeDataService, IExplorerService, TPingNetworkResponse } from '@cityofzion/blockchain-service';
|
|
2
2
|
import { NeonJsLedgerServiceNeoLegacy } from './services/ledger/NeonJsLedgerServiceNeoLegacy';
|
|
3
3
|
import { IBSNeoLegacy, TBSNeoLegacyNetworkId, TSigningCallback } from './types';
|
|
4
|
-
import { Neo3NeoLegacyMigrationService } from './services/migration/Neo3NeoLegacyMigrationService';
|
|
5
4
|
export declare class BSNeoLegacy<N extends string = string> implements IBSNeoLegacy<N> {
|
|
6
5
|
#private;
|
|
7
6
|
readonly name: N;
|
|
@@ -24,7 +23,6 @@ export declare class BSNeoLegacy<N extends string = string> implements IBSNeoLeg
|
|
|
24
23
|
explorerService: IExplorerService;
|
|
25
24
|
tokenService: ITokenService;
|
|
26
25
|
claimDataService: IClaimDataService;
|
|
27
|
-
neo3NeoLegacyMigrationService: Neo3NeoLegacyMigrationService<N>;
|
|
28
26
|
constructor(name: N, network?: TBSNetwork<TBSNeoLegacyNetworkId>, getLedgerTransport?: TGetLedgerTransport<N>);
|
|
29
27
|
sendTransfer(config: any, nep5ScriptBuilder?: any): Promise<any>;
|
|
30
28
|
generateSigningCallback(account: TBSAccount<N>): Promise<{
|
package/dist/BSNeoLegacy.js
CHANGED
|
@@ -38,7 +38,6 @@ const NeoTubeESNeoLegacy_1 = require("./services/explorer/NeoTubeESNeoLegacy");
|
|
|
38
38
|
const NeonJsLedgerServiceNeoLegacy_1 = require("./services/ledger/NeonJsLedgerServiceNeoLegacy");
|
|
39
39
|
const TokenServiceNeoLegacy_1 = require("./services/token/TokenServiceNeoLegacy");
|
|
40
40
|
const DoraCDSNeoLegacy_1 = require("./services/claim-data/DoraCDSNeoLegacy");
|
|
41
|
-
const Neo3NeoLegacyMigrationService_1 = require("./services/migration/Neo3NeoLegacyMigrationService");
|
|
42
41
|
const BSNeoLegacyNeonJsSingletonHelper_1 = require("./helpers/BSNeoLegacyNeonJsSingletonHelper");
|
|
43
42
|
const axios_1 = __importDefault(require("axios"));
|
|
44
43
|
class BSNeoLegacy {
|
|
@@ -105,7 +104,6 @@ class BSNeoLegacy {
|
|
|
105
104
|
this.blockchainDataService = new DoraBDSNeoLegacy_1.DoraBDSNeoLegacy(this);
|
|
106
105
|
this.exchangeDataService = new CryptoCompareEDSNeoLegacy_1.CryptoCompareEDSNeoLegacy(this);
|
|
107
106
|
this.claimDataService = new DoraCDSNeoLegacy_1.DoraCDSNeoLegacy(this);
|
|
108
|
-
this.neo3NeoLegacyMigrationService = new Neo3NeoLegacyMigrationService_1.Neo3NeoLegacyMigrationService(this);
|
|
109
107
|
}
|
|
110
108
|
// This method is done manually because we need to ensure that the request is aborted after timeout
|
|
111
109
|
pingNode(url) {
|
|
@@ -10,12 +10,6 @@ export declare class BSNeoLegacyConstants {
|
|
|
10
10
|
static readonly TESTNET_NETWORK: TBSNetwork<TBSNeoLegacyNetworkId>;
|
|
11
11
|
static readonly ALL_NETWORKS: TBSNetwork<TBSNeoLegacyNetworkId>[];
|
|
12
12
|
static readonly DEFAULT_BIP44_DERIVATION_PATH = "m/44'/888'/0'/0/?";
|
|
13
|
-
static readonly MIGRATION_COZ_LEGACY_ADDRESS = "AaT27thuyPaqERPwERhk7QhfKrbj4xoyAV";
|
|
14
|
-
static readonly MIGRATION_COZ_FEE = 0.01;
|
|
15
|
-
static readonly MIGRATION_NEP_17_TRANSFER_FEE = 0.0112143;
|
|
16
|
-
static readonly MIGRATION_MIN_GAS = 0.1;
|
|
17
|
-
static readonly MIGRATION_MIN_NEO = 2;
|
|
18
|
-
static readonly MIGRATION_COZ_NEO3_ADDRESS = "NLMsicDapULKFDmAzTsbhwrZjYZ83j53Ty";
|
|
19
13
|
static readonly MAX_TRANSACTION_SIZE_WITHOUT_FEE = 1024;
|
|
20
14
|
static readonly FEE_APPLIED_TO_PLAYABLE_TRANSACTION = 0.05;
|
|
21
15
|
}
|
|
@@ -21,22 +21,14 @@ BSNeoLegacyConstants.NEO_ASSET = {
|
|
|
21
21
|
BSNeoLegacyConstants.NATIVE_ASSETS = [_a.NEO_ASSET, _a.GAS_ASSET];
|
|
22
22
|
BSNeoLegacyConstants.RPC_LIST_BY_NETWORK_ID = {
|
|
23
23
|
mainnet: [
|
|
24
|
-
'https://mainnet1.neo2.coz.io:443',
|
|
25
|
-
'https://mainnet2.neo2.coz.io:443',
|
|
26
|
-
'https://mainnet3.neo2.coz.io:443',
|
|
27
|
-
'http://seed9.ngd.network:10332',
|
|
28
24
|
'http://seed1.ngd.network:10332',
|
|
29
25
|
'http://seed2.ngd.network:10332',
|
|
30
26
|
'http://seed3.ngd.network:10332',
|
|
31
27
|
'http://seed4.ngd.network:10332',
|
|
32
28
|
'http://seed5.ngd.network:10332',
|
|
29
|
+
'http://seed9.ngd.network:10332',
|
|
33
30
|
],
|
|
34
|
-
testnet: [
|
|
35
|
-
'http://seed5.ngd.network:20332',
|
|
36
|
-
'http://seed1.ngd.network:20332',
|
|
37
|
-
'http://seed2.ngd.network:20332',
|
|
38
|
-
'https://testnet1.neo2.coz.io:443',
|
|
39
|
-
],
|
|
31
|
+
testnet: ['http://seed1.ngd.network:20332', 'http://seed2.ngd.network:20332', 'http://seed5.ngd.network:20332'],
|
|
40
32
|
};
|
|
41
33
|
BSNeoLegacyConstants.LEGACY_NETWORK_BY_NETWORK_ID = {
|
|
42
34
|
mainnet: 'MainNet',
|
|
@@ -56,11 +48,5 @@ BSNeoLegacyConstants.TESTNET_NETWORK = {
|
|
|
56
48
|
};
|
|
57
49
|
BSNeoLegacyConstants.ALL_NETWORKS = [_a.MAINNET_NETWORK, _a.TESTNET_NETWORK];
|
|
58
50
|
BSNeoLegacyConstants.DEFAULT_BIP44_DERIVATION_PATH = "m/44'/888'/0'/0/?";
|
|
59
|
-
BSNeoLegacyConstants.MIGRATION_COZ_LEGACY_ADDRESS = 'AaT27thuyPaqERPwERhk7QhfKrbj4xoyAV';
|
|
60
|
-
BSNeoLegacyConstants.MIGRATION_COZ_FEE = 0.01; // 1%
|
|
61
|
-
BSNeoLegacyConstants.MIGRATION_NEP_17_TRANSFER_FEE = 0.0112143;
|
|
62
|
-
BSNeoLegacyConstants.MIGRATION_MIN_GAS = 0.1;
|
|
63
|
-
BSNeoLegacyConstants.MIGRATION_MIN_NEO = 2;
|
|
64
|
-
BSNeoLegacyConstants.MIGRATION_COZ_NEO3_ADDRESS = 'NLMsicDapULKFDmAzTsbhwrZjYZ83j53Ty';
|
|
65
51
|
BSNeoLegacyConstants.MAX_TRANSACTION_SIZE_WITHOUT_FEE = 1024;
|
|
66
52
|
BSNeoLegacyConstants.FEE_APPLIED_TO_PLAYABLE_TRANSACTION = 0.05;
|
|
@@ -22,7 +22,7 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
|
|
|
22
22
|
var _DoraCDSNeoLegacy_service;
|
|
23
23
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
24
24
|
exports.DoraCDSNeoLegacy = void 0;
|
|
25
|
-
const
|
|
25
|
+
const dora_ts_1 = require("@cityofzion/dora-ts");
|
|
26
26
|
class DoraCDSNeoLegacy {
|
|
27
27
|
constructor(service) {
|
|
28
28
|
_DoraCDSNeoLegacy_service.set(this, void 0);
|
|
@@ -31,9 +31,7 @@ class DoraCDSNeoLegacy {
|
|
|
31
31
|
getUnclaimed(address) {
|
|
32
32
|
return __awaiter(this, void 0, void 0, function* () {
|
|
33
33
|
var _a;
|
|
34
|
-
const
|
|
35
|
-
const rpcClient = new rpc.RPCClient(__classPrivateFieldGet(this, _DoraCDSNeoLegacy_service, "f").network.url);
|
|
36
|
-
const response = yield rpcClient.getUnclaimed(address);
|
|
34
|
+
const response = yield dora_ts_1.api.NeoLegacyREST.getUnclaimed(address);
|
|
37
35
|
return ((_a = response === null || response === void 0 ? void 0 : response.unclaimed) !== null && _a !== void 0 ? _a : 0).toFixed(__classPrivateFieldGet(this, _DoraCDSNeoLegacy_service, "f").claimToken.decimals);
|
|
38
36
|
});
|
|
39
37
|
}
|
package/dist/types.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { TBSAccount,
|
|
1
|
+
import { TBSAccount, IBlockchainService, IBSWithClaim, IBSWithEncryption, IBSWithExplorer, IBSWithLedger, TBSNetworkId } from '@cityofzion/blockchain-service';
|
|
2
2
|
export type TBSNeoLegacyNetworkId = TBSNetworkId<'mainnet' | 'testnet'>;
|
|
3
3
|
export type TSigningCallback = (transaction: string, publicKey: string) => Promise<string | string[]>;
|
|
4
4
|
export interface IBSNeoLegacy<N extends string = string> extends IBlockchainService<N, TBSNeoLegacyNetworkId>, IBSWithClaim<N>, IBSWithExplorer, IBSWithLedger<N>, IBSWithEncryption<N> {
|
|
@@ -8,29 +8,6 @@ export interface IBSNeoLegacy<N extends string = string> extends IBlockchainServ
|
|
|
8
8
|
}>;
|
|
9
9
|
sendTransfer(config: any, nep5ScriptBuilder?: any): Promise<string>;
|
|
10
10
|
}
|
|
11
|
-
export type TNeo3NeoLegacyWaitForMigrationParams = {
|
|
12
|
-
transactionHash: string;
|
|
13
|
-
neo3Address: string;
|
|
14
|
-
neo3Service: IBlockchainService;
|
|
15
|
-
neoLegacyService: IBlockchainService;
|
|
16
|
-
};
|
|
17
|
-
export type TNeo3NeoLegacyMigrateParams<N extends string = string> = {
|
|
18
|
-
account: TBSAccount<N>;
|
|
19
|
-
neo3Address: string;
|
|
20
|
-
neoLegacyMigrationAmounts: TNeo3NeoLegacyMigrationNeoLegacyAmounts;
|
|
21
|
-
};
|
|
22
|
-
export type TNeo3NeoLegacyMigrationNeo3Amounts = {
|
|
23
|
-
gasMigrationTotalFees?: string;
|
|
24
|
-
neoMigrationTotalFees?: string;
|
|
25
|
-
gasMigrationReceiveAmount?: string;
|
|
26
|
-
neoMigrationReceiveAmount?: string;
|
|
27
|
-
};
|
|
28
|
-
export type TNeo3NeoLegacyMigrationNeoLegacyAmounts = {
|
|
29
|
-
hasEnoughGasBalance: boolean;
|
|
30
|
-
hasEnoughNeoBalance: boolean;
|
|
31
|
-
gasBalance?: TBalanceResponse;
|
|
32
|
-
neoBalance?: TBalanceResponse;
|
|
33
|
-
};
|
|
34
11
|
export declare enum ENeonJsLedgerServiceNeoLegacyStatus {
|
|
35
12
|
OK = 36864
|
|
36
13
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cityofzion/bs-neo-legacy",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.14.0",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"types": "dist/index.d.ts",
|
|
6
6
|
"author": "Coz",
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
"/dist"
|
|
10
10
|
],
|
|
11
11
|
"dependencies": {
|
|
12
|
-
"@cityofzion/dora-ts": "
|
|
12
|
+
"@cityofzion/dora-ts": "0.6.1",
|
|
13
13
|
"@cityofzion/neon-js": "4.8.3",
|
|
14
14
|
"axios": "~1.12.2",
|
|
15
15
|
"@cityofzion/blockchain-service": "1.22.3"
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { IBSNeoLegacy, TNeo3NeoLegacyMigrationNeo3Amounts, TNeo3NeoLegacyMigrationNeoLegacyAmounts, TNeo3NeoLegacyMigrateParams, TNeo3NeoLegacyWaitForMigrationParams } from '../../types';
|
|
2
|
-
import { TBalanceResponse } from '@cityofzion/blockchain-service';
|
|
3
|
-
export declare class Neo3NeoLegacyMigrationService<N extends string> {
|
|
4
|
-
#private;
|
|
5
|
-
constructor(service: IBSNeoLegacy<N>);
|
|
6
|
-
migrate({ account, neo3Address, neoLegacyMigrationAmounts }: TNeo3NeoLegacyMigrateParams<N>): Promise<string>;
|
|
7
|
-
/**
|
|
8
|
-
* Reference: https://github.com/CityOfZion/legacy-n3-swap-service/blob/master/policy/policy.go
|
|
9
|
-
*/
|
|
10
|
-
calculateNeo3MigrationAmounts(neoLegacyMigrationAmounts: TNeo3NeoLegacyMigrationNeoLegacyAmounts): TNeo3NeoLegacyMigrationNeo3Amounts;
|
|
11
|
-
calculateNeoLegacyMigrationAmounts(balance: TBalanceResponse[]): TNeo3NeoLegacyMigrationNeoLegacyAmounts;
|
|
12
|
-
static waitForMigration(params: TNeo3NeoLegacyWaitForMigrationParams): Promise<{
|
|
13
|
-
isTransactionConfirmed: boolean;
|
|
14
|
-
isNeo3TransactionConfirmed: boolean;
|
|
15
|
-
}>;
|
|
16
|
-
}
|
|
@@ -1,173 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
|
12
|
-
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
13
|
-
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
14
|
-
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
15
|
-
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
16
|
-
};
|
|
17
|
-
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
18
|
-
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
19
|
-
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");
|
|
20
|
-
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
21
|
-
};
|
|
22
|
-
var _Neo3NeoLegacyMigrationService_service;
|
|
23
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
24
|
-
exports.Neo3NeoLegacyMigrationService = void 0;
|
|
25
|
-
const BSNeoLegacyHelper_1 = require("../../helpers/BSNeoLegacyHelper");
|
|
26
|
-
const BSNeoLegacyConstants_1 = require("../../constants/BSNeoLegacyConstants");
|
|
27
|
-
const blockchain_service_1 = require("@cityofzion/blockchain-service");
|
|
28
|
-
const BSNeoLegacyNeonJsSingletonHelper_1 = require("../../helpers/BSNeoLegacyNeonJsSingletonHelper");
|
|
29
|
-
class Neo3NeoLegacyMigrationService {
|
|
30
|
-
constructor(service) {
|
|
31
|
-
_Neo3NeoLegacyMigrationService_service.set(this, void 0);
|
|
32
|
-
__classPrivateFieldSet(this, _Neo3NeoLegacyMigrationService_service, service, "f");
|
|
33
|
-
}
|
|
34
|
-
migrate(_a) {
|
|
35
|
-
return __awaiter(this, arguments, void 0, function* ({ account, neo3Address, neoLegacyMigrationAmounts }) {
|
|
36
|
-
if (!BSNeoLegacyHelper_1.BSNeoLegacyHelper.isMainnetNetwork(__classPrivateFieldGet(this, _Neo3NeoLegacyMigrationService_service, "f").network)) {
|
|
37
|
-
throw new Error('Must use Mainnet network');
|
|
38
|
-
}
|
|
39
|
-
if ((!neoLegacyMigrationAmounts.hasEnoughGasBalance && !neoLegacyMigrationAmounts.hasEnoughNeoBalance) ||
|
|
40
|
-
(!neoLegacyMigrationAmounts.gasBalance && !neoLegacyMigrationAmounts.neoBalance)) {
|
|
41
|
-
throw new Error('Must have at least 0.1 GAS or 2 NEO');
|
|
42
|
-
}
|
|
43
|
-
const { neonJsAccount, signingCallback } = yield __classPrivateFieldGet(this, _Neo3NeoLegacyMigrationService_service, "f").generateSigningCallback(account);
|
|
44
|
-
const { api, tx, u } = BSNeoLegacyNeonJsSingletonHelper_1.BSNeoLegacyNeonJsSingletonHelper.getInstance();
|
|
45
|
-
const provider = new api.neoCli.instance(__classPrivateFieldGet(this, _Neo3NeoLegacyMigrationService_service, "f").network.url);
|
|
46
|
-
const intents = [];
|
|
47
|
-
if (neoLegacyMigrationAmounts.hasEnoughGasBalance && neoLegacyMigrationAmounts.gasBalance)
|
|
48
|
-
intents.push(...api.makeIntent({ [BSNeoLegacyConstants_1.BSNeoLegacyConstants.GAS_ASSET.symbol]: Number(neoLegacyMigrationAmounts.gasBalance.amount) }, BSNeoLegacyConstants_1.BSNeoLegacyConstants.MIGRATION_COZ_LEGACY_ADDRESS));
|
|
49
|
-
if (neoLegacyMigrationAmounts.hasEnoughNeoBalance && neoLegacyMigrationAmounts.neoBalance)
|
|
50
|
-
intents.push(...api.makeIntent({ [BSNeoLegacyConstants_1.BSNeoLegacyConstants.NEO_ASSET.symbol]: Number(neoLegacyMigrationAmounts.neoBalance.amount) }, BSNeoLegacyConstants_1.BSNeoLegacyConstants.MIGRATION_COZ_LEGACY_ADDRESS));
|
|
51
|
-
return yield __classPrivateFieldGet(this, _Neo3NeoLegacyMigrationService_service, "f").sendTransfer({
|
|
52
|
-
url: __classPrivateFieldGet(this, _Neo3NeoLegacyMigrationService_service, "f").network.url,
|
|
53
|
-
api: provider,
|
|
54
|
-
account: neonJsAccount,
|
|
55
|
-
intents,
|
|
56
|
-
signingFunction: signingCallback,
|
|
57
|
-
override: {
|
|
58
|
-
attributes: [
|
|
59
|
-
new tx.TransactionAttribute({
|
|
60
|
-
usage: tx.TxAttrUsage.Remark14,
|
|
61
|
-
data: u.str2hexstring(neo3Address),
|
|
62
|
-
}),
|
|
63
|
-
new tx.TransactionAttribute({
|
|
64
|
-
usage: tx.TxAttrUsage.Remark15,
|
|
65
|
-
data: u.str2hexstring('Neon Desktop Migration'),
|
|
66
|
-
}),
|
|
67
|
-
],
|
|
68
|
-
},
|
|
69
|
-
});
|
|
70
|
-
});
|
|
71
|
-
}
|
|
72
|
-
/**
|
|
73
|
-
* Reference: https://github.com/CityOfZion/legacy-n3-swap-service/blob/master/policy/policy.go
|
|
74
|
-
*/
|
|
75
|
-
calculateNeo3MigrationAmounts(neoLegacyMigrationAmounts) {
|
|
76
|
-
const response = {
|
|
77
|
-
gasMigrationReceiveAmount: undefined,
|
|
78
|
-
gasMigrationTotalFees: undefined,
|
|
79
|
-
neoMigrationReceiveAmount: undefined,
|
|
80
|
-
neoMigrationTotalFees: undefined,
|
|
81
|
-
};
|
|
82
|
-
if (neoLegacyMigrationAmounts.gasBalance && neoLegacyMigrationAmounts.hasEnoughGasBalance) {
|
|
83
|
-
// Two transfers fee and one transfer fee left over
|
|
84
|
-
const allNep17TransfersFee = BSNeoLegacyConstants_1.BSNeoLegacyConstants.MIGRATION_NEP_17_TRANSFER_FEE * 3;
|
|
85
|
-
const gasMigrationAmountNumber = Number(neoLegacyMigrationAmounts.gasBalance.amount);
|
|
86
|
-
// Necessary to calculate the COZ fee
|
|
87
|
-
const gasAmountNumberLessAllNep17TransfersFee = gasMigrationAmountNumber - allNep17TransfersFee;
|
|
88
|
-
// Example: ~0.06635710 * 0.01 = ~0.00066357
|
|
89
|
-
const cozFee = gasAmountNumberLessAllNep17TransfersFee * BSNeoLegacyConstants_1.BSNeoLegacyConstants.MIGRATION_COZ_FEE;
|
|
90
|
-
// Example: ~0.06635710 - ~0.00066357 = ~0.06569352
|
|
91
|
-
const gasAmountNumberLessCozFee = gasAmountNumberLessAllNep17TransfersFee - cozFee;
|
|
92
|
-
const allGasFeeNumberThatUserWillPay = cozFee + BSNeoLegacyConstants_1.BSNeoLegacyConstants.MIGRATION_NEP_17_TRANSFER_FEE * 2;
|
|
93
|
-
const allGasAmountNumberThatUserWillReceive = gasAmountNumberLessCozFee + BSNeoLegacyConstants_1.BSNeoLegacyConstants.MIGRATION_NEP_17_TRANSFER_FEE;
|
|
94
|
-
response.gasMigrationTotalFees = blockchain_service_1.BSBigNumberHelper.format(allGasFeeNumberThatUserWillPay, {
|
|
95
|
-
decimals: BSNeoLegacyConstants_1.BSNeoLegacyConstants.GAS_ASSET.decimals,
|
|
96
|
-
});
|
|
97
|
-
response.gasMigrationReceiveAmount = blockchain_service_1.BSBigNumberHelper.format(allGasAmountNumberThatUserWillReceive, {
|
|
98
|
-
decimals: BSNeoLegacyConstants_1.BSNeoLegacyConstants.GAS_ASSET.decimals,
|
|
99
|
-
});
|
|
100
|
-
}
|
|
101
|
-
if (neoLegacyMigrationAmounts.neoBalance && neoLegacyMigrationAmounts.hasEnoughNeoBalance) {
|
|
102
|
-
const neoMigrationAmountNumber = Number(neoLegacyMigrationAmounts.neoBalance.amount);
|
|
103
|
-
response.neoMigrationTotalFees = blockchain_service_1.BSBigNumberHelper.format(Math.ceil(neoMigrationAmountNumber * BSNeoLegacyConstants_1.BSNeoLegacyConstants.MIGRATION_COZ_FEE), { decimals: BSNeoLegacyConstants_1.BSNeoLegacyConstants.NEO_ASSET.decimals });
|
|
104
|
-
response.neoMigrationReceiveAmount = blockchain_service_1.BSBigNumberHelper.format(neoMigrationAmountNumber - Number(response.neoMigrationTotalFees), { decimals: BSNeoLegacyConstants_1.BSNeoLegacyConstants.NEO_ASSET.decimals });
|
|
105
|
-
}
|
|
106
|
-
return response;
|
|
107
|
-
}
|
|
108
|
-
calculateNeoLegacyMigrationAmounts(balance) {
|
|
109
|
-
const gasBalance = balance.find(({ token }) => __classPrivateFieldGet(this, _Neo3NeoLegacyMigrationService_service, "f").tokenService.predicateByHash(BSNeoLegacyConstants_1.BSNeoLegacyConstants.GAS_ASSET, token));
|
|
110
|
-
const neoBalance = balance.find(({ token }) => __classPrivateFieldGet(this, _Neo3NeoLegacyMigrationService_service, "f").tokenService.predicateByHash(BSNeoLegacyConstants_1.BSNeoLegacyConstants.NEO_ASSET, token));
|
|
111
|
-
let hasEnoughGasBalance = false;
|
|
112
|
-
let hasEnoughNeoBalance = false;
|
|
113
|
-
if (gasBalance) {
|
|
114
|
-
const gasBalanceNumber = blockchain_service_1.BSBigNumberHelper.fromNumber(gasBalance.amount);
|
|
115
|
-
hasEnoughGasBalance = gasBalanceNumber.isGreaterThanOrEqualTo(BSNeoLegacyConstants_1.BSNeoLegacyConstants.MIGRATION_MIN_GAS);
|
|
116
|
-
}
|
|
117
|
-
if (neoBalance) {
|
|
118
|
-
const neoBalanceNumber = blockchain_service_1.BSBigNumberHelper.fromNumber(neoBalance.amount);
|
|
119
|
-
hasEnoughNeoBalance = neoBalanceNumber.isGreaterThanOrEqualTo(BSNeoLegacyConstants_1.BSNeoLegacyConstants.MIGRATION_MIN_NEO);
|
|
120
|
-
}
|
|
121
|
-
return {
|
|
122
|
-
gasBalance,
|
|
123
|
-
neoBalance,
|
|
124
|
-
hasEnoughGasBalance,
|
|
125
|
-
hasEnoughNeoBalance,
|
|
126
|
-
};
|
|
127
|
-
}
|
|
128
|
-
static waitForMigration(params) {
|
|
129
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
130
|
-
const { neo3Address, neo3Service, transactionHash, neoLegacyService } = params;
|
|
131
|
-
const MAX_ATTEMPTS = 10;
|
|
132
|
-
const NEO3_MAX_ATTEMPTS = 20;
|
|
133
|
-
const response = {
|
|
134
|
-
isTransactionConfirmed: false,
|
|
135
|
-
isNeo3TransactionConfirmed: false,
|
|
136
|
-
};
|
|
137
|
-
let transactionResponse;
|
|
138
|
-
for (let i = 0; i < MAX_ATTEMPTS; i++) {
|
|
139
|
-
yield blockchain_service_1.BSUtilsHelper.wait(30000);
|
|
140
|
-
try {
|
|
141
|
-
transactionResponse = yield neoLegacyService.blockchainDataService.getTransaction(transactionHash);
|
|
142
|
-
response.isTransactionConfirmed = true;
|
|
143
|
-
break;
|
|
144
|
-
}
|
|
145
|
-
catch (_a) {
|
|
146
|
-
// Empty block
|
|
147
|
-
}
|
|
148
|
-
}
|
|
149
|
-
if (!response.isTransactionConfirmed)
|
|
150
|
-
return response;
|
|
151
|
-
for (let i = 0; i < NEO3_MAX_ATTEMPTS; i++) {
|
|
152
|
-
yield blockchain_service_1.BSUtilsHelper.wait(60000);
|
|
153
|
-
try {
|
|
154
|
-
const neo3Response = yield neo3Service.blockchainDataService.getTransactionsByAddress({
|
|
155
|
-
address: neo3Address,
|
|
156
|
-
});
|
|
157
|
-
const isTransactionConfirmed = neo3Response.transactions.some(transaction => transaction.time > transactionResponse.time &&
|
|
158
|
-
transaction.transfers.some(transfer => transfer.from === BSNeoLegacyConstants_1.BSNeoLegacyConstants.MIGRATION_COZ_NEO3_ADDRESS));
|
|
159
|
-
if (isTransactionConfirmed) {
|
|
160
|
-
response.isNeo3TransactionConfirmed = true;
|
|
161
|
-
break;
|
|
162
|
-
}
|
|
163
|
-
}
|
|
164
|
-
catch (_b) {
|
|
165
|
-
// Empty block
|
|
166
|
-
}
|
|
167
|
-
}
|
|
168
|
-
return response;
|
|
169
|
-
});
|
|
170
|
-
}
|
|
171
|
-
}
|
|
172
|
-
exports.Neo3NeoLegacyMigrationService = Neo3NeoLegacyMigrationService;
|
|
173
|
-
_Neo3NeoLegacyMigrationService_service = new WeakMap();
|