@unlink-xyz/react 0.1.3-canary.d1872f5 → 0.1.3-canary.f8763d3
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.d.ts +106 -17
- package/dist/index.js +321 -45
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -35871,63 +35871,79 @@ var Runtime = {
|
|
|
35871
35871
|
}
|
|
35872
35872
|
};
|
|
35873
35873
|
var CONFIG_URL = "https://config.unlink.xyz/networks.json";
|
|
35874
|
-
function parseRequiredString(
|
|
35874
|
+
function parseRequiredString(chain2, field, value) {
|
|
35875
35875
|
if (typeof value !== "string" || value.trim().length === 0) {
|
|
35876
35876
|
throw new InitializationError(
|
|
35877
|
-
`Invalid SDK config for ${
|
|
35877
|
+
`Invalid SDK config for ${chain2}: ${field} must be a non-empty string`
|
|
35878
35878
|
);
|
|
35879
35879
|
}
|
|
35880
35880
|
return value.trim();
|
|
35881
35881
|
}
|
|
35882
|
-
function parseOptionalString(
|
|
35882
|
+
function parseOptionalString(chain2, field, value) {
|
|
35883
35883
|
if (value === void 0) return void 0;
|
|
35884
35884
|
if (typeof value !== "string" || value.trim().length === 0) {
|
|
35885
35885
|
throw new InitializationError(
|
|
35886
|
-
`Invalid SDK config for ${
|
|
35886
|
+
`Invalid SDK config for ${chain2}: ${field} must be a non-empty string when provided`
|
|
35887
35887
|
);
|
|
35888
35888
|
}
|
|
35889
35889
|
return value.trim();
|
|
35890
35890
|
}
|
|
35891
|
-
function
|
|
35891
|
+
function parseRequiredChainId(chain2, value) {
|
|
35892
|
+
if (typeof value !== "number" || !Number.isInteger(value) || value <= 0) {
|
|
35893
|
+
throw new InitializationError(
|
|
35894
|
+
`Invalid SDK config for ${chain2}: chainId must be a positive integer`
|
|
35895
|
+
);
|
|
35896
|
+
}
|
|
35897
|
+
return value;
|
|
35898
|
+
}
|
|
35899
|
+
function parseChainConfig(chain2, value) {
|
|
35892
35900
|
if (value === null || typeof value !== "object" || Array.isArray(value)) {
|
|
35893
35901
|
throw new InitializationError(
|
|
35894
|
-
`Invalid SDK config for ${
|
|
35902
|
+
`Invalid SDK config for ${chain2}: expected object`
|
|
35895
35903
|
);
|
|
35896
35904
|
}
|
|
35897
35905
|
const raw = value;
|
|
35906
|
+
const chainId = parseRequiredChainId(chain2, raw.chainId);
|
|
35898
35907
|
const gatewayUrl = parseRequiredString(
|
|
35899
|
-
|
|
35908
|
+
chain2,
|
|
35900
35909
|
"gatewayUrl",
|
|
35901
35910
|
raw.gatewayUrl
|
|
35902
35911
|
).replace(/\/+$/, "");
|
|
35903
|
-
const poolAddress = parseRequiredString(
|
|
35912
|
+
const poolAddress = parseRequiredString(
|
|
35913
|
+
chain2,
|
|
35914
|
+
"poolAddress",
|
|
35915
|
+
raw.poolAddress
|
|
35916
|
+
);
|
|
35904
35917
|
const artifactVersion = parseRequiredString(
|
|
35905
|
-
|
|
35918
|
+
chain2,
|
|
35906
35919
|
"artifactVersion",
|
|
35907
35920
|
raw.artifactVersion
|
|
35908
35921
|
).replace(/^\/+|\/+$/g, "");
|
|
35909
35922
|
const artifactBaseUrl = parseOptionalString(
|
|
35910
|
-
|
|
35923
|
+
chain2,
|
|
35911
35924
|
"artifactBaseUrl",
|
|
35912
35925
|
raw.artifactBaseUrl
|
|
35913
35926
|
)?.replace(/\/+$/, "");
|
|
35914
35927
|
return {
|
|
35928
|
+
chainId,
|
|
35915
35929
|
gatewayUrl,
|
|
35916
35930
|
poolAddress,
|
|
35917
35931
|
artifactVersion,
|
|
35918
35932
|
...artifactBaseUrl !== void 0 ? { artifactBaseUrl } : { artifactBaseUrl: DEFAULT_ARTIFACT_BASE_URL }
|
|
35919
35933
|
};
|
|
35920
35934
|
}
|
|
35921
|
-
async function
|
|
35935
|
+
async function fetchChainConfig(chain2) {
|
|
35922
35936
|
const res = await fetch(CONFIG_URL);
|
|
35923
35937
|
if (!res.ok) {
|
|
35924
35938
|
throw new InitializationError(`Failed to fetch SDK config: ${res.status}`);
|
|
35925
35939
|
}
|
|
35926
35940
|
const config22 = await res.json();
|
|
35927
|
-
if (!config22[
|
|
35928
|
-
throw new InitializationError(
|
|
35941
|
+
if (!config22[chain2]) {
|
|
35942
|
+
throw new InitializationError(
|
|
35943
|
+
`Unknown chain: "${chain2}". Supported chains: ${Object.keys(config22).join(", ")}`
|
|
35944
|
+
);
|
|
35929
35945
|
}
|
|
35930
|
-
return
|
|
35946
|
+
return parseChainConfig(chain2, config22[chain2]);
|
|
35931
35947
|
}
|
|
35932
35948
|
function createServiceConfig(gatewayUrl) {
|
|
35933
35949
|
const baseUrl = gatewayUrl.replace(/\/+$/, "");
|
|
@@ -55640,6 +55656,16 @@ function createAdapterService(deps) {
|
|
|
55640
55656
|
const reshieldSpecs = params.reshields.map(
|
|
55641
55657
|
(reshield, i) => normalizeReshieldSpec(reshield, i)
|
|
55642
55658
|
);
|
|
55659
|
+
const seenReshieldTokens = /* @__PURE__ */ new Set();
|
|
55660
|
+
for (const r2 of reshieldSpecs) {
|
|
55661
|
+
const lower = r2.token.toLowerCase();
|
|
55662
|
+
if (seenReshieldTokens.has(lower)) {
|
|
55663
|
+
throw new AdapterError(
|
|
55664
|
+
`duplicate reshield token ${r2.token}; each reshield must target a unique token`
|
|
55665
|
+
);
|
|
55666
|
+
}
|
|
55667
|
+
seenReshieldTokens.add(lower);
|
|
55668
|
+
}
|
|
55643
55669
|
const account = overrides?.account ?? await deps.requireActiveAccount();
|
|
55644
55670
|
const signer = overrides?.signer ?? deps.requireSigner(account);
|
|
55645
55671
|
const nowSeconds = BigInt(Math.floor(nowImpl() / 1e3));
|
|
@@ -56536,34 +56562,37 @@ var UnlinkWallet = class _UnlinkWallet {
|
|
|
56536
56562
|
* Create a new UnlinkWallet instance.
|
|
56537
56563
|
*
|
|
56538
56564
|
* Handles all initialization internally:
|
|
56539
|
-
* - Resolves
|
|
56565
|
+
* - Resolves chain config (if using `chain` instead of explicit URLs)
|
|
56540
56566
|
* - Auto-detects storage (IndexedDB in browser) and rng (crypto.getRandomValues)
|
|
56541
56567
|
* - Runs schema migration via `initCore()`
|
|
56542
56568
|
* - Creates the internal SDK
|
|
56543
56569
|
*/
|
|
56544
56570
|
static async create(config22) {
|
|
56571
|
+
let chainId;
|
|
56545
56572
|
let gatewayUrl;
|
|
56546
56573
|
let poolAddress;
|
|
56547
56574
|
let proverConfig = config22.prover;
|
|
56548
|
-
if ("
|
|
56575
|
+
if ("chain" in config22) {
|
|
56576
|
+
const chainConfig = await fetchChainConfig(config22.chain);
|
|
56577
|
+
chainId = chainConfig.chainId;
|
|
56578
|
+
gatewayUrl = chainConfig.gatewayUrl;
|
|
56579
|
+
poolAddress = config22.poolAddress ?? chainConfig.poolAddress;
|
|
56580
|
+
proverConfig = {
|
|
56581
|
+
artifactSource: {
|
|
56582
|
+
baseUrl: config22.prover?.artifactSource?.baseUrl ?? chainConfig.artifactBaseUrl,
|
|
56583
|
+
version: config22.prover?.artifactSource?.version ?? chainConfig.artifactVersion,
|
|
56584
|
+
preferLocalFiles: config22.prover?.artifactSource?.preferLocalFiles
|
|
56585
|
+
}
|
|
56586
|
+
};
|
|
56587
|
+
} else {
|
|
56588
|
+
chainId = config22.chainId;
|
|
56549
56589
|
gatewayUrl = config22.gatewayUrl;
|
|
56550
56590
|
poolAddress = config22.poolAddress;
|
|
56551
56591
|
if (typeof window !== "undefined" && !config22.prover?.artifactSource?.version) {
|
|
56552
56592
|
throw new InitializationError(
|
|
56553
|
-
"prover.artifactSource.version is required in browser when using explicit gatewayUrl mode. Use
|
|
56593
|
+
"prover.artifactSource.version is required in browser when using explicit gatewayUrl mode. Use chain mode or provide a pinned artifact version."
|
|
56554
56594
|
);
|
|
56555
56595
|
}
|
|
56556
|
-
} else {
|
|
56557
|
-
const envConfig = await fetchEnvironmentConfig(config22.environment);
|
|
56558
|
-
gatewayUrl = envConfig.gatewayUrl;
|
|
56559
|
-
poolAddress = config22.poolAddress ?? envConfig.poolAddress;
|
|
56560
|
-
proverConfig = {
|
|
56561
|
-
artifactSource: {
|
|
56562
|
-
baseUrl: config22.prover?.artifactSource?.baseUrl ?? envConfig.artifactBaseUrl,
|
|
56563
|
-
version: config22.prover?.artifactSource?.version ?? envConfig.artifactVersion,
|
|
56564
|
-
preferLocalFiles: config22.prover?.artifactSource?.preferLocalFiles
|
|
56565
|
-
}
|
|
56566
|
-
};
|
|
56567
56596
|
}
|
|
56568
56597
|
const storage = config22.storage ?? detectStorage();
|
|
56569
56598
|
const rng = config22.rng ?? defaultRng;
|
|
@@ -56572,14 +56601,14 @@ var UnlinkWallet = class _UnlinkWallet {
|
|
|
56572
56601
|
const sdk = createWalletSDK(
|
|
56573
56602
|
{ core, fetch: fetchImpl },
|
|
56574
56603
|
{
|
|
56575
|
-
chainId
|
|
56604
|
+
chainId,
|
|
56576
56605
|
gatewayUrl,
|
|
56577
56606
|
chainRpcUrl: config22.chainRpcUrl,
|
|
56578
56607
|
prover: proverConfig,
|
|
56579
56608
|
autoSync: config22.autoSync
|
|
56580
56609
|
}
|
|
56581
56610
|
);
|
|
56582
|
-
return new _UnlinkWallet(sdk,
|
|
56611
|
+
return new _UnlinkWallet(sdk, chainId, poolAddress);
|
|
56583
56612
|
}
|
|
56584
56613
|
// ===== Seed Lifecycle =====
|
|
56585
56614
|
/** Seed management (create, import, export, delete mnemonic). */
|
|
@@ -56935,8 +56964,10 @@ var initialState = {
|
|
|
56935
56964
|
accounts: [],
|
|
56936
56965
|
activeAccount: null,
|
|
56937
56966
|
activeAccountIndex: null,
|
|
56967
|
+
chainId: null,
|
|
56938
56968
|
notes: [],
|
|
56939
56969
|
balances: {},
|
|
56970
|
+
burners: [],
|
|
56940
56971
|
pendingDeposits: [],
|
|
56941
56972
|
pendingTransfers: [],
|
|
56942
56973
|
pendingWithdrawals: [],
|
|
@@ -56954,14 +56985,15 @@ function convertNotes(noteRecords) {
|
|
|
56954
56985
|
}
|
|
56955
56986
|
function UnlinkProvider({
|
|
56956
56987
|
children,
|
|
56957
|
-
chainId,
|
|
56958
56988
|
poolAddress,
|
|
56959
56989
|
syncInterval = 5e3,
|
|
56960
56990
|
autoSync = true,
|
|
56961
|
-
|
|
56962
|
-
|
|
56963
|
-
prover
|
|
56991
|
+
prover,
|
|
56992
|
+
...configProps
|
|
56964
56993
|
}) {
|
|
56994
|
+
const chain2 = "chain" in configProps ? configProps.chain : void 0;
|
|
56995
|
+
const chainId = "chainId" in configProps ? configProps.chainId : void 0;
|
|
56996
|
+
const gatewayUrl = "gatewayUrl" in configProps ? configProps.gatewayUrl : void 0;
|
|
56965
56997
|
const [state, setState] = useState(initialState);
|
|
56966
56998
|
const walletRef = useRef(null);
|
|
56967
56999
|
const proverKey = JSON.stringify(prover ?? null);
|
|
@@ -56991,13 +57023,13 @@ function UnlinkProvider({
|
|
|
56991
57023
|
}
|
|
56992
57024
|
}, []);
|
|
56993
57025
|
useEffect(() => {
|
|
56994
|
-
if (!
|
|
57026
|
+
if (!chain2 && !gatewayUrl) {
|
|
56995
57027
|
const configError = new ValidationError(
|
|
56996
|
-
"Either
|
|
57028
|
+
"Either chain or gatewayUrl is required"
|
|
56997
57029
|
);
|
|
56998
57030
|
setState((prev2) => ({
|
|
56999
57031
|
...prev2,
|
|
57000
|
-
status: "Error: Either
|
|
57032
|
+
status: "Error: Either chain or gatewayUrl is required",
|
|
57001
57033
|
error: createUnlinkError(configError, "init")
|
|
57002
57034
|
}));
|
|
57003
57035
|
return;
|
|
@@ -57011,14 +57043,13 @@ function UnlinkProvider({
|
|
|
57011
57043
|
status: "Initializing SDK..."
|
|
57012
57044
|
}));
|
|
57013
57045
|
const wallet = await UnlinkWallet.create(
|
|
57014
|
-
|
|
57015
|
-
|
|
57016
|
-
gatewayUrl,
|
|
57046
|
+
chain2 ? {
|
|
57047
|
+
chain: chain2,
|
|
57017
57048
|
poolAddress,
|
|
57018
57049
|
...prover ? { prover } : {}
|
|
57019
57050
|
} : {
|
|
57020
57051
|
chainId,
|
|
57021
|
-
|
|
57052
|
+
gatewayUrl,
|
|
57022
57053
|
poolAddress,
|
|
57023
57054
|
...prover ? { prover } : {}
|
|
57024
57055
|
}
|
|
@@ -57059,6 +57090,7 @@ function UnlinkProvider({
|
|
|
57059
57090
|
accounts,
|
|
57060
57091
|
activeAccount,
|
|
57061
57092
|
activeAccountIndex,
|
|
57093
|
+
chainId: wallet.chainId,
|
|
57062
57094
|
notes,
|
|
57063
57095
|
balances,
|
|
57064
57096
|
ready: true,
|
|
@@ -57069,7 +57101,7 @@ function UnlinkProvider({
|
|
|
57069
57101
|
wallet.startAutoSync(syncInterval);
|
|
57070
57102
|
}
|
|
57071
57103
|
unsubscribe = wallet.on((event) => {
|
|
57072
|
-
if (event.type === "notes-updated" && event.chainId === chainId) {
|
|
57104
|
+
if (event.type === "notes-updated" && event.chainId === wallet.chainId) {
|
|
57073
57105
|
setState((prev2) => ({ ...prev2, syncError: null }));
|
|
57074
57106
|
void refreshState(wallet);
|
|
57075
57107
|
}
|
|
@@ -57103,13 +57135,13 @@ function UnlinkProvider({
|
|
|
57103
57135
|
walletRef.current?.stopAutoSync();
|
|
57104
57136
|
};
|
|
57105
57137
|
}, [
|
|
57138
|
+
chain2,
|
|
57106
57139
|
chainId,
|
|
57107
57140
|
autoSync,
|
|
57108
57141
|
syncInterval,
|
|
57109
57142
|
refreshState,
|
|
57110
57143
|
refreshAccounts,
|
|
57111
57144
|
gatewayUrl,
|
|
57112
|
-
environment,
|
|
57113
57145
|
poolAddress,
|
|
57114
57146
|
proverKey
|
|
57115
57147
|
]);
|
|
@@ -57157,6 +57189,7 @@ function UnlinkProvider({
|
|
|
57157
57189
|
accounts,
|
|
57158
57190
|
activeAccount,
|
|
57159
57191
|
activeAccountIndex,
|
|
57192
|
+
burners: [],
|
|
57160
57193
|
busy: false,
|
|
57161
57194
|
status: accounts.length > 0 ? "Wallet imported" : "Wallet imported - create an account",
|
|
57162
57195
|
syncError: null,
|
|
@@ -57191,6 +57224,7 @@ function UnlinkProvider({
|
|
|
57191
57224
|
activeAccountIndex: null,
|
|
57192
57225
|
notes: [],
|
|
57193
57226
|
balances: {},
|
|
57227
|
+
burners: [],
|
|
57194
57228
|
busy: false,
|
|
57195
57229
|
status: "Wallet cleared",
|
|
57196
57230
|
syncError: null,
|
|
@@ -57475,6 +57509,36 @@ function UnlinkProvider({
|
|
|
57475
57509
|
},
|
|
57476
57510
|
[]
|
|
57477
57511
|
);
|
|
57512
|
+
const executeAdapter = useCallback(
|
|
57513
|
+
async (params) => {
|
|
57514
|
+
const wallet = walletRef.current;
|
|
57515
|
+
if (!wallet) throw new Error("SDK not initialized");
|
|
57516
|
+
setState((prev2) => ({
|
|
57517
|
+
...prev2,
|
|
57518
|
+
busy: true,
|
|
57519
|
+
status: "Executing adapter..."
|
|
57520
|
+
}));
|
|
57521
|
+
try {
|
|
57522
|
+
const result = await wallet.adapter.execute(params);
|
|
57523
|
+
setState((prev2) => ({
|
|
57524
|
+
...prev2,
|
|
57525
|
+
busy: false,
|
|
57526
|
+
status: "Adapter execution submitted",
|
|
57527
|
+
error: null
|
|
57528
|
+
}));
|
|
57529
|
+
return result;
|
|
57530
|
+
} catch (err) {
|
|
57531
|
+
setState((prev2) => ({
|
|
57532
|
+
...prev2,
|
|
57533
|
+
busy: false,
|
|
57534
|
+
status: `Error: ${err instanceof Error ? err.message : "Unknown"}`,
|
|
57535
|
+
error: createUnlinkError(err, "executeAdapter")
|
|
57536
|
+
}));
|
|
57537
|
+
throw err;
|
|
57538
|
+
}
|
|
57539
|
+
},
|
|
57540
|
+
[]
|
|
57541
|
+
);
|
|
57478
57542
|
const planWithdraw = useCallback(
|
|
57479
57543
|
async (params) => {
|
|
57480
57544
|
const wallet = walletRef.current;
|
|
@@ -57516,6 +57580,149 @@ function UnlinkProvider({
|
|
|
57516
57580
|
throw err;
|
|
57517
57581
|
}
|
|
57518
57582
|
}, []);
|
|
57583
|
+
const createBurner = useCallback(async (index) => {
|
|
57584
|
+
const wallet = walletRef.current;
|
|
57585
|
+
if (!wallet) throw new Error("SDK not initialized");
|
|
57586
|
+
setState((prev2) => ({
|
|
57587
|
+
...prev2,
|
|
57588
|
+
busy: true,
|
|
57589
|
+
status: `Creating burner ${index}...`
|
|
57590
|
+
}));
|
|
57591
|
+
try {
|
|
57592
|
+
const burner = await wallet.burner.addressOf(index);
|
|
57593
|
+
setState((prev2) => ({
|
|
57594
|
+
...prev2,
|
|
57595
|
+
burners: [
|
|
57596
|
+
...prev2.burners.filter((existing) => existing.index !== burner.index),
|
|
57597
|
+
burner
|
|
57598
|
+
],
|
|
57599
|
+
busy: false,
|
|
57600
|
+
status: `Burner ${index} ready`,
|
|
57601
|
+
error: null
|
|
57602
|
+
}));
|
|
57603
|
+
return burner;
|
|
57604
|
+
} catch (err) {
|
|
57605
|
+
setState((prev2) => ({
|
|
57606
|
+
...prev2,
|
|
57607
|
+
busy: false,
|
|
57608
|
+
status: `Error: ${err instanceof Error ? err.message : "Unknown"}`,
|
|
57609
|
+
error: createUnlinkError(err, "createBurner")
|
|
57610
|
+
}));
|
|
57611
|
+
throw err;
|
|
57612
|
+
}
|
|
57613
|
+
}, []);
|
|
57614
|
+
const removeBurner = useCallback((index) => {
|
|
57615
|
+
setState((prev2) => ({
|
|
57616
|
+
...prev2,
|
|
57617
|
+
burners: prev2.burners.filter((burner) => burner.index !== index)
|
|
57618
|
+
}));
|
|
57619
|
+
}, []);
|
|
57620
|
+
const burnerSend = useCallback(
|
|
57621
|
+
async (index, tx) => {
|
|
57622
|
+
const wallet = walletRef.current;
|
|
57623
|
+
if (!wallet) throw new Error("SDK not initialized");
|
|
57624
|
+
setState((prev2) => ({
|
|
57625
|
+
...prev2,
|
|
57626
|
+
busy: true,
|
|
57627
|
+
status: "Sending burner transaction..."
|
|
57628
|
+
}));
|
|
57629
|
+
try {
|
|
57630
|
+
const result = await wallet.burner.send(index, tx);
|
|
57631
|
+
setState((prev2) => ({
|
|
57632
|
+
...prev2,
|
|
57633
|
+
busy: false,
|
|
57634
|
+
status: "Burner transaction sent",
|
|
57635
|
+
error: null
|
|
57636
|
+
}));
|
|
57637
|
+
return result;
|
|
57638
|
+
} catch (err) {
|
|
57639
|
+
setState((prev2) => ({
|
|
57640
|
+
...prev2,
|
|
57641
|
+
busy: false,
|
|
57642
|
+
status: `Error: ${err instanceof Error ? err.message : "Unknown"}`,
|
|
57643
|
+
error: createUnlinkError(err, "burnerSend")
|
|
57644
|
+
}));
|
|
57645
|
+
throw err;
|
|
57646
|
+
}
|
|
57647
|
+
},
|
|
57648
|
+
[]
|
|
57649
|
+
);
|
|
57650
|
+
const burnerFund = useCallback(
|
|
57651
|
+
async (index, params) => {
|
|
57652
|
+
const wallet = walletRef.current;
|
|
57653
|
+
if (!wallet) throw new Error("SDK not initialized");
|
|
57654
|
+
setState((prev2) => ({
|
|
57655
|
+
...prev2,
|
|
57656
|
+
busy: true,
|
|
57657
|
+
status: "Funding burner..."
|
|
57658
|
+
}));
|
|
57659
|
+
try {
|
|
57660
|
+
const result = await wallet.burner.fund(index, params);
|
|
57661
|
+
setState((prev2) => ({
|
|
57662
|
+
...prev2,
|
|
57663
|
+
busy: false,
|
|
57664
|
+
status: "Burner funded",
|
|
57665
|
+
error: null
|
|
57666
|
+
}));
|
|
57667
|
+
return result;
|
|
57668
|
+
} catch (err) {
|
|
57669
|
+
setState((prev2) => ({
|
|
57670
|
+
...prev2,
|
|
57671
|
+
busy: false,
|
|
57672
|
+
status: `Error: ${err instanceof Error ? err.message : "Unknown"}`,
|
|
57673
|
+
error: createUnlinkError(err, "burnerFund")
|
|
57674
|
+
}));
|
|
57675
|
+
throw err;
|
|
57676
|
+
}
|
|
57677
|
+
},
|
|
57678
|
+
[]
|
|
57679
|
+
);
|
|
57680
|
+
const burnerSweepToPool = useCallback(
|
|
57681
|
+
async (index, params) => {
|
|
57682
|
+
const wallet = walletRef.current;
|
|
57683
|
+
if (!wallet) throw new Error("SDK not initialized");
|
|
57684
|
+
setState((prev2) => ({
|
|
57685
|
+
...prev2,
|
|
57686
|
+
busy: true,
|
|
57687
|
+
status: "Sweeping burner to pool..."
|
|
57688
|
+
}));
|
|
57689
|
+
try {
|
|
57690
|
+
const result = await wallet.burner.sweepToPool(index, params);
|
|
57691
|
+
setState((prev2) => ({
|
|
57692
|
+
...prev2,
|
|
57693
|
+
busy: false,
|
|
57694
|
+
status: "Burner sweep submitted",
|
|
57695
|
+
error: null
|
|
57696
|
+
}));
|
|
57697
|
+
return result;
|
|
57698
|
+
} catch (err) {
|
|
57699
|
+
setState((prev2) => ({
|
|
57700
|
+
...prev2,
|
|
57701
|
+
busy: false,
|
|
57702
|
+
status: `Error: ${err instanceof Error ? err.message : "Unknown"}`,
|
|
57703
|
+
error: createUnlinkError(err, "burnerSweepToPool")
|
|
57704
|
+
}));
|
|
57705
|
+
throw err;
|
|
57706
|
+
}
|
|
57707
|
+
},
|
|
57708
|
+
[]
|
|
57709
|
+
);
|
|
57710
|
+
const burnerGetTokenBalance = useCallback(
|
|
57711
|
+
async (address, token) => {
|
|
57712
|
+
const wallet = walletRef.current;
|
|
57713
|
+
if (!wallet) throw new Error("SDK not initialized");
|
|
57714
|
+
return wallet.burner.getTokenBalance(address, token);
|
|
57715
|
+
},
|
|
57716
|
+
[]
|
|
57717
|
+
);
|
|
57718
|
+
const burnerGetBalance = useCallback(
|
|
57719
|
+
async (address) => {
|
|
57720
|
+
const wallet = walletRef.current;
|
|
57721
|
+
if (!wallet) throw new Error("SDK not initialized");
|
|
57722
|
+
return wallet.burner.getBalance(address);
|
|
57723
|
+
},
|
|
57724
|
+
[]
|
|
57725
|
+
);
|
|
57519
57726
|
const refresh = useCallback(async () => {
|
|
57520
57727
|
const wallet = walletRef.current;
|
|
57521
57728
|
if (!wallet) return;
|
|
@@ -57631,7 +57838,6 @@ function UnlinkProvider({
|
|
|
57631
57838
|
const value = useMemo(
|
|
57632
57839
|
() => ({
|
|
57633
57840
|
...state,
|
|
57634
|
-
chainId,
|
|
57635
57841
|
// Wallet actions
|
|
57636
57842
|
createWallet,
|
|
57637
57843
|
importWallet,
|
|
@@ -57648,8 +57854,18 @@ function UnlinkProvider({
|
|
|
57648
57854
|
requestDeposit,
|
|
57649
57855
|
// Withdraw actions
|
|
57650
57856
|
requestWithdraw,
|
|
57857
|
+
// Adapter actions
|
|
57858
|
+
executeAdapter,
|
|
57651
57859
|
planWithdraw,
|
|
57652
57860
|
executeWithdraw,
|
|
57861
|
+
// Burner actions
|
|
57862
|
+
createBurner,
|
|
57863
|
+
removeBurner,
|
|
57864
|
+
burnerSend,
|
|
57865
|
+
burnerFund,
|
|
57866
|
+
burnerSweepToPool,
|
|
57867
|
+
burnerGetTokenBalance,
|
|
57868
|
+
burnerGetBalance,
|
|
57653
57869
|
// Sync actions
|
|
57654
57870
|
refresh,
|
|
57655
57871
|
forceResync,
|
|
@@ -57661,7 +57877,6 @@ function UnlinkProvider({
|
|
|
57661
57877
|
}),
|
|
57662
57878
|
[
|
|
57663
57879
|
state,
|
|
57664
|
-
chainId,
|
|
57665
57880
|
createWallet,
|
|
57666
57881
|
importWallet,
|
|
57667
57882
|
exportMnemonic,
|
|
@@ -57673,8 +57888,16 @@ function UnlinkProvider({
|
|
|
57673
57888
|
executeTransfer,
|
|
57674
57889
|
requestDeposit,
|
|
57675
57890
|
requestWithdraw,
|
|
57891
|
+
executeAdapter,
|
|
57676
57892
|
planWithdraw,
|
|
57677
57893
|
executeWithdraw,
|
|
57894
|
+
createBurner,
|
|
57895
|
+
removeBurner,
|
|
57896
|
+
burnerSend,
|
|
57897
|
+
burnerFund,
|
|
57898
|
+
burnerSweepToPool,
|
|
57899
|
+
burnerGetTokenBalance,
|
|
57900
|
+
burnerGetBalance,
|
|
57678
57901
|
refresh,
|
|
57679
57902
|
forceResync,
|
|
57680
57903
|
clearError,
|
|
@@ -57910,6 +58133,57 @@ function useWithdraw() {
|
|
|
57910
58133
|
);
|
|
57911
58134
|
return useOperationMutation(op);
|
|
57912
58135
|
}
|
|
58136
|
+
|
|
58137
|
+
// src/useAdapter.ts
|
|
58138
|
+
import { useCallback as useCallback8 } from "react";
|
|
58139
|
+
function useAdapter() {
|
|
58140
|
+
const { executeAdapter } = useUnlink();
|
|
58141
|
+
const op = useCallback8(
|
|
58142
|
+
(params) => executeAdapter(params),
|
|
58143
|
+
[executeAdapter]
|
|
58144
|
+
);
|
|
58145
|
+
return useOperationMutation(op);
|
|
58146
|
+
}
|
|
58147
|
+
|
|
58148
|
+
// src/useBurner.ts
|
|
58149
|
+
import { useCallback as useCallback9 } from "react";
|
|
58150
|
+
function useBurner() {
|
|
58151
|
+
const {
|
|
58152
|
+
burners,
|
|
58153
|
+
createBurner,
|
|
58154
|
+
removeBurner,
|
|
58155
|
+
burnerSend,
|
|
58156
|
+
burnerFund,
|
|
58157
|
+
burnerSweepToPool,
|
|
58158
|
+
burnerGetTokenBalance,
|
|
58159
|
+
burnerGetBalance
|
|
58160
|
+
} = useUnlink();
|
|
58161
|
+
const sendOp = useCallback9(
|
|
58162
|
+
(input) => burnerSend(input.index, input.tx),
|
|
58163
|
+
[burnerSend]
|
|
58164
|
+
);
|
|
58165
|
+
const fundOp = useCallback9(
|
|
58166
|
+
(input) => burnerFund(input.index, input.params),
|
|
58167
|
+
[burnerFund]
|
|
58168
|
+
);
|
|
58169
|
+
const sweepOp = useCallback9(
|
|
58170
|
+
(input) => burnerSweepToPool(input.index, input.params),
|
|
58171
|
+
[burnerSweepToPool]
|
|
58172
|
+
);
|
|
58173
|
+
const send = useOperationMutation(sendOp);
|
|
58174
|
+
const fund = useOperationMutation(fundOp);
|
|
58175
|
+
const sweepToPool = useOperationMutation(sweepOp);
|
|
58176
|
+
return {
|
|
58177
|
+
burners,
|
|
58178
|
+
createBurner,
|
|
58179
|
+
removeBurner,
|
|
58180
|
+
send,
|
|
58181
|
+
fund,
|
|
58182
|
+
sweepToPool,
|
|
58183
|
+
getTokenBalance: burnerGetTokenBalance,
|
|
58184
|
+
getBalance: burnerGetBalance
|
|
58185
|
+
};
|
|
58186
|
+
}
|
|
57913
58187
|
export {
|
|
57914
58188
|
CONFIRMATION_POLL_INTERVAL_MS,
|
|
57915
58189
|
DEFAULT_CONFIRMATION_TIMEOUT_MS,
|
|
@@ -57926,6 +58200,8 @@ export {
|
|
|
57926
58200
|
parseZkAddress,
|
|
57927
58201
|
randomHex,
|
|
57928
58202
|
shortenHex,
|
|
58203
|
+
useAdapter,
|
|
58204
|
+
useBurner,
|
|
57929
58205
|
useDeposit,
|
|
57930
58206
|
useOperationMutation,
|
|
57931
58207
|
useTransfer,
|