@taquito/taquito 11.0.2 → 11.2.0-beta-RC.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 +2 -2
- package/dist/lib/batch/rpc-batch-provider.js +115 -249
- package/dist/lib/batch/rpc-batch-provider.js.map +1 -1
- package/dist/lib/constants.js +10 -4
- package/dist/lib/constants.js.map +1 -1
- package/dist/lib/context.js +143 -223
- package/dist/lib/context.js.map +1 -1
- package/dist/lib/contract/big-map.js +26 -66
- package/dist/lib/contract/big-map.js.map +1 -1
- package/dist/lib/contract/compose.js +1 -3
- package/dist/lib/contract/compose.js.map +1 -1
- package/dist/lib/contract/contract-methods/contract-method-factory.js +17 -16
- package/dist/lib/contract/contract-methods/contract-method-factory.js.map +1 -1
- package/dist/lib/contract/contract-methods/contract-method-flat-param.js +39 -68
- package/dist/lib/contract/contract-methods/contract-method-flat-param.js.map +1 -1
- package/dist/lib/contract/contract-methods/contract-method-object-param.js +21 -28
- package/dist/lib/contract/contract-methods/contract-method-object-param.js.map +1 -1
- package/dist/lib/contract/contract-methods/contract-on-chain-view.js +142 -0
- package/dist/lib/contract/contract-methods/contract-on-chain-view.js.map +1 -0
- package/dist/lib/contract/contract.js +114 -162
- package/dist/lib/contract/contract.js.map +1 -1
- package/dist/lib/contract/errors.js +68 -24
- package/dist/lib/contract/errors.js.map +1 -1
- package/dist/lib/contract/estimate.js +74 -112
- package/dist/lib/contract/estimate.js.map +1 -1
- package/dist/lib/contract/lambda-view.js +39 -95
- package/dist/lib/contract/lambda-view.js.map +1 -1
- package/dist/lib/contract/manager-lambda.js +10 -10
- package/dist/lib/contract/manager-lambda.js.map +1 -1
- package/dist/lib/contract/naive-estimate-provider.js +49 -143
- package/dist/lib/contract/naive-estimate-provider.js.map +1 -1
- package/dist/lib/contract/prepare.js +96 -160
- package/dist/lib/contract/prepare.js.map +1 -1
- package/dist/lib/contract/rpc-contract-provider.js +237 -523
- package/dist/lib/contract/rpc-contract-provider.js.map +1 -1
- package/dist/lib/contract/rpc-estimate-provider.js +209 -532
- package/dist/lib/contract/rpc-estimate-provider.js.map +1 -1
- package/dist/lib/contract/sapling-state-abstraction.js +9 -39
- package/dist/lib/contract/sapling-state-abstraction.js.map +1 -1
- package/dist/lib/contract/semantic.js +9 -9
- package/dist/lib/contract/semantic.js.map +1 -1
- package/dist/lib/contract/view_lambda.js +4 -4
- package/dist/lib/contract/view_lambda.js.map +1 -1
- package/dist/lib/forger/composite-forger.js +26 -61
- package/dist/lib/forger/composite-forger.js.map +1 -1
- package/dist/lib/forger/rpc-forger.js +6 -8
- package/dist/lib/forger/rpc-forger.js.map +1 -1
- package/dist/lib/format.js +5 -7
- package/dist/lib/format.js.map +1 -1
- package/dist/lib/global-constants/default-global-constants-provider.js +47 -0
- package/dist/lib/global-constants/default-global-constants-provider.js.map +1 -0
- package/dist/lib/global-constants/error.js +19 -0
- package/dist/lib/global-constants/error.js.map +1 -0
- package/dist/lib/global-constants/interface-global-constants-provider.js +3 -0
- package/dist/lib/global-constants/interface-global-constants-provider.js.map +1 -0
- package/dist/lib/global-constants/noop-global-constants-provider.js +22 -0
- package/dist/lib/global-constants/noop-global-constants-provider.js.map +1 -0
- package/dist/lib/injector/rpc-injector.js +5 -6
- package/dist/lib/injector/rpc-injector.js.map +1 -1
- package/dist/lib/operations/batch-operation.js +43 -87
- package/dist/lib/operations/batch-operation.js.map +1 -1
- package/dist/lib/operations/delegate-operation.js +44 -96
- package/dist/lib/operations/delegate-operation.js.map +1 -1
- package/dist/lib/operations/operation-emitter.js +184 -340
- package/dist/lib/operations/operation-emitter.js.map +1 -1
- package/dist/lib/operations/operation-errors.js +29 -64
- package/dist/lib/operations/operation-errors.js.map +1 -1
- package/dist/lib/operations/operations.js +80 -148
- package/dist/lib/operations/operations.js.map +1 -1
- package/dist/lib/operations/origination-operation.js +59 -145
- package/dist/lib/operations/origination-operation.js.map +1 -1
- package/dist/lib/operations/register-global-constant-operation.js +38 -82
- package/dist/lib/operations/register-global-constant-operation.js.map +1 -1
- package/dist/lib/operations/reveal-operation.js +50 -106
- package/dist/lib/operations/reveal-operation.js.map +1 -1
- package/dist/lib/operations/transaction-operation.js +54 -114
- package/dist/lib/operations/transaction-operation.js.map +1 -1
- package/dist/lib/operations/types.js +11 -22
- package/dist/lib/operations/types.js.map +1 -1
- package/dist/lib/packer/michel-codec-packer.js +8 -41
- package/dist/lib/packer/michel-codec-packer.js.map +1 -1
- package/dist/lib/packer/rpc-packer.js +7 -37
- package/dist/lib/packer/rpc-packer.js.map +1 -1
- package/dist/lib/parser/michel-codec-parser.js +103 -159
- package/dist/lib/parser/michel-codec-parser.js.map +1 -1
- package/dist/lib/parser/noop-parser.js +6 -38
- package/dist/lib/parser/noop-parser.js.map +1 -1
- package/dist/lib/signer/noop.js +22 -61
- package/dist/lib/signer/noop.js.map +1 -1
- package/dist/lib/subscribe/filters.js +13 -33
- package/dist/lib/subscribe/filters.js.map +1 -1
- package/dist/lib/subscribe/observable-subscription.js +32 -56
- package/dist/lib/subscribe/observable-subscription.js.map +1 -1
- package/dist/lib/subscribe/polling-provider.js +24 -81
- package/dist/lib/subscribe/polling-provider.js.map +1 -1
- package/dist/lib/taquito.js +117 -142
- package/dist/lib/taquito.js.map +1 -1
- package/dist/lib/tz/rpc-tz-provider.js +37 -97
- package/dist/lib/tz/rpc-tz-provider.js.map +1 -1
- package/dist/lib/version.js +2 -4
- package/dist/lib/version.js.map +1 -1
- package/dist/lib/wallet/batch-operation.js +31 -89
- package/dist/lib/wallet/batch-operation.js.map +1 -1
- package/dist/lib/wallet/delegation-operation.js +29 -94
- package/dist/lib/wallet/delegation-operation.js.map +1 -1
- package/dist/lib/wallet/legacy.js +25 -86
- package/dist/lib/wallet/legacy.js.map +1 -1
- package/dist/lib/wallet/operation-factory.js +61 -191
- package/dist/lib/wallet/operation-factory.js.map +1 -1
- package/dist/lib/wallet/operation.js +79 -185
- package/dist/lib/wallet/operation.js.map +1 -1
- package/dist/lib/wallet/origination-operation.js +36 -108
- package/dist/lib/wallet/origination-operation.js.map +1 -1
- package/dist/lib/wallet/receipt.js +20 -21
- package/dist/lib/wallet/receipt.js.map +1 -1
- package/dist/lib/wallet/transaction-operation.js +29 -94
- package/dist/lib/wallet/transaction-operation.js.map +1 -1
- package/dist/lib/wallet/wallet.js +133 -311
- package/dist/lib/wallet/wallet.js.map +1 -1
- package/dist/taquito.es6.js +4573 -0
- package/dist/taquito.es6.js.map +1 -0
- package/dist/taquito.min.js +1 -1
- package/dist/taquito.umd.js +2741 -4196
- package/dist/taquito.umd.js.map +1 -1
- package/dist/types/batch/rpc-batch-provider.d.ts +2 -1
- package/dist/types/constants.d.ts +9 -3
- package/dist/types/context.d.ts +7 -4
- package/dist/types/contract/contract-methods/contract-method-factory.d.ts +9 -3
- package/dist/types/contract/contract-methods/contract-method-flat-param.d.ts +1 -1
- package/dist/types/contract/contract-methods/contract-method-object-param.d.ts +2 -2
- package/dist/types/contract/contract-methods/contract-on-chain-view.d.ts +42 -0
- package/dist/types/contract/contract.d.ts +32 -15
- package/dist/types/contract/errors.d.ts +28 -8
- package/dist/types/contract/interface.d.ts +2 -2
- package/dist/types/contract/lambda-view.d.ts +1 -1
- package/dist/types/contract/prepare.d.ts +1 -1
- package/dist/types/contract/rpc-contract-provider.d.ts +3 -3
- package/dist/types/forger/composite-forger.d.ts +1 -2
- package/dist/types/global-constants/default-global-constants-provider.d.ts +18 -0
- package/dist/types/global-constants/error.d.ts +9 -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/operations/operation-emitter.d.ts +3 -3
- package/dist/types/operations/operation-errors.d.ts +2 -4
- package/dist/types/operations/origination-operation.d.ts +3 -2
- package/dist/types/operations/types.d.ts +2 -2
- package/dist/types/parser/michel-codec-parser.d.ts +1 -0
- package/dist/types/signer/interface.d.ts +1 -1
- package/dist/types/signer/noop.d.ts +2 -2
- package/dist/types/taquito.d.ts +28 -1
- package/dist/types/wallet/interface.d.ts +1 -1
- package/dist/types/wallet/legacy.d.ts +1 -1
- package/dist/types/wallet/operation.d.ts +2 -2
- package/dist/types/wallet/origination-operation.d.ts +3 -2
- package/dist/types/wallet/wallet.d.ts +5 -4
- package/package.json +30 -31
- package/dist/taquito.es5.js +0 -6036
- package/dist/taquito.es5.js.map +0 -1
|
@@ -8,66 +8,19 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
8
8
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
13
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
|
-
function step(op) {
|
|
16
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
-
while (_) try {
|
|
18
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
19
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
|
-
switch (op[0]) {
|
|
21
|
-
case 0: case 1: t = op; break;
|
|
22
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
23
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
24
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
25
|
-
default:
|
|
26
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
27
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
28
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
29
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
30
|
-
if (t[2]) _.ops.pop();
|
|
31
|
-
_.trys.pop(); continue;
|
|
32
|
-
}
|
|
33
|
-
op = body.call(thisArg, _);
|
|
34
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
35
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
|
-
}
|
|
37
|
-
};
|
|
38
|
-
var __read = (this && this.__read) || function (o, n) {
|
|
39
|
-
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
40
|
-
if (!m) return o;
|
|
41
|
-
var i = m.call(o), r, ar = [], e;
|
|
42
|
-
try {
|
|
43
|
-
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
44
|
-
}
|
|
45
|
-
catch (error) { e = { error: error }; }
|
|
46
|
-
finally {
|
|
47
|
-
try {
|
|
48
|
-
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
49
|
-
}
|
|
50
|
-
finally { if (e) throw e.error; }
|
|
51
|
-
}
|
|
52
|
-
return ar;
|
|
53
|
-
};
|
|
54
|
-
var __spread = (this && this.__spread) || function () {
|
|
55
|
-
for (var ar = [], i = 0; i < arguments.length; i++) ar = ar.concat(__read(arguments[i]));
|
|
56
|
-
return ar;
|
|
57
|
-
};
|
|
58
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
59
12
|
exports.ContractAbstraction = exports.ContractView = exports.DEFAULT_SMART_CONTRACT_METHOD_NAME = void 0;
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
13
|
+
const michelson_encoder_1 = require("@taquito/michelson-encoder");
|
|
14
|
+
const constants_1 = require("../constants");
|
|
15
|
+
const contract_method_factory_1 = require("./contract-methods/contract-method-factory");
|
|
16
|
+
const errors_1 = require("./errors");
|
|
17
|
+
const lambda_view_1 = require("./lambda-view");
|
|
65
18
|
exports.DEFAULT_SMART_CONTRACT_METHOD_NAME = 'default';
|
|
66
19
|
/**
|
|
67
20
|
* @description Utility class to retrieve data from a smart contract's storage without incurring fees via a contract's view method
|
|
68
21
|
*/
|
|
69
|
-
|
|
70
|
-
|
|
22
|
+
class ContractView {
|
|
23
|
+
constructor(currentContract, provider, name, chainId, callbackParametersSchema, parameterSchema, args) {
|
|
71
24
|
this.currentContract = currentContract;
|
|
72
25
|
this.provider = provider;
|
|
73
26
|
this.name = name;
|
|
@@ -80,82 +33,74 @@ var ContractView = /** @class */ (function () {
|
|
|
80
33
|
*
|
|
81
34
|
* @description Find which lambda contract to use based on the current network,
|
|
82
35
|
* encode parameters to Michelson,
|
|
83
|
-
* create an instance of Lambdaview to
|
|
36
|
+
* create an instance of Lambdaview to retrieve data, and
|
|
84
37
|
* Decode Michelson response
|
|
85
38
|
*
|
|
86
39
|
* @param Options Address of a lambda contract (sandbox users)
|
|
87
40
|
*/
|
|
88
|
-
|
|
89
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
return [4 /*yield*/, lambdaView.execute()];
|
|
120
|
-
case 2:
|
|
121
|
-
failedWith = _b.sent();
|
|
122
|
-
response = this.callbackParametersSchema.Execute(failedWith);
|
|
123
|
-
return [2 /*return*/, response];
|
|
124
|
-
}
|
|
125
|
-
});
|
|
41
|
+
read(customLambdaAddress) {
|
|
42
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
43
|
+
let lambdaAddress;
|
|
44
|
+
// TODO Verify if the 'customLambdaAdress' is a valid originated contract and if not, return an appropriate error message.
|
|
45
|
+
if (customLambdaAddress) {
|
|
46
|
+
lambdaAddress = customLambdaAddress;
|
|
47
|
+
}
|
|
48
|
+
else if (this.chainId === constants_1.ChainIds.GRANADANET) {
|
|
49
|
+
lambdaAddress = constants_1.DefaultLambdaAddresses.GRANADANET;
|
|
50
|
+
}
|
|
51
|
+
else if (this.chainId === constants_1.ChainIds.HANGZHOUNET) {
|
|
52
|
+
lambdaAddress = constants_1.DefaultLambdaAddresses.HANGZHOUNET;
|
|
53
|
+
}
|
|
54
|
+
else if (this.chainId === constants_1.ChainIds.ITHACANET) {
|
|
55
|
+
lambdaAddress = constants_1.DefaultLambdaAddresses.ITHACANET;
|
|
56
|
+
}
|
|
57
|
+
else if (this.chainId === constants_1.ChainIds.ITHACANET2) {
|
|
58
|
+
lambdaAddress = constants_1.DefaultLambdaAddresses.ITHACANET2;
|
|
59
|
+
}
|
|
60
|
+
else if (this.chainId === constants_1.ChainIds.MAINNET) {
|
|
61
|
+
lambdaAddress = constants_1.DefaultLambdaAddresses.MAINNET;
|
|
62
|
+
}
|
|
63
|
+
else {
|
|
64
|
+
throw new errors_1.UndefinedLambdaContractError();
|
|
65
|
+
}
|
|
66
|
+
const lambdaContract = yield this.provider.at(lambdaAddress);
|
|
67
|
+
const arg = this.parameterSchema.Encode(...this.args);
|
|
68
|
+
const lambdaView = new lambda_view_1.default(lambdaContract, this.currentContract, this.name, arg);
|
|
69
|
+
const failedWith = yield lambdaView.execute();
|
|
70
|
+
const response = this.callbackParametersSchema.Execute(failedWith);
|
|
71
|
+
return response;
|
|
126
72
|
});
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
}());
|
|
73
|
+
}
|
|
74
|
+
}
|
|
130
75
|
exports.ContractView = ContractView;
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
if (!sigs.find(
|
|
76
|
+
const validateArgs = (args, schema, name) => {
|
|
77
|
+
const sigs = schema.ExtractSignatures();
|
|
78
|
+
if (!sigs.find((x) => x.length === args.length)) {
|
|
134
79
|
throw new errors_1.InvalidParameterError(name, sigs, args);
|
|
135
80
|
}
|
|
136
81
|
};
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
if (
|
|
141
|
-
|
|
82
|
+
// lambda view tzip4
|
|
83
|
+
const isView = (entrypoint) => {
|
|
84
|
+
let isView = false;
|
|
85
|
+
if ('prim' in entrypoint && entrypoint.prim === 'pair' && entrypoint.args) {
|
|
86
|
+
const lastElement = entrypoint.args[entrypoint.args.length - 1];
|
|
87
|
+
if ('prim' in lastElement && lastElement.prim === 'contract') {
|
|
88
|
+
isView = true;
|
|
89
|
+
}
|
|
142
90
|
}
|
|
143
91
|
return isView;
|
|
144
92
|
};
|
|
145
|
-
|
|
146
|
-
return variableToCheck.contractProviderTypeSymbol !== undefined;
|
|
147
|
-
};
|
|
93
|
+
const isContractProvider = (variableToCheck) => variableToCheck.contractProviderTypeSymbol !== undefined;
|
|
148
94
|
/**
|
|
149
95
|
* @description Smart contract abstraction
|
|
150
96
|
*/
|
|
151
|
-
|
|
152
|
-
|
|
97
|
+
class ContractAbstraction {
|
|
98
|
+
constructor(address, script, provider, storageProvider, entrypoints, chainId, rpc) {
|
|
153
99
|
this.address = address;
|
|
154
100
|
this.script = script;
|
|
155
101
|
this.storageProvider = storageProvider;
|
|
156
102
|
this.entrypoints = entrypoints;
|
|
157
103
|
this.chainId = chainId;
|
|
158
|
-
this.contractMethodFactory = new contract_method_factory_1.ContractMethodFactory();
|
|
159
104
|
/**
|
|
160
105
|
* @description Contains methods that are implemented by the target Tezos Smart Contract, and offers the user to call the Smart Contract methods as if they were native TS/JS methods.
|
|
161
106
|
* NB: if the contract contains annotation it will include named properties; if not it will be indexed by a number.
|
|
@@ -169,82 +114,91 @@ var ContractAbstraction = /** @class */ (function () {
|
|
|
169
114
|
*
|
|
170
115
|
*/
|
|
171
116
|
this.methodsObject = {};
|
|
117
|
+
/**
|
|
118
|
+
* @description Contains lamda views (tzip4) that are implemented by the target Tezos Smart Contract, and offers the user to call the lambda views as if they were native TS/JS methods.
|
|
119
|
+
* NB: These are the view defined in the tzip4 standard, not the views introduced by the Hangzhou protocol.
|
|
120
|
+
*/
|
|
172
121
|
this.views = {};
|
|
122
|
+
/**
|
|
123
|
+
* @description Contains on-chain views that are defined by the target Tezos Smart Contract, and offers the user to simulate the views execution as if they were native TS/JS methods.
|
|
124
|
+
* NB: the expected format for the parameter when calling a smart contract view is the object format (same format as for the storage) and not the flattened representation.
|
|
125
|
+
*
|
|
126
|
+
*/
|
|
127
|
+
this.contractViews = {};
|
|
128
|
+
this.contractMethodFactory = new contract_method_factory_1.ContractMethodFactory(provider, address);
|
|
173
129
|
this.schema = michelson_encoder_1.Schema.fromRPCResponse({ script: this.script });
|
|
174
130
|
this.parameterSchema = michelson_encoder_1.ParameterSchema.fromRPCResponse({ script: this.script });
|
|
175
|
-
this.
|
|
131
|
+
this.viewSchema = michelson_encoder_1.ViewSchema.fromRPCResponse({ script: this.script });
|
|
132
|
+
if (this.viewSchema.length !== 0) {
|
|
133
|
+
this._initializeOnChainViews(this, rpc, this.viewSchema);
|
|
134
|
+
}
|
|
135
|
+
this._initializeMethods(this, provider, this.entrypoints.entrypoints, this.chainId);
|
|
176
136
|
}
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
var keys = Object.keys(entrypoints);
|
|
137
|
+
_initializeMethods(currentContract, provider, entrypoints, chainId) {
|
|
138
|
+
const parameterSchema = this.parameterSchema;
|
|
139
|
+
const keys = Object.keys(entrypoints);
|
|
181
140
|
if (parameterSchema.isMultipleEntryPoint) {
|
|
182
|
-
keys.forEach(
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
for (var _i = 0; _i < arguments.length; _i++) {
|
|
187
|
-
args[_i] = arguments[_i];
|
|
188
|
-
}
|
|
189
|
-
return currentContract.contractMethodFactory.createContractMethodFlatParams(provider, address, smartContractMethodSchema, smartContractMethodName, args);
|
|
141
|
+
keys.forEach((smartContractMethodName) => {
|
|
142
|
+
const smartContractMethodSchema = new michelson_encoder_1.ParameterSchema(entrypoints[smartContractMethodName]);
|
|
143
|
+
this.methods[smartContractMethodName] = function (...args) {
|
|
144
|
+
return currentContract.contractMethodFactory.createContractMethodFlatParams(smartContractMethodSchema, smartContractMethodName, args);
|
|
190
145
|
};
|
|
191
|
-
|
|
192
|
-
return currentContract.contractMethodFactory.createContractMethodObjectParam(
|
|
146
|
+
this.methodsObject[smartContractMethodName] = function (args) {
|
|
147
|
+
return currentContract.contractMethodFactory.createContractMethodObjectParam(smartContractMethodSchema, smartContractMethodName, args);
|
|
193
148
|
};
|
|
194
149
|
if (isContractProvider(provider)) {
|
|
195
|
-
if (isView(
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
var parametersCallback = entrypoints[smartContractMethodName].args[1].args[0];
|
|
204
|
-
var smartContractMethodCallbackSchema = new michelson_encoder_1.ParameterSchema(parametersCallback);
|
|
150
|
+
if (isView(entrypoints[smartContractMethodName])) {
|
|
151
|
+
const view = function (...args) {
|
|
152
|
+
const entrypointParamWithoutCallback = entrypoints[smartContractMethodName]
|
|
153
|
+
.args[0];
|
|
154
|
+
const smartContractMethodSchemaWithoutCallback = new michelson_encoder_1.ParameterSchema(entrypointParamWithoutCallback);
|
|
155
|
+
const parametersCallback = entrypoints[smartContractMethodName].args[1]
|
|
156
|
+
.args[0];
|
|
157
|
+
const smartContractMethodCallbackSchema = new michelson_encoder_1.ParameterSchema(parametersCallback);
|
|
205
158
|
validateArgs(args, smartContractMethodSchemaWithoutCallback, smartContractMethodName);
|
|
206
159
|
return new ContractView(currentContract, provider, smartContractMethodName, chainId, smartContractMethodCallbackSchema, smartContractMethodSchemaWithoutCallback, args);
|
|
207
160
|
};
|
|
208
|
-
|
|
161
|
+
this.views[smartContractMethodName] = view;
|
|
209
162
|
}
|
|
210
163
|
}
|
|
211
164
|
});
|
|
212
165
|
// Deal with methods with no annotations which were not discovered by the RPC endpoint
|
|
213
166
|
// Methods with no annotations are discovered using parameter schema
|
|
214
|
-
|
|
215
|
-
anonymousMethods.forEach(
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
for (var _i = 0; _i < arguments.length; _i++) {
|
|
219
|
-
args[_i] = arguments[_i];
|
|
220
|
-
}
|
|
221
|
-
return currentContract.contractMethodFactory.createContractMethodFlatParams(provider, address, parameterSchema, smartContractMethodName, args, false, true);
|
|
167
|
+
const anonymousMethods = Object.keys(parameterSchema.ExtractSchema()).filter((key) => Object.keys(entrypoints).indexOf(key) === -1);
|
|
168
|
+
anonymousMethods.forEach((smartContractMethodName) => {
|
|
169
|
+
this.methods[smartContractMethodName] = function (...args) {
|
|
170
|
+
return currentContract.contractMethodFactory.createContractMethodFlatParams(parameterSchema, smartContractMethodName, args, false, true);
|
|
222
171
|
};
|
|
223
|
-
|
|
224
|
-
return currentContract.contractMethodFactory.createContractMethodObjectParam(
|
|
172
|
+
this.methodsObject[smartContractMethodName] = function (args) {
|
|
173
|
+
return currentContract.contractMethodFactory.createContractMethodObjectParam(parameterSchema, smartContractMethodName, args, false, true);
|
|
225
174
|
};
|
|
226
175
|
});
|
|
227
176
|
}
|
|
228
177
|
else {
|
|
229
|
-
|
|
230
|
-
this.methods[exports.DEFAULT_SMART_CONTRACT_METHOD_NAME] = function () {
|
|
231
|
-
|
|
232
|
-
for (var _i = 0; _i < arguments.length; _i++) {
|
|
233
|
-
args[_i] = arguments[_i];
|
|
234
|
-
}
|
|
235
|
-
return currentContract.contractMethodFactory.createContractMethodFlatParams(provider, address, smartContractMethodSchema_1, exports.DEFAULT_SMART_CONTRACT_METHOD_NAME, args, false);
|
|
178
|
+
const smartContractMethodSchema = this.parameterSchema;
|
|
179
|
+
this.methods[exports.DEFAULT_SMART_CONTRACT_METHOD_NAME] = function (...args) {
|
|
180
|
+
return currentContract.contractMethodFactory.createContractMethodFlatParams(smartContractMethodSchema, exports.DEFAULT_SMART_CONTRACT_METHOD_NAME, args, false);
|
|
236
181
|
};
|
|
237
182
|
this.methodsObject[exports.DEFAULT_SMART_CONTRACT_METHOD_NAME] = function (args) {
|
|
238
|
-
return currentContract.contractMethodFactory.createContractMethodObjectParam(
|
|
183
|
+
return currentContract.contractMethodFactory.createContractMethodObjectParam(smartContractMethodSchema, exports.DEFAULT_SMART_CONTRACT_METHOD_NAME, args, false);
|
|
239
184
|
};
|
|
240
185
|
}
|
|
241
|
-
}
|
|
186
|
+
}
|
|
187
|
+
_initializeOnChainViews(currentContract, rpc, allContractViews) {
|
|
188
|
+
const storageType = this.schema.val;
|
|
189
|
+
const storageValue = this.script.storage;
|
|
190
|
+
allContractViews.forEach((viewSchema) => {
|
|
191
|
+
this.contractViews[viewSchema.viewName] = function (args) {
|
|
192
|
+
return currentContract.contractMethodFactory.createContractViewObjectParam(rpc, viewSchema, storageType, storageValue, args);
|
|
193
|
+
};
|
|
194
|
+
});
|
|
195
|
+
}
|
|
242
196
|
/**
|
|
243
197
|
* @description Return a friendly representation of the smart contract storage
|
|
244
198
|
*/
|
|
245
|
-
|
|
199
|
+
storage() {
|
|
246
200
|
return this.storageProvider.getStorage(this.address, this.schema);
|
|
247
|
-
}
|
|
201
|
+
}
|
|
248
202
|
/**
|
|
249
203
|
*
|
|
250
204
|
* @description Return a friendly representation of the smart contract big map value
|
|
@@ -255,11 +209,9 @@ var ContractAbstraction = /** @class */ (function () {
|
|
|
255
209
|
*
|
|
256
210
|
* @see https://tezos.gitlab.io/api/rpc.html#post-block-id-context-contracts-contract-id-big-map-get
|
|
257
211
|
*/
|
|
258
|
-
|
|
259
|
-
// tslint:disable-next-line: deprecation
|
|
212
|
+
bigMap(key) {
|
|
260
213
|
return this.storageProvider.getBigMapKey(this.address, key, this.schema);
|
|
261
|
-
}
|
|
262
|
-
|
|
263
|
-
}());
|
|
214
|
+
}
|
|
215
|
+
}
|
|
264
216
|
exports.ContractAbstraction = ContractAbstraction;
|
|
265
217
|
//# sourceMappingURL=contract.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"contract.js","sourceRoot":"","sources":["../../../src/contract/contract.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"contract.js","sourceRoot":"","sources":["../../../src/contract/contract.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,kEAAiF;AAOjF,4CAAgE;AAEhE,wFAAmF;AAInF,qCAA+E;AAE/E,+CAAuC;AAE1B,QAAA,kCAAkC,GAAG,SAAS,CAAC;AAE5D;;GAEG;AACH,MAAa,YAAY;IACvB,YACU,eAA+D,EAC/D,QAA0B,EAC1B,IAAY,EACZ,OAAe,EACf,wBAAyC,EACzC,eAAgC,EAChC,IAAW;QANX,oBAAe,GAAf,eAAe,CAAgD;QAC/D,aAAQ,GAAR,QAAQ,CAAkB;QAC1B,SAAI,GAAJ,IAAI,CAAQ;QACZ,YAAO,GAAP,OAAO,CAAQ;QACf,6BAAwB,GAAxB,wBAAwB,CAAiB;QACzC,oBAAe,GAAf,eAAe,CAAiB;QAChC,SAAI,GAAJ,IAAI,CAAO;IAClB,CAAC;IAEJ;;;;;;;;OAQG;IACG,IAAI,CAAC,mBAA4B;;YACrC,IAAI,aAAa,CAAC;YAElB,4HAA4H;YAC5H,IAAI,mBAAmB,EAAE;gBACvB,aAAa,GAAG,mBAAmB,CAAC;aACrC;iBAAM,IAAI,IAAI,CAAC,OAAO,KAAK,oBAAQ,CAAC,UAAU,EAAE;gBAC/C,aAAa,GAAG,kCAAsB,CAAC,UAAU,CAAC;aACnD;iBAAM,IAAI,IAAI,CAAC,OAAO,KAAK,oBAAQ,CAAC,WAAW,EAAE;gBAChD,aAAa,GAAG,kCAAsB,CAAC,WAAW,CAAC;aACpD;iBAAM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,YAAY,EACZ,IAAI,CACL,CAAC;YACJ,CAAC,CAAC;QACJ,CAAC,CAAC,CAAC;IACL,CAAC;IAED;;OAEG;IACI,OAAO;QACZ,OAAO,IAAI,CAAC,eAAe,CAAC,UAAU,CAAI,IAAI,CAAC,OAAO,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC;IACvE,CAAC;IAED;;;;;;;;;OASG;IACI,MAAM,CAAC,GAAW;QACvB,OAAO,IAAI,CAAC,eAAe,CAAC,YAAY,CAAC,IAAI,CAAC,OAAO,EAAE,GAAG,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC;IAC3E,CAAC;CACF;AA9MD,kDA8MC"}
|
|
@@ -1,50 +1,94 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.InvalidInitParameter = exports.InvalidCodeParameter = exports.InvalidDelegationSource = exports.UndefinedLambdaContractError = exports.InvalidParameterError = void 0;
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
exports.InvalidViewSimulationContext = exports.validateAndExtractFailwith = exports.ViewSimulationError = exports.InvalidViewParameterError = exports.InvalidInitParameter = exports.InvalidCodeParameter = exports.InvalidDelegationSource = exports.UndefinedLambdaContractError = exports.InvalidParameterError = void 0;
|
|
4
|
+
class InvalidParameterError extends Error {
|
|
5
|
+
constructor(smartContractMethodName, sigs, args) {
|
|
6
|
+
super(`${smartContractMethodName} Received ${args.length} arguments while expecting one of the following signatures (${JSON.stringify(sigs)})`);
|
|
6
7
|
this.smartContractMethodName = smartContractMethodName;
|
|
7
8
|
this.sigs = sigs;
|
|
8
9
|
this.args = args;
|
|
9
10
|
this.name = 'Invalid parameters error';
|
|
10
|
-
this.message = smartContractMethodName + " Received " + args.length + " arguments while expecting one of the following signatures (" + JSON.stringify(sigs) + ")";
|
|
11
11
|
}
|
|
12
|
-
|
|
13
|
-
}());
|
|
12
|
+
}
|
|
14
13
|
exports.InvalidParameterError = InvalidParameterError;
|
|
15
|
-
|
|
16
|
-
|
|
14
|
+
class UndefinedLambdaContractError extends Error {
|
|
15
|
+
constructor() {
|
|
16
|
+
super('This might happen if you are using a sandbox. Please provide the address of a lambda contract as a parameter of the read method.');
|
|
17
17
|
this.name = 'Undefined LambdaContract error';
|
|
18
|
-
this.message = "This might happen if you are using a sandbox. Please provide the address of a lambda contract as a parameter of the read method.";
|
|
19
18
|
}
|
|
20
|
-
|
|
21
|
-
}());
|
|
19
|
+
}
|
|
22
20
|
exports.UndefinedLambdaContractError = UndefinedLambdaContractError;
|
|
23
|
-
|
|
24
|
-
|
|
21
|
+
class InvalidDelegationSource extends Error {
|
|
22
|
+
constructor(source) {
|
|
23
|
+
super(`Since Babylon delegation source can no longer be a contract address ${source}. Please use the smart contract abstraction to set your delegate.`);
|
|
25
24
|
this.source = source;
|
|
26
25
|
this.name = 'Invalid delegation source error';
|
|
27
|
-
this.message = "Since Babylon delegation source can no longer be a contract address " + source + ". Please use the smart contract abstraction to set your delegate.";
|
|
28
26
|
}
|
|
29
|
-
|
|
30
|
-
}());
|
|
27
|
+
}
|
|
31
28
|
exports.InvalidDelegationSource = InvalidDelegationSource;
|
|
32
|
-
|
|
33
|
-
|
|
29
|
+
class InvalidCodeParameter extends Error {
|
|
30
|
+
constructor(message, data) {
|
|
31
|
+
super(message);
|
|
34
32
|
this.message = message;
|
|
35
33
|
this.data = data;
|
|
36
34
|
this.name = 'InvalidCodeParameter';
|
|
37
35
|
}
|
|
38
|
-
|
|
39
|
-
}());
|
|
36
|
+
}
|
|
40
37
|
exports.InvalidCodeParameter = InvalidCodeParameter;
|
|
41
|
-
|
|
42
|
-
|
|
38
|
+
class InvalidInitParameter extends Error {
|
|
39
|
+
constructor(message, data) {
|
|
40
|
+
super(message);
|
|
43
41
|
this.message = message;
|
|
44
42
|
this.data = data;
|
|
45
43
|
this.name = 'InvalidInitParameter';
|
|
46
44
|
}
|
|
47
|
-
|
|
48
|
-
}());
|
|
45
|
+
}
|
|
49
46
|
exports.InvalidInitParameter = InvalidInitParameter;
|
|
47
|
+
class InvalidViewParameterError extends Error {
|
|
48
|
+
constructor(smartContractViewName, sigs, args, originalError) {
|
|
49
|
+
super(`Unable to encode the parameter of the view: ${smartContractViewName}. Received ${args} as parameter while expecting one of the following signatures (${JSON.stringify(sigs)})`);
|
|
50
|
+
this.smartContractViewName = smartContractViewName;
|
|
51
|
+
this.sigs = sigs;
|
|
52
|
+
this.args = args;
|
|
53
|
+
this.originalError = originalError;
|
|
54
|
+
this.name = 'Invalid view parameters error';
|
|
55
|
+
this.cause = originalError;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
exports.InvalidViewParameterError = InvalidViewParameterError;
|
|
59
|
+
class ViewSimulationError extends Error {
|
|
60
|
+
constructor(message, originalError) {
|
|
61
|
+
super(message);
|
|
62
|
+
this.message = message;
|
|
63
|
+
this.originalError = originalError;
|
|
64
|
+
this.name = 'ViewSimulationError';
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
exports.ViewSimulationError = ViewSimulationError;
|
|
68
|
+
const validateAndExtractFailwith = (error) => {
|
|
69
|
+
if (isJsonString(error.body)) {
|
|
70
|
+
const parsedError = JSON.parse(error.body);
|
|
71
|
+
if (Array.isArray(parsedError) && 'with' in parsedError[parsedError.length - 1]) {
|
|
72
|
+
return parsedError[parsedError.length - 1].with;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
};
|
|
76
|
+
exports.validateAndExtractFailwith = validateAndExtractFailwith;
|
|
77
|
+
const isJsonString = (str) => {
|
|
78
|
+
try {
|
|
79
|
+
JSON.parse(str);
|
|
80
|
+
}
|
|
81
|
+
catch (e) {
|
|
82
|
+
return false;
|
|
83
|
+
}
|
|
84
|
+
return true;
|
|
85
|
+
};
|
|
86
|
+
class InvalidViewSimulationContext extends Error {
|
|
87
|
+
constructor(info) {
|
|
88
|
+
super(`${info} Please configure the context of the view execution in the executeView method.`);
|
|
89
|
+
this.info = info;
|
|
90
|
+
this.name = 'InvalidViewSimulationContext';
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
exports.InvalidViewSimulationContext = InvalidViewSimulationContext;
|
|
50
94
|
//# sourceMappingURL=errors.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../../../src/contract/errors.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../../../src/contract/errors.ts"],"names":[],"mappings":";;;AAGA,MAAa,qBAAsB,SAAQ,KAAK;IAE9C,YAAmB,uBAA+B,EAAS,IAAW,EAAS,IAAW;QACxF,KAAK,CACH,GAAG,uBAAuB,aACxB,IAAI,CAAC,MACP,+DAA+D,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,GAAG,CACvF,CAAC;QALe,4BAAuB,GAAvB,uBAAuB,CAAQ;QAAS,SAAI,GAAJ,IAAI,CAAO;QAAS,SAAI,GAAJ,IAAI,CAAO;QAD1F,SAAI,GAAG,0BAA0B,CAAC;IAOlC,CAAC;CACF;AATD,sDASC;AAED,MAAa,4BAA6B,SAAQ,KAAK;IAErD;QACE,KAAK,CACH,kIAAkI,CACnI,CAAC;QAJJ,SAAI,GAAG,gCAAgC,CAAC;IAKxC,CAAC;CACF;AAPD,oEAOC;AACD,MAAa,uBAAwB,SAAQ,KAAK;IAGhD,YAAmB,MAAc;QAC/B,KAAK,CACH,uEAAuE,MAAM,mEAAmE,CACjJ,CAAC;QAHe,WAAM,GAAN,MAAM,CAAQ;QAFjC,SAAI,GAAG,iCAAiC,CAAC;IAMzC,CAAC;CACF;AARD,0DAQC;AAED,MAAa,oBAAqB,SAAQ,KAAK;IAE7C,YAAmB,OAAe,EAAkB,IAAS;QAC3D,KAAK,CAAC,OAAO,CAAC,CAAC;QADE,YAAO,GAAP,OAAO,CAAQ;QAAkB,SAAI,GAAJ,IAAI,CAAK;QADtD,SAAI,GAAG,sBAAsB,CAAC;IAGrC,CAAC;CACF;AALD,oDA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