-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
73 changed files
with
2,123 additions
and
210 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,7 @@ | ||
--- | ||
"@ckb-ccc/spore": minor | ||
"@ckb-ccc/shell": minor | ||
"@ckb-ccc/ccc": minor | ||
--- | ||
|
||
feat: export backend packages in @ckb-ccc/shell |
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,7 @@ | ||
--- | ||
"@ckb-ccc/core": minor | ||
"@ckb-ccc/ssri": minor | ||
"@ckb-ccc/udt": minor | ||
--- | ||
|
||
feat: SSRI & UDT SDK |
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 |
---|---|---|
@@ -1,7 +1,7 @@ | ||
export * from "@ckb-ccc/core/advancedBarrel"; | ||
export * from "@ckb-ccc/eip6963/advanced"; | ||
export * from "@ckb-ccc/nip07/advanced"; | ||
export * from "@ckb-ccc/okx/advanced"; | ||
export * from "@ckb-ccc/shell/advancedBarrel"; | ||
export * from "@ckb-ccc/uni-sat/advanced"; | ||
export * from "@ckb-ccc/utxo-global/advanced"; | ||
export * from "@ckb-ccc/xverse/advanced"; |
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
121 changes: 121 additions & 0 deletions
121
packages/demo/src/app/connected/(tools)/TransferUdt/page.tsx
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,121 @@ | ||
"use client"; | ||
|
||
import React, { useEffect, useState } from "react"; | ||
import { TextInput } from "@/src/components/Input"; | ||
import { Button } from "@/src/components/Button"; | ||
import { ccc } from "@ckb-ccc/connector-react"; | ||
import { Textarea } from "@/src/components/Textarea"; | ||
import { useGetExplorerLink } from "@/src/utils"; | ||
import { useApp } from "@/src/context"; | ||
import { ButtonsPanel } from "@/src/components/ButtonsPanel"; | ||
|
||
export default function TransferUdt() { | ||
const { client } = ccc.useCcc(); | ||
const { signer, createSender } = useApp(); | ||
const { log } = createSender("Transfer xUDT"); | ||
|
||
const { explorerTransaction } = useGetExplorerLink(); | ||
|
||
const [udtTxHash, setUdtTxHash] = useState<string>(""); | ||
const [udtIndex, setUdtIndex] = useState<string>(""); | ||
const [udtCodeHash, setUdtCodeHash] = useState<string>(""); | ||
const [udtHashType, setUdtHashType] = useState<string>(""); | ||
const [udtArgs, setUdtArgs] = useState<string>(""); | ||
const [transferTo, setTransferTo] = useState<string>(""); | ||
const [amount, setAmount] = useState<string>(""); | ||
|
||
useEffect(() => { | ||
(async () => { | ||
const script = await client.getKnownScript(ccc.KnownScript.XUdt); | ||
setUdtCodeHash(script.codeHash); | ||
setUdtHashType(script.hashType); | ||
setUdtTxHash(script.cellDeps[0].cellDep.outPoint.txHash); | ||
setUdtIndex(script.cellDeps[0].cellDep.outPoint.index.toString()); | ||
})(); | ||
}, [client]); | ||
|
||
return ( | ||
<div className="flex w-full flex-col items-stretch"> | ||
<Textarea | ||
label="Address" | ||
placeholder="Addresses to transfer to, separated by lines" | ||
state={[transferTo, setTransferTo]} | ||
/> | ||
<TextInput | ||
label="Amount" | ||
placeholder="Amount to transfer for each" | ||
state={[amount, setAmount]} | ||
/> | ||
<TextInput | ||
label="Args" | ||
placeholder="UDT args to transfer" | ||
state={[udtArgs, setUdtArgs]} | ||
/> | ||
<TextInput | ||
label="Code Hash" | ||
placeholder="UDT args to transfer" | ||
state={[udtCodeHash, setUdtCodeHash]} | ||
/> | ||
<TextInput | ||
label="Hash Type" | ||
placeholder="UDT hash type to transfer" | ||
state={[udtHashType, setUdtHashType]} | ||
/> | ||
<TextInput | ||
label="Script Code Tx Hash" | ||
placeholder="Tx hash of the script code" | ||
state={[udtTxHash, setUdtTxHash]} | ||
/> | ||
<TextInput | ||
label="Script Code index" | ||
placeholder="Index of the script code" | ||
state={[udtIndex, setUdtIndex]} | ||
/> | ||
<ButtonsPanel> | ||
<Button | ||
className="self-center" | ||
onClick={async () => { | ||
if (!signer) { | ||
return; | ||
} | ||
const toAddresses = await Promise.all( | ||
transferTo | ||
.split("\n") | ||
.map((addr) => ccc.Address.fromString(addr, signer.client)), | ||
); | ||
const udt = new ccc.udt.Udt( | ||
{ | ||
txHash: udtTxHash, | ||
index: udtIndex, | ||
}, | ||
{ | ||
codeHash: udtCodeHash, | ||
hashType: udtHashType, | ||
args: udtArgs, | ||
}, | ||
); | ||
|
||
const { res: tx } = await udt.transfer( | ||
signer, | ||
toAddresses.map(({ script }) => ({ | ||
to: script, | ||
amount: amount, | ||
})), | ||
); | ||
const completedTx = await udt.completeBy(tx, signer); | ||
await completedTx.completeInputsByCapacity(signer); | ||
await completedTx.completeFeeBy(signer); | ||
|
||
// Sign and send the transaction | ||
const txHash = await signer.sendTransaction(completedTx); | ||
log("Transaction sent:", explorerTransaction(txHash)); | ||
await signer.client.waitTransaction(txHash); | ||
log("Transaction committed:", explorerTransaction(txHash)); | ||
}} | ||
> | ||
Transfer | ||
</Button> | ||
</ButtonsPanel> | ||
</div> | ||
); | ||
} |
100 changes: 0 additions & 100 deletions
100
packages/demo/src/app/connected/(tools)/TransferXUdt/page.tsx
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
Oops, something went wrong.