mirror of
https://github.com/zhigang1992/liquid-stacking.git
synced 2026-01-12 17:23:23 +08:00
fix: improve nft post conditions
This commit is contained in:
@@ -222,9 +222,19 @@
|
||||
(try! (is-dao-or-extension))
|
||||
(try! (contract-call? .token-vlqstx mint amount tx-sender))
|
||||
(try! (contract-call? .token-vlqstx transfer vlqstx-amount tx-sender .lqstx-mint-registry none))
|
||||
(try! (contract-call? .li-stx-burn-nft mint request-id amount sender))
|
||||
(print { type: "burn-request", id: request-id, details: request-details })
|
||||
(ok { request-id: request-id, status: PENDING })))
|
||||
(if (>= (stx-get-balance .lqstx-vault) amount)
|
||||
(begin
|
||||
(try! (contract-call? .lqstx-mint-registry transfer vlqstx-amount (as-contract tx-sender) .token-vlqstx))
|
||||
(try! (contract-call? .token-vlqstx burn vlqstx-amount (as-contract tx-sender)))
|
||||
(try! (contract-call? .token-lqstx dao-burn amount (as-contract tx-sender)))
|
||||
(try! (contract-call? .lqstx-vault proxy-call .stx-transfer-proxy (unwrap-panic (to-consensus-buff? { ustx: vlqstx-amount, recipient: sender }))))
|
||||
(try! (contract-call? .lqstx-mint-registry set-burn-request request-id (merge request-details { status: FINALIZED })))
|
||||
(ok {request-id: request-id, status: FINALIZED })
|
||||
)
|
||||
(begin
|
||||
(try! (contract-call? .li-stx-burn-nft mint request-id amount sender))
|
||||
(ok { request-id: request-id, status: PENDING })))))
|
||||
|
||||
(define-public (finalize-burn (request-id uint))
|
||||
(let (
|
||||
|
||||
@@ -26,9 +26,6 @@
|
||||
|
||||
(define-public (request-burn (amount uint))
|
||||
(let (
|
||||
(sender tx-sender)
|
||||
(send-token (try! (contract-call? .token-lqstx transfer amount sender (as-contract tx-sender) none)))
|
||||
(request-data (as-contract (try! (contract-call? .lqstx-mint-endpoint-v1-02 request-burn sender amount)))))
|
||||
(match (finalize-burn (get request-id request-data))
|
||||
ok-value (ok { request-id: (get request-id request-data), status: FINALIZED })
|
||||
err-value (ok request-data))))
|
||||
(sender tx-sender))
|
||||
(try! (contract-call? .token-lqstx transfer amount sender (as-contract tx-sender) none))
|
||||
(as-contract (contract-call? .lqstx-mint-endpoint-v1-02 request-burn sender amount))))
|
||||
|
||||
@@ -84,7 +84,7 @@ describe('LiSTX NFT', () => {
|
||||
expect(response.result).toBeOk(
|
||||
Cl.tuple({ 'request-id': Cl.uint(2), status: Cl.bufferFromHex('01') })
|
||||
);
|
||||
// nft was already burnt
|
||||
// nfts were never minted
|
||||
expect(simnet.callReadOnlyFn(contracts.burnNft, 'get-owner', [Cl.uint(1)], user).result).toBeOk(
|
||||
Cl.none()
|
||||
);
|
||||
@@ -92,7 +92,7 @@ describe('LiSTX NFT', () => {
|
||||
Cl.none()
|
||||
);
|
||||
expect(simnet.callReadOnlyFn(contracts.burnNft, 'get-last-token-id', [], user).result).toBeOk(
|
||||
Cl.uint(2)
|
||||
Cl.uint(0)
|
||||
);
|
||||
|
||||
// check that bot received stx
|
||||
|
||||
@@ -174,8 +174,10 @@ describe(contracts.endpoint, () => {
|
||||
expect(response.result).toBeOk(
|
||||
Cl.tuple({ 'request-id': Cl.uint(1), status: Cl.buffer(new Uint8Array([1])) })
|
||||
);
|
||||
expect(response.events[7].event).toBe('nft_mint_event');
|
||||
expect(response.events[17].event).toBe('nft_burn_event');
|
||||
// no nft minted
|
||||
expect(simnet.callReadOnlyFn(contracts.burnNft, 'get-last-token-id', [], user).result).toBeOk(
|
||||
Cl.uint(0)
|
||||
);
|
||||
});
|
||||
|
||||
it('can interact with strategies', () => {
|
||||
|
||||
Reference in New Issue
Block a user