starknet 6.4.2 → 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 +26 -0
- package/dist/index.d.ts +468 -4
- package/dist/index.global.js +280 -50
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +296 -51
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +280 -50
- 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
|
|
|
@@ -125,7 +140,8 @@ __export(constants_exports, {
|
|
|
125
140
|
TRANSACTION_VERSION: () => ETransactionVersion4,
|
|
126
141
|
TransactionHashPrefix: () => TransactionHashPrefix,
|
|
127
142
|
UDC: () => UDC,
|
|
128
|
-
ZERO: () => ZERO
|
|
143
|
+
ZERO: () => ZERO,
|
|
144
|
+
feeMarginPercentage: () => feeMarginPercentage
|
|
129
145
|
});
|
|
130
146
|
|
|
131
147
|
// src/types/api/index.ts
|
|
@@ -452,11 +468,17 @@ var TransactionHashPrefix = /* @__PURE__ */ ((TransactionHashPrefix2) => {
|
|
|
452
468
|
TransactionHashPrefix2["L1_HANDLER"] = "0x6c315f68616e646c6572";
|
|
453
469
|
return TransactionHashPrefix2;
|
|
454
470
|
})(TransactionHashPrefix || {});
|
|
471
|
+
var feeMarginPercentage = /* @__PURE__ */ ((feeMarginPercentage2) => {
|
|
472
|
+
feeMarginPercentage2[feeMarginPercentage2["L1_BOUND_MAX_AMOUNT"] = 50] = "L1_BOUND_MAX_AMOUNT";
|
|
473
|
+
feeMarginPercentage2[feeMarginPercentage2["L1_BOUND_MAX_PRICE_PER_UNIT"] = 50] = "L1_BOUND_MAX_PRICE_PER_UNIT";
|
|
474
|
+
feeMarginPercentage2[feeMarginPercentage2["MAX_FEE"] = 50] = "MAX_FEE";
|
|
475
|
+
return feeMarginPercentage2;
|
|
476
|
+
})(feeMarginPercentage || {});
|
|
455
477
|
var UDC = {
|
|
456
478
|
ADDRESS: "0x041a78e741e5af2fec34b695679bc6891742439f7afb8484ecd7766661ad02bf",
|
|
457
479
|
ENTRYPOINT: "deployContract"
|
|
458
480
|
};
|
|
459
|
-
var RPC_DEFAULT_VERSION = "
|
|
481
|
+
var RPC_DEFAULT_VERSION = "v0_7";
|
|
460
482
|
var RPC_NODES = {
|
|
461
483
|
SN_GOERLI: [
|
|
462
484
|
`https://starknet-testnet.public.blastapi.io/rpc/${RPC_DEFAULT_VERSION}`,
|
|
@@ -2941,10 +2963,10 @@ function signatureToDecimalArray(sig) {
|
|
|
2941
2963
|
function signatureToHexArray(sig) {
|
|
2942
2964
|
return bigNumberishArrayToHexadecimalStringArray(formatSignature(sig));
|
|
2943
2965
|
}
|
|
2944
|
-
function estimatedFeeToMaxFee(estimatedFee, overhead =
|
|
2945
|
-
return addPercent(estimatedFee, overhead
|
|
2966
|
+
function estimatedFeeToMaxFee(estimatedFee, overhead = 50 /* MAX_FEE */) {
|
|
2967
|
+
return addPercent(estimatedFee, overhead);
|
|
2946
2968
|
}
|
|
2947
|
-
function estimateFeeToBounds(estimate, amountOverhead =
|
|
2969
|
+
function estimateFeeToBounds(estimate, amountOverhead = 50 /* L1_BOUND_MAX_AMOUNT */, priceOverhead = 50 /* L1_BOUND_MAX_PRICE_PER_UNIT */) {
|
|
2948
2970
|
if (typeof estimate === "bigint") {
|
|
2949
2971
|
return {
|
|
2950
2972
|
l2_gas: { max_amount: "0x0", max_price_per_unit: "0x0" },
|
|
@@ -2954,7 +2976,7 @@ function estimateFeeToBounds(estimate, amountOverhead = 10, priceOverhead = 50)
|
|
|
2954
2976
|
if (typeof estimate.gas_consumed === "undefined" || typeof estimate.gas_price === "undefined") {
|
|
2955
2977
|
throw Error("estimateFeeToBounds: estimate is undefined");
|
|
2956
2978
|
}
|
|
2957
|
-
const maxUnits = toHex(addPercent(estimate.gas_consumed, amountOverhead));
|
|
2979
|
+
const maxUnits = estimate.data_gas_consumed !== void 0 && estimate.data_gas_price !== void 0 ? toHex(addPercent(BigInt(estimate.overall_fee) / BigInt(estimate.gas_price), amountOverhead)) : toHex(addPercent(estimate.gas_consumed, amountOverhead));
|
|
2958
2980
|
const maxUnitPrice = toHex(addPercent(estimate.gas_price, priceOverhead));
|
|
2959
2981
|
return {
|
|
2960
2982
|
l2_gas: { max_amount: "0x0", max_price_per_unit: "0x0" },
|
|
@@ -3180,6 +3202,7 @@ function isPendingStateUpdate(response) {
|
|
|
3180
3202
|
// src/utils/transaction.ts
|
|
3181
3203
|
var transaction_exports = {};
|
|
3182
3204
|
__export(transaction_exports, {
|
|
3205
|
+
buildUDCCall: () => buildUDCCall,
|
|
3183
3206
|
fromCallsToExecuteCalldata: () => fromCallsToExecuteCalldata,
|
|
3184
3207
|
fromCallsToExecuteCalldataWithNonce: () => fromCallsToExecuteCalldataWithNonce,
|
|
3185
3208
|
fromCallsToExecuteCalldata_cairo1: () => fromCallsToExecuteCalldata_cairo1,
|
|
@@ -3237,6 +3260,41 @@ var getExecuteCalldata = (calls, cairoVersion = "0") => {
|
|
|
3237
3260
|
}
|
|
3238
3261
|
return fromCallsToExecuteCalldata(calls);
|
|
3239
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
|
+
}
|
|
3240
3298
|
function getVersionsByType(versionType) {
|
|
3241
3299
|
return versionType === "fee" ? {
|
|
3242
3300
|
v1: "0x100000000000000000000000000000001" /* F1 */,
|
|
@@ -3278,6 +3336,9 @@ var RpcChannel = class {
|
|
|
3278
3336
|
this.waitMode = waitMode || false;
|
|
3279
3337
|
this.requestId = 0;
|
|
3280
3338
|
}
|
|
3339
|
+
setChainId(chainId) {
|
|
3340
|
+
this.chainId = chainId;
|
|
3341
|
+
}
|
|
3281
3342
|
fetch(method, params, id = 0) {
|
|
3282
3343
|
const rpcRequestBody = {
|
|
3283
3344
|
id,
|
|
@@ -3808,6 +3869,9 @@ var RpcChannel2 = class {
|
|
|
3808
3869
|
this.waitMode = waitMode || false;
|
|
3809
3870
|
this.requestId = 0;
|
|
3810
3871
|
}
|
|
3872
|
+
setChainId(chainId) {
|
|
3873
|
+
this.chainId = chainId;
|
|
3874
|
+
}
|
|
3811
3875
|
fetch(method, params, id = 0) {
|
|
3812
3876
|
const rpcRequestBody = {
|
|
3813
3877
|
id,
|
|
@@ -4308,6 +4372,20 @@ var RpcChannel2 = class {
|
|
|
4308
4372
|
|
|
4309
4373
|
// src/utils/responseParser/rpc.ts
|
|
4310
4374
|
var RPCResponseParser = class {
|
|
4375
|
+
margin;
|
|
4376
|
+
constructor(margin) {
|
|
4377
|
+
this.margin = margin;
|
|
4378
|
+
}
|
|
4379
|
+
estimatedFeeToMaxFee(estimatedFee) {
|
|
4380
|
+
return estimatedFeeToMaxFee(estimatedFee, this.margin?.maxFee);
|
|
4381
|
+
}
|
|
4382
|
+
estimateFeeToBounds(estimate) {
|
|
4383
|
+
return estimateFeeToBounds(
|
|
4384
|
+
estimate,
|
|
4385
|
+
this.margin?.l1BoundMaxAmount,
|
|
4386
|
+
this.margin?.l1BoundMaxPricePerUnit
|
|
4387
|
+
);
|
|
4388
|
+
}
|
|
4311
4389
|
parseGetBlockResponse(res) {
|
|
4312
4390
|
return { status: "PENDING", ...res };
|
|
4313
4391
|
}
|
|
@@ -4330,8 +4408,8 @@ var RPCResponseParser = class {
|
|
|
4330
4408
|
gas_consumed: toBigInt(val.gas_consumed),
|
|
4331
4409
|
gas_price: toBigInt(val.gas_price),
|
|
4332
4410
|
unit: val.unit,
|
|
4333
|
-
suggestedMaxFee: estimatedFeeToMaxFee(val.overall_fee),
|
|
4334
|
-
resourceBounds: estimateFeeToBounds(val)
|
|
4411
|
+
suggestedMaxFee: this.estimatedFeeToMaxFee(val.overall_fee),
|
|
4412
|
+
resourceBounds: this.estimateFeeToBounds(val)
|
|
4335
4413
|
};
|
|
4336
4414
|
}
|
|
4337
4415
|
parseFeeEstimateBulkResponse(res) {
|
|
@@ -4340,16 +4418,16 @@ var RPCResponseParser = class {
|
|
|
4340
4418
|
gas_consumed: toBigInt(val.gas_consumed),
|
|
4341
4419
|
gas_price: toBigInt(val.gas_price),
|
|
4342
4420
|
unit: val.unit,
|
|
4343
|
-
suggestedMaxFee: estimatedFeeToMaxFee(val.overall_fee),
|
|
4344
|
-
resourceBounds: estimateFeeToBounds(val)
|
|
4421
|
+
suggestedMaxFee: this.estimatedFeeToMaxFee(val.overall_fee),
|
|
4422
|
+
resourceBounds: this.estimateFeeToBounds(val)
|
|
4345
4423
|
}));
|
|
4346
4424
|
}
|
|
4347
4425
|
parseSimulateTransactionResponse(res) {
|
|
4348
4426
|
return res.map((it) => {
|
|
4349
4427
|
return {
|
|
4350
4428
|
...it,
|
|
4351
|
-
suggestedMaxFee: estimatedFeeToMaxFee(
|
|
4352
|
-
resourceBounds: estimateFeeToBounds(it.fee_estimation)
|
|
4429
|
+
suggestedMaxFee: this.estimatedFeeToMaxFee(it.fee_estimation.overall_fee),
|
|
4430
|
+
resourceBounds: this.estimateFeeToBounds(it.fee_estimation)
|
|
4353
4431
|
};
|
|
4354
4432
|
});
|
|
4355
4433
|
}
|
|
@@ -4363,13 +4441,15 @@ var RPCResponseParser = class {
|
|
|
4363
4441
|
|
|
4364
4442
|
// src/provider/rpc.ts
|
|
4365
4443
|
var RpcProvider = class {
|
|
4366
|
-
responseParser
|
|
4444
|
+
responseParser;
|
|
4367
4445
|
channel;
|
|
4368
4446
|
constructor(optionsOrProvider) {
|
|
4369
4447
|
if (optionsOrProvider && "channel" in optionsOrProvider) {
|
|
4370
4448
|
this.channel = optionsOrProvider.channel;
|
|
4449
|
+
this.responseParser = optionsOrProvider.responseParser;
|
|
4371
4450
|
} else {
|
|
4372
4451
|
this.channel = new RpcChannel2({ ...optionsOrProvider, waitMode: false });
|
|
4452
|
+
this.responseParser = new RPCResponseParser(optionsOrProvider?.feeMarginPercentage);
|
|
4373
4453
|
}
|
|
4374
4454
|
}
|
|
4375
4455
|
fetch(method, params, id = 0) {
|
|
@@ -4462,7 +4542,7 @@ var RpcProvider = class {
|
|
|
4462
4542
|
* - skipFeeCharge (default true)<br/>
|
|
4463
4543
|
*/
|
|
4464
4544
|
async getSimulateTransaction(invocations, options) {
|
|
4465
|
-
return this.channel.simulateTransaction(invocations, options).then(this.responseParser.parseSimulateTransactionResponse);
|
|
4545
|
+
return this.channel.simulateTransaction(invocations, options).then((r) => this.responseParser.parseSimulateTransactionResponse(r));
|
|
4466
4546
|
}
|
|
4467
4547
|
async waitForTransaction(txHash, options) {
|
|
4468
4548
|
return this.channel.waitForTransaction(txHash, options);
|
|
@@ -4519,7 +4599,7 @@ var RpcProvider = class {
|
|
|
4519
4599
|
}
|
|
4520
4600
|
],
|
|
4521
4601
|
{ blockIdentifier, skipValidate }
|
|
4522
|
-
).then(this.responseParser.parseFeeEstimateResponse);
|
|
4602
|
+
).then((r) => this.responseParser.parseFeeEstimateResponse(r));
|
|
4523
4603
|
}
|
|
4524
4604
|
async getDeclareEstimateFee(invocation, details, blockIdentifier, skipValidate) {
|
|
4525
4605
|
return this.channel.getEstimateFee(
|
|
@@ -4531,7 +4611,7 @@ var RpcProvider = class {
|
|
|
4531
4611
|
}
|
|
4532
4612
|
],
|
|
4533
4613
|
{ blockIdentifier, skipValidate }
|
|
4534
|
-
).then(this.responseParser.parseFeeEstimateResponse);
|
|
4614
|
+
).then((r) => this.responseParser.parseFeeEstimateResponse(r));
|
|
4535
4615
|
}
|
|
4536
4616
|
async getDeployAccountEstimateFee(invocation, details, blockIdentifier, skipValidate) {
|
|
4537
4617
|
return this.channel.getEstimateFee(
|
|
@@ -4543,10 +4623,10 @@ var RpcProvider = class {
|
|
|
4543
4623
|
}
|
|
4544
4624
|
],
|
|
4545
4625
|
{ blockIdentifier, skipValidate }
|
|
4546
|
-
).then(this.responseParser.parseFeeEstimateResponse);
|
|
4626
|
+
).then((r) => this.responseParser.parseFeeEstimateResponse(r));
|
|
4547
4627
|
}
|
|
4548
4628
|
async getEstimateFeeBulk(invocations, options) {
|
|
4549
|
-
return this.channel.getEstimateFee(invocations, options).then(this.responseParser.parseFeeEstimateBulkResponse);
|
|
4629
|
+
return this.channel.getEstimateFee(invocations, options).then((r) => this.responseParser.parseFeeEstimateBulkResponse(r));
|
|
4550
4630
|
}
|
|
4551
4631
|
async invokeFunction(functionInvocation, details) {
|
|
4552
4632
|
return this.channel.invoke(functionInvocation, details);
|
|
@@ -5887,37 +5967,7 @@ var Account = class extends RpcProvider2 {
|
|
|
5887
5967
|
return this.declareContract(declareContractTransaction, declareDetails);
|
|
5888
5968
|
}
|
|
5889
5969
|
async deploy(payload, details = {}) {
|
|
5890
|
-
const
|
|
5891
|
-
const {
|
|
5892
|
-
classHash,
|
|
5893
|
-
salt,
|
|
5894
|
-
unique = true,
|
|
5895
|
-
constructorCalldata = []
|
|
5896
|
-
} = it;
|
|
5897
|
-
const compiledConstructorCallData = CallData.compile(constructorCalldata);
|
|
5898
|
-
const deploySalt = salt ?? randomAddress();
|
|
5899
|
-
return {
|
|
5900
|
-
call: {
|
|
5901
|
-
contractAddress: UDC.ADDRESS,
|
|
5902
|
-
entrypoint: UDC.ENTRYPOINT,
|
|
5903
|
-
calldata: [
|
|
5904
|
-
classHash,
|
|
5905
|
-
deploySalt,
|
|
5906
|
-
toCairoBool(unique),
|
|
5907
|
-
compiledConstructorCallData.length,
|
|
5908
|
-
...compiledConstructorCallData
|
|
5909
|
-
]
|
|
5910
|
-
},
|
|
5911
|
-
address: calculateContractAddressFromHash(
|
|
5912
|
-
unique ? starkCurve.pedersen(this.address, deploySalt) : deploySalt,
|
|
5913
|
-
classHash,
|
|
5914
|
-
compiledConstructorCallData,
|
|
5915
|
-
unique ? UDC.ADDRESS : 0
|
|
5916
|
-
)
|
|
5917
|
-
};
|
|
5918
|
-
});
|
|
5919
|
-
const calls = params.map((it) => it.call);
|
|
5920
|
-
const addresses = params.map((it) => it.address);
|
|
5970
|
+
const { calls, addresses } = buildUDCCall(payload, this.address);
|
|
5921
5971
|
const invokeResponse = await this.execute(calls, void 0, details);
|
|
5922
5972
|
return {
|
|
5923
5973
|
...invokeResponse,
|
|
@@ -6232,6 +6282,186 @@ var Account = class extends RpcProvider2 {
|
|
|
6232
6282
|
var AccountInterface = class extends ProviderInterface {
|
|
6233
6283
|
};
|
|
6234
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
|
+
|
|
6235
6465
|
// src/utils/events/index.ts
|
|
6236
6466
|
var events_exports = {};
|
|
6237
6467
|
__export(events_exports, {
|
|
@@ -6743,13 +6973,19 @@ var number = num_exports;
|
|
|
6743
6973
|
TypedDataRevision,
|
|
6744
6974
|
Uint,
|
|
6745
6975
|
ValidateType,
|
|
6976
|
+
WalletAccount,
|
|
6746
6977
|
addAddressPadding,
|
|
6978
|
+
addDeclareTransaction,
|
|
6979
|
+
addDeployAccountTransaction,
|
|
6980
|
+
addInvokeTransaction,
|
|
6981
|
+
addStarknetChain,
|
|
6747
6982
|
buildUrl,
|
|
6748
6983
|
byteArray,
|
|
6749
6984
|
cairo,
|
|
6750
6985
|
constants,
|
|
6751
6986
|
contractClassResponseToLegacyCompiledContract,
|
|
6752
6987
|
defaultProvider,
|
|
6988
|
+
deploymentData,
|
|
6753
6989
|
ec,
|
|
6754
6990
|
encode,
|
|
6755
6991
|
eth,
|
|
@@ -6759,6 +6995,7 @@ var number = num_exports;
|
|
|
6759
6995
|
fixStack,
|
|
6760
6996
|
getCalldata,
|
|
6761
6997
|
getChecksumAddress,
|
|
6998
|
+
getPermissions,
|
|
6762
6999
|
hash,
|
|
6763
7000
|
isSierra,
|
|
6764
7001
|
isUrl,
|
|
@@ -6766,13 +7003,20 @@ var number = num_exports;
|
|
|
6766
7003
|
merkle,
|
|
6767
7004
|
num,
|
|
6768
7005
|
number,
|
|
7006
|
+
onAccountChange,
|
|
7007
|
+
onNetworkChanged,
|
|
6769
7008
|
parseUDCEvent,
|
|
6770
7009
|
provider,
|
|
7010
|
+
requestAccounts,
|
|
7011
|
+
requestChainId,
|
|
6771
7012
|
selector,
|
|
6772
7013
|
shortString,
|
|
7014
|
+
signMessage,
|
|
6773
7015
|
splitArgsAndOptions,
|
|
6774
7016
|
stark,
|
|
6775
7017
|
starknetId,
|
|
7018
|
+
supportedSpecs,
|
|
7019
|
+
switchStarknetChain,
|
|
6776
7020
|
transaction,
|
|
6777
7021
|
typedData,
|
|
6778
7022
|
types,
|
|
@@ -6780,6 +7024,7 @@ var number = num_exports;
|
|
|
6780
7024
|
v2hash,
|
|
6781
7025
|
v3hash,
|
|
6782
7026
|
validateAndParseAddress,
|
|
6783
|
-
validateChecksumAddress
|
|
7027
|
+
validateChecksumAddress,
|
|
7028
|
+
watchAsset
|
|
6784
7029
|
});
|
|
6785
7030
|
//# sourceMappingURL=index.js.map
|