-
Notifications
You must be signed in to change notification settings - Fork 35
feat: add margin feature to enable zero-transfer fee #241
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
base: master
Are you sure you want to change the base?
Changes from 8 commits
2c1cc53
92040af
f4f8289
97f1591
17726dc
9b6c23c
eaf3dc6
6d25c00
1466bd3
dacf39e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| --- | ||
| "@ckb-ccc/core": patch | ||
| --- | ||
|
|
||
| Change a little low-level logic in fee completion from a transaction | ||
|
|
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| --- | ||
| "@ckb-ccc/spore": patch | ||
| --- | ||
|
|
||
| Add margin option in createSpore for zero-transfer-fee feature | ||
|
|
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| PRIVATE_KEY=0x0000000000000000000000000000000000000000000000000000000000000000 |
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,45 @@ | ||
| import { ccc } from "@ckb-ccc/core"; | ||
| import { JsonRpcTransformers } from "@ckb-ccc/core/advanced"; | ||
| import { describe, expect, it } from "vitest"; | ||
| import { transferSpore } from "../index.js"; | ||
|
|
||
| describe("transferSpore [testnet]", () => { | ||
| expect(process.env.PRIVATE_KEY).toBeDefined(); | ||
|
|
||
| it("should transfer a Spore cell by sporeId", async () => { | ||
| const client = new ccc.ClientPublicTestnet(); | ||
| const signer = new ccc.SignerCkbPrivateKey( | ||
| client, | ||
| process.env.PRIVATE_KEY!, | ||
| ); | ||
|
|
||
| // Create a new owner | ||
| const owner = await ccc.Address.fromString( | ||
| "ckt1qzda0cr08m85hc8jlnfp3zer7xulejywt49kt2rr0vthywaa50xwsqv5puz2ee96nuh9nmc6rtm0n8v7agju4rgdmxlnk", | ||
| signer.client, | ||
| ); | ||
|
|
||
| // Build transaction | ||
| let { tx, zeroFeeApplied } = await transferSpore({ | ||
| signer, | ||
| // Change this if you have a different sporeId | ||
| id: "0xe1b98f485de4a7cec6161a15a3ae1fc06a9d7170df04d27ba453023254b2c5e3", | ||
| to: owner.script, | ||
| zeroTransferFeeRate: 1000, | ||
| }); | ||
|
|
||
| // Complete transaction if zero fee is not applied | ||
| if (!zeroFeeApplied) { | ||
| await tx.completeFeeBy(signer); | ||
| console.log("zero-transfer-fee is not applied, complete fee by signer"); | ||
| } else { | ||
| console.log("zero-transfer-fee is applied, skip complete fee"); | ||
| } | ||
| tx = await signer.signTransaction(tx); | ||
| console.log(JSON.stringify(JsonRpcTransformers.transactionFrom(tx))); | ||
|
|
||
| // Send transaction | ||
| const txHash = await signer.client.sendTransaction(tx); | ||
| console.log(txHash); | ||
|
Comment on lines
+39
to
+43
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The test uses |
||
| }, 60000); | ||
| }); | ||
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.
This
addOutputoverload appears to be a duplicate of the one defined just below it (lines 1787-1790) and the one that was already present. This redundancy can be confusing and should be removed to improve code clarity.