-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #167 from nervina-labs/develop
Release v0.6.3
- Loading branch information
Showing
13 changed files
with
567 additions
and
365 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
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 |
---|---|---|
|
@@ -27,10 +27,10 @@ | |
"@jridgewell/resolve-uri" "^3.0.3" | ||
"@jridgewell/sourcemap-codec" "^1.4.10" | ||
|
||
"@nervina-labs/[email protected].1": | ||
version "0.6.1" | ||
resolved "https://registry.yarnpkg.com/@nervina-labs/cota-sdk/-/cota-sdk-0.6.1.tgz#acd00d9529d36c1a9d4ff310864194f824dd160f" | ||
integrity sha512-rKI7R4tIiO19n0sQS6z2SjiIP5cw1RUDQL1l66ETI1db0zOd8vq7qs/LXe7ycT7un4ayS2oNJllf3SrWCiNcGw== | ||
"@nervina-labs/[email protected].2": | ||
version "0.6.2" | ||
resolved "https://registry.yarnpkg.com/@nervina-labs/cota-sdk/-/cota-sdk-0.6.2.tgz#1e111f51545c9d5037966c10df40c784b2aa88e3" | ||
integrity sha512-87+3TKr8rvDlpAnIMnwHNkyHskgfyuABJJBv/wvwoaXYKGRSodkVSDXkakNzIx2Gg1x0iLYwmX86Xl3d6+UwcQ== | ||
dependencies: | ||
"@nervosnetwork/ckb-sdk-core" "^0.103.0" | ||
"@nervosnetwork/ckb-sdk-utils" "^0.103.0" | ||
|
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 |
---|---|---|
|
@@ -2,10 +2,10 @@ | |
# yarn lockfile v1 | ||
|
||
|
||
"@nervina-labs/[email protected].1": | ||
version "0.6.1" | ||
resolved "https://registry.yarnpkg.com/@nervina-labs/cota-sdk/-/cota-sdk-0.6.1.tgz#acd00d9529d36c1a9d4ff310864194f824dd160f" | ||
integrity sha512-rKI7R4tIiO19n0sQS6z2SjiIP5cw1RUDQL1l66ETI1db0zOd8vq7qs/LXe7ycT7un4ayS2oNJllf3SrWCiNcGw== | ||
"@nervina-labs/[email protected].2": | ||
version "0.6.2" | ||
resolved "https://registry.yarnpkg.com/@nervina-labs/cota-sdk/-/cota-sdk-0.6.2.tgz#1e111f51545c9d5037966c10df40c784b2aa88e3" | ||
integrity sha512-87+3TKr8rvDlpAnIMnwHNkyHskgfyuABJJBv/wvwoaXYKGRSodkVSDXkakNzIx2Gg1x0iLYwmX86Xl3d6+UwcQ== | ||
dependencies: | ||
"@nervosnetwork/ckb-sdk-core" "^0.103.0" | ||
"@nervosnetwork/ckb-sdk-utils" "^0.103.0" | ||
|
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,49 @@ | ||
import { rawTransactionToHash, scriptToHash, serializeWitnessArgs } from '@nervosnetwork/ckb-sdk-utils' | ||
import { Collector } from '../src/collector' | ||
import { Aggregator } from '../src/aggregator' | ||
import { getAlwaysSuccessLock } from '../src/constants' | ||
import { generateUpdateCcidsTx } from '../src/service/registry' | ||
import { Service } from '../src' | ||
import signWitnesses from '@nervosnetwork/ckb-sdk-core/lib/signWitnesses' | ||
|
||
|
||
const run = async () => { | ||
// True for mainnet and false for testnet | ||
const isMainnet = false | ||
|
||
const service: Service = { | ||
collector: new Collector({ ckbNodeUrl: 'https://testnet.ckb.dev/rpc', ckbIndexerUrl: 'https://testnet.ckb.dev/indexer' }), | ||
aggregator: new Aggregator({ registryUrl: 'http://localhost:3050', cotaUrl: 'http://localhost:3030' }), | ||
} | ||
const ckb = service.collector.getCkb() | ||
|
||
let rawTx = await generateUpdateCcidsTx(service, isMainnet) | ||
|
||
const registryLock = getAlwaysSuccessLock(isMainnet) | ||
|
||
let keyMap = new Map<string, string>() | ||
keyMap.set(scriptToHash(registryLock), '') | ||
|
||
const cells = rawTx.inputs.map((input, _) => ({ | ||
outPoint: input.previousOutput, | ||
lock: registryLock, | ||
})) | ||
|
||
const transactionHash = rawTransactionToHash(rawTx) | ||
|
||
const signedWitnesses = signWitnesses(keyMap)({ | ||
transactionHash, | ||
witnesses: rawTx.witnesses, | ||
inputCells: cells, | ||
skipMissingKeys: true, | ||
}) | ||
const signedTx = { | ||
...rawTx, | ||
witnesses: signedWitnesses.map(witness => (typeof witness === 'string' ? witness : serializeWitnessArgs(witness))), | ||
} | ||
console.log(JSON.stringify(signedTx)) | ||
let txHash = await ckb.rpc.sendTransaction(signedTx, 'passthrough') | ||
console.log(`Update registered ccids tx has been sent with tx hash ${txHash}`) | ||
} | ||
|
||
run() |
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,6 +1,6 @@ | ||
{ | ||
"name": "@nervina-labs/cota-sdk", | ||
"version": "0.6.2", | ||
"version": "0.6.3", | ||
"description": "The SDK of CoTA", | ||
"repository": "[email protected]:nervina-labs/cota-sdk-js.git", | ||
"author": "duanyytop <[email protected]>", | ||
|
@@ -34,9 +34,9 @@ | |
"devDependencies": { | ||
"@types/crypto-js": "4.1.1", | ||
"@types/node": "17.0.31", | ||
"@typescript-eslint/parser": "5.30.7", | ||
"@typescript-eslint/parser": "5.33.0", | ||
"babel-eslint": "10.1.0", | ||
"eslint": "8.14.0", | ||
"eslint": "8.21.0", | ||
"eslint-config-prettier": "8.5.0", | ||
"eslint-plugin-import": "2.26.0", | ||
"eslint-plugin-prettier": "4.2.1", | ||
|
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
Oops, something went wrong.