@portal-hq/web 3.16.0 → 3.17.0-alpha.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/src/mpc/index.ts CHANGED
@@ -127,6 +127,10 @@ import {
127
127
  RawSignOptions,
128
128
  RpcProxyRequest,
129
129
  RpcProxyResponse,
130
+ BuildBatchedUserOpRequest,
131
+ BuildBatchedUserOpResponse,
132
+ BroadcastBatchedUserOpRequest,
133
+ BroadcastBatchedUserOpResponse,
130
134
  } from '../shared/types'
131
135
  import {
132
136
  ScreenAddressApiResponse,
@@ -134,7 +138,7 @@ import {
134
138
  } from '../../hypernative'
135
139
  import { generateTraceId } from '../shared/trace'
136
140
 
137
- const WEB_SDK_VERSION = '3.16.0'
141
+ const WEB_SDK_VERSION = '3.17.0-alpha.0'
138
142
 
139
143
  class Mpc {
140
144
  public iframe?: HTMLIFrameElement
@@ -372,6 +376,7 @@ class Mpc {
372
376
  signatureApprovalMemo: options.signatureApprovalMemo,
373
377
  }),
374
378
  },
379
+ traceId: options?.traceId,
375
380
  })
376
381
  }
377
382
 
@@ -1130,6 +1135,36 @@ class Mpc {
1130
1135
  })
1131
1136
  }
1132
1137
 
1138
+ /*******************************
1139
+ * Account Abstraction Methods
1140
+ *******************************/
1141
+
1142
+ public async accountAbstractionBuildBatchedUserOp(
1143
+ data: BuildBatchedUserOpRequest,
1144
+ traceId?: string,
1145
+ ): Promise<BuildBatchedUserOpResponse> {
1146
+ return this.handleRequestToIframeAndPost({
1147
+ methodMessage: 'portal:accountAbstraction:buildBatchedUserOp',
1148
+ errorMessage: 'portal:accountAbstraction:buildBatchedUserOpError',
1149
+ resultMessage: 'portal:accountAbstraction:buildBatchedUserOpResult',
1150
+ data,
1151
+ traceId,
1152
+ })
1153
+ }
1154
+
1155
+ public async accountAbstractionBroadcastBatchedUserOp(
1156
+ data: BroadcastBatchedUserOpRequest,
1157
+ traceId?: string,
1158
+ ): Promise<BroadcastBatchedUserOpResponse> {
1159
+ return this.handleRequestToIframeAndPost({
1160
+ methodMessage: 'portal:accountAbstraction:broadcastBatchedUserOp',
1161
+ errorMessage: 'portal:accountAbstraction:broadcastBatchedUserOpError',
1162
+ resultMessage: 'portal:accountAbstraction:broadcastBatchedUserOpResult',
1163
+ data,
1164
+ traceId,
1165
+ })
1166
+ }
1167
+
1133
1168
  /***************************
1134
1169
  * Private Methods
1135
1170
  ***************************/
