starknet 3.18.2 → 4.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.
Files changed (165) hide show
  1. package/CHANGELOG.md +70 -0
  2. package/README.md +1 -2
  3. package/__tests__/account.test.ts +11 -56
  4. package/__tests__/contract.test.ts +11 -49
  5. package/__tests__/defaultProvider.test.ts +321 -0
  6. package/__tests__/fixtures.ts +32 -11
  7. package/__tests__/jest.setup.ts +2 -3
  8. package/__tests__/rpcProvider.test.ts +17 -0
  9. package/__tests__/sequencerProvider.test.ts +45 -0
  10. package/account/default.d.ts +54 -77
  11. package/account/default.js +271 -596
  12. package/account/index.js +18 -31
  13. package/account/interface.d.ts +66 -95
  14. package/account/interface.js +20 -30
  15. package/constants.d.ts +17 -19
  16. package/constants.js +2038 -2059
  17. package/contract/contractFactory.d.ts +25 -29
  18. package/contract/contractFactory.js +94 -210
  19. package/contract/default.d.ts +117 -146
  20. package/contract/default.js +582 -776
  21. package/contract/index.js +19 -32
  22. package/contract/interface.d.ts +72 -92
  23. package/contract/interface.js +6 -5
  24. package/dist/account/default.d.ts +5 -9
  25. package/dist/account/default.js +35 -169
  26. package/dist/account/interface.d.ts +3 -15
  27. package/dist/contract/contractFactory.js +4 -4
  28. package/dist/contract/default.d.ts +3 -3
  29. package/dist/contract/default.js +3 -2
  30. package/dist/contract/interface.d.ts +2 -2
  31. package/dist/provider/default.d.ts +18 -134
  32. package/dist/provider/default.js +47 -411
  33. package/dist/provider/index.d.ts +2 -0
  34. package/dist/provider/index.js +2 -0
  35. package/dist/provider/interface.d.ts +45 -50
  36. package/dist/provider/rpc.d.ts +57 -0
  37. package/dist/provider/rpc.js +364 -0
  38. package/dist/provider/sequencer.d.ts +66 -0
  39. package/dist/provider/sequencer.js +444 -0
  40. package/dist/types/account.d.ts +2 -3
  41. package/dist/types/api/index.d.ts +16 -0
  42. package/dist/types/api/index.js +18 -0
  43. package/dist/types/api/rpc.d.ts +221 -0
  44. package/dist/types/{api.js → api/rpc.js} +0 -0
  45. package/dist/types/api/sequencer.d.ts +289 -0
  46. package/dist/types/api/sequencer.js +2 -0
  47. package/dist/types/index.d.ts +3 -1
  48. package/dist/types/index.js +15 -1
  49. package/dist/types/lib.d.ts +3 -1
  50. package/dist/types/provider.d.ts +86 -0
  51. package/dist/types/provider.js +2 -0
  52. package/dist/utils/fetchPonyfill.d.ts +2 -0
  53. package/dist/utils/fetchPonyfill.js +6 -0
  54. package/dist/utils/provider.d.ts +4 -0
  55. package/dist/utils/provider.js +38 -0
  56. package/dist/utils/responseParser/index.d.ts +11 -0
  57. package/dist/utils/responseParser/index.js +9 -0
  58. package/dist/utils/responseParser/rpc.d.ts +13 -0
  59. package/dist/utils/responseParser/rpc.js +96 -0
  60. package/dist/utils/responseParser/sequencer.d.ts +13 -0
  61. package/dist/utils/responseParser/sequencer.js +124 -0
  62. package/index.js +42 -75
  63. package/package.json +2 -3
  64. package/provider/default.d.ts +21 -175
  65. package/provider/default.js +139 -704
  66. package/provider/errors.d.ts +4 -4
  67. package/provider/errors.js +30 -40
  68. package/provider/index.d.ts +2 -0
  69. package/provider/index.js +22 -33
  70. package/provider/interface.d.ts +104 -131
  71. package/provider/interface.js +6 -5
  72. package/provider/rpc.d.ts +57 -0
  73. package/provider/rpc.js +364 -0
  74. package/provider/sequencer.d.ts +66 -0
  75. package/provider/sequencer.js +444 -0
  76. package/provider/utils.d.ts +7 -9
  77. package/provider/utils.js +39 -44
  78. package/signer/default.d.ts +5 -9
  79. package/signer/default.js +72 -177
  80. package/signer/index.js +18 -31
  81. package/signer/interface.d.ts +29 -33
  82. package/signer/interface.js +6 -5
  83. package/src/account/default.ts +26 -146
  84. package/src/account/interface.ts +5 -20
  85. package/src/contract/contractFactory.ts +3 -6
  86. package/src/contract/default.ts +6 -4
  87. package/src/contract/interface.ts +2 -2
  88. package/src/provider/default.ts +63 -395
  89. package/src/provider/index.ts +2 -0
  90. package/src/provider/interface.ts +68 -63
  91. package/src/provider/rpc.ts +299 -0
  92. package/src/provider/sequencer.ts +385 -0
  93. package/src/types/account.ts +2 -3
  94. package/src/types/api/index.ts +17 -0
  95. package/src/types/api/rpc.ts +247 -0
  96. package/src/types/api/sequencer.ts +331 -0
  97. package/src/types/index.ts +3 -1
  98. package/src/types/lib.ts +3 -1
  99. package/src/types/provider.ts +108 -0
  100. package/src/utils/fetchPonyfill.ts +4 -0
  101. package/src/utils/provider.ts +28 -0
  102. package/src/utils/responseParser/index.ts +28 -0
  103. package/src/utils/responseParser/rpc.ts +93 -0
  104. package/src/utils/responseParser/sequencer.ts +127 -0
  105. package/types/account.d.ts +5 -7
  106. package/types/account.js +2 -2
  107. package/types/api/index.d.ts +16 -0
  108. package/types/api/index.js +18 -0
  109. package/types/api/rpc.d.ts +221 -0
  110. package/types/api/rpc.js +2 -0
  111. package/types/api/sequencer.d.ts +289 -0
  112. package/types/api/sequencer.js +2 -0
  113. package/types/contract.d.ts +1 -1
  114. package/types/contract.js +2 -2
  115. package/types/index.d.ts +3 -1
  116. package/types/index.js +35 -34
  117. package/types/lib.d.ts +36 -41
  118. package/types/lib.js +2 -2
  119. package/types/provider.d.ts +86 -0
  120. package/types/provider.js +2 -0
  121. package/types/signer.d.ts +2 -2
  122. package/types/signer.js +2 -2
  123. package/utils/address.js +26 -37
  124. package/utils/ellipticCurve.d.ts +1 -6
  125. package/utils/ellipticCurve.js +73 -137
  126. package/utils/encode.js +49 -85
  127. package/utils/fetchPonyfill.d.ts +2 -0
  128. package/utils/fetchPonyfill.js +6 -0
  129. package/utils/hash.d.ts +4 -31
  130. package/utils/hash.js +76 -141
  131. package/utils/json.d.ts +13 -45
  132. package/utils/json.js +15 -22
  133. package/utils/number.d.ts +2 -9
  134. package/utils/number.js +47 -81
  135. package/utils/provider.d.ts +4 -0
  136. package/utils/provider.js +38 -0
  137. package/utils/responseParser/index.d.ts +11 -0
  138. package/utils/responseParser/index.js +9 -0
  139. package/utils/responseParser/rpc.d.ts +13 -0
  140. package/utils/responseParser/rpc.js +96 -0
  141. package/utils/responseParser/sequencer.d.ts +13 -0
  142. package/utils/responseParser/sequencer.js +124 -0
  143. package/utils/shortString.js +13 -21
  144. package/utils/stark.d.ts +0 -1
  145. package/utils/stark.js +59 -93
  146. package/utils/transaction.d.ts +3 -6
  147. package/utils/transaction.js +50 -81
  148. package/utils/typedData/index.d.ts +3 -15
  149. package/utils/typedData/index.js +109 -175
  150. package/utils/typedData/types.d.ts +9 -9
  151. package/utils/typedData/types.js +2 -2
  152. package/utils/typedData/utils.js +6 -6
  153. package/utils/uint256.d.ts +5 -5
  154. package/utils/uint256.js +16 -26
  155. package/www/docs/API/account.md +3 -4
  156. package/www/docs/API/contract.md +2 -2
  157. package/www/docs/API/contractFactory.md +2 -2
  158. package/www/docs/API/provider.md +185 -74
  159. package/www/guides/account.md +1 -8
  160. package/www/guides/erc20.md +3 -0
  161. package/__tests__/provider.test.ts +0 -168
  162. package/dist/types/api.d.ts +0 -261
  163. package/src/types/api.ts +0 -303
  164. package/types/api.d.ts +0 -287
  165. package/types/api.js +0 -2
