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.js
CHANGED
|
@@ -67,13 +67,19 @@ __export(src_exports, {
|
|
|
67
67
|
TypedDataRevision: () => TypedDataRevision,
|
|
68
68
|
Uint: () => Uint,
|
|
69
69
|
ValidateType: () => ValidateType,
|
|
70
|
+
WalletAccount: () => WalletAccount,
|
|
70
71
|
addAddressPadding: () => addAddressPadding,
|
|
72
|
+
addDeclareTransaction: () => addDeclareTransaction,
|
|
73
|
+
addDeployAccountTransaction: () => addDeployAccountTransaction,
|
|
74
|
+
addInvokeTransaction: () => addInvokeTransaction,
|
|
75
|
+
addStarknetChain: () => addStarknetChain,
|
|
71
76
|
buildUrl: () => buildUrl,
|
|
72
77
|
byteArray: () => byteArray_exports,
|
|
73
78
|
cairo: () => cairo_exports,
|
|
74
79
|
constants: () => constants_exports,
|
|
75
80
|
contractClassResponseToLegacyCompiledContract: () => contractClassResponseToLegacyCompiledContract,
|
|
76
81
|
defaultProvider: () => defaultProvider,
|
|
82
|
+
deploymentData: () => deploymentData,
|
|
77
83
|
ec: () => ec_exports,
|
|
78
84
|
encode: () => encode_exports,
|
|
79
85
|
eth: () => eth_exports,
|
|
@@ -83,6 +89,7 @@ __export(src_exports, {
|
|
|
83
89
|
fixStack: () => fixStack,
|
|
84
90
|
getCalldata: () => getCalldata,
|
|
85
91
|
getChecksumAddress: () => getChecksumAddress,
|
|
92
|
+
getPermissions: () => getPermissions,
|
|
86
93
|
hash: () => hash_exports,
|
|
87
94
|
isSierra: () => isSierra,
|
|
88
95
|
isUrl: () => isUrl,
|
|
@@ -90,13 +97,20 @@ __export(src_exports, {
|
|
|
90
97
|
merkle: () => merkle_exports,
|
|
91
98
|
num: () => num_exports,
|
|
92
99
|
number: () => number,
|
|
100
|
+
onAccountChange: () => onAccountChange,
|
|
101
|
+
onNetworkChanged: () => onNetworkChanged,
|
|
93
102
|
parseUDCEvent: () => parseUDCEvent,
|
|
94
103
|
provider: () => provider_exports,
|
|
104
|
+
requestAccounts: () => requestAccounts,
|
|
105
|
+
requestChainId: () => requestChainId,
|
|
95
106
|
selector: () => selector_exports,
|
|
96
107
|
shortString: () => shortString_exports,
|
|
108
|
+
signMessage: () => signMessage,
|
|
97
109
|
splitArgsAndOptions: () => splitArgsAndOptions,
|
|
98
110
|
stark: () => stark_exports,
|
|
99
111
|
starknetId: () => starknetId_exports,
|
|
112
|
+
supportedSpecs: () => supportedSpecs,
|
|
113
|
+
switchStarknetChain: () => switchStarknetChain,
|
|
100
114
|
transaction: () => transaction_exports,
|
|
101
115
|
typedData: () => typedData_exports,
|
|
102
116
|
types: () => types_exports,
|
|
@@ -104,7 +118,8 @@ __export(src_exports, {
|
|
|
104
118
|
v2hash: () => v2_exports,
|
|
105
119
|
v3hash: () => v3_exports,
|
|
106
120
|
validateAndParseAddress: () => validateAndParseAddress,
|
|
107
|
-
validateChecksumAddress: () => validateChecksumAddress
|
|
121
|
+
validateChecksumAddress: () => validateChecksumAddress,
|
|
122
|
+
watchAsset: () => watchAsset
|
|
108
123
|
});
|
|
109
124
|
module.exports = __toCommonJS(src_exports);
|
|
110
125
|
|
|
@@ -463,7 +478,7 @@ var UDC = {
|
|
|
463
478
|
ADDRESS: "0x041a78e741e5af2fec34b695679bc6891742439f7afb8484ecd7766661ad02bf",
|
|
464
479
|
ENTRYPOINT: "deployContract"
|
|
465
480
|
};
|
|
466
|
-
var RPC_DEFAULT_VERSION = "
|
|
481
|
+
var RPC_DEFAULT_VERSION = "v0_7";
|
|
467
482
|
var RPC_NODES = {
|
|
468
483
|
SN_GOERLI: [
|
|
469
484
|
`https://starknet-testnet.public.blastapi.io/rpc/${RPC_DEFAULT_VERSION}`,
|
|
@@ -3187,6 +3202,7 @@ function isPendingStateUpdate(response) {
|
|
|
3187
3202
|
// src/utils/transaction.ts
|
|
3188
3203
|
var transaction_exports = {};
|
|
3189
3204
|
__export(transaction_exports, {
|
|
3205
|
+
buildUDCCall: () => buildUDCCall,
|
|
3190
3206
|
fromCallsToExecuteCalldata: () => fromCallsToExecuteCalldata,
|
|
3191
3207
|
fromCallsToExecuteCalldataWithNonce: () => fromCallsToExecuteCalldataWithNonce,
|
|
3192
3208
|
fromCallsToExecuteCalldata_cairo1: () => fromCallsToExecuteCalldata_cairo1,
|
|
@@ -3244,6 +3260,41 @@ var getExecuteCalldata = (calls, cairoVersion = "0") => {
|
|
|
3244
3260
|
}
|
|
3245
3261
|
return fromCallsToExecuteCalldata(calls);
|
|
3246
3262
|
};
|
|
3263
|
+
function buildUDCCall(payload, address) {
|
|
3264
|
+
const params = [].concat(payload).map((it) => {
|
|
3265
|
+
const {
|
|
3266
|
+
classHash,
|
|
3267
|
+
salt,
|
|
3268
|
+
unique = true,
|
|
3269
|
+
constructorCalldata = []
|
|
3270
|
+
} = it;
|
|
3271
|
+
const compiledConstructorCallData = CallData.compile(constructorCalldata);
|
|
3272
|
+
const deploySalt = salt ?? randomAddress();
|
|
3273
|
+
return {
|
|
3274
|
+
call: {
|
|
3275
|
+
contractAddress: UDC.ADDRESS,
|
|
3276
|
+
entrypoint: UDC.ENTRYPOINT,
|
|
3277
|
+
calldata: [
|
|
3278
|
+
classHash,
|
|
3279
|
+
deploySalt,
|
|
3280
|
+
toCairoBool(unique),
|
|
3281
|
+
compiledConstructorCallData.length,
|
|
3282
|
+
...compiledConstructorCallData
|
|
3283
|
+
]
|
|
3284
|
+
},
|
|
3285
|
+
address: calculateContractAddressFromHash(
|
|
3286
|
+
unique ? starkCurve.pedersen(address, deploySalt) : deploySalt,
|
|
3287
|
+
classHash,
|
|
3288
|
+
compiledConstructorCallData,
|
|
3289
|
+
unique ? UDC.ADDRESS : 0
|
|
3290
|
+
)
|
|
3291
|
+
};
|
|
3292
|
+
});
|
|
3293
|
+
return {
|
|
3294
|
+
calls: params.map((it) => it.call),
|
|
3295
|
+
addresses: params.map((it) => it.address)
|
|
3296
|
+
};
|
|
3297
|
+
}
|
|
3247
3298
|
function getVersionsByType(versionType) {
|
|
3248
3299
|
return versionType === "fee" ? {
|
|
3249
3300
|
v1: "0x100000000000000000000000000000001" /* F1 */,
|
|
@@ -3285,6 +3336,9 @@ var RpcChannel = class {
|
|
|
3285
3336
|
this.waitMode = waitMode || false;
|
|
3286
3337
|
this.requestId = 0;
|
|
3287
3338
|
}
|
|
3339
|
+
setChainId(chainId) {
|
|
3340
|
+
this.chainId = chainId;
|
|
3341
|
+
}
|
|
3288
3342
|
fetch(method, params, id = 0) {
|
|
3289
3343
|
const rpcRequestBody = {
|
|
3290
3344
|
id,
|
|
@@ -3815,6 +3869,9 @@ var RpcChannel2 = class {
|
|
|
3815
3869
|
this.waitMode = waitMode || false;
|
|
3816
3870
|
this.requestId = 0;
|
|
3817
3871
|
}
|
|
3872
|
+
setChainId(chainId) {
|
|
3873
|
+
this.chainId = chainId;
|
|
3874
|
+
}
|
|
3818
3875
|
fetch(method, params, id = 0) {
|
|
3819
3876
|
const rpcRequestBody = {
|
|
3820
3877
|
id,
|
|
@@ -5910,37 +5967,7 @@ var Account = class extends RpcProvider2 {
|
|
|
5910
5967
|
return this.declareContract(declareContractTransaction, declareDetails);
|
|
5911
5968
|
}
|
|
5912
5969
|
async deploy(payload, details = {}) {
|
|
5913
|
-
const
|
|
5914
|
-
const {
|
|
5915
|
-
classHash,
|
|
5916
|
-
salt,
|
|
5917
|
-
unique = true,
|
|
5918
|
-
constructorCalldata = []
|
|
5919
|
-
} = it;
|
|
5920
|
-
const compiledConstructorCallData = CallData.compile(constructorCalldata);
|
|
5921
|
-
const deploySalt = salt ?? randomAddress();
|
|
5922
|
-
return {
|
|
5923
|
-
call: {
|
|
5924
|
-
contractAddress: UDC.ADDRESS,
|
|
5925
|
-
entrypoint: UDC.ENTRYPOINT,
|
|
5926
|
-
calldata: [
|
|
5927
|
-
classHash,
|
|
5928
|
-
deploySalt,
|
|
5929
|
-
toCairoBool(unique),
|
|
5930
|
-
compiledConstructorCallData.length,
|
|
5931
|
-
...compiledConstructorCallData
|
|
5932
|
-
]
|
|
5933
|
-
},
|
|
5934
|
-
address: calculateContractAddressFromHash(
|
|
5935
|
-
unique ? starkCurve.pedersen(this.address, deploySalt) : deploySalt,
|
|
5936
|
-
classHash,
|
|
5937
|
-
compiledConstructorCallData,
|
|
5938
|
-
unique ? UDC.ADDRESS : 0
|
|
5939
|
-
)
|
|
5940
|
-
};
|
|
5941
|
-
});
|
|
5942
|
-
const calls = params.map((it) => it.call);
|
|
5943
|
-
const addresses = params.map((it) => it.address);
|
|
5970
|
+
const { calls, addresses } = buildUDCCall(payload, this.address);
|
|
5944
5971
|
const invokeResponse = await this.execute(calls, void 0, details);
|
|
5945
5972
|
return {
|
|
5946
5973
|
...invokeResponse,
|
|
@@ -6255,6 +6282,186 @@ var Account = class extends RpcProvider2 {
|
|
|
6255
6282
|
var AccountInterface = class extends ProviderInterface {
|
|
6256
6283
|
};
|
|
6257
6284
|
|
|
6285
|
+
// src/wallet/connect.ts
|
|
6286
|
+
function requestAccounts(swo, silentMode = false) {
|
|
6287
|
+
return swo.request({
|
|
6288
|
+
type: "wallet_requestAccounts",
|
|
6289
|
+
params: {
|
|
6290
|
+
silentMode
|
|
6291
|
+
}
|
|
6292
|
+
});
|
|
6293
|
+
}
|
|
6294
|
+
function getPermissions(swo) {
|
|
6295
|
+
return swo.request({ type: "wallet_getPermissions" });
|
|
6296
|
+
}
|
|
6297
|
+
function watchAsset(swo, asset) {
|
|
6298
|
+
return swo.request({
|
|
6299
|
+
type: "wallet_watchAsset",
|
|
6300
|
+
params: asset
|
|
6301
|
+
});
|
|
6302
|
+
}
|
|
6303
|
+
function addStarknetChain(swo, chain) {
|
|
6304
|
+
return swo.request({
|
|
6305
|
+
type: "wallet_addStarknetChain",
|
|
6306
|
+
params: chain
|
|
6307
|
+
});
|
|
6308
|
+
}
|
|
6309
|
+
function switchStarknetChain(swo, chainId) {
|
|
6310
|
+
return swo.request({
|
|
6311
|
+
type: "wallet_switchStarknetChain",
|
|
6312
|
+
params: {
|
|
6313
|
+
chainId
|
|
6314
|
+
}
|
|
6315
|
+
});
|
|
6316
|
+
}
|
|
6317
|
+
function requestChainId(swo) {
|
|
6318
|
+
return swo.request({ type: "wallet_requestChainId" });
|
|
6319
|
+
}
|
|
6320
|
+
function deploymentData(swo) {
|
|
6321
|
+
return swo.request({ type: "wallet_deploymentData" });
|
|
6322
|
+
}
|
|
6323
|
+
function addInvokeTransaction(swo, params) {
|
|
6324
|
+
return swo.request({
|
|
6325
|
+
type: "starknet_addInvokeTransaction",
|
|
6326
|
+
params
|
|
6327
|
+
});
|
|
6328
|
+
}
|
|
6329
|
+
function addDeclareTransaction(swo, params) {
|
|
6330
|
+
return swo.request({
|
|
6331
|
+
type: "starknet_addDeclareTransaction",
|
|
6332
|
+
params
|
|
6333
|
+
});
|
|
6334
|
+
}
|
|
6335
|
+
function addDeployAccountTransaction(swo, params) {
|
|
6336
|
+
return swo.request({
|
|
6337
|
+
type: "starknet_addDeployAccountTransaction",
|
|
6338
|
+
params
|
|
6339
|
+
});
|
|
6340
|
+
}
|
|
6341
|
+
function signMessage(swo, typedData) {
|
|
6342
|
+
return swo.request({
|
|
6343
|
+
type: "starknet_signTypedData",
|
|
6344
|
+
params: typedData
|
|
6345
|
+
});
|
|
6346
|
+
}
|
|
6347
|
+
function supportedSpecs(swo) {
|
|
6348
|
+
return swo.request({ type: "starknet_supportedSpecs" });
|
|
6349
|
+
}
|
|
6350
|
+
function onAccountChange(swo, callback) {
|
|
6351
|
+
swo.on("accountsChanged", callback);
|
|
6352
|
+
}
|
|
6353
|
+
function onNetworkChanged(swo, callback) {
|
|
6354
|
+
swo.on("networkChanged", callback);
|
|
6355
|
+
}
|
|
6356
|
+
|
|
6357
|
+
// src/wallet/account.ts
|
|
6358
|
+
var WalletAccount = class extends Account {
|
|
6359
|
+
address = "";
|
|
6360
|
+
walletProvider;
|
|
6361
|
+
constructor(providerOrOptions, walletProvider, cairoVersion) {
|
|
6362
|
+
super(providerOrOptions, "", "", cairoVersion);
|
|
6363
|
+
this.walletProvider = walletProvider;
|
|
6364
|
+
this.walletProvider.on("accountsChanged", (res) => {
|
|
6365
|
+
if (!res)
|
|
6366
|
+
return;
|
|
6367
|
+
this.address = res[0].toLowerCase();
|
|
6368
|
+
});
|
|
6369
|
+
this.walletProvider.on("networkChanged", (res) => {
|
|
6370
|
+
if (!res)
|
|
6371
|
+
return;
|
|
6372
|
+
this.channel.setChainId(res);
|
|
6373
|
+
});
|
|
6374
|
+
walletProvider.request({
|
|
6375
|
+
type: "wallet_requestAccounts",
|
|
6376
|
+
params: {
|
|
6377
|
+
silentMode: false
|
|
6378
|
+
}
|
|
6379
|
+
}).then((res) => {
|
|
6380
|
+
this.address = res[0].toLowerCase();
|
|
6381
|
+
});
|
|
6382
|
+
}
|
|
6383
|
+
/**
|
|
6384
|
+
* WALLET EVENTS
|
|
6385
|
+
*/
|
|
6386
|
+
onAccountChange(callback) {
|
|
6387
|
+
onAccountChange(this.walletProvider, callback);
|
|
6388
|
+
}
|
|
6389
|
+
onNetworkChanged(callback) {
|
|
6390
|
+
onNetworkChanged(this.walletProvider, callback);
|
|
6391
|
+
}
|
|
6392
|
+
/**
|
|
6393
|
+
* WALLET SPECIFIC METHODS
|
|
6394
|
+
*/
|
|
6395
|
+
requestAccounts(silentMode = false) {
|
|
6396
|
+
return requestAccounts(this.walletProvider, silentMode);
|
|
6397
|
+
}
|
|
6398
|
+
getPermissions() {
|
|
6399
|
+
return getPermissions(this.walletProvider);
|
|
6400
|
+
}
|
|
6401
|
+
switchStarknetChain(chainId) {
|
|
6402
|
+
return switchStarknetChain(this.walletProvider, chainId);
|
|
6403
|
+
}
|
|
6404
|
+
watchAsset(asset) {
|
|
6405
|
+
return watchAsset(this.walletProvider, asset);
|
|
6406
|
+
}
|
|
6407
|
+
addStarknetChain(chain) {
|
|
6408
|
+
return addStarknetChain(this.walletProvider, chain);
|
|
6409
|
+
}
|
|
6410
|
+
/**
|
|
6411
|
+
* ACCOUNT METHODS
|
|
6412
|
+
*/
|
|
6413
|
+
execute(calls) {
|
|
6414
|
+
const txCalls = [].concat(calls).map((it) => {
|
|
6415
|
+
const { contractAddress, entrypoint, calldata } = it;
|
|
6416
|
+
return {
|
|
6417
|
+
contract_address: contractAddress,
|
|
6418
|
+
entrypoint,
|
|
6419
|
+
calldata
|
|
6420
|
+
};
|
|
6421
|
+
});
|
|
6422
|
+
const params = {
|
|
6423
|
+
calls: txCalls
|
|
6424
|
+
};
|
|
6425
|
+
return addInvokeTransaction(this.walletProvider, params);
|
|
6426
|
+
}
|
|
6427
|
+
declare(payload) {
|
|
6428
|
+
const declareContractPayload = extractContractHashes(payload);
|
|
6429
|
+
const pContract = payload.contract;
|
|
6430
|
+
const cairo1Contract = {
|
|
6431
|
+
...pContract,
|
|
6432
|
+
abi: stringify2(pContract.abi)
|
|
6433
|
+
};
|
|
6434
|
+
if (!declareContractPayload.compiledClassHash) {
|
|
6435
|
+
throw Error("compiledClassHash is required");
|
|
6436
|
+
}
|
|
6437
|
+
const params = {
|
|
6438
|
+
compiled_class_hash: declareContractPayload.compiledClassHash,
|
|
6439
|
+
contract_class: cairo1Contract
|
|
6440
|
+
};
|
|
6441
|
+
return addDeclareTransaction(this.walletProvider, params);
|
|
6442
|
+
}
|
|
6443
|
+
async deploy(payload) {
|
|
6444
|
+
const { calls, addresses } = buildUDCCall(payload, this.address);
|
|
6445
|
+
const invokeResponse = await this.execute(calls);
|
|
6446
|
+
return {
|
|
6447
|
+
...invokeResponse,
|
|
6448
|
+
contract_address: addresses
|
|
6449
|
+
};
|
|
6450
|
+
}
|
|
6451
|
+
deployAccount(payload) {
|
|
6452
|
+
const params = {
|
|
6453
|
+
contract_address_salt: payload.addressSalt?.toString() || "0",
|
|
6454
|
+
constructor_calldata: payload.constructorCalldata ? CallData.compile(payload.constructorCalldata) : [],
|
|
6455
|
+
class_hash: payload.classHash
|
|
6456
|
+
};
|
|
6457
|
+
return addDeployAccountTransaction(this.walletProvider, params);
|
|
6458
|
+
}
|
|
6459
|
+
signMessage(typedData) {
|
|
6460
|
+
return signMessage(this.walletProvider, typedData);
|
|
6461
|
+
}
|
|
6462
|
+
// TODO: MISSING ESTIMATES
|
|
6463
|
+
};
|
|
6464
|
+
|
|
6258
6465
|
// src/utils/events/index.ts
|
|
6259
6466
|
var events_exports = {};
|
|
6260
6467
|
__export(events_exports, {
|
|
@@ -6766,13 +6973,19 @@ var number = num_exports;
|
|
|
6766
6973
|
TypedDataRevision,
|
|
6767
6974
|
Uint,
|
|
6768
6975
|
ValidateType,
|
|
6976
|
+
WalletAccount,
|
|
6769
6977
|
addAddressPadding,
|
|
6978
|
+
addDeclareTransaction,
|
|
6979
|
+
addDeployAccountTransaction,
|
|
6980
|
+
addInvokeTransaction,
|
|
6981
|
+
addStarknetChain,
|
|
6770
6982
|
buildUrl,
|
|
6771
6983
|
byteArray,
|
|
6772
6984
|
cairo,
|
|
6773
6985
|
constants,
|
|
6774
6986
|
contractClassResponseToLegacyCompiledContract,
|
|
6775
6987
|
defaultProvider,
|
|
6988
|
+
deploymentData,
|
|
6776
6989
|
ec,
|
|
6777
6990
|
encode,
|
|
6778
6991
|
eth,
|
|
@@ -6782,6 +6995,7 @@ var number = num_exports;
|
|
|
6782
6995
|
fixStack,
|
|
6783
6996
|
getCalldata,
|
|
6784
6997
|
getChecksumAddress,
|
|
6998
|
+
getPermissions,
|
|
6785
6999
|
hash,
|
|
6786
7000
|
isSierra,
|
|
6787
7001
|
isUrl,
|
|
@@ -6789,13 +7003,20 @@ var number = num_exports;
|
|
|
6789
7003
|
merkle,
|
|
6790
7004
|
num,
|
|
6791
7005
|
number,
|
|
7006
|
+
onAccountChange,
|
|
7007
|
+
onNetworkChanged,
|
|
6792
7008
|
parseUDCEvent,
|
|
6793
7009
|
provider,
|
|
7010
|
+
requestAccounts,
|
|
7011
|
+
requestChainId,
|
|
6794
7012
|
selector,
|
|
6795
7013
|
shortString,
|
|
7014
|
+
signMessage,
|
|
6796
7015
|
splitArgsAndOptions,
|
|
6797
7016
|
stark,
|
|
6798
7017
|
starknetId,
|
|
7018
|
+
supportedSpecs,
|
|
7019
|
+
switchStarknetChain,
|
|
6799
7020
|
transaction,
|
|
6800
7021
|
typedData,
|
|
6801
7022
|
types,
|
|
@@ -6803,6 +7024,7 @@ var number = num_exports;
|
|
|
6803
7024
|
v2hash,
|
|
6804
7025
|
v3hash,
|
|
6805
7026
|
validateAndParseAddress,
|
|
6806
|
-
validateChecksumAddress
|
|
7027
|
+
validateChecksumAddress,
|
|
7028
|
+
watchAsset
|
|
6807
7029
|
});
|
|
6808
7030
|
//# sourceMappingURL=index.js.map
|