@unlink-xyz/react 0.1.6 → 0.1.8
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 +50 -40
- package/dist/index.js +449 -334
- package/dist/index.js.map +1 -1
- package/dist/multisig/index.d.ts +1 -1
- package/dist/multisig/index.js +70 -70
- package/dist/multisig/index.js.map +1 -1
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -28352,8 +28352,8 @@ var ContractUnknownEventPayload = class extends EventPayload {
|
|
|
28352
28352
|
/**
|
|
28353
28353
|
* @_event:
|
|
28354
28354
|
*/
|
|
28355
|
-
constructor(
|
|
28356
|
-
super(
|
|
28355
|
+
constructor(contract2, listener, filter, log) {
|
|
28356
|
+
super(contract2, listener, filter);
|
|
28357
28357
|
defineProperties(this, { log });
|
|
28358
28358
|
}
|
|
28359
28359
|
/**
|
|
@@ -28379,9 +28379,9 @@ var ContractEventPayload = class extends ContractUnknownEventPayload {
|
|
|
28379
28379
|
/**
|
|
28380
28380
|
* @_ignore:
|
|
28381
28381
|
*/
|
|
28382
|
-
constructor(
|
|
28383
|
-
super(
|
|
28384
|
-
const args =
|
|
28382
|
+
constructor(contract2, listener, filter, fragment, _log) {
|
|
28383
|
+
super(contract2, listener, filter, new EventLog(_log, contract2.interface, fragment));
|
|
28384
|
+
const args = contract2.interface.decodeEventLog(fragment, this.log.data, this.log.topics);
|
|
28385
28385
|
defineProperties(this, { args, fragment });
|
|
28386
28386
|
}
|
|
28387
28387
|
/**
|
|
@@ -28424,12 +28424,12 @@ function getResolver(value) {
|
|
|
28424
28424
|
var PreparedTopicFilter = class {
|
|
28425
28425
|
#filter;
|
|
28426
28426
|
fragment;
|
|
28427
|
-
constructor(
|
|
28427
|
+
constructor(contract2, fragment, args) {
|
|
28428
28428
|
defineProperties(this, { fragment });
|
|
28429
28429
|
if (fragment.inputs.length < args.length) {
|
|
28430
28430
|
throw new Error("too many arguments");
|
|
28431
28431
|
}
|
|
28432
|
-
const runner = getRunner(
|
|
28432
|
+
const runner = getRunner(contract2.runner, "resolveName");
|
|
28433
28433
|
const resolver = canResolve(runner) ? runner : null;
|
|
28434
28434
|
this.#filter = (async function() {
|
|
28435
28435
|
const resolvedArgs = await Promise.all(fragment.inputs.map((param, index) => {
|
|
@@ -28447,7 +28447,7 @@ var PreparedTopicFilter = class {
|
|
|
28447
28447
|
return value;
|
|
28448
28448
|
});
|
|
28449
28449
|
}));
|
|
28450
|
-
return
|
|
28450
|
+
return contract2.interface.encodeFilterTopics(fragment, resolvedArgs);
|
|
28451
28451
|
})();
|
|
28452
28452
|
}
|
|
28453
28453
|
getTopicFilter() {
|
|
@@ -28496,14 +28496,14 @@ async function resolveArgs(_runner, inputs, args) {
|
|
|
28496
28496
|
});
|
|
28497
28497
|
}));
|
|
28498
28498
|
}
|
|
28499
|
-
function buildWrappedFallback(
|
|
28499
|
+
function buildWrappedFallback(contract2) {
|
|
28500
28500
|
const populateTransaction = async function(overrides) {
|
|
28501
28501
|
const tx = await copyOverrides(overrides, ["data"]);
|
|
28502
|
-
tx.to = await
|
|
28502
|
+
tx.to = await contract2.getAddress();
|
|
28503
28503
|
if (tx.from) {
|
|
28504
|
-
tx.from = await resolveAddress(tx.from, getResolver(
|
|
28504
|
+
tx.from = await resolveAddress(tx.from, getResolver(contract2.runner));
|
|
28505
28505
|
}
|
|
28506
|
-
const iface =
|
|
28506
|
+
const iface = contract2.interface;
|
|
28507
28507
|
const noValue = getBigInt(tx.value || BN_09, "overrides.value") === BN_09;
|
|
28508
28508
|
const noData = (tx.data || "0x") === "0x";
|
|
28509
28509
|
if (iface.fallback && !iface.fallback.payable && iface.receive && !noData && !noValue) {
|
|
@@ -28516,27 +28516,27 @@ function buildWrappedFallback(contract) {
|
|
|
28516
28516
|
return tx;
|
|
28517
28517
|
};
|
|
28518
28518
|
const staticCall = async function(overrides) {
|
|
28519
|
-
const runner = getRunner(
|
|
28519
|
+
const runner = getRunner(contract2.runner, "call");
|
|
28520
28520
|
assert(canCall(runner), "contract runner does not support calling", "UNSUPPORTED_OPERATION", { operation: "call" });
|
|
28521
28521
|
const tx = await populateTransaction(overrides);
|
|
28522
28522
|
try {
|
|
28523
28523
|
return await runner.call(tx);
|
|
28524
28524
|
} catch (error) {
|
|
28525
28525
|
if (isCallException(error) && error.data) {
|
|
28526
|
-
throw
|
|
28526
|
+
throw contract2.interface.makeError(error.data, tx);
|
|
28527
28527
|
}
|
|
28528
28528
|
throw error;
|
|
28529
28529
|
}
|
|
28530
28530
|
};
|
|
28531
28531
|
const send = async function(overrides) {
|
|
28532
|
-
const runner =
|
|
28532
|
+
const runner = contract2.runner;
|
|
28533
28533
|
assert(canSend(runner), "contract runner does not support sending transactions", "UNSUPPORTED_OPERATION", { operation: "sendTransaction" });
|
|
28534
28534
|
const tx = await runner.sendTransaction(await populateTransaction(overrides));
|
|
28535
|
-
const provider = getProvider(
|
|
28536
|
-
return new ContractTransactionResponse(
|
|
28535
|
+
const provider = getProvider(contract2.runner);
|
|
28536
|
+
return new ContractTransactionResponse(contract2.interface, provider, tx);
|
|
28537
28537
|
};
|
|
28538
28538
|
const estimateGas = async function(overrides) {
|
|
28539
|
-
const runner = getRunner(
|
|
28539
|
+
const runner = getRunner(contract2.runner, "estimateGas");
|
|
28540
28540
|
assert(canEstimate(runner), "contract runner does not support gas estimation", "UNSUPPORTED_OPERATION", { operation: "estimateGas" });
|
|
28541
28541
|
return await runner.estimateGas(await populateTransaction(overrides));
|
|
28542
28542
|
};
|
|
@@ -28544,7 +28544,7 @@ function buildWrappedFallback(contract) {
|
|
|
28544
28544
|
return await send(overrides);
|
|
28545
28545
|
};
|
|
28546
28546
|
defineProperties(method, {
|
|
28547
|
-
_contract:
|
|
28547
|
+
_contract: contract2,
|
|
28548
28548
|
estimateGas,
|
|
28549
28549
|
populateTransaction,
|
|
28550
28550
|
send,
|
|
@@ -28552,9 +28552,9 @@ function buildWrappedFallback(contract) {
|
|
|
28552
28552
|
});
|
|
28553
28553
|
return method;
|
|
28554
28554
|
}
|
|
28555
|
-
function buildWrappedMethod(
|
|
28555
|
+
function buildWrappedMethod(contract2, key) {
|
|
28556
28556
|
const getFragment = function(...args) {
|
|
28557
|
-
const fragment =
|
|
28557
|
+
const fragment = contract2.interface.getFunction(key, args);
|
|
28558
28558
|
assert(fragment, "no matching fragment", "UNSUPPORTED_OPERATION", {
|
|
28559
28559
|
operation: "fragment",
|
|
28560
28560
|
info: { key, args }
|
|
@@ -28567,16 +28567,16 @@ function buildWrappedMethod(contract, key) {
|
|
|
28567
28567
|
if (fragment.inputs.length + 1 === args.length) {
|
|
28568
28568
|
overrides = await copyOverrides(args.pop());
|
|
28569
28569
|
if (overrides.from) {
|
|
28570
|
-
overrides.from = await resolveAddress(overrides.from, getResolver(
|
|
28570
|
+
overrides.from = await resolveAddress(overrides.from, getResolver(contract2.runner));
|
|
28571
28571
|
}
|
|
28572
28572
|
}
|
|
28573
28573
|
if (fragment.inputs.length !== args.length) {
|
|
28574
28574
|
throw new Error("internal error: fragment inputs doesn't match arguments; should not happen");
|
|
28575
28575
|
}
|
|
28576
|
-
const resolvedArgs = await resolveArgs(
|
|
28576
|
+
const resolvedArgs = await resolveArgs(contract2.runner, fragment.inputs, args);
|
|
28577
28577
|
return Object.assign({}, overrides, await resolveProperties({
|
|
28578
|
-
to:
|
|
28579
|
-
data:
|
|
28578
|
+
to: contract2.getAddress(),
|
|
28579
|
+
data: contract2.interface.encodeFunctionData(fragment, resolvedArgs)
|
|
28580
28580
|
}));
|
|
28581
28581
|
};
|
|
28582
28582
|
const staticCall = async function(...args) {
|
|
@@ -28587,19 +28587,19 @@ function buildWrappedMethod(contract, key) {
|
|
|
28587
28587
|
return result;
|
|
28588
28588
|
};
|
|
28589
28589
|
const send = async function(...args) {
|
|
28590
|
-
const runner =
|
|
28590
|
+
const runner = contract2.runner;
|
|
28591
28591
|
assert(canSend(runner), "contract runner does not support sending transactions", "UNSUPPORTED_OPERATION", { operation: "sendTransaction" });
|
|
28592
28592
|
const tx = await runner.sendTransaction(await populateTransaction(...args));
|
|
28593
|
-
const provider = getProvider(
|
|
28594
|
-
return new ContractTransactionResponse(
|
|
28593
|
+
const provider = getProvider(contract2.runner);
|
|
28594
|
+
return new ContractTransactionResponse(contract2.interface, provider, tx);
|
|
28595
28595
|
};
|
|
28596
28596
|
const estimateGas = async function(...args) {
|
|
28597
|
-
const runner = getRunner(
|
|
28597
|
+
const runner = getRunner(contract2.runner, "estimateGas");
|
|
28598
28598
|
assert(canEstimate(runner), "contract runner does not support gas estimation", "UNSUPPORTED_OPERATION", { operation: "estimateGas" });
|
|
28599
28599
|
return await runner.estimateGas(await populateTransaction(...args));
|
|
28600
28600
|
};
|
|
28601
28601
|
const staticCallResult = async function(...args) {
|
|
28602
|
-
const runner = getRunner(
|
|
28602
|
+
const runner = getRunner(contract2.runner, "call");
|
|
28603
28603
|
assert(canCall(runner), "contract runner does not support calling", "UNSUPPORTED_OPERATION", { operation: "call" });
|
|
28604
28604
|
const tx = await populateTransaction(...args);
|
|
28605
28605
|
let result = "0x";
|
|
@@ -28607,12 +28607,12 @@ function buildWrappedMethod(contract, key) {
|
|
|
28607
28607
|
result = await runner.call(tx);
|
|
28608
28608
|
} catch (error) {
|
|
28609
28609
|
if (isCallException(error) && error.data) {
|
|
28610
|
-
throw
|
|
28610
|
+
throw contract2.interface.makeError(error.data, tx);
|
|
28611
28611
|
}
|
|
28612
28612
|
throw error;
|
|
28613
28613
|
}
|
|
28614
28614
|
const fragment = getFragment(...args);
|
|
28615
|
-
return
|
|
28615
|
+
return contract2.interface.decodeFunctionResult(fragment, result);
|
|
28616
28616
|
};
|
|
28617
28617
|
const method = async (...args) => {
|
|
28618
28618
|
const fragment = getFragment(...args);
|
|
@@ -28622,8 +28622,8 @@ function buildWrappedMethod(contract, key) {
|
|
|
28622
28622
|
return await send(...args);
|
|
28623
28623
|
};
|
|
28624
28624
|
defineProperties(method, {
|
|
28625
|
-
name:
|
|
28626
|
-
_contract:
|
|
28625
|
+
name: contract2.interface.getFunctionName(key),
|
|
28626
|
+
_contract: contract2,
|
|
28627
28627
|
_key: key,
|
|
28628
28628
|
getFragment,
|
|
28629
28629
|
estimateGas,
|
|
@@ -28636,7 +28636,7 @@ function buildWrappedMethod(contract, key) {
|
|
|
28636
28636
|
configurable: false,
|
|
28637
28637
|
enumerable: true,
|
|
28638
28638
|
get: () => {
|
|
28639
|
-
const fragment =
|
|
28639
|
+
const fragment = contract2.interface.getFunction(key);
|
|
28640
28640
|
assert(fragment, "no matching fragment", "UNSUPPORTED_OPERATION", {
|
|
28641
28641
|
operation: "fragment",
|
|
28642
28642
|
info: { key }
|
|
@@ -28646,9 +28646,9 @@ function buildWrappedMethod(contract, key) {
|
|
|
28646
28646
|
});
|
|
28647
28647
|
return method;
|
|
28648
28648
|
}
|
|
28649
|
-
function buildWrappedEvent(
|
|
28649
|
+
function buildWrappedEvent(contract2, key) {
|
|
28650
28650
|
const getFragment = function(...args) {
|
|
28651
|
-
const fragment =
|
|
28651
|
+
const fragment = contract2.interface.getEvent(key, args);
|
|
28652
28652
|
assert(fragment, "no matching fragment", "UNSUPPORTED_OPERATION", {
|
|
28653
28653
|
operation: "fragment",
|
|
28654
28654
|
info: { key, args }
|
|
@@ -28656,11 +28656,11 @@ function buildWrappedEvent(contract, key) {
|
|
|
28656
28656
|
return fragment;
|
|
28657
28657
|
};
|
|
28658
28658
|
const method = function(...args) {
|
|
28659
|
-
return new PreparedTopicFilter(
|
|
28659
|
+
return new PreparedTopicFilter(contract2, getFragment(...args), args);
|
|
28660
28660
|
};
|
|
28661
28661
|
defineProperties(method, {
|
|
28662
|
-
name:
|
|
28663
|
-
_contract:
|
|
28662
|
+
name: contract2.interface.getEventName(key),
|
|
28663
|
+
_contract: contract2,
|
|
28664
28664
|
_key: key,
|
|
28665
28665
|
getFragment
|
|
28666
28666
|
});
|
|
@@ -28668,7 +28668,7 @@ function buildWrappedEvent(contract, key) {
|
|
|
28668
28668
|
configurable: false,
|
|
28669
28669
|
enumerable: true,
|
|
28670
28670
|
get: () => {
|
|
28671
|
-
const fragment =
|
|
28671
|
+
const fragment = contract2.interface.getEvent(key);
|
|
28672
28672
|
assert(fragment, "no matching fragment", "UNSUPPORTED_OPERATION", {
|
|
28673
28673
|
operation: "fragment",
|
|
28674
28674
|
info: { key }
|
|
@@ -28680,16 +28680,16 @@ function buildWrappedEvent(contract, key) {
|
|
|
28680
28680
|
}
|
|
28681
28681
|
var internal2 = /* @__PURE__ */ Symbol.for("_ethersInternal_contract");
|
|
28682
28682
|
var internalValues = /* @__PURE__ */ new WeakMap();
|
|
28683
|
-
function setInternal(
|
|
28684
|
-
internalValues.set(
|
|
28683
|
+
function setInternal(contract2, values) {
|
|
28684
|
+
internalValues.set(contract2[internal2], values);
|
|
28685
28685
|
}
|
|
28686
|
-
function getInternal(
|
|
28687
|
-
return internalValues.get(
|
|
28686
|
+
function getInternal(contract2) {
|
|
28687
|
+
return internalValues.get(contract2[internal2]);
|
|
28688
28688
|
}
|
|
28689
28689
|
function isDeferred(value) {
|
|
28690
28690
|
return value && typeof value === "object" && "getTopicFilter" in value && typeof value.getTopicFilter === "function" && value.fragment;
|
|
28691
28691
|
}
|
|
28692
|
-
async function getSubInfo(
|
|
28692
|
+
async function getSubInfo(contract2, event) {
|
|
28693
28693
|
let topics;
|
|
28694
28694
|
let fragment = null;
|
|
28695
28695
|
if (Array.isArray(event)) {
|
|
@@ -28697,7 +28697,7 @@ async function getSubInfo(contract, event) {
|
|
|
28697
28697
|
if (isHexString(name, 32)) {
|
|
28698
28698
|
return name;
|
|
28699
28699
|
}
|
|
28700
|
-
const fragment2 =
|
|
28700
|
+
const fragment2 = contract2.interface.getEvent(name);
|
|
28701
28701
|
assertArgument(fragment2, "unknown fragment", "name", name);
|
|
28702
28702
|
return fragment2.topicHash;
|
|
28703
28703
|
};
|
|
@@ -28716,7 +28716,7 @@ async function getSubInfo(contract, event) {
|
|
|
28716
28716
|
if (isHexString(event, 32)) {
|
|
28717
28717
|
topics = [event];
|
|
28718
28718
|
} else {
|
|
28719
|
-
fragment =
|
|
28719
|
+
fragment = contract2.interface.getEvent(event);
|
|
28720
28720
|
assertArgument(fragment, "unknown fragment", "event", event);
|
|
28721
28721
|
topics = [fragment.topicHash];
|
|
28722
28722
|
}
|
|
@@ -28753,36 +28753,36 @@ async function getSubInfo(contract, event) {
|
|
|
28753
28753
|
}).join("&");
|
|
28754
28754
|
return { fragment, tag, topics };
|
|
28755
28755
|
}
|
|
28756
|
-
async function hasSub(
|
|
28757
|
-
const { subs } = getInternal(
|
|
28758
|
-
return subs.get((await getSubInfo(
|
|
28756
|
+
async function hasSub(contract2, event) {
|
|
28757
|
+
const { subs } = getInternal(contract2);
|
|
28758
|
+
return subs.get((await getSubInfo(contract2, event)).tag) || null;
|
|
28759
28759
|
}
|
|
28760
|
-
async function getSub(
|
|
28761
|
-
const provider = getProvider(
|
|
28760
|
+
async function getSub(contract2, operation, event) {
|
|
28761
|
+
const provider = getProvider(contract2.runner);
|
|
28762
28762
|
assert(provider, "contract runner does not support subscribing", "UNSUPPORTED_OPERATION", { operation });
|
|
28763
|
-
const { fragment, tag, topics } = await getSubInfo(
|
|
28764
|
-
const { addr, subs } = getInternal(
|
|
28763
|
+
const { fragment, tag, topics } = await getSubInfo(contract2, event);
|
|
28764
|
+
const { addr, subs } = getInternal(contract2);
|
|
28765
28765
|
let sub2 = subs.get(tag);
|
|
28766
28766
|
if (!sub2) {
|
|
28767
|
-
const address = addr ? addr :
|
|
28767
|
+
const address = addr ? addr : contract2;
|
|
28768
28768
|
const filter = { address, topics };
|
|
28769
28769
|
const listener = (log) => {
|
|
28770
28770
|
let foundFragment = fragment;
|
|
28771
28771
|
if (foundFragment == null) {
|
|
28772
28772
|
try {
|
|
28773
|
-
foundFragment =
|
|
28773
|
+
foundFragment = contract2.interface.getEvent(log.topics[0]);
|
|
28774
28774
|
} catch (error) {
|
|
28775
28775
|
}
|
|
28776
28776
|
}
|
|
28777
28777
|
if (foundFragment) {
|
|
28778
28778
|
const _foundFragment = foundFragment;
|
|
28779
|
-
const args = fragment ?
|
|
28780
|
-
emit22(
|
|
28781
|
-
return new ContractEventPayload(
|
|
28779
|
+
const args = fragment ? contract2.interface.decodeEventLog(fragment, log.data, log.topics) : [];
|
|
28780
|
+
emit22(contract2, event, args, (listener2) => {
|
|
28781
|
+
return new ContractEventPayload(contract2, listener2, event, _foundFragment, log);
|
|
28782
28782
|
});
|
|
28783
28783
|
} else {
|
|
28784
|
-
emit22(
|
|
28785
|
-
return new ContractUnknownEventPayload(
|
|
28784
|
+
emit22(contract2, event, [], (listener2) => {
|
|
28785
|
+
return new ContractUnknownEventPayload(contract2, listener2, event, log);
|
|
28786
28786
|
});
|
|
28787
28787
|
}
|
|
28788
28788
|
};
|
|
@@ -28808,9 +28808,9 @@ async function getSub(contract, operation, event) {
|
|
|
28808
28808
|
return sub2;
|
|
28809
28809
|
}
|
|
28810
28810
|
var lastEmit = Promise.resolve();
|
|
28811
|
-
async function _emit(
|
|
28811
|
+
async function _emit(contract2, event, args, payloadFunc) {
|
|
28812
28812
|
await lastEmit;
|
|
28813
|
-
const sub2 = await hasSub(
|
|
28813
|
+
const sub2 = await hasSub(contract2, event);
|
|
28814
28814
|
if (!sub2) {
|
|
28815
28815
|
return false;
|
|
28816
28816
|
}
|
|
@@ -28821,23 +28821,23 @@ async function _emit(contract, event, args, payloadFunc) {
|
|
|
28821
28821
|
passArgs.push(payloadFunc(once22 ? null : listener));
|
|
28822
28822
|
}
|
|
28823
28823
|
try {
|
|
28824
|
-
listener.call(
|
|
28824
|
+
listener.call(contract2, ...passArgs);
|
|
28825
28825
|
} catch (error) {
|
|
28826
28826
|
}
|
|
28827
28827
|
return !once22;
|
|
28828
28828
|
});
|
|
28829
28829
|
if (sub2.listeners.length === 0) {
|
|
28830
28830
|
sub2.stop();
|
|
28831
|
-
getInternal(
|
|
28831
|
+
getInternal(contract2).subs.delete(sub2.tag);
|
|
28832
28832
|
}
|
|
28833
28833
|
return count > 0;
|
|
28834
28834
|
}
|
|
28835
|
-
async function emit22(
|
|
28835
|
+
async function emit22(contract2, event, args, payloadFunc) {
|
|
28836
28836
|
try {
|
|
28837
28837
|
await lastEmit;
|
|
28838
28838
|
} catch (error) {
|
|
28839
28839
|
}
|
|
28840
|
-
const resultPromise = _emit(
|
|
28840
|
+
const resultPromise = _emit(contract2, event, args, payloadFunc);
|
|
28841
28841
|
lastEmit = resultPromise;
|
|
28842
28842
|
return await resultPromise;
|
|
28843
28843
|
}
|
|
@@ -29263,8 +29263,8 @@ var BaseContract = class _BaseContract {
|
|
|
29263
29263
|
if (runner == null) {
|
|
29264
29264
|
runner = null;
|
|
29265
29265
|
}
|
|
29266
|
-
const
|
|
29267
|
-
return
|
|
29266
|
+
const contract2 = new this(target, abi, runner);
|
|
29267
|
+
return contract2;
|
|
29268
29268
|
}
|
|
29269
29269
|
};
|
|
29270
29270
|
function _ContractBase() {
|
|
@@ -29559,7 +29559,7 @@ var EnsResolver = class _EnsResolver {
|
|
|
29559
29559
|
return { url: null, linkage };
|
|
29560
29560
|
}
|
|
29561
29561
|
const tokenId = comps[1];
|
|
29562
|
-
const
|
|
29562
|
+
const contract2 = new Contract(comps[0], [
|
|
29563
29563
|
// ERC-721
|
|
29564
29564
|
"function tokenURI(uint) view returns (string)",
|
|
29565
29565
|
"function ownerOf(uint) view returns (address)",
|
|
@@ -29568,21 +29568,21 @@ var EnsResolver = class _EnsResolver {
|
|
|
29568
29568
|
"function balanceOf(address, uint256) view returns (uint)"
|
|
29569
29569
|
], this.provider);
|
|
29570
29570
|
if (scheme === "erc721") {
|
|
29571
|
-
const tokenOwner = await
|
|
29571
|
+
const tokenOwner = await contract2.ownerOf(tokenId);
|
|
29572
29572
|
if (owner !== tokenOwner) {
|
|
29573
29573
|
linkage.push({ type: "!owner", value: tokenOwner });
|
|
29574
29574
|
return { url: null, linkage };
|
|
29575
29575
|
}
|
|
29576
29576
|
linkage.push({ type: "owner", value: tokenOwner });
|
|
29577
29577
|
} else if (scheme === "erc1155") {
|
|
29578
|
-
const balance = await
|
|
29578
|
+
const balance = await contract2.balanceOf(owner, tokenId);
|
|
29579
29579
|
if (!balance) {
|
|
29580
29580
|
linkage.push({ type: "!balance", value: "0" });
|
|
29581
29581
|
return { url: null, linkage };
|
|
29582
29582
|
}
|
|
29583
29583
|
linkage.push({ type: "balance", value: balance.toString() });
|
|
29584
29584
|
}
|
|
29585
|
-
let metadataUrl = await
|
|
29585
|
+
let metadataUrl = await contract2[selector](tokenId);
|
|
29586
29586
|
if (metadataUrl == null || metadataUrl === "0x") {
|
|
29587
29587
|
linkage.push({ type: "!metadata-url", value: "" });
|
|
29588
29588
|
return { url: null, linkage };
|
|
@@ -29654,10 +29654,10 @@ var EnsResolver = class _EnsResolver {
|
|
|
29654
29654
|
static async #getResolver(provider, name) {
|
|
29655
29655
|
const ensAddr = await _EnsResolver.getEnsAddress(provider);
|
|
29656
29656
|
try {
|
|
29657
|
-
const
|
|
29657
|
+
const contract2 = new Contract(ensAddr, [
|
|
29658
29658
|
"function resolver(bytes32) view returns (address)"
|
|
29659
29659
|
], provider);
|
|
29660
|
-
const addr = await
|
|
29660
|
+
const addr = await contract2.resolver(namehash(name), {
|
|
29661
29661
|
enableCcipRead: true
|
|
29662
29662
|
});
|
|
29663
29663
|
if (addr === ZeroAddress) {
|
|
@@ -35931,6 +35931,11 @@ function parseChainConfig(chain2, value) {
|
|
|
35931
35931
|
"artifactVersion",
|
|
35932
35932
|
raw.artifactVersion
|
|
35933
35933
|
).replace(/^\/+|\/+$/g, "");
|
|
35934
|
+
const adapterAddress = parseOptionalString(
|
|
35935
|
+
chain2,
|
|
35936
|
+
"adapterAddress",
|
|
35937
|
+
raw.adapterAddress
|
|
35938
|
+
);
|
|
35934
35939
|
const frostUrl = parseOptionalString(
|
|
35935
35940
|
chain2,
|
|
35936
35941
|
"frostUrl",
|
|
@@ -35941,13 +35946,33 @@ function parseChainConfig(chain2, value) {
|
|
|
35941
35946
|
"artifactBaseUrl",
|
|
35942
35947
|
raw.artifactBaseUrl
|
|
35943
35948
|
)?.replace(/\/+$/, "");
|
|
35949
|
+
let tokenAddresses;
|
|
35950
|
+
if (raw.tokenAddresses !== void 0) {
|
|
35951
|
+
if (raw.tokenAddresses === null || typeof raw.tokenAddresses !== "object" || Array.isArray(raw.tokenAddresses)) {
|
|
35952
|
+
throw new InitializationError(
|
|
35953
|
+
`Invalid SDK config for ${chain2}: tokenAddresses must be an object`
|
|
35954
|
+
);
|
|
35955
|
+
}
|
|
35956
|
+
tokenAddresses = {};
|
|
35957
|
+
for (const [name, addr] of Object.entries(
|
|
35958
|
+
raw.tokenAddresses
|
|
35959
|
+
)) {
|
|
35960
|
+
tokenAddresses[name] = parseRequiredString(
|
|
35961
|
+
chain2,
|
|
35962
|
+
`tokenAddresses.${name}`,
|
|
35963
|
+
addr
|
|
35964
|
+
);
|
|
35965
|
+
}
|
|
35966
|
+
}
|
|
35944
35967
|
return {
|
|
35945
35968
|
chainId,
|
|
35946
35969
|
gatewayUrl,
|
|
35947
35970
|
...frostUrl !== void 0 ? { frostUrl } : {},
|
|
35948
35971
|
poolAddress,
|
|
35972
|
+
...adapterAddress !== void 0 ? { adapterAddress } : {},
|
|
35949
35973
|
artifactVersion,
|
|
35950
|
-
...artifactBaseUrl !== void 0 ? { artifactBaseUrl } : { artifactBaseUrl: DEFAULT_ARTIFACT_BASE_URL }
|
|
35974
|
+
...artifactBaseUrl !== void 0 ? { artifactBaseUrl } : { artifactBaseUrl: DEFAULT_ARTIFACT_BASE_URL },
|
|
35975
|
+
...tokenAddresses !== void 0 ? { tokenAddresses } : {}
|
|
35951
35976
|
};
|
|
35952
35977
|
}
|
|
35953
35978
|
async function fetchChainConfig(chain2) {
|
|
@@ -54308,6 +54333,58 @@ function normalizeReshield(reshield, index) {
|
|
|
54308
54333
|
);
|
|
54309
54334
|
return { npk, random, token, minAmount };
|
|
54310
54335
|
}
|
|
54336
|
+
function approve(token, spender, amount) {
|
|
54337
|
+
const normalizedToken = ensureAddress("token", token);
|
|
54338
|
+
const normalizedSpender = ensureAddress("spender", spender);
|
|
54339
|
+
const normalizedAmount = ensureNonNegative("amount", amount);
|
|
54340
|
+
const data = approveInterface.encodeFunctionData("approve", [
|
|
54341
|
+
normalizedSpender,
|
|
54342
|
+
normalizedAmount
|
|
54343
|
+
]);
|
|
54344
|
+
return {
|
|
54345
|
+
to: normalizedToken,
|
|
54346
|
+
data,
|
|
54347
|
+
value: 0n
|
|
54348
|
+
};
|
|
54349
|
+
}
|
|
54350
|
+
function toCall(tx) {
|
|
54351
|
+
if (tx.to == null) {
|
|
54352
|
+
throw new AdapterError("tx.to is required");
|
|
54353
|
+
}
|
|
54354
|
+
const to = ensureAddress("tx.to", tx.to);
|
|
54355
|
+
if (tx.data == null) {
|
|
54356
|
+
throw new AdapterError("tx.data is required");
|
|
54357
|
+
}
|
|
54358
|
+
const data = ensureHexData("tx.data", tx.data);
|
|
54359
|
+
let value;
|
|
54360
|
+
if (tx.value == null) {
|
|
54361
|
+
value = 0n;
|
|
54362
|
+
} else {
|
|
54363
|
+
try {
|
|
54364
|
+
value = BigInt(tx.value);
|
|
54365
|
+
} catch {
|
|
54366
|
+
throw new AdapterError(
|
|
54367
|
+
`tx.value must be convertible to bigint, received: ${String(tx.value)}`
|
|
54368
|
+
);
|
|
54369
|
+
}
|
|
54370
|
+
}
|
|
54371
|
+
return { to, data, value: ensureNonNegative("tx.value", value) };
|
|
54372
|
+
}
|
|
54373
|
+
function contract(address, abi) {
|
|
54374
|
+
const to = ensureAddress("contract.address", address);
|
|
54375
|
+
const iface = new Interface(abi);
|
|
54376
|
+
return new Proxy(
|
|
54377
|
+
{},
|
|
54378
|
+
{
|
|
54379
|
+
get(_, method) {
|
|
54380
|
+
return (...args) => {
|
|
54381
|
+
const data = iface.encodeFunctionData(method, args);
|
|
54382
|
+
return { to, data, value: 0n };
|
|
54383
|
+
};
|
|
54384
|
+
}
|
|
54385
|
+
}
|
|
54386
|
+
);
|
|
54387
|
+
}
|
|
54311
54388
|
function encodeAdapterExecute(params) {
|
|
54312
54389
|
const transactCalldata = ensureHexData(
|
|
54313
54390
|
"transactCalldata",
|
|
@@ -54331,6 +54408,7 @@ function encodeAdapterExecute(params) {
|
|
|
54331
54408
|
deadline
|
|
54332
54409
|
]);
|
|
54333
54410
|
}
|
|
54411
|
+
var buildApproveCall = approve;
|
|
54334
54412
|
init_process();
|
|
54335
54413
|
init_buffer();
|
|
54336
54414
|
init_process();
|
|
@@ -55717,26 +55795,34 @@ function normalizeCall2(call, index) {
|
|
|
55717
55795
|
value: call.value
|
|
55718
55796
|
};
|
|
55719
55797
|
}
|
|
55720
|
-
function
|
|
55721
|
-
const token = ensureAddress(`
|
|
55798
|
+
function normalizeSpendInput(input, index) {
|
|
55799
|
+
const token = ensureAddress(`spend[${index}].token`, input.token);
|
|
55800
|
+
if (token.toLowerCase() === ETH_TOKEN.toLowerCase()) {
|
|
55801
|
+
throw new AdapterError(
|
|
55802
|
+
`spend[${index}].token: native ETH is not supported in adapter execution`
|
|
55803
|
+
);
|
|
55804
|
+
}
|
|
55722
55805
|
if (input.amount <= 0n) {
|
|
55723
|
-
throw new AdapterError(`
|
|
55806
|
+
throw new AdapterError(`spend[${index}].amount must be greater than zero`);
|
|
55724
55807
|
}
|
|
55725
55808
|
return {
|
|
55726
55809
|
token,
|
|
55727
55810
|
amount: input.amount
|
|
55728
55811
|
};
|
|
55729
55812
|
}
|
|
55730
|
-
function
|
|
55731
|
-
const token = ensureAddress(`
|
|
55732
|
-
if (
|
|
55813
|
+
function normalizeReceiveInput(receive, index) {
|
|
55814
|
+
const token = ensureAddress(`receive[${index}].token`, receive.token);
|
|
55815
|
+
if (token.toLowerCase() === ETH_TOKEN.toLowerCase()) {
|
|
55733
55816
|
throw new AdapterError(
|
|
55734
|
-
`
|
|
55817
|
+
`receive[${index}].token: native ETH is not supported in adapter execution`
|
|
55735
55818
|
);
|
|
55736
55819
|
}
|
|
55820
|
+
if (receive.minAmount < 0n) {
|
|
55821
|
+
throw new AdapterError(`receive[${index}].minAmount must be non-negative`);
|
|
55822
|
+
}
|
|
55737
55823
|
return {
|
|
55738
55824
|
token,
|
|
55739
|
-
minAmount:
|
|
55825
|
+
minAmount: receive.minAmount
|
|
55740
55826
|
};
|
|
55741
55827
|
}
|
|
55742
55828
|
function randomFieldElement(randomBigintFn) {
|
|
@@ -55756,41 +55842,41 @@ function createAdapterService(deps) {
|
|
|
55756
55842
|
"adapterAddress",
|
|
55757
55843
|
params.adapterAddress
|
|
55758
55844
|
);
|
|
55759
|
-
if (!params.
|
|
55760
|
-
throw new AdapterError("at least one
|
|
55845
|
+
if (!params.spend.length) {
|
|
55846
|
+
throw new AdapterError("at least one spend token is required");
|
|
55761
55847
|
}
|
|
55762
55848
|
if (!params.calls.length) {
|
|
55763
55849
|
throw new AdapterError("at least one adapter call is required");
|
|
55764
55850
|
}
|
|
55765
|
-
if (!params.
|
|
55766
|
-
throw new AdapterError("at least one
|
|
55851
|
+
if (!params.receive.length) {
|
|
55852
|
+
throw new AdapterError("at least one receive output is required");
|
|
55767
55853
|
}
|
|
55768
|
-
const
|
|
55769
|
-
(input, i) =>
|
|
55854
|
+
const spendInputs = params.spend.map(
|
|
55855
|
+
(input, i) => normalizeSpendInput(input, i)
|
|
55770
55856
|
);
|
|
55771
55857
|
const seenTokens = /* @__PURE__ */ new Set();
|
|
55772
|
-
for (const input of
|
|
55858
|
+
for (const input of spendInputs) {
|
|
55773
55859
|
const lower = input.token.toLowerCase();
|
|
55774
55860
|
if (seenTokens.has(lower)) {
|
|
55775
55861
|
throw new AdapterError(
|
|
55776
|
-
`duplicate
|
|
55862
|
+
`duplicate spend token ${input.token}; combine amounts per token instead`
|
|
55777
55863
|
);
|
|
55778
55864
|
}
|
|
55779
55865
|
seenTokens.add(lower);
|
|
55780
55866
|
}
|
|
55781
55867
|
const calls = params.calls.map((call, i) => normalizeCall2(call, i));
|
|
55782
|
-
const
|
|
55783
|
-
(
|
|
55868
|
+
const receiveSpecs = params.receive.map(
|
|
55869
|
+
(receive, i) => normalizeReceiveInput(receive, i)
|
|
55784
55870
|
);
|
|
55785
|
-
const
|
|
55786
|
-
for (const r2 of
|
|
55871
|
+
const seenReceiveTokens = /* @__PURE__ */ new Set();
|
|
55872
|
+
for (const r2 of receiveSpecs) {
|
|
55787
55873
|
const lower = r2.token.toLowerCase();
|
|
55788
|
-
if (
|
|
55874
|
+
if (seenReceiveTokens.has(lower)) {
|
|
55789
55875
|
throw new AdapterError(
|
|
55790
|
-
`duplicate
|
|
55876
|
+
`duplicate receive token ${r2.token}; each receive must target a unique token`
|
|
55791
55877
|
);
|
|
55792
55878
|
}
|
|
55793
|
-
|
|
55879
|
+
seenReceiveTokens.add(lower);
|
|
55794
55880
|
}
|
|
55795
55881
|
const account = overrides?.account ?? await deps.requireActiveAccount();
|
|
55796
55882
|
const signer = overrides?.signer ?? deps.requireSigner(account);
|
|
@@ -55800,19 +55886,19 @@ function createAdapterService(deps) {
|
|
|
55800
55886
|
throw new AdapterError("deadline must be in the future");
|
|
55801
55887
|
}
|
|
55802
55888
|
const executionCalls = calls;
|
|
55803
|
-
const reshields =
|
|
55804
|
-
(
|
|
55889
|
+
const reshields = receiveSpecs.map(
|
|
55890
|
+
(receive) => {
|
|
55805
55891
|
const random = randomFieldElement(randomBigintImpl);
|
|
55806
55892
|
const npk = poseidon([account.masterPublicKey, random]);
|
|
55807
55893
|
return {
|
|
55808
55894
|
npk,
|
|
55809
55895
|
random,
|
|
55810
|
-
token:
|
|
55811
|
-
minAmount:
|
|
55896
|
+
token: receive.token,
|
|
55897
|
+
minAmount: receive.minAmount
|
|
55812
55898
|
};
|
|
55813
55899
|
}
|
|
55814
55900
|
);
|
|
55815
|
-
const inputTokens =
|
|
55901
|
+
const inputTokens = spendInputs.map((input) => input.token);
|
|
55816
55902
|
const nonce = randomFieldElement(randomBigintImpl);
|
|
55817
55903
|
const adapterDataHash = computeAdapterDataHash({
|
|
55818
55904
|
calls: executionCalls,
|
|
@@ -55829,7 +55915,7 @@ function createAdapterService(deps) {
|
|
|
55829
55915
|
});
|
|
55830
55916
|
const withdrawalPlans = planWithdrawalsImpl(
|
|
55831
55917
|
notes,
|
|
55832
|
-
|
|
55918
|
+
spendInputs.map((input) => ({
|
|
55833
55919
|
token: input.token,
|
|
55834
55920
|
amount: input.amount,
|
|
55835
55921
|
recipient: adapterAddress
|
|
@@ -55912,7 +55998,7 @@ function createAdapterService(deps) {
|
|
|
55912
55998
|
adapterCalldata,
|
|
55913
55999
|
historyPreview: {
|
|
55914
56000
|
kind: "Withdraw",
|
|
55915
|
-
amounts:
|
|
56001
|
+
amounts: spendInputs.map((input) => ({
|
|
55916
56002
|
token: input.token,
|
|
55917
56003
|
delta: (-input.amount).toString()
|
|
55918
56004
|
}))
|
|
@@ -55932,6 +56018,9 @@ init_process();
|
|
|
55932
56018
|
init_buffer();
|
|
55933
56019
|
var BIP44_ETH_PREFIX = "m/44'/60'/0'/0";
|
|
55934
56020
|
var ERC20_BALANCE_OF = "function balanceOf(address) view returns (uint256)";
|
|
56021
|
+
function isNativeToken(token) {
|
|
56022
|
+
return token.toLowerCase() === ETH_TOKEN.toLowerCase();
|
|
56023
|
+
}
|
|
55935
56024
|
function createBurnerService(deps) {
|
|
55936
56025
|
const { chainRpcUrl, getMasterSeed, withdrawToAddress, requestDeposit } = deps;
|
|
55937
56026
|
const provider = new JsonRpcProvider(chainRpcUrl);
|
|
@@ -55979,8 +56068,8 @@ function createBurnerService(deps) {
|
|
|
55979
56068
|
}
|
|
55980
56069
|
async function getTokenBalance(address, token) {
|
|
55981
56070
|
const iface = new Interface([ERC20_BALANCE_OF]);
|
|
55982
|
-
const
|
|
55983
|
-
const bal = await
|
|
56071
|
+
const contract2 = new Contract(token, iface, provider);
|
|
56072
|
+
const bal = await contract2.getFunction("balanceOf")(address);
|
|
55984
56073
|
return BigInt(bal ?? 0);
|
|
55985
56074
|
}
|
|
55986
56075
|
async function getBalance(address) {
|
|
@@ -55999,6 +56088,12 @@ function createBurnerService(deps) {
|
|
|
55999
56088
|
}
|
|
56000
56089
|
async function sweepToPool(index, params) {
|
|
56001
56090
|
const { address } = await addressOf(index);
|
|
56091
|
+
const native = isNativeToken(params.token);
|
|
56092
|
+
if (native && params.amount == null) {
|
|
56093
|
+
throw new Error(
|
|
56094
|
+
"amount is required for native ETH sweeps (needed to reserve gas)"
|
|
56095
|
+
);
|
|
56096
|
+
}
|
|
56002
56097
|
const amount = params.amount ?? await getTokenBalance(address, params.token);
|
|
56003
56098
|
if (amount === 0n) {
|
|
56004
56099
|
throw new Error("No token balance to sweep");
|
|
@@ -56009,17 +56104,20 @@ function createBurnerService(deps) {
|
|
|
56009
56104
|
depositor: address,
|
|
56010
56105
|
deposits: [{ token: params.token, amount }]
|
|
56011
56106
|
});
|
|
56012
|
-
|
|
56013
|
-
|
|
56014
|
-
|
|
56015
|
-
|
|
56016
|
-
|
|
56017
|
-
|
|
56018
|
-
|
|
56019
|
-
|
|
56107
|
+
if (!native) {
|
|
56108
|
+
const erc20Iface = new Interface([
|
|
56109
|
+
"function approve(address spender, uint256 amount)"
|
|
56110
|
+
]);
|
|
56111
|
+
const approveData = erc20Iface.encodeFunctionData("approve", [
|
|
56112
|
+
params.poolAddress,
|
|
56113
|
+
amount
|
|
56114
|
+
]);
|
|
56115
|
+
await send(index, { to: params.token, data: approveData });
|
|
56116
|
+
}
|
|
56020
56117
|
const { txHash } = await send(index, {
|
|
56021
56118
|
to: depositResult.to,
|
|
56022
|
-
data: depositResult.calldata
|
|
56119
|
+
data: depositResult.calldata,
|
|
56120
|
+
value: depositResult.value
|
|
56023
56121
|
});
|
|
56024
56122
|
return { txHash };
|
|
56025
56123
|
}
|
|
@@ -56672,20 +56770,26 @@ function createWalletSDK(deps, options) {
|
|
|
56672
56770
|
};
|
|
56673
56771
|
return sdk;
|
|
56674
56772
|
}
|
|
56675
|
-
var
|
|
56773
|
+
var Unlink = class _Unlink {
|
|
56676
56774
|
/** @internal */
|
|
56677
56775
|
sdk;
|
|
56678
56776
|
/** Chain ID this wallet operates on. */
|
|
56679
56777
|
chainId;
|
|
56680
56778
|
/** Pool contract address this wallet transacts with. */
|
|
56681
56779
|
poolAddress;
|
|
56682
|
-
|
|
56780
|
+
/** Adapter contract address for DeFi operations. */
|
|
56781
|
+
adapterAddress;
|
|
56782
|
+
constructor(sdk, chainId, poolAddress, adapterAddress) {
|
|
56683
56783
|
this.sdk = sdk;
|
|
56684
56784
|
this.chainId = chainId;
|
|
56685
56785
|
this.poolAddress = poolAddress;
|
|
56786
|
+
this.adapterAddress = adapterAddress;
|
|
56787
|
+
this.adapter = {
|
|
56788
|
+
address: adapterAddress
|
|
56789
|
+
};
|
|
56686
56790
|
}
|
|
56687
56791
|
/**
|
|
56688
|
-
* Create a new
|
|
56792
|
+
* Create a new Unlink instance.
|
|
56689
56793
|
*
|
|
56690
56794
|
* Handles all initialization internally:
|
|
56691
56795
|
* - Resolves chain config (if using `chain` instead of explicit URLs)
|
|
@@ -56697,12 +56801,14 @@ var UnlinkWallet = class _UnlinkWallet {
|
|
|
56697
56801
|
let chainId;
|
|
56698
56802
|
let gatewayUrl;
|
|
56699
56803
|
let poolAddress;
|
|
56804
|
+
let adapterAddress;
|
|
56700
56805
|
let proverConfig = config22.prover;
|
|
56701
56806
|
if ("chain" in config22) {
|
|
56702
56807
|
const chainConfig = await fetchChainConfig(config22.chain);
|
|
56703
56808
|
chainId = chainConfig.chainId;
|
|
56704
56809
|
gatewayUrl = chainConfig.gatewayUrl;
|
|
56705
56810
|
poolAddress = config22.poolAddress ?? chainConfig.poolAddress;
|
|
56811
|
+
adapterAddress = config22.adapterAddress ?? chainConfig.adapterAddress;
|
|
56706
56812
|
proverConfig = {
|
|
56707
56813
|
artifactSource: {
|
|
56708
56814
|
baseUrl: config22.prover?.artifactSource?.baseUrl ?? chainConfig.artifactBaseUrl,
|
|
@@ -56714,6 +56820,7 @@ var UnlinkWallet = class _UnlinkWallet {
|
|
|
56714
56820
|
chainId = config22.chainId;
|
|
56715
56821
|
gatewayUrl = config22.gatewayUrl;
|
|
56716
56822
|
poolAddress = config22.poolAddress;
|
|
56823
|
+
adapterAddress = config22.adapterAddress;
|
|
56717
56824
|
if (typeof window !== "undefined" && !config22.prover?.artifactSource?.version) {
|
|
56718
56825
|
throw new InitializationError(
|
|
56719
56826
|
"prover.artifactSource.version is required in browser when using explicit gatewayUrl mode. Use chain mode or provide a pinned artifact version."
|
|
@@ -56734,7 +56841,7 @@ var UnlinkWallet = class _UnlinkWallet {
|
|
|
56734
56841
|
autoSync: config22.autoSync
|
|
56735
56842
|
}
|
|
56736
56843
|
);
|
|
56737
|
-
return new
|
|
56844
|
+
return new _Unlink(sdk, chainId, poolAddress, adapterAddress ?? "");
|
|
56738
56845
|
}
|
|
56739
56846
|
// ===== Seed Lifecycle =====
|
|
56740
56847
|
/** Seed management (create, import, export, delete mnemonic). */
|
|
@@ -56765,10 +56872,10 @@ var UnlinkWallet = class _UnlinkWallet {
|
|
|
56765
56872
|
return this.sdk.deposit.reconcile(relayId);
|
|
56766
56873
|
}
|
|
56767
56874
|
/**
|
|
56768
|
-
*
|
|
56875
|
+
* Send a private transfer (1 or more recipients).
|
|
56769
56876
|
* Handles note selection, circuit selection, and proof generation automatically.
|
|
56770
56877
|
*/
|
|
56771
|
-
async
|
|
56878
|
+
async send(params, overrides) {
|
|
56772
56879
|
return this.sdk.transfer.send(
|
|
56773
56880
|
{
|
|
56774
56881
|
chainId: this.chainId,
|
|
@@ -56779,9 +56886,9 @@ var UnlinkWallet = class _UnlinkWallet {
|
|
|
56779
56886
|
);
|
|
56780
56887
|
}
|
|
56781
56888
|
/**
|
|
56782
|
-
* Get a
|
|
56889
|
+
* Get a send plan without executing (for preview/confirmation UIs).
|
|
56783
56890
|
*/
|
|
56784
|
-
async
|
|
56891
|
+
async planSend(params, account) {
|
|
56785
56892
|
return this.sdk.transfer.plan(
|
|
56786
56893
|
{
|
|
56787
56894
|
chainId: this.chainId,
|
|
@@ -56791,8 +56898,8 @@ var UnlinkWallet = class _UnlinkWallet {
|
|
|
56791
56898
|
account
|
|
56792
56899
|
);
|
|
56793
56900
|
}
|
|
56794
|
-
/** Execute a pre-built
|
|
56795
|
-
async
|
|
56901
|
+
/** Execute a pre-built send plan. */
|
|
56902
|
+
async executeSend(plans, overrides) {
|
|
56796
56903
|
return this.sdk.transfer.execute(
|
|
56797
56904
|
plans,
|
|
56798
56905
|
{ chainId: this.chainId, poolAddress: this.poolAddress },
|
|
@@ -56941,31 +57048,31 @@ var UnlinkWallet = class _UnlinkWallet {
|
|
|
56941
57048
|
return this.sdk.burner.getBalance(address);
|
|
56942
57049
|
}
|
|
56943
57050
|
};
|
|
56944
|
-
// =====
|
|
57051
|
+
// ===== Interact (Private DeFi) =====
|
|
56945
57052
|
/**
|
|
56946
|
-
*
|
|
56947
|
-
*
|
|
57053
|
+
* Adapter contract address (resolved from config).
|
|
57054
|
+
* Use for building DeFi calls that reference the adapter.
|
|
56948
57055
|
*/
|
|
56949
|
-
adapter
|
|
56950
|
-
|
|
56951
|
-
|
|
56952
|
-
|
|
56953
|
-
|
|
56954
|
-
|
|
56955
|
-
|
|
56956
|
-
|
|
56957
|
-
|
|
56958
|
-
|
|
56959
|
-
|
|
56960
|
-
|
|
56961
|
-
|
|
56962
|
-
|
|
56963
|
-
|
|
56964
|
-
|
|
56965
|
-
|
|
56966
|
-
|
|
56967
|
-
|
|
56968
|
-
}
|
|
57056
|
+
adapter;
|
|
57057
|
+
/**
|
|
57058
|
+
* Execute an atomic unshield -> DeFi call(s) -> reshield flow through an adapter.
|
|
57059
|
+
* chainId/poolAddress/adapterAddress are injected automatically.
|
|
57060
|
+
*/
|
|
57061
|
+
async interact(params, opts, overrides) {
|
|
57062
|
+
return this.sdk.adapter.execute(
|
|
57063
|
+
{
|
|
57064
|
+
chainId: this.chainId,
|
|
57065
|
+
poolAddress: this.poolAddress,
|
|
57066
|
+
adapterAddress: this.adapterAddress,
|
|
57067
|
+
spend: params.spend,
|
|
57068
|
+
calls: params.calls,
|
|
57069
|
+
receive: params.receive,
|
|
57070
|
+
deadline: params.deadline
|
|
57071
|
+
},
|
|
57072
|
+
opts,
|
|
57073
|
+
overrides
|
|
57074
|
+
);
|
|
57075
|
+
}
|
|
56969
57076
|
// ===== Advanced =====
|
|
56970
57077
|
/**
|
|
56971
57078
|
* Advanced escape hatch for raw JoinSplit transaction building.
|
|
@@ -57085,7 +57192,7 @@ function createUnlinkError(err, operation) {
|
|
|
57085
57192
|
};
|
|
57086
57193
|
}
|
|
57087
57194
|
var initialState = {
|
|
57088
|
-
|
|
57195
|
+
unlink: null,
|
|
57089
57196
|
walletExists: false,
|
|
57090
57197
|
accounts: [],
|
|
57091
57198
|
activeAccount: null,
|
|
@@ -57095,7 +57202,7 @@ var initialState = {
|
|
|
57095
57202
|
balances: {},
|
|
57096
57203
|
burners: [],
|
|
57097
57204
|
pendingDeposits: [],
|
|
57098
|
-
|
|
57205
|
+
pendingSends: [],
|
|
57099
57206
|
pendingWithdrawals: [],
|
|
57100
57207
|
ready: false,
|
|
57101
57208
|
busy: false,
|
|
@@ -57121,13 +57228,13 @@ function UnlinkProvider({
|
|
|
57121
57228
|
const chainId = "chainId" in configProps ? configProps.chainId : void 0;
|
|
57122
57229
|
const gatewayUrl = "gatewayUrl" in configProps ? configProps.gatewayUrl : void 0;
|
|
57123
57230
|
const [state, setState] = useState(initialState);
|
|
57124
|
-
const
|
|
57231
|
+
const unlinkRef = useRef(null);
|
|
57125
57232
|
const proverKey = JSON.stringify(prover ?? null);
|
|
57126
|
-
const refreshAccounts = useCallback(async (
|
|
57233
|
+
const refreshAccounts = useCallback(async (unlink) => {
|
|
57127
57234
|
try {
|
|
57128
|
-
const accounts = await
|
|
57129
|
-
const activeAccount = await
|
|
57130
|
-
const activeAccountIndex = await
|
|
57235
|
+
const accounts = await unlink.accounts.list();
|
|
57236
|
+
const activeAccount = await unlink.accounts.getActive();
|
|
57237
|
+
const activeAccountIndex = await unlink.accounts.getActiveIndex();
|
|
57131
57238
|
setState((prev2) => ({
|
|
57132
57239
|
...prev2,
|
|
57133
57240
|
accounts,
|
|
@@ -57138,11 +57245,11 @@ function UnlinkProvider({
|
|
|
57138
57245
|
console.error("[UnlinkProvider] refreshAccounts error", err);
|
|
57139
57246
|
}
|
|
57140
57247
|
}, []);
|
|
57141
|
-
const refreshState = useCallback(async (
|
|
57248
|
+
const refreshState = useCallback(async (unlink) => {
|
|
57142
57249
|
try {
|
|
57143
|
-
const noteRecords = await
|
|
57250
|
+
const noteRecords = await unlink.getNotes();
|
|
57144
57251
|
const notes = convertNotes(noteRecords);
|
|
57145
|
-
const balances = await
|
|
57252
|
+
const balances = await unlink.getBalances();
|
|
57146
57253
|
setState((prev2) => ({ ...prev2, notes, balances }));
|
|
57147
57254
|
} catch (err) {
|
|
57148
57255
|
console.error("[UnlinkProvider] refresh error", err);
|
|
@@ -57168,7 +57275,7 @@ function UnlinkProvider({
|
|
|
57168
57275
|
...prev2,
|
|
57169
57276
|
status: "Initializing SDK..."
|
|
57170
57277
|
}));
|
|
57171
|
-
const
|
|
57278
|
+
const unlink = await Unlink.create(
|
|
57172
57279
|
chain2 ? {
|
|
57173
57280
|
chain: chain2,
|
|
57174
57281
|
poolAddress,
|
|
@@ -57181,8 +57288,8 @@ function UnlinkProvider({
|
|
|
57181
57288
|
}
|
|
57182
57289
|
);
|
|
57183
57290
|
if (cancelled) return;
|
|
57184
|
-
|
|
57185
|
-
const walletExists = await
|
|
57291
|
+
unlinkRef.current = unlink;
|
|
57292
|
+
const walletExists = await unlink.seed.exists();
|
|
57186
57293
|
if (cancelled) return;
|
|
57187
57294
|
let accounts = [];
|
|
57188
57295
|
let activeAccount = null;
|
|
@@ -57190,33 +57297,33 @@ function UnlinkProvider({
|
|
|
57190
57297
|
let notes = [];
|
|
57191
57298
|
let balances = {};
|
|
57192
57299
|
if (walletExists) {
|
|
57193
|
-
accounts = await
|
|
57300
|
+
accounts = await unlink.accounts.list();
|
|
57194
57301
|
if (accounts.length === 0) {
|
|
57195
|
-
await
|
|
57196
|
-
accounts = await
|
|
57302
|
+
await unlink.accounts.create();
|
|
57303
|
+
accounts = await unlink.accounts.list();
|
|
57197
57304
|
}
|
|
57198
|
-
activeAccount = await
|
|
57199
|
-
activeAccountIndex = await
|
|
57305
|
+
activeAccount = await unlink.accounts.getActive();
|
|
57306
|
+
activeAccountIndex = await unlink.accounts.getActiveIndex();
|
|
57200
57307
|
if (accounts.length > 0 && !activeAccount) {
|
|
57201
|
-
await
|
|
57202
|
-
activeAccount = await
|
|
57203
|
-
activeAccountIndex = await
|
|
57308
|
+
await unlink.accounts.setActive(accounts[0].index);
|
|
57309
|
+
activeAccount = await unlink.accounts.getActive();
|
|
57310
|
+
activeAccountIndex = await unlink.accounts.getActiveIndex();
|
|
57204
57311
|
}
|
|
57205
57312
|
if (activeAccount) {
|
|
57206
|
-
const noteRecords = await
|
|
57313
|
+
const noteRecords = await unlink.getNotes();
|
|
57207
57314
|
notes = convertNotes(noteRecords);
|
|
57208
|
-
balances = await
|
|
57315
|
+
balances = await unlink.getBalances();
|
|
57209
57316
|
}
|
|
57210
57317
|
}
|
|
57211
57318
|
const statusMessage = !walletExists ? "No wallet - create or import one" : !activeAccount ? "No account - create one to get started" : "Ready";
|
|
57212
57319
|
setState((prev2) => ({
|
|
57213
57320
|
...prev2,
|
|
57214
|
-
|
|
57321
|
+
unlink,
|
|
57215
57322
|
walletExists,
|
|
57216
57323
|
accounts,
|
|
57217
57324
|
activeAccount,
|
|
57218
57325
|
activeAccountIndex,
|
|
57219
|
-
chainId:
|
|
57326
|
+
chainId: unlink.chainId,
|
|
57220
57327
|
notes,
|
|
57221
57328
|
balances,
|
|
57222
57329
|
ready: true,
|
|
@@ -57224,12 +57331,12 @@ function UnlinkProvider({
|
|
|
57224
57331
|
error: null
|
|
57225
57332
|
}));
|
|
57226
57333
|
if (autoSync && walletExists && activeAccount) {
|
|
57227
|
-
|
|
57334
|
+
unlink.startAutoSync(syncInterval);
|
|
57228
57335
|
}
|
|
57229
|
-
unsubscribe =
|
|
57230
|
-
if (event.type === "notes-updated" && event.chainId ===
|
|
57336
|
+
unsubscribe = unlink.on((event) => {
|
|
57337
|
+
if (event.type === "notes-updated" && event.chainId === unlink.chainId) {
|
|
57231
57338
|
setState((prev2) => ({ ...prev2, syncError: null }));
|
|
57232
|
-
void refreshState(
|
|
57339
|
+
void refreshState(unlink);
|
|
57233
57340
|
}
|
|
57234
57341
|
if (event.type === "sync-error") {
|
|
57235
57342
|
setState((prev2) => ({ ...prev2, syncError: event.error }));
|
|
@@ -57238,9 +57345,9 @@ function UnlinkProvider({
|
|
|
57238
57345
|
setState((prev2) => ({ ...prev2, walletExists: true }));
|
|
57239
57346
|
}
|
|
57240
57347
|
if (event.type === "account-created" || event.type === "account-switched") {
|
|
57241
|
-
void refreshAccounts(
|
|
57348
|
+
void refreshAccounts(unlink);
|
|
57242
57349
|
if (event.type === "account-switched") {
|
|
57243
|
-
void refreshState(
|
|
57350
|
+
void refreshState(unlink);
|
|
57244
57351
|
}
|
|
57245
57352
|
}
|
|
57246
57353
|
});
|
|
@@ -57258,7 +57365,7 @@ function UnlinkProvider({
|
|
|
57258
57365
|
return () => {
|
|
57259
57366
|
cancelled = true;
|
|
57260
57367
|
unsubscribe?.();
|
|
57261
|
-
|
|
57368
|
+
unlinkRef.current?.stopAutoSync();
|
|
57262
57369
|
};
|
|
57263
57370
|
}, [
|
|
57264
57371
|
chain2,
|
|
@@ -57272,11 +57379,11 @@ function UnlinkProvider({
|
|
|
57272
57379
|
proverKey
|
|
57273
57380
|
]);
|
|
57274
57381
|
const createWallet = useCallback(async () => {
|
|
57275
|
-
const
|
|
57276
|
-
if (!
|
|
57382
|
+
const unlink = unlinkRef.current;
|
|
57383
|
+
if (!unlink) throw new Error("SDK not initialized");
|
|
57277
57384
|
setState((prev2) => ({ ...prev2, busy: true, status: "Creating wallet..." }));
|
|
57278
57385
|
try {
|
|
57279
|
-
const result = await
|
|
57386
|
+
const result = await unlink.seed.create();
|
|
57280
57387
|
setState((prev2) => ({
|
|
57281
57388
|
...prev2,
|
|
57282
57389
|
walletExists: true,
|
|
@@ -57297,18 +57404,18 @@ function UnlinkProvider({
|
|
|
57297
57404
|
}
|
|
57298
57405
|
}, []);
|
|
57299
57406
|
const importWallet = useCallback(async (mnemonic) => {
|
|
57300
|
-
const
|
|
57301
|
-
if (!
|
|
57407
|
+
const unlink = unlinkRef.current;
|
|
57408
|
+
if (!unlink) throw new Error("SDK not initialized");
|
|
57302
57409
|
setState((prev2) => ({
|
|
57303
57410
|
...prev2,
|
|
57304
57411
|
busy: true,
|
|
57305
57412
|
status: "Importing wallet..."
|
|
57306
57413
|
}));
|
|
57307
57414
|
try {
|
|
57308
|
-
await
|
|
57309
|
-
const accounts = await
|
|
57310
|
-
const activeAccount = await
|
|
57311
|
-
const activeAccountIndex = await
|
|
57415
|
+
await unlink.seed.importMnemonic(mnemonic);
|
|
57416
|
+
const accounts = await unlink.accounts.list();
|
|
57417
|
+
const activeAccount = await unlink.accounts.getActive();
|
|
57418
|
+
const activeAccountIndex = await unlink.accounts.getActiveIndex();
|
|
57312
57419
|
setState((prev2) => ({
|
|
57313
57420
|
...prev2,
|
|
57314
57421
|
walletExists: true,
|
|
@@ -57332,16 +57439,16 @@ function UnlinkProvider({
|
|
|
57332
57439
|
}
|
|
57333
57440
|
}, []);
|
|
57334
57441
|
const exportMnemonic = useCallback(async () => {
|
|
57335
|
-
const
|
|
57336
|
-
if (!
|
|
57337
|
-
return
|
|
57442
|
+
const unlink = unlinkRef.current;
|
|
57443
|
+
if (!unlink) throw new Error("SDK not initialized");
|
|
57444
|
+
return unlink.seed.exportMnemonic();
|
|
57338
57445
|
}, []);
|
|
57339
57446
|
const clearWallet = useCallback(async () => {
|
|
57340
|
-
const
|
|
57341
|
-
if (!
|
|
57447
|
+
const unlink = unlinkRef.current;
|
|
57448
|
+
if (!unlink) throw new Error("SDK not initialized");
|
|
57342
57449
|
setState((prev2) => ({ ...prev2, busy: true, status: "Clearing wallet..." }));
|
|
57343
57450
|
try {
|
|
57344
|
-
await
|
|
57451
|
+
await unlink.seed.delete();
|
|
57345
57452
|
setState((prev2) => ({
|
|
57346
57453
|
...prev2,
|
|
57347
57454
|
walletExists: false,
|
|
@@ -57368,18 +57475,18 @@ function UnlinkProvider({
|
|
|
57368
57475
|
}, []);
|
|
57369
57476
|
const createAccount = useCallback(
|
|
57370
57477
|
async (index) => {
|
|
57371
|
-
const
|
|
57372
|
-
if (!
|
|
57478
|
+
const unlink = unlinkRef.current;
|
|
57479
|
+
if (!unlink) throw new Error("SDK not initialized");
|
|
57373
57480
|
setState((prev2) => ({
|
|
57374
57481
|
...prev2,
|
|
57375
57482
|
busy: true,
|
|
57376
57483
|
status: "Creating account..."
|
|
57377
57484
|
}));
|
|
57378
57485
|
try {
|
|
57379
|
-
const account = await
|
|
57380
|
-
const accounts = await
|
|
57381
|
-
const activeAccount = await
|
|
57382
|
-
const activeAccountIndex = await
|
|
57486
|
+
const account = await unlink.accounts.create(index);
|
|
57487
|
+
const accounts = await unlink.accounts.list();
|
|
57488
|
+
const activeAccount = await unlink.accounts.getActive();
|
|
57489
|
+
const activeAccountIndex = await unlink.accounts.getActiveIndex();
|
|
57383
57490
|
setState((prev2) => ({
|
|
57384
57491
|
...prev2,
|
|
57385
57492
|
accounts,
|
|
@@ -57390,7 +57497,7 @@ function UnlinkProvider({
|
|
|
57390
57497
|
error: null
|
|
57391
57498
|
}));
|
|
57392
57499
|
if (autoSync && accounts.length === 1) {
|
|
57393
|
-
|
|
57500
|
+
unlink.startAutoSync(syncInterval);
|
|
57394
57501
|
}
|
|
57395
57502
|
return account;
|
|
57396
57503
|
} catch (err) {
|
|
@@ -57406,22 +57513,22 @@ function UnlinkProvider({
|
|
|
57406
57513
|
[autoSync, syncInterval]
|
|
57407
57514
|
);
|
|
57408
57515
|
const switchAccount = useCallback(async (index) => {
|
|
57409
|
-
const
|
|
57410
|
-
if (!
|
|
57516
|
+
const unlink = unlinkRef.current;
|
|
57517
|
+
if (!unlink) throw new Error("SDK not initialized");
|
|
57411
57518
|
setState((prev2) => ({
|
|
57412
57519
|
...prev2,
|
|
57413
57520
|
busy: true,
|
|
57414
57521
|
status: "Switching account..."
|
|
57415
57522
|
}));
|
|
57416
57523
|
try {
|
|
57417
|
-
await
|
|
57418
|
-
const activeAccount = await
|
|
57524
|
+
await unlink.accounts.setActive(index);
|
|
57525
|
+
const activeAccount = await unlink.accounts.getActive();
|
|
57419
57526
|
let notes = [];
|
|
57420
57527
|
let balances = {};
|
|
57421
57528
|
if (activeAccount) {
|
|
57422
|
-
const noteRecords = await
|
|
57529
|
+
const noteRecords = await unlink.getNotes();
|
|
57423
57530
|
notes = convertNotes(noteRecords);
|
|
57424
|
-
balances = await
|
|
57531
|
+
balances = await unlink.getBalances();
|
|
57425
57532
|
}
|
|
57426
57533
|
setState((prev2) => ({
|
|
57427
57534
|
...prev2,
|
|
@@ -57445,8 +57552,8 @@ function UnlinkProvider({
|
|
|
57445
57552
|
}, []);
|
|
57446
57553
|
const send = useCallback(
|
|
57447
57554
|
async (params, overrides) => {
|
|
57448
|
-
const
|
|
57449
|
-
if (!
|
|
57555
|
+
const unlink = unlinkRef.current;
|
|
57556
|
+
if (!unlink) throw new Error("SDK not initialized");
|
|
57450
57557
|
if (params.length === 0) {
|
|
57451
57558
|
throw new Error("At least one transfer is required");
|
|
57452
57559
|
}
|
|
@@ -57456,7 +57563,7 @@ function UnlinkProvider({
|
|
|
57456
57563
|
status: params.length > 1 ? `Sending (${params.length} transfers)...` : "Sending..."
|
|
57457
57564
|
}));
|
|
57458
57565
|
try {
|
|
57459
|
-
const result = await
|
|
57566
|
+
const result = await unlink.send(
|
|
57460
57567
|
{
|
|
57461
57568
|
transfers: params.map((t) => ({
|
|
57462
57569
|
token: t.token,
|
|
@@ -57470,12 +57577,12 @@ function UnlinkProvider({
|
|
|
57470
57577
|
...prev2,
|
|
57471
57578
|
busy: false,
|
|
57472
57579
|
status: params.length > 1 ? `Transfer submitted (${params.length} transfers)` : "Transfer submitted",
|
|
57473
|
-
|
|
57474
|
-
...prev2.
|
|
57580
|
+
pendingSends: [
|
|
57581
|
+
...prev2.pendingSends,
|
|
57475
57582
|
...params.map((t, i) => ({
|
|
57476
57583
|
txId: `${result.relayId}-${i}`,
|
|
57477
57584
|
status: "pending",
|
|
57478
|
-
chainId:
|
|
57585
|
+
chainId: unlink.chainId,
|
|
57479
57586
|
token: t.token,
|
|
57480
57587
|
amount: t.amount,
|
|
57481
57588
|
recipient: t.recipient,
|
|
@@ -57497,10 +57604,10 @@ function UnlinkProvider({
|
|
|
57497
57604
|
},
|
|
57498
57605
|
[]
|
|
57499
57606
|
);
|
|
57500
|
-
const
|
|
57501
|
-
const
|
|
57502
|
-
if (!
|
|
57503
|
-
return
|
|
57607
|
+
const planSend = useCallback(async (params) => {
|
|
57608
|
+
const unlink = unlinkRef.current;
|
|
57609
|
+
if (!unlink) throw new Error("SDK not initialized");
|
|
57610
|
+
return unlink.planSend({
|
|
57504
57611
|
transfers: params.map((t) => ({
|
|
57505
57612
|
token: t.token,
|
|
57506
57613
|
recipient: t.recipient,
|
|
@@ -57508,21 +57615,21 @@ function UnlinkProvider({
|
|
|
57508
57615
|
}))
|
|
57509
57616
|
});
|
|
57510
57617
|
}, []);
|
|
57511
|
-
const
|
|
57618
|
+
const executeSend = useCallback(
|
|
57512
57619
|
async (plans, overrides) => {
|
|
57513
|
-
const
|
|
57514
|
-
if (!
|
|
57620
|
+
const unlink = unlinkRef.current;
|
|
57621
|
+
if (!unlink) throw new Error("SDK not initialized");
|
|
57515
57622
|
setState((prev2) => ({
|
|
57516
57623
|
...prev2,
|
|
57517
57624
|
busy: true,
|
|
57518
|
-
status: "Executing
|
|
57625
|
+
status: "Executing send..."
|
|
57519
57626
|
}));
|
|
57520
57627
|
try {
|
|
57521
|
-
const result = await
|
|
57628
|
+
const result = await unlink.executeSend(plans, overrides);
|
|
57522
57629
|
setState((prev2) => ({
|
|
57523
57630
|
...prev2,
|
|
57524
57631
|
busy: false,
|
|
57525
|
-
status: "
|
|
57632
|
+
status: "Send executed",
|
|
57526
57633
|
error: null
|
|
57527
57634
|
}));
|
|
57528
57635
|
return result;
|
|
@@ -57531,17 +57638,17 @@ function UnlinkProvider({
|
|
|
57531
57638
|
...prev2,
|
|
57532
57639
|
busy: false,
|
|
57533
57640
|
status: `Error: ${err instanceof Error ? err.message : "Unknown"}`,
|
|
57534
|
-
error: createUnlinkError(err, "
|
|
57641
|
+
error: createUnlinkError(err, "executeSend")
|
|
57535
57642
|
}));
|
|
57536
57643
|
throw err;
|
|
57537
57644
|
}
|
|
57538
57645
|
},
|
|
57539
57646
|
[]
|
|
57540
57647
|
);
|
|
57541
|
-
const
|
|
57648
|
+
const deposit2 = useCallback(
|
|
57542
57649
|
async (params) => {
|
|
57543
|
-
const
|
|
57544
|
-
if (!
|
|
57650
|
+
const unlink = unlinkRef.current;
|
|
57651
|
+
if (!unlink) throw new Error("SDK not initialized");
|
|
57545
57652
|
if (params.length === 0) {
|
|
57546
57653
|
throw new Error("At least one deposit is required");
|
|
57547
57654
|
}
|
|
@@ -57555,7 +57662,7 @@ function UnlinkProvider({
|
|
|
57555
57662
|
status: params.length > 1 ? `Preparing deposit (${params.length} tokens)...` : "Preparing deposit..."
|
|
57556
57663
|
}));
|
|
57557
57664
|
try {
|
|
57558
|
-
const result = await
|
|
57665
|
+
const result = await unlink.deposit({
|
|
57559
57666
|
depositor,
|
|
57560
57667
|
deposits: params.map((d2) => ({
|
|
57561
57668
|
token: d2.token,
|
|
@@ -57573,7 +57680,7 @@ function UnlinkProvider({
|
|
|
57573
57680
|
status: "pending",
|
|
57574
57681
|
token: c.token,
|
|
57575
57682
|
amount: c.amount,
|
|
57576
|
-
chainId:
|
|
57683
|
+
chainId: unlink.chainId,
|
|
57577
57684
|
commitment: c.commitment,
|
|
57578
57685
|
startedAt: Date.now()
|
|
57579
57686
|
}))
|
|
@@ -57586,17 +57693,17 @@ function UnlinkProvider({
|
|
|
57586
57693
|
...prev2,
|
|
57587
57694
|
busy: false,
|
|
57588
57695
|
status: `Error: ${err instanceof Error ? err.message : "Unknown"}`,
|
|
57589
|
-
error: createUnlinkError(err, "
|
|
57696
|
+
error: createUnlinkError(err, "deposit")
|
|
57590
57697
|
}));
|
|
57591
57698
|
throw err;
|
|
57592
57699
|
}
|
|
57593
57700
|
},
|
|
57594
57701
|
[]
|
|
57595
57702
|
);
|
|
57596
|
-
const
|
|
57703
|
+
const withdraw = useCallback(
|
|
57597
57704
|
async (params, overrides) => {
|
|
57598
|
-
const
|
|
57599
|
-
if (!
|
|
57705
|
+
const unlink = unlinkRef.current;
|
|
57706
|
+
if (!unlink) throw new Error("SDK not initialized");
|
|
57600
57707
|
if (params.length === 0) {
|
|
57601
57708
|
throw new Error("At least one withdrawal is required");
|
|
57602
57709
|
}
|
|
@@ -57606,7 +57713,7 @@ function UnlinkProvider({
|
|
|
57606
57713
|
status: params.length > 1 ? `Processing withdrawal (${params.length} tokens)...` : "Withdrawing..."
|
|
57607
57714
|
}));
|
|
57608
57715
|
try {
|
|
57609
|
-
const result = await
|
|
57716
|
+
const result = await unlink.withdraw(
|
|
57610
57717
|
{
|
|
57611
57718
|
withdrawals: params.map((w) => ({
|
|
57612
57719
|
token: w.token,
|
|
@@ -57625,7 +57732,7 @@ function UnlinkProvider({
|
|
|
57625
57732
|
...params.map((w, i) => ({
|
|
57626
57733
|
txId: `${result.relayId}-${i}`,
|
|
57627
57734
|
status: "pending",
|
|
57628
|
-
chainId:
|
|
57735
|
+
chainId: unlink.chainId,
|
|
57629
57736
|
token: w.token,
|
|
57630
57737
|
amount: w.amount,
|
|
57631
57738
|
recipient: w.recipient,
|
|
@@ -57640,28 +57747,28 @@ function UnlinkProvider({
|
|
|
57640
57747
|
...prev2,
|
|
57641
57748
|
busy: false,
|
|
57642
57749
|
status: `Error: ${err instanceof Error ? err.message : "Unknown"}`,
|
|
57643
|
-
error: createUnlinkError(err, "
|
|
57750
|
+
error: createUnlinkError(err, "withdraw")
|
|
57644
57751
|
}));
|
|
57645
57752
|
throw err;
|
|
57646
57753
|
}
|
|
57647
57754
|
},
|
|
57648
57755
|
[]
|
|
57649
57756
|
);
|
|
57650
|
-
const
|
|
57757
|
+
const interact = useCallback(
|
|
57651
57758
|
async (params) => {
|
|
57652
|
-
const
|
|
57653
|
-
if (!
|
|
57759
|
+
const unlink = unlinkRef.current;
|
|
57760
|
+
if (!unlink) throw new Error("SDK not initialized");
|
|
57654
57761
|
setState((prev2) => ({
|
|
57655
57762
|
...prev2,
|
|
57656
57763
|
busy: true,
|
|
57657
|
-
status: "Executing
|
|
57764
|
+
status: "Executing interaction..."
|
|
57658
57765
|
}));
|
|
57659
57766
|
try {
|
|
57660
|
-
const result = await
|
|
57767
|
+
const result = await unlink.interact(params);
|
|
57661
57768
|
setState((prev2) => ({
|
|
57662
57769
|
...prev2,
|
|
57663
57770
|
busy: false,
|
|
57664
|
-
status: "
|
|
57771
|
+
status: "Interaction submitted",
|
|
57665
57772
|
error: null
|
|
57666
57773
|
}));
|
|
57667
57774
|
return result;
|
|
@@ -57670,7 +57777,7 @@ function UnlinkProvider({
|
|
|
57670
57777
|
...prev2,
|
|
57671
57778
|
busy: false,
|
|
57672
57779
|
status: `Error: ${err instanceof Error ? err.message : "Unknown"}`,
|
|
57673
|
-
error: createUnlinkError(err, "
|
|
57780
|
+
error: createUnlinkError(err, "interact")
|
|
57674
57781
|
}));
|
|
57675
57782
|
throw err;
|
|
57676
57783
|
}
|
|
@@ -57679,9 +57786,9 @@ function UnlinkProvider({
|
|
|
57679
57786
|
);
|
|
57680
57787
|
const planWithdraw = useCallback(
|
|
57681
57788
|
async (params) => {
|
|
57682
|
-
const
|
|
57683
|
-
if (!
|
|
57684
|
-
return
|
|
57789
|
+
const unlink = unlinkRef.current;
|
|
57790
|
+
if (!unlink) throw new Error("SDK not initialized");
|
|
57791
|
+
return unlink.planWithdraw({
|
|
57685
57792
|
withdrawals: params.map((w) => ({
|
|
57686
57793
|
token: w.token,
|
|
57687
57794
|
amount: w.amount,
|
|
@@ -57693,15 +57800,15 @@ function UnlinkProvider({
|
|
|
57693
57800
|
);
|
|
57694
57801
|
const executeWithdraw = useCallback(
|
|
57695
57802
|
async (plans, overrides) => {
|
|
57696
|
-
const
|
|
57697
|
-
if (!
|
|
57803
|
+
const unlink = unlinkRef.current;
|
|
57804
|
+
if (!unlink) throw new Error("SDK not initialized");
|
|
57698
57805
|
setState((prev2) => ({
|
|
57699
57806
|
...prev2,
|
|
57700
57807
|
busy: true,
|
|
57701
57808
|
status: plans.length > 1 ? `Executing withdrawal (${plans.length} tokens)...` : "Executing withdrawal..."
|
|
57702
57809
|
}));
|
|
57703
57810
|
try {
|
|
57704
|
-
const result = await
|
|
57811
|
+
const result = await unlink.executeWithdraw(plans, overrides);
|
|
57705
57812
|
setState((prev2) => ({
|
|
57706
57813
|
...prev2,
|
|
57707
57814
|
busy: false,
|
|
@@ -57722,15 +57829,15 @@ function UnlinkProvider({
|
|
|
57722
57829
|
[]
|
|
57723
57830
|
);
|
|
57724
57831
|
const createBurner = useCallback(async (index) => {
|
|
57725
|
-
const
|
|
57726
|
-
if (!
|
|
57832
|
+
const unlink = unlinkRef.current;
|
|
57833
|
+
if (!unlink) throw new Error("SDK not initialized");
|
|
57727
57834
|
setState((prev2) => ({
|
|
57728
57835
|
...prev2,
|
|
57729
57836
|
busy: true,
|
|
57730
57837
|
status: `Creating burner ${index}...`
|
|
57731
57838
|
}));
|
|
57732
57839
|
try {
|
|
57733
|
-
const burner = await
|
|
57840
|
+
const burner = await unlink.burner.addressOf(index);
|
|
57734
57841
|
setState((prev2) => ({
|
|
57735
57842
|
...prev2,
|
|
57736
57843
|
burners: [
|
|
@@ -57760,15 +57867,15 @@ function UnlinkProvider({
|
|
|
57760
57867
|
}, []);
|
|
57761
57868
|
const burnerSend = useCallback(
|
|
57762
57869
|
async (index, tx) => {
|
|
57763
|
-
const
|
|
57764
|
-
if (!
|
|
57870
|
+
const unlink = unlinkRef.current;
|
|
57871
|
+
if (!unlink) throw new Error("SDK not initialized");
|
|
57765
57872
|
setState((prev2) => ({
|
|
57766
57873
|
...prev2,
|
|
57767
57874
|
busy: true,
|
|
57768
57875
|
status: "Sending burner transaction..."
|
|
57769
57876
|
}));
|
|
57770
57877
|
try {
|
|
57771
|
-
const result = await
|
|
57878
|
+
const result = await unlink.burner.send(index, tx);
|
|
57772
57879
|
setState((prev2) => ({
|
|
57773
57880
|
...prev2,
|
|
57774
57881
|
busy: false,
|
|
@@ -57790,15 +57897,15 @@ function UnlinkProvider({
|
|
|
57790
57897
|
);
|
|
57791
57898
|
const burnerFund = useCallback(
|
|
57792
57899
|
async (index, params) => {
|
|
57793
|
-
const
|
|
57794
|
-
if (!
|
|
57900
|
+
const unlink = unlinkRef.current;
|
|
57901
|
+
if (!unlink) throw new Error("SDK not initialized");
|
|
57795
57902
|
setState((prev2) => ({
|
|
57796
57903
|
...prev2,
|
|
57797
57904
|
busy: true,
|
|
57798
57905
|
status: "Funding burner..."
|
|
57799
57906
|
}));
|
|
57800
57907
|
try {
|
|
57801
|
-
const result = await
|
|
57908
|
+
const result = await unlink.burner.fund(index, params);
|
|
57802
57909
|
setState((prev2) => ({
|
|
57803
57910
|
...prev2,
|
|
57804
57911
|
busy: false,
|
|
@@ -57820,15 +57927,15 @@ function UnlinkProvider({
|
|
|
57820
57927
|
);
|
|
57821
57928
|
const burnerSweepToPool = useCallback(
|
|
57822
57929
|
async (index, params) => {
|
|
57823
|
-
const
|
|
57824
|
-
if (!
|
|
57930
|
+
const unlink = unlinkRef.current;
|
|
57931
|
+
if (!unlink) throw new Error("SDK not initialized");
|
|
57825
57932
|
setState((prev2) => ({
|
|
57826
57933
|
...prev2,
|
|
57827
57934
|
busy: true,
|
|
57828
57935
|
status: "Sweeping burner to pool..."
|
|
57829
57936
|
}));
|
|
57830
57937
|
try {
|
|
57831
|
-
const result = await
|
|
57938
|
+
const result = await unlink.burner.sweepToPool(index, params);
|
|
57832
57939
|
setState((prev2) => ({
|
|
57833
57940
|
...prev2,
|
|
57834
57941
|
busy: false,
|
|
@@ -57850,24 +57957,24 @@ function UnlinkProvider({
|
|
|
57850
57957
|
);
|
|
57851
57958
|
const burnerGetTokenBalance = useCallback(
|
|
57852
57959
|
async (address, token) => {
|
|
57853
|
-
const
|
|
57854
|
-
if (!
|
|
57855
|
-
return
|
|
57960
|
+
const unlink = unlinkRef.current;
|
|
57961
|
+
if (!unlink) throw new Error("SDK not initialized");
|
|
57962
|
+
return unlink.burner.getTokenBalance(address, token);
|
|
57856
57963
|
},
|
|
57857
57964
|
[]
|
|
57858
57965
|
);
|
|
57859
57966
|
const burnerGetBalance = useCallback(
|
|
57860
57967
|
async (address) => {
|
|
57861
|
-
const
|
|
57862
|
-
if (!
|
|
57863
|
-
return
|
|
57968
|
+
const unlink = unlinkRef.current;
|
|
57969
|
+
if (!unlink) throw new Error("SDK not initialized");
|
|
57970
|
+
return unlink.burner.getBalance(address);
|
|
57864
57971
|
},
|
|
57865
57972
|
[]
|
|
57866
57973
|
);
|
|
57867
57974
|
const refresh = useCallback(async () => {
|
|
57868
|
-
const
|
|
57869
|
-
if (!
|
|
57870
|
-
const activeAccount = await
|
|
57975
|
+
const unlink = unlinkRef.current;
|
|
57976
|
+
if (!unlink) return;
|
|
57977
|
+
const activeAccount = await unlink.accounts.getActive();
|
|
57871
57978
|
if (!activeAccount) return;
|
|
57872
57979
|
setState((prev2) => ({
|
|
57873
57980
|
...prev2,
|
|
@@ -57875,8 +57982,8 @@ function UnlinkProvider({
|
|
|
57875
57982
|
status: "Syncing..."
|
|
57876
57983
|
}));
|
|
57877
57984
|
try {
|
|
57878
|
-
await
|
|
57879
|
-
await refreshState(
|
|
57985
|
+
await unlink.sync();
|
|
57986
|
+
await refreshState(unlink);
|
|
57880
57987
|
setState((prev2) => ({
|
|
57881
57988
|
...prev2,
|
|
57882
57989
|
busy: false,
|
|
@@ -57893,9 +58000,9 @@ function UnlinkProvider({
|
|
|
57893
58000
|
}
|
|
57894
58001
|
}, [refreshState]);
|
|
57895
58002
|
const forceResync = useCallback(async () => {
|
|
57896
|
-
const
|
|
57897
|
-
if (!
|
|
57898
|
-
const activeAccount = await
|
|
58003
|
+
const unlink = unlinkRef.current;
|
|
58004
|
+
if (!unlink) return;
|
|
58005
|
+
const activeAccount = await unlink.accounts.getActive();
|
|
57899
58006
|
if (!activeAccount) return;
|
|
57900
58007
|
setState((prev2) => ({
|
|
57901
58008
|
...prev2,
|
|
@@ -57903,8 +58010,8 @@ function UnlinkProvider({
|
|
|
57903
58010
|
status: "Resyncing..."
|
|
57904
58011
|
}));
|
|
57905
58012
|
try {
|
|
57906
|
-
await
|
|
57907
|
-
await refreshState(
|
|
58013
|
+
await unlink.sync({ forceFullResync: true });
|
|
58014
|
+
await refreshState(unlink);
|
|
57908
58015
|
setState((prev2) => ({
|
|
57909
58016
|
...prev2,
|
|
57910
58017
|
busy: false,
|
|
@@ -57924,9 +58031,9 @@ function UnlinkProvider({
|
|
|
57924
58031
|
setState((prev2) => ({ ...prev2, error: null }));
|
|
57925
58032
|
}, []);
|
|
57926
58033
|
const getTxStatus = useCallback(async (txId) => {
|
|
57927
|
-
const
|
|
57928
|
-
if (!
|
|
57929
|
-
const response = await
|
|
58034
|
+
const unlink = unlinkRef.current;
|
|
58035
|
+
if (!unlink) throw new Error("SDK not initialized");
|
|
58036
|
+
const response = await unlink.getTxStatus(txId);
|
|
57930
58037
|
return {
|
|
57931
58038
|
txId: response.id,
|
|
57932
58039
|
state: response.state,
|
|
@@ -57937,8 +58044,8 @@ function UnlinkProvider({
|
|
|
57937
58044
|
}, []);
|
|
57938
58045
|
const waitForConfirmation = useCallback(
|
|
57939
58046
|
async (txId, options) => {
|
|
57940
|
-
const
|
|
57941
|
-
if (!
|
|
58047
|
+
const unlink = unlinkRef.current;
|
|
58048
|
+
if (!unlink) throw new Error("SDK not initialized");
|
|
57942
58049
|
const timeout2 = options?.timeout ?? DEFAULT_CONFIRMATION_TIMEOUT_MS;
|
|
57943
58050
|
const startTime3 = Date.now();
|
|
57944
58051
|
let delay2 = CONFIRMATION_POLL_INTERVAL_MS;
|
|
@@ -57987,16 +58094,16 @@ function UnlinkProvider({
|
|
|
57987
58094
|
// Account actions
|
|
57988
58095
|
createAccount,
|
|
57989
58096
|
switchAccount,
|
|
57990
|
-
//
|
|
58097
|
+
// Send actions
|
|
57991
58098
|
send,
|
|
57992
|
-
|
|
57993
|
-
|
|
58099
|
+
planSend,
|
|
58100
|
+
executeSend,
|
|
57994
58101
|
// Deposit actions
|
|
57995
|
-
|
|
58102
|
+
deposit: deposit2,
|
|
57996
58103
|
// Withdraw actions
|
|
57997
|
-
|
|
57998
|
-
//
|
|
57999
|
-
|
|
58104
|
+
withdraw,
|
|
58105
|
+
// Interact actions
|
|
58106
|
+
interact,
|
|
58000
58107
|
planWithdraw,
|
|
58001
58108
|
executeWithdraw,
|
|
58002
58109
|
// Burner actions
|
|
@@ -58025,11 +58132,11 @@ function UnlinkProvider({
|
|
|
58025
58132
|
createAccount,
|
|
58026
58133
|
switchAccount,
|
|
58027
58134
|
send,
|
|
58028
|
-
|
|
58029
|
-
|
|
58030
|
-
|
|
58031
|
-
|
|
58032
|
-
|
|
58135
|
+
planSend,
|
|
58136
|
+
executeSend,
|
|
58137
|
+
deposit2,
|
|
58138
|
+
withdraw,
|
|
58139
|
+
interact,
|
|
58033
58140
|
planWithdraw,
|
|
58034
58141
|
executeWithdraw,
|
|
58035
58142
|
createBurner,
|
|
@@ -58062,20 +58169,20 @@ function useUnlink() {
|
|
|
58062
58169
|
// src/useUnlinkHistory.ts
|
|
58063
58170
|
import { useCallback as useCallback2, useEffect as useEffect2, useState as useState2 } from "react";
|
|
58064
58171
|
function useUnlinkHistory(options) {
|
|
58065
|
-
const {
|
|
58172
|
+
const { unlink, activeAccount } = useUnlink();
|
|
58066
58173
|
const includeSelfSends = options?.includeSelfSends;
|
|
58067
58174
|
const [history, setHistory] = useState2([]);
|
|
58068
58175
|
const [loading, setLoading] = useState2(true);
|
|
58069
58176
|
const [error, setError] = useState2(null);
|
|
58070
58177
|
const fetchHistory = useCallback2(async () => {
|
|
58071
|
-
if (!
|
|
58178
|
+
if (!unlink || !activeAccount) {
|
|
58072
58179
|
setHistory([]);
|
|
58073
58180
|
setLoading(false);
|
|
58074
58181
|
return;
|
|
58075
58182
|
}
|
|
58076
58183
|
try {
|
|
58077
58184
|
setLoading(true);
|
|
58078
|
-
const entries = await
|
|
58185
|
+
const entries = await unlink.getHistory({
|
|
58079
58186
|
includeSelfSends
|
|
58080
58187
|
});
|
|
58081
58188
|
setHistory(entries);
|
|
@@ -58085,19 +58192,19 @@ function useUnlinkHistory(options) {
|
|
|
58085
58192
|
} finally {
|
|
58086
58193
|
setLoading(false);
|
|
58087
58194
|
}
|
|
58088
|
-
}, [
|
|
58195
|
+
}, [unlink, activeAccount, includeSelfSends]);
|
|
58089
58196
|
useEffect2(() => {
|
|
58090
58197
|
void fetchHistory();
|
|
58091
58198
|
}, [fetchHistory]);
|
|
58092
58199
|
useEffect2(() => {
|
|
58093
|
-
if (!
|
|
58094
|
-
const unsubscribe =
|
|
58200
|
+
if (!unlink) return;
|
|
58201
|
+
const unsubscribe = unlink.on((event) => {
|
|
58095
58202
|
if (event.type === "notes-updated") {
|
|
58096
58203
|
void fetchHistory();
|
|
58097
58204
|
}
|
|
58098
58205
|
});
|
|
58099
58206
|
return unsubscribe;
|
|
58100
|
-
}, [
|
|
58207
|
+
}, [unlink, fetchHistory]);
|
|
58101
58208
|
const refresh = useCallback2(async () => {
|
|
58102
58209
|
await fetchHistory();
|
|
58103
58210
|
}, [fetchHistory]);
|
|
@@ -58130,7 +58237,7 @@ function useUnlinkBalances() {
|
|
|
58130
58237
|
// src/useTxStatus.ts
|
|
58131
58238
|
import { useCallback as useCallback3, useEffect as useEffect3, useRef as useRef2, useState as useState3 } from "react";
|
|
58132
58239
|
function useTxStatus(txId) {
|
|
58133
|
-
const { getTxStatus,
|
|
58240
|
+
const { getTxStatus, unlink } = useUnlink();
|
|
58134
58241
|
const [state, setState] = useState3(null);
|
|
58135
58242
|
const [txHash, setTxHash] = useState3(null);
|
|
58136
58243
|
const [blockNumber, setBlockNumber] = useState3(null);
|
|
@@ -58140,7 +58247,7 @@ function useTxStatus(txId) {
|
|
|
58140
58247
|
currentTxIdRef.current = txId;
|
|
58141
58248
|
const refresh = useCallback3(async () => {
|
|
58142
58249
|
const targetTxId = currentTxIdRef.current;
|
|
58143
|
-
if (!targetTxId || !
|
|
58250
|
+
if (!targetTxId || !unlink) return;
|
|
58144
58251
|
setIsLoading(true);
|
|
58145
58252
|
try {
|
|
58146
58253
|
const status = await getTxStatus(targetTxId);
|
|
@@ -58157,13 +58264,13 @@ function useTxStatus(txId) {
|
|
|
58157
58264
|
setIsLoading(false);
|
|
58158
58265
|
}
|
|
58159
58266
|
}
|
|
58160
|
-
}, [
|
|
58267
|
+
}, [unlink, getTxStatus]);
|
|
58161
58268
|
useEffect3(() => {
|
|
58162
|
-
if (txId &&
|
|
58163
|
-
|
|
58269
|
+
if (txId && unlink) {
|
|
58270
|
+
unlink.trackTx(txId);
|
|
58164
58271
|
void refresh();
|
|
58165
58272
|
return () => {
|
|
58166
|
-
|
|
58273
|
+
unlink.untrackTx(txId);
|
|
58167
58274
|
};
|
|
58168
58275
|
} else {
|
|
58169
58276
|
setState(null);
|
|
@@ -58171,10 +58278,10 @@ function useTxStatus(txId) {
|
|
|
58171
58278
|
setBlockNumber(null);
|
|
58172
58279
|
setError(null);
|
|
58173
58280
|
}
|
|
58174
|
-
}, [txId,
|
|
58281
|
+
}, [txId, unlink, refresh]);
|
|
58175
58282
|
useEffect3(() => {
|
|
58176
|
-
if (!
|
|
58177
|
-
const unsubscribe =
|
|
58283
|
+
if (!unlink || !txId) return;
|
|
58284
|
+
const unsubscribe = unlink.on((event) => {
|
|
58178
58285
|
if (event.type === "tx-status-changed" && event.txId === txId) {
|
|
58179
58286
|
setState(event.state);
|
|
58180
58287
|
setTxHash(event.txHash ?? null);
|
|
@@ -58183,7 +58290,7 @@ function useTxStatus(txId) {
|
|
|
58183
58290
|
}
|
|
58184
58291
|
});
|
|
58185
58292
|
return unsubscribe;
|
|
58186
|
-
}, [
|
|
58293
|
+
}, [unlink, txId]);
|
|
58187
58294
|
return { state, txHash, blockNumber, error, isLoading, refresh };
|
|
58188
58295
|
}
|
|
58189
58296
|
|
|
@@ -58248,45 +58355,49 @@ function useOperationMutation(operation) {
|
|
|
58248
58355
|
|
|
58249
58356
|
// src/useDeposit.ts
|
|
58250
58357
|
function useDeposit() {
|
|
58251
|
-
const {
|
|
58358
|
+
const { deposit: deposit2 } = useUnlink();
|
|
58252
58359
|
const op = useCallback5(
|
|
58253
|
-
(params) =>
|
|
58254
|
-
[
|
|
58360
|
+
(params) => deposit2(params),
|
|
58361
|
+
[deposit2]
|
|
58255
58362
|
);
|
|
58256
|
-
|
|
58363
|
+
const { execute, ...rest } = useOperationMutation(op);
|
|
58364
|
+
return { deposit: execute, ...rest };
|
|
58257
58365
|
}
|
|
58258
58366
|
|
|
58259
|
-
// src/
|
|
58367
|
+
// src/useSend.ts
|
|
58260
58368
|
import { useCallback as useCallback6 } from "react";
|
|
58261
|
-
function
|
|
58369
|
+
function useSend(overrides) {
|
|
58262
58370
|
const { send } = useUnlink();
|
|
58263
58371
|
const op = useCallback6(
|
|
58264
58372
|
(params) => send(params, overrides),
|
|
58265
58373
|
[send, overrides]
|
|
58266
58374
|
);
|
|
58267
|
-
|
|
58375
|
+
const { execute, ...rest } = useOperationMutation(op);
|
|
58376
|
+
return { send: execute, ...rest };
|
|
58268
58377
|
}
|
|
58269
58378
|
|
|
58270
58379
|
// src/useWithdraw.ts
|
|
58271
58380
|
import { useCallback as useCallback7 } from "react";
|
|
58272
58381
|
function useWithdraw(overrides) {
|
|
58273
|
-
const {
|
|
58382
|
+
const { withdraw } = useUnlink();
|
|
58274
58383
|
const op = useCallback7(
|
|
58275
|
-
(params) =>
|
|
58276
|
-
[
|
|
58384
|
+
(params) => withdraw(params, overrides),
|
|
58385
|
+
[withdraw, overrides]
|
|
58277
58386
|
);
|
|
58278
|
-
|
|
58387
|
+
const { execute, ...rest } = useOperationMutation(op);
|
|
58388
|
+
return { withdraw: execute, ...rest };
|
|
58279
58389
|
}
|
|
58280
58390
|
|
|
58281
|
-
// src/
|
|
58391
|
+
// src/useInteract.ts
|
|
58282
58392
|
import { useCallback as useCallback8 } from "react";
|
|
58283
|
-
function
|
|
58284
|
-
const {
|
|
58393
|
+
function useInteract() {
|
|
58394
|
+
const { interact } = useUnlink();
|
|
58285
58395
|
const op = useCallback8(
|
|
58286
|
-
(params) =>
|
|
58287
|
-
[
|
|
58396
|
+
(params) => interact(params),
|
|
58397
|
+
[interact]
|
|
58288
58398
|
);
|
|
58289
|
-
|
|
58399
|
+
const { execute, ...rest } = useOperationMutation(op);
|
|
58400
|
+
return { interact: execute, ...rest };
|
|
58290
58401
|
}
|
|
58291
58402
|
|
|
58292
58403
|
// src/useBurner.ts
|
|
@@ -58335,7 +58446,10 @@ export {
|
|
|
58335
58446
|
TimeoutError2 as TimeoutError,
|
|
58336
58447
|
TransactionFailedError,
|
|
58337
58448
|
UnlinkProvider,
|
|
58449
|
+
approve,
|
|
58450
|
+
buildApproveCall,
|
|
58338
58451
|
computeBalances,
|
|
58452
|
+
contract,
|
|
58339
58453
|
decodeAddress,
|
|
58340
58454
|
encodeAddress,
|
|
58341
58455
|
formatAmount,
|
|
@@ -58344,11 +58458,12 @@ export {
|
|
|
58344
58458
|
parseZkAddress,
|
|
58345
58459
|
randomHex,
|
|
58346
58460
|
shortenHex,
|
|
58347
|
-
|
|
58461
|
+
toCall,
|
|
58348
58462
|
useBurner,
|
|
58349
58463
|
useDeposit,
|
|
58464
|
+
useInteract,
|
|
58350
58465
|
useOperationMutation,
|
|
58351
|
-
|
|
58466
|
+
useSend,
|
|
58352
58467
|
useTxStatus,
|
|
58353
58468
|
useUnlink,
|
|
58354
58469
|
useUnlinkBalance,
|