@dubsdotapp/expo 0.2.35 → 0.2.37
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/dist/index.js +1 -30
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1 -30
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/errors.ts +0 -13
- package/src/hooks/useClaim.ts +1 -29
package/dist/index.js
CHANGED
|
@@ -151,12 +151,6 @@ var SOLANA_PROGRAM_ERRORS = {
|
|
|
151
151
|
6048: { code: "no_survivors_to_distribute", message: "No survivors to distribute winnings to" },
|
|
152
152
|
6049: { code: "too_many_survivors", message: "Too many survivors (max 50 per batch)" }
|
|
153
153
|
};
|
|
154
|
-
var WALLET_ERROR_PATTERNS = [
|
|
155
|
-
{ pattern: /CancellationException/i, error: { code: "transaction_rejected", message: "Transaction was rejected by the wallet" } },
|
|
156
|
-
{ pattern: /declined/i, error: { code: "user_declined", message: "Transaction was declined" } },
|
|
157
|
-
{ pattern: /timeout/i, error: { code: "transaction_timeout", message: "Transaction timed out" } },
|
|
158
|
-
{ pattern: /not connected/i, error: { code: "wallet_not_connected", message: "Wallet is not connected" } }
|
|
159
|
-
];
|
|
160
154
|
var SOLANA_BUILTIN_ERRORS = {
|
|
161
155
|
0: { code: "generic_error", message: "Generic instruction error" },
|
|
162
156
|
1: { code: "invalid_argument", message: "Invalid argument passed to program" },
|
|
@@ -173,9 +167,6 @@ function parseSolanaError(err) {
|
|
|
173
167
|
if (!err) return { code: "unknown_error", message: "Unknown transaction error" };
|
|
174
168
|
let parsed = err;
|
|
175
169
|
if (typeof parsed === "string") {
|
|
176
|
-
for (const { pattern, error } of WALLET_ERROR_PATTERNS) {
|
|
177
|
-
if (pattern.test(parsed)) return error;
|
|
178
|
-
}
|
|
179
170
|
try {
|
|
180
171
|
const jsonMatch = parsed.match(/\{.*\}/s);
|
|
181
172
|
if (jsonMatch) parsed = JSON.parse(jsonMatch[0]);
|
|
@@ -1888,27 +1879,7 @@ function useClaim() {
|
|
|
1888
1879
|
return result;
|
|
1889
1880
|
} catch (err) {
|
|
1890
1881
|
console.error("[useClaim] FAILED:", err);
|
|
1891
|
-
const
|
|
1892
|
-
const parsed = parseSolanaError(raw);
|
|
1893
|
-
if (parsed.code === "transaction_rejected" || parsed.code === "transaction_failed") {
|
|
1894
|
-
try {
|
|
1895
|
-
const game = await client.getGame(params.gameId);
|
|
1896
|
-
const myBet = game.bettors?.find(
|
|
1897
|
-
(b) => b.wallet === params.playerWallet
|
|
1898
|
-
);
|
|
1899
|
-
if (myBet?.amountClaimed != null && myBet.amountClaimed > 0) {
|
|
1900
|
-
const claimedErr = new Error("Player has already claimed their winnings");
|
|
1901
|
-
claimedErr.code = "already_claimed";
|
|
1902
|
-
setError(claimedErr);
|
|
1903
|
-
setStatus("error");
|
|
1904
|
-
throw claimedErr;
|
|
1905
|
-
}
|
|
1906
|
-
} catch (checkErr) {
|
|
1907
|
-
if (checkErr?.code === "already_claimed") throw checkErr;
|
|
1908
|
-
}
|
|
1909
|
-
}
|
|
1910
|
-
const error2 = new Error(parsed.message);
|
|
1911
|
-
error2.code = parsed.code;
|
|
1882
|
+
const error2 = err instanceof Error ? err : new Error(String(err));
|
|
1912
1883
|
setError(error2);
|
|
1913
1884
|
setStatus("error");
|
|
1914
1885
|
throw error2;
|