@cityofzion/dora-ts
Advanced tools
Comparing version 0.0.8 to 0.0.9
@@ -1,5 +0,6 @@ | ||
import type { AddressTransactionsResponse, AssetResponse, BalanceResponse, BlockResponse, BlocksResponse, ContractResponse, ContractsResponse, GetAddressAbstractsResponse, GetAllNodesResponse, HeightResponse, InvocationStatsResponse, LogResponse, TransactionResponse, TransactionsResponse, TransferHistoryResponse } from '../../interfaces/api/neo'; | ||
import type { AddressTransactionsResponse, AddressTXFullResponse, AssetResponse, BalanceResponse, BlockResponse, BlocksResponse, ContractResponse, ContractsResponse, GetAddressAbstractsResponse, GetAllNodesResponse, HeightResponse, InvocationStatsResponse, LogResponse, TransactionResponse, TransactionsResponse, TransferHistoryResponse, VoterResponse } from '../../interfaces/api/neo'; | ||
export declare class NeoRest { | ||
static axios: import("axios").AxiosInstance; | ||
static addressTransactions(address: string, page?: number, network?: string): Promise<AddressTransactionsResponse>; | ||
static addressTXFull(address: string, page?: number, network?: string): Promise<AddressTXFullResponse>; | ||
static asset(assetHash: string, network?: string): Promise<AssetResponse>; | ||
@@ -10,2 +11,3 @@ static assets(page?: number, network?: string): Promise<any>; | ||
static blocks(page?: number, network?: string): Promise<BlocksResponse>; | ||
static committee(network?: string): Promise<BalanceResponse>; | ||
static contract(contractHash: string, network?: string): Promise<ContractResponse>; | ||
@@ -22,3 +24,4 @@ static contracts(page: number, network?: string): Promise<ContractsResponse>; | ||
static transferHistory(address: string, page?: number, network?: string): Promise<TransferHistoryResponse>; | ||
static voter(address: string, network?: string): Promise<VoterResponse>; | ||
private static get; | ||
} |
@@ -59,2 +59,17 @@ "use strict"; | ||
}; | ||
NeoRest.addressTXFull = function (address, page, network) { | ||
if (page === void 0) { page = 1; } | ||
if (network === void 0) { network = 'mainnet'; } | ||
return __awaiter(this, void 0, void 0, function () { | ||
var method; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: | ||
method = 'address_txfull'; | ||
return [4, this.get(network, method, address, page)]; | ||
case 1: return [2, _a.sent()]; | ||
} | ||
}); | ||
}); | ||
}; | ||
NeoRest.asset = function (assetHash, network) { | ||
@@ -132,2 +147,16 @@ if (network === void 0) { network = 'mainnet'; } | ||
}; | ||
NeoRest.committee = function (network) { | ||
if (network === void 0) { network = 'mainnet'; } | ||
return __awaiter(this, void 0, void 0, function () { | ||
var method; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: | ||
method = 'committee'; | ||
return [4, this.get(network, method)]; | ||
case 1: return [2, _a.sent()]; | ||
} | ||
}); | ||
}); | ||
}; | ||
NeoRest.contract = function (contractHash, network) { | ||
@@ -290,2 +319,16 @@ if (network === void 0) { network = 'mainnet'; } | ||
}; | ||
NeoRest.voter = function (address, network) { | ||
if (network === void 0) { network = 'mainnet'; } | ||
return __awaiter(this, void 0, void 0, function () { | ||
var method; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: | ||
method = 'voter'; | ||
return [4, this.get(network, method, address)]; | ||
case 1: return [2, _a.sent()]; | ||
} | ||
}); | ||
}); | ||
}; | ||
NeoRest.get = function () { | ||
@@ -292,0 +335,0 @@ var args = []; |
@@ -7,2 +7,3 @@ import { AddressAbstractEntry, Asset, ContractInvocationStats, Balance, Block, NodeMetaData, TransferAbstract, TypedResponse, Witness } from '../common'; | ||
} | ||
export declare type AddressTXFullResponse = AddressTransactionsResponse; | ||
export declare type AssetResponse = Token; | ||
@@ -35,2 +36,16 @@ export interface AssetsResponse { | ||
} | ||
export interface Committee { | ||
scripthash: string; | ||
name: string; | ||
location: string; | ||
website: string; | ||
email: string; | ||
github: string; | ||
telegram: string; | ||
twitter: string; | ||
description: string; | ||
logo: string; | ||
votes: number; | ||
pubkey: string; | ||
} | ||
export interface ContractResponse { | ||
@@ -80,1 +95,7 @@ block: number; | ||
} | ||
export interface VoterResponse { | ||
vote: string; | ||
candidate: string; | ||
candidatePubbkey: string; | ||
balance: number; | ||
} |
@@ -270,3 +270,44 @@ "use strict"; | ||
}); }); | ||
it('should get the voter information of a user', function () { return __awaiter(void 0, void 0, void 0, function () { | ||
var res; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: return [4, neo_1.NeoRest.voter('NNtgxn9X4oRG1y7UfxDyjef8aFy6eRpApa')]; | ||
case 1: | ||
res = _a.sent(); | ||
chai_1.assert.isNotNull(res); | ||
chai_1.assert.isObject(res); | ||
return [2]; | ||
} | ||
}); | ||
}); }); | ||
it('should get Neo committee information', function () { return __awaiter(void 0, void 0, void 0, function () { | ||
var res; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: return [4, neo_1.NeoRest.committee()]; | ||
case 1: | ||
res = _a.sent(); | ||
chai_1.assert.isNotNull(res); | ||
chai_1.assert.isArray(res); | ||
return [2]; | ||
} | ||
}); | ||
}); }); | ||
it('should get the full transactions history for an address', function () { return __awaiter(void 0, void 0, void 0, function () { | ||
var res; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: return [4, neo_1.NeoRest.addressTXFull('NNtgxn9X4oRG1y7UfxDyjef8aFy6eRpApa', 1)]; | ||
case 1: | ||
res = _a.sent(); | ||
chai_1.assert.isNotNull(res); | ||
chai_1.assert.isObject(res); | ||
chai_1.assert.isArray(res.items); | ||
chai_1.assert.isAtLeast(res.items.length, 14); | ||
return [2]; | ||
} | ||
}); | ||
}); }); | ||
}); | ||
//# sourceMappingURL=neo.test.js.map |
{ | ||
"name": "@cityofzion/dora-ts", | ||
"version": "0.0.8", | ||
"version": "0.0.9", | ||
"description": "", | ||
@@ -19,3 +19,3 @@ "main": "dist/index", | ||
"test": "mocha 'src/**/*.test.ts'", | ||
"fmt": "prettier --write '**/**/*.ts'" | ||
"fmt": "prettier --write ./src/**/*.ts" | ||
}, | ||
@@ -22,0 +22,0 @@ "devDependencies": { |
import type { | ||
AddressTransactionsResponse, | ||
AddressTransactionsResponse, AddressTXFullResponse, | ||
AssetResponse, | ||
@@ -16,3 +16,4 @@ BalanceResponse, | ||
TransactionsResponse, | ||
TransferHistoryResponse | ||
TransferHistoryResponse, | ||
VoterResponse | ||
} from '../../interfaces/api/neo' | ||
@@ -33,2 +34,11 @@ import { AXIOS_DORA } from '../../constants' | ||
static async addressTXFull( | ||
address: string, | ||
page = 1, | ||
network = 'mainnet' | ||
): Promise<AddressTXFullResponse> { | ||
const method = 'address_txfull' | ||
return await this.get(network, method, address, page) | ||
} | ||
static async asset( | ||
@@ -71,2 +81,9 @@ assetHash: string, | ||
static async committee( | ||
network = 'mainnet' | ||
): Promise<BalanceResponse> { | ||
const method = 'committee' | ||
return await this.get(network, method) | ||
} | ||
static async contract( | ||
@@ -152,2 +169,10 @@ contractHash: string, | ||
static async voter( | ||
address: string, | ||
network = 'mainnet' | ||
): Promise<VoterResponse> { | ||
const method = 'voter' | ||
return await this.get(network, method, address) | ||
} | ||
private static async get(...args: any[]) { | ||
@@ -154,0 +179,0 @@ const endpoint = args.join('/') |
@@ -41,6 +41,7 @@ import { TypedResponse, Witness } from '../common' | ||
type: string | ||
metadata: InvocationDetailNEP17Transfer | | ||
InvocationDetailNEP11Transfer | | ||
InvocationDetailContractInvocation | | ||
InvocationDetailVote | ||
metadata: | ||
| InvocationDetailNEP17Transfer | ||
| InvocationDetailNEP11Transfer | ||
| InvocationDetailContractInvocation | ||
| InvocationDetailVote | ||
} | ||
@@ -173,2 +174,2 @@ | ||
invocations: InvocationDetails[] | ||
} | ||
} |
@@ -12,3 +12,10 @@ import { | ||
} from '../common' | ||
import {Contract, Manifest, NEF, Token, Transaction, TransactionEnhanced} from './interface' | ||
import { | ||
Contract, | ||
Manifest, | ||
NEF, | ||
Token, | ||
Transaction, | ||
TransactionEnhanced | ||
} from './interface' | ||
@@ -20,2 +27,4 @@ export interface AddressTransactionsResponse { | ||
export type AddressTXFullResponse = AddressTransactionsResponse | ||
export type AssetResponse = Token | ||
@@ -53,2 +62,17 @@ | ||
export interface Committee { | ||
scripthash: string | ||
name: string | ||
location: string | ||
website: string | ||
email: string | ||
github: string | ||
telegram: string | ||
twitter: string | ||
description: string | ||
logo: string | ||
votes: number | ||
pubkey: string | ||
} | ||
export interface ContractResponse { | ||
@@ -107,1 +131,8 @@ block: number | ||
} | ||
export interface VoterResponse { | ||
vote: string | ||
candidate: string | ||
candidatePubbkey: string | ||
balance: number | ||
} |
@@ -139,3 +139,6 @@ import { assert } from 'chai' | ||
it('should get the enhanced transactions for an address', async () => { | ||
const res = await NeoRest.addressTransactions('NNtgxn9X4oRG1y7UfxDyjef8aFy6eRpApa', 1) | ||
const res = await NeoRest.addressTransactions( | ||
'NNtgxn9X4oRG1y7UfxDyjef8aFy6eRpApa', | ||
1 | ||
) | ||
assert.isNotNull(res) | ||
@@ -158,2 +161,25 @@ assert.isObject(res) | ||
}) | ||
it('should get the voter information of a user', async () => { | ||
const res = await NeoRest.voter('NNtgxn9X4oRG1y7UfxDyjef8aFy6eRpApa') | ||
assert.isNotNull(res) | ||
assert.isObject(res) | ||
}) | ||
it('should get Neo committee information', async () => { | ||
const res = await NeoRest.committee() | ||
assert.isNotNull(res) | ||
assert.isArray(res) | ||
}) | ||
it('should get the full transactions history for an address', async () => { | ||
const res = await NeoRest.addressTXFull( | ||
'NNtgxn9X4oRG1y7UfxDyjef8aFy6eRpApa', | ||
1 | ||
) | ||
assert.isNotNull(res) | ||
assert.isObject(res) | ||
assert.isArray(res.items) | ||
assert.isAtLeast(res.items.length, 14) | ||
}) | ||
}) |
@@ -6,2 +6,3 @@ { | ||
"declaration": true, | ||
"baseUrl": ".", | ||
"sourceMap": true, | ||
@@ -8,0 +9,0 @@ "outDir": "dist", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
139261
3058