@@ -0,0 +1,122 @@
1
+ export interface UserOperationCall {
2
+ to: string
3
+ value?: string
4
+ data?: string
5
+ nonce?: string
6
+ }
7
+
8
+ export interface BuildBatchedUserOpRequest {
9
+ chain: string
10
+ calls: UserOperationCall[]
11
+ }
12
+
13
+ export interface BuildBatchedUserOpResponse {
14
+ data: {
15
+ userOperation: string
16
+ userOpHash: string
17
+ }
18
+ metadata: {
19
+ chainId: string
20
+ /**
21
+ * Total gas units the built user operation is bounded by, as a decimal
22
+ * string: the straight sum of its gas-limit fields (`callGasLimit`,
23
+ * `verificationGasLimit`, `preVerificationGas`, `paymasterVerificationGasLimit`,
24
+ * `paymasterPostOpGasLimit`) — the ERC-4337 paymaster prefund multiplier is
25
+ * intentionally NOT applied. Upper-bound at build time, not post-execution
26
+ * actual. Optional: omitted by backends that predate this field.
27
+ */
28
+ totalGas?: string
29
+ /**
30
+ * The price per gas unit (wei) the user operation will pay, as a decimal
31
+ * string. `'0'` on chains/providers that carry no on-chain fee on the op
32
+ * (e.g. Ultra Relay bundler-level sponsorship). Optional.
33
+ */
34
+ maxFeePerGas?: string
35
+ /**
36
+ * Build-time upper-bound gas cost in wei, as a decimal string
37
+ * (`totalGas * maxFeePerGas`, computed server-side). This is the authoritative
38
+ * value to charge against — convert wei → fee token and apply your own buffer.
39
+ * `'0'` when the op carries no on-chain fee. Optional: omitted by backends
40
+ * that predate this field.
41
+ */
42
+ estimatedGasCostWei?: string
43
+ }
44
+ }
45
+
46
+ export interface BroadcastBatchedUserOpRequest {
47
+ chain: string
48
+ userOperation: string
49
+ signature: string
50
+ }
51
+
52
+ export interface BroadcastBatchedUserOpResponse {
53
+ data: {
54
+ userOpHash: string
55
+ }
56
+ metadata: {
57
+ chainId: string
58
+ }
59
+ }
60
+
61
+ export interface SendBatchUserOpTransaction {
62
+ token: string
63
+ value: string
64
+ to: string
65
+ }
66
+
67
+ export interface SendBatchUserOpRequest {
68
+ chain: string
69
+ transactions: SendBatchUserOpTransaction[]
70
+ signatureApprovalMemo?: string
71
+ traceId?: string
72
+ }
73
+
74
+ /**
75
+ * Gas-reimbursement configuration for `sendBatchedAssets`.
76
+ *
77
+ * The end user's transaction is gas-subsidized by Portal's paymaster; this config
78
+ * appends a final call that transfers `feeToken` from the user's smart account to
79
+ * `feeRecipient` to reimburse the platform for that subsidized gas.
80
+ */
81
+ export interface GasReimbursement {
82
+ /** Fee token symbol to charge the end user in (e.g. 'USDC'). */
83
+ feeToken: string
84
+ /** Address that receives the reimbursement (the platform's collection wallet). */
85
+ feeRecipient: string
86
+ /**
87
+ * Convert the estimated native gas cost (in wei) into a fee-token amount. The
88
+ * platform owns this FX entirely (rate + margin) — Portal does no conversion.
89
+ * Return a human-readable decimal string in `feeToken` units (e.g. '0.42' for
90
+ * 0.42 USDC). May be async.
91
+ */
92
+ convertGasToFeeAmount: (gasCostWei: bigint) => string | Promise<string>
93
+ /**
94
+ * Optional safety margin in basis points applied to the gas cost BEFORE
95
+ * conversion, to absorb gas-price drift between the estimate and the final
96
+ * build (e.g. 1000 = +10%). Defaults to 0.
97
+ */
98
+ bufferBps?: number
99
+ /**
100
+ * Optional non-zero placeholder amount (human-readable, `feeToken` units) used
101
+ * to build the fee call during the gas-estimation pass so the estimate reflects
102
+ * the final batch shape. Defaults to '0.01'. Must be ≤ the wallet's balance. The
103
+ * amount does not affect the gas estimate; it only needs to produce a
104
+ * representative transfer.
105
+ */
106
+ placeholderAmount?: string
107
+ }
108
+
109
+ /**
110
+ * Request for `sendBatchedAssets` — a gas-subsidized batch where the end user
111
+ * reimburses the platform, in a fee token, for the gas Portal sponsored. See
112
+ * {@link GasReimbursement}.
113
+ */
114
+ export interface SendBatchedAssetsRequest {
115
+ chain: string
116
+ /** The end user's actual transaction(s) to execute in the batch. */
117
+ transactions: SendBatchUserOpTransaction[]
118
+ /** Reimbursement appended as the final call in the batch. */
119
+ gasReimbursement: GasReimbursement
120
+ signatureApprovalMemo?: string
121
+ traceId?: string
122
+ }
@@ -896,6 +896,9 @@ export interface SignResult {
896
896
  export interface RawSignOptions {
897
897
  /** Optional memo displayed to the user during the signature approval flow. */
898
898
  signatureApprovalMemo?: string
899
+ /** Caller-supplied trace ID for end-to-end request correlation. When provided it is
900
+ * forwarded to the iframe and MPC layer instead of generating a new one. */
901
+ traceId?: string
899
902
  }
900
903
 
901
904
  export interface EncryptArgs {
@@ -20,6 +20,9 @@ export * from './noah'
20
20
  export * from './hypernative'
21
21
  export * from './blockaid'
22
22
 
23
+ // Account Abstraction types
24
+ export * from './accountAbstraction'
25
+
23
26
  // Delegations types (Address type is internal, not re-exported to avoid conflict with common.Address)
24
27
  export type {
25
28
  DelegationBaseRequest,