@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,140 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.InvalidBalanceError = exports.OriginationParameterError = exports.RevealOperationError = exports.InvalidViewSimulationContext = exports.validateAndExtractFailwith = exports.ViewSimulationError = exports.InvalidInitParameter = exports.InvalidCodeParameter = exports.InvalidDelegationSource = exports.InvalidParameterError = void 0;
|
|
4
|
+
const octez_js_core_1 = require("@tezos-x/octez.js-core");
|
|
5
|
+
/**
|
|
6
|
+
* @category Error
|
|
7
|
+
* @description Error that indicates invalid smart contract parameters being passed or used
|
|
8
|
+
*/
|
|
9
|
+
class InvalidParameterError extends octez_js_core_1.ParameterValidationError {
|
|
10
|
+
constructor(smartContractMethodName, sigs, invalidParams) {
|
|
11
|
+
super();
|
|
12
|
+
this.smartContractMethodName = smartContractMethodName;
|
|
13
|
+
this.sigs = sigs;
|
|
14
|
+
this.invalidParams = invalidParams;
|
|
15
|
+
this.name = 'InvalidParameterError';
|
|
16
|
+
this.message = `${smartContractMethodName} Received ${invalidParams.length} arguments while expecting one of the following signatures (${JSON.stringify(sigs)})`;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
exports.InvalidParameterError = InvalidParameterError;
|
|
20
|
+
/**
|
|
21
|
+
* @category Error
|
|
22
|
+
* @description Error that indicates an invalid delegation source contract address being passed or used
|
|
23
|
+
*/
|
|
24
|
+
class InvalidDelegationSource extends octez_js_core_1.ParameterValidationError {
|
|
25
|
+
constructor(source) {
|
|
26
|
+
super();
|
|
27
|
+
this.source = source;
|
|
28
|
+
this.name = `InvalidDelegationSource`;
|
|
29
|
+
this.message = `Since Babylon delegation source can no longer be a contract address ${source}. Please use the smart contract abstraction to set your delegate.`;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
exports.InvalidDelegationSource = InvalidDelegationSource;
|
|
33
|
+
/**
|
|
34
|
+
* @category Error
|
|
35
|
+
* @description Error that indicates an invalid smart contract code parameter being passed or used
|
|
36
|
+
*/
|
|
37
|
+
class InvalidCodeParameter extends octez_js_core_1.ParameterValidationError {
|
|
38
|
+
constructor(message, data) {
|
|
39
|
+
super();
|
|
40
|
+
this.message = message;
|
|
41
|
+
this.data = data;
|
|
42
|
+
this.name = 'InvalidCodeParameter';
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
exports.InvalidCodeParameter = InvalidCodeParameter;
|
|
46
|
+
/**
|
|
47
|
+
* @category Error
|
|
48
|
+
* @description Error that indicates invalid smart contract init parameter being passed or used
|
|
49
|
+
*/
|
|
50
|
+
class InvalidInitParameter extends octez_js_core_1.ParameterValidationError {
|
|
51
|
+
constructor(message, data) {
|
|
52
|
+
super();
|
|
53
|
+
this.message = message;
|
|
54
|
+
this.data = data;
|
|
55
|
+
this.name = 'InvalidInitParameter';
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
exports.InvalidInitParameter = InvalidInitParameter;
|
|
59
|
+
/**
|
|
60
|
+
* @category Error
|
|
61
|
+
* @description Error that indicates a failure when conducting a view simulation
|
|
62
|
+
*/
|
|
63
|
+
class ViewSimulationError extends octez_js_core_1.RpcError {
|
|
64
|
+
constructor(message, viewName, failWith, cause) {
|
|
65
|
+
super();
|
|
66
|
+
this.message = message;
|
|
67
|
+
this.viewName = viewName;
|
|
68
|
+
this.failWith = failWith;
|
|
69
|
+
this.cause = cause;
|
|
70
|
+
this.name = 'ViewSimulationError';
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
exports.ViewSimulationError = ViewSimulationError;
|
|
74
|
+
const validateAndExtractFailwith = (error) => {
|
|
75
|
+
if (isJsonString(error.body)) {
|
|
76
|
+
const parsedError = JSON.parse(error.body);
|
|
77
|
+
if (Array.isArray(parsedError) && 'with' in parsedError[parsedError.length - 1]) {
|
|
78
|
+
return parsedError[parsedError.length - 1].with;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
};
|
|
82
|
+
exports.validateAndExtractFailwith = validateAndExtractFailwith;
|
|
83
|
+
const isJsonString = (str) => {
|
|
84
|
+
try {
|
|
85
|
+
JSON.parse(str);
|
|
86
|
+
}
|
|
87
|
+
catch (e) {
|
|
88
|
+
return false;
|
|
89
|
+
}
|
|
90
|
+
return true;
|
|
91
|
+
};
|
|
92
|
+
/**
|
|
93
|
+
* @category Error
|
|
94
|
+
* @description Error that indicates invalid or unconfigured context when executing a view
|
|
95
|
+
*/
|
|
96
|
+
class InvalidViewSimulationContext extends octez_js_core_1.ParameterValidationError {
|
|
97
|
+
constructor(info) {
|
|
98
|
+
super();
|
|
99
|
+
this.info = info;
|
|
100
|
+
this.name = 'InvalidViewSimulationContext';
|
|
101
|
+
this.message = `${info} Please configure the context of the view execution in the executeView method.`;
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
exports.InvalidViewSimulationContext = InvalidViewSimulationContext;
|
|
105
|
+
/**
|
|
106
|
+
* @category Error
|
|
107
|
+
* @description Error that indicates a mistake happening during the reveal operation
|
|
108
|
+
*/
|
|
109
|
+
class RevealOperationError extends octez_js_core_1.RpcError {
|
|
110
|
+
constructor(message) {
|
|
111
|
+
super();
|
|
112
|
+
this.message = message;
|
|
113
|
+
this.name = 'RevealOperationError';
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
exports.RevealOperationError = RevealOperationError;
|
|
117
|
+
/**
|
|
118
|
+
* @category Error
|
|
119
|
+
* @description Error that indicates a mistake in the parameters in the preparation of an Origination operation
|
|
120
|
+
*/
|
|
121
|
+
class OriginationParameterError extends octez_js_core_1.ParameterValidationError {
|
|
122
|
+
constructor(message) {
|
|
123
|
+
super();
|
|
124
|
+
this.message = message;
|
|
125
|
+
this.name;
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
exports.OriginationParameterError = OriginationParameterError;
|
|
129
|
+
/**
|
|
130
|
+
* @category Error
|
|
131
|
+
* @description Error that indicates an invalid balance being passed or used
|
|
132
|
+
*/
|
|
133
|
+
class InvalidBalanceError extends octez_js_core_1.ParameterValidationError {
|
|
134
|
+
constructor(message) {
|
|
135
|
+
super();
|
|
136
|
+
this.message = message;
|
|
137
|
+
this.name = 'InvalidBalanceError';
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
exports.InvalidBalanceError = InvalidBalanceError;
|
|
@@ -0,0 +1,30 @@
|
|
|
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 __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
exports.smartContractAbstractionSemantic = exports.compose = void 0;
|
|
18
|
+
__exportStar(require("./contract"), exports);
|
|
19
|
+
__exportStar(require("./errors"), exports);
|
|
20
|
+
__exportStar(require("./interface"), exports);
|
|
21
|
+
__exportStar(require("./manager-lambda"), exports);
|
|
22
|
+
__exportStar(require("./prepare"), exports);
|
|
23
|
+
__exportStar(require("./view_lambda"), exports);
|
|
24
|
+
var compose_1 = require("./compose");
|
|
25
|
+
Object.defineProperty(exports, "compose", { enumerable: true, get: function () { return compose_1.compose; } });
|
|
26
|
+
__exportStar(require("./contract-methods/contract-method-interface"), exports);
|
|
27
|
+
__exportStar(require("./contract-methods/contract-method-object-param"), exports);
|
|
28
|
+
__exportStar(require("./sapling-state-abstraction"), exports);
|
|
29
|
+
var semantic_1 = require("./semantic");
|
|
30
|
+
Object.defineProperty(exports, "smartContractAbstractionSemantic", { enumerable: true, get: function () { return semantic_1.smartContractAbstractionSemantic; } });
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.MANAGER_LAMBDA = void 0;
|
|
4
|
+
const setDelegate = (key) => {
|
|
5
|
+
return [
|
|
6
|
+
{ prim: 'DROP' },
|
|
7
|
+
{ prim: 'NIL', args: [{ prim: 'operation' }] },
|
|
8
|
+
{
|
|
9
|
+
prim: 'PUSH',
|
|
10
|
+
args: [{ prim: 'key_hash' }, { string: key }],
|
|
11
|
+
},
|
|
12
|
+
{ prim: 'SOME' },
|
|
13
|
+
{ prim: 'SET_DELEGATE' },
|
|
14
|
+
{ prim: 'CONS' },
|
|
15
|
+
];
|
|
16
|
+
};
|
|
17
|
+
const transferImplicit = (key, mutez) => {
|
|
18
|
+
return [
|
|
19
|
+
{ prim: 'DROP' },
|
|
20
|
+
{ prim: 'NIL', args: [{ prim: 'operation' }] },
|
|
21
|
+
{
|
|
22
|
+
prim: 'PUSH',
|
|
23
|
+
args: [{ prim: 'key_hash' }, { string: key }],
|
|
24
|
+
},
|
|
25
|
+
{ prim: 'IMPLICIT_ACCOUNT' },
|
|
26
|
+
{
|
|
27
|
+
prim: 'PUSH',
|
|
28
|
+
args: [{ prim: 'mutez' }, { int: `${mutez}` }],
|
|
29
|
+
},
|
|
30
|
+
{ prim: 'UNIT' },
|
|
31
|
+
{ prim: 'TRANSFER_TOKENS' },
|
|
32
|
+
{ prim: 'CONS' },
|
|
33
|
+
];
|
|
34
|
+
};
|
|
35
|
+
const removeDelegate = () => {
|
|
36
|
+
return [
|
|
37
|
+
{ prim: 'DROP' },
|
|
38
|
+
{ prim: 'NIL', args: [{ prim: 'operation' }] },
|
|
39
|
+
{ prim: 'NONE', args: [{ prim: 'key_hash' }] },
|
|
40
|
+
{ prim: 'SET_DELEGATE' },
|
|
41
|
+
{ prim: 'CONS' },
|
|
42
|
+
];
|
|
43
|
+
};
|
|
44
|
+
const transferToContract = (key, amount) => {
|
|
45
|
+
return [
|
|
46
|
+
{ prim: 'DROP' },
|
|
47
|
+
{ prim: 'NIL', args: [{ prim: 'operation' }] },
|
|
48
|
+
{
|
|
49
|
+
prim: 'PUSH',
|
|
50
|
+
args: [{ prim: 'address' }, { string: key }],
|
|
51
|
+
},
|
|
52
|
+
{ prim: 'CONTRACT', args: [{ prim: 'unit' }] },
|
|
53
|
+
{
|
|
54
|
+
prim: 'IF_NONE',
|
|
55
|
+
args: [[{ prim: 'UNIT' }, { prim: 'FAILWITH' }], []],
|
|
56
|
+
},
|
|
57
|
+
{
|
|
58
|
+
prim: 'PUSH',
|
|
59
|
+
args: [{ prim: 'mutez' }, { int: `${amount}` }],
|
|
60
|
+
},
|
|
61
|
+
{ prim: 'UNIT' },
|
|
62
|
+
{ prim: 'TRANSFER_TOKENS' },
|
|
63
|
+
{ prim: 'CONS' },
|
|
64
|
+
];
|
|
65
|
+
};
|
|
66
|
+
exports.MANAGER_LAMBDA = {
|
|
67
|
+
setDelegate,
|
|
68
|
+
removeDelegate,
|
|
69
|
+
transferImplicit,
|
|
70
|
+
transferToContract,
|
|
71
|
+
};
|
|
@@ -0,0 +1,240 @@
|
|
|
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.createSmartRollupExecuteOutboxMessageOperation = exports.createSmartRollupOriginateOperation = exports.createSmartRollupAddMessagesOperation = exports.createUpdateCompanionKeyOperation = exports.createUpdateConsensusKeyOperation = exports.createProposalsOperation = exports.createBallotOperation = exports.createDrainDelegateOperation = exports.createIncreasePaidStorageOperation = exports.createTransferTicketOperation = exports.createRegisterGlobalConstantOperation = exports.createRevealOperation = exports.createRegisterDelegateOperation = exports.createSetDelegateOperation = exports.createTransferOperation = exports.createOriginationOperation = exports.createActivationOperation = void 0;
|
|
13
|
+
const octez_js_michelson_encoder_1 = require("@tezos-x/octez.js-michelson-encoder");
|
|
14
|
+
const octez_js_rpc_1 = require("@tezos-x/octez.js-rpc");
|
|
15
|
+
const constants_1 = require("../constants");
|
|
16
|
+
const octez_js_utils_1 = require("@tezos-x/octez.js-utils");
|
|
17
|
+
const errors_1 = require("./errors");
|
|
18
|
+
const createActivationOperation = (_a) => __awaiter(void 0, [_a], void 0, function* ({ pkh, secret }) {
|
|
19
|
+
return {
|
|
20
|
+
kind: octez_js_rpc_1.OpKind.ACTIVATION,
|
|
21
|
+
pkh,
|
|
22
|
+
secret,
|
|
23
|
+
};
|
|
24
|
+
});
|
|
25
|
+
exports.createActivationOperation = createActivationOperation;
|
|
26
|
+
const createOriginationOperation = (_a) => __awaiter(void 0, [_a], void 0, function* ({ code, init, balance = '0', delegate, storage, fee, gasLimit, storageLimit, mutez = false, }) {
|
|
27
|
+
if (storage !== undefined && init !== undefined) {
|
|
28
|
+
throw new errors_1.OriginationParameterError('Storage and Init cannot be set a the same time. Please either use storage or init but not both.');
|
|
29
|
+
}
|
|
30
|
+
if (!Array.isArray(code)) {
|
|
31
|
+
throw new errors_1.InvalidCodeParameter('Wrong code parameter type, expected an array', code);
|
|
32
|
+
}
|
|
33
|
+
let contractStorage;
|
|
34
|
+
if (storage !== undefined) {
|
|
35
|
+
const storageType = code.find((p) => 'prim' in p && p.prim === 'storage');
|
|
36
|
+
if ((storageType === null || storageType === void 0 ? void 0 : storageType.args) === undefined) {
|
|
37
|
+
throw new errors_1.InvalidCodeParameter('The storage section is missing from the script', code);
|
|
38
|
+
}
|
|
39
|
+
const schema = new octez_js_michelson_encoder_1.Schema(storageType.args[0]); // TODO
|
|
40
|
+
contractStorage = schema.Encode(storage);
|
|
41
|
+
}
|
|
42
|
+
else if (init !== undefined && typeof init === 'object') {
|
|
43
|
+
contractStorage = init;
|
|
44
|
+
}
|
|
45
|
+
else {
|
|
46
|
+
throw new errors_1.InvalidInitParameter('Wrong init parameter type, expected JSON Michelson', init);
|
|
47
|
+
}
|
|
48
|
+
const script = {
|
|
49
|
+
code,
|
|
50
|
+
storage: contractStorage,
|
|
51
|
+
};
|
|
52
|
+
if (isNaN(Number(balance))) {
|
|
53
|
+
throw new errors_1.InvalidBalanceError(`Invalid Balance "${balance}", cannot be converted to a number`);
|
|
54
|
+
}
|
|
55
|
+
const operation = {
|
|
56
|
+
kind: octez_js_rpc_1.OpKind.ORIGINATION,
|
|
57
|
+
fee,
|
|
58
|
+
gas_limit: gasLimit,
|
|
59
|
+
storage_limit: storageLimit,
|
|
60
|
+
balance: mutez ? balance.toString() : (0, octez_js_utils_1.format)('tz', 'mutez', balance).toString(),
|
|
61
|
+
script,
|
|
62
|
+
};
|
|
63
|
+
if (delegate) {
|
|
64
|
+
operation.delegate = delegate;
|
|
65
|
+
}
|
|
66
|
+
return operation;
|
|
67
|
+
});
|
|
68
|
+
exports.createOriginationOperation = createOriginationOperation;
|
|
69
|
+
const createTransferOperation = (_a) => __awaiter(void 0, [_a], void 0, function* ({ to, amount, parameter, fee, gasLimit, storageLimit, mutez = false, }) {
|
|
70
|
+
return {
|
|
71
|
+
kind: octez_js_rpc_1.OpKind.TRANSACTION,
|
|
72
|
+
fee,
|
|
73
|
+
gas_limit: gasLimit,
|
|
74
|
+
storage_limit: storageLimit,
|
|
75
|
+
amount: mutez ? amount.toString() : (0, octez_js_utils_1.format)('tz', 'mutez', amount).toString(),
|
|
76
|
+
destination: to,
|
|
77
|
+
parameters: parameter,
|
|
78
|
+
};
|
|
79
|
+
});
|
|
80
|
+
exports.createTransferOperation = createTransferOperation;
|
|
81
|
+
const createSetDelegateOperation = (_a) => __awaiter(void 0, [_a], void 0, function* ({ delegate, source, fee, gasLimit, storageLimit, }) {
|
|
82
|
+
const operation = {
|
|
83
|
+
kind: octez_js_rpc_1.OpKind.DELEGATION,
|
|
84
|
+
source,
|
|
85
|
+
fee,
|
|
86
|
+
gas_limit: gasLimit,
|
|
87
|
+
storage_limit: storageLimit,
|
|
88
|
+
delegate,
|
|
89
|
+
};
|
|
90
|
+
return operation;
|
|
91
|
+
});
|
|
92
|
+
exports.createSetDelegateOperation = createSetDelegateOperation;
|
|
93
|
+
const createRegisterDelegateOperation = (_a, source_1) => __awaiter(void 0, [_a, source_1], void 0, function* ({ fee, gasLimit, storageLimit }, source) {
|
|
94
|
+
return {
|
|
95
|
+
kind: octez_js_rpc_1.OpKind.DELEGATION,
|
|
96
|
+
fee,
|
|
97
|
+
gas_limit: gasLimit,
|
|
98
|
+
storage_limit: storageLimit,
|
|
99
|
+
delegate: source,
|
|
100
|
+
};
|
|
101
|
+
});
|
|
102
|
+
exports.createRegisterDelegateOperation = createRegisterDelegateOperation;
|
|
103
|
+
const createRevealOperation = (_a, source_1, publicKey_1) => __awaiter(void 0, [_a, source_1, publicKey_1], void 0, function* ({ fee, gasLimit, storageLimit, proof }, source, publicKey) {
|
|
104
|
+
return {
|
|
105
|
+
kind: octez_js_rpc_1.OpKind.REVEAL,
|
|
106
|
+
fee,
|
|
107
|
+
public_key: publicKey,
|
|
108
|
+
source,
|
|
109
|
+
gas_limit: gasLimit !== null && gasLimit !== void 0 ? gasLimit : (0, constants_1.getRevealGasLimit)(source),
|
|
110
|
+
storage_limit: storageLimit,
|
|
111
|
+
proof,
|
|
112
|
+
};
|
|
113
|
+
});
|
|
114
|
+
exports.createRevealOperation = createRevealOperation;
|
|
115
|
+
const createRegisterGlobalConstantOperation = (_a) => __awaiter(void 0, [_a], void 0, function* ({ value, source, fee, gasLimit, storageLimit, }) {
|
|
116
|
+
return {
|
|
117
|
+
kind: octez_js_rpc_1.OpKind.REGISTER_GLOBAL_CONSTANT,
|
|
118
|
+
value,
|
|
119
|
+
fee,
|
|
120
|
+
gas_limit: gasLimit,
|
|
121
|
+
storage_limit: storageLimit,
|
|
122
|
+
source,
|
|
123
|
+
};
|
|
124
|
+
});
|
|
125
|
+
exports.createRegisterGlobalConstantOperation = createRegisterGlobalConstantOperation;
|
|
126
|
+
const createTransferTicketOperation = (_a) => __awaiter(void 0, [_a], void 0, function* ({ ticketContents, ticketTy, ticketTicketer, ticketAmount, destination, entrypoint, source, fee, gasLimit, storageLimit, }) {
|
|
127
|
+
return {
|
|
128
|
+
kind: octez_js_rpc_1.OpKind.TRANSFER_TICKET,
|
|
129
|
+
fee,
|
|
130
|
+
gas_limit: gasLimit,
|
|
131
|
+
storage_limit: storageLimit,
|
|
132
|
+
source,
|
|
133
|
+
ticket_contents: ticketContents,
|
|
134
|
+
ticket_ty: ticketTy,
|
|
135
|
+
ticket_ticketer: ticketTicketer,
|
|
136
|
+
ticket_amount: ticketAmount,
|
|
137
|
+
destination,
|
|
138
|
+
entrypoint,
|
|
139
|
+
};
|
|
140
|
+
});
|
|
141
|
+
exports.createTransferTicketOperation = createTransferTicketOperation;
|
|
142
|
+
const createIncreasePaidStorageOperation = (_a) => __awaiter(void 0, [_a], void 0, function* ({ source, fee, gasLimit, storageLimit, amount, destination, }) {
|
|
143
|
+
return {
|
|
144
|
+
kind: octez_js_rpc_1.OpKind.INCREASE_PAID_STORAGE,
|
|
145
|
+
source,
|
|
146
|
+
fee,
|
|
147
|
+
gas_limit: gasLimit,
|
|
148
|
+
storage_limit: storageLimit,
|
|
149
|
+
amount,
|
|
150
|
+
destination,
|
|
151
|
+
};
|
|
152
|
+
});
|
|
153
|
+
exports.createIncreasePaidStorageOperation = createIncreasePaidStorageOperation;
|
|
154
|
+
const createDrainDelegateOperation = (_a) => __awaiter(void 0, [_a], void 0, function* ({ consensus_key, delegate, destination, }) {
|
|
155
|
+
return {
|
|
156
|
+
kind: octez_js_rpc_1.OpKind.DRAIN_DELEGATE,
|
|
157
|
+
consensus_key,
|
|
158
|
+
delegate,
|
|
159
|
+
destination,
|
|
160
|
+
};
|
|
161
|
+
});
|
|
162
|
+
exports.createDrainDelegateOperation = createDrainDelegateOperation;
|
|
163
|
+
const createBallotOperation = (_a) => __awaiter(void 0, [_a], void 0, function* ({ source, proposal, ballot }) {
|
|
164
|
+
return {
|
|
165
|
+
kind: octez_js_rpc_1.OpKind.BALLOT,
|
|
166
|
+
source,
|
|
167
|
+
proposal,
|
|
168
|
+
ballot,
|
|
169
|
+
};
|
|
170
|
+
});
|
|
171
|
+
exports.createBallotOperation = createBallotOperation;
|
|
172
|
+
const createProposalsOperation = (_a) => __awaiter(void 0, [_a], void 0, function* ({ source, proposals }) {
|
|
173
|
+
return {
|
|
174
|
+
kind: octez_js_rpc_1.OpKind.PROPOSALS,
|
|
175
|
+
source,
|
|
176
|
+
proposals,
|
|
177
|
+
};
|
|
178
|
+
});
|
|
179
|
+
exports.createProposalsOperation = createProposalsOperation;
|
|
180
|
+
const createUpdateConsensusKeyOperation = (_a) => __awaiter(void 0, [_a], void 0, function* ({ source, fee, gasLimit, storageLimit, pk, proof, }) {
|
|
181
|
+
return {
|
|
182
|
+
kind: octez_js_rpc_1.OpKind.UPDATE_CONSENSUS_KEY,
|
|
183
|
+
source,
|
|
184
|
+
fee,
|
|
185
|
+
gas_limit: gasLimit,
|
|
186
|
+
storage_limit: storageLimit,
|
|
187
|
+
pk,
|
|
188
|
+
proof,
|
|
189
|
+
};
|
|
190
|
+
});
|
|
191
|
+
exports.createUpdateConsensusKeyOperation = createUpdateConsensusKeyOperation;
|
|
192
|
+
const createUpdateCompanionKeyOperation = (_a) => __awaiter(void 0, [_a], void 0, function* ({ source, fee, gasLimit, storageLimit, pk, proof, }) {
|
|
193
|
+
return {
|
|
194
|
+
kind: octez_js_rpc_1.OpKind.UPDATE_COMPANION_KEY,
|
|
195
|
+
source,
|
|
196
|
+
fee,
|
|
197
|
+
gas_limit: gasLimit,
|
|
198
|
+
storage_limit: storageLimit,
|
|
199
|
+
pk,
|
|
200
|
+
proof,
|
|
201
|
+
};
|
|
202
|
+
});
|
|
203
|
+
exports.createUpdateCompanionKeyOperation = createUpdateCompanionKeyOperation;
|
|
204
|
+
const createSmartRollupAddMessagesOperation = (_a) => __awaiter(void 0, [_a], void 0, function* ({ source, fee, gasLimit, storageLimit, message, }) {
|
|
205
|
+
return {
|
|
206
|
+
kind: octez_js_rpc_1.OpKind.SMART_ROLLUP_ADD_MESSAGES,
|
|
207
|
+
source,
|
|
208
|
+
fee,
|
|
209
|
+
gas_limit: gasLimit,
|
|
210
|
+
storage_limit: storageLimit,
|
|
211
|
+
message,
|
|
212
|
+
};
|
|
213
|
+
});
|
|
214
|
+
exports.createSmartRollupAddMessagesOperation = createSmartRollupAddMessagesOperation;
|
|
215
|
+
const createSmartRollupOriginateOperation = (_a) => __awaiter(void 0, [_a], void 0, function* ({ source, fee, gasLimit, storageLimit, pvmKind, kernel, parametersType, }) {
|
|
216
|
+
return {
|
|
217
|
+
kind: octez_js_rpc_1.OpKind.SMART_ROLLUP_ORIGINATE,
|
|
218
|
+
source,
|
|
219
|
+
fee,
|
|
220
|
+
gas_limit: gasLimit,
|
|
221
|
+
storage_limit: storageLimit,
|
|
222
|
+
pvm_kind: pvmKind,
|
|
223
|
+
kernel,
|
|
224
|
+
parameters_ty: parametersType,
|
|
225
|
+
};
|
|
226
|
+
});
|
|
227
|
+
exports.createSmartRollupOriginateOperation = createSmartRollupOriginateOperation;
|
|
228
|
+
const createSmartRollupExecuteOutboxMessageOperation = (_a) => __awaiter(void 0, [_a], void 0, function* ({ source, fee, gasLimit, storageLimit, rollup, cementedCommitment, outputProof, }) {
|
|
229
|
+
return {
|
|
230
|
+
kind: octez_js_rpc_1.OpKind.SMART_ROLLUP_EXECUTE_OUTBOX_MESSAGE,
|
|
231
|
+
source,
|
|
232
|
+
fee,
|
|
233
|
+
gas_limit: gasLimit,
|
|
234
|
+
storage_limit: storageLimit,
|
|
235
|
+
rollup,
|
|
236
|
+
cemented_commitment: cementedCommitment,
|
|
237
|
+
output_proof: outputProof,
|
|
238
|
+
};
|
|
239
|
+
});
|
|
240
|
+
exports.createSmartRollupExecuteOutboxMessageOperation = createSmartRollupExecuteOutboxMessageOperation;
|