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.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
|
|
@@ -12766,7 +12781,8 @@ var starknet = (() => {
|
|
|
12766
12781
|
TRANSACTION_VERSION: () => ETransactionVersion4,
|
|
12767
12782
|
TransactionHashPrefix: () => TransactionHashPrefix,
|
|
12768
12783
|
UDC: () => UDC,
|
|
12769
|
-
ZERO: () => ZERO
|
|
12784
|
+
ZERO: () => ZERO,
|
|
12785
|
+
feeMarginPercentage: () => feeMarginPercentage
|
|
12770
12786
|
});
|
|
12771
12787
|
|
|
12772
12788
|
// src/types/api/index.ts
|
|
@@ -13251,11 +13267,17 @@ var starknet = (() => {
|
|
|
13251
13267
|
TransactionHashPrefix2["L1_HANDLER"] = "0x6c315f68616e646c6572";
|
|
13252
13268
|
return TransactionHashPrefix2;
|
|
13253
13269
|
})(TransactionHashPrefix || {});
|
|
13270
|
+
var feeMarginPercentage = /* @__PURE__ */ ((feeMarginPercentage2) => {
|
|
13271
|
+
feeMarginPercentage2[feeMarginPercentage2["L1_BOUND_MAX_AMOUNT"] = 50] = "L1_BOUND_MAX_AMOUNT";
|
|
13272
|
+
feeMarginPercentage2[feeMarginPercentage2["L1_BOUND_MAX_PRICE_PER_UNIT"] = 50] = "L1_BOUND_MAX_PRICE_PER_UNIT";
|
|
13273
|
+
feeMarginPercentage2[feeMarginPercentage2["MAX_FEE"] = 50] = "MAX_FEE";
|
|
13274
|
+
return feeMarginPercentage2;
|
|
13275
|
+
})(feeMarginPercentage || {});
|
|
13254
13276
|
var UDC = {
|
|
13255
13277
|
ADDRESS: "0x041a78e741e5af2fec34b695679bc6891742439f7afb8484ecd7766661ad02bf",
|
|
13256
13278
|
ENTRYPOINT: "deployContract"
|
|
13257
13279
|
};
|
|
13258
|
-
var RPC_DEFAULT_VERSION = "
|
|
13280
|
+
var RPC_DEFAULT_VERSION = "v0_7";
|
|
13259
13281
|
var RPC_NODES = {
|
|
13260
13282
|
SN_GOERLI: [
|
|
13261
13283
|
`https://starknet-testnet.public.blastapi.io/rpc/${RPC_DEFAULT_VERSION}`,
|
|
@@ -22997,10 +23019,10 @@ var starknet = (() => {
|
|
|
22997
23019
|
function signatureToHexArray(sig) {
|
|
22998
23020
|
return bigNumberishArrayToHexadecimalStringArray(formatSignature(sig));
|
|
22999
23021
|
}
|
|
23000
|
-
function estimatedFeeToMaxFee(estimatedFee, overhead =
|
|
23001
|
-
return addPercent(estimatedFee, overhead
|
|
23022
|
+
function estimatedFeeToMaxFee(estimatedFee, overhead = 50 /* MAX_FEE */) {
|
|
23023
|
+
return addPercent(estimatedFee, overhead);
|
|
23002
23024
|
}
|
|
23003
|
-
function estimateFeeToBounds(estimate, amountOverhead =
|
|
23025
|
+
function estimateFeeToBounds(estimate, amountOverhead = 50 /* L1_BOUND_MAX_AMOUNT */, priceOverhead = 50 /* L1_BOUND_MAX_PRICE_PER_UNIT */) {
|
|
23004
23026
|
if (typeof estimate === "bigint") {
|
|
23005
23027
|
return {
|
|
23006
23028
|
l2_gas: { max_amount: "0x0", max_price_per_unit: "0x0" },
|
|
@@ -23010,7 +23032,7 @@ var starknet = (() => {
|
|
|
23010
23032
|
if (typeof estimate.gas_consumed === "undefined" || typeof estimate.gas_price === "undefined") {
|
|
23011
23033
|
throw Error("estimateFeeToBounds: estimate is undefined");
|
|
23012
23034
|
}
|
|
23013
|
-
const maxUnits = toHex(addPercent(estimate.gas_consumed, amountOverhead));
|
|
23035
|
+
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));
|
|
23014
23036
|
const maxUnitPrice = toHex(addPercent(estimate.gas_price, priceOverhead));
|
|
23015
23037
|
return {
|
|
23016
23038
|
l2_gas: { max_amount: "0x0", max_price_per_unit: "0x0" },
|
|
@@ -23395,6 +23417,7 @@ var starknet = (() => {
|
|
|
23395
23417
|
// src/utils/transaction.ts
|
|
23396
23418
|
var transaction_exports = {};
|
|
23397
23419
|
__export(transaction_exports, {
|
|
23420
|
+
buildUDCCall: () => buildUDCCall,
|
|
23398
23421
|
fromCallsToExecuteCalldata: () => fromCallsToExecuteCalldata,
|
|
23399
23422
|
fromCallsToExecuteCalldataWithNonce: () => fromCallsToExecuteCalldataWithNonce,
|
|
23400
23423
|
fromCallsToExecuteCalldata_cairo1: () => fromCallsToExecuteCalldata_cairo1,
|
|
@@ -23452,6 +23475,41 @@ var starknet = (() => {
|
|
|
23452
23475
|
}
|
|
23453
23476
|
return fromCallsToExecuteCalldata(calls);
|
|
23454
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
|
+
}
|
|
23455
23513
|
function getVersionsByType(versionType) {
|
|
23456
23514
|
return versionType === "fee" ? {
|
|
23457
23515
|
v1: "0x100000000000000000000000000000001" /* F1 */,
|
|
@@ -23493,6 +23551,9 @@ var starknet = (() => {
|
|
|
23493
23551
|
this.waitMode = waitMode || false;
|
|
23494
23552
|
this.requestId = 0;
|
|
23495
23553
|
}
|
|
23554
|
+
setChainId(chainId) {
|
|
23555
|
+
this.chainId = chainId;
|
|
23556
|
+
}
|
|
23496
23557
|
fetch(method, params, id = 0) {
|
|
23497
23558
|
const rpcRequestBody = {
|
|
23498
23559
|
id,
|
|
@@ -24023,6 +24084,9 @@ var starknet = (() => {
|
|
|
24023
24084
|
this.waitMode = waitMode || false;
|
|
24024
24085
|
this.requestId = 0;
|
|
24025
24086
|
}
|
|
24087
|
+
setChainId(chainId) {
|
|
24088
|
+
this.chainId = chainId;
|
|
24089
|
+
}
|
|
24026
24090
|
fetch(method, params, id = 0) {
|
|
24027
24091
|
const rpcRequestBody = {
|
|
24028
24092
|
id,
|
|
@@ -24523,6 +24587,20 @@ var starknet = (() => {
|
|
|
24523
24587
|
|
|
24524
24588
|
// src/utils/responseParser/rpc.ts
|
|
24525
24589
|
var RPCResponseParser = class {
|
|
24590
|
+
margin;
|
|
24591
|
+
constructor(margin) {
|
|
24592
|
+
this.margin = margin;
|
|
24593
|
+
}
|
|
24594
|
+
estimatedFeeToMaxFee(estimatedFee) {
|
|
24595
|
+
return estimatedFeeToMaxFee(estimatedFee, this.margin?.maxFee);
|
|
24596
|
+
}
|
|
24597
|
+
estimateFeeToBounds(estimate) {
|
|
24598
|
+
return estimateFeeToBounds(
|
|
24599
|
+
estimate,
|
|
24600
|
+
this.margin?.l1BoundMaxAmount,
|
|
24601
|
+
this.margin?.l1BoundMaxPricePerUnit
|
|
24602
|
+
);
|
|
24603
|
+
}
|
|
24526
24604
|
parseGetBlockResponse(res) {
|
|
24527
24605
|
return { status: "PENDING", ...res };
|
|
24528
24606
|
}
|
|
@@ -24545,8 +24623,8 @@ var starknet = (() => {
|
|
|
24545
24623
|
gas_consumed: toBigInt(val.gas_consumed),
|
|
24546
24624
|
gas_price: toBigInt(val.gas_price),
|
|
24547
24625
|
unit: val.unit,
|
|
24548
|
-
suggestedMaxFee: estimatedFeeToMaxFee(val.overall_fee),
|
|
24549
|
-
resourceBounds: estimateFeeToBounds(val)
|
|
24626
|
+
suggestedMaxFee: this.estimatedFeeToMaxFee(val.overall_fee),
|
|
24627
|
+
resourceBounds: this.estimateFeeToBounds(val)
|
|
24550
24628
|
};
|
|
24551
24629
|
}
|
|
24552
24630
|
parseFeeEstimateBulkResponse(res) {
|
|
@@ -24555,16 +24633,16 @@ var starknet = (() => {
|
|
|
24555
24633
|
gas_consumed: toBigInt(val.gas_consumed),
|
|
24556
24634
|
gas_price: toBigInt(val.gas_price),
|
|
24557
24635
|
unit: val.unit,
|
|
24558
|
-
suggestedMaxFee: estimatedFeeToMaxFee(val.overall_fee),
|
|
24559
|
-
resourceBounds: estimateFeeToBounds(val)
|
|
24636
|
+
suggestedMaxFee: this.estimatedFeeToMaxFee(val.overall_fee),
|
|
24637
|
+
resourceBounds: this.estimateFeeToBounds(val)
|
|
24560
24638
|
}));
|
|
24561
24639
|
}
|
|
24562
24640
|
parseSimulateTransactionResponse(res) {
|
|
24563
24641
|
return res.map((it) => {
|
|
24564
24642
|
return {
|
|
24565
24643
|
...it,
|
|
24566
|
-
suggestedMaxFee: estimatedFeeToMaxFee(
|
|
24567
|
-
resourceBounds: estimateFeeToBounds(it.fee_estimation)
|
|
24644
|
+
suggestedMaxFee: this.estimatedFeeToMaxFee(it.fee_estimation.overall_fee),
|
|
24645
|
+
resourceBounds: this.estimateFeeToBounds(it.fee_estimation)
|
|
24568
24646
|
};
|
|
24569
24647
|
});
|
|
24570
24648
|
}
|
|
@@ -24578,13 +24656,15 @@ var starknet = (() => {
|
|
|
24578
24656
|
|
|
24579
24657
|
// src/provider/rpc.ts
|
|
24580
24658
|
var RpcProvider = class {
|
|
24581
|
-
responseParser
|
|
24659
|
+
responseParser;
|
|
24582
24660
|
channel;
|
|
24583
24661
|
constructor(optionsOrProvider) {
|
|
24584
24662
|
if (optionsOrProvider && "channel" in optionsOrProvider) {
|
|
24585
24663
|
this.channel = optionsOrProvider.channel;
|
|
24664
|
+
this.responseParser = optionsOrProvider.responseParser;
|
|
24586
24665
|
} else {
|
|
24587
24666
|
this.channel = new RpcChannel2({ ...optionsOrProvider, waitMode: false });
|
|
24667
|
+
this.responseParser = new RPCResponseParser(optionsOrProvider?.feeMarginPercentage);
|
|
24588
24668
|
}
|
|
24589
24669
|
}
|
|
24590
24670
|
fetch(method, params, id = 0) {
|
|
@@ -24677,7 +24757,7 @@ var starknet = (() => {
|
|
|
24677
24757
|
* - skipFeeCharge (default true)<br/>
|
|
24678
24758
|
*/
|
|
24679
24759
|
async getSimulateTransaction(invocations, options) {
|
|
24680
|
-
return this.channel.simulateTransaction(invocations, options).then(this.responseParser.parseSimulateTransactionResponse);
|
|
24760
|
+
return this.channel.simulateTransaction(invocations, options).then((r) => this.responseParser.parseSimulateTransactionResponse(r));
|
|
24681
24761
|
}
|
|
24682
24762
|
async waitForTransaction(txHash, options) {
|
|
24683
24763
|
return this.channel.waitForTransaction(txHash, options);
|
|
@@ -24734,7 +24814,7 @@ var starknet = (() => {
|
|
|
24734
24814
|
}
|
|
24735
24815
|
],
|
|
24736
24816
|
{ blockIdentifier, skipValidate }
|
|
24737
|
-
).then(this.responseParser.parseFeeEstimateResponse);
|
|
24817
|
+
).then((r) => this.responseParser.parseFeeEstimateResponse(r));
|
|
24738
24818
|
}
|
|
24739
24819
|
async getDeclareEstimateFee(invocation, details, blockIdentifier, skipValidate) {
|
|
24740
24820
|
return this.channel.getEstimateFee(
|
|
@@ -24746,7 +24826,7 @@ var starknet = (() => {
|
|
|
24746
24826
|
}
|
|
24747
24827
|
],
|
|
24748
24828
|
{ blockIdentifier, skipValidate }
|
|
24749
|
-
).then(this.responseParser.parseFeeEstimateResponse);
|
|
24829
|
+
).then((r) => this.responseParser.parseFeeEstimateResponse(r));
|
|
24750
24830
|
}
|
|
24751
24831
|
async getDeployAccountEstimateFee(invocation, details, blockIdentifier, skipValidate) {
|
|
24752
24832
|
return this.channel.getEstimateFee(
|
|
@@ -24758,10 +24838,10 @@ var starknet = (() => {
|
|
|
24758
24838
|
}
|
|
24759
24839
|
],
|
|
24760
24840
|
{ blockIdentifier, skipValidate }
|
|
24761
|
-
).then(this.responseParser.parseFeeEstimateResponse);
|
|
24841
|
+
).then((r) => this.responseParser.parseFeeEstimateResponse(r));
|
|
24762
24842
|
}
|
|
24763
24843
|
async getEstimateFeeBulk(invocations, options) {
|
|
24764
|
-
return this.channel.getEstimateFee(invocations, options).then(this.responseParser.parseFeeEstimateBulkResponse);
|
|
24844
|
+
return this.channel.getEstimateFee(invocations, options).then((r) => this.responseParser.parseFeeEstimateBulkResponse(r));
|
|
24765
24845
|
}
|
|
24766
24846
|
async invokeFunction(functionInvocation, details) {
|
|
24767
24847
|
return this.channel.invoke(functionInvocation, details);
|
|
@@ -26399,37 +26479,7 @@ var starknet = (() => {
|
|
|
26399
26479
|
return this.declareContract(declareContractTransaction, declareDetails);
|
|
26400
26480
|
}
|
|
26401
26481
|
async deploy(payload, details = {}) {
|
|
26402
|
-
const
|
|
26403
|
-
const {
|
|
26404
|
-
classHash,
|
|
26405
|
-
salt,
|
|
26406
|
-
unique: unique2 = true,
|
|
26407
|
-
constructorCalldata = []
|
|
26408
|
-
} = it;
|
|
26409
|
-
const compiledConstructorCallData = CallData.compile(constructorCalldata);
|
|
26410
|
-
const deploySalt = salt ?? randomAddress();
|
|
26411
|
-
return {
|
|
26412
|
-
call: {
|
|
26413
|
-
contractAddress: UDC.ADDRESS,
|
|
26414
|
-
entrypoint: UDC.ENTRYPOINT,
|
|
26415
|
-
calldata: [
|
|
26416
|
-
classHash,
|
|
26417
|
-
deploySalt,
|
|
26418
|
-
toCairoBool(unique2),
|
|
26419
|
-
compiledConstructorCallData.length,
|
|
26420
|
-
...compiledConstructorCallData
|
|
26421
|
-
]
|
|
26422
|
-
},
|
|
26423
|
-
address: calculateContractAddressFromHash(
|
|
26424
|
-
unique2 ? esm_exports.pedersen(this.address, deploySalt) : deploySalt,
|
|
26425
|
-
classHash,
|
|
26426
|
-
compiledConstructorCallData,
|
|
26427
|
-
unique2 ? UDC.ADDRESS : 0
|
|
26428
|
-
)
|
|
26429
|
-
};
|
|
26430
|
-
});
|
|
26431
|
-
const calls = params.map((it) => it.call);
|
|
26432
|
-
const addresses = params.map((it) => it.address);
|
|
26482
|
+
const { calls, addresses } = buildUDCCall(payload, this.address);
|
|
26433
26483
|
const invokeResponse = await this.execute(calls, void 0, details);
|
|
26434
26484
|
return {
|
|
26435
26485
|
...invokeResponse,
|
|
@@ -26744,6 +26794,186 @@ var starknet = (() => {
|
|
|
26744
26794
|
var AccountInterface = class extends ProviderInterface {
|
|
26745
26795
|
};
|
|
26746
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
|
+
|
|
26747
26977
|
// src/utils/events/index.ts
|
|
26748
26978
|
var events_exports = {};
|
|
26749
26979
|
__export(events_exports, {
|