starknet 5.0.0 → 5.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 +7 -0
- package/dist/index.global.js +225 -176
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +21 -21
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +20 -20
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -4
package/dist/index.mjs
CHANGED
|
@@ -4,9 +4,6 @@ var __export = (target, all) => {
|
|
|
4
4
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
5
5
|
};
|
|
6
6
|
|
|
7
|
-
// src/contract/default.ts
|
|
8
|
-
import assert4 from "minimalistic-assert";
|
|
9
|
-
|
|
10
7
|
// src/types/lib.ts
|
|
11
8
|
var TransactionStatus = /* @__PURE__ */ ((TransactionStatus2) => {
|
|
12
9
|
TransactionStatus2["NOT_RECEIVED"] = "NOT_RECEIVED";
|
|
@@ -2238,7 +2235,15 @@ __export(number_exports, {
|
|
|
2238
2235
|
toHex: () => toHex,
|
|
2239
2236
|
toHexString: () => toHexString
|
|
2240
2237
|
});
|
|
2241
|
-
|
|
2238
|
+
|
|
2239
|
+
// src/utils/assert.ts
|
|
2240
|
+
function assert(condition, message) {
|
|
2241
|
+
if (!condition) {
|
|
2242
|
+
throw new Error(message || "Assertion failure");
|
|
2243
|
+
}
|
|
2244
|
+
}
|
|
2245
|
+
|
|
2246
|
+
// src/utils/number.ts
|
|
2242
2247
|
function isHex(hex) {
|
|
2243
2248
|
return /^0x[0-9a-f]*$/i.test(hex);
|
|
2244
2249
|
}
|
|
@@ -2829,7 +2834,7 @@ function useEncoded(decoded) {
|
|
|
2829
2834
|
}
|
|
2830
2835
|
function getStarknetIdContract(chainId) {
|
|
2831
2836
|
const starknetIdMainnetContract = "0x6ac597f8116f886fa1c97a23fa4e08299975ecaf6b598873ca6792b9bbfb678";
|
|
2832
|
-
const starknetIdTestnetContract = "
|
|
2837
|
+
const starknetIdTestnetContract = "0x3bab268e932d2cecd1946f100ae67ce3dff9fd234119ea2f6da57d16d29fce";
|
|
2833
2838
|
switch (chainId) {
|
|
2834
2839
|
case "0x534e5f4d41494e" /* SN_MAIN */:
|
|
2835
2840
|
return starknetIdMainnetContract;
|
|
@@ -3913,9 +3918,6 @@ var ProviderInterface = class {
|
|
|
3913
3918
|
// src/provider/index.ts
|
|
3914
3919
|
var defaultProvider = new Provider();
|
|
3915
3920
|
|
|
3916
|
-
// src/utils/calldata/index.ts
|
|
3917
|
-
import assert3 from "minimalistic-assert";
|
|
3918
|
-
|
|
3919
3921
|
// src/utils/calldata/formatter.ts
|
|
3920
3922
|
var guard = {
|
|
3921
3923
|
isBN: (data, type, key) => {
|
|
@@ -4141,27 +4143,26 @@ function responseParser(responseIterator, output, structs, parsedResult) {
|
|
|
4141
4143
|
}
|
|
4142
4144
|
|
|
4143
4145
|
// src/utils/calldata/validate.ts
|
|
4144
|
-
import assert2 from "minimalistic-assert";
|
|
4145
4146
|
var validateFelt = (parameter, input) => {
|
|
4146
|
-
|
|
4147
|
+
assert(
|
|
4147
4148
|
typeof parameter === "string" || typeof parameter === "number" || typeof parameter === "bigint",
|
|
4148
4149
|
`Validate: arg ${input.name} should be a felt (string, number, BigNumber)`
|
|
4149
4150
|
);
|
|
4150
4151
|
};
|
|
4151
4152
|
var validateStruct = (parameter, input, structs) => {
|
|
4152
|
-
|
|
4153
|
+
assert(
|
|
4153
4154
|
typeof parameter === "object" && !Array.isArray(parameter),
|
|
4154
4155
|
`Validate: arg ${input.name} is cairo type struct (${input.type}), and should be defined as js object (not array)`
|
|
4155
4156
|
);
|
|
4156
4157
|
structs[input.type].members.forEach(({ name }) => {
|
|
4157
|
-
|
|
4158
|
+
assert(
|
|
4158
4159
|
Object.keys(parameter).includes(name),
|
|
4159
4160
|
`Validate: arg ${input.name} should have a property ${name}`
|
|
4160
4161
|
);
|
|
4161
4162
|
});
|
|
4162
4163
|
};
|
|
4163
4164
|
var validateTuple = (parameter, input) => {
|
|
4164
|
-
|
|
4165
|
+
assert(
|
|
4165
4166
|
typeof parameter === "object" && !Array.isArray(parameter),
|
|
4166
4167
|
`Validate: arg ${input.name} should be a tuple (defined as object)`
|
|
4167
4168
|
);
|
|
@@ -4170,7 +4171,7 @@ var validateArray = (parameter, input, structs) => {
|
|
|
4170
4171
|
const baseType = input.type.replace("*", "");
|
|
4171
4172
|
if (isTypeFelt(baseType) && isLongText(parameter))
|
|
4172
4173
|
return;
|
|
4173
|
-
|
|
4174
|
+
assert(Array.isArray(parameter), `Validate: arg ${input.name} should be an Array`);
|
|
4174
4175
|
switch (true) {
|
|
4175
4176
|
case isTypeFelt(baseType):
|
|
4176
4177
|
parameter.forEach((param) => validateFelt(param, input));
|
|
@@ -4230,7 +4231,7 @@ var CallData = class {
|
|
|
4230
4231
|
const isView = abi.stateMutability === "view";
|
|
4231
4232
|
return type === "INVOKE" ? !isView : isView;
|
|
4232
4233
|
}).map((abi) => abi.name);
|
|
4233
|
-
|
|
4234
|
+
assert(
|
|
4234
4235
|
invocableFunctionNames.includes(method),
|
|
4235
4236
|
`${type === "INVOKE" ? "invocable" : "viewable"} method not found in abi`
|
|
4236
4237
|
);
|
|
@@ -4429,7 +4430,7 @@ var Contract = class {
|
|
|
4429
4430
|
}
|
|
4430
4431
|
async call(method, args = [], options = { parseRequest: true, parseResponse: true, formatResponse: void 0 }) {
|
|
4431
4432
|
var _a;
|
|
4432
|
-
|
|
4433
|
+
assert(this.address !== null, "contract is not connected to an address");
|
|
4433
4434
|
const blockIdentifier = (options == null ? void 0 : options.blockIdentifier) || void 0;
|
|
4434
4435
|
let calldata = args[0];
|
|
4435
4436
|
if (options.parseRequest && !((_a = args[0]) == null ? void 0 : _a.compiled)) {
|
|
@@ -4457,7 +4458,7 @@ var Contract = class {
|
|
|
4457
4458
|
invoke(method, args = [], options = {
|
|
4458
4459
|
parseRequest: true
|
|
4459
4460
|
}) {
|
|
4460
|
-
|
|
4461
|
+
assert(this.address !== null, "contract is not connected to an address");
|
|
4461
4462
|
let calldata = args == null ? void 0 : args[0];
|
|
4462
4463
|
if (options.parseRequest && !(calldata == null ? void 0 : calldata.compiled)) {
|
|
4463
4464
|
const { inputs } = this.abi.find((abi) => abi.name === method);
|
|
@@ -4491,7 +4492,7 @@ var Contract = class {
|
|
|
4491
4492
|
}
|
|
4492
4493
|
async estimate(method, args = []) {
|
|
4493
4494
|
var _a;
|
|
4494
|
-
|
|
4495
|
+
assert(this.address !== null, "contract is not connected to an address");
|
|
4495
4496
|
if (!((_a = args[0]) == null ? void 0 : _a.compiled)) {
|
|
4496
4497
|
this.callData.validate("INVOKE", method, args);
|
|
4497
4498
|
}
|
|
@@ -4518,7 +4519,6 @@ var ContractInterface = class {
|
|
|
4518
4519
|
};
|
|
4519
4520
|
|
|
4520
4521
|
// src/contract/contractFactory.ts
|
|
4521
|
-
import assert5 from "minimalistic-assert";
|
|
4522
4522
|
var ContractFactory = class {
|
|
4523
4523
|
constructor(compiledContract, classHash, account, abi = compiledContract.abi) {
|
|
4524
4524
|
this.abi = abi;
|
|
@@ -4556,7 +4556,7 @@ var ContractFactory = class {
|
|
|
4556
4556
|
constructorCalldata,
|
|
4557
4557
|
salt: addressSalt
|
|
4558
4558
|
});
|
|
4559
|
-
|
|
4559
|
+
assert(Boolean(contract_address), "Deployment of the contract failed");
|
|
4560
4560
|
const contractInstance = new Contract(
|
|
4561
4561
|
this.compiledContract.abi,
|
|
4562
4562
|
contract_address,
|