@alchemy/smart-accounts 5.0.0-beta.3 → 5.0.0-beta.30
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/README.md +45 -2
- package/dist/esm/index.d.ts +1 -7
- package/dist/esm/index.js +1 -4
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/light-account/accounts/base.js +0 -1
- package/dist/esm/light-account/accounts/base.js.map +1 -1
- package/dist/esm/light-account/accounts/calldataCodec.js +0 -3
- package/dist/esm/light-account/accounts/calldataCodec.js.map +1 -1
- package/dist/esm/light-account/utils.js +0 -5
- package/dist/esm/light-account/utils.js.map +1 -1
- package/dist/esm/ma-v1/accounts/base.js +1 -1
- package/dist/esm/ma-v1/accounts/base.js.map +1 -1
- package/dist/esm/ma-v1/accounts/calldataCodec.js +0 -4
- package/dist/esm/ma-v1/accounts/calldataCodec.js.map +1 -1
- package/dist/esm/ma-v1/mav1StaticImpl.d.ts +0 -2
- package/dist/esm/ma-v1/mav1StaticImpl.js +0 -2
- package/dist/esm/ma-v1/mav1StaticImpl.js.map +1 -1
- package/dist/esm/ma-v2/accounts/account.d.ts +39 -0
- package/dist/esm/ma-v2/accounts/account.js +40 -1
- package/dist/esm/ma-v2/accounts/account.js.map +1 -1
- package/dist/esm/ma-v2/accounts/base.js +1 -1
- package/dist/esm/ma-v2/accounts/base.js.map +1 -1
- package/dist/esm/ma-v2/accounts/calldataCodec.js +0 -4
- package/dist/esm/ma-v2/accounts/calldataCodec.js.map +1 -1
- package/dist/esm/ma-v2/decorators/deferralActions.d.ts +3 -3
- package/dist/esm/ma-v2/decorators/deferralActions.js +3 -3
- package/dist/esm/ma-v2/decorators/deferralActions.js.map +1 -1
- package/dist/esm/ma-v2/decorators/installValidation.d.ts +8 -20
- package/dist/esm/ma-v2/decorators/installValidation.js +7 -58
- package/dist/esm/ma-v2/decorators/installValidation.js.map +1 -1
- package/dist/esm/ma-v2/mav2StaticImpl.d.ts +0 -4
- package/dist/esm/ma-v2/mav2StaticImpl.js +0 -4
- package/dist/esm/ma-v2/mav2StaticImpl.js.map +1 -1
- package/dist/esm/ma-v2/permissionBuilder.d.ts +2 -2
- package/dist/esm/ma-v2/permissionBuilder.js +46 -14
- package/dist/esm/ma-v2/permissionBuilder.js.map +1 -1
- package/dist/esm/ma-v2/utils/account.js +0 -2
- package/dist/esm/ma-v2/utils/account.js.map +1 -1
- package/dist/esm/ma-v2/utils/deferredActions.d.ts +6 -6
- package/dist/esm/ma-v2/utils/deferredActions.js +5 -5
- package/dist/esm/ma-v2/utils/deferredActions.js.map +1 -1
- package/dist/esm/version.d.ts +1 -1
- package/dist/esm/version.js +1 -1
- package/dist/esm/version.js.map +1 -1
- package/dist/types/index.d.ts +1 -7
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/light-account/accounts/base.d.ts.map +1 -1
- package/dist/types/light-account/accounts/calldataCodec.d.ts.map +1 -1
- package/dist/types/light-account/utils.d.ts.map +1 -1
- package/dist/types/ma-v1/accounts/calldataCodec.d.ts.map +1 -1
- package/dist/types/ma-v1/mav1StaticImpl.d.ts +0 -2
- package/dist/types/ma-v1/mav1StaticImpl.d.ts.map +1 -1
- package/dist/types/ma-v2/accounts/account.d.ts +39 -0
- package/dist/types/ma-v2/accounts/account.d.ts.map +1 -1
- package/dist/types/ma-v2/accounts/calldataCodec.d.ts.map +1 -1
- package/dist/types/ma-v2/decorators/deferralActions.d.ts +3 -3
- package/dist/types/ma-v2/decorators/deferralActions.d.ts.map +1 -1
- package/dist/types/ma-v2/decorators/installValidation.d.ts +8 -20
- package/dist/types/ma-v2/decorators/installValidation.d.ts.map +1 -1
- package/dist/types/ma-v2/mav2StaticImpl.d.ts +0 -4
- package/dist/types/ma-v2/mav2StaticImpl.d.ts.map +1 -1
- package/dist/types/ma-v2/permissionBuilder.d.ts +2 -2
- package/dist/types/ma-v2/permissionBuilder.d.ts.map +1 -1
- package/dist/types/ma-v2/utils/account.d.ts.map +1 -1
- package/dist/types/ma-v2/utils/deferredActions.d.ts +6 -6
- package/dist/types/ma-v2/utils/deferredActions.d.ts.map +1 -1
- package/dist/types/version.d.ts +1 -1
- package/dist/types/version.d.ts.map +1 -1
- package/package.json +6 -6
- package/src/index.ts +1 -14
- package/src/light-account/accounts/base.ts +0 -1
- package/src/light-account/accounts/calldataCodec.ts +0 -4
- package/src/light-account/utils.ts +0 -6
- package/src/ma-v1/accounts/base.ts +1 -1
- package/src/ma-v1/accounts/calldataCodec.ts +0 -5
- package/src/ma-v1/mav1StaticImpl.ts +0 -2
- package/src/ma-v2/accounts/account.ts +41 -2
- package/src/ma-v2/accounts/base.ts +1 -1
- package/src/ma-v2/accounts/calldataCodec.ts +0 -5
- package/src/ma-v2/decorators/deferralActions.ts +7 -7
- package/src/ma-v2/decorators/installValidation.ts +8 -83
- package/src/ma-v2/mav2StaticImpl.ts +0 -4
- package/src/ma-v2/permissionBuilder.ts +54 -17
- package/src/ma-v2/utils/account.ts +0 -2
- package/src/ma-v2/utils/deferredActions.ts +9 -9
- package/src/version.ts +1 -1
- package/dist/esm/light-account/decorators/multiOwner.d.ts +0 -17
- package/dist/esm/light-account/decorators/multiOwner.js +0 -39
- package/dist/esm/light-account/decorators/multiOwner.js.map +0 -1
- package/dist/esm/light-account/decorators/singleOwner.d.ts +0 -16
- package/dist/esm/light-account/decorators/singleOwner.js +0 -35
- package/dist/esm/light-account/decorators/singleOwner.js.map +0 -1
- package/dist/esm/ma-v1/decorators/multiOwner.d.ts +0 -17
- package/dist/esm/ma-v1/decorators/multiOwner.js +0 -39
- package/dist/esm/ma-v1/decorators/multiOwner.js.map +0 -1
- package/dist/types/light-account/decorators/multiOwner.d.ts +0 -18
- package/dist/types/light-account/decorators/multiOwner.d.ts.map +0 -1
- package/dist/types/light-account/decorators/singleOwner.d.ts +0 -17
- package/dist/types/light-account/decorators/singleOwner.d.ts.map +0 -1
- package/dist/types/ma-v1/decorators/multiOwner.d.ts +0 -18
- package/dist/types/ma-v1/decorators/multiOwner.d.ts.map +0 -1
- package/src/light-account/decorators/multiOwner.ts +0 -72
- package/src/light-account/decorators/singleOwner.ts +0 -63
- package/src/ma-v1/decorators/multiOwner.ts +0 -72
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
import type { Address, Chain, Client, Hex, IsUndefined, Transport } from "viem";
|
|
2
|
-
import { sendUserOperation, type SmartAccount } from "viem/account-abstraction";
|
|
3
|
-
import { getAction } from "viem/utils";
|
|
4
|
-
import type { GetAccountParameter } from "../../types.js";
|
|
5
|
-
import type { MultiOwnerLightAccount } from "../accounts/multi-owner-account.js";
|
|
6
|
-
import { AccountNotFoundError } from "@alchemy/common";
|
|
7
|
-
|
|
8
|
-
export type MultiOwnerLightAccountActions<
|
|
9
|
-
TAccount extends MultiOwnerLightAccount | undefined =
|
|
10
|
-
| MultiOwnerLightAccount
|
|
11
|
-
| undefined,
|
|
12
|
-
> = {
|
|
13
|
-
updateOwners: (
|
|
14
|
-
args: {
|
|
15
|
-
ownersToAdd: Address[];
|
|
16
|
-
ownersToRemove: Address[];
|
|
17
|
-
} & GetAccountParameter<TAccount, MultiOwnerLightAccount>,
|
|
18
|
-
) => Promise<Hex>;
|
|
19
|
-
};
|
|
20
|
-
|
|
21
|
-
function isMultiOwnerLightAccount(
|
|
22
|
-
account: SmartAccount,
|
|
23
|
-
): account is MultiOwnerLightAccount {
|
|
24
|
-
return (
|
|
25
|
-
"smartAccountType" in account &&
|
|
26
|
-
account.smartAccountType === "MultiOwnerLightAccount"
|
|
27
|
-
);
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
/**
|
|
31
|
-
* Generates client actions for a multi-owner light account, including the ability to update owners.
|
|
32
|
-
*
|
|
33
|
-
* @param {Client<TTransport, TChain, TAccount>} client The client instance used to interact with the account
|
|
34
|
-
* @returns {MultiOwnerLightAccountActions<TAccount>} An object containing the client actions specifically for a multi-owner light account
|
|
35
|
-
*/
|
|
36
|
-
export function multiOwnerLightAccountActions<
|
|
37
|
-
TTransport extends Transport = Transport,
|
|
38
|
-
TChain extends Chain | undefined = Chain | undefined,
|
|
39
|
-
TAccount extends SmartAccount | undefined = SmartAccount | undefined,
|
|
40
|
-
>(
|
|
41
|
-
client: Client<TTransport, TChain, TAccount>,
|
|
42
|
-
): MultiOwnerLightAccountActions<
|
|
43
|
-
IsUndefined<TAccount> extends true ? undefined : MultiOwnerLightAccount
|
|
44
|
-
> {
|
|
45
|
-
return {
|
|
46
|
-
// TODO(v5): Another pattern I think we should consider deprecating for v5 - actions that
|
|
47
|
-
// implicitly do a sendUserOperation internally. These are non-composable with batching
|
|
48
|
-
// and have a number of other issues that are solved with viem writeContract.
|
|
49
|
-
updateOwners: async (args) => {
|
|
50
|
-
const { ownersToAdd, ownersToRemove, account = client.account } = args;
|
|
51
|
-
|
|
52
|
-
if (!account || !isMultiOwnerLightAccount(account)) {
|
|
53
|
-
throw new AccountNotFoundError();
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
const data = account.encodeUpdateOwners(ownersToAdd, ownersToRemove);
|
|
57
|
-
|
|
58
|
-
const action = getAction(client, sendUserOperation, "sendUserOperation");
|
|
59
|
-
const result = await action({
|
|
60
|
-
calls: [
|
|
61
|
-
{
|
|
62
|
-
to: account.address,
|
|
63
|
-
data,
|
|
64
|
-
},
|
|
65
|
-
],
|
|
66
|
-
account,
|
|
67
|
-
});
|
|
68
|
-
|
|
69
|
-
return result;
|
|
70
|
-
},
|
|
71
|
-
};
|
|
72
|
-
}
|
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
import { AccountNotFoundError } from "@alchemy/common";
|
|
2
|
-
import type { Address, Chain, Client, Hex, IsUndefined, Transport } from "viem";
|
|
3
|
-
import { sendUserOperation, type SmartAccount } from "viem/account-abstraction";
|
|
4
|
-
import { getAction } from "viem/utils";
|
|
5
|
-
import type { GetAccountParameter } from "../../types.js";
|
|
6
|
-
import type { LightAccount } from "../accounts/account.js";
|
|
7
|
-
|
|
8
|
-
export type LightAccountActions<
|
|
9
|
-
TAccount extends LightAccount | undefined = LightAccount | undefined,
|
|
10
|
-
> = {
|
|
11
|
-
transferOwnership: (
|
|
12
|
-
args: {
|
|
13
|
-
newOwner: Address;
|
|
14
|
-
} & GetAccountParameter<TAccount, LightAccount>,
|
|
15
|
-
) => Promise<Hex>;
|
|
16
|
-
};
|
|
17
|
-
|
|
18
|
-
function isLightAccount(account: SmartAccount): account is LightAccount {
|
|
19
|
-
return (
|
|
20
|
-
"smartAccountType" in account && account.smartAccountType === "LightAccount"
|
|
21
|
-
);
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
/**
|
|
25
|
-
* A decorator that can be used with viem's bundler client to add light account actions to the client
|
|
26
|
-
*
|
|
27
|
-
* @param {BundlerClient<TTransport, TChain, TAccount>} client The client instance for which to provide the light account actions
|
|
28
|
-
* @returns {LightAccountActions<TAccount>} An object containing the available light account actions
|
|
29
|
-
*/
|
|
30
|
-
export function singleOwnerLightAccountActions<
|
|
31
|
-
TTransport extends Transport = Transport,
|
|
32
|
-
TChain extends Chain | undefined = Chain | undefined,
|
|
33
|
-
TAccount extends SmartAccount | undefined = SmartAccount | undefined,
|
|
34
|
-
>(
|
|
35
|
-
client: Client<TTransport, TChain, TAccount>,
|
|
36
|
-
): LightAccountActions<
|
|
37
|
-
IsUndefined<TAccount> extends true ? undefined : LightAccount
|
|
38
|
-
> {
|
|
39
|
-
return {
|
|
40
|
-
transferOwnership: async (args) => {
|
|
41
|
-
const { newOwner, account = client.account } = args;
|
|
42
|
-
|
|
43
|
-
if (!account || !isLightAccount(account)) {
|
|
44
|
-
throw new AccountNotFoundError();
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
const data = account.encodeTransferOwnership(newOwner);
|
|
48
|
-
|
|
49
|
-
const action = getAction(client, sendUserOperation, "sendUserOperation");
|
|
50
|
-
const result = await action({
|
|
51
|
-
calls: [
|
|
52
|
-
{
|
|
53
|
-
to: account.address,
|
|
54
|
-
data,
|
|
55
|
-
},
|
|
56
|
-
],
|
|
57
|
-
account,
|
|
58
|
-
});
|
|
59
|
-
|
|
60
|
-
return result;
|
|
61
|
-
},
|
|
62
|
-
};
|
|
63
|
-
}
|
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
import type { Address, Chain, Client, Hex, IsUndefined, Transport } from "viem";
|
|
2
|
-
import { sendUserOperation, type SmartAccount } from "viem/account-abstraction";
|
|
3
|
-
import { getAction } from "viem/utils";
|
|
4
|
-
import type { GetAccountParameter } from "../../types.js";
|
|
5
|
-
import { AccountNotFoundError } from "@alchemy/common";
|
|
6
|
-
import type { MultiOwnerModularAccountV1 } from "../accounts/multi-owner-account.js";
|
|
7
|
-
|
|
8
|
-
export type MultiOwnerModularAccountV1Actions<
|
|
9
|
-
TAccount extends MultiOwnerModularAccountV1 | undefined =
|
|
10
|
-
| MultiOwnerModularAccountV1
|
|
11
|
-
| undefined,
|
|
12
|
-
> = {
|
|
13
|
-
updateOwners: (
|
|
14
|
-
args: {
|
|
15
|
-
ownersToAdd: Address[];
|
|
16
|
-
ownersToRemove: Address[];
|
|
17
|
-
} & GetAccountParameter<TAccount, MultiOwnerModularAccountV1>,
|
|
18
|
-
) => Promise<Hex>;
|
|
19
|
-
};
|
|
20
|
-
|
|
21
|
-
function isMultiOwnerModularAccountV1(
|
|
22
|
-
account: SmartAccount,
|
|
23
|
-
): account is MultiOwnerModularAccountV1 {
|
|
24
|
-
return (
|
|
25
|
-
"smartAccountType" in account &&
|
|
26
|
-
account.smartAccountType === "MultiOwnerModularAccountV1"
|
|
27
|
-
);
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
/**
|
|
31
|
-
* Generates client actions for a multi-owner MAv1 account, including the ability to update owners.
|
|
32
|
-
*
|
|
33
|
-
* @param {Client<TTransport, TChain, TAccount>} client The client instance used to interact with the account
|
|
34
|
-
* @returns {MultiOwnerLightAccountActions<TAccount>} An object containing the client actions specifically for a multi-owner modular account
|
|
35
|
-
*/
|
|
36
|
-
export function multiOwnerModularAccountV1Actions<
|
|
37
|
-
TTransport extends Transport = Transport,
|
|
38
|
-
TChain extends Chain | undefined = Chain | undefined,
|
|
39
|
-
TAccount extends SmartAccount | undefined = SmartAccount | undefined,
|
|
40
|
-
>(
|
|
41
|
-
client: Client<TTransport, TChain, TAccount>,
|
|
42
|
-
): MultiOwnerModularAccountV1Actions<
|
|
43
|
-
IsUndefined<TAccount> extends true ? undefined : MultiOwnerModularAccountV1
|
|
44
|
-
> {
|
|
45
|
-
return {
|
|
46
|
-
// TODO(v5): Another pattern I think we should consider deprecating for v5 - actions that
|
|
47
|
-
// implicitly do a sendUserOperation internally. These are non-composable with batching
|
|
48
|
-
// and have a number of other issues that are solved with viem writeContract.
|
|
49
|
-
updateOwners: async (args) => {
|
|
50
|
-
const { ownersToAdd, ownersToRemove, account = client.account } = args;
|
|
51
|
-
|
|
52
|
-
if (!account || !isMultiOwnerModularAccountV1(account)) {
|
|
53
|
-
throw new AccountNotFoundError();
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
const data = account.encodeUpdateOwners(ownersToAdd, ownersToRemove);
|
|
57
|
-
|
|
58
|
-
const action = getAction(client, sendUserOperation, "sendUserOperation");
|
|
59
|
-
const result = await action({
|
|
60
|
-
calls: [
|
|
61
|
-
{
|
|
62
|
-
to: account.address,
|
|
63
|
-
data,
|
|
64
|
-
},
|
|
65
|
-
],
|
|
66
|
-
account,
|
|
67
|
-
});
|
|
68
|
-
|
|
69
|
-
return result;
|
|
70
|
-
},
|
|
71
|
-
};
|
|
72
|
-
}
|