@tezos-x/octez.js 0.9.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/README.md +154 -0
- package/dist/lib/batch/constants.js +16 -0
- package/dist/lib/batch/rpc-batch-provider.js +319 -0
- package/dist/lib/constants.js +133 -0
- package/dist/lib/context.js +182 -0
- package/dist/lib/contract/big-map.js +70 -0
- package/dist/lib/contract/compose.js +6 -0
- package/dist/lib/contract/constants.js +4 -0
- package/dist/lib/contract/contract-methods/contract-method-factory.js +18 -0
- package/dist/lib/contract/contract-methods/contract-method-interface.js +2 -0
- package/dist/lib/contract/contract-methods/contract-method-object-param.js +72 -0
- package/dist/lib/contract/contract-methods/contract-on-chain-view.js +124 -0
- package/dist/lib/contract/contract.js +169 -0
- package/dist/lib/contract/errors.js +140 -0
- package/dist/lib/contract/index.js +30 -0
- package/dist/lib/contract/interface.js +2 -0
- package/dist/lib/contract/manager-lambda.js +71 -0
- package/dist/lib/contract/prepare.js +240 -0
- package/dist/lib/contract/rpc-contract-provider.js +724 -0
- package/dist/lib/contract/sapling-state-abstraction.js +35 -0
- package/dist/lib/contract/semantic.js +40 -0
- package/dist/lib/contract/view_lambda.js +27 -0
- package/dist/lib/errors.js +42 -0
- package/dist/lib/estimate/errors.js +16 -0
- package/dist/lib/estimate/estimate-provider-interface.js +2 -0
- package/dist/lib/estimate/estimate.js +130 -0
- package/dist/lib/estimate/index.js +20 -0
- package/dist/lib/estimate/rpc-estimate-provider.js +673 -0
- package/dist/lib/extension/extension.js +2 -0
- package/dist/lib/forger/composite-forger.js +43 -0
- package/dist/lib/forger/errors.js +30 -0
- package/dist/lib/forger/octez.js-local-forger.js +34 -0
- package/dist/lib/forger/rpc-forger.js +12 -0
- package/dist/lib/global-constants/default-global-constants-provider.js +46 -0
- package/dist/lib/global-constants/errors.js +30 -0
- package/dist/lib/global-constants/interface-global-constants-provider.js +2 -0
- package/dist/lib/global-constants/noop-global-constants-provider.js +21 -0
- package/dist/lib/import-key.js +51 -0
- package/dist/lib/injector/helper.js +18 -0
- package/dist/lib/injector/interface.js +2 -0
- package/dist/lib/injector/rpc-injector.js +38 -0
- package/dist/lib/octez.js +404 -0
- package/dist/lib/operations/ballot-operation.js +33 -0
- package/dist/lib/operations/batch-operation.js +66 -0
- package/dist/lib/operations/delegate-operation.js +57 -0
- package/dist/lib/operations/drain-delegate-operation.js +31 -0
- package/dist/lib/operations/errors.js +130 -0
- package/dist/lib/operations/failing-noop-operation.js +2 -0
- package/dist/lib/operations/increase-paid-storage-operation.js +52 -0
- package/dist/lib/operations/index.js +54 -0
- package/dist/lib/operations/operations.js +123 -0
- package/dist/lib/operations/origination-operation.js +89 -0
- package/dist/lib/operations/proposals-operation.js +30 -0
- package/dist/lib/operations/register-global-constant-operation.js +55 -0
- package/dist/lib/operations/reveal-operation.js +74 -0
- package/dist/lib/operations/smart-rollup-add-messages-operation.js +47 -0
- package/dist/lib/operations/smart-rollup-execute-outbox-message-operation.js +56 -0
- package/dist/lib/operations/smart-rollup-originate-operation.js +53 -0
- package/dist/lib/operations/transaction-operation.js +70 -0
- package/dist/lib/operations/transfer-ticket-operation.js +49 -0
- package/dist/lib/operations/types.js +90 -0
- package/dist/lib/operations/update-companion-key-operation.js +58 -0
- package/dist/lib/operations/update-consensus-key-operation.js +58 -0
- package/dist/lib/packer/interface.js +2 -0
- package/dist/lib/packer/michel-codec-packer.js +22 -0
- package/dist/lib/packer/rpc-packer.js +23 -0
- package/dist/lib/parser/interface.js +2 -0
- package/dist/lib/parser/michel-codec-parser.js +135 -0
- package/dist/lib/parser/noop-parser.js +20 -0
- package/dist/lib/prepare/index.js +18 -0
- package/dist/lib/prepare/interface.js +2 -0
- package/dist/lib/prepare/prepare-provider.js +1010 -0
- package/dist/lib/provider.js +169 -0
- package/dist/lib/read-provider/interface.js +2 -0
- package/dist/lib/read-provider/rpc-read-adapter.js +228 -0
- package/dist/lib/signer/errors.js +17 -0
- package/dist/lib/signer/noop.js +40 -0
- package/dist/lib/subscribe/create-observable-from-subscription.js +20 -0
- package/dist/lib/subscribe/errors.js +30 -0
- package/dist/lib/subscribe/filters.js +96 -0
- package/dist/lib/subscribe/interface.js +2 -0
- package/dist/lib/subscribe/observable-subscription.js +79 -0
- package/dist/lib/subscribe/polling-subcribe-provider.js +118 -0
- package/dist/lib/tz/interface.js +2 -0
- package/dist/lib/tz/rpc-tz-provider.js +63 -0
- package/dist/lib/version.js +8 -0
- package/dist/lib/wallet/batch-operation.js +84 -0
- package/dist/lib/wallet/delegation-operation.js +57 -0
- package/dist/lib/wallet/errors.js +28 -0
- package/dist/lib/wallet/increase-paid-storage-operation.js +57 -0
- package/dist/lib/wallet/index.js +25 -0
- package/dist/lib/wallet/interface.js +2 -0
- package/dist/lib/wallet/legacy.js +86 -0
- package/dist/lib/wallet/operation-factory.js +117 -0
- package/dist/lib/wallet/operation.js +157 -0
- package/dist/lib/wallet/origination-operation.js +65 -0
- package/dist/lib/wallet/receipt.js +43 -0
- package/dist/lib/wallet/register-global-constant-operation.js +62 -0
- package/dist/lib/wallet/transaction-operation.js +53 -0
- package/dist/lib/wallet/transfer-ticket-operation.js +53 -0
- package/dist/lib/wallet/wallet.js +442 -0
- package/dist/octez.es6.js +7673 -0
- package/dist/octez.es6.js.map +1 -0
- package/dist/octez.umd.js +7787 -0
- package/dist/octez.umd.js.map +1 -0
- package/dist/types/batch/constants.d.ts +3 -0
- package/dist/types/batch/rpc-batch-provider.d.ts +139 -0
- package/dist/types/constants.d.ts +81 -0
- package/dist/types/context.d.ts +100 -0
- package/dist/types/contract/big-map.d.ts +35 -0
- package/dist/types/contract/compose.d.ts +5 -0
- package/dist/types/contract/constants.d.ts +1 -0
- package/dist/types/contract/contract-methods/contract-method-factory.d.ts +14 -0
- package/dist/types/contract/contract-methods/contract-method-interface.d.ts +28 -0
- package/dist/types/contract/contract-methods/contract-method-object-param.d.ts +39 -0
- package/dist/types/contract/contract-methods/contract-on-chain-view.d.ts +43 -0
- package/dist/types/contract/contract.d.ts +75 -0
- package/dist/types/contract/errors.d.ts +83 -0
- package/dist/types/contract/index.d.ts +11 -0
- package/dist/types/contract/interface.d.ts +254 -0
- package/dist/types/contract/manager-lambda.d.ts +73 -0
- package/dist/types/contract/prepare.d.ts +18 -0
- package/dist/types/contract/rpc-contract-provider.d.ts +269 -0
- package/dist/types/contract/sapling-state-abstraction.d.ts +17 -0
- package/dist/types/contract/semantic.d.ts +7 -0
- package/dist/types/contract/view_lambda.d.ts +34 -0
- package/dist/types/errors.d.ts +26 -0
- package/dist/types/estimate/errors.d.ts +8 -0
- package/dist/types/estimate/estimate-provider-interface.d.ts +156 -0
- package/dist/types/estimate/estimate.d.ts +94 -0
- package/dist/types/estimate/index.d.ts +4 -0
- package/dist/types/estimate/rpc-estimate-provider.d.ts +170 -0
- package/dist/types/extension/extension.d.ts +4 -0
- package/dist/types/forger/composite-forger.d.ts +6 -0
- package/dist/types/forger/errors.d.ts +16 -0
- package/dist/types/forger/octez.js-local-forger.d.ts +8 -0
- package/dist/types/forger/rpc-forger.d.ts +7 -0
- package/dist/types/global-constants/default-global-constants-provider.d.ts +18 -0
- package/dist/types/global-constants/errors.d.ts +16 -0
- package/dist/types/global-constants/interface-global-constants-provider.d.ts +11 -0
- package/dist/types/global-constants/noop-global-constants-provider.d.ts +5 -0
- package/dist/types/import-key.d.ts +13 -0
- package/dist/types/injector/helper.d.ts +2 -0
- package/dist/types/injector/interface.d.ts +5 -0
- package/dist/types/injector/rpc-injector.d.ts +7 -0
- package/dist/types/octez.d.ts +248 -0
- package/dist/types/operations/ballot-operation.d.ts +18 -0
- package/dist/types/operations/batch-operation.d.ts +19 -0
- package/dist/types/operations/delegate-operation.d.ts +24 -0
- package/dist/types/operations/drain-delegate-operation.d.ts +17 -0
- package/dist/types/operations/errors.d.ts +50 -0
- package/dist/types/operations/failing-noop-operation.d.ts +17 -0
- package/dist/types/operations/increase-paid-storage-operation.d.ts +23 -0
- package/dist/types/operations/index.d.ts +18 -0
- package/dist/types/operations/operations.d.ts +35 -0
- package/dist/types/operations/origination-operation.d.ts +35 -0
- package/dist/types/operations/proposals-operation.d.ts +17 -0
- package/dist/types/operations/register-global-constant-operation.d.ts +25 -0
- package/dist/types/operations/reveal-operation.d.ts +25 -0
- package/dist/types/operations/smart-rollup-add-messages-operation.d.ts +20 -0
- package/dist/types/operations/smart-rollup-execute-outbox-message-operation.d.ts +24 -0
- package/dist/types/operations/smart-rollup-originate-operation.d.ts +23 -0
- package/dist/types/operations/transaction-operation.d.ts +28 -0
- package/dist/types/operations/transfer-ticket-operation.d.ts +22 -0
- package/dist/types/operations/types.d.ts +461 -0
- package/dist/types/operations/update-companion-key-operation.d.ts +23 -0
- package/dist/types/operations/update-consensus-key-operation.d.ts +23 -0
- package/dist/types/packer/interface.d.ts +4 -0
- package/dist/types/packer/michel-codec-packer.d.ts +5 -0
- package/dist/types/packer/rpc-packer.d.ts +8 -0
- package/dist/types/parser/interface.d.ts +4 -0
- package/dist/types/parser/michel-codec-parser.d.ts +16 -0
- package/dist/types/parser/noop-parser.d.ts +5 -0
- package/dist/types/prepare/index.d.ts +2 -0
- package/dist/types/prepare/interface.d.ts +153 -0
- package/dist/types/prepare/prepare-provider.d.ts +213 -0
- package/dist/types/provider.d.ts +44 -0
- package/dist/types/read-provider/interface.d.ts +132 -0
- package/dist/types/read-provider/rpc-read-adapter.d.ts +130 -0
- package/dist/types/signer/errors.d.ts +8 -0
- package/dist/types/signer/noop.d.ts +11 -0
- package/dist/types/subscribe/create-observable-from-subscription.d.ts +4 -0
- package/dist/types/subscribe/errors.d.ts +18 -0
- package/dist/types/subscribe/filters.d.ts +6 -0
- package/dist/types/subscribe/interface.d.ts +48 -0
- package/dist/types/subscribe/observable-subscription.d.ts +21 -0
- package/dist/types/subscribe/polling-subcribe-provider.d.ts +23 -0
- package/dist/types/tz/interface.d.ts +20 -0
- package/dist/types/tz/rpc-tz-provider.d.ts +13 -0
- package/dist/types/version.d.ts +4 -0
- package/dist/types/wallet/batch-operation.d.ts +13 -0
- package/dist/types/wallet/delegation-operation.d.ts +12 -0
- package/dist/types/wallet/errors.d.ts +16 -0
- package/dist/types/wallet/increase-paid-storage-operation.d.ts +12 -0
- package/dist/types/wallet/index.d.ts +9 -0
- package/dist/types/wallet/interface.d.ts +66 -0
- package/dist/types/wallet/legacy.d.ts +21 -0
- package/dist/types/wallet/operation-factory.d.ts +32 -0
- package/dist/types/wallet/operation.d.ts +54 -0
- package/dist/types/wallet/origination-operation.d.ts +14 -0
- package/dist/types/wallet/receipt.d.ts +16 -0
- package/dist/types/wallet/register-global-constant-operation.d.ts +13 -0
- package/dist/types/wallet/transaction-operation.d.ts +12 -0
- package/dist/types/wallet/transfer-ticket-operation.d.ts +12 -0
- package/dist/types/wallet/wallet.d.ts +195 -0
- package/package.json +131 -0
- package/patch.js +20 -0
- package/signature.json +866 -0
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.CompositeForger = void 0;
|
|
13
|
+
const errors_1 = require("./errors");
|
|
14
|
+
class CompositeForger {
|
|
15
|
+
constructor(forgers) {
|
|
16
|
+
this.forgers = forgers;
|
|
17
|
+
if (forgers.length === 0) {
|
|
18
|
+
throw new errors_1.UnspecifiedForgerError();
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
forge(_a) {
|
|
22
|
+
return __awaiter(this, arguments, void 0, function* ({ branch, contents }) {
|
|
23
|
+
const results = yield Promise.all(this.forgers.map((forger) => {
|
|
24
|
+
return forger.forge({ branch, contents });
|
|
25
|
+
}));
|
|
26
|
+
if (results.length === 0) {
|
|
27
|
+
throw new errors_1.UnspecifiedForgerError();
|
|
28
|
+
}
|
|
29
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
30
|
+
let lastResult = results.pop(); // Assumed to be more than one since we
|
|
31
|
+
while (results.length) {
|
|
32
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
33
|
+
const currentResult = results.pop();
|
|
34
|
+
if (currentResult !== lastResult) {
|
|
35
|
+
throw new errors_1.ForgingMismatchError([lastResult, currentResult]);
|
|
36
|
+
}
|
|
37
|
+
lastResult = currentResult;
|
|
38
|
+
}
|
|
39
|
+
return lastResult;
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
exports.CompositeForger = CompositeForger;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.UnspecifiedForgerError = exports.ForgingMismatchError = void 0;
|
|
4
|
+
const octez_js_core_1 = require("@tezos-x/octez.js-core");
|
|
5
|
+
/**
|
|
6
|
+
* @category Error
|
|
7
|
+
* @description Error that indicates CompositeForger.forge() results doesn't match each other
|
|
8
|
+
*/
|
|
9
|
+
class ForgingMismatchError extends octez_js_core_1.TaquitoError {
|
|
10
|
+
constructor(results) {
|
|
11
|
+
super();
|
|
12
|
+
this.results = results;
|
|
13
|
+
this.name = 'ForgingMismatchError';
|
|
14
|
+
this.message = `Forging mismatch error`;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
exports.ForgingMismatchError = ForgingMismatchError;
|
|
18
|
+
/**
|
|
19
|
+
* @category Error
|
|
20
|
+
* @description Error that indicates no forger has been configured for CompositeForger
|
|
21
|
+
*/
|
|
22
|
+
class UnspecifiedForgerError extends octez_js_core_1.TezosToolkitConfigError {
|
|
23
|
+
constructor() {
|
|
24
|
+
super();
|
|
25
|
+
this.name = 'UnspecifiedForgerError';
|
|
26
|
+
this.message =
|
|
27
|
+
'No forger has been configured. Please configure new CompositeForger([rpcForger, localForger]) with your TezosToolkit instance.';
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
exports.UnspecifiedForgerError = UnspecifiedForgerError;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.TaquitoLocalForger = void 0;
|
|
13
|
+
const octez_js_local_forging_1 = require("@tezos-x/octez.js-local-forging");
|
|
14
|
+
class TaquitoLocalForger {
|
|
15
|
+
constructor(context) {
|
|
16
|
+
this.context = context;
|
|
17
|
+
}
|
|
18
|
+
getNextProto() {
|
|
19
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
20
|
+
if (!this.context.proto) {
|
|
21
|
+
const nextProto = yield this.context.readProvider.getNextProtocol('head');
|
|
22
|
+
this.context.proto = nextProto;
|
|
23
|
+
}
|
|
24
|
+
return this.context.proto;
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
forge(_a) {
|
|
28
|
+
return __awaiter(this, arguments, void 0, function* ({ branch, contents }) {
|
|
29
|
+
const forger = new octez_js_local_forging_1.LocalForger(yield this.getNextProto());
|
|
30
|
+
return forger.forge({ branch, contents });
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
exports.TaquitoLocalForger = TaquitoLocalForger;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.RpcForger = void 0;
|
|
4
|
+
class RpcForger {
|
|
5
|
+
constructor(context) {
|
|
6
|
+
this.context = context;
|
|
7
|
+
}
|
|
8
|
+
forge({ branch, contents }) {
|
|
9
|
+
return this.context.rpc.forgeOperations({ branch, contents });
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
exports.RpcForger = RpcForger;
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.DefaultGlobalConstantsProvider = void 0;
|
|
13
|
+
const errors_1 = require("./errors");
|
|
14
|
+
class DefaultGlobalConstantsProvider {
|
|
15
|
+
constructor() {
|
|
16
|
+
this._globalConstantsLibrary = {};
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
*
|
|
20
|
+
* @description Allows to load global constant hashes and their corresponding Michelson JSON values
|
|
21
|
+
*/
|
|
22
|
+
loadGlobalConstant(globalConstant) {
|
|
23
|
+
for (const hash in globalConstant) {
|
|
24
|
+
Object.assign(this._globalConstantsLibrary, {
|
|
25
|
+
[hash]: globalConstant[hash],
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
*
|
|
31
|
+
* @description Retrieve the Michelson value of a global constant based on its hash
|
|
32
|
+
*
|
|
33
|
+
* @param hash a string representing the global constant hash
|
|
34
|
+
* @returns Expr, the JSON Michelson value
|
|
35
|
+
*/
|
|
36
|
+
getGlobalConstantByHash(hash) {
|
|
37
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
38
|
+
const value = this._globalConstantsLibrary[hash];
|
|
39
|
+
if (!value) {
|
|
40
|
+
throw new errors_1.GlobalConstantNotFound(hash);
|
|
41
|
+
}
|
|
42
|
+
return value;
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
exports.DefaultGlobalConstantsProvider = DefaultGlobalConstantsProvider;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.UnconfiguredGlobalConstantsProviderError = exports.GlobalConstantNotFound = void 0;
|
|
4
|
+
const octez_js_core_1 = require("@tezos-x/octez.js-core");
|
|
5
|
+
/**
|
|
6
|
+
* @category Error
|
|
7
|
+
* @description Error that indicates that a global constant does not exist
|
|
8
|
+
*/
|
|
9
|
+
class GlobalConstantNotFound extends octez_js_core_1.TaquitoError {
|
|
10
|
+
constructor(hash) {
|
|
11
|
+
super();
|
|
12
|
+
this.hash = hash;
|
|
13
|
+
this.name = 'GlobalConstantNotFound';
|
|
14
|
+
this.message = `Please load the value associated with the constant ${hash} using the loadGlobalConstant method of the DefaultGlobalConstantsProvider.`;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
exports.GlobalConstantNotFound = GlobalConstantNotFound;
|
|
18
|
+
/**
|
|
19
|
+
* @category Error
|
|
20
|
+
* @description Error that indicates the global constant provider not being configured under TezosToolkit
|
|
21
|
+
*/
|
|
22
|
+
class UnconfiguredGlobalConstantsProviderError extends octez_js_core_1.TezosToolkitConfigError {
|
|
23
|
+
constructor() {
|
|
24
|
+
super();
|
|
25
|
+
this.name = 'UnconfiguredGlobalConstantsProviderError';
|
|
26
|
+
this.message =
|
|
27
|
+
'No global constants provider has been configured. Please configure one by calling setGlobalConstantsProvider({globalConstantsProvider}) on your TezosToolkit instance.';
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
exports.UnconfiguredGlobalConstantsProviderError = UnconfiguredGlobalConstantsProviderError;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.NoopGlobalConstantsProvider = void 0;
|
|
13
|
+
const errors_1 = require("./errors");
|
|
14
|
+
class NoopGlobalConstantsProvider {
|
|
15
|
+
getGlobalConstantByHash(_hash) {
|
|
16
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
17
|
+
throw new errors_1.UnconfiguredGlobalConstantsProviderError();
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
exports.NoopGlobalConstantsProvider = NoopGlobalConstantsProvider;
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.importKey = importKey;
|
|
13
|
+
const octez_js_signer_1 = require("@tezos-x/octez.js-signer");
|
|
14
|
+
/**
|
|
15
|
+
*
|
|
16
|
+
* @description Import a key to sign operation with the side-effect of setting the Tezos instance to use the InMemorySigner provider
|
|
17
|
+
*
|
|
18
|
+
* @warn The JSON faucets are no longer available on https://teztnets.com/
|
|
19
|
+
* @param toolkit The toolkit instance to attach a signer
|
|
20
|
+
* @param privateKeyOrEmail Key to load in memory
|
|
21
|
+
* @param passphrase If the key is encrypted passphrase to decrypt it
|
|
22
|
+
* @param mnemonic Faucet mnemonic
|
|
23
|
+
* @param secret Faucet secret
|
|
24
|
+
*/
|
|
25
|
+
function importKey(toolkit, privateKeyOrEmail, passphrase, mnemonic, secret) {
|
|
26
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
27
|
+
if (privateKeyOrEmail && passphrase && mnemonic && secret) {
|
|
28
|
+
const signer = octez_js_signer_1.InMemorySigner.fromFundraiser(privateKeyOrEmail, passphrase, mnemonic);
|
|
29
|
+
toolkit.setProvider({ signer });
|
|
30
|
+
const pkh = yield signer.publicKeyHash();
|
|
31
|
+
let op;
|
|
32
|
+
try {
|
|
33
|
+
op = yield toolkit.tz.activate(pkh, secret);
|
|
34
|
+
}
|
|
35
|
+
catch (ex) {
|
|
36
|
+
const isInvalidActivationError = ex && ex.body && /Invalid activation/.test(ex.body);
|
|
37
|
+
if (!isInvalidActivationError) {
|
|
38
|
+
throw ex;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
if (op) {
|
|
42
|
+
yield op.confirmation();
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
else {
|
|
46
|
+
// Fallback to regular import
|
|
47
|
+
const signer = yield octez_js_signer_1.InMemorySigner.fromSecretKey(privateKeyOrEmail, passphrase);
|
|
48
|
+
toolkit.setProvider({ signer });
|
|
49
|
+
}
|
|
50
|
+
});
|
|
51
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.formatErrorMessage = formatErrorMessage;
|
|
4
|
+
const octez_js_http_utils_1 = require("@tezos-x/octez.js-http-utils");
|
|
5
|
+
function formatErrorMessage(error, stringToReplace) {
|
|
6
|
+
const body = JSON.parse(error.body);
|
|
7
|
+
if (body[0] && body[0].kind && body[0].msg) {
|
|
8
|
+
const newBody = JSON.stringify({
|
|
9
|
+
kind: body[0].kind,
|
|
10
|
+
id: body[0].id,
|
|
11
|
+
msg: body[0].msg.replace(stringToReplace, ''),
|
|
12
|
+
});
|
|
13
|
+
return new octez_js_http_utils_1.HttpResponseError(`Http error response: (${error.status}) ${newBody}`, error.status, error.statusText, newBody, error.url);
|
|
14
|
+
}
|
|
15
|
+
else {
|
|
16
|
+
return error;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.RpcInjector = void 0;
|
|
13
|
+
const helper_1 = require("./helper");
|
|
14
|
+
const octez_js_http_utils_1 = require("@tezos-x/octez.js-http-utils");
|
|
15
|
+
class RpcInjector {
|
|
16
|
+
constructor(context) {
|
|
17
|
+
this.context = context;
|
|
18
|
+
}
|
|
19
|
+
inject(signedOperationBytes) {
|
|
20
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
21
|
+
let hash;
|
|
22
|
+
try {
|
|
23
|
+
hash = yield this.context.rpc.injectOperation(signedOperationBytes);
|
|
24
|
+
}
|
|
25
|
+
catch (error) {
|
|
26
|
+
const stringToStrip = '. You may want to use --replace to provide adequate fee and replace it';
|
|
27
|
+
if (error instanceof octez_js_http_utils_1.HttpResponseError && error.message.includes(stringToStrip)) {
|
|
28
|
+
throw (0, helper_1.formatErrorMessage)(error, stringToStrip);
|
|
29
|
+
}
|
|
30
|
+
else {
|
|
31
|
+
throw error;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
return hash;
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
exports.RpcInjector = RpcInjector;
|