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.
- package/CHANGELOG.md +70 -0
- package/README.md +1 -2
- package/__tests__/account.test.ts +11 -56
- package/__tests__/contract.test.ts +11 -49
- package/__tests__/defaultProvider.test.ts +321 -0
- package/__tests__/fixtures.ts +32 -11
- package/__tests__/jest.setup.ts +2 -3
- package/__tests__/rpcProvider.test.ts +17 -0
- package/__tests__/sequencerProvider.test.ts +45 -0
- package/account/default.d.ts +54 -77
- package/account/default.js +271 -596
- package/account/index.js +18 -31
- package/account/interface.d.ts +66 -95
- package/account/interface.js +20 -30
- package/constants.d.ts +17 -19
- package/constants.js +2038 -2059
- package/contract/contractFactory.d.ts +25 -29
- package/contract/contractFactory.js +94 -210
- package/contract/default.d.ts +117 -146
- package/contract/default.js +582 -776
- package/contract/index.js +19 -32
- package/contract/interface.d.ts +72 -92
- package/contract/interface.js +6 -5
- package/dist/account/default.d.ts +5 -9
- package/dist/account/default.js +35 -169
- package/dist/account/interface.d.ts +3 -15
- package/dist/contract/contractFactory.js +4 -4
- package/dist/contract/default.d.ts +3 -3
- package/dist/contract/default.js +3 -2
- package/dist/contract/interface.d.ts +2 -2
- package/dist/provider/default.d.ts +18 -134
- package/dist/provider/default.js +47 -411
- package/dist/provider/index.d.ts +2 -0
- package/dist/provider/index.js +2 -0
- package/dist/provider/interface.d.ts +45 -50
- package/dist/provider/rpc.d.ts +57 -0
- package/dist/provider/rpc.js +364 -0
- package/dist/provider/sequencer.d.ts +66 -0
- package/dist/provider/sequencer.js +444 -0
- package/dist/types/account.d.ts +2 -3
- package/dist/types/api/index.d.ts +16 -0
- package/dist/types/api/index.js +18 -0
- package/dist/types/api/rpc.d.ts +221 -0
- package/dist/types/{api.js → api/rpc.js} +0 -0
- package/dist/types/api/sequencer.d.ts +289 -0
- package/dist/types/api/sequencer.js +2 -0
- package/dist/types/index.d.ts +3 -1
- package/dist/types/index.js +15 -1
- package/dist/types/lib.d.ts +3 -1
- package/dist/types/provider.d.ts +86 -0
- package/dist/types/provider.js +2 -0
- package/dist/utils/fetchPonyfill.d.ts +2 -0
- package/dist/utils/fetchPonyfill.js +6 -0
- package/dist/utils/provider.d.ts +4 -0
- package/dist/utils/provider.js +38 -0
- package/dist/utils/responseParser/index.d.ts +11 -0
- package/dist/utils/responseParser/index.js +9 -0
- package/dist/utils/responseParser/rpc.d.ts +13 -0
- package/dist/utils/responseParser/rpc.js +96 -0
- package/dist/utils/responseParser/sequencer.d.ts +13 -0
- package/dist/utils/responseParser/sequencer.js +124 -0
- package/index.js +42 -75
- package/package.json +2 -3
- package/provider/default.d.ts +21 -175
- package/provider/default.js +139 -704
- package/provider/errors.d.ts +4 -4
- package/provider/errors.js +30 -40
- package/provider/index.d.ts +2 -0
- package/provider/index.js +22 -33
- package/provider/interface.d.ts +104 -131
- package/provider/interface.js +6 -5
- package/provider/rpc.d.ts +57 -0
- package/provider/rpc.js +364 -0
- package/provider/sequencer.d.ts +66 -0
- package/provider/sequencer.js +444 -0
- package/provider/utils.d.ts +7 -9
- package/provider/utils.js +39 -44
- package/signer/default.d.ts +5 -9
- package/signer/default.js +72 -177
- package/signer/index.js +18 -31
- package/signer/interface.d.ts +29 -33
- package/signer/interface.js +6 -5
- package/src/account/default.ts +26 -146
- package/src/account/interface.ts +5 -20
- package/src/contract/contractFactory.ts +3 -6
- package/src/contract/default.ts +6 -4
- package/src/contract/interface.ts +2 -2
- package/src/provider/default.ts +63 -395
- package/src/provider/index.ts +2 -0
- package/src/provider/interface.ts +68 -63
- package/src/provider/rpc.ts +299 -0
- package/src/provider/sequencer.ts +385 -0
- package/src/types/account.ts +2 -3
- package/src/types/api/index.ts +17 -0
- package/src/types/api/rpc.ts +247 -0
- package/src/types/api/sequencer.ts +331 -0
- package/src/types/index.ts +3 -1
- package/src/types/lib.ts +3 -1
- package/src/types/provider.ts +108 -0
- package/src/utils/fetchPonyfill.ts +4 -0
- package/src/utils/provider.ts +28 -0
- package/src/utils/responseParser/index.ts +28 -0
- package/src/utils/responseParser/rpc.ts +93 -0
- package/src/utils/responseParser/sequencer.ts +127 -0
- package/types/account.d.ts +5 -7
- package/types/account.js +2 -2
- package/types/api/index.d.ts +16 -0
- package/types/api/index.js +18 -0
- package/types/api/rpc.d.ts +221 -0
- package/types/api/rpc.js +2 -0
- package/types/api/sequencer.d.ts +289 -0
- package/types/api/sequencer.js +2 -0
- package/types/contract.d.ts +1 -1
- package/types/contract.js +2 -2
- package/types/index.d.ts +3 -1
- package/types/index.js +35 -34
- package/types/lib.d.ts +36 -41
- package/types/lib.js +2 -2
- package/types/provider.d.ts +86 -0
- package/types/provider.js +2 -0
- package/types/signer.d.ts +2 -2
- package/types/signer.js +2 -2
- package/utils/address.js +26 -37
- package/utils/ellipticCurve.d.ts +1 -6
- package/utils/ellipticCurve.js +73 -137
- package/utils/encode.js +49 -85
- package/utils/fetchPonyfill.d.ts +2 -0
- package/utils/fetchPonyfill.js +6 -0
- package/utils/hash.d.ts +4 -31
- package/utils/hash.js +76 -141
- package/utils/json.d.ts +13 -45
- package/utils/json.js +15 -22
- package/utils/number.d.ts +2 -9
- package/utils/number.js +47 -81
- package/utils/provider.d.ts +4 -0
- package/utils/provider.js +38 -0
- package/utils/responseParser/index.d.ts +11 -0
- package/utils/responseParser/index.js +9 -0
- package/utils/responseParser/rpc.d.ts +13 -0
- package/utils/responseParser/rpc.js +96 -0
- package/utils/responseParser/sequencer.d.ts +13 -0
- package/utils/responseParser/sequencer.js +124 -0
- package/utils/shortString.js +13 -21
- package/utils/stark.d.ts +0 -1
- package/utils/stark.js +59 -93
- package/utils/transaction.d.ts +3 -6
- package/utils/transaction.js +50 -81
- package/utils/typedData/index.d.ts +3 -15
- package/utils/typedData/index.js +109 -175
- package/utils/typedData/types.d.ts +9 -9
- package/utils/typedData/types.js +2 -2
- package/utils/typedData/utils.js +6 -6
- package/utils/uint256.d.ts +5 -5
- package/utils/uint256.js +16 -26
- package/www/docs/API/account.md +3 -4
- package/www/docs/API/contract.md +2 -2
- package/www/docs/API/contractFactory.md +2 -2
- package/www/docs/API/provider.md +185 -74
- package/www/guides/account.md +1 -8
- package/www/guides/erc20.md +3 -0
- package/__tests__/provider.test.ts +0 -168
- package/dist/types/api.d.ts +0 -261
- package/src/types/api.ts +0 -303
- package/types/api.d.ts +0 -287
- 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
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
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
|
-
|
|
2
|
-
var __awaiter =
|
|
3
|
-
|
|
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
|
-
|
|
14
|
-
try {
|
|
15
|
-
|
|
16
|
-
|
|
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
|
-
|
|
35
|
-
|
|
36
|
-
|
|
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
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
(
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
op[0]
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
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
|
-
|
|
135
|
-
|
|
136
|
-
|
|
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(
|
|
141
|
-
var provider_1 = require(
|
|
142
|
-
var default_1 = require(
|
|
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
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
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
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
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;
|
package/contract/default.d.ts
CHANGED
|
@@ -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
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
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
|
}
|