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.global.js
CHANGED
|
@@ -12709,13 +12709,19 @@ var starknet = (() => {
|
|
|
12709
12709
|
TypedDataRevision: () => TypedDataRevision,
|
|
12710
12710
|
Uint: () => Uint,
|
|
12711
12711
|
ValidateType: () => ValidateType,
|
|
12712
|
+
WalletAccount: () => WalletAccount,
|
|
12712
12713
|
addAddressPadding: () => addAddressPadding,
|
|
12714
|
+
addDeclareTransaction: () => addDeclareTransaction,
|
|
12715
|
+
addDeployAccountTransaction: () => addDeployAccountTransaction,
|
|
12716
|
+
addInvokeTransaction: () => addInvokeTransaction,
|
|
12717
|
+
addStarknetChain: () => addStarknetChain,
|
|
12713
12718
|
buildUrl: () => buildUrl,
|
|
12714
12719
|
byteArray: () => byteArray_exports,
|
|
12715
12720
|
cairo: () => cairo_exports,
|
|
12716
12721
|
constants: () => constants_exports,
|
|
12717
12722
|
contractClassResponseToLegacyCompiledContract: () => contractClassResponseToLegacyCompiledContract,
|
|
12718
12723
|
defaultProvider: () => defaultProvider,
|
|
12724
|
+
deploymentData: () => deploymentData,
|
|
12719
12725
|
ec: () => ec_exports,
|
|
12720
12726
|
encode: () => encode_exports,
|
|
12721
12727
|
eth: () => eth_exports,
|
|
@@ -12725,6 +12731,7 @@ var starknet = (() => {
|
|
|
12725
12731
|
fixStack: () => fixStack,
|
|
12726
12732
|
getCalldata: () => getCalldata,
|
|
12727
12733
|
getChecksumAddress: () => getChecksumAddress,
|
|
12734
|
+
getPermissions: () => getPermissions,
|
|
12728
12735
|
hash: () => hash_exports,
|
|
12729
12736
|
isSierra: () => isSierra,
|
|
12730
12737
|
isUrl: () => isUrl,
|
|
@@ -12732,13 +12739,20 @@ var starknet = (() => {
|
|
|
12732
12739
|
merkle: () => merkle_exports,
|
|
12733
12740
|
num: () => num_exports,
|
|
12734
12741
|
number: () => number2,
|
|
12742
|
+
onAccountChange: () => onAccountChange,
|
|
12743
|
+
onNetworkChanged: () => onNetworkChanged,
|
|
12735
12744
|
parseUDCEvent: () => parseUDCEvent,
|
|
12736
12745
|
provider: () => provider_exports,
|
|
12746
|
+
requestAccounts: () => requestAccounts,
|
|
12747
|
+
requestChainId: () => requestChainId,
|
|
12737
12748
|
selector: () => selector_exports,
|
|
12738
12749
|
shortString: () => shortString_exports,
|
|
12750
|
+
signMessage: () => signMessage,
|
|
12739
12751
|
splitArgsAndOptions: () => splitArgsAndOptions,
|
|
12740
12752
|
stark: () => stark_exports,
|
|
12741
12753
|
starknetId: () => starknetId_exports,
|
|
12754
|
+
supportedSpecs: () => supportedSpecs,
|
|
12755
|
+
switchStarknetChain: () => switchStarknetChain,
|
|
12742
12756
|
transaction: () => transaction_exports,
|
|
12743
12757
|
typedData: () => typedData_exports,
|
|
12744
12758
|
types: () => types_exports,
|
|
@@ -12746,7 +12760,8 @@ var starknet = (() => {
|
|
|
12746
12760
|
v2hash: () => v2_exports,
|
|
12747
12761
|
v3hash: () => v3_exports,
|
|
12748
12762
|
validateAndParseAddress: () => validateAndParseAddress,
|
|
12749
|
-
validateChecksumAddress: () => validateChecksumAddress
|
|
12763
|
+
validateChecksumAddress: () => validateChecksumAddress,
|
|
12764
|
+
watchAsset: () => watchAsset
|
|
12750
12765
|
});
|
|
12751
12766
|
|
|
12752
12767
|
// src/constants.ts
|
|
@@ -13262,7 +13277,7 @@ var starknet = (() => {
|
|
|
13262
13277
|
ADDRESS: "0x041a78e741e5af2fec34b695679bc6891742439f7afb8484ecd7766661ad02bf",
|
|
13263
13278
|
ENTRYPOINT: "deployContract"
|
|
13264
13279
|
};
|
|
13265
|
-
var RPC_DEFAULT_VERSION = "
|
|
13280
|
+
var RPC_DEFAULT_VERSION = "v0_7";
|
|
13266
13281
|
var RPC_NODES = {
|
|
13267
13282
|
SN_GOERLI: [
|
|
13268
13283
|
`https://starknet-testnet.public.blastapi.io/rpc/${RPC_DEFAULT_VERSION}`,
|
|
@@ -23402,6 +23417,7 @@ var starknet = (() => {
|
|
|
23402
23417
|
// src/utils/transaction.ts
|
|
23403
23418
|
var transaction_exports = {};
|
|
23404
23419
|
__export(transaction_exports, {
|
|
23420
|
+
buildUDCCall: () => buildUDCCall,
|
|
23405
23421
|
fromCallsToExecuteCalldata: () => fromCallsToExecuteCalldata,
|
|
23406
23422
|
fromCallsToExecuteCalldataWithNonce: () => fromCallsToExecuteCalldataWithNonce,
|
|
23407
23423
|
fromCallsToExecuteCalldata_cairo1: () => fromCallsToExecuteCalldata_cairo1,
|
|
@@ -23459,6 +23475,41 @@ var starknet = (() => {
|
|
|
23459
23475
|
}
|
|
23460
23476
|
return fromCallsToExecuteCalldata(calls);
|
|
23461
23477
|
};
|
|
23478
|
+
function buildUDCCall(payload, address) {
|
|
23479
|
+
const params = [].concat(payload).map((it) => {
|
|
23480
|
+
const {
|
|
23481
|
+
classHash,
|
|
23482
|
+
salt,
|
|
23483
|
+
unique: unique2 = true,
|
|
23484
|
+
constructorCalldata = []
|
|
23485
|
+
} = it;
|
|
23486
|
+
const compiledConstructorCallData = CallData.compile(constructorCalldata);
|
|
23487
|
+
const deploySalt = salt ?? randomAddress();
|
|
23488
|
+
return {
|
|
23489
|
+
call: {
|
|
23490
|
+
contractAddress: UDC.ADDRESS,
|
|
23491
|
+
entrypoint: UDC.ENTRYPOINT,
|
|
23492
|
+
calldata: [
|
|
23493
|
+
classHash,
|
|
23494
|
+
deploySalt,
|
|
23495
|
+
toCairoBool(unique2),
|
|
23496
|
+
compiledConstructorCallData.length,
|
|
23497
|
+
...compiledConstructorCallData
|
|
23498
|
+
]
|
|
23499
|
+
},
|
|
23500
|
+
address: calculateContractAddressFromHash(
|
|
23501
|
+
unique2 ? esm_exports.pedersen(address, deploySalt) : deploySalt,
|
|
23502
|
+
classHash,
|
|
23503
|
+
compiledConstructorCallData,
|
|
23504
|
+
unique2 ? UDC.ADDRESS : 0
|
|
23505
|
+
)
|
|
23506
|
+
};
|
|
23507
|
+
});
|
|
23508
|
+
return {
|
|
23509
|
+
calls: params.map((it) => it.call),
|
|
23510
|
+
addresses: params.map((it) => it.address)
|
|
23511
|
+
};
|
|
23512
|
+
}
|
|
23462
23513
|
function getVersionsByType(versionType) {
|
|
23463
23514
|
return versionType === "fee" ? {
|
|
23464
23515
|
v1: "0x100000000000000000000000000000001" /* F1 */,
|
|
@@ -23500,6 +23551,9 @@ var starknet = (() => {
|
|
|
23500
23551
|
this.waitMode = waitMode || false;
|
|
23501
23552
|
this.requestId = 0;
|
|
23502
23553
|
}
|
|
23554
|
+
setChainId(chainId) {
|
|
23555
|
+
this.chainId = chainId;
|
|
23556
|
+
}
|
|
23503
23557
|
fetch(method, params, id = 0) {
|
|
23504
23558
|
const rpcRequestBody = {
|
|
23505
23559
|
id,
|
|
@@ -24030,6 +24084,9 @@ var starknet = (() => {
|
|
|
24030
24084
|
this.waitMode = waitMode || false;
|
|
24031
24085
|
this.requestId = 0;
|
|
24032
24086
|
}
|
|
24087
|
+
setChainId(chainId) {
|
|
24088
|
+
this.chainId = chainId;
|
|
24089
|
+
}
|
|
24033
24090
|
fetch(method, params, id = 0) {
|
|
24034
24091
|
const rpcRequestBody = {
|
|
24035
24092
|
id,
|
|
@@ -26422,37 +26479,7 @@ var starknet = (() => {
|
|
|
26422
26479
|
return this.declareContract(declareContractTransaction, declareDetails);
|
|
26423
26480
|
}
|
|
26424
26481
|
async deploy(payload, details = {}) {
|
|
26425
|
-
const
|
|
26426
|
-
const {
|
|
26427
|
-
classHash,
|
|
26428
|
-
salt,
|
|
26429
|
-
unique: unique2 = true,
|
|
26430
|
-
constructorCalldata = []
|
|
26431
|
-
} = it;
|
|
26432
|
-
const compiledConstructorCallData = CallData.compile(constructorCalldata);
|
|
26433
|
-
const deploySalt = salt ?? randomAddress();
|
|
26434
|
-
return {
|
|
26435
|
-
call: {
|
|
26436
|
-
contractAddress: UDC.ADDRESS,
|
|
26437
|
-
entrypoint: UDC.ENTRYPOINT,
|
|
26438
|
-
calldata: [
|
|
26439
|
-
classHash,
|
|
26440
|
-
deploySalt,
|
|
26441
|
-
toCairoBool(unique2),
|
|
26442
|
-
compiledConstructorCallData.length,
|
|
26443
|
-
...compiledConstructorCallData
|
|
26444
|
-
]
|
|
26445
|
-
},
|
|
26446
|
-
address: calculateContractAddressFromHash(
|
|
26447
|
-
unique2 ? esm_exports.pedersen(this.address, deploySalt) : deploySalt,
|
|
26448
|
-
classHash,
|
|
26449
|
-
compiledConstructorCallData,
|
|
26450
|
-
unique2 ? UDC.ADDRESS : 0
|
|
26451
|
-
)
|
|
26452
|
-
};
|
|
26453
|
-
});
|
|
26454
|
-
const calls = params.map((it) => it.call);
|
|
26455
|
-
const addresses = params.map((it) => it.address);
|
|
26482
|
+
const { calls, addresses } = buildUDCCall(payload, this.address);
|
|
26456
26483
|
const invokeResponse = await this.execute(calls, void 0, details);
|
|
26457
26484
|
return {
|
|
26458
26485
|
...invokeResponse,
|
|
@@ -26767,6 +26794,186 @@ var starknet = (() => {
|
|
|
26767
26794
|
var AccountInterface = class extends ProviderInterface {
|
|
26768
26795
|
};
|
|
26769
26796
|
|
|
26797
|
+
// src/wallet/connect.ts
|
|
26798
|
+
function requestAccounts(swo, silentMode = false) {
|
|
26799
|
+
return swo.request({
|
|
26800
|
+
type: "wallet_requestAccounts",
|
|
26801
|
+
params: {
|
|
26802
|
+
silentMode
|
|
26803
|
+
}
|
|
26804
|
+
});
|
|
26805
|
+
}
|
|
26806
|
+
function getPermissions(swo) {
|
|
26807
|
+
return swo.request({ type: "wallet_getPermissions" });
|
|
26808
|
+
}
|
|
26809
|
+
function watchAsset(swo, asset) {
|
|
26810
|
+
return swo.request({
|
|
26811
|
+
type: "wallet_watchAsset",
|
|
26812
|
+
params: asset
|
|
26813
|
+
});
|
|
26814
|
+
}
|
|
26815
|
+
function addStarknetChain(swo, chain2) {
|
|
26816
|
+
return swo.request({
|
|
26817
|
+
type: "wallet_addStarknetChain",
|
|
26818
|
+
params: chain2
|
|
26819
|
+
});
|
|
26820
|
+
}
|
|
26821
|
+
function switchStarknetChain(swo, chainId) {
|
|
26822
|
+
return swo.request({
|
|
26823
|
+
type: "wallet_switchStarknetChain",
|
|
26824
|
+
params: {
|
|
26825
|
+
chainId
|
|
26826
|
+
}
|
|
26827
|
+
});
|
|
26828
|
+
}
|
|
26829
|
+
function requestChainId(swo) {
|
|
26830
|
+
return swo.request({ type: "wallet_requestChainId" });
|
|
26831
|
+
}
|
|
26832
|
+
function deploymentData(swo) {
|
|
26833
|
+
return swo.request({ type: "wallet_deploymentData" });
|
|
26834
|
+
}
|
|
26835
|
+
function addInvokeTransaction(swo, params) {
|
|
26836
|
+
return swo.request({
|
|
26837
|
+
type: "starknet_addInvokeTransaction",
|
|
26838
|
+
params
|
|
26839
|
+
});
|
|
26840
|
+
}
|
|
26841
|
+
function addDeclareTransaction(swo, params) {
|
|
26842
|
+
return swo.request({
|
|
26843
|
+
type: "starknet_addDeclareTransaction",
|
|
26844
|
+
params
|
|
26845
|
+
});
|
|
26846
|
+
}
|
|
26847
|
+
function addDeployAccountTransaction(swo, params) {
|
|
26848
|
+
return swo.request({
|
|
26849
|
+
type: "starknet_addDeployAccountTransaction",
|
|
26850
|
+
params
|
|
26851
|
+
});
|
|
26852
|
+
}
|
|
26853
|
+
function signMessage(swo, typedData) {
|
|
26854
|
+
return swo.request({
|
|
26855
|
+
type: "starknet_signTypedData",
|
|
26856
|
+
params: typedData
|
|
26857
|
+
});
|
|
26858
|
+
}
|
|
26859
|
+
function supportedSpecs(swo) {
|
|
26860
|
+
return swo.request({ type: "starknet_supportedSpecs" });
|
|
26861
|
+
}
|
|
26862
|
+
function onAccountChange(swo, callback) {
|
|
26863
|
+
swo.on("accountsChanged", callback);
|
|
26864
|
+
}
|
|
26865
|
+
function onNetworkChanged(swo, callback) {
|
|
26866
|
+
swo.on("networkChanged", callback);
|
|
26867
|
+
}
|
|
26868
|
+
|
|
26869
|
+
// src/wallet/account.ts
|
|
26870
|
+
var WalletAccount = class extends Account {
|
|
26871
|
+
address = "";
|
|
26872
|
+
walletProvider;
|
|
26873
|
+
constructor(providerOrOptions, walletProvider, cairoVersion) {
|
|
26874
|
+
super(providerOrOptions, "", "", cairoVersion);
|
|
26875
|
+
this.walletProvider = walletProvider;
|
|
26876
|
+
this.walletProvider.on("accountsChanged", (res) => {
|
|
26877
|
+
if (!res)
|
|
26878
|
+
return;
|
|
26879
|
+
this.address = res[0].toLowerCase();
|
|
26880
|
+
});
|
|
26881
|
+
this.walletProvider.on("networkChanged", (res) => {
|
|
26882
|
+
if (!res)
|
|
26883
|
+
return;
|
|
26884
|
+
this.channel.setChainId(res);
|
|
26885
|
+
});
|
|
26886
|
+
walletProvider.request({
|
|
26887
|
+
type: "wallet_requestAccounts",
|
|
26888
|
+
params: {
|
|
26889
|
+
silentMode: false
|
|
26890
|
+
}
|
|
26891
|
+
}).then((res) => {
|
|
26892
|
+
this.address = res[0].toLowerCase();
|
|
26893
|
+
});
|
|
26894
|
+
}
|
|
26895
|
+
/**
|
|
26896
|
+
* WALLET EVENTS
|
|
26897
|
+
*/
|
|
26898
|
+
onAccountChange(callback) {
|
|
26899
|
+
onAccountChange(this.walletProvider, callback);
|
|
26900
|
+
}
|
|
26901
|
+
onNetworkChanged(callback) {
|
|
26902
|
+
onNetworkChanged(this.walletProvider, callback);
|
|
26903
|
+
}
|
|
26904
|
+
/**
|
|
26905
|
+
* WALLET SPECIFIC METHODS
|
|
26906
|
+
*/
|
|
26907
|
+
requestAccounts(silentMode = false) {
|
|
26908
|
+
return requestAccounts(this.walletProvider, silentMode);
|
|
26909
|
+
}
|
|
26910
|
+
getPermissions() {
|
|
26911
|
+
return getPermissions(this.walletProvider);
|
|
26912
|
+
}
|
|
26913
|
+
switchStarknetChain(chainId) {
|
|
26914
|
+
return switchStarknetChain(this.walletProvider, chainId);
|
|
26915
|
+
}
|
|
26916
|
+
watchAsset(asset) {
|
|
26917
|
+
return watchAsset(this.walletProvider, asset);
|
|
26918
|
+
}
|
|
26919
|
+
addStarknetChain(chain2) {
|
|
26920
|
+
return addStarknetChain(this.walletProvider, chain2);
|
|
26921
|
+
}
|
|
26922
|
+
/**
|
|
26923
|
+
* ACCOUNT METHODS
|
|
26924
|
+
*/
|
|
26925
|
+
execute(calls) {
|
|
26926
|
+
const txCalls = [].concat(calls).map((it) => {
|
|
26927
|
+
const { contractAddress, entrypoint, calldata } = it;
|
|
26928
|
+
return {
|
|
26929
|
+
contract_address: contractAddress,
|
|
26930
|
+
entrypoint,
|
|
26931
|
+
calldata
|
|
26932
|
+
};
|
|
26933
|
+
});
|
|
26934
|
+
const params = {
|
|
26935
|
+
calls: txCalls
|
|
26936
|
+
};
|
|
26937
|
+
return addInvokeTransaction(this.walletProvider, params);
|
|
26938
|
+
}
|
|
26939
|
+
declare(payload) {
|
|
26940
|
+
const declareContractPayload = extractContractHashes(payload);
|
|
26941
|
+
const pContract = payload.contract;
|
|
26942
|
+
const cairo1Contract = {
|
|
26943
|
+
...pContract,
|
|
26944
|
+
abi: stringify2(pContract.abi)
|
|
26945
|
+
};
|
|
26946
|
+
if (!declareContractPayload.compiledClassHash) {
|
|
26947
|
+
throw Error("compiledClassHash is required");
|
|
26948
|
+
}
|
|
26949
|
+
const params = {
|
|
26950
|
+
compiled_class_hash: declareContractPayload.compiledClassHash,
|
|
26951
|
+
contract_class: cairo1Contract
|
|
26952
|
+
};
|
|
26953
|
+
return addDeclareTransaction(this.walletProvider, params);
|
|
26954
|
+
}
|
|
26955
|
+
async deploy(payload) {
|
|
26956
|
+
const { calls, addresses } = buildUDCCall(payload, this.address);
|
|
26957
|
+
const invokeResponse = await this.execute(calls);
|
|
26958
|
+
return {
|
|
26959
|
+
...invokeResponse,
|
|
26960
|
+
contract_address: addresses
|
|
26961
|
+
};
|
|
26962
|
+
}
|
|
26963
|
+
deployAccount(payload) {
|
|
26964
|
+
const params = {
|
|
26965
|
+
contract_address_salt: payload.addressSalt?.toString() || "0",
|
|
26966
|
+
constructor_calldata: payload.constructorCalldata ? CallData.compile(payload.constructorCalldata) : [],
|
|
26967
|
+
class_hash: payload.classHash
|
|
26968
|
+
};
|
|
26969
|
+
return addDeployAccountTransaction(this.walletProvider, params);
|
|
26970
|
+
}
|
|
26971
|
+
signMessage(typedData) {
|
|
26972
|
+
return signMessage(this.walletProvider, typedData);
|
|
26973
|
+
}
|
|
26974
|
+
// TODO: MISSING ESTIMATES
|
|
26975
|
+
};
|
|
26976
|
+
|
|
26770
26977
|
// src/utils/events/index.ts
|
|
26771
26978
|
var events_exports = {};
|
|
26772
26979
|
__export(events_exports, {
|