openchain-nodejs-ts-yxl 1.0.3 → 1.0.5
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 +974 -21
- package/package.json +1 -1
package/index.d.ts
CHANGED
@@ -39,88 +39,228 @@ declare class OpenChainSDK {
|
|
39
39
|
* @example
|
40
40
|
* sdk.account.create().then(console.log);
|
41
41
|
*
|
42
|
+
* // 返回示例:
|
43
|
+
* {
|
44
|
+
* errorCode: 0,
|
45
|
+
* result: {
|
46
|
+
* privateKey: 'priv4FXWYaYMpGMeYtEPyUWBCH5aGVGtGR5uvtXGKxgBU2',
|
47
|
+
* publicKey: 'b001d8236a15923c91eab5b36dc0ea7c5faad04ed9184246a5d18c4547b06c89e4b',
|
48
|
+
* address: 'adxSZHxE1YzrDRyQCJVpx7aStghSvyJTQAzF'
|
49
|
+
* }
|
50
|
+
* }
|
51
|
+
*
|
42
52
|
* // 错误码:
|
43
53
|
* // - SYSTEM_ERROR 20000 系统错误
|
54
|
+
* // - KEYPAIR_CREATE_ERROR 11031 密钥对创建失败
|
44
55
|
*/
|
45
56
|
create(): Promise<{ errorCode: number; result: { privateKey: string; publicKey: string; address: string } }>;
|
57
|
+
|
46
58
|
/**
|
47
59
|
* 查询账户信息
|
48
|
-
* @param {string} address
|
60
|
+
* @param {string} address 账户地址(需以'adx'开头的base58编码格式)
|
49
61
|
* @returns {Promise<{errorCode:number, result:AccountInfoResult}>}
|
50
62
|
* @example
|
51
|
-
* sdk.account.getInfo('
|
63
|
+
* sdk.account.getInfo('adxSZHxE1YzrDRyQCJVpx7aStghSvyJTQAzF').then(console.log);
|
64
|
+
*
|
65
|
+
* // 返回示例:
|
66
|
+
* {
|
67
|
+
* errorCode: 0,
|
68
|
+
* result: {
|
69
|
+
* address: 'adxSZHxE1YzrDRyQCJVpx7aStghSvyJTQAzF',
|
70
|
+
* balance: '1000000000',
|
71
|
+
* nonce: '1',
|
72
|
+
* type_thresholds: [{
|
73
|
+
* type: 1,
|
74
|
+
* threshold: '1'
|
75
|
+
* }]
|
76
|
+
* }
|
77
|
+
* }
|
52
78
|
*
|
53
79
|
* // 错误码:
|
54
|
-
* // -
|
80
|
+
* // - INVALID_ADDRESS_ERROR 11002 无效地址
|
81
|
+
* // - ACCOUNT_NOT_EXIST 11003 账户不存在
|
82
|
+
* // - ACCOUNT_NOT_ACTIVATED 11004 账户未激活
|
55
83
|
*/
|
56
84
|
getInfo(address: string): Promise<{ errorCode: number; result: AccountInfoResult }>;
|
85
|
+
|
57
86
|
/**
|
58
87
|
* 校验账户地址有效性
|
59
|
-
* @param {string} address
|
88
|
+
* @param {string} address 待校验的区块链地址(需以'adx'开头的base58编码格式)
|
60
89
|
* @returns {Promise<{errorCode:number, result:{isValid:boolean}}>}
|
61
90
|
* @example
|
62
|
-
* sdk.account.checkValid('
|
91
|
+
* sdk.account.checkValid('adxSZHxE1YzrDRyQCJVpx7aStghSvyJTQAzF').then(console.log);
|
92
|
+
*
|
93
|
+
* // 返回示例:
|
94
|
+
* {
|
95
|
+
* errorCode: 0,
|
96
|
+
* result: {
|
97
|
+
* isValid: true
|
98
|
+
* }
|
99
|
+
* }
|
63
100
|
*
|
64
101
|
* // 错误码:
|
65
102
|
* // - INVALID_ADDRESS_ERROR 11002 地址格式错误
|
103
|
+
* // - ADDRESS_LENGTH_ERROR 11003 地址长度错误
|
104
|
+
* // - ADDRESS_CHECKSUM_ERROR 11004 地址校验和错误
|
66
105
|
*/
|
67
106
|
checkValid(address: string): Promise<{ errorCode: number; result: { isValid: boolean } }>;
|
68
107
|
|
69
108
|
/**
|
70
109
|
* 查询账户余额
|
71
|
-
* @param {string} address
|
110
|
+
* @param {string} address 账户地址(需以'adx'开头的base58编码格式)
|
72
111
|
* @returns {Promise<{errorCode:number, result:{balance:string}}>} 余额单位MO(1 MO = 1e8 stroop)
|
73
112
|
* @example
|
74
|
-
* sdk.account.getBalance('
|
113
|
+
* sdk.account.getBalance('adxSZHxE1YzrDRyQCJVpx7aStghSvyJTQAzF').then(console.log);
|
114
|
+
*
|
115
|
+
* // 返回示例:
|
116
|
+
* {
|
117
|
+
* errorCode: 0,
|
118
|
+
* result: {
|
119
|
+
* balance: '1000000000' // 10 MO
|
120
|
+
* }
|
121
|
+
* }
|
75
122
|
*
|
76
123
|
* // 错误码:
|
77
124
|
* // - INVALID_ADDRESS_ERROR 11002 无效地址
|
78
125
|
* // - ACCOUNT_NOT_EXIST 11003 账户不存在
|
126
|
+
* // - ACCOUNT_NOT_ACTIVATED 11004 账户未激活
|
79
127
|
*/
|
80
128
|
getBalance(address: string): Promise<{ errorCode: number; result: { balance: string } }>;
|
81
129
|
|
82
130
|
/**
|
83
131
|
* 获取账户交易序列号
|
84
|
-
* @param {string} address
|
132
|
+
* @param {string} address 账户地址(需以'adx'开头的base58编码格式)
|
85
133
|
* @returns {Promise<{errorCode:number, result:{nonce:string}}>} nonce值用于防止重放攻击
|
86
134
|
* @example
|
87
|
-
* sdk.account.getNonce('
|
135
|
+
* sdk.account.getNonce('adxSZHxE1YzrDRyQCJVpx7aStghSvyJTQAzF').then(console.log);
|
136
|
+
*
|
137
|
+
* // 返回示例:
|
138
|
+
* {
|
139
|
+
* errorCode: 0,
|
140
|
+
* result: {
|
141
|
+
* nonce: '1'
|
142
|
+
* }
|
143
|
+
* }
|
88
144
|
*
|
89
145
|
* // 错误码:
|
90
146
|
* // - INVALID_ADDRESS_ERROR 11002 无效地址
|
91
147
|
* // - ACCOUNT_NOT_EXIST 11003 账户不存在
|
148
|
+
* // - ACCOUNT_NOT_ACTIVATED 11004 账户未激活
|
92
149
|
*/
|
93
150
|
getNonce(address: string): Promise<{ errorCode: number; result: { nonce: string } }>;
|
94
151
|
|
95
152
|
/**
|
96
153
|
* 查询账户元数据
|
97
154
|
* @param {Object} params 查询参数
|
98
|
-
* @param {string} params.address
|
99
|
-
* @param {string} params.key
|
155
|
+
* @param {string} params.address 账户地址(需以'adx'开头的base58编码格式)
|
156
|
+
* @param {string} params.key 元数据键(不超过1024字节)
|
100
157
|
* @returns {Promise<{errorCode:number, result:MetadataResult}>} 包含版本号和值的元数据
|
101
158
|
* @example
|
102
|
-
* sdk.account.getMetadata({
|
159
|
+
* sdk.account.getMetadata({
|
160
|
+
* address: 'adxSZHxE1YzrDRyQCJVpx7aStghSvyJTQAzF',
|
161
|
+
* key: 'kyc_info'
|
162
|
+
* }).then(console.log);
|
163
|
+
*
|
164
|
+
* // 返回示例:
|
165
|
+
* {
|
166
|
+
* errorCode: 0,
|
167
|
+
* result: {
|
168
|
+
* version: '1',
|
169
|
+
* value: 'metadata value'
|
170
|
+
* }
|
171
|
+
* }
|
103
172
|
*
|
104
173
|
* // 错误码:
|
105
174
|
* // - METADATA_NOT_FOUND 12001 元数据不存在
|
106
175
|
* // - INVALID_ADDRESS_ERROR 11002 无效地址
|
176
|
+
* // - INVALID_DATAKEY_ERROR 11011 无效的元数据键
|
177
|
+
* // - ACCOUNT_NOT_EXIST 11003 账户不存在
|
107
178
|
*/
|
108
179
|
getMetadata(params: { address: string; key: string }): Promise<{ errorCode: number; result: MetadataResult }>;
|
109
180
|
|
110
181
|
/**
|
111
182
|
* 检查账户是否激活
|
112
|
-
* @param {string} address
|
183
|
+
* @param {string} address 待检查账户地址(需以'adx'开头的base58编码格式)
|
113
184
|
* @returns {Promise<{errorCode:number, result:{isActivated:boolean}}>}
|
114
185
|
* @example
|
115
|
-
*
|
186
|
+
* sdk.account.isActivated('adxSZHxE1YzrDRyQCJVpx7aStghSvyJTQAzF').then(console.log);
|
187
|
+
*
|
188
|
+
* // 返回示例:
|
189
|
+
* {
|
190
|
+
* errorCode: 0,
|
191
|
+
* result: {
|
192
|
+
* isActivated: true
|
193
|
+
* }
|
194
|
+
* }
|
116
195
|
*
|
117
196
|
* // 错误码:
|
197
|
+
* // - INVALID_ADDRESS_ERROR 11002 无效地址
|
198
|
+
* // - ACCOUNT_NOT_EXIST 11003 账户不存在
|
118
199
|
* // - ACCOUNT_NOT_ACTIVATED 11004 账户未激活
|
119
200
|
*/
|
120
201
|
isActivated(address: string): Promise<{ errorCode: number; result: { isActivated: boolean } }>;
|
121
202
|
};
|
122
203
|
|
123
204
|
contract: {
|
205
|
+
/**
|
206
|
+
* 检查合约地址有效性
|
207
|
+
* @param {string} contractAddress 合约账户地址
|
208
|
+
* @returns {Promise<{errorCode:number, result:{isValid:boolean}}>}
|
209
|
+
* @example
|
210
|
+
* sdk.contract.checkValid('adxScpCtbeLP2KGRaCkbtrmz8iB5mu6DQcW3r').then(console.log);
|
211
|
+
*
|
212
|
+
* // 返回示例:
|
213
|
+
* {
|
214
|
+
* errorCode: 0,
|
215
|
+
* result: {
|
216
|
+
* isValid: true
|
217
|
+
* }
|
218
|
+
* }
|
219
|
+
*
|
220
|
+
* // 错误码:
|
221
|
+
* // - INVALID_CONTRACTADDRESS_ERROR 11037 无效合约地址
|
222
|
+
* // - ACCOUNT_NOT_EXIST 11003 账户不存在
|
223
|
+
*/
|
224
|
+
checkValid(contractAddress: string): Promise<{ errorCode: number; result: { isValid: boolean } }>;
|
225
|
+
|
226
|
+
/**
|
227
|
+
* 调用合约方法
|
228
|
+
* @param {ContractCallParams} args 合约调用参数
|
229
|
+
* @returns {Promise<{errorCode:number, result:ContractCallResult}>}
|
230
|
+
* @example
|
231
|
+
* sdk.contract.call({
|
232
|
+
* contractAddress: 'adx...',
|
233
|
+
* sourceAddress: 'adx...',
|
234
|
+
* input: 'method(param)',
|
235
|
+
* contractBalance: '0',
|
236
|
+
* optType: 2,
|
237
|
+
* feeLimit: '1000000',
|
238
|
+
* gasPrice: '100'
|
239
|
+
* }).then(console.log);
|
240
|
+
*
|
241
|
+
* // 返回示例:
|
242
|
+
* {
|
243
|
+
* errorCode: 0,
|
244
|
+
* result: {
|
245
|
+
* logs: 'execution logs',
|
246
|
+
* queryRets: ['return value'],
|
247
|
+
* stat: {
|
248
|
+
* apply_time: 0,
|
249
|
+
* memory_usage: 0,
|
250
|
+
* stack_usage: 0,
|
251
|
+
* step: 0
|
252
|
+
* }
|
253
|
+
* }
|
254
|
+
* }
|
255
|
+
*
|
256
|
+
* // 错误码:
|
257
|
+
* // - INVALID_ARGUMENTS 11001 无效参数
|
258
|
+
* // - INVALID_OPTTYPE_ERROR 11045 无效的操作类型
|
259
|
+
* // - CONTRACTADDRESS_CODE_BOTH_NULL_ERROR 11046 合约地址和代码不能同时为空
|
260
|
+
* // - INVALID_CONTRACTADDRESS_ERROR 11037 无效合约地址
|
261
|
+
*/
|
262
|
+
call(args: ContractCallParams): Promise<{ errorCode: number; result: ContractCallResult }>;
|
263
|
+
|
124
264
|
/**
|
125
265
|
* 查询合约信息
|
126
266
|
* @param {string} contractAddress 合约账户地址(需以'adx'开头的base58编码格式)
|
@@ -128,26 +268,49 @@ declare class OpenChainSDK {
|
|
128
268
|
* @example
|
129
269
|
* sdk.contract.getInfo('adxScpCtbeLP2KGRaCkbtrmz8iB5mu6DQcW3r').then(console.log);
|
130
270
|
*
|
271
|
+
* // 返回示例:
|
272
|
+
* {
|
273
|
+
* errorCode: 0,
|
274
|
+
* result: {
|
275
|
+
* contract: {
|
276
|
+
* type: 0,
|
277
|
+
* payload: '...'
|
278
|
+
* }
|
279
|
+
* }
|
280
|
+
* }
|
281
|
+
*
|
131
282
|
* // 错误码:
|
132
283
|
* // - INVALID_CONTRACTADDRESS_ERROR 11037 无效合约地址
|
133
284
|
* // - CONTRACTADDRESS_NOT_CONTRACTACCOUNT_ERROR 11038 非合约账户地址
|
285
|
+
* // - CONTRACT_NOT_EXIST 11039 合约不存在
|
134
286
|
* // - SYSTEM_ERROR 20000 系统错误
|
135
287
|
*/
|
136
288
|
getInfo(contractAddress: string): Promise<{ errorCode: number; result: ContractInfoResult }>;
|
137
|
-
|
289
|
+
|
138
290
|
/**
|
139
291
|
* 通过交易哈希查询合约地址
|
140
292
|
* @param {string} hash 创建合约的交易哈希(64位十六进制字符串)
|
141
|
-
* @returns {Promise<{errorCode:number, result:ContractAddressInfo[]}>}
|
293
|
+
* @returns {Promise<{errorCode:number, result:{contractAddressList:ContractAddressInfo[]}}}>}
|
142
294
|
* @example
|
143
295
|
* sdk.contract.getAddress('cc4c...').then(console.log);
|
144
296
|
*
|
297
|
+
* // 返回示例:
|
298
|
+
* {
|
299
|
+
* errorCode: 0,
|
300
|
+
* result: {
|
301
|
+
* contractAddressList: [{
|
302
|
+
* contract_address: 'adx...',
|
303
|
+
* operation_index: 0
|
304
|
+
* }]
|
305
|
+
* }
|
306
|
+
* }
|
307
|
+
*
|
145
308
|
* // 错误码:
|
146
309
|
* // - INVALID_HASH_ERROR 11025 无效交易哈希
|
147
310
|
* // - QUERY_RESULT_NOT_EXIST 12002 查询结果不存在
|
148
|
-
* //
|
311
|
+
* // - INVALID_CONTRACT_HASH 11040 无效的合约哈希
|
149
312
|
*/
|
150
|
-
getAddress(hash: string): Promise<{ errorCode: number; result: ContractAddressInfo[] }>;
|
313
|
+
getAddress(hash: string): Promise<{ errorCode: number; result: { contractAddressList: ContractAddressInfo[] } }>;
|
151
314
|
|
152
315
|
/**
|
153
316
|
* 创建智能合约
|
@@ -158,12 +321,25 @@ declare class OpenChainSDK {
|
|
158
321
|
* sourceAddress: 'adx...',
|
159
322
|
* initBalance: '10',
|
160
323
|
* type: 0,
|
161
|
-
* payload: 'contract code'
|
324
|
+
* payload: 'contract code',
|
325
|
+
* initInput: 'constructor(param)',
|
326
|
+
* metadata: 'create contract'
|
162
327
|
* }).then(console.log);
|
328
|
+
*
|
329
|
+
* // 返回示例:
|
330
|
+
* {
|
331
|
+
* errorCode: 0,
|
332
|
+
* result: {
|
333
|
+
* contract_address: 'adx...',
|
334
|
+
* operation_index: 0
|
335
|
+
* }
|
336
|
+
* }
|
163
337
|
*
|
164
338
|
* // 错误码:
|
165
339
|
* // - INVALID_SOURCEADDRESS_ERROR 11002 无效源地址
|
166
340
|
* // - PAYLOAD_EMPTY_ERROR 11044 合约代码为空
|
341
|
+
* // - INVALID_CONTRACT_TYPE 11041 无效的合约类型
|
342
|
+
* // - INVALID_INIT_BALANCE 11042 无效的初始化余额
|
167
343
|
*/
|
168
344
|
createContract(params: ContractCreateParams): Promise<{ errorCode: number; result: ContractAddressInfo }>;
|
169
345
|
|
@@ -175,11 +351,24 @@ declare class OpenChainSDK {
|
|
175
351
|
* sdk.contract.invokeContract({
|
176
352
|
* sourceAddress: 'adx...',
|
177
353
|
* contractAddress: 'adx...',
|
178
|
-
* input: 'methodName(param)'
|
354
|
+
* input: 'methodName(param)',
|
355
|
+
* metadata: 'invoke contract'
|
179
356
|
* }).then(console.log);
|
357
|
+
*
|
358
|
+
* // 返回示例:
|
359
|
+
* {
|
360
|
+
* errorCode: 0,
|
361
|
+
* result: {
|
362
|
+
* result: 'execution result',
|
363
|
+
* logs: 'execution logs'
|
364
|
+
* }
|
365
|
+
* }
|
180
366
|
*
|
181
367
|
* // 错误码:
|
182
368
|
* // - CONTRACT_EXECUTE_FAILED 12003 合约执行失败
|
369
|
+
* // - INVALID_CONTRACTADDRESS_ERROR 11037 无效合约地址
|
370
|
+
* // - CONTRACT_NOT_EXIST 11039 合约不存在
|
371
|
+
* // - INVALID_INPUT_ERROR 11043 无效的输入参数
|
183
372
|
*/
|
184
373
|
invokeContract(params: ContractInvokeParams): Promise<{ errorCode: number; result: ContractInvokeResult }>;
|
185
374
|
};
|
@@ -219,6 +408,102 @@ declare class OpenChainSDK {
|
|
219
408
|
* // - BLOCK_NOT_EXIST 11008 区块不存在
|
220
409
|
*/
|
221
410
|
getTransactions(blockNumber: string): Promise<{ errorCode: number; result: TransactionListResult }>;
|
411
|
+
|
412
|
+
/**
|
413
|
+
* 获取指定区块信息
|
414
|
+
* @param {string} blockNumber 区块高度
|
415
|
+
* @returns {Promise<{errorCode:number, result:BlockInfoResult}>} 返回区块信息
|
416
|
+
* @example
|
417
|
+
* sdk.block.getInfo('100').then(console.log);
|
418
|
+
*
|
419
|
+
* // 错误码:
|
420
|
+
* // - INVALID_BLOCKNUMBER_ERROR 11007 无效区块高度
|
421
|
+
* // - QUERY_RESULT_NOT_EXIST 12002 查询结果不存在
|
422
|
+
*/
|
423
|
+
getInfo(blockNumber: string): Promise<{ errorCode: number; result: BlockInfoResult }>;
|
424
|
+
|
425
|
+
/**
|
426
|
+
* 获取最新区块信息
|
427
|
+
* @returns {Promise<{errorCode:number, result:BlockInfoResult}>} 返回最新区块信息
|
428
|
+
* @example
|
429
|
+
* sdk.block.getLatestInfo().then(console.log);
|
430
|
+
*
|
431
|
+
* // 错误码:
|
432
|
+
* // - QUERY_RESULT_NOT_EXIST 12002 查询结果不存在
|
433
|
+
*/
|
434
|
+
getLatestInfo(): Promise<{ errorCode: number; result: BlockInfoResult }>;
|
435
|
+
|
436
|
+
/**
|
437
|
+
* 获取指定区块的验证者信息
|
438
|
+
* @param {string} blockNumber 区块高度
|
439
|
+
* @returns {Promise<{errorCode:number, result:ValidatorsResult}>} 返回验证者信息
|
440
|
+
* @example
|
441
|
+
* sdk.block.getValidators('100').then(console.log);
|
442
|
+
*
|
443
|
+
* // 错误码:
|
444
|
+
* // - INVALID_BLOCKNUMBER_ERROR 11007 无效区块高度
|
445
|
+
* // - QUERY_RESULT_NOT_EXIST 12002 查询结果不存在
|
446
|
+
*/
|
447
|
+
getValidators(blockNumber: string): Promise<{ errorCode: number; result: ValidatorsResult }>;
|
448
|
+
|
449
|
+
/**
|
450
|
+
* 获取最新区块的验证者信息
|
451
|
+
* @returns {Promise<{errorCode:number, result:ValidatorsResult}>} 返回最新验证者信息
|
452
|
+
* @example
|
453
|
+
* sdk.block.getLatestValidators().then(console.log);
|
454
|
+
*
|
455
|
+
* // 错误码:
|
456
|
+
* // - QUERY_RESULT_NOT_EXIST 12002 查询结果不存在
|
457
|
+
*/
|
458
|
+
getLatestValidators(): Promise<{ errorCode: number; result: ValidatorsResult }>;
|
459
|
+
|
460
|
+
/**
|
461
|
+
* 获取指定区块的奖励信息
|
462
|
+
* @param {string} blockNumber 区块高度
|
463
|
+
* @returns {Promise<{errorCode:number, result:BlockRewardResult}>} 返回区块奖励信息
|
464
|
+
* @example
|
465
|
+
* sdk.block.getReward('100').then(console.log);
|
466
|
+
*
|
467
|
+
* // 错误码:
|
468
|
+
* // - INVALID_BLOCKNUMBER_ERROR 11007 无效区块高度
|
469
|
+
* // - QUERY_RESULT_NOT_EXIST 12002 查询结果不存在
|
470
|
+
*/
|
471
|
+
getReward(blockNumber: string): Promise<{ errorCode: number; result: BlockRewardResult }>;
|
472
|
+
|
473
|
+
/**
|
474
|
+
* 获取最新区块的奖励信息
|
475
|
+
* @returns {Promise<{errorCode:number, result:BlockRewardResult}>} 返回最新区块奖励信息
|
476
|
+
* @example
|
477
|
+
* sdk.block.getLatestReward().then(console.log);
|
478
|
+
*
|
479
|
+
* // 错误码:
|
480
|
+
* // - QUERY_RESULT_NOT_EXIST 12002 查询结果不存在
|
481
|
+
*/
|
482
|
+
getLatestReward(): Promise<{ errorCode: number; result: BlockRewardResult }>;
|
483
|
+
|
484
|
+
/**
|
485
|
+
* 获取指定区块的手续费信息
|
486
|
+
* @param {string} blockNumber 区块高度
|
487
|
+
* @returns {Promise<{errorCode:number, result:BlockFeesResult}>} 返回区块手续费信息
|
488
|
+
* @example
|
489
|
+
* sdk.block.getFees('100').then(console.log);
|
490
|
+
*
|
491
|
+
* // 错误码:
|
492
|
+
* // - INVALID_BLOCKNUMBER_ERROR 11007 无效区块高度
|
493
|
+
* // - QUERY_RESULT_NOT_EXIST 12002 查询结果不存在
|
494
|
+
*/
|
495
|
+
getFees(blockNumber: string): Promise<{ errorCode: number; result: BlockFeesResult }>;
|
496
|
+
|
497
|
+
/**
|
498
|
+
* 获取最新区块的手续费信息
|
499
|
+
* @returns {Promise<{errorCode:number, result:BlockFeesResult}>} 返回最新区块手续费信息
|
500
|
+
* @example
|
501
|
+
* sdk.block.getLatestFees().then(console.log);
|
502
|
+
*
|
503
|
+
* // 错误码:
|
504
|
+
* // - QUERY_RESULT_NOT_EXIST 12002 查询结果不存在
|
505
|
+
*/
|
506
|
+
getLatestFees(): Promise<{ errorCode: number; result: BlockFeesResult }>;
|
222
507
|
};
|
223
508
|
|
224
509
|
operation: {
|
@@ -242,12 +527,369 @@ declare class OpenChainSDK {
|
|
242
527
|
* @returns {OperationResult} 返回操作结果
|
243
528
|
*/
|
244
529
|
accountSetMetadataOperation(params: MetadataParams): { errorCode: number; result: OperationResult };
|
530
|
+
|
531
|
+
/**
|
532
|
+
* 创建合约操作
|
533
|
+
* @param {ContractCreateOperationParams} params 合约创建参数
|
534
|
+
* @returns {OperationResult} 返回操作结果
|
535
|
+
* @example
|
536
|
+
* sdk.operation.contractCreateOperation({
|
537
|
+
* sourceAddress: 'adx...',
|
538
|
+
* initBalance: '10000',
|
539
|
+
* type: 0,
|
540
|
+
* payload: 'contract code'
|
541
|
+
* });
|
542
|
+
*/
|
543
|
+
contractCreateOperation(params: ContractCreateOperationParams): { errorCode: number; result: OperationResult };
|
544
|
+
|
545
|
+
/**
|
546
|
+
* 调用合约操作
|
547
|
+
* @param {ContractInvokeOperationParams} params 合约调用参数
|
548
|
+
* @returns {OperationResult} 返回操作结果
|
549
|
+
* @example
|
550
|
+
* sdk.operation.contractInvokeOperation({
|
551
|
+
* sourceAddress: 'adx...',
|
552
|
+
* contractAddress: 'adx...',
|
553
|
+
* input: 'method(param)'
|
554
|
+
* });
|
555
|
+
*/
|
556
|
+
contractInvokeOperation(params: ContractInvokeOperationParams): { errorCode: number; result: OperationResult };
|
557
|
+
|
558
|
+
/**
|
559
|
+
* 发送Gas操作
|
560
|
+
* @param {GasSendOperationParams} params Gas发送参数
|
561
|
+
* @returns {OperationResult} 返回操作结果
|
562
|
+
* @example
|
563
|
+
* sdk.operation.gasSendOperation({
|
564
|
+
* sourceAddress: 'adx...',
|
565
|
+
* destAddress: 'adx...',
|
566
|
+
* amount: '1000'
|
567
|
+
* });
|
568
|
+
*/
|
569
|
+
gasSendOperation(params: GasSendOperationParams): { errorCode: number; result: OperationResult };
|
570
|
+
|
571
|
+
/**
|
572
|
+
* 创建日志操作
|
573
|
+
* @param {LogCreateOperationParams} params 日志创建参数
|
574
|
+
* @returns {OperationResult} 返回操作结果
|
575
|
+
* @example
|
576
|
+
* sdk.operation.logCreateOperation({
|
577
|
+
* sourceAddress: 'adx...',
|
578
|
+
* topic: 'mytopic',
|
579
|
+
* data: 'log content'
|
580
|
+
* });
|
581
|
+
*/
|
582
|
+
logCreateOperation(params: LogCreateOperationParams): { errorCode: number; result: OperationResult };
|
583
|
+
};
|
584
|
+
|
585
|
+
token: {
|
586
|
+
/**
|
587
|
+
* 发行代币
|
588
|
+
* @param {TokenIssueParams} params 代币发行参数
|
589
|
+
* @returns {Promise<{errorCode:number, result:TokenIssueResult}>}
|
590
|
+
* @example
|
591
|
+
* sdk.token.issue({
|
592
|
+
* sourceAddress: 'adx...',
|
593
|
+
* name: 'MyToken',
|
594
|
+
* code: 'MTK',
|
595
|
+
* totalSupply: '1000000',
|
596
|
+
* decimals: 8,
|
597
|
+
* description: 'My test token'
|
598
|
+
* }).then(console.log);
|
599
|
+
*
|
600
|
+
* // 返回示例:
|
601
|
+
* {
|
602
|
+
* errorCode: 0,
|
603
|
+
* result: {
|
604
|
+
* hash: '0x...',
|
605
|
+
* token: {
|
606
|
+
* code: 'MTK',
|
607
|
+
* issuer: 'adx...'
|
608
|
+
* }
|
609
|
+
* }
|
610
|
+
* }
|
611
|
+
*
|
612
|
+
* // 错误码:
|
613
|
+
* // - INVALID_SOURCEADDRESS_ERROR 11002 无效源地址
|
614
|
+
* // - TOKEN_CODE_INVALID 11101 无效的代币代码
|
615
|
+
* // - TOKEN_ALREADY_EXISTS 11102 代币已存在
|
616
|
+
* // - TOKEN_SUPPLY_LIMIT_ERROR 11103 代币发行量超出限制
|
617
|
+
*/
|
618
|
+
issue(params: TokenIssueParams): Promise<{ errorCode: number; result: TokenIssueResult }>;
|
619
|
+
|
620
|
+
/**
|
621
|
+
* 转移代币
|
622
|
+
* @param {TokenTransferParams} params 代币转移参数
|
623
|
+
* @returns {Promise<{errorCode:number, result:TokenTransferResult}>}
|
624
|
+
* @example
|
625
|
+
* sdk.token.transfer({
|
626
|
+
* sourceAddress: 'adx...',
|
627
|
+
* destAddress: 'adx...',
|
628
|
+
* code: 'MTK',
|
629
|
+
* amount: '100',
|
630
|
+
* metadata: 'transfer token'
|
631
|
+
* }).then(console.log);
|
632
|
+
*
|
633
|
+
* // 返回示例:
|
634
|
+
* {
|
635
|
+
* errorCode: 0,
|
636
|
+
* result: {
|
637
|
+
* hash: '0x...'
|
638
|
+
* }
|
639
|
+
* }
|
640
|
+
*
|
641
|
+
* // 错误码:
|
642
|
+
* // - INVALID_SOURCEADDRESS_ERROR 11002 无效源地址
|
643
|
+
* // - INVALID_DESTADDRESS_ERROR 11003 无效目标地址
|
644
|
+
* // - TOKEN_NOT_FOUND 11104 代币不存在
|
645
|
+
* // - INSUFFICIENT_TOKEN_BALANCE 11105 代币余额不足
|
646
|
+
*/
|
647
|
+
transfer(params: TokenTransferParams): Promise<{ errorCode: number; result: TokenTransferResult }>;
|
648
|
+
|
649
|
+
/**
|
650
|
+
* 查询代币信息
|
651
|
+
* @param {string} code 代币代码
|
652
|
+
* @returns {Promise<{errorCode:number, result:TokenInfoResult}>}
|
653
|
+
* @example
|
654
|
+
* sdk.token.getInfo('MTK').then(console.log);
|
655
|
+
*
|
656
|
+
* // 返回示例:
|
657
|
+
* {
|
658
|
+
* errorCode: 0,
|
659
|
+
* result: {
|
660
|
+
* token: {
|
661
|
+
* code: 'MTK',
|
662
|
+
* name: 'MyToken',
|
663
|
+
* description: 'My test token',
|
664
|
+
* decimals: 8,
|
665
|
+
* totalSupply: '1000000',
|
666
|
+
* issuer: 'adx...',
|
667
|
+
* createTime: '1632047037000'
|
668
|
+
* }
|
669
|
+
* }
|
670
|
+
* }
|
671
|
+
*
|
672
|
+
* // 错误码:
|
673
|
+
* // - TOKEN_NOT_FOUND 11104 代币不存在
|
674
|
+
*/
|
675
|
+
getInfo(code: string): Promise<{ errorCode: number; result: TokenInfoResult }>;
|
676
|
+
|
677
|
+
/**
|
678
|
+
* 查询代币余额
|
679
|
+
* @param {TokenBalanceParams} params 余额查询参数
|
680
|
+
* @returns {Promise<{errorCode:number, result:TokenBalanceResult}>}
|
681
|
+
* @example
|
682
|
+
* sdk.token.getBalance({
|
683
|
+
* address: 'adx...',
|
684
|
+
* code: 'MTK'
|
685
|
+
* }).then(console.log);
|
686
|
+
*
|
687
|
+
* // 返回示例:
|
688
|
+
* {
|
689
|
+
* errorCode: 0,
|
690
|
+
* result: {
|
691
|
+
* balance: '100',
|
692
|
+
* frozen: '0'
|
693
|
+
* }
|
694
|
+
* }
|
695
|
+
*
|
696
|
+
* // 错误码:
|
697
|
+
* // - INVALID_ADDRESS_ERROR 11002 无效地址
|
698
|
+
* // - TOKEN_NOT_FOUND 11104 代币不存在
|
699
|
+
*/
|
700
|
+
getBalance(params: TokenBalanceParams): Promise<{ errorCode: number; result: TokenBalanceResult }>;
|
701
|
+
|
702
|
+
/**
|
703
|
+
* 查询代币持有者列表
|
704
|
+
* @param {TokenHoldersParams} params 持有者查询参数
|
705
|
+
* @returns {Promise<{errorCode:number, result:TokenHoldersResult}>}
|
706
|
+
* @example
|
707
|
+
* sdk.token.getHolders({
|
708
|
+
* code: 'MTK',
|
709
|
+
* limit: 10,
|
710
|
+
* offset: 0
|
711
|
+
* }).then(console.log);
|
712
|
+
*
|
713
|
+
* // 返回示例:
|
714
|
+
* {
|
715
|
+
* errorCode: 0,
|
716
|
+
* result: {
|
717
|
+
* total: 100,
|
718
|
+
* holders: [{
|
719
|
+
* address: 'adx...',
|
720
|
+
* balance: '1000',
|
721
|
+
* percentage: '0.001'
|
722
|
+
* }]
|
723
|
+
* }
|
724
|
+
* }
|
725
|
+
*
|
726
|
+
* // 错误码:
|
727
|
+
* // - TOKEN_NOT_FOUND 11104 代币不存在
|
728
|
+
* // - INVALID_PARAMETER 11001 无效参数
|
729
|
+
*/
|
730
|
+
getHolders(params: TokenHoldersParams): Promise<{ errorCode: number; result: TokenHoldersResult }>;
|
731
|
+
};
|
732
|
+
|
733
|
+
util: {
|
734
|
+
/**
|
735
|
+
* 检查对象是否为 BigNumber 类型
|
736
|
+
* @param {any} object 要检查的对象
|
737
|
+
* @returns {boolean} 如果对象是 BigNumber 类型返回 true,否则返回 false
|
738
|
+
* @example
|
739
|
+
* const isBig = sdk.util.isBigNumber(new BigNumber('100'));
|
740
|
+
* console.log(isBig); // true
|
741
|
+
*/
|
742
|
+
isBigNumber(object: any): boolean;
|
743
|
+
|
744
|
+
/**
|
745
|
+
* 将输入数据转换为 BigNumber 对象
|
746
|
+
* @param {string | number} data 要转换的数据
|
747
|
+
* @returns {BigNumber} 转换后的 BigNumber 对象
|
748
|
+
* @example
|
749
|
+
* const big = sdk.util.toBigNumber('100');
|
750
|
+
* console.log(big.toString()); // '100'
|
751
|
+
*/
|
752
|
+
toBigNumber(data: string | number): any; // 返回 BigNumber 类型
|
753
|
+
|
754
|
+
/**
|
755
|
+
* 将 UTF-8 字符串转换为十六进制字符串
|
756
|
+
* @param {string} str UTF-8 字符串
|
757
|
+
* @returns {string} 转换后的十六进制字符串
|
758
|
+
* @example
|
759
|
+
* const hex = sdk.util.utfToHex('Hello');
|
760
|
+
* console.log(hex); // '48656c6c6f'
|
761
|
+
*/
|
762
|
+
utfToHex(str: string): string;
|
763
|
+
|
764
|
+
/**
|
765
|
+
* 将十六进制字符串转换为 UTF-8 字符串
|
766
|
+
* @param {string} str 十六进制字符串
|
767
|
+
* @returns {string} 转换后的 UTF-8 字符串
|
768
|
+
* @example
|
769
|
+
* const text = sdk.util.hexToUtf('48656c6c6f');
|
770
|
+
* console.log(text); // 'Hello'
|
771
|
+
*/
|
772
|
+
hexToUtf(str: string): string;
|
773
|
+
|
774
|
+
/**
|
775
|
+
* 将 BU 单位的数值转换为 MO 单位
|
776
|
+
* @param {string} bu BU 单位的数值
|
777
|
+
* @returns {string} MO 单位的数值字符串
|
778
|
+
* @example
|
779
|
+
* const mo = sdk.util.buToMo('1');
|
780
|
+
* console.log(mo); // '100000000'
|
781
|
+
*/
|
782
|
+
buToMo(bu: string): string;
|
783
|
+
|
784
|
+
/**
|
785
|
+
* 将 MO 单位的数值转换为 BU 单位
|
786
|
+
* @param {string} mo MO 单位的数值
|
787
|
+
* @returns {string} BU 单位的数值字符串
|
788
|
+
* @example
|
789
|
+
* const bu = sdk.util.moToBu('100000000');
|
790
|
+
* console.log(bu); // '1'
|
791
|
+
*/
|
792
|
+
moToBu(mo: string): string;
|
793
|
+
|
794
|
+
/**
|
795
|
+
* 根据指定的小数位数计算代币数量
|
796
|
+
* @param {string} amount 代币数量
|
797
|
+
* @param {string} decimals 小数位数
|
798
|
+
* @returns {string | false} 计算后的数值字符串,如果计算结果无效则返回 false
|
799
|
+
* @example
|
800
|
+
* const amount = sdk.util.unitWithDecimals('100', '8');
|
801
|
+
* console.log(amount); // '10000000000'
|
802
|
+
*/
|
803
|
+
unitWithDecimals(amount: string, decimals: string): string | false;
|
245
804
|
};
|
246
805
|
|
247
806
|
transaction: {
|
248
|
-
|
807
|
+
/**
|
808
|
+
* 构建交易
|
809
|
+
* @param {TransactionBuildBlobParams} params 交易构建参数
|
810
|
+
* @returns {Promise<{errorCode:number, result:TransactionBuildBlobResult}>} 返回交易blob
|
811
|
+
* @example
|
812
|
+
* sdk.transaction.buildBlob({
|
813
|
+
* sourceAddress: 'adx...',
|
814
|
+
* gasPrice: '100',
|
815
|
+
* feeLimit: '1000000',
|
816
|
+
* nonce: '1',
|
817
|
+
* operations: [{...}]
|
818
|
+
* }).then(console.log);
|
819
|
+
*
|
820
|
+
* // 错误码:
|
821
|
+
* // - INVALID_ARGUMENTS 11001 无效参数
|
822
|
+
* // - INVALID_SOURCEADDRESS_ERROR 11002 无效源地址
|
823
|
+
*/
|
824
|
+
buildBlob(params: TransactionBuildBlobParams): Promise<{ errorCode: number; result: TransactionBuildBlobResult }>;
|
825
|
+
|
826
|
+
/**
|
827
|
+
* 签名交易
|
828
|
+
* @param {TransactionSignParams} params 签名参数
|
829
|
+
* @returns {Promise<{errorCode:number, result:TransactionSignResult}>} 返回签名结果
|
830
|
+
* @example
|
831
|
+
* sdk.transaction.sign({
|
832
|
+
* privateKeys: ['priv...'],
|
833
|
+
* blob: '0x...'
|
834
|
+
* }).then(console.log);
|
835
|
+
*
|
836
|
+
* // 错误码:
|
837
|
+
* // - INVALID_ARGUMENTS 11001 无效参数
|
838
|
+
* // - PRIVATEKEY_NULL_ERROR 11057 私钥不能为空
|
839
|
+
* // - INVALID_BLOB_ERROR 11056 无效的blob数据
|
840
|
+
*/
|
249
841
|
sign(params: TransactionSignParams): Promise<{ errorCode: number; result: TransactionSignResult }>;
|
842
|
+
|
843
|
+
/**
|
844
|
+
* 提交交易
|
845
|
+
* @param {TransactionSubmitParams} params 提交参数
|
846
|
+
* @returns {Promise<{errorCode:number, result:TransactionSubmitResult}>} 返回提交结果
|
847
|
+
* @example
|
848
|
+
* sdk.transaction.submit({
|
849
|
+
* blob: '0x...',
|
850
|
+
* signatures: [{
|
851
|
+
* signData: '0x...',
|
852
|
+
* publicKey: '0x...'
|
853
|
+
* }]
|
854
|
+
* }).then(console.log);
|
855
|
+
*
|
856
|
+
* // 错误码:
|
857
|
+
* // - INVALID_ARGUMENTS 11001 无效参数
|
858
|
+
* // - INVALID_BLOB_ERROR 11056 无效的blob数据
|
859
|
+
* // - SIGNATURE_EMPTY_ERROR 11067 签名数据不能为空
|
860
|
+
*/
|
250
861
|
submit(params: TransactionSubmitParams): Promise<{ errorCode: number; result: TransactionSubmitResult }>;
|
862
|
+
|
863
|
+
/**
|
864
|
+
* 评估交易费用
|
865
|
+
* @param {TransactionEvaluateFeeParams} params 评估参数
|
866
|
+
* @returns {Promise<{errorCode:number, result:TransactionEvaluateFeeResult}>} 返回费用评估结果
|
867
|
+
* @example
|
868
|
+
* sdk.transaction.evaluateFee({
|
869
|
+
* sourceAddress: 'adx...',
|
870
|
+
* nonce: '1',
|
871
|
+
* operations: [{...}],
|
872
|
+
* signtureNumber: '1'
|
873
|
+
* }).then(console.log);
|
874
|
+
*
|
875
|
+
* // 错误码:
|
876
|
+
* // - INVALID_ARGUMENTS 11001 无效参数
|
877
|
+
* // - INVALID_SOURCEADDRESS_ERROR 11002 无效源地址
|
878
|
+
* // - INVALID_NONCE_ERROR 11048 无效nonce值
|
879
|
+
*/
|
880
|
+
evaluateFee(params: TransactionEvaluateFeeParams): Promise<{ errorCode: number; result: TransactionEvaluateFeeResult }>;
|
881
|
+
|
882
|
+
/**
|
883
|
+
* 获取交易信息
|
884
|
+
* @param {string} hash 交易哈希
|
885
|
+
* @returns {Promise<{errorCode:number, result:TransactionResult}>} 返回交易详情
|
886
|
+
* @example
|
887
|
+
* sdk.transaction.getInfo('0x...').then(console.log);
|
888
|
+
*
|
889
|
+
* // 错误码:
|
890
|
+
* // - INVALID_HASH_ERROR 11025 无效的交易哈希
|
891
|
+
* // - QUERY_RESULT_NOT_EXIST 12002 查询结果不存在
|
892
|
+
*/
|
251
893
|
getInfo(hash: string): Promise<{ errorCode: number; result: TransactionResult }>;
|
252
894
|
};
|
253
895
|
}
|
@@ -418,6 +1060,70 @@ export interface AccountActivateParams {
|
|
418
1060
|
metadata?: string;
|
419
1061
|
}
|
420
1062
|
|
1063
|
+
/**
|
1064
|
+
* 合约创建操作参数
|
1065
|
+
* @interface
|
1066
|
+
* @property {string} sourceAddress 操作源账户地址
|
1067
|
+
* @property {string} initBalance 合约初始化余额
|
1068
|
+
* @property {number} type 合约类型(0-JavaScript, 1-EVM)
|
1069
|
+
* @property {string} payload 合约代码
|
1070
|
+
* @property {string} [initInput] 合约初始化参数
|
1071
|
+
* @property {string} [metadata] 操作备注
|
1072
|
+
*/
|
1073
|
+
export interface ContractCreateOperationParams {
|
1074
|
+
sourceAddress: string;
|
1075
|
+
initBalance: string;
|
1076
|
+
type: number;
|
1077
|
+
payload: string;
|
1078
|
+
initInput?: string;
|
1079
|
+
metadata?: string;
|
1080
|
+
}
|
1081
|
+
|
1082
|
+
/**
|
1083
|
+
* 合约调用操作参数
|
1084
|
+
* @interface
|
1085
|
+
* @property {string} sourceAddress 调用者账户地址
|
1086
|
+
* @property {string} contractAddress 合约账户地址
|
1087
|
+
* @property {string} input 合约调用输入数据
|
1088
|
+
* @property {string} [metadata] 操作备注
|
1089
|
+
*/
|
1090
|
+
export interface ContractInvokeOperationParams {
|
1091
|
+
sourceAddress: string;
|
1092
|
+
contractAddress: string;
|
1093
|
+
input: string;
|
1094
|
+
metadata?: string;
|
1095
|
+
}
|
1096
|
+
|
1097
|
+
/**
|
1098
|
+
* Gas发送操作参数
|
1099
|
+
* @interface
|
1100
|
+
* @property {string} sourceAddress 发送方账户地址
|
1101
|
+
* @property {string} destAddress 接收方账户地址
|
1102
|
+
* @property {string} amount 发送金额(单位MO)
|
1103
|
+
* @property {string} [metadata] 操作备注
|
1104
|
+
*/
|
1105
|
+
export interface GasSendOperationParams {
|
1106
|
+
sourceAddress: string;
|
1107
|
+
destAddress: string;
|
1108
|
+
amount: string;
|
1109
|
+
metadata?: string;
|
1110
|
+
}
|
1111
|
+
|
1112
|
+
/**
|
1113
|
+
* 日志创建操作参数
|
1114
|
+
* @interface
|
1115
|
+
* @property {string} sourceAddress 操作源账户地址
|
1116
|
+
* @property {string} topic 日志主题
|
1117
|
+
* @property {string} data 日志内容
|
1118
|
+
* @property {string} [metadata] 操作备注
|
1119
|
+
*/
|
1120
|
+
export interface LogCreateOperationParams {
|
1121
|
+
sourceAddress: string;
|
1122
|
+
topic: string;
|
1123
|
+
data: string;
|
1124
|
+
metadata?: string;
|
1125
|
+
}
|
1126
|
+
|
421
1127
|
/**
|
422
1128
|
* 交易参数结构定义
|
423
1129
|
* @interface
|
@@ -532,4 +1238,251 @@ export interface TransactionResult {
|
|
532
1238
|
txSize: number;
|
533
1239
|
}>;
|
534
1240
|
}
|
1241
|
+
|
1242
|
+
|
1243
|
+
/**
|
1244
|
+
* 区块信息查询结果
|
1245
|
+
* @interface
|
1246
|
+
*/
|
1247
|
+
export interface BlockInfoResult {
|
1248
|
+
closeTime: string;
|
1249
|
+
number: string;
|
1250
|
+
txCount: string;
|
1251
|
+
version: string;
|
1252
|
+
}
|
1253
|
+
|
1254
|
+
/**
|
1255
|
+
* 验证者信息查询结果
|
1256
|
+
* @interface
|
1257
|
+
*/
|
1258
|
+
export interface ValidatorsResult {
|
1259
|
+
validators: Array<{
|
1260
|
+
address: string;
|
1261
|
+
pledge_coin_amount: string;
|
1262
|
+
[key: string]: any;
|
1263
|
+
}>;
|
1264
|
+
}
|
1265
|
+
|
1266
|
+
/**
|
1267
|
+
* 区块奖励信息查询结果
|
1268
|
+
* @interface
|
1269
|
+
*/
|
1270
|
+
export interface BlockRewardResult {
|
1271
|
+
blockReward: string;
|
1272
|
+
validatorsReward: Array<{
|
1273
|
+
validator: string;
|
1274
|
+
reward: string;
|
1275
|
+
}>;
|
1276
|
+
}
|
1277
|
+
|
1278
|
+
/**
|
1279
|
+
* 区块手续费信息查询结果
|
1280
|
+
* @interface
|
1281
|
+
*/
|
1282
|
+
export interface BlockFeesResult {
|
1283
|
+
fees: {
|
1284
|
+
base_reserve: string;
|
1285
|
+
gas_price: string;
|
1286
|
+
[key: string]: any;
|
1287
|
+
};
|
1288
|
+
}
|
1289
|
+
|
1290
|
+
/**
|
1291
|
+
* 代币发行参数
|
1292
|
+
* @interface
|
1293
|
+
* @property {string} sourceAddress 发行者账户地址
|
1294
|
+
* @property {string} name 代币名称
|
1295
|
+
* @property {string} code 代币代码(唯一标识)
|
1296
|
+
* @property {string} totalSupply 发行总量
|
1297
|
+
* @property {number} decimals 小数位数(0-8)
|
1298
|
+
* @property {string} [description] 代币描述
|
1299
|
+
* @property {string} [icon] 代币图标URL
|
1300
|
+
* @property {string} [metadata] 操作备注
|
1301
|
+
*/
|
1302
|
+
export interface TokenIssueParams {
|
1303
|
+
sourceAddress: string;
|
1304
|
+
name: string;
|
1305
|
+
code: string;
|
1306
|
+
totalSupply: string;
|
1307
|
+
decimals: number;
|
1308
|
+
description?: string;
|
1309
|
+
icon?: string;
|
1310
|
+
metadata?: string;
|
1311
|
+
}
|
1312
|
+
|
1313
|
+
/**
|
1314
|
+
* 代币发行结果
|
1315
|
+
* @interface
|
1316
|
+
* @property {string} hash 交易哈希
|
1317
|
+
* @property {Object} token 代币信息
|
1318
|
+
*/
|
1319
|
+
export interface TokenIssueResult {
|
1320
|
+
hash: string;
|
1321
|
+
token: {
|
1322
|
+
code: string;
|
1323
|
+
issuer: string;
|
1324
|
+
};
|
1325
|
+
}
|
1326
|
+
|
1327
|
+
/**
|
1328
|
+
* 代币转移参数
|
1329
|
+
* @interface
|
1330
|
+
* @property {string} sourceAddress 转出账户地址
|
1331
|
+
* @property {string} destAddress 转入账户地址
|
1332
|
+
* @property {string} code 代币代码
|
1333
|
+
* @property {string} amount 转移数量
|
1334
|
+
* @property {string} [metadata] 操作备注
|
1335
|
+
*/
|
1336
|
+
export interface TokenTransferParams {
|
1337
|
+
sourceAddress: string;
|
1338
|
+
destAddress: string;
|
1339
|
+
code: string;
|
1340
|
+
amount: string;
|
1341
|
+
metadata?: string;
|
1342
|
+
}
|
1343
|
+
|
1344
|
+
/**
|
1345
|
+
* 代币转移结果
|
1346
|
+
* @interface
|
1347
|
+
* @property {string} hash 交易哈希
|
1348
|
+
*/
|
1349
|
+
export interface TokenTransferResult {
|
1350
|
+
hash: string;
|
1351
|
+
}
|
1352
|
+
|
1353
|
+
/**
|
1354
|
+
* 代币信息查询结果
|
1355
|
+
* @interface
|
1356
|
+
* @property {Object} token 代币详情
|
1357
|
+
*/
|
1358
|
+
export interface TokenInfoResult {
|
1359
|
+
token: {
|
1360
|
+
code: string;
|
1361
|
+
name: string;
|
1362
|
+
description?: string;
|
1363
|
+
decimals: number;
|
1364
|
+
totalSupply: string;
|
1365
|
+
issuer: string;
|
1366
|
+
createTime: string;
|
1367
|
+
icon?: string;
|
1368
|
+
};
|
1369
|
+
}
|
1370
|
+
|
1371
|
+
/**
|
1372
|
+
* 代币余额查询参数
|
1373
|
+
* @interface
|
1374
|
+
* @property {string} address 账户地址
|
1375
|
+
* @property {string} code 代币代码
|
1376
|
+
*/
|
1377
|
+
export interface TokenBalanceParams {
|
1378
|
+
address: string;
|
1379
|
+
code: string;
|
1380
|
+
}
|
1381
|
+
|
1382
|
+
/**
|
1383
|
+
* 代币余额查询结果
|
1384
|
+
* @interface
|
1385
|
+
* @property {string} balance 可用余额
|
1386
|
+
* @property {string} frozen 冻结金额
|
1387
|
+
*/
|
1388
|
+
export interface TokenBalanceResult {
|
1389
|
+
balance: string;
|
1390
|
+
frozen: string;
|
1391
|
+
}
|
1392
|
+
|
1393
|
+
/**
|
1394
|
+
* 代币持有者查询参数
|
1395
|
+
* @interface
|
1396
|
+
* @property {string} code 代币代码
|
1397
|
+
* @property {number} [limit] 返回记录数量限制
|
1398
|
+
* @property {number} [offset] 起始位置偏移量
|
1399
|
+
*/
|
1400
|
+
export interface TokenHoldersParams {
|
1401
|
+
code: string;
|
1402
|
+
limit?: number;
|
1403
|
+
offset?: number;
|
1404
|
+
}
|
1405
|
+
|
1406
|
+
/**
|
1407
|
+
* 代币持有者查询结果
|
1408
|
+
* @interface
|
1409
|
+
* @property {number} total 总持有者数量
|
1410
|
+
* @property {Array} holders 持有者列表
|
1411
|
+
*/
|
1412
|
+
export interface TokenHoldersResult {
|
1413
|
+
total: number;
|
1414
|
+
holders: Array<{
|
1415
|
+
address: string;
|
1416
|
+
balance: string;
|
1417
|
+
percentage: string;
|
1418
|
+
}>;
|
1419
|
+
}
|
1420
|
+
|
1421
|
+
/**
|
1422
|
+
* 交易构建参数
|
1423
|
+
* @interface
|
1424
|
+
* @property {string} sourceAddress 交易发起账户地址
|
1425
|
+
* @property {string} nonce 交易序列号
|
1426
|
+
* @property {OperationResult[]} operations 操作列表
|
1427
|
+
* @property {string} [gasPrice] Gas单价(单位MO)
|
1428
|
+
* @property {string} [feeLimit] 交易费用上限
|
1429
|
+
* @property {string} [metadata] 交易备注
|
1430
|
+
* @example
|
1431
|
+
* {
|
1432
|
+
* sourceAddress: 'adx...',
|
1433
|
+
* gasPrice: '100',
|
1434
|
+
* feeLimit: '1000000',
|
1435
|
+
* nonce: '1',
|
1436
|
+
* operations: [{...}]
|
1437
|
+
* }
|
1438
|
+
*/
|
1439
|
+
export interface TransactionBuildBlobParams {
|
1440
|
+
sourceAddress: string;
|
1441
|
+
nonce: string;
|
1442
|
+
operations: OperationResult[];
|
1443
|
+
gasPrice?: string;
|
1444
|
+
feeLimit?: string;
|
1445
|
+
metadata?: string;
|
1446
|
+
}
|
1447
|
+
|
1448
|
+
/**
|
1449
|
+
* 交易费用评估参数
|
1450
|
+
* @interface
|
1451
|
+
* @property {string} sourceAddress 交易发起账户地址
|
1452
|
+
* @property {string} nonce 交易序列号
|
1453
|
+
* @property {OperationResult[]} operations 操作列表
|
1454
|
+
* @property {string} signtureNumber 签名数量
|
1455
|
+
* @property {string} [metadata] 交易备注
|
1456
|
+
* @example
|
1457
|
+
* {
|
1458
|
+
* sourceAddress: 'adx...',
|
1459
|
+
* nonce: '1',
|
1460
|
+
* operations: [{...}],
|
1461
|
+
* signtureNumber: '1'
|
1462
|
+
* }
|
1463
|
+
*/
|
1464
|
+
export interface TransactionEvaluateFeeParams {
|
1465
|
+
sourceAddress: string;
|
1466
|
+
nonce: string;
|
1467
|
+
operations: OperationResult[];
|
1468
|
+
signtureNumber: string;
|
1469
|
+
metadata?: string;
|
1470
|
+
}
|
1471
|
+
|
1472
|
+
/**
|
1473
|
+
* 交易费用评估结果
|
1474
|
+
* @interface
|
1475
|
+
* @property {string} gasPrice 建议的Gas单价(单位MO)
|
1476
|
+
* @property {string} feeLimit 建议的费用上限
|
1477
|
+
* @example
|
1478
|
+
* {
|
1479
|
+
* gasPrice: '100',
|
1480
|
+
* feeLimit: '1000000'
|
1481
|
+
* }
|
1482
|
+
*/
|
1483
|
+
export interface TransactionEvaluateFeeResult {
|
1484
|
+
gasPrice: string;
|
1485
|
+
feeLimit: string;
|
1486
|
+
}
|
1487
|
+
|
535
1488
|
export default OpenChainSDK;
|