@unlink-xyz/sdk 0.3.0-canary.570 → 0.3.0-canary.577
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/README.md +62 -0
- package/dist/admin/index.d.ts +2 -2
- package/dist/admin/index.js +2 -2
- package/dist/advanced/index.d.ts +3 -3
- package/dist/advanced/index.js +6 -6
- package/dist/browser/index.d.ts +2 -2
- package/dist/browser/index.js +3 -3
- package/dist/{chunk-BJTGR3G3.js → chunk-4F4TGNXO.js} +1 -1
- package/dist/{chunk-SVF55JJW.js → chunk-EGGG2NHC.js} +2 -2
- package/dist/{chunk-TFI6P7R7.js → chunk-RS7NZTSS.js} +3 -0
- package/dist/{chunk-3TVXTVOE.js → chunk-VWYQOXOL.js} +1 -1
- package/dist/client/index.d.ts +4 -4
- package/dist/client/index.js +3 -3
- package/dist/{client-core-leKzUC4O.d.ts → client-core-CpPGn72-.d.ts} +1 -1
- package/dist/{environments-BL5ujqbL.d.ts → environments-CfyD59YH.d.ts} +3 -0
- package/dist/react/index.d.ts +74 -0
- package/dist/react/index.js +169 -0
- package/package.json +20 -1
package/README.md
CHANGED
|
@@ -25,6 +25,7 @@ maps to one chain and Engine URL.
|
|
|
25
25
|
|
|
26
26
|
- `base-sepolia-production` - Base Sepolia, available now
|
|
27
27
|
- `ethereum-sepolia-production` - Ethereum Sepolia, available now
|
|
28
|
+
- `arc-testnet-production` - Arc testnet, available now
|
|
28
29
|
- `monad-testnet-production` - Monad testnet, coming soon
|
|
29
30
|
- `base-production` - Base Mainnet, coming soon
|
|
30
31
|
|
|
@@ -66,6 +67,67 @@ await tx.wait();
|
|
|
66
67
|
The user client authenticates with short-lived authorization tokens issued by
|
|
67
68
|
your backend. The admin API key never ships to browser bundles.
|
|
68
69
|
|
|
70
|
+
## React
|
|
71
|
+
|
|
72
|
+
`@unlink-xyz/sdk/react` wraps the browser client in one hook. `react` is an
|
|
73
|
+
optional peer — install it in your app.
|
|
74
|
+
|
|
75
|
+
```tsx
|
|
76
|
+
import { account, createUnlinkClient } from "@unlink-xyz/sdk/browser";
|
|
77
|
+
import { UnlinkProvider, useUnlink } from "@unlink-xyz/sdk/react";
|
|
78
|
+
|
|
79
|
+
const { account: unlinkAccount } = await account.fromMetaMask({
|
|
80
|
+
provider: window.ethereum,
|
|
81
|
+
appId: "your-app-id",
|
|
82
|
+
chainId: 84532,
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
const client = createUnlinkClient({
|
|
86
|
+
environment: "base-sepolia-production",
|
|
87
|
+
account: unlinkAccount,
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
function App() {
|
|
91
|
+
return (
|
|
92
|
+
<UnlinkProvider client={client}>
|
|
93
|
+
<Wallet />
|
|
94
|
+
</UnlinkProvider>
|
|
95
|
+
);
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
function Wallet() {
|
|
99
|
+
const { status, balances, transfer } = useUnlink();
|
|
100
|
+
if (status !== "ready") return <p>Loading…</p>;
|
|
101
|
+
const send = async () => {
|
|
102
|
+
try {
|
|
103
|
+
await transfer({ recipientAddress, token, amount });
|
|
104
|
+
} catch (err) {
|
|
105
|
+
// Actions reject on failure — handle it (toast, retry, …).
|
|
106
|
+
}
|
|
107
|
+
};
|
|
108
|
+
return <button onClick={send}>Send</button>;
|
|
109
|
+
}
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
`UnlinkProvider` takes a ready `client` (above) or a `config` object it builds
|
|
113
|
+
the client from; both are read once on first render. The provider registers the
|
|
114
|
+
user and loads balances on mount, so no explicit `ensureRegistered()` is needed.
|
|
115
|
+
`useUnlink()` returns reactive `status`, `address`, `balances`, `transactions`,
|
|
116
|
+
and `error`, plus `refresh` and the `deposit` / `depositWithApproval` /
|
|
117
|
+
`transfer` / `withdraw` / `execute` actions — each waits for completion, then
|
|
118
|
+
refreshes (pass `TransactionHandleWaitOptions` for an abort signal, status
|
|
119
|
+
callback, or timeout). Reach `client` for anything not surfaced here (execution
|
|
120
|
+
accounts, faucet, approval, polling, or a fire-and-forget handle).
|
|
121
|
+
|
|
122
|
+
Notes:
|
|
123
|
+
|
|
124
|
+
- **Actions reject on failure.** The snapshot `error` reflects the data load
|
|
125
|
+
(`refresh`), not actions — `try`/`catch` your `transfer`/`deposit`/… calls.
|
|
126
|
+
- **Switching account/client.** `client`/`config` are read once; to follow a
|
|
127
|
+
wallet or account switch, remount the provider with a React `key`.
|
|
128
|
+
- **React version.** Runtime peer is `react >=18 <20`; the published types
|
|
129
|
+
typecheck cleanly under both `@types/react@18` and `@types/react@19`.
|
|
130
|
+
|
|
69
131
|
## Backend Routes
|
|
70
132
|
|
|
71
133
|
```ts
|
package/dist/admin/index.d.ts
CHANGED
|
@@ -3,8 +3,8 @@ import { R as RegistrationPayload, a as RegistrationPayloadWire, c as components
|
|
|
3
3
|
export { A as AccountKeys, b as ApiError, C as CapabilityError, d as CapabilityErrorCode, e as CapabilityErrorOptions, T as TimeoutError, U as UnlinkError, V as ValidationError, f as assertRegistrationPayloadWire, g as fromRegistrationPayloadWire, t as toRegistrationPayload, h as toRegistrationPayloadWire } from '../errors-Bh08EOB1.js';
|
|
4
4
|
import { B as BalancesData, T as TransactionListData, I as IssueAuthorizationTokenParams, A as AuthorizationToken } from '../queries-BBgrTZ99.js';
|
|
5
5
|
export { i as issueAuthorizationToken } from '../queries-BBgrTZ99.js';
|
|
6
|
-
import { E as EnvironmentName } from '../environments-
|
|
7
|
-
export { a as ENVIRONMENTS } from '../environments-
|
|
6
|
+
import { E as EnvironmentName } from '../environments-CfyD59YH.js';
|
|
7
|
+
export { a as ENVIRONMENTS } from '../environments-CfyD59YH.js';
|
|
8
8
|
|
|
9
9
|
type EnvironmentInfo = components["schemas"]["EnvironmentInfo"];
|
|
10
10
|
type TransactionStatus = components["schemas"]["TransactionStatus"];
|
package/dist/admin/index.js
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import {
|
|
2
2
|
createHttpClient,
|
|
3
3
|
issueAuthorizationToken
|
|
4
|
-
} from "../chunk-
|
|
4
|
+
} from "../chunk-VWYQOXOL.js";
|
|
5
5
|
import {
|
|
6
6
|
ENVIRONMENTS,
|
|
7
7
|
getEnvironment,
|
|
8
8
|
getUserBalances,
|
|
9
9
|
getUserTransactions,
|
|
10
10
|
resolveEngineUrl
|
|
11
|
-
} from "../chunk-
|
|
11
|
+
} from "../chunk-RS7NZTSS.js";
|
|
12
12
|
import {
|
|
13
13
|
ApiError,
|
|
14
14
|
CapabilityError,
|
package/dist/advanced/index.d.ts
CHANGED
|
@@ -2,9 +2,9 @@ import * as openapi_fetch from 'openapi-fetch';
|
|
|
2
2
|
import { Client } from 'openapi-fetch';
|
|
3
3
|
import { p as paths, S as SignSigningRequestFn } from '../errors-Bh08EOB1.js';
|
|
4
4
|
export { A as AccountKeys, b as ApiError, C as CapabilityError, d as CapabilityErrorCode, e as CapabilityErrorOptions, R as RegistrationPayload, a as RegistrationPayloadWire, m as Signature, n as SigningRequest, T as TimeoutError, U as UnlinkError, V as ValidationError, f as assertRegistrationPayloadWire, u as assertValidSignature, g as fromRegistrationPayloadWire, v as signSigningRequest, t as toRegistrationPayload, h as toRegistrationPayloadWire, w as verifyMessageHash } from '../errors-Bh08EOB1.js';
|
|
5
|
-
export { a as ENVIRONMENTS, E as EnvironmentName, r as resolveEngineUrl } from '../environments-
|
|
6
|
-
import {
|
|
7
|
-
export {
|
|
5
|
+
export { a as ENVIRONMENTS, E as EnvironmentName, r as resolveEngineUrl } from '../environments-CfyD59YH.js';
|
|
6
|
+
import { Q as SignTypedDataFn, X as Permit2NonceManager, a as TransactionResult, H as TransferInstruction, Y as Permit2TypedData, Z as Permit2WitnessTypedData } from '../client-core-CpPGn72-.js';
|
|
7
|
+
export { _ as CreateExecutionAccountClientOptions, $ as DepositBackParams, a0 as DepositBackPreSignParams, a1 as ENTRY_POINT_V07_ADDRESS, h as Eip1193ProviderOptions, i as EthersProviderLike, j as EthersProviderOptions, k as EthersSignerLike, l as EvmProvider, m as EvmTransactionRequest, a2 as ExecuteCall, a3 as ExecuteNextAction, a4 as ExecuteRecoveryError, a5 as ExecuteRecoveryMetadata, a6 as ExecuteRecoveryStage, E as ExecuteResult, a7 as ExecuteSubmitPayload, n as ExecutionAccount, a8 as ExecutionAccountClient, a9 as ExecutionAccountDiscovery, aa as ExecutionAccountIndices, o as ExecutionAccountListResponse, ab as ExecutionAccountNumberish, ac as ExecutionAccountPathIndices, p as ExecutionAccountPolicy, q as ExecutionAccountReservation, ad as ExecutionAccountStatus, ae as ExecutionIntent, af as ExecutionIntentTypedData, ag as ExecutionReservation, s as ExecutionSession, t as ExecutionSessionStatus, ah as ExecutionStatus, ai as GetCodeFn, aj as PollExecuteStatusOptions, ak as PreSignedPermit2DepositBack, al as PrepareDepositBack, am as SignedExecutionIntent, z as SignerProviderOptions, an as TERMINAL_EXECUTE_STATUSES, ao as TERMINAL_TRANSACTION_STATUSES, B as TransactionHandle, T as TransactionHandleWaitOptions, V as ViemAccountProviderOptions, I as ViemLocalAccountLike, J as ViemProviderOptions, K as ViemPublicClientLike, M as ViemWalletClientLike, ap as buildExecutionIntentTypedData, aq as computeSoladyERC4337InitCodeHash, ar as computeSoladyExecutionAccountAddress, as as createExecutionAccountClient, at as encodeExecutionIntentUserOperationSignature, O as evm, au as executionAccountPath, av as fromWireExecutionIntent, aw as getExecuteNextAction, ax as getExecuteSession, ay as getExecutionAccount, az as getExecutionAccountByAddress, aA as hashExecutionIntent, aB as listExecutionAccounts, aC as ownerAddressToOwnSalt, aD as pollExecuteStatus, aE as prepareExecute, aF as reserveExecutionAccount, aG as resolveExecutionAccountPolicy, aH as submitExecute } from '../client-core-CpPGn72-.js';
|
|
8
8
|
export { A as AuthorizationToken, a as Balance, B as BalancesData, E as EnvironmentInfo, I as IssueAuthorizationTokenParams, b as Transaction, T as TransactionListData, g as getEnvironment, c as getTransaction, d as getUserBalances, e as getUserTransactions, i as issueAuthorizationToken } from '../queries-BBgrTZ99.js';
|
|
9
9
|
import 'viem';
|
|
10
10
|
|
package/dist/advanced/index.js
CHANGED
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
import {
|
|
2
|
+
createHttpClient,
|
|
3
|
+
issueAuthorizationToken
|
|
4
|
+
} from "../chunk-VWYQOXOL.js";
|
|
1
5
|
import {
|
|
2
6
|
ENTRY_POINT_V07_ADDRESS,
|
|
3
7
|
ExecuteRecoveryError,
|
|
@@ -31,11 +35,7 @@ import {
|
|
|
31
35
|
submitExecute,
|
|
32
36
|
transfer,
|
|
33
37
|
withdraw
|
|
34
|
-
} from "../chunk-
|
|
35
|
-
import {
|
|
36
|
-
createHttpClient,
|
|
37
|
-
issueAuthorizationToken
|
|
38
|
-
} from "../chunk-3TVXTVOE.js";
|
|
38
|
+
} from "../chunk-4F4TGNXO.js";
|
|
39
39
|
import {
|
|
40
40
|
ENVIRONMENTS,
|
|
41
41
|
getEnvironment,
|
|
@@ -43,7 +43,7 @@ import {
|
|
|
43
43
|
getUserBalances,
|
|
44
44
|
getUserTransactions,
|
|
45
45
|
resolveEngineUrl
|
|
46
|
-
} from "../chunk-
|
|
46
|
+
} from "../chunk-RS7NZTSS.js";
|
|
47
47
|
import {
|
|
48
48
|
ApiError,
|
|
49
49
|
CapabilityError,
|
package/dist/browser/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export { AuthorizationTokenProviderWithContext, AuthorizationTokenRequestContext, AuthorizationTokenSource, CreateUnlinkClientOptions, DEFAULT_AUTHORIZATION_TOKEN_URL, DEFAULT_REGISTER_URL, createUnlinkClient } from '../client/index.js';
|
|
2
|
-
export { a as ENVIRONMENTS, E as EnvironmentName } from '../environments-
|
|
3
|
-
export {
|
|
2
|
+
export { a as ENVIRONMENTS, E as EnvironmentName } from '../environments-CfyD59YH.js';
|
|
3
|
+
export { A as AccountMetaMaskOptions, d as AccountMetaMaskResult, e as ApprovalParams, C as CoreExecutePollOptions, f as CoreTxPollOptions, D as DepositParams, b as DepositWithApprovalParams, g as Eip1193Provider, h as Eip1193ProviderOptions, i as EthersProviderLike, j as EthersProviderOptions, k as EthersSignerLike, l as EvmProvider, m as EvmTransactionRequest, E as ExecuteResult, n as ExecutionAccount, o as ExecutionAccountListResponse, p as ExecutionAccountPolicy, q as ExecutionAccountReservation, r as ExecutionAccounts, s as ExecutionSession, t as ExecutionSessionStatus, F as Faucet, u as FaucetRequestPrivateTokensParams, v as FaucetRequestTestTokensParams, G as GetBalancesParams, w as GetExecutionAccountByAddressParams, x as GetTransactionsParams, L as ListExecutionAccountsParams, P as PollExecuteOptions, y as PollOptions, R as ReserveExecutionAccountParams, S as SessionExecuteParams, z as SignerProviderOptions, B as TransactionHandle, T as TransactionHandleWaitOptions, a as TransactionResult, H as TransferInstruction, c as TransferParams, U as UnlinkClient, V as ViemAccountProviderOptions, I as ViemLocalAccountLike, J as ViemProviderOptions, K as ViemPublicClientLike, M as ViemWalletClientLike, W as WithdrawParams, N as account, O as evm } from '../client-core-CpPGn72-.js';
|
|
4
4
|
export { i as AccountEthereumSignatureOptions, j as AccountExportPayload, A as AccountKeys, k as AccountMnemonicOptions, l as AccountSeedOptions, b as ApiError, C as CapabilityError, d as CapabilityErrorCode, e as CapabilityErrorOptions, R as RegistrationPayload, a as RegistrationPayloadWire, T as TimeoutError, U as UnlinkError, o as UnlinkLocalAccount, V as ValidationError } from '../errors-Bh08EOB1.js';
|
|
5
5
|
import 'openapi-fetch';
|
|
6
6
|
import 'viem';
|
package/dist/browser/index.js
CHANGED
|
@@ -2,14 +2,14 @@ import {
|
|
|
2
2
|
DEFAULT_AUTHORIZATION_TOKEN_URL,
|
|
3
3
|
DEFAULT_REGISTER_URL,
|
|
4
4
|
createUnlinkClient
|
|
5
|
-
} from "../chunk-
|
|
5
|
+
} from "../chunk-EGGG2NHC.js";
|
|
6
6
|
import {
|
|
7
7
|
evm
|
|
8
|
-
} from "../chunk-
|
|
8
|
+
} from "../chunk-4F4TGNXO.js";
|
|
9
9
|
import {
|
|
10
10
|
ENVIRONMENTS,
|
|
11
11
|
account
|
|
12
|
-
} from "../chunk-
|
|
12
|
+
} from "../chunk-RS7NZTSS.js";
|
|
13
13
|
import {
|
|
14
14
|
ApiError,
|
|
15
15
|
CapabilityError,
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import {
|
|
2
2
|
UnlinkClientImpl
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-4F4TGNXO.js";
|
|
4
4
|
import {
|
|
5
5
|
createBodySafeFetch,
|
|
6
6
|
createRetryFetch,
|
|
7
7
|
getEnvironment,
|
|
8
8
|
resolveEngineUrl
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-RS7NZTSS.js";
|
|
10
10
|
import {
|
|
11
11
|
ApiError,
|
|
12
12
|
CapabilityError,
|
|
@@ -148,6 +148,9 @@ var ENVIRONMENTS = {
|
|
|
148
148
|
},
|
|
149
149
|
"arc-testnet-staging": {
|
|
150
150
|
engineUrl: "https://arc-testnet-staging-api.unlink.xyz"
|
|
151
|
+
},
|
|
152
|
+
"arc-testnet-production": {
|
|
153
|
+
engineUrl: "https://arc-testnet-production-api.unlink.xyz"
|
|
151
154
|
}
|
|
152
155
|
};
|
|
153
156
|
function resolveEngineUrl(target) {
|
package/dist/client/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { E as EnvironmentName } from '../environments-
|
|
2
|
-
export { a as ENVIRONMENTS } from '../environments-
|
|
3
|
-
import {
|
|
4
|
-
export {
|
|
1
|
+
import { E as EnvironmentName } from '../environments-CfyD59YH.js';
|
|
2
|
+
export { a as ENVIRONMENTS } from '../environments-CfyD59YH.js';
|
|
3
|
+
import { l as EvmProvider, U as UnlinkClient } from '../client-core-CpPGn72-.js';
|
|
4
|
+
export { A as AccountMetaMaskOptions, d as AccountMetaMaskResult, e as ApprovalParams, C as CoreExecutePollOptions, f as CoreTxPollOptions, D as DepositParams, b as DepositWithApprovalParams, h as Eip1193ProviderOptions, i as EthersProviderLike, j as EthersProviderOptions, k as EthersSignerLike, m as EvmTransactionRequest, E as ExecuteResult, n as ExecutionAccount, o as ExecutionAccountListResponse, p as ExecutionAccountPolicy, q as ExecutionAccountReservation, r as ExecutionAccounts, s as ExecutionSession, t as ExecutionSessionStatus, F as Faucet, u as FaucetRequestPrivateTokensParams, v as FaucetRequestTestTokensParams, G as GetBalancesParams, w as GetExecutionAccountByAddressParams, x as GetTransactionsParams, L as ListExecutionAccountsParams, P as PollExecuteOptions, y as PollOptions, R as ReserveExecutionAccountParams, S as SessionExecuteParams, z as SignerProviderOptions, B as TransactionHandle, T as TransactionHandleWaitOptions, a as TransactionResult, H as TransferInstruction, c as TransferParams, V as ViemAccountProviderOptions, I as ViemLocalAccountLike, J as ViemProviderOptions, K as ViemPublicClientLike, M as ViemWalletClientLike, W as WithdrawParams, N as account, O as evm } from '../client-core-CpPGn72-.js';
|
|
5
5
|
import { o as UnlinkLocalAccount, R as RegistrationPayload } from '../errors-Bh08EOB1.js';
|
|
6
6
|
export { i as AccountEthereumSignatureOptions, j as AccountExportPayload, A as AccountKeys, k as AccountMnemonicOptions, l as AccountSeedOptions, b as ApiError, C as CapabilityError, d as CapabilityErrorCode, e as CapabilityErrorOptions, a as RegistrationPayloadWire, T as TimeoutError, U as UnlinkError, V as ValidationError } from '../errors-Bh08EOB1.js';
|
|
7
7
|
import 'openapi-fetch';
|
package/dist/client/index.js
CHANGED
|
@@ -2,14 +2,14 @@ import {
|
|
|
2
2
|
DEFAULT_AUTHORIZATION_TOKEN_URL,
|
|
3
3
|
DEFAULT_REGISTER_URL,
|
|
4
4
|
createUnlinkClient
|
|
5
|
-
} from "../chunk-
|
|
5
|
+
} from "../chunk-EGGG2NHC.js";
|
|
6
6
|
import {
|
|
7
7
|
evm
|
|
8
|
-
} from "../chunk-
|
|
8
|
+
} from "../chunk-4F4TGNXO.js";
|
|
9
9
|
import {
|
|
10
10
|
ENVIRONMENTS,
|
|
11
11
|
account
|
|
12
|
-
} from "../chunk-
|
|
12
|
+
} from "../chunk-RS7NZTSS.js";
|
|
13
13
|
import {
|
|
14
14
|
ApiError,
|
|
15
15
|
CapabilityError,
|
|
@@ -936,4 +936,4 @@ interface UnlinkClient {
|
|
|
936
936
|
faucet: Faucet;
|
|
937
937
|
}
|
|
938
938
|
|
|
939
|
-
export { type
|
|
939
|
+
export { type DepositBackParams as $, type AccountMetaMaskOptions as A, type TransactionHandle as B, type CoreExecutePollOptions as C, type DepositParams as D, type ExecuteResult as E, type Faucet as F, type GetBalancesParams as G, type TransferInstruction as H, type ViemLocalAccountLike as I, type ViemProviderOptions as J, type ViemPublicClientLike as K, type ListExecutionAccountsParams as L, type ViemWalletClientLike as M, account as N, evm as O, type PollExecuteOptions as P, type SignTypedDataFn as Q, type ReserveExecutionAccountParams as R, type SessionExecuteParams as S, type TransactionHandleWaitOptions as T, type UnlinkClient as U, type ViemAccountProviderOptions as V, type WithdrawParams as W, Permit2NonceManager as X, type Permit2TypedData as Y, type Permit2WitnessTypedData as Z, type CreateExecutionAccountClientOptions as _, type TransactionResult as a, type DepositBackPreSignParams as a0, ENTRY_POINT_V07_ADDRESS as a1, type ExecuteCall as a2, type ExecuteNextAction as a3, ExecuteRecoveryError as a4, type ExecuteRecoveryMetadata as a5, type ExecuteRecoveryStage as a6, type ExecuteSubmitPayload as a7, type ExecutionAccountClient as a8, type ExecutionAccountDiscovery as a9, hashExecutionIntent as aA, listExecutionAccounts as aB, ownerAddressToOwnSalt as aC, pollExecuteStatus as aD, prepareExecute as aE, reserveExecutionAccount as aF, resolveExecutionAccountPolicy as aG, submitExecute as aH, type ExecutionAccountIndices as aa, type ExecutionAccountNumberish as ab, type ExecutionAccountPathIndices as ac, type ExecutionAccountStatus as ad, type ExecutionIntent as ae, type ExecutionIntentTypedData as af, type ExecutionReservation as ag, type ExecutionStatus as ah, type GetCodeFn as ai, type PollExecuteStatusOptions as aj, type PreSignedPermit2DepositBack as ak, type PrepareDepositBack as al, type SignedExecutionIntent as am, TERMINAL_EXECUTE_STATUSES as an, TERMINAL_TRANSACTION_STATUSES as ao, buildExecutionIntentTypedData as ap, computeSoladyERC4337InitCodeHash as aq, computeSoladyExecutionAccountAddress as ar, createExecutionAccountClient as as, encodeExecutionIntentUserOperationSignature as at, executionAccountPath as au, fromWireExecutionIntent as av, getExecuteNextAction as aw, getExecuteSession as ax, getExecutionAccount as ay, getExecutionAccountByAddress as az, type DepositWithApprovalParams as b, type TransferParams as c, type AccountMetaMaskResult as d, type ApprovalParams as e, type CoreTxPollOptions as f, type Eip1193Provider as g, type Eip1193ProviderOptions as h, type EthersProviderLike as i, type EthersProviderOptions as j, type EthersSignerLike as k, type EvmProvider as l, type EvmTransactionRequest as m, type ExecutionAccount as n, type ExecutionAccountListResponse as o, type ExecutionAccountPolicy as p, type ExecutionAccountReservation as q, type ExecutionAccounts as r, type ExecutionSession as s, type ExecutionSessionStatus$1 as t, type FaucetRequestPrivateTokensParams as u, type FaucetRequestTestTokensParams as v, type GetExecutionAccountByAddressParams as w, type GetTransactionsParams as x, type PollOptions as y, type SignerProviderOptions as z };
|
|
@@ -39,6 +39,9 @@ declare const ENVIRONMENTS: {
|
|
|
39
39
|
readonly "arc-testnet-staging": {
|
|
40
40
|
readonly engineUrl: "https://arc-testnet-staging-api.unlink.xyz";
|
|
41
41
|
};
|
|
42
|
+
readonly "arc-testnet-production": {
|
|
43
|
+
readonly engineUrl: "https://arc-testnet-production-api.unlink.xyz";
|
|
44
|
+
};
|
|
42
45
|
};
|
|
43
46
|
/** Canonical names the SDK resolves to a hosted Engine URL. */
|
|
44
47
|
type EnvironmentName = keyof typeof ENVIRONMENTS;
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
import { CreateUnlinkClientOptions } from '../client/index.js';
|
|
3
|
+
export { AuthorizationTokenProviderWithContext, AuthorizationTokenRequestContext, AuthorizationTokenSource, DEFAULT_AUTHORIZATION_TOKEN_URL, DEFAULT_REGISTER_URL, createUnlinkClient } from '../client/index.js';
|
|
4
|
+
import { U as UnlinkClient, D as DepositParams, T as TransactionHandleWaitOptions, a as TransactionResult, b as DepositWithApprovalParams, c as TransferParams, W as WithdrawParams, S as SessionExecuteParams, E as ExecuteResult } from '../client-core-CpPGn72-.js';
|
|
5
|
+
export { A as AccountMetaMaskOptions, d as AccountMetaMaskResult, e as ApprovalParams, C as CoreExecutePollOptions, f as CoreTxPollOptions, g as Eip1193Provider, h as Eip1193ProviderOptions, i as EthersProviderLike, j as EthersProviderOptions, k as EthersSignerLike, l as EvmProvider, m as EvmTransactionRequest, n as ExecutionAccount, o as ExecutionAccountListResponse, p as ExecutionAccountPolicy, q as ExecutionAccountReservation, r as ExecutionAccounts, s as ExecutionSession, t as ExecutionSessionStatus, F as Faucet, u as FaucetRequestPrivateTokensParams, v as FaucetRequestTestTokensParams, G as GetBalancesParams, w as GetExecutionAccountByAddressParams, x as GetTransactionsParams, L as ListExecutionAccountsParams, P as PollExecuteOptions, y as PollOptions, R as ReserveExecutionAccountParams, z as SignerProviderOptions, B as TransactionHandle, H as TransferInstruction, V as ViemAccountProviderOptions, I as ViemLocalAccountLike, J as ViemProviderOptions, K as ViemPublicClientLike, M as ViemWalletClientLike, N as account, O as evm } from '../client-core-CpPGn72-.js';
|
|
6
|
+
import { c as components } from '../errors-Bh08EOB1.js';
|
|
7
|
+
export { i as AccountEthereumSignatureOptions, j as AccountExportPayload, A as AccountKeys, k as AccountMnemonicOptions, l as AccountSeedOptions, b as ApiError, C as CapabilityError, d as CapabilityErrorCode, e as CapabilityErrorOptions, R as RegistrationPayload, a as RegistrationPayloadWire, T as TimeoutError, U as UnlinkError, o as UnlinkLocalAccount, V as ValidationError } from '../errors-Bh08EOB1.js';
|
|
8
|
+
export { a as ENVIRONMENTS, E as EnvironmentName } from '../environments-CfyD59YH.js';
|
|
9
|
+
import 'openapi-fetch';
|
|
10
|
+
import 'viem';
|
|
11
|
+
|
|
12
|
+
type BalancesData = components["schemas"]["BalancesData"];
|
|
13
|
+
type TransactionListData = components["schemas"]["TransactionListData"];
|
|
14
|
+
/** Lifecycle of the controller's data load. Apps label these themselves. */
|
|
15
|
+
type UnlinkStatus = "idle" | "loading" | "ready" | "error";
|
|
16
|
+
/** Immutable reactive state. Stable reference between changes (safe for `useSyncExternalStore`). */
|
|
17
|
+
interface UnlinkSnapshot {
|
|
18
|
+
readonly status: UnlinkStatus;
|
|
19
|
+
readonly address: string | null;
|
|
20
|
+
readonly balances: BalancesData | null;
|
|
21
|
+
readonly transactions: TransactionListData | null;
|
|
22
|
+
/** Most recent data-load error; cleared on the next `refresh`. */
|
|
23
|
+
readonly error: Error | null;
|
|
24
|
+
}
|
|
25
|
+
interface UnlinkController {
|
|
26
|
+
/** Raw client escape hatch (execution accounts, faucet, approval, polling). */
|
|
27
|
+
readonly client: UnlinkClient;
|
|
28
|
+
/** Current immutable snapshot. */
|
|
29
|
+
getSnapshot(): UnlinkSnapshot;
|
|
30
|
+
/** Subscribe to snapshot changes; returns an unsubscribe fn. */
|
|
31
|
+
subscribe(listener: () => void): () => void;
|
|
32
|
+
/** Ensure the user is registered (idempotent), then load address + balances + transactions. */
|
|
33
|
+
refresh(): Promise<void>;
|
|
34
|
+
deposit(params: DepositParams, waitOptions?: TransactionHandleWaitOptions): Promise<TransactionResult>;
|
|
35
|
+
depositWithApproval(params: DepositWithApprovalParams, waitOptions?: TransactionHandleWaitOptions): Promise<TransactionResult>;
|
|
36
|
+
transfer(params: TransferParams, waitOptions?: TransactionHandleWaitOptions): Promise<TransactionResult>;
|
|
37
|
+
withdraw(params: WithdrawParams, waitOptions?: TransactionHandleWaitOptions): Promise<TransactionResult>;
|
|
38
|
+
execute(params: SessionExecuteParams): Promise<ExecuteResult>;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
interface UnlinkProviderProps {
|
|
42
|
+
/** A ready client. Mutually exclusive with `config`. */
|
|
43
|
+
client?: UnlinkClient;
|
|
44
|
+
/** Options to build a client. Mutually exclusive with `client`. */
|
|
45
|
+
config?: CreateUnlinkClientOptions;
|
|
46
|
+
children: ReactNode;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Provides a single `UnlinkController` to descendants. `client`/`config` are
|
|
50
|
+
* read once on first render; later prop changes are ignored (rebuild by
|
|
51
|
+
* remounting, e.g. via a `key`). The initial balances/transactions load fires
|
|
52
|
+
* from a mount effect.
|
|
53
|
+
*/
|
|
54
|
+
declare function UnlinkProvider(props: UnlinkProviderProps): ReactNode;
|
|
55
|
+
|
|
56
|
+
/** Reactive state + actions returned by {@link useUnlink}. */
|
|
57
|
+
interface UseUnlinkResult extends UnlinkSnapshot {
|
|
58
|
+
/** Raw client escape hatch for anything not surfaced here. */
|
|
59
|
+
client: UnlinkClient;
|
|
60
|
+
refresh: UnlinkController["refresh"];
|
|
61
|
+
deposit: UnlinkController["deposit"];
|
|
62
|
+
depositWithApproval: UnlinkController["depositWithApproval"];
|
|
63
|
+
transfer: UnlinkController["transfer"];
|
|
64
|
+
withdraw: UnlinkController["withdraw"];
|
|
65
|
+
execute: UnlinkController["execute"];
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* The one primitive: reactive Unlink state (`status`, `address`, `balances`,
|
|
69
|
+
* `transactions`, `error`) plus action methods that wait for completion then
|
|
70
|
+
* refresh. Must be called under an `<UnlinkProvider>`.
|
|
71
|
+
*/
|
|
72
|
+
declare function useUnlink(): UseUnlinkResult;
|
|
73
|
+
|
|
74
|
+
export { CreateUnlinkClientOptions, DepositParams, DepositWithApprovalParams, ExecuteResult, SessionExecuteParams, TransactionHandleWaitOptions, TransactionResult, TransferParams, UnlinkClient, type UnlinkController, UnlinkProvider, type UnlinkProviderProps, type UnlinkSnapshot, type UnlinkStatus, type UseUnlinkResult, WithdrawParams, useUnlink };
|
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
import {
|
|
2
|
+
DEFAULT_AUTHORIZATION_TOKEN_URL,
|
|
3
|
+
DEFAULT_REGISTER_URL,
|
|
4
|
+
createUnlinkClient
|
|
5
|
+
} from "../chunk-EGGG2NHC.js";
|
|
6
|
+
import {
|
|
7
|
+
evm
|
|
8
|
+
} from "../chunk-4F4TGNXO.js";
|
|
9
|
+
import {
|
|
10
|
+
ENVIRONMENTS,
|
|
11
|
+
account
|
|
12
|
+
} from "../chunk-RS7NZTSS.js";
|
|
13
|
+
import {
|
|
14
|
+
ApiError,
|
|
15
|
+
CapabilityError,
|
|
16
|
+
TimeoutError,
|
|
17
|
+
UnlinkError,
|
|
18
|
+
ValidationError
|
|
19
|
+
} from "../chunk-SCM5FQ6U.js";
|
|
20
|
+
import "../chunk-JSBRDJBE.js";
|
|
21
|
+
|
|
22
|
+
// src/react/context.ts
|
|
23
|
+
import {
|
|
24
|
+
createContext,
|
|
25
|
+
createElement,
|
|
26
|
+
useContext,
|
|
27
|
+
useEffect,
|
|
28
|
+
useState
|
|
29
|
+
} from "react";
|
|
30
|
+
|
|
31
|
+
// src/internal/controller/create-controller.ts
|
|
32
|
+
var IDLE = {
|
|
33
|
+
status: "idle",
|
|
34
|
+
address: null,
|
|
35
|
+
balances: null,
|
|
36
|
+
transactions: null,
|
|
37
|
+
error: null
|
|
38
|
+
};
|
|
39
|
+
function toError(value) {
|
|
40
|
+
return value instanceof Error ? value : new Error(String(value));
|
|
41
|
+
}
|
|
42
|
+
function createUnlinkController(client) {
|
|
43
|
+
let snapshot = IDLE;
|
|
44
|
+
const listeners = /* @__PURE__ */ new Set();
|
|
45
|
+
let refreshToken = 0;
|
|
46
|
+
const setState = (patch) => {
|
|
47
|
+
snapshot = { ...snapshot, ...patch };
|
|
48
|
+
for (const listener of listeners) listener();
|
|
49
|
+
};
|
|
50
|
+
const getSnapshot = () => snapshot;
|
|
51
|
+
const subscribe = (listener) => {
|
|
52
|
+
listeners.add(listener);
|
|
53
|
+
return () => {
|
|
54
|
+
listeners.delete(listener);
|
|
55
|
+
};
|
|
56
|
+
};
|
|
57
|
+
const ensureReady = () => client.ensureRegistered();
|
|
58
|
+
const refresh = async () => {
|
|
59
|
+
const token = ++refreshToken;
|
|
60
|
+
setState({ status: "loading", error: null });
|
|
61
|
+
let patch;
|
|
62
|
+
try {
|
|
63
|
+
await ensureReady();
|
|
64
|
+
const [address, balances, transactions] = await Promise.all([
|
|
65
|
+
client.getAddress(),
|
|
66
|
+
client.getBalances(),
|
|
67
|
+
client.getTransactions()
|
|
68
|
+
]);
|
|
69
|
+
patch = { status: "ready", address, balances, transactions };
|
|
70
|
+
} catch (err) {
|
|
71
|
+
patch = { status: "error", error: toError(err) };
|
|
72
|
+
}
|
|
73
|
+
if (token !== refreshToken) return;
|
|
74
|
+
setState(patch);
|
|
75
|
+
};
|
|
76
|
+
const runAndRefresh = async (action, waitOptions) => {
|
|
77
|
+
await ensureReady();
|
|
78
|
+
const result = await (await action()).wait(waitOptions);
|
|
79
|
+
await refresh();
|
|
80
|
+
return result;
|
|
81
|
+
};
|
|
82
|
+
return {
|
|
83
|
+
client,
|
|
84
|
+
getSnapshot,
|
|
85
|
+
subscribe,
|
|
86
|
+
refresh,
|
|
87
|
+
deposit: (params, waitOptions) => runAndRefresh(() => client.deposit(params), waitOptions),
|
|
88
|
+
depositWithApproval: (params, waitOptions) => runAndRefresh(() => client.depositWithApproval(params), waitOptions),
|
|
89
|
+
transfer: (params, waitOptions) => runAndRefresh(() => client.transfer(params), waitOptions),
|
|
90
|
+
withdraw: (params, waitOptions) => runAndRefresh(() => client.withdraw(params), waitOptions),
|
|
91
|
+
// No waitOptions here (unlike the four above): client.execute already
|
|
92
|
+
// resolves to a terminal ExecuteResult, not a TransactionHandle to .wait().
|
|
93
|
+
execute: async (params) => {
|
|
94
|
+
await ensureReady();
|
|
95
|
+
const result = await client.execute(params);
|
|
96
|
+
await refresh();
|
|
97
|
+
return result;
|
|
98
|
+
}
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
// src/react/context.ts
|
|
103
|
+
var UnlinkControllerContext = createContext(null);
|
|
104
|
+
function UnlinkProvider(props) {
|
|
105
|
+
const [controller] = useState(() => {
|
|
106
|
+
const client = props.client ?? (props.config ? createUnlinkClient(props.config) : null);
|
|
107
|
+
if (!client) {
|
|
108
|
+
throw new CapabilityError(
|
|
109
|
+
"UnlinkProvider requires either a `client` or a `config` prop",
|
|
110
|
+
{ code: "missing_identity" }
|
|
111
|
+
);
|
|
112
|
+
}
|
|
113
|
+
return createUnlinkController(client);
|
|
114
|
+
});
|
|
115
|
+
useEffect(() => {
|
|
116
|
+
void controller.refresh();
|
|
117
|
+
}, [controller]);
|
|
118
|
+
return createElement(
|
|
119
|
+
UnlinkControllerContext.Provider,
|
|
120
|
+
{ value: controller },
|
|
121
|
+
props.children
|
|
122
|
+
);
|
|
123
|
+
}
|
|
124
|
+
function useUnlinkController() {
|
|
125
|
+
const controller = useContext(UnlinkControllerContext);
|
|
126
|
+
if (!controller) {
|
|
127
|
+
throw new CapabilityError(
|
|
128
|
+
"useUnlink must be used within an <UnlinkProvider>",
|
|
129
|
+
{ code: "missing_identity" }
|
|
130
|
+
);
|
|
131
|
+
}
|
|
132
|
+
return controller;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
// src/react/use-unlink.ts
|
|
136
|
+
import { useSyncExternalStore } from "react";
|
|
137
|
+
function useUnlink() {
|
|
138
|
+
const controller = useUnlinkController();
|
|
139
|
+
const snapshot = useSyncExternalStore(
|
|
140
|
+
controller.subscribe,
|
|
141
|
+
controller.getSnapshot,
|
|
142
|
+
controller.getSnapshot
|
|
143
|
+
);
|
|
144
|
+
return {
|
|
145
|
+
...snapshot,
|
|
146
|
+
client: controller.client,
|
|
147
|
+
refresh: controller.refresh,
|
|
148
|
+
deposit: controller.deposit,
|
|
149
|
+
depositWithApproval: controller.depositWithApproval,
|
|
150
|
+
transfer: controller.transfer,
|
|
151
|
+
withdraw: controller.withdraw,
|
|
152
|
+
execute: controller.execute
|
|
153
|
+
};
|
|
154
|
+
}
|
|
155
|
+
export {
|
|
156
|
+
ApiError,
|
|
157
|
+
CapabilityError,
|
|
158
|
+
DEFAULT_AUTHORIZATION_TOKEN_URL,
|
|
159
|
+
DEFAULT_REGISTER_URL,
|
|
160
|
+
ENVIRONMENTS,
|
|
161
|
+
TimeoutError,
|
|
162
|
+
UnlinkError,
|
|
163
|
+
UnlinkProvider,
|
|
164
|
+
ValidationError,
|
|
165
|
+
account,
|
|
166
|
+
createUnlinkClient,
|
|
167
|
+
evm,
|
|
168
|
+
useUnlink
|
|
169
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@unlink-xyz/sdk",
|
|
3
|
-
"version": "0.3.0-canary.
|
|
3
|
+
"version": "0.3.0-canary.577",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"exports": {
|
|
6
6
|
"./browser": {
|
|
@@ -28,6 +28,11 @@
|
|
|
28
28
|
"types": "./dist/crypto/index.d.ts",
|
|
29
29
|
"import": "./dist/crypto/index.js",
|
|
30
30
|
"default": "./dist/crypto/index.js"
|
|
31
|
+
},
|
|
32
|
+
"./react": {
|
|
33
|
+
"types": "./dist/react/index.d.ts",
|
|
34
|
+
"import": "./dist/react/index.js",
|
|
35
|
+
"default": "./dist/react/index.js"
|
|
31
36
|
}
|
|
32
37
|
},
|
|
33
38
|
"files": [
|
|
@@ -56,6 +61,14 @@
|
|
|
56
61
|
"publint": "publint",
|
|
57
62
|
"attw": "attw --pack ."
|
|
58
63
|
},
|
|
64
|
+
"peerDependencies": {
|
|
65
|
+
"react": ">=18 <20"
|
|
66
|
+
},
|
|
67
|
+
"peerDependenciesMeta": {
|
|
68
|
+
"react": {
|
|
69
|
+
"optional": true
|
|
70
|
+
}
|
|
71
|
+
},
|
|
59
72
|
"dependencies": {
|
|
60
73
|
"@noble/curves": "^2.2.0",
|
|
61
74
|
"@noble/hashes": "^2.2.0",
|
|
@@ -70,11 +83,17 @@
|
|
|
70
83
|
"@arethetypeswrong/cli": "^0.18.0",
|
|
71
84
|
"@metamask/eth-sig-util": "^8.2.0",
|
|
72
85
|
"@size-limit/preset-small-lib": "^11.2.0",
|
|
86
|
+
"@testing-library/react": "^16.1.0",
|
|
87
|
+
"@types/react": "^19.2.0",
|
|
88
|
+
"@types/react-dom": "^19.2.0",
|
|
73
89
|
"@vitest/coverage-v8": "^3.2.4",
|
|
74
90
|
"@zk-kit/eddsa-poseidon": "^1.1.0",
|
|
75
91
|
"ethers": "^6.15.0",
|
|
92
|
+
"jsdom": "^26.1.0",
|
|
76
93
|
"openapi-typescript": "^7.13.0",
|
|
77
94
|
"publint": "^0.3.0",
|
|
95
|
+
"react": "^19.2.0",
|
|
96
|
+
"react-dom": "^19.2.0",
|
|
78
97
|
"size-limit": "^11.2.0",
|
|
79
98
|
"tsup": "^8.0.0",
|
|
80
99
|
"vitest": "^3.0.0"
|