@ckb-lumos/experiment-tx-assembler
Advanced tools
Comparing version 0.18.0 to 0.19.0-alpha.0
import { Script, CellDep, HexString, OutPoint, Hash, HexNumber, Cell } from "@ckb-lumos/base"; | ||
import { BIish } from "@ckb-lumos/bi"; | ||
import { ScriptConfigs } from "@ckb-lumos/config-manager"; | ||
import { Reader } from "@ckb-lumos/toolkit"; | ||
interface ScriptRegistry<T extends ScriptConfigs> { | ||
extend: <T1 extends ScriptConfigs>(newPayload: T1) => ScriptRegistry<T & T1>; | ||
newScript: (key: keyof T, args: string | Reader) => Script; | ||
newScript: (key: keyof T, args: string) => Script; | ||
isScriptOf: (key: keyof T, script: Script) => boolean; | ||
@@ -18,5 +17,5 @@ newCellDep: (key: keyof T) => CellDep; | ||
data?: HexString; | ||
out_point?: OutPoint; | ||
block_hash?: Hash; | ||
block_number?: HexNumber; | ||
outPoint?: OutPoint; | ||
blockHash?: Hash; | ||
blockNumber?: HexNumber; | ||
} | ||
@@ -23,0 +22,0 @@ export declare function createCell(payload: Payload, options?: { |
@@ -26,8 +26,8 @@ "use strict"; | ||
const config = map.get(key); | ||
if (config === undefined) throw new Error(`${key} doesn't exist in ScriptRegistry`); | ||
if (config === undefined) throw new Error(`${String(key)} doesn't exist in ScriptRegistry`); | ||
if (typeof args === "string") { | ||
return { | ||
code_hash: config.CODE_HASH, | ||
hash_type: config.HASH_TYPE, | ||
codeHash: config.CODE_HASH, | ||
hashType: config.HASH_TYPE, | ||
args: args | ||
@@ -37,5 +37,5 @@ }; | ||
return { | ||
code_hash: config.CODE_HASH, | ||
hash_type: config.HASH_TYPE, | ||
args: args.serializeJson() | ||
codeHash: config.CODE_HASH, | ||
hashType: config.HASH_TYPE, | ||
args: args | ||
}; | ||
@@ -47,4 +47,4 @@ } | ||
const config = map.get(key); | ||
if (config === undefined) throw new Error(`${key} doesn't exist in ScriptRegistry`); | ||
return script.code_hash === config.CODE_HASH && script.hash_type === config.HASH_TYPE; | ||
if (config === undefined) throw new Error(`${String(key)} doesn't exist in ScriptRegistry`); | ||
return script.codeHash === config.CODE_HASH && script.hashType === config.HASH_TYPE; | ||
}; | ||
@@ -54,9 +54,9 @@ | ||
const config = map.get(key); | ||
if (config === undefined) throw new Error(`${key} doesn't exist in ScriptRegistry`); | ||
if (config === undefined) throw new Error(`${String(key)} doesn't exist in ScriptRegistry`); | ||
return { | ||
out_point: { | ||
tx_hash: config.TX_HASH, | ||
outPoint: { | ||
txHash: config.TX_HASH, | ||
index: config.INDEX | ||
}, | ||
dep_type: config.DEP_TYPE | ||
depType: config.DEP_TYPE | ||
}; | ||
@@ -68,3 +68,3 @@ }; | ||
map.forEach((value, key) => { | ||
if (script.code_hash === (value === null || value === void 0 ? void 0 : value.CODE_HASH) && script.hash_type === value.HASH_TYPE) { | ||
if (script.codeHash === (value === null || value === void 0 ? void 0 : value.CODE_HASH) && script.hashType === value.HASH_TYPE) { | ||
name = key; | ||
@@ -99,21 +99,21 @@ } | ||
let cell = { | ||
cell_output: cellOutput, | ||
cellOutput: cellOutput, | ||
data: data | ||
}; | ||
if (payload.out_point) { | ||
if (payload.outPoint) { | ||
cell = Object.assign(cell, { | ||
out_point: payload.out_point | ||
outPoint: payload.outPoint | ||
}); | ||
} | ||
if (payload.block_hash) { | ||
if (payload.blockHash) { | ||
cell = Object.assign(cell, { | ||
block_hash: payload.block_hash | ||
blockHash: payload.blockHash | ||
}); | ||
} | ||
if (payload.block_number) { | ||
if (payload.blockNumber) { | ||
cell = Object.assign(cell, { | ||
block_number: payload.block_number | ||
blockNumber: payload.blockNumber | ||
}); | ||
@@ -147,9 +147,9 @@ } | ||
const cell = { | ||
cell_output: cellOutput, | ||
cellOutput: cellOutput, | ||
data: data | ||
}; | ||
const min = (0, _helpers.minimalCellCapacity)(cell); | ||
cell.cell_output.capacity = _bi.BI.from(min).toHexString(); | ||
cell.cellOutput.capacity = _bi.BI.from(min).toHexString(); | ||
return cell; | ||
} | ||
//# sourceMappingURL=index.js.map |
{ | ||
"name": "@ckb-lumos/experiment-tx-assembler", | ||
"version": "0.18.0", | ||
"version": "0.19.0-alpha.0", | ||
"description": "", | ||
@@ -24,6 +24,6 @@ "homepage": "https://github.com/nervosnetwork/lumos#readme", | ||
"dependencies": { | ||
"@ckb-lumos/base": "0.18.0", | ||
"@ckb-lumos/config-manager": "0.18.0", | ||
"@ckb-lumos/helpers": "0.18.0", | ||
"@ckb-lumos/toolkit": "0.18.0" | ||
"@ckb-lumos/base": "^0.19.0-alpha.0", | ||
"@ckb-lumos/config-manager": "^0.19.0-alpha.0", | ||
"@ckb-lumos/helpers": "^0.19.0-alpha.0", | ||
"@ckb-lumos/toolkit": "^0.19.0-alpha.0" | ||
}, | ||
@@ -56,3 +56,3 @@ "repository": { | ||
}, | ||
"gitHead": "732d60fdd2f4cbb7401df9b67c6295ea79c99180" | ||
"gitHead": "665f4e985dc1444a27e2e1db499d0ea64cf4d5b8" | ||
} |
@@ -29,3 +29,3 @@ # `@ckb-lumos/experiment-tx-assembler` | ||
To create input or output cells, you can use `createCell` or `createCellWithMinimalCapacity`, you can also indicate `type`, `data`, `block_hash`, `block_number` of the cell. | ||
To create input or output cells, you can use `createCell` or `createCellWithMinimalCapacity`, you can also indicate `type`, `data`, `blockHash`, `blockNumber` of the cell. | ||
@@ -36,9 +36,9 @@ - Create an input cell: | ||
const lock: Script = { | ||
code_hash: | ||
codeHash: | ||
"0x9bd7e06f3ecf4be0f2fcd2188b23f1b9fcc88e5d4b65a8637b17723bbda3cce8", | ||
args: "0x159890a7cacb44a95bef0743064433d763de229c", | ||
hash_type: "type", | ||
hashType: "type", | ||
}; | ||
const outPoint = { | ||
tx_hash: | ||
txHash: | ||
"0x942c23f72f0a2558a0029522b1dea2a7c64ba5196aed829ab6bfe4b6c3270958", | ||
@@ -50,3 +50,3 @@ index: "0x0", | ||
capacity: BI.from("10000000000"), | ||
out_point: outPoint, | ||
outPoint: outPoint, | ||
}); | ||
@@ -59,5 +59,5 @@ ``` | ||
const lock: Script = { | ||
code_hash: | ||
codeHash: | ||
"0x79f90bb5e892d80dd213439eeab551120eb417678824f282b4ffb5f21bad2e1e", | ||
hash_type: "type", | ||
hashType: "type", | ||
args: "0x01a08bcc398854db4eaffd9c28b881c65f91e3a28b00", | ||
@@ -71,5 +71,5 @@ }; | ||
const lock: Script = { | ||
code_hash: | ||
codeHash: | ||
"0x79f90bb5e892d80dd213439eeab551120eb417678824f282b4ffb5f21bad2e1e", | ||
hash_type: "type", | ||
hashType: "type", | ||
args: "0x01a08bcc398854db4eaffd9c28b881c65f91e3a28b00", | ||
@@ -76,0 +76,0 @@ }; |
@@ -13,7 +13,6 @@ import { | ||
import { ScriptConfig, ScriptConfigs } from "@ckb-lumos/config-manager"; | ||
import { Reader } from "@ckb-lumos/toolkit"; | ||
interface ScriptRegistry<T extends ScriptConfigs> { | ||
extend: <T1 extends ScriptConfigs>(newPayload: T1) => ScriptRegistry<T & T1>; | ||
newScript: (key: keyof T, args: string | Reader) => Script; | ||
newScript: (key: keyof T, args: string) => Script; | ||
isScriptOf: (key: keyof T, script: Script) => boolean; | ||
@@ -34,10 +33,10 @@ newCellDep: (key: keyof T) => CellDep; | ||
const newScript = (key: keyof T, args: string | Reader) => { | ||
const newScript = (key: keyof T, args: string) => { | ||
const config = map.get(key); | ||
if (config === undefined) | ||
throw new Error(`${key} doesn't exist in ScriptRegistry`); | ||
throw new Error(`${String(key)} doesn't exist in ScriptRegistry`); | ||
if (typeof args === "string") { | ||
return { | ||
code_hash: config.CODE_HASH, | ||
hash_type: config.HASH_TYPE, | ||
codeHash: config.CODE_HASH, | ||
hashType: config.HASH_TYPE, | ||
args: args, | ||
@@ -47,5 +46,5 @@ }; | ||
return { | ||
code_hash: config.CODE_HASH, | ||
hash_type: config.HASH_TYPE, | ||
args: args.serializeJson(), | ||
codeHash: config.CODE_HASH, | ||
hashType: config.HASH_TYPE, | ||
args: args, | ||
}; | ||
@@ -58,6 +57,6 @@ } | ||
if (config === undefined) | ||
throw new Error(`${key} doesn't exist in ScriptRegistry`); | ||
throw new Error(`${String(key)} doesn't exist in ScriptRegistry`); | ||
return ( | ||
script.code_hash === config.CODE_HASH && | ||
script.hash_type === config.HASH_TYPE | ||
script.codeHash === config.CODE_HASH && | ||
script.hashType === config.HASH_TYPE | ||
); | ||
@@ -69,9 +68,9 @@ }; | ||
if (config === undefined) | ||
throw new Error(`${key} doesn't exist in ScriptRegistry`); | ||
throw new Error(`${String(key)} doesn't exist in ScriptRegistry`); | ||
return { | ||
out_point: { | ||
tx_hash: config.TX_HASH, | ||
outPoint: { | ||
txHash: config.TX_HASH, | ||
index: config.INDEX, | ||
}, | ||
dep_type: config.DEP_TYPE, | ||
depType: config.DEP_TYPE, | ||
}; | ||
@@ -84,4 +83,4 @@ }; | ||
if ( | ||
script.code_hash === value?.CODE_HASH && | ||
script.hash_type === value.HASH_TYPE | ||
script.codeHash === value?.CODE_HASH && | ||
script.hashType === value.HASH_TYPE | ||
) { | ||
@@ -108,5 +107,5 @@ name = key; | ||
data?: HexString; | ||
out_point?: OutPoint; | ||
block_hash?: Hash; | ||
block_number?: HexNumber; | ||
outPoint?: OutPoint; | ||
blockHash?: Hash; | ||
blockNumber?: HexNumber; | ||
} | ||
@@ -127,13 +126,13 @@ | ||
let cell = { | ||
cell_output: cellOutput, | ||
cellOutput: cellOutput, | ||
data: data, | ||
}; | ||
if (payload.out_point) { | ||
cell = Object.assign(cell, { out_point: payload.out_point }); | ||
if (payload.outPoint) { | ||
cell = Object.assign(cell, { outPoint: payload.outPoint }); | ||
} | ||
if (payload.block_hash) { | ||
cell = Object.assign(cell, { block_hash: payload.block_hash }); | ||
if (payload.blockHash) { | ||
cell = Object.assign(cell, { blockHash: payload.blockHash }); | ||
} | ||
if (payload.block_number) { | ||
cell = Object.assign(cell, { block_number: payload.block_number }); | ||
if (payload.blockNumber) { | ||
cell = Object.assign(cell, { blockNumber: payload.blockNumber }); | ||
} | ||
@@ -163,8 +162,8 @@ if (options?.skipCheckCapacityIsEnough !== false) { | ||
const cell = { | ||
cell_output: cellOutput, | ||
cellOutput: cellOutput, | ||
data: data, | ||
}; | ||
const min = minimalCellCapacity(cell); | ||
cell.cell_output.capacity = BI.from(min).toHexString(); | ||
cell.cellOutput.capacity = BI.from(min).toHexString(); | ||
return cell; | ||
} |
Sorry, the diff of this file is not supported yet
22061
302
+ Added@ckb-lumos/base@0.19.0(transitive)
+ Added@ckb-lumos/bi@0.19.0(transitive)
+ Added@ckb-lumos/codec@0.19.0(transitive)
+ Added@ckb-lumos/config-manager@0.19.0(transitive)
+ Added@ckb-lumos/helpers@0.19.0(transitive)
+ Added@ckb-lumos/toolkit@0.19.0(transitive)
+ Added@types/blake2b@2.1.3(transitive)
- Removed@ckb-lumos/base@0.18.0(transitive)
- Removed@ckb-lumos/bi@0.18.0(transitive)
- Removed@ckb-lumos/config-manager@0.18.0(transitive)
- Removed@ckb-lumos/helpers@0.18.0(transitive)
- Removed@ckb-lumos/toolkit@0.18.0(transitive)