Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/sudt backend #512

Draft
wants to merge 50 commits into
base: develop
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
50 commits
Select commit Hold shift + click to select a range
b2ec018
fix: create new capsule project when not found (#489)
PainterPuppets Nov 15, 2023
4c9a449
feat(sudt-demo): add api doc
Daryl-L Sep 16, 2023
1a398ed
fix: emit decorator metadata in ts config
Daryl-L Oct 12, 2023
3a03a40
feat(sudt-manager): add response formatter
Daryl-L Oct 12, 2023
f0cfc40
feat(sudt): sudt create, update and detail
Daryl-L Oct 12, 2023
afe3ce0
feat(sudt): add account controller
Daryl-L Oct 13, 2023
127d258
feat(sudt): transaction entity for db
Daryl-L Oct 13, 2023
e12c586
style(sudt): extract bootstrap from the main
Daryl-L Oct 13, 2023
057ca6c
feat(sudt): mint api
Daryl-L Oct 24, 2023
076e4c5
feat(sudt): update doc
Daryl-L Oct 24, 2023
c8b5e68
feat(sudt): token apis
Daryl-L Oct 24, 2023
609032b
feat(sudt): example of env file
Daryl-L Oct 24, 2023
e2370fe
fix(sudt): amount should use BI
Daryl-L Oct 24, 2023
f09f908
feat(sudt): add explorer service
Daryl-L Oct 25, 2023
0c3b3bc
feat(sudt): explorer service
Daryl-L Oct 25, 2023
ef557cb
feat(sudt-manager): api
Daryl-L Nov 22, 2023
3997f2a
chore: fix sudt backend cors & support mysql8 (#567)
PainterPuppets Nov 30, 2023
3afa248
feat(sudt): support acp
Daryl-L Dec 5, 2023
2684afe
fix(sudt): wrong class used
Daryl-L Dec 6, 2023
6a3b429
fix(sudt): async
Daryl-L Dec 7, 2023
4d31450
feat(sudt): transfer history
Daryl-L Dec 13, 2023
5656b97
feat(sudt): history respond the address in `from` and `to`
Daryl-L Dec 14, 2023
a7f34f9
chore: change mint api path (#574)
PainterPuppets Dec 14, 2023
6d87827
feat(sudt): workspace
Daryl-L Dec 18, 2023
701c5da
fix(sudt): redis config
Daryl-L Dec 19, 2023
f4d93f9
test(sudt): only for test
Daryl-L Dec 19, 2023
b73e133
test(sudt): test for railway
Daryl-L Dec 19, 2023
d9c5ffe
feat(sudt): without _ in env
Daryl-L Dec 19, 2023
6c0d011
feat(sudt): fetch all transaction
Daryl-L Dec 19, 2023
1bdd14e
feat(sudt): transactions
Daryl-L Dec 19, 2023
c7568d5
feat(transaction): token history add token name
Daryl-L Dec 20, 2023
46e1e14
feat(sudt): history change to the front end
Daryl-L Dec 20, 2023
cc7f790
fix(sudt): need start block in config
Daryl-L Dec 24, 2023
91507e0
feat(sudt): assets will not be responded while user don't hold
Daryl-L Dec 25, 2023
453bf1a
feat(sudt): use acp to sudt model
Daryl-L Dec 26, 2023
7bf1b30
feat(sudt): set owner address in token api
Daryl-L Dec 28, 2023
3bcb3ed
fix(sudt): filter the token which users don't have
Daryl-L Dec 28, 2023
86dfdf2
Merge branch 'develop' into feature/sudt-backend
Keith-CY Dec 28, 2023
d2529c8
fix: history api amount bug & history tx duplicated bug
PainterPuppets Dec 31, 2023
bdf6aa4
fix(sudt): submit the token info to explorer in task
Daryl-L Jan 7, 2024
4e2bdbc
feat(sudt): filter the tx which token not included
Daryl-L Jan 7, 2024
5b3f6af
fix(sudt): explorer service put method
Daryl-L Jan 8, 2024
8af44e2
fix(sudt): explorer update token info api
Daryl-L Jan 8, 2024
def258b
test
Daryl-L Jan 8, 2024
ee22e3b
test
Daryl-L Jan 8, 2024
9d3c7fb
fix(sudt): typeorm timezone
Daryl-L Jan 8, 2024
d81b797
fix(sudt): explorer error
Daryl-L Jan 8, 2024
46b34aa
test
Daryl-L Jan 8, 2024
1f71795
fix(sudt): explorer error
Daryl-L Jan 8, 2024
a35f270
fix(sudt): error amount
Daryl-L Jan 10, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
138 changes: 137 additions & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 18 additions & 1 deletion packages/common/src/util.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { TransactionWithStatus } from '@ckb-lumos/base'
import type { RPC } from '@ckb-lumos/lumos'
import { config, type RPC, type helpers } from '@ckb-lumos/lumos'
import { scheduler } from 'node:timers/promises'
import path from 'node:path'
import fs from 'node:fs'
Expand Down Expand Up @@ -84,3 +84,20 @@ export async function getPackageJson(): Promise<PackageJson> {
const root = getPackageRoot()
return JSON.parse(fs.readFileSync(path.join(root, 'package.json'), 'utf-8'))
}

export const addBuiltInCellDeps = (txSkeleton: helpers.TransactionSkeletonType, dep: string) => {
const depConfig = config.getConfig().SCRIPTS[dep]
if (depConfig) {
txSkeleton = txSkeleton.update('cellDeps', (cellDeps) =>
cellDeps.push({
outPoint: {
txHash: depConfig.TX_HASH,
index: depConfig.INDEX,
},
depType: depConfig.DEP_TYPE,
}),
)
}

return txSkeleton
}
6 changes: 5 additions & 1 deletion packages/models/src/resource-binding/manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,12 @@ export class Manager extends Actor<object, MessagePayload<ResourceBindingManager
constructor(
private _listener: Listener<Header>,
private _dataSource: ChainSource,
startBlockNumber?: string,
) {
super()
if (startBlockNumber && BI.isBI(BI.from(startBlockNumber))) {
this.#tipBlockNumber = BI.from(startBlockNumber)
}
}

onListenBlock = (blockHeader: Header) => {
Expand Down Expand Up @@ -233,7 +237,7 @@ export class Manager extends Actor<object, MessagePayload<ResourceBindingManager
)
})
/**
* remove inputs and outputs if they are matched in the block
* remove inputs and outputs if they are matched in the block cross transactions
*/
;[...newInputs.keys()].forEach((outPoint) => {
if (newOutputs.has(outPoint)) {
Expand Down
3 changes: 2 additions & 1 deletion packages/models/src/resource-binding/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,13 @@ export function initiateResourceBindingManager(params: {
dataSource?: ChainSource
listener?: Listener<Header>
rpc?: string
startBlockNumber?: string
}) {
assert(params.rpc || params.dataSource, 'dataSource or rpc is required')

const dataSource = params.dataSource ?? new NervosChainSource(params.rpc!)
const listener = params.listener ?? new TipHeaderListener(dataSource)
Reflect.defineMetadata(ProviderKey.Actor, { ref: new ActorReference('resource', '/').json }, Manager)
const manager = new Manager(listener, dataSource)
const manager = new Manager(listener, dataSource, params.startBlockNumber)
return { manager, ...manager.listen() }
}
19 changes: 19 additions & 0 deletions packages/samples/sudt/.env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# app
HOST=127.0.0.1
PORT=3001

# ckb
CKB_RPC_URL=https://testnet.ckb.dev/rpc
NETWORK=testnet

# redis
REDIS_PORT=6379
REDIS_HOST=127.0.0.1

EXPLORER_HOST=https://explorer.nervos.org
EXPLORER_API_HOST=https://explorer.nervos.org/api
DB_HOST=localhost
DB_PORT=3306
DB_USERNAME=root
DB_PASSWORD=root
DB_DATABASE=sudt
Loading
Loading