Skip to content

Commit

Permalink
refactor: Update buildRgbppTransferTx parameters' name
Browse files Browse the repository at this point in the history
  • Loading branch information
duanyytop committed Jun 6, 2024
1 parent 4f44f26 commit 42699bd
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 25 deletions.
6 changes: 3 additions & 3 deletions examples/rgbpp/xudt/2-btc-transfer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ const transfer = async ({ rgbppLockArgsList, toBtcAddress, xudtTypeArgs, transfe
transferAmount,
},
btc: {
fromBtcAddress: btcAddress!,
toBtcAddress,
btcDataSource,
fromAddress: btcAddress!,
toAddress: toBtcAddress,
dataSource: btcDataSource,
},
isMainnet,
});
Expand Down
6 changes: 3 additions & 3 deletions examples/rgbpp/xudt/local/2-btc-transfer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ const transfer = async ({ rgbppLockArgsList, toBtcAddress, xudtTypeArgs, transfe
transferAmount,
},
btc: {
fromBtcAddress: btcAddress!,
toBtcAddress,
btcDataSource,
fromAddress: btcAddress!,
toAddress: toBtcAddress,
dataSource: btcDataSource,
},
isMainnet,
});
Expand Down
16 changes: 8 additions & 8 deletions packages/rgbpp/src/rgbpp/types.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { DataSource } from '@rgbpp-sdk/btc';
import { BtcTransferVirtualTxResult, Collector, Hex } from '@rgbpp-sdk/ckb';

export interface RgbppTransferCkb {
export interface RgbppTransferCkbParams {
// The collector that collects CKB live cells and transactions
collector: Collector;
// The transferred RGB++ xUDT type script args
Expand All @@ -11,24 +11,24 @@ export interface RgbppTransferCkb {
// The XUDT amount to be transferred, if the noMergeOutputCells is true, the transferAmount will be ignored
transferAmount: bigint;
// The CKB transaction fee rate, default value is 1100
ckbFeeRate?: bigint;
feeRate?: bigint;
}

export interface RgbppTransferBtc {
export interface RgbppTransferBtcParams {
// The sender BTC address
fromBtcAddress: string;
fromAddress: string;
// The receiver BTC address
toBtcAddress: string;
btcDataSource: DataSource;
toAddress: string;
dataSource: DataSource;
// The public key of sender BTC address
fromPubkey?: Hex;
// The fee rate of the BTC transaction
feeRate?: number;
}

export interface RgbppTransferTxParams {
ckb: RgbppTransferCkb;
btc: RgbppTransferBtc;
ckb: RgbppTransferCkbParams;
btc: RgbppTransferBtcParams;
isMainnet: boolean;
}

Expand Down
22 changes: 11 additions & 11 deletions packages/rgbpp/src/rgbpp/xudt.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,19 @@ import { RgbppTransferTxParams, RgbppTransferTxResult } from './types';
* @param xudtTypeArgs The transferred xUDT type script args
* @param rgbppLockArgsList The RGB++ assets cell lock script args array whose data structure is: out_index | bitcoin_tx_id
* @param transferAmount The XUDT amount to be transferred, if the noMergeOutputCells is true, the transferAmount will be ignored
* @param ckbFeeRate The CKB transaction fee rate, default value is 1100
* @param feeRate The CKB transaction fee rate, default value is 1100
*
* BTC pramaeters
* @param fromBtcAddress The sender BTC address
* @param fromAddress The sender BTC address
* @param fromPubkey The public key of the sender BTC address
* @param toBtcAddress The receiver BTC address
* @param btcDataSource The BTC data source
* @param toAddress The receiver BTC address
* @param dataSource The BTC data source
* @param feeRate The fee rate of the BTC transaction
* @param isMainnet
*/
export const buildRgbppTransferTx = async ({
ckb: { collector, xudtTypeArgs, rgbppLockArgsList, transferAmount, ckbFeeRate },
btc: { fromBtcAddress, toBtcAddress, btcDataSource, fromPubkey, feeRate },
ckb: { collector, xudtTypeArgs, rgbppLockArgsList, transferAmount, feeRate: ckbFeeRate },
btc,
isMainnet,
}: RgbppTransferTxParams): Promise<RgbppTransferTxResult> => {
const xudtType: CKBComponents.Script = {
Expand All @@ -45,12 +45,12 @@ export const buildRgbppTransferTx = async ({
const psbt = await sendRgbppUtxos({
ckbVirtualTx: ckbRawTx,
commitment,
tos: [toBtcAddress],
tos: [btc.toAddress],
ckbCollector: collector,
from: fromBtcAddress!,
fromPubkey,
source: btcDataSource,
feeRate,
from: btc.fromAddress!,
fromPubkey: btc.fromPubkey,
source: btc.dataSource,
feeRate: btc.feeRate,
});

return {
Expand Down

0 comments on commit 42699bd

Please sign in to comment.