@taquito/tzip16 11.1.0 → 12.0.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 +31 -18
- package/dist/lib/composer.js +5 -4
- package/dist/lib/composer.js.map +1 -1
- package/dist/lib/handlers/http-handler.js +14 -43
- package/dist/lib/handlers/http-handler.js.map +1 -1
- package/dist/lib/handlers/ipfs-handler.js +14 -44
- package/dist/lib/handlers/ipfs-handler.js.map +1 -1
- package/dist/lib/handlers/tezos-storage-handler.js +31 -70
- package/dist/lib/handlers/tezos-storage-handler.js.map +1 -1
- package/dist/lib/metadata-provider.js +36 -71
- package/dist/lib/metadata-provider.js.map +1 -1
- package/dist/lib/tzip16-contract-abstraction.js +72 -155
- package/dist/lib/tzip16-contract-abstraction.js.map +1 -1
- package/dist/lib/tzip16-errors.js +44 -55
- package/dist/lib/tzip16-errors.js.map +1 -1
- package/dist/lib/tzip16-extension.js +9 -10
- package/dist/lib/tzip16-extension.js.map +1 -1
- package/dist/lib/tzip16-utils.js +1 -1
- package/dist/lib/tzip16-utils.js.map +1 -1
- package/dist/lib/version.js +2 -4
- package/dist/lib/version.js.map +1 -1
- package/dist/lib/viewKind/michelson-storage-view.js +98 -196
- package/dist/lib/viewKind/michelson-storage-view.js.map +1 -1
- package/dist/lib/viewKind/viewFactory.js +16 -19
- package/dist/lib/viewKind/viewFactory.js.map +1 -1
- package/dist/taquito-tzip16.es6.js +569 -0
- package/dist/taquito-tzip16.es6.js.map +1 -0
- package/dist/taquito-tzip16.umd.js +326 -522
- package/dist/taquito-tzip16.umd.js.map +1 -1
- package/dist/types/composer.d.ts +1 -1
- package/dist/types/tzip16-errors.d.ts +15 -22
- package/dist/types/viewKind/michelson-storage-view.d.ts +3 -1
- package/dist/types/viewKind/viewFactory.d.ts +2 -2
- package/package.json +27 -27
- package/dist/taquito-tzip16.es5.js +0 -761
- package/dist/taquito-tzip16.es5.js.map +0 -1
|
@@ -8,79 +8,24 @@ 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 __values = (this && this.__values) || function(o) {
|
|
39
|
-
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
|
|
40
|
-
if (m) return m.call(o);
|
|
41
|
-
if (o && typeof o.length === "number") return {
|
|
42
|
-
next: function () {
|
|
43
|
-
if (o && i >= o.length) o = void 0;
|
|
44
|
-
return { value: o && o[i++], done: !o };
|
|
45
|
-
}
|
|
46
|
-
};
|
|
47
|
-
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
|
|
48
|
-
};
|
|
49
|
-
var __read = (this && this.__read) || function (o, n) {
|
|
50
|
-
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
51
|
-
if (!m) return o;
|
|
52
|
-
var i = m.call(o), r, ar = [], e;
|
|
53
|
-
try {
|
|
54
|
-
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
55
|
-
}
|
|
56
|
-
catch (error) { e = { error: error }; }
|
|
57
|
-
finally {
|
|
58
|
-
try {
|
|
59
|
-
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
60
|
-
}
|
|
61
|
-
finally { if (e) throw e.error; }
|
|
62
|
-
}
|
|
63
|
-
return ar;
|
|
64
|
-
};
|
|
65
|
-
var __spread = (this && this.__spread) || function () {
|
|
66
|
-
for (var ar = [], i = 0; i < arguments.length; i++) ar = ar.concat(__read(arguments[i]));
|
|
67
|
-
return ar;
|
|
68
|
-
};
|
|
69
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
70
12
|
exports.MichelsonStorageView = void 0;
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
13
|
+
const michelson_encoder_1 = require("@taquito/michelson-encoder");
|
|
14
|
+
const taquito_1 = require("@taquito/taquito");
|
|
15
|
+
const tzip16_errors_1 = require("../tzip16-errors");
|
|
16
|
+
const taquito_2 = require("@taquito/taquito");
|
|
17
|
+
class MichelsonStorageView {
|
|
18
|
+
constructor(viewName, contract, rpc, readProvider, returnType, code, viewParameterType) {
|
|
75
19
|
this.viewName = viewName;
|
|
76
20
|
this.contract = contract;
|
|
77
21
|
this.rpc = rpc;
|
|
22
|
+
this.readProvider = readProvider;
|
|
78
23
|
this.returnType = returnType;
|
|
79
24
|
this.code = code;
|
|
80
25
|
this.viewParameterType = viewParameterType;
|
|
81
|
-
this.validateArgs =
|
|
82
|
-
|
|
83
|
-
if (!sigs.find(
|
|
26
|
+
this.validateArgs = (args, schema, viewName) => {
|
|
27
|
+
const sigs = schema.ExtractSignatures();
|
|
28
|
+
if (!sigs.find((x) => x.length === args.length)) {
|
|
84
29
|
throw new tzip16_errors_1.InvalidViewParameterError(viewName, sigs, args);
|
|
85
30
|
}
|
|
86
31
|
};
|
|
@@ -90,106 +35,73 @@ var MichelsonStorageView = /** @class */ (function () {
|
|
|
90
35
|
* 'AMOUNT', 'CREATE_CONTRACT', 'SENDER', 'SET_DELEGATE', 'SOURCE', and 'TRANSFER_TOKENS'
|
|
91
36
|
* The method throw an error if an illegal instruction is found
|
|
92
37
|
*/
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
var illegalInstructions = [
|
|
38
|
+
findForbiddenInstructionInViewCode(code) {
|
|
39
|
+
const illegalInstructions = [
|
|
96
40
|
'AMOUNT',
|
|
97
41
|
'CREATE_CONTRACT',
|
|
98
42
|
'SENDER',
|
|
99
43
|
'SET_DELEGATE',
|
|
100
44
|
'SOURCE',
|
|
101
|
-
'TRANSFER_TOKENS'
|
|
45
|
+
'TRANSFER_TOKENS',
|
|
102
46
|
];
|
|
103
|
-
|
|
104
|
-
for (
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
for (var code_1 = (e_2 = void 0, __values(code)), code_1_1 = code_1.next(); !code_1_1.done; code_1_1 = code_1.next()) {
|
|
108
|
-
var instruction = code_1_1.value;
|
|
109
|
-
if (instruction.prim === forbiddenInstruction) {
|
|
110
|
-
throw new tzip16_errors_1.ForbiddenInstructionInViewCode(forbiddenInstruction);
|
|
111
|
-
}
|
|
112
|
-
if (instruction.args && instruction.args.length !== 0) {
|
|
113
|
-
this.findForbiddenInstructionInViewCode(instruction.args);
|
|
114
|
-
}
|
|
115
|
-
}
|
|
47
|
+
for (const forbiddenInstruction of illegalInstructions) {
|
|
48
|
+
for (const instruction of code) {
|
|
49
|
+
if (instruction.prim === forbiddenInstruction) {
|
|
50
|
+
throw new tzip16_errors_1.ForbiddenInstructionInViewCode(forbiddenInstruction);
|
|
116
51
|
}
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
try {
|
|
120
|
-
if (code_1_1 && !code_1_1.done && (_b = code_1.return)) _b.call(code_1);
|
|
121
|
-
}
|
|
122
|
-
finally { if (e_2) throw e_2.error; }
|
|
52
|
+
if (instruction.args && instruction.args.length !== 0) {
|
|
53
|
+
this.findForbiddenInstructionInViewCode(instruction.args);
|
|
123
54
|
}
|
|
124
55
|
}
|
|
125
56
|
}
|
|
126
|
-
|
|
127
|
-
finally {
|
|
128
|
-
try {
|
|
129
|
-
if (illegalInstructions_1_1 && !illegalInstructions_1_1.done && (_a = illegalInstructions_1.return)) _a.call(illegalInstructions_1);
|
|
130
|
-
}
|
|
131
|
-
finally { if (e_1) throw e_1.error; }
|
|
132
|
-
}
|
|
133
|
-
};
|
|
57
|
+
}
|
|
134
58
|
/**
|
|
135
59
|
* @description According to the tzip-16 standard, in the first version of the specification, the instruction SELF should only be used before ADDRESS
|
|
136
60
|
* The method throws an error is the instruction SELF is present, but not followed by ADDRESS
|
|
137
61
|
*/
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
if (
|
|
144
|
-
|
|
145
|
-
var nextInstruction = code[index + 1] ? code[index + 1].prim : undefined;
|
|
146
|
-
if (nextInstruction !== 'ADDRESS') {
|
|
147
|
-
throw new tzip16_errors_1.ForbiddenInstructionInViewCode('the instruction SELF should only be used before ADDRESS');
|
|
148
|
-
}
|
|
149
|
-
}
|
|
150
|
-
if (instruction.args && instruction.args.length !== 0) {
|
|
151
|
-
this.illegalUseOfSelfInstruction(instruction.args);
|
|
62
|
+
illegalUseOfSelfInstruction(code) {
|
|
63
|
+
for (const instruction of code) {
|
|
64
|
+
if (instruction.prim === 'SELF') {
|
|
65
|
+
const index = code.indexOf(instruction);
|
|
66
|
+
const nextInstruction = code[index + 1] ? code[index + 1].prim : undefined;
|
|
67
|
+
if (nextInstruction !== 'ADDRESS') {
|
|
68
|
+
throw new tzip16_errors_1.ForbiddenInstructionInViewCode('the instruction SELF should only be used before ADDRESS');
|
|
152
69
|
}
|
|
153
70
|
}
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
finally {
|
|
157
|
-
try {
|
|
158
|
-
if (code_2_1 && !code_2_1.done && (_a = code_2.return)) _a.call(code_2);
|
|
71
|
+
if (instruction.args && instruction.args.length !== 0) {
|
|
72
|
+
this.illegalUseOfSelfInstruction(instruction.args);
|
|
159
73
|
}
|
|
160
|
-
finally { if (e_3) throw e_3.error; }
|
|
161
74
|
}
|
|
162
|
-
}
|
|
75
|
+
}
|
|
163
76
|
/**
|
|
164
77
|
* @description Loops through the view's code and replace SELF, BALANCE, NOW, and CHAIN_ID with Michelson expressions that match the current context, if applicable.
|
|
165
78
|
*/
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
var instructionsToReplace = {
|
|
79
|
+
adaptViewCodeToContext(code, contractBalance, blockTimeStamp, chainId) {
|
|
80
|
+
const instructionsToReplace = {
|
|
169
81
|
SELF: [
|
|
170
82
|
{ prim: 'PUSH', args: [{ prim: 'address' }, { string: this.contract.address }] },
|
|
171
83
|
{ prim: 'CONTRACT', args: [{ prim: 'unit' }] },
|
|
172
|
-
{ prim: 'IF_NONE', args: [[{ prim: 'UNIT' }, { prim: 'FAILWITH' }], []] }
|
|
84
|
+
{ prim: 'IF_NONE', args: [[{ prim: 'UNIT' }, { prim: 'FAILWITH' }], []] },
|
|
173
85
|
],
|
|
174
86
|
BALANCE: [{ prim: 'PUSH', args: [{ prim: 'mutez' }, { int: contractBalance }] }],
|
|
175
87
|
NOW: [{ prim: 'PUSH', args: [{ prim: 'timestamp' }, { string: blockTimeStamp }] }],
|
|
176
|
-
CHAIN_ID: [{ prim: 'PUSH', args: [{ prim: 'string' }, { string: chainId }] }]
|
|
88
|
+
CHAIN_ID: [{ prim: 'PUSH', args: [{ prim: 'string' }, { string: chainId }] }],
|
|
177
89
|
};
|
|
178
|
-
code.forEach(
|
|
179
|
-
for (
|
|
90
|
+
code.forEach((x, i) => {
|
|
91
|
+
for (const instruction in instructionsToReplace) {
|
|
180
92
|
if (x.prim === instruction) {
|
|
181
93
|
code[i] = Object(instructionsToReplace)[instruction];
|
|
182
94
|
}
|
|
183
95
|
if (x.args && x.args.length !== 0) {
|
|
184
|
-
|
|
96
|
+
this.adaptViewCodeToContext(x.args, contractBalance, blockTimeStamp, chainId);
|
|
185
97
|
}
|
|
186
98
|
}
|
|
187
99
|
});
|
|
188
100
|
return code;
|
|
189
|
-
}
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
101
|
+
}
|
|
102
|
+
formatArgsAndParameter(argView) {
|
|
103
|
+
let args = argView;
|
|
104
|
+
let viewParameterType = this.viewParameterType;
|
|
193
105
|
if (!viewParameterType) {
|
|
194
106
|
viewParameterType = { args: [], prim: 'unit', annots: [] };
|
|
195
107
|
}
|
|
@@ -201,75 +113,65 @@ var MichelsonStorageView = /** @class */ (function () {
|
|
|
201
113
|
throw new tzip16_errors_1.NoParameterExpectedError(this.viewName, argView);
|
|
202
114
|
}
|
|
203
115
|
}
|
|
204
|
-
|
|
116
|
+
const parameterViewSchema = new michelson_encoder_1.ParameterSchema(viewParameterType);
|
|
205
117
|
this.validateArgs(args, parameterViewSchema, this.viewName);
|
|
206
|
-
|
|
207
|
-
return { arg
|
|
208
|
-
}
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
}
|
|
240
|
-
viewScript = {
|
|
241
|
-
script: [
|
|
242
|
-
{ prim: 'parameter', args: [{ prim: 'pair', args: [viewParameterType, storageArgs] }] },
|
|
243
|
-
{ prim: 'storage', args: [{ prim: 'option', args: [this.returnType] }] },
|
|
244
|
-
{
|
|
245
|
-
prim: 'code',
|
|
246
|
-
args: [
|
|
247
|
-
[
|
|
248
|
-
{ prim: 'CAR' },
|
|
249
|
-
code,
|
|
250
|
-
{ prim: 'SOME' },
|
|
251
|
-
{ prim: 'NIL', args: [{ prim: 'operation' }] },
|
|
252
|
-
{ prim: 'PAIR' }
|
|
253
|
-
]
|
|
254
|
-
]
|
|
255
|
-
}
|
|
118
|
+
const arg = parameterViewSchema.Encode(...args);
|
|
119
|
+
return { arg, viewParameterType };
|
|
120
|
+
}
|
|
121
|
+
executeView(...args) {
|
|
122
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
123
|
+
// validate view code against tzip-16 specifications
|
|
124
|
+
this.findForbiddenInstructionInViewCode(this.code);
|
|
125
|
+
this.illegalUseOfSelfInstruction(this.code);
|
|
126
|
+
const { arg, viewParameterType } = this.formatArgsAndParameter(args);
|
|
127
|
+
const storageType = this.contract.script.code.find((x) => x.prim === 'storage');
|
|
128
|
+
const storageArgs = storageType.args[0];
|
|
129
|
+
// currentContext
|
|
130
|
+
const storageValue = yield this.readProvider.getStorage(this.contract.address, 'head');
|
|
131
|
+
const chainId = yield this.readProvider.getChainId();
|
|
132
|
+
const contractBalance = (yield this.readProvider.getBalance(this.contract.address, 'head')).toString();
|
|
133
|
+
const blockTimestamp = yield this.readProvider.getBlockTimestamp('head');
|
|
134
|
+
const code = this.adaptViewCodeToContext(this.code, contractBalance, blockTimestamp, chainId);
|
|
135
|
+
if (!this.viewParameterType) {
|
|
136
|
+
code.unshift({ prim: 'CDR' });
|
|
137
|
+
}
|
|
138
|
+
const viewScript = {
|
|
139
|
+
script: [
|
|
140
|
+
{ prim: 'parameter', args: [{ prim: 'pair', args: [viewParameterType, storageArgs] }] },
|
|
141
|
+
{ prim: 'storage', args: [{ prim: 'option', args: [this.returnType] }] },
|
|
142
|
+
{
|
|
143
|
+
prim: 'code',
|
|
144
|
+
args: [
|
|
145
|
+
[
|
|
146
|
+
{ prim: 'CAR' },
|
|
147
|
+
code,
|
|
148
|
+
{ prim: 'SOME' },
|
|
149
|
+
{ prim: 'NIL', args: [{ prim: 'operation' }] },
|
|
150
|
+
{ prim: 'PAIR' },
|
|
256
151
|
],
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
}
|
|
152
|
+
],
|
|
153
|
+
},
|
|
154
|
+
],
|
|
155
|
+
storage: { prim: 'None' },
|
|
156
|
+
input: { prim: 'Pair', args: [arg, storageValue] },
|
|
157
|
+
amount: '0',
|
|
158
|
+
chain_id: chainId,
|
|
159
|
+
balance: '0',
|
|
160
|
+
};
|
|
161
|
+
let result;
|
|
162
|
+
try {
|
|
163
|
+
result = yield this.rpc.runCode(viewScript);
|
|
164
|
+
}
|
|
165
|
+
catch (error) {
|
|
166
|
+
const failWith = taquito_2.validateAndExtractFailwith(error);
|
|
167
|
+
throw failWith
|
|
168
|
+
? new taquito_1.ViewSimulationError(`The simulation of the Michelson view failed with: ${JSON.stringify(failWith)}`, this.viewName, failWith, error)
|
|
169
|
+
: error;
|
|
170
|
+
}
|
|
171
|
+
const viewResultSchema = new michelson_encoder_1.ParameterSchema(this.returnType);
|
|
172
|
+
return viewResultSchema.Execute(result.storage.args[0]);
|
|
270
173
|
});
|
|
271
|
-
}
|
|
272
|
-
|
|
273
|
-
}());
|
|
174
|
+
}
|
|
175
|
+
}
|
|
274
176
|
exports.MichelsonStorageView = MichelsonStorageView;
|
|
275
177
|
//# sourceMappingURL=michelson-storage-view.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"michelson-storage-view.js","sourceRoot":"","sources":["../../../src/viewKind/michelson-storage-view.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"michelson-storage-view.js","sourceRoot":"","sources":["../../../src/viewKind/michelson-storage-view.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,kEAA6D;AAM7D,8CAK0B;AAC1B,oDAI0B;AAC1B,8CAA8E;AAG9E,MAAa,oBAAoB;IAC/B,YACU,QAAgB,EAChB,QAAwD,EACxD,GAAuB,EACvB,YAA4B,EAC5B,UAAiC,EACjC,IAAqC,EACrC,iBAAiD;QANjD,aAAQ,GAAR,QAAQ,CAAQ;QAChB,aAAQ,GAAR,QAAQ,CAAgD;QACxD,QAAG,GAAH,GAAG,CAAoB;QACvB,iBAAY,GAAZ,YAAY,CAAgB;QAC5B,eAAU,GAAV,UAAU,CAAuB;QACjC,SAAI,GAAJ,IAAI,CAAiC;QACrC,sBAAiB,GAAjB,iBAAiB,CAAgC;QAoFnD,iBAAY,GAAG,CAAC,IAAW,EAAE,MAAuB,EAAE,QAAgB,EAAE,EAAE;YAChF,MAAM,IAAI,GAAG,MAAM,CAAC,iBAAiB,EAAE,CAAC;YAExC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAQ,EAAE,EAAE,CAAC,CAAC,CAAC,MAAM,KAAK,IAAI,CAAC,MAAM,CAAC,EA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,KAAK,CAAC;aACX;YAED,MAAM,gBAAgB,GAAG,IAAI,mCAAe,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;YAC9D,OAAO,gBAAgB,CAAC,OAAO,CAAC,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;QAC1D,CAAC;KAAA;CACF;AA3LD,oDA2LC"}
|
|
@@ -1,31 +1,28 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.ViewFactory = void 0;
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
}
|
|
9
|
-
ViewFactory.prototype.getView = function (viewName, rpc, contract, viewImplementation) {
|
|
4
|
+
const metadata_interface_1 = require("../metadata-interface");
|
|
5
|
+
const michelson_storage_view_1 = require("./michelson-storage-view");
|
|
6
|
+
class ViewFactory {
|
|
7
|
+
getView(viewName, rpc, readProvider, contract, viewImplementation) {
|
|
10
8
|
if (this.isMichelsonStorageView(viewImplementation)) {
|
|
11
|
-
|
|
12
|
-
if (!
|
|
13
|
-
console.warn(viewName
|
|
9
|
+
const viewValues = viewImplementation[metadata_interface_1.ViewImplementationType.MICHELSON_STORAGE];
|
|
10
|
+
if (!viewValues.returnType || !viewValues.code) {
|
|
11
|
+
console.warn(`${viewName} is missing mandatory code or returnType property therefore it will be skipped.`);
|
|
14
12
|
return;
|
|
15
13
|
}
|
|
16
|
-
return
|
|
17
|
-
|
|
14
|
+
return () => {
|
|
15
|
+
const view = new michelson_storage_view_1.MichelsonStorageView(viewName, contract, rpc, readProvider, viewValues.returnType, viewValues.code, viewValues.parameter);
|
|
18
16
|
return view;
|
|
19
17
|
};
|
|
20
18
|
}
|
|
21
|
-
}
|
|
22
|
-
|
|
19
|
+
}
|
|
20
|
+
getImplementationType(viewImplementation) {
|
|
23
21
|
return Object.keys(viewImplementation)[0];
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
return this.getImplementationType(viewImplementation) === metadata_interface_1.ViewImplementationType.MICHELSON_STORAGE;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
}());
|
|
22
|
+
}
|
|
23
|
+
isMichelsonStorageView(viewImplementation) {
|
|
24
|
+
return (this.getImplementationType(viewImplementation) === metadata_interface_1.ViewImplementationType.MICHELSON_STORAGE);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
30
27
|
exports.ViewFactory = ViewFactory;
|
|
31
28
|
//# sourceMappingURL=viewFactory.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"viewFactory.js","sourceRoot":"","sources":["../../../src/viewKind/viewFactory.ts"],"names":[],"mappings":";;;AAEA,
|
|
1
|
+
{"version":3,"file":"viewFactory.js","sourceRoot":"","sources":["../../../src/viewKind/viewFactory.ts"],"names":[],"mappings":";;;AAEA,8DAAmF;AACnF,qEAAgE;AAEhE,MAAa,WAAW;IACtB,OAAO,CACL,QAAgB,EAChB,GAAuB,EACvB,YAA4B,EAC5B,QAAwD,EACxD,kBAAsC;QAEtC,IAAI,IAAI,CAAC,sBAAsB,CAAC,kBAAkB,CAAC,EAAE;YACnD,MAAM,UAAU,GAAG,kBAAkB,CAAC,2CAAsB,CAAC,iBAAiB,CAAC,CAAC;YAChF,IAAI,CAAC,UAAU,CAAC,UAAU,IAAI,CAAC,UAAU,CAAC,IAAI,EAAE;gBAC9C,OAAO,CAAC,IAAI,CACV,GAAG,QAAQ,iFAAiF,CAC7F,CAAC;gBACF,OAAO;aACR;YACD,OAAO,GAAG,EAAE;gBACV,MAAM,IAAI,GAAG,IAAI,6CAAoB,CACnC,QAAQ,EACR,QAAQ,EACR,GAAG,EACH,YAAY,EACZ,UAAU,CAAC,UAAiB,EAC5B,UAAU,CAAC,IAAW,EACtB,UAAU,CAAC,SAAgB,CAC5B,CAAC;gBACF,OAAO,IAAI,CAAC;YACd,CAAC,CAAC;SACH;IACH,CAAC;IAED,qBAAqB,CAAC,kBAAsC;QAC1D,OAAO,MAAM,CAAC,IAAI,CAAC,kBAAkB,CAAC,CAAC,CAAC,CAAC,CAAC;IAC5C,CAAC;IAEO,sBAAsB,CAC5B,kBAAsC;QAEtC,OAAO,CACL,IAAI,CAAC,qBAAqB,CAAC,kBAAkB,CAAC,KAAK,2CAAsB,CAAC,iBAAiB,CAC5F,CAAC;IACJ,CAAC;CACF;AA1CD,kCA0CC"}
|