mirror of
https://github.com/Brotocol-xyz/bro-sdk.git
synced 2026-01-12 14:54:21 +08:00
feat: btc-peg-in-endpoint-v2-01 -> btc-peg-in-endpoint-v2-02
This commit is contained in:
@@ -1,128 +0,0 @@
|
||||
|
||||
import {
|
||||
defineContract,
|
||||
bufferT,
|
||||
booleanT,
|
||||
responseSimpleT,
|
||||
uintT,
|
||||
tupleT,
|
||||
principalT,
|
||||
optionalT,
|
||||
noneT
|
||||
} from "../smartContractHelpers/codegenImport"
|
||||
|
||||
export const btcBridgeRegistryV201 = defineContract({
|
||||
"btc-bridge-registry-v2-01": {
|
||||
'approve-peg-in-address': {
|
||||
input: [
|
||||
{ name: 'address', type: bufferT },
|
||||
{ name: 'approved', type: booleanT }
|
||||
],
|
||||
output: responseSimpleT(booleanT, ),
|
||||
mode: 'public'
|
||||
},
|
||||
'set-peg-in-sent': {
|
||||
input: [
|
||||
{ name: 'tx', type: bufferT },
|
||||
{ name: 'output', type: uintT },
|
||||
{ name: 'sent', type: booleanT }
|
||||
],
|
||||
output: responseSimpleT(booleanT, ),
|
||||
mode: 'public'
|
||||
},
|
||||
'set-request': {
|
||||
input: [
|
||||
{ name: 'request-id', type: uintT },
|
||||
{
|
||||
name: 'details',
|
||||
type: tupleT({
|
||||
'amount-net': uintT,
|
||||
claimed: uintT,
|
||||
'claimed-by': principalT,
|
||||
fee: uintT,
|
||||
finalized: booleanT,
|
||||
'fulfilled-by': bufferT,
|
||||
'gas-fee': uintT,
|
||||
'peg-out-address': bufferT,
|
||||
'requested-at': uintT,
|
||||
'requested-at-burn-height': uintT,
|
||||
'requested-by': principalT,
|
||||
revoked: booleanT
|
||||
}, )
|
||||
}
|
||||
],
|
||||
output: responseSimpleT(uintT, ),
|
||||
mode: 'public'
|
||||
},
|
||||
'set-request-claim-grace-period': {
|
||||
input: [ { name: 'grace-period', type: uintT } ],
|
||||
output: responseSimpleT(booleanT, ),
|
||||
mode: 'public'
|
||||
},
|
||||
'set-request-revoke-grace-period': {
|
||||
input: [ { name: 'grace-period', type: uintT } ],
|
||||
output: responseSimpleT(booleanT, ),
|
||||
mode: 'public'
|
||||
},
|
||||
'get-peg-in-sent-or-default': {
|
||||
input: [ { name: 'tx', type: bufferT }, { name: 'output', type: uintT } ],
|
||||
output: booleanT,
|
||||
mode: 'readonly'
|
||||
},
|
||||
'get-request-claim-grace-period': { input: [], output: uintT, mode: 'readonly' },
|
||||
'get-request-or-fail': {
|
||||
input: [ { name: 'request-id', type: uintT } ],
|
||||
output: responseSimpleT(tupleT({
|
||||
'amount-net': uintT,
|
||||
claimed: uintT,
|
||||
'claimed-by': principalT,
|
||||
fee: uintT,
|
||||
finalized: booleanT,
|
||||
'fulfilled-by': bufferT,
|
||||
'gas-fee': uintT,
|
||||
'peg-out-address': bufferT,
|
||||
'requested-at': uintT,
|
||||
'requested-at-burn-height': uintT,
|
||||
'requested-by': principalT,
|
||||
revoked: booleanT
|
||||
}, ), ),
|
||||
mode: 'readonly'
|
||||
},
|
||||
'get-request-revoke-grace-period': { input: [], output: uintT, mode: 'readonly' },
|
||||
'is-dao-or-extension': { input: [], output: responseSimpleT(booleanT, ), mode: 'readonly' },
|
||||
'is-peg-in-address-approved': {
|
||||
input: [ { name: 'address', type: bufferT } ],
|
||||
output: booleanT,
|
||||
mode: 'readonly'
|
||||
},
|
||||
'approved-peg-in-address': { input: bufferT, output: optionalT(booleanT, ), mode: 'mapEntry' },
|
||||
'peg-in-sent': {
|
||||
input: tupleT({ output: uintT, tx: bufferT }, ),
|
||||
output: optionalT(booleanT, ),
|
||||
mode: 'mapEntry'
|
||||
},
|
||||
requests: {
|
||||
input: uintT,
|
||||
output: optionalT(tupleT({
|
||||
'amount-net': uintT,
|
||||
claimed: uintT,
|
||||
'claimed-by': principalT,
|
||||
fee: uintT,
|
||||
finalized: booleanT,
|
||||
'fulfilled-by': bufferT,
|
||||
'gas-fee': uintT,
|
||||
'peg-out-address': bufferT,
|
||||
'requested-at': uintT,
|
||||
'requested-at-burn-height': uintT,
|
||||
'requested-by': principalT,
|
||||
revoked: booleanT
|
||||
}, ), ),
|
||||
mode: 'mapEntry'
|
||||
},
|
||||
'request-claim-grace-period': { input: noneT, output: uintT, mode: 'variable' },
|
||||
'request-nonce': { input: noneT, output: uintT, mode: 'variable' },
|
||||
'request-revoke-grace-period': { input: noneT, output: uintT, mode: 'variable' }
|
||||
}
|
||||
} as const)
|
||||
|
||||
|
||||
@@ -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 },
|
||||
@@ -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, ),
|
||||
@@ -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': {
|
||||
@@ -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'
|
||||
},
|
||||
@@ -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,
|
||||
|
||||
@@ -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",
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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,
|
||||
@@ -106,6 +106,7 @@ export async function createBridgeOrder_BitcoinToEVM(
|
||||
},
|
||||
info: {
|
||||
targetChain: KnownChainId.EVMChain
|
||||
fromBitcoinScriptPubKey: Uint8Array
|
||||
receiverAddr: string
|
||||
swapRoute: BridgeSwapRoute_FromBitcoin
|
||||
swapSlippedAmount?: bigint
|
||||
@@ -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,
|
||||
},
|
||||
},
|
||||
|
||||
@@ -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,
|
||||
@@ -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,
|
||||
|
||||
@@ -231,6 +231,7 @@ async function bridgeFromBitcoin_toEVM(
|
||||
},
|
||||
{
|
||||
targetChain: info.toChain,
|
||||
fromBitcoinScriptPubKey: info.fromAddressScriptPubKey,
|
||||
receiverAddr: info.toAddress,
|
||||
swapSlippedAmount: numberToStacksContractNumber(info.amount),
|
||||
swapRoute: [],
|
||||
|
||||
@@ -165,6 +165,7 @@ async function estimateFromBitcoin_toEVM(
|
||||
},
|
||||
{
|
||||
targetChain: info.toChain,
|
||||
fromBitcoinScriptPubKey: info.fromAddressScriptPubKey,
|
||||
receiverAddr: info.toAddress,
|
||||
swapSlippedAmount: numberToStacksContractNumber(info.amount),
|
||||
swapRoute: [],
|
||||
|
||||
Reference in New Issue
Block a user