@unlink-xyz/core 0.1.3-canary.01ac52d → 0.1.3-canary.05ae89f
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/browser/index.js +402 -173
- package/dist/browser/index.js.map +1 -1
- package/dist/browser/wallet/index.js +354 -172
- package/dist/browser/wallet/index.js.map +1 -1
- package/dist/clients/http.d.ts.map +1 -1
- package/dist/config.d.ts +7 -0
- package/dist/config.d.ts.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +325 -96
- package/dist/index.js.map +1 -1
- package/dist/transactions/adapter.d.ts +34 -1
- package/dist/transactions/adapter.d.ts.map +1 -1
- package/dist/transactions/index.d.ts +1 -1
- package/dist/transactions/index.d.ts.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/utils/async.js.map +1 -1
- package/dist/wallet/adapter.d.ts +2 -2
- package/dist/wallet/adapter.d.ts.map +1 -1
- package/dist/wallet/burner/service.d.ts +1 -0
- package/dist/wallet/burner/service.d.ts.map +1 -1
- package/dist/wallet/burner/types.d.ts +2 -2
- package/dist/wallet/burner/types.d.ts.map +1 -1
- package/dist/wallet/index.d.ts +2 -2
- package/dist/wallet/index.d.ts.map +1 -1
- package/dist/wallet/index.js +277 -95
- package/dist/wallet/index.js.map +1 -1
- package/dist/wallet/sdk.d.ts +2 -2
- package/dist/wallet/types.d.ts +49 -38
- package/dist/wallet/types.d.ts.map +1 -1
- package/dist/wallet/{unlink-wallet.d.ts → unlink.d.ts} +38 -31
- package/dist/wallet/unlink.d.ts.map +1 -0
- package/package.json +1 -1
- package/dist/wallet/unlink-wallet.d.ts.map +0 -1
package/dist/browser/index.js
CHANGED
|
@@ -27209,8 +27209,8 @@ var ContractUnknownEventPayload = class extends EventPayload {
|
|
|
27209
27209
|
/**
|
|
27210
27210
|
* @_event:
|
|
27211
27211
|
*/
|
|
27212
|
-
constructor(
|
|
27213
|
-
super(
|
|
27212
|
+
constructor(contract2, listener, filter, log) {
|
|
27213
|
+
super(contract2, listener, filter);
|
|
27214
27214
|
defineProperties(this, { log });
|
|
27215
27215
|
}
|
|
27216
27216
|
/**
|
|
@@ -27236,9 +27236,9 @@ var ContractEventPayload = class extends ContractUnknownEventPayload {
|
|
|
27236
27236
|
/**
|
|
27237
27237
|
* @_ignore:
|
|
27238
27238
|
*/
|
|
27239
|
-
constructor(
|
|
27240
|
-
super(
|
|
27241
|
-
const args =
|
|
27239
|
+
constructor(contract2, listener, filter, fragment, _log) {
|
|
27240
|
+
super(contract2, listener, filter, new EventLog(_log, contract2.interface, fragment));
|
|
27241
|
+
const args = contract2.interface.decodeEventLog(fragment, this.log.data, this.log.topics);
|
|
27242
27242
|
defineProperties(this, { args, fragment });
|
|
27243
27243
|
}
|
|
27244
27244
|
/**
|
|
@@ -27283,12 +27283,12 @@ function getResolver(value) {
|
|
|
27283
27283
|
var PreparedTopicFilter = class {
|
|
27284
27284
|
#filter;
|
|
27285
27285
|
fragment;
|
|
27286
|
-
constructor(
|
|
27286
|
+
constructor(contract2, fragment, args) {
|
|
27287
27287
|
defineProperties(this, { fragment });
|
|
27288
27288
|
if (fragment.inputs.length < args.length) {
|
|
27289
27289
|
throw new Error("too many arguments");
|
|
27290
27290
|
}
|
|
27291
|
-
const runner = getRunner(
|
|
27291
|
+
const runner = getRunner(contract2.runner, "resolveName");
|
|
27292
27292
|
const resolver = canResolve(runner) ? runner : null;
|
|
27293
27293
|
this.#filter = (async function() {
|
|
27294
27294
|
const resolvedArgs = await Promise.all(fragment.inputs.map((param, index) => {
|
|
@@ -27306,7 +27306,7 @@ var PreparedTopicFilter = class {
|
|
|
27306
27306
|
return value;
|
|
27307
27307
|
});
|
|
27308
27308
|
}));
|
|
27309
|
-
return
|
|
27309
|
+
return contract2.interface.encodeFilterTopics(fragment, resolvedArgs);
|
|
27310
27310
|
})();
|
|
27311
27311
|
}
|
|
27312
27312
|
getTopicFilter() {
|
|
@@ -27355,14 +27355,14 @@ async function resolveArgs(_runner, inputs, args) {
|
|
|
27355
27355
|
});
|
|
27356
27356
|
}));
|
|
27357
27357
|
}
|
|
27358
|
-
function buildWrappedFallback(
|
|
27358
|
+
function buildWrappedFallback(contract2) {
|
|
27359
27359
|
const populateTransaction = async function(overrides) {
|
|
27360
27360
|
const tx = await copyOverrides(overrides, ["data"]);
|
|
27361
|
-
tx.to = await
|
|
27361
|
+
tx.to = await contract2.getAddress();
|
|
27362
27362
|
if (tx.from) {
|
|
27363
|
-
tx.from = await resolveAddress(tx.from, getResolver(
|
|
27363
|
+
tx.from = await resolveAddress(tx.from, getResolver(contract2.runner));
|
|
27364
27364
|
}
|
|
27365
|
-
const iface =
|
|
27365
|
+
const iface = contract2.interface;
|
|
27366
27366
|
const noValue = getBigInt(tx.value || BN_09, "overrides.value") === BN_09;
|
|
27367
27367
|
const noData = (tx.data || "0x") === "0x";
|
|
27368
27368
|
if (iface.fallback && !iface.fallback.payable && iface.receive && !noData && !noValue) {
|
|
@@ -27375,27 +27375,27 @@ function buildWrappedFallback(contract) {
|
|
|
27375
27375
|
return tx;
|
|
27376
27376
|
};
|
|
27377
27377
|
const staticCall = async function(overrides) {
|
|
27378
|
-
const runner = getRunner(
|
|
27378
|
+
const runner = getRunner(contract2.runner, "call");
|
|
27379
27379
|
assert(canCall(runner), "contract runner does not support calling", "UNSUPPORTED_OPERATION", { operation: "call" });
|
|
27380
27380
|
const tx = await populateTransaction(overrides);
|
|
27381
27381
|
try {
|
|
27382
27382
|
return await runner.call(tx);
|
|
27383
27383
|
} catch (error) {
|
|
27384
27384
|
if (isCallException(error) && error.data) {
|
|
27385
|
-
throw
|
|
27385
|
+
throw contract2.interface.makeError(error.data, tx);
|
|
27386
27386
|
}
|
|
27387
27387
|
throw error;
|
|
27388
27388
|
}
|
|
27389
27389
|
};
|
|
27390
27390
|
const send = async function(overrides) {
|
|
27391
|
-
const runner =
|
|
27391
|
+
const runner = contract2.runner;
|
|
27392
27392
|
assert(canSend(runner), "contract runner does not support sending transactions", "UNSUPPORTED_OPERATION", { operation: "sendTransaction" });
|
|
27393
27393
|
const tx = await runner.sendTransaction(await populateTransaction(overrides));
|
|
27394
|
-
const provider = getProvider(
|
|
27395
|
-
return new ContractTransactionResponse(
|
|
27394
|
+
const provider = getProvider(contract2.runner);
|
|
27395
|
+
return new ContractTransactionResponse(contract2.interface, provider, tx);
|
|
27396
27396
|
};
|
|
27397
27397
|
const estimateGas = async function(overrides) {
|
|
27398
|
-
const runner = getRunner(
|
|
27398
|
+
const runner = getRunner(contract2.runner, "estimateGas");
|
|
27399
27399
|
assert(canEstimate(runner), "contract runner does not support gas estimation", "UNSUPPORTED_OPERATION", { operation: "estimateGas" });
|
|
27400
27400
|
return await runner.estimateGas(await populateTransaction(overrides));
|
|
27401
27401
|
};
|
|
@@ -27403,7 +27403,7 @@ function buildWrappedFallback(contract) {
|
|
|
27403
27403
|
return await send(overrides);
|
|
27404
27404
|
};
|
|
27405
27405
|
defineProperties(method, {
|
|
27406
|
-
_contract:
|
|
27406
|
+
_contract: contract2,
|
|
27407
27407
|
estimateGas,
|
|
27408
27408
|
populateTransaction,
|
|
27409
27409
|
send,
|
|
@@ -27411,9 +27411,9 @@ function buildWrappedFallback(contract) {
|
|
|
27411
27411
|
});
|
|
27412
27412
|
return method;
|
|
27413
27413
|
}
|
|
27414
|
-
function buildWrappedMethod(
|
|
27414
|
+
function buildWrappedMethod(contract2, key) {
|
|
27415
27415
|
const getFragment = function(...args) {
|
|
27416
|
-
const fragment =
|
|
27416
|
+
const fragment = contract2.interface.getFunction(key, args);
|
|
27417
27417
|
assert(fragment, "no matching fragment", "UNSUPPORTED_OPERATION", {
|
|
27418
27418
|
operation: "fragment",
|
|
27419
27419
|
info: { key, args }
|
|
@@ -27426,16 +27426,16 @@ function buildWrappedMethod(contract, key) {
|
|
|
27426
27426
|
if (fragment.inputs.length + 1 === args.length) {
|
|
27427
27427
|
overrides = await copyOverrides(args.pop());
|
|
27428
27428
|
if (overrides.from) {
|
|
27429
|
-
overrides.from = await resolveAddress(overrides.from, getResolver(
|
|
27429
|
+
overrides.from = await resolveAddress(overrides.from, getResolver(contract2.runner));
|
|
27430
27430
|
}
|
|
27431
27431
|
}
|
|
27432
27432
|
if (fragment.inputs.length !== args.length) {
|
|
27433
27433
|
throw new Error("internal error: fragment inputs doesn't match arguments; should not happen");
|
|
27434
27434
|
}
|
|
27435
|
-
const resolvedArgs = await resolveArgs(
|
|
27435
|
+
const resolvedArgs = await resolveArgs(contract2.runner, fragment.inputs, args);
|
|
27436
27436
|
return Object.assign({}, overrides, await resolveProperties({
|
|
27437
|
-
to:
|
|
27438
|
-
data:
|
|
27437
|
+
to: contract2.getAddress(),
|
|
27438
|
+
data: contract2.interface.encodeFunctionData(fragment, resolvedArgs)
|
|
27439
27439
|
}));
|
|
27440
27440
|
};
|
|
27441
27441
|
const staticCall = async function(...args) {
|
|
@@ -27446,19 +27446,19 @@ function buildWrappedMethod(contract, key) {
|
|
|
27446
27446
|
return result;
|
|
27447
27447
|
};
|
|
27448
27448
|
const send = async function(...args) {
|
|
27449
|
-
const runner =
|
|
27449
|
+
const runner = contract2.runner;
|
|
27450
27450
|
assert(canSend(runner), "contract runner does not support sending transactions", "UNSUPPORTED_OPERATION", { operation: "sendTransaction" });
|
|
27451
27451
|
const tx = await runner.sendTransaction(await populateTransaction(...args));
|
|
27452
|
-
const provider = getProvider(
|
|
27453
|
-
return new ContractTransactionResponse(
|
|
27452
|
+
const provider = getProvider(contract2.runner);
|
|
27453
|
+
return new ContractTransactionResponse(contract2.interface, provider, tx);
|
|
27454
27454
|
};
|
|
27455
27455
|
const estimateGas = async function(...args) {
|
|
27456
|
-
const runner = getRunner(
|
|
27456
|
+
const runner = getRunner(contract2.runner, "estimateGas");
|
|
27457
27457
|
assert(canEstimate(runner), "contract runner does not support gas estimation", "UNSUPPORTED_OPERATION", { operation: "estimateGas" });
|
|
27458
27458
|
return await runner.estimateGas(await populateTransaction(...args));
|
|
27459
27459
|
};
|
|
27460
27460
|
const staticCallResult = async function(...args) {
|
|
27461
|
-
const runner = getRunner(
|
|
27461
|
+
const runner = getRunner(contract2.runner, "call");
|
|
27462
27462
|
assert(canCall(runner), "contract runner does not support calling", "UNSUPPORTED_OPERATION", { operation: "call" });
|
|
27463
27463
|
const tx = await populateTransaction(...args);
|
|
27464
27464
|
let result = "0x";
|
|
@@ -27466,12 +27466,12 @@ function buildWrappedMethod(contract, key) {
|
|
|
27466
27466
|
result = await runner.call(tx);
|
|
27467
27467
|
} catch (error) {
|
|
27468
27468
|
if (isCallException(error) && error.data) {
|
|
27469
|
-
throw
|
|
27469
|
+
throw contract2.interface.makeError(error.data, tx);
|
|
27470
27470
|
}
|
|
27471
27471
|
throw error;
|
|
27472
27472
|
}
|
|
27473
27473
|
const fragment = getFragment(...args);
|
|
27474
|
-
return
|
|
27474
|
+
return contract2.interface.decodeFunctionResult(fragment, result);
|
|
27475
27475
|
};
|
|
27476
27476
|
const method = async (...args) => {
|
|
27477
27477
|
const fragment = getFragment(...args);
|
|
@@ -27481,8 +27481,8 @@ function buildWrappedMethod(contract, key) {
|
|
|
27481
27481
|
return await send(...args);
|
|
27482
27482
|
};
|
|
27483
27483
|
defineProperties(method, {
|
|
27484
|
-
name:
|
|
27485
|
-
_contract:
|
|
27484
|
+
name: contract2.interface.getFunctionName(key),
|
|
27485
|
+
_contract: contract2,
|
|
27486
27486
|
_key: key,
|
|
27487
27487
|
getFragment,
|
|
27488
27488
|
estimateGas,
|
|
@@ -27495,7 +27495,7 @@ function buildWrappedMethod(contract, key) {
|
|
|
27495
27495
|
configurable: false,
|
|
27496
27496
|
enumerable: true,
|
|
27497
27497
|
get: () => {
|
|
27498
|
-
const fragment =
|
|
27498
|
+
const fragment = contract2.interface.getFunction(key);
|
|
27499
27499
|
assert(fragment, "no matching fragment", "UNSUPPORTED_OPERATION", {
|
|
27500
27500
|
operation: "fragment",
|
|
27501
27501
|
info: { key }
|
|
@@ -27505,9 +27505,9 @@ function buildWrappedMethod(contract, key) {
|
|
|
27505
27505
|
});
|
|
27506
27506
|
return method;
|
|
27507
27507
|
}
|
|
27508
|
-
function buildWrappedEvent(
|
|
27508
|
+
function buildWrappedEvent(contract2, key) {
|
|
27509
27509
|
const getFragment = function(...args) {
|
|
27510
|
-
const fragment =
|
|
27510
|
+
const fragment = contract2.interface.getEvent(key, args);
|
|
27511
27511
|
assert(fragment, "no matching fragment", "UNSUPPORTED_OPERATION", {
|
|
27512
27512
|
operation: "fragment",
|
|
27513
27513
|
info: { key, args }
|
|
@@ -27515,11 +27515,11 @@ function buildWrappedEvent(contract, key) {
|
|
|
27515
27515
|
return fragment;
|
|
27516
27516
|
};
|
|
27517
27517
|
const method = function(...args) {
|
|
27518
|
-
return new PreparedTopicFilter(
|
|
27518
|
+
return new PreparedTopicFilter(contract2, getFragment(...args), args);
|
|
27519
27519
|
};
|
|
27520
27520
|
defineProperties(method, {
|
|
27521
|
-
name:
|
|
27522
|
-
_contract:
|
|
27521
|
+
name: contract2.interface.getEventName(key),
|
|
27522
|
+
_contract: contract2,
|
|
27523
27523
|
_key: key,
|
|
27524
27524
|
getFragment
|
|
27525
27525
|
});
|
|
@@ -27527,7 +27527,7 @@ function buildWrappedEvent(contract, key) {
|
|
|
27527
27527
|
configurable: false,
|
|
27528
27528
|
enumerable: true,
|
|
27529
27529
|
get: () => {
|
|
27530
|
-
const fragment =
|
|
27530
|
+
const fragment = contract2.interface.getEvent(key);
|
|
27531
27531
|
assert(fragment, "no matching fragment", "UNSUPPORTED_OPERATION", {
|
|
27532
27532
|
operation: "fragment",
|
|
27533
27533
|
info: { key }
|
|
@@ -27539,16 +27539,16 @@ function buildWrappedEvent(contract, key) {
|
|
|
27539
27539
|
}
|
|
27540
27540
|
var internal2 = /* @__PURE__ */ Symbol.for("_ethersInternal_contract");
|
|
27541
27541
|
var internalValues = /* @__PURE__ */ new WeakMap();
|
|
27542
|
-
function setInternal(
|
|
27543
|
-
internalValues.set(
|
|
27542
|
+
function setInternal(contract2, values) {
|
|
27543
|
+
internalValues.set(contract2[internal2], values);
|
|
27544
27544
|
}
|
|
27545
|
-
function getInternal(
|
|
27546
|
-
return internalValues.get(
|
|
27545
|
+
function getInternal(contract2) {
|
|
27546
|
+
return internalValues.get(contract2[internal2]);
|
|
27547
27547
|
}
|
|
27548
27548
|
function isDeferred(value) {
|
|
27549
27549
|
return value && typeof value === "object" && "getTopicFilter" in value && typeof value.getTopicFilter === "function" && value.fragment;
|
|
27550
27550
|
}
|
|
27551
|
-
async function getSubInfo(
|
|
27551
|
+
async function getSubInfo(contract2, event) {
|
|
27552
27552
|
let topics;
|
|
27553
27553
|
let fragment = null;
|
|
27554
27554
|
if (Array.isArray(event)) {
|
|
@@ -27556,7 +27556,7 @@ async function getSubInfo(contract, event) {
|
|
|
27556
27556
|
if (isHexString(name, 32)) {
|
|
27557
27557
|
return name;
|
|
27558
27558
|
}
|
|
27559
|
-
const fragment2 =
|
|
27559
|
+
const fragment2 = contract2.interface.getEvent(name);
|
|
27560
27560
|
assertArgument(fragment2, "unknown fragment", "name", name);
|
|
27561
27561
|
return fragment2.topicHash;
|
|
27562
27562
|
};
|
|
@@ -27575,7 +27575,7 @@ async function getSubInfo(contract, event) {
|
|
|
27575
27575
|
if (isHexString(event, 32)) {
|
|
27576
27576
|
topics = [event];
|
|
27577
27577
|
} else {
|
|
27578
|
-
fragment =
|
|
27578
|
+
fragment = contract2.interface.getEvent(event);
|
|
27579
27579
|
assertArgument(fragment, "unknown fragment", "event", event);
|
|
27580
27580
|
topics = [fragment.topicHash];
|
|
27581
27581
|
}
|
|
@@ -27612,36 +27612,36 @@ async function getSubInfo(contract, event) {
|
|
|
27612
27612
|
}).join("&");
|
|
27613
27613
|
return { fragment, tag, topics };
|
|
27614
27614
|
}
|
|
27615
|
-
async function hasSub(
|
|
27616
|
-
const { subs } = getInternal(
|
|
27617
|
-
return subs.get((await getSubInfo(
|
|
27615
|
+
async function hasSub(contract2, event) {
|
|
27616
|
+
const { subs } = getInternal(contract2);
|
|
27617
|
+
return subs.get((await getSubInfo(contract2, event)).tag) || null;
|
|
27618
27618
|
}
|
|
27619
|
-
async function getSub(
|
|
27620
|
-
const provider = getProvider(
|
|
27619
|
+
async function getSub(contract2, operation, event) {
|
|
27620
|
+
const provider = getProvider(contract2.runner);
|
|
27621
27621
|
assert(provider, "contract runner does not support subscribing", "UNSUPPORTED_OPERATION", { operation });
|
|
27622
|
-
const { fragment, tag, topics } = await getSubInfo(
|
|
27623
|
-
const { addr, subs } = getInternal(
|
|
27622
|
+
const { fragment, tag, topics } = await getSubInfo(contract2, event);
|
|
27623
|
+
const { addr, subs } = getInternal(contract2);
|
|
27624
27624
|
let sub2 = subs.get(tag);
|
|
27625
27625
|
if (!sub2) {
|
|
27626
|
-
const address = addr ? addr :
|
|
27626
|
+
const address = addr ? addr : contract2;
|
|
27627
27627
|
const filter = { address, topics };
|
|
27628
27628
|
const listener = (log) => {
|
|
27629
27629
|
let foundFragment = fragment;
|
|
27630
27630
|
if (foundFragment == null) {
|
|
27631
27631
|
try {
|
|
27632
|
-
foundFragment =
|
|
27632
|
+
foundFragment = contract2.interface.getEvent(log.topics[0]);
|
|
27633
27633
|
} catch (error) {
|
|
27634
27634
|
}
|
|
27635
27635
|
}
|
|
27636
27636
|
if (foundFragment) {
|
|
27637
27637
|
const _foundFragment = foundFragment;
|
|
27638
|
-
const args = fragment ?
|
|
27639
|
-
emit2(
|
|
27640
|
-
return new ContractEventPayload(
|
|
27638
|
+
const args = fragment ? contract2.interface.decodeEventLog(fragment, log.data, log.topics) : [];
|
|
27639
|
+
emit2(contract2, event, args, (listener2) => {
|
|
27640
|
+
return new ContractEventPayload(contract2, listener2, event, _foundFragment, log);
|
|
27641
27641
|
});
|
|
27642
27642
|
} else {
|
|
27643
|
-
emit2(
|
|
27644
|
-
return new ContractUnknownEventPayload(
|
|
27643
|
+
emit2(contract2, event, [], (listener2) => {
|
|
27644
|
+
return new ContractUnknownEventPayload(contract2, listener2, event, log);
|
|
27645
27645
|
});
|
|
27646
27646
|
}
|
|
27647
27647
|
};
|
|
@@ -27667,9 +27667,9 @@ async function getSub(contract, operation, event) {
|
|
|
27667
27667
|
return sub2;
|
|
27668
27668
|
}
|
|
27669
27669
|
var lastEmit = Promise.resolve();
|
|
27670
|
-
async function _emit(
|
|
27670
|
+
async function _emit(contract2, event, args, payloadFunc) {
|
|
27671
27671
|
await lastEmit;
|
|
27672
|
-
const sub2 = await hasSub(
|
|
27672
|
+
const sub2 = await hasSub(contract2, event);
|
|
27673
27673
|
if (!sub2) {
|
|
27674
27674
|
return false;
|
|
27675
27675
|
}
|
|
@@ -27680,23 +27680,23 @@ async function _emit(contract, event, args, payloadFunc) {
|
|
|
27680
27680
|
passArgs.push(payloadFunc(once2 ? null : listener));
|
|
27681
27681
|
}
|
|
27682
27682
|
try {
|
|
27683
|
-
listener.call(
|
|
27683
|
+
listener.call(contract2, ...passArgs);
|
|
27684
27684
|
} catch (error) {
|
|
27685
27685
|
}
|
|
27686
27686
|
return !once2;
|
|
27687
27687
|
});
|
|
27688
27688
|
if (sub2.listeners.length === 0) {
|
|
27689
27689
|
sub2.stop();
|
|
27690
|
-
getInternal(
|
|
27690
|
+
getInternal(contract2).subs.delete(sub2.tag);
|
|
27691
27691
|
}
|
|
27692
27692
|
return count > 0;
|
|
27693
27693
|
}
|
|
27694
|
-
async function emit2(
|
|
27694
|
+
async function emit2(contract2, event, args, payloadFunc) {
|
|
27695
27695
|
try {
|
|
27696
27696
|
await lastEmit;
|
|
27697
27697
|
} catch (error) {
|
|
27698
27698
|
}
|
|
27699
|
-
const resultPromise = _emit(
|
|
27699
|
+
const resultPromise = _emit(contract2, event, args, payloadFunc);
|
|
27700
27700
|
lastEmit = resultPromise;
|
|
27701
27701
|
return await resultPromise;
|
|
27702
27702
|
}
|
|
@@ -28122,8 +28122,8 @@ var BaseContract = class _BaseContract {
|
|
|
28122
28122
|
if (runner == null) {
|
|
28123
28123
|
runner = null;
|
|
28124
28124
|
}
|
|
28125
|
-
const
|
|
28126
|
-
return
|
|
28125
|
+
const contract2 = new this(target, abi, runner);
|
|
28126
|
+
return contract2;
|
|
28127
28127
|
}
|
|
28128
28128
|
};
|
|
28129
28129
|
function _ContractBase() {
|
|
@@ -28424,7 +28424,7 @@ var EnsResolver = class _EnsResolver {
|
|
|
28424
28424
|
return { url: null, linkage };
|
|
28425
28425
|
}
|
|
28426
28426
|
const tokenId = comps[1];
|
|
28427
|
-
const
|
|
28427
|
+
const contract2 = new Contract(comps[0], [
|
|
28428
28428
|
// ERC-721
|
|
28429
28429
|
"function tokenURI(uint) view returns (string)",
|
|
28430
28430
|
"function ownerOf(uint) view returns (address)",
|
|
@@ -28433,21 +28433,21 @@ var EnsResolver = class _EnsResolver {
|
|
|
28433
28433
|
"function balanceOf(address, uint256) view returns (uint)"
|
|
28434
28434
|
], this.provider);
|
|
28435
28435
|
if (scheme === "erc721") {
|
|
28436
|
-
const tokenOwner = await
|
|
28436
|
+
const tokenOwner = await contract2.ownerOf(tokenId);
|
|
28437
28437
|
if (owner !== tokenOwner) {
|
|
28438
28438
|
linkage.push({ type: "!owner", value: tokenOwner });
|
|
28439
28439
|
return { url: null, linkage };
|
|
28440
28440
|
}
|
|
28441
28441
|
linkage.push({ type: "owner", value: tokenOwner });
|
|
28442
28442
|
} else if (scheme === "erc1155") {
|
|
28443
|
-
const balance = await
|
|
28443
|
+
const balance = await contract2.balanceOf(owner, tokenId);
|
|
28444
28444
|
if (!balance) {
|
|
28445
28445
|
linkage.push({ type: "!balance", value: "0" });
|
|
28446
28446
|
return { url: null, linkage };
|
|
28447
28447
|
}
|
|
28448
28448
|
linkage.push({ type: "balance", value: balance.toString() });
|
|
28449
28449
|
}
|
|
28450
|
-
let metadataUrl = await
|
|
28450
|
+
let metadataUrl = await contract2[selector](tokenId);
|
|
28451
28451
|
if (metadataUrl == null || metadataUrl === "0x") {
|
|
28452
28452
|
linkage.push({ type: "!metadata-url", value: "" });
|
|
28453
28453
|
return { url: null, linkage };
|
|
@@ -28519,10 +28519,10 @@ var EnsResolver = class _EnsResolver {
|
|
|
28519
28519
|
static async #getResolver(provider, name) {
|
|
28520
28520
|
const ensAddr = await _EnsResolver.getEnsAddress(provider);
|
|
28521
28521
|
try {
|
|
28522
|
-
const
|
|
28522
|
+
const contract2 = new Contract(ensAddr, [
|
|
28523
28523
|
"function resolver(bytes32) view returns (address)"
|
|
28524
28524
|
], provider);
|
|
28525
|
-
const addr = await
|
|
28525
|
+
const addr = await contract2.resolver(namehash(name), {
|
|
28526
28526
|
enableCcipRead: true
|
|
28527
28527
|
});
|
|
28528
28528
|
if (addr === ZeroAddress) {
|
|
@@ -34626,29 +34626,41 @@ function createJsonHttpClient(baseUrl, deps) {
|
|
|
34626
34626
|
fetch: fetchImpl,
|
|
34627
34627
|
// Disable ky's automatic error throwing to prevent browser DevTools
|
|
34628
34628
|
// from logging expected 404s as network errors
|
|
34629
|
-
throwHttpErrors: false
|
|
34629
|
+
throwHttpErrors: false,
|
|
34630
|
+
retry: 0
|
|
34630
34631
|
});
|
|
34632
|
+
const RETRYABLE_STATUSES = [502, 503, 504];
|
|
34633
|
+
const MAX_RETRIES = 3;
|
|
34634
|
+
const BASE_DELAY_MS = 500;
|
|
34631
34635
|
return {
|
|
34632
34636
|
async request(opts) {
|
|
34633
34637
|
let res;
|
|
34634
|
-
|
|
34635
|
-
|
|
34636
|
-
|
|
34637
|
-
|
|
34638
|
-
|
|
34639
|
-
|
|
34640
|
-
|
|
34641
|
-
|
|
34642
|
-
|
|
34643
|
-
|
|
34644
|
-
|
|
34645
|
-
|
|
34638
|
+
for (let attempt = 0; attempt <= MAX_RETRIES; attempt++) {
|
|
34639
|
+
try {
|
|
34640
|
+
res = await api(opts.path.replace(/^\//, ""), {
|
|
34641
|
+
method: opts.method,
|
|
34642
|
+
searchParams: opts.query,
|
|
34643
|
+
json: opts.json,
|
|
34644
|
+
body: opts.body,
|
|
34645
|
+
headers: opts.headers,
|
|
34646
|
+
signal: opts.signal
|
|
34647
|
+
});
|
|
34648
|
+
} catch (err) {
|
|
34649
|
+
if (err instanceof TimeoutError) {
|
|
34650
|
+
throw new HttpError("HTTP timeout", 408, null);
|
|
34651
|
+
}
|
|
34652
|
+
throw new HttpError(
|
|
34653
|
+
err instanceof Error ? err.message : "Network error",
|
|
34654
|
+
0,
|
|
34655
|
+
null
|
|
34656
|
+
);
|
|
34646
34657
|
}
|
|
34647
|
-
|
|
34648
|
-
|
|
34649
|
-
|
|
34650
|
-
|
|
34651
|
-
|
|
34658
|
+
if (RETRYABLE_STATUSES.includes(res.status) && attempt < MAX_RETRIES) {
|
|
34659
|
+
const delay2 = BASE_DELAY_MS * 2 ** attempt + Math.random() * 200;
|
|
34660
|
+
await new Promise((r2) => setTimeout(r2, delay2));
|
|
34661
|
+
continue;
|
|
34662
|
+
}
|
|
34663
|
+
break;
|
|
34652
34664
|
}
|
|
34653
34665
|
if (!res.ok) {
|
|
34654
34666
|
const body = await readErrorBodySafe(res);
|
|
@@ -34857,6 +34869,10 @@ var Runtime = {
|
|
|
34857
34869
|
};
|
|
34858
34870
|
|
|
34859
34871
|
// config.ts
|
|
34872
|
+
var DEFAULT_RPC_URLS = {
|
|
34873
|
+
"monad-testnet": "https://testnet-rpc.monad.xyz",
|
|
34874
|
+
"monad-testnet-staging": "https://testnet-rpc.monad.xyz"
|
|
34875
|
+
};
|
|
34860
34876
|
var CONFIG_URL = "https://config.unlink.xyz/networks.json";
|
|
34861
34877
|
function parseRequiredString(chain2, field, value) {
|
|
34862
34878
|
if (typeof value !== "string" || value.trim().length === 0) {
|
|
@@ -34906,17 +34922,48 @@ function parseChainConfig(chain2, value) {
|
|
|
34906
34922
|
"artifactVersion",
|
|
34907
34923
|
raw.artifactVersion
|
|
34908
34924
|
).replace(/^\/+|\/+$/g, "");
|
|
34925
|
+
const adapterAddress = parseOptionalString(
|
|
34926
|
+
chain2,
|
|
34927
|
+
"adapterAddress",
|
|
34928
|
+
raw.adapterAddress
|
|
34929
|
+
);
|
|
34930
|
+
const frostUrl = parseOptionalString(
|
|
34931
|
+
chain2,
|
|
34932
|
+
"frostUrl",
|
|
34933
|
+
raw.frostUrl
|
|
34934
|
+
)?.replace(/\/+$/, "");
|
|
34909
34935
|
const artifactBaseUrl = parseOptionalString(
|
|
34910
34936
|
chain2,
|
|
34911
34937
|
"artifactBaseUrl",
|
|
34912
34938
|
raw.artifactBaseUrl
|
|
34913
34939
|
)?.replace(/\/+$/, "");
|
|
34940
|
+
let tokenAddresses;
|
|
34941
|
+
if (raw.tokenAddresses !== void 0) {
|
|
34942
|
+
if (raw.tokenAddresses === null || typeof raw.tokenAddresses !== "object" || Array.isArray(raw.tokenAddresses)) {
|
|
34943
|
+
throw new InitializationError(
|
|
34944
|
+
`Invalid SDK config for ${chain2}: tokenAddresses must be an object`
|
|
34945
|
+
);
|
|
34946
|
+
}
|
|
34947
|
+
tokenAddresses = {};
|
|
34948
|
+
for (const [name, addr] of Object.entries(
|
|
34949
|
+
raw.tokenAddresses
|
|
34950
|
+
)) {
|
|
34951
|
+
tokenAddresses[name] = parseRequiredString(
|
|
34952
|
+
chain2,
|
|
34953
|
+
`tokenAddresses.${name}`,
|
|
34954
|
+
addr
|
|
34955
|
+
);
|
|
34956
|
+
}
|
|
34957
|
+
}
|
|
34914
34958
|
return {
|
|
34915
34959
|
chainId,
|
|
34916
34960
|
gatewayUrl,
|
|
34961
|
+
...frostUrl !== void 0 ? { frostUrl } : {},
|
|
34917
34962
|
poolAddress,
|
|
34963
|
+
...adapterAddress !== void 0 ? { adapterAddress } : {},
|
|
34918
34964
|
artifactVersion,
|
|
34919
|
-
...artifactBaseUrl !== void 0 ? { artifactBaseUrl } : { artifactBaseUrl: DEFAULT_ARTIFACT_BASE_URL }
|
|
34965
|
+
...artifactBaseUrl !== void 0 ? { artifactBaseUrl } : { artifactBaseUrl: DEFAULT_ARTIFACT_BASE_URL },
|
|
34966
|
+
...tokenAddresses !== void 0 ? { tokenAddresses } : {}
|
|
34920
34967
|
};
|
|
34921
34968
|
}
|
|
34922
34969
|
async function fetchChainConfig(chain2) {
|
|
@@ -52343,6 +52390,114 @@ var circuits_default = {
|
|
|
52343
52390
|
template: "JoinSplit",
|
|
52344
52391
|
pubs: ["merkleRoot", "boundParamsHash", "nullifiers", "commitmentsOut"],
|
|
52345
52392
|
params: [5, 2, 16]
|
|
52393
|
+
},
|
|
52394
|
+
joinsplit_1x3_16: {
|
|
52395
|
+
file: "joinsplit",
|
|
52396
|
+
template: "JoinSplit",
|
|
52397
|
+
pubs: ["merkleRoot", "boundParamsHash", "nullifiers", "commitmentsOut"],
|
|
52398
|
+
params: [1, 3, 16]
|
|
52399
|
+
},
|
|
52400
|
+
joinsplit_4x3_16: {
|
|
52401
|
+
file: "joinsplit",
|
|
52402
|
+
template: "JoinSplit",
|
|
52403
|
+
pubs: ["merkleRoot", "boundParamsHash", "nullifiers", "commitmentsOut"],
|
|
52404
|
+
params: [4, 3, 16]
|
|
52405
|
+
},
|
|
52406
|
+
joinsplit_5x3_16: {
|
|
52407
|
+
file: "joinsplit",
|
|
52408
|
+
template: "JoinSplit",
|
|
52409
|
+
pubs: ["merkleRoot", "boundParamsHash", "nullifiers", "commitmentsOut"],
|
|
52410
|
+
params: [5, 3, 16]
|
|
52411
|
+
},
|
|
52412
|
+
joinsplit_6x1_16: {
|
|
52413
|
+
file: "joinsplit",
|
|
52414
|
+
template: "JoinSplit",
|
|
52415
|
+
pubs: ["merkleRoot", "boundParamsHash", "nullifiers", "commitmentsOut"],
|
|
52416
|
+
params: [6, 1, 16]
|
|
52417
|
+
},
|
|
52418
|
+
joinsplit_6x2_16: {
|
|
52419
|
+
file: "joinsplit",
|
|
52420
|
+
template: "JoinSplit",
|
|
52421
|
+
pubs: ["merkleRoot", "boundParamsHash", "nullifiers", "commitmentsOut"],
|
|
52422
|
+
params: [6, 2, 16]
|
|
52423
|
+
},
|
|
52424
|
+
joinsplit_6x3_16: {
|
|
52425
|
+
file: "joinsplit",
|
|
52426
|
+
template: "JoinSplit",
|
|
52427
|
+
pubs: ["merkleRoot", "boundParamsHash", "nullifiers", "commitmentsOut"],
|
|
52428
|
+
params: [6, 3, 16]
|
|
52429
|
+
},
|
|
52430
|
+
joinsplit_7x1_16: {
|
|
52431
|
+
file: "joinsplit",
|
|
52432
|
+
template: "JoinSplit",
|
|
52433
|
+
pubs: ["merkleRoot", "boundParamsHash", "nullifiers", "commitmentsOut"],
|
|
52434
|
+
params: [7, 1, 16]
|
|
52435
|
+
},
|
|
52436
|
+
joinsplit_7x2_16: {
|
|
52437
|
+
file: "joinsplit",
|
|
52438
|
+
template: "JoinSplit",
|
|
52439
|
+
pubs: ["merkleRoot", "boundParamsHash", "nullifiers", "commitmentsOut"],
|
|
52440
|
+
params: [7, 2, 16]
|
|
52441
|
+
},
|
|
52442
|
+
joinsplit_7x3_16: {
|
|
52443
|
+
file: "joinsplit",
|
|
52444
|
+
template: "JoinSplit",
|
|
52445
|
+
pubs: ["merkleRoot", "boundParamsHash", "nullifiers", "commitmentsOut"],
|
|
52446
|
+
params: [7, 3, 16]
|
|
52447
|
+
},
|
|
52448
|
+
joinsplit_8x1_16: {
|
|
52449
|
+
file: "joinsplit",
|
|
52450
|
+
template: "JoinSplit",
|
|
52451
|
+
pubs: ["merkleRoot", "boundParamsHash", "nullifiers", "commitmentsOut"],
|
|
52452
|
+
params: [8, 1, 16]
|
|
52453
|
+
},
|
|
52454
|
+
joinsplit_8x2_16: {
|
|
52455
|
+
file: "joinsplit",
|
|
52456
|
+
template: "JoinSplit",
|
|
52457
|
+
pubs: ["merkleRoot", "boundParamsHash", "nullifiers", "commitmentsOut"],
|
|
52458
|
+
params: [8, 2, 16]
|
|
52459
|
+
},
|
|
52460
|
+
joinsplit_8x3_16: {
|
|
52461
|
+
file: "joinsplit",
|
|
52462
|
+
template: "JoinSplit",
|
|
52463
|
+
pubs: ["merkleRoot", "boundParamsHash", "nullifiers", "commitmentsOut"],
|
|
52464
|
+
params: [8, 3, 16]
|
|
52465
|
+
},
|
|
52466
|
+
joinsplit_9x1_16: {
|
|
52467
|
+
file: "joinsplit",
|
|
52468
|
+
template: "JoinSplit",
|
|
52469
|
+
pubs: ["merkleRoot", "boundParamsHash", "nullifiers", "commitmentsOut"],
|
|
52470
|
+
params: [9, 1, 16]
|
|
52471
|
+
},
|
|
52472
|
+
joinsplit_9x2_16: {
|
|
52473
|
+
file: "joinsplit",
|
|
52474
|
+
template: "JoinSplit",
|
|
52475
|
+
pubs: ["merkleRoot", "boundParamsHash", "nullifiers", "commitmentsOut"],
|
|
52476
|
+
params: [9, 2, 16]
|
|
52477
|
+
},
|
|
52478
|
+
joinsplit_9x3_16: {
|
|
52479
|
+
file: "joinsplit",
|
|
52480
|
+
template: "JoinSplit",
|
|
52481
|
+
pubs: ["merkleRoot", "boundParamsHash", "nullifiers", "commitmentsOut"],
|
|
52482
|
+
params: [9, 3, 16]
|
|
52483
|
+
},
|
|
52484
|
+
joinsplit_10x1_16: {
|
|
52485
|
+
file: "joinsplit",
|
|
52486
|
+
template: "JoinSplit",
|
|
52487
|
+
pubs: ["merkleRoot", "boundParamsHash", "nullifiers", "commitmentsOut"],
|
|
52488
|
+
params: [10, 1, 16]
|
|
52489
|
+
},
|
|
52490
|
+
joinsplit_10x2_16: {
|
|
52491
|
+
file: "joinsplit",
|
|
52492
|
+
template: "JoinSplit",
|
|
52493
|
+
pubs: ["merkleRoot", "boundParamsHash", "nullifiers", "commitmentsOut"],
|
|
52494
|
+
params: [10, 2, 16]
|
|
52495
|
+
},
|
|
52496
|
+
joinsplit_10x3_16: {
|
|
52497
|
+
file: "joinsplit",
|
|
52498
|
+
template: "JoinSplit",
|
|
52499
|
+
pubs: ["merkleRoot", "boundParamsHash", "nullifiers", "commitmentsOut"],
|
|
52500
|
+
params: [10, 3, 16]
|
|
52346
52501
|
}
|
|
52347
52502
|
};
|
|
52348
52503
|
|
|
@@ -52362,7 +52517,7 @@ function getCircuitConfig(inputs, outputs) {
|
|
|
52362
52517
|
}
|
|
52363
52518
|
|
|
52364
52519
|
// prover/prover.ts
|
|
52365
|
-
var MAX_ARTIFACT_CACHE_ENTRIES =
|
|
52520
|
+
var MAX_ARTIFACT_CACHE_ENTRIES = 16;
|
|
52366
52521
|
var artifactCache = /* @__PURE__ */ new Map();
|
|
52367
52522
|
function selectCircuit(inputs, outputs) {
|
|
52368
52523
|
const config2 = getCircuitConfig(inputs, outputs);
|
|
@@ -53219,7 +53374,7 @@ function buildCall(params) {
|
|
|
53219
53374
|
}
|
|
53220
53375
|
return { to, data, value };
|
|
53221
53376
|
}
|
|
53222
|
-
function
|
|
53377
|
+
function approve(token, spender, amount) {
|
|
53223
53378
|
const normalizedToken = ensureAddress("token", token);
|
|
53224
53379
|
const normalizedSpender = ensureAddress("spender", spender);
|
|
53225
53380
|
const normalizedAmount = ensureNonNegative("amount", amount);
|
|
@@ -53233,6 +53388,44 @@ function buildApproveCall(token, spender, amount) {
|
|
|
53233
53388
|
value: 0n
|
|
53234
53389
|
};
|
|
53235
53390
|
}
|
|
53391
|
+
function toCall(tx) {
|
|
53392
|
+
if (tx.to == null) {
|
|
53393
|
+
throw new AdapterError("tx.to is required");
|
|
53394
|
+
}
|
|
53395
|
+
const to = ensureAddress("tx.to", tx.to);
|
|
53396
|
+
if (tx.data == null) {
|
|
53397
|
+
throw new AdapterError("tx.data is required");
|
|
53398
|
+
}
|
|
53399
|
+
const data = ensureHexData("tx.data", tx.data);
|
|
53400
|
+
let value;
|
|
53401
|
+
if (tx.value == null) {
|
|
53402
|
+
value = 0n;
|
|
53403
|
+
} else {
|
|
53404
|
+
try {
|
|
53405
|
+
value = BigInt(tx.value);
|
|
53406
|
+
} catch {
|
|
53407
|
+
throw new AdapterError(
|
|
53408
|
+
`tx.value must be convertible to bigint, received: ${String(tx.value)}`
|
|
53409
|
+
);
|
|
53410
|
+
}
|
|
53411
|
+
}
|
|
53412
|
+
return { to, data, value: ensureNonNegative("tx.value", value) };
|
|
53413
|
+
}
|
|
53414
|
+
function contract(address, abi) {
|
|
53415
|
+
const to = ensureAddress("contract.address", address);
|
|
53416
|
+
const iface = new Interface(abi);
|
|
53417
|
+
return new Proxy(
|
|
53418
|
+
{},
|
|
53419
|
+
{
|
|
53420
|
+
get(_, method) {
|
|
53421
|
+
return (...args) => {
|
|
53422
|
+
const data = iface.encodeFunctionData(method, args);
|
|
53423
|
+
return { to, data, value: 0n };
|
|
53424
|
+
};
|
|
53425
|
+
}
|
|
53426
|
+
}
|
|
53427
|
+
);
|
|
53428
|
+
}
|
|
53236
53429
|
function encodeAdapterExecute(params) {
|
|
53237
53430
|
const transactCalldata = ensureHexData(
|
|
53238
53431
|
"transactCalldata",
|
|
@@ -53256,6 +53449,7 @@ function encodeAdapterExecute(params) {
|
|
|
53256
53449
|
deadline
|
|
53257
53450
|
]);
|
|
53258
53451
|
}
|
|
53452
|
+
var buildApproveCall = approve;
|
|
53259
53453
|
|
|
53260
53454
|
// transactions/transaction-planner.ts
|
|
53261
53455
|
init_process();
|
|
@@ -54373,7 +54567,7 @@ function createNoteSyncService(stateStore, options = {}) {
|
|
|
54373
54567
|
};
|
|
54374
54568
|
}
|
|
54375
54569
|
|
|
54376
|
-
// wallet/unlink
|
|
54570
|
+
// wallet/unlink.ts
|
|
54377
54571
|
init_process();
|
|
54378
54572
|
init_buffer();
|
|
54379
54573
|
|
|
@@ -54670,26 +54864,34 @@ function normalizeCall2(call, index) {
|
|
|
54670
54864
|
value: call.value
|
|
54671
54865
|
};
|
|
54672
54866
|
}
|
|
54673
|
-
function
|
|
54674
|
-
const token = ensureAddress(`
|
|
54867
|
+
function normalizeSpendInput(input, index) {
|
|
54868
|
+
const token = ensureAddress(`spend[${index}].token`, input.token);
|
|
54869
|
+
if (token.toLowerCase() === ETH_TOKEN.toLowerCase()) {
|
|
54870
|
+
throw new AdapterError(
|
|
54871
|
+
`spend[${index}].token: native ETH is not supported in adapter execution`
|
|
54872
|
+
);
|
|
54873
|
+
}
|
|
54675
54874
|
if (input.amount <= 0n) {
|
|
54676
|
-
throw new AdapterError(`
|
|
54875
|
+
throw new AdapterError(`spend[${index}].amount must be greater than zero`);
|
|
54677
54876
|
}
|
|
54678
54877
|
return {
|
|
54679
54878
|
token,
|
|
54680
54879
|
amount: input.amount
|
|
54681
54880
|
};
|
|
54682
54881
|
}
|
|
54683
|
-
function
|
|
54684
|
-
const token = ensureAddress(`
|
|
54685
|
-
if (
|
|
54882
|
+
function normalizeReceiveInput(receive, index) {
|
|
54883
|
+
const token = ensureAddress(`receive[${index}].token`, receive.token);
|
|
54884
|
+
if (token.toLowerCase() === ETH_TOKEN.toLowerCase()) {
|
|
54686
54885
|
throw new AdapterError(
|
|
54687
|
-
`
|
|
54886
|
+
`receive[${index}].token: native ETH is not supported in adapter execution`
|
|
54688
54887
|
);
|
|
54689
54888
|
}
|
|
54889
|
+
if (receive.minAmount < 0n) {
|
|
54890
|
+
throw new AdapterError(`receive[${index}].minAmount must be non-negative`);
|
|
54891
|
+
}
|
|
54690
54892
|
return {
|
|
54691
54893
|
token,
|
|
54692
|
-
minAmount:
|
|
54894
|
+
minAmount: receive.minAmount
|
|
54693
54895
|
};
|
|
54694
54896
|
}
|
|
54695
54897
|
function randomFieldElement(randomBigintFn) {
|
|
@@ -54709,41 +54911,41 @@ function createAdapterService(deps) {
|
|
|
54709
54911
|
"adapterAddress",
|
|
54710
54912
|
params.adapterAddress
|
|
54711
54913
|
);
|
|
54712
|
-
if (!params.
|
|
54713
|
-
throw new AdapterError("at least one
|
|
54914
|
+
if (!params.spend.length) {
|
|
54915
|
+
throw new AdapterError("at least one spend token is required");
|
|
54714
54916
|
}
|
|
54715
54917
|
if (!params.calls.length) {
|
|
54716
54918
|
throw new AdapterError("at least one adapter call is required");
|
|
54717
54919
|
}
|
|
54718
|
-
if (!params.
|
|
54719
|
-
throw new AdapterError("at least one
|
|
54920
|
+
if (!params.receive.length) {
|
|
54921
|
+
throw new AdapterError("at least one receive output is required");
|
|
54720
54922
|
}
|
|
54721
|
-
const
|
|
54722
|
-
(input, i) =>
|
|
54923
|
+
const spendInputs = params.spend.map(
|
|
54924
|
+
(input, i) => normalizeSpendInput(input, i)
|
|
54723
54925
|
);
|
|
54724
54926
|
const seenTokens = /* @__PURE__ */ new Set();
|
|
54725
|
-
for (const input of
|
|
54927
|
+
for (const input of spendInputs) {
|
|
54726
54928
|
const lower = input.token.toLowerCase();
|
|
54727
54929
|
if (seenTokens.has(lower)) {
|
|
54728
54930
|
throw new AdapterError(
|
|
54729
|
-
`duplicate
|
|
54931
|
+
`duplicate spend token ${input.token}; combine amounts per token instead`
|
|
54730
54932
|
);
|
|
54731
54933
|
}
|
|
54732
54934
|
seenTokens.add(lower);
|
|
54733
54935
|
}
|
|
54734
54936
|
const calls = params.calls.map((call, i) => normalizeCall2(call, i));
|
|
54735
|
-
const
|
|
54736
|
-
(
|
|
54937
|
+
const receiveSpecs = params.receive.map(
|
|
54938
|
+
(receive, i) => normalizeReceiveInput(receive, i)
|
|
54737
54939
|
);
|
|
54738
|
-
const
|
|
54739
|
-
for (const r2 of
|
|
54940
|
+
const seenReceiveTokens = /* @__PURE__ */ new Set();
|
|
54941
|
+
for (const r2 of receiveSpecs) {
|
|
54740
54942
|
const lower = r2.token.toLowerCase();
|
|
54741
|
-
if (
|
|
54943
|
+
if (seenReceiveTokens.has(lower)) {
|
|
54742
54944
|
throw new AdapterError(
|
|
54743
|
-
`duplicate
|
|
54945
|
+
`duplicate receive token ${r2.token}; each receive must target a unique token`
|
|
54744
54946
|
);
|
|
54745
54947
|
}
|
|
54746
|
-
|
|
54948
|
+
seenReceiveTokens.add(lower);
|
|
54747
54949
|
}
|
|
54748
54950
|
const account = overrides?.account ?? await deps.requireActiveAccount();
|
|
54749
54951
|
const signer = overrides?.signer ?? deps.requireSigner(account);
|
|
@@ -54753,19 +54955,19 @@ function createAdapterService(deps) {
|
|
|
54753
54955
|
throw new AdapterError("deadline must be in the future");
|
|
54754
54956
|
}
|
|
54755
54957
|
const executionCalls = calls;
|
|
54756
|
-
const reshields =
|
|
54757
|
-
(
|
|
54958
|
+
const reshields = receiveSpecs.map(
|
|
54959
|
+
(receive) => {
|
|
54758
54960
|
const random = randomFieldElement(randomBigintImpl);
|
|
54759
54961
|
const npk = poseidon([account.masterPublicKey, random]);
|
|
54760
54962
|
return {
|
|
54761
54963
|
npk,
|
|
54762
54964
|
random,
|
|
54763
|
-
token:
|
|
54764
|
-
minAmount:
|
|
54965
|
+
token: receive.token,
|
|
54966
|
+
minAmount: receive.minAmount
|
|
54765
54967
|
};
|
|
54766
54968
|
}
|
|
54767
54969
|
);
|
|
54768
|
-
const inputTokens =
|
|
54970
|
+
const inputTokens = spendInputs.map((input) => input.token);
|
|
54769
54971
|
const nonce = randomFieldElement(randomBigintImpl);
|
|
54770
54972
|
const adapterDataHash = computeAdapterDataHash({
|
|
54771
54973
|
calls: executionCalls,
|
|
@@ -54782,7 +54984,7 @@ function createAdapterService(deps) {
|
|
|
54782
54984
|
});
|
|
54783
54985
|
const withdrawalPlans = planWithdrawalsImpl(
|
|
54784
54986
|
notes,
|
|
54785
|
-
|
|
54987
|
+
spendInputs.map((input) => ({
|
|
54786
54988
|
token: input.token,
|
|
54787
54989
|
amount: input.amount,
|
|
54788
54990
|
recipient: adapterAddress
|
|
@@ -54865,7 +55067,7 @@ function createAdapterService(deps) {
|
|
|
54865
55067
|
adapterCalldata,
|
|
54866
55068
|
historyPreview: {
|
|
54867
55069
|
kind: "Withdraw",
|
|
54868
|
-
amounts:
|
|
55070
|
+
amounts: spendInputs.map((input) => ({
|
|
54869
55071
|
token: input.token,
|
|
54870
55072
|
delta: (-input.amount).toString()
|
|
54871
55073
|
}))
|
|
@@ -54887,6 +55089,9 @@ init_process();
|
|
|
54887
55089
|
init_buffer();
|
|
54888
55090
|
var BIP44_ETH_PREFIX = "m/44'/60'/0'/0";
|
|
54889
55091
|
var ERC20_BALANCE_OF = "function balanceOf(address) view returns (uint256)";
|
|
55092
|
+
function isNativeToken(token) {
|
|
55093
|
+
return token.toLowerCase() === ETH_TOKEN.toLowerCase();
|
|
55094
|
+
}
|
|
54890
55095
|
function createBurnerService(deps) {
|
|
54891
55096
|
const { chainRpcUrl, getMasterSeed, withdrawToAddress, requestDeposit } = deps;
|
|
54892
55097
|
const provider = new JsonRpcProvider(chainRpcUrl);
|
|
@@ -54934,8 +55139,8 @@ function createBurnerService(deps) {
|
|
|
54934
55139
|
}
|
|
54935
55140
|
async function getTokenBalance(address, token) {
|
|
54936
55141
|
const iface = new Interface([ERC20_BALANCE_OF]);
|
|
54937
|
-
const
|
|
54938
|
-
const bal = await
|
|
55142
|
+
const contract2 = new Contract(token, iface, provider);
|
|
55143
|
+
const bal = await contract2.getFunction("balanceOf")(address);
|
|
54939
55144
|
return BigInt(bal ?? 0);
|
|
54940
55145
|
}
|
|
54941
55146
|
async function getBalance(address) {
|
|
@@ -54954,6 +55159,12 @@ function createBurnerService(deps) {
|
|
|
54954
55159
|
}
|
|
54955
55160
|
async function sweepToPool(index, params) {
|
|
54956
55161
|
const { address } = await addressOf(index);
|
|
55162
|
+
const native = isNativeToken(params.token);
|
|
55163
|
+
if (native && params.amount == null) {
|
|
55164
|
+
throw new Error(
|
|
55165
|
+
"amount is required for native ETH sweeps (needed to reserve gas)"
|
|
55166
|
+
);
|
|
55167
|
+
}
|
|
54957
55168
|
const amount = params.amount ?? await getTokenBalance(address, params.token);
|
|
54958
55169
|
if (amount === 0n) {
|
|
54959
55170
|
throw new Error("No token balance to sweep");
|
|
@@ -54964,17 +55175,20 @@ function createBurnerService(deps) {
|
|
|
54964
55175
|
depositor: address,
|
|
54965
55176
|
deposits: [{ token: params.token, amount }]
|
|
54966
55177
|
});
|
|
54967
|
-
|
|
54968
|
-
|
|
54969
|
-
|
|
54970
|
-
|
|
54971
|
-
|
|
54972
|
-
|
|
54973
|
-
|
|
54974
|
-
|
|
55178
|
+
if (!native) {
|
|
55179
|
+
const erc20Iface = new Interface([
|
|
55180
|
+
"function approve(address spender, uint256 amount)"
|
|
55181
|
+
]);
|
|
55182
|
+
const approveData = erc20Iface.encodeFunctionData("approve", [
|
|
55183
|
+
params.poolAddress,
|
|
55184
|
+
amount
|
|
55185
|
+
]);
|
|
55186
|
+
await send(index, { to: params.token, data: approveData });
|
|
55187
|
+
}
|
|
54975
55188
|
const { txHash } = await send(index, {
|
|
54976
55189
|
to: depositResult.to,
|
|
54977
|
-
data: depositResult.calldata
|
|
55190
|
+
data: depositResult.calldata,
|
|
55191
|
+
value: depositResult.value
|
|
54978
55192
|
});
|
|
54979
55193
|
return { txHash };
|
|
54980
55194
|
}
|
|
@@ -55684,21 +55898,27 @@ async function createBrowserWalletSDK(options) {
|
|
|
55684
55898
|
};
|
|
55685
55899
|
}
|
|
55686
55900
|
|
|
55687
|
-
// wallet/unlink
|
|
55688
|
-
var
|
|
55901
|
+
// wallet/unlink.ts
|
|
55902
|
+
var Unlink = class _Unlink {
|
|
55689
55903
|
/** @internal */
|
|
55690
55904
|
sdk;
|
|
55691
55905
|
/** Chain ID this wallet operates on. */
|
|
55692
55906
|
chainId;
|
|
55693
55907
|
/** Pool contract address this wallet transacts with. */
|
|
55694
55908
|
poolAddress;
|
|
55695
|
-
|
|
55909
|
+
/** Adapter contract address for DeFi operations. */
|
|
55910
|
+
adapterAddress;
|
|
55911
|
+
constructor(sdk, chainId, poolAddress, adapterAddress) {
|
|
55696
55912
|
this.sdk = sdk;
|
|
55697
55913
|
this.chainId = chainId;
|
|
55698
55914
|
this.poolAddress = poolAddress;
|
|
55915
|
+
this.adapterAddress = adapterAddress;
|
|
55916
|
+
this.adapter = {
|
|
55917
|
+
address: adapterAddress
|
|
55918
|
+
};
|
|
55699
55919
|
}
|
|
55700
55920
|
/**
|
|
55701
|
-
* Create a new
|
|
55921
|
+
* Create a new Unlink instance.
|
|
55702
55922
|
*
|
|
55703
55923
|
* Handles all initialization internally:
|
|
55704
55924
|
* - Resolves chain config (if using `chain` instead of explicit URLs)
|
|
@@ -55710,12 +55930,14 @@ var UnlinkWallet = class _UnlinkWallet {
|
|
|
55710
55930
|
let chainId;
|
|
55711
55931
|
let gatewayUrl;
|
|
55712
55932
|
let poolAddress;
|
|
55933
|
+
let adapterAddress;
|
|
55713
55934
|
let proverConfig = config2.prover;
|
|
55714
55935
|
if ("chain" in config2) {
|
|
55715
55936
|
const chainConfig = await fetchChainConfig(config2.chain);
|
|
55716
55937
|
chainId = chainConfig.chainId;
|
|
55717
55938
|
gatewayUrl = chainConfig.gatewayUrl;
|
|
55718
55939
|
poolAddress = config2.poolAddress ?? chainConfig.poolAddress;
|
|
55940
|
+
adapterAddress = config2.adapterAddress ?? chainConfig.adapterAddress;
|
|
55719
55941
|
proverConfig = {
|
|
55720
55942
|
artifactSource: {
|
|
55721
55943
|
baseUrl: config2.prover?.artifactSource?.baseUrl ?? chainConfig.artifactBaseUrl,
|
|
@@ -55727,6 +55949,7 @@ var UnlinkWallet = class _UnlinkWallet {
|
|
|
55727
55949
|
chainId = config2.chainId;
|
|
55728
55950
|
gatewayUrl = config2.gatewayUrl;
|
|
55729
55951
|
poolAddress = config2.poolAddress;
|
|
55952
|
+
adapterAddress = config2.adapterAddress;
|
|
55730
55953
|
if (typeof window !== "undefined" && !config2.prover?.artifactSource?.version) {
|
|
55731
55954
|
throw new InitializationError(
|
|
55732
55955
|
"prover.artifactSource.version is required in browser when using explicit gatewayUrl mode. Use chain mode or provide a pinned artifact version."
|
|
@@ -55747,7 +55970,7 @@ var UnlinkWallet = class _UnlinkWallet {
|
|
|
55747
55970
|
autoSync: config2.autoSync
|
|
55748
55971
|
}
|
|
55749
55972
|
);
|
|
55750
|
-
return new
|
|
55973
|
+
return new _Unlink(sdk, chainId, poolAddress, adapterAddress ?? "");
|
|
55751
55974
|
}
|
|
55752
55975
|
// ===== Seed Lifecycle =====
|
|
55753
55976
|
/** Seed management (create, import, export, delete mnemonic). */
|
|
@@ -55778,10 +56001,10 @@ var UnlinkWallet = class _UnlinkWallet {
|
|
|
55778
56001
|
return this.sdk.deposit.reconcile(relayId);
|
|
55779
56002
|
}
|
|
55780
56003
|
/**
|
|
55781
|
-
*
|
|
56004
|
+
* Send a private transfer (1 or more recipients).
|
|
55782
56005
|
* Handles note selection, circuit selection, and proof generation automatically.
|
|
55783
56006
|
*/
|
|
55784
|
-
async
|
|
56007
|
+
async send(params, overrides) {
|
|
55785
56008
|
return this.sdk.transfer.send(
|
|
55786
56009
|
{
|
|
55787
56010
|
chainId: this.chainId,
|
|
@@ -55792,9 +56015,9 @@ var UnlinkWallet = class _UnlinkWallet {
|
|
|
55792
56015
|
);
|
|
55793
56016
|
}
|
|
55794
56017
|
/**
|
|
55795
|
-
* Get a
|
|
56018
|
+
* Get a send plan without executing (for preview/confirmation UIs).
|
|
55796
56019
|
*/
|
|
55797
|
-
async
|
|
56020
|
+
async planSend(params, account) {
|
|
55798
56021
|
return this.sdk.transfer.plan(
|
|
55799
56022
|
{
|
|
55800
56023
|
chainId: this.chainId,
|
|
@@ -55804,8 +56027,8 @@ var UnlinkWallet = class _UnlinkWallet {
|
|
|
55804
56027
|
account
|
|
55805
56028
|
);
|
|
55806
56029
|
}
|
|
55807
|
-
/** Execute a pre-built
|
|
55808
|
-
async
|
|
56030
|
+
/** Execute a pre-built send plan. */
|
|
56031
|
+
async executeSend(plans, overrides) {
|
|
55809
56032
|
return this.sdk.transfer.execute(
|
|
55810
56033
|
plans,
|
|
55811
56034
|
{ chainId: this.chainId, poolAddress: this.poolAddress },
|
|
@@ -55954,31 +56177,31 @@ var UnlinkWallet = class _UnlinkWallet {
|
|
|
55954
56177
|
return this.sdk.burner.getBalance(address);
|
|
55955
56178
|
}
|
|
55956
56179
|
};
|
|
55957
|
-
// =====
|
|
56180
|
+
// ===== Interact (Private DeFi) =====
|
|
55958
56181
|
/**
|
|
55959
|
-
*
|
|
55960
|
-
*
|
|
56182
|
+
* Adapter contract address (resolved from config).
|
|
56183
|
+
* Use for building DeFi calls that reference the adapter.
|
|
55961
56184
|
*/
|
|
55962
|
-
adapter
|
|
55963
|
-
|
|
55964
|
-
|
|
55965
|
-
|
|
55966
|
-
|
|
55967
|
-
|
|
55968
|
-
|
|
55969
|
-
|
|
55970
|
-
|
|
55971
|
-
|
|
55972
|
-
|
|
55973
|
-
|
|
55974
|
-
|
|
55975
|
-
|
|
55976
|
-
|
|
55977
|
-
|
|
55978
|
-
|
|
55979
|
-
|
|
55980
|
-
|
|
55981
|
-
}
|
|
56185
|
+
adapter;
|
|
56186
|
+
/**
|
|
56187
|
+
* Execute an atomic unshield -> DeFi call(s) -> reshield flow through an adapter.
|
|
56188
|
+
* chainId/poolAddress/adapterAddress are injected automatically.
|
|
56189
|
+
*/
|
|
56190
|
+
async interact(params, opts, overrides) {
|
|
56191
|
+
return this.sdk.adapter.execute(
|
|
56192
|
+
{
|
|
56193
|
+
chainId: this.chainId,
|
|
56194
|
+
poolAddress: this.poolAddress,
|
|
56195
|
+
adapterAddress: this.adapterAddress,
|
|
56196
|
+
spend: params.spend,
|
|
56197
|
+
calls: params.calls,
|
|
56198
|
+
receive: params.receive,
|
|
56199
|
+
deadline: params.deadline
|
|
56200
|
+
},
|
|
56201
|
+
opts,
|
|
56202
|
+
overrides
|
|
56203
|
+
);
|
|
56204
|
+
}
|
|
55982
56205
|
// ===== Advanced =====
|
|
55983
56206
|
/**
|
|
55984
56207
|
* Advanced escape hatch for raw JoinSplit transaction building.
|
|
@@ -56026,12 +56249,14 @@ var defaultRng = (n2) => {
|
|
|
56026
56249
|
}
|
|
56027
56250
|
return globalThis.crypto.getRandomValues(new Uint8Array(n2));
|
|
56028
56251
|
};
|
|
56252
|
+
var UnlinkWallet = Unlink;
|
|
56029
56253
|
export {
|
|
56030
56254
|
ADAPTER_EXECUTE_ABI,
|
|
56031
56255
|
AdapterError,
|
|
56032
56256
|
CORE_SCHEMA_VERSION,
|
|
56033
56257
|
CoreError,
|
|
56034
56258
|
DEFAULT_JOB_TIMEOUT_MS,
|
|
56259
|
+
DEFAULT_RPC_URLS,
|
|
56035
56260
|
DEPOSIT_ABI,
|
|
56036
56261
|
ETH_TOKEN,
|
|
56037
56262
|
FieldSize,
|
|
@@ -56049,8 +56274,10 @@ export {
|
|
|
56049
56274
|
ReconcileError,
|
|
56050
56275
|
SNARK_SCALAR_FIELD,
|
|
56051
56276
|
SchemaMismatchError,
|
|
56277
|
+
Unlink,
|
|
56052
56278
|
UnlinkWallet,
|
|
56053
56279
|
ValidationError,
|
|
56280
|
+
approve,
|
|
56054
56281
|
assertNonNegative,
|
|
56055
56282
|
buildApproveCall,
|
|
56056
56283
|
buildCall,
|
|
@@ -56060,6 +56287,7 @@ export {
|
|
|
56060
56287
|
computeCommitment,
|
|
56061
56288
|
computeMasterPublicKey,
|
|
56062
56289
|
computeNullifyingKey,
|
|
56290
|
+
contract,
|
|
56063
56291
|
createBroadcasterClient,
|
|
56064
56292
|
createBrowserWalletSDK,
|
|
56065
56293
|
createCiphertextStore,
|
|
@@ -56132,6 +56360,7 @@ export {
|
|
|
56132
56360
|
syncDeposit,
|
|
56133
56361
|
syncTransact,
|
|
56134
56362
|
toAccountView,
|
|
56363
|
+
toCall,
|
|
56135
56364
|
transact,
|
|
56136
56365
|
validateKey,
|
|
56137
56366
|
verifySignature,
|