@charterlabs/rhinestone-sdk 0.1.13 → 0.2.1
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 +181 -74
- package/dist/src/accounts/index.d.ts +8 -7
- package/dist/src/accounts/index.d.ts.map +1 -1
- package/dist/src/accounts/index.js +65 -210
- package/dist/src/accounts/index.test.js +2 -3
- package/dist/src/accounts/kernel.d.ts +3 -2
- package/dist/src/accounts/kernel.d.ts.map +1 -1
- package/dist/src/accounts/kernel.js +3 -5
- package/dist/src/accounts/kernel.test.js +5 -12
- package/dist/src/accounts/nexus.d.ts +2 -2
- package/dist/src/accounts/nexus.d.ts.map +1 -1
- package/dist/src/accounts/nexus.js +17 -17
- package/dist/src/accounts/nexus.test.js +11 -14
- package/dist/src/accounts/safe.d.ts +2 -2
- package/dist/src/accounts/safe.d.ts.map +1 -1
- package/dist/src/accounts/safe.js +3 -5
- package/dist/src/accounts/safe.test.js +4 -7
- package/dist/src/accounts/signing/common.d.ts +23 -0
- package/dist/src/accounts/signing/common.d.ts.map +1 -0
- package/dist/src/accounts/signing/common.js +113 -0
- package/dist/src/accounts/signing/message.d.ts +5 -0
- package/dist/src/accounts/signing/message.d.ts.map +1 -0
- package/dist/src/accounts/signing/message.js +51 -0
- package/dist/src/accounts/signing/typedData.d.ts +5 -0
- package/dist/src/accounts/signing/typedData.d.ts.map +1 -0
- package/dist/src/accounts/signing/typedData.js +39 -0
- package/dist/src/accounts/startale.d.ts +2 -2
- package/dist/src/accounts/startale.d.ts.map +1 -1
- package/dist/src/accounts/startale.js +3 -3
- package/dist/src/accounts/startale.test.js +4 -7
- package/dist/src/actions/index.d.ts +84 -0
- package/dist/src/actions/index.d.ts.map +1 -1
- package/dist/src/actions/index.js +92 -0
- package/dist/src/actions/index.test.js +15 -15
- package/dist/src/actions/smart-session.d.ts +6 -0
- package/dist/src/actions/smart-session.d.ts.map +1 -1
- package/dist/src/actions/smart-session.js +6 -0
- package/dist/src/execution/compact.d.ts +128 -1
- package/dist/src/execution/compact.d.ts.map +1 -1
- package/dist/src/execution/compact.js +91 -0
- package/dist/src/execution/index.d.ts.map +1 -1
- package/dist/src/execution/index.js +2 -3
- package/dist/src/execution/utils.d.ts +6 -5
- package/dist/src/execution/utils.d.ts.map +1 -1
- package/dist/src/execution/utils.js +37 -17
- package/dist/src/index.d.ts +9 -7
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +92 -31
- package/dist/src/modules/index.d.ts +3 -8
- package/dist/src/modules/index.d.ts.map +1 -1
- package/dist/src/modules/index.js +26 -27
- package/dist/src/modules/index.test.js +1 -4
- package/dist/src/modules/validators/core.d.ts.map +1 -1
- package/dist/src/modules/validators/core.js +19 -14
- package/dist/src/modules/validators/core.test.js +4 -11
- package/dist/src/modules/validators/index.d.ts +1 -2
- package/dist/src/modules/validators/index.d.ts.map +1 -1
- package/dist/src/modules/validators/index.js +1 -13
- package/dist/src/modules/validators/smart-sessions.js +3 -3
- package/dist/src/modules/validators/smart-sessions.test.js +4 -4
- package/dist/src/orchestrator/index.d.ts +1 -2
- package/dist/src/orchestrator/index.d.ts.map +1 -1
- package/dist/src/orchestrator/index.js +1 -3
- package/dist/src/orchestrator/utils.d.ts +1 -3
- package/dist/src/orchestrator/utils.d.ts.map +1 -1
- package/dist/src/orchestrator/utils.js +0 -102
- package/dist/src/types.d.ts +2 -5
- package/dist/src/types.d.ts.map +1 -1
- package/package.json +2 -2
|
@@ -18,7 +18,6 @@ const core_1 = require("./validators/core");
|
|
|
18
18
|
const SMART_SESSION_COMPATIBILITY_FALLBACK_ADDRESS = '0x12cae64c42f362e7d5a847c2d33388373f629177';
|
|
19
19
|
function getSetup(config) {
|
|
20
20
|
const ownerValidator = (0, validators_1.getOwnerValidator)(config);
|
|
21
|
-
console.log('what validator is being installed', ownerValidator.type);
|
|
22
21
|
const smartSessionValidator = (0, validators_1.getSmartSessionValidator)(config);
|
|
23
22
|
const validators = [ownerValidator];
|
|
24
23
|
if (smartSessionValidator) {
|
|
@@ -60,14 +59,10 @@ function getSetup(config) {
|
|
|
60
59
|
executors,
|
|
61
60
|
fallbacks,
|
|
62
61
|
hooks,
|
|
63
|
-
registry: viem_1.zeroAddress,
|
|
64
|
-
attesters: [],
|
|
65
|
-
threshold: 0,
|
|
66
62
|
};
|
|
67
63
|
}
|
|
68
|
-
function getWebauthnValidatorSignature(
|
|
69
|
-
const {
|
|
70
|
-
const { authenticatorData, clientDataJSON, challengeIndex, typeIndex } = webauthn;
|
|
64
|
+
function getWebauthnValidatorSignature({ webauthn, signature, usePrecompiled = false, }) {
|
|
65
|
+
const { authenticatorData, clientDataJSON, typeIndex } = webauthn;
|
|
71
66
|
let r;
|
|
72
67
|
let s;
|
|
73
68
|
if (typeof signature === 'string' || signature instanceof Uint8Array) {
|
|
@@ -79,31 +74,35 @@ function getWebauthnValidatorSignature(params) {
|
|
|
79
74
|
r = signature.r;
|
|
80
75
|
s = signature.s;
|
|
81
76
|
}
|
|
82
|
-
const auth = [{
|
|
83
|
-
authenticatorData,
|
|
84
|
-
clientDataJSON,
|
|
85
|
-
challengeIndex: BigInt(challengeIndex),
|
|
86
|
-
typeIndex: BigInt(typeIndex),
|
|
87
|
-
r,
|
|
88
|
-
s
|
|
89
|
-
}];
|
|
90
77
|
return (0, viem_1.encodeAbiParameters)([
|
|
91
|
-
{ type: '
|
|
92
|
-
{ type: 'bool', name: 'usePrecompiled' },
|
|
78
|
+
{ type: 'bytes', name: 'authenticatorData' },
|
|
93
79
|
{
|
|
94
|
-
type: '
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
80
|
+
type: 'string',
|
|
81
|
+
name: 'clientDataJSON',
|
|
82
|
+
},
|
|
83
|
+
{
|
|
84
|
+
type: 'uint256',
|
|
85
|
+
name: 'responseTypeLocation',
|
|
86
|
+
},
|
|
87
|
+
{
|
|
88
|
+
type: 'uint256',
|
|
89
|
+
name: 'r',
|
|
90
|
+
},
|
|
91
|
+
{
|
|
92
|
+
type: 'uint256',
|
|
93
|
+
name: 's',
|
|
94
|
+
},
|
|
95
|
+
{
|
|
96
|
+
type: 'bool',
|
|
97
|
+
name: 'usePrecompiled',
|
|
102
98
|
},
|
|
103
99
|
], [
|
|
104
|
-
|
|
100
|
+
authenticatorData,
|
|
101
|
+
clientDataJSON,
|
|
102
|
+
typeof typeIndex === 'bigint' ? typeIndex : BigInt(typeIndex),
|
|
103
|
+
r,
|
|
104
|
+
s,
|
|
105
105
|
usePrecompiled,
|
|
106
|
-
auth,
|
|
107
106
|
]);
|
|
108
107
|
}
|
|
109
108
|
function isRip7212SupportedNetwork(chain) {
|
|
@@ -15,7 +15,7 @@ const index_1 = require("./index");
|
|
|
15
15
|
},
|
|
16
16
|
};
|
|
17
17
|
const setup = (0, index_1.getSetup)(config);
|
|
18
|
-
(0, vitest_1.expect)(setup.validators[0].address).toBe('
|
|
18
|
+
(0, vitest_1.expect)(setup.validators[0].address).toBe('0x20C008719Ba9D8aA14C7d07D122cd5E965aA8da5');
|
|
19
19
|
(0, vitest_1.expect)(setup.validators[0].type).toBe(1n);
|
|
20
20
|
});
|
|
21
21
|
(0, vitest_1.test)('should use webauthn validator for passkey owners', () => {
|
|
@@ -24,7 +24,6 @@ const index_1 = require("./index");
|
|
|
24
24
|
owners: {
|
|
25
25
|
type: 'passkey',
|
|
26
26
|
account: consts_1.passkeyAccount,
|
|
27
|
-
credentialIds: ['0x1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef'],
|
|
28
27
|
},
|
|
29
28
|
};
|
|
30
29
|
const setup = (0, index_1.getSetup)(config);
|
|
@@ -91,11 +90,9 @@ const index_1 = require("./index");
|
|
|
91
90
|
(0, vitest_1.describe)('WebAuthn Validator Signature', () => {
|
|
92
91
|
(0, vitest_1.test)('default', () => {
|
|
93
92
|
const signature = (0, index_1.getWebauthnValidatorSignature)({
|
|
94
|
-
credentialIds: ['0x1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef'],
|
|
95
93
|
webauthn: {
|
|
96
94
|
authenticatorData: '0x49960de5880e8c687434170f6476605b8fe4aeb9a28632c7995cf3ba831d97631d00000000',
|
|
97
95
|
clientDataJSON: '{"type":"webauthn.get","challenge":"tbxXNFS9X_4Byr1cMwqKrIGB-_30a0QhZ6y7ucM0BOE","origin":"http://localhost:3000","crossOrigin":false, "other_keys_can_be_added_here":"do not compare clientDataJSON against a template. See https://goo.gl/yabPex"}',
|
|
98
|
-
challengeIndex: 23n,
|
|
99
96
|
typeIndex: 44941127272049826721201904734628716258498742255959991581049806490182030242267n,
|
|
100
97
|
},
|
|
101
98
|
signature: '0x00000000000000000000000000000000000000000000000000000000000000c000000000000000000000000000000000000000000000000000000000000001200000000000000000000000000000000000000000000000000000000000000001635bc6d0f68ff895cae8a288ecf7542a6a9cd555df784b73e1e2ea7e9104b1db15e9015d280cb19527881c625fee43fd3a405d5b0d199a8c8e6589a7381209e40000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002549960de5880e8c687434170f6476605b8fe4aeb9a28632c7995cf3ba831d97631d0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000f47b2274797065223a22776562617574686e2e676574222c226368616c6c656e6765223a22746278584e465339585f3442797231634d77714b724947422d5f3330613051685a36793775634d30424f45222c226f726967696e223a22687474703a2f2f6c6f63616c686f73743a33303030222c2263726f73734f726967696e223a66616c73652c20226f746865725f6b6579735f63616e5f62655f61646465645f68657265223a22646f206e6f7420636f6d7061726520636c69656e74446174614a534f4e20616761696e737420612074656d706c6174652e205365652068747470733a2f2f676f6f2e676c2f796162506578227d000000000000000000000000',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"core.d.ts","sourceRoot":"","sources":["../../../../modules/validators/core.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,OAAO,EACZ,KAAK,OAAO,EAKZ,KAAK,GAAG,EAKT,MAAM,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C,EAAE,MAAM,GAAG,SAAS,CAAA;IAC3B,CAAC,EAAE,MAAM,CAAA;IACT,CAAC,EAAE,MAAM,CAAA;CACV;AAED,UAAU,kBAAkB;IAC1B,MAAM,EAAE,SAAS,GAAG,GAAG,GAAG,UAAU,CAAA;IACpC,eAAe,EAAE,MAAM,CAAA;CACxB;AAED,QAAA,MAAM,yBAAyB,EAAE,OACa,CAAA;AAC9C,QAAA,MAAM,0BAA0B,EAAE,OACY,CAAA;AAG9C,QAAA,MAAM,8BAA8B,EAAE,OACQ,CAAA;AAO9C,iBAAS,iBAAiB,CAAC,MAAM,EAAE,uBAAuB,UAEzD;AAED,iBAAS,gBAAgB,CAAC,QAAQ,EAAE,QAAQ,GAAG,GAAG,CAiDjD;AAED,iBAAS,YAAY,CAAC,MAAM,EAAE,QAAQ,UAgBrC;AAED,iBAAS,mBAAmB,CAAC,SAAS,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,GAAG,MAAM,CAiBzE;AAED,iBAAS,oBAAoB,CAAC,kBAAkB,EAAE,kBAAkB,GAAG,MAAM,CAwD5E;AAED,iBAAS,uBAAuB,CAC9B,SAAS,EAAE,MAAM,EACjB,UAAU,EAAE,CAAC,sBAAsB,GAAG,uBAAuB,GAAG,IAAI,CAAC,EAAE,GACtE,MAAM,CAgDR;AAED,iBAAS,0BAA0B,CACjC,SAAS,EAAE,OAAO,EAAE,EACpB,SAAS,SAAI,GACZ,MAAM,CAsBR;AAeD,OAAO,EACL,yBAAyB,EACzB,0BAA0B,EAC1B,8BAA8B,EAC9B,iBAAiB,EACjB,mBAAmB,EACnB,oBAAoB,EACpB,uBAAuB,EACvB,0BAA0B,EAC1B,YAAY,EACZ,gBAAgB,GACjB,CAAA;AACD,YAAY,EAAE,kBAAkB,EAAE,CAAA"}
|
|
@@ -10,7 +10,7 @@ exports.getValidator = getValidator;
|
|
|
10
10
|
exports.getMockSignature = getMockSignature;
|
|
11
11
|
const viem_1 = require("viem");
|
|
12
12
|
const common_1 = require("../common");
|
|
13
|
-
const OWNABLE_VALIDATOR_ADDRESS = '
|
|
13
|
+
const OWNABLE_VALIDATOR_ADDRESS = '0x20C008719Ba9D8aA14C7d07D122cd5E965aA8da5';
|
|
14
14
|
exports.OWNABLE_VALIDATOR_ADDRESS = OWNABLE_VALIDATOR_ADDRESS;
|
|
15
15
|
const WEBAUTHN_VALIDATOR_ADDRESS = '0x0000000000578c4cB0e472a5462da43C495C3F33';
|
|
16
16
|
exports.WEBAUTHN_VALIDATOR_ADDRESS = WEBAUTHN_VALIDATOR_ADDRESS;
|
|
@@ -97,18 +97,15 @@ function getWebAuthnValidator(webAuthnCredential) {
|
|
|
97
97
|
// Distinguish between PublicKey and Hex / byte encoded public key
|
|
98
98
|
if (typeof webAuthnCredential.pubKey === 'string' ||
|
|
99
99
|
webAuthnCredential.pubKey instanceof Uint8Array) {
|
|
100
|
-
console.log('webAuthnCredential.pubKey in the if of webauthn validator');
|
|
101
100
|
// It's a P256Credential
|
|
102
101
|
const { x, y, prefix } = parsePublicKey(webAuthnCredential.pubKey);
|
|
103
102
|
pubKeyX = x;
|
|
104
103
|
pubKeyY = y;
|
|
105
104
|
if (prefix && prefix !== 4) {
|
|
106
|
-
console.log('prefix is not 4');
|
|
107
105
|
throw new Error('Only uncompressed public keys are supported');
|
|
108
106
|
}
|
|
109
107
|
}
|
|
110
108
|
else {
|
|
111
|
-
console.log('webAuthnCredential.pubKey in the else of webauthn validator');
|
|
112
109
|
// It's already a PublicKey
|
|
113
110
|
pubKeyX = webAuthnCredential.pubKey.x;
|
|
114
111
|
pubKeyY = webAuthnCredential.pubKey.y;
|
|
@@ -116,21 +113,29 @@ function getWebAuthnValidator(webAuthnCredential) {
|
|
|
116
113
|
return {
|
|
117
114
|
address: WEBAUTHN_VALIDATOR_ADDRESS,
|
|
118
115
|
initData: (0, viem_1.encodeAbiParameters)([
|
|
119
|
-
{ name: 'threshold', type: 'uint256' },
|
|
120
116
|
{
|
|
121
|
-
name: 'credentials',
|
|
122
|
-
type: 'tuple[]',
|
|
123
117
|
components: [
|
|
124
|
-
{
|
|
125
|
-
|
|
126
|
-
|
|
118
|
+
{
|
|
119
|
+
name: 'pubKeyX',
|
|
120
|
+
type: 'uint256',
|
|
121
|
+
},
|
|
122
|
+
{
|
|
123
|
+
name: 'pubKeyY',
|
|
124
|
+
type: 'uint256',
|
|
125
|
+
},
|
|
127
126
|
],
|
|
127
|
+
type: 'tuple',
|
|
128
|
+
},
|
|
129
|
+
{
|
|
130
|
+
type: 'bytes32',
|
|
131
|
+
name: 'authenticatorIdHash',
|
|
128
132
|
},
|
|
129
133
|
], [
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
+
{
|
|
135
|
+
pubKeyX,
|
|
136
|
+
pubKeyY,
|
|
137
|
+
},
|
|
138
|
+
(0, viem_1.keccak256)((0, viem_1.toHex)(webAuthnCredential.authenticatorId)),
|
|
134
139
|
]),
|
|
135
140
|
deInitData: '0x',
|
|
136
141
|
additionalContext: '0x',
|
|
@@ -14,7 +14,7 @@ const core_1 = require("./core");
|
|
|
14
14
|
});
|
|
15
15
|
(0, vitest_1.expect)(validator.type).toEqual(common_1.MODULE_TYPE_ID_VALIDATOR);
|
|
16
16
|
(0, vitest_1.expect)((0, viem_1.isAddress)(validator.address)).toEqual(true);
|
|
17
|
-
(0, vitest_1.expect)(validator.address).toEqual('
|
|
17
|
+
(0, vitest_1.expect)(validator.address).toEqual('0x20C008719Ba9D8aA14C7d07D122cd5E965aA8da5');
|
|
18
18
|
(0, vitest_1.expect)(validator.initData).toEqual('0x000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000001000000000000000000000000f6c02c78ded62973b43bfa523b247da099486936');
|
|
19
19
|
});
|
|
20
20
|
(0, vitest_1.test)('ECDSA: two addresses', () => {
|
|
@@ -24,7 +24,7 @@ const core_1 = require("./core");
|
|
|
24
24
|
});
|
|
25
25
|
(0, vitest_1.expect)(validator.type).toEqual(common_1.MODULE_TYPE_ID_VALIDATOR);
|
|
26
26
|
(0, vitest_1.expect)((0, viem_1.isAddress)(validator.address)).toEqual(true);
|
|
27
|
-
(0, vitest_1.expect)(validator.address).toEqual('
|
|
27
|
+
(0, vitest_1.expect)(validator.address).toEqual('0x20C008719Ba9D8aA14C7d07D122cd5E965aA8da5');
|
|
28
28
|
(0, vitest_1.expect)(validator.initData).toEqual('0x0000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000020000000000000000000000006092086a3dc0020cd604a68fcf5d430007d51bb7000000000000000000000000f6c02c78ded62973b43bfa523b247da099486936');
|
|
29
29
|
});
|
|
30
30
|
(0, vitest_1.test)('ECDSA: three addresses, custom threshold', () => {
|
|
@@ -35,24 +35,18 @@ const core_1 = require("./core");
|
|
|
35
35
|
});
|
|
36
36
|
(0, vitest_1.expect)(validator.type).toEqual(common_1.MODULE_TYPE_ID_VALIDATOR);
|
|
37
37
|
(0, vitest_1.expect)((0, viem_1.isAddress)(validator.address)).toEqual(true);
|
|
38
|
-
(0, vitest_1.expect)(validator.address).toEqual('
|
|
38
|
+
(0, vitest_1.expect)(validator.address).toEqual('0x20C008719Ba9D8aA14C7d07D122cd5E965aA8da5');
|
|
39
39
|
(0, vitest_1.expect)(validator.initData).toEqual('0x0000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000030000000000000000000000006092086a3dc0020cd604a68fcf5d430007d51bb7000000000000000000000000c27b7578151c5ef713c62c65db09763d57ac3596000000000000000000000000f6c02c78ded62973b43bfa523b247da099486936');
|
|
40
40
|
});
|
|
41
41
|
(0, vitest_1.test)('Passkey', () => {
|
|
42
42
|
const validator = (0, core_1.getValidator)({
|
|
43
43
|
type: 'passkey',
|
|
44
44
|
account: consts_1.passkeyAccount,
|
|
45
|
-
credentialIds: ['0x1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef'],
|
|
46
45
|
});
|
|
47
46
|
(0, vitest_1.expect)(validator.type).toEqual(common_1.MODULE_TYPE_ID_VALIDATOR);
|
|
48
47
|
(0, vitest_1.expect)((0, viem_1.isAddress)(validator.address)).toEqual(true);
|
|
49
48
|
(0, vitest_1.expect)(validator.address).toEqual('0x0000000000578c4cB0e472a5462da43C495C3F33');
|
|
50
|
-
(0, vitest_1.expect)(validator.initData).toEqual('
|
|
51
|
-
'0000000000000000000000000000000000000000000000000000000000000040' +
|
|
52
|
-
'0000000000000000000000000000000000000000000000000000000000000001' +
|
|
53
|
-
'580a9af0569ad3905b26a703201b358aa0904236642ebe79b22a19d00d373763' +
|
|
54
|
-
'7d46f725a5427ae45a9569259bf67e1e16b187d7b3ad1ed70138c4f0409677d1' +
|
|
55
|
-
'0000000000000000000000000000000000000000000000000000000000000000');
|
|
49
|
+
(0, vitest_1.expect)(validator.initData).toEqual('0x580a9af0569ad3905b26a703201b358aa0904236642ebe79b22a19d00d3737637d46f725a5427ae45a9569259bf67e1e16b187d7b3ad1ed70138c4f0409677d19c9a01073b202db2ed56e604ad11db557d8c3ad75181619597f21b830f2da82a');
|
|
56
50
|
});
|
|
57
51
|
});
|
|
58
52
|
(0, vitest_1.describe)('Mock Signature', () => {
|
|
@@ -74,7 +68,6 @@ const core_1 = require("./core");
|
|
|
74
68
|
const signature = (0, core_1.getMockSignature)({
|
|
75
69
|
type: 'passkey',
|
|
76
70
|
account: consts_1.passkeyAccount,
|
|
77
|
-
credentialIds: ['0x1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef'],
|
|
78
71
|
});
|
|
79
72
|
// Should have the proper schema
|
|
80
73
|
(0, viem_1.decodeAbiParameters)([
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { getMockSignature, getOwnerValidator } from './core';
|
|
2
2
|
import { encodeSmartSessionSignature, getEnableSessionCall, getPermissionId, getSmartSessionValidator, isSessionEnabled, SMART_SESSION_MODE_ENABLE, SMART_SESSION_MODE_USE, SMART_SESSIONS_VALIDATOR_ADDRESS } from './smart-sessions';
|
|
3
|
-
|
|
4
|
-
export { SMART_SESSION_MODE_USE, SMART_SESSION_MODE_ENABLE, SMART_SESSIONS_VALIDATOR_ADDRESS, getOwnerValidator, getSmartSessionValidator, getEnableSessionCall, encodeSmartSessionSignature, getPermissionId, getMockSignature, isSessionEnabled, addCredential, generateCredentialId, getCredentialIds, getCredentialInfo, getCredentials, getThreshold, hasCredential, hasCredentialById, removeCredential, setThreshold, WEBAUTHN_VALIDATOR_ABI, };
|
|
3
|
+
export { SMART_SESSION_MODE_USE, SMART_SESSION_MODE_ENABLE, SMART_SESSIONS_VALIDATOR_ADDRESS, getOwnerValidator, getSmartSessionValidator, getEnableSessionCall, encodeSmartSessionSignature, getPermissionId, getMockSignature, isSessionEnabled, };
|
|
5
4
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../modules/validators/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,MAAM,QAAQ,CAAA;AAC5D,OAAO,EACL,2BAA2B,EAC3B,oBAAoB,EACpB,eAAe,EACf,wBAAwB,EACxB,gBAAgB,EAChB,yBAAyB,EACzB,sBAAsB,EACtB,gCAAgC,EACjC,MAAM,kBAAkB,CAAA;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../modules/validators/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,MAAM,QAAQ,CAAA;AAC5D,OAAO,EACL,2BAA2B,EAC3B,oBAAoB,EACpB,eAAe,EACf,wBAAwB,EACxB,gBAAgB,EAChB,yBAAyB,EACzB,sBAAsB,EACtB,gCAAgC,EACjC,MAAM,kBAAkB,CAAA;AAEzB,OAAO,EACL,sBAAsB,EACtB,yBAAyB,EACzB,gCAAgC,EAChC,iBAAiB,EACjB,wBAAwB,EACxB,oBAAoB,EACpB,2BAA2B,EAC3B,eAAe,EACf,gBAAgB,EAChB,gBAAgB,GACjB,CAAA"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.isSessionEnabled = exports.getMockSignature = exports.getPermissionId = exports.encodeSmartSessionSignature = exports.getEnableSessionCall = exports.getSmartSessionValidator = exports.getOwnerValidator = exports.SMART_SESSIONS_VALIDATOR_ADDRESS = exports.SMART_SESSION_MODE_ENABLE = exports.SMART_SESSION_MODE_USE = void 0;
|
|
4
4
|
const core_1 = require("./core");
|
|
5
5
|
Object.defineProperty(exports, "getMockSignature", { enumerable: true, get: function () { return core_1.getMockSignature; } });
|
|
6
6
|
Object.defineProperty(exports, "getOwnerValidator", { enumerable: true, get: function () { return core_1.getOwnerValidator; } });
|
|
@@ -13,15 +13,3 @@ Object.defineProperty(exports, "isSessionEnabled", { enumerable: true, get: func
|
|
|
13
13
|
Object.defineProperty(exports, "SMART_SESSION_MODE_ENABLE", { enumerable: true, get: function () { return smart_sessions_1.SMART_SESSION_MODE_ENABLE; } });
|
|
14
14
|
Object.defineProperty(exports, "SMART_SESSION_MODE_USE", { enumerable: true, get: function () { return smart_sessions_1.SMART_SESSION_MODE_USE; } });
|
|
15
15
|
Object.defineProperty(exports, "SMART_SESSIONS_VALIDATOR_ADDRESS", { enumerable: true, get: function () { return smart_sessions_1.SMART_SESSIONS_VALIDATOR_ADDRESS; } });
|
|
16
|
-
const webauthn_contract_1 = require("./webauthn-contract");
|
|
17
|
-
Object.defineProperty(exports, "addCredential", { enumerable: true, get: function () { return webauthn_contract_1.addCredential; } });
|
|
18
|
-
Object.defineProperty(exports, "generateCredentialId", { enumerable: true, get: function () { return webauthn_contract_1.generateCredentialId; } });
|
|
19
|
-
Object.defineProperty(exports, "getCredentialIds", { enumerable: true, get: function () { return webauthn_contract_1.getCredentialIds; } });
|
|
20
|
-
Object.defineProperty(exports, "getCredentialInfo", { enumerable: true, get: function () { return webauthn_contract_1.getCredentialInfo; } });
|
|
21
|
-
Object.defineProperty(exports, "getCredentials", { enumerable: true, get: function () { return webauthn_contract_1.getCredentials; } });
|
|
22
|
-
Object.defineProperty(exports, "getThreshold", { enumerable: true, get: function () { return webauthn_contract_1.getThreshold; } });
|
|
23
|
-
Object.defineProperty(exports, "hasCredential", { enumerable: true, get: function () { return webauthn_contract_1.hasCredential; } });
|
|
24
|
-
Object.defineProperty(exports, "hasCredentialById", { enumerable: true, get: function () { return webauthn_contract_1.hasCredentialById; } });
|
|
25
|
-
Object.defineProperty(exports, "removeCredential", { enumerable: true, get: function () { return webauthn_contract_1.removeCredential; } });
|
|
26
|
-
Object.defineProperty(exports, "setThreshold", { enumerable: true, get: function () { return webauthn_contract_1.setThreshold; } });
|
|
27
|
-
Object.defineProperty(exports, "WEBAUTHN_VALIDATOR_ABI", { enumerable: true, get: function () { return webauthn_contract_1.WEBAUTHN_VALIDATOR_ABI; } });
|
|
@@ -294,9 +294,9 @@ function getPolicyData(policy) {
|
|
|
294
294
|
case 'time-frame': {
|
|
295
295
|
return {
|
|
296
296
|
policy: TIME_FRAME_POLICY_ADDRESS,
|
|
297
|
-
initData: (0, viem_1.encodePacked)(['
|
|
298
|
-
|
|
299
|
-
|
|
297
|
+
initData: (0, viem_1.encodePacked)(['uint48', 'uint48'], [
|
|
298
|
+
Math.floor(policy.validUntil / 1000),
|
|
299
|
+
Math.floor(policy.validAfter / 1000),
|
|
300
300
|
]),
|
|
301
301
|
};
|
|
302
302
|
}
|
|
@@ -15,7 +15,7 @@ const smart_sessions_2 = require("./smart-sessions");
|
|
|
15
15
|
type: 'ecdsa',
|
|
16
16
|
accounts: [consts_1.accountA, consts_1.accountB],
|
|
17
17
|
},
|
|
18
|
-
})).toBe('
|
|
18
|
+
})).toBe('0xf24845e5da40837f1dc8f1d6ce3d2fd64e96b35e9c9eccf614ed2c4e3be70e9f');
|
|
19
19
|
});
|
|
20
20
|
(0, vitest_1.test)('with salt', () => {
|
|
21
21
|
(0, vitest_1.expect)((0, smart_sessions_2.getPermissionId)({
|
|
@@ -24,7 +24,7 @@ const smart_sessions_2 = require("./smart-sessions");
|
|
|
24
24
|
accounts: [consts_1.accountA, consts_1.accountB],
|
|
25
25
|
},
|
|
26
26
|
salt: '0x97340e1cfff3319c76ef22b2bc9d3231071d550125d68c9d4a8972823f166320',
|
|
27
|
-
})).toBe('
|
|
27
|
+
})).toBe('0xee8658aa7297fb41dc2658545e3c99eb2173085b4c982b9ab3802af86b3adf54');
|
|
28
28
|
});
|
|
29
29
|
});
|
|
30
30
|
(0, vitest_1.describe)('Smart Session Validator', () => {
|
|
@@ -217,10 +217,10 @@ const smart_sessions_2 = require("./smart-sessions");
|
|
|
217
217
|
});
|
|
218
218
|
(0, vitest_1.describe)('Encode Smart Session Signature', () => {
|
|
219
219
|
(0, vitest_1.test)('use mode', () => {
|
|
220
|
-
const permissionId = '
|
|
220
|
+
const permissionId = '0xf24845e5da40837f1dc8f1d6ce3d2fd64e96b35e9c9eccf614ed2c4e3be70e9f';
|
|
221
221
|
const signature = '0xabcdef';
|
|
222
222
|
const sessionSignature = (0, smart_sessions_2.encodeSmartSessionSignature)(smart_sessions_2.SMART_SESSION_MODE_USE, permissionId, signature);
|
|
223
|
-
(0, vitest_1.expect)(sessionSignature).toEqual('
|
|
223
|
+
(0, vitest_1.expect)(sessionSignature).toEqual('0x00f24845e5da40837f1dc8f1d6ce3d2fd64e96b35e9c9eccf614ed2c4e3be70e9fabcdef');
|
|
224
224
|
});
|
|
225
225
|
});
|
|
226
226
|
});
|
|
@@ -4,8 +4,7 @@ import { AuthenticationRequiredError, InsufficientBalanceError, IntentNotFoundEr
|
|
|
4
4
|
import { getSupportedTokens, getTokenAddress, getTokenSymbol, getWethAddress, isTokenAddressSupported } from './registry';
|
|
5
5
|
import type { IntentCost, IntentInput, IntentOp, IntentOpStatus, IntentResult, IntentRoute, Portfolio, SettlementSystem, SignedIntentOp, SupportedChain, TokenConfig } from './types';
|
|
6
6
|
import { INTENT_STATUS_COMPLETED, INTENT_STATUS_EXPIRED, INTENT_STATUS_FAILED, INTENT_STATUS_FILLED, INTENT_STATUS_PARTIALLY_COMPLETED, INTENT_STATUS_PENDING, INTENT_STATUS_PRECONFIRMED, INTENT_STATUS_UNKNOWN } from './types';
|
|
7
|
-
import { getIntentOpHash } from './utils';
|
|
8
7
|
declare function getOrchestrator(apiKey: string, orchestratorUrl?: string): Orchestrator;
|
|
9
8
|
export type { IntentCost, IntentInput, IntentOp, IntentOpStatus, IntentResult, IntentRoute, SettlementSystem, SignedIntentOp, SupportedChain, TokenConfig, Portfolio, };
|
|
10
|
-
export { INTENT_STATUS_PENDING, INTENT_STATUS_EXPIRED, INTENT_STATUS_PARTIALLY_COMPLETED, INTENT_STATUS_COMPLETED, INTENT_STATUS_FILLED, INTENT_STATUS_FAILED, INTENT_STATUS_PRECONFIRMED, INTENT_STATUS_UNKNOWN, RHINESTONE_SPOKE_POOL_ADDRESS, Orchestrator, AuthenticationRequiredError, InsufficientBalanceError, InvalidApiKeyError, InvalidIntentSignatureError, NoPathFoundError, OnlyOneTargetTokenAmountCanBeUnsetError, OrchestratorError, IntentNotFoundError, TokenNotSupportedError, UnsupportedChainError, UnsupportedChainIdError, UnsupportedTokenError, getOrchestrator,
|
|
9
|
+
export { INTENT_STATUS_PENDING, INTENT_STATUS_EXPIRED, INTENT_STATUS_PARTIALLY_COMPLETED, INTENT_STATUS_COMPLETED, INTENT_STATUS_FILLED, INTENT_STATUS_FAILED, INTENT_STATUS_PRECONFIRMED, INTENT_STATUS_UNKNOWN, RHINESTONE_SPOKE_POOL_ADDRESS, Orchestrator, AuthenticationRequiredError, InsufficientBalanceError, InvalidApiKeyError, InvalidIntentSignatureError, NoPathFoundError, OnlyOneTargetTokenAmountCanBeUnsetError, OrchestratorError, IntentNotFoundError, TokenNotSupportedError, UnsupportedChainError, UnsupportedChainIdError, UnsupportedTokenError, getOrchestrator, getWethAddress, getTokenSymbol, getTokenAddress, getSupportedTokens, isOrchestratorError, isTokenAddressSupported, };
|
|
11
10
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../orchestrator/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,UAAU,CAAA;AACvC,OAAO,EAAyB,6BAA6B,EAAE,MAAM,UAAU,CAAA;AAC/E,OAAO,EACL,2BAA2B,EAC3B,wBAAwB,EACxB,mBAAmB,EACnB,kBAAkB,EAClB,2BAA2B,EAC3B,mBAAmB,EACnB,gBAAgB,EAChB,uCAAuC,EACvC,iBAAiB,EACjB,sBAAsB,EACtB,qBAAqB,EACrB,uBAAuB,EACvB,qBAAqB,EACtB,MAAM,SAAS,CAAA;AAChB,OAAO,EACL,kBAAkB,EAClB,eAAe,EACf,cAAc,EACd,cAAc,EACd,uBAAuB,EACxB,MAAM,YAAY,CAAA;AACnB,OAAO,KAAK,EACV,UAAU,EACV,WAAW,EACX,QAAQ,EACR,cAAc,EACd,YAAY,EACZ,WAAW,EACX,SAAS,EACT,gBAAgB,EAChB,cAAc,EACd,cAAc,EACd,WAAW,EACZ,MAAM,SAAS,CAAA;AAChB,OAAO,EACL,uBAAuB,EACvB,qBAAqB,EACrB,oBAAoB,EACpB,oBAAoB,EACpB,iCAAiC,EACjC,qBAAqB,EACrB,0BAA0B,EAC1B,qBAAqB,EACtB,MAAM,SAAS,CAAA;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../orchestrator/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,UAAU,CAAA;AACvC,OAAO,EAAyB,6BAA6B,EAAE,MAAM,UAAU,CAAA;AAC/E,OAAO,EACL,2BAA2B,EAC3B,wBAAwB,EACxB,mBAAmB,EACnB,k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GACxB,CAAA"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.isTokenAddressSupported = exports.isOrchestratorError = exports.getSupportedTokens = exports.getTokenAddress = exports.getTokenSymbol = exports.getWethAddress = exports.
|
|
3
|
+
exports.isTokenAddressSupported = exports.isOrchestratorError = exports.getSupportedTokens = exports.getTokenAddress = exports.getTokenSymbol = exports.getWethAddress = exports.UnsupportedTokenError = exports.UnsupportedChainIdError = exports.UnsupportedChainError = exports.TokenNotSupportedError = exports.IntentNotFoundError = exports.OrchestratorError = exports.OnlyOneTargetTokenAmountCanBeUnsetError = exports.NoPathFoundError = exports.InvalidIntentSignatureError = exports.InvalidApiKeyError = exports.InsufficientBalanceError = exports.AuthenticationRequiredError = exports.Orchestrator = exports.RHINESTONE_SPOKE_POOL_ADDRESS = exports.INTENT_STATUS_UNKNOWN = exports.INTENT_STATUS_PRECONFIRMED = exports.INTENT_STATUS_FAILED = exports.INTENT_STATUS_FILLED = exports.INTENT_STATUS_COMPLETED = exports.INTENT_STATUS_PARTIALLY_COMPLETED = exports.INTENT_STATUS_EXPIRED = exports.INTENT_STATUS_PENDING = void 0;
|
|
4
4
|
exports.getOrchestrator = getOrchestrator;
|
|
5
5
|
const client_1 = require("./client");
|
|
6
6
|
Object.defineProperty(exports, "Orchestrator", { enumerable: true, get: function () { return client_1.Orchestrator; } });
|
|
@@ -35,8 +35,6 @@ Object.defineProperty(exports, "INTENT_STATUS_PARTIALLY_COMPLETED", { enumerable
|
|
|
35
35
|
Object.defineProperty(exports, "INTENT_STATUS_PENDING", { enumerable: true, get: function () { return types_1.INTENT_STATUS_PENDING; } });
|
|
36
36
|
Object.defineProperty(exports, "INTENT_STATUS_PRECONFIRMED", { enumerable: true, get: function () { return types_1.INTENT_STATUS_PRECONFIRMED; } });
|
|
37
37
|
Object.defineProperty(exports, "INTENT_STATUS_UNKNOWN", { enumerable: true, get: function () { return types_1.INTENT_STATUS_UNKNOWN; } });
|
|
38
|
-
const utils_1 = require("./utils");
|
|
39
|
-
Object.defineProperty(exports, "getIntentOpHash", { enumerable: true, get: function () { return utils_1.getIntentOpHash; } });
|
|
40
38
|
function getOrchestrator(apiKey, orchestratorUrl) {
|
|
41
39
|
return new client_1.Orchestrator(orchestratorUrl ?? consts_1.PROD_ORCHESTRATOR_URL, apiKey);
|
|
42
40
|
}
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import type { IntentOp } from './types';
|
|
2
|
-
declare function getIntentOpHash(intentOp: IntentOp): `0x${string}`;
|
|
3
1
|
declare function convertBigIntFields(obj: any): any;
|
|
4
|
-
export {
|
|
2
|
+
export { convertBigIntFields };
|
|
5
3
|
//# sourceMappingURL=utils.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../orchestrator/utils.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../orchestrator/utils.ts"],"names":[],"mappings":"AAAA,iBAAS,mBAAmB,CAAC,GAAG,EAAE,GAAG,GAAG,GAAG,CAwB1C;AAED,OAAO,EAAE,mBAAmB,EAAE,CAAA"}
|
|
@@ -1,108 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getIntentOpHash = getIntentOpHash;
|
|
4
3
|
exports.convertBigIntFields = convertBigIntFields;
|
|
5
|
-
const viem_1 = require("viem");
|
|
6
|
-
function getClaimProofer(settlementSystem) {
|
|
7
|
-
switch (settlementSystem) {
|
|
8
|
-
case 'ACROSS':
|
|
9
|
-
return '0x1636b30481Db91Bbc5818e65d3962838BdCd5569';
|
|
10
|
-
case 'SAME_CHAIN':
|
|
11
|
-
return viem_1.zeroAddress;
|
|
12
|
-
}
|
|
13
|
-
}
|
|
14
|
-
function getIntentOpHash(intentOp) {
|
|
15
|
-
const notarizedChainElement = intentOp.elements[0];
|
|
16
|
-
const settlementSystem = notarizedChainElement.mandate.qualifier.settlementSystem;
|
|
17
|
-
const claimProofer = getClaimProofer(settlementSystem);
|
|
18
|
-
return (0, viem_1.hashTypedData)({
|
|
19
|
-
domain: {
|
|
20
|
-
name: 'The Compact',
|
|
21
|
-
version: '1',
|
|
22
|
-
chainId: BigInt(notarizedChainElement.chainId),
|
|
23
|
-
verifyingContract: '0xAbd3388A633758D0Bae01Efb885EF1e87BD519a6',
|
|
24
|
-
},
|
|
25
|
-
types: {
|
|
26
|
-
MultichainCompact: [
|
|
27
|
-
{ name: 'sponsor', type: 'address' },
|
|
28
|
-
{ name: 'nonce', type: 'uint256' },
|
|
29
|
-
{ name: 'expires', type: 'uint256' },
|
|
30
|
-
{ name: 'elements', type: 'Element[]' },
|
|
31
|
-
],
|
|
32
|
-
Element: [
|
|
33
|
-
{ name: 'arbiter', type: 'address' },
|
|
34
|
-
{ name: 'chainId', type: 'uint256' },
|
|
35
|
-
{ name: 'commitments', type: 'Lock[]' },
|
|
36
|
-
{ name: 'mandate', type: 'Mandate' },
|
|
37
|
-
],
|
|
38
|
-
Lock: [
|
|
39
|
-
{ name: 'lockTag', type: 'bytes12' },
|
|
40
|
-
{ name: 'token', type: 'address' },
|
|
41
|
-
{ name: 'amount', type: 'uint256' },
|
|
42
|
-
],
|
|
43
|
-
Mandate: [
|
|
44
|
-
{ name: 'target', type: 'Target' },
|
|
45
|
-
{ name: 'originOps', type: 'Op[]' },
|
|
46
|
-
{ name: 'destOps', type: 'Op[]' },
|
|
47
|
-
{ name: 'q', type: 'bytes32' },
|
|
48
|
-
],
|
|
49
|
-
Target: [
|
|
50
|
-
{ name: 'recipient', type: 'address' },
|
|
51
|
-
{ name: 'tokenOut', type: 'Token[]' },
|
|
52
|
-
{ name: 'targetChain', type: 'uint256' },
|
|
53
|
-
{ name: 'fillExpiry', type: 'uint256' },
|
|
54
|
-
{ name: 'claimProofer', type: 'address' },
|
|
55
|
-
],
|
|
56
|
-
Token: [
|
|
57
|
-
{ name: 'token', type: 'address' },
|
|
58
|
-
{ name: 'amount', type: 'uint256' },
|
|
59
|
-
],
|
|
60
|
-
Op: [
|
|
61
|
-
{ name: 'to', type: 'address' },
|
|
62
|
-
{ name: 'value', type: 'uint256' },
|
|
63
|
-
{ name: 'data', type: 'bytes' },
|
|
64
|
-
],
|
|
65
|
-
},
|
|
66
|
-
primaryType: 'MultichainCompact',
|
|
67
|
-
message: {
|
|
68
|
-
sponsor: intentOp.sponsor,
|
|
69
|
-
nonce: BigInt(intentOp.nonce),
|
|
70
|
-
expires: BigInt(intentOp.expires),
|
|
71
|
-
elements: intentOp.elements.map((element) => ({
|
|
72
|
-
arbiter: element.arbiter,
|
|
73
|
-
chainId: BigInt(element.chainId),
|
|
74
|
-
commitments: element.idsAndAmounts.map((token) => ({
|
|
75
|
-
lockTag: (0, viem_1.slice)((0, viem_1.toHex)(BigInt(token[0])), 0, 12),
|
|
76
|
-
token: (0, viem_1.slice)((0, viem_1.toHex)(BigInt(token[0])), 12, 32),
|
|
77
|
-
amount: BigInt(token[1]),
|
|
78
|
-
})),
|
|
79
|
-
mandate: {
|
|
80
|
-
target: {
|
|
81
|
-
recipient: element.mandate.recipient,
|
|
82
|
-
tokenOut: element.mandate.tokenOut.map((token) => ({
|
|
83
|
-
token: (0, viem_1.slice)((0, viem_1.toHex)(BigInt(token[0])), 12, 32),
|
|
84
|
-
amount: BigInt(token[1]),
|
|
85
|
-
})),
|
|
86
|
-
targetChain: BigInt(element.mandate.destinationChainId),
|
|
87
|
-
fillExpiry: BigInt(element.mandate.fillDeadline),
|
|
88
|
-
claimProofer: claimProofer,
|
|
89
|
-
},
|
|
90
|
-
originOps: element.mandate.preClaimOps.map((op) => ({
|
|
91
|
-
to: op.to,
|
|
92
|
-
value: BigInt(op.value),
|
|
93
|
-
data: op.data,
|
|
94
|
-
})),
|
|
95
|
-
destOps: element.mandate.destinationOps.map((op) => ({
|
|
96
|
-
to: op.to,
|
|
97
|
-
value: BigInt(op.value),
|
|
98
|
-
data: op.data,
|
|
99
|
-
})),
|
|
100
|
-
q: (0, viem_1.keccak256)(element.mandate.qualifier?.encodedVal ?? '0x'),
|
|
101
|
-
},
|
|
102
|
-
})),
|
|
103
|
-
},
|
|
104
|
-
});
|
|
105
|
-
}
|
|
106
4
|
function convertBigIntFields(obj) {
|
|
107
5
|
if (obj === null || obj === undefined) {
|
|
108
6
|
return obj;
|
package/dist/src/types.d.ts
CHANGED
|
@@ -13,7 +13,6 @@ interface OwnableValidatorConfig {
|
|
|
13
13
|
interface WebauthnValidatorConfig {
|
|
14
14
|
type: 'passkey';
|
|
15
15
|
account: WebAuthnAccount;
|
|
16
|
-
credentialIds: Hex[];
|
|
17
16
|
}
|
|
18
17
|
interface MultiFactorValidatorConfig {
|
|
19
18
|
type: 'multi-factor';
|
|
@@ -119,11 +118,10 @@ type OwnerSignerSet = {
|
|
|
119
118
|
type: 'owner';
|
|
120
119
|
kind: 'passkey';
|
|
121
120
|
account: WebAuthnAccount;
|
|
122
|
-
credentialIds: Hex[];
|
|
123
121
|
} | {
|
|
124
122
|
type: 'owner';
|
|
125
123
|
kind: 'multi-factor';
|
|
126
|
-
validators:
|
|
124
|
+
validators: ({
|
|
127
125
|
type: 'ecdsa';
|
|
128
126
|
id: number | Hex;
|
|
129
127
|
accounts: Account[];
|
|
@@ -131,8 +129,7 @@ type OwnerSignerSet = {
|
|
|
131
129
|
type: 'passkey';
|
|
132
130
|
id: number | Hex;
|
|
133
131
|
account: WebAuthnAccount;
|
|
134
|
-
|
|
135
|
-
}>;
|
|
132
|
+
})[];
|
|
136
133
|
};
|
|
137
134
|
interface SessionSignerSet {
|
|
138
135
|
type: 'session';
|
package/dist/src/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE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AAM,CAAA;IACjB,OAAO,CAAC,EAAE,SAAS,CAAA;IACnB,SAAS,CAAC,EAAE,OAAO,CAAA;IACnB,oBAAoB,CAAC,EAAE,GAAG,CAAA;CAC3B;AAED,UAAU,oBAAqB,SAAQ,eAAe;IACpD,KAAK,EAAE,KAAK,CAAA;CACb;AAED,UAAU,qBAAsB,SAAQ,eAAe;IACrD,YAAY,CAAC,EAAE,KAAK,EAAE,CAAA;IACtB,WAAW,EAAE,KAAK,CAAA;CACnB;AAED,KAAK,WAAW,GAAG,oBAAoB,GAAG,qBAAqB,CAAA;AAE/D,YAAY,EACV,WAAW,EACX,uBAAuB,EACvB,qBAAqB,EACrB,cAAc,EACd,aAAa,EACb,eAAe,EACf,WAAW,EACX,WAAW,EACX,SAAS,EACT,IAAI,EACJ,YAAY,EACZ,QAAQ,EACR,sBAAsB,EACtB,uBAAuB,EACvB,0BAA0B,EAC1B,SAAS,EACT,OAAO,EACP,QAAQ,EACR,MAAM,EACN,mCAAmC,GACpC,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@charterlabs/rhinestone-sdk",
|
|
3
|
-
"version": "0.1
|
|
3
|
+
"version": "0.2.1",
|
|
4
4
|
"description": "Rhinestone SDK for Charter Labs",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "Charter Labs",
|
|
@@ -42,4 +42,4 @@
|
|
|
42
42
|
"peerDependencies": {
|
|
43
43
|
"viem": "^2.28.0"
|
|
44
44
|
}
|
|
45
|
-
}
|
|
45
|
+
}
|