@inco/shield-js 0.0.0-bootstrap.0 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +52 -308
- package/dist/contracts/abi.d.ts +2000 -4513
- package/dist/contracts/abi.js +2400 -5651
- package/dist/contracts/index.d.ts +2 -2
- package/dist/contracts/index.js +2 -2
- package/dist/contracts/utils.d.ts +5 -24
- package/dist/contracts/utils.js +13 -24
- package/dist/errors.d.ts +16 -47
- package/dist/errors.js +6 -53
- package/dist/generated/inco/shield/v2/conductor_pb.d.ts +77 -0
- package/dist/generated/inco/shield/v2/conductor_pb.js +6 -0
- package/dist/generated/inco/shield/v2/deposit_pb.d.ts +12 -103
- package/dist/generated/inco/shield/v2/deposit_pb.js +4 -141
- package/dist/generated/inco/shield/v2/drafting_pb.d.ts +45 -269
- package/dist/generated/inco/shield/v2/drafting_pb.js +8 -361
- package/dist/generated/inco/shield/v2/types_pb.d.ts +47 -166
- package/dist/generated/inco/shield/v2/types_pb.js +12 -261
- package/dist/index.d.ts +1 -7
- package/dist/index.js +1 -14
- package/dist/shield/abi.d.ts +5 -0
- package/dist/shield/abi.js +28 -0
- package/dist/shield/client.d.ts +27 -51
- package/dist/shield/client.js +73 -65
- package/dist/shield/convert.d.ts +2 -14
- package/dist/shield/convert.js +39 -115
- package/dist/shield/encryption.d.ts +0 -67
- package/dist/shield/encryption.js +0 -67
- package/dist/shield/envelope.d.ts +10 -11
- package/dist/shield/envelope.js +15 -14
- package/dist/shield/fee.d.ts +24 -0
- package/dist/shield/fee.js +151 -0
- package/dist/shield/index.d.ts +9 -3
- package/dist/shield/index.js +7 -2
- package/dist/shield/intent.d.ts +20 -933
- package/dist/shield/intent.js +92 -112
- package/dist/shield/permission-status.d.ts +9 -0
- package/dist/shield/permission-status.js +8 -0
- package/dist/shield/rpc.d.ts +50 -49
- package/dist/shield/rpc.js +207 -354
- package/dist/shield/shield.eip712.gen.d.ts +1096 -43
- package/dist/shield/shield.eip712.gen.js +572 -62
- package/dist/shield/types.d.ts +7 -102
- package/dist/shield/types.js +1 -4
- package/dist/shield/userop/gas-estimation.d.ts +8 -23
- package/dist/shield/userop/gas-estimation.js +100 -137
- package/dist/shield/userop/paymaster.d.ts +15 -0
- package/dist/shield/userop/paymaster.js +17 -0
- package/dist/shield/userop/token-exchange.d.ts +5 -52
- package/dist/shield/userop/token-exchange.js +41 -149
- package/dist/shield/userop/types.d.ts +3 -28
- package/dist/shield/userop/types.js +0 -3
- package/dist/shield/userop/userOp.d.ts +0 -19
- package/dist/shield/userop/userOp.js +4 -22
- package/dist/shield/utils/chain.d.ts +1 -0
- package/dist/shield/utils/chain.js +3 -0
- package/dist/shield/validate-withdrawal-split.d.ts +13 -0
- package/dist/shield/validate-withdrawal-split.js +93 -0
- package/package.json +18 -27
- package/dist/generated/inco/shield/v2/conductor_connect.d.ts +0 -137
- package/dist/generated/inco/shield/v2/conductor_connect.js +0 -141
- package/dist/generated/inco/shield/v2/permission_pb.d.ts +0 -443
- package/dist/generated/inco/shield/v2/permission_pb.js +0 -639
- package/dist/generated/inco/shield/v2/query_pb.d.ts +0 -103
- package/dist/generated/inco/shield/v2/query_pb.js +0 -141
- package/dist/shield/userop/index.d.ts +0 -1
- package/dist/shield/userop/index.js +0 -1
- package/dist/uniswap-adapter/config.d.ts +0 -34
- package/dist/uniswap-adapter/config.js +0 -45
- package/dist/uniswap-adapter/find-pools.d.ts +0 -91
- package/dist/uniswap-adapter/find-pools.js +0 -108
- package/dist/uniswap-adapter/index.d.ts +0 -10
- package/dist/uniswap-adapter/index.js +0 -13
- package/dist/uniswap-adapter/swap.d.ts +0 -344
- package/dist/uniswap-adapter/swap.js +0 -309
package/dist/shield/intent.js
CHANGED
|
@@ -1,29 +1,37 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { encodeAbiParameters, http, zeroHash, } from 'viem';
|
|
2
2
|
import { createBundlerClient, entryPoint07Address, } from 'viem/account-abstraction';
|
|
3
|
-
import {
|
|
3
|
+
import { computeErc20AssetId, erc20Asset, NATIVE_ASSET, } from '../contracts/utils.js';
|
|
4
4
|
import { BundlerGasEstimateIncomplete } from '../errors.js';
|
|
5
5
|
import { IntentKind } from '../generated/inco/shield/v2/drafting_pb.js';
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
6
|
+
import { encodeStruct } from './abi.js';
|
|
7
|
+
import { reserveUnmeasuredSignatureGas, userOpFromIntentForGasEstimation, } from './userop/gas-estimation.js';
|
|
8
|
+
import { assertFeeTokenSupported, convertEthWeiToTokenUnits, } from './userop/token-exchange.js';
|
|
9
|
+
import { defaultBundlerUrl } from './utils/chain.js';
|
|
10
|
+
const NATIVE_ASSET_MOVEMENT = {
|
|
11
|
+
account: '0x0000000000000000000000000000000000000000',
|
|
12
|
+
assetAdapter: '0x0000000000000000000000000000000000000000',
|
|
13
|
+
movementArgs: '0x',
|
|
14
|
+
};
|
|
15
|
+
export function isNativeSettlement(gasAssetId) {
|
|
16
|
+
return BigInt(gasAssetId) === 0n;
|
|
17
|
+
}
|
|
18
|
+
async function createIntent(intentOp, salt, signer, shieldConfig, publicClient, gas, paymasterContext) {
|
|
19
|
+
const bundlerUrl = shieldConfig.bundlerUrl ?? defaultBundlerUrl(Number(shieldConfig.chainId));
|
|
20
20
|
const bundlerClient = createBundlerClient({
|
|
21
|
-
client:
|
|
21
|
+
client: publicClient,
|
|
22
22
|
transport: http(bundlerUrl),
|
|
23
23
|
});
|
|
24
|
-
|
|
25
|
-
const
|
|
26
|
-
|
|
24
|
+
const feeToken = gas.feeToken;
|
|
25
|
+
const assetId = feeToken === undefined ? zeroHash : computeErc20AssetId(feeToken);
|
|
26
|
+
const feeRates = {
|
|
27
|
+
maxFeePerGas: gas.maxFeePerGas,
|
|
28
|
+
maxPriorityFeePerGas: gas.maxPriorityFeePerGas,
|
|
29
|
+
};
|
|
30
|
+
if (feeToken !== undefined) {
|
|
31
|
+
await assertFeeTokenSupported(publicClient, paymasterContext.paymaster, feeToken);
|
|
32
|
+
}
|
|
33
|
+
const usesPaymaster = !isNativeSettlement(assetId);
|
|
34
|
+
const { userOp: placeholderUserOp, signerCount } = await userOpFromIntentForGasEstimation(intentOp, shieldConfig, publicClient, gas, usesPaymaster ? paymasterContext.paymaster : undefined);
|
|
27
35
|
const gasEstimate = await bundlerClient.estimateUserOperationGas({
|
|
28
36
|
entryPointAddress: entryPoint07Address,
|
|
29
37
|
sender: placeholderUserOp.sender,
|
|
@@ -35,18 +43,28 @@ async function createIntent(intentOp, salt, signer, shieldConfig, publicClient,
|
|
|
35
43
|
callGasLimit: placeholderUserOp.callGasLimit,
|
|
36
44
|
maxFeePerGas: placeholderUserOp.maxFeePerGas,
|
|
37
45
|
maxPriorityFeePerGas: placeholderUserOp.maxPriorityFeePerGas,
|
|
38
|
-
|
|
39
|
-
|
|
46
|
+
...(usesPaymaster
|
|
47
|
+
? {
|
|
48
|
+
paymaster: placeholderUserOp.paymaster,
|
|
49
|
+
paymasterData: placeholderUserOp.paymasterData,
|
|
50
|
+
paymasterVerificationGasLimit: placeholderUserOp.paymasterVerificationGasLimit,
|
|
51
|
+
paymasterPostOpGasLimit: placeholderUserOp.paymasterPostOpGasLimit,
|
|
52
|
+
}
|
|
53
|
+
: {}),
|
|
40
54
|
});
|
|
41
55
|
const preVerificationGas = gasEstimate.preVerificationGas;
|
|
42
|
-
const
|
|
56
|
+
const estimatedVerificationGasLimit = gasEstimate.verificationGasLimit;
|
|
43
57
|
const callGasLimit = gasEstimate.callGasLimit;
|
|
44
|
-
const paymasterVerificationGasLimit =
|
|
45
|
-
|
|
58
|
+
const paymasterVerificationGasLimit = usesPaymaster
|
|
59
|
+
? placeholderUserOp.paymasterVerificationGasLimit
|
|
60
|
+
: 0n;
|
|
61
|
+
const paymasterPostOpGasLimit = usesPaymaster
|
|
62
|
+
? placeholderUserOp.paymasterPostOpGasLimit
|
|
63
|
+
: 0n;
|
|
46
64
|
const missingFields = [];
|
|
47
65
|
if (preVerificationGas === undefined)
|
|
48
66
|
missingFields.push('preVerificationGas');
|
|
49
|
-
if (
|
|
67
|
+
if (estimatedVerificationGasLimit === undefined)
|
|
50
68
|
missingFields.push('verificationGasLimit');
|
|
51
69
|
if (callGasLimit === undefined)
|
|
52
70
|
missingFields.push('callGasLimit');
|
|
@@ -55,7 +73,7 @@ async function createIntent(intentOp, salt, signer, shieldConfig, publicClient,
|
|
|
55
73
|
if (paymasterPostOpGasLimit === undefined)
|
|
56
74
|
missingFields.push('paymasterPostOpGasLimit');
|
|
57
75
|
if (preVerificationGas === undefined ||
|
|
58
|
-
|
|
76
|
+
estimatedVerificationGasLimit === undefined ||
|
|
59
77
|
callGasLimit === undefined ||
|
|
60
78
|
paymasterVerificationGasLimit === undefined ||
|
|
61
79
|
paymasterPostOpGasLimit === undefined) {
|
|
@@ -64,24 +82,20 @@ async function createIntent(intentOp, salt, signer, shieldConfig, publicClient,
|
|
|
64
82
|
missingFields,
|
|
65
83
|
});
|
|
66
84
|
}
|
|
67
|
-
|
|
68
|
-
// in `gas.assetId` smallest-units (e.g. 1_000_000 = 1 USDC).
|
|
69
|
-
//
|
|
70
|
-
// We compute that ETH-wei cost, then convert to token units via a Chainlink RAY-precision exchange rate, ceiling-
|
|
71
|
-
// rounded to match the paymaster's on-chain rounding so the signed cap can never come in below what `_postOp` actually charges.
|
|
85
|
+
const verificationGasLimit = reserveUnmeasuredSignatureGas(estimatedVerificationGasLimit, signerCount);
|
|
72
86
|
const totalGasUnits = preVerificationGas +
|
|
73
87
|
verificationGasLimit +
|
|
74
88
|
callGasLimit +
|
|
75
89
|
paymasterVerificationGasLimit +
|
|
76
90
|
paymasterPostOpGasLimit;
|
|
77
91
|
const maxGasCostWei = totalGasUnits * gas.maxFeePerGas;
|
|
78
|
-
const maxAmount =
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
// from it. Writing back only `callGasLimit` would leave the intent's
|
|
82
|
-
// other limits at the caller's placeholders, inconsistent with `maxAmount`.
|
|
92
|
+
const maxAmount = feeToken === undefined
|
|
93
|
+
? 0n
|
|
94
|
+
: await convertEthWeiToTokenUnits(publicClient, paymasterContext.paymaster, feeToken, maxGasCostWei);
|
|
83
95
|
const estimatedGas = {
|
|
84
|
-
|
|
96
|
+
asset: feeToken === undefined ? NATIVE_ASSET : erc20Asset(feeToken),
|
|
97
|
+
assetMovement: resolveGasAssetMovement(feeToken, paymasterContext.paymaster, paymasterContext.adapter, maxAmount),
|
|
98
|
+
...feeRates,
|
|
85
99
|
callGasLimit,
|
|
86
100
|
verificationGasLimit,
|
|
87
101
|
preVerificationGas,
|
|
@@ -91,98 +105,64 @@ async function createIntent(intentOp, salt, signer, shieldConfig, publicClient,
|
|
|
91
105
|
};
|
|
92
106
|
return assembleIntent(intentOp.op, signer, estimatedGas, salt);
|
|
93
107
|
}
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
108
|
+
function resolveGasAssetMovement(feeToken, paymaster, adapter, amount) {
|
|
109
|
+
if (feeToken === undefined) {
|
|
110
|
+
return NATIVE_ASSET_MOVEMENT;
|
|
111
|
+
}
|
|
112
|
+
return {
|
|
113
|
+
account: paymaster,
|
|
114
|
+
assetAdapter: adapter,
|
|
115
|
+
movementArgs: encodeAbiParameters([{ type: 'uint256' }], [amount]),
|
|
116
|
+
};
|
|
117
|
+
}
|
|
118
|
+
async function createDelegatedIntent(intentOp, salt, spender, permissionId, signer, shieldConfig, publicClient, gas, paymasterContext) {
|
|
119
|
+
const intent = await createIntent(intentOp, salt, signer, shieldConfig, publicClient, gas, paymasterContext);
|
|
120
|
+
return { intent, spender, permissionId };
|
|
97
121
|
}
|
|
98
122
|
function assembleIntent(op, signer, gas, salt) {
|
|
99
123
|
return { op, signer: signer.address, gas, salt };
|
|
100
124
|
}
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
return createIntent({ kind: IntentKind.TRANSFER, op: transferIntentOp }, salt, signer, shieldConfig, publicClient, gas, bundlerUrl);
|
|
125
|
+
export async function createTransferIntent(transferIntentOp, salt, signer, shieldConfig, publicClient, gas, paymasterContext) {
|
|
126
|
+
return createIntent({ kind: IntentKind.TRANSFER, op: transferIntentOp }, salt, signer, shieldConfig, publicClient, gas, paymasterContext);
|
|
104
127
|
}
|
|
105
|
-
export async function createWithdrawIntent(withdrawalIntentOp, salt, signer, shieldConfig, publicClient, gas,
|
|
106
|
-
return createIntent({ kind: IntentKind.WITHDRAW, op: withdrawalIntentOp }, salt, signer, shieldConfig, publicClient, gas,
|
|
128
|
+
export async function createWithdrawIntent(withdrawalIntentOp, salt, signer, shieldConfig, publicClient, gas, paymasterContext) {
|
|
129
|
+
return createIntent({ kind: IntentKind.WITHDRAW, op: withdrawalIntentOp }, salt, signer, shieldConfig, publicClient, gas, paymasterContext);
|
|
107
130
|
}
|
|
108
|
-
export async function createDefiInteractionIntent(defiInteractionIntentOp, salt, signer, shieldConfig, publicClient, gas,
|
|
109
|
-
return createIntent({ kind: IntentKind.DEFI_INTERACTION, op: defiInteractionIntentOp }, salt, signer, shieldConfig, publicClient, gas,
|
|
131
|
+
export async function createDefiInteractionIntent(defiInteractionIntentOp, salt, signer, shieldConfig, publicClient, gas, paymasterContext) {
|
|
132
|
+
return createIntent({ kind: IntentKind.DEFI_INTERACTION, op: defiInteractionIntentOp }, salt, signer, shieldConfig, publicClient, gas, paymasterContext);
|
|
110
133
|
}
|
|
111
|
-
export async function createIndividualRevocationIntent(individualRevocationIntentOp, salt, signer, shieldConfig, publicClient, gas,
|
|
134
|
+
export async function createIndividualRevocationIntent(individualRevocationIntentOp, salt, signer, shieldConfig, publicClient, gas, paymasterContext) {
|
|
112
135
|
return createIntent({
|
|
113
136
|
kind: IntentKind.INDIVIDUAL_REVOCATION,
|
|
114
137
|
op: individualRevocationIntentOp,
|
|
115
|
-
}, salt, signer, shieldConfig, publicClient, gas,
|
|
138
|
+
}, salt, signer, shieldConfig, publicClient, gas, paymasterContext);
|
|
116
139
|
}
|
|
117
|
-
export async function createUserWideRevocationIntent(userWideRevocationIntentOp, salt, signer, shieldConfig, publicClient, gas,
|
|
118
|
-
return createIntent({ kind: IntentKind.USER_WIDE_REVOCATION, op: userWideRevocationIntentOp }, salt, signer, shieldConfig, publicClient, gas,
|
|
140
|
+
export async function createUserWideRevocationIntent(userWideRevocationIntentOp, salt, signer, shieldConfig, publicClient, gas, paymasterContext) {
|
|
141
|
+
return createIntent({ kind: IntentKind.USER_WIDE_REVOCATION, op: userWideRevocationIntentOp }, salt, signer, shieldConfig, publicClient, gas, paymasterContext);
|
|
119
142
|
}
|
|
120
|
-
export async function createDelegatedTransferIntent(transferIntentOp, salt, spender,
|
|
121
|
-
return createDelegatedIntent({ kind: IntentKind.DELEGATED_TRANSFER, op: transferIntentOp }, salt, spender,
|
|
143
|
+
export async function createDelegatedTransferIntent(transferIntentOp, salt, spender, permissionId, signer, shieldConfig, publicClient, gas, paymasterContext) {
|
|
144
|
+
return createDelegatedIntent({ kind: IntentKind.DELEGATED_TRANSFER, op: transferIntentOp }, salt, spender, permissionId, signer, shieldConfig, publicClient, gas, paymasterContext);
|
|
122
145
|
}
|
|
123
|
-
export async function createDelegatedWithdrawIntent(withdrawalIntentOp, salt, spender,
|
|
124
|
-
return createDelegatedIntent({ kind: IntentKind.DELEGATED_WITHDRAW, op: withdrawalIntentOp }, salt, spender,
|
|
146
|
+
export async function createDelegatedWithdrawIntent(withdrawalIntentOp, salt, spender, permissionId, signer, shieldConfig, publicClient, gas, paymasterContext) {
|
|
147
|
+
return createDelegatedIntent({ kind: IntentKind.DELEGATED_WITHDRAW, op: withdrawalIntentOp }, salt, spender, permissionId, signer, shieldConfig, publicClient, gas, paymasterContext);
|
|
125
148
|
}
|
|
126
|
-
export async function createDelegatedDefiInteractionIntent(defiInteractionIntentOp, salt, spender,
|
|
149
|
+
export async function createDelegatedDefiInteractionIntent(defiInteractionIntentOp, salt, spender, permissionId, signer, shieldConfig, publicClient, gas, paymasterContext) {
|
|
127
150
|
return createDelegatedIntent({
|
|
128
151
|
kind: IntentKind.DELEGATED_DEFI_INTERACTION,
|
|
129
152
|
op: defiInteractionIntentOp,
|
|
130
|
-
}, salt, spender,
|
|
153
|
+
}, salt, spender, permissionId, signer, shieldConfig, publicClient, gas, paymasterContext);
|
|
131
154
|
}
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
const defiInteractionIntentAbi = getAbiItem({
|
|
142
|
-
abi: shieldAbiStubAbi,
|
|
143
|
-
name: 'defiInteractionIntent',
|
|
144
|
-
}).inputs[0];
|
|
145
|
-
const individualRevocationIntentAbi = getAbiItem({
|
|
146
|
-
abi: shieldAbiStubAbi,
|
|
147
|
-
name: 'individualRevocationIntent',
|
|
148
|
-
}).inputs[0];
|
|
149
|
-
const userWideRevocationIntentAbi = getAbiItem({
|
|
150
|
-
abi: shieldAbiStubAbi,
|
|
151
|
-
name: 'userWideRevocationIntent',
|
|
152
|
-
}).inputs[0];
|
|
153
|
-
const delegatedTransferIntentAbi = getAbiItem({
|
|
154
|
-
abi: shieldAbiStubAbi,
|
|
155
|
-
name: 'delegatedTransferIntent',
|
|
156
|
-
}).inputs[0];
|
|
157
|
-
const delegatedWithdrawalIntentAbi = getAbiItem({
|
|
158
|
-
abi: shieldAbiStubAbi,
|
|
159
|
-
name: 'delegatedWithdrawalIntent',
|
|
160
|
-
}).inputs[0];
|
|
161
|
-
const delegatedDefiInteractionIntentAbi = getAbiItem({
|
|
162
|
-
abi: shieldAbiStubAbi,
|
|
163
|
-
name: 'delegatedDefiInteractionIntent',
|
|
164
|
-
}).inputs[0];
|
|
165
|
-
/**
|
|
166
|
-
* Mapping from the intent kind to the abi item.
|
|
167
|
-
*/
|
|
168
|
-
export const intentAbi = {
|
|
169
|
-
[IntentKind.TRANSFER]: transferIntentAbi,
|
|
170
|
-
[IntentKind.WITHDRAW]: withdrawalIntentAbi,
|
|
171
|
-
[IntentKind.DEFI_INTERACTION]: defiInteractionIntentAbi,
|
|
172
|
-
[IntentKind.INDIVIDUAL_REVOCATION]: individualRevocationIntentAbi,
|
|
173
|
-
[IntentKind.USER_WIDE_REVOCATION]: userWideRevocationIntentAbi,
|
|
174
|
-
[IntentKind.DELEGATED_TRANSFER]: delegatedTransferIntentAbi,
|
|
175
|
-
[IntentKind.DELEGATED_WITHDRAW]: delegatedWithdrawalIntentAbi,
|
|
176
|
-
[IntentKind.DELEGATED_DEFI_INTERACTION]: delegatedDefiInteractionIntentAbi,
|
|
155
|
+
const intentStructName = {
|
|
156
|
+
[IntentKind.TRANSFER]: 'TransferIntent',
|
|
157
|
+
[IntentKind.WITHDRAW]: 'WithdrawalIntent',
|
|
158
|
+
[IntentKind.DEFI_INTERACTION]: 'DefiInteractionIntent',
|
|
159
|
+
[IntentKind.INDIVIDUAL_REVOCATION]: 'IndividualRevocationIntent',
|
|
160
|
+
[IntentKind.USER_WIDE_REVOCATION]: 'UserWideRevocationIntent',
|
|
161
|
+
[IntentKind.DELEGATED_TRANSFER]: 'DelegatedTransferIntent',
|
|
162
|
+
[IntentKind.DELEGATED_WITHDRAW]: 'DelegatedWithdrawalIntent',
|
|
163
|
+
[IntentKind.DELEGATED_DEFI_INTERACTION]: 'DelegatedDefiInteractionIntent',
|
|
177
164
|
};
|
|
178
|
-
/**
|
|
179
|
-
* ABI-encode an intent.
|
|
180
|
-
*/
|
|
181
165
|
export function encodeIntent(kind, intent) {
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
// are paired by construction, so we erase the union to a single `AbiParameter`
|
|
185
|
-
// before encoding.
|
|
186
|
-
const params = [intentAbi[kind]];
|
|
187
|
-
return encodeAbiParameters(params, [intent]);
|
|
166
|
+
const name = intentStructName[kind];
|
|
167
|
+
return encodeStruct(name, intent);
|
|
188
168
|
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export declare const PERMISSION_STATUS: {
|
|
2
|
+
readonly unspecified: 0;
|
|
3
|
+
readonly active: 1;
|
|
4
|
+
readonly notYetActive: 2;
|
|
5
|
+
readonly expired: 3;
|
|
6
|
+
readonly revoked: 4;
|
|
7
|
+
readonly generationRevoked: 5;
|
|
8
|
+
};
|
|
9
|
+
export type PermissionStatus = (typeof PERMISSION_STATUS)[keyof typeof PERMISSION_STATUS];
|
package/dist/shield/rpc.d.ts
CHANGED
|
@@ -1,72 +1,73 @@
|
|
|
1
1
|
import type { Client } from '@connectrpc/connect';
|
|
2
|
-
import { type Hex } from 'viem';
|
|
2
|
+
import { type Address, type Hex, type PublicClient, type TypedDataDomain } from 'viem';
|
|
3
3
|
import type { UserOperation } from 'viem/account-abstraction';
|
|
4
|
-
import type
|
|
5
|
-
import { type
|
|
6
|
-
import type
|
|
4
|
+
import { type ConductorService as ConductorServiceType } from '../generated/inco/shield/v2/conductor_pb.js';
|
|
5
|
+
import { type PaymasterContext, type UserGasParams } from './intent.js';
|
|
6
|
+
import { type BalanceHistoryResponse, type BalanceQuery, type BalanceResponse, type DepositAttestation, type GetPermissionDetails, type GetPermissionsByOwner, type GetPermissionsBySpender, type HistoryCursor, type OwnerGenerationResponse, type Permission, type PermissionAttestation, type PermissionDetailsResponse, type PermissionListResponse, type PermissionRequest, type PortfolioHistoryResponse, type PortfolioResponse, type ResponsePagination, type TransferIntentOp, type ViewingSession, type WithdrawalIntentOp } from './shield.eip712.gen.js';
|
|
7
|
+
import type { ResolvedSigner, ShieldConfig } from './types.js';
|
|
7
8
|
import type { ENTRYPOINT_VERSION } from './userop/types.js';
|
|
8
9
|
export type Rpc = Client<typeof ConductorServiceType>;
|
|
9
10
|
export type RpcContext = {
|
|
10
11
|
rpc: Rpc;
|
|
11
|
-
|
|
12
|
-
signer:
|
|
12
|
+
domain: TypedDataDomain;
|
|
13
|
+
signer: ResolvedSigner;
|
|
13
14
|
teePublicKey: CryptoKey;
|
|
15
|
+
publicClient: PublicClient;
|
|
16
|
+
shieldConfig: ShieldConfig;
|
|
17
|
+
paymasterContext: PaymasterContext;
|
|
14
18
|
};
|
|
15
|
-
|
|
16
|
-
* Inputs to the salted `permissionId` formula. Mirrors `PermissionIntent` minus
|
|
17
|
-
* `intentExpiry` (which gates issuance, not identity).
|
|
18
|
-
*/
|
|
19
|
-
export type PermissionIdInput = Omit<PermissionIntent, 'intentExpiry'>;
|
|
20
|
-
/**
|
|
21
|
-
* `permissionId = keccak256(abi.encode(...))` over the 9 identity fields. Must
|
|
22
|
-
* match the umbo helper bit-for-bit; cross-checked in `sdk/test/permission-id.test.ts`.
|
|
23
|
-
*
|
|
24
|
-
* Off-chain only — no on-chain code recomputes this.
|
|
25
|
-
*/
|
|
19
|
+
export type PermissionIdInput = Permission;
|
|
26
20
|
export declare function computePermissionId(input: PermissionIdInput): Hex;
|
|
27
|
-
export declare function issueTransfer(ctx: RpcContext, intentOp: TransferIntentOp): Promise<{
|
|
21
|
+
export declare function issueTransfer(ctx: RpcContext, intentOp: TransferIntentOp, gas?: UserGasParams): Promise<{
|
|
28
22
|
userOp: UserOperation<typeof ENTRYPOINT_VERSION>;
|
|
29
23
|
}>;
|
|
30
|
-
export declare function issueWithdraw(ctx: RpcContext, intentOp: WithdrawalIntentOp): Promise<{
|
|
24
|
+
export declare function issueWithdraw(ctx: RpcContext, intentOp: WithdrawalIntentOp, gas?: UserGasParams): Promise<{
|
|
31
25
|
userOp: UserOperation<typeof ENTRYPOINT_VERSION>;
|
|
32
26
|
}>;
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
* long-lived `PermissionAttestation` for the spender. The spender presents
|
|
36
|
-
* the attestation on every subsequent draft.
|
|
37
|
-
*
|
|
38
|
-
* Doc-mandated client cross-check: recompute `permissionId` locally from
|
|
39
|
-
* intent terms and verify the TEE's returned attestation matches. A mismatch
|
|
40
|
-
* means the TEE substituted a different identity — fail closed.
|
|
41
|
-
*/
|
|
42
|
-
export declare function requestPermissionAttestation(ctx: RpcContext, req: PermissionAttestationRequest): Promise<PermissionAttestation>;
|
|
43
|
-
/**
|
|
44
|
-
* Spender-side delegated transfer draft: sign the transfer intent, present the
|
|
45
|
-
* owner's `PermissionAttestation` to the TEE, receive a spending note. The TEE
|
|
46
|
-
* verifies the attestation signature and runs all 7 validation steps before
|
|
47
|
-
* drafting the spend.
|
|
48
|
-
*/
|
|
49
|
-
export declare function issueDelegatedTransfer(ctx: RpcContext, intentOp: TransferIntentOp, attestation: PermissionAttestation): Promise<{
|
|
27
|
+
export declare function requestPermissionAttestation(ctx: RpcContext, req: PermissionRequest): Promise<PermissionAttestation>;
|
|
28
|
+
export declare function issueDelegatedTransfer(ctx: RpcContext, intentOp: TransferIntentOp, permissionId: Hex, gas?: UserGasParams): Promise<{
|
|
50
29
|
userOp: UserOperation<typeof ENTRYPOINT_VERSION>;
|
|
51
30
|
}>;
|
|
52
|
-
|
|
53
|
-
* The resulting cheque settles byte-identically to a direct withdraw —
|
|
54
|
-
* observers cannot distinguish delegated from direct.
|
|
55
|
-
*/
|
|
56
|
-
export declare function issueDelegatedWithdraw(ctx: RpcContext, intentOp: WithdrawalIntentOp, attestation: PermissionAttestation): Promise<{
|
|
31
|
+
export declare function issueDelegatedWithdraw(ctx: RpcContext, intentOp: WithdrawalIntentOp, permissionId: Hex, gas?: UserGasParams): Promise<{
|
|
57
32
|
userOp: UserOperation<typeof ENTRYPOINT_VERSION>;
|
|
58
33
|
}>;
|
|
59
34
|
export declare function revokeOne(ctx: RpcContext, params: {
|
|
60
35
|
permissionId: Hex;
|
|
61
|
-
}): Promise<{
|
|
36
|
+
}, gas?: UserGasParams): Promise<{
|
|
62
37
|
userOp: UserOperation<typeof ENTRYPOINT_VERSION>;
|
|
63
38
|
}>;
|
|
64
|
-
export declare function revokeAll(ctx: RpcContext): Promise<{
|
|
39
|
+
export declare function revokeAll(ctx: RpcContext, gas?: UserGasParams): Promise<{
|
|
65
40
|
userOp: UserOperation<typeof ENTRYPOINT_VERSION>;
|
|
66
41
|
}>;
|
|
67
|
-
export
|
|
68
|
-
export
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
export declare function
|
|
42
|
+
export type ViewingSessionParams = Pick<ViewingSession, 'expiresAt'> & Partial<Pick<ViewingSession, 'owner' | 'periodStart' | 'periodEnd'>>;
|
|
43
|
+
export type SignedViewingSession = {
|
|
44
|
+
readonly session: ViewingSession;
|
|
45
|
+
readonly signature: Hex;
|
|
46
|
+
};
|
|
47
|
+
export declare function createViewingSession(ctx: RpcContext, params: ViewingSessionParams): Promise<SignedViewingSession>;
|
|
48
|
+
export type GetBalanceParams = Pick<BalanceQuery, 'assetId'>;
|
|
49
|
+
export declare function getBalance(ctx: RpcContext, viewing: SignedViewingSession, params: GetBalanceParams): Promise<BalanceResponse>;
|
|
50
|
+
export declare function getPortfolio(ctx: RpcContext, viewing: SignedViewingSession): Promise<PortfolioResponse>;
|
|
51
|
+
export declare function nextHistoryCursor(response: ResponsePagination): HistoryCursor | undefined;
|
|
52
|
+
export type HistoryPageOptions = {
|
|
53
|
+
cursor?: HistoryCursor;
|
|
54
|
+
limit?: number;
|
|
55
|
+
};
|
|
56
|
+
export declare function getBalanceHistory(ctx: RpcContext, viewing: SignedViewingSession, assetId: Hex, options?: HistoryPageOptions): Promise<BalanceHistoryResponse>;
|
|
57
|
+
export declare function getPortfolioHistory(ctx: RpcContext, viewing: SignedViewingSession, options?: HistoryPageOptions): Promise<PortfolioHistoryResponse>;
|
|
58
|
+
export type DepositAttestationParams = {
|
|
59
|
+
recipient: Address;
|
|
60
|
+
assetAdapter: Address;
|
|
61
|
+
assetIdentificationArgs: Hex;
|
|
62
|
+
memo: Hex;
|
|
63
|
+
escapeHatch: Hex;
|
|
64
|
+
};
|
|
65
|
+
export declare function requestDepositAttestation(ctx: RpcContext, params: DepositAttestationParams): Promise<DepositAttestation>;
|
|
66
|
+
export type GetPermissionsByOwnerParams = Partial<Pick<GetPermissionsByOwner, 'includeExpired'>>;
|
|
67
|
+
export type GetPermissionsBySpenderParams = Partial<Pick<GetPermissionsBySpender, 'includeExpired'>>;
|
|
68
|
+
export type GetPermissionDetailsParams = Pick<GetPermissionDetails, 'permissionId'>;
|
|
69
|
+
export declare function getPermissionsByOwner(ctx: RpcContext, params?: GetPermissionsByOwnerParams): Promise<PermissionListResponse>;
|
|
70
|
+
export declare function getPermissionsBySpender(ctx: RpcContext, params?: GetPermissionsBySpenderParams): Promise<PermissionListResponse>;
|
|
71
|
+
export declare function getPermissionDetails(ctx: RpcContext, params: GetPermissionDetailsParams): Promise<PermissionDetailsResponse>;
|
|
72
|
+
export declare function getOwnerGeneration(ctx: RpcContext): Promise<OwnerGenerationResponse>;
|
|
73
|
+
export declare function getLatestHandle(ctx: RpcContext): Promise<Hex>;
|