@portal-hq/web 3.13.2 → 3.14.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/lib/commonjs/index.js +127 -9
- package/lib/commonjs/index.test.js +13 -0
- package/lib/commonjs/integrations/delegations/index.js +109 -2
- package/lib/commonjs/integrations/delegations/index.test.js +171 -0
- package/lib/commonjs/integrations/ramps/noah/index.test.js +18 -5
- package/lib/commonjs/integrations/trading/index.js +16 -5
- package/lib/commonjs/integrations/trading/lifi/index.js +297 -25
- package/lib/commonjs/integrations/trading/lifi/lifi.tradeAsset.test.js +360 -0
- package/lib/commonjs/integrations/trading/lifi/lifiStatusPoll.js +118 -0
- package/lib/commonjs/integrations/trading/lifi/lifiStatusPoll.test.js +66 -0
- package/lib/commonjs/integrations/trading/zero-x/index.js +129 -26
- package/lib/commonjs/integrations/trading/zero-x/index.test.js +163 -1
- package/lib/commonjs/integrations/yield/index.js +18 -4
- package/lib/commonjs/integrations/yield/yieldxyz.getValidators.test.js +71 -0
- package/lib/commonjs/integrations/yield/yieldxyz.highLevel.test.js +330 -0
- package/lib/commonjs/integrations/yield/yieldxyz.js +517 -1
- package/lib/commonjs/internal/pollLoop.js +64 -0
- package/lib/commonjs/internal/pollLoop.test.js +100 -0
- package/lib/commonjs/internal/stripStalePlanningNonce.js +65 -0
- package/lib/commonjs/internal/stripStalePlanningNonce.test.js +35 -0
- package/lib/commonjs/internal/waitForEvmOrUserOpConfirmation.js +155 -0
- package/lib/commonjs/internal/waitForEvmOrUserOpConfirmation.test.js +33 -0
- package/lib/commonjs/internal/waitForEvmTxConfirmation.js +104 -0
- package/lib/commonjs/internal/waitForSolanaTxConfirmation.js +106 -0
- package/lib/commonjs/internal/yieldEvmNetwork.js +60 -0
- package/lib/commonjs/mpc/index.js +116 -1
- package/lib/commonjs/provider/index.js +17 -0
- package/lib/commonjs/shared/trace/index.js +0 -1
- package/lib/esm/index.js +127 -9
- package/lib/esm/index.test.js +13 -0
- package/lib/esm/integrations/delegations/index.js +109 -2
- package/lib/esm/integrations/delegations/index.test.js +171 -0
- package/lib/esm/integrations/ramps/noah/index.test.js +18 -5
- package/lib/esm/integrations/trading/index.js +16 -5
- package/lib/esm/integrations/trading/lifi/index.js +292 -25
- package/lib/esm/integrations/trading/lifi/lifi.tradeAsset.test.js +332 -0
- package/lib/esm/integrations/trading/lifi/lifiStatusPoll.js +113 -0
- package/lib/esm/integrations/trading/lifi/lifiStatusPoll.test.js +64 -0
- package/lib/esm/integrations/trading/zero-x/index.js +129 -26
- package/lib/esm/integrations/trading/zero-x/index.test.js +141 -2
- package/lib/esm/integrations/yield/index.js +18 -4
- package/lib/esm/integrations/yield/yieldxyz.getValidators.test.js +66 -0
- package/lib/esm/integrations/yield/yieldxyz.highLevel.test.js +325 -0
- package/lib/esm/integrations/yield/yieldxyz.js +517 -1
- package/lib/esm/internal/pollLoop.js +59 -0
- package/lib/esm/internal/pollLoop.test.js +98 -0
- package/lib/esm/internal/stripStalePlanningNonce.js +61 -0
- package/lib/esm/internal/stripStalePlanningNonce.test.js +33 -0
- package/lib/esm/internal/waitForEvmOrUserOpConfirmation.js +151 -0
- package/lib/esm/internal/waitForEvmOrUserOpConfirmation.test.js +31 -0
- package/lib/esm/internal/waitForEvmTxConfirmation.js +100 -0
- package/lib/esm/internal/waitForSolanaTxConfirmation.js +102 -0
- package/lib/esm/internal/yieldEvmNetwork.js +55 -0
- package/lib/esm/mpc/index.js +116 -1
- package/lib/esm/provider/index.js +17 -0
- package/lib/esm/shared/trace/index.js +0 -1
- package/noah-types.d.ts +16 -2
- package/package.json +3 -2
- package/src/index.test.ts +15 -0
- package/src/index.ts +203 -14
- package/src/integrations/delegations/index.test.ts +251 -0
- package/src/integrations/delegations/index.ts +202 -4
- package/src/integrations/ramps/noah/index.test.ts +18 -5
- package/src/integrations/trading/index.ts +10 -7
- package/src/integrations/trading/lifi/index.ts +388 -28
- package/src/integrations/trading/lifi/lifi.tradeAsset.test.ts +436 -0
- package/src/integrations/trading/lifi/lifiStatusPoll.test.ts +74 -0
- package/src/integrations/trading/lifi/lifiStatusPoll.ts +158 -0
- package/src/integrations/trading/zero-x/index.test.ts +297 -1
- package/src/integrations/trading/zero-x/index.ts +181 -27
- package/src/integrations/yield/index.ts +24 -4
- package/src/integrations/yield/yieldxyz.getValidators.test.ts +70 -0
- package/src/integrations/yield/yieldxyz.highLevel.test.ts +403 -0
- package/src/integrations/yield/yieldxyz.ts +740 -8
- package/src/internal/pollLoop.test.ts +109 -0
- package/src/internal/pollLoop.ts +87 -0
- package/src/internal/stripStalePlanningNonce.test.ts +38 -0
- package/src/internal/stripStalePlanningNonce.ts +66 -0
- package/src/internal/waitForEvmOrUserOpConfirmation.test.ts +31 -0
- package/src/internal/waitForEvmOrUserOpConfirmation.ts +194 -0
- package/src/internal/waitForEvmTxConfirmation.ts +155 -0
- package/src/internal/waitForSolanaTxConfirmation.ts +135 -0
- package/src/internal/yieldEvmNetwork.ts +57 -0
- package/src/mpc/index.ts +142 -1
- package/src/provider/index.ts +25 -0
- package/src/shared/trace/index.ts +0 -1
- package/src/shared/types/README.md +6 -0
- package/src/shared/types/api.ts +12 -1
- package/src/shared/types/common.ts +332 -20
- package/src/shared/types/delegations.ts +10 -0
- package/src/shared/types/index.ts +1 -0
- package/src/shared/types/lifi.ts +82 -0
- package/src/shared/types/noah.ts +124 -33
- package/src/shared/types/yieldxyz.ts +186 -0
- package/src/shared/types/zero-x.ts +66 -0
- package/types.d.ts +6 -0
package/src/shared/types/noah.ts
CHANGED
|
@@ -25,9 +25,40 @@ export interface NoahInitiatePayinRequest {
|
|
|
25
25
|
destinationAddress: string
|
|
26
26
|
}
|
|
27
27
|
|
|
28
|
+
export interface StreetAddress {
|
|
29
|
+
city?: string
|
|
30
|
+
country?: string
|
|
31
|
+
line1?: string
|
|
32
|
+
line2?: string
|
|
33
|
+
postalCode?: string
|
|
34
|
+
state?: string
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export interface BankToAddressRelatedPaymentMethod {
|
|
38
|
+
paymentMethodId: string
|
|
39
|
+
paymentMethodType: string
|
|
40
|
+
details?: {
|
|
41
|
+
accountNumber?: string
|
|
42
|
+
bankCode?: string
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export interface BankDetails {
|
|
47
|
+
paymentMethodId: string
|
|
48
|
+
paymentMethodType: string
|
|
49
|
+
accountNumber: string
|
|
50
|
+
network: string
|
|
51
|
+
accountHolderName?: string
|
|
52
|
+
bankCode?: string
|
|
53
|
+
bankName?: string
|
|
54
|
+
bankAddress?: StreetAddress
|
|
55
|
+
reference?: string
|
|
56
|
+
relatedPaymentMethods?: BankToAddressRelatedPaymentMethod[]
|
|
57
|
+
}
|
|
58
|
+
|
|
28
59
|
export interface NoahInitiatePayinResponseData {
|
|
29
60
|
payinId: string
|
|
30
|
-
bankDetails:
|
|
61
|
+
bankDetails: BankDetails
|
|
31
62
|
}
|
|
32
63
|
|
|
33
64
|
export type NoahInitiatePayinResponse =
|
|
@@ -39,13 +70,15 @@ export interface NoahSimulatePayinRequest {
|
|
|
39
70
|
fiatCurrency: string
|
|
40
71
|
}
|
|
41
72
|
|
|
42
|
-
export
|
|
73
|
+
export interface NoahSimulatePayinResponseData {
|
|
74
|
+
fiatDepositId: string
|
|
75
|
+
}
|
|
43
76
|
|
|
44
77
|
export type NoahSimulatePayinResponse =
|
|
45
78
|
PortalApiSuccessEnvelope<NoahSimulatePayinResponseData>
|
|
46
79
|
|
|
47
80
|
export interface NoahGetPayoutCountriesResponseData {
|
|
48
|
-
countries:
|
|
81
|
+
countries: Record<string, string[]>
|
|
49
82
|
}
|
|
50
83
|
|
|
51
84
|
export type NoahGetPayoutCountriesResponse =
|
|
@@ -58,17 +91,84 @@ export interface NoahGetPayoutChannelsRequest {
|
|
|
58
91
|
fiatAmount?: string
|
|
59
92
|
}
|
|
60
93
|
|
|
61
|
-
|
|
62
|
-
|
|
94
|
+
export interface ChannelLimits {
|
|
95
|
+
minLimit: string
|
|
96
|
+
maxLimit?: string
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
export interface ChannelCalculated {
|
|
100
|
+
totalFee: string
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
export interface Channel {
|
|
104
|
+
id: string
|
|
105
|
+
paymentMethodType: string
|
|
106
|
+
fiatCurrency: string
|
|
107
|
+
country: string
|
|
108
|
+
limits: ChannelLimits
|
|
109
|
+
rate: string
|
|
110
|
+
processingSeconds: number
|
|
111
|
+
calculated?: ChannelCalculated
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
export interface NoahGetPayoutChannelsResponseData {
|
|
115
|
+
items: Channel[]
|
|
116
|
+
pageToken?: string
|
|
117
|
+
}
|
|
63
118
|
|
|
64
119
|
export type NoahGetPayoutChannelsResponse =
|
|
65
120
|
PortalApiSuccessEnvelope<NoahGetPayoutChannelsResponseData>
|
|
66
121
|
|
|
67
|
-
export
|
|
122
|
+
export interface NoahGetPayoutChannelFormResponseData {
|
|
123
|
+
formSchema?: Record<string, unknown>
|
|
124
|
+
formMetadata?: {
|
|
125
|
+
contentHash: string
|
|
126
|
+
}
|
|
127
|
+
}
|
|
68
128
|
|
|
69
129
|
export type NoahGetPayoutChannelFormResponse =
|
|
70
130
|
PortalApiSuccessEnvelope<NoahGetPayoutChannelFormResponseData>
|
|
71
131
|
|
|
132
|
+
export interface PaymentMethodDetails {
|
|
133
|
+
type: string
|
|
134
|
+
accountNumber?: string
|
|
135
|
+
bankCode?: string
|
|
136
|
+
last4?: string
|
|
137
|
+
scheme?: string
|
|
138
|
+
identifierType?: string
|
|
139
|
+
identifier?: string
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
export interface AccountHolderDetails {
|
|
143
|
+
name?: string
|
|
144
|
+
taxId?: string
|
|
145
|
+
email?: string
|
|
146
|
+
phoneNumber?: string
|
|
147
|
+
address?: StreetAddress
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
export interface IssuerDetails {
|
|
151
|
+
name?: string
|
|
152
|
+
bankCode?: string
|
|
153
|
+
bankName?: string
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
export interface PaymentMethod {
|
|
157
|
+
id: string
|
|
158
|
+
paymentMethodType: string
|
|
159
|
+
details: PaymentMethodDetails
|
|
160
|
+
accountHolderDetails?: AccountHolderDetails
|
|
161
|
+
issuerDetails?: IssuerDetails
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
export interface NoahGetPaymentMethodsResponseData {
|
|
165
|
+
paymentMethods: PaymentMethod[]
|
|
166
|
+
pageToken?: string
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
export type NoahGetPaymentMethodsResponse =
|
|
170
|
+
PortalApiSuccessEnvelope<NoahGetPaymentMethodsResponseData>
|
|
171
|
+
|
|
72
172
|
export interface NoahGetPayoutQuoteRequest {
|
|
73
173
|
channelId: string
|
|
74
174
|
cryptoCurrency: string
|
|
@@ -78,34 +178,33 @@ export interface NoahGetPayoutQuoteRequest {
|
|
|
78
178
|
paymentMethodId?: string
|
|
79
179
|
}
|
|
80
180
|
|
|
181
|
+
export interface FormNextStep {
|
|
182
|
+
stepId: string
|
|
183
|
+
stepType: 'Ack' | 'DataEntry'
|
|
184
|
+
schema: Record<string, unknown>
|
|
185
|
+
}
|
|
186
|
+
|
|
81
187
|
export interface NoahGetPayoutQuoteResponseData {
|
|
82
188
|
payoutId: string
|
|
83
|
-
formSessionId: string
|
|
84
|
-
cryptoAmountEstimate: string
|
|
85
189
|
totalFee: string
|
|
86
|
-
|
|
190
|
+
cryptoAmountEstimate: string
|
|
191
|
+
formSessionId: string
|
|
192
|
+
nextStep?: FormNextStep
|
|
87
193
|
}
|
|
88
194
|
|
|
89
195
|
export type NoahGetPayoutQuoteResponse =
|
|
90
196
|
PortalApiSuccessEnvelope<NoahGetPayoutQuoteResponseData>
|
|
91
197
|
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
*/
|
|
96
|
-
export interface NoahAmountConditionRow {
|
|
97
|
-
ComparisonOperator?: string
|
|
98
|
-
Value?: string
|
|
99
|
-
comparisonOperator?: string
|
|
100
|
-
value?: string
|
|
198
|
+
export interface AmountCondition {
|
|
199
|
+
comparisonOperator: string
|
|
200
|
+
value: string
|
|
101
201
|
}
|
|
102
202
|
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
network?: string
|
|
203
|
+
export interface DepositSourceTriggerCondition {
|
|
204
|
+
amountConditions: AmountCondition[]
|
|
205
|
+
cryptoCurrency: string
|
|
206
|
+
network: string
|
|
207
|
+
destinationAddress: string
|
|
109
208
|
}
|
|
110
209
|
|
|
111
210
|
/** Supported Solana CAIP-2 IDs for payout deposit flows. */
|
|
@@ -135,16 +234,8 @@ export interface NoahInitiatePayoutRequest {
|
|
|
135
234
|
|
|
136
235
|
export interface NoahInitiatePayoutResponseData {
|
|
137
236
|
destinationAddress: string | null
|
|
138
|
-
conditions:
|
|
237
|
+
conditions: DepositSourceTriggerCondition[]
|
|
139
238
|
}
|
|
140
239
|
|
|
141
240
|
export type NoahInitiatePayoutResponse =
|
|
142
241
|
PortalApiSuccessEnvelope<NoahInitiatePayoutResponseData>
|
|
143
|
-
|
|
144
|
-
export interface NoahGetPaymentMethodsResponseData {
|
|
145
|
-
paymentMethods: unknown
|
|
146
|
-
pageToken?: unknown
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
export type NoahGetPaymentMethodsResponse =
|
|
150
|
-
PortalApiSuccessEnvelope<NoahGetPaymentMethodsResponseData>
|
|
@@ -776,3 +776,189 @@ export interface YieldXyzGetTransactionResponse {
|
|
|
776
776
|
error?: string
|
|
777
777
|
metadata?: YieldXyzGetTransactionMetadata
|
|
778
778
|
}
|
|
779
|
+
|
|
780
|
+
// ============================================================================
|
|
781
|
+
// High-level Yield (deposit / withdraw / validators) — shared contract types
|
|
782
|
+
// ============================================================================
|
|
783
|
+
|
|
784
|
+
export interface YieldDefaultYieldEntry {
|
|
785
|
+
yieldId: string
|
|
786
|
+
opportunity: YieldXyzOpportunity | null
|
|
787
|
+
}
|
|
788
|
+
|
|
789
|
+
export type YieldDefaultYieldsMap = Record<string, YieldDefaultYieldEntry>
|
|
790
|
+
|
|
791
|
+
export interface YieldXyzGetYieldDefaultsRequest {
|
|
792
|
+
includeOpportunities?: boolean
|
|
793
|
+
}
|
|
794
|
+
|
|
795
|
+
export interface YieldXyzGetYieldDefaultsResponse {
|
|
796
|
+
data?: YieldDefaultYieldsMap
|
|
797
|
+
error?: string
|
|
798
|
+
}
|
|
799
|
+
|
|
800
|
+
export interface YieldXyzValidator {
|
|
801
|
+
address: string
|
|
802
|
+
name?: string
|
|
803
|
+
commission?: string
|
|
804
|
+
apy?: string
|
|
805
|
+
[key: string]: unknown
|
|
806
|
+
}
|
|
807
|
+
|
|
808
|
+
export interface YieldXyzGetYieldValidatorsResponse {
|
|
809
|
+
data?: {
|
|
810
|
+
/** Validators may appear on data.validators or nested under data.rawResponse; consumers should read both. */
|
|
811
|
+
validators?: YieldXyzValidator[]
|
|
812
|
+
rawResponse?: {
|
|
813
|
+
validators?: YieldXyzValidator[]
|
|
814
|
+
/** Paginated validator list shape on nested rawResponse for some native-staking responses. */
|
|
815
|
+
items?: YieldXyzValidator[]
|
|
816
|
+
total?: number
|
|
817
|
+
offset?: number
|
|
818
|
+
limit?: number
|
|
819
|
+
}
|
|
820
|
+
}
|
|
821
|
+
error?: string
|
|
822
|
+
}
|
|
823
|
+
|
|
824
|
+
|
|
825
|
+
|
|
826
|
+
|
|
827
|
+
/**
|
|
828
|
+
* Progress event for deposit/withdraw high-level methods.
|
|
829
|
+
* Lifecycle steps emitted by high-level deposit/withdraw:
|
|
830
|
+
* - `signing`: about to call signAndSendTransaction
|
|
831
|
+
* - `submitted`: hash received from signAndSendTransaction
|
|
832
|
+
* - `confirming`: waiting for on-chain confirmation to reach required depth
|
|
833
|
+
* - `confirmed`: on-chain confirmation complete; about to track
|
|
834
|
+
*/
|
|
835
|
+
export interface YieldSubmitProgress {
|
|
836
|
+
step: 'signing' | 'submitted' | 'confirming' | 'confirmed'
|
|
837
|
+
index: number
|
|
838
|
+
total: number
|
|
839
|
+
hash?: string
|
|
840
|
+
}
|
|
841
|
+
|
|
842
|
+
/**
|
|
843
|
+
* High-level yield deposit / withdraw using an explicit Portal `yieldId` (no defaults lookup).
|
|
844
|
+
*/
|
|
845
|
+
export interface YieldDepositParamsByYieldId {
|
|
846
|
+
yieldId: string
|
|
847
|
+
amount: string
|
|
848
|
+
address: string
|
|
849
|
+
arguments?: YieldXyzEnterArguments
|
|
850
|
+
}
|
|
851
|
+
|
|
852
|
+
/**
|
|
853
|
+
* High-level yield deposit / withdraw: the SDK resolves `yieldId` by fetching Portal yield
|
|
854
|
+
* defaults and reading the entry for `{chain}:{token}`. Pass `token` **exactly** as that map key
|
|
855
|
+
* suffix (same casing/symbol the API returns).
|
|
856
|
+
*/
|
|
857
|
+
export interface YieldDepositParamsByChainAndToken {
|
|
858
|
+
chain: string
|
|
859
|
+
token: string
|
|
860
|
+
amount: string
|
|
861
|
+
address: string
|
|
862
|
+
arguments?: YieldXyzEnterArguments
|
|
863
|
+
}
|
|
864
|
+
|
|
865
|
+
/**
|
|
866
|
+
* High-level yield deposit parameters: either {@link YieldDepositParamsByYieldId} or
|
|
867
|
+
* {@link YieldDepositParamsByChainAndToken}. When `yieldId` is a non-empty string (after trim), it
|
|
868
|
+
* is used directly and defaults lookup is skipped; otherwise `chain` and `token` are required.
|
|
869
|
+
* At runtime, a non-empty `yieldId` takes precedence over any also-present `chain` / `token`.
|
|
870
|
+
*/
|
|
871
|
+
export type YieldDepositParams =
|
|
872
|
+
| YieldDepositParamsByYieldId
|
|
873
|
+
| YieldDepositParamsByChainAndToken
|
|
874
|
+
|
|
875
|
+
/**
|
|
876
|
+
* Same union as {@link YieldDepositParams}.
|
|
877
|
+
*/
|
|
878
|
+
export type YieldWithdrawParams = YieldDepositParams
|
|
879
|
+
|
|
880
|
+
/**
|
|
881
|
+
* Options for deposit/withdraw high-level methods (e.g. onProgress).
|
|
882
|
+
*/
|
|
883
|
+
export interface YieldSubmitOptions {
|
|
884
|
+
onProgress?: (event: YieldSubmitProgress) => void
|
|
885
|
+
/**
|
|
886
|
+
* Per-call signer override. Takes priority over the instance-level setter
|
|
887
|
+
* ({@link YieldXyz.setSignAndSendTransaction}) when provided.
|
|
888
|
+
* Useful for one-off calls that need a different signer without reconfiguring the instance.
|
|
889
|
+
*/
|
|
890
|
+
signAndSendTransaction?: (
|
|
891
|
+
transaction: unknown,
|
|
892
|
+
network: string,
|
|
893
|
+
) => Promise<string>
|
|
894
|
+
/**
|
|
895
|
+
* Optional per-call override for post-submit confirmation logic.
|
|
896
|
+
* Called for **every** transaction on **any** chain (EVM and non-EVM).
|
|
897
|
+
* Takes priority over Portal.waitForConfirmation.
|
|
898
|
+
*
|
|
899
|
+
* When omitted, Portal.waitForConfirmation is used for EVM Yield networks
|
|
900
|
+
* (eth_getTransactionReceipt via gatewayConfig), so multi-step EVM flows stay
|
|
901
|
+
* nonce-safe without extra integrator code.
|
|
902
|
+
*/
|
|
903
|
+
waitForConfirmation?: (
|
|
904
|
+
txHash: string,
|
|
905
|
+
network: string,
|
|
906
|
+
) => Promise<void | boolean>
|
|
907
|
+
/**
|
|
908
|
+
* Optional per-call JSON-RPC transport used by the built-in EVM receipt poller when
|
|
909
|
+
* `waitForConfirmation` is not supplied.
|
|
910
|
+
*/
|
|
911
|
+
evmRequestFn?: (
|
|
912
|
+
method: string,
|
|
913
|
+
params: unknown[],
|
|
914
|
+
network: string,
|
|
915
|
+
) => Promise<unknown>
|
|
916
|
+
/**
|
|
917
|
+
* Per-call tuning for the built-in EVM receipt poller used when `waitForConfirmation`
|
|
918
|
+
* is not provided and the standalone `evmRequestFn` fallback is active.
|
|
919
|
+
* When omitted, the built-in defaults (4 s poll interval, 15 min timeout) are used.
|
|
920
|
+
*/
|
|
921
|
+
evmPollerOptions?: {
|
|
922
|
+
pollIntervalMs?: number
|
|
923
|
+
timeoutMs?: number
|
|
924
|
+
}
|
|
925
|
+
}
|
|
926
|
+
|
|
927
|
+
/**
|
|
928
|
+
* Result of high-level deposit. When the call used `chain` + `token`, those are echoed on the
|
|
929
|
+
* result; when only `yieldId` was passed, `chain` and `token` are omitted.
|
|
930
|
+
*/
|
|
931
|
+
export interface YieldDepositResult {
|
|
932
|
+
hashes: string[]
|
|
933
|
+
yieldId: string
|
|
934
|
+
chain?: string
|
|
935
|
+
token?: string
|
|
936
|
+
yieldOpportunityDetails: {
|
|
937
|
+
yieldId: string
|
|
938
|
+
intent?: YieldXyzActionIntent
|
|
939
|
+
type?: YieldXyzActionType
|
|
940
|
+
executionPattern?: YieldXyzActionExecutionPattern
|
|
941
|
+
status?: YieldXyzActionStatus
|
|
942
|
+
amount?: string | null
|
|
943
|
+
amountUsd?: string | null
|
|
944
|
+
}
|
|
945
|
+
}
|
|
946
|
+
|
|
947
|
+
/**
|
|
948
|
+
* Result of high-level withdraw. Same `chain` / `token` echo rules as {@link YieldDepositResult}.
|
|
949
|
+
*/
|
|
950
|
+
export interface YieldWithdrawResult {
|
|
951
|
+
hashes: string[]
|
|
952
|
+
yieldId: string
|
|
953
|
+
chain?: string
|
|
954
|
+
token?: string
|
|
955
|
+
yieldOpportunityDetails: {
|
|
956
|
+
yieldId: string
|
|
957
|
+
intent?: YieldXyzActionIntent
|
|
958
|
+
type?: YieldXyzActionType
|
|
959
|
+
executionPattern?: YieldXyzActionExecutionPattern
|
|
960
|
+
status?: YieldXyzActionStatus
|
|
961
|
+
amount?: string | null
|
|
962
|
+
amountUsd?: string | null
|
|
963
|
+
}
|
|
964
|
+
}
|
|
@@ -15,6 +15,8 @@ export interface ZeroExQuoteRequest {
|
|
|
15
15
|
}
|
|
16
16
|
|
|
17
17
|
export interface ZeroExQuoteResponse {
|
|
18
|
+
/** When set (non-empty after trim), do not execute the quote (fail closed). */
|
|
19
|
+
error?: string
|
|
18
20
|
data: {
|
|
19
21
|
rawResponse: {
|
|
20
22
|
message?: string
|
|
@@ -202,3 +204,67 @@ export interface ZeroExPriceResponse {
|
|
|
202
204
|
export interface ZeroExOptions {
|
|
203
205
|
zeroXApiKey?: string
|
|
204
206
|
}
|
|
207
|
+
|
|
208
|
+
// --- High-level 0x trade and progress types ---
|
|
209
|
+
|
|
210
|
+
export type ZeroXTradeAssetProgressStatus =
|
|
211
|
+
| 'fetching_quote'
|
|
212
|
+
| 'signing'
|
|
213
|
+
| 'submitted'
|
|
214
|
+
| 'confirming'
|
|
215
|
+
| 'confirmed'
|
|
216
|
+
| 'failed'
|
|
217
|
+
|
|
218
|
+
export interface ZeroXTradeAssetProgressData {
|
|
219
|
+
errorMessage?: string
|
|
220
|
+
buyAmount?: string
|
|
221
|
+
sellAmount?: string
|
|
222
|
+
transaction?: unknown
|
|
223
|
+
txHash?: string
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
export interface ZeroXTradeAssetParams extends Omit<ZeroExQuoteRequest, 'txOrigin'> {
|
|
227
|
+
fromAddress: string
|
|
228
|
+
onProgress?: (
|
|
229
|
+
status: ZeroXTradeAssetProgressStatus,
|
|
230
|
+
data?: ZeroXTradeAssetProgressData,
|
|
231
|
+
) => void
|
|
232
|
+
zeroXApiKey?: string
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
/**
|
|
236
|
+
* **Signer:** per-call → instance (Portal wires default).
|
|
237
|
+
* **Confirmation:** per-call → instance, or `evmRequestFn` + receipt poll (eip155 only) on Web.
|
|
238
|
+
*
|
|
239
|
+
* @remarks
|
|
240
|
+
* When `waitForConfirmation` is omitted on EVM, the browser package can still confirm via
|
|
241
|
+
* `eth_getTransactionReceipt` polling by supplying `evmRequestFn` as the JSON-RPC transport.
|
|
242
|
+
*/
|
|
243
|
+
export interface ZeroXTradeAssetOptions {
|
|
244
|
+
signAndSendTransaction?: (
|
|
245
|
+
transaction: unknown,
|
|
246
|
+
network: string,
|
|
247
|
+
) => Promise<string>
|
|
248
|
+
waitForConfirmation?: (
|
|
249
|
+
txHash: string,
|
|
250
|
+
network: string,
|
|
251
|
+
) => Promise<void | boolean>
|
|
252
|
+
/**
|
|
253
|
+
* When `waitForConfirmation` is not set, the built-in EVM receipt poller uses this JSON-RPC
|
|
254
|
+
* function. Pass `waitForConfirmation` when you need custom confirmation semantics.
|
|
255
|
+
*/
|
|
256
|
+
evmRequestFn?: (
|
|
257
|
+
method: string,
|
|
258
|
+
params: unknown[],
|
|
259
|
+
network: string,
|
|
260
|
+
) => Promise<unknown>
|
|
261
|
+
/** Tuning for the built-in EVM receipt poller when using `evmRequestFn`. */
|
|
262
|
+
evmPollerOptions?: {
|
|
263
|
+
pollIntervalMs?: number
|
|
264
|
+
timeoutMs?: number
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
export interface ZeroXTradeAssetResult {
|
|
269
|
+
hashes: string[]
|
|
270
|
+
}
|
package/types.d.ts
CHANGED
|
@@ -267,6 +267,12 @@ export interface PortalOptions {
|
|
|
267
267
|
// Required options
|
|
268
268
|
rpcConfig: RpcConfig
|
|
269
269
|
|
|
270
|
+
/**
|
|
271
|
+
* Optional RPC map for iframe-proxied reads only (receipt / Solana polling). Parent signing still
|
|
272
|
+
* uses `rpcConfig`. Omit in production when iframe and gateway CORS already align.
|
|
273
|
+
*/
|
|
274
|
+
iframeRpcConfig?: RpcConfig
|
|
275
|
+
|
|
270
276
|
// Optional options
|
|
271
277
|
apiKey?: string
|
|
272
278
|
authToken?: string
|