Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(rgbpp-ckb): build btc transfer virtual ckb tx #13

Merged
merged 22 commits into from
Mar 9, 2024

Conversation

duanyytop
Copy link
Collaborator

@duanyytop duanyytop commented Mar 7, 2024

Changes

  • Add BTC transfer virtual CKB tx builder
  • Add necessary methods for service to build and sign CKB transactions
  • Add necessary utils methods and RGB++ types

Reviewers

@ShookLyngs @ahonn @Flouse

@duanyytop duanyytop requested a review from ShookLyngs March 7, 2024 09:36
@duanyytop duanyytop force-pushed the l1-transfer-virtual branch from 8109ab3 to 052be60 Compare March 7, 2024 09:47
@duanyytop duanyytop force-pushed the l1-transfer-virtual branch from 052be60 to ffc7a21 Compare March 7, 2024 09:52
@Flouse
Copy link
Contributor

Flouse commented Mar 7, 2024

  • Add layer1 transfer virtual tx builder

In the design documentation, BTC is referred to as Layer 1 (L1).

To avoid conceptual confusion, I suggest:

  • avoid using L1, L2 naming, just use BTC_TX and CKB_TX style, which is clearer.
  • e.g. L1VirtualTx -> ckbVirtualTx

packages/ckb/src/utils/rgbpp.ts Outdated Show resolved Hide resolved
@duanyytop duanyytop changed the title build layer1 transfer virtual tx build btc transfer virtual ckb tx Mar 7, 2024
@duanyytop duanyytop requested a review from Flouse March 7, 2024 14:21
@duanyytop
Copy link
Collaborator Author

I will add more test cases when the test cases of RGBPP lock script are finished

if (sumAmount < needAmount) {
throw new UdtAmountNotEnoughError('Insufficient UDT balance');
}
return { inputs, capacity: sumCapacity, amount: sumAmount };
Copy link
Contributor

@Flouse Flouse Mar 7, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated ec07a01

@Flouse Flouse self-requested a review March 7, 2024 15:58
packages/ckb/src/rgbpp/ckb-builder.ts Outdated Show resolved Hide resolved
Comment on lines +69 to +82
const transactionHash = rawTransactionToHash(rawTx);
const signedWitnesses = signWitnesses(keyMap)({
transactionHash,
witnesses: rawTx.witnesses,
inputCells: cells,
skipMissingKeys: true,
});
const emptyWitness = { lock: '', inputType: '', outputType: '' };
const signedTx = {
...rawTx,
witnesses: signedWitnesses.map((witness, index) => (index === 0 ? serializeWitnessArgs(emptyWitness) : witness)),
};
return signedTx;
};
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

need test cases later.

Copy link
Collaborator Author

@duanyytop duanyytop Mar 8, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. The integration test will be added later and I think we should focus on the new features now.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1

@@ -42,7 +42,7 @@ jobs:

- name: Install dependencies
run: pnpm i

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The test workflow doesn't seem to have any significant changes?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think adding an empty line will be more clear and I don't think it's a bad thing. Do you think so ?

If you think it's necessary to remove the empty line, I will do it.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I agree with you. I think breaking steps with an empty line is clearer than collapsing them together. However, I noticed that the only change in the test.yaml file in the PR is the addition of more spaces on line 45, rather than adding more line breaks as you suggested.

@duanyytop duanyytop requested a review from Flouse March 8, 2024 02:03
@ShookLyngs
Copy link
Collaborator

ShookLyngs commented Mar 8, 2024

If the PR contains noticeable or significant changes, please include a changeset in each relevant commit (1-to-1).
You can run the changeset command locally to create a changeset, which should look like this: b376000#diff-b8615fc591e5d8f2fa98f08cfc873a2c9328fd4d2ef1c55f0d8ed9d63ca3d32a

@duanyytop
Copy link
Collaborator Author

duanyytop commented Mar 8, 2024

If the PR contains noticeable or significant changes, please include a changeset in each relevant commit (1-to-1). You can run the changeset command locally to create a changeset, which should look like this: b376000#diff-b8615fc591e5d8f2fa98f08cfc873a2c9328fd4d2ef1c55f0d8ed9d63ca3d32a

We don’t have enough time now, and there are still many features that need to be implemented. I don’t think adding the changeset which only includes the PR's name is necessary. What do you think? @Flouse

@Flouse
Copy link
Contributor

Flouse commented Mar 8, 2024

If the PR contains noticeable or significant changes, please include a changeset in each relevant commit (1-to-1). You can run the changeset command locally to create a changeset, which should look like this: b376000#diff-b8615fc591e5d8f2fa98f08cfc873a2c9328fd4d2ef1c55f0d8ed9d63ca3d32a

We don’t have enough time now, and there are still many features that need to be implemented. I don’t think adding the changeset which only includes the PR's name is necessary. What do you think? @Flouse

Yes, we can follow @ShookLyngs 's suggestion once we are ready to open source.
IMO, for now, a clear PR name and description is enough.

@Flouse Flouse changed the title build btc transfer virtual ckb tx feat(rgbpp-ckb): build btc transfer virtual ckb tx Mar 8, 2024
@duanyytop duanyytop merged commit bcfc3fa into main Mar 9, 2024
1 check passed
@duanyytop duanyytop deleted the l1-transfer-virtual branch March 9, 2024 00:26
Flouse added a commit that referenced this pull request Apr 3, 2024
feat(rgbpp-sdk/service): sync apis from btc-assets-api #13 and #21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants