@cityofzion/bs-neo3 0.4.2 → 0.7.1
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/state.json +1 -1
- package/.rush/temp/package-deps_build.json +25 -0
- package/.rush/temp/shrinkwrap-deps.json +2 -2
- package/bs-neo3.build.log +1 -86
- package/dist/BSNeo3.d.ts +24 -27
- package/dist/BSNeo3.js +124 -162
- package/dist/DoraBDSNeo3.d.ts +12 -0
- package/dist/DoraBDSNeo3.js +169 -0
- package/dist/FlamingoEDSNeo3.d.ts +8 -0
- package/dist/FlamingoEDSNeo3.js +44 -0
- package/dist/GhostMarketNDSNeo3.d.ts +10 -0
- package/dist/GhostMarketNDSNeo3.js +75 -0
- package/dist/RpcBDSNeo3.d.ts +15 -0
- package/dist/RpcBDSNeo3.js +152 -0
- package/dist/assets/tokens/common.json +14 -0
- package/dist/assets/tokens/mainnet.json +116 -0
- package/dist/constants.d.ts +7 -3
- package/dist/constants.js +24 -9
- package/dist/index.d.ts +4 -2
- package/dist/index.js +4 -2
- package/docs/assets/search.js +1 -1
- package/docs/classes/BDSNeo3.html +13 -13
- package/docs/classes/BSNeo3.html +80 -36
- package/docs/interfaces/DoraNeo3Abi.html +6 -6
- package/docs/interfaces/DoraNeo3Asset.html +9 -9
- package/docs/interfaces/DoraNeo3AssetState.html +6 -6
- package/docs/interfaces/DoraNeo3Balance.html +5 -5
- package/docs/interfaces/DoraNeo3ConsensusNode.html +3 -3
- package/docs/interfaces/DoraNeo3Contract.html +8 -8
- package/docs/interfaces/DoraNeo3Event.html +3 -3
- package/docs/interfaces/DoraNeo3Features.html +1 -1
- package/docs/interfaces/DoraNeo3HistoryState.html +3 -3
- package/docs/interfaces/DoraNeo3Invocation.html +3 -3
- package/docs/interfaces/DoraNeo3Item.html +11 -11
- package/docs/interfaces/DoraNeo3Manifest.html +9 -9
- package/docs/interfaces/DoraNeo3Metadata.html +12 -12
- package/docs/interfaces/DoraNeo3Method.html +12 -12
- package/docs/interfaces/DoraNeo3Nef.html +7 -7
- package/docs/interfaces/DoraNeo3Notification.html +4 -4
- package/docs/interfaces/DoraNeo3Parameter.html +3 -3
- package/docs/interfaces/DoraNeo3Permission.html +3 -3
- package/docs/interfaces/DoraNeo3Signer.html +3 -3
- package/docs/interfaces/DoraNeo3Token.html +6 -6
- package/docs/interfaces/DoraNeo3Transaction.html +16 -16
- package/docs/interfaces/DoraNeo3TransactionHistory.html +3 -3
- package/docs/interfaces/DoraNeo3Transfer.html +9 -9
- package/docs/interfaces/DoraNeo3Witness.html +3 -3
- package/docs/variables/DORA_ASSET.html +1 -1
- package/docs/variables/DORA_BALANCE.html +1 -1
- package/docs/variables/DORA_CONTRACT.html +1 -1
- package/docs/variables/DORA_NODES.html +1 -1
- package/docs/variables/DORA_TRANSACTION.html +1 -1
- package/docs/variables/DORA_TRANSACTIONS.html +1 -1
- package/docs/variables/explorerOptions.html +1 -1
- package/docs/variables/gasInfoNeo3.html +11 -2
- package/docs/variables/neoInfoNeo3.html +11 -2
- package/jest.config.ts +13 -0
- package/jest.setup.ts +1 -0
- package/package.json +14 -6
- package/src/BSNeo3.ts +221 -221
- package/src/DoraBDSNeo3.ts +180 -0
- package/src/FlamingoEDSNeo3.ts +45 -0
- package/src/GhostMarketNDSNeo3.ts +117 -0
- package/src/RpcBDSNeo3.ts +155 -0
- package/src/__tests__/BDSNeo3.spec.ts +126 -0
- package/src/__tests__/BSNeo3.spec.ts +142 -0
- package/src/__tests__/FlamingoEDSNeo3.spec.ts +45 -0
- package/src/__tests__/GhostMarketNDSNeo3.spec.ts +43 -0
- package/src/__tests__/utils/sleep.ts +1 -0
- package/src/assets/tokens/common.json +14 -0
- package/src/assets/tokens/mainnet.json +116 -0
- package/src/constants.ts +26 -10
- package/src/index.ts +4 -2
- package/tsconfig.build.json +4 -0
- package/tsconfig.json +3 -7
- package/bs-neo3.build.error.log +0 -84
- package/dist/excpetions.d.ts +0 -3
- package/dist/excpetions.js +0 -8
- package/src/BDSNeo3.ts +0 -168
- package/src/assets/blockchain_icon_neo.png +0 -0
- package/src/assets/blockchain_icon_neo_white.png +0 -0
- package/src/assets/tokens.json +0 -129
- package/src/exceptions.ts +0 -5
- package/src/explorer/dora/DoraNeo3Responses.ts +0 -207
- package/src/explorer/dora/DoraNeo3Routes.ts +0 -6
- package/src/explorer/index.ts +0 -8
|
@@ -0,0 +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: neon_js_1.u.BigInteger.fromNumber(balance.balance).toDecimal(token.decimals),
|
|
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;
|
|
@@ -0,0 +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
|
+
}
|
|
@@ -0,0 +1,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
|
+
}));
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
getCurrencyRatio(currency) {
|
|
38
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
39
|
+
const { data } = yield this.axiosInstance.get(`/fiat/exchange-rate?pair=USD_${currency}`);
|
|
40
|
+
return data;
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
exports.FlamingoEDSNeo3 = FlamingoEDSNeo3;
|
|
@@ -0,0 +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
|
+
}
|
|
@@ -0,0 +1,75 @@
|
|
|
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.GhostMarketNDSNeo3 = void 0;
|
|
16
|
+
const query_string_1 = __importDefault(require("query-string"));
|
|
17
|
+
const axios_1 = __importDefault(require("axios"));
|
|
18
|
+
const constants_1 = require("./constants");
|
|
19
|
+
class GhostMarketNDSNeo3 {
|
|
20
|
+
constructor(networkType) {
|
|
21
|
+
this.networkType = networkType;
|
|
22
|
+
}
|
|
23
|
+
getNftsByAddress({ address, size = 18, cursor, page }) {
|
|
24
|
+
var _a;
|
|
25
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
26
|
+
const url = this.getUrlWithParams({
|
|
27
|
+
size,
|
|
28
|
+
owners: [address],
|
|
29
|
+
cursor: cursor,
|
|
30
|
+
});
|
|
31
|
+
const { data } = yield axios_1.default.get(url);
|
|
32
|
+
const nfts = (_a = data.assets) !== null && _a !== void 0 ? _a : [];
|
|
33
|
+
return { nextCursor: data.next, items: nfts.map(this.parse.bind(this)) };
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
getNft({ contractHash, tokenId }) {
|
|
37
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
38
|
+
const url = this.getUrlWithParams({
|
|
39
|
+
contract: contractHash,
|
|
40
|
+
tokenIds: [tokenId],
|
|
41
|
+
});
|
|
42
|
+
const { data } = yield axios_1.default.get(url);
|
|
43
|
+
return this.parse(data.assets[0]);
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
treatGhostMarketImage(srcImage) {
|
|
47
|
+
if (!srcImage) {
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
if (srcImage.startsWith('ipfs://')) {
|
|
51
|
+
const [, imageId] = srcImage.split('://');
|
|
52
|
+
return `https://ghostmarket.mypinata.cloud/ipfs/${imageId}`;
|
|
53
|
+
}
|
|
54
|
+
return srcImage;
|
|
55
|
+
}
|
|
56
|
+
getUrlWithParams(params) {
|
|
57
|
+
const parameters = query_string_1.default.stringify(Object.assign({ chain: constants_1.GHOSTMARKET_CHAIN_BY_NETWORK_TYPE[this.networkType] }, params), { arrayFormat: 'bracket' });
|
|
58
|
+
return `${constants_1.GHOSTMARKET_URL_BY_NETWORK_TYPE[this.networkType]}/assets?${parameters}`;
|
|
59
|
+
}
|
|
60
|
+
parse(data) {
|
|
61
|
+
var _a, _b;
|
|
62
|
+
const nftResponse = {
|
|
63
|
+
collectionImage: this.treatGhostMarketImage((_a = data.collection) === null || _a === void 0 ? void 0 : _a.logoUrl),
|
|
64
|
+
id: data.tokenId,
|
|
65
|
+
contractHash: data.contract.hash,
|
|
66
|
+
symbol: data.contract.symbol,
|
|
67
|
+
collectionName: (_b = data.collection) === null || _b === void 0 ? void 0 : _b.name,
|
|
68
|
+
image: this.treatGhostMarketImage(data.metadata.mediaUri),
|
|
69
|
+
isSVG: String(data.metadata.mediaType).includes('svg+xml'),
|
|
70
|
+
name: data.metadata.name,
|
|
71
|
+
};
|
|
72
|
+
return nftResponse;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
exports.GhostMarketNDSNeo3 = GhostMarketNDSNeo3;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { BDSClaimable, BalanceResponse, BlockchainDataService, ContractResponse, Network, Token, TransactionResponse, TransactionsByAddressParams, TransactionsByAddressResponse } from '@cityofzion/blockchain-service';
|
|
2
|
+
export declare class RPCBDSNeo3 implements BlockchainDataService, BDSClaimable {
|
|
3
|
+
protected readonly tokenCache: Map<string, Token>;
|
|
4
|
+
protected readonly feeToken: Token;
|
|
5
|
+
protected readonly claimToken: Token;
|
|
6
|
+
readonly network: Network;
|
|
7
|
+
constructor(network: Network, feeToken: Token, claimToken: Token);
|
|
8
|
+
getTransaction(hash: string): Promise<TransactionResponse>;
|
|
9
|
+
getTransactionsByAddress(_params: TransactionsByAddressParams): Promise<TransactionsByAddressResponse>;
|
|
10
|
+
getContract(contractHash: string): Promise<ContractResponse>;
|
|
11
|
+
getTokenInfo(tokenHash: string): Promise<Token>;
|
|
12
|
+
getBalance(address: string): Promise<BalanceResponse[]>;
|
|
13
|
+
getBlockHeight(): Promise<number>;
|
|
14
|
+
getUnclaimed(address: string): Promise<string>;
|
|
15
|
+
}
|
|
@@ -0,0 +1,152 @@
|
|
|
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.RPCBDSNeo3 = void 0;
|
|
13
|
+
const neon_core_1 = require("@cityofzion/neon-core");
|
|
14
|
+
const neon_invoker_1 = require("@cityofzion/neon-invoker");
|
|
15
|
+
const constants_1 = require("./constants");
|
|
16
|
+
class RPCBDSNeo3 {
|
|
17
|
+
constructor(network, feeToken, claimToken) {
|
|
18
|
+
this.tokenCache = new Map();
|
|
19
|
+
this.network = network;
|
|
20
|
+
this.feeToken = feeToken;
|
|
21
|
+
this.claimToken = claimToken;
|
|
22
|
+
}
|
|
23
|
+
getTransaction(hash) {
|
|
24
|
+
var _a, _b;
|
|
25
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
26
|
+
try {
|
|
27
|
+
const rpcClient = new neon_core_1.rpc.RPCClient(this.network.url);
|
|
28
|
+
const response = yield rpcClient.getRawTransaction(hash, true);
|
|
29
|
+
return {
|
|
30
|
+
hash: response.hash,
|
|
31
|
+
block: response.validuntilblock,
|
|
32
|
+
fee: neon_core_1.u.BigInteger.fromNumber((_a = response.netfee) !== null && _a !== void 0 ? _a : 0)
|
|
33
|
+
.add(neon_core_1.u.BigInteger.fromNumber((_b = response.sysfee) !== null && _b !== void 0 ? _b : 0))
|
|
34
|
+
.toDecimal(this.feeToken.decimals),
|
|
35
|
+
notifications: [],
|
|
36
|
+
transfers: [],
|
|
37
|
+
time: response.blocktime,
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
catch (_c) {
|
|
41
|
+
throw new Error(`Transaction not found: ${hash}`);
|
|
42
|
+
}
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
getTransactionsByAddress(_params) {
|
|
46
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
47
|
+
throw new Error('Method not supported.');
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
getContract(contractHash) {
|
|
51
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
52
|
+
try {
|
|
53
|
+
const rpcClient = new neon_core_1.rpc.RPCClient(this.network.url);
|
|
54
|
+
const contractState = yield rpcClient.getContractState(contractHash);
|
|
55
|
+
const methods = contractState.manifest.abi.methods.map(method => ({
|
|
56
|
+
name: method.name,
|
|
57
|
+
parameters: method.parameters.map(parameter => ({
|
|
58
|
+
name: parameter.name,
|
|
59
|
+
type: parameter.type,
|
|
60
|
+
})),
|
|
61
|
+
}));
|
|
62
|
+
return {
|
|
63
|
+
hash: contractState.hash,
|
|
64
|
+
name: contractState.manifest.name,
|
|
65
|
+
methods,
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
catch (_a) {
|
|
69
|
+
throw new Error(`Contract not found: ${contractHash}`);
|
|
70
|
+
}
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
getTokenInfo(tokenHash) {
|
|
74
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
75
|
+
const localToken = constants_1.TOKENS[this.network.type].find(token => token.hash === tokenHash);
|
|
76
|
+
if (localToken)
|
|
77
|
+
return localToken;
|
|
78
|
+
if (this.tokenCache.has(tokenHash)) {
|
|
79
|
+
return this.tokenCache.get(tokenHash);
|
|
80
|
+
}
|
|
81
|
+
try {
|
|
82
|
+
const rpcClient = new neon_core_1.rpc.RPCClient(this.network.url);
|
|
83
|
+
const contractState = yield rpcClient.getContractState(tokenHash);
|
|
84
|
+
const invoker = yield neon_invoker_1.NeonInvoker.init({
|
|
85
|
+
rpcAddress: this.network.url,
|
|
86
|
+
});
|
|
87
|
+
const response = yield invoker.testInvoke({
|
|
88
|
+
invocations: [
|
|
89
|
+
{
|
|
90
|
+
scriptHash: tokenHash,
|
|
91
|
+
operation: 'decimals',
|
|
92
|
+
args: [],
|
|
93
|
+
},
|
|
94
|
+
{ scriptHash: tokenHash, operation: 'symbol', args: [] },
|
|
95
|
+
],
|
|
96
|
+
});
|
|
97
|
+
const decimals = Number(response.stack[0].value);
|
|
98
|
+
const symbol = neon_core_1.u.base642utf8(response.stack[1].value);
|
|
99
|
+
const token = {
|
|
100
|
+
name: contractState.manifest.name,
|
|
101
|
+
symbol,
|
|
102
|
+
hash: contractState.hash,
|
|
103
|
+
decimals,
|
|
104
|
+
};
|
|
105
|
+
this.tokenCache.set(tokenHash, token);
|
|
106
|
+
return token;
|
|
107
|
+
}
|
|
108
|
+
catch (_a) {
|
|
109
|
+
throw new Error(`Token not found: ${tokenHash}`);
|
|
110
|
+
}
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
getBalance(address) {
|
|
114
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
115
|
+
const rpcClient = new neon_core_1.rpc.RPCClient(this.network.url);
|
|
116
|
+
const response = yield rpcClient.getNep17Balances(address);
|
|
117
|
+
const promises = response.balance.map((balance) => __awaiter(this, void 0, void 0, function* () {
|
|
118
|
+
var _a;
|
|
119
|
+
let token = {
|
|
120
|
+
hash: balance.assethash,
|
|
121
|
+
name: '-',
|
|
122
|
+
symbol: '-',
|
|
123
|
+
decimals: 8,
|
|
124
|
+
};
|
|
125
|
+
try {
|
|
126
|
+
token = yield this.getTokenInfo(balance.assethash);
|
|
127
|
+
}
|
|
128
|
+
catch (_b) { }
|
|
129
|
+
return {
|
|
130
|
+
amount: neon_core_1.u.BigInteger.fromNumber(balance.amount).toDecimal((_a = token === null || token === void 0 ? void 0 : token.decimals) !== null && _a !== void 0 ? _a : 8),
|
|
131
|
+
token,
|
|
132
|
+
};
|
|
133
|
+
}));
|
|
134
|
+
const balances = yield Promise.all(promises);
|
|
135
|
+
return balances;
|
|
136
|
+
});
|
|
137
|
+
}
|
|
138
|
+
getBlockHeight() {
|
|
139
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
140
|
+
const rpcClient = new neon_core_1.rpc.RPCClient(this.network.url);
|
|
141
|
+
return yield rpcClient.getBlockCount();
|
|
142
|
+
});
|
|
143
|
+
}
|
|
144
|
+
getUnclaimed(address) {
|
|
145
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
146
|
+
const rpcClient = new neon_core_1.rpc.RPCClient(this.network.url);
|
|
147
|
+
const response = yield rpcClient.getUnclaimedGas(address);
|
|
148
|
+
return neon_core_1.u.BigInteger.fromNumber(response).toDecimal(this.claimToken.decimals);
|
|
149
|
+
});
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
exports.RPCBDSNeo3 = RPCBDSNeo3;
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
[
|
|
2
|
+
{
|
|
3
|
+
"symbol": "LRB",
|
|
4
|
+
"name": "LyrebirdToken",
|
|
5
|
+
"hash": "0x8c07b4c9f5bc170a3922eac4f5bb7ef17b0acc8b",
|
|
6
|
+
"decimals": 8
|
|
7
|
+
},
|
|
8
|
+
{
|
|
9
|
+
"symbol": "USDL",
|
|
10
|
+
"name": "LyrebirdUSDToken",
|
|
11
|
+
"hash": "0xa8c51aa0c177187aeed3db88bdfa908ccbc9b1a5",
|
|
12
|
+
"decimals": 8
|
|
13
|
+
},
|
|
14
|
+
{
|
|
15
|
+
"symbol": "FLM",
|
|
16
|
+
"name": "FLM",
|
|
17
|
+
"hash": "0xf0151f528127558851b39c2cd8aa47da7418ab28",
|
|
18
|
+
"decimals": 8
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
"symbol": "fCAKE",
|
|
22
|
+
"name": "fCAKE",
|
|
23
|
+
"hash": "0xe65b462b90516012826f8a9c4c285d8c750e3a77",
|
|
24
|
+
"decimals": 18
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
"symbol": "WING",
|
|
28
|
+
"name": "WING",
|
|
29
|
+
"hash": "0xeeccd60ed722111f8400434dac3ba42c14d8beb1",
|
|
30
|
+
"decimals": 9
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
"symbol": "fWETH",
|
|
34
|
+
"name": "fWETH",
|
|
35
|
+
"hash": "0xc14b601252aa5dfa6166cf35fe5ccd2e35f3fdf5",
|
|
36
|
+
"decimals": 18
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
"symbol": "fWBTC",
|
|
40
|
+
"name": "fWBTC",
|
|
41
|
+
"hash": "0xd6abe115ecb75e1fa0b42f5e85934ce8c1ae2893",
|
|
42
|
+
"decimals": 8
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
"symbol": "SWTH",
|
|
46
|
+
"name": "SWTHToken",
|
|
47
|
+
"hash": "0x78e1330db47634afdb5ea455302ba2d12b8d549f",
|
|
48
|
+
"decimals": 8
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
"symbol": "pONT",
|
|
52
|
+
"name": "pONT",
|
|
53
|
+
"hash": "0x8122bc2212ec971690a044b37a6f52a9349b702b",
|
|
54
|
+
"decimals": 9
|
|
55
|
+
},
|
|
56
|
+
{
|
|
57
|
+
"symbol": "fUSDT",
|
|
58
|
+
"name": "fUSDT",
|
|
59
|
+
"hash": "0xcd48b160c1bbc9d74997b803b9a7ad50a4bef020",
|
|
60
|
+
"decimals": 6
|
|
61
|
+
},
|
|
62
|
+
{
|
|
63
|
+
"symbol": "FLUND",
|
|
64
|
+
"name": "FLUND",
|
|
65
|
+
"hash": "0xa9603a59e21d29e37ac39cf1b5f5abf5006b22a3",
|
|
66
|
+
"decimals": 8
|
|
67
|
+
},
|
|
68
|
+
{
|
|
69
|
+
"symbol": "GM",
|
|
70
|
+
"name": "GhostMarketToken",
|
|
71
|
+
"hash": "0x9b049f1283515eef1d3f6ac610e1595ed25ca3e9",
|
|
72
|
+
"decimals": 8
|
|
73
|
+
},
|
|
74
|
+
{
|
|
75
|
+
"symbol": "NUDES",
|
|
76
|
+
"name": "Nudes",
|
|
77
|
+
"hash": "0x340720c7107ef5721e44ed2ea8e314cce5c130fa",
|
|
78
|
+
"decimals": 8
|
|
79
|
+
},
|
|
80
|
+
{
|
|
81
|
+
"symbol": "CANDY",
|
|
82
|
+
"name": "NeoCandy",
|
|
83
|
+
"hash": "0x88da18a5bca86ec8206d9b4960a7d0c4355a432f",
|
|
84
|
+
"decimals": 9
|
|
85
|
+
},
|
|
86
|
+
{
|
|
87
|
+
"symbol": "DOGER",
|
|
88
|
+
"name": "DogeRift",
|
|
89
|
+
"hash": "0x322b5a366ca724801a1aa01e669b5f3d7f8c7f6f",
|
|
90
|
+
"decimals": 8
|
|
91
|
+
},
|
|
92
|
+
{
|
|
93
|
+
"symbol": "DOGEF",
|
|
94
|
+
"name": "DogeFood",
|
|
95
|
+
"hash": "0xa3291b66f70d4687fc0e41977d8acb0699f235ae",
|
|
96
|
+
"decimals": 8
|
|
97
|
+
},
|
|
98
|
+
{
|
|
99
|
+
"symbol": "SOM",
|
|
100
|
+
"name": "Som",
|
|
101
|
+
"hash": "0x2d4c6cf0417209a7eb410160344e224e74f87195",
|
|
102
|
+
"decimals": 8
|
|
103
|
+
},
|
|
104
|
+
{
|
|
105
|
+
"symbol": "LAMBO",
|
|
106
|
+
"name": "BoomerFund",
|
|
107
|
+
"hash": "0xafdd6abedf066ff8c5fbc868cc89f80eac467142",
|
|
108
|
+
"decimals": 8
|
|
109
|
+
},
|
|
110
|
+
{
|
|
111
|
+
"symbol": "bNEO",
|
|
112
|
+
"hash": "0x48c40d4666f93408be1bef038b6722404d9a4c2a",
|
|
113
|
+
"decimals": 8,
|
|
114
|
+
"name": "BurgerNEO"
|
|
115
|
+
}
|
|
116
|
+
]
|
package/dist/constants.d.ts
CHANGED
|
@@ -1,3 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export declare const
|
|
3
|
-
export declare const
|
|
1
|
+
import { NetworkType, Token } from '@cityofzion/blockchain-service';
|
|
2
|
+
export declare const TOKENS: Record<NetworkType, Token[]>;
|
|
3
|
+
export declare const NEO_NS_HASH = "0x50ac1c37690cc2cfc594472833cf57505d5f46de";
|
|
4
|
+
export declare const DEFAULT_URL_BY_NETWORK_TYPE: Record<NetworkType, string>;
|
|
5
|
+
export declare const GHOSTMARKET_URL_BY_NETWORK_TYPE: Partial<Record<NetworkType, string>>;
|
|
6
|
+
export declare const GHOSTMARKET_CHAIN_BY_NETWORK_TYPE: Partial<Record<NetworkType, string>>;
|
|
7
|
+
export declare const DERIVATION_PATH = "m/44'/888'/0'/0/?";
|
package/dist/constants.js
CHANGED
|
@@ -1,13 +1,28 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
2
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
6
|
+
exports.DERIVATION_PATH = exports.GHOSTMARKET_CHAIN_BY_NETWORK_TYPE = exports.GHOSTMARKET_URL_BY_NETWORK_TYPE = exports.DEFAULT_URL_BY_NETWORK_TYPE = exports.NEO_NS_HASH = exports.TOKENS = void 0;
|
|
7
|
+
const common_json_1 = __importDefault(require("./assets/tokens/common.json"));
|
|
8
|
+
const mainnet_json_1 = __importDefault(require("./assets/tokens/mainnet.json"));
|
|
9
|
+
exports.TOKENS = {
|
|
10
|
+
mainnet: [...common_json_1.default, ...mainnet_json_1.default],
|
|
11
|
+
testnet: common_json_1.default,
|
|
12
|
+
custom: common_json_1.default,
|
|
13
|
+
};
|
|
14
|
+
exports.NEO_NS_HASH = '0x50ac1c37690cc2cfc594472833cf57505d5f46de';
|
|
15
|
+
exports.DEFAULT_URL_BY_NETWORK_TYPE = {
|
|
16
|
+
mainnet: 'https://mainnet1.neo.coz.io:443',
|
|
17
|
+
testnet: 'https://testnet1.neo.coz.io:443',
|
|
18
|
+
custom: 'http://127.0.0.1:50012',
|
|
19
|
+
};
|
|
20
|
+
exports.GHOSTMARKET_URL_BY_NETWORK_TYPE = {
|
|
21
|
+
mainnet: 'https://api.ghostmarket.io/api/v2',
|
|
22
|
+
testnet: 'https://api-testnet.ghostmarket.io/api/v2',
|
|
8
23
|
};
|
|
9
|
-
exports.
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
decimals: 0
|
|
24
|
+
exports.GHOSTMARKET_CHAIN_BY_NETWORK_TYPE = {
|
|
25
|
+
mainnet: 'n3',
|
|
26
|
+
testnet: 'n3t',
|
|
13
27
|
};
|
|
28
|
+
exports.DERIVATION_PATH = "m/44'/888'/0'/0/?";
|
package/dist/index.d.ts
CHANGED