diff --git a/example/claim-update.ts b/example/claim-update.ts index 3d8be8f..952e9c0 100644 --- a/example/claim-update.ts +++ b/example/claim-update.ts @@ -2,7 +2,7 @@ import { addressToScript } from '@nervosnetwork/ckb-sdk-utils' import { Collector } from '../src/collector' import { Aggregator } from '../src/aggregator' import { generateClaimUpdateCotaTx } from '../src/service/cota' -import { CotaNft, Service } from '../src' +import { CotaNft, Service, FEE } from '../src' import CKB from '@nervosnetwork/ckb-sdk-core' const TEST_ADDRESS = 'ckt1qyq0scej4vn0uka238m63azcel7cmcme7f2sxj5ska' diff --git a/example/claim.ts b/example/claim.ts index 9ba0b32..f79507f 100644 --- a/example/claim.ts +++ b/example/claim.ts @@ -2,7 +2,7 @@ import { addressToScript } from '@nervosnetwork/ckb-sdk-utils' import { Collector } from '../src/collector' import { Aggregator } from '../src/aggregator' import { generateClaimCotaTx } from '../src/service/cota' -import { Claim, Service } from '../src' +import { Claim, Service, FEE } from '../src' import CKB from '@nervosnetwork/ckb-sdk-core' const TEST_ADDRESS = 'ckt1qyq0scej4vn0uka238m63azcel7cmcme7f2sxj5ska' diff --git a/example/define-flashsigner.ts b/example/define-flashsigner.ts index 62286e7..82506bd 100644 --- a/example/define-flashsigner.ts +++ b/example/define-flashsigner.ts @@ -2,7 +2,7 @@ import { addressToScript, serializeWitnessArgs } from '@nervosnetwork/ckb-sdk-ut import { Collector } from '../src/collector' import { Aggregator } from '../src/aggregator' import { generateDefineCotaTx } from '../src/service/cota' -import { Service } from '../src' +import { Service, FEE } from '../src' import { toSnakeCase } from '../src/utils' const TEST_ADDRESS = 'ckt1qpth5hjexr3wehtzqpm97dzzucgemjv7sl05wnez7y72hqvuszeyyqvz2vhrf3xz0jr8dcmxlv059kmpx4tt5vcluapd4' diff --git a/example/define.ts b/example/define.ts index f5896c4..24f613b 100644 --- a/example/define.ts +++ b/example/define.ts @@ -2,7 +2,7 @@ import { addressToScript } from '@nervosnetwork/ckb-sdk-utils' import { Collector } from '../src/collector' import { Aggregator } from '../src/aggregator' import { generateDefineCotaTx } from '../src/service/cota' -import { CotaInfo, Service } from '../src' +import { CotaInfo, Service, FEE } from '../src' const TEST_PRIVATE_KEY = '0xc5bd09c9b954559c70a77d68bde95369e2ce910556ddc20f739080cde3b62ef2' const TEST_ADDRESS = 'ckt1qyq0scej4vn0uka238m63azcel7cmcme7f2sxj5ska' diff --git a/example/issuer.ts b/example/issuer.ts index c7dc589..aa8eb44 100644 --- a/example/issuer.ts +++ b/example/issuer.ts @@ -2,7 +2,7 @@ import { addressToScript } from '@nervosnetwork/ckb-sdk-utils' import { Collector } from '../src/collector' import { Aggregator } from '../src/aggregator' import { generateIssuerInfoTx } from '../src/service/cota' -import { IssuerInfo, Service } from '../src' +import { IssuerInfo, Service, FEE } from '../src' import CKB from '@nervosnetwork/ckb-sdk-core' const TEST_PRIVATE_KEY = '0xc5bd09c9b954559c70a77d68bde95369e2ce910556ddc20f739080cde3b62ef2' diff --git a/example/mint.ts b/example/mint.ts index 6926ded..a15359d 100644 --- a/example/mint.ts +++ b/example/mint.ts @@ -2,7 +2,7 @@ import { addressToScript, serializeScript } from '@nervosnetwork/ckb-sdk-utils' import { Collector } from '../src/collector' import { Aggregator } from '../src/aggregator' import { generateMintCotaTx } from '../src/service/cota' -import { MintCotaInfo, Service } from '../src' +import { MintCotaInfo, Service, FEE } from '../src' import CKB from '@nervosnetwork/ckb-sdk-core' const TEST_PRIVATE_KEY = '0xc5bd09c9b954559c70a77d68bde95369e2ce910556ddc20f739080cde3b62ef2' diff --git a/example/registry.js b/example/registry.js index cec312d..13614a2 100644 --- a/example/registry.js +++ b/example/registry.js @@ -31,12 +31,15 @@ const run = async () => { // Mainnet // let rawTx = await generateRegisterCotaTx(service, [unregisteredCotaLock], provideCKBLock, FEE, true) - + const secp256k1Dep = await secp256k1CellDep(ckb) rawTx.cellDeps.push(secp256k1Dep) const registryLock = getAlwaysSuccessLock(false) + // Mainnet + // const registryLock = getAlwaysSuccessLock(true) + let keyMap = new Map() keyMap.set(scriptToHash(registryLock), '') keyMap.set(scriptToHash(provideCKBLock), TEST_PRIVATE_KEY) diff --git a/example/registry.ts b/example/registry.ts index eafa944..dbacdd2 100644 --- a/example/registry.ts +++ b/example/registry.ts @@ -18,7 +18,7 @@ const secp256k1CellDep = async (ckb: CKB): Promise => { const run = async () => { const service: Service = { collector: new Collector({ ckbNodeUrl: 'http://localhost:8114', ckbIndexerUrl: 'http://localhost:8116' }), - aggregator: new Aggregator({ registryUrl: 'http:/localhost:3050/', cotaUrl: 'http://localhost:3030' }), + aggregator: new Aggregator({ registryUrl: 'http://localhost:3050', cotaUrl: 'http://localhost:3030' }), } const ckb = service.collector.getCkb() const provideCKBLock = addressToScript(TEST_ADDRESS) @@ -33,6 +33,9 @@ const run = async () => { const registryLock = getAlwaysSuccessLock(false) + // Mainnet + // const registryLock = getAlwaysSuccessLock(true) + let keyMap = new Map() keyMap.set(scriptToHash(registryLock), '') keyMap.set(scriptToHash(provideCKBLock), TEST_PRIVATE_KEY) diff --git a/example/transfer-update.ts b/example/transfer-update.ts index 741baca..6d519bc 100644 --- a/example/transfer-update.ts +++ b/example/transfer-update.ts @@ -2,7 +2,7 @@ import { addressToScript, serializeScript } from '@nervosnetwork/ckb-sdk-utils' import { Collector } from '../src/collector' import { Aggregator } from '../src/aggregator' import { generateTransferUpdateCotaTx } from '../src/service/cota' -import { Service, TransferUpdate } from '../src' +import { Service, TransferUpdate, FEE } from '../src' import CKB from '@nervosnetwork/ckb-sdk-core' const TEST_ADDRESS = 'ckt1qyq0scej4vn0uka238m63azcel7cmcme7f2sxj5ska' diff --git a/example/transfer.ts b/example/transfer.ts index 542fc69..53898e2 100644 --- a/example/transfer.ts +++ b/example/transfer.ts @@ -2,7 +2,7 @@ import { addressToScript, serializeScript } from '@nervosnetwork/ckb-sdk-utils' import { Collector } from '../src/collector' import { Aggregator } from '../src/aggregator' import { generateTransferCotaTx } from '../src/service/cota' -import { TransferWithdrawal, Service, Hex } from '../src' +import { TransferWithdrawal, Service, FEE } from '../src' import CKB from '@nervosnetwork/ckb-sdk-core' const TEST_ADDRESS = 'ckt1qyq0scej4vn0uka238m63azcel7cmcme7f2sxj5ska' diff --git a/example/update.ts b/example/update.ts index f08670b..1347d60 100644 --- a/example/update.ts +++ b/example/update.ts @@ -2,7 +2,7 @@ import { addressToScript } from '@nervosnetwork/ckb-sdk-utils' import { Collector } from '../src/collector' import { Aggregator } from '../src/aggregator' import { generateUpdateCotaTx } from '../src/service/cota' -import { CotaNft, Service } from '../src' +import { CotaNft, Service, FEE } from '../src' import CKB from '@nervosnetwork/ckb-sdk-core' const TEST_PRIVATE_KEY = '0xc5bd09c9b954559c70a77d68bde95369e2ce910556ddc20f739080cde3b62ef2' diff --git a/example/withdraw.ts b/example/withdraw.ts index e9898eb..3984e27 100644 --- a/example/withdraw.ts +++ b/example/withdraw.ts @@ -2,7 +2,7 @@ import { addressToScript, serializeScript } from '@nervosnetwork/ckb-sdk-utils' import { Collector } from '../src/collector' import { Aggregator } from '../src/aggregator' import { generateWithdrawCotaTx } from '../src/service/cota' -import { Service, TransferWithdrawal } from '../src' +import { Service, TransferWithdrawal, FEE } from '../src' import CKB from '@nervosnetwork/ckb-sdk-core' const TEST_ADDRESS = 'ckt1qyq0scej4vn0uka238m63azcel7cmcme7f2sxj5ska' diff --git a/package.json b/package.json index 46265e5..647db07 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@nervina-labs/cota-sdk", - "version": "0.4.5", + "version": "0.4.6", "description": "The SDK of CoTA", "repository": "git@github.com:nervina-labs/cota-sdk-js.git", "author": "duanyytop ", diff --git a/src/aggregator/index.ts b/src/aggregator/index.ts index b7b1c1a..f86c3ec 100644 --- a/src/aggregator/index.ts +++ b/src/aggregator/index.ts @@ -66,7 +66,7 @@ export class Aggregator { headers: { 'Content-Type': 'application/json', }, - timeout: 60000, + timeout: 300000, data: body, }) ).data diff --git a/src/service/registry/index.ts b/src/service/registry/index.ts index c0cbd35..4398d7c 100644 --- a/src/service/registry/index.ts +++ b/src/service/registry/index.ts @@ -70,7 +70,8 @@ export const generateRegisterCotaTx = async ( let outputs = await generateCotaOutputs(capacity, cotaLocks, lock) outputs = [registryCell.output].concat(outputs) - outputs.at(-1).capacity = `0x${(BigInt(outputs.at(-1).capacity) - FEE).toString(16)}` + const length = outputs.length + outputs[length-1].capacity = `0x${(BigInt(outputs[length-1].capacity) - FEE).toString(16)}` const lockHashes = cotaLocks.map(lock => scriptToHash(lock)) const { smtRootHash, registrySmtEntry } = await service.aggregator.generateRegisterCotaSmt(lockHashes) diff --git a/yarn.lock b/yarn.lock index 8482869..c50e020 100644 --- a/yarn.lock +++ b/yarn.lock @@ -890,9 +890,9 @@ follow-redirects@^1.14.0: integrity sha512-+hbxoLbFMbRKDwohX8GkTataGqO6Jb7jGwpAlwgy2bIz25XtRm7KEzJM76R1WiNT5SwZkX4Y75SwBolkpmE7iQ== follow-redirects@^1.14.9: - version "1.14.9" - resolved "https://registry.yarnpkg.com/follow-redirects/-/follow-redirects-1.14.9.tgz#dd4ea157de7bfaf9ea9b3fbd85aa16951f78d8d7" - integrity sha512-MQDfihBQYMcyy5dhRDJUHcw7lb2Pv/TuE6xP1vyraLukNDHKbDxDNaOE3NbCAdKQApno+GPRyo1YAp89yCjK4w== + version "1.15.0" + resolved "https://registry.yarnpkg.com/follow-redirects/-/follow-redirects-1.15.0.tgz#06441868281c86d0dda4ad8bdaead2d02dca89d4" + integrity sha512-aExlJShTV4qOUOL7yF1U5tvLCB0xQuudbf6toyYA0E/acBNw71mvjFTnLaRp50aQaYocMR0a/RMMBIHeZnGyjQ== form-data@^4.0.0: version "4.0.0"