openchain-nodejs-ts-yxl 1.0.2 → 1.0.3

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/index.d.ts CHANGED
@@ -1,16 +1,36 @@
1
+ /**
2
+ * OpenChain SDK配置参数接口
3
+ */
4
+ export interface OpenChainSDKConfig {
5
+ /** 区块链节点API地址 */
6
+ host: string;
7
+ /** 链ID */
8
+ chainID?: number;
9
+ /** 请求超时时间(ms) */
10
+ timeout?: number;
11
+ /** 是否使用HTTPS */
12
+ secure?: boolean;
13
+ }
14
+
1
15
  /**
2
16
  * OpenChain区块链SDK核心类
3
17
  * @class
4
18
  * @example
5
19
  * const sdk = new OpenChainSDK({host: 'http://api.openchain.org'});
6
20
  */
7
- export class OpenChainSDK {
21
+ declare class OpenChainSDK {
8
22
  /**
9
23
  * 初始化SDK实例
10
- * @param {Object} config 配置参数
11
- * @param {string} config.host 区块链节点API地址
24
+ * @param {OpenChainSDKConfig} config 配置参数
25
+ * @example
26
+ * const sdk = new OpenChainSDK({
27
+ * host: 'http://api.openchain.org',
28
+ * chainID: 0,
29
+ * timeout: 3000,
30
+ * secure: false
31
+ * });
12
32
  */
13
- constructor(config: { host: string, chainID?: number, timeout?: number, secure?: boolean});
33
+ constructor(config: OpenChainSDKConfig);
14
34
 
15
35
  account: {
16
36
  /**
@@ -511,4 +531,5 @@ export interface TransactionResult {
511
531
  };
512
532
  txSize: number;
513
533
  }>;
514
- }
534
+ }
535
+ export default OpenChainSDK;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "openchain-nodejs-ts-yxl",
3
- "version": "1.0.2",
3
+ "version": "1.0.3",
4
4
  "description": "openchain sdk",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",
@@ -13,7 +13,7 @@ describe('Test token.ctp10Token', function() {
13
13
  let address = 'YxLSTjYcKBcCJ3tDnBM6z8u8uvFNaZ7L8pse';
14
14
  let data = await sdk.token.ctp10Token.checkValid(address);
15
15
  data.result.isValid.should.equal(true);
16
- address = 'adxSk4rkz84a4fh5xYxfSqmAsnhcWZzrTfG2t';
16
+ address = 'YxLW1Vb5sz2DnaNtY3RdVV5XcvVQJKobiFEPz';
17
17
  data = await sdk.token.ctp10Token.checkValid(address);
18
18
  data.errorCode.should.equal(11037)
19
19
  });
@@ -12,7 +12,7 @@ describe('Test bu send operation', function() {
12
12
 
13
13
  it('test operation.buSendOperation()', function() {
14
14
  let data = sdk.operation.buSendOperation({
15
- sourceAddress: 'adxSk4rkz84a4fh5xYxfSqmAsnhcWZzrTfG2t',
15
+ sourceAddress: 'YxLW1Vb5sz2DnaNtY3RdVV5XcvVQJKobiFEPz',
16
16
  destAddress: 'adxSqKcX8wGCMKhzNUBoDWfbeQaMhfnGdtyG2',
17
17
  buAmount: '6000',
18
18
  metadata: 'oh my send bu',
@@ -26,7 +26,7 @@ describe('Test bu send operation', function() {
26
26
 
27
27
  // Invalid sourceAddress
28
28
  data = sdk.operation.buSendOperation({
29
- sourceAddress: 'adxSk4rkz84a4fh5xYxfSqmAsnhcWZzrTfG2tA',
29
+ sourceAddress: 'YxLW1Vb5sz2DnaNtY3RdVV5XcvVQJKobiFEPzA',
30
30
  destAddress: 'adxSqKcX8wGCMKhzNUBoDWfbeQaMhfnGdtyG2',
31
31
  buAmount: '6000',
32
32
  metadata: 'oh my send bu',
@@ -34,7 +34,7 @@ describe('Test bu send operation', function() {
34
34
  data.errorCode.should.equal(11002);
35
35
 
36
36
  data = sdk.operation.buSendOperation({
37
- sourceAddress: 'adxSk4rkz84a4fh5xYxfSqmAsnhcWZzrTfG2t',
37
+ sourceAddress: 'YxLW1Vb5sz2DnaNtY3RdVV5XcvVQJKobiFEPz',
38
38
  destAddress: 'adxSqKcX8wGCMKhzNUBoDWfbeQaMhfnGdtyG2A',
39
39
  buAmount: '6000',
40
40
  metadata: 'oh my send bu',
@@ -43,7 +43,7 @@ describe('Test bu send operation', function() {
43
43
 
44
44
  // Invalid buAmount
45
45
  data = sdk.operation.buSendOperation({
46
- sourceAddress: 'adxSk4rkz84a4fh5xYxfSqmAsnhcWZzrTfG2t',
46
+ sourceAddress: 'YxLW1Vb5sz2DnaNtY3RdVV5XcvVQJKobiFEPz',
47
47
  destAddress: 'adxSqKcX8wGCMKhzNUBoDWfbeQaMhfnGdtyG2',
48
48
  buAmount: '6000A',
49
49
  metadata: 'oh my send bu',
@@ -52,7 +52,7 @@ describe('Test bu send operation', function() {
52
52
 
53
53
  // Invalid metadata
54
54
  data = sdk.operation.buSendOperation({
55
- sourceAddress: 'adxSk4rkz84a4fh5xYxfSqmAsnhcWZzrTfG2t',
55
+ sourceAddress: 'YxLW1Vb5sz2DnaNtY3RdVV5XcvVQJKobiFEPz',
56
56
  destAddress: 'adxSqKcX8wGCMKhzNUBoDWfbeQaMhfnGdtyG2',
57
57
  buAmount: '6000',
58
58
  metadata: '',
@@ -12,7 +12,7 @@ describe('Test contract create operation', function() {
12
12
  it('test operation.contractCreateOperation()', function() {
13
13
 
14
14
  let contractCreateOperation = sdk.operation.contractCreateOperation({
15
- sourceAddress: 'adxSk4rkz84a4fh5xYxfSqmAsnhcWZzrTfG2t',
15
+ sourceAddress: 'YxLW1Vb5sz2DnaNtY3RdVV5XcvVQJKobiFEPz',
16
16
  initBalance: '1000',
17
17
  type: 0,
18
18
  payload: 'afasfsaff',
@@ -28,7 +28,7 @@ describe('Test contract create operation', function() {
28
28
  const operationItem = contractCreateOperation.result.operation;
29
29
 
30
30
  const blobInfo = sdk.transaction.buildBlob({
31
- sourceAddress: 'adxSk4rkz84a4fh5xYxfSqmAsnhcWZzrTfG2t',
31
+ sourceAddress: 'YxLW1Vb5sz2DnaNtY3RdVV5XcvVQJKobiFEPz',
32
32
  gasPrice: '1000',
33
33
  feeLimit: '1000000',
34
34
  nonce: '123',
@@ -35,7 +35,7 @@ describe('Test contract invoke by asset operation transaction', function() {
35
35
  assetAmount: '1000',
36
36
  input: 'aaaa',
37
37
  code: 'leo',
38
- issuer: 'adxSk4rkz84a4fh5xYxfSqmAsnhcWZzrTfG2t',
38
+ issuer: 'YxLW1Vb5sz2DnaNtY3RdVV5XcvVQJKobiFEPz',
39
39
  // metadata: 'Test contract create operation',
40
40
  });
41
41
 
@@ -16,7 +16,7 @@ describe('Test transaction', function() {
16
16
 
17
17
  it('evaluateFee', function() {
18
18
  const sourceAddress = 'adxSqKcX8wGCMKhzNUBoDWfbeQaMhfnGdtyG2';
19
- const destAddress = 'adxSk4rkz84a4fh5xYxfSqmAsnhcWZzrTfG2t';
19
+ const destAddress = 'YxLW1Vb5sz2DnaNtY3RdVV5XcvVQJKobiFEPz';
20
20
 
21
21
  sdk.account.getNonce(sourceAddress).then(info => {
22
22