@caict/bop-typescript-sdk 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/CHANGELOG.md +34 -0
- package/base.tsconfig.json +14 -0
- package/dist/bop/bop-base/base.d.ts +24 -0
- package/dist/bop/bop-base/base.js +253 -0
- package/dist/bop/bop-base/base.js.map +1 -0
- package/dist/bop/bop-base/index.d.ts +18 -0
- package/dist/bop/bop-base/index.js +69 -0
- package/dist/bop/bop-base/index.js.map +1 -0
- package/dist/bop/bop-base/permit.d.ts +11 -0
- package/dist/bop/bop-base/permit.js +104 -0
- package/dist/bop/bop-base/permit.js.map +1 -0
- package/dist/bop/bop-base/test/base.test.d.ts +1 -0
- package/dist/bop/bop-base/test/base.test.js +772 -0
- package/dist/bop/bop-base/test/base.test.js.map +1 -0
- package/dist/bop/bop-base/test/index.test.d.ts +1 -0
- package/dist/bop/bop-base/test/index.test.js +89 -0
- package/dist/bop/bop-base/test/index.test.js.map +1 -0
- package/dist/bop/bop-base/test/permit.test.d.ts +1 -0
- package/dist/bop/bop-base/test/permit.test.js +140 -0
- package/dist/bop/bop-base/test/permit.test.js.map +1 -0
- package/dist/bop/bop-proto/bop-ws.d.ts +325 -0
- package/dist/bop/bop-proto/bop-ws.js +3599 -0
- package/dist/bop/bop-proto/bop-ws.js.map +1 -0
- package/dist/bop/bop-proto/bop.d.ts +903 -0
- package/dist/bop/bop-proto/bop.js +10421 -0
- package/dist/bop/bop-proto/bop.js.map +1 -0
- package/dist/bop/bop-ws/index.d.ts +43 -0
- package/dist/bop/bop-ws/index.js +265 -0
- package/dist/bop/bop-ws/index.js.map +1 -0
- package/dist/bop/bop-ws/sample/sample.d.ts +1 -0
- package/dist/bop/bop-ws/sample/sample.js +96 -0
- package/dist/bop/bop-ws/sample/sample.js.map +1 -0
- package/dist/bop/index.d.ts +5 -0
- package/dist/bop/index.js +37 -0
- package/dist/bop/index.js.map +1 -0
- package/dist/bop-sdk/index.d.ts +13 -0
- package/dist/bop-sdk/index.js +45 -0
- package/dist/bop-sdk/index.js.map +1 -0
- package/dist/bop-sdk/interface/abstract-service/abstract-account.d.ts +8 -0
- package/dist/bop-sdk/interface/abstract-service/abstract-account.js +7 -0
- package/dist/bop-sdk/interface/abstract-service/abstract-account.js.map +1 -0
- package/dist/bop-sdk/interface/abstract-service/abstract-chain.d.ts +5 -0
- package/dist/bop-sdk/interface/abstract-service/abstract-chain.js +7 -0
- package/dist/bop-sdk/interface/abstract-service/abstract-chain.js.map +1 -0
- package/dist/bop-sdk/interface/abstract-service/abstract-contract.d.ts +6 -0
- package/dist/bop-sdk/interface/abstract-service/abstract-contract.js +7 -0
- package/dist/bop-sdk/interface/abstract-service/abstract-contract.js.map +1 -0
- package/dist/bop-sdk/interface/abstract-service/abstract-ledger.d.ts +8 -0
- package/dist/bop-sdk/interface/abstract-service/abstract-ledger.js +7 -0
- package/dist/bop-sdk/interface/abstract-service/abstract-ledger.js.map +1 -0
- package/dist/bop-sdk/interface/abstract-service/abstract-provider.d.ts +12 -0
- package/dist/bop-sdk/interface/abstract-service/abstract-provider.js +7 -0
- package/dist/bop-sdk/interface/abstract-service/abstract-provider.js.map +1 -0
- package/dist/bop-sdk/interface/abstract-service/abstract-signer.d.ts +17 -0
- package/dist/bop-sdk/interface/abstract-service/abstract-signer.js +109 -0
- package/dist/bop-sdk/interface/abstract-service/abstract-signer.js.map +1 -0
- package/dist/bop-sdk/interface/abstract-service/abstract-transaction.d.ts +17 -0
- package/dist/bop-sdk/interface/abstract-service/abstract-transaction.js +7 -0
- package/dist/bop-sdk/interface/abstract-service/abstract-transaction.js.map +1 -0
- package/dist/bop-sdk/interface/provider-ws.d.ts +5 -0
- package/dist/bop-sdk/interface/provider-ws.js +12 -0
- package/dist/bop-sdk/interface/provider-ws.js.map +1 -0
- package/dist/bop-sdk/interface/provider.d.ts +7 -0
- package/dist/bop-sdk/interface/provider.js +23 -0
- package/dist/bop-sdk/interface/provider.js.map +1 -0
- package/dist/bop-sdk/interface/service/3rd.d.ts +12 -0
- package/dist/bop-sdk/interface/service/3rd.js +49 -0
- package/dist/bop-sdk/interface/service/3rd.js.map +1 -0
- package/dist/bop-sdk/interface/service/account.d.ts +12 -0
- package/dist/bop-sdk/interface/service/account.js +98 -0
- package/dist/bop-sdk/interface/service/account.js.map +1 -0
- package/dist/bop-sdk/interface/service/chain.d.ts +9 -0
- package/dist/bop-sdk/interface/service/chain.js +55 -0
- package/dist/bop-sdk/interface/service/chain.js.map +1 -0
- package/dist/bop-sdk/interface/service/contract.d.ts +10 -0
- package/dist/bop-sdk/interface/service/contract.js +67 -0
- package/dist/bop-sdk/interface/service/contract.js.map +1 -0
- package/dist/bop-sdk/interface/service/helper.d.ts +20 -0
- package/dist/bop-sdk/interface/service/helper.js +383 -0
- package/dist/bop-sdk/interface/service/helper.js.map +1 -0
- package/dist/bop-sdk/interface/service/ledger.d.ts +12 -0
- package/dist/bop-sdk/interface/service/ledger.js +89 -0
- package/dist/bop-sdk/interface/service/ledger.js.map +1 -0
- package/dist/bop-sdk/interface/service/offline/check/index.js +138 -0
- package/dist/bop-sdk/interface/service/offline/common/constant.js +6 -0
- package/dist/bop-sdk/interface/service/offline/common/snowFlakeUtils.js +192 -0
- package/dist/bop-sdk/interface/service/offline/common/util.js +511 -0
- package/dist/bop-sdk/interface/service/offline/exception/customErrors.js +29 -0
- package/dist/bop-sdk/interface/service/offline/exception/errors.js +90 -0
- package/dist/bop-sdk/interface/service/offline/exception/index.js +5 -0
- package/dist/bop-sdk/interface/service/offline/operation/accountCreateOperation.js +28 -0
- package/dist/bop-sdk/interface/service/offline/operation/accountSetMetadataOperation.js +44 -0
- package/dist/bop-sdk/interface/service/offline/operation/accountSetPrivilegeOperation.js +49 -0
- package/dist/bop-sdk/interface/service/offline/operation/contractCreateOperation.js +43 -0
- package/dist/bop-sdk/interface/service/offline/operation/contractInvokeOperation.js +42 -0
- package/dist/bop-sdk/interface/service/offline/operation/contractInvokeRequestOperation.js +69 -0
- package/dist/bop-sdk/interface/service/offline/operation/gasSendOperation.js +29 -0
- package/dist/bop-sdk/interface/service/offline/operation/gasSendRequestOperation.js +61 -0
- package/dist/bop-sdk/interface/service/offline/operation/index.js +20 -0
- package/dist/bop-sdk/interface/service/offline/proto/chain_pb.js +12079 -0
- package/dist/bop-sdk/interface/service/offline/proto/common_pb.js +2867 -0
- package/dist/bop-sdk/interface/service/offline/transaction/index.js +988 -0
- package/dist/bop-sdk/interface/service/offline/transaction/operations.js +188 -0
- package/dist/bop-sdk/interface/service/offline/validate/account.js +152 -0
- package/dist/bop-sdk/interface/service/offline/validate/contract.js +101 -0
- package/dist/bop-sdk/interface/service/offline/validate/index.js +10 -0
- package/dist/bop-sdk/interface/service/offline/validate/transaction.js +51 -0
- package/dist/bop-sdk/interface/service/transaction.d.ts +21 -0
- package/dist/bop-sdk/interface/service/transaction.js +591 -0
- package/dist/bop-sdk/interface/service/transaction.js.map +1 -0
- package/dist/bop-sdk/interface/signer.d.ts +12 -0
- package/dist/bop-sdk/interface/signer.js +53 -0
- package/dist/bop-sdk/interface/signer.js.map +1 -0
- package/dist/bop-sdk/interface/test/3rd.test.d.ts +1 -0
- package/dist/bop-sdk/interface/test/3rd.test.js +1524 -0
- package/dist/bop-sdk/interface/test/3rd.test.js.map +1 -0
- package/dist/bop-sdk/interface/test/account.test.d.ts +1 -0
- package/dist/bop-sdk/interface/test/account.test.js +225 -0
- package/dist/bop-sdk/interface/test/account.test.js.map +1 -0
- package/dist/bop-sdk/interface/test/chain.test.d.ts +1 -0
- package/dist/bop-sdk/interface/test/chain.test.js +72 -0
- package/dist/bop-sdk/interface/test/chain.test.js.map +1 -0
- package/dist/bop-sdk/interface/test/contract.test.d.ts +1 -0
- package/dist/bop-sdk/interface/test/contract.test.js +266 -0
- package/dist/bop-sdk/interface/test/contract.test.js.map +1 -0
- package/dist/bop-sdk/interface/test/ledger.test.d.ts +1 -0
- package/dist/bop-sdk/interface/test/ledger.test.js +167 -0
- package/dist/bop-sdk/interface/test/ledger.test.js.map +1 -0
- package/dist/bop-sdk/interface/test/provider.test.d.ts +1 -0
- package/dist/bop-sdk/interface/test/provider.test.js +295 -0
- package/dist/bop-sdk/interface/test/provider.test.js.map +1 -0
- package/dist/bop-sdk/interface/test/signer.test.d.ts +1 -0
- package/dist/bop-sdk/interface/test/signer.test.js +87 -0
- package/dist/bop-sdk/interface/test/signer.test.js.map +1 -0
- package/dist/bop-sdk/interface/test/transaction.test.d.ts +1 -0
- package/dist/bop-sdk/interface/test/transaction.test.js +663 -0
- package/dist/bop-sdk/interface/test/transaction.test.js.map +1 -0
- package/dist/bop-sdk/proto/bop-sdk-common.d.ts +225 -0
- package/dist/bop-sdk/proto/bop-sdk-common.js +831 -0
- package/dist/bop-sdk/proto/bop-sdk-common.js.map +1 -0
- package/dist/bop-sdk/proto/bop-sdk-interface.d.ts +623 -0
- package/dist/bop-sdk/proto/bop-sdk-interface.js +8623 -0
- package/dist/bop-sdk/proto/bop-sdk-interface.js.map +1 -0
- package/dist/bop-sdk/proto/bop-sdk-utils.d.ts +107 -0
- package/dist/bop-sdk/proto/bop-sdk-utils.js +1160 -0
- package/dist/bop-sdk/proto/bop-sdk-utils.js.map +1 -0
- package/dist/bop-sdk/utils/abi/abi-coder.d.ts +16 -0
- package/dist/bop-sdk/utils/abi/abi-coder.js +101 -0
- package/dist/bop-sdk/utils/abi/abi-coder.js.map +1 -0
- package/dist/bop-sdk/utils/abi/address.d.ts +8 -0
- package/dist/bop-sdk/utils/abi/address.js +116 -0
- package/dist/bop-sdk/utils/abi/address.js.map +1 -0
- package/dist/bop-sdk/utils/abi/bignumber.d.ts +39 -0
- package/dist/bop-sdk/utils/abi/bignumber.js +316 -0
- package/dist/bop-sdk/utils/abi/bignumber.js.map +1 -0
- package/dist/bop-sdk/utils/abi/bytes.d.ts +41 -0
- package/dist/bop-sdk/utils/abi/bytes.js +423 -0
- package/dist/bop-sdk/utils/abi/bytes.js.map +1 -0
- package/dist/bop-sdk/utils/abi/coders/abstract-coder.d.ts +52 -0
- package/dist/bop-sdk/utils/abi/coders/abstract-coder.js +164 -0
- package/dist/bop-sdk/utils/abi/coders/abstract-coder.js.map +1 -0
- package/dist/bop-sdk/utils/abi/coders/address.d.ts +7 -0
- package/dist/bop-sdk/utils/abi/coders/address.js +52 -0
- package/dist/bop-sdk/utils/abi/coders/address.js.map +1 -0
- package/dist/bop-sdk/utils/abi/coders/anonymous.d.ts +8 -0
- package/dist/bop-sdk/utils/abi/coders/anonymous.js +22 -0
- package/dist/bop-sdk/utils/abi/coders/anonymous.js.map +1 -0
- package/dist/bop-sdk/utils/abi/coders/array.d.ts +13 -0
- package/dist/bop-sdk/utils/abi/coders/array.js +220 -0
- package/dist/bop-sdk/utils/abi/coders/array.js.map +1 -0
- package/dist/bop-sdk/utils/abi/coders/boolean.d.ts +7 -0
- package/dist/bop-sdk/utils/abi/coders/boolean.js +20 -0
- package/dist/bop-sdk/utils/abi/coders/boolean.js.map +1 -0
- package/dist/bop-sdk/utils/abi/coders/bytes.d.ts +11 -0
- package/dist/bop-sdk/utils/abi/coders/bytes.js +33 -0
- package/dist/bop-sdk/utils/abi/coders/bytes.js.map +1 -0
- package/dist/bop-sdk/utils/abi/coders/fixed-bytes.d.ts +9 -0
- package/dist/bop-sdk/utils/abi/coders/fixed-bytes.js +28 -0
- package/dist/bop-sdk/utils/abi/coders/fixed-bytes.js.map +1 -0
- package/dist/bop-sdk/utils/abi/coders/null.d.ts +7 -0
- package/dist/bop-sdk/utils/abi/coders/null.js +24 -0
- package/dist/bop-sdk/utils/abi/coders/null.js.map +1 -0
- package/dist/bop-sdk/utils/abi/coders/number.d.ts +10 -0
- package/dist/bop-sdk/utils/abi/coders/number.js +45 -0
- package/dist/bop-sdk/utils/abi/coders/number.js.map +1 -0
- package/dist/bop-sdk/utils/abi/coders/string.d.ts +8 -0
- package/dist/bop-sdk/utils/abi/coders/string.js +21 -0
- package/dist/bop-sdk/utils/abi/coders/string.js.map +1 -0
- package/dist/bop-sdk/utils/abi/coders/tuple.d.ts +10 -0
- package/dist/bop-sdk/utils/abi/coders/tuple.js +60 -0
- package/dist/bop-sdk/utils/abi/coders/tuple.js.map +1 -0
- package/dist/bop-sdk/utils/abi/constants/addresses.d.ts +1 -0
- package/dist/bop-sdk/utils/abi/constants/addresses.js +5 -0
- package/dist/bop-sdk/utils/abi/constants/addresses.js.map +1 -0
- package/dist/bop-sdk/utils/abi/constants/bignumbers.d.ts +10 -0
- package/dist/bop-sdk/utils/abi/constants/bignumbers.js +21 -0
- package/dist/bop-sdk/utils/abi/constants/bignumbers.js.map +1 -0
- package/dist/bop-sdk/utils/abi/constants/hashes.d.ts +1 -0
- package/dist/bop-sdk/utils/abi/constants/hashes.js +5 -0
- package/dist/bop-sdk/utils/abi/constants/hashes.js.map +1 -0
- package/dist/bop-sdk/utils/abi/constants/index.d.ts +4 -0
- package/dist/bop-sdk/utils/abi/constants/index.js +19 -0
- package/dist/bop-sdk/utils/abi/constants/index.js.map +1 -0
- package/dist/bop-sdk/utils/abi/constants/strings.d.ts +1 -0
- package/dist/bop-sdk/utils/abi/constants/strings.js +6 -0
- package/dist/bop-sdk/utils/abi/constants/strings.js.map +1 -0
- package/dist/bop-sdk/utils/abi/fragments.d.ts +84 -0
- package/dist/bop-sdk/utils/abi/fragments.js +919 -0
- package/dist/bop-sdk/utils/abi/fragments.js.map +1 -0
- package/dist/bop-sdk/utils/abi/id.d.ts +1 -0
- package/dist/bop-sdk/utils/abi/id.js +10 -0
- package/dist/bop-sdk/utils/abi/id.js.map +1 -0
- package/dist/bop-sdk/utils/abi/index.d.ts +4 -0
- package/dist/bop-sdk/utils/abi/index.js +21 -0
- package/dist/bop-sdk/utils/abi/index.js.map +1 -0
- package/dist/bop-sdk/utils/abi/interface.d.ts +83 -0
- package/dist/bop-sdk/utils/abi/interface.js +663 -0
- package/dist/bop-sdk/utils/abi/interface.js.map +1 -0
- package/dist/bop-sdk/utils/abi/keccak256.d.ts +2 -0
- package/dist/bop-sdk/utils/abi/keccak256.js +13 -0
- package/dist/bop-sdk/utils/abi/keccak256.js.map +1 -0
- package/dist/bop-sdk/utils/abi/properties.d.ts +16 -0
- package/dist/bop-sdk/utils/abi/properties.js +141 -0
- package/dist/bop-sdk/utils/abi/properties.js.map +1 -0
- package/dist/bop-sdk/utils/abi/strings/bytes32.d.ts +3 -0
- package/dist/bop-sdk/utils/abi/strings/bytes32.js +36 -0
- package/dist/bop-sdk/utils/abi/strings/bytes32.js.map +1 -0
- package/dist/bop-sdk/utils/abi/strings/idna.d.ts +4 -0
- package/dist/bop-sdk/utils/abi/strings/idna.js +200 -0
- package/dist/bop-sdk/utils/abi/strings/idna.js.map +1 -0
- package/dist/bop-sdk/utils/abi/strings/index.d.ts +4 -0
- package/dist/bop-sdk/utils/abi/strings/index.js +17 -0
- package/dist/bop-sdk/utils/abi/strings/index.js.map +1 -0
- package/dist/bop-sdk/utils/abi/strings/utf8.d.ts +26 -0
- package/dist/bop-sdk/utils/abi/strings/utf8.js +265 -0
- package/dist/bop-sdk/utils/abi/strings/utf8.js.map +1 -0
- package/dist/bop-sdk/utils/encryption-address.d.ts +25 -0
- package/dist/bop-sdk/utils/encryption-address.js +426 -0
- package/dist/bop-sdk/utils/encryption-address.js.map +1 -0
- package/dist/bop-sdk/utils/encryption-crypto.d.ts +16 -0
- package/dist/bop-sdk/utils/encryption-crypto.js +406 -0
- package/dist/bop-sdk/utils/encryption-crypto.js.map +1 -0
- package/dist/bop-sdk/utils/encryption-mnemonics.d.ts +7 -0
- package/dist/bop-sdk/utils/encryption-mnemonics.js +129 -0
- package/dist/bop-sdk/utils/encryption-mnemonics.js.map +1 -0
- package/dist/bop-sdk/utils/index.d.ts +13 -0
- package/dist/bop-sdk/utils/index.js +22 -0
- package/dist/bop-sdk/utils/index.js.map +1 -0
- package/dist/bop-sdk/utils/logger.d.ts +52 -0
- package/dist/bop-sdk/utils/logger.js +377 -0
- package/dist/bop-sdk/utils/logger.js.map +1 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +18 -0
- package/dist/index.js.map +1 -0
- package/package.json +92 -88
- package/tsconfig.json +24 -0
|
@@ -0,0 +1,663 @@
|
|
|
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 __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
26
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
27
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
28
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
29
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
30
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
31
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
32
|
+
});
|
|
33
|
+
};
|
|
34
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
35
|
+
const transaction_1 = require("../service/transaction");
|
|
36
|
+
const chai_1 = require("chai");
|
|
37
|
+
const sinon = __importStar(require("sinon"));
|
|
38
|
+
const bop_base_1 = require("../../../bop/bop-base");
|
|
39
|
+
const bop_sdk_interface_1 = require("../../proto/bop-sdk-interface");
|
|
40
|
+
const signer_1 = require("../signer");
|
|
41
|
+
const provider_1 = require("../provider");
|
|
42
|
+
// 使用 Sinon 创建模拟对象
|
|
43
|
+
const sandbox = sinon.createSandbox();
|
|
44
|
+
const apiKey = "xxx";
|
|
45
|
+
const apiSecret = "xxx";
|
|
46
|
+
describe("provider-transaction-test", () => {
|
|
47
|
+
let transaction;
|
|
48
|
+
let bopInterface;
|
|
49
|
+
let config;
|
|
50
|
+
let signer;
|
|
51
|
+
let signer2;
|
|
52
|
+
let provider;
|
|
53
|
+
beforeEach(() => {
|
|
54
|
+
config = new bop_base_1.Config("https://bif-mainnet.bitfactory.cn", apiKey, apiSecret);
|
|
55
|
+
bopInterface = new bop_base_1.BopInterface(config);
|
|
56
|
+
transaction = new transaction_1.TransactionByBop(bopInterface);
|
|
57
|
+
signer = new signer_1.SignerByBop("your encprivate key");
|
|
58
|
+
signer2 = new signer_1.SignerByBop("your encprivate key");
|
|
59
|
+
provider = new provider_1.ProviderByBop(bopInterface);
|
|
60
|
+
});
|
|
61
|
+
afterEach(() => {
|
|
62
|
+
// 重置模拟对象
|
|
63
|
+
sandbox.restore();
|
|
64
|
+
});
|
|
65
|
+
describe("transaction test", () => {
|
|
66
|
+
it("transaction.getTxPoolSize", () => __awaiter(void 0, void 0, void 0, function* () {
|
|
67
|
+
let response;
|
|
68
|
+
response = yield transaction.getTxPoolSize();
|
|
69
|
+
console.log(response);
|
|
70
|
+
(0, chai_1.expect)(response.errorCode).to.equal(0);
|
|
71
|
+
(0, chai_1.expect)(response.errorDesc).to.equal("ok");
|
|
72
|
+
}));
|
|
73
|
+
it("transaction.getTransactionHistory none params", () => __awaiter(void 0, void 0, void 0, function* () {
|
|
74
|
+
var _a;
|
|
75
|
+
let response;
|
|
76
|
+
response = yield transaction.getTransactionHistory();
|
|
77
|
+
console.log(response);
|
|
78
|
+
(0, chai_1.expect)(response.errorCode).to.equal(0);
|
|
79
|
+
(0, chai_1.expect)(response.errorDesc).to.equal("ok");
|
|
80
|
+
(0, chai_1.expect)((_a = response.result) === null || _a === void 0 ? void 0 : _a.totalCount).to.equal(100);
|
|
81
|
+
}));
|
|
82
|
+
it("transaction.getTransactionHistory with exist hash", () => __awaiter(void 0, void 0, void 0, function* () {
|
|
83
|
+
var _b, _c, _d, _e, _f, _g;
|
|
84
|
+
let response;
|
|
85
|
+
response = yield transaction.getTransactionHistory(undefined, undefined, undefined, "b5cef0860f6000cdfb4fa0d2dc95a013632032a49764ade7c1d972a493307315");
|
|
86
|
+
console.log(response);
|
|
87
|
+
console.log(JSON.stringify(bop_sdk_interface_1.GetTransactionHistoryResponse.toJSON(response)));
|
|
88
|
+
(0, chai_1.expect)(response.errorCode).to.equal(0);
|
|
89
|
+
(0, chai_1.expect)(response.errorDesc).to.equal("ok");
|
|
90
|
+
(0, chai_1.expect)((_b = response.result) === null || _b === void 0 ? void 0 : _b.totalCount).to.equal(1);
|
|
91
|
+
(0, chai_1.expect)((_g = (_f = (_e = (_d = (_c = response.result) === null || _c === void 0 ? void 0 : _c.transactions[0]) === null || _d === void 0 ? void 0 : _d.transaction) === null || _e === void 0 ? void 0 : _e.operations[0]) === null || _f === void 0 ? void 0 : _f.log) === null || _g === void 0 ? void 0 : _g.datas[0]).to.equal("080110641a286469643a6269643a65664765486467643141776d746755424b616333624771726d506f4e6841316b2a5618b1432802324f4661696c656420746f207375626d6974206c61796572322073746174652c206c617965723220736571283836323529206973206e6f7420657175616c206d617820736571283836323529202b20312e");
|
|
92
|
+
}));
|
|
93
|
+
it("transaction.getTransactionHistory with not exist hash", () => __awaiter(void 0, void 0, void 0, function* () {
|
|
94
|
+
let response;
|
|
95
|
+
response = yield transaction.getTransactionHistory(undefined, undefined, undefined, "xxx");
|
|
96
|
+
console.log(response);
|
|
97
|
+
console.log(JSON.stringify(bop_sdk_interface_1.GetTransactionHistoryResponse.toJSON(response)));
|
|
98
|
+
(0, chai_1.expect)(response.errorCode).to.equal(4);
|
|
99
|
+
}));
|
|
100
|
+
it("transaction.getTransactionHistory with seq", () => __awaiter(void 0, void 0, void 0, function* () {
|
|
101
|
+
var _h;
|
|
102
|
+
let response;
|
|
103
|
+
response = yield transaction.getTransactionHistory(5845093);
|
|
104
|
+
console.log(response);
|
|
105
|
+
console.log(JSON.stringify(bop_sdk_interface_1.GetTransactionHistoryResponse.toJSON(response)));
|
|
106
|
+
(0, chai_1.expect)(response.errorCode).to.equal(0);
|
|
107
|
+
(0, chai_1.expect)(response.errorDesc).to.equal("ok");
|
|
108
|
+
(0, chai_1.expect)((_h = response.result) === null || _h === void 0 ? void 0 : _h.totalCount).to.equal(2);
|
|
109
|
+
}));
|
|
110
|
+
it("transaction.getTransactionHistory with seq and start & limit", () => __awaiter(void 0, void 0, void 0, function* () {
|
|
111
|
+
var _j;
|
|
112
|
+
let response;
|
|
113
|
+
response = yield transaction.getTransactionHistory(5845093, 0, 1);
|
|
114
|
+
console.log(response);
|
|
115
|
+
console.log(JSON.stringify(bop_sdk_interface_1.GetTransactionHistoryResponse.toJSON(response)));
|
|
116
|
+
(0, chai_1.expect)(response.errorCode).to.equal(0);
|
|
117
|
+
(0, chai_1.expect)(response.errorDesc).to.equal("ok");
|
|
118
|
+
(0, chai_1.expect)((_j = response.result) === null || _j === void 0 ? void 0 : _j.totalCount).to.equal(2);
|
|
119
|
+
}));
|
|
120
|
+
it("transaction.getTransactionHistory with seq and default start", () => __awaiter(void 0, void 0, void 0, function* () {
|
|
121
|
+
var _k;
|
|
122
|
+
let response;
|
|
123
|
+
response = yield transaction.getTransactionHistory(5845093);
|
|
124
|
+
console.log(response);
|
|
125
|
+
console.log(JSON.stringify(bop_sdk_interface_1.GetTransactionHistoryResponse.toJSON(response)));
|
|
126
|
+
(0, chai_1.expect)(response.errorCode).to.equal(0);
|
|
127
|
+
(0, chai_1.expect)(response.errorDesc).to.equal("ok");
|
|
128
|
+
(0, chai_1.expect)((_k = response.result) === null || _k === void 0 ? void 0 : _k.totalCount).to.equal(2);
|
|
129
|
+
}));
|
|
130
|
+
it("transaction.getTransactionHistory with seq and hash", () => __awaiter(void 0, void 0, void 0, function* () {
|
|
131
|
+
var _l;
|
|
132
|
+
let response;
|
|
133
|
+
response = yield transaction.getTransactionHistory(5845127, undefined, undefined, "7370f1759c37f09268d72019c006b6167392d21186e11b0bd098148ac8f34479");
|
|
134
|
+
console.log(response);
|
|
135
|
+
console.log(JSON.stringify(bop_sdk_interface_1.GetTransactionHistoryResponse.toJSON(response)));
|
|
136
|
+
(0, chai_1.expect)(response.errorCode).to.equal(0);
|
|
137
|
+
(0, chai_1.expect)(response.errorDesc).to.equal("ok");
|
|
138
|
+
(0, chai_1.expect)((_l = response.result) === null || _l === void 0 ? void 0 : _l.totalCount).to.equal(2);
|
|
139
|
+
}));
|
|
140
|
+
it("transaction.getTransactionHistory with hash empty", () => __awaiter(void 0, void 0, void 0, function* () {
|
|
141
|
+
let response;
|
|
142
|
+
response = yield transaction.getTransactionHistory(undefined, undefined, undefined, "");
|
|
143
|
+
console.log(response);
|
|
144
|
+
(0, chai_1.expect)(response.errorCode).to.equal(0);
|
|
145
|
+
}));
|
|
146
|
+
it("transaction.getTransactionHistory with hash invalid", () => __awaiter(void 0, void 0, void 0, function* () {
|
|
147
|
+
let response;
|
|
148
|
+
response = yield transaction.getTransactionHistory(undefined, undefined, undefined, "xxx");
|
|
149
|
+
console.log(response);
|
|
150
|
+
(0, chai_1.expect)(response.errorCode).to.equal(4);
|
|
151
|
+
}));
|
|
152
|
+
it("transaction.getTransactionHistory with ledgerseq 0", () => __awaiter(void 0, void 0, void 0, function* () {
|
|
153
|
+
let response;
|
|
154
|
+
response = yield transaction.getTransactionHistory(0);
|
|
155
|
+
console.log(response);
|
|
156
|
+
(0, chai_1.expect)(response.errorCode).to.equal(4);
|
|
157
|
+
}));
|
|
158
|
+
it("transaction.getTransactionHistory with ledgerseq negative", () => __awaiter(void 0, void 0, void 0, function* () {
|
|
159
|
+
let response;
|
|
160
|
+
response = yield transaction.getTransactionHistory(-1);
|
|
161
|
+
console.log(response);
|
|
162
|
+
(0, chai_1.expect)(response.errorCode).to.equal(4);
|
|
163
|
+
}));
|
|
164
|
+
it("transaction.getTransactionHistory with ledgerseq more than max", () => __awaiter(void 0, void 0, void 0, function* () {
|
|
165
|
+
let response;
|
|
166
|
+
response = yield transaction.getTransactionHistory(9999999999999);
|
|
167
|
+
console.log(response);
|
|
168
|
+
(0, chai_1.expect)(response.errorCode).to.equal(4);
|
|
169
|
+
}));
|
|
170
|
+
it("transaction.getTransactionHistory with start 0", () => __awaiter(void 0, void 0, void 0, function* () {
|
|
171
|
+
let response;
|
|
172
|
+
response = yield transaction.getTransactionHistory(undefined, 0);
|
|
173
|
+
console.log(response);
|
|
174
|
+
(0, chai_1.expect)(response.errorCode).to.equal(0);
|
|
175
|
+
}));
|
|
176
|
+
it("transaction.getTransactionHistory with start negative", () => __awaiter(void 0, void 0, void 0, function* () {
|
|
177
|
+
let response;
|
|
178
|
+
response = yield transaction.getTransactionHistory(undefined, -1);
|
|
179
|
+
console.log(response);
|
|
180
|
+
(0, chai_1.expect)(response.errorCode).to.equal(0);
|
|
181
|
+
}));
|
|
182
|
+
it("transaction.getTransactionHistory with start more than max", () => __awaiter(void 0, void 0, void 0, function* () {
|
|
183
|
+
let response;
|
|
184
|
+
response = yield transaction.getTransactionHistory(undefined, 9999999999999);
|
|
185
|
+
console.log(response);
|
|
186
|
+
(0, chai_1.expect)(response.errorCode).to.equal(0);
|
|
187
|
+
}));
|
|
188
|
+
it("transaction.getTransactionHistory with limit 0", () => __awaiter(void 0, void 0, void 0, function* () {
|
|
189
|
+
let response;
|
|
190
|
+
response = yield transaction.getTransactionHistory(undefined, undefined, 0);
|
|
191
|
+
console.log(response);
|
|
192
|
+
(0, chai_1.expect)(response.errorCode).to.equal(0);
|
|
193
|
+
}));
|
|
194
|
+
it("transaction.getTransactionHistory with limit negative", () => __awaiter(void 0, void 0, void 0, function* () {
|
|
195
|
+
let response;
|
|
196
|
+
response = yield transaction.getTransactionHistory(undefined, undefined, -1);
|
|
197
|
+
console.log(response);
|
|
198
|
+
(0, chai_1.expect)(response.errorCode).to.equal(0);
|
|
199
|
+
}));
|
|
200
|
+
it("transaction.getTransactionHistory with limit more than max", () => __awaiter(void 0, void 0, void 0, function* () {
|
|
201
|
+
let response;
|
|
202
|
+
response = yield transaction.getTransactionHistory(undefined, undefined, 9999999999999);
|
|
203
|
+
console.log(response);
|
|
204
|
+
(0, chai_1.expect)(response.errorCode).to.equal(0);
|
|
205
|
+
}));
|
|
206
|
+
it("transaction.getTxPoolTransactions", () => __awaiter(void 0, void 0, void 0, function* () {
|
|
207
|
+
{
|
|
208
|
+
let request = {
|
|
209
|
+
params: {
|
|
210
|
+
nonceType: bop_sdk_interface_1.TxType.INCREASE_NONCE,
|
|
211
|
+
gasPrice: 1,
|
|
212
|
+
feeLimit: 10000,
|
|
213
|
+
remarks: "test",
|
|
214
|
+
},
|
|
215
|
+
destAddress: "did:bid:ef27sVwzEMTEUwC1E1ivQmzEccsphtac7",
|
|
216
|
+
amount: 1,
|
|
217
|
+
};
|
|
218
|
+
let signerWithProvider = signer.connect(provider);
|
|
219
|
+
let response;
|
|
220
|
+
response = yield transaction.buildGasSendTx(request, [
|
|
221
|
+
signerWithProvider,
|
|
222
|
+
]);
|
|
223
|
+
console.log(response);
|
|
224
|
+
(0, chai_1.expect)(response.errorCode).to.equal(0);
|
|
225
|
+
let subresponse;
|
|
226
|
+
subresponse = yield transaction.submitTransaction({
|
|
227
|
+
items: [response.result],
|
|
228
|
+
});
|
|
229
|
+
console.log(subresponse);
|
|
230
|
+
}
|
|
231
|
+
let response;
|
|
232
|
+
response = yield transaction.getTxPoolTransactions(0);
|
|
233
|
+
console.log(JSON.stringify(response));
|
|
234
|
+
(0, chai_1.expect)(response.errorCode).to.equal(4);
|
|
235
|
+
(0, chai_1.expect)(response.errorDesc).to.equal("The object does not exist, such as not being able to query accounts, TX, blocks, etc");
|
|
236
|
+
}));
|
|
237
|
+
it("transaction.buildAccountCreateTx", () => __awaiter(void 0, void 0, void 0, function* () {
|
|
238
|
+
let request = {
|
|
239
|
+
params: {
|
|
240
|
+
nonceType: bop_sdk_interface_1.TxType.INCREASE_NONCE,
|
|
241
|
+
gasPrice: 1,
|
|
242
|
+
feeLimit: 1000,
|
|
243
|
+
remarks: "",
|
|
244
|
+
},
|
|
245
|
+
destAddress: "did:bid:ef26vF64vKMTGM2uCGERVXJNAobFTm7wY",
|
|
246
|
+
amount: 1,
|
|
247
|
+
};
|
|
248
|
+
console.log(request);
|
|
249
|
+
let signerWithProvider = signer.connect(provider);
|
|
250
|
+
let response;
|
|
251
|
+
response = yield transaction.buildAccountCreateTx(request, [
|
|
252
|
+
signerWithProvider,
|
|
253
|
+
]);
|
|
254
|
+
console.log(response);
|
|
255
|
+
(0, chai_1.expect)(response.errorCode).to.equal(0);
|
|
256
|
+
let subresponse;
|
|
257
|
+
subresponse = yield transaction.submitTransaction({
|
|
258
|
+
items: [response.result],
|
|
259
|
+
});
|
|
260
|
+
console.log(subresponse);
|
|
261
|
+
}));
|
|
262
|
+
it("transaction.buildGasSendTx", () => __awaiter(void 0, void 0, void 0, function* () {
|
|
263
|
+
let request = {
|
|
264
|
+
params: {
|
|
265
|
+
nonceType: bop_sdk_interface_1.TxType.INCREASE_NONCE,
|
|
266
|
+
gasPrice: 1,
|
|
267
|
+
feeLimit: 10000,
|
|
268
|
+
remarks: "test",
|
|
269
|
+
},
|
|
270
|
+
destAddress: "did:bid:ef27sVwzEMTEUwC1E1ivQmzEccsphtac7",
|
|
271
|
+
amount: 1,
|
|
272
|
+
};
|
|
273
|
+
let signerWithProvider = signer.connect(provider);
|
|
274
|
+
let response;
|
|
275
|
+
response = yield transaction.buildGasSendTx(request, [
|
|
276
|
+
signerWithProvider,
|
|
277
|
+
]);
|
|
278
|
+
console.log(response);
|
|
279
|
+
(0, chai_1.expect)(response.errorCode).to.equal(0);
|
|
280
|
+
let subresponse;
|
|
281
|
+
subresponse = yield transaction.submitTransaction({
|
|
282
|
+
items: [response.result],
|
|
283
|
+
});
|
|
284
|
+
console.log(subresponse);
|
|
285
|
+
}));
|
|
286
|
+
it("transaction.buildContractCreateTx solidity", () => __awaiter(void 0, void 0, void 0, function* () {
|
|
287
|
+
let request = {
|
|
288
|
+
params: {
|
|
289
|
+
nonceType: bop_sdk_interface_1.TxType.INCREASE_NONCE,
|
|
290
|
+
gasPrice: 1,
|
|
291
|
+
feeLimit: 10000000,
|
|
292
|
+
remarks: "test",
|
|
293
|
+
},
|
|
294
|
+
initBalance: 1,
|
|
295
|
+
type: bop_sdk_interface_1.ContractType.EVM,
|
|
296
|
+
payload: "608060405234801561000f575f80fd5b5061019a8061001d5f395ff3fe608060405234801561000f575f80fd5b5060043610610034575f3560e01c80632e64cec1146100385780636057361d14610056575b5f80fd5b610040610072565b60405161004d91906100d2565b60405180910390f35b610070600480360381019061006b9190610119565b61007a565b005b5f8054905090565b805f819055507f23b3e9cfb15bae93d147362e55f22b745d66a37405bece55b6bfbdb35a0fb060816040516100af91906100d2565b60405180910390a150565b5f819050919050565b6100cc816100ba565b82525050565b5f6020820190506100e55f8301846100c3565b92915050565b5f80fd5b6100f8816100ba565b8114610102575f80fd5b50565b5f81359050610113816100ef565b92915050565b5f6020828403121561012e5761012d6100eb565b5b5f61013b84828501610105565b9150509291505056fea2646970667358221220bb054df7a684290d3dceeca77407e3f5a111ba0b1ef00e88956c5e4f2f970ca664736f6c637822302e382e32312d63692e323032342e332e312b636f6d6d69742e31383065353661320053",
|
|
297
|
+
initInput: "",
|
|
298
|
+
};
|
|
299
|
+
console.log(request);
|
|
300
|
+
let signerWithProvider = signer.connect(provider);
|
|
301
|
+
let response;
|
|
302
|
+
response = yield transaction.buildContractCreateTx(request, [
|
|
303
|
+
signerWithProvider,
|
|
304
|
+
]);
|
|
305
|
+
console.log(response);
|
|
306
|
+
(0, chai_1.expect)(response.errorCode).to.equal(0);
|
|
307
|
+
let subresponse;
|
|
308
|
+
subresponse = yield transaction.submitTransaction({
|
|
309
|
+
items: [response.result],
|
|
310
|
+
});
|
|
311
|
+
console.log(subresponse);
|
|
312
|
+
}));
|
|
313
|
+
it("transaction.buildContractCreateTx javascript", () => __awaiter(void 0, void 0, void 0, function* () {
|
|
314
|
+
let request = {
|
|
315
|
+
params: {
|
|
316
|
+
nonceType: bop_sdk_interface_1.TxType.INCREASE_NONCE,
|
|
317
|
+
gasPrice: 1,
|
|
318
|
+
feeLimit: 10000000,
|
|
319
|
+
remarks: "test",
|
|
320
|
+
},
|
|
321
|
+
initBalance: 1,
|
|
322
|
+
type: bop_sdk_interface_1.ContractType.JAVASCRIPT,
|
|
323
|
+
payload: "'use strict';function init(input){return;}function main(input){let para=JSON.parse(input);if(para.do_foo){let x={'hello':'world'};}}function query(input){return input;}",
|
|
324
|
+
initInput: "",
|
|
325
|
+
};
|
|
326
|
+
console.log(request);
|
|
327
|
+
let signerWithProvider = signer.connect(provider);
|
|
328
|
+
let response;
|
|
329
|
+
response = yield transaction.buildContractCreateTx(request, [
|
|
330
|
+
signerWithProvider,
|
|
331
|
+
]);
|
|
332
|
+
console.log(response);
|
|
333
|
+
(0, chai_1.expect)(response.errorCode).to.equal(0);
|
|
334
|
+
let subresponse;
|
|
335
|
+
subresponse = yield transaction.submitTransaction({
|
|
336
|
+
items: [response.result],
|
|
337
|
+
});
|
|
338
|
+
console.log(subresponse);
|
|
339
|
+
}));
|
|
340
|
+
it("transaction.buildContractInvokeTx solidity", () => __awaiter(void 0, void 0, void 0, function* () {
|
|
341
|
+
let request = {
|
|
342
|
+
params: {
|
|
343
|
+
nonceType: bop_sdk_interface_1.TxType.INCREASE_NONCE,
|
|
344
|
+
gasPrice: 1,
|
|
345
|
+
feeLimit: 100000,
|
|
346
|
+
remarks: "test",
|
|
347
|
+
},
|
|
348
|
+
contractAddress: "did:bid:efhj9cgStGJckhLwHZefYS9Yje38NVuP",
|
|
349
|
+
input: '{"function":"store(uint256)","args":"1"}',
|
|
350
|
+
amount: 0,
|
|
351
|
+
};
|
|
352
|
+
console.log(request);
|
|
353
|
+
let signerWithProvider = signer.connect(provider);
|
|
354
|
+
let response;
|
|
355
|
+
response = yield transaction.buildContractInvokeTx(request, [
|
|
356
|
+
signerWithProvider,
|
|
357
|
+
]);
|
|
358
|
+
console.log(response);
|
|
359
|
+
(0, chai_1.expect)(response.errorCode).to.equal(0);
|
|
360
|
+
let subresponse;
|
|
361
|
+
subresponse = yield transaction.submitTransaction({
|
|
362
|
+
items: [response.result],
|
|
363
|
+
});
|
|
364
|
+
console.log(subresponse);
|
|
365
|
+
}));
|
|
366
|
+
it("transaction.buildContractInvokeTx javascript", () => __awaiter(void 0, void 0, void 0, function* () {
|
|
367
|
+
let request = {
|
|
368
|
+
params: {
|
|
369
|
+
nonceType: bop_sdk_interface_1.TxType.INCREASE_NONCE,
|
|
370
|
+
gasPrice: 1,
|
|
371
|
+
feeLimit: 10000,
|
|
372
|
+
remarks: "test",
|
|
373
|
+
},
|
|
374
|
+
contractAddress: "did:bid:eftf3aqGEQE4ANLj6U13GKqu4pzUSj2U",
|
|
375
|
+
input: '{"method":"getsuperlist"}',
|
|
376
|
+
amount: 1,
|
|
377
|
+
};
|
|
378
|
+
console.log(request);
|
|
379
|
+
let signerWithProvider = signer.connect(provider);
|
|
380
|
+
let response;
|
|
381
|
+
response = yield transaction.buildContractInvokeTx(request, [
|
|
382
|
+
signerWithProvider,
|
|
383
|
+
]);
|
|
384
|
+
console.log(response);
|
|
385
|
+
(0, chai_1.expect)(response.errorCode).to.equal(0);
|
|
386
|
+
let subresponse;
|
|
387
|
+
subresponse = yield transaction.submitTransaction({
|
|
388
|
+
items: [response.result],
|
|
389
|
+
});
|
|
390
|
+
console.log(subresponse);
|
|
391
|
+
}));
|
|
392
|
+
it("transaction.buildSetMetadataTx", () => __awaiter(void 0, void 0, void 0, function* () {
|
|
393
|
+
let request = {
|
|
394
|
+
params: {
|
|
395
|
+
nonceType: bop_sdk_interface_1.TxType.INCREASE_NONCE,
|
|
396
|
+
gasPrice: 1,
|
|
397
|
+
feeLimit: 10000,
|
|
398
|
+
remarks: "test",
|
|
399
|
+
},
|
|
400
|
+
key: "A",
|
|
401
|
+
value: "C",
|
|
402
|
+
version: 1,
|
|
403
|
+
};
|
|
404
|
+
console.log(request);
|
|
405
|
+
let signerWithProvider = signer.connect(provider);
|
|
406
|
+
let response;
|
|
407
|
+
response = yield transaction.buildSetMetadataTx(request, [
|
|
408
|
+
signerWithProvider,
|
|
409
|
+
]);
|
|
410
|
+
console.log(response);
|
|
411
|
+
(0, chai_1.expect)(response.errorCode).to.equal(0);
|
|
412
|
+
let subresponse;
|
|
413
|
+
subresponse = yield transaction.submitTransaction({
|
|
414
|
+
items: [response.result],
|
|
415
|
+
});
|
|
416
|
+
console.log(subresponse);
|
|
417
|
+
}));
|
|
418
|
+
it("transaction.buildSetPrivilegeTx", () => __awaiter(void 0, void 0, void 0, function* () {
|
|
419
|
+
let request = {
|
|
420
|
+
params: {
|
|
421
|
+
nonceType: bop_sdk_interface_1.TxType.INCREASE_NONCE,
|
|
422
|
+
gasPrice: 1,
|
|
423
|
+
feeLimit: 10000,
|
|
424
|
+
remarks: "test",
|
|
425
|
+
},
|
|
426
|
+
masterWeight: "1",
|
|
427
|
+
signers: [
|
|
428
|
+
{
|
|
429
|
+
address: "did:bid:efsdhXX7bNYxeYYVasatAi7DPE4nM3Lb",
|
|
430
|
+
weight: 1,
|
|
431
|
+
},
|
|
432
|
+
],
|
|
433
|
+
txThreshold: "1",
|
|
434
|
+
typeThresholds: [
|
|
435
|
+
{
|
|
436
|
+
type: bop_sdk_interface_1.OperationTypeThreshold_Type.CREATE_ACCOUNT,
|
|
437
|
+
threshold: 1,
|
|
438
|
+
},
|
|
439
|
+
],
|
|
440
|
+
};
|
|
441
|
+
console.log(request);
|
|
442
|
+
let signerWithProvider = signer.connect(provider);
|
|
443
|
+
let response;
|
|
444
|
+
response = yield transaction.buildSetPrivilegeTx(request, [
|
|
445
|
+
signerWithProvider,
|
|
446
|
+
]);
|
|
447
|
+
console.log(response);
|
|
448
|
+
(0, chai_1.expect)(response.errorCode).to.equal(0);
|
|
449
|
+
let subresponse;
|
|
450
|
+
subresponse = yield transaction.submitTransaction({
|
|
451
|
+
items: [response.result],
|
|
452
|
+
});
|
|
453
|
+
console.log(subresponse);
|
|
454
|
+
}));
|
|
455
|
+
it("transaction.buildBatchGasSend", () => __awaiter(void 0, void 0, void 0, function* () {
|
|
456
|
+
let request = {
|
|
457
|
+
base: {
|
|
458
|
+
nonceType: bop_sdk_interface_1.TxType.INCREASE_NONCE,
|
|
459
|
+
gasPrice: 1,
|
|
460
|
+
feeLimit: 10000,
|
|
461
|
+
remarks: "test",
|
|
462
|
+
},
|
|
463
|
+
params: [
|
|
464
|
+
{
|
|
465
|
+
destAddress: "did:bid:zfkeY37hHn2HGSeUpEdWuH76aJbkoX6H",
|
|
466
|
+
amount: -1,
|
|
467
|
+
},
|
|
468
|
+
{
|
|
469
|
+
destAddress: "did:bid:zfkeY37hHn2HGSeUpEdWuH76aJbkoX6H",
|
|
470
|
+
amount: 1,
|
|
471
|
+
},
|
|
472
|
+
],
|
|
473
|
+
};
|
|
474
|
+
console.log(request);
|
|
475
|
+
let signerWithProvider = signer.connect(provider);
|
|
476
|
+
let response;
|
|
477
|
+
response = yield transaction.buildBatchGasSend(request, [
|
|
478
|
+
signerWithProvider,
|
|
479
|
+
]);
|
|
480
|
+
console.log(response);
|
|
481
|
+
(0, chai_1.expect)(response.errorCode).to.equal(0);
|
|
482
|
+
let subresponse;
|
|
483
|
+
subresponse = yield transaction.submitTransaction({
|
|
484
|
+
items: [response.result],
|
|
485
|
+
});
|
|
486
|
+
console.log(subresponse);
|
|
487
|
+
}));
|
|
488
|
+
it("transaction.buildBatchContractInvoke", () => __awaiter(void 0, void 0, void 0, function* () {
|
|
489
|
+
let request = {
|
|
490
|
+
base: {
|
|
491
|
+
nonceType: bop_sdk_interface_1.TxType.INCREASE_NONCE,
|
|
492
|
+
gasPrice: 1,
|
|
493
|
+
feeLimit: 1000000,
|
|
494
|
+
remarks: "test",
|
|
495
|
+
},
|
|
496
|
+
params: [
|
|
497
|
+
{
|
|
498
|
+
contractAddress: "did:bid:efYzPhz9f3aFNAZZ42bhbLetBxPyYLdk",
|
|
499
|
+
input: '{"function":"store(uint256)","args":"5"}',
|
|
500
|
+
amount: 0,
|
|
501
|
+
},
|
|
502
|
+
{
|
|
503
|
+
contractAddress: "did:bid:efYzPhz9f3aFNAZZ42bhbLetBxPyYLdk",
|
|
504
|
+
input: '{"function":"store(uint256)","args":"6"}',
|
|
505
|
+
amount: 0,
|
|
506
|
+
},
|
|
507
|
+
],
|
|
508
|
+
};
|
|
509
|
+
console.log(request);
|
|
510
|
+
let signerWithProvider = signer.connect(provider);
|
|
511
|
+
let response;
|
|
512
|
+
response = yield transaction.buildBatchContractInvoke(request, [
|
|
513
|
+
signerWithProvider,
|
|
514
|
+
]);
|
|
515
|
+
console.log(response);
|
|
516
|
+
(0, chai_1.expect)(response.errorCode).to.equal(0);
|
|
517
|
+
let subresponse;
|
|
518
|
+
subresponse = yield transaction.submitTransaction({
|
|
519
|
+
items: [response.result],
|
|
520
|
+
});
|
|
521
|
+
console.log(subresponse);
|
|
522
|
+
}));
|
|
523
|
+
it("transaction.submitTransaction", () => __awaiter(void 0, void 0, void 0, function* () {
|
|
524
|
+
let request = {
|
|
525
|
+
params: {
|
|
526
|
+
nonceType: bop_sdk_interface_1.TxType.INCREASE_NONCE,
|
|
527
|
+
gasPrice: 1,
|
|
528
|
+
feeLimit: 10000,
|
|
529
|
+
remarks: "test",
|
|
530
|
+
},
|
|
531
|
+
key: "A",
|
|
532
|
+
value: "C",
|
|
533
|
+
version: 2,
|
|
534
|
+
};
|
|
535
|
+
console.log(request);
|
|
536
|
+
let signerWithProvider = signer.connect(provider);
|
|
537
|
+
let response;
|
|
538
|
+
response = yield transaction.buildSetMetadataTx(request, [
|
|
539
|
+
signerWithProvider,
|
|
540
|
+
]);
|
|
541
|
+
console.log(JSON.stringify(response));
|
|
542
|
+
(0, chai_1.expect)(response.errorCode).to.equal(0);
|
|
543
|
+
let tx = response;
|
|
544
|
+
tx.result.signatures[0].signData =
|
|
545
|
+
"52936dffa7ca865b592ea2d2ad5b3d0a679eb1524fdb61389018cfee0ad3b31a89dbb6ff2da9a2b228275850c2293cd20df71747a11e77769b04b090dc9d003d";
|
|
546
|
+
let subresponse;
|
|
547
|
+
subresponse = yield transaction.submitTransaction({ items: [tx.result] });
|
|
548
|
+
console.log(subresponse);
|
|
549
|
+
}));
|
|
550
|
+
it("transaction.estimateGas", () => __awaiter(void 0, void 0, void 0, function* () {
|
|
551
|
+
let request = {
|
|
552
|
+
items: [
|
|
553
|
+
{
|
|
554
|
+
transactionJson: {
|
|
555
|
+
feeLimit: 100000,
|
|
556
|
+
sourceAddress: "did:bid:zfVHJnop875UMPmskam4JC4kLW4tAaDK",
|
|
557
|
+
gasPrice: 1,
|
|
558
|
+
nonce: "58",
|
|
559
|
+
operations: [
|
|
560
|
+
// {
|
|
561
|
+
// type: 1,
|
|
562
|
+
// createAccount: {
|
|
563
|
+
// destAddress: "did:bid:ef24McYxrgR5PJUPqw8Ldhsd8XUYx1sSN",
|
|
564
|
+
// initBalance: 1,
|
|
565
|
+
// priv: {
|
|
566
|
+
// masterWeight: 1,
|
|
567
|
+
// thresholds: {
|
|
568
|
+
// txThreshold: 1,
|
|
569
|
+
// },
|
|
570
|
+
// },
|
|
571
|
+
// },
|
|
572
|
+
// },
|
|
573
|
+
// {
|
|
574
|
+
// type: 1,
|
|
575
|
+
// createAccount: {
|
|
576
|
+
// initBalance: 0,
|
|
577
|
+
// contract: {
|
|
578
|
+
// type: 1,
|
|
579
|
+
// payload: "608060405234801561000f575f80fd5b506101638061001d5f395ff3fe608060405234801561000f575f80fd5b5060043610610034575f3560e01c80632e64cec1146100385780636057361d14610056575b5f80fd5b610040610072565b60405161004d919061009b565b60405180910390f35b610070600480360381019061006b91906100e2565b61007a565b005b5f8054905090565b805f8190555050565b5f819050919050565b61009581610083565b82525050565b5f6020820190506100ae5f83018461008c565b92915050565b5f80fd5b6100c181610083565b81146100cb575f80fd5b50565b5f813590506100dc816100b8565b92915050565b5f602082840312156100f7576100f66100b4565b5b5f610104848285016100ce565b9150509291505056fea26469706673582212205e90a2a9da6608b7a94c2c5cf27906d85803927c0bd952e062893006d1814fd564736f6c637822302e382e32312d63692e323032342e332e312b636f6d6d69742e31383065353661320053"
|
|
580
|
+
// },
|
|
581
|
+
// initInput: "",
|
|
582
|
+
// priv: {
|
|
583
|
+
// masterWeight: 0,
|
|
584
|
+
// thresholds: {
|
|
585
|
+
// txThreshold: 1,
|
|
586
|
+
// },
|
|
587
|
+
// },
|
|
588
|
+
// },
|
|
589
|
+
// },
|
|
590
|
+
// {
|
|
591
|
+
// type: 1,
|
|
592
|
+
// createAccount: {
|
|
593
|
+
// initBalance: 0,
|
|
594
|
+
// contract: {
|
|
595
|
+
// type: 0,
|
|
596
|
+
// payload: "'use strict';function init(input){return;}function main(input){let para=JSON.parse(input);if(para.do_foo){let x={'hello':'world'};}}function query(input){return input;}"
|
|
597
|
+
// },
|
|
598
|
+
// initInput: "",
|
|
599
|
+
// priv: {
|
|
600
|
+
// masterWeight: 0,
|
|
601
|
+
// thresholds: {
|
|
602
|
+
// txThreshold: 1,
|
|
603
|
+
// },
|
|
604
|
+
// },
|
|
605
|
+
// },
|
|
606
|
+
// },
|
|
607
|
+
// {
|
|
608
|
+
// type: 7,
|
|
609
|
+
// payCoin: {
|
|
610
|
+
// destAddress: "did:bid:ef24McYxrgR5PJUPqw8Ldhsd8XUYx1sSN",
|
|
611
|
+
// amount: 1,
|
|
612
|
+
// }
|
|
613
|
+
// },
|
|
614
|
+
// {
|
|
615
|
+
// type: 7,
|
|
616
|
+
// payCoin: {
|
|
617
|
+
// destAddress: "did:bid:ef8eHAyVVUJeZqCpJVZGi2todhibpASp",
|
|
618
|
+
// amount: 0,
|
|
619
|
+
// input: '{"function":"store(uint256)","args":"2"}'
|
|
620
|
+
// }
|
|
621
|
+
// },
|
|
622
|
+
// {
|
|
623
|
+
// type: 7,
|
|
624
|
+
// payCoin: {
|
|
625
|
+
// destAddress: "did:bid:eftf3aqGEQE4ANLj6U13GKqu4pzUSj2U",
|
|
626
|
+
// amount: 0,
|
|
627
|
+
// input: '{"method":"getsuperlist"}'
|
|
628
|
+
// }
|
|
629
|
+
// },
|
|
630
|
+
// {
|
|
631
|
+
// type: 4,
|
|
632
|
+
// setMetadata: {
|
|
633
|
+
// key: "CCC",
|
|
634
|
+
// value: "C",
|
|
635
|
+
// version: 1,
|
|
636
|
+
// }
|
|
637
|
+
// },
|
|
638
|
+
// {
|
|
639
|
+
// type: 9,
|
|
640
|
+
// setPrivilege: {
|
|
641
|
+
// masterWeight: "1",
|
|
642
|
+
// typeThresholds: [
|
|
643
|
+
// {
|
|
644
|
+
// type: 1,
|
|
645
|
+
// threshold: 1,
|
|
646
|
+
// }
|
|
647
|
+
// ]
|
|
648
|
+
// }
|
|
649
|
+
// }
|
|
650
|
+
],
|
|
651
|
+
},
|
|
652
|
+
signatureNumber: 1,
|
|
653
|
+
},
|
|
654
|
+
],
|
|
655
|
+
};
|
|
656
|
+
let response;
|
|
657
|
+
response = yield transaction.estimateGas(request);
|
|
658
|
+
console.log(JSON.stringify(response));
|
|
659
|
+
(0, chai_1.expect)(response.errorCode).to.equal(0);
|
|
660
|
+
}));
|
|
661
|
+
});
|
|
662
|
+
});
|
|
663
|
+
//# sourceMappingURL=transaction.test.js.map
|