lampamazaza-new-intents-sdk 0.47.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.
Files changed (179) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +1083 -0
  3. package/dist/_virtual/rolldown_runtime.cjs +29 -0
  4. package/dist/index.cjs +124 -0
  5. package/dist/index.d.cts +22 -0
  6. package/dist/index.d.ts +22 -0
  7. package/dist/index.js +19 -0
  8. package/dist/src/bridges/aurora-engine-bridge/aurora-engine-bridge-constants.cjs +10 -0
  9. package/dist/src/bridges/aurora-engine-bridge/aurora-engine-bridge-constants.js +7 -0
  10. package/dist/src/bridges/aurora-engine-bridge/aurora-engine-bridge-utils.cjs +44 -0
  11. package/dist/src/bridges/aurora-engine-bridge/aurora-engine-bridge-utils.js +42 -0
  12. package/dist/src/bridges/aurora-engine-bridge/aurora-engine-bridge.cjs +111 -0
  13. package/dist/src/bridges/aurora-engine-bridge/aurora-engine-bridge.js +110 -0
  14. package/dist/src/bridges/direct-bridge/direct-bridge-constants.cjs +8 -0
  15. package/dist/src/bridges/direct-bridge/direct-bridge-constants.js +6 -0
  16. package/dist/src/bridges/direct-bridge/direct-bridge-utils.cjs +47 -0
  17. package/dist/src/bridges/direct-bridge/direct-bridge-utils.js +44 -0
  18. package/dist/src/bridges/direct-bridge/direct-bridge.cjs +155 -0
  19. package/dist/src/bridges/direct-bridge/direct-bridge.js +154 -0
  20. package/dist/src/bridges/direct-bridge/error.cjs +16 -0
  21. package/dist/src/bridges/direct-bridge/error.d.cts +12 -0
  22. package/dist/src/bridges/direct-bridge/error.d.ts +12 -0
  23. package/dist/src/bridges/direct-bridge/error.js +15 -0
  24. package/dist/src/bridges/hot-bridge/error.cjs +23 -0
  25. package/dist/src/bridges/hot-bridge/error.d.cts +19 -0
  26. package/dist/src/bridges/hot-bridge/error.d.ts +19 -0
  27. package/dist/src/bridges/hot-bridge/error.js +21 -0
  28. package/dist/src/bridges/hot-bridge/hot-bridge-chains.cjs +21 -0
  29. package/dist/src/bridges/hot-bridge/hot-bridge-chains.d.cts +6 -0
  30. package/dist/src/bridges/hot-bridge/hot-bridge-chains.d.ts +6 -0
  31. package/dist/src/bridges/hot-bridge/hot-bridge-chains.js +20 -0
  32. package/dist/src/bridges/hot-bridge/hot-bridge-constants.cjs +11 -0
  33. package/dist/src/bridges/hot-bridge/hot-bridge-constants.js +9 -0
  34. package/dist/src/bridges/hot-bridge/hot-bridge-utils.cjs +66 -0
  35. package/dist/src/bridges/hot-bridge/hot-bridge-utils.js +61 -0
  36. package/dist/src/bridges/hot-bridge/hot-bridge.cjs +241 -0
  37. package/dist/src/bridges/hot-bridge/hot-bridge.js +239 -0
  38. package/dist/src/bridges/intents-bridge/intents-bridge.cjs +59 -0
  39. package/dist/src/bridges/intents-bridge/intents-bridge.js +59 -0
  40. package/dist/src/bridges/omni-bridge/error.cjs +54 -0
  41. package/dist/src/bridges/omni-bridge/error.d.cts +41 -0
  42. package/dist/src/bridges/omni-bridge/error.d.ts +41 -0
  43. package/dist/src/bridges/omni-bridge/error.js +49 -0
  44. package/dist/src/bridges/omni-bridge/omni-bridge-constants.cjs +12 -0
  45. package/dist/src/bridges/omni-bridge/omni-bridge-constants.js +8 -0
  46. package/dist/src/bridges/omni-bridge/omni-bridge-utils.cjs +153 -0
  47. package/dist/src/bridges/omni-bridge/omni-bridge-utils.js +143 -0
  48. package/dist/src/bridges/omni-bridge/omni-bridge.cjs +316 -0
  49. package/dist/src/bridges/omni-bridge/omni-bridge.js +314 -0
  50. package/dist/src/bridges/poa-bridge/poa-bridge-utils.cjs +76 -0
  51. package/dist/src/bridges/poa-bridge/poa-bridge-utils.js +73 -0
  52. package/dist/src/bridges/poa-bridge/poa-bridge.cjs +175 -0
  53. package/dist/src/bridges/poa-bridge/poa-bridge.js +173 -0
  54. package/dist/src/bridges/poa-bridge/poa-constants.cjs +6 -0
  55. package/dist/src/bridges/poa-bridge/poa-constants.js +5 -0
  56. package/dist/src/classes/errors.cjs +87 -0
  57. package/dist/src/classes/errors.d.cts +48 -0
  58. package/dist/src/classes/errors.d.ts +48 -0
  59. package/dist/src/classes/errors.js +81 -0
  60. package/dist/src/constants/bridge-name-enum.cjs +11 -0
  61. package/dist/src/constants/bridge-name-enum.d.cts +11 -0
  62. package/dist/src/constants/bridge-name-enum.d.ts +11 -0
  63. package/dist/src/constants/bridge-name-enum.js +10 -0
  64. package/dist/src/constants/poa-tokens-routable-through-omni-bridge.cjs +17 -0
  65. package/dist/src/constants/poa-tokens-routable-through-omni-bridge.d.cts +12 -0
  66. package/dist/src/constants/poa-tokens-routable-through-omni-bridge.d.ts +12 -0
  67. package/dist/src/constants/poa-tokens-routable-through-omni-bridge.js +16 -0
  68. package/dist/src/constants/public-rpc-urls.cjs +25 -0
  69. package/dist/src/constants/public-rpc-urls.js +24 -0
  70. package/dist/src/constants/route-enum.cjs +13 -0
  71. package/dist/src/constants/route-enum.d.cts +13 -0
  72. package/dist/src/constants/route-enum.d.ts +13 -0
  73. package/dist/src/constants/route-enum.js +12 -0
  74. package/dist/src/constants/withdrawal-timing.cjs +68 -0
  75. package/dist/src/constants/withdrawal-timing.js +68 -0
  76. package/dist/src/core/withdrawal-watcher.cjs +86 -0
  77. package/dist/src/core/withdrawal-watcher.d.cts +18 -0
  78. package/dist/src/core/withdrawal-watcher.d.ts +19 -0
  79. package/dist/src/core/withdrawal-watcher.js +82 -0
  80. package/dist/src/intents/expirable-nonce.cjs +90 -0
  81. package/dist/src/intents/expirable-nonce.d.cts +44 -0
  82. package/dist/src/intents/expirable-nonce.d.ts +45 -0
  83. package/dist/src/intents/expirable-nonce.js +82 -0
  84. package/dist/src/intents/intent-executer-impl/intent-executer.cjs +85 -0
  85. package/dist/src/intents/intent-executer-impl/intent-executer.d.cts +20 -0
  86. package/dist/src/intents/intent-executer-impl/intent-executer.d.ts +24 -0
  87. package/dist/src/intents/intent-executer-impl/intent-executer.js +85 -0
  88. package/dist/src/intents/intent-hash.cjs +48 -0
  89. package/dist/src/intents/intent-hash.d.cts +8 -0
  90. package/dist/src/intents/intent-hash.d.ts +8 -0
  91. package/dist/src/intents/intent-hash.js +47 -0
  92. package/dist/src/intents/intent-hashes/erc191.cjs +38 -0
  93. package/dist/src/intents/intent-hashes/erc191.js +37 -0
  94. package/dist/src/intents/intent-hashes/nep413.cjs +23 -0
  95. package/dist/src/intents/intent-hashes/nep413.js +22 -0
  96. package/dist/src/intents/intent-hashes/raw-ed25519.cjs +26 -0
  97. package/dist/src/intents/intent-hashes/raw-ed25519.js +25 -0
  98. package/dist/src/intents/intent-hashes/sep53.cjs +36 -0
  99. package/dist/src/intents/intent-hashes/sep53.js +35 -0
  100. package/dist/src/intents/intent-hashes/tip191.cjs +39 -0
  101. package/dist/src/intents/intent-hashes/tip191.js +38 -0
  102. package/dist/src/intents/intent-hashes/ton-connect.cjs +105 -0
  103. package/dist/src/intents/intent-hashes/ton-connect.js +104 -0
  104. package/dist/src/intents/intent-hashes/webauthn.cjs +26 -0
  105. package/dist/src/intents/intent-hashes/webauthn.js +25 -0
  106. package/dist/src/intents/intent-payload-builder.cjs +208 -0
  107. package/dist/src/intents/intent-payload-builder.d.cts +161 -0
  108. package/dist/src/intents/intent-payload-builder.d.ts +161 -0
  109. package/dist/src/intents/intent-payload-builder.js +207 -0
  110. package/dist/src/intents/intent-payload-factory.cjs +23 -0
  111. package/dist/src/intents/intent-payload-factory.js +21 -0
  112. package/dist/src/intents/intent-relayer-impl/intent-relayer-public.cjs +43 -0
  113. package/dist/src/intents/intent-relayer-impl/intent-relayer-public.js +42 -0
  114. package/dist/src/intents/intent-signer-impl/factories.cjs +19 -0
  115. package/dist/src/intents/intent-signer-impl/factories.d.cts +11 -0
  116. package/dist/src/intents/intent-signer-impl/factories.d.ts +11 -0
  117. package/dist/src/intents/intent-signer-impl/factories.js +17 -0
  118. package/dist/src/intents/intent-signer-impl/intent-signer-near-keypair.cjs +22 -0
  119. package/dist/src/intents/intent-signer-impl/intent-signer-near-keypair.d.cts +15 -0
  120. package/dist/src/intents/intent-signer-impl/intent-signer-near-keypair.d.ts +16 -0
  121. package/dist/src/intents/intent-signer-impl/intent-signer-near-keypair.js +21 -0
  122. package/dist/src/intents/intent-signer-impl/intent-signer-nep413.cjs +37 -0
  123. package/dist/src/intents/intent-signer-impl/intent-signer-nep413.d.cts +14 -0
  124. package/dist/src/intents/intent-signer-impl/intent-signer-nep413.d.ts +14 -0
  125. package/dist/src/intents/intent-signer-impl/intent-signer-nep413.js +36 -0
  126. package/dist/src/intents/intent-signer-impl/intent-signer-noop.cjs +8 -0
  127. package/dist/src/intents/intent-signer-impl/intent-signer-noop.js +7 -0
  128. package/dist/src/intents/intent-signer-impl/intent-signer-viem.cjs +31 -0
  129. package/dist/src/intents/intent-signer-impl/intent-signer-viem.d.cts +17 -0
  130. package/dist/src/intents/intent-signer-impl/intent-signer-viem.d.ts +17 -0
  131. package/dist/src/intents/intent-signer-impl/intent-signer-viem.js +30 -0
  132. package/dist/src/intents/interfaces/intent-executer.d.ts +2 -0
  133. package/dist/src/intents/interfaces/intent-relayer.d.cts +43 -0
  134. package/dist/src/intents/interfaces/intent-relayer.d.ts +43 -0
  135. package/dist/src/intents/interfaces/intent-signer.d.cts +8 -0
  136. package/dist/src/intents/interfaces/intent-signer.d.ts +8 -0
  137. package/dist/src/intents/interfaces/salt-manager.d.cts +9 -0
  138. package/dist/src/intents/interfaces/salt-manager.d.ts +9 -0
  139. package/dist/src/intents/salt-manager.cjs +74 -0
  140. package/dist/src/intents/salt-manager.js +72 -0
  141. package/dist/src/intents/shared-types.d.cts +20 -0
  142. package/dist/src/intents/shared-types.d.ts +20 -0
  143. package/dist/src/lib/array.cjs +11 -0
  144. package/dist/src/lib/array.js +10 -0
  145. package/dist/src/lib/caip2.cjs +50 -0
  146. package/dist/src/lib/caip2.d.cts +38 -0
  147. package/dist/src/lib/caip2.d.ts +38 -0
  148. package/dist/src/lib/caip2.js +48 -0
  149. package/dist/src/lib/configure-rpc-config.cjs +20 -0
  150. package/dist/src/lib/configure-rpc-config.js +18 -0
  151. package/dist/src/lib/estimate-fee.cjs +96 -0
  152. package/dist/src/lib/estimate-fee.js +94 -0
  153. package/dist/src/lib/hex.cjs +11 -0
  154. package/dist/src/lib/hex.js +10 -0
  155. package/dist/src/lib/nep413.cjs +42 -0
  156. package/dist/src/lib/nep413.d.cts +14 -0
  157. package/dist/src/lib/nep413.d.ts +14 -0
  158. package/dist/src/lib/nep413.js +41 -0
  159. package/dist/src/lib/object.cjs +10 -0
  160. package/dist/src/lib/object.js +9 -0
  161. package/dist/src/lib/parse-defuse-asset-id.cjs +15 -0
  162. package/dist/src/lib/parse-defuse-asset-id.js +14 -0
  163. package/dist/src/lib/route-config-factory.cjs +43 -0
  164. package/dist/src/lib/route-config-factory.d.cts +13 -0
  165. package/dist/src/lib/route-config-factory.d.ts +13 -0
  166. package/dist/src/lib/route-config-factory.js +37 -0
  167. package/dist/src/lib/tokensUsdPricesHttpClient/apis.cjs +17 -0
  168. package/dist/src/lib/tokensUsdPricesHttpClient/apis.js +16 -0
  169. package/dist/src/lib/validateAddress.cjs +271 -0
  170. package/dist/src/lib/validateAddress.d.cts +14 -0
  171. package/dist/src/lib/validateAddress.d.ts +14 -0
  172. package/dist/src/lib/validateAddress.js +270 -0
  173. package/dist/src/sdk.cjs +435 -0
  174. package/dist/src/sdk.d.cts +231 -0
  175. package/dist/src/sdk.d.ts +231 -0
  176. package/dist/src/sdk.js +433 -0
  177. package/dist/src/shared-types.d.cts +378 -0
  178. package/dist/src/shared-types.d.ts +378 -0
  179. package/package.json +62 -0
