-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: update prod deployments for l1 contracts
- Loading branch information
Showing
11 changed files
with
891 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,134 @@ | ||
;; @contract Community Handles | ||
;; @version 2 | ||
|
||
(define-constant err-not-authorized (err u403)) | ||
(define-constant internal-price-high u999999999999999999999999999999) | ||
(define-constant name-salt 0x00) | ||
(define-fungible-token danger-zone-token) | ||
|
||
(define-map namespace-controller (buff 20) principal) | ||
|
||
;; variables for iteration functions | ||
(define-data-var ctx-bulk-registration-namespace (buff 20) 0x00) | ||
|
||
;; @desc preorder the namespace on-chain | ||
;; @param hashed-salted-namespace; ripdem160 hash of namespace concat with salt | ||
;; @param stx-to-burn; namespace price in ustx | ||
(define-public (namespace-preorder (hashed-salted-namespace (buff 20)) (stx-to-burn uint)) | ||
(contract-call? 'SP000000000000000000002Q6VF78.bns | ||
namespace-preorder hashed-salted-namespace stx-to-burn)) | ||
|
||
;; @desc reveal the namespace | ||
;; @param namespace; namespace to register | ||
;; @param salt; salt used during preorder | ||
;; @param lifetime; number of blocks until a name expires | ||
;; @param controller; optional principal set as the first namespace controller | ||
;; defaults to contract-caller | ||
(define-public (namespace-reveal (namespace (buff 20)) (salt (buff 20)) (lifetime uint) (controller (optional principal))) | ||
(begin | ||
(map-set namespace-controller namespace (default-to contract-caller controller)) | ||
(try! (contract-call? 'SP000000000000000000002Q6VF78.bns | ||
namespace-reveal | ||
namespace | ||
salt | ||
internal-price-high u1 u1 u1 u1 u1 u1 u1 u1 u1 u1 u1 u1 u1 u1 u1 u1 u1 u1 u1 | ||
lifetime | ||
(as-contract tx-sender))) | ||
(try! (as-contract (contract-call? 'SP000000000000000000002Q6VF78.bns | ||
namespace-ready namespace))) | ||
(ok true))) | ||
|
||
;; @desc register name for 1 ustx by namespace controller only | ||
;; @param namespace; controlled namespace | ||
;; @param name; name in the controlled namespace | ||
;; @param zonefile-hash; hash of the attachment/zonefile for the name | ||
;; @param owner; principal owning the name after registration | ||
(define-public (name-register (namespace (buff 20)) | ||
(name (buff 48)) | ||
(owner principal) | ||
(zonefile-hash (buff 20))) | ||
(let ((hash (hash160 (concat (concat (concat name 0x2e) namespace) name-salt)))) | ||
(try! (is-contract-caller-namespace-controller namespace)) | ||
(try! (to-uint-response (contract-call? 'SP000000000000000000002Q6VF78.bns name-preorder hash u1))) | ||
(try! (as-contract (to-bool-response (contract-call? 'SP000000000000000000002Q6VF78.bns namespace-update-function-price namespace u0 u0 u0 u0 u0 u0 u0 u0 u0 u0 u0 u0 u0 u0 u0 u0 u0 u0 u1 u1)))) | ||
(try! (to-bool-response (contract-call? 'SP000000000000000000002Q6VF78.bns name-register namespace name name-salt zonefile-hash))) | ||
(try! (to-bool-response (contract-call? 'SP000000000000000000002Q6VF78.bns name-transfer namespace name owner (some zonefile-hash)))) | ||
(try! (as-contract (to-bool-response (contract-call? 'SP000000000000000000002Q6VF78.bns namespace-update-function-price namespace internal-price-high u1 u1 u1 u1 u1 u1 u1 u1 u1 u1 u1 u1 u1 u1 u1 u1 u1 u1 u1)))) | ||
(ok true))) | ||
|
||
;; @desc renew a name for 1 ustx by namespace controller only | ||
;; @param namespace; controlled namespace | ||
;; @param name; name in the controlled namespace | ||
;; @param new-owner; optional new owner of name after renewal | ||
;; @param zonefile-hash; optional new zonefile hash after renewal | ||
(define-public (name-renewal (namespace (buff 20)) | ||
(name (buff 48)) | ||
(new-owner (optional principal)) | ||
(zonefile-hash (optional (buff 20)))) | ||
(let ((original-owner tx-sender)) | ||
(try! (is-contract-caller-namespace-controller namespace)) | ||
(try! (as-contract (to-bool-response (contract-call? 'SP000000000000000000002Q6VF78.bns namespace-update-function-price namespace u0 u0 u0 u0 u0 u0 u0 u0 u0 u0 u0 u0 u0 u0 u0 u0 u0 u0 u1 u1)))) | ||
(try! (to-bool-response (contract-call? 'SP000000000000000000002Q6VF78.bns name-renewal namespace name u1 new-owner zonefile-hash))) | ||
(try! (as-contract (to-bool-response (contract-call? 'SP000000000000000000002Q6VF78.bns namespace-update-function-price namespace internal-price-high u1 u1 u1 u1 u1 u1 u1 u1 u1 u1 u1 u1 u1 u1 u1 u1 u1 u1 u1)))) | ||
(ok true))) | ||
|
||
|
||
;; iterator for bulk-name-register | ||
(define-private (bulk-name-register-iter (entry {name: (buff 48), owner: principal, zonefile-hash: (buff 20)}) (prev (response bool uint))) | ||
(let ((namespace (var-get ctx-bulk-registration-namespace)) | ||
(name (get name entry)) | ||
(hash (hash160 (concat (concat (concat name 0x2e) namespace) name-salt)))) | ||
(try! prev) | ||
(try! (to-uint-response (contract-call? 'SP000000000000000000002Q6VF78.bns name-preorder hash u1))) | ||
(try! (to-bool-response (contract-call? 'SP000000000000000000002Q6VF78.bns name-register namespace name name-salt (get zonefile-hash entry)))) | ||
(try! (to-bool-response (contract-call? 'SP000000000000000000002Q6VF78.bns name-transfer namespace name (get owner entry) (some (get zonefile-hash entry))))) | ||
(ok true))) | ||
|
||
;; @desc register multiple namens for 1 ustx by namespace controller only | ||
;; @param namespace; controlled namespace | ||
;; @param names; list of names with owner and hash of the attachment/zonefile for the name | ||
(define-public (bulk-name-register (namespace (buff 20)) (names (list 1000 {name: (buff 48), owner: principal, zonefile-hash: (buff 20)}))) | ||
(begin | ||
(try! (is-contract-caller-namespace-controller namespace)) | ||
(var-set ctx-bulk-registration-namespace namespace) | ||
(try! (as-contract (to-bool-response (contract-call? 'SP000000000000000000002Q6VF78.bns namespace-update-function-price namespace u0 u0 u0 u0 u0 u0 u0 u0 u0 u0 u0 u0 u0 u0 u0 u0 u0 u0 u1 u1)))) | ||
(try! (fold bulk-name-register-iter names (ok true))) | ||
(var-set ctx-bulk-registration-namespace 0x00) | ||
(try! (as-contract (to-bool-response (contract-call? 'SP000000000000000000002Q6VF78.bns namespace-update-function-price namespace internal-price-high u1 u1 u1 u1 u1 u1 u1 u1 u1 u1 u1 u1 u1 u1 u1 u1 u1 u1 u1)))) | ||
(ok true))) | ||
|
||
;; convert response to standard uint response with uint error | ||
;; (response uint int) (response uint uint) | ||
(define-private (to-uint-response (value (response uint int))) | ||
(match value | ||
success (ok success) | ||
error (err (to-uint error)))) | ||
|
||
;; convert response to standard bool response with uint error | ||
;; (response bool int) (response bool uint) | ||
(define-private (to-bool-response (value (response bool int))) | ||
(match value | ||
success (ok success) | ||
error (err (to-uint error)))) | ||
|
||
(define-private (is-contract-caller-namespace-controller (namespace (buff 20))) | ||
(ok (asserts! (is-eq (map-get? namespace-controller namespace) (some contract-caller)) err-not-authorized))) | ||
|
||
(define-read-only (get-namespace-controller (namespace (buff 20))) | ||
(map-get? namespace-controller namespace)) | ||
|
||
;; @desc set new namespace controller, by current namespace owner only | ||
;; | ||
;; It is the responsibility of the namespace controller to | ||
;; ensure that the new controller can manage the namespace. | ||
;; Otherwise, it might happen that new names can NOT be registered anymore. | ||
;; | ||
;; @param namespace; controlled namespace by contract caller | ||
;; @param new-controller; new namespace controller | ||
(define-public (set-namespace-controller (namespace (buff 20)) (new-controller principal)) | ||
(begin | ||
(try! (is-contract-caller-namespace-controller namespace)) | ||
(try! (ft-mint? danger-zone-token u1 tx-sender)) | ||
(try! (ft-burn? danger-zone-token u1 tx-sender)) | ||
(map-set namespace-controller namespace new-controller) | ||
(ok true))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
--- | ||
id: 0 | ||
name: Register helper - mainnet | ||
network: mainnet | ||
stacks-node: "https://stacks-node-api.mainnet.stacks.co" | ||
bitcoin-node: "http://blockstack:blockstacksystem@bitcoin.blockstack.com:8332" | ||
plan: | ||
batches: | ||
- id: 0 | ||
transactions: | ||
- contract-call: | ||
contract-id: SP1JTCR202ECC6333N7ZXD7MK7E3ZTEEE1MJ73C60.bnsx-extensions | ||
method: execute | ||
expected-sender: SP1JTCR202ECC6333N7ZXD7MK7E3ZTEEE1MJ73C60 | ||
cost: 100000 | ||
anchor_block_only: false | ||
parameters: | ||
- "'SP1JTCR202ECC6333N7ZXD7MK7E3ZTEEE1MJ73C60.proposal-migrator-v2" | ||
- "'SP1JTCR202ECC6333N7ZXD7MK7E3ZTEEE1MJ73C60" | ||
- contract-call: | ||
contract-id: SP1JTCR202ECC6333N7ZXD7MK7E3ZTEEE1MJ73C60.wrapper-migrator-v2 | ||
method: execute | ||
expected-sender: SP1JTCR202ECC6333N7ZXD7MK7E3ZTEEE1MJ73C60 | ||
cost: 100000 | ||
anchor_block_only: false | ||
parameters: | ||
- "'SP1JTCR202ECC6333N7ZXD7MK7E3ZTEEE1MJ73C60" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
--- | ||
id: 0 | ||
name: Register helper - mainnet | ||
network: mainnet | ||
stacks-node: "https://stacks-node-api.mainnet.stacks.co" | ||
bitcoin-node: "http://blockstack:blockstacksystem@bitcoin.blockstack.com:8332" | ||
plan: | ||
batches: | ||
- id: 0 | ||
transactions: | ||
- contract-publish: | ||
contract-name: wrapper-migrator-v2 | ||
expected-sender: SP1JTCR202ECC6333N7ZXD7MK7E3ZTEEE1MJ73C60 | ||
cost: 200000 | ||
path: contracts/wrapper-migrator-v2.clar | ||
anchor-block-only: false | ||
clarity-version: 2 | ||
# - contract-publish: | ||
# contract-name: proposal-migrator-v2 | ||
# expected-sender: SP1JTCR202ECC6333N7ZXD7MK7E3ZTEEE1MJ73C60 | ||
# cost: 200000 | ||
# path: contracts/proposals/proposal-migrator-v2.clar | ||
# anchor-block-only: true | ||
# clarity-version: 2 | ||
# - contract-publish: | ||
# contract-name: l1-registry | ||
# expected-sender: SP1JTCR202ECC6333N7ZXD7MK7E3ZTEEE1MJ73C60 | ||
# cost: 200000 | ||
# path: contracts/l1/registry.clar | ||
# anchor-block-only: true | ||
# clarity-version: 2 | ||
- contract-publish: | ||
contract-name: l1-bridge-v1 | ||
expected-sender: SP1JTCR202ECC6333N7ZXD7MK7E3ZTEEE1MJ73C60 | ||
cost: 200000 | ||
path: contracts/l1/bridge-v1.clar | ||
anchor-block-only: false | ||
clarity-version: 2 | ||
# - contract-call: | ||
# contract-id: SP1JTCR202ECC6333N7ZXD7MK7E3ZTEEE1MJ73C60.bnsx-extensions | ||
# method: execute | ||
# expected-sender: SP1JTCR202ECC6333N7ZXD7MK7E3ZTEEE1MJ73C60 | ||
# cost: 100000 | ||
# anchor_block_only: false | ||
# parameters: | ||
# - "'SP1JTCR202ECC6333N7ZXD7MK7E3ZTEEE1MJ73C60.proposal-migrator-v2" | ||
# - "'SP1JTCR202ECC6333N7ZXD7MK7E3ZTEEE1MJ73C60" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
import 'cross-fetch/polyfill'; | ||
import { config } from 'dotenv'; | ||
import { | ||
AnchorMode, | ||
broadcastTransaction, | ||
PostConditionMode, | ||
makeContractCall, | ||
} from 'micro-stacks/transactions'; | ||
import { c32addressDecode } from 'micro-stacks/crypto'; | ||
import { | ||
contracts, | ||
deployer, | ||
getControllerAddress, | ||
getNonce, | ||
network, | ||
networkKey, | ||
} from './script-utils'; | ||
import { bytesToHex, hexToBytes } from 'micro-stacks/common'; | ||
|
||
const migrator = contracts.wrapperMigrator; | ||
|
||
config(); | ||
|
||
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion | ||
const privateKey = process.env.DEPLOYER_KEY!; | ||
|
||
const [signer] = process.argv.slice(2); | ||
|
||
async function run() { | ||
console.log('Network:', networkKey); | ||
console.log('Signer:', signer); | ||
console.log('Migrator:', migrator.identifier); | ||
const controller = getControllerAddress(privateKey); | ||
console.log('Controller:', controller); | ||
console.log('Deployer:', deployer); | ||
|
||
const nonce = await getNonce(); | ||
|
||
const proposalTx = await makeContractCall({ | ||
...contracts.bnsxExtensions.execute(contracts.proposalMigratorV2.identifier, controller), | ||
nonce, | ||
fee: 100000, | ||
network, | ||
senderKey: privateKey, | ||
anchorMode: AnchorMode.Any, | ||
}); | ||
|
||
const migratorTx = await makeContractCall({ | ||
...contracts.wrapperMigratorV2.setSigners([ | ||
{ | ||
signer, | ||
enabled: true, | ||
}, | ||
]), | ||
nonce: nonce + 1, | ||
fee: 100000, | ||
network, | ||
senderKey: privateKey, | ||
anchorMode: AnchorMode.Any, | ||
}); | ||
|
||
const bridgeTx = await makeContractCall({ | ||
...contracts.l1BridgeV1.updateSigner(signer), | ||
nonce: nonce + 2, | ||
fee: 100000, | ||
network, | ||
senderKey: privateKey, | ||
anchorMode: AnchorMode.Any, | ||
}); | ||
|
||
if (networkKey !== 'devnet') { | ||
throw 'Safe exit'; | ||
} | ||
|
||
console.log(await broadcastTransaction(proposalTx, network)); | ||
console.log(await broadcastTransaction(migratorTx, network)); | ||
console.log(await broadcastTransaction(bridgeTx, network)); | ||
} | ||
|
||
run() | ||
.catch(console.error) | ||
.finally(() => { | ||
process.exit(); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.