@atomiqlabs/chain-starknet 4.0.0-dev.12 → 4.0.0-dev.13
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/LICENSE +201 -201
- package/dist/index.d.ts +38 -38
- package/dist/index.js +54 -54
- package/dist/starknet/StarknetChainType.d.ts +13 -13
- package/dist/starknet/StarknetChainType.js +2 -2
- package/dist/starknet/StarknetInitializer.d.ts +27 -27
- package/dist/starknet/StarknetInitializer.js +69 -69
- package/dist/starknet/btcrelay/BtcRelayAbi.d.ts +250 -250
- package/dist/starknet/btcrelay/BtcRelayAbi.js +341 -341
- package/dist/starknet/btcrelay/StarknetBtcRelay.d.ts +186 -186
- package/dist/starknet/btcrelay/StarknetBtcRelay.js +379 -379
- package/dist/starknet/btcrelay/headers/StarknetBtcHeader.d.ts +31 -31
- package/dist/starknet/btcrelay/headers/StarknetBtcHeader.js +74 -74
- package/dist/starknet/btcrelay/headers/StarknetBtcStoredHeader.d.ts +51 -51
- package/dist/starknet/btcrelay/headers/StarknetBtcStoredHeader.js +113 -113
- package/dist/starknet/chain/StarknetAction.d.ts +19 -19
- package/dist/starknet/chain/StarknetAction.js +73 -73
- package/dist/starknet/chain/StarknetChainInterface.d.ts +52 -52
- package/dist/starknet/chain/StarknetChainInterface.js +91 -91
- package/dist/starknet/chain/StarknetModule.d.ts +14 -14
- package/dist/starknet/chain/StarknetModule.js +13 -13
- package/dist/starknet/chain/modules/ERC20Abi.d.ts +755 -755
- package/dist/starknet/chain/modules/ERC20Abi.js +1032 -1032
- package/dist/starknet/chain/modules/StarknetAccounts.d.ts +6 -6
- package/dist/starknet/chain/modules/StarknetAccounts.js +24 -24
- package/dist/starknet/chain/modules/StarknetAddresses.d.ts +9 -9
- package/dist/starknet/chain/modules/StarknetAddresses.js +26 -26
- package/dist/starknet/chain/modules/StarknetBlocks.d.ts +20 -20
- package/dist/starknet/chain/modules/StarknetBlocks.js +64 -64
- package/dist/starknet/chain/modules/StarknetEvents.d.ts +44 -44
- package/dist/starknet/chain/modules/StarknetEvents.js +88 -88
- package/dist/starknet/chain/modules/StarknetFees.d.ts +77 -77
- package/dist/starknet/chain/modules/StarknetFees.js +114 -114
- package/dist/starknet/chain/modules/StarknetSignatures.d.ts +29 -29
- package/dist/starknet/chain/modules/StarknetSignatures.js +72 -72
- package/dist/starknet/chain/modules/StarknetTokens.d.ts +69 -69
- package/dist/starknet/chain/modules/StarknetTokens.js +102 -98
- package/dist/starknet/chain/modules/StarknetTransactions.d.ts +93 -93
- package/dist/starknet/chain/modules/StarknetTransactions.js +261 -260
- package/dist/starknet/contract/StarknetContractBase.d.ts +13 -13
- package/dist/starknet/contract/StarknetContractBase.js +20 -16
- package/dist/starknet/contract/StarknetContractModule.d.ts +8 -8
- package/dist/starknet/contract/StarknetContractModule.js +11 -11
- package/dist/starknet/contract/modules/StarknetContractEvents.d.ts +51 -51
- package/dist/starknet/contract/modules/StarknetContractEvents.js +97 -97
- package/dist/starknet/events/StarknetChainEvents.d.ts +21 -21
- package/dist/starknet/events/StarknetChainEvents.js +52 -52
- package/dist/starknet/events/StarknetChainEventsBrowser.d.ts +89 -90
- package/dist/starknet/events/StarknetChainEventsBrowser.js +296 -294
- package/dist/starknet/provider/RpcProviderWithRetries.d.ts +21 -21
- package/dist/starknet/provider/RpcProviderWithRetries.js +32 -32
- package/dist/starknet/spv_swap/SpvVaultContractAbi.d.ts +488 -488
- package/dist/starknet/spv_swap/SpvVaultContractAbi.js +656 -656
- package/dist/starknet/spv_swap/StarknetSpvVaultContract.d.ts +66 -66
- package/dist/starknet/spv_swap/StarknetSpvVaultContract.js +382 -382
- package/dist/starknet/spv_swap/StarknetSpvVaultData.d.ts +49 -49
- package/dist/starknet/spv_swap/StarknetSpvVaultData.js +145 -145
- package/dist/starknet/spv_swap/StarknetSpvWithdrawalData.d.ts +25 -25
- package/dist/starknet/spv_swap/StarknetSpvWithdrawalData.js +72 -72
- package/dist/starknet/swaps/EscrowManagerAbi.d.ts +431 -431
- package/dist/starknet/swaps/EscrowManagerAbi.js +583 -583
- package/dist/starknet/swaps/StarknetSwapContract.d.ts +191 -191
- package/dist/starknet/swaps/StarknetSwapContract.js +424 -424
- package/dist/starknet/swaps/StarknetSwapData.d.ts +74 -74
- package/dist/starknet/swaps/StarknetSwapData.js +325 -325
- package/dist/starknet/swaps/StarknetSwapModule.d.ts +10 -10
- package/dist/starknet/swaps/StarknetSwapModule.js +11 -11
- package/dist/starknet/swaps/handlers/IHandler.d.ts +13 -13
- package/dist/starknet/swaps/handlers/IHandler.js +2 -2
- package/dist/starknet/swaps/handlers/claim/ClaimHandlers.d.ts +13 -13
- package/dist/starknet/swaps/handlers/claim/ClaimHandlers.js +13 -13
- package/dist/starknet/swaps/handlers/claim/HashlockClaimHandler.d.ts +21 -21
- package/dist/starknet/swaps/handlers/claim/HashlockClaimHandler.js +44 -44
- package/dist/starknet/swaps/handlers/claim/btc/BitcoinNoncedOutputClaimHandler.d.ts +24 -24
- package/dist/starknet/swaps/handlers/claim/btc/BitcoinNoncedOutputClaimHandler.js +48 -48
- package/dist/starknet/swaps/handlers/claim/btc/BitcoinOutputClaimHandler.d.ts +25 -25
- package/dist/starknet/swaps/handlers/claim/btc/BitcoinOutputClaimHandler.js +40 -40
- package/dist/starknet/swaps/handlers/claim/btc/BitcoinTxIdClaimHandler.d.ts +20 -20
- package/dist/starknet/swaps/handlers/claim/btc/BitcoinTxIdClaimHandler.js +30 -30
- package/dist/starknet/swaps/handlers/claim/btc/IBitcoinClaimHandler.d.ts +45 -45
- package/dist/starknet/swaps/handlers/claim/btc/IBitcoinClaimHandler.js +52 -52
- package/dist/starknet/swaps/handlers/refund/TimelockRefundHandler.d.ts +17 -17
- package/dist/starknet/swaps/handlers/refund/TimelockRefundHandler.js +27 -27
- package/dist/starknet/swaps/modules/StarknetLpVault.d.ts +69 -69
- package/dist/starknet/swaps/modules/StarknetLpVault.js +122 -122
- package/dist/starknet/swaps/modules/StarknetSwapClaim.d.ts +53 -53
- package/dist/starknet/swaps/modules/StarknetSwapClaim.js +100 -100
- package/dist/starknet/swaps/modules/StarknetSwapInit.d.ts +94 -87
- package/dist/starknet/swaps/modules/StarknetSwapInit.js +235 -225
- package/dist/starknet/swaps/modules/StarknetSwapRefund.d.ts +62 -62
- package/dist/starknet/swaps/modules/StarknetSwapRefund.js +128 -128
- package/dist/starknet/wallet/StarknetKeypairWallet.d.ts +7 -7
- package/dist/starknet/wallet/StarknetKeypairWallet.js +35 -30
- package/dist/starknet/wallet/StarknetSigner.d.ts +12 -12
- package/dist/starknet/wallet/StarknetSigner.js +47 -46
- package/dist/utils/Utils.d.ts +37 -37
- package/dist/utils/Utils.js +260 -261
- package/package.json +43 -37
- package/src/index.ts +47 -47
- package/src/starknet/StarknetChainType.ts +28 -28
- package/src/starknet/StarknetInitializer.ts +108 -108
- package/src/starknet/btcrelay/BtcRelayAbi.ts +338 -338
- package/src/starknet/btcrelay/StarknetBtcRelay.ts +494 -494
- package/src/starknet/btcrelay/headers/StarknetBtcHeader.ts +100 -100
- package/src/starknet/btcrelay/headers/StarknetBtcStoredHeader.ts +141 -141
- package/src/starknet/chain/StarknetAction.ts +85 -85
- package/src/starknet/chain/StarknetChainInterface.ts +149 -149
- package/src/starknet/chain/StarknetModule.ts +19 -19
- package/src/starknet/chain/modules/ERC20Abi.ts +1029 -1029
- package/src/starknet/chain/modules/StarknetAccounts.ts +25 -25
- package/src/starknet/chain/modules/StarknetAddresses.ts +22 -22
- package/src/starknet/chain/modules/StarknetBlocks.ts +75 -74
- package/src/starknet/chain/modules/StarknetEvents.ts +104 -104
- package/src/starknet/chain/modules/StarknetFees.ts +154 -154
- package/src/starknet/chain/modules/StarknetSignatures.ts +91 -91
- package/src/starknet/chain/modules/StarknetTokens.ts +120 -116
- package/src/starknet/chain/modules/StarknetTransactions.ts +285 -283
- package/src/starknet/contract/StarknetContractBase.ts +30 -26
- package/src/starknet/contract/StarknetContractModule.ts +16 -16
- package/src/starknet/contract/modules/StarknetContractEvents.ts +134 -134
- package/src/starknet/events/StarknetChainEvents.ts +67 -67
- package/src/starknet/events/StarknetChainEventsBrowser.ts +411 -411
- package/src/starknet/provider/RpcProviderWithRetries.ts +43 -43
- package/src/starknet/spv_swap/SpvVaultContractAbi.ts +656 -656
- package/src/starknet/spv_swap/StarknetSpvVaultContract.ts +483 -483
- package/src/starknet/spv_swap/StarknetSpvVaultData.ts +195 -195
- package/src/starknet/spv_swap/StarknetSpvWithdrawalData.ts +79 -79
- package/src/starknet/swaps/EscrowManagerAbi.ts +582 -582
- package/src/starknet/swaps/StarknetSwapContract.ts +647 -647
- package/src/starknet/swaps/StarknetSwapData.ts +455 -455
- package/src/starknet/swaps/StarknetSwapModule.ts +17 -17
- package/src/starknet/swaps/handlers/IHandler.ts +20 -20
- package/src/starknet/swaps/handlers/claim/ClaimHandlers.ts +23 -23
- package/src/starknet/swaps/handlers/claim/HashlockClaimHandler.ts +53 -53
- package/src/starknet/swaps/handlers/claim/btc/BitcoinNoncedOutputClaimHandler.ts +73 -73
- package/src/starknet/swaps/handlers/claim/btc/BitcoinOutputClaimHandler.ts +67 -67
- package/src/starknet/swaps/handlers/claim/btc/BitcoinTxIdClaimHandler.ts +50 -50
- package/src/starknet/swaps/handlers/claim/btc/IBitcoinClaimHandler.ts +102 -102
- package/src/starknet/swaps/handlers/refund/TimelockRefundHandler.ts +38 -38
- package/src/starknet/swaps/modules/StarknetLpVault.ts +147 -147
- package/src/starknet/swaps/modules/StarknetSwapClaim.ts +141 -141
- package/src/starknet/swaps/modules/StarknetSwapInit.ts +300 -287
- package/src/starknet/swaps/modules/StarknetSwapRefund.ts +196 -196
- package/src/starknet/wallet/StarknetKeypairWallet.ts +44 -39
- package/src/starknet/wallet/StarknetSigner.ts +55 -55
- package/src/utils/Utils.ts +251 -252
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { StarknetSwapContract } from "./StarknetSwapContract";
|
|
2
|
-
import { TypedContractV2 } from "starknet";
|
|
3
|
-
import { EscrowManagerAbi } from "./EscrowManagerAbi";
|
|
4
|
-
import { StarknetChainInterface } from "../chain/StarknetChainInterface";
|
|
5
|
-
import { StarknetContractModule } from "../contract/StarknetContractModule";
|
|
6
|
-
export declare class StarknetSwapModule extends StarknetContractModule<typeof EscrowManagerAbi> {
|
|
7
|
-
readonly contract: StarknetSwapContract;
|
|
8
|
-
readonly swapContract: TypedContractV2<typeof EscrowManagerAbi>;
|
|
9
|
-
constructor(chainInterface: StarknetChainInterface, contract: StarknetSwapContract);
|
|
10
|
-
}
|
|
1
|
+
import { StarknetSwapContract } from "./StarknetSwapContract";
|
|
2
|
+
import { TypedContractV2 } from "starknet";
|
|
3
|
+
import { EscrowManagerAbi } from "./EscrowManagerAbi";
|
|
4
|
+
import { StarknetChainInterface } from "../chain/StarknetChainInterface";
|
|
5
|
+
import { StarknetContractModule } from "../contract/StarknetContractModule";
|
|
6
|
+
export declare class StarknetSwapModule extends StarknetContractModule<typeof EscrowManagerAbi> {
|
|
7
|
+
readonly contract: StarknetSwapContract;
|
|
8
|
+
readonly swapContract: TypedContractV2<typeof EscrowManagerAbi>;
|
|
9
|
+
constructor(chainInterface: StarknetChainInterface, contract: StarknetSwapContract);
|
|
10
|
+
}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.StarknetSwapModule = void 0;
|
|
4
|
-
const StarknetContractModule_1 = require("../contract/StarknetContractModule");
|
|
5
|
-
class StarknetSwapModule extends StarknetContractModule_1.StarknetContractModule {
|
|
6
|
-
constructor(chainInterface, contract) {
|
|
7
|
-
super(chainInterface, contract);
|
|
8
|
-
this.swapContract = contract.contract;
|
|
9
|
-
}
|
|
10
|
-
}
|
|
11
|
-
exports.StarknetSwapModule = StarknetSwapModule;
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.StarknetSwapModule = void 0;
|
|
4
|
+
const StarknetContractModule_1 = require("../contract/StarknetContractModule");
|
|
5
|
+
class StarknetSwapModule extends StarknetContractModule_1.StarknetContractModule {
|
|
6
|
+
constructor(chainInterface, contract) {
|
|
7
|
+
super(chainInterface, contract);
|
|
8
|
+
this.swapContract = contract.contract;
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
exports.StarknetSwapModule = StarknetSwapModule;
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { StarknetSwapData } from "../StarknetSwapData";
|
|
2
|
-
import { BigNumberish } from "starknet";
|
|
3
|
-
import { StarknetTx } from "../../chain/modules/StarknetTransactions";
|
|
4
|
-
import { StarknetGas } from "../../chain/modules/StarknetFees";
|
|
5
|
-
export interface IHandler<TCommitmentData, TWitnessData> {
|
|
6
|
-
readonly address: string;
|
|
7
|
-
getCommitment(data: TCommitmentData): BigNumberish;
|
|
8
|
-
getWitness(signer: string, data: StarknetSwapData, witnessData: TWitnessData, feeRate?: string): Promise<{
|
|
9
|
-
initialTxns: StarknetTx[];
|
|
10
|
-
witness: BigNumberish[];
|
|
11
|
-
}>;
|
|
12
|
-
getGas(data: StarknetSwapData): StarknetGas;
|
|
13
|
-
}
|
|
1
|
+
import { StarknetSwapData } from "../StarknetSwapData";
|
|
2
|
+
import { BigNumberish } from "starknet";
|
|
3
|
+
import { StarknetTx } from "../../chain/modules/StarknetTransactions";
|
|
4
|
+
import { StarknetGas } from "../../chain/modules/StarknetFees";
|
|
5
|
+
export interface IHandler<TCommitmentData, TWitnessData> {
|
|
6
|
+
readonly address: string;
|
|
7
|
+
getCommitment(data: TCommitmentData): BigNumberish;
|
|
8
|
+
getWitness(signer: string, data: StarknetSwapData, witnessData: TWitnessData, feeRate?: string): Promise<{
|
|
9
|
+
initialTxns: StarknetTx[];
|
|
10
|
+
witness: BigNumberish[];
|
|
11
|
+
}>;
|
|
12
|
+
getGas(data: StarknetSwapData): StarknetGas;
|
|
13
|
+
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { ChainSwapType } from "@atomiqlabs/base";
|
|
2
|
-
import { IHandler } from "../IHandler";
|
|
3
|
-
import { BigNumberish } from "starknet";
|
|
4
|
-
import { StarknetGas } from "../../../chain/modules/StarknetFees";
|
|
5
|
-
export interface IClaimHandler<C, W> extends IHandler<C, W> {
|
|
6
|
-
getType(): ChainSwapType;
|
|
7
|
-
parseWitnessResult(result: BigNumberish[]): string;
|
|
8
|
-
}
|
|
9
|
-
export type ClaimHandlerType = {
|
|
10
|
-
gas: StarknetGas;
|
|
11
|
-
type: ChainSwapType;
|
|
12
|
-
} & (new (address: string) => IClaimHandler<any, any>);
|
|
13
|
-
export declare const claimHandlersList: ClaimHandlerType[];
|
|
1
|
+
import { ChainSwapType } from "@atomiqlabs/base";
|
|
2
|
+
import { IHandler } from "../IHandler";
|
|
3
|
+
import { BigNumberish } from "starknet";
|
|
4
|
+
import { StarknetGas } from "../../../chain/modules/StarknetFees";
|
|
5
|
+
export interface IClaimHandler<C, W> extends IHandler<C, W> {
|
|
6
|
+
getType(): ChainSwapType;
|
|
7
|
+
parseWitnessResult(result: BigNumberish[]): string;
|
|
8
|
+
}
|
|
9
|
+
export type ClaimHandlerType = {
|
|
10
|
+
gas: StarknetGas;
|
|
11
|
+
type: ChainSwapType;
|
|
12
|
+
} & (new (address: string) => IClaimHandler<any, any>);
|
|
13
|
+
export declare const claimHandlersList: ClaimHandlerType[];
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.claimHandlersList = void 0;
|
|
4
|
-
const HashlockClaimHandler_1 = require("./HashlockClaimHandler");
|
|
5
|
-
const BitcoinTxIdClaimHandler_1 = require("./btc/BitcoinTxIdClaimHandler");
|
|
6
|
-
const BitcoinOutputClaimHandler_1 = require("./btc/BitcoinOutputClaimHandler");
|
|
7
|
-
const BitcoinNoncedOutputClaimHandler_1 = require("./btc/BitcoinNoncedOutputClaimHandler");
|
|
8
|
-
exports.claimHandlersList = [
|
|
9
|
-
HashlockClaimHandler_1.HashlockClaimHandler,
|
|
10
|
-
BitcoinTxIdClaimHandler_1.BitcoinTxIdClaimHandler,
|
|
11
|
-
BitcoinOutputClaimHandler_1.BitcoinOutputClaimHandler,
|
|
12
|
-
BitcoinNoncedOutputClaimHandler_1.BitcoinNoncedOutputClaimHandler
|
|
13
|
-
];
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.claimHandlersList = void 0;
|
|
4
|
+
const HashlockClaimHandler_1 = require("./HashlockClaimHandler");
|
|
5
|
+
const BitcoinTxIdClaimHandler_1 = require("./btc/BitcoinTxIdClaimHandler");
|
|
6
|
+
const BitcoinOutputClaimHandler_1 = require("./btc/BitcoinOutputClaimHandler");
|
|
7
|
+
const BitcoinNoncedOutputClaimHandler_1 = require("./btc/BitcoinNoncedOutputClaimHandler");
|
|
8
|
+
exports.claimHandlersList = [
|
|
9
|
+
HashlockClaimHandler_1.HashlockClaimHandler,
|
|
10
|
+
BitcoinTxIdClaimHandler_1.BitcoinTxIdClaimHandler,
|
|
11
|
+
BitcoinOutputClaimHandler_1.BitcoinOutputClaimHandler,
|
|
12
|
+
BitcoinNoncedOutputClaimHandler_1.BitcoinNoncedOutputClaimHandler
|
|
13
|
+
];
|
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
import { StarknetSwapData } from "../../StarknetSwapData";
|
|
2
|
-
import { BigNumberish } from "starknet";
|
|
3
|
-
import { ChainSwapType } from "@atomiqlabs/base";
|
|
4
|
-
import { Buffer } from "buffer";
|
|
5
|
-
import { StarknetTx } from "../../../chain/modules/StarknetTransactions";
|
|
6
|
-
import { IClaimHandler } from "./ClaimHandlers";
|
|
7
|
-
import { StarknetGas } from "../../../chain/modules/StarknetFees";
|
|
8
|
-
export declare class HashlockClaimHandler implements IClaimHandler<Buffer, string> {
|
|
9
|
-
readonly address: string;
|
|
10
|
-
static readonly type: ChainSwapType;
|
|
11
|
-
static readonly gas: StarknetGas;
|
|
12
|
-
constructor(address: string);
|
|
13
|
-
getCommitment(data: Buffer): BigNumberish;
|
|
14
|
-
getWitness(signer: string, data: StarknetSwapData, witnessData: string): Promise<{
|
|
15
|
-
initialTxns: StarknetTx[];
|
|
16
|
-
witness: BigNumberish[];
|
|
17
|
-
}>;
|
|
18
|
-
getGas(): StarknetGas;
|
|
19
|
-
getType(): ChainSwapType;
|
|
20
|
-
parseWitnessResult(result: BigNumberish[]): string;
|
|
21
|
-
}
|
|
1
|
+
import { StarknetSwapData } from "../../StarknetSwapData";
|
|
2
|
+
import { BigNumberish } from "starknet";
|
|
3
|
+
import { ChainSwapType } from "@atomiqlabs/base";
|
|
4
|
+
import { Buffer } from "buffer";
|
|
5
|
+
import { StarknetTx } from "../../../chain/modules/StarknetTransactions";
|
|
6
|
+
import { IClaimHandler } from "./ClaimHandlers";
|
|
7
|
+
import { StarknetGas } from "../../../chain/modules/StarknetFees";
|
|
8
|
+
export declare class HashlockClaimHandler implements IClaimHandler<Buffer, string> {
|
|
9
|
+
readonly address: string;
|
|
10
|
+
static readonly type: ChainSwapType;
|
|
11
|
+
static readonly gas: StarknetGas;
|
|
12
|
+
constructor(address: string);
|
|
13
|
+
getCommitment(data: Buffer): BigNumberish;
|
|
14
|
+
getWitness(signer: string, data: StarknetSwapData, witnessData: string): Promise<{
|
|
15
|
+
initialTxns: StarknetTx[];
|
|
16
|
+
witness: BigNumberish[];
|
|
17
|
+
}>;
|
|
18
|
+
getGas(): StarknetGas;
|
|
19
|
+
getType(): ChainSwapType;
|
|
20
|
+
parseWitnessResult(result: BigNumberish[]): string;
|
|
21
|
+
}
|
|
@@ -1,44 +1,44 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.HashlockClaimHandler = void 0;
|
|
4
|
-
const Utils_1 = require("../../../../utils/Utils");
|
|
5
|
-
const starknet_1 = require("starknet");
|
|
6
|
-
const base_1 = require("@atomiqlabs/base");
|
|
7
|
-
const buffer_1 = require("buffer");
|
|
8
|
-
const sha2_1 = require("@noble/hashes/sha2");
|
|
9
|
-
class HashlockClaimHandler {
|
|
10
|
-
constructor(address) {
|
|
11
|
-
this.address = address;
|
|
12
|
-
}
|
|
13
|
-
getCommitment(data) {
|
|
14
|
-
if (data.length !== 32)
|
|
15
|
-
throw new Error("Invalid swap hash");
|
|
16
|
-
return starknet_1.hash.computePoseidonHashOnElements((0, Utils_1.bufferToU32Array)(data));
|
|
17
|
-
}
|
|
18
|
-
getWitness(signer, data, witnessData) {
|
|
19
|
-
if (!data.isClaimHandler(this.address))
|
|
20
|
-
throw new Error("Invalid claim handler");
|
|
21
|
-
if (witnessData.length !== 64)
|
|
22
|
-
throw new Error("Invalid hash secret: string length");
|
|
23
|
-
const buffer = buffer_1.Buffer.from(witnessData, "hex");
|
|
24
|
-
if (buffer.length !== 32)
|
|
25
|
-
throw new Error("Invalid hash secret: buff length");
|
|
26
|
-
const witnessSha256 = buffer_1.Buffer.from((0, sha2_1.sha256)(buffer));
|
|
27
|
-
if (!data.isClaimData((0, Utils_1.toHex)(this.getCommitment(witnessSha256))))
|
|
28
|
-
throw new Error("Invalid hash secret: poseidon hash doesn't match");
|
|
29
|
-
const witnessArray = (0, Utils_1.bufferToU32Array)(buffer);
|
|
30
|
-
return Promise.resolve({ initialTxns: [], witness: witnessArray });
|
|
31
|
-
}
|
|
32
|
-
getGas() {
|
|
33
|
-
return HashlockClaimHandler.gas;
|
|
34
|
-
}
|
|
35
|
-
getType() {
|
|
36
|
-
return HashlockClaimHandler.type;
|
|
37
|
-
}
|
|
38
|
-
parseWitnessResult(result) {
|
|
39
|
-
return (0, Utils_1.u32ArrayToBuffer)(result).toString("hex");
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
exports.HashlockClaimHandler = HashlockClaimHandler;
|
|
43
|
-
HashlockClaimHandler.type = base_1.ChainSwapType.HTLC;
|
|
44
|
-
HashlockClaimHandler.gas = { l1DataGas: 0, l2Gas: 800 * 40000, l1Gas: 0 };
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.HashlockClaimHandler = void 0;
|
|
4
|
+
const Utils_1 = require("../../../../utils/Utils");
|
|
5
|
+
const starknet_1 = require("starknet");
|
|
6
|
+
const base_1 = require("@atomiqlabs/base");
|
|
7
|
+
const buffer_1 = require("buffer");
|
|
8
|
+
const sha2_1 = require("@noble/hashes/sha2");
|
|
9
|
+
class HashlockClaimHandler {
|
|
10
|
+
constructor(address) {
|
|
11
|
+
this.address = address;
|
|
12
|
+
}
|
|
13
|
+
getCommitment(data) {
|
|
14
|
+
if (data.length !== 32)
|
|
15
|
+
throw new Error("Invalid swap hash");
|
|
16
|
+
return starknet_1.hash.computePoseidonHashOnElements((0, Utils_1.bufferToU32Array)(data));
|
|
17
|
+
}
|
|
18
|
+
getWitness(signer, data, witnessData) {
|
|
19
|
+
if (!data.isClaimHandler(this.address))
|
|
20
|
+
throw new Error("Invalid claim handler");
|
|
21
|
+
if (witnessData.length !== 64)
|
|
22
|
+
throw new Error("Invalid hash secret: string length");
|
|
23
|
+
const buffer = buffer_1.Buffer.from(witnessData, "hex");
|
|
24
|
+
if (buffer.length !== 32)
|
|
25
|
+
throw new Error("Invalid hash secret: buff length");
|
|
26
|
+
const witnessSha256 = buffer_1.Buffer.from((0, sha2_1.sha256)(buffer));
|
|
27
|
+
if (!data.isClaimData((0, Utils_1.toHex)(this.getCommitment(witnessSha256))))
|
|
28
|
+
throw new Error("Invalid hash secret: poseidon hash doesn't match");
|
|
29
|
+
const witnessArray = (0, Utils_1.bufferToU32Array)(buffer);
|
|
30
|
+
return Promise.resolve({ initialTxns: [], witness: witnessArray });
|
|
31
|
+
}
|
|
32
|
+
getGas() {
|
|
33
|
+
return HashlockClaimHandler.gas;
|
|
34
|
+
}
|
|
35
|
+
getType() {
|
|
36
|
+
return HashlockClaimHandler.type;
|
|
37
|
+
}
|
|
38
|
+
parseWitnessResult(result) {
|
|
39
|
+
return (0, Utils_1.u32ArrayToBuffer)(result).toString("hex");
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
exports.HashlockClaimHandler = HashlockClaimHandler;
|
|
43
|
+
HashlockClaimHandler.type = base_1.ChainSwapType.HTLC;
|
|
44
|
+
HashlockClaimHandler.gas = { l1DataGas: 0, l2Gas: 800 * 40000, l1Gas: 0 };
|
|
@@ -1,24 +1,24 @@
|
|
|
1
|
-
import { StarknetSwapData } from "../../../StarknetSwapData";
|
|
2
|
-
import { ChainSwapType } from "@atomiqlabs/base";
|
|
3
|
-
import { BigNumberish } from "starknet";
|
|
4
|
-
import { StarknetTx } from "../../../../chain/modules/StarknetTransactions";
|
|
5
|
-
import { BitcoinCommitmentData, IBitcoinClaimHandler } from "./IBitcoinClaimHandler";
|
|
6
|
-
import { BitcoinOutputWitnessData } from "./BitcoinOutputClaimHandler";
|
|
7
|
-
import { Buffer } from "buffer";
|
|
8
|
-
import { StarknetGas } from "../../../../chain/modules/StarknetFees";
|
|
9
|
-
export type BitcoinNoncedOutputCommitmentData = {
|
|
10
|
-
output: Buffer;
|
|
11
|
-
amount: bigint;
|
|
12
|
-
nonce: bigint;
|
|
13
|
-
};
|
|
14
|
-
export declare class BitcoinNoncedOutputClaimHandler extends IBitcoinClaimHandler<BitcoinNoncedOutputCommitmentData, BitcoinOutputWitnessData> {
|
|
15
|
-
static readonly type: ChainSwapType;
|
|
16
|
-
static readonly gas: StarknetGas;
|
|
17
|
-
protected serializeCommitment(data: BitcoinNoncedOutputCommitmentData & BitcoinCommitmentData): BigNumberish[];
|
|
18
|
-
getWitness(signer: string, swapData: StarknetSwapData, witnessData: BitcoinOutputWitnessData, feeRate?: string): Promise<{
|
|
19
|
-
initialTxns: StarknetTx[];
|
|
20
|
-
witness: BigNumberish[];
|
|
21
|
-
}>;
|
|
22
|
-
getGas(data: StarknetSwapData): StarknetGas;
|
|
23
|
-
getType(): ChainSwapType;
|
|
24
|
-
}
|
|
1
|
+
import { StarknetSwapData } from "../../../StarknetSwapData";
|
|
2
|
+
import { ChainSwapType } from "@atomiqlabs/base";
|
|
3
|
+
import { BigNumberish } from "starknet";
|
|
4
|
+
import { StarknetTx } from "../../../../chain/modules/StarknetTransactions";
|
|
5
|
+
import { BitcoinCommitmentData, IBitcoinClaimHandler } from "./IBitcoinClaimHandler";
|
|
6
|
+
import { BitcoinOutputWitnessData } from "./BitcoinOutputClaimHandler";
|
|
7
|
+
import { Buffer } from "buffer";
|
|
8
|
+
import { StarknetGas } from "../../../../chain/modules/StarknetFees";
|
|
9
|
+
export type BitcoinNoncedOutputCommitmentData = {
|
|
10
|
+
output: Buffer;
|
|
11
|
+
amount: bigint;
|
|
12
|
+
nonce: bigint;
|
|
13
|
+
};
|
|
14
|
+
export declare class BitcoinNoncedOutputClaimHandler extends IBitcoinClaimHandler<BitcoinNoncedOutputCommitmentData, BitcoinOutputWitnessData> {
|
|
15
|
+
static readonly type: ChainSwapType;
|
|
16
|
+
static readonly gas: StarknetGas;
|
|
17
|
+
protected serializeCommitment(data: BitcoinNoncedOutputCommitmentData & BitcoinCommitmentData): BigNumberish[];
|
|
18
|
+
getWitness(signer: string, swapData: StarknetSwapData, witnessData: BitcoinOutputWitnessData, feeRate?: string): Promise<{
|
|
19
|
+
initialTxns: StarknetTx[];
|
|
20
|
+
witness: BigNumberish[];
|
|
21
|
+
}>;
|
|
22
|
+
getGas(data: StarknetSwapData): StarknetGas;
|
|
23
|
+
getType(): ChainSwapType;
|
|
24
|
+
}
|
|
@@ -1,48 +1,48 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.BitcoinNoncedOutputClaimHandler = void 0;
|
|
4
|
-
const base_1 = require("@atomiqlabs/base");
|
|
5
|
-
const starknet_1 = require("starknet");
|
|
6
|
-
const Utils_1 = require("../../../../../utils/Utils");
|
|
7
|
-
const IBitcoinClaimHandler_1 = require("./IBitcoinClaimHandler");
|
|
8
|
-
const btc_signer_1 = require("@scure/btc-signer");
|
|
9
|
-
const buffer_1 = require("buffer");
|
|
10
|
-
const logger = (0, Utils_1.getLogger)("BitcoinNoncedOutputClaimHandler: ");
|
|
11
|
-
function getTransactionNonce(btcTx) {
|
|
12
|
-
const locktimeSub500M = BigInt(btcTx.lockTime - 500000000);
|
|
13
|
-
if (locktimeSub500M < 0n)
|
|
14
|
-
throw new Error("Locktime too low!");
|
|
15
|
-
const nSequence = BigInt(btcTx.getInput(0).sequence);
|
|
16
|
-
return (locktimeSub500M << 24n) | (nSequence & 0x00ffffffn);
|
|
17
|
-
}
|
|
18
|
-
class BitcoinNoncedOutputClaimHandler extends IBitcoinClaimHandler_1.IBitcoinClaimHandler {
|
|
19
|
-
serializeCommitment(data) {
|
|
20
|
-
return [
|
|
21
|
-
starknet_1.hash.computePoseidonHashOnElements([(0, Utils_1.toBigInt)(data.nonce), (0, Utils_1.toBigInt)(data.amount), (0, Utils_1.poseidonHashRange)(data.output)]),
|
|
22
|
-
...super.serializeCommitment(data)
|
|
23
|
-
];
|
|
24
|
-
}
|
|
25
|
-
async getWitness(signer, swapData, witnessData, feeRate) {
|
|
26
|
-
if (!swapData.isClaimHandler(this.address))
|
|
27
|
-
throw new Error("Invalid claim handler");
|
|
28
|
-
const parsedBtcTx = btc_signer_1.Transaction.fromRaw(buffer_1.Buffer.from(witnessData.tx.hex, "hex"));
|
|
29
|
-
const out = parsedBtcTx.getOutput(witnessData.vout);
|
|
30
|
-
const { initialTxns, witness } = await this._getWitness(signer, swapData, witnessData, {
|
|
31
|
-
output: buffer_1.Buffer.from(out.script),
|
|
32
|
-
amount: out.amount,
|
|
33
|
-
nonce: getTransactionNonce(parsedBtcTx)
|
|
34
|
-
});
|
|
35
|
-
witness.push(...(0, Utils_1.bufferToByteArray)(buffer_1.Buffer.from(witnessData.tx.hex, "hex")));
|
|
36
|
-
witness.push(BigInt(witnessData.vout));
|
|
37
|
-
return { initialTxns, witness };
|
|
38
|
-
}
|
|
39
|
-
getGas(data) {
|
|
40
|
-
return BitcoinNoncedOutputClaimHandler.gas;
|
|
41
|
-
}
|
|
42
|
-
getType() {
|
|
43
|
-
return BitcoinNoncedOutputClaimHandler.type;
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
exports.BitcoinNoncedOutputClaimHandler = BitcoinNoncedOutputClaimHandler;
|
|
47
|
-
BitcoinNoncedOutputClaimHandler.type = base_1.ChainSwapType.CHAIN_NONCED;
|
|
48
|
-
BitcoinNoncedOutputClaimHandler.gas = { l1DataGas: 0, l2Gas: 20000 * 40000, l1Gas: 0 };
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.BitcoinNoncedOutputClaimHandler = void 0;
|
|
4
|
+
const base_1 = require("@atomiqlabs/base");
|
|
5
|
+
const starknet_1 = require("starknet");
|
|
6
|
+
const Utils_1 = require("../../../../../utils/Utils");
|
|
7
|
+
const IBitcoinClaimHandler_1 = require("./IBitcoinClaimHandler");
|
|
8
|
+
const btc_signer_1 = require("@scure/btc-signer");
|
|
9
|
+
const buffer_1 = require("buffer");
|
|
10
|
+
const logger = (0, Utils_1.getLogger)("BitcoinNoncedOutputClaimHandler: ");
|
|
11
|
+
function getTransactionNonce(btcTx) {
|
|
12
|
+
const locktimeSub500M = BigInt(btcTx.lockTime - 500000000);
|
|
13
|
+
if (locktimeSub500M < 0n)
|
|
14
|
+
throw new Error("Locktime too low!");
|
|
15
|
+
const nSequence = BigInt(btcTx.getInput(0).sequence);
|
|
16
|
+
return (locktimeSub500M << 24n) | (nSequence & 0x00ffffffn);
|
|
17
|
+
}
|
|
18
|
+
class BitcoinNoncedOutputClaimHandler extends IBitcoinClaimHandler_1.IBitcoinClaimHandler {
|
|
19
|
+
serializeCommitment(data) {
|
|
20
|
+
return [
|
|
21
|
+
starknet_1.hash.computePoseidonHashOnElements([(0, Utils_1.toBigInt)(data.nonce), (0, Utils_1.toBigInt)(data.amount), (0, Utils_1.poseidonHashRange)(data.output)]),
|
|
22
|
+
...super.serializeCommitment(data)
|
|
23
|
+
];
|
|
24
|
+
}
|
|
25
|
+
async getWitness(signer, swapData, witnessData, feeRate) {
|
|
26
|
+
if (!swapData.isClaimHandler(this.address))
|
|
27
|
+
throw new Error("Invalid claim handler");
|
|
28
|
+
const parsedBtcTx = btc_signer_1.Transaction.fromRaw(buffer_1.Buffer.from(witnessData.tx.hex, "hex"));
|
|
29
|
+
const out = parsedBtcTx.getOutput(witnessData.vout);
|
|
30
|
+
const { initialTxns, witness } = await this._getWitness(signer, swapData, witnessData, {
|
|
31
|
+
output: buffer_1.Buffer.from(out.script),
|
|
32
|
+
amount: out.amount,
|
|
33
|
+
nonce: getTransactionNonce(parsedBtcTx)
|
|
34
|
+
});
|
|
35
|
+
witness.push(...(0, Utils_1.bufferToByteArray)(buffer_1.Buffer.from(witnessData.tx.hex, "hex")));
|
|
36
|
+
witness.push(BigInt(witnessData.vout));
|
|
37
|
+
return { initialTxns, witness };
|
|
38
|
+
}
|
|
39
|
+
getGas(data) {
|
|
40
|
+
return BitcoinNoncedOutputClaimHandler.gas;
|
|
41
|
+
}
|
|
42
|
+
getType() {
|
|
43
|
+
return BitcoinNoncedOutputClaimHandler.type;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
exports.BitcoinNoncedOutputClaimHandler = BitcoinNoncedOutputClaimHandler;
|
|
47
|
+
BitcoinNoncedOutputClaimHandler.type = base_1.ChainSwapType.CHAIN_NONCED;
|
|
48
|
+
BitcoinNoncedOutputClaimHandler.gas = { l1DataGas: 0, l2Gas: 20000 * 40000, l1Gas: 0 };
|
|
@@ -1,25 +1,25 @@
|
|
|
1
|
-
import { StarknetSwapData } from "../../../StarknetSwapData";
|
|
2
|
-
import { ChainSwapType } from "@atomiqlabs/base";
|
|
3
|
-
import { BigNumberish } from "starknet";
|
|
4
|
-
import { StarknetTx } from "../../../../chain/modules/StarknetTransactions";
|
|
5
|
-
import { BitcoinCommitmentData, BitcoinWitnessData, IBitcoinClaimHandler } from "./IBitcoinClaimHandler";
|
|
6
|
-
import { Buffer } from "buffer";
|
|
7
|
-
import { StarknetGas } from "../../../../chain/modules/StarknetFees";
|
|
8
|
-
export type BitcoinOutputCommitmentData = {
|
|
9
|
-
output: Buffer;
|
|
10
|
-
amount: bigint;
|
|
11
|
-
};
|
|
12
|
-
export type BitcoinOutputWitnessData = BitcoinWitnessData & {
|
|
13
|
-
vout: number;
|
|
14
|
-
};
|
|
15
|
-
export declare class BitcoinOutputClaimHandler extends IBitcoinClaimHandler<BitcoinOutputCommitmentData, BitcoinOutputWitnessData> {
|
|
16
|
-
static readonly type: ChainSwapType;
|
|
17
|
-
static readonly gas: StarknetGas;
|
|
18
|
-
protected serializeCommitment(data: BitcoinOutputCommitmentData & BitcoinCommitmentData): BigNumberish[];
|
|
19
|
-
getWitness(signer: string, swapData: StarknetSwapData, witnessData: BitcoinOutputWitnessData, feeRate?: string): Promise<{
|
|
20
|
-
initialTxns: StarknetTx[];
|
|
21
|
-
witness: BigNumberish[];
|
|
22
|
-
}>;
|
|
23
|
-
getGas(data: StarknetSwapData): StarknetGas;
|
|
24
|
-
getType(): ChainSwapType;
|
|
25
|
-
}
|
|
1
|
+
import { StarknetSwapData } from "../../../StarknetSwapData";
|
|
2
|
+
import { ChainSwapType } from "@atomiqlabs/base";
|
|
3
|
+
import { BigNumberish } from "starknet";
|
|
4
|
+
import { StarknetTx } from "../../../../chain/modules/StarknetTransactions";
|
|
5
|
+
import { BitcoinCommitmentData, BitcoinWitnessData, IBitcoinClaimHandler } from "./IBitcoinClaimHandler";
|
|
6
|
+
import { Buffer } from "buffer";
|
|
7
|
+
import { StarknetGas } from "../../../../chain/modules/StarknetFees";
|
|
8
|
+
export type BitcoinOutputCommitmentData = {
|
|
9
|
+
output: Buffer;
|
|
10
|
+
amount: bigint;
|
|
11
|
+
};
|
|
12
|
+
export type BitcoinOutputWitnessData = BitcoinWitnessData & {
|
|
13
|
+
vout: number;
|
|
14
|
+
};
|
|
15
|
+
export declare class BitcoinOutputClaimHandler extends IBitcoinClaimHandler<BitcoinOutputCommitmentData, BitcoinOutputWitnessData> {
|
|
16
|
+
static readonly type: ChainSwapType;
|
|
17
|
+
static readonly gas: StarknetGas;
|
|
18
|
+
protected serializeCommitment(data: BitcoinOutputCommitmentData & BitcoinCommitmentData): BigNumberish[];
|
|
19
|
+
getWitness(signer: string, swapData: StarknetSwapData, witnessData: BitcoinOutputWitnessData, feeRate?: string): Promise<{
|
|
20
|
+
initialTxns: StarknetTx[];
|
|
21
|
+
witness: BigNumberish[];
|
|
22
|
+
}>;
|
|
23
|
+
getGas(data: StarknetSwapData): StarknetGas;
|
|
24
|
+
getType(): ChainSwapType;
|
|
25
|
+
}
|
|
@@ -1,40 +1,40 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.BitcoinOutputClaimHandler = void 0;
|
|
4
|
-
const base_1 = require("@atomiqlabs/base");
|
|
5
|
-
const starknet_1 = require("starknet");
|
|
6
|
-
const Utils_1 = require("../../../../../utils/Utils");
|
|
7
|
-
const IBitcoinClaimHandler_1 = require("./IBitcoinClaimHandler");
|
|
8
|
-
const btc_signer_1 = require("@scure/btc-signer");
|
|
9
|
-
const buffer_1 = require("buffer");
|
|
10
|
-
const logger = (0, Utils_1.getLogger)("BitcoinOutputClaimHandler: ");
|
|
11
|
-
class BitcoinOutputClaimHandler extends IBitcoinClaimHandler_1.IBitcoinClaimHandler {
|
|
12
|
-
serializeCommitment(data) {
|
|
13
|
-
return [
|
|
14
|
-
starknet_1.hash.computePoseidonHashOnElements([(0, Utils_1.toBigInt)(data.amount), (0, Utils_1.poseidonHashRange)(data.output)]),
|
|
15
|
-
...super.serializeCommitment(data)
|
|
16
|
-
];
|
|
17
|
-
}
|
|
18
|
-
async getWitness(signer, swapData, witnessData, feeRate) {
|
|
19
|
-
if (!swapData.isClaimHandler(this.address))
|
|
20
|
-
throw new Error("Invalid claim handler");
|
|
21
|
-
const parsedBtcTx = btc_signer_1.Transaction.fromRaw(buffer_1.Buffer.from(witnessData.tx.hex, "hex"));
|
|
22
|
-
const out = parsedBtcTx.getOutput(witnessData.vout);
|
|
23
|
-
const { initialTxns, witness } = await this._getWitness(signer, swapData, witnessData, {
|
|
24
|
-
output: buffer_1.Buffer.from(out.script),
|
|
25
|
-
amount: out.amount
|
|
26
|
-
});
|
|
27
|
-
witness.push(...(0, Utils_1.bufferToByteArray)(buffer_1.Buffer.from(witnessData.tx.hex, "hex")));
|
|
28
|
-
witness.push(BigInt(witnessData.vout));
|
|
29
|
-
return { initialTxns, witness };
|
|
30
|
-
}
|
|
31
|
-
getGas(data) {
|
|
32
|
-
return BitcoinOutputClaimHandler.gas;
|
|
33
|
-
}
|
|
34
|
-
getType() {
|
|
35
|
-
return BitcoinOutputClaimHandler.type;
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
exports.BitcoinOutputClaimHandler = BitcoinOutputClaimHandler;
|
|
39
|
-
BitcoinOutputClaimHandler.type = base_1.ChainSwapType.CHAIN;
|
|
40
|
-
BitcoinOutputClaimHandler.gas = { l1DataGas: 0, l2Gas: 20000 * 40000, l1Gas: 0 };
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.BitcoinOutputClaimHandler = void 0;
|
|
4
|
+
const base_1 = require("@atomiqlabs/base");
|
|
5
|
+
const starknet_1 = require("starknet");
|
|
6
|
+
const Utils_1 = require("../../../../../utils/Utils");
|
|
7
|
+
const IBitcoinClaimHandler_1 = require("./IBitcoinClaimHandler");
|
|
8
|
+
const btc_signer_1 = require("@scure/btc-signer");
|
|
9
|
+
const buffer_1 = require("buffer");
|
|
10
|
+
const logger = (0, Utils_1.getLogger)("BitcoinOutputClaimHandler: ");
|
|
11
|
+
class BitcoinOutputClaimHandler extends IBitcoinClaimHandler_1.IBitcoinClaimHandler {
|
|
12
|
+
serializeCommitment(data) {
|
|
13
|
+
return [
|
|
14
|
+
starknet_1.hash.computePoseidonHashOnElements([(0, Utils_1.toBigInt)(data.amount), (0, Utils_1.poseidonHashRange)(data.output)]),
|
|
15
|
+
...super.serializeCommitment(data)
|
|
16
|
+
];
|
|
17
|
+
}
|
|
18
|
+
async getWitness(signer, swapData, witnessData, feeRate) {
|
|
19
|
+
if (!swapData.isClaimHandler(this.address))
|
|
20
|
+
throw new Error("Invalid claim handler");
|
|
21
|
+
const parsedBtcTx = btc_signer_1.Transaction.fromRaw(buffer_1.Buffer.from(witnessData.tx.hex, "hex"));
|
|
22
|
+
const out = parsedBtcTx.getOutput(witnessData.vout);
|
|
23
|
+
const { initialTxns, witness } = await this._getWitness(signer, swapData, witnessData, {
|
|
24
|
+
output: buffer_1.Buffer.from(out.script),
|
|
25
|
+
amount: out.amount
|
|
26
|
+
});
|
|
27
|
+
witness.push(...(0, Utils_1.bufferToByteArray)(buffer_1.Buffer.from(witnessData.tx.hex, "hex")));
|
|
28
|
+
witness.push(BigInt(witnessData.vout));
|
|
29
|
+
return { initialTxns, witness };
|
|
30
|
+
}
|
|
31
|
+
getGas(data) {
|
|
32
|
+
return BitcoinOutputClaimHandler.gas;
|
|
33
|
+
}
|
|
34
|
+
getType() {
|
|
35
|
+
return BitcoinOutputClaimHandler.type;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
exports.BitcoinOutputClaimHandler = BitcoinOutputClaimHandler;
|
|
39
|
+
BitcoinOutputClaimHandler.type = base_1.ChainSwapType.CHAIN;
|
|
40
|
+
BitcoinOutputClaimHandler.gas = { l1DataGas: 0, l2Gas: 20000 * 40000, l1Gas: 0 };
|
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
import { StarknetSwapData } from "../../../StarknetSwapData";
|
|
2
|
-
import { ChainSwapType } from "@atomiqlabs/base";
|
|
3
|
-
import { BigNumberish } from "starknet";
|
|
4
|
-
import { StarknetTx } from "../../../../chain/modules/StarknetTransactions";
|
|
5
|
-
import { BitcoinCommitmentData, BitcoinWitnessData, IBitcoinClaimHandler } from "./IBitcoinClaimHandler";
|
|
6
|
-
import { StarknetGas } from "../../../../chain/modules/StarknetFees";
|
|
7
|
-
export type BitcoinTxIdCommitmentData = {
|
|
8
|
-
txId: string;
|
|
9
|
-
};
|
|
10
|
-
export declare class BitcoinTxIdClaimHandler extends IBitcoinClaimHandler<BitcoinTxIdCommitmentData, BitcoinWitnessData> {
|
|
11
|
-
static readonly type: ChainSwapType;
|
|
12
|
-
static readonly gas: StarknetGas;
|
|
13
|
-
protected serializeCommitment(data: BitcoinTxIdCommitmentData & BitcoinCommitmentData): BigNumberish[];
|
|
14
|
-
getWitness(signer: string, swapData: StarknetSwapData, witnessData: BitcoinWitnessData, feeRate?: string): Promise<{
|
|
15
|
-
initialTxns: StarknetTx[];
|
|
16
|
-
witness: BigNumberish[];
|
|
17
|
-
}>;
|
|
18
|
-
getGas(data: StarknetSwapData): StarknetGas;
|
|
19
|
-
getType(): ChainSwapType;
|
|
20
|
-
}
|
|
1
|
+
import { StarknetSwapData } from "../../../StarknetSwapData";
|
|
2
|
+
import { ChainSwapType } from "@atomiqlabs/base";
|
|
3
|
+
import { BigNumberish } from "starknet";
|
|
4
|
+
import { StarknetTx } from "../../../../chain/modules/StarknetTransactions";
|
|
5
|
+
import { BitcoinCommitmentData, BitcoinWitnessData, IBitcoinClaimHandler } from "./IBitcoinClaimHandler";
|
|
6
|
+
import { StarknetGas } from "../../../../chain/modules/StarknetFees";
|
|
7
|
+
export type BitcoinTxIdCommitmentData = {
|
|
8
|
+
txId: string;
|
|
9
|
+
};
|
|
10
|
+
export declare class BitcoinTxIdClaimHandler extends IBitcoinClaimHandler<BitcoinTxIdCommitmentData, BitcoinWitnessData> {
|
|
11
|
+
static readonly type: ChainSwapType;
|
|
12
|
+
static readonly gas: StarknetGas;
|
|
13
|
+
protected serializeCommitment(data: BitcoinTxIdCommitmentData & BitcoinCommitmentData): BigNumberish[];
|
|
14
|
+
getWitness(signer: string, swapData: StarknetSwapData, witnessData: BitcoinWitnessData, feeRate?: string): Promise<{
|
|
15
|
+
initialTxns: StarknetTx[];
|
|
16
|
+
witness: BigNumberish[];
|
|
17
|
+
}>;
|
|
18
|
+
getGas(data: StarknetSwapData): StarknetGas;
|
|
19
|
+
getType(): ChainSwapType;
|
|
20
|
+
}
|