-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #270 from ckb-cell/feat/l1-transfer-all
feat(rgbpp): support for batch transferring of RGBPP XUDT assets
- Loading branch information
Showing
33 changed files
with
12,354 additions
and
333 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
--- | ||
"@rgbpp-sdk/btc": minor | ||
"@rgbpp-sdk/ckb": minor | ||
"rgbpp": minor | ||
--- | ||
|
||
Support for batch transferring of RGBPP XUDT assets | ||
|
||
- Add `buildRgbppTransferAllTxs()` API in the rgbpp lib for generating one or more BTC/CKB transaction groups for transferring the entire amount of a specific type of RGBPP XUDT asset from one or more BTC addresses to a recipient | ||
- Add `sendRgbppTxGroups()` API in the rgbpp lib for sending BTC/CKB transaction groups to the `BtcAssetsApi` | ||
- Add `unpackRgbppLockArgs()` API in the ckb lib for unpacking the lock script args of an RGBPP Cell | ||
- Add `encodeCellId()` and `decodeCellId()` APIs in the ckb lib for handling the ID of a CKB Cell | ||
- Add `encodeUtxoId()` and `decodeUtxoId()` APIs in the btc lib for handling the ID of a BTC UTXO |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import { describe, it, expect } from 'vitest'; | ||
import { encodeCellId, decodeCellId } from './id'; | ||
|
||
describe('cell id', () => { | ||
it('encodeCellId', () => { | ||
expect(encodeCellId('0x7610efaec3b9ce66349909fea88a1ae78cd488de3128bc6f71afc068306e0e65', '0x0')).toBe( | ||
'0x7610efaec3b9ce66349909fea88a1ae78cd488de3128bc6f71afc068306e0e65:0x0', | ||
); | ||
expect(encodeCellId('0x7610efaec3b9ce66349909fea88a1ae78cd488de3128bc6f71afc068306e0e65', '0xffffffff')).toBe( | ||
'0x7610efaec3b9ce66349909fea88a1ae78cd488de3128bc6f71afc068306e0e65:0xffffffff', | ||
); | ||
|
||
expect(() => | ||
encodeCellId('0x7610efaec3b9ce66349909fea88a1ae78cd488de3128bc6f71afc068306e0e6', '0x0'), | ||
).toThrowError(); | ||
expect(() => | ||
encodeCellId('0x7610efaec3b9ce66349909fea88a1ae78cd488de3128bc6f71afc068306e0e65', '0xffffffff01'), | ||
).toThrowError(); | ||
expect(() => | ||
encodeCellId('7610efaec3b9ce66349909fea88a1ae78cd488de3128bc6f71afc068306e0e65', '0x0'), | ||
).toThrowError(); | ||
expect(() => | ||
encodeCellId('0x7610efaec3b9ce66349909fea88a1ae78cd488de3128bc6f71afc068306e0e65', '0'), | ||
).toThrowError(); | ||
}); | ||
it('decodeCellId', () => { | ||
expect(decodeCellId('0x7610efaec3b9ce66349909fea88a1ae78cd488de3128bc6f71afc068306e0e65:0x0')).toStrictEqual({ | ||
txHash: '0x7610efaec3b9ce66349909fea88a1ae78cd488de3128bc6f71afc068306e0e65', | ||
index: '0x0', | ||
}); | ||
expect(decodeCellId('0x7610efaec3b9ce66349909fea88a1ae78cd488de3128bc6f71afc068306e0e65:0xffffffff')).toStrictEqual( | ||
{ | ||
txHash: '0x7610efaec3b9ce66349909fea88a1ae78cd488de3128bc6f71afc068306e0e65', | ||
index: '0xffffffff', | ||
}, | ||
); | ||
|
||
expect(() => decodeCellId('0x7610efaec3b9ce66349909fea88a1ae78cd488de3128bc6f71afc068306e0e6:0x0')).toThrowError(); | ||
expect(() => | ||
decodeCellId('0x7610efaec3b9ce66349909fea88a1ae78cd488de3128bc6f71afc068306e0e65:0xffffffff01'), | ||
).toThrowError(); | ||
expect(() => decodeCellId('7610efaec3b9ce66349909fea88a1ae78cd488de3128bc6f71afc068306e0e65:0x0')).toThrowError(); | ||
expect(() => decodeCellId('0x7610efaec3b9ce66349909fea88a1ae78cd488de3128bc6f71afc068306e0e65:0')).toThrowError(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import { Hash, HexNumber, OutPoint, blockchain } from '@ckb-lumos/base'; | ||
import { InvalidCellIdError } from '../error'; | ||
import { append0x } from './hex'; | ||
|
||
export const encodeCellId = (txHash: Hash, index: HexNumber): string => { | ||
if (!txHash.startsWith('0x') || !index.startsWith('0x')) { | ||
throw new InvalidCellIdError(`Cannot encode CellId due to valid format: txHash=${txHash}, index=${index}`); | ||
} | ||
try { | ||
blockchain.OutPoint.pack({ | ||
txHash, | ||
index, | ||
}); | ||
return `${txHash}:${index}`; | ||
} catch { | ||
throw new InvalidCellIdError(`Cannot encode CellId due to valid format: txHash=${txHash}, index=${index}`); | ||
} | ||
}; | ||
|
||
export const decodeCellId = (cellId: string): OutPoint => { | ||
const [txHash, index] = cellId.split(':'); | ||
if (!txHash.startsWith('0x') || !index.startsWith('0x')) { | ||
throw new InvalidCellIdError(`Cannot decode CellId: ${cellId}`); | ||
} | ||
try { | ||
blockchain.OutPoint.pack({ | ||
txHash, | ||
index, | ||
}); | ||
return { | ||
txHash: append0x(txHash), | ||
index: append0x(index), | ||
}; | ||
} catch { | ||
throw new InvalidCellIdError(`Cannot decode CellId due to valid format: ${cellId}`); | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# Network | ||
VITE_IS_MAINNET=false | ||
|
||
# CKB | ||
VITE_CKB_NODE_URL=https://testnet.ckb.dev/rpc | ||
VITE_CKB_INDEXER_URL=https://testnet.ckb.dev/indexer | ||
|
||
# BTC | ||
VITE_BTC_SERVICE_URL=https://btc-assets-api.testnet.mibao.pro | ||
VITE_BTC_SERVICE_TOKEN= | ||
VITE_BTC_SERVICE_ORIGIN= |
Oops, something went wrong.
215dd98
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
New snapshot version of the rgbpp-sdk packages have been released:
0.0.0-snap-20240812163646
0.0.0-snap-20240812163646
0.0.0-snap-20240812163646
0.0.0-snap-20240812163646