@dynamic-labs/ethereum-aa 4.10.4-preview.0 → 4.10.4

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.
@@ -1,29 +0,0 @@
1
- 'use client'
2
- 'use strict';
3
-
4
- Object.defineProperty(exports, '__esModule', { value: true });
5
-
6
- var _tslib = require('../../_virtual/_tslib.cjs');
7
- var viem = require('viem');
8
- var zksync = require('viem/zksync');
9
- var ecdsaAccount = require('./ecdsaAccount.cjs');
10
- var walletActions = require('./walletActions.cjs');
11
-
12
- const createZksyncEcdsaClient = (_parameters) => _tslib.__awaiter(void 0, void 0, void 0, function* () {
13
- const parameters = Object.assign(Object.assign({}, _parameters), { address: viem.getAddress(_parameters.address), key: _parameters.key || 'zksync-sso-ecdsa-wallet', name: _parameters.name || 'ZKsync SSO ECDSA Client' });
14
- const account = yield ecdsaAccount.toEcdsaAccount({
15
- address: parameters.address,
16
- owner: parameters.owner,
17
- });
18
- const client = viem.createClient(Object.assign(Object.assign({}, parameters), { account, type: 'walletClient' }))
19
- .extend(() => ({
20
- contracts: parameters.contracts,
21
- }))
22
- .extend(viem.publicActions)
23
- .extend(viem.walletActions)
24
- .extend(zksync.eip712WalletActions())
25
- .extend(walletActions.zksyncSsoEcdsaWalletActions);
26
- return client;
27
- });
28
-
29
- exports.createZksyncEcdsaClient = createZksyncEcdsaClient;
@@ -1,24 +0,0 @@
1
- import { type Account, type Address, type Chain, type Client, type Prettify, type PublicActions, type PublicRpcSchema, type RpcSchema, type Transport, type WalletActions, type WalletClientConfig, type WalletRpcSchema } from 'viem';
2
- import { CustomPaymasterHandler } from 'zksync-sso/paymaster';
3
- import { Signer } from './types';
4
- export declare const createZksyncEcdsaClient: <transport extends Transport, chain extends Chain, rpcSchema extends RpcSchema | undefined = undefined>(_parameters: ZksyncSsoEcdsaClientConfig<transport, chain, rpcSchema>) => Promise<ZksyncSsoEcdsaClient<transport, chain, rpcSchema>>;
5
- export type EcdsaRequiredContracts = {
6
- session: Address;
7
- accountFactory?: Address;
8
- };
9
- type ZksyncSsoEcdsaData = {
10
- contracts: EcdsaRequiredContracts;
11
- paymasterHandler?: CustomPaymasterHandler;
12
- };
13
- export type ClientWithZksyncSsoEcdsaData<transport extends Transport = Transport, chain extends Chain = Chain> = Client<transport, chain, Account> & ZksyncSsoEcdsaData;
14
- export type ZksyncSsoEcdsaClient<transport extends Transport = Transport, chain extends Chain = Chain, rpcSchema extends RpcSchema | undefined = undefined, account extends Account = Account> = Prettify<Client<transport, chain, account, rpcSchema extends RpcSchema ? [...PublicRpcSchema, ...WalletRpcSchema, ...rpcSchema] : [...PublicRpcSchema, ...WalletRpcSchema], PublicActions<transport, chain, account> & WalletActions<chain, account>> & ZksyncSsoEcdsaData>;
15
- export interface ZksyncSsoEcdsaClientConfig<transport extends Transport = Transport, chain extends Chain = Chain, rpcSchema extends RpcSchema | undefined = undefined> extends Omit<WalletClientConfig<transport, chain, Account, rpcSchema>, 'account'> {
16
- chain: NonNullable<chain>;
17
- address: Address;
18
- owner: Signer;
19
- contracts: EcdsaRequiredContracts;
20
- key?: string;
21
- name?: string;
22
- paymasterHandler?: CustomPaymasterHandler;
23
- }
24
- export {};
@@ -1,25 +0,0 @@
1
- 'use client'
2
- import { __awaiter } from '../../_virtual/_tslib.js';
3
- import { getAddress, createClient, publicActions, walletActions } from 'viem';
4
- import { eip712WalletActions } from 'viem/zksync';
5
- import { toEcdsaAccount } from './ecdsaAccount.js';
6
- import { zksyncSsoEcdsaWalletActions } from './walletActions.js';
7
-
8
- const createZksyncEcdsaClient = (_parameters) => __awaiter(void 0, void 0, void 0, function* () {
9
- const parameters = Object.assign(Object.assign({}, _parameters), { address: getAddress(_parameters.address), key: _parameters.key || 'zksync-sso-ecdsa-wallet', name: _parameters.name || 'ZKsync SSO ECDSA Client' });
10
- const account = yield toEcdsaAccount({
11
- address: parameters.address,
12
- owner: parameters.owner,
13
- });
14
- const client = createClient(Object.assign(Object.assign({}, parameters), { account, type: 'walletClient' }))
15
- .extend(() => ({
16
- contracts: parameters.contracts,
17
- }))
18
- .extend(publicActions)
19
- .extend(walletActions)
20
- .extend(eip712WalletActions())
21
- .extend(zksyncSsoEcdsaWalletActions);
22
- return client;
23
- });
24
-
25
- export { createZksyncEcdsaClient };
@@ -1,32 +0,0 @@
1
- 'use client'
2
- 'use strict';
3
-
4
- Object.defineProperty(exports, '__esModule', { value: true });
5
-
6
- var _tslib = require('../../_virtual/_tslib.cjs');
7
- var accounts = require('viem/accounts');
8
- var zksync = require('viem/zksync');
9
- var types = require('./types.cjs');
10
- var getEip712Domain = require('./getEip712Domain.cjs');
11
-
12
- const toEcdsaAccount = (parameters) => _tslib.__awaiter(void 0, void 0, void 0, function* () {
13
- const { address, owner } = parameters;
14
- const localOwner = yield types.toOwner({ address, owner });
15
- if (!address) {
16
- throw new Error('Address is required');
17
- }
18
- const account = accounts.toAccount({
19
- address,
20
- signMessage: (_a) => _tslib.__awaiter(void 0, [_a], void 0, function* ({ message }) { return localOwner.signMessage({ message }); }),
21
- signTransaction: (transaction) => _tslib.__awaiter(void 0, void 0, void 0, function* () {
22
- const signableTransaction = Object.assign(Object.assign({}, transaction), { from: address, type: 'eip712' });
23
- const eip712DomainAndMessage = getEip712Domain.getEip712Domain(signableTransaction);
24
- const signature = yield localOwner.signTypedData(eip712DomainAndMessage);
25
- return zksync.serializeTransaction(Object.assign(Object.assign({}, signableTransaction), { customSignature: signature }));
26
- }),
27
- signTypedData: (typedData) => localOwner.signTypedData(typedData),
28
- });
29
- return Object.assign(Object.assign({}, account), { source: 'ssoEcdsaAccount' });
30
- });
31
-
32
- exports.toEcdsaAccount = toEcdsaAccount;
@@ -1,13 +0,0 @@
1
- import type { Address } from 'abitype';
2
- import { type CustomSource, type LocalAccount } from 'viem';
3
- import { type Signer } from './types';
4
- export type ToEcdsaAccountParameters = {
5
- /** Address of the deployed SSO Wallet */
6
- address: Address;
7
- /** Owner of the EOA */
8
- owner: Signer;
9
- };
10
- export type EcdsaAccount = LocalAccount<'ssoEcdsaAccount'> & {
11
- sign: NonNullable<CustomSource['sign']>;
12
- };
13
- export declare const toEcdsaAccount: (parameters: ToEcdsaAccountParameters) => Promise<EcdsaAccount>;
@@ -1,28 +0,0 @@
1
- 'use client'
2
- import { __awaiter } from '../../_virtual/_tslib.js';
3
- import { toAccount } from 'viem/accounts';
4
- import { serializeTransaction } from 'viem/zksync';
5
- import { toOwner } from './types.js';
6
- import { getEip712Domain } from './getEip712Domain.js';
7
-
8
- const toEcdsaAccount = (parameters) => __awaiter(void 0, void 0, void 0, function* () {
9
- const { address, owner } = parameters;
10
- const localOwner = yield toOwner({ address, owner });
11
- if (!address) {
12
- throw new Error('Address is required');
13
- }
14
- const account = toAccount({
15
- address,
16
- signMessage: (_a) => __awaiter(void 0, [_a], void 0, function* ({ message }) { return localOwner.signMessage({ message }); }),
17
- signTransaction: (transaction) => __awaiter(void 0, void 0, void 0, function* () {
18
- const signableTransaction = Object.assign(Object.assign({}, transaction), { from: address, type: 'eip712' });
19
- const eip712DomainAndMessage = getEip712Domain(signableTransaction);
20
- const signature = yield localOwner.signTypedData(eip712DomainAndMessage);
21
- return serializeTransaction(Object.assign(Object.assign({}, signableTransaction), { customSignature: signature }));
22
- }),
23
- signTypedData: (typedData) => localOwner.signTypedData(typedData),
24
- });
25
- return Object.assign(Object.assign({}, account), { source: 'ssoEcdsaAccount' });
26
- });
27
-
28
- export { toEcdsaAccount };
@@ -1,62 +0,0 @@
1
- 'use client'
2
- 'use strict';
3
-
4
- Object.defineProperty(exports, '__esModule', { value: true });
5
-
6
- var viem = require('viem');
7
- var zksync = require('viem/zksync');
8
-
9
- const gasPerPubdataDefault = BigInt(50000);
10
- const getEip712Domain = (transaction) => {
11
- const message = transactionToMessage(transaction);
12
- return {
13
- domain: {
14
- chainId: transaction.chainId,
15
- // cspell:ignore zkSync
16
- name: 'zkSync',
17
- version: '2',
18
- },
19
- message: message,
20
- primaryType: 'Transaction',
21
- types: {
22
- Transaction: [
23
- { name: 'txType', type: 'uint256' },
24
- { name: 'from', type: 'uint256' },
25
- { name: 'to', type: 'uint256' },
26
- { name: 'gasLimit', type: 'uint256' },
27
- { name: 'gasPerPubdataByteLimit', type: 'uint256' },
28
- { name: 'maxFeePerGas', type: 'uint256' },
29
- { name: 'maxPriorityFeePerGas', type: 'uint256' },
30
- { name: 'paymaster', type: 'uint256' },
31
- { name: 'nonce', type: 'uint256' },
32
- { name: 'value', type: 'uint256' },
33
- { name: 'data', type: 'bytes' },
34
- { name: 'factoryDeps', type: 'bytes32[]' },
35
- { name: 'paymasterInput', type: 'bytes' },
36
- ],
37
- },
38
- };
39
- };
40
- //////////////////////////////////////////////////////////////////////////////
41
- // Utilities
42
- const transactionToMessage = (transaction) => {
43
- var _a;
44
- const { gas, nonce, to, from, value, maxFeePerGas, maxPriorityFeePerGas, factoryDeps, paymaster, paymasterInput, gasPerPubdata, data, } = transaction;
45
- return {
46
- data: data ? data : '0x0',
47
- factoryDeps: (_a = factoryDeps === null || factoryDeps === void 0 ? void 0 : factoryDeps.map((dep) => viem.toHex(zksync.hashBytecode(dep)))) !== null && _a !== void 0 ? _a : [],
48
- from: BigInt(from),
49
- gasLimit: gas !== null && gas !== void 0 ? gas : BigInt(0),
50
- gasPerPubdataByteLimit: gasPerPubdata !== null && gasPerPubdata !== void 0 ? gasPerPubdata : gasPerPubdataDefault,
51
- maxFeePerGas: maxFeePerGas !== null && maxFeePerGas !== void 0 ? maxFeePerGas : BigInt(0),
52
- maxPriorityFeePerGas: maxPriorityFeePerGas !== null && maxPriorityFeePerGas !== void 0 ? maxPriorityFeePerGas : BigInt(0),
53
- nonce: nonce ? BigInt(nonce) : BigInt(0),
54
- paymaster: paymaster ? BigInt(paymaster) : BigInt(0),
55
- paymasterInput: paymasterInput ? paymasterInput : '0x',
56
- to: to ? BigInt(to) : BigInt(0),
57
- txType: BigInt(113),
58
- value: value !== null && value !== void 0 ? value : BigInt(0),
59
- };
60
- };
61
-
62
- exports.getEip712Domain = getEip712Domain;
@@ -1,2 +0,0 @@
1
- import { type EIP712DomainFn, type ZksyncEIP712TransactionSignable, type ZksyncTransactionSerializable } from 'viem/zksync';
2
- export declare const getEip712Domain: EIP712DomainFn<ZksyncTransactionSerializable, ZksyncEIP712TransactionSignable>;
@@ -1,58 +0,0 @@
1
- 'use client'
2
- import { toHex } from 'viem';
3
- import { hashBytecode } from 'viem/zksync';
4
-
5
- const gasPerPubdataDefault = BigInt(50000);
6
- const getEip712Domain = (transaction) => {
7
- const message = transactionToMessage(transaction);
8
- return {
9
- domain: {
10
- chainId: transaction.chainId,
11
- // cspell:ignore zkSync
12
- name: 'zkSync',
13
- version: '2',
14
- },
15
- message: message,
16
- primaryType: 'Transaction',
17
- types: {
18
- Transaction: [
19
- { name: 'txType', type: 'uint256' },
20
- { name: 'from', type: 'uint256' },
21
- { name: 'to', type: 'uint256' },
22
- { name: 'gasLimit', type: 'uint256' },
23
- { name: 'gasPerPubdataByteLimit', type: 'uint256' },
24
- { name: 'maxFeePerGas', type: 'uint256' },
25
- { name: 'maxPriorityFeePerGas', type: 'uint256' },
26
- { name: 'paymaster', type: 'uint256' },
27
- { name: 'nonce', type: 'uint256' },
28
- { name: 'value', type: 'uint256' },
29
- { name: 'data', type: 'bytes' },
30
- { name: 'factoryDeps', type: 'bytes32[]' },
31
- { name: 'paymasterInput', type: 'bytes' },
32
- ],
33
- },
34
- };
35
- };
36
- //////////////////////////////////////////////////////////////////////////////
37
- // Utilities
38
- const transactionToMessage = (transaction) => {
39
- var _a;
40
- const { gas, nonce, to, from, value, maxFeePerGas, maxPriorityFeePerGas, factoryDeps, paymaster, paymasterInput, gasPerPubdata, data, } = transaction;
41
- return {
42
- data: data ? data : '0x0',
43
- factoryDeps: (_a = factoryDeps === null || factoryDeps === void 0 ? void 0 : factoryDeps.map((dep) => toHex(hashBytecode(dep)))) !== null && _a !== void 0 ? _a : [],
44
- from: BigInt(from),
45
- gasLimit: gas !== null && gas !== void 0 ? gas : BigInt(0),
46
- gasPerPubdataByteLimit: gasPerPubdata !== null && gasPerPubdata !== void 0 ? gasPerPubdata : gasPerPubdataDefault,
47
- maxFeePerGas: maxFeePerGas !== null && maxFeePerGas !== void 0 ? maxFeePerGas : BigInt(0),
48
- maxPriorityFeePerGas: maxPriorityFeePerGas !== null && maxPriorityFeePerGas !== void 0 ? maxPriorityFeePerGas : BigInt(0),
49
- nonce: nonce ? BigInt(nonce) : BigInt(0),
50
- paymaster: paymaster ? BigInt(paymaster) : BigInt(0),
51
- paymasterInput: paymasterInput ? paymasterInput : '0x',
52
- to: to ? BigInt(to) : BigInt(0),
53
- txType: BigInt(113),
54
- value: value !== null && value !== void 0 ? value : BigInt(0),
55
- };
56
- };
57
-
58
- export { getEip712Domain };
@@ -1,52 +0,0 @@
1
- 'use client'
2
- 'use strict';
3
-
4
- Object.defineProperty(exports, '__esModule', { value: true });
5
-
6
- var _tslib = require('../../_virtual/_tslib.cjs');
7
- var viem = require('viem');
8
- var accounts = require('viem/accounts');
9
- var actions = require('viem/actions');
10
- var utils = require('viem/utils');
11
-
12
- const toOwner = (_a) => _tslib.__awaiter(void 0, [_a], void 0, function* ({ owner, address, }) {
13
- if ('type' in owner && owner.type === 'local') {
14
- return owner;
15
- }
16
- let walletClient = undefined;
17
- if ('request' in owner) {
18
- if (!address) {
19
- try {
20
- [address] = yield owner.request({
21
- method: 'eth_requestAccounts',
22
- });
23
- }
24
- catch (_b) {
25
- [address] = yield owner.request({
26
- method: 'eth_accounts',
27
- });
28
- }
29
- }
30
- if (!address) {
31
- // For TS to be happy
32
- throw new Error('address is required');
33
- }
34
- walletClient = viem.createWalletClient({
35
- account: address,
36
- transport: viem.custom(owner),
37
- });
38
- }
39
- if (!walletClient) {
40
- walletClient = owner;
41
- }
42
- return accounts.toAccount({
43
- address: walletClient.account.address,
44
- signMessage: (_c) => _tslib.__awaiter(void 0, [_c], void 0, function* ({ message }) { return walletClient.signMessage({ message }); }),
45
- signTransaction: () => _tslib.__awaiter(void 0, void 0, void 0, function* () {
46
- throw new Error("Smart account signer doesn't need to sign transactions");
47
- }),
48
- signTypedData: (typedData) => _tslib.__awaiter(void 0, void 0, void 0, function* () { return utils.getAction(walletClient, actions.signTypedData, 'signTypedData')(typedData); }),
49
- });
50
- });
51
-
52
- exports.toOwner = toOwner;
@@ -1,9 +0,0 @@
1
- import { type Account, type Address, type Chain, type EIP1193Provider, type LocalAccount, type OneOf, type Transport, type WalletClient } from 'viem';
2
- export type Signer = OneOf<EIP1193Provider | WalletClient<Transport, Chain | undefined, Account> | LocalAccount>;
3
- export type EthereumProvider = OneOf<{
4
- request(...args: any): Promise<any>;
5
- } | EIP1193Provider>;
6
- export declare const toOwner: <provider extends EthereumProvider>({ owner, address, }: {
7
- owner: OneOf<provider | WalletClient<Transport, Chain | undefined, Account> | LocalAccount>;
8
- address: Address;
9
- }) => Promise<LocalAccount>;
@@ -1,48 +0,0 @@
1
- 'use client'
2
- import { __awaiter } from '../../_virtual/_tslib.js';
3
- import { createWalletClient, custom } from 'viem';
4
- import { toAccount } from 'viem/accounts';
5
- import { signTypedData } from 'viem/actions';
6
- import { getAction } from 'viem/utils';
7
-
8
- const toOwner = (_a) => __awaiter(void 0, [_a], void 0, function* ({ owner, address, }) {
9
- if ('type' in owner && owner.type === 'local') {
10
- return owner;
11
- }
12
- let walletClient = undefined;
13
- if ('request' in owner) {
14
- if (!address) {
15
- try {
16
- [address] = yield owner.request({
17
- method: 'eth_requestAccounts',
18
- });
19
- }
20
- catch (_b) {
21
- [address] = yield owner.request({
22
- method: 'eth_accounts',
23
- });
24
- }
25
- }
26
- if (!address) {
27
- // For TS to be happy
28
- throw new Error('address is required');
29
- }
30
- walletClient = createWalletClient({
31
- account: address,
32
- transport: custom(owner),
33
- });
34
- }
35
- if (!walletClient) {
36
- walletClient = owner;
37
- }
38
- return toAccount({
39
- address: walletClient.account.address,
40
- signMessage: (_c) => __awaiter(void 0, [_c], void 0, function* ({ message }) { return walletClient.signMessage({ message }); }),
41
- signTransaction: () => __awaiter(void 0, void 0, void 0, function* () {
42
- throw new Error("Smart account signer doesn't need to sign transactions");
43
- }),
44
- signTypedData: (typedData) => __awaiter(void 0, void 0, void 0, function* () { return getAction(walletClient, signTypedData, 'signTypedData')(typedData); }),
45
- });
46
- });
47
-
48
- export { toOwner };
@@ -1,93 +0,0 @@
1
- 'use client'
2
- 'use strict';
3
-
4
- Object.defineProperty(exports, '__esModule', { value: true });
5
-
6
- var _tslib = require('../../_virtual/_tslib.cjs');
7
- var viem = require('viem');
8
- var actions = require('viem/actions');
9
- var zksync = require('viem/zksync');
10
- var paymaster = require('zksync-sso/paymaster');
11
-
12
- const zksyncSsoEcdsaWalletActions = (client) => ({
13
- deployContract: (args) => actions.deployContract(client, args),
14
- getAddresses: () => actions.getAddresses(client),
15
- getChainId: () => actions.getChainId(client),
16
- sendRawTransaction: (args) => actions.sendRawTransaction(client, args),
17
- sendTransaction: (args) => _tslib.__awaiter(void 0, void 0, void 0, function* () {
18
- var _a, _b, _c, _d, _e;
19
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
20
- const unformattedTx = Object.assign({}, args);
21
- if ('eip712Meta' in unformattedTx) {
22
- const eip712Meta = unformattedTx.eip712Meta;
23
- unformattedTx.gasPerPubdata = eip712Meta.gasPerPubdata
24
- ? BigInt(eip712Meta.gasPerPubdata)
25
- : undefined;
26
- unformattedTx.factoryDeps = eip712Meta.factoryDeps;
27
- unformattedTx.customSignature = eip712Meta.customSignature;
28
- unformattedTx.paymaster = (_a = eip712Meta.paymasterParams) === null || _a === void 0 ? void 0 : _a.paymaster;
29
- unformattedTx.paymasterInput = ((_b = eip712Meta.paymasterParams) === null || _b === void 0 ? void 0 : _b.paymasterInput)
30
- ? viem.bytesToHex(new Uint8Array((_c = eip712Meta.paymasterParams) === null || _c === void 0 ? void 0 : _c.paymasterInput))
31
- : undefined;
32
- delete unformattedTx.eip712Meta;
33
- }
34
- /* eslint-disable @typescript-eslint/no-unused-vars */
35
- const _f = yield paymaster.getTransactionWithPaymasterData(client.chain.id, client.account.address, unformattedTx, client.paymasterHandler), unformattedTxWithPaymaster = _tslib.__rest(_f, ["chainId"]);
36
- const formatters = (_d = client.chain) === null || _d === void 0 ? void 0 : _d.formatters;
37
- const format = ((_e = formatters === null || formatters === void 0 ? void 0 : formatters.transaction) === null || _e === void 0 ? void 0 : _e.format) || viem.formatTransaction;
38
- const tx = Object.assign(Object.assign({}, format(unformattedTxWithPaymaster)), { type: 'eip712' });
39
- return yield sendEip712Transaction(client, tx);
40
- }),
41
- signMessage: (args) => actions.signMessage(client, args),
42
- signTransaction: (args) => _tslib.__awaiter(void 0, void 0, void 0, function* () {
43
- /* eslint-disable @typescript-eslint/no-unused-vars */
44
- const _g = yield paymaster.getTransactionWithPaymasterData(client.chain.id, client.account.address, args, client.paymasterHandler), unformattedTxWithPaymaster = _tslib.__rest(_g, ["chainId"]);
45
- return zksync.signTransaction(client, Object.assign(Object.assign({}, args), { type: 'eip712', unformattedTxWithPaymaster }));
46
- }),
47
- signTypedData: (args) => actions.signTypedData(client, args),
48
- writeContract: (args) => actions.writeContract(client, args),
49
- });
50
- const sendEip712Transaction = (client, parameters) => _tslib.__awaiter(void 0, void 0, void 0, function* () {
51
- var _h;
52
- const { account: account_ = client.account, chain = client.chain } = parameters, rest = _tslib.__rest(parameters, ["account", "chain"]);
53
- if (!account_)
54
- throw new Error('Account not found.');
55
- const { account } = client;
56
- if (!account)
57
- throw new Error('Account not found.');
58
- const request = yield getAction(client, actions.prepareTransactionRequest, 'prepareTransactionRequest')(Object.assign({ account,
59
- chain, nonceManager: account.nonceManager }, rest));
60
- const serializer = (_h = chain === null || chain === void 0 ? void 0 : chain.serializers) === null || _h === void 0 ? void 0 : _h.transaction;
61
- // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
62
- const serializedTransaction = (yield account.signTransaction(request, {
63
- serializer,
64
- }));
65
- return yield getAction(client, actions.sendRawTransaction, 'sendRawTransaction')({
66
- serializedTransaction,
67
- });
68
- });
69
- /**
70
- * Retrieves and returns an action from the client (if exists), and falls
71
- * back to the tree-shakable action.
72
- *
73
- * Useful for extracting overridden actions from a client (ie. if a consumer
74
- * wants to override the `sendTransaction` implementation).
75
- */
76
- const getAction = (client, actionFn,
77
- // cspell:ignore minifiers
78
- // Some minifiers drop `Function.prototype.name`, or replace it with short letters,
79
- // meaning that `actionFn.name` will not always work. For that case, the consumer
80
- // needs to pass the name explicitly.
81
- name) => {
82
- const action_implicit = client[actionFn.name];
83
- if (typeof action_implicit === 'function')
84
- return action_implicit;
85
- const action_explicit = client[name];
86
- if (typeof action_explicit === 'function')
87
- return action_explicit;
88
- return (params) => actionFn(client, params);
89
- };
90
-
91
- exports.getAction = getAction;
92
- exports.sendEip712Transaction = sendEip712Transaction;
93
- exports.zksyncSsoEcdsaWalletActions = zksyncSsoEcdsaWalletActions;
@@ -1,15 +0,0 @@
1
- import { type Account, type Chain, type Client, type PublicActions, type RpcSchema, type SendTransactionRequest, type Transport, type WalletActions } from 'viem';
2
- import { type ChainEIP712, type SendEip712TransactionParameters, type SendEip712TransactionReturnType } from 'viem/zksync';
3
- export type ZksyncSsoEcdsaWalletActions<chain extends Chain, account extends Account> = Omit<WalletActions<chain, account>, 'addChain' | 'getPermissions' | 'requestAddresses' | 'requestPermissions' | 'switchChain' | 'watchAsset' | 'prepareTransactionRequest'>;
4
- export declare const zksyncSsoEcdsaWalletActions: <transport extends Transport, chain extends Chain, account extends Account>(client: Client<transport, chain, account>) => any;
5
- export declare const sendEip712Transaction: <chain extends ChainEIP712 | undefined, account extends Account | undefined, request extends SendTransactionRequest<chain, chainOverride>, chainOverride extends ChainEIP712 | undefined = undefined>(client: Client<Transport, chain, account>, parameters: SendEip712TransactionParameters<chain, account, chainOverride, request>) => Promise<SendEip712TransactionReturnType>;
6
- /**
7
- * Retrieves and returns an action from the client (if exists), and falls
8
- * back to the tree-shakable action.
9
- *
10
- * Useful for extracting overridden actions from a client (ie. if a consumer
11
- * wants to override the `sendTransaction` implementation).
12
- */
13
- export declare const getAction: <transport extends Transport, chain extends Chain | undefined, account extends Account | undefined, rpcSchema extends RpcSchema | undefined, extended extends {
14
- [key: string]: unknown;
15
- }, client extends Client<transport, chain, account, rpcSchema, extended>, parameters, returnType>(client: client, actionFn: (_: any, parameters: parameters) => returnType, name: keyof PublicActions | keyof WalletActions | string) => ((parameters: parameters) => returnType);
@@ -1,87 +0,0 @@
1
- 'use client'
2
- import { __awaiter, __rest } from '../../_virtual/_tslib.js';
3
- import { bytesToHex, formatTransaction } from 'viem';
4
- import { deployContract, getAddresses, getChainId, sendRawTransaction, signMessage, signTypedData, writeContract, prepareTransactionRequest } from 'viem/actions';
5
- import { signTransaction } from 'viem/zksync';
6
- import { getTransactionWithPaymasterData } from 'zksync-sso/paymaster';
7
-
8
- const zksyncSsoEcdsaWalletActions = (client) => ({
9
- deployContract: (args) => deployContract(client, args),
10
- getAddresses: () => getAddresses(client),
11
- getChainId: () => getChainId(client),
12
- sendRawTransaction: (args) => sendRawTransaction(client, args),
13
- sendTransaction: (args) => __awaiter(void 0, void 0, void 0, function* () {
14
- var _a, _b, _c, _d, _e;
15
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
16
- const unformattedTx = Object.assign({}, args);
17
- if ('eip712Meta' in unformattedTx) {
18
- const eip712Meta = unformattedTx.eip712Meta;
19
- unformattedTx.gasPerPubdata = eip712Meta.gasPerPubdata
20
- ? BigInt(eip712Meta.gasPerPubdata)
21
- : undefined;
22
- unformattedTx.factoryDeps = eip712Meta.factoryDeps;
23
- unformattedTx.customSignature = eip712Meta.customSignature;
24
- unformattedTx.paymaster = (_a = eip712Meta.paymasterParams) === null || _a === void 0 ? void 0 : _a.paymaster;
25
- unformattedTx.paymasterInput = ((_b = eip712Meta.paymasterParams) === null || _b === void 0 ? void 0 : _b.paymasterInput)
26
- ? bytesToHex(new Uint8Array((_c = eip712Meta.paymasterParams) === null || _c === void 0 ? void 0 : _c.paymasterInput))
27
- : undefined;
28
- delete unformattedTx.eip712Meta;
29
- }
30
- /* eslint-disable @typescript-eslint/no-unused-vars */
31
- const _f = yield getTransactionWithPaymasterData(client.chain.id, client.account.address, unformattedTx, client.paymasterHandler), unformattedTxWithPaymaster = __rest(_f, ["chainId"]);
32
- const formatters = (_d = client.chain) === null || _d === void 0 ? void 0 : _d.formatters;
33
- const format = ((_e = formatters === null || formatters === void 0 ? void 0 : formatters.transaction) === null || _e === void 0 ? void 0 : _e.format) || formatTransaction;
34
- const tx = Object.assign(Object.assign({}, format(unformattedTxWithPaymaster)), { type: 'eip712' });
35
- return yield sendEip712Transaction(client, tx);
36
- }),
37
- signMessage: (args) => signMessage(client, args),
38
- signTransaction: (args) => __awaiter(void 0, void 0, void 0, function* () {
39
- /* eslint-disable @typescript-eslint/no-unused-vars */
40
- const _g = yield getTransactionWithPaymasterData(client.chain.id, client.account.address, args, client.paymasterHandler), unformattedTxWithPaymaster = __rest(_g, ["chainId"]);
41
- return signTransaction(client, Object.assign(Object.assign({}, args), { type: 'eip712', unformattedTxWithPaymaster }));
42
- }),
43
- signTypedData: (args) => signTypedData(client, args),
44
- writeContract: (args) => writeContract(client, args),
45
- });
46
- const sendEip712Transaction = (client, parameters) => __awaiter(void 0, void 0, void 0, function* () {
47
- var _h;
48
- const { account: account_ = client.account, chain = client.chain } = parameters, rest = __rest(parameters, ["account", "chain"]);
49
- if (!account_)
50
- throw new Error('Account not found.');
51
- const { account } = client;
52
- if (!account)
53
- throw new Error('Account not found.');
54
- const request = yield getAction(client, prepareTransactionRequest, 'prepareTransactionRequest')(Object.assign({ account,
55
- chain, nonceManager: account.nonceManager }, rest));
56
- const serializer = (_h = chain === null || chain === void 0 ? void 0 : chain.serializers) === null || _h === void 0 ? void 0 : _h.transaction;
57
- // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
58
- const serializedTransaction = (yield account.signTransaction(request, {
59
- serializer,
60
- }));
61
- return yield getAction(client, sendRawTransaction, 'sendRawTransaction')({
62
- serializedTransaction,
63
- });
64
- });
65
- /**
66
- * Retrieves and returns an action from the client (if exists), and falls
67
- * back to the tree-shakable action.
68
- *
69
- * Useful for extracting overridden actions from a client (ie. if a consumer
70
- * wants to override the `sendTransaction` implementation).
71
- */
72
- const getAction = (client, actionFn,
73
- // cspell:ignore minifiers
74
- // Some minifiers drop `Function.prototype.name`, or replace it with short letters,
75
- // meaning that `actionFn.name` will not always work. For that case, the consumer
76
- // needs to pass the name explicitly.
77
- name) => {
78
- const action_implicit = client[actionFn.name];
79
- if (typeof action_implicit === 'function')
80
- return action_implicit;
81
- const action_explicit = client[name];
82
- if (typeof action_explicit === 'function')
83
- return action_explicit;
84
- return (params) => actionFn(client, params);
85
- };
86
-
87
- export { getAction, sendEip712Transaction, zksyncSsoEcdsaWalletActions };