@taquito/taquito 23.0.3 → 24.0.0-beta.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.
Files changed (65) hide show
  1. package/README.md +1 -1
  2. package/dist/lib/batch/constants.js +16 -0
  3. package/dist/lib/batch/rpc-batch-provider.js +5 -9
  4. package/dist/lib/constants.js +5 -32
  5. package/dist/lib/contract/constants.js +4 -0
  6. package/dist/lib/contract/contract-methods/contract-method-factory.js +0 -4
  7. package/dist/lib/contract/contract-methods/contract-method-object-param.js +13 -8
  8. package/dist/lib/contract/contract.js +9 -32
  9. package/dist/lib/contract/index.js +0 -1
  10. package/dist/lib/contract/rpc-contract-provider.js +6 -39
  11. package/dist/lib/estimate/rpc-estimate-provider.js +6 -6
  12. package/dist/lib/import-key.js +51 -0
  13. package/dist/lib/operations/batch-operation.js +2 -2
  14. package/dist/lib/operations/transfer-ticket-operation.js +1 -1
  15. package/dist/lib/prepare/prepare-provider.js +6 -6
  16. package/dist/lib/provider.js +0 -9
  17. package/dist/lib/subscribe/polling-subcribe-provider.js +3 -3
  18. package/dist/lib/taquito.js +3 -2
  19. package/dist/lib/version.js +2 -2
  20. package/dist/lib/wallet/batch-operation.js +11 -3
  21. package/dist/lib/wallet/index.js +1 -0
  22. package/dist/lib/wallet/legacy.js +5 -0
  23. package/dist/lib/wallet/operation-factory.js +6 -0
  24. package/dist/lib/wallet/register-global-constant-operation.js +62 -0
  25. package/dist/lib/wallet/wallet.js +31 -10
  26. package/dist/taquito.es6.js +3399 -3442
  27. package/dist/taquito.es6.js.map +1 -1
  28. package/dist/taquito.min.js +1 -1
  29. package/dist/taquito.min.js.LICENSE.txt +2 -0
  30. package/dist/taquito.umd.js +3391 -3437
  31. package/dist/taquito.umd.js.map +1 -1
  32. package/dist/types/batch/constants.d.ts +3 -0
  33. package/dist/types/batch/rpc-batch-provider.d.ts +2 -5
  34. package/dist/types/constants.d.ts +4 -31
  35. package/dist/types/contract/constants.d.ts +1 -0
  36. package/dist/types/contract/contract-methods/contract-method-factory.d.ts +2 -4
  37. package/dist/types/contract/contract-methods/contract-method-object-param.d.ts +4 -3
  38. package/dist/types/contract/contract-methods/contract-on-chain-view.d.ts +2 -2
  39. package/dist/types/contract/contract.d.ts +4 -23
  40. package/dist/types/contract/index.d.ts +0 -1
  41. package/dist/types/contract/interface.d.ts +0 -13
  42. package/dist/types/contract/rpc-contract-provider.d.ts +0 -13
  43. package/dist/types/estimate/estimate-provider-interface.d.ts +2 -2
  44. package/dist/types/estimate/rpc-estimate-provider.d.ts +2 -2
  45. package/dist/types/import-key.d.ts +13 -0
  46. package/dist/types/operations/transfer-ticket-operation.d.ts +1 -1
  47. package/dist/types/operations/types.d.ts +7 -2
  48. package/dist/types/prepare/interface.d.ts +2 -3
  49. package/dist/types/prepare/prepare-provider.d.ts +1 -2
  50. package/dist/types/provider.d.ts +1 -6
  51. package/dist/types/taquito.d.ts +1 -6
  52. package/dist/types/wallet/batch-operation.d.ts +2 -1
  53. package/dist/types/wallet/index.d.ts +1 -0
  54. package/dist/types/wallet/interface.d.ts +7 -2
  55. package/dist/types/wallet/legacy.d.ts +2 -1
  56. package/dist/types/wallet/operation-factory.d.ts +2 -0
  57. package/dist/types/wallet/register-global-constant-operation.d.ts +13 -0
  58. package/dist/types/wallet/wallet.d.ts +20 -11
  59. package/package.json +13 -11
  60. package/dist/400.taquito.min.js +0 -1
  61. package/dist/993.taquito.min.js +0 -1
  62. package/dist/lib/contract/contract-methods/contract-method-flat-param.js +0 -92
  63. package/dist/lib/contract/lambda-view.js +0 -253
  64. package/dist/types/contract/contract-methods/contract-method-flat-param.d.ts +0 -43
  65. package/dist/types/contract/lambda-view.d.ts +0 -19
package/README.md CHANGED
@@ -7,7 +7,7 @@ The `@taquito/taquito` package contains higher-level functionality that builds u
7
7
  ## CDN Bundle
8
8
 
9
9
  ```html
10
- <script src="https://unpkg.com/@taquito/taquito@23.0.3/dist/taquito.min.js"
10
+ <script src="https://unpkg.com/@taquito/taquito@24.0.0-beta.0/dist/taquito.min.js"
11
11
  crossorigin="anonymous" integrity="sha384-IxvP0ECHi5oqLyz94wF85pU9+ktcsL1HHtA42MITxZsGbsUMEu/g+0Vkjj5vqiMR"></script>
12
12
  ```
