Skip to content

Commit dffebdd

Browse files
committed
feat: updated examples
1 parent 1027a6f commit dffebdd

File tree

12 files changed

+127
-195
lines changed

12 files changed

+127
-195
lines changed

packages/examples/src/pauseableUdt/pause.ts

Lines changed: 2 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -97,24 +97,9 @@ const pudtnPauseTx = (
9797
[targetReceiverBScript.hash()],
9898
)
9999
).res;
100-
await render(pudtnPauseTx);
101100

102101
await pudtPauseTx.completeFeeBy(signer);
103102
await pudtnPauseTx.completeFeeBy(signer);
104-
// NOTE: This would fail for 36 ("Nothing To DO") if run again because it's already paused and it would be deduped. Run unpause before pausing them again
105-
const pudtPauseTxHash = await signer.sendTransaction(pudtPauseTx);
106-
console.log(pudtPauseTxHash);
107-
// "0xc8df6b7edaa295f4044107e5c7f5b20fffe6e36e37fcf6513337c2be8c354e39"
108-
const pudtnPauseTxHash = await signer.sendTransaction(pudtnPauseTx);
109-
console.log(pudtnPauseTxHash);
110-
// "0x04fd05e091189d9beae525decd22d61cd8d63bd2ce6949369961fca7fa63a27b"
111-
112-
// NOTE: This won't change because you need to upgrade the script to see the change
113-
const pudtnPaused = await pudtn.enumeratePaused();
114-
console.log(pudtnPaused);
115-
// {"res":[],"cellDeps":[]}
116103

117-
// NOTE: This might be delayed if the transaction is not yet confirmed
118-
const pudtPaused = await pudt.enumeratePaused();
119-
console.log(pudtPaused);
120-
// {"res":["0x787e97af6860c58fcecd12653714330c003f5b960e09f027295a49e3c41d609f","0x0ac6e7d7ed8d8ac0832992f106dbebbd71a2cfa4791ef621dec081a047f7668d","0xa320a09489791af2e5e1fe84927eda84f71afcbd2c7a65cb419464fe46e75085","0x779c916fc89f7c7d03c97d7a2aa5cf4f854d4f279ef0a89f8568dc65e744b3a6"],"cellDeps":[{"txHash":"0xc8df6b7edaa295f4044107e5c7f5b20fffe6e36e37fcf6513337c2be8c354e39","index":"0"}]}
104+
await render(pudtPauseTx);
105+
await render(pudtnPauseTx);

packages/examples/src/pauseableUdt/unpause.ts

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -60,14 +60,6 @@ const pudtUnpauseTx = (
6060
[targetReceiverBScript.hash()],
6161
)
6262
).res;
63-
await render(pudtUnpauseTx);
6463

6564
await pudtUnpauseTx.completeFeeBy(signer);
66-
const pudtUnpauseTxHash = await signer.sendTransaction(pudtUnpauseTx);
67-
console.log(pudtUnpauseTxHash);
68-
// "0x7715e78b4c5ded8928027c6aa610468eafce81c88e48e1267c1b787f52bb4929"
69-
70-
// NOTE: This might be delayed if the transaction is not yet confirmed
71-
const pudtPaused = await pudt.enumeratePaused();
72-
console.log(pudtPaused);
73-
// {"res":["0x787e97af6860c58fcecd12653714330c003f5b960e09f027295a49e3c41d609f"],"cellDeps":[{"txHash":"0x7715e78b4c5ded8928027c6aa610468eafce81c88e48e1267c1b787f52bb4929","index":"0"}]}
65+
await render(pudtUnpauseTx);

packages/examples/src/ssri/getMethods.ts

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,27 +3,27 @@ import { signer } from "@ckb-ccc/playground";
33

44
const executor = new ccc.ssri.ExecutorJsonRpc("http://localhost:9090");
55

