@buildonspark/spark-sdk 0.2.7 → 0.2.8

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 (87) hide show
  1. package/CHANGELOG.md +11 -0
  2. package/dist/bare/index.cjs +1657 -1879
  3. package/dist/bare/index.d.cts +65 -115
  4. package/dist/bare/index.d.ts +65 -115
  5. package/dist/bare/index.js +1578 -1807
  6. package/dist/{chunk-GIDAHHDB.js → chunk-6CMNEDBK.js} +217 -9
  7. package/dist/{chunk-J24LM4RO.js → chunk-76SYPHOC.js} +1 -1
  8. package/dist/{chunk-2HD3USKS.js → chunk-A5M55UR3.js} +0 -24
  9. package/dist/{chunk-7LY7PJQL.js → chunk-G2RIVSSI.js} +14 -5
  10. package/dist/{chunk-R5VUHUJR.js → chunk-HMJO7LPI.js} +4160 -3739
  11. package/dist/{client-DmjOifnt.d.ts → client-B5vlztPA.d.ts} +1 -1
  12. package/dist/{client-BmnZ1xDg.d.cts → client-TLqKGhj8.d.cts} +1 -1
  13. package/dist/debug.cjs +1664 -1945
  14. package/dist/debug.d.cts +12 -7
  15. package/dist/debug.d.ts +12 -7
  16. package/dist/debug.js +6 -8
  17. package/dist/graphql/objects/index.d.cts +3 -3
  18. package/dist/graphql/objects/index.d.ts +3 -3
  19. package/dist/index.cjs +1703 -1926
  20. package/dist/index.d.cts +18 -6
  21. package/dist/index.d.ts +18 -6
  22. package/dist/index.js +17 -8
  23. package/dist/index.node.cjs +1703 -1926
  24. package/dist/index.node.d.cts +7 -6
  25. package/dist/index.node.d.ts +7 -6
  26. package/dist/index.node.js +22 -6
  27. package/dist/native/index.cjs +1697 -1927
  28. package/dist/native/index.d.cts +78 -123
  29. package/dist/native/index.d.ts +78 -123
  30. package/dist/native/index.js +1626 -1862
  31. package/dist/proto/spark.cjs +0 -24
  32. package/dist/proto/spark.d.cts +1 -1
  33. package/dist/proto/spark.d.ts +1 -1
  34. package/dist/proto/spark.js +1 -1
  35. package/dist/proto/spark_token.cjs +221 -8
  36. package/dist/proto/spark_token.d.cts +25 -2
  37. package/dist/proto/spark_token.d.ts +25 -2
  38. package/dist/proto/spark_token.js +12 -2
  39. package/dist/{spark-B305mDNB.d.cts → spark-CBBjw5AY.d.cts} +2 -30
  40. package/dist/{spark-B305mDNB.d.ts → spark-CBBjw5AY.d.ts} +2 -30
  41. package/dist/{spark-wallet-BdwARy70.d.cts → spark-wallet-CIuHgbSR.d.cts} +38 -29
  42. package/dist/{spark-wallet-enp968Uc.d.ts → spark-wallet-CrNWPa9p.d.ts} +38 -29
  43. package/dist/{spark-wallet.node-CtpJlYBs.d.cts → spark-wallet.node-BvfiSwh_.d.cts} +1 -1
  44. package/dist/{spark-wallet.node-DqWcsNb6.d.ts → spark-wallet.node-pnKSb-aa.d.ts} +1 -1
  45. package/dist/tests/test-utils.cjs +483 -1120
  46. package/dist/tests/test-utils.d.cts +8 -4
  47. package/dist/tests/test-utils.d.ts +8 -4
  48. package/dist/tests/test-utils.js +5 -6
  49. package/dist/{token-transactions-3-pVToE0.d.cts → token-transactions-ChvD_wLe.d.cts} +15 -10
  50. package/dist/{token-transactions-84Hp0hGz.d.ts → token-transactions-e8UUOjFk.d.ts} +15 -10
  51. package/dist/types/index.cjs +0 -24
  52. package/dist/types/index.d.cts +2 -2
  53. package/dist/types/index.d.ts +2 -2
  54. package/dist/types/index.js +2 -2
  55. package/dist/{xchain-address-BtuJEbzG.d.cts → xchain-address-CDnNobbB.d.ts} +9 -3
  56. package/dist/{xchain-address-Q1BrcwID.d.ts → xchain-address-CtqVOuWz.d.cts} +9 -3
  57. package/package.json +1 -1
  58. package/src/constants.ts +7 -1
  59. package/src/debug.ts +1 -1
  60. package/src/proto/spark.ts +2 -48
  61. package/src/proto/spark_token.ts +255 -7
  62. package/src/services/token-transactions.ts +57 -14
  63. package/src/services/transfer.ts +20 -17
  64. package/src/services/wallet-config.ts +2 -0
  65. package/src/signer/signer.react-native.ts +0 -2
  66. package/src/spark-wallet/spark-wallet.browser.ts +9 -8
  67. package/src/spark-wallet/spark-wallet.node.ts +8 -4
  68. package/src/spark-wallet/spark-wallet.ts +424 -227
  69. package/src/tests/address.test.ts +87 -1
  70. package/src/tests/integration/retry.test.ts +78 -0
  71. package/src/tests/integration/transfer.test.ts +285 -1
  72. package/src/tests/integration/wallet.test.ts +160 -0
  73. package/src/tests/{tokens.test.ts → token-hashing.test.ts} +150 -162
  74. package/src/tests/token-outputs.test.ts +194 -0
  75. package/src/tests/utils/spark-testing-wallet.ts +16 -8
  76. package/src/utils/address.ts +152 -11
  77. package/src/utils/invoice-hashing.test.ts +235 -0
  78. package/src/utils/invoice-hashing.ts +227 -0
  79. package/src/utils/mempool.ts +6 -0
  80. package/src/utils/retry.ts +116 -0
  81. package/src/utils/token-hashing.ts +566 -0
  82. package/src/utils/token-transactions.ts +9 -5
  83. package/dist/chunk-7N6R7G3E.js +0 -7
  84. package/dist/spark-wallet.browser-BYlprQpX.d.ts +0 -12
  85. package/dist/spark-wallet.browser-CVI2Ss3u.d.cts +0 -12
  86. package/src/services/tree-creation.ts +0 -893
  87. package/src/tests/integration/tree-creation.test.ts +0 -46