@@ -0,0 +1,378 @@
1
+ import { HotBridgeEVMChain } from "./bridges/hot-bridge/hot-bridge-chains.js";
2
+ import { BridgeNameEnumValues } from "./constants/bridge-name-enum.js";
3
+ import { RouteEnum, RouteEnumValues } from "./constants/route-enum.js";
4
+ import { IntentHash, IntentPayloadFactory, IntentPrimitive, IntentRelayParamsFactory, MultiPayload } from "./intents/shared-types.js";
5
+ import { IIntentSigner } from "./intents/interfaces/intent-signer.js";
6
+ import { OnBeforePublishIntentHook } from "./intents/intent-executer-impl/intent-executer.js";
7
+ import { Chain, Chains } from "./lib/caip2.js";
8
+ import { ILogger, solverRelay } from "lampamazaza-internal-utils";
9
+
10
+ //#region src/shared-types.d.ts
11
+ interface IntentPublishResult {
12
+ intentHash: IntentHash;
13
+ }
14
+ interface WithdrawalResult {
15
+ feeEstimation: FeeEstimation;
16
+ intentHash: IntentHash;
17
+ intentTx: NearTxInfo;
18
+ destinationTx: TxInfo | TxNoInfo;
19
+ }
20
+ interface BatchWithdrawalResult {
21
+ feeEstimation: FeeEstimation[];
22
+ intentHash: IntentHash;
23
+ intentTx: NearTxInfo;
24
+ destinationTx: (TxInfo | TxNoInfo)[];
25
+ }
26
+ type IntentSettlementStatus = solverRelay.GetStatusReturnType;
27
+ /**
28
+ * Configuration for including pre-signed intents to be published atomically.
29
+ *
30
+ * Pre-signed intents can be included in two ways:
31
+ * - `before`: Pre-signed intents that execute before the newly created intent
32
+ * - `after`: Pre-signed intents that execute after the newly created intent
33
+ *
34
+ * The execution order is guaranteed: before → new intent → after
35
+ *
36
+ * @example
37
+ * ```typescript
38
+ * // Include pre-signed intents from other users
39
+ * const signedIntents: SignedIntents = {
40
+ * before: [signedIntent1, signedIntent2],
41
+ * after: [cleanupIntent],
42
+ * };
43
+ *
44
+ * await sdk.signAndSendIntent({
45
+ * intents: [myNewIntent],
46
+ * signedIntents,
47
+ * });
48
+ * ```
49
+ */
50
+ interface SignedIntentsComposition {
51
+ /**
52
+ * Pre-signed intents (MultiPayload) to execute before the newly created intent.
53
+ * Useful for dependencies that must be executed first.
54
+ */
55
+ before?: MultiPayload[];
56
+ /**
57
+ * Pre-signed intents (MultiPayload) to execute after the newly created intent.
58
+ * Useful for cleanup or follow-up actions.
59
+ */
60
+ after?: MultiPayload[];
61
+ }
62
+ interface SignAndSendArgs {
63
+ intents: IntentPrimitive[];
64
+ /**
65
+ * Factory function to modify the intent payload draft before signing.
66
+ * Use this to add or modify intent primitives in the payload.
67
+ *
68
+ * @example
69
+ * ```typescript
70
+ * payload: (draft) => ({
71
+ * intents: [...draft.intents, { intent: "transfer", ... }]
72
+ * })
73
+ * ```
74
+ */
75
+ payload?: IntentPayloadFactory;
76
+ relayParams?: IntentRelayParamsFactory;
77
+ signer?: IIntentSigner;
78
+ onBeforePublishIntent?: OnBeforePublishIntentHook;
79
+ /**
80
+ * Pre-signed intents for atomic execution.
81
+ * The newly created intent will be published together with these pre-signed intents.
82
+ */
83
+ signedIntents?: SignedIntentsComposition;
84
+ logger?: ILogger;
85
+ }
86
+ type SignAndSendWithdrawalArgs<T extends WithdrawalParams | WithdrawalParams[]> = {
87
+ withdrawalParams: T;
88
+ feeEstimation: T extends WithdrawalParams[] ? FeeEstimation[] : FeeEstimation;
89
+ referral?: string;
90
+ intent?: Omit<SignAndSendArgs, "logger" | "intents">;
91
+ logger?: ILogger;
92
+ };
93
+ type ProcessWithdrawalArgs<T extends WithdrawalParams | WithdrawalParams[]> = {
94
+ withdrawalParams: T;
95
+ feeEstimation?: T extends WithdrawalParams[] ? FeeEstimation[] : FeeEstimation;
96
+ intent?: {
97
+ /** @see SignAndSendArgs.payload */
98
+ payload?: IntentPayloadFactory;
99
+ /** @see SignAndSendArgs.relayParams */
100
+ relayParams?: IntentRelayParamsFactory;
101
+ /** @see SignAndSendArgs.signer */
102
+ signer?: IIntentSigner;
103
+ /** @see SignAndSendArgs.onBeforePublishIntent */
104
+ onBeforePublishIntent?: OnBeforePublishIntentHook;
105
+ /** @see SignAndSendArgs.signedIntents */
106
+ signedIntents?: SignedIntentsComposition;
107
+ };
108
+ referral?: string;
109
+ logger?: ILogger;
110
+ };
111
+ interface IIntentsSDK {
112
+ setIntentSigner(signer: IIntentSigner): void;
113
+ sendSignedIntents(args: {
114
+ multiPayloads: MultiPayload[];
115
+ quoteHashes?: string[];
116
+ logger?: ILogger;
117
+ }): Promise<{
118
+ tickets: IntentHash[];
119
+ }>;
120
+ signAndSendIntent(args: SignAndSendArgs): Promise<IntentPublishResult>;
121
+ waitForIntentSettlement(args: {
122
+ intentHash: IntentHash;
123
+ /** AbortSignal for cancellation/timeout. Use AbortSignal.timeout(ms) for timeout. */
124
+ signal?: AbortSignal;
125
+ logger?: ILogger;
126
+ }): Promise<NearTxInfo>;
127
+ getIntentStatus(args: {
128
+ intentHash: IntentHash;
129
+ logger?: ILogger;
130
+ }): Promise<IntentSettlementStatus>;
131
+ invalidateNonces(args: {
132
+ nonces: string[];
133
+ signer?: IIntentSigner;
134
+ logger?: ILogger;
135
+ }): Promise<void>;
136
+ estimateWithdrawalFee(args: {
137
+ withdrawalParams: WithdrawalParams;
138
+ quoteOptions?: QuoteOptions;
139
+ logger?: ILogger;
140
+ }): Promise<FeeEstimation>;
141
+ estimateWithdrawalFee(args: {
142
+ withdrawalParams: WithdrawalParams[];
143
+ quoteOptions?: QuoteOptions;
144
+ logger?: ILogger;
145
+ }): Promise<FeeEstimation[]>;
146
+ signAndSendWithdrawalIntent(args: SignAndSendWithdrawalArgs<WithdrawalParams> | SignAndSendWithdrawalArgs<WithdrawalParams[]>): Promise<IntentPublishResult>;
147
+ waitForWithdrawalCompletion(args: {
148
+ withdrawalParams: WithdrawalParams;
149
+ intentTx: NearTxInfo;
150
+ signal?: AbortSignal;
151
+ logger?: ILogger;
152
+ }): Promise<TxInfo | TxNoInfo>;
153
+ waitForWithdrawalCompletion(args: {
154
+ withdrawalParams: WithdrawalParams[];
155
+ intentTx: NearTxInfo;
156
+ signal?: AbortSignal;
157
+ logger?: ILogger;
158
+ }): Promise<Array<TxInfo | TxNoInfo>>;
159
+ createWithdrawalCompletionPromises(params: CreateWithdrawalCompletionPromisesParams): Array<Promise<TxInfo | TxNoInfo>>;
160
+ createWithdrawalIntents(args: {
161
+ withdrawalParams: WithdrawalParams;
162
+ feeEstimation: FeeEstimation;
163
+ referral?: string;
164
+ logger?: ILogger;
165
+ }): Promise<IntentPrimitive[]>;
166
+ parseAssetId(assetId: string): ParsedAssetInfo;
167
+ processWithdrawal(args: ProcessWithdrawalArgs<WithdrawalParams>): Promise<WithdrawalResult>;
168
+ processWithdrawal(args: ProcessWithdrawalArgs<WithdrawalParams[]>): Promise<BatchWithdrawalResult>;
169
+ }
170
+ interface QuoteOptions {
171
+ waitMs?: number;
172
+ minWaitMs?: number;
173
+ maxWaitMs?: number;
174
+ trustedMetadata?: unknown;
175
+ }
176
+ interface NearTxInfo {
177
+ hash: string;
178
+ accountId: string;
179
+ }
180
+ interface TxInfo {
181
+ hash: string;
182
+ }
183
+ interface TxNoInfo {
184
+ hash: null;
185
+ }
186
+ interface CreateWithdrawalCompletionPromisesParams {
187
+ withdrawalParams: WithdrawalParams[];
188
+ intentTx: NearTxInfo;
189
+ signal?: AbortSignal;
190
+ logger?: ILogger;
191
+ }
192
+ interface WithdrawalParams {
193
+ assetId: string;
194
+ amount: bigint;
195
+ destinationAddress: string;
196
+ /**
197
+ * XRP Leger chain specific. MEMO IS NOT SUPPORTED FOR STELLAR AND TON.
198
+ */
199
+ destinationMemo?: string | undefined;
200
+ feeInclusive: boolean;
201
+ routeConfig?: RouteConfig | undefined;
202
+ }
203
+ type NearWithdrawalRouteConfig = {
204
+ route: RouteEnum["NearWithdrawal"];
205
+ msg?: string;
206
+ };
207
+ type InternalTransferRouteConfig = {
208
+ route: RouteEnum["InternalTransfer"];
209
+ };
210
+ type VirtualChainRouteConfig = {
211
+ route: RouteEnum["VirtualChain"];
212
+ auroraEngineContractId: string;
213
+ proxyTokenContractId: string | null;
214
+ };
215
+ type PoaBridgeRouteConfig = {
216
+ route: RouteEnum["PoaBridge"];
217
+ };
218
+ type HotBridgeRouteConfig = {
219
+ route: RouteEnum["HotBridge"];
220
+ chain: Chain;
221
+ };
222
+ type OmniBridgeRouteConfig = {
223
+ route: RouteEnum["OmniBridge"];
224
+ chain?: Chain;
225
+ };
226
+ type RouteConfig = NearWithdrawalRouteConfig | InternalTransferRouteConfig | VirtualChainRouteConfig | PoaBridgeRouteConfig | HotBridgeRouteConfig | OmniBridgeRouteConfig;
227
+ /**
228
+ * Fee structure definitions for each route type.
229
+ */
230
+ interface RouteFeeStructures {
231
+ [RouteEnum.HotBridge]: {
232
+ /** Relayer fee for processing the withdrawal on destination chain, taken in base token of destination chain. */
233
+ relayerFee: bigint;
234
+ /** Block number at the time of fee estimation, required for building gasless withdraw intent. */
235
+ blockNumber: bigint;
236
+ };
237
+ [RouteEnum.PoaBridge]: {
238
+ /** Relayer fee for POA bridge transfers, taken in transferred token. */
239
+ relayerFee: bigint;
240
+ };
241
+ [RouteEnum.NearWithdrawal]: {
242
+ /** Fee for nep141 storage deposit in NEAR blockchain, taken in wrap.near token. Paid for a token recipient. */
243
+ storageDepositFee: bigint;
244
+ };
245
+ [RouteEnum.OmniBridge]: {
246
+ /** Fee for nep141 storage deposit in NEAR blockchain, taken in wrap.near token. Paid for omni bridge contract. */
247
+ storageDepositFee: bigint;
248
+ /** Relayer fee for transferring tokens via Omni Bridge to other supported blockchains, taken in wrap.near token. */
249
+ relayerFee: bigint;
250
+ /** Fee taken when making a withdrawal via UTXO connector (e.g., btc-connector.bridge.near), taken in transferred token. */
251
+ utxoProtocolFee?: bigint;
252
+ /** Maximum amount of tokens that can be spent on gas when making a withdrawal via UTXO connector (e.g., btc-connector.bridge.near), taken in transferred token. */
253
+ utxoMaxGasFee?: bigint;
254
+ };
255
+ [RouteEnum.VirtualChain]: {
256
+ /** Fee for nep141 storage deposit in NEAR blockchain, taken in wrap.near token. Paid for virtual chain contract */
257
+ storageDepositFee: bigint;
258
+ };
259
+ /** Internal transfers have no fees */
260
+ [RouteEnum.InternalTransfer]: null;
261
+ }
262
+ /**
263
+ * Represents the different categories of fees that may apply across various withdrawal operations.
264
+ * Each route type has an optional fee structure. Uses a mapped type to ensure all RouteEnum values are covered.
265
+ */
266
+ type UnderlyingFees = { [K in RouteEnumValues]?: RouteFeeStructures[K] };
267
+ interface FeeEstimation {
268
+ amount: bigint;
269
+ /**
270
+ * @internal Implementation detail - do not use directly.
271
+ * This field may change or be removed without notice.
272
+ */
273
+ quote: null | solverRelay.Quote;
274
+ /**
275
+ * @internal Implementation detail - do not use directly.
276
+ * This field may change or be removed without notice.
277
+ */
278
+ underlyingFees: UnderlyingFees;
279
+ }
280
+ interface Bridge {
281
+ readonly route: RouteEnumValues;
282
+ supports(params: Pick<WithdrawalParams, "assetId" | "routeConfig">): Promise<boolean>;
283
+ parseAssetId(assetId: string): ParsedAssetInfo | null;
284
+ /**
285
+ * Validates withdrawal constraints for the bridge.
286
+ * Each bridge implementation may have different withdrawal requirements.
287
+ * Some bridges (like Aurora Engine, Intents) have no restrictions and will always pass.
288
+ * Others (like POA) check minimum amounts, and HOT Bridge checks trustlines for Stellar.
289
+ * @throws {MinWithdrawalAmountError} If the amount is below the minimum required
290
+ * @throws {TrustlineNotFoundError} If destination address lacks required trustline
291
+ */
292
+ validateWithdrawal(args: {
293
+ assetId: string;
294
+ amount: bigint;
295
+ destinationAddress: string;
296
+ feeEstimation: FeeEstimation;
297
+ routeConfig?: RouteConfig;
298
+ logger?: ILogger;
299
+ }): Promise<void>;
300
+ estimateWithdrawalFee<T extends Pick<WithdrawalParams, "assetId" | "destinationAddress" | "routeConfig" | "amount">>(args: {
301
+ withdrawalParams: T;
302
+ quoteOptions?: QuoteOptions;
303
+ logger?: ILogger;
304
+ }): Promise<FeeEstimation>;
305
+ createWithdrawalIntents(args: {
306
+ withdrawalParams: WithdrawalParams;
307
+ feeEstimation: FeeEstimation;
308
+ referral?: string;
309
+ }): Promise<IntentPrimitive[]>;
310
+ /**
311
+ * Creates a complete withdrawal identifier with all required info.
312
+ * Derives landingChain from withdrawalParams.routeConfig.chain if available, otherwise from assetId.
313
+ */
314
+ createWithdrawalIdentifier(args: {
315
+ withdrawalParams: WithdrawalParams;
316
+ index: number;
317
+ tx: NearTxInfo;
318
+ }): WithdrawalIdentifier;
319
+ /**
320
+ * One-shot status check for a withdrawal.
321
+ * Returns the current status without polling.
322
+ */
323
+ describeWithdrawal(args: WithdrawalIdentifier & {
324
+ logger?: ILogger;
325
+ }): Promise<WithdrawalStatus>;
326
+ }
327
+ interface WithdrawalIdentifier {
328
+ /** Actual chain where funds arrive; Near for virtual/internal routes */
329
+ landingChain: Chain;
330
+ /** Per-bridge withdrawal sequence number */
331
+ index: number;
332
+ withdrawalParams: WithdrawalParams;
333
+ tx: NearTxInfo;
334
+ }
335
+ /**
336
+ * Represents the current state of a withdrawal as returned by bridge adapters.
337
+ *
338
+ * Error handling follows AWS SDK "describe" API patterns:
339
+ * - **Thrown errors**: Infrastructure failures (network, auth, service unavailable).
340
+ * Meaning: "I couldn't check the status."
341
+ * - **`failed` status**: Job-level failure reported by the bridge.
342
+ * Meaning: "I checked, and the withdrawal failed."
343
+ *
344
+ * @see https://docs.aws.amazon.com/AmazonS3/latest/userguide/batch-ops-job-status.html
345
+ */
346
+ type WithdrawalStatus = {
347
+ status: "pending";
348
+ } | {
349
+ status: "completed";
350
+ txHash: string | null;
351
+ } | {
352
+ status: "failed";
353
+ reason: string;
354
+ };
355
+ type ParsedAssetInfo = ({
356
+ blockchain: Chain;
357
+ bridgeName: BridgeNameEnumValues;
358
+ standard: "nep141";
359
+ contractId: string;
360
+ } | {
361
+ blockchain: Chain;
362
+ bridgeName: BridgeNameEnumValues;
363
+ standard: "nep245";
364
+ contractId: string;
365
+ tokenId: string;
366
+ }) & ({
367
+ native: true;
368
+ } | {
369
+ address: string;
370
+ });
371
+ type RPCEndpointMap = Record<typeof Chains.Near | HotBridgeEVMChain, string[]> & { [K in typeof Chains.Stellar]: {
372
+ soroban: string[];
373
+ horizon: string[];
374
+ } };
375
+ type DeepPartial<T> = T extends object ? T extends Array<infer U> ? Array<DeepPartial<U>> : T extends Function ? T : { [P in keyof T]?: DeepPartial<T[P]> } : T;
376
+ type PartialRPCEndpointMap = DeepPartial<RPCEndpointMap>;
377
+ //#endregion
378
+ export { BatchWithdrawalResult, Bridge, CreateWithdrawalCompletionPromisesParams, FeeEstimation, HotBridgeRouteConfig, IIntentsSDK, IntentPublishResult, IntentSettlementStatus, InternalTransferRouteConfig, NearTxInfo, NearWithdrawalRouteConfig, OmniBridgeRouteConfig, ParsedAssetInfo, PartialRPCEndpointMap, PoaBridgeRouteConfig, ProcessWithdrawalArgs, QuoteOptions, RouteConfig, SignAndSendArgs, SignAndSendWithdrawalArgs, SignedIntentsComposition, TxInfo, TxNoInfo, VirtualChainRouteConfig, WithdrawalIdentifier, WithdrawalParams, WithdrawalResult };
package/package.json ADDED
@@ -0,0 +1,62 @@
1
+ {
2
+ "name": "lampamazaza-new-intents-sdk",
3
+ "version": "0.47.1",
4
+ "private": false,
5
+ "type": "module",
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "git+https://github.com/defuse-protocol/sdk-monorepo.git",
9
+ "directory": "packages/intents-sdk"
10
+ },
11
+ "bugs": {
12
+ "url": "https://github.com/defuse-protocol/sdk-monorepo/issues"
13
+ },
14
+ "homepage": "https://github.com/defuse-protocol/sdk-monorepo/tree/main/packages/intents-sdk#readme",
15
+ "sideEffects": false,
16
+ "main": "./dist/index.cjs",
17
+ "module": "./dist/index.js",
18
+ "types": "./dist/index.d.ts",
19
+ "exports": {
20
+ ".": {
21
+ "types": "./dist/index.d.ts",
22
+ "import": "./dist/index.js",
23
+ "require": "./dist/index.cjs",
24
+ "default": "./dist/index.js"
25
+ }
26
+ },
27
+ "files": [
28
+ "dist"
29
+ ],
30
+ "peerDependencies": {
31
+ "typescript": "^5"
32
+ },
33
+ "dependencies": {
34
+ "@hot-labs/omni-sdk": "2.24.7",
35
+ "@isaacs/ttlcache": "^1.0.0",
36
+ "@lifeomic/attempt": "^3.0.0",
37
+ "@omni-bridge/core": "0.2.3",
38
+ "@omni-bridge/near": "0.2.3",
39
+ "@noble/hashes": "^1.7.1",
40
+ "@scure/base": "^1.0.0",
41
+ "@solana/web3.js": "^1.0.0",
42
+ "borsher": "^4.0.0",
43
+ "lru-cache": "^11",
44
+ "near-api-js": "^4.0.0 || ^5.0.0",
45
+ "ripple-address-codec": "^5.0.0",
46
+ "valibot": "^1.0.0",
47
+ "viem": "^2.0.0",
48
+ "lampamazaza-new-contract-types": "0.6.0",
49
+ "lampamazaza-new-internal-utils": "0.24.3"
50
+ },
51
+ "devDependencies": {
52
+ "tsdown": "0.19.0"
53
+ },
54
+ "scripts": {
55
+ "build": "tsdown",
56
+ "dev": "tsdown --watch",
57
+ "lint": "biome check .",
58
+ "lint:fix": "biome check --write .",
59
+ "format": "biome format --write .",
60
+ "typecheck": "npx tsc --noEmit"
61
+ }
62
+ }