Skip to content

Commit 89bfa00

Browse files
committed
Bandaid smart-wallet-standard contract to run Rendezvous tests
1 parent fb77047 commit 89bfa00

2 files changed

Lines changed: 147 additions & 137 deletions

File tree

contracts/smart-wallet-standard.clar

Lines changed: 145 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22
;; version: 1
33
;; summary: Extendible single-owner smart wallet with standard SIP-010 and SIP-009 support
44

5+
;; Allows Rendezvous to pick the contract as a valid csw-trait implementation.
6+
(impl-trait .csw-registry.csw-trait)
7+
58
(use-trait extension-trait 'ST3FFRX7C911PZP5RHE148YDVDD9JWVS6FZRA60VS.extension-trait.extension-trait)
69

710
(use-trait sip-010-trait 'SP3FBR2AGK5H9QBDH3EEN6DF8EK8JY7RX8QJ5SVTE.sip-010-trait-ft-standard.sip-010-trait)
@@ -317,3 +320,145 @@
317320
;; init
318321
(map-set admins tx-sender true)
319322
(map-set admins current-contract true)
323+
324+
;; Rendezvous helpers (not part of the contract)
325+
326+
;; ============================================
327+
;; SHARED TESTING HELPERS
328+
;; ============================================
329+
330+
(define-constant smart-wallet-contract current-contract)
331+
(define-data-var delegate-extension-funds uint u0)
332+
333+
;; Helper to fund the wallet with STX.
334+
(define-private (fund-wallet-stx (amount uint))
335+
(stx-transfer? amount tx-sender smart-wallet-contract)
336+
)
337+
338+
;; Helper to fund the wallet with sBTC.
339+
(define-private (fund-wallet-sbtc (amount uint))
340+
(contract-call? 'SM3VDXK3WZZSA84XXFKAFAF15NNZX32CTSG82JFQ4.sbtc-token transfer
341+
amount tx-sender smart-wallet-contract none
342+
)
343+
)
344+
345+
;; ext-sponsored-stx-transfer extension call wrapper.
346+
(define-private (ext-sponsored-stx-transfer
347+
(amount uint)
348+
(recipient principal)
349+
(fees uint)
350+
)
351+
(extension-call
352+
.ext-sponsored-transfer
353+
(unwrap-panic
354+
(to-consensus-buff?
355+
{
356+
amount: amount,
357+
to: recipient,
358+
fees: fees,
359+
}
360+
)
361+
)
362+
none
363+
)
364+
)
365+
366+
;; ext-sponsored-sbtc-transfer extension call wrapper.
367+
(define-private (ext-sponsored-sbtc-transfer
368+
(amount uint)
369+
(recipient principal)
370+
(fees uint)
371+
)
372+
(extension-call
373+
.ext-sponsored-sbtc-transfer
374+
(unwrap-panic
375+
(to-consensus-buff?
376+
{
377+
amount: amount,
378+
to: recipient,
379+
fees: fees,
380+
}
381+
)
382+
)
383+
none
384+
)
385+
)
386+
387+
;; ext-delegate-stx-pox-4 extension delegate call wrapper.
388+
(define-private (delegate-stx-pox-4
389+
(amount uint)
390+
(to principal)
391+
(until-burn-ht (optional uint))
392+
(pox-addr
393+
(optional
394+
{
395+
version: (buff 1),
396+
hashbytes: (buff 32),
397+
}
398+
)
399+
)
400+
)
401+
(extension-call
402+
.ext-delegate-stx-pox-4
403+
(unwrap-panic
404+
(to-consensus-buff? {
405+
action: "delegate",
406+
amount-ustx: amount,
407+
delegate-to: to,
408+
until-burn-ht: until-burn-ht,
409+
pox-addr: pox-addr,
410+
})
411+
)
412+
none
413+
)
414+
)
415+
416+
;; ext-delegate-stx-pox-4 extension revoke call wrapper.
417+
(define-private (revoke-delegate-stx-pox-4)
418+
(extension-call
419+
.ext-delegate-stx-pox-4
420+
(unwrap-panic (to-consensus-buff? {
421+
action: "revoke",
422+
amount-ustx: u0,
423+
delegate-to: tx-sender,
424+
until-burn-ht: none,
425+
pox-addr: none,
426+
}))
427+
none
428+
)
429+
)
430+
431+
;; ext-delegate-stx-pox-4 extension refund call wrapper.
432+
(define-private (refund-delegate-extension)
433+
(extension-call
434+
.ext-delegate-stx-pox-4
435+
(unwrap-panic (to-consensus-buff? {
436+
action: "",
437+
amount-ustx: u0,
438+
delegate-to: tx-sender,
439+
until-burn-ht: none,
440+
pox-addr: none,
441+
}))
442+
none
443+
)
444+
)
445+
446+
(define-read-only (sbtc-get-balance (who principal))
447+
(unwrap-panic
448+
(contract-call? 'SM3VDXK3WZZSA84XXFKAFAF15NNZX32CTSG82JFQ4.sbtc-token
449+
get-balance who
450+
)
451+
)
452+
)
453+
454+
(define-read-only (is-admin (who principal))
455+
(default-to false (map-get? admins who))
456+
)
457+
458+
(define-read-only (already-delegated (who principal))
459+
(is-some
460+
(contract-call? 'SP000000000000000000002Q6VF78.pox-4
461+
get-check-delegation who
462+
)
463+
)
464+
)

contracts/smart-wallet-standard.tests.clar

Lines changed: 2 additions & 137 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@
5151
;; Discard invalid inputs.
5252
(ok false)
5353
(begin
54-
(try! (stx-transfer amount recipient memo))
54+
(try! (stx-transfer amount recipient memo none))
5555
(asserts!
5656
(is-eq
5757
(stx-get-balance smart-wallet-contract)
@@ -137,7 +137,7 @@
137137
fees: fees,
138138
})))
139139
)
140-
(try! (extension-call .ext-sponsored-sbtc-transfer payload))
140+
(try! (extension-call .ext-sponsored-sbtc-transfer payload none))
141141
(asserts!
142142
(is-eq
143143
(sbtc-get-balance smart-wallet-contract)
@@ -586,138 +586,3 @@
586586
(ok true)
587587
)
588588
)
589-
590-
;; ============================================
591-
;; SHARED HELPERS
592-
;; ============================================
593-
594-
(define-constant smart-wallet-contract (as-contract tx-sender))
595-
(define-data-var delegate-extension-funds uint u0)
596-
597-
;; Helper to fund the wallet with STX.
598-
(define-private (fund-wallet-stx (amount uint))
599-
(stx-transfer? amount tx-sender smart-wallet-contract)
600-
)
601-
602-
;; Helper to fund the wallet with sBTC.
603-
(define-private (fund-wallet-sbtc (amount uint))
604-
(contract-call? 'SM3VDXK3WZZSA84XXFKAFAF15NNZX32CTSG82JFQ4.sbtc-token transfer
605-
amount tx-sender smart-wallet-contract none
606-
)
607-
)
608-
609-
;; ext-sponsored-stx-transfer extension call wrapper.
610-
(define-private (ext-sponsored-stx-transfer
611-
(amount uint)
612-
(recipient principal)
613-
(fees uint)
614-
)
615-
(extension-call
616-
.ext-sponsored-transfer
617-
(unwrap-panic
618-
(to-consensus-buff?
619-
{
620-
amount: amount,
621-
to: recipient,
622-
fees: fees,
623-
}
624-
)
625-
)
626-
)
627-
)
628-
629-
;; ext-sponsored-sbtc-transfer extension call wrapper.
630-
(define-private (ext-sponsored-sbtc-transfer
631-
(amount uint)
632-
(recipient principal)
633-
(fees uint)
634-
)
635-
(extension-call
636-
.ext-sponsored-sbtc-transfer
637-
(unwrap-panic
638-
(to-consensus-buff?
639-
{
640-
amount: amount,
641-
to: recipient,
642-
fees: fees,
643-
}
644-
)
645-
)
646-
)
647-
)
648-
649-
;; ext-delegate-stx-pox-4 extension delegate call wrapper.
650-
(define-private (delegate-stx-pox-4
651-
(amount uint)
652-
(to principal)
653-
(until-burn-ht (optional uint))
654-
(pox-addr
655-
(optional
656-
{
657-
version: (buff 1),
658-
hashbytes: (buff 32),
659-
}
660-
)
661-
)
662-
)
663-
(extension-call
664-
.ext-delegate-stx-pox-4
665-
(unwrap-panic
666-
(to-consensus-buff? {
667-
action: "delegate",
668-
amount-ustx: amount,
669-
delegate-to: to,
670-
until-burn-ht: until-burn-ht,
671-
pox-addr: pox-addr,
672-
})
673-
)
674-
)
675-
)
676-
677-
;; ext-delegate-stx-pox-4 extension revoke call wrapper.
678-
(define-private (revoke-delegate-stx-pox-4)
679-
(extension-call
680-
.ext-delegate-stx-pox-4
681-
(unwrap-panic (to-consensus-buff? {
682-
action: "revoke",
683-
amount-ustx: u0,
684-
delegate-to: tx-sender,
685-
until-burn-ht: none,
686-
pox-addr: none,
687-
}))
688-
)
689-
)
690-
691-
;; ext-delegate-stx-pox-4 extension refund call wrapper.
692-
(define-private (refund-delegate-extension)
693-
(extension-call
694-
.ext-delegate-stx-pox-4
695-
(unwrap-panic (to-consensus-buff? {
696-
action: "",
697-
amount-ustx: u0,
698-
delegate-to: tx-sender,
699-
until-burn-ht: none,
700-
pox-addr: none,
701-
}))
702-
)
703-
)
704-
705-
(define-read-only (sbtc-get-balance (who principal))
706-
(unwrap-panic
707-
(contract-call? 'SM3VDXK3WZZSA84XXFKAFAF15NNZX32CTSG82JFQ4.sbtc-token
708-
get-balance who
709-
)
710-
)
711-
)
712-
713-
(define-read-only (is-admin (who principal))
714-
(default-to false (map-get? admins who))
715-
)
716-
717-
(define-read-only (already-delegated (who principal))
718-
(is-some
719-
(contract-call? 'SP000000000000000000002Q6VF78.pox-4
720-
get-check-delegation who
721-
)
722-
)
723-
)

0 commit comments

Comments
 (0)