13
13
 
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.BATCH_KINDS = void 0;
4
+ const rpc_1 = require("@taquito/rpc");
5
+ exports.BATCH_KINDS = [
6
+ rpc_1.OpKind.ACTIVATION,
7
+ rpc_1.OpKind.ORIGINATION,
8
+ rpc_1.OpKind.TRANSACTION,
9
+ rpc_1.OpKind.DELEGATION,
10
+ rpc_1.OpKind.REGISTER_GLOBAL_CONSTANT,
11
+ rpc_1.OpKind.INCREASE_PAID_STORAGE,
12
+ rpc_1.OpKind.TRANSFER_TICKET,
13
+ rpc_1.OpKind.SMART_ROLLUP_ADD_MESSAGES,
14
+ rpc_1.OpKind.SMART_ROLLUP_ORIGINATE,
15
+ rpc_1.OpKind.SMART_ROLLUP_EXECUTE_OUTBOX_MESSAGE,
16
+ ];
@@ -17,12 +17,8 @@ const utils_1 = require("@taquito/utils");
17
17
  const core_1 = require("@taquito/core");
18
18
  const provider_1 = require("../provider");
19
19
  const prepare_2 = require("../prepare");
20
- exports.BATCH_KINDS = [
21
- rpc_1.OpKind.ACTIVATION,
22
- rpc_1.OpKind.ORIGINATION,
23
- rpc_1.OpKind.TRANSACTION,
24
- rpc_1.OpKind.DELEGATION,
25
- ];
20
+ var constants_1 = require("./constants");
21
+ Object.defineProperty(exports, "BATCH_KINDS", { enumerable: true, get: function () { return constants_1.BATCH_KINDS; } });
26
22
  class OperationBatch extends provider_1.Provider {
27
23
  constructor(context, estimator) {
28
24
  super(context);
@@ -78,12 +74,12 @@ class OperationBatch extends provider_1.Provider {
78
74
  * @param params Delegation operation parameter
79
75
  */
80
76
  withDelegation(params) {
81
- var _a;
82
- const sourceValidation = (0, utils_1.validateAddress)(params.source);
77
+ var _a, _b;
78
+ const sourceValidation = (0, utils_1.validateAddress)((_a = params.source) !== null && _a !== void 0 ? _a : '');
83
79
  if (params.source && sourceValidation !== utils_1.ValidationResult.VALID) {
84
80
  throw new core_1.InvalidAddressError(params.source, sourceValidation);
85
81
  }
86
- const delegateValidation = (0, utils_1.validateAddress)((_a = params.delegate) !== null && _a !== void 0 ? _a : '');
82
+ const delegateValidation = (0, utils_1.validateAddress)((_b = params.delegate) !== null && _b !== void 0 ? _b : '');
87
83
  if (params.delegate && delegateValidation !== utils_1.ValidationResult.VALID) {
88
84
  throw new core_1.InvalidAddressError(params.delegate, delegateValidation);
89
85
  }
@@ -1,36 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getRevealFeeInternal = exports.getRevealFee = exports.getRevealGasLimit = exports.ChainIds = exports.protocols = exports.Protocols = exports.COST_PER_BYTE = exports.ORIGINATION_SIZE = exports.REVEAL_STORAGE_LIMIT = exports.DEFAULT_STORAGE_LIMIT = exports.DEFAULT_FEE = exports.DEFAULT_GAS_LIMIT = void 0;
4
- /**
5
- * @deprecated default reveal gasLimit please use getRevealGasLimit(address) instead, removing hardcoded gasLimit of delegation, origination and transfer
6
- */
7
- exports.DEFAULT_GAS_LIMIT = {
8
- DELEGATION: 10600,
9
- ORIGINATION: 10600,
10
- TRANSFER: 10600,
11
- REVEAL_TZ1: 1000,
12
- REVEAL_TZ2: 1000,
13
- REVEAL_TZ3: 2000,
14
- REVEAL_TZ4: 2000,
15
- };
16
- /**
17
- * @deprecated default reveal fee please use getRevealFee(address) instead, removing hardcoded fee of delegation, origination and transfer
18
- */
19
- exports.DEFAULT_FEE = {
20
- DELEGATION: 1257,
21
- ORIGINATION: 10000,
22
- TRANSFER: 10000,
23
- REVEAL: 374,
24
- };
25
- /**
26
- * @deprecated default reveal storageLimit please use REVEAL_STORAGE_LIMIT instead, removing hardcoded storageLimit of delegation, origination and transfer
27
- */
28
- exports.DEFAULT_STORAGE_LIMIT = {
29
- DELEGATION: 0,
30
- ORIGINATION: 257,
31
- TRANSFER: 257,
32
- REVEAL: 0,
33
- };
3
+ exports.getRevealFeeInternal = exports.getRevealFee = exports.getRevealGasLimit = exports.ChainIds = exports.protocols = exports.Protocols = exports.COST_PER_BYTE = exports.ORIGINATION_SIZE = exports.REVEAL_STORAGE_LIMIT = void 0;
34
4
  // value is based on octez-client reveal operation gasLimit of each address type in Seoul Protocol
35
5
  const REVEAL_GAS_LIMIT = {
36
6
  TZ1: 171,
@@ -76,6 +46,7 @@ var Protocols;
76
46
  Protocols["PsQuebecn"] = "PsQuebecnLByd3JwTiGadoG4nGWi3HYiLXUjkibeFV8dCFeVMUg";
77
47
  Protocols["PsRiotuma"] = "PsRiotumaAMotcRoDWW1bysEhQy2n1M5fy8JgRp8jjRfHGmfeA7";
78
48
  Protocols["PtSeouLou"] = "PtSeouLouXkxhg39oWzjxDWaCydNfR3RxCUrNe4Q9Ro8BTehcbh";
49
+ Protocols["PtTALLiNt"] = "PtTALLiNtPec7mE7yY4m3k26J8Qukef3E3ehzhfXgFZKGtDdAXu";
79
50
  Protocols["ProtoALpha"] = "ProtoALphaALphaALphaALphaALphaALphaALphaALphaDdp3zK";
80
51
  })(Protocols || (exports.Protocols = Protocols = {}));
81
52
  exports.protocols = {
@@ -98,7 +69,8 @@ exports.protocols = {
98
69
  '021': [Protocols.PsQuebecn],
99
70
  '022': [Protocols.PsRiotuma],
100
71
  '023': [Protocols.PtSeouLou],
101
- '024': [Protocols.ProtoALpha],
72
+ '024': [Protocols.PtTALLiNt],
73
+ '025': [Protocols.ProtoALpha],
102
74
  };
103
75
  var ChainIds;
104
76
  (function (ChainIds) {
@@ -124,6 +96,7 @@ var ChainIds;
124
96
  ChainIds["QUEBECNET"] = "NetXuTeGinLEqxp";
125
97
  ChainIds["RIONET"] = "NetXPdgaoabtBth";
126
98
  ChainIds["SEOULNET"] = "NetXd56aBs1aeW3";
99
+ ChainIds["TALLINNNET"] = "NetXe8DbhW9A1eS";
127
100
  })(ChainIds || (exports.ChainIds = ChainIds = {}));
128
101
  const getRevealGasLimit = (address) => Math.round((getRevealGasLimitInternal(address) * 37) / 10);
129
102
  exports.getRevealGasLimit = getRevealGasLimit;
@@ -0,0 +1,4 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.DEFAULT_SMART_CONTRACT_METHOD_NAME = void 0;
4
+ exports.DEFAULT_SMART_CONTRACT_METHOD_NAME = 'default';
@@ -2,16 +2,12 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.ContractMethodFactory = void 0;
4
4
  const contract_method_object_param_1 = require("./contract-method-object-param");
5
- const contract_method_flat_param_1 = require("./contract-method-flat-param");
6
5
  const contract_on_chain_view_1 = require("./contract-on-chain-view");
7
6
  class ContractMethodFactory {
8
7
  constructor(provider, contractAddress) {
9
8
  this.provider = provider;
10
9
  this.contractAddress = contractAddress;
11
10
  }
12
- createContractMethodFlatParams(smartContractMethodSchema, smartContractMethodName, args, isMultipleEntrypoint = true, isAnonymous = false) {
13
- return new contract_method_flat_param_1.ContractMethod(this.provider, this.contractAddress, smartContractMethodSchema, smartContractMethodName, args, isMultipleEntrypoint, isAnonymous);
14
- }
15
11
  createContractMethodObjectParam(smartContractMethodSchema, smartContractMethodName, args, isMultipleEntrypoint = true, isAnonymous = false) {
16
12
  return new contract_method_object_param_1.ContractMethodObject(this.provider, this.contractAddress, smartContractMethodSchema, smartContractMethodName, args, isMultipleEntrypoint, isAnonymous);
17
13
  }
@@ -1,8 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.ContractMethodObject = void 0;
4
- const wallet_1 = require("../../wallet");
5
- const contract_1 = require("../contract");
4
+ const constants_1 = require("../constants");
6
5
  /**
7
6
  * @description Utility class to send smart contract operation
8
7
  * The format for the arguments is the object representation
@@ -21,9 +20,12 @@ class ContractMethodObject {
21
20
  * @description Get the signature of the smart contract method
22
21
  */
23
22
  getSignature() {
24
- return this.isAnonymous
25
- ? this.parameterSchema.ExtractSchema()[this.name]
26
- : this.parameterSchema.ExtractSchema();
23
+ const generatedSchema = this.parameterSchema.generateSchema();
24
+ if (this.isAnonymous) {
25
+ const schemaObj = generatedSchema.schema;
26
+ return schemaObj === null || schemaObj === void 0 ? void 0 : schemaObj[this.name];
27
+ }
28
+ return generatedSchema;
27
29
  }
28
30
  /**
29
31
  *
@@ -32,8 +34,11 @@ class ContractMethodObject {
32
34
  * @param Options generic operation parameter
33
35
  */
34
36
  send(params = {}) {
35
- if (this.provider instanceof wallet_1.Wallet) {
36
- return this.provider.transfer(this.toTransferParams(params)).send();
37
+ // provider is either ContractProvider | Wallet but pkh method is unique to Wallet
38
+ if (this.provider && 'pkh' in this.provider) {
39
+ return this.provider
40
+ .transfer(this.toTransferParams(params))
41
+ .send();
37
42
  }
38
43
  else {
39
44
  return this.provider.transfer(this.toTransferParams(params));
@@ -55,7 +60,7 @@ class ContractMethodObject {
55
60
  gasLimit,
56
61
  storageLimit,
57
62
  parameter: {
58
- entrypoint: this.isMultipleEntrypoint ? this.name : contract_1.DEFAULT_SMART_CONTRACT_METHOD_NAME,
63
+ entrypoint: this.isMultipleEntrypoint ? this.name : constants_1.DEFAULT_SMART_CONTRACT_METHOD_NAME,
59
64
  value: this.isAnonymous
60
65
  ? this.parameterSchema.EncodeObject({ [this.name]: this.args })
61
66
  : this.parameterSchema.EncodeObject(this.args),
@@ -15,7 +15,8 @@ const utils_1 = require("@taquito/utils");
15
15
  const contract_method_factory_1 = require("./contract-methods/contract-method-factory");
16
16
  const errors_1 = require("./errors");
17
17
  const core_1 = require("@taquito/core");
18
- exports.DEFAULT_SMART_CONTRACT_METHOD_NAME = 'default';
18
+ const constants_1 = require("./constants");
19
+ Object.defineProperty(exports, "DEFAULT_SMART_CONTRACT_METHOD_NAME", { enumerable: true, get: function () { return constants_1.DEFAULT_SMART_CONTRACT_METHOD_NAME; } });
19
20
  /**
20
21
  * @description Utility class to retrieve data from a smart contract's storage without incurring fees via a contract's view method
21
22
  */
@@ -78,12 +79,6 @@ class ContractAbstraction {
78
79
  this.entrypoints = entrypoints;
79
80
  this.rpc = rpc;
80
81
  this.readProvider = readProvider;
81
- /**
82
- * @deprecated use methodsObject instead, flat params of methods can't sufficiently represent all Michelson values
83
- * @description Contains methods that are implemented by the target Tezos Smart Contract, and offers the user to call the Smart Contract methods as if they were native TS/JS methods.
84
- * NB: if the contract contains annotation it will include named properties; if not it will be indexed by a number.
85
- */
86
- this.methods = {};
87
82
  /**
88
83
  * @description Contains methods that are implemented by the target Tezos Smart Contract, and offers the user to call the Smart Contract methods as if they were native TS/JS methods.
89
84
  * `methodsObject` serves the exact same purpose as the `methods` member. The difference is that it allows passing the parameter in an object format when calling the smart contract method (instead of the flattened representation)
@@ -118,9 +113,6 @@ class ContractAbstraction {
118
113
  if (parameterSchema.isMultipleEntryPoint) {
119
114
  keys.forEach((smartContractMethodName) => {
120
115
  const smartContractMethodSchema = new michelson_encoder_1.ParameterSchema(entrypoints[smartContractMethodName]);
121
- this.methods[smartContractMethodName] = function (...args) {
122
- return currentContract.contractMethodFactory.createContractMethodFlatParams(smartContractMethodSchema, smartContractMethodName, args);
123
- };
124
116
  this.methodsObject[smartContractMethodName] = function (args) {
125
117
  return currentContract.contractMethodFactory.createContractMethodObjectParam(smartContractMethodSchema, smartContractMethodName, args);
126
118
  };
@@ -140,11 +132,12 @@ class ContractAbstraction {
140
132
  });
141
133
  // Deal with methods with no annotations which were not discovered by the RPC endpoint
142
134
  // Methods with no annotations are discovered using parameter schema
143
- const anonymousMethods = Object.keys(parameterSchema.ExtractSchema()).filter((key) => Object.keys(entrypoints).indexOf(key) === -1);
135
+ const generatedSchema = parameterSchema.generateSchema();
136
+ const schemaKeys = generatedSchema.schema && typeof generatedSchema.schema === 'object'
137
+ ? Object.keys(generatedSchema.schema)
138
+ : [];
139
+ const anonymousMethods = schemaKeys.filter((key) => Object.keys(entrypoints).indexOf(key) === -1);
144
140
  anonymousMethods.forEach((smartContractMethodName) => {
145
- this.methods[smartContractMethodName] = function (...args) {
146
- return currentContract.contractMethodFactory.createContractMethodFlatParams(parameterSchema, smartContractMethodName, args, false, true);
147
- };
148
141
  this.methodsObject[smartContractMethodName] = function (args) {
149
142
  return currentContract.contractMethodFactory.createContractMethodObjectParam(parameterSchema, smartContractMethodName, args, false, true);
150
143
  };
@@ -152,12 +145,9 @@ class ContractAbstraction {
152
145
  }
153
146
  else {
154
147
  const smartContractMethodSchema = this.parameterSchema;
155
- this.methods[exports.DEFAULT_SMART_CONTRACT_METHOD_NAME] = function (...args) {
156
- return currentContract.contractMethodFactory.createContractMethodFlatParams(smartContractMethodSchema, exports.DEFAULT_SMART_CONTRACT_METHOD_NAME, args, false);
157
- };
158
- this.methodsObject[exports.DEFAULT_SMART_CONTRACT_METHOD_NAME] =
148
+ this.methodsObject[constants_1.DEFAULT_SMART_CONTRACT_METHOD_NAME] =
159
149
  function (args) {
160
- return currentContract.contractMethodFactory.createContractMethodObjectParam(smartContractMethodSchema, exports.DEFAULT_SMART_CONTRACT_METHOD_NAME, args, false);
150
+ return currentContract.contractMethodFactory.createContractMethodObjectParam(smartContractMethodSchema, constants_1.DEFAULT_SMART_CONTRACT_METHOD_NAME, args, false);
161
151
  };
162
152
  }
163
153
  }
@@ -175,18 +165,5 @@ class ContractAbstraction {
175
165
  storage() {
176
166
  return this.storageProvider.getStorage(this.address, this.schema);
177
167
  }
178
- /**
179
- *
180
- * @description Return a friendly representation of the smart contract big map value
181
- *
182
- * @param key BigMap key to fetch
183
- *
184
- * @deprecated getBigMapKey has been deprecated in favor of getBigMapKeyByID
185
- *
186
- * @see https://tezos.gitlab.io/api/rpc.html#post-block-id-context-contracts-contract-id-big-map-get
187
- */
188
- bigMap(key) {
189
- return this.storageProvider.getBigMapKey(this.address, key, this.schema);
190
- }
191
168
  }
192
169
  exports.ContractAbstraction = ContractAbstraction;
@@ -24,7 +24,6 @@ __exportStar(require("./view_lambda"), exports);
24
24
  var compose_1 = require("./compose");
25
25
  Object.defineProperty(exports, "compose", { enumerable: true, get: function () { return compose_1.compose; } });
26
26
  __exportStar(require("./contract-methods/contract-method-interface"), exports);
27
- __exportStar(require("./contract-methods/contract-method-flat-param"), exports);
28
27
  __exportStar(require("./contract-methods/contract-method-object-param"), exports);
29
28
  __exportStar(require("./sapling-state-abstraction"), exports);
30
29
  var semantic_1 = require("./semantic");
@@ -72,39 +72,6 @@ class RpcContractProvider extends provider_1.Provider {
72
72
  return contractSchema.Execute(script.storage, (0, semantic_1.smartContractAbstractionSemantic)(this)); // Cast into T because only the caller can know the true type of the storage
73
73
  });
74
74
  }
75
- /**
76
- *
77
- * @description Return a well formatted json object of the contract big map storage
78
- *
79
- * @param contract contract address you want to get the storage from
80
- * @param key contract big map key to fetch value from
81
- * @param schema optional schema can either be the contract script rpc response or a michelson-encoder schema
82
- * @throws {@link InvalidContractAddressError}
83
- * @deprecated Deprecated in favor of getBigMapKeyByID
84
- *
85
- * @see https://tezos.gitlab.io/api/rpc.html#post-block-id-context-contracts-contract-id-big-map-get
86
- */
87
- getBigMapKey(contract, key, schema) {
88
- return __awaiter(this, void 0, void 0, function* () {
89
- const contractValidation = (0, utils_1.validateContractAddress)(contract);
90
- if (contractValidation !== utils_1.ValidationResult.VALID) {
91
- throw new core_1.InvalidContractAddressError(contract, contractValidation);
92
- }
93
- if (!schema) {
94
- schema = (yield this.rpc.getContract(contract)).script;
95
- }
96
- let contractSchema;
97
- if (michelson_encoder_1.Schema.isSchema(schema)) {
98
- contractSchema = schema;
99
- }
100
- else {
101
- contractSchema = michelson_encoder_1.Schema.fromRPCResponse({ script: schema });
102
- }
103
- const encodedKey = contractSchema.EncodeBigMapKey(key);
104
- const val = yield this.rpc.getBigMapKey(contract, encodedKey);
105
- return contractSchema.ExecuteOnBigMapValue(val); // Cast into T because only the caller can know the true type of the storage
106
- });
107
- }
108
75
  /**
109
76
  *
110
77
  * @description Return a well formatted json object of a big map value
@@ -229,18 +196,18 @@ class RpcContractProvider extends provider_1.Provider {
229
196
  */
230
197
  setDelegate(params) {
231
198
  return __awaiter(this, void 0, void 0, function* () {
232
- var _a;
233
- const sourceValidation = (0, utils_1.validateAddress)(params.source);
199
+ var _a, _b, _c, _d;
200
+ const sourceValidation = (0, utils_1.validateAddress)((_a = params.source) !== null && _a !== void 0 ? _a : '');
234
201
  if (params.source && sourceValidation !== utils_1.ValidationResult.VALID) {
235
202
  throw new core_1.InvalidAddressError(params.source, sourceValidation);
236
203
  }
237
- const delegateValidation = (0, utils_1.validateAddress)((_a = params.delegate) !== null && _a !== void 0 ? _a : '');
204
+ const delegateValidation = (0, utils_1.validateAddress)((_b = params.delegate) !== null && _b !== void 0 ? _b : '');
238
205
  if (params.delegate && delegateValidation !== utils_1.ValidationResult.VALID) {
239
206
  throw new core_1.InvalidAddressError(params.delegate, delegateValidation);
240
207
  }
241
208
  // Since babylon delegation source cannot smart contract
242
- if (/^kt1/i.test(params.source)) {
243
- throw new errors_1.InvalidDelegationSource(params.source);
209
+ if (/^kt1/i.test((_c = params.source) !== null && _c !== void 0 ? _c : '')) {
210
+ throw new errors_1.InvalidDelegationSource((_d = params.source) !== null && _d !== void 0 ? _d : '');
244
211
  }
245
212
  const publicKeyHash = yield this.signer.publicKeyHash();
246
213
  const sourceOrDefault = params.source || publicKeyHash;
@@ -503,7 +470,7 @@ class RpcContractProvider extends provider_1.Provider {
503
470
  */
504
471
  increasePaidStorage(params) {
505
472
  return __awaiter(this, void 0, void 0, function* () {
506
- if (params.amount < 0) {
473
+ if (params.amount <= 0) {
507
474
  throw new core_1.InvalidAmountError(params.amount.toString());
508
475
  }
509
476
  const publicKeyHash = yield this.signer.publicKeyHash();
@@ -46,10 +46,10 @@ class RPCEstimateProvider extends provider_1.Provider {
46
46
  return {
47
47
  publicKeyHash: isSignerConfigured
48
48
  ? yield this.signer.publicKeyHash()
49
- : yield this.context.walletProvider.getPKH(),
49
+ : yield this.context.wallet.pkh(),
50
50
  publicKey: isSignerConfigured
51
51
  ? yield this.signer.publicKey()
52
- : yield this.context.walletProvider.getPK(),
52
+ : yield this.context.wallet.pk(),
53
53
  };
54
54
  });
55
55
  }
@@ -363,13 +363,13 @@ class RPCEstimateProvider extends provider_1.Provider {
363
363
  */
364
364
  setDelegate(_a) {
365
365
  return __awaiter(this, void 0, void 0, function* () {
366
- var _b;
366
+ var _b, _c;
367
367
  var { fee, gasLimit, storageLimit } = _a, rest = __rest(_a, ["fee", "gasLimit", "storageLimit"]);
368
- const sourceValidation = (0, utils_1.validateAddress)(rest.source);
368
+ const sourceValidation = (0, utils_1.validateAddress)((_b = rest.source) !== null && _b !== void 0 ? _b : '');
369
369
  if (rest.source && sourceValidation !== utils_1.ValidationResult.VALID) {
370
370
  throw new core_1.InvalidAddressError(rest.source, sourceValidation);
371
371
  }
372
- const delegateValidation = (0, utils_1.validateAddress)((_b = rest.delegate) !== null && _b !== void 0 ? _b : '');
372
+ const delegateValidation = (0, utils_1.validateAddress)((_c = rest.delegate) !== null && _c !== void 0 ? _c : '');
373
373
  if (rest.delegate && delegateValidation !== utils_1.ValidationResult.VALID) {
374
374
  throw new core_1.InvalidAddressError(rest.delegate, delegateValidation);
375
375
  }
@@ -503,7 +503,7 @@ class RPCEstimateProvider extends provider_1.Provider {
503
503
  increasePaidStorage(_a) {
504
504
  return __awaiter(this, void 0, void 0, function* () {
505
505
  var { fee, storageLimit, gasLimit } = _a, rest = __rest(_a, ["fee", "storageLimit", "gasLimit"]);
506
- if (rest.amount < 0) {
506
+ if (rest.amount <= 0) {
507
507
  throw new core_1.InvalidAmountError(rest.amount.toString());
508
508
  }
509
509
  const protocolConstants = yield this.context.readProvider.getProtocolConstants('head');
@@ -0,0 +1,51 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.importKey = importKey;
13
+ const signer_1 = require("@taquito/signer");
14
+ /**
15
+ *
16
+ * @description Import a key to sign operation with the side-effect of setting the Tezos instance to use the InMemorySigner provider
17
+ *
18
+ * @warn The JSON faucets are no longer available on https://teztnets.com/
19
+ * @param toolkit The toolkit instance to attach a signer
20
+ * @param privateKeyOrEmail Key to load in memory
21
+ * @param passphrase If the key is encrypted passphrase to decrypt it
22
+ * @param mnemonic Faucet mnemonic
23
+ * @param secret Faucet secret
24
+ */
25
+ function importKey(toolkit, privateKeyOrEmail, passphrase, mnemonic, secret) {
26
+ return __awaiter(this, void 0, void 0, function* () {
27
+ if (privateKeyOrEmail && passphrase && mnemonic && secret) {
28
+ const signer = signer_1.InMemorySigner.fromFundraiser(privateKeyOrEmail, passphrase, mnemonic);
29
+ toolkit.setProvider({ signer });
30
+ const pkh = yield signer.publicKeyHash();
31
+ let op;
32
+ try {
33
+ op = yield toolkit.tz.activate(pkh, secret);
34
+ }
35
+ catch (ex) {
36
+ const isInvalidActivationError = ex && ex.body && /Invalid activation/.test(ex.body);
37
+ if (!isInvalidActivationError) {
38
+ throw ex;
39
+ }
40
+ }
41
+ if (op) {
42
+ yield op.confirmation();
43
+ }
44
+ }
45
+ else {
46
+ // Fallback to regular import
47
+ const signer = yield signer_1.InMemorySigner.fromSecretKey(privateKeyOrEmail, passphrase);
48
+ toolkit.setProvider({ signer });
49
+ }
50
+ });
51
+ }
@@ -2,7 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.BatchOperation = void 0;
4
4
  const bignumber_js_1 = require("bignumber.js");
5
- const rpc_batch_provider_1 = require("../batch/rpc-batch-provider");
5
+ const constants_1 = require("../batch/constants");
6
6
  const errors_1 = require("./errors");
7
7
  const operations_1 = require("./operations");
8
8
  const types_1 = require("./types");
@@ -29,7 +29,7 @@ class BatchOperation extends operations_1.Operation {
29
29
  }
30
30
  get status() {
31
31
  return (this.results
32
- .filter((result) => rpc_batch_provider_1.BATCH_KINDS.indexOf(result.kind) !== -1)
32
+ .filter((result) => constants_1.BATCH_KINDS.indexOf(result.kind) !== -1)
33
33
  .map((result) => {
34
34
  if ((0, types_1.hasMetadataWithResult)(result)) {
35
35
  const opResult = result.metadata.operation_result;
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.TransferTicketOperation = void 0;
4
4
  const rpc_1 = require("@taquito/rpc");
5
5
  const bignumber_js_1 = require("bignumber.js");
6
- const operations_1 = require("../operations");
6
+ const operations_1 = require("./operations");
7
7
  /**
8
8
  *
9
9
  * @description Transfer tickets from a Tezos address (tz1, tz2 or tz3) to a smart contract address (KT1) (everything on layer 1 at this step)
@@ -136,10 +136,10 @@ class PrepareProvider extends provider_1.Provider {
136
136
  return {
137
137
  pkh: isSignerConfigured
138
138
  ? yield this.signer.publicKeyHash()
139
- : yield this.context.walletProvider.getPKH(),
139
+ : yield this.context.wallet.pkh(),
140
140
  publicKey: isSignerConfigured
141
141
  ? yield this.signer.publicKey()
142
- : yield this.context.walletProvider.getPK(),
142
+ : yield this.context.wallet.pk(),
143
143
  };
144
144
  });
145
145
  }
@@ -183,12 +183,12 @@ class PrepareProvider extends provider_1.Provider {
183
183
  if (currentVotingPeriod === undefined) {
184
184
  throw new errors_1.RPCResponseError(`Failed to get the current voting period index`);
185
185
  }
186
- return Object.assign(Object.assign({}, op), { period: currentVotingPeriod === null || currentVotingPeriod === void 0 ? void 0 : currentVotingPeriod.voting_period.index });
186
+ return Object.assign(Object.assign(Object.assign({}, op), { period: currentVotingPeriod === null || currentVotingPeriod === void 0 ? void 0 : currentVotingPeriod.voting_period.index }), this.getSource(op, pkh, source));
187
187
  case rpc_1.OpKind.PROPOSALS:
188
188
  if (currentVotingPeriod === undefined) {
189
189
  throw new errors_1.RPCResponseError(`Failed to get the current voting period index`);
190
190
  }
191
- return Object.assign(Object.assign({}, op), { period: currentVotingPeriod === null || currentVotingPeriod === void 0 ? void 0 : currentVotingPeriod.voting_period.index });
191
+ return Object.assign(Object.assign(Object.assign({}, op), { period: currentVotingPeriod === null || currentVotingPeriod === void 0 ? void 0 : currentVotingPeriod.voting_period.index }), this.getSource(op, pkh, source));
192
192
  default:
193
193
  throw new core_1.InvalidOperationKindError(op.kind);
194
194
  }
@@ -672,7 +672,7 @@ class PrepareProvider extends provider_1.Provider {
672
672
  catch (e) {
673
673
  throw new errors_1.RPCResponseError('Failed to get the current voting period index');
674
674
  }
675
- const contents = this.constructOpContents(ops, headCounter, pkh, undefined, currentVotingPeriod);
675
+ const contents = this.constructOpContents(ops, headCounter, pkh, params.source, currentVotingPeriod);
676
676
  return {
677
677
  opOb: {
678
678
  branch: hash,
@@ -705,7 +705,7 @@ class PrepareProvider extends provider_1.Provider {
705
705
  catch (e) {
706
706
  throw new errors_1.RPCResponseError('Failed to get the current voting period index');
707
707
  }
708
- const contents = this.constructOpContents(ops, headCounter, pkh, undefined, currentVotingPeriod);
708
+ const contents = this.constructOpContents(ops, headCounter, pkh, params.source, currentVotingPeriod);
709
709
  return {
710
710
  opOb: {
711
711
  branch: hash,
@@ -108,15 +108,6 @@ class Provider {
108
108
  }
109
109
  });
110
110
  }
111
- runOperation(op) {
112
- return __awaiter(this, void 0, void 0, function* () {
113
- return {
114
- opResponse: yield this.rpc.runOperation(op),
115
- op,
116
- context: this.context.clone(),
117
- };
118
- });
119
- }
120
111
  simulate(op) {
121
112
  return __awaiter(this, void 0, void 0, function* () {
122
113
  return {
@@ -83,7 +83,7 @@ class PollingSubscribeProvider {
83
83
  return __awaiter(this, void 0, void 0, function* () {
84
84
  if (!this.config.pollingIntervalMilliseconds) {
85
85
  const defaultIntervalTestnetsMainnet = 5000;
86
- const defaultIntervalSandbox = 1000;
86
+ const minimumPollingInterval = 700;
87
87
  try {
88
88
  const constants = yield this.context.readProvider.getProtocolConstants('head');
89
89
  const blockTime = constants.minimal_block_delay
@@ -92,8 +92,8 @@ class PollingSubscribeProvider {
92
92
  const confirmationPollingInterval = blockTime.dividedBy(3);
93
93
  this.config.pollingIntervalMilliseconds =
94
94
  confirmationPollingInterval.toNumber() === 0
95
- ? defaultIntervalSandbox
96
- : confirmationPollingInterval.toNumber();
95
+ ? minimumPollingInterval
96
+ : Math.max(confirmationPollingInterval.toNumber(), minimumPollingInterval);
97
97
  }
98
98
  catch (exception) {
99
99
  return defaultIntervalTestnetsMainnet;
@@ -18,7 +18,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
18
18
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
19
19
  };
20
20
  Object.defineProperty(exports, "__esModule", { value: true });
21
- exports.TezosToolkit = exports.TaquitoLocalForger = exports.RpcReadAdapter = exports.ObservableSubscription = exports.PollingSubscribeProvider = exports.OperationBatch = exports.RpcForger = exports.CompositeForger = exports.UnitValue = exports.MichelsonMap = exports.Token = void 0;
21
+ exports.TezosToolkit = exports.importKey = exports.TaquitoLocalForger = exports.RpcReadAdapter = exports.ObservableSubscription = exports.PollingSubscribeProvider = exports.OperationBatch = exports.RpcForger = exports.CompositeForger = exports.UnitValue = exports.MichelsonMap = exports.Token = void 0;
22
22
  const rpc_1 = require("@taquito/rpc");
23
23
  const context_1 = require("./context");
24
24
  const utils_1 = require("@taquito/utils");
@@ -72,6 +72,8 @@ __exportStar(require("./estimate"), exports);
72
72
  var taquito_local_forger_2 = require("./forger/taquito-local-forger");
73
73
  Object.defineProperty(exports, "TaquitoLocalForger", { enumerable: true, get: function () { return taquito_local_forger_2.TaquitoLocalForger; } });
74
74
  __exportStar(require("./prepare"), exports);
75
+ var import_key_1 = require("./import-key");
76
+ Object.defineProperty(exports, "importKey", { enumerable: true, get: function () { return import_key_1.importKey; } });
75
77
  /**
76
78
  * @description Facade class that surfaces all of the libraries capability and allow it's configuration
77
79
  *
@@ -91,7 +93,6 @@ class TezosToolkit {
91
93
  this._context = new context_1.Context(_rpc);
92
94
  this._wallet = new wallet_1.Wallet(this._context);
93
95
  this.setProvider({ rpc: this._rpcClient });
94
- this.batch = this._context.batch.batch.bind(this._context.batch);
95
96
  }
96
97
  /**
97
98
  * @description Sets configuration on the Tezos Taquito instance. Allows user to choose which signer, rpc client, rpc url, forger and so forth
@@ -3,6 +3,6 @@ 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": "42048d039f6d4345fc59d04b03650bcb8e27bb62",
7
- "version": "23.0.3"
6
+ "commitHash": "7912b77f57f943dff619383900bd46a7a593a244",
7
+ "version": "24.0.0-beta.0"
8
8
  };
@@ -9,12 +9,20 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
9
9
  });
10
10
  };
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.BatchWalletOperation = void 0;
12
+ exports.BatchWalletOperation = exports.WALLET_BATCH_KINDS = void 0;
13
13
  const rpc_1 = require("@taquito/rpc");
14
- const rpc_batch_provider_1 = require("../batch/rpc-batch-provider");
15
14
  const types_1 = require("../operations/types");
16
15
  const operation_1 = require("./operation");
17
16
  const errors_1 = require("./errors");
17
+ exports.WALLET_BATCH_KINDS = [
18
+ rpc_1.OpKind.REVEAL,
19
+ rpc_1.OpKind.ORIGINATION,
20
+ rpc_1.OpKind.TRANSACTION,
21
+ rpc_1.OpKind.DELEGATION,
22
+ rpc_1.OpKind.REGISTER_GLOBAL_CONSTANT,
23
+ rpc_1.OpKind.INCREASE_PAID_STORAGE,
24
+ rpc_1.OpKind.TRANSFER_TICKET,
25
+ ];
18
26
  class BatchWalletOperation extends operation_1.WalletOperation {
19
27
  constructor(opHash, context, newHead$) {
20
28
  super(opHash, context, newHead$);
@@ -56,7 +64,7 @@ class BatchWalletOperation extends operation_1.WalletOperation {
56
64
  const op = yield this.operationResults();
57
65
  if (op) {
58
66
  return (op
59
- .filter((result) => rpc_batch_provider_1.BATCH_KINDS.indexOf(result.kind) !== -1)
67
+ .filter((result) => exports.WALLET_BATCH_KINDS.indexOf(result.kind) !== -1)
60
68
  .map((result) => {
61
69
  if ((0, types_1.hasMetadataWithResult)(result)) {
62
70
  const opResult = result.metadata.operation_result;
@@ -20,5 +20,6 @@ __exportStar(require("./transaction-operation"), exports);
20
20
  __exportStar(require("./origination-operation"), exports);
21
21
  __exportStar(require("./delegation-operation"), exports);
22
22
  __exportStar(require("./transfer-ticket-operation"), exports);
23
+ __exportStar(require("./register-global-constant-operation"), exports);
23
24
  __exportStar(require("./interface"), exports);
24
25
  __exportStar(require("./legacy"), exports);