starknet 6.5.0 → 6.6.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 +16 -0
- package/dist/index.d.ts +455 -3
- package/dist/index.global.js +240 -33
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +256 -34
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +240 -33
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
package/dist/index.mjs
CHANGED
|
@@ -359,7 +359,7 @@ var UDC = {
|
|
|
359
359
|
ADDRESS: "0x041a78e741e5af2fec34b695679bc6891742439f7afb8484ecd7766661ad02bf",
|
|
360
360
|
ENTRYPOINT: "deployContract"
|
|
361
361
|
};
|
|
362
|
-
var RPC_DEFAULT_VERSION = "
|
|
362
|
+
var RPC_DEFAULT_VERSION = "v0_7";
|
|
363
363
|
var RPC_NODES = {
|
|
364
364
|
SN_GOERLI: [
|
|
365
365
|
`https://starknet-testnet.public.blastapi.io/rpc/${RPC_DEFAULT_VERSION}`,
|
|
@@ -3083,6 +3083,7 @@ function isPendingStateUpdate(response) {
|
|
|
3083
3083
|
// src/utils/transaction.ts
|
|
3084
3084
|
var transaction_exports = {};
|
|
3085
3085
|
__export(transaction_exports, {
|
|
3086
|
+
buildUDCCall: () => buildUDCCall,
|
|
3086
3087
|
fromCallsToExecuteCalldata: () => fromCallsToExecuteCalldata,
|
|
3087
3088
|
fromCallsToExecuteCalldataWithNonce: () => fromCallsToExecuteCalldataWithNonce,
|
|
3088
3089
|
fromCallsToExecuteCalldata_cairo1: () => fromCallsToExecuteCalldata_cairo1,
|
|
@@ -3140,6 +3141,41 @@ var getExecuteCalldata = (calls, cairoVersion = "0") => {
|
|
|
3140
3141
|
}
|
|
3141
3142
|
return fromCallsToExecuteCalldata(calls);
|
|
3142
3143
|
};
|
|
3144
|
+
function buildUDCCall(payload, address) {
|
|
3145
|
+
const params = [].concat(payload).map((it) => {
|
|
3146
|
+
const {
|
|
3147
|
+
classHash,
|
|
3148
|
+
salt,
|
|
3149
|
+
unique = true,
|
|
3150
|
+
constructorCalldata = []
|
|
3151
|
+
} = it;
|
|
3152
|
+
const compiledConstructorCallData = CallData.compile(constructorCalldata);
|
|
3153
|
+
const deploySalt = salt ?? randomAddress();
|
|
3154
|
+
return {
|
|
3155
|
+
call: {
|
|
3156
|
+
contractAddress: UDC.ADDRESS,
|
|
3157
|
+
entrypoint: UDC.ENTRYPOINT,
|
|
3158
|
+
calldata: [
|
|
3159
|
+
classHash,
|
|
3160
|
+
deploySalt,
|
|
3161
|
+
toCairoBool(unique),
|
|
3162
|
+
compiledConstructorCallData.length,
|
|
3163
|
+
...compiledConstructorCallData
|
|
3164
|
+
]
|
|
3165
|
+
},
|
|
3166
|
+
address: calculateContractAddressFromHash(
|
|
3167
|
+
unique ? starkCurve.pedersen(address, deploySalt) : deploySalt,
|
|
3168
|
+
classHash,
|
|
3169
|
+
compiledConstructorCallData,
|
|
3170
|
+
unique ? UDC.ADDRESS : 0
|
|
3171
|
+
)
|
|
3172
|
+
};
|
|
3173
|
+
});
|
|
3174
|
+
return {
|
|
3175
|
+
calls: params.map((it) => it.call),
|
|
3176
|
+
addresses: params.map((it) => it.address)
|
|
3177
|
+
};
|
|
3178
|
+
}
|
|
3143
3179
|
function getVersionsByType(versionType) {
|
|
3144
3180
|
return versionType === "fee" ? {
|
|
3145
3181
|
v1: "0x100000000000000000000000000000001" /* F1 */,
|
|
@@ -3181,6 +3217,9 @@ var RpcChannel = class {
|
|
|
3181
3217
|
this.waitMode = waitMode || false;
|
|
3182
3218
|
this.requestId = 0;
|
|
3183
3219
|
}
|
|
3220
|
+
setChainId(chainId) {
|
|
3221
|
+
this.chainId = chainId;
|
|
3222
|
+
}
|
|
3184
3223
|
fetch(method, params, id = 0) {
|
|
3185
3224
|
const rpcRequestBody = {
|
|
3186
3225
|
id,
|
|
@@ -3711,6 +3750,9 @@ var RpcChannel2 = class {
|
|
|
3711
3750
|
this.waitMode = waitMode || false;
|
|
3712
3751
|
this.requestId = 0;
|
|
3713
3752
|
}
|
|
3753
|
+
setChainId(chainId) {
|
|
3754
|
+
this.chainId = chainId;
|
|
3755
|
+
}
|
|
3714
3756
|
fetch(method, params, id = 0) {
|
|
3715
3757
|
const rpcRequestBody = {
|
|
3716
3758
|
id,
|
|
@@ -5806,37 +5848,7 @@ var Account = class extends RpcProvider2 {
|
|
|
5806
5848
|
return this.declareContract(declareContractTransaction, declareDetails);
|
|
5807
5849
|
}
|
|
5808
5850
|
async deploy(payload, details = {}) {
|
|
5809
|
-
const
|
|
5810
|
-
const {
|
|
5811
|
-
classHash,
|
|
5812
|
-
salt,
|
|
5813
|
-
unique = true,
|
|
5814
|
-
constructorCalldata = []
|
|
5815
|
-
} = it;
|
|
5816
|
-
const compiledConstructorCallData = CallData.compile(constructorCalldata);
|
|
5817
|
-
const deploySalt = salt ?? randomAddress();
|
|
5818
|
-
return {
|
|
5819
|
-
call: {
|
|
5820
|
-
contractAddress: UDC.ADDRESS,
|
|
5821
|
-
entrypoint: UDC.ENTRYPOINT,
|
|
5822
|
-
calldata: [
|
|
5823
|
-
classHash,
|
|
5824
|
-
deploySalt,
|
|
5825
|
-
toCairoBool(unique),
|
|
5826
|
-
compiledConstructorCallData.length,
|
|
5827
|
-
...compiledConstructorCallData
|
|
5828
|
-
]
|
|
5829
|
-
},
|
|
5830
|
-
address: calculateContractAddressFromHash(
|
|
5831
|
-
unique ? starkCurve.pedersen(this.address, deploySalt) : deploySalt,
|
|
5832
|
-
classHash,
|
|
5833
|
-
compiledConstructorCallData,
|
|
5834
|
-
unique ? UDC.ADDRESS : 0
|
|
5835
|
-
)
|
|
5836
|
-
};
|
|
5837
|
-
});
|
|
5838
|
-
const calls = params.map((it) => it.call);
|
|
5839
|
-
const addresses = params.map((it) => it.address);
|
|
5851
|
+
const { calls, addresses } = buildUDCCall(payload, this.address);
|
|
5840
5852
|
const invokeResponse = await this.execute(calls, void 0, details);
|
|
5841
5853
|
return {
|
|
5842
5854
|
...invokeResponse,
|
|
@@ -6151,6 +6163,186 @@ var Account = class extends RpcProvider2 {
|
|
|
6151
6163
|
var AccountInterface = class extends ProviderInterface {
|
|
6152
6164
|
};
|
|
6153
6165
|
|
|
6166
|
+
// src/wallet/connect.ts
|
|
6167
|
+
function requestAccounts(swo, silentMode = false) {
|
|
6168
|
+
return swo.request({
|
|
6169
|
+
type: "wallet_requestAccounts",
|
|
6170
|
+
params: {
|
|
6171
|
+
silentMode
|
|
6172
|
+
}
|
|
6173
|
+
});
|
|
6174
|
+
}
|
|
6175
|
+
function getPermissions(swo) {
|
|
6176
|
+
return swo.request({ type: "wallet_getPermissions" });
|
|
6177
|
+
}
|
|
6178
|
+
function watchAsset(swo, asset) {
|
|
6179
|
+
return swo.request({
|
|
6180
|
+
type: "wallet_watchAsset",
|
|
6181
|
+
params: asset
|
|
6182
|
+
});
|
|
6183
|
+
}
|
|
6184
|
+
function addStarknetChain(swo, chain) {
|
|
6185
|
+
return swo.request({
|
|
6186
|
+
type: "wallet_addStarknetChain",
|
|
6187
|
+
params: chain
|
|
6188
|
+
});
|
|
6189
|
+
}
|
|
6190
|
+
function switchStarknetChain(swo, chainId) {
|
|
6191
|
+
return swo.request({
|
|
6192
|
+
type: "wallet_switchStarknetChain",
|
|
6193
|
+
params: {
|
|
6194
|
+
chainId
|
|
6195
|
+
}
|
|
6196
|
+
});
|
|
6197
|
+
}
|
|
6198
|
+
function requestChainId(swo) {
|
|
6199
|
+
return swo.request({ type: "wallet_requestChainId" });
|
|
6200
|
+
}
|
|
6201
|
+
function deploymentData(swo) {
|
|
6202
|
+
return swo.request({ type: "wallet_deploymentData" });
|
|
6203
|
+
}
|
|
6204
|
+
function addInvokeTransaction(swo, params) {
|
|
6205
|
+
return swo.request({
|
|
6206
|
+
type: "starknet_addInvokeTransaction",
|
|
6207
|
+
params
|
|
6208
|
+
});
|
|
6209
|
+
}
|
|
6210
|
+
function addDeclareTransaction(swo, params) {
|
|
6211
|
+
return swo.request({
|
|
6212
|
+
type: "starknet_addDeclareTransaction",
|
|
6213
|
+
params
|
|
6214
|
+
});
|
|
6215
|
+
}
|
|
6216
|
+
function addDeployAccountTransaction(swo, params) {
|
|
6217
|
+
return swo.request({
|
|
6218
|
+
type: "starknet_addDeployAccountTransaction",
|
|
6219
|
+
params
|
|
6220
|
+
});
|
|
6221
|
+
}
|
|
6222
|
+
function signMessage(swo, typedData) {
|
|
6223
|
+
return swo.request({
|
|
6224
|
+
type: "starknet_signTypedData",
|
|
6225
|
+
params: typedData
|
|
6226
|
+
});
|
|
6227
|
+
}
|
|
6228
|
+
function supportedSpecs(swo) {
|
|
6229
|
+
return swo.request({ type: "starknet_supportedSpecs" });
|
|
6230
|
+
}
|
|
6231
|
+
function onAccountChange(swo, callback) {
|
|
6232
|
+
swo.on("accountsChanged", callback);
|
|
6233
|
+
}
|
|
6234
|
+
function onNetworkChanged(swo, callback) {
|
|
6235
|
+
swo.on("networkChanged", callback);
|
|
6236
|
+
}
|
|
6237
|
+
|
|
6238
|
+
// src/wallet/account.ts
|
|
6239
|
+
var WalletAccount = class extends Account {
|
|
6240
|
+
address = "";
|
|
6241
|
+
walletProvider;
|
|
6242
|
+
constructor(providerOrOptions, walletProvider, cairoVersion) {
|
|
6243
|
+
super(providerOrOptions, "", "", cairoVersion);
|
|
6244
|
+
this.walletProvider = walletProvider;
|
|
6245
|
+
this.walletProvider.on("accountsChanged", (res) => {
|
|
6246
|
+
if (!res)
|
|
6247
|
+
return;
|
|
6248
|
+
this.address = res[0].toLowerCase();
|
|
6249
|
+
});
|
|
6250
|
+
this.walletProvider.on("networkChanged", (res) => {
|
|
6251
|
+
if (!res)
|
|
6252
|
+
return;
|
|
6253
|
+
this.channel.setChainId(res);
|
|
6254
|
+
});
|
|
6255
|
+
walletProvider.request({
|
|
6256
|
+
type: "wallet_requestAccounts",
|
|
6257
|
+
params: {
|
|
6258
|
+
silentMode: false
|
|
6259
|
+
}
|
|
6260
|
+
}).then((res) => {
|
|
6261
|
+
this.address = res[0].toLowerCase();
|
|
6262
|
+
});
|
|
6263
|
+
}
|
|
6264
|
+
/**
|
|
6265
|
+
* WALLET EVENTS
|
|
6266
|
+
*/
|
|
6267
|
+
onAccountChange(callback) {
|
|
6268
|
+
onAccountChange(this.walletProvider, callback);
|
|
6269
|
+
}
|
|
6270
|
+
onNetworkChanged(callback) {
|
|
6271
|
+
onNetworkChanged(this.walletProvider, callback);
|
|
6272
|
+
}
|
|
6273
|
+
/**
|
|
6274
|
+
* WALLET SPECIFIC METHODS
|
|
6275
|
+
*/
|
|
6276
|
+
requestAccounts(silentMode = false) {
|
|
6277
|
+
return requestAccounts(this.walletProvider, silentMode);
|
|
6278
|
+
}
|
|
6279
|
+
getPermissions() {
|
|
6280
|
+
return getPermissions(this.walletProvider);
|
|
6281
|
+
}
|
|
6282
|
+
switchStarknetChain(chainId) {
|
|
6283
|
+
return switchStarknetChain(this.walletProvider, chainId);
|
|
6284
|
+
}
|
|
6285
|
+
watchAsset(asset) {
|
|
6286
|
+
return watchAsset(this.walletProvider, asset);
|
|
6287
|
+
}
|
|
6288
|
+
addStarknetChain(chain) {
|
|
6289
|
+
return addStarknetChain(this.walletProvider, chain);
|
|
6290
|
+
}
|
|
6291
|
+
/**
|
|
6292
|
+
* ACCOUNT METHODS
|
|
6293
|
+
*/
|
|
6294
|
+
execute(calls) {
|
|
6295
|
+
const txCalls = [].concat(calls).map((it) => {
|
|
6296
|
+
const { contractAddress, entrypoint, calldata } = it;
|
|
6297
|
+
return {
|
|
6298
|
+
contract_address: contractAddress,
|
|
6299
|
+
entrypoint,
|
|
6300
|
+
calldata
|
|
6301
|
+
};
|
|
6302
|
+
});
|
|
6303
|
+
const params = {
|
|
6304
|
+
calls: txCalls
|
|
6305
|
+
};
|
|
6306
|
+
return addInvokeTransaction(this.walletProvider, params);
|
|
6307
|
+
}
|
|
6308
|
+
declare(payload) {
|
|
6309
|
+
const declareContractPayload = extractContractHashes(payload);
|
|
6310
|
+
const pContract = payload.contract;
|
|
6311
|
+
const cairo1Contract = {
|
|
6312
|
+
...pContract,
|
|
6313
|
+
abi: stringify2(pContract.abi)
|
|
6314
|
+
};
|
|
6315
|
+
if (!declareContractPayload.compiledClassHash) {
|
|
6316
|
+
throw Error("compiledClassHash is required");
|
|
6317
|
+
}
|
|
6318
|
+
const params = {
|
|
6319
|
+
compiled_class_hash: declareContractPayload.compiledClassHash,
|
|
6320
|
+
contract_class: cairo1Contract
|
|
6321
|
+
};
|
|
6322
|
+
return addDeclareTransaction(this.walletProvider, params);
|
|
6323
|
+
}
|
|
6324
|
+
async deploy(payload) {
|
|
6325
|
+
const { calls, addresses } = buildUDCCall(payload, this.address);
|
|
6326
|
+
const invokeResponse = await this.execute(calls);
|
|
6327
|
+
return {
|
|
6328
|
+
...invokeResponse,
|
|
6329
|
+
contract_address: addresses
|
|
6330
|
+
};
|
|
6331
|
+
}
|
|
6332
|
+
deployAccount(payload) {
|
|
6333
|
+
const params = {
|
|
6334
|
+
contract_address_salt: payload.addressSalt?.toString() || "0",
|
|
6335
|
+
constructor_calldata: payload.constructorCalldata ? CallData.compile(payload.constructorCalldata) : [],
|
|
6336
|
+
class_hash: payload.classHash
|
|
6337
|
+
};
|
|
6338
|
+
return addDeployAccountTransaction(this.walletProvider, params);
|
|
6339
|
+
}
|
|
6340
|
+
signMessage(typedData) {
|
|
6341
|
+
return signMessage(this.walletProvider, typedData);
|
|
6342
|
+
}
|
|
6343
|
+
// TODO: MISSING ESTIMATES
|
|
6344
|
+
};
|
|
6345
|
+
|
|
6154
6346
|
// src/utils/events/index.ts
|
|
6155
6347
|
var events_exports = {};
|
|
6156
6348
|
__export(events_exports, {
|
|
@@ -6661,13 +6853,19 @@ export {
|
|
|
6661
6853
|
TypedDataRevision,
|
|
6662
6854
|
Uint,
|
|
6663
6855
|
ValidateType,
|
|
6856
|
+
WalletAccount,
|
|
6664
6857
|
addAddressPadding,
|
|
6858
|
+
addDeclareTransaction,
|
|
6859
|
+
addDeployAccountTransaction,
|
|
6860
|
+
addInvokeTransaction,
|
|
6861
|
+
addStarknetChain,
|
|
6665
6862
|
buildUrl,
|
|
6666
6863
|
byteArray_exports as byteArray,
|
|
6667
6864
|
cairo_exports as cairo,
|
|
6668
6865
|
constants_exports as constants,
|
|
6669
6866
|
contractClassResponseToLegacyCompiledContract,
|
|
6670
6867
|
defaultProvider,
|
|
6868
|
+
deploymentData,
|
|
6671
6869
|
ec_exports as ec,
|
|
6672
6870
|
encode_exports as encode,
|
|
6673
6871
|
eth_exports as eth,
|
|
@@ -6677,6 +6875,7 @@ export {
|
|
|
6677
6875
|
fixStack,
|
|
6678
6876
|
getCalldata,
|
|
6679
6877
|
getChecksumAddress,
|
|
6878
|
+
getPermissions,
|
|
6680
6879
|
hash_exports as hash,
|
|
6681
6880
|
isSierra,
|
|
6682
6881
|
isUrl,
|
|
@@ -6684,13 +6883,20 @@ export {
|
|
|
6684
6883
|
merkle_exports as merkle,
|
|
6685
6884
|
num_exports as num,
|
|
6686
6885
|
number,
|
|
6886
|
+
onAccountChange,
|
|
6887
|
+
onNetworkChanged,
|
|
6687
6888
|
parseUDCEvent,
|
|
6688
6889
|
provider_exports as provider,
|
|
6890
|
+
requestAccounts,
|
|
6891
|
+
requestChainId,
|
|
6689
6892
|
selector_exports as selector,
|
|
6690
6893
|
shortString_exports as shortString,
|
|
6894
|
+
signMessage,
|
|
6691
6895
|
splitArgsAndOptions,
|
|
6692
6896
|
stark_exports as stark,
|
|
6693
6897
|
starknetId_exports as starknetId,
|
|
6898
|
+
supportedSpecs,
|
|
6899
|
+
switchStarknetChain,
|
|
6694
6900
|
transaction_exports as transaction,
|
|
6695
6901
|
typedData_exports as typedData,
|
|
6696
6902
|
types_exports as types,
|
|
@@ -6698,6 +6904,7 @@ export {
|
|
|
6698
6904
|
v2_exports as v2hash,
|
|
6699
6905
|
v3_exports as v3hash,
|
|
6700
6906
|
validateAndParseAddress,
|
|
6701
|
-
validateChecksumAddress
|
|
6907
|
+
validateChecksumAddress,
|
|
6908
|
+
watchAsset
|
|
6702
6909
|
};
|
|
6703
6910
|
//# sourceMappingURL=index.mjs.map
|