@buildonspark/issuer-sdk 0.1.35 → 0.1.36
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/CHANGELOG.md +8 -0
- package/dist/index.browser.d.ts +2 -1
- package/dist/index.browser.js +102 -92
- package/dist/index.node.cjs +102 -92
- package/dist/index.node.d.cts +2 -1
- package/dist/index.node.d.ts +2 -1
- package/dist/index.node.js +102 -92
- package/dist/native/index.react-native.cjs +102 -92
- package/dist/native/index.react-native.d.cts +2 -1
- package/dist/native/index.react-native.d.ts +2 -1
- package/dist/native/index.react-native.js +102 -92
- package/package.json +9 -6
- package/src/issuer-wallet/issuer-spark-wallet.react-native.ts +0 -1
- package/src/issuer-wallet/issuer-spark-wallet.ts +20 -15
- package/src/issuer-wallet/types.ts +2 -1
- package/src/services/freeze.ts +3 -3
- package/src/services/token-transactions.ts +109 -101
- package/src/tests/integration/multi-token-issuer.test.ts +3 -10
- package/src/tests/integration/test-configs.ts +1 -1
- package/src/tests/integration/token-invoices.test.ts +13 -14
- package/src/tests/integration/token-lifecycle.test.ts +5 -5
- package/src/tests/integration/token-monitoring.test.ts +31 -43
- package/src/tests/integration/token-outputs.test.ts +7 -7
- package/src/tests/integration/token-transfers.test.ts +23 -23
- package/src/tests/stress/transfers.test.ts +10 -8
- package/src/tests/utils/issuer-test-wallet.ts +9 -3
- package/src/utils/token-hashing.ts +2 -2
|
@@ -65,7 +65,7 @@ describe("Stress test for token transfers", () => {
|
|
|
65
65
|
try {
|
|
66
66
|
// Transfer tokens from issuer to user
|
|
67
67
|
await issuerWallet.transferTokens({
|
|
68
|
-
tokenIdentifier: tokenIdentifier
|
|
68
|
+
tokenIdentifier: tokenIdentifier,
|
|
69
69
|
tokenAmount: TOKEN_AMOUNT,
|
|
70
70
|
receiverSparkAddress: userWalletSparkAddress,
|
|
71
71
|
});
|
|
@@ -74,14 +74,14 @@ describe("Stress test for token transfers", () => {
|
|
|
74
74
|
const userBalanceObj = await userWallet.getBalance();
|
|
75
75
|
const userBalance = filterTokenBalanceForTokenIdentifier(
|
|
76
76
|
userBalanceObj?.tokenBalances,
|
|
77
|
-
tokenIdentifier
|
|
77
|
+
tokenIdentifier,
|
|
78
78
|
);
|
|
79
79
|
expect(issuerBalance.balance).toEqual(0n);
|
|
80
80
|
expect(userBalance.ownedBalance).toEqual(TOKEN_AMOUNT);
|
|
81
81
|
|
|
82
82
|
// Transfer tokens from user to issuer
|
|
83
83
|
await userWallet.transferTokens({
|
|
84
|
-
tokenIdentifier: tokenIdentifier
|
|
84
|
+
tokenIdentifier: tokenIdentifier,
|
|
85
85
|
tokenAmount: TOKEN_AMOUNT,
|
|
86
86
|
receiverSparkAddress: issuerWalletSparkAddress,
|
|
87
87
|
});
|
|
@@ -90,19 +90,21 @@ describe("Stress test for token transfers", () => {
|
|
|
90
90
|
const userBalanceAfterTransferBack =
|
|
91
91
|
filterTokenBalanceForTokenIdentifier(
|
|
92
92
|
userBalanceObjAfterTransferBack?.tokenBalances,
|
|
93
|
-
tokenIdentifier
|
|
93
|
+
tokenIdentifier,
|
|
94
94
|
);
|
|
95
95
|
const issuerBalanceAfterTransferBack =
|
|
96
96
|
await issuerWallet.getIssuerTokenBalance();
|
|
97
97
|
expect(userBalanceAfterTransferBack.ownedBalance).toEqual(0n);
|
|
98
98
|
expect(issuerBalanceAfterTransferBack.balance).toEqual(TOKEN_AMOUNT);
|
|
99
|
-
} catch (error:
|
|
99
|
+
} catch (error: unknown) {
|
|
100
100
|
const end_time = Date.now();
|
|
101
101
|
const duration_ms = end_time - start_time;
|
|
102
102
|
const minutes = Math.floor(duration_ms / 60000);
|
|
103
103
|
const seconds = ((duration_ms % 60000) / 1000).toFixed(2);
|
|
104
104
|
throw new Error(
|
|
105
|
-
`Test failed on iteration ${i}: ${
|
|
105
|
+
`Test failed on iteration ${i}: ${String(
|
|
106
|
+
error,
|
|
107
|
+
)} in ${duration_ms}ms (${minutes}m ${seconds}s)`,
|
|
106
108
|
);
|
|
107
109
|
}
|
|
108
110
|
}
|
|
@@ -153,7 +155,7 @@ describe("Stress test for token transfers", () => {
|
|
|
153
155
|
const start_time = Date.now();
|
|
154
156
|
try {
|
|
155
157
|
await issuer.wallet.transferTokens({
|
|
156
|
-
tokenIdentifier: tokenIdentifier
|
|
158
|
+
tokenIdentifier: tokenIdentifier,
|
|
157
159
|
tokenAmount: TOKEN_AMOUNT,
|
|
158
160
|
receiverSparkAddress: userAddress,
|
|
159
161
|
});
|
|
@@ -172,7 +174,7 @@ describe("Stress test for token transfers", () => {
|
|
|
172
174
|
|
|
173
175
|
const errors = results.filter((r: { success: boolean }) => !r.success);
|
|
174
176
|
errors.forEach((e, i) => {
|
|
175
|
-
console.log(`Error ${i}: ${e.error} occurred in ${e.duration}ms`);
|
|
177
|
+
console.log(`Error ${i}: ${String(e.error)} occurred in ${e.duration}ms`);
|
|
176
178
|
});
|
|
177
179
|
|
|
178
180
|
const numSuccessfulTransfers = results.filter(
|
|
@@ -1,8 +1,14 @@
|
|
|
1
1
|
import { IssuerSparkWallet } from "../../issuer-wallet/issuer-spark-wallet.node.js";
|
|
2
2
|
|
|
3
3
|
export class IssuerSparkWalletTesting extends IssuerSparkWallet {
|
|
4
|
-
protected override
|
|
5
|
-
|
|
6
|
-
|
|
4
|
+
protected override setupBackgroundStream(): Promise<void> {
|
|
5
|
+
return new Promise((resolve) => {
|
|
6
|
+
console.log("IssuerSparkWalletTesting.setupBackgroundStream disabled");
|
|
7
|
+
resolve();
|
|
8
|
+
});
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
public syncTokenOutputsForTesting(): Promise<void> {
|
|
12
|
+
return this.syncTokenOutputs();
|
|
7
13
|
}
|
|
8
14
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { sha256 } from "@scure/btc-signer/utils";
|
|
2
|
-
import { FreezeTokensPayload } from "@buildonspark/spark-sdk/proto/spark_token";
|
|
2
|
+
import { type FreezeTokensPayload } from "@buildonspark/spark-sdk/proto/spark_token";
|
|
3
3
|
import { SparkValidationError } from "@buildonspark/spark-sdk";
|
|
4
4
|
|
|
5
5
|
export function hashFreezeTokensPayload(
|
|
@@ -13,7 +13,7 @@ export function hashFreezeTokensPayload(
|
|
|
13
13
|
});
|
|
14
14
|
}
|
|
15
15
|
|
|
16
|
-
|
|
16
|
+
const allHashes: Uint8Array[] = [];
|
|
17
17
|
|
|
18
18
|
// Hash version
|
|
19
19
|
const versionHashObj = sha256.create();
|