starknet 10.5.2 → 10.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 +12 -0
- package/dist/index.d.ts +190 -21
- package/dist/index.global.js +114 -8
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +114 -8
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +114 -8
- package/dist/index.mjs.map +1 -1
- package/package.json +3 -2
package/dist/index.js
CHANGED
|
@@ -12948,6 +12948,27 @@ var WalletAccountV5 = class _WalletAccountV5 extends Account {
|
|
|
12948
12948
|
// TODO: MISSING ESTIMATES
|
|
12949
12949
|
};
|
|
12950
12950
|
|
|
12951
|
+
// src/wallet/adapterV6.ts
|
|
12952
|
+
function toWalletApiCall(call) {
|
|
12953
|
+
return {
|
|
12954
|
+
contract_address: call.contractAddress,
|
|
12955
|
+
entry_point: call.entrypoint,
|
|
12956
|
+
calldata: CallData.toHex(call.calldata)
|
|
12957
|
+
};
|
|
12958
|
+
}
|
|
12959
|
+
function fromWalletApiCall(call) {
|
|
12960
|
+
return {
|
|
12961
|
+
contractAddress: call.contract_address,
|
|
12962
|
+
entrypoint: call.entry_point,
|
|
12963
|
+
calldata: call.calldata ?? []
|
|
12964
|
+
};
|
|
12965
|
+
}
|
|
12966
|
+
function toWalletApiActions(actions) {
|
|
12967
|
+
return actions.map(
|
|
12968
|
+
(action) => action.type === "subaccount_invoke" ? { ...action, calls: action.calls.map(toWalletApiCall) } : action
|
|
12969
|
+
);
|
|
12970
|
+
}
|
|
12971
|
+
|
|
12951
12972
|
// src/wallet/connectV6.ts
|
|
12952
12973
|
var connectV6_exports = {};
|
|
12953
12974
|
__export(connectV6_exports, {
|
|
@@ -12963,6 +12984,7 @@ __export(connectV6_exports, {
|
|
|
12963
12984
|
strk20Balances: () => strk20Balances,
|
|
12964
12985
|
strk20InvokeTransaction: () => strk20InvokeTransaction,
|
|
12965
12986
|
strk20PrepareInvoke: () => strk20PrepareInvoke,
|
|
12987
|
+
strk20SubaccountCommitment: () => strk20SubaccountCommitment,
|
|
12966
12988
|
subscribeWalletEvent: () => subscribeWalletEvent2,
|
|
12967
12989
|
supportedSpecs: () => supportedSpecs3,
|
|
12968
12990
|
supportedWalletApi: () => supportedWalletApi3,
|
|
@@ -13050,6 +13072,12 @@ function strk20InvokeTransaction(walletWSF, actions) {
|
|
|
13050
13072
|
params: { actions }
|
|
13051
13073
|
});
|
|
13052
13074
|
}
|
|
13075
|
+
function strk20SubaccountCommitment(walletWSF, dapp_name, nonce) {
|
|
13076
|
+
return walletWSF.features["starknet:walletApi"].request({
|
|
13077
|
+
type: "wallet_strk20SubaccountCommitment",
|
|
13078
|
+
params: { dapp_name, nonce }
|
|
13079
|
+
});
|
|
13080
|
+
}
|
|
13053
13081
|
|
|
13054
13082
|
// src/wallet/accountV6.ts
|
|
13055
13083
|
var WalletAccountV6 = class _WalletAccountV6 extends WalletAccountV5 {
|
|
@@ -13063,22 +13091,100 @@ var WalletAccountV6 = class _WalletAccountV6 extends WalletAccountV5 {
|
|
|
13063
13091
|
switchStarknetChain(chainId, silent_mode = false) {
|
|
13064
13092
|
return switchStarknetChain3(this.v6Provider, chainId, silent_mode);
|
|
13065
13093
|
}
|
|
13094
|
+
/**
|
|
13095
|
+
* Execute call(s) with an optional STRK20 privacy proof attached. Same signature as
|
|
13096
|
+
* `execute()`, with an extra parameter for the proof provided by `strk20PrepareInvoke()`.
|
|
13097
|
+
* @param {AllowArray<Call>} calls - The call(s) to invoke.
|
|
13098
|
+
* @param {STRK20_PROOF} [proof] - The SNIP-36 zero-knowledge proof to attach.
|
|
13099
|
+
* @returns {Promise<AddInvokeTransactionResult>} The hash of the submitted transaction.
|
|
13100
|
+
* @example
|
|
13101
|
+
* ```typescript
|
|
13102
|
+
* const { proof } = await myWalletAccount.strk20PrepareInvoke(actions);
|
|
13103
|
+
* const result = await myWalletAccount.executeWithProof(myContract.populate('claim'), proof);
|
|
13104
|
+
* // result = { transaction_hash: '0x6f7d...' }
|
|
13105
|
+
* ```
|
|
13106
|
+
*/
|
|
13066
13107
|
executeWithProof(calls, proof) {
|
|
13067
|
-
const txCalls = [].concat(calls).map(
|
|
13068
|
-
contract_address: it.contractAddress,
|
|
13069
|
-
entry_point: it.entrypoint,
|
|
13070
|
-
calldata: it.calldata
|
|
13071
|
-
}));
|
|
13108
|
+
const txCalls = [].concat(calls).map(toWalletApiCall);
|
|
13072
13109
|
return addInvokeTransaction3(this.v6Provider, { calls: txCalls, proof });
|
|
13073
13110
|
}
|
|
13111
|
+
/**
|
|
13112
|
+
* Get the private balances held by the user inside the STRK20 privacy pool.
|
|
13113
|
+
* @param {Address[]} tokens - The tokens to get the private balance of. An empty array returns every shielded token.
|
|
13114
|
+
* @returns {Promise<STRK20_BALANCE_ENTRY[]>} One entry per token.
|
|
13115
|
+
* @example
|
|
13116
|
+
* ```typescript
|
|
13117
|
+
* const balances = await myWalletAccount.strk20Balances([strkAddress]);
|
|
13118
|
+
* // balances = [{ token: '0x4718...', amount: '0x2386f26fc10000' }]
|
|
13119
|
+
* ```
|
|
13120
|
+
*/
|
|
13074
13121
|
strk20Balances(tokens) {
|
|
13075
13122
|
return strk20Balances(this.v6Provider, tokens);
|
|
13076
13123
|
}
|
|
13077
|
-
|
|
13078
|
-
|
|
13124
|
+
/**
|
|
13125
|
+
* Build the Starknet call and the SNIP-36 zero-knowledge proof of a STRK20 transaction,
|
|
13126
|
+
* without submitting it : the DAPP submits the returned call itself, and therefore pays
|
|
13127
|
+
* the fee (the wallet adds no fee action in this mode).
|
|
13128
|
+
*
|
|
13129
|
+
* With `simulate` set to true, the wallet skips the expensive proof generation and
|
|
13130
|
+
* returns an empty proof : the call is then NOT submittable on-chain, and is only useful
|
|
13131
|
+
* for fee estimation or UI previews.
|
|
13132
|
+
* @param {STRK20_ACTION[]} actions - The STRK20 actions to perform atomically (min 1).
|
|
13133
|
+
* @param {boolean} [simulate] - True to skip the proof generation.
|
|
13134
|
+
* @returns {Promise<STRK20_CALL_AND_PROOF>} The Starknet.js call to submit, and its proof.
|
|
13135
|
+
* @example
|
|
13136
|
+
* ```typescript
|
|
13137
|
+
* const { call, proof } = await myWalletAccount.strk20PrepareInvoke(actions);
|
|
13138
|
+
* const result = await mySponsorAccount.execute(call, {
|
|
13139
|
+
* proof: proof.data,
|
|
13140
|
+
* proofFacts: proof.proof_facts,
|
|
13141
|
+
* });
|
|
13142
|
+
* // result = { transaction_hash: '0x6f7d...' }
|
|
13143
|
+
* ```
|
|
13144
|
+
*/
|
|
13145
|
+
async strk20PrepareInvoke(actions, simulate) {
|
|
13146
|
+
const { call, proof } = await strk20PrepareInvoke(
|
|
13147
|
+
this.v6Provider,
|
|
13148
|
+
toWalletApiActions(actions),
|
|
13149
|
+
simulate
|
|
13150
|
+
);
|
|
13151
|
+
return { call: fromWalletApiCall(call), proof };
|
|
13079
13152
|
}
|
|
13153
|
+
/**
|
|
13154
|
+
* Submit STRK20 actions as a single atomic transaction. The wallet displays an approval
|
|
13155
|
+
* UI, generates the SNIP-36 proof, adds the fee action, and submits — so this call may
|
|
13156
|
+
* take significantly longer than a standard invoke.
|
|
13157
|
+
* @param {STRK20_ACTION[]} actions - The STRK20 actions to perform atomically (min 1).
|
|
13158
|
+
* @returns {Promise<{transaction_hash: string}>} The hash of the submitted transaction.
|
|
13159
|
+
* @example
|
|
13160
|
+
* ```typescript
|
|
13161
|
+
* const result = await myWalletAccount.strk20InvokeTransaction(actions);
|
|
13162
|
+
* // result = { transaction_hash: '0x6f7d...' }
|
|
13163
|
+
* ```
|
|
13164
|
+
*/
|
|
13080
13165
|
strk20InvokeTransaction(actions) {
|
|
13081
|
-
return strk20InvokeTransaction(this.v6Provider, actions);
|
|
13166
|
+
return strk20InvokeTransaction(this.v6Provider, toWalletApiActions(actions));
|
|
13167
|
+
}
|
|
13168
|
+
/**
|
|
13169
|
+
* Compute the commitment of a DAPP STRK20 sub-account. The commitment is computed
|
|
13170
|
+
* locally by the wallet from the user private state ; no transaction is sent.
|
|
13171
|
+
*
|
|
13172
|
+
* When `nonce` is given, the full commitment of this single sub-account is returned.
|
|
13173
|
+
* When `nonce` is omitted, the partial (nonce independent) commitment is returned
|
|
13174
|
+
* instead : it is shared by every sub-account the user derives for this DAPP, so it can
|
|
13175
|
+
* be published once to let a DAPP recognize all the sub-accounts of a user without
|
|
13176
|
+
* learning any individual nonce.
|
|
13177
|
+
* @param {STRK20_DAPP_NAME} dappName - The DAPP that scopes the sub-account(s).
|
|
13178
|
+
* @param {FELT} [nonce] - The sub-account nonce ; each nonce selects a distinct sub-account for this user + DAPP. Omit it to get the partial commitment.
|
|
13179
|
+
* @returns {Promise<FELT>} The sub-account commitment.
|
|
13180
|
+
* @example
|
|
13181
|
+
* ```typescript
|
|
13182
|
+
* const commitment = await myWalletAccount.strk20SubaccountCommitment('myDapp', '0x0');
|
|
13183
|
+
* // commitment = '0x5f2e...'
|
|
13184
|
+
* ```
|
|
13185
|
+
*/
|
|
13186
|
+
strk20SubaccountCommitment(dappName, nonce) {
|
|
13187
|
+
return strk20SubaccountCommitment(this.v6Provider, dappName, nonce);
|
|
13082
13188
|
}
|
|
13083
13189
|
static async connect(provider, walletProvider, cairoVersion, paymaster, silentMode = false) {
|
|
13084
13190
|
const { accounts } = await standardConnect2(walletProvider, silentMode);
|