Skip to content

Commit 3fc8df0

Browse files
committed
feat: use sbt-transfer-many native, foramt
1 parent e4ebffc commit 3fc8df0

7 files changed

Lines changed: 51 additions & 14 deletions

contracts/extensions/ext-sponsored-sbtc-transfer-many.clar

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,26 @@
4040
)
4141
)
4242

43+
;; Uses native transfer-many function with standard tuple format. More
44+
;; efficient cost-wise but supports fewer recipients.
45+
;;
46+
;; Max recipients:
47+
;; - 19 standard principals
48+
;; - 5 contract principals
49+
(define-private (sbtc-transfer-many-native (recipients (list
50+
200
51+
{
52+
amount: uint,
53+
sender: principal,
54+
to: principal,
55+
memo: (optional (buff 34)),
56+
}
57+
)))
58+
(contract-call? 'SM3VDXK3WZZSA84XXFKAFAF15NNZX32CTSG82JFQ4.sbtc-token
59+
transfer-many recipients
60+
)
61+
)
62+
4363
(define-private (sbtc-transfer
4464
(amount uint)
4565
(from principal)
@@ -50,6 +70,18 @@
5070
)
5171
)
5272

73+
(define-private (to-native (transfer {
74+
a: uint,
75+
r: principal,
76+
}))
77+
{
78+
amount: (get a transfer),
79+
sender: tx-sender,
80+
to: (get r transfer),
81+
memo: none,
82+
}
83+
)
84+
5385
(define-public (call (payload (buff 2048)))
5486
(let ((details (unwrap!
5587
(from-consensus-buff? {
@@ -66,7 +98,7 @@
6698
)
6799
err-invalid-payload
68100
)))
69-
(try! (sbtc-transfer-many-custom (get recipients details)))
101+
(try! (sbtc-transfer-many-native (map to-native (get recipients details))))
70102
(match tx-sponsor?
71103
spnsr (let ((fees (get fees details)))
72104
(and (> fees u0) (try! (sbtc-transfer fees tx-sender spnsr)))

contracts/extensions/ext-sponsored-send-many.clar

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,9 @@
99
ustx: uint,
1010
to: principal,
1111
})))
12-
(contract-call? 'SP3FBR2AGK5H9QBDH3EEN6DF8EK8JY7RX8QJ5SVTE.send-many send-many recipients)
12+
(contract-call? 'SP3FBR2AGK5H9QBDH3EEN6DF8EK8JY7RX8QJ5SVTE.send-many send-many
13+
recipients
14+
)
1315
)
1416

1517
(define-public (call (payload (buff 2048)))

contracts/smart-wallet-endpoint.clar

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,16 @@
2020
)
2121
)
2222

23-
(define-public (stx-send-many-sponsored (sm <wallet-trait>) (details {
24-
recipients: (list 11 {
25-
ustx: uint,
26-
to: principal,
27-
}),
28-
fees: uint,
29-
}))
23+
(define-public (stx-send-many-sponsored
24+
(sm <wallet-trait>)
25+
(details {
26+
recipients: (list 11 {
27+
ustx: uint,
28+
to: principal,
29+
}),
30+
fees: uint,
31+
})
32+
)
3033
(contract-call? sm extension-call .ext-sponsored-send-many
3134
(unwrap! (to-consensus-buff? details) err-invalid-payload)
3235
)
@@ -48,7 +51,8 @@
4851
(define-public (sbtc-transfer-many-sponsored
4952
(sm <wallet-trait>)
5053
(details {
51-
recipients: (list 11 {
54+
recipients: (list 11
55+
{
5256
;; Amount in sats.
5357
a: uint,
5458
;; Recipient address.

contracts/smart-wallet-group.clar

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,5 +142,5 @@
142142
)
143143

144144
;; init
145-
(map-set admins tx-sender true)
145+
(map-set admins tx-sender true)
146146
(map-set admins (as-contract tx-sender) true)

contracts/smart-wallet-standard.clar

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,5 +136,5 @@
136136
)
137137

138138
;; init
139-
(map-set admins tx-sender true)
139+
(map-set admins tx-sender true)
140140
(map-set admins (as-contract tx-sender) true)

contracts/smart-wallet-standard_test.clar

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,3 @@
2121
(ok true)
2222
)
2323
)
24-

contracts/smart-wallet-with-rules.clar

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,5 +171,5 @@
171171

172172
;; init
173173
(set-security-level u1)
174-
(map-set admins .inactive-observer true)
174+
(map-set admins .inactive-observer true)
175175
(map-set admins tx-sender true) ;; send 1000 ustx to the smart wallet(stx-transfer? u1000 tx-sender (as-contract tx-sender))

0 commit comments

Comments
 (0)