@@ -4,33 +4,29 @@ import { Abi, CompiledContract, RawCalldata } from '../types';
4
4
  import { BigNumberish } from '../utils/number';
5
5
  import { Contract } from './default';
6
6
  export declare class ContractFactory {
7
- abi: Abi;
8
- compiledContract: CompiledContract;
9
- providerOrAccount: ProviderInterface | AccountInterface;
10
- constructor(
11
- compiledContract: CompiledContract,
12
- providerOrAccount?: ProviderInterface | AccountInterface,
13
- abi?: Abi
14
- );
15
- /**
16
- * Deploys contract and returns new instance of the Contract
17
- *
18
- * @param constructorCalldata - Constructor Calldata
19
- * @param addressSalt (optional) - Address Salt for deployment
20
- * @returns deployed Contract
21
- */
22
- deploy(constructorCalldata?: RawCalldata, addressSalt?: BigNumberish): Promise<Contract>;
23
- /**
24
- * Attaches to new Provider or Account
25
- *
26
- * @param providerOrAccount - new Provider or Account to attach to
27
- */
28
- connect(providerOrAccount: ProviderInterface | AccountInterface): ContractFactory;
29
- /**
30
- * Attaches current abi and provider or account to the new address
31
- *
32
- * @param address - Contract address
33
- * @returns Contract
34
- */
35
- attach(address: string): Contract;
7
+ abi: Abi;
8
+ compiledContract: CompiledContract;
9
+ providerOrAccount: ProviderInterface | AccountInterface;
10
+ constructor(compiledContract: CompiledContract, providerOrAccount?: ProviderInterface | AccountInterface, abi?: Abi);
11
+ /**
12
+ * Deploys contract and returns new instance of the Contract
13
+ *
14
+ * @param constructorCalldata - Constructor Calldata
15
+ * @param addressSalt (optional) - Address Salt for deployment
16
+ * @returns deployed Contract
17
+ */
18
+ deploy(constructorCalldata?: RawCalldata, addressSalt?: BigNumberish): Promise<Contract>;
19
+ /**
20
+ * Attaches to new Provider or Account
21
+ *
22
+ * @param providerOrAccount - new Provider or Account to attach to
23
+ */
24
+ connect(providerOrAccount: ProviderInterface | AccountInterface): ContractFactory;
25
+ /**
26
+ * Attaches current abi and provider or account to the new address
27
+ *
28
+ * @param address - Contract address
29
+ * @returns Contract
30
+ */
31
+ attach(address: string): Contract;
36
32
  }
