Skip to content

Commit

Permalink
feat: btc-peg-in-endpoint-v2-01 -> btc-peg-in-endpoint-v2-02
Browse files Browse the repository at this point in the history
  • Loading branch information
bolasblack committed Aug 7, 2024
1 parent 248c430 commit d1916c7
Show file tree
Hide file tree
Showing 9 changed files with 20 additions and 147 deletions.
128 changes: 0 additions & 128 deletions generated/smartContract/contract_xlink_btc-bridge-registry-v2-01.ts

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ listT,
noneT
} from "../smartContractHelpers/codegenImport"

export const btcPegInEndpointV201 = defineContract({
"btc-peg-in-endpoint-v2-01": {
export const btcPegInEndpointV202 = defineContract({
"btc-peg-in-endpoint-v2-02": {
callback: {
input: [
{ name: 'sender', type: principalT },
Expand Down Expand Up @@ -84,7 +84,7 @@ export const btcPegInEndpointV201 = defineContract({
input: [
{
name: 'order',
type: tupleT({ 'chain-id': uintT, recipient: bufferT }, )
type: tupleT({ 'chain-id': uintT, from: bufferT, to: bufferT }, )
}
],
output: responseSimpleT(bufferT, ),
Expand All @@ -97,7 +97,7 @@ export const btcPegInEndpointV201 = defineContract({
},
'decode-order-cross-or-fail': {
input: [ { name: 'order-script', type: bufferT } ],
output: responseSimpleT(tupleT({ 'chain-id': uintT, recipient: bufferT }, ), ),
output: responseSimpleT(tupleT({ 'chain-id': uintT, from: bufferT, to: bufferT }, ), ),
mode: 'readonly'
},
'extract-tx-ins-outs': {
Expand Down Expand Up @@ -150,7 +150,7 @@ export const btcPegInEndpointV201 = defineContract({
output: responseSimpleT(tupleT({
'amount-net': uintT,
fee: uintT,
'order-details': tupleT({ 'chain-id': uintT, recipient: bufferT }, )
'order-details': tupleT({ 'chain-id': uintT, from: bufferT, to: bufferT }, )
}, ), ),
mode: 'readonly'
},
Expand Down
6 changes: 2 additions & 4 deletions generated/smartContract/contracts_xlink.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
import { defineContract } from "../smartContractHelpers/codegenImport";
import { btcBridgeRegistryV201 } from "./contract_xlink_btc-bridge-registry-v2-01"
import { btcPegInEndpointV201 } from "./contract_xlink_btc-peg-in-endpoint-v2-01"
import { btcPegInEndpointV202 } from "./contract_xlink_btc-peg-in-endpoint-v2-02"
import { btcPegOutEndpointV201 } from "./contract_xlink_btc-peg-out-endpoint-v2-01"
import { crossBridgeRegistryV201 } from "./contract_xlink_cross-bridge-registry-v2-01"
import { crossPegInEndpointV201 } from "./contract_xlink_cross-peg-in-endpoint-v2-01"
import { crossPegOutEndpointV201 } from "./contract_xlink_cross-peg-out-endpoint-v2-01"

export const xlinkContracts = defineContract({
...btcBridgeRegistryV201,
...btcPegInEndpointV201,
...btcPegInEndpointV202,
...btcPegOutEndpointV201,
...crossBridgeRegistryV201,
...crossPegInEndpointV201,
Expand Down
3 changes: 1 addition & 2 deletions scripts/generateClarityTranscoders.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@ import { STACKS_CONTRACT_DEPLOYER_MAINNET, STACKS_MAINNET } from "../src/config"
STACKS_MAINNET.coreApiUrl,
STACKS_CONTRACT_DEPLOYER_MAINNET,
[
"btc-bridge-registry-v2-01",
"btc-peg-in-endpoint-v2-01",
"btc-peg-in-endpoint-v2-02",
"btc-peg-out-endpoint-v2-01",
"cross-bridge-registry-v2-01",
"cross-peg-in-endpoint-v2-01",
Expand Down
6 changes: 3 additions & 3 deletions src/bitcoinUtils/peggingHelpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,19 +36,19 @@ export const getBtc2StacksFeeInfo = async (route: {

const resp = await props({
isPaused: executeReadonlyCallXLINK(
"btc-peg-in-endpoint-v2-01",
"btc-peg-in-endpoint-v2-02",
"is-peg-in-paused",
{},
executeOptions,
),
feeRate: executeReadonlyCallXLINK(
"btc-peg-in-endpoint-v2-01",
"btc-peg-in-endpoint-v2-02",
"get-peg-in-fee",
{},
executeOptions,
).then(numberFromStacksContractNumber),
minFeeAmount: executeReadonlyCallXLINK(
"btc-peg-in-endpoint-v2-01",
"btc-peg-in-endpoint-v2-02",
"get-peg-in-min-fee",
{},
executeOptions,
Expand Down
8 changes: 5 additions & 3 deletions src/stacksUtils/createBridgeOrder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ export async function createBridgeOrder_BitcoinToStacks(

if (hasLength(swapRoute, 0)) {
data = await executeReadonlyCallXLINK(
"btc-peg-in-endpoint-v2-01",
"btc-peg-in-endpoint-v2-02",
"create-order-0-or-fail",
{ order: receiverAddr },
executeOptions,
Expand Down Expand Up @@ -106,6 +106,7 @@ export async function createBridgeOrder_BitcoinToEVM(
},
info: {
targetChain: KnownChainId.EVMChain
fromBitcoinScriptPubKey: Uint8Array
receiverAddr: string
swapRoute: BridgeSwapRoute_FromBitcoin
swapSlippedAmount?: bigint
Expand All @@ -127,11 +128,12 @@ export async function createBridgeOrder_BitcoinToEVM(

if (hasLength(swapRoute, 0)) {
data = await executeReadonlyCallXLINK(
"btc-peg-in-endpoint-v2-01",
"btc-peg-in-endpoint-v2-02",
"create-order-cross-or-fail",
{
order: {
recipient: decodeHex(receiverAddr),
from: info.fromBitcoinScriptPubKey,
to: decodeHex(receiverAddr),
"chain-id": targetChainId,
},
},
Expand Down
4 changes: 2 additions & 2 deletions src/stacksUtils/validateBridgeOrder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export async function validateBridgeOrder_BitcoinToStacks(

if (hasLength(swapRoute, 0)) {
resp = await executeReadonlyCallXLINK(
"btc-peg-in-endpoint-v2-01",
"btc-peg-in-endpoint-v2-02",
"validate-tx-0",
{
tx: btcTx,
Expand Down Expand Up @@ -114,7 +114,7 @@ export async function validateBridgeOrder_BitcoinToEVM(

if (hasLength(swapRoute, 0)) {
resp = await executeReadonlyCallXLINK(
"btc-peg-in-endpoint-v2-01",
"btc-peg-in-endpoint-v2-02",
"validate-tx-cross",
{
tx: btcTx,
Expand Down
1 change: 1 addition & 0 deletions src/xlinkSdkUtils/bridgeFromBitcoin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,7 @@ async function bridgeFromBitcoin_toEVM(
},
{
targetChain: info.toChain,
fromBitcoinScriptPubKey: info.fromAddressScriptPubKey,
receiverAddr: info.toAddress,
swapSlippedAmount: numberToStacksContractNumber(info.amount),
swapRoute: [],
Expand Down
1 change: 1 addition & 0 deletions src/xlinkSdkUtils/estimateBridgeTransactionFromBitcoin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,7 @@ async function estimateFromBitcoin_toEVM(
},
{
targetChain: info.toChain,
fromBitcoinScriptPubKey: info.fromAddressScriptPubKey,
receiverAddr: info.toAddress,
swapSlippedAmount: numberToStacksContractNumber(info.amount),
swapRoute: [],
Expand Down

0 comments on commit d1916c7

Please sign in to comment.