@stacks/network 3.0.0 → 3.2.1-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/esm/index.d.ts +13 -31
- package/dist/esm/index.js +29 -5
- package/dist/esm/index.js.map +1 -1
- package/dist/index.d.ts +13 -31
- package/dist/index.js +31 -6
- package/dist/index.js.map +1 -1
- package/dist/polyfill/index.js +1 -0
- package/dist/umd/index.js +7504 -0
- package/dist/umd/index.js.map +1 -0
- package/package.json +13 -8
- package/src/index.ts +39 -45
- package/CHANGELOG.md +0 -52
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stacks/network",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.2.1-beta.0",
|
|
4
4
|
"description": "Library for Stacks network operations",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"stacks",
|
|
@@ -23,14 +23,16 @@
|
|
|
23
23
|
},
|
|
24
24
|
"scripts": {
|
|
25
25
|
"start": "tsc -b tsconfig.build.json --watch --verbose",
|
|
26
|
-
"build": "npm run clean && npm run build:cjs && npm run build:esm",
|
|
26
|
+
"build": "npm run clean && npm run build:cjs && npm run build:esm && npm run build:umd && npm run build:polyfill",
|
|
27
27
|
"build:cjs": "tsc -b tsconfig.build.json",
|
|
28
28
|
"build:esm": "tsc -p tsconfig.build.json --module ES6 --outDir ./dist/esm",
|
|
29
29
|
"build:umd": "webpack --config webpack.config.js",
|
|
30
|
+
"build:polyfill": "NODE_OPTIONS=--max-old-space-size=8192 rollup -c ../../configs/rollup.config.js && rimraf dist/polyfill/dist",
|
|
30
31
|
"clean": "rimraf dist && tsc -b tsconfig.build.json --clean",
|
|
31
32
|
"typecheck": "tsc --noEmit",
|
|
32
33
|
"typecheck:watch": "npm run typecheck -- --watch",
|
|
33
|
-
"
|
|
34
|
+
"pack": "npm pack",
|
|
35
|
+
"prepublishOnly": "npm run test && npm run build",
|
|
34
36
|
"test": "jest",
|
|
35
37
|
"test:watch": "jest --watch --coverage=false"
|
|
36
38
|
},
|
|
@@ -38,25 +40,28 @@
|
|
|
38
40
|
"url": "https://github.com/blockstack/blockstack.js/issues"
|
|
39
41
|
},
|
|
40
42
|
"dependencies": {
|
|
41
|
-
"@stacks/common": "^3.
|
|
43
|
+
"@stacks/common": "^3.2.1-beta.0"
|
|
42
44
|
},
|
|
43
45
|
"devDependencies": {
|
|
44
46
|
"@types/jest": "^26.0.22",
|
|
45
47
|
"jest": "^26.6.3",
|
|
46
48
|
"jest-fetch-mock": "^3.0.3",
|
|
47
49
|
"jest-module-name-mapper": "^0.1.5",
|
|
50
|
+
"process": "^0.11.10",
|
|
48
51
|
"rimraf": "^3.0.2",
|
|
49
52
|
"ts-jest": "^26.5.5",
|
|
50
53
|
"ts-loader": "^9.1.1",
|
|
51
54
|
"typescript": "^4.2.4",
|
|
52
55
|
"webpack": "^5.36.1",
|
|
56
|
+
"webpack-bundle-analyzer": "^4.5.0",
|
|
53
57
|
"webpack-cli": "^4.6.0"
|
|
54
58
|
},
|
|
55
59
|
"sideEffects": false,
|
|
60
|
+
"typings": "dist/index.d.ts",
|
|
56
61
|
"main": "dist/index.js",
|
|
57
62
|
"module": "dist/esm/index.js",
|
|
58
|
-
"
|
|
59
|
-
"umd:main": "dist/index.
|
|
60
|
-
"unpkg": "dist/index.
|
|
61
|
-
"gitHead": "
|
|
63
|
+
"browser": "dist/polyfill/index.js",
|
|
64
|
+
"umd:main": "dist/umd/index.js",
|
|
65
|
+
"unpkg": "dist/umd/index.js",
|
|
66
|
+
"gitHead": "bf5692b4b8eade0bc390b149bd6f7aafdda24f2d"
|
|
62
67
|
}
|
package/src/index.ts
CHANGED
|
@@ -8,48 +8,10 @@ export interface NetworkConfig {
|
|
|
8
8
|
url: string;
|
|
9
9
|
}
|
|
10
10
|
|
|
11
|
-
export
|
|
12
|
-
|
|
13
|
-
chainId: ChainID;
|
|
14
|
-
bnsLookupUrl: string;
|
|
15
|
-
readonly coreApiUrl: string;
|
|
16
|
-
broadcastEndpoint: string;
|
|
17
|
-
transferFeeEstimateEndpoint: string;
|
|
18
|
-
transactionFeeEstimateEndpoint: string;
|
|
19
|
-
accountEndpoint: string;
|
|
20
|
-
contractAbiEndpoint: string;
|
|
21
|
-
readOnlyFunctionCallEndpoint: string;
|
|
22
|
-
isMainnet(): boolean;
|
|
23
|
-
getBroadcastApiUrl: () => string;
|
|
24
|
-
getTransferFeeEstimateApiUrl: () => string;
|
|
25
|
-
getTransactionFeeEstimateApiUrl: () => string;
|
|
26
|
-
getAccountApiUrl: (address: string) => string;
|
|
27
|
-
getAbiApiUrl: (address: string, contract: string) => string;
|
|
28
|
-
getReadOnlyFunctionCallApiUrl: (
|
|
29
|
-
contractAddress: string,
|
|
30
|
-
contractName: string,
|
|
31
|
-
functionName: string
|
|
32
|
-
) => string;
|
|
33
|
-
getInfoUrl: () => string;
|
|
34
|
-
getBlockTimeInfoUrl: () => string;
|
|
35
|
-
getPoxInfoUrl: () => string;
|
|
36
|
-
getRewardsUrl: (address: string, options?: any) => string;
|
|
37
|
-
getRewardHoldersUrl: (address: string, options?: any) => string;
|
|
38
|
-
getRewardsTotalUrl: (address: string) => string;
|
|
39
|
-
getStackerInfoUrl: (contractAddress: string, contractName: string) => string;
|
|
40
|
-
|
|
41
|
-
/**
|
|
42
|
-
* Get WHOIS-like information for a name, including the address that owns it,
|
|
43
|
-
* the block at which it expires, and the zone file anchored to it (if available).
|
|
44
|
-
*
|
|
45
|
-
* This is intended for use in third-party wallets or in DApps that register names.
|
|
46
|
-
* @param fullyQualifiedName the name to query. Can be on-chain of off-chain.
|
|
47
|
-
* @return a promise that resolves to the WHOIS-like information
|
|
48
|
-
*/
|
|
49
|
-
getNameInfo: (fullyQualifiedName: string) => any;
|
|
50
|
-
}
|
|
11
|
+
export const StacksNetworks = ['mainnet', 'testnet'] as const;
|
|
12
|
+
export type StacksNetworkName = typeof StacksNetworks[number];
|
|
51
13
|
|
|
52
|
-
export class
|
|
14
|
+
export class StacksNetwork {
|
|
53
15
|
version = TransactionVersion.Mainnet;
|
|
54
16
|
chainId = ChainID.Mainnet;
|
|
55
17
|
bnsLookupUrl = 'https://stacks-node-api.mainnet.stacks.co';
|
|
@@ -62,10 +24,33 @@ export class StacksMainnet implements StacksNetwork {
|
|
|
62
24
|
|
|
63
25
|
readonly coreApiUrl: string;
|
|
64
26
|
|
|
65
|
-
constructor(
|
|
66
|
-
this.coreApiUrl =
|
|
27
|
+
constructor(networkConfig: NetworkConfig) {
|
|
28
|
+
this.coreApiUrl = networkConfig.url;
|
|
67
29
|
}
|
|
68
30
|
|
|
31
|
+
static fromName = (networkName: StacksNetworkName): StacksNetwork => {
|
|
32
|
+
switch (networkName) {
|
|
33
|
+
case 'mainnet':
|
|
34
|
+
return new StacksMainnet();
|
|
35
|
+
case 'testnet':
|
|
36
|
+
return new StacksTestnet();
|
|
37
|
+
default:
|
|
38
|
+
throw new Error(
|
|
39
|
+
`Invalid network name provided. Must be one of the following: ${StacksNetworks.join(
|
|
40
|
+
', '
|
|
41
|
+
)}`
|
|
42
|
+
);
|
|
43
|
+
}
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
static fromNameOrNetwork = (network: StacksNetworkName | StacksNetwork) => {
|
|
47
|
+
if (typeof network !== 'string' && 'version' in network) {
|
|
48
|
+
return network;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
return StacksNetwork.fromName(network);
|
|
52
|
+
};
|
|
53
|
+
|
|
69
54
|
isMainnet = () => this.version === TransactionVersion.Mainnet;
|
|
70
55
|
getBroadcastApiUrl = () => `${this.coreApiUrl}${this.broadcastEndpoint}`;
|
|
71
56
|
getTransferFeeEstimateApiUrl = () => `${this.coreApiUrl}${this.transferFeeEstimateEndpoint}`;
|
|
@@ -133,7 +118,16 @@ export class StacksMainnet implements StacksNetwork {
|
|
|
133
118
|
}
|
|
134
119
|
}
|
|
135
120
|
|
|
136
|
-
export class
|
|
121
|
+
export class StacksMainnet extends StacksNetwork {
|
|
122
|
+
version = TransactionVersion.Mainnet;
|
|
123
|
+
chainId = ChainID.Mainnet;
|
|
124
|
+
|
|
125
|
+
constructor(networkUrl: NetworkConfig = { url: HIRO_MAINNET_DEFAULT }) {
|
|
126
|
+
super(networkUrl);
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
export class StacksTestnet extends StacksNetwork {
|
|
137
131
|
version = TransactionVersion.Testnet;
|
|
138
132
|
chainId = ChainID.Testnet;
|
|
139
133
|
|
|
@@ -142,7 +136,7 @@ export class StacksTestnet extends StacksMainnet implements StacksNetwork {
|
|
|
142
136
|
}
|
|
143
137
|
}
|
|
144
138
|
|
|
145
|
-
export class StacksMocknet extends
|
|
139
|
+
export class StacksMocknet extends StacksNetwork {
|
|
146
140
|
version = TransactionVersion.Testnet;
|
|
147
141
|
chainId = ChainID.Testnet;
|
|
148
142
|
|
package/CHANGELOG.md
DELETED
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
# Change Log
|
|
2
|
-
|
|
3
|
-
All notable changes to this project will be documented in this file.
|
|
4
|
-
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
|
-
|
|
6
|
-
## [2.0.1](https://github.com/blockstack/blockstack.js/compare/v2.0.1-beta.2...v2.0.1) (2021-08-09)
|
|
7
|
-
|
|
8
|
-
**Note:** Version bump only for package @stacks/network
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
## [2.0.1-beta.2](https://github.com/blockstack/blockstack.js/compare/v2.0.1-beta.1...v2.0.1-beta.2) (2021-08-06)
|
|
15
|
-
|
|
16
|
-
**Note:** Version bump only for package @stacks/network
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
## [2.0.1-beta.1](https://github.com/blockstack/blockstack.js/compare/v2.0.0-beta.1...v2.0.1-beta.1) (2021-07-26)
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
### Bug Fixes
|
|
26
|
-
|
|
27
|
-
* BREAKING CHANGE: make coreApiUrl readonly for stacks network and initialize in constructor ([5d8cf6d](https://github.com/blockstack/blockstack.js/commit/5d8cf6d366665dace2df8102049d3f7ac1bf437e))
|
|
28
|
-
* broken types following diverged network config changes ([1cd9612](https://github.com/blockstack/blockstack.js/commit/1cd96128334465c461665cf079532f66b893b938))
|
|
29
|
-
* removeread only and add private field to prevent run time assignment ([62709aa](https://github.com/blockstack/blockstack.js/commit/62709aa5b6483299718063482bc26d6e94cc8c1c))
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
### Features
|
|
33
|
-
|
|
34
|
-
* add regtest to list of available networks ([f572477](https://github.com/blockstack/blockstack.js/commit/f572477ca0e5bc5e862c8a4e2fcc276655ee55a3)), closes [#1041](https://github.com/blockstack/blockstack.js/issues/1041)
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
# [2.0.0-beta.2](https://github.com/blockstack/blockstack.js/compare/v2.0.0-beta.1...v2.0.0-beta.2) (2021-07-26)
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
### Bug Fixes
|
|
44
|
-
|
|
45
|
-
* BREAKING CHANGE: make coreApiUrl readonly for stacks network and initialize in constructor ([5d8cf6d](https://github.com/blockstack/blockstack.js/commit/5d8cf6d366665dace2df8102049d3f7ac1bf437e))
|
|
46
|
-
* broken types following diverged network config changes ([1cd9612](https://github.com/blockstack/blockstack.js/commit/1cd96128334465c461665cf079532f66b893b938))
|
|
47
|
-
* removeread only and add private field to prevent run time assignment ([62709aa](https://github.com/blockstack/blockstack.js/commit/62709aa5b6483299718063482bc26d6e94cc8c1c))
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
### Features
|
|
51
|
-
|
|
52
|
-
* add regtest to list of available networks ([f572477](https://github.com/blockstack/blockstack.js/commit/f572477ca0e5bc5e862c8a4e2fcc276655ee55a3)), closes [#1041](https://github.com/blockstack/blockstack.js/issues/1041)
|