starknet 11.1.0 → 11.2.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.
- package/CHANGELOG.md +6 -0
- package/dist/index.d.ts +188 -6
- package/dist/index.global.js +175 -3
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +176 -3
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +175 -3
- package/dist/index.mjs.map +1 -1
- package/dist/ledger/index.d.ts +116 -0
- package/dist/ledger/index.js +75 -0
- package/dist/ledger/index.js.map +1 -0
- package/dist/ledger/index.mjs +32 -0
- package/dist/ledger/index.mjs.map +1 -0
- package/package.json +22 -1
package/dist/index.mjs
CHANGED
|
@@ -48,6 +48,7 @@ __export(constants_exports, {
|
|
|
48
48
|
RANGE_I32: () => RANGE_I32,
|
|
49
49
|
RANGE_I64: () => RANGE_I64,
|
|
50
50
|
RANGE_I8: () => RANGE_I8,
|
|
51
|
+
RANGE_STORAGE_ADDRESS: () => RANGE_STORAGE_ADDRESS,
|
|
51
52
|
RANGE_U128: () => RANGE_U128,
|
|
52
53
|
RANGE_U16: () => RANGE_U16,
|
|
53
54
|
RANGE_U32: () => RANGE_U32,
|
|
@@ -280,6 +281,7 @@ var RANGE_I128 = range(-(2n ** 127n), 2n ** 127n - 1n);
|
|
|
280
281
|
var RANGE_ETH_ADDRESS = range(ZERO, 2n ** 160n - 1n);
|
|
281
282
|
var RANGE_CONTRACT_ADDRESS = range(ZERO, ADDR_BOUND - 1n);
|
|
282
283
|
var RANGE_CLASS_HASH = range(ZERO, 2n ** 251n - 1n);
|
|
284
|
+
var RANGE_STORAGE_ADDRESS = range(ZERO, 2n ** 251n - 1n);
|
|
283
285
|
var LegacyUDC = {
|
|
284
286
|
ADDRESS: "0x041a78e741e5af2fec34b695679bc6891742439f7afb8484ecd7766661ad02bf",
|
|
285
287
|
ENTRYPOINT: "deployContract"
|
|
@@ -961,6 +963,7 @@ var Literal = {
|
|
|
961
963
|
ClassHash: "core::starknet::class_hash::ClassHash",
|
|
962
964
|
ContractAddress: "core::starknet::contract_address::ContractAddress",
|
|
963
965
|
Secp256k1Point: "core::starknet::secp256k1::Secp256k1Point",
|
|
966
|
+
StorageAddress: "core::starknet::storage_access::StorageAddress",
|
|
964
967
|
U96: "core::internal::bounded_int::BoundedInt::<0, 79228162514264337593543950335>"
|
|
965
968
|
};
|
|
966
969
|
var ETH_ADDRESS = "core::starknet::eth_address::EthAddress";
|
|
@@ -8074,6 +8077,169 @@ var CairoContractAddress = class _CairoContractAddress {
|
|
|
8074
8077
|
}
|
|
8075
8078
|
};
|
|
8076
8079
|
|
|
8080
|
+
// src/utils/cairoDataTypes/storageAddress.ts
|
|
8081
|
+
var CairoStorageAddress = class _CairoStorageAddress {
|
|
8082
|
+
/**
|
|
8083
|
+
* The address, always as a bigint.
|
|
8084
|
+
* @example
|
|
8085
|
+
* ```typescript
|
|
8086
|
+
* const result = new CairoStorageAddress('0x1234').data;
|
|
8087
|
+
* // result = 4660n
|
|
8088
|
+
* ```
|
|
8089
|
+
*/
|
|
8090
|
+
data;
|
|
8091
|
+
/**
|
|
8092
|
+
* The abi type this class serializes.
|
|
8093
|
+
* @example
|
|
8094
|
+
* ```typescript
|
|
8095
|
+
* const result = CairoStorageAddress.abiSelector;
|
|
8096
|
+
* // result = "core::starknet::storage_access::StorageAddress"
|
|
8097
|
+
* ```
|
|
8098
|
+
*/
|
|
8099
|
+
static abiSelector = Literal.StorageAddress;
|
|
8100
|
+
/**
|
|
8101
|
+
* Build from a number or a numeric string, refusing text and anything outside the
|
|
8102
|
+
* StorageAddress range.
|
|
8103
|
+
* @param {BigNumberish | boolean} data the address to carry, within [0, 2^251 - 1]
|
|
8104
|
+
* @throws {Error} when the value is text, a decimal number, not a felt252 input, or out of the StorageAddress range
|
|
8105
|
+
* @example
|
|
8106
|
+
* ```typescript
|
|
8107
|
+
* const result = new CairoStorageAddress('0x1234').toApiRequest();
|
|
8108
|
+
* // result = ["4660"]
|
|
8109
|
+
* ```
|
|
8110
|
+
*/
|
|
8111
|
+
constructor(data) {
|
|
8112
|
+
_CairoStorageAddress.validate(data);
|
|
8113
|
+
this.data = new CairoFelt252(data).toBigInt();
|
|
8114
|
+
}
|
|
8115
|
+
/**
|
|
8116
|
+
* Serialize to the single felt a contract call carries.
|
|
8117
|
+
* @returns {string[]} one decimal-string felt, flagged as compiled
|
|
8118
|
+
* @example
|
|
8119
|
+
* ```typescript
|
|
8120
|
+
* const result = new CairoStorageAddress('0x1234').toApiRequest();
|
|
8121
|
+
* // result = ["4660"]
|
|
8122
|
+
* ```
|
|
8123
|
+
*/
|
|
8124
|
+
toApiRequest() {
|
|
8125
|
+
return addCompiledFlag([this.toBigInt().toString()]);
|
|
8126
|
+
}
|
|
8127
|
+
/**
|
|
8128
|
+
* The address as a number.
|
|
8129
|
+
* @returns {bigint} the number this address holds
|
|
8130
|
+
* @example
|
|
8131
|
+
* ```typescript
|
|
8132
|
+
* const result = new CairoStorageAddress('0x1234').toBigInt();
|
|
8133
|
+
* // result = 4660n
|
|
8134
|
+
* ```
|
|
8135
|
+
*/
|
|
8136
|
+
toBigInt() {
|
|
8137
|
+
return this.data;
|
|
8138
|
+
}
|
|
8139
|
+
/**
|
|
8140
|
+
* The address in hexadecimal, without padding.
|
|
8141
|
+
*
|
|
8142
|
+
* Leading zeros are dropped, as they are everywhere else in the library.
|
|
8143
|
+
* @returns {string} the address as a 0x-prefixed hex string
|
|
8144
|
+
* @example
|
|
8145
|
+
* ```typescript
|
|
8146
|
+
* const result = new CairoStorageAddress(4660).toHexString();
|
|
8147
|
+
* // result = "0x1234"
|
|
8148
|
+
* const result2 = new CairoStorageAddress('0x0034').toHexString();
|
|
8149
|
+
* // result2 = "0x34" (four digits in, two out)
|
|
8150
|
+
* ```
|
|
8151
|
+
*/
|
|
8152
|
+
toHexString() {
|
|
8153
|
+
return addHexPrefix(this.toBigInt().toString(16));
|
|
8154
|
+
}
|
|
8155
|
+
/**
|
|
8156
|
+
* Throw unless the value can be carried by a StorageAddress.
|
|
8157
|
+
*
|
|
8158
|
+
* Text is refused first, then a number with a decimal part. A number or a bigint is read as it
|
|
8159
|
+
* is, so that a negative one reaches the range check. Anything else is read as a felt252 — which
|
|
8160
|
+
* is what refuses a null, an object or an unsupported type. The value is finally checked against
|
|
8161
|
+
* the range of the Cairo `StorageAddress` type, [0, 2^251), which is narrower than the field.
|
|
8162
|
+
* @param {BigNumberish | boolean} data the value to check
|
|
8163
|
+
* @throws {Error} when the value is text, a decimal number, not a felt252 input, or out of the StorageAddress range
|
|
8164
|
+
* @example
|
|
8165
|
+
* ```typescript
|
|
8166
|
+
* CairoStorageAddress.validate('0x1234'); // passes
|
|
8167
|
+
* CairoStorageAddress.validate('abc');
|
|
8168
|
+
* // throws Error("Invalid input: a StorageAddress cannot be built from text")
|
|
8169
|
+
* CairoStorageAddress.validate(2n ** 251n);
|
|
8170
|
+
* // throws Error("Value is out of StorageAddress range [0, 3618502788666131106986593281521497120414687020801267626233049500247285301247]")
|
|
8171
|
+
* CairoStorageAddress.validate(-1);
|
|
8172
|
+
* // throws Error("Value is out of StorageAddress range [0, 3618502788666131106986593281521497120414687020801267626233049500247285301247]")
|
|
8173
|
+
* ```
|
|
8174
|
+
*/
|
|
8175
|
+
static validate(data) {
|
|
8176
|
+
assert(!isText(data), "Invalid input: a StorageAddress cannot be built from text");
|
|
8177
|
+
assert(
|
|
8178
|
+
!isNumber(data) || Number.isInteger(data),
|
|
8179
|
+
"Invalid input: decimal numbers are not supported, only integers"
|
|
8180
|
+
);
|
|
8181
|
+
const value = isNumber(data) || isBigInt(data) ? BigInt(data) : new CairoFelt252(data).toBigInt();
|
|
8182
|
+
assert(
|
|
8183
|
+
value >= RANGE_STORAGE_ADDRESS.min && value <= RANGE_STORAGE_ADDRESS.max,
|
|
8184
|
+
`Value is out of StorageAddress range [${RANGE_STORAGE_ADDRESS.min}, ${RANGE_STORAGE_ADDRESS.max}]`
|
|
8185
|
+
);
|
|
8186
|
+
}
|
|
8187
|
+
/**
|
|
8188
|
+
* Can this value be carried by a StorageAddress?
|
|
8189
|
+
*
|
|
8190
|
+
* The non-throwing form of {@link CairoStorageAddress.validate}, so it answers false for every
|
|
8191
|
+
* input that one refuses, whatever the reason.
|
|
8192
|
+
* @param {BigNumberish | boolean} data the value to test
|
|
8193
|
+
* @returns {boolean} true when the value fits in a StorageAddress
|
|
8194
|
+
* @example
|
|
8195
|
+
* ```typescript
|
|
8196
|
+
* const result = CairoStorageAddress.is('0x1234');
|
|
8197
|
+
* // result = true
|
|
8198
|
+
* const result2 = CairoStorageAddress.is('abc');
|
|
8199
|
+
* // result2 = false (text, not a number)
|
|
8200
|
+
* ```
|
|
8201
|
+
*/
|
|
8202
|
+
static is(data) {
|
|
8203
|
+
try {
|
|
8204
|
+
_CairoStorageAddress.validate(data);
|
|
8205
|
+
return true;
|
|
8206
|
+
} catch {
|
|
8207
|
+
return false;
|
|
8208
|
+
}
|
|
8209
|
+
}
|
|
8210
|
+
/**
|
|
8211
|
+
* Is this abi type the one this class serializes?
|
|
8212
|
+
* @param {string} abiType the abi type to test
|
|
8213
|
+
* @returns {boolean} true for `core::starknet::storage_access::StorageAddress`
|
|
8214
|
+
* @example
|
|
8215
|
+
* ```typescript
|
|
8216
|
+
* const result = CairoStorageAddress.isAbiType(
|
|
8217
|
+
* 'core::starknet::storage_access::StorageAddress'
|
|
8218
|
+
* );
|
|
8219
|
+
* // result = true
|
|
8220
|
+
* const result2 = CairoStorageAddress.isAbiType('core::felt252');
|
|
8221
|
+
* // result2 = false
|
|
8222
|
+
* ```
|
|
8223
|
+
*/
|
|
8224
|
+
static isAbiType(abiType) {
|
|
8225
|
+
return abiType === _CairoStorageAddress.abiSelector;
|
|
8226
|
+
}
|
|
8227
|
+
/**
|
|
8228
|
+
* Read one StorageAddress off a contract response, advancing the iterator past it.
|
|
8229
|
+
* @param {Iterator<string>} responseIterator the response felts, positioned on this address
|
|
8230
|
+
* @returns {CairoStorageAddress} the address that was read
|
|
8231
|
+
* @example
|
|
8232
|
+
* ```typescript
|
|
8233
|
+
* const response = ['0x1234'];
|
|
8234
|
+
* const result = CairoStorageAddress.factoryFromApiResponse(response.values()).toBigInt();
|
|
8235
|
+
* // result = 4660n
|
|
8236
|
+
* ```
|
|
8237
|
+
*/
|
|
8238
|
+
static factoryFromApiResponse(responseIterator) {
|
|
8239
|
+
return new _CairoStorageAddress(getNext(responseIterator));
|
|
8240
|
+
}
|
|
8241
|
+
};
|
|
8242
|
+
|
|
8077
8243
|
// src/utils/cairoDataTypes/ethAddress.ts
|
|
8078
8244
|
var CairoEthAddress = class _CairoEthAddress {
|
|
8079
8245
|
/**
|
|
@@ -10480,6 +10646,7 @@ var LEAF_TYPES = [
|
|
|
10480
10646
|
CairoEthAddress,
|
|
10481
10647
|
CairoClassHash,
|
|
10482
10648
|
CairoContractAddress,
|
|
10649
|
+
CairoStorageAddress,
|
|
10483
10650
|
CairoBytes31,
|
|
10484
10651
|
CairoByteArray,
|
|
10485
10652
|
CairoSecp256k1Point,
|
|
@@ -10553,6 +10720,7 @@ var cairoTypeStrategy = {
|
|
|
10553
10720
|
[CairoEthAddress.abiSelector]: (instance) => instance.toBigInt(),
|
|
10554
10721
|
[CairoClassHash.abiSelector]: (instance) => instance.toBigInt(),
|
|
10555
10722
|
[CairoContractAddress.abiSelector]: (instance) => instance.toBigInt(),
|
|
10723
|
+
[CairoStorageAddress.abiSelector]: (instance) => instance.toBigInt(),
|
|
10556
10724
|
[CairoBytes31.abiSelector]: (instance) => instance.decodeUtf8(),
|
|
10557
10725
|
[CairoByteArray.abiSelector]: (instance) => instance.decodeUtf8(),
|
|
10558
10726
|
[CairoSecp256k1Point.abiSelector]: (instance) => instance.toBigInt(),
|
|
@@ -17332,6 +17500,9 @@ if (typeof Symbol.dispose !== "undefined") {
|
|
|
17332
17500
|
WebSocketProvider.prototype[Symbol.dispose] = WebSocketProvider.prototype.dispose;
|
|
17333
17501
|
}
|
|
17334
17502
|
|
|
17503
|
+
// src/provider/index.ts
|
|
17504
|
+
var Provider = RpcProvider;
|
|
17505
|
+
|
|
17335
17506
|
// src/signer/interface.ts
|
|
17336
17507
|
var SignerInterface = class {
|
|
17337
17508
|
};
|
|
@@ -17799,13 +17970,13 @@ var LedgerSigner221 = class extends LedgerSigner111 {
|
|
|
17799
17970
|
*
|
|
17800
17971
|
* If you are using APP v2.2.1 with an account created with the v1.1.1, you need to use :
|
|
17801
17972
|
* ```typescript
|
|
17802
|
-
* const myLedgerSigner = new
|
|
17973
|
+
* const myLedgerSigner = new LedgerSigner221(myNodeTransport, 0, undefined, getLedgerPathBuffer111);
|
|
17803
17974
|
* ```
|
|
17804
17975
|
* @example
|
|
17805
17976
|
* ```typescript
|
|
17806
17977
|
* import TransportNodeHid from "@ledgerhq/hw-transport-node-hid";
|
|
17807
17978
|
* const myNodeTransport = await TransportNodeHid.create();
|
|
17808
|
-
* const myLedgerSigner = new
|
|
17979
|
+
* const myLedgerSigner = new LedgerSigner221(myNodeTransport, 0);
|
|
17809
17980
|
* ```
|
|
17810
17981
|
*/
|
|
17811
17982
|
constructor(transport, accountID, eip2645application = "LedgerW", pathFunction = getLedgerPathBuffer221) {
|
|
@@ -21322,6 +21493,7 @@ export {
|
|
|
21322
21493
|
CairoResult,
|
|
21323
21494
|
CairoResultVariant,
|
|
21324
21495
|
CairoSecp256k1Point,
|
|
21496
|
+
CairoStorageAddress,
|
|
21325
21497
|
CairoStruct,
|
|
21326
21498
|
CairoTuple,
|
|
21327
21499
|
CairoTypeCustomEnum,
|
|
@@ -21368,7 +21540,7 @@ export {
|
|
|
21368
21540
|
PaymasterInterface,
|
|
21369
21541
|
PaymasterRpc,
|
|
21370
21542
|
PluginManager,
|
|
21371
|
-
|
|
21543
|
+
Provider,
|
|
21372
21544
|
ProviderInterface,
|
|
21373
21545
|
api_exports as RPC,
|
|
21374
21546
|
v0_10_2_exports as RPC0102,
|