From 61f61de4483a0f83ca4b0fa1a75bd1002bc3337b Mon Sep 17 00:00:00 2001 From: ahonn Date: Tue, 23 Apr 2024 15:35:13 +1000 Subject: [PATCH 1/2] feat: upgrade rgbpp sdk to support spore type cell --- package.json | 8 +-- pnpm-lock.yaml | 165 ++++++++++++++++++++++--------------------------- 2 files changed, 78 insertions(+), 95 deletions(-) diff --git a/package.json b/package.json index d3e76652..6aa0849a 100644 --- a/package.json +++ b/package.json @@ -28,7 +28,7 @@ "@ckb-lumos/base": "^0.21.1", "@ckb-lumos/ckb-indexer": "^0.21.1", "@ckb-lumos/codec": "^0.21.1", - "@ckb-lumos/lumos": "^0.21.1", + "@ckb-lumos/lumos": "0.22.0-next.5", "@fastify/compress": "^7.0.0", "@fastify/cors": "^9.0.1", "@fastify/http-proxy": "^9.4.0", @@ -40,9 +40,9 @@ "@fastify/swagger-ui": "^3.0.0", "@immobiliarelabs/fastify-sentry": "^8.0.1", "@nervosnetwork/ckb-sdk-utils": "^0.109.1", - "@rgbpp-sdk/btc": "0.0.0-snap-20240406174830", - "@rgbpp-sdk/ckb": "0.0.0-snap-20240406174830", - "@rgbpp-sdk/service": "0.0.0-snap-20240406174830", + "@rgbpp-sdk/btc": "0.0.0-snap-20240423032314", + "@rgbpp-sdk/ckb": "0.0.0-snap-20240423032314", + "@rgbpp-sdk/service": "0.0.0-snap-20240423032314", "@sentry/node": "^7.102.1", "@sentry/profiling-node": "^7.102.1", "awilix": "^10.0.1", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index e1576d79..910bb4be 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -15,8 +15,8 @@ dependencies: specifier: ^0.21.1 version: 0.21.1 '@ckb-lumos/lumos': - specifier: ^0.21.1 - version: 0.21.1 + specifier: 0.22.0-next.5 + version: 0.22.0-next.5 '@fastify/compress': specifier: ^7.0.0 version: 7.0.0 @@ -51,14 +51,14 @@ dependencies: specifier: ^0.109.1 version: 0.109.1 '@rgbpp-sdk/btc': - specifier: 0.0.0-snap-20240406174830 - version: 0.0.0-snap-20240406174830 + specifier: 0.0.0-snap-20240423032314 + version: 0.0.0-snap-20240423032314(@ckb-lumos/lumos@0.22.0-next.5) '@rgbpp-sdk/ckb': - specifier: 0.0.0-snap-20240406174830 - version: 0.0.0-snap-20240406174830 + specifier: 0.0.0-snap-20240423032314 + version: 0.0.0-snap-20240423032314(@ckb-lumos/lumos@0.22.0-next.5)(lodash@4.17.21) '@rgbpp-sdk/service': - specifier: 0.0.0-snap-20240406174830 - version: 0.0.0-snap-20240406174830 + specifier: 0.0.0-snap-20240423032314 + version: 0.0.0-snap-20240423032314 '@sentry/node': specifier: ^7.102.1 version: 7.102.1 @@ -423,6 +423,20 @@ packages: lodash.isequal: 4.5.0 dev: false + /@ckb-lumos/base@0.22.2: + resolution: {integrity: sha512-nosUCSa5rTV2IzxbEpqzrvUeQNXB66mgA0h40+QEdnE/gV/s4ke83AScrTAxWkErJy1G/sToIHCc2kWwO95DfQ==} + engines: {node: '>=12.0.0'} + dependencies: + '@ckb-lumos/bi': 0.22.2 + '@ckb-lumos/codec': 0.22.2 + '@ckb-lumos/toolkit': 0.22.2 + '@types/blake2b': 2.1.3 + '@types/lodash.isequal': 4.5.8 + blake2b: 2.1.4 + js-xxhash: 1.0.4 + lodash.isequal: 4.5.0 + dev: false + /@ckb-lumos/bi@0.21.1: resolution: {integrity: sha512-6q8uesvu3DAM7GReei9H5seino4tnakTeg8uXtZBPDC6rboMohLCPQvEwhl1iHmsybXvBYVQt4Te1BPPZtuaRw==} engines: {node: '>=12.0.0'} @@ -437,6 +451,13 @@ packages: jsbi: 4.3.0 dev: false + /@ckb-lumos/bi@0.22.2: + resolution: {integrity: sha512-F+dLC/tE+xdtNuGgJxlDqbgX/f8azg1tvIFTR5mu7Vhz08nkFgnA+Z+yC0t/I3fDwwH4p/SlGP/yducrsfVTqw==} + engines: {node: '>=12.0.0'} + dependencies: + jsbi: 4.3.0 + dev: false + /@ckb-lumos/ckb-indexer@0.21.1: resolution: {integrity: sha512-592pMVP3lwTXF7TmlOcayvGYKOhkYpjbLHUDo7By4yWbm7ZpdexaN5hn0X1sjJgMuee5prxGr9/fY684VTpJQw==} engines: {node: '>=12.0.0'} @@ -481,20 +502,11 @@ packages: '@ckb-lumos/bi': 0.22.0-next.5 dev: false - /@ckb-lumos/common-scripts@0.21.1: - resolution: {integrity: sha512-EfZQ9wdxPmEsxVVwtBjhpZVKbYCm1FJkMt59ABsIO1Ub7yi0qap7AQl0MMbuLwWIGKwS2w0U3wx/oJPm7z1RXg==} + /@ckb-lumos/codec@0.22.2: + resolution: {integrity: sha512-P5SyhT2qkJwCwcHF3yMLInE0z3wWHDkqJNbSM2Q9oyu0+9kjMQfexNia3T+atBl2M7ELFzN5WvttojYr6DrCwQ==} engines: {node: '>=12.0.0'} dependencies: - '@ckb-lumos/base': 0.21.1 - '@ckb-lumos/bi': 0.21.1 - '@ckb-lumos/codec': 0.21.1 - '@ckb-lumos/config-manager': 0.21.1 - '@ckb-lumos/helpers': 0.21.1 - '@ckb-lumos/rpc': 0.21.1 - '@ckb-lumos/toolkit': 0.21.1 - immutable: 4.3.5 - transitivePeerDependencies: - - encoding + '@ckb-lumos/bi': 0.22.2 dev: false /@ckb-lumos/common-scripts@0.22.0-next.5: @@ -515,17 +527,6 @@ packages: - encoding dev: false - /@ckb-lumos/config-manager@0.21.1: - resolution: {integrity: sha512-BmrNqYyaksdCKHWagyC8+R8GUxhIO+sOM5S925jlkpjju2sUbH0Id2/zmdb7I9KxdKnbx3WsR+hqy7/bYqw1lA==} - engines: {node: '>=12.0.0'} - dependencies: - '@ckb-lumos/base': 0.21.1 - '@ckb-lumos/bi': 0.21.1 - '@ckb-lumos/codec': 0.21.1 - '@types/deep-freeze-strict': 1.1.2 - deep-freeze-strict: 1.1.1 - dev: false - /@ckb-lumos/config-manager@0.22.0-next.5: resolution: {integrity: sha512-kicoRgPP9DPxA90que/+9R0iQgiIJQNreZv1/EJ+4GDOj/pFb0iBbTEQxF3zXtLKjnZoMTqTQH7e4CAV0ZftSA==} engines: {node: '>=12.0.0'} @@ -540,19 +541,6 @@ packages: - encoding dev: false - /@ckb-lumos/hd@0.21.1: - resolution: {integrity: sha512-BnfpJf/sx/dJzL5BrOxPeKbKgv2x74KWd0xwjw1/gBQ2IMhu0S1mLwFsOT3Zu2nuhpQYvZGvr0cd3vD/SoMDow==} - engines: {node: '>=12.0.0'} - dependencies: - '@ckb-lumos/base': 0.21.1 - '@ckb-lumos/bi': 0.21.1 - bn.js: 5.2.1 - elliptic: 6.5.5 - scrypt-js: 3.0.1 - sha3: 2.1.4 - uuid: 8.3.2 - dev: false - /@ckb-lumos/hd@0.22.0-next.5: resolution: {integrity: sha512-d+Ws/fknuh+P9+aEBhLWiCOxMVE6i78T+2bEj8aWDLoVfrLvuCqFEyVRCspOG22pgEj0h853nMsetrb4pI+fdw==} engines: {node: '>=12.0.0'} @@ -566,19 +554,6 @@ packages: uuid: 8.3.2 dev: false - /@ckb-lumos/helpers@0.21.1: - resolution: {integrity: sha512-jFN6DtWzwVNEY4kmnzczRaQqtyRJQwzAEuHRUQ0LqTiIGM+SlfgjH/l/InAG4cIhDOurMudnUJ4ex68wmbkhVw==} - engines: {node: '>=12.0.0'} - dependencies: - '@ckb-lumos/base': 0.21.1 - '@ckb-lumos/bi': 0.21.1 - '@ckb-lumos/codec': 0.21.1 - '@ckb-lumos/config-manager': 0.21.1 - '@ckb-lumos/toolkit': 0.21.1 - bech32: 2.0.0 - immutable: 4.3.5 - dev: false - /@ckb-lumos/helpers@0.22.0-next.5: resolution: {integrity: sha512-fsPr7oTQuKdfEvqdakgfDv9daU4PLPc9g8l13klMhEayaTamBndG3GdhTTASFMBxQaz58E6thTObsig220yVIg==} engines: {node: '>=12.0.0'} @@ -607,23 +582,6 @@ packages: - encoding dev: false - /@ckb-lumos/lumos@0.21.1: - resolution: {integrity: sha512-a5n8xaIUvmaPsw2fBki8Jamy6/6uQnLWDZM9SQX29cZ1YVoAk/slnBmEbCIGXmxDhcuAlLkTeJaiLDKEGrZ6pg==} - engines: {node: '>=12.0.0'} - dependencies: - '@ckb-lumos/base': 0.21.1 - '@ckb-lumos/bi': 0.21.1 - '@ckb-lumos/ckb-indexer': 0.21.1 - '@ckb-lumos/common-scripts': 0.21.1 - '@ckb-lumos/config-manager': 0.21.1 - '@ckb-lumos/hd': 0.21.1 - '@ckb-lumos/helpers': 0.21.1 - '@ckb-lumos/rpc': 0.21.1 - '@ckb-lumos/toolkit': 0.21.1 - transitivePeerDependencies: - - encoding - dev: false - /@ckb-lumos/lumos@0.22.0-next.5: resolution: {integrity: sha512-Dv+MKa664zsD9Nxrnor04Hb52MNcwgtEutgzdlE+qtAB/skp6P0NVnU9uQF7RiYHNpdmUe8PROlkzB4jaKz9NA==} engines: {node: '>=12.0.0'} @@ -682,6 +640,13 @@ packages: '@ckb-lumos/bi': 0.22.0-next.5 dev: false + /@ckb-lumos/toolkit@0.22.2: + resolution: {integrity: sha512-HmKz2dGQeaW2XDqkvjJfLv50VQWGKbthg2RDfIxGsZyjveluRROTyuHP1akypy4pqF8TApGLsXci2MaHCRau+w==} + engines: {node: '>=12.0.0'} + dependencies: + '@ckb-lumos/bi': 0.22.2 + dev: false + /@ckb-lumos/transaction-manager@0.22.0-next.5: resolution: {integrity: sha512-Xs10tTPgxqrB1cUMUqTdAZDDpTs3ESxPLv9HmyR2jLFI6HVJjSbGJipXODYJaJ+iUNPG/qZaehHmuQoGgbBwiw==} engines: {node: '>=12.0.0'} @@ -974,6 +939,11 @@ packages: engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} dev: true + /@exact-realty/multipart-parser@1.0.13: + resolution: {integrity: sha512-BGnB0VVn18dkz85rvBmp/CyxAMvUcVrsNf3qw8Fdx80V6+MsQUTxRdQnC0PzLIxbN8PKGFs8afd+ur8V1JLv8g==} + engines: {node: '>=16.0.0', npm: '>=8.0.0'} + dev: false + /@fastify/accept-negotiator@1.1.0: resolution: {integrity: sha512-OIHZrb2ImZ7XG85HXOONLcJWGosv7sIvM2ifAPQVhg9Lv7qdmMBNVaai4QTdyuaqbKM5eO6sLSQOYI7wEQeCJQ==} engines: {node: '>=14'} @@ -1384,50 +1354,53 @@ packages: resolution: {integrity: sha512-2LuNTFBIO0m7kKIQvvPHN6UE63VjpmL9rnEEaOOaiSPbZK+zUOYIzBAWcED+3XYzhYsd/0mD57VdxAEqqV52CQ==} dev: true - /@rgbpp-sdk/btc@0.0.0-snap-20240406174830: - resolution: {integrity: sha512-c/d0zxLpYq/Lz/EwiaUum+CEojJ7RopAZzCpR8mQ0dGBKvyWffN8FXf/yYx8rU+1yhxQOhC3oqI2MiK9esnFNA==} + /@rgbpp-sdk/btc@0.0.0-snap-20240423032314(@ckb-lumos/lumos@0.22.0-next.5): + resolution: {integrity: sha512-QtzBjXZq5ZTcT4uYtqeDh8fzt7ziTJvCDkpa+Jafddh+h6D/67vd8Ps6wzowmwWNfjWW8yMEsHEw8qg/l0zmtQ==} dependencies: '@bitcoinerlab/secp256k1': 1.1.1 - '@ckb-lumos/lumos': 0.22.0-next.5 + '@ckb-lumos/codec': 0.22.2 '@mempool/mempool.js': 2.3.0 '@nervosnetwork/ckb-types': 0.109.1 - '@rgbpp-sdk/ckb': 0.0.0-snap-20240406174830 - '@rgbpp-sdk/service': 0.0.0-snap-20240406174830 + '@rgbpp-sdk/ckb': 0.0.0-snap-20240423032314(@ckb-lumos/lumos@0.22.0-next.5)(lodash@4.17.21) + '@rgbpp-sdk/service': 0.0.0-snap-20240423032314 bip32: 4.0.0 bitcoinjs-lib: 6.1.5 ecpair: 2.1.0 lodash: 4.17.21 transitivePeerDependencies: + - '@ckb-lumos/lumos' - bufferutil - debug - - encoding - utf-8-validate dev: false - /@rgbpp-sdk/ckb@0.0.0-snap-20240406174830: - resolution: {integrity: sha512-3FdopioFScWpK7tgetxx2M6aJ5ggwl5PpSXugcpaoicbWAqKvb0FwIUzUZLB5p8YWuNEHHw+sdLiXba3SUxakQ==} + /@rgbpp-sdk/ckb@0.0.0-snap-20240423032314(@ckb-lumos/lumos@0.22.0-next.5)(lodash@4.17.21): + resolution: {integrity: sha512-rvBFdx15bZAf8y81X6YyFgl9rC4OfkJ9I06laegB2q7kCbBUW+xyF6NtF9UNgdjp6IUCu2ZA5t3Nc4Q9eyaiqw==} dependencies: - '@ckb-lumos/base': 0.21.1 - '@ckb-lumos/codec': 0.22.0-next.5 + '@ckb-lumos/base': 0.22.2 + '@ckb-lumos/codec': 0.22.2 + '@exact-realty/multipart-parser': 1.0.13 '@nervosnetwork/ckb-sdk-core': 0.109.1 '@nervosnetwork/ckb-sdk-utils': 0.109.1 '@nervosnetwork/ckb-types': 0.109.1 - '@rgbpp-sdk/service': 0.0.0-snap-20240406174830 + '@rgbpp-sdk/service': 0.0.0-snap-20240423032314 + '@spore-sdk/core': 0.2.0-beta.8(@ckb-lumos/lumos@0.22.0-next.5)(lodash@4.17.21) axios: 1.6.8 camelcase-keys: 7.0.2 js-sha256: 0.11.0 transitivePeerDependencies: + - '@ckb-lumos/lumos' - debug - - encoding + - lodash dev: false - /@rgbpp-sdk/service@0.0.0-snap-20240406174830: - resolution: {integrity: sha512-V/zmYLBnjtx7XD6zz6iUknOS9O+Tgligob5SO3xUcvloBpSUQcYZ/fIj7sj4YtmN8RPCaex+TLevuJ9gc5FzrQ==} + /@rgbpp-sdk/service@0.0.0-snap-20240423032314: + resolution: {integrity: sha512-LJYYLnQUGm3pshIxWiw/MxAPEFwJOLHz93D49BDjAm5YRoIpqLGIrBsvUGjEvXpVkJ8ULe19uD8Cj0a0iJ60Aw==} dependencies: - '@ckb-lumos/lumos': 0.22.0-next.5 + '@ckb-lumos/base': 0.22.2 + '@ckb-lumos/codec': 0.22.2 '@nervosnetwork/ckb-types': 0.109.1 - transitivePeerDependencies: - - encoding + lodash: 4.17.21 dev: false /@rollup/pluginutils@4.2.1: @@ -1649,6 +1622,16 @@ packages: resolution: {integrity: sha512-+Fj43pSMwJs4KRrH/938Uf+uAELIgVBmQzg/q1YG10djyfA3TnrU8N8XzqCh/okZdszqBQTZf96idMfE5lnwTA==} dev: true + /@spore-sdk/core@0.2.0-beta.8(@ckb-lumos/lumos@0.22.0-next.5)(lodash@4.17.21): + resolution: {integrity: sha512-2u0e544JDQMVnJOcO3QK9G7yNrbj6nju8PH78k7+/cf9EbOltDudZCpU3YpgffsdMOKhfmpY8xCAq4w/+Jjm1Q==} + peerDependencies: + '@ckb-lumos/lumos': 0.22.0-next.5 + lodash: ^4.17.21 + dependencies: + '@ckb-lumos/lumos': 0.22.0-next.5 + lodash: 4.17.21 + dev: false + /@tootallnate/once@2.0.0: resolution: {integrity: sha512-XCuKFP5PS55gnMVu3dty8KPatLqUoy/ZYzDzAGCQ8JNFCkLXzmI7vNHCR+XpbZaMWQK/vQubr7PkYq8g470J/A==} engines: {node: '>= 10'} From dd3beabf05317cb91d888e502ee8e20d0d5e7e7b Mon Sep 17 00:00:00 2001 From: ahonn Date: Wed, 24 Apr 2024 11:40:50 +1000 Subject: [PATCH 2/2] feat(transaction): append spore cobuild witness when processing spore transfer transaction --- package.json | 6 +++--- pnpm-lock.yaml | 30 +++++++++++++++--------------- src/services/transaction.ts | 37 ++++++++++++++++++++++++++++++++++++- 3 files changed, 54 insertions(+), 19 deletions(-) diff --git a/package.json b/package.json index 6aa0849a..a79dbc00 100644 --- a/package.json +++ b/package.json @@ -40,9 +40,9 @@ "@fastify/swagger-ui": "^3.0.0", "@immobiliarelabs/fastify-sentry": "^8.0.1", "@nervosnetwork/ckb-sdk-utils": "^0.109.1", - "@rgbpp-sdk/btc": "0.0.0-snap-20240423032314", - "@rgbpp-sdk/ckb": "0.0.0-snap-20240423032314", - "@rgbpp-sdk/service": "0.0.0-snap-20240423032314", + "@rgbpp-sdk/btc": "0.0.0-snap-20240423144119", + "@rgbpp-sdk/ckb": "0.0.0-snap-20240423144119", + "@rgbpp-sdk/service": "0.0.0-snap-20240423144119", "@sentry/node": "^7.102.1", "@sentry/profiling-node": "^7.102.1", "awilix": "^10.0.1", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 910bb4be..246f152e 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -51,14 +51,14 @@ dependencies: specifier: ^0.109.1 version: 0.109.1 '@rgbpp-sdk/btc': - specifier: 0.0.0-snap-20240423032314 - version: 0.0.0-snap-20240423032314(@ckb-lumos/lumos@0.22.0-next.5) + specifier: 0.0.0-snap-20240423144119 + version: 0.0.0-snap-20240423144119(@ckb-lumos/lumos@0.22.0-next.5) '@rgbpp-sdk/ckb': - specifier: 0.0.0-snap-20240423032314 - version: 0.0.0-snap-20240423032314(@ckb-lumos/lumos@0.22.0-next.5)(lodash@4.17.21) + specifier: 0.0.0-snap-20240423144119 + version: 0.0.0-snap-20240423144119(@ckb-lumos/lumos@0.22.0-next.5)(lodash@4.17.21) '@rgbpp-sdk/service': - specifier: 0.0.0-snap-20240423032314 - version: 0.0.0-snap-20240423032314 + specifier: 0.0.0-snap-20240423144119 + version: 0.0.0-snap-20240423144119 '@sentry/node': specifier: ^7.102.1 version: 7.102.1 @@ -1354,15 +1354,15 @@ packages: resolution: {integrity: sha512-2LuNTFBIO0m7kKIQvvPHN6UE63VjpmL9rnEEaOOaiSPbZK+zUOYIzBAWcED+3XYzhYsd/0mD57VdxAEqqV52CQ==} dev: true - /@rgbpp-sdk/btc@0.0.0-snap-20240423032314(@ckb-lumos/lumos@0.22.0-next.5): - resolution: {integrity: sha512-QtzBjXZq5ZTcT4uYtqeDh8fzt7ziTJvCDkpa+Jafddh+h6D/67vd8Ps6wzowmwWNfjWW8yMEsHEw8qg/l0zmtQ==} + /@rgbpp-sdk/btc@0.0.0-snap-20240423144119(@ckb-lumos/lumos@0.22.0-next.5): + resolution: {integrity: sha512-8m8LMg0zROX06gqLBP4Q3UGKkWB1zAd7jvvtbw+DOne3xZSWpswC94f4lK5/NGkVb7tjtDRa6y0/6LABkNgX6A==} dependencies: '@bitcoinerlab/secp256k1': 1.1.1 '@ckb-lumos/codec': 0.22.2 '@mempool/mempool.js': 2.3.0 '@nervosnetwork/ckb-types': 0.109.1 - '@rgbpp-sdk/ckb': 0.0.0-snap-20240423032314(@ckb-lumos/lumos@0.22.0-next.5)(lodash@4.17.21) - '@rgbpp-sdk/service': 0.0.0-snap-20240423032314 + '@rgbpp-sdk/ckb': 0.0.0-snap-20240423144119(@ckb-lumos/lumos@0.22.0-next.5)(lodash@4.17.21) + '@rgbpp-sdk/service': 0.0.0-snap-20240423144119 bip32: 4.0.0 bitcoinjs-lib: 6.1.5 ecpair: 2.1.0 @@ -1374,8 +1374,8 @@ packages: - utf-8-validate dev: false - /@rgbpp-sdk/ckb@0.0.0-snap-20240423032314(@ckb-lumos/lumos@0.22.0-next.5)(lodash@4.17.21): - resolution: {integrity: sha512-rvBFdx15bZAf8y81X6YyFgl9rC4OfkJ9I06laegB2q7kCbBUW+xyF6NtF9UNgdjp6IUCu2ZA5t3Nc4Q9eyaiqw==} + /@rgbpp-sdk/ckb@0.0.0-snap-20240423144119(@ckb-lumos/lumos@0.22.0-next.5)(lodash@4.17.21): + resolution: {integrity: sha512-x5lJPQIa93/+eQPjRL8Yca654pThTrKrmWnUisqVLYOHytOxW8o++TDe985ihkChfzEZcCarZ/Cinc53zK0nkg==} dependencies: '@ckb-lumos/base': 0.22.2 '@ckb-lumos/codec': 0.22.2 @@ -1383,7 +1383,7 @@ packages: '@nervosnetwork/ckb-sdk-core': 0.109.1 '@nervosnetwork/ckb-sdk-utils': 0.109.1 '@nervosnetwork/ckb-types': 0.109.1 - '@rgbpp-sdk/service': 0.0.0-snap-20240423032314 + '@rgbpp-sdk/service': 0.0.0-snap-20240423144119 '@spore-sdk/core': 0.2.0-beta.8(@ckb-lumos/lumos@0.22.0-next.5)(lodash@4.17.21) axios: 1.6.8 camelcase-keys: 7.0.2 @@ -1394,8 +1394,8 @@ packages: - lodash dev: false - /@rgbpp-sdk/service@0.0.0-snap-20240423032314: - resolution: {integrity: sha512-LJYYLnQUGm3pshIxWiw/MxAPEFwJOLHz93D49BDjAm5YRoIpqLGIrBsvUGjEvXpVkJ8ULe19uD8Cj0a0iJ60Aw==} + /@rgbpp-sdk/service@0.0.0-snap-20240423144119: + resolution: {integrity: sha512-UNwABcpRvFk+2bWdyhVKrAatgqVTRCcekEQzV8kRWPZhR7Yi9oeR+aJ4iP9/vC3ibPIlxLHxcO7k85HNi7JTcA==} dependencies: '@ckb-lumos/base': 0.22.2 '@ckb-lumos/codec': 0.22.2 diff --git a/src/services/transaction.ts b/src/services/transaction.ts index 3339977b..1f9fd569 100644 --- a/src/services/transaction.ts +++ b/src/services/transaction.ts @@ -4,9 +4,12 @@ import { RGBPPLock, RGBPP_TX_ID_PLACEHOLDER, appendCkbTxWitnesses, + generateSporeTransferCoBuild, getBtcTimeLockScript, getRgbppLockScript, getSecp256k1CellDep, + getSporeTypeDep, + isClusterSporeTypeSupported, updateCkbTxWithRealBtcTxId, } from '@rgbpp-sdk/ckb'; import { @@ -30,6 +33,7 @@ import { BI } from '@ckb-lumos/lumos'; import { CKBRpcError, CKBRPCErrorCodes } from './ckb'; import { cloneDeep } from 'lodash'; import { JwtPayload } from '../plugins/jwt'; +import { serializeCellDep } from '@nervosnetwork/ckb-sdk-utils'; export interface ITransactionRequest { txid: string; @@ -314,11 +318,42 @@ export default class TransactionManager implements ITransactionManager { ]); // using for spv proof, we need to remove the witness data from the transaction const hexWithoutWitness = transactionToHex(BitcoinTransaction.fromHex(hex), false); - const signedTx = await appendCkbTxWitnesses({ + let signedTx = await appendCkbTxWitnesses({ ckbRawTx, btcTxBytes: hexWithoutWitness, rgbppApiSpvProof, })!; + + // append the spore cobuild witness to the transaction if needed + const sporeTypeDep = getSporeTypeDep(this.isMainnet); + const hasSporeTypeDep = signedTx.cellDeps.some((cellDep) => { + return serializeCellDep(cellDep) === serializeCellDep(sporeTypeDep); + }); + if (hasSporeTypeDep) { + signedTx = await this.appendSporeCobuildWitness(signedTx); + } + + return signedTx; + } + + /** + * Append the spore cobuild witness to the transaction if the input contains spore cell + * (support spore transfer only for now, will support more in the future) + * @param signedTx - the signed CKB transaction + */ + private async appendSporeCobuildWitness(signedTx: CKBRawTransaction) { + const inputs = await Promise.all( + signedTx.inputs.map(async (input) => { + return this.cradle.ckb.rpc.getLiveCell(input.previousOutput!, false); + }), + ); + const sporeLiveCell = inputs.find(({ cell }) => { + return cell?.output.type && isClusterSporeTypeSupported(cell?.output.type, this.isMainnet); + }); + if (sporeLiveCell?.cell) { + const [output] = signedTx.outputs; + signedTx.witnesses[signedTx.witnesses.length - 1] = generateSporeTransferCoBuild(sporeLiveCell.cell, output); + } return signedTx; }