@taquito/tzip16 11.2.0 → 12.0.1
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/dist/lib/handlers/http-handler.js +3 -1
- package/dist/lib/handlers/http-handler.js.map +1 -1
- package/dist/lib/handlers/ipfs-handler.js +3 -2
- package/dist/lib/handlers/ipfs-handler.js.map +1 -1
- package/dist/lib/handlers/tezos-storage-handler.js +2 -2
- package/dist/lib/handlers/tezos-storage-handler.js.map +1 -1
- package/dist/lib/tzip16-contract-abstraction.js +9 -7
- package/dist/lib/tzip16-contract-abstraction.js.map +1 -1
- package/dist/lib/version.js +2 -2
- package/dist/lib/viewKind/michelson-storage-view.js +6 -6
- package/dist/lib/viewKind/michelson-storage-view.js.map +1 -1
- package/dist/lib/viewKind/viewFactory.js +3 -3
- package/dist/lib/viewKind/viewFactory.js.map +1 -1
- package/dist/taquito-tzip16.es6.js +28 -23
- package/dist/taquito-tzip16.es6.js.map +1 -1
- package/dist/taquito-tzip16.umd.js +28 -23
- package/dist/taquito-tzip16.umd.js.map +1 -1
- package/dist/types/viewKind/michelson-storage-view.d.ts +3 -1
- package/dist/types/viewKind/viewFactory.d.ts +2 -2
- package/package.json +8 -8
|
@@ -20,7 +20,9 @@ class HttpHandler {
|
|
|
20
20
|
return this.httpBackend.createRequest({
|
|
21
21
|
url: `${protocol}:${decodeURIComponent(location)}`,
|
|
22
22
|
method: 'GET',
|
|
23
|
-
|
|
23
|
+
headers: {
|
|
24
|
+
'Content-Type': 'text/plain; charset=utf-8'
|
|
25
|
+
},
|
|
24
26
|
json: false
|
|
25
27
|
});
|
|
26
28
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"http-handler.js","sourceRoot":"","sources":["../../../src/handlers/http-handler.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,oDAAkD;AAIlD,MAAa,WAAW;IAEpB;QACI,IAAI,CAAC,WAAW,GAAG,IAAI,wBAAW,EAAE,CAAC;IACzC,CAAC;IACK,WAAW,CAAC,oBAAoE,EAAE,EAAE,QAAQ,EAAE,QAAQ,EAAa,EAAE,QAAiB;;YACxI,OAAO,IAAI,CAAC,WAAW,CAAC,aAAa,CAAS;gBAC1C,GAAG,EAAE,GAAG,QAAQ,IAAI,kBAAkB,CAAC,QAAQ,CAAC,EAAE;gBAClD,MAAM,EAAE,KAAK;gBACb,
|
|
1
|
+
{"version":3,"file":"http-handler.js","sourceRoot":"","sources":["../../../src/handlers/http-handler.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,oDAAkD;AAIlD,MAAa,WAAW;IAEpB;QACI,IAAI,CAAC,WAAW,GAAG,IAAI,wBAAW,EAAE,CAAC;IACzC,CAAC;IACK,WAAW,CAAC,oBAAoE,EAAE,EAAE,QAAQ,EAAE,QAAQ,EAAa,EAAE,QAAiB;;YACxI,OAAO,IAAI,CAAC,WAAW,CAAC,aAAa,CAAS;gBAC1C,GAAG,EAAE,GAAG,QAAQ,IAAI,kBAAkB,CAAC,QAAQ,CAAC,EAAE;gBAClD,MAAM,EAAE,KAAK;gBACb,OAAO,EAAE;oBACP,cAAc,EAAE,2BAA2B;iBAC5C;gBACD,IAAI,EAAE,KAAK;aACd,CAAC,CAAA;QACN,CAAC;KAAA;CACJ;AAfD,kCAeC"}
|
|
@@ -21,8 +21,9 @@ class IpfsHttpHandler {
|
|
|
21
21
|
return this.httpBackend.createRequest({
|
|
22
22
|
url: `https://${this._ipfsGateway}/ipfs/${location.substring(2)}/`,
|
|
23
23
|
method: 'GET',
|
|
24
|
-
headers: {
|
|
25
|
-
|
|
24
|
+
headers: {
|
|
25
|
+
'Content-Type': 'text/plain; charset=utf-8'
|
|
26
|
+
},
|
|
26
27
|
json: false
|
|
27
28
|
});
|
|
28
29
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ipfs-handler.js","sourceRoot":"","sources":["../../../src/handlers/ipfs-handler.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,oDAAkD;AAIlD,MAAa,eAAe;IAIxB,YAAY,YAAoB;QAFzB,gBAAW,GAAG,IAAI,wBAAW,EAAE,CAAC;QAGnC,IAAI,CAAC,YAAY,GAAG,YAAY,CAAA,CAAC,CAAC,YAAY,CAAA,CAAC,CAAC,SAAS,CAAC;IAC9D,CAAC;IAEK,WAAW,CAAC,oBAAoE,EAAE,EAAE,QAAQ,EAAa,EAAE,QAAiB;;YAC9H,OAAO,IAAI,CAAC,WAAW,CAAC,aAAa,CAAS;gBAC1C,GAAG,EAAE,WAAW,IAAI,CAAC,YAAY,SAAS,QAAQ,CAAC,SAAS,CAAC,CAAC,CAAC,GAAG;gBAClE,MAAM,EAAE,KAAK;gBACb,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"ipfs-handler.js","sourceRoot":"","sources":["../../../src/handlers/ipfs-handler.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,oDAAkD;AAIlD,MAAa,eAAe;IAIxB,YAAY,YAAoB;QAFzB,gBAAW,GAAG,IAAI,wBAAW,EAAE,CAAC;QAGnC,IAAI,CAAC,YAAY,GAAG,YAAY,CAAA,CAAC,CAAC,YAAY,CAAA,CAAC,CAAC,SAAS,CAAC;IAC9D,CAAC;IAEK,WAAW,CAAC,oBAAoE,EAAE,EAAE,QAAQ,EAAa,EAAE,QAAiB;;YAC9H,OAAO,IAAI,CAAC,WAAW,CAAC,aAAa,CAAS;gBAC1C,GAAG,EAAE,WAAW,IAAI,CAAC,YAAY,SAAS,QAAQ,CAAC,SAAS,CAAC,CAAC,CAAC,GAAG;gBAClE,MAAM,EAAE,KAAK;gBACb,OAAO,EAAE;oBACP,cAAc,EAAE,2BAA2B;iBAC5C;gBACD,IAAI,EAAE,KAAK;aACd,CAAC,CAAA;QACN,CAAC;KAAA;CACJ;AAlBD,0CAkBC"}
|
|
@@ -28,8 +28,8 @@ class TezosStorageHandler {
|
|
|
28
28
|
if (!parsedTezosStorageUri) {
|
|
29
29
|
throw new tzip16_errors_1.InvalidUri(`tezos-storage:${location}`);
|
|
30
30
|
}
|
|
31
|
-
const
|
|
32
|
-
const bigMapId = michelson_encoder_1.Schema.fromRPCResponse({ script
|
|
31
|
+
const script = yield context.readProvider.getScript(parsedTezosStorageUri.contractAddress || contractAbstraction.address, 'head');
|
|
32
|
+
const bigMapId = michelson_encoder_1.Schema.fromRPCResponse({ script }).FindFirstInTopLevelPair(script.storage, typeOfValueToFind);
|
|
33
33
|
if (!bigMapId) {
|
|
34
34
|
throw new tzip16_errors_1.BigMapMetadataNotFound();
|
|
35
35
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tezos-storage-handler.js","sourceRoot":"","sources":["../../../src/handlers/tezos-storage-handler.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,kEAAoD;AAGpD,0CAA4C;AAC5C,oDAK0B;AAE1B,MAAM,iBAAiB,GAAG;IACxB,IAAI,EAAE,SAAS;IACf,IAAI,EAAE,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;IAC7C,MAAM,EAAE,CAAC,WAAW,CAAC;CACtB,CAAC;AAIF,MAAa,mBAAmB;IAAhC;QACmB,wBAAmB,GAAG,8CAA8C,CAAC;
|
|
1
|
+
{"version":3,"file":"tezos-storage-handler.js","sourceRoot":"","sources":["../../../src/handlers/tezos-storage-handler.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,kEAAoD;AAGpD,0CAA4C;AAC5C,oDAK0B;AAE1B,MAAM,iBAAiB,GAAG;IACxB,IAAI,EAAE,SAAS;IACf,IAAI,EAAE,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;IAC7C,MAAM,EAAE,CAAC,WAAW,CAAC;CACtB,CAAC;AAIF,MAAa,mBAAmB;IAAhC;QACmB,wBAAmB,GAAG,8CAA8C,CAAC;IA0DxF,CAAC;IAxDO,WAA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C;QACjE,IAAI,CAAC,SAAS;YAAE,OAAO;QACvB,OAAO;YACL,eAAe,EAAE,SAAS,CAAC,CAAC,CAAC;YAC7B,OAAO,EAAE,SAAS,CAAC,CAAC,CAAC;YACrB,IAAI,EAAE,kBAAkB,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC;SACvC,CAAC;IACJ,CAAC;CACF;AA3DD,kDA2DC"}
|
|
@@ -30,15 +30,17 @@ class Tzip16ContractAbstraction {
|
|
|
30
30
|
this._metadataProvider = context.metadataProvider;
|
|
31
31
|
}
|
|
32
32
|
findMetadataBigMap() {
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
33
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
34
|
+
const metadataBigMapId = this.constractAbstraction.schema.FindFirstInTopLevelPair(yield this.context.readProvider.getStorage(this.constractAbstraction.address, 'head'), metadataBigMapType);
|
|
35
|
+
if (!metadataBigMapId) {
|
|
36
|
+
throw new tzip16_errors_1.BigMapMetadataNotFound();
|
|
37
|
+
}
|
|
38
|
+
return new taquito_1.BigMapAbstraction(new bignumber_js_1.default(metadataBigMapId['int']), new michelson_encoder_1.Schema(metadataBigMapType), this.context.contract);
|
|
39
|
+
});
|
|
38
40
|
}
|
|
39
41
|
getUriOrFail() {
|
|
40
42
|
return __awaiter(this, void 0, void 0, function* () {
|
|
41
|
-
const metadataBigMap = this.findMetadataBigMap();
|
|
43
|
+
const metadataBigMap = yield this.findMetadataBigMap();
|
|
42
44
|
const uri = yield metadataBigMap.get('');
|
|
43
45
|
if (!uri) {
|
|
44
46
|
throw new tzip16_errors_1.UriNotFound();
|
|
@@ -94,7 +96,7 @@ class Tzip16ContractAbstraction {
|
|
|
94
96
|
if (view.name) {
|
|
95
97
|
// when views have the same name, add an index at the end of the name
|
|
96
98
|
const viewName = this.generateIndexedViewName(view.name, metadataViews);
|
|
97
|
-
const metadataView = this._viewFactory.getView(viewName, this.context.rpc, this.constractAbstraction, viewImplementation);
|
|
99
|
+
const metadataView = this._viewFactory.getView(viewName, this.context.rpc, this.context.readProvider, this.constractAbstraction, viewImplementation);
|
|
98
100
|
if (metadataView) {
|
|
99
101
|
metadataViews[viewName] = metadataView;
|
|
100
102
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tzip16-contract-abstraction.js","sourceRoot":"","sources":["../../src/tzip16-contract-abstraction.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,8CAM0B;AAC1B,0CAA4C;AAE5C,mDAIyB;AACzB,+CAAqC;AACrC,kEAAoD;AACpD,wDAAqD;AAUrD,MAAM,kBAAkB,GAAG;IACzB,IAAI,EAAE,SAAS;IACf,IAAI,EAAE,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;IAC7C,MAAM,EAAE,CAAC,WAAW,CAAC;CACtB,CAAC;AACF,MAAa,yBAAyB;IAMpC,YACU,oBAAoE,EACpE,OAAwB;QADxB,yBAAoB,GAApB,oBAAoB,CAAgD;QACpE,YAAO,GAAP,OAAO,CAAiB;QAL1B,iBAAY,GAAG,IAAI,yBAAW,EAAE,CAAC;QACjC,yBAAoB,GAAkC,EAAE,CAAC;QAM/D,IAAI,CAAC,iBAAiB,GAAG,OAAO,CAAC,gBAAgB,CAAC;IACpD,CAAC;
|
|
1
|
+
{"version":3,"file":"tzip16-contract-abstraction.js","sourceRoot":"","sources":["../../src/tzip16-contract-abstraction.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,8CAM0B;AAC1B,0CAA4C;AAE5C,mDAIyB;AACzB,+CAAqC;AACrC,kEAAoD;AACpD,wDAAqD;AAUrD,MAAM,kBAAkB,GAAG;IACzB,IAAI,EAAE,SAAS;IACf,IAAI,EAAE,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;IAC7C,MAAM,EAAE,CAAC,WAAW,CAAC;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AE;YAC5D,IAAI,IAAI,CAAC,IAAI,EAAE;gBACb,qEAAqE;gBACrE,MAAM,QAAQ,GAAG,IAAI,CAAC,uBAAuB,CAAC,IAAI,CAAC,IAAI,EAAE,aAAa,CAAC,CAAC;gBACxE,MAAM,YAAY,GAAG,IAAI,CAAC,YAAY,CAAC,OAAO,CAC5C,QAAQ,EACR,IAAI,CAAC,OAAO,CAAC,GAAG,EAChB,IAAI,CAAC,OAAO,CAAC,YAAY,EACzB,IAAI,CAAC,oBAAoB,EACzB,kBAAkB,CACnB,CAAC;gBACF,IAAI,YAAY,EAAE;oBAChB,aAAa,CAAC,QAAQ,CAAC,GAAG,YAAY,CAAC;iBACxC;qBAAM;oBACL,OAAO,CAAC,IAAI,CACV,sBAAsB,QAAQ,8CAA8C,IAAI,CAAC,YAAY,CAAC,qBAAqB,CACjH,kBAAkB,CACnB,EAAE,CACJ,CAAC;iBACH;aACF;SACF;IACH,CAAC;CACF;AA1GD,8DA0GC"}
|
package/dist/lib/version.js
CHANGED
|
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.VERSION = void 0;
|
|
4
4
|
// IMPORTANT: THIS FILE IS AUTO GENERATED! DO NOT MANUALLY EDIT OR CHECKIN!
|
|
5
5
|
exports.VERSION = {
|
|
6
|
-
"commitHash": "
|
|
7
|
-
"version": "
|
|
6
|
+
"commitHash": "8203ea7669c742797022f1b61f2577bcac50ca55",
|
|
7
|
+
"version": "12.0.1"
|
|
8
8
|
};
|
|
9
9
|
//# sourceMappingURL=version.js.map
|
|
@@ -15,10 +15,11 @@ const taquito_1 = require("@taquito/taquito");
|
|
|
15
15
|
const tzip16_errors_1 = require("../tzip16-errors");
|
|
16
16
|
const taquito_2 = require("@taquito/taquito");
|
|
17
17
|
class MichelsonStorageView {
|
|
18
|
-
constructor(viewName, contract, rpc, returnType, code, viewParameterType) {
|
|
18
|
+
constructor(viewName, contract, rpc, readProvider, returnType, code, viewParameterType) {
|
|
19
19
|
this.viewName = viewName;
|
|
20
20
|
this.contract = contract;
|
|
21
21
|
this.rpc = rpc;
|
|
22
|
+
this.readProvider = readProvider;
|
|
22
23
|
this.returnType = returnType;
|
|
23
24
|
this.code = code;
|
|
24
25
|
this.viewParameterType = viewParameterType;
|
|
@@ -125,12 +126,11 @@ class MichelsonStorageView {
|
|
|
125
126
|
const { arg, viewParameterType } = this.formatArgsAndParameter(args);
|
|
126
127
|
const storageType = this.contract.script.code.find((x) => x.prim === 'storage');
|
|
127
128
|
const storageArgs = storageType.args[0];
|
|
128
|
-
const storageValue = this.contract.script.storage;
|
|
129
129
|
// currentContext
|
|
130
|
-
const
|
|
131
|
-
const
|
|
132
|
-
const
|
|
133
|
-
const blockTimestamp =
|
|
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
134
|
const code = this.adaptViewCodeToContext(this.code, contractBalance, blockTimestamp, chainId);
|
|
135
135
|
if (!this.viewParameterType) {
|
|
136
136
|
code.unshift({ prim: 'CDR' });
|
|
@@ -1 +1 @@
|
|
|
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,
|
|
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,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AAC,GAAG,EAAE,YAAY,CAAC,EAAE;gBAClD,MAAM,EAAE,GAAG;gBACX,QAAQ,EAAE,OAAO;gBACjB,OAAO,EAAE,GAAG;aACb,CAAC;YAEF,IAAI,MAAW,CAAC;YAChB,IAAI;gBACF,MAAM,GAAG,MAAM,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,UAAiB,CAAC,CAAC;aACpD;YAAC,OAAO,KAAU,EAAE;gBACnB,MAAM,QAAQ,GAAG,oCAA0B,CAAC,KAAK,CAAC,CAAC;gBACnD,MAAM,QAAQ;oBACZ,CAAC,CAAC,IAAI,6BAAmB,CACrB,qDAAqD,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,EAAE,EAC/E,IAAI,CAAC,QAAQ,EACb,QAAQ,EACR,KAAK,CACN;oBACH,CAAC,CAAC,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"}
|
|
@@ -4,7 +4,7 @@ exports.ViewFactory = void 0;
|
|
|
4
4
|
const metadata_interface_1 = require("../metadata-interface");
|
|
5
5
|
const michelson_storage_view_1 = require("./michelson-storage-view");
|
|
6
6
|
class ViewFactory {
|
|
7
|
-
getView(viewName, rpc, contract, viewImplementation) {
|
|
7
|
+
getView(viewName, rpc, readProvider, contract, viewImplementation) {
|
|
8
8
|
if (this.isMichelsonStorageView(viewImplementation)) {
|
|
9
9
|
const viewValues = viewImplementation[metadata_interface_1.ViewImplementationType.MICHELSON_STORAGE];
|
|
10
10
|
if (!viewValues.returnType || !viewValues.code) {
|
|
@@ -12,7 +12,7 @@ class ViewFactory {
|
|
|
12
12
|
return;
|
|
13
13
|
}
|
|
14
14
|
return () => {
|
|
15
|
-
const view = new michelson_storage_view_1.MichelsonStorageView(viewName, contract, rpc, viewValues.returnType, viewValues.code, viewValues.parameter);
|
|
15
|
+
const view = new michelson_storage_view_1.MichelsonStorageView(viewName, contract, rpc, readProvider, viewValues.returnType, viewValues.code, viewValues.parameter);
|
|
16
16
|
return view;
|
|
17
17
|
};
|
|
18
18
|
}
|
|
@@ -21,7 +21,7 @@ class ViewFactory {
|
|
|
21
21
|
return Object.keys(viewImplementation)[0];
|
|
22
22
|
}
|
|
23
23
|
isMichelsonStorageView(viewImplementation) {
|
|
24
|
-
return this.getImplementationType(viewImplementation) === metadata_interface_1.ViewImplementationType.MICHELSON_STORAGE;
|
|
24
|
+
return (this.getImplementationType(viewImplementation) === metadata_interface_1.ViewImplementationType.MICHELSON_STORAGE);
|
|
25
25
|
}
|
|
26
26
|
}
|
|
27
27
|
exports.ViewFactory = ViewFactory;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"viewFactory.js","sourceRoot":"","sources":["../../../src/viewKind/viewFactory.ts"],"names":[],"mappings":";;;AAEA,8DAAmF;AACnF,qEAAgE;AAEhE,MAAa,WAAW;
|
|
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"}
|
|
@@ -40,7 +40,9 @@ class HttpHandler {
|
|
|
40
40
|
return this.httpBackend.createRequest({
|
|
41
41
|
url: `${protocol}:${decodeURIComponent(location)}`,
|
|
42
42
|
method: 'GET',
|
|
43
|
-
|
|
43
|
+
headers: {
|
|
44
|
+
'Content-Type': 'text/plain; charset=utf-8'
|
|
45
|
+
},
|
|
44
46
|
json: false
|
|
45
47
|
});
|
|
46
48
|
});
|
|
@@ -139,8 +141,8 @@ class TezosStorageHandler {
|
|
|
139
141
|
if (!parsedTezosStorageUri) {
|
|
140
142
|
throw new InvalidUri(`tezos-storage:${location}`);
|
|
141
143
|
}
|
|
142
|
-
const
|
|
143
|
-
const bigMapId = Schema.fromRPCResponse({ script
|
|
144
|
+
const script = yield context.readProvider.getScript(parsedTezosStorageUri.contractAddress || contractAbstraction.address, 'head');
|
|
145
|
+
const bigMapId = Schema.fromRPCResponse({ script }).FindFirstInTopLevelPair(script.storage, typeOfValueToFind);
|
|
144
146
|
if (!bigMapId) {
|
|
145
147
|
throw new BigMapMetadataNotFound();
|
|
146
148
|
}
|
|
@@ -181,8 +183,9 @@ class IpfsHttpHandler {
|
|
|
181
183
|
return this.httpBackend.createRequest({
|
|
182
184
|
url: `https://${this._ipfsGateway}/ipfs/${location.substring(2)}/`,
|
|
183
185
|
method: 'GET',
|
|
184
|
-
headers: {
|
|
185
|
-
|
|
186
|
+
headers: {
|
|
187
|
+
'Content-Type': 'text/plain; charset=utf-8'
|
|
188
|
+
},
|
|
186
189
|
json: false
|
|
187
190
|
});
|
|
188
191
|
});
|
|
@@ -196,10 +199,11 @@ var ViewImplementationType;
|
|
|
196
199
|
})(ViewImplementationType || (ViewImplementationType = {}));
|
|
197
200
|
|
|
198
201
|
class MichelsonStorageView {
|
|
199
|
-
constructor(viewName, contract, rpc, returnType, code, viewParameterType) {
|
|
202
|
+
constructor(viewName, contract, rpc, readProvider, returnType, code, viewParameterType) {
|
|
200
203
|
this.viewName = viewName;
|
|
201
204
|
this.contract = contract;
|
|
202
205
|
this.rpc = rpc;
|
|
206
|
+
this.readProvider = readProvider;
|
|
203
207
|
this.returnType = returnType;
|
|
204
208
|
this.code = code;
|
|
205
209
|
this.viewParameterType = viewParameterType;
|
|
@@ -306,12 +310,11 @@ class MichelsonStorageView {
|
|
|
306
310
|
const { arg, viewParameterType } = this.formatArgsAndParameter(args);
|
|
307
311
|
const storageType = this.contract.script.code.find((x) => x.prim === 'storage');
|
|
308
312
|
const storageArgs = storageType.args[0];
|
|
309
|
-
const storageValue = this.contract.script.storage;
|
|
310
313
|
// currentContext
|
|
311
|
-
const
|
|
312
|
-
const
|
|
313
|
-
const
|
|
314
|
-
const blockTimestamp =
|
|
314
|
+
const storageValue = yield this.readProvider.getStorage(this.contract.address, 'head');
|
|
315
|
+
const chainId = yield this.readProvider.getChainId();
|
|
316
|
+
const contractBalance = (yield this.readProvider.getBalance(this.contract.address, 'head')).toString();
|
|
317
|
+
const blockTimestamp = yield this.readProvider.getBlockTimestamp('head');
|
|
315
318
|
const code = this.adaptViewCodeToContext(this.code, contractBalance, blockTimestamp, chainId);
|
|
316
319
|
if (!this.viewParameterType) {
|
|
317
320
|
code.unshift({ prim: 'CDR' });
|
|
@@ -356,7 +359,7 @@ class MichelsonStorageView {
|
|
|
356
359
|
}
|
|
357
360
|
|
|
358
361
|
class ViewFactory {
|
|
359
|
-
getView(viewName, rpc, contract, viewImplementation) {
|
|
362
|
+
getView(viewName, rpc, readProvider, contract, viewImplementation) {
|
|
360
363
|
if (this.isMichelsonStorageView(viewImplementation)) {
|
|
361
364
|
const viewValues = viewImplementation[ViewImplementationType.MICHELSON_STORAGE];
|
|
362
365
|
if (!viewValues.returnType || !viewValues.code) {
|
|
@@ -364,7 +367,7 @@ class ViewFactory {
|
|
|
364
367
|
return;
|
|
365
368
|
}
|
|
366
369
|
return () => {
|
|
367
|
-
const view = new MichelsonStorageView(viewName, contract, rpc, viewValues.returnType, viewValues.code, viewValues.parameter);
|
|
370
|
+
const view = new MichelsonStorageView(viewName, contract, rpc, readProvider, viewValues.returnType, viewValues.code, viewValues.parameter);
|
|
368
371
|
return view;
|
|
369
372
|
};
|
|
370
373
|
}
|
|
@@ -373,7 +376,7 @@ class ViewFactory {
|
|
|
373
376
|
return Object.keys(viewImplementation)[0];
|
|
374
377
|
}
|
|
375
378
|
isMichelsonStorageView(viewImplementation) {
|
|
376
|
-
return this.getImplementationType(viewImplementation) === ViewImplementationType.MICHELSON_STORAGE;
|
|
379
|
+
return (this.getImplementationType(viewImplementation) === ViewImplementationType.MICHELSON_STORAGE);
|
|
377
380
|
}
|
|
378
381
|
}
|
|
379
382
|
|
|
@@ -391,15 +394,17 @@ class Tzip16ContractAbstraction {
|
|
|
391
394
|
this._metadataProvider = context.metadataProvider;
|
|
392
395
|
}
|
|
393
396
|
findMetadataBigMap() {
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
397
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
398
|
+
const metadataBigMapId = this.constractAbstraction.schema.FindFirstInTopLevelPair(yield this.context.readProvider.getStorage(this.constractAbstraction.address, 'head'), metadataBigMapType);
|
|
399
|
+
if (!metadataBigMapId) {
|
|
400
|
+
throw new BigMapMetadataNotFound();
|
|
401
|
+
}
|
|
402
|
+
return new BigMapAbstraction(new BigNumber(metadataBigMapId['int']), new Schema(metadataBigMapType), this.context.contract);
|
|
403
|
+
});
|
|
399
404
|
}
|
|
400
405
|
getUriOrFail() {
|
|
401
406
|
return __awaiter(this, void 0, void 0, function* () {
|
|
402
|
-
const metadataBigMap = this.findMetadataBigMap();
|
|
407
|
+
const metadataBigMap = yield this.findMetadataBigMap();
|
|
403
408
|
const uri = yield metadataBigMap.get('');
|
|
404
409
|
if (!uri) {
|
|
405
410
|
throw new UriNotFound();
|
|
@@ -455,7 +460,7 @@ class Tzip16ContractAbstraction {
|
|
|
455
460
|
if (view.name) {
|
|
456
461
|
// when views have the same name, add an index at the end of the name
|
|
457
462
|
const viewName = this.generateIndexedViewName(view.name, metadataViews);
|
|
458
|
-
const metadataView = this._viewFactory.getView(viewName, this.context.rpc, this.constractAbstraction, viewImplementation);
|
|
463
|
+
const metadataView = this._viewFactory.getView(viewName, this.context.rpc, this.context.readProvider, this.constractAbstraction, viewImplementation);
|
|
459
464
|
if (metadataView) {
|
|
460
465
|
metadataViews[viewName] = metadataView;
|
|
461
466
|
}
|
|
@@ -556,8 +561,8 @@ class Tzip16Module {
|
|
|
556
561
|
|
|
557
562
|
// IMPORTANT: THIS FILE IS AUTO GENERATED! DO NOT MANUALLY EDIT OR CHECKIN!
|
|
558
563
|
const VERSION = {
|
|
559
|
-
"commitHash": "
|
|
560
|
-
"version": "
|
|
564
|
+
"commitHash": "8203ea7669c742797022f1b61f2577bcac50ca55",
|
|
565
|
+
"version": "12.0.1"
|
|
561
566
|
};
|
|
562
567
|
|
|
563
568
|
export { BigMapMetadataNotFound, DEFAULT_HANDLERS, ForbiddenInstructionInViewCode, HttpHandler, InvalidMetadata, InvalidMetadataType, InvalidUri, InvalidViewParameterError, IpfsHttpHandler, MetadataNotFound, MetadataProvider, MichelsonStorageView, NoParameterExpectedError, ProtocolNotSupported, TezosStorageHandler, Tzip16ContractAbstraction, Tzip16Module, UnconfiguredMetadataProviderError, UriNotFound, VERSION, ViewFactory, ViewImplementationType, calculateSHA256Hash, tzip16 };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"taquito-tzip16.es6.js","sources":["../src/handlers/http-handler.ts","../src/tzip16-errors.ts","../src/handlers/tezos-storage-handler.ts","../src/handlers/ipfs-handler.ts","../src/metadata-interface.ts","../src/viewKind/michelson-storage-view.ts","../src/viewKind/viewFactory.ts","../src/tzip16-contract-abstraction.ts","../src/composer.ts","../src/tzip16-utils.ts","../src/metadata-provider.ts","../src/tzip16-extension.ts","../src/version.ts"],"sourcesContent":["import { HttpBackend } from \"@taquito/http-utils\";\nimport { ContractAbstraction, ContractProvider, Wallet, Context } from \"@taquito/taquito\";\nimport { Handler, Tzip16Uri } from \"../metadata-provider\";\n\nexport class HttpHandler implements Handler {\n httpBackend: HttpBackend;\n constructor() {\n this.httpBackend = new HttpBackend();\n }\n async getMetadata(_contractAbstraction: ContractAbstraction<ContractProvider | Wallet>, { protocol, location }: Tzip16Uri, _context: Context) {\n return this.httpBackend.createRequest<string>({\n url: `${protocol}:${decodeURIComponent(location)}`,\n method: 'GET',\n mimeType: \"text; charset=utf-8\",\n json: false\n })\n }\n}","export class BigMapMetadataNotFound extends Error {\n name = 'BigMapMetadataNotFound';\n\n constructor() {\n super(\n 'Non-compliance with the TZIP-016 standard. No big map named metadata was found in the contract storage.'\n );\n }\n}\n\nexport class MetadataNotFound extends Error {\n name = 'MetadataNotFound';\n\n constructor(public info: string) {\n super(`No metadata was found in the contract storage. ${info}`);\n }\n}\n\nexport class UriNotFound extends Error {\n name = 'UriNotFound';\n constructor() {\n super('Non-compliance with the TZIP-016 standard. No URI found in the contract storage.');\n }\n}\n\nexport class InvalidUri extends Error {\n name = 'InvalidUri';\n\n constructor(public uri: string) {\n super(`Non-compliance with the TZIP-016 standard. The URI is invalid: ${uri}.`);\n }\n}\n\nexport class InvalidMetadata extends Error {\n name = 'InvalidMetadata';\n\n constructor(public invalidMetadata: string) {\n super(\n `The metadata found at the pointed ressource are not compliant with tzip16 standard: ${invalidMetadata}.`\n );\n }\n}\n\nexport class ProtocolNotSupported extends Error {\n name = 'ProtocolNotSupported';\n\n constructor(public protocol: string) {\n super(`The protocol found in the URI is not supported: ${protocol}.`);\n }\n}\n\nexport class InvalidMetadataType extends Error {\n name = 'InvalidMetadataType';\n\n constructor() {\n super(\n 'The contract does not comply with the tzip16 standard. The type of metadata should be bytes.'\n );\n }\n}\n\nexport class UnconfiguredMetadataProviderError extends Error {\n name = 'UnconfiguredMetadataProviderError';\n\n constructor() {\n super(\n 'No metadata provider has been configured. The default one can be configured by calling addExtension(new Tzip16Module()) on your TezosToolkit instance.'\n );\n }\n}\n\nexport class ForbiddenInstructionInViewCode extends Error {\n name = 'ForbiddenInstructionInViewCode';\n\n constructor(public instruction: string) {\n super(\n `Error found in the code of the view. It contains a forbidden instruction: ${instruction}.`\n );\n }\n}\n\nexport class NoParameterExpectedError extends Error {\n name = 'NoParameterExpectedError';\n\n constructor(public viewName: string, public args: any[]) {\n super(`${viewName} Received ${args.length} arguments while expecting no parameter or 'Unit'`);\n }\n}\n\nexport class InvalidViewParameterError extends Error {\n name = 'InvalidViewParameterError';\n\n constructor(public viewName: string, public sigs: any[], public args: any[]) {\n super(\n `${viewName} Received ${\n args.length\n } arguments while expecting one of the following signatures (${JSON.stringify(sigs)})`\n );\n }\n}\n","import { Schema } from '@taquito/michelson-encoder';\nimport { Context, ContractAbstraction, ContractProvider, Wallet } from '@taquito/taquito';\nimport { Handler, Tzip16Uri } from '../metadata-provider';\nimport { bytes2Char } from '@taquito/utils';\nimport {\n InvalidMetadataType,\n BigMapMetadataNotFound,\n InvalidUri,\n MetadataNotFound,\n} from '../tzip16-errors';\n\nconst typeOfValueToFind = {\n prim: 'big_map',\n args: [{ prim: 'string' }, { prim: 'bytes' }],\n annots: ['%metadata'],\n};\n\ntype BigMapId = { int: string };\n\nexport class TezosStorageHandler implements Handler {\n private readonly TEZOS_STORAGE_REGEX = /^(?:\\/\\/(KT1\\w{33})(?:\\.(.+))?\\/)?([\\w|%]+)$/;\n\n async getMetadata(\n contractAbstraction: ContractAbstraction<ContractProvider | Wallet>,\n { location }: Tzip16Uri,\n context: Context\n ) {\n const parsedTezosStorageUri = this.parseTezosStorageUri(location);\n if (!parsedTezosStorageUri) {\n throw new InvalidUri(`tezos-storage:${location}`);\n }\n const storage: any = await context.rpc.getNormalizedScript(\n parsedTezosStorageUri.contractAddress || contractAbstraction.address\n );\n const bigMapId = Schema.fromRPCResponse({ script: storage }).FindFirstInTopLevelPair<BigMapId>(\n storage.storage,\n typeOfValueToFind\n );\n\n if (!bigMapId) {\n throw new BigMapMetadataNotFound();\n }\n\n const bytes = await context.contract.getBigMapKeyByID<string>(\n bigMapId['int'].toString(),\n parsedTezosStorageUri.path,\n new Schema(typeOfValueToFind)\n );\n\n if (!bytes) {\n throw new MetadataNotFound(\n `No '${parsedTezosStorageUri.path}' key found in the big map %metadata of the contract ${\n parsedTezosStorageUri.contractAddress || contractAbstraction.address\n }`\n );\n }\n\n if (!/^[0-9a-fA-F]*$/.test(bytes)) {\n throw new InvalidMetadataType();\n }\n return bytes2Char(bytes);\n }\n\n /**\n * @description Extract the smart contract address, the network and the path pointing to the metadata from the uri\n * @returns an object which contains the properties allowing to find where the metadata are located or it returns undefined if the uri is not valid\n * @param tezosStorageURI URI (without the tezos-storage prefix)\n */\n private parseTezosStorageUri(tezosStorageURI: string) {\n const extractor = this.TEZOS_STORAGE_REGEX.exec(tezosStorageURI);\n if (!extractor) return;\n return {\n contractAddress: extractor[1],\n network: extractor[2],\n path: decodeURIComponent(extractor[3]),\n };\n }\n}\n","import { HttpBackend } from \"@taquito/http-utils\";\nimport { ContractAbstraction, ContractProvider, Wallet, Context } from \"@taquito/taquito\";\nimport { Handler, Tzip16Uri } from \"../metadata-provider\";\n\nexport class IpfsHttpHandler implements Handler {\n private _ipfsGateway: string;\n public httpBackend = new HttpBackend();\n\n constructor(ipfsGatheway?:string){\n this._ipfsGateway = ipfsGatheway? ipfsGatheway: 'ipfs.io';\n }\n\n async getMetadata(_contractAbstraction: ContractAbstraction<ContractProvider | Wallet>, { location }: Tzip16Uri, _context: Context): Promise<string> {\n return this.httpBackend.createRequest<string>({\n url: `https://${this._ipfsGateway}/ipfs/${location.substring(2)}/`,\n method: 'GET',\n headers: {'Content-Type': 'text/plain'},\n mimeType: \"text; charset=utf-8\",\n json: false\n })\n }\n}\n","import { MichelsonV1Expression } from '@taquito/rpc';\nexport interface MetadataInterface {\n\tname?: string;\n\tdescription?: string;\n\tversion?: string;\n\tlicense?: { name: string; details?: string };\n\tauthors?: string[];\n\thomepage?: string;\n\tsource?: { tools?: string[]; location?: string };\n\tinterfaces?: string[];\n\terrors?: ErrorsTzip16;\n\tviews?: Views;\n}\n\nexport type ErrorsTzip16 = Array<\n\t| { error: MichelineTzip16Expression; expansion: MichelineTzip16Expression; languages?: string[] }\n\t| { view: string; languages?: string[] }\n>;\n\nexport enum ViewImplementationType {\n\tMICHELSON_STORAGE = 'michelsonStorageView',\n\tREST_API_QUERY = 'restApiQuery'\n}\n\nexport type ViewImplementation =\n\t| { [ViewImplementationType.MICHELSON_STORAGE]: MichelsonStorageViewType }\n\t| { [ViewImplementationType.REST_API_QUERY]: RestApiQueryType };\n\nexport interface ViewDefinition {\n\tname?: string;\n\tdescription?: string;\n\timplementations?: ViewImplementation[];\n\tpure?: boolean;\n}\n\nexport type Views = ViewDefinition[];\n\nexport type MichelsonStorageViewType = {\n\tparameter?: MichelineTzip16Expression;\n\treturnType: MichelineTzip16Expression;\n\tcode: MichelineTzip16Expression;\n\tannotations?: Array<{ name: string; description: string }>;\n\tversion?: string;\n};\n\nexport type RestApiQueryType = {\n\tspecificationUri: string;\n\tbaseUri?: string;\n\tpath: string;\n\tmethod?: 'GET' | 'POST' | 'PUT';\n};\n\nexport type MichelineTzip16Expression =\n\t| MichelsonV1Expression\n\t| MichelineTzip16Expression[]\n\t| { prim: Unistring; args?: MichelineTzip16Expression[]; annots?: string[] };\n\ntype Unistring = string | { invalid_utf8_string: number[] };\n","import { ParameterSchema } from '@taquito/michelson-encoder';\nimport {\n RpcClientInterface,\n MichelsonV1Expression,\n MichelsonV1ExpressionExtended,\n} from '@taquito/rpc';\nimport {\n ContractAbstraction,\n ContractProvider,\n Wallet,\n ViewSimulationError,\n} from '@taquito/taquito';\nimport {\n ForbiddenInstructionInViewCode,\n InvalidViewParameterError,\n NoParameterExpectedError,\n} from '../tzip16-errors';\nimport { validateAndExtractFailwith } from '@taquito/taquito';\nimport { View } from './interface';\n\nexport class MichelsonStorageView implements View {\n constructor(\n private viewName: string,\n private contract: ContractAbstraction<ContractProvider | Wallet>,\n private rpc: RpcClientInterface,\n private returnType: MichelsonV1Expression,\n private code: MichelsonV1ExpressionExtended[],\n private viewParameterType?: MichelsonV1ExpressionExtended\n ) {}\n\n /**\n * @description According to the tzip-16 standard, the following instructions must not be used in the code of the view:\n * 'AMOUNT', 'CREATE_CONTRACT', 'SENDER', 'SET_DELEGATE', 'SOURCE', and 'TRANSFER_TOKENS'\n * The method throw an error if an illegal instruction is found\n */\n private findForbiddenInstructionInViewCode(code: MichelsonV1ExpressionExtended[]) {\n const illegalInstructions = [\n 'AMOUNT',\n 'CREATE_CONTRACT',\n 'SENDER',\n 'SET_DELEGATE',\n 'SOURCE',\n 'TRANSFER_TOKENS',\n ];\n\n for (const forbiddenInstruction of illegalInstructions) {\n for (const instruction of code) {\n if (instruction.prim === forbiddenInstruction) {\n throw new ForbiddenInstructionInViewCode(forbiddenInstruction);\n }\n if (instruction.args && instruction.args.length !== 0) {\n this.findForbiddenInstructionInViewCode(instruction.args as any);\n }\n }\n }\n }\n\n /**\n * @description According to the tzip-16 standard, in the first version of the specification, the instruction SELF should only be used before ADDRESS\n * The method throws an error is the instruction SELF is present, but not followed by ADDRESS\n */\n private illegalUseOfSelfInstruction(code: MichelsonV1ExpressionExtended[]) {\n for (const instruction of code) {\n if (instruction.prim === 'SELF') {\n const index = code.indexOf(instruction);\n const nextInstruction = code[index + 1] ? code[index + 1].prim : undefined;\n if (nextInstruction !== 'ADDRESS') {\n throw new ForbiddenInstructionInViewCode(\n 'the instruction SELF should only be used before ADDRESS'\n );\n }\n }\n if (instruction.args && instruction.args.length !== 0) {\n this.illegalUseOfSelfInstruction(instruction.args as any);\n }\n }\n }\n\n /**\n * @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.\n */\n private adaptViewCodeToContext(\n code: MichelsonV1ExpressionExtended[],\n contractBalance: string,\n blockTimeStamp: string,\n chainId: string\n ) {\n const instructionsToReplace = {\n SELF: [\n { prim: 'PUSH', args: [{ prim: 'address' }, { string: this.contract.address }] },\n { prim: 'CONTRACT', args: [{ prim: 'unit' }] },\n { prim: 'IF_NONE', args: [[{ prim: 'UNIT' }, { prim: 'FAILWITH' }], []] },\n ],\n BALANCE: [{ prim: 'PUSH', args: [{ prim: 'mutez' }, { int: contractBalance }] }],\n NOW: [{ prim: 'PUSH', args: [{ prim: 'timestamp' }, { string: blockTimeStamp }] }],\n CHAIN_ID: [{ prim: 'PUSH', args: [{ prim: 'string' }, { string: chainId }] }],\n };\n\n code.forEach((x: any, i: any) => {\n for (const instruction in instructionsToReplace) {\n if (x.prim === instruction) {\n code[i] = Object(instructionsToReplace)[instruction];\n }\n if (x.args && x.args.length !== 0) {\n this.adaptViewCodeToContext(x.args, contractBalance, blockTimeStamp, chainId);\n }\n }\n });\n return code;\n }\n\n private validateArgs = (args: any[], schema: ParameterSchema, viewName: string) => {\n const sigs = schema.ExtractSignatures();\n\n if (!sigs.find((x: any[]) => x.length === args.length)) {\n throw new InvalidViewParameterError(viewName, sigs, args);\n }\n };\n\n private formatArgsAndParameter(argView: any[]) {\n let args = argView;\n let viewParameterType = this.viewParameterType;\n if (!viewParameterType) {\n viewParameterType = { args: [], prim: 'unit', annots: [] };\n }\n\n if (viewParameterType.prim === 'unit') {\n if (args.length === 0) {\n args = ['Unit'];\n }\n if (args.length !== 0 && args[0] !== 'Unit') {\n throw new NoParameterExpectedError(this.viewName, argView);\n }\n }\n const parameterViewSchema = new ParameterSchema(viewParameterType);\n this.validateArgs(args, parameterViewSchema, this.viewName);\n const arg = parameterViewSchema.Encode(...args);\n return { arg, viewParameterType };\n }\n\n async executeView(...args: any[]) {\n // validate view code against tzip-16 specifications\n this.findForbiddenInstructionInViewCode(this.code);\n this.illegalUseOfSelfInstruction(this.code);\n\n const { arg, viewParameterType } = this.formatArgsAndParameter(args);\n\n const storageType: any = this.contract.script.code.find((x: any) => x.prim === 'storage');\n const storageArgs = storageType.args[0];\n const storageValue: any = this.contract.script.storage;\n\n // currentContext\n const chainId = await this.rpc.getChainId();\n const contractBalance = (await this.rpc.getBalance(this.contract.address)).toString();\n const block = await this.rpc.getBlock();\n const blockTimestamp = block.header.timestamp.toString();\n\n const code = this.adaptViewCodeToContext(this.code, contractBalance, blockTimestamp, chainId);\n\n if (!this.viewParameterType) {\n code.unshift({ prim: 'CDR' });\n }\n\n const viewScript = {\n script: [\n { prim: 'parameter', args: [{ prim: 'pair', args: [viewParameterType, storageArgs] }] },\n { prim: 'storage', args: [{ prim: 'option', args: [this.returnType] }] },\n {\n prim: 'code',\n args: [\n [\n { prim: 'CAR' },\n code,\n { prim: 'SOME' },\n { prim: 'NIL', args: [{ prim: 'operation' }] },\n { prim: 'PAIR' },\n ],\n ],\n },\n ],\n storage: { prim: 'None' },\n input: { prim: 'Pair', args: [arg, storageValue] },\n amount: '0',\n chain_id: chainId,\n balance: '0',\n };\n\n let result: any;\n try {\n result = await this.rpc.runCode(viewScript as any);\n } catch (error: any) {\n const failWith = validateAndExtractFailwith(error);\n throw failWith\n ? new ViewSimulationError(\n `The simulation of the Michelson view failed with: ${JSON.stringify(failWith)}`,\n this.viewName,\n failWith,\n error\n )\n : error;\n }\n\n const viewResultSchema = new ParameterSchema(this.returnType);\n return viewResultSchema.Execute(result.storage.args[0]);\n }\n}\n","import { RpcClientInterface } from '@taquito/rpc';\nimport { ContractAbstraction, ContractProvider, Wallet } from '@taquito/taquito';\nimport { ViewImplementation, ViewImplementationType } from '../metadata-interface';\nimport { MichelsonStorageView } from './michelson-storage-view';\n\nexport class ViewFactory {\n getView(\n viewName: string,\n rpc: RpcClientInterface,\n contract: ContractAbstraction<ContractProvider | Wallet>,\n viewImplementation: ViewImplementation\n ) {\n if (this.isMichelsonStorageView(viewImplementation)) {\n const viewValues = viewImplementation[ViewImplementationType.MICHELSON_STORAGE];\n if (!viewValues.returnType || !viewValues.code) {\n console.warn(\n `${viewName} is missing mandatory code or returnType property therefore it will be skipped.`\n );\n return;\n }\n return () => {\n const view = new MichelsonStorageView(\n viewName,\n contract,\n rpc,\n viewValues.returnType as any,\n viewValues.code as any,\n viewValues.parameter as any\n );\n return view;\n };\n }\n }\n\n getImplementationType(viewImplementation: ViewImplementation) {\n return Object.keys(viewImplementation)[0];\n }\n\n private isMichelsonStorageView(\n viewImplementation: ViewImplementation\n ): viewImplementation is { [ViewImplementationType.MICHELSON_STORAGE]: any } {\n return this.getImplementationType(viewImplementation) === ViewImplementationType.MICHELSON_STORAGE;\n }\n}\n","import {\n BigMapAbstraction,\n Context,\n ContractAbstraction,\n ContractProvider,\n Wallet,\n} from '@taquito/taquito';\nimport { bytes2Char } from '@taquito/utils';\nimport { MetadataEnvelope, MetadataProviderInterface } from './metadata-provider';\nimport {\n BigMapMetadataNotFound,\n UnconfiguredMetadataProviderError,\n UriNotFound,\n} from './tzip16-errors';\nimport BigNumber from 'bignumber.js';\nimport { Schema } from '@taquito/michelson-encoder';\nimport { ViewFactory } from './viewKind/viewFactory';\nimport { View } from './viewKind/interface';\nimport { ViewDefinition } from './metadata-interface';\n\nexport type MetadataContext = Context & {\n metadataProvider: MetadataProviderInterface;\n};\n\ntype BigMapId = { int: string };\n\nconst metadataBigMapType = {\n prim: 'big_map',\n args: [{ prim: 'string' }, { prim: 'bytes' }],\n annots: ['%metadata'],\n};\nexport class Tzip16ContractAbstraction {\n private _metadataProvider: MetadataProviderInterface;\n private _metadataEnvelope?: MetadataEnvelope;\n private _viewFactory = new ViewFactory();\n private _metadataViewsObject: { [key: string]: () => View } = {};\n\n constructor(\n private constractAbstraction: ContractAbstraction<ContractProvider | Wallet>,\n private context: MetadataContext\n ) {\n this._metadataProvider = context.metadataProvider;\n }\n\n private findMetadataBigMap(): BigMapAbstraction {\n const metadataBigMapId = this.constractAbstraction.schema.FindFirstInTopLevelPair<BigMapId>(\n this.constractAbstraction.script.storage,\n metadataBigMapType\n );\n\n if (!metadataBigMapId) {\n throw new BigMapMetadataNotFound();\n }\n\n return new BigMapAbstraction(\n new BigNumber(metadataBigMapId['int']),\n new Schema(metadataBigMapType),\n this.context.contract\n );\n }\n\n private async getUriOrFail() {\n const metadataBigMap = this.findMetadataBigMap();\n const uri = await metadataBigMap.get<string>('');\n if (!uri) {\n throw new UriNotFound();\n }\n return uri;\n }\n\n /**\n * @description Return an object containing the metadata, the uri, an optional integrity check result and an optional sha256 hash\n */\n async getMetadata() {\n if (!this._metadataProvider) {\n throw new UnconfiguredMetadataProviderError();\n }\n if (!this._metadataEnvelope) {\n const uri = await this.getUriOrFail();\n this._metadataEnvelope = await this._metadataProvider.provideMetadata(\n this.constractAbstraction,\n bytes2Char(uri),\n this.context\n );\n }\n return this._metadataEnvelope;\n }\n\n async metadataViews() {\n if (Object.keys(this._metadataViewsObject).length === 0) {\n await this.initializeMetadataViewsList();\n }\n return this._metadataViewsObject;\n }\n\n private async initializeMetadataViewsList() {\n const { metadata } = await this.getMetadata();\n const metadataViews: any = {};\n metadata.views?.forEach((view) => this.createViewImplementations(view, metadataViews));\n this._metadataViewsObject = metadataViews;\n }\n\n private generateIndexedViewName(viewName: string, metadataViews: object) {\n let i = 1;\n if (viewName in metadataViews) {\n while (`${viewName}${i}` in metadataViews) {\n i++;\n }\n viewName = `${viewName}${i}`;\n }\n return viewName;\n }\n\n private createViewImplementations(view: ViewDefinition, metadataViews: any) {\n for (const viewImplementation of view?.implementations ?? []) {\n if (view.name) {\n // when views have the same name, add an index at the end of the name\n const viewName = this.generateIndexedViewName(view.name, metadataViews);\n const metadataView = this._viewFactory.getView(\n viewName,\n this.context.rpc,\n this.constractAbstraction,\n viewImplementation\n );\n if (metadataView) {\n metadataViews[viewName] = metadataView;\n } else {\n console.warn(\n `Skipped generating ${viewName} because the view has an unsupported type: ${this._viewFactory.getImplementationType(\n viewImplementation\n )}`\n );\n }\n }\n }\n }\n}\n","import { Context, ContractAbstraction, ContractProvider, Wallet } from '@taquito/taquito';\nimport { MetadataContext, Tzip16ContractAbstraction } from './tzip16-contract-abstraction';\n\nconst ABSTRACTION_KEY = Symbol('Tzip16ContractAbstractionObjectKey');\n\nexport function tzip16<T extends ContractAbstraction<ContractProvider | Wallet>>(\n abs: T,\n context: Context\n) {\n return Object.assign(abs, {\n // namespace tzip16\n tzip16(\n this: ContractAbstraction<ContractProvider | Wallet> & {\n [ABSTRACTION_KEY]?: Tzip16ContractAbstraction;\n }\n ) {\n if (!this[ABSTRACTION_KEY]) {\n this[ABSTRACTION_KEY] = new Tzip16ContractAbstraction(this, context as MetadataContext);\n }\n\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n return this[ABSTRACTION_KEY]!;\n },\n });\n}\n","import CryptoJS from \"crypto-js\";\n\nexport function calculateSHA256Hash(preimage: string): string {\n return CryptoJS.SHA256(preimage).toString(CryptoJS.enc.Hex);\n}","import { ContractAbstraction, ContractProvider, Wallet, Context } from '@taquito/taquito';\nimport { MetadataInterface } from './metadata-interface';\nimport { MetadataContext } from './tzip16-contract-abstraction';\nimport { InvalidMetadata, InvalidUri, ProtocolNotSupported } from './tzip16-errors';\nimport { calculateSHA256Hash } from './tzip16-utils';\n\nexport interface MetadataProviderInterface {\n provideMetadata(\n contractAbstraction: ContractAbstraction<ContractProvider | Wallet>,\n uri: string,\n context: MetadataContext\n ): Promise<MetadataEnvelope>;\n}\n\nexport interface MetadataEnvelope {\n uri: string;\n integrityCheckResult?: boolean;\n sha256Hash?: string;\n metadata: MetadataInterface;\n}\nexport interface Handler {\n getMetadata(\n contractAbstraction: ContractAbstraction<ContractProvider | Wallet>,\n uri: Tzip16Uri,\n context: Context\n ): Promise<string>;\n}\n\nexport interface Tzip16Uri {\n sha256hash: string | undefined;\n protocol: string;\n location: string;\n}\n\n/**\n * @description: Metadata Provider\n */\nexport class MetadataProvider implements MetadataProviderInterface {\n private readonly PROTOCOL_REGEX = /(?:sha256:\\/\\/0x(.*)\\/)?(https?|ipfs|tezos-storage):(.*)/;\n\n constructor(private handlers: Map<string, Handler>) {}\n\n /**\n * @description Fetch the metadata by using the appropriate handler based on the protcol found in the URI\n * @returns an object which contains the uri, the metadata, an optional integrity check result and an optional SHA256 hash\n * @param _contractAbstraction the contract abstraction which contains the URI in its storage\n * @param _uri the decoded uri found in the storage\n * @param context the TezosToolkit Context\n */\n async provideMetadata(\n contractAbstraction: ContractAbstraction<ContractProvider | Wallet>,\n uri: string,\n context: Context\n ): Promise<MetadataEnvelope> {\n const uriInfo = this.extractProtocolInfo(uri);\n if (!uriInfo || !uriInfo.location) {\n throw new InvalidUri(uri);\n }\n\n const handler = this.handlers.get(uriInfo.protocol);\n if (!handler) {\n throw new ProtocolNotSupported(uriInfo.protocol);\n }\n\n const metadata = await handler.getMetadata(contractAbstraction, uriInfo, context);\n const sha256Hash = calculateSHA256Hash(metadata);\n let metadataJSON;\n try {\n metadataJSON = JSON.parse(metadata);\n } catch (ex) {\n throw new InvalidMetadata(metadata);\n }\n\n return {\n uri,\n metadata: metadataJSON,\n integrityCheckResult: uriInfo.sha256hash ? uriInfo.sha256hash === sha256Hash : undefined,\n sha256Hash: uriInfo.sha256hash ? sha256Hash : undefined,\n };\n }\n\n private extractProtocolInfo(_uri: string) {\n const extractor = this.PROTOCOL_REGEX.exec(_uri);\n if (!extractor) return;\n return {\n sha256hash: extractor[1],\n protocol: extractor[2],\n location: extractor[3],\n };\n }\n}\n","import { Context, Extension } from \"@taquito/taquito\";\nimport { Handler, MetadataProvider, MetadataProviderInterface } from \"./metadata-provider\";\nimport { HttpHandler } from \"./handlers/http-handler\";\nimport { TezosStorageHandler } from \"./handlers/tezos-storage-handler\";\nimport { IpfsHttpHandler } from \"./handlers/ipfs-handler\";\n\nexport const DEFAULT_HANDLERS = new Map<string, Handler>([\n ['http', new HttpHandler()],\n ['https', new HttpHandler()],\n ['tezos-storage', new TezosStorageHandler()],\n ['ipfs', new IpfsHttpHandler()]\n])\nexport class Tzip16Module implements Extension {\n private _metadataProvider: MetadataProviderInterface;\n\n constructor(metadataProvider?: MetadataProviderInterface) {\n this._metadataProvider = metadataProvider ? metadataProvider : new MetadataProvider(DEFAULT_HANDLERS);\n }\n\n configureContext(context: Context) {\n Object.assign(context, { metadataProvider: this._metadataProvider });\n }\n}","\n// IMPORTANT: THIS FILE IS AUTO GENERATED! DO NOT MANUALLY EDIT OR CHECKIN!\nexport const VERSION = {\n \"commitHash\": \"81f0a5b103f867f57fbe5d526315c375a3788346\",\n \"version\": \"11.2.0\"\n};\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;MAIa,WAAW;IAEpB;QACI,IAAI,CAAC,WAAW,GAAG,IAAI,WAAW,EAAE,CAAC;KACxC;IACK,WAAW,CAAC,oBAAoE,EAAE,EAAE,QAAQ,EAAE,QAAQ,EAAa,EAAE,QAAiB;;YACxI,OAAO,IAAI,CAAC,WAAW,CAAC,aAAa,CAAS;gBAC1C,GAAG,EAAE,GAAG,QAAQ,IAAI,kBAAkB,CAAC,QAAQ,CAAC,EAAE;gBAClD,MAAM,EAAE,KAAK;gBACb,QAAQ,EAAE,qBAAqB;gBAC/B,IAAI,EAAE,KAAK;aACd,CAAC,CAAA;SACL;KAAA;;;MChBQ,sBAAuB,SAAQ,KAAK;IAG/C;QACE,KAAK,CACH,yGAAyG,CAC1G,CAAC;QALJ,SAAI,GAAG,wBAAwB,CAAC;KAM/B;C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G;IACnB,YAAY,EAAE,0CAA0C;IACxD,SAAS,EAAE,QAAQ;;;;;"}
|
|
1
|
+
{"version":3,"file":"taquito-tzip16.es6.js","sources":["../src/handlers/http-handler.ts","../src/tzip16-errors.ts","../src/handlers/tezos-storage-handler.ts","../src/handlers/ipfs-handler.ts","../src/metadata-interface.ts","../src/viewKind/michelson-storage-view.ts","../src/viewKind/viewFactory.ts","../src/tzip16-contract-abstraction.ts","../src/composer.ts","../src/tzip16-utils.ts","../src/metadata-provider.ts","../src/tzip16-extension.ts","../src/version.ts"],"sourcesContent":["import { HttpBackend } from \"@taquito/http-utils\";\nimport { ContractAbstraction, ContractProvider, Wallet, Context } from \"@taquito/taquito\";\nimport { Handler, Tzip16Uri } from \"../metadata-provider\";\n\nexport class HttpHandler implements Handler {\n httpBackend: HttpBackend;\n constructor() {\n this.httpBackend = new HttpBackend();\n }\n async getMetadata(_contractAbstraction: ContractAbstraction<ContractProvider | Wallet>, { protocol, location }: Tzip16Uri, _context: Context) {\n return this.httpBackend.createRequest<string>({\n url: `${protocol}:${decodeURIComponent(location)}`,\n method: 'GET',\n headers: {\n 'Content-Type': 'text/plain; charset=utf-8'\n },\n json: false\n })\n }\n}","export class BigMapMetadataNotFound extends Error {\n name = 'BigMapMetadataNotFound';\n\n constructor() {\n super(\n 'Non-compliance with the TZIP-016 standard. No big map named metadata was found in the contract storage.'\n );\n }\n}\n\nexport class MetadataNotFound extends Error {\n name = 'MetadataNotFound';\n\n constructor(public info: string) {\n super(`No metadata was found in the contract storage. ${info}`);\n }\n}\n\nexport class UriNotFound extends Error {\n name = 'UriNotFound';\n constructor() {\n super('Non-compliance with the TZIP-016 standard. No URI found in the contract storage.');\n }\n}\n\nexport class InvalidUri extends Error {\n name = 'InvalidUri';\n\n constructor(public uri: string) {\n super(`Non-compliance with the TZIP-016 standard. The URI is invalid: ${uri}.`);\n }\n}\n\nexport class InvalidMetadata extends Error {\n name = 'InvalidMetadata';\n\n constructor(public invalidMetadata: string) {\n super(\n `The metadata found at the pointed ressource are not compliant with tzip16 standard: ${invalidMetadata}.`\n );\n }\n}\n\nexport class ProtocolNotSupported extends Error {\n name = 'ProtocolNotSupported';\n\n constructor(public protocol: string) {\n super(`The protocol found in the URI is not supported: ${protocol}.`);\n }\n}\n\nexport class InvalidMetadataType extends Error {\n name = 'InvalidMetadataType';\n\n constructor() {\n super(\n 'The contract does not comply with the tzip16 standard. The type of metadata should be bytes.'\n );\n }\n}\n\nexport class UnconfiguredMetadataProviderError extends Error {\n name = 'UnconfiguredMetadataProviderError';\n\n constructor() {\n super(\n 'No metadata provider has been configured. The default one can be configured by calling addExtension(new Tzip16Module()) on your TezosToolkit instance.'\n );\n }\n}\n\nexport class ForbiddenInstructionInViewCode extends Error {\n name = 'ForbiddenInstructionInViewCode';\n\n constructor(public instruction: string) {\n super(\n `Error found in the code of the view. It contains a forbidden instruction: ${instruction}.`\n );\n }\n}\n\nexport class NoParameterExpectedError extends Error {\n name = 'NoParameterExpectedError';\n\n constructor(public viewName: string, public args: any[]) {\n super(`${viewName} Received ${args.length} arguments while expecting no parameter or 'Unit'`);\n }\n}\n\nexport class InvalidViewParameterError extends Error {\n name = 'InvalidViewParameterError';\n\n constructor(public viewName: string, public sigs: any[], public args: any[]) {\n super(\n `${viewName} Received ${\n args.length\n } arguments while expecting one of the following signatures (${JSON.stringify(sigs)})`\n );\n }\n}\n","import { Schema } from '@taquito/michelson-encoder';\nimport { Context, ContractAbstraction, ContractProvider, Wallet } from '@taquito/taquito';\nimport { Handler, Tzip16Uri } from '../metadata-provider';\nimport { bytes2Char } from '@taquito/utils';\nimport {\n InvalidMetadataType,\n BigMapMetadataNotFound,\n InvalidUri,\n MetadataNotFound,\n} from '../tzip16-errors';\n\nconst typeOfValueToFind = {\n prim: 'big_map',\n args: [{ prim: 'string' }, { prim: 'bytes' }],\n annots: ['%metadata'],\n};\n\ntype BigMapId = { int: string };\n\nexport class TezosStorageHandler implements Handler {\n private readonly TEZOS_STORAGE_REGEX = /^(?:\\/\\/(KT1\\w{33})(?:\\.(.+))?\\/)?([\\w|%]+)$/;\n\n async getMetadata(\n contractAbstraction: ContractAbstraction<ContractProvider | Wallet>,\n { location }: Tzip16Uri,\n context: Context\n ) {\n const parsedTezosStorageUri = this.parseTezosStorageUri(location);\n if (!parsedTezosStorageUri) {\n throw new InvalidUri(`tezos-storage:${location}`);\n }\n const script = await context.readProvider.getScript(\n parsedTezosStorageUri.contractAddress || contractAbstraction.address,\n 'head'\n );\n const bigMapId = Schema.fromRPCResponse({ script }).FindFirstInTopLevelPair<BigMapId>(\n script.storage,\n typeOfValueToFind\n );\n\n if (!bigMapId) {\n throw new BigMapMetadataNotFound();\n }\n\n const bytes = await context.contract.getBigMapKeyByID<string>(\n bigMapId['int'].toString(),\n parsedTezosStorageUri.path,\n new Schema(typeOfValueToFind)\n );\n\n if (!bytes) {\n throw new MetadataNotFound(\n `No '${parsedTezosStorageUri.path}' key found in the big map %metadata of the contract ${\n parsedTezosStorageUri.contractAddress || contractAbstraction.address\n }`\n );\n }\n\n if (!/^[0-9a-fA-F]*$/.test(bytes)) {\n throw new InvalidMetadataType();\n }\n return bytes2Char(bytes);\n }\n\n /**\n * @description Extract the smart contract address, the network and the path pointing to the metadata from the uri\n * @returns an object which contains the properties allowing to find where the metadata are located or it returns undefined if the uri is not valid\n * @param tezosStorageURI URI (without the tezos-storage prefix)\n */\n private parseTezosStorageUri(tezosStorageURI: string) {\n const extractor = this.TEZOS_STORAGE_REGEX.exec(tezosStorageURI);\n if (!extractor) return;\n return {\n contractAddress: extractor[1],\n network: extractor[2],\n path: decodeURIComponent(extractor[3]),\n };\n }\n}\n","import { HttpBackend } from \"@taquito/http-utils\";\nimport { ContractAbstraction, ContractProvider, Wallet, Context } from \"@taquito/taquito\";\nimport { Handler, Tzip16Uri } from \"../metadata-provider\";\n\nexport class IpfsHttpHandler implements Handler {\n private _ipfsGateway: string;\n public httpBackend = new HttpBackend();\n\n constructor(ipfsGatheway?:string){\n this._ipfsGateway = ipfsGatheway? ipfsGatheway: 'ipfs.io';\n }\n\n async getMetadata(_contractAbstraction: ContractAbstraction<ContractProvider | Wallet>, { location }: Tzip16Uri, _context: Context): Promise<string> {\n return this.httpBackend.createRequest<string>({\n url: `https://${this._ipfsGateway}/ipfs/${location.substring(2)}/`,\n method: 'GET',\n headers: {\n 'Content-Type': 'text/plain; charset=utf-8'\n },\n json: false\n })\n }\n}\n","import { MichelsonV1Expression } from '@taquito/rpc';\nexport interface MetadataInterface {\n\tname?: string;\n\tdescription?: string;\n\tversion?: string;\n\tlicense?: { name: string; details?: string };\n\tauthors?: string[];\n\thomepage?: string;\n\tsource?: { tools?: string[]; location?: string };\n\tinterfaces?: string[];\n\terrors?: ErrorsTzip16;\n\tviews?: Views;\n}\n\nexport type ErrorsTzip16 = Array<\n\t| { error: MichelineTzip16Expression; expansion: MichelineTzip16Expression; languages?: string[] }\n\t| { view: string; languages?: string[] }\n>;\n\nexport enum ViewImplementationType {\n\tMICHELSON_STORAGE = 'michelsonStorageView',\n\tREST_API_QUERY = 'restApiQuery'\n}\n\nexport type ViewImplementation =\n\t| { [ViewImplementationType.MICHELSON_STORAGE]: MichelsonStorageViewType }\n\t| { [ViewImplementationType.REST_API_QUERY]: RestApiQueryType };\n\nexport interface ViewDefinition {\n\tname?: string;\n\tdescription?: string;\n\timplementations?: ViewImplementation[];\n\tpure?: boolean;\n}\n\nexport type Views = ViewDefinition[];\n\nexport type MichelsonStorageViewType = {\n\tparameter?: MichelineTzip16Expression;\n\treturnType: MichelineTzip16Expression;\n\tcode: MichelineTzip16Expression;\n\tannotations?: Array<{ name: string; description: string }>;\n\tversion?: string;\n};\n\nexport type RestApiQueryType = {\n\tspecificationUri: string;\n\tbaseUri?: string;\n\tpath: string;\n\tmethod?: 'GET' | 'POST' | 'PUT';\n};\n\nexport type MichelineTzip16Expression =\n\t| MichelsonV1Expression\n\t| MichelineTzip16Expression[]\n\t| { prim: Unistring; args?: MichelineTzip16Expression[]; annots?: string[] };\n\ntype Unistring = string | { invalid_utf8_string: number[] };\n","import { ParameterSchema } from '@taquito/michelson-encoder';\nimport {\n RpcClientInterface,\n MichelsonV1Expression,\n MichelsonV1ExpressionExtended,\n} from '@taquito/rpc';\nimport {\n ContractAbstraction,\n ContractProvider,\n Wallet,\n ViewSimulationError,\n} from '@taquito/taquito';\nimport {\n ForbiddenInstructionInViewCode,\n InvalidViewParameterError,\n NoParameterExpectedError,\n} from '../tzip16-errors';\nimport { validateAndExtractFailwith, TzReadProvider } from '@taquito/taquito';\nimport { View } from './interface';\n\nexport class MichelsonStorageView implements View {\n constructor(\n private viewName: string,\n private contract: ContractAbstraction<ContractProvider | Wallet>,\n private rpc: RpcClientInterface,\n private readProvider: TzReadProvider,\n private returnType: MichelsonV1Expression,\n private code: MichelsonV1ExpressionExtended[],\n private viewParameterType?: MichelsonV1ExpressionExtended\n ) {}\n\n /**\n * @description According to the tzip-16 standard, the following instructions must not be used in the code of the view:\n * 'AMOUNT', 'CREATE_CONTRACT', 'SENDER', 'SET_DELEGATE', 'SOURCE', and 'TRANSFER_TOKENS'\n * The method throw an error if an illegal instruction is found\n */\n private findForbiddenInstructionInViewCode(code: MichelsonV1ExpressionExtended[]) {\n const illegalInstructions = [\n 'AMOUNT',\n 'CREATE_CONTRACT',\n 'SENDER',\n 'SET_DELEGATE',\n 'SOURCE',\n 'TRANSFER_TOKENS',\n ];\n\n for (const forbiddenInstruction of illegalInstructions) {\n for (const instruction of code) {\n if (instruction.prim === forbiddenInstruction) {\n throw new ForbiddenInstructionInViewCode(forbiddenInstruction);\n }\n if (instruction.args && instruction.args.length !== 0) {\n this.findForbiddenInstructionInViewCode(instruction.args as any);\n }\n }\n }\n }\n\n /**\n * @description According to the tzip-16 standard, in the first version of the specification, the instruction SELF should only be used before ADDRESS\n * The method throws an error is the instruction SELF is present, but not followed by ADDRESS\n */\n private illegalUseOfSelfInstruction(code: MichelsonV1ExpressionExtended[]) {\n for (const instruction of code) {\n if (instruction.prim === 'SELF') {\n const index = code.indexOf(instruction);\n const nextInstruction = code[index + 1] ? code[index + 1].prim : undefined;\n if (nextInstruction !== 'ADDRESS') {\n throw new ForbiddenInstructionInViewCode(\n 'the instruction SELF should only be used before ADDRESS'\n );\n }\n }\n if (instruction.args && instruction.args.length !== 0) {\n this.illegalUseOfSelfInstruction(instruction.args as any);\n }\n }\n }\n\n /**\n * @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.\n */\n private adaptViewCodeToContext(\n code: MichelsonV1ExpressionExtended[],\n contractBalance: string,\n blockTimeStamp: string,\n chainId: string\n ) {\n const instructionsToReplace = {\n SELF: [\n { prim: 'PUSH', args: [{ prim: 'address' }, { string: this.contract.address }] },\n { prim: 'CONTRACT', args: [{ prim: 'unit' }] },\n { prim: 'IF_NONE', args: [[{ prim: 'UNIT' }, { prim: 'FAILWITH' }], []] },\n ],\n BALANCE: [{ prim: 'PUSH', args: [{ prim: 'mutez' }, { int: contractBalance }] }],\n NOW: [{ prim: 'PUSH', args: [{ prim: 'timestamp' }, { string: blockTimeStamp }] }],\n CHAIN_ID: [{ prim: 'PUSH', args: [{ prim: 'string' }, { string: chainId }] }],\n };\n\n code.forEach((x: any, i: any) => {\n for (const instruction in instructionsToReplace) {\n if (x.prim === instruction) {\n code[i] = Object(instructionsToReplace)[instruction];\n }\n if (x.args && x.args.length !== 0) {\n this.adaptViewCodeToContext(x.args, contractBalance, blockTimeStamp, chainId);\n }\n }\n });\n return code;\n }\n\n private validateArgs = (args: any[], schema: ParameterSchema, viewName: string) => {\n const sigs = schema.ExtractSignatures();\n\n if (!sigs.find((x: any[]) => x.length === args.length)) {\n throw new InvalidViewParameterError(viewName, sigs, args);\n }\n };\n\n private formatArgsAndParameter(argView: any[]) {\n let args = argView;\n let viewParameterType = this.viewParameterType;\n if (!viewParameterType) {\n viewParameterType = { args: [], prim: 'unit', annots: [] };\n }\n\n if (viewParameterType.prim === 'unit') {\n if (args.length === 0) {\n args = ['Unit'];\n }\n if (args.length !== 0 && args[0] !== 'Unit') {\n throw new NoParameterExpectedError(this.viewName, argView);\n }\n }\n const parameterViewSchema = new ParameterSchema(viewParameterType);\n this.validateArgs(args, parameterViewSchema, this.viewName);\n const arg = parameterViewSchema.Encode(...args);\n return { arg, viewParameterType };\n }\n\n async executeView(...args: any[]) {\n // validate view code against tzip-16 specifications\n this.findForbiddenInstructionInViewCode(this.code);\n this.illegalUseOfSelfInstruction(this.code);\n\n const { arg, viewParameterType } = this.formatArgsAndParameter(args);\n\n const storageType: any = this.contract.script.code.find((x: any) => x.prim === 'storage');\n const storageArgs = storageType.args[0];\n\n // currentContext\n const storageValue: any = await this.readProvider.getStorage(this.contract.address, 'head');\n const chainId = await this.readProvider.getChainId();\n const contractBalance = (\n await this.readProvider.getBalance(this.contract.address, 'head')\n ).toString();\n const blockTimestamp = await this.readProvider.getBlockTimestamp('head');\n\n const code = this.adaptViewCodeToContext(this.code, contractBalance, blockTimestamp, chainId);\n\n if (!this.viewParameterType) {\n code.unshift({ prim: 'CDR' });\n }\n\n const viewScript = {\n script: [\n { prim: 'parameter', args: [{ prim: 'pair', args: [viewParameterType, storageArgs] }] },\n { prim: 'storage', args: [{ prim: 'option', args: [this.returnType] }] },\n {\n prim: 'code',\n args: [\n [\n { prim: 'CAR' },\n code,\n { prim: 'SOME' },\n { prim: 'NIL', args: [{ prim: 'operation' }] },\n { prim: 'PAIR' },\n ],\n ],\n },\n ],\n storage: { prim: 'None' },\n input: { prim: 'Pair', args: [arg, storageValue] },\n amount: '0',\n chain_id: chainId,\n balance: '0',\n };\n\n let result: any;\n try {\n result = await this.rpc.runCode(viewScript as any);\n } catch (error: any) {\n const failWith = validateAndExtractFailwith(error);\n throw failWith\n ? new ViewSimulationError(\n `The simulation of the Michelson view failed with: ${JSON.stringify(failWith)}`,\n this.viewName,\n failWith,\n error\n )\n : error;\n }\n\n const viewResultSchema = new ParameterSchema(this.returnType);\n return viewResultSchema.Execute(result.storage.args[0]);\n }\n}\n","import { RpcClientInterface } from '@taquito/rpc';\nimport { ContractAbstraction, ContractProvider, Wallet, TzReadProvider } from '@taquito/taquito';\nimport { ViewImplementation, ViewImplementationType } from '../metadata-interface';\nimport { MichelsonStorageView } from './michelson-storage-view';\n\nexport class ViewFactory {\n getView(\n viewName: string,\n rpc: RpcClientInterface,\n readProvider: TzReadProvider,\n contract: ContractAbstraction<ContractProvider | Wallet>,\n viewImplementation: ViewImplementation\n ) {\n if (this.isMichelsonStorageView(viewImplementation)) {\n const viewValues = viewImplementation[ViewImplementationType.MICHELSON_STORAGE];\n if (!viewValues.returnType || !viewValues.code) {\n console.warn(\n `${viewName} is missing mandatory code or returnType property therefore it will be skipped.`\n );\n return;\n }\n return () => {\n const view = new MichelsonStorageView(\n viewName,\n contract,\n rpc,\n readProvider,\n viewValues.returnType as any,\n viewValues.code as any,\n viewValues.parameter as any\n );\n return view;\n };\n }\n }\n\n getImplementationType(viewImplementation: ViewImplementation) {\n return Object.keys(viewImplementation)[0];\n }\n\n private isMichelsonStorageView(\n viewImplementation: ViewImplementation\n ): viewImplementation is { [ViewImplementationType.MICHELSON_STORAGE]: any } {\n return (\n this.getImplementationType(viewImplementation) === ViewImplementationType.MICHELSON_STORAGE\n );\n }\n}\n","import {\n BigMapAbstraction,\n Context,\n ContractAbstraction,\n ContractProvider,\n Wallet,\n} from '@taquito/taquito';\nimport { bytes2Char } from '@taquito/utils';\nimport { MetadataEnvelope, MetadataProviderInterface } from './metadata-provider';\nimport {\n BigMapMetadataNotFound,\n UnconfiguredMetadataProviderError,\n UriNotFound,\n} from './tzip16-errors';\nimport BigNumber from 'bignumber.js';\nimport { Schema } from '@taquito/michelson-encoder';\nimport { ViewFactory } from './viewKind/viewFactory';\nimport { View } from './viewKind/interface';\nimport { ViewDefinition } from './metadata-interface';\n\nexport type MetadataContext = Context & {\n metadataProvider: MetadataProviderInterface;\n};\n\ntype BigMapId = { int: string };\n\nconst metadataBigMapType = {\n prim: 'big_map',\n args: [{ prim: 'string' }, { prim: 'bytes' }],\n annots: ['%metadata'],\n};\nexport class Tzip16ContractAbstraction {\n private _metadataProvider: MetadataProviderInterface;\n private _metadataEnvelope?: MetadataEnvelope;\n private _viewFactory = new ViewFactory();\n private _metadataViewsObject: { [key: string]: () => View } = {};\n\n constructor(\n private constractAbstraction: ContractAbstraction<ContractProvider | Wallet>,\n private context: MetadataContext\n ) {\n this._metadataProvider = context.metadataProvider;\n }\n\n private async findMetadataBigMap(): Promise<BigMapAbstraction> {\n const metadataBigMapId = this.constractAbstraction.schema.FindFirstInTopLevelPair<BigMapId>(\n await this.context.readProvider.getStorage(this.constractAbstraction.address, 'head'),\n metadataBigMapType\n );\n\n if (!metadataBigMapId) {\n throw new BigMapMetadataNotFound();\n }\n\n return new BigMapAbstraction(\n new BigNumber(metadataBigMapId['int']),\n new Schema(metadataBigMapType),\n this.context.contract\n );\n }\n\n private async getUriOrFail() {\n const metadataBigMap = await this.findMetadataBigMap();\n const uri = await metadataBigMap.get<string>('');\n if (!uri) {\n throw new UriNotFound();\n }\n return uri;\n }\n\n /**\n * @description Return an object containing the metadata, the uri, an optional integrity check result and an optional sha256 hash\n */\n async getMetadata() {\n if (!this._metadataProvider) {\n throw new UnconfiguredMetadataProviderError();\n }\n if (!this._metadataEnvelope) {\n const uri = await this.getUriOrFail();\n this._metadataEnvelope = await this._metadataProvider.provideMetadata(\n this.constractAbstraction,\n bytes2Char(uri),\n this.context\n );\n }\n return this._metadataEnvelope;\n }\n\n async metadataViews() {\n if (Object.keys(this._metadataViewsObject).length === 0) {\n await this.initializeMetadataViewsList();\n }\n return this._metadataViewsObject;\n }\n\n private async initializeMetadataViewsList() {\n const { metadata } = await this.getMetadata();\n const metadataViews: any = {};\n metadata.views?.forEach((view) => this.createViewImplementations(view, metadataViews));\n this._metadataViewsObject = metadataViews;\n }\n\n private generateIndexedViewName(viewName: string, metadataViews: object) {\n let i = 1;\n if (viewName in metadataViews) {\n while (`${viewName}${i}` in metadataViews) {\n i++;\n }\n viewName = `${viewName}${i}`;\n }\n return viewName;\n }\n\n private createViewImplementations(view: ViewDefinition, metadataViews: any) {\n for (const viewImplementation of view?.implementations ?? []) {\n if (view.name) {\n // when views have the same name, add an index at the end of the name\n const viewName = this.generateIndexedViewName(view.name, metadataViews);\n const metadataView = this._viewFactory.getView(\n viewName,\n this.context.rpc,\n this.context.readProvider,\n this.constractAbstraction,\n viewImplementation\n );\n if (metadataView) {\n metadataViews[viewName] = metadataView;\n } else {\n console.warn(\n `Skipped generating ${viewName} because the view has an unsupported type: ${this._viewFactory.getImplementationType(\n viewImplementation\n )}`\n );\n }\n }\n }\n }\n}\n","import { Context, ContractAbstraction, ContractProvider, Wallet } from '@taquito/taquito';\nimport { MetadataContext, Tzip16ContractAbstraction } from './tzip16-contract-abstraction';\n\nconst ABSTRACTION_KEY = Symbol('Tzip16ContractAbstractionObjectKey');\n\nexport function tzip16<T extends ContractAbstraction<ContractProvider | Wallet>>(\n abs: T,\n context: Context\n) {\n return Object.assign(abs, {\n // namespace tzip16\n tzip16(\n this: ContractAbstraction<ContractProvider | Wallet> & {\n [ABSTRACTION_KEY]?: Tzip16ContractAbstraction;\n }\n ) {\n if (!this[ABSTRACTION_KEY]) {\n this[ABSTRACTION_KEY] = new Tzip16ContractAbstraction(this, context as MetadataContext);\n }\n\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n return this[ABSTRACTION_KEY]!;\n },\n });\n}\n","import CryptoJS from \"crypto-js\";\n\nexport function calculateSHA256Hash(preimage: string): string {\n return CryptoJS.SHA256(preimage).toString(CryptoJS.enc.Hex);\n}","import { ContractAbstraction, ContractProvider, Wallet, Context } from '@taquito/taquito';\nimport { MetadataInterface } from './metadata-interface';\nimport { MetadataContext } from './tzip16-contract-abstraction';\nimport { InvalidMetadata, InvalidUri, ProtocolNotSupported } from './tzip16-errors';\nimport { calculateSHA256Hash } from './tzip16-utils';\n\nexport interface MetadataProviderInterface {\n provideMetadata(\n contractAbstraction: ContractAbstraction<ContractProvider | Wallet>,\n uri: string,\n context: MetadataContext\n ): Promise<MetadataEnvelope>;\n}\n\nexport interface MetadataEnvelope {\n uri: string;\n integrityCheckResult?: boolean;\n sha256Hash?: string;\n metadata: MetadataInterface;\n}\nexport interface Handler {\n getMetadata(\n contractAbstraction: ContractAbstraction<ContractProvider | Wallet>,\n uri: Tzip16Uri,\n context: Context\n ): Promise<string>;\n}\n\nexport interface Tzip16Uri {\n sha256hash: string | undefined;\n protocol: string;\n location: string;\n}\n\n/**\n * @description: Metadata Provider\n */\nexport class MetadataProvider implements MetadataProviderInterface {\n private readonly PROTOCOL_REGEX = /(?:sha256:\\/\\/0x(.*)\\/)?(https?|ipfs|tezos-storage):(.*)/;\n\n constructor(private handlers: Map<string, Handler>) {}\n\n /**\n * @description Fetch the metadata by using the appropriate handler based on the protcol found in the URI\n * @returns an object which contains the uri, the metadata, an optional integrity check result and an optional SHA256 hash\n * @param _contractAbstraction the contract abstraction which contains the URI in its storage\n * @param _uri the decoded uri found in the storage\n * @param context the TezosToolkit Context\n */\n async provideMetadata(\n contractAbstraction: ContractAbstraction<ContractProvider | Wallet>,\n uri: string,\n context: Context\n ): Promise<MetadataEnvelope> {\n const uriInfo = this.extractProtocolInfo(uri);\n if (!uriInfo || !uriInfo.location) {\n throw new InvalidUri(uri);\n }\n\n const handler = this.handlers.get(uriInfo.protocol);\n if (!handler) {\n throw new ProtocolNotSupported(uriInfo.protocol);\n }\n\n const metadata = await handler.getMetadata(contractAbstraction, uriInfo, context);\n const sha256Hash = calculateSHA256Hash(metadata);\n let metadataJSON;\n try {\n metadataJSON = JSON.parse(metadata);\n } catch (ex) {\n throw new InvalidMetadata(metadata);\n }\n\n return {\n uri,\n metadata: metadataJSON,\n integrityCheckResult: uriInfo.sha256hash ? uriInfo.sha256hash === sha256Hash : undefined,\n sha256Hash: uriInfo.sha256hash ? sha256Hash : undefined,\n };\n }\n\n private extractProtocolInfo(_uri: string) {\n const extractor = this.PROTOCOL_REGEX.exec(_uri);\n if (!extractor) return;\n return {\n sha256hash: extractor[1],\n protocol: extractor[2],\n location: extractor[3],\n };\n }\n}\n","import { Context, Extension } from \"@taquito/taquito\";\nimport { Handler, MetadataProvider, MetadataProviderInterface } from \"./metadata-provider\";\nimport { HttpHandler } from \"./handlers/http-handler\";\nimport { TezosStorageHandler } from \"./handlers/tezos-storage-handler\";\nimport { IpfsHttpHandler } from \"./handlers/ipfs-handler\";\n\nexport const DEFAULT_HANDLERS = new Map<string, Handler>([\n ['http', new HttpHandler()],\n ['https', new HttpHandler()],\n ['tezos-storage', new TezosStorageHandler()],\n ['ipfs', new IpfsHttpHandler()]\n])\nexport class Tzip16Module implements Extension {\n private _metadataProvider: MetadataProviderInterface;\n\n constructor(metadataProvider?: MetadataProviderInterface) {\n this._metadataProvider = metadataProvider ? metadataProvider : new MetadataProvider(DEFAULT_HANDLERS);\n }\n\n configureContext(context: Context) {\n Object.assign(context, { metadataProvider: this._metadataProvider });\n }\n}","\n// IMPORTANT: THIS FILE IS AUTO GENERATED! DO NOT MANUALLY EDIT OR CHECKIN!\nexport const VERSION = {\n \"commitHash\": \"8203ea7669c742797022f1b61f2577bcac50ca55\",\n \"version\": \"12.0.1\"\n};\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;MAIa,WAAW;IAEpB;QACI,IAAI,CAAC,WAAW,GAAG,IAAI,WAAW,EAAE,CAAC;KACxC;IACK,WAAW,CAAC,oBAAoE,EAAE,EAAE,QAAQ,EAAE,QAAQ,EAAa,EAAE,QAAiB;;YACxI,OAAO,IAAI,CAAC,WAAW,CAAC,aAAa,CAAS;gBAC1C,GAAG,EAAE,GAAG,QAAQ,IAAI,kBAAkB,CAAC,QAAQ,CAAC,EAAE;gBAClD,MAAM,EAAE,KAAK;gBACb,OAAO,EAAE;oBACP,cAAc,EAAE,2BAA2B;iBAC5C;gBACD,IAAI,EAAE,KAAK;aACd,CAAC,CAAA;SACL;KAAA;;;MClBQ,sBAAuB,SAAQ,KAA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G,gBAAgB,GAAG,gBAAgB,GAAG,IAAI,gBAAgB,CAAC,gBAAgB,CAAC,CAAC;KACzG;IAED,gBAAgB,CAAC,OAAgB;QAC7B,MAAM,CAAC,MAAM,CAAC,OAAO,EAAE,EAAE,gBAAgB,EAAE,IAAI,CAAC,iBAAiB,EAAE,CAAC,CAAC;KACxE;;;ACpBL;MACa,OAAO,GAAG;IACnB,YAAY,EAAE,0CAA0C;IACxD,SAAS,EAAE,QAAQ;;;;;"}
|
|
@@ -43,7 +43,9 @@
|
|
|
43
43
|
return this.httpBackend.createRequest({
|
|
44
44
|
url: `${protocol}:${decodeURIComponent(location)}`,
|
|
45
45
|
method: 'GET',
|
|
46
|
-
|
|
46
|
+
headers: {
|
|
47
|
+
'Content-Type': 'text/plain; charset=utf-8'
|
|
48
|
+
},
|
|
47
49
|
json: false
|
|
48
50
|
});
|
|
49
51
|
});
|
|
@@ -142,8 +144,8 @@
|
|
|
142
144
|
if (!parsedTezosStorageUri) {
|
|
143
145
|
throw new InvalidUri(`tezos-storage:${location}`);
|
|
144
146
|
}
|
|
145
|
-
const
|
|
146
|
-
const bigMapId = michelsonEncoder.Schema.fromRPCResponse({ script
|
|
147
|
+
const script = yield context.readProvider.getScript(parsedTezosStorageUri.contractAddress || contractAbstraction.address, 'head');
|
|
148
|
+
const bigMapId = michelsonEncoder.Schema.fromRPCResponse({ script }).FindFirstInTopLevelPair(script.storage, typeOfValueToFind);
|
|
147
149
|
if (!bigMapId) {
|
|
148
150
|
throw new BigMapMetadataNotFound();
|
|
149
151
|
}
|
|
@@ -184,8 +186,9 @@
|
|
|
184
186
|
return this.httpBackend.createRequest({
|
|
185
187
|
url: `https://${this._ipfsGateway}/ipfs/${location.substring(2)}/`,
|
|
186
188
|
method: 'GET',
|
|
187
|
-
headers: {
|
|
188
|
-
|
|
189
|
+
headers: {
|
|
190
|
+
'Content-Type': 'text/plain; charset=utf-8'
|
|
191
|
+
},
|
|
189
192
|
json: false
|
|
190
193
|
});
|
|
191
194
|
});
|
|
@@ -199,10 +202,11 @@
|
|
|
199
202
|
})(exports.ViewImplementationType || (exports.ViewImplementationType = {}));
|
|
200
203
|
|
|
201
204
|
class MichelsonStorageView {
|
|
202
|
-
constructor(viewName, contract, rpc, returnType, code, viewParameterType) {
|
|
205
|
+
constructor(viewName, contract, rpc, readProvider, returnType, code, viewParameterType) {
|
|
203
206
|
this.viewName = viewName;
|
|
204
207
|
this.contract = contract;
|
|
205
208
|
this.rpc = rpc;
|
|
209
|
+
this.readProvider = readProvider;
|
|
206
210
|
this.returnType = returnType;
|
|
207
211
|
this.code = code;
|
|
208
212
|
this.viewParameterType = viewParameterType;
|
|
@@ -309,12 +313,11 @@
|
|
|
309
313
|
const { arg, viewParameterType } = this.formatArgsAndParameter(args);
|
|
310
314
|
const storageType = this.contract.script.code.find((x) => x.prim === 'storage');
|
|
311
315
|
const storageArgs = storageType.args[0];
|
|
312
|
-
const storageValue = this.contract.script.storage;
|
|
313
316
|
// currentContext
|
|
314
|
-
const
|
|
315
|
-
const
|
|
316
|
-
const
|
|
317
|
-
const blockTimestamp =
|
|
317
|
+
const storageValue = yield this.readProvider.getStorage(this.contract.address, 'head');
|
|
318
|
+
const chainId = yield this.readProvider.getChainId();
|
|
319
|
+
const contractBalance = (yield this.readProvider.getBalance(this.contract.address, 'head')).toString();
|
|
320
|
+
const blockTimestamp = yield this.readProvider.getBlockTimestamp('head');
|
|
318
321
|
const code = this.adaptViewCodeToContext(this.code, contractBalance, blockTimestamp, chainId);
|
|
319
322
|
if (!this.viewParameterType) {
|
|
320
323
|
code.unshift({ prim: 'CDR' });
|
|
@@ -359,7 +362,7 @@
|
|
|
359
362
|
}
|
|
360
363
|
|
|
361
364
|
class ViewFactory {
|
|
362
|
-
getView(viewName, rpc, contract, viewImplementation) {
|
|
365
|
+
getView(viewName, rpc, readProvider, contract, viewImplementation) {
|
|
363
366
|
if (this.isMichelsonStorageView(viewImplementation)) {
|
|
364
367
|
const viewValues = viewImplementation[exports.ViewImplementationType.MICHELSON_STORAGE];
|
|
365
368
|
if (!viewValues.returnType || !viewValues.code) {
|
|
@@ -367,7 +370,7 @@
|
|
|
367
370
|
return;
|
|
368
371
|
}
|
|
369
372
|
return () => {
|
|
370
|
-
const view = new MichelsonStorageView(viewName, contract, rpc, viewValues.returnType, viewValues.code, viewValues.parameter);
|
|
373
|
+
const view = new MichelsonStorageView(viewName, contract, rpc, readProvider, viewValues.returnType, viewValues.code, viewValues.parameter);
|
|
371
374
|
return view;
|
|
372
375
|
};
|
|
373
376
|
}
|
|
@@ -376,7 +379,7 @@
|
|
|
376
379
|
return Object.keys(viewImplementation)[0];
|
|
377
380
|
}
|
|
378
381
|
isMichelsonStorageView(viewImplementation) {
|
|
379
|
-
return this.getImplementationType(viewImplementation) === exports.ViewImplementationType.MICHELSON_STORAGE;
|
|
382
|
+
return (this.getImplementationType(viewImplementation) === exports.ViewImplementationType.MICHELSON_STORAGE);
|
|
380
383
|
}
|
|
381
384
|
}
|
|
382
385
|
|
|
@@ -394,15 +397,17 @@
|
|
|
394
397
|
this._metadataProvider = context.metadataProvider;
|
|
395
398
|
}
|
|
396
399
|
findMetadataBigMap() {
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
400
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
401
|
+
const metadataBigMapId = this.constractAbstraction.schema.FindFirstInTopLevelPair(yield this.context.readProvider.getStorage(this.constractAbstraction.address, 'head'), metadataBigMapType);
|
|
402
|
+
if (!metadataBigMapId) {
|
|
403
|
+
throw new BigMapMetadataNotFound();
|
|
404
|
+
}
|
|
405
|
+
return new taquito.BigMapAbstraction(new BigNumber__default["default"](metadataBigMapId['int']), new michelsonEncoder.Schema(metadataBigMapType), this.context.contract);
|
|
406
|
+
});
|
|
402
407
|
}
|
|
403
408
|
getUriOrFail() {
|
|
404
409
|
return __awaiter(this, void 0, void 0, function* () {
|
|
405
|
-
const metadataBigMap = this.findMetadataBigMap();
|
|
410
|
+
const metadataBigMap = yield this.findMetadataBigMap();
|
|
406
411
|
const uri = yield metadataBigMap.get('');
|
|
407
412
|
if (!uri) {
|
|
408
413
|
throw new UriNotFound();
|
|
@@ -458,7 +463,7 @@
|
|
|
458
463
|
if (view.name) {
|
|
459
464
|
// when views have the same name, add an index at the end of the name
|
|
460
465
|
const viewName = this.generateIndexedViewName(view.name, metadataViews);
|
|
461
|
-
const metadataView = this._viewFactory.getView(viewName, this.context.rpc, this.constractAbstraction, viewImplementation);
|
|
466
|
+
const metadataView = this._viewFactory.getView(viewName, this.context.rpc, this.context.readProvider, this.constractAbstraction, viewImplementation);
|
|
462
467
|
if (metadataView) {
|
|
463
468
|
metadataViews[viewName] = metadataView;
|
|
464
469
|
}
|
|
@@ -559,8 +564,8 @@
|
|
|
559
564
|
|
|
560
565
|
// IMPORTANT: THIS FILE IS AUTO GENERATED! DO NOT MANUALLY EDIT OR CHECKIN!
|
|
561
566
|
const VERSION = {
|
|
562
|
-
"commitHash": "
|
|
563
|
-
"version": "
|
|
567
|
+
"commitHash": "8203ea7669c742797022f1b61f2577bcac50ca55",
|
|
568
|
+
"version": "12.0.1"
|
|
564
569
|
};
|
|
565
570
|
|
|
566
571
|
Object.defineProperty(exports, 'bytes2Char', {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"taquito-tzip16.umd.js","sources":["../src/handlers/http-handler.ts","../src/tzip16-errors.ts","../src/handlers/tezos-storage-handler.ts","../src/handlers/ipfs-handler.ts","../src/metadata-interface.ts","../src/viewKind/michelson-storage-view.ts","../src/viewKind/viewFactory.ts","../src/tzip16-contract-abstraction.ts","../src/composer.ts","../src/tzip16-utils.ts","../src/metadata-provider.ts","../src/tzip16-extension.ts","../src/version.ts"],"sourcesContent":["import { HttpBackend } from \"@taquito/http-utils\";\nimport { ContractAbstraction, ContractProvider, Wallet, Context } from \"@taquito/taquito\";\nimport { Handler, Tzip16Uri } from \"../metadata-provider\";\n\nexport class HttpHandler implements Handler {\n httpBackend: HttpBackend;\n constructor() {\n this.httpBackend = new HttpBackend();\n }\n async getMetadata(_contractAbstraction: ContractAbstraction<ContractProvider | Wallet>, { protocol, location }: Tzip16Uri, _context: Context) {\n return this.httpBackend.createRequest<string>({\n url: `${protocol}:${decodeURIComponent(location)}`,\n method: 'GET',\n mimeType: \"text; charset=utf-8\",\n json: false\n })\n }\n}","export class BigMapMetadataNotFound extends Error {\n name = 'BigMapMetadataNotFound';\n\n constructor() {\n super(\n 'Non-compliance with the TZIP-016 standard. No big map named metadata was found in the contract storage.'\n );\n }\n}\n\nexport class MetadataNotFound extends Error {\n name = 'MetadataNotFound';\n\n constructor(public info: string) {\n super(`No metadata was found in the contract storage. ${info}`);\n }\n}\n\nexport class UriNotFound extends Error {\n name = 'UriNotFound';\n constructor() {\n super('Non-compliance with the TZIP-016 standard. No URI found in the contract storage.');\n }\n}\n\nexport class InvalidUri extends Error {\n name = 'InvalidUri';\n\n constructor(public uri: string) {\n super(`Non-compliance with the TZIP-016 standard. The URI is invalid: ${uri}.`);\n }\n}\n\nexport class InvalidMetadata extends Error {\n name = 'InvalidMetadata';\n\n constructor(public invalidMetadata: string) {\n super(\n `The metadata found at the pointed ressource are not compliant with tzip16 standard: ${invalidMetadata}.`\n );\n }\n}\n\nexport class ProtocolNotSupported extends Error {\n name = 'ProtocolNotSupported';\n\n constructor(public protocol: string) {\n super(`The protocol found in the URI is not supported: ${protocol}.`);\n }\n}\n\nexport class InvalidMetadataType extends Error {\n name = 'InvalidMetadataType';\n\n constructor() {\n super(\n 'The contract does not comply with the tzip16 standard. The type of metadata should be bytes.'\n );\n }\n}\n\nexport class UnconfiguredMetadataProviderError extends Error {\n name = 'UnconfiguredMetadataProviderError';\n\n constructor() {\n super(\n 'No metadata provider has been configured. The default one can be configured by calling addExtension(new Tzip16Module()) on your TezosToolkit instance.'\n );\n }\n}\n\nexport class ForbiddenInstructionInViewCode extends Error {\n name = 'ForbiddenInstructionInViewCode';\n\n constructor(public instruction: string) {\n super(\n `Error found in the code of the view. It contains a forbidden instruction: ${instruction}.`\n );\n }\n}\n\nexport class NoParameterExpectedError extends Error {\n name = 'NoParameterExpectedError';\n\n constructor(public viewName: string, public args: any[]) {\n super(`${viewName} Received ${args.length} arguments while expecting no parameter or 'Unit'`);\n }\n}\n\nexport class InvalidViewParameterError extends Error {\n name = 'InvalidViewParameterError';\n\n constructor(public viewName: string, public sigs: any[], public args: any[]) {\n super(\n `${viewName} Received ${\n args.length\n } arguments while expecting one of the following signatures (${JSON.stringify(sigs)})`\n );\n }\n}\n","import { Schema } from '@taquito/michelson-encoder';\nimport { Context, ContractAbstraction, ContractProvider, Wallet } from '@taquito/taquito';\nimport { Handler, Tzip16Uri } from '../metadata-provider';\nimport { bytes2Char } from '@taquito/utils';\nimport {\n InvalidMetadataType,\n BigMapMetadataNotFound,\n InvalidUri,\n MetadataNotFound,\n} from '../tzip16-errors';\n\nconst typeOfValueToFind = {\n prim: 'big_map',\n args: [{ prim: 'string' }, { prim: 'bytes' }],\n annots: ['%metadata'],\n};\n\ntype BigMapId = { int: string };\n\nexport class TezosStorageHandler implements Handler {\n private readonly TEZOS_STORAGE_REGEX = /^(?:\\/\\/(KT1\\w{33})(?:\\.(.+))?\\/)?([\\w|%]+)$/;\n\n async getMetadata(\n contractAbstraction: ContractAbstraction<ContractProvider | Wallet>,\n { location }: Tzip16Uri,\n context: Context\n ) {\n const parsedTezosStorageUri = this.parseTezosStorageUri(location);\n if (!parsedTezosStorageUri) {\n throw new InvalidUri(`tezos-storage:${location}`);\n }\n const storage: any = await context.rpc.getNormalizedScript(\n parsedTezosStorageUri.contractAddress || contractAbstraction.address\n );\n const bigMapId = Schema.fromRPCResponse({ script: storage }).FindFirstInTopLevelPair<BigMapId>(\n storage.storage,\n typeOfValueToFind\n );\n\n if (!bigMapId) {\n throw new BigMapMetadataNotFound();\n }\n\n const bytes = await context.contract.getBigMapKeyByID<string>(\n bigMapId['int'].toString(),\n parsedTezosStorageUri.path,\n new Schema(typeOfValueToFind)\n );\n\n if (!bytes) {\n throw new MetadataNotFound(\n `No '${parsedTezosStorageUri.path}' key found in the big map %metadata of the contract ${\n parsedTezosStorageUri.contractAddress || contractAbstraction.address\n }`\n );\n }\n\n if (!/^[0-9a-fA-F]*$/.test(bytes)) {\n throw new InvalidMetadataType();\n }\n return bytes2Char(bytes);\n }\n\n /**\n * @description Extract the smart contract address, the network and the path pointing to the metadata from the uri\n * @returns an object which contains the properties allowing to find where the metadata are located or it returns undefined if the uri is not valid\n * @param tezosStorageURI URI (without the tezos-storage prefix)\n */\n private parseTezosStorageUri(tezosStorageURI: string) {\n const extractor = this.TEZOS_STORAGE_REGEX.exec(tezosStorageURI);\n if (!extractor) return;\n return {\n contractAddress: extractor[1],\n network: extractor[2],\n path: decodeURIComponent(extractor[3]),\n };\n }\n}\n","import { HttpBackend } from \"@taquito/http-utils\";\nimport { ContractAbstraction, ContractProvider, Wallet, Context } from \"@taquito/taquito\";\nimport { Handler, Tzip16Uri } from \"../metadata-provider\";\n\nexport class IpfsHttpHandler implements Handler {\n private _ipfsGateway: string;\n public httpBackend = new HttpBackend();\n\n constructor(ipfsGatheway?:string){\n this._ipfsGateway = ipfsGatheway? ipfsGatheway: 'ipfs.io';\n }\n\n async getMetadata(_contractAbstraction: ContractAbstraction<ContractProvider | Wallet>, { location }: Tzip16Uri, _context: Context): Promise<string> {\n return this.httpBackend.createRequest<string>({\n url: `https://${this._ipfsGateway}/ipfs/${location.substring(2)}/`,\n method: 'GET',\n headers: {'Content-Type': 'text/plain'},\n mimeType: \"text; charset=utf-8\",\n json: false\n })\n }\n}\n","import { MichelsonV1Expression } from '@taquito/rpc';\nexport interface MetadataInterface {\n\tname?: string;\n\tdescription?: string;\n\tversion?: string;\n\tlicense?: { name: string; details?: string };\n\tauthors?: string[];\n\thomepage?: string;\n\tsource?: { tools?: string[]; location?: string };\n\tinterfaces?: string[];\n\terrors?: ErrorsTzip16;\n\tviews?: Views;\n}\n\nexport type ErrorsTzip16 = Array<\n\t| { error: MichelineTzip16Expression; expansion: MichelineTzip16Expression; languages?: string[] }\n\t| { view: string; languages?: string[] }\n>;\n\nexport enum ViewImplementationType {\n\tMICHELSON_STORAGE = 'michelsonStorageView',\n\tREST_API_QUERY = 'restApiQuery'\n}\n\nexport type ViewImplementation =\n\t| { [ViewImplementationType.MICHELSON_STORAGE]: MichelsonStorageViewType }\n\t| { [ViewImplementationType.REST_API_QUERY]: RestApiQueryType };\n\nexport interface ViewDefinition {\n\tname?: string;\n\tdescription?: string;\n\timplementations?: ViewImplementation[];\n\tpure?: boolean;\n}\n\nexport type Views = ViewDefinition[];\n\nexport type MichelsonStorageViewType = {\n\tparameter?: MichelineTzip16Expression;\n\treturnType: MichelineTzip16Expression;\n\tcode: MichelineTzip16Expression;\n\tannotations?: Array<{ name: string; description: string }>;\n\tversion?: string;\n};\n\nexport type RestApiQueryType = {\n\tspecificationUri: string;\n\tbaseUri?: string;\n\tpath: string;\n\tmethod?: 'GET' | 'POST' | 'PUT';\n};\n\nexport type MichelineTzip16Expression =\n\t| MichelsonV1Expression\n\t| MichelineTzip16Expression[]\n\t| { prim: Unistring; args?: MichelineTzip16Expression[]; annots?: string[] };\n\ntype Unistring = string | { invalid_utf8_string: number[] };\n","import { ParameterSchema } from '@taquito/michelson-encoder';\nimport {\n RpcClientInterface,\n MichelsonV1Expression,\n MichelsonV1ExpressionExtended,\n} from '@taquito/rpc';\nimport {\n ContractAbstraction,\n ContractProvider,\n Wallet,\n ViewSimulationError,\n} from '@taquito/taquito';\nimport {\n ForbiddenInstructionInViewCode,\n InvalidViewParameterError,\n NoParameterExpectedError,\n} from '../tzip16-errors';\nimport { validateAndExtractFailwith } from '@taquito/taquito';\nimport { View } from './interface';\n\nexport class MichelsonStorageView implements View {\n constructor(\n private viewName: string,\n private contract: ContractAbstraction<ContractProvider | Wallet>,\n private rpc: RpcClientInterface,\n private returnType: MichelsonV1Expression,\n private code: MichelsonV1ExpressionExtended[],\n private viewParameterType?: MichelsonV1ExpressionExtended\n ) {}\n\n /**\n * @description According to the tzip-16 standard, the following instructions must not be used in the code of the view:\n * 'AMOUNT', 'CREATE_CONTRACT', 'SENDER', 'SET_DELEGATE', 'SOURCE', and 'TRANSFER_TOKENS'\n * The method throw an error if an illegal instruction is found\n */\n private findForbiddenInstructionInViewCode(code: MichelsonV1ExpressionExtended[]) {\n const illegalInstructions = [\n 'AMOUNT',\n 'CREATE_CONTRACT',\n 'SENDER',\n 'SET_DELEGATE',\n 'SOURCE',\n 'TRANSFER_TOKENS',\n ];\n\n for (const forbiddenInstruction of illegalInstructions) {\n for (const instruction of code) {\n if (instruction.prim === forbiddenInstruction) {\n throw new ForbiddenInstructionInViewCode(forbiddenInstruction);\n }\n if (instruction.args && instruction.args.length !== 0) {\n this.findForbiddenInstructionInViewCode(instruction.args as any);\n }\n }\n }\n }\n\n /**\n * @description According to the tzip-16 standard, in the first version of the specification, the instruction SELF should only be used before ADDRESS\n * The method throws an error is the instruction SELF is present, but not followed by ADDRESS\n */\n private illegalUseOfSelfInstruction(code: MichelsonV1ExpressionExtended[]) {\n for (const instruction of code) {\n if (instruction.prim === 'SELF') {\n const index = code.indexOf(instruction);\n const nextInstruction = code[index + 1] ? code[index + 1].prim : undefined;\n if (nextInstruction !== 'ADDRESS') {\n throw new ForbiddenInstructionInViewCode(\n 'the instruction SELF should only be used before ADDRESS'\n );\n }\n }\n if (instruction.args && instruction.args.length !== 0) {\n this.illegalUseOfSelfInstruction(instruction.args as any);\n }\n }\n }\n\n /**\n * @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.\n */\n private adaptViewCodeToContext(\n code: MichelsonV1ExpressionExtended[],\n contractBalance: string,\n blockTimeStamp: string,\n chainId: string\n ) {\n const instructionsToReplace = {\n SELF: [\n { prim: 'PUSH', args: [{ prim: 'address' }, { string: this.contract.address }] },\n { prim: 'CONTRACT', args: [{ prim: 'unit' }] },\n { prim: 'IF_NONE', args: [[{ prim: 'UNIT' }, { prim: 'FAILWITH' }], []] },\n ],\n BALANCE: [{ prim: 'PUSH', args: [{ prim: 'mutez' }, { int: contractBalance }] }],\n NOW: [{ prim: 'PUSH', args: [{ prim: 'timestamp' }, { string: blockTimeStamp }] }],\n CHAIN_ID: [{ prim: 'PUSH', args: [{ prim: 'string' }, { string: chainId }] }],\n };\n\n code.forEach((x: any, i: any) => {\n for (const instruction in instructionsToReplace) {\n if (x.prim === instruction) {\n code[i] = Object(instructionsToReplace)[instruction];\n }\n if (x.args && x.args.length !== 0) {\n this.adaptViewCodeToContext(x.args, contractBalance, blockTimeStamp, chainId);\n }\n }\n });\n return code;\n }\n\n private validateArgs = (args: any[], schema: ParameterSchema, viewName: string) => {\n const sigs = schema.ExtractSignatures();\n\n if (!sigs.find((x: any[]) => x.length === args.length)) {\n throw new InvalidViewParameterError(viewName, sigs, args);\n }\n };\n\n private formatArgsAndParameter(argView: any[]) {\n let args = argView;\n let viewParameterType = this.viewParameterType;\n if (!viewParameterType) {\n viewParameterType = { args: [], prim: 'unit', annots: [] };\n }\n\n if (viewParameterType.prim === 'unit') {\n if (args.length === 0) {\n args = ['Unit'];\n }\n if (args.length !== 0 && args[0] !== 'Unit') {\n throw new NoParameterExpectedError(this.viewName, argView);\n }\n }\n const parameterViewSchema = new ParameterSchema(viewParameterType);\n this.validateArgs(args, parameterViewSchema, this.viewName);\n const arg = parameterViewSchema.Encode(...args);\n return { arg, viewParameterType };\n }\n\n async executeView(...args: any[]) {\n // validate view code against tzip-16 specifications\n this.findForbiddenInstructionInViewCode(this.code);\n this.illegalUseOfSelfInstruction(this.code);\n\n const { arg, viewParameterType } = this.formatArgsAndParameter(args);\n\n const storageType: any = this.contract.script.code.find((x: any) => x.prim === 'storage');\n const storageArgs = storageType.args[0];\n const storageValue: any = this.contract.script.storage;\n\n // currentContext\n const chainId = await this.rpc.getChainId();\n const contractBalance = (await this.rpc.getBalance(this.contract.address)).toString();\n const block = await this.rpc.getBlock();\n const blockTimestamp = block.header.timestamp.toString();\n\n const code = this.adaptViewCodeToContext(this.code, contractBalance, blockTimestamp, chainId);\n\n if (!this.viewParameterType) {\n code.unshift({ prim: 'CDR' });\n }\n\n const viewScript = {\n script: [\n { prim: 'parameter', args: [{ prim: 'pair', args: [viewParameterType, storageArgs] }] },\n { prim: 'storage', args: [{ prim: 'option', args: [this.returnType] }] },\n {\n prim: 'code',\n args: [\n [\n { prim: 'CAR' },\n code,\n { prim: 'SOME' },\n { prim: 'NIL', args: [{ prim: 'operation' }] },\n { prim: 'PAIR' },\n ],\n ],\n },\n ],\n storage: { prim: 'None' },\n input: { prim: 'Pair', args: [arg, storageValue] },\n amount: '0',\n chain_id: chainId,\n balance: '0',\n };\n\n let result: any;\n try {\n result = await this.rpc.runCode(viewScript as any);\n } catch (error: any) {\n const failWith = validateAndExtractFailwith(error);\n throw failWith\n ? new ViewSimulationError(\n `The simulation of the Michelson view failed with: ${JSON.stringify(failWith)}`,\n this.viewName,\n failWith,\n error\n )\n : error;\n }\n\n const viewResultSchema = new ParameterSchema(this.returnType);\n return viewResultSchema.Execute(result.storage.args[0]);\n }\n}\n","import { RpcClientInterface } from '@taquito/rpc';\nimport { ContractAbstraction, ContractProvider, Wallet } from '@taquito/taquito';\nimport { ViewImplementation, ViewImplementationType } from '../metadata-interface';\nimport { MichelsonStorageView } from './michelson-storage-view';\n\nexport class ViewFactory {\n getView(\n viewName: string,\n rpc: RpcClientInterface,\n contract: ContractAbstraction<ContractProvider | Wallet>,\n viewImplementation: ViewImplementation\n ) {\n if (this.isMichelsonStorageView(viewImplementation)) {\n const viewValues = viewImplementation[ViewImplementationType.MICHELSON_STORAGE];\n if (!viewValues.returnType || !viewValues.code) {\n console.warn(\n `${viewName} is missing mandatory code or returnType property therefore it will be skipped.`\n );\n return;\n }\n return () => {\n const view = new MichelsonStorageView(\n viewName,\n contract,\n rpc,\n viewValues.returnType as any,\n viewValues.code as any,\n viewValues.parameter as any\n );\n return view;\n };\n }\n }\n\n getImplementationType(viewImplementation: ViewImplementation) {\n return Object.keys(viewImplementation)[0];\n }\n\n private isMichelsonStorageView(\n viewImplementation: ViewImplementation\n ): viewImplementation is { [ViewImplementationType.MICHELSON_STORAGE]: any } {\n return this.getImplementationType(viewImplementation) === ViewImplementationType.MICHELSON_STORAGE;\n }\n}\n","import {\n BigMapAbstraction,\n Context,\n ContractAbstraction,\n ContractProvider,\n Wallet,\n} from '@taquito/taquito';\nimport { bytes2Char } from '@taquito/utils';\nimport { MetadataEnvelope, MetadataProviderInterface } from './metadata-provider';\nimport {\n BigMapMetadataNotFound,\n UnconfiguredMetadataProviderError,\n UriNotFound,\n} from './tzip16-errors';\nimport BigNumber from 'bignumber.js';\nimport { Schema } from '@taquito/michelson-encoder';\nimport { ViewFactory } from './viewKind/viewFactory';\nimport { View } from './viewKind/interface';\nimport { ViewDefinition } from './metadata-interface';\n\nexport type MetadataContext = Context & {\n metadataProvider: MetadataProviderInterface;\n};\n\ntype BigMapId = { int: string };\n\nconst metadataBigMapType = {\n prim: 'big_map',\n args: [{ prim: 'string' }, { prim: 'bytes' }],\n annots: ['%metadata'],\n};\nexport class Tzip16ContractAbstraction {\n private _metadataProvider: MetadataProviderInterface;\n private _metadataEnvelope?: MetadataEnvelope;\n private _viewFactory = new ViewFactory();\n private _metadataViewsObject: { [key: string]: () => View } = {};\n\n constructor(\n private constractAbstraction: ContractAbstraction<ContractProvider | Wallet>,\n private context: MetadataContext\n ) {\n this._metadataProvider = context.metadataProvider;\n }\n\n private findMetadataBigMap(): BigMapAbstraction {\n const metadataBigMapId = this.constractAbstraction.schema.FindFirstInTopLevelPair<BigMapId>(\n this.constractAbstraction.script.storage,\n metadataBigMapType\n );\n\n if (!metadataBigMapId) {\n throw new BigMapMetadataNotFound();\n }\n\n return new BigMapAbstraction(\n new BigNumber(metadataBigMapId['int']),\n new Schema(metadataBigMapType),\n this.context.contract\n );\n }\n\n private async getUriOrFail() {\n const metadataBigMap = this.findMetadataBigMap();\n const uri = await metadataBigMap.get<string>('');\n if (!uri) {\n throw new UriNotFound();\n }\n return uri;\n }\n\n /**\n * @description Return an object containing the metadata, the uri, an optional integrity check result and an optional sha256 hash\n */\n async getMetadata() {\n if (!this._metadataProvider) {\n throw new UnconfiguredMetadataProviderError();\n }\n if (!this._metadataEnvelope) {\n const uri = await this.getUriOrFail();\n this._metadataEnvelope = await this._metadataProvider.provideMetadata(\n this.constractAbstraction,\n bytes2Char(uri),\n this.context\n );\n }\n return this._metadataEnvelope;\n }\n\n async metadataViews() {\n if (Object.keys(this._metadataViewsObject).length === 0) {\n await this.initializeMetadataViewsList();\n }\n return this._metadataViewsObject;\n }\n\n private async initializeMetadataViewsList() {\n const { metadata } = await this.getMetadata();\n const metadataViews: any = {};\n metadata.views?.forEach((view) => this.createViewImplementations(view, metadataViews));\n this._metadataViewsObject = metadataViews;\n }\n\n private generateIndexedViewName(viewName: string, metadataViews: object) {\n let i = 1;\n if (viewName in metadataViews) {\n while (`${viewName}${i}` in metadataViews) {\n i++;\n }\n viewName = `${viewName}${i}`;\n }\n return viewName;\n }\n\n private createViewImplementations(view: ViewDefinition, metadataViews: any) {\n for (const viewImplementation of view?.implementations ?? []) {\n if (view.name) {\n // when views have the same name, add an index at the end of the name\n const viewName = this.generateIndexedViewName(view.name, metadataViews);\n const metadataView = this._viewFactory.getView(\n viewName,\n this.context.rpc,\n this.constractAbstraction,\n viewImplementation\n );\n if (metadataView) {\n metadataViews[viewName] = metadataView;\n } else {\n console.warn(\n `Skipped generating ${viewName} because the view has an unsupported type: ${this._viewFactory.getImplementationType(\n viewImplementation\n )}`\n );\n }\n }\n }\n }\n}\n","import { Context, ContractAbstraction, ContractProvider, Wallet } from '@taquito/taquito';\nimport { MetadataContext, Tzip16ContractAbstraction } from './tzip16-contract-abstraction';\n\nconst ABSTRACTION_KEY = Symbol('Tzip16ContractAbstractionObjectKey');\n\nexport function tzip16<T extends ContractAbstraction<ContractProvider | Wallet>>(\n abs: T,\n context: Context\n) {\n return Object.assign(abs, {\n // namespace tzip16\n tzip16(\n this: ContractAbstraction<ContractProvider | Wallet> & {\n [ABSTRACTION_KEY]?: Tzip16ContractAbstraction;\n }\n ) {\n if (!this[ABSTRACTION_KEY]) {\n this[ABSTRACTION_KEY] = new Tzip16ContractAbstraction(this, context as MetadataContext);\n }\n\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n return this[ABSTRACTION_KEY]!;\n },\n });\n}\n","import CryptoJS from \"crypto-js\";\n\nexport function calculateSHA256Hash(preimage: string): string {\n return CryptoJS.SHA256(preimage).toString(CryptoJS.enc.Hex);\n}","import { ContractAbstraction, ContractProvider, Wallet, Context } from '@taquito/taquito';\nimport { MetadataInterface } from './metadata-interface';\nimport { MetadataContext } from './tzip16-contract-abstraction';\nimport { InvalidMetadata, InvalidUri, ProtocolNotSupported } from './tzip16-errors';\nimport { calculateSHA256Hash } from './tzip16-utils';\n\nexport interface MetadataProviderInterface {\n provideMetadata(\n contractAbstraction: ContractAbstraction<ContractProvider | Wallet>,\n uri: string,\n context: MetadataContext\n ): Promise<MetadataEnvelope>;\n}\n\nexport interface MetadataEnvelope {\n uri: string;\n integrityCheckResult?: boolean;\n sha256Hash?: string;\n metadata: MetadataInterface;\n}\nexport interface Handler {\n getMetadata(\n contractAbstraction: ContractAbstraction<ContractProvider | Wallet>,\n uri: Tzip16Uri,\n context: Context\n ): Promise<string>;\n}\n\nexport interface Tzip16Uri {\n sha256hash: string | undefined;\n protocol: string;\n location: string;\n}\n\n/**\n * @description: Metadata Provider\n */\nexport class MetadataProvider implements MetadataProviderInterface {\n private readonly PROTOCOL_REGEX = /(?:sha256:\\/\\/0x(.*)\\/)?(https?|ipfs|tezos-storage):(.*)/;\n\n constructor(private handlers: Map<string, Handler>) {}\n\n /**\n * @description Fetch the metadata by using the appropriate handler based on the protcol found in the URI\n * @returns an object which contains the uri, the metadata, an optional integrity check result and an optional SHA256 hash\n * @param _contractAbstraction the contract abstraction which contains the URI in its storage\n * @param _uri the decoded uri found in the storage\n * @param context the TezosToolkit Context\n */\n async provideMetadata(\n contractAbstraction: ContractAbstraction<ContractProvider | Wallet>,\n uri: string,\n context: Context\n ): Promise<MetadataEnvelope> {\n const uriInfo = this.extractProtocolInfo(uri);\n if (!uriInfo || !uriInfo.location) {\n throw new InvalidUri(uri);\n }\n\n const handler = this.handlers.get(uriInfo.protocol);\n if (!handler) {\n throw new ProtocolNotSupported(uriInfo.protocol);\n }\n\n const metadata = await handler.getMetadata(contractAbstraction, uriInfo, context);\n const sha256Hash = calculateSHA256Hash(metadata);\n let metadataJSON;\n try {\n metadataJSON = JSON.parse(metadata);\n } catch (ex) {\n throw new InvalidMetadata(metadata);\n }\n\n return {\n uri,\n metadata: metadataJSON,\n integrityCheckResult: uriInfo.sha256hash ? uriInfo.sha256hash === sha256Hash : undefined,\n sha256Hash: uriInfo.sha256hash ? sha256Hash : undefined,\n };\n }\n\n private extractProtocolInfo(_uri: string) {\n const extractor = this.PROTOCOL_REGEX.exec(_uri);\n if (!extractor) return;\n return {\n sha256hash: extractor[1],\n protocol: extractor[2],\n location: extractor[3],\n };\n }\n}\n","import { Context, Extension } from \"@taquito/taquito\";\nimport { Handler, MetadataProvider, MetadataProviderInterface } from \"./metadata-provider\";\nimport { HttpHandler } from \"./handlers/http-handler\";\nimport { TezosStorageHandler } from \"./handlers/tezos-storage-handler\";\nimport { IpfsHttpHandler } from \"./handlers/ipfs-handler\";\n\nexport const DEFAULT_HANDLERS = new Map<string, Handler>([\n ['http', new HttpHandler()],\n ['https', new HttpHandler()],\n ['tezos-storage', new TezosStorageHandler()],\n ['ipfs', new IpfsHttpHandler()]\n])\nexport class Tzip16Module implements Extension {\n private _metadataProvider: MetadataProviderInterface;\n\n constructor(metadataProvider?: MetadataProviderInterface) {\n this._metadataProvider = metadataProvider ? metadataProvider : new MetadataProvider(DEFAULT_HANDLERS);\n }\n\n configureContext(context: Context) {\n Object.assign(context, { metadataProvider: this._metadataProvider });\n }\n}","\n// IMPORTANT: THIS FILE IS AUTO GENERATED! DO NOT MANUALLY EDIT OR CHECKIN!\nexport const VERSION = {\n \"commitHash\": \"81f0a5b103f867f57fbe5d526315c375a3788346\",\n \"version\": \"11.2.0\"\n};\n"],"names":["HttpBackend","Schema","bytes2Char","ViewImplementationType","ParameterSchema","validateAndExtractFailwith","ViewSimulationError","BigMapAbstraction","BigNumber","CryptoJS"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;UAIa,WAAW;QAEpB;YACI,IAAI,CAAC,WAAW,GAAG,IAAIA,qBAAW,EAAE,CAAC;SACxC;QACK,WAAW,CAAC,oBAAoE,EAAE,EAAE,QAAQ,EAAE,QAAQ,EAAa,EAAE,QAAiB;;gBACxI,OAAO,IAAI,CAAC,WAAW,CAAC,aAAa,CAAS;oBAC1C,GAAG,EAAE,GAAG,QAAQ,IAAI,kBAAkB,CAAC,QAAQ,CAAC,EAAE;oBAClD,MAAM,EAAE,KAAK;oBACb,QAAQ,EAAE,qBAAqB;oBAC/B,IAAI,EAAE,KAAK;iBACd,CAAC,CAAA;aACL;SAAA;;;UChBQ,sBAAuB,SAAQ,KAAK;QAG/C;YACE,KAAK,CACH,yGAAyG,CAC1G,CAAC;YALJ,SAAI,GAAG,wBAAwB,CAAC;SAM/B;KACF;UAEY,gBAAiB,SAAQ,KAAK;QAGzC,YAAmB,IAAY;YAC7B,KAAK,CAAC,kDAAkD,IAAI,EAAE,CAAC,CAAC;YAD/C,SAAI,GAAJ,IAAI,CAAQ;YAF/B,SAAI,GAAG,kBAAkB,CAAC;SAIzB;KACF;UAEY,WAAY,SAAQ,KAAK;QAEpC;YACE,KAAK,CAAC,kFAAkF,CAAC,CAAC;YAF5F,SAAI,GAAG,aAAa,CAAC;SAGpB;KACF;UAEY,UAAW,SAAQ,KAAK;QAGnC,YAAmB,GAAW;YAC5B,KAAK,CAAC,kEAAkE,GAAG,GAAG,CAAC,CAAC;YAD/D,QAAG,GAAH,GAAG,CAAQ;YAF9B,SAAI,GAAG,YAAY,CAAC;S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,SAAS;oBACxF,UAAU,EAAE,OAAO,CAAC,UAAU,GAAG,UAAU,GAAG,SAAS;iBACxD,CAAC;aACH;SAAA;QAEO,mBAAmB,CAAC,IAAY;YACtC,MAAM,SAAS,GAAG,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;YACjD,IAAI,CAAC,SAAS;gBAAE,OAAO;YACvB,OAAO;gBACL,UAAU,EAAE,SAAS,CAAC,CAAC,CAAC;gBACxB,QAAQ,EAAE,SAAS,CAAC,CAAC,CAAC;gBACtB,QAAQ,EAAE,SAAS,CAAC,CAAC,CAAC;aACvB,CAAC;SACH;;;UCnFU,gBAAgB,GAAG,IAAI,GAAG,CAAkB;QACrD,CAAC,MAAM,EAAE,IAAI,WAAW,EAAE,CAAC;QAC3B,CAAC,OAAO,EAAE,IAAI,WAAW,EAAE,CAAC;QAC5B,CAAC,eAAe,EAAE,IAAI,mBAAmB,EAAE,CAAC;QAC5C,CAAC,MAAM,EAAE,IAAI,eAAe,EAAE,CAAC;KAClC,EAAC;UACW,YAAY;QAGrB,YAAY,gBAA4C;YACpD,IAAI,CAAC,iBAAiB,GAAG,gBAAgB,GAAG,gBAAgB,GAAG,IAAI,gBAAgB,CAAC,gBAAgB,CAAC,CAAC;SACzG;QAED,gBAAgB,CAAC,OAAgB;YAC7B,MAAM,CAAC,MAAM,CAAC,OAAO,EAAE,EAAE,gBAAgB,EAAE,IAAI,CAAC,iBAAiB,EAAE,CAAC,CAAC;SACxE;;;ICpBL;UACa,OAAO,GAAG;QACnB,YAAY,EAAE,0CAA0C;QACxD,SAAS,EAAE,QAAQ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
1
|
+
{"version":3,"file":"taquito-tzip16.umd.js","sources":["../src/handlers/http-handler.ts","../src/tzip16-errors.ts","../src/handlers/tezos-storage-handler.ts","../src/handlers/ipfs-handler.ts","../src/metadata-interface.ts","../src/viewKind/michelson-storage-view.ts","../src/viewKind/viewFactory.ts","../src/tzip16-contract-abstraction.ts","../src/composer.ts","../src/tzip16-utils.ts","../src/metadata-provider.ts","../src/tzip16-extension.ts","../src/version.ts"],"sourcesContent":["import { HttpBackend } from \"@taquito/http-utils\";\nimport { ContractAbstraction, ContractProvider, Wallet, Context } from \"@taquito/taquito\";\nimport { Handler, Tzip16Uri } from \"../metadata-provider\";\n\nexport class HttpHandler implements Handler {\n httpBackend: HttpBackend;\n constructor() {\n this.httpBackend = new HttpBackend();\n }\n async getMetadata(_contractAbstraction: ContractAbstraction<ContractProvider | Wallet>, { protocol, location }: Tzip16Uri, _context: Context) {\n return this.httpBackend.createRequest<string>({\n url: `${protocol}:${decodeURIComponent(location)}`,\n method: 'GET',\n headers: {\n 'Content-Type': 'text/plain; charset=utf-8'\n },\n json: false\n })\n }\n}","export class BigMapMetadataNotFound extends Error {\n name = 'BigMapMetadataNotFound';\n\n constructor() {\n super(\n 'Non-compliance with the TZIP-016 standard. No big map named metadata was found in the contract storage.'\n );\n }\n}\n\nexport class MetadataNotFound extends Error {\n name = 'MetadataNotFound';\n\n constructor(public info: string) {\n super(`No metadata was found in the contract storage. ${info}`);\n }\n}\n\nexport class UriNotFound extends Error {\n name = 'UriNotFound';\n constructor() {\n super('Non-compliance with the TZIP-016 standard. No URI found in the contract storage.');\n }\n}\n\nexport class InvalidUri extends Error {\n name = 'InvalidUri';\n\n constructor(public uri: string) {\n super(`Non-compliance with the TZIP-016 standard. The URI is invalid: ${uri}.`);\n }\n}\n\nexport class InvalidMetadata extends Error {\n name = 'InvalidMetadata';\n\n constructor(public invalidMetadata: string) {\n super(\n `The metadata found at the pointed ressource are not compliant with tzip16 standard: ${invalidMetadata}.`\n );\n }\n}\n\nexport class ProtocolNotSupported extends Error {\n name = 'ProtocolNotSupported';\n\n constructor(public protocol: string) {\n super(`The protocol found in the URI is not supported: ${protocol}.`);\n }\n}\n\nexport class InvalidMetadataType extends Error {\n name = 'InvalidMetadataType';\n\n constructor() {\n super(\n 'The contract does not comply with the tzip16 standard. The type of metadata should be bytes.'\n );\n }\n}\n\nexport class UnconfiguredMetadataProviderError extends Error {\n name = 'UnconfiguredMetadataProviderError';\n\n constructor() {\n super(\n 'No metadata provider has been configured. The default one can be configured by calling addExtension(new Tzip16Module()) on your TezosToolkit instance.'\n );\n }\n}\n\nexport class ForbiddenInstructionInViewCode extends Error {\n name = 'ForbiddenInstructionInViewCode';\n\n constructor(public instruction: string) {\n super(\n `Error found in the code of the view. It contains a forbidden instruction: ${instruction}.`\n );\n }\n}\n\nexport class NoParameterExpectedError extends Error {\n name = 'NoParameterExpectedError';\n\n constructor(public viewName: string, public args: any[]) {\n super(`${viewName} Received ${args.length} arguments while expecting no parameter or 'Unit'`);\n }\n}\n\nexport class InvalidViewParameterError extends Error {\n name = 'InvalidViewParameterError';\n\n constructor(public viewName: string, public sigs: any[], public args: any[]) {\n super(\n `${viewName} Received ${\n args.length\n } arguments while expecting one of the following signatures (${JSON.stringify(sigs)})`\n );\n }\n}\n","import { Schema } from '@taquito/michelson-encoder';\nimport { Context, ContractAbstraction, ContractProvider, Wallet } from '@taquito/taquito';\nimport { Handler, Tzip16Uri } from '../metadata-provider';\nimport { bytes2Char } from '@taquito/utils';\nimport {\n InvalidMetadataType,\n BigMapMetadataNotFound,\n InvalidUri,\n MetadataNotFound,\n} from '../tzip16-errors';\n\nconst typeOfValueToFind = {\n prim: 'big_map',\n args: [{ prim: 'string' }, { prim: 'bytes' }],\n annots: ['%metadata'],\n};\n\ntype BigMapId = { int: string };\n\nexport class TezosStorageHandler implements Handler {\n private readonly TEZOS_STORAGE_REGEX = /^(?:\\/\\/(KT1\\w{33})(?:\\.(.+))?\\/)?([\\w|%]+)$/;\n\n async getMetadata(\n contractAbstraction: ContractAbstraction<ContractProvider | Wallet>,\n { location }: Tzip16Uri,\n context: Context\n ) {\n const parsedTezosStorageUri = this.parseTezosStorageUri(location);\n if (!parsedTezosStorageUri) {\n throw new InvalidUri(`tezos-storage:${location}`);\n }\n const script = await context.readProvider.getScript(\n parsedTezosStorageUri.contractAddress || contractAbstraction.address,\n 'head'\n );\n const bigMapId = Schema.fromRPCResponse({ script }).FindFirstInTopLevelPair<BigMapId>(\n script.storage,\n typeOfValueToFind\n );\n\n if (!bigMapId) {\n throw new BigMapMetadataNotFound();\n }\n\n const bytes = await context.contract.getBigMapKeyByID<string>(\n bigMapId['int'].toString(),\n parsedTezosStorageUri.path,\n new Schema(typeOfValueToFind)\n );\n\n if (!bytes) {\n throw new MetadataNotFound(\n `No '${parsedTezosStorageUri.path}' key found in the big map %metadata of the contract ${\n parsedTezosStorageUri.contractAddress || contractAbstraction.address\n }`\n );\n }\n\n if (!/^[0-9a-fA-F]*$/.test(bytes)) {\n throw new InvalidMetadataType();\n }\n return bytes2Char(bytes);\n }\n\n /**\n * @description Extract the smart contract address, the network and the path pointing to the metadata from the uri\n * @returns an object which contains the properties allowing to find where the metadata are located or it returns undefined if the uri is not valid\n * @param tezosStorageURI URI (without the tezos-storage prefix)\n */\n private parseTezosStorageUri(tezosStorageURI: string) {\n const extractor = this.TEZOS_STORAGE_REGEX.exec(tezosStorageURI);\n if (!extractor) return;\n return {\n contractAddress: extractor[1],\n network: extractor[2],\n path: decodeURIComponent(extractor[3]),\n };\n }\n}\n","import { HttpBackend } from \"@taquito/http-utils\";\nimport { ContractAbstraction, ContractProvider, Wallet, Context } from \"@taquito/taquito\";\nimport { Handler, Tzip16Uri } from \"../metadata-provider\";\n\nexport class IpfsHttpHandler implements Handler {\n private _ipfsGateway: string;\n public httpBackend = new HttpBackend();\n\n constructor(ipfsGatheway?:string){\n this._ipfsGateway = ipfsGatheway? ipfsGatheway: 'ipfs.io';\n }\n\n async getMetadata(_contractAbstraction: ContractAbstraction<ContractProvider | Wallet>, { location }: Tzip16Uri, _context: Context): Promise<string> {\n return this.httpBackend.createRequest<string>({\n url: `https://${this._ipfsGateway}/ipfs/${location.substring(2)}/`,\n method: 'GET',\n headers: {\n 'Content-Type': 'text/plain; charset=utf-8'\n },\n json: false\n })\n }\n}\n","import { MichelsonV1Expression } from '@taquito/rpc';\nexport interface MetadataInterface {\n\tname?: string;\n\tdescription?: string;\n\tversion?: string;\n\tlicense?: { name: string; details?: string };\n\tauthors?: string[];\n\thomepage?: string;\n\tsource?: { tools?: string[]; location?: string };\n\tinterfaces?: string[];\n\terrors?: ErrorsTzip16;\n\tviews?: Views;\n}\n\nexport type ErrorsTzip16 = Array<\n\t| { error: MichelineTzip16Expression; expansion: MichelineTzip16Expression; languages?: string[] }\n\t| { view: string; languages?: string[] }\n>;\n\nexport enum ViewImplementationType {\n\tMICHELSON_STORAGE = 'michelsonStorageView',\n\tREST_API_QUERY = 'restApiQuery'\n}\n\nexport type ViewImplementation =\n\t| { [ViewImplementationType.MICHELSON_STORAGE]: MichelsonStorageViewType }\n\t| { [ViewImplementationType.REST_API_QUERY]: RestApiQueryType };\n\nexport interface ViewDefinition {\n\tname?: string;\n\tdescription?: string;\n\timplementations?: ViewImplementation[];\n\tpure?: boolean;\n}\n\nexport type Views = ViewDefinition[];\n\nexport type MichelsonStorageViewType = {\n\tparameter?: MichelineTzip16Expression;\n\treturnType: MichelineTzip16Expression;\n\tcode: MichelineTzip16Expression;\n\tannotations?: Array<{ name: string; description: string }>;\n\tversion?: string;\n};\n\nexport type RestApiQueryType = {\n\tspecificationUri: string;\n\tbaseUri?: string;\n\tpath: string;\n\tmethod?: 'GET' | 'POST' | 'PUT';\n};\n\nexport type MichelineTzip16Expression =\n\t| MichelsonV1Expression\n\t| MichelineTzip16Expression[]\n\t| { prim: Unistring; args?: MichelineTzip16Expression[]; annots?: string[] };\n\ntype Unistring = string | { invalid_utf8_string: number[] };\n","import { ParameterSchema } from '@taquito/michelson-encoder';\nimport {\n RpcClientInterface,\n MichelsonV1Expression,\n MichelsonV1ExpressionExtended,\n} from '@taquito/rpc';\nimport {\n ContractAbstraction,\n ContractProvider,\n Wallet,\n ViewSimulationError,\n} from '@taquito/taquito';\nimport {\n ForbiddenInstructionInViewCode,\n InvalidViewParameterError,\n NoParameterExpectedError,\n} from '../tzip16-errors';\nimport { validateAndExtractFailwith, TzReadProvider } from '@taquito/taquito';\nimport { View } from './interface';\n\nexport class MichelsonStorageView implements View {\n constructor(\n private viewName: string,\n private contract: ContractAbstraction<ContractProvider | Wallet>,\n private rpc: RpcClientInterface,\n private readProvider: TzReadProvider,\n private returnType: MichelsonV1Expression,\n private code: MichelsonV1ExpressionExtended[],\n private viewParameterType?: MichelsonV1ExpressionExtended\n ) {}\n\n /**\n * @description According to the tzip-16 standard, the following instructions must not be used in the code of the view:\n * 'AMOUNT', 'CREATE_CONTRACT', 'SENDER', 'SET_DELEGATE', 'SOURCE', and 'TRANSFER_TOKENS'\n * The method throw an error if an illegal instruction is found\n */\n private findForbiddenInstructionInViewCode(code: MichelsonV1ExpressionExtended[]) {\n const illegalInstructions = [\n 'AMOUNT',\n 'CREATE_CONTRACT',\n 'SENDER',\n 'SET_DELEGATE',\n 'SOURCE',\n 'TRANSFER_TOKENS',\n ];\n\n for (const forbiddenInstruction of illegalInstructions) {\n for (const instruction of code) {\n if (instruction.prim === forbiddenInstruction) {\n throw new ForbiddenInstructionInViewCode(forbiddenInstruction);\n }\n if (instruction.args && instruction.args.length !== 0) {\n this.findForbiddenInstructionInViewCode(instruction.args as any);\n }\n }\n }\n }\n\n /**\n * @description According to the tzip-16 standard, in the first version of the specification, the instruction SELF should only be used before ADDRESS\n * The method throws an error is the instruction SELF is present, but not followed by ADDRESS\n */\n private illegalUseOfSelfInstruction(code: MichelsonV1ExpressionExtended[]) {\n for (const instruction of code) {\n if (instruction.prim === 'SELF') {\n const index = code.indexOf(instruction);\n const nextInstruction = code[index + 1] ? code[index + 1].prim : undefined;\n if (nextInstruction !== 'ADDRESS') {\n throw new ForbiddenInstructionInViewCode(\n 'the instruction SELF should only be used before ADDRESS'\n );\n }\n }\n if (instruction.args && instruction.args.length !== 0) {\n this.illegalUseOfSelfInstruction(instruction.args as any);\n }\n }\n }\n\n /**\n * @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.\n */\n private adaptViewCodeToContext(\n code: MichelsonV1ExpressionExtended[],\n contractBalance: string,\n blockTimeStamp: string,\n chainId: string\n ) {\n const instructionsToReplace = {\n SELF: [\n { prim: 'PUSH', args: [{ prim: 'address' }, { string: this.contract.address }] },\n { prim: 'CONTRACT', args: [{ prim: 'unit' }] },\n { prim: 'IF_NONE', args: [[{ prim: 'UNIT' }, { prim: 'FAILWITH' }], []] },\n ],\n BALANCE: [{ prim: 'PUSH', args: [{ prim: 'mutez' }, { int: contractBalance }] }],\n NOW: [{ prim: 'PUSH', args: [{ prim: 'timestamp' }, { string: blockTimeStamp }] }],\n CHAIN_ID: [{ prim: 'PUSH', args: [{ prim: 'string' }, { string: chainId }] }],\n };\n\n code.forEach((x: any, i: any) => {\n for (const instruction in instructionsToReplace) {\n if (x.prim === instruction) {\n code[i] = Object(instructionsToReplace)[instruction];\n }\n if (x.args && x.args.length !== 0) {\n this.adaptViewCodeToContext(x.args, contractBalance, blockTimeStamp, chainId);\n }\n }\n });\n return code;\n }\n\n private validateArgs = (args: any[], schema: ParameterSchema, viewName: string) => {\n const sigs = schema.ExtractSignatures();\n\n if (!sigs.find((x: any[]) => x.length === args.length)) {\n throw new InvalidViewParameterError(viewName, sigs, args);\n }\n };\n\n private formatArgsAndParameter(argView: any[]) {\n let args = argView;\n let viewParameterType = this.viewParameterType;\n if (!viewParameterType) {\n viewParameterType = { args: [], prim: 'unit', annots: [] };\n }\n\n if (viewParameterType.prim === 'unit') {\n if (args.length === 0) {\n args = ['Unit'];\n }\n if (args.length !== 0 && args[0] !== 'Unit') {\n throw new NoParameterExpectedError(this.viewName, argView);\n }\n }\n const parameterViewSchema = new ParameterSchema(viewParameterType);\n this.validateArgs(args, parameterViewSchema, this.viewName);\n const arg = parameterViewSchema.Encode(...args);\n return { arg, viewParameterType };\n }\n\n async executeView(...args: any[]) {\n // validate view code against tzip-16 specifications\n this.findForbiddenInstructionInViewCode(this.code);\n this.illegalUseOfSelfInstruction(this.code);\n\n const { arg, viewParameterType } = this.formatArgsAndParameter(args);\n\n const storageType: any = this.contract.script.code.find((x: any) => x.prim === 'storage');\n const storageArgs = storageType.args[0];\n\n // currentContext\n const storageValue: any = await this.readProvider.getStorage(this.contract.address, 'head');\n const chainId = await this.readProvider.getChainId();\n const contractBalance = (\n await this.readProvider.getBalance(this.contract.address, 'head')\n ).toString();\n const blockTimestamp = await this.readProvider.getBlockTimestamp('head');\n\n const code = this.adaptViewCodeToContext(this.code, contractBalance, blockTimestamp, chainId);\n\n if (!this.viewParameterType) {\n code.unshift({ prim: 'CDR' });\n }\n\n const viewScript = {\n script: [\n { prim: 'parameter', args: [{ prim: 'pair', args: [viewParameterType, storageArgs] }] },\n { prim: 'storage', args: [{ prim: 'option', args: [this.returnType] }] },\n {\n prim: 'code',\n args: [\n [\n { prim: 'CAR' },\n code,\n { prim: 'SOME' },\n { prim: 'NIL', args: [{ prim: 'operation' }] },\n { prim: 'PAIR' },\n ],\n ],\n },\n ],\n storage: { prim: 'None' },\n input: { prim: 'Pair', args: [arg, storageValue] },\n amount: '0',\n chain_id: chainId,\n balance: '0',\n };\n\n let result: any;\n try {\n result = await this.rpc.runCode(viewScript as any);\n } catch (error: any) {\n const failWith = validateAndExtractFailwith(error);\n throw failWith\n ? new ViewSimulationError(\n `The simulation of the Michelson view failed with: ${JSON.stringify(failWith)}`,\n this.viewName,\n failWith,\n error\n )\n : error;\n }\n\n const viewResultSchema = new ParameterSchema(this.returnType);\n return viewResultSchema.Execute(result.storage.args[0]);\n }\n}\n","import { RpcClientInterface } from '@taquito/rpc';\nimport { ContractAbstraction, ContractProvider, Wallet, TzReadProvider } from '@taquito/taquito';\nimport { ViewImplementation, ViewImplementationType } from '../metadata-interface';\nimport { MichelsonStorageView } from './michelson-storage-view';\n\nexport class ViewFactory {\n getView(\n viewName: string,\n rpc: RpcClientInterface,\n readProvider: TzReadProvider,\n contract: ContractAbstraction<ContractProvider | Wallet>,\n viewImplementation: ViewImplementation\n ) {\n if (this.isMichelsonStorageView(viewImplementation)) {\n const viewValues = viewImplementation[ViewImplementationType.MICHELSON_STORAGE];\n if (!viewValues.returnType || !viewValues.code) {\n console.warn(\n `${viewName} is missing mandatory code or returnType property therefore it will be skipped.`\n );\n return;\n }\n return () => {\n const view = new MichelsonStorageView(\n viewName,\n contract,\n rpc,\n readProvider,\n viewValues.returnType as any,\n viewValues.code as any,\n viewValues.parameter as any\n );\n return view;\n };\n }\n }\n\n getImplementationType(viewImplementation: ViewImplementation) {\n return Object.keys(viewImplementation)[0];\n }\n\n private isMichelsonStorageView(\n viewImplementation: ViewImplementation\n ): viewImplementation is { [ViewImplementationType.MICHELSON_STORAGE]: any } {\n return (\n this.getImplementationType(viewImplementation) === ViewImplementationType.MICHELSON_STORAGE\n );\n }\n}\n","import {\n BigMapAbstraction,\n Context,\n ContractAbstraction,\n ContractProvider,\n Wallet,\n} from '@taquito/taquito';\nimport { bytes2Char } from '@taquito/utils';\nimport { MetadataEnvelope, MetadataProviderInterface } from './metadata-provider';\nimport {\n BigMapMetadataNotFound,\n UnconfiguredMetadataProviderError,\n UriNotFound,\n} from './tzip16-errors';\nimport BigNumber from 'bignumber.js';\nimport { Schema } from '@taquito/michelson-encoder';\nimport { ViewFactory } from './viewKind/viewFactory';\nimport { View } from './viewKind/interface';\nimport { ViewDefinition } from './metadata-interface';\n\nexport type MetadataContext = Context & {\n metadataProvider: MetadataProviderInterface;\n};\n\ntype BigMapId = { int: string };\n\nconst metadataBigMapType = {\n prim: 'big_map',\n args: [{ prim: 'string' }, { prim: 'bytes' }],\n annots: ['%metadata'],\n};\nexport class Tzip16ContractAbstraction {\n private _metadataProvider: MetadataProviderInterface;\n private _metadataEnvelope?: MetadataEnvelope;\n private _viewFactory = new ViewFactory();\n private _metadataViewsObject: { [key: string]: () => View } = {};\n\n constructor(\n private constractAbstraction: ContractAbstraction<ContractProvider | Wallet>,\n private context: MetadataContext\n ) {\n this._metadataProvider = context.metadataProvider;\n }\n\n private async findMetadataBigMap(): Promise<BigMapAbstraction> {\n const metadataBigMapId = this.constractAbstraction.schema.FindFirstInTopLevelPair<BigMapId>(\n await this.context.readProvider.getStorage(this.constractAbstraction.address, 'head'),\n metadataBigMapType\n );\n\n if (!metadataBigMapId) {\n throw new BigMapMetadataNotFound();\n }\n\n return new BigMapAbstraction(\n new BigNumber(metadataBigMapId['int']),\n new Schema(metadataBigMapType),\n this.context.contract\n );\n }\n\n private async getUriOrFail() {\n const metadataBigMap = await this.findMetadataBigMap();\n const uri = await metadataBigMap.get<string>('');\n if (!uri) {\n throw new UriNotFound();\n }\n return uri;\n }\n\n /**\n * @description Return an object containing the metadata, the uri, an optional integrity check result and an optional sha256 hash\n */\n async getMetadata() {\n if (!this._metadataProvider) {\n throw new UnconfiguredMetadataProviderError();\n }\n if (!this._metadataEnvelope) {\n const uri = await this.getUriOrFail();\n this._metadataEnvelope = await this._metadataProvider.provideMetadata(\n this.constractAbstraction,\n bytes2Char(uri),\n this.context\n );\n }\n return this._metadataEnvelope;\n }\n\n async metadataViews() {\n if (Object.keys(this._metadataViewsObject).length === 0) {\n await this.initializeMetadataViewsList();\n }\n return this._metadataViewsObject;\n }\n\n private async initializeMetadataViewsList() {\n const { metadata } = await this.getMetadata();\n const metadataViews: any = {};\n metadata.views?.forEach((view) => this.createViewImplementations(view, metadataViews));\n this._metadataViewsObject = metadataViews;\n }\n\n private generateIndexedViewName(viewName: string, metadataViews: object) {\n let i = 1;\n if (viewName in metadataViews) {\n while (`${viewName}${i}` in metadataViews) {\n i++;\n }\n viewName = `${viewName}${i}`;\n }\n return viewName;\n }\n\n private createViewImplementations(view: ViewDefinition, metadataViews: any) {\n for (const viewImplementation of view?.implementations ?? []) {\n if (view.name) {\n // when views have the same name, add an index at the end of the name\n const viewName = this.generateIndexedViewName(view.name, metadataViews);\n const metadataView = this._viewFactory.getView(\n viewName,\n this.context.rpc,\n this.context.readProvider,\n this.constractAbstraction,\n viewImplementation\n );\n if (metadataView) {\n metadataViews[viewName] = metadataView;\n } else {\n console.warn(\n `Skipped generating ${viewName} because the view has an unsupported type: ${this._viewFactory.getImplementationType(\n viewImplementation\n )}`\n );\n }\n }\n }\n }\n}\n","import { Context, ContractAbstraction, ContractProvider, Wallet } from '@taquito/taquito';\nimport { MetadataContext, Tzip16ContractAbstraction } from './tzip16-contract-abstraction';\n\nconst ABSTRACTION_KEY = Symbol('Tzip16ContractAbstractionObjectKey');\n\nexport function tzip16<T extends ContractAbstraction<ContractProvider | Wallet>>(\n abs: T,\n context: Context\n) {\n return Object.assign(abs, {\n // namespace tzip16\n tzip16(\n this: ContractAbstraction<ContractProvider | Wallet> & {\n [ABSTRACTION_KEY]?: Tzip16ContractAbstraction;\n }\n ) {\n if (!this[ABSTRACTION_KEY]) {\n this[ABSTRACTION_KEY] = new Tzip16ContractAbstraction(this, context as MetadataContext);\n }\n\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n return this[ABSTRACTION_KEY]!;\n },\n });\n}\n","import CryptoJS from \"crypto-js\";\n\nexport function calculateSHA256Hash(preimage: string): string {\n return CryptoJS.SHA256(preimage).toString(CryptoJS.enc.Hex);\n}","import { ContractAbstraction, ContractProvider, Wallet, Context } from '@taquito/taquito';\nimport { MetadataInterface } from './metadata-interface';\nimport { MetadataContext } from './tzip16-contract-abstraction';\nimport { InvalidMetadata, InvalidUri, ProtocolNotSupported } from './tzip16-errors';\nimport { calculateSHA256Hash } from './tzip16-utils';\n\nexport interface MetadataProviderInterface {\n provideMetadata(\n contractAbstraction: ContractAbstraction<ContractProvider | Wallet>,\n uri: string,\n context: MetadataContext\n ): Promise<MetadataEnvelope>;\n}\n\nexport interface MetadataEnvelope {\n uri: string;\n integrityCheckResult?: boolean;\n sha256Hash?: string;\n metadata: MetadataInterface;\n}\nexport interface Handler {\n getMetadata(\n contractAbstraction: ContractAbstraction<ContractProvider | Wallet>,\n uri: Tzip16Uri,\n context: Context\n ): Promise<string>;\n}\n\nexport interface Tzip16Uri {\n sha256hash: string | undefined;\n protocol: string;\n location: string;\n}\n\n/**\n * @description: Metadata Provider\n */\nexport class MetadataProvider implements MetadataProviderInterface {\n private readonly PROTOCOL_REGEX = /(?:sha256:\\/\\/0x(.*)\\/)?(https?|ipfs|tezos-storage):(.*)/;\n\n constructor(private handlers: Map<string, Handler>) {}\n\n /**\n * @description Fetch the metadata by using the appropriate handler based on the protcol found in the URI\n * @returns an object which contains the uri, the metadata, an optional integrity check result and an optional SHA256 hash\n * @param _contractAbstraction the contract abstraction which contains the URI in its storage\n * @param _uri the decoded uri found in the storage\n * @param context the TezosToolkit Context\n */\n async provideMetadata(\n contractAbstraction: ContractAbstraction<ContractProvider | Wallet>,\n uri: string,\n context: Context\n ): Promise<MetadataEnvelope> {\n const uriInfo = this.extractProtocolInfo(uri);\n if (!uriInfo || !uriInfo.location) {\n throw new InvalidUri(uri);\n }\n\n const handler = this.handlers.get(uriInfo.protocol);\n if (!handler) {\n throw new ProtocolNotSupported(uriInfo.protocol);\n }\n\n const metadata = await handler.getMetadata(contractAbstraction, uriInfo, context);\n const sha256Hash = calculateSHA256Hash(metadata);\n let metadataJSON;\n try {\n metadataJSON = JSON.parse(metadata);\n } catch (ex) {\n throw new InvalidMetadata(metadata);\n }\n\n return {\n uri,\n metadata: metadataJSON,\n integrityCheckResult: uriInfo.sha256hash ? uriInfo.sha256hash === sha256Hash : undefined,\n sha256Hash: uriInfo.sha256hash ? sha256Hash : undefined,\n };\n }\n\n private extractProtocolInfo(_uri: string) {\n const extractor = this.PROTOCOL_REGEX.exec(_uri);\n if (!extractor) return;\n return {\n sha256hash: extractor[1],\n protocol: extractor[2],\n location: extractor[3],\n };\n }\n}\n","import { Context, Extension } from \"@taquito/taquito\";\nimport { Handler, MetadataProvider, MetadataProviderInterface } from \"./metadata-provider\";\nimport { HttpHandler } from \"./handlers/http-handler\";\nimport { TezosStorageHandler } from \"./handlers/tezos-storage-handler\";\nimport { IpfsHttpHandler } from \"./handlers/ipfs-handler\";\n\nexport const DEFAULT_HANDLERS = new Map<string, Handler>([\n ['http', new HttpHandler()],\n ['https', new HttpHandler()],\n ['tezos-storage', new TezosStorageHandler()],\n ['ipfs', new IpfsHttpHandler()]\n])\nexport class Tzip16Module implements Extension {\n private _metadataProvider: MetadataProviderInterface;\n\n constructor(metadataProvider?: MetadataProviderInterface) {\n this._metadataProvider = metadataProvider ? metadataProvider : new MetadataProvider(DEFAULT_HANDLERS);\n }\n\n configureContext(context: Context) {\n Object.assign(context, { metadataProvider: this._metadataProvider });\n }\n}","\n// IMPORTANT: THIS FILE IS AUTO GENERATED! DO NOT MANUALLY EDIT OR CHECKIN!\nexport const VERSION = {\n \"commitHash\": \"8203ea7669c742797022f1b61f2577bcac50ca55\",\n \"version\": \"12.0.1\"\n};\n"],"names":["HttpBackend","Schema","bytes2Char","ViewImplementationType","ParameterSchema","validateAndExtractFailwith","ViewSimulationError","BigMapAbstraction","BigNumber","CryptoJS"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;UAIa,WAAW;QAEpB;YACI,IAAI,CAAC,WAAW,GAAG,IAAIA,qBAAW,EAAE,CAAC;SACxC;QACK,WAAW,CAAC,oBAAoE,EAAE,EAAE,QAAQ,EAAE,QAAQ,EAAa,EAAE,QAAiB;;gBACxI,OAAO,IAAI,CAAC,WAAW,CAAC,aAAa,CAAS;oBAC1C,GAAG,EAAE,GAAG,QAAQ,IAAI,kBAAkB,CAAC,QAAQ,CAAC,EAAE;oBAClD,MAAM,EAAE,KAAK;oBACb,OAAO,EAAE;wBACP,cAAc,EAAE,2BAA2B;qBAC5C;oBACD,IAAI,EAAE,KAAK;iBACd,CAAC,CAAA;aACL;SAAA;;;UClBQ,sBAAuB,SAAQ,KAAK;QAG/C;YACE,KAAK,CACH,yGAAyG,CAC1G,CAAC;YALJ,SAAI,GAAG,wBAAwB,CAAC;SAM/B;KACF;UAEY,gBAAiB,SAAQ,KAAK;QAGzC,YAAmB,IAA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,gBAA4C;YACpD,IAAI,CAAC,iBAAiB,GAAG,gBAAgB,GAAG,gBAAgB,GAAG,IAAI,gBAAgB,CAAC,gBAAgB,CAAC,CAAC;SACzG;QAED,gBAAgB,CAAC,OAAgB;YAC7B,MAAM,CAAC,MAAM,CAAC,OAAO,EAAE,EAAE,gBAAgB,EAAE,IAAI,CAAC,iBAAiB,EAAE,CAAC,CAAC;SACxE;;;ICpBL;UACa,OAAO,GAAG;QACnB,YAAY,EAAE,0CAA0C;QACxD,SAAS,EAAE,QAAQ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -1,14 +1,16 @@
|
|
|
1
1
|
import { RpcClientInterface, MichelsonV1Expression, MichelsonV1ExpressionExtended } from '@taquito/rpc';
|
|
2
2
|
import { ContractAbstraction, ContractProvider, Wallet } from '@taquito/taquito';
|
|
3
|
+
import { TzReadProvider } from '@taquito/taquito';
|
|
3
4
|
import { View } from './interface';
|
|
4
5
|
export declare class MichelsonStorageView implements View {
|
|
5
6
|
private viewName;
|
|
6
7
|
private contract;
|
|
7
8
|
private rpc;
|
|
9
|
+
private readProvider;
|
|
8
10
|
private returnType;
|
|
9
11
|
private code;
|
|
10
12
|
private viewParameterType?;
|
|
11
|
-
constructor(viewName: string, contract: ContractAbstraction<ContractProvider | Wallet>, rpc: RpcClientInterface, returnType: MichelsonV1Expression, code: MichelsonV1ExpressionExtended[], viewParameterType?: MichelsonV1ExpressionExtended | undefined);
|
|
13
|
+
constructor(viewName: string, contract: ContractAbstraction<ContractProvider | Wallet>, rpc: RpcClientInterface, readProvider: TzReadProvider, returnType: MichelsonV1Expression, code: MichelsonV1ExpressionExtended[], viewParameterType?: MichelsonV1ExpressionExtended | undefined);
|
|
12
14
|
/**
|
|
13
15
|
* @description According to the tzip-16 standard, the following instructions must not be used in the code of the view:
|
|
14
16
|
* 'AMOUNT', 'CREATE_CONTRACT', 'SENDER', 'SET_DELEGATE', 'SOURCE', and 'TRANSFER_TOKENS'
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { RpcClientInterface } from '@taquito/rpc';
|
|
2
|
-
import { ContractAbstraction, ContractProvider, Wallet } from '@taquito/taquito';
|
|
2
|
+
import { ContractAbstraction, ContractProvider, Wallet, TzReadProvider } from '@taquito/taquito';
|
|
3
3
|
import { ViewImplementation } from '../metadata-interface';
|
|
4
4
|
import { MichelsonStorageView } from './michelson-storage-view';
|
|
5
5
|
export declare class ViewFactory {
|
|
6
|
-
getView(viewName: string, rpc: RpcClientInterface, contract: ContractAbstraction<ContractProvider | Wallet>, viewImplementation: ViewImplementation): (() => MichelsonStorageView) | undefined;
|
|
6
|
+
getView(viewName: string, rpc: RpcClientInterface, readProvider: TzReadProvider, contract: ContractAbstraction<ContractProvider | Wallet>, viewImplementation: ViewImplementation): (() => MichelsonStorageView) | undefined;
|
|
7
7
|
getImplementationType(viewImplementation: ViewImplementation): string;
|
|
8
8
|
private isMichelsonStorageView;
|
|
9
9
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@taquito/tzip16",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "12.0.1",
|
|
4
4
|
"description": "Tzip16",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"tezos",
|
|
@@ -62,17 +62,17 @@
|
|
|
62
62
|
]
|
|
63
63
|
},
|
|
64
64
|
"dependencies": {
|
|
65
|
-
"@taquito/http-utils": "^
|
|
66
|
-
"@taquito/michelson-encoder": "^
|
|
67
|
-
"@taquito/rpc": "^
|
|
68
|
-
"@taquito/taquito": "^
|
|
69
|
-
"@taquito/utils": "^
|
|
65
|
+
"@taquito/http-utils": "^12.0.1",
|
|
66
|
+
"@taquito/michelson-encoder": "^12.0.1",
|
|
67
|
+
"@taquito/rpc": "^12.0.1",
|
|
68
|
+
"@taquito/taquito": "^12.0.1",
|
|
69
|
+
"@taquito/utils": "^12.0.1",
|
|
70
70
|
"bignumber.js": "^9.0.2",
|
|
71
71
|
"crypto-js": "^4.1.1"
|
|
72
72
|
},
|
|
73
73
|
"devDependencies": {
|
|
74
74
|
"@types/bluebird": "^3.5.36",
|
|
75
|
-
"@types/crypto-js": "^4.1.
|
|
75
|
+
"@types/crypto-js": "^4.1.1",
|
|
76
76
|
"@types/jest": "^26.0.23",
|
|
77
77
|
"@types/node": "^17.0.0",
|
|
78
78
|
"@types/ws": "^8.2.2",
|
|
@@ -101,5 +101,5 @@
|
|
|
101
101
|
"typedoc": "^0.20.36",
|
|
102
102
|
"typescript": "~4.1.5"
|
|
103
103
|
},
|
|
104
|
-
"gitHead": "
|
|
104
|
+
"gitHead": "3cc5f810d80ab04f18b61ac1932c1897ccc22fea"
|
|
105
105
|
}
|