@caict/bop-typescript-sdk 1.0.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/CHANGELOG.md +34 -0
- package/LICENSE +202 -0
- package/NOTICE +5 -0
- package/README.md +112 -0
- package/package.json +90 -0
- package/src/bop/bop-base/README.md +5 -0
- package/src/bop/bop-base/base.ts +366 -0
- package/src/bop/bop-base/index.ts +83 -0
- package/src/bop/bop-base/permit.ts +116 -0
- package/src/bop/bop-base/test/base.test.ts +867 -0
- package/src/bop/bop-base/test/index.test.ts +69 -0
- package/src/bop/bop-base/test/permit.test.ts +125 -0
- package/src/bop/bop-base/tsconfig.json +8 -0
- package/src/bop/bop-proto/README.md +2 -0
- package/src/bop/bop-proto/bop-ws.proto +266 -0
- package/src/bop/bop-proto/bop-ws.ts +4447 -0
- package/src/bop/bop-proto/bop.proto +898 -0
- package/src/bop/bop-proto/bop.ts +12890 -0
- package/src/bop/bop-proto/tsconfig.json +8 -0
- package/src/bop/bop-ws/index.ts +315 -0
- package/src/bop/bop-ws/sample/sample.ts +107 -0
- package/src/bop/bop-ws/tsconfig.json +8 -0
- package/src/bop/index.ts +14 -0
- package/src/bop-sdk/index.ts +22 -0
- package/src/bop-sdk/interface/abstract-service/abstract-account.ts +23 -0
- package/src/bop-sdk/interface/abstract-service/abstract-chain.ts +9 -0
- package/src/bop-sdk/interface/abstract-service/abstract-contract.ts +16 -0
- package/src/bop-sdk/interface/abstract-service/abstract-ledger.ts +15 -0
- package/src/bop-sdk/interface/abstract-service/abstract-provider.ts +13 -0
- package/src/bop-sdk/interface/abstract-service/abstract-signer.ts +133 -0
- package/src/bop-sdk/interface/abstract-service/abstract-transaction.ts +86 -0
- package/src/bop-sdk/interface/provider-ws.ts +10 -0
- package/src/bop-sdk/interface/provider.ts +22 -0
- package/src/bop-sdk/interface/service/3rd.ts +54 -0
- package/src/bop-sdk/interface/service/account.ts +86 -0
- package/src/bop-sdk/interface/service/chain.ts +27 -0
- package/src/bop-sdk/interface/service/contract.ts +51 -0
- package/src/bop-sdk/interface/service/helper.ts +426 -0
- package/src/bop-sdk/interface/service/ledger.ts +75 -0
- package/src/bop-sdk/interface/service/offline/check/index.js +138 -0
- package/src/bop-sdk/interface/service/offline/common/constant.js +6 -0
- package/src/bop-sdk/interface/service/offline/common/snowFlakeUtils.js +192 -0
- package/src/bop-sdk/interface/service/offline/common/util.js +511 -0
- package/src/bop-sdk/interface/service/offline/exception/customErrors.js +29 -0
- package/src/bop-sdk/interface/service/offline/exception/errors.js +90 -0
- package/src/bop-sdk/interface/service/offline/exception/index.js +5 -0
- package/src/bop-sdk/interface/service/offline/operation/accountCreateOperation.js +28 -0
- package/src/bop-sdk/interface/service/offline/operation/accountSetMetadataOperation.js +44 -0
- package/src/bop-sdk/interface/service/offline/operation/accountSetPrivilegeOperation.js +49 -0
- package/src/bop-sdk/interface/service/offline/operation/contractCreateOperation.js +43 -0
- package/src/bop-sdk/interface/service/offline/operation/contractInvokeOperation.js +42 -0
- package/src/bop-sdk/interface/service/offline/operation/contractInvokeRequestOperation.js +69 -0
- package/src/bop-sdk/interface/service/offline/operation/gasSendOperation.js +29 -0
- package/src/bop-sdk/interface/service/offline/operation/gasSendRequestOperation.js +61 -0
- package/src/bop-sdk/interface/service/offline/operation/index.js +20 -0
- package/src/bop-sdk/interface/service/offline/proto/chain_pb.js +12079 -0
- package/src/bop-sdk/interface/service/offline/proto/common_pb.js +2867 -0
- package/src/bop-sdk/interface/service/offline/transaction/index.js +988 -0
- package/src/bop-sdk/interface/service/offline/transaction/operations.js +188 -0
- package/src/bop-sdk/interface/service/offline/validate/account.js +152 -0
- package/src/bop-sdk/interface/service/offline/validate/contract.js +101 -0
- package/src/bop-sdk/interface/service/offline/validate/index.js +10 -0
- package/src/bop-sdk/interface/service/offline/validate/transaction.js +51 -0
- package/src/bop-sdk/interface/service/transaction.ts +731 -0
- package/src/bop-sdk/interface/signer.ts +46 -0
- package/src/bop-sdk/interface/test/3rd.test.ts +1571 -0
- package/src/bop-sdk/interface/test/account.test.ts +284 -0
- package/src/bop-sdk/interface/test/chain.test.ts +45 -0
- package/src/bop-sdk/interface/test/contract.test.ts +283 -0
- package/src/bop-sdk/interface/test/ledger.test.ts +166 -0
- package/src/bop-sdk/interface/test/provider.test.ts +407 -0
- package/src/bop-sdk/interface/test/signer.test.ts +105 -0
- package/src/bop-sdk/interface/test/transaction.test.ts +713 -0
- package/src/bop-sdk/proto/bop-sdk-common.proto +159 -0
- package/src/bop-sdk/proto/bop-sdk-common.ts +829 -0
- package/src/bop-sdk/proto/bop-sdk-interface.proto +581 -0
- package/src/bop-sdk/proto/bop-sdk-interface.ts +10839 -0
- package/src/bop-sdk/proto/bop-sdk-utils.proto +86 -0
- package/src/bop-sdk/proto/bop-sdk-utils.ts +1495 -0
- package/src/bop-sdk/utils/abi/abi-coder.ts +147 -0
- package/src/bop-sdk/utils/abi/address.ts +109 -0
- package/src/bop-sdk/utils/abi/bignumber.ts +403 -0
- package/src/bop-sdk/utils/abi/bytes.ts +565 -0
- package/src/bop-sdk/utils/abi/coders/abstract-coder.ts +239 -0
- package/src/bop-sdk/utils/abi/coders/address.ts +58 -0
- package/src/bop-sdk/utils/abi/coders/anonymous.ts +25 -0
- package/src/bop-sdk/utils/abi/coders/array.ts +275 -0
- package/src/bop-sdk/utils/abi/coders/boolean.ts +21 -0
- package/src/bop-sdk/utils/abi/coders/bytes.ts +36 -0
- package/src/bop-sdk/utils/abi/coders/fixed-bytes.ts +35 -0
- package/src/bop-sdk/utils/abi/coders/null.ts +25 -0
- package/src/bop-sdk/utils/abi/coders/number.ts +56 -0
- package/src/bop-sdk/utils/abi/coders/string.ts +24 -0
- package/src/bop-sdk/utils/abi/coders/tuple.ts +73 -0
- package/src/bop-sdk/utils/abi/constants/addresses.ts +1 -0
- package/src/bop-sdk/utils/abi/constants/bignumbers.ts +30 -0
- package/src/bop-sdk/utils/abi/constants/hashes.ts +2 -0
- package/src/bop-sdk/utils/abi/constants/index.ts +15 -0
- package/src/bop-sdk/utils/abi/constants/strings.ts +2 -0
- package/src/bop-sdk/utils/abi/fragments.ts +1243 -0
- package/src/bop-sdk/utils/abi/id.ts +6 -0
- package/src/bop-sdk/utils/abi/index.ts +46 -0
- package/src/bop-sdk/utils/abi/interface.ts +921 -0
- package/src/bop-sdk/utils/abi/keccak256.ts +9 -0
- package/src/bop-sdk/utils/abi/properties.ts +172 -0
- package/src/bop-sdk/utils/abi/strings/bytes32.ts +40 -0
- package/src/bop-sdk/utils/abi/strings/idna.ts +258 -0
- package/src/bop-sdk/utils/abi/strings/index.ts +28 -0
- package/src/bop-sdk/utils/abi/strings/utf8.ts +373 -0
- package/src/bop-sdk/utils/encryption-address.ts +501 -0
- package/src/bop-sdk/utils/encryption-crypto.ts +427 -0
- package/src/bop-sdk/utils/encryption-mnemonics.ts +120 -0
- package/src/bop-sdk/utils/index.ts +27 -0
- package/src/bop-sdk/utils/logger.ts +480 -0
- package/src/index.ts +35 -0
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { expect } from "chai";
|
|
2
|
+
import { promisify } from "util";
|
|
3
|
+
import * as sinon from "sinon";
|
|
4
|
+
import { Config, BopInterface } from "../index";
|
|
5
|
+
import { ApplyRequest } from "../../bop-proto/bop";
|
|
6
|
+
|
|
7
|
+
// 使用 Sinon 创建模拟对象
|
|
8
|
+
const sandbox = sinon.createSandbox();
|
|
9
|
+
|
|
10
|
+
describe("BopInterface", () => {
|
|
11
|
+
let bopInterface: BopInterface;
|
|
12
|
+
let config: Config;
|
|
13
|
+
let permitServiceMock: sinon.SinonMock; // 假设 PermitService 有一些方法需要模拟
|
|
14
|
+
|
|
15
|
+
beforeEach(() => {
|
|
16
|
+
config = new Config("https://bif-mainnet.bitfactory.cn", "xxx", "xxx");
|
|
17
|
+
bopInterface = new BopInterface(config);
|
|
18
|
+
|
|
19
|
+
// 模拟 PermitService
|
|
20
|
+
permitServiceMock = sandbox.mock(bopInterface.getPermitService());
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
afterEach(() => {
|
|
24
|
+
// 重置模拟对象
|
|
25
|
+
sandbox.restore();
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
describe("callService", () => {
|
|
29
|
+
it("should call the correct service and method", async () => {
|
|
30
|
+
// 设置模拟对象的行为
|
|
31
|
+
permitServiceMock
|
|
32
|
+
.expects("apply")
|
|
33
|
+
.withArgs(sinon.match.any)
|
|
34
|
+
.resolves({ status: "success", data: {} });
|
|
35
|
+
|
|
36
|
+
const applyRequest: ApplyRequest = {
|
|
37
|
+
data: [],
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
const response = await bopInterface.callService(
|
|
41
|
+
"permit_apply",
|
|
42
|
+
applyRequest,
|
|
43
|
+
);
|
|
44
|
+
|
|
45
|
+
expect(response).to.deep.equal({ status: "success", data: {} });
|
|
46
|
+
|
|
47
|
+
// 验证模拟对象的方法调用
|
|
48
|
+
permitServiceMock.verify();
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
it("should throw an error for unknown method", async () => {
|
|
52
|
+
// 设置模拟对象的行为以抛出错误
|
|
53
|
+
permitServiceMock
|
|
54
|
+
.expects("apply")
|
|
55
|
+
.throws(new Error("Method not implemented"));
|
|
56
|
+
|
|
57
|
+
const applyRequest: ApplyRequest = {
|
|
58
|
+
data: [],
|
|
59
|
+
};
|
|
60
|
+
try {
|
|
61
|
+
await bopInterface.callService("permit_apply", applyRequest);
|
|
62
|
+
} catch (err) {
|
|
63
|
+
expect(err.message).to.equal("Method not implemented");
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
permitServiceMock.verify();
|
|
67
|
+
});
|
|
68
|
+
});
|
|
69
|
+
});
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
import { expect } from "chai";
|
|
2
|
+
import { promisify } from "util";
|
|
3
|
+
import * as sinon from "sinon";
|
|
4
|
+
import { Config } from "../index";
|
|
5
|
+
import { PermitService } from "../permit";
|
|
6
|
+
import {
|
|
7
|
+
ApplyRequest,
|
|
8
|
+
ApplyResponse,
|
|
9
|
+
statusCodesToJSON,
|
|
10
|
+
ApplyStatusRequest,
|
|
11
|
+
ApplyStatusResponse,
|
|
12
|
+
DetailRequest,
|
|
13
|
+
DetailResponse,
|
|
14
|
+
} from "../../bop-proto/bop";
|
|
15
|
+
|
|
16
|
+
// 使用 Sinon 创建模拟对象
|
|
17
|
+
const sandbox = sinon.createSandbox();
|
|
18
|
+
|
|
19
|
+
describe("PermitService", () => {
|
|
20
|
+
let config: Config;
|
|
21
|
+
let permitService: PermitService;
|
|
22
|
+
|
|
23
|
+
beforeEach(() => {
|
|
24
|
+
config = new Config("https://bif-mainnet.bitfactory.cn", "xxx", "xxx");
|
|
25
|
+
permitService = new PermitService(config.host);
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
afterEach(() => {
|
|
29
|
+
// 重置模拟对象
|
|
30
|
+
sandbox.restore();
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
describe("apply", () => {
|
|
34
|
+
it("apply status 1 should return 0", async () => {
|
|
35
|
+
const request: ApplyRequest = {
|
|
36
|
+
data: [
|
|
37
|
+
{
|
|
38
|
+
bid: "did:bid:efC5REiFesaBuu1UXbMJWvEsqFRkQKiq",
|
|
39
|
+
status: "1",
|
|
40
|
+
},
|
|
41
|
+
],
|
|
42
|
+
};
|
|
43
|
+
let response: ApplyResponse;
|
|
44
|
+
response = await permitService.apply(request);
|
|
45
|
+
expect(response.errorCode).to.equal(0);
|
|
46
|
+
expect(response.errorDesc).to.equal("ok");
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
it("apply status 0 should return 0", async () => {
|
|
50
|
+
const request: ApplyRequest = {
|
|
51
|
+
data: [
|
|
52
|
+
{
|
|
53
|
+
bid: "did:bid:efC5REiFesaBuu1UXbMJWvEsqFRkQKiq",
|
|
54
|
+
status: "0",
|
|
55
|
+
},
|
|
56
|
+
],
|
|
57
|
+
};
|
|
58
|
+
let response: ApplyResponse;
|
|
59
|
+
response = await permitService.apply(request);
|
|
60
|
+
expect(response.errorCode).to.equal(0);
|
|
61
|
+
expect(response.errorDesc).to.equal("ok");
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
it("apply status 0 should return 1106", async () => {
|
|
65
|
+
const request: ApplyRequest = {
|
|
66
|
+
data: [
|
|
67
|
+
{
|
|
68
|
+
bid: "xxx",
|
|
69
|
+
status: "0",
|
|
70
|
+
},
|
|
71
|
+
],
|
|
72
|
+
};
|
|
73
|
+
let response: ApplyResponse;
|
|
74
|
+
response = await permitService.apply(request);
|
|
75
|
+
expect(statusCodesToJSON(response.errorCode)).to.equal(
|
|
76
|
+
"REMOTE_CALL_FAILED",
|
|
77
|
+
);
|
|
78
|
+
expect(response.errorDesc).to.equal("Parameter format error");
|
|
79
|
+
});
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
describe("status", () => {
|
|
83
|
+
it("status return 0", async () => {
|
|
84
|
+
const request: ApplyStatusRequest = {
|
|
85
|
+
requestNo: "ca3d2fa2-28ab-4322-b9f7-b018667acf87",
|
|
86
|
+
};
|
|
87
|
+
let response: ApplyStatusResponse;
|
|
88
|
+
response = await permitService.status(request);
|
|
89
|
+
expect(response.errorCode).to.equal(0);
|
|
90
|
+
expect(response.errorDesc).to.equal("ok");
|
|
91
|
+
});
|
|
92
|
+
|
|
93
|
+
it("status invalid requestNo return 1106", async () => {
|
|
94
|
+
const request: ApplyStatusRequest = {
|
|
95
|
+
requestNo: "xxx",
|
|
96
|
+
};
|
|
97
|
+
let response: ApplyStatusResponse;
|
|
98
|
+
response = await permitService.status(request);
|
|
99
|
+
expect(response.errorCode).to.equal(1106);
|
|
100
|
+
expect(response.errorDesc).to.equal("The data does not exist.");
|
|
101
|
+
});
|
|
102
|
+
});
|
|
103
|
+
|
|
104
|
+
describe("detail", () => {
|
|
105
|
+
it("detail return 0", async () => {
|
|
106
|
+
const request: DetailRequest = {
|
|
107
|
+
requestNo: "ca3d2fa2-28ab-4322-b9f7-b018667acf87",
|
|
108
|
+
};
|
|
109
|
+
let response: DetailResponse;
|
|
110
|
+
response = await permitService.detail(request);
|
|
111
|
+
expect(response.errorCode).to.equal(0);
|
|
112
|
+
expect(response.errorDesc).to.equal("ok");
|
|
113
|
+
});
|
|
114
|
+
|
|
115
|
+
it("detail invalid requestNo return 1106", async () => {
|
|
116
|
+
const request: DetailRequest = {
|
|
117
|
+
requestNo: "xxx",
|
|
118
|
+
};
|
|
119
|
+
let response: DetailResponse;
|
|
120
|
+
response = await permitService.detail(request);
|
|
121
|
+
expect(response.errorCode).to.equal(1106);
|
|
122
|
+
expect(response.errorDesc).to.equal("The data does not exist.");
|
|
123
|
+
});
|
|
124
|
+
});
|
|
125
|
+
});
|
|
@@ -0,0 +1,266 @@
|
|
|
1
|
+
syntax = "proto3";
|
|
2
|
+
package bopws;
|
|
3
|
+
|
|
4
|
+
// 定义心跳消息、错误提示和订阅类型的枚举
|
|
5
|
+
enum MessageType {
|
|
6
|
+
HEARTBEAT = 0; // 心跳消息
|
|
7
|
+
ERROR = -1; // 连接返回错误提示
|
|
8
|
+
BLOCK_HEADER = 1; // 订阅区块头
|
|
9
|
+
BID_TRANSACTION = 2;// 订阅指定bid的交易
|
|
10
|
+
TLOG = 3; // 订阅TLOG
|
|
11
|
+
DISCARD_TRANSACTION = 4; // 订阅丢弃交易
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
// 心跳消息(可以是ping或pong)
|
|
15
|
+
message HeartbeatMessage {
|
|
16
|
+
string message = 1; // 可选的附加信息,如"ping"或"pong"
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
message SubscribeRequest {
|
|
20
|
+
repeated string message = 1;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
message LedgerHeaderMessage
|
|
24
|
+
{
|
|
25
|
+
int64 seq = 1;
|
|
26
|
+
string hash = 2;
|
|
27
|
+
string previous_hash = 3 [json_name = "previous_hash"];
|
|
28
|
+
string account_tree_hash = 4 [json_name = "account_tree_hash"];
|
|
29
|
+
int64 close_time = 5 [json_name = "close_time"];
|
|
30
|
+
string consensus_value_hash = 6 [json_name = "consensus_value_hash"];
|
|
31
|
+
int64 version = 7;
|
|
32
|
+
int64 tx_count = 8 [json_name = "tx_count"];
|
|
33
|
+
string validators_hash = 9 [json_name = "validators_hash"]; // hash
|
|
34
|
+
string fees_hash = 10 [json_name = "fees_hash"];
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
message Contract{
|
|
38
|
+
enum ContractType{
|
|
39
|
+
JAVASCRIPT = 0;
|
|
40
|
+
EVM = 1;
|
|
41
|
+
SYSTEM = 2;
|
|
42
|
+
}
|
|
43
|
+
ContractType type = 1;
|
|
44
|
+
string payload = 2;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
message Signer {
|
|
48
|
+
enum Limit{
|
|
49
|
+
SIGNER_NONE = 0;
|
|
50
|
+
SIGNER = 100;
|
|
51
|
+
};
|
|
52
|
+
string address = 1;
|
|
53
|
+
int64 weight = 2;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
message AccountPrivilege {
|
|
57
|
+
int64 master_weight = 1 [json_name = "master_weight"];
|
|
58
|
+
repeated Signer signers = 2;
|
|
59
|
+
AccountThreshold thresholds = 3;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
message OperationTypeThreshold{
|
|
63
|
+
enum Type {
|
|
64
|
+
UNKNOWN = 0;
|
|
65
|
+
CREATE_ACCOUNT = 1;
|
|
66
|
+
SET_METADATA = 4;
|
|
67
|
+
SET_SIGNER_WEIGHT = 5;
|
|
68
|
+
SET_THRESHOLD = 6;
|
|
69
|
+
PAY_COIN = 7;
|
|
70
|
+
LOG = 8;
|
|
71
|
+
SET_PRIVILEGE = 9;
|
|
72
|
+
UPGRADE_CONTRACT = 10;
|
|
73
|
+
SET_CONTROLLED_AREA = 11;
|
|
74
|
+
AUTHORIZE_TRANSFER = 12;
|
|
75
|
+
};
|
|
76
|
+
Type type = 1;
|
|
77
|
+
int64 threshold = 2;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
message AccountThreshold{
|
|
81
|
+
int64 tx_threshold = 1 [json_name = "tx_threshold"]; //required, [-1,MAX(INT64)] -1: indicates no setting
|
|
82
|
+
repeated OperationTypeThreshold type_thresholds = 2 [json_name = "type_thresholds"];
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
message OperationCreateAccount{
|
|
86
|
+
string dest_address = 1 [json_name = "dest_address"];
|
|
87
|
+
Contract contract = 2;
|
|
88
|
+
AccountPrivilege priv = 3;
|
|
89
|
+
repeated KeyPair metadatas = 4;
|
|
90
|
+
int64 init_balance = 5 [json_name = "init_balance"];
|
|
91
|
+
string init_input = 6 [json_name = "init_input"];
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
message OperationPayCoin {
|
|
95
|
+
string dest_address = 1 [json_name = "dest_address"];
|
|
96
|
+
int64 amount = 2;
|
|
97
|
+
string input = 3;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
message OperationSetMetadata{
|
|
101
|
+
string key = 1;
|
|
102
|
+
string value = 2;
|
|
103
|
+
int64 version = 3; //optional
|
|
104
|
+
bool delete_flag = 4 [json_name = "delete_flag"];
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
message OperationUpgradeContract {
|
|
108
|
+
string dest_address = 1 [json_name = "dest_address"];
|
|
109
|
+
string payload = 2;
|
|
110
|
+
int64 type = 3;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
message OperationSetSignerWeight{
|
|
114
|
+
int64 master_weight = 1 [json_name = "master_weight"]; //required, [-1,MAX(UINT32)] -1: indicates no setting
|
|
115
|
+
repeated Signer signers = 2; //address:weight, if weight is 0, it indicates deleting this signer
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
message OperationSetThreshold{
|
|
119
|
+
int64 tx_threshold = 1;
|
|
120
|
+
repeated OperationTypeThreshold type_thresholds = 4 [json_name = "type_thresholds"]; //type:threshold, threshold:0 indicates deleting this type
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
message OperationLog{
|
|
124
|
+
string topic = 1;
|
|
125
|
+
repeated string datas = 2;
|
|
126
|
+
repeated string topics = 3; //for evm
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
message OperationSetPrivilege{
|
|
130
|
+
string master_weight = 1 [json_name = "master_weight"];
|
|
131
|
+
repeated Signer signers = 2;
|
|
132
|
+
string tx_threshold = 3 [json_name = "tx_threshold"];
|
|
133
|
+
repeated OperationTypeThreshold type_thresholds = 4 [json_name = "type_thresholds"];
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
message ControlledArea{
|
|
137
|
+
enum TRUST_FLAG {
|
|
138
|
+
UNCERT = 0;
|
|
139
|
+
TRUSTED = 1;
|
|
140
|
+
UNTRUSTED = 2;
|
|
141
|
+
};
|
|
142
|
+
|
|
143
|
+
enum STATUS_FALG {
|
|
144
|
+
ENABLED = 0;
|
|
145
|
+
DISABLED = 1;
|
|
146
|
+
};
|
|
147
|
+
|
|
148
|
+
TRUST_FLAG trusted = 1;
|
|
149
|
+
STATUS_FALG status = 2;
|
|
150
|
+
repeated KeyPair attributes = 3 ;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
message OperationSetControlledArea {
|
|
154
|
+
string dest_address = 1 [json_name = "dest_address"];
|
|
155
|
+
bool s_trusted = 2 [json_name = "s_trusted"];
|
|
156
|
+
bool s_status = 3 [json_name = "s_status"];
|
|
157
|
+
ControlledArea.TRUST_FLAG trusted = 4;
|
|
158
|
+
ControlledArea.STATUS_FALG status = 5;
|
|
159
|
+
repeated KeyPair attributes = 6;
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
message OperationAuthorizeTransfer{
|
|
163
|
+
string dest_address = 1 [json_name = "dest_address"];
|
|
164
|
+
bool auth = 2;
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
message Operation {
|
|
168
|
+
enum Type {
|
|
169
|
+
UNKNOWN = 0;
|
|
170
|
+
CREATE_ACCOUNT = 1;
|
|
171
|
+
SET_METADATA = 4;
|
|
172
|
+
SET_SIGNER_WEIGHT = 5;
|
|
173
|
+
SET_THRESHOLD = 6;
|
|
174
|
+
PAY_COIN = 7;
|
|
175
|
+
LOG = 8;
|
|
176
|
+
SET_PRIVILEGE = 9;
|
|
177
|
+
UPGRADE_CONTRACT = 10;
|
|
178
|
+
SET_CONTROLLED_AREA = 11;
|
|
179
|
+
AUTHORIZE_TRANSFER = 12;
|
|
180
|
+
};
|
|
181
|
+
Type type = 1;
|
|
182
|
+
string source_address = 2 [json_name = "source_address"];
|
|
183
|
+
string metadata = 3;
|
|
184
|
+
|
|
185
|
+
OperationCreateAccount create_account = 4 [json_name = "create_account"];
|
|
186
|
+
OperationSetMetadata set_metadata = 7 [json_name = "set_metadata"];
|
|
187
|
+
OperationSetSignerWeight set_signer_weight = 8 [json_name = "set_signer_weight"];
|
|
188
|
+
OperationSetThreshold set_threshold = 9 [json_name = "set_threshold"];
|
|
189
|
+
OperationPayCoin pay_coin = 10 [json_name = "pay_coin"];
|
|
190
|
+
OperationLog log = 11;
|
|
191
|
+
OperationSetPrivilege set_privilege = 12 [json_name = "set_privilege"];
|
|
192
|
+
OperationUpgradeContract upgrade_contract = 13 [json_name = "upgrade_contract"];
|
|
193
|
+
OperationSetControlledArea set_controlled_area = 14 [json_name = "set_controlled_area"];
|
|
194
|
+
OperationAuthorizeTransfer authorize_transfer = 15 [json_name = "authorize_transfer"];
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
message Transaction {
|
|
198
|
+
enum TxType{
|
|
199
|
+
INCREASE_NONCE = 0;
|
|
200
|
+
RANDOM_NONCE = 1;
|
|
201
|
+
};
|
|
202
|
+
string source_address = 1 [json_name = "source_address"];
|
|
203
|
+
int64 fee_limit = 2 [json_name = "fee_limit"];
|
|
204
|
+
int64 gas_price = 3 [json_name = "gas_price"];
|
|
205
|
+
string nonce = 4;
|
|
206
|
+
string metadata = 5;
|
|
207
|
+
TxType nonce_type = 6 [json_name = "nonce_type"];
|
|
208
|
+
int64 max_ledger_seq = 7 [json_name = "max_ledger_seq"];
|
|
209
|
+
repeated Operation operations = 8;
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
message Trigger{
|
|
213
|
+
enum TransactionType{
|
|
214
|
+
NORMAL_TRANSACTION = 0;
|
|
215
|
+
CONTRACT_TRANSACTION = 1;
|
|
216
|
+
};
|
|
217
|
+
|
|
218
|
+
message OperationTrigger{
|
|
219
|
+
bytes hash = 1;
|
|
220
|
+
int64 index = 2;
|
|
221
|
+
}
|
|
222
|
+
TransactionType transaction_type = 1;
|
|
223
|
+
int64 ledger_seq = 2 [json_name = "ledger_seq"]; //If it is triggered by a specific block (temporarily not provided)
|
|
224
|
+
OperationTrigger transaction = 3; //If it's a transaction triggered
|
|
225
|
+
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
message TransactionEnv {
|
|
229
|
+
Transaction transaction = 1;
|
|
230
|
+
repeated Signature signatures = 2;
|
|
231
|
+
Trigger trigger = 3;
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
message TransactionEnvStoreMessage {
|
|
235
|
+
TransactionEnv transaction_env = 1 [json_name = "transaction_env"];
|
|
236
|
+
int32 error_code = 2 [json_name = "error_code"];
|
|
237
|
+
string error_desc = 3 [json_name = "error_desc"];
|
|
238
|
+
int64 ledger_seq = 4 [json_name = "ledger_seq"];
|
|
239
|
+
int64 close_time = 5 [json_name = "close_time"];
|
|
240
|
+
//for notify
|
|
241
|
+
string hash = 6;
|
|
242
|
+
int64 actual_fee = 7 [json_name = "actual_fee"];
|
|
243
|
+
repeated string contract_tx_hashes = 8 [json_name = "contract_tx_hashes"];
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
message Signature {
|
|
247
|
+
string public_key = 1 [json_name = "public_key"];
|
|
248
|
+
string sign_data = 2 [json_name = "sign_data"];
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
message KeyPair{
|
|
252
|
+
string key = 1;
|
|
253
|
+
string value = 2;
|
|
254
|
+
int64 version = 3;
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
message DropTxMessage {
|
|
258
|
+
enum PoolType{
|
|
259
|
+
PLATFORM = 0;
|
|
260
|
+
CHAIN = 1;
|
|
261
|
+
};
|
|
262
|
+
string tx_hash = 1 [json_name = "tx_hash"];
|
|
263
|
+
PoolType source = 2;
|
|
264
|
+
int64 timestamp = 3;
|
|
265
|
+
string tx = 4; //序列化Transaction数据
|
|
266
|
+
}
|