@taquito/contracts-library 16.2.0 → 17.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,13 +1,18 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.InvalidScriptFormatError = void 0;
4
+ const core_1 = require("@taquito/core");
4
5
  /**
5
6
  * @category Error
6
- * @description Error that indicates invalid script format being useed or passed
7
+ * @description Error indicates invalid script format being useed or passed
7
8
  */
8
- class InvalidScriptFormatError extends Error {
9
- constructor(message) {
10
- super(message);
9
+ class InvalidScriptFormatError extends core_1.ParameterValidationError {
10
+ constructor(message, script, address) {
11
+ super();
12
+ this.message = message;
13
+ this.script = script;
14
+ this.address = address;
15
+ this.name = 'InvalidScriptFormatError';
11
16
  }
12
17
  }
13
18
  exports.InvalidScriptFormatError = InvalidScriptFormatError;
@@ -1 +1 @@
1
- {"version":3,"file":"errors.js","sourceRoot":"","sources":["../../src/errors.ts"],"names":[],"mappings":";;;AAAA;;;GAGG;AACH,MAAa,wBAAyB,SAAQ,KAAK;IACjD,YAAY,OAAe;QACzB,KAAK,CAAC,OAAO,CAAC,CAAC;IACjB,CAAC;CACF;AAJD,4DAIC"}
1
+ {"version":3,"file":"errors.js","sourceRoot":"","sources":["../../src/errors.ts"],"names":[],"mappings":";;;AAAA,wCAAyD;AAEzD;;;GAGG;AACH,MAAa,wBAAyB,SAAQ,+BAAwB;IACpE,YAAmB,OAAe,EAAS,MAAyB,EAAS,OAAe;QAC1F,KAAK,EAAE,CAAC;QADS,YAAO,GAAP,OAAO,CAAQ;QAAS,WAAM,GAAN,MAAM,CAAmB;QAAS,YAAO,GAAP,OAAO,CAAQ;QAE1F,IAAI,CAAC,IAAI,GAAG,0BAA0B,CAAC;IACzC,CAAC;CACF;AALD,4DAKC"}
@@ -42,7 +42,8 @@ class ContractsLibrary {
42
42
  * @param contract is an object where the key is a contract address and the value is an object having a script and an entrypoints properties.
43
43
  * Note: the expected format for the script and entrypoints properties are the same as the one respectivlely returned by
44
44
  * `TezosToolkit.rpc.getContract('contractAddress').script` and `TezosToolkit.rpc.getEntrypoints`
45
- *
45
+ * @throws {@link InvalidAddressError} If the contract address is not valid
46
+ * @throws {@link InvalidScriptFormatError} If the script is not in the expected format
46
47
  */
47
48
  addContract(contract) {
48
49
  for (const contractAddress in contract) {
@@ -65,12 +66,12 @@ class ContractsLibrary {
65
66
  validateContractAddress(address) {
66
67
  const addressValidation = utils_1.validateAddress(address);
67
68
  if (addressValidation !== utils_1.ValidationResult.VALID) {
68
- throw new core_1.InvalidAddressError(address, utils_1.invalidErrorDetail(addressValidation));
69
+ throw new core_1.InvalidAddressError(address, utils_1.invalidDetail(addressValidation));
69
70
  }
70
71
  }
71
72
  validateContractScriptFormat(script, address) {
72
73
  if (!script.code) {
73
- throw new errors_1.InvalidScriptFormatError(`An invalid script property has been provided for ${address}. The script property can be retrieved from TezosToolkit.rpc.getNormalizedScript(${address}). Invalid script: ${script}`);
74
+ throw new errors_1.InvalidScriptFormatError(`Invalid script format of ${address} missing property "code". Valid script can be retrieved from "TezosToolkit.rpc.getNormalizedScript(${address})".`, script, address);
74
75
  }
75
76
  }
76
77
  }
@@ -1 +1 @@
1
- {"version":3,"file":"taquito-contracts-library.js","sourceRoot":"","sources":["../../src/taquito-contracts-library.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAIH,0CAAuF;AACvF,qCAAoD;AACpD,mEAAsE;AACtE,wCAAoD;AAMpD;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,MAAa,gBAAgB;IAA7B;QACU,sBAAiB,GAAkB,EAAE,CAAC;IA6ChD,CAAC;IA3CC;;;;;;;OAOG;IACH,WAAW,CAAC,QAAuB;QACjC,KAAK,MAAM,eAAe,IAAI,QAAQ,EAAE;YACtC,IAAI,CAAC,uBAAuB,CAAC,eAAe,CAAC,CAAC;YAC9C,IAAI,CAAC,4BAA4B,CAAC,QAAQ,CAAC,eAAe,CAAC,CAAC,MAAM,EAAE,eAAe,CAAC,CAAC;YACrF,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,iBAAiB,EAAE;gBACpC,CAAC,eAAe,CAAC,oBAAO,QAAQ,CAAC,eAAe,CAAC,CAAE;aACpD,CAAC,CAAC;SACJ;IACH,CAAC;IAED,WAAW,CAAC,eAAuB;QACjC,OAAO,IAAI,CAAC,iBAAiB,CAAC,eAAe,CAAC,CAAC;IACjD,CAAC;IAED,gBAAgB,CAAC,OAAgB;QAC/B,OAAO,CAAC,yBAAyB,CAAC,CAAC,OAAgB,EAAE,EAAE;YACrD,OAAO,CAAC,YAAY,GAAG,IAAI,mDAA2B,CAAC,OAAO,CAAC,YAAY,EAAE,IAAI,CAAC,CAAC;YACnF,OAAO,OAAO,CAAC;QACjB,CAAC,CAAC,CAAC;IACL,CAAC;IAEO,uBAAuB,CAAC,OAAe;QAC7C,MAAM,iBAAiB,GAAG,uBAAe,CAAC,OAAO,CAAC,CAAC;QACnD,IAAI,iBAAiB,KAAK,wBAAgB,CAAC,KAAK,EAAE;YAChD,MAAM,IAAI,0BAAmB,CAAC,OAAO,EAAE,0BAAkB,CAAC,iBAAiB,CAAC,CAAC,CAAC;SAC/E;IACH,CAAC;IAEO,4BAA4B,CAAC,MAAyB,EAAE,OAAe;QAC7E,IAAI,CAAC,MAAM,CAAC,IAAI,EAAE;YAChB,MAAM,IAAI,iCAAwB,CAChC,oDAAoD,OAAO,oFAAoF,OAAO,sBAAsB,MAAM,EAAE,CACrL,CAAC;SACH;IACH,CAAC;CACF;AA9CD,4CA8CC"}
1
+ {"version":3,"file":"taquito-contracts-library.js","sourceRoot":"","sources":["../../src/taquito-contracts-library.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAIH,0CAAkF;AAClF,qCAAoD;AACpD,mEAAsE;AACtE,wCAAoD;AAMpD;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,MAAa,gBAAgB;IAA7B;QACU,sBAAiB,GAAkB,EAA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Property(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": "adc0f8c31492e8eb2f03b06ac36ba053e8ba6224",
7
- "version": "16.2.0"
6
+ "commitHash": "b357541c90c2168d48216d62a07de5dd3baab9a0",
7
+ "version": "17.0.0"
8
8
  };
9
9
  //# sourceMappingURL=version.js.map
@@ -1,13 +1,17 @@
1
- import { validateAddress, ValidationResult, invalidErrorDetail } from '@taquito/utils';
2
- import { InvalidAddressError } from '@taquito/core';
1
+ import { validateAddress, ValidationResult, invalidDetail } from '@taquito/utils';
2
+ import { ParameterValidationError, InvalidAddressError } from '@taquito/core';
3
3
 
4
4
  /**
5
5
  * @category Error
6
- * @description Error that indicates invalid script format being useed or passed
6
+ * @description Error indicates invalid script format being useed or passed
7
7
  */
8
- class InvalidScriptFormatError extends Error {
9
- constructor(message) {
10
- super(message);
8
+ class InvalidScriptFormatError extends ParameterValidationError {
9
+ constructor(message, script, address) {
10
+ super();
11
+ this.message = message;
12
+ this.script = script;
13
+ this.address = address;
14
+ this.name = 'InvalidScriptFormatError';
11
15
  }
12
16
  }
13
17
 
@@ -150,7 +154,8 @@ class ContractsLibrary {
150
154
  * @param contract is an object where the key is a contract address and the value is an object having a script and an entrypoints properties.
151
155
  * Note: the expected format for the script and entrypoints properties are the same as the one respectivlely returned by
152
156
  * `TezosToolkit.rpc.getContract('contractAddress').script` and `TezosToolkit.rpc.getEntrypoints`
153
- *
157
+ * @throws {@link InvalidAddressError} If the contract address is not valid
158
+ * @throws {@link InvalidScriptFormatError} If the script is not in the expected format
154
159
  */
155
160
  addContract(contract) {
156
161
  for (const contractAddress in contract) {
@@ -173,12 +178,12 @@ class ContractsLibrary {
173
178
  validateContractAddress(address) {
174
179
  const addressValidation = validateAddress(address);
175
180
  if (addressValidation !== ValidationResult.VALID) {
176
- throw new InvalidAddressError(address, invalidErrorDetail(addressValidation));
181
+ throw new InvalidAddressError(address, invalidDetail(addressValidation));
177
182
  }
178
183
  }
179
184
  validateContractScriptFormat(script, address) {
180
185
  if (!script.code) {
181
- throw new InvalidScriptFormatError(`An invalid script property has been provided for ${address}. The script property can be retrieved from TezosToolkit.rpc.getNormalizedScript(${address}). Invalid script: ${script}`);
186
+ throw new InvalidScriptFormatError(`Invalid script format of ${address} missing property "code". Valid script can be retrieved from "TezosToolkit.rpc.getNormalizedScript(${address})".`, script, address);
182
187
  }
183
188
  }
184
189
  }
@@ -1 +1 @@
1
- {"version":3,"file":"taquito-contracts-library.es6.js","sources":["../src/errors.ts","../src/read-provider-wrapper.ts","../src/taquito-contracts-library.ts"],"sourcesContent":["/**\n * @category Error\n * @description Error that indicates invalid script format being useed or passed\n */\nexport class InvalidScriptFormatError extends Error {\n constructor(message: string) {\n super(message);\n }\n}\n","import { BigNumber } from 'bignumber.js';\nimport {\n BlockResponse,\n EntrypointsResponse,\n MichelsonV1Expression,\n SaplingDiffResponse,\n ScriptedContracts,\n} from '@taquito/rpc';\nimport { ContractsLibrary } from './taquito-contracts-library';\nimport { BigMapQuery, BlockIdentifier, SaplingStateQuery, TzReadProvider } from '@taquito/taquito';\n\nexport class ReadWrapperContractsLibrary implements TzReadProvider {\n constructor(private readProvider: TzReadProvider, private contractslibrary: ContractsLibrary) {}\n\n async getScript(address: string, block: BlockIdentifier): Promise<ScriptedContracts> {\n const contractData = this.contractslibrary.getContract(address);\n if (contractData) {\n return contractData.script;\n } else {\n return this.readProvider.getScript(address, block);\n }\n }\n\n async getEntrypoints(contract: string): Promise<EntrypointsResponse> {\n const contractData = this.contractslibrary.getContract(contract);\n if (contractData) {\n return contractData.entrypoints;\n } else {\n return this.readProvider.getEntrypoints(contract);\n }\n }\n\n getBalance(address: string, block: BlockIdentifier): Promise<BigNumber> {\n return this.readProvider.getBalance(address, block);\n }\n getDelegate(address: string, block: BlockIdentifier): Promise<string | null> {\n return this.readProvider.getDelegate(address, block);\n }\n getNextProtocol(block: BlockIdentifier): Promise<string> {\n return this.readProvider.getNextProtocol(block);\n }\n getProtocolConstants(block: BlockIdentifier): Promise<{\n time_between_blocks?: BigNumber[] | undefined;\n minimal_block_delay?: BigNumber | undefined;\n hard_gas_limit_per_operation: BigNumber;\n hard_gas_limit_per_block: BigNumber;\n hard_storage_limit_per_operation: BigNumber;\n cost_per_byte: BigNumber;\n smart_rollup_origination_size: number;\n }> {\n return this.readProvider.getProtocolConstants(block);\n }\n getStorage(contract: string, block: BlockIdentifier): Promise<MichelsonV1Expression> {\n return this.readProvider.getStorage(contract, block);\n }\n getBlockHash(block: BlockIdentifier): Promise<string> {\n return this.readProvider.getBlockHash(block);\n }\n getBlockLevel(block: BlockIdentifier): Promise<number> {\n return this.readProvider.getBlockLevel(block);\n }\n getCounter(pkh: string, block: BlockIdentifier): Promise<string> {\n return this.readProvider.getCounter(pkh, block);\n }\n getBlockTimestamp(block: BlockIdentifier): Promise<string> {\n return this.readProvider.getBlockTimestamp(block);\n }\n getBigMapValue(bigMapQuery: BigMapQuery, block: BlockIdentifier): Promise<MichelsonV1Expression> {\n return this.readProvider.getBigMapValue(bigMapQuery, block);\n }\n getSaplingDiffById(\n saplingStateQuery: SaplingStateQuery,\n block: BlockIdentifier\n ): Promise<SaplingDiffResponse> {\n return this.readProvider.getSaplingDiffById(saplingStateQuery, block);\n }\n getSaplingDiffByContract(\n contractAddress: string,\n block: BlockIdentifier\n ): Promise<SaplingDiffResponse> {\n return this.readProvider.getSaplingDiffByContract(contractAddress, block);\n }\n getChainId(): Promise<string> {\n return this.readProvider.getChainId();\n }\n isAccountRevealed(publicKeyHash: string, block: BlockIdentifier): Promise<boolean> {\n return this.readProvider.isAccountRevealed(publicKeyHash, block);\n }\n getBlock(block: BlockIdentifier): Promise<BlockResponse> {\n return this.readProvider.getBlock(block);\n }\n getLiveBlocks(block: BlockIdentifier): Promise<string[]> {\n return this.readProvider.getLiveBlocks(block);\n }\n}\n","/**\n * @packageDocumentation\n * @module @taquito/contracts-library\n */\n\nimport { EntrypointsResponse, ScriptedContracts } from '@taquito/rpc';\nimport { Extension, Context } from '@taquito/taquito';\nimport { validateAddress, ValidationResult, invalidErrorDetail } from '@taquito/utils';\nimport { InvalidScriptFormatError } from './errors';\nimport { ReadWrapperContractsLibrary } from './read-provider-wrapper';\nimport { InvalidAddressError } from '@taquito/core';\n\ninterface ContractsData {\n [contractAddress: string]: { script: ScriptedContracts; entrypoints: EntrypointsResponse };\n}\n\n/**\n * @description Allows to specify static data related to contracts (i.e., script and entrypoints) avoiding Taquito to fetch them from the network.\n *\n * @example\n * ```\n * import { ContractsLibrary } from '@taquito/contracts-library';\n * import { TezosToolkit } from '@taquito/taquito';\n *\n * const Tezos = new TezosToolkit('rpcUrl');\n * const contractsLibrary = new ContractsLibrary();\n *\n * contractsLibrary.addContract({\n * ['contractAddress1']: {\n * script: script1, // obtained from Tezos.rpc.getContract('contractAddress1').script\n * entrypoints: entrypoints1 // obtained from Tezos.rpc.getEntrypoints('contractAddress1')\n * },\n * // load more contracts\n * });\n *\n * Tezos.addExtension(contractsLibrary);\n * ```\n *\n */\nexport class ContractsLibrary implements Extension {\n private _contractsLibrary: ContractsData = {};\n\n /**\n * @description Saves one of several contract in the library\n *\n * @param contract is an object where the key is a contract address and the value is an object having a script and an entrypoints properties.\n * Note: the expected format for the script and entrypoints properties are the same as the one respectivlely returned by\n * `TezosToolkit.rpc.getContract('contractAddress').script` and `TezosToolkit.rpc.getEntrypoints`\n *\n */\n addContract(contract: ContractsData) {\n for (const contractAddress in contract) {\n this.validateContractAddress(contractAddress);\n this.validateContractScriptFormat(contract[contractAddress].script, contractAddress);\n Object.assign(this._contractsLibrary, {\n [contractAddress]: { ...contract[contractAddress] },\n });\n }\n }\n\n getContract(contractAddress: string) {\n return this._contractsLibrary[contractAddress];\n }\n\n configureContext(context: Context) {\n context.registerProviderDecorator((context: Context) => {\n context.readProvider = new ReadWrapperContractsLibrary(context.readProvider, this);\n return context;\n });\n }\n\n private validateContractAddress(address: string) {\n const addressValidation = validateAddress(address);\n if (addressValidation !== ValidationResult.VALID) {\n throw new InvalidAddressError(address, invalidErrorDetail(addressValidation));\n }\n }\n\n private validateContractScriptFormat(script: ScriptedContracts, address: string) {\n if (!script.code) {\n throw new InvalidScriptFormatError(\n `An invalid script property has been provided for ${address}. The script property can be retrieved from TezosToolkit.rpc.getNormalizedScript(${address}). Invalid script: ${script}`\n );\n }\n }\n}\n"],"names":[],"mappings":";;;AAAA;;;AAGG;AACG,MAAO,wBAAyB,SAAQ,KAAK,CAAA;AACjD,IAAA,WAAA,CAAY,OAAe,EAAA;QACzB,KAAK,CAAC,OAAO,CAAC,CAAC;KAChB;AACF;;;;;;;;;;;;;;;;;;;;;;;;;;;MCGY,2BAA2B,CAAA;IACtC,WAAoB,CAAA,YAA4B,EAAU,gBAAkC,EAAA;QAAxE,IAAY,CAAA,YAAA,GAAZ,YAAY,CAAgB;QAAU,IAAgB,CAAA,gBAAA,GAAhB,gBAAgB,CAAkB;KAAI;IAE1F,SAAS,CAAC,OAAe,EAAE,KAAsB,EAAA;;YACrD,MAAM,YAAY,GAAG,IAAI,CAAC,gBAAgB,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC;AAChE,YAAA,IAAI,YAAY,EAAE;gBAChB,OAAO,YAAY,CAAC,MAAM,CAAC;AAC5B,aAAA;AAAM,iBAAA;gBACL,OAAO,IAAI,CAAC,YAAY,CAAC,SAAS,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;AACpD,aAAA;SACF,CAAA,CAAA;AAAA,KAAA;AAEK,IAAA,cAAc,CAAC,QAAgB,EAAA;;YACnC,MAAM,YAAY,GAAG,IAAI,CAAC,gBAAgB,CAAC,WAAW,CAAC,QAAQ,CAAC,CAAC;AACjE,YAAA,IAAI,YAAY,EAAE;gBAChB,OAAO,YAAY,CAAC,WAAW,CAAC;AACjC,aAAA;AAAM,iBAAA;gBACL,OAAO,IAAI,CAAC,YAAY,CAAC,cAA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AA,CAAC,eAAe,GAAC,MAAA,CAAA,MAAA,CAAA,EAAA,EAAO,QAAQ,CAAC,eAAe,CAAC,CAAE;AACpD,aAAA,CAAC,CAAC;AACJ,SAAA;KACF;AAED,IAAA,WAAW,CAAC,eAAuB,EAAA;AACjC,QAAA,OAAO,IAAI,CAAC,iBAAiB,CAAC,eAAe,CAAC,CAAC;KAChD;AAED,IAAA,gBAAgB,CAAC,OAAgB,EAAA;AAC/B,QAAA,OAAO,CAAC,yBAAyB,CAAC,CAAC,OAAgB,KAAI;AACrD,YAAA,OAAO,CAAC,YAAY,GAAG,IAAI,2BAA2B,CAAC,OAAO,CAAC,YAAY,EAAE,IAAI,CAAC,CAAC;AACnF,YAAA,OAAO,OAAO,CAAC;AACjB,SAAC,CAAC,CAAC;KACJ;AAEO,IAAA,uBAAuB,CAAC,OAAe,EAAA;AAC7C,QAAA,MAAM,iBAAiB,GAAG,eAAe,CAAC,OAAO,CAAC,CAAC;AACnD,QAAA,IAAI,iBAAiB,KAAK,gBAAgB,CAAC,KAAK,EAAE;YAChD,MAAM,IAAI,mBAAmB,CAAC,OAAO,EAAE,kBAAkB,CAAC,iBAAiB,CAAC,CAAC,CAAC;AAC/E,SAAA;KACF;IAEO,4BAA4B,CAAC,MAAyB,EAAE,OAAe,EAAA;AAC7E,QAAA,IAAI,CAAC,MAAM,CAAC,IAAI,EAAE;YAChB,MAAM,IAAI,wBAAwB,CAChC,CAAoD,iDAAA,EAAA,OAAO,CAAoF,iFAAA,EAAA,OAAO,CAAsB,mBAAA,EAAA,MAAM,CAAE,CAAA,CACrL,CAAC;AACH,SAAA;KACF;AACF;;;;"}
1
+ {"version":3,"file":"taquito-contracts-library.es6.js","sources":["../src/errors.ts","../src/read-provider-wrapper.ts","../src/taquito-contracts-library.ts"],"sourcesContent":["import { ParameterValidationError } from '@taquito/core';\nimport { ScriptedContracts } from '@taquito/rpc';\n/**\n * @category Error\n * @description Error indicates invalid script format being useed or passed\n */\nexport class InvalidScriptFormatError extends ParameterValidationError {\n constructor(public message: string, public script: ScriptedContracts, public address: string) {\n super();\n this.name = 'InvalidScriptFormatError';\n }\n}\n","import { BigNumber } from 'bignumber.js';\nimport {\n BlockResponse,\n EntrypointsResponse,\n MichelsonV1Expression,\n SaplingDiffResponse,\n ScriptedContracts,\n} from '@taquito/rpc';\nimport { ContractsLibrary } from './taquito-contracts-library';\nimport { BigMapQuery, BlockIdentifier, SaplingStateQuery, TzReadProvider } from '@taquito/taquito';\n\nexport class ReadWrapperContractsLibrary implements TzReadProvider {\n constructor(private readProvider: TzReadProvider, private contractslibrary: ContractsLibrary) {}\n\n async getScript(address: string, block: BlockIdentifier): Promise<ScriptedContracts> {\n const contractData = this.contractslibrary.getContract(address);\n if (contractData) {\n return contractData.script;\n } else {\n return this.readProvider.getScript(address, block);\n }\n }\n\n async getEntrypoints(contract: string): Promise<EntrypointsResponse> {\n const contractData = this.contractslibrary.getContract(contract);\n if (contractData) {\n return contractData.entrypoints;\n } else {\n return this.readProvider.getEntrypoints(contract);\n }\n }\n\n getBalance(address: string, block: BlockIdentifier): Promise<BigNumber> {\n return this.readProvider.getBalance(address, block);\n }\n getDelegate(address: string, block: BlockIdentifier): Promise<string | null> {\n return this.readProvider.getDelegate(address, block);\n }\n getNextProtocol(block: BlockIdentifier): Promise<string> {\n return this.readProvider.getNextProtocol(block);\n }\n getProtocolConstants(block: BlockIdentifier): Promise<{\n time_between_blocks?: BigNumber[] | undefined;\n minimal_block_delay?: BigNumber | undefined;\n hard_gas_limit_per_operation: BigNumber;\n hard_gas_limit_per_block: BigNumber;\n hard_storage_limit_per_operation: BigNumber;\n cost_per_byte: BigNumber;\n smart_rollup_origination_size: number;\n }> {\n return this.readProvider.getProtocolConstants(block);\n }\n getStorage(contract: string, block: BlockIdentifier): Promise<MichelsonV1Expression> {\n return this.readProvider.getStorage(contract, block);\n }\n getBlockHash(block: BlockIdentifier): Promise<string> {\n return this.readProvider.getBlockHash(block);\n }\n getBlockLevel(block: BlockIdentifier): Promise<number> {\n return this.readProvider.getBlockLevel(block);\n }\n getCounter(pkh: string, block: BlockIdentifier): Promise<string> {\n return this.readProvider.getCounter(pkh, block);\n }\n getBlockTimestamp(block: BlockIdentifier): Promise<string> {\n return this.readProvider.getBlockTimestamp(block);\n }\n getBigMapValue(bigMapQuery: BigMapQuery, block: BlockIdentifier): Promise<MichelsonV1Expression> {\n return this.readProvider.getBigMapValue(bigMapQuery, block);\n }\n getSaplingDiffById(\n saplingStateQuery: SaplingStateQuery,\n block: BlockIdentifier\n ): Promise<SaplingDiffResponse> {\n return this.readProvider.getSaplingDiffById(saplingStateQuery, block);\n }\n getSaplingDiffByContract(\n contractAddress: string,\n block: BlockIdentifier\n ): Promise<SaplingDiffResponse> {\n return this.readProvider.getSaplingDiffByContract(contractAddress, block);\n }\n getChainId(): Promise<string> {\n return this.readProvider.getChainId();\n }\n isAccountRevealed(publicKeyHash: string, block: BlockIdentifier): Promise<boolean> {\n return this.readProvider.isAccountRevealed(publicKeyHash, block);\n }\n getBlock(block: BlockIdentifier): Promise<BlockResponse> {\n return this.readProvider.getBlock(block);\n }\n getLiveBlocks(block: BlockIdentifier): Promise<string[]> {\n return this.readProvider.getLiveBlocks(block);\n }\n}\n","/**\n * @packageDocumentation\n * @module @taquito/contracts-library\n */\n\nimport { EntrypointsResponse, ScriptedContracts } from '@taquito/rpc';\nimport { Extension, Context } from '@taquito/taquito';\nimport { validateAddress, ValidationResult, invalidDetail } from '@taquito/utils';\nimport { InvalidScriptFormatError } from './errors';\nimport { ReadWrapperContractsLibrary } from './read-provider-wrapper';\nimport { InvalidAddressError } from '@taquito/core';\n\ninterface ContractsData {\n [contractAddress: string]: { script: ScriptedContracts; entrypoints: EntrypointsResponse };\n}\n\n/**\n * @description Allows to specify static data related to contracts (i.e., script and entrypoints) avoiding Taquito to fetch them from the network.\n *\n * @example\n * ```\n * import { ContractsLibrary } from '@taquito/contracts-library';\n * import { TezosToolkit } from '@taquito/taquito';\n *\n * const Tezos = new TezosToolkit('rpcUrl');\n * const contractsLibrary = new ContractsLibrary();\n *\n * contractsLibrary.addContract({\n * ['contractAddress1']: {\n * script: script1, // obtained from Tezos.rpc.getContract('contractAddress1').script\n * entrypoints: entrypoints1 // obtained from Tezos.rpc.getEntrypoints('contractAddress1')\n * },\n * // load more contracts\n * });\n *\n * Tezos.addExtension(contractsLibrary);\n * ```\n *\n */\nexport class ContractsLibrary implements Extension {\n private _contractsLibrary: ContractsData = {};\n\n /**\n * @description Saves one of several contract in the library\n *\n * @param contract is an object where the key is a contract address and the value is an object having a script and an entrypoints properties.\n * Note: the expected format for the script and entrypoints properties are the same as the one respectivlely returned by\n * `TezosToolkit.rpc.getContract('contractAddress').script` and `TezosToolkit.rpc.getEntrypoints`\n * @throws {@link InvalidAddressError} If the contract address is not valid\n * @throws {@link InvalidScriptFormatError} If the script is not in the expected format\n */\n addContract(contract: ContractsData) {\n for (const contractAddress in contract) {\n this.validateContractAddress(contractAddress);\n this.validateContractScriptFormat(contract[contractAddress].script, contractAddress);\n Object.assign(this._contractsLibrary, {\n [contractAddress]: { ...contract[contractAddress] },\n });\n }\n }\n\n getContract(contractAddress: string) {\n return this._contractsLibrary[contractAddress];\n }\n\n configureContext(context: Context) {\n context.registerProviderDecorator((context: Context) => {\n context.readProvider = new ReadWrapperContractsLibrary(context.readProvider, this);\n return context;\n });\n }\n\n private validateContractAddress(address: string) {\n const addressValidation = validateAddress(address);\n if (addressValidation !== ValidationResult.VALID) {\n throw new InvalidAddressError(address, invalidDetail(addressValidation));\n }\n }\n\n private validateContractScriptFormat(script: ScriptedContracts, address: string) {\n if (!script.code) {\n throw new InvalidScriptFormatError(\n `Invalid script format of ${address} missing property \"code\". Valid script can be retrieved from \"TezosToolkit.rpc.getNormalizedScript(${address})\".`,\n script,\n address\n );\n }\n }\n}\n"],"names":[],"mappings":";;;AAEA;;;AAGG;AACG,MAAO,wBAAyB,SAAQ,wBAAwB,CAAA;AACpE,IAAA,WAAA,CAAmB,OAAe,EAAS,MA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C,iBAAiB,CAAC,eAAe,CAAC,CAAC;KAChD;AAED,IAAA,gBAAgB,CAAC,OAAgB,EAAA;AAC/B,QAAA,OAAO,CAAC,yBAAyB,CAAC,CAAC,OAAgB,KAAI;AACrD,YAAA,OAAO,CAAC,YAAY,GAAG,IAAI,2BAA2B,CAAC,OAAO,CAAC,YAAY,EAAE,IAAI,CAAC,CAAC;AACnF,YAAA,OAAO,OAAO,CAAC;AACjB,SAAC,CAAC,CAAC;KACJ;AAEO,IAAA,uBAAuB,CAAC,OAAe,EAAA;AAC7C,QAAA,MAAM,iBAAiB,GAAG,eAAe,CAAC,OAAO,CAAC,CAAC;AACnD,QAAA,IAAI,iBAAiB,KAAK,gBAAgB,CAAC,KAAK,EAAE;YAChD,MAAM,IAAI,mBAAmB,CAAC,OAAO,EAAE,aAAa,CAAC,iBAAiB,CAAC,CAAC,CAAC;AAC1E,SAAA;KACF;IAEO,4BAA4B,CAAC,MAAyB,EAAE,OAAe,EAAA;AAC7E,QAAA,IAAI,CAAC,MAAM,CAAC,IAAI,EAAE;AAChB,YAAA,MAAM,IAAI,wBAAwB,CAChC,CAAA,yBAAA,EAA4B,OAAO,CAAA,mGAAA,EAAsG,OAAO,CAAA,GAAA,CAAK,EACrJ,MAAM,EACN,OAAO,CACR,CAAC;AACH,SAAA;KACF;AACF;;;;"}
@@ -6,11 +6,15 @@
6
6
 
7
7
  /**
8
8
  * @category Error
9
- * @description Error that indicates invalid script format being useed or passed
9
+ * @description Error indicates invalid script format being useed or passed
10
10
  */
11
- class InvalidScriptFormatError extends Error {
12
- constructor(message) {
13
- super(message);
11
+ class InvalidScriptFormatError extends core.ParameterValidationError {
12
+ constructor(message, script, address) {
13
+ super();
14
+ this.message = message;
15
+ this.script = script;
16
+ this.address = address;
17
+ this.name = 'InvalidScriptFormatError';
14
18
  }
15
19
  }
16
20
 
@@ -153,7 +157,8 @@
153
157
  * @param contract is an object where the key is a contract address and the value is an object having a script and an entrypoints properties.
154
158
  * Note: the expected format for the script and entrypoints properties are the same as the one respectivlely returned by
155
159
  * `TezosToolkit.rpc.getContract('contractAddress').script` and `TezosToolkit.rpc.getEntrypoints`
156
- *
160
+ * @throws {@link InvalidAddressError} If the contract address is not valid
161
+ * @throws {@link InvalidScriptFormatError} If the script is not in the expected format
157
162
  */
158
163
  addContract(contract) {
159
164
  for (const contractAddress in contract) {
@@ -176,12 +181,12 @@
176
181
  validateContractAddress(address) {
177
182
  const addressValidation = utils.validateAddress(address);
178
183
  if (addressValidation !== utils.ValidationResult.VALID) {
179
- throw new core.InvalidAddressError(address, utils.invalidErrorDetail(addressValidation));
184
+ throw new core.InvalidAddressError(address, utils.invalidDetail(addressValidation));
180
185
  }
181
186
  }
182
187
  validateContractScriptFormat(script, address) {
183
188
  if (!script.code) {
184
- throw new InvalidScriptFormatError(`An invalid script property has been provided for ${address}. The script property can be retrieved from TezosToolkit.rpc.getNormalizedScript(${address}). Invalid script: ${script}`);
189
+ throw new InvalidScriptFormatError(`Invalid script format of ${address} missing property "code". Valid script can be retrieved from "TezosToolkit.rpc.getNormalizedScript(${address})".`, script, address);
185
190
  }
186
191
  }
187
192
  }
@@ -1 +1 @@
1
- {"version":3,"file":"taquito-contracts-library.umd.js","sources":["../src/errors.ts","../src/read-provider-wrapper.ts","../src/taquito-contracts-library.ts"],"sourcesContent":["/**\n * @category Error\n * @description Error that indicates invalid script format being useed or passed\n */\nexport class InvalidScriptFormatError extends Error {\n constructor(message: string) {\n super(message);\n }\n}\n","import { BigNumber } from 'bignumber.js';\nimport {\n BlockResponse,\n EntrypointsResponse,\n MichelsonV1Expression,\n SaplingDiffResponse,\n ScriptedContracts,\n} from '@taquito/rpc';\nimport { ContractsLibrary } from './taquito-contracts-library';\nimport { BigMapQuery, BlockIdentifier, SaplingStateQuery, TzReadProvider } from '@taquito/taquito';\n\nexport class ReadWrapperContractsLibrary implements TzReadProvider {\n constructor(private readProvider: TzReadProvider, private contractslibrary: ContractsLibrary) {}\n\n async getScript(address: string, block: BlockIdentifier): Promise<ScriptedContracts> {\n const contractData = this.contractslibrary.getContract(address);\n if (contractData) {\n return contractData.script;\n } else {\n return this.readProvider.getScript(address, block);\n }\n }\n\n async getEntrypoints(contract: string): Promise<EntrypointsResponse> {\n const contractData = this.contractslibrary.getContract(contract);\n if (contractData) {\n return contractData.entrypoints;\n } else {\n return this.readProvider.getEntrypoints(contract);\n }\n }\n\n getBalance(address: string, block: BlockIdentifier): Promise<BigNumber> {\n return this.readProvider.getBalance(address, block);\n }\n getDelegate(address: string, block: BlockIdentifier): Promise<string | null> {\n return this.readProvider.getDelegate(address, block);\n }\n getNextProtocol(block: BlockIdentifier): Promise<string> {\n return this.readProvider.getNextProtocol(block);\n }\n getProtocolConstants(block: BlockIdentifier): Promise<{\n time_between_blocks?: BigNumber[] | undefined;\n minimal_block_delay?: BigNumber | undefined;\n hard_gas_limit_per_operation: BigNumber;\n hard_gas_limit_per_block: BigNumber;\n hard_storage_limit_per_operation: BigNumber;\n cost_per_byte: BigNumber;\n smart_rollup_origination_size: number;\n }> {\n return this.readProvider.getProtocolConstants(block);\n }\n getStorage(contract: string, block: BlockIdentifier): Promise<MichelsonV1Expression> {\n return this.readProvider.getStorage(contract, block);\n }\n getBlockHash(block: BlockIdentifier): Promise<string> {\n return this.readProvider.getBlockHash(block);\n }\n getBlockLevel(block: BlockIdentifier): Promise<number> {\n return this.readProvider.getBlockLevel(block);\n }\n getCounter(pkh: string, block: BlockIdentifier): Promise<string> {\n return this.readProvider.getCounter(pkh, block);\n }\n getBlockTimestamp(block: BlockIdentifier): Promise<string> {\n return this.readProvider.getBlockTimestamp(block);\n }\n getBigMapValue(bigMapQuery: BigMapQuery, block: BlockIdentifier): Promise<MichelsonV1Expression> {\n return this.readProvider.getBigMapValue(bigMapQuery, block);\n }\n getSaplingDiffById(\n saplingStateQuery: SaplingStateQuery,\n block: BlockIdentifier\n ): Promise<SaplingDiffResponse> {\n return this.readProvider.getSaplingDiffById(saplingStateQuery, block);\n }\n getSaplingDiffByContract(\n contractAddress: string,\n block: BlockIdentifier\n ): Promise<SaplingDiffResponse> {\n return this.readProvider.getSaplingDiffByContract(contractAddress, block);\n }\n getChainId(): Promise<string> {\n return this.readProvider.getChainId();\n }\n isAccountRevealed(publicKeyHash: string, block: BlockIdentifier): Promise<boolean> {\n return this.readProvider.isAccountRevealed(publicKeyHash, block);\n }\n getBlock(block: BlockIdentifier): Promise<BlockResponse> {\n return this.readProvider.getBlock(block);\n }\n getLiveBlocks(block: BlockIdentifier): Promise<string[]> {\n return this.readProvider.getLiveBlocks(block);\n }\n}\n","/**\n * @packageDocumentation\n * @module @taquito/contracts-library\n */\n\nimport { EntrypointsResponse, ScriptedContracts } from '@taquito/rpc';\nimport { Extension, Context } from '@taquito/taquito';\nimport { validateAddress, ValidationResult, invalidErrorDetail } from '@taquito/utils';\nimport { InvalidScriptFormatError } from './errors';\nimport { ReadWrapperContractsLibrary } from './read-provider-wrapper';\nimport { InvalidAddressError } from '@taquito/core';\n\ninterface ContractsData {\n [contractAddress: string]: { script: ScriptedContracts; entrypoints: EntrypointsResponse };\n}\n\n/**\n * @description Allows to specify static data related to contracts (i.e., script and entrypoints) avoiding Taquito to fetch them from the network.\n *\n * @example\n * ```\n * import { ContractsLibrary } from '@taquito/contracts-library';\n * import { TezosToolkit } from '@taquito/taquito';\n *\n * const Tezos = new TezosToolkit('rpcUrl');\n * const contractsLibrary = new ContractsLibrary();\n *\n * contractsLibrary.addContract({\n * ['contractAddress1']: {\n * script: script1, // obtained from Tezos.rpc.getContract('contractAddress1').script\n * entrypoints: entrypoints1 // obtained from Tezos.rpc.getEntrypoints('contractAddress1')\n * },\n * // load more contracts\n * });\n *\n * Tezos.addExtension(contractsLibrary);\n * ```\n *\n */\nexport class ContractsLibrary implements Extension {\n private _contractsLibrary: ContractsData = {};\n\n /**\n * @description Saves one of several contract in the library\n *\n * @param contract is an object where the key is a contract address and the value is an object having a script and an entrypoints properties.\n * Note: the expected format for the script and entrypoints properties are the same as the one respectivlely returned by\n * `TezosToolkit.rpc.getContract('contractAddress').script` and `TezosToolkit.rpc.getEntrypoints`\n *\n */\n addContract(contract: ContractsData) {\n for (const contractAddress in contract) {\n this.validateContractAddress(contractAddress);\n this.validateContractScriptFormat(contract[contractAddress].script, contractAddress);\n Object.assign(this._contractsLibrary, {\n [contractAddress]: { ...contract[contractAddress] },\n });\n }\n }\n\n getContract(contractAddress: string) {\n return this._contractsLibrary[contractAddress];\n }\n\n configureContext(context: Context) {\n context.registerProviderDecorator((context: Context) => {\n context.readProvider = new ReadWrapperContractsLibrary(context.readProvider, this);\n return context;\n });\n }\n\n private validateContractAddress(address: string) {\n const addressValidation = validateAddress(address);\n if (addressValidation !== ValidationResult.VALID) {\n throw new InvalidAddressError(address, invalidErrorDetail(addressValidation));\n }\n }\n\n private validateContractScriptFormat(script: ScriptedContracts, address: string) {\n if (!script.code) {\n throw new InvalidScriptFormatError(\n `An invalid script property has been provided for ${address}. The script property can be retrieved from TezosToolkit.rpc.getNormalizedScript(${address}). Invalid script: ${script}`\n );\n }\n }\n}\n"],"names":["validateAddress","ValidationResult","InvalidAddressError","invalidErrorDetail"],"mappings":";;;;;;EAAA;;;EAGG;EACG,MAAO,wBAAyB,SAAQ,KAAK,CAAA;EACjD,IAAA,WAAA,CAAY,OAAe,EAAA;UACzB,KAAK,CAAC,OAAO,CAAC,CAAC;OAChB;EACF;;;;;;;;;;;;;;;;;;;;;;;;;;;QCGY,2BAA2B,CAAA;MACtC,WAAoB,CAAA,YAA4B,EAAU,gBAAkC,EAAA;UAAxE,IAAY,CAAA,YAAA,GAAZ,YAAY,CAAgB;UAAU,IAAgB,CAAA,gBAAA,GAAhB,gBAAgB,CAAkB;OAAI;MAE1F,SAAS,CAAC,OAAe,EAAE,KAAsB,EAAA;;cACrD,MAAM,YAAY,GAAG,IAAI,CAAC,gBAAgB,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC;EAChE,YAAA,IAAI,YAAY,EAAE;kBAChB,OAAO,YAAY,CAAC,MAA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,CAAC,MAAM,CAAC,IAAI,EAAE;cAChB,MAAM,IAAI,wBAAwB,CAChC,CAAoD,iDAAA,EAAA,OAAO,CAAoF,iFAAA,EAAA,OAAO,CAAsB,mBAAA,EAAA,MAAM,CAAE,CAAA,CACrL,CAAC;EACH,SAAA;OACF;EACF;;;;;;;;;;"}
1
+ {"version":3,"file":"taquito-contracts-library.umd.js","sources":["../src/errors.ts","../src/read-provider-wrapper.ts","../src/taquito-contracts-library.ts"],"sourcesContent":["import { ParameterValidationError } from '@taquito/core';\nimport { ScriptedContracts } from '@taquito/rpc';\n/**\n * @category Error\n * @description Error indicates invalid script format being useed or passed\n */\nexport class InvalidScriptFormatError extends ParameterValidationError {\n constructor(public message: string, public script: ScriptedContracts, public address: string) {\n super();\n this.name = 'InvalidScriptFormatError';\n }\n}\n","import { BigNumber } from 'bignumber.js';\nimport {\n BlockResponse,\n EntrypointsResponse,\n MichelsonV1Expression,\n SaplingDiffResponse,\n ScriptedContracts,\n} from '@taquito/rpc';\nimport { ContractsLibrary } from './taquito-contracts-library';\nimport { BigMapQuery, BlockIdentifier, SaplingStateQuery, TzReadProvider } from '@taquito/taquito';\n\nexport class ReadWrapperContractsLibrary implements TzReadProvider {\n constructor(private readProvider: TzReadProvider, private contractslibrary: ContractsLibrary) {}\n\n async getScript(address: string, block: BlockIdentifier): Promise<ScriptedContracts> {\n const contractData = this.contractslibrary.getContract(address);\n if (contractData) {\n return contractData.script;\n } else {\n return this.readProvider.getScript(address, block);\n }\n }\n\n async getEntrypoints(contract: string): Promise<EntrypointsResponse> {\n const contractData = this.contractslibrary.getContract(contract);\n if (contractData) {\n return contractData.entrypoints;\n } else {\n return this.readProvider.getEntrypoints(contract);\n }\n }\n\n getBalance(address: string, block: BlockIdentifier): Promise<BigNumber> {\n return this.readProvider.getBalance(address, block);\n }\n getDelegate(address: string, block: BlockIdentifier): Promise<string | null> {\n return this.readProvider.getDelegate(address, block);\n }\n getNextProtocol(block: BlockIdentifier): Promise<string> {\n return this.readProvider.getNextProtocol(block);\n }\n getProtocolConstants(block: BlockIdentifier): Promise<{\n time_between_blocks?: BigNumber[] | undefined;\n minimal_block_delay?: BigNumber | undefined;\n hard_gas_limit_per_operation: BigNumber;\n hard_gas_limit_per_block: BigNumber;\n hard_storage_limit_per_operation: BigNumber;\n cost_per_byte: BigNumber;\n smart_rollup_origination_size: number;\n }> {\n return this.readProvider.getProtocolConstants(block);\n }\n getStorage(contract: string, block: BlockIdentifier): Promise<MichelsonV1Expression> {\n return this.readProvider.getStorage(contract, block);\n }\n getBlockHash(block: BlockIdentifier): Promise<string> {\n return this.readProvider.getBlockHash(block);\n }\n getBlockLevel(block: BlockIdentifier): Promise<number> {\n return this.readProvider.getBlockLevel(block);\n }\n getCounter(pkh: string, block: BlockIdentifier): Promise<string> {\n return this.readProvider.getCounter(pkh, block);\n }\n getBlockTimestamp(block: BlockIdentifier): Promise<string> {\n return this.readProvider.getBlockTimestamp(block);\n }\n getBigMapValue(bigMapQuery: BigMapQuery, block: BlockIdentifier): Promise<MichelsonV1Expression> {\n return this.readProvider.getBigMapValue(bigMapQuery, block);\n }\n getSaplingDiffById(\n saplingStateQuery: SaplingStateQuery,\n block: BlockIdentifier\n ): Promise<SaplingDiffResponse> {\n return this.readProvider.getSaplingDiffById(saplingStateQuery, block);\n }\n getSaplingDiffByContract(\n contractAddress: string,\n block: BlockIdentifier\n ): Promise<SaplingDiffResponse> {\n return this.readProvider.getSaplingDiffByContract(contractAddress, block);\n }\n getChainId(): Promise<string> {\n return this.readProvider.getChainId();\n }\n isAccountRevealed(publicKeyHash: string, block: BlockIdentifier): Promise<boolean> {\n return this.readProvider.isAccountRevealed(publicKeyHash, block);\n }\n getBlock(block: BlockIdentifier): Promise<BlockResponse> {\n return this.readProvider.getBlock(block);\n }\n getLiveBlocks(block: BlockIdentifier): Promise<string[]> {\n return this.readProvider.getLiveBlocks(block);\n }\n}\n","/**\n * @packageDocumentation\n * @module @taquito/contracts-library\n */\n\nimport { EntrypointsResponse, ScriptedContracts } from '@taquito/rpc';\nimport { Extension, Context } from '@taquito/taquito';\nimport { validateAddress, ValidationResult, invalidDetail } from '@taquito/utils';\nimport { InvalidScriptFormatError } from './errors';\nimport { ReadWrapperContractsLibrary } from './read-provider-wrapper';\nimport { InvalidAddressError } from '@taquito/core';\n\ninterface ContractsData {\n [contractAddress: string]: { script: ScriptedContracts; entrypoints: EntrypointsResponse };\n}\n\n/**\n * @description Allows to specify static data related to contracts (i.e., script and entrypoints) avoiding Taquito to fetch them from the network.\n *\n * @example\n * ```\n * import { ContractsLibrary } from '@taquito/contracts-library';\n * import { TezosToolkit } from '@taquito/taquito';\n *\n * const Tezos = new TezosToolkit('rpcUrl');\n * const contractsLibrary = new ContractsLibrary();\n *\n * contractsLibrary.addContract({\n * ['contractAddress1']: {\n * script: script1, // obtained from Tezos.rpc.getContract('contractAddress1').script\n * entrypoints: entrypoints1 // obtained from Tezos.rpc.getEntrypoints('contractAddress1')\n * },\n * // load more contracts\n * });\n *\n * Tezos.addExtension(contractsLibrary);\n * ```\n *\n */\nexport class ContractsLibrary implements Extension {\n private _contractsLibrary: ContractsData = {};\n\n /**\n * @description Saves one of several contract in the library\n *\n * @param contract is an object where the key is a contract address and the value is an object having a script and an entrypoints properties.\n * Note: the expected format for the script and entrypoints properties are the same as the one respectivlely returned by\n * `TezosToolkit.rpc.getContract('contractAddress').script` and `TezosToolkit.rpc.getEntrypoints`\n * @throws {@link InvalidAddressError} If the contract address is not valid\n * @throws {@link InvalidScriptFormatError} If the script is not in the expected format\n */\n addContract(contract: ContractsData) {\n for (const contractAddress in contract) {\n this.validateContractAddress(contractAddress);\n this.validateContractScriptFormat(contract[contractAddress].script, contractAddress);\n Object.assign(this._contractsLibrary, {\n [contractAddress]: { ...contract[contractAddress] },\n });\n }\n }\n\n getContract(contractAddress: string) {\n return this._contractsLibrary[contractAddress];\n }\n\n configureContext(context: Context) {\n context.registerProviderDecorator((context: Context) => {\n context.readProvider = new ReadWrapperContractsLibrary(context.readProvider, this);\n return context;\n });\n }\n\n private validateContractAddress(address: string) {\n const addressValidation = validateAddress(address);\n if (addressValidation !== ValidationResult.VALID) {\n throw new InvalidAddressError(address, invalidDetail(addressValidation));\n }\n }\n\n private validateContractScriptFormat(script: ScriptedContracts, address: string) {\n if (!script.code) {\n throw new InvalidScriptFormatError(\n `Invalid script format of ${address} missing property \"code\". Valid script can be retrieved from \"TezosToolkit.rpc.getNormalizedScript(${address})\".`,\n script,\n address\n );\n }\n }\n}\n"],"names":["ParameterValidationError","validateAddress","ValidationResult","InvalidAddressError","invalidDetail"],"mappings":";;;;;;EAEA;;;EAGG;EACG,MAAO,wBAAyB,SAAQA,6BAAwB,CAAA;EACpE,IAAA,WAAA,CAAmB,OAAe,EAAS,MAAyB,EAAS,OAAe,EAAA;EAC1F,QAAA,KAAK,EAAE,CAAC;UADS,IAAO,CAAA,OAAA,GAAP,OAAO,CAAQ;UAAS,IAAM,CAAA,MAAA,GAAN,MAAM,CAAmB;UAAS,IAAO,CAAA,OAAA,GAAP,OAAO,CAAQ;EAE1F,QAAA,IAAI,CAAC,IAAI,GAAG,0BAA0B,CAAC;OACxC;EACF;;;;;;;;;;;;;;;;;;;;;;;;;;;QCAY,2BAA2B,CAAA;MACtC,WAAoB,CAAA,YAA4B,EAAU,gBAAkC,EAAA;UAAxE,IAAY,CAAA,YAAA,GAAZ,YAAY,CAAgB;UAAU,IAAgB,CAAA,gBAAA,GAAhB,gBAAgB,CAAkB;OAAI;MAE1F,SAAS,CAAC,OAAe,EAAE,KAAsB,EAAA;;cACrD,MAAM,YAAY,GAAG,IAAI,CAAC,gBAAgB,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC;EAChE,YAAA,IAAI,YAAY,EAAE;kBAChB,OAAO,YAAY,CAAC,MAAM,CAAC;EAC5B,aAAA;EAAM,iBAAA;kBACL,OAAO,IAAI,CAAC,YAAY,CAAC,SAAS,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;EACpD,aAAA;WACF,CA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A,CAAK,EACrJ,MAAM,EACN,OAAO,CACR,CAAC;EACH,SAAA;OACF;EACF;;;;;;;;;;"}
@@ -1,7 +1,12 @@
1
+ import { ParameterValidationError } from '@taquito/core';
2
+ import { ScriptedContracts } from '@taquito/rpc';
1
3
  /**
2
4
  * @category Error
3
- * @description Error that indicates invalid script format being useed or passed
5
+ * @description Error indicates invalid script format being useed or passed
4
6
  */
5
- export declare class InvalidScriptFormatError extends Error {
6
- constructor(message: string);
7
+ export declare class InvalidScriptFormatError extends ParameterValidationError {
8
+ message: string;
9
+ script: ScriptedContracts;
10
+ address: string;
11
+ constructor(message: string, script: ScriptedContracts, address: string);
7
12
  }
@@ -41,7 +41,8 @@ export declare class ContractsLibrary implements Extension {
41
41
  * @param contract is an object where the key is a contract address and the value is an object having a script and an entrypoints properties.
42
42
  * Note: the expected format for the script and entrypoints properties are the same as the one respectivlely returned by
43
43
  * `TezosToolkit.rpc.getContract('contractAddress').script` and `TezosToolkit.rpc.getEntrypoints`
44
- *
44
+ * @throws {@link InvalidAddressError} If the contract address is not valid
45
+ * @throws {@link InvalidScriptFormatError} If the script is not in the expected format
45
46
  */
46
47
  addContract(contract: ContractsData): void;
47
48
  getContract(contractAddress: string): {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@taquito/contracts-library",
3
- "version": "16.2.0",
3
+ "version": "17.0.0",
4
4
  "description": "Can be used as an extension on the TezosToolkit to provide contracts data",
5
5
  "keywords": [
6
6
  "tezos"
@@ -68,10 +68,10 @@
68
68
  ]
69
69
  },
70
70
  "dependencies": {
71
- "@taquito/core": "^16.2.0",
72
- "@taquito/rpc": "^16.2.0",
73
- "@taquito/taquito": "^16.2.0",
74
- "@taquito/utils": "^16.2.0",
71
+ "@taquito/core": "^17.0.0",
72
+ "@taquito/rpc": "^17.0.0",
73
+ "@taquito/taquito": "^17.0.0",
74
+ "@taquito/utils": "^17.0.0",
75
75
  "bignumber.js": "^9.1.0"
76
76
  },
77
77
  "devDependencies": {
@@ -103,5 +103,5 @@
103
103
  "ts-toolbelt": "^9.6.0",
104
104
  "typescript": "~4.1.5"
105
105
  },
106
- "gitHead": "148b11675d2c3d3a10ce20c02dcece388ef59414"
106
+ "gitHead": "388db853edd4d45c1e6e0121a96fa9b71fa699c0"
107
107
  }