@rhinestone/sdk 1.0.0-alpha.32 → 1.0.0-alpha.33
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/dist/src/accounts/index.d.ts +18 -18
- package/dist/src/accounts/index.d.ts.map +1 -1
- package/dist/src/accounts/index.js +12 -8
- package/dist/src/accounts/index.test.js +0 -2
- package/dist/src/accounts/kernel.test.js +0 -6
- package/dist/src/accounts/nexus.test.js +0 -6
- package/dist/src/accounts/safe.test.js +0 -6
- package/dist/src/accounts/signing/common.d.ts +3 -3
- package/dist/src/accounts/signing/common.d.ts.map +1 -1
- package/dist/src/accounts/signing/common.js +10 -8
- package/dist/src/accounts/signing/message.d.ts +1 -1
- package/dist/src/accounts/signing/message.d.ts.map +1 -1
- package/dist/src/accounts/signing/message.js +3 -3
- package/dist/src/accounts/signing/typedData.d.ts.map +1 -1
- package/dist/src/accounts/signing/typedData.js +2 -2
- package/dist/src/accounts/startale.test.js +0 -4
- package/dist/src/accounts/utils.d.ts +2 -2
- package/dist/src/accounts/utils.d.ts.map +1 -1
- package/dist/src/actions/compact.d.ts +13 -0
- package/dist/src/actions/compact.d.ts.map +1 -0
- package/dist/src/actions/compact.js +210 -0
- package/dist/src/actions/ecdsa.d.ts +35 -0
- package/dist/src/actions/ecdsa.d.ts.map +1 -0
- package/dist/src/actions/ecdsa.js +114 -0
- package/dist/src/actions/ecdsa.test.d.ts +2 -0
- package/dist/src/actions/ecdsa.test.d.ts.map +1 -0
- package/dist/src/actions/ecdsa.test.js +99 -0
- package/dist/src/actions/index.d.ts +5 -176
- package/dist/src/actions/index.d.ts.map +1 -1
- package/dist/src/actions/index.js +10 -563
- package/dist/src/actions/mfa.d.ts +37 -0
- package/dist/src/actions/mfa.d.ts.map +1 -0
- package/dist/src/actions/mfa.js +133 -0
- package/dist/src/actions/passkeys.d.ts +37 -0
- package/dist/src/actions/passkeys.d.ts.map +1 -0
- package/dist/src/actions/passkeys.js +129 -0
- package/dist/src/actions/passkeys.test.d.ts +2 -0
- package/dist/src/actions/passkeys.test.d.ts.map +1 -0
- package/dist/src/actions/passkeys.test.js +54 -0
- package/dist/src/actions/recovery.d.ts +33 -0
- package/dist/src/actions/recovery.d.ts.map +1 -0
- package/dist/src/actions/recovery.js +193 -0
- package/dist/src/actions/recovery.test.d.ts +2 -0
- package/dist/src/actions/recovery.test.d.ts.map +1 -0
- package/dist/src/actions/recovery.test.js +168 -0
- package/dist/src/errors/index.d.ts +5 -0
- package/dist/src/errors/index.d.ts.map +1 -0
- package/dist/src/errors/index.js +35 -0
- package/dist/src/execution/compact.d.ts +1 -12
- package/dist/src/execution/compact.d.ts.map +1 -1
- package/dist/src/execution/compact.js +0 -190
- package/dist/src/execution/error.d.ts +2 -16
- package/dist/src/execution/error.d.ts.map +1 -1
- package/dist/src/execution/error.js +4 -22
- package/dist/src/execution/index.d.ts +23 -24
- package/dist/src/execution/index.d.ts.map +1 -1
- package/dist/src/execution/index.js +38 -24
- package/dist/src/execution/smart-session.d.ts +3 -3
- package/dist/src/execution/smart-session.d.ts.map +1 -1
- package/dist/src/execution/utils.d.ts +33 -29
- package/dist/src/execution/utils.d.ts.map +1 -1
- package/dist/src/execution/utils.js +76 -69
- package/dist/src/index.d.ts +28 -17
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +69 -74
- package/dist/src/modules/index.d.ts +2 -2
- package/dist/src/modules/index.d.ts.map +1 -1
- package/dist/src/modules/index.js +1 -1
- package/dist/src/modules/index.test.js +0 -4
- package/dist/src/modules/validators/smart-sessions.test.js +0 -3
- package/dist/src/orchestrator/types.d.ts +1 -6
- package/dist/src/orchestrator/types.d.ts.map +1 -1
- package/dist/src/types.d.ts +22 -4
- package/dist/src/types.d.ts.map +1 -1
- package/package.json +36 -1
- package/dist/src/actions/index.test.d.ts +0 -2
- package/dist/src/actions/index.test.d.ts.map +0 -1
- package/dist/src/actions/index.test.js +0 -302
|
@@ -0,0 +1,210 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.depositEther = depositEther;
|
|
4
|
+
exports.enableEtherWithdrawal = enableEtherWithdrawal;
|
|
5
|
+
exports.disableEtherWithdrawal = disableEtherWithdrawal;
|
|
6
|
+
exports.withdrawEther = withdrawEther;
|
|
7
|
+
exports.depositErc20 = depositErc20;
|
|
8
|
+
exports.enableErc20Withdrawal = enableErc20Withdrawal;
|
|
9
|
+
exports.disableErc20Withdrawal = disableErc20Withdrawal;
|
|
10
|
+
exports.withdrawErc20 = withdrawErc20;
|
|
11
|
+
exports.approveErc20 = approveErc20;
|
|
12
|
+
const viem_1 = require("viem");
|
|
13
|
+
const compact_1 = require("../execution/compact");
|
|
14
|
+
const ALLOCATOR_ADDRESS = '0xd93ed1dd9f1f0b523e4d77233809dc2ee22928c6';
|
|
15
|
+
const DEFAULT_RESET_PERIOD = 6;
|
|
16
|
+
const DEFAULT_SCOPE = 0;
|
|
17
|
+
function depositEther(value) {
|
|
18
|
+
return {
|
|
19
|
+
async resolve({ accountAddress }) {
|
|
20
|
+
return {
|
|
21
|
+
to: compact_1.COMPACT_ADDRESS,
|
|
22
|
+
data: (0, viem_1.encodeFunctionData)({
|
|
23
|
+
abi: [
|
|
24
|
+
{
|
|
25
|
+
type: 'function',
|
|
26
|
+
name: 'depositNative',
|
|
27
|
+
inputs: [
|
|
28
|
+
{ name: 'lockTag', type: 'bytes12', internalType: 'bytes12' },
|
|
29
|
+
{ name: 'recipient', type: 'address', internalType: 'address' },
|
|
30
|
+
],
|
|
31
|
+
outputs: [
|
|
32
|
+
{ name: 'id', type: 'uint256', internalType: 'uint256' },
|
|
33
|
+
],
|
|
34
|
+
stateMutability: 'payable',
|
|
35
|
+
},
|
|
36
|
+
],
|
|
37
|
+
functionName: 'depositNative',
|
|
38
|
+
args: [lockTag(), accountAddress],
|
|
39
|
+
}),
|
|
40
|
+
value,
|
|
41
|
+
};
|
|
42
|
+
},
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
function enableEtherWithdrawal() {
|
|
46
|
+
const id = (0, viem_1.concat)([lockTag(), viem_1.zeroAddress]);
|
|
47
|
+
return enableForcedWithdrawal(BigInt(id));
|
|
48
|
+
}
|
|
49
|
+
function disableEtherWithdrawal() {
|
|
50
|
+
const id = (0, viem_1.concat)([lockTag(), viem_1.zeroAddress]);
|
|
51
|
+
return disableForcedWithdrawal(BigInt(id));
|
|
52
|
+
}
|
|
53
|
+
function withdrawEther(value) {
|
|
54
|
+
return {
|
|
55
|
+
async resolve({ accountAddress }) {
|
|
56
|
+
const id = (0, viem_1.concat)([lockTag(), viem_1.zeroAddress]);
|
|
57
|
+
return forcedWithdrawal(BigInt(id), accountAddress, value);
|
|
58
|
+
},
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
function depositErc20(tokenAddress, amount) {
|
|
62
|
+
return {
|
|
63
|
+
async resolve({ accountAddress }) {
|
|
64
|
+
return {
|
|
65
|
+
to: compact_1.COMPACT_ADDRESS,
|
|
66
|
+
value: 0n,
|
|
67
|
+
data: (0, viem_1.encodeFunctionData)({
|
|
68
|
+
abi: [
|
|
69
|
+
{
|
|
70
|
+
type: 'function',
|
|
71
|
+
name: 'depositERC20',
|
|
72
|
+
inputs: [
|
|
73
|
+
{ name: 'token', type: 'address', internalType: 'address' },
|
|
74
|
+
{ name: 'lockTag', type: 'bytes12', internalType: 'bytes12' },
|
|
75
|
+
{ name: 'amount', type: 'uint256', internalType: 'uint256' },
|
|
76
|
+
{ name: 'recipient', type: 'address', internalType: 'address' },
|
|
77
|
+
],
|
|
78
|
+
outputs: [
|
|
79
|
+
{ name: 'id', type: 'uint256', internalType: 'uint256' },
|
|
80
|
+
],
|
|
81
|
+
stateMutability: 'nonpayable',
|
|
82
|
+
},
|
|
83
|
+
],
|
|
84
|
+
functionName: 'depositERC20',
|
|
85
|
+
args: [tokenAddress, lockTag(), amount, accountAddress],
|
|
86
|
+
}),
|
|
87
|
+
};
|
|
88
|
+
},
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
function enableErc20Withdrawal(tokenAddress) {
|
|
92
|
+
const id = (0, viem_1.concat)([lockTag(), tokenAddress]);
|
|
93
|
+
return enableForcedWithdrawal(BigInt(id));
|
|
94
|
+
}
|
|
95
|
+
function disableErc20Withdrawal(tokenAddress) {
|
|
96
|
+
const id = (0, viem_1.concat)([lockTag(), tokenAddress]);
|
|
97
|
+
return disableForcedWithdrawal(BigInt(id));
|
|
98
|
+
}
|
|
99
|
+
function withdrawErc20(tokenAddress, amount) {
|
|
100
|
+
return {
|
|
101
|
+
async resolve({ accountAddress }) {
|
|
102
|
+
const id = (0, viem_1.concat)([lockTag(), tokenAddress]);
|
|
103
|
+
return forcedWithdrawal(BigInt(id), accountAddress, amount);
|
|
104
|
+
},
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
function enableForcedWithdrawal(id) {
|
|
108
|
+
return {
|
|
109
|
+
to: compact_1.COMPACT_ADDRESS,
|
|
110
|
+
data: (0, viem_1.encodeFunctionData)({
|
|
111
|
+
abi: [
|
|
112
|
+
{
|
|
113
|
+
type: 'function',
|
|
114
|
+
name: 'enableForcedWithdrawal',
|
|
115
|
+
inputs: [{ name: 'id', type: 'uint256', internalType: 'uint256' }],
|
|
116
|
+
outputs: [{ name: '', type: 'uint256', internalType: 'uint256' }],
|
|
117
|
+
stateMutability: 'nonpayable',
|
|
118
|
+
},
|
|
119
|
+
],
|
|
120
|
+
functionName: 'enableForcedWithdrawal',
|
|
121
|
+
args: [id],
|
|
122
|
+
}),
|
|
123
|
+
value: 0n,
|
|
124
|
+
};
|
|
125
|
+
}
|
|
126
|
+
function disableForcedWithdrawal(id) {
|
|
127
|
+
return {
|
|
128
|
+
to: compact_1.COMPACT_ADDRESS,
|
|
129
|
+
data: (0, viem_1.encodeFunctionData)({
|
|
130
|
+
abi: [
|
|
131
|
+
{
|
|
132
|
+
type: 'function',
|
|
133
|
+
name: 'disableForcedWithdrawal',
|
|
134
|
+
inputs: [{ name: 'id', type: 'uint256', internalType: 'uint256' }],
|
|
135
|
+
outputs: [{ name: '', type: 'uint256', internalType: 'uint256' }],
|
|
136
|
+
stateMutability: 'nonpayable',
|
|
137
|
+
},
|
|
138
|
+
],
|
|
139
|
+
functionName: 'disableForcedWithdrawal',
|
|
140
|
+
args: [id],
|
|
141
|
+
}),
|
|
142
|
+
value: 0n,
|
|
143
|
+
};
|
|
144
|
+
}
|
|
145
|
+
function forcedWithdrawal(id, recipient, amount) {
|
|
146
|
+
return {
|
|
147
|
+
to: compact_1.COMPACT_ADDRESS,
|
|
148
|
+
data: (0, viem_1.encodeFunctionData)({
|
|
149
|
+
abi: [
|
|
150
|
+
{
|
|
151
|
+
type: 'function',
|
|
152
|
+
name: 'forcedWithdrawal',
|
|
153
|
+
inputs: [
|
|
154
|
+
{ name: 'id', type: 'uint256', internalType: 'uint256' },
|
|
155
|
+
{ name: 'recipient', type: 'address', internalType: 'address' },
|
|
156
|
+
{ name: 'amount', type: 'uint256', internalType: 'uint256' },
|
|
157
|
+
],
|
|
158
|
+
outputs: [{ name: '', type: 'bool', internalType: 'bool' }],
|
|
159
|
+
stateMutability: 'nonpayable',
|
|
160
|
+
},
|
|
161
|
+
],
|
|
162
|
+
functionName: 'forcedWithdrawal',
|
|
163
|
+
args: [id, recipient, amount],
|
|
164
|
+
}),
|
|
165
|
+
value: 0n,
|
|
166
|
+
};
|
|
167
|
+
}
|
|
168
|
+
function approveErc20(tokenAddress, amount) {
|
|
169
|
+
return {
|
|
170
|
+
to: tokenAddress,
|
|
171
|
+
value: 0n,
|
|
172
|
+
data: (0, viem_1.encodeFunctionData)({
|
|
173
|
+
abi: viem_1.erc20Abi,
|
|
174
|
+
functionName: 'approve',
|
|
175
|
+
args: [compact_1.COMPACT_ADDRESS, amount],
|
|
176
|
+
}),
|
|
177
|
+
};
|
|
178
|
+
}
|
|
179
|
+
function toCompactFlag(allocator) {
|
|
180
|
+
const addrBytes = Buffer.from(allocator.slice(2), 'hex');
|
|
181
|
+
let leadingZeroNibbles = 0;
|
|
182
|
+
for (const byte of addrBytes) {
|
|
183
|
+
if (byte === 0) {
|
|
184
|
+
leadingZeroNibbles += 2;
|
|
185
|
+
}
|
|
186
|
+
else {
|
|
187
|
+
if (byte >> 4 === 0)
|
|
188
|
+
leadingZeroNibbles += 1;
|
|
189
|
+
break;
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
if (leadingZeroNibbles >= 18)
|
|
193
|
+
return 15;
|
|
194
|
+
if (leadingZeroNibbles >= 4)
|
|
195
|
+
return leadingZeroNibbles - 3;
|
|
196
|
+
return 0;
|
|
197
|
+
}
|
|
198
|
+
function usingAllocatorId(allocator = ALLOCATOR_ADDRESS) {
|
|
199
|
+
const compactFlag = BigInt(toCompactFlag(allocator));
|
|
200
|
+
const last88Bits = BigInt(`0x${allocator.slice(-22)}`); // Extract last 88 bits (11 bytes * 2 hex chars per byte)
|
|
201
|
+
return (compactFlag << 88n) | last88Bits;
|
|
202
|
+
}
|
|
203
|
+
function lockTag() {
|
|
204
|
+
const allocatorId = usingAllocatorId(ALLOCATOR_ADDRESS);
|
|
205
|
+
const tagBig = (BigInt(DEFAULT_SCOPE) << 255n) |
|
|
206
|
+
(BigInt(DEFAULT_RESET_PERIOD) << 252n) |
|
|
207
|
+
(allocatorId << 160n);
|
|
208
|
+
const hex = tagBig.toString(16).slice(0, 24);
|
|
209
|
+
return `0x${hex}`;
|
|
210
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { type Address } from 'viem';
|
|
2
|
+
import type { CalldataInput, LazyCallInput } from '../types';
|
|
3
|
+
/**
|
|
4
|
+
* Enable ECDSA authentication
|
|
5
|
+
* @param owners Owners to use for authentication
|
|
6
|
+
* @param threshold Threshold for the owners
|
|
7
|
+
* @returns Calls to enable ECDSA authentication
|
|
8
|
+
*/
|
|
9
|
+
declare function enable(owners: Address[], threshold?: number): LazyCallInput;
|
|
10
|
+
/**
|
|
11
|
+
* Disable ECDSA authentication
|
|
12
|
+
* @returns Calls to disable ECDSA authentication
|
|
13
|
+
*/
|
|
14
|
+
declare function disable(): LazyCallInput;
|
|
15
|
+
/**
|
|
16
|
+
* Add an ECDSA owner
|
|
17
|
+
* @param owner Owner address
|
|
18
|
+
* @returns Call to add the owner
|
|
19
|
+
*/
|
|
20
|
+
declare function addOwner(owner: Address): CalldataInput;
|
|
21
|
+
/**
|
|
22
|
+
* Remove an ECDSA owner
|
|
23
|
+
* @param prevOwner Previous owner address
|
|
24
|
+
* @param ownerToRemove Owner to remove
|
|
25
|
+
* @returns Call to remove the owner
|
|
26
|
+
*/
|
|
27
|
+
declare function removeOwner(prevOwner: Address, ownerToRemove: Address): CalldataInput;
|
|
28
|
+
/**
|
|
29
|
+
* Change an account's signer threshold (ECDSA)
|
|
30
|
+
* @param newThreshold New threshold
|
|
31
|
+
* @returns Call to change the threshold
|
|
32
|
+
*/
|
|
33
|
+
declare function changeThreshold(newThreshold: number): CalldataInput;
|
|
34
|
+
export { addOwner, removeOwner, changeThreshold, disable, enable };
|
|
35
|
+
//# sourceMappingURL=ecdsa.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ecdsa.d.ts","sourceRoot":"","sources":["../../../actions/ecdsa.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,OAAO,EAAsB,MAAM,MAAM,CAAA;AASvD,OAAO,KAAK,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,UAAU,CAAA;AAE5D;;;;;GAKG;AACH,iBAAS,MAAM,CAAC,MAAM,EAAE,OAAO,EAAE,EAAE,SAAS,SAAI,GAAG,aAAa,CAO/D;AAED;;;GAGG;AACH,iBAAS,OAAO,IAAI,aAAa,CAOhC;AAED;;;;GAIG;AACH,iBAAS,QAAQ,CAAC,KAAK,EAAE,OAAO,GAAG,aAAa,CAkB/C;AAED;;;;;GAKG;AACH,iBAAS,WAAW,CAClB,SAAS,EAAE,OAAO,EAClB,aAAa,EAAE,OAAO,GACrB,aAAa,CAqBf;AAED;;;;GAIG;AACH,iBAAS,eAAe,CAAC,YAAY,EAAE,MAAM,GAAG,aAAa,CAoB5D;AAED,OAAO,EAAE,QAAQ,EAAE,WAAW,EAAE,eAAe,EAAE,OAAO,EAAE,MAAM,EAAE,CAAA"}
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.addOwner = addOwner;
|
|
4
|
+
exports.removeOwner = removeOwner;
|
|
5
|
+
exports.changeThreshold = changeThreshold;
|
|
6
|
+
exports.disable = disable;
|
|
7
|
+
exports.enable = enable;
|
|
8
|
+
const viem_1 = require("viem");
|
|
9
|
+
const accounts_1 = require("../accounts");
|
|
10
|
+
const core_1 = require("../modules/validators/core");
|
|
11
|
+
/**
|
|
12
|
+
* Enable ECDSA authentication
|
|
13
|
+
* @param owners Owners to use for authentication
|
|
14
|
+
* @param threshold Threshold for the owners
|
|
15
|
+
* @returns Calls to enable ECDSA authentication
|
|
16
|
+
*/
|
|
17
|
+
function enable(owners, threshold = 1) {
|
|
18
|
+
const module = (0, core_1.getOwnableValidator)(threshold, owners);
|
|
19
|
+
return {
|
|
20
|
+
async resolve({ config }) {
|
|
21
|
+
return (0, accounts_1.getModuleInstallationCalls)(config, module);
|
|
22
|
+
},
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Disable ECDSA authentication
|
|
27
|
+
* @returns Calls to disable ECDSA authentication
|
|
28
|
+
*/
|
|
29
|
+
function disable() {
|
|
30
|
+
const module = (0, core_1.getOwnableValidator)(1, []);
|
|
31
|
+
return {
|
|
32
|
+
async resolve({ config }) {
|
|
33
|
+
return (0, accounts_1.getModuleUninstallationCalls)(config, module);
|
|
34
|
+
},
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Add an ECDSA owner
|
|
39
|
+
* @param owner Owner address
|
|
40
|
+
* @returns Call to add the owner
|
|
41
|
+
*/
|
|
42
|
+
function addOwner(owner) {
|
|
43
|
+
return {
|
|
44
|
+
to: core_1.OWNABLE_VALIDATOR_ADDRESS,
|
|
45
|
+
value: 0n,
|
|
46
|
+
data: (0, viem_1.encodeFunctionData)({
|
|
47
|
+
abi: [
|
|
48
|
+
{
|
|
49
|
+
inputs: [{ internalType: 'address', name: 'owner', type: 'address' }],
|
|
50
|
+
name: 'addOwner',
|
|
51
|
+
outputs: [],
|
|
52
|
+
stateMutability: 'nonpayable',
|
|
53
|
+
type: 'function',
|
|
54
|
+
},
|
|
55
|
+
],
|
|
56
|
+
functionName: 'addOwner',
|
|
57
|
+
args: [owner],
|
|
58
|
+
}),
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Remove an ECDSA owner
|
|
63
|
+
* @param prevOwner Previous owner address
|
|
64
|
+
* @param ownerToRemove Owner to remove
|
|
65
|
+
* @returns Call to remove the owner
|
|
66
|
+
*/
|
|
67
|
+
function removeOwner(prevOwner, ownerToRemove) {
|
|
68
|
+
return {
|
|
69
|
+
to: core_1.OWNABLE_VALIDATOR_ADDRESS,
|
|
70
|
+
value: 0n,
|
|
71
|
+
data: (0, viem_1.encodeFunctionData)({
|
|
72
|
+
abi: [
|
|
73
|
+
{
|
|
74
|
+
inputs: [
|
|
75
|
+
{ internalType: 'address', name: 'prevOwner', type: 'address' },
|
|
76
|
+
{ internalType: 'address', name: 'owner', type: 'address' },
|
|
77
|
+
],
|
|
78
|
+
name: 'removeOwner',
|
|
79
|
+
outputs: [],
|
|
80
|
+
stateMutability: 'nonpayable',
|
|
81
|
+
type: 'function',
|
|
82
|
+
},
|
|
83
|
+
],
|
|
84
|
+
functionName: 'removeOwner',
|
|
85
|
+
args: [prevOwner, ownerToRemove],
|
|
86
|
+
}),
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Change an account's signer threshold (ECDSA)
|
|
91
|
+
* @param newThreshold New threshold
|
|
92
|
+
* @returns Call to change the threshold
|
|
93
|
+
*/
|
|
94
|
+
function changeThreshold(newThreshold) {
|
|
95
|
+
return {
|
|
96
|
+
to: core_1.OWNABLE_VALIDATOR_ADDRESS,
|
|
97
|
+
value: 0n,
|
|
98
|
+
data: (0, viem_1.encodeFunctionData)({
|
|
99
|
+
abi: [
|
|
100
|
+
{
|
|
101
|
+
inputs: [
|
|
102
|
+
{ internalType: 'uint256', name: '_threshold', type: 'uint256' },
|
|
103
|
+
],
|
|
104
|
+
name: 'setThreshold',
|
|
105
|
+
outputs: [],
|
|
106
|
+
stateMutability: 'nonpayable',
|
|
107
|
+
type: 'function',
|
|
108
|
+
},
|
|
109
|
+
],
|
|
110
|
+
functionName: 'setThreshold',
|
|
111
|
+
args: [BigInt(newThreshold)],
|
|
112
|
+
}),
|
|
113
|
+
};
|
|
114
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ecdsa.test.d.ts","sourceRoot":"","sources":["../../../actions/ecdsa.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const chains_1 = require("viem/chains");
|
|
4
|
+
const vitest_1 = require("vitest");
|
|
5
|
+
const consts_1 = require("../../test/consts");
|
|
6
|
+
const __1 = require("..");
|
|
7
|
+
const utils_1 = require("../execution/utils");
|
|
8
|
+
const ecdsa_1 = require("./ecdsa");
|
|
9
|
+
const MOCK_OWNER_A = '0xd1aefebdceefc094f1805b241fa5e6db63a9181a';
|
|
10
|
+
const MOCK_OWNER_B = '0xeddfcb50d18f6d3d51c4f7cbca5ed6bdebc59817';
|
|
11
|
+
const MOCK_OWNER_C = '0xb31e76f19defe76edc4b7eceeb4b0a2d6ddaca39';
|
|
12
|
+
const accountAddress = '0x36C03e7D593F7B2C6b06fC18B5f4E9a4A29C99b0';
|
|
13
|
+
(0, vitest_1.describe)('ECDSA Actions', () => {
|
|
14
|
+
(0, vitest_1.describe)('Install Ownable Validator', async () => {
|
|
15
|
+
const rhinestone = new __1.RhinestoneSDK();
|
|
16
|
+
const rhinestoneAccount = await rhinestone.createAccount({
|
|
17
|
+
owners: {
|
|
18
|
+
type: 'ecdsa',
|
|
19
|
+
accounts: [consts_1.accountA],
|
|
20
|
+
},
|
|
21
|
+
});
|
|
22
|
+
(0, vitest_1.test)('1/1 Owners', async () => {
|
|
23
|
+
const calls = await (0, utils_1.resolveCallInputs)([(0, ecdsa_1.enable)([MOCK_OWNER_A])], rhinestoneAccount.config, chains_1.base, accountAddress);
|
|
24
|
+
(0, vitest_1.expect)(calls).toEqual([
|
|
25
|
+
{
|
|
26
|
+
to: accountAddress,
|
|
27
|
+
value: 0n,
|
|
28
|
+
data: '0x9517e29f0000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000013fdb5234e4e3162a810f54d9f7e9800000000000000000000000000000000000000000000000000000000000000600000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000001000000000000000000000000d1aefebdceefc094f1805b241fa5e6db63a9181a',
|
|
29
|
+
},
|
|
30
|
+
]);
|
|
31
|
+
});
|
|
32
|
+
(0, vitest_1.test)('1/N Owners', async () => {
|
|
33
|
+
const calls = await (0, utils_1.resolveCallInputs)([(0, ecdsa_1.enable)([MOCK_OWNER_A, MOCK_OWNER_B])], rhinestoneAccount.config, chains_1.base, accountAddress);
|
|
34
|
+
(0, vitest_1.expect)(calls).toEqual([
|
|
35
|
+
{
|
|
36
|
+
to: accountAddress,
|
|
37
|
+
value: 0n,
|
|
38
|
+
data: '0x9517e29f0000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000013fdb5234e4e3162a810f54d9f7e98000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000002000000000000000000000000d1aefebdceefc094f1805b241fa5e6db63a9181a000000000000000000000000eddfcb50d18f6d3d51c4f7cbca5ed6bdebc59817',
|
|
39
|
+
},
|
|
40
|
+
]);
|
|
41
|
+
});
|
|
42
|
+
(0, vitest_1.test)('M/N Owners', async () => {
|
|
43
|
+
const calls = await (0, utils_1.resolveCallInputs)([(0, ecdsa_1.enable)([MOCK_OWNER_A, MOCK_OWNER_B, MOCK_OWNER_C], 2)], rhinestoneAccount.config, chains_1.base, accountAddress);
|
|
44
|
+
(0, vitest_1.expect)(calls).toEqual([
|
|
45
|
+
{
|
|
46
|
+
to: accountAddress,
|
|
47
|
+
value: 0n,
|
|
48
|
+
data: '0x9517e29f0000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000013fdb5234e4e3162a810f54d9f7e98000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000c0000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000003000000000000000000000000b31e76f19defe76edc4b7eceeb4b0a2d6ddaca39000000000000000000000000d1aefebdceefc094f1805b241fa5e6db63a9181a000000000000000000000000eddfcb50d18f6d3d51c4f7cbca5ed6bdebc59817',
|
|
49
|
+
},
|
|
50
|
+
]);
|
|
51
|
+
});
|
|
52
|
+
});
|
|
53
|
+
(0, vitest_1.describe)('Uninstall Ownable Validator', async () => {
|
|
54
|
+
const rhinestone = new __1.RhinestoneSDK();
|
|
55
|
+
const rhinestoneAccount = await rhinestone.createAccount({
|
|
56
|
+
owners: {
|
|
57
|
+
type: 'ecdsa',
|
|
58
|
+
accounts: [consts_1.accountA],
|
|
59
|
+
},
|
|
60
|
+
});
|
|
61
|
+
(0, vitest_1.test)('', async () => {
|
|
62
|
+
const calls = await (0, utils_1.resolveCallInputs)([(0, ecdsa_1.disable)()], rhinestoneAccount.config, chains_1.base, accountAddress);
|
|
63
|
+
(0, vitest_1.expect)(calls).toEqual([
|
|
64
|
+
{
|
|
65
|
+
to: accountAddress,
|
|
66
|
+
value: 0n,
|
|
67
|
+
data: '0xa71763a80000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000013fdb5234e4e3162a810f54d9f7e9800000000000000000000000000000000000000000000000000000000000000600000000000000000000000000000000000000000000000000000000000000000',
|
|
68
|
+
},
|
|
69
|
+
]);
|
|
70
|
+
});
|
|
71
|
+
});
|
|
72
|
+
(0, vitest_1.describe)('Add Owner', () => {
|
|
73
|
+
(0, vitest_1.test)('', () => {
|
|
74
|
+
(0, vitest_1.expect)((0, ecdsa_1.addOwner)(MOCK_OWNER_A)).toEqual({
|
|
75
|
+
to: '0x000000000013fdb5234e4e3162a810f54d9f7e98',
|
|
76
|
+
value: 0n,
|
|
77
|
+
data: '0x7065cb48000000000000000000000000d1aefebdceefc094f1805b241fa5e6db63a9181a',
|
|
78
|
+
});
|
|
79
|
+
});
|
|
80
|
+
});
|
|
81
|
+
(0, vitest_1.describe)('Remove Owner', () => {
|
|
82
|
+
(0, vitest_1.test)('', () => {
|
|
83
|
+
(0, vitest_1.expect)((0, ecdsa_1.removeOwner)(MOCK_OWNER_A, MOCK_OWNER_B)).toEqual({
|
|
84
|
+
to: '0x000000000013fdb5234e4e3162a810f54d9f7e98',
|
|
85
|
+
value: 0n,
|
|
86
|
+
data: '0xfbe5ce0a000000000000000000000000d1aefebdceefc094f1805b241fa5e6db63a9181a000000000000000000000000eddfcb50d18f6d3d51c4f7cbca5ed6bdebc59817',
|
|
87
|
+
});
|
|
88
|
+
});
|
|
89
|
+
});
|
|
90
|
+
(0, vitest_1.describe)('Set Threshold', () => {
|
|
91
|
+
(0, vitest_1.test)('', () => {
|
|
92
|
+
(0, vitest_1.expect)((0, ecdsa_1.changeThreshold)(1)).toEqual({
|
|
93
|
+
to: '0x000000000013fdb5234e4e3162a810f54d9f7e98',
|
|
94
|
+
value: 0n,
|
|
95
|
+
data: '0x960bfe040000000000000000000000000000000000000000000000000000000000000001',
|
|
96
|
+
});
|
|
97
|
+
});
|
|
98
|
+
});
|
|
99
|
+
});
|
|
@@ -1,9 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import type { RhinestoneAccount } from '..';
|
|
1
|
+
import type { Address, Hex } from 'viem';
|
|
3
2
|
import { type ModuleType } from '../modules/common';
|
|
4
|
-
import {
|
|
5
|
-
import type { Call, OwnableValidatorConfig, OwnerSet, ProviderConfig, Recovery, WebauthnValidatorConfig } from '../types';
|
|
6
|
-
import { encodeSmartSessionSignature } from './smart-session';
|
|
3
|
+
import type { LazyCallInput } from '../types';
|
|
7
4
|
interface ModuleInput {
|
|
8
5
|
type: ModuleType;
|
|
9
6
|
address: Address;
|
|
@@ -13,183 +10,15 @@ interface ModuleInput {
|
|
|
13
10
|
}
|
|
14
11
|
/**
|
|
15
12
|
* Install a custom module
|
|
16
|
-
* @param rhinestoneAccount Account to install the module on
|
|
17
13
|
* @param module Module to install
|
|
18
14
|
* @returns Calls to install the module
|
|
19
15
|
*/
|
|
20
|
-
declare function installModule(
|
|
21
|
-
rhinestoneAccount: RhinestoneAccount;
|
|
22
|
-
module: ModuleInput;
|
|
23
|
-
}): Call[];
|
|
16
|
+
declare function installModule(module: ModuleInput): LazyCallInput;
|
|
24
17
|
/**
|
|
25
18
|
* Uninstall a custom module
|
|
26
|
-
* @param rhinestoneAccount Account to uninstall the module on
|
|
27
19
|
* @param module Module to uninstall
|
|
28
20
|
* @returns Calls to uninstall the module
|
|
29
21
|
*/
|
|
30
|
-
declare function uninstallModule(
|
|
31
|
-
|
|
32
|
-
module: ModuleInput;
|
|
33
|
-
}): Call[];
|
|
34
|
-
/**
|
|
35
|
-
* Set up social recovery
|
|
36
|
-
* @param rhinestoneAccount Account to set up social recovery on
|
|
37
|
-
* @param guardians Guardians to use for recovery
|
|
38
|
-
* @param threshold Threshold for the guardians
|
|
39
|
-
* @returns Calls to set up social recovery
|
|
40
|
-
*/
|
|
41
|
-
declare function setUpRecovery({ rhinestoneAccount, guardians, threshold, }: {
|
|
42
|
-
rhinestoneAccount: RhinestoneAccount;
|
|
43
|
-
} & Recovery): Call[];
|
|
44
|
-
/**
|
|
45
|
-
* Recover an account's ownership
|
|
46
|
-
* @param address Account address
|
|
47
|
-
* @param newOwners New owners
|
|
48
|
-
* @param chain Chain to recover ownership on
|
|
49
|
-
* @param provider Provider to use for the recovery
|
|
50
|
-
* @returns Calls to recover ownership
|
|
51
|
-
* @deprecated Use `recoverEcdsaOwnership` or `recoverPasskeyOwnership` instead
|
|
52
|
-
*/
|
|
53
|
-
declare function recover(address: Address, newOwners: OwnerSet, chain: Chain, provider?: ProviderConfig): Promise<Call[]>;
|
|
54
|
-
/**
|
|
55
|
-
* Enable ECDSA authentication
|
|
56
|
-
* @param rhinestoneAccount Account to enable ECDSA authentication on
|
|
57
|
-
* @param owners Owners to use for authentication
|
|
58
|
-
* @param threshold Threshold for the owners
|
|
59
|
-
* @returns Calls to enable ECDSA authentication
|
|
60
|
-
*/
|
|
61
|
-
declare function enableEcdsa({ rhinestoneAccount, owners, threshold, }: {
|
|
62
|
-
rhinestoneAccount: RhinestoneAccount;
|
|
63
|
-
owners: Address[];
|
|
64
|
-
threshold?: number;
|
|
65
|
-
}): Call[];
|
|
66
|
-
/**
|
|
67
|
-
* Enable passkeys authentication
|
|
68
|
-
* @param rhinestoneAccount Account to enable passkeys authentication on
|
|
69
|
-
* @param pubKey Public key for the passkey
|
|
70
|
-
* @param authenticatorId Authenticator ID for the passkey
|
|
71
|
-
* @returns Calls to enable passkeys authentication
|
|
72
|
-
*/
|
|
73
|
-
declare function enablePasskeys({ rhinestoneAccount, pubKey, authenticatorId, }: {
|
|
74
|
-
rhinestoneAccount: RhinestoneAccount;
|
|
75
|
-
} & WebauthnCredential): Call[];
|
|
76
|
-
/**
|
|
77
|
-
* Disable ECDSA authentication
|
|
78
|
-
* @param rhinestoneAccount Account to disable ECDSA authentication on
|
|
79
|
-
* @returns Calls to disable ECDSA authentication
|
|
80
|
-
*/
|
|
81
|
-
declare function disableEcdsa({ rhinestoneAccount, }: {
|
|
82
|
-
rhinestoneAccount: RhinestoneAccount;
|
|
83
|
-
}): Call[];
|
|
84
|
-
/**
|
|
85
|
-
* Disable passkeys (WebAuthn) authentication
|
|
86
|
-
* @param rhinestoneAccount Account to disable passkeys authentication on
|
|
87
|
-
* @returns Calls to disable passkeys authentication
|
|
88
|
-
*/
|
|
89
|
-
declare function disablePasskeys({ rhinestoneAccount, }: {
|
|
90
|
-
rhinestoneAccount: RhinestoneAccount;
|
|
91
|
-
}): Call[];
|
|
92
|
-
/**
|
|
93
|
-
* Add an ECDSA owner
|
|
94
|
-
* @param owner Owner address
|
|
95
|
-
* @returns Call to add the owner
|
|
96
|
-
*/
|
|
97
|
-
declare function addOwner(owner: Address): Call;
|
|
98
|
-
/**
|
|
99
|
-
* Remove an ECDSA owner
|
|
100
|
-
* @param prevOwner Previous owner address
|
|
101
|
-
* @param ownerToRemove Owner to remove
|
|
102
|
-
* @returns Call to remove the owner
|
|
103
|
-
*/
|
|
104
|
-
declare function removeOwner(prevOwner: Address, ownerToRemove: Address): Call;
|
|
105
|
-
/**
|
|
106
|
-
* Change an account's signer threshold (ECDSA)
|
|
107
|
-
* @param newThreshold New threshold
|
|
108
|
-
* @returns Call to change the threshold
|
|
109
|
-
*/
|
|
110
|
-
declare function changeThreshold(newThreshold: number): Call;
|
|
111
|
-
/**
|
|
112
|
-
* Add a passkey owner
|
|
113
|
-
* @param pubKeyX Public key X
|
|
114
|
-
* @param pubKeyY Public key Y
|
|
115
|
-
* @param requireUserVerification Whether to require user verification
|
|
116
|
-
* @returns Call to add the passkey owner
|
|
117
|
-
*/
|
|
118
|
-
declare function addPasskeyOwner(pubKeyX: bigint, pubKeyY: bigint, requireUserVerification: boolean): Call;
|
|
119
|
-
/**
|
|
120
|
-
* Remove a passkey owner
|
|
121
|
-
* @param pubKeyX Public key X
|
|
122
|
-
* @param pubKeyY Public key Y
|
|
123
|
-
* @returns Call to remove the passkey owner
|
|
124
|
-
*/
|
|
125
|
-
declare function removePasskeyOwner(pubKeyX: bigint, pubKeyY: bigint): Call;
|
|
126
|
-
/**
|
|
127
|
-
* Change an account's signer threshold (passkey)
|
|
128
|
-
* @param newThreshold New threshold
|
|
129
|
-
* @returns Call to change the threshold
|
|
130
|
-
*/
|
|
131
|
-
declare function changePasskeyThreshold(newThreshold: number): Call;
|
|
132
|
-
/**
|
|
133
|
-
* Recover an account's ownership (ECDSA)
|
|
134
|
-
* @param address Account address
|
|
135
|
-
* @param newOwners New owners
|
|
136
|
-
* @param chain Chain to recover ownership on
|
|
137
|
-
* @param provider Provider to use for the recovery
|
|
138
|
-
* @returns Calls to recover ownership
|
|
139
|
-
*/
|
|
140
|
-
declare function recoverEcdsaOwnership(address: Address, newOwners: OwnableValidatorConfig, chain: Chain, provider?: ProviderConfig): Promise<Call[]>;
|
|
141
|
-
/**
|
|
142
|
-
* Recover an account's ownership (Passkey)
|
|
143
|
-
* @param address Account address
|
|
144
|
-
* @param oldCredentials Old credentials to be replaced (with pubKeyX, pubKeyY)
|
|
145
|
-
* @param newOwners New passkey owners
|
|
146
|
-
* @param chain Chain to recover ownership on
|
|
147
|
-
* @param provider Provider to use for the recovery
|
|
148
|
-
* @returns Calls to recover ownership
|
|
149
|
-
*/
|
|
150
|
-
declare function recoverPasskeyOwnership(address: Address, oldCredentials: {
|
|
151
|
-
pubKeyX: bigint;
|
|
152
|
-
pubKeyY: bigint;
|
|
153
|
-
}[], newOwners: WebauthnValidatorConfig, chain: Chain, provider?: ProviderConfig): Promise<Call[]>;
|
|
154
|
-
/**
|
|
155
|
-
* Enable multi-factor authentication
|
|
156
|
-
* @param rhinestoneAccount Account to enable multi-factor authentication on
|
|
157
|
-
* @param validators List of validators to use
|
|
158
|
-
* @param threshold Threshold for the validators
|
|
159
|
-
* @returns Calls to enable multi-factor authentication
|
|
160
|
-
*/
|
|
161
|
-
declare function enableMultiFactor({ rhinestoneAccount, validators, threshold, }: {
|
|
162
|
-
rhinestoneAccount: RhinestoneAccount;
|
|
163
|
-
validators: (OwnableValidatorConfig | WebauthnValidatorConfig | null)[];
|
|
164
|
-
threshold?: number;
|
|
165
|
-
}): Call[];
|
|
166
|
-
/**
|
|
167
|
-
* Disable multi-factor authentication
|
|
168
|
-
* @param rhinestoneAccount Account to disable multi-factor authentication on
|
|
169
|
-
* @returns Calls to disable multi-factor authentication
|
|
170
|
-
*/
|
|
171
|
-
declare function disableMultiFactor({ rhinestoneAccount, }: {
|
|
172
|
-
rhinestoneAccount: RhinestoneAccount;
|
|
173
|
-
}): Call[];
|
|
174
|
-
/**
|
|
175
|
-
* Change the multi-factor threshold
|
|
176
|
-
* @param newThreshold New threshold
|
|
177
|
-
* @returns Call to change the threshold
|
|
178
|
-
*/
|
|
179
|
-
declare function changeMultiFactorThreshold(newThreshold: number): Call;
|
|
180
|
-
/**
|
|
181
|
-
* Set a sub-validator (multi-factor)
|
|
182
|
-
* @param id Validator ID
|
|
183
|
-
* @param validator Validator module
|
|
184
|
-
* @returns Call to set the sub-validator
|
|
185
|
-
*/
|
|
186
|
-
declare function setSubValidator(id: Hex | number, validator: OwnableValidatorConfig | WebauthnValidatorConfig): Call;
|
|
187
|
-
/**
|
|
188
|
-
* Remove a sub-validator (multi-factor)
|
|
189
|
-
* @param id Validator ID
|
|
190
|
-
* @param validator Validator module
|
|
191
|
-
* @returns Call to remove the sub-validator
|
|
192
|
-
*/
|
|
193
|
-
declare function removeSubValidator(id: Hex | number, validator: OwnableValidatorConfig | WebauthnValidatorConfig): Call;
|
|
194
|
-
export { installModule, uninstallModule, enableEcdsa, enablePasskeys, disableEcdsa, disablePasskeys, addOwner, removeOwner, changeThreshold, addPasskeyOwner, removePasskeyOwner, changePasskeyThreshold, recover, recoverEcdsaOwnership, recoverPasskeyOwnership, setUpRecovery, encodeSmartSessionSignature, enableMultiFactor, disableMultiFactor, changeMultiFactorThreshold, setSubValidator, removeSubValidator, };
|
|
22
|
+
declare function uninstallModule(module: ModuleInput): LazyCallInput;
|
|
23
|
+
export { installModule, uninstallModule };
|
|
195
24
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../actions/index.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../actions/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,MAAM,CAAA;AAMxC,OAAO,EAAe,KAAK,UAAU,EAAkB,MAAM,mBAAmB,CAAA;AAChF,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,UAAU,CAAA;AAE7C,UAAU,WAAW;IACnB,IAAI,EAAE,UAAU,CAAA;IAChB,OAAO,EAAE,OAAO,CAAA;IAChB,QAAQ,CAAC,EAAE,GAAG,CAAA;IACd,UAAU,CAAC,EAAE,GAAG,CAAA;IAChB,iBAAiB,CAAC,EAAE,GAAG,CAAA;CACxB;AAED;;;;GAIG;AACH,iBAAS,aAAa,CAAC,MAAM,EAAE,WAAW,GAAG,aAAa,CAOzD;AAED;;;;GAIG;AACH,iBAAS,eAAe,CAAC,MAAM,EAAE,WAAW,GAAG,aAAa,CAO3D;AAYD,OAAO,EAAE,aAAa,EAAE,eAAe,EAAE,CAAA"}
|