@cogcoin/client 1.1.7 → 1.1.9
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/README.md +1 -1
- package/dist/bitcoind/service.js +1 -1
- package/dist/cli/commands/mining-read.js +1 -1
- package/dist/cli/commands/wallet-mutation/anchor.d.ts +2 -0
- package/dist/cli/commands/wallet-mutation/anchor.js +33 -0
- package/dist/cli/commands/wallet-mutation/bitcoin-transfer.d.ts +2 -0
- package/dist/cli/commands/wallet-mutation/bitcoin-transfer.js +32 -0
- package/dist/cli/commands/wallet-mutation/cog.d.ts +2 -0
- package/dist/cli/commands/wallet-mutation/cog.js +131 -0
- package/dist/cli/commands/wallet-mutation/context.d.ts +3 -0
- package/dist/cli/commands/wallet-mutation/context.js +18 -0
- package/dist/cli/commands/wallet-mutation/domain-admin.d.ts +2 -0
- package/dist/cli/commands/wallet-mutation/domain-admin.js +173 -0
- package/dist/cli/commands/wallet-mutation/domain-market.d.ts +2 -0
- package/dist/cli/commands/wallet-mutation/domain-market.js +107 -0
- package/dist/cli/commands/wallet-mutation/field.d.ts +2 -0
- package/dist/cli/commands/wallet-mutation/field.js +125 -0
- package/dist/cli/commands/wallet-mutation/register.d.ts +2 -0
- package/dist/cli/commands/wallet-mutation/register.js +38 -0
- package/dist/cli/commands/wallet-mutation/registry.d.ts +3 -0
- package/dist/cli/commands/wallet-mutation/registry.js +39 -0
- package/dist/cli/commands/wallet-mutation/reputation.d.ts +2 -0
- package/dist/cli/commands/wallet-mutation/reputation.js +57 -0
- package/dist/cli/commands/wallet-mutation/types.d.ts +32 -0
- package/dist/cli/commands/wallet-mutation/types.js +1 -0
- package/dist/cli/commands/wallet-mutation.js +13 -765
- package/dist/cli/commands/wallet-read.js +4 -4
- package/dist/cli/mutation-success.d.ts +0 -2
- package/dist/cli/output/classify.d.ts +7 -0
- package/dist/cli/output/classify.js +94 -0
- package/dist/cli/output/render.d.ts +2 -0
- package/dist/cli/output/render.js +13 -0
- package/dist/cli/output/rules/cli-surface.d.ts +2 -0
- package/dist/cli/output/rules/cli-surface.js +110 -0
- package/dist/cli/output/rules/generic.d.ts +2 -0
- package/dist/cli/output/rules/generic.js +13 -0
- package/dist/cli/output/rules/index.d.ts +2 -0
- package/dist/cli/output/rules/index.js +24 -0
- package/dist/cli/output/rules/mining-update.d.ts +2 -0
- package/dist/cli/output/rules/mining-update.js +68 -0
- package/dist/cli/output/rules/services.d.ts +2 -0
- package/dist/cli/output/rules/services.js +110 -0
- package/dist/cli/output/rules/wallet-admin.d.ts +2 -0
- package/dist/cli/output/rules/wallet-admin.js +224 -0
- package/dist/cli/output/rules/wallet-mutations.d.ts +2 -0
- package/dist/cli/output/rules/wallet-mutations.js +274 -0
- package/dist/cli/output/types.d.ts +16 -0
- package/dist/cli/output/types.js +1 -0
- package/dist/cli/output.d.ts +2 -168
- package/dist/cli/output.js +6 -989
- package/dist/cli/pagination.d.ts +15 -0
- package/dist/cli/pagination.js +16 -0
- package/dist/cli/recommendations.d.ts +4 -0
- package/dist/cli/recommendations.js +108 -0
- package/dist/cli/wallet-format/availability.d.ts +5 -0
- package/dist/cli/wallet-format/availability.js +96 -0
- package/dist/cli/wallet-format/balance.d.ts +2 -0
- package/dist/cli/wallet-format/balance.js +162 -0
- package/dist/cli/wallet-format/domains.d.ts +8 -0
- package/dist/cli/wallet-format/domains.js +84 -0
- package/dist/cli/wallet-format/fields.d.ts +6 -0
- package/dist/cli/wallet-format/fields.js +61 -0
- package/dist/cli/wallet-format/identity.d.ts +5 -0
- package/dist/cli/wallet-format/identity.js +19 -0
- package/dist/cli/wallet-format/locks.d.ts +7 -0
- package/dist/cli/wallet-format/locks.js +52 -0
- package/dist/cli/wallet-format/overview.d.ts +2 -0
- package/dist/cli/wallet-format/overview.js +122 -0
- package/dist/cli/wallet-format/pending.d.ts +13 -0
- package/dist/cli/wallet-format/pending.js +101 -0
- package/dist/cli/wallet-format/shared.d.ts +7 -0
- package/dist/cli/wallet-format/shared.js +31 -0
- package/dist/cli/wallet-format/status.d.ts +3 -0
- package/dist/cli/wallet-format/status.js +27 -0
- package/dist/cli/wallet-format.d.ts +8 -30
- package/dist/cli/wallet-format.js +8 -830
- package/dist/cli/wallet-read-helpers.d.ts +6 -0
- package/dist/cli/wallet-read-helpers.js +17 -0
- package/dist/wallet/mining/candidate.d.ts +1 -1
- package/dist/wallet/mining/candidate.js +3 -3
- package/dist/wallet/mining/constants.d.ts +2 -2
- package/dist/wallet/mining/constants.js +2 -2
- package/dist/wallet/mining/engine-state.js +10 -0
- package/dist/wallet/mining/sentence-protocol.d.ts +2 -2
- package/dist/wallet/mining/sentences.js +8 -8
- package/dist/wallet/mining/visualizer-sync.js +79 -15
- package/dist/wallet/read/context.js +1 -1
- package/dist/wallet/reset/artifacts.d.ts +16 -0
- package/dist/wallet/reset/artifacts.js +141 -0
- package/dist/wallet/reset/execution.d.ts +38 -0
- package/dist/wallet/reset/execution.js +458 -0
- package/dist/wallet/reset/preflight.d.ts +7 -0
- package/dist/wallet/reset/preflight.js +116 -0
- package/dist/wallet/reset/preview.d.ts +2 -0
- package/dist/wallet/reset/preview.js +50 -0
- package/dist/wallet/reset/process-cleanup.d.ts +12 -0
- package/dist/wallet/reset/process-cleanup.js +179 -0
- package/dist/wallet/reset/types.d.ts +189 -0
- package/dist/wallet/reset/types.js +1 -0
- package/dist/wallet/reset.d.ts +4 -119
- package/dist/wallet/reset.js +4 -882
- package/dist/wallet/tx/anchor/confirm.d.ts +15 -0
- package/dist/wallet/tx/anchor/confirm.js +60 -0
- package/dist/wallet/tx/anchor/draft.d.ts +39 -0
- package/dist/wallet/tx/anchor/draft.js +167 -0
- package/dist/wallet/tx/anchor/index.d.ts +5 -0
- package/dist/wallet/tx/anchor/index.js +148 -0
- package/dist/wallet/tx/anchor/intent.d.ts +61 -0
- package/dist/wallet/tx/anchor/intent.js +101 -0
- package/dist/wallet/tx/anchor/plan.d.ts +3 -0
- package/dist/wallet/tx/anchor/plan.js +18 -0
- package/dist/wallet/tx/anchor/result.d.ts +25 -0
- package/dist/wallet/tx/anchor/result.js +20 -0
- package/dist/wallet/tx/anchor.d.ts +1 -39
- package/dist/wallet/tx/anchor.js +1 -494
- package/dist/wallet/tx/bitcoin-transfer/confirm.d.ts +7 -0
- package/dist/wallet/tx/bitcoin-transfer/confirm.js +11 -0
- package/dist/wallet/tx/bitcoin-transfer/index.d.ts +5 -0
- package/dist/wallet/tx/bitcoin-transfer/index.js +112 -0
- package/dist/wallet/tx/bitcoin-transfer/intent.d.ts +52 -0
- package/dist/wallet/tx/bitcoin-transfer/intent.js +74 -0
- package/dist/wallet/tx/bitcoin-transfer/plan.d.ts +5 -0
- package/dist/wallet/tx/bitcoin-transfer/plan.js +21 -0
- package/dist/wallet/tx/bitcoin-transfer/result.d.ts +19 -0
- package/dist/wallet/tx/bitcoin-transfer/result.js +16 -0
- package/dist/wallet/tx/bitcoin-transfer.d.ts +1 -35
- package/dist/wallet/tx/bitcoin-transfer.js +1 -200
- package/dist/wallet/tx/cog/confirm.d.ts +13 -0
- package/dist/wallet/tx/cog/confirm.js +59 -0
- package/dist/wallet/tx/cog/draft.d.ts +20 -0
- package/dist/wallet/tx/cog/draft.js +114 -0
- package/dist/wallet/tx/cog/index.d.ts +6 -0
- package/dist/wallet/tx/cog/index.js +117 -0
- package/dist/wallet/tx/cog/intent.d.ts +30 -0
- package/dist/wallet/tx/cog/intent.js +169 -0
- package/dist/wallet/tx/cog/plan.d.ts +19 -0
- package/dist/wallet/tx/cog/plan.js +65 -0
- package/dist/wallet/tx/cog/result.d.ts +27 -0
- package/dist/wallet/tx/cog/result.js +28 -0
- package/dist/wallet/tx/cog/types.d.ts +186 -0
- package/dist/wallet/tx/cog/types.js +2 -0
- package/dist/wallet/tx/cog/variants/claim.d.ts +3 -0
- package/dist/wallet/tx/cog/variants/claim.js +92 -0
- package/dist/wallet/tx/cog/variants/lock.d.ts +2 -0
- package/dist/wallet/tx/cog/variants/lock.js +102 -0
- package/dist/wallet/tx/cog/variants/send.d.ts +2 -0
- package/dist/wallet/tx/cog/variants/send.js +77 -0
- package/dist/wallet/tx/cog.d.ts +1 -96
- package/dist/wallet/tx/cog.js +1 -824
- package/dist/wallet/tx/common.d.ts +14 -199
- package/dist/wallet/tx/common.js +10 -493
- package/dist/wallet/tx/domain-admin/confirm.d.ts +17 -0
- package/dist/wallet/tx/domain-admin/confirm.js +58 -0
- package/dist/wallet/tx/domain-admin/draft.d.ts +20 -0
- package/dist/wallet/tx/domain-admin/draft.js +161 -0
- package/dist/wallet/tx/domain-admin/index.d.ts +9 -0
- package/dist/wallet/tx/domain-admin/index.js +150 -0
- package/dist/wallet/tx/domain-admin/intent.d.ts +12 -0
- package/dist/wallet/tx/domain-admin/intent.js +61 -0
- package/dist/wallet/tx/domain-admin/plan.d.ts +19 -0
- package/dist/wallet/tx/domain-admin/plan.js +64 -0
- package/dist/wallet/tx/domain-admin/result.d.ts +19 -0
- package/dist/wallet/tx/domain-admin/result.js +33 -0
- package/dist/wallet/tx/domain-admin/types.d.ts +162 -0
- package/dist/wallet/tx/domain-admin/types.js +1 -0
- package/dist/wallet/tx/domain-admin/variants/canonical.d.ts +2 -0
- package/dist/wallet/tx/domain-admin/variants/canonical.js +22 -0
- package/dist/wallet/tx/domain-admin/variants/delegate.d.ts +3 -0
- package/dist/wallet/tx/domain-admin/variants/delegate.js +60 -0
- package/dist/wallet/tx/domain-admin/variants/endpoint.d.ts +3 -0
- package/dist/wallet/tx/domain-admin/variants/endpoint.js +102 -0
- package/dist/wallet/tx/domain-admin/variants/miner.d.ts +3 -0
- package/dist/wallet/tx/domain-admin/variants/miner.js +59 -0
- package/dist/wallet/tx/domain-admin.d.ts +1 -107
- package/dist/wallet/tx/domain-admin.js +1 -729
- package/dist/wallet/tx/domain-market/confirm.d.ts +6 -0
- package/dist/wallet/tx/domain-market/confirm.js +52 -0
- package/dist/wallet/tx/domain-market/draft.d.ts +43 -0
- package/dist/wallet/tx/domain-market/draft.js +286 -0
- package/dist/wallet/tx/domain-market/index.d.ts +6 -0
- package/dist/wallet/tx/domain-market/index.js +145 -0
- package/dist/wallet/tx/domain-market/intent.d.ts +15 -0
- package/dist/wallet/tx/domain-market/intent.js +131 -0
- package/dist/wallet/tx/domain-market/plan.d.ts +31 -0
- package/dist/wallet/tx/domain-market/plan.js +98 -0
- package/dist/wallet/tx/domain-market/result.d.ts +45 -0
- package/dist/wallet/tx/domain-market/result.js +88 -0
- package/dist/wallet/tx/domain-market/types.d.ts +221 -0
- package/dist/wallet/tx/domain-market/types.js +1 -0
- package/dist/wallet/tx/domain-market/variants/buy.d.ts +2 -0
- package/dist/wallet/tx/domain-market/variants/buy.js +103 -0
- package/dist/wallet/tx/domain-market/variants/sell.d.ts +2 -0
- package/dist/wallet/tx/domain-market/variants/sell.js +91 -0
- package/dist/wallet/tx/domain-market/variants/transfer.d.ts +2 -0
- package/dist/wallet/tx/domain-market/variants/transfer.js +105 -0
- package/dist/wallet/tx/domain-market.d.ts +1 -116
- package/dist/wallet/tx/domain-market.js +1 -1078
- package/dist/wallet/tx/draft-build.d.ts +60 -0
- package/dist/wallet/tx/draft-build.js +127 -0
- package/dist/wallet/tx/executor.d.ts +6 -40
- package/dist/wallet/tx/executor.js +6 -100
- package/dist/wallet/tx/fee.d.ts +30 -0
- package/dist/wallet/tx/fee.js +98 -0
- package/dist/wallet/tx/field/confirm.d.ts +11 -0
- package/dist/wallet/tx/field/confirm.js +19 -0
- package/dist/wallet/tx/field/draft.d.ts +23 -0
- package/dist/wallet/tx/field/draft.js +202 -0
- package/dist/wallet/tx/field/index.d.ts +5 -0
- package/dist/wallet/tx/field/index.js +140 -0
- package/dist/wallet/tx/field/intent.d.ts +5 -0
- package/dist/wallet/tx/field/intent.js +50 -0
- package/dist/wallet/tx/field/plan.d.ts +20 -0
- package/dist/wallet/tx/field/plan.js +65 -0
- package/dist/wallet/tx/field/result.d.ts +29 -0
- package/dist/wallet/tx/field/result.js +103 -0
- package/dist/wallet/tx/field/types.d.ts +163 -0
- package/dist/wallet/tx/field/types.js +1 -0
- package/dist/wallet/tx/field/variants/clear.d.ts +2 -0
- package/dist/wallet/tx/field/variants/clear.js +60 -0
- package/dist/wallet/tx/field/variants/create.d.ts +2 -0
- package/dist/wallet/tx/field/variants/create.js +67 -0
- package/dist/wallet/tx/field/variants/set.d.ts +2 -0
- package/dist/wallet/tx/field/variants/set.js +195 -0
- package/dist/wallet/tx/field.d.ts +1 -95
- package/dist/wallet/tx/field.js +1 -920
- package/dist/wallet/tx/mining-preemption.d.ts +6 -0
- package/dist/wallet/tx/mining-preemption.js +7 -0
- package/dist/wallet/tx/primitives.d.ts +13 -0
- package/dist/wallet/tx/primitives.js +42 -0
- package/dist/wallet/tx/psbt-assert.d.ts +14 -0
- package/dist/wallet/tx/psbt-assert.js +39 -0
- package/dist/wallet/tx/publish.d.ts +37 -0
- package/dist/wallet/tx/publish.js +88 -0
- package/dist/wallet/tx/readiness.d.ts +7 -0
- package/dist/wallet/tx/readiness.js +61 -0
- package/dist/wallet/tx/reconcile.d.ts +24 -0
- package/dist/wallet/tx/reconcile.js +72 -0
- package/dist/wallet/tx/register/confirm.d.ts +6 -0
- package/dist/wallet/tx/register/confirm.js +66 -0
- package/dist/wallet/tx/register/draft.d.ts +42 -0
- package/dist/wallet/tx/register/draft.js +181 -0
- package/dist/wallet/tx/register/index.d.ts +6 -0
- package/dist/wallet/tx/register/index.js +158 -0
- package/dist/wallet/tx/register/intent.d.ts +74 -0
- package/dist/wallet/tx/register/intent.js +119 -0
- package/dist/wallet/tx/register/plan.d.ts +43 -0
- package/dist/wallet/tx/register/plan.js +168 -0
- package/dist/wallet/tx/register/result.d.ts +78 -0
- package/dist/wallet/tx/register/result.js +41 -0
- package/dist/wallet/tx/register.d.ts +1 -70
- package/dist/wallet/tx/register.js +1 -681
- package/dist/wallet/tx/reputation/confirm.d.ts +11 -0
- package/dist/wallet/tx/reputation/confirm.js +51 -0
- package/dist/wallet/tx/reputation/draft.d.ts +20 -0
- package/dist/wallet/tx/reputation/draft.js +130 -0
- package/dist/wallet/tx/reputation/index.d.ts +4 -0
- package/dist/wallet/tx/reputation/index.js +162 -0
- package/dist/wallet/tx/reputation/intent.d.ts +36 -0
- package/dist/wallet/tx/reputation/intent.js +157 -0
- package/dist/wallet/tx/reputation/plan.d.ts +19 -0
- package/dist/wallet/tx/reputation/plan.js +64 -0
- package/dist/wallet/tx/reputation/result.d.ts +21 -0
- package/dist/wallet/tx/reputation/result.js +31 -0
- package/dist/wallet/tx/reputation/types.d.ts +130 -0
- package/dist/wallet/tx/reputation/types.js +1 -0
- package/dist/wallet/tx/reputation.d.ts +1 -74
- package/dist/wallet/tx/reputation.js +1 -556
- package/dist/wallet/tx/signing.d.ts +18 -0
- package/dist/wallet/tx/signing.js +31 -0
- package/dist/wallet/tx/state-persist.d.ts +27 -0
- package/dist/wallet/tx/state-persist.js +54 -0
- package/dist/wallet/tx/types.d.ts +44 -0
- package/dist/wallet/tx/types.js +1 -0
- package/package.json +1 -1
- package/dist/cli/mining-json.d.ts +0 -20
- package/dist/cli/mining-json.js +0 -46
- package/dist/cli/mutation-json.d.ts +0 -325
- package/dist/cli/mutation-json.js +0 -269
- package/dist/cli/mutation-resolved-json.d.ts +0 -117
- package/dist/cli/mutation-resolved-json.js +0 -123
- package/dist/cli/preview-json.d.ts +0 -319
- package/dist/cli/preview-json.js +0 -254
- package/dist/cli/read-json.d.ts +0 -190
- package/dist/cli/read-json.js +0 -627
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { WalletPrompter } from "../../lifecycle.js";
|
|
2
|
+
import type { DomainMarketResolvedEconomicEffect, DomainMarketResolvedRecipientSummary, DomainMarketResolvedSenderSummary } from "./types.js";
|
|
3
|
+
import type { MutationSender } from "../common.js";
|
|
4
|
+
export declare function confirmTransfer(prompter: WalletPrompter, domainName: string, sender: DomainMarketResolvedSenderSummary, recipient: DomainMarketResolvedRecipientSummary, economicEffect: DomainMarketResolvedEconomicEffect, assumeYes?: boolean): Promise<void>;
|
|
5
|
+
export declare function confirmSell(prompter: WalletPrompter, domainName: string, sender: DomainMarketResolvedSenderSummary, listedPriceCogtoshi: bigint, assumeYes?: boolean): Promise<void>;
|
|
6
|
+
export declare function confirmBuy(prompter: WalletPrompter, domainName: string, buyerSelector: string, buyer: MutationSender, sellerScriptPubKeyHex: string, sellerAddress: string | null, listedPriceCogtoshi: bigint, assumeYes?: boolean): Promise<void>;
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { confirmTypedAcknowledgement, confirmYesNo, } from "../confirm.js";
|
|
2
|
+
export async function confirmTransfer(prompter, domainName, sender, recipient, economicEffect, assumeYes = false) {
|
|
3
|
+
prompter.writeLine(`You are transferring "${domainName}".`);
|
|
4
|
+
prompter.writeLine(`Resolved sender: ${sender.selector} (${sender.address})`);
|
|
5
|
+
prompter.writeLine(`Resolved recipient: ${recipient.address ?? `spk:${recipient.scriptPubKeyHex}`}`);
|
|
6
|
+
prompter.writeLine(`Economic effect: ${economicEffect.kind === "ownership-transfer" && economicEffect.clearsListing
|
|
7
|
+
? "transfer domain ownership and clear any active listing."
|
|
8
|
+
: "transfer domain ownership."}`);
|
|
9
|
+
if (recipient.opaque) {
|
|
10
|
+
prompter.writeLine(`Target script length: ${recipient.scriptPubKeyHex.length / 2} bytes`);
|
|
11
|
+
prompter.writeLine("Cogcoin identity is exact raw-script equality. Different script templates are different identities.");
|
|
12
|
+
const acknowledgement = `RAW-SCRIPT:${recipient.scriptPubKeyHex.slice(0, 16)}`;
|
|
13
|
+
await confirmTypedAcknowledgement(prompter, {
|
|
14
|
+
assumeYes,
|
|
15
|
+
expected: acknowledgement,
|
|
16
|
+
prompt: `Type ${acknowledgement} to continue: `,
|
|
17
|
+
errorCode: "wallet_transfer_confirmation_rejected",
|
|
18
|
+
requiresTtyErrorCode: "wallet_transfer_requires_tty",
|
|
19
|
+
typedAckRequiredErrorCode: "wallet_transfer_typed_ack_required",
|
|
20
|
+
});
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
await confirmYesNo(prompter, "This publishes a standalone DOMAIN_TRANSFER.", {
|
|
24
|
+
assumeYes,
|
|
25
|
+
errorCode: "wallet_transfer_confirmation_rejected",
|
|
26
|
+
requiresTtyErrorCode: "wallet_transfer_requires_tty",
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
export async function confirmSell(prompter, domainName, sender, listedPriceCogtoshi, assumeYes = false) {
|
|
30
|
+
prompter.writeLine(`You are listing "${domainName}".`);
|
|
31
|
+
prompter.writeLine(`Resolved sender: ${sender.selector} (${sender.address})`);
|
|
32
|
+
prompter.writeLine(`Exact listing price: ${listedPriceCogtoshi.toString()} cogtoshi.`);
|
|
33
|
+
prompter.writeLine(`Economic effect: set the listing price to ${listedPriceCogtoshi.toString()} cogtoshi in COG state.`);
|
|
34
|
+
prompter.writeLine("Settlement: entirely in COG state. No BTC payment output will be added.");
|
|
35
|
+
await confirmYesNo(prompter, "This publishes a standalone DOMAIN_SELL mutation.", {
|
|
36
|
+
assumeYes,
|
|
37
|
+
errorCode: "wallet_sell_confirmation_rejected",
|
|
38
|
+
requiresTtyErrorCode: "wallet_sell_requires_tty",
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
export async function confirmBuy(prompter, domainName, buyerSelector, buyer, sellerScriptPubKeyHex, sellerAddress, listedPriceCogtoshi, assumeYes = false) {
|
|
42
|
+
prompter.writeLine(`You are buying "${domainName}".`);
|
|
43
|
+
prompter.writeLine(`Exact listing price: ${listedPriceCogtoshi.toString()} cogtoshi.`);
|
|
44
|
+
prompter.writeLine(`Resolved buyer: ${buyerSelector} (${buyer.address})`);
|
|
45
|
+
prompter.writeLine(`Resolved seller: ${sellerAddress ?? `spk:${sellerScriptPubKeyHex}`}`);
|
|
46
|
+
prompter.writeLine("Settlement: entirely in COG state. No BTC payment output will be added.");
|
|
47
|
+
await confirmYesNo(prompter, "This publishes a standalone DOMAIN_BUY mutation.", {
|
|
48
|
+
assumeYes,
|
|
49
|
+
errorCode: "wallet_buy_confirmation_rejected",
|
|
50
|
+
requiresTtyErrorCode: "wallet_buy_requires_tty",
|
|
51
|
+
});
|
|
52
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import type { WalletRuntimePaths } from "../../runtime.js";
|
|
2
|
+
import type { WalletSecretProvider } from "../../state/provider.js";
|
|
3
|
+
import type { PendingMutationRecord, WalletStateV1 } from "../../types.js";
|
|
4
|
+
import type { WalletReadContext } from "../../read/index.js";
|
|
5
|
+
import type { DomainMarketDraftMutationOptions, DomainMarketRpcClient } from "./types.js";
|
|
6
|
+
export declare function reserveTransferredDomainRecord(options: {
|
|
7
|
+
state: WalletStateV1;
|
|
8
|
+
domainName: string;
|
|
9
|
+
domainId: number | null;
|
|
10
|
+
currentOwnerScriptPubKeyHex: string;
|
|
11
|
+
nowUnixMs: number;
|
|
12
|
+
}): WalletStateV1;
|
|
13
|
+
export declare function createDomainMarketDraftMutation(options: DomainMarketDraftMutationOptions): PendingMutationRecord;
|
|
14
|
+
export declare function getTransferStatusAfterAcceptance(options: {
|
|
15
|
+
snapshot: WalletReadContext["snapshot"];
|
|
16
|
+
domainName: string;
|
|
17
|
+
recipientScriptPubKeyHex: string;
|
|
18
|
+
}): "live" | "confirmed";
|
|
19
|
+
export declare function getSellStatusAfterAcceptance(options: {
|
|
20
|
+
snapshot: WalletReadContext["snapshot"];
|
|
21
|
+
domainName: string;
|
|
22
|
+
senderScriptPubKeyHex: string;
|
|
23
|
+
listedPriceCogtoshi: bigint;
|
|
24
|
+
}): "live" | "confirmed";
|
|
25
|
+
export declare function getBuyStatusAfterAcceptance(options: {
|
|
26
|
+
snapshot: WalletReadContext["snapshot"];
|
|
27
|
+
domainName: string;
|
|
28
|
+
buyerScriptPubKeyHex: string;
|
|
29
|
+
}): "live" | "confirmed";
|
|
30
|
+
export declare function reconcilePendingDomainMarketMutation(options: {
|
|
31
|
+
state: WalletStateV1;
|
|
32
|
+
mutation: PendingMutationRecord;
|
|
33
|
+
provider: WalletSecretProvider;
|
|
34
|
+
nowUnixMs: number;
|
|
35
|
+
paths: WalletRuntimePaths;
|
|
36
|
+
rpc: DomainMarketRpcClient;
|
|
37
|
+
walletName: string;
|
|
38
|
+
context: WalletReadContext;
|
|
39
|
+
}): Promise<{
|
|
40
|
+
state: WalletStateV1;
|
|
41
|
+
mutation: PendingMutationRecord;
|
|
42
|
+
resolution: "confirmed" | "live" | "repair-required" | "not-seen" | "continue";
|
|
43
|
+
}>;
|
|
@@ -0,0 +1,286 @@
|
|
|
1
|
+
import { randomBytes } from "node:crypto";
|
|
2
|
+
import { getListing, lookupDomain } from "@cogcoin/indexer/queries";
|
|
3
|
+
import { createWalletMutationFeeMetadata, saveWalletStatePreservingUnlock, unlockTemporaryBuilderLocks, updateMutationRecord, } from "../common.js";
|
|
4
|
+
import { upsertPendingMutation } from "../journal.js";
|
|
5
|
+
export function reserveTransferredDomainRecord(options) {
|
|
6
|
+
const existing = options.state.domains.find((domain) => domain.name === options.domainName) ?? null;
|
|
7
|
+
const domains = options.state.domains.some((domain) => domain.name === options.domainName)
|
|
8
|
+
? options.state.domains.map((domain) => {
|
|
9
|
+
if (domain.name !== options.domainName) {
|
|
10
|
+
return domain;
|
|
11
|
+
}
|
|
12
|
+
return {
|
|
13
|
+
...domain,
|
|
14
|
+
domainId: options.domainId ?? domain.domainId,
|
|
15
|
+
currentOwnerScriptPubKeyHex: options.currentOwnerScriptPubKeyHex,
|
|
16
|
+
canonicalChainStatus: "registered-unanchored",
|
|
17
|
+
birthTime: domain.birthTime ?? Math.floor(options.nowUnixMs / 1000),
|
|
18
|
+
};
|
|
19
|
+
})
|
|
20
|
+
: [
|
|
21
|
+
...options.state.domains,
|
|
22
|
+
{
|
|
23
|
+
name: options.domainName,
|
|
24
|
+
domainId: options.domainId,
|
|
25
|
+
currentOwnerScriptPubKeyHex: options.currentOwnerScriptPubKeyHex,
|
|
26
|
+
canonicalChainStatus: "registered-unanchored",
|
|
27
|
+
foundingMessageText: existing?.foundingMessageText ?? null,
|
|
28
|
+
birthTime: Math.floor(options.nowUnixMs / 1000),
|
|
29
|
+
},
|
|
30
|
+
];
|
|
31
|
+
return {
|
|
32
|
+
...options.state,
|
|
33
|
+
domains,
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
export function createDomainMarketDraftMutation(options) {
|
|
37
|
+
if (options.existing !== null && options.existing !== undefined) {
|
|
38
|
+
return {
|
|
39
|
+
...options.existing,
|
|
40
|
+
kind: options.kind,
|
|
41
|
+
parentDomainName: options.parentDomainName ?? null,
|
|
42
|
+
senderScriptPubKeyHex: options.sender.scriptPubKeyHex,
|
|
43
|
+
senderLocalIndex: options.sender.localIndex,
|
|
44
|
+
recipientScriptPubKeyHex: options.recipientScriptPubKeyHex ?? null,
|
|
45
|
+
priceCogtoshi: options.priceCogtoshi ?? null,
|
|
46
|
+
status: "draft",
|
|
47
|
+
lastUpdatedAtUnixMs: options.nowUnixMs,
|
|
48
|
+
attemptedTxid: null,
|
|
49
|
+
attemptedWtxid: null,
|
|
50
|
+
...createWalletMutationFeeMetadata(options.feeSelection),
|
|
51
|
+
temporaryBuilderLockedOutpoints: [],
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
return {
|
|
55
|
+
mutationId: randomBytes(12).toString("hex"),
|
|
56
|
+
kind: options.kind,
|
|
57
|
+
domainName: options.domainName,
|
|
58
|
+
parentDomainName: options.parentDomainName ?? null,
|
|
59
|
+
senderScriptPubKeyHex: options.sender.scriptPubKeyHex,
|
|
60
|
+
senderLocalIndex: options.sender.localIndex,
|
|
61
|
+
recipientScriptPubKeyHex: options.recipientScriptPubKeyHex ?? null,
|
|
62
|
+
priceCogtoshi: options.priceCogtoshi ?? null,
|
|
63
|
+
intentFingerprintHex: options.intentFingerprintHex,
|
|
64
|
+
status: "draft",
|
|
65
|
+
createdAtUnixMs: options.nowUnixMs,
|
|
66
|
+
lastUpdatedAtUnixMs: options.nowUnixMs,
|
|
67
|
+
attemptedTxid: null,
|
|
68
|
+
attemptedWtxid: null,
|
|
69
|
+
...createWalletMutationFeeMetadata(options.feeSelection),
|
|
70
|
+
temporaryBuilderLockedOutpoints: [],
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
export function getTransferStatusAfterAcceptance(options) {
|
|
74
|
+
const chainDomain = options.snapshot === null ? null : lookupDomain(options.snapshot.state, options.domainName);
|
|
75
|
+
if (chainDomain === null) {
|
|
76
|
+
return "live";
|
|
77
|
+
}
|
|
78
|
+
return Buffer.from(chainDomain.ownerScriptPubKey).toString("hex") === options.recipientScriptPubKeyHex
|
|
79
|
+
? "confirmed"
|
|
80
|
+
: "live";
|
|
81
|
+
}
|
|
82
|
+
export function getSellStatusAfterAcceptance(options) {
|
|
83
|
+
const chainDomain = options.snapshot === null ? null : lookupDomain(options.snapshot.state, options.domainName);
|
|
84
|
+
if (chainDomain === null) {
|
|
85
|
+
return "live";
|
|
86
|
+
}
|
|
87
|
+
const ownerHex = Buffer.from(chainDomain.ownerScriptPubKey).toString("hex");
|
|
88
|
+
const listing = getListing(options.snapshot.state, chainDomain.domainId);
|
|
89
|
+
if (options.listedPriceCogtoshi === 0n) {
|
|
90
|
+
return ownerHex === options.senderScriptPubKeyHex && listing === null ? "confirmed" : "live";
|
|
91
|
+
}
|
|
92
|
+
return ownerHex === options.senderScriptPubKeyHex && listing?.priceCogtoshi === options.listedPriceCogtoshi
|
|
93
|
+
? "confirmed"
|
|
94
|
+
: "live";
|
|
95
|
+
}
|
|
96
|
+
export function getBuyStatusAfterAcceptance(options) {
|
|
97
|
+
const chainDomain = options.snapshot === null ? null : lookupDomain(options.snapshot.state, options.domainName);
|
|
98
|
+
if (chainDomain === null) {
|
|
99
|
+
return "live";
|
|
100
|
+
}
|
|
101
|
+
return Buffer.from(chainDomain.ownerScriptPubKey).toString("hex") === options.buyerScriptPubKeyHex
|
|
102
|
+
? "confirmed"
|
|
103
|
+
: "live";
|
|
104
|
+
}
|
|
105
|
+
export async function reconcilePendingDomainMarketMutation(options) {
|
|
106
|
+
if (options.mutation.status === "repair-required") {
|
|
107
|
+
return {
|
|
108
|
+
state: options.state,
|
|
109
|
+
mutation: options.mutation,
|
|
110
|
+
resolution: "repair-required",
|
|
111
|
+
};
|
|
112
|
+
}
|
|
113
|
+
const chainDomain = options.context.snapshot === null
|
|
114
|
+
? null
|
|
115
|
+
: lookupDomain(options.context.snapshot.state, options.mutation.domainName);
|
|
116
|
+
if (chainDomain !== null) {
|
|
117
|
+
const ownerHex = Buffer.from(chainDomain.ownerScriptPubKey).toString("hex");
|
|
118
|
+
const listing = getListing(options.context.snapshot.state, chainDomain.domainId);
|
|
119
|
+
if (options.mutation.kind === "transfer") {
|
|
120
|
+
if (ownerHex === options.mutation.recipientScriptPubKeyHex) {
|
|
121
|
+
await unlockTemporaryBuilderLocks(options.rpc, options.walletName, options.mutation.temporaryBuilderLockedOutpoints);
|
|
122
|
+
const confirmed = updateMutationRecord(options.mutation, "confirmed", options.nowUnixMs, {
|
|
123
|
+
temporaryBuilderLockedOutpoints: [],
|
|
124
|
+
});
|
|
125
|
+
const nextState = reserveTransferredDomainRecord({
|
|
126
|
+
state: upsertPendingMutation(options.state, confirmed),
|
|
127
|
+
domainName: options.mutation.domainName,
|
|
128
|
+
domainId: chainDomain.domainId,
|
|
129
|
+
currentOwnerScriptPubKeyHex: ownerHex,
|
|
130
|
+
nowUnixMs: options.nowUnixMs,
|
|
131
|
+
});
|
|
132
|
+
await saveWalletStatePreservingUnlock({
|
|
133
|
+
state: nextState,
|
|
134
|
+
provider: options.provider,
|
|
135
|
+
nowUnixMs: options.nowUnixMs,
|
|
136
|
+
paths: options.paths,
|
|
137
|
+
});
|
|
138
|
+
return { state: nextState, mutation: confirmed, resolution: "confirmed" };
|
|
139
|
+
}
|
|
140
|
+
if (ownerHex !== options.mutation.senderScriptPubKeyHex) {
|
|
141
|
+
const repair = updateMutationRecord(options.mutation, "repair-required", options.nowUnixMs, {
|
|
142
|
+
temporaryBuilderLockedOutpoints: [],
|
|
143
|
+
});
|
|
144
|
+
const nextState = upsertPendingMutation(options.state, repair);
|
|
145
|
+
await saveWalletStatePreservingUnlock({
|
|
146
|
+
state: nextState,
|
|
147
|
+
provider: options.provider,
|
|
148
|
+
nowUnixMs: options.nowUnixMs,
|
|
149
|
+
paths: options.paths,
|
|
150
|
+
});
|
|
151
|
+
return { state: nextState, mutation: repair, resolution: "repair-required" };
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
if (options.mutation.kind === "sell") {
|
|
155
|
+
const targetPrice = options.mutation.priceCogtoshi ?? 0n;
|
|
156
|
+
if (ownerHex === options.mutation.senderScriptPubKeyHex) {
|
|
157
|
+
if (targetPrice === 0n && listing === null) {
|
|
158
|
+
await unlockTemporaryBuilderLocks(options.rpc, options.walletName, options.mutation.temporaryBuilderLockedOutpoints);
|
|
159
|
+
const confirmed = updateMutationRecord(options.mutation, "confirmed", options.nowUnixMs, {
|
|
160
|
+
temporaryBuilderLockedOutpoints: [],
|
|
161
|
+
});
|
|
162
|
+
const nextState = upsertPendingMutation(options.state, confirmed);
|
|
163
|
+
await saveWalletStatePreservingUnlock({
|
|
164
|
+
state: nextState,
|
|
165
|
+
provider: options.provider,
|
|
166
|
+
nowUnixMs: options.nowUnixMs,
|
|
167
|
+
paths: options.paths,
|
|
168
|
+
});
|
|
169
|
+
return { state: nextState, mutation: confirmed, resolution: "confirmed" };
|
|
170
|
+
}
|
|
171
|
+
if (targetPrice > 0n && listing?.priceCogtoshi === targetPrice) {
|
|
172
|
+
await unlockTemporaryBuilderLocks(options.rpc, options.walletName, options.mutation.temporaryBuilderLockedOutpoints);
|
|
173
|
+
const confirmed = updateMutationRecord(options.mutation, "confirmed", options.nowUnixMs, {
|
|
174
|
+
temporaryBuilderLockedOutpoints: [],
|
|
175
|
+
});
|
|
176
|
+
const nextState = upsertPendingMutation(options.state, confirmed);
|
|
177
|
+
await saveWalletStatePreservingUnlock({
|
|
178
|
+
state: nextState,
|
|
179
|
+
provider: options.provider,
|
|
180
|
+
nowUnixMs: options.nowUnixMs,
|
|
181
|
+
paths: options.paths,
|
|
182
|
+
});
|
|
183
|
+
return { state: nextState, mutation: confirmed, resolution: "confirmed" };
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
else {
|
|
187
|
+
const repair = updateMutationRecord(options.mutation, "repair-required", options.nowUnixMs, {
|
|
188
|
+
temporaryBuilderLockedOutpoints: [],
|
|
189
|
+
});
|
|
190
|
+
const nextState = upsertPendingMutation(options.state, repair);
|
|
191
|
+
await saveWalletStatePreservingUnlock({
|
|
192
|
+
state: nextState,
|
|
193
|
+
provider: options.provider,
|
|
194
|
+
nowUnixMs: options.nowUnixMs,
|
|
195
|
+
paths: options.paths,
|
|
196
|
+
});
|
|
197
|
+
return { state: nextState, mutation: repair, resolution: "repair-required" };
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
if (options.mutation.kind === "buy") {
|
|
201
|
+
if (ownerHex === options.mutation.senderScriptPubKeyHex) {
|
|
202
|
+
await unlockTemporaryBuilderLocks(options.rpc, options.walletName, options.mutation.temporaryBuilderLockedOutpoints);
|
|
203
|
+
const confirmed = updateMutationRecord(options.mutation, "confirmed", options.nowUnixMs, {
|
|
204
|
+
temporaryBuilderLockedOutpoints: [],
|
|
205
|
+
});
|
|
206
|
+
const nextState = reserveTransferredDomainRecord({
|
|
207
|
+
state: upsertPendingMutation(options.state, confirmed),
|
|
208
|
+
domainName: options.mutation.domainName,
|
|
209
|
+
domainId: chainDomain.domainId,
|
|
210
|
+
currentOwnerScriptPubKeyHex: ownerHex,
|
|
211
|
+
nowUnixMs: options.nowUnixMs,
|
|
212
|
+
});
|
|
213
|
+
await saveWalletStatePreservingUnlock({
|
|
214
|
+
state: nextState,
|
|
215
|
+
provider: options.provider,
|
|
216
|
+
nowUnixMs: options.nowUnixMs,
|
|
217
|
+
paths: options.paths,
|
|
218
|
+
});
|
|
219
|
+
return { state: nextState, mutation: confirmed, resolution: "confirmed" };
|
|
220
|
+
}
|
|
221
|
+
if (listing === null) {
|
|
222
|
+
const repair = updateMutationRecord(options.mutation, "repair-required", options.nowUnixMs, {
|
|
223
|
+
temporaryBuilderLockedOutpoints: [],
|
|
224
|
+
});
|
|
225
|
+
const nextState = upsertPendingMutation(options.state, repair);
|
|
226
|
+
await saveWalletStatePreservingUnlock({
|
|
227
|
+
state: nextState,
|
|
228
|
+
provider: options.provider,
|
|
229
|
+
nowUnixMs: options.nowUnixMs,
|
|
230
|
+
paths: options.paths,
|
|
231
|
+
});
|
|
232
|
+
return { state: nextState, mutation: repair, resolution: "repair-required" };
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
if (options.mutation.attemptedTxid !== null) {
|
|
237
|
+
const mempool = await options.rpc.getRawMempool().catch(() => []);
|
|
238
|
+
if (mempool.includes(options.mutation.attemptedTxid)) {
|
|
239
|
+
await unlockTemporaryBuilderLocks(options.rpc, options.walletName, options.mutation.temporaryBuilderLockedOutpoints);
|
|
240
|
+
const live = updateMutationRecord(options.mutation, "live", options.nowUnixMs, {
|
|
241
|
+
temporaryBuilderLockedOutpoints: [],
|
|
242
|
+
});
|
|
243
|
+
let nextState = upsertPendingMutation(options.state, live);
|
|
244
|
+
if (live.kind === "transfer" || live.kind === "buy") {
|
|
245
|
+
nextState = reserveTransferredDomainRecord({
|
|
246
|
+
state: nextState,
|
|
247
|
+
domainName: live.domainName,
|
|
248
|
+
domainId: chainDomain?.domainId ?? null,
|
|
249
|
+
currentOwnerScriptPubKeyHex: live.kind === "transfer"
|
|
250
|
+
? (live.recipientScriptPubKeyHex ?? live.senderScriptPubKeyHex)
|
|
251
|
+
: live.senderScriptPubKeyHex,
|
|
252
|
+
nowUnixMs: options.nowUnixMs,
|
|
253
|
+
});
|
|
254
|
+
}
|
|
255
|
+
await saveWalletStatePreservingUnlock({
|
|
256
|
+
state: nextState,
|
|
257
|
+
provider: options.provider,
|
|
258
|
+
nowUnixMs: options.nowUnixMs,
|
|
259
|
+
paths: options.paths,
|
|
260
|
+
});
|
|
261
|
+
return { state: nextState, mutation: live, resolution: "live" };
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
if (options.mutation.status === "broadcast-unknown"
|
|
265
|
+
|| options.mutation.status === "live"
|
|
266
|
+
|| options.mutation.status === "draft"
|
|
267
|
+
|| options.mutation.status === "broadcasting") {
|
|
268
|
+
await unlockTemporaryBuilderLocks(options.rpc, options.walletName, options.mutation.temporaryBuilderLockedOutpoints);
|
|
269
|
+
const canceled = updateMutationRecord(options.mutation, "canceled", options.nowUnixMs, {
|
|
270
|
+
temporaryBuilderLockedOutpoints: [],
|
|
271
|
+
});
|
|
272
|
+
const nextState = upsertPendingMutation(options.state, canceled);
|
|
273
|
+
await saveWalletStatePreservingUnlock({
|
|
274
|
+
state: nextState,
|
|
275
|
+
provider: options.provider,
|
|
276
|
+
nowUnixMs: options.nowUnixMs,
|
|
277
|
+
paths: options.paths,
|
|
278
|
+
});
|
|
279
|
+
return { state: nextState, mutation: canceled, resolution: "not-seen" };
|
|
280
|
+
}
|
|
281
|
+
return {
|
|
282
|
+
state: options.state,
|
|
283
|
+
mutation: options.mutation,
|
|
284
|
+
resolution: "continue",
|
|
285
|
+
};
|
|
286
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { BuyDomainOptions, DomainMarketMutationResult, SellDomainOptions, TransferDomainOptions } from "./types.js";
|
|
2
|
+
export { parseCogAmountToCogtoshi } from "./intent.js";
|
|
3
|
+
export type { BuyDomainOptions, DomainMarketMutationResult, DomainMarketResolvedBuyerSummary, DomainMarketResolvedEconomicEffect, DomainMarketResolvedRecipientSummary, DomainMarketResolvedSellerSummary, DomainMarketResolvedSenderSummary, DomainMarketResolvedSummary, SellDomainOptions, TransferDomainOptions, } from "./types.js";
|
|
4
|
+
export declare function transferDomain(options: TransferDomainOptions): Promise<DomainMarketMutationResult>;
|
|
5
|
+
export declare function sellDomain(options: SellDomainOptions): Promise<DomainMarketMutationResult>;
|
|
6
|
+
export declare function buyDomain(options: BuyDomainOptions): Promise<DomainMarketMutationResult>;
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
import { mergeFixedWalletInputs } from "../common.js";
|
|
2
|
+
import { executeWalletMutationOperation, publishWalletMutation, resolveExistingWalletMutation, } from "../executor.js";
|
|
3
|
+
import { reconcilePendingDomainMarketMutation } from "./draft.js";
|
|
4
|
+
import { prepareDomainMarketBuildState, buildPlanForDomainOperation, buildDomainMarketTransaction, } from "./plan.js";
|
|
5
|
+
import { parseCogAmountToCogtoshi } from "./intent.js";
|
|
6
|
+
import { createBuyDomainVariant } from "./variants/buy.js";
|
|
7
|
+
import { createSellDomainVariant } from "./variants/sell.js";
|
|
8
|
+
import { createTransferDomainVariant } from "./variants/transfer.js";
|
|
9
|
+
export { parseCogAmountToCogtoshi } from "./intent.js";
|
|
10
|
+
async function executeDomainMarketMutation(options, variant) {
|
|
11
|
+
const execution = await executeWalletMutationOperation({
|
|
12
|
+
...options,
|
|
13
|
+
controlLockPurpose: variant.controlLockPurpose,
|
|
14
|
+
preemptionReason: variant.preemptionReason,
|
|
15
|
+
resolveOperation(readContext) {
|
|
16
|
+
return variant.resolveOperation(readContext);
|
|
17
|
+
},
|
|
18
|
+
createIntentFingerprint(operation) {
|
|
19
|
+
return variant.createIntentFingerprint(operation);
|
|
20
|
+
},
|
|
21
|
+
async resolveExistingMutation({ operation, existingMutation, execution }) {
|
|
22
|
+
if (existingMutation === null) {
|
|
23
|
+
return { state: operation.state, replacementFixedInputs: null, result: null };
|
|
24
|
+
}
|
|
25
|
+
return resolveExistingWalletMutation({
|
|
26
|
+
existingMutation,
|
|
27
|
+
execution,
|
|
28
|
+
repairRequiredErrorCode: variant.repairRequiredErrorCode,
|
|
29
|
+
reconcileExistingMutation: (mutation) => reconcilePendingDomainMarketMutation({
|
|
30
|
+
state: operation.state,
|
|
31
|
+
mutation,
|
|
32
|
+
provider: execution.provider,
|
|
33
|
+
nowUnixMs: execution.nowUnixMs,
|
|
34
|
+
paths: execution.paths,
|
|
35
|
+
rpc: execution.rpc,
|
|
36
|
+
walletName: execution.walletName,
|
|
37
|
+
context: execution.readContext,
|
|
38
|
+
}),
|
|
39
|
+
createReuseResult: ({ mutation, resolution, fees }) => variant.createReuseResult({
|
|
40
|
+
operation,
|
|
41
|
+
mutation,
|
|
42
|
+
resolution,
|
|
43
|
+
fees,
|
|
44
|
+
}),
|
|
45
|
+
});
|
|
46
|
+
},
|
|
47
|
+
confirm({ operation }) {
|
|
48
|
+
return variant.confirm(operation);
|
|
49
|
+
},
|
|
50
|
+
createDraftMutation({ operation, existingMutation, execution, intentFingerprintHex }) {
|
|
51
|
+
return {
|
|
52
|
+
mutation: variant.createDraftMutation({
|
|
53
|
+
operation,
|
|
54
|
+
existingMutation,
|
|
55
|
+
feeSelection: execution.feeSelection,
|
|
56
|
+
intentFingerprintHex,
|
|
57
|
+
nowUnixMs: execution.nowUnixMs,
|
|
58
|
+
}),
|
|
59
|
+
prepared: null,
|
|
60
|
+
};
|
|
61
|
+
},
|
|
62
|
+
async prepareBuildState({ state, execution }) {
|
|
63
|
+
return (await prepareDomainMarketBuildState({
|
|
64
|
+
rpc: execution.rpc,
|
|
65
|
+
walletName: execution.walletName,
|
|
66
|
+
state,
|
|
67
|
+
provider: execution.provider,
|
|
68
|
+
nowUnixMs: execution.nowUnixMs,
|
|
69
|
+
paths: execution.paths,
|
|
70
|
+
preflightCoinControl: false,
|
|
71
|
+
})).state;
|
|
72
|
+
},
|
|
73
|
+
async build({ operation, state, execution, replacementFixedInputs }) {
|
|
74
|
+
const domainPlan = buildPlanForDomainOperation({
|
|
75
|
+
state,
|
|
76
|
+
allUtxos: await execution.rpc.listUnspent(execution.walletName, 1),
|
|
77
|
+
sender: operation.sender,
|
|
78
|
+
opReturnData: variant.createOpReturnData(operation),
|
|
79
|
+
errorPrefix: variant.errorPrefix,
|
|
80
|
+
});
|
|
81
|
+
return buildDomainMarketTransaction({
|
|
82
|
+
rpc: execution.rpc,
|
|
83
|
+
walletName: execution.walletName,
|
|
84
|
+
state,
|
|
85
|
+
plan: {
|
|
86
|
+
...domainPlan,
|
|
87
|
+
fixedInputs: mergeFixedWalletInputs(domainPlan.fixedInputs, replacementFixedInputs),
|
|
88
|
+
},
|
|
89
|
+
feeRateSatVb: execution.feeSelection.feeRateSatVb,
|
|
90
|
+
});
|
|
91
|
+
},
|
|
92
|
+
async beforePublish({ operation }) {
|
|
93
|
+
if (variant.beforePublish !== undefined) {
|
|
94
|
+
await variant.beforePublish(operation);
|
|
95
|
+
}
|
|
96
|
+
},
|
|
97
|
+
publish({ operation, state, execution, built, mutation }) {
|
|
98
|
+
return publishWalletMutation({
|
|
99
|
+
rpc: execution.rpc,
|
|
100
|
+
walletName: execution.walletName,
|
|
101
|
+
snapshotHeight: execution.readContext.snapshot?.tip?.height ?? null,
|
|
102
|
+
built,
|
|
103
|
+
mutation,
|
|
104
|
+
state,
|
|
105
|
+
provider: execution.provider,
|
|
106
|
+
nowUnixMs: execution.nowUnixMs,
|
|
107
|
+
paths: execution.paths,
|
|
108
|
+
errorPrefix: variant.errorPrefix,
|
|
109
|
+
async afterAccepted({ state: acceptedState, broadcastingMutation, built, nowUnixMs }) {
|
|
110
|
+
return variant.afterAccepted({
|
|
111
|
+
operation,
|
|
112
|
+
acceptedState,
|
|
113
|
+
broadcastingMutation,
|
|
114
|
+
built,
|
|
115
|
+
nowUnixMs,
|
|
116
|
+
snapshot: execution.readContext.snapshot,
|
|
117
|
+
});
|
|
118
|
+
},
|
|
119
|
+
});
|
|
120
|
+
},
|
|
121
|
+
createResult({ operation, mutation, built, status, reusedExisting, fees }) {
|
|
122
|
+
return variant.createResult({
|
|
123
|
+
operation,
|
|
124
|
+
mutation,
|
|
125
|
+
builtTxid: built?.txid ?? null,
|
|
126
|
+
status: status,
|
|
127
|
+
reusedExisting,
|
|
128
|
+
fees,
|
|
129
|
+
});
|
|
130
|
+
},
|
|
131
|
+
});
|
|
132
|
+
return execution.result;
|
|
133
|
+
}
|
|
134
|
+
export async function transferDomain(options) {
|
|
135
|
+
return executeDomainMarketMutation(options, createTransferDomainVariant(options));
|
|
136
|
+
}
|
|
137
|
+
export async function sellDomain(options) {
|
|
138
|
+
if (options.listedPriceCogtoshi < 0n) {
|
|
139
|
+
throw new Error("wallet_sell_invalid_amount");
|
|
140
|
+
}
|
|
141
|
+
return executeDomainMarketMutation(options, createSellDomainVariant(options));
|
|
142
|
+
}
|
|
143
|
+
export async function buyDomain(options) {
|
|
144
|
+
return executeDomainMarketMutation(options, createBuyDomainVariant(options));
|
|
145
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { normalizeBtcTarget } from "../targets.js";
|
|
2
|
+
import type { BuyOperationContext, DomainMarketResolvedBuyerSummary, DomainMarketResolvedEconomicEffect, DomainMarketResolvedRecipientSummary, DomainMarketResolvedSellerSummary, DomainMarketResolvedSenderSummary, DomainOperationContext } from "./types.js";
|
|
3
|
+
export declare function normalizeDomainMarketDomainName(domainName: string): string;
|
|
4
|
+
export declare function parseCogAmountToCogtoshi(raw: string): bigint;
|
|
5
|
+
export declare function createDomainMarketIntentFingerprint(parts: string[]): string;
|
|
6
|
+
export declare function createResolvedDomainMarketSenderSummary(sender: MutationSender, selector: string): DomainMarketResolvedSenderSummary;
|
|
7
|
+
export declare function createResolvedDomainMarketRecipientSummary(recipient: ReturnType<typeof normalizeBtcTarget>): DomainMarketResolvedRecipientSummary;
|
|
8
|
+
export declare function createTransferEconomicEffectSummary(clearsListing: boolean): DomainMarketResolvedEconomicEffect;
|
|
9
|
+
export declare function createSellEconomicEffectSummary(listedPriceCogtoshi: bigint): DomainMarketResolvedEconomicEffect;
|
|
10
|
+
export declare function resolveOwnedDomainOperation(context: WalletReadContext, domainName: string, errorPrefix: string): DomainOperationContext;
|
|
11
|
+
export declare function resolveBuyOperation(context: WalletReadContext, domainName: string, fromIdentity?: string | null): BuyOperationContext;
|
|
12
|
+
export declare function createResolvedBuyerSummary(selector: string, sender: MutationSender): DomainMarketResolvedBuyerSummary;
|
|
13
|
+
export declare function createResolvedSellerSummary(scriptPubKeyHex: string, address: string | null): DomainMarketResolvedSellerSummary;
|
|
14
|
+
import type { WalletReadContext } from "../../read/index.js";
|
|
15
|
+
import type { MutationSender } from "../common.js";
|