@mavrykdynamics/taquito
Version:
High level functionality that builds upon the other packages in the Mavryk Typescript Library Suite.
41 lines (40 loc) • 1.73 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.smartContractAbstractionSemantic = void 0;
const taquito_michelson_encoder_1 = require("@mavrykdynamics/taquito-michelson-encoder");
const big_map_1 = require("./big-map");
const bignumber_js_1 = require("bignumber.js");
const sapling_state_abstraction_1 = require("./sapling-state-abstraction");
/**
* @description Override the default michelson encoder semantic to provide richer abstraction over storage properties
* @param provider ContractProvider (contract API)
*/
// Override the default michelson encoder semantic to provide richer abstraction over storage properties
const smartContractAbstractionSemantic = (provider) => ({
// Provide a specific abstraction for BigMaps
big_map: (val, code) => {
if (!val || !('int' in val) || val.int === undefined) {
// Return an empty object in case of missing big map ID
return {};
}
else {
const schema = new taquito_michelson_encoder_1.Schema(code);
return new big_map_1.BigMapAbstraction(new bignumber_js_1.default(val.int), schema, provider);
}
},
sapling_state: (val) => {
if (!val || !('int' in val) || val.int === undefined) {
// Return an empty object in case of missing sapling state ID
return {};
}
else {
return new sapling_state_abstraction_1.SaplingStateAbstraction(new bignumber_js_1.default(val.int), provider);
}
},
/*
// TODO: embed useful other abstractions
'contract': () => {},
'address': () => {}
*/
});
exports.smartContractAbstractionSemantic = smartContractAbstractionSemantic;