@vultisig/core-chain 1.5.0 → 1.5.2
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/CHANGELOG.md +22 -0
- package/dist/chains/cosmos/cosmosGasLimitRecord.d.ts.map +1 -1
- package/dist/chains/cosmos/cosmosGasLimitRecord.js +7 -1
- package/dist/chains/cosmos/cosmosGasLimitRecord.js.map +1 -1
- package/dist/chains/cosmos/cosmosRpcUrl.js +1 -1
- package/dist/chains/cosmos/cosmosRpcUrl.js.map +1 -1
- package/dist/chains/cosmos/qbtc/claim/broadcastClaimTx.d.ts +15 -1
- package/dist/chains/cosmos/qbtc/claim/broadcastClaimTx.d.ts.map +1 -1
- package/dist/chains/cosmos/qbtc/claim/broadcastClaimTx.js +65 -10
- package/dist/chains/cosmos/qbtc/claim/broadcastClaimTx.js.map +1 -1
- package/dist/chains/cosmos/qbtc/claim/buildClaimTx.d.ts +7 -0
- package/dist/chains/cosmos/qbtc/claim/buildClaimTx.d.ts.map +1 -1
- package/dist/chains/cosmos/qbtc/claim/buildClaimTx.js +3 -2
- package/dist/chains/cosmos/qbtc/claim/buildClaimTx.js.map +1 -1
- package/dist/chains/cosmos/qbtc/claim/getClaimableUtxos.d.ts +6 -4
- package/dist/chains/cosmos/qbtc/claim/getClaimableUtxos.d.ts.map +1 -1
- package/dist/chains/cosmos/qbtc/claim/getClaimableUtxos.js +28 -6
- package/dist/chains/cosmos/qbtc/claim/getClaimableUtxos.js.map +1 -1
- package/dist/chains/cosmos/qbtc/claim/proofService.d.ts +7 -0
- package/dist/chains/cosmos/qbtc/claim/proofService.d.ts.map +1 -1
- package/dist/chains/cosmos/qbtc/claim/proofService.js +3 -0
- package/dist/chains/cosmos/qbtc/claim/proofService.js.map +1 -1
- package/dist/chains/cosmos/tendermintRpcUrl.js +1 -1
- package/dist/chains/cosmos/tendermintRpcUrl.js.map +1 -1
- package/dist/chains/cosmos/thor/lp/pools.d.ts +1 -1
- package/dist/chains/cosmos/thor/lp/pools.d.ts.map +1 -1
- package/dist/chains/cosmos/thor/lp/pools.js +1 -1
- package/dist/chains/cosmos/thor/lp/pools.js.map +1 -1
- package/dist/chains/solana/getDynamicPriorityFeePrice.d.ts +13 -2
- package/dist/chains/solana/getDynamicPriorityFeePrice.d.ts.map +1 -1
- package/dist/chains/solana/getDynamicPriorityFeePrice.js +35 -9
- package/dist/chains/solana/getDynamicPriorityFeePrice.js.map +1 -1
- package/dist/chains/solana/solanaConfig.d.ts +1 -0
- package/dist/chains/solana/solanaConfig.d.ts.map +1 -1
- package/dist/chains/solana/solanaConfig.js +19 -5
- package/dist/chains/solana/solanaConfig.js.map +1 -1
- package/dist/coin/knownTokens/index.d.ts.map +1 -1
- package/dist/coin/knownTokens/index.js +19 -0
- package/dist/coin/knownTokens/index.js.map +1 -1
- package/dist/security/blockaid/tx/simulation/api/core.d.ts +14 -0
- package/dist/security/blockaid/tx/simulation/api/core.d.ts.map +1 -1
- package/dist/security/blockaid/tx/simulation/api/core.js +88 -67
- package/dist/security/blockaid/tx/simulation/api/core.js.map +1 -1
- package/dist/security/blockaid/tx/simulation/core.d.ts +7 -11
- package/dist/security/blockaid/tx/simulation/core.d.ts.map +1 -1
- package/dist/swap/quote/findSwapQuote.d.ts.map +1 -1
- package/dist/swap/quote/findSwapQuote.js +75 -8
- package/dist/swap/quote/findSwapQuote.js.map +1 -1
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,27 @@
|
|
|
1
1
|
# @vultisig/core-chain
|
|
2
2
|
|
|
3
|
+
## 1.5.2
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#356](https://github.com/vultisig/vultisig-sdk/pull/356) [`b97da23`](https://github.com/vultisig/vultisig-sdk/commit/b97da233b3fdaeeb75e3a0c986d7fd15e0d743e4) Thanks [@rcoderdev](https://github.com/rcoderdev)! - Rank swap quotes by comparable destination-token amount across eligible providers instead of using the first successful provider. Native THORChain/Maya quotes are re-based from swap API precision (`getNativeSwapDecimals`) to the destination coin decimals before comparison with aggregator `dstAmount`.
|
|
8
|
+
|
|
9
|
+
- [#383](https://github.com/vultisig/vultisig-sdk/pull/383) [`745172f`](https://github.com/vultisig/vultisig-sdk/commit/745172f3ee511bc4e95914986bfbdb8acf794b1e) Thanks [@Ehsan-saradar](https://github.com/Ehsan-saradar)! - Migrate THORChain Midgard, THORNode REST, and Tendermint RPC endpoints from the legacy `*.thorchain.network` hosts to the Liquify gateway (`gateway.liquify.com/chain/thorchain_midgard`, `…/thorchain_api`, `…/thorchain_rpc`). Updated `cosmosRpcUrl.THORChain`, `tendermintRpcUrl.THORChain`, `thorchainMidgardBaseUrl`, and the rujira `MAINNET_CONFIG` endpoints accordingly.
|
|
10
|
+
|
|
11
|
+
In `RujiraDiscovery.discoverViaChain()`, replaced the brittle `rpc → thornode` string substitution with a direct read of `MAINNET_CONFIG.restEndpoint`. Under the new gateway routing the substitution silently produced an invalid host (`thorchain_thornode`) and the fallback branch was unreachable. Removed the now-unused `rpcEndpoint` option from `DiscoveryOptions` and the corresponding plumbing in `RujiraClient`.
|
|
12
|
+
|
|
13
|
+
## 1.5.1
|
|
14
|
+
|
|
15
|
+
### Patch Changes
|
|
16
|
+
|
|
17
|
+
- [#319](https://github.com/vultisig/vultisig-sdk/pull/319) [`03007d7`](https://github.com/vultisig/vultisig-sdk/commit/03007d7293b2f51f6269d39bf3725715182f933e) Thanks [@rcoderdev](https://github.com/rcoderdev)! - fix(chain): THORChain native swap `streaming_interval` 0 (Rapid Swaps)
|
|
18
|
+
|
|
19
|
+
THORChain can serve swaps in a single block and auto-stream when needed.
|
|
20
|
+
Using `1` forced streaming; `0` lets the protocol choose. MayaChain
|
|
21
|
+
unchanged (`3`).
|
|
22
|
+
|
|
23
|
+
Refs: https://github.com/vultisig/vultisig-windows/issues/3613
|
|
24
|
+
|
|
3
25
|
## 1.5.0
|
|
4
26
|
|
|
5
27
|
### Minor Changes
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cosmosGasLimitRecord.d.ts","sourceRoot":"","sources":["../../../../../../packages/core/chain/chains/cosmos/cosmosGasLimitRecord.ts"],"names":[],"mappings":"AAAA,OAAO,EAAS,WAAW,EAAE,MAAM,4BAA4B,CAAA;AAE/D,OAAO,EAAiB,OAAO,EAAE,MAAM,iBAAiB,CAAA;
|
|
1
|
+
{"version":3,"file":"cosmosGasLimitRecord.d.ts","sourceRoot":"","sources":["../../../../../../packages/core/chain/chains/cosmos/cosmosGasLimitRecord.ts"],"names":[],"mappings":"AAAA,OAAO,EAAS,WAAW,EAAE,MAAM,4BAA4B,CAAA;AAE/D,OAAO,EAAiB,OAAO,EAAE,MAAM,iBAAiB,CAAA;AAqBxD,eAAO,MAAM,iBAAiB,GAAI,MAAM,OAAO,CAAC,WAAW,CAAC,KAAG,MAM9D,CAAA"}
|
|
@@ -8,7 +8,13 @@ const cosmosGasLimitRecord = {
|
|
|
8
8
|
[Chain.Noble]: 200000n,
|
|
9
9
|
[Chain.Akash]: 200000n,
|
|
10
10
|
[Chain.Terra]: 300000n,
|
|
11
|
-
|
|
11
|
+
// TerraClassic default covers both bank.MsgSend (uluna ~80k) and
|
|
12
|
+
// ibc.MsgTransfer (~150-200k), with margin for chain load. uusd
|
|
13
|
+
// (USTC) MsgSend has its own 1M override below for the burn-tax /
|
|
14
|
+
// treasury post-handler path; IBC `MsgTransfer` is exempt from the
|
|
15
|
+
// burn tax (per classic-terra/core fee_tax.go::FilterMsgAndComputeTax)
|
|
16
|
+
// so it falls through to this default.
|
|
17
|
+
[Chain.TerraClassic]: 400000n,
|
|
12
18
|
[Chain.THORChain]: 20000000n,
|
|
13
19
|
[Chain.MayaChain]: 2000000000n,
|
|
14
20
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cosmosGasLimitRecord.js","sourceRoot":"","sources":["../../../../../../packages/core/chain/chains/cosmos/cosmosGasLimitRecord.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAe,MAAM,4BAA4B,CAAA;AAE/D,OAAO,EAAE,aAAa,EAAW,MAAM,iBAAiB,CAAA;AAExD,MAAM,oBAAoB,GAAgC;IACxD,CAAC,KAAK,CAAC,MAAM,CAAC,EAAE,OAAO;IACvB,CAAC,KAAK,CAAC,OAAO,CAAC,EAAE,OAAO;IACxB,CAAC,KAAK,CAAC,MAAM,CAAC,EAAE,OAAO;IACvB,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE,OAAO;IACrB,CAAC,KAAK,CAAC,KAAK,CAAC,EAAE,OAAO;IACtB,CAAC,KAAK,CAAC,KAAK,CAAC,EAAE,OAAO;IACtB,CAAC,KAAK,CAAC,KAAK,CAAC,EAAE,OAAO;IACtB,CAAC,KAAK,CAAC,YAAY,CAAC,EAAE,OAAO;IAC7B,CAAC,KAAK,CAAC,SAAS,CAAC,EAAE,SAAS;IAC5B,CAAC,KAAK,CAAC,SAAS,CAAC,EAAE,WAAW;CAC/B,CAAA;AAED,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC,IAA0B,EAAU,EAAE;IACtE,IAAI,aAAa,CAAC,IAAI,EAAE,EAAE,KAAK,EAAE,KAAK,CAAC,YAAY,EAAE,EAAE,EAAE,MAAM,EAAE,CAAC,EAAE,CAAC;QACnE,OAAO,QAAU,CAAA;IACnB,CAAC;IAED,OAAO,oBAAoB,CAAC,IAAI,CAAC,KAAK,CAAC,CAAA;AACzC,CAAC,CAAA"}
|
|
1
|
+
{"version":3,"file":"cosmosGasLimitRecord.js","sourceRoot":"","sources":["../../../../../../packages/core/chain/chains/cosmos/cosmosGasLimitRecord.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAe,MAAM,4BAA4B,CAAA;AAE/D,OAAO,EAAE,aAAa,EAAW,MAAM,iBAAiB,CAAA;AAExD,MAAM,oBAAoB,GAAgC;IACxD,CAAC,KAAK,CAAC,MAAM,CAAC,EAAE,OAAO;IACvB,CAAC,KAAK,CAAC,OAAO,CAAC,EAAE,OAAO;IACxB,CAAC,KAAK,CAAC,MAAM,CAAC,EAAE,OAAO;IACvB,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE,OAAO;IACrB,CAAC,KAAK,CAAC,KAAK,CAAC,EAAE,OAAO;IACtB,CAAC,KAAK,CAAC,KAAK,CAAC,EAAE,OAAO;IACtB,CAAC,KAAK,CAAC,KAAK,CAAC,EAAE,OAAO;IACtB,iEAAiE;IACjE,gEAAgE;IAChE,kEAAkE;IAClE,mEAAmE;IACnE,uEAAuE;IACvE,uCAAuC;IACvC,CAAC,KAAK,CAAC,YAAY,CAAC,EAAE,OAAO;IAC7B,CAAC,KAAK,CAAC,SAAS,CAAC,EAAE,SAAS;IAC5B,CAAC,KAAK,CAAC,SAAS,CAAC,EAAE,WAAW;CAC/B,CAAA;AAED,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC,IAA0B,EAAU,EAAE;IACtE,IAAI,aAAa,CAAC,IAAI,EAAE,EAAE,KAAK,EAAE,KAAK,CAAC,YAAY,EAAE,EAAE,EAAE,MAAM,EAAE,CAAC,EAAE,CAAC;QACnE,OAAO,QAAU,CAAA;IACnB,CAAC;IAED,OAAO,oBAAoB,CAAC,IAAI,CAAC,KAAK,CAAC,CAAA;AACzC,CAAC,CAAA"}
|
|
@@ -7,7 +7,7 @@ export const cosmosRpcUrl = {
|
|
|
7
7
|
Terra: 'https://terra-lcd.publicnode.com',
|
|
8
8
|
TerraClassic: 'https://terra-classic-lcd.publicnode.com',
|
|
9
9
|
Noble: 'https://noble-api.polkachu.com',
|
|
10
|
-
THORChain: 'https://
|
|
10
|
+
THORChain: 'https://gateway.liquify.com/chain/thorchain_api',
|
|
11
11
|
MayaChain: 'https://mayanode.mayachain.info',
|
|
12
12
|
Akash: 'https://akash-rest.publicnode.com',
|
|
13
13
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cosmosRpcUrl.js","sourceRoot":"","sources":["../../../../../../packages/core/chain/chains/cosmos/cosmosRpcUrl.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,EAAE,MAAM,kCAAkC,CAAA;AAE/D,MAAM,CAAC,MAAM,YAAY,GAAgC;IACvD,MAAM,EAAE,oCAAoC;IAC5C,OAAO,EAAE,qCAAqC;IAC9C,IAAI,EAAE,kCAAkC;IACxC,MAAM,EAAE,oCAAoC;IAC5C,KAAK,EAAE,kCAAkC;IACzC,YAAY,EAAE,0CAA0C;IACxD,KAAK,EAAE,gCAAgC;IACvC,SAAS,EAAE,
|
|
1
|
+
{"version":3,"file":"cosmosRpcUrl.js","sourceRoot":"","sources":["../../../../../../packages/core/chain/chains/cosmos/cosmosRpcUrl.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,EAAE,MAAM,kCAAkC,CAAA;AAE/D,MAAM,CAAC,MAAM,YAAY,GAAgC;IACvD,MAAM,EAAE,oCAAoC;IAC5C,OAAO,EAAE,qCAAqC;IAC9C,IAAI,EAAE,kCAAkC;IACxC,MAAM,EAAE,oCAAoC;IAC5C,KAAK,EAAE,kCAAkC;IACzC,YAAY,EAAE,0CAA0C;IACxD,KAAK,EAAE,gCAAgC;IACvC,SAAS,EAAE,iDAAiD;IAC5D,SAAS,EAAE,iCAAiC;IAC5C,KAAK,EAAE,mCAAmC;CAC3C,CAAA;AAED,MAAM,CAAC,MAAM,4BAA4B,GAAG,CAAC,EAC3C,KAAK,EACL,EAAE,EACF,OAAO,GACqB,EAAE,EAAE,CAChC,GAAG,YAAY,CAAC,KAAK,CAAC,8BAA8B,EAAE,UAAU,YAAY,CAAC,IAAI,CAAC,SAAS,CAAC,EAAE,OAAO,EAAE,EAAE,OAAO,EAAE,EAAE,CAAC,CAAC,EAAE,CAAA"}
|
|
@@ -13,13 +13,27 @@ type BroadcastClaimTxInput = {
|
|
|
13
13
|
txBytesBase64: string;
|
|
14
14
|
/** Transaction hash (SHA256 of TxRaw), hex-encoded. */
|
|
15
15
|
txHash: string;
|
|
16
|
+
/**
|
|
17
|
+
* Max time to wait for the tx to be included in a block after a
|
|
18
|
+
* successful broadcast. Defaults to 30 s — Cosmos block times are
|
|
19
|
+
* typically 5–7 s.
|
|
20
|
+
*/
|
|
21
|
+
inclusionTimeoutMs?: number;
|
|
22
|
+
/** Polling interval while waiting for inclusion. Defaults to 1 s. */
|
|
23
|
+
inclusionPollIntervalMs?: number;
|
|
16
24
|
};
|
|
17
25
|
/**
|
|
18
26
|
* Broadcasts a signed MsgClaimWithProof transaction to the QBTC chain
|
|
19
27
|
* via the REST API (following the restOnlyChains pattern).
|
|
20
28
|
*
|
|
29
|
+
* BROADCAST_MODE_SYNC returns after Tendermint's CheckTx — the
|
|
30
|
+
* `claim_with_proof` event is emitted later in DeliverTx. We poll
|
|
31
|
+
* `/cosmos/tx/v1beta1/txs/{txHash}` until the tx lands and parse the
|
|
32
|
+
* event attributes (`total_amount`, `utxos_claimed`, `utxos_skipped`)
|
|
33
|
+
* so the success screen can show real numbers instead of zeros.
|
|
34
|
+
*
|
|
21
35
|
* The claim transaction is gas-free — the chain does not charge gas.
|
|
22
36
|
*/
|
|
23
|
-
export declare const broadcastClaimTx: ({ txBytesBase64, txHash, }: BroadcastClaimTxInput) => Promise<ClaimTxResponse>;
|
|
37
|
+
export declare const broadcastClaimTx: ({ txBytesBase64, txHash, inclusionTimeoutMs, inclusionPollIntervalMs, }: BroadcastClaimTxInput) => Promise<ClaimTxResponse>;
|
|
24
38
|
export {};
|
|
25
39
|
//# sourceMappingURL=broadcastClaimTx.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"broadcastClaimTx.d.ts","sourceRoot":"","sources":["../../../../../../../../packages/core/chain/chains/cosmos/qbtc/claim/broadcastClaimTx.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"broadcastClaimTx.d.ts","sourceRoot":"","sources":["../../../../../../../../packages/core/chain/chains/cosmos/qbtc/claim/broadcastClaimTx.ts"],"names":[],"mappings":"AAGA,KAAK,eAAe,GAAG;IACrB,8BAA8B;IAC9B,kBAAkB,EAAE,MAAM,CAAA;IAC1B,4CAA4C;IAC5C,YAAY,EAAE,MAAM,CAAA;IACpB,qEAAqE;IACrE,YAAY,EAAE,MAAM,CAAA;IACpB,wBAAwB;IACxB,MAAM,EAAE,MAAM,CAAA;CACf,CAAA;AAED,KAAK,qBAAqB,GAAG;IAC3B,2CAA2C;IAC3C,aAAa,EAAE,MAAM,CAAA;IACrB,uDAAuD;IACvD,MAAM,EAAE,MAAM,CAAA;IACd;;;;OAIG;IACH,kBAAkB,CAAC,EAAE,MAAM,CAAA;IAC3B,qEAAqE;IACrE,uBAAuB,CAAC,EAAE,MAAM,CAAA;CACjC,CAAA;AA0GD;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,gBAAgB,GAAU,yEAKpC,qBAAqB,KAAG,OAAO,CAAC,eAAe,CAmDjD,CAAA"}
|
|
@@ -1,11 +1,59 @@
|
|
|
1
1
|
import { qbtcRestUrl } from '@vultisig/core-chain/chains/cosmos/qbtc/tendermintRpcUrl';
|
|
2
|
+
import { sleep } from '@vultisig/lib-utils/sleep';
|
|
3
|
+
const claimWithProofEventType = 'claim_with_proof';
|
|
4
|
+
const findEventAttr = (events, type, key) => events
|
|
5
|
+
?.find(e => e.type === type)
|
|
6
|
+
?.attributes?.find(a => a.key === key)?.value;
|
|
7
|
+
const parseClaimResultFromEvents = (events, txHash) => ({
|
|
8
|
+
totalAmountClaimed: BigInt(findEventAttr(events, claimWithProofEventType, 'total_amount') ?? '0'),
|
|
9
|
+
utxosClaimed: Number(findEventAttr(events, claimWithProofEventType, 'utxos_claimed') ?? '0'),
|
|
10
|
+
utxosSkipped: Number(findEventAttr(events, claimWithProofEventType, 'utxos_skipped') ?? '0'),
|
|
11
|
+
txHash,
|
|
12
|
+
});
|
|
13
|
+
const idempotentResult = (txHash) => ({
|
|
14
|
+
totalAmountClaimed: 0n,
|
|
15
|
+
utxosClaimed: 0,
|
|
16
|
+
utxosSkipped: 0,
|
|
17
|
+
txHash,
|
|
18
|
+
});
|
|
19
|
+
/**
|
|
20
|
+
* Polls `/cosmos/tx/v1beta1/txs/{txHash}` until the tx is included in a
|
|
21
|
+
* block (200 OK) or the timeout fires. 404 means "not yet included" and
|
|
22
|
+
* triggers a retry. Other non-2xx statuses propagate as errors so we
|
|
23
|
+
* don't mask infra failures as "still pending".
|
|
24
|
+
*/
|
|
25
|
+
const waitForTxInclusion = async ({ txHash, timeoutMs, intervalMs, }) => {
|
|
26
|
+
const url = `${qbtcRestUrl}/cosmos/tx/v1beta1/txs/${txHash}`;
|
|
27
|
+
const deadline = Date.now() + timeoutMs;
|
|
28
|
+
while (Date.now() <= deadline) {
|
|
29
|
+
const response = await fetch(url);
|
|
30
|
+
if (response.ok) {
|
|
31
|
+
const data = await response.json();
|
|
32
|
+
if (data.tx_response)
|
|
33
|
+
return data.tx_response;
|
|
34
|
+
throw new Error(`QBTC claim tx ${txHash}: missing tx_response on inclusion query`);
|
|
35
|
+
}
|
|
36
|
+
if (response.status !== 404) {
|
|
37
|
+
const text = await response.text();
|
|
38
|
+
throw new Error(`QBTC claim inclusion query failed (${response.status}): ${text}`);
|
|
39
|
+
}
|
|
40
|
+
await sleep(intervalMs);
|
|
41
|
+
}
|
|
42
|
+
throw new Error(`QBTC claim tx ${txHash} not included within ${timeoutMs}ms`);
|
|
43
|
+
};
|
|
2
44
|
/**
|
|
3
45
|
* Broadcasts a signed MsgClaimWithProof transaction to the QBTC chain
|
|
4
46
|
* via the REST API (following the restOnlyChains pattern).
|
|
5
47
|
*
|
|
48
|
+
* BROADCAST_MODE_SYNC returns after Tendermint's CheckTx — the
|
|
49
|
+
* `claim_with_proof` event is emitted later in DeliverTx. We poll
|
|
50
|
+
* `/cosmos/tx/v1beta1/txs/{txHash}` until the tx lands and parse the
|
|
51
|
+
* event attributes (`total_amount`, `utxos_claimed`, `utxos_skipped`)
|
|
52
|
+
* so the success screen can show real numbers instead of zeros.
|
|
53
|
+
*
|
|
6
54
|
* The claim transaction is gas-free — the chain does not charge gas.
|
|
7
55
|
*/
|
|
8
|
-
export const broadcastClaimTx = async ({ txBytesBase64, txHash, }) => {
|
|
56
|
+
export const broadcastClaimTx = async ({ txBytesBase64, txHash, inclusionTimeoutMs = 30_000, inclusionPollIntervalMs = 1_000, }) => {
|
|
9
57
|
const response = await fetch(`${qbtcRestUrl}/cosmos/tx/v1beta1/txs`, {
|
|
10
58
|
method: 'POST',
|
|
11
59
|
headers: { 'Content-Type': 'application/json' },
|
|
@@ -14,16 +62,10 @@ export const broadcastClaimTx = async ({ txBytesBase64, txHash, }) => {
|
|
|
14
62
|
mode: 'BROADCAST_MODE_SYNC',
|
|
15
63
|
}),
|
|
16
64
|
});
|
|
17
|
-
const idempotentResult = {
|
|
18
|
-
totalAmountClaimed: 0n,
|
|
19
|
-
utxosClaimed: 0,
|
|
20
|
-
utxosSkipped: 0,
|
|
21
|
-
txHash,
|
|
22
|
-
};
|
|
23
65
|
if (!response.ok) {
|
|
24
66
|
const text = await response.text();
|
|
25
67
|
if (text.includes('tx already exists in cache')) {
|
|
26
|
-
return idempotentResult;
|
|
68
|
+
return idempotentResult(txHash);
|
|
27
69
|
}
|
|
28
70
|
throw new Error(`QBTC claim broadcast failed (${response.status}): ${text}`);
|
|
29
71
|
}
|
|
@@ -34,10 +76,23 @@ export const broadcastClaimTx = async ({ txBytesBase64, txHash, }) => {
|
|
|
34
76
|
if (data.tx_response.code !== 0) {
|
|
35
77
|
const log = data.tx_response.raw_log || data.tx_response.log;
|
|
36
78
|
if (log?.includes('tx already exists in cache')) {
|
|
37
|
-
return idempotentResult;
|
|
79
|
+
return idempotentResult(txHash);
|
|
38
80
|
}
|
|
39
81
|
throw new Error(`QBTC claim tx error: ${log}`);
|
|
40
82
|
}
|
|
41
|
-
|
|
83
|
+
// CheckTx passed; wait for DeliverTx events.
|
|
84
|
+
const included = await waitForTxInclusion({
|
|
85
|
+
txHash,
|
|
86
|
+
timeoutMs: inclusionTimeoutMs,
|
|
87
|
+
intervalMs: inclusionPollIntervalMs,
|
|
88
|
+
});
|
|
89
|
+
if (typeof included.code !== 'number') {
|
|
90
|
+
throw new Error(`QBTC claim tx ${txHash}: missing code on included tx_response`);
|
|
91
|
+
}
|
|
92
|
+
if (included.code !== 0) {
|
|
93
|
+
const log = included.raw_log || included.log;
|
|
94
|
+
throw new Error(`QBTC claim tx error: ${log}`);
|
|
95
|
+
}
|
|
96
|
+
return parseClaimResultFromEvents(included.events, txHash);
|
|
42
97
|
};
|
|
43
98
|
//# sourceMappingURL=broadcastClaimTx.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"broadcastClaimTx.js","sourceRoot":"","sources":["../../../../../../../../packages/core/chain/chains/cosmos/qbtc/claim/broadcastClaimTx.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,0DAA0D,CAAA;
|
|
1
|
+
{"version":3,"file":"broadcastClaimTx.js","sourceRoot":"","sources":["../../../../../../../../packages/core/chain/chains/cosmos/qbtc/claim/broadcastClaimTx.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,0DAA0D,CAAA;AACtF,OAAO,EAAE,KAAK,EAAE,MAAM,2BAA2B,CAAA;AAsDjD,MAAM,uBAAuB,GAAG,kBAAkB,CAAA;AAElD,MAAM,aAAa,GAAG,CACpB,MAA6B,EAC7B,IAAY,EACZ,GAAW,EACS,EAAE,CACtB,MAAM;IACJ,EAAE,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,IAAI,CAAC;IAC5B,EAAE,UAAU,EAAE,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,KAAK,GAAG,CAAC,EAAE,KAAK,CAAA;AAEjD,MAAM,0BAA0B,GAAG,CACjC,MAA6B,EAC7B,MAAc,EACG,EAAE,CAAC,CAAC;IACrB,kBAAkB,EAAE,MAAM,CACxB,aAA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MAAM,GAAG,GAAG,IAAI,CAAC,WAAW,CAAC,OAAO,IAAI,IAAI,CAAC,WAAW,CAAC,GAAG,CAAA;QAC5D,IAAI,GAAG,EAAE,QAAQ,CAAC,4BAA4B,CAAC,EAAE,CAAC;YAChD,OAAO,gBAAgB,CAAC,MAAM,CAAC,CAAA;QACjC,CAAC;QACD,MAAM,IAAI,KAAK,CAAC,wBAAwB,GAAG,EAAE,CAAC,CAAA;IAChD,CAAC;IAED,6CAA6C;IAC7C,MAAM,QAAQ,GAAG,MAAM,kBAAkB,CAAC;QACxC,MAAM;QACN,SAAS,EAAE,kBAAkB;QAC7B,UAAU,EAAE,uBAAuB;KACpC,CAAC,CAAA;IAEF,IAAI,OAAO,QAAQ,CAAC,IAAI,KAAK,QAAQ,EAAE,CAAC;QACtC,MAAM,IAAI,KAAK,CACb,iBAAiB,MAAM,wCAAwC,CAChE,CAAA;IACH,CAAC;IAED,IAAI,QAAQ,CAAC,IAAI,KAAK,CAAC,EAAE,CAAC;QACxB,MAAM,GAAG,GAAG,QAAQ,CAAC,OAAO,IAAI,QAAQ,CAAC,GAAG,CAAA;QAC5C,MAAM,IAAI,KAAK,CAAC,wBAAwB,GAAG,EAAE,CAAC,CAAA;IAChD,CAAC;IAED,OAAO,0BAA0B,CAAC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;AAC5D,CAAC,CAAA"}
|
|
@@ -15,6 +15,13 @@ type BuildMsgClaimWithProofInput = {
|
|
|
15
15
|
addressHash: string;
|
|
16
16
|
/** 64-char hex QBTCAddressHash. */
|
|
17
17
|
qbtcAddressHash: string;
|
|
18
|
+
/**
|
|
19
|
+
* 64-char hex SHA256 of the 33-byte SEC-compressed BTC pubkey. The chain
|
|
20
|
+
* runs RIPEMD160 over this natively to bind the proof to the BTC address
|
|
21
|
+
* (the in-circuit Hash160 was removed in btcq-org/qbtc#148).
|
|
22
|
+
* Returned by the proof service as `pub_key_hash_sha256`.
|
|
23
|
+
*/
|
|
24
|
+
pubKeyHashSha256: string;
|
|
18
25
|
};
|
|
19
26
|
/** Validates the claim input against the chain's constraints (Section 5). */
|
|
20
27
|
export declare const validateClaimInput: (input: BuildMsgClaimWithProofInput) => void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"buildClaimTx.d.ts","sourceRoot":"","sources":["../../../../../../../../packages/core/chain/chains/cosmos/qbtc/claim/buildClaimTx.ts"],"names":[],"mappings":"AASA,KAAK,OAAO,GAAG;IACb,IAAI,EAAE,MAAM,CAAA;IACZ,IAAI,EAAE,MAAM,CAAA;CACb,CAAA;AAED,KAAK,2BAA2B,GAAG;IACjC,0CAA0C;IAC1C,OAAO,EAAE,MAAM,CAAA;IACf,2DAA2D;IAC3D,KAAK,EAAE,OAAO,EAAE,CAAA;IAChB,kCAAkC;IAClC,KAAK,EAAE,MAAM,CAAA;IACb,+BAA+B;IAC/B,WAAW,EAAE,MAAM,CAAA;IACnB,yCAAyC;IACzC,WAAW,EAAE,MAAM,CAAA;IACnB,mCAAmC;IACnC,eAAe,EAAE,MAAM,CAAA;
|
|
1
|
+
{"version":3,"file":"buildClaimTx.d.ts","sourceRoot":"","sources":["../../../../../../../../packages/core/chain/chains/cosmos/qbtc/claim/buildClaimTx.ts"],"names":[],"mappings":"AASA,KAAK,OAAO,GAAG;IACb,IAAI,EAAE,MAAM,CAAA;IACZ,IAAI,EAAE,MAAM,CAAA;CACb,CAAA;AAED,KAAK,2BAA2B,GAAG;IACjC,0CAA0C;IAC1C,OAAO,EAAE,MAAM,CAAA;IACf,2DAA2D;IAC3D,KAAK,EAAE,OAAO,EAAE,CAAA;IAChB,kCAAkC;IAClC,KAAK,EAAE,MAAM,CAAA;IACb,+BAA+B;IAC/B,WAAW,EAAE,MAAM,CAAA;IACnB,yCAAyC;IACzC,WAAW,EAAE,MAAM,CAAA;IACnB,mCAAmC;IACnC,eAAe,EAAE,MAAM,CAAA;IACvB;;;;;OAKG;IACH,gBAAgB,EAAE,MAAM,CAAA;CACzB,CAAA;AAYD,6EAA6E;AAC7E,eAAO,MAAM,kBAAkB,GAAI,OAAO,2BAA2B,SAuCpE,CAAA;AAuBD,uDAAuD;AACvD,eAAO,MAAM,sBAAsB,GACjC,OAAO,2BAA2B,KACjC,UAOF,CAAA;AAED,+DAA+D;AAC/D,eAAO,MAAM,gBAAgB,GAC3B,OAAO,2BAA2B,KACjC,UAGF,CAAA"}
|
|
@@ -8,7 +8,7 @@ const assertHex = (value, name, expectedLength) => {
|
|
|
8
8
|
};
|
|
9
9
|
/** Validates the claim input against the chain's constraints (Section 5). */
|
|
10
10
|
export const validateClaimInput = (input) => {
|
|
11
|
-
const { utxos, proof, messageHash, addressHash, qbtcAddressHash } = input;
|
|
11
|
+
const { utxos, proof, messageHash, addressHash, qbtcAddressHash, pubKeyHashSha256, } = input;
|
|
12
12
|
if (utxos.length === 0 || utxos.length > 50) {
|
|
13
13
|
throw new Error(`UTXOs count must be 1-50, got ${utxos.length}`);
|
|
14
14
|
}
|
|
@@ -35,13 +35,14 @@ export const validateClaimInput = (input) => {
|
|
|
35
35
|
assertHex(messageHash, 'message_hash', 64);
|
|
36
36
|
assertHex(addressHash, 'address_hash', 40);
|
|
37
37
|
assertHex(qbtcAddressHash, 'qbtc_address_hash', 64);
|
|
38
|
+
assertHex(pubKeyHashSha256, 'pub_key_hash_sha256', 64);
|
|
38
39
|
};
|
|
39
40
|
/** Encodes a single UTXORef as protobuf. */
|
|
40
41
|
const encodeUtxoRef = ({ txid, vout }) => concatBytes(protoString(1, txid), protoVarint(2, BigInt(vout)));
|
|
41
42
|
/** Encodes MsgClaimWithProof as protobuf bytes. */
|
|
42
43
|
const buildMsgClaimWithProof = (input) => {
|
|
43
44
|
const utxoBytes = input.utxos.map(utxo => protoBytes(2, encodeUtxoRef(utxo)));
|
|
44
|
-
return concatBytes(protoString(1, input.claimer), ...utxoBytes, protoString(3, input.proof), protoString(4, input.messageHash), protoString(5, input.addressHash), protoString(6, input.qbtcAddressHash));
|
|
45
|
+
return concatBytes(protoString(1, input.claimer), ...utxoBytes, protoString(3, input.proof), protoString(4, input.messageHash), protoString(5, input.addressHash), protoString(6, input.qbtcAddressHash), protoString(7, input.pubKeyHashSha256));
|
|
45
46
|
};
|
|
46
47
|
/** Wraps MsgClaimWithProof in a Cosmos Any message. */
|
|
47
48
|
export const buildClaimWithProofAny = (input) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"buildClaimTx.js","sourceRoot":"","sources":["../../../../../../../../packages/core/chain/chains/cosmos/qbtc/claim/buildClaimTx.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,WAAW,EACX,UAAU,EACV,WAAW,EACX,WAAW,GACZ,MAAM,kDAAkD,CAAA;AAEzD,MAAM,wBAAwB,GAAG,iCAAiC,CAAA;
|
|
1
|
+
{"version":3,"file":"buildClaimTx.js","sourceRoot":"","sources":["../../../../../../../../packages/core/chain/chains/cosmos/qbtc/claim/buildClaimTx.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,WAAW,EACX,UAAU,EACV,WAAW,EACX,WAAW,GACZ,MAAM,kDAAkD,CAAA;AAEzD,MAAM,wBAAwB,GAAG,iCAAiC,CAAA;AA6BlE,MAAM,KAAK,GAAG,CAAC,KAAa,EAAE,EAAE,CAAC,cAAc,CAAC,IAAI,CAAC,KAAK,CAAC,CAAA;AAE3D,MAAM,SAAS,GAAG,CAAC,KAAa,EAAE,IAAY,EAAE,cAAsB,EAAE,EAAE;IACxE,IAAI,KAAK,CAAC,MAAM,KAAK,cAAc,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,EAAE,CAAC;QACrD,MAAM,IAAI,KAAK,CACb,GAAG,IAAI,YAAY,cAAc,mBAAmB,KAAK,CAAC,MAAM,EAAE,CACnE,CAAA;IACH,CAAC;AACH,CAAC,CAAA;AAED,6EAA6E;AAC7E,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,KAAkC,EAAE,EAAE;IACvE,MAAM,EACJ,KAAK,EACL,KAAK,EAC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AAsB,CAAC,KAAK,CAAC,CAAA;IACzC,OAAO,WAAW,CAChB,WAAW,CAAC,CAAC,EAAE,wBAAwB,CAAC,EACxC,UAAU,CAAC,CAAC,EAAE,GAAG,CAAC,CACnB,CAAA;AACH,CAAC,CAAA;AAED,+DAA+D;AAC/D,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAC9B,KAAkC,EACtB,EAAE;IACd,MAAM,MAAM,GAAG,sBAAsB,CAAC,KAAK,CAAC,CAAA;IAC5C,OAAO,UAAU,CAAC,CAAC,EAAE,MAAM,CAAC,CAAA;AAC9B,CAAC,CAAA"}
|
|
@@ -3,11 +3,13 @@ type GetClaimableUtxosInput = {
|
|
|
3
3
|
btcAddress: string;
|
|
4
4
|
};
|
|
5
5
|
/**
|
|
6
|
-
* Fetches Bitcoin UTXOs for the given address via Blockchair and
|
|
7
|
-
*
|
|
6
|
+
* Fetches Bitcoin UTXOs for the given address via Blockchair and filters
|
|
7
|
+
* out any the QBTC chain has already paid out.
|
|
8
8
|
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
9
|
+
* Bitcoin doesn't know about QBTC claims, so a Blockchair UTXO can still
|
|
10
|
+
* appear "spendable" after the QBTC chain has consumed it. Cross-checking
|
|
11
|
+
* against the chain's UTXO endpoint (btcq-org/qbtc#141) prevents the user
|
|
12
|
+
* from selecting a stale entry and burning ~90s on a no-op claim.
|
|
11
13
|
*/
|
|
12
14
|
export declare const getClaimableUtxos: ({ btcAddress, }: GetClaimableUtxosInput) => Promise<ClaimableUtxo[]>;
|
|
13
15
|
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getClaimableUtxos.d.ts","sourceRoot":"","sources":["../../../../../../../../packages/core/chain/chains/cosmos/qbtc/claim/getClaimableUtxos.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"getClaimableUtxos.d.ts","sourceRoot":"","sources":["../../../../../../../../packages/core/chain/chains/cosmos/qbtc/claim/getClaimableUtxos.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAA;AAE/C,KAAK,sBAAsB,GAAG;IAC5B,UAAU,EAAE,MAAM,CAAA;CACnB,CAAA;AA0BD;;;;;;;;GAQG;AACH,eAAO,MAAM,iBAAiB,GAAU,iBAErC,sBAAsB,KAAG,OAAO,CAAC,aAAa,EAAE,CAqBlD,CAAA"}
|
|
@@ -1,22 +1,44 @@
|
|
|
1
1
|
import { Chain } from '@vultisig/core-chain/Chain';
|
|
2
|
+
import { qbtcRestUrl } from '@vultisig/core-chain/chains/cosmos/qbtc/tendermintRpcUrl';
|
|
2
3
|
import { getUtxoAddressInfo } from '@vultisig/core-chain/chains/utxo/client/getUtxoAddressInfo';
|
|
3
4
|
/**
|
|
4
|
-
*
|
|
5
|
-
*
|
|
5
|
+
* Asks the QBTC chain whether a given UTXO is still claimable
|
|
6
|
+
* (i.e. registered + unclaimed) via `GET /qbtc/v1/utxo/{txid}/{vout}`.
|
|
6
7
|
*
|
|
7
|
-
*
|
|
8
|
-
* already
|
|
8
|
+
* - 200 → claimable
|
|
9
|
+
* - 404 → already claimed or never registered
|
|
10
|
+
* - other → propagated as a hard error so transient network failures
|
|
11
|
+
* don't silently drop UTXOs from the user's list.
|
|
12
|
+
*/
|
|
13
|
+
const isUtxoClaimableOnChain = async ({ txid, vout, }) => {
|
|
14
|
+
const response = await fetch(`${qbtcRestUrl}/qbtc/v1/utxo/${txid}/${vout}`);
|
|
15
|
+
if (response.ok)
|
|
16
|
+
return true;
|
|
17
|
+
if (response.status === 404)
|
|
18
|
+
return false;
|
|
19
|
+
throw new Error(`Failed to verify UTXO ${txid}:${vout} on QBTC chain (${response.status} ${response.statusText})`);
|
|
20
|
+
};
|
|
21
|
+
/**
|
|
22
|
+
* Fetches Bitcoin UTXOs for the given address via Blockchair and filters
|
|
23
|
+
* out any the QBTC chain has already paid out.
|
|
24
|
+
*
|
|
25
|
+
* Bitcoin doesn't know about QBTC claims, so a Blockchair UTXO can still
|
|
26
|
+
* appear "spendable" after the QBTC chain has consumed it. Cross-checking
|
|
27
|
+
* against the chain's UTXO endpoint (btcq-org/qbtc#141) prevents the user
|
|
28
|
+
* from selecting a stale entry and burning ~90s on a no-op claim.
|
|
9
29
|
*/
|
|
10
30
|
export const getClaimableUtxos = async ({ btcAddress, }) => {
|
|
11
31
|
const response = await getUtxoAddressInfo({
|
|
12
32
|
address: btcAddress,
|
|
13
33
|
chain: Chain.Bitcoin,
|
|
14
34
|
});
|
|
15
|
-
const
|
|
16
|
-
|
|
35
|
+
const btcUtxos = response.data[btcAddress]?.utxo ?? [];
|
|
36
|
+
const candidates = btcUtxos.map(({ transaction_hash, index, value }) => ({
|
|
17
37
|
txid: transaction_hash,
|
|
18
38
|
vout: index,
|
|
19
39
|
amount: value,
|
|
20
40
|
}));
|
|
41
|
+
const claimableFlags = await Promise.all(candidates.map(({ txid, vout }) => isUtxoClaimableOnChain({ txid, vout })));
|
|
42
|
+
return candidates.filter((_, i) => claimableFlags[i]);
|
|
21
43
|
};
|
|
22
44
|
//# sourceMappingURL=getClaimableUtxos.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getClaimableUtxos.js","sourceRoot":"","sources":["../../../../../../../../packages/core/chain/chains/cosmos/qbtc/claim/getClaimableUtxos.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,4BAA4B,CAAA;AAClD,OAAO,EAAE,kBAAkB,EAAE,MAAM,4DAA4D,CAAA;AAQ/F
|
|
1
|
+
{"version":3,"file":"getClaimableUtxos.js","sourceRoot":"","sources":["../../../../../../../../packages/core/chain/chains/cosmos/qbtc/claim/getClaimableUtxos.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,4BAA4B,CAAA;AAClD,OAAO,EAAE,WAAW,EAAE,MAAM,0DAA0D,CAAA;AACtF,OAAO,EAAE,kBAAkB,EAAE,MAAM,4DAA4D,CAAA;AAQ/F;;;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C,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC,CAAA;AACvD,CAAC,CAAA"}
|
|
@@ -33,6 +33,13 @@ type GenerateClaimProofResponse = {
|
|
|
33
33
|
address_hash: string;
|
|
34
34
|
/** 64-char hex QBTCAddressHash. */
|
|
35
35
|
qbtc_address_hash: string;
|
|
36
|
+
/**
|
|
37
|
+
* 64-char hex SHA256 of the SEC-compressed BTC pubkey. Required by
|
|
38
|
+
* `MsgClaimWithProof` (proto field 7) since btcq-org/qbtc#148 — the
|
|
39
|
+
* chain runs RIPEMD160 over this natively to bind the proof to the
|
|
40
|
+
* BTC address.
|
|
41
|
+
*/
|
|
42
|
+
pub_key_hash_sha256: string;
|
|
36
43
|
/** UTXOs included in the proof. */
|
|
37
44
|
utxos: UtxoRef[];
|
|
38
45
|
/** QBTC claimer address. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"proofService.d.ts","sourceRoot":"","sources":["../../../../../../../../packages/core/chain/chains/cosmos/qbtc/claim/proofService.ts"],"names":[],"mappings":"AAAA,2CAA2C;AAC3C,eAAO,MAAM,sBAAsB,+BAA+B,CAAA;AASlE,6DAA6D;AAC7D,eAAO,MAAM,uBAAuB,GAAU,eAE3C;IAAE,OAAO,CAAC,EAAE,MAAM,CAAA;CAAO,KAAG,OAAO,CAAC,OAAO,CAS7C,CAAA;AAED,KAAK,OAAO,GAAG;IACb,IAAI,EAAE,MAAM,CAAA;IACZ,IAAI,EAAE,MAAM,CAAA;CACb,CAAA;AAED,KAAK,uBAAuB,GAAG;IAC7B,uDAAuD;IACvD,UAAU,EAAE,MAAM,CAAA;IAClB,uDAAuD;IACvD,UAAU,EAAE,MAAM,CAAA;IAClB,4DAA4D;IAC5D,SAAS,EAAE,MAAM,CAAA;IACjB,qCAAqC;IACrC,KAAK,EAAE,OAAO,EAAE,CAAA;IAChB,0CAA0C;IAC1C,cAAc,EAAE,MAAM,CAAA;IACtB,sCAAsC;IACtC,OAAO,EAAE,MAAM,CAAA;IACf,0EAA0E;IAC1E,OAAO,CAAC,EAAE,MAAM,CAAA;CACjB,CAAA;AAED,KAAK,0BAA0B,GAAG;IAChC,kCAAkC;IAClC,KAAK,EAAE,MAAM,CAAA;IACb,+BAA+B;IAC/B,YAAY,EAAE,MAAM,CAAA;IACpB,yCAAyC;IACzC,YAAY,EAAE,MAAM,CAAA;IACpB,mCAAmC;IACnC,iBAAiB,EAAE,MAAM,CAAA;IACzB,mCAAmC;IACnC,KAAK,EAAE,OAAO,EAAE,CAAA;IAChB,4BAA4B;IAC5B,eAAe,EAAE,MAAM,CAAA;CACxB,CAAA;AAED,YAAY,EAAE,0BAA0B,IAAI,gBAAgB,EAAE,CAAA;
|
|
1
|
+
{"version":3,"file":"proofService.d.ts","sourceRoot":"","sources":["../../../../../../../../packages/core/chain/chains/cosmos/qbtc/claim/proofService.ts"],"names":[],"mappings":"AAAA,2CAA2C;AAC3C,eAAO,MAAM,sBAAsB,+BAA+B,CAAA;AASlE,6DAA6D;AAC7D,eAAO,MAAM,uBAAuB,GAAU,eAE3C;IAAE,OAAO,CAAC,EAAE,MAAM,CAAA;CAAO,KAAG,OAAO,CAAC,OAAO,CAS7C,CAAA;AAED,KAAK,OAAO,GAAG;IACb,IAAI,EAAE,MAAM,CAAA;IACZ,IAAI,EAAE,MAAM,CAAA;CACb,CAAA;AAED,KAAK,uBAAuB,GAAG;IAC7B,uDAAuD;IACvD,UAAU,EAAE,MAAM,CAAA;IAClB,uDAAuD;IACvD,UAAU,EAAE,MAAM,CAAA;IAClB,4DAA4D;IAC5D,SAAS,EAAE,MAAM,CAAA;IACjB,qCAAqC;IACrC,KAAK,EAAE,OAAO,EAAE,CAAA;IAChB,0CAA0C;IAC1C,cAAc,EAAE,MAAM,CAAA;IACtB,sCAAsC;IACtC,OAAO,EAAE,MAAM,CAAA;IACf,0EAA0E;IAC1E,OAAO,CAAC,EAAE,MAAM,CAAA;CACjB,CAAA;AAED,KAAK,0BAA0B,GAAG;IAChC,kCAAkC;IAClC,KAAK,EAAE,MAAM,CAAA;IACb,+BAA+B;IAC/B,YAAY,EAAE,MAAM,CAAA;IACpB,yCAAyC;IACzC,YAAY,EAAE,MAAM,CAAA;IACpB,mCAAmC;IACnC,iBAAiB,EAAE,MAAM,CAAA;IACzB;;;;;OAKG;IACH,mBAAmB,EAAE,MAAM,CAAA;IAC3B,mCAAmC;IACnC,KAAK,EAAE,OAAO,EAAE,CAAA;IAChB,4BAA4B;IAC5B,eAAe,EAAE,MAAM,CAAA;CACxB,CAAA;AAED,YAAY,EAAE,0BAA0B,IAAI,gBAAgB,EAAE,CAAA;AAgC9D;;;;;;GAMG;AACH,eAAO,MAAM,kBAAkB,GAAU,iFAQtC,uBAAuB,KAAG,OAAO,CAAC,0BAA0B,CAiC9D,CAAA"}
|
|
@@ -31,6 +31,9 @@ const assertValidClaimProofResponse = (data) => {
|
|
|
31
31
|
if (!isHexWithLength(data.qbtc_address_hash, 64)) {
|
|
32
32
|
throw new Error('Invalid proof service response: invalid qbtc_address_hash');
|
|
33
33
|
}
|
|
34
|
+
if (!isHexWithLength(data.pub_key_hash_sha256, 64)) {
|
|
35
|
+
throw new Error('Invalid proof service response: invalid pub_key_hash_sha256');
|
|
36
|
+
}
|
|
34
37
|
};
|
|
35
38
|
/**
|
|
36
39
|
* Calls the proof service to generate a PLONK ZK proof for the QBTC claim.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"proofService.js","sourceRoot":"","sources":["../../../../../../../../packages/core/chain/chains/cosmos/qbtc/claim/proofService.ts"],"names":[],"mappings":"AAAA,2CAA2C;AAC3C,MAAM,CAAC,MAAM,sBAAsB,GAAG,4BAA4B,CAAA;AAElE,MAAM,wBAAwB,GAAG,OAAO,CAAA;AAOxC,6DAA6D;AAC7D,MAAM,CAAC,MAAM,uBAAuB,GAAG,KAAK,EAAE,EAC5C,OAAO,GAAG,sBAAsB,MACR,EAAE,EAAoB,EAAE;IAChD,IAAI,CAAC;QACH,MAAM,QAAQ,GAAG,MAAM,KAAK,CAAC,GAAG,OAAO,SAAS,CAAC,CAAA;QACjD,IAAI,CAAC,QAAQ,CAAC,EAAE;YAAE,OAAO,KAAK,CAAA;QAC9B,MAAM,IAAI,GAA+B,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAA;QAC9D,OAAO,IAAI,CAAC,MAAM,KAAK,SAAS,IAAI,IAAI,CAAC,YAAY,KAAK,IAAI,CAAA;IAChE,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,KAAK,CAAA;IACd,CAAC;AACH,CAAC,CAAA;
|
|
1
|
+
{"version":3,"file":"proofService.js","sourceRoot":"","sources":["../../../../../../../../packages/core/chain/chains/cosmos/qbtc/claim/proofService.ts"],"names":[],"mappings":"AAAA,2CAA2C;AAC3C,MAAM,CAAC,MAAM,sBAAsB,GAAG,4BAA4B,CAAA;AAElE,MAAM,wBAAwB,GAAG,OAAO,CAAA;AAOxC,6DAA6D;AAC7D,MAAM,CAAC,MAAM,uBAAuB,GAAG,KAAK,EAAE,EAC5C,OAAO,GAAG,sBAAsB,MACR,EAAE,EAAoB,EAAE;IAChD,IAAI,CAAC;QACH,MAAM,QAAQ,GAAG,MAAM,KAAK,CAAC,GAAG,OAAO,SAAS,CAAC,CAAA;QACjD,IAAI,CAAC,QAAQ,CAAC,EAAE;YAAE,OAAO,KAAK,CAAA;QAC9B,MAAM,IAAI,GAA+B,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAA;QAC9D,OAAO,IAAI,CAAC,MAAM,KAAK,SAAS,IAAI,IAAI,CAAC,YAAY,KAAK,IAAI,CAAA;IAChE,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,KAAK,CAAA;IACd,CAAC;AACH,CAAC,CAAA;AAgDD,MAAM,eAAe,GAAG,CAAC,KAAc,EAAE,MAAc,EAAmB,EAAE,CAC1E,OAAO,KAAK,KAAK,QAAQ;IACzB,KAAK,CAAC,MAAM,KAAK,MAAM;IACv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AG,MAAM,KAAK,CAAC,GAAG,OAAO,QAAQ,EAAE;YAC/C,MAAM,EAAE,MAAM;YACd,OAAO,EAAE,EAAE,cAAc,EAAE,kBAAkB,EAAE;YAC/C,MAAM,EAAE,UAAU,CAAC,MAAM;YACzB,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC;gBACnB,WAAW,EAAE,UAAU;gBACvB,WAAW,EAAE,UAAU;gBACvB,UAAU,EAAE,SAAS;gBACrB,KAAK,EAAE,KAAK,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,EAAE,EAAE,CAAC,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC;gBACtD,eAAe,EAAE,cAAc;gBAC/B,QAAQ,EAAE,OAAO;aAClB,CAAC;SACH,CAAC,CAAA;QAEF,IAAI,CAAC,QAAQ,CAAC,EAAE,EAAE,CAAC;YACjB,MAAM,IAAI,GAAG,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAA;YAClC,MAAM,IAAI,KAAK,CAAC,wBAAwB,QAAQ,CAAC,MAAM,MAAM,IAAI,EAAE,CAAC,CAAA;QACtE,CAAC;QAED,MAAM,IAAI,GAA+B,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAA;QAC9D,6BAA6B,CAAC,IAAI,CAAC,CAAA;QACnC,OAAO,IAAI,CAAA;IACb,CAAC;YAAS,CAAC;QACT,YAAY,CAAC,OAAO,CAAC,CAAA;IACvB,CAAC;AACH,CAAC,CAAA"}
|
|
@@ -6,7 +6,7 @@ export const tendermintRpcUrl = {
|
|
|
6
6
|
Terra: 'https://terra-rpc.publicnode.com:443',
|
|
7
7
|
TerraClassic: 'https://terra-classic-rpc.publicnode.com:443',
|
|
8
8
|
Noble: 'https://noble-rpc.polkachu.com/',
|
|
9
|
-
THORChain: 'https://
|
|
9
|
+
THORChain: 'https://gateway.liquify.com/chain/thorchain_rpc',
|
|
10
10
|
MayaChain: 'https://tendermint.mayachain.info',
|
|
11
11
|
Akash: 'https://akash-rpc.publicnode.com:443',
|
|
12
12
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tendermintRpcUrl.js","sourceRoot":"","sources":["../../../../../../packages/core/chain/chains/cosmos/tendermintRpcUrl.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,gBAAgB,GAAgC;IAC3D,MAAM,EAAE,uCAAuC;IAC/C,OAAO,EAAE,wCAAwC;IACjD,IAAI,EAAE,qCAAqC;IAC3C,MAAM,EAAE,uCAAuC;IAC/C,KAAK,EAAE,sCAAsC;IAC7C,YAAY,EAAE,8CAA8C;IAC5D,KAAK,EAAE,iCAAiC;IACxC,SAAS,EAAE
|
|
1
|
+
{"version":3,"file":"tendermintRpcUrl.js","sourceRoot":"","sources":["../../../../../../packages/core/chain/chains/cosmos/tendermintRpcUrl.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,gBAAgB,GAAgC;IAC3D,MAAM,EAAE,uCAAuC;IAC/C,OAAO,EAAE,wCAAwC;IACjD,IAAI,EAAE,qCAAqC;IAC3C,MAAM,EAAE,uCAAuC;IAC/C,KAAK,EAAE,sCAAsC;IAC7C,YAAY,EAAE,8CAA8C;IAC5D,KAAK,EAAE,iCAAiC;IACxC,SAAS,EAAE,iDAAiD;IAC5D,SAAS,EAAE,mCAAmC;IAC9C,KAAK,EAAE,sCAAsC;CAC9C,CAAA"}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* Midgard base URL used by every helper in this module. Matches what
|
|
3
3
|
* vultisig-ios and the rujira package use as the default mainnet endpoint.
|
|
4
4
|
*/
|
|
5
|
-
export declare const thorchainMidgardBaseUrl = "https://
|
|
5
|
+
export declare const thorchainMidgardBaseUrl = "https://gateway.liquify.com/chain/thorchain_midgard";
|
|
6
6
|
/**
|
|
7
7
|
* Validate a THORChain pool id is in the canonical format.
|
|
8
8
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pools.d.ts","sourceRoot":"","sources":["../../../../../../../../packages/core/chain/chains/cosmos/thor/lp/pools.ts"],"names":[],"mappings":"AAEA;;;GAGG;AACH,eAAO,MAAM,uBAAuB,
|
|
1
|
+
{"version":3,"file":"pools.d.ts","sourceRoot":"","sources":["../../../../../../../../packages/core/chain/chains/cosmos/thor/lp/pools.ts"],"names":[],"mappings":"AAEA;;;GAGG;AACH,eAAO,MAAM,uBAAuB,wDAAwD,CAAA;AA2B5F;;;;;;;;GAQG;AACH,eAAO,MAAM,iBAAiB,GAAI,MAAM,MAAM,KAAG,IAahD,CAAA;AAED;;;GAGG;AACH,eAAO,MAAM,aAAa,GAAI,MAAM,MAAM,KAAG,OAG5C,CAAA;AAED;;;;GAIG;AACH,MAAM,MAAM,oBAAoB,GAAG;IACjC,KAAK,EAAE,MAAM,CAAA;IACb,MAAM,EAAE,MAAM,CAAA;IACd,UAAU,EAAE,MAAM,CAAA;IAClB,SAAS,EAAE,MAAM,CAAA;IACjB,cAAc,EAAE,MAAM,CAAA;IACtB,SAAS,EAAE,MAAM,CAAA;IACjB,oBAAoB,EAAE,MAAM,CAAA;CAC7B,CAAA;AAsBD,MAAM,MAAM,wBAAwB,GAAG;IACrC,iEAAiE;IACjE,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;CACvB,CAAA;AAED;;;;;GAKG;AACH,eAAO,MAAM,iBAAiB,GAC5B,UAAS,wBAA6B,KACrC,OAAO,CAAC,oBAAoB,EAAE,CAahC,CAAA"}
|
|
@@ -3,7 +3,7 @@ import { queryUrl } from '@vultisig/lib-utils/query/queryUrl';
|
|
|
3
3
|
* Midgard base URL used by every helper in this module. Matches what
|
|
4
4
|
* vultisig-ios and the rujira package use as the default mainnet endpoint.
|
|
5
5
|
*/
|
|
6
|
-
export const thorchainMidgardBaseUrl = 'https://
|
|
6
|
+
export const thorchainMidgardBaseUrl = 'https://gateway.liquify.com/chain/thorchain_midgard';
|
|
7
7
|
/**
|
|
8
8
|
* Canonical THORChain pool-id format: `CHAIN.ASSET` for native assets
|
|
9
9
|
* (e.g. `BTC.BTC`, `ETH.ETH`) or `CHAIN.ASSET-CONTRACT` for ERC-20-style
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pools.js","sourceRoot":"","sources":["../../../../../../../../packages/core/chain/chains/cosmos/thor/lp/pools.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,oCAAoC,CAAA;AAE7D;;;GAGG;AACH,MAAM,CAAC,MAAM,uBAAuB,GAAG,
|
|
1
|
+
{"version":3,"file":"pools.js","sourceRoot":"","sources":["../../../../../../../../packages/core/chain/chains/cosmos/thor/lp/pools.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,oCAAoC,CAAA;AAE7D;;;GAGG;AACH,MAAM,CAAC,MAAM,uBAAuB,GAAG,qDAAqD,CAAA;AAE5F;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,MAAM,UAAU,GAAG,qCAAqC,CAAA;AAExD;;;;;;;;GAQG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC,IAAY,EAAQ,EAAE;IACtD,IAAI,OAAO,IAAI,KAAK,QAAQ,IAAI,IAAI,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAClD,MAAM,IAAI,KAAK,CACb,8DAA8D,OAAO,IAAI,IAAI,IAAI,KAAK,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CACvG,CAAA;IACH,CAAC;IACD,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;QAC3B,MAAM,IAAI,KAAK,CACb,sBAAsB,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,qCAAqC;YAC7E,0EAA0E;YAC1E,+DAA+D,CAClE,CAAA;IACH,CAAC;AACH,CAAC,CAAA;AAED;;;GAGG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,IAAY,EAAW,EA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CAAC,CAAA;AAC9C,CAAC,CAAA"}
|
|
@@ -1,3 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import { PublicKey } from '@solana/web3.js';
|
|
2
|
+
/**
|
|
3
|
+
* Fetches the 75th-percentile non-zero recent prioritization fee from the
|
|
4
|
+
* Solana RPC. When `writableAccounts` is provided, the query is scoped to
|
|
5
|
+
* slots that wrote to those accounts (vault-aware) — the global feed is
|
|
6
|
+
* dominated by no-op vote txs and underestimates fees for contended
|
|
7
|
+
* writes. Floors at `solanaConfig.priorityFeePrice` so a low-congestion
|
|
8
|
+
* percentile never undershoots the cross-platform minimum, AND falls
|
|
9
|
+
* back to the floor when the sample window is too sparse to extrapolate
|
|
10
|
+
* a reliable percentile (see MIN_SAMPLE_SIZE).
|
|
11
|
+
*/
|
|
12
|
+
export declare const getDynamicPriorityFeePrice: (writableAccounts?: PublicKey[]) => Promise<number>;
|
|
13
|
+
export declare const _MIN_SAMPLE_SIZE_FOR_TEST = 5;
|
|
3
14
|
//# sourceMappingURL=getDynamicPriorityFeePrice.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getDynamicPriorityFeePrice.d.ts","sourceRoot":"","sources":["../../../../../../packages/core/chain/chains/solana/getDynamicPriorityFeePrice.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"getDynamicPriorityFeePrice.d.ts","sourceRoot":"","sources":["../../../../../../packages/core/chain/chains/solana/getDynamicPriorityFeePrice.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAA;AAoB3C;;;;;;;;;GASG;AACH,eAAO,MAAM,0BAA0B,GACnC,mBAAkB,SAAS,EAAO,KACnC,OAAO,CAAC,MAAM,CA0BhB,CAAA;AAID,eAAO,MAAM,yBAAyB,IAAkB,CAAA"}
|
|
@@ -1,20 +1,46 @@
|
|
|
1
1
|
import { getSolanaClient } from './client.js';
|
|
2
2
|
import { solanaConfig } from './solanaConfig.js';
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
const PRIORITY_FEE_PERCENTILE = 0.75;
|
|
4
|
+
/**
|
|
5
|
+
* Minimum sample size before the percentile selection is statistically
|
|
6
|
+
* meaningful. With the new lockedWritableAccounts scoping, sparse windows
|
|
7
|
+
* (1-3 non-zero fee slots in the recent window) become more likely - a
|
|
8
|
+
* single LP-add slot at e.g. 50_000_000 µLam/CU would dominate the
|
|
9
|
+
* percentile and set a wildly inflated fee for the next caller. Math.max
|
|
10
|
+
* floor below only protects against UNDER-payment; this guard protects
|
|
11
|
+
* against OVER-payment from a sparse-window spike. Below threshold we
|
|
12
|
+
* fall back to the cross-platform floor as the base rate (effectively
|
|
13
|
+
* "we don't have enough signal, pay the minimum").
|
|
14
|
+
*/
|
|
15
|
+
const MIN_SAMPLE_SIZE = 5;
|
|
16
|
+
/**
|
|
17
|
+
* Fetches the 75th-percentile non-zero recent prioritization fee from the
|
|
18
|
+
* Solana RPC. When `writableAccounts` is provided, the query is scoped to
|
|
19
|
+
* slots that wrote to those accounts (vault-aware) — the global feed is
|
|
20
|
+
* dominated by no-op vote txs and underestimates fees for contended
|
|
21
|
+
* writes. Floors at `solanaConfig.priorityFeePrice` so a low-congestion
|
|
22
|
+
* percentile never undershoots the cross-platform minimum, AND falls
|
|
23
|
+
* back to the floor when the sample window is too sparse to extrapolate
|
|
24
|
+
* a reliable percentile (see MIN_SAMPLE_SIZE).
|
|
25
|
+
*/
|
|
26
|
+
export const getDynamicPriorityFeePrice = async (writableAccounts = []) => {
|
|
5
27
|
const client = getSolanaClient();
|
|
6
|
-
const recentFees = await client.getRecentPrioritizationFees(
|
|
28
|
+
const recentFees = await client.getRecentPrioritizationFees(writableAccounts.length > 0
|
|
29
|
+
? { lockedWritableAccounts: writableAccounts }
|
|
30
|
+
: undefined);
|
|
7
31
|
const nonZeroFees = recentFees
|
|
8
32
|
.map(entry => entry.prioritizationFee)
|
|
9
33
|
.filter(fee => fee > 0)
|
|
10
34
|
.sort((a, b) => a - b);
|
|
11
|
-
|
|
35
|
+
// Sparse-window guard: too few non-zero samples means a single
|
|
36
|
+
// outlier slot would dominate the percentile. Fall back to floor.
|
|
37
|
+
if (nonZeroFees.length < MIN_SAMPLE_SIZE) {
|
|
12
38
|
return solanaConfig.priorityFeePrice;
|
|
13
39
|
}
|
|
14
|
-
const
|
|
15
|
-
|
|
16
|
-
return Math.round((nonZeroFees[mid - 1] + nonZeroFees[mid]) / 2);
|
|
17
|
-
}
|
|
18
|
-
return nonZeroFees[mid];
|
|
40
|
+
const index = Math.min(Math.floor(nonZeroFees.length * PRIORITY_FEE_PERCENTILE), nonZeroFees.length - 1);
|
|
41
|
+
return Math.max(nonZeroFees[index], solanaConfig.priorityFeePrice);
|
|
19
42
|
};
|
|
43
|
+
// Test-only export: lets unit tests pin the threshold without re-stating
|
|
44
|
+
// the magic number. Not exported from package barrel.
|
|
45
|
+
export const _MIN_SAMPLE_SIZE_FOR_TEST = MIN_SAMPLE_SIZE;
|
|
20
46
|
//# sourceMappingURL=getDynamicPriorityFeePrice.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getDynamicPriorityFeePrice.js","sourceRoot":"","sources":["../../../../../../packages/core/chain/chains/solana/getDynamicPriorityFeePrice.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"getDynamicPriorityFeePrice.js","sourceRoot":"","sources":["../../../../../../packages/core/chain/chains/solana/getDynamicPriorityFeePrice.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,eAAe,EAAE,MAAM,UAAU,CAAA;AAC1C,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAA;AAE7C,MAAM,uBAAuB,GAAG,IAAI,CAAA;AAEpC;;;;;;;;;;GAUG;AACH,MAAM,eAAe,GAAG,CAAC,CAAA;AAEzB;;;;;;;;;GASG;AACH,MAAM,CAAC,MAAM,0BAA0B,GAAG,KAAK,EAC3C,mBAAgC,EAAE,EACnB,EAAE;IACjB,MAAM,MAAM,GAAG,eAAe,EAAE,CAAA;IAEhC,MAAM,UAAU,GAAG,MAAM,MAAM,CAAC,2BAA2B,CACvD,gBAAgB,CAAC,MAAM,GAAG,CAAC;QACvB,CAAC,CAAC,EAAE,sBAAsB,EAAE,gBAAgB,EAAE;QAC9C,CAAC,CAAC,SAAS,CAClB,CAAA;IAED,MAAM,WAAW,GAAG,UAAU;SACzB,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC,KAAK,CAAC,iBAAiB,CAAC;SACrC,MAAM,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,GAAG,CAAC,CAAC;SACtB,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,CAAA;IAE1B,+DAA+D;IAC/D,kEAAkE;IAClE,IAAI,WAAW,CAAC,MAAM,GAAG,eAAe,EAAE,CAAC;QACvC,OAAO,YAAY,CAAC,gBAAgB,CAAA;IACxC,CAAC;IAED,MAAM,KAAK,GAAG,IAAI,CAAC,GAAG,CAClB,IAAI,CAAC,KAAK,CAAC,WAAW,CAAC,MAAM,GAAG,uBAAuB,CAAC,EACxD,WAAW,CAAC,MAAM,GAAG,CAAC,CACzB,CAAA;IAED,OAAO,IAAI,CAAC,GAAG,CAAC,WAAW,CAAC,KAAK,CAAC,EAAE,YAAY,CAAC,gBAAgB,CAAC,CAAA;AACtE,CAAC,CAAA;AAED,yEAAyE;AACzE,sDAAsD;AACtD,MAAM,CAAC,MAAM,yBAAyB,GAAG,eAAe,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"solanaConfig.d.ts","sourceRoot":"","sources":["../../../../../../packages/core/chain/chains/solana/solanaConfig.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,YAAY
|
|
1
|
+
{"version":3,"file":"solanaConfig.d.ts","sourceRoot":"","sources":["../../../../../../packages/core/chain/chains/solana/solanaConfig.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,YAAY;;;;;CAsBxB,CAAA"}
|