@@ -6,15 +6,19 @@ import {
6
6
  Bech32mTokenIdentifier,
7
7
  decodeBech32mTokenIdentifier,
8
8
  } from "./token-identifier.js";
9
- import { NetworkType } from "./network.js";
10
9
 
11
10
  export function sumAvailableTokens(
12
11
  outputs: OutputWithPreviousTransactionData[],
13
12
  ): bigint {
14
- return outputs.reduce(
15
- (sum, output) => sum + BigInt(bytesToNumberBE(output.output!.tokenAmount!)),
16
- BigInt(0),
17
- );
13
+ try {
14
+ return outputs.reduce(
15
+ (sum, output) =>
16
+ sum + BigInt(bytesToNumberBE(output.output!.tokenAmount!)),
17
+ BigInt(0),
18
+ );
19
+ } catch (error) {
20
+ return 0n;
21
+ }
18
22
  }
19
23
 
20
24
  export function checkIfSelectedOutputsAreAvailable(
@@ -1,7 +0,0 @@
1
- import {
2
- setCrypto
3
- } from "./chunk-R5VUHUJR.js";
4
-
5
- // src/index.ts
6
- var cryptoImpl = typeof window !== "undefined" && window.crypto ? window.crypto : typeof global !== "undefined" && global.crypto ? global.crypto : null;
7
- setCrypto(cryptoImpl);
@@ -1,12 +0,0 @@
1
- import { z as SparkWallet, x as SparkWalletProps } from './spark-wallet-enp968Uc.js';
2
-
3
- declare class SparkWalletBrowser extends SparkWallet {
4
- static initialize({ mnemonicOrSeed, accountNumber, signer, options, }: SparkWalletProps): Promise<{
5
- mnemonic?: string | undefined;
6
- wallet: SparkWalletBrowser;
7
- }>;
8
- protected initializeTracerEnv({ spanProcessors, traceUrls, }: Parameters<SparkWallet["initializeTracerEnv"]>[0]): void;
9
- }
10
- declare function initializeTracerEnvBrowser({ spanProcessors, traceUrls, }: Parameters<SparkWallet["initializeTracerEnv"]>[0]): void;
11
-
12
- export { SparkWalletBrowser as S, initializeTracerEnvBrowser as i };
@@ -1,12 +0,0 @@
1
- import { z as SparkWallet, x as SparkWalletProps } from './spark-wallet-BdwARy70.cjs';
2
-
3
- declare class SparkWalletBrowser extends SparkWallet {
4
- static initialize({ mnemonicOrSeed, accountNumber, signer, options, }: SparkWalletProps): Promise<{
5
- mnemonic?: string | undefined;
6
- wallet: SparkWalletBrowser;
7
- }>;
8
- protected initializeTracerEnv({ spanProcessors, traceUrls, }: Parameters<SparkWallet["initializeTracerEnv"]>[0]): void;
9
- }
10
- declare function initializeTracerEnvBrowser({ spanProcessors, traceUrls, }: Parameters<SparkWallet["initializeTracerEnv"]>[0]): void;
11
-
12
- export { SparkWalletBrowser as S, initializeTracerEnvBrowser as i };