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.mjs
CHANGED
|
@@ -12765,6 +12765,27 @@ var WalletAccountV5 = class _WalletAccountV5 extends Account {
|
|
|
12765
12765
|
// TODO: MISSING ESTIMATES
|
|
12766
12766
|
};
|
|
12767
12767
|
|
|
12768
|
+
// src/wallet/adapterV6.ts
|
|
12769
|
+
function toWalletApiCall(call) {
|
|
12770
|
+
return {
|
|
12771
|
+
contract_address: call.contractAddress,
|
|
12772
|
+
entry_point: call.entrypoint,
|
|
12773
|
+
calldata: CallData.toHex(call.calldata)
|
|
12774
|
+
};
|
|
12775
|
+
}
|
|
12776
|
+
function fromWalletApiCall(call) {
|
|
12777
|
+
return {
|
|
12778
|
+
contractAddress: call.contract_address,
|
|
12779
|
+
entrypoint: call.entry_point,
|
|
12780
|
+
calldata: call.calldata ?? []
|
|
12781
|
+
};
|
|
12782
|
+
}
|
|
12783
|
+
function toWalletApiActions(actions) {
|
|
12784
|
+
return actions.map(
|
|
12785
|
+
(action) => action.type === "subaccount_invoke" ? { ...action, calls: action.calls.map(toWalletApiCall) } : action
|
|
12786
|
+
);
|
|
12787
|
+
}
|
|
12788
|
+
|
|
12768
12789
|
// src/wallet/connectV6.ts
|
|
12769
12790
|
var connectV6_exports = {};
|
|
12770
12791
|
__export(connectV6_exports, {
|
|
@@ -12780,6 +12801,7 @@ __export(connectV6_exports, {
|
|
|
12780
12801
|
strk20Balances: () => strk20Balances,
|
|
12781
12802
|
strk20InvokeTransaction: () => strk20InvokeTransaction,
|
|
12782
12803
|
strk20PrepareInvoke: () => strk20PrepareInvoke,
|
|
12804
|
+
strk20SubaccountCommitment: () => strk20SubaccountCommitment,
|
|
12783
12805
|
subscribeWalletEvent: () => subscribeWalletEvent2,
|
|
12784
12806
|
supportedSpecs: () => supportedSpecs3,
|
|
12785
12807
|
supportedWalletApi: () => supportedWalletApi3,
|
|
@@ -12867,6 +12889,12 @@ function strk20InvokeTransaction(walletWSF, actions) {
|
|
|
12867
12889
|
params: { actions }
|
|
12868
12890
|
});
|
|
12869
12891
|
}
|
|
12892
|
+
function strk20SubaccountCommitment(walletWSF, dapp_name, nonce) {
|
|
12893
|
+
return walletWSF.features["starknet:walletApi"].request({
|
|
12894
|
+
type: "wallet_strk20SubaccountCommitment",
|
|
12895
|
+
params: { dapp_name, nonce }
|
|
12896
|
+
});
|
|
12897
|
+
}
|
|
12870
12898
|
|
|
12871
12899
|
// src/wallet/accountV6.ts
|
|
12872
12900
|
var WalletAccountV6 = class _WalletAccountV6 extends WalletAccountV5 {
|
|
@@ -12880,22 +12908,100 @@ var WalletAccountV6 = class _WalletAccountV6 extends WalletAccountV5 {
|
|
|
12880
12908
|
switchStarknetChain(chainId, silent_mode = false) {
|
|
12881
12909
|
return switchStarknetChain3(this.v6Provider, chainId, silent_mode);
|
|
12882
12910
|
}
|
|
12911
|
+
/**
|
|
12912
|
+
* Execute call(s) with an optional STRK20 privacy proof attached. Same signature as
|
|
12913
|
+
* `execute()`, with an extra parameter for the proof provided by `strk20PrepareInvoke()`.
|
|
12914
|
+
* @param {AllowArray<Call>} calls - The call(s) to invoke.
|
|
12915
|
+
* @param {STRK20_PROOF} [proof] - The SNIP-36 zero-knowledge proof to attach.
|
|
12916
|
+
* @returns {Promise<AddInvokeTransactionResult>} The hash of the submitted transaction.
|
|
12917
|
+
* @example
|
|
12918
|
+
* ```typescript
|
|
12919
|
+
* const { proof } = await myWalletAccount.strk20PrepareInvoke(actions);
|
|
12920
|
+
* const result = await myWalletAccount.executeWithProof(myContract.populate('claim'), proof);
|
|
12921
|
+
* // result = { transaction_hash: '0x6f7d...' }
|
|
12922
|
+
* ```
|
|
12923
|
+
*/
|
|
12883
12924
|
executeWithProof(calls, proof) {
|
|
12884
|
-
const txCalls = [].concat(calls).map(
|
|
12885
|
-
contract_address: it.contractAddress,
|
|
12886
|
-
entry_point: it.entrypoint,
|
|
12887
|
-
calldata: it.calldata
|
|
12888
|
-
}));
|
|
12925
|
+
const txCalls = [].concat(calls).map(toWalletApiCall);
|
|
12889
12926
|
return addInvokeTransaction3(this.v6Provider, { calls: txCalls, proof });
|
|
12890
12927
|
}
|
|
12928
|
+
/**
|
|
12929
|
+
* Get the private balances held by the user inside the STRK20 privacy pool.
|
|
12930
|
+
* @param {Address[]} tokens - The tokens to get the private balance of. An empty array returns every shielded token.
|
|
12931
|
+
* @returns {Promise<STRK20_BALANCE_ENTRY[]>} One entry per token.
|
|
12932
|
+
* @example
|
|
12933
|
+
* ```typescript
|
|
12934
|
+
* const balances = await myWalletAccount.strk20Balances([strkAddress]);
|
|
12935
|
+
* // balances = [{ token: '0x4718...', amount: '0x2386f26fc10000' }]
|
|
12936
|
+
* ```
|
|
12937
|
+
*/
|
|
12891
12938
|
strk20Balances(tokens) {
|
|
12892
12939
|
return strk20Balances(this.v6Provider, tokens);
|
|
12893
12940
|
}
|
|
12894
|
-
|
|
12895
|
-
|
|
12941
|
+
/**
|
|
12942
|
+
* Build the Starknet call and the SNIP-36 zero-knowledge proof of a STRK20 transaction,
|
|
12943
|
+
* without submitting it : the DAPP submits the returned call itself, and therefore pays
|
|
12944
|
+
* the fee (the wallet adds no fee action in this mode).
|
|
12945
|
+
*
|
|
12946
|
+
* With `simulate` set to true, the wallet skips the expensive proof generation and
|
|
12947
|
+
* returns an empty proof : the call is then NOT submittable on-chain, and is only useful
|
|
12948
|
+
* for fee estimation or UI previews.
|
|
12949
|
+
* @param {STRK20_ACTION[]} actions - The STRK20 actions to perform atomically (min 1).
|
|
12950
|
+
* @param {boolean} [simulate] - True to skip the proof generation.
|
|
12951
|
+
* @returns {Promise<STRK20_CALL_AND_PROOF>} The Starknet.js call to submit, and its proof.
|
|
12952
|
+
* @example
|
|
12953
|
+
* ```typescript
|
|
12954
|
+
* const { call, proof } = await myWalletAccount.strk20PrepareInvoke(actions);
|
|
12955
|
+
* const result = await mySponsorAccount.execute(call, {
|
|
12956
|
+
* proof: proof.data,
|
|
12957
|
+
* proofFacts: proof.proof_facts,
|
|
12958
|
+
* });
|
|
12959
|
+
* // result = { transaction_hash: '0x6f7d...' }
|
|
12960
|
+
* ```
|
|
12961
|
+
*/
|
|
12962
|
+
async strk20PrepareInvoke(actions, simulate) {
|
|
12963
|
+
const { call, proof } = await strk20PrepareInvoke(
|
|
12964
|
+
this.v6Provider,
|
|
12965
|
+
toWalletApiActions(actions),
|
|
12966
|
+
simulate
|
|
12967
|
+
);
|
|
12968
|
+
return { call: fromWalletApiCall(call), proof };
|
|
12896
12969
|
}
|
|
12970
|
+
/**
|
|
12971
|
+
* Submit STRK20 actions as a single atomic transaction. The wallet displays an approval
|
|
12972
|
+
* UI, generates the SNIP-36 proof, adds the fee action, and submits — so this call may
|
|
12973
|
+
* take significantly longer than a standard invoke.
|
|
12974
|
+
* @param {STRK20_ACTION[]} actions - The STRK20 actions to perform atomically (min 1).
|
|
12975
|
+
* @returns {Promise<{transaction_hash: string}>} The hash of the submitted transaction.
|
|
12976
|
+
* @example
|
|
12977
|
+
* ```typescript
|
|
12978
|
+
* const result = await myWalletAccount.strk20InvokeTransaction(actions);
|
|
12979
|
+
* // result = { transaction_hash: '0x6f7d...' }
|
|
12980
|
+
* ```
|
|
12981
|
+
*/
|
|
12897
12982
|
strk20InvokeTransaction(actions) {
|
|
12898
|
-
return strk20InvokeTransaction(this.v6Provider, actions);
|
|
12983
|
+
return strk20InvokeTransaction(this.v6Provider, toWalletApiActions(actions));
|
|
12984
|
+
}
|
|
12985
|
+
/**
|
|
12986
|
+
* Compute the commitment of a DAPP STRK20 sub-account. The commitment is computed
|
|
12987
|
+
* locally by the wallet from the user private state ; no transaction is sent.
|
|
12988
|
+
*
|
|
12989
|
+
* When `nonce` is given, the full commitment of this single sub-account is returned.
|
|
12990
|
+
* When `nonce` is omitted, the partial (nonce independent) commitment is returned
|
|
12991
|
+
* instead : it is shared by every sub-account the user derives for this DAPP, so it can
|
|
12992
|
+
* be published once to let a DAPP recognize all the sub-accounts of a user without
|
|
12993
|
+
* learning any individual nonce.
|
|
12994
|
+
* @param {STRK20_DAPP_NAME} dappName - The DAPP that scopes the sub-account(s).
|
|
12995
|
+
* @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.
|
|
12996
|
+
* @returns {Promise<FELT>} The sub-account commitment.
|
|
12997
|
+
* @example
|
|
12998
|
+
* ```typescript
|
|
12999
|
+
* const commitment = await myWalletAccount.strk20SubaccountCommitment('myDapp', '0x0');
|
|
13000
|
+
* // commitment = '0x5f2e...'
|
|
13001
|
+
* ```
|
|
13002
|
+
*/
|
|
13003
|
+
strk20SubaccountCommitment(dappName, nonce) {
|
|
13004
|
+
return strk20SubaccountCommitment(this.v6Provider, dappName, nonce);
|
|
12899
13005
|
}
|
|
12900
13006
|
static async connect(provider, walletProvider, cairoVersion, paymaster, silentMode = false) {
|
|
12901
13007
|
const { accounts } = await standardConnect2(walletProvider, silentMode);
|