@@ -1,218 +1,102 @@
1
- 'use strict';
2
- var __awaiter =
3
- (this && this.__awaiter) ||
4
- function (thisArg, _arguments, P, generator) {
5
- function adopt(value) {
6
- return value instanceof P
7
- ? value
8
- : new P(function (resolve) {
9
- resolve(value);
10
- });
11
- }
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); }); }
12
4
  return new (P || (P = Promise))(function (resolve, reject) {
13
- function fulfilled(value) {
14
- try {
15
- step(generator.next(value));
16
- } catch (e) {
17
- reject(e);
18
- }
19
- }
20
- function rejected(value) {
21
- try {
22
- step(generator['throw'](value));
23
- } catch (e) {
24
- reject(e);
25
- }
26
- }
27
- function step(result) {
28
- result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
29
- }
30
- step((generator = generator.apply(thisArg, _arguments || [])).next());
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());
31
9
  });
32
- };
33
- var __generator =
34
- (this && this.__generator) ||
35
- function (thisArg, body) {
36
- var _ = {
37
- label: 0,
38
- sent: function () {
39
- if (t[0] & 1) throw t[1];
40
- return t[1];
41
- },
42
- trys: [],
43
- ops: [],
44
- },
45
- f,
46
- y,
47
- t,
48
- g;
49
- return (
50
- (g = { next: verb(0), throw: verb(1), return: verb(2) }),
51
- typeof Symbol === 'function' &&
52
- (g[Symbol.iterator] = function () {
53
- return this;
54
- }),
55
- g
56
- );
57
- function verb(n) {
58
- return function (v) {
59
- return step([n, v]);
60
- };
61
- }
10
+ };
11
+ var __generator = (this && this.__generator) || function (thisArg, body) {
12
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
13
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
14
+ function verb(n) { return function (v) { return step([n, v]); }; }
62
15
  function step(op) {
63
- if (f) throw new TypeError('Generator is already executing.');
64
- while (_)
65
- try {
66
- if (
67
- ((f = 1),
68
- y &&
69
- (t =
70
- op[0] & 2
71
- ? y['return']
72
- : op[0]
73
- ? y['throw'] || ((t = y['return']) && t.call(y), 0)
74
- : y.next) &&
75
- !(t = t.call(y, op[1])).done)
76
- )
77
- return t;
78
- if (((y = 0), t)) op = [op[0] & 2, t.value];
79
- switch (op[0]) {
80
- case 0:
81
- case 1:
82
- t = op;
83
- break;
84
- case 4:
85
- _.label++;
86
- return { value: op[1], done: false };
87
- case 5:
88
- _.label++;
89
- y = op[1];
90
- op = [0];
91
- continue;
92
- case 7:
93
- op = _.ops.pop();
94
- _.trys.pop();
95
- continue;
96
- default:
97
- if (
98
- !((t = _.trys), (t = t.length > 0 && t[t.length - 1])) &&
99
- (op[0] === 6 || op[0] === 2)
100
- ) {
101
- _ = 0;
102
- continue;
103
- }
104
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) {
105
- _.label = op[1];
106
- break;
107
- }
108
- if (op[0] === 6 && _.label < t[1]) {
109
- _.label = t[1];
110
- t = op;
111
- break;
112
- }
113
- if (t && _.label < t[2]) {
114
- _.label = t[2];
115
- _.ops.push(op);
116
- break;
117
- }
118
- if (t[2]) _.ops.pop();
119
- _.trys.pop();
120
- continue;
121
- }
122
- op = body.call(thisArg, _);
123
- } catch (e) {
124
- op = [6, e];
125
- y = 0;
126
- } finally {
127
- f = t = 0;
128
- }
129
- if (op[0] & 5) throw op[1];
130
- return { value: op[0] ? op[1] : void 0, done: true };
16
+ if (f) throw new TypeError("Generator is already executing.");
17
+ while (_) try {
18
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
19
+ if (y = 0, t) op = [op[0] & 2, t.value];
20
+ switch (op[0]) {
21
+ case 0: case 1: t = op; break;
22
+ case 4: _.label++; return { value: op[1], done: false };
23
+ case 5: _.label++; y = op[1]; op = [0]; continue;
24
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
25
+ default:
26
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
27
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
28
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
29
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
30
+ if (t[2]) _.ops.pop();
31
+ _.trys.pop(); continue;
32
+ }
33
+ op = body.call(thisArg, _);
34
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
35
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
131
36
  }
132
- };
133
- var __importDefault =
134
- (this && this.__importDefault) ||
135
- function (mod) {
136
- return mod && mod.__esModule ? mod : { default: mod };
137
- };
138
- Object.defineProperty(exports, '__esModule', { value: true });
37
+ };
38
+ var __importDefault = (this && this.__importDefault) || function (mod) {
39
+ return (mod && mod.__esModule) ? mod : { "default": mod };
40
+ };
41
+ Object.defineProperty(exports, "__esModule", { value: true });
139
42
  exports.ContractFactory = void 0;
