@unlink-xyz/core 0.1.5 → 0.1.7-canary.252b8ea
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/account/account.d.ts +1 -1
- package/dist/account/account.d.ts.map +1 -1
- package/dist/browser/index.js +476 -215
- package/dist/browser/index.js.map +1 -1
- package/dist/browser/wallet/index.js +427 -213
- package/dist/browser/wallet/index.js.map +1 -1
- package/dist/clients/http.d.ts.map +1 -1
- package/dist/config.d.ts +20 -8
- package/dist/config.d.ts.map +1 -1
- package/dist/index.d.ts +3 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +399 -138
- 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/utils/validators.d.ts +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 +350 -136
- package/dist/wallet/index.js.map +1 -1
- package/dist/wallet/sdk.d.ts +8 -9
- package/dist/wallet/sdk.d.ts.map +1 -1
- package/dist/wallet/types.d.ts +61 -52
- package/dist/wallet/types.d.ts.map +1 -1
- package/dist/wallet/{unlink-wallet.d.ts → unlink.d.ts} +44 -38
- package/dist/wallet/unlink.d.ts.map +1 -0
- package/package.json +1 -1
- package/dist/wallet/unlink-wallet.d.ts.map +0 -1
|
@@ -3555,7 +3555,7 @@ var init_fs = __esm({
|
|
|
3555
3555
|
init_process();
|
|
3556
3556
|
init_buffer();
|
|
3557
3557
|
|
|
3558
|
-
// wallet/unlink
|
|
3558
|
+
// wallet/unlink.ts
|
|
3559
3559
|
init_process();
|
|
3560
3560
|
init_buffer();
|
|
3561
3561
|
|
|
@@ -3707,63 +3707,110 @@ var Runtime = {
|
|
|
3707
3707
|
|
|
3708
3708
|
// config.ts
|
|
3709
3709
|
var CONFIG_URL = "https://config.unlink.xyz/networks.json";
|
|
3710
|
-
function parseRequiredString(
|
|
3710
|
+
function parseRequiredString(chain2, field, value) {
|
|
3711
3711
|
if (typeof value !== "string" || value.trim().length === 0) {
|
|
3712
3712
|
throw new InitializationError(
|
|
3713
|
-
`Invalid SDK config for ${
|
|
3713
|
+
`Invalid SDK config for ${chain2}: ${field} must be a non-empty string`
|
|
3714
3714
|
);
|
|
3715
3715
|
}
|
|
3716
3716
|
return value.trim();
|
|
3717
3717
|
}
|
|
3718
|
-
function parseOptionalString(
|
|
3718
|
+
function parseOptionalString(chain2, field, value) {
|
|
3719
3719
|
if (value === void 0) return void 0;
|
|
3720
3720
|
if (typeof value !== "string" || value.trim().length === 0) {
|
|
3721
3721
|
throw new InitializationError(
|
|
3722
|
-
`Invalid SDK config for ${
|
|
3722
|
+
`Invalid SDK config for ${chain2}: ${field} must be a non-empty string when provided`
|
|
3723
3723
|
);
|
|
3724
3724
|
}
|
|
3725
3725
|
return value.trim();
|
|
3726
3726
|
}
|
|
3727
|
-
function
|
|
3727
|
+
function parseRequiredChainId(chain2, value) {
|
|
3728
|
+
if (typeof value !== "number" || !Number.isInteger(value) || value <= 0) {
|
|
3729
|
+
throw new InitializationError(
|
|
3730
|
+
`Invalid SDK config for ${chain2}: chainId must be a positive integer`
|
|
3731
|
+
);
|
|
3732
|
+
}
|
|
3733
|
+
return value;
|
|
3734
|
+
}
|
|
3735
|
+
function parseChainConfig(chain2, value) {
|
|
3728
3736
|
if (value === null || typeof value !== "object" || Array.isArray(value)) {
|
|
3729
3737
|
throw new InitializationError(
|
|
3730
|
-
`Invalid SDK config for ${
|
|
3738
|
+
`Invalid SDK config for ${chain2}: expected object`
|
|
3731
3739
|
);
|
|
3732
3740
|
}
|
|
3733
3741
|
const raw = value;
|
|
3742
|
+
const chainId = parseRequiredChainId(chain2, raw.chainId);
|
|
3734
3743
|
const gatewayUrl = parseRequiredString(
|
|
3735
|
-
|
|
3744
|
+
chain2,
|
|
3736
3745
|
"gatewayUrl",
|
|
3737
3746
|
raw.gatewayUrl
|
|
3738
3747
|
).replace(/\/+$/, "");
|
|
3739
|
-
const poolAddress = parseRequiredString(
|
|
3748
|
+
const poolAddress = parseRequiredString(
|
|
3749
|
+
chain2,
|
|
3750
|
+
"poolAddress",
|
|
3751
|
+
raw.poolAddress
|
|
3752
|
+
);
|
|
3740
3753
|
const artifactVersion = parseRequiredString(
|
|
3741
|
-
|
|
3754
|
+
chain2,
|
|
3742
3755
|
"artifactVersion",
|
|
3743
3756
|
raw.artifactVersion
|
|
3744
3757
|
).replace(/^\/+|\/+$/g, "");
|
|
3758
|
+
const adapterAddress = parseOptionalString(
|
|
3759
|
+
chain2,
|
|
3760
|
+
"adapterAddress",
|
|
3761
|
+
raw.adapterAddress
|
|
3762
|
+
);
|
|
3763
|
+
const frostUrl = parseOptionalString(
|
|
3764
|
+
chain2,
|
|
3765
|
+
"frostUrl",
|
|
3766
|
+
raw.frostUrl
|
|
3767
|
+
)?.replace(/\/+$/, "");
|
|
3745
3768
|
const artifactBaseUrl = parseOptionalString(
|
|
3746
|
-
|
|
3769
|
+
chain2,
|
|
3747
3770
|
"artifactBaseUrl",
|
|
3748
3771
|
raw.artifactBaseUrl
|
|
3749
3772
|
)?.replace(/\/+$/, "");
|
|
3773
|
+
let tokenAddresses;
|
|
3774
|
+
if (raw.tokenAddresses !== void 0) {
|
|
3775
|
+
if (raw.tokenAddresses === null || typeof raw.tokenAddresses !== "object" || Array.isArray(raw.tokenAddresses)) {
|
|
3776
|
+
throw new InitializationError(
|
|
3777
|
+
`Invalid SDK config for ${chain2}: tokenAddresses must be an object`
|
|
3778
|
+
);
|
|
3779
|
+
}
|
|
3780
|
+
tokenAddresses = {};
|
|
3781
|
+
for (const [name, addr] of Object.entries(
|
|
3782
|
+
raw.tokenAddresses
|
|
3783
|
+
)) {
|
|
3784
|
+
tokenAddresses[name] = parseRequiredString(
|
|
3785
|
+
chain2,
|
|
3786
|
+
`tokenAddresses.${name}`,
|
|
3787
|
+
addr
|
|
3788
|
+
);
|
|
3789
|
+
}
|
|
3790
|
+
}
|
|
3750
3791
|
return {
|
|
3792
|
+
chainId,
|
|
3751
3793
|
gatewayUrl,
|
|
3794
|
+
...frostUrl !== void 0 ? { frostUrl } : {},
|
|
3752
3795
|
poolAddress,
|
|
3796
|
+
...adapterAddress !== void 0 ? { adapterAddress } : {},
|
|
3753
3797
|
artifactVersion,
|
|
3754
|
-
...artifactBaseUrl !== void 0 ? { artifactBaseUrl } : { artifactBaseUrl: DEFAULT_ARTIFACT_BASE_URL }
|
|
3798
|
+
...artifactBaseUrl !== void 0 ? { artifactBaseUrl } : { artifactBaseUrl: DEFAULT_ARTIFACT_BASE_URL },
|
|
3799
|
+
...tokenAddresses !== void 0 ? { tokenAddresses } : {}
|
|
3755
3800
|
};
|
|
3756
3801
|
}
|
|
3757
|
-
async function
|
|
3802
|
+
async function fetchChainConfig(chain2) {
|
|
3758
3803
|
const res = await fetch(CONFIG_URL);
|
|
3759
3804
|
if (!res.ok) {
|
|
3760
3805
|
throw new InitializationError(`Failed to fetch SDK config: ${res.status}`);
|
|
3761
3806
|
}
|
|
3762
3807
|
const config2 = await res.json();
|
|
3763
|
-
if (!config2[
|
|
3764
|
-
throw new InitializationError(
|
|
3808
|
+
if (!config2[chain2]) {
|
|
3809
|
+
throw new InitializationError(
|
|
3810
|
+
`Unknown chain: "${chain2}". Supported chains: ${Object.keys(config2).join(", ")}`
|
|
3811
|
+
);
|
|
3765
3812
|
}
|
|
3766
|
-
return
|
|
3813
|
+
return parseChainConfig(chain2, config2[chain2]);
|
|
3767
3814
|
}
|
|
3768
3815
|
function createServiceConfig(gatewayUrl) {
|
|
3769
3816
|
const baseUrl = gatewayUrl.replace(/\/+$/, "");
|
|
@@ -4512,9 +4559,9 @@ var Hex = class _Hex {
|
|
|
4512
4559
|
|
|
4513
4560
|
// keys/address.ts
|
|
4514
4561
|
var VERSION = 1;
|
|
4515
|
-
var LIMIT =
|
|
4562
|
+
var LIMIT = 130;
|
|
4516
4563
|
var ALL_CHAINS = "ffffffffffffffff";
|
|
4517
|
-
var PREFIX = "
|
|
4564
|
+
var PREFIX = "unlink";
|
|
4518
4565
|
var SALT = new TextEncoder().encode("unlink");
|
|
4519
4566
|
function xorWithSalt(hex2) {
|
|
4520
4567
|
const bytes2 = Hex.toBytes(hex2);
|
|
@@ -13376,29 +13423,41 @@ function createJsonHttpClient(baseUrl, deps) {
|
|
|
13376
13423
|
fetch: fetchImpl,
|
|
13377
13424
|
// Disable ky's automatic error throwing to prevent browser DevTools
|
|
13378
13425
|
// from logging expected 404s as network errors
|
|
13379
|
-
throwHttpErrors: false
|
|
13426
|
+
throwHttpErrors: false,
|
|
13427
|
+
retry: 0
|
|
13380
13428
|
});
|
|
13429
|
+
const RETRYABLE_STATUSES = [502, 503, 504];
|
|
13430
|
+
const MAX_RETRIES = 3;
|
|
13431
|
+
const BASE_DELAY_MS = 500;
|
|
13381
13432
|
return {
|
|
13382
13433
|
async request(opts) {
|
|
13383
13434
|
let res;
|
|
13384
|
-
|
|
13385
|
-
|
|
13386
|
-
|
|
13387
|
-
|
|
13388
|
-
|
|
13389
|
-
|
|
13390
|
-
|
|
13391
|
-
|
|
13392
|
-
|
|
13393
|
-
|
|
13394
|
-
|
|
13395
|
-
|
|
13435
|
+
for (let attempt = 0; attempt <= MAX_RETRIES; attempt++) {
|
|
13436
|
+
try {
|
|
13437
|
+
res = await api(opts.path.replace(/^\//, ""), {
|
|
13438
|
+
method: opts.method,
|
|
13439
|
+
searchParams: opts.query,
|
|
13440
|
+
json: opts.json,
|
|
13441
|
+
body: opts.body,
|
|
13442
|
+
headers: opts.headers,
|
|
13443
|
+
signal: opts.signal
|
|
13444
|
+
});
|
|
13445
|
+
} catch (err) {
|
|
13446
|
+
if (err instanceof TimeoutError) {
|
|
13447
|
+
throw new HttpError("HTTP timeout", 408, null);
|
|
13448
|
+
}
|
|
13449
|
+
throw new HttpError(
|
|
13450
|
+
err instanceof Error ? err.message : "Network error",
|
|
13451
|
+
0,
|
|
13452
|
+
null
|
|
13453
|
+
);
|
|
13396
13454
|
}
|
|
13397
|
-
|
|
13398
|
-
|
|
13399
|
-
|
|
13400
|
-
|
|
13401
|
-
|
|
13455
|
+
if (RETRYABLE_STATUSES.includes(res.status) && attempt < MAX_RETRIES) {
|
|
13456
|
+
const delay2 = BASE_DELAY_MS * 2 ** attempt + Math.random() * 200;
|
|
13457
|
+
await new Promise((r2) => setTimeout(r2, delay2));
|
|
13458
|
+
continue;
|
|
13459
|
+
}
|
|
13460
|
+
break;
|
|
13402
13461
|
}
|
|
13403
13462
|
if (!res.ok) {
|
|
13404
13463
|
const body = await readErrorBodySafe(res);
|
|
@@ -13624,7 +13683,7 @@ function parseZkAddress(value) {
|
|
|
13624
13683
|
};
|
|
13625
13684
|
} catch (err) {
|
|
13626
13685
|
throw new ValidationError(
|
|
13627
|
-
`Invalid ZK address (expected
|
|
13686
|
+
`Invalid ZK address (expected unlink1... format): ${err instanceof Error ? err.message : "unknown error"}`
|
|
13628
13687
|
);
|
|
13629
13688
|
}
|
|
13630
13689
|
}
|
|
@@ -28485,8 +28544,8 @@ var ContractUnknownEventPayload = class extends EventPayload {
|
|
|
28485
28544
|
/**
|
|
28486
28545
|
* @_event:
|
|
28487
28546
|
*/
|
|
28488
|
-
constructor(
|
|
28489
|
-
super(
|
|
28547
|
+
constructor(contract2, listener, filter, log) {
|
|
28548
|
+
super(contract2, listener, filter);
|
|
28490
28549
|
defineProperties(this, { log });
|
|
28491
28550
|
}
|
|
28492
28551
|
/**
|
|
@@ -28512,9 +28571,9 @@ var ContractEventPayload = class extends ContractUnknownEventPayload {
|
|
|
28512
28571
|
/**
|
|
28513
28572
|
* @_ignore:
|
|
28514
28573
|
*/
|
|
28515
|
-
constructor(
|
|
28516
|
-
super(
|
|
28517
|
-
const args =
|
|
28574
|
+
constructor(contract2, listener, filter, fragment, _log) {
|
|
28575
|
+
super(contract2, listener, filter, new EventLog(_log, contract2.interface, fragment));
|
|
28576
|
+
const args = contract2.interface.decodeEventLog(fragment, this.log.data, this.log.topics);
|
|
28518
28577
|
defineProperties(this, { args, fragment });
|
|
28519
28578
|
}
|
|
28520
28579
|
/**
|
|
@@ -28559,12 +28618,12 @@ function getResolver(value) {
|
|
|
28559
28618
|
var PreparedTopicFilter = class {
|
|
28560
28619
|
#filter;
|
|
28561
28620
|
fragment;
|
|
28562
|
-
constructor(
|
|
28621
|
+
constructor(contract2, fragment, args) {
|
|
28563
28622
|
defineProperties(this, { fragment });
|
|
28564
28623
|
if (fragment.inputs.length < args.length) {
|
|
28565
28624
|
throw new Error("too many arguments");
|
|
28566
28625
|
}
|
|
28567
|
-
const runner = getRunner(
|
|
28626
|
+
const runner = getRunner(contract2.runner, "resolveName");
|
|
28568
28627
|
const resolver = canResolve(runner) ? runner : null;
|
|
28569
28628
|
this.#filter = (async function() {
|
|
28570
28629
|
const resolvedArgs = await Promise.all(fragment.inputs.map((param, index) => {
|
|
@@ -28582,7 +28641,7 @@ var PreparedTopicFilter = class {
|
|
|
28582
28641
|
return value;
|
|
28583
28642
|
});
|
|
28584
28643
|
}));
|
|
28585
|
-
return
|
|
28644
|
+
return contract2.interface.encodeFilterTopics(fragment, resolvedArgs);
|
|
28586
28645
|
})();
|
|
28587
28646
|
}
|
|
28588
28647
|
getTopicFilter() {
|
|
@@ -28631,14 +28690,14 @@ async function resolveArgs(_runner, inputs, args) {
|
|
|
28631
28690
|
});
|
|
28632
28691
|
}));
|
|
28633
28692
|
}
|
|
28634
|
-
function buildWrappedFallback(
|
|
28693
|
+
function buildWrappedFallback(contract2) {
|
|
28635
28694
|
const populateTransaction = async function(overrides) {
|
|
28636
28695
|
const tx = await copyOverrides(overrides, ["data"]);
|
|
28637
|
-
tx.to = await
|
|
28696
|
+
tx.to = await contract2.getAddress();
|
|
28638
28697
|
if (tx.from) {
|
|
28639
|
-
tx.from = await resolveAddress(tx.from, getResolver(
|
|
28698
|
+
tx.from = await resolveAddress(tx.from, getResolver(contract2.runner));
|
|
28640
28699
|
}
|
|
28641
|
-
const iface =
|
|
28700
|
+
const iface = contract2.interface;
|
|
28642
28701
|
const noValue = getBigInt(tx.value || BN_09, "overrides.value") === BN_09;
|
|
28643
28702
|
const noData = (tx.data || "0x") === "0x";
|
|
28644
28703
|
if (iface.fallback && !iface.fallback.payable && iface.receive && !noData && !noValue) {
|
|
@@ -28651,27 +28710,27 @@ function buildWrappedFallback(contract) {
|
|
|
28651
28710
|
return tx;
|
|
28652
28711
|
};
|
|
28653
28712
|
const staticCall = async function(overrides) {
|
|
28654
|
-
const runner = getRunner(
|
|
28713
|
+
const runner = getRunner(contract2.runner, "call");
|
|
28655
28714
|
assert(canCall(runner), "contract runner does not support calling", "UNSUPPORTED_OPERATION", { operation: "call" });
|
|
28656
28715
|
const tx = await populateTransaction(overrides);
|
|
28657
28716
|
try {
|
|
28658
28717
|
return await runner.call(tx);
|
|
28659
28718
|
} catch (error) {
|
|
28660
28719
|
if (isCallException(error) && error.data) {
|
|
28661
|
-
throw
|
|
28720
|
+
throw contract2.interface.makeError(error.data, tx);
|
|
28662
28721
|
}
|
|
28663
28722
|
throw error;
|
|
28664
28723
|
}
|
|
28665
28724
|
};
|
|
28666
28725
|
const send = async function(overrides) {
|
|
28667
|
-
const runner =
|
|
28726
|
+
const runner = contract2.runner;
|
|
28668
28727
|
assert(canSend(runner), "contract runner does not support sending transactions", "UNSUPPORTED_OPERATION", { operation: "sendTransaction" });
|
|
28669
28728
|
const tx = await runner.sendTransaction(await populateTransaction(overrides));
|
|
28670
|
-
const provider = getProvider(
|
|
28671
|
-
return new ContractTransactionResponse(
|
|
28729
|
+
const provider = getProvider(contract2.runner);
|
|
28730
|
+
return new ContractTransactionResponse(contract2.interface, provider, tx);
|
|
28672
28731
|
};
|
|
28673
28732
|
const estimateGas = async function(overrides) {
|
|
28674
|
-
const runner = getRunner(
|
|
28733
|
+
const runner = getRunner(contract2.runner, "estimateGas");
|
|
28675
28734
|
assert(canEstimate(runner), "contract runner does not support gas estimation", "UNSUPPORTED_OPERATION", { operation: "estimateGas" });
|
|
28676
28735
|
return await runner.estimateGas(await populateTransaction(overrides));
|
|
28677
28736
|
};
|
|
@@ -28679,7 +28738,7 @@ function buildWrappedFallback(contract) {
|
|
|
28679
28738
|
return await send(overrides);
|
|
28680
28739
|
};
|
|
28681
28740
|
defineProperties(method, {
|
|
28682
|
-
_contract:
|
|
28741
|
+
_contract: contract2,
|
|
28683
28742
|
estimateGas,
|
|
28684
28743
|
populateTransaction,
|
|
28685
28744
|
send,
|
|
@@ -28687,9 +28746,9 @@ function buildWrappedFallback(contract) {
|
|
|
28687
28746
|
});
|
|
28688
28747
|
return method;
|
|
28689
28748
|
}
|
|
28690
|
-
function buildWrappedMethod(
|
|
28749
|
+
function buildWrappedMethod(contract2, key) {
|
|
28691
28750
|
const getFragment = function(...args) {
|
|
28692
|
-
const fragment =
|
|
28751
|
+
const fragment = contract2.interface.getFunction(key, args);
|
|
28693
28752
|
assert(fragment, "no matching fragment", "UNSUPPORTED_OPERATION", {
|
|
28694
28753
|
operation: "fragment",
|
|
28695
28754
|
info: { key, args }
|
|
@@ -28702,16 +28761,16 @@ function buildWrappedMethod(contract, key) {
|
|
|
28702
28761
|
if (fragment.inputs.length + 1 === args.length) {
|
|
28703
28762
|
overrides = await copyOverrides(args.pop());
|
|
28704
28763
|
if (overrides.from) {
|
|
28705
|
-
overrides.from = await resolveAddress(overrides.from, getResolver(
|
|
28764
|
+
overrides.from = await resolveAddress(overrides.from, getResolver(contract2.runner));
|
|
28706
28765
|
}
|
|
28707
28766
|
}
|
|
28708
28767
|
if (fragment.inputs.length !== args.length) {
|
|
28709
28768
|
throw new Error("internal error: fragment inputs doesn't match arguments; should not happen");
|
|
28710
28769
|
}
|
|
28711
|
-
const resolvedArgs = await resolveArgs(
|
|
28770
|
+
const resolvedArgs = await resolveArgs(contract2.runner, fragment.inputs, args);
|
|
28712
28771
|
return Object.assign({}, overrides, await resolveProperties({
|
|
28713
|
-
to:
|
|
28714
|
-
data:
|
|
28772
|
+
to: contract2.getAddress(),
|
|
28773
|
+
data: contract2.interface.encodeFunctionData(fragment, resolvedArgs)
|
|
28715
28774
|
}));
|
|
28716
28775
|
};
|
|
28717
28776
|
const staticCall = async function(...args) {
|
|
@@ -28722,19 +28781,19 @@ function buildWrappedMethod(contract, key) {
|
|
|
28722
28781
|
return result;
|
|
28723
28782
|
};
|
|
28724
28783
|
const send = async function(...args) {
|
|
28725
|
-
const runner =
|
|
28784
|
+
const runner = contract2.runner;
|
|
28726
28785
|
assert(canSend(runner), "contract runner does not support sending transactions", "UNSUPPORTED_OPERATION", { operation: "sendTransaction" });
|
|
28727
28786
|
const tx = await runner.sendTransaction(await populateTransaction(...args));
|
|
28728
|
-
const provider = getProvider(
|
|
28729
|
-
return new ContractTransactionResponse(
|
|
28787
|
+
const provider = getProvider(contract2.runner);
|
|
28788
|
+
return new ContractTransactionResponse(contract2.interface, provider, tx);
|
|
28730
28789
|
};
|
|
28731
28790
|
const estimateGas = async function(...args) {
|
|
28732
|
-
const runner = getRunner(
|
|
28791
|
+
const runner = getRunner(contract2.runner, "estimateGas");
|
|
28733
28792
|
assert(canEstimate(runner), "contract runner does not support gas estimation", "UNSUPPORTED_OPERATION", { operation: "estimateGas" });
|
|
28734
28793
|
return await runner.estimateGas(await populateTransaction(...args));
|
|
28735
28794
|
};
|
|
28736
28795
|
const staticCallResult = async function(...args) {
|
|
28737
|
-
const runner = getRunner(
|
|
28796
|
+
const runner = getRunner(contract2.runner, "call");
|
|
28738
28797
|
assert(canCall(runner), "contract runner does not support calling", "UNSUPPORTED_OPERATION", { operation: "call" });
|
|
28739
28798
|
const tx = await populateTransaction(...args);
|
|
28740
28799
|
let result = "0x";
|
|
@@ -28742,12 +28801,12 @@ function buildWrappedMethod(contract, key) {
|
|
|
28742
28801
|
result = await runner.call(tx);
|
|
28743
28802
|
} catch (error) {
|
|
28744
28803
|
if (isCallException(error) && error.data) {
|
|
28745
|
-
throw
|
|
28804
|
+
throw contract2.interface.makeError(error.data, tx);
|
|
28746
28805
|
}
|
|
28747
28806
|
throw error;
|
|
28748
28807
|
}
|
|
28749
28808
|
const fragment = getFragment(...args);
|
|
28750
|
-
return
|
|
28809
|
+
return contract2.interface.decodeFunctionResult(fragment, result);
|
|
28751
28810
|
};
|
|
28752
28811
|
const method = async (...args) => {
|
|
28753
28812
|
const fragment = getFragment(...args);
|
|
@@ -28757,8 +28816,8 @@ function buildWrappedMethod(contract, key) {
|
|
|
28757
28816
|
return await send(...args);
|
|
28758
28817
|
};
|
|
28759
28818
|
defineProperties(method, {
|
|
28760
|
-
name:
|
|
28761
|
-
_contract:
|
|
28819
|
+
name: contract2.interface.getFunctionName(key),
|
|
28820
|
+
_contract: contract2,
|
|
28762
28821
|
_key: key,
|
|
28763
28822
|
getFragment,
|
|
28764
28823
|
estimateGas,
|
|
@@ -28771,7 +28830,7 @@ function buildWrappedMethod(contract, key) {
|
|
|
28771
28830
|
configurable: false,
|
|
28772
28831
|
enumerable: true,
|
|
28773
28832
|
get: () => {
|
|
28774
|
-
const fragment =
|
|
28833
|
+
const fragment = contract2.interface.getFunction(key);
|
|
28775
28834
|
assert(fragment, "no matching fragment", "UNSUPPORTED_OPERATION", {
|
|
28776
28835
|
operation: "fragment",
|
|
28777
28836
|
info: { key }
|
|
@@ -28781,9 +28840,9 @@ function buildWrappedMethod(contract, key) {
|
|
|
28781
28840
|
});
|
|
28782
28841
|
return method;
|
|
28783
28842
|
}
|
|
28784
|
-
function buildWrappedEvent(
|
|
28843
|
+
function buildWrappedEvent(contract2, key) {
|
|
28785
28844
|
const getFragment = function(...args) {
|
|
28786
|
-
const fragment =
|
|
28845
|
+
const fragment = contract2.interface.getEvent(key, args);
|
|
28787
28846
|
assert(fragment, "no matching fragment", "UNSUPPORTED_OPERATION", {
|
|
28788
28847
|
operation: "fragment",
|
|
28789
28848
|
info: { key, args }
|
|
@@ -28791,11 +28850,11 @@ function buildWrappedEvent(contract, key) {
|
|
|
28791
28850
|
return fragment;
|
|
28792
28851
|
};
|
|
28793
28852
|
const method = function(...args) {
|
|
28794
|
-
return new PreparedTopicFilter(
|
|
28853
|
+
return new PreparedTopicFilter(contract2, getFragment(...args), args);
|
|
28795
28854
|
};
|
|
28796
28855
|
defineProperties(method, {
|
|
28797
|
-
name:
|
|
28798
|
-
_contract:
|
|
28856
|
+
name: contract2.interface.getEventName(key),
|
|
28857
|
+
_contract: contract2,
|
|
28799
28858
|
_key: key,
|
|
28800
28859
|
getFragment
|
|
28801
28860
|
});
|
|
@@ -28803,7 +28862,7 @@ function buildWrappedEvent(contract, key) {
|
|
|
28803
28862
|
configurable: false,
|
|
28804
28863
|
enumerable: true,
|
|
28805
28864
|
get: () => {
|
|
28806
|
-
const fragment =
|
|
28865
|
+
const fragment = contract2.interface.getEvent(key);
|
|
28807
28866
|
assert(fragment, "no matching fragment", "UNSUPPORTED_OPERATION", {
|
|
28808
28867
|
operation: "fragment",
|
|
28809
28868
|
info: { key }
|
|
@@ -28815,16 +28874,16 @@ function buildWrappedEvent(contract, key) {
|
|
|
28815
28874
|
}
|
|
28816
28875
|
var internal2 = /* @__PURE__ */ Symbol.for("_ethersInternal_contract");
|
|
28817
28876
|
var internalValues = /* @__PURE__ */ new WeakMap();
|
|
28818
|
-
function setInternal(
|
|
28819
|
-
internalValues.set(
|
|
28877
|
+
function setInternal(contract2, values) {
|
|
28878
|
+
internalValues.set(contract2[internal2], values);
|
|
28820
28879
|
}
|
|
28821
|
-
function getInternal(
|
|
28822
|
-
return internalValues.get(
|
|
28880
|
+
function getInternal(contract2) {
|
|
28881
|
+
return internalValues.get(contract2[internal2]);
|
|
28823
28882
|
}
|
|
28824
28883
|
function isDeferred(value) {
|
|
28825
28884
|
return value && typeof value === "object" && "getTopicFilter" in value && typeof value.getTopicFilter === "function" && value.fragment;
|
|
28826
28885
|
}
|
|
28827
|
-
async function getSubInfo(
|
|
28886
|
+
async function getSubInfo(contract2, event) {
|
|
28828
28887
|
let topics;
|
|
28829
28888
|
let fragment = null;
|
|
28830
28889
|
if (Array.isArray(event)) {
|
|
@@ -28832,7 +28891,7 @@ async function getSubInfo(contract, event) {
|
|
|
28832
28891
|
if (isHexString(name, 32)) {
|
|
28833
28892
|
return name;
|
|
28834
28893
|
}
|
|
28835
|
-
const fragment2 =
|
|
28894
|
+
const fragment2 = contract2.interface.getEvent(name);
|
|
28836
28895
|
assertArgument(fragment2, "unknown fragment", "name", name);
|
|
28837
28896
|
return fragment2.topicHash;
|
|
28838
28897
|
};
|
|
@@ -28851,7 +28910,7 @@ async function getSubInfo(contract, event) {
|
|
|
28851
28910
|
if (isHexString(event, 32)) {
|
|
28852
28911
|
topics = [event];
|
|
28853
28912
|
} else {
|
|
28854
|
-
fragment =
|
|
28913
|
+
fragment = contract2.interface.getEvent(event);
|
|
28855
28914
|
assertArgument(fragment, "unknown fragment", "event", event);
|
|
28856
28915
|
topics = [fragment.topicHash];
|
|
28857
28916
|
}
|
|
@@ -28888,36 +28947,36 @@ async function getSubInfo(contract, event) {
|
|
|
28888
28947
|
}).join("&");
|
|
28889
28948
|
return { fragment, tag, topics };
|
|
28890
28949
|
}
|
|
28891
|
-
async function hasSub(
|
|
28892
|
-
const { subs } = getInternal(
|
|
28893
|
-
return subs.get((await getSubInfo(
|
|
28950
|
+
async function hasSub(contract2, event) {
|
|
28951
|
+
const { subs } = getInternal(contract2);
|
|
28952
|
+
return subs.get((await getSubInfo(contract2, event)).tag) || null;
|
|
28894
28953
|
}
|
|
28895
|
-
async function getSub(
|
|
28896
|
-
const provider = getProvider(
|
|
28954
|
+
async function getSub(contract2, operation, event) {
|
|
28955
|
+
const provider = getProvider(contract2.runner);
|
|
28897
28956
|
assert(provider, "contract runner does not support subscribing", "UNSUPPORTED_OPERATION", { operation });
|
|
28898
|
-
const { fragment, tag, topics } = await getSubInfo(
|
|
28899
|
-
const { addr, subs } = getInternal(
|
|
28957
|
+
const { fragment, tag, topics } = await getSubInfo(contract2, event);
|
|
28958
|
+
const { addr, subs } = getInternal(contract2);
|
|
28900
28959
|
let sub2 = subs.get(tag);
|
|
28901
28960
|
if (!sub2) {
|
|
28902
|
-
const address = addr ? addr :
|
|
28961
|
+
const address = addr ? addr : contract2;
|
|
28903
28962
|
const filter = { address, topics };
|
|
28904
28963
|
const listener = (log) => {
|
|
28905
28964
|
let foundFragment = fragment;
|
|
28906
28965
|
if (foundFragment == null) {
|
|
28907
28966
|
try {
|
|
28908
|
-
foundFragment =
|
|
28967
|
+
foundFragment = contract2.interface.getEvent(log.topics[0]);
|
|
28909
28968
|
} catch (error) {
|
|
28910
28969
|
}
|
|
28911
28970
|
}
|
|
28912
28971
|
if (foundFragment) {
|
|
28913
28972
|
const _foundFragment = foundFragment;
|
|
28914
|
-
const args = fragment ?
|
|
28915
|
-
emit2(
|
|
28916
|
-
return new ContractEventPayload(
|
|
28973
|
+
const args = fragment ? contract2.interface.decodeEventLog(fragment, log.data, log.topics) : [];
|
|
28974
|
+
emit2(contract2, event, args, (listener2) => {
|
|
28975
|
+
return new ContractEventPayload(contract2, listener2, event, _foundFragment, log);
|
|
28917
28976
|
});
|
|
28918
28977
|
} else {
|
|
28919
|
-
emit2(
|
|
28920
|
-
return new ContractUnknownEventPayload(
|
|
28978
|
+
emit2(contract2, event, [], (listener2) => {
|
|
28979
|
+
return new ContractUnknownEventPayload(contract2, listener2, event, log);
|
|
28921
28980
|
});
|
|
28922
28981
|
}
|
|
28923
28982
|
};
|
|
@@ -28943,9 +29002,9 @@ async function getSub(contract, operation, event) {
|
|
|
28943
29002
|
return sub2;
|
|
28944
29003
|
}
|
|
28945
29004
|
var lastEmit = Promise.resolve();
|
|
28946
|
-
async function _emit(
|
|
29005
|
+
async function _emit(contract2, event, args, payloadFunc) {
|
|
28947
29006
|
await lastEmit;
|
|
28948
|
-
const sub2 = await hasSub(
|
|
29007
|
+
const sub2 = await hasSub(contract2, event);
|
|
28949
29008
|
if (!sub2) {
|
|
28950
29009
|
return false;
|
|
28951
29010
|
}
|
|
@@ -28956,23 +29015,23 @@ async function _emit(contract, event, args, payloadFunc) {
|
|
|
28956
29015
|
passArgs.push(payloadFunc(once2 ? null : listener));
|
|
28957
29016
|
}
|
|
28958
29017
|
try {
|
|
28959
|
-
listener.call(
|
|
29018
|
+
listener.call(contract2, ...passArgs);
|
|
28960
29019
|
} catch (error) {
|
|
28961
29020
|
}
|
|
28962
29021
|
return !once2;
|
|
28963
29022
|
});
|
|
28964
29023
|
if (sub2.listeners.length === 0) {
|
|
28965
29024
|
sub2.stop();
|
|
28966
|
-
getInternal(
|
|
29025
|
+
getInternal(contract2).subs.delete(sub2.tag);
|
|
28967
29026
|
}
|
|
28968
29027
|
return count > 0;
|
|
28969
29028
|
}
|
|
28970
|
-
async function emit2(
|
|
29029
|
+
async function emit2(contract2, event, args, payloadFunc) {
|
|
28971
29030
|
try {
|
|
28972
29031
|
await lastEmit;
|
|
28973
29032
|
} catch (error) {
|
|
28974
29033
|
}
|
|
28975
|
-
const resultPromise = _emit(
|
|
29034
|
+
const resultPromise = _emit(contract2, event, args, payloadFunc);
|
|
28976
29035
|
lastEmit = resultPromise;
|
|
28977
29036
|
return await resultPromise;
|
|
28978
29037
|
}
|
|
@@ -29398,8 +29457,8 @@ var BaseContract = class _BaseContract {
|
|
|
29398
29457
|
if (runner == null) {
|
|
29399
29458
|
runner = null;
|
|
29400
29459
|
}
|
|
29401
|
-
const
|
|
29402
|
-
return
|
|
29460
|
+
const contract2 = new this(target, abi, runner);
|
|
29461
|
+
return contract2;
|
|
29403
29462
|
}
|
|
29404
29463
|
};
|
|
29405
29464
|
function _ContractBase() {
|
|
@@ -29700,7 +29759,7 @@ var EnsResolver = class _EnsResolver {
|
|
|
29700
29759
|
return { url: null, linkage };
|
|
29701
29760
|
}
|
|
29702
29761
|
const tokenId = comps[1];
|
|
29703
|
-
const
|
|
29762
|
+
const contract2 = new Contract(comps[0], [
|
|
29704
29763
|
// ERC-721
|
|
29705
29764
|
"function tokenURI(uint) view returns (string)",
|
|
29706
29765
|
"function ownerOf(uint) view returns (address)",
|
|
@@ -29709,21 +29768,21 @@ var EnsResolver = class _EnsResolver {
|
|
|
29709
29768
|
"function balanceOf(address, uint256) view returns (uint)"
|
|
29710
29769
|
], this.provider);
|
|
29711
29770
|
if (scheme === "erc721") {
|
|
29712
|
-
const tokenOwner = await
|
|
29771
|
+
const tokenOwner = await contract2.ownerOf(tokenId);
|
|
29713
29772
|
if (owner !== tokenOwner) {
|
|
29714
29773
|
linkage.push({ type: "!owner", value: tokenOwner });
|
|
29715
29774
|
return { url: null, linkage };
|
|
29716
29775
|
}
|
|
29717
29776
|
linkage.push({ type: "owner", value: tokenOwner });
|
|
29718
29777
|
} else if (scheme === "erc1155") {
|
|
29719
|
-
const balance = await
|
|
29778
|
+
const balance = await contract2.balanceOf(owner, tokenId);
|
|
29720
29779
|
if (!balance) {
|
|
29721
29780
|
linkage.push({ type: "!balance", value: "0" });
|
|
29722
29781
|
return { url: null, linkage };
|
|
29723
29782
|
}
|
|
29724
29783
|
linkage.push({ type: "balance", value: balance.toString() });
|
|
29725
29784
|
}
|
|
29726
|
-
let metadataUrl = await
|
|
29785
|
+
let metadataUrl = await contract2[selector](tokenId);
|
|
29727
29786
|
if (metadataUrl == null || metadataUrl === "0x") {
|
|
29728
29787
|
linkage.push({ type: "!metadata-url", value: "" });
|
|
29729
29788
|
return { url: null, linkage };
|
|
@@ -29795,10 +29854,10 @@ var EnsResolver = class _EnsResolver {
|
|
|
29795
29854
|
static async #getResolver(provider, name) {
|
|
29796
29855
|
const ensAddr = await _EnsResolver.getEnsAddress(provider);
|
|
29797
29856
|
try {
|
|
29798
|
-
const
|
|
29857
|
+
const contract2 = new Contract(ensAddr, [
|
|
29799
29858
|
"function resolver(bytes32) view returns (address)"
|
|
29800
29859
|
], provider);
|
|
29801
|
-
const addr = await
|
|
29860
|
+
const addr = await contract2.resolver(namehash(name), {
|
|
29802
29861
|
enableCcipRead: true
|
|
29803
29862
|
});
|
|
29804
29863
|
if (addr === ZeroAddress) {
|
|
@@ -52395,6 +52454,114 @@ var circuits_default = {
|
|
|
52395
52454
|
template: "JoinSplit",
|
|
52396
52455
|
pubs: ["merkleRoot", "boundParamsHash", "nullifiers", "commitmentsOut"],
|
|
52397
52456
|
params: [5, 2, 16]
|
|
52457
|
+
},
|
|
52458
|
+
joinsplit_1x3_16: {
|
|
52459
|
+
file: "joinsplit",
|
|
52460
|
+
template: "JoinSplit",
|
|
52461
|
+
pubs: ["merkleRoot", "boundParamsHash", "nullifiers", "commitmentsOut"],
|
|
52462
|
+
params: [1, 3, 16]
|
|
52463
|
+
},
|
|
52464
|
+
joinsplit_4x3_16: {
|
|
52465
|
+
file: "joinsplit",
|
|
52466
|
+
template: "JoinSplit",
|
|
52467
|
+
pubs: ["merkleRoot", "boundParamsHash", "nullifiers", "commitmentsOut"],
|
|
52468
|
+
params: [4, 3, 16]
|
|
52469
|
+
},
|
|
52470
|
+
joinsplit_5x3_16: {
|
|
52471
|
+
file: "joinsplit",
|
|
52472
|
+
template: "JoinSplit",
|
|
52473
|
+
pubs: ["merkleRoot", "boundParamsHash", "nullifiers", "commitmentsOut"],
|
|
52474
|
+
params: [5, 3, 16]
|
|
52475
|
+
},
|
|
52476
|
+
joinsplit_6x1_16: {
|
|
52477
|
+
file: "joinsplit",
|
|
52478
|
+
template: "JoinSplit",
|
|
52479
|
+
pubs: ["merkleRoot", "boundParamsHash", "nullifiers", "commitmentsOut"],
|
|
52480
|
+
params: [6, 1, 16]
|
|
52481
|
+
},
|
|
52482
|
+
joinsplit_6x2_16: {
|
|
52483
|
+
file: "joinsplit",
|
|
52484
|
+
template: "JoinSplit",
|
|
52485
|
+
pubs: ["merkleRoot", "boundParamsHash", "nullifiers", "commitmentsOut"],
|
|
52486
|
+
params: [6, 2, 16]
|
|
52487
|
+
},
|
|
52488
|
+
joinsplit_6x3_16: {
|
|
52489
|
+
file: "joinsplit",
|
|
52490
|
+
template: "JoinSplit",
|
|
52491
|
+
pubs: ["merkleRoot", "boundParamsHash", "nullifiers", "commitmentsOut"],
|
|
52492
|
+
params: [6, 3, 16]
|
|
52493
|
+
},
|
|
52494
|
+
joinsplit_7x1_16: {
|
|
52495
|
+
file: "joinsplit",
|
|
52496
|
+
template: "JoinSplit",
|
|
52497
|
+
pubs: ["merkleRoot", "boundParamsHash", "nullifiers", "commitmentsOut"],
|
|
52498
|
+
params: [7, 1, 16]
|
|
52499
|
+
},
|
|
52500
|
+
joinsplit_7x2_16: {
|
|
52501
|
+
file: "joinsplit",
|
|
52502
|
+
template: "JoinSplit",
|
|
52503
|
+
pubs: ["merkleRoot", "boundParamsHash", "nullifiers", "commitmentsOut"],
|
|
52504
|
+
params: [7, 2, 16]
|
|
52505
|
+
},
|
|
52506
|
+
joinsplit_7x3_16: {
|
|
52507
|
+
file: "joinsplit",
|
|
52508
|
+
template: "JoinSplit",
|
|
52509
|
+
pubs: ["merkleRoot", "boundParamsHash", "nullifiers", "commitmentsOut"],
|
|
52510
|
+
params: [7, 3, 16]
|
|
52511
|
+
},
|
|
52512
|
+
joinsplit_8x1_16: {
|
|
52513
|
+
file: "joinsplit",
|
|
52514
|
+
template: "JoinSplit",
|
|
52515
|
+
pubs: ["merkleRoot", "boundParamsHash", "nullifiers", "commitmentsOut"],
|
|
52516
|
+
params: [8, 1, 16]
|
|
52517
|
+
},
|
|
52518
|
+
joinsplit_8x2_16: {
|
|
52519
|
+
file: "joinsplit",
|
|
52520
|
+
template: "JoinSplit",
|
|
52521
|
+
pubs: ["merkleRoot", "boundParamsHash", "nullifiers", "commitmentsOut"],
|
|
52522
|
+
params: [8, 2, 16]
|
|
52523
|
+
},
|
|
52524
|
+
joinsplit_8x3_16: {
|
|
52525
|
+
file: "joinsplit",
|
|
52526
|
+
template: "JoinSplit",
|
|
52527
|
+
pubs: ["merkleRoot", "boundParamsHash", "nullifiers", "commitmentsOut"],
|
|
52528
|
+
params: [8, 3, 16]
|
|
52529
|
+
},
|
|
52530
|
+
joinsplit_9x1_16: {
|
|
52531
|
+
file: "joinsplit",
|
|
52532
|
+
template: "JoinSplit",
|
|
52533
|
+
pubs: ["merkleRoot", "boundParamsHash", "nullifiers", "commitmentsOut"],
|
|
52534
|
+
params: [9, 1, 16]
|
|
52535
|
+
},
|
|
52536
|
+
joinsplit_9x2_16: {
|
|
52537
|
+
file: "joinsplit",
|
|
52538
|
+
template: "JoinSplit",
|
|
52539
|
+
pubs: ["merkleRoot", "boundParamsHash", "nullifiers", "commitmentsOut"],
|
|
52540
|
+
params: [9, 2, 16]
|
|
52541
|
+
},
|
|
52542
|
+
joinsplit_9x3_16: {
|
|
52543
|
+
file: "joinsplit",
|
|
52544
|
+
template: "JoinSplit",
|
|
52545
|
+
pubs: ["merkleRoot", "boundParamsHash", "nullifiers", "commitmentsOut"],
|
|
52546
|
+
params: [9, 3, 16]
|
|
52547
|
+
},
|
|
52548
|
+
joinsplit_10x1_16: {
|
|
52549
|
+
file: "joinsplit",
|
|
52550
|
+
template: "JoinSplit",
|
|
52551
|
+
pubs: ["merkleRoot", "boundParamsHash", "nullifiers", "commitmentsOut"],
|
|
52552
|
+
params: [10, 1, 16]
|
|
52553
|
+
},
|
|
52554
|
+
joinsplit_10x2_16: {
|
|
52555
|
+
file: "joinsplit",
|
|
52556
|
+
template: "JoinSplit",
|
|
52557
|
+
pubs: ["merkleRoot", "boundParamsHash", "nullifiers", "commitmentsOut"],
|
|
52558
|
+
params: [10, 2, 16]
|
|
52559
|
+
},
|
|
52560
|
+
joinsplit_10x3_16: {
|
|
52561
|
+
file: "joinsplit",
|
|
52562
|
+
template: "JoinSplit",
|
|
52563
|
+
pubs: ["merkleRoot", "boundParamsHash", "nullifiers", "commitmentsOut"],
|
|
52564
|
+
params: [10, 3, 16]
|
|
52398
52565
|
}
|
|
52399
52566
|
};
|
|
52400
52567
|
|
|
@@ -52414,7 +52581,7 @@ function getCircuitConfig(inputs, outputs) {
|
|
|
52414
52581
|
}
|
|
52415
52582
|
|
|
52416
52583
|
// prover/prover.ts
|
|
52417
|
-
var MAX_ARTIFACT_CACHE_ENTRIES =
|
|
52584
|
+
var MAX_ARTIFACT_CACHE_ENTRIES = 16;
|
|
52418
52585
|
var artifactCache = /* @__PURE__ */ new Map();
|
|
52419
52586
|
function selectCircuit(inputs, outputs) {
|
|
52420
52587
|
const config2 = getCircuitConfig(inputs, outputs);
|
|
@@ -54416,26 +54583,34 @@ function normalizeCall2(call, index) {
|
|
|
54416
54583
|
value: call.value
|
|
54417
54584
|
};
|
|
54418
54585
|
}
|
|
54419
|
-
function
|
|
54420
|
-
const token = ensureAddress(`
|
|
54586
|
+
function normalizeSpendInput(input, index) {
|
|
54587
|
+
const token = ensureAddress(`spend[${index}].token`, input.token);
|
|
54588
|
+
if (token.toLowerCase() === ETH_TOKEN.toLowerCase()) {
|
|
54589
|
+
throw new AdapterError(
|
|
54590
|
+
`spend[${index}].token: native ETH is not supported in adapter execution`
|
|
54591
|
+
);
|
|
54592
|
+
}
|
|
54421
54593
|
if (input.amount <= 0n) {
|
|
54422
|
-
throw new AdapterError(`
|
|
54594
|
+
throw new AdapterError(`spend[${index}].amount must be greater than zero`);
|
|
54423
54595
|
}
|
|
54424
54596
|
return {
|
|
54425
54597
|
token,
|
|
54426
54598
|
amount: input.amount
|
|
54427
54599
|
};
|
|
54428
54600
|
}
|
|
54429
|
-
function
|
|
54430
|
-
const token = ensureAddress(`
|
|
54431
|
-
if (
|
|
54601
|
+
function normalizeReceiveInput(receive, index) {
|
|
54602
|
+
const token = ensureAddress(`receive[${index}].token`, receive.token);
|
|
54603
|
+
if (token.toLowerCase() === ETH_TOKEN.toLowerCase()) {
|
|
54432
54604
|
throw new AdapterError(
|
|
54433
|
-
`
|
|
54605
|
+
`receive[${index}].token: native ETH is not supported in adapter execution`
|
|
54434
54606
|
);
|
|
54435
54607
|
}
|
|
54608
|
+
if (receive.minAmount < 0n) {
|
|
54609
|
+
throw new AdapterError(`receive[${index}].minAmount must be non-negative`);
|
|
54610
|
+
}
|
|
54436
54611
|
return {
|
|
54437
54612
|
token,
|
|
54438
|
-
minAmount:
|
|
54613
|
+
minAmount: receive.minAmount
|
|
54439
54614
|
};
|
|
54440
54615
|
}
|
|
54441
54616
|
function randomFieldElement(randomBigintFn) {
|
|
@@ -54455,32 +54630,42 @@ function createAdapterService(deps) {
|
|
|
54455
54630
|
"adapterAddress",
|
|
54456
54631
|
params.adapterAddress
|
|
54457
54632
|
);
|
|
54458
|
-
if (!params.
|
|
54459
|
-
throw new AdapterError("at least one
|
|
54633
|
+
if (!params.spend.length) {
|
|
54634
|
+
throw new AdapterError("at least one spend token is required");
|
|
54460
54635
|
}
|
|
54461
54636
|
if (!params.calls.length) {
|
|
54462
54637
|
throw new AdapterError("at least one adapter call is required");
|
|
54463
54638
|
}
|
|
54464
|
-
if (!params.
|
|
54465
|
-
throw new AdapterError("at least one
|
|
54639
|
+
if (!params.receive.length) {
|
|
54640
|
+
throw new AdapterError("at least one receive output is required");
|
|
54466
54641
|
}
|
|
54467
|
-
const
|
|
54468
|
-
(input, i) =>
|
|
54642
|
+
const spendInputs = params.spend.map(
|
|
54643
|
+
(input, i) => normalizeSpendInput(input, i)
|
|
54469
54644
|
);
|
|
54470
54645
|
const seenTokens = /* @__PURE__ */ new Set();
|
|
54471
|
-
for (const input of
|
|
54646
|
+
for (const input of spendInputs) {
|
|
54472
54647
|
const lower = input.token.toLowerCase();
|
|
54473
54648
|
if (seenTokens.has(lower)) {
|
|
54474
54649
|
throw new AdapterError(
|
|
54475
|
-
`duplicate
|
|
54650
|
+
`duplicate spend token ${input.token}; combine amounts per token instead`
|
|
54476
54651
|
);
|
|
54477
54652
|
}
|
|
54478
54653
|
seenTokens.add(lower);
|
|
54479
54654
|
}
|
|
54480
54655
|
const calls = params.calls.map((call, i) => normalizeCall2(call, i));
|
|
54481
|
-
const
|
|
54482
|
-
(
|
|
54656
|
+
const receiveSpecs = params.receive.map(
|
|
54657
|
+
(receive, i) => normalizeReceiveInput(receive, i)
|
|
54483
54658
|
);
|
|
54659
|
+
const seenReceiveTokens = /* @__PURE__ */ new Set();
|
|
54660
|
+
for (const r2 of receiveSpecs) {
|
|
54661
|
+
const lower = r2.token.toLowerCase();
|
|
54662
|
+
if (seenReceiveTokens.has(lower)) {
|
|
54663
|
+
throw new AdapterError(
|
|
54664
|
+
`duplicate receive token ${r2.token}; each receive must target a unique token`
|
|
54665
|
+
);
|
|
54666
|
+
}
|
|
54667
|
+
seenReceiveTokens.add(lower);
|
|
54668
|
+
}
|
|
54484
54669
|
const account = overrides?.account ?? await deps.requireActiveAccount();
|
|
54485
54670
|
const signer = overrides?.signer ?? deps.requireSigner(account);
|
|
54486
54671
|
const nowSeconds = BigInt(Math.floor(nowImpl() / 1e3));
|
|
@@ -54489,19 +54674,19 @@ function createAdapterService(deps) {
|
|
|
54489
54674
|
throw new AdapterError("deadline must be in the future");
|
|
54490
54675
|
}
|
|
54491
54676
|
const executionCalls = calls;
|
|
54492
|
-
const reshields =
|
|
54493
|
-
(
|
|
54677
|
+
const reshields = receiveSpecs.map(
|
|
54678
|
+
(receive) => {
|
|
54494
54679
|
const random = randomFieldElement(randomBigintImpl);
|
|
54495
54680
|
const npk = poseidon([account.masterPublicKey, random]);
|
|
54496
54681
|
return {
|
|
54497
54682
|
npk,
|
|
54498
54683
|
random,
|
|
54499
|
-
token:
|
|
54500
|
-
minAmount:
|
|
54684
|
+
token: receive.token,
|
|
54685
|
+
minAmount: receive.minAmount
|
|
54501
54686
|
};
|
|
54502
54687
|
}
|
|
54503
54688
|
);
|
|
54504
|
-
const inputTokens =
|
|
54689
|
+
const inputTokens = spendInputs.map((input) => input.token);
|
|
54505
54690
|
const nonce = randomFieldElement(randomBigintImpl);
|
|
54506
54691
|
const adapterDataHash = computeAdapterDataHash({
|
|
54507
54692
|
calls: executionCalls,
|
|
@@ -54518,7 +54703,7 @@ function createAdapterService(deps) {
|
|
|
54518
54703
|
});
|
|
54519
54704
|
const withdrawalPlans = planWithdrawalsImpl(
|
|
54520
54705
|
notes,
|
|
54521
|
-
|
|
54706
|
+
spendInputs.map((input) => ({
|
|
54522
54707
|
token: input.token,
|
|
54523
54708
|
amount: input.amount,
|
|
54524
54709
|
recipient: adapterAddress
|
|
@@ -54601,7 +54786,7 @@ function createAdapterService(deps) {
|
|
|
54601
54786
|
adapterCalldata,
|
|
54602
54787
|
historyPreview: {
|
|
54603
54788
|
kind: "Withdraw",
|
|
54604
|
-
amounts:
|
|
54789
|
+
amounts: spendInputs.map((input) => ({
|
|
54605
54790
|
token: input.token,
|
|
54606
54791
|
delta: (-input.amount).toString()
|
|
54607
54792
|
}))
|
|
@@ -54623,6 +54808,9 @@ init_process();
|
|
|
54623
54808
|
init_buffer();
|
|
54624
54809
|
var BIP44_ETH_PREFIX = "m/44'/60'/0'/0";
|
|
54625
54810
|
var ERC20_BALANCE_OF = "function balanceOf(address) view returns (uint256)";
|
|
54811
|
+
function isNativeToken(token) {
|
|
54812
|
+
return token.toLowerCase() === ETH_TOKEN.toLowerCase();
|
|
54813
|
+
}
|
|
54626
54814
|
function createBurnerService(deps) {
|
|
54627
54815
|
const { chainRpcUrl, getMasterSeed, withdrawToAddress, requestDeposit } = deps;
|
|
54628
54816
|
const provider = new JsonRpcProvider(chainRpcUrl);
|
|
@@ -54670,8 +54858,8 @@ function createBurnerService(deps) {
|
|
|
54670
54858
|
}
|
|
54671
54859
|
async function getTokenBalance(address, token) {
|
|
54672
54860
|
const iface = new Interface([ERC20_BALANCE_OF]);
|
|
54673
|
-
const
|
|
54674
|
-
const bal = await
|
|
54861
|
+
const contract2 = new Contract(token, iface, provider);
|
|
54862
|
+
const bal = await contract2.getFunction("balanceOf")(address);
|
|
54675
54863
|
return BigInt(bal ?? 0);
|
|
54676
54864
|
}
|
|
54677
54865
|
async function getBalance(address) {
|
|
@@ -54690,6 +54878,12 @@ function createBurnerService(deps) {
|
|
|
54690
54878
|
}
|
|
54691
54879
|
async function sweepToPool(index, params) {
|
|
54692
54880
|
const { address } = await addressOf(index);
|
|
54881
|
+
const native = isNativeToken(params.token);
|
|
54882
|
+
if (native && params.amount == null) {
|
|
54883
|
+
throw new Error(
|
|
54884
|
+
"amount is required for native ETH sweeps (needed to reserve gas)"
|
|
54885
|
+
);
|
|
54886
|
+
}
|
|
54693
54887
|
const amount = params.amount ?? await getTokenBalance(address, params.token);
|
|
54694
54888
|
if (amount === 0n) {
|
|
54695
54889
|
throw new Error("No token balance to sweep");
|
|
@@ -54700,17 +54894,20 @@ function createBurnerService(deps) {
|
|
|
54700
54894
|
depositor: address,
|
|
54701
54895
|
deposits: [{ token: params.token, amount }]
|
|
54702
54896
|
});
|
|
54703
|
-
|
|
54704
|
-
|
|
54705
|
-
|
|
54706
|
-
|
|
54707
|
-
|
|
54708
|
-
|
|
54709
|
-
|
|
54710
|
-
|
|
54897
|
+
if (!native) {
|
|
54898
|
+
const erc20Iface = new Interface([
|
|
54899
|
+
"function approve(address spender, uint256 amount)"
|
|
54900
|
+
]);
|
|
54901
|
+
const approveData = erc20Iface.encodeFunctionData("approve", [
|
|
54902
|
+
params.poolAddress,
|
|
54903
|
+
amount
|
|
54904
|
+
]);
|
|
54905
|
+
await send(index, { to: params.token, data: approveData });
|
|
54906
|
+
}
|
|
54711
54907
|
const { txHash } = await send(index, {
|
|
54712
54908
|
to: depositResult.to,
|
|
54713
|
-
data: depositResult.calldata
|
|
54909
|
+
data: depositResult.calldata,
|
|
54910
|
+
value: depositResult.value
|
|
54714
54911
|
});
|
|
54715
54912
|
return { txHash };
|
|
54716
54913
|
}
|
|
@@ -55366,28 +55563,31 @@ function createWalletSDK(deps, options) {
|
|
|
55366
55563
|
return sdk;
|
|
55367
55564
|
}
|
|
55368
55565
|
async function createBrowserWalletSDK(options) {
|
|
55566
|
+
let chainId;
|
|
55369
55567
|
let gatewayUrl;
|
|
55370
55568
|
let poolAddress;
|
|
55371
55569
|
let prover = options.prover;
|
|
55372
|
-
if ("
|
|
55570
|
+
if ("chain" in options) {
|
|
55571
|
+
const chainConfig = await fetchChainConfig(options.chain);
|
|
55572
|
+
chainId = chainConfig.chainId;
|
|
55573
|
+
gatewayUrl = chainConfig.gatewayUrl;
|
|
55574
|
+
poolAddress = options.poolAddress ?? chainConfig.poolAddress;
|
|
55575
|
+
prover = {
|
|
55576
|
+
artifactSource: {
|
|
55577
|
+
baseUrl: options.prover?.artifactSource?.baseUrl ?? chainConfig.artifactBaseUrl,
|
|
55578
|
+
version: options.prover?.artifactSource?.version ?? chainConfig.artifactVersion,
|
|
55579
|
+
preferLocalFiles: options.prover?.artifactSource?.preferLocalFiles
|
|
55580
|
+
}
|
|
55581
|
+
};
|
|
55582
|
+
} else {
|
|
55583
|
+
chainId = options.chainId;
|
|
55373
55584
|
gatewayUrl = options.gatewayUrl;
|
|
55374
55585
|
poolAddress = options.poolAddress;
|
|
55375
55586
|
if (typeof window !== "undefined" && !options.prover?.artifactSource?.version) {
|
|
55376
55587
|
throw new InitializationError(
|
|
55377
|
-
"prover.artifactSource.version is required in browser when using explicit gatewayUrl mode. Use
|
|
55588
|
+
"prover.artifactSource.version is required in browser when using explicit gatewayUrl mode. Use chain mode or provide a pinned artifact version."
|
|
55378
55589
|
);
|
|
55379
55590
|
}
|
|
55380
|
-
} else {
|
|
55381
|
-
const envConfig = await fetchEnvironmentConfig(options.environment);
|
|
55382
|
-
gatewayUrl = envConfig.gatewayUrl;
|
|
55383
|
-
poolAddress = options.poolAddress ?? envConfig.poolAddress;
|
|
55384
|
-
prover = {
|
|
55385
|
-
artifactSource: {
|
|
55386
|
-
baseUrl: options.prover?.artifactSource?.baseUrl ?? envConfig.artifactBaseUrl,
|
|
55387
|
-
version: options.prover?.artifactSource?.version ?? envConfig.artifactVersion,
|
|
55388
|
-
preferLocalFiles: options.prover?.artifactSource?.preferLocalFiles
|
|
55389
|
-
}
|
|
55390
|
-
};
|
|
55391
55591
|
}
|
|
55392
55592
|
const storage = createIndexedDbStorage({ name: "unlink-wallet" });
|
|
55393
55593
|
const rng = (n2) => {
|
|
@@ -55404,7 +55604,7 @@ async function createBrowserWalletSDK(options) {
|
|
|
55404
55604
|
core,
|
|
55405
55605
|
fetch: globalThis.fetch
|
|
55406
55606
|
},
|
|
55407
|
-
{ chainId
|
|
55607
|
+
{ chainId, gatewayUrl, prover }
|
|
55408
55608
|
);
|
|
55409
55609
|
return {
|
|
55410
55610
|
sdk,
|
|
@@ -55417,51 +55617,63 @@ async function createBrowserWalletSDK(options) {
|
|
|
55417
55617
|
};
|
|
55418
55618
|
}
|
|
55419
55619
|
|
|
55420
|
-
// wallet/unlink
|
|
55421
|
-
var
|
|
55620
|
+
// wallet/unlink.ts
|
|
55621
|
+
var Unlink = class _Unlink {
|
|
55422
55622
|
/** @internal */
|
|
55423
55623
|
sdk;
|
|
55424
55624
|
/** Chain ID this wallet operates on. */
|
|
55425
55625
|
chainId;
|
|
55426
55626
|
/** Pool contract address this wallet transacts with. */
|
|
55427
55627
|
poolAddress;
|
|
55428
|
-
|
|
55628
|
+
/** Adapter contract address for DeFi operations. */
|
|
55629
|
+
adapterAddress;
|
|
55630
|
+
constructor(sdk, chainId, poolAddress, adapterAddress) {
|
|
55429
55631
|
this.sdk = sdk;
|
|
55430
55632
|
this.chainId = chainId;
|
|
55431
55633
|
this.poolAddress = poolAddress;
|
|
55634
|
+
this.adapterAddress = adapterAddress;
|
|
55635
|
+
this.adapter = {
|
|
55636
|
+
address: adapterAddress
|
|
55637
|
+
};
|
|
55432
55638
|
}
|
|
55433
55639
|
/**
|
|
55434
|
-
* Create a new
|
|
55640
|
+
* Create a new Unlink instance.
|
|
55435
55641
|
*
|
|
55436
55642
|
* Handles all initialization internally:
|
|
55437
|
-
* - Resolves
|
|
55643
|
+
* - Resolves chain config (if using `chain` instead of explicit URLs)
|
|
55438
55644
|
* - Auto-detects storage (IndexedDB in browser) and rng (crypto.getRandomValues)
|
|
55439
55645
|
* - Runs schema migration via `initCore()`
|
|
55440
55646
|
* - Creates the internal SDK
|
|
55441
55647
|
*/
|
|
55442
55648
|
static async create(config2) {
|
|
55649
|
+
let chainId;
|
|
55443
55650
|
let gatewayUrl;
|
|
55444
55651
|
let poolAddress;
|
|
55652
|
+
let adapterAddress;
|
|
55445
55653
|
let proverConfig = config2.prover;
|
|
55446
|
-
if ("
|
|
55654
|
+
if ("chain" in config2) {
|
|
55655
|
+
const chainConfig = await fetchChainConfig(config2.chain);
|
|
55656
|
+
chainId = chainConfig.chainId;
|
|
55657
|
+
gatewayUrl = chainConfig.gatewayUrl;
|
|
55658
|
+
poolAddress = config2.poolAddress ?? chainConfig.poolAddress;
|
|
55659
|
+
adapterAddress = config2.adapterAddress ?? chainConfig.adapterAddress;
|
|
55660
|
+
proverConfig = {
|
|
55661
|
+
artifactSource: {
|
|
55662
|
+
baseUrl: config2.prover?.artifactSource?.baseUrl ?? chainConfig.artifactBaseUrl,
|
|
55663
|
+
version: config2.prover?.artifactSource?.version ?? chainConfig.artifactVersion,
|
|
55664
|
+
preferLocalFiles: config2.prover?.artifactSource?.preferLocalFiles
|
|
55665
|
+
}
|
|
55666
|
+
};
|
|
55667
|
+
} else {
|
|
55668
|
+
chainId = config2.chainId;
|
|
55447
55669
|
gatewayUrl = config2.gatewayUrl;
|
|
55448
55670
|
poolAddress = config2.poolAddress;
|
|
55671
|
+
adapterAddress = config2.adapterAddress;
|
|
55449
55672
|
if (typeof window !== "undefined" && !config2.prover?.artifactSource?.version) {
|
|
55450
55673
|
throw new InitializationError(
|
|
55451
|
-
"prover.artifactSource.version is required in browser when using explicit gatewayUrl mode. Use
|
|
55674
|
+
"prover.artifactSource.version is required in browser when using explicit gatewayUrl mode. Use chain mode or provide a pinned artifact version."
|
|
55452
55675
|
);
|
|
55453
55676
|
}
|
|
55454
|
-
} else {
|
|
55455
|
-
const envConfig = await fetchEnvironmentConfig(config2.environment);
|
|
55456
|
-
gatewayUrl = envConfig.gatewayUrl;
|
|
55457
|
-
poolAddress = config2.poolAddress ?? envConfig.poolAddress;
|
|
55458
|
-
proverConfig = {
|
|
55459
|
-
artifactSource: {
|
|
55460
|
-
baseUrl: config2.prover?.artifactSource?.baseUrl ?? envConfig.artifactBaseUrl,
|
|
55461
|
-
version: config2.prover?.artifactSource?.version ?? envConfig.artifactVersion,
|
|
55462
|
-
preferLocalFiles: config2.prover?.artifactSource?.preferLocalFiles
|
|
55463
|
-
}
|
|
55464
|
-
};
|
|
55465
55677
|
}
|
|
55466
55678
|
const storage = config2.storage ?? detectStorage();
|
|
55467
55679
|
const rng = config2.rng ?? defaultRng;
|
|
@@ -55470,14 +55682,14 @@ var UnlinkWallet = class _UnlinkWallet {
|
|
|
55470
55682
|
const sdk = createWalletSDK(
|
|
55471
55683
|
{ core, fetch: fetchImpl },
|
|
55472
55684
|
{
|
|
55473
|
-
chainId
|
|
55685
|
+
chainId,
|
|
55474
55686
|
gatewayUrl,
|
|
55475
55687
|
chainRpcUrl: config2.chainRpcUrl,
|
|
55476
55688
|
prover: proverConfig,
|
|
55477
55689
|
autoSync: config2.autoSync
|
|
55478
55690
|
}
|
|
55479
55691
|
);
|
|
55480
|
-
return new
|
|
55692
|
+
return new _Unlink(sdk, chainId, poolAddress, adapterAddress ?? "");
|
|
55481
55693
|
}
|
|
55482
55694
|
// ===== Seed Lifecycle =====
|
|
55483
55695
|
/** Seed management (create, import, export, delete mnemonic). */
|
|
@@ -55508,10 +55720,10 @@ var UnlinkWallet = class _UnlinkWallet {
|
|
|
55508
55720
|
return this.sdk.deposit.reconcile(relayId);
|
|
55509
55721
|
}
|
|
55510
55722
|
/**
|
|
55511
|
-
*
|
|
55723
|
+
* Send a private transfer (1 or more recipients).
|
|
55512
55724
|
* Handles note selection, circuit selection, and proof generation automatically.
|
|
55513
55725
|
*/
|
|
55514
|
-
async
|
|
55726
|
+
async send(params, overrides) {
|
|
55515
55727
|
return this.sdk.transfer.send(
|
|
55516
55728
|
{
|
|
55517
55729
|
chainId: this.chainId,
|
|
@@ -55522,9 +55734,9 @@ var UnlinkWallet = class _UnlinkWallet {
|
|
|
55522
55734
|
);
|
|
55523
55735
|
}
|
|
55524
55736
|
/**
|
|
55525
|
-
* Get a
|
|
55737
|
+
* Get a send plan without executing (for preview/confirmation UIs).
|
|
55526
55738
|
*/
|
|
55527
|
-
async
|
|
55739
|
+
async planSend(params, account) {
|
|
55528
55740
|
return this.sdk.transfer.plan(
|
|
55529
55741
|
{
|
|
55530
55742
|
chainId: this.chainId,
|
|
@@ -55534,8 +55746,8 @@ var UnlinkWallet = class _UnlinkWallet {
|
|
|
55534
55746
|
account
|
|
55535
55747
|
);
|
|
55536
55748
|
}
|
|
55537
|
-
/** Execute a pre-built
|
|
55538
|
-
async
|
|
55749
|
+
/** Execute a pre-built send plan. */
|
|
55750
|
+
async executeSend(plans, overrides) {
|
|
55539
55751
|
return this.sdk.transfer.execute(
|
|
55540
55752
|
plans,
|
|
55541
55753
|
{ chainId: this.chainId, poolAddress: this.poolAddress },
|
|
@@ -55684,31 +55896,31 @@ var UnlinkWallet = class _UnlinkWallet {
|
|
|
55684
55896
|
return this.sdk.burner.getBalance(address);
|
|
55685
55897
|
}
|
|
55686
55898
|
};
|
|
55687
|
-
// =====
|
|
55899
|
+
// ===== Interact (Private DeFi) =====
|
|
55688
55900
|
/**
|
|
55689
|
-
*
|
|
55690
|
-
*
|
|
55901
|
+
* Adapter contract address (resolved from config).
|
|
55902
|
+
* Use for building DeFi calls that reference the adapter.
|
|
55691
55903
|
*/
|
|
55692
|
-
adapter
|
|
55693
|
-
|
|
55694
|
-
|
|
55695
|
-
|
|
55696
|
-
|
|
55697
|
-
|
|
55698
|
-
|
|
55699
|
-
|
|
55700
|
-
|
|
55701
|
-
|
|
55702
|
-
|
|
55703
|
-
|
|
55704
|
-
|
|
55705
|
-
|
|
55706
|
-
|
|
55707
|
-
|
|
55708
|
-
|
|
55709
|
-
|
|
55710
|
-
|
|
55711
|
-
}
|
|
55904
|
+
adapter;
|
|
55905
|
+
/**
|
|
55906
|
+
* Execute an atomic unshield -> DeFi call(s) -> reshield flow through an adapter.
|
|
55907
|
+
* chainId/poolAddress/adapterAddress are injected automatically.
|
|
55908
|
+
*/
|
|
55909
|
+
async interact(params, opts, overrides) {
|
|
55910
|
+
return this.sdk.adapter.execute(
|
|
55911
|
+
{
|
|
55912
|
+
chainId: this.chainId,
|
|
55913
|
+
poolAddress: this.poolAddress,
|
|
55914
|
+
adapterAddress: this.adapterAddress,
|
|
55915
|
+
spend: params.spend,
|
|
55916
|
+
calls: params.calls,
|
|
55917
|
+
receive: params.receive,
|
|
55918
|
+
deadline: params.deadline
|
|
55919
|
+
},
|
|
55920
|
+
opts,
|
|
55921
|
+
overrides
|
|
55922
|
+
);
|
|
55923
|
+
}
|
|
55712
55924
|
// ===== Advanced =====
|
|
55713
55925
|
/**
|
|
55714
55926
|
* Advanced escape hatch for raw JoinSplit transaction building.
|
|
@@ -55756,6 +55968,7 @@ var defaultRng = (n2) => {
|
|
|
55756
55968
|
}
|
|
55757
55969
|
return globalThis.crypto.getRandomValues(new Uint8Array(n2));
|
|
55758
55970
|
};
|
|
55971
|
+
var UnlinkWallet = Unlink;
|
|
55759
55972
|
|
|
55760
55973
|
// utils/amounts.ts
|
|
55761
55974
|
init_process();
|
|
@@ -55812,6 +56025,7 @@ export {
|
|
|
55812
56025
|
HttpError,
|
|
55813
56026
|
InitializationError,
|
|
55814
56027
|
ProofError,
|
|
56028
|
+
Unlink,
|
|
55815
56029
|
UnlinkWallet,
|
|
55816
56030
|
ValidationError,
|
|
55817
56031
|
computeBalances,
|