@idosgames/wallet 0.1.5 → 0.1.7
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/bridge-BEEkIeZj.d.cts +70 -0
- package/dist/bridge-BzZmMMxK.d.ts +70 -0
- package/dist/chains-DMjdV7VV.d.cts +120 -0
- package/dist/chains-DMjdV7VV.d.ts +120 -0
- package/dist/chunk-ACZSIOFR.js +1 -0
- package/dist/chunk-NDNNLWPS.js +1 -0
- package/dist/chunk-XFMDEOHO.js +2 -0
- package/dist/chunk-ZL42KPPC.js +1 -0
- package/dist/index.cjs +2 -1
- package/dist/index.d.cts +5 -2
- package/dist/index.d.ts +5 -2
- package/dist/index.js +1 -1
- package/dist/react/index.cjs +2 -1
- package/dist/react/index.d.cts +21 -62
- package/dist/react/index.d.ts +21 -62
- package/dist/react/index.js +1 -1
- package/dist/react/solanaIndex.cjs +2 -0
- package/dist/react/solanaIndex.d.cts +93 -0
- package/dist/react/solanaIndex.d.ts +93 -0
- package/dist/react/solanaIndex.js +1 -0
- package/dist/{bridge-BCxf6AHE.d.cts → withdraw-DTHssYc9.d.ts} +3 -124
- package/dist/{bridge-BCxf6AHE.d.ts → withdraw-DgTjKpSf.d.cts} +3 -124
- package/package.json +9 -7
- package/dist/chunk-YV6AQWSH.js +0 -1
|
@@ -1,61 +1,6 @@
|
|
|
1
1
|
import { PublicClient, WalletClient, Address, Abi, ContractFunctionName, ContractFunctionArgs, Hex } from 'viem';
|
|
2
|
-
import { IDosGamesClient, BlockchainNetworkDefinition, DepositNFTResponse, DepositTokenResponse, WithdrawalSignatureResponse, NFTWithdrawalResponse, TokenWithdrawalResponse
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* Where a multi-step bridge flow stopped. Deposits run approve → deposit-onchain → report;
|
|
6
|
-
* withdrawals run request → withdraw-onchain → confirm. Knowing the stage lets a UI recover
|
|
7
|
-
* correctly (e.g. a failed `withdraw-onchain` after a successful `request` means the asset is
|
|
8
|
-
* already debited — offer `retryWithdrawal`, never a fresh request that would debit twice).
|
|
9
|
-
*/
|
|
10
|
-
type BridgeStage = "approve" | "deposit-onchain" | "report" | "request" | "withdraw-onchain" | "confirm";
|
|
11
|
-
interface BridgeSuccess<T> {
|
|
12
|
-
ok: true;
|
|
13
|
-
/** Hash/signature of the on-chain transaction that moved the asset (EVM hex or Solana base58). */
|
|
14
|
-
onChainTxHash: string;
|
|
15
|
-
/** The core SDK response that finalized the operation server-side. */
|
|
16
|
-
data: T;
|
|
17
|
-
}
|
|
18
|
-
interface BridgeFailure {
|
|
19
|
-
ok: false;
|
|
20
|
-
stage: BridgeStage;
|
|
21
|
-
error: string;
|
|
22
|
-
/**
|
|
23
|
-
* Set when the asset-moving on-chain tx already landed but a later step failed — the caller can
|
|
24
|
-
* finish the flow with this hash (e.g. re-call `confirmWithdrawal`) instead of restarting.
|
|
25
|
-
*/
|
|
26
|
-
onChainTxHash?: string;
|
|
27
|
-
/**
|
|
28
|
-
* Set for a withdrawal whose server-side `request` already succeeded (and already debited the
|
|
29
|
-
* player) but whose on-chain/confirm leg failed. Recover with `client.blockchain.retryWithdrawal`
|
|
30
|
-
* (before ExpiresAt) or `confirmWithdrawal` (if the tx actually landed) — NOT a fresh request.
|
|
31
|
-
*/
|
|
32
|
-
titleTransactionID?: string;
|
|
33
|
-
}
|
|
34
|
-
type BridgeResult<T> = BridgeSuccess<T> | BridgeFailure;
|
|
35
|
-
/** Normalizes a thrown value (viem error, plain Error, or unknown) into a short human string. */
|
|
36
|
-
declare function toErrorMessage(e: unknown): string;
|
|
37
|
-
declare function bridgeFail(stage: BridgeStage, error: string, extra?: {
|
|
38
|
-
onChainTxHash?: string;
|
|
39
|
-
titleTransactionID?: string;
|
|
40
|
-
}): BridgeFailure;
|
|
41
|
-
/**
|
|
42
|
-
* Where a wallet-login flow stopped. `challenge` = fetching the message to sign; `sign` = the
|
|
43
|
-
* wallet signing it (user may reject); `login` = exchanging the signature for a session. Unlike
|
|
44
|
-
* a bridge flow there is no on-chain transaction — this is an off-chain proof of ownership.
|
|
45
|
-
*/
|
|
46
|
-
type WalletLoginStage = "challenge" | "sign" | "login";
|
|
47
|
-
interface WalletLoginSuccess<T> {
|
|
48
|
-
ok: true;
|
|
49
|
-
/** The core SDK result of the successful login (the fresh ClientState). */
|
|
50
|
-
data: T;
|
|
51
|
-
}
|
|
52
|
-
interface WalletLoginFailure {
|
|
53
|
-
ok: false;
|
|
54
|
-
stage: WalletLoginStage;
|
|
55
|
-
error: string;
|
|
56
|
-
}
|
|
57
|
-
type WalletLoginResult<T> = WalletLoginSuccess<T> | WalletLoginFailure;
|
|
58
|
-
declare function walletLoginFail(stage: WalletLoginStage, error: string): WalletLoginFailure;
|
|
2
|
+
import { IDosGamesClient, BlockchainNetworkDefinition, DepositNFTResponse, DepositTokenResponse, WithdrawalSignatureResponse, NFTWithdrawalResponse, TokenWithdrawalResponse } from '@idosgames/core';
|
|
3
|
+
import { b as BridgeResult } from './chains-DMjdV7VV.js';
|
|
59
4
|
|
|
60
5
|
/**
|
|
61
6
|
* The viem clients + signing account the EVM bridge needs. wagmi supplies all three:
|
|
@@ -200,70 +145,4 @@ interface WithdrawNftEvmParams {
|
|
|
200
145
|
/** Full EVM NFT-withdrawal flow: `requestNFTWithdrawal` → `withdrawERC1155` → `confirmWithdrawal`. */
|
|
201
146
|
declare function withdrawNftEvm(params: WithdrawNftEvmParams): Promise<BridgeResult<NFTWithdrawalResponse>>;
|
|
202
147
|
|
|
203
|
-
|
|
204
|
-
* The on-chain half of the Solana bridge, delegated to the title's own program integration.
|
|
205
|
-
*
|
|
206
|
-
* Unlike EVM — where the RewardPool ABI is fully known and viem builds the calls — the Solana
|
|
207
|
-
* RewardPool is a custom program whose instruction/account layout (DepositSpl, withdraw_spl + the
|
|
208
|
-
* ed25519 sig-verify instruction) lives in that program's IDL, NOT in this client SDK. So the
|
|
209
|
-
* bridge asks you to provide these two calls, built with your program's IDL / `@solana/web3.js`
|
|
210
|
-
* (or Anchor) against the connected wallet from `@solana/wallet-adapter-react`. The SDK-side
|
|
211
|
-
* orchestration (request → submit → confirm, deposit → report) is identical to EVM and handled by
|
|
212
|
-
* {@link depositTokenSolana} / {@link withdrawTokenSolana}.
|
|
213
|
-
*/
|
|
214
|
-
interface SolanaProgramAdapter {
|
|
215
|
-
/**
|
|
216
|
-
* Builds and sends the on-chain `DepositSpl` transfer of `amountRaw` base units of `mint` into
|
|
217
|
-
* the platform program pool, embedding the identifiers the backend reads back
|
|
218
|
-
* (`GetDepositSplCallDetailsBySignature` verifies `userID`). Returns the transaction signature.
|
|
219
|
-
*/
|
|
220
|
-
depositSpl(params: {
|
|
221
|
-
mint: string;
|
|
222
|
-
amountRaw: bigint;
|
|
223
|
-
userID: string;
|
|
224
|
-
titleID: string;
|
|
225
|
-
category: string;
|
|
226
|
-
}): Promise<string>;
|
|
227
|
-
/**
|
|
228
|
-
* Builds and sends the on-chain `withdraw_spl` transaction from a server-issued signature
|
|
229
|
-
* payload — including the ed25519 sig-verify instruction at `SigIxIndex` carrying
|
|
230
|
-
* `Ed25519PublicKey`/`Ed25519Message`/`SignatureHex`. Returns the transaction signature.
|
|
231
|
-
*/
|
|
232
|
-
submitWithdrawal(sig: SolanaWithdrawalSignature): Promise<string>;
|
|
233
|
-
}
|
|
234
|
-
|
|
235
|
-
interface DepositTokenSolanaParams {
|
|
236
|
-
client: IDosGamesClient;
|
|
237
|
-
adapter: SolanaProgramAdapter;
|
|
238
|
-
network: BlockchainNetworkDefinition;
|
|
239
|
-
/** SPL mint of the token being deposited. */
|
|
240
|
-
mint: string;
|
|
241
|
-
/** Raw base-unit amount (already scaled by the mint's decimals). */
|
|
242
|
-
amountRaw: bigint;
|
|
243
|
-
titleID: string;
|
|
244
|
-
category?: string;
|
|
245
|
-
}
|
|
246
|
-
/**
|
|
247
|
-
* Full Solana token-deposit flow: your {@link SolanaProgramAdapter.depositSpl} sends the on-chain
|
|
248
|
-
* transfer, then `client.blockchain.depositToken` reports the signature so the backend verifies
|
|
249
|
-
* and credits the in-game balance. Mirrors {@link depositTokenEvm}.
|
|
250
|
-
*/
|
|
251
|
-
declare function depositTokenSolana(params: DepositTokenSolanaParams): Promise<BridgeResult<DepositTokenResponse>>;
|
|
252
|
-
interface WithdrawTokenSolanaParams {
|
|
253
|
-
client: IDosGamesClient;
|
|
254
|
-
adapter: SolanaProgramAdapter;
|
|
255
|
-
currencyID: string;
|
|
256
|
-
networkID: string;
|
|
257
|
-
walletAddress: string;
|
|
258
|
-
amount: string;
|
|
259
|
-
category?: string;
|
|
260
|
-
}
|
|
261
|
-
/**
|
|
262
|
-
* Full Solana token-withdrawal flow: `requestTokenWithdrawal` → your
|
|
263
|
-
* {@link SolanaProgramAdapter.submitWithdrawal} sends the `withdraw_spl` tx → `confirmWithdrawal`.
|
|
264
|
-
* Same recovery semantics as EVM: a post-request failure carries `titleTransactionID` (already
|
|
265
|
-
* debited — retry, don't re-request). Mirrors {@link withdrawTokenEvm}.
|
|
266
|
-
*/
|
|
267
|
-
declare function withdrawTokenSolana(params: WithdrawTokenSolanaParams): Promise<BridgeResult<TokenWithdrawalResponse>>;
|
|
268
|
-
|
|
269
|
-
export { writeAndWait as A, type BridgeFailure as B, type DepositNft721EvmParams as D, type EvmBridgeClients as E, type SolanaProgramAdapter as S, type WalletLoginResult as W, type BridgeResult as a, type BridgeStage as b, type BridgeSuccess as c, type DepositNftEvmParams as d, type DepositTokenEvmParams as e, type DepositTokenSolanaParams as f, type WalletLoginFailure as g, type WalletLoginStage as h, type WalletLoginSuccess as i, type WithdrawNftEvmParams as j, type WithdrawTokenEvmParams as k, type WithdrawTokenSolanaParams as l, bridgeFail as m, depositNftEvm as n, depositNftEvm721 as o, depositTokenEvm as p, depositTokenSolana as q, ensureErc20Allowance as r, submitEvmNftWithdrawal as s, submitEvmNftWithdrawal721 as t, submitEvmTokenWithdrawal as u, toErrorMessage as v, walletLoginFail as w, withdrawNftEvm as x, withdrawTokenEvm as y, withdrawTokenSolana as z };
|
|
148
|
+
export { type DepositNft721EvmParams as D, type EvmBridgeClients as E, type WithdrawNftEvmParams as W, type DepositNftEvmParams as a, type DepositTokenEvmParams as b, type WithdrawTokenEvmParams as c, depositNftEvm as d, depositNftEvm721 as e, depositTokenEvm as f, ensureErc20Allowance as g, submitEvmNftWithdrawal721 as h, submitEvmTokenWithdrawal as i, withdrawTokenEvm as j, writeAndWait as k, submitEvmNftWithdrawal as s, withdrawNftEvm as w };
|
|
@@ -1,61 +1,6 @@
|
|
|
1
1
|
import { PublicClient, WalletClient, Address, Abi, ContractFunctionName, ContractFunctionArgs, Hex } from 'viem';
|
|
2
|
-
import { IDosGamesClient, BlockchainNetworkDefinition, DepositNFTResponse, DepositTokenResponse, WithdrawalSignatureResponse, NFTWithdrawalResponse, TokenWithdrawalResponse
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* Where a multi-step bridge flow stopped. Deposits run approve → deposit-onchain → report;
|
|
6
|
-
* withdrawals run request → withdraw-onchain → confirm. Knowing the stage lets a UI recover
|
|
7
|
-
* correctly (e.g. a failed `withdraw-onchain` after a successful `request` means the asset is
|
|
8
|
-
* already debited — offer `retryWithdrawal`, never a fresh request that would debit twice).
|
|
9
|
-
*/
|
|
10
|
-
type BridgeStage = "approve" | "deposit-onchain" | "report" | "request" | "withdraw-onchain" | "confirm";
|
|
11
|
-
interface BridgeSuccess<T> {
|
|
12
|
-
ok: true;
|
|
13
|
-
/** Hash/signature of the on-chain transaction that moved the asset (EVM hex or Solana base58). */
|
|
14
|
-
onChainTxHash: string;
|
|
15
|
-
/** The core SDK response that finalized the operation server-side. */
|
|
16
|
-
data: T;
|
|
17
|
-
}
|
|
18
|
-
interface BridgeFailure {
|
|
19
|
-
ok: false;
|
|
20
|
-
stage: BridgeStage;
|
|
21
|
-
error: string;
|
|
22
|
-
/**
|
|
23
|
-
* Set when the asset-moving on-chain tx already landed but a later step failed — the caller can
|
|
24
|
-
* finish the flow with this hash (e.g. re-call `confirmWithdrawal`) instead of restarting.
|
|
25
|
-
*/
|
|
26
|
-
onChainTxHash?: string;
|
|
27
|
-
/**
|
|
28
|
-
* Set for a withdrawal whose server-side `request` already succeeded (and already debited the
|
|
29
|
-
* player) but whose on-chain/confirm leg failed. Recover with `client.blockchain.retryWithdrawal`
|
|
30
|
-
* (before ExpiresAt) or `confirmWithdrawal` (if the tx actually landed) — NOT a fresh request.
|
|
31
|
-
*/
|
|
32
|
-
titleTransactionID?: string;
|
|
33
|
-
}
|
|
34
|
-
type BridgeResult<T> = BridgeSuccess<T> | BridgeFailure;
|
|
35
|
-
/** Normalizes a thrown value (viem error, plain Error, or unknown) into a short human string. */
|
|
36
|
-
declare function toErrorMessage(e: unknown): string;
|
|
37
|
-
declare function bridgeFail(stage: BridgeStage, error: string, extra?: {
|
|
38
|
-
onChainTxHash?: string;
|
|
39
|
-
titleTransactionID?: string;
|
|
40
|
-
}): BridgeFailure;
|
|
41
|
-
/**
|
|
42
|
-
* Where a wallet-login flow stopped. `challenge` = fetching the message to sign; `sign` = the
|
|
43
|
-
* wallet signing it (user may reject); `login` = exchanging the signature for a session. Unlike
|
|
44
|
-
* a bridge flow there is no on-chain transaction — this is an off-chain proof of ownership.
|
|
45
|
-
*/
|
|
46
|
-
type WalletLoginStage = "challenge" | "sign" | "login";
|
|
47
|
-
interface WalletLoginSuccess<T> {
|
|
48
|
-
ok: true;
|
|
49
|
-
/** The core SDK result of the successful login (the fresh ClientState). */
|
|
50
|
-
data: T;
|
|
51
|
-
}
|
|
52
|
-
interface WalletLoginFailure {
|
|
53
|
-
ok: false;
|
|
54
|
-
stage: WalletLoginStage;
|
|
55
|
-
error: string;
|
|
56
|
-
}
|
|
57
|
-
type WalletLoginResult<T> = WalletLoginSuccess<T> | WalletLoginFailure;
|
|
58
|
-
declare function walletLoginFail(stage: WalletLoginStage, error: string): WalletLoginFailure;
|
|
2
|
+
import { IDosGamesClient, BlockchainNetworkDefinition, DepositNFTResponse, DepositTokenResponse, WithdrawalSignatureResponse, NFTWithdrawalResponse, TokenWithdrawalResponse } from '@idosgames/core';
|
|
3
|
+
import { b as BridgeResult } from './chains-DMjdV7VV.cjs';
|
|
59
4
|
|
|
60
5
|
/**
|
|
61
6
|
* The viem clients + signing account the EVM bridge needs. wagmi supplies all three:
|
|
@@ -200,70 +145,4 @@ interface WithdrawNftEvmParams {
|
|
|
200
145
|
/** Full EVM NFT-withdrawal flow: `requestNFTWithdrawal` → `withdrawERC1155` → `confirmWithdrawal`. */
|
|
201
146
|
declare function withdrawNftEvm(params: WithdrawNftEvmParams): Promise<BridgeResult<NFTWithdrawalResponse>>;
|
|
202
147
|
|
|
203
|
-
|
|
204
|
-
* The on-chain half of the Solana bridge, delegated to the title's own program integration.
|
|
205
|
-
*
|
|
206
|
-
* Unlike EVM — where the RewardPool ABI is fully known and viem builds the calls — the Solana
|
|
207
|
-
* RewardPool is a custom program whose instruction/account layout (DepositSpl, withdraw_spl + the
|
|
208
|
-
* ed25519 sig-verify instruction) lives in that program's IDL, NOT in this client SDK. So the
|
|
209
|
-
* bridge asks you to provide these two calls, built with your program's IDL / `@solana/web3.js`
|
|
210
|
-
* (or Anchor) against the connected wallet from `@solana/wallet-adapter-react`. The SDK-side
|
|
211
|
-
* orchestration (request → submit → confirm, deposit → report) is identical to EVM and handled by
|
|
212
|
-
* {@link depositTokenSolana} / {@link withdrawTokenSolana}.
|
|
213
|
-
*/
|
|
214
|
-
interface SolanaProgramAdapter {
|
|
215
|
-
/**
|
|
216
|
-
* Builds and sends the on-chain `DepositSpl` transfer of `amountRaw` base units of `mint` into
|
|
217
|
-
* the platform program pool, embedding the identifiers the backend reads back
|
|
218
|
-
* (`GetDepositSplCallDetailsBySignature` verifies `userID`). Returns the transaction signature.
|
|
219
|
-
*/
|
|
220
|
-
depositSpl(params: {
|
|
221
|
-
mint: string;
|
|
222
|
-
amountRaw: bigint;
|
|
223
|
-
userID: string;
|
|
224
|
-
titleID: string;
|
|
225
|
-
category: string;
|
|
226
|
-
}): Promise<string>;
|
|
227
|
-
/**
|
|
228
|
-
* Builds and sends the on-chain `withdraw_spl` transaction from a server-issued signature
|
|
229
|
-
* payload — including the ed25519 sig-verify instruction at `SigIxIndex` carrying
|
|
230
|
-
* `Ed25519PublicKey`/`Ed25519Message`/`SignatureHex`. Returns the transaction signature.
|
|
231
|
-
*/
|
|
232
|
-
submitWithdrawal(sig: SolanaWithdrawalSignature): Promise<string>;
|
|
233
|
-
}
|
|
234
|
-
|
|
235
|
-
interface DepositTokenSolanaParams {
|
|
236
|
-
client: IDosGamesClient;
|
|
237
|
-
adapter: SolanaProgramAdapter;
|
|
238
|
-
network: BlockchainNetworkDefinition;
|
|
239
|
-
/** SPL mint of the token being deposited. */
|
|
240
|
-
mint: string;
|
|
241
|
-
/** Raw base-unit amount (already scaled by the mint's decimals). */
|
|
242
|
-
amountRaw: bigint;
|
|
243
|
-
titleID: string;
|
|
244
|
-
category?: string;
|
|
245
|
-
}
|
|
246
|
-
/**
|
|
247
|
-
* Full Solana token-deposit flow: your {@link SolanaProgramAdapter.depositSpl} sends the on-chain
|
|
248
|
-
* transfer, then `client.blockchain.depositToken` reports the signature so the backend verifies
|
|
249
|
-
* and credits the in-game balance. Mirrors {@link depositTokenEvm}.
|
|
250
|
-
*/
|
|
251
|
-
declare function depositTokenSolana(params: DepositTokenSolanaParams): Promise<BridgeResult<DepositTokenResponse>>;
|
|
252
|
-
interface WithdrawTokenSolanaParams {
|
|
253
|
-
client: IDosGamesClient;
|
|
254
|
-
adapter: SolanaProgramAdapter;
|
|
255
|
-
currencyID: string;
|
|
256
|
-
networkID: string;
|
|
257
|
-
walletAddress: string;
|
|
258
|
-
amount: string;
|
|
259
|
-
category?: string;
|
|
260
|
-
}
|
|
261
|
-
/**
|
|
262
|
-
* Full Solana token-withdrawal flow: `requestTokenWithdrawal` → your
|
|
263
|
-
* {@link SolanaProgramAdapter.submitWithdrawal} sends the `withdraw_spl` tx → `confirmWithdrawal`.
|
|
264
|
-
* Same recovery semantics as EVM: a post-request failure carries `titleTransactionID` (already
|
|
265
|
-
* debited — retry, don't re-request). Mirrors {@link withdrawTokenEvm}.
|
|
266
|
-
*/
|
|
267
|
-
declare function withdrawTokenSolana(params: WithdrawTokenSolanaParams): Promise<BridgeResult<TokenWithdrawalResponse>>;
|
|
268
|
-
|
|
269
|
-
export { writeAndWait as A, type BridgeFailure as B, type DepositNft721EvmParams as D, type EvmBridgeClients as E, type SolanaProgramAdapter as S, type WalletLoginResult as W, type BridgeResult as a, type BridgeStage as b, type BridgeSuccess as c, type DepositNftEvmParams as d, type DepositTokenEvmParams as e, type DepositTokenSolanaParams as f, type WalletLoginFailure as g, type WalletLoginStage as h, type WalletLoginSuccess as i, type WithdrawNftEvmParams as j, type WithdrawTokenEvmParams as k, type WithdrawTokenSolanaParams as l, bridgeFail as m, depositNftEvm as n, depositNftEvm721 as o, depositTokenEvm as p, depositTokenSolana as q, ensureErc20Allowance as r, submitEvmNftWithdrawal as s, submitEvmNftWithdrawal721 as t, submitEvmTokenWithdrawal as u, toErrorMessage as v, walletLoginFail as w, withdrawNftEvm as x, withdrawTokenEvm as y, withdrawTokenSolana as z };
|
|
148
|
+
export { type DepositNft721EvmParams as D, type EvmBridgeClients as E, type WithdrawNftEvmParams as W, type DepositNftEvmParams as a, type DepositTokenEvmParams as b, type WithdrawTokenEvmParams as c, depositNftEvm as d, depositNftEvm721 as e, depositTokenEvm as f, ensureErc20Allowance as g, submitEvmNftWithdrawal721 as h, submitEvmTokenWithdrawal as i, withdrawTokenEvm as j, writeAndWait as k, submitEvmNftWithdrawal as s, withdrawNftEvm as w };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@idosgames/wallet",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.7",
|
|
4
4
|
"description": "Wallet-bridge companion to @idosgames/core: connect browser & mobile wallets (EVM via wagmi/viem/WalletConnect, Solana via wallet-adapter) and move tokens/NFTs in and out of the game through client.blockchain.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -42,6 +42,11 @@
|
|
|
42
42
|
"types": "./dist/react/index.d.ts",
|
|
43
43
|
"import": "./dist/react/index.js",
|
|
44
44
|
"require": "./dist/react/index.cjs"
|
|
45
|
+
},
|
|
46
|
+
"./react/solana": {
|
|
47
|
+
"types": "./dist/react/solanaIndex.d.ts",
|
|
48
|
+
"import": "./dist/react/solanaIndex.js",
|
|
49
|
+
"require": "./dist/react/solanaIndex.cjs"
|
|
45
50
|
}
|
|
46
51
|
},
|
|
47
52
|
"files": [
|
|
@@ -56,13 +61,13 @@
|
|
|
56
61
|
"//": "@idosgames/core не '*': опубликованный пакет обязан назвать диапазон, иначе установка wallet притянет любую версию core, включая будущую ломающую. На 0.x '^' даёт >=0.1.0 <0.2.0 — ровно ту зону, где core обещает совместимость (см. RELEASING.md). Поднимать при мажорном/минорном бампе core.",
|
|
57
62
|
"dependencies": {
|
|
58
63
|
"@idosgames/core": "^0.1.1",
|
|
59
|
-
"@
|
|
60
|
-
"@
|
|
64
|
+
"@reown/appkit": "^1.8.23",
|
|
65
|
+
"@reown/appkit-adapter-solana": "^1.8.23",
|
|
66
|
+
"@reown/appkit-adapter-wagmi": "^1.8.23",
|
|
61
67
|
"viem": "^2.55.2"
|
|
62
68
|
},
|
|
63
69
|
"peerDependencies": {
|
|
64
70
|
"@solana/wallet-adapter-base": "^0.9.27",
|
|
65
|
-
"@solana/wallet-adapter-react": "^0.15.39",
|
|
66
71
|
"@tanstack/react-query": "^5.101.2",
|
|
67
72
|
"react": "^18.3.1 || ^19.0.0",
|
|
68
73
|
"wagmi": "^3.0.0"
|
|
@@ -79,9 +84,6 @@
|
|
|
79
84
|
},
|
|
80
85
|
"@solana/wallet-adapter-base": {
|
|
81
86
|
"optional": true
|
|
82
|
-
},
|
|
83
|
-
"@solana/wallet-adapter-react": {
|
|
84
|
-
"optional": true
|
|
85
87
|
}
|
|
86
88
|
},
|
|
87
89
|
"devDependencies": {
|
package/dist/chunk-YV6AQWSH.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import {BaseError,encodeAbiParameters}from'viem';import {normalizeBlockchainCategory}from'@idosgames/core';function g(e){return e instanceof BaseError?e.shortMessage:e instanceof Error?e.message:String(e)}function a(e,t,n){return {ok:false,stage:e,error:t,...n}}function w(e,t){return {ok:false,stage:e,error:t}}var h=[{type:"function",name:"depositERC20",stateMutability:"nonpayable",inputs:[{name:"token",type:"address"},{name:"amount",type:"uint256"},{name:"userID",type:"string"},{name:"titleID",type:"string"},{name:"category",type:"string"}],outputs:[{name:"",type:"bool"}]},{type:"function",name:"withdrawERC20",stateMutability:"nonpayable",inputs:[{name:"token",type:"address"},{name:"to",type:"address"},{name:"amount",type:"uint256"},{name:"burnAmount",type:"uint256"},{name:"nonce",type:"uint256"},{name:"signature",type:"bytes"},{name:"userID",type:"string"},{name:"titleID",type:"string"},{name:"category",type:"string"},{name:"deadline",type:"uint256"}],outputs:[]},{type:"function",name:"withdrawERC1155",stateMutability:"nonpayable",inputs:[{name:"token",type:"address"},{name:"to",type:"address"},{name:"id",type:"uint256"},{name:"amount",type:"uint256"},{name:"nonce",type:"uint256"},{name:"signature",type:"bytes"},{name:"userID",type:"string"},{name:"titleID",type:"string"},{name:"category",type:"string"},{name:"deadline",type:"uint256"}],outputs:[]},{type:"function",name:"withdrawERC721",stateMutability:"nonpayable",inputs:[{name:"token",type:"address"},{name:"to",type:"address"},{name:"tokenId",type:"uint256"},{name:"nonce",type:"uint256"},{name:"signature",type:"bytes"},{name:"userID",type:"string"},{name:"titleID",type:"string"},{name:"category",type:"string"},{name:"deadline",type:"uint256"}],outputs:[]}],D=[{type:"function",name:"withdrawERC1155Mint",stateMutability:"nonpayable",inputs:[{name:"collection",type:"address"},{name:"to",type:"address"},{name:"id",type:"uint256"},{name:"amount",type:"uint256"},{name:"nonce",type:"uint256"},{name:"signature",type:"bytes"},{name:"userID",type:"string"},{name:"titleID",type:"string"},{name:"category",type:"string"},{name:"deadline",type:"uint256"}],outputs:[]},{type:"function",name:"withdrawERC721Mint",stateMutability:"nonpayable",inputs:[{name:"collection",type:"address"},{name:"to",type:"address"},{name:"tokenId",type:"uint256"},{name:"nonce",type:"uint256"},{name:"signature",type:"bytes"},{name:"userID",type:"string"},{name:"titleID",type:"string"},{name:"category",type:"string"},{name:"deadline",type:"uint256"}],outputs:[]}],k=[{type:"function",name:"approve",stateMutability:"nonpayable",inputs:[{name:"spender",type:"address"},{name:"amount",type:"uint256"}],outputs:[{name:"",type:"bool"}]},{type:"function",name:"allowance",stateMutability:"view",inputs:[{name:"owner",type:"address"},{name:"spender",type:"address"}],outputs:[{name:"",type:"uint256"}]},{type:"function",name:"decimals",stateMutability:"view",inputs:[],outputs:[{name:"",type:"uint8"}]},{type:"function",name:"balanceOf",stateMutability:"view",inputs:[{name:"account",type:"address"}],outputs:[{name:"",type:"uint256"}]}],A=[{type:"function",name:"safeTransferFrom",stateMutability:"nonpayable",inputs:[{name:"from",type:"address"},{name:"to",type:"address"},{name:"id",type:"uint256"},{name:"amount",type:"uint256"},{name:"data",type:"bytes"}],outputs:[]},{type:"function",name:"isApprovedForAll",stateMutability:"view",inputs:[{name:"account",type:"address"},{name:"operator",type:"address"}],outputs:[{name:"",type:"bool"}]},{type:"function",name:"setApprovalForAll",stateMutability:"nonpayable",inputs:[{name:"operator",type:"address"},{name:"approved",type:"bool"}],outputs:[]},{type:"function",name:"balanceOf",stateMutability:"view",inputs:[{name:"account",type:"address"},{name:"id",type:"uint256"}],outputs:[{name:"",type:"uint256"}]}],x=[{type:"function",name:"safeTransferFrom",stateMutability:"nonpayable",inputs:[{name:"from",type:"address"},{name:"to",type:"address"},{name:"tokenId",type:"uint256"},{name:"data",type:"bytes"}],outputs:[]}];function b(e,t,n){return encodeAbiParameters([{type:"string"},{type:"string"},{type:"string"}],[e,t,normalizeBlockchainCategory(n)])}async function f(e,t){let{walletClient:n,publicClient:i,account:c}=e,o=await n.writeContract({address:t.address,abi:t.abi,functionName:t.functionName,args:t.args,account:c,chain:n.chain,value:t.value});if((await i.waitForTransactionReceipt({hash:o})).status==="reverted")throw new Error(`On-chain transaction reverted (${o}).`);return o}function I(e){let t=e.RewardPoolAddress;return t||null}async function T(e,t,n,i){return await e.publicClient.readContract({address:t,abi:k,functionName:"allowance",args:[e.account,n]})>=i?null:f(e,{address:t,abi:k,functionName:"approve",args:[n,i]})}async function S(e){let{client:t,clients:n,network:i,tokenAddress:c,amount:o,titleID:p,category:u}=e,r=t.auth.context?.userID;if(!r)return a("approve","Not logged in.");let d=I(i);if(!d)return a("approve","Network has no RewardPoolAddress.");if(o<=0n)return a("approve","Amount must be positive.");try{await T(n,c,d,o);}catch(m){return a("approve",g(m))}let s;try{s=await f(n,{address:d,abi:h,functionName:"depositERC20",args:[c,o,r,p,u??""]});}catch(m){return a("deposit-onchain",g(m))}let l=await t.blockchain.depositToken(i.NetworkID??"",s);return l.ok?{ok:true,onChainTxHash:s,data:l.data}:a("report",l.error,{onChainTxHash:s})}async function R(e){let{client:t,clients:n,network:i,nftContractAddress:c,tokenId:o,amount:p,titleID:u,category:r}=e,d=t.auth.context?.userID;if(!d)return a("deposit-onchain","Not logged in.");let s=I(i);if(!s)return a("deposit-onchain","Network has no RewardPoolAddress.");if(p<=0n)return a("deposit-onchain","Amount must be positive.");let l=b(d,u,r),m;try{m=await f(n,{address:c,abi:A,functionName:"safeTransferFrom",args:[n.account,s,o,p,l]});}catch(E){return a("deposit-onchain",g(E))}let y=await t.blockchain.depositNFT(i.NetworkID??"",m);return y.ok?{ok:true,onChainTxHash:m,data:y.data}:a("report",y.error,{onChainTxHash:m})}async function H(e){let{client:t,clients:n,network:i,nftContractAddress:c,tokenId:o,titleID:p,category:u}=e,r=t.auth.context?.userID;if(!r)return a("deposit-onchain","Not logged in.");let d=I(i);if(!d)return a("deposit-onchain","Network has no RewardPoolAddress.");let s=b(r,p,u),l;try{l=await f(n,{address:c,abi:x,functionName:"safeTransferFrom",args:[n.account,d,o,s]});}catch(y){return a("deposit-onchain",g(y))}let m=await t.blockchain.depositNFT(i.NetworkID??"",l);return m.ok?{ok:true,onChainTxHash:l,data:m.data}:a("report",m.error,{onChainTxHash:l})}async function C(e,t){return f(e,{address:t.ContractAddress,abi:h,functionName:"withdrawERC20",args:[t.TokenAddress,t.WalletAddress,BigInt(t.Amount??"0"),BigInt(t.BurnAmount??"0"),BigInt(t.Nonce??"0"),t.Signature??"0x",t.UserID??"",t.TitleID??"",t.Category??"",BigInt(t.Deadline??"0")]})}async function W(e,t){return f(e,{address:t.ContractAddress,abi:D,functionName:"withdrawERC1155Mint",args:[t.TokenAddress,t.WalletAddress,BigInt(t.TokenId??"0"),BigInt(t.Amount??"0"),BigInt(t.Nonce??"0"),t.Signature??"0x",t.UserID??"",t.TitleID??"",t.Category??"",BigInt(t.Deadline??"0")]})}async function M(e,t){return f(e,{address:t.ContractAddress,abi:D,functionName:"withdrawERC721Mint",args:[t.TokenAddress,t.WalletAddress,BigInt(t.TokenId??"0"),BigInt(t.Nonce??"0"),t.Signature??"0x",t.UserID??"",t.TitleID??"",t.Category??"",BigInt(t.Deadline??"0")]})}async function F(e){let{client:t,clients:n,currencyID:i,networkID:c,walletAddress:o,amount:p,category:u}=e,r=await t.blockchain.requestTokenWithdrawal(i,c,o,p,u);if(!r.ok)return a("request",r.error);let d=r.data.EvmSignature,s=r.data.TitleTransactionID??void 0;if(!d)return a("request","Withdrawal response carried no EVM signature.",{titleTransactionID:s});let l;try{l=await C(n,d);}catch(y){return a("withdraw-onchain",g(y),{titleTransactionID:s})}let m=await v(t,s,l);return m.ok?{ok:true,onChainTxHash:l,data:r.data}:m}async function L(e){let{client:t,clients:n,itemID:i,networkID:c,walletAddress:o,amount:p,category:u}=e,r=await t.blockchain.requestNFTWithdrawal(i,c,o,p,u);if(!r.ok)return a("request",r.error);let d=r.data.EvmSignature,s=r.data.TitleTransactionID??void 0;if(!d)return a("request","Withdrawal response carried no EVM signature.",{titleTransactionID:s});let l;try{l=await W(n,d);}catch(y){return a("withdraw-onchain",g(y),{titleTransactionID:s})}let m=await v(t,s,l);return m.ok?{ok:true,onChainTxHash:l,data:r.data}:m}async function v(e,t,n){if(!t)return a("confirm","Missing TitleTransactionID.",{onChainTxHash:n});let i=await e.blockchain.confirmWithdrawal(t,n);return i.ok?{ok:true,onChainTxHash:n,data:i.data}:a("confirm",i.error,{onChainTxHash:n,titleTransactionID:t})}async function G(e){let{client:t,clients:n,networkID:i}=e,c=e.walletAddress??n.account,o=await t.auth.requestWalletChallenge(c,i);if(!o.ok)return w("challenge",o.error);let p;try{p=await n.walletClient.signMessage({account:n.account,message:o.data.Message});}catch(r){return w("sign",g(r))}let u=await t.auth.loginWithWallet(c,i,p);return u.ok?{ok:true,data:u.data}:w("login",u.error)}async function U(e){let{client:t,adapter:n,network:i,mint:c,amountRaw:o,titleID:p,category:u}=e,r=t.auth.context?.userID;if(!r)return a("deposit-onchain","Not logged in.");if(o<=0n)return a("deposit-onchain","Amount must be positive.");let d;try{d=await n.depositSpl({mint:c,amountRaw:o,userID:r,titleID:p,category:normalizeBlockchainCategory(u)});}catch(l){return a("deposit-onchain",g(l))}let s=await t.blockchain.depositToken(i.NetworkID??"",d);return s.ok?{ok:true,onChainTxHash:d,data:s.data}:a("report",s.error,{onChainTxHash:d})}async function O(e){let{client:t,adapter:n,currencyID:i,networkID:c,walletAddress:o,amount:p,category:u}=e,r=await t.blockchain.requestTokenWithdrawal(i,c,o,p,u);if(!r.ok)return a("request",r.error);let d=r.data.SolanaSignature,s=r.data.TitleTransactionID??void 0;if(!d)return a("request","Withdrawal response carried no Solana signature.",{titleTransactionID:s});let l;try{l=await n.submitWithdrawal(d);}catch(y){return a("withdraw-onchain",g(y),{titleTransactionID:s})}if(!s)return a("confirm","Missing TitleTransactionID.",{onChainTxHash:l});let m=await t.blockchain.confirmWithdrawal(s,l);return m.ok?{ok:true,onChainTxHash:l,data:r.data}:a("confirm",m.error,{onChainTxHash:l,titleTransactionID:s})}async function z(e){let{client:t,networkID:n,walletAddress:i,signMessage:c}=e,o=await t.auth.requestWalletChallenge(i,n);if(!o.ok)return w("challenge",o.error);let p;try{let r=await c(new TextEncoder().encode(o.data.Message));p=V(r);}catch(r){return w("sign",g(r))}let u=await t.auth.loginWithWallet(i,n,p);return u.ok?{ok:true,data:u.data}:w("login",u.error)}function V(e){let t="0x";for(let n of e)t+=n.toString(16).padStart(2,"0");return t}export{g as a,a as b,w as c,h as d,k as e,A as f,x as g,b as h,f as i,T as j,S as k,R as l,H as m,C as n,W as o,M as p,F as q,L as r,G as s,U as t,O as u,z as v};
|