140
- var minimalistic_assert_1 = __importDefault(require('minimalistic-assert'));
141
- var provider_1 = require('../provider');
142
- var default_1 = require('./default');
43
+ var minimalistic_assert_1 = __importDefault(require("minimalistic-assert"));
44
+ var provider_1 = require("../provider");
45
+ var default_1 = require("./default");
143
46
  var ContractFactory = /** @class */ (function () {
144
- function ContractFactory(
145
- compiledContract,
146
- providerOrAccount,
147
- abi // abi can be different from the deployed contract ie for proxy contracts
148
- ) {
149
- if (providerOrAccount === void 0) {
150
- providerOrAccount = provider_1.defaultProvider;
47
+ function ContractFactory(compiledContract, providerOrAccount, abi // abi can be different from the deployed contract ie for proxy contracts
48
+ ) {
49
+ if (providerOrAccount === void 0) { providerOrAccount = provider_1.defaultProvider; }
50
+ if (abi === void 0) { abi = compiledContract.abi; }
51
+ this.abi = abi;
52
+ this.compiledContract = compiledContract;
53
+ this.providerOrAccount = providerOrAccount;
151
54
  }
152
- if (abi === void 0) {
153
- abi = compiledContract.abi;
154
- }
155
- this.abi = abi;
156
- this.compiledContract = compiledContract;
157
- this.providerOrAccount = providerOrAccount;
158
- }
159
- /**
160
- * Deploys contract and returns new instance of the Contract
161
- *
162
- * @param constructorCalldata - Constructor Calldata
163
- * @param addressSalt (optional) - Address Salt for deployment
164
- * @returns deployed Contract
165
- */
166
- ContractFactory.prototype.deploy = function (constructorCalldata, addressSalt) {
167
- return __awaiter(this, void 0, void 0, function () {
168
- var _a, address, code, transaction_hash, contractInstance;
169
- return __generator(this, function (_b) {
170
- switch (_b.label) {
171
- case 0:
172
- return [
173
- 4 /*yield*/,
174
- this.providerOrAccount.deployContract({
175
- contract: this.compiledContract,
176
- constructorCalldata: constructorCalldata,
177
- addressSalt: addressSalt,
178
- }),
179
- ];
180
- case 1:
181
- (_a = _b.sent()),
182
- (address = _a.address),
183
- (code = _a.code),
184
- (transaction_hash = _a.transaction_hash);
185
- (0,
186
- minimalistic_assert_1.default)(code === 'TRANSACTION_RECEIVED' && Boolean(address), 'Deployment of the contract failed');
187
- contractInstance = new default_1.Contract(
188
- this.compiledContract.abi,
189
- address,
190
- this.providerOrAccount
191
- );
192
- contractInstance.deployTransactionHash = transaction_hash;
193
- return [2 /*return*/, contractInstance];
194
- }
195
- });
196
- });
197
- };
198
- /**
199
- * Attaches to new Provider or Account
200
- *
201
- * @param providerOrAccount - new Provider or Account to attach to
202
- */
203
- ContractFactory.prototype.connect = function (providerOrAccount) {
204
- this.providerOrAccount = providerOrAccount;
205
- return this;
206
- };
207
- /**
208
- * Attaches current abi and provider or account to the new address
209
- *
210
- * @param address - Contract address
211
- * @returns Contract
212
- */
213
- ContractFactory.prototype.attach = function (address) {
214
- return new default_1.Contract(this.abi, address, this.providerOrAccount);
215
- };
216
- return ContractFactory;
217
- })();
55
+ /**
56
+ * Deploys contract and returns new instance of the Contract
57
+ *
58
+ * @param constructorCalldata - Constructor Calldata
59
+ * @param addressSalt (optional) - Address Salt for deployment
60
+ * @returns deployed Contract
61
+ */
62
+ ContractFactory.prototype.deploy = function (constructorCalldata, addressSalt) {
63
+ return __awaiter(this, void 0, void 0, function () {
64
+ var _a, contract_address, transaction_hash, contractInstance;
65
+ return __generator(this, function (_b) {
66
+ switch (_b.label) {
67
+ case 0: return [4 /*yield*/, this.providerOrAccount.deployContract({
68
+ contract: this.compiledContract,
69
+ constructorCalldata: constructorCalldata,
70
+ addressSalt: addressSalt,
71
+ })];
72
+ case 1:
73
+ _a = _b.sent(), contract_address = _a.contract_address, transaction_hash = _a.transaction_hash;
74
+ (0, minimalistic_assert_1.default)(Boolean(contract_address), 'Deployment of the contract failed');
75
+ contractInstance = new default_1.Contract(this.compiledContract.abi, contract_address, this.providerOrAccount);
76
+ contractInstance.deployTransactionHash = transaction_hash;
77
+ return [2 /*return*/, contractInstance];
78
+ }
79
+ });
80
+ });
81
+ };
82
+ /**
83
+ * Attaches to new Provider or Account
84
+ *
85
+ * @param providerOrAccount - new Provider or Account to attach to
86
+ */
87
+ ContractFactory.prototype.connect = function (providerOrAccount) {
88
+ this.providerOrAccount = providerOrAccount;
89
+ return this;
90
+ };
91
+ /**
92
+ * Attaches current abi and provider or account to the new address
93
+ *
94
+ * @param address - Contract address
95
+ * @returns Contract
96
+ */
97
+ ContractFactory.prototype.attach = function (address) {
98
+ return new default_1.Contract(this.abi, address, this.providerOrAccount);
99
+ };
100
+ return ContractFactory;
101
+ }());
218
102
  exports.ContractFactory = ContractFactory;
