@unlink-xyz/react 0.1.3-canary.f8763d3 → 0.1.3-canary.fd96273
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 +20 -17
- package/dist/index.js +473 -263
- package/dist/index.js.map +1 -1
- package/dist/multisig/index.d.ts +106 -0
- package/dist/multisig/index.js +31353 -0
- package/dist/multisig/index.js.map +1 -0
- package/package.json +12 -2
package/dist/index.js
CHANGED
|
@@ -9042,9 +9042,9 @@ function genBech32(encoding) {
|
|
|
9042
9042
|
}
|
|
9043
9043
|
var bech32m = /* @__PURE__ */ genBech32("bech32m");
|
|
9044
9044
|
var VERSION = 1;
|
|
9045
|
-
var LIMIT =
|
|
9045
|
+
var LIMIT = 130;
|
|
9046
9046
|
var ALL_CHAINS = "ffffffffffffffff";
|
|
9047
|
-
var PREFIX = "
|
|
9047
|
+
var PREFIX = "unlink";
|
|
9048
9048
|
var SALT = new TextEncoder().encode("unlink");
|
|
9049
9049
|
function xorWithSalt(hex2) {
|
|
9050
9050
|
const bytes2 = Hex.toBytes(hex2);
|
|
@@ -9162,7 +9162,7 @@ function parseZkAddress(value) {
|
|
|
9162
9162
|
};
|
|
9163
9163
|
} catch (err) {
|
|
9164
9164
|
throw new ValidationError(
|
|
9165
|
-
`Invalid ZK address (expected
|
|
9165
|
+
`Invalid ZK address (expected unlink1... format): ${err instanceof Error ? err.message : "unknown error"}`
|
|
9166
9166
|
);
|
|
9167
9167
|
}
|
|
9168
9168
|
}
|
|
@@ -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) {
|
|
@@ -35647,29 +35647,41 @@ function createJsonHttpClient(baseUrl, deps) {
|
|
|
35647
35647
|
fetch: fetchImpl,
|
|
35648
35648
|
// Disable ky's automatic error throwing to prevent browser DevTools
|
|
35649
35649
|
// from logging expected 404s as network errors
|
|
35650
|
-
throwHttpErrors: false
|
|
35650
|
+
throwHttpErrors: false,
|
|
35651
|
+
retry: 0
|
|
35651
35652
|
});
|
|
35653
|
+
const RETRYABLE_STATUSES = [502, 503, 504];
|
|
35654
|
+
const MAX_RETRIES = 3;
|
|
35655
|
+
const BASE_DELAY_MS = 500;
|
|
35652
35656
|
return {
|
|
35653
35657
|
async request(opts) {
|
|
35654
35658
|
let res;
|
|
35655
|
-
|
|
35656
|
-
|
|
35657
|
-
|
|
35658
|
-
|
|
35659
|
-
|
|
35660
|
-
|
|
35661
|
-
|
|
35662
|
-
|
|
35663
|
-
|
|
35664
|
-
|
|
35665
|
-
|
|
35666
|
-
|
|
35659
|
+
for (let attempt = 0; attempt <= MAX_RETRIES; attempt++) {
|
|
35660
|
+
try {
|
|
35661
|
+
res = await api(opts.path.replace(/^\//, ""), {
|
|
35662
|
+
method: opts.method,
|
|
35663
|
+
searchParams: opts.query,
|
|
35664
|
+
json: opts.json,
|
|
35665
|
+
body: opts.body,
|
|
35666
|
+
headers: opts.headers,
|
|
35667
|
+
signal: opts.signal
|
|
35668
|
+
});
|
|
35669
|
+
} catch (err) {
|
|
35670
|
+
if (err instanceof TimeoutError) {
|
|
35671
|
+
throw new HttpError("HTTP timeout", 408, null);
|
|
35672
|
+
}
|
|
35673
|
+
throw new HttpError(
|
|
35674
|
+
err instanceof Error ? err.message : "Network error",
|
|
35675
|
+
0,
|
|
35676
|
+
null
|
|
35677
|
+
);
|
|
35667
35678
|
}
|
|
35668
|
-
|
|
35669
|
-
|
|
35670
|
-
|
|
35671
|
-
|
|
35672
|
-
|
|
35679
|
+
if (RETRYABLE_STATUSES.includes(res.status) && attempt < MAX_RETRIES) {
|
|
35680
|
+
const delay2 = BASE_DELAY_MS * 2 ** attempt + Math.random() * 200;
|
|
35681
|
+
await new Promise((r2) => setTimeout(r2, delay2));
|
|
35682
|
+
continue;
|
|
35683
|
+
}
|
|
35684
|
+
break;
|
|
35673
35685
|
}
|
|
35674
35686
|
if (!res.ok) {
|
|
35675
35687
|
const body = await readErrorBodySafe(res);
|
|
@@ -35919,6 +35931,16 @@ function parseChainConfig(chain2, value) {
|
|
|
35919
35931
|
"artifactVersion",
|
|
35920
35932
|
raw.artifactVersion
|
|
35921
35933
|
).replace(/^\/+|\/+$/g, "");
|
|
35934
|
+
const adapterAddress = parseOptionalString(
|
|
35935
|
+
chain2,
|
|
35936
|
+
"adapterAddress",
|
|
35937
|
+
raw.adapterAddress
|
|
35938
|
+
);
|
|
35939
|
+
const frostUrl = parseOptionalString(
|
|
35940
|
+
chain2,
|
|
35941
|
+
"frostUrl",
|
|
35942
|
+
raw.frostUrl
|
|
35943
|
+
)?.replace(/\/+$/, "");
|
|
35922
35944
|
const artifactBaseUrl = parseOptionalString(
|
|
35923
35945
|
chain2,
|
|
35924
35946
|
"artifactBaseUrl",
|
|
@@ -35927,7 +35949,9 @@ function parseChainConfig(chain2, value) {
|
|
|
35927
35949
|
return {
|
|
35928
35950
|
chainId,
|
|
35929
35951
|
gatewayUrl,
|
|
35952
|
+
...frostUrl !== void 0 ? { frostUrl } : {},
|
|
35930
35953
|
poolAddress,
|
|
35954
|
+
...adapterAddress !== void 0 ? { adapterAddress } : {},
|
|
35931
35955
|
artifactVersion,
|
|
35932
35956
|
...artifactBaseUrl !== void 0 ? { artifactBaseUrl } : { artifactBaseUrl: DEFAULT_ARTIFACT_BASE_URL }
|
|
35933
35957
|
};
|
|
@@ -53332,6 +53356,114 @@ var circuits_default = {
|
|
|
53332
53356
|
template: "JoinSplit",
|
|
53333
53357
|
pubs: ["merkleRoot", "boundParamsHash", "nullifiers", "commitmentsOut"],
|
|
53334
53358
|
params: [5, 2, 16]
|
|
53359
|
+
},
|
|
53360
|
+
joinsplit_1x3_16: {
|
|
53361
|
+
file: "joinsplit",
|
|
53362
|
+
template: "JoinSplit",
|
|
53363
|
+
pubs: ["merkleRoot", "boundParamsHash", "nullifiers", "commitmentsOut"],
|
|
53364
|
+
params: [1, 3, 16]
|
|
53365
|
+
},
|
|
53366
|
+
joinsplit_4x3_16: {
|
|
53367
|
+
file: "joinsplit",
|
|
53368
|
+
template: "JoinSplit",
|
|
53369
|
+
pubs: ["merkleRoot", "boundParamsHash", "nullifiers", "commitmentsOut"],
|
|
53370
|
+
params: [4, 3, 16]
|
|
53371
|
+
},
|
|
53372
|
+
joinsplit_5x3_16: {
|
|
53373
|
+
file: "joinsplit",
|
|
53374
|
+
template: "JoinSplit",
|
|
53375
|
+
pubs: ["merkleRoot", "boundParamsHash", "nullifiers", "commitmentsOut"],
|
|
53376
|
+
params: [5, 3, 16]
|
|
53377
|
+
},
|
|
53378
|
+
joinsplit_6x1_16: {
|
|
53379
|
+
file: "joinsplit",
|
|
53380
|
+
template: "JoinSplit",
|
|
53381
|
+
pubs: ["merkleRoot", "boundParamsHash", "nullifiers", "commitmentsOut"],
|
|
53382
|
+
params: [6, 1, 16]
|
|
53383
|
+
},
|
|
53384
|
+
joinsplit_6x2_16: {
|
|
53385
|
+
file: "joinsplit",
|
|
53386
|
+
template: "JoinSplit",
|
|
53387
|
+
pubs: ["merkleRoot", "boundParamsHash", "nullifiers", "commitmentsOut"],
|
|
53388
|
+
params: [6, 2, 16]
|
|
53389
|
+
},
|
|
53390
|
+
joinsplit_6x3_16: {
|
|
53391
|
+
file: "joinsplit",
|
|
53392
|
+
template: "JoinSplit",
|
|
53393
|
+
pubs: ["merkleRoot", "boundParamsHash", "nullifiers", "commitmentsOut"],
|
|
53394
|
+
params: [6, 3, 16]
|
|
53395
|
+
},
|
|
53396
|
+
joinsplit_7x1_16: {
|
|
53397
|
+
file: "joinsplit",
|
|
53398
|
+
template: "JoinSplit",
|
|
53399
|
+
pubs: ["merkleRoot", "boundParamsHash", "nullifiers", "commitmentsOut"],
|
|
53400
|
+
params: [7, 1, 16]
|
|
53401
|
+
},
|
|
53402
|
+
joinsplit_7x2_16: {
|
|
53403
|
+
file: "joinsplit",
|
|
53404
|
+
template: "JoinSplit",
|
|
53405
|
+
pubs: ["merkleRoot", "boundParamsHash", "nullifiers", "commitmentsOut"],
|
|
53406
|
+
params: [7, 2, 16]
|
|
53407
|
+
},
|
|
53408
|
+
joinsplit_7x3_16: {
|
|
53409
|
+
file: "joinsplit",
|
|
53410
|
+
template: "JoinSplit",
|
|
53411
|
+
pubs: ["merkleRoot", "boundParamsHash", "nullifiers", "commitmentsOut"],
|
|
53412
|
+
params: [7, 3, 16]
|
|
53413
|
+
},
|
|
53414
|
+
joinsplit_8x1_16: {
|
|
53415
|
+
file: "joinsplit",
|
|
53416
|
+
template: "JoinSplit",
|
|
53417
|
+
pubs: ["merkleRoot", "boundParamsHash", "nullifiers", "commitmentsOut"],
|
|
53418
|
+
params: [8, 1, 16]
|
|
53419
|
+
},
|
|
53420
|
+
joinsplit_8x2_16: {
|
|
53421
|
+
file: "joinsplit",
|
|
53422
|
+
template: "JoinSplit",
|
|
53423
|
+
pubs: ["merkleRoot", "boundParamsHash", "nullifiers", "commitmentsOut"],
|
|
53424
|
+
params: [8, 2, 16]
|
|
53425
|
+
},
|
|
53426
|
+
joinsplit_8x3_16: {
|
|
53427
|
+
file: "joinsplit",
|
|
53428
|
+
template: "JoinSplit",
|
|
53429
|
+
pubs: ["merkleRoot", "boundParamsHash", "nullifiers", "commitmentsOut"],
|
|
53430
|
+
params: [8, 3, 16]
|
|
53431
|
+
},
|
|
53432
|
+
joinsplit_9x1_16: {
|
|
53433
|
+
file: "joinsplit",
|
|
53434
|
+
template: "JoinSplit",
|
|
53435
|
+
pubs: ["merkleRoot", "boundParamsHash", "nullifiers", "commitmentsOut"],
|
|
53436
|
+
params: [9, 1, 16]
|
|
53437
|
+
},
|
|
53438
|
+
joinsplit_9x2_16: {
|
|
53439
|
+
file: "joinsplit",
|
|
53440
|
+
template: "JoinSplit",
|
|
53441
|
+
pubs: ["merkleRoot", "boundParamsHash", "nullifiers", "commitmentsOut"],
|
|
53442
|
+
params: [9, 2, 16]
|
|
53443
|
+
},
|
|
53444
|
+
joinsplit_9x3_16: {
|
|
53445
|
+
file: "joinsplit",
|
|
53446
|
+
template: "JoinSplit",
|
|
53447
|
+
pubs: ["merkleRoot", "boundParamsHash", "nullifiers", "commitmentsOut"],
|
|
53448
|
+
params: [9, 3, 16]
|
|
53449
|
+
},
|
|
53450
|
+
joinsplit_10x1_16: {
|
|
53451
|
+
file: "joinsplit",
|
|
53452
|
+
template: "JoinSplit",
|
|
53453
|
+
pubs: ["merkleRoot", "boundParamsHash", "nullifiers", "commitmentsOut"],
|
|
53454
|
+
params: [10, 1, 16]
|
|
53455
|
+
},
|
|
53456
|
+
joinsplit_10x2_16: {
|
|
53457
|
+
file: "joinsplit",
|
|
53458
|
+
template: "JoinSplit",
|
|
53459
|
+
pubs: ["merkleRoot", "boundParamsHash", "nullifiers", "commitmentsOut"],
|
|
53460
|
+
params: [10, 2, 16]
|
|
53461
|
+
},
|
|
53462
|
+
joinsplit_10x3_16: {
|
|
53463
|
+
file: "joinsplit",
|
|
53464
|
+
template: "JoinSplit",
|
|
53465
|
+
pubs: ["merkleRoot", "boundParamsHash", "nullifiers", "commitmentsOut"],
|
|
53466
|
+
params: [10, 3, 16]
|
|
53335
53467
|
}
|
|
53336
53468
|
};
|
|
53337
53469
|
var registry = {};
|
|
@@ -53347,7 +53479,7 @@ var SUPPORTED_CIRCUITS = Object.keys(CIRCUIT_REGISTRY);
|
|
|
53347
53479
|
function getCircuitConfig(inputs, outputs) {
|
|
53348
53480
|
return CIRCUIT_REGISTRY[`${inputs}x${outputs}`];
|
|
53349
53481
|
}
|
|
53350
|
-
var MAX_ARTIFACT_CACHE_ENTRIES =
|
|
53482
|
+
var MAX_ARTIFACT_CACHE_ENTRIES = 16;
|
|
53351
53483
|
var artifactCache = /* @__PURE__ */ new Map();
|
|
53352
53484
|
function selectCircuit(inputs, outputs) {
|
|
53353
53485
|
const config22 = getCircuitConfig(inputs, outputs);
|
|
@@ -54182,6 +54314,58 @@ function normalizeReshield(reshield, index) {
|
|
|
54182
54314
|
);
|
|
54183
54315
|
return { npk, random, token, minAmount };
|
|
54184
54316
|
}
|
|
54317
|
+
function approve(token, spender, amount) {
|
|
54318
|
+
const normalizedToken = ensureAddress("token", token);
|
|
54319
|
+
const normalizedSpender = ensureAddress("spender", spender);
|
|
54320
|
+
const normalizedAmount = ensureNonNegative("amount", amount);
|
|
54321
|
+
const data = approveInterface.encodeFunctionData("approve", [
|
|
54322
|
+
normalizedSpender,
|
|
54323
|
+
normalizedAmount
|
|
54324
|
+
]);
|
|
54325
|
+
return {
|
|
54326
|
+
to: normalizedToken,
|
|
54327
|
+
data,
|
|
54328
|
+
value: 0n
|
|
54329
|
+
};
|
|
54330
|
+
}
|
|
54331
|
+
function toCall(tx) {
|
|
54332
|
+
if (tx.to == null) {
|
|
54333
|
+
throw new AdapterError("tx.to is required");
|
|
54334
|
+
}
|
|
54335
|
+
const to = ensureAddress("tx.to", tx.to);
|
|
54336
|
+
if (tx.data == null) {
|
|
54337
|
+
throw new AdapterError("tx.data is required");
|
|
54338
|
+
}
|
|
54339
|
+
const data = ensureHexData("tx.data", tx.data);
|
|
54340
|
+
let value;
|
|
54341
|
+
if (tx.value == null) {
|
|
54342
|
+
value = 0n;
|
|
54343
|
+
} else {
|
|
54344
|
+
try {
|
|
54345
|
+
value = BigInt(tx.value);
|
|
54346
|
+
} catch {
|
|
54347
|
+
throw new AdapterError(
|
|
54348
|
+
`tx.value must be convertible to bigint, received: ${String(tx.value)}`
|
|
54349
|
+
);
|
|
54350
|
+
}
|
|
54351
|
+
}
|
|
54352
|
+
return { to, data, value: ensureNonNegative("tx.value", value) };
|
|
54353
|
+
}
|
|
54354
|
+
function contract(address, abi) {
|
|
54355
|
+
const to = ensureAddress("contract.address", address);
|
|
54356
|
+
const iface = new Interface(abi);
|
|
54357
|
+
return new Proxy(
|
|
54358
|
+
{},
|
|
54359
|
+
{
|
|
54360
|
+
get(_, method) {
|
|
54361
|
+
return (...args) => {
|
|
54362
|
+
const data = iface.encodeFunctionData(method, args);
|
|
54363
|
+
return { to, data, value: 0n };
|
|
54364
|
+
};
|
|
54365
|
+
}
|
|
54366
|
+
}
|
|
54367
|
+
);
|
|
54368
|
+
}
|
|
54185
54369
|
function encodeAdapterExecute(params) {
|
|
54186
54370
|
const transactCalldata = ensureHexData(
|
|
54187
54371
|
"transactCalldata",
|
|
@@ -54205,6 +54389,7 @@ function encodeAdapterExecute(params) {
|
|
|
54205
54389
|
deadline
|
|
54206
54390
|
]);
|
|
54207
54391
|
}
|
|
54392
|
+
var buildApproveCall = approve;
|
|
54208
54393
|
init_process();
|
|
54209
54394
|
init_buffer();
|
|
54210
54395
|
init_process();
|
|
@@ -55591,26 +55776,24 @@ function normalizeCall2(call, index) {
|
|
|
55591
55776
|
value: call.value
|
|
55592
55777
|
};
|
|
55593
55778
|
}
|
|
55594
|
-
function
|
|
55595
|
-
const token = ensureAddress(`
|
|
55779
|
+
function normalizeSpendInput(input, index) {
|
|
55780
|
+
const token = ensureAddress(`spend[${index}].token`, input.token);
|
|
55596
55781
|
if (input.amount <= 0n) {
|
|
55597
|
-
throw new AdapterError(`
|
|
55782
|
+
throw new AdapterError(`spend[${index}].amount must be greater than zero`);
|
|
55598
55783
|
}
|
|
55599
55784
|
return {
|
|
55600
55785
|
token,
|
|
55601
55786
|
amount: input.amount
|
|
55602
55787
|
};
|
|
55603
55788
|
}
|
|
55604
|
-
function
|
|
55605
|
-
const token = ensureAddress(`
|
|
55606
|
-
if (
|
|
55607
|
-
throw new AdapterError(
|
|
55608
|
-
`reshields[${index}].minAmount must be non-negative`
|
|
55609
|
-
);
|
|
55789
|
+
function normalizeReceiveInput(receive, index) {
|
|
55790
|
+
const token = ensureAddress(`receive[${index}].token`, receive.token);
|
|
55791
|
+
if (receive.minAmount < 0n) {
|
|
55792
|
+
throw new AdapterError(`receive[${index}].minAmount must be non-negative`);
|
|
55610
55793
|
}
|
|
55611
55794
|
return {
|
|
55612
55795
|
token,
|
|
55613
|
-
minAmount:
|
|
55796
|
+
minAmount: receive.minAmount
|
|
55614
55797
|
};
|
|
55615
55798
|
}
|
|
55616
55799
|
function randomFieldElement(randomBigintFn) {
|
|
@@ -55630,41 +55813,41 @@ function createAdapterService(deps) {
|
|
|
55630
55813
|
"adapterAddress",
|
|
55631
55814
|
params.adapterAddress
|
|
55632
55815
|
);
|
|
55633
|
-
if (!params.
|
|
55634
|
-
throw new AdapterError("at least one
|
|
55816
|
+
if (!params.spend.length) {
|
|
55817
|
+
throw new AdapterError("at least one spend token is required");
|
|
55635
55818
|
}
|
|
55636
55819
|
if (!params.calls.length) {
|
|
55637
55820
|
throw new AdapterError("at least one adapter call is required");
|
|
55638
55821
|
}
|
|
55639
|
-
if (!params.
|
|
55640
|
-
throw new AdapterError("at least one
|
|
55822
|
+
if (!params.receive.length) {
|
|
55823
|
+
throw new AdapterError("at least one receive output is required");
|
|
55641
55824
|
}
|
|
55642
|
-
const
|
|
55643
|
-
(input, i) =>
|
|
55825
|
+
const spendInputs = params.spend.map(
|
|
55826
|
+
(input, i) => normalizeSpendInput(input, i)
|
|
55644
55827
|
);
|
|
55645
55828
|
const seenTokens = /* @__PURE__ */ new Set();
|
|
55646
|
-
for (const input of
|
|
55829
|
+
for (const input of spendInputs) {
|
|
55647
55830
|
const lower = input.token.toLowerCase();
|
|
55648
55831
|
if (seenTokens.has(lower)) {
|
|
55649
55832
|
throw new AdapterError(
|
|
55650
|
-
`duplicate
|
|
55833
|
+
`duplicate spend token ${input.token}; combine amounts per token instead`
|
|
55651
55834
|
);
|
|
55652
55835
|
}
|
|
55653
55836
|
seenTokens.add(lower);
|
|
55654
55837
|
}
|
|
55655
55838
|
const calls = params.calls.map((call, i) => normalizeCall2(call, i));
|
|
55656
|
-
const
|
|
55657
|
-
(
|
|
55839
|
+
const receiveSpecs = params.receive.map(
|
|
55840
|
+
(receive, i) => normalizeReceiveInput(receive, i)
|
|
55658
55841
|
);
|
|
55659
|
-
const
|
|
55660
|
-
for (const r2 of
|
|
55842
|
+
const seenReceiveTokens = /* @__PURE__ */ new Set();
|
|
55843
|
+
for (const r2 of receiveSpecs) {
|
|
55661
55844
|
const lower = r2.token.toLowerCase();
|
|
55662
|
-
if (
|
|
55845
|
+
if (seenReceiveTokens.has(lower)) {
|
|
55663
55846
|
throw new AdapterError(
|
|
55664
|
-
`duplicate
|
|
55847
|
+
`duplicate receive token ${r2.token}; each receive must target a unique token`
|
|
55665
55848
|
);
|
|
55666
55849
|
}
|
|
55667
|
-
|
|
55850
|
+
seenReceiveTokens.add(lower);
|
|
55668
55851
|
}
|
|
55669
55852
|
const account = overrides?.account ?? await deps.requireActiveAccount();
|
|
55670
55853
|
const signer = overrides?.signer ?? deps.requireSigner(account);
|
|
@@ -55674,19 +55857,19 @@ function createAdapterService(deps) {
|
|
|
55674
55857
|
throw new AdapterError("deadline must be in the future");
|
|
55675
55858
|
}
|
|
55676
55859
|
const executionCalls = calls;
|
|
55677
|
-
const reshields =
|
|
55678
|
-
(
|
|
55860
|
+
const reshields = receiveSpecs.map(
|
|
55861
|
+
(receive) => {
|
|
55679
55862
|
const random = randomFieldElement(randomBigintImpl);
|
|
55680
55863
|
const npk = poseidon([account.masterPublicKey, random]);
|
|
55681
55864
|
return {
|
|
55682
55865
|
npk,
|
|
55683
55866
|
random,
|
|
55684
|
-
token:
|
|
55685
|
-
minAmount:
|
|
55867
|
+
token: receive.token,
|
|
55868
|
+
minAmount: receive.minAmount
|
|
55686
55869
|
};
|
|
55687
55870
|
}
|
|
55688
55871
|
);
|
|
55689
|
-
const inputTokens =
|
|
55872
|
+
const inputTokens = spendInputs.map((input) => input.token);
|
|
55690
55873
|
const nonce = randomFieldElement(randomBigintImpl);
|
|
55691
55874
|
const adapterDataHash = computeAdapterDataHash({
|
|
55692
55875
|
calls: executionCalls,
|
|
@@ -55703,7 +55886,7 @@ function createAdapterService(deps) {
|
|
|
55703
55886
|
});
|
|
55704
55887
|
const withdrawalPlans = planWithdrawalsImpl(
|
|
55705
55888
|
notes,
|
|
55706
|
-
|
|
55889
|
+
spendInputs.map((input) => ({
|
|
55707
55890
|
token: input.token,
|
|
55708
55891
|
amount: input.amount,
|
|
55709
55892
|
recipient: adapterAddress
|
|
@@ -55786,7 +55969,7 @@ function createAdapterService(deps) {
|
|
|
55786
55969
|
adapterCalldata,
|
|
55787
55970
|
historyPreview: {
|
|
55788
55971
|
kind: "Withdraw",
|
|
55789
|
-
amounts:
|
|
55972
|
+
amounts: spendInputs.map((input) => ({
|
|
55790
55973
|
token: input.token,
|
|
55791
55974
|
delta: (-input.amount).toString()
|
|
55792
55975
|
}))
|
|
@@ -55853,8 +56036,8 @@ function createBurnerService(deps) {
|
|
|
55853
56036
|
}
|
|
55854
56037
|
async function getTokenBalance(address, token) {
|
|
55855
56038
|
const iface = new Interface([ERC20_BALANCE_OF]);
|
|
55856
|
-
const
|
|
55857
|
-
const bal = await
|
|
56039
|
+
const contract2 = new Contract(token, iface, provider);
|
|
56040
|
+
const bal = await contract2.getFunction("balanceOf")(address);
|
|
55858
56041
|
return BigInt(bal ?? 0);
|
|
55859
56042
|
}
|
|
55860
56043
|
async function getBalance(address) {
|
|
@@ -56553,10 +56736,31 @@ var UnlinkWallet = class _UnlinkWallet {
|
|
|
56553
56736
|
chainId;
|
|
56554
56737
|
/** Pool contract address this wallet transacts with. */
|
|
56555
56738
|
poolAddress;
|
|
56556
|
-
|
|
56739
|
+
/** Adapter contract address for DeFi operations. */
|
|
56740
|
+
adapterAddress;
|
|
56741
|
+
constructor(sdk, chainId, poolAddress, adapterAddress) {
|
|
56557
56742
|
this.sdk = sdk;
|
|
56558
56743
|
this.chainId = chainId;
|
|
56559
56744
|
this.poolAddress = poolAddress;
|
|
56745
|
+
this.adapterAddress = adapterAddress;
|
|
56746
|
+
this.adapter = {
|
|
56747
|
+
address: adapterAddress,
|
|
56748
|
+
execute: (params, opts, overrides) => {
|
|
56749
|
+
return this.sdk.adapter.execute(
|
|
56750
|
+
{
|
|
56751
|
+
chainId: this.chainId,
|
|
56752
|
+
poolAddress: this.poolAddress,
|
|
56753
|
+
adapterAddress: this.adapterAddress,
|
|
56754
|
+
spend: params.spend,
|
|
56755
|
+
calls: params.calls,
|
|
56756
|
+
receive: params.receive,
|
|
56757
|
+
deadline: params.deadline
|
|
56758
|
+
},
|
|
56759
|
+
opts,
|
|
56760
|
+
overrides
|
|
56761
|
+
);
|
|
56762
|
+
}
|
|
56763
|
+
};
|
|
56560
56764
|
}
|
|
56561
56765
|
/**
|
|
56562
56766
|
* Create a new UnlinkWallet instance.
|
|
@@ -56571,12 +56775,14 @@ var UnlinkWallet = class _UnlinkWallet {
|
|
|
56571
56775
|
let chainId;
|
|
56572
56776
|
let gatewayUrl;
|
|
56573
56777
|
let poolAddress;
|
|
56778
|
+
let adapterAddress;
|
|
56574
56779
|
let proverConfig = config22.prover;
|
|
56575
56780
|
if ("chain" in config22) {
|
|
56576
56781
|
const chainConfig = await fetchChainConfig(config22.chain);
|
|
56577
56782
|
chainId = chainConfig.chainId;
|
|
56578
56783
|
gatewayUrl = chainConfig.gatewayUrl;
|
|
56579
56784
|
poolAddress = config22.poolAddress ?? chainConfig.poolAddress;
|
|
56785
|
+
adapterAddress = config22.adapterAddress ?? chainConfig.adapterAddress;
|
|
56580
56786
|
proverConfig = {
|
|
56581
56787
|
artifactSource: {
|
|
56582
56788
|
baseUrl: config22.prover?.artifactSource?.baseUrl ?? chainConfig.artifactBaseUrl,
|
|
@@ -56588,6 +56794,7 @@ var UnlinkWallet = class _UnlinkWallet {
|
|
|
56588
56794
|
chainId = config22.chainId;
|
|
56589
56795
|
gatewayUrl = config22.gatewayUrl;
|
|
56590
56796
|
poolAddress = config22.poolAddress;
|
|
56797
|
+
adapterAddress = config22.adapterAddress;
|
|
56591
56798
|
if (typeof window !== "undefined" && !config22.prover?.artifactSource?.version) {
|
|
56592
56799
|
throw new InitializationError(
|
|
56593
56800
|
"prover.artifactSource.version is required in browser when using explicit gatewayUrl mode. Use chain mode or provide a pinned artifact version."
|
|
@@ -56608,7 +56815,7 @@ var UnlinkWallet = class _UnlinkWallet {
|
|
|
56608
56815
|
autoSync: config22.autoSync
|
|
56609
56816
|
}
|
|
56610
56817
|
);
|
|
56611
|
-
return new _UnlinkWallet(sdk, chainId, poolAddress);
|
|
56818
|
+
return new _UnlinkWallet(sdk, chainId, poolAddress, adapterAddress ?? "");
|
|
56612
56819
|
}
|
|
56613
56820
|
// ===== Seed Lifecycle =====
|
|
56614
56821
|
/** Seed management (create, import, export, delete mnemonic). */
|
|
@@ -56818,28 +57025,9 @@ var UnlinkWallet = class _UnlinkWallet {
|
|
|
56818
57025
|
// ===== Adapter =====
|
|
56819
57026
|
/**
|
|
56820
57027
|
* Private DeFi adapter operations.
|
|
56821
|
-
* chainId/poolAddress are injected automatically.
|
|
57028
|
+
* chainId/poolAddress/adapterAddress are injected automatically.
|
|
56822
57029
|
*/
|
|
56823
|
-
adapter
|
|
56824
|
-
/**
|
|
56825
|
-
* Execute an atomic unshield -> call(s) -> reshield flow through an adapter.
|
|
56826
|
-
*/
|
|
56827
|
-
execute: (params, opts, overrides) => {
|
|
56828
|
-
return this.sdk.adapter.execute(
|
|
56829
|
-
{
|
|
56830
|
-
chainId: this.chainId,
|
|
56831
|
-
poolAddress: this.poolAddress,
|
|
56832
|
-
adapterAddress: params.adapterAddress,
|
|
56833
|
-
inputs: params.inputs,
|
|
56834
|
-
calls: params.calls,
|
|
56835
|
-
reshields: params.reshields,
|
|
56836
|
-
deadline: params.deadline
|
|
56837
|
-
},
|
|
56838
|
-
opts,
|
|
56839
|
-
overrides
|
|
56840
|
-
);
|
|
56841
|
-
}
|
|
56842
|
-
};
|
|
57030
|
+
adapter;
|
|
56843
57031
|
// ===== Advanced =====
|
|
56844
57032
|
/**
|
|
56845
57033
|
* Advanced escape hatch for raw JoinSplit transaction building.
|
|
@@ -57317,54 +57505,60 @@ function UnlinkProvider({
|
|
|
57317
57505
|
throw err;
|
|
57318
57506
|
}
|
|
57319
57507
|
}, []);
|
|
57320
|
-
const send = useCallback(
|
|
57321
|
-
|
|
57322
|
-
|
|
57323
|
-
|
|
57324
|
-
|
|
57325
|
-
|
|
57326
|
-
|
|
57327
|
-
...prev2,
|
|
57328
|
-
busy: true,
|
|
57329
|
-
status: params.length > 1 ? `Sending (${params.length} transfers)...` : "Sending..."
|
|
57330
|
-
}));
|
|
57331
|
-
try {
|
|
57332
|
-
const result = await wallet.transfer({
|
|
57333
|
-
transfers: params.map((t) => ({
|
|
57334
|
-
token: t.token,
|
|
57335
|
-
recipient: t.recipient,
|
|
57336
|
-
amount: t.amount
|
|
57337
|
-
}))
|
|
57338
|
-
});
|
|
57339
|
-
setState((prev2) => ({
|
|
57340
|
-
...prev2,
|
|
57341
|
-
busy: false,
|
|
57342
|
-
status: params.length > 1 ? `Transfer submitted (${params.length} transfers)` : "Transfer submitted",
|
|
57343
|
-
pendingTransfers: [
|
|
57344
|
-
...prev2.pendingTransfers,
|
|
57345
|
-
...params.map((t, i) => ({
|
|
57346
|
-
txId: `${result.relayId}-${i}`,
|
|
57347
|
-
status: "pending",
|
|
57348
|
-
chainId: wallet.chainId,
|
|
57349
|
-
token: t.token,
|
|
57350
|
-
amount: t.amount,
|
|
57351
|
-
recipient: t.recipient,
|
|
57352
|
-
startedAt: Date.now()
|
|
57353
|
-
}))
|
|
57354
|
-
],
|
|
57355
|
-
error: null
|
|
57356
|
-
}));
|
|
57357
|
-
return result;
|
|
57358
|
-
} catch (err) {
|
|
57508
|
+
const send = useCallback(
|
|
57509
|
+
async (params, overrides) => {
|
|
57510
|
+
const wallet = walletRef.current;
|
|
57511
|
+
if (!wallet) throw new Error("SDK not initialized");
|
|
57512
|
+
if (params.length === 0) {
|
|
57513
|
+
throw new Error("At least one transfer is required");
|
|
57514
|
+
}
|
|
57359
57515
|
setState((prev2) => ({
|
|
57360
57516
|
...prev2,
|
|
57361
|
-
busy:
|
|
57362
|
-
status:
|
|
57363
|
-
error: createUnlinkError(err, "send")
|
|
57517
|
+
busy: true,
|
|
57518
|
+
status: params.length > 1 ? `Sending (${params.length} transfers)...` : "Sending..."
|
|
57364
57519
|
}));
|
|
57365
|
-
|
|
57366
|
-
|
|
57367
|
-
|
|
57520
|
+
try {
|
|
57521
|
+
const result = await wallet.transfer(
|
|
57522
|
+
{
|
|
57523
|
+
transfers: params.map((t) => ({
|
|
57524
|
+
token: t.token,
|
|
57525
|
+
recipient: t.recipient,
|
|
57526
|
+
amount: t.amount
|
|
57527
|
+
}))
|
|
57528
|
+
},
|
|
57529
|
+
overrides
|
|
57530
|
+
);
|
|
57531
|
+
setState((prev2) => ({
|
|
57532
|
+
...prev2,
|
|
57533
|
+
busy: false,
|
|
57534
|
+
status: params.length > 1 ? `Transfer submitted (${params.length} transfers)` : "Transfer submitted",
|
|
57535
|
+
pendingTransfers: [
|
|
57536
|
+
...prev2.pendingTransfers,
|
|
57537
|
+
...params.map((t, i) => ({
|
|
57538
|
+
txId: `${result.relayId}-${i}`,
|
|
57539
|
+
status: "pending",
|
|
57540
|
+
chainId: wallet.chainId,
|
|
57541
|
+
token: t.token,
|
|
57542
|
+
amount: t.amount,
|
|
57543
|
+
recipient: t.recipient,
|
|
57544
|
+
startedAt: Date.now()
|
|
57545
|
+
}))
|
|
57546
|
+
],
|
|
57547
|
+
error: null
|
|
57548
|
+
}));
|
|
57549
|
+
return result;
|
|
57550
|
+
} catch (err) {
|
|
57551
|
+
setState((prev2) => ({
|
|
57552
|
+
...prev2,
|
|
57553
|
+
busy: false,
|
|
57554
|
+
status: `Error: ${err instanceof Error ? err.message : "Unknown"}`,
|
|
57555
|
+
error: createUnlinkError(err, "send")
|
|
57556
|
+
}));
|
|
57557
|
+
throw err;
|
|
57558
|
+
}
|
|
57559
|
+
},
|
|
57560
|
+
[]
|
|
57561
|
+
);
|
|
57368
57562
|
const planTransfer = useCallback(async (params) => {
|
|
57369
57563
|
const wallet = walletRef.current;
|
|
57370
57564
|
if (!wallet) throw new Error("SDK not initialized");
|
|
@@ -57376,33 +57570,36 @@ function UnlinkProvider({
|
|
|
57376
57570
|
}))
|
|
57377
57571
|
});
|
|
57378
57572
|
}, []);
|
|
57379
|
-
const executeTransfer = useCallback(
|
|
57380
|
-
|
|
57381
|
-
|
|
57382
|
-
|
|
57383
|
-
...prev2,
|
|
57384
|
-
busy: true,
|
|
57385
|
-
status: "Executing transfer..."
|
|
57386
|
-
}));
|
|
57387
|
-
try {
|
|
57388
|
-
const result = await wallet.executeTransfer(plans);
|
|
57389
|
-
setState((prev2) => ({
|
|
57390
|
-
...prev2,
|
|
57391
|
-
busy: false,
|
|
57392
|
-
status: "Transfer executed",
|
|
57393
|
-
error: null
|
|
57394
|
-
}));
|
|
57395
|
-
return result;
|
|
57396
|
-
} catch (err) {
|
|
57573
|
+
const executeTransfer = useCallback(
|
|
57574
|
+
async (plans, overrides) => {
|
|
57575
|
+
const wallet = walletRef.current;
|
|
57576
|
+
if (!wallet) throw new Error("SDK not initialized");
|
|
57397
57577
|
setState((prev2) => ({
|
|
57398
57578
|
...prev2,
|
|
57399
|
-
busy:
|
|
57400
|
-
status:
|
|
57401
|
-
error: createUnlinkError(err, "executeTransfer")
|
|
57579
|
+
busy: true,
|
|
57580
|
+
status: "Executing transfer..."
|
|
57402
57581
|
}));
|
|
57403
|
-
|
|
57404
|
-
|
|
57405
|
-
|
|
57582
|
+
try {
|
|
57583
|
+
const result = await wallet.executeTransfer(plans, overrides);
|
|
57584
|
+
setState((prev2) => ({
|
|
57585
|
+
...prev2,
|
|
57586
|
+
busy: false,
|
|
57587
|
+
status: "Transfer executed",
|
|
57588
|
+
error: null
|
|
57589
|
+
}));
|
|
57590
|
+
return result;
|
|
57591
|
+
} catch (err) {
|
|
57592
|
+
setState((prev2) => ({
|
|
57593
|
+
...prev2,
|
|
57594
|
+
busy: false,
|
|
57595
|
+
status: `Error: ${err instanceof Error ? err.message : "Unknown"}`,
|
|
57596
|
+
error: createUnlinkError(err, "executeTransfer")
|
|
57597
|
+
}));
|
|
57598
|
+
throw err;
|
|
57599
|
+
}
|
|
57600
|
+
},
|
|
57601
|
+
[]
|
|
57602
|
+
);
|
|
57406
57603
|
const requestDeposit = useCallback(
|
|
57407
57604
|
async (params) => {
|
|
57408
57605
|
const wallet = walletRef.current;
|
|
@@ -57459,7 +57656,7 @@ function UnlinkProvider({
|
|
|
57459
57656
|
[]
|
|
57460
57657
|
);
|
|
57461
57658
|
const requestWithdraw = useCallback(
|
|
57462
|
-
async (params) => {
|
|
57659
|
+
async (params, overrides) => {
|
|
57463
57660
|
const wallet = walletRef.current;
|
|
57464
57661
|
if (!wallet) throw new Error("SDK not initialized");
|
|
57465
57662
|
if (params.length === 0) {
|
|
@@ -57471,13 +57668,16 @@ function UnlinkProvider({
|
|
|
57471
57668
|
status: params.length > 1 ? `Processing withdrawal (${params.length} tokens)...` : "Withdrawing..."
|
|
57472
57669
|
}));
|
|
57473
57670
|
try {
|
|
57474
|
-
const result = await wallet.withdraw(
|
|
57475
|
-
|
|
57476
|
-
|
|
57477
|
-
|
|
57478
|
-
|
|
57479
|
-
|
|
57480
|
-
|
|
57671
|
+
const result = await wallet.withdraw(
|
|
57672
|
+
{
|
|
57673
|
+
withdrawals: params.map((w) => ({
|
|
57674
|
+
token: w.token,
|
|
57675
|
+
amount: w.amount,
|
|
57676
|
+
recipient: w.recipient
|
|
57677
|
+
}))
|
|
57678
|
+
},
|
|
57679
|
+
overrides
|
|
57680
|
+
);
|
|
57481
57681
|
setState((prev2) => ({
|
|
57482
57682
|
...prev2,
|
|
57483
57683
|
busy: false,
|
|
@@ -57553,33 +57753,36 @@ function UnlinkProvider({
|
|
|
57553
57753
|
},
|
|
57554
57754
|
[]
|
|
57555
57755
|
);
|
|
57556
|
-
const executeWithdraw = useCallback(
|
|
57557
|
-
|
|
57558
|
-
|
|
57559
|
-
|
|
57560
|
-
...prev2,
|
|
57561
|
-
busy: true,
|
|
57562
|
-
status: plans.length > 1 ? `Executing withdrawal (${plans.length} tokens)...` : "Executing withdrawal..."
|
|
57563
|
-
}));
|
|
57564
|
-
try {
|
|
57565
|
-
const result = await wallet.executeWithdraw(plans);
|
|
57566
|
-
setState((prev2) => ({
|
|
57567
|
-
...prev2,
|
|
57568
|
-
busy: false,
|
|
57569
|
-
status: plans.length > 1 ? `Withdrawal executed (${plans.length} tokens)` : "Withdrawal executed",
|
|
57570
|
-
error: null
|
|
57571
|
-
}));
|
|
57572
|
-
return result;
|
|
57573
|
-
} catch (err) {
|
|
57756
|
+
const executeWithdraw = useCallback(
|
|
57757
|
+
async (plans, overrides) => {
|
|
57758
|
+
const wallet = walletRef.current;
|
|
57759
|
+
if (!wallet) throw new Error("SDK not initialized");
|
|
57574
57760
|
setState((prev2) => ({
|
|
57575
57761
|
...prev2,
|
|
57576
|
-
busy:
|
|
57577
|
-
status:
|
|
57578
|
-
error: createUnlinkError(err, "executeWithdraw")
|
|
57762
|
+
busy: true,
|
|
57763
|
+
status: plans.length > 1 ? `Executing withdrawal (${plans.length} tokens)...` : "Executing withdrawal..."
|
|
57579
57764
|
}));
|
|
57580
|
-
|
|
57581
|
-
|
|
57582
|
-
|
|
57765
|
+
try {
|
|
57766
|
+
const result = await wallet.executeWithdraw(plans, overrides);
|
|
57767
|
+
setState((prev2) => ({
|
|
57768
|
+
...prev2,
|
|
57769
|
+
busy: false,
|
|
57770
|
+
status: plans.length > 1 ? `Withdrawal executed (${plans.length} tokens)` : "Withdrawal executed",
|
|
57771
|
+
error: null
|
|
57772
|
+
}));
|
|
57773
|
+
return result;
|
|
57774
|
+
} catch (err) {
|
|
57775
|
+
setState((prev2) => ({
|
|
57776
|
+
...prev2,
|
|
57777
|
+
busy: false,
|
|
57778
|
+
status: `Error: ${err instanceof Error ? err.message : "Unknown"}`,
|
|
57779
|
+
error: createUnlinkError(err, "executeWithdraw")
|
|
57780
|
+
}));
|
|
57781
|
+
throw err;
|
|
57782
|
+
}
|
|
57783
|
+
},
|
|
57784
|
+
[]
|
|
57785
|
+
);
|
|
57583
57786
|
const createBurner = useCallback(async (index) => {
|
|
57584
57787
|
const wallet = walletRef.current;
|
|
57585
57788
|
if (!wallet) throw new Error("SDK not initialized");
|
|
@@ -58059,7 +58262,7 @@ function useOperationMutation(operation) {
|
|
|
58059
58262
|
const [isError2, setIsError] = useState4(false);
|
|
58060
58263
|
const pendingRef = useRef3(false);
|
|
58061
58264
|
const generationRef = useRef3(0);
|
|
58062
|
-
const
|
|
58265
|
+
const execute = useCallback4(
|
|
58063
58266
|
async (input) => {
|
|
58064
58267
|
if (pendingRef.current) {
|
|
58065
58268
|
throw new Error("Operation already in progress");
|
|
@@ -58102,7 +58305,7 @@ function useOperationMutation(operation) {
|
|
|
58102
58305
|
setIsSuccess(false);
|
|
58103
58306
|
setIsError(false);
|
|
58104
58307
|
}, []);
|
|
58105
|
-
return {
|
|
58308
|
+
return { execute, data, isPending, isSuccess, isError: isError2, error, reset };
|
|
58106
58309
|
}
|
|
58107
58310
|
|
|
58108
58311
|
// src/useDeposit.ts
|
|
@@ -58117,19 +58320,22 @@ function useDeposit() {
|
|
|
58117
58320
|
|
|
58118
58321
|
// src/useTransfer.ts
|
|
58119
58322
|
import { useCallback as useCallback6 } from "react";
|
|
58120
|
-
function useTransfer() {
|
|
58323
|
+
function useTransfer(overrides) {
|
|
58121
58324
|
const { send } = useUnlink();
|
|
58122
|
-
const op = useCallback6(
|
|
58325
|
+
const op = useCallback6(
|
|
58326
|
+
(params) => send(params, overrides),
|
|
58327
|
+
[send, overrides]
|
|
58328
|
+
);
|
|
58123
58329
|
return useOperationMutation(op);
|
|
58124
58330
|
}
|
|
58125
58331
|
|
|
58126
58332
|
// src/useWithdraw.ts
|
|
58127
58333
|
import { useCallback as useCallback7 } from "react";
|
|
58128
|
-
function useWithdraw() {
|
|
58334
|
+
function useWithdraw(overrides) {
|
|
58129
58335
|
const { requestWithdraw } = useUnlink();
|
|
58130
58336
|
const op = useCallback7(
|
|
58131
|
-
(params) => requestWithdraw(params),
|
|
58132
|
-
[requestWithdraw]
|
|
58337
|
+
(params) => requestWithdraw(params, overrides),
|
|
58338
|
+
[requestWithdraw, overrides]
|
|
58133
58339
|
);
|
|
58134
58340
|
return useOperationMutation(op);
|
|
58135
58341
|
}
|
|
@@ -58191,7 +58397,10 @@ export {
|
|
|
58191
58397
|
TimeoutError2 as TimeoutError,
|
|
58192
58398
|
TransactionFailedError,
|
|
58193
58399
|
UnlinkProvider,
|
|
58400
|
+
approve,
|
|
58401
|
+
buildApproveCall,
|
|
58194
58402
|
computeBalances,
|
|
58403
|
+
contract,
|
|
58195
58404
|
decodeAddress,
|
|
58196
58405
|
encodeAddress,
|
|
58197
58406
|
formatAmount,
|
|
@@ -58200,6 +58409,7 @@ export {
|
|
|
58200
58409
|
parseZkAddress,
|
|
58201
58410
|
randomHex,
|
|
58202
58411
|
shortenHex,
|
|
58412
|
+
toCall,
|
|
58203
58413
|
useAdapter,
|
|
58204
58414
|
useBurner,
|
|
58205
58415
|
useDeposit,
|