6-
const pudtScriptCell = await signer.client.findSingletonCellByType({
6+
const scriptCell = await signer.client.findSingletonCellByType({
77
// TypeID Code Hash. Don't change
88
codeHash:
99
"0x00000000000000000000000000000000000000000000000000545950455f4944",
1010
hashType: "type",
11-
// TypeID args. Change it to the args of the Type ID script of your UDT
11+
// TypeID args. Change it to the args of the Type ID script of your Script
1212
args: "0x8fd55df879dc6176c95f3c420631f990ada2d4ece978c9512c39616dead2ed56",
1313
});
14-
if (!pudtScriptCell) {
15-
throw new Error("PUDT script cell not found");
14+
if (!scriptCell) {
15+
throw new Error("Script cell not found");
1616
}
1717

18-
const pudtCodeHash = pudtScriptCell.cellOutput.type?.hash();
19-
if (!pudtCodeHash) {
20-
throw new Error("PUDT code hash not found");
18+
const scriptCodeHash = scriptCell.cellOutput.type?.hash();
19+
if (!scriptCodeHash) {
20+
throw new Error("Script code hash not found");
2121
}
2222

23-
const pudt = new ccc.ssri.Trait(pudtScriptCell.outPoint, executor);
23+
const script = new ccc.ssri.Trait(scriptCell.outPoint, executor);
2424

25-
const pudtMethods = await pudt.getMethods();
25+
const scriptMethods = await script.getMethods();
2626

27-
console.log(pudtMethods);
27+
console.log(scriptMethods);
2828
///
2929
// {"res":["0x6f2a4642323106f8","0x58f02409de9de7b1","0xb43d1128f8726c19","0xc78a67cec2fcc54f","0x35fa711c8c918aad","0x2f87f08056af234d","0xa306f89e40893737","0x235c6c5c6ee04b08","0x9adf445d336222e1","0x2e04fafee9f986ea","0x03cd9ce840759d42","0x849def40c0e9a525","0x43f92b1ceda6fa2b"],"cellDeps":[]}

packages/examples/src/ssri/hasMethods.ts

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,26 +3,26 @@ import { signer } from "@ckb-ccc/playground";
33

44
const executor = new ccc.ssri.ExecutorJsonRpc("http://localhost:9090");
55

6-
const pudtScriptCell = await signer.client.findSingletonCellByType({
6+
const scriptCell = await signer.client.findSingletonCellByType({
77
// TypeID Code Hash. Don't change
88
codeHash:
99
"0x00000000000000000000000000000000000000000000000000545950455f4944",
1010
hashType: "type",
11-
// TypeID args. Change it to the args of the Type ID script of your UDT
11+
// TypeID args. Change it to the args of the Type ID script of your Script
1212
args: "0x8fd55df879dc6176c95f3c420631f990ada2d4ece978c9512c39616dead2ed56",
1313
});
14-
if (!pudtScriptCell) {
15-
throw new Error("PUDT script cell not found");
14+
if (!scriptCell) {
15+
throw new Error("Script cell not found");
1616
}
1717

18-
const pudtCodeHash = pudtScriptCell.cellOutput.type?.hash();
19-
if (!pudtCodeHash) {
20-
throw new Error("PUDT code hash not found");
18+
const scriptCodeHash = scriptCell.cellOutput.type?.hash();
19+
if (!scriptCodeHash) {
20+
throw new Error("Script code hash not found");
2121
}
2222

23-
const pudt = new ccc.ssri.Trait(pudtScriptCell.outPoint, executor);
23+
const script = new ccc.ssri.Trait(scriptCell.outPoint, executor);
2424

25-
const pudtHasMethods = await pudt.hasMethods([
25+
const scriptHasMethods = await script.hasMethods([
2626
"SSRI.get_methods",
2727
"SSRI.has_methods",
2828
"SSRI.version",
@@ -39,7 +39,7 @@ const pudtHasMethods = await pudt.hasMethods([
3939
"UNKNOWN",
4040
]);
4141

42-
console.log(pudtHasMethods);
42+
console.log(scriptHasMethods);
4343
///
4444
// {"res":[true,true,true,true,true,true,true,true,true,true,true,true,true,false],"cellDeps":[]}
4545
///

packages/examples/src/ssri/version.ts

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,28 +3,28 @@ import { signer } from "@ckb-ccc/playground";
33

44
const executor = new ccc.ssri.ExecutorJsonRpc("http://localhost:9090");
55

6-
const pudtScriptCell = await signer.client.findSingletonCellByType({
6+
const scriptCell = await signer.client.findSingletonCellByType({
77
// TypeID Code Hash. Don't change
88
codeHash:
99
"0x00000000000000000000000000000000000000000000000000545950455f4944",
1010
hashType: "type",
11-
// TypeID args. Change it to the args of the Type ID script of your UDT
11+
// TypeID args. Change it to the args of the Type ID script of your Script
1212
args: "0x8fd55df879dc6176c95f3c420631f990ada2d4ece978c9512c39616dead2ed56",
1313
});
14-
if (!pudtScriptCell) {
15-
throw new Error("PUDT script cell not found");
14+
if (!scriptCell) {
15+
throw new Error("Script cell not found");
1616
}
1717

18-
const pudtCodeHash = pudtScriptCell.cellOutput.type?.hash();
19-
if (!pudtCodeHash) {
20-
throw new Error("PUDT code hash not found");
18+
const scriptCodeHash = scriptCell.cellOutput.type?.hash();
19+
if (!scriptCodeHash) {
20+
throw new Error("Script code hash not found");
2121
}
2222

23-
const pudt = new ccc.ssri.Trait(pudtScriptCell.outPoint, executor);
23+
const script = new ccc.ssri.Trait(scriptCell.outPoint, executor);
2424

25-
const pudtVersion = await pudt.version();
25+
const scriptVersion = await script.version();
2626

27-
console.log(pudtVersion);
27+
console.log(scriptVersion);
2828
///
2929
// {"res":"0","cellDeps":[]}
3030
///

packages/examples/src/udt/decimals.ts

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,35 +3,35 @@ import { signer } from "@ckb-ccc/playground";
33

44
const executor = new ccc.ssri.ExecutorJsonRpc("http://localhost:9090");
55

6-
const pudtScriptCell = await signer.client.findSingletonCellByType({
6+
const udtScriptCell = await signer.client.findSingletonCellByType({
77
// TypeID Code Hash. Don't change
88
codeHash:
99
"0x00000000000000000000000000000000000000000000000000545950455f4944",
1010
hashType: "type",
1111
// TypeID args. Change it to the args of the Type ID script of your UDT
1212
args: "0x8fd55df879dc6176c95f3c420631f990ada2d4ece978c9512c39616dead2ed56",
1313
});
14-
if (!pudtScriptCell) {
15-
throw new Error("PUDT script cell not found");
14+
if (!udtScriptCell) {
15+
throw new Error("udt script cell not found");
1616
}
1717

18-
const pudtCodeHash = pudtScriptCell.cellOutput.type?.hash();
19-
if (!pudtCodeHash) {
20-
throw new Error("PUDT code hash not found");
18+
const udtCodeHash = udtScriptCell.cellOutput.type?.hash();
19+
if (!udtCodeHash) {
20+
throw new Error("udt code hash not found");
2121
}
22-
const pudtType = {
23-
codeHash: pudtCodeHash,
22+
const udtType = {
23+
codeHash: udtCodeHash,
2424
hashType: "type",
2525
args: "0x02c93173368ec56f72ec023f63148461b80e7698eddd62cbd9dbe31a13f2b330",
2626
};
2727

28-
const pudt = new ccc.udt.Udt(pudtScriptCell.outPoint, pudtType, {
28+
const udt = new ccc.udt.Udt(udtScriptCell.outPoint, udtType, {
2929
executor,
3030
});
3131

32-
const pudtDecimals = await pudt.decimals();
32+
const udtDecimals = await udt.decimals();
3333

34-
console.log(pudtDecimals);
34+
console.log(udtDecimals);
3535
///
3636
// {"res":"6","cellDeps":[]}
3737
///

packages/examples/src/udt/icon.ts

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,32 +3,32 @@ import { signer } from "@ckb-ccc/playground";
33

44
const executor = new ccc.ssri.ExecutorJsonRpc("http://localhost:9090");
55

6-
const pudtScriptCell = await signer.client.findSingletonCellByType({
6+
const udtScriptCell = await signer.client.findSingletonCellByType({
77
// TypeID Code Hash. Don't change
88
codeHash:
99
"0x00000000000000000000000000000000000000000000000000545950455f4944",
1010
hashType: "type",
1111
// TypeID args. Change it to the args of the Type ID script of your UDT
1212
args: "0x8fd55df879dc6176c95f3c420631f990ada2d4ece978c9512c39616dead2ed56",
1313
});
14-
if (!pudtScriptCell) {
15-
throw new Error("PUDT script cell not found");
14+
if (!udtScriptCell) {
15+
throw new Error("udt script cell not found");
1616
}
1717

18-
const pudtCodeHash = pudtScriptCell.cellOutput.type?.hash();
19-
if (!pudtCodeHash) {
20-
throw new Error("PUDT code hash not found");
18+
const udtCodeHash = udtScriptCell.cellOutput.type?.hash();
19+
if (!udtCodeHash) {
20+
throw new Error("udt code hash not found");
2121
}
22-
const pudtType = {
23-
codeHash: pudtCodeHash,
22+
const udtType = {
23+
codeHash: udtCodeHash,
2424
hashType: "type",
2525
args: "0x02c93173368ec56f72ec023f63148461b80e7698eddd62cbd9dbe31a13f2b330",
2626
};
2727

28-
const pudt = new ccc.udt.Udt(pudtScriptCell.outPoint, pudtType, {
28+
const udt = new ccc.udt.Udt(udtScriptCell.outPoint, udtType, {
2929
executor,
3030
});
3131

32-
const pudtIcon = await pudt.icon();
33-
console.log(pudtIcon);
32+
const udtIcon = await udt.icon();
33+
console.log(udtIcon);
3434
// {"res":"Pausable UDT without external data","cellDeps":[]}

packages/examples/src/udt/mint.ts

Lines changed: 13 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -6,29 +6,29 @@ const executor = new ccc.ssri.ExecutorJsonRpc("http://localhost:9090");
66
const signerAddress = await signer.getRecommendedAddress();
77
const {script: signerLock} = await ccc.Address.fromString(signerAddress, signer.client);
88

9-
const pudtScriptCell = await signer.client.findSingletonCellByType({
9+
const udtScriptCell = await signer.client.findSingletonCellByType({
1010
// TypeID Code Hash. Don't change
1111
codeHash:
1212
"0x00000000000000000000000000000000000000000000000000545950455f4944",
1313
hashType: "type",
1414
// TypeID args. Change it to the args of the Type ID script of your UDT
1515
args: "0x8fd55df879dc6176c95f3c420631f990ada2d4ece978c9512c39616dead2ed56",
1616
});
17-
if (!pudtScriptCell) {
18-
throw new Error("PUDT script cell not found");
17+
if (!udtScriptCell) {
18+
throw new Error("udt script cell not found");
1919
}
2020

21-
const pudtCodeHash = pudtScriptCell.cellOutput.type?.hash();
22-
if (!pudtCodeHash) {
23-
throw new Error("PUDT code hash not found");
21+
const udtCodeHash = udtScriptCell.cellOutput.type?.hash();
22+
if (!udtCodeHash) {
23+
throw new Error("udt code hash not found");
2424
}
25-
const signerPudtType = {
26-
codeHash: pudtCodeHash,
25+
const signerUdtType = {
26+
codeHash: udtCodeHash,
2727
hashType: "type",
2828
args: signerLock.hash()
2929
};
3030

31-
const signerPudt = new ccc.udt.Udt(pudtScriptCell.outPoint, signerPudtType, {
31+
const signerUdt = new ccc.udt.Udt(udtScriptCell.outPoint, signerUdtType, {
3232
executor,
3333
});
3434

@@ -49,8 +49,8 @@ const { script: lockB } = await ccc.Address.fromString(
4949
signer.client,
5050
);
5151

52-
const signerPudtMintTx = (
53-
await signerPudt.mint(signer, [
52+
const signerUdtMintTx = (
53+
await signerUdt.mint(signer, [
5454
{
5555
to: lockA,
5656
amount: 1000000000000000000,
@@ -62,9 +62,5 @@ const signerPudtMintTx = (
6262
])
6363
).res;
6464

65-
await signerPudtMintTx.completeFeeBy(signer);
66-
await render(signerPudtMintTx);
67-
68-
const signerPudtMintTxHash = await signer.sendTransaction(signerPudtMintTx);
69-
70-
console.log(signerPudtMintTxHash);
65+
await signerUdtMintTx.completeFeeBy(signer);
66+
await render(signerUdtMintTx);

packages/examples/src/udt/name.ts

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,32 +3,32 @@ import { signer } from "@ckb-ccc/playground";
33

44
const executor = new ccc.ssri.ExecutorJsonRpc("http://localhost:9090");
55

6-
const pudtScriptCell = await signer.client.findSingletonCellByType({
6+
const udtScriptCell = await signer.client.findSingletonCellByType({
77
// TypeID Code Hash. Don't change
88
codeHash:
99
"0x00000000000000000000000000000000000000000000000000545950455f4944",
1010
hashType: "type",
1111
// TypeID args. Change it to the args of the Type ID script of your UDT
1212
args: "0x8fd55df879dc6176c95f3c420631f990ada2d4ece978c9512c39616dead2ed56",
1313
});
14-
if (!pudtScriptCell) {
15-
throw new Error("PUDT script cell not found");
14+
if (!udtScriptCell) {
15+
throw new Error("udt script cell not found");
1616
}
1717

18-
const pudtCodeHash = pudtScriptCell.cellOutput.type?.hash();
19-
if (!pudtCodeHash) {
20-
throw new Error("PUDT code hash not found");
18+
const udtCodeHash = udtScriptCell.cellOutput.type?.hash();
19+
if (!udtCodeHash) {
20+
throw new Error("udt code hash not found");
2121
}
22-
const pudtType = {
23-
codeHash: pudtCodeHash,
22+
const udtType = {
23+
codeHash: udtCodeHash,
2424
hashType: "type",
2525
args: "0x02c93173368ec56f72ec023f63148461b80e7698eddd62cbd9dbe31a13f2b330",
2626
};
2727

28-
const pudt = new ccc.udt.Udt(pudtScriptCell.outPoint, pudtType, {
28+
const udt = new ccc.udt.Udt(udtScriptCell.outPoint, udtType, {
2929
executor,
3030
});
3131

32-
const pudtName = await pudt.name();
33-
console.log(pudtName);
32+
const udtName = await udt.name();
33+
console.log(udtName);
3434
// {"res":"Pausable UDT without external data","cellDeps":[]}

0 commit comments

Comments
 (0)