@@ -1,153 +1,124 @@
1
1
  import { AccountInterface } from '../account';
2
2
  import { ProviderInterface } from '../provider';
3
3
  import { BlockIdentifier } from '../provider/utils';
4
- import {
5
- Abi,
6
- AbiEntry,
7
- AddTransactionResponse,
8
- Args,
9
- AsyncContractFunction,
10
- Calldata,
11
- ContractFunction,
12
- Invocation,
13
- Overrides,
14
- ParsedStruct,
15
- Result,
16
- StructAbi,
17
- } from '../types';
4
+ import { Abi, AbiEntry, Args, AsyncContractFunction, Calldata, ContractFunction, Invocation, InvokeFunctionResponse, Overrides, ParsedStruct, Result, StructAbi } from '../types';
18
5
  import { BigNumberish } from '../utils/number';
19
6
  import { ContractInterface } from './interface';
20
7
  export declare class Contract implements ContractInterface {
21
- abi: Abi;
22
- address: string;
23
- providerOrAccount: ProviderInterface | AccountInterface;
24
- deployTransactionHash?: string;
25
- protected readonly structs: {
26
- [name: string]: StructAbi;
27
- };
28
- readonly functions: {
29
- [name: string]: AsyncContractFunction;
30
- };
31
- readonly callStatic: {
32
- [name: string]: AsyncContractFunction;
33
- };
34
- readonly populateTransaction: {
35
- [name: string]: ContractFunction;
36
- };
37
- readonly estimateFee: {
38
- [name: string]: ContractFunction;
39
- };
40
- readonly [key: string]: AsyncContractFunction | any;
41
- /**
42
- * Contract class to handle contract methods
43
- *
44
- * @param abi - Abi of the contract object
45
- * @param address (optional) - address to connect to
46
- * @param providerOrAccount (optional) - Provider or Account to attach to
47
- */
48
- constructor(abi: Abi, address: string, providerOrAccount?: ProviderInterface | AccountInterface);
49
- /**
50
- * Saves the address of the contract deployed on network that will be used for interaction
51
- *
52
- * @param address - address of the contract
53
- */
54
- attach(address: string): void;
55
- /**
56
- * Attaches to new Provider or Account
57
- *
58
- * @param providerOrAccount - new Provider or Account to attach to
59
- */
60
- connect(providerOrAccount: ProviderInterface | AccountInterface): void;
61
- /**
62
- * Resolves when contract is deployed on the network or when no deployment transaction is found
63
- *
64
- * @returns Promise that resolves when contract is deployed on the network or when no deployment transaction is found
65
- * @throws When deployment fails
66
- */
67
- deployed(): Promise<Contract>;
68
- /**
69
- * Validates if all arguments that are passed to the method are corresponding to the ones in the abi
70
- *
71
- * @param type - type of the method
72
- * @param method - name of the method
73
- * @param args - arguments that are passed to the method
74
- */
75
- protected validateMethodAndArgs(type: 'INVOKE' | 'CALL', method: string, args?: Array<any>): void;
76
- /**
77
- * Deep parse of the object that has been passed to the method
78
- *
79
- * @param struct - struct that needs to be calculated
80
- * @return {number} - number of members for the given struct
81
- */
82
- private calculateStructMembers;
83
- /**
84
- * Deep parse of the object that has been passed to the method
85
- *
86
- * @param element - element that needs to be parsed
87
- * @param type - name of the method
88
- * @return {string | string[]} - parsed arguments in format that contract is expecting
89
- */
90
- protected parseCalldataValue(
91
- element: ParsedStruct | BigNumberish | BigNumberish[],
92
- type: string
93
- ): string | string[];
94
- /**
95
- * Parse of the response elements that are converted to Object (Struct) by using the abi
96
- *
97
- * @param responseIterator - iterator of the response
98
- * @param type - type of the struct
99
- * @return {BigNumberish | ParsedStruct} - parsed arguments in format that contract is expecting
100
- */
101
- protected parseResponseStruct(
102
- responseIterator: Iterator<string>,
103
- type: string
104
- ): BigNumberish | ParsedStruct;
105
- /**
106
- * Parse one field of the calldata by using input field from the abi for that method
107
- *
108
- * @param args - value of the field
109
- * @param input - input(field) information from the abi that will be used to parse the data
110
- * @return {string | string[]} - parsed arguments in format that contract is expecting
111
- */
112
- protected parseCalldataField(argsIterator: Iterator<any>, input: AbiEntry): string | string[];
113
- /**
114
- * Parse the calldata by using input fields from the abi for that method
115
- *
116
- * @param args - arguments passed the the method
117
- * @param inputs - list of inputs(fields) that are in the abi
118
- * @return {Calldata} - parsed arguments in format that contract is expecting
119
- */
120
- protected compileCalldata(args: Array<any>, inputs: AbiEntry[]): Calldata;
121
- /**
122
- * Parse elements of the response and structuring them into one field by using output property from the abi for that method
123
- *
124
- * @param responseIterator - iterator of the response
125
- * @param output - output(field) information from the abi that will be used to parse the data
126
- * @return - parsed response corresponding to the abi structure of the field
127
- */
128
- protected parseResponseField(
129
- responseIterator: Iterator<string>,
130
- output: AbiEntry,
131
- parsedResult?: Args
132
- ): any;
133
- /**
134
- * Parse elements of the response array and structuring them into response object
135
- *
136
- * @param method - method name
137
- * @param response - response from the method
138
- * @return - parsed response corresponding to the abi
139
- */
140
- protected parseResponse(method: string, response: string[]): Result;
141
- invoke(method: string, args?: Array<any>, options?: Overrides): Promise<AddTransactionResponse>;
142
- call(
143
- method: string,
144
- args?: Array<any>,
145
- {
146
- blockIdentifier,
147
- }?: {
148
- blockIdentifier?: BlockIdentifier;
149
- }
150
- ): Promise<Result>;
151
- estimate(method: string, args?: Array<any>): Promise<import('../types').EstimateFee>;
152
- populate(method: string, args?: Array<any>): Invocation;
8
+ abi: Abi;
9
+ address: string;
10
+ providerOrAccount: ProviderInterface | AccountInterface;
11
+ deployTransactionHash?: string;
12
+ protected readonly structs: {
13
+ [name: string]: StructAbi;
14
+ };
15
+ readonly functions: {
16
+ [name: string]: AsyncContractFunction;
17
+ };
18
+ readonly callStatic: {
19
+ [name: string]: AsyncContractFunction;
20
+ };
21
+ readonly populateTransaction: {
22
+ [name: string]: ContractFunction;
23
+ };
24
+ readonly estimateFee: {
25
+ [name: string]: ContractFunction;
26
+ };
27
+ readonly [key: string]: AsyncContractFunction | any;
28
+ /**
29
+ * Contract class to handle contract methods
30
+ *
31
+ * @param abi - Abi of the contract object
32
+ * @param address (optional) - address to connect to
33
+ * @param providerOrAccount (optional) - Provider or Account to attach to
34
+ */
35
+ constructor(abi: Abi, address: string, providerOrAccount?: ProviderInterface | AccountInterface);
36
+ /**
37
+ * Saves the address of the contract deployed on network that will be used for interaction
38
+ *
39
+ * @param address - address of the contract
40
+ */
41
+ attach(address: string): void;
42
+ /**
43
+ * Attaches to new Provider or Account
44
+ *
45
+ * @param providerOrAccount - new Provider or Account to attach to
46
+ */
47
+ connect(providerOrAccount: ProviderInterface | AccountInterface): void;
48
+ /**
49
+ * Resolves when contract is deployed on the network or when no deployment transaction is found
50
+ *
51
+ * @returns Promise that resolves when contract is deployed on the network or when no deployment transaction is found
52
+ * @throws When deployment fails
53
+ */
54
+ deployed(): Promise<Contract>;
55
+ /**
56
+ * Validates if all arguments that are passed to the method are corresponding to the ones in the abi
57
+ *
58
+ * @param type - type of the method
59
+ * @param method - name of the method
60
+ * @param args - arguments that are passed to the method
61
+ */
62
+ protected validateMethodAndArgs(type: 'INVOKE' | 'CALL', method: string, args?: Array<any>): void;
63
+ /**
64
+ * Deep parse of the object that has been passed to the method
65
+ *
66
+ * @param struct - struct that needs to be calculated
67
+ * @return {number} - number of members for the given struct
68
+ */
69
+ private calculateStructMembers;
70
+ /**
71
+ * Deep parse of the object that has been passed to the method
72
+ *
73
+ * @param element - element that needs to be parsed
74
+ * @param type - name of the method
75
+ * @return {string | string[]} - parsed arguments in format that contract is expecting
76
+ */
77
+ protected parseCalldataValue(element: ParsedStruct | BigNumberish | BigNumberish[], type: string): string | string[];
78
+ /**
79
+ * Parse of the response elements that are converted to Object (Struct) by using the abi
80
+ *
81
+ * @param responseIterator - iterator of the response
82
+ * @param type - type of the struct
83
+ * @return {BigNumberish | ParsedStruct} - parsed arguments in format that contract is expecting
84
+ */
85
+ protected parseResponseStruct(responseIterator: Iterator<string>, type: string): BigNumberish | ParsedStruct;
86
+ /**
87
+ * Parse one field of the calldata by using input field from the abi for that method
88
+ *
89
+ * @param args - value of the field
90
+ * @param input - input(field) information from the abi that will be used to parse the data
91
+ * @return {string | string[]} - parsed arguments in format that contract is expecting
92
+ */
93
+ protected parseCalldataField(argsIterator: Iterator<any>, input: AbiEntry): string | string[];
94
+ /**
95
+ * Parse the calldata by using input fields from the abi for that method
96
+ *
97
+ * @param args - arguments passed the the method
98
+ * @param inputs - list of inputs(fields) that are in the abi
99
+ * @return {Calldata} - parsed arguments in format that contract is expecting
100
+ */
101
+ protected compileCalldata(args: Array<any>, inputs: AbiEntry[]): Calldata;
102
+ /**
103
+ * Parse elements of the response and structuring them into one field by using output property from the abi for that method
104
+ *
105
+ * @param responseIterator - iterator of the response
106
+ * @param output - output(field) information from the abi that will be used to parse the data
107
+ * @return - parsed response corresponding to the abi structure of the field
108
+ */
109
+ protected parseResponseField(responseIterator: Iterator<string>, output: AbiEntry, parsedResult?: Args): any;
110
+ /**
111
+ * Parse elements of the response array and structuring them into response object
112
+ *
113
+ * @param method - method name
114
+ * @param response - response from the method
115
+ * @return - parsed response corresponding to the abi
116
+ */
117
+ protected parseResponse(method: string, response: string[]): Result;
118
+ invoke(method: string, args?: Array<any>, options?: Overrides): Promise<InvokeFunctionResponse>;
119
+ call(method: string, args?: Array<any>, { blockIdentifier, }?: {
120
+ blockIdentifier?: BlockIdentifier;
121
+ }): Promise<Result>;
122
+ estimate(method: string, args?: Array<any>): Promise<import("../types").EstimateFeeResponse>;
123
+ populate(method: string, args?: Array<any>): Invocation;
153
124
  }