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,54 @@
1
+ const require_rolldown_runtime = require('../../../_virtual/rolldown_runtime.cjs');
2
+ let lampamazaza_internal_utils = require("lampamazaza-internal-utils");
3
+
4
+ //#region src/bridges/omni-bridge/error.ts
5
+ var TokenNotFoundInDestinationChainError = class extends lampamazaza_internal_utils.BaseError {
6
+ constructor(token, destinationChain) {
7
+ super(`The token ${token} doesn't exist in destination chain ${destinationChain}`, {
8
+ metaMessages: [`Token: ${token}`, `Destination Chain: ${destinationChain}`],
9
+ name: "TokenNotFoundInDestinationChainError"
10
+ });
11
+ this.token = token;
12
+ this.destinationChain = destinationChain;
13
+ }
14
+ };
15
+ var InvalidFeeValueError = class extends lampamazaza_internal_utils.BaseError {
16
+ constructor(token, value) {
17
+ super(`Invalid fee value`, {
18
+ metaMessages: [`Token: ${token}`, `Fee value: ${value}`],
19
+ name: "InvalidFeeValueError"
20
+ });
21
+ this.token = token;
22
+ }
23
+ };
24
+ var IntentsNearOmniAvailableBalanceTooLowError = class extends lampamazaza_internal_utils.BaseError {
25
+ constructor(balance) {
26
+ super(`Omni storage balance of intents contract is too low to complete this transaction safely.`, {
27
+ metaMessages: [`Balance: ${balance}`],
28
+ name: "IntentsNearOmniAvailableBalanceTooLowError",
29
+ details: `The available Omni storage balance for intents contract is ${balance}, which is too low to complete this transaction safely. The balance needs to be topped up before retrying.`
30
+ });
31
+ this.balance = balance;
32
+ }
33
+ };
34
+ var OmniWithdrawalApiFeeRequestTimeoutError = class extends lampamazaza_internal_utils.BaseError {
35
+ constructor() {
36
+ super("Omni bridge withdrawal fee request timed out.", { name: "OmniWithdrawalApiFeeRequestTimeoutError" });
37
+ }
38
+ };
39
+ var InsufficientUtxoForOmniBridgeWithdrawalError = class extends lampamazaza_internal_utils.BaseError {
40
+ constructor(destinationChain) {
41
+ super("Insufficient utxo for withdrawal to a utxo chain.", {
42
+ metaMessages: [`Destination Chain: ${destinationChain}`],
43
+ name: "InsufficientUtxoForOmniBridgeWithdrawalError"
44
+ });
45
+ this.destinationChain = destinationChain;
46
+ }
47
+ };
48
+
49
+ //#endregion
50
+ exports.InsufficientUtxoForOmniBridgeWithdrawalError = InsufficientUtxoForOmniBridgeWithdrawalError;
51
+ exports.IntentsNearOmniAvailableBalanceTooLowError = IntentsNearOmniAvailableBalanceTooLowError;
52
+ exports.InvalidFeeValueError = InvalidFeeValueError;
53
+ exports.OmniWithdrawalApiFeeRequestTimeoutError = OmniWithdrawalApiFeeRequestTimeoutError;
54
+ exports.TokenNotFoundInDestinationChainError = TokenNotFoundInDestinationChainError;
@@ -0,0 +1,41 @@
1
+ import { Chain } from "../../lib/caip2.cjs";
2
+ import { BaseError } from "lampamazaza-internal-utils";
3
+
4
+ //#region src/bridges/omni-bridge/error.d.ts
5
+ type TokenNotFoundInDestinationChainErrorType = TokenNotFoundInDestinationChainError & {
6
+ name: "TokenNotFoundInDestinationChainError";
7
+ };
8
+ declare class TokenNotFoundInDestinationChainError extends BaseError {
9
+ token: string;
10
+ destinationChain: Chain;
11
+ constructor(token: string, destinationChain: Chain);
12
+ }
13
+ type InvalidFeeValueErrorType = InvalidFeeValueError & {
14
+ name: "InvalidFeeValueError";
15
+ };
16
+ declare class InvalidFeeValueError extends BaseError {
17
+ token: string;
18
+ constructor(token: string, value: unknown);
19
+ }
20
+ type IntentsNearOmniAvailableBalanceTooLowErrorType = IntentsNearOmniAvailableBalanceTooLowError & {
21
+ name: "IntentsNearOmniAvailableBalanceTooLowError";
22
+ };
23
+ declare class IntentsNearOmniAvailableBalanceTooLowError extends BaseError {
24
+ balance: string;
25
+ constructor(balance: string);
26
+ }
27
+ type OmniWithdrawalApiFeeRequestTimeoutErrorType = OmniWithdrawalApiFeeRequestTimeoutError & {
28
+ name: "OmniWithdrawalApiFeeRequestTimeoutError";
29
+ };
30
+ declare class OmniWithdrawalApiFeeRequestTimeoutError extends BaseError {
31
+ constructor();
32
+ }
33
+ type InsufficientUtxoForOmniBridgeWithdrawalErrorType = InsufficientUtxoForOmniBridgeWithdrawalError & {
34
+ name: "InsufficientUtxoForOmniBridgeWithdrawalError";
35
+ };
36
+ declare class InsufficientUtxoForOmniBridgeWithdrawalError extends BaseError {
37
+ destinationChain: Chain;
38
+ constructor(destinationChain: Chain);
39
+ }
40
+ //#endregion
41
+ export { InsufficientUtxoForOmniBridgeWithdrawalError, InsufficientUtxoForOmniBridgeWithdrawalErrorType, IntentsNearOmniAvailableBalanceTooLowError, IntentsNearOmniAvailableBalanceTooLowErrorType, InvalidFeeValueError, InvalidFeeValueErrorType, OmniWithdrawalApiFeeRequestTimeoutError, OmniWithdrawalApiFeeRequestTimeoutErrorType, TokenNotFoundInDestinationChainError, TokenNotFoundInDestinationChainErrorType };
@@ -0,0 +1,41 @@
1
+ import { Chain } from "../../lib/caip2.js";
2
+ import { BaseError } from "lampamazaza-internal-utils";
3
+
4
+ //#region src/bridges/omni-bridge/error.d.ts
5
+ type TokenNotFoundInDestinationChainErrorType = TokenNotFoundInDestinationChainError & {
6
+ name: "TokenNotFoundInDestinationChainError";
7
+ };
8
+ declare class TokenNotFoundInDestinationChainError extends BaseError {
9
+ token: string;
10
+ destinationChain: Chain;
11
+ constructor(token: string, destinationChain: Chain);
12
+ }
13
+ type InvalidFeeValueErrorType = InvalidFeeValueError & {
14
+ name: "InvalidFeeValueError";
15
+ };
16
+ declare class InvalidFeeValueError extends BaseError {
17
+ token: string;
18
+ constructor(token: string, value: unknown);
19
+ }
20
+ type IntentsNearOmniAvailableBalanceTooLowErrorType = IntentsNearOmniAvailableBalanceTooLowError & {
21
+ name: "IntentsNearOmniAvailableBalanceTooLowError";
22
+ };
23
+ declare class IntentsNearOmniAvailableBalanceTooLowError extends BaseError {
24
+ balance: string;
25
+ constructor(balance: string);
26
+ }
27
+ type OmniWithdrawalApiFeeRequestTimeoutErrorType = OmniWithdrawalApiFeeRequestTimeoutError & {
28
+ name: "OmniWithdrawalApiFeeRequestTimeoutError";
29
+ };
30
+ declare class OmniWithdrawalApiFeeRequestTimeoutError extends BaseError {
31
+ constructor();
32
+ }
33
+ type InsufficientUtxoForOmniBridgeWithdrawalErrorType = InsufficientUtxoForOmniBridgeWithdrawalError & {
34
+ name: "InsufficientUtxoForOmniBridgeWithdrawalError";
35
+ };
36
+ declare class InsufficientUtxoForOmniBridgeWithdrawalError extends BaseError {
37
+ destinationChain: Chain;
38
+ constructor(destinationChain: Chain);
39
+ }
40
+ //#endregion
41
+ export { InsufficientUtxoForOmniBridgeWithdrawalError, InsufficientUtxoForOmniBridgeWithdrawalErrorType, IntentsNearOmniAvailableBalanceTooLowError, IntentsNearOmniAvailableBalanceTooLowErrorType, InvalidFeeValueError, InvalidFeeValueErrorType, OmniWithdrawalApiFeeRequestTimeoutError, OmniWithdrawalApiFeeRequestTimeoutErrorType, TokenNotFoundInDestinationChainError, TokenNotFoundInDestinationChainErrorType };
@@ -0,0 +1,49 @@
1
+ import { BaseError } from "lampamazaza-internal-utils";
2
+
3
+ //#region src/bridges/omni-bridge/error.ts
4
+ var TokenNotFoundInDestinationChainError = class extends BaseError {
5
+ constructor(token, destinationChain) {
6
+ super(`The token ${token} doesn't exist in destination chain ${destinationChain}`, {
7
+ metaMessages: [`Token: ${token}`, `Destination Chain: ${destinationChain}`],
8
+ name: "TokenNotFoundInDestinationChainError"
9
+ });
10
+ this.token = token;
11
+ this.destinationChain = destinationChain;
12
+ }
13
+ };
14
+ var InvalidFeeValueError = class extends BaseError {
15
+ constructor(token, value) {
16
+ super(`Invalid fee value`, {
17
+ metaMessages: [`Token: ${token}`, `Fee value: ${value}`],
18
+ name: "InvalidFeeValueError"
19
+ });
20
+ this.token = token;
21
+ }
22
+ };
23
+ var IntentsNearOmniAvailableBalanceTooLowError = class extends BaseError {
24
+ constructor(balance) {
25
+ super(`Omni storage balance of intents contract is too low to complete this transaction safely.`, {
26
+ metaMessages: [`Balance: ${balance}`],
27
+ name: "IntentsNearOmniAvailableBalanceTooLowError",
28
+ details: `The available Omni storage balance for intents contract is ${balance}, which is too low to complete this transaction safely. The balance needs to be topped up before retrying.`
29
+ });
30
+ this.balance = balance;
31
+ }
32
+ };
33
+ var OmniWithdrawalApiFeeRequestTimeoutError = class extends BaseError {
34
+ constructor() {
35
+ super("Omni bridge withdrawal fee request timed out.", { name: "OmniWithdrawalApiFeeRequestTimeoutError" });
36
+ }
37
+ };
38
+ var InsufficientUtxoForOmniBridgeWithdrawalError = class extends BaseError {
39
+ constructor(destinationChain) {
40
+ super("Insufficient utxo for withdrawal to a utxo chain.", {
41
+ metaMessages: [`Destination Chain: ${destinationChain}`],
42
+ name: "InsufficientUtxoForOmniBridgeWithdrawalError"
43
+ });
44
+ this.destinationChain = destinationChain;
45
+ }
46
+ };
47
+
48
+ //#endregion
49
+ export { InsufficientUtxoForOmniBridgeWithdrawalError, IntentsNearOmniAvailableBalanceTooLowError, InvalidFeeValueError, OmniWithdrawalApiFeeRequestTimeoutError, TokenNotFoundInDestinationChainError };
@@ -0,0 +1,12 @@
1
+
2
+ //#region src/bridges/omni-bridge/omni-bridge-constants.ts
3
+ const NEAR_NATIVE_ASSET_ID = "nep141:wrap.near";
4
+ const OMNI_BRIDGE_CONTRACT = "omni.bridge.near";
5
+ const MIN_ALLOWED_STORAGE_BALANCE_FOR_INTENTS_NEAR = 500000000000000000000000n;
6
+ const MIN_GAS_AMOUNT = "37400000000000";
7
+
8
+ //#endregion
9
+ exports.MIN_ALLOWED_STORAGE_BALANCE_FOR_INTENTS_NEAR = MIN_ALLOWED_STORAGE_BALANCE_FOR_INTENTS_NEAR;
10
+ exports.MIN_GAS_AMOUNT = MIN_GAS_AMOUNT;
11
+ exports.NEAR_NATIVE_ASSET_ID = NEAR_NATIVE_ASSET_ID;
12
+ exports.OMNI_BRIDGE_CONTRACT = OMNI_BRIDGE_CONTRACT;
@@ -0,0 +1,8 @@
1
+ //#region src/bridges/omni-bridge/omni-bridge-constants.ts
2
+ const NEAR_NATIVE_ASSET_ID = "nep141:wrap.near";
3
+ const OMNI_BRIDGE_CONTRACT = "omni.bridge.near";
4
+ const MIN_ALLOWED_STORAGE_BALANCE_FOR_INTENTS_NEAR = 500000000000000000000000n;
5
+ const MIN_GAS_AMOUNT = "37400000000000";
6
+
7
+ //#endregion
8
+ export { MIN_ALLOWED_STORAGE_BALANCE_FOR_INTENTS_NEAR, MIN_GAS_AMOUNT, NEAR_NATIVE_ASSET_ID, OMNI_BRIDGE_CONTRACT };
@@ -0,0 +1,153 @@
1
+ const require_rolldown_runtime = require('../../../_virtual/rolldown_runtime.cjs');
2
+ const require_caip2 = require('../../lib/caip2.cjs');
3
+ const require_omni_bridge_constants = require('./omni-bridge-constants.cjs');
4
+ const require_poa_tokens_routable_through_omni_bridge = require('../../constants/poa-tokens-routable-through-omni-bridge.cjs');
5
+ let lampamazaza_internal_utils = require("lampamazaza-internal-utils");
6
+ let valibot = require("valibot");
7
+ valibot = require_rolldown_runtime.__toESM(valibot);
8
+ let _omni_bridge_core = require("@omni-bridge/core");
9
+ let _omni_bridge_near = require("@omni-bridge/near");
10
+
11
+ //#region src/bridges/omni-bridge/omni-bridge-utils.ts
12
+ function createWithdrawIntentsPrimitive(params) {
13
+ const { contractId: tokenAccountId, standard } = lampamazaza_internal_utils.utils.parseDefuseAssetId(params.assetId);
14
+ (0, lampamazaza_internal_utils.assert)(standard === "nep141", "Only NEP-141 is supported");
15
+ const recipient = (0, _omni_bridge_core.omniAddress)(params.omniChainKind, params.destinationAddress);
16
+ let msg = "";
17
+ const ftWithdrawPayload = {
18
+ recipient,
19
+ fee: "0",
20
+ native_token_fee: params.nativeFee.toString()
21
+ };
22
+ if (isUtxoChain(params.omniChainKind)) {
23
+ (0, lampamazaza_internal_utils.assert)(params.utxoMaxGasFee !== null && params.utxoMaxGasFee > 0n, `Invalid utxo max gas fee: expected > 0, got ${params.utxoMaxGasFee}`);
24
+ msg = JSON.stringify({ MaxGasFee: params.utxoMaxGasFee.toString() });
25
+ ftWithdrawPayload.msg = msg;
26
+ }
27
+ const intents = [];
28
+ if (params.nativeFee > 0n) intents.push({
29
+ deposit_for_account_id: (0, _omni_bridge_near.calculateStorageAccountId)({
30
+ token: `near:${tokenAccountId}`,
31
+ amount: params.amount,
32
+ recipient,
33
+ fee: {
34
+ fee: 0n,
35
+ native_fee: params.nativeFee
36
+ },
37
+ sender: `near:${params.intentsContract}`,
38
+ msg
39
+ }),
40
+ amount: params.nativeFee.toString(),
41
+ contract_id: require_omni_bridge_constants.OMNI_BRIDGE_CONTRACT,
42
+ intent: "storage_deposit"
43
+ });
44
+ intents.push({
45
+ intent: "ft_withdraw",
46
+ token: tokenAccountId,
47
+ receiver_id: require_omni_bridge_constants.OMNI_BRIDGE_CONTRACT,
48
+ amount: params.amount.toString(),
49
+ storage_deposit: params.storageDepositAmount > 0n ? params.storageDepositAmount.toString() : void 0,
50
+ msg: JSON.stringify(ftWithdrawPayload),
51
+ min_gas: require_omni_bridge_constants.MIN_GAS_AMOUNT
52
+ });
53
+ return intents;
54
+ }
55
+ /**
56
+ * Mapping between CAIP-2 chain identifiers and Omni Bridge ChainKind.
57
+ * This serves as a single source of truth for bidirectional chain conversions.
58
+ */
59
+ const CHAIN_MAPPINGS = [
60
+ [require_caip2.Chains.Ethereum, _omni_bridge_core.ChainKind.Eth],
61
+ [require_caip2.Chains.Base, _omni_bridge_core.ChainKind.Base],
62
+ [require_caip2.Chains.Arbitrum, _omni_bridge_core.ChainKind.Arb],
63
+ [require_caip2.Chains.Solana, _omni_bridge_core.ChainKind.Sol],
64
+ [require_caip2.Chains.BNB, _omni_bridge_core.ChainKind.Bnb],
65
+ [require_caip2.Chains.Bitcoin, _omni_bridge_core.ChainKind.Btc]
66
+ ];
67
+ function caip2ToChainKind(network) {
68
+ return CHAIN_MAPPINGS.find(([chain]) => chain === network)?.[1] ?? null;
69
+ }
70
+ function chainKindToCaip2(network) {
71
+ return CHAIN_MAPPINGS.find(([_, kind]) => kind === network)?.[0] ?? null;
72
+ }
73
+ const UTXO_CHAINS = [_omni_bridge_core.ChainKind.Btc];
74
+ function isUtxoChain(network) {
75
+ return UTXO_CHAINS.includes(network);
76
+ }
77
+ function poaContractIdToChainKind(contractId) {
78
+ return require_poa_tokens_routable_through_omni_bridge.POA_TOKENS_ROUTABLE_THROUGH_OMNI_BRIDGE[contractId] ?? null;
79
+ }
80
+ function validateOmniToken(nearAddress) {
81
+ if (nearAddress.endsWith(".testnet")) return false;
82
+ return (0, _omni_bridge_core.isBridgeToken)(nearAddress);
83
+ }
84
+ async function getAccountOmniStorageBalance(nearProvider, accountId) {
85
+ return lampamazaza_internal_utils.utils.queryContract({
86
+ contractId: require_omni_bridge_constants.OMNI_BRIDGE_CONTRACT,
87
+ methodName: "storage_balance_of",
88
+ args: { account_id: accountId },
89
+ finality: "optimistic",
90
+ nearClient: nearProvider,
91
+ schema: valibot.union([valibot.null(), valibot.object({
92
+ total: valibot.string(),
93
+ available: valibot.string()
94
+ })])
95
+ });
96
+ }
97
+ const OmniAddressSchema = valibot.custom((input) => typeof input === "string" && (input.startsWith("eth:") || input.startsWith("near:") || input.startsWith("sol:") || input.startsWith("arb:") || input.startsWith("base:") || input.startsWith("btc:") || input.startsWith("bnb:")), "Must comply with omni address schema");
98
+ /**
99
+ * Converts a token address from one chain to its equivalent on another chain.
100
+ * @param nearProvider Near provider used for querying the contract
101
+ * @param tokenAddress The source token address to convert
102
+ * @param destinationChain The target chain for the conversion
103
+ * @returns Promise resolving to the equivalent token address on the destination chain
104
+ * @throws Error if source and destination chains are the same
105
+ *
106
+ * @example
107
+ * // Convert NEAR token to ETH
108
+ * const ethAddress = await getBridgedToken("near:token123", ChainKind.Ethereum)
109
+ */
110
+ async function getBridgedToken(nearProvider, tokenAddress, destinationChain) {
111
+ return lampamazaza_internal_utils.utils.queryContract({
112
+ contractId: require_omni_bridge_constants.OMNI_BRIDGE_CONTRACT,
113
+ methodName: "get_bridged_token",
114
+ args: {
115
+ chain: _omni_bridge_core.ChainKind[destinationChain].toString(),
116
+ address: tokenAddress
117
+ },
118
+ finality: "optimistic",
119
+ nearClient: nearProvider,
120
+ schema: valibot.union([valibot.null(), OmniAddressSchema])
121
+ });
122
+ }
123
+ /**
124
+ * Gets token decimals from the NEAR contract
125
+ * @param nearProvider Near provider used for querying the contract
126
+ * @param tokenAddress The Omni token address to check
127
+ * @returns Promise resolving to the token's decimal information
128
+ */
129
+ async function getTokenDecimals(nearProvider, tokenAddress) {
130
+ if ((0, _omni_bridge_core.getChain)(tokenAddress) === _omni_bridge_core.ChainKind.Near) throw new Error("Token decimals cannot be queried using NEAR addresses. Use the token's foreign chain representation (e.g., eth:0x...) to query decimals.");
131
+ return lampamazaza_internal_utils.utils.queryContract({
132
+ contractId: require_omni_bridge_constants.OMNI_BRIDGE_CONTRACT,
133
+ methodName: "get_token_decimals",
134
+ args: { address: tokenAddress },
135
+ finality: "optimistic",
136
+ nearClient: nearProvider,
137
+ schema: valibot.union([valibot.null(), valibot.object({
138
+ decimals: valibot.number(),
139
+ origin_decimals: valibot.number()
140
+ })])
141
+ });
142
+ }
143
+
144
+ //#endregion
145
+ exports.caip2ToChainKind = caip2ToChainKind;
146
+ exports.chainKindToCaip2 = chainKindToCaip2;
147
+ exports.createWithdrawIntentsPrimitive = createWithdrawIntentsPrimitive;
148
+ exports.getAccountOmniStorageBalance = getAccountOmniStorageBalance;
149
+ exports.getBridgedToken = getBridgedToken;
150
+ exports.getTokenDecimals = getTokenDecimals;
151
+ exports.isUtxoChain = isUtxoChain;
152
+ exports.poaContractIdToChainKind = poaContractIdToChainKind;
153
+ exports.validateOmniToken = validateOmniToken;
@@ -0,0 +1,143 @@
1
+ import { Chains } from "../../lib/caip2.js";
2
+ import { MIN_GAS_AMOUNT, OMNI_BRIDGE_CONTRACT } from "./omni-bridge-constants.js";
3
+ import { POA_TOKENS_ROUTABLE_THROUGH_OMNI_BRIDGE } from "../../constants/poa-tokens-routable-through-omni-bridge.js";
4
+ import { assert, utils } from "lampamazaza-internal-utils";
5
+ import * as v from "valibot";
6
+ import { ChainKind, getChain, isBridgeToken, omniAddress } from "@omni-bridge/core";
7
+ import { calculateStorageAccountId } from "@omni-bridge/near";
8
+
9
+ //#region src/bridges/omni-bridge/omni-bridge-utils.ts
10
+ function createWithdrawIntentsPrimitive(params) {
11
+ const { contractId: tokenAccountId, standard } = utils.parseDefuseAssetId(params.assetId);
12
+ assert(standard === "nep141", "Only NEP-141 is supported");
13
+ const recipient = omniAddress(params.omniChainKind, params.destinationAddress);
14
+ let msg = "";
15
+ const ftWithdrawPayload = {
16
+ recipient,
17
+ fee: "0",
18
+ native_token_fee: params.nativeFee.toString()
19
+ };
20
+ if (isUtxoChain(params.omniChainKind)) {
21
+ assert(params.utxoMaxGasFee !== null && params.utxoMaxGasFee > 0n, `Invalid utxo max gas fee: expected > 0, got ${params.utxoMaxGasFee}`);
22
+ msg = JSON.stringify({ MaxGasFee: params.utxoMaxGasFee.toString() });
23
+ ftWithdrawPayload.msg = msg;
24
+ }
25
+ const intents = [];
26
+ if (params.nativeFee > 0n) intents.push({
27
+ deposit_for_account_id: calculateStorageAccountId({
28
+ token: `near:${tokenAccountId}`,
29
+ amount: params.amount,
30
+ recipient,
31
+ fee: {
32
+ fee: 0n,
33
+ native_fee: params.nativeFee
34
+ },
35
+ sender: `near:${params.intentsContract}`,
36
+ msg
37
+ }),
38
+ amount: params.nativeFee.toString(),
39
+ contract_id: OMNI_BRIDGE_CONTRACT,
40
+ intent: "storage_deposit"
41
+ });
42
+ intents.push({
43
+ intent: "ft_withdraw",
44
+ token: tokenAccountId,
45
+ receiver_id: OMNI_BRIDGE_CONTRACT,
46
+ amount: params.amount.toString(),
47
+ storage_deposit: params.storageDepositAmount > 0n ? params.storageDepositAmount.toString() : void 0,
48
+ msg: JSON.stringify(ftWithdrawPayload),
49
+ min_gas: MIN_GAS_AMOUNT
50
+ });
51
+ return intents;
52
+ }
53
+ /**
54
+ * Mapping between CAIP-2 chain identifiers and Omni Bridge ChainKind.
55
+ * This serves as a single source of truth for bidirectional chain conversions.
56
+ */
57
+ const CHAIN_MAPPINGS = [
58
+ [Chains.Ethereum, ChainKind.Eth],
59
+ [Chains.Base, ChainKind.Base],
60
+ [Chains.Arbitrum, ChainKind.Arb],
61
+ [Chains.Solana, ChainKind.Sol],
62
+ [Chains.BNB, ChainKind.Bnb],
63
+ [Chains.Bitcoin, ChainKind.Btc]
64
+ ];
65
+ function caip2ToChainKind(network) {
66
+ return CHAIN_MAPPINGS.find(([chain]) => chain === network)?.[1] ?? null;
67
+ }
68
+ function chainKindToCaip2(network) {
69
+ return CHAIN_MAPPINGS.find(([_, kind]) => kind === network)?.[0] ?? null;
70
+ }
71
+ const UTXO_CHAINS = [ChainKind.Btc];
72
+ function isUtxoChain(network) {
73
+ return UTXO_CHAINS.includes(network);
74
+ }
75
+ function poaContractIdToChainKind(contractId) {
76
+ return POA_TOKENS_ROUTABLE_THROUGH_OMNI_BRIDGE[contractId] ?? null;
77
+ }
78
+ function validateOmniToken(nearAddress) {
79
+ if (nearAddress.endsWith(".testnet")) return false;
80
+ return isBridgeToken(nearAddress);
81
+ }
82
+ async function getAccountOmniStorageBalance(nearProvider, accountId) {
83
+ return utils.queryContract({
84
+ contractId: OMNI_BRIDGE_CONTRACT,
85
+ methodName: "storage_balance_of",
86
+ args: { account_id: accountId },
87
+ finality: "optimistic",
88
+ nearClient: nearProvider,
89
+ schema: v.union([v.null(), v.object({
90
+ total: v.string(),
91
+ available: v.string()
92
+ })])
93
+ });
94
+ }
95
+ const OmniAddressSchema = v.custom((input) => typeof input === "string" && (input.startsWith("eth:") || input.startsWith("near:") || input.startsWith("sol:") || input.startsWith("arb:") || input.startsWith("base:") || input.startsWith("btc:") || input.startsWith("bnb:")), "Must comply with omni address schema");
96
+ /**
97
+ * Converts a token address from one chain to its equivalent on another chain.
98
+ * @param nearProvider Near provider used for querying the contract
99
+ * @param tokenAddress The source token address to convert
100
+ * @param destinationChain The target chain for the conversion
101
+ * @returns Promise resolving to the equivalent token address on the destination chain
102
+ * @throws Error if source and destination chains are the same
103
+ *
104
+ * @example
105
+ * // Convert NEAR token to ETH
106
+ * const ethAddress = await getBridgedToken("near:token123", ChainKind.Ethereum)
107
+ */
108
+ async function getBridgedToken(nearProvider, tokenAddress, destinationChain) {
109
+ return utils.queryContract({
110
+ contractId: OMNI_BRIDGE_CONTRACT,
111
+ methodName: "get_bridged_token",
112
+ args: {
113
+ chain: ChainKind[destinationChain].toString(),
114
+ address: tokenAddress
115
+ },
116
+ finality: "optimistic",
117
+ nearClient: nearProvider,
118
+ schema: v.union([v.null(), OmniAddressSchema])
119
+ });
120
+ }
121
+ /**
122
+ * Gets token decimals from the NEAR contract
123
+ * @param nearProvider Near provider used for querying the contract
124
+ * @param tokenAddress The Omni token address to check
125
+ * @returns Promise resolving to the token's decimal information
126
+ */
127
+ async function getTokenDecimals(nearProvider, tokenAddress) {
128
+ if (getChain(tokenAddress) === ChainKind.Near) throw new Error("Token decimals cannot be queried using NEAR addresses. Use the token's foreign chain representation (e.g., eth:0x...) to query decimals.");
129
+ return utils.queryContract({
130
+ contractId: OMNI_BRIDGE_CONTRACT,
131
+ methodName: "get_token_decimals",
132
+ args: { address: tokenAddress },
133
+ finality: "optimistic",
134
+ nearClient: nearProvider,
135
+ schema: v.union([v.null(), v.object({
136
+ decimals: v.number(),
137
+ origin_decimals: v.number()
138
+ })])
139
+ });
140
+ }
141
+
142
+ //#endregion
143
+ export { caip2ToChainKind, chainKindToCaip2, createWithdrawIntentsPrimitive, getAccountOmniStorageBalance, getBridgedToken, getTokenDecimals, isUtxoChain, poaContractIdToChainKind, validateOmniToken };