From 7c2ee5767f30c85d07fc847013a6344602c2727d Mon Sep 17 00:00:00 2001 From: sunchengzhu Date: Tue, 23 Apr 2024 16:45:01 +0800 Subject: [PATCH 1/2] add xudt config --- packages/config-manager/src/predefined.ts | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/packages/config-manager/src/predefined.ts b/packages/config-manager/src/predefined.ts index 9e8b00ed0..6161c8d0b 100644 --- a/packages/config-manager/src/predefined.ts +++ b/packages/config-manager/src/predefined.ts @@ -74,6 +74,15 @@ const LINA = createConfig({ INDEX: "0x0", DEP_TYPE: "code", }, + XUDT: { + CODE_HASH: + "0x50bd8d6680b8b9cf98b73f3c08faf8b2a21914311954118ad6609be6e78a1b95", + HASH_TYPE: "data1", + TX_HASH: + "0xc07844ce21b38e4b071dd0e1ee3b0e27afd8d7532491327f39b786343f558ab7", + INDEX: "0x0", + DEP_TYPE: "code", + }, }, }); @@ -137,6 +146,15 @@ const AGGRON4 = createConfig({ INDEX: "0x0", DEP_TYPE: "code", }, + XUDT: { + CODE_HASH: + "0x25c29dc317811a6f6f3985a7a9ebc4838bd388d19d0feeecf0bcd60f6c0975bb", + HASH_TYPE: "type", + TX_HASH: + "0xbf6fb538763efec2a70a6a3dcb7242787087e1030c4e7d86585bc63a9d337f5f", + INDEX: "0x0", + DEP_TYPE: "code", + }, }, }); From ff0b583a35a089c6b61fb34ff2ad00e6b8be660c Mon Sep 17 00:00:00 2001 From: homura Date: Sun, 28 Apr 2024 19:10:15 +0900 Subject: [PATCH 2/2] feat(common-scripts): support signing with phantom on solana (#663) --- .eslintrc.next.js | 22 +- examples/omni-lock-metamask/package.json | 3 + examples/omni-lock-solana/README.md | 21 + examples/omni-lock-solana/index.html | 13 + examples/omni-lock-solana/index.tsx | 93 ++ examples/omni-lock-solana/lib.ts | 71 + examples/omni-lock-solana/package.json | 22 + examples/omni-lock-solana/tsconfig.json | 9 + examples/omni-lock-unisat/README.md | 4 +- examples/pnpm-lock.yaml | 1437 ++++++++++++++--- packages/common-scripts/package.json | 3 +- packages/common-scripts/src/helper.ts | 25 +- .../common-scripts/src/omnilock-solana.ts | 59 + packages/common-scripts/src/omnilock.ts | 86 +- packages/common-scripts/tests/inputs.ts | 4 +- .../tests/omnilock-solana.test.ts | 90 ++ .../{omni_lock_9419b77 => omni_lock_1a09a42} | Bin 123552 -> 139936 bytes packages/debugger/src/context.ts | 9 +- packages/lumos/src/common-scripts/omnilock.ts | 1 + pnpm-lock.yaml | 7 + 20 files changed, 1714 insertions(+), 265 deletions(-) create mode 100644 examples/omni-lock-solana/README.md create mode 100644 examples/omni-lock-solana/index.html create mode 100644 examples/omni-lock-solana/index.tsx create mode 100644 examples/omni-lock-solana/lib.ts create mode 100644 examples/omni-lock-solana/package.json create mode 100644 examples/omni-lock-solana/tsconfig.json create mode 100644 packages/common-scripts/src/omnilock-solana.ts create mode 100644 packages/common-scripts/tests/omnilock-solana.test.ts rename packages/debugger/contracts/{omni_lock_9419b77 => omni_lock_1a09a42} (68%) mode change 100755 => 100644 diff --git a/.eslintrc.next.js b/.eslintrc.next.js index d95078af3..0b3f580c2 100644 --- a/.eslintrc.next.js +++ b/.eslintrc.next.js @@ -7,15 +7,25 @@ module.exports = { tsconfigRootDir: __dirname, project: ["./tsconfig.json", "packages/*/tsconfig.json"], }, - extends: [ - "eslint:recommended", - "plugin:@typescript-eslint/recommended" - ], + extends: ["eslint:recommended", "plugin:@typescript-eslint/recommended"], rules: { "@typescript-eslint/no-explicit-any": "error", "@typescript-eslint/explicit-module-boundary-types": "error", - "no-constant-condition": ["error", { "checkLoops": false }] - } + "no-constant-condition": ["error", { checkLoops: false }], + "@typescript-eslint/no-magic-numbers": [ + "error", + { + ignoreEnums: true, + ignoreArrayIndexes: true, + ignore: [ + -1, // index -1 is not found + 0, // first element of an array + 1, // common for i + 1 in a loop + 16, // toString(16) + ], + }, + ], + }, }, ], }; diff --git a/examples/omni-lock-metamask/package.json b/examples/omni-lock-metamask/package.json index 4d50b6587..d2ca2ee1d 100644 --- a/examples/omni-lock-metamask/package.json +++ b/examples/omni-lock-metamask/package.json @@ -15,5 +15,8 @@ "@types/react-dom": "^18.0.9", "react": "18.2.0", "react-dom": "18.2.0" + }, + "devDependencies": { + "parcel": "^2.9.5" } } diff --git a/examples/omni-lock-solana/README.md b/examples/omni-lock-solana/README.md new file mode 100644 index 000000000..349ef17a9 --- /dev/null +++ b/examples/omni-lock-solana/README.md @@ -0,0 +1,21 @@ +# Lumos Works with Solana + +Nervos maintains a powerful lock +called [Omnilock](https://github.com/nervosnetwork/rfcs/blob/master/rfcs/0042-omnilock/0042-omnilock.md) (previously named RC lock), which +can use Phantom as a signer. This example will show how to use Lumos to send a transaction using Omnilock and Phantom + +## Quick Start + +> we should [build](..) Lumos project first before we start this example + +``` +npm run build +cd examples/omni-lock-solana +npm start +``` + +## Links + +- [Phantom](https://phantom.app/) - A crypto wallet for Solana +- [Nervos Faucet](https://faucet.nervos.org/) - Claim Nervos testnet CKB +- [Omnilock](https://github.com/nervosnetwork/rfcs/blob/master/rfcs/0042-omnilock/0042-omnilock.md) - Omnilock intro diff --git a/examples/omni-lock-solana/index.html b/examples/omni-lock-solana/index.html new file mode 100644 index 000000000..9df193edc --- /dev/null +++ b/examples/omni-lock-solana/index.html @@ -0,0 +1,13 @@ + + + + + + + Lumos ❤️ Solana & Phantom + + +
+ + + diff --git a/examples/omni-lock-solana/index.tsx b/examples/omni-lock-solana/index.tsx new file mode 100644 index 000000000..deffbdfd4 --- /dev/null +++ b/examples/omni-lock-solana/index.tsx @@ -0,0 +1,93 @@ +import React, { useEffect, useState } from "react"; +import { helpers, Script, config, commons } from "@ckb-lumos/lumos"; +import ReactDOM from "react-dom"; +import { asyncSleep, capacityOf, solana, transfer } from "./lib"; + +const App: React.FC = () => { + const [solanaAddr, setSolanaAddr] = useState(""); + const [omniAddr, setOmniAddr] = useState(""); + const [omniLock, setOmniLock] = useState