@cityofzion/blockchain-service 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/dist/BSAggregator.d.ts +16 -0
- package/dist/BSAggregator.js +86 -0
- package/dist/exceptions.d.ts +9 -4
- package/dist/exceptions.js +18 -8
- package/dist/functions.d.ts +5 -3
- package/dist/functions.js +13 -5
- package/dist/index.d.ts +2 -4
- package/dist/index.js +1 -3
- package/dist/interfaces.d.ts +119 -108
- package/dist/interfaces.js +0 -9
- package/package.json +1 -5
- package/dist/excpetions.d.ts +0 -4
- package/dist/excpetions.js +0 -11
- package/dist/helpers/index.d.ts +0 -1
- package/dist/helpers/index.js +0 -17
- package/dist/helpers/keychain.d.ts +0 -3
- package/dist/helpers/keychain.js +0 -7
- package/dist/polyfills/asteroid-sdk.d.ts +0 -3
- package/dist/polyfills/asteroid-sdk.js +0 -77346
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { AccountWithDerivationPath, BlockchainService } from './interfaces';
|
|
2
|
+
export declare class BSAggregator<BSCustomName extends string = string, BSCustom extends BlockchainService<BSCustomName> = BlockchainService<BSCustomName>> {
|
|
3
|
+
readonly blockchainServicesByName: Record<BSCustomName, BSCustom>;
|
|
4
|
+
readonly blockchainServices: BlockchainService<BSCustomName>[];
|
|
5
|
+
constructor(blockchainServices: Record<BSCustomName, BSCustom>);
|
|
6
|
+
addBlockchain(name: BSCustomName, blockchain: BSCustom): void;
|
|
7
|
+
validateAddressAllBlockchains(address: string): boolean;
|
|
8
|
+
validateTextAllBlockchains(text: string): boolean;
|
|
9
|
+
validateKeyAllBlockchains(wif: string): boolean;
|
|
10
|
+
validateEncryptedAllBlockchains(keyOrJson: string): boolean;
|
|
11
|
+
getBlockchainByName(name: BSCustomName): BlockchainService<BSCustomName>;
|
|
12
|
+
getBlockchainByAddress(address: string): BlockchainService<BSCustomName> | undefined;
|
|
13
|
+
getBlockchainByKey(wif: string): BlockchainService<BSCustomName> | undefined;
|
|
14
|
+
getBlockchainByEncrypted(keyOrJson: string): BlockchainService<BSCustomName> | undefined;
|
|
15
|
+
generateAccountFromMnemonicAllBlockchains(mnemonic: string, skippedAddresses?: string[]): Promise<Map<BSCustomName, AccountWithDerivationPath[]>>;
|
|
16
|
+
}
|
|
@@ -0,0 +1,86 @@
|
|
|
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.BSAggregator = void 0;
|
|
13
|
+
const exceptions_1 = require("./exceptions");
|
|
14
|
+
class BSAggregator {
|
|
15
|
+
constructor(blockchainServices) {
|
|
16
|
+
this.blockchainServicesByName = blockchainServices;
|
|
17
|
+
this.blockchainServices = Object.values(blockchainServices);
|
|
18
|
+
}
|
|
19
|
+
addBlockchain(name, blockchain) {
|
|
20
|
+
if (this.blockchainServicesByName[name])
|
|
21
|
+
throw new exceptions_1.BlockchainAlreadyExistError(name);
|
|
22
|
+
this.blockchainServicesByName[name] = blockchain;
|
|
23
|
+
this.blockchainServices.push(blockchain);
|
|
24
|
+
}
|
|
25
|
+
validateAddressAllBlockchains(address) {
|
|
26
|
+
return this.blockchainServices.some(bs => bs.validateAddress(address));
|
|
27
|
+
}
|
|
28
|
+
validateTextAllBlockchains(text) {
|
|
29
|
+
return this.blockchainServices.some(bs => [bs.validateAddress(text), bs.validateEncrypted(text), bs.validateKey(text)].some(it => it === true));
|
|
30
|
+
}
|
|
31
|
+
validateKeyAllBlockchains(wif) {
|
|
32
|
+
return this.blockchainServices.some(bs => bs.validateKey(wif));
|
|
33
|
+
}
|
|
34
|
+
validateEncryptedAllBlockchains(keyOrJson) {
|
|
35
|
+
return this.blockchainServices.some(bs => bs.validateEncrypted(keyOrJson));
|
|
36
|
+
}
|
|
37
|
+
getBlockchainByName(name) {
|
|
38
|
+
const service = this.blockchainServicesByName[name];
|
|
39
|
+
if (!service)
|
|
40
|
+
throw new exceptions_1.BlockchainNotFoundError(name);
|
|
41
|
+
return this.blockchainServicesByName[name];
|
|
42
|
+
}
|
|
43
|
+
getBlockchainByAddress(address) {
|
|
44
|
+
return this.blockchainServices.find(bs => bs.validateAddress(address));
|
|
45
|
+
}
|
|
46
|
+
getBlockchainByKey(wif) {
|
|
47
|
+
return this.blockchainServices.find(bs => bs.validateKey(wif));
|
|
48
|
+
}
|
|
49
|
+
getBlockchainByEncrypted(keyOrJson) {
|
|
50
|
+
return this.blockchainServices.find(bs => bs.validateEncrypted(keyOrJson));
|
|
51
|
+
}
|
|
52
|
+
generateAccountFromMnemonicAllBlockchains(mnemonic, skippedAddresses) {
|
|
53
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
54
|
+
const mnemonicAccounts = new Map();
|
|
55
|
+
const promises = this.blockchainServices.map((service) => __awaiter(this, void 0, void 0, function* () {
|
|
56
|
+
let index = 0;
|
|
57
|
+
const accounts = [];
|
|
58
|
+
while (true) {
|
|
59
|
+
const generatedAccount = service.generateAccountFromMnemonic(mnemonic, index);
|
|
60
|
+
if (skippedAddresses && skippedAddresses.find(address => address === generatedAccount.address)) {
|
|
61
|
+
index++;
|
|
62
|
+
continue;
|
|
63
|
+
}
|
|
64
|
+
if (index !== 0) {
|
|
65
|
+
try {
|
|
66
|
+
const { totalCount } = yield service.blockchainDataService.getTransactionsByAddress({
|
|
67
|
+
address: generatedAccount.address,
|
|
68
|
+
});
|
|
69
|
+
if (!totalCount || totalCount <= 0)
|
|
70
|
+
break;
|
|
71
|
+
}
|
|
72
|
+
catch (_a) {
|
|
73
|
+
break;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
accounts.push(generatedAccount);
|
|
77
|
+
index++;
|
|
78
|
+
}
|
|
79
|
+
mnemonicAccounts.set(service.blockchainName, accounts);
|
|
80
|
+
}));
|
|
81
|
+
yield Promise.all(promises);
|
|
82
|
+
return mnemonicAccounts;
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
exports.BSAggregator = BSAggregator;
|
package/dist/exceptions.d.ts
CHANGED
|
@@ -1,4 +1,9 @@
|
|
|
1
|
-
export declare
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
export declare class BlockchainAlreadyExistError extends Error {
|
|
2
|
+
constructor(blockchainName: string);
|
|
3
|
+
}
|
|
4
|
+
export declare class InvalidBlockchainServiceError extends Error {
|
|
5
|
+
constructor(message?: string);
|
|
6
|
+
}
|
|
7
|
+
export declare class BlockchainNotFoundError extends Error {
|
|
8
|
+
constructor(blockchainName: string);
|
|
9
|
+
}
|
package/dist/exceptions.js
CHANGED
|
@@ -1,11 +1,21 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
},
|
|
8
|
-
blockchainAlreadyExist: (blockchainName) => {
|
|
9
|
-
throw new Error(`The blockchain ${blockchainName} already exist`);
|
|
3
|
+
exports.BlockchainNotFoundError = exports.InvalidBlockchainServiceError = exports.BlockchainAlreadyExistError = void 0;
|
|
4
|
+
class BlockchainAlreadyExistError extends Error {
|
|
5
|
+
constructor(blockchainName) {
|
|
6
|
+
super(`The blockchain ${blockchainName} already exist`);
|
|
10
7
|
}
|
|
11
|
-
}
|
|
8
|
+
}
|
|
9
|
+
exports.BlockchainAlreadyExistError = BlockchainAlreadyExistError;
|
|
10
|
+
class InvalidBlockchainServiceError extends Error {
|
|
11
|
+
constructor(message) {
|
|
12
|
+
super(`Invalid blockchainServices => ${message}`);
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
exports.InvalidBlockchainServiceError = InvalidBlockchainServiceError;
|
|
16
|
+
class BlockchainNotFoundError extends Error {
|
|
17
|
+
constructor(blockchainName) {
|
|
18
|
+
super(`The blockchain ${blockchainName} not found`);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
exports.BlockchainNotFoundError = BlockchainNotFoundError;
|
package/dist/functions.d.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
-
import { BlockchainService,
|
|
2
|
-
export declare function
|
|
3
|
-
export declare function isClaimable(service: BlockchainService): service is
|
|
1
|
+
import { BlockchainService, BSCalculableFee, BSClaimable, BSWithNameService, BSWithNft } from './interfaces';
|
|
2
|
+
export declare function hasNameService(service: BlockchainService): service is BlockchainService & BSWithNameService;
|
|
3
|
+
export declare function isClaimable(service: BlockchainService): service is BlockchainService & BSClaimable;
|
|
4
|
+
export declare function isCalculableFee(service: BlockchainService): service is BlockchainService & BSCalculableFee;
|
|
5
|
+
export declare function hasNft(service: BlockchainService): service is BlockchainService & BSWithNft;
|
package/dist/functions.js
CHANGED
|
@@ -1,11 +1,19 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.isClaimable = exports.
|
|
4
|
-
function
|
|
5
|
-
return
|
|
3
|
+
exports.hasNft = exports.isCalculableFee = exports.isClaimable = exports.hasNameService = void 0;
|
|
4
|
+
function hasNameService(service) {
|
|
5
|
+
return 'resolveNameServiceDomain' in service && 'validateNameServiceDomainFormat' in service;
|
|
6
6
|
}
|
|
7
|
-
exports.
|
|
7
|
+
exports.hasNameService = hasNameService;
|
|
8
8
|
function isClaimable(service) {
|
|
9
|
-
return
|
|
9
|
+
return 'claim' in service && 'claimToken' in service && 'getUnclaimed' in service.blockchainDataService;
|
|
10
10
|
}
|
|
11
11
|
exports.isClaimable = isClaimable;
|
|
12
|
+
function isCalculableFee(service) {
|
|
13
|
+
return 'calculateTransferFee' in service;
|
|
14
|
+
}
|
|
15
|
+
exports.isCalculableFee = isCalculableFee;
|
|
16
|
+
function hasNft(service) {
|
|
17
|
+
return 'nftDataService' in service;
|
|
18
|
+
}
|
|
19
|
+
exports.hasNft = hasNft;
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -15,7 +15,5 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
__exportStar(require("./interfaces"), exports);
|
|
18
|
-
__exportStar(require("./
|
|
19
|
-
__exportStar(require("./exchanges"), exports);
|
|
18
|
+
__exportStar(require("./BSAggregator"), exports);
|
|
20
19
|
__exportStar(require("./functions"), exports);
|
|
21
|
-
__exportStar(require("./helpers"), exports);
|
package/dist/interfaces.d.ts
CHANGED
|
@@ -1,111 +1,119 @@
|
|
|
1
|
-
export type
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
export type PartialBy<T, K extends keyof T> = Omit<T, K> & Partial<Pick<T, K>>;
|
|
2
|
+
export type Account = {
|
|
3
|
+
key: string;
|
|
4
|
+
type: 'wif' | 'privateKey';
|
|
5
|
+
address: string;
|
|
5
6
|
};
|
|
6
|
-
export type
|
|
7
|
-
|
|
8
|
-
tokenHash: string;
|
|
9
|
-
amount: number;
|
|
7
|
+
export type AccountWithDerivationPath = Account & {
|
|
8
|
+
derivationPath: string;
|
|
10
9
|
};
|
|
11
|
-
export
|
|
12
|
-
hash: string;
|
|
10
|
+
export interface Token {
|
|
13
11
|
symbol: string;
|
|
12
|
+
name: string;
|
|
13
|
+
hash: string;
|
|
14
14
|
decimals: number;
|
|
15
|
+
}
|
|
16
|
+
export type NetworkType = 'mainnet' | 'testnet' | 'custom';
|
|
17
|
+
export type Network = {
|
|
18
|
+
type: NetworkType;
|
|
19
|
+
url: string;
|
|
15
20
|
};
|
|
16
|
-
export type
|
|
17
|
-
|
|
18
|
-
|
|
21
|
+
export type IntentTransferParam = {
|
|
22
|
+
receiverAddress: string;
|
|
23
|
+
tokenHash: string;
|
|
24
|
+
amount: string;
|
|
25
|
+
tokenDecimals?: number;
|
|
19
26
|
};
|
|
20
|
-
export type
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
27
|
+
export type TransferParam = {
|
|
28
|
+
senderAccount: Account;
|
|
29
|
+
intent: IntentTransferParam;
|
|
30
|
+
tipIntent?: IntentTransferParam;
|
|
31
|
+
priorityFee?: string;
|
|
24
32
|
};
|
|
25
|
-
export type
|
|
26
|
-
|
|
33
|
+
export type TokenPricesResponse = {
|
|
34
|
+
price: number;
|
|
27
35
|
symbol: string;
|
|
28
|
-
hash: string;
|
|
29
36
|
};
|
|
30
|
-
export
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
tokenClaim: TokenInfo;
|
|
34
|
-
}
|
|
35
|
-
export declare enum NNSRecordTypes {
|
|
36
|
-
IPV4 = "1",
|
|
37
|
-
CANONICAL_NAME = "5",
|
|
38
|
-
TEXT = "16",
|
|
39
|
-
IPV6 = "28"
|
|
40
|
-
}
|
|
41
|
-
export interface NeoNameService {
|
|
42
|
-
getNNSRecord(domainName: string, type: NNSRecordTypes): Promise<string>;
|
|
43
|
-
getOwnerOfNNS(domainName: string): Promise<string>;
|
|
44
|
-
validateNNSFormat(domainName: string): boolean;
|
|
37
|
+
export type Currency = 'USD' | 'BRL' | 'EUR';
|
|
38
|
+
export interface ExchangeDataService {
|
|
39
|
+
getTokenPrices(currency: Currency): Promise<TokenPricesResponse[]>;
|
|
45
40
|
}
|
|
46
|
-
export type Token = {
|
|
47
|
-
name: string;
|
|
48
|
-
symbol: string;
|
|
49
|
-
hash: string;
|
|
50
|
-
decimals: number;
|
|
51
|
-
};
|
|
52
|
-
export type Account = {
|
|
53
|
-
wif: string;
|
|
54
|
-
address: string;
|
|
55
|
-
};
|
|
56
|
-
export type CalculateTransferFeeResponse = {
|
|
57
|
-
result: number;
|
|
58
|
-
details?: CalculateTransferFeeDetails;
|
|
59
|
-
};
|
|
60
41
|
export interface BlockchainService<BSCustomName extends string = string> {
|
|
61
|
-
readonly dataService: BlockchainDataService;
|
|
62
42
|
readonly blockchainName: BSCustomName;
|
|
63
|
-
readonly
|
|
64
|
-
readonly
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
43
|
+
readonly derivationPath: string;
|
|
44
|
+
readonly feeToken: Token;
|
|
45
|
+
exchangeDataService: ExchangeDataService;
|
|
46
|
+
blockchainDataService: BlockchainDataService;
|
|
47
|
+
tokens: Token[];
|
|
48
|
+
network: Network;
|
|
49
|
+
setNetwork: (network: PartialBy<Network, 'url'>) => void;
|
|
50
|
+
generateAccountFromMnemonic(mnemonic: string | string, index: number): AccountWithDerivationPath;
|
|
51
|
+
generateAccountFromKey(key: string): Account;
|
|
52
|
+
decrypt(keyOrJson: string, password: string): Promise<Account>;
|
|
71
53
|
validateAddress(address: string): boolean;
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
54
|
+
validateEncrypted(keyOrJson: string): boolean;
|
|
55
|
+
validateKey(key: string): boolean;
|
|
56
|
+
transfer(param: TransferParam): Promise<string>;
|
|
57
|
+
}
|
|
58
|
+
export interface BSCalculableFee {
|
|
59
|
+
calculateTransferFee(param: TransferParam, details?: boolean): Promise<string>;
|
|
60
|
+
}
|
|
61
|
+
export interface BSClaimable {
|
|
62
|
+
readonly claimToken: Token;
|
|
63
|
+
readonly burnToken: Token;
|
|
64
|
+
blockchainDataService: BlockchainDataService & BDSClaimable;
|
|
65
|
+
claim(account: Account): Promise<string>;
|
|
66
|
+
}
|
|
67
|
+
export interface BSWithNameService {
|
|
68
|
+
resolveNameServiceDomain(domainName: string): Promise<string>;
|
|
69
|
+
validateNameServiceDomainFormat(domainName: string): boolean;
|
|
70
|
+
}
|
|
71
|
+
export interface BSWithNft {
|
|
72
|
+
nftDataService: NftDataService;
|
|
75
73
|
}
|
|
76
74
|
export type TransactionNotifications = {
|
|
77
|
-
|
|
78
|
-
event_name: string;
|
|
75
|
+
eventName: string;
|
|
79
76
|
state: {
|
|
80
77
|
type: string;
|
|
81
78
|
value: string;
|
|
82
79
|
}[];
|
|
83
80
|
};
|
|
84
|
-
export type
|
|
85
|
-
txid: string;
|
|
86
|
-
block: number;
|
|
87
|
-
time: string;
|
|
88
|
-
transfers: Omit<TransactionTransfer, 'txid'>[];
|
|
89
|
-
sysfee: string;
|
|
90
|
-
netfee: string;
|
|
91
|
-
totfee: string;
|
|
92
|
-
notifications: TransactionNotifications[];
|
|
93
|
-
};
|
|
94
|
-
export type TransactionTransfer = {
|
|
81
|
+
export type TransactionTransferAsset = {
|
|
95
82
|
amount: string;
|
|
96
83
|
to: string;
|
|
97
84
|
from: string;
|
|
85
|
+
type: 'token';
|
|
86
|
+
contractHash: string;
|
|
87
|
+
token?: Token;
|
|
88
|
+
};
|
|
89
|
+
export type TransactionTransferNft = {
|
|
90
|
+
tokenId: string;
|
|
91
|
+
to: string;
|
|
92
|
+
from: string;
|
|
93
|
+
type: 'nft';
|
|
94
|
+
contractHash: string;
|
|
95
|
+
};
|
|
96
|
+
export type TransactionResponse = {
|
|
98
97
|
hash: string;
|
|
99
|
-
|
|
98
|
+
block: number;
|
|
99
|
+
time: number;
|
|
100
|
+
transfers: (TransactionTransferAsset | TransactionTransferNft)[];
|
|
101
|
+
fee?: string;
|
|
102
|
+
notifications: TransactionNotifications[];
|
|
100
103
|
};
|
|
101
104
|
export type ContractParameter = {
|
|
102
105
|
name: string;
|
|
103
106
|
type: string;
|
|
104
107
|
};
|
|
105
|
-
export type
|
|
108
|
+
export type TransactionsByAddressResponse = {
|
|
106
109
|
totalCount: number;
|
|
110
|
+
limit: number;
|
|
107
111
|
transactions: TransactionResponse[];
|
|
108
112
|
};
|
|
113
|
+
export type TransactionsByAddressParams = {
|
|
114
|
+
address: string;
|
|
115
|
+
page?: number;
|
|
116
|
+
};
|
|
109
117
|
export type ContractMethod = {
|
|
110
118
|
name: string;
|
|
111
119
|
parameters: ContractParameter[];
|
|
@@ -115,44 +123,47 @@ export type ContractResponse = {
|
|
|
115
123
|
name: string;
|
|
116
124
|
methods: ContractMethod[];
|
|
117
125
|
};
|
|
118
|
-
export type ConsensusNodeResponse = {
|
|
119
|
-
url: string;
|
|
120
|
-
height: number;
|
|
121
|
-
};
|
|
122
|
-
export type TokenInfoResponse = {
|
|
123
|
-
symbol: string;
|
|
124
|
-
decimals: number;
|
|
125
|
-
};
|
|
126
|
-
export type BlockchainNetwork = "mainnet" | "testnet" | "privatenet";
|
|
127
126
|
export type BalanceResponse = {
|
|
128
|
-
amount:
|
|
129
|
-
|
|
130
|
-
symbol: string;
|
|
131
|
-
name: string;
|
|
132
|
-
};
|
|
133
|
-
export type UnclaimedResponse = {
|
|
134
|
-
address: string;
|
|
135
|
-
unclaimed: number;
|
|
127
|
+
amount: string;
|
|
128
|
+
token: Token;
|
|
136
129
|
};
|
|
137
|
-
export interface BDSClaimable {
|
|
138
|
-
getUnclaimed(address: string): Promise<UnclaimedResponse>;
|
|
139
|
-
}
|
|
140
130
|
export interface BlockchainDataService {
|
|
141
|
-
readonly explorer: string;
|
|
142
|
-
network: BlockchainNetwork;
|
|
143
|
-
setNetwork(network: BlockchainNetwork): void;
|
|
144
131
|
getTransaction(txid: string): Promise<TransactionResponse>;
|
|
145
|
-
|
|
132
|
+
getTransactionsByAddress(params: TransactionsByAddressParams): Promise<TransactionsByAddressResponse>;
|
|
146
133
|
getContract(contractHash: string): Promise<ContractResponse>;
|
|
147
|
-
getTokenInfo(tokenHash: string): Promise<
|
|
134
|
+
getTokenInfo(tokenHash: string): Promise<Token>;
|
|
148
135
|
getBalance(address: string): Promise<BalanceResponse[]>;
|
|
149
|
-
|
|
150
|
-
getHigherNode(): Promise<ConsensusNodeResponse>;
|
|
136
|
+
getBlockHeight(): Promise<number>;
|
|
151
137
|
}
|
|
152
|
-
export
|
|
153
|
-
|
|
154
|
-
|
|
138
|
+
export interface BDSClaimable {
|
|
139
|
+
getUnclaimed(address: string): Promise<string>;
|
|
140
|
+
}
|
|
141
|
+
export interface NftResponse {
|
|
142
|
+
id: string;
|
|
143
|
+
contractHash: string;
|
|
144
|
+
collectionName?: string;
|
|
145
|
+
collectionImage?: string;
|
|
146
|
+
symbol: string;
|
|
147
|
+
image?: string;
|
|
148
|
+
name?: string;
|
|
149
|
+
isSVG?: boolean;
|
|
150
|
+
}
|
|
151
|
+
export interface NftsResponse {
|
|
152
|
+
items: NftResponse[];
|
|
153
|
+
nextCursor?: string;
|
|
154
|
+
total?: number;
|
|
155
|
+
}
|
|
156
|
+
export type GetNftsByAddressParams = {
|
|
157
|
+
address: string;
|
|
158
|
+
page?: number;
|
|
159
|
+
cursor?: string;
|
|
160
|
+
size?: number;
|
|
155
161
|
};
|
|
156
|
-
export
|
|
157
|
-
|
|
162
|
+
export type GetNftParam = {
|
|
163
|
+
tokenId: string;
|
|
164
|
+
contractHash: string;
|
|
165
|
+
};
|
|
166
|
+
export interface NftDataService {
|
|
167
|
+
getNftsByAddress(params: GetNftsByAddressParams): Promise<NftsResponse>;
|
|
168
|
+
getNft(params: GetNftParam): Promise<NftResponse>;
|
|
158
169
|
}
|
package/dist/interfaces.js
CHANGED
|
@@ -1,11 +1,2 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.NNSRecordTypes = void 0;
|
|
4
|
-
var NNSRecordTypes;
|
|
5
|
-
(function (NNSRecordTypes) {
|
|
6
|
-
NNSRecordTypes["IPV4"] = "1";
|
|
7
|
-
NNSRecordTypes["CANONICAL_NAME"] = "5";
|
|
8
|
-
NNSRecordTypes["TEXT"] = "16";
|
|
9
|
-
NNSRecordTypes["IPV6"] = "28";
|
|
10
|
-
})(NNSRecordTypes = exports.NNSRecordTypes || (exports.NNSRecordTypes = {}));
|
|
11
|
-
//*****************************************************************************
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cityofzion/blockchain-service",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.7.1",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"types": "dist/index.d.ts",
|
|
6
6
|
"repository": "https://github.com/CityOfZion/blockchain-services",
|
|
@@ -12,10 +12,6 @@
|
|
|
12
12
|
"scripts": {
|
|
13
13
|
"build": "tsc && typedoc"
|
|
14
14
|
},
|
|
15
|
-
"dependencies": {
|
|
16
|
-
"axios": "1.3.2",
|
|
17
|
-
"@moonlight-io/asteroid-sdk-js": "git+https://github.com/Moonlight-io/asteroid-sdk-js"
|
|
18
|
-
},
|
|
19
15
|
"devDependencies": {
|
|
20
16
|
"@types/node": "~20.2.5",
|
|
21
17
|
"ts-node": "10.9.1",
|
package/dist/excpetions.d.ts
DELETED
package/dist/excpetions.js
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.exception = void 0;
|
|
4
|
-
exports.exception = {
|
|
5
|
-
invalidBlockchainService: (message) => {
|
|
6
|
-
throw new Error(`Invalid blockchainServices => ${message}`);
|
|
7
|
-
},
|
|
8
|
-
blockchainAlreadyExist: (blockchainName) => {
|
|
9
|
-
throw new Error(`The blockchain ${blockchainName} already exist`);
|
|
10
|
-
}
|
|
11
|
-
};
|
package/dist/helpers/index.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from "./keychain";
|
package/dist/helpers/index.js
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./keychain"), exports);
|
package/dist/helpers/keychain.js
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.keychain = exports.SDK = void 0;
|
|
4
|
-
// @ts-ignore
|
|
5
|
-
const SDK = typeof window !== 'undefined' ? require('../polyfills/asteroid-sdk') : require('@moonlight-io/asteroid-sdk-js');
|
|
6
|
-
exports.SDK = SDK;
|
|
7
|
-
exports.keychain = new SDK.Keychain();
|