@cityofzion/bs-neo3 0.7.3 → 0.8.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/.rush/temp/operation/build/all.log +1 -0
- package/.rush/temp/operation/build/state.json +1 -1
- package/.rush/temp/package-deps_build.json +7 -5
- package/.rush/temp/shrinkwrap-deps.json +354 -130
- package/CHANGELOG.json +22 -0
- package/CHANGELOG.md +11 -0
- package/bs-neo3.build.log +1 -2
- package/dist/BSNeo3.d.ts +28 -28
- package/dist/BSNeo3.js +184 -184
- package/dist/DoraBDSNeo3.d.ts +12 -12
- package/dist/DoraBDSNeo3.js +169 -169
- package/dist/DoraESNeo3.d.ts +7 -7
- package/dist/DoraESNeo3.js +19 -19
- package/dist/FlamingoEDSNeo3.d.ts +8 -8
- package/dist/FlamingoEDSNeo3.js +45 -44
- package/dist/GhostMarketNDSNeo3.d.ts +10 -10
- package/dist/GhostMarketNDSNeo3.js +75 -75
- package/dist/RpcBDSNeo3.d.ts +16 -16
- package/dist/RpcBDSNeo3.js +153 -153
- package/dist/assets/tokens/common.json +14 -14
- package/dist/assets/tokens/mainnet.json +116 -116
- package/dist/constants.d.ts +7 -7
- package/dist/constants.js +28 -28
- package/dist/index.d.ts +6 -6
- package/dist/index.js +22 -22
- package/jest.config.ts +13 -13
- package/jest.setup.ts +1 -1
- package/package.json +33 -32
- package/src/BSNeo3.ts +228 -228
- package/src/DoraBDSNeo3.ts +180 -180
- package/src/DoraESNeo3.ts +19 -19
- package/src/FlamingoEDSNeo3.ts +47 -45
- package/src/GhostMarketNDSNeo3.ts +117 -117
- package/src/RpcBDSNeo3.ts +157 -157
- package/src/__tests__/BDSNeo3.spec.ts +126 -126
- package/src/__tests__/BSNeo3.spec.ts +142 -142
- package/src/__tests__/DoraESNeo3.spec.ts +23 -23
- package/src/__tests__/FlamingoEDSNeo3.spec.ts +48 -45
- package/src/__tests__/GhostMarketNDSNeo3.spec.ts +43 -43
- package/src/__tests__/utils/sleep.ts +1 -1
- package/src/assets/tokens/common.json +13 -13
- package/src/assets/tokens/mainnet.json +115 -115
- package/src/constants.ts +29 -29
- package/src/index.ts +6 -6
- package/tsconfig.build.json +4 -4
- package/tsconfig.json +14 -14
- package/dist/BDSNeo3.d.ts +0 -15
- package/dist/BDSNeo3.js +0 -211
- package/dist/assets/tokens.json +0 -128
- package/dist/exceptions.d.ts +0 -3
- package/dist/exceptions.js +0 -8
- package/dist/explorer/dora/DoraNeo3Responses.d.ts +0 -174
- package/dist/explorer/dora/DoraNeo3Responses.js +0 -3
- package/dist/explorer/dora/DoraNeo3Routes.d.ts +0 -6
- package/dist/explorer/dora/DoraNeo3Routes.js +0 -9
- package/dist/explorer/index.d.ts +0 -6
- package/dist/explorer/index.js +0 -23
- package/docs/.nojekyll +0 -1
- package/docs/assets/highlight.css +0 -22
- package/docs/assets/main.js +0 -58
- package/docs/assets/search.js +0 -1
- package/docs/assets/style.css +0 -1280
- package/docs/classes/BDSNeo3.html +0 -253
- package/docs/classes/BSNeo3.html +0 -442
- package/docs/index.html +0 -82
- package/docs/interfaces/DoraNeo3Abi.html +0 -78
- package/docs/interfaces/DoraNeo3Asset.html +0 -117
- package/docs/interfaces/DoraNeo3AssetState.html +0 -96
- package/docs/interfaces/DoraNeo3Balance.html +0 -89
- package/docs/interfaces/DoraNeo3ConsensusNode.html +0 -75
- package/docs/interfaces/DoraNeo3Contract.html +0 -110
- package/docs/interfaces/DoraNeo3Event.html +0 -75
- package/docs/interfaces/DoraNeo3Features.html +0 -84
- package/docs/interfaces/DoraNeo3HistoryState.html +0 -75
- package/docs/interfaces/DoraNeo3Invocation.html +0 -75
- package/docs/interfaces/DoraNeo3Item.html +0 -131
- package/docs/interfaces/DoraNeo3Manifest.html +0 -117
- package/docs/interfaces/DoraNeo3Metadata.html +0 -138
- package/docs/interfaces/DoraNeo3Method.html +0 -102
- package/docs/interfaces/DoraNeo3Nef.html +0 -103
- package/docs/interfaces/DoraNeo3Notification.html +0 -82
- package/docs/interfaces/DoraNeo3Parameter.html +0 -75
- package/docs/interfaces/DoraNeo3Permission.html +0 -75
- package/docs/interfaces/DoraNeo3Signer.html +0 -75
- package/docs/interfaces/DoraNeo3Token.html +0 -96
- package/docs/interfaces/DoraNeo3Transaction.html +0 -166
- package/docs/interfaces/DoraNeo3TransactionHistory.html +0 -75
- package/docs/interfaces/DoraNeo3Transfer.html +0 -117
- package/docs/interfaces/DoraNeo3Witness.html +0 -75
- package/docs/modules.html +0 -122
- package/docs/variables/DORA_ASSET.html +0 -81
- package/docs/variables/DORA_BALANCE.html +0 -81
- package/docs/variables/DORA_CONTRACT.html +0 -81
- package/docs/variables/DORA_NODES.html +0 -81
- package/docs/variables/DORA_TRANSACTION.html +0 -81
- package/docs/variables/DORA_TRANSACTIONS.html +0 -81
- package/docs/variables/explorerOptions.html +0 -86
- package/docs/variables/gasInfoNeo3.html +0 -90
- package/docs/variables/neoInfoNeo3.html +0 -90
package/dist/DoraBDSNeo3.js
CHANGED
|
@@ -1,169 +1,169 @@
|
|
|
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
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.DoraBDSNeo3 = void 0;
|
|
13
|
-
const neon_js_1 = require("@cityofzion/neon-js");
|
|
14
|
-
const api_1 = require("@cityofzion/dora-ts/dist/api");
|
|
15
|
-
const RpcBDSNeo3_1 = require("./RpcBDSNeo3");
|
|
16
|
-
const constants_1 = require("./constants");
|
|
17
|
-
const NeoRest = new api_1.NeoRESTApi({
|
|
18
|
-
doraUrl: 'https://dora.coz.io',
|
|
19
|
-
endpoint: '/api/v2/neo3',
|
|
20
|
-
});
|
|
21
|
-
class DoraBDSNeo3 extends RpcBDSNeo3_1.RPCBDSNeo3 {
|
|
22
|
-
constructor(network, feeToken, claimToken) {
|
|
23
|
-
if (network.type === 'custom') {
|
|
24
|
-
throw new Error('DoraBDSNeo3 does not support custom networks');
|
|
25
|
-
}
|
|
26
|
-
super(network, feeToken, claimToken);
|
|
27
|
-
this.network = network;
|
|
28
|
-
}
|
|
29
|
-
getTransaction(hash) {
|
|
30
|
-
var _a, _b;
|
|
31
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
32
|
-
try {
|
|
33
|
-
const data = yield NeoRest.transaction(hash, this.network.type);
|
|
34
|
-
return {
|
|
35
|
-
block: data.block,
|
|
36
|
-
time: Number(data.time),
|
|
37
|
-
hash: data.hash,
|
|
38
|
-
fee: neon_js_1.u.BigInteger.fromNumber((_a = data.netfee) !== null && _a !== void 0 ? _a : 0)
|
|
39
|
-
.add(neon_js_1.u.BigInteger.fromNumber((_b = data.sysfee) !== null && _b !== void 0 ? _b : 0))
|
|
40
|
-
.toDecimal(this.feeToken.decimals),
|
|
41
|
-
notifications: [],
|
|
42
|
-
transfers: [],
|
|
43
|
-
};
|
|
44
|
-
}
|
|
45
|
-
catch (_c) {
|
|
46
|
-
throw new Error(`Transaction not found: ${hash}`);
|
|
47
|
-
}
|
|
48
|
-
});
|
|
49
|
-
}
|
|
50
|
-
getTransactionsByAddress({ address, page = 1, }) {
|
|
51
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
52
|
-
const data = yield NeoRest.addressTXFull(address, page, this.network.type);
|
|
53
|
-
const transactions = yield Promise.all(data.items.map((item) => __awaiter(this, void 0, void 0, function* () {
|
|
54
|
-
var _a, _b;
|
|
55
|
-
const filteredTransfers = item.notifications.filter(item => item.event_name === 'Transfer' && (item.state.value.length === 3 || item.state.value.length === 4));
|
|
56
|
-
const transferPromises = filteredTransfers.map(({ contract: contractHash, state: { value: properties } }) => __awaiter(this, void 0, void 0, function* () {
|
|
57
|
-
var _c;
|
|
58
|
-
const isAsset = properties.length === 3;
|
|
59
|
-
const from = properties[0].value;
|
|
60
|
-
const to = properties[1].value;
|
|
61
|
-
const convertedFrom = from ? this.convertByteStringToAddress(from) : 'Mint';
|
|
62
|
-
const convertedTo = to ? this.convertByteStringToAddress(to) : 'Burn';
|
|
63
|
-
if (isAsset) {
|
|
64
|
-
const token = yield this.getTokenInfo(contractHash);
|
|
65
|
-
const [, , { value: amount }] = properties;
|
|
66
|
-
return {
|
|
67
|
-
amount: neon_js_1.u.BigInteger.fromNumber(amount).toDecimal((_c = token.decimals) !== null && _c !== void 0 ? _c : 0),
|
|
68
|
-
from: convertedFrom,
|
|
69
|
-
to: convertedTo,
|
|
70
|
-
contractHash,
|
|
71
|
-
type: 'token',
|
|
72
|
-
token,
|
|
73
|
-
};
|
|
74
|
-
}
|
|
75
|
-
return {
|
|
76
|
-
from: convertedFrom,
|
|
77
|
-
to: convertedTo,
|
|
78
|
-
tokenId: properties[3].value,
|
|
79
|
-
contractHash,
|
|
80
|
-
type: 'nft',
|
|
81
|
-
};
|
|
82
|
-
}));
|
|
83
|
-
const transfers = yield Promise.all(transferPromises);
|
|
84
|
-
const notifications = item.notifications.map(notification => ({
|
|
85
|
-
eventName: notification.event_name,
|
|
86
|
-
state: notification.state,
|
|
87
|
-
}));
|
|
88
|
-
return {
|
|
89
|
-
block: item.block,
|
|
90
|
-
time: Number(item.time),
|
|
91
|
-
hash: item.hash,
|
|
92
|
-
fee: neon_js_1.u.BigInteger.fromNumber((_a = item.netfee) !== null && _a !== void 0 ? _a : 0)
|
|
93
|
-
.add(neon_js_1.u.BigInteger.fromNumber((_b = item.sysfee) !== null && _b !== void 0 ? _b : 0))
|
|
94
|
-
.toDecimal(this.feeToken.decimals),
|
|
95
|
-
transfers,
|
|
96
|
-
notifications,
|
|
97
|
-
};
|
|
98
|
-
})));
|
|
99
|
-
return {
|
|
100
|
-
totalCount: data.totalCount,
|
|
101
|
-
transactions,
|
|
102
|
-
limit: 15,
|
|
103
|
-
};
|
|
104
|
-
});
|
|
105
|
-
}
|
|
106
|
-
getContract(contractHash) {
|
|
107
|
-
var _a, _b;
|
|
108
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
109
|
-
try {
|
|
110
|
-
const data = yield NeoRest.contract(contractHash, this.network.type);
|
|
111
|
-
return {
|
|
112
|
-
hash: data.hash,
|
|
113
|
-
methods: (_b = (_a = data.manifest.abi) === null || _a === void 0 ? void 0 : _a.methods) !== null && _b !== void 0 ? _b : [],
|
|
114
|
-
name: data.manifest.name,
|
|
115
|
-
};
|
|
116
|
-
}
|
|
117
|
-
catch (_c) {
|
|
118
|
-
throw new Error(`Contract not found: ${contractHash}`);
|
|
119
|
-
}
|
|
120
|
-
});
|
|
121
|
-
}
|
|
122
|
-
getTokenInfo(tokenHash) {
|
|
123
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
124
|
-
const localToken = constants_1.TOKENS[this.network.type].find(token => token.hash === tokenHash);
|
|
125
|
-
if (localToken)
|
|
126
|
-
return localToken;
|
|
127
|
-
if (this.tokenCache.has(tokenHash)) {
|
|
128
|
-
return this.tokenCache.get(tokenHash);
|
|
129
|
-
}
|
|
130
|
-
try {
|
|
131
|
-
const { decimals, symbol, name, scripthash } = yield NeoRest.asset(tokenHash, this.network.type);
|
|
132
|
-
const token = {
|
|
133
|
-
decimals: Number(decimals),
|
|
134
|
-
symbol,
|
|
135
|
-
name,
|
|
136
|
-
hash: scripthash,
|
|
137
|
-
};
|
|
138
|
-
this.tokenCache.set(tokenHash, token);
|
|
139
|
-
return token;
|
|
140
|
-
}
|
|
141
|
-
catch (_a) {
|
|
142
|
-
throw new Error(`Token not found: ${tokenHash}`);
|
|
143
|
-
}
|
|
144
|
-
});
|
|
145
|
-
}
|
|
146
|
-
getBalance(address) {
|
|
147
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
148
|
-
const response = yield NeoRest.balance(address, this.network.type);
|
|
149
|
-
const promises = response.map((balance) => __awaiter(this, void 0, void 0, function* () {
|
|
150
|
-
try {
|
|
151
|
-
const token = yield this.getTokenInfo(balance.asset);
|
|
152
|
-
return {
|
|
153
|
-
amount:
|
|
154
|
-
token,
|
|
155
|
-
};
|
|
156
|
-
}
|
|
157
|
-
catch (_a) { }
|
|
158
|
-
}));
|
|
159
|
-
const balances = yield Promise.all(promises);
|
|
160
|
-
const filteredBalances = balances.filter(balance => balance !== undefined);
|
|
161
|
-
return filteredBalances;
|
|
162
|
-
});
|
|
163
|
-
}
|
|
164
|
-
convertByteStringToAddress(byteString) {
|
|
165
|
-
const account = new neon_js_1.wallet.Account(neon_js_1.u.reverseHex(neon_js_1.u.HexString.fromBase64(byteString).toString()));
|
|
166
|
-
return account.address;
|
|
167
|
-
}
|
|
168
|
-
}
|
|
169
|
-
exports.DoraBDSNeo3 = DoraBDSNeo3;
|
|
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
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.DoraBDSNeo3 = void 0;
|
|
13
|
+
const neon_js_1 = require("@cityofzion/neon-js");
|
|
14
|
+
const api_1 = require("@cityofzion/dora-ts/dist/api");
|
|
15
|
+
const RpcBDSNeo3_1 = require("./RpcBDSNeo3");
|
|
16
|
+
const constants_1 = require("./constants");
|
|
17
|
+
const NeoRest = new api_1.NeoRESTApi({
|
|
18
|
+
doraUrl: 'https://dora.coz.io',
|
|
19
|
+
endpoint: '/api/v2/neo3',
|
|
20
|
+
});
|
|
21
|
+
class DoraBDSNeo3 extends RpcBDSNeo3_1.RPCBDSNeo3 {
|
|
22
|
+
constructor(network, feeToken, claimToken) {
|
|
23
|
+
if (network.type === 'custom') {
|
|
24
|
+
throw new Error('DoraBDSNeo3 does not support custom networks');
|
|
25
|
+
}
|
|
26
|
+
super(network, feeToken, claimToken);
|
|
27
|
+
this.network = network;
|
|
28
|
+
}
|
|
29
|
+
getTransaction(hash) {
|
|
30
|
+
var _a, _b;
|
|
31
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
32
|
+
try {
|
|
33
|
+
const data = yield NeoRest.transaction(hash, this.network.type);
|
|
34
|
+
return {
|
|
35
|
+
block: data.block,
|
|
36
|
+
time: Number(data.time),
|
|
37
|
+
hash: data.hash,
|
|
38
|
+
fee: neon_js_1.u.BigInteger.fromNumber((_a = data.netfee) !== null && _a !== void 0 ? _a : 0)
|
|
39
|
+
.add(neon_js_1.u.BigInteger.fromNumber((_b = data.sysfee) !== null && _b !== void 0 ? _b : 0))
|
|
40
|
+
.toDecimal(this.feeToken.decimals),
|
|
41
|
+
notifications: [],
|
|
42
|
+
transfers: [],
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
catch (_c) {
|
|
46
|
+
throw new Error(`Transaction not found: ${hash}`);
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
getTransactionsByAddress({ address, page = 1, }) {
|
|
51
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
52
|
+
const data = yield NeoRest.addressTXFull(address, page, this.network.type);
|
|
53
|
+
const transactions = yield Promise.all(data.items.map((item) => __awaiter(this, void 0, void 0, function* () {
|
|
54
|
+
var _a, _b;
|
|
55
|
+
const filteredTransfers = item.notifications.filter(item => item.event_name === 'Transfer' && (item.state.value.length === 3 || item.state.value.length === 4));
|
|
56
|
+
const transferPromises = filteredTransfers.map(({ contract: contractHash, state: { value: properties } }) => __awaiter(this, void 0, void 0, function* () {
|
|
57
|
+
var _c;
|
|
58
|
+
const isAsset = properties.length === 3;
|
|
59
|
+
const from = properties[0].value;
|
|
60
|
+
const to = properties[1].value;
|
|
61
|
+
const convertedFrom = from ? this.convertByteStringToAddress(from) : 'Mint';
|
|
62
|
+
const convertedTo = to ? this.convertByteStringToAddress(to) : 'Burn';
|
|
63
|
+
if (isAsset) {
|
|
64
|
+
const token = yield this.getTokenInfo(contractHash);
|
|
65
|
+
const [, , { value: amount }] = properties;
|
|
66
|
+
return {
|
|
67
|
+
amount: neon_js_1.u.BigInteger.fromNumber(amount).toDecimal((_c = token.decimals) !== null && _c !== void 0 ? _c : 0),
|
|
68
|
+
from: convertedFrom,
|
|
69
|
+
to: convertedTo,
|
|
70
|
+
contractHash,
|
|
71
|
+
type: 'token',
|
|
72
|
+
token,
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
return {
|
|
76
|
+
from: convertedFrom,
|
|
77
|
+
to: convertedTo,
|
|
78
|
+
tokenId: properties[3].value,
|
|
79
|
+
contractHash,
|
|
80
|
+
type: 'nft',
|
|
81
|
+
};
|
|
82
|
+
}));
|
|
83
|
+
const transfers = yield Promise.all(transferPromises);
|
|
84
|
+
const notifications = item.notifications.map(notification => ({
|
|
85
|
+
eventName: notification.event_name,
|
|
86
|
+
state: notification.state,
|
|
87
|
+
}));
|
|
88
|
+
return {
|
|
89
|
+
block: item.block,
|
|
90
|
+
time: Number(item.time),
|
|
91
|
+
hash: item.hash,
|
|
92
|
+
fee: neon_js_1.u.BigInteger.fromNumber((_a = item.netfee) !== null && _a !== void 0 ? _a : 0)
|
|
93
|
+
.add(neon_js_1.u.BigInteger.fromNumber((_b = item.sysfee) !== null && _b !== void 0 ? _b : 0))
|
|
94
|
+
.toDecimal(this.feeToken.decimals),
|
|
95
|
+
transfers,
|
|
96
|
+
notifications,
|
|
97
|
+
};
|
|
98
|
+
})));
|
|
99
|
+
return {
|
|
100
|
+
totalCount: data.totalCount,
|
|
101
|
+
transactions,
|
|
102
|
+
limit: 15,
|
|
103
|
+
};
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
getContract(contractHash) {
|
|
107
|
+
var _a, _b;
|
|
108
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
109
|
+
try {
|
|
110
|
+
const data = yield NeoRest.contract(contractHash, this.network.type);
|
|
111
|
+
return {
|
|
112
|
+
hash: data.hash,
|
|
113
|
+
methods: (_b = (_a = data.manifest.abi) === null || _a === void 0 ? void 0 : _a.methods) !== null && _b !== void 0 ? _b : [],
|
|
114
|
+
name: data.manifest.name,
|
|
115
|
+
};
|
|
116
|
+
}
|
|
117
|
+
catch (_c) {
|
|
118
|
+
throw new Error(`Contract not found: ${contractHash}`);
|
|
119
|
+
}
|
|
120
|
+
});
|
|
121
|
+
}
|
|
122
|
+
getTokenInfo(tokenHash) {
|
|
123
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
124
|
+
const localToken = constants_1.TOKENS[this.network.type].find(token => token.hash === tokenHash);
|
|
125
|
+
if (localToken)
|
|
126
|
+
return localToken;
|
|
127
|
+
if (this.tokenCache.has(tokenHash)) {
|
|
128
|
+
return this.tokenCache.get(tokenHash);
|
|
129
|
+
}
|
|
130
|
+
try {
|
|
131
|
+
const { decimals, symbol, name, scripthash } = yield NeoRest.asset(tokenHash, this.network.type);
|
|
132
|
+
const token = {
|
|
133
|
+
decimals: Number(decimals),
|
|
134
|
+
symbol,
|
|
135
|
+
name,
|
|
136
|
+
hash: scripthash,
|
|
137
|
+
};
|
|
138
|
+
this.tokenCache.set(tokenHash, token);
|
|
139
|
+
return token;
|
|
140
|
+
}
|
|
141
|
+
catch (_a) {
|
|
142
|
+
throw new Error(`Token not found: ${tokenHash}`);
|
|
143
|
+
}
|
|
144
|
+
});
|
|
145
|
+
}
|
|
146
|
+
getBalance(address) {
|
|
147
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
148
|
+
const response = yield NeoRest.balance(address, this.network.type);
|
|
149
|
+
const promises = response.map((balance) => __awaiter(this, void 0, void 0, function* () {
|
|
150
|
+
try {
|
|
151
|
+
const token = yield this.getTokenInfo(balance.asset);
|
|
152
|
+
return {
|
|
153
|
+
amount: balance.balance.toString(),
|
|
154
|
+
token,
|
|
155
|
+
};
|
|
156
|
+
}
|
|
157
|
+
catch (_a) { }
|
|
158
|
+
}));
|
|
159
|
+
const balances = yield Promise.all(promises);
|
|
160
|
+
const filteredBalances = balances.filter(balance => balance !== undefined);
|
|
161
|
+
return filteredBalances;
|
|
162
|
+
});
|
|
163
|
+
}
|
|
164
|
+
convertByteStringToAddress(byteString) {
|
|
165
|
+
const account = new neon_js_1.wallet.Account(neon_js_1.u.reverseHex(neon_js_1.u.HexString.fromBase64(byteString).toString()));
|
|
166
|
+
return account.address;
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
exports.DoraBDSNeo3 = DoraBDSNeo3;
|
package/dist/DoraESNeo3.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { ExplorerService, NetworkType, BuildNftUrlParams } from '@cityofzion/blockchain-service';
|
|
2
|
-
export declare class DoraESNeo3 implements ExplorerService {
|
|
3
|
-
private networkType;
|
|
4
|
-
constructor(networkType: NetworkType);
|
|
5
|
-
buildTransactionUrl(hash: string): string;
|
|
6
|
-
buildNftUrl({ contractHash, tokenId }: BuildNftUrlParams): string;
|
|
7
|
-
}
|
|
1
|
+
import { ExplorerService, NetworkType, BuildNftUrlParams } from '@cityofzion/blockchain-service';
|
|
2
|
+
export declare class DoraESNeo3 implements ExplorerService {
|
|
3
|
+
private networkType;
|
|
4
|
+
constructor(networkType: NetworkType);
|
|
5
|
+
buildTransactionUrl(hash: string): string;
|
|
6
|
+
buildNftUrl({ contractHash, tokenId }: BuildNftUrlParams): string;
|
|
7
|
+
}
|
package/dist/DoraESNeo3.js
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.DoraESNeo3 = void 0;
|
|
4
|
-
class DoraESNeo3 {
|
|
5
|
-
constructor(networkType) {
|
|
6
|
-
this.networkType = networkType;
|
|
7
|
-
}
|
|
8
|
-
buildTransactionUrl(hash) {
|
|
9
|
-
if (this.networkType === 'custom')
|
|
10
|
-
throw new Error('DoraESNeo3 does not support custom network');
|
|
11
|
-
return `https://dora.coz.io/transaction/neo3/${this.networkType}/${hash}`;
|
|
12
|
-
}
|
|
13
|
-
buildNftUrl({ contractHash, tokenId }) {
|
|
14
|
-
if (this.networkType === 'custom')
|
|
15
|
-
throw new Error('DoraESNeo3 does not support custom network');
|
|
16
|
-
return `https://dora.coz.io/nft/neo3/${this.networkType}/${contractHash}/${tokenId}`;
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
exports.DoraESNeo3 = DoraESNeo3;
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DoraESNeo3 = void 0;
|
|
4
|
+
class DoraESNeo3 {
|
|
5
|
+
constructor(networkType) {
|
|
6
|
+
this.networkType = networkType;
|
|
7
|
+
}
|
|
8
|
+
buildTransactionUrl(hash) {
|
|
9
|
+
if (this.networkType === 'custom')
|
|
10
|
+
throw new Error('DoraESNeo3 does not support custom network');
|
|
11
|
+
return `https://dora.coz.io/transaction/neo3/${this.networkType}/${hash}`;
|
|
12
|
+
}
|
|
13
|
+
buildNftUrl({ contractHash, tokenId }) {
|
|
14
|
+
if (this.networkType === 'custom')
|
|
15
|
+
throw new Error('DoraESNeo3 does not support custom network');
|
|
16
|
+
return `https://dora.coz.io/nft/neo3/${this.networkType}/${contractHash}/${tokenId}`;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
exports.DoraESNeo3 = DoraESNeo3;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { Currency, ExchangeDataService, NetworkType, TokenPricesResponse } from '@cityofzion/blockchain-service';
|
|
2
|
-
export declare class FlamingoEDSNeo3 implements ExchangeDataService {
|
|
3
|
-
readonly networkType: NetworkType;
|
|
4
|
-
private axiosInstance;
|
|
5
|
-
constructor(networkType: NetworkType);
|
|
6
|
-
getTokenPrices(currency: Currency): Promise<TokenPricesResponse[]>;
|
|
7
|
-
private getCurrencyRatio;
|
|
8
|
-
}
|
|
1
|
+
import { Currency, ExchangeDataService, NetworkType, TokenPricesResponse } from '@cityofzion/blockchain-service';
|
|
2
|
+
export declare class FlamingoEDSNeo3 implements ExchangeDataService {
|
|
3
|
+
readonly networkType: NetworkType;
|
|
4
|
+
private axiosInstance;
|
|
5
|
+
constructor(networkType: NetworkType);
|
|
6
|
+
getTokenPrices(currency: Currency): Promise<TokenPricesResponse[]>;
|
|
7
|
+
private getCurrencyRatio;
|
|
8
|
+
}
|
package/dist/FlamingoEDSNeo3.js
CHANGED
|
@@ -1,44 +1,45 @@
|
|
|
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 __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
-
};
|
|
14
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
-
exports.FlamingoEDSNeo3 = void 0;
|
|
16
|
-
const axios_1 = __importDefault(require("axios"));
|
|
17
|
-
class FlamingoEDSNeo3 {
|
|
18
|
-
constructor(networkType) {
|
|
19
|
-
this.networkType = networkType;
|
|
20
|
-
this.axiosInstance = axios_1.default.create({ baseURL: 'https://api.flamingo.finance' });
|
|
21
|
-
}
|
|
22
|
-
getTokenPrices(currency) {
|
|
23
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
24
|
-
if (this.networkType !== 'mainnet')
|
|
25
|
-
throw new Error('Exchange is only available on mainnet');
|
|
26
|
-
const { data: prices } = yield this.axiosInstance.get('/token-info/prices');
|
|
27
|
-
let currencyRatio = 1;
|
|
28
|
-
if (currency !== 'USD') {
|
|
29
|
-
currencyRatio = yield this.getCurrencyRatio(currency);
|
|
30
|
-
}
|
|
31
|
-
return prices.map(price => ({
|
|
32
|
-
price: price.usd_price * currencyRatio,
|
|
33
|
-
symbol: price.symbol,
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
}
|
|
44
|
-
|
|
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 __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.FlamingoEDSNeo3 = void 0;
|
|
16
|
+
const axios_1 = __importDefault(require("axios"));
|
|
17
|
+
class FlamingoEDSNeo3 {
|
|
18
|
+
constructor(networkType) {
|
|
19
|
+
this.networkType = networkType;
|
|
20
|
+
this.axiosInstance = axios_1.default.create({ baseURL: 'https://api.flamingo.finance' });
|
|
21
|
+
}
|
|
22
|
+
getTokenPrices(currency) {
|
|
23
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
24
|
+
if (this.networkType !== 'mainnet')
|
|
25
|
+
throw new Error('Exchange is only available on mainnet');
|
|
26
|
+
const { data: prices } = yield this.axiosInstance.get('/token-info/prices');
|
|
27
|
+
let currencyRatio = 1;
|
|
28
|
+
if (currency !== 'USD') {
|
|
29
|
+
currencyRatio = yield this.getCurrencyRatio(currency);
|
|
30
|
+
}
|
|
31
|
+
return prices.map(price => ({
|
|
32
|
+
price: price.usd_price * currencyRatio,
|
|
33
|
+
symbol: price.symbol,
|
|
34
|
+
hash: price.hash,
|
|
35
|
+
}));
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
getCurrencyRatio(currency) {
|
|
39
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
40
|
+
const { data } = yield this.axiosInstance.get(`/fiat/exchange-rate?pair=USD_${currency}`);
|
|
41
|
+
return data;
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
exports.FlamingoEDSNeo3 = FlamingoEDSNeo3;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { NftResponse, NftsResponse, NetworkType, NftDataService, GetNftParam, GetNftsByAddressParams } from '@cityofzion/blockchain-service';
|
|
2
|
-
export declare class GhostMarketNDSNeo3 implements NftDataService {
|
|
3
|
-
private networkType;
|
|
4
|
-
constructor(networkType: NetworkType);
|
|
5
|
-
getNftsByAddress({ address, size, cursor, page }: GetNftsByAddressParams): Promise<NftsResponse>;
|
|
6
|
-
getNft({ contractHash, tokenId }: GetNftParam): Promise<NftResponse>;
|
|
7
|
-
private treatGhostMarketImage;
|
|
8
|
-
private getUrlWithParams;
|
|
9
|
-
private parse;
|
|
10
|
-
}
|
|
1
|
+
import { NftResponse, NftsResponse, NetworkType, NftDataService, GetNftParam, GetNftsByAddressParams } from '@cityofzion/blockchain-service';
|
|
2
|
+
export declare class GhostMarketNDSNeo3 implements NftDataService {
|
|
3
|
+
private networkType;
|
|
4
|
+
constructor(networkType: NetworkType);
|
|
5
|
+
getNftsByAddress({ address, size, cursor, page }: GetNftsByAddressParams): Promise<NftsResponse>;
|
|
6
|
+
getNft({ contractHash, tokenId }: GetNftParam): Promise<NftResponse>;
|
|
7
|
+
private treatGhostMarketImage;
|
|
8
|
+
private getUrlWithParams;
|
|
9
|
+
private parse;
|
|
10
|
+
}
|